@elementor/editor-controls 4.2.0-873 → 4.2.0-875
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/dist/index.js +64 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -16
- package/src/controls/query-filter-repeater-control.tsx +91 -12
package/dist/index.mjs
CHANGED
|
@@ -4840,9 +4840,12 @@ function extractChips(value) {
|
|
|
4840
4840
|
// src/controls/query-filter-repeater-control.tsx
|
|
4841
4841
|
import * as React77 from "react";
|
|
4842
4842
|
import { useMemo as useMemo12, useRef as useRef13 } from "react";
|
|
4843
|
+
import { useSelectedElementSettings } from "@elementor/editor-elements";
|
|
4843
4844
|
import {
|
|
4845
|
+
extractValue,
|
|
4844
4846
|
queryFilterArrayPropTypeUtil,
|
|
4845
4847
|
queryFilterPropTypeUtil,
|
|
4848
|
+
stringArrayPropTypeUtil as stringArrayPropTypeUtil2,
|
|
4846
4849
|
stringPropTypeUtil as stringPropTypeUtil13
|
|
4847
4850
|
} from "@elementor/editor-props";
|
|
4848
4851
|
import { PlusIcon as PlusIcon3 } from "@elementor/icons";
|
|
@@ -4856,20 +4859,25 @@ var QueryFilterRepeaterControl = createControl(
|
|
|
4856
4859
|
chipsPlaceholder
|
|
4857
4860
|
}) => {
|
|
4858
4861
|
const { propType, value, setValue } = useBoundProp(queryFilterArrayPropTypeUtil);
|
|
4862
|
+
const { settings } = useSelectedElementSettings();
|
|
4863
|
+
const visibleKeys = useMemo12(
|
|
4864
|
+
() => allowedKeys.filter((key) => isKeyVisible(keyConfig[key]?.visibleWhen, settings)),
|
|
4865
|
+
[allowedKeys, keyConfig, settings]
|
|
4866
|
+
);
|
|
4859
4867
|
const usedKeys = useMemo12(() => getUsedKeys(value ?? []), [value]);
|
|
4860
4868
|
const nextAvailableKey = useMemo12(
|
|
4861
|
-
() =>
|
|
4862
|
-
[
|
|
4869
|
+
() => visibleKeys.find((key) => !usedKeys.has(key)) ?? null,
|
|
4870
|
+
[visibleKeys, usedKeys]
|
|
4863
4871
|
);
|
|
4864
4872
|
const getKeySelectOptions = useMemo12(
|
|
4865
|
-
() => (currentKey) =>
|
|
4873
|
+
() => (currentKey) => visibleKeys.map((itemKey) => ({
|
|
4866
4874
|
value: itemKey,
|
|
4867
4875
|
label: keyConfig[itemKey]?.label ?? itemKey,
|
|
4868
4876
|
disabled: itemKey !== currentKey && usedKeys.has(itemKey)
|
|
4869
4877
|
})),
|
|
4870
|
-
[
|
|
4878
|
+
[visibleKeys, keyConfig, usedKeys]
|
|
4871
4879
|
);
|
|
4872
|
-
const initialFallback = useMemo12(() => createItemForKey(
|
|
4880
|
+
const initialFallback = useMemo12(() => createItemForKey(visibleKeys[0] ?? ""), [visibleKeys]);
|
|
4873
4881
|
return /* @__PURE__ */ React77.createElement(PropProvider, { propType, value, setValue }, /* @__PURE__ */ React77.createElement(ControlRepeater, { initial: initialFallback, propTypeUtil: queryFilterArrayPropTypeUtil }, /* @__PURE__ */ React77.createElement(RepeaterHeader, { label }, /* @__PURE__ */ React77.createElement(AddFilterItemAction, { nextAvailableKey, ariaLabel: label })), /* @__PURE__ */ React77.createElement(ItemsContainer, { isSortable: false }, /* @__PURE__ */ React77.createElement(
|
|
4874
4882
|
Item,
|
|
4875
4883
|
{
|
|
@@ -4915,7 +4923,12 @@ var ItemLabel2 = ({ value, keyConfig }) => {
|
|
|
4915
4923
|
const itemKey = stringPropTypeUtil13.extract(value?.value?.key);
|
|
4916
4924
|
const label = itemKey && keyConfig[itemKey]?.label || __28("Item", "elementor");
|
|
4917
4925
|
const chipLabels = extractChipLabels(value?.value?.values);
|
|
4918
|
-
const
|
|
4926
|
+
const taxonomyLabels = extractTaxonomyLabels(
|
|
4927
|
+
value?.value?.taxonomies,
|
|
4928
|
+
itemKey ? keyConfig[itemKey] : void 0
|
|
4929
|
+
);
|
|
4930
|
+
const allLabels = [...chipLabels, ...taxonomyLabels];
|
|
4931
|
+
const suffix = allLabels.length > 0 ? `: ${allLabels.join(", ")}` : "";
|
|
4919
4932
|
return /* @__PURE__ */ React77.createElement(Box14, { component: "span" }, label, suffix);
|
|
4920
4933
|
};
|
|
4921
4934
|
function extractChipLabels(chipsProp) {
|
|
@@ -4928,7 +4941,7 @@ var ItemContent = ({
|
|
|
4928
4941
|
chipsPlaceholder
|
|
4929
4942
|
}) => {
|
|
4930
4943
|
const propContext = useBoundProp(queryFilterPropTypeUtil);
|
|
4931
|
-
const
|
|
4944
|
+
const snapshotsByKeyRef = useRef13({});
|
|
4932
4945
|
const handleValueChange = (nextValue, options, meta) => {
|
|
4933
4946
|
if (meta?.bind !== "key") {
|
|
4934
4947
|
propContext.setValue(nextValue, options, meta);
|
|
@@ -4937,16 +4950,27 @@ var ItemContent = ({
|
|
|
4937
4950
|
const previousKey = stringPropTypeUtil13.extract(propContext.value?.key);
|
|
4938
4951
|
const newKey = stringPropTypeUtil13.extract(nextValue?.key);
|
|
4939
4952
|
if (previousKey) {
|
|
4940
|
-
|
|
4953
|
+
snapshotsByKeyRef.current[previousKey] = {
|
|
4954
|
+
values: propContext.value?.values ?? null,
|
|
4955
|
+
taxonomies: propContext.value?.taxonomies ?? null
|
|
4956
|
+
};
|
|
4941
4957
|
}
|
|
4942
|
-
const
|
|
4943
|
-
propContext.setValue(
|
|
4958
|
+
const restored = newKey ? snapshotsByKeyRef.current[newKey] : void 0;
|
|
4959
|
+
propContext.setValue(
|
|
4960
|
+
{
|
|
4961
|
+
...nextValue,
|
|
4962
|
+
values: restored?.values ?? null,
|
|
4963
|
+
taxonomies: restored?.taxonomies ?? null
|
|
4964
|
+
},
|
|
4965
|
+
options,
|
|
4966
|
+
meta
|
|
4967
|
+
);
|
|
4944
4968
|
};
|
|
4945
4969
|
const currentKey = stringPropTypeUtil13.extract(propContext.value?.key);
|
|
4946
4970
|
const currentKeyConfig = currentKey ? keyConfig[currentKey] : void 0;
|
|
4947
|
-
const
|
|
4971
|
+
const valueType = currentKeyConfig?.valueType ?? "chips";
|
|
4948
4972
|
const keySelectOptions = useMemo12(() => getKeySelectOptions(currentKey), [getKeySelectOptions, currentKey]);
|
|
4949
|
-
return /* @__PURE__ */ React77.createElement(PopoverContent, { p: 1.5 }, /* @__PURE__ */ React77.createElement(PropProvider, { ...propContext, setValue: handleValueChange }, /* @__PURE__ */ React77.createElement(PopoverGridContainer, { flexWrap: "wrap" }, /* @__PURE__ */ React77.createElement(Grid11, { item: true, xs: 12 }, /* @__PURE__ */ React77.createElement(ControlFormLabel, null, __28("Type", "elementor"))), /* @__PURE__ */ React77.createElement(Grid11, { item: true, xs: 12 }, /* @__PURE__ */ React77.createElement(PropKeyProvider, { bind: "key" }, /* @__PURE__ */ React77.createElement(SelectControl, { options: keySelectOptions })))),
|
|
4973
|
+
return /* @__PURE__ */ React77.createElement(PopoverContent, { p: 1.5 }, /* @__PURE__ */ React77.createElement(PropProvider, { ...propContext, setValue: handleValueChange }, /* @__PURE__ */ React77.createElement(PopoverGridContainer, { flexWrap: "wrap" }, /* @__PURE__ */ React77.createElement(Grid11, { item: true, xs: 12 }, /* @__PURE__ */ React77.createElement(ControlFormLabel, null, __28("Type", "elementor"))), /* @__PURE__ */ React77.createElement(Grid11, { item: true, xs: 12 }, /* @__PURE__ */ React77.createElement(PropKeyProvider, { bind: "key" }, /* @__PURE__ */ React77.createElement(SelectControl, { options: keySelectOptions })))), valueType === "taxonomies" && currentKeyConfig?.staticOptions && /* @__PURE__ */ React77.createElement(PopoverGridContainer, { flexWrap: "wrap" }, /* @__PURE__ */ React77.createElement(Grid11, { item: true, xs: 12 }, /* @__PURE__ */ React77.createElement(ControlFormLabel, null, currentKeyConfig.label)), /* @__PURE__ */ React77.createElement(Grid11, { item: true, xs: 12 }, /* @__PURE__ */ React77.createElement(PropKeyProvider, { bind: "taxonomies" }, /* @__PURE__ */ React77.createElement(ChipsControl, { options: currentKeyConfig.staticOptions })))), valueType !== "taxonomies" && currentKeyConfig?.queryEndpoint && /* @__PURE__ */ React77.createElement(PopoverGridContainer, { flexWrap: "wrap" }, /* @__PURE__ */ React77.createElement(Grid11, { item: true, xs: 12 }, /* @__PURE__ */ React77.createElement(ControlFormLabel, null, currentKeyConfig.label)), /* @__PURE__ */ React77.createElement(Grid11, { item: true, xs: 12 }, /* @__PURE__ */ React77.createElement(PropKeyProvider, { bind: "values" }, /* @__PURE__ */ React77.createElement(
|
|
4950
4974
|
QueryChipsControl,
|
|
4951
4975
|
{
|
|
4952
4976
|
queryOptions: {
|
|
@@ -4957,10 +4981,29 @@ var ItemContent = ({
|
|
|
4957
4981
|
}
|
|
4958
4982
|
))))));
|
|
4959
4983
|
};
|
|
4984
|
+
function isKeyVisible(rule, settings) {
|
|
4985
|
+
if (!rule) {
|
|
4986
|
+
return true;
|
|
4987
|
+
}
|
|
4988
|
+
if (!settings) {
|
|
4989
|
+
return false;
|
|
4990
|
+
}
|
|
4991
|
+
const extracted = stringPropTypeUtil13.extract(extractValue(rule.path, settings));
|
|
4992
|
+
return extracted !== null && rule.in.includes(extracted);
|
|
4993
|
+
}
|
|
4994
|
+
function extractTaxonomyLabels(taxonomiesProp, config) {
|
|
4995
|
+
const slugs = (stringArrayPropTypeUtil2.extract(taxonomiesProp) ?? []).map((item) => stringPropTypeUtil13.extract(item)).filter((slug) => !!slug);
|
|
4996
|
+
if (!slugs.length) {
|
|
4997
|
+
return [];
|
|
4998
|
+
}
|
|
4999
|
+
const options = config?.staticOptions ?? [];
|
|
5000
|
+
return slugs.map((slug) => options.find((opt) => opt.value === slug)?.label ?? slug);
|
|
5001
|
+
}
|
|
4960
5002
|
function createItemForKey(key) {
|
|
4961
5003
|
return queryFilterPropTypeUtil.create({
|
|
4962
5004
|
key: stringPropTypeUtil13.create(key),
|
|
4963
|
-
values: null
|
|
5005
|
+
values: null,
|
|
5006
|
+
taxonomies: null
|
|
4964
5007
|
});
|
|
4965
5008
|
}
|
|
4966
5009
|
function getUsedKeys(items2) {
|
|
@@ -8173,7 +8216,7 @@ function useFormFieldSuggestions(options) {
|
|
|
8173
8216
|
// src/controls/email-form-action-control/email-chips-field.tsx
|
|
8174
8217
|
import * as React116 from "react";
|
|
8175
8218
|
import { useState as useState19 } from "react";
|
|
8176
|
-
import { stringArrayPropTypeUtil as
|
|
8219
|
+
import { stringArrayPropTypeUtil as stringArrayPropTypeUtil3, stringPropTypeUtil as stringPropTypeUtil22 } from "@elementor/editor-props";
|
|
8177
8220
|
import { Autocomplete as Autocomplete4, Grid as Grid32, TextField as TextField11 } from "@elementor/ui";
|
|
8178
8221
|
|
|
8179
8222
|
// src/controls/email-form-action-control/utils.ts
|
|
@@ -8197,7 +8240,7 @@ var shouldShowMentionsInfo = () => {
|
|
|
8197
8240
|
|
|
8198
8241
|
// src/controls/email-form-action-control/email-chips-field.tsx
|
|
8199
8242
|
var EmailChipsField = ({ fieldLabel, placeholder }) => {
|
|
8200
|
-
const { value, setValue, disabled } = useBoundProp(
|
|
8243
|
+
const { value, setValue, disabled } = useBoundProp(stringArrayPropTypeUtil3);
|
|
8201
8244
|
const [inputValue, setInputValue] = useState19("");
|
|
8202
8245
|
const items2 = value || [];
|
|
8203
8246
|
const selectedValues = items2.map((item) => stringPropTypeUtil22.extract(item)).filter((val) => val !== null);
|