@plaudit/gutenberg-api-extensions 2.89.0 → 2.90.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/blocks/SNPFlexibleItemsListComponent.d.ts +2 -2
- package/dist/blocks/SNPFlexibleItemsListComponent.js +1 -1
- package/dist/blocks/SNPFlexibleItemsListComponent.js.map +1 -1
- package/dist/blocks/SNPGroupComponent.js +2 -2
- package/dist/blocks/SNPGroupComponent.js.map +1 -1
- package/dist/blocks/SNPListComponent.js +1 -1
- package/dist/blocks/SNPListComponent.js.map +1 -1
- package/dist/blocks/basic-custom-block-bindings-support.js +6 -6
- package/dist/blocks/basic-custom-block-bindings-support.js.map +1 -1
- package/dist/blocks/common-native-property-constructors.js +21 -14
- package/dist/blocks/common-native-property-constructors.js.map +1 -1
- package/dist/blocks/conditions.js +1 -1
- package/dist/blocks/conditions.js.map +1 -1
- package/dist/blocks/layout/LaidOutPropertyRow.d.ts +5 -2
- package/dist/blocks/layout/LaidOutPropertyRow.js +5 -0
- package/dist/blocks/layout/LaidOutPropertyRow.js.map +1 -1
- package/dist/blocks/layout/PanelRoot.js +1 -4
- package/dist/blocks/layout/PanelRoot.js.map +1 -1
- package/dist/blocks/layout/TabsRoot.js +1 -1
- package/dist/blocks/layout/TabsRoot.js.map +1 -1
- package/dist/blocks/simple-block.d.ts +2 -2
- package/dist/blocks/simple-native-property-impl.js +5 -5
- package/dist/blocks/simple-native-property-impl.js.map +1 -1
- package/dist/controls/AsynchronousFormTokenField.js +1 -1
- package/dist/controls/AsynchronousFormTokenField.js.map +1 -1
- package/dist/controls/BaseSortableItemsControl.d.ts +1 -1
- package/dist/controls/BaseSortableItemsControl.js +2 -2
- package/dist/controls/BaseSortableItemsControl.js.map +1 -1
- package/dist/controls/ExtendedFormTokenField.js +1 -1
- package/dist/controls/ExtendedFormTokenField.js.map +1 -1
- package/dist/controls/ExtendedRadioControl.js +1 -1
- package/dist/controls/ExtendedRadioControl.js.map +1 -1
- package/dist/controls/ExtendedTextareaControl.js +1 -1
- package/dist/controls/ExtendedTextareaControl.js.map +1 -1
- package/dist/controls/FileControl.js +3 -3
- package/dist/controls/FileControl.js.map +1 -1
- package/dist/controls/FullSizeToggleControl.js +1 -0
- package/dist/controls/FullSizeToggleControl.js.map +1 -1
- package/dist/controls/ImageControl.js +5 -5
- package/dist/controls/ImageControl.js.map +1 -1
- package/dist/controls/LazySuggestionsComboboxControl.js +4 -4
- package/dist/controls/LazySuggestionsComboboxControl.js.map +1 -1
- package/dist/controls/PickOne.js +2 -2
- package/dist/controls/PickOne.js.map +1 -1
- package/dist/controls/ProperLinkControl.js +3 -3
- package/dist/controls/ProperLinkControl.js.map +1 -1
- package/dist/controls/SimpleToggle.js +1 -1
- package/dist/controls/SimpleToggle.js.map +1 -1
- package/dist/controls/SortableFlexibleItemsControl.d.ts +2 -2
- package/dist/controls/SortableFlexibleItemsControl.js +1 -1
- package/dist/controls/SortableFlexibleItemsControl.js.map +1 -1
- package/dist/controls/SortableItemsControl.js +1 -1
- package/dist/controls/SortableItemsControl.js.map +1 -1
- package/package.json +12 -12
- package/src/blocks/SNPFlexibleItemsListComponent.tsx +4 -4
- package/src/blocks/SNPGroupComponent.tsx +3 -3
- package/src/blocks/SNPListComponent.tsx +2 -2
- package/src/blocks/basic-custom-block-bindings-support.tsx +11 -6
- package/src/blocks/common-native-property-constructors.tsx +48 -34
- package/src/blocks/conditions.ts +1 -1
- package/src/blocks/layout/LaidOutPropertyRow.tsx +7 -1
- package/src/blocks/layout/PanelRoot.tsx +2 -5
- package/src/blocks/layout/TabsRoot.tsx +2 -2
- package/src/blocks/simple-block.tsx +2 -2
- package/src/blocks/simple-native-property-impl.tsx +5 -5
- package/src/controls/AsynchronousFormTokenField.tsx +1 -0
- package/src/controls/BaseSortableItemsControl.tsx +8 -8
- package/src/controls/ExtendedFormTokenField.tsx +2 -0
- package/src/controls/ExtendedRadioControl.tsx +2 -2
- package/src/controls/ExtendedTextareaControl.tsx +1 -1
- package/src/controls/FileControl.tsx +4 -4
- package/src/controls/FullSizeToggleControl.tsx +1 -0
- package/src/controls/ImageControl.tsx +5 -5
- package/src/controls/LazySuggestionsComboboxControl.tsx +11 -9
- package/src/controls/PickOne.tsx +2 -1
- package/src/controls/ProperLinkControl.tsx +11 -6
- package/src/controls/SimpleToggle.tsx +1 -1
- package/src/controls/SortableFlexibleItemsControl.tsx +5 -3
- package/src/controls/SortableItemsControl.tsx +5 -1
|
@@ -46,14 +46,14 @@ function ProperLinkControl(props) {
|
|
|
46
46
|
}, [areAdvancedSettingsVisible, advancedSettingsRef]);
|
|
47
47
|
const safeOnRemove = (0, element_1.useCallback)(() => onRemove !== undefined ? onRemove() : onChange?.(undefined), [onRemove, onChange]);
|
|
48
48
|
const renderableSettings = settings === false ? [] : settings;
|
|
49
|
-
const renderControlBottom = (0, element_1.useCallback)(() => (value?.url && renderableSettings?.length && (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(components_1.Button, { variant: "tertiary", onClick: () => setAreAdvancedSettingsVisible(!areAdvancedSettingsVisible), icon: areAdvancedSettingsVisible ? icons_1.chevronUp : icons_1.chevronDown, iconPosition: "right", text: "Advanced" }), (0, jsx_runtime_1.jsxs)("div", { ref: advancedSettingsRef, style: { display: "none", transition: "max-height 200ms ease-in-out", overflow: "hidden" }, children: [...renderableSettings.map(setting => (0, jsx_runtime_1.jsx)(ProperLinkControlSetting, { setting: setting, onChange: onChange, value: value }))] })] })) || "", [value, settings, areAdvancedSettingsVisible, onChange]);
|
|
50
|
-
return (0, jsx_runtime_1.jsx)(components_1.BaseControl, { id: "", label: props.label, help: props.help, children: (0, jsx_runtime_1.jsx)(block_editor_1.LinkControl, { ...linkControlProps, value: value, onChange: onChange, onRemove: safeOnRemove, settings: ProperLinkControl.DUMMY_LINK_SETTINGS, renderControlBottom: renderControlBottom }) });
|
|
49
|
+
const renderControlBottom = (0, element_1.useCallback)(() => (value?.url && renderableSettings?.length && (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(components_1.Button, { variant: "tertiary", onClick: () => setAreAdvancedSettingsVisible(!areAdvancedSettingsVisible), icon: areAdvancedSettingsVisible ? icons_1.chevronUp : icons_1.chevronDown, iconPosition: "right", text: "Advanced", __next40pxDefaultSize: true, accessibleWhenDisabled: true }), (0, jsx_runtime_1.jsxs)("div", { ref: advancedSettingsRef, style: { display: "none", transition: "max-height 200ms ease-in-out", overflow: "hidden" }, children: [...renderableSettings.map(setting => (0, jsx_runtime_1.jsx)(ProperLinkControlSetting, { setting: setting, onChange: onChange, value: value }, setting.id))] })] })) || "", [value, settings, areAdvancedSettingsVisible, onChange]);
|
|
50
|
+
return (0, jsx_runtime_1.jsx)(components_1.BaseControl, { __nextHasNoMarginBottom: true, id: "", label: props.label, help: props.help, children: (0, jsx_runtime_1.jsx)(block_editor_1.LinkControl, { ...linkControlProps, value: value, onChange: onChange, onRemove: safeOnRemove, settings: ProperLinkControl.DUMMY_LINK_SETTINGS, renderControlBottom: renderControlBottom }) });
|
|
51
51
|
}
|
|
52
52
|
ProperLinkControl.DEFAULT_LINK_SETTINGS = block_editor_1.LinkControl.DEFAULT_LINK_SETTINGS;
|
|
53
53
|
ProperLinkControl.DUMMY_LINK_SETTINGS = [];
|
|
54
54
|
function ProperLinkControlSetting({ value, onChange, setting }) {
|
|
55
55
|
return (0, jsx_runtime_1.jsx)("div", { style: { marginTop: "8px" }, children: setting.type === 'text'
|
|
56
|
-
? (0, jsx_runtime_1.jsx)(components_1.TextControl, { style: { marginTop: "8px" }, value: value?.[setting.id] ?? setting.default ?? '', label: setting.title, onChange: v => onChange?.({ ...value, [setting.id]: v }) })
|
|
56
|
+
? (0, jsx_runtime_1.jsx)(components_1.TextControl, { style: { marginTop: "8px" }, value: value?.[setting.id] ?? setting.default ?? '', label: setting.title, onChange: v => onChange?.({ ...value, [setting.id]: v }), __next40pxDefaultSize: true, __nextHasNoMarginBottom: true })
|
|
57
57
|
: (0, jsx_runtime_1.jsx)(components_1.ToggleControl, { style: { marginTop: "8px" }, checked: value?.[setting.id] ?? setting.default ?? false, label: setting.title, onChange: v => onChange?.({ ...value, [setting.id]: v }) }) });
|
|
58
58
|
}
|
|
59
59
|
//# sourceMappingURL=ProperLinkControl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProperLinkControl.js","sourceRoot":"","sources":["../../src/controls/ProperLinkControl.tsx"],"names":[],"mappings":";;AAUA,
|
|
1
|
+
{"version":3,"file":"ProperLinkControl.js","sourceRoot":"","sources":["../../src/controls/ProperLinkControl.tsx"],"names":[],"mappings":";;AAUA,8CAgEC;;AA1ED,0DAAoD;AACpD,sDAAsF;AACtF,gDAA4E;AAC5E,4CAAwD;AAOxD,SAAgB,iBAAiB,CAAC,KAA6B;IAC9D,MAAM,EAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAC5C,QAAQ,GAAG,iBAAiB,CAAC,qBAAqB,EAAE,GAAG,gBAAgB,EAAC,GAAG,KAAK,CAAC;IAClF,MAAM,CAAC,0BAA0B,EAAE,6BAA6B,CAAC,GAAG,IAAA,kBAAQ,EAAC,KAAK,CAAC,CAAC;IACpF,MAAM,mBAAmB,GAAG,IAAA,gBAAM,EAAsB,IAAI,CAAC,CAAC;IAE9D,IAAA,mBAAS,EAAC,GAAG,EAAE;QACd,MAAM,uBAAuB,GAAG,mBAAmB,CAAC,OAAO,CAAC;QAC5D,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC9B,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;QACjB,CAAC;QACD,MAAM,kBAAkB,GAAG,CAAC,GAAoB,EAAE,EAAE;YACnD,IAAI,GAAG,CAAC,YAAY,KAAK,YAAY,IAAI,GAAG,CAAC,MAAM,KAAK,uBAAuB,EAAE,CAAC;gBACjF,IAAI,uBAA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_1 = require("@wordpress/element");
|
|
7
7
|
function SimpleToggle(props) {
|
|
8
8
|
const onChange = (0, element_1.useCallback)((checked) => props.setAttributes({ [props.attribute]: checked }), [props.setAttributes, props.attribute]);
|
|
9
|
-
return (0, jsx_runtime_1.jsx)(components_1.ToggleControl, { checked: props.attributes[props.attribute], label: props.label, onChange: onChange });
|
|
9
|
+
return (0, jsx_runtime_1.jsx)(components_1.ToggleControl, { __nextHasNoMarginBottom: true, checked: props.attributes[props.attribute], label: props.label, onChange: onChange });
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=SimpleToggle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleToggle.js","sourceRoot":"","sources":["../../src/controls/SimpleToggle.tsx"],"names":[],"mappings":";;AAKA,oCAGC;;AARD,sDAAoD;AACpD,gDAA+C;AAI/C,SAAgB,YAAY,CAAmB,KAA0C;IACxF,MAAM,QAAQ,GAAG,IAAA,qBAAW,EAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,EAAC,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,OAAO,EAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IAC9I,OAAO,uBAAC,0BAAa,IAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"SimpleToggle.js","sourceRoot":"","sources":["../../src/controls/SimpleToggle.tsx"],"names":[],"mappings":";;AAKA,oCAGC;;AARD,sDAAoD;AACpD,gDAA+C;AAI/C,SAAgB,YAAY,CAAmB,KAA0C;IACxF,MAAM,QAAQ,GAAG,IAAA,qBAAW,EAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,EAAC,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,OAAO,EAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IAC9I,OAAO,uBAAC,0BAAa,IAAC,uBAAuB,QAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAAC;AACtI,CAAC"}
|
|
@@ -8,6 +8,6 @@ type SortableFlexibleItemsControlSpecificProps<T extends string> = {
|
|
|
8
8
|
}>;
|
|
9
9
|
emptyValueBuilder: (type: T) => FlexibleItem<T>;
|
|
10
10
|
};
|
|
11
|
-
export type
|
|
12
|
-
export declare function SortableFlexibleItemsControl<T extends string>({ availableTypes, emptyValueBuilder, ...baseProps }:
|
|
11
|
+
export type SortableFlexibleItemsControlProps<T extends string> = Omit<BaseSortableItemsControlProps<FlexibleItem<T>>, 'buttonsArea'> & SortableFlexibleItemsControlSpecificProps<T>;
|
|
12
|
+
export declare function SortableFlexibleItemsControl<T extends string>({ availableTypes, emptyValueBuilder, ...baseProps }: SortableFlexibleItemsControlProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
export {};
|
|
@@ -13,6 +13,6 @@ function SortableFlexibleItemsControl({ availableTypes, emptyValueBuilder, ...ba
|
|
|
13
13
|
}
|
|
14
14
|
function ButtonsArea({ addHandler, disabled, availableTypes, emptyValueBuilder }) {
|
|
15
15
|
const [selectedType, setSelectedType] = (0, element_1.useState)(availableTypes[0].value);
|
|
16
|
-
return (0, jsx_runtime_1.jsxs)("div", { className: "plaudit-sortable-items-buttons flexible-items", children: [(0, jsx_runtime_1.jsx)(components_1.Button, { icon: "insert", disabled: disabled, onClick: () => addHandler(emptyValueBuilder(selectedType)), children: "Add" }), (0, jsx_runtime_1.jsx)(components_1.SelectControl, { label: "Type", hideLabelFromVision: true, value: selectedType, options: availableTypes, onChange: setSelectedType })] });
|
|
16
|
+
return (0, jsx_runtime_1.jsxs)("div", { className: "plaudit-sortable-items-buttons flexible-items", children: [(0, jsx_runtime_1.jsx)(components_1.Button, { icon: "insert", disabled: disabled, onClick: () => addHandler(emptyValueBuilder(selectedType)), __next40pxDefaultSize: true, accessibleWhenDisabled: true, children: "Add" }), (0, jsx_runtime_1.jsx)(components_1.SelectControl, { __next40pxDefaultSize: true, __nextHasNoMarginBottom: true, label: "Type", hideLabelFromVision: true, value: selectedType, options: availableTypes, onChange: setSelectedType })] });
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=SortableFlexibleItemsControl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SortableFlexibleItemsControl.js","sourceRoot":"","sources":["../../src/controls/SortableFlexibleItemsControl.tsx"],"names":[],"mappings":";;AAcA,oEAKC;;AAnBD,sDAA4D;AAC5D,gDAAyD;AAEzD,yEAAwG;AAWxG,SAAgB,4BAA4B,CAAmB,EAAC,cAAc,EAAE,iBAAiB,EAAE,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"SortableFlexibleItemsControl.js","sourceRoot":"","sources":["../../src/controls/SortableFlexibleItemsControl.tsx"],"names":[],"mappings":";;AAcA,oEAKC;;AAnBD,sDAA4D;AAC5D,gDAAyD;AAEzD,yEAAwG;AAWxG,SAAgB,4BAA4B,CAAmB,EAAC,cAAc,EAAE,iBAAiB,EAAE,GAAG,SAAS,EAAuC;IACrJ,MAAM,WAAW,GAAG,IAAA,qBAAW;IAC9B,wHAAwH;IACxH,IAAI,CAAC,EAAE,CAAC,uBAAC,WAAW,OAAK,IAAI,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,GAAI,EAAE,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAC/I,OAAO,uBAAC,mDAAwB,OAAK,SAAS,EAAE,WAAW,EAAE,WAAW,GAAI,CAAC;AAC9E,CAAC;AAGD,SAAS,WAAW,CAAmB,EAAC,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,iBAAiB,EAAsB;IACpH,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,kBAAQ,EAAC,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC1E,OAAO,iCAAK,SAAS,EAAC,+CAA+C,aACpE,uBAAC,mBAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC,EAAE,qBAAqB,QAAC,sBAAsB,0BAAa,EAC/J,uBAAC,0BAAa,IACb,qBAAqB,QACrB,uBAAuB,QACvB,KAAK,EAAC,MAAM,EACZ,mBAAmB,EAAE,IAAI,EACzB,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,eAAe,GACxB,IACG,CAAC;AACR,CAAC"}
|
|
@@ -10,6 +10,6 @@ function SortableItemsControl({ emptyValue, addRowText, ...baseProps }) {
|
|
|
10
10
|
return (0, jsx_runtime_1.jsx)(BaseSortableItemsControl_1.BaseSortableItemsControl, { ...baseProps, buttonsArea: buttonsArea, emptyValue: emptyValue });
|
|
11
11
|
}
|
|
12
12
|
function ButtonsArea({ addHandler, disabled, emptyValue, addRowText }) {
|
|
13
|
-
return (0, jsx_runtime_1.jsx)("div", { className: "plaudit-sortable-items-buttons", children: (0, jsx_runtime_1.jsx)(components_1.Button, { icon: "insert", disabled: disabled, onClick: () => addHandler(typeof emptyValue === 'object' ? { ...emptyValue } : emptyValue), children: addRowText ?? "Add Row" }) });
|
|
13
|
+
return (0, jsx_runtime_1.jsx)("div", { className: "plaudit-sortable-items-buttons", children: (0, jsx_runtime_1.jsx)(components_1.Button, { icon: "insert", disabled: disabled, onClick: () => addHandler(typeof emptyValue === 'object' ? { ...emptyValue } : emptyValue), __next40pxDefaultSize: true, accessibleWhenDisabled: true, children: addRowText ?? "Add Row" }) });
|
|
14
14
|
}
|
|
15
15
|
//# sourceMappingURL=SortableItemsControl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SortableItemsControl.js","sourceRoot":"","sources":["../../src/controls/SortableItemsControl.tsx"],"names":[],"mappings":";;AAMA,oDAIC;;AAVD,sDAA6C;AAC7C,gDAA+C;AAE/C,yEAAwG;AAGxG,SAAgB,oBAAoB,CAAI,EAAC,UAAU,EAAE,UAAU,EAAE,GAAG,SAAS,EAA+B;IAC3G,MAAM,WAAW,GAAG,IAAA,qBAAW,EAC9B,IAAI,CAAC,EAAE,CAAC,uBAAC,WAAW,OAAK,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,GAAI,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;IAC9G,OAAO,uBAAC,mDAAwB,OAAK,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,GAAI,CAAC;AACtG,CAAC;AAGD,SAAS,WAAW,CAAI,EAAC,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAsB;IAC1F,OAAO,gCAAK,SAAS,EAAC,gCAAgC,YACrD,uBAAC,mBAAM,
|
|
1
|
+
{"version":3,"file":"SortableItemsControl.js","sourceRoot":"","sources":["../../src/controls/SortableItemsControl.tsx"],"names":[],"mappings":";;AAMA,oDAIC;;AAVD,sDAA6C;AAC7C,gDAA+C;AAE/C,yEAAwG;AAGxG,SAAgB,oBAAoB,CAAI,EAAC,UAAU,EAAE,UAAU,EAAE,GAAG,SAAS,EAA+B;IAC3G,MAAM,WAAW,GAAG,IAAA,qBAAW,EAC9B,IAAI,CAAC,EAAE,CAAC,uBAAC,WAAW,OAAK,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,GAAI,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;IAC9G,OAAO,uBAAC,mDAAwB,OAAK,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,GAAI,CAAC;AACtG,CAAC;AAGD,SAAS,WAAW,CAAI,EAAC,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAsB;IAC1F,OAAO,gCAAK,SAAS,EAAC,gCAAgC,YACrD,uBAAC,mBAAM,IACN,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,QAAQ,EAC1B,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAC,GAAG,UAAU,EAAC,CAAC,CAAC,CAAC,UAAU,CAAC,EAC9F,qBAAqB,QAAC,sBAAsB,kBAC3C,UAAU,IAAI,SAAS,GAAU,GAC9B,CAAA;AACP,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaudit/gutenberg-api-extensions",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.90.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"files": [
|
|
6
6
|
"./dist",
|
|
@@ -25,19 +25,19 @@
|
|
|
25
25
|
"@types/react": "^18.3.28",
|
|
26
26
|
"@types/wordpress__block-editor": "^15.0.5",
|
|
27
27
|
"@types/wordpress__blocks": "^15.10.2",
|
|
28
|
-
"@wordpress/block-editor": "^15.
|
|
29
|
-
"@wordpress/blocks": "^15.
|
|
28
|
+
"@wordpress/block-editor": "^15.16.0",
|
|
29
|
+
"@wordpress/blocks": "^15.16.0",
|
|
30
30
|
"@wordpress/components": "^30.9.0",
|
|
31
|
-
"@wordpress/compose": "^7.
|
|
32
|
-
"@wordpress/core-data": "^7.
|
|
33
|
-
"@wordpress/data": "^10.
|
|
34
|
-
"@wordpress/editor": "^14.
|
|
35
|
-
"@wordpress/element": "^6.
|
|
36
|
-
"@wordpress/hooks": "^4.
|
|
37
|
-
"@wordpress/i18n": "^6.
|
|
38
|
-
"@wordpress/icons": "^
|
|
31
|
+
"@wordpress/compose": "^7.43.0",
|
|
32
|
+
"@wordpress/core-data": "^7.43.0",
|
|
33
|
+
"@wordpress/data": "^10.43.0",
|
|
34
|
+
"@wordpress/editor": "^14.43.0",
|
|
35
|
+
"@wordpress/element": "^6.43.0",
|
|
36
|
+
"@wordpress/hooks": "^4.43.0",
|
|
37
|
+
"@wordpress/i18n": "^6.16.0",
|
|
38
|
+
"@wordpress/icons": "^12.1.0",
|
|
39
39
|
"framer-motion": "^12.38.0",
|
|
40
|
-
"html-react-parser": "^
|
|
40
|
+
"html-react-parser": "^6.0.0",
|
|
41
41
|
"immer": "^11.1.4",
|
|
42
42
|
"react": "^18.3.1",
|
|
43
43
|
"react-dom": "^18.3.1",
|
|
@@ -2,24 +2,24 @@ import {useCallback} from "@wordpress/element";
|
|
|
2
2
|
|
|
3
3
|
import type {FlexibleItemsListPropertyConfig} from "./csnp-api";
|
|
4
4
|
import {type FlexibleItem, SortableFlexibleItemsControl} from "../controls";
|
|
5
|
-
import {
|
|
5
|
+
import {makeLaidOutPropertyRow} from "./layout/LaidOutPropertyRow";
|
|
6
6
|
import {NodeContextWrapper, useNodeContext} from "./layout/NodeContext";
|
|
7
7
|
import type {NonEmptyArray} from "../lib/useful-types";
|
|
8
8
|
import type {CSNPControlComponentProps} from "./shared-internal-types";
|
|
9
9
|
import type {HydratedSimpleNativeProperty, SNPControlSlots} from "./simple-native-property-api";
|
|
10
10
|
|
|
11
|
-
export type
|
|
11
|
+
export type SNPFlexibleItemsListComponentProps<T extends string> = CSNPControlComponentProps<FlexibleItemsListPropertyConfig<T>, FlexibleItem<T>[], {
|
|
12
12
|
availableTypes: NonEmptyArray<{value: T, label: string}>, emptyValues: {[key in T]?: FlexibleItem<T>}
|
|
13
13
|
hydratedProperties: {[key in T]: (HydratedSimpleNativeProperty|HydratedSimpleNativeProperty[])[]}
|
|
14
14
|
}>&SNPControlSlots;
|
|
15
15
|
export function SNPFlexibleItemsListComponent(
|
|
16
|
-
{config, availableTypes, emptyValues, hydratedProperties, value, Label, Messages}:
|
|
16
|
+
{config, availableTypes, emptyValues, hydratedProperties, value, Label, Messages}: SNPFlexibleItemsListComponentProps<string>
|
|
17
17
|
) {
|
|
18
18
|
const context = useNodeContext("build a SNP List");
|
|
19
19
|
const onReorder = useCallback((oldIndex: number, newIndex: number) => context.moveNode({from: oldIndex, to: newIndex}), [context]);
|
|
20
20
|
const emptyValueBuilder = useCallback((type: string) => ({...emptyValues[type], type}), [emptyValues]);
|
|
21
21
|
const childRenderer = useCallback((datum: FlexibleItem, onDatumChange: (datum: FlexibleItem) => void, index: number) => {
|
|
22
|
-
return <NodeContextWrapper nodeName={index} children={hydratedProperties[datum.type]
|
|
22
|
+
return <NodeContextWrapper nodeName={index} children={(hydratedProperties[datum.type] ?? []).map(property => makeLaidOutPropertyRow({property}))} />;
|
|
23
23
|
}, [hydratedProperties]);
|
|
24
24
|
|
|
25
25
|
return <SortableFlexibleItemsControl
|
|
@@ -3,7 +3,7 @@ import {useCallback} from "@wordpress/element";
|
|
|
3
3
|
|
|
4
4
|
import type {GroupPropertyCSNPConfig} from "./csnp-api";
|
|
5
5
|
import type {Dict} from "../controls";
|
|
6
|
-
import {LaidOutPropertyRow} from "./layout/LaidOutPropertyRow";
|
|
6
|
+
import {LaidOutPropertyRow, makeLaidOutPropertyRow} from "./layout/LaidOutPropertyRow";
|
|
7
7
|
import {useNodeContext} from "./layout/NodeContext";
|
|
8
8
|
import type {CSNPControlComponentProps} from "./shared-internal-types";
|
|
9
9
|
import type {SNPControlSlots} from "./simple-native-property-api";
|
|
@@ -22,7 +22,7 @@ export function SNPGroupComponent({config, hydratedProperties, Label, Messages}:
|
|
|
22
22
|
setValue((resetAllFilters ?? []).reduce((q: any, filter) => filter(q), value))
|
|
23
23
|
}, [value, setValue])}
|
|
24
24
|
>
|
|
25
|
-
{...hydratedProperties.map(property =>
|
|
25
|
+
{...hydratedProperties.map(property => makeLaidOutPropertyRow({property, inToolsPanel: true}))}
|
|
26
26
|
</ToolsPanel>
|
|
27
27
|
<Messages/>
|
|
28
28
|
</>;
|
|
@@ -30,7 +30,7 @@ export function SNPGroupComponent({config, hydratedProperties, Label, Messages}:
|
|
|
30
30
|
return <fieldset {...config.component} className={config.component?.className ? `plaudit-snp-group-component ${config.component.className}` : "plaudit-snp-group-component"}>
|
|
31
31
|
<legend><Label/></legend>
|
|
32
32
|
<div className="plaudit-snp-laid-out-properties-wrapper">
|
|
33
|
-
{...hydratedProperties.map(property =>
|
|
33
|
+
{...hydratedProperties.map(property => makeLaidOutPropertyRow({property}))}
|
|
34
34
|
</div>
|
|
35
35
|
<Messages/>
|
|
36
36
|
</fieldset>;
|
|
@@ -2,7 +2,7 @@ import {useCallback, useMemo} from "@wordpress/element";
|
|
|
2
2
|
|
|
3
3
|
import type {ObjectListPropertyConfig} from "./csnp-api";
|
|
4
4
|
import {type Dict, SortableItemsControl} from "../controls";
|
|
5
|
-
import {LaidOutPropertyRow} from "./layout/LaidOutPropertyRow";
|
|
5
|
+
import {LaidOutPropertyRow, makeLaidOutPropertyRow} from "./layout/LaidOutPropertyRow";
|
|
6
6
|
import {NodeContextWrapper, useNodeContext} from "./layout/NodeContext";
|
|
7
7
|
import type {CSNPControlComponentProps} from "./shared-internal-types";
|
|
8
8
|
import type {HydratedSimpleNativeProperty, SNPControlSlots} from "./simple-native-property-api";
|
|
@@ -15,7 +15,7 @@ export function SNPListComponent({config, hydratedProperties, value, Label, Mess
|
|
|
15
15
|
const onReorder = useCallback((oldIndex: number, newIndex: number) => context.moveNode({from: oldIndex, to: newIndex}), [context]);
|
|
16
16
|
const emptyValue = useMemo(() => config.emptyValue ?? {}, [config.emptyValue]);
|
|
17
17
|
const childRenderer = useCallback((datum: Dict<any>, onDatumChange: (datum: Dict<any>) => void, index: number) => {
|
|
18
|
-
return <NodeContextWrapper nodeName={index} children={hydratedProperties.map(property =>
|
|
18
|
+
return <NodeContextWrapper nodeName={index} children={hydratedProperties.map(property => makeLaidOutPropertyRow({property}))} />
|
|
19
19
|
}, [hydratedProperties]);
|
|
20
20
|
|
|
21
21
|
return <SortableItemsControl
|
|
@@ -46,7 +46,7 @@ export function installCustomBlockBindingsSupport() {
|
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
addFilter('editor.BlockEdit', 'plaudit/gutenberg-api-extensions/basic-custom-block-bindings-support',
|
|
49
|
-
createHigherOrderComponent(BlockEdit => (blockEditProps: ActualBlockEditProps)
|
|
49
|
+
createHigherOrderComponent(BlockEdit => function CustomBlockBindingsSupportBlockEdit(blockEditProps: ActualBlockEditProps) {
|
|
50
50
|
const availableBindingsList = BLOCK_BINDINGS_ALLOWED_BLOCKS[blockEditProps.name];
|
|
51
51
|
if (!availableBindingsList?.length) {
|
|
52
52
|
return <BlockEdit {...blockEditProps} />;
|
|
@@ -117,7 +117,8 @@ export function installCustomBlockBindingsSupport() {
|
|
|
117
117
|
<SelectControl
|
|
118
118
|
key="source"
|
|
119
119
|
label="Source"
|
|
120
|
-
|
|
120
|
+
__next40pxDefaultSize
|
|
121
|
+
__nextHasNoMarginBottom
|
|
121
122
|
onChange={source => updateBlockBindings({[binding]: {source, args: {}}})}
|
|
122
123
|
options={[
|
|
123
124
|
{
|
|
@@ -169,7 +170,8 @@ export function installCustomBlockBindingsSupport() {
|
|
|
169
170
|
controls.push(<SelectControl
|
|
170
171
|
key="field"
|
|
171
172
|
label="Field"
|
|
172
|
-
|
|
173
|
+
__next40pxDefaultSize
|
|
174
|
+
__nextHasNoMarginBottom
|
|
173
175
|
// We exclude subfield from this update because we need to reset it when the selected field changes
|
|
174
176
|
onChange={key => updateBlockBindings({[binding]: (value ? {...value, args: {key}} : undefined)})}
|
|
175
177
|
options={[
|
|
@@ -188,7 +190,8 @@ export function installCustomBlockBindingsSupport() {
|
|
|
188
190
|
controls.push(<TextControl
|
|
189
191
|
key="subfield"
|
|
190
192
|
label="Subfield"
|
|
191
|
-
|
|
193
|
+
__next40pxDefaultSize
|
|
194
|
+
__nextHasNoMarginBottom
|
|
192
195
|
onChange={subfield => updateBlockBindings({[binding]: (value ? {...value, args: {...value.args, subfield}} : undefined)})}
|
|
193
196
|
value={value?.args['subfield'] ?? ''}
|
|
194
197
|
help="Please enter the name of a subfield. You may need to inspect the raw data from this binding to determine the subfield."
|
|
@@ -197,7 +200,8 @@ export function installCustomBlockBindingsSupport() {
|
|
|
197
200
|
controls.push(<SelectControl
|
|
198
201
|
key="subfield"
|
|
199
202
|
label="Subfield"
|
|
200
|
-
|
|
203
|
+
__next40pxDefaultSize
|
|
204
|
+
__nextHasNoMarginBottom
|
|
201
205
|
onChange={subfield => updateBlockBindings({[binding]: (value ? {...value, args: {...value.args, subfield}} : undefined)})}
|
|
202
206
|
options={[
|
|
203
207
|
{
|
|
@@ -216,7 +220,8 @@ export function installCustomBlockBindingsSupport() {
|
|
|
216
220
|
controls.push(<SelectControl
|
|
217
221
|
key="db-source"
|
|
218
222
|
label="DB Source"
|
|
219
|
-
|
|
223
|
+
__next40pxDefaultSize
|
|
224
|
+
__nextHasNoMarginBottom
|
|
220
225
|
onChange={db_source => updateBlockBindings({[binding]: (value ? {...value, args: {...value.args, db_source}} : undefined)})}
|
|
221
226
|
options={dbSources}
|
|
222
227
|
value={value?.args['db_source'] ?? dbSources[0]!.value}
|
|
@@ -131,7 +131,7 @@ function hydrateDesiccatedSimpleNativeProperty(
|
|
|
131
131
|
const safeOnChange = useCallback((v: string|undefined) => onChange(v ? colorToValue[v] : undefined), [colorToValue, onChange]);
|
|
132
132
|
|
|
133
133
|
const {baseControlProps, controlProps} = useBaseControlProps({label: <Label />, help: config.help});
|
|
134
|
-
return <BaseControl {...baseControlProps}>
|
|
134
|
+
return <BaseControl __nextHasNoMarginBottom {...baseControlProps}>
|
|
135
135
|
<ColorPalette
|
|
136
136
|
{...config.component}
|
|
137
137
|
{...controlProps}
|
|
@@ -157,7 +157,7 @@ function hydrateDesiccatedSimpleNativeProperty(
|
|
|
157
157
|
control({value, slots: {Label, Messages}}: SNPControlProps<any>) {
|
|
158
158
|
const {current: voidChangeHandler} = useRef(() => {});
|
|
159
159
|
return <Disabled>
|
|
160
|
-
<TextControl {...config.component} value={value} onChange={voidChangeHandler} label={<Label />} help={config.help} disabled={true} />
|
|
160
|
+
<TextControl __nextHasNoMarginBottom __next40pxDefaultSize {...config.component} value={value} onChange={voidChangeHandler} label={<Label />} help={config.help} disabled={true} />
|
|
161
161
|
<Messages />
|
|
162
162
|
</Disabled>;
|
|
163
163
|
}
|
|
@@ -172,7 +172,7 @@ function hydrateDesiccatedSimpleNativeProperty(
|
|
|
172
172
|
transformer: config.transformer,
|
|
173
173
|
control({value, onChange, slots: {Label, Messages}}) {
|
|
174
174
|
const safeOnChange = useCallback((v: string|null) => onChange(v === null ? undefined : new Date(v).getTime()), [onChange]);
|
|
175
|
-
return <BaseControl id="" label={<Label />} help={config.help}>
|
|
175
|
+
return <BaseControl __nextHasNoMarginBottom id="" label={<Label />} help={config.help}>
|
|
176
176
|
{config.time
|
|
177
177
|
? <DateTimePicker {...config.component} currentDate={value ?? null} onChange={safeOnChange} />
|
|
178
178
|
: <DatePicker {...config.component} currentDate={value ?? null} onChange={safeOnChange} />
|
|
@@ -193,7 +193,7 @@ function hydrateDesiccatedSimpleNativeProperty(
|
|
|
193
193
|
return <FileControl label={<Label />} help={config.help} onChange={onChange} value={value} allowedTypes={config.allowedTypes} />;
|
|
194
194
|
}
|
|
195
195
|
};
|
|
196
|
-
case "group":
|
|
196
|
+
case "group": {
|
|
197
197
|
registerPlainTextLabelRequiredMarker("post", " > .components-tools-panel > .components-tools-panel-header > *");
|
|
198
198
|
const currentTypes = parentTypes.toSpliced(parentTypes.length - 1, 0, 'object');
|
|
199
199
|
const hydratedProperties = (config.fields ?? [])
|
|
@@ -228,6 +228,7 @@ function hydrateDesiccatedSimpleNativeProperty(
|
|
|
228
228
|
</ToolsPanelContext.Provider>;
|
|
229
229
|
}
|
|
230
230
|
};
|
|
231
|
+
}
|
|
231
232
|
case "image":
|
|
232
233
|
return {
|
|
233
234
|
type: 'object',
|
|
@@ -264,24 +265,24 @@ function hydrateDesiccatedSimpleNativeProperty(
|
|
|
264
265
|
</>;
|
|
265
266
|
}
|
|
266
267
|
};
|
|
267
|
-
case "list":
|
|
268
|
+
case "list": {
|
|
268
269
|
const sharedProps: ShareableSNPElements<'array'> = {...passthroughProps, type: 'array', alwaysStore: config.alwaysStore};
|
|
269
270
|
switch (config.itemType) {
|
|
270
271
|
case undefined:
|
|
271
272
|
case "string":
|
|
272
273
|
return {
|
|
273
274
|
...sharedProps,
|
|
274
|
-
default:
|
|
275
|
-
type:
|
|
276
|
-
validator:
|
|
275
|
+
default: config.default,
|
|
276
|
+
type: 'array',
|
|
277
|
+
validator: config.validator,
|
|
277
278
|
transformer: config.transformer,
|
|
278
279
|
control({value, onChange, slots}) {
|
|
279
280
|
const children = useCallback((datum: any, onDatumChange: (datum: any) => void) => {
|
|
280
|
-
return <TextControl {...config.listComponent} value={datum} onChange={onDatumChange}/>;
|
|
281
|
+
return <TextControl {...config.listComponent} __nextHasNoMarginBottom __next40pxDefaultSize value={datum} onChange={onDatumChange} />;
|
|
281
282
|
}, [config.listComponent]);
|
|
282
283
|
return <SortableItemsControl {...config.component} {...slots}
|
|
283
|
-
|
|
284
|
-
|
|
284
|
+
value={value} onChange={onChange} min={config.min} max={config.max} label={config.label}
|
|
285
|
+
help={config.help} emptyValue={config.emptyValue ?? ''} children={children}
|
|
285
286
|
/>;
|
|
286
287
|
}
|
|
287
288
|
};
|
|
@@ -290,21 +291,22 @@ function hydrateDesiccatedSimpleNativeProperty(
|
|
|
290
291
|
case "integer":
|
|
291
292
|
return {
|
|
292
293
|
...sharedProps,
|
|
293
|
-
default:
|
|
294
|
-
type:
|
|
295
|
-
validator:
|
|
294
|
+
default: config.default,
|
|
295
|
+
type: 'array',
|
|
296
|
+
validator: config.validator,
|
|
296
297
|
transformer: config.transformer,
|
|
297
298
|
control({value, onChange, slots}) {
|
|
298
299
|
const children = useCallback((datum: any, onDatumChange: (datum: any) => void) => {
|
|
299
|
-
return <NumberLikeListTextControl listComponent={config.listComponent} datum={datum} itemType={config.itemType}
|
|
300
|
+
return <NumberLikeListTextControl listComponent={config.listComponent} datum={datum} itemType={config.itemType}
|
|
301
|
+
onDatumChange={onDatumChange} />;
|
|
300
302
|
}, [config.listComponent, config.itemType]);
|
|
301
303
|
return <SortableItemsControl {...config.component} {...slots}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
+
value={value} onChange={onChange} min={config.min} max={config.max} label={config.label}
|
|
305
|
+
help={config.help} emptyValue={config.emptyValue ?? 0} children={children}
|
|
304
306
|
/>;
|
|
305
307
|
}
|
|
306
308
|
};
|
|
307
|
-
default:
|
|
309
|
+
default: {
|
|
308
310
|
const currentTypes = parentTypes.toSpliced(parentTypes.length - 1, 0, 'array');
|
|
309
311
|
if (isObjectListPropertyConfig(config)) {
|
|
310
312
|
const hydratedProperties = config.itemType
|
|
@@ -312,9 +314,9 @@ function hydrateDesiccatedSimpleNativeProperty(
|
|
|
312
314
|
const def = config.default ?? [];
|
|
313
315
|
return {
|
|
314
316
|
...sharedProps,
|
|
315
|
-
children:
|
|
316
|
-
default:
|
|
317
|
-
validator:
|
|
317
|
+
children: hydratedProperties,
|
|
318
|
+
default: def, // This type-checks, but directly inlining the value doesn't
|
|
319
|
+
validator: config.validator,
|
|
318
320
|
transformer: config.transformer,
|
|
319
321
|
control({value, onChange, slots}) {
|
|
320
322
|
return <SNPListComponent config={config as ObjectListPropertyConfig} onChange={onChange} value={value}
|
|
@@ -340,10 +342,10 @@ function hydrateDesiccatedSimpleNativeProperty(
|
|
|
340
342
|
}
|
|
341
343
|
const hydratedProperties = Object.fromEntries(
|
|
342
344
|
Object.entries(completedItemTypes)
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
.map(([itemType, {properties}]) => {
|
|
346
|
+
return [itemType, properties
|
|
347
|
+
.map(property => hydrateSimpleNativeProperty(property, propPath, outsideHydrationInfo, currentTypes))]
|
|
348
|
+
})
|
|
347
349
|
);
|
|
348
350
|
const emptyValues = Object.fromEntries(
|
|
349
351
|
Object.entries(completedItemTypes).map(([itemType, {emptyValue}]) => {
|
|
@@ -352,9 +354,9 @@ function hydrateDesiccatedSimpleNativeProperty(
|
|
|
352
354
|
const def = config.default ?? [];
|
|
353
355
|
return {
|
|
354
356
|
...sharedProps,
|
|
355
|
-
children:
|
|
356
|
-
default:
|
|
357
|
-
validator:
|
|
357
|
+
children: hydratedProperties,
|
|
358
|
+
default: def, // This type-checks, but directly inlining the value doesn't
|
|
359
|
+
validator: config.validator,
|
|
358
360
|
transformer: config.transformer,
|
|
359
361
|
control({value, onChange, slots}) {
|
|
360
362
|
return <SNPFlexibleItemsListComponent
|
|
@@ -364,7 +366,9 @@ function hydrateDesiccatedSimpleNativeProperty(
|
|
|
364
366
|
}
|
|
365
367
|
}
|
|
366
368
|
}
|
|
369
|
+
}
|
|
367
370
|
}
|
|
371
|
+
}
|
|
368
372
|
case "message":
|
|
369
373
|
return {
|
|
370
374
|
type: 'string',
|
|
@@ -375,7 +379,11 @@ function hydrateDesiccatedSimpleNativeProperty(
|
|
|
375
379
|
transformer: config.transformer as any,
|
|
376
380
|
control({value}: SNPControlProps<string>) {
|
|
377
381
|
const lines = useMemo(() => {
|
|
378
|
-
|
|
382
|
+
if (value && /\r?\n/.exec(value)) {
|
|
383
|
+
// eslint-disable-next-line react/jsx-key -- random <br /> elements don't need a key
|
|
384
|
+
return value.split(/\r?\n/g).flatMap(line => [<br />, line]).slice(1);
|
|
385
|
+
}
|
|
386
|
+
return value;
|
|
379
387
|
}, [value]);
|
|
380
388
|
return <Disabled children={lines} />;
|
|
381
389
|
}
|
|
@@ -396,6 +404,7 @@ function hydrateDesiccatedSimpleNativeProperty(
|
|
|
396
404
|
|| (config.step !== undefined && !Number.isInteger(config.step));
|
|
397
405
|
return <>
|
|
398
406
|
<TextControl {...config.component}
|
|
407
|
+
__nextHasNoMarginBottom __next40pxDefaultSize
|
|
399
408
|
type="number" value={value ?? ''} min={config.min} max={config.max} step={config.step ?? (float ? "any" : undefined)}
|
|
400
409
|
onChange={safeOnChange} label={<Label />} help={config.help} placeholder={config.placeholder}
|
|
401
410
|
/>
|
|
@@ -433,7 +442,7 @@ function hydrateDesiccatedSimpleNativeProperty(
|
|
|
433
442
|
return <>
|
|
434
443
|
<RangeControl
|
|
435
444
|
{...config.component} value={value} onChange={onChange} min={config.min} max={config.max} label={config.label}
|
|
436
|
-
step={config.step} help={config.help}
|
|
445
|
+
step={config.step} help={config.help} __nextHasNoMarginBottom __next40pxDefaultSize
|
|
437
446
|
/>
|
|
438
447
|
<Messages />
|
|
439
448
|
</>;
|
|
@@ -470,7 +479,8 @@ function hydrateDesiccatedSimpleNativeProperty(
|
|
|
470
479
|
transformer: config.transformer,
|
|
471
480
|
control({value, onChange, slots: {Label, Messages}}) {
|
|
472
481
|
return <>
|
|
473
|
-
<TextControl {...config.component} value={value ?? ''}
|
|
482
|
+
<TextControl {...config.component} __nextHasNoMarginBottom __next40pxDefaultSize value={value ?? ''}
|
|
483
|
+
onChange={onChange} label={<Label />} help={config.help} placeholder={config.placeholder} />
|
|
474
484
|
<Messages />
|
|
475
485
|
</>;
|
|
476
486
|
}
|
|
@@ -488,7 +498,8 @@ function hydrateDesiccatedSimpleNativeProperty(
|
|
|
488
498
|
const switchCfg = useMemo(() => config.switch ?? {}, [config.switch]);
|
|
489
499
|
if (switchCfg.small === true) {
|
|
490
500
|
return <>
|
|
491
|
-
<ToggleControl {...config.component as Partial<ComponentPropsWithoutRef<typeof ToggleControl>>}
|
|
501
|
+
<ToggleControl {...config.component as Partial<ComponentPropsWithoutRef<typeof ToggleControl>>}
|
|
502
|
+
__nextHasNoMarginBottom checked={value} onChange={onChange} label={<Label />} help={config.help} />
|
|
492
503
|
<Messages />
|
|
493
504
|
</>;
|
|
494
505
|
} else {
|
|
@@ -574,7 +585,7 @@ const ToggleGroupControlLabelSelector: string = " > .components-base-control > .
|
|
|
574
585
|
type NumberLikeListTextControlProps = {listComponent?: ComponentPropsWithoutRef<typeof TextControl>, datum: string, itemType: string, onDatumChange(value: any): void};
|
|
575
586
|
function NumberLikeListTextControl({listComponent, datum, itemType, onDatumChange}: NumberLikeListTextControlProps) {
|
|
576
587
|
const onChange = useCallback((v: string) => onDatumChange(itemType !== 'float' ? parseInt(v) : parseFloat(v)), [itemType, onDatumChange])
|
|
577
|
-
return <TextControl {...listComponent} type="number" value={datum} onChange={onChange} />
|
|
588
|
+
return <TextControl {...listComponent} __nextHasNoMarginBottom __next40pxDefaultSize type="number" value={datum} onChange={onChange} />
|
|
578
589
|
}
|
|
579
590
|
|
|
580
591
|
type PotentiallyExtendedRadioControlProps = CSNPControlComponentProps<RadioPropertyCSNPConfig, string>&SNPControlSlots;
|
|
@@ -839,7 +850,10 @@ function hydrateSelectProperty(config: SelectPropertyCSNPConfig): HydratedSimple
|
|
|
839
850
|
control({value, onChange, slots: {Label, Messages}}) {
|
|
840
851
|
const normalizedOptions = useAsOptions(useSuspendableOptions(config), value, config.clearable ? '' : undefined);
|
|
841
852
|
return <>
|
|
842
|
-
<SelectControl
|
|
853
|
+
<SelectControl
|
|
854
|
+
__nextHasNoMarginBottom __next40pxDefaultSize
|
|
855
|
+
value={value ?? config.default ?? ''} onChange={onChange} options={normalizedOptions} label={<Label />} help={config.help}
|
|
856
|
+
/>
|
|
843
857
|
<Messages />
|
|
844
858
|
</>;
|
|
845
859
|
}
|
package/src/blocks/conditions.ts
CHANGED
|
@@ -172,7 +172,7 @@ export function resolveValueForCondition(propertyPath: RawPath, contextPath: Raw
|
|
|
172
172
|
return undefined;
|
|
173
173
|
}
|
|
174
174
|
const dataStore = getDataStore(actualPath[0]);
|
|
175
|
-
return walkToNodeWithLogging(dataStore ? dataStore.getValue(actualPath[0]) : select(
|
|
175
|
+
return walkToNodeWithLogging(dataStore ? dataStore.getValue(actualPath[0]) : select(blockEditorStore).getBlockAttributes(blockClientId)?.[actualPath[0]], actualPath);
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
function resolveActualPathToValueForCondition(propertyPath: RawPath, contextPath: RawPath): NodePath|undefined {
|
|
@@ -5,8 +5,9 @@ import type {HydratedLaidOutProperties} from "../simple-native-property-internal
|
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
|
|
8
|
+
type LaidOutPropertyRowProps = {property: HydratedLaidOutProperties[number], dataController?: DataController, inToolsPanel?: boolean};
|
|
8
9
|
export function LaidOutPropertyRow(
|
|
9
|
-
{property, dataController, inToolsPanel}:
|
|
10
|
+
{property, dataController, inToolsPanel}: LaidOutPropertyRowProps
|
|
10
11
|
) {
|
|
11
12
|
if (Array.isArray(property)) {
|
|
12
13
|
return <div style={{display: "flex", flexWrap: "wrap", columnGap: "8px"}}>
|
|
@@ -20,3 +21,8 @@ export function LaidOutPropertyRow(
|
|
|
20
21
|
</NodeContextWrapper>;
|
|
21
22
|
}
|
|
22
23
|
}
|
|
24
|
+
|
|
25
|
+
export function makeLaidOutPropertyRow({property, ...args}: LaidOutPropertyRowProps) {
|
|
26
|
+
const key = Array.isArray(property) ? property.map(prop => prop.name).join('-') : property.name;
|
|
27
|
+
return <LaidOutPropertyRow key={key} property={property} {...args} />;
|
|
28
|
+
}
|
|
@@ -3,7 +3,7 @@ import {PanelBody} from "@wordpress/components";
|
|
|
3
3
|
import {cautionFilled} from "@wordpress/icons";
|
|
4
4
|
|
|
5
5
|
import {testCondition} from "../conditions";
|
|
6
|
-
import {
|
|
6
|
+
import {makeLaidOutPropertyRow} from "./LaidOutPropertyRow";
|
|
7
7
|
import {HydratedSimpleNativePanel, isRootLevelPanelGroup} from "../simple-native-property-internal-shared";
|
|
8
8
|
import {useSNPTreeContext} from "../SNPTreeContext";
|
|
9
9
|
|
|
@@ -25,9 +25,6 @@ export function PanelRoot({panel}: PanelRootProps) {
|
|
|
25
25
|
: {};
|
|
26
26
|
|
|
27
27
|
const panelGroup = panel.group === 'layered-styles' ? 'styles' : panel.group;
|
|
28
|
-
const children = properties.map(property => {
|
|
29
|
-
const key = Array.isArray(property) ? property.map(prop => prop.name).join('-') : property.name;
|
|
30
|
-
return <LaidOutPropertyRow key={key} property={property} dataController={dataController}/>;
|
|
31
|
-
});
|
|
28
|
+
const children = properties.map(property => makeLaidOutPropertyRow({property, dataController}));
|
|
32
29
|
return <InspectorControls group={panelGroup} children={(raw ?? !isRootLevelPanelGroup(panelGroup)) ? children : <PanelBody {...panelBodyProps} {...bonusProps} children={children} />} />;
|
|
33
30
|
}
|
|
@@ -2,7 +2,7 @@ import {InspectorControls} from "@wordpress/block-editor";
|
|
|
2
2
|
import {PanelBody, TabPanel} from "@wordpress/components";
|
|
3
3
|
|
|
4
4
|
import {testCondition} from "../conditions";
|
|
5
|
-
import {LaidOutPropertyRow} from "./LaidOutPropertyRow";
|
|
5
|
+
import {LaidOutPropertyRow, makeLaidOutPropertyRow} from "./LaidOutPropertyRow";
|
|
6
6
|
import type {DataController, InspectorPanelGroup} from "../simple-native-property-api";
|
|
7
7
|
import type {HydratedSimpleNativeTab, HydratedSimpleNativeTabItem, HydratedSimpleNativeTabGroup} from "../simple-native-property-internal-shared";
|
|
8
8
|
import {useSNPTreeContext} from "../SNPTreeContext";
|
|
@@ -51,6 +51,6 @@ type RenderedTabPanelProps = {dataController: DataController, panel: HydratedSim
|
|
|
51
51
|
function RenderedTabPanel({dataController, panel}: RenderedTabPanelProps): ReactNode {
|
|
52
52
|
// We have already tested the rendered-ness of the Panel earlier, so there's no need to redo it
|
|
53
53
|
const {condition, properties, raw, ...panelBodyProps} = panel;
|
|
54
|
-
const children = properties.map(property =>
|
|
54
|
+
const children = properties.map(property => makeLaidOutPropertyRow({property, dataController}));
|
|
55
55
|
return raw ? children : <PanelBody {...panelBodyProps} opened={panelBodyProps.title ? undefined : true} children={children} />;
|
|
56
56
|
}
|
|
@@ -4,13 +4,13 @@ import type {UseBlockProps} from "@wordpress/block-editor/components/use-block-p
|
|
|
4
4
|
|
|
5
5
|
import {plauditIcon} from "../lib/plaudit-icons";
|
|
6
6
|
|
|
7
|
-
import type {ComponentType, ReactNode} from "react";
|
|
7
|
+
import type {ComponentType, ReactElement, ReactNode} from "react";
|
|
8
8
|
|
|
9
9
|
export type SimpleBlockTypeConfig<TAttributes extends Record<string, any>> = {
|
|
10
10
|
icon?: BlockConfiguration<TAttributes>['icon']|undefined,
|
|
11
11
|
defaults?: Required<TAttributes>,
|
|
12
12
|
controls?: NonNullable<Block<TAttributes>['edit']>,
|
|
13
|
-
renderer: (attributes: BlockSaveProps<TAttributes>, wrapperProps: UseBlockProps|UseBlockProps['save'], InnerBlocks: () =>
|
|
13
|
+
renderer: (attributes: BlockSaveProps<TAttributes>, wrapperProps: UseBlockProps|UseBlockProps['save'], InnerBlocks: () => ReactElement, mode: "edit"|"save") => ReactNode,
|
|
14
14
|
innerBlocksProps?: InnerBlocks.Props,
|
|
15
15
|
settings?: Partial<BlockConfiguration<TAttributes>>,
|
|
16
16
|
};
|