@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
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default = void 0;
|
|
8
|
+
exports.default = exports.ResizableBox = void 0;
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
@@ -61,7 +61,7 @@ const HANDLE_STYLES = {
|
|
|
61
61
|
bottomLeft: HANDLE_STYLES_OVERRIDES
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
function
|
|
64
|
+
function UnforwardedResizableBox(_ref, ref) {
|
|
65
65
|
let {
|
|
66
66
|
className,
|
|
67
67
|
children,
|
|
@@ -78,7 +78,8 @@ function ResizableBox(_ref, ref) {
|
|
|
78
78
|
}, props), children, showTooltip && (0, _element.createElement)(_resizeTooltip.default, tooltipProps));
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
const ResizableBox = (0, _element.forwardRef)(UnforwardedResizableBox);
|
|
82
|
+
exports.ResizableBox = ResizableBox;
|
|
83
|
+
var _default = ResizableBox;
|
|
83
84
|
exports.default = _default;
|
|
84
85
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/resizable-box/index.tsx"],"names":["HANDLE_CLASS_NAME","SIDE_HANDLE_CLASS_NAME","CORNER_HANDLE_CLASS_NAME","HANDLE_CLASSES","top","right","bottom","left","topLeft","topRight","bottomRight","bottomLeft","HANDLE_STYLES_OVERRIDES","width","undefined","height","HANDLE_STYLES","
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/resizable-box/index.tsx"],"names":["HANDLE_CLASS_NAME","SIDE_HANDLE_CLASS_NAME","CORNER_HANDLE_CLASS_NAME","HANDLE_CLASSES","top","right","bottom","left","topLeft","topRight","bottomRight","bottomLeft","HANDLE_STYLES_OVERRIDES","width","undefined","height","HANDLE_STYLES","UnforwardedResizableBox","ref","className","children","showHandle","__experimentalShowTooltip","showTooltip","__experimentalTooltipProps","tooltipProps","props","ResizableBox"],"mappings":";;;;;;;;;AAGA;;;;AAKA;;AACA;;AAOA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAGA,MAAMA,iBAAiB,GAAG,kCAA1B;AACA,MAAMC,sBAAsB,GAAG,uCAA/B;AACA,MAAMC,wBAAwB,GAAG,yCAAjC;AAEA,MAAMC,cAAc,GAAG;AACtBC,EAAAA,GAAG,EAAE,yBACJJ,iBADI,EAEJC,sBAFI,EAGJ,sCAHI,CADiB;AAMtBI,EAAAA,KAAK,EAAE,yBACNL,iBADM,EAENC,sBAFM,EAGN,wCAHM,CANe;AAWtBK,EAAAA,MAAM,EAAE,yBACPN,iBADO,EAEPC,sBAFO,EAGP,yCAHO,CAXc;AAgBtBM,EAAAA,IAAI,EAAE,yBACLP,iBADK,EAELC,sBAFK,EAGL,uCAHK,CAhBgB;AAqBtBO,EAAAA,OAAO,EAAE,yBACRR,iBADQ,EAERE,wBAFQ,EAGR,sCAHQ,EAIR,uCAJQ,CArBa;AA2BtBO,EAAAA,QAAQ,EAAE,yBACTT,iBADS,EAETE,wBAFS,EAGT,sCAHS,EAIT,wCAJS,CA3BY;AAiCtBQ,EAAAA,WAAW,EAAE,yBACZV,iBADY,EAEZE,wBAFY,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D;AAgBA;;AAEM,MAAME,YAAY,GAAG,yBAAYV,uBAAZ,CAArB;;eAEQU,Y","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { Resizable } from 're-resizable';\nimport type { ResizableProps } from 're-resizable';\nimport type { ReactNode, ForwardedRef } from 'react';\n\n/**\n * Internal dependencies\n */\nimport ResizeTooltip from './resize-tooltip';\n\nconst HANDLE_CLASS_NAME = 'components-resizable-box__handle';\nconst SIDE_HANDLE_CLASS_NAME = 'components-resizable-box__side-handle';\nconst CORNER_HANDLE_CLASS_NAME = 'components-resizable-box__corner-handle';\n\nconst HANDLE_CLASSES = {\n\ttop: classnames(\n\t\tHANDLE_CLASS_NAME,\n\t\tSIDE_HANDLE_CLASS_NAME,\n\t\t'components-resizable-box__handle-top'\n\t),\n\tright: classnames(\n\t\tHANDLE_CLASS_NAME,\n\t\tSIDE_HANDLE_CLASS_NAME,\n\t\t'components-resizable-box__handle-right'\n\t),\n\tbottom: classnames(\n\t\tHANDLE_CLASS_NAME,\n\t\tSIDE_HANDLE_CLASS_NAME,\n\t\t'components-resizable-box__handle-bottom'\n\t),\n\tleft: classnames(\n\t\tHANDLE_CLASS_NAME,\n\t\tSIDE_HANDLE_CLASS_NAME,\n\t\t'components-resizable-box__handle-left'\n\t),\n\ttopLeft: classnames(\n\t\tHANDLE_CLASS_NAME,\n\t\tCORNER_HANDLE_CLASS_NAME,\n\t\t'components-resizable-box__handle-top',\n\t\t'components-resizable-box__handle-left'\n\t),\n\ttopRight: classnames(\n\t\tHANDLE_CLASS_NAME,\n\t\tCORNER_HANDLE_CLASS_NAME,\n\t\t'components-resizable-box__handle-top',\n\t\t'components-resizable-box__handle-right'\n\t),\n\tbottomRight: classnames(\n\t\tHANDLE_CLASS_NAME,\n\t\tCORNER_HANDLE_CLASS_NAME,\n\t\t'components-resizable-box__handle-bottom',\n\t\t'components-resizable-box__handle-right'\n\t),\n\tbottomLeft: classnames(\n\t\tHANDLE_CLASS_NAME,\n\t\tCORNER_HANDLE_CLASS_NAME,\n\t\t'components-resizable-box__handle-bottom',\n\t\t'components-resizable-box__handle-left'\n\t),\n};\n\n// Removes the inline styles in the drag handles.\nconst HANDLE_STYLES_OVERRIDES = {\n\twidth: undefined,\n\theight: undefined,\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\nconst HANDLE_STYLES = {\n\ttop: HANDLE_STYLES_OVERRIDES,\n\tright: HANDLE_STYLES_OVERRIDES,\n\tbottom: HANDLE_STYLES_OVERRIDES,\n\tleft: HANDLE_STYLES_OVERRIDES,\n\ttopLeft: HANDLE_STYLES_OVERRIDES,\n\ttopRight: HANDLE_STYLES_OVERRIDES,\n\tbottomRight: HANDLE_STYLES_OVERRIDES,\n\tbottomLeft: HANDLE_STYLES_OVERRIDES,\n};\n\ntype ResizableBoxProps = ResizableProps & {\n\tchildren: ReactNode;\n\tshowHandle?: boolean;\n\t__experimentalShowTooltip?: boolean;\n\t__experimentalTooltipProps?: Parameters< typeof ResizeTooltip >[ 0 ];\n};\n\nfunction UnforwardedResizableBox(\n\t{\n\t\tclassName,\n\t\tchildren,\n\t\tshowHandle = true,\n\t\t__experimentalShowTooltip: showTooltip = false,\n\t\t__experimentalTooltipProps: tooltipProps = {},\n\t\t...props\n\t}: ResizableBoxProps,\n\tref: ForwardedRef< Resizable >\n): JSX.Element {\n\treturn (\n\t\t<Resizable\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-resizable-box__container',\n\t\t\t\tshowHandle && 'has-show-handle',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\thandleClasses={ HANDLE_CLASSES }\n\t\t\thandleStyles={ HANDLE_STYLES }\n\t\t\tref={ ref }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ children }\n\t\t\t{ showTooltip && <ResizeTooltip { ...tooltipProps } /> }\n\t\t</Resizable>\n\t);\n}\n\nexport const ResizableBox = forwardRef( UnforwardedResizableBox );\n\nexport default ResizableBox;\n"]}
|
|
@@ -20,6 +20,23 @@ var _compose = require("@wordpress/compose");
|
|
|
20
20
|
/**
|
|
21
21
|
* WordPress dependencies
|
|
22
22
|
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A wrapper component that maintains its aspect ratio when resized.
|
|
26
|
+
*
|
|
27
|
+
* ```jsx
|
|
28
|
+
* import { ResponsiveWrapper } from '@wordpress/components';
|
|
29
|
+
*
|
|
30
|
+
* const MyResponsiveWrapper = () => (
|
|
31
|
+
* <ResponsiveWrapper naturalWidth={ 2000 } naturalHeight={ 680 }>
|
|
32
|
+
* <img
|
|
33
|
+
* src="https://s.w.org/style/images/about/WordPress-logotype-standard.png"
|
|
34
|
+
* alt="WordPress"
|
|
35
|
+
* />
|
|
36
|
+
* </ResponsiveWrapper>
|
|
37
|
+
* );
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
23
40
|
function ResponsiveWrapper(_ref) {
|
|
24
41
|
let {
|
|
25
42
|
naturalWidth,
|
|
@@ -36,7 +53,7 @@ function ResponsiveWrapper(_ref) {
|
|
|
36
53
|
}
|
|
37
54
|
|
|
38
55
|
const imageStyle = {
|
|
39
|
-
paddingBottom: naturalWidth < containerWidth ? naturalHeight : naturalHeight / naturalWidth * 100 + '%'
|
|
56
|
+
paddingBottom: naturalWidth < (containerWidth !== null && containerWidth !== void 0 ? containerWidth : 0) ? naturalHeight : naturalHeight / naturalWidth * 100 + '%'
|
|
40
57
|
};
|
|
41
58
|
const TagName = isInline ? 'span' : 'div';
|
|
42
59
|
return (0, _element.createElement)(TagName, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/responsive-wrapper/index.
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/responsive-wrapper/index.tsx"],"names":["ResponsiveWrapper","naturalWidth","naturalHeight","children","isInline","containerResizeListener","width","containerWidth","Children","count","imageStyle","paddingBottom","TagName","className","props"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,iBAAT,OAK4B;AAAA,MALA;AAC3BC,IAAAA,YAD2B;AAE3BC,IAAAA,aAF2B;AAG3BC,IAAAA,QAH2B;AAI3BC,IAAAA,QAAQ,GAAG;AAJgB,GAKA;AAC3B,QAAM,CAAEC,uBAAF,EAA2B;AAAEC,IAAAA,KAAK,EAAEC;AAAT,GAA3B,IACL,iCADD;;AAEA,MAAKC,kBAASC,KAAT,CAAgBN,QAAhB,MAA+B,CAApC,EAAwC;AACvC,WAAO,IAAP;AACA;;AACD,QAAMO,UAAU,GAAG;AAClBC,IAAAA,aAAa,EACZV,YAAY,IAAKM,cAAL,aAAKA,cAAL,cAAKA,cAAL,GAAuB,CAAvB,CAAZ,GACGL,aADH,GAEKA,aAAa,GAAGD,YAAlB,GAAmC,GAAnC,GAAyC;AAJ3B,GAAnB;AAMA,QAAMW,OAAO,GAAGR,QAAQ,GAAG,MAAH,GAAY,KAApC;AACA,SACC,4BAAC,OAAD;AAAS,IAAA,SAAS,EAAC;AAAnB,KACGC,uBADH,EAEC,4BAAC,OAAD;AAAS,IAAA,KAAK,EAAGK;AAAjB,IAFD,EAGG,2BAAcP,QAAd,EAAwB;AACzBU,IAAAA,SAAS,EAAE,yBACV,wCADU,EAEVV,QAAQ,CAACW,KAAT,CAAeD,SAFL;AADc,GAAxB,CAHH,CADD;AAYA;;eAEcb,iB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { cloneElement, Children } from '@wordpress/element';\nimport { useResizeObserver } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { ResponsiveWrapperProps } from './types';\n\n/**\n * A wrapper component that maintains its aspect ratio when resized.\n *\n * ```jsx\n * import { ResponsiveWrapper } from '@wordpress/components';\n *\n * const MyResponsiveWrapper = () => (\n * \t<ResponsiveWrapper naturalWidth={ 2000 } naturalHeight={ 680 }>\n * \t\t<img\n * \t\t\tsrc=\"https://s.w.org/style/images/about/WordPress-logotype-standard.png\"\n * \t\t\talt=\"WordPress\"\n * \t\t/>\n * \t</ResponsiveWrapper>\n * );\n * ```\n */\nfunction ResponsiveWrapper( {\n\tnaturalWidth,\n\tnaturalHeight,\n\tchildren,\n\tisInline = false,\n}: ResponsiveWrapperProps ) {\n\tconst [ containerResizeListener, { width: containerWidth } ] =\n\t\tuseResizeObserver();\n\tif ( Children.count( children ) !== 1 ) {\n\t\treturn null;\n\t}\n\tconst imageStyle = {\n\t\tpaddingBottom:\n\t\t\tnaturalWidth < ( containerWidth ?? 0 )\n\t\t\t\t? naturalHeight\n\t\t\t\t: ( naturalHeight / naturalWidth ) * 100 + '%',\n\t};\n\tconst TagName = isInline ? 'span' : 'div';\n\treturn (\n\t\t<TagName className=\"components-responsive-wrapper\">\n\t\t\t{ containerResizeListener }\n\t\t\t<TagName style={ imageStyle } />\n\t\t\t{ cloneElement( children, {\n\t\t\t\tclassName: classnames(\n\t\t\t\t\t'components-responsive-wrapper__content',\n\t\t\t\t\tchildren.props.className\n\t\t\t\t),\n\t\t\t} ) }\n\t\t</TagName>\n\t);\n}\n\nexport default ResponsiveWrapper;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
package/build/sandbox/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
|
|
8
8
|
var _element = require("@wordpress/element");
|
|
9
9
|
|
|
@@ -64,7 +64,8 @@ const observeAndResizeJS = function () {
|
|
|
64
64
|
// get an DOM mutations for that, so do the resize when the window is resized, too.
|
|
65
65
|
|
|
66
66
|
window.addEventListener('resize', sendResize, true);
|
|
67
|
-
};
|
|
67
|
+
}; // TODO: These styles shouldn't be coupled with WordPress.
|
|
68
|
+
|
|
68
69
|
|
|
69
70
|
const style = `
|
|
70
71
|
body {
|
|
@@ -88,8 +89,19 @@ const style = `
|
|
|
88
89
|
margin-bottom: 0 !important;
|
|
89
90
|
}
|
|
90
91
|
`;
|
|
92
|
+
/**
|
|
93
|
+
* This component provides an isolated environment for arbitrary HTML via iframes.
|
|
94
|
+
*
|
|
95
|
+
* ```jsx
|
|
96
|
+
* import { SandBox } from '@wordpress/components';
|
|
97
|
+
*
|
|
98
|
+
* const MySandBox = () => (
|
|
99
|
+
* <SandBox html="<p>Content</p>" title="SandBox" type="embed" />
|
|
100
|
+
* );
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
91
103
|
|
|
92
|
-
function
|
|
104
|
+
function SandBox(_ref) {
|
|
93
105
|
let {
|
|
94
106
|
html = '',
|
|
95
107
|
title = '',
|
|
@@ -104,13 +116,15 @@ function Sandbox(_ref) {
|
|
|
104
116
|
|
|
105
117
|
function isFrameAccessible() {
|
|
106
118
|
try {
|
|
107
|
-
|
|
119
|
+
var _ref$current, _ref$current$contentD;
|
|
120
|
+
|
|
121
|
+
return !!((_ref$current = ref.current) !== null && _ref$current !== void 0 && (_ref$current$contentD = _ref$current.contentDocument) !== null && _ref$current$contentD !== void 0 && _ref$current$contentD.body);
|
|
108
122
|
} catch (e) {
|
|
109
123
|
return false;
|
|
110
124
|
}
|
|
111
125
|
}
|
|
112
126
|
|
|
113
|
-
function
|
|
127
|
+
function trySandBox() {
|
|
114
128
|
let forceRerender = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
115
129
|
|
|
116
130
|
if (!isFrameAccessible()) {
|
|
@@ -121,11 +135,8 @@ function Sandbox(_ref) {
|
|
|
121
135
|
contentDocument,
|
|
122
136
|
ownerDocument
|
|
123
137
|
} = ref.current;
|
|
124
|
-
const {
|
|
125
|
-
body
|
|
126
|
-
} = contentDocument;
|
|
127
138
|
|
|
128
|
-
if (!forceRerender && null !== body.getAttribute('data-resizable-iframe-connected')) {
|
|
139
|
+
if (!forceRerender && null !== (contentDocument === null || contentDocument === void 0 ? void 0 : contentDocument.body.getAttribute('data-resizable-iframe-connected'))) {
|
|
129
140
|
return;
|
|
130
141
|
} // Put the html snippet into a html document, and then write it to the iframe's document
|
|
131
142
|
// we can use this in the future to inject custom styles or scripts.
|
|
@@ -170,10 +181,12 @@ function Sandbox(_ref) {
|
|
|
170
181
|
}
|
|
171
182
|
|
|
172
183
|
(0, _element.useEffect)(() => {
|
|
173
|
-
|
|
184
|
+
var _iframe$ownerDocument;
|
|
174
185
|
|
|
175
|
-
|
|
176
|
-
|
|
186
|
+
trySandBox();
|
|
187
|
+
|
|
188
|
+
function tryNoForceSandBox() {
|
|
189
|
+
trySandBox(false);
|
|
177
190
|
}
|
|
178
191
|
|
|
179
192
|
function checkMessageForResize(event) {
|
|
@@ -203,32 +216,27 @@ function Sandbox(_ref) {
|
|
|
203
216
|
}
|
|
204
217
|
|
|
205
218
|
const iframe = ref.current;
|
|
206
|
-
const {
|
|
207
|
-
ownerDocument
|
|
208
|
-
} = iframe;
|
|
209
|
-
const {
|
|
210
|
-
defaultView
|
|
211
|
-
} = ownerDocument; // This used to be registered using <iframe onLoad={} />, but it made the iframe blank
|
|
219
|
+
const defaultView = iframe === null || iframe === void 0 ? void 0 : (_iframe$ownerDocument = iframe.ownerDocument) === null || _iframe$ownerDocument === void 0 ? void 0 : _iframe$ownerDocument.defaultView; // This used to be registered using <iframe onLoad={} />, but it made the iframe blank
|
|
212
220
|
// after reordering the containing block. See these two issues for more details:
|
|
213
221
|
// https://github.com/WordPress/gutenberg/issues/6146
|
|
214
222
|
// https://github.com/facebook/react/issues/18752
|
|
215
223
|
|
|
216
|
-
iframe.addEventListener('load',
|
|
217
|
-
defaultView.addEventListener('message', checkMessageForResize);
|
|
224
|
+
iframe === null || iframe === void 0 ? void 0 : iframe.addEventListener('load', tryNoForceSandBox, false);
|
|
225
|
+
defaultView === null || defaultView === void 0 ? void 0 : defaultView.addEventListener('message', checkMessageForResize);
|
|
218
226
|
return () => {
|
|
219
|
-
iframe === null || iframe === void 0 ? void 0 : iframe.removeEventListener('load',
|
|
220
|
-
defaultView.addEventListener('message', checkMessageForResize);
|
|
227
|
+
iframe === null || iframe === void 0 ? void 0 : iframe.removeEventListener('load', tryNoForceSandBox, false);
|
|
228
|
+
defaultView === null || defaultView === void 0 ? void 0 : defaultView.addEventListener('message', checkMessageForResize);
|
|
221
229
|
}; // Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.
|
|
222
230
|
// See https://github.com/WordPress/gutenberg/pull/44378
|
|
223
231
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
224
232
|
}, []);
|
|
225
233
|
(0, _element.useEffect)(() => {
|
|
226
|
-
|
|
234
|
+
trySandBox(); // Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.
|
|
227
235
|
// See https://github.com/WordPress/gutenberg/pull/44378
|
|
228
236
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
229
237
|
}, [title, styles, scripts]);
|
|
230
238
|
(0, _element.useEffect)(() => {
|
|
231
|
-
|
|
239
|
+
trySandBox(true); // Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.
|
|
232
240
|
// See https://github.com/WordPress/gutenberg/pull/44378
|
|
233
241
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
234
242
|
}, [html, type]);
|
|
@@ -242,4 +250,7 @@ function Sandbox(_ref) {
|
|
|
242
250
|
height: Math.ceil(height)
|
|
243
251
|
});
|
|
244
252
|
}
|
|
253
|
+
|
|
254
|
+
var _default = SandBox;
|
|
255
|
+
exports.default = _default;
|
|
245
256
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/sandbox/index.js"],"names":["observeAndResizeJS","MutationObserver","window","document","body","parent","sendResize","clientBoundingRect","getBoundingClientRect","postMessage","action","width","height","observer","observe","attributes","attributeOldValue","characterData","characterDataOldValue","childList","subtree","addEventListener","removeViewportStyles","ruleOrNode","style","forEach","test","Array","prototype","call","querySelectorAll","styleSheets","stylesheet","cssRules","rules","position","setAttribute","Sandbox","html","title","type","styles","scripts","onFocus","ref","setWidth","setHeight","isFrameAccessible","current","contentDocument","e","trySandbox","forceRerender","ownerDocument","getAttribute","htmlDoc","documentElement","lang","__html","map","i","toString","src","open","write","close","tryNoForceSandbox","checkMessageForResize","event","iframe","contentWindow","source","data","JSON","parse","defaultView","removeEventListener","Math","ceil"],"mappings":";;;;;;;AAGA;;AAMA;;AATA;AACA;AACA;AASA,MAAMA,kBAAkB,GAAG,YAAY;AACtC,QAAM;AAAEC,IAAAA;AAAF,MAAuBC,MAA7B;;AAEA,MAAK,CAAED,gBAAF,IAAsB,CAAEE,QAAQ,CAACC,IAAjC,IAAyC,CAAEF,MAAM,CAACG,MAAvD,EAAgE;AAC/D;AACA;;AAED,WAASC,UAAT,GAAsB;AACrB,UAAMC,kBAAkB,GAAGJ,QAAQ,CAACC,IAAT,CAAcI,qBAAd,EAA3B;AAEAN,IAAAA,MAAM,CAACG,MAAP,CAAcI,WAAd,CACC;AACCC,MAAAA,MAAM,EAAE,QADT;AAECC,MAAAA,KAAK,EAAEJ,kBAAkB,CAACI,KAF3B;AAGCC,MAAAA,MAAM,EAAEL,kBAAkB,CAACK;AAH5B,KADD,EAMC,GAND;AAQA;;AAED,QAAMC,QAAQ,GAAG,IAAIZ,gBAAJ,CAAsBK,UAAtB,CAAjB;AACAO,EAAAA,QAAQ,CAACC,OAAT,CAAkBX,QAAQ,CAACC,IAA3B,EAAiC;AAChCW,IAAAA,UAAU,EAAE,IADoB;AAEhCC,IAAAA,iBAAiB,EAAE,KAFa;AAGhCC,IAAAA,aAAa,EAAE,IAHiB;AAIhCC,IAAAA,qBAAqB,EAAE,KAJS;AAKhCC,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AAEb,IAAF,EAAQE,IAAR,CALH;AAOA,SACC;AACC,IAAA,GAAG,EAAG,2BAAc,CAAEI,GAAF,EAAO,kCAAP,CAAd,CADP;AAEC,IAAA,KAAK,EAAGL,KAFT;AAGC,IAAA,SAAS,EAAC,oBAHX;AAIC,IAAA,OAAO,EAAC,oDAJT;AAKC,IAAA,OAAO,EAAGI,OALX;AAMC,IAAA,KAAK,EAAGkC,IAAI,CAACC,IAAL,CAAWnE,KAAX,CANT;AAOC,IAAA,MAAM,EAAGkE,IAAI,CAACC,IAAL,CAAWlE,MAAX;AAPV,IADD;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\trenderToString,\n\tuseRef,\n\tuseState,\n\tuseEffect,\n} from '@wordpress/element';\nimport { useFocusableIframe, useMergeRefs } from '@wordpress/compose';\n\nconst observeAndResizeJS = function () {\n\tconst { MutationObserver } = window;\n\n\tif ( ! MutationObserver || ! document.body || ! window.parent ) {\n\t\treturn;\n\t}\n\n\tfunction sendResize() {\n\t\tconst clientBoundingRect = document.body.getBoundingClientRect();\n\n\t\twindow.parent.postMessage(\n\t\t\t{\n\t\t\t\taction: 'resize',\n\t\t\t\twidth: clientBoundingRect.width,\n\t\t\t\theight: clientBoundingRect.height,\n\t\t\t},\n\t\t\t'*'\n\t\t);\n\t}\n\n\tconst observer = new MutationObserver( sendResize );\n\tobserver.observe( document.body, {\n\t\tattributes: true,\n\t\tattributeOldValue: false,\n\t\tcharacterData: true,\n\t\tcharacterDataOldValue: false,\n\t\tchildList: true,\n\t\tsubtree: true,\n\t} );\n\n\twindow.addEventListener( 'load', sendResize, true );\n\n\t// Hack: Remove viewport unit styles, as these are relative\n\t// the iframe root and interfere with our mechanism for\n\t// determining the unconstrained page bounds.\n\tfunction removeViewportStyles( ruleOrNode ) {\n\t\tif ( ruleOrNode.style ) {\n\t\t\t[ 'width', 'height', 'minHeight', 'maxHeight' ].forEach( function (\n\t\t\t\tstyle\n\t\t\t) {\n\t\t\t\tif (\n\t\t\t\t\t/^\\\\d+(vmin|vmax|vh|vw)$/.test( ruleOrNode.style[ style ] )\n\t\t\t\t) {\n\t\t\t\t\truleOrNode.style[ style ] = '';\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t}\n\n\tArray.prototype.forEach.call(\n\t\tdocument.querySelectorAll( '[style]' ),\n\t\tremoveViewportStyles\n\t);\n\tArray.prototype.forEach.call(\n\t\tdocument.styleSheets,\n\t\tfunction ( stylesheet ) {\n\t\t\tArray.prototype.forEach.call(\n\t\t\t\tstylesheet.cssRules || stylesheet.rules,\n\t\t\t\tremoveViewportStyles\n\t\t\t);\n\t\t}\n\t);\n\n\tdocument.body.style.position = 'absolute';\n\tdocument.body.style.width = '100%';\n\tdocument.body.setAttribute( 'data-resizable-iframe-connected', '' );\n\n\tsendResize();\n\n\t// Resize events can change the width of elements with 100% width, but we don't\n\t// get an DOM mutations for that, so do the resize when the window is resized, too.\n\twindow.addEventListener( 'resize', sendResize, true );\n};\n\nconst style = `\n\tbody {\n\t\tmargin: 0;\n\t}\n\thtml,\n\tbody,\n\tbody > div {\n\t\twidth: 100%;\n\t}\n\thtml.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio > div,\n\tbody.wp-has-aspect-ratio > div iframe {\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\toverflow: hidden; /* If it has an aspect ratio, it shouldn't scroll. */\n\t}\n\tbody > div > * {\n\t\tmargin-top: 0 !important; /* Has to have !important to override inline styles. */\n\t\tmargin-bottom: 0 !important;\n\t}\n`;\n\nexport default function Sandbox( {\n\thtml = '',\n\ttitle = '',\n\ttype,\n\tstyles = [],\n\tscripts = [],\n\tonFocus,\n} ) {\n\tconst ref = useRef();\n\tconst [ width, setWidth ] = useState( 0 );\n\tconst [ height, setHeight ] = useState( 0 );\n\n\tfunction isFrameAccessible() {\n\t\ttry {\n\t\t\treturn !! ref.current.contentDocument.body;\n\t\t} catch ( e ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tfunction trySandbox( forceRerender = false ) {\n\t\tif ( ! isFrameAccessible() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { contentDocument, ownerDocument } = ref.current;\n\t\tconst { body } = contentDocument;\n\n\t\tif (\n\t\t\t! forceRerender &&\n\t\t\tnull !== body.getAttribute( 'data-resizable-iframe-connected' )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Put the html snippet into a html document, and then write it to the iframe's document\n\t\t// we can use this in the future to inject custom styles or scripts.\n\t\t// Scripts go into the body rather than the head, to support embedded content such as Instagram\n\t\t// that expect the scripts to be part of the body.\n\t\tconst htmlDoc = (\n\t\t\t<html\n\t\t\t\tlang={ ownerDocument.documentElement.lang }\n\t\t\t\tclassName={ type }\n\t\t\t>\n\t\t\t\t<head>\n\t\t\t\t\t<title>{ title }</title>\n\t\t\t\t\t<style dangerouslySetInnerHTML={ { __html: style } } />\n\t\t\t\t\t{ styles.map( ( rules, i ) => (\n\t\t\t\t\t\t<style\n\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\tdangerouslySetInnerHTML={ { __html: rules } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</head>\n\t\t\t\t<body\n\t\t\t\t\tdata-resizable-iframe-connected=\"data-resizable-iframe-connected\"\n\t\t\t\t\tclassName={ type }\n\t\t\t\t>\n\t\t\t\t\t<div dangerouslySetInnerHTML={ { __html: html } } />\n\t\t\t\t\t<script\n\t\t\t\t\t\ttype=\"text/javascript\"\n\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t__html: `(${ observeAndResizeJS.toString() })();`,\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ scripts.map( ( src ) => (\n\t\t\t\t\t\t<script key={ src } src={ src } />\n\t\t\t\t\t) ) }\n\t\t\t\t</body>\n\t\t\t</html>\n\t\t);\n\n\t\t// Writing the document like this makes it act in the same way as if it was\n\t\t// loaded over the network, so DOM creation and mutation, script execution, etc.\n\t\t// all work as expected.\n\t\tcontentDocument.open();\n\t\tcontentDocument.write( '<!DOCTYPE html>' + renderToString( htmlDoc ) );\n\t\tcontentDocument.close();\n\t}\n\n\tuseEffect( () => {\n\t\ttrySandbox();\n\n\t\tfunction tryNoForceSandbox() {\n\t\t\ttrySandbox( false );\n\t\t}\n\n\t\tfunction checkMessageForResize( event ) {\n\t\t\tconst iframe = ref.current;\n\n\t\t\t// Verify that the mounted element is the source of the message.\n\t\t\tif ( ! iframe || iframe.contentWindow !== event.source ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Attempt to parse the message data as JSON if passed as string.\n\t\t\tlet data = event.data || {};\n\n\t\t\tif ( 'string' === typeof data ) {\n\t\t\t\ttry {\n\t\t\t\t\tdata = JSON.parse( data );\n\t\t\t\t} catch ( e ) {}\n\t\t\t}\n\n\t\t\t// Update the state only if the message is formatted as we expect,\n\t\t\t// i.e. as an object with a 'resize' action.\n\t\t\tif ( 'resize' !== data.action ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetWidth( data.width );\n\t\t\tsetHeight( data.height );\n\t\t}\n\n\t\tconst iframe = ref.current;\n\t\tconst { ownerDocument } = iframe;\n\t\tconst { defaultView } = ownerDocument;\n\n\t\t// This used to be registered using <iframe onLoad={} />, but it made the iframe blank\n\t\t// after reordering the containing block. See these two issues for more details:\n\t\t// https://github.com/WordPress/gutenberg/issues/6146\n\t\t// https://github.com/facebook/react/issues/18752\n\t\tiframe.addEventListener( 'load', tryNoForceSandbox, false );\n\t\tdefaultView.addEventListener( 'message', checkMessageForResize );\n\n\t\treturn () => {\n\t\t\tiframe?.removeEventListener( 'load', tryNoForceSandbox, false );\n\t\t\tdefaultView.addEventListener( 'message', checkMessageForResize );\n\t\t};\n\t\t// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [] );\n\n\tuseEffect( () => {\n\t\ttrySandbox();\n\t\t// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ title, styles, scripts ] );\n\n\tuseEffect( () => {\n\t\ttrySandbox( true );\n\t\t// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ html, type ] );\n\n\treturn (\n\t\t<iframe\n\t\t\tref={ useMergeRefs( [ ref, useFocusableIframe() ] ) }\n\t\t\ttitle={ title }\n\t\t\tclassName=\"components-sandbox\"\n\t\t\tsandbox=\"allow-scripts allow-same-origin allow-presentation\"\n\t\t\tonFocus={ onFocus }\n\t\t\twidth={ Math.ceil( width ) }\n\t\t\theight={ Math.ceil( height ) }\n\t\t/>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/sandbox/index.tsx"],"names":["observeAndResizeJS","MutationObserver","window","document","body","parent","sendResize","clientBoundingRect","getBoundingClientRect","postMessage","action","width","height","observer","observe","attributes","attributeOldValue","characterData","characterDataOldValue","childList","subtree","addEventListener","removeViewportStyles","ruleOrNode","style","forEach","test","Array","prototype","call","querySelectorAll","styleSheets","stylesheet","cssRules","rules","position","setAttribute","SandBox","html","title","type","styles","scripts","onFocus","ref","setWidth","setHeight","isFrameAccessible","current","contentDocument","e","trySandBox","forceRerender","ownerDocument","getAttribute","htmlDoc","documentElement","lang","__html","map","i","toString","src","open","write","close","tryNoForceSandBox","checkMessageForResize","event","iframe","contentWindow","source","data","JSON","parse","defaultView","removeEventListener","Math","ceil"],"mappings":";;;;;;;AAGA;;AAMA;;AATA;AACA;AACA;AAcA,MAAMA,kBAAkB,GAAG,YAAY;AACtC,QAAM;AAAEC,IAAAA;AAAF,MAAuBC,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IAAI,CAACC,IAAL,CAAWlE,MAAX;AAPV,IADD;AAWA;;eAEcyB,O","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\trenderToString,\n\tuseRef,\n\tuseState,\n\tuseEffect,\n} from '@wordpress/element';\nimport { useFocusableIframe, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { SandBoxProps } from './types';\n\nconst observeAndResizeJS = function () {\n\tconst { MutationObserver } = window;\n\n\tif ( ! MutationObserver || ! document.body || ! window.parent ) {\n\t\treturn;\n\t}\n\n\tfunction sendResize() {\n\t\tconst clientBoundingRect = document.body.getBoundingClientRect();\n\n\t\twindow.parent.postMessage(\n\t\t\t{\n\t\t\t\taction: 'resize',\n\t\t\t\twidth: clientBoundingRect.width,\n\t\t\t\theight: clientBoundingRect.height,\n\t\t\t},\n\t\t\t'*'\n\t\t);\n\t}\n\n\tconst observer = new MutationObserver( sendResize );\n\tobserver.observe( document.body, {\n\t\tattributes: true,\n\t\tattributeOldValue: false,\n\t\tcharacterData: true,\n\t\tcharacterDataOldValue: false,\n\t\tchildList: true,\n\t\tsubtree: true,\n\t} );\n\n\twindow.addEventListener( 'load', sendResize, true );\n\n\t// Hack: Remove viewport unit styles, as these are relative\n\t// the iframe root and interfere with our mechanism for\n\t// determining the unconstrained page bounds.\n\tfunction removeViewportStyles( ruleOrNode: ElementCSSInlineStyle ) {\n\t\tif ( ruleOrNode.style ) {\n\t\t\t(\n\t\t\t\t[ 'width', 'height', 'minHeight', 'maxHeight' ] as const\n\t\t\t ).forEach( function ( style ) {\n\t\t\t\tif (\n\t\t\t\t\t/^\\\\d+(vmin|vmax|vh|vw)$/.test( ruleOrNode.style[ style ] )\n\t\t\t\t) {\n\t\t\t\t\truleOrNode.style[ style ] = '';\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t}\n\n\tArray.prototype.forEach.call(\n\t\tdocument.querySelectorAll( '[style]' ),\n\t\tremoveViewportStyles\n\t);\n\tArray.prototype.forEach.call(\n\t\tdocument.styleSheets,\n\t\tfunction ( stylesheet ) {\n\t\t\tArray.prototype.forEach.call(\n\t\t\t\tstylesheet.cssRules || stylesheet.rules,\n\t\t\t\tremoveViewportStyles\n\t\t\t);\n\t\t}\n\t);\n\n\tdocument.body.style.position = 'absolute';\n\tdocument.body.style.width = '100%';\n\tdocument.body.setAttribute( 'data-resizable-iframe-connected', '' );\n\n\tsendResize();\n\n\t// Resize events can change the width of elements with 100% width, but we don't\n\t// get an DOM mutations for that, so do the resize when the window is resized, too.\n\twindow.addEventListener( 'resize', sendResize, true );\n};\n\n// TODO: These styles shouldn't be coupled with WordPress.\nconst style = `\n\tbody {\n\t\tmargin: 0;\n\t}\n\thtml,\n\tbody,\n\tbody > div {\n\t\twidth: 100%;\n\t}\n\thtml.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio > div,\n\tbody.wp-has-aspect-ratio > div iframe {\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\toverflow: hidden; /* If it has an aspect ratio, it shouldn't scroll. */\n\t}\n\tbody > div > * {\n\t\tmargin-top: 0 !important; /* Has to have !important to override inline styles. */\n\t\tmargin-bottom: 0 !important;\n\t}\n`;\n\n/**\n * This component provides an isolated environment for arbitrary HTML via iframes.\n *\n * ```jsx\n * import { SandBox } from '@wordpress/components';\n *\n * const MySandBox = () => (\n * \t<SandBox html=\"<p>Content</p>\" title=\"SandBox\" type=\"embed\" />\n * );\n * ```\n */\nfunction SandBox( {\n\thtml = '',\n\ttitle = '',\n\ttype,\n\tstyles = [],\n\tscripts = [],\n\tonFocus,\n}: SandBoxProps ) {\n\tconst ref = useRef< HTMLIFrameElement >();\n\tconst [ width, setWidth ] = useState( 0 );\n\tconst [ height, setHeight ] = useState( 0 );\n\n\tfunction isFrameAccessible() {\n\t\ttry {\n\t\t\treturn !! ref.current?.contentDocument?.body;\n\t\t} catch ( e ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tfunction trySandBox( forceRerender = false ) {\n\t\tif ( ! isFrameAccessible() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { contentDocument, ownerDocument } =\n\t\t\tref.current as HTMLIFrameElement & {\n\t\t\t\tcontentDocument: Document;\n\t\t\t};\n\n\t\tif (\n\t\t\t! forceRerender &&\n\t\t\tnull !==\n\t\t\t\tcontentDocument?.body.getAttribute(\n\t\t\t\t\t'data-resizable-iframe-connected'\n\t\t\t\t)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Put the html snippet into a html document, and then write it to the iframe's document\n\t\t// we can use this in the future to inject custom styles or scripts.\n\t\t// Scripts go into the body rather than the head, to support embedded content such as Instagram\n\t\t// that expect the scripts to be part of the body.\n\t\tconst htmlDoc = (\n\t\t\t<html\n\t\t\t\tlang={ ownerDocument.documentElement.lang }\n\t\t\t\tclassName={ type }\n\t\t\t>\n\t\t\t\t<head>\n\t\t\t\t\t<title>{ title }</title>\n\t\t\t\t\t<style dangerouslySetInnerHTML={ { __html: style } } />\n\t\t\t\t\t{ styles.map( ( rules, i ) => (\n\t\t\t\t\t\t<style\n\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\tdangerouslySetInnerHTML={ { __html: rules } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</head>\n\t\t\t\t<body\n\t\t\t\t\tdata-resizable-iframe-connected=\"data-resizable-iframe-connected\"\n\t\t\t\t\tclassName={ type }\n\t\t\t\t>\n\t\t\t\t\t<div dangerouslySetInnerHTML={ { __html: html } } />\n\t\t\t\t\t<script\n\t\t\t\t\t\ttype=\"text/javascript\"\n\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t__html: `(${ observeAndResizeJS.toString() })();`,\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ scripts.map( ( src ) => (\n\t\t\t\t\t\t<script key={ src } src={ src } />\n\t\t\t\t\t) ) }\n\t\t\t\t</body>\n\t\t\t</html>\n\t\t);\n\n\t\t// Writing the document like this makes it act in the same way as if it was\n\t\t// loaded over the network, so DOM creation and mutation, script execution, etc.\n\t\t// all work as expected.\n\t\tcontentDocument.open();\n\t\tcontentDocument.write( '<!DOCTYPE html>' + renderToString( htmlDoc ) );\n\t\tcontentDocument.close();\n\t}\n\n\tuseEffect( () => {\n\t\ttrySandBox();\n\n\t\tfunction tryNoForceSandBox() {\n\t\t\ttrySandBox( false );\n\t\t}\n\n\t\tfunction checkMessageForResize( event: MessageEvent ) {\n\t\t\tconst iframe = ref.current;\n\n\t\t\t// Verify that the mounted element is the source of the message.\n\t\t\tif ( ! iframe || iframe.contentWindow !== event.source ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Attempt to parse the message data as JSON if passed as string.\n\t\t\tlet data = event.data || {};\n\n\t\t\tif ( 'string' === typeof data ) {\n\t\t\t\ttry {\n\t\t\t\t\tdata = JSON.parse( data );\n\t\t\t\t} catch ( e ) {}\n\t\t\t}\n\n\t\t\t// Update the state only if the message is formatted as we expect,\n\t\t\t// i.e. as an object with a 'resize' action.\n\t\t\tif ( 'resize' !== data.action ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetWidth( data.width );\n\t\t\tsetHeight( data.height );\n\t\t}\n\n\t\tconst iframe = ref.current;\n\t\tconst defaultView = iframe?.ownerDocument?.defaultView;\n\n\t\t// This used to be registered using <iframe onLoad={} />, but it made the iframe blank\n\t\t// after reordering the containing block. See these two issues for more details:\n\t\t// https://github.com/WordPress/gutenberg/issues/6146\n\t\t// https://github.com/facebook/react/issues/18752\n\t\tiframe?.addEventListener( 'load', tryNoForceSandBox, false );\n\t\tdefaultView?.addEventListener( 'message', checkMessageForResize );\n\n\t\treturn () => {\n\t\t\tiframe?.removeEventListener( 'load', tryNoForceSandBox, false );\n\t\t\tdefaultView?.addEventListener( 'message', checkMessageForResize );\n\t\t};\n\t\t// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [] );\n\n\tuseEffect( () => {\n\t\ttrySandBox();\n\t\t// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ title, styles, scripts ] );\n\n\tuseEffect( () => {\n\t\ttrySandBox( true );\n\t\t// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ html, type ] );\n\n\treturn (\n\t\t<iframe\n\t\t\tref={ useMergeRefs( [ ref, useFocusableIframe() ] ) }\n\t\t\ttitle={ title }\n\t\t\tclassName=\"components-sandbox\"\n\t\t\tsandbox=\"allow-scripts allow-same-origin allow-presentation\"\n\t\t\tonFocus={ onFocus }\n\t\t\twidth={ Math.ceil( width ) }\n\t\t\theight={ Math.ceil( height ) }\n\t\t/>\n\t);\n}\n\nexport default SandBox;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
package/build/tab-panel/index.js
CHANGED
|
@@ -14,8 +14,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
14
14
|
|
|
15
15
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
16
16
|
|
|
17
|
-
var _lodash = require("lodash");
|
|
18
|
-
|
|
19
17
|
var _compose = require("@wordpress/compose");
|
|
20
18
|
|
|
21
19
|
var _navigableContainer = require("../navigable-container");
|
|
@@ -36,7 +34,6 @@ var _button = _interopRequireDefault(require("../button"));
|
|
|
36
34
|
const TabButton = _ref => {
|
|
37
35
|
let {
|
|
38
36
|
tabId,
|
|
39
|
-
onClick,
|
|
40
37
|
children,
|
|
41
38
|
selected,
|
|
42
39
|
...rest
|
|
@@ -46,7 +43,7 @@ const TabButton = _ref => {
|
|
|
46
43
|
tabIndex: selected ? null : -1,
|
|
47
44
|
"aria-selected": selected,
|
|
48
45
|
id: tabId,
|
|
49
|
-
|
|
46
|
+
__experimentalIsFocusable: true
|
|
50
47
|
}, rest), children);
|
|
51
48
|
};
|
|
52
49
|
/**
|
|
@@ -112,15 +109,23 @@ function TabPanel(_ref2) {
|
|
|
112
109
|
child.click();
|
|
113
110
|
};
|
|
114
111
|
|
|
115
|
-
const selectedTab =
|
|
116
|
-
|
|
112
|
+
const selectedTab = tabs.find(_ref3 => {
|
|
113
|
+
let {
|
|
114
|
+
name
|
|
115
|
+
} = _ref3;
|
|
116
|
+
return name === selected;
|
|
117
117
|
});
|
|
118
118
|
const selectedId = `${instanceId}-${(_selectedTab$name = selectedTab === null || selectedTab === void 0 ? void 0 : selectedTab.name) !== null && _selectedTab$name !== void 0 ? _selectedTab$name : 'none'}`;
|
|
119
119
|
(0, _element.useEffect)(() => {
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
const firstEnabledTab = tabs.find(tab => !tab.disabled);
|
|
121
|
+
const initialTab = tabs.find(tab => tab.name === initialTabName);
|
|
122
|
+
|
|
123
|
+
if (!(selectedTab !== null && selectedTab !== void 0 && selectedTab.name) && firstEnabledTab) {
|
|
124
|
+
handleTabSelection(initialTab && !initialTab.disabled ? initialTab.name : firstEnabledTab.name);
|
|
125
|
+
} else if (selectedTab !== null && selectedTab !== void 0 && selectedTab.disabled && firstEnabledTab) {
|
|
126
|
+
handleTabSelection(firstEnabledTab.name);
|
|
122
127
|
}
|
|
123
|
-
}, [tabs, selectedTab === null || selectedTab === void 0 ? void 0 : selectedTab.name, initialTabName, handleTabSelection]);
|
|
128
|
+
}, [tabs, selectedTab === null || selectedTab === void 0 ? void 0 : selectedTab.name, selectedTab === null || selectedTab === void 0 ? void 0 : selectedTab.disabled, initialTabName, handleTabSelection]);
|
|
124
129
|
return (0, _element.createElement)("div", {
|
|
125
130
|
className: className
|
|
126
131
|
}, (0, _element.createElement)(_navigableContainer.NavigableMenu, {
|
|
@@ -137,6 +142,7 @@ function TabPanel(_ref2) {
|
|
|
137
142
|
selected: tab.name === selected,
|
|
138
143
|
key: tab.name,
|
|
139
144
|
onClick: () => handleTabSelection(tab.name),
|
|
145
|
+
disabled: tab.disabled,
|
|
140
146
|
label: tab.icon && tab.title,
|
|
141
147
|
icon: tab.icon,
|
|
142
148
|
showTooltip: !!tab.icon
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/tab-panel/index.tsx"],"names":["TabButton","tabId","
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/tab-panel/index.tsx"],"names":["TabButton","tabId","children","selected","rest","TabPanel","className","tabs","selectOnMove","initialTabName","orientation","activeClass","onSelect","instanceId","setSelected","handleTabSelection","tabKey","activateTabAutomatically","_childIndex","child","click","selectedTab","find","name","selectedId","firstEnabledTab","tab","disabled","initialTab","undefined","map","icon","title"],"mappings":";;;;;;;;;;AAQA;;;;AALA;;AAMA;;AAKA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAMA,MAAMA,SAAS,GAAG;AAAA,MAAE;AACnBC,IAAAA,KADmB;AAEnBC,IAAAA,QAFmB;AAGnBC,IAAAA,QAHmB;AAInB,OAAGC;AAJgB,GAAF;AAAA,SAMjB,4BAAC,eAAD;AACC,IAAA,IAAI,EAAC,KADN;AAEC,IAAA,QAAQ,EAAGD,QAAQ,GAAG,IAAH,GAAU,CAAC,CAF/B;AAGC,qBAAgBA,QAHjB;AAIC,IAAA,EAAE,EAAGF,KAJN;AAKC,IAAA,yBAAyB;AAL1B,KAMMG,IANN,GAQGF,QARH,CANiB;AAAA,CAAlB;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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AO,EAAG,MAAMR,kBAAkB,CAAEW,GAAG,CAACH,IAAN,CAZnC;AAaC,IAAA,QAAQ,EAAGG,GAAG,CAACC,QAbhB;AAcC,IAAA,KAAK,EAAGD,GAAG,CAACK,IAAJ,IAAYL,GAAG,CAACM,KAdzB;AAeC,IAAA,IAAI,EAAGN,GAAG,CAACK,IAfZ;AAgBC,IAAA,WAAW,EAAG,CAAC,CAAEL,GAAG,CAACK;AAhBtB,KAkBG,CAAEL,GAAG,CAACK,IAAN,IAAcL,GAAG,CAACM,KAlBrB,CADC,CARH,CADD,EAgCGX,WAAW,IACZ;AACC,IAAA,GAAG,EAAGG,UADP;AAEC,uBAAkBA,UAFnB;AAGC,IAAA,IAAI,EAAC,UAHN;AAIC,IAAA,EAAE,EAAI,GAAGA,UAAY,OAJtB;AAKC,IAAA,SAAS,EAAC;AALX,KAOGtB,QAAQ,CAAEmB,WAAF,CAPX,CAjCF,CADD;AA8CA;;eAEchB,Q","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useCallback } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { NavigableMenu } from '../navigable-container';\nimport Button from '../button';\nimport type { TabButtonProps, TabPanelProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nconst TabButton = ( {\n\ttabId,\n\tchildren,\n\tselected,\n\t...rest\n}: TabButtonProps ) => (\n\t<Button\n\t\trole=\"tab\"\n\t\ttabIndex={ selected ? null : -1 }\n\t\taria-selected={ selected }\n\t\tid={ tabId }\n\t\t__experimentalIsFocusable\n\t\t{ ...rest }\n\t>\n\t\t{ children }\n\t</Button>\n);\n\n/**\n * TabPanel is an ARIA-compliant tabpanel.\n *\n * TabPanels organize content across different screens, data sets, and interactions.\n * It has two sections: a list of tabs, and the view to show when tabs are chosen.\n *\n * ```jsx\n * import { TabPanel } from '@wordpress/components';\n *\n * const onSelect = ( tabName ) => {\n * console.log( 'Selecting tab', tabName );\n * };\n *\n * const MyTabPanel = () => (\n * <TabPanel\n * className=\"my-tab-panel\"\n * activeClass=\"active-tab\"\n * onSelect={ onSelect }\n * tabs={ [\n * {\n * name: 'tab1',\n * title: 'Tab 1',\n * className: 'tab-one',\n * },\n * {\n * name: 'tab2',\n * title: 'Tab 2',\n * className: 'tab-two',\n * },\n * ] }\n * >\n * { ( tab ) => <p>{ tab.title }</p> }\n * </TabPanel>\n * );\n * ```\n */\nexport function TabPanel( {\n\tclassName,\n\tchildren,\n\ttabs,\n\tselectOnMove = true,\n\tinitialTabName,\n\torientation = 'horizontal',\n\tactiveClass = 'is-active',\n\tonSelect,\n}: WordPressComponentProps< TabPanelProps, 'div', false > ) {\n\tconst instanceId = useInstanceId( TabPanel, 'tab-panel' );\n\tconst [ selected, setSelected ] = useState< string >();\n\n\tconst handleTabSelection = useCallback(\n\t\t( tabKey: string ) => {\n\t\t\tsetSelected( tabKey );\n\t\t\tonSelect?.( tabKey );\n\t\t},\n\t\t[ onSelect ]\n\t);\n\n\t// Simulate a click on the newly focused tab, which causes the component\n\t// to show the `tab-panel` associated with the clicked tab.\n\tconst activateTabAutomatically = (\n\t\t_childIndex: number,\n\t\tchild: HTMLButtonElement\n\t) => {\n\t\tchild.click();\n\t};\n\tconst selectedTab = tabs.find( ( { name } ) => name === selected );\n\tconst selectedId = `${ instanceId }-${ selectedTab?.name ?? 'none' }`;\n\n\tuseEffect( () => {\n\t\tconst firstEnabledTab = tabs.find( ( tab ) => ! tab.disabled );\n\t\tconst initialTab = tabs.find( ( tab ) => tab.name === initialTabName );\n\t\tif ( ! selectedTab?.name && firstEnabledTab ) {\n\t\t\thandleTabSelection(\n\t\t\t\tinitialTab && ! initialTab.disabled\n\t\t\t\t\t? initialTab.name\n\t\t\t\t\t: firstEnabledTab.name\n\t\t\t);\n\t\t} else if ( selectedTab?.disabled && firstEnabledTab ) {\n\t\t\thandleTabSelection( firstEnabledTab.name );\n\t\t}\n\t}, [\n\t\ttabs,\n\t\tselectedTab?.name,\n\t\tselectedTab?.disabled,\n\t\tinitialTabName,\n\t\thandleTabSelection,\n\t] );\n\n\treturn (\n\t\t<div className={ className }>\n\t\t\t<NavigableMenu\n\t\t\t\trole=\"tablist\"\n\t\t\t\torientation={ orientation }\n\t\t\t\tonNavigate={\n\t\t\t\t\tselectOnMove ? activateTabAutomatically : undefined\n\t\t\t\t}\n\t\t\t\tclassName=\"components-tab-panel__tabs\"\n\t\t\t>\n\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t<TabButton\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'components-tab-panel__tabs-item',\n\t\t\t\t\t\t\ttab.className,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t[ activeClass ]: tab.name === selected,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\ttabId={ `${ instanceId }-${ tab.name }` }\n\t\t\t\t\t\taria-controls={ `${ instanceId }-${ tab.name }-view` }\n\t\t\t\t\t\tselected={ tab.name === selected }\n\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t\tonClick={ () => handleTabSelection( tab.name ) }\n\t\t\t\t\t\tdisabled={ tab.disabled }\n\t\t\t\t\t\tlabel={ tab.icon && tab.title }\n\t\t\t\t\t\ticon={ tab.icon }\n\t\t\t\t\t\tshowTooltip={ !! tab.icon }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! tab.icon && tab.title }\n\t\t\t\t\t</TabButton>\n\t\t\t\t) ) }\n\t\t\t</NavigableMenu>\n\t\t\t{ selectedTab && (\n\t\t\t\t<div\n\t\t\t\t\tkey={ selectedId }\n\t\t\t\t\taria-labelledby={ selectedId }\n\t\t\t\t\trole=\"tabpanel\"\n\t\t\t\t\tid={ `${ selectedId }-view` }\n\t\t\t\t\tclassName=\"components-tab-panel__tab-content\"\n\t\t\t\t>\n\t\t\t\t\t{ children( selectedTab ) }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default TabPanel;\n"]}
|
package/build/toolbar/index.js
CHANGED
|
@@ -5,70 +5,52 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
8
|
+
Object.defineProperty(exports, "Toolbar", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return _toolbar.default;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "ToolbarButton", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () {
|
|
17
|
+
return _toolbarButton.default;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "ToolbarContext", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () {
|
|
23
|
+
return _toolbarContext.default;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "ToolbarDropdownMenu", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () {
|
|
29
|
+
return _toolbarDropdownMenu.default;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, "ToolbarGroup", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _toolbarGroup.default;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports, "ToolbarItem", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return _toolbarItem.default;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
33
44
|
|
|
34
|
-
|
|
35
|
-
* Renders a toolbar.
|
|
36
|
-
*
|
|
37
|
-
* To add controls, simply pass `ToolbarButton` components as children.
|
|
38
|
-
*
|
|
39
|
-
* @param {Object} props Component props.
|
|
40
|
-
* @param {string} [props.className] Class to set on the container div.
|
|
41
|
-
* @param {string} [props.label] ARIA label for toolbar container.
|
|
42
|
-
* @param {Object} ref React Element ref.
|
|
43
|
-
*/
|
|
44
|
-
function Toolbar(_ref, ref) {
|
|
45
|
-
let {
|
|
46
|
-
className,
|
|
47
|
-
label,
|
|
48
|
-
...props
|
|
49
|
-
} = _ref;
|
|
45
|
+
var _toolbar = _interopRequireDefault(require("./toolbar"));
|
|
50
46
|
|
|
51
|
-
|
|
52
|
-
(0, _deprecated.default)('Using Toolbar without label prop', {
|
|
53
|
-
since: '5.6',
|
|
54
|
-
alternative: 'ToolbarGroup component',
|
|
55
|
-
link: 'https://developer.wordpress.org/block-editor/components/toolbar/'
|
|
56
|
-
});
|
|
57
|
-
return (0, _element.createElement)(_toolbarGroup.default, (0, _extends2.default)({}, props, {
|
|
58
|
-
className: className
|
|
59
|
-
}));
|
|
60
|
-
} // `ToolbarGroup` already uses components-toolbar for compatibility reasons.
|
|
47
|
+
var _toolbarButton = _interopRequireDefault(require("./toolbar-button"));
|
|
61
48
|
|
|
49
|
+
var _toolbarContext = _interopRequireDefault(require("./toolbar-context"));
|
|
62
50
|
|
|
63
|
-
|
|
64
|
-
return (0, _element.createElement)(_toolbarContainer.default, (0, _extends2.default)({
|
|
65
|
-
className: finalClassName,
|
|
66
|
-
label: label,
|
|
67
|
-
ref: ref
|
|
68
|
-
}, props));
|
|
69
|
-
}
|
|
51
|
+
var _toolbarDropdownMenu = _interopRequireDefault(require("./toolbar-dropdown-menu"));
|
|
70
52
|
|
|
71
|
-
var
|
|
53
|
+
var _toolbarGroup = _interopRequireDefault(require("./toolbar-group"));
|
|
72
54
|
|
|
73
|
-
|
|
55
|
+
var _toolbarItem = _interopRequireDefault(require("./toolbar-item"));
|
|
74
56
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/toolbar/index.js"],"names":[
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/toolbar/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["export { default as Toolbar } from './toolbar';\nexport { default as ToolbarButton } from './toolbar-button';\nexport { default as ToolbarContext } from './toolbar-context';\nexport { default as ToolbarDropdownMenu } from './toolbar-dropdown-menu';\nexport { default as ToolbarGroup } from './toolbar-group';\nexport { default as ToolbarItem } from './toolbar-item';\n"]}
|