@wordpress/components 25.9.1 → 25.11.1-next.f8d8eceb.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 +48 -0
- package/build/alignment-matrix-control/cell.js +8 -5
- package/build/alignment-matrix-control/cell.js.map +1 -1
- package/build/alignment-matrix-control/index.js +27 -43
- package/build/alignment-matrix-control/index.js.map +1 -1
- package/build/alignment-matrix-control/utils.js +29 -9
- package/build/alignment-matrix-control/utils.js.map +1 -1
- package/build/autocomplete/index.js +104 -52
- package/build/autocomplete/index.js.map +1 -1
- package/build/circular-option-picker/circular-option-picker-option.js +20 -39
- package/build/circular-option-picker/circular-option-picker-option.js.map +1 -1
- package/build/circular-option-picker/circular-option-picker.js +11 -32
- package/build/circular-option-picker/circular-option-picker.js.map +1 -1
- package/build/circular-option-picker/types.js.map +1 -1
- package/build/color-palette/index.js +7 -2
- package/build/color-palette/index.js.map +1 -1
- package/build/color-picker/component.js +12 -2
- package/build/color-picker/component.js.map +1 -1
- package/build/color-picker/picker.js +77 -1
- package/build/color-picker/picker.js.map +1 -1
- package/build/color-picker/styles.js +8 -8
- package/build/color-picker/styles.js.map +1 -1
- package/build/color-picker/types.js.map +1 -1
- package/build/composite/v2.js +43 -0
- package/build/composite/v2.js.map +1 -0
- package/build/confirm-dialog/component.js +74 -8
- package/build/confirm-dialog/component.js.map +1 -1
- package/build/confirm-dialog/types.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/control-points.js +13 -4
- package/build/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
- package/build/dropdown-menu-v2-ariakit/index.js +217 -0
- package/build/dropdown-menu-v2-ariakit/index.js.map +1 -0
- package/build/dropdown-menu-v2-ariakit/styles.js +157 -0
- package/build/dropdown-menu-v2-ariakit/styles.js.map +1 -0
- package/build/dropdown-menu-v2-ariakit/types.js +6 -0
- package/build/dropdown-menu-v2-ariakit/types.js.map +1 -0
- package/build/font-size-picker/utils.js +1 -1
- package/build/font-size-picker/utils.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +23 -23
- package/build/input-control/styles/input-control-styles.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/modal/index.js +45 -16
- package/build/modal/index.js.map +1 -1
- package/build/palette-edit/index.js +4 -0
- package/build/palette-edit/index.js.map +1 -1
- package/build/popover/index.js +34 -6
- package/build/popover/index.js.map +1 -1
- package/build/private-apis.js +18 -2
- package/build/private-apis.js.map +1 -1
- package/build/progress-bar/styles.js +5 -5
- package/build/progress-bar/styles.js.map +1 -1
- package/build/sandbox/index.js +1 -1
- package/build/sandbox/index.js.map +1 -1
- package/build/sandbox/index.native.js +1 -1
- package/build/sandbox/index.native.js.map +1 -1
- package/build/select-control/styles/select-control-styles.js +8 -8
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- package/build/tabs/context.js +16 -0
- package/build/tabs/context.js.map +1 -0
- package/build/tabs/index.js +147 -0
- package/build/tabs/index.js.map +1 -0
- package/build/tabs/styles.js +38 -0
- package/build/tabs/styles.js.map +1 -0
- package/build/tabs/tab.js +46 -0
- package/build/tabs/tab.js.map +1 -0
- package/build/tabs/tablist.js +47 -0
- package/build/tabs/tablist.js.map +1 -0
- package/build/tabs/tabpanel.js +48 -0
- package/build/tabs/tabpanel.js.map +1 -0
- package/build/tabs/types.js +6 -0
- package/build/tabs/types.js.map +1 -0
- package/build/text/component.js +7 -6
- package/build/text/component.js.map +1 -1
- package/build/text/hook.js +6 -15
- package/build/text/hook.js.map +1 -1
- package/build/text/index.js.map +1 -1
- package/build/text/styles.js +7 -7
- package/build/text/styles.js.map +1 -1
- package/build/text/types.js.map +1 -1
- package/build/text/utils.js +17 -33
- package/build/text/utils.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option-base/component.js +1 -0
- package/build/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
- package/build/toolbar/toolbar/index.js +17 -10
- package/build/toolbar/toolbar/index.js.map +1 -1
- package/build/toolbar/toolbar/types.js.map +1 -1
- package/build/tools-panel/tools-panel-item/hook.js +2 -2
- package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build/tools-panel/types.js.map +1 -1
- package/build/tooltip/index.js +2 -2
- package/build/tooltip/index.js.map +1 -1
- package/build/unit-control/utils.js +108 -0
- package/build/unit-control/utils.js.map +1 -1
- package/build/utils/unit-values.js +1 -1
- package/build/utils/unit-values.js.map +1 -1
- package/build-module/alignment-matrix-control/cell.js +7 -4
- package/build-module/alignment-matrix-control/cell.js.map +1 -1
- package/build-module/alignment-matrix-control/index.js +27 -43
- package/build-module/alignment-matrix-control/index.js.map +1 -1
- package/build-module/alignment-matrix-control/utils.js +29 -8
- package/build-module/alignment-matrix-control/utils.js.map +1 -1
- package/build-module/autocomplete/index.js +104 -52
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/circular-option-picker/circular-option-picker-option.js +20 -39
- package/build-module/circular-option-picker/circular-option-picker-option.js.map +1 -1
- package/build-module/circular-option-picker/circular-option-picker.js +10 -31
- package/build-module/circular-option-picker/circular-option-picker.js.map +1 -1
- package/build-module/circular-option-picker/types.js.map +1 -1
- package/build-module/color-palette/index.js +7 -2
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-picker/component.js +13 -3
- package/build-module/color-picker/component.js.map +1 -1
- package/build-module/color-picker/picker.js +78 -2
- package/build-module/color-picker/picker.js.map +1 -1
- package/build-module/color-picker/styles.js +8 -8
- package/build-module/color-picker/styles.js.map +1 -1
- package/build-module/color-picker/types.js.map +1 -1
- package/build-module/composite/v2.js +15 -0
- package/build-module/composite/v2.js.map +1 -0
- package/build-module/confirm-dialog/component.js +72 -7
- package/build-module/confirm-dialog/component.js.map +1 -1
- package/build-module/confirm-dialog/types.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/control-points.js +13 -4
- package/build-module/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
- package/build-module/dropdown-menu-v2-ariakit/index.js +199 -0
- package/build-module/dropdown-menu-v2-ariakit/index.js.map +1 -0
- package/build-module/dropdown-menu-v2-ariakit/styles.js +136 -0
- package/build-module/dropdown-menu-v2-ariakit/styles.js.map +1 -0
- package/build-module/dropdown-menu-v2-ariakit/types.js +2 -0
- package/build-module/dropdown-menu-v2-ariakit/types.js.map +1 -0
- package/build-module/font-size-picker/utils.js +1 -1
- package/build-module/font-size-picker/utils.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +23 -23
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +2 -2
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/modal/index.js +47 -18
- package/build-module/modal/index.js.map +1 -1
- package/build-module/palette-edit/index.js +4 -0
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/popover/index.js +34 -6
- package/build-module/popover/index.js.map +1 -1
- package/build-module/private-apis.js +18 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/progress-bar/styles.js +5 -5
- package/build-module/progress-bar/styles.js.map +1 -1
- package/build-module/sandbox/index.js +1 -1
- package/build-module/sandbox/index.js.map +1 -1
- package/build-module/sandbox/index.native.js +1 -1
- package/build-module/sandbox/index.native.js.map +1 -1
- package/build-module/select-control/styles/select-control-styles.js +8 -8
- package/build-module/select-control/styles/select-control-styles.js.map +1 -1
- package/build-module/tabs/context.js +12 -0
- package/build-module/tabs/context.js.map +1 -0
- package/build-module/tabs/index.js +142 -0
- package/build-module/tabs/index.js.map +1 -0
- package/build-module/tabs/styles.js +36 -0
- package/build-module/tabs/styles.js.map +1 -0
- package/build-module/tabs/tab.js +43 -0
- package/build-module/tabs/tab.js.map +1 -0
- package/build-module/tabs/tablist.js +41 -0
- package/build-module/tabs/tablist.js.map +1 -0
- package/build-module/tabs/tabpanel.js +43 -0
- package/build-module/tabs/tabpanel.js.map +1 -0
- package/build-module/tabs/types.js +2 -0
- package/build-module/tabs/types.js.map +1 -0
- package/build-module/text/component.js +6 -6
- package/build-module/text/component.js.map +1 -1
- package/build-module/text/hook.js +11 -19
- package/build-module/text/hook.js.map +1 -1
- package/build-module/text/index.js.map +1 -1
- package/build-module/text/styles.js +7 -7
- package/build-module/text/styles.js.map +1 -1
- package/build-module/text/types.js.map +1 -1
- package/build-module/text/utils.js +17 -10
- package/build-module/text/utils.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option-base/component.js +1 -0
- package/build-module/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
- package/build-module/toolbar/toolbar/index.js +18 -11
- package/build-module/toolbar/toolbar/index.js.map +1 -1
- package/build-module/toolbar/toolbar/types.js.map +1 -1
- package/build-module/tools-panel/tools-panel-item/hook.js +2 -2
- package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build-module/tools-panel/types.js.map +1 -1
- package/build-module/tooltip/index.js +2 -2
- package/build-module/tooltip/index.js.map +1 -1
- package/build-module/unit-control/utils.js +108 -0
- package/build-module/unit-control/utils.js.map +1 -1
- package/build-module/utils/unit-values.js +1 -1
- package/build-module/utils/unit-values.js.map +1 -1
- package/build-style/style-rtl.css +17 -5
- package/build-style/style.css +17 -5
- package/build-types/alignment-matrix-control/cell.d.ts +1 -1
- package/build-types/alignment-matrix-control/cell.d.ts.map +1 -1
- package/build-types/alignment-matrix-control/index.d.ts.map +1 -1
- package/build-types/alignment-matrix-control/stories/index.story.d.ts.map +1 -1
- package/build-types/alignment-matrix-control/utils.d.ts +9 -9
- package/build-types/alignment-matrix-control/utils.d.ts.map +1 -1
- package/build-types/autocomplete/index.d.ts.map +1 -1
- package/build-types/circular-option-picker/circular-option-picker-option.d.ts.map +1 -1
- package/build-types/circular-option-picker/circular-option-picker.d.ts.map +1 -1
- package/build-types/circular-option-picker/types.d.ts +4 -6
- package/build-types/circular-option-picker/types.d.ts.map +1 -1
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/color-picker/component.d.ts.map +1 -1
- package/build-types/color-picker/picker.d.ts +1 -1
- package/build-types/color-picker/picker.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/color-picker/types.d.ts +3 -0
- package/build-types/color-picker/types.d.ts.map +1 -1
- package/build-types/composite/v2.d.ts +12 -0
- package/build-types/composite/v2.d.ts.map +1 -0
- package/build-types/confirm-dialog/component.d.ts +70 -29
- package/build-types/confirm-dialog/component.d.ts.map +1 -1
- package/build-types/confirm-dialog/stories/index.story.d.ts +11 -0
- package/build-types/confirm-dialog/stories/index.story.d.ts.map +1 -0
- package/build-types/confirm-dialog/test/index.d.ts +2 -0
- package/build-types/confirm-dialog/test/index.d.ts.map +1 -0
- package/build-types/confirm-dialog/types.d.ts +32 -10
- package/build-types/confirm-dialog/types.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/control-points.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2-ariakit/index.d.ts +11 -0
- package/build-types/dropdown-menu-v2-ariakit/index.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts +16 -0
- package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2-ariakit/styles.d.ts +88 -0
- package/build-types/dropdown-menu-v2-ariakit/styles.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2-ariakit/test/index.d.ts +2 -0
- package/build-types/dropdown-menu-v2-ariakit/test/index.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2-ariakit/types.d.ts +174 -0
- package/build-types/dropdown-menu-v2-ariakit/types.d.ts.map +1 -0
- package/build-types/font-size-picker/utils.d.ts.map +1 -1
- package/build-types/heading/stories/index.story.d.ts.map +1 -1
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/popover/index.d.ts +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/popover/stories/e2e/index.story.d.ts +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/progress-bar/styles.d.ts.map +1 -1
- package/build-types/sandbox/index.d.ts.map +1 -1
- package/build-types/tabs/context.d.ts +8 -0
- package/build-types/tabs/context.d.ts.map +1 -0
- package/build-types/tabs/index.d.ts +13 -0
- package/build-types/tabs/index.d.ts.map +1 -0
- package/build-types/tabs/stories/index.story.d.ts +20 -0
- package/build-types/tabs/stories/index.story.d.ts.map +1 -0
- package/build-types/tabs/styles.d.ts +17 -0
- package/build-types/tabs/styles.d.ts.map +1 -0
- package/build-types/tabs/tab.d.ts +10 -0
- package/build-types/tabs/tab.d.ts.map +1 -0
- package/build-types/tabs/tablist.d.ts +7 -0
- package/build-types/tabs/tablist.d.ts.map +1 -0
- package/build-types/tabs/tabpanel.d.ts +7 -0
- package/build-types/tabs/tabpanel.d.ts.map +1 -0
- package/build-types/tabs/test/index.d.ts +2 -0
- package/build-types/tabs/test/index.d.ts.map +1 -0
- package/build-types/tabs/types.d.ts +134 -0
- package/build-types/tabs/types.d.ts.map +1 -0
- package/build-types/text/component.d.ts +4 -2
- package/build-types/text/component.d.ts.map +1 -1
- package/build-types/text/hook.d.ts +171 -165
- package/build-types/text/hook.d.ts.map +1 -1
- package/build-types/text/index.d.ts +2 -2
- package/build-types/text/index.d.ts.map +1 -1
- package/build-types/text/stories/index.story.d.ts +21 -0
- package/build-types/text/stories/index.story.d.ts.map +1 -0
- package/build-types/text/styles.d.ts +7 -7
- package/build-types/text/styles.d.ts.map +1 -1
- package/build-types/text/types.d.ts +1 -1
- package/build-types/text/types.d.ts.map +1 -1
- package/build-types/text/utils.d.ts +56 -61
- package/build-types/text/utils.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
- package/build-types/toolbar/stories/index.story.d.ts +5 -0
- package/build-types/toolbar/stories/index.story.d.ts.map +1 -1
- package/build-types/toolbar/toolbar/index.d.ts.map +1 -1
- package/build-types/toolbar/toolbar/types.d.ts +10 -0
- package/build-types/toolbar/toolbar/types.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/build-types/tools-panel/types.d.ts +2 -0
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/build-types/unit-control/utils.d.ts.map +1 -1
- package/package.json +21 -20
- package/src/alignment-matrix-control/cell.tsx +6 -2
- package/src/alignment-matrix-control/index.tsx +31 -54
- package/src/alignment-matrix-control/stories/index.story.tsx +3 -7
- package/src/alignment-matrix-control/test/index.tsx +117 -18
- package/src/alignment-matrix-control/utils.tsx +33 -9
- package/src/autocomplete/index.tsx +136 -77
- package/src/button/style.scss +1 -2
- package/src/circular-option-picker/circular-option-picker-option.tsx +24 -38
- package/src/circular-option-picker/circular-option-picker.tsx +11 -28
- package/src/circular-option-picker/types.ts +6 -5
- package/src/color-palette/index.tsx +6 -1
- package/src/color-picker/component.tsx +25 -3
- package/src/color-picker/picker.tsx +96 -2
- package/src/color-picker/styles.ts +0 -1
- package/src/color-picker/types.ts +3 -0
- package/src/composite/v2.ts +22 -0
- package/src/confirm-dialog/README.md +1 -1
- package/src/confirm-dialog/component.tsx +79 -13
- package/src/confirm-dialog/stories/{index.story.js → index.story.tsx} +26 -24
- package/src/confirm-dialog/test/{index.js → index.tsx} +3 -3
- package/src/confirm-dialog/types.ts +32 -12
- package/src/custom-gradient-picker/gradient-bar/control-points.tsx +32 -25
- package/src/dimension-control/test/__snapshots__/index.test.js.snap +8 -8
- package/src/dropdown-menu-v2-ariakit/README.md +324 -0
- package/src/dropdown-menu-v2-ariakit/index.tsx +318 -0
- package/src/dropdown-menu-v2-ariakit/stories/index.story.tsx +506 -0
- package/src/dropdown-menu-v2-ariakit/styles.ts +297 -0
- package/src/dropdown-menu-v2-ariakit/test/index.tsx +1139 -0
- package/src/dropdown-menu-v2-ariakit/types.ts +186 -0
- package/src/font-size-picker/utils.ts +2 -1
- package/src/heading/stories/index.story.tsx +2 -4
- package/src/input-control/styles/input-control-styles.tsx +2 -2
- package/src/mobile/global-styles-context/utils.native.js +2 -2
- package/src/modal/index.tsx +58 -22
- package/src/modal/test/index.tsx +29 -0
- package/src/notice/style.scss +0 -1
- package/src/palette-edit/index.tsx +4 -0
- package/src/popover/index.tsx +99 -57
- package/src/popover/style.scss +9 -0
- package/src/private-apis.ts +31 -1
- package/src/progress-bar/styles.ts +19 -4
- package/src/sandbox/index.native.js +1 -1
- package/src/sandbox/index.tsx +3 -1
- package/src/select-control/styles/select-control-styles.ts +2 -2
- package/src/tabs/README.md +242 -0
- package/src/tabs/context.ts +13 -0
- package/src/tabs/index.tsx +167 -0
- package/src/tabs/stories/index.story.tsx +352 -0
- package/src/tabs/styles.ts +103 -0
- package/src/tabs/tab.tsx +39 -0
- package/src/tabs/tablist.tsx +40 -0
- package/src/tabs/tabpanel.tsx +42 -0
- package/src/tabs/test/index.tsx +1133 -0
- package/src/tabs/types.ts +142 -0
- package/src/text/README.md +2 -2
- package/src/text/{component.js → component.tsx} +10 -6
- package/src/text/{hook.js → hook.ts} +12 -15
- package/src/text/stories/index.story.tsx +80 -0
- package/src/text/types.ts +1 -6
- package/src/text/{utils.js → utils.ts} +40 -14
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +16 -0
- package/src/toggle-group-control/toggle-group-control-option-base/component.tsx +1 -0
- package/src/toolbar/stories/index.story.tsx +15 -0
- package/src/toolbar/test/index.tsx +8 -0
- package/src/toolbar/toolbar/README.md +9 -0
- package/src/toolbar/toolbar/index.tsx +21 -12
- package/src/toolbar/toolbar/style.scss +9 -0
- package/src/toolbar/toolbar/types.ts +10 -0
- package/src/tools-panel/tools-panel/README.md +3 -0
- package/src/tools-panel/tools-panel-item/hook.ts +4 -6
- package/src/tools-panel/types.ts +2 -0
- package/src/tooltip/index.tsx +2 -3
- package/src/unit-control/utils.ts +124 -0
- package/src/utils/unit-values.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/src/text/stories/index.story.js +0 -53
- /package/src/text/{index.js → index.ts} +0 -0
- /package/src/text/{styles.js → styles.ts} +0 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
// eslint-disable-next-line no-restricted-imports
|
|
5
|
+
import type * as Ariakit from '@ariakit/react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import type { IconType } from '../icon';
|
|
11
|
+
|
|
12
|
+
export type TabsContextProps =
|
|
13
|
+
| {
|
|
14
|
+
/**
|
|
15
|
+
* The tabStore object returned by Ariakit's `useTabStore` hook.
|
|
16
|
+
*/
|
|
17
|
+
store: Ariakit.TabStore;
|
|
18
|
+
/**
|
|
19
|
+
* The unique id string for this instance of the Tabs component.
|
|
20
|
+
*/
|
|
21
|
+
instanceId: string;
|
|
22
|
+
}
|
|
23
|
+
| undefined;
|
|
24
|
+
|
|
25
|
+
export type TabsProps = {
|
|
26
|
+
/**
|
|
27
|
+
* The children elements, which should be at least a
|
|
28
|
+
* `Tabs.Tablist` component and a series of `Tabs.TabPanel`
|
|
29
|
+
* components.
|
|
30
|
+
*/
|
|
31
|
+
children: React.ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* When `true`, the tab will be selected when receiving focus (automatic tab
|
|
34
|
+
* activation). When `false`, the tab will be selected only when clicked
|
|
35
|
+
* (manual tab activation). See the official W3C docs for more info.
|
|
36
|
+
*
|
|
37
|
+
* @default true
|
|
38
|
+
*
|
|
39
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/tabpanel/
|
|
40
|
+
*/
|
|
41
|
+
selectOnMove?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The id of the tab to be selected upon mounting of component.
|
|
44
|
+
* If this prop is not set, the first tab will be selected by default.
|
|
45
|
+
* The id provided will be internally prefixed with the
|
|
46
|
+
* `TabsContextProps.instanceId`.
|
|
47
|
+
*
|
|
48
|
+
* Note: this prop will be overridden by the `selectedTabId` prop if it is
|
|
49
|
+
* provided. (Controlled Mode)
|
|
50
|
+
*/
|
|
51
|
+
initialTabId?: string;
|
|
52
|
+
/**
|
|
53
|
+
* The function called when a tab has been selected.
|
|
54
|
+
* It is passed the id of the newly selected tab as an argument.
|
|
55
|
+
*/
|
|
56
|
+
onSelect?: ( selectedId: string | null | undefined ) => void;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The orientation of the tablist.
|
|
60
|
+
*
|
|
61
|
+
* @default `horizontal`
|
|
62
|
+
*/
|
|
63
|
+
orientation?: 'horizontal' | 'vertical';
|
|
64
|
+
/**
|
|
65
|
+
* The Id of the tab to display. This id is prepended with the `Tabs`
|
|
66
|
+
* instanceId internally.
|
|
67
|
+
*
|
|
68
|
+
* If left `undefined`, the component assumes it is being used in
|
|
69
|
+
* uncontrolled mode. Consequently, any value different than `undefined`
|
|
70
|
+
* will set the component in `controlled` mode.
|
|
71
|
+
* When in controlled mode, the `null` value will result in no tab being selected.
|
|
72
|
+
*/
|
|
73
|
+
selectedTabId?: string | null;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type TabListProps = {
|
|
77
|
+
/**
|
|
78
|
+
* The children elements, which should be a series of `Tabs.TabPanel` components.
|
|
79
|
+
*/
|
|
80
|
+
children?: React.ReactNode;
|
|
81
|
+
/**
|
|
82
|
+
* The class name to apply to the tablist.
|
|
83
|
+
*/
|
|
84
|
+
className?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Custom CSS styles for the rendered tablist.
|
|
87
|
+
*/
|
|
88
|
+
style?: React.CSSProperties;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export type TabProps = {
|
|
92
|
+
/**
|
|
93
|
+
* The id of the tab, which is prepended with the `Tabs` instanceId.
|
|
94
|
+
*/
|
|
95
|
+
id: string;
|
|
96
|
+
/**
|
|
97
|
+
* Custom CSS styles for the tab.
|
|
98
|
+
*/
|
|
99
|
+
style?: React.CSSProperties;
|
|
100
|
+
/**
|
|
101
|
+
* The children elements, generally the text to display on the tab.
|
|
102
|
+
*/
|
|
103
|
+
children?: React.ReactNode;
|
|
104
|
+
/**
|
|
105
|
+
* The class name to apply to the tab button.
|
|
106
|
+
*/
|
|
107
|
+
className?: string;
|
|
108
|
+
/**
|
|
109
|
+
* The icon used for the tab button.
|
|
110
|
+
*/
|
|
111
|
+
icon?: IconType;
|
|
112
|
+
/**
|
|
113
|
+
* Determines if the tab button should be disabled.
|
|
114
|
+
*
|
|
115
|
+
* @default false
|
|
116
|
+
*/
|
|
117
|
+
disabled?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* The type of component to render the tab button as. If this prop is not
|
|
120
|
+
* provided, the tab button will be rendered as a `button` element.
|
|
121
|
+
*/
|
|
122
|
+
render?: React.ReactElement;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export type TabPanelProps = {
|
|
126
|
+
/**
|
|
127
|
+
* The children elements, generally the content to display on the tabpanel.
|
|
128
|
+
*/
|
|
129
|
+
children?: React.ReactNode;
|
|
130
|
+
/**
|
|
131
|
+
* A unique identifier for the TabPanel, which is used to generate a unique `id` for the underlying element.
|
|
132
|
+
*/
|
|
133
|
+
id: string;
|
|
134
|
+
/**
|
|
135
|
+
* The class name to apply to the tabpanel.
|
|
136
|
+
*/
|
|
137
|
+
className?: string;
|
|
138
|
+
/**
|
|
139
|
+
* Custom CSS styles for the rendered `TabPanel` component.
|
|
140
|
+
*/
|
|
141
|
+
style?: React.CSSProperties;
|
|
142
|
+
};
|
package/src/text/README.md
CHANGED
|
@@ -22,7 +22,7 @@ function Example() {
|
|
|
22
22
|
|
|
23
23
|
### adjustLineHeightForInnerControls
|
|
24
24
|
|
|
25
|
-
**Type**: `
|
|
25
|
+
**Type**: `"large"`,`"medium"`,`"small"`,`"xSmall"`
|
|
26
26
|
|
|
27
27
|
Automatically calculate the appropriate line-height value for contents that render text and Control elements (e.g. `TextInput`).
|
|
28
28
|
|
|
@@ -31,7 +31,7 @@ import { __experimentalText as Text, TextInput } from '@wordpress/components';
|
|
|
31
31
|
|
|
32
32
|
function Example() {
|
|
33
33
|
return (
|
|
34
|
-
<Text adjustLineHeightForInnerControls>
|
|
34
|
+
<Text adjustLineHeightForInnerControls={"small"}>
|
|
35
35
|
Lorem ipsum dolor sit amet, consectetur
|
|
36
36
|
<TextInput value="adipiscing elit..." />
|
|
37
37
|
</Text>
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
+
import type { WordPressComponentProps } from '../context';
|
|
4
5
|
import { contextConnect } from '../context';
|
|
5
6
|
import { View } from '../view';
|
|
6
7
|
import useText from './hook';
|
|
8
|
+
import type { Props } from './types';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
11
|
+
* @param props
|
|
12
|
+
* @param forwardedRef
|
|
11
13
|
*/
|
|
12
|
-
function
|
|
14
|
+
function UnconnectedText(
|
|
15
|
+
props: WordPressComponentProps< Props, 'span' >,
|
|
16
|
+
forwardedRef: React.ForwardedRef< any >
|
|
17
|
+
) {
|
|
13
18
|
const textProps = useText( props );
|
|
14
19
|
|
|
15
20
|
return <View as="span" { ...textProps } ref={ forwardedRef } />;
|
|
@@ -31,6 +36,5 @@ function Text( props, forwardedRef ) {
|
|
|
31
36
|
* }
|
|
32
37
|
* ```
|
|
33
38
|
*/
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
export default ConnectedText;
|
|
39
|
+
export const Text = contextConnect( UnconnectedText, 'Text' );
|
|
40
|
+
export default Text;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
+
import type { SerializedStyles } from '@emotion/react';
|
|
4
5
|
import { css } from '@emotion/react';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -11,6 +12,7 @@ import { useMemo, Children, cloneElement } from '@wordpress/element';
|
|
|
11
12
|
/**
|
|
12
13
|
* Internal dependencies
|
|
13
14
|
*/
|
|
15
|
+
import type { WordPressComponentProps } from '../context';
|
|
14
16
|
import { hasConnectNamespace, useContextSystem } from '../context';
|
|
15
17
|
import { useTruncate } from '../truncate';
|
|
16
18
|
import { getOptimalTextShade } from '../utils/colors';
|
|
@@ -20,11 +22,15 @@ import { getFontSize } from '../utils/font-size';
|
|
|
20
22
|
import { CONFIG, COLORS } from '../utils';
|
|
21
23
|
import { getLineHeight } from './get-line-height';
|
|
22
24
|
import { useCx } from '../utils/hooks/use-cx';
|
|
25
|
+
import type { Props } from './types';
|
|
26
|
+
import type React from 'react';
|
|
23
27
|
|
|
24
28
|
/**
|
|
25
29
|
* @param {import('../context').WordPressComponentProps<import('./types').Props, 'span'>} props
|
|
26
30
|
*/
|
|
27
|
-
export default function useText(
|
|
31
|
+
export default function useText(
|
|
32
|
+
props: WordPressComponentProps< Props, 'span' >
|
|
33
|
+
) {
|
|
28
34
|
const {
|
|
29
35
|
adjustLineHeightForInnerControls,
|
|
30
36
|
align,
|
|
@@ -50,8 +56,7 @@ export default function useText( props ) {
|
|
|
50
56
|
...otherProps
|
|
51
57
|
} = useContextSystem( props, 'Text' );
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
let content = children;
|
|
59
|
+
let content: React.ReactNode = children;
|
|
55
60
|
const isHighlighter = Array.isArray( highlightWords );
|
|
56
61
|
const isCaption = size === 'caption';
|
|
57
62
|
|
|
@@ -64,9 +69,7 @@ export default function useText( props ) {
|
|
|
64
69
|
|
|
65
70
|
content = createHighlighterText( {
|
|
66
71
|
autoEscape: highlightEscape,
|
|
67
|
-
|
|
68
|
-
// eslint-disable-next-line object-shorthand
|
|
69
|
-
children: /** @type {string} */ ( children ),
|
|
72
|
+
children,
|
|
70
73
|
caseSensitive: highlightCaseSensitive,
|
|
71
74
|
searchWords: highlightWords,
|
|
72
75
|
sanitize: highlightSanitize,
|
|
@@ -76,7 +79,7 @@ export default function useText( props ) {
|
|
|
76
79
|
const cx = useCx();
|
|
77
80
|
|
|
78
81
|
const classes = useMemo( () => {
|
|
79
|
-
const sx = {};
|
|
82
|
+
const sx: Record< string, SerializedStyles | null > = {};
|
|
80
83
|
|
|
81
84
|
const lineHeight = getLineHeight(
|
|
82
85
|
adjustLineHeightForInnerControls,
|
|
@@ -87,12 +90,7 @@ export default function useText( props ) {
|
|
|
87
90
|
color,
|
|
88
91
|
display,
|
|
89
92
|
fontSize: getFontSize( size ),
|
|
90
|
-
|
|
91
|
-
fontWeight:
|
|
92
|
-
/** @type {import('react').CSSProperties['fontWeight']} */ (
|
|
93
|
-
weight
|
|
94
|
-
),
|
|
95
|
-
/* eslint-enable jsdoc/valid-types */
|
|
93
|
+
fontWeight: weight,
|
|
96
94
|
lineHeight,
|
|
97
95
|
letterSpacing,
|
|
98
96
|
textAlign: align,
|
|
@@ -143,8 +141,7 @@ export default function useText( props ) {
|
|
|
143
141
|
weight,
|
|
144
142
|
] );
|
|
145
143
|
|
|
146
|
-
|
|
147
|
-
let finalEllipsizeMode;
|
|
144
|
+
let finalEllipsizeMode: undefined | 'auto' | 'none';
|
|
148
145
|
if ( truncate === true ) {
|
|
149
146
|
finalEllipsizeMode = 'auto';
|
|
150
147
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { Meta, StoryFn } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { Text } from '../component';
|
|
10
|
+
|
|
11
|
+
const meta: Meta< typeof Text > = {
|
|
12
|
+
component: Text,
|
|
13
|
+
title: 'Components (Experimental)/Text',
|
|
14
|
+
argTypes: {
|
|
15
|
+
as: { control: { type: 'text' } },
|
|
16
|
+
color: { control: { type: 'color' } },
|
|
17
|
+
display: { control: { type: 'text' } },
|
|
18
|
+
lineHeight: { control: { type: 'text' } },
|
|
19
|
+
letterSpacing: { control: { type: 'text' } },
|
|
20
|
+
optimizeReadabilityFor: { control: { type: 'color' } },
|
|
21
|
+
size: { control: { type: 'text' } },
|
|
22
|
+
variant: {
|
|
23
|
+
options: [ undefined, 'muted' ],
|
|
24
|
+
control: { type: 'select' },
|
|
25
|
+
},
|
|
26
|
+
weight: { control: { type: 'text' } },
|
|
27
|
+
},
|
|
28
|
+
parameters: {
|
|
29
|
+
actions: { argTypesRegex: '^on.*' },
|
|
30
|
+
controls: { expanded: true },
|
|
31
|
+
docs: { canvas: { sourceState: 'shown' } },
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
export default meta;
|
|
35
|
+
|
|
36
|
+
const Template: StoryFn< typeof Text > = ( props ) => {
|
|
37
|
+
return <Text { ...props } />;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const Default = Template.bind( {} );
|
|
41
|
+
Default.args = {
|
|
42
|
+
children: 'Code is poetry',
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const Truncate = Template.bind( {} );
|
|
46
|
+
Truncate.args = {
|
|
47
|
+
children: `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut
|
|
48
|
+
facilisis dictum tortor, eu tincidunt justo scelerisque tincidunt.
|
|
49
|
+
Duis semper dui id augue malesuada, ut feugiat nisi aliquam.
|
|
50
|
+
Vestibulum venenatis diam sem, finibus dictum massa semper in. Nulla
|
|
51
|
+
facilisi. Nunc vulputate faucibus diam, in lobortis arcu ornare vel.
|
|
52
|
+
In dignissim nunc sed facilisis finibus. Etiam imperdiet mattis
|
|
53
|
+
arcu, sed rutrum sapien blandit gravida. Aenean sollicitudin neque
|
|
54
|
+
eget enim blandit, sit amet rutrum leo vehicula. Nunc malesuada
|
|
55
|
+
ultricies eros ut faucibus. Aliquam erat volutpat. Nulla nec feugiat
|
|
56
|
+
risus. Vivamus iaculis dui aliquet ante ultricies feugiat.
|
|
57
|
+
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices
|
|
58
|
+
posuere cubilia curae; Vivamus nec pretium velit, sit amet
|
|
59
|
+
consectetur ante. Praesent porttitor ex eget fermentum mattis.`,
|
|
60
|
+
numberOfLines: 2,
|
|
61
|
+
truncate: true,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const Highlight = Template.bind( {} );
|
|
65
|
+
Highlight.args = {
|
|
66
|
+
children: `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut
|
|
67
|
+
facilisis dictum tortor, eu tincidunt justo scelerisque tincidunt.
|
|
68
|
+
Duis semper dui id augue malesuada, ut feugiat nisi aliquam.
|
|
69
|
+
Vestibulum venenatis diam sem, finibus dictum massa semper in. Nulla
|
|
70
|
+
facilisi. Nunc vulputate faucibus diam, in lobortis arcu ornare vel.
|
|
71
|
+
In dignissim nunc sed facilisis finibus. Etiam imperdiet mattis
|
|
72
|
+
arcu, sed rutrum sapien blandit gravida. Aenean sollicitudin neque
|
|
73
|
+
eget enim blandit, sit amet rutrum leo vehicula. Nunc malesuada
|
|
74
|
+
ultricies eros ut faucibus. Aliquam erat volutpat. Nulla nec feugiat
|
|
75
|
+
risus. Vivamus iaculis dui aliquet ante ultricies feugiat.
|
|
76
|
+
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices
|
|
77
|
+
posuere cubilia curae; Vivamus nec pretium velit, sit amet
|
|
78
|
+
consectetur ante. Praesent porttitor ex eget fermentum mattis.`,
|
|
79
|
+
highlightWords: [ 'con' ],
|
|
80
|
+
};
|
package/src/text/types.ts
CHANGED
|
@@ -29,12 +29,7 @@ export interface Props extends TruncateProps {
|
|
|
29
29
|
/**
|
|
30
30
|
* Automatically calculate the appropriate line-height value for contents that render text and Control elements (e.g. `TextInput`).
|
|
31
31
|
*/
|
|
32
|
-
adjustLineHeightForInnerControls?:
|
|
33
|
-
| boolean
|
|
34
|
-
| 'large'
|
|
35
|
-
| 'medium'
|
|
36
|
-
| 'small'
|
|
37
|
-
| 'xSmall';
|
|
32
|
+
adjustLineHeightForInnerControls?: 'large' | 'medium' | 'small' | 'xSmall';
|
|
38
33
|
/**
|
|
39
34
|
* Adjusts the text color.
|
|
40
35
|
*/
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import memoize from 'memize';
|
|
5
|
+
import type { FindAllArgs } from 'highlight-words-core';
|
|
5
6
|
import { findAll } from 'highlight-words-core';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -14,7 +15,6 @@ import { createElement } from '@wordpress/element';
|
|
|
14
15
|
* https://github.com/bvaughn/react-highlight-words/blob/HEAD/src/Highlighter.js
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
|
-
/* eslint-disable jsdoc/valid-types */
|
|
18
18
|
/**
|
|
19
19
|
* @typedef Options
|
|
20
20
|
* @property {string} [activeClassName=''] Classname for active highlighted areas.
|
|
@@ -33,28 +33,55 @@ import { createElement } from '@wordpress/element';
|
|
|
33
33
|
* @property {import('react').AllHTMLAttributes<HTMLDivElement>['style']} [unhighlightStyle] Style to apply to unhighlighted text.
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
|
+
interface Options {
|
|
37
|
+
activeClassName?: string;
|
|
38
|
+
activeIndex?: number;
|
|
39
|
+
activeStyle?: React.AllHTMLAttributes< HTMLDivElement >[ 'style' ];
|
|
40
|
+
autoEscape?: boolean;
|
|
41
|
+
caseSensitive?: boolean;
|
|
42
|
+
children: string;
|
|
43
|
+
findChunks?: FindAllArgs[ 'findChunks' ];
|
|
44
|
+
highlightClassName?: string | Record< string, unknown >;
|
|
45
|
+
highlightStyle?: React.AllHTMLAttributes< HTMLDivElement >[ 'style' ];
|
|
46
|
+
highlightTag?: keyof JSX.IntrinsicElements;
|
|
47
|
+
sanitize?: FindAllArgs[ 'sanitize' ];
|
|
48
|
+
searchWords?: string[];
|
|
49
|
+
unhighlightClassName?: string;
|
|
50
|
+
unhighlightStyle?: React.AllHTMLAttributes< HTMLDivElement >[ 'style' ];
|
|
51
|
+
}
|
|
52
|
+
|
|
36
53
|
/**
|
|
37
54
|
* Maps props to lowercase names.
|
|
38
55
|
*
|
|
39
|
-
* @
|
|
40
|
-
* @
|
|
41
|
-
* @return {{[K in keyof T as Lowercase<string & K>]: T[K]}} The mapped props.
|
|
56
|
+
* @param object Props to map.
|
|
57
|
+
* @return The mapped props.
|
|
42
58
|
*/
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
/** @type {any} */
|
|
46
|
-
const mapped = {};
|
|
59
|
+
const lowercaseProps = < T extends Record< string, unknown > >( object: T ) => {
|
|
60
|
+
const mapped: Record< string, unknown > = {};
|
|
47
61
|
for ( const key in object ) {
|
|
48
62
|
mapped[ key.toLowerCase() ] = object[ key ];
|
|
49
63
|
}
|
|
50
|
-
return mapped;
|
|
64
|
+
return mapped as { [ K in keyof T as Lowercase< string & K > ]: T[ K ] };
|
|
51
65
|
};
|
|
52
66
|
|
|
53
67
|
const memoizedLowercaseProps = memoize( lowercaseProps );
|
|
54
68
|
|
|
55
69
|
/**
|
|
56
|
-
*
|
|
57
|
-
* @param
|
|
70
|
+
* @param options
|
|
71
|
+
* @param options.activeClassName
|
|
72
|
+
* @param options.activeIndex
|
|
73
|
+
* @param options.activeStyle
|
|
74
|
+
* @param options.autoEscape
|
|
75
|
+
* @param options.caseSensitive
|
|
76
|
+
* @param options.children
|
|
77
|
+
* @param options.findChunks
|
|
78
|
+
* @param options.highlightClassName
|
|
79
|
+
* @param options.highlightStyle
|
|
80
|
+
* @param options.highlightTag
|
|
81
|
+
* @param options.sanitize
|
|
82
|
+
* @param options.searchWords
|
|
83
|
+
* @param options.unhighlightClassName
|
|
84
|
+
* @param options.unhighlightStyle
|
|
58
85
|
*/
|
|
59
86
|
export function createHighlighterText( {
|
|
60
87
|
activeClassName = '',
|
|
@@ -71,7 +98,7 @@ export function createHighlighterText( {
|
|
|
71
98
|
searchWords = [],
|
|
72
99
|
unhighlightClassName = '',
|
|
73
100
|
unhighlightStyle,
|
|
74
|
-
} ) {
|
|
101
|
+
}: Options ) {
|
|
75
102
|
if ( ! children ) return null;
|
|
76
103
|
if ( typeof children !== 'string' ) return children;
|
|
77
104
|
|
|
@@ -122,8 +149,7 @@ export function createHighlighterText( {
|
|
|
122
149
|
? Object.assign( {}, highlightStyle, activeStyle )
|
|
123
150
|
: highlightStyle;
|
|
124
151
|
|
|
125
|
-
|
|
126
|
-
const props = {
|
|
152
|
+
const props: Record< string, unknown > = {
|
|
127
153
|
children: text,
|
|
128
154
|
className: highlightClassNames,
|
|
129
155
|
key: index,
|
|
@@ -255,6 +255,8 @@ exports[`ToggleGroupControl controlled should render correctly with icons 1`] =
|
|
|
255
255
|
data-wp-component="ToggleGroupControlOptionBase"
|
|
256
256
|
id="toggle-group-control-as-radio-group-8-20"
|
|
257
257
|
role="radio"
|
|
258
|
+
type="button"
|
|
259
|
+
value="uppercase"
|
|
258
260
|
>
|
|
259
261
|
<div
|
|
260
262
|
class="emotion-13 emotion-14"
|
|
@@ -292,6 +294,8 @@ exports[`ToggleGroupControl controlled should render correctly with icons 1`] =
|
|
|
292
294
|
data-wp-component="ToggleGroupControlOptionBase"
|
|
293
295
|
id="toggle-group-control-as-radio-group-8-21"
|
|
294
296
|
role="radio"
|
|
297
|
+
type="button"
|
|
298
|
+
value="lowercase"
|
|
295
299
|
>
|
|
296
300
|
<div
|
|
297
301
|
class="emotion-13 emotion-14"
|
|
@@ -500,6 +504,8 @@ exports[`ToggleGroupControl controlled should render correctly with text options
|
|
|
500
504
|
data-wp-component="ToggleGroupControlOptionBase"
|
|
501
505
|
id="toggle-group-control-as-radio-group-7-18"
|
|
502
506
|
role="radio"
|
|
507
|
+
type="button"
|
|
508
|
+
value="rigas"
|
|
503
509
|
>
|
|
504
510
|
<div
|
|
505
511
|
class="emotion-13 emotion-14"
|
|
@@ -521,6 +527,8 @@ exports[`ToggleGroupControl controlled should render correctly with text options
|
|
|
521
527
|
data-wp-component="ToggleGroupControlOptionBase"
|
|
522
528
|
id="toggle-group-control-as-radio-group-7-19"
|
|
523
529
|
role="radio"
|
|
530
|
+
type="button"
|
|
531
|
+
value="jack"
|
|
524
532
|
>
|
|
525
533
|
<div
|
|
526
534
|
class="emotion-13 emotion-14"
|
|
@@ -796,6 +804,8 @@ exports[`ToggleGroupControl uncontrolled should render correctly with icons 1`]
|
|
|
796
804
|
data-wp-component="ToggleGroupControlOptionBase"
|
|
797
805
|
id="toggle-group-control-as-radio-group-1-2"
|
|
798
806
|
role="radio"
|
|
807
|
+
type="button"
|
|
808
|
+
value="uppercase"
|
|
799
809
|
>
|
|
800
810
|
<div
|
|
801
811
|
class="emotion-13 emotion-14"
|
|
@@ -833,6 +843,8 @@ exports[`ToggleGroupControl uncontrolled should render correctly with icons 1`]
|
|
|
833
843
|
data-wp-component="ToggleGroupControlOptionBase"
|
|
834
844
|
id="toggle-group-control-as-radio-group-1-3"
|
|
835
845
|
role="radio"
|
|
846
|
+
type="button"
|
|
847
|
+
value="lowercase"
|
|
836
848
|
>
|
|
837
849
|
<div
|
|
838
850
|
class="emotion-13 emotion-14"
|
|
@@ -1035,6 +1047,8 @@ exports[`ToggleGroupControl uncontrolled should render correctly with text optio
|
|
|
1035
1047
|
data-wp-component="ToggleGroupControlOptionBase"
|
|
1036
1048
|
id="toggle-group-control-as-radio-group-0-0"
|
|
1037
1049
|
role="radio"
|
|
1050
|
+
type="button"
|
|
1051
|
+
value="rigas"
|
|
1038
1052
|
>
|
|
1039
1053
|
<div
|
|
1040
1054
|
class="emotion-13 emotion-14"
|
|
@@ -1056,6 +1070,8 @@ exports[`ToggleGroupControl uncontrolled should render correctly with text optio
|
|
|
1056
1070
|
data-wp-component="ToggleGroupControlOptionBase"
|
|
1057
1071
|
id="toggle-group-control-as-radio-group-0-1"
|
|
1058
1072
|
role="radio"
|
|
1073
|
+
type="button"
|
|
1074
|
+
value="jack"
|
|
1059
1075
|
>
|
|
1060
1076
|
<div
|
|
1061
1077
|
class="emotion-13 emotion-14"
|
|
@@ -52,6 +52,10 @@ const meta: Meta< typeof Toolbar > = {
|
|
|
52
52
|
},
|
|
53
53
|
argTypes: {
|
|
54
54
|
children: { control: { type: null } },
|
|
55
|
+
variant: {
|
|
56
|
+
options: [ undefined, 'unstyled' ],
|
|
57
|
+
control: { type: 'radio' },
|
|
58
|
+
},
|
|
55
59
|
},
|
|
56
60
|
parameters: {
|
|
57
61
|
controls: { expanded: true },
|
|
@@ -181,3 +185,14 @@ WithoutGroup.args = {
|
|
|
181
185
|
</>
|
|
182
186
|
),
|
|
183
187
|
};
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Set the variant to `unstyled` to remove default border styles.
|
|
191
|
+
* Otherwise, leave it as `undefined` for default styles.
|
|
192
|
+
*/
|
|
193
|
+
|
|
194
|
+
export const Unstyled = Template.bind( {} );
|
|
195
|
+
Unstyled.args = {
|
|
196
|
+
...Default.args,
|
|
197
|
+
variant: 'unstyled',
|
|
198
|
+
};
|
|
@@ -25,5 +25,13 @@ describe( 'Toolbar', () => {
|
|
|
25
25
|
screen.getByLabelText( 'control2', { selector: 'button' } )
|
|
26
26
|
).toBeInTheDocument();
|
|
27
27
|
} );
|
|
28
|
+
|
|
29
|
+
it( 'should apply the unstyled variant correctly via the `variant` prop', () => {
|
|
30
|
+
render( <Toolbar label="blocks" variant="unstyled" /> );
|
|
31
|
+
|
|
32
|
+
expect( screen.getByRole( 'toolbar' ) ).toHaveClass(
|
|
33
|
+
'is-unstyled'
|
|
34
|
+
);
|
|
35
|
+
} );
|
|
28
36
|
} );
|
|
29
37
|
} );
|
|
@@ -71,6 +71,15 @@ An accessible label for the toolbar.
|
|
|
71
71
|
|
|
72
72
|
- Required: Yes
|
|
73
73
|
|
|
74
|
+
#### `variant`: `'unstyled' | undefined`
|
|
75
|
+
|
|
76
|
+
Specifies the toolbar's style.
|
|
77
|
+
|
|
78
|
+
Leave undefined for the default style. Or `'unstyled'` which removes the border from the toolbar, but keeps the default popover style.
|
|
79
|
+
|
|
80
|
+
- Required: No
|
|
81
|
+
- Default: `undefined`
|
|
82
|
+
|
|
74
83
|
## Related components
|
|
75
84
|
|
|
76
85
|
- Toolbar may contain [ToolbarGroup](/packages/components/src/toolbar-group/README.md), [ToolbarButton](/packages/components/src/toolbar-button/README.md) and [ToolbarItem](/packages/components/src/toolbar-Item/README.md) as children.
|
|
@@ -7,7 +7,7 @@ import type { ForwardedRef } from 'react';
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
-
import { forwardRef } from '@wordpress/element';
|
|
10
|
+
import { forwardRef, useMemo } from '@wordpress/element';
|
|
11
11
|
import deprecated from '@wordpress/deprecated';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -19,23 +19,30 @@ import type { ToolbarProps } from './types';
|
|
|
19
19
|
import type { WordPressComponentProps } from '../../context';
|
|
20
20
|
import { ContextSystemProvider } from '../../context';
|
|
21
21
|
|
|
22
|
-
const CONTEXT_SYSTEM_VALUE = {
|
|
23
|
-
DropdownMenu: {
|
|
24
|
-
variant: 'toolbar',
|
|
25
|
-
},
|
|
26
|
-
Dropdown: {
|
|
27
|
-
variant: 'toolbar',
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
|
|
31
22
|
function UnforwardedToolbar(
|
|
32
23
|
{
|
|
33
24
|
className,
|
|
34
25
|
label,
|
|
26
|
+
variant,
|
|
35
27
|
...props
|
|
36
28
|
}: WordPressComponentProps< ToolbarProps, 'div', false >,
|
|
37
29
|
ref: ForwardedRef< any >
|
|
38
30
|
) {
|
|
31
|
+
const isVariantDefined = variant !== undefined;
|
|
32
|
+
const contextSystemValue = useMemo( () => {
|
|
33
|
+
if ( isVariantDefined ) {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
DropdownMenu: {
|
|
38
|
+
variant: 'toolbar',
|
|
39
|
+
},
|
|
40
|
+
Dropdown: {
|
|
41
|
+
variant: 'toolbar',
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}, [ isVariantDefined ] );
|
|
45
|
+
|
|
39
46
|
if ( ! label ) {
|
|
40
47
|
deprecated( 'Using Toolbar without label prop', {
|
|
41
48
|
since: '5.6',
|
|
@@ -55,10 +62,12 @@ function UnforwardedToolbar(
|
|
|
55
62
|
// `ToolbarGroup` already uses components-toolbar for compatibility reasons.
|
|
56
63
|
const finalClassName = classnames(
|
|
57
64
|
'components-accessible-toolbar',
|
|
58
|
-
className
|
|
65
|
+
className,
|
|
66
|
+
variant && `is-${ variant }`
|
|
59
67
|
);
|
|
68
|
+
|
|
60
69
|
return (
|
|
61
|
-
<ContextSystemProvider value={
|
|
70
|
+
<ContextSystemProvider value={ contextSystemValue }>
|
|
62
71
|
<ToolbarContainer
|
|
63
72
|
className={ finalClassName }
|
|
64
73
|
label={ label }
|