Skip to content

Commit 0103ee8

Browse files
authored
Merge branch 'develop' into dependabot/npm_and_yarn/min-document-2.19.1
2 parents b42dd16 + 6108c60 commit 0103ee8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+681
-466
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ I have verified that this pull request:
66

77
* [ ] has no linting errors (`npm run lint`)
88
* [ ] has no test errors (`npm run test`)
9+
* [ ] has no typecheck errors (`npm run typecheck`)
910
* [ ] is from a uniquely-named feature branch and is up to date with the `develop` branch.
1011
* [ ] is descriptively named and links to an issue number, i.e. `Fixes #123`
1112
* [ ] meets the standards outlined in the [accessibility guidelines](https://github.com/processing/p5.js-web-editor/blob/develop/contributor_docs/accessibility.md)

client/common/Button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export interface ButtonProps extends React.HTMLAttributes<HTMLElement> {
8080
/**
8181
* If using a native button, specifies on an onClick action
8282
*/
83-
onClick?: () => void;
83+
onClick?: (evt: React.MouseEvent<HTMLButtonElement>) => void;
8484
/**
8585
* If using a button, then type is defines the type of button
8686
*/

client/common/useSyncFormTranslations.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
import { useEffect, MutableRefObject } from 'react';
2+
import type { FormApi } from 'final-form';
23

3-
export interface FormLike {
4-
getState(): { values: Record<string, unknown> };
5-
reset(): void;
6-
change(field: string, value: unknown): void;
7-
}
4+
// Generic FormLike that mirrors FormApi for any form value type
5+
export interface FormLike<FormValues = Record<string, unknown>>
6+
extends Pick<FormApi<FormValues>, 'getState' | 'reset' | 'change'> {}
87

98
/**
109
* This hook ensures that form values are preserved when the language changes.
1110
* @param formRef
1211
* @param language
1312
*/
14-
export const useSyncFormTranslations = (
15-
formRef: MutableRefObject<FormLike>,
13+
export const useSyncFormTranslations = <FormValues extends Record<string, any>>(
14+
formRef: MutableRefObject<FormLike<FormValues> | null>,
1615
language: string
1716
) => {
1817
useEffect(() => {
19-
const form = formRef.current;
18+
const form = formRef?.current;
2019
if (!form) return;
2120

2221
const { values } = form.getState();
2322
form.reset();
2423

25-
Object.keys(values).forEach((field) => {
26-
if (values[field]) {
27-
form.change(field, values[field]);
24+
(Object.keys(values) as (keyof FormValues)[]).forEach((field) => {
25+
const value = values[field];
26+
if (value !== undefined && value !== null && value !== '') {
27+
form.change(field, value);
2828
}
2929
});
3030
}, [language]);

client/modules/App/App.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { showReduxDevTools } from '../../store';
66
import DevTools from './components/DevTools';
77
import { setPreviousPath } from '../IDE/actions/ide';
88
import { setLanguage } from '../IDE/actions/preferences';
9-
import CookieConsent from '../User/components/CookieConsent';
9+
import { CookieConsent } from '../User/components/CookieConsent';
1010

1111
function hideCookieConsent(pathname) {
1212
if (pathname.includes('/full/') || pathname.includes('/embed/')) {

client/modules/IDE/actions/preferences.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import type {
66
UpdatePreferencesDispatch,
77
SetPreferencesTabValue,
88
SetFontSizeValue,
9-
GetRootState,
109
SetLineNumbersValue,
1110
SetAutocloseBracketsQuotesValue,
1211
SetAutocompleteHinterValue,
@@ -20,6 +19,7 @@ import type {
2019
SetLanguageValue,
2120
SetThemeValue
2221
} from './preferences.types';
22+
import type { GetRootState } from '../../../reducers';
2323

2424
function updatePreferences(
2525
formParams: UpdatePreferencesRequestBody,

client/modules/IDE/actions/preferences.types.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as ActionTypes from '../../../constants';
22
import type { PreferencesState } from '../reducers/preferences';
3-
import type { RootState } from '../../../reducers';
3+
import type { GetRootState } from '../../../reducers';
44

55
// Value Definitions:
66
export type SetPreferencesTabValue = PreferencesState['tabIndex'];
@@ -112,5 +112,3 @@ export type PreferencesThunk = (
112112
dispatch: UpdatePreferencesDispatch,
113113
getState: GetRootState
114114
) => void;
115-
116-
export type GetRootState = () => RootState;

client/modules/IDE/components/Header/Toolbar.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import StopIcon from '../../../../images/stop.svg';
2020
import PreferencesIcon from '../../../../images/preferences.svg';
2121
import ProjectName from './ProjectName';
2222
import VersionIndicator from '../VersionIndicator';
23-
import VisibilityDropdown from '../../../User/components/VisibilityDropdown';
23+
import { VisibilityDropdown } from '../../../User/components/VisibilityDropdown';
2424
import { changeVisibility } from '../../actions/project';
2525

2626
const Toolbar = (props) => {

client/modules/IDE/components/SketchListRowBase.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { TableDropdown } from '../../../components/Dropdown/TableDropdown';
1010
import { MenuItem } from '../../../components/Dropdown/MenuItem';
1111
import { formatDateToString } from '../../../utils/formatDate';
1212
import { getConfig } from '../../../utils/getConfig';
13-
import VisibilityDropdown from '../../User/components/VisibilityDropdown';
13+
import { VisibilityDropdown } from '../../User/components/VisibilityDropdown';
1414

1515
const ROOT_URL = getConfig('API_URL');
1616

client/modules/IDE/components/VersionPicker.jsx

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,23 @@ const VersionPicker = React.forwardRef(({ onChangeVersion }, ref) => {
7777
return (
7878
<VersionDropdownMenu
7979
className="versionPicker"
80+
aria-label="Select p5.js version"
8081
anchor={
8182
<VersionPickerButton ref={ref}>
82-
<VersionPickerText>{versionInfo.version}</VersionPickerText>
83+
<VersionPickerText>
84+
{versionInfo
85+
? (() => {
86+
const current = p5Versions.find((v) =>
87+
typeof v === 'string'
88+
? v === versionInfo.version
89+
: v.version === versionInfo.version
90+
);
91+
if (!current) return versionInfo.version;
92+
if (typeof current === 'string') return current;
93+
return `${current.version} ${current.label}`;
94+
})()
95+
: t('Toolbar.CustomLibraryVersion')}
96+
</VersionPickerText>
8397
<VersionPickerArrow>
8498
<DropdownArrowIcon />
8599
</VersionPickerArrow>
@@ -88,11 +102,20 @@ const VersionPicker = React.forwardRef(({ onChangeVersion }, ref) => {
88102
align="left"
89103
maxHeight="50vh"
90104
>
91-
{p5Versions.map((version) => (
92-
<MenuItem key={version} onClick={() => dispatchReplaceVersion(version)}>
93-
{version}
94-
</MenuItem>
95-
))}
105+
{p5Versions.map((item) => {
106+
const version = typeof item === 'string' ? item : item.version;
107+
const label =
108+
typeof item === 'string' ? item : `${item.version} ${item.label}`;
109+
110+
return (
111+
<MenuItem
112+
key={version}
113+
onClick={() => dispatchReplaceVersion(version)}
114+
>
115+
{label}
116+
</MenuItem>
117+
);
118+
})}
96119
</VersionDropdownMenu>
97120
);
98121
});

client/modules/IDE/hooks/useP5Version.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ export function P5VersionProvider(props) {
6060
if (!match) return null;
6161

6262
// See if this is a version we recognize
63-
if (p5Versions.includes(match[1])) {
63+
const versionExists = p5Versions.some((v) =>
64+
typeof v === 'string' ? v === match[1] : v.version === match[1]
65+
);
66+
if (versionExists) {
6467
return { version: match[1], minified: !!match[2], scriptNode };
6568
}
6669
return null;

0 commit comments

Comments
 (0)