@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
package/src/panel/test/body.js
CHANGED
|
@@ -1,154 +1,163 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { render,
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
import userEvent from '@testing-library/user-event';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
8
9
|
*/
|
|
9
10
|
import { PanelBody } from '../body';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
container.querySelector( '.components-panel__body' );
|
|
13
|
-
const getPanelBodyContent = ( container ) =>
|
|
14
|
-
container.querySelector( '.components-panel__body > div' );
|
|
15
|
-
const getPanelToggle = ( container ) =>
|
|
16
|
-
container.querySelector( '.components-panel__body-toggle' );
|
|
12
|
+
jest.useFakeTimers();
|
|
17
13
|
|
|
18
14
|
describe( 'PanelBody', () => {
|
|
19
15
|
describe( 'basic rendering', () => {
|
|
20
16
|
it( 'should render an empty div with the matching className', () => {
|
|
21
17
|
const { container } = render( <PanelBody /> );
|
|
22
|
-
const panelBody = getPanelBody( container );
|
|
23
18
|
|
|
24
|
-
expect(
|
|
25
|
-
expect( panelBody.tagName ).toBe( 'DIV' );
|
|
19
|
+
expect( container ).toMatchSnapshot();
|
|
26
20
|
} );
|
|
27
21
|
|
|
28
22
|
it( 'should render inner content, if opened', () => {
|
|
29
|
-
|
|
30
|
-
<PanelBody opened
|
|
31
|
-
<div
|
|
23
|
+
render(
|
|
24
|
+
<PanelBody opened>
|
|
25
|
+
<div data-testid="inner-content">Content</div>
|
|
32
26
|
</PanelBody>
|
|
33
27
|
);
|
|
34
|
-
const panelContent = getPanelBodyContent( container );
|
|
35
28
|
|
|
36
|
-
expect(
|
|
29
|
+
expect( screen.getByTestId( 'inner-content' ) ).toBeVisible();
|
|
37
30
|
} );
|
|
38
31
|
|
|
39
32
|
it( 'should be opened by default', () => {
|
|
40
|
-
|
|
33
|
+
render(
|
|
41
34
|
<PanelBody>
|
|
42
|
-
<div>Content</div>
|
|
35
|
+
<div data-testid="inner-content">Content</div>
|
|
43
36
|
</PanelBody>
|
|
44
37
|
);
|
|
45
|
-
const panelContent = getPanelBodyContent( container );
|
|
46
38
|
|
|
47
|
-
expect(
|
|
39
|
+
expect( screen.getByTestId( 'inner-content' ) ).toBeVisible();
|
|
48
40
|
} );
|
|
49
41
|
|
|
50
42
|
it( 'should render as initially opened, if specified', () => {
|
|
51
|
-
|
|
52
|
-
<PanelBody initialOpen
|
|
53
|
-
<div>Content</div>
|
|
43
|
+
render(
|
|
44
|
+
<PanelBody initialOpen>
|
|
45
|
+
<div data-testid="inner-content">Content</div>
|
|
54
46
|
</PanelBody>
|
|
55
47
|
);
|
|
56
|
-
const panelContent = getPanelBodyContent( container );
|
|
57
48
|
|
|
58
|
-
expect(
|
|
49
|
+
expect( screen.getByTestId( 'inner-content' ) ).toBeVisible();
|
|
59
50
|
} );
|
|
60
51
|
|
|
61
52
|
it( 'should call the children function, if specified', () => {
|
|
62
|
-
const {
|
|
63
|
-
<PanelBody opened
|
|
64
|
-
{ ( { opened } ) =>
|
|
53
|
+
const { rerender } = render(
|
|
54
|
+
<PanelBody opened>
|
|
55
|
+
{ ( { opened } ) => (
|
|
56
|
+
<div hidden={ opened } data-testid="inner-content">
|
|
57
|
+
Content
|
|
58
|
+
</div>
|
|
59
|
+
) }
|
|
65
60
|
</PanelBody>
|
|
66
61
|
);
|
|
67
|
-
let panelContent = getPanelBodyContent( container );
|
|
68
62
|
|
|
69
|
-
|
|
63
|
+
let panelContent = screen.getByTestId( 'inner-content' );
|
|
64
|
+
|
|
65
|
+
expect( panelContent ).toBeInTheDocument();
|
|
66
|
+
expect( panelContent ).not.toBeVisible();
|
|
70
67
|
expect( panelContent ).toHaveAttribute( 'hidden', '' );
|
|
71
68
|
|
|
72
69
|
rerender(
|
|
73
70
|
<PanelBody opened={ false }>
|
|
74
|
-
{ ( { opened } ) =>
|
|
71
|
+
{ ( { opened } ) => (
|
|
72
|
+
<div hidden={ opened } data-testid="inner-content">
|
|
73
|
+
Content
|
|
74
|
+
</div>
|
|
75
|
+
) }
|
|
75
76
|
</PanelBody>
|
|
76
77
|
);
|
|
77
|
-
panelContent = getPanelBodyContent( container );
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
panelContent = screen.getByTestId( 'inner-content' );
|
|
80
|
+
|
|
81
|
+
expect( panelContent ).toBeVisible();
|
|
80
82
|
expect( panelContent ).not.toHaveAttribute( 'hidden' );
|
|
81
83
|
} );
|
|
82
84
|
} );
|
|
83
85
|
|
|
84
86
|
describe( 'toggling', () => {
|
|
85
87
|
it( 'should toggle collapse with opened prop', () => {
|
|
86
|
-
const {
|
|
87
|
-
<PanelBody opened
|
|
88
|
-
<div>Content</div>
|
|
88
|
+
const { rerender } = render(
|
|
89
|
+
<PanelBody opened>
|
|
90
|
+
<div data-testid="inner-content">Content</div>
|
|
89
91
|
</PanelBody>
|
|
90
92
|
);
|
|
91
|
-
let panelContent = getPanelBodyContent( container );
|
|
92
93
|
|
|
93
|
-
|
|
94
|
+
let panelContent = screen.getByTestId( 'inner-content' );
|
|
95
|
+
|
|
96
|
+
expect( panelContent ).toBeVisible();
|
|
94
97
|
|
|
95
98
|
rerender(
|
|
96
99
|
<PanelBody opened={ false }>
|
|
97
|
-
<div>Content</div>
|
|
100
|
+
<div data-testid="inner-content">Content</div>
|
|
98
101
|
</PanelBody>
|
|
99
102
|
);
|
|
100
103
|
|
|
101
|
-
panelContent =
|
|
104
|
+
panelContent = screen.queryByTestId( 'inner-content' );
|
|
102
105
|
|
|
103
|
-
expect( panelContent ).
|
|
106
|
+
expect( panelContent ).not.toBeInTheDocument();
|
|
104
107
|
|
|
105
108
|
rerender(
|
|
106
|
-
<PanelBody opened
|
|
107
|
-
<div>Content</div>
|
|
109
|
+
<PanelBody opened>
|
|
110
|
+
<div data-testid="inner-content">Content</div>
|
|
108
111
|
</PanelBody>
|
|
109
112
|
);
|
|
110
113
|
|
|
111
|
-
panelContent =
|
|
114
|
+
panelContent = screen.getByTestId( 'inner-content' );
|
|
112
115
|
|
|
113
|
-
expect( panelContent ).
|
|
116
|
+
expect( panelContent ).toBeVisible();
|
|
114
117
|
} );
|
|
115
118
|
|
|
116
|
-
it( 'should toggle when clicking header', () => {
|
|
117
|
-
const
|
|
119
|
+
it( 'should toggle when clicking header', async () => {
|
|
120
|
+
const user = userEvent.setup( {
|
|
121
|
+
advanceTimers: jest.advanceTimersByTime,
|
|
122
|
+
} );
|
|
123
|
+
|
|
124
|
+
render(
|
|
118
125
|
<PanelBody title="Panel" initialOpen={ false }>
|
|
119
|
-
<div>Content</div>
|
|
126
|
+
<div data-testid="inner-content">Content</div>
|
|
120
127
|
</PanelBody>
|
|
121
128
|
);
|
|
122
|
-
let panelContent = getPanelBodyContent( container );
|
|
123
|
-
const panelToggle = getPanelToggle( container );
|
|
124
129
|
|
|
125
|
-
|
|
130
|
+
let panelContent = screen.queryByTestId( 'inner-content' );
|
|
131
|
+
const panelToggle = screen.getByRole( 'button', { name: 'Panel' } );
|
|
132
|
+
|
|
133
|
+
expect( panelContent ).not.toBeInTheDocument();
|
|
126
134
|
|
|
127
|
-
|
|
135
|
+
await user.click( panelToggle );
|
|
128
136
|
|
|
129
|
-
panelContent =
|
|
137
|
+
panelContent = screen.getByTestId( 'inner-content' );
|
|
130
138
|
|
|
131
|
-
expect( panelContent ).
|
|
139
|
+
expect( panelContent ).toBeVisible();
|
|
132
140
|
|
|
133
|
-
|
|
141
|
+
await user.click( panelToggle );
|
|
134
142
|
|
|
135
|
-
panelContent =
|
|
143
|
+
panelContent = screen.queryByTestId( 'inner-content' );
|
|
136
144
|
|
|
137
|
-
expect( panelContent ).
|
|
145
|
+
expect( panelContent ).not.toBeInTheDocument();
|
|
138
146
|
} );
|
|
139
147
|
|
|
140
|
-
it( 'should pass button props to panel title', () => {
|
|
148
|
+
it( 'should pass button props to panel title', async () => {
|
|
149
|
+
const user = userEvent.setup( {
|
|
150
|
+
advanceTimers: jest.advanceTimersByTime,
|
|
151
|
+
} );
|
|
141
152
|
const mock = jest.fn();
|
|
142
153
|
|
|
143
|
-
|
|
154
|
+
render(
|
|
144
155
|
<PanelBody title="Panel" buttonProps={ { onClick: mock } }>
|
|
145
|
-
<div>Content</div>
|
|
156
|
+
<div data-testid="inner-content">Content</div>
|
|
146
157
|
</PanelBody>
|
|
147
158
|
);
|
|
148
159
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
fireEvent.click( panelToggle );
|
|
160
|
+
await user.click( screen.getByRole( 'button', { name: 'Panel' } ) );
|
|
152
161
|
|
|
153
162
|
expect( mock ).toHaveBeenCalled();
|
|
154
163
|
} );
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
> svg,
|
|
46
46
|
.dashicon,
|
|
47
47
|
.block-editor-block-icon {
|
|
48
|
-
margin-right:
|
|
48
|
+
margin-right: $grid-unit-15;
|
|
49
49
|
fill: currentColor;
|
|
50
50
|
// Optimizate for high contrast modes.
|
|
51
51
|
// See also https://blogs.windows.com/msedgedev/2020/09/17/styling-for-windows-high-contrast-with-new-standards-for-forced-colors/.
|
|
@@ -59,6 +59,7 @@ describe( 'Placeholder', () => {
|
|
|
59
59
|
|
|
60
60
|
// Test for empty label. When the label is empty, the only way to
|
|
61
61
|
// query the div is with `querySelector`.
|
|
62
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
62
63
|
const label = placeholder.querySelector(
|
|
63
64
|
'.components-placeholder__label'
|
|
64
65
|
);
|
|
@@ -67,6 +68,7 @@ describe( 'Placeholder', () => {
|
|
|
67
68
|
|
|
68
69
|
// Test for non existent instructions. When the instructions is
|
|
69
70
|
// empty, the only way to query the div is with `querySelector`.
|
|
71
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
70
72
|
const placeholderInstructions = placeholder.querySelector(
|
|
71
73
|
'.components-placeholder__instructions'
|
|
72
74
|
);
|
|
@@ -84,6 +86,7 @@ describe( 'Placeholder', () => {
|
|
|
84
86
|
|
|
85
87
|
const placeholder = getPlaceholder();
|
|
86
88
|
const icon = within( placeholder ).getByTestId( 'icon' );
|
|
89
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
87
90
|
expect( icon.parentNode ).toHaveClass(
|
|
88
91
|
'components-placeholder__label'
|
|
89
92
|
);
|
|
@@ -38,8 +38,8 @@ const Edit = ( props ) => {
|
|
|
38
38
|
} }
|
|
39
39
|
onResizeStop={ ( event, direction, elt, delta ) => {
|
|
40
40
|
setAttributes( {
|
|
41
|
-
height:
|
|
42
|
-
width:
|
|
41
|
+
height: height + delta.height,
|
|
42
|
+
width: width + delta.width,
|
|
43
43
|
} );
|
|
44
44
|
toggleSelection( true );
|
|
45
45
|
} }
|
|
@@ -88,14 +88,13 @@ const HANDLE_STYLES = {
|
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
type ResizableBoxProps = ResizableProps & {
|
|
91
|
-
className: string;
|
|
92
91
|
children: ReactNode;
|
|
93
|
-
showHandle
|
|
94
|
-
__experimentalShowTooltip
|
|
95
|
-
__experimentalTooltipProps
|
|
92
|
+
showHandle?: boolean;
|
|
93
|
+
__experimentalShowTooltip?: boolean;
|
|
94
|
+
__experimentalTooltipProps?: Parameters< typeof ResizeTooltip >[ 0 ];
|
|
96
95
|
};
|
|
97
96
|
|
|
98
|
-
function
|
|
97
|
+
function UnforwardedResizableBox(
|
|
99
98
|
{
|
|
100
99
|
className,
|
|
101
100
|
children,
|
|
@@ -124,4 +123,6 @@ function ResizableBox(
|
|
|
124
123
|
);
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
export
|
|
126
|
+
export const ResizableBox = forwardRef( UnforwardedResizableBox );
|
|
127
|
+
|
|
128
|
+
export default ResizableBox;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import ResizableBox from '..';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* WordPress dependencies
|
|
13
|
+
*/
|
|
14
|
+
import { useState } from '@wordpress/element';
|
|
15
|
+
|
|
16
|
+
const meta: ComponentMeta< typeof ResizableBox > = {
|
|
17
|
+
title: 'Components/ResizableBox',
|
|
18
|
+
component: ResizableBox,
|
|
19
|
+
argTypes: {
|
|
20
|
+
children: { control: { type: null } },
|
|
21
|
+
enable: { control: 'object' },
|
|
22
|
+
onResizeStop: { action: 'onResizeStop' },
|
|
23
|
+
},
|
|
24
|
+
parameters: {
|
|
25
|
+
controls: { expanded: true },
|
|
26
|
+
docs: { source: { state: 'open' } },
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export default meta;
|
|
30
|
+
|
|
31
|
+
const Template: ComponentStory< typeof ResizableBox > = ( {
|
|
32
|
+
onResizeStop,
|
|
33
|
+
...props
|
|
34
|
+
} ) => {
|
|
35
|
+
const [ { height, width }, setAttributes ] = useState( {
|
|
36
|
+
height: 200,
|
|
37
|
+
width: 400,
|
|
38
|
+
} );
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<ResizableBox
|
|
42
|
+
{ ...props }
|
|
43
|
+
size={ {
|
|
44
|
+
height,
|
|
45
|
+
width,
|
|
46
|
+
} }
|
|
47
|
+
onResizeStop={ ( event, direction, elt, delta ) => {
|
|
48
|
+
onResizeStop?.( event, direction, elt, delta );
|
|
49
|
+
setAttributes( {
|
|
50
|
+
height: height + delta.height,
|
|
51
|
+
width: width + delta.width,
|
|
52
|
+
} );
|
|
53
|
+
} }
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const Default = Template.bind( {} );
|
|
59
|
+
Default.args = {
|
|
60
|
+
children: (
|
|
61
|
+
<div
|
|
62
|
+
style={ {
|
|
63
|
+
background: '#eee',
|
|
64
|
+
display: 'flex',
|
|
65
|
+
height: '100%',
|
|
66
|
+
width: '100%',
|
|
67
|
+
alignItems: 'center',
|
|
68
|
+
justifyContent: 'center',
|
|
69
|
+
} }
|
|
70
|
+
>
|
|
71
|
+
Resize
|
|
72
|
+
</div>
|
|
73
|
+
),
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The `enable` prop can be used to disable resizing in specific directions.
|
|
78
|
+
*/
|
|
79
|
+
export const DisabledDirections = Template.bind( {} );
|
|
80
|
+
DisabledDirections.args = {
|
|
81
|
+
...Default.args,
|
|
82
|
+
enable: {
|
|
83
|
+
top: false,
|
|
84
|
+
right: true,
|
|
85
|
+
bottom: true,
|
|
86
|
+
left: false,
|
|
87
|
+
topRight: false,
|
|
88
|
+
bottomRight: true,
|
|
89
|
+
bottomLeft: false,
|
|
90
|
+
topLeft: false,
|
|
91
|
+
},
|
|
92
|
+
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# ResponsiveWrapper
|
|
2
2
|
|
|
3
|
+
A wrapper component that maintains its aspect ratio when resized.
|
|
4
|
+
|
|
3
5
|
## Usage
|
|
4
6
|
|
|
5
7
|
```jsx
|
|
@@ -14,3 +16,30 @@ const MyResponsiveWrapper = () => (
|
|
|
14
16
|
</ResponsiveWrapper>
|
|
15
17
|
);
|
|
16
18
|
```
|
|
19
|
+
|
|
20
|
+
## Props
|
|
21
|
+
|
|
22
|
+
### `children`: `React.ReactElement`
|
|
23
|
+
|
|
24
|
+
The element to wrap.
|
|
25
|
+
|
|
26
|
+
- Required: Yes
|
|
27
|
+
|
|
28
|
+
### `isInline`: `boolean`
|
|
29
|
+
|
|
30
|
+
If true, the wrapper will be `span` instead of `div`.
|
|
31
|
+
|
|
32
|
+
- Required: No
|
|
33
|
+
- Default: `false`
|
|
34
|
+
|
|
35
|
+
### `naturalHeight`: `number`
|
|
36
|
+
|
|
37
|
+
The intrinsic height of the element to wrap. Will be used to determine the aspect ratio.
|
|
38
|
+
|
|
39
|
+
- Required: Yes
|
|
40
|
+
|
|
41
|
+
### `naturalWidth`: `number`
|
|
42
|
+
|
|
43
|
+
The intrinsic width of the element to wrap. Will be used to determine the aspect ratio.
|
|
44
|
+
|
|
45
|
+
- Required: Yes
|
|
@@ -9,12 +9,33 @@ import classnames from 'classnames';
|
|
|
9
9
|
import { cloneElement, Children } from '@wordpress/element';
|
|
10
10
|
import { useResizeObserver } from '@wordpress/compose';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import type { ResponsiveWrapperProps } from './types';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A wrapper component that maintains its aspect ratio when resized.
|
|
19
|
+
*
|
|
20
|
+
* ```jsx
|
|
21
|
+
* import { ResponsiveWrapper } from '@wordpress/components';
|
|
22
|
+
*
|
|
23
|
+
* const MyResponsiveWrapper = () => (
|
|
24
|
+
* <ResponsiveWrapper naturalWidth={ 2000 } naturalHeight={ 680 }>
|
|
25
|
+
* <img
|
|
26
|
+
* src="https://s.w.org/style/images/about/WordPress-logotype-standard.png"
|
|
27
|
+
* alt="WordPress"
|
|
28
|
+
* />
|
|
29
|
+
* </ResponsiveWrapper>
|
|
30
|
+
* );
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
12
33
|
function ResponsiveWrapper( {
|
|
13
34
|
naturalWidth,
|
|
14
35
|
naturalHeight,
|
|
15
36
|
children,
|
|
16
37
|
isInline = false,
|
|
17
|
-
} ) {
|
|
38
|
+
}: ResponsiveWrapperProps ) {
|
|
18
39
|
const [ containerResizeListener, { width: containerWidth } ] =
|
|
19
40
|
useResizeObserver();
|
|
20
41
|
if ( Children.count( children ) !== 1 ) {
|
|
@@ -22,7 +43,7 @@ function ResponsiveWrapper( {
|
|
|
22
43
|
}
|
|
23
44
|
const imageStyle = {
|
|
24
45
|
paddingBottom:
|
|
25
|
-
naturalWidth < containerWidth
|
|
46
|
+
naturalWidth < ( containerWidth ?? 0 )
|
|
26
47
|
? naturalHeight
|
|
27
48
|
: ( naturalHeight / naturalWidth ) * 100 + '%',
|
|
28
49
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import ResponsiveWrapper from '..';
|
|
10
|
+
|
|
11
|
+
const meta: ComponentMeta< typeof ResponsiveWrapper > = {
|
|
12
|
+
component: ResponsiveWrapper,
|
|
13
|
+
title: 'Components/ResponsiveWrapper',
|
|
14
|
+
argTypes: {
|
|
15
|
+
children: { control: { type: null } },
|
|
16
|
+
},
|
|
17
|
+
parameters: {
|
|
18
|
+
controls: { expanded: true },
|
|
19
|
+
docs: { source: { state: 'open' } },
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
export default meta;
|
|
23
|
+
|
|
24
|
+
const Template: ComponentStory< typeof ResponsiveWrapper > = ( args ) => (
|
|
25
|
+
<ResponsiveWrapper { ...args } />
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export const Default = Template.bind( {} );
|
|
29
|
+
Default.args = {
|
|
30
|
+
naturalWidth: 2000,
|
|
31
|
+
naturalHeight: 680,
|
|
32
|
+
children: (
|
|
33
|
+
<img
|
|
34
|
+
src="https://s.w.org/style/images/about/WordPress-logotype-standard.png"
|
|
35
|
+
alt="WordPress"
|
|
36
|
+
/>
|
|
37
|
+
),
|
|
38
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type ResponsiveWrapperProps = {
|
|
2
|
+
/**
|
|
3
|
+
* The intrinsic width of the element to wrap. Will be used to determine the aspect ratio.
|
|
4
|
+
*/
|
|
5
|
+
naturalWidth: number;
|
|
6
|
+
/**
|
|
7
|
+
* The intrinsic height of the element to wrap. Will be used to determine the aspect ratio.
|
|
8
|
+
*/
|
|
9
|
+
naturalHeight: number;
|
|
10
|
+
/**
|
|
11
|
+
* The element to wrap.
|
|
12
|
+
*/
|
|
13
|
+
children: React.ReactElement;
|
|
14
|
+
/**
|
|
15
|
+
* If true, the wrapper will be `span` instead of `div`.
|
|
16
|
+
*
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
isInline?: boolean;
|
|
20
|
+
};
|
package/src/sandbox/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SandBox
|
|
2
2
|
|
|
3
3
|
This component provides an isolated environment for arbitrary HTML via iframes.
|
|
4
4
|
|
|
@@ -8,6 +8,49 @@ This component provides an isolated environment for arbitrary HTML via iframes.
|
|
|
8
8
|
import { SandBox } from '@wordpress/components';
|
|
9
9
|
|
|
10
10
|
const MySandBox = () => (
|
|
11
|
-
<SandBox html="<p>Content</p>" title="
|
|
11
|
+
<SandBox html="<p>Content</p>" title="SandBox" type="embed" />
|
|
12
12
|
);
|
|
13
13
|
```
|
|
14
|
+
|
|
15
|
+
## Props
|
|
16
|
+
|
|
17
|
+
### `html`: `string`
|
|
18
|
+
|
|
19
|
+
The HTML to render in the body of the iframe document.
|
|
20
|
+
|
|
21
|
+
- Required: No
|
|
22
|
+
- Default: ""
|
|
23
|
+
|
|
24
|
+
### `onFocus`: `React.DOMAttributes< HTMLIFrameElement >[ 'onFocus' ]`
|
|
25
|
+
|
|
26
|
+
The `onFocus` callback for the iframe.
|
|
27
|
+
|
|
28
|
+
- Required: No
|
|
29
|
+
|
|
30
|
+
### `scripts`: `string[]`
|
|
31
|
+
|
|
32
|
+
An array of script URLs to inject as `<script>` tags into the bottom of the `<body>` of the iframe document.
|
|
33
|
+
|
|
34
|
+
- Required: No
|
|
35
|
+
- Default: []
|
|
36
|
+
|
|
37
|
+
### `styles`: `string[]`
|
|
38
|
+
|
|
39
|
+
An array of CSS strings to inject into the `<head>` of the iframe document.
|
|
40
|
+
|
|
41
|
+
- Required: No
|
|
42
|
+
- Default: []
|
|
43
|
+
|
|
44
|
+
### `title`: `string`
|
|
45
|
+
|
|
46
|
+
The `<title>` of the iframe document.
|
|
47
|
+
|
|
48
|
+
- Required: No
|
|
49
|
+
- Default: ""
|
|
50
|
+
|
|
51
|
+
### `type`: `string`
|
|
52
|
+
|
|
53
|
+
The CSS class name to apply to the `<html>` and `<body>` elements of the iframe.
|
|
54
|
+
|
|
55
|
+
- Required: No
|
|
56
|
+
- Default: ""
|