@wordpress/block-editor 15.6.1-next.36001005c.0 → 15.6.2
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/components/background-image-control/index.js +2 -2
- package/build/components/background-image-control/index.js.map +2 -2
- package/build/components/block-list/block.js +3 -3
- package/build/components/block-list/block.js.map +2 -2
- package/build/components/block-list/index.js +2 -2
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-quick-navigation/index.js +0 -1
- package/build/components/block-quick-navigation/index.js.map +2 -2
- package/build/components/global-styles/border-panel.js +1 -2
- package/build/components/global-styles/border-panel.js.map +2 -2
- package/build/components/global-styles/color-panel.js +1 -2
- package/build/components/global-styles/color-panel.js.map +2 -2
- package/build/components/global-styles/dimensions-panel.js +2 -3
- package/build/components/global-styles/dimensions-panel.js.map +2 -2
- package/build/components/global-styles/filters-panel.js +1 -2
- package/build/components/global-styles/filters-panel.js.map +2 -2
- package/build/components/global-styles/get-block-css-selector.js +78 -0
- package/build/components/global-styles/get-block-css-selector.js.map +7 -0
- package/build/components/global-styles/hooks.js +95 -23
- package/build/components/global-styles/hooks.js.map +2 -2
- package/build/components/global-styles/index.js +14 -0
- package/build/components/global-styles/index.js.map +2 -2
- package/build/components/global-styles/typography-panel.js +19 -3
- package/build/components/global-styles/typography-panel.js.map +2 -2
- package/build/components/global-styles/typography-utils.js +49 -2
- package/build/components/global-styles/typography-utils.js.map +2 -2
- package/build/components/global-styles/use-global-styles-output.js +998 -0
- package/build/components/global-styles/use-global-styles-output.js.map +7 -0
- package/build/components/global-styles/utils.js +377 -0
- package/build/components/global-styles/utils.js.map +2 -2
- package/build/components/rich-text/index.js +8 -7
- package/build/components/rich-text/index.js.map +2 -2
- package/build/hooks/allowed-blocks.js +50 -1
- package/build/hooks/allowed-blocks.js.map +2 -2
- package/build/hooks/block-bindings.js +111 -170
- package/build/hooks/block-bindings.js.map +2 -2
- package/build/hooks/block-style-variation.js +10 -6
- package/build/hooks/block-style-variation.js.map +2 -2
- package/build/hooks/custom-class-name.js +1 -1
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/duotone.js +3 -3
- package/build/hooks/duotone.js.map +2 -2
- package/build/hooks/fit-text.js +33 -20
- package/build/hooks/fit-text.js.map +2 -2
- package/build/hooks/font-size.js +6 -5
- package/build/hooks/font-size.js.map +2 -2
- package/build/hooks/metadata.js +48 -2
- package/build/hooks/metadata.js.map +2 -2
- package/build/hooks/typography.js +11 -4
- package/build/hooks/typography.js.map +3 -3
- package/build/hooks/use-typography-props.js +2 -2
- package/build/hooks/use-typography-props.js.map +2 -2
- package/build/store/private-selectors.js +3 -3
- package/build/store/private-selectors.js.map +2 -2
- package/build/store/selectors.js +38 -13
- package/build/store/selectors.js.map +2 -2
- package/build/store/utils.js +2 -1
- package/build/store/utils.js.map +2 -2
- package/build/utils/fit-text-utils.js +4 -4
- package/build/utils/fit-text-utils.js.map +2 -2
- package/build-module/components/background-image-control/index.js +1 -1
- package/build-module/components/background-image-control/index.js.map +2 -2
- package/build-module/components/block-list/block.js +3 -3
- package/build-module/components/block-list/block.js.map +2 -2
- package/build-module/components/block-list/index.js +2 -2
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +0 -1
- package/build-module/components/block-quick-navigation/index.js.map +2 -2
- package/build-module/components/global-styles/border-panel.js +1 -2
- package/build-module/components/global-styles/border-panel.js.map +2 -2
- package/build-module/components/global-styles/color-panel.js +1 -2
- package/build-module/components/global-styles/color-panel.js.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.js +1 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +2 -2
- package/build-module/components/global-styles/filters-panel.js +1 -2
- package/build-module/components/global-styles/filters-panel.js.map +2 -2
- package/build-module/components/global-styles/get-block-css-selector.js +54 -0
- package/build-module/components/global-styles/get-block-css-selector.js.map +7 -0
- package/build-module/components/global-styles/hooks.js +95 -27
- package/build-module/components/global-styles/hooks.js.map +2 -2
- package/build-module/components/global-styles/index.js +14 -0
- package/build-module/components/global-styles/index.js.map +2 -2
- package/build-module/components/global-styles/typography-panel.js +19 -3
- package/build-module/components/global-styles/typography-panel.js.map +2 -2
- package/build-module/components/global-styles/typography-utils.js +49 -1
- package/build-module/components/global-styles/typography-utils.js.map +2 -2
- package/build-module/components/global-styles/use-global-styles-output.js +979 -0
- package/build-module/components/global-styles/use-global-styles-output.js.map +7 -0
- package/build-module/components/global-styles/utils.js +364 -0
- package/build-module/components/global-styles/utils.js.map +2 -2
- package/build-module/components/rich-text/index.js +8 -7
- package/build-module/components/rich-text/index.js.map +2 -2
- package/build-module/hooks/allowed-blocks.js +49 -1
- package/build-module/hooks/allowed-blocks.js.map +2 -2
- package/build-module/hooks/block-bindings.js +112 -172
- package/build-module/hooks/block-bindings.js.map +2 -2
- package/build-module/hooks/block-style-variation.js +12 -4
- package/build-module/hooks/block-style-variation.js.map +2 -2
- package/build-module/hooks/custom-class-name.js +1 -1
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/duotone.js +3 -3
- package/build-module/hooks/duotone.js.map +2 -2
- package/build-module/hooks/fit-text.js +34 -21
- package/build-module/hooks/fit-text.js.map +2 -2
- package/build-module/hooks/font-size.js +5 -4
- package/build-module/hooks/font-size.js.map +2 -2
- package/build-module/hooks/metadata.js +46 -1
- package/build-module/hooks/metadata.js.map +2 -2
- package/build-module/hooks/typography.js +11 -4
- package/build-module/hooks/typography.js.map +3 -3
- package/build-module/hooks/use-typography-props.js +1 -1
- package/build-module/hooks/use-typography-props.js.map +2 -2
- package/build-module/store/private-selectors.js +2 -2
- package/build-module/store/private-selectors.js.map +2 -2
- package/build-module/store/selectors.js +39 -14
- package/build-module/store/selectors.js.map +2 -2
- package/build-module/store/utils.js +3 -2
- package/build-module/store/utils.js.map +2 -2
- package/build-module/utils/fit-text-utils.js +4 -4
- package/build-module/utils/fit-text-utils.js.map +2 -2
- package/build-style/style-rtl.css +6 -10
- package/build-style/style.css +6 -10
- package/package.json +35 -36
- package/src/components/background-image-control/index.js +1 -1
- package/src/components/block-card/style.scss +1 -1
- package/src/components/block-list/block.js +1 -1
- package/src/components/block-list/index.js +2 -2
- package/src/components/block-navigation/style.scss +1 -1
- package/src/components/block-quick-navigation/index.js +0 -1
- package/src/components/block-switcher/style.scss +1 -1
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/global-styles/border-panel.js +1 -2
- package/src/components/global-styles/color-panel.js +1 -2
- package/src/components/global-styles/color-panel.native.js +1 -1
- package/src/components/global-styles/dimensions-panel.js +1 -2
- package/src/components/global-styles/filters-panel.js +1 -2
- package/src/components/global-styles/get-block-css-selector.js +114 -0
- package/src/components/global-styles/hooks.js +108 -29
- package/src/components/global-styles/index.js +8 -0
- package/src/components/global-styles/test/typography-utils.js +806 -0
- package/src/components/global-styles/test/use-global-styles-output.js +1131 -0
- package/src/components/global-styles/test/utils.js +442 -1
- package/src/components/global-styles/typography-panel.js +27 -3
- package/src/components/global-styles/typography-utils.js +133 -0
- package/src/components/global-styles/use-global-styles-output.js +1487 -0
- package/src/components/global-styles/utils.js +537 -0
- package/src/components/inserter/style.scss +2 -2
- package/src/components/multi-selection-inspector/style.scss +1 -1
- package/src/components/rich-text/index.js +8 -14
- package/src/hooks/allowed-blocks.js +89 -1
- package/src/hooks/block-bindings.js +79 -153
- package/src/hooks/block-style-variation.js +12 -4
- package/src/hooks/custom-class-name.js +1 -1
- package/src/hooks/duotone.js +3 -3
- package/src/hooks/fit-text.js +39 -30
- package/src/hooks/font-size.js +8 -4
- package/src/hooks/metadata.js +89 -0
- package/src/hooks/test/allowed-blocks.js +278 -0
- package/src/hooks/test/metadata.js +316 -0
- package/src/hooks/typography.js +15 -4
- package/src/hooks/use-typography-props.js +1 -1
- package/src/store/private-selectors.js +2 -2
- package/src/store/selectors.js +59 -21
- package/src/store/test/selectors.js +1 -1
- package/src/store/utils.js +2 -1
- package/src/style.scss +0 -1
- package/src/utils/fit-text-utils.js +4 -16
- package/tsconfig.json +0 -1
- package/src/components/block-quick-navigation/style.scss +0 -5
|
@@ -9,11 +9,10 @@ import {
|
|
|
9
9
|
__experimentalToolsPanel as ToolsPanel,
|
|
10
10
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
11
11
|
__experimentalVStack as VStack,
|
|
12
|
-
Modal,
|
|
13
12
|
privateApis as componentsPrivateApis
|
|
14
13
|
} from "@wordpress/components";
|
|
15
14
|
import { useSelect } from "@wordpress/data";
|
|
16
|
-
import { useContext
|
|
15
|
+
import { useContext } from "@wordpress/element";
|
|
17
16
|
import { useViewportMatch } from "@wordpress/compose";
|
|
18
17
|
import { useBlockBindingsUtils } from "../utils/block-bindings";
|
|
19
18
|
import { unlock } from "../lock-unlock";
|
|
@@ -37,12 +36,7 @@ const useToolsPanelDropdownMenuProps = () => {
|
|
|
37
36
|
}
|
|
38
37
|
} : {};
|
|
39
38
|
};
|
|
40
|
-
function BlockBindingsPanelMenuContent({
|
|
41
|
-
attribute,
|
|
42
|
-
binding,
|
|
43
|
-
sources,
|
|
44
|
-
onOpenModal
|
|
45
|
-
}) {
|
|
39
|
+
function BlockBindingsPanelMenuContent({ attribute, binding, sources }) {
|
|
46
40
|
const { clientId } = useBlockEditContext();
|
|
47
41
|
const { updateBlockBindings } = useBlockBindingsUtils();
|
|
48
42
|
const isMobile = useViewportMatch("medium", "<");
|
|
@@ -65,79 +59,66 @@ function BlockBindingsPanelMenuContent({
|
|
|
65
59
|
if (noItemsAvailable) {
|
|
66
60
|
return null;
|
|
67
61
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
children:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
{
|
|
92
|
-
|
|
93
|
-
const isCurrentlySelected = fastDeepEqual(
|
|
94
|
-
binding?.args,
|
|
95
|
-
item.args
|
|
96
|
-
) ?? // Deprecate key dependency in 7.0.
|
|
97
|
-
item.key === binding?.args?.key;
|
|
98
|
-
if (isCurrentlySelected) {
|
|
99
|
-
updateBlockBindings({
|
|
100
|
-
[attribute]: void 0
|
|
101
|
-
});
|
|
102
|
-
} else {
|
|
103
|
-
updateBlockBindings({
|
|
104
|
-
[attribute]: itemBindings
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
name: attribute + "-binding",
|
|
109
|
-
value: values[attribute],
|
|
110
|
-
checked: fastDeepEqual(
|
|
62
|
+
return /* @__PURE__ */ jsxs(
|
|
63
|
+
Menu,
|
|
64
|
+
{
|
|
65
|
+
placement: isMobile ? "bottom-start" : "left-start",
|
|
66
|
+
children: [
|
|
67
|
+
/* @__PURE__ */ jsx(Menu.SubmenuTriggerItem, { children: /* @__PURE__ */ jsx(Menu.ItemLabel, { children: source.label }) }),
|
|
68
|
+
/* @__PURE__ */ jsx(Menu.Popover, { gutter: 8, children: /* @__PURE__ */ jsx(Menu.Group, { children: sourceDataItems.map((item) => {
|
|
69
|
+
const itemBindings = {
|
|
70
|
+
source: sourceKey,
|
|
71
|
+
args: item?.args || {
|
|
72
|
+
key: item.key
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const values = source.getValues({
|
|
76
|
+
select,
|
|
77
|
+
context: blockContext,
|
|
78
|
+
bindings: {
|
|
79
|
+
[attribute]: itemBindings
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return /* @__PURE__ */ jsxs(
|
|
83
|
+
Menu.CheckboxItem,
|
|
84
|
+
{
|
|
85
|
+
onChange: () => {
|
|
86
|
+
const isCurrentlySelected = fastDeepEqual(
|
|
111
87
|
binding?.args,
|
|
112
88
|
item.args
|
|
113
89
|
) ?? // Deprecate key dependency in 7.0.
|
|
114
|
-
item.key === binding?.args?.key
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
90
|
+
item.key === binding?.args?.key;
|
|
91
|
+
if (isCurrentlySelected) {
|
|
92
|
+
updateBlockBindings({
|
|
93
|
+
[attribute]: void 0
|
|
94
|
+
});
|
|
95
|
+
} else {
|
|
96
|
+
updateBlockBindings({
|
|
97
|
+
[attribute]: itemBindings
|
|
98
|
+
});
|
|
99
|
+
}
|
|
119
100
|
},
|
|
120
|
-
|
|
101
|
+
name: attribute + "-binding",
|
|
102
|
+
value: values[attribute],
|
|
103
|
+
checked: fastDeepEqual(
|
|
104
|
+
binding?.args,
|
|
121
105
|
item.args
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
return null;
|
|
106
|
+
) ?? // Deprecate key dependency in 7.0.
|
|
107
|
+
item.key === binding?.args?.key,
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ jsx(Menu.ItemLabel, { children: item?.label }),
|
|
110
|
+
/* @__PURE__ */ jsx(Menu.ItemHelpText, { children: values[attribute] })
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
sourceKey + JSON.stringify(
|
|
114
|
+
item.args
|
|
115
|
+
) || item.key
|
|
116
|
+
);
|
|
117
|
+
}) }) })
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
sourceKey
|
|
121
|
+
);
|
|
141
122
|
}) });
|
|
142
123
|
}
|
|
143
124
|
function BlockBindingsAttribute({ attribute, binding, sources, blockName }) {
|
|
@@ -200,14 +181,10 @@ function EditableBlockBindingsPanelItem({
|
|
|
200
181
|
attribute,
|
|
201
182
|
binding,
|
|
202
183
|
sources,
|
|
203
|
-
setModalState,
|
|
204
184
|
blockName
|
|
205
185
|
}) {
|
|
206
186
|
const { updateBlockBindings } = useBlockBindingsUtils();
|
|
207
187
|
const isMobile = useViewportMatch("medium", "<");
|
|
208
|
-
const handleOpenModal = ({ sourceKey }) => {
|
|
209
|
-
setModalState({ attribute, sourceKey });
|
|
210
|
-
};
|
|
211
188
|
return /* @__PURE__ */ jsx(
|
|
212
189
|
ToolsPanelItem,
|
|
213
190
|
{
|
|
@@ -233,8 +210,7 @@ function EditableBlockBindingsPanelItem({
|
|
|
233
210
|
{
|
|
234
211
|
attribute,
|
|
235
212
|
binding,
|
|
236
|
-
sources
|
|
237
|
-
onOpenModal: handleOpenModal
|
|
213
|
+
sources
|
|
238
214
|
}
|
|
239
215
|
) })
|
|
240
216
|
] })
|
|
@@ -245,10 +221,6 @@ const BlockBindingsPanel = ({ name: blockName, metadata }) => {
|
|
|
245
221
|
const blockContext = useContext(BlockContext);
|
|
246
222
|
const { removeAllBlockBindings } = useBlockBindingsUtils();
|
|
247
223
|
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
248
|
-
const [modalState, setModalState] = useState(null);
|
|
249
|
-
const handleCloseModal = () => {
|
|
250
|
-
setModalState(null);
|
|
251
|
-
};
|
|
252
224
|
const _sources = {};
|
|
253
225
|
const { sources, canUpdateBlockBindings, bindableAttributes } = useSelect(
|
|
254
226
|
(select) => {
|
|
@@ -261,7 +233,7 @@ const BlockBindingsPanel = ({ name: blockName, metadata }) => {
|
|
|
261
233
|
Object.entries(registeredSources).forEach(
|
|
262
234
|
([
|
|
263
235
|
sourceName,
|
|
264
|
-
{
|
|
236
|
+
{ getFieldsList, usesContext, label, getValues }
|
|
265
237
|
]) => {
|
|
266
238
|
const context = {};
|
|
267
239
|
if (usesContext?.length) {
|
|
@@ -269,37 +241,16 @@ const BlockBindingsPanel = ({ name: blockName, metadata }) => {
|
|
|
269
241
|
context[key] = blockContext[key];
|
|
270
242
|
}
|
|
271
243
|
}
|
|
272
|
-
if (
|
|
273
|
-
const
|
|
244
|
+
if (getFieldsList) {
|
|
245
|
+
const fieldsListResult = getFieldsList({
|
|
274
246
|
select,
|
|
275
247
|
context
|
|
276
248
|
});
|
|
277
249
|
_sources[sourceName] = {
|
|
278
|
-
|
|
250
|
+
data: fieldsListResult || [],
|
|
279
251
|
label,
|
|
280
252
|
getValues
|
|
281
253
|
};
|
|
282
|
-
} else if (getFieldsList) {
|
|
283
|
-
const fieldsListResult = getFieldsList({
|
|
284
|
-
select,
|
|
285
|
-
context
|
|
286
|
-
});
|
|
287
|
-
if (fieldsListResult) {
|
|
288
|
-
const data = Object.entries(fieldsListResult).map(
|
|
289
|
-
([key, field]) => ({
|
|
290
|
-
label: field.label || key,
|
|
291
|
-
type: field.type || "string",
|
|
292
|
-
args: { key }
|
|
293
|
-
})
|
|
294
|
-
);
|
|
295
|
-
_sources[sourceName] = {
|
|
296
|
-
mode: "dropdown",
|
|
297
|
-
// Default mode for backward compatibility.
|
|
298
|
-
data,
|
|
299
|
-
label,
|
|
300
|
-
getValues
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
254
|
} else {
|
|
304
255
|
_sources[sourceName] = {
|
|
305
256
|
data: [],
|
|
@@ -325,70 +276,59 @@ const BlockBindingsPanel = ({ name: blockName, metadata }) => {
|
|
|
325
276
|
(source) => source.data && source.data.length > 0
|
|
326
277
|
);
|
|
327
278
|
const readOnly = !canUpdateBlockBindings || !hasCompatibleData;
|
|
328
|
-
const RenderModalContent = sources[modalState?.sourceKey]?.renderModalContent;
|
|
329
279
|
if (bindings === void 0 && !hasCompatibleData) {
|
|
330
280
|
return null;
|
|
331
281
|
}
|
|
332
|
-
return /* @__PURE__ */
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
children:
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
).some(
|
|
352
|
-
(
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
}
|
|
383
|
-
),
|
|
384
|
-
RenderModalContent && /* @__PURE__ */ jsx(Modal, { onRequestClose: handleCloseModal, children: /* @__PURE__ */ jsx(
|
|
385
|
-
RenderModalContent,
|
|
386
|
-
{
|
|
387
|
-
attribute: modalState.attribute,
|
|
388
|
-
closeModal: handleCloseModal
|
|
389
|
-
}
|
|
390
|
-
) })
|
|
391
|
-
] });
|
|
282
|
+
return /* @__PURE__ */ jsx(InspectorControls, { group: "bindings", children: /* @__PURE__ */ jsxs(
|
|
283
|
+
ToolsPanel,
|
|
284
|
+
{
|
|
285
|
+
label: __("Attributes"),
|
|
286
|
+
resetAll: () => {
|
|
287
|
+
removeAllBlockBindings();
|
|
288
|
+
},
|
|
289
|
+
dropdownMenuProps,
|
|
290
|
+
className: "block-editor-bindings__panel",
|
|
291
|
+
children: [
|
|
292
|
+
/* @__PURE__ */ jsx(ItemGroup, { isBordered: true, isSeparated: true, children: bindableAttributes.map((attribute) => {
|
|
293
|
+
const binding = bindings?.[attribute];
|
|
294
|
+
const attributeType = getAttributeType(
|
|
295
|
+
blockName,
|
|
296
|
+
attribute
|
|
297
|
+
);
|
|
298
|
+
const hasCompatibleDataForAttribute = Object.values(
|
|
299
|
+
sources
|
|
300
|
+
).some(
|
|
301
|
+
(source) => source.data?.some(
|
|
302
|
+
(item) => item?.type === attributeType
|
|
303
|
+
)
|
|
304
|
+
);
|
|
305
|
+
const isAttributeReadOnly = readOnly || !hasCompatibleDataForAttribute;
|
|
306
|
+
return isAttributeReadOnly ? /* @__PURE__ */ jsx(
|
|
307
|
+
ReadOnlyBlockBindingsPanelItem,
|
|
308
|
+
{
|
|
309
|
+
attribute,
|
|
310
|
+
binding,
|
|
311
|
+
sources,
|
|
312
|
+
blockName
|
|
313
|
+
},
|
|
314
|
+
attribute
|
|
315
|
+
) : /* @__PURE__ */ jsx(
|
|
316
|
+
EditableBlockBindingsPanelItem,
|
|
317
|
+
{
|
|
318
|
+
attribute,
|
|
319
|
+
binding,
|
|
320
|
+
sources,
|
|
321
|
+
blockName
|
|
322
|
+
},
|
|
323
|
+
attribute
|
|
324
|
+
);
|
|
325
|
+
}) }),
|
|
326
|
+
/* @__PURE__ */ jsx(Text, { as: "div", variant: "muted", children: /* @__PURE__ */ jsx("p", { children: __(
|
|
327
|
+
"Attributes connected to custom fields or other dynamic data."
|
|
328
|
+
) }) })
|
|
329
|
+
]
|
|
330
|
+
}
|
|
331
|
+
) });
|
|
392
332
|
};
|
|
393
333
|
var block_bindings_default = {
|
|
394
334
|
edit: BlockBindingsPanel,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/block-bindings.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { getBlockBindingsSources, getBlockType } from '@wordpress/blocks';\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalText as Text,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalVStack as VStack,\n\tModal,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useContext, useState } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useBlockBindingsUtils } from '../utils/block-bindings';\nimport { unlock } from '../lock-unlock';\nimport InspectorControls from '../components/inspector-controls';\nimport BlockContext from '../components/block-context';\nimport { useBlockEditContext } from '../components/block-edit';\nimport { store as blockEditorStore } from '../store';\n\nconst { Menu } = unlock( componentsPrivateApis );\n\nconst EMPTY_OBJECT = {};\n\n/**\n * Get the normalized attribute type for block bindings.\n * Converts 'rich-text' to 'string' since rich-text is stored as string.\n *\n * @param {string} blockName The block name.\n * @param {string} attribute The attribute name.\n * @return {string} The normalized attribute type.\n */\nconst getAttributeType = ( blockName, attribute ) => {\n\tconst _attributeType =\n\t\tgetBlockType( blockName ).attributes?.[ attribute ]?.type;\n\treturn _attributeType === 'rich-text' ? 'string' : _attributeType;\n};\n\nconst useToolsPanelDropdownMenuProps = () => {\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn ! isMobile\n\t\t? {\n\t\t\t\tpopoverProps: {\n\t\t\t\t\tplacement: 'left-start',\n\t\t\t\t\t// For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px)\n\t\t\t\t\toffset: 259,\n\t\t\t\t},\n\t\t }\n\t\t: {};\n};\n\nfunction BlockBindingsPanelMenuContent( {\n\tattribute,\n\tbinding,\n\tsources,\n\tonOpenModal,\n} ) {\n\tconst { clientId } = useBlockEditContext();\n\tconst { updateBlockBindings } = useBlockBindingsUtils();\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\tconst blockContext = useContext( BlockContext );\n\tconst { attributeType, select } = useSelect(\n\t\t( _select ) => {\n\t\t\tconst { name: blockName } =\n\t\t\t\t_select( blockEditorStore ).getBlock( clientId );\n\t\t\treturn {\n\t\t\t\tattributeType: getAttributeType( blockName, attribute ),\n\t\t\t\tselect: _select,\n\t\t\t};\n\t\t},\n\t\t[ clientId, attribute ]\n\t);\n\treturn (\n\t\t<Menu placement={ isMobile ? 'bottom-start' : 'left-start' }>\n\t\t\t{ Object.entries( sources ).map( ( [ sourceKey, source ] ) => {\n\t\t\t\t// Only show sources that have compatible data for this specific attribute.\n\t\t\t\tconst sourceDataItems = source.data?.filter(\n\t\t\t\t\t( item ) => item?.type === attributeType\n\t\t\t\t);\n\n\t\t\t\tconst noItemsAvailable =\n\t\t\t\t\t! sourceDataItems || sourceDataItems.length === 0;\n\n\t\t\t\tif ( noItemsAvailable ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tif ( source.mode === 'dropdown' ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Menu\n\t\t\t\t\t\t\tkey={ sourceKey }\n\t\t\t\t\t\t\tplacement={\n\t\t\t\t\t\t\t\tisMobile ? 'bottom-start' : 'left-start'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Menu.SubmenuTriggerItem>\n\t\t\t\t\t\t\t\t<Menu.ItemLabel>\n\t\t\t\t\t\t\t\t\t{ source.label }\n\t\t\t\t\t\t\t\t</Menu.ItemLabel>\n\t\t\t\t\t\t\t</Menu.SubmenuTriggerItem>\n\t\t\t\t\t\t\t<Menu.Popover gutter={ 8 }>\n\t\t\t\t\t\t\t\t<Menu.Group>\n\t\t\t\t\t\t\t\t\t{ sourceDataItems.map( ( item ) => {\n\t\t\t\t\t\t\t\t\t\tconst itemBindings = {\n\t\t\t\t\t\t\t\t\t\t\tsource: sourceKey,\n\t\t\t\t\t\t\t\t\t\t\targs: item?.args || {\n\t\t\t\t\t\t\t\t\t\t\t\tkey: item.key,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\tconst values = source.getValues( {\n\t\t\t\t\t\t\t\t\t\t\tselect,\n\t\t\t\t\t\t\t\t\t\t\tcontext: blockContext,\n\t\t\t\t\t\t\t\t\t\t\tbindings: {\n\t\t\t\t\t\t\t\t\t\t\t\t[ attribute ]: itemBindings,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t\t<Menu.CheckboxItem\n\t\t\t\t\t\t\t\t\t\t\t\tkey={\n\t\t\t\t\t\t\t\t\t\t\t\t\tsourceKey +\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\titem.args\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) || item.key\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\tonChange={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tconst isCurrentlySelected =\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfastDeepEqual(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbinding?.args,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\titem.args\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// Deprecate key dependency in 7.0.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\titem.key ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbinding?.args?.key;\n\n\t\t\t\t\t\t\t\t\t\t\t\t\tif ( isCurrentlySelected ) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t// Unset if the same item is selected again.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tupdateBlockBindings( {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[ attribute ]:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tundefined,\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} else {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tupdateBlockBindings( {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[ attribute ]:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\titemBindings,\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}\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\tname={ attribute + '-binding' }\n\t\t\t\t\t\t\t\t\t\t\t\tvalue={ values[ attribute ] }\n\t\t\t\t\t\t\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t\t\t\t\t\t\tfastDeepEqual(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tbinding?.args,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\titem.args\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\t// Deprecate key dependency in 7.0.\n\t\t\t\t\t\t\t\t\t\t\t\t\titem.key ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tbinding?.args?.key\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>\n\t\t\t\t\t\t\t\t\t\t\t\t<Menu.ItemLabel>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ item?.label }\n\t\t\t\t\t\t\t\t\t\t\t\t</Menu.ItemLabel>\n\t\t\t\t\t\t\t\t\t\t\t\t<Menu.ItemHelpText>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ values[ attribute ] }\n\t\t\t\t\t\t\t\t\t\t\t\t</Menu.ItemHelpText>\n\t\t\t\t\t\t\t\t\t\t\t</Menu.CheckboxItem>\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</Menu.Group>\n\t\t\t\t\t\t\t</Menu.Popover>\n\t\t\t\t\t\t</Menu>\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif ( source.mode === 'modal' ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Menu.Item\n\t\t\t\t\t\t\tkey={ sourceKey }\n\t\t\t\t\t\t\tonClick={ () => onOpenModal( { sourceKey } ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Menu.ItemLabel>{ source.label }</Menu.ItemLabel>\n\t\t\t\t\t\t</Menu.Item>\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn null;\n\t\t\t} ) }\n\t\t</Menu>\n\t);\n}\n\nfunction BlockBindingsAttribute( { attribute, binding, sources, blockName } ) {\n\tconst { source: sourceName, args } = binding || {};\n\tconst source = sources?.[ sourceName ];\n\n\tlet displayText;\n\tlet isValid = true;\n\tconst isNotBound = binding === undefined;\n\n\tif ( isNotBound ) {\n\t\t// Check if there are any compatible sources for this attribute type.\n\t\tconst attributeType = getAttributeType( blockName, attribute );\n\n\t\tconst hasCompatibleSources = Object.values( sources ).some( ( src ) =>\n\t\t\tsrc.data?.some( ( item ) => item?.type === attributeType )\n\t\t);\n\n\t\tif ( ! hasCompatibleSources ) {\n\t\t\tdisplayText = __( 'No sources available' );\n\t\t} else {\n\t\t\tdisplayText = __( 'Not connected' );\n\t\t}\n\t\tisValid = true;\n\t} else if ( ! source ) {\n\t\t// If there's a binding but the source is not found, it's invalid.\n\t\tisValid = false;\n\t\tdisplayText = __( 'Source not registered' );\n\t\tif ( Object.keys( sources ).length === 0 ) {\n\t\t\tdisplayText = __( 'No sources available' );\n\t\t}\n\t} else {\n\t\tdisplayText =\n\t\t\tsource.data?.find( ( item ) => fastDeepEqual( item.args, args ) )\n\t\t\t\t?.label ||\n\t\t\tsource.label ||\n\t\t\tsourceName;\n\t}\n\n\treturn (\n\t\t<VStack className=\"block-editor-bindings__item\" spacing={ 0 }>\n\t\t\t<Text truncate>{ attribute }</Text>\n\t\t\t<Text\n\t\t\t\ttruncate\n\t\t\t\tvariant={ isValid ? 'muted' : undefined }\n\t\t\t\tisDestructive={ ! isValid }\n\t\t\t>\n\t\t\t\t{ displayText }\n\t\t\t</Text>\n\t\t</VStack>\n\t);\n}\n\nfunction ReadOnlyBlockBindingsPanelItem( {\n\tattribute,\n\tbinding,\n\tsources,\n\tblockName,\n} ) {\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\n\treturn (\n\t\t<ToolsPanelItem hasValue={ () => !! binding } label={ attribute }>\n\t\t\t<Menu placement={ isMobile ? 'bottom-start' : 'left-start' }>\n\t\t\t\t<Menu.TriggerButton render={ <Item /> } disabled>\n\t\t\t\t\t<BlockBindingsAttribute\n\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\tsources={ sources }\n\t\t\t\t\t\tblockName={ blockName }\n\t\t\t\t\t/>\n\t\t\t\t</Menu.TriggerButton>\n\t\t\t</Menu>\n\t\t</ToolsPanelItem>\n\t);\n}\n\nfunction EditableBlockBindingsPanelItem( {\n\tattribute,\n\tbinding,\n\tsources,\n\tsetModalState,\n\tblockName,\n} ) {\n\tconst { updateBlockBindings } = useBlockBindingsUtils();\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\n\tconst handleOpenModal = ( { sourceKey } ) => {\n\t\tsetModalState( { attribute, sourceKey } );\n\t};\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\thasValue={ () => !! binding }\n\t\t\tlabel={ attribute }\n\t\t\tonDeselect={ () => {\n\t\t\t\tupdateBlockBindings( {\n\t\t\t\t\t[ attribute ]: undefined,\n\t\t\t\t} );\n\t\t\t} }\n\t\t>\n\t\t\t<Menu placement={ isMobile ? 'bottom-start' : 'left-start' }>\n\t\t\t\t<Menu.TriggerButton render={ <Item /> }>\n\t\t\t\t\t<BlockBindingsAttribute\n\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\tsources={ sources }\n\t\t\t\t\t\tblockName={ blockName }\n\t\t\t\t\t/>\n\t\t\t\t</Menu.TriggerButton>\n\t\t\t\t<Menu.Popover gutter={ isMobile ? 8 : 36 }>\n\t\t\t\t\t<BlockBindingsPanelMenuContent\n\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\tsources={ sources }\n\t\t\t\t\t\tonOpenModal={ handleOpenModal }\n\t\t\t\t\t/>\n\t\t\t\t</Menu.Popover>\n\t\t\t</Menu>\n\t\t</ToolsPanelItem>\n\t);\n}\n\nexport const BlockBindingsPanel = ( { name: blockName, metadata } ) => {\n\tconst blockContext = useContext( BlockContext );\n\tconst { removeAllBlockBindings } = useBlockBindingsUtils();\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst [ modalState, setModalState ] = useState( null );\n\n\tconst handleCloseModal = () => {\n\t\tsetModalState( null );\n\t};\n\n\t// Use useSelect to ensure sources are updated whenever there are updates in block context\n\t// or when underlying data changes.\n\t// Still needs a fix regarding _sources scope.\n\tconst _sources = {};\n\tconst { sources, canUpdateBlockBindings, bindableAttributes } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { __experimentalBlockBindingsSupportedAttributes } =\n\t\t\t\tselect( blockEditorStore ).getSettings();\n\t\t\tconst _bindableAttributes =\n\t\t\t\t__experimentalBlockBindingsSupportedAttributes?.[ blockName ];\n\t\t\tif ( ! _bindableAttributes || _bindableAttributes.length === 0 ) {\n\t\t\t\treturn EMPTY_OBJECT;\n\t\t\t}\n\n\t\t\tconst registeredSources = getBlockBindingsSources();\n\t\t\tObject.entries( registeredSources ).forEach(\n\t\t\t\t( [\n\t\t\t\t\tsourceName,\n\t\t\t\t\t{ editorUI, getFieldsList, usesContext, label, getValues },\n\t\t\t\t] ) => {\n\t\t\t\t\t// Populate context.\n\t\t\t\t\tconst context = {};\n\t\t\t\t\tif ( usesContext?.length ) {\n\t\t\t\t\t\tfor ( const key of usesContext ) {\n\t\t\t\t\t\t\tcontext[ key ] = blockContext[ key ];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( editorUI ) {\n\t\t\t\t\t\tconst editorUIResult = editorUI( {\n\t\t\t\t\t\t\tselect,\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t_sources[ sourceName ] = {\n\t\t\t\t\t\t\t...editorUIResult,\n\t\t\t\t\t\t\tlabel,\n\t\t\t\t\t\t\tgetValues,\n\t\t\t\t\t\t};\n\t\t\t\t\t} else if ( getFieldsList ) {\n\t\t\t\t\t\t// Backward compatibility: Convert getFieldsList to editorUI format.\n\t\t\t\t\t\tconst fieldsListResult = getFieldsList( {\n\t\t\t\t\t\t\tselect,\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tif ( fieldsListResult ) {\n\t\t\t\t\t\t\tconst data = Object.entries( fieldsListResult ).map(\n\t\t\t\t\t\t\t\t( [ key, field ] ) => ( {\n\t\t\t\t\t\t\t\t\tlabel: field.label || key,\n\t\t\t\t\t\t\t\t\ttype: field.type || 'string',\n\t\t\t\t\t\t\t\t\targs: { key },\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t_sources[ sourceName ] = {\n\t\t\t\t\t\t\t\tmode: 'dropdown', // Default mode for backward compatibility.\n\t\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\t\tlabel,\n\t\t\t\t\t\t\t\tgetValues,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t/*\n\t\t\t\t\t\t * Include sources without editorUI if they are already used in a binding.\n\t\t\t\t\t\t * This allows them to be displayed in read-only mode.\n\t\t\t\t\t\t */\n\t\t\t\t\t\t_sources[ sourceName ] = {\n\t\t\t\t\t\t\tdata: [],\n\t\t\t\t\t\t\tlabel,\n\t\t\t\t\t\t\tgetValues,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tsources:\n\t\t\t\t\tObject.values( _sources ).length > 0\n\t\t\t\t\t\t? _sources\n\t\t\t\t\t\t: EMPTY_OBJECT,\n\t\t\t\tcanUpdateBlockBindings:\n\t\t\t\t\tselect( blockEditorStore ).getSettings()\n\t\t\t\t\t\t.canUpdateBlockBindings,\n\t\t\t\tbindableAttributes: _bindableAttributes,\n\t\t\t};\n\t\t},\n\t\t[ blockContext, blockName ]\n\t);\n\t// Return early if there are no bindable attributes.\n\tif ( ! bindableAttributes || bindableAttributes.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst { bindings } = metadata || {};\n\n\t// Check if all sources have empty data arrays.\n\tconst hasCompatibleData = Object.values( sources ).some(\n\t\t( source ) => source.data && source.data.length > 0\n\t);\n\n\t// Lock the UI when the user can't update bindings or there are no fields to connect to.\n\tconst readOnly = ! canUpdateBlockBindings || ! hasCompatibleData;\n\n\tconst RenderModalContent =\n\t\tsources[ modalState?.sourceKey ]?.renderModalContent;\n\n\tif ( bindings === undefined && ! hasCompatibleData ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"bindings\">\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Attributes' ) }\n\t\t\t\tresetAll={ () => {\n\t\t\t\t\tremoveAllBlockBindings();\n\t\t\t\t} }\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\tclassName=\"block-editor-bindings__panel\"\n\t\t\t>\n\t\t\t\t<ItemGroup isBordered isSeparated>\n\t\t\t\t\t{ bindableAttributes.map( ( attribute ) => {\n\t\t\t\t\t\tconst binding = bindings?.[ attribute ];\n\n\t\t\t\t\t\t// Check if this specific attribute has compatible data from any source.\n\t\t\t\t\t\tconst attributeType = getAttributeType(\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tattribute\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst hasCompatibleDataForAttribute = Object.values(\n\t\t\t\t\t\t\tsources\n\t\t\t\t\t\t).some( ( source ) =>\n\t\t\t\t\t\t\tsource.data?.some(\n\t\t\t\t\t\t\t\t( item ) => item?.type === attributeType\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst isAttributeReadOnly =\n\t\t\t\t\t\t\treadOnly || ! hasCompatibleDataForAttribute;\n\n\t\t\t\t\t\treturn isAttributeReadOnly ? (\n\t\t\t\t\t\t\t<ReadOnlyBlockBindingsPanelItem\n\t\t\t\t\t\t\t\tkey={ attribute }\n\t\t\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\t\t\tsources={ sources }\n\t\t\t\t\t\t\t\tblockName={ blockName }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<EditableBlockBindingsPanelItem\n\t\t\t\t\t\t\t\tkey={ attribute }\n\t\t\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\t\t\tsources={ sources }\n\t\t\t\t\t\t\t\tsetModalState={ setModalState }\n\t\t\t\t\t\t\t\tblockName={ blockName }\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</ItemGroup>\n\t\t\t\t{ /*\n\t\t\t\t\tUse a div element to make the ToolsPanelHiddenInnerWrapper\n\t\t\t\t\ttoggle the visibility of this help text automatically.\n\t\t\t\t*/ }\n\t\t\t\t<Text as=\"div\" variant=\"muted\">\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Attributes connected to custom fields or other dynamic data.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t</Text>\n\t\t\t</ToolsPanel>\n\t\t\t{ RenderModalContent && (\n\t\t\t\t<Modal onRequestClose={ handleCloseModal }>\n\t\t\t\t\t<RenderModalContent\n\t\t\t\t\t\tattribute={ modalState.attribute }\n\t\t\t\t\t\tcloseModal={ handleCloseModal }\n\t\t\t\t\t/>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n};\n\nexport default {\n\tedit: BlockBindingsPanel,\n\tattributeKeys: [ 'metadata' ],\n\thasSupport() {\n\t\treturn true;\n\t},\n};\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { getBlockBindingsSources, getBlockType } from '@wordpress/blocks';\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalText as Text,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalVStack as VStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useContext } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useBlockBindingsUtils } from '../utils/block-bindings';\nimport { unlock } from '../lock-unlock';\nimport InspectorControls from '../components/inspector-controls';\nimport BlockContext from '../components/block-context';\nimport { useBlockEditContext } from '../components/block-edit';\nimport { store as blockEditorStore } from '../store';\n\nconst { Menu } = unlock( componentsPrivateApis );\n\nconst EMPTY_OBJECT = {};\n\n/**\n * Get the normalized attribute type for block bindings.\n * Converts 'rich-text' to 'string' since rich-text is stored as string.\n *\n * @param {string} blockName The block name.\n * @param {string} attribute The attribute name.\n * @return {string} The normalized attribute type.\n */\nconst getAttributeType = ( blockName, attribute ) => {\n\tconst _attributeType =\n\t\tgetBlockType( blockName ).attributes?.[ attribute ]?.type;\n\treturn _attributeType === 'rich-text' ? 'string' : _attributeType;\n};\n\nconst useToolsPanelDropdownMenuProps = () => {\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn ! isMobile\n\t\t? {\n\t\t\t\tpopoverProps: {\n\t\t\t\t\tplacement: 'left-start',\n\t\t\t\t\t// For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px)\n\t\t\t\t\toffset: 259,\n\t\t\t\t},\n\t\t }\n\t\t: {};\n};\n\nfunction BlockBindingsPanelMenuContent( { attribute, binding, sources } ) {\n\tconst { clientId } = useBlockEditContext();\n\tconst { updateBlockBindings } = useBlockBindingsUtils();\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\tconst blockContext = useContext( BlockContext );\n\tconst { attributeType, select } = useSelect(\n\t\t( _select ) => {\n\t\t\tconst { name: blockName } =\n\t\t\t\t_select( blockEditorStore ).getBlock( clientId );\n\t\t\treturn {\n\t\t\t\tattributeType: getAttributeType( blockName, attribute ),\n\t\t\t\tselect: _select,\n\t\t\t};\n\t\t},\n\t\t[ clientId, attribute ]\n\t);\n\treturn (\n\t\t<Menu placement={ isMobile ? 'bottom-start' : 'left-start' }>\n\t\t\t{ Object.entries( sources ).map( ( [ sourceKey, source ] ) => {\n\t\t\t\t// Only show sources that have compatible data for this specific attribute.\n\t\t\t\tconst sourceDataItems = source.data?.filter(\n\t\t\t\t\t( item ) => item?.type === attributeType\n\t\t\t\t);\n\n\t\t\t\tconst noItemsAvailable =\n\t\t\t\t\t! sourceDataItems || sourceDataItems.length === 0;\n\n\t\t\t\tif ( noItemsAvailable ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<Menu\n\t\t\t\t\t\tkey={ sourceKey }\n\t\t\t\t\t\tplacement={ isMobile ? 'bottom-start' : 'left-start' }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Menu.SubmenuTriggerItem>\n\t\t\t\t\t\t\t<Menu.ItemLabel>{ source.label }</Menu.ItemLabel>\n\t\t\t\t\t\t</Menu.SubmenuTriggerItem>\n\t\t\t\t\t\t<Menu.Popover gutter={ 8 }>\n\t\t\t\t\t\t\t<Menu.Group>\n\t\t\t\t\t\t\t\t{ sourceDataItems.map( ( item ) => {\n\t\t\t\t\t\t\t\t\tconst itemBindings = {\n\t\t\t\t\t\t\t\t\t\tsource: sourceKey,\n\t\t\t\t\t\t\t\t\t\targs: item?.args || {\n\t\t\t\t\t\t\t\t\t\t\tkey: item.key,\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\tconst values = source.getValues( {\n\t\t\t\t\t\t\t\t\t\tselect,\n\t\t\t\t\t\t\t\t\t\tcontext: blockContext,\n\t\t\t\t\t\t\t\t\t\tbindings: {\n\t\t\t\t\t\t\t\t\t\t\t[ attribute ]: itemBindings,\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\treturn (\n\t\t\t\t\t\t\t\t\t\t<Menu.CheckboxItem\n\t\t\t\t\t\t\t\t\t\t\tkey={\n\t\t\t\t\t\t\t\t\t\t\t\tsourceKey +\n\t\t\t\t\t\t\t\t\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\titem.args\n\t\t\t\t\t\t\t\t\t\t\t\t\t) || item.key\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\tconst isCurrentlySelected =\n\t\t\t\t\t\t\t\t\t\t\t\t\tfastDeepEqual(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tbinding?.args,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\titem.args\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\t// Deprecate key dependency in 7.0.\n\t\t\t\t\t\t\t\t\t\t\t\t\titem.key ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tbinding?.args?.key;\n\n\t\t\t\t\t\t\t\t\t\t\t\tif ( isCurrentlySelected ) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t// Unset if the same item is selected again.\n\t\t\t\t\t\t\t\t\t\t\t\t\tupdateBlockBindings( {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[ attribute ]:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tundefined,\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} else {\n\t\t\t\t\t\t\t\t\t\t\t\t\tupdateBlockBindings( {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[ attribute ]:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\titemBindings,\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} }\n\t\t\t\t\t\t\t\t\t\t\tname={ attribute + '-binding' }\n\t\t\t\t\t\t\t\t\t\t\tvalue={ values[ attribute ] }\n\t\t\t\t\t\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t\t\t\t\t\tfastDeepEqual(\n\t\t\t\t\t\t\t\t\t\t\t\t\tbinding?.args,\n\t\t\t\t\t\t\t\t\t\t\t\t\titem.args\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// Deprecate key dependency in 7.0.\n\t\t\t\t\t\t\t\t\t\t\t\titem.key === binding?.args?.key\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<Menu.ItemLabel>\n\t\t\t\t\t\t\t\t\t\t\t\t{ item?.label }\n\t\t\t\t\t\t\t\t\t\t\t</Menu.ItemLabel>\n\t\t\t\t\t\t\t\t\t\t\t<Menu.ItemHelpText>\n\t\t\t\t\t\t\t\t\t\t\t\t{ values[ attribute ] }\n\t\t\t\t\t\t\t\t\t\t\t</Menu.ItemHelpText>\n\t\t\t\t\t\t\t\t\t\t</Menu.CheckboxItem>\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</Menu.Group>\n\t\t\t\t\t\t</Menu.Popover>\n\t\t\t\t\t</Menu>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Menu>\n\t);\n}\n\nfunction BlockBindingsAttribute( { attribute, binding, sources, blockName } ) {\n\tconst { source: sourceName, args } = binding || {};\n\tconst source = sources?.[ sourceName ];\n\n\tlet displayText;\n\tlet isValid = true;\n\tconst isNotBound = binding === undefined;\n\n\tif ( isNotBound ) {\n\t\t// Check if there are any compatible sources for this attribute type.\n\t\tconst attributeType = getAttributeType( blockName, attribute );\n\n\t\tconst hasCompatibleSources = Object.values( sources ).some( ( src ) =>\n\t\t\tsrc.data?.some( ( item ) => item?.type === attributeType )\n\t\t);\n\n\t\tif ( ! hasCompatibleSources ) {\n\t\t\tdisplayText = __( 'No sources available' );\n\t\t} else {\n\t\t\tdisplayText = __( 'Not connected' );\n\t\t}\n\t\tisValid = true;\n\t} else if ( ! source ) {\n\t\t// If there's a binding but the source is not found, it's invalid.\n\t\tisValid = false;\n\t\tdisplayText = __( 'Source not registered' );\n\t\tif ( Object.keys( sources ).length === 0 ) {\n\t\t\tdisplayText = __( 'No sources available' );\n\t\t}\n\t} else {\n\t\tdisplayText =\n\t\t\tsource.data?.find( ( item ) => fastDeepEqual( item.args, args ) )\n\t\t\t\t?.label ||\n\t\t\tsource.label ||\n\t\t\tsourceName;\n\t}\n\n\treturn (\n\t\t<VStack className=\"block-editor-bindings__item\" spacing={ 0 }>\n\t\t\t<Text truncate>{ attribute }</Text>\n\t\t\t<Text\n\t\t\t\ttruncate\n\t\t\t\tvariant={ isValid ? 'muted' : undefined }\n\t\t\t\tisDestructive={ ! isValid }\n\t\t\t>\n\t\t\t\t{ displayText }\n\t\t\t</Text>\n\t\t</VStack>\n\t);\n}\n\nfunction ReadOnlyBlockBindingsPanelItem( {\n\tattribute,\n\tbinding,\n\tsources,\n\tblockName,\n} ) {\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\n\treturn (\n\t\t<ToolsPanelItem hasValue={ () => !! binding } label={ attribute }>\n\t\t\t<Menu placement={ isMobile ? 'bottom-start' : 'left-start' }>\n\t\t\t\t<Menu.TriggerButton render={ <Item /> } disabled>\n\t\t\t\t\t<BlockBindingsAttribute\n\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\tsources={ sources }\n\t\t\t\t\t\tblockName={ blockName }\n\t\t\t\t\t/>\n\t\t\t\t</Menu.TriggerButton>\n\t\t\t</Menu>\n\t\t</ToolsPanelItem>\n\t);\n}\n\nfunction EditableBlockBindingsPanelItem( {\n\tattribute,\n\tbinding,\n\tsources,\n\tblockName,\n} ) {\n\tconst { updateBlockBindings } = useBlockBindingsUtils();\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\thasValue={ () => !! binding }\n\t\t\tlabel={ attribute }\n\t\t\tonDeselect={ () => {\n\t\t\t\tupdateBlockBindings( {\n\t\t\t\t\t[ attribute ]: undefined,\n\t\t\t\t} );\n\t\t\t} }\n\t\t>\n\t\t\t<Menu placement={ isMobile ? 'bottom-start' : 'left-start' }>\n\t\t\t\t<Menu.TriggerButton render={ <Item /> }>\n\t\t\t\t\t<BlockBindingsAttribute\n\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\tsources={ sources }\n\t\t\t\t\t\tblockName={ blockName }\n\t\t\t\t\t/>\n\t\t\t\t</Menu.TriggerButton>\n\t\t\t\t<Menu.Popover gutter={ isMobile ? 8 : 36 }>\n\t\t\t\t\t<BlockBindingsPanelMenuContent\n\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\tsources={ sources }\n\t\t\t\t\t/>\n\t\t\t\t</Menu.Popover>\n\t\t\t</Menu>\n\t\t</ToolsPanelItem>\n\t);\n}\n\nexport const BlockBindingsPanel = ( { name: blockName, metadata } ) => {\n\tconst blockContext = useContext( BlockContext );\n\tconst { removeAllBlockBindings } = useBlockBindingsUtils();\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\t// Use useSelect to ensure sources are updated whenever there are updates in block context\n\t// or when underlying data changes.\n\t// Still needs a fix regarding _sources scope.\n\tconst _sources = {};\n\tconst { sources, canUpdateBlockBindings, bindableAttributes } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { __experimentalBlockBindingsSupportedAttributes } =\n\t\t\t\tselect( blockEditorStore ).getSettings();\n\t\t\tconst _bindableAttributes =\n\t\t\t\t__experimentalBlockBindingsSupportedAttributes?.[ blockName ];\n\t\t\tif ( ! _bindableAttributes || _bindableAttributes.length === 0 ) {\n\t\t\t\treturn EMPTY_OBJECT;\n\t\t\t}\n\n\t\t\tconst registeredSources = getBlockBindingsSources();\n\t\t\tObject.entries( registeredSources ).forEach(\n\t\t\t\t( [\n\t\t\t\t\tsourceName,\n\t\t\t\t\t{ getFieldsList, usesContext, label, getValues },\n\t\t\t\t] ) => {\n\t\t\t\t\t// Populate context.\n\t\t\t\t\tconst context = {};\n\t\t\t\t\tif ( usesContext?.length ) {\n\t\t\t\t\t\tfor ( const key of usesContext ) {\n\t\t\t\t\t\t\tcontext[ key ] = blockContext[ key ];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif ( getFieldsList ) {\n\t\t\t\t\t\tconst fieldsListResult = getFieldsList( {\n\t\t\t\t\t\t\tselect,\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\t_sources[ sourceName ] = {\n\t\t\t\t\t\t\tdata: fieldsListResult || [],\n\t\t\t\t\t\t\tlabel,\n\t\t\t\t\t\t\tgetValues,\n\t\t\t\t\t\t};\n\t\t\t\t\t} else {\n\t\t\t\t\t\t/*\n\t\t\t\t\t\t * Include sources without getFieldsList if they are already used in a binding.\n\t\t\t\t\t\t * This allows them to be displayed in read-only mode.\n\t\t\t\t\t\t */\n\t\t\t\t\t\t_sources[ sourceName ] = {\n\t\t\t\t\t\t\tdata: [],\n\t\t\t\t\t\t\tlabel,\n\t\t\t\t\t\t\tgetValues,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tsources:\n\t\t\t\t\tObject.values( _sources ).length > 0\n\t\t\t\t\t\t? _sources\n\t\t\t\t\t\t: EMPTY_OBJECT,\n\t\t\t\tcanUpdateBlockBindings:\n\t\t\t\t\tselect( blockEditorStore ).getSettings()\n\t\t\t\t\t\t.canUpdateBlockBindings,\n\t\t\t\tbindableAttributes: _bindableAttributes,\n\t\t\t};\n\t\t},\n\t\t[ blockContext, blockName ]\n\t);\n\t// Return early if there are no bindable attributes.\n\tif ( ! bindableAttributes || bindableAttributes.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst { bindings } = metadata || {};\n\n\t// Check if all sources have empty data arrays.\n\tconst hasCompatibleData = Object.values( sources ).some(\n\t\t( source ) => source.data && source.data.length > 0\n\t);\n\n\t// Lock the UI when the user can't update bindings or there are no fields to connect to.\n\tconst readOnly = ! canUpdateBlockBindings || ! hasCompatibleData;\n\n\tif ( bindings === undefined && ! hasCompatibleData ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"bindings\">\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Attributes' ) }\n\t\t\t\tresetAll={ () => {\n\t\t\t\t\tremoveAllBlockBindings();\n\t\t\t\t} }\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\tclassName=\"block-editor-bindings__panel\"\n\t\t\t>\n\t\t\t\t<ItemGroup isBordered isSeparated>\n\t\t\t\t\t{ bindableAttributes.map( ( attribute ) => {\n\t\t\t\t\t\tconst binding = bindings?.[ attribute ];\n\n\t\t\t\t\t\t// Check if this specific attribute has compatible data from any source.\n\t\t\t\t\t\tconst attributeType = getAttributeType(\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tattribute\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst hasCompatibleDataForAttribute = Object.values(\n\t\t\t\t\t\t\tsources\n\t\t\t\t\t\t).some( ( source ) =>\n\t\t\t\t\t\t\tsource.data?.some(\n\t\t\t\t\t\t\t\t( item ) => item?.type === attributeType\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst isAttributeReadOnly =\n\t\t\t\t\t\t\treadOnly || ! hasCompatibleDataForAttribute;\n\n\t\t\t\t\t\treturn isAttributeReadOnly ? (\n\t\t\t\t\t\t\t<ReadOnlyBlockBindingsPanelItem\n\t\t\t\t\t\t\t\tkey={ attribute }\n\t\t\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\t\t\tsources={ sources }\n\t\t\t\t\t\t\t\tblockName={ blockName }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<EditableBlockBindingsPanelItem\n\t\t\t\t\t\t\t\tkey={ attribute }\n\t\t\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t\t\t\tbinding={ binding }\n\t\t\t\t\t\t\t\tsources={ sources }\n\t\t\t\t\t\t\t\tblockName={ blockName }\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</ItemGroup>\n\t\t\t\t{ /*\n\t\t\t\t\tUse a div element to make the ToolsPanelHiddenInnerWrapper\n\t\t\t\t\ttoggle the visibility of this help text automatically.\n\t\t\t\t*/ }\n\t\t\t\t<Text as=\"div\" variant=\"muted\">\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Attributes connected to custom fields or other dynamic data.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t</Text>\n\t\t\t</ToolsPanel>\n\t\t</InspectorControls>\n\t);\n};\n\nexport default {\n\tedit: BlockBindingsPanel,\n\tattributeKeys: [ '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AAAA,QAKA,oBAAC,QAAK,IAAG,OAAM,SAAQ,SACtB,8BAAC,OACE;AAAA,UACD;AAAA,QACD,GACD,GACD;AAAA;AAAA;AAAA,EACD,GACD;AAEF;AAEA,IAAO,yBAAQ;AAAA,EACd,MAAM;AAAA,EACN,eAAe,CAAE,UAAW;AAAA,EAC5B,aAAa;AACZ,WAAO;AAAA,EACR;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,8 +2,11 @@ import { Fragment, jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { getBlockTypes, store as blocksStore } from "@wordpress/blocks";
|
|
3
3
|
import { useSelect } from "@wordpress/data";
|
|
4
4
|
import { useContext, useMemo } from "@wordpress/element";
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
GlobalStylesContext,
|
|
7
|
+
toStyles,
|
|
8
|
+
getBlockSelectors
|
|
9
|
+
} from "../components/global-styles";
|
|
7
10
|
import { usePrivateStyleOverride } from "./utils";
|
|
8
11
|
import { getValueFromObjectPath } from "../utils/object";
|
|
9
12
|
import { store as blockEditorStore } from "../store";
|
|
@@ -80,6 +83,7 @@ function __unstableBlockStyleVariationOverridesWithConfig({ config }) {
|
|
|
80
83
|
};
|
|
81
84
|
const blockSelectors = getBlockSelectors(
|
|
82
85
|
getBlockTypes(),
|
|
86
|
+
getBlockStyles,
|
|
83
87
|
override.clientId
|
|
84
88
|
);
|
|
85
89
|
const hasBlockGapSupport = false;
|
|
@@ -220,7 +224,11 @@ function useBlockProps({ name, className, clientId }) {
|
|
|
220
224
|
return;
|
|
221
225
|
}
|
|
222
226
|
const variationConfig = { settings, styles };
|
|
223
|
-
const blockSelectors = getBlockSelectors(
|
|
227
|
+
const blockSelectors = getBlockSelectors(
|
|
228
|
+
getBlockTypes(),
|
|
229
|
+
getBlockStyles,
|
|
230
|
+
clientId
|
|
231
|
+
);
|
|
224
232
|
const hasBlockGapSupport = false;
|
|
225
233
|
const hasFallbackGapSupport = true;
|
|
226
234
|
const disableLayoutStyles = true;
|
|
@@ -242,7 +250,7 @@ function useBlockProps({ name, className, clientId }) {
|
|
|
242
250
|
variationStyles: true
|
|
243
251
|
}
|
|
244
252
|
);
|
|
245
|
-
}, [variation, settings, styles, clientId]);
|
|
253
|
+
}, [variation, settings, styles, getBlockStyles, clientId]);
|
|
246
254
|
usePrivateStyleOverride({
|
|
247
255
|
id: `variation-${clientId}`,
|
|
248
256
|
css: variationStyles,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/block-style-variation.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getBlockTypes, store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useContext, useMemo } from '@wordpress/element';\nimport { toStyles, getBlockSelectors } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport { GlobalStylesContext } from '../components/global-styles';\nimport { usePrivateStyleOverride } from './utils';\nimport { getValueFromObjectPath } from '../utils/object';\nimport { store as blockEditorStore } from '../store';\nimport { globalStylesDataKey } from '../store/private-keys';\nimport { unlock } from '../lock-unlock';\n\nconst VARIATION_PREFIX = 'is-style-';\n\nfunction getVariationMatches( className ) {\n\tif ( ! className ) {\n\t\treturn [];\n\t}\n\treturn className.split( /\\s+/ ).reduce( ( matches, name ) => {\n\t\tif ( name.startsWith( VARIATION_PREFIX ) ) {\n\t\t\tconst match = name.slice( VARIATION_PREFIX.length );\n\t\t\tif ( match !== 'default' ) {\n\t\t\t\tmatches.push( match );\n\t\t\t}\n\t\t}\n\t\treturn matches;\n\t}, [] );\n}\n\n/**\n * Get the first block style variation that has been registered from the class string.\n *\n * @param {string} className CSS class string for a block.\n * @param {Array} registeredStyles Currently registered block styles.\n *\n * @return {string|null} The name of the first registered variation.\n */\nfunction getVariationNameFromClass( className, registeredStyles = [] ) {\n\t// The global flag affects how capturing groups work in JS. So the regex\n\t// below will only return full CSS classes not just the variation name.\n\tconst matches = getVariationMatches( className );\n\n\tif ( ! matches ) {\n\t\treturn null;\n\t}\n\n\tfor ( const variation of matches ) {\n\t\tif ( registeredStyles.some( ( style ) => style.name === variation ) ) {\n\t\t\treturn variation;\n\t\t}\n\t}\n\treturn null;\n}\n\n// A helper component to apply a style override using the useStyleOverride hook.\nfunction OverrideStyles( { override } ) {\n\tusePrivateStyleOverride( override );\n}\n\n/**\n * This component is used to generate new block style variation overrides\n * based on an incoming theme config. If a matching style is found in the config,\n * a new override is created and returned. The overrides can be used in conjunction with\n * useStyleOverride to apply the new styles to the editor. Its use is\n * subject to change.\n *\n * @param {Object} props Props.\n * @param {Object} props.config A global styles object, containing settings and styles.\n * @return {JSX.Element|undefined} An array of new block variation overrides.\n */\nexport function __unstableBlockStyleVariationOverridesWithConfig( { config } ) {\n\tconst { getBlockStyles, overrides } = useSelect(\n\t\t( select ) => ( {\n\t\t\tgetBlockStyles: select( blocksStore ).getBlockStyles,\n\t\t\toverrides: unlock( select( blockEditorStore ) ).getStyleOverrides(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { getBlockName } = useSelect( blockEditorStore );\n\n\tconst overridesWithConfig = useMemo( () => {\n\t\tif ( ! overrides?.length ) {\n\t\t\treturn;\n\t\t}\n\t\tconst newOverrides = [];\n\t\tconst overriddenClientIds = [];\n\t\tfor ( const [ , override ] of overrides ) {\n\t\t\tif (\n\t\t\t\toverride?.variation &&\n\t\t\t\toverride?.clientId &&\n\t\t\t\t/*\n\t\t\t\t * Because this component overwrites existing style overrides,\n\t\t\t\t * filter out any overrides that are already present in the store.\n\t\t\t\t */\n\t\t\t\t! overriddenClientIds.includes( override.clientId )\n\t\t\t) {\n\t\t\t\tconst blockName = getBlockName( override.clientId );\n\t\t\t\tconst configStyles =\n\t\t\t\t\tconfig?.styles?.blocks?.[ blockName ]?.variations?.[\n\t\t\t\t\t\toverride.variation\n\t\t\t\t\t];\n\t\t\t\tif ( configStyles ) {\n\t\t\t\t\tconst variationConfig = {\n\t\t\t\t\t\tsettings: config?.settings,\n\t\t\t\t\t\t// The variation style data is all that is needed to generate\n\t\t\t\t\t\t// the styles for the current application to a block. The variation\n\t\t\t\t\t\t// name is updated to match the instance specific class name.\n\t\t\t\t\t\tstyles: {\n\t\t\t\t\t\t\tblocks: {\n\t\t\t\t\t\t\t\t[ blockName ]: {\n\t\t\t\t\t\t\t\t\tvariations: {\n\t\t\t\t\t\t\t\t\t\t[ `${ override.variation }-${ override.clientId }` ]:\n\t\t\t\t\t\t\t\t\t\t\tconfigStyles,\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};\n\t\t\t\t\tconst blockSelectors = getBlockSelectors(\n\t\t\t\t\t\tgetBlockTypes(),\n\t\t\t\t\t\toverride.clientId\n\t\t\t\t\t);\n\t\t\t\t\tconst hasBlockGapSupport = false;\n\t\t\t\t\tconst hasFallbackGapSupport = true;\n\t\t\t\t\tconst disableLayoutStyles = true;\n\t\t\t\t\tconst disableRootPadding = true;\n\t\t\t\t\tconst variationStyles = toStyles(\n\t\t\t\t\t\tvariationConfig,\n\t\t\t\t\t\tblockSelectors,\n\t\t\t\t\t\thasBlockGapSupport,\n\t\t\t\t\t\thasFallbackGapSupport,\n\t\t\t\t\t\tdisableLayoutStyles,\n\t\t\t\t\t\tdisableRootPadding,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tblockGap: false,\n\t\t\t\t\t\t\tblockStyles: true,\n\t\t\t\t\t\t\tlayoutStyles: false,\n\t\t\t\t\t\t\tmarginReset: false,\n\t\t\t\t\t\t\tpresets: false,\n\t\t\t\t\t\t\trootPadding: false,\n\t\t\t\t\t\t\tvariationStyles: true,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tnewOverrides.push( {\n\t\t\t\t\t\tid: `${ override.variation }-${ override.clientId }`,\n\t\t\t\t\t\tcss: variationStyles,\n\t\t\t\t\t\t__unstableType: 'variation',\n\t\t\t\t\t\tvariation: override.variation,\n\t\t\t\t\t\t// The clientId will be stored with the override and used to ensure\n\t\t\t\t\t\t// the order of overrides matches the order of blocks so that the\n\t\t\t\t\t\t// correct CSS cascade is maintained.\n\t\t\t\t\t\tclientId: override.clientId,\n\t\t\t\t\t} );\n\t\t\t\t\toverriddenClientIds.push( override.clientId );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn newOverrides;\n\t}, [ config, overrides, getBlockStyles, getBlockName ] );\n\n\tif ( ! overridesWithConfig || ! overridesWithConfig.length ) {\n\t\treturn;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ overridesWithConfig.map( ( override ) => (\n\t\t\t\t<OverrideStyles key={ override.id } override={ override } />\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\n/**\n * Retrieves any variation styles data and resolves any referenced values.\n *\n * @param {Object} globalStyles A complete global styles object, containing settings and styles.\n * @param {string} name The name of the desired block type.\n * @param {variation} variation The of the block style variation to retrieve data for.\n *\n * @return {Object|undefined} The global styles data for the specified variation.\n */\nexport function getVariationStylesWithRefValues(\n\tglobalStyles,\n\tname,\n\tvariation\n) {\n\tif ( ! globalStyles?.styles?.blocks?.[ name ]?.variations?.[ variation ] ) {\n\t\treturn;\n\t}\n\n\t// Helper to recursively look for `ref` values to resolve.\n\tconst replaceRefs = ( variationStyles ) => {\n\t\tObject.keys( variationStyles ).forEach( ( key ) => {\n\t\t\tconst value = variationStyles[ key ];\n\n\t\t\t// Only process objects.\n\t\t\tif ( typeof value === 'object' && value !== null ) {\n\t\t\t\t// Process `ref` value if present.\n\t\t\t\tif ( value.ref !== undefined ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof value.ref !== 'string' ||\n\t\t\t\t\t\tvalue.ref.trim() === ''\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Remove invalid ref.\n\t\t\t\t\t\tdelete variationStyles[ key ];\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Resolve `ref` value.\n\t\t\t\t\t\tconst refValue = getValueFromObjectPath(\n\t\t\t\t\t\t\tglobalStyles,\n\t\t\t\t\t\t\tvalue.ref\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( refValue ) {\n\t\t\t\t\t\t\tvariationStyles[ key ] = refValue;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdelete variationStyles[ key ];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Recursively resolve `ref` values in nested objects.\n\t\t\t\t\treplaceRefs( value );\n\n\t\t\t\t\t// After recursion, if value is empty due to explicitly\n\t\t\t\t\t// `undefined` ref value, remove it.\n\t\t\t\t\tif ( Object.keys( value ).length === 0 ) {\n\t\t\t\t\t\tdelete variationStyles[ key ];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t};\n\n\t// Deep clone variation node to avoid mutating it within global styles and losing refs.\n\tconst styles = JSON.parse(\n\t\tJSON.stringify(\n\t\t\tglobalStyles.styles.blocks[ name ].variations[ variation ]\n\t\t)\n\t);\n\treplaceRefs( styles );\n\n\treturn styles;\n}\n\nfunction useBlockStyleVariation( name, variation, clientId ) {\n\t// Prefer global styles data in GlobalStylesContext, which are available\n\t// if in the site editor. Otherwise fall back to whatever is in the\n\t// editor settings and available in the post editor.\n\tconst { merged: mergedConfig } = useContext( GlobalStylesContext );\n\tconst { globalSettings, globalStyles } = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tglobalSettings: settings.__experimentalFeatures,\n\t\t\tglobalStyles: settings[ globalStylesDataKey ],\n\t\t};\n\t}, [] );\n\n\treturn useMemo( () => {\n\t\tconst variationStyles = getVariationStylesWithRefValues(\n\t\t\t{\n\t\t\t\tsettings: mergedConfig?.settings ?? globalSettings,\n\t\t\t\tstyles: mergedConfig?.styles ?? globalStyles,\n\t\t\t},\n\t\t\tname,\n\t\t\tvariation\n\t\t);\n\n\t\treturn {\n\t\t\tsettings: mergedConfig?.settings ?? globalSettings,\n\t\t\t// The variation style data is all that is needed to generate\n\t\t\t// the styles for the current application to a block. The variation\n\t\t\t// name is updated to match the instance specific class name.\n\t\t\tstyles: {\n\t\t\t\tblocks: {\n\t\t\t\t\t[ name ]: {\n\t\t\t\t\t\tvariations: {\n\t\t\t\t\t\t\t[ `${ variation }-${ clientId }` ]: variationStyles,\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};\n\t}, [\n\t\tmergedConfig,\n\t\tglobalSettings,\n\t\tglobalStyles,\n\t\tvariation,\n\t\tclientId,\n\t\tname,\n\t] );\n}\n\n// Rather than leveraging `useInstanceId` here, the `clientId` is used.\n// This is so that the variation style override's ID is predictable\n// when the order of applied style variations changes.\nfunction useBlockProps( { name, className, clientId } ) {\n\tconst { getBlockStyles } = useSelect( blocksStore );\n\n\tconst registeredStyles = getBlockStyles( name );\n\tconst variation = getVariationNameFromClass( className, registeredStyles );\n\tconst variationClass = `${ VARIATION_PREFIX }${ variation }-${ clientId }`;\n\n\tconst { settings, styles } = useBlockStyleVariation(\n\t\tname,\n\t\tvariation,\n\t\tclientId\n\t);\n\n\tconst variationStyles = useMemo( () => {\n\t\tif ( ! variation ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst variationConfig = { settings, styles };\n\t\tconst blockSelectors = getBlockSelectors( getBlockTypes(), clientId );\n\t\tconst hasBlockGapSupport = false;\n\t\tconst hasFallbackGapSupport = true;\n\t\tconst disableLayoutStyles = true;\n\t\tconst disableRootPadding = true;\n\n\t\treturn toStyles(\n\t\t\tvariationConfig,\n\t\t\tblockSelectors,\n\t\t\thasBlockGapSupport,\n\t\t\thasFallbackGapSupport,\n\t\t\tdisableLayoutStyles,\n\t\t\tdisableRootPadding,\n\t\t\t{\n\t\t\t\tblockGap: false,\n\t\t\t\tblockStyles: true,\n\t\t\t\tlayoutStyles: false,\n\t\t\t\tmarginReset: false,\n\t\t\t\tpresets: false,\n\t\t\t\trootPadding: false,\n\t\t\t\tvariationStyles: true,\n\t\t\t}\n\t\t);\n\t}, [ variation, settings, styles, clientId ] );\n\n\tusePrivateStyleOverride( {\n\t\tid: `variation-${ clientId }`,\n\t\tcss: variationStyles,\n\t\t__unstableType: 'variation',\n\t\tvariation,\n\t\t// The clientId will be stored with the override and used to ensure\n\t\t// the order of overrides matches the order of blocks so that the\n\t\t// correct CSS cascade is maintained.\n\t\tclientId,\n\t} );\n\n\treturn variation ? { className: variationClass } : {};\n}\n\nexport default {\n\thasSupport: () => true,\n\tattributeKeys: [ 'className' ],\n\tisMatch: ( { className } ) => getVariationMatches( className ).length > 0,\n\tuseBlockProps,\n};\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getBlockTypes, store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useContext, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tGlobalStylesContext,\n\ttoStyles,\n\tgetBlockSelectors,\n} from '../components/global-styles';\nimport { usePrivateStyleOverride } from './utils';\nimport { getValueFromObjectPath } from '../utils/object';\nimport { store as blockEditorStore } from '../store';\nimport { globalStylesDataKey } from '../store/private-keys';\nimport { unlock } from '../lock-unlock';\n\nconst VARIATION_PREFIX = 'is-style-';\n\nfunction getVariationMatches( className ) {\n\tif ( ! className ) {\n\t\treturn [];\n\t}\n\treturn className.split( /\\s+/ ).reduce( ( matches, name ) => {\n\t\tif ( name.startsWith( VARIATION_PREFIX ) ) {\n\t\t\tconst match = name.slice( VARIATION_PREFIX.length );\n\t\t\tif ( match !== 'default' ) {\n\t\t\t\tmatches.push( match );\n\t\t\t}\n\t\t}\n\t\treturn matches;\n\t}, [] );\n}\n\n/**\n * Get the first block style variation that has been registered from the class string.\n *\n * @param {string} className CSS class string for a block.\n * @param {Array} registeredStyles Currently registered block styles.\n *\n * @return {string|null} The name of the first registered variation.\n */\nfunction getVariationNameFromClass( className, registeredStyles = [] ) {\n\t// The global flag affects how capturing groups work in JS. So the regex\n\t// below will only return full CSS classes not just the variation name.\n\tconst matches = getVariationMatches( className );\n\n\tif ( ! matches ) {\n\t\treturn null;\n\t}\n\n\tfor ( const variation of matches ) {\n\t\tif ( registeredStyles.some( ( style ) => style.name === variation ) ) {\n\t\t\treturn variation;\n\t\t}\n\t}\n\treturn null;\n}\n\n// A helper component to apply a style override using the useStyleOverride hook.\nfunction OverrideStyles( { override } ) {\n\tusePrivateStyleOverride( override );\n}\n\n/**\n * This component is used to generate new block style variation overrides\n * based on an incoming theme config. If a matching style is found in the config,\n * a new override is created and returned. The overrides can be used in conjunction with\n * useStyleOverride to apply the new styles to the editor. Its use is\n * subject to change.\n *\n * @param {Object} props Props.\n * @param {Object} props.config A global styles object, containing settings and styles.\n * @return {JSX.Element|undefined} An array of new block variation overrides.\n */\nexport function __unstableBlockStyleVariationOverridesWithConfig( { config } ) {\n\tconst { getBlockStyles, overrides } = useSelect(\n\t\t( select ) => ( {\n\t\t\tgetBlockStyles: select( blocksStore ).getBlockStyles,\n\t\t\toverrides: unlock( select( blockEditorStore ) ).getStyleOverrides(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { getBlockName } = useSelect( blockEditorStore );\n\n\tconst overridesWithConfig = useMemo( () => {\n\t\tif ( ! overrides?.length ) {\n\t\t\treturn;\n\t\t}\n\t\tconst newOverrides = [];\n\t\tconst overriddenClientIds = [];\n\t\tfor ( const [ , override ] of overrides ) {\n\t\t\tif (\n\t\t\t\toverride?.variation &&\n\t\t\t\toverride?.clientId &&\n\t\t\t\t/*\n\t\t\t\t * Because this component overwrites existing style overrides,\n\t\t\t\t * filter out any overrides that are already present in the store.\n\t\t\t\t */\n\t\t\t\t! overriddenClientIds.includes( override.clientId )\n\t\t\t) {\n\t\t\t\tconst blockName = getBlockName( override.clientId );\n\t\t\t\tconst configStyles =\n\t\t\t\t\tconfig?.styles?.blocks?.[ blockName ]?.variations?.[\n\t\t\t\t\t\toverride.variation\n\t\t\t\t\t];\n\t\t\t\tif ( configStyles ) {\n\t\t\t\t\tconst variationConfig = {\n\t\t\t\t\t\tsettings: config?.settings,\n\t\t\t\t\t\t// The variation style data is all that is needed to generate\n\t\t\t\t\t\t// the styles for the current application to a block. The variation\n\t\t\t\t\t\t// name is updated to match the instance specific class name.\n\t\t\t\t\t\tstyles: {\n\t\t\t\t\t\t\tblocks: {\n\t\t\t\t\t\t\t\t[ blockName ]: {\n\t\t\t\t\t\t\t\t\tvariations: {\n\t\t\t\t\t\t\t\t\t\t[ `${ override.variation }-${ override.clientId }` ]:\n\t\t\t\t\t\t\t\t\t\t\tconfigStyles,\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};\n\t\t\t\t\tconst blockSelectors = getBlockSelectors(\n\t\t\t\t\t\tgetBlockTypes(),\n\t\t\t\t\t\tgetBlockStyles,\n\t\t\t\t\t\toverride.clientId\n\t\t\t\t\t);\n\t\t\t\t\tconst hasBlockGapSupport = false;\n\t\t\t\t\tconst hasFallbackGapSupport = true;\n\t\t\t\t\tconst disableLayoutStyles = true;\n\t\t\t\t\tconst disableRootPadding = true;\n\t\t\t\t\tconst variationStyles = toStyles(\n\t\t\t\t\t\tvariationConfig,\n\t\t\t\t\t\tblockSelectors,\n\t\t\t\t\t\thasBlockGapSupport,\n\t\t\t\t\t\thasFallbackGapSupport,\n\t\t\t\t\t\tdisableLayoutStyles,\n\t\t\t\t\t\tdisableRootPadding,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tblockGap: false,\n\t\t\t\t\t\t\tblockStyles: true,\n\t\t\t\t\t\t\tlayoutStyles: false,\n\t\t\t\t\t\t\tmarginReset: false,\n\t\t\t\t\t\t\tpresets: false,\n\t\t\t\t\t\t\trootPadding: false,\n\t\t\t\t\t\t\tvariationStyles: true,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tnewOverrides.push( {\n\t\t\t\t\t\tid: `${ override.variation }-${ override.clientId }`,\n\t\t\t\t\t\tcss: variationStyles,\n\t\t\t\t\t\t__unstableType: 'variation',\n\t\t\t\t\t\tvariation: override.variation,\n\t\t\t\t\t\t// The clientId will be stored with the override and used to ensure\n\t\t\t\t\t\t// the order of overrides matches the order of blocks so that the\n\t\t\t\t\t\t// correct CSS cascade is maintained.\n\t\t\t\t\t\tclientId: override.clientId,\n\t\t\t\t\t} );\n\t\t\t\t\toverriddenClientIds.push( override.clientId );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn newOverrides;\n\t}, [ config, overrides, getBlockStyles, getBlockName ] );\n\n\tif ( ! overridesWithConfig || ! overridesWithConfig.length ) {\n\t\treturn;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ overridesWithConfig.map( ( override ) => (\n\t\t\t\t<OverrideStyles key={ override.id } override={ override } />\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\n/**\n * Retrieves any variation styles data and resolves any referenced values.\n *\n * @param {Object} globalStyles A complete global styles object, containing settings and styles.\n * @param {string} name The name of the desired block type.\n * @param {variation} variation The of the block style variation to retrieve data for.\n *\n * @return {Object|undefined} The global styles data for the specified variation.\n */\nexport function getVariationStylesWithRefValues(\n\tglobalStyles,\n\tname,\n\tvariation\n) {\n\tif ( ! globalStyles?.styles?.blocks?.[ name ]?.variations?.[ variation ] ) {\n\t\treturn;\n\t}\n\n\t// Helper to recursively look for `ref` values to resolve.\n\tconst replaceRefs = ( variationStyles ) => {\n\t\tObject.keys( variationStyles ).forEach( ( key ) => {\n\t\t\tconst value = variationStyles[ key ];\n\n\t\t\t// Only process objects.\n\t\t\tif ( typeof value === 'object' && value !== null ) {\n\t\t\t\t// Process `ref` value if present.\n\t\t\t\tif ( value.ref !== undefined ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof value.ref !== 'string' ||\n\t\t\t\t\t\tvalue.ref.trim() === ''\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Remove invalid ref.\n\t\t\t\t\t\tdelete variationStyles[ key ];\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Resolve `ref` value.\n\t\t\t\t\t\tconst refValue = getValueFromObjectPath(\n\t\t\t\t\t\t\tglobalStyles,\n\t\t\t\t\t\t\tvalue.ref\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( refValue ) {\n\t\t\t\t\t\t\tvariationStyles[ key ] = refValue;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdelete variationStyles[ key ];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Recursively resolve `ref` values in nested objects.\n\t\t\t\t\treplaceRefs( value );\n\n\t\t\t\t\t// After recursion, if value is empty due to explicitly\n\t\t\t\t\t// `undefined` ref value, remove it.\n\t\t\t\t\tif ( Object.keys( value ).length === 0 ) {\n\t\t\t\t\t\tdelete variationStyles[ key ];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t};\n\n\t// Deep clone variation node to avoid mutating it within global styles and losing refs.\n\tconst styles = JSON.parse(\n\t\tJSON.stringify(\n\t\t\tglobalStyles.styles.blocks[ name ].variations[ variation ]\n\t\t)\n\t);\n\treplaceRefs( styles );\n\n\treturn styles;\n}\n\nfunction useBlockStyleVariation( name, variation, clientId ) {\n\t// Prefer global styles data in GlobalStylesContext, which are available\n\t// if in the site editor. Otherwise fall back to whatever is in the\n\t// editor settings and available in the post editor.\n\tconst { merged: mergedConfig } = useContext( GlobalStylesContext );\n\tconst { globalSettings, globalStyles } = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tglobalSettings: settings.__experimentalFeatures,\n\t\t\tglobalStyles: settings[ globalStylesDataKey ],\n\t\t};\n\t}, [] );\n\n\treturn useMemo( () => {\n\t\tconst variationStyles = getVariationStylesWithRefValues(\n\t\t\t{\n\t\t\t\tsettings: mergedConfig?.settings ?? globalSettings,\n\t\t\t\tstyles: mergedConfig?.styles ?? globalStyles,\n\t\t\t},\n\t\t\tname,\n\t\t\tvariation\n\t\t);\n\n\t\treturn {\n\t\t\tsettings: mergedConfig?.settings ?? globalSettings,\n\t\t\t// The variation style data is all that is needed to generate\n\t\t\t// the styles for the current application to a block. The variation\n\t\t\t// name is updated to match the instance specific class name.\n\t\t\tstyles: {\n\t\t\t\tblocks: {\n\t\t\t\t\t[ name ]: {\n\t\t\t\t\t\tvariations: {\n\t\t\t\t\t\t\t[ `${ variation }-${ clientId }` ]: variationStyles,\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};\n\t}, [\n\t\tmergedConfig,\n\t\tglobalSettings,\n\t\tglobalStyles,\n\t\tvariation,\n\t\tclientId,\n\t\tname,\n\t] );\n}\n\n// Rather than leveraging `useInstanceId` here, the `clientId` is used.\n// This is so that the variation style override's ID is predictable\n// when the order of applied style variations changes.\nfunction useBlockProps( { name, className, clientId } ) {\n\tconst { getBlockStyles } = useSelect( blocksStore );\n\n\tconst registeredStyles = getBlockStyles( name );\n\tconst variation = getVariationNameFromClass( className, registeredStyles );\n\tconst variationClass = `${ VARIATION_PREFIX }${ variation }-${ clientId }`;\n\n\tconst { settings, styles } = useBlockStyleVariation(\n\t\tname,\n\t\tvariation,\n\t\tclientId\n\t);\n\n\tconst variationStyles = useMemo( () => {\n\t\tif ( ! variation ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst variationConfig = { settings, styles };\n\t\tconst blockSelectors = getBlockSelectors(\n\t\t\tgetBlockTypes(),\n\t\t\tgetBlockStyles,\n\t\t\tclientId\n\t\t);\n\t\tconst hasBlockGapSupport = false;\n\t\tconst hasFallbackGapSupport = true;\n\t\tconst disableLayoutStyles = true;\n\t\tconst disableRootPadding = true;\n\n\t\treturn toStyles(\n\t\t\tvariationConfig,\n\t\t\tblockSelectors,\n\t\t\thasBlockGapSupport,\n\t\t\thasFallbackGapSupport,\n\t\t\tdisableLayoutStyles,\n\t\t\tdisableRootPadding,\n\t\t\t{\n\t\t\t\tblockGap: false,\n\t\t\t\tblockStyles: true,\n\t\t\t\tlayoutStyles: false,\n\t\t\t\tmarginReset: false,\n\t\t\t\tpresets: false,\n\t\t\t\trootPadding: false,\n\t\t\t\tvariationStyles: true,\n\t\t\t}\n\t\t);\n\t}, [ variation, settings, styles, getBlockStyles, clientId ] );\n\n\tusePrivateStyleOverride( {\n\t\tid: `variation-${ clientId }`,\n\t\tcss: variationStyles,\n\t\t__unstableType: 'variation',\n\t\tvariation,\n\t\t// The clientId will be stored with the override and used to ensure\n\t\t// the order of overrides matches the order of blocks so that the\n\t\t// correct CSS cascade is maintained.\n\t\tclientId,\n\t} );\n\n\treturn variation ? { className: variationClass } : {};\n}\n\nexport default {\n\thasSupport: () => true,\n\tattributeKeys: [ 'className' ],\n\tisMatch: ( { className } ) => getVariationMatches( className ).length > 0,\n\tuseBlockProps,\n};\n"],
|
|
5
|
+
"mappings": "AA+KE,mBAEE,WAFF;AA5KF,SAAS,eAAe,SAAS,mBAAmB;AACpD,SAAS,iBAAiB;AAC1B,SAAS,YAAY,eAAe;AAKpC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,+BAA+B;AACxC,SAAS,8BAA8B;AACvC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,2BAA2B;AACpC,SAAS,cAAc;AAEvB,MAAM,mBAAmB;AAEzB,SAAS,oBAAqB,WAAY;AACzC,MAAK,CAAE,WAAY;AAClB,WAAO,CAAC;AAAA,EACT;AACA,SAAO,UAAU,MAAO,KAAM,EAAE,OAAQ,CAAE,SAAS,SAAU;AAC5D,QAAK,KAAK,WAAY,gBAAiB,GAAI;AAC1C,YAAM,QAAQ,KAAK,MAAO,iBAAiB,MAAO;AAClD,UAAK,UAAU,WAAY;AAC1B,gBAAQ,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