@wordpress/components 28.1.0 → 28.2.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 +131 -120
- package/build/custom-select-control-v2/custom-select.js +1 -3
- package/build/custom-select-control-v2/custom-select.js.map +1 -1
- package/build/custom-select-control-v2/legacy-component/index.js +16 -10
- package/build/custom-select-control-v2/legacy-component/index.js.map +1 -1
- package/build/custom-select-control-v2/styles.js +34 -19
- package/build/custom-select-control-v2/styles.js.map +1 -1
- package/build/custom-select-control-v2/types.js.map +1 -1
- package/build/drop-zone/index.js +16 -79
- package/build/drop-zone/index.js.map +1 -1
- package/build/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/palette-edit/index.js +30 -38
- package/build/palette-edit/index.js.map +1 -1
- package/build/palette-edit/types.js.map +1 -1
- package/build-module/custom-select-control-v2/custom-select.js +1 -3
- package/build-module/custom-select-control-v2/custom-select.js.map +1 -1
- package/build-module/custom-select-control-v2/legacy-component/index.js +16 -11
- package/build-module/custom-select-control-v2/legacy-component/index.js.map +1 -1
- package/build-module/custom-select-control-v2/styles.js +33 -18
- package/build-module/custom-select-control-v2/styles.js.map +1 -1
- package/build-module/custom-select-control-v2/types.js.map +1 -1
- package/build-module/drop-zone/index.js +17 -80
- package/build-module/drop-zone/index.js.map +1 -1
- package/build-module/lock-unlock.js +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/palette-edit/index.js +31 -39
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/palette-edit/types.js.map +1 -1
- package/build-style/style-rtl.css +28 -6
- package/build-style/style.css +28 -6
- package/build-types/custom-select-control/stories/index.story.d.ts +15 -0
- package/build-types/custom-select-control/stories/index.story.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/legacy-component/index.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/styles.d.ts +4 -0
- package/build-types/custom-select-control-v2/styles.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/types.d.ts +1 -0
- package/build-types/custom-select-control-v2/types.d.ts.map +1 -1
- package/build-types/drop-zone/index.d.ts +3 -0
- package/build-types/drop-zone/index.d.ts.map +1 -1
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/palette-edit/types.d.ts +1 -3
- package/build-types/palette-edit/types.d.ts.map +1 -1
- package/package.json +19 -19
- package/src/custom-select-control/stories/index.story.tsx +32 -3
- package/src/custom-select-control/test/index.js +205 -22
- package/src/custom-select-control-v2/custom-select.tsx +1 -1
- package/src/custom-select-control-v2/legacy-component/index.tsx +18 -10
- package/src/custom-select-control-v2/legacy-component/test/index.tsx +220 -38
- package/src/custom-select-control-v2/styles.ts +22 -10
- package/src/custom-select-control-v2/types.ts +1 -0
- package/src/drop-zone/index.tsx +17 -76
- package/src/drop-zone/style.scss +51 -16
- package/src/lock-unlock.js +1 -1
- package/src/palette-edit/index.tsx +33 -45
- package/src/palette-edit/test/index.tsx +2 -4
- package/src/palette-edit/types.ts +1 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -10,88 +10,13 @@ import { __ } from '@wordpress/i18n';
|
|
|
10
10
|
import { useState } from '@wordpress/element';
|
|
11
11
|
import { upload, Icon } from '@wordpress/icons';
|
|
12
12
|
import { getFilesFromDataTransfer } from '@wordpress/dom';
|
|
13
|
-
import { __experimentalUseDropZone as useDropZone
|
|
13
|
+
import { __experimentalUseDropZone as useDropZone } from '@wordpress/compose';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Internal dependencies
|
|
17
17
|
*/
|
|
18
|
-
import { __unstableMotion as motion, __unstableAnimatePresence as AnimatePresence } from '../animation';
|
|
19
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
19
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
-
const backdrop = {
|
|
22
|
-
hidden: {
|
|
23
|
-
opacity: 0
|
|
24
|
-
},
|
|
25
|
-
show: {
|
|
26
|
-
opacity: 1,
|
|
27
|
-
transition: {
|
|
28
|
-
type: 'tween',
|
|
29
|
-
duration: 0.2,
|
|
30
|
-
delay: 0,
|
|
31
|
-
delayChildren: 0.1
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
exit: {
|
|
35
|
-
opacity: 0,
|
|
36
|
-
transition: {
|
|
37
|
-
duration: 0.2,
|
|
38
|
-
delayChildren: 0
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const foreground = {
|
|
43
|
-
hidden: {
|
|
44
|
-
opacity: 0,
|
|
45
|
-
scale: 0.9
|
|
46
|
-
},
|
|
47
|
-
show: {
|
|
48
|
-
opacity: 1,
|
|
49
|
-
scale: 1,
|
|
50
|
-
transition: {
|
|
51
|
-
duration: 0.1
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
exit: {
|
|
55
|
-
opacity: 0,
|
|
56
|
-
scale: 0.9
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
function DropIndicator({
|
|
60
|
-
label
|
|
61
|
-
}) {
|
|
62
|
-
const disableMotion = useReducedMotion();
|
|
63
|
-
const children = /*#__PURE__*/_jsx(motion.div, {
|
|
64
|
-
variants: backdrop,
|
|
65
|
-
initial: disableMotion ? 'show' : 'hidden',
|
|
66
|
-
animate: "show",
|
|
67
|
-
exit: disableMotion ? 'show' : 'exit',
|
|
68
|
-
className: "components-drop-zone__content"
|
|
69
|
-
// Without this, when this div is shown,
|
|
70
|
-
// Safari calls a onDropZoneLeave causing a loop because of this bug
|
|
71
|
-
// https://bugs.webkit.org/show_bug.cgi?id=66547
|
|
72
|
-
,
|
|
73
|
-
style: {
|
|
74
|
-
pointerEvents: 'none'
|
|
75
|
-
},
|
|
76
|
-
children: /*#__PURE__*/_jsxs(motion.div, {
|
|
77
|
-
variants: foreground,
|
|
78
|
-
children: [/*#__PURE__*/_jsx(Icon, {
|
|
79
|
-
icon: upload,
|
|
80
|
-
className: "components-drop-zone__content-icon"
|
|
81
|
-
}), /*#__PURE__*/_jsx("span", {
|
|
82
|
-
className: "components-drop-zone__content-text",
|
|
83
|
-
children: label ? label : __('Drop files to upload')
|
|
84
|
-
})]
|
|
85
|
-
})
|
|
86
|
-
});
|
|
87
|
-
if (disableMotion) {
|
|
88
|
-
return children;
|
|
89
|
-
}
|
|
90
|
-
return /*#__PURE__*/_jsx(AnimatePresence, {
|
|
91
|
-
children: children
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
20
|
/**
|
|
96
21
|
* `DropZone` is a component creating a drop zone area taking the full size of its parent element. It supports dropping files, HTML content or any other HTML drop event.
|
|
97
22
|
*
|
|
@@ -133,7 +58,7 @@ export function DropZoneComponent({
|
|
|
133
58
|
|
|
134
59
|
/**
|
|
135
60
|
* From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.
|
|
136
|
-
* The order of the checks is important to
|
|
61
|
+
* The order of the checks is important to recognize the HTML drop.
|
|
137
62
|
*/
|
|
138
63
|
if (html && onHTMLDrop) {
|
|
139
64
|
onHTMLDrop(html);
|
|
@@ -149,7 +74,7 @@ export function DropZoneComponent({
|
|
|
149
74
|
|
|
150
75
|
/**
|
|
151
76
|
* From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.
|
|
152
|
-
* The order of the checks is important to
|
|
77
|
+
* The order of the checks is important to recognize the HTML drop.
|
|
153
78
|
*/
|
|
154
79
|
if (event.dataTransfer?.types.includes('text/html')) {
|
|
155
80
|
_type = 'html';
|
|
@@ -174,6 +99,8 @@ export function DropZoneComponent({
|
|
|
174
99
|
});
|
|
175
100
|
const classes = clsx('components-drop-zone', className, {
|
|
176
101
|
'is-active': (isDraggingOverDocument || isDraggingOverElement) && (type === 'file' && onFilesDrop || type === 'html' && onHTMLDrop || type === 'default' && onDrop),
|
|
102
|
+
'has-dragged-out': !isDraggingOverElement,
|
|
103
|
+
// Keeping the following classnames for legacy purposes
|
|
177
104
|
'is-dragging-over-document': isDraggingOverDocument,
|
|
178
105
|
'is-dragging-over-element': isDraggingOverElement,
|
|
179
106
|
[`is-dragging-${type}`]: !!type
|
|
@@ -182,8 +109,18 @@ export function DropZoneComponent({
|
|
|
182
109
|
...restProps,
|
|
183
110
|
ref: ref,
|
|
184
111
|
className: classes,
|
|
185
|
-
children:
|
|
186
|
-
|
|
112
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
113
|
+
className: "components-drop-zone__content",
|
|
114
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
115
|
+
className: "components-drop-zone__content-inner",
|
|
116
|
+
children: [/*#__PURE__*/_jsx(Icon, {
|
|
117
|
+
icon: upload,
|
|
118
|
+
className: "components-drop-zone__content-icon"
|
|
119
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
120
|
+
className: "components-drop-zone__content-text",
|
|
121
|
+
children: label ? label : __('Drop files to upload')
|
|
122
|
+
})]
|
|
123
|
+
})
|
|
187
124
|
})
|
|
188
125
|
});
|
|
189
126
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","__","useState","upload","Icon","getFilesFromDataTransfer","__experimentalUseDropZone","useDropZone","useReducedMotion","__unstableMotion","motion","__unstableAnimatePresence","AnimatePresence","jsx","_jsx","jsxs","_jsxs","backdrop","hidden","opacity","show","transition","type","duration","delay","delayChildren","exit","foreground","scale","DropIndicator","label","disableMotion","children","div","variants","initial","animate","className","style","pointerEvents","icon","DropZoneComponent","onFilesDrop","onHTMLDrop","onDrop","restProps","isDraggingOverDocument","setIsDraggingOverDocument","isDraggingOverElement","setIsDraggingOverElement","setType","ref","event","files","dataTransfer","html","getData","length","onDragStart","_type","types","includes","onDragEnd","undefined","onDragEnter","onDragLeave","classes"],"sources":["@wordpress/components/src/drop-zone/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { upload, Icon } from '@wordpress/icons';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\nimport {\n\t__experimentalUseDropZone as useDropZone,\n\tuseReducedMotion,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '../animation';\nimport type { DropType, DropZoneProps } from './types';\nimport type { WordPressComponentProps } from '../context';\n\nconst backdrop = {\n\thidden: { opacity: 0 },\n\tshow: {\n\t\topacity: 1,\n\t\ttransition: {\n\t\t\ttype: 'tween',\n\t\t\tduration: 0.2,\n\t\t\tdelay: 0,\n\t\t\tdelayChildren: 0.1,\n\t\t},\n\t},\n\texit: {\n\t\topacity: 0,\n\t\ttransition: {\n\t\t\tduration: 0.2,\n\t\t\tdelayChildren: 0,\n\t\t},\n\t},\n};\n\nconst foreground = {\n\thidden: { opacity: 0, scale: 0.9 },\n\tshow: {\n\t\topacity: 1,\n\t\tscale: 1,\n\t\ttransition: {\n\t\t\tduration: 0.1,\n\t\t},\n\t},\n\texit: { opacity: 0, scale: 0.9 },\n};\n\nfunction DropIndicator( { label }: { label?: string } ) {\n\tconst disableMotion = useReducedMotion();\n\tconst children = (\n\t\t<motion.div\n\t\t\tvariants={ backdrop }\n\t\t\tinitial={ disableMotion ? 'show' : 'hidden' }\n\t\t\tanimate=\"show\"\n\t\t\texit={ disableMotion ? 'show' : 'exit' }\n\t\t\tclassName=\"components-drop-zone__content\"\n\t\t\t// Without this, when this div is shown,\n\t\t\t// Safari calls a onDropZoneLeave causing a loop because of this bug\n\t\t\t// https://bugs.webkit.org/show_bug.cgi?id=66547\n\t\t\tstyle={ { pointerEvents: 'none' } }\n\t\t>\n\t\t\t<motion.div variants={ foreground }>\n\t\t\t\t<Icon\n\t\t\t\t\ticon={ upload }\n\t\t\t\t\tclassName=\"components-drop-zone__content-icon\"\n\t\t\t\t/>\n\t\t\t\t<span className=\"components-drop-zone__content-text\">\n\t\t\t\t\t{ label ? label : __( 'Drop files to upload' ) }\n\t\t\t\t</span>\n\t\t\t</motion.div>\n\t\t</motion.div>\n\t);\n\n\tif ( disableMotion ) {\n\t\treturn children;\n\t}\n\n\treturn <AnimatePresence>{ children }</AnimatePresence>;\n}\n\n/**\n * `DropZone` is a component creating a drop zone area taking the full size of its parent element. It supports dropping files, HTML content or any other HTML drop event.\n *\n * ```jsx\n * import { DropZone } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyDropZone = () => {\n * const [ hasDropped, setHasDropped ] = useState( false );\n *\n * return (\n * <div>\n * { hasDropped ? 'Dropped!' : 'Drop something here' }\n * <DropZone\n * onFilesDrop={ () => setHasDropped( true ) }\n * onHTMLDrop={ () => setHasDropped( true ) }\n * onDrop={ () => setHasDropped( true ) }\n * />\n * </div>\n * );\n * }\n * ```\n */\nexport function DropZoneComponent( {\n\tclassName,\n\tlabel,\n\tonFilesDrop,\n\tonHTMLDrop,\n\tonDrop,\n\t...restProps\n}: WordPressComponentProps< DropZoneProps, 'div', false > ) {\n\tconst [ isDraggingOverDocument, setIsDraggingOverDocument ] =\n\t\tuseState< boolean >();\n\tconst [ isDraggingOverElement, setIsDraggingOverElement ] =\n\t\tuseState< boolean >();\n\tconst [ type, setType ] = useState< DropType >();\n\tconst ref = useDropZone( {\n\t\tonDrop( event ) {\n\t\t\tconst files = event.dataTransfer\n\t\t\t\t? getFilesFromDataTransfer( event.dataTransfer )\n\t\t\t\t: [];\n\t\t\tconst html = event.dataTransfer?.getData( 'text/html' );\n\n\t\t\t/**\n\t\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t\t */\n\t\t\tif ( html && onHTMLDrop ) {\n\t\t\t\tonHTMLDrop( html );\n\t\t\t} else if ( files.length && onFilesDrop ) {\n\t\t\t\tonFilesDrop( files );\n\t\t\t} else if ( onDrop ) {\n\t\t\t\tonDrop( event );\n\t\t\t}\n\t\t},\n\t\tonDragStart( event ) {\n\t\t\tsetIsDraggingOverDocument( true );\n\n\t\t\tlet _type: DropType = 'default';\n\n\t\t\t/**\n\t\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t\t */\n\t\t\tif ( event.dataTransfer?.types.includes( 'text/html' ) ) {\n\t\t\t\t_type = 'html';\n\t\t\t} else if (\n\t\t\t\t// Check for the types because sometimes the files themselves\n\t\t\t\t// are only available on drop.\n\t\t\t\tevent.dataTransfer?.types.includes( 'Files' ) ||\n\t\t\t\t( event.dataTransfer\n\t\t\t\t\t? getFilesFromDataTransfer( event.dataTransfer )\n\t\t\t\t\t: []\n\t\t\t\t).length > 0\n\t\t\t) {\n\t\t\t\t_type = 'file';\n\t\t\t}\n\n\t\t\tsetType( _type );\n\t\t},\n\t\tonDragEnd() {\n\t\t\tsetIsDraggingOverDocument( false );\n\t\t\tsetType( undefined );\n\t\t},\n\t\tonDragEnter() {\n\t\t\tsetIsDraggingOverElement( true );\n\t\t},\n\t\tonDragLeave() {\n\t\t\tsetIsDraggingOverElement( false );\n\t\t},\n\t} );\n\tconst classes = clsx( 'components-drop-zone', className, {\n\t\t'is-active':\n\t\t\t( isDraggingOverDocument || isDraggingOverElement ) &&\n\t\t\t( ( type === 'file' && onFilesDrop ) ||\n\t\t\t\t( type === 'html' && onHTMLDrop ) ||\n\t\t\t\t( type === 'default' && onDrop ) ),\n\t\t'is-dragging-over-document': isDraggingOverDocument,\n\t\t'is-dragging-over-element': isDraggingOverElement,\n\t\t[ `is-dragging-${ type }` ]: !! type,\n\t} );\n\n\treturn (\n\t\t<div { ...restProps } ref={ ref } className={ classes }>\n\t\t\t{ isDraggingOverElement && <DropIndicator label={ label } /> }\n\t\t</div>\n\t);\n}\n\nexport default DropZoneComponent;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7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AAE;IACxD,WAAW,EACV,CAAES,sBAAsB,IAAIE,qBAAqB,MAC7C1B,IAAI,KAAK,MAAM,IAAIoB,WAAW,IAC/BpB,IAAI,KAAK,MAAM,IAAIqB,UAAY,IAC/BrB,IAAI,KAAK,SAAS,IAAIsB,MAAQ,CAAE;IACpC,2BAA2B,EAAEE,sBAAsB;IACnD,0BAA0B,EAAEE,qBAAqB;IACjD,CAAG,eAAe1B,IAAM,EAAC,GAAI,CAAC,CAAEA;EACjC,CAAE,CAAC;EAEH,oBACCR,IAAA;IAAA,GAAU+B,SAAS;IAAGM,GAAG,EAAGA,GAAK;IAACd,SAAS,EAAG6B,OAAS;IAAAlC,QAAA,EACpDgB,qBAAqB,iBAAIlC,IAAA,CAACe,aAAa;MAACC,KAAK,EAAGA;IAAO,CAAE;EAAC,CACxD,CAAC;AAER;AAEA,eAAeW,iBAAiB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","__","useState","upload","Icon","getFilesFromDataTransfer","__experimentalUseDropZone","useDropZone","jsx","_jsx","jsxs","_jsxs","DropZoneComponent","className","label","onFilesDrop","onHTMLDrop","onDrop","restProps","isDraggingOverDocument","setIsDraggingOverDocument","isDraggingOverElement","setIsDraggingOverElement","type","setType","ref","event","files","dataTransfer","html","getData","length","onDragStart","_type","types","includes","onDragEnd","undefined","onDragEnter","onDragLeave","classes","children","icon"],"sources":["@wordpress/components/src/drop-zone/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { upload, Icon } from '@wordpress/icons';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\nimport { __experimentalUseDropZone as useDropZone } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { DropType, DropZoneProps } from './types';\nimport type { WordPressComponentProps } from '../context';\n\n/**\n * `DropZone` is a component creating a drop zone area taking the full size of its parent element. It supports dropping files, HTML content or any other HTML drop event.\n *\n * ```jsx\n * import { DropZone } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyDropZone = () => {\n * const [ hasDropped, setHasDropped ] = useState( false );\n *\n * return (\n * <div>\n * { hasDropped ? 'Dropped!' : 'Drop something here' }\n * <DropZone\n * onFilesDrop={ () => setHasDropped( true ) }\n * onHTMLDrop={ () => setHasDropped( true ) }\n * onDrop={ () => setHasDropped( true ) }\n * />\n * </div>\n * );\n * }\n * ```\n */\nexport function DropZoneComponent( {\n\tclassName,\n\tlabel,\n\tonFilesDrop,\n\tonHTMLDrop,\n\tonDrop,\n\t...restProps\n}: WordPressComponentProps< DropZoneProps, 'div', false > ) {\n\tconst [ isDraggingOverDocument, setIsDraggingOverDocument ] =\n\t\tuseState< boolean >();\n\tconst [ isDraggingOverElement, setIsDraggingOverElement ] =\n\t\tuseState< boolean >();\n\tconst [ type, setType ] = useState< DropType >();\n\tconst ref = useDropZone( {\n\t\tonDrop( event ) {\n\t\t\tconst files = event.dataTransfer\n\t\t\t\t? getFilesFromDataTransfer( event.dataTransfer )\n\t\t\t\t: [];\n\t\t\tconst html = event.dataTransfer?.getData( 'text/html' );\n\n\t\t\t/**\n\t\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t\t * The order of the checks is important to recognize the HTML drop.\n\t\t\t */\n\t\t\tif ( html && onHTMLDrop ) {\n\t\t\t\tonHTMLDrop( html );\n\t\t\t} else if ( files.length && onFilesDrop ) {\n\t\t\t\tonFilesDrop( files );\n\t\t\t} else if ( onDrop ) {\n\t\t\t\tonDrop( event );\n\t\t\t}\n\t\t},\n\t\tonDragStart( event ) {\n\t\t\tsetIsDraggingOverDocument( true );\n\n\t\t\tlet _type: DropType = 'default';\n\n\t\t\t/**\n\t\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t\t * The order of the checks is important to recognize the HTML drop.\n\t\t\t */\n\t\t\tif ( event.dataTransfer?.types.includes( 'text/html' ) ) {\n\t\t\t\t_type = 'html';\n\t\t\t} else if (\n\t\t\t\t// Check for the types because sometimes the files themselves\n\t\t\t\t// are only available on drop.\n\t\t\t\tevent.dataTransfer?.types.includes( 'Files' ) ||\n\t\t\t\t( event.dataTransfer\n\t\t\t\t\t? getFilesFromDataTransfer( event.dataTransfer )\n\t\t\t\t\t: []\n\t\t\t\t).length > 0\n\t\t\t) {\n\t\t\t\t_type = 'file';\n\t\t\t}\n\n\t\t\tsetType( _type );\n\t\t},\n\t\tonDragEnd() {\n\t\t\tsetIsDraggingOverDocument( false );\n\t\t\tsetType( undefined );\n\t\t},\n\t\tonDragEnter() {\n\t\t\tsetIsDraggingOverElement( true );\n\t\t},\n\t\tonDragLeave() {\n\t\t\tsetIsDraggingOverElement( false );\n\t\t},\n\t} );\n\n\tconst classes = clsx( 'components-drop-zone', className, {\n\t\t'is-active':\n\t\t\t( isDraggingOverDocument || isDraggingOverElement ) &&\n\t\t\t( ( type === 'file' && onFilesDrop ) ||\n\t\t\t\t( type === 'html' && onHTMLDrop ) ||\n\t\t\t\t( type === 'default' && onDrop ) ),\n\t\t'has-dragged-out': ! isDraggingOverElement,\n\t\t// Keeping the following classnames for legacy purposes\n\t\t'is-dragging-over-document': isDraggingOverDocument,\n\t\t'is-dragging-over-element': isDraggingOverElement,\n\t\t[ `is-dragging-${ type }` ]: !! type,\n\t} );\n\n\treturn (\n\t\t<div { ...restProps } ref={ ref } className={ classes }>\n\t\t\t<div className=\"components-drop-zone__content\">\n\t\t\t\t<div className=\"components-drop-zone__content-inner\">\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\tclassName=\"components-drop-zone__content-icon\"\n\t\t\t\t\t/>\n\t\t\t\t\t<span className=\"components-drop-zone__content-text\">\n\t\t\t\t\t\t{ label ? label : __( 'Drop files to upload' ) }\n\t\t\t\t\t</span>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport default DropZoneComponent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EAAEE,qBAAqB;IACjD,CAAG,eAAeE,IAAM,EAAC,GAAI,CAAC,CAAEA;EACjC,CAAE,CAAC;EAEH,oBACCd,IAAA;IAAA,GAAUS,SAAS;IAAGO,GAAG,EAAGA,GAAK;IAACZ,SAAS,EAAG2B,OAAS;IAAAC,QAAA,eACtDhC,IAAA;MAAKI,SAAS,EAAC,+BAA+B;MAAA4B,QAAA,eAC7C9B,KAAA;QAAKE,SAAS,EAAC,qCAAqC;QAAA4B,QAAA,gBACnDhC,IAAA,CAACL,IAAI;UACJsC,IAAI,EAAGvC,MAAQ;UACfU,SAAS,EAAC;QAAoC,CAC9C,CAAC,eACFJ,IAAA;UAAMI,SAAS,EAAC,oCAAoC;UAAA4B,QAAA,EACjD3B,KAAK,GAAGA,KAAK,GAAGb,EAAE,CAAE,sBAAuB;QAAC,CACzC,CAAC;MAAA,CACH;IAAC,CACF;EAAC,CACF,CAAC;AAER;AAEA,eAAeW,iBAAiB","ignoreList":[]}
|
|
@@ -5,5 +5,5 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri
|
|
|
5
5
|
export const {
|
|
6
6
|
lock,
|
|
7
7
|
unlock
|
|
8
|
-
} = __dangerousOptInToUnstableAPIsOnlyForCoreModules('I
|
|
8
|
+
} = __dangerousOptInToUnstableAPIsOnlyForCoreModules('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/components');
|
|
9
9
|
//# sourceMappingURL=lock-unlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"sources":["@wordpress/components/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I
|
|
1
|
+
{"version":3,"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"sources":["@wordpress/components/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/components'\n\t);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gDAAgD,QAAQ,yBAAyB;AAE1F,OAAO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5BF,gDAAgD,CAC/C,+HAA+H,EAC/H,uBACD,CAAC","ignoreList":[]}
|
|
@@ -9,7 +9,7 @@ import clsx from 'clsx';
|
|
|
9
9
|
import { useState, useRef, useEffect, useCallback, useMemo } from '@wordpress/element';
|
|
10
10
|
import { __, sprintf } from '@wordpress/i18n';
|
|
11
11
|
import { lineSolid, moreVertical, plus } from '@wordpress/icons';
|
|
12
|
-
import {
|
|
12
|
+
import { useDebounce } from '@wordpress/compose';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
@@ -126,16 +126,13 @@ function Option({
|
|
|
126
126
|
canOnlyChangeValues,
|
|
127
127
|
element,
|
|
128
128
|
onChange,
|
|
129
|
-
isEditing,
|
|
130
|
-
onStartEditing,
|
|
131
129
|
onRemove,
|
|
132
|
-
onStopEditing,
|
|
133
130
|
popoverProps: receivedPopoverProps,
|
|
134
131
|
slugPrefix,
|
|
135
132
|
isGradient
|
|
136
133
|
}) {
|
|
137
|
-
const focusOutsideProps = useFocusOutside(onStopEditing);
|
|
138
134
|
const value = isGradient ? element.gradient : element.color;
|
|
135
|
+
const [isEditingColor, setIsEditingColor] = useState(false);
|
|
139
136
|
|
|
140
137
|
// Use internal state instead of a ref to make sure that the component
|
|
141
138
|
// re-renders when the popover's anchor updates.
|
|
@@ -146,22 +143,25 @@ function Option({
|
|
|
146
143
|
anchor: popoverAnchor
|
|
147
144
|
}), [popoverAnchor, receivedPopoverProps]);
|
|
148
145
|
return /*#__PURE__*/_jsxs(PaletteItem, {
|
|
149
|
-
className: isEditing ? 'is-selected' : undefined,
|
|
150
|
-
as: isEditing ? 'div' : 'button',
|
|
151
|
-
onClick: onStartEditing,
|
|
152
|
-
"aria-label": isEditing ? undefined : sprintf(
|
|
153
|
-
// translators: %s is a color or gradient name, e.g. "Red".
|
|
154
|
-
__('Edit: %s'), element.name.trim().length ? element.name : value),
|
|
155
146
|
ref: setPopoverAnchor,
|
|
156
|
-
|
|
157
|
-
...focusOutsideProps
|
|
158
|
-
} : {}),
|
|
147
|
+
as: "div",
|
|
159
148
|
children: [/*#__PURE__*/_jsxs(HStack, {
|
|
160
149
|
justify: "flex-start",
|
|
161
|
-
children: [/*#__PURE__*/_jsx(
|
|
162
|
-
|
|
150
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
151
|
+
onClick: () => {
|
|
152
|
+
setIsEditingColor(true);
|
|
153
|
+
},
|
|
154
|
+
"aria-label": sprintf(
|
|
155
|
+
// translators: %s is a color or gradient name, e.g. "Red".
|
|
156
|
+
__('Edit: %s'), element.name.trim().length ? element.name : value),
|
|
157
|
+
style: {
|
|
158
|
+
padding: 0
|
|
159
|
+
},
|
|
160
|
+
children: /*#__PURE__*/_jsx(IndicatorStyled, {
|
|
161
|
+
colorValue: value
|
|
162
|
+
})
|
|
163
163
|
}), /*#__PURE__*/_jsx(FlexItem, {
|
|
164
|
-
children:
|
|
164
|
+
children: !canOnlyChangeValues ? /*#__PURE__*/_jsx(NameInput, {
|
|
165
165
|
label: isGradient ? __('Gradient name') : __('Color name'),
|
|
166
166
|
value: element.name,
|
|
167
167
|
onChange: nextName => onChange({
|
|
@@ -173,31 +173,33 @@ function Option({
|
|
|
173
173
|
children: element.name.trim().length ? element.name : /* Fall back to non-breaking space to maintain height */
|
|
174
174
|
'\u00A0'
|
|
175
175
|
})
|
|
176
|
-
}),
|
|
176
|
+
}), !canOnlyChangeValues && /*#__PURE__*/_jsx(FlexItem, {
|
|
177
177
|
children: /*#__PURE__*/_jsx(RemoveButton, {
|
|
178
178
|
size: "small",
|
|
179
179
|
icon: lineSolid,
|
|
180
|
-
label:
|
|
180
|
+
label: sprintf(
|
|
181
|
+
// translators: %s is a color or gradient name, e.g. "Red".
|
|
182
|
+
__('Remove color: %s'), element.name.trim().length ? element.name : value),
|
|
181
183
|
onClick: onRemove
|
|
182
184
|
})
|
|
183
185
|
})]
|
|
184
|
-
}),
|
|
186
|
+
}), isEditingColor && /*#__PURE__*/_jsx(ColorPickerPopover, {
|
|
185
187
|
isGradient: isGradient,
|
|
186
188
|
onChange: onChange,
|
|
187
189
|
element: element,
|
|
188
|
-
popoverProps: popoverProps
|
|
190
|
+
popoverProps: popoverProps,
|
|
191
|
+
onClose: () => setIsEditingColor(false)
|
|
189
192
|
})]
|
|
190
193
|
});
|
|
191
194
|
}
|
|
192
195
|
function PaletteEditListView({
|
|
193
196
|
elements,
|
|
194
197
|
onChange,
|
|
195
|
-
editingElement,
|
|
196
|
-
setEditingElement,
|
|
197
198
|
canOnlyChangeValues,
|
|
198
199
|
slugPrefix,
|
|
199
200
|
isGradient,
|
|
200
|
-
popoverProps
|
|
201
|
+
popoverProps,
|
|
202
|
+
addColorRef
|
|
201
203
|
}) {
|
|
202
204
|
// When unmounting the component if there are empty elements (the user did not complete the insertion) clean them.
|
|
203
205
|
const elementsReference = useRef();
|
|
@@ -213,11 +215,6 @@ function PaletteEditListView({
|
|
|
213
215
|
isGradient: isGradient,
|
|
214
216
|
canOnlyChangeValues: canOnlyChangeValues,
|
|
215
217
|
element: element,
|
|
216
|
-
onStartEditing: () => {
|
|
217
|
-
if (editingElement !== index) {
|
|
218
|
-
setEditingElement(index);
|
|
219
|
-
}
|
|
220
|
-
},
|
|
221
218
|
onChange: newElement => {
|
|
222
219
|
debounceOnChange(elements.map((currentElement, currentIndex) => {
|
|
223
220
|
if (currentIndex === index) {
|
|
@@ -227,7 +224,6 @@ function PaletteEditListView({
|
|
|
227
224
|
}));
|
|
228
225
|
},
|
|
229
226
|
onRemove: () => {
|
|
230
|
-
setEditingElement(null);
|
|
231
227
|
const newElements = elements.filter((_currentElement, currentIndex) => {
|
|
232
228
|
if (currentIndex === index) {
|
|
233
229
|
return false;
|
|
@@ -235,12 +231,7 @@ function PaletteEditListView({
|
|
|
235
231
|
return true;
|
|
236
232
|
});
|
|
237
233
|
onChange(newElements.length ? newElements : undefined);
|
|
238
|
-
|
|
239
|
-
isEditing: index === editingElement,
|
|
240
|
-
onStopEditing: () => {
|
|
241
|
-
if (index === editingElement) {
|
|
242
|
-
setEditingElement(null);
|
|
243
|
-
}
|
|
234
|
+
addColorRef.current?.focus();
|
|
244
235
|
},
|
|
245
236
|
slugPrefix: slugPrefix,
|
|
246
237
|
popoverProps: popoverProps
|
|
@@ -300,6 +291,7 @@ export function PaletteEdit({
|
|
|
300
291
|
setIsEditing(true);
|
|
301
292
|
}
|
|
302
293
|
}, [isGradient, elements]);
|
|
294
|
+
const addColorRef = useRef(null);
|
|
303
295
|
return /*#__PURE__*/_jsxs(PaletteEditStyles, {
|
|
304
296
|
children: [/*#__PURE__*/_jsxs(HStack, {
|
|
305
297
|
children: [/*#__PURE__*/_jsx(PaletteHeading, {
|
|
@@ -314,6 +306,7 @@ export function PaletteEdit({
|
|
|
314
306
|
},
|
|
315
307
|
children: __('Done')
|
|
316
308
|
}), !canOnlyChangeValues && /*#__PURE__*/_jsx(Button, {
|
|
309
|
+
ref: addColorRef,
|
|
317
310
|
size: "small",
|
|
318
311
|
isPressed: isAdding,
|
|
319
312
|
icon: plus,
|
|
@@ -388,11 +381,10 @@ export function PaletteEdit({
|
|
|
388
381
|
// @ts-expect-error TODO: Don't know how to resolve
|
|
389
382
|
,
|
|
390
383
|
onChange: onChange,
|
|
391
|
-
editingElement: editingElement,
|
|
392
|
-
setEditingElement: setEditingElement,
|
|
393
384
|
slugPrefix: slugPrefix,
|
|
394
385
|
isGradient: isGradient,
|
|
395
|
-
popoverProps: popoverProps
|
|
386
|
+
popoverProps: popoverProps,
|
|
387
|
+
addColorRef: addColorRef
|
|
396
388
|
}), !isEditing && editingElement !== null && /*#__PURE__*/_jsx(ColorPickerPopover, {
|
|
397
389
|
isGradient: isGradient,
|
|
398
390
|
onClose: () => setEditingElement(null),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","useState","useRef","useEffect","useCallback","useMemo","__","sprintf","lineSolid","moreVertical","plus","__experimentalUseFocusOutside","useFocusOutside","useDebounce","Button","ColorPicker","FlexItem","HStack","ItemGroup","VStack","GradientPicker","ColorPalette","DropdownMenu","Popover","PaletteActionsContainer","PaletteEditStyles","PaletteHeading","IndicatorStyled","PaletteItem","NameContainer","NameInputControl","DoneButton","RemoveButton","PaletteEditContents","NavigableMenu","DEFAULT_GRADIENT","CustomGradientPicker","kebabCase","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","DEFAULT_COLOR","NameInput","value","onChange","label","hideLabelFromVision","getNameAndSlugForPosition","elements","slugPrefix","nameRegex","RegExp","position","reduce","previousValue","currentValue","slug","matches","match","id","parseInt","name","ColorPickerPopover","isGradient","element","popoverProps","receivedPopoverProps","onClose","shift","offset","resize","placement","className","children","color","enableAlpha","newColor","__experimentalIsRenderedInSidebar","gradient","newGradient","Option","canOnlyChangeValues","isEditing","onStartEditing","onRemove","onStopEditing","focusOutsideProps","popoverAnchor","setPopoverAnchor","anchor","undefined","as","onClick","trim","length","ref","justify","colorValue","nextName","size","icon","PaletteEditListView","editingElement","setEditingElement","elementsReference","current","debounceOnChange","spacing","isRounded","map","index","newElement","currentElement","currentIndex","newElements","filter","_currentElement","EMPTY_ARRAY","PaletteEdit","gradients","colors","paletteLabel","paletteLabelHeadingLevel","emptyMessage","canReset","setIsEditing","isAdding","elementsLength","hasElements","onSelectPaletteItem","newEditingElementIndex","selectedElement","key","level","isPressed","toggleProps","role","variant","clearable","disableCustomGradients","disableCustomColors"],"sources":["@wordpress/components/src/palette-edit/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tuseCallback,\n\tuseMemo,\n} from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { lineSolid, moreVertical, plus } from '@wordpress/icons';\nimport {\n\t__experimentalUseFocusOutside as useFocusOutside,\n\tuseDebounce,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { ColorPicker } from '../color-picker';\nimport { FlexItem } from '../flex';\nimport { HStack } from '../h-stack';\nimport { ItemGroup } from '../item-group';\nimport { VStack } from '../v-stack';\nimport GradientPicker from '../gradient-picker';\nimport ColorPalette from '../color-palette';\nimport DropdownMenu from '../dropdown-menu';\nimport Popover from '../popover';\nimport {\n\tPaletteActionsContainer,\n\tPaletteEditStyles,\n\tPaletteHeading,\n\tIndicatorStyled,\n\tPaletteItem,\n\tNameContainer,\n\tNameInputControl,\n\tDoneButton,\n\tRemoveButton,\n\tPaletteEditContents,\n} from './styles';\nimport { NavigableMenu } from '../navigable-container';\nimport { DEFAULT_GRADIENT } from '../custom-gradient-picker/constants';\nimport CustomGradientPicker from '../custom-gradient-picker';\nimport { kebabCase } from '../utils/strings';\nimport type {\n\tColor,\n\tColorPickerPopoverProps,\n\tGradient,\n\tNameInputProps,\n\tOptionProps,\n\tPaletteEditListViewProps,\n\tPaletteEditProps,\n\tPaletteElement,\n} from './types';\n\nconst DEFAULT_COLOR = '#000';\n\nfunction NameInput( { value, onChange, label }: NameInputProps ) {\n\treturn (\n\t\t<NameInputControl\n\t\t\tlabel={ label }\n\t\t\thideLabelFromVision\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\n/**\n * Returns a name and slug for a palette item. The name takes the format \"Color + id\".\n * To ensure there are no duplicate ids, this function checks all slugs.\n * It expects slugs to be in the format: slugPrefix + color- + number.\n * It then sets the id component of the new name based on the incremented id of the highest existing slug id.\n *\n * @param elements An array of color palette items.\n * @param slugPrefix The slug prefix used to match the element slug.\n *\n * @return A name and slug for the new palette item.\n */\nexport function getNameAndSlugForPosition(\n\telements: PaletteElement[],\n\tslugPrefix: string\n) {\n\tconst nameRegex = new RegExp( `^${ slugPrefix }color-([\\\\d]+)$` );\n\tconst position = elements.reduce( ( previousValue, currentValue ) => {\n\t\tif ( typeof currentValue?.slug === 'string' ) {\n\t\t\tconst matches = currentValue?.slug.match( nameRegex );\n\t\t\tif ( matches ) {\n\t\t\t\tconst id = parseInt( matches[ 1 ], 10 );\n\t\t\t\tif ( id >= previousValue ) {\n\t\t\t\t\treturn id + 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn previousValue;\n\t}, 1 );\n\n\treturn {\n\t\tname: sprintf(\n\t\t\t/* translators: %s: is an id for a custom color */\n\t\t\t__( 'Color %s' ),\n\t\t\tposition\n\t\t),\n\t\tslug: `${ slugPrefix }color-${ position }`,\n\t};\n}\n\nfunction ColorPickerPopover< T extends Color | Gradient >( {\n\tisGradient,\n\telement,\n\tonChange,\n\tpopoverProps: receivedPopoverProps,\n\tonClose = () => {},\n}: ColorPickerPopoverProps< T > ) {\n\tconst popoverProps: ColorPickerPopoverProps< T >[ 'popoverProps' ] =\n\t\tuseMemo(\n\t\t\t() => ( {\n\t\t\t\tshift: true,\n\t\t\t\toffset: 20,\n\t\t\t\t// Disabling resize as it would otherwise cause the popover to show\n\t\t\t\t// scrollbars while dragging the color picker's handle close to the\n\t\t\t\t// popover edge.\n\t\t\t\tresize: false,\n\t\t\t\tplacement: 'left-start',\n\t\t\t\t...receivedPopoverProps,\n\t\t\t\tclassName: clsx(\n\t\t\t\t\t'components-palette-edit__popover',\n\t\t\t\t\treceivedPopoverProps?.className\n\t\t\t\t),\n\t\t\t} ),\n\t\t\t[ receivedPopoverProps ]\n\t\t);\n\n\treturn (\n\t\t<Popover { ...popoverProps } onClose={ onClose }>\n\t\t\t{ ! isGradient && (\n\t\t\t\t<ColorPicker\n\t\t\t\t\tcolor={ element.color }\n\t\t\t\t\tenableAlpha\n\t\t\t\t\tonChange={ ( newColor ) => {\n\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t...element,\n\t\t\t\t\t\t\tcolor: newColor,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isGradient && (\n\t\t\t\t<div className=\"components-palette-edit__popover-gradient-picker\">\n\t\t\t\t\t<CustomGradientPicker\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\tvalue={ element.gradient }\n\t\t\t\t\t\tonChange={ ( newGradient ) => {\n\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t...element,\n\t\t\t\t\t\t\t\tgradient: newGradient,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</Popover>\n\t);\n}\n\nfunction Option< T extends Color | Gradient >( {\n\tcanOnlyChangeValues,\n\telement,\n\tonChange,\n\tisEditing,\n\tonStartEditing,\n\tonRemove,\n\tonStopEditing,\n\tpopoverProps: receivedPopoverProps,\n\tslugPrefix,\n\tisGradient,\n}: OptionProps< T > ) {\n\tconst focusOutsideProps = useFocusOutside( onStopEditing );\n\tconst value = isGradient ? element.gradient : element.color;\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t...receivedPopoverProps,\n\t\t\t// Use the custom palette color item as the popover anchor.\n\t\t\tanchor: popoverAnchor,\n\t\t} ),\n\t\t[ popoverAnchor, receivedPopoverProps ]\n\t);\n\n\treturn (\n\t\t<PaletteItem\n\t\t\tclassName={ isEditing ? 'is-selected' : undefined }\n\t\t\tas={ isEditing ? 'div' : 'button' }\n\t\t\tonClick={ onStartEditing }\n\t\t\taria-label={\n\t\t\t\tisEditing\n\t\t\t\t\t? undefined\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: %s is a color or gradient name, e.g. \"Red\".\n\t\t\t\t\t\t\t__( 'Edit: %s' ),\n\t\t\t\t\t\t\telement.name.trim().length ? element.name : value\n\t\t\t\t\t )\n\t\t\t}\n\t\t\tref={ setPopoverAnchor }\n\t\t\t{ ...( isEditing ? { ...focusOutsideProps } : {} ) }\n\t\t>\n\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t<IndicatorStyled colorValue={ value } />\n\t\t\t\t<FlexItem>\n\t\t\t\t\t{ isEditing && ! canOnlyChangeValues ? (\n\t\t\t\t\t\t<NameInput\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\tisGradient\n\t\t\t\t\t\t\t\t\t? __( 'Gradient name' )\n\t\t\t\t\t\t\t\t\t: __( 'Color name' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tvalue={ element.name }\n\t\t\t\t\t\t\tonChange={ ( nextName?: string ) =>\n\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\t...element,\n\t\t\t\t\t\t\t\t\tname: nextName,\n\t\t\t\t\t\t\t\t\tslug:\n\t\t\t\t\t\t\t\t\t\tslugPrefix +\n\t\t\t\t\t\t\t\t\t\tkebabCase( nextName ?? '' ),\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<NameContainer>\n\t\t\t\t\t\t\t{ element.name.trim().length\n\t\t\t\t\t\t\t\t? element.name\n\t\t\t\t\t\t\t\t: /* Fall back to non-breaking space to maintain height */\n\t\t\t\t\t\t\t\t '\\u00A0' }\n\t\t\t\t\t\t</NameContainer>\n\t\t\t\t\t) }\n\t\t\t\t</FlexItem>\n\t\t\t\t{ isEditing && ! canOnlyChangeValues && (\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<RemoveButton\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\ticon={ lineSolid }\n\t\t\t\t\t\t\tlabel={ __( 'Remove color' ) }\n\t\t\t\t\t\t\tonClick={ onRemove }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t\t{ isEditing && (\n\t\t\t\t<ColorPickerPopover\n\t\t\t\t\tisGradient={ isGradient }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\telement={ element }\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</PaletteItem>\n\t);\n}\n\nfunction PaletteEditListView< T extends Color | Gradient >( {\n\telements,\n\tonChange,\n\teditingElement,\n\tsetEditingElement,\n\tcanOnlyChangeValues,\n\tslugPrefix,\n\tisGradient,\n\tpopoverProps,\n}: PaletteEditListViewProps< T > ) {\n\t// When unmounting the component if there are empty elements (the user did not complete the insertion) clean them.\n\tconst elementsReference = useRef< typeof elements >();\n\tuseEffect( () => {\n\t\telementsReference.current = elements;\n\t}, [ elements ] );\n\n\tconst debounceOnChange = useDebounce( onChange, 100 );\n\n\treturn (\n\t\t<VStack spacing={ 3 }>\n\t\t\t<ItemGroup isRounded>\n\t\t\t\t{ elements.map( ( element, index ) => (\n\t\t\t\t\t<Option\n\t\t\t\t\t\tisGradient={ isGradient }\n\t\t\t\t\t\tcanOnlyChangeValues={ canOnlyChangeValues }\n\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\telement={ element }\n\t\t\t\t\t\tonStartEditing={ () => {\n\t\t\t\t\t\t\tif ( editingElement !== index ) {\n\t\t\t\t\t\t\t\tsetEditingElement( index );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonChange={ ( newElement ) => {\n\t\t\t\t\t\t\tdebounceOnChange(\n\t\t\t\t\t\t\t\telements.map(\n\t\t\t\t\t\t\t\t\t( currentElement, currentIndex ) => {\n\t\t\t\t\t\t\t\t\t\tif ( currentIndex === index ) {\n\t\t\t\t\t\t\t\t\t\t\treturn newElement;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\treturn currentElement;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\tsetEditingElement( null );\n\t\t\t\t\t\t\tconst newElements = elements.filter(\n\t\t\t\t\t\t\t\t( _currentElement, currentIndex ) => {\n\t\t\t\t\t\t\t\t\tif ( currentIndex === index ) {\n\t\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tnewElements.length ? newElements : undefined\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisEditing={ index === editingElement }\n\t\t\t\t\t\tonStopEditing={ () => {\n\t\t\t\t\t\t\tif ( index === editingElement ) {\n\t\t\t\t\t\t\t\tsetEditingElement( null );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tslugPrefix={ slugPrefix }\n\t\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</ItemGroup>\n\t\t</VStack>\n\t);\n}\n\nconst EMPTY_ARRAY: Color[] = [];\n\n/**\n * Allows editing a palette of colors or gradients.\n *\n * ```jsx\n * import { PaletteEdit } from '@wordpress/components';\n * const MyPaletteEdit = () => {\n * const [ controlledColors, setControlledColors ] = useState( colors );\n *\n * return (\n * <PaletteEdit\n * colors={ controlledColors }\n * onChange={ ( newColors?: Color[] ) => {\n * setControlledColors( newColors );\n * } }\n * paletteLabel=\"Here is a label\"\n * />\n * );\n * };\n * ```\n */\nexport function PaletteEdit( {\n\tgradients,\n\tcolors = EMPTY_ARRAY,\n\tonChange,\n\tpaletteLabel,\n\tpaletteLabelHeadingLevel = 2,\n\temptyMessage,\n\tcanOnlyChangeValues,\n\tcanReset,\n\tslugPrefix = '',\n\tpopoverProps,\n}: PaletteEditProps ) {\n\tconst isGradient = !! gradients;\n\tconst elements = isGradient ? gradients : colors;\n\tconst [ isEditing, setIsEditing ] = useState( false );\n\tconst [ editingElement, setEditingElement ] = useState<\n\t\tnumber | null | undefined\n\t>( null );\n\tconst isAdding =\n\t\tisEditing &&\n\t\t!! editingElement &&\n\t\telements[ editingElement ] &&\n\t\t! elements[ editingElement ].slug;\n\tconst elementsLength = elements.length;\n\tconst hasElements = elementsLength > 0;\n\tconst debounceOnChange = useDebounce( onChange, 100 );\n\tconst onSelectPaletteItem = useCallback(\n\t\t(\n\t\t\tvalue?: PaletteElement[ keyof PaletteElement ],\n\t\t\tnewEditingElementIndex?: number\n\t\t) => {\n\t\t\tconst selectedElement =\n\t\t\t\tnewEditingElementIndex === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: elements[ newEditingElementIndex ];\n\t\t\tconst key = isGradient ? 'gradient' : 'color';\n\t\t\t// Ensures that the index returned matches a known element value.\n\t\t\tif ( !! selectedElement && selectedElement[ key ] === value ) {\n\t\t\t\tsetEditingElement( newEditingElementIndex );\n\t\t\t} else {\n\t\t\t\tsetIsEditing( true );\n\t\t\t}\n\t\t},\n\t\t[ isGradient, elements ]\n\t);\n\n\treturn (\n\t\t<PaletteEditStyles>\n\t\t\t<HStack>\n\t\t\t\t<PaletteHeading level={ paletteLabelHeadingLevel }>\n\t\t\t\t\t{ paletteLabel }\n\t\t\t\t</PaletteHeading>\n\t\t\t\t<PaletteActionsContainer>\n\t\t\t\t\t{ hasElements && isEditing && (\n\t\t\t\t\t\t<DoneButton\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetIsEditing( false );\n\t\t\t\t\t\t\t\tsetEditingElement( null );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Done' ) }\n\t\t\t\t\t\t</DoneButton>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! canOnlyChangeValues && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\tisPressed={ isAdding }\n\t\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\tisGradient\n\t\t\t\t\t\t\t\t\t? __( 'Add gradient' )\n\t\t\t\t\t\t\t\t\t: __( 'Add color' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tconst { name, slug } =\n\t\t\t\t\t\t\t\t\tgetNameAndSlugForPosition(\n\t\t\t\t\t\t\t\t\t\telements,\n\t\t\t\t\t\t\t\t\t\tslugPrefix\n\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tif ( !! gradients ) {\n\t\t\t\t\t\t\t\t\tonChange( [\n\t\t\t\t\t\t\t\t\t\t...gradients,\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tgradient: DEFAULT_GRADIENT,\n\t\t\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t] );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tonChange( [\n\t\t\t\t\t\t\t\t\t\t...colors,\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcolor: DEFAULT_COLOR,\n\t\t\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t] );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsetIsEditing( true );\n\t\t\t\t\t\t\t\tsetEditingElement( elements.length );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ hasElements &&\n\t\t\t\t\t\t( ! isEditing ||\n\t\t\t\t\t\t\t! canOnlyChangeValues ||\n\t\t\t\t\t\t\tcanReset ) && (\n\t\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\tisGradient\n\t\t\t\t\t\t\t\t\t\t? __( 'Gradient options' )\n\t\t\t\t\t\t\t\t\t\t: __( 'Color options' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\t\tsize: 'small',\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ ( { onClose }: { onClose: () => void } ) => (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<NavigableMenu role=\"menu\">\n\t\t\t\t\t\t\t\t\t\t\t{ ! isEditing && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetIsEditing( true );\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-palette-edit__menu-button\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Show details' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t{ ! canOnlyChangeValues && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetEditingElement(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnull\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetIsEditing( false );\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonChange();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-palette-edit__menu-button\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ isGradient\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Remove all gradients'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Remove all colors'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t{ canReset && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetEditingElement(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnull\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonChange();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ isGradient\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? __( 'Reset gradient' )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: __( 'Reset colors' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</DropdownMenu>\n\t\t\t\t\t\t) }\n\t\t\t\t</PaletteActionsContainer>\n\t\t\t</HStack>\n\t\t\t{ hasElements && (\n\t\t\t\t<PaletteEditContents>\n\t\t\t\t\t{ isEditing && (\n\t\t\t\t\t\t<PaletteEditListView< ( typeof elements )[ number ] >\n\t\t\t\t\t\t\tcanOnlyChangeValues={ canOnlyChangeValues }\n\t\t\t\t\t\t\telements={ elements }\n\t\t\t\t\t\t\t// @ts-expect-error TODO: Don't know how to resolve\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\teditingElement={ editingElement }\n\t\t\t\t\t\t\tsetEditingElement={ setEditingElement }\n\t\t\t\t\t\t\tslugPrefix={ slugPrefix }\n\t\t\t\t\t\t\tisGradient={ isGradient }\n\t\t\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isEditing && editingElement !== null && (\n\t\t\t\t\t\t<ColorPickerPopover\n\t\t\t\t\t\t\tisGradient={ isGradient }\n\t\t\t\t\t\t\tonClose={ () => setEditingElement( null ) }\n\t\t\t\t\t\t\tonChange={ (\n\t\t\t\t\t\t\t\tnewElement: ( typeof elements )[ number ]\n\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\tdebounceOnChange(\n\t\t\t\t\t\t\t\t\t// @ts-expect-error TODO: Don't know how to resolve\n\t\t\t\t\t\t\t\t\telements.map(\n\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\tcurrentElement: ( typeof elements )[ number ],\n\t\t\t\t\t\t\t\t\t\t\tcurrentIndex: number\n\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\tcurrentIndex === editingElement\n\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn newElement;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\treturn currentElement;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\telement={ elements[ editingElement ?? -1 ] }\n\t\t\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isEditing &&\n\t\t\t\t\t\t( isGradient ? (\n\t\t\t\t\t\t\t<GradientPicker\n\t\t\t\t\t\t\t\tgradients={ gradients }\n\t\t\t\t\t\t\t\tonChange={ onSelectPaletteItem }\n\t\t\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\t\t\tdisableCustomGradients\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\t\t\tonChange={ onSelectPaletteItem }\n\t\t\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\t\t\tdisableCustomColors\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) ) }\n\t\t\t\t</PaletteEditContents>\n\t\t\t) }\n\t\t\t{ ! hasElements && emptyMessage && (\n\t\t\t\t<PaletteEditContents>{ emptyMessage }</PaletteEditContents>\n\t\t\t) }\n\t\t</PaletteEditStyles>\n\t);\n}\n\nexport default PaletteEdit;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SACCC,QAAQ,EACRC,MAAM,EACNC,SAAS,EACTC,WAAW,EACXC,OAAO,QACD,oBAAoB;AAC3B,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,SAAS,EAAEC,YAAY,EAAEC,IAAI,QAAQ,kBAAkB;AAChE,SACCC,6BAA6B,IAAIC,eAAe,EAChDC,WAAW,QACL,oBAAoB;;AAE3B;AACA;AACA;AACA,OAAOC,MAAM,MAAM,WAAW;AAC9B,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,QAAQ,QAAQ,SAAS;AAClC,SAASC,MAAM,QAAQ,YAAY;AACnC,SAASC,SAAS,QAAQ,eAAe;AACzC,SAASC,MAAM,QAAQ,YAAY;AACnC,OAAOC,cAAc,MAAM,oBAAoB;AAC/C,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,OAAO,MAAM,YAAY;AAChC,SACCC,uBAAuB,EACvBC,iBAAiB,EACjBC,cAAc,EACdC,eAAe,EACfC,WAAW,EACXC,aAAa,EACbC,gBAAgB,EAChBC,UAAU,EACVC,YAAY,EACZC,mBAAmB,QACb,UAAU;AACjB,SAASC,aAAa,QAAQ,wBAAwB;AACtD,SAASC,gBAAgB,QAAQ,qCAAqC;AACtE,OAAOC,oBAAoB,MAAM,2BAA2B;AAC5D,SAASC,SAAS,QAAQ,kBAAkB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAY7C,MAAMC,aAAa,GAAG,MAAM;AAE5B,SAASC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C7B,CACD,EACC,CAAEiB,SAAS,KACVnB,UAAU,gBACX3B,IAAA,CAACnB,cAAc;QACdsG,SAAS,EAAGA,SAAW;QACvB3E,QAAQ,EAAGqF,mBAAqB;QAChCS,SAAS,EAAG,KAAO;QACnBC,sBAAsB;MAAA,CACtB,CAAC,gBAEFvG,IAAA,CAAClB,YAAY;QACZsG,MAAM,EAAGA,MAAQ;QACjB5E,QAAQ,EAAGqF,mBAAqB;QAChCS,SAAS,EAAG,KAAO;QACnBE,mBAAmB;MAAA,CACnB,CACD,CAAE;IAAA,CACgB,CACrB,EACC,CAAEZ,WAAW,IAAIL,YAAY,iBAC9BvF,IAAA,CAACN,mBAAmB;MAAA2C,QAAA,EAAGkD;IAAY,CAAuB,CAC1D;EAAA,CACiB,CAAC;AAEtB;AAEA,eAAeL,WAAW","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","useState","useRef","useEffect","useCallback","useMemo","__","sprintf","lineSolid","moreVertical","plus","useDebounce","Button","ColorPicker","FlexItem","HStack","ItemGroup","VStack","GradientPicker","ColorPalette","DropdownMenu","Popover","PaletteActionsContainer","PaletteEditStyles","PaletteHeading","IndicatorStyled","PaletteItem","NameContainer","NameInputControl","DoneButton","RemoveButton","PaletteEditContents","NavigableMenu","DEFAULT_GRADIENT","CustomGradientPicker","kebabCase","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","DEFAULT_COLOR","NameInput","value","onChange","label","hideLabelFromVision","getNameAndSlugForPosition","elements","slugPrefix","nameRegex","RegExp","position","reduce","previousValue","currentValue","slug","matches","match","id","parseInt","name","ColorPickerPopover","isGradient","element","popoverProps","receivedPopoverProps","onClose","shift","offset","resize","placement","className","children","color","enableAlpha","newColor","__experimentalIsRenderedInSidebar","gradient","newGradient","Option","canOnlyChangeValues","onRemove","isEditingColor","setIsEditingColor","popoverAnchor","setPopoverAnchor","anchor","ref","as","justify","onClick","trim","length","style","padding","colorValue","nextName","size","icon","PaletteEditListView","addColorRef","elementsReference","current","debounceOnChange","spacing","isRounded","map","index","newElement","currentElement","currentIndex","newElements","filter","_currentElement","undefined","focus","EMPTY_ARRAY","PaletteEdit","gradients","colors","paletteLabel","paletteLabelHeadingLevel","emptyMessage","canReset","isEditing","setIsEditing","editingElement","setEditingElement","isAdding","elementsLength","hasElements","onSelectPaletteItem","newEditingElementIndex","selectedElement","key","level","isPressed","toggleProps","role","variant","clearable","disableCustomGradients","disableCustomColors"],"sources":["@wordpress/components/src/palette-edit/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tuseCallback,\n\tuseMemo,\n} from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { lineSolid, moreVertical, plus } from '@wordpress/icons';\nimport { useDebounce } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { ColorPicker } from '../color-picker';\nimport { FlexItem } from '../flex';\nimport { HStack } from '../h-stack';\nimport { ItemGroup } from '../item-group';\nimport { VStack } from '../v-stack';\nimport GradientPicker from '../gradient-picker';\nimport ColorPalette from '../color-palette';\nimport DropdownMenu from '../dropdown-menu';\nimport Popover from '../popover';\nimport {\n\tPaletteActionsContainer,\n\tPaletteEditStyles,\n\tPaletteHeading,\n\tIndicatorStyled,\n\tPaletteItem,\n\tNameContainer,\n\tNameInputControl,\n\tDoneButton,\n\tRemoveButton,\n\tPaletteEditContents,\n} from './styles';\nimport { NavigableMenu } from '../navigable-container';\nimport { DEFAULT_GRADIENT } from '../custom-gradient-picker/constants';\nimport CustomGradientPicker from '../custom-gradient-picker';\nimport { kebabCase } from '../utils/strings';\nimport type {\n\tColor,\n\tColorPickerPopoverProps,\n\tGradient,\n\tNameInputProps,\n\tOptionProps,\n\tPaletteEditListViewProps,\n\tPaletteEditProps,\n\tPaletteElement,\n} from './types';\n\nconst DEFAULT_COLOR = '#000';\n\nfunction NameInput( { value, onChange, label }: NameInputProps ) {\n\treturn (\n\t\t<NameInputControl\n\t\t\tlabel={ label }\n\t\t\thideLabelFromVision\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\n/**\n * Returns a name and slug for a palette item. The name takes the format \"Color + id\".\n * To ensure there are no duplicate ids, this function checks all slugs.\n * It expects slugs to be in the format: slugPrefix + color- + number.\n * It then sets the id component of the new name based on the incremented id of the highest existing slug id.\n *\n * @param elements An array of color palette items.\n * @param slugPrefix The slug prefix used to match the element slug.\n *\n * @return A name and slug for the new palette item.\n */\nexport function getNameAndSlugForPosition(\n\telements: PaletteElement[],\n\tslugPrefix: string\n) {\n\tconst nameRegex = new RegExp( `^${ slugPrefix }color-([\\\\d]+)$` );\n\tconst position = elements.reduce( ( previousValue, currentValue ) => {\n\t\tif ( typeof currentValue?.slug === 'string' ) {\n\t\t\tconst matches = currentValue?.slug.match( nameRegex );\n\t\t\tif ( matches ) {\n\t\t\t\tconst id = parseInt( matches[ 1 ], 10 );\n\t\t\t\tif ( id >= previousValue ) {\n\t\t\t\t\treturn id + 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn previousValue;\n\t}, 1 );\n\n\treturn {\n\t\tname: sprintf(\n\t\t\t/* translators: %s: is an id for a custom color */\n\t\t\t__( 'Color %s' ),\n\t\t\tposition\n\t\t),\n\t\tslug: `${ slugPrefix }color-${ position }`,\n\t};\n}\n\nfunction ColorPickerPopover< T extends Color | Gradient >( {\n\tisGradient,\n\telement,\n\tonChange,\n\tpopoverProps: receivedPopoverProps,\n\tonClose = () => {},\n}: ColorPickerPopoverProps< T > ) {\n\tconst popoverProps: ColorPickerPopoverProps< T >[ 'popoverProps' ] =\n\t\tuseMemo(\n\t\t\t() => ( {\n\t\t\t\tshift: true,\n\t\t\t\toffset: 20,\n\t\t\t\t// Disabling resize as it would otherwise cause the popover to show\n\t\t\t\t// scrollbars while dragging the color picker's handle close to the\n\t\t\t\t// popover edge.\n\t\t\t\tresize: false,\n\t\t\t\tplacement: 'left-start',\n\t\t\t\t...receivedPopoverProps,\n\t\t\t\tclassName: clsx(\n\t\t\t\t\t'components-palette-edit__popover',\n\t\t\t\t\treceivedPopoverProps?.className\n\t\t\t\t),\n\t\t\t} ),\n\t\t\t[ receivedPopoverProps ]\n\t\t);\n\n\treturn (\n\t\t<Popover { ...popoverProps } onClose={ onClose }>\n\t\t\t{ ! isGradient && (\n\t\t\t\t<ColorPicker\n\t\t\t\t\tcolor={ element.color }\n\t\t\t\t\tenableAlpha\n\t\t\t\t\tonChange={ ( newColor ) => {\n\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t...element,\n\t\t\t\t\t\t\tcolor: newColor,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isGradient && (\n\t\t\t\t<div className=\"components-palette-edit__popover-gradient-picker\">\n\t\t\t\t\t<CustomGradientPicker\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\tvalue={ element.gradient }\n\t\t\t\t\t\tonChange={ ( newGradient ) => {\n\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t...element,\n\t\t\t\t\t\t\t\tgradient: newGradient,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</Popover>\n\t);\n}\n\nfunction Option< T extends Color | Gradient >( {\n\tcanOnlyChangeValues,\n\telement,\n\tonChange,\n\tonRemove,\n\tpopoverProps: receivedPopoverProps,\n\tslugPrefix,\n\tisGradient,\n}: OptionProps< T > ) {\n\tconst value = isGradient ? element.gradient : element.color;\n\tconst [ isEditingColor, setIsEditingColor ] = useState( false );\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t...receivedPopoverProps,\n\t\t\t// Use the custom palette color item as the popover anchor.\n\t\t\tanchor: popoverAnchor,\n\t\t} ),\n\t\t[ popoverAnchor, receivedPopoverProps ]\n\t);\n\n\treturn (\n\t\t<PaletteItem ref={ setPopoverAnchor } as=\"div\">\n\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t<Button\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetIsEditingColor( true );\n\t\t\t\t\t} }\n\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t// translators: %s is a color or gradient name, e.g. \"Red\".\n\t\t\t\t\t\t__( 'Edit: %s' ),\n\t\t\t\t\t\telement.name.trim().length ? element.name : value\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ { padding: 0 } }\n\t\t\t\t>\n\t\t\t\t\t<IndicatorStyled colorValue={ value } />\n\t\t\t\t</Button>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t{ ! canOnlyChangeValues ? (\n\t\t\t\t\t\t<NameInput\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\tisGradient\n\t\t\t\t\t\t\t\t\t? __( 'Gradient name' )\n\t\t\t\t\t\t\t\t\t: __( 'Color name' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tvalue={ element.name }\n\t\t\t\t\t\t\tonChange={ ( nextName?: string ) =>\n\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\t...element,\n\t\t\t\t\t\t\t\t\tname: nextName,\n\t\t\t\t\t\t\t\t\tslug:\n\t\t\t\t\t\t\t\t\t\tslugPrefix +\n\t\t\t\t\t\t\t\t\t\tkebabCase( nextName ?? '' ),\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<NameContainer>\n\t\t\t\t\t\t\t{ element.name.trim().length\n\t\t\t\t\t\t\t\t? element.name\n\t\t\t\t\t\t\t\t: /* Fall back to non-breaking space to maintain height */\n\t\t\t\t\t\t\t\t '\\u00A0' }\n\t\t\t\t\t\t</NameContainer>\n\t\t\t\t\t) }\n\t\t\t\t</FlexItem>\n\t\t\t\t{ ! canOnlyChangeValues && (\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<RemoveButton\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\ticon={ lineSolid }\n\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s is a color or gradient name, e.g. \"Red\".\n\t\t\t\t\t\t\t\t__( 'Remove color: %s' ),\n\t\t\t\t\t\t\t\telement.name.trim().length\n\t\t\t\t\t\t\t\t\t? element.name\n\t\t\t\t\t\t\t\t\t: value\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ onRemove }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t\t{ isEditingColor && (\n\t\t\t\t<ColorPickerPopover\n\t\t\t\t\tisGradient={ isGradient }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\telement={ element }\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\tonClose={ () => setIsEditingColor( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</PaletteItem>\n\t);\n}\n\nfunction PaletteEditListView< T extends Color | Gradient >( {\n\telements,\n\tonChange,\n\tcanOnlyChangeValues,\n\tslugPrefix,\n\tisGradient,\n\tpopoverProps,\n\taddColorRef,\n}: PaletteEditListViewProps< T > ) {\n\t// When unmounting the component if there are empty elements (the user did not complete the insertion) clean them.\n\tconst elementsReference = useRef< typeof elements >();\n\tuseEffect( () => {\n\t\telementsReference.current = elements;\n\t}, [ elements ] );\n\n\tconst debounceOnChange = useDebounce( onChange, 100 );\n\n\treturn (\n\t\t<VStack spacing={ 3 }>\n\t\t\t<ItemGroup isRounded>\n\t\t\t\t{ elements.map( ( element, index ) => (\n\t\t\t\t\t<Option\n\t\t\t\t\t\tisGradient={ isGradient }\n\t\t\t\t\t\tcanOnlyChangeValues={ canOnlyChangeValues }\n\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\telement={ element }\n\t\t\t\t\t\tonChange={ ( newElement ) => {\n\t\t\t\t\t\t\tdebounceOnChange(\n\t\t\t\t\t\t\t\telements.map(\n\t\t\t\t\t\t\t\t\t( currentElement, currentIndex ) => {\n\t\t\t\t\t\t\t\t\t\tif ( currentIndex === index ) {\n\t\t\t\t\t\t\t\t\t\t\treturn newElement;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\treturn currentElement;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\tconst newElements = elements.filter(\n\t\t\t\t\t\t\t\t( _currentElement, currentIndex ) => {\n\t\t\t\t\t\t\t\t\tif ( currentIndex === index ) {\n\t\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tnewElements.length ? newElements : undefined\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\taddColorRef.current?.focus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tslugPrefix={ slugPrefix }\n\t\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</ItemGroup>\n\t\t</VStack>\n\t);\n}\n\nconst EMPTY_ARRAY: Color[] = [];\n\n/**\n * Allows editing a palette of colors or gradients.\n *\n * ```jsx\n * import { PaletteEdit } from '@wordpress/components';\n * const MyPaletteEdit = () => {\n * const [ controlledColors, setControlledColors ] = useState( colors );\n *\n * return (\n * <PaletteEdit\n * colors={ controlledColors }\n * onChange={ ( newColors?: Color[] ) => {\n * setControlledColors( newColors );\n * } }\n * paletteLabel=\"Here is a label\"\n * />\n * );\n * };\n * ```\n */\nexport function PaletteEdit( {\n\tgradients,\n\tcolors = EMPTY_ARRAY,\n\tonChange,\n\tpaletteLabel,\n\tpaletteLabelHeadingLevel = 2,\n\temptyMessage,\n\tcanOnlyChangeValues,\n\tcanReset,\n\tslugPrefix = '',\n\tpopoverProps,\n}: PaletteEditProps ) {\n\tconst isGradient = !! gradients;\n\tconst elements = isGradient ? gradients : colors;\n\tconst [ isEditing, setIsEditing ] = useState( false );\n\tconst [ editingElement, setEditingElement ] = useState<\n\t\tnumber | null | undefined\n\t>( null );\n\tconst isAdding =\n\t\tisEditing &&\n\t\t!! editingElement &&\n\t\telements[ editingElement ] &&\n\t\t! elements[ editingElement ].slug;\n\tconst elementsLength = elements.length;\n\tconst hasElements = elementsLength > 0;\n\tconst debounceOnChange = useDebounce( onChange, 100 );\n\tconst onSelectPaletteItem = useCallback(\n\t\t(\n\t\t\tvalue?: PaletteElement[ keyof PaletteElement ],\n\t\t\tnewEditingElementIndex?: number\n\t\t) => {\n\t\t\tconst selectedElement =\n\t\t\t\tnewEditingElementIndex === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: elements[ newEditingElementIndex ];\n\t\t\tconst key = isGradient ? 'gradient' : 'color';\n\t\t\t// Ensures that the index returned matches a known element value.\n\t\t\tif ( !! selectedElement && selectedElement[ key ] === value ) {\n\t\t\t\tsetEditingElement( newEditingElementIndex );\n\t\t\t} else {\n\t\t\t\tsetIsEditing( true );\n\t\t\t}\n\t\t},\n\t\t[ isGradient, elements ]\n\t);\n\n\tconst addColorRef = useRef< HTMLButtonElement | null >( null );\n\n\treturn (\n\t\t<PaletteEditStyles>\n\t\t\t<HStack>\n\t\t\t\t<PaletteHeading level={ paletteLabelHeadingLevel }>\n\t\t\t\t\t{ paletteLabel }\n\t\t\t\t</PaletteHeading>\n\t\t\t\t<PaletteActionsContainer>\n\t\t\t\t\t{ hasElements && isEditing && (\n\t\t\t\t\t\t<DoneButton\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetIsEditing( false );\n\t\t\t\t\t\t\t\tsetEditingElement( null );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Done' ) }\n\t\t\t\t\t\t</DoneButton>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! canOnlyChangeValues && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tref={ addColorRef }\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\tisPressed={ isAdding }\n\t\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\tisGradient\n\t\t\t\t\t\t\t\t\t? __( 'Add gradient' )\n\t\t\t\t\t\t\t\t\t: __( 'Add color' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tconst { name, slug } =\n\t\t\t\t\t\t\t\t\tgetNameAndSlugForPosition(\n\t\t\t\t\t\t\t\t\t\telements,\n\t\t\t\t\t\t\t\t\t\tslugPrefix\n\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tif ( !! gradients ) {\n\t\t\t\t\t\t\t\t\tonChange( [\n\t\t\t\t\t\t\t\t\t\t...gradients,\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tgradient: DEFAULT_GRADIENT,\n\t\t\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t] );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tonChange( [\n\t\t\t\t\t\t\t\t\t\t...colors,\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcolor: DEFAULT_COLOR,\n\t\t\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t] );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsetIsEditing( true );\n\t\t\t\t\t\t\t\tsetEditingElement( elements.length );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ hasElements &&\n\t\t\t\t\t\t( ! isEditing ||\n\t\t\t\t\t\t\t! canOnlyChangeValues ||\n\t\t\t\t\t\t\tcanReset ) && (\n\t\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\tisGradient\n\t\t\t\t\t\t\t\t\t\t? __( 'Gradient options' )\n\t\t\t\t\t\t\t\t\t\t: __( 'Color options' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\t\tsize: 'small',\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ ( { onClose }: { onClose: () => void } ) => (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<NavigableMenu role=\"menu\">\n\t\t\t\t\t\t\t\t\t\t\t{ ! isEditing && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetIsEditing( true );\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-palette-edit__menu-button\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Show details' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t{ ! canOnlyChangeValues && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetEditingElement(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnull\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetIsEditing( false );\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonChange();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-palette-edit__menu-button\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ isGradient\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Remove all gradients'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Remove all colors'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t{ canReset && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetEditingElement(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnull\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonChange();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ isGradient\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? __( 'Reset gradient' )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: __( 'Reset colors' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</DropdownMenu>\n\t\t\t\t\t\t) }\n\t\t\t\t</PaletteActionsContainer>\n\t\t\t</HStack>\n\t\t\t{ hasElements && (\n\t\t\t\t<PaletteEditContents>\n\t\t\t\t\t{ isEditing && (\n\t\t\t\t\t\t<PaletteEditListView< ( typeof elements )[ number ] >\n\t\t\t\t\t\t\tcanOnlyChangeValues={ canOnlyChangeValues }\n\t\t\t\t\t\t\telements={ elements }\n\t\t\t\t\t\t\t// @ts-expect-error TODO: Don't know how to resolve\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tslugPrefix={ slugPrefix }\n\t\t\t\t\t\t\tisGradient={ isGradient }\n\t\t\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\t\t\taddColorRef={ addColorRef }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isEditing && editingElement !== null && (\n\t\t\t\t\t\t<ColorPickerPopover\n\t\t\t\t\t\t\tisGradient={ isGradient }\n\t\t\t\t\t\t\tonClose={ () => setEditingElement( null ) }\n\t\t\t\t\t\t\tonChange={ (\n\t\t\t\t\t\t\t\tnewElement: ( typeof elements )[ number ]\n\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\tdebounceOnChange(\n\t\t\t\t\t\t\t\t\t// @ts-expect-error TODO: Don't know how to resolve\n\t\t\t\t\t\t\t\t\telements.map(\n\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\tcurrentElement: ( typeof elements )[ number ],\n\t\t\t\t\t\t\t\t\t\t\tcurrentIndex: number\n\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\tcurrentIndex === editingElement\n\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn newElement;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\treturn currentElement;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\telement={ elements[ editingElement ?? -1 ] }\n\t\t\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isEditing &&\n\t\t\t\t\t\t( isGradient ? (\n\t\t\t\t\t\t\t<GradientPicker\n\t\t\t\t\t\t\t\tgradients={ gradients }\n\t\t\t\t\t\t\t\tonChange={ onSelectPaletteItem }\n\t\t\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\t\t\tdisableCustomGradients\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\t\t\tonChange={ onSelectPaletteItem }\n\t\t\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\t\t\tdisableCustomColors\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) ) }\n\t\t\t\t</PaletteEditContents>\n\t\t\t) }\n\t\t\t{ ! hasElements && emptyMessage && (\n\t\t\t\t<PaletteEditContents>{ emptyMessage }</PaletteEditContents>\n\t\t\t) }\n\t\t</PaletteEditStyles>\n\t);\n}\n\nexport default PaletteEdit;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SACCC,QAAQ,EACRC,MAAM,EACNC,SAAS,EACTC,WAAW,EACXC,OAAO,QACD,oBAAoB;AAC3B,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,SAAS,EAAEC,YAAY,EAAEC,IAAI,QAAQ,kBAAkB;AAChE,SAASC,WAAW,QAAQ,oBAAoB;;AAEhD;AACA;AACA;AACA,OAAOC,MAAM,MAAM,WAAW;AAC9B,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,QAAQ,QAAQ,SAAS;AAClC,SAASC,MAAM,QAAQ,YAAY;AACnC,SAASC,SAAS,QAAQ,eAAe;AACzC,SAASC,MAAM,QAAQ,YAAY;AACnC,OAAOC,cAAc,MAAM,oBAAoB;AAC/C,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,OAAO,MAAM,YAAY;AAChC,SACCC,uBAAuB,EACvBC,iBAAiB,EACjBC,cAAc,EACdC,eAAe,EACfC,WAAW,EACXC,aAAa,EACbC,gBAAgB,EAChBC,UAAU,EACVC,YAAY,EACZC,mBAAmB,QACb,UAAU;AACjB,SAASC,aAAa,QAAQ,wBAAwB;AACtD,SAASC,gBAAgB,QAAQ,qCAAqC;AACtE,OAAOC,oBAAoB,MAAM,2BAA2B;AAC5D,SAASC,SAAS,QAAQ,kBAAkB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAY7C,MAAMC,aAAa,GAAG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A,SAAW;QACvB3E,QAAQ,EAAGwF,mBAAqB;QAChCS,SAAS,EAAG,KAAO;QACnBC,sBAAsB;MAAA,CACtB,CAAC,gBAEF1G,IAAA,CAAClB,YAAY;QACZsG,MAAM,EAAGA,MAAQ;QACjB5E,QAAQ,EAAGwF,mBAAqB;QAChCS,SAAS,EAAG,KAAO;QACnBE,mBAAmB;MAAA,CACnB,CACD,CAAE;IAAA,CACgB,CACrB,EACC,CAAEZ,WAAW,IAAIR,YAAY,iBAC9BvF,IAAA,CAACN,mBAAmB;MAAA2C,QAAA,EAAGkD;IAAY,CAAuB,CAC1D;EAAA,CACiB,CAAC;AAEtB;AAEA,eAAeL,WAAW","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/components/src/palette-edit/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { Key, MouseEventHandler } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type Popover from '../popover';\nimport type { HeadingSize } from '../heading/types';\n\nexport type Color = {\n\tcolor: string;\n\tname: string;\n\tslug: string;\n\tgradient?: never;\n};\n\nexport type Gradient = {\n\tgradient: string;\n\tname: string;\n\tslug: string;\n\tcolor?: never;\n};\n\nexport type PaletteElement = Color | Gradient;\n\nexport type BasePaletteEdit = {\n\t/**\n\t * Whether the user can only change the color or gradient values.\n\t * If true, they cannot change names or delete values.\n\t *\n\t * @default false\n\t */\n\tcanOnlyChangeValues?: boolean;\n\t/**\n\t * Whether the user can reset the editor.\n\t *\n\t * @default false\n\t */\n\tcanReset?: boolean;\n\t/**\n\t * A message to show if there's nothing to edit.\n\t */\n\temptyMessage?: string;\n\t/**\n\t * A heading label for the palette.\n\t */\n\tpaletteLabel: string;\n\t/**\n\t * The label's heading level.\n\t *\n\t * @default 2\n\t */\n\tpaletteLabelHeadingLevel?: HeadingSize;\n\t/**\n\t * The prefix for the element slug.\n\t *\n\t * @default ''\n\t */\n\tslugPrefix?: string;\n\t/**\n\t * Props to pass through to the underlying Popover component.\n\t */\n\tpopoverProps?: Omit<\n\t\tReact.ComponentPropsWithoutRef< typeof Popover >,\n\t\t'children'\n\t>;\n};\n\ntype PaletteEditColors = {\n\t/**\n\t * The colors in the palette.\n\t */\n\tcolors?: Color[];\n\t/**\n\t * Runs on changing the value.\n\t */\n\tonChange: ( values?: Color[] ) => void;\n\tgradients?: never;\n};\n\ntype PaletteEditGradients = {\n\t/**\n\t * The gradients in the palette.\n\t */\n\tgradients: Gradient[];\n\t/**\n\t * Runs on changing the value.\n\t */\n\tonChange: ( values?: Gradient[] ) => void;\n\tcolors?: never;\n};\n\nexport type PaletteEditProps = BasePaletteEdit &\n\t( PaletteEditColors | PaletteEditGradients );\n\ntype EditingElement = number | null;\n\nexport type ColorPickerPopoverProps< T extends Color | Gradient > = {\n\telement: T;\n\tonChange: ( newElement: T ) => void;\n\tisGradient?: T extends Gradient ? true : false;\n\tonClose?: () => void;\n\tpopoverProps?: PaletteEditProps[ 'popoverProps' ];\n};\n\nexport type NameInputProps = {\n\tlabel: string;\n\tonChange: ( nextName?: PaletteElement[ 'name' ] ) => void;\n\tvalue: PaletteElement[ 'name' ];\n};\n\nexport type OptionProps< T extends Color | Gradient > = {\n\telement: T;\n\tonChange: ( newElement: T ) => void;\n\tisGradient: T extends Gradient ? true : false;\n\tcanOnlyChangeValues: PaletteEditProps[ 'canOnlyChangeValues' ];\n\
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/components/src/palette-edit/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { Key, MouseEventHandler } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type Popover from '../popover';\nimport type { HeadingSize } from '../heading/types';\n\nexport type Color = {\n\tcolor: string;\n\tname: string;\n\tslug: string;\n\tgradient?: never;\n};\n\nexport type Gradient = {\n\tgradient: string;\n\tname: string;\n\tslug: string;\n\tcolor?: never;\n};\n\nexport type PaletteElement = Color | Gradient;\n\nexport type BasePaletteEdit = {\n\t/**\n\t * Whether the user can only change the color or gradient values.\n\t * If true, they cannot change names or delete values.\n\t *\n\t * @default false\n\t */\n\tcanOnlyChangeValues?: boolean;\n\t/**\n\t * Whether the user can reset the editor.\n\t *\n\t * @default false\n\t */\n\tcanReset?: boolean;\n\t/**\n\t * A message to show if there's nothing to edit.\n\t */\n\temptyMessage?: string;\n\t/**\n\t * A heading label for the palette.\n\t */\n\tpaletteLabel: string;\n\t/**\n\t * The label's heading level.\n\t *\n\t * @default 2\n\t */\n\tpaletteLabelHeadingLevel?: HeadingSize;\n\t/**\n\t * The prefix for the element slug.\n\t *\n\t * @default ''\n\t */\n\tslugPrefix?: string;\n\t/**\n\t * Props to pass through to the underlying Popover component.\n\t */\n\tpopoverProps?: Omit<\n\t\tReact.ComponentPropsWithoutRef< typeof Popover >,\n\t\t'children'\n\t>;\n};\n\ntype PaletteEditColors = {\n\t/**\n\t * The colors in the palette.\n\t */\n\tcolors?: Color[];\n\t/**\n\t * Runs on changing the value.\n\t */\n\tonChange: ( values?: Color[] ) => void;\n\tgradients?: never;\n};\n\ntype PaletteEditGradients = {\n\t/**\n\t * The gradients in the palette.\n\t */\n\tgradients: Gradient[];\n\t/**\n\t * Runs on changing the value.\n\t */\n\tonChange: ( values?: Gradient[] ) => void;\n\tcolors?: never;\n};\n\nexport type PaletteEditProps = BasePaletteEdit &\n\t( PaletteEditColors | PaletteEditGradients );\n\ntype EditingElement = number | null;\n\nexport type ColorPickerPopoverProps< T extends Color | Gradient > = {\n\telement: T;\n\tonChange: ( newElement: T ) => void;\n\tisGradient?: T extends Gradient ? true : false;\n\tonClose?: () => void;\n\tpopoverProps?: PaletteEditProps[ 'popoverProps' ];\n};\n\nexport type NameInputProps = {\n\tlabel: string;\n\tonChange: ( nextName?: PaletteElement[ 'name' ] ) => void;\n\tvalue: PaletteElement[ 'name' ];\n};\n\nexport type OptionProps< T extends Color | Gradient > = {\n\telement: T;\n\tonChange: ( newElement: T ) => void;\n\tisGradient: T extends Gradient ? true : false;\n\tcanOnlyChangeValues: PaletteEditProps[ 'canOnlyChangeValues' ];\n\tkey: Key;\n\tonRemove: MouseEventHandler< HTMLButtonElement >;\n\tpopoverProps?: PaletteEditProps[ 'popoverProps' ];\n\tslugPrefix: string;\n};\n\nexport type PaletteEditListViewProps< T extends Color | Gradient > = {\n\telements: T[];\n\tonChange: ( newElements?: T[] ) => void;\n\tisGradient: T extends Gradient ? true : false;\n\tcanOnlyChangeValues: PaletteEditProps[ 'canOnlyChangeValues' ];\n\taddColorRef: React.RefObject< HTMLButtonElement >;\n\teditingElement?: EditingElement;\n\tpopoverProps?: PaletteEditProps[ 'popoverProps' ];\n\tsetEditingElement: ( newEditingElement?: EditingElement ) => void;\n\tslugPrefix: string;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -530,8 +530,7 @@ p + .components-button.is-tertiary {
|
|
|
530
530
|
vertical-align: top;
|
|
531
531
|
width: var(--checkbox-input-size);
|
|
532
532
|
height: var(--checkbox-input-size);
|
|
533
|
-
|
|
534
|
-
appearance: none;
|
|
533
|
+
appearance: none;
|
|
535
534
|
transition: 0.1s border-color ease-in-out;
|
|
536
535
|
}
|
|
537
536
|
@media (prefers-reduced-motion: reduce) {
|
|
@@ -1174,8 +1173,7 @@ body.is-dragging-components-draggable {
|
|
|
1174
1173
|
opacity: 1;
|
|
1175
1174
|
visibility: visible;
|
|
1176
1175
|
}
|
|
1177
|
-
|
|
1178
|
-
.components-drop-zone__content {
|
|
1176
|
+
.components-drop-zone .components-drop-zone__content {
|
|
1179
1177
|
position: absolute;
|
|
1180
1178
|
top: 0;
|
|
1181
1179
|
bottom: 0;
|
|
@@ -1190,6 +1188,31 @@ body.is-dragging-components-draggable {
|
|
|
1190
1188
|
z-index: 50;
|
|
1191
1189
|
text-align: center;
|
|
1192
1190
|
color: #fff;
|
|
1191
|
+
opacity: 0;
|
|
1192
|
+
pointer-events: none;
|
|
1193
|
+
}
|
|
1194
|
+
.components-drop-zone .components-drop-zone__content-inner {
|
|
1195
|
+
opacity: 0;
|
|
1196
|
+
transform: scale(0.9);
|
|
1197
|
+
}
|
|
1198
|
+
.components-drop-zone.is-active:not(.has-dragged-out) .components-drop-zone__content {
|
|
1199
|
+
opacity: 1;
|
|
1200
|
+
transition: opacity 0.2s ease-in-out;
|
|
1201
|
+
}
|
|
1202
|
+
@media (prefers-reduced-motion) {
|
|
1203
|
+
.components-drop-zone.is-active:not(.has-dragged-out) .components-drop-zone__content {
|
|
1204
|
+
transition: none;
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
.components-drop-zone.is-active:not(.has-dragged-out) .components-drop-zone__content-inner {
|
|
1208
|
+
opacity: 1;
|
|
1209
|
+
transform: scale(1);
|
|
1210
|
+
transition: opacity 0.1s ease-in-out 0.1s, transform 0.1s ease-in-out 0.1s;
|
|
1211
|
+
}
|
|
1212
|
+
@media (prefers-reduced-motion) {
|
|
1213
|
+
.components-drop-zone.is-active:not(.has-dragged-out) .components-drop-zone__content-inner {
|
|
1214
|
+
transition: none;
|
|
1215
|
+
}
|
|
1193
1216
|
}
|
|
1194
1217
|
|
|
1195
1218
|
.components-drop-zone__content-icon,
|
|
@@ -2647,8 +2670,7 @@ body.rtl .components-panel__body-toggle.components-button .dashicons-arrow-right
|
|
|
2647
2670
|
display: inline-flex;
|
|
2648
2671
|
margin: 0 0 0 8px;
|
|
2649
2672
|
padding: 0;
|
|
2650
|
-
|
|
2651
|
-
appearance: none;
|
|
2673
|
+
appearance: none;
|
|
2652
2674
|
cursor: pointer;
|
|
2653
2675
|
}
|
|
2654
2676
|
@media (prefers-reduced-motion: reduce) {
|