@wordpress/components 32.2.1-next.v.202602191100.0 → 32.3.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 +24 -0
- package/build/alignment-matrix-control/cell.cjs +2 -2
- package/build/alignment-matrix-control/cell.cjs.map +2 -2
- package/build/alignment-matrix-control/index.cjs +2 -2
- package/build/alignment-matrix-control/index.cjs.map +2 -2
- package/build/angle-picker-control/angle-circle.cjs +2 -2
- package/build/angle-picker-control/angle-circle.cjs.map +2 -2
- package/build/color-picker/color-input.cjs +11 -8
- package/build/color-picker/color-input.cjs.map +2 -2
- package/build/color-picker/component.cjs +47 -3
- package/build/color-picker/component.cjs.map +2 -2
- package/build/color-picker/hsl-input.cjs +7 -28
- package/build/color-picker/hsl-input.cjs.map +2 -2
- package/build/color-picker/picker.cjs +29 -20
- package/build/color-picker/picker.cjs.map +2 -2
- package/build/date-time/date/styles.cjs +9 -9
- package/build/date-time/date/styles.cjs.map +2 -2
- package/build/number-control/index.cjs +2 -5
- package/build/number-control/index.cjs.map +2 -2
- package/build/select-control/styles/select-control-styles.cjs +8 -8
- package/build/select-control/styles/select-control-styles.cjs.map +2 -2
- package/build/snackbar/list.cjs +4 -1
- package/build/snackbar/list.cjs.map +2 -2
- package/build/toggle-group-control/toggle-group-control-option-base/styles.cjs +8 -8
- package/build/toggle-group-control/toggle-group-control-option-base/styles.cjs.map +2 -2
- package/build-module/alignment-matrix-control/cell.mjs +2 -2
- package/build-module/alignment-matrix-control/cell.mjs.map +2 -2
- package/build-module/alignment-matrix-control/index.mjs +2 -2
- package/build-module/alignment-matrix-control/index.mjs.map +2 -2
- package/build-module/angle-picker-control/angle-circle.mjs +2 -2
- package/build-module/angle-picker-control/angle-circle.mjs.map +2 -2
- package/build-module/color-picker/color-input.mjs +11 -8
- package/build-module/color-picker/color-input.mjs.map +2 -2
- package/build-module/color-picker/component.mjs +48 -4
- package/build-module/color-picker/component.mjs.map +2 -2
- package/build-module/color-picker/hsl-input.mjs +7 -28
- package/build-module/color-picker/hsl-input.mjs.map +2 -2
- package/build-module/color-picker/picker.mjs +30 -21
- package/build-module/color-picker/picker.mjs.map +2 -2
- package/build-module/date-time/date/styles.mjs +9 -9
- package/build-module/date-time/date/styles.mjs.map +2 -2
- package/build-module/number-control/index.mjs +2 -5
- package/build-module/number-control/index.mjs.map +2 -2
- package/build-module/select-control/styles/select-control-styles.mjs +8 -8
- package/build-module/select-control/styles/select-control-styles.mjs.map +2 -2
- package/build-module/snackbar/list.mjs +4 -1
- package/build-module/snackbar/list.mjs.map +2 -2
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.mjs +8 -8
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.mjs.map +2 -2
- package/build-style/style-rtl.css +2 -0
- package/build-style/style.css +2 -0
- package/build-types/color-picker/color-input.d.ts +1 -1
- package/build-types/color-picker/color-input.d.ts.map +1 -1
- package/build-types/color-picker/component.d.ts.map +1 -1
- package/build-types/color-picker/hsl-input.d.ts +1 -1
- package/build-types/color-picker/hsl-input.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/types.d.ts +6 -4
- package/build-types/color-picker/types.d.ts.map +1 -1
- package/build-types/date-time/date/styles.d.ts.map +1 -1
- package/build-types/dropdown/types.d.ts +9 -13
- package/build-types/dropdown/types.d.ts.map +1 -1
- package/build-types/modal/types.d.ts +9 -3
- package/build-types/modal/types.d.ts.map +1 -1
- package/build-types/number-control/index.d.ts.map +1 -1
- package/build-types/popover/types.d.ts +10 -10
- package/build-types/popover/types.d.ts.map +1 -1
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/snackbar/list.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts +1 -1
- package/build-types/tools-panel/types.d.ts +1 -1
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/package.json +21 -21
- package/src/button/style.scss +1 -0
- package/src/color-picker/color-input.tsx +23 -4
- package/src/color-picker/component.tsx +88 -4
- package/src/color-picker/hsl-input.tsx +9 -51
- package/src/color-picker/picker.tsx +28 -24
- package/src/color-picker/test/index.tsx +139 -6
- package/src/color-picker/types.ts +6 -4
- package/src/date-time/date/styles.ts +1 -0
- package/src/dropdown/types.ts +9 -14
- package/src/form-token-field/style.scss +1 -0
- package/src/modal/types.ts +9 -5
- package/src/number-control/index.tsx +73 -77
- package/src/popover/types.ts +10 -10
- package/src/select-control/styles/select-control-styles.ts +1 -0
- package/src/snackbar/list.tsx +6 -1
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +18 -16
- package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +4 -6
- package/src/tools-panel/types.ts +4 -1
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import type { ReactNode, MutableRefObject, SyntheticEvent } from 'react';
|
|
5
1
|
import type { Placement } from '@floating-ui/react-dom';
|
|
2
|
+
import type { useFocusOnMount } from '@wordpress/compose';
|
|
3
|
+
import type { MutableRefObject, ReactNode, SyntheticEvent } from 'react';
|
|
6
4
|
type PositionYAxis = 'top' | 'middle' | 'bottom';
|
|
7
5
|
type PositionXAxis = 'left' | 'center' | 'right';
|
|
8
6
|
type PositionCorner = 'top' | 'right' | 'bottom' | 'left';
|
|
@@ -70,15 +68,17 @@ export type PopoverProps = {
|
|
|
70
68
|
*/
|
|
71
69
|
constrainTabbing?: boolean;
|
|
72
70
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
71
|
+
* Determines focus behavior when the popover mounts.
|
|
72
|
+
*
|
|
73
|
+
* - `"firstElement"` focuses the first tabbable element within.
|
|
74
|
+
* - `"firstInputElement"` focuses the first value control within.
|
|
75
|
+
* - `true` focuses the element itself.
|
|
76
|
+
* - `false` does nothing and _should not be used unless an accessible
|
|
77
|
+
* substitute behavior is implemented_.
|
|
78
78
|
*
|
|
79
79
|
* @default 'firstElement'
|
|
80
80
|
*/
|
|
81
|
-
focusOnMount?:
|
|
81
|
+
focusOnMount?: useFocusOnMount.Mode;
|
|
82
82
|
/**
|
|
83
83
|
* A callback invoked when the focus leaves the opened popover. This should
|
|
84
84
|
* only be provided in advanced use-cases when a popover should close under
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/popover/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/popover/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEzE,KAAK,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACjD,KAAK,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AACjD,KAAK,cAAc,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE1D,KAAK,wBAAwB,GAAG,OAAO,GAAG;IACzC,aAAa,CAAC,EAAE,QAAQ,CAAC;CACzB,CAAC;AAEF,KAAK,gBAAgB,GAAG,SAAS,GAAG,SAAS,CAAC;AAE9C,MAAM,MAAM,yBAAyB,GAAG,gBAAgB,CACvD,OAAO,GAAG,IAAI,GAAG,SAAS,CAC1B,CAAC;AACF,MAAM,MAAM,yBAAyB,GAAG;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC;AAE1E,MAAM,MAAM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,EAAE,UAAU,GAAG,SAAS,CAAC;IACjC;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;;;;OAMG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,wBAAwB,CAAC;IACtC;;;;;;OAMG;IACH,SAAS,CAAC,EACP,OAAO,GACP,yBAAyB,GACzB,yBAAyB,GACzB,KAAK,CAAC;IACT;;;;;OAKG;IACH,aAAa,CAAC,EAAE,CACf,wBAAwB,EAAE,OAAO,GAAG,IAAI,KACpC,wBAAwB,CAAC;IAC9B;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC9B;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-control-styles.d.ts","sourceRoot":"","sources":["../../../src/select-control/styles/select-control-styles.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAKnD,UAAU,WACT,SAAQ,IAAI,CACX,kBAAkB,EAClB,uBAAuB,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAC7D;IAGD,UAAU,CAAC,EAAE,kBAAkB,CAAE,MAAM,CAAE,CAAC;CAC1C;AAuBD,eAAO,MAAM,eAAe;;;;wBAM3B,CAAC;AAiDF,eAAO,MAAM,eAAe,KAAK,CAAC;AAmDlC,eAAO,MAAM,MAAM;;;
|
|
1
|
+
{"version":3,"file":"select-control-styles.d.ts","sourceRoot":"","sources":["../../../src/select-control/styles/select-control-styles.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAKnD,UAAU,WACT,SAAQ,IAAI,CACX,kBAAkB,EAClB,uBAAuB,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAC7D;IAGD,UAAU,CAAC,EAAE,kBAAkB,CAAE,MAAM,CAAE,CAAC;CAC1C;AAuBD,eAAO,MAAM,eAAe;;;;wBAM3B,CAAC;AAiDF,eAAO,MAAM,eAAe,KAAK,CAAC;AAmDlC,eAAO,MAAM,MAAM;;;mIAwBlB,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;yGAO5B,CAAC;AAEF,eAAO,MAAM,yCAAyC;;;;UAOrD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/snackbar/list.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AA8B1D;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAE,EAC7B,OAAO,EACP,SAAS,EACT,QAAQ,EACR,QAAQ,GACR,EAAE,uBAAuB,CAAE,iBAAiB,EAAE,KAAK,CAAE,+
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/snackbar/list.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AA8B1D;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAE,EAC7B,OAAO,EACP,SAAS,EACT,QAAQ,EACR,QAAQ,GACR,EAAE,uBAAuB,CAAE,iBAAiB,EAAE,KAAK,CAAE,+BAkDrD;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/toggle-group-control/toggle-group-control-option-base/styles.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACX,uBAAuB,EACvB,iCAAiC,EACjC,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,SAAS;;;yGAKrB,CAAC;AAEF,eAAO,MAAM,UAAU,2CAEtB,CAAC;AAEF,eAAO,MAAM,UAAU,GAAK,8CAKzB,IAAI,CAAE,uBAAuB,EAAE,gBAAgB,GAAG,MAAM,CAAE,GAC5D,IAAI,CAAE,iCAAiC,EAAE,QAAQ,CAAE,GAAG;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB,
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/toggle-group-control/toggle-group-control-option-base/styles.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACX,uBAAuB,EACvB,iCAAiC,EACjC,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,SAAS;;;yGAKrB,CAAC;AAEF,eAAO,MAAM,UAAU,2CAEtB,CAAC;AAEF,eAAO,MAAM,UAAU,GAAK,8CAKzB,IAAI,CAAE,uBAAuB,EAAE,gBAAgB,GAAG,MAAM,CAAE,GAC5D,IAAI,CAAE,iCAAiC,EAAE,QAAQ,CAAE,GAAG;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB,8CA4CD,CAAC;AAoBF,eAAO,MAAM,iBAAiB;;;yGAI7B,CAAC"}
|
|
@@ -23,7 +23,7 @@ export declare function useToolsPanel(props: WordPressComponentProps<ToolsPanelP
|
|
|
23
23
|
toggleItem: (label: string) => void;
|
|
24
24
|
className: string;
|
|
25
25
|
children: import("react").ReactNode;
|
|
26
|
-
dropdownMenuProps?: React.ComponentProps<typeof import("../..").DropdownMenu>;
|
|
26
|
+
dropdownMenuProps?: Omit<React.ComponentProps<typeof import("../..").DropdownMenu>, "label">;
|
|
27
27
|
label: string;
|
|
28
28
|
defaultValue?: string | number | readonly string[] | undefined;
|
|
29
29
|
onChange?: import("react").FormEventHandler<HTMLDivElement> | undefined;
|
|
@@ -17,7 +17,7 @@ export type ToolsPanelProps = {
|
|
|
17
17
|
/**
|
|
18
18
|
* The dropdown menu props to configure the panel's `DropdownMenu`.
|
|
19
19
|
*/
|
|
20
|
-
dropdownMenuProps?: React.ComponentProps<typeof DropdownMenu>;
|
|
20
|
+
dropdownMenuProps?: Omit<React.ComponentProps<typeof DropdownMenu>, 'label'>;
|
|
21
21
|
/**
|
|
22
22
|
* Flags that the items in this ToolsPanel will be contained within an inner
|
|
23
23
|
* wrapper element allowing the panel to lay them out accordingly.
|
|
@@ -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;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,MAAM,cAAc,GAAG,CAAE,UAAU,CAAC,EAAE,GAAG,KAAM,GAAG,CAAC;AACzD,KAAK,QAAQ,GAAG,CAAE,OAAO,CAAC,EAAE,cAAc,EAAE,KAAM,IAAI,CAAC;AAEvD,MAAM,MAAM,eAAe,GAAG;IAC7B;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,cAAc,CAAE,OAAO,YAAY,CAAE,CAAC;
|
|
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;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,MAAM,cAAc,GAAG,CAAE,UAAU,CAAC,EAAE,GAAG,KAAM,GAAG,CAAC;AACzD,KAAK,QAAQ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M,CAAC;IAC3B,mCAAmC,CAAC,EAAE,MAAM,CAAC;IAC7C,kCAAkC,CAAC,EAAE,MAAM,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IAC1C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,CAAE,MAAM,EAAE,OAAO,CAAE,EAAE,CAAC;IAC7B,UAAU,EAAE,CAAE,KAAK,EAAE,MAAM,KAAM,IAAI,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACvC,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,CAAC,EAAE,mBAAmB,CAAC;IACvC,aAAa,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/components",
|
|
3
|
-
"version": "32.
|
|
3
|
+
"version": "32.3.0",
|
|
4
4
|
"description": "UI components for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -64,24 +64,24 @@
|
|
|
64
64
|
"@types/highlight-words-core": "1.2.1",
|
|
65
65
|
"@types/react": "^18.3.27",
|
|
66
66
|
"@use-gesture/react": "^10.3.1",
|
|
67
|
-
"@wordpress/a11y": "^4.
|
|
68
|
-
"@wordpress/base-styles": "^6.
|
|
69
|
-
"@wordpress/compose": "^7.
|
|
70
|
-
"@wordpress/date": "^5.
|
|
71
|
-
"@wordpress/deprecated": "^4.
|
|
72
|
-
"@wordpress/dom": "^4.
|
|
73
|
-
"@wordpress/element": "^6.
|
|
74
|
-
"@wordpress/escape-html": "^3.
|
|
75
|
-
"@wordpress/hooks": "^4.
|
|
76
|
-
"@wordpress/html-entities": "^4.
|
|
77
|
-
"@wordpress/i18n": "^6.
|
|
78
|
-
"@wordpress/icons": "^11.
|
|
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/warning": "^3.
|
|
67
|
+
"@wordpress/a11y": "^4.41.0",
|
|
68
|
+
"@wordpress/base-styles": "^6.17.0",
|
|
69
|
+
"@wordpress/compose": "^7.41.0",
|
|
70
|
+
"@wordpress/date": "^5.41.0",
|
|
71
|
+
"@wordpress/deprecated": "^4.41.0",
|
|
72
|
+
"@wordpress/dom": "^4.41.0",
|
|
73
|
+
"@wordpress/element": "^6.41.0",
|
|
74
|
+
"@wordpress/escape-html": "^3.41.0",
|
|
75
|
+
"@wordpress/hooks": "^4.41.0",
|
|
76
|
+
"@wordpress/html-entities": "^4.41.0",
|
|
77
|
+
"@wordpress/i18n": "^6.14.0",
|
|
78
|
+
"@wordpress/icons": "^11.8.0",
|
|
79
|
+
"@wordpress/is-shallow-equal": "^5.41.0",
|
|
80
|
+
"@wordpress/keycodes": "^4.41.0",
|
|
81
|
+
"@wordpress/primitives": "^4.41.0",
|
|
82
|
+
"@wordpress/private-apis": "^1.41.0",
|
|
83
|
+
"@wordpress/rich-text": "^7.41.0",
|
|
84
|
+
"@wordpress/warning": "^3.41.0",
|
|
85
85
|
"change-case": "^4.1.2",
|
|
86
86
|
"clsx": "^2.1.1",
|
|
87
87
|
"colord": "^2.7.0",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"@storybook/react-vite": "^10.1.11",
|
|
108
108
|
"@testing-library/jest-dom": "^6.9.1",
|
|
109
109
|
"@types/jest": "^29.5.14",
|
|
110
|
-
"@wordpress/jest-console": "^8.
|
|
110
|
+
"@wordpress/jest-console": "^8.41.0",
|
|
111
111
|
"snapshot-diff": "^0.10.0",
|
|
112
112
|
"storybook": "^10.1.11",
|
|
113
113
|
"timezone-mock": "^1.3.6"
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"publishConfig": {
|
|
120
120
|
"access": "public"
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "8bfc179b9aed74c0a6dd6e8edf7a49e40e4f87cc"
|
|
123
123
|
}
|
package/src/button/style.scss
CHANGED
|
@@ -9,17 +9,36 @@ import type { ColorInputProps } from './types';
|
|
|
9
9
|
export const ColorInput = ( {
|
|
10
10
|
colorType,
|
|
11
11
|
color,
|
|
12
|
+
hsla,
|
|
12
13
|
onChange,
|
|
14
|
+
onHSLChange,
|
|
13
15
|
enableAlpha,
|
|
14
16
|
}: ColorInputProps ) => {
|
|
15
|
-
const props = { color, onChange, enableAlpha };
|
|
16
17
|
switch ( colorType ) {
|
|
17
18
|
case 'hsl':
|
|
18
|
-
return
|
|
19
|
+
return (
|
|
20
|
+
<HslInput
|
|
21
|
+
hsla={ hsla }
|
|
22
|
+
onChange={ onHSLChange }
|
|
23
|
+
enableAlpha={ enableAlpha }
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
19
26
|
case 'rgb':
|
|
20
|
-
return
|
|
27
|
+
return (
|
|
28
|
+
<RgbInput
|
|
29
|
+
color={ color }
|
|
30
|
+
onChange={ onChange }
|
|
31
|
+
enableAlpha={ enableAlpha }
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
21
34
|
default:
|
|
22
35
|
case 'hex':
|
|
23
|
-
return
|
|
36
|
+
return (
|
|
37
|
+
<HexInput
|
|
38
|
+
color={ color }
|
|
39
|
+
onChange={ onChange }
|
|
40
|
+
enableAlpha={ enableAlpha }
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
24
43
|
}
|
|
25
44
|
};
|
|
@@ -4,12 +4,19 @@
|
|
|
4
4
|
import type { ClipboardEvent, ForwardedRef } from 'react';
|
|
5
5
|
import type { Colord } from 'colord';
|
|
6
6
|
import { colord, extend, getFormat } from 'colord';
|
|
7
|
+
import type { HslaColor } from 'react-colorful';
|
|
7
8
|
import namesPlugin from 'colord/plugins/names';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* WordPress dependencies
|
|
11
12
|
*/
|
|
12
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
useCallback,
|
|
15
|
+
useEffect,
|
|
16
|
+
useRef,
|
|
17
|
+
useState,
|
|
18
|
+
useMemo,
|
|
19
|
+
} from '@wordpress/element';
|
|
13
20
|
import { useDebounce } from '@wordpress/compose';
|
|
14
21
|
import { __ } from '@wordpress/i18n';
|
|
15
22
|
|
|
@@ -33,6 +40,21 @@ import type { ColorPickerProps, ColorType } from './types';
|
|
|
33
40
|
|
|
34
41
|
extend( [ namesPlugin ] );
|
|
35
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Merges incoming HSLA with previous state, preserving hue for achromatic
|
|
45
|
+
* colors and saturation only at lightness extremes (black/white) where
|
|
46
|
+
* it has no visual effect.
|
|
47
|
+
*/
|
|
48
|
+
function mergeHSLA( nextHSLA: HslaColor, prevHSLA: HslaColor ): HslaColor {
|
|
49
|
+
if ( nextHSLA.s === 0 ) {
|
|
50
|
+
if ( nextHSLA.l === 0 || nextHSLA.l === 100 ) {
|
|
51
|
+
return { ...nextHSLA, h: prevHSLA.h, s: prevHSLA.s };
|
|
52
|
+
}
|
|
53
|
+
return { ...nextHSLA, h: prevHSLA.h };
|
|
54
|
+
}
|
|
55
|
+
return nextHSLA;
|
|
56
|
+
}
|
|
57
|
+
|
|
36
58
|
const options = [
|
|
37
59
|
{ label: 'RGB', value: 'rgb' as const },
|
|
38
60
|
{ label: 'HSL', value: 'hsl' as const },
|
|
@@ -65,9 +87,69 @@ const UnconnectedColorPicker = (
|
|
|
65
87
|
|
|
66
88
|
const debouncedSetColor = useDebounce( setColor );
|
|
67
89
|
|
|
90
|
+
// Internal HSLA state preserves hue and saturation values that
|
|
91
|
+
// would otherwise be lost when converting to/from hex at achromatic
|
|
92
|
+
// colors (e.g. pure black or white where any H/S maps to the same hex).
|
|
93
|
+
const [ internalHSLA, setInternalHSLA ] = useState< HslaColor >( () => ( {
|
|
94
|
+
...safeColordColor.toHsl(),
|
|
95
|
+
} ) );
|
|
96
|
+
|
|
97
|
+
// Track the last hex we produced so the sync effect can
|
|
98
|
+
// distinguish our own updates from external prop changes.
|
|
99
|
+
const lastProducedHexRef = useRef( safeColordColor.toHex() );
|
|
100
|
+
|
|
101
|
+
// Sync internalHSLA when the color prop changes externally (e.g.
|
|
102
|
+
// parent passes a new color that wasn't produced by our onChange).
|
|
103
|
+
useEffect( () => {
|
|
104
|
+
const incomingHex = safeColordColor.toHex();
|
|
105
|
+
|
|
106
|
+
// If this hex matches what we last produced, it's our own
|
|
107
|
+
// update arriving back — skip the sync to avoid overwriting
|
|
108
|
+
// internalHSLA with lossy round-tripped values.
|
|
109
|
+
if ( incomingHex === lastProducedHexRef.current ) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Genuinely external change — sync internalHSLA.
|
|
114
|
+
lastProducedHexRef.current = incomingHex;
|
|
115
|
+
const externalHSLA = safeColordColor.toHsl();
|
|
116
|
+
setInternalHSLA( ( prev ) => mergeHSLA( externalHSLA, prev ) );
|
|
117
|
+
}, [ safeColordColor ] );
|
|
118
|
+
|
|
119
|
+
// Handler for HSL-aware components (Picker, HSL inputs) that
|
|
120
|
+
// provide raw HSLA values without information loss.
|
|
121
|
+
// Uses direct setColor (not debounced) to prevent race conditions
|
|
122
|
+
// where a stale debounced hex would overwrite newer internalHSLA.
|
|
123
|
+
// This is safe performance-wise because react-colorful internally
|
|
124
|
+
// throttles its onChange callbacks using requestAnimationFrame.
|
|
125
|
+
|
|
126
|
+
const handleHSLAChange = useCallback(
|
|
127
|
+
( nextHSLA: HslaColor ) => {
|
|
128
|
+
// No mergeHSLA here — this handler receives the user's explicit
|
|
129
|
+
// choice from the picker or HSL inputs, with no lossy conversion.
|
|
130
|
+
setInternalHSLA( nextHSLA );
|
|
131
|
+
const previousHex = lastProducedHexRef.current;
|
|
132
|
+
const nextHex = colord( nextHSLA ).toHex();
|
|
133
|
+
// Only notify parent when the hex actually changes. This
|
|
134
|
+
// avoids firing onChange for H/S changes on achromatic
|
|
135
|
+
// colors (e.g. adjusting hue on pure white).
|
|
136
|
+
if ( nextHex !== previousHex ) {
|
|
137
|
+
lastProducedHexRef.current = nextHex;
|
|
138
|
+
setColor( nextHex );
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
[ setColor ]
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
// Handler for components that provide Colord values (RGB, Hex inputs).
|
|
145
|
+
// Uses debouncedSetColor since the hex input fires per keystroke.
|
|
68
146
|
const handleChange = useCallback(
|
|
69
147
|
( nextValue: Colord ) => {
|
|
70
|
-
|
|
148
|
+
const nextHSLA = nextValue.toHsl();
|
|
149
|
+
setInternalHSLA( ( prev ) => mergeHSLA( nextHSLA, prev ) );
|
|
150
|
+
const nextHex = nextValue.toHex();
|
|
151
|
+
lastProducedHexRef.current = nextHex;
|
|
152
|
+
debouncedSetColor( nextHex );
|
|
71
153
|
},
|
|
72
154
|
[ debouncedSetColor ]
|
|
73
155
|
);
|
|
@@ -128,8 +210,8 @@ const UnconnectedColorPicker = (
|
|
|
128
210
|
onPasteCapture={ maybeHandlePaste }
|
|
129
211
|
>
|
|
130
212
|
<Picker
|
|
131
|
-
onChange={
|
|
132
|
-
|
|
213
|
+
onChange={ handleHSLAChange }
|
|
214
|
+
hsla={ internalHSLA }
|
|
133
215
|
enableAlpha={ enableAlpha }
|
|
134
216
|
/>
|
|
135
217
|
<AuxiliaryColorArtefactWrapper>
|
|
@@ -154,7 +236,9 @@ const UnconnectedColorPicker = (
|
|
|
154
236
|
<ColorInput
|
|
155
237
|
colorType={ colorType }
|
|
156
238
|
color={ safeColordColor }
|
|
239
|
+
hsla={ internalHSLA }
|
|
157
240
|
onChange={ handleChange }
|
|
241
|
+
onHSLChange={ handleHSLAChange }
|
|
158
242
|
enableAlpha={ enableAlpha }
|
|
159
243
|
/>
|
|
160
244
|
</ColorInputWrapper>
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { useState, useEffect, useMemo } from '@wordpress/element';
|
|
4
|
+
import type { HslaColor } from 'react-colorful';
|
|
10
5
|
|
|
11
6
|
/**
|
|
12
7
|
* Internal dependencies
|
|
@@ -14,49 +9,12 @@ import { useState, useEffect, useMemo } from '@wordpress/element';
|
|
|
14
9
|
import { InputWithSlider } from './input-with-slider';
|
|
15
10
|
import type { HslInputProps } from './types';
|
|
16
11
|
|
|
17
|
-
export const HslInput = ( {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const isInternalColorSameAsReceivedColor = color.isEqual(
|
|
23
|
-
colord( internalHSLA )
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
useEffect( () => {
|
|
27
|
-
if ( ! isInternalColorSameAsReceivedColor ) {
|
|
28
|
-
// Keep internal HSLA color up to date with the received color prop
|
|
29
|
-
setInternalHSLA( colorPropHSLA );
|
|
30
|
-
}
|
|
31
|
-
}, [ colorPropHSLA, isInternalColorSameAsReceivedColor ] );
|
|
32
|
-
|
|
33
|
-
// If the internal color is equal to the received color prop, we can use the
|
|
34
|
-
// HSLA values from the local state which, compared to the received color prop,
|
|
35
|
-
// retain more details about the actual H and S values that the user selected,
|
|
36
|
-
// and thus allow for better UX when interacting with the H and S sliders.
|
|
37
|
-
const colorValue = isInternalColorSameAsReceivedColor
|
|
38
|
-
? internalHSLA
|
|
39
|
-
: colorPropHSLA;
|
|
40
|
-
|
|
41
|
-
const updateHSLAValue = (
|
|
42
|
-
partialNewValue: Partial< typeof colorPropHSLA >
|
|
43
|
-
) => {
|
|
44
|
-
const nextOnChangeValue = colord( {
|
|
45
|
-
...colorValue,
|
|
12
|
+
export const HslInput = ( { hsla, onChange, enableAlpha }: HslInputProps ) => {
|
|
13
|
+
const updateHSLAValue = ( partialNewValue: Partial< HslaColor > ) => {
|
|
14
|
+
onChange( {
|
|
15
|
+
...hsla,
|
|
46
16
|
...partialNewValue,
|
|
47
17
|
} );
|
|
48
|
-
|
|
49
|
-
// Fire `onChange` only if the resulting color is different from the
|
|
50
|
-
// current one.
|
|
51
|
-
// Otherwise, update the internal HSLA color to cause a re-render.
|
|
52
|
-
if ( ! color.isEqual( nextOnChangeValue ) ) {
|
|
53
|
-
onChange( nextOnChangeValue );
|
|
54
|
-
} else {
|
|
55
|
-
setInternalHSLA( ( prevHSLA ) => ( {
|
|
56
|
-
...prevHSLA,
|
|
57
|
-
...partialNewValue,
|
|
58
|
-
} ) );
|
|
59
|
-
}
|
|
60
18
|
};
|
|
61
19
|
|
|
62
20
|
return (
|
|
@@ -66,7 +24,7 @@ export const HslInput = ( { color, onChange, enableAlpha }: HslInputProps ) => {
|
|
|
66
24
|
max={ 359 }
|
|
67
25
|
label="Hue"
|
|
68
26
|
abbreviation="H"
|
|
69
|
-
value={
|
|
27
|
+
value={ hsla.h }
|
|
70
28
|
onChange={ ( nextH: number ) => {
|
|
71
29
|
updateHSLAValue( { h: nextH } );
|
|
72
30
|
} }
|
|
@@ -76,7 +34,7 @@ export const HslInput = ( { color, onChange, enableAlpha }: HslInputProps ) => {
|
|
|
76
34
|
max={ 100 }
|
|
77
35
|
label="Saturation"
|
|
78
36
|
abbreviation="S"
|
|
79
|
-
value={
|
|
37
|
+
value={ hsla.s }
|
|
80
38
|
onChange={ ( nextS: number ) => {
|
|
81
39
|
updateHSLAValue( { s: nextS } );
|
|
82
40
|
} }
|
|
@@ -86,7 +44,7 @@ export const HslInput = ( { color, onChange, enableAlpha }: HslInputProps ) => {
|
|
|
86
44
|
max={ 100 }
|
|
87
45
|
label="Lightness"
|
|
88
46
|
abbreviation="L"
|
|
89
|
-
value={
|
|
47
|
+
value={ hsla.l }
|
|
90
48
|
onChange={ ( nextL: number ) => {
|
|
91
49
|
updateHSLAValue( { l: nextL } );
|
|
92
50
|
} }
|
|
@@ -97,7 +55,7 @@ export const HslInput = ( { color, onChange, enableAlpha }: HslInputProps ) => {
|
|
|
97
55
|
max={ 100 }
|
|
98
56
|
label="Alpha"
|
|
99
57
|
abbreviation="A"
|
|
100
|
-
value={ Math.trunc( 100 *
|
|
58
|
+
value={ Math.trunc( 100 * hsla.a ) }
|
|
101
59
|
onChange={ ( nextA: number ) => {
|
|
102
60
|
updateHSLAValue( { a: nextA / 100 } );
|
|
103
61
|
} }
|
|
@@ -1,40 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import { colord } from 'colord';
|
|
4
|
+
import { HslColorPicker, HslaColorPicker } from 'react-colorful';
|
|
6
5
|
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { useMemo } from '@wordpress/element';
|
|
11
6
|
/**
|
|
12
7
|
* Internal dependencies
|
|
13
8
|
*/
|
|
14
9
|
import type { PickerProps } from './types';
|
|
15
10
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
// Pointer capture fortifies drag gestures so that they continue to work
|
|
12
|
+
// while dragging outside the component over objects like iframes. If a
|
|
13
|
+
// newer version of react-colorful begins to employ pointer capture this
|
|
14
|
+
// will be redundant and should be removed.
|
|
15
|
+
const pointerCaptureProps = {
|
|
16
|
+
onPointerDown( { currentTarget, pointerId }: React.PointerEvent ) {
|
|
17
|
+
currentTarget.setPointerCapture( pointerId );
|
|
18
|
+
},
|
|
19
|
+
onPointerUp( { currentTarget, pointerId }: React.PointerEvent ) {
|
|
20
|
+
currentTarget.releasePointerCapture( pointerId );
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const Picker = ( { hsla, enableAlpha, onChange }: PickerProps ) => {
|
|
25
|
+
if ( enableAlpha ) {
|
|
26
|
+
return (
|
|
27
|
+
<HslaColorPicker
|
|
28
|
+
color={ hsla }
|
|
29
|
+
onChange={ onChange }
|
|
30
|
+
{ ...pointerCaptureProps }
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
21
34
|
|
|
22
35
|
return (
|
|
23
|
-
<
|
|
24
|
-
color={
|
|
36
|
+
<HslColorPicker
|
|
37
|
+
color={ hsla }
|
|
25
38
|
onChange={ ( nextColor ) => {
|
|
26
|
-
onChange(
|
|
27
|
-
} }
|
|
28
|
-
// Pointer capture fortifies drag gestures so that they continue to
|
|
29
|
-
// work while dragging outside the component over objects like
|
|
30
|
-
// iframes. If a newer version of react-colorful begins to employ
|
|
31
|
-
// pointer capture this will be redundant and should be removed.
|
|
32
|
-
onPointerDown={ ( { currentTarget, pointerId } ) => {
|
|
33
|
-
currentTarget.setPointerCapture( pointerId );
|
|
34
|
-
} }
|
|
35
|
-
onPointerUp={ ( { currentTarget, pointerId } ) => {
|
|
36
|
-
currentTarget.releasePointerCapture( pointerId );
|
|
39
|
+
onChange( { ...nextColor, a: hsla.a } );
|
|
37
40
|
} }
|
|
41
|
+
{ ...pointerCaptureProps }
|
|
38
42
|
/>
|
|
39
43
|
);
|
|
40
44
|
};
|