@wordpress/components 23.4.0 → 23.5.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 +15 -0
- package/build/autocomplete/autocompleter-ui.js +41 -17
- package/build/autocomplete/autocompleter-ui.js.map +1 -1
- package/build/autocomplete/index.js +31 -33
- package/build/autocomplete/index.js.map +1 -1
- package/build/circular-option-picker/index.js +63 -14
- package/build/circular-option-picker/index.js.map +1 -1
- package/build/circular-option-picker/types.js +6 -0
- package/build/circular-option-picker/types.js.map +1 -0
- package/build/dropdown-menu/index.js +6 -2
- package/build/dropdown-menu/index.js.map +1 -1
- package/build/higher-order/with-constrained-tabbing/index.js +9 -0
- package/build/higher-order/with-constrained-tabbing/index.js.map +1 -1
- package/build/mobile/global-styles-context/utils.native.js +2 -1
- package/build/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build/range-control/index.js +1 -0
- package/build/range-control/index.js.map +1 -1
- package/build/tools-panel/context.js +2 -0
- package/build/tools-panel/context.js.map +1 -1
- package/build/tools-panel/tools-panel/hook.js +18 -12
- package/build/tools-panel/tools-panel/hook.js.map +1 -1
- package/build/tools-panel/tools-panel-item/hook.js +14 -2
- package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build/ui/context/context-system-provider.js +8 -4
- package/build/ui/context/context-system-provider.js.map +1 -1
- package/build-module/autocomplete/autocompleter-ui.js +40 -19
- package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
- package/build-module/autocomplete/index.js +30 -32
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/circular-option-picker/index.js +59 -16
- package/build-module/circular-option-picker/index.js.map +1 -1
- package/build-module/circular-option-picker/types.js +2 -0
- package/build-module/circular-option-picker/types.js.map +1 -0
- package/build-module/dropdown-menu/index.js +6 -2
- package/build-module/dropdown-menu/index.js.map +1 -1
- package/build-module/higher-order/with-constrained-tabbing/index.js +9 -0
- package/build-module/higher-order/with-constrained-tabbing/index.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +2 -1
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/range-control/index.js +1 -0
- package/build-module/range-control/index.js.map +1 -1
- package/build-module/tools-panel/context.js +2 -0
- package/build-module/tools-panel/context.js.map +1 -1
- package/build-module/tools-panel/tools-panel/hook.js +18 -12
- package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
- package/build-module/tools-panel/tools-panel-item/hook.js +14 -2
- package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build-module/ui/context/context-system-provider.js +7 -4
- package/build-module/ui/context/context-system-provider.js.map +1 -1
- package/build-style/style-rtl.css +1 -0
- package/build-style/style.css +1 -0
- package/build-types/circular-option-picker/index.d.ts +56 -7
- package/build-types/circular-option-picker/index.d.ts.map +1 -1
- package/build-types/circular-option-picker/stories/index.d.ts +14 -0
- package/build-types/circular-option-picker/stories/index.d.ts.map +1 -0
- package/build-types/circular-option-picker/types.d.ts +49 -0
- package/build-types/circular-option-picker/types.d.ts.map +1 -0
- package/build-types/dropdown-menu/index.d.ts.map +1 -1
- package/build-types/h-stack/stories/e2e/index.d.ts +9 -0
- package/build-types/h-stack/stories/e2e/index.d.ts.map +1 -0
- package/build-types/higher-order/with-constrained-tabbing/index.d.ts +10 -1
- package/build-types/higher-order/with-constrained-tabbing/index.d.ts.map +1 -1
- package/build-types/range-control/index.d.ts.map +1 -1
- package/build-types/tab-panel/stories/index.d.ts +1 -0
- package/build-types/tab-panel/stories/index.d.ts.map +1 -1
- package/build-types/tools-panel/context.d.ts.map +1 -1
- package/build-types/tools-panel/test/index.d.ts +2 -0
- package/build-types/tools-panel/test/index.d.ts.map +1 -0
- package/build-types/tools-panel/tools-panel/hook.d.ts +3 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/hook.d.ts +1 -1
- package/build-types/tools-panel/tools-panel-item/component.d.ts +1 -0
- package/build-types/tools-panel/tools-panel-item/component.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 +11 -9
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/build-types/ui/context/context-system-provider.d.ts.map +1 -1
- package/build-types/v-stack/stories/e2e/index.d.ts +9 -0
- package/build-types/v-stack/stories/e2e/index.d.ts.map +1 -0
- package/package.json +23 -21
- package/src/autocomplete/autocompleter-ui.js +72 -34
- package/src/autocomplete/index.js +36 -36
- package/src/circular-option-picker/README.md +141 -0
- package/src/circular-option-picker/{index.js → index.tsx} +74 -14
- package/src/circular-option-picker/stories/index.tsx +134 -0
- package/src/circular-option-picker/types.ts +69 -0
- package/src/color-palette/test/__snapshots__/index.tsx.snap +1 -1
- package/src/dropdown-menu/index.js +6 -3
- package/src/h-stack/stories/e2e/index.tsx +36 -0
- package/src/higher-order/navigate-regions/style.scss +2 -1
- package/src/higher-order/with-constrained-tabbing/index.tsx +30 -0
- package/src/mobile/global-styles-context/utils.native.js +1 -0
- package/src/range-control/index.tsx +5 -1
- package/src/tab-panel/stories/index.tsx +41 -0
- package/src/tab-panel/test/index.tsx +794 -262
- package/src/tools-panel/context.ts +2 -0
- package/src/tools-panel/test/{index.js → index.tsx} +171 -61
- package/src/tools-panel/tools-panel/hook.ts +30 -11
- package/src/tools-panel/tools-panel-item/hook.ts +18 -2
- package/src/tools-panel/types.ts +12 -9
- package/src/tree-grid/test/__snapshots__/index.tsx.snap +1 -1
- package/src/ui/context/context-system-provider.js +7 -4
- package/src/v-stack/stories/e2e/index.tsx +36 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/higher-order/with-constrained-tabbing/index.js +0 -22
|
@@ -3,6 +3,7 @@ export declare const ToolsPanelItem: import("../../ui/context").WordPressCompone
|
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
onDeselect?: (() => void) | undefined;
|
|
5
5
|
onSelect?: (() => void) | undefined;
|
|
6
|
+
resetAllFilter?: import("../types").ResetAllFilter | undefined;
|
|
6
7
|
} & import("react").RefAttributes<any>, true>;
|
|
7
8
|
export default ToolsPanelItem;
|
|
8
9
|
//# sourceMappingURL=component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/tools-panel/tools-panel-item/component.tsx"],"names":[],"mappings":";AAuCA,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/tools-panel/tools-panel-item/component.tsx"],"names":[],"mappings":";AAuCA,eAAO,MAAM,cAAc;;;;;6CAG1B,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../../src/tools-panel/tools-panel-item/hook.ts"],"names":[],"mappings":";AAWA,OAAO,EAAoB,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAIpD,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,uBAAuB,CAAE,mBAAmB,EAAE,KAAK,CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../../src/tools-panel/tools-panel-item/hook.ts"],"names":[],"mappings":";AAWA,OAAO,EAAoB,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAIpD,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,uBAAuB,CAAE,mBAAmB,EAAE,KAAK,CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgM5D"}
|
|
@@ -6,7 +6,7 @@ import type { ReactNode } from 'react';
|
|
|
6
6
|
* Internal dependencies
|
|
7
7
|
*/
|
|
8
8
|
import type { HeadingSize } from '../heading/types';
|
|
9
|
-
declare type ResetAllFilter = (attributes?: any) => any;
|
|
9
|
+
export declare type ResetAllFilter = (attributes?: any) => any;
|
|
10
10
|
declare type ResetAll = (filters?: ResetAllFilter[]) => void;
|
|
11
11
|
export declare type ToolsPanelProps = {
|
|
12
12
|
/**
|
|
@@ -117,14 +117,6 @@ export declare type ToolsPanelItem = {
|
|
|
117
117
|
* from a shared source.
|
|
118
118
|
*/
|
|
119
119
|
panelId?: string | null;
|
|
120
|
-
/**
|
|
121
|
-
* A `ToolsPanel` will collect each item's `resetAllFilter` and pass an
|
|
122
|
-
* array of these functions through to the panel's `resetAll` callback. They
|
|
123
|
-
* can then be iterated over to perform additional tasks.
|
|
124
|
-
*
|
|
125
|
-
* @default noop
|
|
126
|
-
*/
|
|
127
|
-
resetAllFilter?: ResetAllFilter;
|
|
128
120
|
};
|
|
129
121
|
export declare type ToolsPanelItemProps = ToolsPanelItem & {
|
|
130
122
|
/**
|
|
@@ -141,6 +133,14 @@ export declare type ToolsPanelItemProps = ToolsPanelItem & {
|
|
|
141
133
|
* menu.
|
|
142
134
|
*/
|
|
143
135
|
onSelect?: () => void;
|
|
136
|
+
/**
|
|
137
|
+
* A `ToolsPanel` will collect each item's `resetAllFilter` and pass an
|
|
138
|
+
* array of these functions through to the panel's `resetAll` callback. They
|
|
139
|
+
* can then be iterated over to perform additional tasks.
|
|
140
|
+
*
|
|
141
|
+
* @default noop
|
|
142
|
+
*/
|
|
143
|
+
resetAllFilter?: ResetAllFilter;
|
|
144
144
|
};
|
|
145
145
|
export declare type ToolsPanelMenuItemKey = 'default' | 'optional';
|
|
146
146
|
export declare type ToolsPanelMenuItems = {
|
|
@@ -154,6 +154,8 @@ export declare type ToolsPanelContext = {
|
|
|
154
154
|
hasMenuItems: boolean;
|
|
155
155
|
registerPanelItem: (item: ToolsPanelItem) => void;
|
|
156
156
|
deregisterPanelItem: (label: string) => void;
|
|
157
|
+
registerResetAllFilter: (filter: ResetAllFilter) => void;
|
|
158
|
+
deregisterResetAllFilter: (filter: ResetAllFilter) => void;
|
|
157
159
|
flagItemCustomization: (label: string, group?: ToolsPanelMenuItemKey) => void;
|
|
158
160
|
isResetting: boolean;
|
|
159
161
|
shouldRenderPlaceholderItems: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools-panel/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC;;GAEG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools-panel/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC;;GAEG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,oBAAY,cAAc,GAAG,CAAE,UAAU,CAAC,EAAE,GAAG,KAAM,GAAG,CAAC;AAC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IAAI,CAAC;CACtC,CAAC;AAEF,oBAAY,yBAAyB,GAAG;IACvC,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,CAAC,EAAE,mBAAmB,CAAC;CACvC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-system-provider.d.ts","sourceRoot":"","sources":["../../../src/ui/context/context-system-provider.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context-system-provider.d.ts","sourceRoot":"","sources":["../../../src/ui/context/context-system-provider.js"],"names":[],"mappings":"AAwBA,6EAEE;AACK,4DAAkE;AA4EzE;cAdW,OAAO,OAAO,EAAE,SAAS;;MAExB,WAAW,GAYgD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
5
|
+
import { VStack } from '../..';
|
|
6
|
+
declare const meta: ComponentMeta<typeof VStack>;
|
|
7
|
+
export default meta;
|
|
8
|
+
export declare const Default: ComponentStory<typeof VStack>;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/v-stack/stories/e2e/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAMtE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,QAAA,MAAM,IAAI,EAAE,aAAa,CAAE,OAAO,MAAM,CAGvC,CAAC;AACF,eAAe,IAAI,CAAC;AAiBpB,eAAO,MAAM,OAAO,EAAE,cAAc,CAAE,OAAO,MAAM,CAAwB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/components",
|
|
3
|
-
"version": "23.
|
|
3
|
+
"version": "23.5.0",
|
|
4
4
|
"description": "UI components for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -36,35 +36,37 @@
|
|
|
36
36
|
"@emotion/serialize": "^1.0.2",
|
|
37
37
|
"@emotion/styled": "^11.6.0",
|
|
38
38
|
"@emotion/utils": "^1.0.0",
|
|
39
|
-
"@floating-ui/react-dom": "
|
|
39
|
+
"@floating-ui/react-dom": "1.0.0",
|
|
40
40
|
"@use-gesture/react": "^10.2.6",
|
|
41
|
-
"@wordpress/a11y": "^3.
|
|
42
|
-
"@wordpress/compose": "^6.
|
|
43
|
-
"@wordpress/date": "^4.
|
|
44
|
-
"@wordpress/deprecated": "^3.
|
|
45
|
-
"@wordpress/dom": "^3.
|
|
46
|
-
"@wordpress/element": "^5.
|
|
47
|
-
"@wordpress/escape-html": "^2.
|
|
48
|
-
"@wordpress/hooks": "^3.
|
|
49
|
-
"@wordpress/html-entities": "^3.
|
|
50
|
-
"@wordpress/i18n": "^4.
|
|
51
|
-
"@wordpress/icons": "^9.
|
|
52
|
-
"@wordpress/is-shallow-equal": "^4.
|
|
53
|
-
"@wordpress/keycodes": "^3.
|
|
54
|
-
"@wordpress/primitives": "^3.
|
|
55
|
-
"@wordpress/private-apis": "^0.
|
|
56
|
-
"@wordpress/rich-text": "^6.
|
|
57
|
-
"@wordpress/warning": "^2.
|
|
41
|
+
"@wordpress/a11y": "^3.28.0",
|
|
42
|
+
"@wordpress/compose": "^6.5.0",
|
|
43
|
+
"@wordpress/date": "^4.28.0",
|
|
44
|
+
"@wordpress/deprecated": "^3.28.0",
|
|
45
|
+
"@wordpress/dom": "^3.28.0",
|
|
46
|
+
"@wordpress/element": "^5.5.0",
|
|
47
|
+
"@wordpress/escape-html": "^2.28.0",
|
|
48
|
+
"@wordpress/hooks": "^3.28.0",
|
|
49
|
+
"@wordpress/html-entities": "^3.28.0",
|
|
50
|
+
"@wordpress/i18n": "^4.28.0",
|
|
51
|
+
"@wordpress/icons": "^9.19.0",
|
|
52
|
+
"@wordpress/is-shallow-equal": "^4.28.0",
|
|
53
|
+
"@wordpress/keycodes": "^3.28.0",
|
|
54
|
+
"@wordpress/primitives": "^3.26.0",
|
|
55
|
+
"@wordpress/private-apis": "^0.10.0",
|
|
56
|
+
"@wordpress/rich-text": "^6.5.0",
|
|
57
|
+
"@wordpress/warning": "^2.28.0",
|
|
58
58
|
"change-case": "^4.1.2",
|
|
59
59
|
"classnames": "^2.3.1",
|
|
60
60
|
"colord": "^2.7.0",
|
|
61
61
|
"date-fns": "^2.28.0",
|
|
62
|
+
"deepmerge": "^4.3.0",
|
|
62
63
|
"dom-scroll-into-view": "^1.2.1",
|
|
63
64
|
"downshift": "^6.0.15",
|
|
64
65
|
"fast-deep-equal": "^3.1.3",
|
|
65
66
|
"framer-motion": "^7.6.1",
|
|
66
67
|
"gradient-parser": "^0.1.5",
|
|
67
68
|
"highlight-words-core": "^1.2.2",
|
|
69
|
+
"is-plain-object": "^5.0.0",
|
|
68
70
|
"lodash": "^4.17.21",
|
|
69
71
|
"memize": "^1.1.0",
|
|
70
72
|
"path-to-regexp": "^6.2.1",
|
|
@@ -74,7 +76,7 @@
|
|
|
74
76
|
"remove-accents": "^0.4.2",
|
|
75
77
|
"use-lilius": "^2.0.1",
|
|
76
78
|
"uuid": "^8.3.0",
|
|
77
|
-
"valtio": "
|
|
79
|
+
"valtio": "1.7.0"
|
|
78
80
|
},
|
|
79
81
|
"peerDependencies": {
|
|
80
82
|
"react": "^18.0.0",
|
|
@@ -83,5 +85,5 @@
|
|
|
83
85
|
"publishConfig": {
|
|
84
86
|
"access": "public"
|
|
85
87
|
},
|
|
86
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "d5e03a74b79e3ca84afda24375474a103a063ee4"
|
|
87
89
|
}
|
|
@@ -6,8 +6,14 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
useLayoutEffect,
|
|
11
|
+
useRef,
|
|
12
|
+
useEffect,
|
|
13
|
+
useState,
|
|
14
|
+
} from '@wordpress/element';
|
|
10
15
|
import { useAnchor } from '@wordpress/rich-text';
|
|
16
|
+
import { useMergeRefs, useRefEffect } from '@wordpress/compose';
|
|
11
17
|
|
|
12
18
|
/**
|
|
13
19
|
* Internal dependencies
|
|
@@ -15,6 +21,8 @@ import { useAnchor } from '@wordpress/rich-text';
|
|
|
15
21
|
import getDefaultUseItems from './get-default-use-items';
|
|
16
22
|
import Button from '../button';
|
|
17
23
|
import Popover from '../popover';
|
|
24
|
+
import { VisuallyHidden } from '../visually-hidden';
|
|
25
|
+
import { createPortal } from 'react-dom';
|
|
18
26
|
|
|
19
27
|
export function getAutoCompleterUI( autocompleter ) {
|
|
20
28
|
const useItems = autocompleter.useItems
|
|
@@ -40,7 +48,25 @@ export function getAutoCompleterUI( autocompleter ) {
|
|
|
40
48
|
value,
|
|
41
49
|
} );
|
|
42
50
|
|
|
51
|
+
const [ needsA11yCompat, setNeedsA11yCompat ] = useState( false );
|
|
43
52
|
const popoverRef = useRef();
|
|
53
|
+
const popoverRefs = useMergeRefs( [
|
|
54
|
+
popoverRef,
|
|
55
|
+
useRefEffect(
|
|
56
|
+
( node ) => {
|
|
57
|
+
if ( ! contentRef.current ) return;
|
|
58
|
+
|
|
59
|
+
// If the popover is rendered in a different document than
|
|
60
|
+
// the content, we need to duplicate the options list in the
|
|
61
|
+
// content document so that it's available to the screen
|
|
62
|
+
// readers, which check the DOM ID based aira-* attributes.
|
|
63
|
+
setNeedsA11yCompat(
|
|
64
|
+
node.ownerDocument !== contentRef.current.ownerDocument
|
|
65
|
+
);
|
|
66
|
+
},
|
|
67
|
+
[ contentRef ]
|
|
68
|
+
),
|
|
69
|
+
] );
|
|
44
70
|
|
|
45
71
|
useOnClickOutside( popoverRef, reset );
|
|
46
72
|
|
|
@@ -55,41 +81,53 @@ export function getAutoCompleterUI( autocompleter ) {
|
|
|
55
81
|
return null;
|
|
56
82
|
}
|
|
57
83
|
|
|
58
|
-
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
className="components-autocomplete__popover"
|
|
64
|
-
anchor={ popoverAnchor }
|
|
65
|
-
ref={ popoverRef }
|
|
84
|
+
const ListBox = ( { Component = 'div' } ) => (
|
|
85
|
+
<Component
|
|
86
|
+
id={ listBoxId }
|
|
87
|
+
role="listbox"
|
|
88
|
+
className="components-autocomplete__results"
|
|
66
89
|
>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
90
|
+
{ items.map( ( option, index ) => (
|
|
91
|
+
<Button
|
|
92
|
+
key={ option.key }
|
|
93
|
+
id={ `components-autocomplete-item-${ instanceId }-${ option.key }` }
|
|
94
|
+
role="option"
|
|
95
|
+
aria-selected={ index === selectedIndex }
|
|
96
|
+
disabled={ option.isDisabled }
|
|
97
|
+
className={ classnames(
|
|
98
|
+
'components-autocomplete__result',
|
|
99
|
+
className,
|
|
100
|
+
{
|
|
101
|
+
'is-selected': index === selectedIndex,
|
|
102
|
+
}
|
|
103
|
+
) }
|
|
104
|
+
onClick={ () => onSelect( option ) }
|
|
105
|
+
>
|
|
106
|
+
{ option.label }
|
|
107
|
+
</Button>
|
|
108
|
+
) ) }
|
|
109
|
+
</Component>
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<>
|
|
114
|
+
<Popover
|
|
115
|
+
focusOnMount={ false }
|
|
116
|
+
onClose={ onReset }
|
|
117
|
+
placement="top-start"
|
|
118
|
+
className="components-autocomplete__popover"
|
|
119
|
+
anchor={ popoverAnchor }
|
|
120
|
+
ref={ popoverRefs }
|
|
71
121
|
>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
className,
|
|
82
|
-
{
|
|
83
|
-
'is-selected': index === selectedIndex,
|
|
84
|
-
}
|
|
85
|
-
) }
|
|
86
|
-
onClick={ () => onSelect( option ) }
|
|
87
|
-
>
|
|
88
|
-
{ option.label }
|
|
89
|
-
</Button>
|
|
90
|
-
) ) }
|
|
91
|
-
</div>
|
|
92
|
-
</Popover>
|
|
122
|
+
<ListBox />
|
|
123
|
+
</Popover>
|
|
124
|
+
{ contentRef.current &&
|
|
125
|
+
needsA11yCompat &&
|
|
126
|
+
createPortal(
|
|
127
|
+
<ListBox Component={ VisuallyHidden } />,
|
|
128
|
+
contentRef.current.ownerDocument.body
|
|
129
|
+
) }
|
|
130
|
+
</>
|
|
93
131
|
);
|
|
94
132
|
}
|
|
95
133
|
|
|
@@ -35,6 +35,8 @@ import { speak } from '@wordpress/a11y';
|
|
|
35
35
|
import { getAutoCompleterUI } from './autocompleter-ui';
|
|
36
36
|
import { escapeRegExp } from '../utils/strings';
|
|
37
37
|
|
|
38
|
+
const EMPTY_ARRAY = [];
|
|
39
|
+
|
|
38
40
|
/**
|
|
39
41
|
* A raw completer option.
|
|
40
42
|
*
|
|
@@ -121,7 +123,7 @@ function useAutocomplete( {
|
|
|
121
123
|
const debouncedSpeak = useDebounce( speak, 500 );
|
|
122
124
|
const instanceId = useInstanceId( useAutocomplete );
|
|
123
125
|
const [ selectedIndex, setSelectedIndex ] = useState( 0 );
|
|
124
|
-
const [ filteredOptions, setFilteredOptions ] = useState(
|
|
126
|
+
const [ filteredOptions, setFilteredOptions ] = useState( EMPTY_ARRAY );
|
|
125
127
|
const [ filterValue, setFilterValue ] = useState( '' );
|
|
126
128
|
const [ autocompleter, setAutocompleter ] = useState( null );
|
|
127
129
|
const [ AutocompleterUI, setAutocompleterUI ] = useState( null );
|
|
@@ -169,7 +171,7 @@ function useAutocomplete( {
|
|
|
169
171
|
|
|
170
172
|
function reset() {
|
|
171
173
|
setSelectedIndex( 0 );
|
|
172
|
-
setFilteredOptions(
|
|
174
|
+
setFilteredOptions( EMPTY_ARRAY );
|
|
173
175
|
setFilterValue( '' );
|
|
174
176
|
setAutocompleter( null );
|
|
175
177
|
setAutocompleterUI( null );
|
|
@@ -281,23 +283,19 @@ function useAutocomplete( {
|
|
|
281
283
|
|
|
282
284
|
useEffect( () => {
|
|
283
285
|
if ( ! textContent ) {
|
|
284
|
-
reset();
|
|
286
|
+
if ( autocompleter ) reset();
|
|
285
287
|
return;
|
|
286
288
|
}
|
|
287
289
|
|
|
288
|
-
const text = removeAccents( textContent );
|
|
289
|
-
const textAfterSelection = getTextContent(
|
|
290
|
-
slice( record, undefined, getTextContent( record ).length )
|
|
291
|
-
);
|
|
292
290
|
const completer = completers?.find(
|
|
293
291
|
( { triggerPrefix, allowContext } ) => {
|
|
294
|
-
const index =
|
|
292
|
+
const index = textContent.lastIndexOf( triggerPrefix );
|
|
295
293
|
|
|
296
294
|
if ( index === -1 ) {
|
|
297
295
|
return false;
|
|
298
296
|
}
|
|
299
297
|
|
|
300
|
-
const textWithoutTrigger =
|
|
298
|
+
const textWithoutTrigger = textContent.slice(
|
|
301
299
|
index + triggerPrefix.length
|
|
302
300
|
);
|
|
303
301
|
|
|
@@ -339,9 +337,16 @@ function useAutocomplete( {
|
|
|
339
337
|
return false;
|
|
340
338
|
}
|
|
341
339
|
|
|
340
|
+
const textAfterSelection = getTextContent(
|
|
341
|
+
slice( record, undefined, getTextContent( record ).length )
|
|
342
|
+
);
|
|
343
|
+
|
|
342
344
|
if (
|
|
343
345
|
allowContext &&
|
|
344
|
-
! allowContext(
|
|
346
|
+
! allowContext(
|
|
347
|
+
textContent.slice( 0, index ),
|
|
348
|
+
textAfterSelection
|
|
349
|
+
)
|
|
345
350
|
) {
|
|
346
351
|
return false;
|
|
347
352
|
}
|
|
@@ -358,11 +363,12 @@ function useAutocomplete( {
|
|
|
358
363
|
);
|
|
359
364
|
|
|
360
365
|
if ( ! completer ) {
|
|
361
|
-
reset();
|
|
366
|
+
if ( autocompleter ) reset();
|
|
362
367
|
return;
|
|
363
368
|
}
|
|
364
369
|
|
|
365
370
|
const safeTrigger = escapeRegExp( completer.triggerPrefix );
|
|
371
|
+
const text = removeAccents( textContent );
|
|
366
372
|
const match = text
|
|
367
373
|
.slice( text.lastIndexOf( completer.triggerPrefix ) )
|
|
368
374
|
.match( new RegExp( `${ safeTrigger }([\u0000-\uFFFF]*)$` ) );
|
|
@@ -412,53 +418,47 @@ function useAutocomplete( {
|
|
|
412
418
|
};
|
|
413
419
|
}
|
|
414
420
|
|
|
421
|
+
function useLastDifferentValue( value ) {
|
|
422
|
+
const history = useRef( new Set() );
|
|
423
|
+
|
|
424
|
+
history.current.add( value );
|
|
425
|
+
|
|
426
|
+
// Keep the history size to 2.
|
|
427
|
+
if ( history.current.size > 2 ) {
|
|
428
|
+
history.current.delete( Array.from( history.current )[ 0 ] );
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
return Array.from( history.current )[ 0 ];
|
|
432
|
+
}
|
|
433
|
+
|
|
415
434
|
export function useAutocompleteProps( options ) {
|
|
416
|
-
const [ isVisible, setIsVisible ] = useState( false );
|
|
417
435
|
const ref = useRef();
|
|
418
|
-
const recordAfterInput = useRef();
|
|
419
436
|
const onKeyDownRef = useRef();
|
|
437
|
+
const { record } = options;
|
|
438
|
+
const previousRecord = useLastDifferentValue( record );
|
|
420
439
|
const { popover, listBoxId, activeId, onKeyDown } = useAutocomplete( {
|
|
421
440
|
...options,
|
|
422
441
|
contentRef: ref,
|
|
423
442
|
} );
|
|
424
443
|
onKeyDownRef.current = onKeyDown;
|
|
425
444
|
|
|
426
|
-
useEffect( () => {
|
|
427
|
-
if ( isVisible ) {
|
|
428
|
-
if ( ! recordAfterInput.current ) {
|
|
429
|
-
recordAfterInput.current = options.record;
|
|
430
|
-
} else if (
|
|
431
|
-
recordAfterInput.current.start !== options.record.start ||
|
|
432
|
-
recordAfterInput.current.end !== options.record.end
|
|
433
|
-
) {
|
|
434
|
-
setIsVisible( false );
|
|
435
|
-
recordAfterInput.current = null;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
439
|
-
}, [ options.record ] );
|
|
440
|
-
|
|
441
445
|
const mergedRefs = useMergeRefs( [
|
|
442
446
|
ref,
|
|
443
447
|
useRefEffect( ( element ) => {
|
|
444
448
|
function _onKeyDown( event ) {
|
|
445
449
|
onKeyDownRef.current( event );
|
|
446
450
|
}
|
|
447
|
-
function _onInput() {
|
|
448
|
-
// Only show auto complete UI if the user is inputting text.
|
|
449
|
-
setIsVisible( true );
|
|
450
|
-
recordAfterInput.current = null;
|
|
451
|
-
}
|
|
452
451
|
element.addEventListener( 'keydown', _onKeyDown );
|
|
453
|
-
element.addEventListener( 'input', _onInput );
|
|
454
452
|
return () => {
|
|
455
453
|
element.removeEventListener( 'keydown', _onKeyDown );
|
|
456
|
-
element.removeEventListener( 'input', _onInput );
|
|
457
454
|
};
|
|
458
455
|
}, [] ),
|
|
459
456
|
] );
|
|
460
457
|
|
|
461
|
-
if
|
|
458
|
+
// We only want to show the popover if the user has typed something.
|
|
459
|
+
const didUserInput = record.text !== previousRecord?.text;
|
|
460
|
+
|
|
461
|
+
if ( ! didUserInput ) {
|
|
462
462
|
return { ref: mergedRefs };
|
|
463
463
|
}
|
|
464
464
|
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# `CircularOptionPicker`
|
|
2
|
+
|
|
3
|
+
<div class="callout callout-alert">
|
|
4
|
+
This component is not exported, and therefore can only be used internally to the `@wordpress/components` package.
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
`CircularOptionPicker` is a component that displays a set of options as circular buttons.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```jsx
|
|
12
|
+
import { CircularOptionPicker } from '../circular-option-picker';
|
|
13
|
+
import { useState } from '@wordpress/element';
|
|
14
|
+
|
|
15
|
+
const Example = () => {
|
|
16
|
+
const [ currentColor, setCurrentColor ] = useState();
|
|
17
|
+
const colors = [
|
|
18
|
+
{ color: '#f00', name: 'Red' },
|
|
19
|
+
{ color: '#0f0', name: 'Green' },
|
|
20
|
+
{ color: '#00f', name: 'Blue' },
|
|
21
|
+
];
|
|
22
|
+
const colorOptions = (
|
|
23
|
+
<>
|
|
24
|
+
{ colors.map( ( { color, name }, index ) => {
|
|
25
|
+
return (
|
|
26
|
+
<CircularOptionPicker.Option
|
|
27
|
+
key={ `${ color }-${ index }` }
|
|
28
|
+
tooltipText={ name }
|
|
29
|
+
style={ { backgroundColor: color, color } }
|
|
30
|
+
isSelected={ index === currentColor }
|
|
31
|
+
onClick={ () => setCurrentColor( index ) }
|
|
32
|
+
aria-label={ name }
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
} ) }
|
|
36
|
+
</>
|
|
37
|
+
);
|
|
38
|
+
return (
|
|
39
|
+
<CircularOptionPicker
|
|
40
|
+
options={ colorOptions }
|
|
41
|
+
actions={
|
|
42
|
+
<CircularOptionPicker.ButtonAction
|
|
43
|
+
onClick={ () => setCurrentColor( undefined ) }
|
|
44
|
+
>
|
|
45
|
+
{ 'Clear' }
|
|
46
|
+
</CircularOptionPicker.ButtonAction>
|
|
47
|
+
}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Props
|
|
54
|
+
|
|
55
|
+
### `className`: `string`
|
|
56
|
+
|
|
57
|
+
A CSS class to apply to the wrapper element.
|
|
58
|
+
|
|
59
|
+
- Required: No
|
|
60
|
+
|
|
61
|
+
### `actions`: `ReactNode`
|
|
62
|
+
|
|
63
|
+
The action(s) to be rendered after the options, such as a 'clear' button as seen in `ColorPalette`.
|
|
64
|
+
|
|
65
|
+
Usually a `CircularOptionPicker.ButtonAction` or `CircularOptionPicker.DropdownLinkAction` component.
|
|
66
|
+
|
|
67
|
+
- Required: No
|
|
68
|
+
|
|
69
|
+
### `options`: `ReactNode`
|
|
70
|
+
|
|
71
|
+
The options to be rendered, such as color swatches.
|
|
72
|
+
|
|
73
|
+
Usually a `CircularOptionPicker.Option` component.
|
|
74
|
+
|
|
75
|
+
- Required: No
|
|
76
|
+
|
|
77
|
+
### `children`: `ReactNode`
|
|
78
|
+
|
|
79
|
+
The child elements.
|
|
80
|
+
|
|
81
|
+
- Required: No
|
|
82
|
+
|
|
83
|
+
## Subcomponents
|
|
84
|
+
|
|
85
|
+
### `CircularOptionPicker.ButtonAction`
|
|
86
|
+
|
|
87
|
+
A `ButtonAction` is an action that is rendered as a button alongside the options themselves.
|
|
88
|
+
|
|
89
|
+
A common use case is a 'clear' button to deselect the currently selected option.
|
|
90
|
+
|
|
91
|
+
#### Props
|
|
92
|
+
|
|
93
|
+
##### `className`: `string`
|
|
94
|
+
|
|
95
|
+
A CSS class to apply to the underlying `Button` component.
|
|
96
|
+
|
|
97
|
+
- Required: No
|
|
98
|
+
|
|
99
|
+
##### `children`: `ReactNode`
|
|
100
|
+
|
|
101
|
+
The button's children.
|
|
102
|
+
|
|
103
|
+
- Required: No
|
|
104
|
+
|
|
105
|
+
##### Inherited props
|
|
106
|
+
|
|
107
|
+
`CircularOptionPicker.ButtonAction` also inherits all of the [`Button` props](/packages/components/src/button/README.md#props), except for `href` and `target`.
|
|
108
|
+
|
|
109
|
+
### `CircularOptionPicker.DropdownLinkAction`
|
|
110
|
+
|
|
111
|
+
`CircularOptionPicker.DropdownLinkAction` is an action that's hidden behind a dropdown toggle. The button is formatted as a link and rendered as an `anchor` element.
|
|
112
|
+
|
|
113
|
+
#### Props
|
|
114
|
+
|
|
115
|
+
##### `className`: `string`
|
|
116
|
+
|
|
117
|
+
A CSS class to apply to the underlying `Dropdown` component.
|
|
118
|
+
|
|
119
|
+
- Required: No
|
|
120
|
+
|
|
121
|
+
##### `linkText`: `string`
|
|
122
|
+
|
|
123
|
+
The text to be displayed on the button.
|
|
124
|
+
|
|
125
|
+
- Required: Yes
|
|
126
|
+
|
|
127
|
+
##### `dropdownProps`: `object`
|
|
128
|
+
|
|
129
|
+
The props for the underlying `Dropdown` component.
|
|
130
|
+
|
|
131
|
+
Inherits all of the [`Dropdown` props](/packages/components/src/dropdown/README.md#props), except for `className` and `renderToggle`.
|
|
132
|
+
|
|
133
|
+
- Required: Yes
|
|
134
|
+
|
|
135
|
+
##### `buttonProps`: `object`
|
|
136
|
+
|
|
137
|
+
Props for the underlying `Button` component.
|
|
138
|
+
|
|
139
|
+
Inherits all of the [`Button` props](/packages/components/src/button/README.md#props), except for `href`, `target`, and `children`.
|
|
140
|
+
|
|
141
|
+
- Required: No
|