@elementor/editor-controls 4.2.0-894 → 4.2.0-896
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 +42 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -16
- package/src/hooks/use-form-field-suggestions.ts +58 -15
package/dist/index.mjs
CHANGED
|
@@ -8182,8 +8182,8 @@ import { Grid as Grid34, Stack as Stack19 } from "@elementor/ui";
|
|
|
8182
8182
|
import { __ as __57 } from "@wordpress/i18n";
|
|
8183
8183
|
|
|
8184
8184
|
// src/hooks/use-form-field-suggestions.ts
|
|
8185
|
-
import { getContainer as getContainer2, getSelectedElements as getSelectedElements3 } from "@elementor/editor-elements";
|
|
8186
|
-
import {
|
|
8185
|
+
import { getContainer as getContainer2, getSelectedElements as getSelectedElements3, getWidgetsCache } from "@elementor/editor-elements";
|
|
8186
|
+
import { stringPropTypeUtil as stringPropTypeUtil22 } from "@elementor/editor-props";
|
|
8187
8187
|
import { __privateUseListenTo as useListenTo2, commandEndEvent as commandEndEvent2, v1ReadyEvent } from "@elementor/editor-v1-adapters";
|
|
8188
8188
|
var FORM_FIELD_WIDGET_TYPES = [
|
|
8189
8189
|
"e-form-input",
|
|
@@ -8194,6 +8194,35 @@ var FORM_FIELD_WIDGET_TYPES = [
|
|
|
8194
8194
|
"e-form-date-picker",
|
|
8195
8195
|
"e-form-time-picker"
|
|
8196
8196
|
];
|
|
8197
|
+
var FORM_ELEMENT_TYPE = "e-form";
|
|
8198
|
+
var CSS_ID_PROP_KEY = "_cssid";
|
|
8199
|
+
function isFormFieldWidgetType(widgetType) {
|
|
8200
|
+
return FORM_FIELD_WIDGET_TYPES.includes(widgetType);
|
|
8201
|
+
}
|
|
8202
|
+
function extractStringPropValue(value) {
|
|
8203
|
+
return stringPropTypeUtil22.extract(value);
|
|
8204
|
+
}
|
|
8205
|
+
function getSettingWithDefault(child, widgetType, key) {
|
|
8206
|
+
const fromGet = child.settings.get(key);
|
|
8207
|
+
if (fromGet !== null && fromGet !== void 0) {
|
|
8208
|
+
return fromGet;
|
|
8209
|
+
}
|
|
8210
|
+
const schema = getWidgetsCache()?.[widgetType]?.atomic_props_schema;
|
|
8211
|
+
return schema?.[key]?.default ?? null;
|
|
8212
|
+
}
|
|
8213
|
+
function getFieldCssId(child, widgetType) {
|
|
8214
|
+
return extractStringPropValue(getSettingWithDefault(child, widgetType, CSS_ID_PROP_KEY));
|
|
8215
|
+
}
|
|
8216
|
+
function getFormContainer(elementId) {
|
|
8217
|
+
let container = getContainer2(elementId);
|
|
8218
|
+
while (container) {
|
|
8219
|
+
if (container.model.get("elType") === FORM_ELEMENT_TYPE) {
|
|
8220
|
+
return container;
|
|
8221
|
+
}
|
|
8222
|
+
container = container.parent ?? null;
|
|
8223
|
+
}
|
|
8224
|
+
return null;
|
|
8225
|
+
}
|
|
8197
8226
|
function useFormFieldSuggestions(options) {
|
|
8198
8227
|
return useListenTo2(
|
|
8199
8228
|
[
|
|
@@ -8204,32 +8233,33 @@ function useFormFieldSuggestions(options) {
|
|
|
8204
8233
|
],
|
|
8205
8234
|
() => {
|
|
8206
8235
|
const selectedElements = getSelectedElements3();
|
|
8207
|
-
const
|
|
8208
|
-
if (!
|
|
8236
|
+
const selectedElement = selectedElements[0];
|
|
8237
|
+
if (!selectedElement) {
|
|
8209
8238
|
return [];
|
|
8210
8239
|
}
|
|
8211
|
-
const
|
|
8212
|
-
if (!
|
|
8240
|
+
const formContainer = getFormContainer(selectedElement.id);
|
|
8241
|
+
if (!formContainer?.children) {
|
|
8213
8242
|
return [];
|
|
8214
8243
|
}
|
|
8215
8244
|
const suggestions = [];
|
|
8216
|
-
|
|
8245
|
+
const seenCssIds = /* @__PURE__ */ new Set();
|
|
8246
|
+
formContainer.children.forEachRecursive?.((child) => {
|
|
8217
8247
|
const widgetType = child.model.get("widgetType");
|
|
8218
|
-
if (!widgetType || !
|
|
8248
|
+
if (!widgetType || !isFormFieldWidgetType(widgetType)) {
|
|
8219
8249
|
return;
|
|
8220
8250
|
}
|
|
8221
8251
|
if (options?.inputType) {
|
|
8222
|
-
const
|
|
8223
|
-
const typeValue = isTransformable3(typeProp) ? typeProp.value : typeProp;
|
|
8252
|
+
const typeValue = extractStringPropValue(getSettingWithDefault(child, widgetType, "type"));
|
|
8224
8253
|
if (typeValue !== options.inputType) {
|
|
8225
8254
|
return;
|
|
8226
8255
|
}
|
|
8227
8256
|
}
|
|
8228
|
-
const
|
|
8229
|
-
|
|
8230
|
-
|
|
8231
|
-
suggestions.push({ label: fieldId, value: fieldId });
|
|
8257
|
+
const cssId = getFieldCssId(child, widgetType);
|
|
8258
|
+
if (!cssId || seenCssIds.has(cssId)) {
|
|
8259
|
+
return;
|
|
8232
8260
|
}
|
|
8261
|
+
seenCssIds.add(cssId);
|
|
8262
|
+
suggestions.push({ label: cssId, value: cssId });
|
|
8233
8263
|
});
|
|
8234
8264
|
return suggestions;
|
|
8235
8265
|
},
|
|
@@ -8240,7 +8270,7 @@ function useFormFieldSuggestions(options) {
|
|
|
8240
8270
|
// src/controls/email-form-action-control/email-chips-field.tsx
|
|
8241
8271
|
import * as React116 from "react";
|
|
8242
8272
|
import { useState as useState19 } from "react";
|
|
8243
|
-
import { stringArrayPropTypeUtil as stringArrayPropTypeUtil3, stringPropTypeUtil as
|
|
8273
|
+
import { stringArrayPropTypeUtil as stringArrayPropTypeUtil3, stringPropTypeUtil as stringPropTypeUtil23 } from "@elementor/editor-props";
|
|
8244
8274
|
import { Autocomplete as Autocomplete4, Grid as Grid32, TextField as TextField11 } from "@elementor/ui";
|
|
8245
8275
|
|
|
8246
8276
|
// src/controls/email-form-action-control/utils.ts
|
|
@@ -8267,13 +8297,13 @@ var EmailChipsField = ({ fieldLabel, placeholder }) => {
|
|
|
8267
8297
|
const { value, setValue, disabled } = useBoundProp(stringArrayPropTypeUtil3);
|
|
8268
8298
|
const [inputValue, setInputValue] = useState19("");
|
|
8269
8299
|
const items2 = value || [];
|
|
8270
|
-
const selectedValues = items2.map((item) =>
|
|
8300
|
+
const selectedValues = items2.map((item) => stringPropTypeUtil23.extract(item)).filter((val) => val !== null);
|
|
8271
8301
|
const tryAddChip = (raw) => {
|
|
8272
8302
|
const address = raw.trim();
|
|
8273
8303
|
if (!address || selectedValues.includes(address) || !isValidEmail(address)) {
|
|
8274
8304
|
return;
|
|
8275
8305
|
}
|
|
8276
|
-
setValue([...items2,
|
|
8306
|
+
setValue([...items2, stringPropTypeUtil23.create(address)]);
|
|
8277
8307
|
setInputValue("");
|
|
8278
8308
|
};
|
|
8279
8309
|
const handleChange = (_, newValue) => {
|
|
@@ -8283,7 +8313,7 @@ var EmailChipsField = ({ fieldLabel, placeholder }) => {
|
|
|
8283
8313
|
if (!address || !isValidEmail(address)) {
|
|
8284
8314
|
continue;
|
|
8285
8315
|
}
|
|
8286
|
-
updated.push(
|
|
8316
|
+
updated.push(stringPropTypeUtil23.create(address));
|
|
8287
8317
|
}
|
|
8288
8318
|
setValue(updated);
|
|
8289
8319
|
setInputValue("");
|