@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
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
4
|
-
import {
|
|
5
|
-
computePopoverPosition,
|
|
6
|
-
computePopoverYAxisPosition,
|
|
7
|
-
computePopoverXAxisPosition,
|
|
8
|
-
offsetIframe,
|
|
9
|
-
} from '../utils';
|
|
10
|
-
|
|
11
|
-
describe( 'computePopoverYAxisPosition', () => {
|
|
12
|
-
it( 'should leave the position as is there’s enought space', () => {
|
|
13
|
-
const anchorRect = {
|
|
14
|
-
top: 10,
|
|
15
|
-
left: 10,
|
|
16
|
-
bottom: 30,
|
|
17
|
-
right: 30,
|
|
18
|
-
width: 20,
|
|
19
|
-
height: 20,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const contentSize = {
|
|
23
|
-
width: 200,
|
|
24
|
-
height: 300,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
expect(
|
|
28
|
-
computePopoverYAxisPosition( anchorRect, contentSize, 'bottom' )
|
|
29
|
-
).toEqual( {
|
|
30
|
-
contentHeight: null,
|
|
31
|
-
popoverTop: 30,
|
|
32
|
-
yAxis: 'bottom',
|
|
33
|
-
} );
|
|
34
|
-
} );
|
|
35
|
-
|
|
36
|
-
it( "should switch to bottom position if there's not enough space", () => {
|
|
37
|
-
const anchorRect = {
|
|
38
|
-
top: 10,
|
|
39
|
-
left: 10,
|
|
40
|
-
bottom: 30,
|
|
41
|
-
right: 30,
|
|
42
|
-
width: 20,
|
|
43
|
-
height: 20,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const contentSize = {
|
|
47
|
-
width: 200,
|
|
48
|
-
height: 300,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
expect(
|
|
52
|
-
computePopoverYAxisPosition( anchorRect, contentSize, 'top' )
|
|
53
|
-
).toEqual( {
|
|
54
|
-
contentHeight: null,
|
|
55
|
-
popoverTop: 30,
|
|
56
|
-
yAxis: 'bottom',
|
|
57
|
-
} );
|
|
58
|
-
} );
|
|
59
|
-
|
|
60
|
-
it( "should set a maxHeight if there's not enough space in any direction", () => {
|
|
61
|
-
const anchorRect = {
|
|
62
|
-
top: 400,
|
|
63
|
-
left: 10,
|
|
64
|
-
bottom: 420,
|
|
65
|
-
right: 30,
|
|
66
|
-
width: 20,
|
|
67
|
-
height: 20,
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const contentSize = {
|
|
71
|
-
width: 200,
|
|
72
|
-
height: 500,
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
expect(
|
|
76
|
-
computePopoverYAxisPosition( anchorRect, contentSize, 'bottom' )
|
|
77
|
-
).toEqual( {
|
|
78
|
-
contentHeight: 390,
|
|
79
|
-
popoverTop: 400,
|
|
80
|
-
yAxis: 'top',
|
|
81
|
-
} );
|
|
82
|
-
} );
|
|
83
|
-
|
|
84
|
-
it( 'should position a popover in the middle', () => {
|
|
85
|
-
const anchorRect = {
|
|
86
|
-
top: 400,
|
|
87
|
-
left: 10,
|
|
88
|
-
bottom: 30,
|
|
89
|
-
right: 30,
|
|
90
|
-
width: 20,
|
|
91
|
-
height: 20,
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const contentSize = {
|
|
95
|
-
width: 200,
|
|
96
|
-
height: 300,
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
expect(
|
|
100
|
-
computePopoverYAxisPosition( anchorRect, contentSize, 'middle' )
|
|
101
|
-
).toEqual( {
|
|
102
|
-
contentHeight: null,
|
|
103
|
-
popoverTop: 410,
|
|
104
|
-
yAxis: 'middle',
|
|
105
|
-
} );
|
|
106
|
-
} );
|
|
107
|
-
} );
|
|
108
|
-
|
|
109
|
-
describe( 'computePopoverXAxisPosition', () => {
|
|
110
|
-
it( 'should leave the position as is there’s enought space', () => {
|
|
111
|
-
const anchorRect = {
|
|
112
|
-
top: 10,
|
|
113
|
-
left: 10,
|
|
114
|
-
bottom: 30,
|
|
115
|
-
right: 30,
|
|
116
|
-
width: 20,
|
|
117
|
-
height: 20,
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const contentSize = {
|
|
121
|
-
width: 200,
|
|
122
|
-
height: 300,
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
expect(
|
|
126
|
-
computePopoverXAxisPosition( anchorRect, contentSize, 'right' )
|
|
127
|
-
).toEqual( {
|
|
128
|
-
contentWidth: null,
|
|
129
|
-
popoverLeft: 20,
|
|
130
|
-
xAxis: 'right',
|
|
131
|
-
} );
|
|
132
|
-
} );
|
|
133
|
-
|
|
134
|
-
it( "should switch to right position if there's not enough space", () => {
|
|
135
|
-
const anchorRect = {
|
|
136
|
-
top: 10,
|
|
137
|
-
left: 10,
|
|
138
|
-
bottom: 30,
|
|
139
|
-
right: 30,
|
|
140
|
-
width: 20,
|
|
141
|
-
height: 20,
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
const contentSize = {
|
|
145
|
-
width: 200,
|
|
146
|
-
height: 300,
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
expect(
|
|
150
|
-
computePopoverXAxisPosition( anchorRect, contentSize, 'center' )
|
|
151
|
-
).toEqual( {
|
|
152
|
-
contentWidth: null,
|
|
153
|
-
popoverLeft: 20,
|
|
154
|
-
xAxis: 'right',
|
|
155
|
-
} );
|
|
156
|
-
} );
|
|
157
|
-
|
|
158
|
-
it( "should center popover if there's not enough space in any direction", () => {
|
|
159
|
-
const anchorRect = {
|
|
160
|
-
top: 10,
|
|
161
|
-
left: 400,
|
|
162
|
-
bottom: 30,
|
|
163
|
-
right: 420,
|
|
164
|
-
width: 20,
|
|
165
|
-
height: 20,
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
const contentSize = {
|
|
169
|
-
width: 800,
|
|
170
|
-
height: 300,
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
expect(
|
|
174
|
-
computePopoverXAxisPosition( anchorRect, contentSize, 'right' )
|
|
175
|
-
).toEqual( {
|
|
176
|
-
contentWidth: null,
|
|
177
|
-
popoverLeft: 512,
|
|
178
|
-
xAxis: 'center',
|
|
179
|
-
} );
|
|
180
|
-
} );
|
|
181
|
-
|
|
182
|
-
it( 'should set the content width to the viewport width if content is too wide', () => {
|
|
183
|
-
const anchorRect = {
|
|
184
|
-
top: 10,
|
|
185
|
-
left: 400,
|
|
186
|
-
bottom: 30,
|
|
187
|
-
right: 420,
|
|
188
|
-
width: 20,
|
|
189
|
-
height: 20,
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
const contentSize = {
|
|
193
|
-
width: 1500,
|
|
194
|
-
height: 300,
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
expect(
|
|
198
|
-
computePopoverXAxisPosition( anchorRect, contentSize, 'right' )
|
|
199
|
-
).toEqual( {
|
|
200
|
-
contentWidth: 1024,
|
|
201
|
-
popoverLeft: 512,
|
|
202
|
-
xAxis: 'center',
|
|
203
|
-
} );
|
|
204
|
-
} );
|
|
205
|
-
} );
|
|
206
|
-
|
|
207
|
-
describe( 'computePopoverPosition', () => {
|
|
208
|
-
it( 'should leave the position as is there’s enought space', () => {
|
|
209
|
-
const anchorRect = {
|
|
210
|
-
top: 10,
|
|
211
|
-
left: 10,
|
|
212
|
-
bottom: 30,
|
|
213
|
-
right: 30,
|
|
214
|
-
width: 20,
|
|
215
|
-
height: 20,
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
const contentSize = {
|
|
219
|
-
width: 200,
|
|
220
|
-
height: 300,
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
expect(
|
|
224
|
-
computePopoverPosition( anchorRect, contentSize, 'bottom right' )
|
|
225
|
-
).toEqual( {
|
|
226
|
-
contentWidth: null,
|
|
227
|
-
popoverLeft: 20,
|
|
228
|
-
xAxis: 'right',
|
|
229
|
-
contentHeight: null,
|
|
230
|
-
popoverTop: 30,
|
|
231
|
-
yAxis: 'bottom',
|
|
232
|
-
} );
|
|
233
|
-
} );
|
|
234
|
-
} );
|
|
235
|
-
|
|
236
|
-
describe( 'offsetIframe', () => {
|
|
237
|
-
let parent;
|
|
238
|
-
|
|
239
|
-
beforeEach( () => {
|
|
240
|
-
parent = document.createElement( 'div' );
|
|
241
|
-
document.body.appendChild( parent );
|
|
242
|
-
} );
|
|
243
|
-
|
|
244
|
-
afterEach( () => {
|
|
245
|
-
parent.remove();
|
|
246
|
-
} );
|
|
247
|
-
|
|
248
|
-
it( 'returns rect without changes if element is not an iframe', () => {
|
|
249
|
-
const rect = {
|
|
250
|
-
left: 50,
|
|
251
|
-
top: 50,
|
|
252
|
-
bottom: 100,
|
|
253
|
-
right: 100,
|
|
254
|
-
width: 50,
|
|
255
|
-
height: 50,
|
|
256
|
-
};
|
|
257
|
-
const offsettedRect = offsetIframe( rect, parent.ownerDocument );
|
|
258
|
-
|
|
259
|
-
expect( offsettedRect ).toEqual( rect );
|
|
260
|
-
} );
|
|
261
|
-
|
|
262
|
-
it( 'returns offsetted rect if element is in an iframe', () => {
|
|
263
|
-
const iframeLeft = 25;
|
|
264
|
-
const iframeTop = 50;
|
|
265
|
-
const childLeft = 10;
|
|
266
|
-
const childTop = 100;
|
|
267
|
-
|
|
268
|
-
const iframe = document.createElement( 'iframe' );
|
|
269
|
-
parent.appendChild( iframe );
|
|
270
|
-
// JSDom doesn't have a layout engine
|
|
271
|
-
// so we need to mock getBoundingClientRect and DOMRect.
|
|
272
|
-
iframe.getBoundingClientRect = jest.fn( () => ( {
|
|
273
|
-
width: 100,
|
|
274
|
-
height: 100,
|
|
275
|
-
top: iframeTop,
|
|
276
|
-
left: iframeLeft,
|
|
277
|
-
} ) );
|
|
278
|
-
iframe.contentWindow.DOMRect = jest.fn(
|
|
279
|
-
( left, top, width, height ) => ( {
|
|
280
|
-
left,
|
|
281
|
-
top,
|
|
282
|
-
right: left + width,
|
|
283
|
-
bottom: top + height,
|
|
284
|
-
width,
|
|
285
|
-
height,
|
|
286
|
-
} )
|
|
287
|
-
);
|
|
288
|
-
|
|
289
|
-
const child = document.createElement( 'div' );
|
|
290
|
-
iframe.contentWindow.document.body.appendChild( child );
|
|
291
|
-
child.getBoundingClientRect = jest.fn( () => ( {
|
|
292
|
-
width: 100,
|
|
293
|
-
height: 100,
|
|
294
|
-
top: childTop,
|
|
295
|
-
left: childLeft,
|
|
296
|
-
} ) );
|
|
297
|
-
|
|
298
|
-
const rect = child.getBoundingClientRect();
|
|
299
|
-
const offsettedRect = offsetIframe( rect, child.ownerDocument, parent );
|
|
300
|
-
|
|
301
|
-
expect( offsettedRect.left ).toBe( iframeLeft + childLeft );
|
|
302
|
-
expect( offsettedRect.top ).toBe( iframeTop + childTop );
|
|
303
|
-
} );
|
|
304
|
-
} );
|
package/src/popover/utils.js
DELETED
|
@@ -1,396 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { isRTL } from '@wordpress/i18n';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Module constants
|
|
9
|
-
*/
|
|
10
|
-
const HEIGHT_OFFSET = 10; // Used by the arrow and a bit of empty space.
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Utility used to compute the popover position over the xAxis
|
|
14
|
-
*
|
|
15
|
-
* @param {Object} anchorRect Anchor Rect.
|
|
16
|
-
* @param {Object} contentSize Content Size.
|
|
17
|
-
* @param {string} xAxis Desired xAxis.
|
|
18
|
-
* @param {string} corner Desired corner.
|
|
19
|
-
* @param {boolean} stickyBoundaryElement The boundary element to use when
|
|
20
|
-
* switching between sticky and normal
|
|
21
|
-
* position.
|
|
22
|
-
* @param {string} chosenYAxis yAxis to be used.
|
|
23
|
-
* @param {Element} boundaryElement Boundary element.
|
|
24
|
-
* @param {boolean} forcePosition Don't adjust position based on anchor.
|
|
25
|
-
* @param {boolean} forceXAlignment Don't adjust alignment based on YAxis
|
|
26
|
-
*
|
|
27
|
-
* @return {Object} Popover xAxis position and constraints.
|
|
28
|
-
*/
|
|
29
|
-
export function computePopoverXAxisPosition(
|
|
30
|
-
anchorRect,
|
|
31
|
-
contentSize,
|
|
32
|
-
xAxis,
|
|
33
|
-
corner,
|
|
34
|
-
stickyBoundaryElement,
|
|
35
|
-
chosenYAxis,
|
|
36
|
-
boundaryElement,
|
|
37
|
-
forcePosition,
|
|
38
|
-
forceXAlignment
|
|
39
|
-
) {
|
|
40
|
-
const { width } = contentSize;
|
|
41
|
-
|
|
42
|
-
// Correct xAxis for RTL support.
|
|
43
|
-
if ( xAxis === 'left' && isRTL() ) {
|
|
44
|
-
xAxis = 'right';
|
|
45
|
-
} else if ( xAxis === 'right' && isRTL() ) {
|
|
46
|
-
xAxis = 'left';
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if ( corner === 'left' && isRTL() ) {
|
|
50
|
-
corner = 'right';
|
|
51
|
-
} else if ( corner === 'right' && isRTL() ) {
|
|
52
|
-
corner = 'left';
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// X axis alignment choices.
|
|
56
|
-
const anchorMidPoint = Math.round( anchorRect.left + anchorRect.width / 2 );
|
|
57
|
-
const centerAlignment = {
|
|
58
|
-
popoverLeft: anchorMidPoint,
|
|
59
|
-
contentWidth:
|
|
60
|
-
( anchorMidPoint - width / 2 > 0 ? width / 2 : anchorMidPoint ) +
|
|
61
|
-
( anchorMidPoint + width / 2 > window.innerWidth
|
|
62
|
-
? window.innerWidth - anchorMidPoint
|
|
63
|
-
: width / 2 ),
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
let leftAlignmentX = anchorRect.left;
|
|
67
|
-
|
|
68
|
-
if ( corner === 'right' ) {
|
|
69
|
-
leftAlignmentX = anchorRect.right;
|
|
70
|
-
} else if ( chosenYAxis !== 'middle' && ! forceXAlignment ) {
|
|
71
|
-
leftAlignmentX = anchorMidPoint;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
let rightAlignmentX = anchorRect.right;
|
|
75
|
-
|
|
76
|
-
if ( corner === 'left' ) {
|
|
77
|
-
rightAlignmentX = anchorRect.left;
|
|
78
|
-
} else if ( chosenYAxis !== 'middle' && ! forceXAlignment ) {
|
|
79
|
-
rightAlignmentX = anchorMidPoint;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const leftAlignment = {
|
|
83
|
-
popoverLeft: leftAlignmentX,
|
|
84
|
-
contentWidth: leftAlignmentX - width > 0 ? width : leftAlignmentX,
|
|
85
|
-
};
|
|
86
|
-
const rightAlignment = {
|
|
87
|
-
popoverLeft: rightAlignmentX,
|
|
88
|
-
contentWidth:
|
|
89
|
-
rightAlignmentX + width > window.innerWidth
|
|
90
|
-
? window.innerWidth - rightAlignmentX
|
|
91
|
-
: width,
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// Choosing the x axis.
|
|
95
|
-
let chosenXAxis = xAxis;
|
|
96
|
-
let contentWidth = null;
|
|
97
|
-
|
|
98
|
-
if ( ! stickyBoundaryElement && ! forcePosition ) {
|
|
99
|
-
if ( xAxis === 'center' && centerAlignment.contentWidth === width ) {
|
|
100
|
-
chosenXAxis = 'center';
|
|
101
|
-
} else if ( xAxis === 'left' && leftAlignment.contentWidth === width ) {
|
|
102
|
-
chosenXAxis = 'left';
|
|
103
|
-
} else if (
|
|
104
|
-
xAxis === 'right' &&
|
|
105
|
-
rightAlignment.contentWidth === width
|
|
106
|
-
) {
|
|
107
|
-
chosenXAxis = 'right';
|
|
108
|
-
} else {
|
|
109
|
-
chosenXAxis =
|
|
110
|
-
leftAlignment.contentWidth > rightAlignment.contentWidth
|
|
111
|
-
? 'left'
|
|
112
|
-
: 'right';
|
|
113
|
-
const chosenWidth =
|
|
114
|
-
chosenXAxis === 'left'
|
|
115
|
-
? leftAlignment.contentWidth
|
|
116
|
-
: rightAlignment.contentWidth;
|
|
117
|
-
|
|
118
|
-
// Limit width of the content to the viewport width
|
|
119
|
-
if ( width > window.innerWidth ) {
|
|
120
|
-
contentWidth = window.innerWidth;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// If we can't find any alignment options that could fit
|
|
124
|
-
// our content, then let's fallback to the center of the viewport.
|
|
125
|
-
if ( chosenWidth !== width ) {
|
|
126
|
-
chosenXAxis = 'center';
|
|
127
|
-
centerAlignment.popoverLeft = window.innerWidth / 2;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
let popoverLeft;
|
|
133
|
-
if ( chosenXAxis === 'center' ) {
|
|
134
|
-
popoverLeft = centerAlignment.popoverLeft;
|
|
135
|
-
} else if ( chosenXAxis === 'left' ) {
|
|
136
|
-
popoverLeft = leftAlignment.popoverLeft;
|
|
137
|
-
} else {
|
|
138
|
-
popoverLeft = rightAlignment.popoverLeft;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if ( boundaryElement ) {
|
|
142
|
-
popoverLeft = Math.min(
|
|
143
|
-
popoverLeft,
|
|
144
|
-
boundaryElement.offsetLeft + boundaryElement.offsetWidth - width
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
// Avoid the popover being position beyond the left boundary if the
|
|
148
|
-
// direction is left to right.
|
|
149
|
-
if ( ! isRTL() ) {
|
|
150
|
-
popoverLeft = Math.max( popoverLeft, 0 );
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return {
|
|
155
|
-
xAxis: chosenXAxis,
|
|
156
|
-
popoverLeft,
|
|
157
|
-
contentWidth,
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Utility used to compute the popover position over the yAxis
|
|
163
|
-
*
|
|
164
|
-
* @param {Object} anchorRect Anchor Rect.
|
|
165
|
-
* @param {Object} contentSize Content Size.
|
|
166
|
-
* @param {string} yAxis Desired yAxis.
|
|
167
|
-
* @param {string} corner Desired corner.
|
|
168
|
-
* @param {boolean} stickyBoundaryElement The boundary element to use when switching between sticky
|
|
169
|
-
* and normal position.
|
|
170
|
-
* @param {Element} anchorRef The anchor element.
|
|
171
|
-
* @param {Element} relativeOffsetTop If applicable, top offset of the relative positioned
|
|
172
|
-
* parent container.
|
|
173
|
-
* @param {boolean} forcePosition Don't adjust position based on anchor.
|
|
174
|
-
* @param {Element|null} editorWrapper Element that wraps the editor content. Used to access
|
|
175
|
-
* scroll position to determine sticky behavior.
|
|
176
|
-
* @return {Object} Popover xAxis position and constraints.
|
|
177
|
-
*/
|
|
178
|
-
export function computePopoverYAxisPosition(
|
|
179
|
-
anchorRect,
|
|
180
|
-
contentSize,
|
|
181
|
-
yAxis,
|
|
182
|
-
corner,
|
|
183
|
-
stickyBoundaryElement,
|
|
184
|
-
anchorRef,
|
|
185
|
-
relativeOffsetTop,
|
|
186
|
-
forcePosition,
|
|
187
|
-
editorWrapper
|
|
188
|
-
) {
|
|
189
|
-
const { height } = contentSize;
|
|
190
|
-
|
|
191
|
-
if ( stickyBoundaryElement ) {
|
|
192
|
-
const stickyRect = stickyBoundaryElement.getBoundingClientRect();
|
|
193
|
-
const stickyPositionTop = stickyRect.top + height - relativeOffsetTop;
|
|
194
|
-
const stickyPositionBottom =
|
|
195
|
-
stickyRect.bottom - height - relativeOffsetTop;
|
|
196
|
-
|
|
197
|
-
if ( anchorRect.top <= stickyPositionTop ) {
|
|
198
|
-
if ( editorWrapper ) {
|
|
199
|
-
// If a popover cannot be positioned above the anchor, even after scrolling, we must
|
|
200
|
-
// ensure we use the bottom position instead of the popover slot. This prevents the
|
|
201
|
-
// popover from always restricting block content and interaction while selected if the
|
|
202
|
-
// block is near the top of the site editor.
|
|
203
|
-
|
|
204
|
-
const isRoomAboveInCanvas =
|
|
205
|
-
height + HEIGHT_OFFSET <
|
|
206
|
-
editorWrapper.scrollTop + anchorRect.top;
|
|
207
|
-
if ( ! isRoomAboveInCanvas ) {
|
|
208
|
-
return {
|
|
209
|
-
yAxis: 'bottom',
|
|
210
|
-
// If the bottom of the block is also below the bottom sticky position (ex -
|
|
211
|
-
// block is also taller than the editor window), return the bottom sticky
|
|
212
|
-
// position instead. We do this instead of the top sticky position both to
|
|
213
|
-
// allow a smooth transition and more importantly to ensure every section of
|
|
214
|
-
// the block can be free from popover obscuration at some point in the
|
|
215
|
-
// scroll position.
|
|
216
|
-
popoverTop: Math.min(
|
|
217
|
-
anchorRect.bottom,
|
|
218
|
-
stickyPositionBottom
|
|
219
|
-
),
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
// Default sticky behavior.
|
|
224
|
-
return {
|
|
225
|
-
yAxis,
|
|
226
|
-
popoverTop: Math.min( anchorRect.bottom, stickyPositionTop ),
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// Y axis alignment choices.
|
|
232
|
-
let anchorMidPoint = anchorRect.top + anchorRect.height / 2;
|
|
233
|
-
|
|
234
|
-
if ( corner === 'bottom' ) {
|
|
235
|
-
anchorMidPoint = anchorRect.bottom;
|
|
236
|
-
} else if ( corner === 'top' ) {
|
|
237
|
-
anchorMidPoint = anchorRect.top;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const middleAlignment = {
|
|
241
|
-
popoverTop: anchorMidPoint,
|
|
242
|
-
contentHeight:
|
|
243
|
-
( anchorMidPoint - height / 2 > 0 ? height / 2 : anchorMidPoint ) +
|
|
244
|
-
( anchorMidPoint + height / 2 > window.innerHeight
|
|
245
|
-
? window.innerHeight - anchorMidPoint
|
|
246
|
-
: height / 2 ),
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
const topAlignment = {
|
|
250
|
-
popoverTop: anchorRect.top,
|
|
251
|
-
contentHeight:
|
|
252
|
-
anchorRect.top - HEIGHT_OFFSET - height > 0
|
|
253
|
-
? height
|
|
254
|
-
: anchorRect.top - HEIGHT_OFFSET,
|
|
255
|
-
};
|
|
256
|
-
const bottomAlignment = {
|
|
257
|
-
popoverTop: anchorRect.bottom,
|
|
258
|
-
contentHeight:
|
|
259
|
-
anchorRect.bottom + HEIGHT_OFFSET + height > window.innerHeight
|
|
260
|
-
? window.innerHeight - HEIGHT_OFFSET - anchorRect.bottom
|
|
261
|
-
: height,
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
// Choosing the y axis.
|
|
265
|
-
let chosenYAxis = yAxis;
|
|
266
|
-
let contentHeight = null;
|
|
267
|
-
|
|
268
|
-
if ( ! stickyBoundaryElement && ! forcePosition ) {
|
|
269
|
-
if ( yAxis === 'middle' && middleAlignment.contentHeight === height ) {
|
|
270
|
-
chosenYAxis = 'middle';
|
|
271
|
-
} else if ( yAxis === 'top' && topAlignment.contentHeight === height ) {
|
|
272
|
-
chosenYAxis = 'top';
|
|
273
|
-
} else if (
|
|
274
|
-
yAxis === 'bottom' &&
|
|
275
|
-
bottomAlignment.contentHeight === height
|
|
276
|
-
) {
|
|
277
|
-
chosenYAxis = 'bottom';
|
|
278
|
-
} else {
|
|
279
|
-
chosenYAxis =
|
|
280
|
-
topAlignment.contentHeight > bottomAlignment.contentHeight
|
|
281
|
-
? 'top'
|
|
282
|
-
: 'bottom';
|
|
283
|
-
const chosenHeight =
|
|
284
|
-
chosenYAxis === 'top'
|
|
285
|
-
? topAlignment.contentHeight
|
|
286
|
-
: bottomAlignment.contentHeight;
|
|
287
|
-
contentHeight = chosenHeight !== height ? chosenHeight : null;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
let popoverTop;
|
|
292
|
-
if ( chosenYAxis === 'middle' ) {
|
|
293
|
-
popoverTop = middleAlignment.popoverTop;
|
|
294
|
-
} else if ( chosenYAxis === 'top' ) {
|
|
295
|
-
popoverTop = topAlignment.popoverTop;
|
|
296
|
-
} else {
|
|
297
|
-
popoverTop = bottomAlignment.popoverTop;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
return {
|
|
301
|
-
yAxis: chosenYAxis,
|
|
302
|
-
popoverTop,
|
|
303
|
-
contentHeight,
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* Utility used to compute the popover position and the content max width/height for a popover given
|
|
309
|
-
* its anchor rect and its content size.
|
|
310
|
-
*
|
|
311
|
-
* @param {Object} anchorRect Anchor Rect.
|
|
312
|
-
* @param {Object} contentSize Content Size.
|
|
313
|
-
* @param {string} position Position.
|
|
314
|
-
* @param {boolean} stickyBoundaryElement The boundary element to use when switching between
|
|
315
|
-
* sticky and normal position.
|
|
316
|
-
* @param {Element} anchorRef The anchor element.
|
|
317
|
-
* @param {number} relativeOffsetTop If applicable, top offset of the relative positioned
|
|
318
|
-
* parent container.
|
|
319
|
-
* @param {Element} boundaryElement Boundary element.
|
|
320
|
-
* @param {boolean} forcePosition Don't adjust position based on anchor.
|
|
321
|
-
* @param {boolean} forceXAlignment Don't adjust alignment based on YAxis
|
|
322
|
-
* @param {Element|null} editorWrapper Element that wraps the editor content. Used to access
|
|
323
|
-
* scroll position to determine sticky behavior.
|
|
324
|
-
* @return {Object} Popover position and constraints.
|
|
325
|
-
*/
|
|
326
|
-
export function computePopoverPosition(
|
|
327
|
-
anchorRect,
|
|
328
|
-
contentSize,
|
|
329
|
-
position = 'top',
|
|
330
|
-
stickyBoundaryElement,
|
|
331
|
-
anchorRef,
|
|
332
|
-
relativeOffsetTop,
|
|
333
|
-
boundaryElement,
|
|
334
|
-
forcePosition,
|
|
335
|
-
forceXAlignment,
|
|
336
|
-
editorWrapper
|
|
337
|
-
) {
|
|
338
|
-
const [ yAxis, xAxis = 'center', corner ] = position.split( ' ' );
|
|
339
|
-
|
|
340
|
-
const yAxisPosition = computePopoverYAxisPosition(
|
|
341
|
-
anchorRect,
|
|
342
|
-
contentSize,
|
|
343
|
-
yAxis,
|
|
344
|
-
corner,
|
|
345
|
-
stickyBoundaryElement,
|
|
346
|
-
anchorRef,
|
|
347
|
-
relativeOffsetTop,
|
|
348
|
-
forcePosition,
|
|
349
|
-
editorWrapper
|
|
350
|
-
);
|
|
351
|
-
const xAxisPosition = computePopoverXAxisPosition(
|
|
352
|
-
anchorRect,
|
|
353
|
-
contentSize,
|
|
354
|
-
xAxis,
|
|
355
|
-
corner,
|
|
356
|
-
stickyBoundaryElement,
|
|
357
|
-
yAxisPosition.yAxis,
|
|
358
|
-
boundaryElement,
|
|
359
|
-
forcePosition,
|
|
360
|
-
forceXAlignment
|
|
361
|
-
);
|
|
362
|
-
|
|
363
|
-
return {
|
|
364
|
-
...xAxisPosition,
|
|
365
|
-
...yAxisPosition,
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Offsets the given rect by the position of the iframe that contains the
|
|
371
|
-
* element. If the owner document is not in an iframe then it returns with the
|
|
372
|
-
* original rect. If the popover container document and the anchor document are
|
|
373
|
-
* the same, the original rect will also be returned.
|
|
374
|
-
*
|
|
375
|
-
* @param {DOMRect} rect bounds of the element
|
|
376
|
-
* @param {Document} ownerDocument document of the element
|
|
377
|
-
* @param {Element} container The popover container to position.
|
|
378
|
-
*
|
|
379
|
-
* @return {DOMRect} offsetted bounds
|
|
380
|
-
*/
|
|
381
|
-
export function offsetIframe( rect, ownerDocument, container ) {
|
|
382
|
-
const { defaultView } = ownerDocument;
|
|
383
|
-
const { frameElement } = defaultView;
|
|
384
|
-
|
|
385
|
-
if ( ! frameElement || ownerDocument === container.ownerDocument ) {
|
|
386
|
-
return rect;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
const iframeRect = frameElement.getBoundingClientRect();
|
|
390
|
-
return new defaultView.DOMRect(
|
|
391
|
-
rect.left + iframeRect.left,
|
|
392
|
-
rect.top + iframeRect.top,
|
|
393
|
-
rect.width,
|
|
394
|
-
rect.height
|
|
395
|
-
);
|
|
396
|
-
}
|