@elementor/editor-controls 4.3.0-1007 → 4.3.0-1009

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.mjs CHANGED
@@ -8275,7 +8275,7 @@ function useFormFieldSuggestions(options) {
8275
8275
 
8276
8276
  // src/controls/email-form-action-control/email-chips-field.tsx
8277
8277
  import * as React116 from "react";
8278
- import { useState as useState19 } from "react";
8278
+ import { useMemo as useMemo18, useState as useState19 } from "react";
8279
8279
  import { stringArrayPropTypeUtil as stringArrayPropTypeUtil3, stringPropTypeUtil as stringPropTypeUtil22 } from "@elementor/editor-props";
8280
8280
  import { Autocomplete as Autocomplete4, Grid as Grid32, TextField as TextField11 } from "@elementor/ui";
8281
8281
 
@@ -8287,6 +8287,10 @@ var CHIP_TRIGGER_KEYS = /* @__PURE__ */ new Set([" ", ","]);
8287
8287
  function isValidEmail(email) {
8288
8288
  return z.string().email().safeParse(email).success;
8289
8289
  }
8290
+ var FORM_FIELD_SHORTCODE_PATTERN = /^\[[^[\]]+]$/;
8291
+ function isFormFieldShortcode(value) {
8292
+ return FORM_FIELD_SHORTCODE_PATTERN.test(value);
8293
+ }
8290
8294
  var shouldShowMentionsInfo = () => {
8291
8295
  if (!hasProInstalled3()) {
8292
8296
  return true;
@@ -8299,14 +8303,26 @@ var shouldShowMentionsInfo = () => {
8299
8303
  };
8300
8304
 
8301
8305
  // src/controls/email-form-action-control/email-chips-field.tsx
8302
- var EmailChipsControl = createControl(({ placeholder }) => {
8306
+ var isValidRecipient = (address) => isValidEmail(address) || isFormFieldShortcode(address);
8307
+ function resolveMention(raw, suggestions) {
8308
+ if (!raw.startsWith("@")) {
8309
+ return raw;
8310
+ }
8311
+ const match = suggestions.find((suggestion) => createMentionPattern(suggestion.value, "start").test(raw));
8312
+ return match ? `[${match.value}]` : raw;
8313
+ }
8314
+ var EmailChipsControl = createControl(({ placeholder, suggestions = [] }) => {
8303
8315
  const { value, setValue, disabled } = useBoundProp(stringArrayPropTypeUtil3);
8304
8316
  const [inputValue, setInputValue] = useState19("");
8305
8317
  const items2 = value || [];
8306
8318
  const selectedValues = items2.map((item) => stringPropTypeUtil22.extract(item)).filter((val) => val !== null);
8319
+ const suggestionOptions = useMemo18(
8320
+ () => suggestions.map((suggestion) => `[${suggestion.value}]`),
8321
+ [suggestions]
8322
+ );
8307
8323
  const tryAddChip = (raw) => {
8308
- const address = raw.trim();
8309
- if (!address || selectedValues.includes(address) || !isValidEmail(address)) {
8324
+ const address = resolveMention(raw.trim(), suggestions);
8325
+ if (!address || selectedValues.includes(address) || !isValidRecipient(address)) {
8310
8326
  return;
8311
8327
  }
8312
8328
  setValue([...items2, stringPropTypeUtil22.create(address)]);
@@ -8315,8 +8331,8 @@ var EmailChipsControl = createControl(({ placeholder }) => {
8315
8331
  const handleChange = (_, newValue) => {
8316
8332
  const updated = [];
8317
8333
  for (const entry of newValue) {
8318
- const address = entry.trim();
8319
- if (!address || !isValidEmail(address)) {
8334
+ const address = resolveMention(entry.trim(), suggestions);
8335
+ if (!address || !isValidRecipient(address)) {
8320
8336
  continue;
8321
8337
  }
8322
8338
  updated.push(stringPropTypeUtil22.create(address));
@@ -8351,7 +8367,12 @@ var EmailChipsControl = createControl(({ placeholder }) => {
8351
8367
  },
8352
8368
  value: selectedValues,
8353
8369
  onChange: handleChange,
8354
- options: [],
8370
+ options: suggestionOptions,
8371
+ filterOptions: (options, state) => {
8372
+ const query = state.inputValue.trim().replace(/^@/, "").toLowerCase();
8373
+ return query ? options.filter((option) => option.toLowerCase().includes(query)) : options;
8374
+ },
8375
+ filterSelectedOptions: true,
8355
8376
  onBlur: handleBlur,
8356
8377
  getOptionLabel: (option) => option,
8357
8378
  isOptionEqualToValue: (option, val) => option === val,
@@ -8360,7 +8381,7 @@ var EmailChipsControl = createControl(({ placeholder }) => {
8360
8381
  }
8361
8382
  ));
8362
8383
  });
8363
- var EmailChipsField = ({ fieldLabel, placeholder }) => /* @__PURE__ */ React116.createElement(Grid32, { container: true, direction: "column", gap: 0.5 }, /* @__PURE__ */ React116.createElement(Grid32, { item: true }, /* @__PURE__ */ React116.createElement(ControlFormLabel, null, fieldLabel)), /* @__PURE__ */ React116.createElement(Grid32, { item: true }, /* @__PURE__ */ React116.createElement(EmailChipsControl, { placeholder })));
8384
+ var EmailChipsField = ({ fieldLabel, placeholder, suggestions }) => /* @__PURE__ */ React116.createElement(Grid32, { container: true, direction: "column", gap: 0.5 }, /* @__PURE__ */ React116.createElement(Grid32, { item: true }, /* @__PURE__ */ React116.createElement(ControlFormLabel, null, fieldLabel)), /* @__PURE__ */ React116.createElement(Grid32, { item: true }, /* @__PURE__ */ React116.createElement(EmailChipsControl, { placeholder, suggestions })));
8364
8385
 
8365
8386
  // src/controls/email-form-action-control/email-field.tsx
8366
8387
  import * as React117 from "react";
@@ -8368,7 +8389,17 @@ import { Grid as Grid33 } from "@elementor/ui";
8368
8389
  var EmailField = ({ bind, label, placeholder }) => /* @__PURE__ */ React117.createElement(PropKeyProvider, { bind }, /* @__PURE__ */ React117.createElement(Grid33, { container: true, direction: "column", gap: 0.5 }, /* @__PURE__ */ React117.createElement(Grid33, { item: true }, /* @__PURE__ */ React117.createElement(ControlFormLabel, null, label)), /* @__PURE__ */ React117.createElement(Grid33, { item: true }, /* @__PURE__ */ React117.createElement(TextControl, { placeholder }))));
8369
8390
 
8370
8391
  // src/controls/email-form-action-control/fields.tsx
8371
- var SendToField = ({ placeholder }) => /* @__PURE__ */ React118.createElement(PropKeyProvider, { bind: "to" }, /* @__PURE__ */ React118.createElement(EmailChipsField, { fieldLabel: __57("Send to", "elementor"), placeholder }));
8392
+ var SendToField = ({ placeholder }) => {
8393
+ const suggestions = useFormFieldSuggestions({ inputType: "email" });
8394
+ return /* @__PURE__ */ React118.createElement(PropKeyProvider, { bind: "to" }, /* @__PURE__ */ React118.createElement(Stack19, { gap: 0.5 }, /* @__PURE__ */ React118.createElement(
8395
+ EmailChipsField,
8396
+ {
8397
+ fieldLabel: __57("Send to", "elementor"),
8398
+ placeholder,
8399
+ suggestions
8400
+ }
8401
+ ), shouldShowMentionsInfo() && /* @__PURE__ */ React118.createElement(InfoAlert2, null, __57("Type @ or an email field name to insert its submitted value.", "elementor"))));
8402
+ };
8372
8403
  var SubjectField = () => /* @__PURE__ */ React118.createElement(
8373
8404
  EmailField,
8374
8405
  {
@@ -8412,8 +8443,14 @@ var ReplyToField = () => {
8412
8443
  }
8413
8444
  ))));
8414
8445
  };
8415
- var CcField = () => /* @__PURE__ */ React118.createElement(PropKeyProvider, { bind: "cc" }, /* @__PURE__ */ React118.createElement(EmailChipsField, { fieldLabel: __57("Cc", "elementor") }));
8416
- var BccField = () => /* @__PURE__ */ React118.createElement(PropKeyProvider, { bind: "bcc" }, /* @__PURE__ */ React118.createElement(EmailChipsField, { fieldLabel: __57("Bcc", "elementor") }));
8446
+ var CcField = () => {
8447
+ const suggestions = useFormFieldSuggestions({ inputType: "email" });
8448
+ return /* @__PURE__ */ React118.createElement(PropKeyProvider, { bind: "cc" }, /* @__PURE__ */ React118.createElement(EmailChipsField, { fieldLabel: __57("Cc", "elementor"), suggestions }));
8449
+ };
8450
+ var BccField = () => {
8451
+ const suggestions = useFormFieldSuggestions({ inputType: "email" });
8452
+ return /* @__PURE__ */ React118.createElement(PropKeyProvider, { bind: "bcc" }, /* @__PURE__ */ React118.createElement(EmailChipsField, { fieldLabel: __57("Bcc", "elementor"), suggestions }));
8453
+ };
8417
8454
  var MetaDataField = () => /* @__PURE__ */ React118.createElement(PropKeyProvider, { bind: "meta-data" }, /* @__PURE__ */ React118.createElement(Stack19, { gap: 0.5 }, /* @__PURE__ */ React118.createElement(ControlFormLabel, null, __57("Metadata", "elementor")), /* @__PURE__ */ React118.createElement(
8418
8455
  ChipsControl,
8419
8456
  {
@@ -8863,7 +8900,7 @@ var usePopover = (openOnMount, onOpen, onPopoverClose) => {
8863
8900
 
8864
8901
  // src/components/inline-editor-toolbar.tsx
8865
8902
  import * as React128 from "react";
8866
- import { useEffect as useEffect21, useMemo as useMemo18, useRef as useRef32, useState as useState22 } from "react";
8903
+ import { useEffect as useEffect21, useMemo as useMemo19, useRef as useRef32, useState as useState22 } from "react";
8867
8904
  import { getContainer as getContainer3, getElementSetting } from "@elementor/editor-elements";
8868
8905
  import {
8869
8906
  BoldIcon,
@@ -8962,7 +8999,7 @@ var InlineEditorToolbar = ({ editor, elementId, sx = {} }) => {
8962
8999
  editor,
8963
9000
  selector: (ctx) => possibleFormats.filter((format) => ctx.editor.isActive(format))
8964
9001
  });
8965
- const formatButtonsList = useMemo18(() => {
9002
+ const formatButtonsList = useMemo19(() => {
8966
9003
  const buttons = Object.values(formatButtons);
8967
9004
  if (isElementClickable) {
8968
9005
  return buttons.filter((button) => button.action !== "link");
@@ -9309,7 +9346,7 @@ var hasValue = (value) => {
9309
9346
  };
9310
9347
 
9311
9348
  // src/hooks/use-font-families.ts
9312
- import { useMemo as useMemo19 } from "react";
9349
+ import { useMemo as useMemo20 } from "react";
9313
9350
  import { getElementorConfig } from "@elementor/editor-v1-adapters";
9314
9351
  var getFontControlConfig = () => {
9315
9352
  const { controls } = getElementorConfig();
@@ -9317,7 +9354,7 @@ var getFontControlConfig = () => {
9317
9354
  };
9318
9355
  var useFontFamilies = () => {
9319
9356
  const { groups, options } = getFontControlConfig();
9320
- return useMemo19(() => {
9357
+ return useMemo20(() => {
9321
9358
  if (!groups || !options) {
9322
9359
  return [];
9323
9360
  }