@wordpress/components 19.16.0 → 19.17.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 +40 -4
- package/build/base-control/index.js +6 -3
- package/build/base-control/index.js.map +1 -1
- package/build/base-control/styles/base-control-styles.js +8 -8
- package/build/base-control/styles/base-control-styles.js.map +1 -1
- package/build/border-control/styles.js +17 -25
- package/build/border-control/styles.js.map +1 -1
- package/build/box-control/all-input-control.js +2 -27
- package/build/box-control/all-input-control.js.map +1 -1
- package/build/box-control/index.js +10 -5
- package/build/box-control/index.js.map +1 -1
- package/build/box-control/styles/box-control-styles.js +17 -9
- package/build/box-control/styles/box-control-styles.js.map +1 -1
- package/build/box-control/utils.js +35 -0
- package/build/box-control/utils.js.map +1 -1
- package/build/color-picker/styles.js +10 -8
- package/build/color-picker/styles.js.map +1 -1
- package/build/combobox-control/index.js +14 -6
- package/build/combobox-control/index.js.map +1 -1
- package/build/custom-select-control/index.js +3 -1
- package/build/custom-select-control/index.js.map +1 -1
- package/build/date-time/time/index.js +6 -2
- package/build/date-time/time/index.js.map +1 -1
- package/build/date-time/time/styles.js +17 -24
- package/build/date-time/time/styles.js.map +1 -1
- package/build/external-link/index.js +6 -0
- package/build/external-link/index.js.map +1 -1
- package/build/flex/flex/component.js +9 -9
- package/build/flex/flex/component.js.map +1 -1
- package/build/flex/flex/hook.js +6 -16
- package/build/flex/flex/hook.js.map +1 -1
- package/build/flex/flex/index.js.map +1 -1
- package/build/flex/flex-block/component.js +9 -9
- package/build/flex/flex-block/component.js.map +1 -1
- package/build/flex/flex-block/hook.js +0 -4
- package/build/flex/flex-block/hook.js.map +1 -1
- package/build/flex/flex-block/index.js.map +1 -1
- package/build/flex/flex-item/component.js +9 -9
- package/build/flex/flex-item/component.js.map +1 -1
- package/build/flex/flex-item/hook.js +1 -5
- package/build/flex/flex-item/hook.js.map +1 -1
- package/build/flex/flex-item/index.js.map +1 -1
- package/build/flex/index.js.map +1 -1
- package/build/flex/styles.js +5 -5
- package/build/flex/styles.js.map +1 -1
- package/build/focal-point-picker/styles/focal-point-picker-style.js +22 -22
- package/build/focal-point-picker/styles/focal-point-picker-style.js.map +1 -1
- package/build/focal-point-picker/styles/focal-point-style.js +5 -5
- package/build/focal-point-picker/styles/focal-point-style.js.map +1 -1
- package/build/font-size-picker/index.js +15 -6
- package/build/font-size-picker/index.js.map +1 -1
- package/build/form-token-field/index.js +6 -2
- package/build/form-token-field/index.js.map +1 -1
- package/build/form-token-field/suggestions-list.js +19 -6
- package/build/form-token-field/suggestions-list.js.map +1 -1
- package/build/index.js +7 -1
- package/build/index.js.map +1 -1
- package/build/input-control/input-base.js +1 -2
- package/build/input-control/input-base.js.map +1 -1
- package/build/input-control/reducer/actions.js +3 -1
- package/build/input-control/reducer/actions.js.map +1 -1
- package/build/input-control/reducer/reducer.js +28 -11
- package/build/input-control/reducer/reducer.js.map +1 -1
- package/build/input-control/reducer/state.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +26 -26
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/mobile/global-styles-context/utils.native.js +23 -3
- package/build/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build/mobile/image/index.native.js +23 -2
- package/build/mobile/image/index.native.js.map +1 -1
- package/build/mobile/link-picker/link-picker-screen.native.js +10 -4
- package/build/mobile/link-picker/link-picker-screen.native.js.map +1 -1
- package/build/mobile/picker/index.ios.js +16 -3
- package/build/mobile/picker/index.ios.js.map +1 -1
- package/build/placeholder/index.js +11 -14
- package/build/placeholder/index.js.map +1 -1
- package/build/placeholder/types.js +6 -0
- package/build/placeholder/types.js.map +1 -0
- package/build/popover/index.js +113 -62
- package/build/popover/index.js.map +1 -1
- package/build/range-control/styles/range-control-styles.js +40 -40
- package/build/range-control/styles/range-control-styles.js.map +1 -1
- package/build/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +4 -4
- package/build/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js.map +1 -1
- package/build/select-control/styles/select-control-styles.js +6 -6
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- package/build/style-provider/index.js +10 -7
- package/build/style-provider/index.js.map +1 -1
- package/build/style-provider/types.js +6 -0
- package/build/style-provider/types.js.map +1 -0
- package/build/swatch/index.js +2 -0
- package/build/swatch/index.js.map +1 -1
- package/build/swatch/types.js +6 -0
- package/build/swatch/types.js.map +1 -0
- package/build/text/hook.js +5 -8
- package/build/text/hook.js.map +1 -1
- package/build/tools-panel/styles.js +13 -10
- package/build/tools-panel/styles.js.map +1 -1
- package/build/tools-panel/tools-panel/hook.js +1 -1
- package/build/tools-panel/tools-panel/hook.js.map +1 -1
- package/build/ui/tooltip/styles.js +4 -4
- package/build/ui/tooltip/styles.js.map +1 -1
- package/build/unit-control/styles/unit-control-styles.js +34 -9
- package/build/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build/utils/base-label.js +24 -0
- package/build/utils/base-label.js.map +1 -0
- package/build/utils/box-sizing.js +22 -0
- package/build/utils/box-sizing.js.map +1 -0
- package/build/utils/style-mixins.js +16 -0
- package/build/utils/style-mixins.js.map +1 -1
- package/build-module/base-control/index.js +7 -5
- package/build-module/base-control/index.js.map +1 -1
- package/build-module/base-control/styles/base-control-styles.js +9 -9
- package/build-module/base-control/styles/base-control-styles.js.map +1 -1
- package/build-module/border-control/styles.js +18 -26
- package/build-module/border-control/styles.js.map +1 -1
- package/build-module/box-control/all-input-control.js +3 -28
- package/build-module/box-control/all-input-control.js.map +1 -1
- package/build-module/box-control/index.js +4 -4
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/box-control/styles/box-control-styles.js +18 -10
- package/build-module/box-control/styles/box-control-styles.js.map +1 -1
- package/build-module/box-control/utils.js +33 -0
- package/build-module/box-control/utils.js.map +1 -1
- package/build-module/color-picker/styles.js +9 -8
- package/build-module/color-picker/styles.js.map +1 -1
- package/build-module/combobox-control/index.js +13 -6
- package/build-module/combobox-control/index.js.map +1 -1
- package/build-module/custom-select-control/index.js +2 -1
- package/build-module/custom-select-control/index.js.map +1 -1
- package/build-module/date-time/time/index.js +6 -3
- package/build-module/date-time/time/index.js.map +1 -1
- package/build-module/date-time/time/styles.js +15 -21
- package/build-module/date-time/time/styles.js.map +1 -1
- package/build-module/external-link/index.js +6 -0
- package/build-module/external-link/index.js.map +1 -1
- package/build-module/flex/flex/component.js +9 -9
- package/build-module/flex/flex/component.js.map +1 -1
- package/build-module/flex/flex/hook.js +6 -15
- package/build-module/flex/flex/hook.js.map +1 -1
- package/build-module/flex/flex/index.js.map +1 -1
- package/build-module/flex/flex-block/component.js +9 -9
- package/build-module/flex/flex-block/component.js.map +1 -1
- package/build-module/flex/flex-block/hook.js +0 -4
- package/build-module/flex/flex-block/hook.js.map +1 -1
- package/build-module/flex/flex-block/index.js.map +1 -1
- package/build-module/flex/flex-item/component.js +9 -9
- package/build-module/flex/flex-item/component.js.map +1 -1
- package/build-module/flex/flex-item/hook.js +1 -5
- package/build-module/flex/flex-item/hook.js.map +1 -1
- package/build-module/flex/flex-item/index.js.map +1 -1
- package/build-module/flex/index.js.map +1 -1
- package/build-module/flex/styles.js +5 -5
- package/build-module/flex/styles.js.map +1 -1
- package/build-module/focal-point-picker/styles/focal-point-picker-style.js +22 -22
- package/build-module/focal-point-picker/styles/focal-point-picker-style.js.map +1 -1
- package/build-module/focal-point-picker/styles/focal-point-style.js +5 -5
- package/build-module/focal-point-picker/styles/focal-point-style.js.map +1 -1
- package/build-module/font-size-picker/index.js +14 -6
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/form-token-field/index.js +5 -2
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/form-token-field/suggestions-list.js +19 -6
- package/build-module/form-token-field/suggestions-list.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/input-control/input-base.js +1 -2
- package/build-module/input-control/input-base.js.map +1 -1
- package/build-module/input-control/reducer/actions.js +1 -0
- package/build-module/input-control/reducer/actions.js.map +1 -1
- package/build-module/input-control/reducer/reducer.js +28 -11
- package/build-module/input-control/reducer/reducer.js.map +1 -1
- package/build-module/input-control/reducer/state.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +27 -27
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +23 -4
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/mobile/image/index.native.js +25 -4
- package/build-module/mobile/image/index.native.js.map +1 -1
- package/build-module/mobile/link-picker/link-picker-screen.native.js +11 -4
- package/build-module/mobile/link-picker/link-picker-screen.native.js.map +1 -1
- package/build-module/mobile/picker/index.ios.js +14 -3
- package/build-module/mobile/picker/index.ios.js.map +1 -1
- package/build-module/placeholder/index.js +10 -15
- package/build-module/placeholder/index.js.map +1 -1
- package/build-module/placeholder/types.js +2 -0
- package/build-module/placeholder/types.js.map +1 -0
- package/build-module/popover/index.js +112 -62
- package/build-module/popover/index.js.map +1 -1
- package/build-module/range-control/styles/range-control-styles.js +40 -40
- package/build-module/range-control/styles/range-control-styles.js.map +1 -1
- package/build-module/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +4 -4
- package/build-module/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js.map +1 -1
- package/build-module/select-control/styles/select-control-styles.js +6 -6
- package/build-module/select-control/styles/select-control-styles.js.map +1 -1
- package/build-module/style-provider/index.js +10 -5
- package/build-module/style-provider/index.js.map +1 -1
- package/build-module/style-provider/types.js +2 -0
- package/build-module/style-provider/types.js.map +1 -0
- package/build-module/swatch/index.js +2 -0
- package/build-module/swatch/index.js.map +1 -1
- package/build-module/swatch/types.js +2 -0
- package/build-module/swatch/types.js.map +1 -0
- package/build-module/text/hook.js +5 -7
- package/build-module/text/hook.js.map +1 -1
- package/build-module/tools-panel/styles.js +12 -11
- package/build-module/tools-panel/styles.js.map +1 -1
- package/build-module/tools-panel/tools-panel/hook.js +1 -1
- package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
- package/build-module/ui/tooltip/styles.js +4 -4
- package/build-module/ui/tooltip/styles.js.map +1 -1
- package/build-module/unit-control/styles/unit-control-styles.js +35 -9
- package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build-module/utils/base-label.js +18 -0
- package/build-module/utils/base-label.js.map +1 -0
- package/build-module/utils/box-sizing.js +16 -0
- package/build-module/utils/box-sizing.js.map +1 -0
- package/build-module/utils/style-mixins.js +2 -0
- package/build-module/utils/style-mixins.js.map +1 -1
- package/build-style/style-rtl.css +50 -30
- package/build-style/style.css +52 -30
- package/build-types/base-control/index.d.ts +4 -3
- package/build-types/base-control/index.d.ts.map +1 -1
- package/build-types/base-control/stories/index.d.ts +1 -1
- package/build-types/base-control/stories/index.d.ts.map +1 -1
- package/build-types/base-control/styles/base-control-styles.d.ts.map +1 -1
- package/build-types/base-control/types.d.ts +0 -1
- package/build-types/base-control/types.d.ts.map +1 -1
- package/build-types/border-control/styles.d.ts.map +1 -1
- package/build-types/color-picker/color-display.d.ts +13 -0
- package/build-types/color-picker/color-display.d.ts.map +1 -0
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/date-time/time/index.d.ts.map +1 -1
- package/build-types/date-time/time/styles.d.ts +0 -4
- package/build-types/date-time/time/styles.d.ts.map +1 -1
- package/build-types/external-link/index.d.ts.map +1 -1
- package/build-types/flex/flex/component.d.ts +5 -4
- package/build-types/flex/flex/component.d.ts.map +1 -1
- package/build-types/flex/flex/hook.d.ts +5 -2
- package/build-types/flex/flex/hook.d.ts.map +1 -1
- package/build-types/flex/flex/index.d.ts +2 -2
- package/build-types/flex/flex/index.d.ts.map +1 -1
- package/build-types/flex/flex-block/component.d.ts +5 -4
- package/build-types/flex/flex-block/component.d.ts.map +1 -1
- package/build-types/flex/flex-block/hook.d.ts +6 -3
- package/build-types/flex/flex-block/hook.d.ts.map +1 -1
- package/build-types/flex/flex-block/index.d.ts +2 -2
- package/build-types/flex/flex-block/index.d.ts.map +1 -1
- package/build-types/flex/flex-item/component.d.ts +5 -4
- package/build-types/flex/flex-item/component.d.ts.map +1 -1
- package/build-types/flex/flex-item/hook.d.ts +6 -3
- package/build-types/flex/flex-item/hook.d.ts.map +1 -1
- package/build-types/flex/flex-item/index.d.ts +2 -2
- package/build-types/flex/flex-item/index.d.ts.map +1 -1
- package/build-types/flex/index.d.ts +3 -3
- package/build-types/flex/index.d.ts.map +1 -1
- package/build-types/flex/stories/index.d.ts +13 -0
- package/build-types/flex/stories/index.d.ts.map +1 -0
- package/build-types/flex/styles.d.ts +5 -5
- package/build-types/flex/styles.d.ts.map +1 -1
- package/build-types/flex/test/index.d.ts +2 -0
- package/build-types/flex/test/index.d.ts.map +1 -0
- package/build-types/flex/types.d.ts +15 -11
- package/build-types/flex/types.d.ts.map +1 -1
- package/build-types/flyout/context.d.ts +6 -0
- package/build-types/flyout/context.d.ts.map +1 -0
- package/build-types/flyout/flyout/component.d.ts +21 -0
- package/build-types/flyout/flyout/component.d.ts.map +1 -0
- package/build-types/flyout/flyout/hook.d.ts +270 -0
- package/build-types/flyout/flyout/hook.d.ts.map +1 -0
- package/build-types/flyout/flyout/index.d.ts +3 -0
- package/build-types/flyout/flyout/index.d.ts.map +1 -0
- package/build-types/flyout/flyout-content/component.d.ts +3 -0
- package/build-types/flyout/flyout-content/component.d.ts.map +1 -0
- package/build-types/flyout/flyout-content/index.d.ts +2 -0
- package/build-types/flyout/flyout-content/index.d.ts.map +1 -0
- package/build-types/flyout/index.d.ts +2 -0
- package/build-types/flyout/index.d.ts.map +1 -0
- package/build-types/flyout/styles.d.ts +22 -0
- package/build-types/flyout/styles.d.ts.map +1 -0
- package/build-types/flyout/types.d.ts +80 -0
- package/build-types/flyout/types.d.ts.map +1 -0
- package/build-types/flyout/utils.d.ts +8 -0
- package/build-types/flyout/utils.d.ts.map +1 -0
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/stories/index.d.ts +6 -0
- package/build-types/form-token-field/stories/index.d.ts.map +1 -1
- package/build-types/form-token-field/suggestions-list.d.ts +1 -1
- package/build-types/form-token-field/suggestions-list.d.ts.map +1 -1
- package/build-types/form-token-field/types.d.ts +15 -3
- package/build-types/form-token-field/types.d.ts.map +1 -1
- package/build-types/input-control/input-base.d.ts.map +1 -1
- package/build-types/input-control/reducer/actions.d.ts +3 -1
- package/build-types/input-control/reducer/actions.d.ts.map +1 -1
- package/build-types/input-control/reducer/reducer.d.ts +2 -2
- package/build-types/input-control/reducer/reducer.d.ts.map +1 -1
- package/build-types/input-control/reducer/state.d.ts +2 -2
- package/build-types/input-control/reducer/state.d.ts.map +1 -1
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/placeholder/index.d.ts +16 -0
- package/build-types/placeholder/index.d.ts.map +1 -0
- package/build-types/placeholder/stories/index.d.ts +12 -0
- package/build-types/placeholder/stories/index.d.ts.map +1 -0
- package/build-types/placeholder/types.d.ts +47 -0
- package/build-types/placeholder/types.d.ts.map +1 -0
- package/build-types/popover/index.d.ts +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/popover/utils.d.ts +70 -0
- package/build-types/popover/utils.d.ts.map +1 -0
- package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/style-provider/index.d.ts +7 -4
- package/build-types/style-provider/index.d.ts.map +1 -1
- package/build-types/style-provider/types.d.ts +15 -0
- package/build-types/style-provider/types.d.ts.map +1 -0
- package/build-types/swatch/index.d.ts +5 -0
- package/build-types/swatch/index.d.ts.map +1 -0
- package/build-types/swatch/types.d.ts +11 -0
- package/build-types/swatch/types.d.ts.map +1 -0
- package/build-types/text/hook.d.ts.map +1 -1
- package/build-types/tools-panel/styles.d.ts +1 -1
- package/build-types/tools-panel/styles.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/ui/tooltip/styles.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +1 -1
- package/build-types/unit-control/stories/index.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
- package/build-types/unit-control/types.d.ts +1 -7
- package/build-types/unit-control/types.d.ts.map +1 -1
- package/build-types/utils/base-label.d.ts +2 -0
- package/build-types/utils/base-label.d.ts.map +1 -0
- package/build-types/utils/box-sizing.d.ts +2 -0
- package/build-types/utils/box-sizing.d.ts.map +1 -0
- package/build-types/utils/hooks/use-combined-ref.d.ts +8 -0
- package/build-types/utils/hooks/use-combined-ref.d.ts.map +1 -0
- package/build-types/utils/style-mixins.d.ts +2 -0
- package/package.json +17 -17
- package/src/base-control/index.tsx +5 -3
- package/src/base-control/stories/index.tsx +1 -0
- package/src/base-control/styles/base-control-styles.ts +9 -5
- package/src/base-control/types.ts +0 -1
- package/src/border-control/styles.ts +2 -1
- package/src/box-control/all-input-control.js +3 -27
- package/src/box-control/index.js +5 -6
- package/src/box-control/styles/box-control-styles.js +1 -2
- package/src/box-control/utils.js +32 -0
- package/src/color-picker/styles.ts +3 -0
- package/src/combobox-control/README.md +7 -0
- package/src/combobox-control/index.js +14 -4
- package/src/combobox-control/stories/index.js +49 -5
- package/src/custom-gradient-picker/style.scss +0 -12
- package/src/custom-select-control/index.js +3 -2
- package/src/custom-select-control/style.scss +1 -5
- package/src/date-time/time/index.tsx +7 -5
- package/src/date-time/time/styles.ts +3 -6
- package/src/external-link/index.tsx +10 -0
- package/src/flex/flex/README.md +19 -13
- package/src/flex/flex/{component.js → component.tsx} +15 -10
- package/src/flex/flex/{hook.js → hook.ts} +14 -13
- package/src/flex/flex/{index.js → index.ts} +0 -0
- package/src/flex/flex-block/README.md +3 -3
- package/src/flex/flex-block/{component.js → component.tsx} +15 -10
- package/src/flex/flex-block/{hook.js → hook.ts} +5 -5
- package/src/flex/flex-block/{index.js → index.ts} +0 -0
- package/src/flex/flex-item/README.md +6 -5
- package/src/flex/flex-item/{component.js → component.tsx} +15 -10
- package/src/flex/flex-item/{hook.js → hook.ts} +10 -7
- package/src/flex/flex-item/{index.js → index.ts} +0 -0
- package/src/flex/{index.js → index.ts} +0 -0
- package/src/flex/stories/index.tsx +81 -0
- package/src/flex/{styles.js → styles.ts} +0 -0
- package/src/flex/test/__snapshots__/{index.js.snap → index.tsx.snap} +49 -9
- package/src/flex/test/index.tsx +84 -0
- package/src/flex/types.ts +15 -11
- package/src/focal-point-picker/styles/focal-point-picker-style.js +0 -5
- package/src/focal-point-picker/styles/focal-point-style.js +0 -1
- package/src/font-size-picker/index.js +18 -7
- package/src/font-size-picker/stories/index.js +6 -0
- package/src/form-token-field/README.md +2 -1
- package/src/form-token-field/index.tsx +5 -2
- package/src/form-token-field/stories/index.tsx +14 -0
- package/src/form-token-field/style.scss +0 -5
- package/src/form-token-field/suggestions-list.tsx +21 -12
- package/src/form-token-field/types.ts +16 -2
- package/src/index.js +4 -1
- package/src/input-control/input-base.tsx +0 -1
- package/src/input-control/reducer/actions.ts +3 -1
- package/src/input-control/reducer/reducer.ts +27 -10
- package/src/input-control/reducer/state.ts +7 -2
- package/src/input-control/styles/input-control-styles.tsx +3 -1
- package/src/input-control/test/index.js +20 -4
- package/src/mobile/global-styles-context/utils.native.js +21 -4
- package/src/mobile/image/index.native.js +27 -2
- package/src/mobile/link-picker/link-picker-screen.native.js +12 -4
- package/src/mobile/picker/index.ios.js +16 -0
- package/src/mobile/picker/styles.native.scss +8 -0
- package/src/panel/style.scss +4 -1
- package/src/placeholder/README.md +49 -9
- package/src/placeholder/{index.js → index.tsx} +27 -23
- package/src/placeholder/stories/index.tsx +64 -0
- package/src/placeholder/style.scss +0 -4
- package/src/placeholder/types.ts +48 -0
- package/src/popover/README.md +7 -0
- package/src/popover/index.js +144 -70
- package/src/popover/stories/index.js +199 -98
- package/src/popover/style.scss +60 -6
- package/src/popover/test/index.js +23 -1
- package/src/range-control/styles/range-control-styles.ts +0 -12
- package/src/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +1 -1
- package/src/select-control/styles/select-control-styles.ts +0 -1
- package/src/style-provider/index.tsx +41 -0
- package/src/style-provider/types.ts +15 -0
- package/src/swatch/{index.js → index.tsx} +4 -1
- package/src/swatch/types.ts +11 -0
- package/src/text/hook.js +5 -3
- package/src/toggle-group-control/test/__snapshots__/index.js.snap +24 -0
- package/src/tools-panel/styles.ts +7 -16
- package/src/tools-panel/test/__snapshots__/index.js.snap +2 -11
- package/src/tools-panel/tools-panel/hook.ts +6 -1
- package/src/ui/tooltip/styles.js +1 -0
- package/src/ui/tooltip/test/__snapshots__/index.js.snap +1 -0
- package/src/unit-control/stories/index.tsx +16 -23
- package/src/unit-control/styles/unit-control-styles.ts +93 -41
- package/src/unit-control/types.ts +1 -7
- package/src/utils/base-label.ts +13 -0
- package/src/utils/box-sizing.ts +14 -0
- package/src/utils/style-mixins.js +2 -0
- package/tsconfig.json +2 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/flex/stories/index.js +0 -29
- package/src/flex/test/index.js +0 -77
- package/src/placeholder/stories/index.js +0 -44
- package/src/popover/stories/_utils.js +0 -64
- package/src/style-provider/index.js +0 -31
|
@@ -9,12 +9,52 @@ import { more } from '@wordpress/icons';
|
|
|
9
9
|
const MyPlaceholder = () => <Placeholder icon={ more } label="Placeholder" />;
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
## Props
|
|
13
|
+
|
|
14
|
+
### `className`: `string`
|
|
15
|
+
|
|
16
|
+
Class to set on the container div.
|
|
17
|
+
|
|
18
|
+
- Required: No
|
|
19
|
+
|
|
20
|
+
### `icon`: `string|Function|WPComponent|null`
|
|
21
|
+
|
|
22
|
+
If provided, renders an icon next to the label.
|
|
23
|
+
|
|
24
|
+
- Required: No
|
|
25
|
+
|
|
26
|
+
### `instructions`: `string`
|
|
27
|
+
|
|
28
|
+
Instructions of the placeholder.
|
|
29
|
+
|
|
30
|
+
- Required: No
|
|
31
|
+
|
|
32
|
+
### `isColumnLayout`: `boolean`
|
|
33
|
+
|
|
34
|
+
Changes placeholder children layout from flex-row to flex-column.
|
|
35
|
+
|
|
36
|
+
- Required: No
|
|
37
|
+
|
|
38
|
+
### `label`: `string`
|
|
39
|
+
|
|
40
|
+
Title of the placeholder.
|
|
41
|
+
|
|
42
|
+
- Required: Yes
|
|
43
|
+
|
|
44
|
+
### `notices`: `ReactNode`
|
|
45
|
+
|
|
46
|
+
A rendered notices list
|
|
47
|
+
|
|
48
|
+
- Required: No
|
|
49
|
+
|
|
50
|
+
### `preview`: `ReactNode`
|
|
51
|
+
|
|
52
|
+
Preview to be rendered in the placeholder.
|
|
53
|
+
|
|
54
|
+
- Required: No
|
|
55
|
+
|
|
56
|
+
### `withIllustration`: `boolean`
|
|
57
|
+
|
|
58
|
+
Outputs a placeholder illustration.
|
|
59
|
+
|
|
60
|
+
- Required: No
|
|
@@ -13,6 +13,8 @@ import { SVG, Path } from '@wordpress/primitives';
|
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
15
|
import Icon from '../icon';
|
|
16
|
+
import type { PlaceholderProps } from './types';
|
|
17
|
+
import type { WordPressComponentProps } from '../ui/context';
|
|
16
18
|
|
|
17
19
|
const PlaceholderIllustration = (
|
|
18
20
|
<SVG
|
|
@@ -29,31 +31,33 @@ const PlaceholderIllustration = (
|
|
|
29
31
|
/**
|
|
30
32
|
* Renders a placeholder. Normally used by blocks to render their empty state.
|
|
31
33
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @param {string} props.label Title of the placeholder.
|
|
36
|
-
* @param {string} props.instructions Instructions of the placeholder.
|
|
37
|
-
* @param {string} props.className Class to set on the container div.
|
|
38
|
-
* @param {Object} props.notices A rendered notices list.
|
|
39
|
-
* @param {Object} props.preview Preview to be rendered in the placeholder.
|
|
40
|
-
* @param {boolean} props.isColumnLayout Whether a column layout should be used.
|
|
41
|
-
* @param {boolean} props.withIllustration Whether to add an illustration to the placeholder.
|
|
34
|
+
* ```jsx
|
|
35
|
+
* import { Placeholder } from '@wordpress/components';
|
|
36
|
+
* import { more } from '@wordpress/icons';
|
|
42
37
|
*
|
|
43
|
-
*
|
|
38
|
+
* const MyPlaceholder = () => <Placeholder icon={ more } label="Placeholder" />;
|
|
39
|
+
* ```
|
|
44
40
|
*/
|
|
45
|
-
function Placeholder(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
41
|
+
export function Placeholder< IconProps = unknown >(
|
|
42
|
+
// ref is omitted until we have `WordPressComponentPropsWithoutRef` or add
|
|
43
|
+
// ref forwarding to Placeholder.
|
|
44
|
+
props: Omit<
|
|
45
|
+
WordPressComponentProps< PlaceholderProps< IconProps >, 'div', false >,
|
|
46
|
+
'ref'
|
|
47
|
+
>
|
|
48
|
+
) {
|
|
49
|
+
const {
|
|
50
|
+
icon,
|
|
51
|
+
children,
|
|
52
|
+
label,
|
|
53
|
+
instructions,
|
|
54
|
+
className,
|
|
55
|
+
notices,
|
|
56
|
+
preview,
|
|
57
|
+
isColumnLayout,
|
|
58
|
+
withIllustration,
|
|
59
|
+
...additionalProps
|
|
60
|
+
} = props;
|
|
57
61
|
const [ resizeListener, { width } ] = useResizeObserver();
|
|
58
62
|
|
|
59
63
|
// Since `useResizeObserver` will report a width of `null` until after the
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { starEmpty, starFilled, styles, wordpress } from '@wordpress/icons';
|
|
10
|
+
import { useState } from '@wordpress/element';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import Placeholder from '../';
|
|
16
|
+
import TextControl from '../../text-control';
|
|
17
|
+
|
|
18
|
+
const ICONS = { starEmpty, starFilled, styles, wordpress };
|
|
19
|
+
|
|
20
|
+
const meta: ComponentMeta< typeof Placeholder > = {
|
|
21
|
+
component: Placeholder,
|
|
22
|
+
title: 'Components/Placeholder',
|
|
23
|
+
argTypes: {
|
|
24
|
+
children: { control: { type: null } },
|
|
25
|
+
notices: { control: { type: null } },
|
|
26
|
+
preview: { control: { type: null } },
|
|
27
|
+
icon: {
|
|
28
|
+
control: { type: 'select' },
|
|
29
|
+
options: Object.keys( ICONS ),
|
|
30
|
+
mapping: ICONS,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
parameters: {
|
|
34
|
+
controls: { expanded: true },
|
|
35
|
+
docs: { source: { state: 'open' } },
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
export default meta;
|
|
39
|
+
|
|
40
|
+
const Template: ComponentStory< typeof Placeholder > = ( args ) => {
|
|
41
|
+
const [ value, setValue ] = useState( '' );
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Placeholder { ...args }>
|
|
45
|
+
<div>
|
|
46
|
+
<TextControl
|
|
47
|
+
label="Sample Field"
|
|
48
|
+
placeholder="Enter something here"
|
|
49
|
+
value={ value }
|
|
50
|
+
onChange={ setValue }
|
|
51
|
+
/>
|
|
52
|
+
</div>
|
|
53
|
+
</Placeholder>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const Default: ComponentStory< typeof Placeholder > = Template.bind(
|
|
58
|
+
{}
|
|
59
|
+
);
|
|
60
|
+
Default.args = {
|
|
61
|
+
icon: 'wordpress',
|
|
62
|
+
label: 'My Placeholder Label',
|
|
63
|
+
instructions: 'Here are instructions you should follow',
|
|
64
|
+
};
|
|
@@ -27,10 +27,6 @@
|
|
|
27
27
|
box-shadow: inset 0 0 0 $border-width $gray-900;
|
|
28
28
|
outline: 1px solid transparent; // Shown for Windows 10 High Contrast mode.
|
|
29
29
|
|
|
30
|
-
.components-base-control__label {
|
|
31
|
-
font-size: $default-font-size;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
30
|
&.has-illustration {
|
|
35
31
|
background: none;
|
|
36
32
|
border: none;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import type { IconType } from '../icon';
|
|
10
|
+
|
|
11
|
+
export type PlaceholderProps< IconProps = unknown > = {
|
|
12
|
+
/**
|
|
13
|
+
* The children elements.
|
|
14
|
+
*/
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Class to set on the container div.
|
|
18
|
+
*/
|
|
19
|
+
className?: string;
|
|
20
|
+
/**
|
|
21
|
+
* If provided, renders an icon next to the label.
|
|
22
|
+
*/
|
|
23
|
+
icon?: IconType< IconProps >;
|
|
24
|
+
/**
|
|
25
|
+
* Instructions of the placeholder.
|
|
26
|
+
*/
|
|
27
|
+
instructions?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Changes placeholder children layout from flex-row to flex-column.
|
|
30
|
+
*/
|
|
31
|
+
isColumnLayout?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Title of the placeholder.
|
|
34
|
+
*/
|
|
35
|
+
label?: string;
|
|
36
|
+
/**
|
|
37
|
+
* A rendered notices list
|
|
38
|
+
*/
|
|
39
|
+
notices?: ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Preview to be rendered in the placeholder.
|
|
42
|
+
*/
|
|
43
|
+
preview?: ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* Outputs a placeholder illustration.
|
|
46
|
+
*/
|
|
47
|
+
withIllustration?: boolean;
|
|
48
|
+
};
|
package/src/popover/README.md
CHANGED
|
@@ -71,6 +71,13 @@ Each of these base placements has an alignment in the form -start and -end. For
|
|
|
71
71
|
- Required: No
|
|
72
72
|
- Default: `"bottom-start"`
|
|
73
73
|
|
|
74
|
+
### offset
|
|
75
|
+
|
|
76
|
+
The distance (in pixels) between the anchor and popover.
|
|
77
|
+
|
|
78
|
+
- Type: `Number`
|
|
79
|
+
- Required: No
|
|
80
|
+
|
|
74
81
|
### children
|
|
75
82
|
|
|
76
83
|
The content to be displayed within the popover.
|
package/src/popover/index.js
CHANGED
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
} from '@wordpress/compose';
|
|
33
33
|
import { close } from '@wordpress/icons';
|
|
34
34
|
import deprecated from '@wordpress/deprecated';
|
|
35
|
+
import { Path, SVG } from '@wordpress/primitives';
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
38
|
* Internal dependencies
|
|
@@ -48,6 +49,30 @@ import { getAnimateClassName } from '../animate';
|
|
|
48
49
|
*/
|
|
49
50
|
const SLOT_NAME = 'Popover';
|
|
50
51
|
|
|
52
|
+
// An SVG displaying a triangle facing down, filled with a solid
|
|
53
|
+
// color and bordered in such a way to create an arrow-like effect.
|
|
54
|
+
// Keeping the SVG's viewbox squared simplify the arrow positioning
|
|
55
|
+
// calculations.
|
|
56
|
+
const ArrowTriangle = ( props ) => (
|
|
57
|
+
<SVG
|
|
58
|
+
{ ...props }
|
|
59
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
60
|
+
viewBox={ `0 0 100 100` }
|
|
61
|
+
className="components-popover__triangle"
|
|
62
|
+
role="presentation"
|
|
63
|
+
>
|
|
64
|
+
<Path
|
|
65
|
+
className="components-popover__triangle-bg"
|
|
66
|
+
d="M 0 0 L 50 50 L 100 0"
|
|
67
|
+
/>
|
|
68
|
+
<Path
|
|
69
|
+
className="components-popover__triangle-border"
|
|
70
|
+
d="M 0 0 L 50 50 L 100 0"
|
|
71
|
+
vectorEffect="non-scaling-stroke"
|
|
72
|
+
/>
|
|
73
|
+
</SVG>
|
|
74
|
+
);
|
|
75
|
+
|
|
51
76
|
const slotNameContext = createContext();
|
|
52
77
|
|
|
53
78
|
const positionToPlacement = ( position ) => {
|
|
@@ -104,7 +129,7 @@ const Popover = (
|
|
|
104
129
|
noArrow = true,
|
|
105
130
|
isAlternate,
|
|
106
131
|
position,
|
|
107
|
-
placement = 'bottom-start',
|
|
132
|
+
placement: placementProp = 'bottom-start',
|
|
108
133
|
offset,
|
|
109
134
|
focusOnMount = 'firstElement',
|
|
110
135
|
anchorRef,
|
|
@@ -114,11 +139,11 @@ const Popover = (
|
|
|
114
139
|
onFocusOutside,
|
|
115
140
|
__unstableSlotName = SLOT_NAME,
|
|
116
141
|
__unstableObserveElement,
|
|
117
|
-
__unstableForcePosition,
|
|
142
|
+
__unstableForcePosition = false,
|
|
118
143
|
__unstableShift = false,
|
|
119
144
|
...contentProps
|
|
120
145
|
},
|
|
121
|
-
|
|
146
|
+
forwardedRef
|
|
122
147
|
) => {
|
|
123
148
|
if ( range ) {
|
|
124
149
|
deprecated( 'range prop in Popover component', {
|
|
@@ -129,33 +154,35 @@ const Popover = (
|
|
|
129
154
|
|
|
130
155
|
const arrowRef = useRef( null );
|
|
131
156
|
const anchorRefFallback = useRef( null );
|
|
157
|
+
|
|
132
158
|
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
133
159
|
const isExpanded = expandOnMobile && isMobileViewport;
|
|
134
160
|
const hasArrow = ! isExpanded && ! noArrow;
|
|
135
|
-
const
|
|
161
|
+
const normalizedPlacementFromProps = position
|
|
136
162
|
? positionToPlacement( position )
|
|
137
|
-
:
|
|
163
|
+
: placementProp;
|
|
138
164
|
|
|
139
165
|
const ownerDocument = useMemo( () => {
|
|
166
|
+
let documentToReturn;
|
|
167
|
+
|
|
140
168
|
if ( anchorRef?.top ) {
|
|
141
|
-
|
|
169
|
+
documentToReturn = anchorRef?.top.ownerDocument;
|
|
142
170
|
} else if ( anchorRef?.startContainer ) {
|
|
143
|
-
|
|
171
|
+
documentToReturn = anchorRef.startContainer.ownerDocument;
|
|
144
172
|
} else if ( anchorRef?.current ) {
|
|
145
|
-
|
|
173
|
+
documentToReturn = anchorRef.current.ownerDocument;
|
|
146
174
|
} else if ( anchorRef ) {
|
|
147
175
|
// This one should be deprecated.
|
|
148
|
-
|
|
176
|
+
documentToReturn = anchorRef.ownerDocument;
|
|
149
177
|
} else if ( anchorRect && anchorRect?.ownerDocument ) {
|
|
150
|
-
|
|
178
|
+
documentToReturn = anchorRect.ownerDocument;
|
|
151
179
|
} else if ( getAnchorRect ) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
);
|
|
180
|
+
documentToReturn = getAnchorRect(
|
|
181
|
+
anchorRefFallback.current
|
|
182
|
+
)?.ownerDocument;
|
|
156
183
|
}
|
|
157
184
|
|
|
158
|
-
return document;
|
|
185
|
+
return documentToReturn ?? document;
|
|
159
186
|
}, [ anchorRef, anchorRect, getAnchorRect ] );
|
|
160
187
|
|
|
161
188
|
/**
|
|
@@ -170,20 +197,42 @@ const Popover = (
|
|
|
170
197
|
}
|
|
171
198
|
|
|
172
199
|
const iframeRect = frameElement.getBoundingClientRect();
|
|
173
|
-
return {
|
|
174
|
-
name: 'iframeOffset',
|
|
175
|
-
fn( { x, y } ) {
|
|
176
|
-
return {
|
|
177
|
-
x: x + iframeRect.left,
|
|
178
|
-
y: y + iframeRect.top,
|
|
179
|
-
};
|
|
180
|
-
},
|
|
181
|
-
};
|
|
200
|
+
return { x: iframeRect.left, y: iframeRect.top };
|
|
182
201
|
}, [ ownerDocument ] );
|
|
183
202
|
|
|
184
|
-
const
|
|
185
|
-
frameOffset
|
|
186
|
-
|
|
203
|
+
const middleware = [
|
|
204
|
+
frameOffset || offset
|
|
205
|
+
? offsetMiddleware( ( { placement: currentPlacement } ) => {
|
|
206
|
+
if ( ! frameOffset ) {
|
|
207
|
+
return offset;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const isTopBottomPlacement =
|
|
211
|
+
currentPlacement.includes( 'top' ) ||
|
|
212
|
+
currentPlacement.includes( 'bottom' );
|
|
213
|
+
|
|
214
|
+
// The main axis should represent the gap between the
|
|
215
|
+
// floating element and the reference element. The cross
|
|
216
|
+
// axis is always perpendicular to the main axis.
|
|
217
|
+
const mainAxis = isTopBottomPlacement ? 'y' : 'x';
|
|
218
|
+
const crossAxis = mainAxis === 'x' ? 'y' : 'x';
|
|
219
|
+
|
|
220
|
+
// When the popover is before the reference, subtract the offset,
|
|
221
|
+
// of the main axis else add it.
|
|
222
|
+
const hasBeforePlacement =
|
|
223
|
+
currentPlacement.includes( 'top' ) ||
|
|
224
|
+
currentPlacement.includes( 'left' );
|
|
225
|
+
const mainAxisModifier = hasBeforePlacement ? -1 : 1;
|
|
226
|
+
const normalizedOffset = offset ? offset : 0;
|
|
227
|
+
|
|
228
|
+
return {
|
|
229
|
+
mainAxis:
|
|
230
|
+
normalizedOffset +
|
|
231
|
+
frameOffset[ mainAxis ] * mainAxisModifier,
|
|
232
|
+
crossAxis: frameOffset[ crossAxis ],
|
|
233
|
+
};
|
|
234
|
+
} )
|
|
235
|
+
: undefined,
|
|
187
236
|
__unstableForcePosition ? undefined : flip(),
|
|
188
237
|
__unstableForcePosition
|
|
189
238
|
? undefined
|
|
@@ -231,33 +280,38 @@ const Popover = (
|
|
|
231
280
|
} );
|
|
232
281
|
|
|
233
282
|
const {
|
|
283
|
+
// Positioning coordinates
|
|
234
284
|
x,
|
|
235
285
|
y,
|
|
286
|
+
// Callback refs (not regular refs). This allows the position to be updated.
|
|
287
|
+
// when either elements change.
|
|
236
288
|
reference,
|
|
237
289
|
floating,
|
|
238
|
-
|
|
290
|
+
// Object with "regular" refs to both "reference" and "floating"
|
|
239
291
|
refs,
|
|
292
|
+
// Type of CSS position property to use (absolute or fixed)
|
|
293
|
+
strategy,
|
|
240
294
|
update,
|
|
241
|
-
placement:
|
|
295
|
+
placement: computedPlacement,
|
|
242
296
|
middlewareData: { arrow: arrowData = {} },
|
|
243
|
-
} = useFloating( {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
// Updates references
|
|
297
|
+
} = useFloating( { placement: normalizedPlacementFromProps, middleware } );
|
|
298
|
+
|
|
299
|
+
// Update the `reference`'s ref.
|
|
300
|
+
//
|
|
301
|
+
// In floating-ui's terms:
|
|
302
|
+
// - "reference" refers to the popover's anchor element.
|
|
303
|
+
// - "floating" refers the floating popover's element.
|
|
304
|
+
// A floating element can also be positioned relative to a virtual element,
|
|
305
|
+
// instead of a real one. A virtual element is represented by an object
|
|
306
|
+
// with the `getBoundingClientRect()` function (like real elements).
|
|
307
|
+
// See https://floating-ui.com/docs/virtual-elements for more info.
|
|
256
308
|
useLayoutEffect( () => {
|
|
257
|
-
|
|
258
|
-
|
|
309
|
+
let resultingReferenceRef;
|
|
310
|
+
|
|
259
311
|
if ( anchorRef?.top ) {
|
|
260
|
-
|
|
312
|
+
// Create a virtual element for the ref. The expectation is that
|
|
313
|
+
// if anchorRef.top is defined, then anchorRef.bottom is defined too.
|
|
314
|
+
resultingReferenceRef = {
|
|
261
315
|
getBoundingClientRect() {
|
|
262
316
|
const topRect = anchorRef.top.getBoundingClientRect();
|
|
263
317
|
const bottomRect = anchorRef.bottom.getBoundingClientRect();
|
|
@@ -270,17 +324,22 @@ const Popover = (
|
|
|
270
324
|
},
|
|
271
325
|
};
|
|
272
326
|
} else if ( anchorRef?.current ) {
|
|
273
|
-
|
|
327
|
+
// Standard React ref.
|
|
328
|
+
resultingReferenceRef = anchorRef.current;
|
|
274
329
|
} else if ( anchorRef ) {
|
|
275
|
-
|
|
330
|
+
// If `anchorRef` holds directly the element's value (no `current` key)
|
|
331
|
+
// This is a weird scenario and should be deprecated.
|
|
332
|
+
resultingReferenceRef = anchorRef;
|
|
276
333
|
} else if ( anchorRect ) {
|
|
277
|
-
|
|
334
|
+
// Create a virtual element for the ref.
|
|
335
|
+
resultingReferenceRef = {
|
|
278
336
|
getBoundingClientRect() {
|
|
279
337
|
return anchorRect;
|
|
280
338
|
},
|
|
281
339
|
};
|
|
282
340
|
} else if ( getAnchorRect ) {
|
|
283
|
-
|
|
341
|
+
// Create a virtual element for the ref.
|
|
342
|
+
resultingReferenceRef = {
|
|
284
343
|
getBoundingClientRect() {
|
|
285
344
|
const rect = getAnchorRect( anchorRefFallback.current );
|
|
286
345
|
return new window.DOMRect(
|
|
@@ -292,23 +351,29 @@ const Popover = (
|
|
|
292
351
|
},
|
|
293
352
|
};
|
|
294
353
|
} else if ( anchorRefFallback.current ) {
|
|
295
|
-
|
|
354
|
+
// If no explicit ref is passed via props, fall back to
|
|
355
|
+
// anchoring to the popover's parent node.
|
|
356
|
+
resultingReferenceRef = anchorRefFallback.current.parentNode;
|
|
296
357
|
}
|
|
297
358
|
|
|
298
|
-
if ( !
|
|
359
|
+
if ( ! resultingReferenceRef ) {
|
|
299
360
|
return;
|
|
300
361
|
}
|
|
301
362
|
|
|
302
|
-
reference(
|
|
363
|
+
reference( resultingReferenceRef );
|
|
303
364
|
|
|
304
365
|
if ( ! refs.floating.current ) {
|
|
305
366
|
return;
|
|
306
367
|
}
|
|
307
368
|
|
|
308
|
-
return autoUpdate(
|
|
369
|
+
return autoUpdate(
|
|
370
|
+
resultingReferenceRef,
|
|
371
|
+
refs.floating.current,
|
|
372
|
+
update
|
|
373
|
+
);
|
|
309
374
|
}, [ anchorRef, anchorRect, getAnchorRect ] );
|
|
310
375
|
|
|
311
|
-
// This is only needed for a
|
|
376
|
+
// This is only needed for a smooth transition when moving blocks.
|
|
312
377
|
useLayoutEffect( () => {
|
|
313
378
|
if ( ! __unstableObserveElement ) {
|
|
314
379
|
return;
|
|
@@ -321,7 +386,9 @@ const Popover = (
|
|
|
321
386
|
};
|
|
322
387
|
}, [ __unstableObserveElement ] );
|
|
323
388
|
|
|
324
|
-
// If
|
|
389
|
+
// If the reference element is in a different ownerDocument (e.g. iFrame),
|
|
390
|
+
// we need to manually update the floating's position as the reference's owner
|
|
391
|
+
// document scrolls.
|
|
325
392
|
useLayoutEffect( () => {
|
|
326
393
|
if ( ownerDocument === document ) {
|
|
327
394
|
return;
|
|
@@ -336,9 +403,15 @@ const Popover = (
|
|
|
336
403
|
!! animate &&
|
|
337
404
|
getAnimateClassName( {
|
|
338
405
|
type: 'appear',
|
|
339
|
-
origin: placementToAnimationOrigin(
|
|
406
|
+
origin: placementToAnimationOrigin( computedPlacement ),
|
|
340
407
|
} );
|
|
341
408
|
|
|
409
|
+
const mergedFloatingRef = useMergeRefs( [
|
|
410
|
+
floating,
|
|
411
|
+
dialogRef,
|
|
412
|
+
forwardedRef,
|
|
413
|
+
] );
|
|
414
|
+
|
|
342
415
|
// Disable reason: We care to capture the _bubbled_ events from inputs
|
|
343
416
|
// within popover as inferring close intent.
|
|
344
417
|
|
|
@@ -356,7 +429,7 @@ const Popover = (
|
|
|
356
429
|
}
|
|
357
430
|
) }
|
|
358
431
|
{ ...contentProps }
|
|
359
|
-
ref={
|
|
432
|
+
ref={ mergedFloatingRef }
|
|
360
433
|
{ ...dialogProps }
|
|
361
434
|
tabIndex="-1"
|
|
362
435
|
style={
|
|
@@ -369,6 +442,7 @@ const Popover = (
|
|
|
369
442
|
}
|
|
370
443
|
}
|
|
371
444
|
>
|
|
445
|
+
{ /* Prevents scroll on the document */ }
|
|
372
446
|
{ isExpanded && <ScrollLock /> }
|
|
373
447
|
{ isExpanded && (
|
|
374
448
|
<div className="components-popover__header">
|
|
@@ -385,22 +459,22 @@ const Popover = (
|
|
|
385
459
|
<div className="components-popover__content">{ children }</div>
|
|
386
460
|
{ hasArrow && (
|
|
387
461
|
<div
|
|
388
|
-
className="components-popover__arrow"
|
|
389
462
|
ref={ arrowRef }
|
|
463
|
+
className={ [
|
|
464
|
+
'components-popover__arrow',
|
|
465
|
+
`is-${ computedPlacement.split( '-' )[ 0 ] }`,
|
|
466
|
+
].join( ' ' ) }
|
|
390
467
|
style={ {
|
|
391
|
-
left:
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
? 0
|
|
398
|
-
: arrowData.y,
|
|
399
|
-
right: undefined,
|
|
400
|
-
bottom: undefined,
|
|
401
|
-
[ staticSide ]: '-4px',
|
|
468
|
+
left: Number.isFinite( arrowData?.x )
|
|
469
|
+
? `${ arrowData.x }px`
|
|
470
|
+
: '',
|
|
471
|
+
top: Number.isFinite( arrowData?.y )
|
|
472
|
+
? `${ arrowData.y }px`
|
|
473
|
+
: '',
|
|
402
474
|
} }
|
|
403
|
-
|
|
475
|
+
>
|
|
476
|
+
<ArrowTriangle />
|
|
477
|
+
</div>
|
|
404
478
|
) }
|
|
405
479
|
</div>
|
|
406
480
|
);
|