@wordpress/components 19.8.4 → 19.11.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 +60 -0
- package/CONTRIBUTING.md +80 -7
- package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
- package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
- package/build/border-box-control/border-box-control/component.js +22 -7
- package/build/border-box-control/border-box-control/component.js.map +1 -1
- package/build/border-box-control/border-box-control-linked-button/hook.js +3 -2
- package/build/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
- package/build/border-box-control/border-box-control-split-controls/component.js +21 -8
- package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build/border-box-control/border-box-control-visualizer/hook.js +3 -2
- package/build/border-box-control/border-box-control-visualizer/hook.js.map +1 -1
- package/build/border-box-control/styles.js +11 -15
- package/build/border-box-control/styles.js.map +1 -1
- package/build/border-control/border-control/component.js +5 -3
- package/build/border-control/border-control/component.js.map +1 -1
- package/build/border-control/border-control/hook.js +6 -3
- package/build/border-control/border-control/hook.js.map +1 -1
- package/build/border-control/border-control-dropdown/component.js +6 -2
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/border-control/border-control-dropdown/hook.js +5 -5
- package/build/border-control/border-control-dropdown/hook.js.map +1 -1
- package/build/border-control/styles.js +58 -29
- package/build/border-control/styles.js.map +1 -1
- package/build/box-control/index.js +0 -21
- package/build/box-control/index.js.map +1 -1
- package/build/box-control/utils.js +1 -8
- package/build/box-control/utils.js.map +1 -1
- package/build/button/index.js +3 -5
- package/build/button/index.js.map +1 -1
- package/build/button/index.native.js +16 -2
- package/build/button/index.native.js.map +1 -1
- package/build/button-group/index.js +24 -7
- package/build/button-group/index.js.map +1 -1
- package/build/{flyout → button-group}/types.js +0 -0
- package/build/button-group/types.js.map +1 -0
- package/build/checkbox-control/index.js +34 -7
- package/build/checkbox-control/index.js.map +1 -1
- package/build/checkbox-control/types.js +6 -0
- package/build/checkbox-control/types.js.map +1 -0
- package/build/circular-option-picker/index.js +1 -2
- package/build/circular-option-picker/index.js.map +1 -1
- package/build/color-palette/index.js +5 -12
- package/build/color-palette/index.js.map +1 -1
- package/build/date-time/date.js +43 -19
- package/build/date-time/date.js.map +1 -1
- package/build/date-time/index.js +28 -3
- package/build/date-time/index.js.map +1 -1
- package/build/date-time/time.js +42 -40
- package/build/date-time/time.js.map +1 -1
- package/build/date-time/timezone.js +4 -3
- package/build/date-time/timezone.js.map +1 -1
- package/build/date-time/types.js +6 -0
- package/build/date-time/types.js.map +1 -0
- package/build/date-time/utils.js +6 -4
- package/build/date-time/utils.js.map +1 -1
- package/build/disabled/index.js +4 -76
- package/build/disabled/index.js.map +1 -1
- package/build/draggable/index.native.js +223 -0
- package/build/draggable/index.native.js.map +1 -0
- package/build/dropdown/index.js +7 -5
- package/build/dropdown/index.js.map +1 -1
- package/build/focal-point-picker/index.native.js +3 -3
- package/build/focal-point-picker/index.native.js.map +1 -1
- package/build/heading/hook.js +1 -1
- package/build/heading/hook.js.map +1 -1
- package/build/index.js +0 -8
- package/build/index.js.map +1 -1
- package/build/index.native.js +16 -0
- package/build/index.native.js.map +1 -1
- package/build/input-control/index.js +27 -4
- package/build/input-control/index.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +42 -30
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build/mobile/bottom-sheet/index.native.js +1 -1
- package/build/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build/mobile/bottom-sheet-select-control/index.native.js +4 -2
- package/build/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build/mobile/html-text-input/index.native.js +19 -8
- package/build/mobile/html-text-input/index.native.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.android.js +28 -5
- package/build/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.ios.js +47 -24
- package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build/navigation/styles/navigation-styles.js +12 -12
- package/build/navigation/styles/navigation-styles.js.map +1 -1
- package/build/notice/index.native.js +44 -40
- package/build/notice/index.native.js.map +1 -1
- package/build/notice/list.native.js +27 -45
- package/build/notice/list.native.js.map +1 -1
- package/build/palette-edit/index.js +38 -7
- package/build/palette-edit/index.js.map +1 -1
- package/build/popover/index.js +223 -323
- package/build/popover/index.js.map +1 -1
- package/build/resizable-box/resize-tooltip/utils.js +5 -8
- package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build/sandbox/index.js +2 -2
- package/build/sandbox/index.js.map +1 -1
- package/build/sandbox/index.native.js +1 -1
- package/build/sandbox/index.native.js.map +1 -1
- package/build/select-control/index.js +31 -4
- package/build/select-control/index.js.map +1 -1
- package/build/select-control/styles/select-control-styles.js +17 -14
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- package/build/surface/styles.js +8 -8
- package/build/surface/styles.js.map +1 -1
- package/build/text/hook.js +5 -5
- package/build/text/hook.js.map +1 -1
- package/build/text/styles/text-mixins.native.js +1 -1
- package/build/text/styles/text-mixins.native.js.map +1 -1
- package/build/text/styles.js +7 -7
- package/build/text/styles.js.map +1 -1
- package/build/text-control/index.js +35 -28
- package/build/text-control/index.js.map +1 -1
- package/build/text-control/types.js +6 -0
- package/build/text-control/types.js.map +1 -0
- package/build/toggle-group-control/toggle-group-control/component.js +1 -3
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option-icon/component.js +6 -4
- package/build/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
- package/build/tools-panel/tools-panel-header/component.js +52 -36
- package/build/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build/tooltip/index.js +2 -2
- package/build/tooltip/index.js.map +1 -1
- package/build/ui/spinner/component.js +1 -1
- package/build/ui/spinner/component.js.map +1 -1
- package/build/unit-control/index.js +3 -3
- package/build/unit-control/index.js.map +1 -1
- package/build/unit-control/styles/unit-control-styles.js +11 -20
- package/build/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build/unit-control/utils.js.map +1 -1
- package/build/utils/colors-values.js +9 -24
- package/build/utils/colors-values.js.map +1 -1
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
- package/build-module/border-box-control/border-box-control/component.js +22 -7
- package/build-module/border-box-control/border-box-control/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control-linked-button/hook.js +3 -2
- package/build-module/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
- package/build-module/border-box-control/border-box-control-split-controls/component.js +21 -8
- 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-visualizer/hook.js +3 -2
- package/build-module/border-box-control/border-box-control-visualizer/hook.js.map +1 -1
- package/build-module/border-box-control/styles.js +9 -15
- package/build-module/border-box-control/styles.js.map +1 -1
- package/build-module/border-control/border-control/component.js +5 -3
- package/build-module/border-control/border-control/component.js.map +1 -1
- package/build-module/border-control/border-control/hook.js +6 -3
- package/build-module/border-control/border-control/hook.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js +6 -2
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/hook.js +5 -5
- package/build-module/border-control/border-control-dropdown/hook.js.map +1 -1
- package/build-module/border-control/styles.js +56 -29
- package/build-module/border-control/styles.js.map +1 -1
- package/build-module/box-control/index.js +1 -20
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/box-control/utils.js +0 -6
- package/build-module/box-control/utils.js.map +1 -1
- package/build-module/button/index.js +3 -4
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/index.native.js +16 -3
- package/build-module/button/index.native.js.map +1 -1
- package/build-module/button-group/index.js +27 -7
- package/build-module/button-group/index.js.map +1 -1
- package/build-module/{flyout → button-group}/types.js +0 -0
- package/build-module/{flyout → button-group}/types.js.map +0 -0
- package/build-module/checkbox-control/index.js +31 -7
- package/build-module/checkbox-control/index.js.map +1 -1
- package/build-module/checkbox-control/types.js +2 -0
- package/{build/flyout → build-module/checkbox-control}/types.js.map +0 -0
- package/build-module/circular-option-picker/index.js +1 -2
- package/build-module/circular-option-picker/index.js.map +1 -1
- package/build-module/color-palette/index.js +5 -11
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/date-time/date.js +44 -19
- package/build-module/date-time/date.js.map +1 -1
- package/build-module/date-time/index.js +28 -4
- package/build-module/date-time/index.js.map +1 -1
- package/build-module/date-time/time.js +43 -41
- package/build-module/date-time/time.js.map +1 -1
- package/build-module/date-time/timezone.js +4 -3
- package/build-module/date-time/timezone.js.map +1 -1
- package/build-module/date-time/types.js +2 -0
- package/build-module/date-time/types.js.map +1 -0
- package/build-module/date-time/utils.js +6 -4
- package/build-module/date-time/utils.js.map +1 -1
- package/build-module/disabled/index.js +5 -76
- package/build-module/disabled/index.js.map +1 -1
- package/build-module/draggable/index.native.js +206 -0
- package/build-module/draggable/index.native.js.map +1 -0
- package/build-module/dropdown/index.js +7 -5
- package/build-module/dropdown/index.js.map +1 -1
- package/build-module/focal-point-picker/index.native.js +3 -3
- package/build-module/focal-point-picker/index.native.js.map +1 -1
- package/build-module/heading/hook.js +1 -1
- package/build-module/heading/hook.js.map +1 -1
- package/build-module/index.js +0 -1
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +2 -1
- package/build-module/index.native.js.map +1 -1
- package/build-module/input-control/index.js +24 -3
- package/build-module/input-control/index.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +42 -30
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/index.native.js +1 -1
- package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet-select-control/index.native.js +4 -2
- package/build-module/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build-module/mobile/html-text-input/index.native.js +20 -9
- package/build-module/mobile/html-text-input/index.native.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/index.android.js +21 -5
- package/build-module/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +42 -25
- package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build-module/navigation/styles/navigation-styles.js +13 -13
- package/build-module/navigation/styles/navigation-styles.js.map +1 -1
- package/build-module/notice/index.native.js +45 -41
- package/build-module/notice/index.native.js.map +1 -1
- package/build-module/notice/list.native.js +28 -46
- package/build-module/notice/list.native.js.map +1 -1
- package/build-module/palette-edit/index.js +37 -7
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/popover/index.js +225 -325
- package/build-module/popover/index.js.map +1 -1
- package/build-module/resizable-box/resize-tooltip/utils.js +4 -5
- package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build-module/sandbox/index.js +2 -2
- package/build-module/sandbox/index.js.map +1 -1
- package/build-module/sandbox/index.native.js +1 -1
- package/build-module/sandbox/index.native.js.map +1 -1
- package/build-module/select-control/index.js +29 -3
- package/build-module/select-control/index.js.map +1 -1
- package/build-module/select-control/styles/select-control-styles.js +17 -14
- package/build-module/select-control/styles/select-control-styles.js.map +1 -1
- package/build-module/surface/styles.js +8 -8
- package/build-module/surface/styles.js.map +1 -1
- package/build-module/text/hook.js +5 -5
- package/build-module/text/hook.js.map +1 -1
- package/build-module/text/styles/text-mixins.native.js +2 -2
- package/build-module/text/styles/text-mixins.native.js.map +1 -1
- package/build-module/text/styles.js +7 -7
- package/build-module/text/styles.js.map +1 -1
- package/build-module/text-control/index.js +35 -27
- package/build-module/text-control/index.js.map +1 -1
- package/build-module/text-control/types.js +2 -0
- package/build-module/text-control/types.js.map +1 -0
- package/build-module/toggle-group-control/toggle-group-control/component.js +2 -3
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js +1 -5
- package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/component.js +51 -36
- package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build-module/tooltip/index.js +2 -2
- package/build-module/tooltip/index.js.map +1 -1
- package/build-module/ui/spinner/component.js +1 -1
- package/build-module/ui/spinner/component.js.map +1 -1
- package/build-module/unit-control/index.js +3 -3
- package/build-module/unit-control/index.js.map +1 -1
- package/build-module/unit-control/styles/unit-control-styles.js +11 -20
- package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build-module/unit-control/utils.js.map +1 -1
- package/build-module/utils/colors-values.js +19 -23
- package/build-module/utils/colors-values.js.map +1 -1
- package/build-style/style-rtl.css +55 -170
- package/build-style/style.css +51 -170
- 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 +3 -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-linked-button/hook.d.ts.map +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 +3 -1
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts.map +1 -1
- package/build-types/border-box-control/styles.d.ts +2 -2
- package/build-types/border-box-control/styles.d.ts.map +1 -1
- package/build-types/border-box-control/types.d.ts +40 -13
- package/build-types/border-box-control/types.d.ts.map +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 +2 -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.map +1 -1
- package/build-types/border-control/border-control-dropdown/hook.d.ts +1 -0
- package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
- package/build-types/border-control/styles.d.ts +2 -1
- package/build-types/border-control/styles.d.ts.map +1 -1
- package/build-types/border-control/types.d.ts +18 -6
- package/build-types/border-control/types.d.ts.map +1 -1
- package/build-types/button/index.d.ts.map +1 -1
- package/build-types/button-group/index.d.ts +25 -0
- package/build-types/button-group/index.d.ts.map +1 -0
- package/build-types/button-group/stories/index.d.ts +12 -0
- package/build-types/button-group/stories/index.d.ts.map +1 -0
- package/build-types/button-group/types.d.ts +11 -0
- package/build-types/button-group/types.d.ts.map +1 -0
- package/build-types/checkbox-control/index.d.ts +26 -0
- package/build-types/checkbox-control/index.d.ts.map +1 -0
- package/build-types/checkbox-control/stories/index.d.ts +13 -0
- package/build-types/checkbox-control/stories/index.d.ts.map +1 -0
- package/build-types/checkbox-control/types.d.ts +35 -0
- package/build-types/checkbox-control/types.d.ts.map +1 -0
- package/build-types/circular-option-picker/index.d.ts.map +1 -1
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +3 -3
- package/build-types/date-time/date.d.ts +24 -0
- package/build-types/date-time/date.d.ts.map +1 -0
- package/build-types/date-time/index.d.ts +35 -0
- package/build-types/date-time/index.d.ts.map +1 -0
- package/build-types/date-time/stories/date.d.ts +14 -0
- package/build-types/date-time/stories/date.d.ts.map +1 -0
- package/build-types/date-time/stories/index.d.ts +14 -0
- package/build-types/date-time/stories/index.d.ts.map +1 -0
- package/build-types/date-time/stories/time.d.ts +12 -0
- package/build-types/date-time/stories/time.d.ts.map +1 -0
- package/build-types/date-time/stories/utils.d.ts +3 -0
- package/build-types/date-time/stories/utils.d.ts.map +1 -0
- package/build-types/date-time/test/date.d.ts +2 -0
- package/build-types/date-time/test/date.d.ts.map +1 -0
- package/build-types/date-time/test/time.d.ts +2 -0
- package/build-types/date-time/test/time.d.ts.map +1 -0
- package/build-types/date-time/test/utils.d.ts +2 -0
- package/build-types/date-time/test/utils.d.ts.map +1 -0
- package/build-types/date-time/time.d.ts +25 -0
- package/build-types/date-time/time.d.ts.map +1 -0
- package/build-types/date-time/timezone.d.ts +8 -0
- package/build-types/date-time/timezone.d.ts.map +1 -0
- package/build-types/date-time/types.d.ts +91 -0
- package/build-types/date-time/types.d.ts.map +1 -0
- package/build-types/date-time/utils.d.ts +15 -0
- package/build-types/date-time/utils.d.ts.map +1 -0
- package/build-types/disabled/index.d.ts.map +1 -1
- package/build-types/dropdown/index.d.ts.map +1 -1
- package/build-types/input-control/index.d.ts +23 -3
- package/build-types/input-control/index.d.ts.map +1 -1
- package/build-types/input-control/input-field.d.ts +1 -1
- package/build-types/input-control/input-field.d.ts.map +1 -1
- package/build-types/input-control/stories/index.d.ts +5 -5
- package/build-types/input-control/stories/index.d.ts.map +1 -1
- package/build-types/input-control/styles/input-control-styles.d.ts +1 -0
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +79 -3
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
- package/build-types/popover/index.d.ts +5 -8
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/resizable-box/index.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/utils.d.ts.map +1 -1
- package/build-types/select-control/index.d.ts +30 -26
- package/build-types/select-control/index.d.ts.map +1 -1
- package/build-types/select-control/stories/index.d.ts +23 -0
- package/build-types/select-control/stories/index.d.ts.map +1 -0
- package/build-types/select-control/styles/select-control-styles.d.ts +3 -4
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/select-control/test/select-control.d.ts +2 -0
- package/build-types/select-control/test/select-control.d.ts.map +1 -0
- package/build-types/select-control/types.d.ts +52 -1
- package/build-types/select-control/types.d.ts.map +1 -1
- package/build-types/text-control/index.d.ts +2 -2
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
- package/build-types/tools-panel/types.d.ts +0 -1
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +2 -2
- package/build-types/unit-control/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/test/index.d.ts +2 -0
- package/build-types/unit-control/test/index.d.ts.map +1 -0
- package/build-types/unit-control/test/utils.d.ts +2 -0
- package/build-types/unit-control/test/utils.d.ts.map +1 -0
- package/build-types/unit-control/types.d.ts +1 -1
- package/build-types/unit-control/types.d.ts.map +1 -1
- package/build-types/unit-control/utils.d.ts +3 -3
- package/build-types/unit-control/utils.d.ts.map +1 -1
- package/build-types/utils/colors-values.d.ts +6 -146
- package/build-types/utils/colors-values.d.ts.map +1 -1
- package/package.json +19 -19
- package/src/alignment-matrix-control/styles/alignment-matrix-control-styles.js +5 -3
- package/src/autocomplete/style.scss +1 -1
- package/src/border-box-control/border-box-control/README.md +10 -14
- package/src/border-box-control/border-box-control/component.tsx +21 -4
- package/src/border-box-control/border-box-control-linked-button/hook.ts +10 -6
- package/src/border-box-control/border-box-control-split-controls/component.tsx +24 -7
- package/src/border-box-control/border-box-control-visualizer/hook.ts +11 -6
- package/src/border-box-control/stories/index.js +1 -0
- package/src/border-box-control/styles.ts +15 -8
- package/src/border-box-control/types.ts +40 -14
- package/src/border-control/border-control/README.md +0 -7
- package/src/border-control/border-control/component.tsx +4 -2
- package/src/border-control/border-control/hook.ts +5 -2
- package/src/border-control/border-control-dropdown/component.tsx +18 -11
- package/src/border-control/border-control-dropdown/hook.ts +7 -5
- package/src/border-control/stories/index.js +1 -0
- package/src/border-control/styles.ts +82 -22
- package/src/border-control/types.ts +18 -6
- package/src/box-control/README.md +0 -74
- package/src/box-control/index.js +0 -15
- package/src/box-control/stories/index.js +0 -29
- package/src/box-control/utils.js +0 -7
- package/src/button/index.js +2 -4
- package/src/button/index.native.js +33 -18
- package/src/button/test/index.js +16 -1
- package/src/button-group/index.tsx +47 -0
- package/src/button-group/stories/index.tsx +41 -0
- package/src/button-group/types.ts +11 -0
- package/src/checkbox-control/README.md +10 -8
- package/src/checkbox-control/{index.js → index.tsx} +49 -14
- package/src/checkbox-control/stories/{index.js → index.tsx} +49 -27
- package/src/checkbox-control/types.ts +36 -0
- package/src/circular-option-picker/index.js +1 -2
- package/src/circular-option-picker/style.scss +1 -0
- package/src/color-palette/README.md +0 -1
- package/src/color-palette/index.js +6 -13
- package/src/color-palette/style.scss +3 -18
- package/src/color-palette/test/__snapshots__/index.js.snap +2 -3
- package/src/confirm-dialog/stories/index.js +87 -99
- package/src/date-time/README.md +13 -10
- package/src/date-time/{date.js → date.tsx} +49 -20
- package/src/date-time/{index.js → index.tsx} +31 -5
- package/src/date-time/stories/date.tsx +73 -0
- package/src/date-time/stories/index.tsx +75 -0
- package/src/date-time/stories/time.tsx +51 -0
- package/src/date-time/stories/utils.ts +9 -0
- package/src/date-time/test/date.tsx +127 -0
- package/src/date-time/test/{time.js → time.tsx} +34 -19
- package/src/date-time/test/{utils.js → utils.ts} +1 -1
- package/src/date-time/{time.js → time.tsx} +57 -46
- package/src/date-time/{timezone.js → timezone.tsx} +4 -3
- package/src/date-time/types.ts +106 -0
- package/src/date-time/utils.ts +20 -0
- package/src/dimension-control/test/__snapshots__/index.test.js.snap +4 -4
- package/src/disabled/index.js +5 -90
- package/src/draggable/index.native.js +215 -0
- package/src/draggable/style.native.scss +3 -0
- package/src/dropdown/index.js +9 -4
- package/src/dropdown/style.scss +1 -1
- package/src/focal-point-picker/index.native.js +3 -3
- package/src/form-file-upload/test/index.js +20 -13
- package/src/heading/hook.ts +1 -1
- package/src/heading/test/__snapshots__/index.js.snap +3 -3
- package/src/index.js +0 -1
- package/src/index.native.js +1 -0
- package/src/input-control/README.md +3 -3
- package/src/input-control/index.tsx +23 -3
- package/src/input-control/stories/index.tsx +63 -0
- package/src/input-control/styles/input-control-styles.tsx +20 -7
- package/src/input-control/types.ts +79 -2
- package/src/item-group/stories/index.js +22 -18
- package/src/menu-item/style.scss +10 -0
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/test/navigation-container.native.js +9 -2
- package/src/mobile/bottom-sheet/index.native.js +1 -1
- package/src/mobile/bottom-sheet-select-control/index.native.js +8 -2
- package/src/mobile/html-text-input/index.native.js +45 -29
- package/src/mobile/html-text-input/style.android.scss +2 -15
- package/src/mobile/html-text-input/style.ios.scss +2 -15
- package/src/mobile/html-text-input/{style-common.native.scss → style.scss} +16 -0
- package/src/mobile/keyboard-aware-flat-list/index.android.js +15 -5
- package/src/mobile/keyboard-aware-flat-list/index.ios.js +75 -46
- package/src/mobile/link-settings/test/link-settings-navigation.native.js +9 -1
- package/src/navigation/styles/navigation-styles.js +5 -5
- package/src/navigator/stories/index.js +16 -10
- package/src/notice/index.native.js +44 -54
- package/src/notice/list.native.js +27 -51
- package/src/notice/style.native.scss +1 -0
- package/src/palette-edit/index.js +37 -9
- package/src/palette-edit/style.scss +0 -7
- package/src/palette-edit/test/index.js +63 -0
- package/src/panel/README.md +1 -1
- package/src/placeholder/test/index.js +7 -0
- package/src/popover/README.md +7 -9
- package/src/popover/index.js +242 -417
- package/src/popover/style.scss +20 -190
- package/src/popover/test/__snapshots__/index.js.snap +6 -18
- package/src/query-controls/README.md +2 -2
- package/src/resizable-box/resize-tooltip/utils.ts +4 -5
- package/src/sandbox/index.js +2 -2
- package/src/sandbox/index.native.js +1 -1
- package/src/select-control/README.md +2 -2
- package/src/select-control/index.tsx +30 -29
- package/src/select-control/stories/index.tsx +90 -0
- package/src/select-control/styles/select-control-styles.ts +16 -12
- package/src/select-control/test/{select-control.js → select-control.tsx} +2 -2
- package/src/select-control/types.ts +66 -1
- package/src/surface/styles.js +1 -1
- package/src/tab-panel/style.scss +1 -1
- package/src/text/hook.js +1 -1
- package/src/text/styles/text-mixins.native.js +2 -2
- package/src/text/styles.js +1 -1
- package/src/text/test/__snapshots__/{index.js.snap → index.tsx.snap} +16 -0
- package/src/text/test/{index.js → index.tsx} +12 -6
- package/src/text-control/index.tsx +84 -0
- package/src/text-control/stories/index.tsx +66 -0
- package/src/text-control/types.ts +29 -0
- package/src/toggle-group-control/test/__snapshots__/index.js.snap +4 -10
- package/src/toggle-group-control/toggle-group-control/component.tsx +7 -3
- package/src/toggle-group-control/toggle-group-control-option-icon/component.tsx +1 -5
- package/src/toolbar-group/style.scss +20 -0
- package/src/tools-panel/test/__snapshots__/index.js.snap +2 -2
- package/src/tools-panel/test/index.js +71 -18
- package/src/tools-panel/tools-panel-header/component.tsx +75 -33
- package/src/tools-panel/types.ts +0 -1
- package/src/tooltip/index.js +8 -2
- package/src/tooltip/style.scss +2 -4
- package/src/tooltip/test/index.js +6 -0
- package/src/tooltip/test/index.native.js +1 -1
- package/src/ui/spinner/component.js +1 -1
- package/src/ui/spinner/test/__snapshots__/index.js.snap +3 -3
- package/src/unit-control/index.tsx +2 -5
- package/src/unit-control/styles/unit-control-styles.ts +3 -13
- package/src/unit-control/test/__snapshots__/index.tsx.snap +33 -0
- package/src/unit-control/test/{index.js → index.tsx} +295 -166
- package/src/unit-control/test/{utils.js → utils.ts} +38 -19
- package/src/unit-control/types.ts +4 -1
- package/src/unit-control/utils.ts +5 -3
- package/src/utils/colors-values.js +18 -22
- package/tsconfig.json +14 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/build/box-control/visualizer.js +0 -165
- package/build/box-control/visualizer.js.map +0 -1
- package/build/flyout/context.js +0 -23
- package/build/flyout/context.js.map +0 -1
- package/build/flyout/flyout/component.js +0 -106
- package/build/flyout/flyout/component.js.map +0 -1
- package/build/flyout/flyout/hook.js +0 -53
- package/build/flyout/flyout/hook.js.map +0 -1
- package/build/flyout/flyout/index.js +0 -24
- package/build/flyout/flyout/index.js.map +0 -1
- package/build/flyout/flyout-content/component.js +0 -65
- package/build/flyout/flyout-content/component.js.map +0 -1
- package/build/flyout/flyout-content/index.js +0 -16
- package/build/flyout/flyout-content/index.js.map +0 -1
- package/build/flyout/index.js +0 -16
- package/build/flyout/index.js.map +0 -1
- package/build/flyout/styles.js +0 -46
- package/build/flyout/styles.js.map +0 -1
- package/build/flyout/utils.js +0 -36
- package/build/flyout/utils.js.map +0 -1
- package/build/mobile/html-text-input/container.android.js +0 -41
- package/build/mobile/html-text-input/container.android.js.map +0 -1
- package/build/mobile/html-text-input/container.ios.js +0 -60
- package/build/mobile/html-text-input/container.ios.js.map +0 -1
- package/build/popover/utils.js +0 -322
- package/build/popover/utils.js.map +0 -1
- package/build-module/box-control/visualizer.js +0 -154
- package/build-module/box-control/visualizer.js.map +0 -1
- package/build-module/flyout/context.js +0 -11
- package/build-module/flyout/context.js.map +0 -1
- package/build-module/flyout/flyout/component.js +0 -89
- package/build-module/flyout/flyout/component.js.map +0 -1
- package/build-module/flyout/flyout/hook.js +0 -44
- package/build-module/flyout/flyout/hook.js.map +0 -1
- package/build-module/flyout/flyout/index.js +0 -3
- package/build-module/flyout/flyout/index.js.map +0 -1
- package/build-module/flyout/flyout-content/component.js +0 -51
- package/build-module/flyout/flyout-content/component.js.map +0 -1
- package/build-module/flyout/flyout-content/index.js +0 -2
- package/build-module/flyout/flyout-content/index.js.map +0 -1
- package/build-module/flyout/index.js +0 -2
- package/build-module/flyout/index.js.map +0 -1
- package/build-module/flyout/styles.js +0 -27
- package/build-module/flyout/styles.js.map +0 -1
- package/build-module/flyout/utils.js +0 -25
- package/build-module/flyout/utils.js.map +0 -1
- package/build-module/mobile/html-text-input/container.android.js +0 -29
- package/build-module/mobile/html-text-input/container.android.js.map +0 -1
- package/build-module/mobile/html-text-input/container.ios.js +0 -48
- package/build-module/mobile/html-text-input/container.ios.js.map +0 -1
- package/build-module/popover/utils.js +0 -308
- package/build-module/popover/utils.js.map +0 -1
- package/build-types/flyout/context.d.ts +0 -6
- package/build-types/flyout/context.d.ts.map +0 -1
- package/build-types/flyout/flyout/component.d.ts +0 -21
- package/build-types/flyout/flyout/component.d.ts.map +0 -1
- package/build-types/flyout/flyout/hook.d.ts +0 -270
- package/build-types/flyout/flyout/hook.d.ts.map +0 -1
- package/build-types/flyout/flyout/index.d.ts +0 -3
- package/build-types/flyout/flyout/index.d.ts.map +0 -1
- package/build-types/flyout/flyout-content/component.d.ts +0 -3
- package/build-types/flyout/flyout-content/component.d.ts.map +0 -1
- package/build-types/flyout/flyout-content/index.d.ts +0 -2
- package/build-types/flyout/flyout-content/index.d.ts.map +0 -1
- package/build-types/flyout/index.d.ts +0 -2
- package/build-types/flyout/index.d.ts.map +0 -1
- package/build-types/flyout/styles.d.ts +0 -22
- package/build-types/flyout/styles.d.ts.map +0 -1
- package/build-types/flyout/types.d.ts +0 -80
- package/build-types/flyout/types.d.ts.map +0 -1
- package/build-types/flyout/utils.d.ts +0 -8
- package/build-types/flyout/utils.d.ts.map +0 -1
- package/build-types/popover/utils.d.ts +0 -70
- package/build-types/popover/utils.d.ts.map +0 -1
- package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts +0 -19
- package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts.map +0 -1
- package/src/box-control/visualizer.js +0 -116
- package/src/button-group/index.js +0 -17
- package/src/button-group/stories/index.js +0 -21
- package/src/date-time/stories/date.js +0 -17
- package/src/date-time/stories/index.js +0 -72
- package/src/date-time/stories/time.js +0 -32
- package/src/date-time/test/date.js +0 -97
- package/src/date-time/utils.js +0 -18
- package/src/flyout/context.js +0 -10
- package/src/flyout/flyout/README.md +0 -98
- package/src/flyout/flyout/component.js +0 -111
- package/src/flyout/flyout/hook.js +0 -45
- package/src/flyout/flyout/index.js +0 -2
- package/src/flyout/flyout-content/component.js +0 -53
- package/src/flyout/flyout-content/index.js +0 -1
- package/src/flyout/index.js +0 -1
- package/src/flyout/stories/index.js +0 -24
- package/src/flyout/styles.ts +0 -41
- package/src/flyout/test/__snapshots__/index.js.snap +0 -186
- package/src/flyout/test/index.js +0 -103
- package/src/flyout/types.ts +0 -84
- package/src/flyout/utils.js +0 -23
- package/src/input-control/stories/index.js +0 -71
- package/src/mobile/html-text-input/container.android.js +0 -23
- package/src/mobile/html-text-input/container.ios.js +0 -50
- package/src/popover/test/utils.js +0 -304
- package/src/popover/utils.js +0 -396
- package/src/select-control/stories/index.js +0 -104
- package/src/text-control/index.js +0 -72
- package/src/text-control/stories/index.js +0 -46
|
@@ -6,19 +6,19 @@ import { createElement } from "@wordpress/element";
|
|
|
6
6
|
* External dependencies
|
|
7
7
|
*/
|
|
8
8
|
import classnames from 'classnames';
|
|
9
|
+
import { useFloating, flip, shift, autoUpdate, arrow, offset as offsetMiddleware, limitShift, size } from '@floating-ui/react-dom';
|
|
9
10
|
/**
|
|
10
11
|
* WordPress dependencies
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
|
-
import { useRef,
|
|
14
|
-
import {
|
|
15
|
-
import { useViewportMatch, useResizeObserver, useMergeRefs, __experimentalUseDialog as useDialog } from '@wordpress/compose';
|
|
14
|
+
import { useRef, useLayoutEffect, forwardRef, createContext, useContext, useMemo } from '@wordpress/element';
|
|
15
|
+
import { useViewportMatch, useMergeRefs, __experimentalUseDialog as useDialog } from '@wordpress/compose';
|
|
16
16
|
import { close } from '@wordpress/icons';
|
|
17
|
+
import deprecated from '@wordpress/deprecated';
|
|
17
18
|
/**
|
|
18
19
|
* Internal dependencies
|
|
19
20
|
*/
|
|
20
21
|
|
|
21
|
-
import { computePopoverPosition, offsetIframe } from './utils';
|
|
22
22
|
import Button from '../button';
|
|
23
23
|
import ScrollLock from '../scroll-lock';
|
|
24
24
|
import { Slot, Fill, useSlot } from '../slot-fill';
|
|
@@ -32,368 +32,167 @@ import { getAnimateClassName } from '../animate';
|
|
|
32
32
|
const SLOT_NAME = 'Popover';
|
|
33
33
|
const slotNameContext = createContext();
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
let shouldAnchorIncludePadding = arguments.length > 4 ? arguments[4] : undefined;
|
|
38
|
-
let container = arguments.length > 5 ? arguments[5] : undefined;
|
|
35
|
+
const positionToPlacement = position => {
|
|
36
|
+
const [x, y, z] = position.split(' ');
|
|
39
37
|
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (getAnchorRect) {
|
|
45
|
-
if (!anchorRefFallback.current) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const rect = getAnchorRect(anchorRefFallback.current);
|
|
50
|
-
return offsetIframe(rect, rect.ownerDocument || anchorRefFallback.current.ownerDocument, container);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (anchorRef !== false) {
|
|
54
|
-
if (!anchorRef || !window.Range || !window.Element || !window.DOMRect) {
|
|
55
|
-
return;
|
|
56
|
-
} // Duck-type to check if `anchorRef` is an instance of Range
|
|
57
|
-
// `anchorRef instanceof window.Range` checks will break across document boundaries
|
|
58
|
-
// such as in an iframe.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (typeof (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.cloneRange) === 'function') {
|
|
62
|
-
return offsetIframe(getRectangleFromRange(anchorRef), anchorRef.endContainer.ownerDocument, container);
|
|
63
|
-
} // Duck-type to check if `anchorRef` is an instance of Element
|
|
64
|
-
// `anchorRef instanceof window.Element` checks will break across document boundaries
|
|
65
|
-
// such as in an iframe.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (typeof (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.getBoundingClientRect) === 'function') {
|
|
69
|
-
const rect = offsetIframe(anchorRef.getBoundingClientRect(), anchorRef.ownerDocument, container);
|
|
70
|
-
|
|
71
|
-
if (shouldAnchorIncludePadding) {
|
|
72
|
-
return rect;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return withoutPadding(rect, anchorRef);
|
|
76
|
-
}
|
|
38
|
+
if (['top', 'bottom'].includes(x)) {
|
|
39
|
+
let suffix = '';
|
|
77
40
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const topRect = top.getBoundingClientRect();
|
|
83
|
-
const bottomRect = bottom.getBoundingClientRect();
|
|
84
|
-
const rect = offsetIframe(new window.DOMRect(topRect.left, topRect.top, topRect.width, bottomRect.bottom - topRect.top), top.ownerDocument, container);
|
|
85
|
-
|
|
86
|
-
if (shouldAnchorIncludePadding) {
|
|
87
|
-
return rect;
|
|
41
|
+
if (!!z && z === 'left' || y === 'right') {
|
|
42
|
+
suffix = '-start';
|
|
43
|
+
} else if (!!z && z === 'right' || y === 'left') {
|
|
44
|
+
suffix = '-end';
|
|
88
45
|
}
|
|
89
46
|
|
|
90
|
-
return
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (!anchorRefFallback.current) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const {
|
|
98
|
-
parentNode
|
|
99
|
-
} = anchorRefFallback.current;
|
|
100
|
-
const rect = offsetIframe(parentNode.getBoundingClientRect(), parentNode.ownerDocument, container);
|
|
101
|
-
|
|
102
|
-
if (shouldAnchorIncludePadding) {
|
|
103
|
-
return rect;
|
|
47
|
+
return x + suffix;
|
|
104
48
|
}
|
|
105
49
|
|
|
106
|
-
return
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function getComputedStyle(node) {
|
|
110
|
-
return node.ownerDocument.defaultView.getComputedStyle(node);
|
|
111
|
-
}
|
|
50
|
+
return y;
|
|
51
|
+
};
|
|
112
52
|
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
paddingBottom,
|
|
117
|
-
paddingLeft,
|
|
118
|
-
paddingRight
|
|
119
|
-
} = getComputedStyle(element);
|
|
120
|
-
const top = paddingTop ? parseInt(paddingTop, 10) : 0;
|
|
121
|
-
const bottom = paddingBottom ? parseInt(paddingBottom, 10) : 0;
|
|
122
|
-
const left = paddingLeft ? parseInt(paddingLeft, 10) : 0;
|
|
123
|
-
const right = paddingRight ? parseInt(paddingRight, 10) : 0;
|
|
124
|
-
return {
|
|
125
|
-
x: rect.left + left,
|
|
126
|
-
y: rect.top + top,
|
|
127
|
-
width: rect.width - left - right,
|
|
128
|
-
height: rect.height - top - bottom,
|
|
129
|
-
left: rect.left + left,
|
|
130
|
-
right: rect.right - right,
|
|
131
|
-
top: rect.top + top,
|
|
132
|
-
bottom: rect.bottom - bottom
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Sets or removes an element attribute.
|
|
137
|
-
*
|
|
138
|
-
* @param {Element} element The element to modify.
|
|
139
|
-
* @param {string} name The attribute name to set or remove.
|
|
140
|
-
* @param {?string} value The value to set. A falsy value will remove the
|
|
141
|
-
* attribute.
|
|
142
|
-
*/
|
|
53
|
+
const placementToAnimationOrigin = placement => {
|
|
54
|
+
const [a, b] = placement.split('-');
|
|
55
|
+
let x, y;
|
|
143
56
|
|
|
57
|
+
if (a === 'top' || a === 'bottom') {
|
|
58
|
+
x = a === 'top' ? 'bottom' : 'top';
|
|
59
|
+
y = 'middle';
|
|
144
60
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (
|
|
148
|
-
|
|
61
|
+
if (b === 'start') {
|
|
62
|
+
y = 'left';
|
|
63
|
+
} else if (b === 'end') {
|
|
64
|
+
y = 'right';
|
|
149
65
|
}
|
|
150
|
-
} else if (element.getAttribute(name) !== value) {
|
|
151
|
-
element.setAttribute(name, value);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Sets or removes an element style property.
|
|
156
|
-
*
|
|
157
|
-
* @param {Element} element The element to modify.
|
|
158
|
-
* @param {string} property The property to set or remove.
|
|
159
|
-
* @param {?string} value The value to set. A falsy value will remove the
|
|
160
|
-
* property.
|
|
161
|
-
*/
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
function setStyle(element, property) {
|
|
165
|
-
let value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
166
|
-
|
|
167
|
-
if (element.style[property] !== value) {
|
|
168
|
-
element.style[property] = value;
|
|
169
66
|
}
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Sets or removes an element class.
|
|
173
|
-
*
|
|
174
|
-
* @param {Element} element The element to modify.
|
|
175
|
-
* @param {string} name The class to set or remove.
|
|
176
|
-
* @param {boolean} toggle True to set the class, false to remove.
|
|
177
|
-
*/
|
|
178
67
|
|
|
68
|
+
if (a === 'left' || a === 'right') {
|
|
69
|
+
x = 'center';
|
|
70
|
+
y = a === 'left' ? 'right' : 'left';
|
|
179
71
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (
|
|
183
|
-
|
|
72
|
+
if (b === 'start') {
|
|
73
|
+
x = 'top';
|
|
74
|
+
} else if (b === 'end') {
|
|
75
|
+
x = 'bottom';
|
|
184
76
|
}
|
|
185
|
-
} else if (element.classList.contains(name)) {
|
|
186
|
-
element.classList.remove(name);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function getAnchorDocument(anchor) {
|
|
191
|
-
if (!anchor) {
|
|
192
|
-
return;
|
|
193
77
|
}
|
|
194
78
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (anchor.top) {
|
|
200
|
-
return anchor.top.ownerDocument;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return anchor.ownerDocument;
|
|
204
|
-
}
|
|
79
|
+
return x + ' ' + y;
|
|
80
|
+
};
|
|
205
81
|
|
|
206
82
|
const Popover = (_ref, ref) => {
|
|
207
83
|
let {
|
|
84
|
+
range,
|
|
85
|
+
animate = true,
|
|
208
86
|
headerTitle,
|
|
209
87
|
onClose,
|
|
210
88
|
children,
|
|
211
89
|
className,
|
|
212
90
|
noArrow = true,
|
|
213
91
|
isAlternate,
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
/* eslint-disable no-unused-vars */
|
|
218
|
-
position = 'bottom right',
|
|
219
|
-
range,
|
|
92
|
+
position,
|
|
93
|
+
placement = 'bottom-start',
|
|
94
|
+
offset,
|
|
220
95
|
focusOnMount = 'firstElement',
|
|
221
96
|
anchorRef,
|
|
222
|
-
shouldAnchorIncludePadding,
|
|
223
97
|
anchorRect,
|
|
224
98
|
getAnchorRect,
|
|
225
99
|
expandOnMobile,
|
|
226
|
-
animate = true,
|
|
227
100
|
onFocusOutside,
|
|
228
|
-
__unstableStickyBoundaryElement,
|
|
229
101
|
__unstableSlotName = SLOT_NAME,
|
|
230
102
|
__unstableObserveElement,
|
|
231
|
-
__unstableBoundaryParent,
|
|
232
103
|
__unstableForcePosition,
|
|
233
|
-
__unstableForceXAlignment,
|
|
234
|
-
__unstableEditorCanvasWrapper,
|
|
235
|
-
|
|
236
|
-
/* eslint-enable no-unused-vars */
|
|
237
104
|
...contentProps
|
|
238
105
|
} = _ref;
|
|
239
|
-
const anchorRefFallback = useRef(null);
|
|
240
|
-
const contentRef = useRef(null);
|
|
241
|
-
const containerRef = useRef();
|
|
242
|
-
const isMobileViewport = useViewportMatch('medium', '<');
|
|
243
|
-
const [animateOrigin, setAnimateOrigin] = useState();
|
|
244
106
|
|
|
245
|
-
|
|
107
|
+
if (range) {
|
|
108
|
+
deprecated('range prop in Popover component', {
|
|
109
|
+
since: '6.1',
|
|
110
|
+
version: '6.3'
|
|
111
|
+
});
|
|
112
|
+
}
|
|
246
113
|
|
|
247
|
-
const
|
|
114
|
+
const arrowRef = useRef(null);
|
|
115
|
+
const isMobileViewport = useViewportMatch('medium', '<');
|
|
248
116
|
const isExpanded = expandOnMobile && isMobileViewport;
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
117
|
+
const hasArrow = !isExpanded && !noArrow;
|
|
118
|
+
const usedPlacement = position ? positionToPlacement(position) : placement;
|
|
119
|
+
/**
|
|
120
|
+
* Offsets the the position of the popover when the anchor is inside an iframe.
|
|
121
|
+
*/
|
|
122
|
+
|
|
123
|
+
const frameOffset = useMemo(() => {
|
|
124
|
+
let ownerDocument = document;
|
|
125
|
+
|
|
126
|
+
if (anchorRef !== null && anchorRef !== void 0 && anchorRef.top) {
|
|
127
|
+
ownerDocument = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.top.ownerDocument;
|
|
128
|
+
} else if (anchorRef !== null && anchorRef !== void 0 && anchorRef.startContainer) {
|
|
129
|
+
ownerDocument = anchorRef.startContainer.ownerDocument;
|
|
130
|
+
} else if (anchorRef !== null && anchorRef !== void 0 && anchorRef.current) {
|
|
131
|
+
ownerDocument = anchorRef.current.ownerDocument;
|
|
132
|
+
} else if (anchorRef) {
|
|
133
|
+
// This one should be deprecated.
|
|
134
|
+
ownerDocument = anchorRef.ownerDocument;
|
|
135
|
+
} else if (anchorRect && anchorRect !== null && anchorRect !== void 0 && anchorRect.ownerDocument) {
|
|
136
|
+
ownerDocument = anchorRect.ownerDocument;
|
|
137
|
+
} else if (getAnchorRect) {
|
|
138
|
+
var _getAnchorRect$ownerD, _getAnchorRect;
|
|
139
|
+
|
|
140
|
+
ownerDocument = (_getAnchorRect$ownerD = (_getAnchorRect = getAnchorRect()) === null || _getAnchorRect === void 0 ? void 0 : _getAnchorRect.ownerDocument) !== null && _getAnchorRect$ownerD !== void 0 ? _getAnchorRect$ownerD : document;
|
|
262
141
|
}
|
|
263
142
|
|
|
264
|
-
const refresh = () => {
|
|
265
|
-
if (!containerRef.current || !contentRef.current) {
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
let anchor = computeAnchorRect(anchorRefFallback, anchorRect, getAnchorRect, anchorRef, shouldAnchorIncludePadding, containerRef.current);
|
|
270
|
-
|
|
271
|
-
if (!anchor) {
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
const {
|
|
276
|
-
offsetParent,
|
|
277
|
-
ownerDocument
|
|
278
|
-
} = containerRef.current;
|
|
279
|
-
let relativeOffsetTop = 0; // If there is a positioned ancestor element that is not the body,
|
|
280
|
-
// subtract the position from the anchor rect. If the position of
|
|
281
|
-
// the popover is fixed, the offset parent is null or the body
|
|
282
|
-
// element, in which case the position is relative to the viewport.
|
|
283
|
-
// See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
|
|
284
|
-
|
|
285
|
-
if (offsetParent && offsetParent !== ownerDocument.body) {
|
|
286
|
-
const offsetParentRect = offsetParent.getBoundingClientRect();
|
|
287
|
-
relativeOffsetTop = offsetParentRect.top;
|
|
288
|
-
anchor = new window.DOMRect(anchor.left - offsetParentRect.left, anchor.top - offsetParentRect.top, anchor.width, anchor.height);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
let boundaryElement;
|
|
292
|
-
|
|
293
|
-
if (__unstableBoundaryParent) {
|
|
294
|
-
boundaryElement = containerRef.current.parentElement;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
const usedContentSize = !contentSize.height ? contentRef.current.getBoundingClientRect() : contentSize;
|
|
298
|
-
const {
|
|
299
|
-
popoverTop,
|
|
300
|
-
popoverLeft,
|
|
301
|
-
xAxis,
|
|
302
|
-
yAxis,
|
|
303
|
-
contentHeight,
|
|
304
|
-
contentWidth
|
|
305
|
-
} = computePopoverPosition(anchor, usedContentSize, position, __unstableStickyBoundaryElement, containerRef.current, relativeOffsetTop, boundaryElement, __unstableForcePosition, __unstableForceXAlignment, __unstableEditorCanvasWrapper);
|
|
306
|
-
|
|
307
|
-
if (typeof popoverTop === 'number' && typeof popoverLeft === 'number') {
|
|
308
|
-
setStyle(containerRef.current, 'top', popoverTop + 'px');
|
|
309
|
-
setStyle(containerRef.current, 'left', popoverLeft + 'px');
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
setClass(containerRef.current, 'is-without-arrow', noArrow || xAxis === 'center' && yAxis === 'middle');
|
|
313
|
-
setClass(containerRef.current, 'is-alternate', isAlternate);
|
|
314
|
-
setAttribute(containerRef.current, 'data-x-axis', xAxis);
|
|
315
|
-
setAttribute(containerRef.current, 'data-y-axis', yAxis);
|
|
316
|
-
setStyle(contentRef.current, 'maxHeight', typeof contentHeight === 'number' ? contentHeight + 'px' : '');
|
|
317
|
-
setStyle(contentRef.current, 'maxWidth', typeof contentWidth === 'number' ? contentWidth + 'px' : ''); // Compute the animation position.
|
|
318
|
-
|
|
319
|
-
const yAxisMapping = {
|
|
320
|
-
top: 'bottom',
|
|
321
|
-
bottom: 'top'
|
|
322
|
-
};
|
|
323
|
-
const xAxisMapping = {
|
|
324
|
-
left: 'right',
|
|
325
|
-
right: 'left'
|
|
326
|
-
};
|
|
327
|
-
const animateYAxis = yAxisMapping[yAxis] || 'middle';
|
|
328
|
-
const animateXAxis = xAxisMapping[xAxis] || 'center';
|
|
329
|
-
setAnimateOrigin(animateXAxis + ' ' + animateYAxis);
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
refresh();
|
|
333
|
-
const {
|
|
334
|
-
ownerDocument
|
|
335
|
-
} = containerRef.current;
|
|
336
143
|
const {
|
|
337
144
|
defaultView
|
|
338
145
|
} = ownerDocument;
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
*/
|
|
346
|
-
|
|
347
|
-
const intervalHandle = defaultView.setInterval(refresh, 500);
|
|
348
|
-
let rafId;
|
|
349
|
-
|
|
350
|
-
const refreshOnAnimationFrame = () => {
|
|
351
|
-
defaultView.cancelAnimationFrame(rafId);
|
|
352
|
-
rafId = defaultView.requestAnimationFrame(refresh);
|
|
353
|
-
}; // Sometimes a click trigger a layout change that affects the popover
|
|
354
|
-
// position. This is an opportunity to immediately refresh rather than
|
|
355
|
-
// at the interval.
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
defaultView.addEventListener('click', refreshOnAnimationFrame);
|
|
359
|
-
defaultView.addEventListener('resize', refresh);
|
|
360
|
-
defaultView.addEventListener('scroll', refresh, true);
|
|
361
|
-
const anchorDocument = getAnchorDocument(anchorRef); // If the anchor is within an iframe, the popover position also needs
|
|
362
|
-
// to refrest when the iframe content is scrolled or resized.
|
|
363
|
-
|
|
364
|
-
if (anchorDocument && anchorDocument !== ownerDocument) {
|
|
365
|
-
anchorDocument.defaultView.addEventListener('resize', refresh);
|
|
366
|
-
anchorDocument.defaultView.addEventListener('scroll', refresh, true);
|
|
146
|
+
const {
|
|
147
|
+
frameElement
|
|
148
|
+
} = defaultView;
|
|
149
|
+
|
|
150
|
+
if (!frameElement || ownerDocument === document) {
|
|
151
|
+
return undefined;
|
|
367
152
|
}
|
|
368
153
|
|
|
369
|
-
|
|
154
|
+
const iframeRect = frameElement.getBoundingClientRect();
|
|
155
|
+
return {
|
|
156
|
+
name: 'iframeOffset',
|
|
157
|
+
|
|
158
|
+
fn(_ref2) {
|
|
159
|
+
let {
|
|
160
|
+
x,
|
|
161
|
+
y
|
|
162
|
+
} = _ref2;
|
|
163
|
+
return {
|
|
164
|
+
x: x + iframeRect.left,
|
|
165
|
+
y: y + iframeRect.top
|
|
166
|
+
};
|
|
167
|
+
}
|
|
370
168
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
169
|
+
};
|
|
170
|
+
}, [anchorRef, anchorRect, getAnchorRect]);
|
|
171
|
+
const middlewares = [frameOffset, offset ? offsetMiddleware(offset) : undefined, __unstableForcePosition ? undefined : flip(), __unstableForcePosition ? undefined : size({
|
|
172
|
+
apply(_ref3) {
|
|
173
|
+
let {
|
|
174
|
+
width,
|
|
175
|
+
height
|
|
176
|
+
} = _ref3;
|
|
177
|
+
if (!refs.floating.current) return;
|
|
178
|
+
Object.assign(refs.floating.current.firstChild.style, {
|
|
179
|
+
maxWidth: `${width}px`,
|
|
180
|
+
maxHeight: `${height}px`,
|
|
181
|
+
overflow: 'auto'
|
|
375
182
|
});
|
|
376
183
|
}
|
|
377
184
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
if (anchorDocument && anchorDocument !== ownerDocument) {
|
|
386
|
-
var _anchorDocument$defau, _anchorDocument$defau2;
|
|
185
|
+
}),, shift({
|
|
186
|
+
crossAxis: true,
|
|
187
|
+
limiter: limitShift()
|
|
188
|
+
}), hasArrow ? arrow({
|
|
189
|
+
element: arrowRef
|
|
190
|
+
}) : undefined].filter(m => !!m);
|
|
191
|
+
const anchorRefFallback = useRef(null);
|
|
387
192
|
|
|
388
|
-
|
|
389
|
-
(_anchorDocument$defau2 = anchorDocument.defaultView) === null || _anchorDocument$defau2 === void 0 ? void 0 : _anchorDocument$defau2.removeEventListener('scroll', refresh, true);
|
|
390
|
-
}
|
|
193
|
+
const slotName = useContext(slotNameContext) || __unstableSlotName;
|
|
391
194
|
|
|
392
|
-
|
|
393
|
-
observer.disconnect();
|
|
394
|
-
}
|
|
395
|
-
};
|
|
396
|
-
}, [isExpanded, anchorRect, getAnchorRect, anchorRef, shouldAnchorIncludePadding, position, contentSize, __unstableStickyBoundaryElement, __unstableObserveElement, __unstableBoundaryParent]);
|
|
195
|
+
const slot = useSlot(slotName);
|
|
397
196
|
|
|
398
197
|
const onDialogClose = (type, event) => {
|
|
399
198
|
// Ideally the popover should have just a single onClose prop and
|
|
@@ -410,12 +209,104 @@ const Popover = (_ref, ref) => {
|
|
|
410
209
|
__unstableOnClose: onDialogClose,
|
|
411
210
|
onClose: onDialogClose
|
|
412
211
|
});
|
|
413
|
-
const
|
|
212
|
+
const {
|
|
213
|
+
x,
|
|
214
|
+
y,
|
|
215
|
+
reference,
|
|
216
|
+
floating,
|
|
217
|
+
strategy,
|
|
218
|
+
refs,
|
|
219
|
+
update,
|
|
220
|
+
placement: placementData,
|
|
221
|
+
middlewareData: {
|
|
222
|
+
arrow: arrowData = {}
|
|
223
|
+
}
|
|
224
|
+
} = useFloating({
|
|
225
|
+
placement: usedPlacement,
|
|
226
|
+
middleware: middlewares
|
|
227
|
+
});
|
|
228
|
+
const staticSide = {
|
|
229
|
+
top: 'bottom',
|
|
230
|
+
right: 'left',
|
|
231
|
+
bottom: 'top',
|
|
232
|
+
left: 'right'
|
|
233
|
+
}[placementData.split('-')[0]];
|
|
234
|
+
const mergedRefs = useMergeRefs([floating, dialogRef, ref]); // Updates references
|
|
235
|
+
|
|
236
|
+
useLayoutEffect(() => {
|
|
237
|
+
// No ref or position have been passed
|
|
238
|
+
let usedRef;
|
|
239
|
+
|
|
240
|
+
if (anchorRef !== null && anchorRef !== void 0 && anchorRef.top) {
|
|
241
|
+
usedRef = {
|
|
242
|
+
getBoundingClientRect() {
|
|
243
|
+
const topRect = anchorRef.top.getBoundingClientRect();
|
|
244
|
+
const bottomRect = anchorRef.bottom.getBoundingClientRect();
|
|
245
|
+
return new window.DOMRect(topRect.x, topRect.y, topRect.width, bottomRect.bottom - topRect.top);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
};
|
|
249
|
+
} else if (anchorRef !== null && anchorRef !== void 0 && anchorRef.current) {
|
|
250
|
+
usedRef = anchorRef.current;
|
|
251
|
+
} else if (anchorRef) {
|
|
252
|
+
usedRef = anchorRef;
|
|
253
|
+
} else if (anchorRect) {
|
|
254
|
+
usedRef = {
|
|
255
|
+
getBoundingClientRect() {
|
|
256
|
+
return anchorRect;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
};
|
|
260
|
+
} else if (getAnchorRect) {
|
|
261
|
+
usedRef = {
|
|
262
|
+
getBoundingClientRect() {
|
|
263
|
+
var _rect$x, _rect$y, _rect$height, _rect$width;
|
|
264
|
+
|
|
265
|
+
const rect = getAnchorRect();
|
|
266
|
+
return { ...rect,
|
|
267
|
+
x: (_rect$x = rect.x) !== null && _rect$x !== void 0 ? _rect$x : rect.left,
|
|
268
|
+
y: (_rect$y = rect.y) !== null && _rect$y !== void 0 ? _rect$y : rect.top,
|
|
269
|
+
height: (_rect$height = rect.height) !== null && _rect$height !== void 0 ? _rect$height : rect.bottom - rect.top,
|
|
270
|
+
width: (_rect$width = rect.width) !== null && _rect$width !== void 0 ? _rect$width : rect.right - rect.left
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
};
|
|
275
|
+
} else if (anchorRefFallback.current) {
|
|
276
|
+
usedRef = anchorRefFallback.current;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (!usedRef) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
reference(usedRef);
|
|
284
|
+
|
|
285
|
+
if (!refs.floating.current) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return autoUpdate(usedRef, refs.floating.current, update);
|
|
290
|
+
}, [anchorRef, anchorRect, getAnchorRect]); // This is only needed for a smoth transition when moving blocks.
|
|
291
|
+
|
|
292
|
+
useLayoutEffect(() => {
|
|
293
|
+
if (!__unstableObserveElement) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const observer = new window.MutationObserver(update);
|
|
298
|
+
observer.observe(__unstableObserveElement, {
|
|
299
|
+
attributes: true
|
|
300
|
+
});
|
|
301
|
+
return () => {
|
|
302
|
+
observer.disconnect();
|
|
303
|
+
};
|
|
304
|
+
}, [__unstableObserveElement]);
|
|
414
305
|
/** @type {false | string} */
|
|
415
306
|
|
|
416
|
-
const animateClassName =
|
|
307
|
+
const animateClassName = !!animate && getAnimateClassName({
|
|
417
308
|
type: 'appear',
|
|
418
|
-
origin:
|
|
309
|
+
origin: placementToAnimationOrigin(placementData)
|
|
419
310
|
}); // Disable reason: We care to capture the _bubbled_ events from inputs
|
|
420
311
|
// within popover as inferring close intent.
|
|
421
312
|
|
|
@@ -424,13 +315,17 @@ const Popover = (_ref, ref) => {
|
|
|
424
315
|
createElement("div", _extends({
|
|
425
316
|
className: classnames('components-popover', className, animateClassName, {
|
|
426
317
|
'is-expanded': isExpanded,
|
|
427
|
-
'is-without-arrow': noArrow,
|
|
428
318
|
'is-alternate': isAlternate
|
|
429
319
|
})
|
|
430
320
|
}, contentProps, {
|
|
431
321
|
ref: mergedRefs
|
|
432
322
|
}, dialogProps, {
|
|
433
|
-
tabIndex: "-1"
|
|
323
|
+
tabIndex: "-1",
|
|
324
|
+
style: isExpanded ? undefined : {
|
|
325
|
+
position: strategy,
|
|
326
|
+
left: Number.isNaN(x) ? 0 : x,
|
|
327
|
+
top: Number.isNaN(y) ? 0 : y
|
|
328
|
+
}
|
|
434
329
|
}), isExpanded && createElement(ScrollLock, null), isExpanded && createElement("div", {
|
|
435
330
|
className: "components-popover__header"
|
|
436
331
|
}, createElement("span", {
|
|
@@ -440,13 +335,18 @@ const Popover = (_ref, ref) => {
|
|
|
440
335
|
icon: close,
|
|
441
336
|
onClick: onClose
|
|
442
337
|
})), createElement("div", {
|
|
443
|
-
ref: contentRef,
|
|
444
338
|
className: "components-popover__content"
|
|
445
|
-
}, createElement("div", {
|
|
339
|
+
}, children), hasArrow && createElement("div", {
|
|
340
|
+
className: "components-popover__arrow",
|
|
341
|
+
ref: arrowRef,
|
|
446
342
|
style: {
|
|
447
|
-
|
|
343
|
+
left: !(arrowData !== null && arrowData !== void 0 && arrowData.x) || Number.isNaN(arrowData === null || arrowData === void 0 ? void 0 : arrowData.x) ? 0 : arrowData.x,
|
|
344
|
+
top: !(arrowData !== null && arrowData !== void 0 && arrowData.y) || Number.isNaN(arrowData === null || arrowData === void 0 ? void 0 : arrowData.y) ? 0 : arrowData.y,
|
|
345
|
+
right: undefined,
|
|
346
|
+
bottom: undefined,
|
|
347
|
+
[staticSide]: '-4px'
|
|
448
348
|
}
|
|
449
|
-
}
|
|
349
|
+
}));
|
|
450
350
|
|
|
451
351
|
if (slot.ref) {
|
|
452
352
|
content = createElement(Fill, {
|
|
@@ -465,10 +365,10 @@ const Popover = (_ref, ref) => {
|
|
|
465
365
|
|
|
466
366
|
const PopoverContainer = forwardRef(Popover);
|
|
467
367
|
|
|
468
|
-
function PopoverSlot(
|
|
368
|
+
function PopoverSlot(_ref4, ref) {
|
|
469
369
|
let {
|
|
470
370
|
name = SLOT_NAME
|
|
471
|
-
} =
|
|
371
|
+
} = _ref4;
|
|
472
372
|
return createElement(Slot, {
|
|
473
373
|
bubblesVirtually: true,
|
|
474
374
|
name: name,
|