@wordpress/components 19.1.2 → 19.2.1-next.33ec3857e2.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 +53 -4
- package/README.md +0 -1
- package/build/angle-picker-control/index.js +2 -0
- package/build/angle-picker-control/index.js.map +1 -1
- package/build/button/index.native.js +13 -3
- package/build/button/index.native.js.map +1 -1
- package/build/checkbox-control/index.js +1 -1
- package/build/checkbox-control/index.js.map +1 -1
- package/build/clipboard-button/index.js +1 -2
- package/build/clipboard-button/index.js.map +1 -1
- package/build/color-palette/index.js +36 -9
- package/build/color-palette/index.js.map +1 -1
- package/build/color-picker/color-display.js +4 -2
- package/build/color-picker/color-display.js.map +1 -1
- package/build/color-picker/hex-input.js +3 -1
- package/build/color-picker/hex-input.js.map +1 -1
- package/build/color-picker/input-with-slider.js +3 -1
- package/build/color-picker/input-with-slider.js.map +1 -1
- package/build/confirm-dialog/component.js +103 -0
- package/build/confirm-dialog/component.js.map +1 -0
- package/build/confirm-dialog/index.js +16 -0
- package/build/confirm-dialog/index.js.map +1 -0
- package/build/confirm-dialog/types.js +6 -0
- package/build/confirm-dialog/types.js.map +1 -0
- package/build/custom-gradient-bar/constants.js +1 -6
- package/build/custom-gradient-bar/constants.js.map +1 -1
- package/build/custom-gradient-bar/control-points.js +52 -21
- package/build/custom-gradient-bar/control-points.js.map +1 -1
- package/build/custom-gradient-bar/index.js +5 -1
- package/build/custom-gradient-bar/index.js.map +1 -1
- package/build/custom-gradient-picker/index.js +4 -1
- package/build/custom-gradient-picker/index.js.map +1 -1
- package/build/date-time/date.js +63 -86
- package/build/date-time/date.js.map +1 -1
- package/build/date-time/utils.js +32 -0
- package/build/date-time/utils.js.map +1 -0
- package/build/divider/component.js +8 -7
- package/build/divider/component.js.map +1 -1
- package/build/divider/styles.js +38 -13
- package/build/divider/styles.js.map +1 -1
- package/build/drop-zone/index.js +14 -6
- package/build/drop-zone/index.js.map +1 -1
- package/build/drop-zone/provider.js +1 -0
- package/build/drop-zone/provider.js.map +1 -1
- package/build/flyout/styles.js +2 -2
- package/build/flyout/styles.js.map +1 -1
- package/build/focusable-iframe/index.js +1 -0
- package/build/focusable-iframe/index.js.map +1 -1
- package/build/font-size-picker/index.js +10 -9
- package/build/font-size-picker/index.js.map +1 -1
- package/build/font-size-picker/utils.js +28 -17
- package/build/font-size-picker/utils.js.map +1 -1
- package/build/gradient-picker/index.js +3 -1
- package/build/gradient-picker/index.js.map +1 -1
- package/build/higher-order/with-focus-outside/index.js +2 -0
- package/build/higher-order/with-focus-outside/index.js.map +1 -1
- package/build/index.js +8 -0
- package/build/index.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +44 -32
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/mobile/bottom-sheet/link-suggestion-item-cell.native.js +10 -3
- package/build/mobile/bottom-sheet/link-suggestion-item-cell.native.js.map +1 -1
- package/build/mobile/color-settings/index.native.js +4 -2
- package/build/mobile/color-settings/index.native.js.map +1 -1
- package/build/mobile/color-settings/palette.screen.native.js +7 -6
- package/build/mobile/color-settings/palette.screen.native.js.map +1 -1
- package/build/mobile/global-styles-context/utils.native.js +1 -1
- package/build/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build/mobile/gridicons/index.native.js +3 -1
- package/build/mobile/gridicons/index.native.js.map +1 -1
- package/build/mobile/link-picker/index.native.js +45 -4
- package/build/mobile/link-picker/index.native.js.map +1 -1
- package/build/mobile/link-settings/index.native.js +10 -0
- package/build/mobile/link-settings/index.native.js.map +1 -1
- package/build/modal/aria-helper.js +2 -0
- package/build/modal/aria-helper.js.map +1 -1
- package/build/modal/index.js +17 -8
- package/build/modal/index.js.map +1 -1
- package/build/palette-edit/index.js +13 -11
- package/build/palette-edit/index.js.map +1 -1
- package/build/select-control/styles/select-control-styles.js +33 -9
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- package/build/style-provider/index.js +2 -0
- package/build/style-provider/index.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js +7 -2
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js +25 -14
- package/build/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option/styles.js +8 -8
- package/build/toggle-group-control/toggle-group-control-option/styles.js.map +1 -1
- package/build/tools-panel/styles.js +12 -10
- package/build/tools-panel/styles.js.map +1 -1
- package/build/tools-panel/tools-panel/component.js +6 -8
- package/build/tools-panel/tools-panel/component.js.map +1 -1
- package/build/tools-panel/tools-panel/hook.js +48 -17
- package/build/tools-panel/tools-panel/hook.js.map +1 -1
- package/build/tools-panel/tools-panel-item/hook.js +5 -1
- package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build/unit-control/styles/unit-control-styles.js +23 -41
- package/build/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build/z-stack/component.js.map +1 -1
- package/build/z-stack/styles.js +10 -8
- package/build/z-stack/styles.js.map +1 -1
- package/build-module/angle-picker-control/index.js +2 -0
- package/build-module/angle-picker-control/index.js.map +1 -1
- package/build-module/button/index.native.js +13 -3
- package/build-module/button/index.native.js.map +1 -1
- package/build-module/checkbox-control/index.js +1 -1
- package/build-module/checkbox-control/index.js.map +1 -1
- package/build-module/clipboard-button/index.js +1 -2
- package/build-module/clipboard-button/index.js.map +1 -1
- package/build-module/color-palette/index.js +34 -10
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-picker/color-display.js +3 -2
- package/build-module/color-picker/color-display.js.map +1 -1
- package/build-module/color-picker/hex-input.js +2 -1
- package/build-module/color-picker/hex-input.js.map +1 -1
- package/build-module/color-picker/input-with-slider.js +2 -1
- package/build-module/color-picker/input-with-slider.js.map +1 -1
- package/build-module/confirm-dialog/component.js +84 -0
- package/build-module/confirm-dialog/component.js.map +1 -0
- package/build-module/confirm-dialog/index.js +6 -0
- package/build-module/confirm-dialog/index.js.map +1 -0
- package/build-module/confirm-dialog/types.js +2 -0
- package/build-module/confirm-dialog/types.js.map +1 -0
- package/build-module/custom-gradient-bar/constants.js +0 -4
- package/build-module/custom-gradient-bar/constants.js.map +1 -1
- package/build-module/custom-gradient-bar/control-points.js +54 -23
- package/build-module/custom-gradient-bar/control-points.js.map +1 -1
- package/build-module/custom-gradient-bar/index.js +5 -1
- package/build-module/custom-gradient-bar/index.js.map +1 -1
- package/build-module/custom-gradient-picker/index.js +4 -1
- package/build-module/custom-gradient-picker/index.js.map +1 -1
- package/build-module/date-time/date.js +63 -87
- package/build-module/date-time/date.js.map +1 -1
- package/build-module/date-time/utils.js +20 -0
- package/build-module/date-time/utils.js.map +1 -0
- package/build-module/divider/component.js +8 -7
- package/build-module/divider/component.js.map +1 -1
- package/build-module/divider/styles.js +37 -13
- package/build-module/divider/styles.js.map +1 -1
- package/build-module/drop-zone/index.js +14 -6
- package/build-module/drop-zone/index.js.map +1 -1
- package/build-module/drop-zone/provider.js +1 -0
- package/build-module/drop-zone/provider.js.map +1 -1
- package/build-module/flyout/styles.js +2 -2
- package/build-module/flyout/styles.js.map +1 -1
- package/build-module/focusable-iframe/index.js +1 -0
- package/build-module/focusable-iframe/index.js.map +1 -1
- package/build-module/font-size-picker/index.js +10 -9
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/font-size-picker/utils.js +28 -17
- package/build-module/font-size-picker/utils.js.map +1 -1
- package/build-module/gradient-picker/index.js +3 -1
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/higher-order/with-focus-outside/index.js +1 -0
- package/build-module/higher-order/with-focus-outside/index.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +44 -32
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/mobile/bottom-sheet/link-suggestion-item-cell.native.js +10 -4
- package/build-module/mobile/bottom-sheet/link-suggestion-item-cell.native.js.map +1 -1
- package/build-module/mobile/color-settings/index.native.js +4 -2
- package/build-module/mobile/color-settings/index.native.js.map +1 -1
- package/build-module/mobile/color-settings/palette.screen.native.js +7 -6
- package/build-module/mobile/color-settings/palette.screen.native.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/mobile/gridicons/index.native.js +1 -0
- package/build-module/mobile/gridicons/index.native.js.map +1 -1
- package/build-module/mobile/link-picker/index.native.js +50 -8
- package/build-module/mobile/link-picker/index.native.js.map +1 -1
- package/build-module/mobile/link-settings/index.native.js +10 -0
- package/build-module/mobile/link-settings/index.native.js.map +1 -1
- package/build-module/modal/aria-helper.js +2 -0
- package/build-module/modal/aria-helper.js.map +1 -1
- package/build-module/modal/index.js +15 -8
- package/build-module/modal/index.js.map +1 -1
- package/build-module/palette-edit/index.js +13 -11
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/select-control/styles/select-control-styles.js +33 -9
- package/build-module/select-control/styles/select-control-styles.js.map +1 -1
- package/build-module/style-provider/index.js +1 -0
- package/build-module/style-provider/index.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js +8 -3
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js +25 -14
- package/build-module/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option/styles.js +8 -8
- package/build-module/toggle-group-control/toggle-group-control-option/styles.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/component.js +5 -8
- package/build-module/tools-panel/tools-panel/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel/hook.js +48 -17
- package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
- package/build-module/tools-panel/tools-panel-item/hook.js +5 -1
- package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build-module/unit-control/styles/unit-control-styles.js +23 -41
- package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build-module/z-stack/component.js.map +1 -1
- package/build-module/z-stack/styles.js +13 -8
- package/build-module/z-stack/styles.js.map +1 -1
- package/build-style/style-rtl.css +34 -12
- package/build-style/style.css +34 -12
- package/build-types/base-field/hook.d.ts +16 -16
- package/build-types/card/card/hook.d.ts +16 -16
- package/build-types/card/card-body/hook.d.ts +16 -16
- package/build-types/card/card-divider/hook.d.ts +18 -18
- package/build-types/card/card-footer/hook.d.ts +17 -17
- package/build-types/card/card-header/hook.d.ts +16 -16
- package/build-types/card/card-media/hook.d.ts +16 -16
- package/build-types/divider/component.d.ts +8 -7
- package/build-types/divider/component.d.ts.map +1 -1
- package/build-types/divider/styles.d.ts +2 -2
- package/build-types/divider/styles.d.ts.map +1 -1
- package/build-types/divider/types.d.ts +5 -5
- package/build-types/divider/types.d.ts.map +1 -1
- package/build-types/elevation/hook.d.ts +15 -15
- package/build-types/flex/flex/hook.d.ts +16 -16
- package/build-types/flex/flex-block/hook.d.ts +16 -16
- package/build-types/flex/flex-item/hook.d.ts +16 -16
- package/build-types/flyout/flyout/hook.d.ts +17 -17
- package/build-types/flyout/styles.d.ts +7 -9
- package/build-types/flyout/styles.d.ts.map +1 -1
- package/build-types/grid/hook.d.ts +16 -16
- package/build-types/h-stack/hook.d.ts +16 -16
- package/build-types/heading/hook.d.ts +16 -16
- package/build-types/input-control/index.d.ts +1 -1
- 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/styles/input-control-styles.d.ts +1 -2
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +2 -1
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/item-group/item/hook.d.ts +16 -16
- package/build-types/item-group/item-group/hook.d.ts +16 -16
- package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
- package/build-types/scrollable/hook.d.ts +16 -16
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/select-control/types.d.ts +1 -1
- package/build-types/select-control/types.d.ts.map +1 -1
- package/build-types/spacer/hook.d.ts +16 -16
- package/build-types/surface/hook.d.ts +16 -16
- package/build-types/text/hook.d.ts +16 -16
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts.map +1 -1
- package/build-types/tools-panel/styles.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts +16 -16
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/hook.d.ts +16 -16
- package/build-types/tools-panel/tools-panel-item/hook.d.ts +16 -16
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/build-types/tools-panel/types.d.ts +2 -1
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/build-types/truncate/hook.d.ts +16 -16
- package/build-types/ui/control-group/hook.d.ts +18 -18
- package/build-types/ui/control-label/hook.d.ts +16 -16
- package/build-types/ui/form-group/form-group.d.ts +4 -4
- package/build-types/ui/form-group/use-form-group.d.ts +55 -55
- package/build-types/unit-control/index.d.ts +1 -1
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -0
- package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
- package/build-types/unit-control/types.d.ts +2 -2
- package/build-types/unit-control/types.d.ts.map +1 -1
- package/build-types/v-stack/hook.d.ts +16 -16
- package/build-types/z-stack/component.d.ts +1 -1
- package/build-types/z-stack/styles.d.ts.map +1 -1
- package/package.json +21 -23
- package/src/alignment-matrix-control/stories/index.js +1 -1
- package/src/angle-picker-control/index.js +2 -0
- package/src/base-control/stories/index.js +1 -1
- package/src/button/index.native.js +15 -1
- package/src/button/stories/index.js +1 -1
- package/src/button/style.scss +14 -0
- package/src/card/card/README.md +3 -3
- package/src/card/stories/index.js +1 -1
- package/src/card/test/__snapshots__/index.js.snap +6 -6
- package/src/checkbox-control/index.js +1 -1
- package/src/checkbox-control/stories/index.js +1 -1
- package/src/clipboard-button/index.js +1 -2
- package/src/color-indicator/stories/index.js +1 -1
- package/src/color-indicator/style.scss +5 -8
- package/src/color-palette/index.js +37 -9
- package/src/color-palette/stories/index.js +1 -1
- package/src/color-palette/style.scss +10 -1
- package/src/color-palette/test/__snapshots__/index.js.snap +30 -21
- package/src/color-picker/color-display.tsx +3 -2
- package/src/color-picker/hex-input.tsx +2 -1
- package/src/color-picker/input-with-slider.tsx +2 -1
- package/src/color-picker/stories/index.js +1 -1
- package/src/combobox-control/README.md +2 -2
- package/src/confirm-dialog/README.md +128 -0
- package/src/confirm-dialog/component.tsx +114 -0
- package/src/confirm-dialog/index.tsx +6 -0
- package/src/confirm-dialog/stories/index.js +120 -0
- package/src/confirm-dialog/test/index.js +302 -0
- package/src/confirm-dialog/types.ts +26 -0
- package/src/custom-gradient-bar/constants.js +0 -5
- package/src/custom-gradient-bar/control-points.js +40 -9
- package/src/custom-gradient-bar/index.js +8 -0
- package/src/custom-gradient-picker/index.js +9 -1
- package/src/custom-gradient-picker/style.scss +0 -4
- package/src/date-time/README.md +7 -0
- package/src/date-time/date.js +67 -84
- package/src/date-time/stories/index.js +1 -1
- package/src/date-time/stories/time.js +1 -1
- package/src/date-time/test/date.js +3 -29
- package/src/date-time/test/utils.js +32 -0
- package/src/date-time/utils.js +18 -0
- package/src/dimension-control/README.md +1 -1
- package/src/divider/README.md +33 -5
- package/src/divider/component.tsx +8 -7
- package/src/divider/stories/index.js +43 -17
- package/src/divider/styles.ts +53 -16
- package/src/divider/test/__snapshots__/index.js.snap +11 -11
- package/src/divider/test/index.js +4 -4
- package/src/divider/types.ts +5 -5
- package/src/drop-zone/index.js +14 -6
- package/src/drop-zone/provider.js +1 -0
- package/src/dropdown-menu/stories/index.js +1 -1
- package/src/duotone-picker/README.md +1 -1
- package/src/elevation/stories/index.js +1 -1
- package/src/external-link/stories/index.js +1 -1
- package/src/flyout/styles.ts +4 -2
- package/src/focusable-iframe/index.js +1 -0
- package/src/font-size-picker/index.js +27 -13
- package/src/font-size-picker/stories/index.js +63 -1
- package/src/font-size-picker/test/index.js +87 -0
- package/src/font-size-picker/test/util.js +74 -0
- package/src/font-size-picker/utils.js +31 -17
- package/src/form-token-field/stories/index.js +1 -1
- package/src/gradient-picker/index.js +4 -0
- package/src/gradient-picker/stories/index.js +1 -1
- package/src/grid/stories/index.js +1 -1
- package/src/guide/stories/index.js +1 -1
- package/src/higher-order/with-focus-outside/index.js +2 -0
- package/src/icon/stories/index.js +1 -1
- package/src/index.js +1 -0
- package/src/input-control/stories/index.js +2 -1
- package/src/input-control/styles/input-control-styles.tsx +16 -6
- package/src/input-control/types.ts +3 -1
- package/src/item-group/stories/index.js +84 -2
- package/src/menu-item/README.md +2 -2
- package/src/mobile/bottom-sheet/link-suggestion-item-cell.native.js +6 -2
- package/src/mobile/color-settings/index.native.js +2 -0
- package/src/mobile/color-settings/palette.screen.native.js +8 -5
- package/src/mobile/color-settings/style.native.scss +1 -1
- package/src/mobile/global-styles-context/utils.native.js +1 -1
- package/src/mobile/gridicons/index.native.js +3 -3
- package/src/mobile/inserter-button/style.native.scss +1 -0
- package/src/mobile/link-picker/index.native.js +41 -7
- package/src/mobile/link-settings/index.native.js +11 -0
- package/src/mobile/link-settings/test/edit.native.js +432 -0
- package/src/modal/README.md +10 -0
- package/src/modal/aria-helper.js +2 -0
- package/src/modal/index.js +72 -55
- package/src/modal/stories/index.js +6 -1
- package/src/modal/style.scss +9 -0
- package/src/modal/test/index.js +11 -0
- package/src/navigation/README.md +0 -9
- package/src/notice/stories/index.js +1 -1
- package/src/number-control/stories/index.js +1 -1
- package/src/palette-edit/index.js +15 -16
- package/src/palette-edit/style.scss +5 -0
- package/src/panel/stories/index.js +1 -1
- package/src/placeholder/stories/index.js +1 -1
- package/src/popover/stories/index.js +1 -1
- package/src/query-controls/README.md +138 -6
- package/src/radio-group/README.md +4 -1
- package/src/range-control/stories/index.js +1 -1
- package/src/resizable-box/stories/index.js +1 -1
- package/src/scrollable/stories/index.js +1 -1
- package/src/search-control/stories/index.js +1 -1
- package/src/select-control/stories/index.js +2 -1
- package/src/select-control/styles/select-control-styles.ts +25 -2
- package/src/select-control/types.ts +1 -1
- package/src/slot-fill/stories/index.js +1 -1
- package/src/snackbar/stories/index.js +1 -1
- package/src/spacer/stories/index.js +1 -1
- package/src/style-provider/index.js +2 -0
- package/src/surface/stories/index.js +1 -1
- package/src/tab-panel/stories/index.js +1 -1
- package/src/text-control/stories/index.js +1 -1
- package/src/text-highlight/stories/index.js +1 -1
- package/src/textarea-control/stories/index.js +1 -1
- package/src/tip/stories/index.js +1 -1
- package/src/toggle-control/stories/index.js +1 -1
- package/src/toggle-group-control/stories/index.js +1 -1
- package/src/toggle-group-control/toggle-group-control/component.tsx +7 -2
- package/src/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.tsx +24 -9
- package/src/toggle-group-control/toggle-group-control-option/styles.ts +3 -0
- package/src/toolbar-button/stories/index.js +1 -1
- package/src/tools-panel/stories/index.js +237 -0
- package/src/tools-panel/styles.ts +41 -1
- package/src/tools-panel/test/index.js +234 -1
- package/src/tools-panel/tools-panel/README.md +9 -0
- package/src/tools-panel/tools-panel/component.tsx +2 -5
- package/src/tools-panel/tools-panel/hook.ts +50 -18
- package/src/tools-panel/tools-panel-item/hook.ts +5 -1
- package/src/tools-panel/types.ts +5 -1
- package/src/tooltip/stories/index.js +1 -1
- package/src/tree-select/stories/index.js +1 -1
- package/src/truncate/stories/index.js +1 -1
- package/src/unit-control/stories/index.js +19 -1
- package/src/unit-control/styles/unit-control-styles.ts +33 -46
- package/src/unit-control/types.ts +5 -2
- package/src/z-stack/README.md +1 -1
- package/src/z-stack/component.tsx +1 -1
- package/src/z-stack/stories/index.js +1 -1
- package/src/z-stack/styles.ts +7 -2
- package/tsconfig.json +6 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -78,6 +78,7 @@ export default function CustomGradientBar( {
|
|
|
78
78
|
onChange,
|
|
79
79
|
disableInserter = false,
|
|
80
80
|
disableAlpha = false,
|
|
81
|
+
__experimentalIsRenderedInSidebar,
|
|
81
82
|
} ) {
|
|
82
83
|
const gradientPickerDomRef = useRef();
|
|
83
84
|
|
|
@@ -134,6 +135,10 @@ export default function CustomGradientBar( {
|
|
|
134
135
|
{ ! disableInserter &&
|
|
135
136
|
( isMovingInserter || isInsertingControlPoint ) && (
|
|
136
137
|
<ControlPoints.InsertPoint
|
|
138
|
+
__experimentalIsRenderedInSidebar={
|
|
139
|
+
__experimentalIsRenderedInSidebar
|
|
140
|
+
}
|
|
141
|
+
gradientPickerDomRef={ gradientPickerDomRef }
|
|
137
142
|
disableAlpha={ disableAlpha }
|
|
138
143
|
insertPosition={ gradientBarState.insertPosition }
|
|
139
144
|
value={ controlPoints }
|
|
@@ -151,6 +156,9 @@ export default function CustomGradientBar( {
|
|
|
151
156
|
/>
|
|
152
157
|
) }
|
|
153
158
|
<ControlPoints
|
|
159
|
+
__experimentalIsRenderedInSidebar={
|
|
160
|
+
__experimentalIsRenderedInSidebar
|
|
161
|
+
}
|
|
154
162
|
disableAlpha={ disableAlpha }
|
|
155
163
|
disableRemove={ disableInserter }
|
|
156
164
|
gradientPickerDomRef={ gradientPickerDomRef }
|
|
@@ -98,12 +98,17 @@ const GradientTypePicker = ( { gradientAST, hasGradient, onChange } ) => {
|
|
|
98
98
|
labelPosition="top"
|
|
99
99
|
onChange={ handleOnChange }
|
|
100
100
|
options={ GRADIENT_OPTIONS }
|
|
101
|
+
size="__unstable-large"
|
|
101
102
|
value={ hasGradient && type }
|
|
102
103
|
/>
|
|
103
104
|
);
|
|
104
105
|
};
|
|
105
106
|
|
|
106
|
-
export default function CustomGradientPicker( {
|
|
107
|
+
export default function CustomGradientPicker( {
|
|
108
|
+
value,
|
|
109
|
+
onChange,
|
|
110
|
+
__experimentalIsRenderedInSidebar,
|
|
111
|
+
} ) {
|
|
107
112
|
const gradientAST = getGradientAstWithDefault( value );
|
|
108
113
|
// On radial gradients the bar should display a linear gradient.
|
|
109
114
|
// On radial gradients the bar represents a slice of the gradient from the center until the outside.
|
|
@@ -120,6 +125,9 @@ export default function CustomGradientPicker( { value, onChange } ) {
|
|
|
120
125
|
return (
|
|
121
126
|
<div className="components-custom-gradient-picker">
|
|
122
127
|
<CustomGradientBar
|
|
128
|
+
__experimentalIsRenderedInSidebar={
|
|
129
|
+
__experimentalIsRenderedInSidebar
|
|
130
|
+
}
|
|
123
131
|
background={ background }
|
|
124
132
|
hasGradient={ hasGradient }
|
|
125
133
|
value={ controlPoints }
|
|
@@ -111,10 +111,6 @@ $components-custom-gradient-picker__padding: $grid-unit-20; // 48px container, 1
|
|
|
111
111
|
|
|
112
112
|
// All these styles should be made generic and changed on the inputs for all components.
|
|
113
113
|
.components-custom-gradient-picker {
|
|
114
|
-
.components-select-control__input,
|
|
115
|
-
.components-input-control__input {
|
|
116
|
-
height: 40px !important;
|
|
117
|
-
}
|
|
118
114
|
.components-input-control__label {
|
|
119
115
|
line-height: 1;
|
|
120
116
|
padding-bottom: $grid-unit-10 !important;
|
package/src/date-time/README.md
CHANGED
|
@@ -64,3 +64,10 @@ A callback function which receives a Date object representing a day as an argume
|
|
|
64
64
|
|
|
65
65
|
- Type: `Function`
|
|
66
66
|
- Required: No
|
|
67
|
+
|
|
68
|
+
### onMonthPreviewed
|
|
69
|
+
|
|
70
|
+
A callback invoked when selecting the previous/next month in the date picker. The callback receives the new month date in the ISO format as an argument.
|
|
71
|
+
|
|
72
|
+
- Type: `Function`
|
|
73
|
+
- Required: No
|
package/src/date-time/date.js
CHANGED
|
@@ -11,9 +11,14 @@ import DayPickerSingleDateController from 'react-dates/lib/components/DayPickerS
|
|
|
11
11
|
/**
|
|
12
12
|
* WordPress dependencies
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
14
|
+
import { useEffect, useRef } from '@wordpress/element';
|
|
15
15
|
import { isRTL, _n, sprintf } from '@wordpress/i18n';
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Internal dependencies
|
|
19
|
+
*/
|
|
20
|
+
import { getMomentDate } from './utils';
|
|
21
|
+
|
|
17
22
|
/**
|
|
18
23
|
* Module Constants
|
|
19
24
|
*/
|
|
@@ -70,21 +75,18 @@ function DatePickerDay( { day, events = [] } ) {
|
|
|
70
75
|
);
|
|
71
76
|
}
|
|
72
77
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.props.onMonthPreviewed?.( newMonthDate.toISOString() );
|
|
86
|
-
this.keepFocusInside();
|
|
87
|
-
}
|
|
78
|
+
function DatePicker( {
|
|
79
|
+
currentDate,
|
|
80
|
+
onChange,
|
|
81
|
+
events,
|
|
82
|
+
isInvalidDate,
|
|
83
|
+
onMonthPreviewed,
|
|
84
|
+
} ) {
|
|
85
|
+
const nodeRef = useRef();
|
|
86
|
+
const onMonthPreviewedHandler = ( newMonthDate ) => {
|
|
87
|
+
onMonthPreviewed?.( newMonthDate.toISOString() );
|
|
88
|
+
keepFocusInside();
|
|
89
|
+
};
|
|
88
90
|
|
|
89
91
|
/*
|
|
90
92
|
* Todo: We should remove this function ASAP.
|
|
@@ -92,21 +94,21 @@ class DatePicker extends Component {
|
|
|
92
94
|
* This focus loss closes the date picker popover.
|
|
93
95
|
* Ideally we should add an upstream commit on react-dates to fix this issue.
|
|
94
96
|
*/
|
|
95
|
-
keepFocusInside() {
|
|
96
|
-
if ( !
|
|
97
|
+
const keepFocusInside = () => {
|
|
98
|
+
if ( ! nodeRef.current ) {
|
|
97
99
|
return;
|
|
98
100
|
}
|
|
99
101
|
|
|
100
|
-
const { ownerDocument } =
|
|
102
|
+
const { ownerDocument } = nodeRef.current;
|
|
101
103
|
const { activeElement } = ownerDocument;
|
|
102
104
|
|
|
103
105
|
// If focus was lost.
|
|
104
106
|
if (
|
|
105
107
|
! activeElement ||
|
|
106
|
-
!
|
|
108
|
+
! nodeRef.current.contains( ownerDocument.activeElement )
|
|
107
109
|
) {
|
|
108
110
|
// Retrieve the focus region div.
|
|
109
|
-
const focusRegion =
|
|
111
|
+
const focusRegion = nodeRef.current.querySelector(
|
|
110
112
|
'.DayPicker_focusRegion'
|
|
111
113
|
);
|
|
112
114
|
if ( ! focusRegion ) {
|
|
@@ -115,11 +117,9 @@ class DatePicker extends Component {
|
|
|
115
117
|
// Keep the focus on focus region.
|
|
116
118
|
focusRegion.focus();
|
|
117
119
|
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
onChangeMoment( newDate ) {
|
|
121
|
-
const { currentDate, onChange } = this.props;
|
|
120
|
+
};
|
|
122
121
|
|
|
122
|
+
const onChangeMoment = ( newDate ) => {
|
|
123
123
|
// If currentDate is null, use now as momentTime to designate hours, minutes, seconds.
|
|
124
124
|
const momentDate = currentDate ? moment( currentDate ) : moment();
|
|
125
125
|
const momentTime = {
|
|
@@ -131,71 +131,54 @@ class DatePicker extends Component {
|
|
|
131
131
|
onChange( newDate.set( momentTime ).format( TIMEZONELESS_FORMAT ) );
|
|
132
132
|
|
|
133
133
|
// Keep focus on the date picker.
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Create a Moment object from a date string. With no currentDate supplied, default to a Moment
|
|
139
|
-
* object representing now. If a null value is passed, return a null value.
|
|
140
|
-
*
|
|
141
|
-
* @param {?string} currentDate Date representing the currently selected date or null to signify no selection.
|
|
142
|
-
* @return {?moment.Moment} Moment object for selected date or null.
|
|
143
|
-
*/
|
|
144
|
-
getMomentDate( currentDate ) {
|
|
145
|
-
if ( null === currentDate ) {
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
return currentDate ? moment( currentDate ) : moment();
|
|
149
|
-
}
|
|
134
|
+
keepFocusInside();
|
|
135
|
+
};
|
|
150
136
|
|
|
151
|
-
getEventsPerDay( day ) {
|
|
152
|
-
if ( !
|
|
137
|
+
const getEventsPerDay = ( day ) => {
|
|
138
|
+
if ( ! events?.length ) {
|
|
153
139
|
return [];
|
|
154
140
|
}
|
|
155
141
|
|
|
156
|
-
return
|
|
142
|
+
return events.filter( ( eventDay ) =>
|
|
157
143
|
day.isSame( eventDay.date, 'day' )
|
|
158
144
|
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
</div>
|
|
197
|
-
);
|
|
198
|
-
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const momentDate = getMomentDate( currentDate );
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<div className="components-datetime__date" ref={ nodeRef }>
|
|
151
|
+
<DayPickerSingleDateController
|
|
152
|
+
date={ momentDate }
|
|
153
|
+
daySize={ 30 }
|
|
154
|
+
focused
|
|
155
|
+
hideKeyboardShortcutsPanel
|
|
156
|
+
// This is a hack to force the calendar to update on month or year change
|
|
157
|
+
// https://github.com/airbnb/react-dates/issues/240#issuecomment-361776665
|
|
158
|
+
key={ `datepicker-controller-${
|
|
159
|
+
momentDate ? momentDate.format( 'MM-YYYY' ) : 'null'
|
|
160
|
+
}` }
|
|
161
|
+
noBorder
|
|
162
|
+
numberOfMonths={ 1 }
|
|
163
|
+
onDateChange={ onChangeMoment }
|
|
164
|
+
transitionDuration={ 0 }
|
|
165
|
+
weekDayFormat="ddd"
|
|
166
|
+
dayAriaLabelFormat={ ARIAL_LABEL_TIME_FORMAT }
|
|
167
|
+
isRTL={ isRTL() }
|
|
168
|
+
isOutsideRange={ ( date ) => {
|
|
169
|
+
return isInvalidDate && isInvalidDate( date.toDate() );
|
|
170
|
+
} }
|
|
171
|
+
onPrevMonthClick={ onMonthPreviewedHandler }
|
|
172
|
+
onNextMonthClick={ onMonthPreviewedHandler }
|
|
173
|
+
renderDayContents={ ( day ) => (
|
|
174
|
+
<DatePickerDay
|
|
175
|
+
day={ day }
|
|
176
|
+
events={ getEventsPerDay( day ) }
|
|
177
|
+
/>
|
|
178
|
+
) }
|
|
179
|
+
/>
|
|
180
|
+
</div>
|
|
181
|
+
);
|
|
199
182
|
}
|
|
200
183
|
|
|
201
184
|
export default DatePicker;
|
|
@@ -31,32 +31,6 @@ describe( 'DatePicker', () => {
|
|
|
31
31
|
expect( moment.isMoment( date ) ).toBe( true );
|
|
32
32
|
} );
|
|
33
33
|
|
|
34
|
-
describe( 'getMomentDate', () => {
|
|
35
|
-
it( 'should return a Moment object representing a given date string', () => {
|
|
36
|
-
const currentDate = '1986-10-18T23:00:00';
|
|
37
|
-
const wrapper = shallow( <DatePicker /> );
|
|
38
|
-
const momentDate = wrapper.instance().getMomentDate( currentDate );
|
|
39
|
-
|
|
40
|
-
expect( moment.isMoment( momentDate ) ).toBe( true );
|
|
41
|
-
expect( momentDate.isSame( moment( currentDate ) ) ).toBe( true );
|
|
42
|
-
} );
|
|
43
|
-
|
|
44
|
-
it( 'should return null when given a null agrument', () => {
|
|
45
|
-
const currentDate = null;
|
|
46
|
-
const wrapper = shallow( <DatePicker /> );
|
|
47
|
-
const momentDate = wrapper.instance().getMomentDate( currentDate );
|
|
48
|
-
|
|
49
|
-
expect( momentDate ).toBeNull();
|
|
50
|
-
} );
|
|
51
|
-
|
|
52
|
-
it( 'should return a Moment object representing now when given an undefined argument', () => {
|
|
53
|
-
const wrapper = shallow( <DatePicker /> );
|
|
54
|
-
const momentDate = wrapper.instance().getMomentDate();
|
|
55
|
-
|
|
56
|
-
expect( moment.isMoment( momentDate ) ).toBe( true );
|
|
57
|
-
} );
|
|
58
|
-
} );
|
|
59
|
-
|
|
60
34
|
describe( 'onChangeMoment', () => {
|
|
61
35
|
it( 'should call onChange with a formated date of the input', () => {
|
|
62
36
|
const onChangeSpy = jest.fn();
|
|
@@ -69,7 +43,7 @@ describe( 'DatePicker', () => {
|
|
|
69
43
|
);
|
|
70
44
|
const newDate = moment();
|
|
71
45
|
|
|
72
|
-
wrapper.
|
|
46
|
+
wrapper.childAt( 0 ).props().onDateChange( newDate );
|
|
73
47
|
|
|
74
48
|
expect( onChangeSpy ).toHaveBeenCalledWith(
|
|
75
49
|
newDate.format( TIMEZONELESS_FORMAT )
|
|
@@ -87,7 +61,7 @@ describe( 'DatePicker', () => {
|
|
|
87
61
|
minutes: current.minutes(),
|
|
88
62
|
seconds: current.seconds(),
|
|
89
63
|
} );
|
|
90
|
-
wrapper.
|
|
64
|
+
wrapper.childAt( 0 ).props().onDateChange( newDate );
|
|
91
65
|
|
|
92
66
|
expect(
|
|
93
67
|
moment( onChangeSpyArgument ).isSame(
|
|
@@ -110,7 +84,7 @@ describe( 'DatePicker', () => {
|
|
|
110
84
|
minutes: current.minutes(),
|
|
111
85
|
seconds: current.seconds(),
|
|
112
86
|
} );
|
|
113
|
-
wrapper.
|
|
87
|
+
wrapper.childAt( 0 ).props().onDateChange( newDate );
|
|
114
88
|
|
|
115
89
|
expect(
|
|
116
90
|
moment( onChangeSpyArgument ).isSame(
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import moment from 'moment';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { getMomentDate } from '../utils';
|
|
10
|
+
|
|
11
|
+
describe( 'getMomentDate', () => {
|
|
12
|
+
it( 'should return a Moment object representing a given date string', () => {
|
|
13
|
+
const currentDate = '1986-10-18T23:00:00';
|
|
14
|
+
const momentDate = getMomentDate( currentDate );
|
|
15
|
+
|
|
16
|
+
expect( moment.isMoment( momentDate ) ).toBe( true );
|
|
17
|
+
expect( momentDate.isSame( moment( currentDate ) ) ).toBe( true );
|
|
18
|
+
} );
|
|
19
|
+
|
|
20
|
+
it( 'should return null when given a null argument', () => {
|
|
21
|
+
const currentDate = null;
|
|
22
|
+
const momentDate = getMomentDate( currentDate );
|
|
23
|
+
|
|
24
|
+
expect( momentDate ).toBeNull();
|
|
25
|
+
} );
|
|
26
|
+
|
|
27
|
+
it( 'should return a Moment object representing now when given an undefined argument', () => {
|
|
28
|
+
const momentDate = getMomentDate();
|
|
29
|
+
|
|
30
|
+
expect( moment.isMoment( momentDate ) ).toBe( true );
|
|
31
|
+
} );
|
|
32
|
+
} );
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import moment from 'moment';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Create a Moment object from a date string. With no date supplied, default to a Moment
|
|
8
|
+
* object representing now. If a null value is passed, return a null value.
|
|
9
|
+
*
|
|
10
|
+
* @param {?string} date Date representing the currently selected date or null to signify no selection.
|
|
11
|
+
* @return {?moment.Moment} Moment object for selected date or null.
|
|
12
|
+
*/
|
|
13
|
+
export const getMomentDate = ( date ) => {
|
|
14
|
+
if ( null === date ) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return date ? moment( date ) : moment();
|
|
18
|
+
};
|
|
@@ -13,7 +13,7 @@ In a block's `edit` implementation, render a `<DimensionControl />` component.
|
|
|
13
13
|
```jsx
|
|
14
14
|
import { registerBlockType } from '@wordpress/blocks';
|
|
15
15
|
import { __ } from '@wordpress/i18n';
|
|
16
|
-
import { DimensionControl } from '@wordpress/
|
|
16
|
+
import { DimensionControl } from '@wordpress/components';
|
|
17
17
|
|
|
18
18
|
registerBlockType( 'my-plugin/my-block', {
|
|
19
19
|
// ...
|
package/src/divider/README.md
CHANGED
|
@@ -9,15 +9,43 @@ This feature is still experimental. “Experimental” means this is an early im
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
11
11
|
```jsx
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
__experimentalDivider as Divider,
|
|
14
|
+
__experimentalText as Text,
|
|
15
|
+
__experimentalVStack as VStack,
|
|
16
|
+
} from `@wordpress/components`;
|
|
13
17
|
|
|
14
18
|
function Example() {
|
|
15
19
|
return (
|
|
16
|
-
<
|
|
17
|
-
<
|
|
20
|
+
<VStack spacing={4}>
|
|
21
|
+
<Text>Some text here</Text>
|
|
18
22
|
<Divider />
|
|
19
|
-
<
|
|
20
|
-
</
|
|
23
|
+
<Text>Some more text here</Text>
|
|
24
|
+
</VStack>
|
|
21
25
|
);
|
|
22
26
|
}
|
|
23
27
|
```
|
|
28
|
+
|
|
29
|
+
## Props
|
|
30
|
+
|
|
31
|
+
### `margin`: `number`
|
|
32
|
+
|
|
33
|
+
Adjusts all margins on the inline dimension.
|
|
34
|
+
|
|
35
|
+
- Required: No
|
|
36
|
+
|
|
37
|
+
### `marginStart`: `number`
|
|
38
|
+
|
|
39
|
+
Adjusts the inline-start margin.
|
|
40
|
+
|
|
41
|
+
- Required: No
|
|
42
|
+
|
|
43
|
+
### `marginEnd`: `number`
|
|
44
|
+
|
|
45
|
+
Adjusts the inline-end margin.
|
|
46
|
+
|
|
47
|
+
- Required: No
|
|
48
|
+
|
|
49
|
+
### Inherited props
|
|
50
|
+
|
|
51
|
+
`Divider` also inherits all of the [`Separator` props](https://reakit.io/docs/separator/).
|
|
@@ -38,17 +38,18 @@ function Divider(
|
|
|
38
38
|
* @example
|
|
39
39
|
* ```js
|
|
40
40
|
* import {
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
41
|
+
* __experimentalDivider as Divider,
|
|
42
|
+
* __experimentalText as Text,
|
|
43
|
+
* __experimentalVStack as VStack,
|
|
44
|
+
* } from `@wordpress/components`;
|
|
44
45
|
*
|
|
45
46
|
* function Example() {
|
|
46
47
|
* return (
|
|
47
|
-
* <
|
|
48
|
-
* <
|
|
48
|
+
* <VStack spacing={4}>
|
|
49
|
+
* <Text>Some text here</Text>
|
|
49
50
|
* <Divider />
|
|
50
|
-
* <
|
|
51
|
-
* </
|
|
51
|
+
* <Text>Some more text here</Text>
|
|
52
|
+
* </VStack>
|
|
52
53
|
* );
|
|
53
54
|
* }
|
|
54
55
|
* ```
|
|
@@ -1,38 +1,64 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { css } from '@emotion/react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
+
import { useCx } from '../../utils';
|
|
10
|
+
import { Text } from '../../text';
|
|
9
11
|
import { Divider } from '..';
|
|
10
12
|
|
|
11
13
|
export default {
|
|
12
14
|
component: Divider,
|
|
13
15
|
title: 'Components (Experimental)/Divider',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
argTypes: {
|
|
17
|
+
margin: {
|
|
18
|
+
control: { type: 'number' },
|
|
19
|
+
},
|
|
20
|
+
marginStart: {
|
|
21
|
+
control: { type: 'number' },
|
|
22
|
+
},
|
|
23
|
+
marginEnd: {
|
|
24
|
+
control: { type: 'number' },
|
|
25
|
+
},
|
|
16
26
|
},
|
|
17
27
|
};
|
|
18
28
|
|
|
19
|
-
const
|
|
20
|
-
<
|
|
29
|
+
const HorizontalTemplate = ( args ) => (
|
|
30
|
+
<div>
|
|
31
|
+
<Text>Some text before the divider</Text>
|
|
32
|
+
<Divider { ...args } />
|
|
33
|
+
<Text>Some text after the divider</Text>
|
|
34
|
+
</div>
|
|
21
35
|
);
|
|
22
36
|
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
37
|
+
const VerticalTemplate = ( args ) => {
|
|
38
|
+
const cx = useCx();
|
|
39
|
+
const wrapperClassName = cx( css`
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: stretch;
|
|
42
|
+
justify-content: start;
|
|
43
|
+
` );
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div className={ wrapperClassName }>
|
|
47
|
+
<Text>Some text before the divider</Text>
|
|
48
|
+
<Divider orientation="vertical" { ...args } />
|
|
49
|
+
<Text>Some text after the divider</Text>
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
29
52
|
};
|
|
30
53
|
|
|
31
|
-
export const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
54
|
+
export const Horizontal = HorizontalTemplate.bind( {} );
|
|
55
|
+
Horizontal.args = {
|
|
56
|
+
margin: 2,
|
|
57
|
+
marginStart: undefined,
|
|
58
|
+
marginEnd: undefined,
|
|
59
|
+
};
|
|
36
60
|
|
|
37
|
-
|
|
61
|
+
export const Vertical = VerticalTemplate.bind( {} );
|
|
62
|
+
Vertical.args = {
|
|
63
|
+
...Horizontal.args,
|
|
38
64
|
};
|
package/src/divider/styles.ts
CHANGED
|
@@ -8,29 +8,66 @@ import { css } from '@emotion/react';
|
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
10
|
import { space } from '../ui/utils/space';
|
|
11
|
-
import
|
|
12
|
-
import type {
|
|
11
|
+
import { rtl } from '../utils';
|
|
12
|
+
import type { Props } from './types';
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
const MARGIN_DIRECTIONS: Record<
|
|
15
|
+
NonNullable< Props[ 'orientation' ] >,
|
|
16
|
+
Record< 'start' | 'end', string >
|
|
17
|
+
> = {
|
|
18
|
+
vertical: {
|
|
19
|
+
start: 'marginLeft',
|
|
20
|
+
end: 'marginRight',
|
|
21
|
+
},
|
|
22
|
+
horizontal: {
|
|
23
|
+
start: 'marginTop',
|
|
24
|
+
end: 'marginBottom',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Renders the correct margins given the Divider's `orientation` and the writing direction.
|
|
29
|
+
// When both the generic `margin` and the specific `marginStart|marginEnd` props are defined,
|
|
30
|
+
// the latter will take priority.
|
|
31
|
+
const renderMargin = ( {
|
|
32
|
+
'aria-orientation': orientation = 'horizontal',
|
|
33
|
+
margin,
|
|
34
|
+
marginStart,
|
|
35
|
+
marginEnd,
|
|
36
|
+
}: Props ) =>
|
|
37
|
+
css(
|
|
38
|
+
rtl( {
|
|
39
|
+
[ MARGIN_DIRECTIONS[ orientation ].start ]: space(
|
|
40
|
+
marginStart ?? margin
|
|
41
|
+
),
|
|
42
|
+
[ MARGIN_DIRECTIONS[ orientation ].end ]: space(
|
|
43
|
+
marginEnd ?? margin
|
|
44
|
+
),
|
|
45
|
+
} )()
|
|
46
|
+
);
|
|
21
47
|
|
|
48
|
+
const renderBorder = ( {
|
|
49
|
+
'aria-orientation': orientation = 'horizontal',
|
|
50
|
+
}: Props ) => {
|
|
22
51
|
return css( {
|
|
23
|
-
|
|
24
|
-
|
|
52
|
+
[ orientation === 'vertical'
|
|
53
|
+
? 'borderRight'
|
|
54
|
+
: 'borderBottom' ]: '1px solid currentColor',
|
|
25
55
|
} );
|
|
26
56
|
};
|
|
27
57
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
58
|
+
const renderSize = ( {
|
|
59
|
+
'aria-orientation': orientation = 'horizontal',
|
|
60
|
+
}: Props ) =>
|
|
61
|
+
css( {
|
|
62
|
+
height: orientation === 'vertical' ? 'auto' : 0,
|
|
63
|
+
width: orientation === 'vertical' ? 0 : 'auto',
|
|
64
|
+
} );
|
|
65
|
+
|
|
66
|
+
export const DividerView = styled.hr< Props >`
|
|
67
|
+
border: 0;
|
|
32
68
|
margin: 0;
|
|
33
|
-
width: auto;
|
|
34
69
|
|
|
70
|
+
${ renderBorder }
|
|
71
|
+
${ renderSize }
|
|
35
72
|
${ renderMargin }
|
|
36
73
|
`;
|