@wordpress/components 19.16.0 → 19.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -4
- package/build/base-control/index.js +6 -3
- package/build/base-control/index.js.map +1 -1
- package/build/base-control/styles/base-control-styles.js +8 -8
- package/build/base-control/styles/base-control-styles.js.map +1 -1
- package/build/border-control/styles.js +17 -25
- package/build/border-control/styles.js.map +1 -1
- package/build/box-control/all-input-control.js +2 -27
- package/build/box-control/all-input-control.js.map +1 -1
- package/build/box-control/index.js +10 -5
- package/build/box-control/index.js.map +1 -1
- package/build/box-control/styles/box-control-styles.js +17 -9
- package/build/box-control/styles/box-control-styles.js.map +1 -1
- package/build/box-control/utils.js +35 -0
- package/build/box-control/utils.js.map +1 -1
- package/build/color-picker/styles.js +10 -8
- package/build/color-picker/styles.js.map +1 -1
- package/build/combobox-control/index.js +14 -6
- package/build/combobox-control/index.js.map +1 -1
- package/build/custom-select-control/index.js +3 -1
- package/build/custom-select-control/index.js.map +1 -1
- package/build/date-time/time/index.js +6 -2
- package/build/date-time/time/index.js.map +1 -1
- package/build/date-time/time/styles.js +17 -24
- package/build/date-time/time/styles.js.map +1 -1
- package/build/external-link/index.js +6 -0
- package/build/external-link/index.js.map +1 -1
- package/build/flex/flex/component.js +9 -9
- package/build/flex/flex/component.js.map +1 -1
- package/build/flex/flex/hook.js +6 -16
- package/build/flex/flex/hook.js.map +1 -1
- package/build/flex/flex/index.js.map +1 -1
- package/build/flex/flex-block/component.js +9 -9
- package/build/flex/flex-block/component.js.map +1 -1
- package/build/flex/flex-block/hook.js +0 -4
- package/build/flex/flex-block/hook.js.map +1 -1
- package/build/flex/flex-block/index.js.map +1 -1
- package/build/flex/flex-item/component.js +9 -9
- package/build/flex/flex-item/component.js.map +1 -1
- package/build/flex/flex-item/hook.js +1 -5
- package/build/flex/flex-item/hook.js.map +1 -1
- package/build/flex/flex-item/index.js.map +1 -1
- package/build/flex/index.js.map +1 -1
- package/build/flex/styles.js +5 -5
- package/build/flex/styles.js.map +1 -1
- package/build/focal-point-picker/styles/focal-point-picker-style.js +22 -22
- package/build/focal-point-picker/styles/focal-point-picker-style.js.map +1 -1
- package/build/focal-point-picker/styles/focal-point-style.js +5 -5
- package/build/focal-point-picker/styles/focal-point-style.js.map +1 -1
- package/build/font-size-picker/index.js +15 -6
- package/build/font-size-picker/index.js.map +1 -1
- package/build/form-token-field/index.js +6 -2
- package/build/form-token-field/index.js.map +1 -1
- package/build/form-token-field/suggestions-list.js +19 -6
- package/build/form-token-field/suggestions-list.js.map +1 -1
- package/build/index.js +7 -1
- package/build/index.js.map +1 -1
- package/build/input-control/input-base.js +1 -2
- package/build/input-control/input-base.js.map +1 -1
- package/build/input-control/reducer/actions.js +3 -1
- package/build/input-control/reducer/actions.js.map +1 -1
- package/build/input-control/reducer/reducer.js +28 -11
- package/build/input-control/reducer/reducer.js.map +1 -1
- package/build/input-control/reducer/state.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +26 -26
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/mobile/global-styles-context/utils.native.js +23 -3
- package/build/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build/mobile/image/index.native.js +23 -2
- package/build/mobile/image/index.native.js.map +1 -1
- package/build/mobile/link-picker/link-picker-screen.native.js +10 -4
- package/build/mobile/link-picker/link-picker-screen.native.js.map +1 -1
- package/build/mobile/picker/index.ios.js +16 -3
- package/build/mobile/picker/index.ios.js.map +1 -1
- package/build/placeholder/index.js +11 -14
- package/build/placeholder/index.js.map +1 -1
- package/build/placeholder/types.js +6 -0
- package/build/placeholder/types.js.map +1 -0
- package/build/popover/index.js +113 -62
- package/build/popover/index.js.map +1 -1
- package/build/range-control/styles/range-control-styles.js +40 -40
- package/build/range-control/styles/range-control-styles.js.map +1 -1
- package/build/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +4 -4
- package/build/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js.map +1 -1
- package/build/select-control/styles/select-control-styles.js +6 -6
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- package/build/style-provider/index.js +10 -7
- package/build/style-provider/index.js.map +1 -1
- package/build/style-provider/types.js +6 -0
- package/build/style-provider/types.js.map +1 -0
- package/build/swatch/index.js +2 -0
- package/build/swatch/index.js.map +1 -1
- package/build/swatch/types.js +6 -0
- package/build/swatch/types.js.map +1 -0
- package/build/text/hook.js +5 -8
- package/build/text/hook.js.map +1 -1
- package/build/tools-panel/styles.js +13 -10
- package/build/tools-panel/styles.js.map +1 -1
- package/build/tools-panel/tools-panel/hook.js +1 -1
- package/build/tools-panel/tools-panel/hook.js.map +1 -1
- package/build/ui/tooltip/styles.js +4 -4
- package/build/ui/tooltip/styles.js.map +1 -1
- package/build/unit-control/styles/unit-control-styles.js +34 -9
- package/build/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build/utils/base-label.js +24 -0
- package/build/utils/base-label.js.map +1 -0
- package/build/utils/box-sizing.js +22 -0
- package/build/utils/box-sizing.js.map +1 -0
- package/build/utils/style-mixins.js +16 -0
- package/build/utils/style-mixins.js.map +1 -1
- package/build-module/base-control/index.js +7 -5
- package/build-module/base-control/index.js.map +1 -1
- package/build-module/base-control/styles/base-control-styles.js +9 -9
- package/build-module/base-control/styles/base-control-styles.js.map +1 -1
- package/build-module/border-control/styles.js +18 -26
- package/build-module/border-control/styles.js.map +1 -1
- package/build-module/box-control/all-input-control.js +3 -28
- package/build-module/box-control/all-input-control.js.map +1 -1
- package/build-module/box-control/index.js +4 -4
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/box-control/styles/box-control-styles.js +18 -10
- package/build-module/box-control/styles/box-control-styles.js.map +1 -1
- package/build-module/box-control/utils.js +33 -0
- package/build-module/box-control/utils.js.map +1 -1
- package/build-module/color-picker/styles.js +9 -8
- package/build-module/color-picker/styles.js.map +1 -1
- package/build-module/combobox-control/index.js +13 -6
- package/build-module/combobox-control/index.js.map +1 -1
- package/build-module/custom-select-control/index.js +2 -1
- package/build-module/custom-select-control/index.js.map +1 -1
- package/build-module/date-time/time/index.js +6 -3
- package/build-module/date-time/time/index.js.map +1 -1
- package/build-module/date-time/time/styles.js +15 -21
- package/build-module/date-time/time/styles.js.map +1 -1
- package/build-module/external-link/index.js +6 -0
- package/build-module/external-link/index.js.map +1 -1
- package/build-module/flex/flex/component.js +9 -9
- package/build-module/flex/flex/component.js.map +1 -1
- package/build-module/flex/flex/hook.js +6 -15
- package/build-module/flex/flex/hook.js.map +1 -1
- package/build-module/flex/flex/index.js.map +1 -1
- package/build-module/flex/flex-block/component.js +9 -9
- package/build-module/flex/flex-block/component.js.map +1 -1
- package/build-module/flex/flex-block/hook.js +0 -4
- package/build-module/flex/flex-block/hook.js.map +1 -1
- package/build-module/flex/flex-block/index.js.map +1 -1
- package/build-module/flex/flex-item/component.js +9 -9
- package/build-module/flex/flex-item/component.js.map +1 -1
- package/build-module/flex/flex-item/hook.js +1 -5
- package/build-module/flex/flex-item/hook.js.map +1 -1
- package/build-module/flex/flex-item/index.js.map +1 -1
- package/build-module/flex/index.js.map +1 -1
- package/build-module/flex/styles.js +5 -5
- package/build-module/flex/styles.js.map +1 -1
- package/build-module/focal-point-picker/styles/focal-point-picker-style.js +22 -22
- package/build-module/focal-point-picker/styles/focal-point-picker-style.js.map +1 -1
- package/build-module/focal-point-picker/styles/focal-point-style.js +5 -5
- package/build-module/focal-point-picker/styles/focal-point-style.js.map +1 -1
- package/build-module/font-size-picker/index.js +14 -6
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/form-token-field/index.js +5 -2
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/form-token-field/suggestions-list.js +19 -6
- package/build-module/form-token-field/suggestions-list.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/input-control/input-base.js +1 -2
- package/build-module/input-control/input-base.js.map +1 -1
- package/build-module/input-control/reducer/actions.js +1 -0
- package/build-module/input-control/reducer/actions.js.map +1 -1
- package/build-module/input-control/reducer/reducer.js +28 -11
- package/build-module/input-control/reducer/reducer.js.map +1 -1
- package/build-module/input-control/reducer/state.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +27 -27
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +23 -4
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/mobile/image/index.native.js +25 -4
- package/build-module/mobile/image/index.native.js.map +1 -1
- package/build-module/mobile/link-picker/link-picker-screen.native.js +11 -4
- package/build-module/mobile/link-picker/link-picker-screen.native.js.map +1 -1
- package/build-module/mobile/picker/index.ios.js +14 -3
- package/build-module/mobile/picker/index.ios.js.map +1 -1
- package/build-module/placeholder/index.js +10 -15
- package/build-module/placeholder/index.js.map +1 -1
- package/build-module/placeholder/types.js +2 -0
- package/build-module/placeholder/types.js.map +1 -0
- package/build-module/popover/index.js +112 -62
- package/build-module/popover/index.js.map +1 -1
- package/build-module/range-control/styles/range-control-styles.js +40 -40
- package/build-module/range-control/styles/range-control-styles.js.map +1 -1
- package/build-module/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +4 -4
- package/build-module/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js.map +1 -1
- package/build-module/select-control/styles/select-control-styles.js +6 -6
- package/build-module/select-control/styles/select-control-styles.js.map +1 -1
- package/build-module/style-provider/index.js +10 -5
- package/build-module/style-provider/index.js.map +1 -1
- package/build-module/style-provider/types.js +2 -0
- package/build-module/style-provider/types.js.map +1 -0
- package/build-module/swatch/index.js +2 -0
- package/build-module/swatch/index.js.map +1 -1
- package/build-module/swatch/types.js +2 -0
- package/build-module/swatch/types.js.map +1 -0
- package/build-module/text/hook.js +5 -7
- package/build-module/text/hook.js.map +1 -1
- package/build-module/tools-panel/styles.js +12 -11
- package/build-module/tools-panel/styles.js.map +1 -1
- package/build-module/tools-panel/tools-panel/hook.js +1 -1
- package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
- package/build-module/ui/tooltip/styles.js +4 -4
- package/build-module/ui/tooltip/styles.js.map +1 -1
- package/build-module/unit-control/styles/unit-control-styles.js +35 -9
- package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build-module/utils/base-label.js +18 -0
- package/build-module/utils/base-label.js.map +1 -0
- package/build-module/utils/box-sizing.js +16 -0
- package/build-module/utils/box-sizing.js.map +1 -0
- package/build-module/utils/style-mixins.js +2 -0
- package/build-module/utils/style-mixins.js.map +1 -1
- package/build-style/style-rtl.css +50 -30
- package/build-style/style.css +52 -30
- package/build-types/base-control/index.d.ts +4 -3
- package/build-types/base-control/index.d.ts.map +1 -1
- package/build-types/base-control/stories/index.d.ts +1 -1
- package/build-types/base-control/stories/index.d.ts.map +1 -1
- package/build-types/base-control/styles/base-control-styles.d.ts.map +1 -1
- package/build-types/base-control/types.d.ts +0 -1
- package/build-types/base-control/types.d.ts.map +1 -1
- package/build-types/border-control/styles.d.ts.map +1 -1
- package/build-types/color-picker/color-display.d.ts +13 -0
- package/build-types/color-picker/color-display.d.ts.map +1 -0
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/date-time/time/index.d.ts.map +1 -1
- package/build-types/date-time/time/styles.d.ts +0 -4
- package/build-types/date-time/time/styles.d.ts.map +1 -1
- package/build-types/external-link/index.d.ts.map +1 -1
- package/build-types/flex/flex/component.d.ts +5 -4
- package/build-types/flex/flex/component.d.ts.map +1 -1
- package/build-types/flex/flex/hook.d.ts +5 -2
- package/build-types/flex/flex/hook.d.ts.map +1 -1
- package/build-types/flex/flex/index.d.ts +2 -2
- package/build-types/flex/flex/index.d.ts.map +1 -1
- package/build-types/flex/flex-block/component.d.ts +5 -4
- package/build-types/flex/flex-block/component.d.ts.map +1 -1
- package/build-types/flex/flex-block/hook.d.ts +6 -3
- package/build-types/flex/flex-block/hook.d.ts.map +1 -1
- package/build-types/flex/flex-block/index.d.ts +2 -2
- package/build-types/flex/flex-block/index.d.ts.map +1 -1
- package/build-types/flex/flex-item/component.d.ts +5 -4
- package/build-types/flex/flex-item/component.d.ts.map +1 -1
- package/build-types/flex/flex-item/hook.d.ts +6 -3
- package/build-types/flex/flex-item/hook.d.ts.map +1 -1
- package/build-types/flex/flex-item/index.d.ts +2 -2
- package/build-types/flex/flex-item/index.d.ts.map +1 -1
- package/build-types/flex/index.d.ts +3 -3
- package/build-types/flex/index.d.ts.map +1 -1
- package/build-types/flex/stories/index.d.ts +13 -0
- package/build-types/flex/stories/index.d.ts.map +1 -0
- package/build-types/flex/styles.d.ts +5 -5
- package/build-types/flex/styles.d.ts.map +1 -1
- package/build-types/flex/test/index.d.ts +2 -0
- package/build-types/flex/test/index.d.ts.map +1 -0
- package/build-types/flex/types.d.ts +15 -11
- package/build-types/flex/types.d.ts.map +1 -1
- package/build-types/flyout/context.d.ts +6 -0
- package/build-types/flyout/context.d.ts.map +1 -0
- package/build-types/flyout/flyout/component.d.ts +21 -0
- package/build-types/flyout/flyout/component.d.ts.map +1 -0
- package/build-types/flyout/flyout/hook.d.ts +270 -0
- package/build-types/flyout/flyout/hook.d.ts.map +1 -0
- package/build-types/flyout/flyout/index.d.ts +3 -0
- package/build-types/flyout/flyout/index.d.ts.map +1 -0
- package/build-types/flyout/flyout-content/component.d.ts +3 -0
- package/build-types/flyout/flyout-content/component.d.ts.map +1 -0
- package/build-types/flyout/flyout-content/index.d.ts +2 -0
- package/build-types/flyout/flyout-content/index.d.ts.map +1 -0
- package/build-types/flyout/index.d.ts +2 -0
- package/build-types/flyout/index.d.ts.map +1 -0
- package/build-types/flyout/styles.d.ts +22 -0
- package/build-types/flyout/styles.d.ts.map +1 -0
- package/build-types/flyout/types.d.ts +80 -0
- package/build-types/flyout/types.d.ts.map +1 -0
- package/build-types/flyout/utils.d.ts +8 -0
- package/build-types/flyout/utils.d.ts.map +1 -0
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/stories/index.d.ts +6 -0
- package/build-types/form-token-field/stories/index.d.ts.map +1 -1
- package/build-types/form-token-field/suggestions-list.d.ts +1 -1
- package/build-types/form-token-field/suggestions-list.d.ts.map +1 -1
- package/build-types/form-token-field/types.d.ts +15 -3
- package/build-types/form-token-field/types.d.ts.map +1 -1
- package/build-types/input-control/input-base.d.ts.map +1 -1
- package/build-types/input-control/reducer/actions.d.ts +3 -1
- package/build-types/input-control/reducer/actions.d.ts.map +1 -1
- package/build-types/input-control/reducer/reducer.d.ts +2 -2
- package/build-types/input-control/reducer/reducer.d.ts.map +1 -1
- package/build-types/input-control/reducer/state.d.ts +2 -2
- package/build-types/input-control/reducer/state.d.ts.map +1 -1
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/placeholder/index.d.ts +16 -0
- package/build-types/placeholder/index.d.ts.map +1 -0
- package/build-types/placeholder/stories/index.d.ts +12 -0
- package/build-types/placeholder/stories/index.d.ts.map +1 -0
- package/build-types/placeholder/types.d.ts +47 -0
- package/build-types/placeholder/types.d.ts.map +1 -0
- package/build-types/popover/index.d.ts +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/popover/utils.d.ts +70 -0
- package/build-types/popover/utils.d.ts.map +1 -0
- package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/style-provider/index.d.ts +7 -4
- package/build-types/style-provider/index.d.ts.map +1 -1
- package/build-types/style-provider/types.d.ts +15 -0
- package/build-types/style-provider/types.d.ts.map +1 -0
- package/build-types/swatch/index.d.ts +5 -0
- package/build-types/swatch/index.d.ts.map +1 -0
- package/build-types/swatch/types.d.ts +11 -0
- package/build-types/swatch/types.d.ts.map +1 -0
- package/build-types/text/hook.d.ts.map +1 -1
- package/build-types/tools-panel/styles.d.ts +1 -1
- package/build-types/tools-panel/styles.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/ui/tooltip/styles.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +1 -1
- package/build-types/unit-control/stories/index.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
- package/build-types/unit-control/types.d.ts +1 -7
- package/build-types/unit-control/types.d.ts.map +1 -1
- package/build-types/utils/base-label.d.ts +2 -0
- package/build-types/utils/base-label.d.ts.map +1 -0
- package/build-types/utils/box-sizing.d.ts +2 -0
- package/build-types/utils/box-sizing.d.ts.map +1 -0
- package/build-types/utils/hooks/use-combined-ref.d.ts +8 -0
- package/build-types/utils/hooks/use-combined-ref.d.ts.map +1 -0
- package/build-types/utils/style-mixins.d.ts +2 -0
- package/package.json +17 -17
- package/src/base-control/index.tsx +5 -3
- package/src/base-control/stories/index.tsx +1 -0
- package/src/base-control/styles/base-control-styles.ts +9 -5
- package/src/base-control/types.ts +0 -1
- package/src/border-control/styles.ts +2 -1
- package/src/box-control/all-input-control.js +3 -27
- package/src/box-control/index.js +5 -6
- package/src/box-control/styles/box-control-styles.js +1 -2
- package/src/box-control/utils.js +32 -0
- package/src/color-picker/styles.ts +3 -0
- package/src/combobox-control/README.md +7 -0
- package/src/combobox-control/index.js +14 -4
- package/src/combobox-control/stories/index.js +49 -5
- package/src/custom-gradient-picker/style.scss +0 -12
- package/src/custom-select-control/index.js +3 -2
- package/src/custom-select-control/style.scss +1 -5
- package/src/date-time/time/index.tsx +7 -5
- package/src/date-time/time/styles.ts +3 -6
- package/src/external-link/index.tsx +10 -0
- package/src/flex/flex/README.md +19 -13
- package/src/flex/flex/{component.js → component.tsx} +15 -10
- package/src/flex/flex/{hook.js → hook.ts} +14 -13
- package/src/flex/flex/{index.js → index.ts} +0 -0
- package/src/flex/flex-block/README.md +3 -3
- package/src/flex/flex-block/{component.js → component.tsx} +15 -10
- package/src/flex/flex-block/{hook.js → hook.ts} +5 -5
- package/src/flex/flex-block/{index.js → index.ts} +0 -0
- package/src/flex/flex-item/README.md +6 -5
- package/src/flex/flex-item/{component.js → component.tsx} +15 -10
- package/src/flex/flex-item/{hook.js → hook.ts} +10 -7
- package/src/flex/flex-item/{index.js → index.ts} +0 -0
- package/src/flex/{index.js → index.ts} +0 -0
- package/src/flex/stories/index.tsx +81 -0
- package/src/flex/{styles.js → styles.ts} +0 -0
- package/src/flex/test/__snapshots__/{index.js.snap → index.tsx.snap} +49 -9
- package/src/flex/test/index.tsx +84 -0
- package/src/flex/types.ts +15 -11
- package/src/focal-point-picker/styles/focal-point-picker-style.js +0 -5
- package/src/focal-point-picker/styles/focal-point-style.js +0 -1
- package/src/font-size-picker/index.js +18 -7
- package/src/font-size-picker/stories/index.js +6 -0
- package/src/form-token-field/README.md +2 -1
- package/src/form-token-field/index.tsx +5 -2
- package/src/form-token-field/stories/index.tsx +14 -0
- package/src/form-token-field/style.scss +0 -5
- package/src/form-token-field/suggestions-list.tsx +21 -12
- package/src/form-token-field/types.ts +16 -2
- package/src/index.js +4 -1
- package/src/input-control/input-base.tsx +0 -1
- package/src/input-control/reducer/actions.ts +3 -1
- package/src/input-control/reducer/reducer.ts +27 -10
- package/src/input-control/reducer/state.ts +7 -2
- package/src/input-control/styles/input-control-styles.tsx +3 -1
- package/src/input-control/test/index.js +20 -4
- package/src/mobile/global-styles-context/utils.native.js +21 -4
- package/src/mobile/image/index.native.js +27 -2
- package/src/mobile/link-picker/link-picker-screen.native.js +12 -4
- package/src/mobile/picker/index.ios.js +16 -0
- package/src/mobile/picker/styles.native.scss +8 -0
- package/src/panel/style.scss +4 -1
- package/src/placeholder/README.md +49 -9
- package/src/placeholder/{index.js → index.tsx} +27 -23
- package/src/placeholder/stories/index.tsx +64 -0
- package/src/placeholder/style.scss +0 -4
- package/src/placeholder/types.ts +48 -0
- package/src/popover/README.md +7 -0
- package/src/popover/index.js +144 -70
- package/src/popover/stories/index.js +199 -98
- package/src/popover/style.scss +60 -6
- package/src/popover/test/index.js +23 -1
- package/src/range-control/styles/range-control-styles.ts +0 -12
- package/src/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +1 -1
- package/src/select-control/styles/select-control-styles.ts +0 -1
- package/src/style-provider/index.tsx +41 -0
- package/src/style-provider/types.ts +15 -0
- package/src/swatch/{index.js → index.tsx} +4 -1
- package/src/swatch/types.ts +11 -0
- package/src/text/hook.js +5 -3
- package/src/toggle-group-control/test/__snapshots__/index.js.snap +24 -0
- package/src/tools-panel/styles.ts +7 -16
- package/src/tools-panel/test/__snapshots__/index.js.snap +2 -11
- package/src/tools-panel/tools-panel/hook.ts +6 -1
- package/src/ui/tooltip/styles.js +1 -0
- package/src/ui/tooltip/test/__snapshots__/index.js.snap +1 -0
- package/src/unit-control/stories/index.tsx +16 -23
- package/src/unit-control/styles/unit-control-styles.ts +93 -41
- package/src/unit-control/types.ts +1 -7
- package/src/utils/base-label.ts +13 -0
- package/src/utils/box-sizing.ts +14 -0
- package/src/utils/style-mixins.js +2 -0
- package/tsconfig.json +2 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/flex/stories/index.js +0 -29
- package/src/flex/test/index.js +0 -77
- package/src/placeholder/stories/index.js +0 -44
- package/src/popover/stories/_utils.js +0 -64
- package/src/style-provider/index.js +0 -31
|
@@ -34,6 +34,7 @@ import { TokensAndInputWrapperFlex } from './styles';
|
|
|
34
34
|
import SuggestionsList from './suggestions-list';
|
|
35
35
|
import type { FormTokenFieldProps, TokenItem } from './types';
|
|
36
36
|
import { FlexItem } from '../flex';
|
|
37
|
+
import { StyledLabel } from '../base-control/styles/base-control-styles';
|
|
37
38
|
|
|
38
39
|
const identity = ( value: string ) => value;
|
|
39
40
|
|
|
@@ -72,6 +73,7 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
72
73
|
remove: __( 'Remove item' ),
|
|
73
74
|
__experimentalInvalid: __( 'Invalid item' ),
|
|
74
75
|
},
|
|
76
|
+
__experimentalRenderItem,
|
|
75
77
|
__experimentalExpandOnFocus = false,
|
|
76
78
|
__experimentalValidateInput = () => true,
|
|
77
79
|
__experimentalShowHowTo = true,
|
|
@@ -659,12 +661,12 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
659
661
|
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
660
662
|
return (
|
|
661
663
|
<div { ...tokenFieldProps }>
|
|
662
|
-
<
|
|
664
|
+
<StyledLabel
|
|
663
665
|
htmlFor={ `components-form-token-input-${ instanceId }` }
|
|
664
666
|
className="components-form-token-field__label"
|
|
665
667
|
>
|
|
666
668
|
{ label }
|
|
667
|
-
</
|
|
669
|
+
</StyledLabel>
|
|
668
670
|
<div
|
|
669
671
|
ref={ tokensAndInput }
|
|
670
672
|
className={ classes }
|
|
@@ -692,6 +694,7 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
692
694
|
scrollIntoView={ selectedSuggestionScroll }
|
|
693
695
|
onHover={ onSuggestionHovered }
|
|
694
696
|
onSelect={ onSuggestionSelected }
|
|
697
|
+
__experimentalRenderItem={ __experimentalRenderItem }
|
|
695
698
|
/>
|
|
696
699
|
) }
|
|
697
700
|
</div>
|
|
@@ -101,3 +101,17 @@ Async.args = {
|
|
|
101
101
|
label: 'Type a continent',
|
|
102
102
|
suggestions: continents,
|
|
103
103
|
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The rendered output of each suggestion can be customized by passing a
|
|
107
|
+
* render function to the `__experimentalRenderItem` prop. (This is still an experimental feature
|
|
108
|
+
* and is subject to change.)
|
|
109
|
+
*/
|
|
110
|
+
export const WithCustomRenderItem: ComponentStory< typeof FormTokenField > =
|
|
111
|
+
DefaultTemplate.bind( {} );
|
|
112
|
+
WithCustomRenderItem.args = {
|
|
113
|
+
...Default.args,
|
|
114
|
+
__experimentalRenderItem: ( { item } ) => (
|
|
115
|
+
<div>{ `${ item } — a nice place to visit` }</div>
|
|
116
|
+
),
|
|
117
|
+
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { map } from 'lodash';
|
|
5
5
|
import scrollView from 'dom-scroll-into-view';
|
|
6
6
|
import classnames from 'classnames';
|
|
7
|
-
import type { MouseEventHandler } from 'react';
|
|
7
|
+
import type { MouseEventHandler, ReactNode } from 'react';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* WordPress dependencies
|
|
@@ -31,6 +31,7 @@ export function SuggestionsList< T extends string | { value: string } >( {
|
|
|
31
31
|
suggestions = [],
|
|
32
32
|
displayTransform,
|
|
33
33
|
instanceId,
|
|
34
|
+
__experimentalRenderItem,
|
|
34
35
|
}: SuggestionsListProps< T > ) {
|
|
35
36
|
const [ scrollingIntoView, setScrollingIntoView ] = useState( false );
|
|
36
37
|
|
|
@@ -122,6 +123,24 @@ export function SuggestionsList< T extends string | { value: string } >( {
|
|
|
122
123
|
}
|
|
123
124
|
);
|
|
124
125
|
|
|
126
|
+
let output: ReactNode;
|
|
127
|
+
|
|
128
|
+
if ( typeof __experimentalRenderItem === 'function' ) {
|
|
129
|
+
output = __experimentalRenderItem( { item: suggestion } );
|
|
130
|
+
} else if ( matchText ) {
|
|
131
|
+
output = (
|
|
132
|
+
<span aria-label={ displayTransform( suggestion ) }>
|
|
133
|
+
{ matchText.suggestionBeforeMatch }
|
|
134
|
+
<strong className="components-form-token-field__suggestion-match">
|
|
135
|
+
{ matchText.suggestionMatch }
|
|
136
|
+
</strong>
|
|
137
|
+
{ matchText.suggestionAfterMatch }
|
|
138
|
+
</span>
|
|
139
|
+
);
|
|
140
|
+
} else {
|
|
141
|
+
output = displayTransform( suggestion );
|
|
142
|
+
}
|
|
143
|
+
|
|
125
144
|
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
126
145
|
return (
|
|
127
146
|
<li
|
|
@@ -139,17 +158,7 @@ export function SuggestionsList< T extends string | { value: string } >( {
|
|
|
139
158
|
onMouseEnter={ handleHover( suggestion ) }
|
|
140
159
|
aria-selected={ index === selectedIndex }
|
|
141
160
|
>
|
|
142
|
-
{
|
|
143
|
-
<span aria-label={ displayTransform( suggestion ) }>
|
|
144
|
-
{ matchText.suggestionBeforeMatch }
|
|
145
|
-
<strong className="components-form-token-field__suggestion-match">
|
|
146
|
-
{ matchText.suggestionMatch }
|
|
147
|
-
</strong>
|
|
148
|
-
{ matchText.suggestionAfterMatch }
|
|
149
|
-
</span>
|
|
150
|
-
) : (
|
|
151
|
-
displayTransform( suggestion )
|
|
152
|
-
) }
|
|
161
|
+
{ output }
|
|
153
162
|
</li>
|
|
154
163
|
);
|
|
155
164
|
/* eslint-enable jsx-a11y/click-events-have-key-events */
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
ComponentPropsWithRef,
|
|
6
|
+
MouseEventHandler,
|
|
7
|
+
ReactNode,
|
|
8
|
+
} from 'react';
|
|
5
9
|
|
|
6
10
|
type Messages = {
|
|
7
11
|
/**
|
|
@@ -154,9 +158,18 @@ export interface FormTokenFieldProps
|
|
|
154
158
|
* @default false
|
|
155
159
|
*/
|
|
156
160
|
__next36pxDefaultSize?: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Custom renderer for suggestions.
|
|
163
|
+
*/
|
|
164
|
+
__experimentalRenderItem?: ( args: { item: string } ) => ReactNode;
|
|
157
165
|
}
|
|
158
166
|
|
|
159
|
-
|
|
167
|
+
/**
|
|
168
|
+
* `T` can be either a `string` or an object which must have a `value` prop as a string.
|
|
169
|
+
*/
|
|
170
|
+
export interface SuggestionsListProps<
|
|
171
|
+
T = string | ( Record< string, unknown > & { value: string } )
|
|
172
|
+
> {
|
|
160
173
|
selectedIndex: number;
|
|
161
174
|
scrollIntoView: boolean;
|
|
162
175
|
match: T;
|
|
@@ -165,6 +178,7 @@ export interface SuggestionsListProps< T = string | { value: string } > {
|
|
|
165
178
|
suggestions: T[];
|
|
166
179
|
displayTransform: ( value: T ) => string;
|
|
167
180
|
instanceId: string | number;
|
|
181
|
+
__experimentalRenderItem?: ( args: { item: T } ) => ReactNode;
|
|
168
182
|
}
|
|
169
183
|
|
|
170
184
|
export interface TokenProps extends TokenItem {
|
package/src/index.js
CHANGED
|
@@ -30,7 +30,10 @@ export {
|
|
|
30
30
|
isEmptyBorder as __experimentalIsEmptyBorder,
|
|
31
31
|
} from './border-box-control';
|
|
32
32
|
export { BorderControl as __experimentalBorderControl } from './border-control';
|
|
33
|
-
export {
|
|
33
|
+
export {
|
|
34
|
+
default as __experimentalBoxControl,
|
|
35
|
+
applyValueToSides as __experimentalApplyValueToSides,
|
|
36
|
+
} from './box-control';
|
|
34
37
|
export { default as Button } from './button';
|
|
35
38
|
export { default as ButtonGroup } from './button-group';
|
|
36
39
|
export {
|
|
@@ -10,6 +10,7 @@ import type { DragProps } from '../types';
|
|
|
10
10
|
|
|
11
11
|
export const CHANGE = 'CHANGE';
|
|
12
12
|
export const COMMIT = 'COMMIT';
|
|
13
|
+
export const CONTROL = 'CONTROL';
|
|
13
14
|
export const DRAG_END = 'DRAG_END';
|
|
14
15
|
export const DRAG_START = 'DRAG_START';
|
|
15
16
|
export const DRAG = 'DRAG';
|
|
@@ -23,7 +24,7 @@ interface EventPayload {
|
|
|
23
24
|
event?: SyntheticEvent;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
interface Action< Type, ExtraPayload = {} > {
|
|
27
|
+
export interface Action< Type = string, ExtraPayload = {} > {
|
|
27
28
|
type: Type;
|
|
28
29
|
payload: EventPayload & ExtraPayload;
|
|
29
30
|
}
|
|
@@ -34,6 +35,7 @@ interface ValuePayload {
|
|
|
34
35
|
|
|
35
36
|
export type ChangeAction = Action< typeof CHANGE, ValuePayload >;
|
|
36
37
|
export type CommitAction = Action< typeof COMMIT, ValuePayload >;
|
|
38
|
+
export type ControlAction = Action< typeof CONTROL, ValuePayload >;
|
|
37
39
|
export type PressUpAction = Action< typeof PRESS_UP >;
|
|
38
40
|
export type PressDownAction = Action< typeof PRESS_DOWN >;
|
|
39
41
|
export type PressEnterAction = Action< typeof PRESS_ENTER >;
|
|
@@ -39,22 +39,32 @@ function mergeInitialState(
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* Creates
|
|
43
|
-
*
|
|
42
|
+
* Creates the base reducer which may be coupled to a specializing reducer.
|
|
43
|
+
* As its final step, for all actions other than CONTROL, the base reducer
|
|
44
|
+
* passes the state and action on through the specializing reducer. The
|
|
45
|
+
* exception for CONTROL actions is because they represent controlled updates
|
|
46
|
+
* from props and no case has yet presented for their specialization.
|
|
44
47
|
*
|
|
45
|
-
*
|
|
46
|
-
* https://kentcdodds.com/blog/the-state-reducer-pattern/
|
|
47
|
-
*
|
|
48
|
-
* @param composedStateReducers A custom reducer that can subscribe and modify state.
|
|
48
|
+
* @param composedStateReducers A reducer to specialize state changes.
|
|
49
49
|
* @return The reducer.
|
|
50
50
|
*/
|
|
51
51
|
function inputControlStateReducer(
|
|
52
52
|
composedStateReducers: StateReducer
|
|
53
|
-
): StateReducer {
|
|
53
|
+
): StateReducer< actions.ControlAction > {
|
|
54
54
|
return ( state, action ) => {
|
|
55
55
|
const nextState = { ...state };
|
|
56
56
|
|
|
57
57
|
switch ( action.type ) {
|
|
58
|
+
/*
|
|
59
|
+
* Controlled updates
|
|
60
|
+
*/
|
|
61
|
+
case actions.CONTROL:
|
|
62
|
+
nextState.value = action.payload.value;
|
|
63
|
+
nextState.isDirty = false;
|
|
64
|
+
nextState._event = undefined;
|
|
65
|
+
// Returns immediately to avoid invoking additional reducers.
|
|
66
|
+
return nextState;
|
|
67
|
+
|
|
58
68
|
/**
|
|
59
69
|
* Keyboard events
|
|
60
70
|
*/
|
|
@@ -140,7 +150,7 @@ export function useInputControlStateReducer(
|
|
|
140
150
|
initialState: Partial< InputState > = initialInputControlState,
|
|
141
151
|
onChangeHandler: InputChangeCallback
|
|
142
152
|
) {
|
|
143
|
-
const [ state, dispatch ] = useReducer
|
|
153
|
+
const [ state, dispatch ] = useReducer(
|
|
144
154
|
inputControlStateReducer( stateReducer ),
|
|
145
155
|
mergeInitialState( initialState )
|
|
146
156
|
);
|
|
@@ -188,10 +198,15 @@ export function useInputControlStateReducer(
|
|
|
188
198
|
|
|
189
199
|
const currentState = useRef( state );
|
|
190
200
|
const refProps = useRef( { value: initialState.value, onChangeHandler } );
|
|
201
|
+
|
|
202
|
+
// Freshens refs to props and state so that subsequent effects have access
|
|
203
|
+
// to their latest values without their changes causing effect runs.
|
|
191
204
|
useLayoutEffect( () => {
|
|
192
205
|
currentState.current = state;
|
|
193
206
|
refProps.current = { value: initialState.value, onChangeHandler };
|
|
194
207
|
} );
|
|
208
|
+
|
|
209
|
+
// Propagates the latest state through onChange.
|
|
195
210
|
useLayoutEffect( () => {
|
|
196
211
|
if (
|
|
197
212
|
currentState.current._event !== undefined &&
|
|
@@ -205,14 +220,16 @@ export function useInputControlStateReducer(
|
|
|
205
220
|
} );
|
|
206
221
|
}
|
|
207
222
|
}, [ state.value, state.isDirty ] );
|
|
223
|
+
|
|
224
|
+
// Updates the state from props.
|
|
208
225
|
useLayoutEffect( () => {
|
|
209
226
|
if (
|
|
210
227
|
initialState.value !== currentState.current.value &&
|
|
211
228
|
! currentState.current.isDirty
|
|
212
229
|
) {
|
|
213
230
|
dispatch( {
|
|
214
|
-
type: actions.
|
|
215
|
-
payload: { value: initialState.value },
|
|
231
|
+
type: actions.CONTROL,
|
|
232
|
+
payload: { value: initialState.value ?? '' },
|
|
216
233
|
} );
|
|
217
234
|
}
|
|
218
235
|
}, [ initialState.value ] );
|
|
@@ -6,7 +6,7 @@ import type { Reducer, SyntheticEvent } from 'react';
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import type { InputAction } from './actions';
|
|
9
|
+
import type { Action, InputAction } from './actions';
|
|
10
10
|
|
|
11
11
|
export interface InputState {
|
|
12
12
|
_event?: SyntheticEvent;
|
|
@@ -19,7 +19,12 @@ export interface InputState {
|
|
|
19
19
|
value?: string;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export type StateReducer =
|
|
22
|
+
export type StateReducer< SpecializedAction = {} > = Reducer<
|
|
23
|
+
InputState,
|
|
24
|
+
SpecializedAction extends Action
|
|
25
|
+
? InputAction | SpecializedAction
|
|
26
|
+
: InputAction
|
|
27
|
+
>;
|
|
23
28
|
|
|
24
29
|
export const initialStateReducer: StateReducer = ( state: InputState ) => state;
|
|
25
30
|
|
|
@@ -11,7 +11,7 @@ import type { CSSProperties, ReactNode } from 'react';
|
|
|
11
11
|
import type { WordPressComponentProps } from '../../ui/context';
|
|
12
12
|
import { Flex, FlexItem } from '../../flex';
|
|
13
13
|
import { Text } from '../../text';
|
|
14
|
-
import { COLORS, rtl } from '../../utils';
|
|
14
|
+
import { baseLabelTypography, COLORS, rtl } from '../../utils';
|
|
15
15
|
import type { LabelPosition, Size } from '../types';
|
|
16
16
|
import { space } from '../../ui/utils/space';
|
|
17
17
|
|
|
@@ -272,6 +272,8 @@ const labelMargin = ( {
|
|
|
272
272
|
|
|
273
273
|
const BaseLabel = styled( Text )< { labelPosition?: LabelPosition } >`
|
|
274
274
|
&&& {
|
|
275
|
+
${ baseLabelTypography };
|
|
276
|
+
|
|
275
277
|
box-sizing: border-box;
|
|
276
278
|
display: block;
|
|
277
279
|
padding-top: 0;
|
|
@@ -85,9 +85,10 @@ describe( 'InputControl', () => {
|
|
|
85
85
|
expect( spy ).toHaveBeenLastCalledWith( 'Hello there' );
|
|
86
86
|
} );
|
|
87
87
|
|
|
88
|
-
it( 'should work as a controlled component', async () => {
|
|
88
|
+
it( 'should work as a controlled component given normal, falsy or nullish values', async () => {
|
|
89
89
|
const user = setupUser();
|
|
90
90
|
const spy = jest.fn();
|
|
91
|
+
const heldKeySet = new Set();
|
|
91
92
|
const Example = () => {
|
|
92
93
|
const [ state, setState ] = useState( 'one' );
|
|
93
94
|
const onChange = ( value ) => {
|
|
@@ -95,13 +96,21 @@ describe( 'InputControl', () => {
|
|
|
95
96
|
spy( value );
|
|
96
97
|
};
|
|
97
98
|
const onKeyDown = ( { key } ) => {
|
|
98
|
-
|
|
99
|
+
heldKeySet.add( key );
|
|
100
|
+
if ( key === 'Escape' ) {
|
|
101
|
+
if ( heldKeySet.has( 'Meta' ) ) setState( 'qux' );
|
|
102
|
+
else if ( heldKeySet.has( 'Alt' ) )
|
|
103
|
+
setState( undefined );
|
|
104
|
+
else setState( '' );
|
|
105
|
+
}
|
|
99
106
|
};
|
|
107
|
+
const onKeyUp = ( { key } ) => heldKeySet.delete( key );
|
|
100
108
|
return (
|
|
101
109
|
<InputControl
|
|
102
110
|
value={ state }
|
|
103
111
|
onChange={ onChange }
|
|
104
112
|
onKeyDown={ onKeyDown }
|
|
113
|
+
onKeyUp={ onKeyUp }
|
|
105
114
|
/>
|
|
106
115
|
);
|
|
107
116
|
};
|
|
@@ -109,10 +118,17 @@ describe( 'InputControl', () => {
|
|
|
109
118
|
const input = getInput();
|
|
110
119
|
|
|
111
120
|
await user.type( input, '2' );
|
|
112
|
-
// Make a controlled update.
|
|
121
|
+
// Make a controlled update with a falsy value.
|
|
113
122
|
await user.keyboard( '{Escape}' );
|
|
123
|
+
expect( input ).toHaveValue( '' );
|
|
114
124
|
|
|
115
|
-
|
|
125
|
+
// Make a controlled update with a normal value.
|
|
126
|
+
await user.keyboard( '{Meta>}{Escape}{/Meta}' );
|
|
127
|
+
expect( input ).toHaveValue( 'qux' );
|
|
128
|
+
|
|
129
|
+
// Make a controlled update with a nullish value.
|
|
130
|
+
await user.keyboard( '{Alt>}{Escape}{/Alt}' );
|
|
131
|
+
expect( input ).toHaveValue( '' );
|
|
116
132
|
/*
|
|
117
133
|
* onChange called only once. onChange is not called when a
|
|
118
134
|
* parent component explicitly passed a (new value) change down to
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { find,
|
|
4
|
+
import { find, get, camelCase, has } from 'lodash';
|
|
5
5
|
import { Dimensions } from 'react-native';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -32,6 +32,7 @@ const BLOCK_STYLE_ATTRIBUTES_MAPPING = {
|
|
|
32
32
|
|
|
33
33
|
const PADDING = 12; // $solid-border-space
|
|
34
34
|
const UNKNOWN_VALUE = 'undefined';
|
|
35
|
+
const DEFAULT_FONT_SIZE = 16;
|
|
35
36
|
|
|
36
37
|
export function getBlockPaddings(
|
|
37
38
|
mergedStyle,
|
|
@@ -103,7 +104,7 @@ export function getBlockColors(
|
|
|
103
104
|
|
|
104
105
|
// Custom colors.
|
|
105
106
|
Object.entries( blockStyleAttributes ).forEach( ( [ key, value ] ) => {
|
|
106
|
-
const isCustomColor = startsWith(
|
|
107
|
+
const isCustomColor = value?.startsWith?.( '#' );
|
|
107
108
|
let styleKey = key;
|
|
108
109
|
|
|
109
110
|
if ( BLOCK_STYLE_ATTRIBUTES_MAPPING[ styleKey ] ) {
|
|
@@ -190,7 +191,7 @@ export function getBlockTypography(
|
|
|
190
191
|
|
|
191
192
|
export function parseStylesVariables( styles, mappedValues, customValues ) {
|
|
192
193
|
let stylesBase = styles;
|
|
193
|
-
const variables = [ 'preset', 'custom', 'var' ];
|
|
194
|
+
const variables = [ 'preset', 'custom', 'var', 'fontSize' ];
|
|
194
195
|
|
|
195
196
|
if ( ! stylesBase ) {
|
|
196
197
|
return styles;
|
|
@@ -203,6 +204,7 @@ export function parseStylesVariables( styles, mappedValues, customValues ) {
|
|
|
203
204
|
// var:preset|color|custom-color-2
|
|
204
205
|
const regex = new RegExp( `var\\(--wp--${ variable }--(.*?)\\)`, 'g' );
|
|
205
206
|
const varRegex = /\"var:preset\|color\|(.*?)\"/gm;
|
|
207
|
+
const fontSizeRegex = /"fontSize":"(.*?)"/gm;
|
|
206
208
|
|
|
207
209
|
if ( variable === 'preset' ) {
|
|
208
210
|
stylesBase = stylesBase.replace( regex, ( _$1, $2 ) => {
|
|
@@ -244,6 +246,21 @@ export function parseStylesVariables( styles, mappedValues, customValues ) {
|
|
|
244
246
|
return UNKNOWN_VALUE;
|
|
245
247
|
} );
|
|
246
248
|
}
|
|
249
|
+
|
|
250
|
+
if ( variable === 'fontSize' ) {
|
|
251
|
+
const { width, height } = Dimensions.get( 'window' );
|
|
252
|
+
|
|
253
|
+
stylesBase = stylesBase.replace( fontSizeRegex, ( _$1, $2 ) => {
|
|
254
|
+
const parsedFontSize =
|
|
255
|
+
getPxFromCssUnit( $2, {
|
|
256
|
+
width,
|
|
257
|
+
height,
|
|
258
|
+
fontSize: DEFAULT_FONT_SIZE,
|
|
259
|
+
} ) || `${ DEFAULT_FONT_SIZE }px`;
|
|
260
|
+
|
|
261
|
+
return `"fontSize":"${ parsedFontSize }"`;
|
|
262
|
+
} );
|
|
263
|
+
}
|
|
247
264
|
} );
|
|
248
265
|
|
|
249
266
|
return JSON.parse( stylesBase );
|
|
@@ -297,7 +314,7 @@ function normalizeFontSizes( fontSizes ) {
|
|
|
297
314
|
{
|
|
298
315
|
width: dimensions.width,
|
|
299
316
|
height: dimensions.height,
|
|
300
|
-
fontSize:
|
|
317
|
+
fontSize: DEFAULT_FONT_SIZE,
|
|
301
318
|
}
|
|
302
319
|
);
|
|
303
320
|
return fontSizeObject;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Image as RNImage,
|
|
6
|
+
Text,
|
|
7
|
+
View,
|
|
8
|
+
useWindowDimensions,
|
|
9
|
+
} from 'react-native';
|
|
5
10
|
import FastImage from 'react-native-fast-image';
|
|
6
11
|
|
|
7
12
|
/**
|
|
@@ -11,7 +16,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
11
16
|
import { Icon } from '@wordpress/components';
|
|
12
17
|
import { image as icon } from '@wordpress/icons';
|
|
13
18
|
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
14
|
-
import { useEffect, useState } from '@wordpress/element';
|
|
19
|
+
import { useEffect, useState, useRef, Platform } from '@wordpress/element';
|
|
15
20
|
|
|
16
21
|
/**
|
|
17
22
|
* Internal dependencies
|
|
@@ -54,6 +59,10 @@ const ImageComponent = ( {
|
|
|
54
59
|
} ) => {
|
|
55
60
|
const [ imageData, setImageData ] = useState( null );
|
|
56
61
|
const [ containerSize, setContainerSize ] = useState( null );
|
|
62
|
+
const [ shouldUseFallback, setShouldUseFallback ] = useState( false );
|
|
63
|
+
const { height: windowHeight, width: windowWidth } = useWindowDimensions();
|
|
64
|
+
const isLandscape = useRef( windowWidth > windowHeight );
|
|
65
|
+
|
|
57
66
|
const Image = ! shouldUseFastImage ? RNImage : FastImage;
|
|
58
67
|
const imageResizeMode = ! shouldUseFastImage
|
|
59
68
|
? resizeMode
|
|
@@ -80,6 +89,21 @@ const ImageComponent = ( {
|
|
|
80
89
|
return () => ( isCurrent = false );
|
|
81
90
|
}, [ url ] );
|
|
82
91
|
|
|
92
|
+
// Workaround for Android where changing the orientation breaks FastImage
|
|
93
|
+
// for now if there's any orientation changes, it will use the fallback
|
|
94
|
+
// prop to use the default Image component.
|
|
95
|
+
// https://github.com/WordPress/gutenberg/issues/42869
|
|
96
|
+
useEffect( () => {
|
|
97
|
+
if ( Platform.isAndroid && shouldUseFastImage ) {
|
|
98
|
+
const isCurrentOrientationLandscape = windowWidth > windowHeight;
|
|
99
|
+
|
|
100
|
+
if ( isLandscape.current !== isCurrentOrientationLandscape ) {
|
|
101
|
+
setShouldUseFallback( true );
|
|
102
|
+
isLandscape.current = isCurrentOrientationLandscape;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}, [ windowHeight, windowWidth ] );
|
|
106
|
+
|
|
83
107
|
const onContainerLayout = ( event ) => {
|
|
84
108
|
const { height, width } = event.nativeEvent.layout;
|
|
85
109
|
|
|
@@ -226,6 +250,7 @@ const ImageComponent = ( {
|
|
|
226
250
|
resizeMethod: 'scale',
|
|
227
251
|
} ) }
|
|
228
252
|
resizeMode={ imageResizeMode }
|
|
253
|
+
fallback={ shouldUseFallback }
|
|
229
254
|
/>
|
|
230
255
|
</View>
|
|
231
256
|
) }
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Keyboard } from 'react-native';
|
|
5
5
|
import { useNavigation, useRoute } from '@react-navigation/native';
|
|
6
|
-
import { delay } from 'lodash';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* WordPress dependencies
|
|
10
9
|
*/
|
|
11
|
-
import { useMemo } from '@wordpress/element';
|
|
10
|
+
import { useEffect, useMemo, useRef } from '@wordpress/element';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Internal dependencies
|
|
@@ -18,10 +17,12 @@ import { LinkPicker } from './';
|
|
|
18
17
|
const LinkPickerScreen = ( { returnScreenName } ) => {
|
|
19
18
|
const navigation = useNavigation();
|
|
20
19
|
const route = useRoute();
|
|
20
|
+
const navigateToLinkTimeoutRef = useRef( null );
|
|
21
|
+
const navigateBackTimeoutRef = useRef( null );
|
|
21
22
|
|
|
22
23
|
const onLinkPicked = ( { url, title } ) => {
|
|
23
24
|
Keyboard.dismiss();
|
|
24
|
-
|
|
25
|
+
navigateToLinkTimeoutRef.current = setTimeout( () => {
|
|
25
26
|
navigation.navigate( returnScreenName, {
|
|
26
27
|
inputValue: url,
|
|
27
28
|
text: title,
|
|
@@ -31,11 +32,18 @@ const LinkPickerScreen = ( { returnScreenName } ) => {
|
|
|
31
32
|
|
|
32
33
|
const onCancel = () => {
|
|
33
34
|
Keyboard.dismiss();
|
|
34
|
-
|
|
35
|
+
navigateBackTimeoutRef.current = setTimeout( () => {
|
|
35
36
|
navigation.goBack();
|
|
36
37
|
}, 100 );
|
|
37
38
|
};
|
|
38
39
|
|
|
40
|
+
useEffect( () => {
|
|
41
|
+
return () => {
|
|
42
|
+
clearTimeout( navigateToLinkTimeoutRef.current );
|
|
43
|
+
clearTimeout( navigateBackTimeoutRef.current );
|
|
44
|
+
};
|
|
45
|
+
}, [] );
|
|
46
|
+
|
|
39
47
|
const { inputValue } = route.params;
|
|
40
48
|
return useMemo( () => {
|
|
41
49
|
return (
|
|
@@ -10,6 +10,12 @@ import { __ } from '@wordpress/i18n';
|
|
|
10
10
|
import { Component, forwardRef, useContext } from '@wordpress/element';
|
|
11
11
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
12
12
|
import { BottomSheetContext } from '@wordpress/components';
|
|
13
|
+
import { usePreferredColorScheme } from '@wordpress/compose';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
import styles from './styles.scss';
|
|
13
19
|
|
|
14
20
|
class Picker extends Component {
|
|
15
21
|
presentPicker() {
|
|
@@ -23,10 +29,16 @@ class Picker extends Component {
|
|
|
23
29
|
isBottomSheetOpened,
|
|
24
30
|
closeBottomSheet,
|
|
25
31
|
onHandleClosingBottomSheet,
|
|
32
|
+
colorScheme,
|
|
26
33
|
} = this.props;
|
|
27
34
|
const labels = options.map( ( { label } ) => label );
|
|
28
35
|
const fullOptions = [ __( 'Cancel' ) ].concat( labels );
|
|
29
36
|
|
|
37
|
+
const buttonTitleColor =
|
|
38
|
+
colorScheme === 'light'
|
|
39
|
+
? styles[ 'components-picker__button-title' ].color
|
|
40
|
+
: styles[ 'components-picker__button-title--dark' ].color;
|
|
41
|
+
|
|
30
42
|
ActionSheetIOS.showActionSheetWithOptions(
|
|
31
43
|
{
|
|
32
44
|
title,
|
|
@@ -35,6 +47,7 @@ class Picker extends Component {
|
|
|
35
47
|
destructiveButtonIndex,
|
|
36
48
|
disabledButtonIndices,
|
|
37
49
|
anchor: getAnchor && getAnchor(),
|
|
50
|
+
tintColor: buttonTitleColor,
|
|
38
51
|
},
|
|
39
52
|
( buttonIndex ) => {
|
|
40
53
|
if ( buttonIndex === 0 ) {
|
|
@@ -66,6 +79,8 @@ const PickerComponent = forwardRef( ( props, ref ) => {
|
|
|
66
79
|
const { closeGeneralSidebar } = useDispatch( 'core/edit-post' );
|
|
67
80
|
const { onHandleClosingBottomSheet } = useContext( BottomSheetContext );
|
|
68
81
|
|
|
82
|
+
const colorScheme = usePreferredColorScheme();
|
|
83
|
+
|
|
69
84
|
return (
|
|
70
85
|
<Picker
|
|
71
86
|
ref={ ref }
|
|
@@ -73,6 +88,7 @@ const PickerComponent = forwardRef( ( props, ref ) => {
|
|
|
73
88
|
isBottomSheetOpened={ isBottomSheetOpened }
|
|
74
89
|
closeBottomSheet={ closeGeneralSidebar }
|
|
75
90
|
onHandleClosingBottomSheet={ onHandleClosingBottomSheet }
|
|
91
|
+
colorScheme={ colorScheme }
|
|
76
92
|
/>
|
|
77
93
|
);
|
|
78
94
|
} );
|
package/src/panel/style.scss
CHANGED
|
@@ -35,9 +35,12 @@
|
|
|
35
35
|
justify-content: space-between;
|
|
36
36
|
align-items: center;
|
|
37
37
|
padding: 0 $grid-unit-20;
|
|
38
|
-
height: $grid-unit-60;
|
|
39
38
|
border-bottom: $border-width solid $gray-300;
|
|
40
39
|
|
|
40
|
+
// This helps ensure the correct panel height, including the border, avoiding subpixel rounding issues.
|
|
41
|
+
box-sizing: content-box;
|
|
42
|
+
height: $grid-unit-60 - $border-width;
|
|
43
|
+
|
|
41
44
|
h2 {
|
|
42
45
|
margin: 0;
|
|
43
46
|
font-size: inherit;
|