@elementor/editor-controls 4.2.0-874 → 4.2.0-876
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.js
CHANGED
|
@@ -4914,6 +4914,7 @@ function extractChips(value) {
|
|
|
4914
4914
|
// src/controls/query-filter-repeater-control.tsx
|
|
4915
4915
|
var React77 = __toESM(require("react"));
|
|
4916
4916
|
var import_react45 = require("react");
|
|
4917
|
+
var import_editor_elements4 = require("@elementor/editor-elements");
|
|
4917
4918
|
var import_editor_props31 = require("@elementor/editor-props");
|
|
4918
4919
|
var import_icons18 = require("@elementor/icons");
|
|
4919
4920
|
var import_ui60 = require("@elementor/ui");
|
|
@@ -4926,20 +4927,25 @@ var QueryFilterRepeaterControl = createControl(
|
|
|
4926
4927
|
chipsPlaceholder
|
|
4927
4928
|
}) => {
|
|
4928
4929
|
const { propType, value, setValue } = useBoundProp(import_editor_props31.queryFilterArrayPropTypeUtil);
|
|
4930
|
+
const { settings } = (0, import_editor_elements4.useSelectedElementSettings)();
|
|
4931
|
+
const visibleKeys = (0, import_react45.useMemo)(
|
|
4932
|
+
() => allowedKeys.filter((key) => isKeyVisible(keyConfig[key]?.visibleWhen, settings)),
|
|
4933
|
+
[allowedKeys, keyConfig, settings]
|
|
4934
|
+
);
|
|
4929
4935
|
const usedKeys = (0, import_react45.useMemo)(() => getUsedKeys(value ?? []), [value]);
|
|
4930
4936
|
const nextAvailableKey = (0, import_react45.useMemo)(
|
|
4931
|
-
() =>
|
|
4932
|
-
[
|
|
4937
|
+
() => visibleKeys.find((key) => !usedKeys.has(key)) ?? null,
|
|
4938
|
+
[visibleKeys, usedKeys]
|
|
4933
4939
|
);
|
|
4934
4940
|
const getKeySelectOptions = (0, import_react45.useMemo)(
|
|
4935
|
-
() => (currentKey) =>
|
|
4941
|
+
() => (currentKey) => visibleKeys.map((itemKey) => ({
|
|
4936
4942
|
value: itemKey,
|
|
4937
4943
|
label: keyConfig[itemKey]?.label ?? itemKey,
|
|
4938
4944
|
disabled: itemKey !== currentKey && usedKeys.has(itemKey)
|
|
4939
4945
|
})),
|
|
4940
|
-
[
|
|
4946
|
+
[visibleKeys, keyConfig, usedKeys]
|
|
4941
4947
|
);
|
|
4942
|
-
const initialFallback = (0, import_react45.useMemo)(() => createItemForKey(
|
|
4948
|
+
const initialFallback = (0, import_react45.useMemo)(() => createItemForKey(visibleKeys[0] ?? ""), [visibleKeys]);
|
|
4943
4949
|
return /* @__PURE__ */ React77.createElement(PropProvider, { propType, value, setValue }, /* @__PURE__ */ React77.createElement(ControlRepeater, { initial: initialFallback, propTypeUtil: import_editor_props31.queryFilterArrayPropTypeUtil }, /* @__PURE__ */ React77.createElement(RepeaterHeader, { label }, /* @__PURE__ */ React77.createElement(AddFilterItemAction, { nextAvailableKey, ariaLabel: label })), /* @__PURE__ */ React77.createElement(ItemsContainer, { isSortable: false }, /* @__PURE__ */ React77.createElement(
|
|
4944
4950
|
Item,
|
|
4945
4951
|
{
|
|
@@ -4985,7 +4991,12 @@ var ItemLabel2 = ({ value, keyConfig }) => {
|
|
|
4985
4991
|
const itemKey = import_editor_props31.stringPropTypeUtil.extract(value?.value?.key);
|
|
4986
4992
|
const label = itemKey && keyConfig[itemKey]?.label || (0, import_i18n28.__)("Item", "elementor");
|
|
4987
4993
|
const chipLabels = extractChipLabels(value?.value?.values);
|
|
4988
|
-
const
|
|
4994
|
+
const taxonomyLabels = extractTaxonomyLabels(
|
|
4995
|
+
value?.value?.taxonomies,
|
|
4996
|
+
itemKey ? keyConfig[itemKey] : void 0
|
|
4997
|
+
);
|
|
4998
|
+
const allLabels = [...chipLabels, ...taxonomyLabels];
|
|
4999
|
+
const suffix = allLabels.length > 0 ? `: ${allLabels.join(", ")}` : "";
|
|
4989
5000
|
return /* @__PURE__ */ React77.createElement(import_ui60.Box, { component: "span" }, label, suffix);
|
|
4990
5001
|
};
|
|
4991
5002
|
function extractChipLabels(chipsProp) {
|
|
@@ -4998,7 +5009,7 @@ var ItemContent = ({
|
|
|
4998
5009
|
chipsPlaceholder
|
|
4999
5010
|
}) => {
|
|
5000
5011
|
const propContext = useBoundProp(import_editor_props31.queryFilterPropTypeUtil);
|
|
5001
|
-
const
|
|
5012
|
+
const snapshotsByKeyRef = (0, import_react45.useRef)({});
|
|
5002
5013
|
const handleValueChange = (nextValue, options, meta) => {
|
|
5003
5014
|
if (meta?.bind !== "key") {
|
|
5004
5015
|
propContext.setValue(nextValue, options, meta);
|
|
@@ -5007,16 +5018,27 @@ var ItemContent = ({
|
|
|
5007
5018
|
const previousKey = import_editor_props31.stringPropTypeUtil.extract(propContext.value?.key);
|
|
5008
5019
|
const newKey = import_editor_props31.stringPropTypeUtil.extract(nextValue?.key);
|
|
5009
5020
|
if (previousKey) {
|
|
5010
|
-
|
|
5021
|
+
snapshotsByKeyRef.current[previousKey] = {
|
|
5022
|
+
values: propContext.value?.values ?? null,
|
|
5023
|
+
taxonomies: propContext.value?.taxonomies ?? null
|
|
5024
|
+
};
|
|
5011
5025
|
}
|
|
5012
|
-
const
|
|
5013
|
-
propContext.setValue(
|
|
5026
|
+
const restored = newKey ? snapshotsByKeyRef.current[newKey] : void 0;
|
|
5027
|
+
propContext.setValue(
|
|
5028
|
+
{
|
|
5029
|
+
...nextValue,
|
|
5030
|
+
values: restored?.values ?? null,
|
|
5031
|
+
taxonomies: restored?.taxonomies ?? null
|
|
5032
|
+
},
|
|
5033
|
+
options,
|
|
5034
|
+
meta
|
|
5035
|
+
);
|
|
5014
5036
|
};
|
|
5015
5037
|
const currentKey = import_editor_props31.stringPropTypeUtil.extract(propContext.value?.key);
|
|
5016
5038
|
const currentKeyConfig = currentKey ? keyConfig[currentKey] : void 0;
|
|
5017
|
-
const
|
|
5039
|
+
const valueType = currentKeyConfig?.valueType ?? "chips";
|
|
5018
5040
|
const keySelectOptions = (0, import_react45.useMemo)(() => getKeySelectOptions(currentKey), [getKeySelectOptions, currentKey]);
|
|
5019
|
-
return /* @__PURE__ */ React77.createElement(PopoverContent, { p: 1.5 }, /* @__PURE__ */ React77.createElement(PropProvider, { ...propContext, setValue: handleValueChange }, /* @__PURE__ */ React77.createElement(PopoverGridContainer, { flexWrap: "wrap" }, /* @__PURE__ */ React77.createElement(import_ui60.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React77.createElement(ControlFormLabel, null, (0, import_i18n28.__)("Type", "elementor"))), /* @__PURE__ */ React77.createElement(import_ui60.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React77.createElement(PropKeyProvider, { bind: "key" }, /* @__PURE__ */ React77.createElement(SelectControl, { options: keySelectOptions })))),
|
|
5041
|
+
return /* @__PURE__ */ React77.createElement(PopoverContent, { p: 1.5 }, /* @__PURE__ */ React77.createElement(PropProvider, { ...propContext, setValue: handleValueChange }, /* @__PURE__ */ React77.createElement(PopoverGridContainer, { flexWrap: "wrap" }, /* @__PURE__ */ React77.createElement(import_ui60.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React77.createElement(ControlFormLabel, null, (0, import_i18n28.__)("Type", "elementor"))), /* @__PURE__ */ React77.createElement(import_ui60.Grid, { 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(import_ui60.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React77.createElement(ControlFormLabel, null, currentKeyConfig.label)), /* @__PURE__ */ React77.createElement(import_ui60.Grid, { 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(import_ui60.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React77.createElement(ControlFormLabel, null, currentKeyConfig.label)), /* @__PURE__ */ React77.createElement(import_ui60.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React77.createElement(PropKeyProvider, { bind: "values" }, /* @__PURE__ */ React77.createElement(
|
|
5020
5042
|
QueryChipsControl,
|
|
5021
5043
|
{
|
|
5022
5044
|
queryOptions: {
|
|
@@ -5027,10 +5049,29 @@ var ItemContent = ({
|
|
|
5027
5049
|
}
|
|
5028
5050
|
))))));
|
|
5029
5051
|
};
|
|
5052
|
+
function isKeyVisible(rule, settings) {
|
|
5053
|
+
if (!rule) {
|
|
5054
|
+
return true;
|
|
5055
|
+
}
|
|
5056
|
+
if (!settings) {
|
|
5057
|
+
return false;
|
|
5058
|
+
}
|
|
5059
|
+
const extracted = import_editor_props31.stringPropTypeUtil.extract((0, import_editor_props31.extractValue)(rule.path, settings));
|
|
5060
|
+
return extracted !== null && rule.in.includes(extracted);
|
|
5061
|
+
}
|
|
5062
|
+
function extractTaxonomyLabels(taxonomiesProp, config) {
|
|
5063
|
+
const slugs = (import_editor_props31.stringArrayPropTypeUtil.extract(taxonomiesProp) ?? []).map((item) => import_editor_props31.stringPropTypeUtil.extract(item)).filter((slug) => !!slug);
|
|
5064
|
+
if (!slugs.length) {
|
|
5065
|
+
return [];
|
|
5066
|
+
}
|
|
5067
|
+
const options = config?.staticOptions ?? [];
|
|
5068
|
+
return slugs.map((slug) => options.find((opt) => opt.value === slug)?.label ?? slug);
|
|
5069
|
+
}
|
|
5030
5070
|
function createItemForKey(key) {
|
|
5031
5071
|
return import_editor_props31.queryFilterPropTypeUtil.create({
|
|
5032
5072
|
key: import_editor_props31.stringPropTypeUtil.create(key),
|
|
5033
|
-
values: null
|
|
5073
|
+
values: null,
|
|
5074
|
+
taxonomies: null
|
|
5034
5075
|
});
|
|
5035
5076
|
}
|
|
5036
5077
|
function getUsedKeys(items2) {
|
|
@@ -7205,7 +7246,7 @@ var transitionsItemsList = transitionProperties.map((category) => ({
|
|
|
7205
7246
|
}));
|
|
7206
7247
|
|
|
7207
7248
|
// src/controls/transition-control/trainsition-events.ts
|
|
7208
|
-
var
|
|
7249
|
+
var import_editor_elements5 = require("@elementor/editor-elements");
|
|
7209
7250
|
var import_events = require("@elementor/events");
|
|
7210
7251
|
var transitionRepeaterMixpanelEvent = {
|
|
7211
7252
|
eventName: "click_added_transition",
|
|
@@ -7217,7 +7258,7 @@ function subscribeToTransitionEvent() {
|
|
|
7217
7258
|
eventBus.subscribe("transition-item-added", (data) => {
|
|
7218
7259
|
const payload = data;
|
|
7219
7260
|
const value = payload?.itemValue?.selection?.value?.value?.value;
|
|
7220
|
-
const selectedElements = (0,
|
|
7261
|
+
const selectedElements = (0, import_editor_elements5.getSelectedElements)();
|
|
7221
7262
|
const widgetType = selectedElements[0]?.type ?? null;
|
|
7222
7263
|
(0, import_events.trackEvent)({
|
|
7223
7264
|
transition_type: value ?? "unknown",
|
|
@@ -7237,7 +7278,7 @@ var import_ui91 = require("@elementor/ui");
|
|
|
7237
7278
|
var import_i18n53 = require("@wordpress/i18n");
|
|
7238
7279
|
|
|
7239
7280
|
// src/utils/tracking.ts
|
|
7240
|
-
var
|
|
7281
|
+
var import_editor_elements6 = require("@elementor/editor-elements");
|
|
7241
7282
|
var import_events2 = require("@elementor/events");
|
|
7242
7283
|
var getBaseEventProperties = (data, config) => ({
|
|
7243
7284
|
app_type: config?.appTypes?.editor ?? "editor",
|
|
@@ -7245,7 +7286,7 @@ var getBaseEventProperties = (data, config) => ({
|
|
|
7245
7286
|
interaction_type: config?.triggers?.click ?? "Click",
|
|
7246
7287
|
target_name: data.target_name,
|
|
7247
7288
|
target_location: data.target_location ?? "widget_panel",
|
|
7248
|
-
location_l1: data.location_l1 ?? (0,
|
|
7289
|
+
location_l1: data.location_l1 ?? (0, import_editor_elements6.getSelectedElements)()[0]?.type ?? "",
|
|
7249
7290
|
...data.location_l2 && { location_l2: data.location_l2 }
|
|
7250
7291
|
});
|
|
7251
7292
|
var dispatchPromotionEvent = (data, resolveOptions) => {
|
|
@@ -8132,7 +8173,7 @@ var import_ui102 = require("@elementor/ui");
|
|
|
8132
8173
|
var import_i18n57 = require("@wordpress/i18n");
|
|
8133
8174
|
|
|
8134
8175
|
// src/hooks/use-form-field-suggestions.ts
|
|
8135
|
-
var
|
|
8176
|
+
var import_editor_elements7 = require("@elementor/editor-elements");
|
|
8136
8177
|
var import_editor_props64 = require("@elementor/editor-props");
|
|
8137
8178
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
8138
8179
|
var FORM_FIELD_WIDGET_TYPES = [
|
|
@@ -8153,12 +8194,12 @@ function useFormFieldSuggestions(options) {
|
|
|
8153
8194
|
(0, import_editor_v1_adapters.commandEndEvent)("document/elements/set-settings")
|
|
8154
8195
|
],
|
|
8155
8196
|
() => {
|
|
8156
|
-
const selectedElements = (0,
|
|
8197
|
+
const selectedElements = (0, import_editor_elements7.getSelectedElements)();
|
|
8157
8198
|
const formElement = selectedElements[0];
|
|
8158
8199
|
if (!formElement) {
|
|
8159
8200
|
return [];
|
|
8160
8201
|
}
|
|
8161
|
-
const container = (0,
|
|
8202
|
+
const container = (0, import_editor_elements7.getContainer)(formElement.id);
|
|
8162
8203
|
if (!container?.children) {
|
|
8163
8204
|
return [];
|
|
8164
8205
|
}
|
|
@@ -8765,7 +8806,7 @@ var usePopover = (openOnMount, onOpen, onPopoverClose) => {
|
|
|
8765
8806
|
// src/components/inline-editor-toolbar.tsx
|
|
8766
8807
|
var React128 = __toESM(require("react"));
|
|
8767
8808
|
var import_react75 = require("react");
|
|
8768
|
-
var
|
|
8809
|
+
var import_editor_elements8 = require("@elementor/editor-elements");
|
|
8769
8810
|
var import_icons42 = require("@elementor/icons");
|
|
8770
8811
|
var import_ui112 = require("@elementor/ui");
|
|
8771
8812
|
var import_react76 = require("@tiptap/react");
|
|
@@ -8959,10 +9000,10 @@ var InlineEditorToolbar = ({ editor, elementId, sx = {} }) => {
|
|
|
8959
9000
|
);
|
|
8960
9001
|
};
|
|
8961
9002
|
var checkIfElementIsClickable = (elementId) => {
|
|
8962
|
-
const container = (0,
|
|
9003
|
+
const container = (0, import_editor_elements8.getContainer)(elementId);
|
|
8963
9004
|
const type = container?.model.get("widgetType");
|
|
8964
9005
|
const isButton = type === "e-button";
|
|
8965
|
-
const hasLink = !!(0,
|
|
9006
|
+
const hasLink = !!(0, import_editor_elements8.getElementSetting)(elementId, "link")?.value?.destination;
|
|
8966
9007
|
return isButton || hasLink;
|
|
8967
9008
|
};
|
|
8968
9009
|
var toolbarButtons = {
|