@wordpress/components 23.9.0 → 25.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 +62 -0
- package/CONTRIBUTING.md +75 -1
- package/README.md +1 -3
- package/build/autocomplete/autocompleter-ui.js +0 -2
- package/build/autocomplete/autocompleter-ui.js.map +1 -1
- package/build/autocomplete/index.js +2 -0
- package/build/autocomplete/index.js.map +1 -1
- package/build/button/index.js +2 -0
- package/build/button/index.js.map +1 -1
- package/build/card/card-media/component.js +2 -1
- package/build/card/card-media/component.js.map +1 -1
- package/build/color-picker/styles.js +8 -8
- package/build/color-picker/styles.js.map +1 -1
- package/build/combobox-control/index.js +7 -5
- package/build/combobox-control/index.js.map +1 -1
- package/build/combobox-control/styles.js +3 -3
- package/build/combobox-control/styles.js.map +1 -1
- package/build/date-time/date-time/index.js +3 -84
- package/build/date-time/date-time/index.js.map +1 -1
- package/build/date-time/date-time/styles.js +4 -19
- package/build/date-time/date-time/styles.js.map +1 -1
- package/build/dimension-control/index.js +1 -1
- package/build/dimension-control/index.js.map +1 -1
- package/build/draggable/index.js +2 -7
- package/build/draggable/index.js.map +1 -1
- package/build/dropdown-menu/index.js +87 -11
- package/build/dropdown-menu/index.js.map +1 -1
- package/build/dropdown-menu/types.js +6 -0
- package/build/dropdown-menu/types.js.map +1 -0
- package/build/dropdown-menu-v2/index.js +195 -0
- package/build/dropdown-menu-v2/index.js.map +1 -0
- package/build/dropdown-menu-v2/styles.js +176 -0
- package/build/dropdown-menu-v2/styles.js.map +1 -0
- package/build/dropdown-menu-v2/types.js +6 -0
- package/build/dropdown-menu-v2/types.js.map +1 -0
- package/build/form-token-field/index.js +5 -3
- package/build/form-token-field/index.js.map +1 -1
- package/build/form-token-field/styles.js +3 -3
- package/build/form-token-field/styles.js.map +1 -1
- package/build/index.native.js +0 -9
- package/build/index.native.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +30 -23
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/mobile/bottom-sheet/cell.native.js +16 -8
- package/build/mobile/bottom-sheet/cell.native.js.map +1 -1
- package/build/mobile/bottom-sheet/range-cell.native.js +3 -2
- package/build/mobile/bottom-sheet/range-cell.native.js.map +1 -1
- package/build/mobile/bottom-sheet/stepper-cell/index.native.js +4 -2
- package/build/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
- package/build/mobile/bottom-sheet/switch-cell.native.js +8 -2
- package/build/mobile/bottom-sheet/switch-cell.native.js.map +1 -1
- package/build/mobile/bottom-sheet-select-control/index.native.js +4 -2
- package/build/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build/mobile/bottom-sheet-text-control/index.native.js +4 -2
- package/build/mobile/bottom-sheet-text-control/index.native.js.map +1 -1
- package/build/mobile/global-styles-context/index.native.js +13 -1
- package/build/mobile/global-styles-context/index.native.js.map +1 -1
- package/build/mobile/link-picker/link-picker-results.native.js +3 -1
- package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
- package/build/navigable-container/container.js +39 -19
- package/build/navigable-container/container.js.map +1 -1
- package/build/navigable-container/index.js.map +1 -1
- package/build/navigable-container/menu.js +37 -5
- package/build/navigable-container/menu.js.map +1 -1
- package/build/navigable-container/tabbable.js +45 -4
- package/build/navigable-container/tabbable.js.map +1 -1
- package/build/navigable-container/types.js +6 -0
- package/build/navigable-container/types.js.map +1 -0
- package/build/palette-edit/index.js +34 -12
- package/build/palette-edit/index.js.map +1 -1
- package/build/private-apis.js +13 -1
- package/build/private-apis.js.map +1 -1
- package/build/range-control/index.native.js +5 -2
- package/build/range-control/index.native.js.map +1 -1
- package/build/sandbox/index.native.js +6 -2
- package/build/sandbox/index.native.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/fill.js +2 -1
- package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +45 -35
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/use-slot.js +11 -26
- package/build/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
- package/build/slot-fill/fill.js +7 -31
- package/build/slot-fill/fill.js.map +1 -1
- package/build/slot-fill/index.js.map +1 -1
- package/build/slot-fill/provider.js +0 -6
- package/build/slot-fill/provider.js.map +1 -1
- package/build/slot-fill/slot.js +0 -5
- package/build/slot-fill/slot.js.map +1 -1
- package/build/snackbar/list.js +0 -2
- package/build/snackbar/list.js.map +1 -1
- package/build/tab-panel/index.js.map +1 -1
- package/build/theme/color-algorithms.js +1 -1
- package/build/theme/color-algorithms.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/styles.js +7 -7
- package/build/toggle-group-control/toggle-group-control/styles.js.map +1 -1
- package/build/toolbar/toolbar-button/index.js +1 -2
- package/build/toolbar/toolbar-button/index.js.map +1 -1
- package/build/toolbar/toolbar-item/index.js +4 -2
- package/build/toolbar/toolbar-item/index.js.map +1 -1
- package/build/utils/colors-values.js +3 -3
- package/build/utils/colors-values.js.map +1 -1
- package/build/utils/use-deprecated-props.js +35 -0
- package/build/utils/use-deprecated-props.js.map +1 -0
- package/build-module/autocomplete/autocompleter-ui.js +1 -3
- package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
- package/build-module/autocomplete/index.js +3 -3
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/button/index.js +2 -0
- package/build-module/button/index.js.map +1 -1
- package/build-module/card/card-media/component.js +2 -1
- package/build-module/card/card-media/component.js.map +1 -1
- package/build-module/color-picker/styles.js +8 -8
- package/build-module/color-picker/styles.js.map +1 -1
- package/build-module/combobox-control/index.js +6 -5
- package/build-module/combobox-control/index.js.map +1 -1
- package/build-module/combobox-control/styles.js +3 -3
- package/build-module/combobox-control/styles.js.map +1 -1
- package/build-module/date-time/date-time/index.js +6 -81
- package/build-module/date-time/date-time/index.js.map +1 -1
- package/build-module/date-time/date-time/styles.js +3 -17
- package/build-module/date-time/date-time/styles.js.map +1 -1
- package/build-module/dimension-control/index.js +1 -1
- package/build-module/dimension-control/index.js.map +1 -1
- package/build-module/draggable/index.js +2 -7
- package/build-module/draggable/index.js.map +1 -1
- package/build-module/dropdown-menu/index.js +87 -10
- package/build-module/dropdown-menu/index.js.map +1 -1
- package/build-module/dropdown-menu/types.js +2 -0
- package/build-module/dropdown-menu/types.js.map +1 -0
- package/build-module/dropdown-menu-v2/index.js +149 -0
- package/build-module/dropdown-menu-v2/index.js.map +1 -0
- package/build-module/dropdown-menu-v2/styles.js +153 -0
- package/build-module/dropdown-menu-v2/styles.js.map +1 -0
- package/build-module/dropdown-menu-v2/types.js +2 -0
- package/build-module/dropdown-menu-v2/types.js.map +1 -0
- package/build-module/form-token-field/index.js +4 -3
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/form-token-field/styles.js +3 -3
- package/build-module/form-token-field/styles.js.map +1 -1
- package/build-module/index.native.js +0 -1
- package/build-module/index.native.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +30 -23
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/mobile/bottom-sheet/cell.native.js +16 -8
- package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/range-cell.native.js +3 -2
- package/build-module/mobile/bottom-sheet/range-cell.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/stepper-cell/index.native.js +4 -2
- package/build-module/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/switch-cell.native.js +7 -2
- package/build-module/mobile/bottom-sheet/switch-cell.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet-select-control/index.native.js +4 -2
- package/build-module/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet-text-control/index.native.js +4 -2
- package/build-module/mobile/bottom-sheet-text-control/index.native.js.map +1 -1
- package/build-module/mobile/global-styles-context/index.native.js +13 -1
- package/build-module/mobile/global-styles-context/index.native.js.map +1 -1
- package/build-module/mobile/link-picker/link-picker-results.native.js +3 -1
- package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
- package/build-module/navigable-container/container.js +43 -19
- package/build-module/navigable-container/container.js.map +1 -1
- package/build-module/navigable-container/index.js +0 -2
- package/build-module/navigable-container/index.js.map +1 -1
- package/build-module/navigable-container/menu.js +36 -4
- package/build-module/navigable-container/menu.js.map +1 -1
- package/build-module/navigable-container/tabbable.js +44 -3
- package/build-module/navigable-container/tabbable.js.map +1 -1
- package/build-module/navigable-container/types.js +2 -0
- package/build-module/navigable-container/types.js.map +1 -0
- package/build-module/palette-edit/index.js +34 -13
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/private-apis.js +12 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/range-control/index.native.js +5 -2
- package/build-module/range-control/index.native.js.map +1 -1
- package/build-module/sandbox/index.native.js +6 -2
- package/build-module/sandbox/index.native.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/fill.js +2 -1
- package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +46 -36
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/use-slot.js +12 -27
- package/build-module/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
- package/build-module/slot-fill/fill.js +7 -31
- package/build-module/slot-fill/fill.js.map +1 -1
- package/build-module/slot-fill/index.js +1 -2
- package/build-module/slot-fill/index.js.map +1 -1
- package/build-module/slot-fill/provider.js +0 -6
- package/build-module/slot-fill/provider.js.map +1 -1
- package/build-module/slot-fill/slot.js +0 -5
- package/build-module/slot-fill/slot.js.map +1 -1
- package/build-module/snackbar/list.js +0 -2
- package/build-module/snackbar/list.js.map +1 -1
- package/build-module/tab-panel/index.js.map +1 -1
- package/build-module/theme/color-algorithms.js +1 -1
- package/build-module/theme/color-algorithms.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/styles.js +7 -7
- package/build-module/toggle-group-control/toggle-group-control/styles.js.map +1 -1
- package/build-module/toolbar/toolbar-button/index.js +1 -2
- package/build-module/toolbar/toolbar-button/index.js.map +1 -1
- package/build-module/toolbar/toolbar-item/index.js +5 -2
- package/build-module/toolbar/toolbar-item/index.js.map +1 -1
- package/build-module/utils/colors-values.js +3 -3
- package/build-module/utils/colors-values.js.map +1 -1
- package/build-module/utils/use-deprecated-props.js +25 -0
- package/build-module/utils/use-deprecated-props.js.map +1 -0
- package/build-style/style-rtl.css +67 -67
- package/build-style/style.css +67 -67
- package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -1
- package/build-types/autocomplete/index.d.ts.map +1 -1
- package/build-types/autocomplete/types.d.ts +2 -18
- package/build-types/autocomplete/types.d.ts.map +1 -1
- package/build-types/button/deprecated.d.ts +6 -0
- package/build-types/button/deprecated.d.ts.map +1 -1
- package/build-types/button/index.d.ts.map +1 -1
- package/build-types/button/types.d.ts +7 -0
- package/build-types/button/types.d.ts.map +1 -1
- package/build-types/card/card-media/component.d.ts +2 -1
- package/build-types/card/card-media/component.d.ts.map +1 -1
- package/build-types/card/stories/index.d.ts +21 -1
- package/build-types/card/stories/index.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/combobox-control/index.d.ts +1 -1
- package/build-types/combobox-control/index.d.ts.map +1 -1
- package/build-types/combobox-control/stories/index.d.ts.map +1 -1
- package/build-types/combobox-control/styles.d.ts +1 -1
- package/build-types/combobox-control/types.d.ts +8 -1
- package/build-types/combobox-control/types.d.ts.map +1 -1
- package/build-types/date-time/date-time/index.d.ts +3 -4
- package/build-types/date-time/date-time/index.d.ts.map +1 -1
- package/build-types/date-time/date-time/styles.d.ts +0 -4
- package/build-types/date-time/date-time/styles.d.ts.map +1 -1
- package/build-types/date-time/stories/date-time.d.ts.map +1 -1
- package/build-types/date-time/types.d.ts +0 -14
- package/build-types/date-time/types.d.ts.map +1 -1
- package/build-types/dimension-control/index.d.ts +1 -1
- package/build-types/draggable/index.d.ts.map +1 -1
- package/build-types/dropdown-menu/index.d.ts +83 -1
- package/build-types/dropdown-menu/index.d.ts.map +1 -1
- package/build-types/dropdown-menu/stories/index.d.ts +13 -0
- package/build-types/dropdown-menu/stories/index.d.ts.map +1 -0
- package/build-types/dropdown-menu/test/index.d.ts +2 -0
- package/build-types/dropdown-menu/test/index.d.ts.map +1 -0
- package/build-types/dropdown-menu/types.d.ts +134 -0
- package/build-types/dropdown-menu/types.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2/index.d.ts +17 -0
- package/build-types/dropdown-menu-v2/index.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2/stories/index.d.ts +13 -0
- package/build-types/dropdown-menu-v2/stories/index.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2/styles.d.ts +41 -0
- package/build-types/dropdown-menu-v2/styles.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2/test/index.d.ts +2 -0
- package/build-types/dropdown-menu-v2/test/index.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2/types.d.ts +242 -0
- package/build-types/dropdown-menu-v2/types.d.ts.map +1 -0
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/styles.d.ts +1 -1
- package/build-types/form-token-field/types.d.ts +8 -1
- package/build-types/form-token-field/types.d.ts.map +1 -1
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/navigable-container/container.d.ts +20 -1
- package/build-types/navigable-container/container.d.ts.map +1 -1
- package/build-types/navigable-container/index.d.ts +5 -2
- package/build-types/navigable-container/index.d.ts.map +1 -1
- package/build-types/navigable-container/menu.d.ts +45 -11
- package/build-types/navigable-container/menu.d.ts.map +1 -1
- package/build-types/navigable-container/stories/navigable-menu.d.ts +12 -0
- package/build-types/navigable-container/stories/navigable-menu.d.ts.map +1 -0
- package/build-types/navigable-container/stories/tabbable-container.d.ts +12 -0
- package/build-types/navigable-container/stories/tabbable-container.d.ts.map +1 -0
- package/build-types/navigable-container/tabbable.d.ts +52 -9
- package/build-types/navigable-container/tabbable.d.ts.map +1 -1
- package/build-types/navigable-container/test/navigable-menu.d.ts +2 -0
- package/build-types/navigable-container/test/navigable-menu.d.ts.map +1 -0
- package/build-types/navigable-container/test/tababble-container.d.ts +2 -0
- package/build-types/navigable-container/test/tababble-container.d.ts.map +1 -0
- package/build-types/navigable-container/types.d.ts +61 -0
- package/build-types/navigable-container/types.d.ts.map +1 -0
- package/build-types/navigator/navigator-back-button/component.d.ts +1 -0
- package/build-types/navigator/navigator-back-button/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-back-button/hook.d.ts +1 -0
- package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
- package/build-types/navigator/navigator-button/component.d.ts +1 -0
- package/build-types/navigator/navigator-button/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-button/hook.d.ts +1 -0
- package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
- package/build-types/navigator/navigator-to-parent-button/component.d.ts +1 -0
- package/build-types/navigator/navigator-to-parent-button/component.d.ts.map +1 -1
- package/build-types/palette-edit/index.d.ts +1 -1
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/palette-edit/stories/index.d.ts.map +1 -1
- package/build-types/palette-edit/types.d.ts +8 -0
- package/build-types/palette-edit/types.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/use-slot.d.ts.map +1 -1
- package/build-types/slot-fill/fill.d.ts +4 -2
- package/build-types/slot-fill/fill.d.ts.map +1 -1
- package/build-types/slot-fill/index.d.ts +1 -2
- package/build-types/slot-fill/index.d.ts.map +1 -1
- package/build-types/slot-fill/provider.d.ts +0 -2
- package/build-types/slot-fill/provider.d.ts.map +1 -1
- package/build-types/slot-fill/slot.d.ts.map +1 -1
- package/build-types/snackbar/list.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
- package/build-types/toolbar/stories/index.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-button/index.d.ts +6 -0
- package/build-types/toolbar/toolbar-button/index.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-item/index.d.ts +6 -4
- package/build-types/toolbar/toolbar-item/index.d.ts.map +1 -1
- package/build-types/tree-grid/types.d.ts +7 -0
- package/build-types/tree-grid/types.d.ts.map +1 -1
- package/build-types/ui/context/get-styled-class-name-from-key.d.ts +1 -10
- package/build-types/ui/context/get-styled-class-name-from-key.d.ts.map +1 -1
- package/build-types/utils/use-deprecated-props.d.ts +9 -0
- package/build-types/utils/use-deprecated-props.d.ts.map +1 -0
- package/package.json +21 -20
- package/src/autocomplete/README.md +78 -52
- package/src/autocomplete/autocompleter-ui.tsx +0 -2
- package/src/autocomplete/index.tsx +1 -2
- package/src/autocomplete/types.ts +3 -19
- package/src/button/index.tsx +2 -0
- package/src/button/style.scss +18 -18
- package/src/button/types.ts +7 -0
- package/src/card/card-media/README.md +1 -1
- package/src/card/card-media/component.tsx +2 -1
- package/src/card/stories/index.tsx +47 -26
- package/src/checkbox-control/style.scss +1 -4
- package/src/color-picker/styles.ts +7 -2
- package/src/combobox-control/index.tsx +24 -18
- package/src/combobox-control/stories/index.tsx +0 -1
- package/src/combobox-control/styles.ts +4 -4
- package/src/combobox-control/types.ts +8 -1
- package/src/custom-gradient-picker/style.scss +2 -2
- package/src/date-time/README.md +0 -16
- package/src/date-time/date-time/index.tsx +17 -155
- package/src/date-time/date-time/styles.ts +0 -4
- package/src/date-time/stories/date-time.tsx +0 -4
- package/src/date-time/types.ts +0 -16
- package/src/dimension-control/index.tsx +1 -1
- package/src/draggable/index.tsx +1 -9
- package/src/dropdown-menu/README.md +12 -22
- package/src/dropdown-menu/{index.js → index.tsx} +111 -25
- package/src/dropdown-menu/stories/{index.js → index.tsx} +14 -22
- package/src/dropdown-menu/test/{index.js → index.tsx} +6 -5
- package/src/dropdown-menu/types.ts +143 -0
- package/src/dropdown-menu-v2/README.md +392 -0
- package/src/dropdown-menu-v2/index.tsx +241 -0
- package/src/dropdown-menu-v2/stories/index.tsx +193 -0
- package/src/dropdown-menu-v2/styles.ts +263 -0
- package/src/dropdown-menu-v2/test/index.tsx +816 -0
- package/src/dropdown-menu-v2/types.ts +250 -0
- package/src/form-toggle/style.scss +1 -5
- package/src/form-token-field/index.tsx +7 -3
- package/src/form-token-field/styles.ts +4 -4
- package/src/form-token-field/types.ts +8 -1
- package/src/index.native.js +0 -1
- package/src/input-control/styles/input-control-styles.tsx +7 -0
- package/src/mobile/bottom-sheet/cell.native.js +26 -5
- package/src/mobile/bottom-sheet/range-cell.native.js +2 -1
- package/src/mobile/bottom-sheet/stepper-cell/index.native.js +2 -0
- package/src/mobile/bottom-sheet/styles.native.scss +13 -1
- package/src/mobile/bottom-sheet/switch-cell.native.js +10 -2
- package/src/mobile/bottom-sheet-select-control/index.native.js +2 -0
- package/src/mobile/bottom-sheet-text-control/index.native.js +2 -0
- package/src/mobile/global-styles-context/index.native.js +12 -1
- package/src/mobile/link-picker/link-picker-results.native.js +3 -0
- package/src/modal/style.scss +1 -1
- package/src/navigable-container/README.md +24 -13
- package/src/navigable-container/{container.js → container.tsx} +57 -27
- package/src/navigable-container/{index.js → index.tsx} +0 -1
- package/src/navigable-container/menu.tsx +100 -0
- package/src/navigable-container/stories/{navigable-menu.js → navigable-menu.tsx} +15 -10
- package/src/navigable-container/stories/{tabbable-container.js → tabbable-container.tsx} +15 -6
- package/src/navigable-container/tabbable.tsx +92 -0
- package/src/navigable-container/test/{navigable-menu.js → navigable-menu.tsx} +3 -1
- package/src/navigable-container/test/{tababble-container.js → tababble-container.tsx} +53 -24
- package/src/navigable-container/types.ts +76 -0
- package/src/palette-edit/index.tsx +45 -7
- package/src/palette-edit/stories/index.tsx +4 -0
- package/src/palette-edit/types.ts +11 -0
- package/src/private-apis.ts +22 -0
- package/src/range-control/index.native.js +3 -0
- package/src/sandbox/index.native.js +4 -0
- package/src/search-control/style.scss +2 -0
- package/src/slot-fill/bubbles-virtually/fill.js +2 -1
- package/src/slot-fill/bubbles-virtually/slot-fill-provider.js +46 -60
- package/src/slot-fill/bubbles-virtually/use-slot.js +14 -41
- package/src/slot-fill/fill.js +4 -26
- package/src/slot-fill/index.js +1 -3
- package/src/slot-fill/provider.js +0 -6
- package/src/slot-fill/slot.js +0 -5
- package/src/snackbar/list.tsx +0 -1
- package/src/style.scss +6 -0
- package/src/tab-panel/index.tsx +1 -1
- package/src/theme/color-algorithms.ts +1 -1
- package/src/theme/stories/index.tsx +1 -1
- package/src/theme/test/color-algorithms.ts +2 -2
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +10 -6
- package/src/toggle-group-control/toggle-group-control/styles.ts +6 -1
- package/src/toolbar/stories/index.tsx +25 -26
- package/src/toolbar/toolbar-button/index.tsx +10 -13
- package/src/toolbar/toolbar-item/{index.js → index.tsx} +12 -3
- package/src/tooltip/style.scss +2 -2
- package/src/tree-grid/README.md +18 -0
- package/src/tree-grid/types.ts +7 -0
- package/src/utils/colors-values.js +3 -3
- package/src/utils/theme-variables.scss +4 -4
- package/src/utils/use-deprecated-props.ts +29 -0
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/mobile/readable-content-view/index.native.js +0 -97
- package/build/mobile/readable-content-view/index.native.js.map +0 -1
- package/build-module/mobile/readable-content-view/index.native.js +0 -81
- package/build-module/mobile/readable-content-view/index.native.js.map +0 -1
- package/src/CONTRIBUTING.md +0 -78
- package/src/README.md +0 -20
- package/src/mobile/readable-content-view/index.native.js +0 -85
- package/src/mobile/readable-content-view/style.native.scss +0 -30
- package/src/navigable-container/menu.js +0 -62
- package/src/navigable-container/tabbable.js +0 -46
|
@@ -6,21 +6,16 @@ import type { ForwardedRef } from 'react';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { forwardRef } from '@wordpress/element';
|
|
10
10
|
import { __, _x } from '@wordpress/i18n';
|
|
11
|
-
import deprecated from '@wordpress/deprecated';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Internal dependencies
|
|
15
14
|
*/
|
|
16
|
-
import Button from '../../button';
|
|
17
15
|
import { default as DatePicker } from '../date';
|
|
18
16
|
import { default as TimePicker } from '../time';
|
|
19
17
|
import type { DateTimePickerProps } from '../types';
|
|
20
|
-
import { Wrapper
|
|
21
|
-
import { HStack } from '../../h-stack';
|
|
22
|
-
import { Heading } from '../../heading';
|
|
23
|
-
import { Spacer } from '../../spacer';
|
|
18
|
+
import { Wrapper } from './styles';
|
|
24
19
|
|
|
25
20
|
export { DatePicker, TimePicker };
|
|
26
21
|
|
|
@@ -35,157 +30,26 @@ function UnforwardedDateTimePicker(
|
|
|
35
30
|
onChange,
|
|
36
31
|
events,
|
|
37
32
|
startOfWeek,
|
|
38
|
-
__nextRemoveHelpButton = false,
|
|
39
|
-
__nextRemoveResetButton = false,
|
|
40
33
|
}: DateTimePickerProps,
|
|
41
34
|
ref: ForwardedRef< any >
|
|
42
35
|
) {
|
|
43
|
-
if ( ! __nextRemoveHelpButton ) {
|
|
44
|
-
deprecated( 'Help button in wp.components.DateTimePicker', {
|
|
45
|
-
since: '13.4',
|
|
46
|
-
version: '15.8', // One year of plugin releases.
|
|
47
|
-
hint: 'Set the `__nextRemoveHelpButton` prop to `true` to remove this warning and opt in to the new behaviour, which will become the default in a future version.',
|
|
48
|
-
} );
|
|
49
|
-
}
|
|
50
|
-
if ( ! __nextRemoveResetButton ) {
|
|
51
|
-
deprecated( 'Reset button in wp.components.DateTimePicker', {
|
|
52
|
-
since: '13.4',
|
|
53
|
-
version: '15.8', // One year of plugin releases.
|
|
54
|
-
hint: 'Set the `__nextRemoveResetButton` prop to `true` to remove this warning and opt in to the new behaviour, which will become the default in a future version.',
|
|
55
|
-
} );
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const [ calendarHelpIsVisible, setCalendarHelpIsVisible ] =
|
|
59
|
-
useState( false );
|
|
60
|
-
|
|
61
|
-
function onClickDescriptionToggle() {
|
|
62
|
-
setCalendarHelpIsVisible( ! calendarHelpIsVisible );
|
|
63
|
-
}
|
|
64
|
-
|
|
65
36
|
return (
|
|
66
37
|
<Wrapper ref={ ref } className="components-datetime" spacing={ 4 }>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
</>
|
|
83
|
-
) }
|
|
84
|
-
{ calendarHelpIsVisible && (
|
|
85
|
-
<CalendarHelp
|
|
86
|
-
className="components-datetime__calendar-help" // Unused, for backwards compatibility.
|
|
87
|
-
>
|
|
88
|
-
<Heading level={ 4 }>{ __( 'Click to Select' ) }</Heading>
|
|
89
|
-
<ul>
|
|
90
|
-
<li>
|
|
91
|
-
{ __(
|
|
92
|
-
'Click the right or left arrows to select other months in the past or the future.'
|
|
93
|
-
) }
|
|
94
|
-
</li>
|
|
95
|
-
<li>{ __( 'Click the desired day to select it.' ) }</li>
|
|
96
|
-
</ul>
|
|
97
|
-
<Heading level={ 4 }>
|
|
98
|
-
{ __( 'Navigating with a keyboard' ) }
|
|
99
|
-
</Heading>
|
|
100
|
-
<ul>
|
|
101
|
-
<li>
|
|
102
|
-
<abbr
|
|
103
|
-
aria-label={ _x( 'Enter', 'keyboard button' ) }
|
|
104
|
-
>
|
|
105
|
-
↵
|
|
106
|
-
</abbr>
|
|
107
|
-
{
|
|
108
|
-
' ' /* JSX removes whitespace, but a space is required for screen readers. */
|
|
109
|
-
}
|
|
110
|
-
<span>{ __( 'Select the date in focus.' ) }</span>
|
|
111
|
-
</li>
|
|
112
|
-
<li>
|
|
113
|
-
<abbr aria-label={ __( 'Left and Right Arrows' ) }>
|
|
114
|
-
←/→
|
|
115
|
-
</abbr>
|
|
116
|
-
{
|
|
117
|
-
' ' /* JSX removes whitespace, but a space is required for screen readers. */
|
|
118
|
-
}
|
|
119
|
-
{ __(
|
|
120
|
-
'Move backward (left) or forward (right) by one day.'
|
|
121
|
-
) }
|
|
122
|
-
</li>
|
|
123
|
-
<li>
|
|
124
|
-
<abbr aria-label={ __( 'Up and Down Arrows' ) }>
|
|
125
|
-
↑/↓
|
|
126
|
-
</abbr>
|
|
127
|
-
{
|
|
128
|
-
' ' /* JSX removes whitespace, but a space is required for screen readers. */
|
|
129
|
-
}
|
|
130
|
-
{ __(
|
|
131
|
-
'Move backward (up) or forward (down) by one week.'
|
|
132
|
-
) }
|
|
133
|
-
</li>
|
|
134
|
-
<li>
|
|
135
|
-
<abbr aria-label={ __( 'Page Up and Page Down' ) }>
|
|
136
|
-
{ __( 'PgUp/PgDn' ) }
|
|
137
|
-
</abbr>
|
|
138
|
-
{
|
|
139
|
-
' ' /* JSX removes whitespace, but a space is required for screen readers. */
|
|
140
|
-
}
|
|
141
|
-
{ __(
|
|
142
|
-
'Move backward (PgUp) or forward (PgDn) by one month.'
|
|
143
|
-
) }
|
|
144
|
-
</li>
|
|
145
|
-
<li>
|
|
146
|
-
<abbr aria-label={ __( 'Home and End' ) }>
|
|
147
|
-
{ /* Translators: Home/End reffer to the 'Home' and 'End' buttons on the keyboard.*/ }
|
|
148
|
-
{ __( 'Home/End' ) }
|
|
149
|
-
</abbr>
|
|
150
|
-
{
|
|
151
|
-
' ' /* JSX removes whitespace, but a space is required for screen readers. */
|
|
152
|
-
}
|
|
153
|
-
{ __(
|
|
154
|
-
'Go to the first (Home) or last (End) day of a week.'
|
|
155
|
-
) }
|
|
156
|
-
</li>
|
|
157
|
-
</ul>
|
|
158
|
-
</CalendarHelp>
|
|
159
|
-
) }
|
|
160
|
-
{ ( ! __nextRemoveResetButton || ! __nextRemoveHelpButton ) && (
|
|
161
|
-
<HStack
|
|
162
|
-
className="components-datetime__buttons" // Unused, for backwards compatibility.
|
|
163
|
-
>
|
|
164
|
-
{ ! __nextRemoveResetButton &&
|
|
165
|
-
! calendarHelpIsVisible &&
|
|
166
|
-
currentDate && (
|
|
167
|
-
<Button
|
|
168
|
-
className="components-datetime__date-reset-button" // Unused, for backwards compatibility.
|
|
169
|
-
variant="link"
|
|
170
|
-
onClick={ () => onChange?.( null ) }
|
|
171
|
-
>
|
|
172
|
-
{ __( 'Reset' ) }
|
|
173
|
-
</Button>
|
|
174
|
-
) }
|
|
175
|
-
<Spacer />
|
|
176
|
-
{ ! __nextRemoveHelpButton && (
|
|
177
|
-
<Button
|
|
178
|
-
className="components-datetime__date-help-toggle" // Unused, for backwards compatibility.
|
|
179
|
-
variant="link"
|
|
180
|
-
onClick={ onClickDescriptionToggle }
|
|
181
|
-
>
|
|
182
|
-
{ calendarHelpIsVisible
|
|
183
|
-
? __( 'Close' )
|
|
184
|
-
: __( 'Calendar Help' ) }
|
|
185
|
-
</Button>
|
|
186
|
-
) }
|
|
187
|
-
</HStack>
|
|
188
|
-
) }
|
|
38
|
+
<>
|
|
39
|
+
<TimePicker
|
|
40
|
+
currentTime={ currentDate }
|
|
41
|
+
onChange={ onChange }
|
|
42
|
+
is12Hour={ is12Hour }
|
|
43
|
+
/>
|
|
44
|
+
<DatePicker
|
|
45
|
+
currentDate={ currentDate }
|
|
46
|
+
onChange={ onChange }
|
|
47
|
+
isInvalidDate={ isInvalidDate }
|
|
48
|
+
events={ events }
|
|
49
|
+
onMonthPreviewed={ onMonthPreviewed }
|
|
50
|
+
startOfWeek={ startOfWeek }
|
|
51
|
+
/>
|
|
52
|
+
</>
|
|
189
53
|
</Wrapper>
|
|
190
54
|
);
|
|
191
55
|
}
|
|
@@ -207,8 +71,6 @@ function UnforwardedDateTimePicker(
|
|
|
207
71
|
* currentDate={ date }
|
|
208
72
|
* onChange={ ( newDate ) => setDate( newDate ) }
|
|
209
73
|
* is12Hour
|
|
210
|
-
* __nextRemoveHelpButton
|
|
211
|
-
* __nextRemoveResetButton
|
|
212
74
|
* />
|
|
213
75
|
* );
|
|
214
76
|
* };
|
|
@@ -52,10 +52,6 @@ const Template: ComponentStory< typeof DateTimePicker > = ( {
|
|
|
52
52
|
export const Default: ComponentStory< typeof DateTimePicker > = Template.bind(
|
|
53
53
|
{}
|
|
54
54
|
);
|
|
55
|
-
Default.args = {
|
|
56
|
-
__nextRemoveHelpButton: true,
|
|
57
|
-
__nextRemoveResetButton: true,
|
|
58
|
-
};
|
|
59
55
|
|
|
60
56
|
export const WithEvents: ComponentStory< typeof DateTimePicker > =
|
|
61
57
|
Template.bind( {} );
|
package/src/date-time/types.ts
CHANGED
|
@@ -73,20 +73,4 @@ export type DateTimePickerProps = Omit< DatePickerProps, 'onChange' > &
|
|
|
73
73
|
* passed the date and time as an argument.
|
|
74
74
|
*/
|
|
75
75
|
onChange?: ( date: string | null ) => void;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Start opting in to not displaying a Help button which will become the
|
|
79
|
-
* default in a future version.
|
|
80
|
-
*
|
|
81
|
-
* @default false
|
|
82
|
-
*/
|
|
83
|
-
__nextRemoveHelpButton?: boolean;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Start opting in to not displaying a Reset button which will become
|
|
87
|
-
* the default in a future version.
|
|
88
|
-
*
|
|
89
|
-
* @default false
|
|
90
|
-
*/
|
|
91
|
-
__nextRemoveResetButton?: boolean;
|
|
92
76
|
};
|
|
@@ -23,8 +23,8 @@ import type { SelectControlSingleSelectionProps } from '../select-control/types'
|
|
|
23
23
|
* This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
|
|
24
24
|
*
|
|
25
25
|
* ```jsx
|
|
26
|
-
* import { useState } from 'react';
|
|
27
26
|
* import { __experimentalDimensionControl as DimensionControl } from '@wordpress/components';
|
|
27
|
+
* import { useState } from '@wordpress/element';
|
|
28
28
|
*
|
|
29
29
|
* export default function MyCustomDimensionControl() {
|
|
30
30
|
* const [ paddingSize, setPaddingSize ] = useState( '' );
|
package/src/draggable/index.tsx
CHANGED
|
@@ -212,14 +212,8 @@ export function Draggable( {
|
|
|
212
212
|
// Update cursor to 'grabbing', document wide.
|
|
213
213
|
ownerDocument.body.classList.add( bodyClass );
|
|
214
214
|
|
|
215
|
-
// Allow the Synthetic Event to be accessed from asynchronous code.
|
|
216
|
-
// https://reactjs.org/docs/events.html#event-pooling
|
|
217
|
-
event.persist();
|
|
218
|
-
|
|
219
|
-
let timerId: number | undefined;
|
|
220
|
-
|
|
221
215
|
if ( onDragStart ) {
|
|
222
|
-
|
|
216
|
+
onDragStart( event );
|
|
223
217
|
}
|
|
224
218
|
|
|
225
219
|
cleanup.current = () => {
|
|
@@ -236,8 +230,6 @@ export function Draggable( {
|
|
|
236
230
|
ownerDocument.body.classList.remove( bodyClass );
|
|
237
231
|
|
|
238
232
|
ownerDocument.removeEventListener( 'dragover', throttledDragOver );
|
|
239
|
-
|
|
240
|
-
clearTimeout( timerId );
|
|
241
233
|
};
|
|
242
234
|
}
|
|
243
235
|
|
|
@@ -131,80 +131,70 @@ const MyDropdownMenu = () => (
|
|
|
131
131
|
|
|
132
132
|
The component accepts the following props:
|
|
133
133
|
|
|
134
|
-
#### icon
|
|
134
|
+
#### `icon`: `string | null`
|
|
135
135
|
|
|
136
136
|
The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug to be shown in the collapsed menu button.
|
|
137
137
|
|
|
138
|
-
- Type: `String|null`
|
|
139
138
|
- Required: No
|
|
140
139
|
- Default: `"menu"`
|
|
141
140
|
|
|
142
141
|
See also: [https://developer.wordpress.org/resource/dashicons/](https://developer.wordpress.org/resource/dashicons/)
|
|
143
142
|
|
|
144
|
-
#### label
|
|
143
|
+
#### `label`: `string`
|
|
145
144
|
|
|
146
145
|
A human-readable label to present as accessibility text on the focused collapsed menu button.
|
|
147
146
|
|
|
148
|
-
- Type: `String`
|
|
149
147
|
- Required: Yes
|
|
150
148
|
|
|
151
|
-
#### controls
|
|
149
|
+
#### `controls:` `DropdownOption[] | DropdownOption[][]`
|
|
152
150
|
|
|
153
|
-
An array of objects describing the options to be shown in the expanded menu.
|
|
151
|
+
An array or nested array of objects describing the options to be shown in the expanded menu.
|
|
154
152
|
|
|
155
153
|
Each object should include an `icon` [Dashicon](https://developer.wordpress.org/resource/dashicons/) slug string, a human-readable `title` string, `isDisabled` boolean flag and an `onClick` function callback to invoke when the option is selected.
|
|
156
154
|
|
|
157
|
-
A valid DropdownMenu must specify
|
|
158
|
-
|
|
159
|
-
- Type: `Array`
|
|
155
|
+
A valid DropdownMenu must specify a `controls` or `children` prop, or both.
|
|
160
156
|
- Required: No
|
|
161
157
|
|
|
162
|
-
#### children
|
|
158
|
+
#### `children`: `( callbackProps: DropdownCallbackProps ) => ReactNode`
|
|
163
159
|
|
|
164
160
|
A [function render prop](https://reactjs.org/docs/render-props.html#using-props-other-than-render) which should return an element or elements valid for use in a DropdownMenu: `MenuItem`, `MenuItemsChoice`, or `MenuGroup`. Its first argument is a props object including the same values as given to a [`Dropdown`'s `renderContent`](/packages/components/src/dropdown#rendercontent) (`isOpen`, `onToggle`, `onClose`).
|
|
165
161
|
|
|
166
|
-
A valid DropdownMenu must specify
|
|
162
|
+
A valid DropdownMenu must specify a `controls` or `children` prop, or both.
|
|
167
163
|
|
|
168
|
-
- Type: `Function`
|
|
169
164
|
- Required: No
|
|
170
165
|
|
|
171
166
|
See also: [https://developer.wordpress.org/resource/dashicons/](https://developer.wordpress.org/resource/dashicons/)
|
|
172
167
|
|
|
173
|
-
#### className
|
|
168
|
+
#### `className`: `string`
|
|
174
169
|
|
|
175
170
|
A class name to apply to the dropdown menu's toggle element wrapper.
|
|
176
171
|
|
|
177
|
-
- Type: `String`
|
|
178
172
|
- Required: No
|
|
179
173
|
|
|
180
|
-
#### popoverProps
|
|
174
|
+
#### `popoverProps`: `DropdownProps[ 'popoverProps' ]`
|
|
181
175
|
|
|
182
176
|
Properties of `popoverProps` object will be passed as props to the nested `Popover` component.
|
|
183
177
|
Use this object to modify props available for the `Popover` component that are not already exposed in the `DropdownMenu` component, e.g.: the direction in which the popover should open relative to its parent node set with `position` prop.
|
|
184
178
|
|
|
185
|
-
- Type: `Object`
|
|
186
179
|
- Required: No
|
|
187
180
|
|
|
188
|
-
#### toggleProps
|
|
181
|
+
#### `toggleProps`: `ToggleProps`
|
|
189
182
|
|
|
190
183
|
Properties of `toggleProps` object will be passed as props to the nested `Button` component in the `renderToggle` implementation of the `Dropdown` component used internally.
|
|
191
184
|
Use this object to modify props available for the `Button` component that are not already exposed in the `DropdownMenu` component, e.g.: the tooltip text displayed on hover set with `tooltip` prop.
|
|
192
185
|
|
|
193
|
-
- Type: `Object`
|
|
194
186
|
- Required: No
|
|
195
187
|
|
|
196
|
-
#### menuProps
|
|
188
|
+
#### `menuProps`: `NavigableContainerProps`
|
|
197
189
|
|
|
198
190
|
Properties of `menuProps` object will be passed as props to the nested `NavigableMenu` component in the `renderContent` implementation of the `Dropdown` component used internally.
|
|
199
191
|
Use this object to modify props available for the `NavigableMenu` component that are not already exposed in the `DropdownMenu` component, e.g.: the orientation of the menu set with `orientation` prop.
|
|
200
192
|
|
|
201
|
-
- Type: `Object`
|
|
202
193
|
- Required: No
|
|
203
194
|
|
|
204
|
-
#### disableOpenOnArrowDown
|
|
195
|
+
#### `disableOpenOnArrowDown`: `boolean`
|
|
205
196
|
|
|
206
197
|
In some contexts, the arrow down key used to open the dropdown menu might need to be disabled—for example when that key is used to perform another action.
|
|
207
198
|
|
|
208
|
-
- Type: `boolean`
|
|
209
199
|
- Required: No
|
|
210
200
|
- Default: `false`
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* External dependencies
|
|
4
3
|
*/
|
|
@@ -15,9 +14,12 @@ import { menu } from '@wordpress/icons';
|
|
|
15
14
|
import Button from '../button';
|
|
16
15
|
import Dropdown from '../dropdown';
|
|
17
16
|
import { NavigableMenu } from '../navigable-container';
|
|
17
|
+
import type { DropdownMenuProps, DropdownOption } from './types';
|
|
18
18
|
|
|
19
|
-
function mergeProps
|
|
20
|
-
|
|
19
|
+
function mergeProps<
|
|
20
|
+
T extends { className?: string; [ key: string ]: unknown }
|
|
21
|
+
>( defaultProps: Partial< T > = {}, props: T = {} as T ) {
|
|
22
|
+
const mergedProps: T = {
|
|
21
23
|
...defaultProps,
|
|
22
24
|
...props,
|
|
23
25
|
};
|
|
@@ -32,17 +34,92 @@ function mergeProps( defaultProps = {}, props = {} ) {
|
|
|
32
34
|
return mergedProps;
|
|
33
35
|
}
|
|
34
36
|
|
|
37
|
+
function isFunction( maybeFunc: unknown ): maybeFunc is () => void {
|
|
38
|
+
return typeof maybeFunc === 'function';
|
|
39
|
+
}
|
|
40
|
+
|
|
35
41
|
/**
|
|
36
|
-
* Whether the argument is a function.
|
|
37
42
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
43
|
+
* The DropdownMenu displays a list of actions (each contained in a MenuItem,
|
|
44
|
+
* MenuItemsChoice, or MenuGroup) in a compact way. It appears in a Popover
|
|
45
|
+
* after the user has interacted with an element (a button or icon) or when
|
|
46
|
+
* they perform a specific action.
|
|
47
|
+
*
|
|
48
|
+
* Render a Dropdown Menu with a set of controls:
|
|
49
|
+
*
|
|
50
|
+
* ```jsx
|
|
51
|
+
* import { DropdownMenu } from '@wordpress/components';
|
|
52
|
+
* import {
|
|
53
|
+
* more,
|
|
54
|
+
* arrowLeft,
|
|
55
|
+
* arrowRight,
|
|
56
|
+
* arrowUp,
|
|
57
|
+
* arrowDown,
|
|
58
|
+
* } from '@wordpress/icons';
|
|
59
|
+
*
|
|
60
|
+
* const MyDropdownMenu = () => (
|
|
61
|
+
* <DropdownMenu
|
|
62
|
+
* icon={ more }
|
|
63
|
+
* label="Select a direction"
|
|
64
|
+
* controls={ [
|
|
65
|
+
* {
|
|
66
|
+
* title: 'Up',
|
|
67
|
+
* icon: arrowUp,
|
|
68
|
+
* onClick: () => console.log( 'up' ),
|
|
69
|
+
* },
|
|
70
|
+
* {
|
|
71
|
+
* title: 'Right',
|
|
72
|
+
* icon: arrowRight,
|
|
73
|
+
* onClick: () => console.log( 'right' ),
|
|
74
|
+
* },
|
|
75
|
+
* {
|
|
76
|
+
* title: 'Down',
|
|
77
|
+
* icon: arrowDown,
|
|
78
|
+
* onClick: () => console.log( 'down' ),
|
|
79
|
+
* },
|
|
80
|
+
* {
|
|
81
|
+
* title: 'Left',
|
|
82
|
+
* icon: arrowLeft,
|
|
83
|
+
* onClick: () => console.log( 'left' ),
|
|
84
|
+
* },
|
|
85
|
+
* ] }
|
|
86
|
+
* />
|
|
87
|
+
* );
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* Alternatively, specify a `children` function which returns elements valid for
|
|
91
|
+
* use in a DropdownMenu: `MenuItem`, `MenuItemsChoice`, or `MenuGroup`.
|
|
92
|
+
*
|
|
93
|
+
* ```jsx
|
|
94
|
+
* import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
|
|
95
|
+
* import { more, arrowUp, arrowDown, trash } from '@wordpress/icons';
|
|
96
|
+
*
|
|
97
|
+
* const MyDropdownMenu = () => (
|
|
98
|
+
* <DropdownMenu icon={ more } label="Select a direction">
|
|
99
|
+
* { ( { onClose } ) => (
|
|
100
|
+
* <>
|
|
101
|
+
* <MenuGroup>
|
|
102
|
+
* <MenuItem icon={ arrowUp } onClick={ onClose }>
|
|
103
|
+
* Move Up
|
|
104
|
+
* </MenuItem>
|
|
105
|
+
* <MenuItem icon={ arrowDown } onClick={ onClose }>
|
|
106
|
+
* Move Down
|
|
107
|
+
* </MenuItem>
|
|
108
|
+
* </MenuGroup>
|
|
109
|
+
* <MenuGroup>
|
|
110
|
+
* <MenuItem icon={ trash } onClick={ onClose }>
|
|
111
|
+
* Remove
|
|
112
|
+
* </MenuItem>
|
|
113
|
+
* </MenuGroup>
|
|
114
|
+
* </>
|
|
115
|
+
* ) }
|
|
116
|
+
* </DropdownMenu>
|
|
117
|
+
* );
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
40
120
|
*/
|
|
41
|
-
function isFunction( maybeFunc ) {
|
|
42
|
-
return typeof maybeFunc === 'function';
|
|
43
|
-
}
|
|
44
121
|
|
|
45
|
-
function DropdownMenu( dropdownMenuProps ) {
|
|
122
|
+
function DropdownMenu( dropdownMenuProps: DropdownMenuProps ) {
|
|
46
123
|
const {
|
|
47
124
|
children,
|
|
48
125
|
className,
|
|
@@ -62,13 +139,18 @@ function DropdownMenu( dropdownMenuProps ) {
|
|
|
62
139
|
}
|
|
63
140
|
|
|
64
141
|
// Normalize controls to nested array of objects (sets of controls)
|
|
65
|
-
let controlSets;
|
|
142
|
+
let controlSets: DropdownOption[][];
|
|
66
143
|
if ( controls?.length ) {
|
|
144
|
+
// @ts-expect-error The check below is needed because `DropdownMenus`
|
|
145
|
+
// rendered by `ToolBarGroup` receive controls as a nested array.
|
|
67
146
|
controlSets = controls;
|
|
68
147
|
if ( ! Array.isArray( controlSets[ 0 ] ) ) {
|
|
69
|
-
|
|
148
|
+
// This is not ideal, but at this point we know that `controls` is
|
|
149
|
+
// not a nested array, even if TypeScript doesn't.
|
|
150
|
+
controlSets = [ controls as DropdownOption[] ];
|
|
70
151
|
}
|
|
71
152
|
}
|
|
153
|
+
|
|
72
154
|
const mergedPopoverProps = mergeProps(
|
|
73
155
|
{
|
|
74
156
|
className: 'components-dropdown-menu__popover',
|
|
@@ -81,7 +163,7 @@ function DropdownMenu( dropdownMenuProps ) {
|
|
|
81
163
|
className={ classnames( 'components-dropdown-menu', className ) }
|
|
82
164
|
popoverProps={ mergedPopoverProps }
|
|
83
165
|
renderToggle={ ( { isOpen, onToggle } ) => {
|
|
84
|
-
const openOnArrowDown = ( event ) => {
|
|
166
|
+
const openOnArrowDown = ( event: React.KeyboardEvent ) => {
|
|
85
167
|
if ( disableOpenOnArrowDown ) {
|
|
86
168
|
return;
|
|
87
169
|
}
|
|
@@ -110,18 +192,22 @@ function DropdownMenu( dropdownMenuProps ) {
|
|
|
110
192
|
<Toggle
|
|
111
193
|
{ ...mergedToggleProps }
|
|
112
194
|
icon={ icon }
|
|
113
|
-
onClick={
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
mergedToggleProps.onClick
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
195
|
+
onClick={
|
|
196
|
+
( ( event ) => {
|
|
197
|
+
onToggle();
|
|
198
|
+
if ( mergedToggleProps.onClick ) {
|
|
199
|
+
mergedToggleProps.onClick( event );
|
|
200
|
+
}
|
|
201
|
+
} ) as React.MouseEventHandler< HTMLButtonElement >
|
|
202
|
+
}
|
|
203
|
+
onKeyDown={
|
|
204
|
+
( ( event ) => {
|
|
205
|
+
openOnArrowDown( event );
|
|
206
|
+
if ( mergedToggleProps.onKeyDown ) {
|
|
207
|
+
mergedToggleProps.onKeyDown( event );
|
|
208
|
+
}
|
|
209
|
+
} ) as React.KeyboardEventHandler< HTMLButtonElement >
|
|
210
|
+
}
|
|
125
211
|
aria-haspopup="true"
|
|
126
212
|
aria-expanded={ isOpen }
|
|
127
213
|
label={ label }
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
1
5
|
/**
|
|
2
6
|
* Internal dependencies
|
|
3
7
|
*/
|
|
4
|
-
import DropdownMenu from '
|
|
5
|
-
import
|
|
8
|
+
import DropdownMenu from '..';
|
|
9
|
+
import MenuItem from '../../menu-item';
|
|
10
|
+
import MenuGroup from '../../menu-group';
|
|
6
11
|
|
|
7
12
|
/**
|
|
8
13
|
* WordPress dependencies
|
|
@@ -16,37 +21,24 @@ import {
|
|
|
16
21
|
trash,
|
|
17
22
|
} from '@wordpress/icons';
|
|
18
23
|
|
|
19
|
-
|
|
24
|
+
const meta: ComponentMeta< typeof DropdownMenu > = {
|
|
20
25
|
title: 'Components/DropdownMenu',
|
|
21
26
|
component: DropdownMenu,
|
|
27
|
+
parameters: {
|
|
28
|
+
controls: { expanded: true },
|
|
29
|
+
docs: { source: { state: 'open' } },
|
|
30
|
+
},
|
|
22
31
|
argTypes: {
|
|
23
|
-
className: { control: { type: 'text' } },
|
|
24
|
-
children: { control: { type: null } },
|
|
25
|
-
disableOpenOnArrowDown: { control: { type: 'boolean' } },
|
|
26
32
|
icon: {
|
|
27
33
|
options: [ 'menu', 'chevronDown', 'more' ],
|
|
28
34
|
mapping: { menu, chevronDown, more },
|
|
29
35
|
control: { type: 'select' },
|
|
30
36
|
},
|
|
31
|
-
menuProps: {
|
|
32
|
-
control: { type: 'object' },
|
|
33
|
-
},
|
|
34
|
-
noIcons: { control: { type: 'boolean' } },
|
|
35
|
-
popoverProps: {
|
|
36
|
-
control: { type: 'object' },
|
|
37
|
-
},
|
|
38
|
-
text: { control: { type: 'text' } },
|
|
39
|
-
toggleProps: {
|
|
40
|
-
control: { type: 'object' },
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
parameters: {
|
|
44
|
-
controls: { expanded: true },
|
|
45
|
-
docs: { source: { state: 'open' } },
|
|
46
37
|
},
|
|
47
38
|
};
|
|
39
|
+
export default meta;
|
|
48
40
|
|
|
49
|
-
const Template = ( props ) => (
|
|
41
|
+
const Template: ComponentStory< typeof DropdownMenu > = ( props ) => (
|
|
50
42
|
<div style={ { height: 150 } }>
|
|
51
43
|
<DropdownMenu { ...props } />
|
|
52
44
|
</div>
|
|
@@ -12,19 +12,19 @@ import { arrowLeft, arrowRight, arrowUp, arrowDown } from '@wordpress/icons';
|
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
|
-
import DropdownMenu from '
|
|
16
|
-
import
|
|
15
|
+
import DropdownMenu from '..';
|
|
16
|
+
import MenuItem from '../../menu-item';
|
|
17
17
|
|
|
18
18
|
describe( 'DropdownMenu', () => {
|
|
19
19
|
it( 'should not render when neither controls nor children are assigned', () => {
|
|
20
|
-
render( <DropdownMenu /> );
|
|
20
|
+
render( <DropdownMenu label="Open dropdown" /> );
|
|
21
21
|
|
|
22
22
|
// The button toggle should not even be rendered
|
|
23
23
|
expect( screen.queryByRole( 'button' ) ).not.toBeInTheDocument();
|
|
24
24
|
} );
|
|
25
25
|
|
|
26
26
|
it( 'should not render when controls are empty and children is not specified', () => {
|
|
27
|
-
render( <DropdownMenu controls={ [] } /> );
|
|
27
|
+
render( <DropdownMenu label="Open dropdown" controls={ [] } /> );
|
|
28
28
|
|
|
29
29
|
// The button toggle should not even be rendered
|
|
30
30
|
expect( screen.queryByRole( 'button' ) ).not.toBeInTheDocument();
|
|
@@ -56,7 +56,7 @@ describe( 'DropdownMenu', () => {
|
|
|
56
56
|
},
|
|
57
57
|
];
|
|
58
58
|
|
|
59
|
-
render( <DropdownMenu controls={ controls } /> );
|
|
59
|
+
render( <DropdownMenu label="Open dropdown" controls={ controls } /> );
|
|
60
60
|
|
|
61
61
|
// Move focus on the toggle button
|
|
62
62
|
await user.tab();
|
|
@@ -78,6 +78,7 @@ describe( 'DropdownMenu', () => {
|
|
|
78
78
|
|
|
79
79
|
render(
|
|
80
80
|
<DropdownMenu
|
|
81
|
+
label="Open dropdown"
|
|
81
82
|
children={ ( { onClose } ) => <MenuItem onClick={ onClose } /> }
|
|
82
83
|
/>
|
|
83
84
|
);
|