@wordpress/components 23.0.0 → 23.2.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 +29 -0
- package/CONTRIBUTING.md +0 -21
- package/LICENSE.md +1 -1
- package/build/autocomplete/index.js +1 -3
- package/build/autocomplete/index.js.map +1 -1
- package/build/border-box-control/border-box-control/component.js +0 -3
- package/build/border-box-control/border-box-control/component.js.map +1 -1
- package/build/border-box-control/border-box-control/hook.js +0 -2
- package/build/border-box-control/border-box-control/hook.js.map +1 -1
- package/build/border-box-control/border-box-control-split-controls/component.js +0 -2
- package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build/border-box-control/border-box-control-split-controls/hook.js +0 -2
- package/build/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
- package/build/border-control/border-control/component.js +0 -2
- package/build/border-control/border-control/component.js.map +1 -1
- package/build/border-control/border-control/hook.js +0 -2
- package/build/border-control/border-control/hook.js.map +1 -1
- package/build/border-control/border-control-dropdown/component.js +6 -11
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/border-control/border-control-dropdown/hook.js +0 -2
- package/build/border-control/border-control-dropdown/hook.js.map +1 -1
- package/build/color-palette/index.js +5 -8
- package/build/color-palette/index.js.map +1 -1
- package/build/color-picker/component.js +1 -0
- package/build/color-picker/component.js.map +1 -1
- package/build/color-picker/styles.js +8 -10
- package/build/color-picker/styles.js.map +1 -1
- package/build/combobox-control/index.js +5 -1
- package/build/combobox-control/index.js.map +1 -1
- package/build/dimension-control/index.js.map +1 -1
- package/build/dropdown/index.js +45 -10
- package/build/dropdown/index.js.map +1 -1
- package/build/focal-point-picker/utils.js +1 -1
- package/build/focal-point-picker/utils.js.map +1 -1
- package/build/gradient-picker/index.js +1 -2
- package/build/gradient-picker/index.js.map +1 -1
- package/build/higher-order/navigate-regions/index.js +4 -3
- package/build/higher-order/navigate-regions/index.js.map +1 -1
- package/build/index.js +7 -25
- package/build/index.js.map +1 -1
- package/build/index.native.js +8 -18
- package/build/index.native.js.map +1 -1
- package/build/item-group/item/component.js +27 -3
- package/build/item-group/item/component.js.map +1 -1
- package/build/item-group/item-group/component.js +26 -3
- package/build/item-group/item-group/component.js.map +1 -1
- package/build/item-group/styles.js +14 -14
- package/build/item-group/styles.js.map +1 -1
- package/build/mobile/bottom-sheet/picker-cell.native.js +1 -9
- package/build/mobile/bottom-sheet/picker-cell.native.js.map +1 -1
- package/build/mobile/global-styles-context/utils.native.js +30 -12
- package/build/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build/panel/row.js +5 -3
- package/build/panel/row.js.map +1 -1
- package/build/query-controls/index.js +1 -0
- package/build/query-controls/index.js.map +1 -1
- package/build/resizable-box/index.js +5 -4
- package/build/resizable-box/index.js.map +1 -1
- package/build/responsive-wrapper/index.js +18 -1
- package/build/responsive-wrapper/index.js.map +1 -1
- package/build/responsive-wrapper/types.js +6 -0
- package/build/responsive-wrapper/types.js.map +1 -0
- package/build/sandbox/index.js +35 -24
- package/build/sandbox/index.js.map +1 -1
- package/build/sandbox/types.js +6 -0
- package/build/sandbox/types.js.map +1 -0
- package/build/tab-panel/index.js +15 -9
- package/build/tab-panel/index.js.map +1 -1
- package/build/toolbar/index.js +42 -60
- package/build/toolbar/index.js.map +1 -1
- package/build/toolbar/toolbar/index.js +74 -0
- package/build/toolbar/toolbar/index.js.map +1 -0
- package/build/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
- package/build/toolbar/toolbar/toolbar-container.js.map +1 -0
- package/build/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
- package/build/toolbar/toolbar/toolbar-container.native.js.map +1 -0
- package/build/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
- package/build/toolbar/toolbar-button/index.js.map +1 -0
- package/build/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
- package/build/toolbar/toolbar-button/toolbar-button-container.js.map +1 -0
- package/build/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
- package/build/toolbar/toolbar-button/toolbar-button-container.native.js.map +1 -0
- package/build/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
- package/build/toolbar/toolbar-context/index.js.map +1 -0
- package/build/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
- package/build/toolbar/toolbar-dropdown-menu/index.js.map +1 -0
- package/build/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
- package/build/toolbar/toolbar-group/index.js.map +1 -0
- package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
- package/build/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -0
- package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
- package/build/toolbar/toolbar-group/toolbar-group-collapsed.native.js.map +1 -0
- package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
- package/build/toolbar/toolbar-group/toolbar-group-container.js.map +1 -0
- package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
- package/build/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -0
- package/build/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
- package/build/toolbar/toolbar-item/index.js.map +1 -0
- package/build/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
- package/build/toolbar/toolbar-item/index.native.js.map +1 -0
- package/build/tree-grid/index.js +3 -3
- package/build/tree-grid/index.js.map +1 -1
- package/build-module/autocomplete/index.js +1 -2
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/border-box-control/border-box-control/component.js +0 -3
- package/build-module/border-box-control/border-box-control/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control/hook.js +0 -2
- package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
- package/build-module/border-box-control/border-box-control-split-controls/component.js +0 -2
- package/build-module/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control-split-controls/hook.js +0 -2
- package/build-module/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
- package/build-module/border-control/border-control/component.js +0 -2
- package/build-module/border-control/border-control/component.js.map +1 -1
- package/build-module/border-control/border-control/hook.js +0 -2
- package/build-module/border-control/border-control/hook.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js +6 -11
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/hook.js +0 -2
- package/build-module/border-control/border-control-dropdown/hook.js.map +1 -1
- package/build-module/color-palette/index.js +5 -8
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-picker/component.js +1 -0
- package/build-module/color-picker/component.js.map +1 -1
- package/build-module/color-picker/styles.js +8 -9
- package/build-module/color-picker/styles.js.map +1 -1
- package/build-module/combobox-control/index.js +5 -1
- package/build-module/combobox-control/index.js.map +1 -1
- package/build-module/dimension-control/index.js +1 -2
- package/build-module/dimension-control/index.js.map +1 -1
- package/build-module/dropdown/index.js +44 -10
- package/build-module/dropdown/index.js.map +1 -1
- package/build-module/focal-point-picker/utils.js +1 -1
- package/build-module/focal-point-picker/utils.js.map +1 -1
- package/build-module/gradient-picker/index.js +1 -2
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/higher-order/navigate-regions/index.js +4 -3
- package/build-module/higher-order/navigate-regions/index.js.map +1 -1
- package/build-module/index.js +1 -7
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +1 -6
- package/build-module/index.native.js.map +1 -1
- package/build-module/item-group/item/component.js +26 -2
- package/build-module/item-group/item/component.js.map +1 -1
- package/build-module/item-group/item-group/component.js +25 -2
- package/build-module/item-group/item-group/component.js.map +1 -1
- package/build-module/item-group/styles.js +14 -14
- package/build-module/item-group/styles.js.map +1 -1
- package/build-module/mobile/bottom-sheet/picker-cell.native.js +1 -8
- package/build-module/mobile/bottom-sheet/picker-cell.native.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +31 -13
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/panel/row.js +5 -3
- package/build-module/panel/row.js.map +1 -1
- package/build-module/query-controls/index.js +1 -0
- package/build-module/query-controls/index.js.map +1 -1
- package/build-module/resizable-box/index.js +3 -2
- package/build-module/resizable-box/index.js.map +1 -1
- package/build-module/responsive-wrapper/index.js +20 -1
- package/build-module/responsive-wrapper/index.js.map +1 -1
- package/build-module/responsive-wrapper/types.js +2 -0
- package/build-module/responsive-wrapper/types.js.map +1 -0
- package/build-module/sandbox/index.js +37 -23
- package/build-module/sandbox/index.js.map +1 -1
- package/build-module/sandbox/types.js +2 -0
- package/build-module/sandbox/types.js.map +1 -0
- package/build-module/tab-panel/index.js +15 -8
- package/build-module/tab-panel/index.js.map +1 -1
- package/build-module/toolbar/index.js +6 -58
- package/build-module/toolbar/index.js.map +1 -1
- package/build-module/toolbar/toolbar/index.js +59 -0
- package/build-module/toolbar/toolbar/index.js.map +1 -0
- package/build-module/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
- package/{build → build-module/toolbar}/toolbar/toolbar-container.js.map +1 -1
- package/build-module/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
- package/build-module/toolbar/toolbar/toolbar-container.native.js.map +1 -0
- package/build-module/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
- package/build-module/toolbar/toolbar-button/index.js.map +1 -0
- package/build-module/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
- package/build-module/toolbar/toolbar-button/toolbar-button-container.js.map +1 -0
- package/build-module/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
- package/build-module/toolbar/toolbar-button/toolbar-button-container.native.js.map +1 -0
- package/build-module/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
- package/build-module/toolbar/toolbar-context/index.js.map +1 -0
- package/build-module/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
- package/build-module/toolbar/toolbar-dropdown-menu/index.js.map +1 -0
- package/build-module/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
- package/build-module/toolbar/toolbar-group/index.js.map +1 -0
- package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
- package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -0
- package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
- package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.native.js.map +1 -0
- package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
- package/build-module/toolbar/toolbar-group/toolbar-group-container.js.map +1 -0
- package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
- package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -0
- package/build-module/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
- package/build-module/toolbar/toolbar-item/index.js.map +1 -0
- package/build-module/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
- package/build-module/toolbar/toolbar-item/index.native.js.map +1 -0
- package/build-module/tree-grid/index.js +3 -3
- package/build-module/tree-grid/index.js.map +1 -1
- package/build-style/style-rtl.css +19 -32
- package/build-style/style.css +19 -32
- package/build-types/border-box-control/border-box-control/component.d.ts +1 -1
- package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts +0 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/component.d.ts +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/component.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +0 -1
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts.map +1 -1
- package/build-types/border-box-control/stories/index.d.ts +1 -1
- package/build-types/border-control/border-control/component.d.ts +1 -1
- package/build-types/border-control/border-control/component.d.ts.map +1 -1
- package/build-types/border-control/border-control/hook.d.ts +0 -1
- package/build-types/border-control/border-control/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/component.d.ts +1 -1
- package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/hook.d.ts +0 -1
- package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
- package/build-types/border-control/stories/index.d.ts +6 -6
- package/build-types/border-control/stories/index.d.ts.map +1 -1
- package/build-types/border-control/types.d.ts +1 -1
- package/build-types/border-control/types.d.ts.map +1 -1
- package/build-types/color-palette/index.d.ts +2 -3
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/color-palette/stories/index.d.ts +2 -9
- package/build-types/color-palette/stories/index.d.ts.map +1 -1
- package/build-types/color-palette/types.d.ts +3 -16
- package/build-types/color-palette/types.d.ts.map +1 -1
- package/build-types/color-picker/component.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/dashicon/types.d.ts +0 -4
- package/build-types/dashicon/types.d.ts.map +1 -1
- package/build-types/disabled/stories/index.d.ts.map +1 -1
- package/build-types/dropdown/index.d.ts +29 -1
- package/build-types/dropdown/index.d.ts.map +1 -1
- package/build-types/dropdown/stories/index.d.ts +23 -0
- package/build-types/dropdown/stories/index.d.ts.map +1 -0
- package/build-types/dropdown/test/index.d.ts +2 -0
- package/build-types/dropdown/test/index.d.ts.map +1 -0
- package/build-types/dropdown/types.d.ts +101 -0
- package/build-types/dropdown/types.d.ts.map +1 -1
- package/build-types/focal-point-picker/utils.d.ts.map +1 -1
- package/build-types/icon/stories/index.d.ts +22 -0
- package/build-types/icon/stories/index.d.ts.map +1 -0
- package/build-types/item-group/item/component.d.ts +24 -2
- package/build-types/item-group/item/component.d.ts.map +1 -1
- package/build-types/item-group/item-group/component.d.ts +23 -2
- package/build-types/item-group/item-group/component.d.ts.map +1 -1
- package/build-types/item-group/stories/index.d.ts +15 -0
- package/build-types/item-group/stories/index.d.ts.map +1 -0
- package/build-types/item-group/styles.d.ts.map +1 -1
- package/build-types/radio-context/index.d.ts +6 -0
- package/build-types/radio-context/index.d.ts.map +1 -0
- package/build-types/resizable-box/index.d.ts +6 -7
- package/build-types/resizable-box/index.d.ts.map +1 -1
- package/build-types/resizable-box/stories/index.d.ts +61 -0
- package/build-types/resizable-box/stories/index.d.ts.map +1 -0
- package/build-types/responsive-wrapper/index.d.ts +24 -0
- package/build-types/responsive-wrapper/index.d.ts.map +1 -0
- package/build-types/responsive-wrapper/stories/index.d.ts +12 -0
- package/build-types/responsive-wrapper/stories/index.d.ts.map +1 -0
- package/build-types/responsive-wrapper/types.d.ts +22 -0
- package/build-types/responsive-wrapper/types.d.ts.map +1 -0
- package/build-types/sandbox/index.d.ts +19 -0
- package/build-types/sandbox/index.d.ts.map +1 -0
- package/build-types/sandbox/stories/index.d.ts +12 -0
- package/build-types/sandbox/stories/index.d.ts.map +1 -0
- package/build-types/sandbox/test/index.d.ts +2 -0
- package/build-types/sandbox/test/index.d.ts.map +1 -0
- package/build-types/sandbox/types.d.ts +36 -0
- package/build-types/sandbox/types.d.ts.map +1 -0
- package/build-types/tab-panel/index.d.ts.map +1 -1
- package/build-types/tab-panel/stories/index.d.ts +1 -0
- package/build-types/tab-panel/stories/index.d.ts.map +1 -1
- package/build-types/tab-panel/types.d.ts +10 -4
- package/build-types/tab-panel/types.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/autocomplete/index.js +1 -3
- package/src/autocomplete/test/index.js +2 -0
- package/src/base-control/test/index.tsx +1 -0
- package/src/border-box-control/border-box-control/component.tsx +0 -7
- package/src/border-box-control/border-box-control/hook.ts +0 -2
- package/src/border-box-control/border-box-control-split-controls/component.tsx +0 -2
- package/src/border-box-control/border-box-control-split-controls/hook.ts +0 -2
- package/src/border-box-control/test/index.js +2 -0
- package/src/border-control/border-control/component.tsx +0 -4
- package/src/border-control/border-control/hook.ts +0 -2
- package/src/border-control/border-control-dropdown/component.tsx +11 -17
- package/src/border-control/border-control-dropdown/hook.ts +0 -2
- package/src/border-control/stories/index.tsx +0 -1
- package/src/border-control/test/index.js +70 -67
- package/src/border-control/types.ts +1 -4
- package/src/box-control/test/index.js +2 -0
- package/src/checkbox-control/test/index.tsx +2 -0
- package/src/color-palette/index.tsx +12 -12
- package/src/color-palette/stories/index.tsx +0 -13
- package/src/color-palette/test/index.tsx +2 -0
- package/src/color-palette/types.ts +3 -17
- package/src/color-picker/component.tsx +1 -0
- package/src/color-picker/stories/index.js +20 -60
- package/src/color-picker/styles.ts +0 -5
- package/src/color-picker/test/index.js +2 -0
- package/src/combobox-control/index.js +9 -1
- package/src/combobox-control/test/index.js +2 -0
- package/src/confirm-dialog/test/index.js +2 -0
- package/src/dashicon/types.ts +0 -6
- package/src/date-time/date/test/index.tsx +2 -0
- package/src/date-time/time/test/index.tsx +2 -0
- package/src/dimension-control/index.js +2 -3
- package/src/dimension-control/test/index.test.js +2 -0
- package/src/disabled/stories/index.tsx +6 -2
- package/src/disabled/test/index.tsx +2 -0
- package/src/dropdown/README.md +41 -46
- package/src/dropdown/{index.js → index.tsx} +57 -13
- package/src/dropdown/stories/{index.js → index.tsx} +21 -8
- package/src/dropdown/test/{index.js → index.tsx} +9 -9
- package/src/dropdown/types.ts +107 -0
- package/src/dropdown-menu/README.md +2 -3
- package/src/dropdown-menu/test/index.js +2 -0
- package/src/external-link/test/index.tsx +2 -0
- package/src/focal-point-picker/stories/index.tsx +1 -1
- package/src/focal-point-picker/test/index.js +2 -0
- package/src/focal-point-picker/utils.ts +4 -1
- package/src/font-size-picker/test/index.tsx +2 -0
- package/src/form-file-upload/test/index.tsx +2 -0
- package/src/form-toggle/test/index.tsx +2 -0
- package/src/form-token-field/test/index.tsx +3 -0
- package/src/gradient-picker/index.js +1 -2
- package/src/gradient-picker/stories/index.js +0 -1
- package/src/guide/stories/index.js +14 -41
- package/src/guide/test/index.js +2 -0
- package/src/higher-order/navigate-regions/index.js +5 -2
- package/src/higher-order/navigate-regions/style.scss +13 -39
- package/src/higher-order/with-filters/test/index.js +70 -74
- package/src/higher-order/with-focus-outside/test/index.js +2 -0
- package/src/higher-order/with-focus-return/test/index.js +2 -0
- package/src/higher-order/with-notices/test/index.js +1 -0
- package/src/icon/stories/index.tsx +103 -0
- package/src/index.js +8 -7
- package/src/index.native.js +8 -6
- package/src/input-control/test/index.js +3 -0
- package/src/isolated-event-container/test/index.js +2 -0
- package/src/item-group/item/component.tsx +26 -2
- package/src/item-group/item-group/component.tsx +25 -2
- package/src/item-group/stories/index.tsx +103 -0
- package/src/item-group/styles.ts +1 -0
- package/src/item-group/test/__snapshots__/index.js.snap +11 -10
- package/src/mobile/bottom-sheet/picker-cell.native.js +1 -6
- package/src/mobile/global-styles-context/utils.native.js +17 -16
- package/src/modal/test/index.tsx +1 -3
- package/src/navigable-container/test/navigable-menu.js +2 -0
- package/src/navigable-container/test/tababble-container.js +2 -0
- package/src/navigation/test/index.js +2 -0
- package/src/navigator/test/index.tsx +2 -0
- package/src/notice/stories/index.js +30 -58
- package/src/notice/test/index.js +8 -3
- package/src/number-control/test/index.tsx +2 -0
- package/src/panel/row.js +3 -3
- package/src/panel/stories/index.js +62 -80
- package/src/panel/test/__snapshots__/body.js.snap +9 -0
- package/src/panel/test/body.js +71 -62
- package/src/placeholder/style.scss +1 -1
- package/src/placeholder/test/index.tsx +3 -0
- package/src/query-controls/index.js +1 -0
- package/src/resizable-box/README.md +2 -2
- package/src/resizable-box/index.tsx +7 -6
- package/src/resizable-box/stories/index.tsx +92 -0
- package/src/responsive-wrapper/README.md +29 -0
- package/src/responsive-wrapper/{index.js → index.tsx} +23 -2
- package/src/responsive-wrapper/stories/index.tsx +38 -0
- package/src/responsive-wrapper/types.ts +20 -0
- package/src/sandbox/README.md +45 -2
- package/src/sandbox/{index.js → index.tsx} +47 -24
- package/src/sandbox/stories/index.tsx +32 -0
- package/src/sandbox/test/{index.js → index.tsx} +9 -4
- package/src/sandbox/types.ts +34 -0
- package/src/select-control/test/select-control.tsx +2 -0
- package/src/slot-fill/stories/index.js +12 -17
- package/src/style.scss +3 -3
- package/src/tab-panel/README.md +1 -0
- package/src/tab-panel/index.tsx +20 -7
- package/src/tab-panel/stories/index.tsx +20 -0
- package/src/tab-panel/test/index.tsx +91 -0
- package/src/tab-panel/types.ts +10 -4
- package/src/text-highlight/test/index.tsx +1 -0
- package/src/toggle-group-control/test/index.tsx +2 -0
- package/src/toolbar/index.js +6 -52
- package/src/toolbar/stories/index.js +2 -9
- package/src/{toolbar-button/stories/index.js → toolbar/stories/toolbar-button.js} +1 -2
- package/src/{toolbar-group/stories/index.js → toolbar/stories/toolbar-group.js} +1 -1
- package/src/toolbar/test/index.js +1 -2
- package/src/{toolbar-group/test/index.js → toolbar/test/toolbar-group.js} +3 -1
- package/src/toolbar/{README.md → toolbar/README.md} +0 -0
- package/src/toolbar/toolbar/index.js +52 -0
- package/src/toolbar/{style.native.scss → toolbar/style.native.scss} +0 -0
- package/src/toolbar/{style.scss → toolbar/style.scss} +1 -1
- package/src/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
- package/src/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
- package/src/{toolbar-button → toolbar/toolbar-button}/README.md +0 -0
- package/src/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
- package/src/{toolbar-button → toolbar/toolbar-button}/style.scss +0 -0
- package/src/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
- package/src/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
- package/src/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
- package/src/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/README.md +0 -0
- package/src/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
- package/src/{toolbar-group → toolbar/toolbar-group}/README.md +0 -0
- package/src/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
- package/src/{toolbar-group → toolbar/toolbar-group}/style.native.scss +0 -0
- package/src/{toolbar-group → toolbar/toolbar-group}/style.scss +0 -0
- package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
- package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
- package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
- package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
- package/src/{toolbar-item → toolbar/toolbar-item}/README.md +0 -0
- package/src/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
- package/src/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
- package/src/tooltip/stories/index.js +68 -78
- package/src/tooltip/test/index.js +2 -0
- package/src/tree-grid/index.js +2 -4
- package/src/unit-control/test/index.tsx +3 -0
- package/src/utils/hooks/test/use-latest-ref.js +2 -0
- package/tsconfig.json +0 -7
- package/tsconfig.tsbuildinfo +1 -1
- package/build/toolbar/toolbar-container.native.js.map +0 -1
- package/build/toolbar-button/index.js.map +0 -1
- package/build/toolbar-button/toolbar-button-container.js.map +0 -1
- package/build/toolbar-button/toolbar-button-container.native.js.map +0 -1
- package/build/toolbar-context/index.js.map +0 -1
- package/build/toolbar-dropdown-menu/index.js.map +0 -1
- package/build/toolbar-group/index.js.map +0 -1
- package/build/toolbar-group/toolbar-group-collapsed.js.map +0 -1
- package/build/toolbar-group/toolbar-group-collapsed.native.js.map +0 -1
- package/build/toolbar-group/toolbar-group-container.js.map +0 -1
- package/build/toolbar-group/toolbar-group-container.native.js.map +0 -1
- package/build/toolbar-item/index.js.map +0 -1
- package/build/toolbar-item/index.native.js.map +0 -1
- package/build-module/toolbar/toolbar-container.js.map +0 -1
- package/build-module/toolbar/toolbar-container.native.js.map +0 -1
- package/build-module/toolbar-button/index.js.map +0 -1
- package/build-module/toolbar-button/toolbar-button-container.js.map +0 -1
- package/build-module/toolbar-button/toolbar-button-container.native.js.map +0 -1
- package/build-module/toolbar-context/index.js.map +0 -1
- package/build-module/toolbar-dropdown-menu/index.js.map +0 -1
- package/build-module/toolbar-group/index.js.map +0 -1
- package/build-module/toolbar-group/toolbar-group-collapsed.js.map +0 -1
- package/build-module/toolbar-group/toolbar-group-collapsed.native.js.map +0 -1
- package/build-module/toolbar-group/toolbar-group-container.js.map +0 -1
- package/build-module/toolbar-group/toolbar-group-container.native.js.map +0 -1
- package/build-module/toolbar-item/index.js.map +0 -1
- package/build-module/toolbar-item/index.native.js.map +0 -1
- package/src/icon/stories/index.js +0 -128
- package/src/item-group/stories/index.js +0 -270
- package/src/resizable-box/stories/index.js +0 -97
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { boolean, select } from '@storybook/addon-knobs';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -12,70 +7,35 @@ import { useState } from '@wordpress/element';
|
|
|
12
7
|
* Internal dependencies
|
|
13
8
|
*/
|
|
14
9
|
import { ColorPicker } from '..';
|
|
15
|
-
import { Flex } from '../../flex';
|
|
16
|
-
import { Spacer } from '../../spacer';
|
|
17
|
-
import { space } from '../../ui/utils/space';
|
|
18
10
|
|
|
19
11
|
export default {
|
|
20
12
|
component: ColorPicker,
|
|
21
13
|
title: 'Components/ColorPicker',
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
argTypes: {
|
|
15
|
+
color: { control: { type: null } },
|
|
16
|
+
copyFormat: {
|
|
17
|
+
control: { type: 'select' },
|
|
18
|
+
options: [ 'rgb', 'hsl', 'hex', undefined ],
|
|
19
|
+
},
|
|
20
|
+
// We can't use a `on*` regex because this component will switch to
|
|
21
|
+
// legacy mode when an onChangeComplete prop is passed.
|
|
22
|
+
onChange: { action: 'onChange' },
|
|
24
23
|
},
|
|
25
24
|
};
|
|
26
25
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
const Example = () => {
|
|
30
|
-
const [ color, setColor ] = useState( undefined );
|
|
31
|
-
const props = {
|
|
32
|
-
enableAlpha: boolean( 'enableAlpha', false ),
|
|
33
|
-
copyFormat: select(
|
|
34
|
-
'copyFormat',
|
|
35
|
-
[ PROP_UNSET, 'rgb', 'hsl', 'hex' ],
|
|
36
|
-
PROP_UNSET
|
|
37
|
-
),
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
if ( props.copyFormat === PROP_UNSET ) {
|
|
41
|
-
delete props.copyFormat;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<Flex
|
|
46
|
-
as={ Spacer }
|
|
47
|
-
gap={ space( 2 ) }
|
|
48
|
-
justify="space-around"
|
|
49
|
-
align="flex-start"
|
|
50
|
-
marginTop={ space( 10 ) }
|
|
51
|
-
>
|
|
52
|
-
<ColorPicker { ...props } color={ color } onChange={ setColor } />
|
|
53
|
-
<div style={ { width: 200, textAlign: 'center' } }>{ color }</div>
|
|
54
|
-
<ColorPicker { ...props } color={ color } onChange={ setColor } />
|
|
55
|
-
</Flex>
|
|
56
|
-
);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const _default = () => {
|
|
60
|
-
return <Example />;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const LegacyExample = () => {
|
|
64
|
-
const [ legacyColor, setLegacyColor ] = useState( '#fff' );
|
|
65
|
-
const legacyProps = {
|
|
66
|
-
color: legacyColor,
|
|
67
|
-
onChangeComplete: setLegacyColor,
|
|
68
|
-
disableAlpha: boolean( 'disableAlpha', true ),
|
|
69
|
-
};
|
|
26
|
+
const Template = ( { onChange, ...props } ) => {
|
|
27
|
+
const [ color, setColor ] = useState();
|
|
70
28
|
|
|
71
29
|
return (
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
30
|
+
<ColorPicker
|
|
31
|
+
{ ...props }
|
|
32
|
+
color={ color }
|
|
33
|
+
onChange={ ( ...changeArgs ) => {
|
|
34
|
+
onChange( ...changeArgs );
|
|
35
|
+
setColor( ...changeArgs );
|
|
36
|
+
} }
|
|
37
|
+
/>
|
|
78
38
|
);
|
|
79
39
|
};
|
|
80
40
|
|
|
81
|
-
export const
|
|
41
|
+
export const Default = Template.bind( {} );
|
|
@@ -9,7 +9,6 @@ import styled from '@emotion/styled';
|
|
|
9
9
|
import NumberControl from '../number-control';
|
|
10
10
|
import InnerSelectControl from '../select-control';
|
|
11
11
|
import InnerRangeControl from '../range-control';
|
|
12
|
-
import { StyledField } from '../base-control/styles/base-control-styles';
|
|
13
12
|
import { space } from '../ui/utils/space';
|
|
14
13
|
import { boxSizingReset } from '../utils';
|
|
15
14
|
import Button from '../button';
|
|
@@ -111,10 +110,6 @@ export const ColorfulWrapper = styled.div`
|
|
|
111
110
|
}
|
|
112
111
|
|
|
113
112
|
${ interactiveHueStyles }
|
|
114
|
-
|
|
115
|
-
${ StyledField } {
|
|
116
|
-
margin-bottom: 0;
|
|
117
|
-
}
|
|
118
113
|
`;
|
|
119
114
|
|
|
120
115
|
export const CopyButton = styled( Button )`
|
|
@@ -8,6 +8,8 @@ import { render, fireEvent } from '@testing-library/react';
|
|
|
8
8
|
*/
|
|
9
9
|
import { ColorPicker } from '..';
|
|
10
10
|
|
|
11
|
+
jest.useFakeTimers();
|
|
12
|
+
|
|
11
13
|
/**
|
|
12
14
|
* Ordinarily we'd try to select the compnoent by role but the silder role appears
|
|
13
15
|
* on several elements and we'd end up encoding assumptions about order when
|
|
@@ -121,7 +121,15 @@ function ComboboxControl( {
|
|
|
121
121
|
const onKeyDown = ( event ) => {
|
|
122
122
|
let preventDefault = false;
|
|
123
123
|
|
|
124
|
-
if (
|
|
124
|
+
if (
|
|
125
|
+
event.defaultPrevented ||
|
|
126
|
+
// Ignore keydowns from IMEs
|
|
127
|
+
event.nativeEvent.isComposing ||
|
|
128
|
+
// Workaround for Mac Safari where the final Enter/Backspace of an IME composition
|
|
129
|
+
// is `isComposing=false`, even though it's technically still part of the composition.
|
|
130
|
+
// These can only be detected by keyCode.
|
|
131
|
+
event.keyCode === 229
|
|
132
|
+
) {
|
|
125
133
|
return;
|
|
126
134
|
}
|
|
127
135
|
|
package/src/dashicon/types.ts
CHANGED
|
@@ -10,6 +10,8 @@ import userEvent from '@testing-library/user-event';
|
|
|
10
10
|
*/
|
|
11
11
|
import DatePicker from '..';
|
|
12
12
|
|
|
13
|
+
jest.useFakeTimers();
|
|
14
|
+
|
|
13
15
|
describe( 'DatePicker', () => {
|
|
14
16
|
it( 'should highlight the current date', () => {
|
|
15
17
|
render( <DatePicker currentDate="2022-05-02T11:00:00" /> );
|
|
@@ -7,7 +7,6 @@ import classnames from 'classnames';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
|
-
import { Fragment } from '@wordpress/element';
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Internal dependencies
|
|
@@ -50,10 +49,10 @@ export function DimensionControl( props ) {
|
|
|
50
49
|
};
|
|
51
50
|
|
|
52
51
|
const selectLabel = (
|
|
53
|
-
|
|
52
|
+
<>
|
|
54
53
|
{ icon && <Icon icon={ icon } /> }
|
|
55
54
|
{ label }
|
|
56
|
-
|
|
55
|
+
</>
|
|
57
56
|
);
|
|
58
57
|
|
|
59
58
|
return (
|
|
@@ -15,6 +15,7 @@ import Disabled from '../';
|
|
|
15
15
|
import SelectControl from '../../select-control/';
|
|
16
16
|
import TextControl from '../../text-control/';
|
|
17
17
|
import TextareaControl from '../../textarea-control/';
|
|
18
|
+
import { VStack } from '../../v-stack/';
|
|
18
19
|
|
|
19
20
|
const meta: ComponentMeta< typeof Disabled > = {
|
|
20
21
|
title: 'Components/Disabled',
|
|
@@ -37,18 +38,21 @@ const Form = () => {
|
|
|
37
38
|
const [ textControlValue, setTextControlValue ] = useState( '' );
|
|
38
39
|
const [ textAreaValue, setTextAreaValue ] = useState( '' );
|
|
39
40
|
return (
|
|
40
|
-
<
|
|
41
|
+
<VStack>
|
|
41
42
|
<TextControl
|
|
43
|
+
__nextHasNoMarginBottom
|
|
42
44
|
label="Text Control"
|
|
43
45
|
value={ textControlValue }
|
|
44
46
|
onChange={ setTextControlValue }
|
|
45
47
|
/>
|
|
46
48
|
<TextareaControl
|
|
49
|
+
__nextHasNoMarginBottom
|
|
47
50
|
label="TextArea Control"
|
|
48
51
|
value={ textAreaValue }
|
|
49
52
|
onChange={ setTextAreaValue }
|
|
50
53
|
/>
|
|
51
54
|
<SelectControl
|
|
55
|
+
__nextHasNoMarginBottom
|
|
52
56
|
label="Select Control"
|
|
53
57
|
onChange={ () => {} }
|
|
54
58
|
options={ [
|
|
@@ -58,7 +62,7 @@ const Form = () => {
|
|
|
58
62
|
{ value: 'c', label: 'Option C' },
|
|
59
63
|
] }
|
|
60
64
|
/>
|
|
61
|
-
</
|
|
65
|
+
</VStack>
|
|
62
66
|
);
|
|
63
67
|
};
|
|
64
68
|
|
package/src/dropdown/README.md
CHANGED
|
@@ -32,96 +32,91 @@ const MyDropdown = () => (
|
|
|
32
32
|
|
|
33
33
|
The component accepts the following props. Props not included in this set will be applied to the element wrapping Popover content.
|
|
34
34
|
|
|
35
|
-
### className
|
|
35
|
+
### `className`: `string`
|
|
36
36
|
|
|
37
37
|
className of the global container
|
|
38
38
|
|
|
39
|
-
- Type: `String`
|
|
40
39
|
- Required: No
|
|
41
40
|
|
|
42
|
-
### contentClassName
|
|
41
|
+
### `contentClassName`: `string`
|
|
43
42
|
|
|
44
43
|
If you want to target the dropdown menu for styling purposes, you need to provide a contentClassName because it's not being rendered as a child of the container node.
|
|
45
44
|
|
|
46
|
-
- Type: `String`
|
|
47
45
|
- Required: No
|
|
48
46
|
|
|
49
|
-
###
|
|
47
|
+
### `expandOnMobile`: `boolean`
|
|
50
48
|
|
|
51
|
-
|
|
49
|
+
Opt-in prop to show popovers fullscreen on mobile.
|
|
52
50
|
|
|
53
|
-
- Type: `String`
|
|
54
51
|
- Required: No
|
|
55
|
-
- Default: `
|
|
56
|
-
|
|
57
|
-
### renderToggle
|
|
58
|
-
|
|
59
|
-
A callback invoked to render the Dropdown Toggle Button.
|
|
60
|
-
|
|
61
|
-
- Type: `Function`
|
|
62
|
-
- Required: Yes
|
|
52
|
+
- Default: `false`
|
|
63
53
|
|
|
64
|
-
|
|
54
|
+
### `focusOnMount`: `'firstElement' | boolean`
|
|
65
55
|
|
|
66
|
-
|
|
67
|
-
- `onToggle`: A function switching the dropdown menu's state from open to closed and vice versa
|
|
68
|
-
- `onClose`: A function that closes the menu if invoked
|
|
56
|
+
By default, the _first tabbable element_ in the popover will receive focus when it mounts. This is the same as setting this prop to `"firstElement"`.
|
|
69
57
|
|
|
70
|
-
|
|
58
|
+
Specifying a `true` value will focus the container instead.
|
|
71
59
|
|
|
72
|
-
|
|
60
|
+
Specifying a `false` value disables the focus handling entirely (this should only be done when an appropriately accessible substitute behavior exists).
|
|
73
61
|
|
|
74
|
-
-
|
|
75
|
-
-
|
|
62
|
+
- Required: No
|
|
63
|
+
- Default: `"firstElement"`
|
|
76
64
|
|
|
77
|
-
###
|
|
65
|
+
### `headerTitle`: `string`
|
|
78
66
|
|
|
79
|
-
|
|
67
|
+
Set this to customize the text that is shown in the dropdown's header when it is fullscreen on mobile.
|
|
80
68
|
|
|
81
|
-
- Type: `Boolean`
|
|
82
69
|
- Required: No
|
|
83
|
-
- Default: `false`
|
|
84
70
|
|
|
85
|
-
###
|
|
71
|
+
### `onClose`: `() => void`
|
|
86
72
|
|
|
87
|
-
|
|
73
|
+
A callback invoked when the popover should be closed.
|
|
88
74
|
|
|
89
|
-
- Type: `String`
|
|
90
75
|
- Required: No
|
|
91
76
|
|
|
92
|
-
###
|
|
93
|
-
|
|
94
|
-
By default, the _first tabbable element_ in the popover will receive focus when it mounts. This is the same as setting this prop to `"firstElement"`.
|
|
77
|
+
### `onToggle`: `( willOpen: boolean ) => void`
|
|
95
78
|
|
|
96
|
-
|
|
79
|
+
A callback invoked when the state of the popover changes from open to closed and vice versa.
|
|
97
80
|
|
|
98
|
-
|
|
81
|
+
The callback receives a boolean as a parameter. If `true`, the popover will open. If `false`, the popover will close.
|
|
99
82
|
|
|
100
|
-
- Type: `'firstElement' | boolean`
|
|
101
83
|
- Required: No
|
|
102
|
-
- Default: `"firstElement"`
|
|
103
84
|
|
|
104
|
-
### popoverProps
|
|
85
|
+
### `popoverProps`: `WordPressComponentProps< Omit< PopoverProps, 'children' > 'div', false >`
|
|
105
86
|
|
|
106
87
|
Properties of popoverProps object will be passed as props to the `Popover` component.
|
|
107
88
|
|
|
108
89
|
Use this object to access properties/features of the `Popover` component that are not already exposed in the `Dropdown` component, e.g.: the ability to have the popover without an arrow.
|
|
109
90
|
|
|
110
|
-
- Type: `Object`
|
|
111
91
|
- Required: No
|
|
112
92
|
|
|
113
|
-
###
|
|
93
|
+
### `position`: `PopoverProps[ 'position' ]`
|
|
114
94
|
|
|
115
|
-
|
|
95
|
+
The direction in which the popover should open relative to its parent node. Specify a y- and an x-axis as a space-separated string. Supports `"top"`, `"bottom"` y-axis, and `"left"`, `"center"`, `"right"` x-axis.
|
|
116
96
|
|
|
117
|
-
- Type: `Function`
|
|
118
97
|
- Required: No
|
|
98
|
+
- Default: `"top center"`
|
|
119
99
|
|
|
120
|
-
###
|
|
100
|
+
### `renderContent`: `( props: CallbackProps ) => ReactNode`
|
|
121
101
|
|
|
122
|
-
A callback invoked
|
|
102
|
+
A callback invoked to render the content of the dropdown menu.
|
|
123
103
|
|
|
124
|
-
|
|
104
|
+
- `isOpen`: whether the dropdown menu is opened or not
|
|
105
|
+
- `onToggle`: A function switching the dropdown menu's state from open to closed and vice versa
|
|
106
|
+
- `onClose`: A function that closes the menu if invoked
|
|
107
|
+
|
|
108
|
+
- Required: Yes
|
|
109
|
+
|
|
110
|
+
### `renderToggle`: `( props: CallbackProps ) => ReactNode`
|
|
111
|
+
|
|
112
|
+
A callback invoked to render the Dropdown Toggle Button.
|
|
113
|
+
|
|
114
|
+
Its props are the same as the `renderContent` props.
|
|
115
|
+
|
|
116
|
+
- Required: Yes
|
|
117
|
+
|
|
118
|
+
### `style`: `React.CSSProperties`
|
|
119
|
+
|
|
120
|
+
The style of the global container
|
|
125
121
|
|
|
126
|
-
- Type: `Function`
|
|
127
122
|
- Required: No
|
|
@@ -1,35 +1,39 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* External dependencies
|
|
4
3
|
*/
|
|
5
4
|
import classnames from 'classnames';
|
|
5
|
+
import type { ForwardedRef } from 'react';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import { forwardRef, useEffect, useRef, useState } from '@wordpress/element';
|
|
11
11
|
import { useMergeRefs } from '@wordpress/compose';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
import Popover from '../popover';
|
|
17
|
+
import type { DropdownProps } from './types';
|
|
17
18
|
|
|
18
|
-
function useObservableState(
|
|
19
|
+
function useObservableState(
|
|
20
|
+
initialState: boolean,
|
|
21
|
+
onStateChange?: ( newState: boolean ) => void
|
|
22
|
+
) {
|
|
19
23
|
const [ state, setState ] = useState( initialState );
|
|
20
24
|
return [
|
|
21
25
|
state,
|
|
22
|
-
( value ) => {
|
|
26
|
+
( value: boolean ) => {
|
|
23
27
|
setState( value );
|
|
24
28
|
if ( onStateChange ) {
|
|
25
29
|
onStateChange( value );
|
|
26
30
|
}
|
|
27
31
|
},
|
|
28
|
-
];
|
|
32
|
+
] as const;
|
|
29
33
|
}
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
function UnforwardedDropdown(
|
|
36
|
+
{
|
|
33
37
|
renderContent,
|
|
34
38
|
renderToggle,
|
|
35
39
|
className,
|
|
@@ -42,12 +46,14 @@ export default function Dropdown( props ) {
|
|
|
42
46
|
onClose,
|
|
43
47
|
onToggle,
|
|
44
48
|
style,
|
|
45
|
-
}
|
|
49
|
+
}: DropdownProps,
|
|
50
|
+
forwardedRef: ForwardedRef< any >
|
|
51
|
+
) {
|
|
46
52
|
// Use internal state instead of a ref to make sure that the component
|
|
47
53
|
// re-renders when the popover's anchor updates.
|
|
48
54
|
const [ fallbackPopoverAnchor, setFallbackPopoverAnchor ] =
|
|
49
|
-
useState( null );
|
|
50
|
-
const containerRef = useRef();
|
|
55
|
+
useState< HTMLDivElement | null >( null );
|
|
56
|
+
const containerRef = useRef< HTMLDivElement >();
|
|
51
57
|
const [ isOpen, setIsOpen ] = useObservableState( false, onToggle );
|
|
52
58
|
|
|
53
59
|
useEffect(
|
|
@@ -70,8 +76,13 @@ export default function Dropdown( props ) {
|
|
|
70
76
|
* case a dialog has opened, allowing focus to return when it's dismissed.
|
|
71
77
|
*/
|
|
72
78
|
function closeIfFocusOutside() {
|
|
79
|
+
if ( ! containerRef.current ) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
73
83
|
const { ownerDocument } = containerRef.current;
|
|
74
|
-
const dialog =
|
|
84
|
+
const dialog =
|
|
85
|
+
ownerDocument?.activeElement?.closest( '[role="dialog"]' );
|
|
75
86
|
if (
|
|
76
87
|
! containerRef.current.contains( ownerDocument.activeElement ) &&
|
|
77
88
|
( ! dialog || dialog.contains( containerRef.current ) )
|
|
@@ -99,11 +110,15 @@ export default function Dropdown( props ) {
|
|
|
99
110
|
return (
|
|
100
111
|
<div
|
|
101
112
|
className={ classnames( 'components-dropdown', className ) }
|
|
102
|
-
ref={ useMergeRefs( [
|
|
113
|
+
ref={ useMergeRefs( [
|
|
114
|
+
containerRef,
|
|
115
|
+
forwardedRef,
|
|
116
|
+
setFallbackPopoverAnchor,
|
|
117
|
+
] ) }
|
|
103
118
|
// Some UAs focus the closest focusable parent when the toggle is
|
|
104
119
|
// clicked. Making this div focusable ensures such UAs will focus
|
|
105
120
|
// it and `closeIfFocusOutside` can tell if the toggle was clicked.
|
|
106
|
-
tabIndex=
|
|
121
|
+
tabIndex={ -1 }
|
|
107
122
|
style={ style }
|
|
108
123
|
>
|
|
109
124
|
{ renderToggle( args ) }
|
|
@@ -136,3 +151,32 @@ export default function Dropdown( props ) {
|
|
|
136
151
|
</div>
|
|
137
152
|
);
|
|
138
153
|
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Renders a button that opens a floating content modal when clicked.
|
|
157
|
+
*
|
|
158
|
+
* ```jsx
|
|
159
|
+
* import { Button, Dropdown } from '@wordpress/components';
|
|
160
|
+
*
|
|
161
|
+
* const MyDropdown = () => (
|
|
162
|
+
* <Dropdown
|
|
163
|
+
* className="my-container-class-name"
|
|
164
|
+
* contentClassName="my-popover-content-classname"
|
|
165
|
+
* position="bottom right"
|
|
166
|
+
* renderToggle={ ( { isOpen, onToggle } ) => (
|
|
167
|
+
* <Button
|
|
168
|
+
* variant="primary"
|
|
169
|
+
* onClick={ onToggle }
|
|
170
|
+
* aria-expanded={ isOpen }
|
|
171
|
+
* >
|
|
172
|
+
* Toggle Popover!
|
|
173
|
+
* </Button>
|
|
174
|
+
* ) }
|
|
175
|
+
* renderContent={ () => <div>This is the content of the popover.</div> }
|
|
176
|
+
* />
|
|
177
|
+
* );
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
export const Dropdown = forwardRef( UnforwardedDropdown );
|
|
181
|
+
|
|
182
|
+
export default Dropdown;
|
|
@@ -1,29 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* Internal dependencies
|
|
3
8
|
*/
|
|
4
|
-
import Dropdown from '
|
|
9
|
+
import Dropdown from '..';
|
|
5
10
|
import Button from '../../button';
|
|
6
11
|
import { DropdownContentWrapper } from '../dropdown-content-wrapper';
|
|
7
12
|
|
|
8
|
-
|
|
13
|
+
const meta: ComponentMeta< typeof Dropdown > = {
|
|
9
14
|
title: 'Components/Dropdown',
|
|
10
15
|
component: Dropdown,
|
|
11
16
|
subcomponents: { DropdownContentWrapper },
|
|
12
17
|
argTypes: {
|
|
13
|
-
expandOnMobile: { control: { type: 'boolean' } },
|
|
14
18
|
focusOnMount: {
|
|
15
19
|
control: {
|
|
16
20
|
type: 'radio',
|
|
17
21
|
options: [ 'firstElement', true, false ],
|
|
18
22
|
},
|
|
19
23
|
},
|
|
20
|
-
headerTitle: { control: { type: 'text' } },
|
|
21
24
|
renderContent: { control: { type: null } },
|
|
22
25
|
renderToggle: { control: { type: null } },
|
|
23
26
|
},
|
|
27
|
+
parameters: {
|
|
28
|
+
controls: {
|
|
29
|
+
expanded: true,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
24
32
|
};
|
|
33
|
+
export default meta;
|
|
25
34
|
|
|
26
|
-
const Template = ( args ) => {
|
|
35
|
+
const Template: ComponentStory< typeof Dropdown > = ( args ) => {
|
|
27
36
|
return (
|
|
28
37
|
<div style={ { height: 150 } }>
|
|
29
38
|
<Dropdown { ...args } />
|
|
@@ -31,7 +40,7 @@ const Template = ( args ) => {
|
|
|
31
40
|
);
|
|
32
41
|
};
|
|
33
42
|
|
|
34
|
-
export const Default = Template.bind( {} );
|
|
43
|
+
export const Default: ComponentStory< typeof Dropdown > = Template.bind( {} );
|
|
35
44
|
Default.args = {
|
|
36
45
|
position: 'bottom right',
|
|
37
46
|
renderToggle: ( { isOpen, onToggle } ) => (
|
|
@@ -46,7 +55,9 @@ Default.args = {
|
|
|
46
55
|
* To apply more padding to the dropdown content, use the provided `<DropdownContentWrapper>`
|
|
47
56
|
* convenience wrapper. A `paddingSize` of `"medium"` is suitable for relatively larger dropdowns (default is `"small"`).
|
|
48
57
|
*/
|
|
49
|
-
export const WithMorePadding = Template.bind(
|
|
58
|
+
export const WithMorePadding: ComponentStory< typeof Dropdown > = Template.bind(
|
|
59
|
+
{}
|
|
60
|
+
);
|
|
50
61
|
WithMorePadding.args = {
|
|
51
62
|
...Default.args,
|
|
52
63
|
renderContent: () => (
|
|
@@ -61,7 +72,9 @@ WithMorePadding.args = {
|
|
|
61
72
|
* with a `paddingSize` of `"none"`. This can also serve as a clean foundation to add arbitrary
|
|
62
73
|
* paddings, for example when child components already have padding on their own.
|
|
63
74
|
*/
|
|
64
|
-
export const WithNoPadding = Template.bind(
|
|
75
|
+
export const WithNoPadding: ComponentStory< typeof Dropdown > = Template.bind(
|
|
76
|
+
{}
|
|
77
|
+
);
|
|
65
78
|
WithNoPadding.args = {
|
|
66
79
|
...Default.args,
|
|
67
80
|
renderContent: () => (
|