Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate custom ID generation APIs from Wonder Blocks #2007

Merged
merged 6 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,26 @@ module.exports = {
message:
"Use of React.FC<Props> is disallowed, use the following alternative: https://khanacademy.atlassian.net/wiki/spaces/ENG/pages/2201682693/TypeScript+for+Flow+Developers#Functional-Components",
},
{
selector:
"JSXElement[openingElement.name.name='UniqueIDProvider']",
message:
"DEPRECATED: Use the `Id` Wonder Blocks Core component instead, or migrate to the `useId` React hook.",
},
{
selector: "JSXElement[openingElement.name.name='IDProvider']",
message:
"DEPRECATED: Use the `Id` Wonder Blocks Core component instead, or migrate to the `useId` React hook.",
},
{
selector: "CallExpression[callee.name='useUniqueIdWithMock']",
message: "DEPRECATED: Use the `useId` React hook instead.",
},
{
selector:
"CallExpression[callee.name='useUniqueIdWithoutMock']",
message: "DEPRECATED: Use the `useId` React hook instead.",
},
Comment on lines +292 to +311
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: These are to discourage new uses of the deprecated APIs.

],

/**
Expand Down
2 changes: 2 additions & 0 deletions dev/gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ function capitalize(key: string): string {
}

export function Gallery() {
// TODO(WB-1812, somewhatabstract): Migrate to Id or useId
// eslint-disable-next-line no-restricted-syntax
const ids = useUniqueIdWithMock();
const params = useMemo(
() => new URLSearchParams(window.location.search),
Expand Down
20 changes: 10 additions & 10 deletions dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
"@khanacademy/perseus-linter": "^1.2.5",
"@khanacademy/pure-markdown": "^0.3.14",
"@khanacademy/simple-markdown": "^0.13.7",
"@khanacademy/wonder-blocks-banner": "3.1.7",
"@khanacademy/wonder-blocks-icon": "4.1.3",
"@khanacademy/wonder-blocks-icon-button": "5.3.4",
"@khanacademy/wonder-blocks-link": "6.1.6",
"@khanacademy/wonder-blocks-search-field": "2.2.23",
"@khanacademy/wonder-blocks-timing": "5.0.1",
"@khanacademy/wonder-blocks-tokens": "2.0.0",
"@khanacademy/wonder-blocks-toolbar": "3.0.35",
"@khanacademy/wonder-blocks-tooltip": "2.4.0",
"@khanacademy/wonder-stuff-core": "1.5.2",
"@khanacademy/wonder-blocks-banner": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-icon": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-icon-button": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-link": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-search-field": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-timing": "6.0.0",
"@khanacademy/wonder-blocks-tokens": "3.0.0",
"@khanacademy/wonder-blocks-toolbar": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-tooltip": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-stuff-core": "1.5.4",
"@phosphor-icons/core": "^2.0.2"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
"@jest/globals": "^29.7.0",
"@khanacademy/eslint-config": "^4.0.0",
"@khanacademy/eslint-plugin": "^3.0.1",
"@khanacademy/mathjax-renderer": "^2.1.0",
"@khanacademy/wonder-blocks-button": "6.3.8",
"@khanacademy/wonder-blocks-layout": "2.1.3",
"@khanacademy/mathjax-renderer": "^2.1.1",
"@khanacademy/wonder-blocks-button": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-layout": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-spacing": "^4.0.1",
"@popperjs/core": "^2.10.2",
"@rollup/plugin-alias": "^3.1.9",
Expand Down Expand Up @@ -109,7 +109,7 @@
"react-router": "5.3.4",
"react-router-dom": "5.3.4",
"react-transition-group": "^4.4.1",
"react-window": "^1.8.5",
"react-window": "^1.8.10",
"rollup": "^2.70.2",
"rollup-plugin-auto-external": "^2.0.0",
"rollup-plugin-executable-output": "^1.3.0",
Expand Down
28 changes: 14 additions & 14 deletions packages/math-input/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
"mathquill": "https://github.com/Khan/mathquill/releases/download/v1.0.0/mathquill-v1.0.0.tgz"
},
"devDependencies": {
"@khanacademy/mathjax-renderer": "^2.1.0",
"@khanacademy/wonder-blocks-clickable": "4.2.6",
"@khanacademy/wonder-blocks-core": "6.4.3",
"@khanacademy/wonder-blocks-popover": "3.2.13",
"@khanacademy/wonder-blocks-timing": "5.0.1",
"@khanacademy/wonder-blocks-tokens": "2.0.0",
"@khanacademy/wonder-stuff-core": "1.5.2",
"@khanacademy/mathjax-renderer": "^2.1.1",
"@khanacademy/wonder-blocks-clickable": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-core": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-popover": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-timing": "6.0.0",
"@khanacademy/wonder-blocks-tokens": "3.0.0",
"@khanacademy/wonder-stuff-core": "1.5.4",
"@phosphor-icons/core": "^2.0.2",
"aphrodite": "^1.2.5",
"jquery": "^2.1.1",
Expand All @@ -61,13 +61,13 @@
"react-transition-group": "^4.4.1"
},
"peerDependencies": {
"@khanacademy/mathjax-renderer": "^2.1.0",
"@khanacademy/wonder-blocks-clickable": "4.2.6",
"@khanacademy/wonder-blocks-core": "6.4.3",
"@khanacademy/wonder-blocks-popover": "3.2.13",
"@khanacademy/wonder-blocks-timing": "5.0.1",
"@khanacademy/wonder-blocks-tokens": "2.0.0",
"@khanacademy/wonder-stuff-core": "1.5.2",
"@khanacademy/mathjax-renderer": "^2.1.1",
"@khanacademy/wonder-blocks-clickable": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-core": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-popover": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-timing": "6.0.0",
"@khanacademy/wonder-blocks-tokens": "3.0.0",
"@khanacademy/wonder-stuff-core": "1.5.4",
"@phosphor-icons/core": "^2.0.2",
"aphrodite": "^1.2.5",
"jquery": "^2.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"dependencies": {},
"devDependencies": {
"@khanacademy/wonder-stuff-core": "1.5.2"
"@khanacademy/wonder-stuff-core": "1.5.4"
},
"peerDependencies": {},
"keywords": []
Expand Down
60 changes: 30 additions & 30 deletions packages/perseus-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@
},
"devDependencies": {
"@khanacademy/perseus-linter": "^1.2.5",
"@khanacademy/wonder-blocks-accordion": "1.3.6",
"@khanacademy/wonder-blocks-banner": "3.1.7",
"@khanacademy/wonder-blocks-button": "6.3.8",
"@khanacademy/wonder-blocks-clickable": "4.2.6",
"@khanacademy/wonder-blocks-core": "6.4.3",
"@khanacademy/wonder-blocks-dropdown": "5.4.5",
"@khanacademy/wonder-blocks-form": "4.9.0",
"@khanacademy/wonder-blocks-icon": "4.1.3",
"@khanacademy/wonder-blocks-icon-button": "5.3.4",
"@khanacademy/wonder-blocks-switch": "1.1.20",
"@khanacademy/wonder-blocks-timing": "5.0.1",
"@khanacademy/wonder-blocks-tokens": "2.0.0",
"@khanacademy/wonder-blocks-tooltip": "2.4.0",
"@khanacademy/wonder-blocks-typography": "2.1.14",
"@khanacademy/wonder-stuff-core": "1.5.2",
"@khanacademy/wonder-blocks-accordion": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-banner": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-button": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-clickable": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-core": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-dropdown": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-form": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-icon": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-icon-button": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-switch": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-timing": "6.0.0",
"@khanacademy/wonder-blocks-tokens": "3.0.0",
"@khanacademy/wonder-blocks-tooltip": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-typography": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-stuff-core": "1.5.4",
"@phosphor-icons/core": "^2.0.2",
"aphrodite": "^1.2.5",
"classnames": "1.1.4",
Expand All @@ -73,21 +73,21 @@
"underscore": "^1.4.4"
},
"peerDependencies": {
"@khanacademy/wonder-blocks-accordion": "1.3.6",
"@khanacademy/wonder-blocks-banner": "3.1.7",
"@khanacademy/wonder-blocks-button": "6.3.8",
"@khanacademy/wonder-blocks-clickable": "4.2.6",
"@khanacademy/wonder-blocks-core": "6.4.3",
"@khanacademy/wonder-blocks-dropdown": "5.4.5",
"@khanacademy/wonder-blocks-form": "4.9.0",
"@khanacademy/wonder-blocks-icon": "4.1.3",
"@khanacademy/wonder-blocks-icon-button": "5.3.4",
"@khanacademy/wonder-blocks-switch": "1.1.20",
"@khanacademy/wonder-blocks-timing": "5.0.1",
"@khanacademy/wonder-blocks-tokens": "2.0.0",
"@khanacademy/wonder-blocks-tooltip": "2.4.0",
"@khanacademy/wonder-blocks-typography": "2.1.14",
"@khanacademy/wonder-stuff-core": "1.5.2",
"@khanacademy/wonder-blocks-accordion": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-banner": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-button": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-clickable": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-core": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-dropdown": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-form": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-icon": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-icon-button": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-switch": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-timing": "6.0.0",
"@khanacademy/wonder-blocks-tokens": "3.0.0",
"@khanacademy/wonder-blocks-tooltip": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-typography": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-stuff-core": "1.5.4",
"@phosphor-icons/core": "^2.0.2",
"aphrodite": "^1.2.5",
"classnames": "1.1.4",
Expand Down
2 changes: 2 additions & 0 deletions packages/perseus-editor/src/components/widget-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ function LabeledSwitch(props: {
onChange: (value: boolean) => unknown;
}) {
const {label, ...switchProps} = props;
// TODO(WB-1812, somewhatabstract): Migrate to Id or useId
// eslint-disable-next-line no-restricted-syntax
const ids = useUniqueIdWithMock();
const id = ids.get("switch");
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type Props = {
const LabeledSwitch = (props: Props) => {
const {checked, label, style, onChange} = props;

// TODO(WB-1812, somewhatabstract): Migrate to Id or useId
// eslint-disable-next-line no-restricted-syntax
const ids = useUniqueIdWithMock();
const switchId = ids.get("switch");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const LockedFiguresSection = (props: Props) => {

const [isExpanded, setIsExpanded] = React.useState(true);

// TODO(WB-1812, somewhatabstract): Migrate to Id or useId
// eslint-disable-next-line no-restricted-syntax
const uniqueId = useUniqueIdWithMock().get("locked-figures-section");
const {figures, onChange} = props;

Expand Down
78 changes: 39 additions & 39 deletions packages/perseus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,25 @@
"uuid": "^10.0.0"
},
"devDependencies": {
"@khanacademy/wonder-blocks-banner": "3.1.7",
"@khanacademy/wonder-blocks-button": "6.3.8",
"@khanacademy/wonder-blocks-clickable": "4.2.6",
"@khanacademy/wonder-blocks-core": "6.4.3",
"@khanacademy/wonder-blocks-data": "13.0.10",
"@khanacademy/wonder-blocks-dropdown": "5.4.5",
"@khanacademy/wonder-blocks-form": "4.9.0",
"@khanacademy/wonder-blocks-icon": "4.1.3",
"@khanacademy/wonder-blocks-icon-button": "5.3.4",
"@khanacademy/wonder-blocks-layout": "2.1.3",
"@khanacademy/wonder-blocks-link": "6.1.6",
"@khanacademy/wonder-blocks-pill": "2.4.5",
"@khanacademy/wonder-blocks-popover": "3.2.13",
"@khanacademy/wonder-blocks-progress-spinner": "2.1.5",
"@khanacademy/wonder-blocks-switch": "1.1.20",
"@khanacademy/wonder-blocks-tokens": "2.0.1",
"@khanacademy/wonder-blocks-tooltip": "2.4.0",
"@khanacademy/wonder-blocks-typography": "2.1.14",
"@khanacademy/wonder-stuff-core": "1.5.2",
"@khanacademy/wonder-blocks-banner": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-button": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-clickable": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-core": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-data": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-dropdown": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-form": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-icon": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-icon-button": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-layout": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-link": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-pill": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-popover": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-progress-spinner": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-switch": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-tokens": "3.0.0",
"@khanacademy/wonder-blocks-tooltip": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-typography": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-stuff-core": "1.5.4",
"@phosphor-icons/core": "^2.0.2",
"@popperjs/core": "^2.10.2",
"aphrodite": "^1.2.5",
Expand All @@ -90,25 +90,25 @@
"underscore": "^1.4.4"
},
"peerDependencies": {
"@khanacademy/wonder-blocks-banner": "3.1.7",
"@khanacademy/wonder-blocks-button": "6.3.8",
"@khanacademy/wonder-blocks-clickable": "4.2.6",
"@khanacademy/wonder-blocks-core": "6.4.3",
"@khanacademy/wonder-blocks-data": "13.0.10",
"@khanacademy/wonder-blocks-dropdown": "5.4.5",
"@khanacademy/wonder-blocks-form": "4.9.0",
"@khanacademy/wonder-blocks-icon": "4.1.3",
"@khanacademy/wonder-blocks-icon-button": "5.3.4",
"@khanacademy/wonder-blocks-layout": "2.1.3",
"@khanacademy/wonder-blocks-link": "6.1.6",
"@khanacademy/wonder-blocks-pill": "2.4.5",
"@khanacademy/wonder-blocks-popover": "3.2.13",
"@khanacademy/wonder-blocks-progress-spinner": "2.1.5",
"@khanacademy/wonder-blocks-switch": "1.1.20",
"@khanacademy/wonder-blocks-tokens": "2.0.1",
"@khanacademy/wonder-blocks-tooltip": "2.4.0",
"@khanacademy/wonder-blocks-typography": "2.1.14",
"@khanacademy/wonder-stuff-core": "1.5.2",
"@khanacademy/wonder-blocks-banner": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-button": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-clickable": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-core": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-data": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-dropdown": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-form": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-icon": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-icon-button": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-layout": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-link": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-pill": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-popover": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-progress-spinner": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-switch": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-tokens": "3.0.0",
"@khanacademy/wonder-blocks-tooltip": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-blocks-typography": "0.0.0-PR2391-20241213201047",
"@khanacademy/wonder-stuff-core": "1.5.4",
"@phosphor-icons/core": "^2.0.2",
"@popperjs/core": "^2.10.2",
"aphrodite": "^1.2.5",
Expand All @@ -124,4 +124,4 @@
"underscore": "^1.4.4"
},
"keywords": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ exports[`renderer snapshots correct answer: correct answer 1`] = `
>
<label
class="text_f1191h-o_O-LabelLarge_5s82ln"
for="uid-dropdown-widget-2-dropdown"
for="uid-dropdown-widget-1-dropdown"
>
Test visible label
</label>
Expand All @@ -365,13 +365,14 @@ exports[`renderer snapshots correct answer: correct answer 1`] = `
data-testid="dropdown-live-region"
/>
<button
aria-controls="uid-single-select-dropdown-3-wb-id"
aria-controls=":r2:"
aria-disabled="false"
aria-expanded="false"
aria-haspopup="listbox"
aria-invalid="false"
aria-label="Test ARIA label"
class="button_vr44p2-o_O-shared_u51dsh-o_O-default_3ie67y"
id="uid-dropdown-widget-2-dropdown"
id="uid-dropdown-widget-1-dropdown"
role="combobox"
type="button"
>
Expand Down Expand Up @@ -428,7 +429,7 @@ exports[`renderer snapshots incorrect answer: incorrect answer 1`] = `
>
<label
class="text_f1191h-o_O-LabelLarge_5s82ln"
for="uid-dropdown-widget-4-dropdown"
for="uid-dropdown-widget-2-dropdown"
>
Test visible label
</label>
Expand All @@ -443,13 +444,14 @@ exports[`renderer snapshots incorrect answer: incorrect answer 1`] = `
data-testid="dropdown-live-region"
/>
<button
aria-controls="uid-single-select-dropdown-5-wb-id"
aria-controls=":r4:"
aria-disabled="false"
aria-expanded="false"
aria-haspopup="listbox"
aria-invalid="false"
aria-label="Test ARIA label"
class="button_vr44p2-o_O-shared_u51dsh-o_O-default_3ie67y"
id="uid-dropdown-widget-4-dropdown"
id="uid-dropdown-widget-2-dropdown"
role="combobox"
type="button"
>
Expand Down Expand Up @@ -521,10 +523,11 @@ exports[`renderer snapshots initial render: initial render 1`] = `
data-testid="dropdown-live-region"
/>
<button
aria-controls="uid-single-select-dropdown-1-wb-id"
aria-controls=":r0:"
aria-disabled="false"
aria-expanded="false"
aria-haspopup="listbox"
aria-invalid="false"
aria-label="Test ARIA label"
class="button_vr44p2-o_O-shared_u51dsh-o_O-default_3ie67y"
id="uid-dropdown-widget-0-dropdown"
Expand Down
Loading
Loading