@elementor/editor-editing-panel 4.2.0-847 → 4.2.0-848

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 CHANGED
@@ -2544,7 +2544,7 @@ function isControl(control) {
2544
2544
  // src/components/style-tab.tsx
2545
2545
  var React85 = __toESM(require("react"));
2546
2546
  var import_react37 = require("react");
2547
- var import_editor_props14 = require("@elementor/editor-props");
2547
+ var import_editor_props15 = require("@elementor/editor-props");
2548
2548
  var import_editor_responsive3 = require("@elementor/editor-responsive");
2549
2549
  var import_locations3 = require("@elementor/locations");
2550
2550
  var import_session8 = require("@elementor/session");
@@ -4123,47 +4123,99 @@ var GridJustifyItemsField = () => /* @__PURE__ */ React50.createElement(StylesFi
4123
4123
  var React51 = __toESM(require("react"));
4124
4124
  var import_react27 = require("react");
4125
4125
  var import_editor_controls26 = require("@elementor/editor-controls");
4126
+ var import_editor_props14 = require("@elementor/editor-props");
4126
4127
  var import_ui30 = require("@elementor/ui");
4127
4128
  var import_i18n29 = require("@wordpress/i18n");
4128
4129
  var FR = "fr";
4129
4130
  var CUSTOM2 = "custom";
4130
4131
  var UNITS = [FR, CUSTOM2];
4132
+ var EMPTY = { kind: "empty" };
4131
4133
  var REPEAT_FR_PATTERN = /^repeat\(\s*(\d+)\s*,\s*1fr\s*\)$/;
4132
- var cssToTrackValue = (css) => {
4134
+ var parseCss = (css) => {
4133
4135
  if (!css) {
4134
- return null;
4136
+ return EMPTY;
4135
4137
  }
4136
4138
  const match = css.match(REPEAT_FR_PATTERN);
4137
4139
  if (match) {
4138
- return { size: parseInt(match[1], 10), unit: FR };
4140
+ const count = parseInt(match[1], 10);
4141
+ return count >= 1 ? { kind: "fr", count } : EMPTY;
4139
4142
  }
4140
- return { size: css, unit: CUSTOM2 };
4143
+ return { kind: "custom", raw: css };
4141
4144
  };
4142
- var trackValueToCss = (trackValue) => {
4143
- if (!trackValue || trackValue.size === "" || trackValue.size === null) {
4144
- return null;
4145
+ var fromSizeInput = (v) => {
4146
+ if (v.size === "" || Number.isNaN(v.size)) {
4147
+ return EMPTY;
4148
+ }
4149
+ if (v.unit === FR) {
4150
+ const n = Number(v.size);
4151
+ return Number.isFinite(n) && n >= 1 ? { kind: "fr", count: Math.trunc(n) } : EMPTY;
4152
+ }
4153
+ return { kind: "custom", raw: String(v.size) };
4154
+ };
4155
+ var toCss = (v) => {
4156
+ switch (v.kind) {
4157
+ case "empty":
4158
+ return null;
4159
+ case "fr":
4160
+ return `repeat(${v.count}, 1fr)`;
4161
+ case "custom":
4162
+ return v.raw;
4163
+ }
4164
+ };
4165
+ var toSizeInput = (v, fallbackUnit = FR) => {
4166
+ switch (v.kind) {
4167
+ case "empty":
4168
+ return { size: "", unit: fallbackUnit };
4169
+ case "fr":
4170
+ return { size: v.count, unit: FR };
4171
+ case "custom":
4172
+ return { size: v.raw, unit: CUSTOM2 };
4173
+ }
4174
+ };
4175
+ var toPlaceholder = (v) => {
4176
+ switch (v.kind) {
4177
+ case "empty":
4178
+ return void 0;
4179
+ case "fr":
4180
+ return String(v.count);
4181
+ case "custom":
4182
+ return v.raw;
4183
+ }
4184
+ };
4185
+ var unitOf = (v, fallback = FR) => {
4186
+ if (v.kind === "fr") {
4187
+ return FR;
4145
4188
  }
4146
- if (trackValue.unit === FR) {
4147
- return `repeat(${trackValue.size}, 1fr)`;
4189
+ if (v.kind === "custom") {
4190
+ return CUSTOM2;
4148
4191
  }
4149
- return String(trackValue.size);
4192
+ return fallback;
4150
4193
  };
4151
- var GridTrackField = ({ cssProp, label }) => /* @__PURE__ */ React51.createElement(StylesField, { bind: cssProp, propDisplayName: label }, /* @__PURE__ */ React51.createElement(GridTrackFieldContent, { cssProp, label }));
4194
+ var GridTrackField = ({ cssProp, label }) => /* @__PURE__ */ React51.createElement(UiProviders, null, /* @__PURE__ */ React51.createElement(StylesField, { bind: cssProp, propDisplayName: label }, /* @__PURE__ */ React51.createElement(GridTrackFieldContent, { cssProp, label })));
4152
4195
  var GridTrackFieldContent = ({ cssProp, label }) => {
4153
4196
  const { value, setValue } = useStylesField(cssProp, {
4154
4197
  history: { propDisplayName: label }
4155
4198
  });
4199
+ const { placeholder: inheritedPlaceholder } = (0, import_editor_controls26.useBoundProp)();
4156
4200
  const anchorRef = (0, import_react27.useRef)(null);
4157
- const trackValue = cssToTrackValue(value?.value ?? null);
4158
- const handleChange = (newValue) => {
4159
- const css = trackValueToCss(newValue);
4160
- setValue(css ? { $$type: "string", value: css } : null);
4201
+ const local = parseCss(value?.value ?? null);
4202
+ const inherited = parseCss(import_editor_props14.stringPropTypeUtil.extract(inheritedPlaceholder));
4203
+ const displayValue = local.kind !== "empty" ? toSizeInput(local) : toSizeInput(EMPTY, unitOf(inherited));
4204
+ const placeholder = toPlaceholder(inherited);
4205
+ const handleChange = (raw) => {
4206
+ const next = fromSizeInput(raw);
4207
+ if (next.kind === "empty" && local.kind !== "empty" && raw.unit !== unitOf(local)) {
4208
+ return;
4209
+ }
4210
+ const css = toCss(next);
4211
+ setValue(css === null ? null : { $$type: "string", value: css });
4161
4212
  };
4162
4213
  return /* @__PURE__ */ React51.createElement(StylesFieldLayout, { label, direction: "column" }, /* @__PURE__ */ React51.createElement("div", { ref: anchorRef }, /* @__PURE__ */ React51.createElement(
4163
4214
  import_editor_controls26.SizeComponent,
4164
4215
  {
4165
4216
  units: UNITS,
4166
- value: trackValue ?? { size: NaN, unit: FR },
4217
+ value: displayValue,
4218
+ placeholder,
4167
4219
  defaultUnit: FR,
4168
4220
  setValue: handleChange,
4169
4221
  onBlur: () => {
@@ -5278,7 +5330,7 @@ function ClassesHeader({ children }) {
5278
5330
  function useCurrentClassesProp() {
5279
5331
  const { elementType } = useElement();
5280
5332
  const prop = Object.entries(elementType.propsSchema).find(
5281
- ([, propType]) => propType.kind === "plain" && propType.key === import_editor_props14.CLASSES_PROP_KEY
5333
+ ([, propType]) => propType.kind === "plain" && propType.key === import_editor_props15.CLASSES_PROP_KEY
5282
5334
  );
5283
5335
  if (!prop) {
5284
5336
  return null;
@@ -5429,7 +5481,7 @@ var init = () => {
5429
5481
  var React89 = __toESM(require("react"));
5430
5482
  var import_editor_controls58 = require("@elementor/editor-controls");
5431
5483
  var import_editor_elements17 = require("@elementor/editor-elements");
5432
- var import_editor_props16 = require("@elementor/editor-props");
5484
+ var import_editor_props17 = require("@elementor/editor-props");
5433
5485
  var import_icons26 = require("@elementor/icons");
5434
5486
  var import_ui43 = require("@elementor/ui");
5435
5487
  var import_i18n64 = require("@wordpress/i18n");
@@ -5450,12 +5502,12 @@ var getElementByType = (elementId, type) => {
5450
5502
  // src/controls-registry/element-controls/tabs-control/use-actions.ts
5451
5503
  var import_editor_controls57 = require("@elementor/editor-controls");
5452
5504
  var import_editor_elements16 = require("@elementor/editor-elements");
5453
- var import_editor_props15 = require("@elementor/editor-props");
5505
+ var import_editor_props16 = require("@elementor/editor-props");
5454
5506
  var import_i18n63 = require("@wordpress/i18n");
5455
5507
  var TAB_ELEMENT_TYPE = "e-tab";
5456
5508
  var TAB_CONTENT_ELEMENT_TYPE = "e-tab-content";
5457
5509
  var useActions = () => {
5458
- const { value, setValue: setDefaultActiveTab } = (0, import_editor_controls57.useBoundProp)(import_editor_props15.numberPropTypeUtil);
5510
+ const { value, setValue: setDefaultActiveTab } = (0, import_editor_controls57.useBoundProp)(import_editor_props16.numberPropTypeUtil);
5459
5511
  const defaultActiveTab = value ?? 0;
5460
5512
  const duplicateItem = ({
5461
5513
  items: items3,
@@ -5716,7 +5768,7 @@ var ItemLabel = ({ value, index }) => {
5716
5768
  return /* @__PURE__ */ React89.createElement(import_ui43.Stack, { sx: { minHeight: 20 }, direction: "row", alignItems: "center", gap: 1.5 }, /* @__PURE__ */ React89.createElement("span", null, elementTitle), /* @__PURE__ */ React89.createElement(ItemDefaultTab, { index }));
5717
5769
  };
5718
5770
  var ItemDefaultTab = ({ index }) => {
5719
- const { value: defaultItem } = (0, import_editor_controls58.useBoundProp)(import_editor_props16.numberPropTypeUtil);
5771
+ const { value: defaultItem } = (0, import_editor_controls58.useBoundProp)(import_editor_props17.numberPropTypeUtil);
5720
5772
  const isDefault = defaultItem === index;
5721
5773
  if (!isDefault) {
5722
5774
  return null;
@@ -5730,7 +5782,7 @@ var ItemContent = ({ value, index }) => {
5730
5782
  return /* @__PURE__ */ React89.createElement(import_ui43.Stack, { p: 2, gap: 1.5 }, /* @__PURE__ */ React89.createElement(TabLabelControl, { elementId: value.id }), /* @__PURE__ */ React89.createElement(SettingsField, { bind: "default-active-tab", propDisplayName: (0, import_i18n64.__)("Tabs", "elementor") }, /* @__PURE__ */ React89.createElement(DefaultTabControl, { tabIndex: index })));
5731
5783
  };
5732
5784
  var DefaultTabControl = ({ tabIndex }) => {
5733
- const { value, setValue } = (0, import_editor_controls58.useBoundProp)(import_editor_props16.numberPropTypeUtil);
5785
+ const { value, setValue } = (0, import_editor_controls58.useBoundProp)(import_editor_props17.numberPropTypeUtil);
5734
5786
  const isDefault = value === tabIndex;
5735
5787
  return /* @__PURE__ */ React89.createElement(import_ui43.Stack, { direction: "row", alignItems: "center", justifyContent: "space-between", gap: 2 }, /* @__PURE__ */ React89.createElement(import_editor_controls58.ControlFormLabel, null, (0, import_i18n64.__)("Set as default tab", "elementor")), /* @__PURE__ */ React89.createElement(ConditionalTooltip, { showTooltip: isDefault, placement: "right" }, /* @__PURE__ */ React89.createElement(
5736
5788
  import_ui43.Switch,
@@ -5810,7 +5862,7 @@ var import_menus2 = require("@elementor/menus");
5810
5862
  // src/dynamics/components/background-control-dynamic-tag.tsx
5811
5863
  var React90 = __toESM(require("react"));
5812
5864
  var import_editor_controls60 = require("@elementor/editor-controls");
5813
- var import_editor_props18 = require("@elementor/editor-props");
5865
+ var import_editor_props19 = require("@elementor/editor-props");
5814
5866
  var import_icons27 = require("@elementor/icons");
5815
5867
 
5816
5868
  // src/dynamics/hooks/use-dynamic-tag.ts
@@ -5866,11 +5918,11 @@ var filterByLicense = (tags) => {
5866
5918
  };
5867
5919
 
5868
5920
  // src/dynamics/utils.ts
5869
- var import_editor_props17 = require("@elementor/editor-props");
5921
+ var import_editor_props18 = require("@elementor/editor-props");
5870
5922
  var import_editor_v1_adapters12 = require("@elementor/editor-v1-adapters");
5871
5923
  var import_schema = require("@elementor/schema");
5872
5924
  var DYNAMIC_PROP_TYPE_KEY = "dynamic";
5873
- var dynamicPropTypeUtil = (0, import_editor_props17.createPropUtils)(
5925
+ var dynamicPropTypeUtil = (0, import_editor_props18.createPropUtils)(
5874
5926
  DYNAMIC_PROP_TYPE_KEY,
5875
5927
  import_schema.z.strictObject({
5876
5928
  name: import_schema.z.string(),
@@ -5887,7 +5939,7 @@ var getDynamicPropType = (propType) => {
5887
5939
  return dynamicPropType && isDynamicPropType(dynamicPropType) ? dynamicPropType : null;
5888
5940
  };
5889
5941
  var isDynamicPropValue = (prop) => {
5890
- return (0, import_editor_props17.isTransformable)(prop) && prop.$$type === DYNAMIC_PROP_TYPE_KEY;
5942
+ return (0, import_editor_props18.isTransformable)(prop) && prop.$$type === DYNAMIC_PROP_TYPE_KEY;
5891
5943
  };
5892
5944
  var supportsDynamic = (propType) => {
5893
5945
  return !!getDynamicPropType(propType);
@@ -5948,7 +6000,7 @@ var useDynamicTag = (tagName) => {
5948
6000
  // src/dynamics/components/background-control-dynamic-tag.tsx
5949
6001
  var BackgroundControlDynamicTagIcon = () => /* @__PURE__ */ React90.createElement(import_icons27.DatabaseIcon, { fontSize: "tiny" });
5950
6002
  var BackgroundControlDynamicTagLabel = ({ value }) => {
5951
- const context = (0, import_editor_controls60.useBoundProp)(import_editor_props18.backgroundImageOverlayPropTypeUtil);
6003
+ const context = (0, import_editor_controls60.useBoundProp)(import_editor_props19.backgroundImageOverlayPropTypeUtil);
5952
6004
  return /* @__PURE__ */ React90.createElement(import_editor_controls60.PropProvider, { ...context, value: value.value }, /* @__PURE__ */ React90.createElement(import_editor_controls60.PropKeyProvider, { bind: "image" }, /* @__PURE__ */ React90.createElement(Wrapper2, { rawValue: value.value })));
5953
6005
  };
5954
6006
  var Wrapper2 = ({ rawValue }) => {
@@ -5985,7 +6037,7 @@ var import_editor_controls61 = require("@elementor/editor-controls");
5985
6037
  // src/dynamics/components/dynamic-conditional-control.tsx
5986
6038
  var React91 = __toESM(require("react"));
5987
6039
  var import_react44 = require("react");
5988
- var import_editor_props19 = require("@elementor/editor-props");
6040
+ var import_editor_props20 = require("@elementor/editor-props");
5989
6041
  var DynamicConditionalControl = ({
5990
6042
  children,
5991
6043
  propType,
@@ -6027,7 +6079,7 @@ var DynamicConditionalControl = ({
6027
6079
  if (!propType?.dependencies?.terms.length) {
6028
6080
  return /* @__PURE__ */ React91.createElement(React91.Fragment, null, children);
6029
6081
  }
6030
- const isHidden = !(0, import_editor_props19.isDependencyMet)(propType?.dependencies, effectiveSettings).isMet;
6082
+ const isHidden = !(0, import_editor_props20.isDependencyMet)(propType?.dependencies, effectiveSettings).isMet;
6031
6083
  return isHidden ? null : /* @__PURE__ */ React91.createElement(React91.Fragment, null, children);
6032
6084
  };
6033
6085
 
@@ -6405,7 +6457,7 @@ function ControlsItemsStack({ items: items3 }) {
6405
6457
 
6406
6458
  // src/dynamics/dynamic-transformer.ts
6407
6459
  var import_editor_canvas2 = require("@elementor/editor-canvas");
6408
- var import_editor_props20 = require("@elementor/editor-props");
6460
+ var import_editor_props21 = require("@elementor/editor-props");
6409
6461
 
6410
6462
  // src/dynamics/errors.ts
6411
6463
  var import_utils9 = require("@elementor/utils");
@@ -6423,7 +6475,7 @@ var dynamicTransformer = (0, import_editor_canvas2.createTransformer)((value, {
6423
6475
  });
6424
6476
  function simpleTransform(props) {
6425
6477
  const transformed = Object.entries(props).map(([settingKey, settingValue]) => {
6426
- const value = (0, import_editor_props20.isTransformable)(settingValue) ? settingValue.value : settingValue;
6478
+ const value = (0, import_editor_props21.isTransformable)(settingValue) ? settingValue.value : settingValue;
6427
6479
  return [settingKey, value];
6428
6480
  });
6429
6481
  return Object.fromEntries(transformed);
@@ -6583,7 +6635,7 @@ function useResetStyleValueProps() {
6583
6635
  // src/styles-inheritance/components/styles-inheritance-indicator.tsx
6584
6636
  var React101 = __toESM(require("react"));
6585
6637
  var import_editor_controls67 = require("@elementor/editor-controls");
6586
- var import_editor_props21 = require("@elementor/editor-props");
6638
+ var import_editor_props22 = require("@elementor/editor-props");
6587
6639
  var import_editor_styles_repository17 = require("@elementor/editor-styles-repository");
6588
6640
  var import_i18n72 = require("@wordpress/i18n");
6589
6641
 
@@ -6935,7 +6987,7 @@ var StylesInheritanceIndicator = ({
6935
6987
  var Indicator = ({ inheritanceChain, path, propType, isDisabled }) => {
6936
6988
  const { id: currentStyleId, provider: currentStyleProvider, meta: currentStyleMeta } = useStyle();
6937
6989
  const currentItem = currentStyleId ? getValueFromInheritanceChain(inheritanceChain, currentStyleId, currentStyleMeta) : null;
6938
- const hasValue = !(0, import_editor_props21.isEmpty)(currentItem?.value);
6990
+ const hasValue = !(0, import_editor_props22.isEmpty)(currentItem?.value);
6939
6991
  const [actualStyle] = inheritanceChain;
6940
6992
  if (actualStyle.provider === import_editor_styles_repository17.ELEMENTS_BASE_STYLES_PROVIDER_KEY) {
6941
6993
  return null;