@wordpress/components 33.1.1-next.v.202605131032.0 → 35.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 +35 -1
- package/build/autocomplete/index.cjs +5 -4
- package/build/autocomplete/index.cjs.map +3 -3
- package/build/box-control/index.cjs +0 -6
- package/build/box-control/index.cjs.map +2 -2
- package/build/box-control/utils.cjs +0 -38
- package/build/box-control/utils.cjs.map +3 -3
- package/build/custom-gradient-picker/gradient-bar/index.cjs.map +2 -2
- package/build/draggable/index.cjs +101 -7
- package/build/draggable/index.cjs.map +3 -3
- package/build/form-token-field/index.cjs +41 -7
- package/build/form-token-field/index.cjs.map +2 -2
- package/build/index.cjs +0 -17
- package/build/index.cjs.map +2 -2
- package/build/notice/index.cjs +33 -35
- package/build/notice/index.cjs.map +2 -2
- package/build/popover/index.cjs +12 -0
- package/build/popover/index.cjs.map +2 -2
- package/build/tabs/styles.cjs +5 -5
- package/build/tabs/styles.cjs.map +2 -2
- package/build-module/autocomplete/index.mjs +6 -5
- package/build-module/autocomplete/index.mjs.map +2 -2
- package/build-module/box-control/index.mjs +0 -2
- package/build-module/box-control/index.mjs.map +2 -2
- package/build-module/box-control/utils.mjs +0 -27
- package/build-module/box-control/utils.mjs.map +2 -2
- package/build-module/custom-gradient-picker/gradient-bar/index.mjs.map +2 -2
- package/build-module/draggable/index.mjs +101 -7
- package/build-module/draggable/index.mjs.map +3 -3
- package/build-module/form-token-field/index.mjs +41 -7
- package/build-module/form-token-field/index.mjs.map +2 -2
- package/build-module/index.mjs +87 -99
- package/build-module/index.mjs.map +2 -2
- package/build-module/notice/index.mjs +34 -36
- package/build-module/notice/index.mjs.map +2 -2
- package/build-module/popover/index.mjs +12 -0
- package/build-module/popover/index.mjs.map +2 -2
- package/build-module/tabs/styles.mjs +5 -5
- package/build-module/tabs/styles.mjs.map +2 -2
- package/build-style/style-rtl.css +64 -66
- package/build-style/style.css +64 -66
- package/build-types/autocomplete/index.d.ts.map +1 -1
- package/build-types/badge/stories/e2e/index.story.d.ts +7 -0
- package/build-types/badge/stories/e2e/index.story.d.ts.map +1 -0
- package/build-types/box-control/index.d.ts +0 -1
- package/build-types/box-control/index.d.ts.map +1 -1
- package/build-types/box-control/styles/box-control-styles.d.ts +1 -2
- package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -1
- package/build-types/box-control/utils.d.ts +0 -13
- package/build-types/box-control/utils.d.ts.map +1 -1
- package/build-types/button/stories/e2e/index.story.d.ts +1 -0
- package/build-types/button/stories/e2e/index.story.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +1 -2
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/index.d.ts.map +1 -1
- package/build-types/draggable/index.d.ts.map +1 -1
- package/build-types/draggable/stories/index.story.d.ts +4 -5
- package/build-types/draggable/stories/index.story.d.ts.map +1 -1
- package/build-types/draggable/types.d.ts +4 -0
- package/build-types/draggable/types.d.ts.map +1 -1
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/icon/stories/index.story.d.ts +0 -6
- package/build-types/icon/stories/index.story.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -6
- package/build-types/index.d.ts.map +1 -1
- package/build-types/notice/index.d.ts.map +1 -1
- package/build-types/notice/types.d.ts +1 -2
- package/build-types/notice/types.d.ts.map +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/range-control/index.d.ts +1 -2
- package/build-types/range-control/index.d.ts.map +1 -1
- package/build-types/range-control/stories/index.story.d.ts.map +1 -1
- package/build-types/range-control/types.d.ts +0 -4
- package/build-types/range-control/types.d.ts.map +1 -1
- package/build-types/tab-panel/stories/index.story.d.ts +0 -6
- package/build-types/tab-panel/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/stories/index.story.d.ts +0 -6
- package/build-types/tabs/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/styles.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/range-control.d.ts +1 -2
- package/build-types/validated-form-controls/components/range-control.d.ts.map +1 -1
- package/package.json +24 -22
- package/src/autocomplete/index.tsx +25 -7
- package/src/badge/stories/e2e/index.story.tsx +21 -0
- package/src/box-control/index.tsx +0 -1
- package/src/box-control/utils.ts +0 -43
- package/src/button/stories/e2e/index.story.tsx +11 -0
- package/src/custom-gradient-picker/gradient-bar/index.tsx +1 -1
- package/src/draggable/index.tsx +32 -10
- package/src/draggable/stories/index.story.tsx +11 -6
- package/src/draggable/style.module.scss +29 -0
- package/src/draggable/types.ts +4 -0
- package/src/form-token-field/index.tsx +84 -8
- package/src/form-token-field/test/index.tsx +189 -0
- package/src/icon/stories/index.story.tsx +2 -14
- package/src/index.ts +0 -6
- package/src/menu/test/index.tsx +9 -4
- package/src/modal/style.scss +2 -1
- package/src/notice/README.md +1 -2
- package/src/notice/index.tsx +57 -64
- package/src/notice/style.scss +49 -41
- package/src/notice/test/__snapshots__/index.tsx.snap +23 -23
- package/src/notice/test/index.tsx +5 -5
- package/src/notice/types.ts +1 -2
- package/src/popover/index.tsx +28 -0
- package/src/popover/test/index.tsx +138 -1
- package/src/range-control/stories/index.story.tsx +0 -1
- package/src/range-control/types.ts +0 -4
- package/src/style.scss +0 -1
- package/src/tab-panel/stories/index.story.tsx +2 -13
- package/src/tab-panel/style.scss +36 -14
- package/src/tabs/stories/index.story.tsx +2 -13
- package/src/tabs/styles.ts +3 -8
- package/build/navigation/back-button/index.cjs +0 -86
- package/build/navigation/back-button/index.cjs.map +0 -7
- package/build/navigation/constants.cjs +0 -34
- package/build/navigation/constants.cjs.map +0 -7
- package/build/navigation/context.cjs +0 -58
- package/build/navigation/context.cjs.map +0 -7
- package/build/navigation/group/context.cjs +0 -38
- package/build/navigation/group/context.cjs.map +0 -7
- package/build/navigation/group/index.cjs +0 -88
- package/build/navigation/group/index.cjs.map +0 -7
- package/build/navigation/index.cjs +0 -113
- package/build/navigation/index.cjs.map +0 -7
- package/build/navigation/item/base-content.cjs +0 -44
- package/build/navigation/item/base-content.cjs.map +0 -7
- package/build/navigation/item/base.cjs +0 -66
- package/build/navigation/item/base.cjs.map +0 -7
- package/build/navigation/item/index.cjs +0 -119
- package/build/navigation/item/index.cjs.map +0 -7
- package/build/navigation/item/use-navigation-tree-item.cjs +0 -64
- package/build/navigation/item/use-navigation-tree-item.cjs.map +0 -7
- package/build/navigation/menu/context.cjs +0 -39
- package/build/navigation/menu/context.cjs.map +0 -7
- package/build/navigation/menu/index.cjs +0 -114
- package/build/navigation/menu/index.cjs.map +0 -7
- package/build/navigation/menu/menu-title-search.cjs +0 -111
- package/build/navigation/menu/menu-title-search.cjs.map +0 -7
- package/build/navigation/menu/menu-title.cjs +0 -104
- package/build/navigation/menu/menu-title.cjs.map +0 -7
- package/build/navigation/menu/search-no-results-found.cjs +0 -48
- package/build/navigation/menu/search-no-results-found.cjs.map +0 -7
- package/build/navigation/menu/use-navigation-tree-menu.cjs +0 -51
- package/build/navigation/menu/use-navigation-tree-menu.cjs.map +0 -7
- package/build/navigation/styles/navigation-styles.cjs +0 -170
- package/build/navigation/styles/navigation-styles.cjs.map +0 -7
- package/build/navigation/types.cjs +0 -19
- package/build/navigation/types.cjs.map +0 -7
- package/build/navigation/use-create-navigation-tree.cjs +0 -103
- package/build/navigation/use-create-navigation-tree.cjs.map +0 -7
- package/build/navigation/use-navigation-tree-nodes.cjs +0 -60
- package/build/navigation/use-navigation-tree-nodes.cjs.map +0 -7
- package/build/navigation/utils.cjs +0 -45
- package/build/navigation/utils.cjs.map +0 -7
- package/build-module/navigation/back-button/index.mjs +0 -51
- package/build-module/navigation/back-button/index.mjs.map +0 -7
- package/build-module/navigation/constants.mjs +0 -8
- package/build-module/navigation/constants.mjs.map +0 -7
- package/build-module/navigation/context.mjs +0 -32
- package/build-module/navigation/context.mjs.map +0 -7
- package/build-module/navigation/group/context.mjs +0 -12
- package/build-module/navigation/group/context.mjs.map +0 -7
- package/build-module/navigation/group/index.mjs +0 -53
- package/build-module/navigation/group/index.mjs.map +0 -7
- package/build-module/navigation/index.mjs +0 -78
- package/build-module/navigation/index.mjs.map +0 -7
- package/build-module/navigation/item/base-content.mjs +0 -23
- package/build-module/navigation/item/base-content.mjs.map +0 -7
- package/build-module/navigation/item/base.mjs +0 -35
- package/build-module/navigation/item/base.mjs.map +0 -7
- package/build-module/navigation/item/index.mjs +0 -84
- package/build-module/navigation/item/index.mjs.map +0 -7
- package/build-module/navigation/item/use-navigation-tree-item.mjs +0 -39
- package/build-module/navigation/item/use-navigation-tree-item.mjs.map +0 -7
- package/build-module/navigation/menu/context.mjs +0 -13
- package/build-module/navigation/menu/context.mjs.map +0 -7
- package/build-module/navigation/menu/index.mjs +0 -79
- package/build-module/navigation/menu/index.mjs.map +0 -7
- package/build-module/navigation/menu/menu-title-search.mjs +0 -80
- package/build-module/navigation/menu/menu-title-search.mjs.map +0 -7
- package/build-module/navigation/menu/menu-title.mjs +0 -73
- package/build-module/navigation/menu/menu-title.mjs.map +0 -7
- package/build-module/navigation/menu/search-no-results-found.mjs +0 -27
- package/build-module/navigation/menu/search-no-results-found.mjs.map +0 -7
- package/build-module/navigation/menu/use-navigation-tree-menu.mjs +0 -26
- package/build-module/navigation/menu/use-navigation-tree-menu.mjs.map +0 -7
- package/build-module/navigation/styles/navigation-styles.mjs +0 -124
- package/build-module/navigation/styles/navigation-styles.mjs.map +0 -7
- package/build-module/navigation/types.mjs +0 -1
- package/build-module/navigation/types.mjs.map +0 -7
- package/build-module/navigation/use-create-navigation-tree.mjs +0 -78
- package/build-module/navigation/use-create-navigation-tree.mjs.map +0 -7
- package/build-module/navigation/use-navigation-tree-nodes.mjs +0 -35
- package/build-module/navigation/use-navigation-tree-nodes.mjs.map +0 -7
- package/build-module/navigation/utils.mjs +0 -9
- package/build-module/navigation/utils.mjs.map +0 -7
- 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/src/draggable/style.scss +0 -21
- package/src/navigation/README.md +0 -267
- package/src/navigation/back-button/index.tsx +0 -73
- package/src/navigation/constants.tsx +0 -2
- package/src/navigation/context.tsx +0 -40
- package/src/navigation/group/context.tsx +0 -16
- package/src/navigation/group/index.tsx +0 -73
- package/src/navigation/index.tsx +0 -152
- package/src/navigation/item/base-content.tsx +0 -31
- package/src/navigation/item/base.tsx +0 -42
- package/src/navigation/item/index.tsx +0 -112
- package/src/navigation/item/use-navigation-tree-item.tsx +0 -47
- package/src/navigation/menu/context.tsx +0 -20
- package/src/navigation/menu/index.tsx +0 -105
- package/src/navigation/menu/menu-title-search.tsx +0 -99
- package/src/navigation/menu/menu-title.tsx +0 -100
- package/src/navigation/menu/search-no-results-found.tsx +0 -34
- package/src/navigation/menu/use-navigation-tree-menu.tsx +0 -29
- package/src/navigation/stories/index.story.tsx +0 -62
- package/src/navigation/stories/style.css +0 -25
- package/src/navigation/stories/utils/controlled-state.tsx +0 -149
- package/src/navigation/stories/utils/default.tsx +0 -92
- package/src/navigation/stories/utils/group.tsx +0 -61
- package/src/navigation/stories/utils/hide-if-empty.tsx +0 -66
- package/src/navigation/stories/utils/more-examples.tsx +0 -162
- package/src/navigation/stories/utils/search.tsx +0 -91
- package/src/navigation/styles/navigation-styles.tsx +0 -197
- package/src/navigation/test/index.tsx +0 -347
- package/src/navigation/types.ts +0 -325
- package/src/navigation/use-create-navigation-tree.tsx +0 -110
- package/src/navigation/use-navigation-tree-nodes.tsx +0 -31
- package/src/navigation/utils.tsx +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/tab-panel/stories/index.story.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/tab-panel/stories/index.story.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAW,MAAM,uBAAuB,CAAC;AAG3D,OAAO,QAAQ,MAAM,IAAI,CAAC;AAE1B,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,QAAQ,CAgBhC,CAAC;eACa,IAAI;AAMnB,eAAO,MAAM,OAAO,0UAAsB,CAAC;AAe3C,eAAO,MAAM,WAAW,0UAAsB,CAAC;AAwB/C,eAAO,MAAM,uBAAuB,0UAA8B,CAAC;AAsBnE,eAAO,MAAM,gBAAgB,0UAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/tabs/stories/index.story.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/tabs/stories/index.story.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAI3D,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAM1B,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,IAAI,CAyB5B,CAAC;eACa,IAAI;AAiCnB,eAAO,MAAM,OAAO,2HAAsB,CAAC;AAE3C,eAAO,MAAM,yBAAyB,EAAE,OAAO,CAAE,OAAO,IAAI,CAsG3D,CAAC;AAiBF,eAAO,MAAM,QAAQ,2HAA8B,CAAC;AAwBpD,eAAO,MAAM,WAAW,2HAAiC,CAAC;AA0C1D,eAAO,MAAM,uBAAuB,2HAEnC,CAAC;AAEF,eAAO,MAAM,gBAAgB,2HAAsB,CAAC;AA0CpD,eAAO,MAAM,aAAa,2HAAmC,CAAC;AA+D9D,eAAO,MAAM,oBAAoB,2HAAiC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/tabs/styles.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAS1C,eAAO,MAAM,aAAa;;;;;;
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/tabs/styles.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAS1C,eAAO,MAAM,aAAa;;;;;;UAmIzB,CAAC;AAEF,eAAO,MAAM,GAAG;;;;;;UAiFf,CAAC;AAEF,eAAO,MAAM,WAAW;;;2GAYvB,CAAC;AAEF,eAAO,MAAM,UAAU;;UAuBtB,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;;UAapB,CAAC"}
|
|
@@ -12,7 +12,6 @@ export declare const ValidatedRangeControl: import("react").ForwardRefExoticComp
|
|
|
12
12
|
beforeIcon?: import("../..").IconType;
|
|
13
13
|
color?: import("react").CSSProperties['color'];
|
|
14
14
|
currentInput?: number;
|
|
15
|
-
icon?: string;
|
|
16
15
|
initialPosition?: number;
|
|
17
16
|
isShiftStepEnabled?: boolean;
|
|
18
17
|
label?: string;
|
|
@@ -32,5 +31,5 @@ export declare const ValidatedRangeControl: import("react").ForwardRefExoticComp
|
|
|
32
31
|
type?: 'stepper';
|
|
33
32
|
withInputField?: boolean;
|
|
34
33
|
__shouldNotWarnDeprecated36pxSize?: boolean;
|
|
35
|
-
} & Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "__next40pxDefaultSize" | "__nextHasNoMarginBottom" | "__shouldNotWarnDeprecated36pxSize" | "afterIcon" | "allowReset" | "as" | "beforeIcon" | "children" | "color" | "currentInput" | "disabled" | "help" | "hideLabelFromVision" | "
|
|
34
|
+
} & Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "__next40pxDefaultSize" | "__nextHasNoMarginBottom" | "__shouldNotWarnDeprecated36pxSize" | "afterIcon" | "allowReset" | "as" | "beforeIcon" | "children" | "color" | "currentInput" | "disabled" | "help" | "hideLabelFromVision" | "initialPosition" | "isShiftStepEnabled" | "label" | "marks" | "onBlur" | "onChange" | "onFocus" | "onMouseLeave" | "onMouseMove" | "railColor" | "renderTooltipContent" | "resetFallbackValue" | "separatorType" | "shiftStep" | "showTooltip" | "step" | "trackColor" | "type" | "withInputField" | keyof import("../../range-control/types").NumericProps> & import("react").RefAttributes<HTMLInputElement>, "__next40pxDefaultSize"> & ValidatedControlProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
36
35
|
//# sourceMappingURL=range-control.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range-control.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/components/range-control.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAmCrD,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"range-control.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/components/range-control.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAmCrD,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;m2BAEjC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "35.0.0",
|
|
4
4
|
"description": "UI components for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"@date-fns/utc": "^2.1.1",
|
|
56
56
|
"@emotion/cache": "^11.14.0",
|
|
57
57
|
"@emotion/css": "^11.13.5",
|
|
58
|
+
"@emotion/native": "^11.11.0",
|
|
58
59
|
"@emotion/react": "^11.14.0",
|
|
59
60
|
"@emotion/serialize": "^1.3.3",
|
|
60
61
|
"@emotion/styled": "^11.14.1",
|
|
@@ -64,25 +65,26 @@
|
|
|
64
65
|
"@types/highlight-words-core": "1.2.1",
|
|
65
66
|
"@types/react": "^18.3.27",
|
|
66
67
|
"@use-gesture/react": "^10.3.1",
|
|
67
|
-
"@wordpress/a11y": "^4.
|
|
68
|
-
"@wordpress/base-styles": "^
|
|
69
|
-
"@wordpress/compose": "^
|
|
70
|
-
"@wordpress/date": "^5.
|
|
71
|
-
"@wordpress/deprecated": "^4.
|
|
72
|
-
"@wordpress/dom": "^4.
|
|
73
|
-
"@wordpress/element": "^
|
|
74
|
-
"@wordpress/escape-html": "^3.
|
|
75
|
-
"@wordpress/hooks": "^4.
|
|
76
|
-
"@wordpress/html-entities": "^4.
|
|
77
|
-
"@wordpress/i18n": "^6.
|
|
78
|
-
"@wordpress/icons": "^13.
|
|
79
|
-
"@wordpress/is-shallow-equal": "^5.
|
|
80
|
-
"@wordpress/keycodes": "^4.
|
|
81
|
-
"@wordpress/primitives": "^4.
|
|
82
|
-
"@wordpress/private-apis": "^1.
|
|
83
|
-
"@wordpress/rich-text": "^7.
|
|
84
|
-
"@wordpress/style-runtime": "^0.
|
|
85
|
-
"@wordpress/
|
|
68
|
+
"@wordpress/a11y": "^4.48.0",
|
|
69
|
+
"@wordpress/base-styles": "^9.1.0",
|
|
70
|
+
"@wordpress/compose": "^8.1.0",
|
|
71
|
+
"@wordpress/date": "^5.48.0",
|
|
72
|
+
"@wordpress/deprecated": "^4.48.0",
|
|
73
|
+
"@wordpress/dom": "^4.48.0",
|
|
74
|
+
"@wordpress/element": "^8.0.0",
|
|
75
|
+
"@wordpress/escape-html": "^3.48.0",
|
|
76
|
+
"@wordpress/hooks": "^4.48.0",
|
|
77
|
+
"@wordpress/html-entities": "^4.48.0",
|
|
78
|
+
"@wordpress/i18n": "^6.21.0",
|
|
79
|
+
"@wordpress/icons": "^13.3.0",
|
|
80
|
+
"@wordpress/is-shallow-equal": "^5.48.0",
|
|
81
|
+
"@wordpress/keycodes": "^4.48.0",
|
|
82
|
+
"@wordpress/primitives": "^4.48.0",
|
|
83
|
+
"@wordpress/private-apis": "^1.48.0",
|
|
84
|
+
"@wordpress/rich-text": "^7.48.0",
|
|
85
|
+
"@wordpress/style-runtime": "^0.4.0",
|
|
86
|
+
"@wordpress/ui": "^0.15.0",
|
|
87
|
+
"@wordpress/warning": "^3.48.0",
|
|
86
88
|
"change-case": "^4.1.2",
|
|
87
89
|
"clsx": "^2.1.1",
|
|
88
90
|
"colord": "^2.7.0",
|
|
@@ -108,7 +110,7 @@
|
|
|
108
110
|
"@storybook/react-vite": "^10.2.8",
|
|
109
111
|
"@testing-library/jest-dom": "^6.9.1",
|
|
110
112
|
"@types/jest": "^29.5.14",
|
|
111
|
-
"@wordpress/jest-console": "^8.
|
|
113
|
+
"@wordpress/jest-console": "^8.48.0",
|
|
112
114
|
"snapshot-diff": "^0.10.0",
|
|
113
115
|
"storybook": "^10.2.8",
|
|
114
116
|
"timezone-mock": "^1.3.6"
|
|
@@ -120,5 +122,5 @@
|
|
|
120
122
|
"publishConfig": {
|
|
121
123
|
"access": "public"
|
|
122
124
|
},
|
|
123
|
-
"gitHead": "
|
|
125
|
+
"gitHead": "e7856693aeb4e2522d13608cd32c994e4a97cb9c"
|
|
124
126
|
}
|
|
@@ -8,7 +8,12 @@ import {
|
|
|
8
8
|
useReducer,
|
|
9
9
|
useRef,
|
|
10
10
|
} from '@wordpress/element';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
useInstanceId,
|
|
13
|
+
useMergeRefs,
|
|
14
|
+
useRefEffect,
|
|
15
|
+
privateApis as composePrivateApis,
|
|
16
|
+
} from '@wordpress/compose';
|
|
12
17
|
import {
|
|
13
18
|
create,
|
|
14
19
|
slice,
|
|
@@ -36,6 +41,9 @@ import type {
|
|
|
36
41
|
UseAutocompleteProps,
|
|
37
42
|
} from './types';
|
|
38
43
|
import getNodeText from '../utils/get-node-text';
|
|
44
|
+
import { unlock } from '../lock-unlock';
|
|
45
|
+
|
|
46
|
+
const { subscribeDelegatedListener } = unlock( composePrivateApis );
|
|
39
47
|
|
|
40
48
|
const EMPTY_FILTERED_OPTIONS: KeyedOption[] = [];
|
|
41
49
|
|
|
@@ -390,13 +398,23 @@ export function useAutocompleteProps( options: UseAutocompleteProps ) {
|
|
|
390
398
|
const mergedRefs = useMergeRefs( [
|
|
391
399
|
ref,
|
|
392
400
|
useRefEffect( ( element: HTMLElement ) => {
|
|
393
|
-
function _onKeyDown( event:
|
|
394
|
-
onKeyDownRef.current?.( event );
|
|
401
|
+
function _onKeyDown( event: Event ) {
|
|
402
|
+
onKeyDownRef.current?.( event as KeyboardEvent );
|
|
395
403
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
404
|
+
// Capture phase. When the autocomplete popover is open,
|
|
405
|
+
// Up/Down/Enter/Escape must navigate the completion list —
|
|
406
|
+
// they shouldn't be consumed by ancestor handlers (e.g.
|
|
407
|
+
// block-editor's writing-flow) for block navigation, block
|
|
408
|
+
// splitting, or "move out of parent" actions. Those handlers
|
|
409
|
+
// fire at bubble phase and gate on `event.defaultPrevented`,
|
|
410
|
+
// so firing in capture lets us preventDefault first when the
|
|
411
|
+
// popover is active.
|
|
412
|
+
return subscribeDelegatedListener(
|
|
413
|
+
element,
|
|
414
|
+
'keydown',
|
|
415
|
+
_onKeyDown,
|
|
416
|
+
true
|
|
417
|
+
);
|
|
400
418
|
}, [] ),
|
|
401
419
|
] );
|
|
402
420
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import Badge from '../..';
|
|
4
|
+
|
|
5
|
+
const meta: Meta< typeof Badge > = {
|
|
6
|
+
component: Badge,
|
|
7
|
+
title: 'Components/Badge',
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
10
|
+
|
|
11
|
+
type Story = StoryObj< typeof Badge >;
|
|
12
|
+
|
|
13
|
+
export const TextOverflow: Story = {
|
|
14
|
+
args: {
|
|
15
|
+
children:
|
|
16
|
+
'This is an extremely long label thatshoulddemonstratetextoverflow behavior',
|
|
17
|
+
},
|
|
18
|
+
parameters: {
|
|
19
|
+
textOverflowContainers: true,
|
|
20
|
+
},
|
|
21
|
+
};
|
package/src/box-control/utils.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import deprecated from '@wordpress/deprecated';
|
|
5
4
|
import { __ } from '@wordpress/i18n';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -188,48 +187,6 @@ export function normalizeSides( sides: BoxControlProps[ 'sides' ] ) {
|
|
|
188
187
|
return filteredSides;
|
|
189
188
|
}
|
|
190
189
|
|
|
191
|
-
/**
|
|
192
|
-
* Applies a value to an object representing top, right, bottom and left sides
|
|
193
|
-
* while taking into account any custom side configuration.
|
|
194
|
-
*
|
|
195
|
-
* @deprecated
|
|
196
|
-
*
|
|
197
|
-
* @param currentValues The current values for each side.
|
|
198
|
-
* @param newValue The value to apply to the sides object.
|
|
199
|
-
* @param sides Array defining valid sides.
|
|
200
|
-
*
|
|
201
|
-
* @return Object containing the updated values for each side.
|
|
202
|
-
*/
|
|
203
|
-
export function applyValueToSides(
|
|
204
|
-
currentValues: BoxControlValue,
|
|
205
|
-
newValue?: string,
|
|
206
|
-
sides?: BoxControlProps[ 'sides' ]
|
|
207
|
-
): BoxControlValue {
|
|
208
|
-
deprecated( 'applyValueToSides', {
|
|
209
|
-
since: '6.8',
|
|
210
|
-
version: '7.0',
|
|
211
|
-
} );
|
|
212
|
-
const newValues = { ...currentValues };
|
|
213
|
-
|
|
214
|
-
if ( sides?.length ) {
|
|
215
|
-
sides.forEach( ( side ) => {
|
|
216
|
-
if ( side === 'vertical' ) {
|
|
217
|
-
newValues.top = newValue;
|
|
218
|
-
newValues.bottom = newValue;
|
|
219
|
-
} else if ( side === 'horizontal' ) {
|
|
220
|
-
newValues.left = newValue;
|
|
221
|
-
newValues.right = newValue;
|
|
222
|
-
} else {
|
|
223
|
-
newValues[ side ] = newValue;
|
|
224
|
-
}
|
|
225
|
-
} );
|
|
226
|
-
} else {
|
|
227
|
-
ALL_SIDES.forEach( ( side ) => ( newValues[ side ] = newValue ) );
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return newValues;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
190
|
/**
|
|
234
191
|
* Return the allowed sides based on the sides configuration.
|
|
235
192
|
*
|
|
@@ -147,6 +147,17 @@ Icon.args = {
|
|
|
147
147
|
icon: wordpress,
|
|
148
148
|
};
|
|
149
149
|
|
|
150
|
+
export const TextOverflow: StoryFn< typeof Button > = ( props ) => {
|
|
151
|
+
return <Button __next40pxDefaultSize { ...props } />;
|
|
152
|
+
};
|
|
153
|
+
TextOverflow.args = {
|
|
154
|
+
children:
|
|
155
|
+
'This is an extremely long label thatshoulddemonstratetextoverflow behavior',
|
|
156
|
+
};
|
|
157
|
+
TextOverflow.parameters = {
|
|
158
|
+
textOverflowContainers: true,
|
|
159
|
+
};
|
|
160
|
+
|
|
150
161
|
export const Dashicons: StoryFn< typeof Button > = ( props ) => {
|
|
151
162
|
return (
|
|
152
163
|
<div style={ { display: 'flex', gap: 8 } }>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
+
import type { MouseEventHandler } from 'react';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* WordPress dependencies
|
|
@@ -20,7 +21,6 @@ import type {
|
|
|
20
21
|
CustomGradientBarReducerAction,
|
|
21
22
|
CustomGradientBarIdleState,
|
|
22
23
|
} from '../types';
|
|
23
|
-
import type { MouseEventHandler } from 'react';
|
|
24
24
|
|
|
25
25
|
const customGradientBarReducer = (
|
|
26
26
|
state: CustomGradientBarReducerState,
|
package/src/draggable/index.tsx
CHANGED
|
@@ -8,16 +8,28 @@ import type { DragEvent } from 'react';
|
|
|
8
8
|
*/
|
|
9
9
|
import { throttle } from '@wordpress/compose';
|
|
10
10
|
import { useEffect, useRef } from '@wordpress/element';
|
|
11
|
+
import { getWpCompatOverlaySlot } from '@wordpress/ui';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Internal dependencies
|
|
14
15
|
*/
|
|
15
16
|
import type { DraggableProps } from './types';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
import styles from './style.module.scss';
|
|
18
|
+
|
|
19
|
+
// Legacy class names preserved alongside the CSS-module hashed ones for
|
|
20
|
+
// backwards compatibility. `filter(Boolean)` strips `undefined` from Jest's
|
|
21
|
+
// CSS-module mock.
|
|
22
|
+
const dragImageClasses = [
|
|
23
|
+
styles[ 'invisible-drag-image' ],
|
|
24
|
+
'components-draggable__invisible-drag-image',
|
|
25
|
+
].filter( Boolean );
|
|
26
|
+
const cloneWrapperClasses = [
|
|
27
|
+
styles.clone,
|
|
28
|
+
'components-draggable__clone',
|
|
29
|
+
].filter( Boolean );
|
|
30
|
+
// Global class — shared with external code (e.g. block-editor keyboard drag).
|
|
20
31
|
const bodyClass = 'is-dragging-components-draggable';
|
|
32
|
+
const clonePadding = 0;
|
|
21
33
|
|
|
22
34
|
/**
|
|
23
35
|
* `Draggable` is a Component that provides a way to set up a cross-browser
|
|
@@ -99,6 +111,10 @@ export function Draggable( {
|
|
|
99
111
|
*/
|
|
100
112
|
function start( event: DragEvent ) {
|
|
101
113
|
const { ownerDocument } = event.target as HTMLElement;
|
|
114
|
+
// Only use the slot when it lives in the same document as the
|
|
115
|
+
// dragged element, so coordinate resolution stays in one space.
|
|
116
|
+
const slot = getWpCompatOverlaySlot();
|
|
117
|
+
const compatSlot = slot?.ownerDocument === ownerDocument ? slot : null;
|
|
102
118
|
|
|
103
119
|
event.dataTransfer.setData(
|
|
104
120
|
transferDataType,
|
|
@@ -116,12 +132,18 @@ export function Draggable( {
|
|
|
116
132
|
// right after. event.dataTransfer.setDragImage is not supported yet in
|
|
117
133
|
// IE, we need to check for its existence first.
|
|
118
134
|
if ( 'function' === typeof event.dataTransfer.setDragImage ) {
|
|
119
|
-
dragImage.classList.add(
|
|
135
|
+
dragImage.classList.add( ...dragImageClasses );
|
|
136
|
+
// Invisible — stays at the document body, no slot needed.
|
|
120
137
|
ownerDocument.body.appendChild( dragImage );
|
|
121
138
|
event.dataTransfer.setDragImage( dragImage, 0, 0 );
|
|
122
139
|
}
|
|
123
140
|
|
|
124
|
-
cloneWrapper.classList.add(
|
|
141
|
+
cloneWrapper.classList.add( ...cloneWrapperClasses );
|
|
142
|
+
|
|
143
|
+
const inSlotClass = styles[ 'is-in-compat-slot' ];
|
|
144
|
+
if ( compatSlot && inSlotClass ) {
|
|
145
|
+
cloneWrapper.classList.add( inSlotClass );
|
|
146
|
+
}
|
|
125
147
|
|
|
126
148
|
if ( cloneClassname ) {
|
|
127
149
|
cloneWrapper.classList.add( cloneClassname );
|
|
@@ -141,8 +163,7 @@ export function Draggable( {
|
|
|
141
163
|
clonedDragComponent.innerHTML = dragComponentRef.current.innerHTML;
|
|
142
164
|
cloneWrapper.appendChild( clonedDragComponent );
|
|
143
165
|
|
|
144
|
-
|
|
145
|
-
ownerDocument.body.appendChild( cloneWrapper );
|
|
166
|
+
( compatSlot ?? ownerDocument.body ).appendChild( cloneWrapper );
|
|
146
167
|
} else {
|
|
147
168
|
const element = ownerDocument.getElementById(
|
|
148
169
|
elementId
|
|
@@ -173,8 +194,9 @@ export function Draggable( {
|
|
|
173
194
|
|
|
174
195
|
cloneWrapper.appendChild( clone );
|
|
175
196
|
|
|
176
|
-
|
|
177
|
-
|
|
197
|
+
if ( compatSlot ) {
|
|
198
|
+
compatSlot.appendChild( cloneWrapper );
|
|
199
|
+
} else if ( appendToOwnerDocument ) {
|
|
178
200
|
ownerDocument.body.appendChild( cloneWrapper );
|
|
179
201
|
} else {
|
|
180
202
|
elementWrapper?.appendChild( cloneWrapper );
|
|
@@ -32,7 +32,13 @@ const meta: Meta< typeof Draggable > = {
|
|
|
32
32
|
},
|
|
33
33
|
parameters: {
|
|
34
34
|
controls: { expanded: true },
|
|
35
|
-
docs: {
|
|
35
|
+
docs: {
|
|
36
|
+
source: { code: '' },
|
|
37
|
+
// Render in its own iframe — Storybook's docs-page wrappers
|
|
38
|
+
// create transform-based containing blocks that break the
|
|
39
|
+
// clone's `position: fixed` resolution.
|
|
40
|
+
story: { inline: false, height: '250px' },
|
|
41
|
+
},
|
|
36
42
|
componentStatus: {
|
|
37
43
|
status: 'use-with-caution',
|
|
38
44
|
whereUsed: 'global',
|
|
@@ -115,11 +121,10 @@ export const Default: StoryFn< typeof Draggable > = DefaultTemplate.bind( {} );
|
|
|
115
121
|
Default.args = {};
|
|
116
122
|
|
|
117
123
|
/**
|
|
118
|
-
* `appendToOwnerDocument`
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* element to be rendered behind other elements.
|
|
124
|
+
* `appendToOwnerDocument` appends the dragged element's clone to the owner
|
|
125
|
+
* document's body instead of the element's parent, which is useful when an
|
|
126
|
+
* ancestor's stacking context (e.g. its `z-index`) would otherwise place the
|
|
127
|
+
* clone behind other content.
|
|
123
128
|
*/
|
|
124
129
|
export const AppendElementToOwnerDocument: StoryFn< typeof Draggable > =
|
|
125
130
|
DefaultTemplate.bind( {} );
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
@use "@wordpress/base-styles/z-index" as *;
|
|
2
|
+
|
|
3
|
+
.invisible-drag-image {
|
|
4
|
+
position: fixed;
|
|
5
|
+
/* stylelint-disable-next-line plugin/use-logical-properties-and-values -- Offscreen drag-image stand-in; flipping with writing direction has no benefit. */
|
|
6
|
+
left: -1000px;
|
|
7
|
+
height: 50px;
|
|
8
|
+
width: 50px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.clone {
|
|
12
|
+
position: fixed;
|
|
13
|
+
padding: 0; // Matches the `clonePadding` JS constant.
|
|
14
|
+
background: transparent;
|
|
15
|
+
pointer-events: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Fallback for clones placed outside the compat overlay slot — the
|
|
19
|
+
// slot's stacking context handles ordering inside it.
|
|
20
|
+
.clone:not(.is-in-compat-slot) {
|
|
21
|
+
z-index: z-index(".components-draggable__clone");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Global selector — external code (e.g. block-editor keyboard drag)
|
|
25
|
+
// toggles the same body class.
|
|
26
|
+
:global(body.is-dragging-components-draggable) {
|
|
27
|
+
cursor: move; /* Fallback for IE/Edge < 14 */
|
|
28
|
+
cursor: grabbing !important;
|
|
29
|
+
}
|
package/src/draggable/types.ts
CHANGED
|
@@ -21,6 +21,10 @@ export type DraggableProps = {
|
|
|
21
21
|
* Whether to append the cloned element to the `ownerDocument` body.
|
|
22
22
|
* By default, elements sourced by id are appended to the element's wrapper.
|
|
23
23
|
*
|
|
24
|
+
* Has no effect when the `@wordpress/ui` compat overlay slot is in use in
|
|
25
|
+
* the same document — the clone goes into the slot instead. Cross-document
|
|
26
|
+
* drags fall back to this prop's regular semantics.
|
|
27
|
+
*
|
|
24
28
|
* @default false
|
|
25
29
|
*/
|
|
26
30
|
appendToOwnerDocument?: boolean;
|
|
@@ -253,7 +253,9 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
253
253
|
break;
|
|
254
254
|
case 'Space':
|
|
255
255
|
if ( tokenizeOnSpace ) {
|
|
256
|
-
preventDefault = addCurrentToken(
|
|
256
|
+
preventDefault = addCurrentToken( {
|
|
257
|
+
preventDefaultOnFailedValidation: false,
|
|
258
|
+
} );
|
|
257
259
|
}
|
|
258
260
|
break;
|
|
259
261
|
case 'Escape':
|
|
@@ -320,7 +322,65 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
320
322
|
const tokenValue = items[ items.length - 1 ] || '';
|
|
321
323
|
|
|
322
324
|
if ( items.length > 1 ) {
|
|
323
|
-
|
|
325
|
+
const tokensToProcess = items.slice( 0, -1 );
|
|
326
|
+
|
|
327
|
+
// Pre-check: would any segment be rejected by
|
|
328
|
+
// `__experimentalValidateInput`? Empties and duplicates of the
|
|
329
|
+
// current selection are intentional skips, not failures.
|
|
330
|
+
const willFailValidation = ( segment: string ) => {
|
|
331
|
+
const transformed = saveTransform( segment );
|
|
332
|
+
return (
|
|
333
|
+
!! transformed &&
|
|
334
|
+
! valueContainsToken( transformed ) &&
|
|
335
|
+
! __experimentalValidateInput( transformed )
|
|
336
|
+
);
|
|
337
|
+
};
|
|
338
|
+
const hasFailures = tokensToProcess.some( willFailValidation );
|
|
339
|
+
|
|
340
|
+
// When there are failures, also commit the trailing in-progress
|
|
341
|
+
// segment so the user is left with only the items that need
|
|
342
|
+
// fixing, instead of mixing the trailing segment with the failed
|
|
343
|
+
// ones (which would block tokenization on Enter or comma).
|
|
344
|
+
const addedTokens = addNewTokens(
|
|
345
|
+
hasFailures ? items : tokensToProcess
|
|
346
|
+
);
|
|
347
|
+
|
|
348
|
+
if ( hasFailures ) {
|
|
349
|
+
// Derive rejected segments from `addedTokens` so this stays
|
|
350
|
+
// in sync with `addNewTokens`'s filter chain.
|
|
351
|
+
const rejected = items.filter( ( token ) => {
|
|
352
|
+
const transformed = saveTransform( token );
|
|
353
|
+
if ( ! transformed ) {
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
if ( addedTokens.has( transformed ) ) {
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
if ( valueContainsToken( transformed ) ) {
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
return ! __experimentalValidateInput( transformed );
|
|
363
|
+
} );
|
|
364
|
+
|
|
365
|
+
// Reuse the separator the user actually used (the last one
|
|
366
|
+
// in `text`) so we don't rewrite their input: comma-separated
|
|
367
|
+
// paste under `tokenizeOnSpace` stays comma-separated, and
|
|
368
|
+
// typed space under `tokenizeOnSpace` stays a space. Falls
|
|
369
|
+
// back to the mode-appropriate separator only when no
|
|
370
|
+
// separator characters are present in `text`.
|
|
371
|
+
const usedSeparators = text.match( /[ ,\t]/g );
|
|
372
|
+
const separatorChar =
|
|
373
|
+
usedSeparators?.[ usedSeparators.length - 1 ] ??
|
|
374
|
+
( tokenizeOnSpace ? ' ' : ',' );
|
|
375
|
+
// Preserve a trailing separator when the input ended with
|
|
376
|
+
// one, so the user can keep typing past a failed-validation
|
|
377
|
+
// space without their separator disappearing.
|
|
378
|
+
const trailing = tokenValue === '' ? separatorChar : '';
|
|
379
|
+
const remaining = rejected.join( separatorChar ) + trailing;
|
|
380
|
+
setIncompleteTokenValue( remaining );
|
|
381
|
+
onInputChange( remaining );
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
324
384
|
}
|
|
325
385
|
setIncompleteTokenValue( tokenValue );
|
|
326
386
|
onInputChange( tokenValue );
|
|
@@ -417,7 +477,9 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
417
477
|
addNewToken( incompleteTokenValue );
|
|
418
478
|
}
|
|
419
479
|
|
|
420
|
-
|
|
480
|
+
// Comma is always a separator (typed in onKeyPress, never as input).
|
|
481
|
+
// Pasted commas go through onInputChangeHandler, which validates.
|
|
482
|
+
return true;
|
|
421
483
|
}
|
|
422
484
|
|
|
423
485
|
function moveInputToIndex( index: number ) {
|
|
@@ -454,7 +516,9 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
454
516
|
}
|
|
455
517
|
}
|
|
456
518
|
|
|
457
|
-
function addCurrentToken(
|
|
519
|
+
function addCurrentToken( {
|
|
520
|
+
preventDefaultOnFailedValidation = true,
|
|
521
|
+
} = {} ) {
|
|
458
522
|
let preventDefault = false;
|
|
459
523
|
const selectedSuggestion = getSelectedSuggestion();
|
|
460
524
|
|
|
@@ -462,20 +526,22 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
462
526
|
addNewToken( selectedSuggestion );
|
|
463
527
|
preventDefault = true;
|
|
464
528
|
} else if ( inputHasValidValue() ) {
|
|
465
|
-
addNewToken( incompleteTokenValue );
|
|
466
|
-
preventDefault =
|
|
529
|
+
const passedValidation = addNewToken( incompleteTokenValue );
|
|
530
|
+
preventDefault =
|
|
531
|
+
passedValidation || preventDefaultOnFailedValidation;
|
|
467
532
|
}
|
|
468
533
|
|
|
469
534
|
return preventDefault;
|
|
470
535
|
}
|
|
471
536
|
|
|
472
|
-
function addNewTokens( tokens: string[] ) {
|
|
537
|
+
function addNewTokens( tokens: string[] ): Set< string > {
|
|
473
538
|
const tokensToAdd = [
|
|
474
539
|
...new Set(
|
|
475
540
|
tokens
|
|
476
541
|
.map( saveTransform )
|
|
477
542
|
.filter( Boolean )
|
|
478
543
|
.filter( ( token ) => ! valueContainsToken( token ) )
|
|
544
|
+
.filter( ( token ) => __experimentalValidateInput( token ) )
|
|
479
545
|
),
|
|
480
546
|
];
|
|
481
547
|
|
|
@@ -484,12 +550,20 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
484
550
|
newValue.splice( getIndexOfInput(), 0, ...tokensToAdd );
|
|
485
551
|
onChange( newValue );
|
|
486
552
|
}
|
|
553
|
+
|
|
554
|
+
return new Set( tokensToAdd );
|
|
487
555
|
}
|
|
488
556
|
|
|
557
|
+
/**
|
|
558
|
+
* Validates and adds `token`. Returns `true` if validation passed,
|
|
559
|
+
* `false` if it was rejected by `__experimentalValidateInput`. A `true`
|
|
560
|
+
* return does not guarantee the token was added: `addNewTokens` may
|
|
561
|
+
* still drop it as a duplicate or after `saveTransform` returns empty.
|
|
562
|
+
*/
|
|
489
563
|
function addNewToken( token: string ) {
|
|
490
564
|
if ( ! __experimentalValidateInput( token ) ) {
|
|
491
565
|
speak( messages.__experimentalInvalid, 'assertive' );
|
|
492
|
-
return;
|
|
566
|
+
return false;
|
|
493
567
|
}
|
|
494
568
|
addNewTokens( [ token ] );
|
|
495
569
|
speak( messages.added, 'assertive' );
|
|
@@ -502,6 +576,8 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
502
576
|
if ( isActive && ! tokenizeOnBlur ) {
|
|
503
577
|
focus();
|
|
504
578
|
}
|
|
579
|
+
|
|
580
|
+
return true;
|
|
505
581
|
}
|
|
506
582
|
|
|
507
583
|
function deleteToken( token: string | TokenItem ) {
|