@elementor/editor-editing-panel 3.32.0-51 → 3.32.0-53

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
@@ -3668,6 +3668,9 @@ var items = [
3668
3668
  }
3669
3669
  ];
3670
3670
  var FlexOrderField = () => {
3671
+ return /* @__PURE__ */ React53.createElement(StylesField, { bind: "order", propDisplayName: ORDER_LABEL }, /* @__PURE__ */ React53.createElement(UiProviders, null, /* @__PURE__ */ React53.createElement(SectionContent, null, /* @__PURE__ */ React53.createElement(FlexOrderFieldContent, null))));
3672
+ };
3673
+ function FlexOrderFieldContent() {
3671
3674
  const {
3672
3675
  value: order,
3673
3676
  setValue: setOrder,
@@ -3675,37 +3678,61 @@ var FlexOrderField = () => {
3675
3678
  } = useStylesField("order", {
3676
3679
  history: { propDisplayName: ORDER_LABEL }
3677
3680
  });
3678
- const [groupControlValue, setGroupControlValue] = (0, import_react27.useState)(getGroupControlValue(order?.value ?? null));
3681
+ const { placeholder } = (0, import_editor_controls24.useBoundProp)();
3682
+ const placeholderValue = placeholder;
3683
+ const currentGroup = (0, import_react27.useMemo)(() => getGroupControlValue(order?.value ?? null), [order]);
3684
+ const [activeGroup, setActiveGroup] = (0, import_react27.useState)(currentGroup);
3685
+ const [customLocked, setCustomLocked] = (0, import_react27.useState)(false);
3686
+ (0, import_react27.useEffect)(() => {
3687
+ if (!customLocked) {
3688
+ setActiveGroup(currentGroup);
3689
+ }
3690
+ }, [currentGroup, customLocked]);
3679
3691
  (0, import_react27.useEffect)(() => {
3680
- const newGroupControlValue = getGroupControlValue(order?.value ?? null);
3681
- setGroupControlValue(newGroupControlValue);
3682
- }, [order?.value]);
3692
+ if (order === null) {
3693
+ setCustomLocked(false);
3694
+ }
3695
+ }, [order]);
3696
+ const groupPlaceholder = getGroupControlValue(placeholderValue?.value ?? null);
3683
3697
  const handleToggleButtonChange = (group) => {
3684
- setGroupControlValue(group);
3685
- if (!group || group === CUSTOM) {
3686
- setOrder(null);
3698
+ setActiveGroup(group);
3699
+ setCustomLocked(group === CUSTOM);
3700
+ if (CUSTOM === group) {
3701
+ setOrder({ $$type: "number", value: null });
3687
3702
  return;
3688
3703
  }
3689
- setOrder({ $$type: "number", value: orderValueMap[group] });
3704
+ if (FIRST === group) {
3705
+ setOrder({ $$type: "number", value: orderValueMap[group] });
3706
+ return;
3707
+ }
3708
+ if (LAST === group) {
3709
+ setOrder({ $$type: "number", value: orderValueMap[group] });
3710
+ return;
3711
+ }
3712
+ setOrder(null);
3690
3713
  };
3691
- return /* @__PURE__ */ React53.createElement(StylesField, { bind: "order", propDisplayName: ORDER_LABEL }, /* @__PURE__ */ React53.createElement(UiProviders, null, /* @__PURE__ */ React53.createElement(SectionContent, null, /* @__PURE__ */ React53.createElement(StylesFieldLayout, { label: ORDER_LABEL }, /* @__PURE__ */ React53.createElement(
3714
+ const isCustomVisible = CUSTOM === activeGroup || CUSTOM === groupPlaceholder;
3715
+ const orderPlaceholder = CUSTOM === groupPlaceholder ? String(placeholderValue?.value ?? null) : "";
3716
+ return /* @__PURE__ */ React53.createElement(React53.Fragment, null, /* @__PURE__ */ React53.createElement(StylesFieldLayout, { label: ORDER_LABEL }, /* @__PURE__ */ React53.createElement(
3692
3717
  import_editor_controls24.ControlToggleButtonGroup,
3693
3718
  {
3694
3719
  items,
3695
- value: groupControlValue,
3720
+ value: activeGroup,
3696
3721
  onChange: handleToggleButtonChange,
3697
3722
  exclusive: true,
3723
+ placeholder: groupPlaceholder,
3698
3724
  disabled: !canEdit
3699
3725
  }
3700
- )), CUSTOM === groupControlValue && /* @__PURE__ */ React53.createElement(import_ui37.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React53.createElement(import_ui37.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React53.createElement(ControlLabel, null, (0, import_i18n28.__)("Custom order", "elementor"))), /* @__PURE__ */ React53.createElement(import_ui37.Grid, { item: true, xs: 6, sx: { display: "flex", justifyContent: "end" } }, /* @__PURE__ */ React53.createElement(
3726
+ )), isCustomVisible && /* @__PURE__ */ React53.createElement(import_ui37.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React53.createElement(import_ui37.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React53.createElement(ControlLabel, null, (0, import_i18n28.__)("Custom order", "elementor"))), /* @__PURE__ */ React53.createElement(import_ui37.Grid, { item: true, xs: 6, sx: { display: "flex", justifyContent: "end" } }, /* @__PURE__ */ React53.createElement(
3701
3727
  import_editor_controls24.NumberControl,
3702
3728
  {
3703
3729
  min: FIRST_DEFAULT_VALUE + 1,
3704
3730
  max: LAST_DEFAULT_VALUE - 1,
3705
- shouldForceInt: true
3731
+ shouldForceInt: true,
3732
+ placeholder: orderPlaceholder
3706
3733
  }
3707
- ))))));
3708
- };
3734
+ ))));
3735
+ }
3709
3736
  var getGroupControlValue = (order) => {
3710
3737
  if (LAST_DEFAULT_VALUE === order) {
3711
3738
  return LAST;
@@ -3713,7 +3740,10 @@ var getGroupControlValue = (order) => {
3713
3740
  if (FIRST_DEFAULT_VALUE === order) {
3714
3741
  return FIRST;
3715
3742
  }
3716
- return 0 === order || order ? CUSTOM : null;
3743
+ if (null !== order) {
3744
+ return CUSTOM;
3745
+ }
3746
+ return null;
3717
3747
  };
3718
3748
 
3719
3749
  // src/components/style-sections/layout-section/flex-size-field.tsx
@@ -3746,14 +3776,15 @@ var items2 = [
3746
3776
  }
3747
3777
  ];
3748
3778
  var FlexSizeField = () => {
3779
+ return /* @__PURE__ */ React54.createElement(UiProviders, null, /* @__PURE__ */ React54.createElement(SectionContent, null, /* @__PURE__ */ React54.createElement(StylesField, { bind: "flex", propDisplayName: FLEX_SIZE_LABEL }, /* @__PURE__ */ React54.createElement(FlexSizeFieldContent, null))));
3780
+ };
3781
+ var FlexSizeFieldContent = () => {
3749
3782
  const { value, setValue, canEdit } = useStylesField("flex", {
3750
3783
  history: { propDisplayName: FLEX_SIZE_LABEL }
3751
3784
  });
3752
- const flexValue = value;
3753
- const grow = flexValue?.value?.flexGrow?.value || null;
3754
- const shrink = flexValue?.value?.flexShrink?.value || null;
3755
- const basis = flexValue?.value?.flexBasis?.value || null;
3756
- const currentGroup = (0, import_react28.useMemo)(() => getActiveGroup({ grow, shrink, basis }), [grow, shrink, basis]);
3785
+ const { placeholder } = (0, import_editor_controls25.useBoundProp)();
3786
+ const flexValues = extractFlexValues(value);
3787
+ const currentGroup = (0, import_react28.useMemo)(() => getActiveGroup(flexValues), [flexValues]);
3757
3788
  const [activeGroup, setActiveGroup] = (0, import_react28.useState)(currentGroup);
3758
3789
  const [customLocked, setCustomLocked] = (0, import_react28.useState)(false);
3759
3790
  (0, import_react28.useEffect)(() => {
@@ -3769,20 +3800,30 @@ var FlexSizeField = () => {
3769
3800
  const onChangeGroup = (group = null) => {
3770
3801
  setActiveGroup(group);
3771
3802
  setCustomLocked(group === "custom");
3772
- const newFlexValue = createFlexValueForGroup(group, flexValue);
3803
+ const newFlexValue = createFlexValueForGroup(group, value);
3773
3804
  setValue(newFlexValue);
3774
3805
  };
3775
- return /* @__PURE__ */ React54.createElement(UiProviders, null, /* @__PURE__ */ React54.createElement(SectionContent, null, /* @__PURE__ */ React54.createElement(StylesField, { bind: "flex", propDisplayName: FLEX_SIZE_LABEL }, /* @__PURE__ */ React54.createElement(StylesFieldLayout, { label: FLEX_SIZE_LABEL }, /* @__PURE__ */ React54.createElement(
3806
+ const groupPlaceholder = getActiveGroup(extractFlexValues(placeholder));
3807
+ const isCustomVisible = "custom" === activeGroup || "custom" === groupPlaceholder;
3808
+ return /* @__PURE__ */ React54.createElement(React54.Fragment, null, /* @__PURE__ */ React54.createElement(StylesFieldLayout, { label: FLEX_SIZE_LABEL }, /* @__PURE__ */ React54.createElement(
3776
3809
  import_editor_controls25.ControlToggleButtonGroup,
3777
3810
  {
3778
- value: activeGroup,
3811
+ value: activeGroup ?? null,
3812
+ placeholder: groupPlaceholder ?? null,
3779
3813
  onChange: onChangeGroup,
3780
3814
  disabled: !canEdit,
3781
3815
  items: items2,
3782
3816
  exclusive: true
3783
3817
  }
3784
- )), "custom" === activeGroup && /* @__PURE__ */ React54.createElement(FlexCustomField, null))));
3818
+ )), isCustomVisible && /* @__PURE__ */ React54.createElement(FlexCustomField, null));
3785
3819
  };
3820
+ function extractFlexValues(source) {
3821
+ return {
3822
+ grow: source?.value?.flexGrow?.value ?? null,
3823
+ shrink: source?.value?.flexShrink?.value ?? null,
3824
+ basis: source?.value?.flexBasis?.value ?? null
3825
+ };
3826
+ }
3786
3827
  var createFlexValueForGroup = (group, flexValue) => {
3787
3828
  if (!group) {
3788
3829
  return null;