@wordpress/components 35.0.1 → 36.0.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 +38 -0
- package/CONTRIBUTING.md +33 -26
- package/build/alignment-matrix-control/cell.cjs +1 -1
- package/build/alignment-matrix-control/cell.cjs.map +2 -2
- package/build/alignment-matrix-control/index.cjs +1 -1
- package/build/alignment-matrix-control/index.cjs.map +2 -2
- package/build/angle-picker-control/angle-circle.cjs +1 -1
- package/build/angle-picker-control/angle-circle.cjs.map +2 -2
- package/build/angle-picker-control/index.cjs +2 -2
- package/build/autocomplete/get-autocomplete-match.cjs.map +1 -1
- package/build/autocomplete/index.cjs.map +1 -1
- package/build/base-control/styles/base-control-styles.cjs +6 -6
- package/build/base-control/styles/base-control-styles.cjs.map +2 -2
- package/build/border-control/styles.cjs +17 -14
- package/build/border-control/styles.cjs.map +2 -2
- package/build/box-control/{input-control.cjs → box-input-control.cjs} +9 -9
- package/build/box-control/box-input-control.cjs.map +7 -0
- package/build/box-control/index.cjs +9 -25
- package/build/box-control/index.cjs.map +3 -3
- package/build/button/index.cjs +3 -7
- package/build/button/index.cjs.map +2 -2
- package/build/card/card-divider/hook.cjs.map +2 -2
- package/build/color-palette/index.cjs.map +1 -1
- package/build/color-picker/component.cjs.map +1 -1
- package/build/date-time/utils.cjs.map +1 -1
- package/build/disabled/index.cjs.map +2 -2
- package/build/divider/component.cjs +108 -3
- package/build/divider/component.cjs.map +4 -4
- package/build/draggable/index.cjs.map +1 -1
- package/build/external-link/index.cjs +1 -1
- package/build/external-link/index.cjs.map +1 -1
- package/build/higher-order/with-fallback-styles/index.cjs +18 -44
- package/build/higher-order/with-fallback-styles/index.cjs.map +2 -2
- package/build/menu/popover.cjs.map +1 -1
- package/build/menu/styles.cjs +17 -17
- package/build/menu/styles.cjs.map +2 -2
- package/build/modal/index.cjs.map +1 -1
- package/build/modal/use-modal-exit-animation.cjs +37 -52
- package/build/modal/use-modal-exit-animation.cjs.map +2 -2
- package/build/palette-edit/index.cjs +1 -1
- package/build/progress-bar/index.cjs +1 -1
- package/build/progress-bar/index.cjs.map +2 -2
- package/build/query-controls/index.cjs +2 -2
- package/build/query-controls/index.cjs.map +2 -2
- package/build/range-control/index.cjs.map +1 -1
- package/build/sandbox/index.cjs +7 -1
- package/build/sandbox/index.cjs.map +2 -2
- package/build/snackbar/index.cjs +1 -1
- package/build/spinner/styles.cjs +4 -4
- package/build/spinner/styles.cjs.map +2 -2
- package/build/tabs/index.cjs +0 -18
- package/build/tabs/index.cjs.map +2 -2
- package/build/tabs/tablist.cjs +5 -15
- package/build/tabs/tablist.cjs.map +2 -2
- package/build/text-control/index.cjs +3 -12
- package/build/text-control/index.cjs.map +3 -3
- package/build/tools-panel/styles.cjs +13 -13
- package/build/tools-panel/styles.cjs.map +2 -2
- package/build/tools-panel/tools-panel/hook.cjs.map +1 -1
- package/build/tree-select/index.cjs +1 -1
- package/build/tree-select/index.cjs.map +1 -1
- package/build/truncate/utils.cjs +1 -1
- package/build/truncate/utils.cjs.map +1 -1
- package/build/utils/colors-values.cjs +12 -12
- package/build/utils/colors-values.cjs.map +2 -2
- package/build/utils/config-values.cjs +2 -2
- package/build/utils/config-values.cjs.map +2 -2
- package/build/utils/dropdown-motion.cjs.map +2 -2
- package/build/utils/strings.cjs.map +1 -1
- package/build/validated-form-controls/components/text-control.cjs +0 -1
- package/build/validated-form-controls/components/text-control.cjs.map +2 -2
- package/build-module/alignment-matrix-control/cell.mjs +1 -1
- package/build-module/alignment-matrix-control/cell.mjs.map +2 -2
- package/build-module/alignment-matrix-control/index.mjs +1 -1
- package/build-module/alignment-matrix-control/index.mjs.map +2 -2
- package/build-module/angle-picker-control/angle-circle.mjs +1 -1
- package/build-module/angle-picker-control/angle-circle.mjs.map +2 -2
- package/build-module/angle-picker-control/index.mjs +2 -2
- package/build-module/autocomplete/get-autocomplete-match.mjs.map +1 -1
- package/build-module/autocomplete/index.mjs.map +1 -1
- package/build-module/base-control/styles/base-control-styles.mjs +6 -6
- package/build-module/base-control/styles/base-control-styles.mjs.map +2 -2
- package/build-module/border-control/styles.mjs +17 -14
- package/build-module/border-control/styles.mjs.map +2 -2
- package/build-module/box-control/{input-control.mjs → box-input-control.mjs} +6 -6
- package/build-module/box-control/box-input-control.mjs.map +7 -0
- package/build-module/box-control/index.mjs +9 -25
- package/build-module/box-control/index.mjs.map +2 -2
- package/build-module/button/index.mjs +2 -5
- package/build-module/button/index.mjs.map +2 -2
- package/build-module/card/card-divider/hook.mjs.map +2 -2
- package/build-module/color-palette/index.mjs.map +1 -1
- package/build-module/color-picker/component.mjs.map +1 -1
- package/build-module/date-time/utils.mjs.map +1 -1
- package/build-module/disabled/index.mjs.map +2 -2
- package/build-module/divider/component.mjs +108 -3
- package/build-module/divider/component.mjs.map +3 -3
- package/build-module/draggable/index.mjs.map +1 -1
- package/build-module/external-link/index.mjs +1 -1
- package/build-module/external-link/index.mjs.map +1 -1
- package/build-module/higher-order/with-fallback-styles/index.mjs +20 -46
- package/build-module/higher-order/with-fallback-styles/index.mjs.map +2 -2
- package/build-module/menu/popover.mjs.map +1 -1
- package/build-module/menu/styles.mjs +17 -17
- package/build-module/menu/styles.mjs.map +2 -2
- package/build-module/modal/index.mjs.map +1 -1
- package/build-module/modal/use-modal-exit-animation.mjs +37 -52
- package/build-module/modal/use-modal-exit-animation.mjs.map +2 -2
- package/build-module/palette-edit/index.mjs +1 -1
- package/build-module/progress-bar/index.mjs +1 -1
- package/build-module/progress-bar/index.mjs.map +2 -2
- package/build-module/query-controls/index.mjs +2 -2
- package/build-module/query-controls/index.mjs.map +2 -2
- package/build-module/range-control/index.mjs.map +1 -1
- package/build-module/sandbox/index.mjs +3 -1
- package/build-module/sandbox/index.mjs.map +2 -2
- package/build-module/snackbar/index.mjs +1 -1
- package/build-module/spinner/styles.mjs +4 -4
- package/build-module/spinner/styles.mjs.map +2 -2
- package/build-module/tabs/index.mjs +1 -19
- package/build-module/tabs/index.mjs.map +2 -2
- package/build-module/tabs/tablist.mjs +5 -15
- package/build-module/tabs/tablist.mjs.map +2 -2
- package/build-module/text-control/index.mjs +3 -12
- package/build-module/text-control/index.mjs.map +2 -2
- package/build-module/tools-panel/styles.mjs +13 -13
- package/build-module/tools-panel/styles.mjs.map +2 -2
- package/build-module/tools-panel/tools-panel/hook.mjs.map +1 -1
- package/build-module/tree-select/index.mjs +1 -1
- package/build-module/tree-select/index.mjs.map +1 -1
- package/build-module/truncate/utils.mjs +1 -1
- package/build-module/truncate/utils.mjs.map +1 -1
- package/build-module/utils/colors-values.mjs +12 -12
- package/build-module/utils/colors-values.mjs.map +2 -2
- package/build-module/utils/config-values.mjs +2 -2
- package/build-module/utils/config-values.mjs.map +2 -2
- package/build-module/utils/dropdown-motion.mjs.map +2 -2
- package/build-module/utils/strings.mjs.map +1 -1
- package/build-module/validated-form-controls/components/text-control.mjs +0 -1
- package/build-module/validated-form-controls/components/text-control.mjs.map +2 -2
- package/build-style/style-rtl.css +85 -101
- package/build-style/style.css +85 -101
- package/build-types/base-control/styles/base-control-styles.d.ts.map +1 -1
- package/build-types/border-control/styles.d.ts.map +1 -1
- package/build-types/box-control/box-input-control.d.ts +3 -0
- package/build-types/box-control/box-input-control.d.ts.map +1 -0
- package/build-types/box-control/index.d.ts +2 -6
- package/build-types/box-control/index.d.ts.map +1 -1
- package/build-types/box-control/stories/index.story.d.ts.map +1 -1
- package/build-types/box-control/types.d.ts +7 -6
- package/build-types/box-control/types.d.ts.map +1 -1
- package/build-types/button/index.d.ts +0 -2
- package/build-types/button/index.d.ts.map +1 -1
- package/build-types/card/card-divider/hook.d.ts +1 -274
- package/build-types/card/card-divider/hook.d.ts.map +1 -1
- package/build-types/composite/stories/index.story.d.ts.map +1 -1
- package/build-types/confirm-dialog/stories/index.story.d.ts.map +1 -1
- package/build-types/disabled/index.d.ts +0 -1
- package/build-types/disabled/index.d.ts.map +1 -1
- package/build-types/disabled/stories/index.story.d.ts.map +1 -1
- package/build-types/divider/component.d.ts.map +1 -1
- package/build-types/dropdown/stories/index.story.d.ts.map +1 -1
- package/build-types/higher-order/with-fallback-styles/index.d.ts +1 -35
- package/build-types/higher-order/with-fallback-styles/index.d.ts.map +1 -1
- package/build-types/higher-order/with-fallback-styles/test/index.d.ts.map +1 -0
- package/build-types/icon/stories/index.story.d.ts +0 -1
- package/build-types/icon/stories/index.story.d.ts.map +1 -1
- package/build-types/menu/styles.d.ts.map +1 -1
- package/build-types/menu/types.d.ts +2 -2
- package/build-types/placeholder/stories/index.story.d.ts.map +1 -1
- package/build-types/resizable-box/index.d.ts +0 -2
- package/build-types/resizable-box/index.d.ts.map +1 -1
- package/build-types/resizable-box/stories/index.story.d.ts +0 -2
- package/build-types/resizable-box/stories/index.story.d.ts.map +1 -1
- package/build-types/sandbox/index.d.ts +15 -0
- package/build-types/sandbox/index.d.ts.map +1 -1
- package/build-types/spinner/styles.d.ts.map +1 -1
- package/build-types/tabs/index.d.ts.map +1 -1
- package/build-types/tabs/tablist.d.ts.map +1 -1
- package/build-types/text-control/index.d.ts +0 -1
- package/build-types/text-control/index.d.ts.map +1 -1
- package/build-types/text-control/stories/index.story.d.ts.map +1 -1
- package/build-types/text-control/types.d.ts +2 -1
- package/build-types/text-control/types.d.ts.map +1 -1
- package/build-types/tools-panel/styles.d.ts.map +1 -1
- package/build-types/utils/colors-values.d.ts.map +1 -1
- package/build-types/utils/dropdown-motion.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/combobox-control.d.ts +2 -2
- package/build-types/validated-form-controls/components/text-control.d.ts +2 -2
- package/build-types/validated-form-controls/components/text-control.d.ts.map +1 -1
- package/package.json +34 -28
- package/src/angle-picker-control/angle-circle.tsx +3 -3
- package/src/base-control/README.md +2 -2
- package/src/base-control/styles/base-control-styles.ts +1 -0
- package/src/border-control/styles.ts +1 -0
- package/src/box-control/README.md +1 -13
- package/src/box-control/{input-control.tsx → box-input-control.tsx} +4 -4
- package/src/box-control/index.tsx +5 -23
- package/src/box-control/stories/index.story.tsx +1 -3
- package/src/box-control/test/index.tsx +15 -2
- package/src/box-control/types.ts +7 -6
- package/src/button/index.tsx +2 -4
- package/src/button/style.scss +3 -3
- package/src/card/card-divider/hook.ts +5 -1
- package/src/card/test/__snapshots__/index.tsx.snap +7 -9
- package/src/checkbox-control/test/__snapshots__/index.tsx.snap +4 -3
- package/src/composite/stories/index.story.tsx +5 -0
- package/src/confirm-dialog/stories/index.story.tsx +1 -0
- package/src/custom-select-control/test/index.tsx +1 -1
- package/src/disabled/README.md +0 -1
- package/src/disabled/index.tsx +0 -1
- package/src/disabled/stories/index.story.tsx +0 -1
- package/src/divider/component.tsx +27 -3
- package/src/divider/style.module.scss +21 -0
- package/src/divider/test/index.tsx +21 -11
- package/src/dropdown/stories/index.story.tsx +5 -0
- package/src/dropdown-menu/style.scss +1 -1
- package/src/external-link/style.scss +4 -4
- package/src/form-toggle/style.scss +1 -1
- package/src/heading/test/__snapshots__/index.tsx.snap +4 -4
- package/src/higher-order/with-constrained-tabbing/README.md +0 -2
- package/src/higher-order/with-fallback-styles/index.tsx +31 -61
- package/src/higher-order/with-fallback-styles/test/index.tsx +47 -0
- package/src/higher-order/with-focus-return/README.md +0 -2
- package/src/icon/stories/index.story.tsx +0 -15
- package/src/menu/README.md +2 -2
- package/src/menu/styles.ts +2 -0
- package/src/menu/test/index.tsx +104 -87
- package/src/menu/types.ts +2 -2
- package/src/menu-item/test/__snapshots__/index.js.snap +2 -0
- package/src/modal/style.scss +1 -1
- package/src/modal/test/index.tsx +0 -24
- package/src/modal/use-modal-exit-animation.ts +2 -2
- package/src/navigable-container/test/navigable-menu.tsx +0 -16
- package/src/navigable-container/test/tababble-container.tsx +0 -16
- package/src/navigator/test/index.tsx +0 -24
- package/src/notice/style.scss +11 -13
- package/src/notice/test/__snapshots__/index.tsx.snap +1 -0
- package/src/panel/README.md +2 -0
- package/src/panel/stories/index.story.tsx +2 -2
- package/src/panel/style.scss +1 -1
- package/src/placeholder/stories/index.story.tsx +0 -1
- package/src/radio-control/style.scss +1 -1
- package/src/resizable-box/index.tsx +1 -2
- package/src/sandbox/index.tsx +18 -1
- package/src/sandbox/test/index.tsx +44 -1
- package/src/spinner/styles.ts +1 -0
- package/src/tab-panel/style.scss +6 -6
- package/src/tab-panel/test/index.tsx +0 -17
- package/src/tabs/index.tsx +1 -26
- package/src/tabs/tablist.tsx +5 -21
- package/src/tabs/test/index.tsx +16 -44
- package/src/text/test/__snapshots__/index.tsx.snap +3 -3
- package/src/text-control/README.md +0 -9
- package/src/text-control/index.tsx +3 -14
- package/src/text-control/stories/index.story.tsx +0 -2
- package/src/text-control/style.scss +7 -11
- package/src/text-control/test/text-control.tsx +1 -5
- package/src/text-control/types.ts +2 -1
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +38 -26
- package/src/toolbar/toolbar-group/style.scss +2 -2
- package/src/tools-panel/styles.ts +1 -1
- package/src/tools-panel/tools-panel/README.md +0 -2
- package/src/tooltip/stories/index.story.tsx +2 -2
- package/src/tree-grid/test/index.tsx +0 -23
- package/src/utils/colors-values.js +36 -16
- package/src/utils/config-values.js +2 -2
- package/src/utils/dropdown-motion.ts +6 -4
- package/src/utils/theme-variables.scss +18 -13
- package/src/validated-form-controls/components/text-control.tsx +2 -10
- package/build/box-control/input-control.cjs.map +0 -7
- package/build/divider/styles.cjs +0 -98
- package/build/divider/styles.cjs.map +0 -7
- package/build-module/box-control/input-control.mjs.map +0 -7
- package/build-module/divider/styles.mjs +0 -63
- package/build-module/divider/styles.mjs.map +0 -7
- package/build-types/box-control/input-control.d.ts +0 -3
- package/build-types/box-control/input-control.d.ts.map +0 -1
- package/build-types/card/context.d.ts +0 -3
- package/build-types/card/context.d.ts.map +0 -1
- package/build-types/date-time/date/index.d.ts +0 -23
- package/build-types/date-time/date/index.d.ts.map +0 -1
- package/build-types/date-time/date/styles.d.ts +0 -45
- package/build-types/date-time/date/styles.d.ts.map +0 -1
- package/build-types/date-time/date/test/index.d.ts.map +0 -1
- package/build-types/date-time/date/test/use-lilius.d.ts +0 -2
- package/build-types/date-time/date/test/use-lilius.d.ts.map +0 -1
- package/build-types/date-time/date/use-lilius/index.d.ts +0 -169
- package/build-types/date-time/date/use-lilius/index.d.ts.map +0 -1
- package/build-types/date-time/time/index.d.ts +0 -27
- package/build-types/date-time/time/index.d.ts.map +0 -1
- package/build-types/date-time/time/styles.d.ts +0 -93
- package/build-types/date-time/time/styles.d.ts.map +0 -1
- package/build-types/date-time/time/test/index.d.ts +0 -2
- package/build-types/date-time/time/test/index.d.ts.map +0 -1
- package/build-types/date-time/time/time-input/index.d.ts +0 -4
- package/build-types/date-time/time/time-input/index.d.ts.map +0 -1
- package/build-types/date-time/time/time-input/test/index.d.ts +0 -2
- package/build-types/date-time/time/time-input/test/index.d.ts.map +0 -1
- package/build-types/date-time/time/timezone.d.ts +0 -7
- package/build-types/date-time/time/timezone.d.ts.map +0 -1
- package/build-types/divider/styles.d.ts +0 -10
- package/build-types/divider/styles.d.ts.map +0 -1
- package/build-types/mobile/image/constants.d.ts +0 -5
- package/build-types/mobile/image/constants.d.ts.map +0 -1
- package/build-types/navigation/back-button/index.d.ts +0 -7
- package/build-types/navigation/back-button/index.d.ts.map +0 -1
- package/build-types/navigation/constants.d.ts +0 -3
- package/build-types/navigation/constants.d.ts.map +0 -1
- package/build-types/navigation/context.d.ts +0 -4
- package/build-types/navigation/context.d.ts.map +0 -1
- package/build-types/navigation/group/context.d.ts +0 -7
- package/build-types/navigation/group/context.d.ts.map +0 -1
- package/build-types/navigation/group/index.d.ts +0 -7
- package/build-types/navigation/group/index.d.ts.map +0 -1
- package/build-types/navigation/index.d.ts +0 -46
- package/build-types/navigation/index.d.ts.map +0 -1
- package/build-types/navigation/item/base-content.d.ts +0 -3
- package/build-types/navigation/item/base-content.d.ts.map +0 -1
- package/build-types/navigation/item/base.d.ts +0 -3
- package/build-types/navigation/item/base.d.ts.map +0 -1
- package/build-types/navigation/item/index.d.ts +0 -7
- package/build-types/navigation/item/index.d.ts.map +0 -1
- package/build-types/navigation/item/use-navigation-tree-item.d.ts +0 -3
- package/build-types/navigation/item/use-navigation-tree-item.d.ts.map +0 -1
- package/build-types/navigation/menu/context.d.ts +0 -7
- package/build-types/navigation/menu/context.d.ts.map +0 -1
- package/build-types/navigation/menu/index.d.ts +0 -7
- package/build-types/navigation/menu/index.d.ts.map +0 -1
- package/build-types/navigation/menu/menu-title-search.d.ts +0 -3
- package/build-types/navigation/menu/menu-title-search.d.ts.map +0 -1
- package/build-types/navigation/menu/menu-title.d.ts +0 -3
- package/build-types/navigation/menu/menu-title.d.ts.map +0 -1
- package/build-types/navigation/menu/search-no-results-found.d.ts +0 -3
- package/build-types/navigation/menu/search-no-results-found.d.ts.map +0 -1
- package/build-types/navigation/menu/use-navigation-tree-menu.d.ts +0 -3
- package/build-types/navigation/menu/use-navigation-tree-menu.d.ts.map +0 -1
- package/build-types/navigation/stories/index.story.d.ts +0 -23
- package/build-types/navigation/stories/index.story.d.ts.map +0 -1
- package/build-types/navigation/stories/utils/controlled-state.d.ts +0 -7
- package/build-types/navigation/stories/utils/controlled-state.d.ts.map +0 -1
- package/build-types/navigation/stories/utils/default.d.ts +0 -10
- package/build-types/navigation/stories/utils/default.d.ts.map +0 -1
- package/build-types/navigation/stories/utils/group.d.ts +0 -10
- package/build-types/navigation/stories/utils/group.d.ts.map +0 -1
- package/build-types/navigation/stories/utils/hide-if-empty.d.ts +0 -10
- package/build-types/navigation/stories/utils/hide-if-empty.d.ts.map +0 -1
- package/build-types/navigation/stories/utils/more-examples.d.ts +0 -10
- package/build-types/navigation/stories/utils/more-examples.d.ts.map +0 -1
- package/build-types/navigation/stories/utils/search.d.ts +0 -10
- package/build-types/navigation/stories/utils/search.d.ts.map +0 -1
- package/build-types/navigation/styles/navigation-styles.d.ts +0 -55
- package/build-types/navigation/styles/navigation-styles.d.ts.map +0 -1
- package/build-types/navigation/test/index.d.ts +0 -2
- package/build-types/navigation/test/index.d.ts.map +0 -1
- package/build-types/navigation/types.d.ts +0 -266
- package/build-types/navigation/types.d.ts.map +0 -1
- package/build-types/navigation/use-create-navigation-tree.d.ts +0 -15
- package/build-types/navigation/use-create-navigation-tree.d.ts.map +0 -1
- package/build-types/navigation/use-navigation-tree-nodes.d.ts +0 -10
- package/build-types/navigation/use-navigation-tree-nodes.d.ts.map +0 -1
- package/build-types/navigation/utils.d.ts +0 -3
- package/build-types/navigation/utils.d.ts.map +0 -1
- package/build-types/visually-hidden/test/index.d.ts +0 -2
- package/build-types/visually-hidden/test/index.d.ts.map +0 -1
- package/src/divider/styles.ts +0 -81
- package/src/divider/test/__snapshots__/index.tsx.snap +0 -71
- /package/build-types/{date-time/date → higher-order/with-fallback-styles}/test/index.d.ts +0 -0
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import * as Ariakit from '@ariakit/react';
|
|
5
|
+
import clsx from 'clsx';
|
|
5
6
|
import type { ForwardedRef } from 'react';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -9,18 +10,41 @@ import type { ForwardedRef } from 'react';
|
|
|
9
10
|
*/
|
|
10
11
|
import type { WordPressComponentProps } from '../context';
|
|
11
12
|
import { contextConnect, useContextSystem } from '../context';
|
|
12
|
-
import {
|
|
13
|
+
import { space } from '../utils/space';
|
|
13
14
|
import type { DividerProps } from './types';
|
|
15
|
+
import styles from './style.module.scss';
|
|
14
16
|
|
|
15
17
|
function UnconnectedDivider(
|
|
16
18
|
props: WordPressComponentProps< DividerProps, 'hr', false >,
|
|
17
19
|
forwardedRef: ForwardedRef< any >
|
|
18
20
|
) {
|
|
19
|
-
const
|
|
21
|
+
const {
|
|
22
|
+
className,
|
|
23
|
+
margin,
|
|
24
|
+
marginEnd,
|
|
25
|
+
marginStart,
|
|
26
|
+
style,
|
|
27
|
+
...contextProps
|
|
28
|
+
} = useContextSystem( props, 'Divider' );
|
|
29
|
+
|
|
30
|
+
const dividerStyle = { ...style };
|
|
31
|
+
const resolvedMarginStart = space( marginStart ?? margin );
|
|
32
|
+
const resolvedMarginEnd = space( marginEnd ?? margin );
|
|
33
|
+
|
|
34
|
+
if ( resolvedMarginStart ) {
|
|
35
|
+
dividerStyle[ '--wp-components-divider-margin-start' ] =
|
|
36
|
+
resolvedMarginStart;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if ( resolvedMarginEnd ) {
|
|
40
|
+
dividerStyle[ '--wp-components-divider-margin-end' ] =
|
|
41
|
+
resolvedMarginEnd;
|
|
42
|
+
}
|
|
20
43
|
|
|
21
44
|
return (
|
|
22
45
|
<Ariakit.Separator
|
|
23
|
-
|
|
46
|
+
className={ clsx( styles.divider, className ) }
|
|
47
|
+
style={ dividerStyle }
|
|
24
48
|
{ ...contextProps }
|
|
25
49
|
ref={ forwardedRef }
|
|
26
50
|
/>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.divider {
|
|
2
|
+
border: 0;
|
|
3
|
+
margin: 0;
|
|
4
|
+
|
|
5
|
+
&[aria-orientation="horizontal"] {
|
|
6
|
+
border-block-end: 1px solid currentColor;
|
|
7
|
+
block-size: 0;
|
|
8
|
+
inline-size: auto;
|
|
9
|
+
margin-block-start: var(--wp-components-divider-margin-start, 0);
|
|
10
|
+
margin-block-end: var(--wp-components-divider-margin-end, 0);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&[aria-orientation="vertical"] {
|
|
14
|
+
display: inline;
|
|
15
|
+
border-inline-end: 1px solid currentColor;
|
|
16
|
+
block-size: auto;
|
|
17
|
+
inline-size: 0;
|
|
18
|
+
margin-inline-start: var(--wp-components-divider-margin-start, 0);
|
|
19
|
+
margin-inline-end: var(--wp-components-divider-margin-end, 0);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -9,32 +9,42 @@ import { render, screen } from '@testing-library/react';
|
|
|
9
9
|
import { Divider } from '..';
|
|
10
10
|
|
|
11
11
|
describe( 'props', () => {
|
|
12
|
-
test( 'should render
|
|
12
|
+
test( 'should render a horizontal separator by default', () => {
|
|
13
13
|
render( <Divider /> );
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
const divider = screen.getByRole( 'separator' );
|
|
16
|
+
expect( divider ).toHaveAttribute( 'aria-orientation', 'horizontal' );
|
|
15
17
|
} );
|
|
16
18
|
|
|
17
19
|
test( 'should render marginStart', () => {
|
|
18
|
-
render( <Divider /> );
|
|
19
20
|
render( <Divider marginStart={ 5 } /> );
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
expect( screen.getByRole( 'separator' ) ).toHaveStyle( {
|
|
23
|
+
'--wp-components-divider-margin-start': 'calc(4px * 5)',
|
|
24
|
+
} );
|
|
23
25
|
} );
|
|
24
26
|
|
|
25
27
|
test( 'should render marginEnd', () => {
|
|
26
|
-
render( <Divider /> );
|
|
27
28
|
render( <Divider marginEnd={ 5 } /> );
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
expect( screen.getByRole( 'separator' ) ).toHaveStyle( {
|
|
31
|
+
'--wp-components-divider-margin-end': 'calc(4px * 5)',
|
|
32
|
+
} );
|
|
31
33
|
} );
|
|
32
34
|
|
|
33
35
|
test( 'should render margin', () => {
|
|
34
|
-
render( <Divider /> );
|
|
35
36
|
render( <Divider margin={ 7 } /> );
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
expect( screen.getByRole( 'separator' ) ).toHaveStyle( {
|
|
39
|
+
'--wp-components-divider-margin-start': 'calc(4px * 7)',
|
|
40
|
+
'--wp-components-divider-margin-end': 'calc(4px * 7)',
|
|
41
|
+
} );
|
|
42
|
+
} );
|
|
43
|
+
|
|
44
|
+
test( 'should render vertical orientation', () => {
|
|
45
|
+
render( <Divider orientation="vertical" /> );
|
|
46
|
+
|
|
47
|
+
const divider = screen.getByRole( 'separator' );
|
|
48
|
+
expect( divider ).toHaveAttribute( 'aria-orientation', 'vertical' );
|
|
39
49
|
} );
|
|
40
50
|
} );
|
|
@@ -19,6 +19,11 @@ const meta: Meta< typeof Dropdown > = {
|
|
|
19
19
|
id: 'components-dropdown',
|
|
20
20
|
component: Dropdown,
|
|
21
21
|
subcomponents: { DropdownContentWrapper },
|
|
22
|
+
// Temporary: Due to an upstream bug, render the root explicitly so the
|
|
23
|
+
// components manifest extractor can resolve props from the JSX.
|
|
24
|
+
//
|
|
25
|
+
// See: https://github.com/storybookjs/storybook/issues/34877
|
|
26
|
+
render: ( args ) => <Dropdown { ...args } />,
|
|
22
27
|
args: {
|
|
23
28
|
onClose: fn(),
|
|
24
29
|
onToggle: fn(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
.components-external-link {
|
|
2
|
-
color: var(--wpds-color-
|
|
2
|
+
color: var(--wpds-color-foreground-interactive-brand);
|
|
3
3
|
text-decoration: none;
|
|
4
4
|
|
|
5
5
|
// Match the `outset-ring--focus` utility used by `Link` in `@wordpress/ui`.
|
|
@@ -12,18 +12,18 @@
|
|
|
12
12
|
outline-offset: 1px;
|
|
13
13
|
|
|
14
14
|
&:visited {
|
|
15
|
-
color: var(--wpds-color-
|
|
15
|
+
color: var(--wpds-color-foreground-interactive-brand);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
&:hover,
|
|
19
19
|
&:active {
|
|
20
|
-
color: var(--wpds-color-
|
|
20
|
+
color: var(--wpds-color-foreground-interactive-brand-active);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
&:focus {
|
|
24
24
|
outline:
|
|
25
25
|
var(--wpds-border-width-focus) solid
|
|
26
|
-
var(--wpds-color-stroke-focus
|
|
26
|
+
var(--wpds-color-stroke-focus);
|
|
27
27
|
// Override style from wp-admin common.css.
|
|
28
28
|
box-shadow: none;
|
|
29
29
|
border-radius: 0;
|
|
@@ -106,7 +106,7 @@ $transition-duration: 0.2s;
|
|
|
106
106
|
.components-disabled & {
|
|
107
107
|
.components-form-toggle__track {
|
|
108
108
|
background-color: $components-color-gray-100;
|
|
109
|
-
border-color:
|
|
109
|
+
border-color: var(--wpds-color-stroke-interactive-neutral-disabled);
|
|
110
110
|
|
|
111
111
|
@media ( forced-colors: active ) {
|
|
112
112
|
border-color: GrayText;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`props should render correctly 1`] = `
|
|
4
4
|
.emotion-0 {
|
|
5
|
-
color: var(--wp-components-color-foreground, #1e1e1e);
|
|
5
|
+
color: var(--wp-components-color-foreground, var(--wpds-color-foreground-content-neutral, #1e1e1e));
|
|
6
6
|
line-height: 1.4;
|
|
7
7
|
margin: 0;
|
|
8
8
|
text-wrap: pretty;
|
|
9
|
-
color: var(--wp-components-color-foreground, #1e1e1e);
|
|
9
|
+
color: var(--wp-components-color-foreground, var(--wpds-color-foreground-content-neutral, #1e1e1e));
|
|
10
10
|
font-size: calc(1.95 * 13px);
|
|
11
11
|
font-weight: 600;
|
|
12
12
|
display: block;
|
|
@@ -29,7 +29,7 @@ Snapshot Diff:
|
|
|
29
29
|
@@ -1,10 +1,10 @@
|
|
30
30
|
Array [
|
|
31
31
|
Object {
|
|
32
|
-
"color": "var(--wp-components-color-foreground, #1e1e1e)",
|
|
32
|
+
"color": "var(--wp-components-color-foreground, var(--wpds-color-foreground-content-neutral, #1e1e1e))",
|
|
33
33
|
"display": "block",
|
|
34
34
|
- "font-size": "calc(1.25 * 13px)",
|
|
35
35
|
+ "font-size": "calc(1.95 * 13px)",
|
|
@@ -48,7 +48,7 @@ Snapshot Diff:
|
|
|
48
48
|
@@ -1,10 +1,10 @@
|
|
49
49
|
Array [
|
|
50
50
|
Object {
|
|
51
|
-
"color": "var(--wp-components-color-foreground, #1e1e1e)",
|
|
51
|
+
"color": "var(--wp-components-color-foreground, var(--wpds-color-foreground-content-neutral, #1e1e1e))",
|
|
52
52
|
"display": "block",
|
|
53
53
|
- "font-size": "calc(1.25 * 13px)",
|
|
54
54
|
+ "font-size": "calc(1.95 * 13px)",
|
|
@@ -23,12 +23,10 @@ const MyComponentWithConstrainedTabbing = () => {
|
|
|
23
23
|
let form = (
|
|
24
24
|
<form>
|
|
25
25
|
<TextControl
|
|
26
|
-
__next40pxDefaultSize
|
|
27
26
|
label="Input 1"
|
|
28
27
|
onChange={ () => {} }
|
|
29
28
|
/>
|
|
30
29
|
<TextControl
|
|
31
|
-
__next40pxDefaultSize
|
|
32
30
|
label="Input 2"
|
|
33
31
|
onChange={ () => {} }
|
|
34
32
|
/>
|
|
@@ -6,19 +6,17 @@ import fastDeepEqual from 'fast-deep-equal/es6/index.js';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { useState, useRef } from '@wordpress/element';
|
|
10
|
+
import {
|
|
11
|
+
createHigherOrderComponent,
|
|
12
|
+
useIsomorphicLayoutEffect,
|
|
13
|
+
} from '@wordpress/compose';
|
|
11
14
|
|
|
12
15
|
type Props = {
|
|
13
16
|
node?: HTMLElement;
|
|
14
17
|
[ key: string ]: any;
|
|
15
18
|
};
|
|
16
19
|
|
|
17
|
-
type State = {
|
|
18
|
-
fallbackStyles?: { [ key: string ]: any };
|
|
19
|
-
grabStylesCompleted: boolean;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
20
|
export default (
|
|
23
21
|
mapNodeToProps: (
|
|
24
22
|
node: HTMLElement,
|
|
@@ -26,69 +24,41 @@ export default (
|
|
|
26
24
|
) => { [ key: string ]: any }
|
|
27
25
|
) =>
|
|
28
26
|
createHigherOrderComponent( ( WrappedComponent ) => {
|
|
29
|
-
return
|
|
30
|
-
|
|
27
|
+
return function WithFallbackStyles( props: Props ) {
|
|
28
|
+
const [ fallbackStyles, setFallbackStyles ] = useState<
|
|
29
|
+
{ [ key: string ]: any } | undefined
|
|
30
|
+
>( undefined );
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
super( props );
|
|
34
|
-
this.nodeRef = this.props.node;
|
|
35
|
-
this.state = {
|
|
36
|
-
fallbackStyles: undefined,
|
|
37
|
-
grabStylesCompleted: false,
|
|
38
|
-
};
|
|
32
|
+
const nodeRef = useRef< HTMLDivElement >( null );
|
|
39
33
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
34
|
+
// Runs before paint, so the fallback styles apply without a flash.
|
|
35
|
+
useIsomorphicLayoutEffect( () => {
|
|
36
|
+
const node = props.node ?? nodeRef.current;
|
|
37
|
+
// Derived from fallbackStyles: the grab is complete once every
|
|
38
|
+
// mapped value has resolved to a truthy style.
|
|
39
|
+
const grabStylesCompleted =
|
|
40
|
+
!! fallbackStyles &&
|
|
41
|
+
Object.values( fallbackStyles ).every( Boolean );
|
|
49
42
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
componentDidUpdate() {
|
|
55
|
-
this.grabFallbackStyles();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
grabFallbackStyles() {
|
|
59
|
-
const { grabStylesCompleted, fallbackStyles } = this.state;
|
|
60
|
-
if ( this.nodeRef && ! grabStylesCompleted ) {
|
|
61
|
-
const newFallbackStyles = mapNodeToProps(
|
|
62
|
-
this.nodeRef,
|
|
63
|
-
this.props
|
|
64
|
-
);
|
|
43
|
+
if ( node && ! grabStylesCompleted ) {
|
|
44
|
+
const newFallbackStyles = mapNodeToProps( node, props );
|
|
65
45
|
|
|
66
46
|
if (
|
|
67
47
|
! fastDeepEqual( newFallbackStyles, fallbackStyles )
|
|
68
48
|
) {
|
|
69
|
-
|
|
70
|
-
fallbackStyles: newFallbackStyles,
|
|
71
|
-
grabStylesCompleted:
|
|
72
|
-
Object.values( newFallbackStyles ).every(
|
|
73
|
-
Boolean
|
|
74
|
-
),
|
|
75
|
-
} );
|
|
49
|
+
setFallbackStyles( newFallbackStyles );
|
|
76
50
|
}
|
|
77
51
|
}
|
|
78
|
-
}
|
|
52
|
+
} );
|
|
53
|
+
|
|
54
|
+
const wrappedComponent = (
|
|
55
|
+
<WrappedComponent { ...props } { ...fallbackStyles } />
|
|
56
|
+
);
|
|
79
57
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
/>
|
|
86
|
-
);
|
|
87
|
-
return this.props.node ? (
|
|
88
|
-
wrappedComponent
|
|
89
|
-
) : (
|
|
90
|
-
<div ref={ this.bindRef }> { wrappedComponent } </div>
|
|
91
|
-
);
|
|
92
|
-
}
|
|
58
|
+
return props.node ? (
|
|
59
|
+
wrappedComponent
|
|
60
|
+
) : (
|
|
61
|
+
<div ref={ nodeRef }> { wrappedComponent } </div>
|
|
62
|
+
);
|
|
93
63
|
};
|
|
94
64
|
}, 'withFallbackStyles' );
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import withFallbackStyles from '..';
|
|
10
|
+
|
|
11
|
+
describe( 'withFallbackStyles', () => {
|
|
12
|
+
const Wrapped = ( props: { fallbackColor?: string } ) => (
|
|
13
|
+
<div>{ props.fallbackColor ?? 'no-fallback' }</div>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
it( 'derives the fallback styles from the provided node prop', () => {
|
|
17
|
+
const node = document.createElement( 'span' );
|
|
18
|
+
node.dataset.color = 'rgb(1, 2, 3)';
|
|
19
|
+
const mapNodeToProps = jest.fn( ( el: HTMLElement ) => ( {
|
|
20
|
+
fallbackColor: el.dataset.color,
|
|
21
|
+
} ) );
|
|
22
|
+
const Component = withFallbackStyles( mapNodeToProps )( Wrapped );
|
|
23
|
+
|
|
24
|
+
render( <Component node={ node } /> );
|
|
25
|
+
|
|
26
|
+
// The rendered value proves the actual node was read by mapNodeToProps.
|
|
27
|
+
expect( mapNodeToProps ).toHaveBeenCalledWith(
|
|
28
|
+
node,
|
|
29
|
+
expect.objectContaining( { node } )
|
|
30
|
+
);
|
|
31
|
+
expect( screen.getByText( 'rgb(1, 2, 3)' ) ).toBeInTheDocument();
|
|
32
|
+
} );
|
|
33
|
+
|
|
34
|
+
it( 'derives the fallback styles from the internal wrapper node when no node prop is given', () => {
|
|
35
|
+
const mapNodeToProps = jest.fn( ( el: HTMLElement ) => ( {
|
|
36
|
+
fallbackColor: el.tagName.toLowerCase(),
|
|
37
|
+
} ) );
|
|
38
|
+
const Component = withFallbackStyles( mapNodeToProps )( Wrapped );
|
|
39
|
+
|
|
40
|
+
render( <Component /> );
|
|
41
|
+
|
|
42
|
+
// The HOC wraps in a <div>, so reading the node's tagName yields 'div'.
|
|
43
|
+
expect( mapNodeToProps ).toHaveBeenCalled();
|
|
44
|
+
expect( mapNodeToProps.mock.calls[ 0 ][ 0 ].tagName ).toBe( 'DIV' );
|
|
45
|
+
expect( screen.getByText( 'div' ) ).toBeInTheDocument();
|
|
46
|
+
} );
|
|
47
|
+
} );
|
|
@@ -14,7 +14,6 @@ const EnhancedComponent = withFocusReturn( () => (
|
|
|
14
14
|
<div>
|
|
15
15
|
Focus will return to the previous input when this component is unmounted
|
|
16
16
|
<TextControl
|
|
17
|
-
__next40pxDefaultSize
|
|
18
17
|
autoFocus={ true }
|
|
19
18
|
onChange={ () => {} }
|
|
20
19
|
/>
|
|
@@ -31,7 +30,6 @@ const MyComponentWithFocusReturn = () => {
|
|
|
31
30
|
return (
|
|
32
31
|
<div>
|
|
33
32
|
<TextControl
|
|
34
|
-
__next40pxDefaultSize
|
|
35
33
|
placeholder="Type something"
|
|
36
34
|
value={ text }
|
|
37
35
|
onChange={ ( value ) => setText( value ) }
|
|
@@ -26,21 +26,6 @@ Default.args = {
|
|
|
26
26
|
icon: wordpress,
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
export const FillColor: StoryFn< typeof Icon > = ( args ) => {
|
|
30
|
-
return (
|
|
31
|
-
<div
|
|
32
|
-
style={ {
|
|
33
|
-
fill: 'blue',
|
|
34
|
-
} }
|
|
35
|
-
>
|
|
36
|
-
<Icon { ...args } />
|
|
37
|
-
</div>
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
FillColor.args = {
|
|
41
|
-
...Default.args,
|
|
42
|
-
};
|
|
43
|
-
|
|
44
29
|
/**
|
|
45
30
|
* When `icon` is a function, it will be passed the `size` prop and any other additional props.
|
|
46
31
|
*/
|
package/src/menu/README.md
CHANGED
|
@@ -306,7 +306,7 @@ that don't support the native `disabled` attribute.
|
|
|
306
306
|
The checked state of the radio menu item when it is initially rendered.
|
|
307
307
|
Use when not wanting to control its checked state.
|
|
308
308
|
|
|
309
|
-
Note: this prop will be
|
|
309
|
+
Note: this prop will be overridden by the `checked` prop, if it is defined.
|
|
310
310
|
|
|
311
311
|
##### `hideOnClick`
|
|
312
312
|
|
|
@@ -404,7 +404,7 @@ that don't support the native `disabled` attribute.
|
|
|
404
404
|
The checked state of the checkbox menu item when it is initially rendered.
|
|
405
405
|
Use when not wanting to control its checked state.
|
|
406
406
|
|
|
407
|
-
Note: this prop will be
|
|
407
|
+
Note: this prop will be overridden by the `checked` prop, if it is defined.
|
|
408
408
|
|
|
409
409
|
##### `hideOnClick`
|
|
410
410
|
|
package/src/menu/styles.ts
CHANGED
|
@@ -22,7 +22,9 @@ const ITEM_PADDING_INLINE = space( 3 );
|
|
|
22
22
|
// - border color and divider color are different from COLORS.theme variables
|
|
23
23
|
// - lighter text color is not defined in COLORS.theme, should it be?
|
|
24
24
|
// - lighter background color is not defined in COLORS.theme, should it be?
|
|
25
|
+
// TODO: should use the `stroke-surface-neutral` WPDS token when refactored to SCSS modules
|
|
25
26
|
const DEFAULT_BORDER_COLOR = COLORS.theme.gray[ 300 ];
|
|
27
|
+
// TODO: should use the `stroke-surface-neutral-weak` WPDS token when refactored to SCSS modules
|
|
26
28
|
const DIVIDER_COLOR = COLORS.theme.gray[ 200 ];
|
|
27
29
|
const LIGHTER_TEXT_COLOR = COLORS.theme.gray[ 700 ];
|
|
28
30
|
const LIGHT_BACKGROUND_COLOR = COLORS.theme.gray[ 100 ];
|