@secretstache/wordpress-gutenberg 0.5.13 → 0.6.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/build/editor-canvas.css +1 -0
- package/build/editor-ui.css +1 -0
- package/build/index.js +7955 -3
- package/build/index.js.map +1 -1
- package/package.json +13 -13
- package/src/components/DataQueryControls.jsx +365 -0
- package/src/components/{EmptyBlockAppender.js → EmptyBlockAppender.jsx} +2 -1
- package/src/components/{IconPicker.js → IconPicker.jsx} +2 -1
- package/src/components/{MediaControl.js → MediaControl.jsx} +1 -1
- package/src/components/{MediaTypeControl.js → MediaTypeControl.jsx} +1 -1
- package/src/components/{MediaWithFocalPointControl.js → MediaWithFocalPointControl.jsx} +1 -1
- package/src/components/{ResponsiveSpacingControl.js → ResponsiveSpacingControl.jsx} +1 -1
- package/src/components/{SpacingControl.js → SpacingControl.jsx} +6 -5
- package/src/components/index.js +16 -16
- package/src/hooks/index.js +4 -5
- package/src/hooks/useAccordionItem.js +8 -8
- package/src/hooks/{usePreviewControl.js → usePreviewControl.jsx} +1 -1
- package/src/hooks/{useTabs.js → useTabs.jsx} +2 -2
- package/src/icons/index.jsx +38 -0
- package/src/index.js +3 -5
- package/src/styles/_empty-block-appender.scss +26 -9
- package/src/styles/editor-canvas.scss +59 -0
- package/src/styles/editor-ui.scss +28 -0
- package/src/styles/styles.scss +1 -1
- package/src/utils/filters.jsx +40 -0
- package/src/utils/helpers.js +18 -3
- package/src/utils/index.js +1 -0
- package/build/styles.css +0 -291
- package/src/components/DataQueryControls.js +0 -53
- package/src/hooks/useColorChange.js +0 -22
- /package/src/components/{ColorPaletteControl.js → ColorPaletteControl.jsx} +0 -0
- /package/src/components/{DividersControl.js → DividersControl.jsx} +0 -0
- /package/src/components/{ImageActions.js → ImageActions.jsx} +0 -0
- /package/src/components/{InsertBlockToolbar.js → InsertBlockToolbar.jsx} +0 -0
- /package/src/components/{LinkControl.js → LinkControl.jsx} +0 -0
- /package/src/components/{PreviewControl.js → PreviewControl.jsx} +0 -0
- /package/src/components/{ResourcesWrapper.js → ResourcesWrapper.jsx} +0 -0
- /package/src/components/{SortableSelect.js → SortableSelect.jsx} +0 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@secretstache/wordpress-gutenberg",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.6.0",
|
4
4
|
"description": "",
|
5
5
|
"author": "Secret Stache",
|
6
6
|
"license": "GPL-2.0-or-later",
|
@@ -15,7 +15,8 @@
|
|
15
15
|
"module": "build/index.js",
|
16
16
|
"exports": {
|
17
17
|
".": "./build/index.js",
|
18
|
-
"./build/
|
18
|
+
"./build/editor-canvas.css": "./build/editor-canvas.css",
|
19
|
+
"./build/editor-ui.css": "./build/editor-ui.css"
|
19
20
|
},
|
20
21
|
"files": [
|
21
22
|
"build",
|
@@ -23,8 +24,10 @@
|
|
23
24
|
],
|
24
25
|
"type": "module",
|
25
26
|
"scripts": {
|
26
|
-
"build": "
|
27
|
-
"
|
27
|
+
"build": "yarn build:js && yarn build:css",
|
28
|
+
"build:js": "vite build",
|
29
|
+
"build:css": "sass src/styles/editor-canvas.scss build/editor-canvas.css --style=compressed --no-source-map && sass src/styles/editor-ui.scss build/editor-ui.css --style=compressed --no-source-map",
|
30
|
+
"dev": "vite",
|
28
31
|
"prepublishOnly": "yarn build"
|
29
32
|
},
|
30
33
|
"devDependencies": {
|
@@ -33,10 +36,7 @@
|
|
33
36
|
"@babel/preset-env": "^7.24.4",
|
34
37
|
"@babel/preset-react": "^7.24.1",
|
35
38
|
"@babel/runtime": "^7.24.4",
|
36
|
-
"@
|
37
|
-
"@rollup/plugin-commonjs": "^25.0.7",
|
38
|
-
"@rollup/plugin-node-resolve": "^15.2.3",
|
39
|
-
"@rollup/plugin-terser": "^0.4.4",
|
39
|
+
"@vitejs/plugin-react": "^4.7.0",
|
40
40
|
"@wordpress/api-fetch": "^7.24.0",
|
41
41
|
"@wordpress/block-editor": "^14.19.0",
|
42
42
|
"@wordpress/blocks": "^14.13.0",
|
@@ -45,14 +45,15 @@
|
|
45
45
|
"@wordpress/dom-ready": "^4.24.0",
|
46
46
|
"@wordpress/element": "^6.24.0",
|
47
47
|
"@wordpress/hooks": "^4.24.0",
|
48
|
-
"@wordpress/icons": "^10.24.0",
|
49
48
|
"babel-core": "^6.26.3",
|
50
49
|
"babel-loader": "^9.1.3",
|
51
50
|
"node-sass": "^9.0.0",
|
52
51
|
"postcss": "^8.4.38",
|
53
|
-
"
|
54
|
-
"
|
55
|
-
"
|
52
|
+
"react": "^18.0.0",
|
53
|
+
"react-dom": "^18.0.0",
|
54
|
+
"sass": "^1.90.0",
|
55
|
+
"vite": "^7.0.6",
|
56
|
+
"vite-plugin-externals": "^0.6.2"
|
56
57
|
},
|
57
58
|
"dependencies": {
|
58
59
|
"classnames": "^2.5.1",
|
@@ -70,7 +71,6 @@
|
|
70
71
|
"@wordpress/dom-ready": "^4.24.0",
|
71
72
|
"@wordpress/element": "^6.24.0",
|
72
73
|
"@wordpress/hooks": "^4.24.0",
|
73
|
-
"@wordpress/icons": "^10.24.0",
|
74
74
|
"react": "^18.0.0",
|
75
75
|
"react-dom": "^18.0.0"
|
76
76
|
},
|
@@ -0,0 +1,365 @@
|
|
1
|
+
import { createContext, useCallback, useContext, useState, useEffect, useMemo, memo } from '@wordpress/element';
|
2
|
+
import {
|
3
|
+
__experimentalDivider as Divider,
|
4
|
+
RangeControl,
|
5
|
+
RadioControl,
|
6
|
+
SelectControl,
|
7
|
+
} from '@wordpress/components';
|
8
|
+
import { useSelect } from '@wordpress/data';
|
9
|
+
import { arrayMove } from 'react-sortable-hoc';
|
10
|
+
import Select from 'react-select';
|
11
|
+
|
12
|
+
import { SortableSelectAsync } from './SortableSelect.jsx';
|
13
|
+
import { decodeHtmlEntities, loadSelectOptions } from '../utils/index.js';
|
14
|
+
|
15
|
+
const DataQueryContext = createContext({});
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Main DataQueryControls component that provides context to children
|
19
|
+
*/
|
20
|
+
export const DataQueryControls = memo(({
|
21
|
+
attributes,
|
22
|
+
setAttributes,
|
23
|
+
children,
|
24
|
+
}) => {
|
25
|
+
const updateAttribute = useCallback((name, value) => {
|
26
|
+
setAttributes({ [name]: value });
|
27
|
+
}, []);
|
28
|
+
|
29
|
+
const contextValue = useMemo(() => ({
|
30
|
+
attributes,
|
31
|
+
setAttributes,
|
32
|
+
updateAttribute,
|
33
|
+
}), [ attributes ]);
|
34
|
+
|
35
|
+
return (
|
36
|
+
<DataQueryContext.Provider value={contextValue}>
|
37
|
+
{children}
|
38
|
+
</DataQueryContext.Provider>
|
39
|
+
);
|
40
|
+
});
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Hook to access the query controls context
|
44
|
+
*/
|
45
|
+
const useDataQueryContext = () => {
|
46
|
+
const context = useContext(DataQueryContext);
|
47
|
+
|
48
|
+
if (!context) {
|
49
|
+
throw new Error('Query control components must be used within a DataQueryControls component');
|
50
|
+
}
|
51
|
+
|
52
|
+
return context;
|
53
|
+
};
|
54
|
+
|
55
|
+
/**
|
56
|
+
* QueryType component for selecting the query type
|
57
|
+
*/
|
58
|
+
const QueryType = memo(({
|
59
|
+
label = 'Query',
|
60
|
+
options = [],
|
61
|
+
onChange,
|
62
|
+
disabled = false,
|
63
|
+
help = '',
|
64
|
+
attributeName = 'queryType',
|
65
|
+
render = null,
|
66
|
+
}) => {
|
67
|
+
const { attributes, updateAttribute } = useDataQueryContext();
|
68
|
+
const queryType = attributes[attributeName];
|
69
|
+
|
70
|
+
const handleChange = useCallback((value) => {
|
71
|
+
updateAttribute(attributeName, value);
|
72
|
+
|
73
|
+
if (onChange) {
|
74
|
+
onChange(value);
|
75
|
+
}
|
76
|
+
}, [ attributeName, onChange ]);
|
77
|
+
|
78
|
+
if (render) {
|
79
|
+
return render({
|
80
|
+
value: queryType,
|
81
|
+
onChange: handleChange,
|
82
|
+
options,
|
83
|
+
disabled,
|
84
|
+
attributeName,
|
85
|
+
});
|
86
|
+
}
|
87
|
+
|
88
|
+
return (
|
89
|
+
<>
|
90
|
+
<RadioControl
|
91
|
+
label={label}
|
92
|
+
selected={queryType}
|
93
|
+
options={options}
|
94
|
+
onChange={handleChange}
|
95
|
+
disabled={disabled}
|
96
|
+
help={help}
|
97
|
+
/>
|
98
|
+
|
99
|
+
<Divider />
|
100
|
+
</>
|
101
|
+
);
|
102
|
+
});
|
103
|
+
|
104
|
+
/**
|
105
|
+
* TaxonomySelect component for taxonomy-based filtering
|
106
|
+
*/
|
107
|
+
const TaxonomySelect = memo(({
|
108
|
+
condition = true,
|
109
|
+
attributeName = 'selectedCategories',
|
110
|
+
taxonomy = 'category',
|
111
|
+
placeholder = 'Categories to show',
|
112
|
+
disabled = false,
|
113
|
+
render = null,
|
114
|
+
customOptions = null,
|
115
|
+
}) => {
|
116
|
+
const { attributes, updateAttribute } = useDataQueryContext();
|
117
|
+
|
118
|
+
const taxonomyTerms = useSelect((select) => {
|
119
|
+
if (customOptions) return null;
|
120
|
+
|
121
|
+
return select('core').getEntityRecords('taxonomy', taxonomy, { per_page: -1 });
|
122
|
+
}, [ taxonomy, customOptions ]);
|
123
|
+
|
124
|
+
const selectOptions = useMemo(() => {
|
125
|
+
if (customOptions) return customOptions;
|
126
|
+
|
127
|
+
return taxonomyTerms?.map(term => ({
|
128
|
+
value: term.id,
|
129
|
+
label: decodeHtmlEntities(term.name),
|
130
|
+
})) || [];
|
131
|
+
}, [ taxonomyTerms, customOptions ]);
|
132
|
+
|
133
|
+
const selectedTermIds = attributes[attributeName] || [];
|
134
|
+
|
135
|
+
const selectedOptions = useMemo(() => {
|
136
|
+
return selectedTermIds
|
137
|
+
.map(id => selectOptions.find(option => option.value === id))
|
138
|
+
.filter(Boolean);
|
139
|
+
}, [ selectedTermIds, selectOptions ]);
|
140
|
+
|
141
|
+
const onChange = useCallback((newSelected) => {
|
142
|
+
const newSelectedIds = newSelected ? newSelected.map(option => option.value) : [];
|
143
|
+
updateAttribute(attributeName, newSelectedIds);
|
144
|
+
}, [ attributeName ]);
|
145
|
+
|
146
|
+
if (!condition || !taxonomy) return null;
|
147
|
+
|
148
|
+
if (render) {
|
149
|
+
return render({
|
150
|
+
value: selectedOptions,
|
151
|
+
onChange,
|
152
|
+
options: selectOptions,
|
153
|
+
placeholder,
|
154
|
+
disabled,
|
155
|
+
attributeName,
|
156
|
+
});
|
157
|
+
}
|
158
|
+
|
159
|
+
return (
|
160
|
+
<>
|
161
|
+
<Select
|
162
|
+
isMulti
|
163
|
+
options={selectOptions}
|
164
|
+
value={selectedOptions}
|
165
|
+
onChange={onChange}
|
166
|
+
className="react-select-container"
|
167
|
+
classNamePrefix="react-select"
|
168
|
+
placeholder={placeholder}
|
169
|
+
isDisabled={disabled}
|
170
|
+
/>
|
171
|
+
|
172
|
+
<Divider />
|
173
|
+
</>
|
174
|
+
);
|
175
|
+
});
|
176
|
+
|
177
|
+
/**
|
178
|
+
* CuratedPosts component for selecting individual posts
|
179
|
+
*/
|
180
|
+
const CuratedPosts = memo(({
|
181
|
+
condition = true,
|
182
|
+
attributeName = 'curatedPosts',
|
183
|
+
postType = 'posts',
|
184
|
+
placeholder = 'Posts to show',
|
185
|
+
disabled = false,
|
186
|
+
render = null,
|
187
|
+
}) => {
|
188
|
+
const { attributes, updateAttribute } = useDataQueryContext();
|
189
|
+
const curatedPosts = attributes[attributeName] || [];
|
190
|
+
|
191
|
+
const loadPostsOptions = useCallback(async (inputValue) => {
|
192
|
+
return await loadSelectOptions(inputValue, postType);
|
193
|
+
}, []);
|
194
|
+
|
195
|
+
const [ defaultPostsOptions, setDefaultPostsOptions ] = useState([]);
|
196
|
+
|
197
|
+
useEffect(() => {
|
198
|
+
loadSelectOptions('', postType).then(setDefaultPostsOptions);
|
199
|
+
}, []);
|
200
|
+
|
201
|
+
const onSortEnd = useCallback(({ oldIndex, newIndex }) => {
|
202
|
+
const newCuratedPosts = arrayMove(curatedPosts, oldIndex, newIndex);
|
203
|
+
updateAttribute(attributeName, newCuratedPosts);
|
204
|
+
}, [ curatedPosts, attributeName ]);
|
205
|
+
|
206
|
+
const onChange = useCallback((newValue) => {
|
207
|
+
updateAttribute(attributeName, newValue);
|
208
|
+
}, [ attributeName ]);
|
209
|
+
|
210
|
+
if (!condition) return null;
|
211
|
+
|
212
|
+
if (render) {
|
213
|
+
return render({
|
214
|
+
value: curatedPosts,
|
215
|
+
onChange,
|
216
|
+
onSortEnd,
|
217
|
+
loadOptions: loadPostsOptions,
|
218
|
+
defaultOptions: defaultPostsOptions,
|
219
|
+
placeholder,
|
220
|
+
disabled,
|
221
|
+
attributeName,
|
222
|
+
});
|
223
|
+
}
|
224
|
+
|
225
|
+
return (
|
226
|
+
<>
|
227
|
+
<SortableSelectAsync
|
228
|
+
onSortEnd={onSortEnd}
|
229
|
+
value={curatedPosts}
|
230
|
+
defaultOptions={defaultPostsOptions}
|
231
|
+
loadOptions={loadPostsOptions}
|
232
|
+
onChange={onChange}
|
233
|
+
placeholder={placeholder}
|
234
|
+
isDisabled={disabled}
|
235
|
+
/>
|
236
|
+
<Divider />
|
237
|
+
</>
|
238
|
+
);
|
239
|
+
});
|
240
|
+
|
241
|
+
/**
|
242
|
+
* NumberOfPosts component for limiting the number of posts
|
243
|
+
*/
|
244
|
+
const NumberOfPosts = memo(({
|
245
|
+
condition = true,
|
246
|
+
attributeName = 'numberOfPosts',
|
247
|
+
label = 'Number of Posts',
|
248
|
+
min = -1,
|
249
|
+
max = 12,
|
250
|
+
help = 'The maximum number of posts to show (-1 for no limit)',
|
251
|
+
disabled = false,
|
252
|
+
render = null,
|
253
|
+
}) => {
|
254
|
+
const { attributes, updateAttribute } = useDataQueryContext();
|
255
|
+
const numberOfPosts = attributes[attributeName];
|
256
|
+
|
257
|
+
const onChange = useCallback((value) => {
|
258
|
+
updateAttribute(attributeName, value);
|
259
|
+
}, [ attributeName ]);
|
260
|
+
|
261
|
+
if (!condition) return null;
|
262
|
+
|
263
|
+
if (render) {
|
264
|
+
return render({
|
265
|
+
value: numberOfPosts,
|
266
|
+
onChange,
|
267
|
+
min,
|
268
|
+
max,
|
269
|
+
help,
|
270
|
+
disabled,
|
271
|
+
attributeName,
|
272
|
+
});
|
273
|
+
}
|
274
|
+
|
275
|
+
return (
|
276
|
+
<>
|
277
|
+
<RangeControl
|
278
|
+
label={label}
|
279
|
+
value={numberOfPosts}
|
280
|
+
onChange={onChange}
|
281
|
+
min={min}
|
282
|
+
max={max}
|
283
|
+
help={help}
|
284
|
+
disabled={disabled}
|
285
|
+
/>
|
286
|
+
|
287
|
+
<Divider />
|
288
|
+
</>
|
289
|
+
);
|
290
|
+
});
|
291
|
+
|
292
|
+
/**
|
293
|
+
* OrderByControl component for controlling ordering
|
294
|
+
*/
|
295
|
+
const OrderByControl = memo(({
|
296
|
+
condition = true,
|
297
|
+
orderByAttributeName = 'orderBy',
|
298
|
+
orderAttributeName = 'order',
|
299
|
+
disabled = false,
|
300
|
+
orderByOptions = [
|
301
|
+
{ label: 'Date', value: 'date' },
|
302
|
+
{ label: 'Title', value: 'title' },
|
303
|
+
],
|
304
|
+
orderOptions = [
|
305
|
+
{ label: 'Ascending', value: 'asc' },
|
306
|
+
{ label: 'Descending', value: 'desc' },
|
307
|
+
],
|
308
|
+
render = null,
|
309
|
+
}) => {
|
310
|
+
const { attributes, updateAttribute } = useDataQueryContext();
|
311
|
+
const orderBy = attributes[orderByAttributeName] || 'date';
|
312
|
+
const order = attributes[orderAttributeName] || 'desc';
|
313
|
+
|
314
|
+
const onOrderByChange = useCallback((value) => {
|
315
|
+
updateAttribute(orderByAttributeName, value);
|
316
|
+
}, [ orderByAttributeName ]);
|
317
|
+
|
318
|
+
const onOrderChange = useCallback((value) => {
|
319
|
+
updateAttribute(orderAttributeName, value);
|
320
|
+
}, [ orderAttributeName ]);
|
321
|
+
|
322
|
+
if (!condition) return null;
|
323
|
+
|
324
|
+
if (render) {
|
325
|
+
return render({
|
326
|
+
orderBy,
|
327
|
+
order,
|
328
|
+
onOrderByChange,
|
329
|
+
onOrderChange,
|
330
|
+
orderByOptions,
|
331
|
+
orderOptions,
|
332
|
+
disabled,
|
333
|
+
orderByAttributeName,
|
334
|
+
orderAttributeName,
|
335
|
+
});
|
336
|
+
}
|
337
|
+
|
338
|
+
return (
|
339
|
+
<>
|
340
|
+
<SelectControl
|
341
|
+
label="Order By"
|
342
|
+
value={orderBy}
|
343
|
+
options={orderByOptions}
|
344
|
+
onChange={onOrderByChange}
|
345
|
+
disabled={disabled}
|
346
|
+
/>
|
347
|
+
|
348
|
+
<SelectControl
|
349
|
+
label="Order"
|
350
|
+
value={order}
|
351
|
+
options={orderOptions}
|
352
|
+
onChange={onOrderChange}
|
353
|
+
disabled={disabled}
|
354
|
+
/>
|
355
|
+
|
356
|
+
<Divider />
|
357
|
+
</>
|
358
|
+
);
|
359
|
+
});
|
360
|
+
|
361
|
+
DataQueryControls.QueryType = QueryType;
|
362
|
+
DataQueryControls.TaxonomySelect = TaxonomySelect;
|
363
|
+
DataQueryControls.CuratedPosts = CuratedPosts;
|
364
|
+
DataQueryControls.NumberOfPosts = NumberOfPosts;
|
365
|
+
DataQueryControls.OrderBy = OrderByControl;
|
@@ -7,11 +7,12 @@ export const EmptyBlockAppender = (props) => {
|
|
7
7
|
showAppender = true,
|
8
8
|
title = 'This block is empty',
|
9
9
|
text = 'Use the "+" button below to add content blocks',
|
10
|
+
isLight = false,
|
10
11
|
className,
|
11
12
|
} = props;
|
12
13
|
|
13
14
|
return (
|
14
|
-
<div className={classNames('empty-block-appender', className)}>
|
15
|
+
<div className={classNames('empty-block-appender', className, { 'empty-block-appender--light': isLight })}>
|
15
16
|
<div className="empty-block-appender__content">
|
16
17
|
{
|
17
18
|
showIcon && (
|
@@ -4,7 +4,8 @@ import {
|
|
4
4
|
MediaUploadCheck,
|
5
5
|
} from '@wordpress/block-editor';
|
6
6
|
import { Button, Icon } from '@wordpress/components';
|
7
|
-
|
7
|
+
|
8
|
+
import { editIcon, trashIcon } from '../icons/index.jsx';
|
8
9
|
|
9
10
|
export const IconPicker = ({ imageId, imageUrl, imageAlt, svgCode, onSelect, onRemove }) => {
|
10
11
|
const hasImage = imageId && imageUrl;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { BaseControl, Button, FocalPointPicker, Icon as WPIcon } from '@wordpress/components';
|
2
2
|
import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';
|
3
|
-
import { page as pageIcon } from '@wordpress/icons';
|
4
3
|
|
4
|
+
import { pageIcon } from '../icons/index.jsx';
|
5
5
|
import { MEDIA_TYPE } from '../utils/index.js';
|
6
6
|
|
7
7
|
export const ImageRenderer = ({
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { useMemo } from '@wordpress/element';
|
2
2
|
import { SelectControl } from '@wordpress/components';
|
3
3
|
|
4
|
-
import { MediaControl } from './MediaControl.
|
4
|
+
import { MediaControl } from './MediaControl.jsx';
|
5
5
|
import { MEDIA_TYPE_LABEL, MEDIA_TYPE } from '../utils/index.js';
|
6
6
|
|
7
7
|
export const MediaTypeControl = (props) => {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { BaseControl, FocalPointPicker } from '@wordpress/components';
|
2
2
|
import { useCallback, memo } from '@wordpress/element';
|
3
3
|
|
4
|
-
import { MediaControl } from './MediaControl.
|
4
|
+
import { MediaControl } from './MediaControl.jsx';
|
5
5
|
import { MEDIA_TYPE } from '../utils/index.js';
|
6
6
|
|
7
7
|
/**
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { TabPanel } from '@wordpress/components';
|
2
2
|
import { useCallback, useEffect, useState } from '@wordpress/element';
|
3
3
|
|
4
|
-
import { SpacingControl } from './SpacingControl.
|
4
|
+
import { SpacingControl } from './SpacingControl.jsx';
|
5
5
|
|
6
6
|
const getTabName = (deviceType = 'Desktop') => {
|
7
7
|
return deviceType === 'Desktop' ? 'desktop' : 'mobile';
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { RangeControl, Tooltip } from '@wordpress/components';
|
2
2
|
import { useCallback } from '@wordpress/element';
|
3
|
-
|
3
|
+
|
4
|
+
import { sidesBottomIcon, sidesTopIcon } from '../icons/index.jsx';
|
4
5
|
|
5
6
|
const generateMarks = (min, max) => [
|
6
7
|
{ value: min, label: min === -1 ? 'Default' : min.toString() },
|
@@ -77,7 +78,7 @@ export const SpacingControl = ({
|
|
77
78
|
onChange={handleChange('margin', 'top')}
|
78
79
|
disabled={disabledMargin.top}
|
79
80
|
tooltip={marginTooltips.top}
|
80
|
-
afterIcon={
|
81
|
+
afterIcon={sidesTopIcon}
|
81
82
|
withInputField={false}
|
82
83
|
/>
|
83
84
|
|
@@ -89,7 +90,7 @@ export const SpacingControl = ({
|
|
89
90
|
onChange={handleChange('margin', 'bottom')}
|
90
91
|
disabled={disabledMargin.bottom}
|
91
92
|
tooltip={marginTooltips.bottom}
|
92
|
-
afterIcon={
|
93
|
+
afterIcon={sidesBottomIcon}
|
93
94
|
withInputField={false}
|
94
95
|
/>
|
95
96
|
</>
|
@@ -105,7 +106,7 @@ export const SpacingControl = ({
|
|
105
106
|
onChange={handleChange('padding', 'top')}
|
106
107
|
disabled={disabledPadding.top}
|
107
108
|
tooltip={paddingTooltips.top}
|
108
|
-
afterIcon={
|
109
|
+
afterIcon={sidesTopIcon}
|
109
110
|
withInputField={false}
|
110
111
|
/>
|
111
112
|
|
@@ -117,7 +118,7 @@ export const SpacingControl = ({
|
|
117
118
|
onChange={handleChange('padding', 'bottom')}
|
118
119
|
disabled={disabledPadding.bottom}
|
119
120
|
tooltip={paddingTooltips.bottom}
|
120
|
-
afterIcon={
|
121
|
+
afterIcon={sidesBottomIcon}
|
121
122
|
withInputField={false}
|
122
123
|
/>
|
123
124
|
</>
|
package/src/components/index.js
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
export { ColorPaletteControl } from './ColorPaletteControl';
|
2
|
-
export { IconPicker } from './IconPicker';
|
3
|
-
export { ImageActions } from './ImageActions';
|
4
|
-
export { LinkControl } from './LinkControl';
|
5
|
-
export { ImageRenderer, VideoRenderer, AnimationRenderer, MediaControl } from './MediaControl.
|
6
|
-
export { SortableSelect, SortableSelectAsync } from './SortableSelect';
|
7
|
-
export { DataQueryControls } from './DataQueryControls.
|
8
|
-
export { SpacingControl } from './SpacingControl.
|
9
|
-
export { ResponsiveSpacingControl } from './ResponsiveSpacingControl.
|
10
|
-
export { ResourcesWrapper } from './ResourcesWrapper.
|
11
|
-
export { DividersControl } from './DividersControl.
|
12
|
-
export { MediaTypeControl } from './MediaTypeControl.
|
13
|
-
export { InsertBlockToolbar } from './InsertBlockToolbar.
|
14
|
-
export { PreviewControl } from './PreviewControl.
|
15
|
-
export { EmptyBlockAppender } from './EmptyBlockAppender.
|
16
|
-
export { MediaWithFocalPointControl } from './MediaWithFocalPointControl.
|
1
|
+
export { ColorPaletteControl } from './ColorPaletteControl.jsx';
|
2
|
+
export { IconPicker } from './IconPicker.jsx';
|
3
|
+
export { ImageActions } from './ImageActions.jsx';
|
4
|
+
export { LinkControl } from './LinkControl.jsx';
|
5
|
+
export { ImageRenderer, VideoRenderer, AnimationRenderer, MediaControl } from './MediaControl.jsx';
|
6
|
+
export { SortableSelect, SortableSelectAsync } from './SortableSelect.jsx';
|
7
|
+
export { DataQueryControls } from './DataQueryControls.jsx';
|
8
|
+
export { SpacingControl } from './SpacingControl.jsx';
|
9
|
+
export { ResponsiveSpacingControl } from './ResponsiveSpacingControl.jsx';
|
10
|
+
export { ResourcesWrapper } from './ResourcesWrapper.jsx';
|
11
|
+
export { DividersControl } from './DividersControl.jsx';
|
12
|
+
export { MediaTypeControl } from './MediaTypeControl.jsx';
|
13
|
+
export { InsertBlockToolbar } from './InsertBlockToolbar.jsx';
|
14
|
+
export { PreviewControl } from './PreviewControl.jsx';
|
15
|
+
export { EmptyBlockAppender } from './EmptyBlockAppender.jsx';
|
16
|
+
export { MediaWithFocalPointControl } from './MediaWithFocalPointControl.jsx';
|
package/src/hooks/index.js
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
export { usePreviewControl } from './usePreviewControl.
|
1
|
+
export { usePreviewControl } from './usePreviewControl.jsx';
|
2
2
|
export { useSlider } from './useSlider.js';
|
3
3
|
export { useParentBlock } from './useParentBlock.js';
|
4
|
-
export {
|
5
|
-
export {
|
6
|
-
export { useDataQuery } from './useDataQuery';
|
4
|
+
export { useThemeColors } from './useThemeColors.js';
|
5
|
+
export { useDataQuery } from './useDataQuery.js';
|
7
6
|
export { useAccordionItem } from './useAccordionItem.js';
|
8
|
-
export { useTabs } from './useTabs.
|
7
|
+
export { useTabs } from './useTabs.jsx';
|
9
8
|
export { useAllowedBlocks } from './useAllowedBlocks.js';
|
10
9
|
export { useChildBlockPosition } from './useChildBlockPosition.js';
|
11
10
|
export { useFilterBlocks } from './useFilterBlocks.js';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { useEffect, useRef } from '@wordpress/element';
|
1
|
+
import { useCallback, useEffect, useMemo, useRef } from '@wordpress/element';
|
2
2
|
|
3
3
|
export const useAccordionItem = ({
|
4
4
|
itemId,
|
@@ -7,26 +7,26 @@ export const useAccordionItem = ({
|
|
7
7
|
contentSelector,
|
8
8
|
heightObserverDeps = []
|
9
9
|
}) => {
|
10
|
-
const isActive = itemId === activeItemId;
|
10
|
+
const isActive = useMemo(() => itemId === activeItemId, [ itemId, activeItemId ]);
|
11
11
|
const blockRef = useRef(null);
|
12
12
|
|
13
|
-
const openContent = () => {
|
13
|
+
const openContent = useCallback(() => {
|
14
14
|
const content = blockRef.current?.querySelector(contentSelector);
|
15
15
|
if (content) {
|
16
16
|
content.style.maxHeight = content.scrollHeight + 'px';
|
17
17
|
}
|
18
|
-
};
|
18
|
+
}, [ contentSelector ]);
|
19
19
|
|
20
|
-
const closeContent = () => {
|
20
|
+
const closeContent = useCallback(() => {
|
21
21
|
const content = blockRef.current?.querySelector(contentSelector);
|
22
22
|
if (content) {
|
23
23
|
content.style.maxHeight = 0;
|
24
24
|
}
|
25
|
-
};
|
25
|
+
}, [ contentSelector ]);
|
26
26
|
|
27
|
-
const toggleItem = () => {
|
27
|
+
const toggleItem = useCallback(() => {
|
28
28
|
setActiveItemId(isActive ? null : itemId);
|
29
|
-
};
|
29
|
+
}, [ isActive, setActiveItemId ]);
|
30
30
|
|
31
31
|
useEffect(() => {
|
32
32
|
if (isActive) {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { useCallback, useState } from '@wordpress/element';
|
2
|
-
import { PreviewControl } from '../components/PreviewControl.
|
2
|
+
import { PreviewControl } from '../components/PreviewControl.jsx';
|
3
3
|
|
4
4
|
export const usePreviewControl = () => {
|
5
5
|
const [ isPreview, setIsPreview ] = useState(false);
|
@@ -2,10 +2,10 @@ import { useSelect, useDispatch, select } from '@wordpress/data';
|
|
2
2
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
3
3
|
import { useLayoutEffect, useState } from '@wordpress/element';
|
4
4
|
import { Button } from '@wordpress/components';
|
5
|
-
import { plus as plusIcon } from '@wordpress/icons';
|
6
5
|
import { createBlock } from '@wordpress/blocks';
|
7
6
|
|
8
|
-
import {
|
7
|
+
import { plusIcon } from '../icons/index.jsx';
|
8
|
+
import { useParentBlock } from './useParentBlock.js';
|
9
9
|
|
10
10
|
export const useTabs = (tabsClientId, tabItemName) => {
|
11
11
|
const { insertBlock } = useDispatch(blockEditorStore);
|