@khanacademy/wonder-blocks-dropdown 6.1.2 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @khanacademy/wonder-blocks-dropdown
2
2
 
3
+ ## 7.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 56d961f1: - Migrate Wonder Blocks components off old id providers and onto new `Id` component
8
+
9
+ ### Patch Changes
10
+
11
+ - b6009b77: Deprecate the ID provider and unique ID utilities
12
+ - Updated dependencies [b6009b77]
13
+ - Updated dependencies [897686bc]
14
+ - Updated dependencies [56d961f1]
15
+ - @khanacademy/wonder-blocks-core@10.0.0
16
+ - @khanacademy/wonder-blocks-search-field@4.0.0
17
+ - @khanacademy/wonder-blocks-modal@7.0.0
18
+ - @khanacademy/wonder-blocks-cell@4.0.2
19
+ - @khanacademy/wonder-blocks-clickable@5.0.2
20
+ - @khanacademy/wonder-blocks-icon@5.0.2
21
+ - @khanacademy/wonder-blocks-layout@3.0.2
22
+ - @khanacademy/wonder-blocks-pill@3.0.2
23
+ - @khanacademy/wonder-blocks-typography@3.0.2
24
+
3
25
  ## 6.1.2
4
26
 
5
27
  ### Patch Changes
package/dist/es/index.js CHANGED
@@ -1,12 +1,13 @@
1
1
  import _extends from '@babel/runtime/helpers/extends';
2
2
  import * as React from 'react';
3
+ import { useId } from 'react';
3
4
  import { StyleSheet } from 'aphrodite';
4
5
  import { CompactCell, DetailCell } from '@khanacademy/wonder-blocks-cell';
5
6
  import * as tokens from '@khanacademy/wonder-blocks-tokens';
6
7
  import { spacing, color, mix, fade, font, border, semanticColor } from '@khanacademy/wonder-blocks-tokens';
7
8
  import { LabelMedium, LabelSmall, LabelLarge } from '@khanacademy/wonder-blocks-typography';
8
9
  import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/objectWithoutPropertiesLoose';
9
- import { View, addStyle, IDProvider, useOnMountEffect, useUniqueIdWithMock } from '@khanacademy/wonder-blocks-core';
10
+ import { View, addStyle, Id, useOnMountEffect } from '@khanacademy/wonder-blocks-core';
10
11
  import { Strut } from '@khanacademy/wonder-blocks-layout';
11
12
  import { PhosphorIcon } from '@khanacademy/wonder-blocks-icon';
12
13
  import checkIcon from '@phosphor-icons/core/bold/check-bold.svg';
@@ -1612,9 +1613,8 @@ class ActionMenu extends React.Component {
1612
1613
  testId,
1613
1614
  id
1614
1615
  } = this.props;
1615
- return React.createElement(IDProvider, {
1616
- id: id,
1617
- scope: "action-menu-opener"
1616
+ return React.createElement(Id, {
1617
+ id: id
1618
1618
  }, uniqueOpenerId => React.createElement(DropdownOpener, {
1619
1619
  id: uniqueOpenerId,
1620
1620
  "aria-controls": dropdownId,
@@ -1646,9 +1646,8 @@ class ActionMenu extends React.Component {
1646
1646
  dropdownId
1647
1647
  } = this.props;
1648
1648
  const items = this.getMenuItems();
1649
- return React.createElement(IDProvider, {
1650
- id: dropdownId,
1651
- scope: "action-menu-dropdown"
1649
+ return React.createElement(Id, {
1650
+ id: dropdownId
1652
1651
  }, uniqueDropdownId => React.createElement(DropdownCore$1, {
1653
1652
  id: uniqueDropdownId,
1654
1653
  role: "menu",
@@ -2099,9 +2098,8 @@ const SingleSelect = props => {
2099
2098
  const items = React.Children.toArray(children);
2100
2099
  const selectedItem = items.find(option => option.props.value === selectedValue);
2101
2100
  const menuText = selectedItem ? getSelectOpenerLabel(showOpenerLabelAsText, selectedItem.props) : placeholder;
2102
- const dropdownOpener = React.createElement(IDProvider, {
2103
- id: id,
2104
- scope: "single-select-opener"
2101
+ const dropdownOpener = React.createElement(Id, {
2102
+ id: id
2105
2103
  }, uniqueOpenerId => {
2106
2104
  return opener ? React.createElement(DropdownOpener, {
2107
2105
  id: uniqueOpenerId,
@@ -2134,9 +2132,8 @@ const SingleSelect = props => {
2134
2132
  const numEnabledOptions = allChildren.filter(option => !option.props.disabled).length;
2135
2133
  const items = getMenuItems(allChildren);
2136
2134
  const isDisabled = numEnabledOptions === 0 || disabled;
2137
- return React.createElement(IDProvider, {
2138
- id: dropdownId,
2139
- scope: "single-select-dropdown"
2135
+ return React.createElement(Id, {
2136
+ id: dropdownId
2140
2137
  }, uniqueDropdownId => React.createElement(DropdownCore$1, {
2141
2138
  id: uniqueDropdownId,
2142
2139
  role: "listbox",
@@ -2382,9 +2379,8 @@ const MultiSelect = props => {
2382
2379
  noneSelected
2383
2380
  } = labels;
2384
2381
  const menuText = getMenuText(allChildren);
2385
- const dropdownOpener = React.createElement(IDProvider, {
2386
- id: id,
2387
- scope: "multi-select-opener"
2382
+ const dropdownOpener = React.createElement(Id, {
2383
+ id: id
2388
2384
  }, uniqueOpenerId => {
2389
2385
  return opener ? React.createElement(DropdownOpener, {
2390
2386
  id: uniqueOpenerId,
@@ -2423,9 +2419,8 @@ const MultiSelect = props => {
2423
2419
  const numEnabledOptions = allChildren.filter(option => !option.props.disabled).length;
2424
2420
  const filteredItems = getMenuItems(allChildren);
2425
2421
  const isDisabled = numEnabledOptions === 0 || disabled;
2426
- return React.createElement(IDProvider, {
2427
- id: dropdownId,
2428
- scope: "multi-select-dropdown"
2422
+ return React.createElement(Id, {
2423
+ id: dropdownId
2429
2424
  }, uniqueDropdownId => React.createElement(DropdownCore$1, {
2430
2425
  id: uniqueDropdownId,
2431
2426
  role: "listbox",
@@ -2824,8 +2819,8 @@ function StandaloneListbox(props) {
2824
2819
  "aria-label": ariaLabel,
2825
2820
  "aria-labelledby": ariaLabelledby
2826
2821
  } = props;
2827
- const ids = useUniqueIdWithMock("listbox");
2828
- const uniqueId = id != null ? id : ids.get("id");
2822
+ const generatedUniqueId = useId();
2823
+ const uniqueId = id != null ? id : generatedUniqueId;
2829
2824
  const {
2830
2825
  focusedIndex,
2831
2826
  isListboxFocused,
@@ -2917,8 +2912,8 @@ function Combobox({
2917
2912
  value = ""
2918
2913
  }) {
2919
2914
  var _renderList$find, _renderList$focusedIn, _renderList$focusedIn2;
2920
- const ids = useUniqueIdWithMock("combobox");
2921
- const uniqueId = id != null ? id : ids.get("listbox");
2915
+ const generatedUniqueId = useId();
2916
+ const uniqueId = id != null ? id : generatedUniqueId;
2922
2917
  const comboboxRef = React.useRef(null);
2923
2918
  const rootNodeRef = React.useRef(null);
2924
2919
  const [open, setOpen] = React.useState(opened != null ? opened : false);
@@ -3070,7 +3065,8 @@ function Combobox({
3070
3065
  style: styles.iconWrapper
3071
3066
  }, startIconElement);
3072
3067
  };
3073
- const pillIdPrefix = id ? `${id}-pill-` : ids.get("pill");
3068
+ const pillIdPrefix = `${uniqueId}-pill-`;
3069
+ const textFieldId = useId();
3074
3070
  const currentActiveDescendant = !openState ? undefined : focusedIndex >= 0 ? (_renderList$focusedIn = renderList[focusedIndex]) == null ? void 0 : (_renderList$focusedIn2 = _renderList$focusedIn.props) == null ? void 0 : _renderList$focusedIn2.id : pillIdPrefix + focusedMultiSelectIndex;
3075
3071
  const controlledWidget = !openState ? undefined : focusedIndex >= 0 ? uniqueId : pillIdPrefix;
3076
3072
  return React.createElement(React.Fragment, null, React.createElement(View, {
@@ -3099,7 +3095,7 @@ function Combobox({
3099
3095
  testId: testId,
3100
3096
  removeSelectedLabel: labels.removeSelected
3101
3097
  }), maybeRenderStartIcon(), React.createElement(TextField, {
3102
- id: ids.get("input"),
3098
+ id: textFieldId,
3103
3099
  testId: testId,
3104
3100
  style: styles.combobox,
3105
3101
  value: inputValue,
@@ -3168,7 +3164,7 @@ function Combobox({
3168
3164
  }],
3169
3165
  testId: testId ? `${testId}-listbox` : undefined,
3170
3166
  "aria-label": labels.listbox,
3171
- "aria-labelledby": ids.get("input")
3167
+ "aria-labelledby": textFieldId
3172
3168
  }, renderList));
3173
3169
  }));
3174
3170
  }
package/dist/index.js CHANGED
@@ -1648,9 +1648,8 @@ class ActionMenu extends React__namespace.Component {
1648
1648
  testId,
1649
1649
  id
1650
1650
  } = this.props;
1651
- return React__namespace.createElement(wonderBlocksCore.IDProvider, {
1652
- id: id,
1653
- scope: "action-menu-opener"
1651
+ return React__namespace.createElement(wonderBlocksCore.Id, {
1652
+ id: id
1654
1653
  }, uniqueOpenerId => React__namespace.createElement(DropdownOpener, {
1655
1654
  id: uniqueOpenerId,
1656
1655
  "aria-controls": dropdownId,
@@ -1682,9 +1681,8 @@ class ActionMenu extends React__namespace.Component {
1682
1681
  dropdownId
1683
1682
  } = this.props;
1684
1683
  const items = this.getMenuItems();
1685
- return React__namespace.createElement(wonderBlocksCore.IDProvider, {
1686
- id: dropdownId,
1687
- scope: "action-menu-dropdown"
1684
+ return React__namespace.createElement(wonderBlocksCore.Id, {
1685
+ id: dropdownId
1688
1686
  }, uniqueDropdownId => React__namespace.createElement(DropdownCore$1, {
1689
1687
  id: uniqueDropdownId,
1690
1688
  role: "menu",
@@ -2135,9 +2133,8 @@ const SingleSelect = props => {
2135
2133
  const items = React__namespace.Children.toArray(children);
2136
2134
  const selectedItem = items.find(option => option.props.value === selectedValue);
2137
2135
  const menuText = selectedItem ? getSelectOpenerLabel(showOpenerLabelAsText, selectedItem.props) : placeholder;
2138
- const dropdownOpener = React__namespace.createElement(wonderBlocksCore.IDProvider, {
2139
- id: id,
2140
- scope: "single-select-opener"
2136
+ const dropdownOpener = React__namespace.createElement(wonderBlocksCore.Id, {
2137
+ id: id
2141
2138
  }, uniqueOpenerId => {
2142
2139
  return opener ? React__namespace.createElement(DropdownOpener, {
2143
2140
  id: uniqueOpenerId,
@@ -2170,9 +2167,8 @@ const SingleSelect = props => {
2170
2167
  const numEnabledOptions = allChildren.filter(option => !option.props.disabled).length;
2171
2168
  const items = getMenuItems(allChildren);
2172
2169
  const isDisabled = numEnabledOptions === 0 || disabled;
2173
- return React__namespace.createElement(wonderBlocksCore.IDProvider, {
2174
- id: dropdownId,
2175
- scope: "single-select-dropdown"
2170
+ return React__namespace.createElement(wonderBlocksCore.Id, {
2171
+ id: dropdownId
2176
2172
  }, uniqueDropdownId => React__namespace.createElement(DropdownCore$1, {
2177
2173
  id: uniqueDropdownId,
2178
2174
  role: "listbox",
@@ -2418,9 +2414,8 @@ const MultiSelect = props => {
2418
2414
  noneSelected
2419
2415
  } = labels;
2420
2416
  const menuText = getMenuText(allChildren);
2421
- const dropdownOpener = React__namespace.createElement(wonderBlocksCore.IDProvider, {
2422
- id: id,
2423
- scope: "multi-select-opener"
2417
+ const dropdownOpener = React__namespace.createElement(wonderBlocksCore.Id, {
2418
+ id: id
2424
2419
  }, uniqueOpenerId => {
2425
2420
  return opener ? React__namespace.createElement(DropdownOpener, {
2426
2421
  id: uniqueOpenerId,
@@ -2459,9 +2454,8 @@ const MultiSelect = props => {
2459
2454
  const numEnabledOptions = allChildren.filter(option => !option.props.disabled).length;
2460
2455
  const filteredItems = getMenuItems(allChildren);
2461
2456
  const isDisabled = numEnabledOptions === 0 || disabled;
2462
- return React__namespace.createElement(wonderBlocksCore.IDProvider, {
2463
- id: dropdownId,
2464
- scope: "multi-select-dropdown"
2457
+ return React__namespace.createElement(wonderBlocksCore.Id, {
2458
+ id: dropdownId
2465
2459
  }, uniqueDropdownId => React__namespace.createElement(DropdownCore$1, {
2466
2460
  id: uniqueDropdownId,
2467
2461
  role: "listbox",
@@ -2860,8 +2854,8 @@ function StandaloneListbox(props) {
2860
2854
  "aria-label": ariaLabel,
2861
2855
  "aria-labelledby": ariaLabelledby
2862
2856
  } = props;
2863
- const ids = wonderBlocksCore.useUniqueIdWithMock("listbox");
2864
- const uniqueId = id != null ? id : ids.get("id");
2857
+ const generatedUniqueId = React.useId();
2858
+ const uniqueId = id != null ? id : generatedUniqueId;
2865
2859
  const {
2866
2860
  focusedIndex,
2867
2861
  isListboxFocused,
@@ -2953,8 +2947,8 @@ function Combobox({
2953
2947
  value = ""
2954
2948
  }) {
2955
2949
  var _renderList$find, _renderList$focusedIn, _renderList$focusedIn2;
2956
- const ids = wonderBlocksCore.useUniqueIdWithMock("combobox");
2957
- const uniqueId = id != null ? id : ids.get("listbox");
2950
+ const generatedUniqueId = React.useId();
2951
+ const uniqueId = id != null ? id : generatedUniqueId;
2958
2952
  const comboboxRef = React__namespace.useRef(null);
2959
2953
  const rootNodeRef = React__namespace.useRef(null);
2960
2954
  const [open, setOpen] = React__namespace.useState(opened != null ? opened : false);
@@ -3106,7 +3100,8 @@ function Combobox({
3106
3100
  style: styles.iconWrapper
3107
3101
  }, startIconElement);
3108
3102
  };
3109
- const pillIdPrefix = id ? `${id}-pill-` : ids.get("pill");
3103
+ const pillIdPrefix = `${uniqueId}-pill-`;
3104
+ const textFieldId = React.useId();
3110
3105
  const currentActiveDescendant = !openState ? undefined : focusedIndex >= 0 ? (_renderList$focusedIn = renderList[focusedIndex]) == null ? void 0 : (_renderList$focusedIn2 = _renderList$focusedIn.props) == null ? void 0 : _renderList$focusedIn2.id : pillIdPrefix + focusedMultiSelectIndex;
3111
3106
  const controlledWidget = !openState ? undefined : focusedIndex >= 0 ? uniqueId : pillIdPrefix;
3112
3107
  return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(wonderBlocksCore.View, {
@@ -3135,7 +3130,7 @@ function Combobox({
3135
3130
  testId: testId,
3136
3131
  removeSelectedLabel: labels.removeSelected
3137
3132
  }), maybeRenderStartIcon(), React__namespace.createElement(wonderBlocksForm.TextField, {
3138
- id: ids.get("input"),
3133
+ id: textFieldId,
3139
3134
  testId: testId,
3140
3135
  style: styles.combobox,
3141
3136
  value: inputValue,
@@ -3204,7 +3199,7 @@ function Combobox({
3204
3199
  }],
3205
3200
  testId: testId ? `${testId}-listbox` : undefined,
3206
3201
  "aria-label": labels.listbox,
3207
- "aria-labelledby": ids.get("input")
3202
+ "aria-labelledby": textFieldId
3208
3203
  }, renderList));
3209
3204
  }));
3210
3205
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-dropdown",
3
- "version": "6.1.2",
3
+ "version": "7.0.0",
4
4
  "design": "v1",
5
5
  "description": "Dropdown variants for Wonder Blocks.",
6
6
  "main": "dist/index.js",
@@ -16,17 +16,17 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@babel/runtime": "^7.18.6",
19
- "@khanacademy/wonder-blocks-cell": "^4.0.1",
20
- "@khanacademy/wonder-blocks-clickable": "^5.0.1",
21
- "@khanacademy/wonder-blocks-core": "^9.0.0",
22
- "@khanacademy/wonder-blocks-icon": "^5.0.1",
23
- "@khanacademy/wonder-blocks-layout": "^3.0.1",
24
- "@khanacademy/wonder-blocks-modal": "^6.0.1",
25
- "@khanacademy/wonder-blocks-pill": "^3.0.1",
26
- "@khanacademy/wonder-blocks-search-field": "^3.1.2",
19
+ "@khanacademy/wonder-blocks-cell": "^4.0.2",
20
+ "@khanacademy/wonder-blocks-clickable": "^5.0.2",
21
+ "@khanacademy/wonder-blocks-core": "^10.0.0",
22
+ "@khanacademy/wonder-blocks-icon": "^5.0.2",
23
+ "@khanacademy/wonder-blocks-layout": "^3.0.2",
24
+ "@khanacademy/wonder-blocks-modal": "^7.0.0",
25
+ "@khanacademy/wonder-blocks-pill": "^3.0.2",
26
+ "@khanacademy/wonder-blocks-search-field": "^4.0.0",
27
27
  "@khanacademy/wonder-blocks-timing": "^6.0.0",
28
28
  "@khanacademy/wonder-blocks-tokens": "^3.0.0",
29
- "@khanacademy/wonder-blocks-typography": "^3.0.1"
29
+ "@khanacademy/wonder-blocks-typography": "^3.0.2"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@phosphor-icons/core": "^2.0.2",
@@ -40,7 +40,7 @@
40
40
  "react-window": "^1.8.10"
41
41
  },
42
42
  "devDependencies": {
43
- "@khanacademy/wonder-blocks-button": "^7.0.1",
43
+ "@khanacademy/wonder-blocks-button": "^7.0.2",
44
44
  "@khanacademy/wb-dev-build-settings": "^2.0.0"
45
45
  }
46
46
  }