@elementor/editor-controls 0.2.0 → 0.3.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @elementor/editor-controls
2
2
 
3
+ ## 0.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - a0ca1d8: fixed an issue where persisting dimensions values behaved unpredictably when switching breakpoints
8
+
9
+ ## 0.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - ff35b95: Added Gaps field with a control, proptype and a transformer
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [8943189]
18
+ - Updated dependencies [ff35b95]
19
+ - @elementor/editor-props@0.5.0
20
+
3
21
  ## 0.2.0
4
22
 
5
23
  ### Minor Changes
package/dist/index.d.mts CHANGED
@@ -46,8 +46,9 @@ type Props$2 = {
46
46
  value: StringPropValue['value'];
47
47
  disabled?: boolean;
48
48
  }>;
49
+ onChange?: (newValue: string | null, previousValue: string | null | undefined) => void;
49
50
  };
50
- declare const SelectControl: ControlComponent<({ options }: Props$2) => React.JSX.Element>;
51
+ declare const SelectControl: ControlComponent<({ options, onChange }: Props$2) => React.JSX.Element>;
51
52
 
52
53
  declare const ColorControl: ControlComponent<(props: Partial<Omit<UnstableColorFieldProps, "value" | "onChange">>) => React.JSX.Element>;
53
54
 
@@ -120,6 +121,10 @@ declare const UrlControl: ControlComponent<({ placeholder }: {
120
121
 
121
122
  declare const LinkControl: ControlComponent<() => React.JSX.Element>;
122
123
 
124
+ declare const GapControl: ControlComponent<({ label }: {
125
+ label: string;
126
+ }) => React.JSX.Element>;
127
+
123
128
  declare const ControlLabel: ({ children }: {
124
129
  children: React.ReactNode;
125
130
  }) => React.JSX.Element;
@@ -174,4 +179,4 @@ type UseInternalStateOptions<TValue> = {
174
179
  };
175
180
  declare const useSyncExternalState: <TValue>({ external, setExternal, persistWhen, fallback, }: UseInternalStateOptions<TValue>) => readonly [TValue, (setter: ((value: TValue) => TValue) | TValue) => void];
176
181
 
177
- export { BackgroundOverlayRepeaterControl, BoundPropProvider, BoxShadowRepeaterControl, ColorControl, ControlActionsProvider, type ControlComponent, ControlLabel, ControlReplacementProvider, ControlToggleButtonGroup, type EqualUnequalItems, EqualUnequalSizesControl, FontFamilyControl, ImageControl, LinkControl, LinkedDimensionsControl, NumberControl, SelectControl, SizeControl, StrokeControl, TextAreaControl, TextControl, type ToggleButtonGroupItem, ToggleControl, UrlControl, createControlReplacement, useBoundProp, useControlActions, useSyncExternalState };
182
+ export { BackgroundOverlayRepeaterControl, BoundPropProvider, BoxShadowRepeaterControl, ColorControl, ControlActionsProvider, type ControlComponent, ControlLabel, ControlReplacementProvider, ControlToggleButtonGroup, type EqualUnequalItems, EqualUnequalSizesControl, FontFamilyControl, GapControl, ImageControl, LinkControl, LinkedDimensionsControl, NumberControl, SelectControl, SizeControl, StrokeControl, TextAreaControl, TextControl, type ToggleButtonGroupItem, ToggleControl, UrlControl, createControlReplacement, useBoundProp, useControlActions, useSyncExternalState };
package/dist/index.d.ts CHANGED
@@ -46,8 +46,9 @@ type Props$2 = {
46
46
  value: StringPropValue['value'];
47
47
  disabled?: boolean;
48
48
  }>;
49
+ onChange?: (newValue: string | null, previousValue: string | null | undefined) => void;
49
50
  };
50
- declare const SelectControl: ControlComponent<({ options }: Props$2) => React.JSX.Element>;
51
+ declare const SelectControl: ControlComponent<({ options, onChange }: Props$2) => React.JSX.Element>;
51
52
 
52
53
  declare const ColorControl: ControlComponent<(props: Partial<Omit<UnstableColorFieldProps, "value" | "onChange">>) => React.JSX.Element>;
53
54
 
@@ -120,6 +121,10 @@ declare const UrlControl: ControlComponent<({ placeholder }: {
120
121
 
121
122
  declare const LinkControl: ControlComponent<() => React.JSX.Element>;
122
123
 
124
+ declare const GapControl: ControlComponent<({ label }: {
125
+ label: string;
126
+ }) => React.JSX.Element>;
127
+
123
128
  declare const ControlLabel: ({ children }: {
124
129
  children: React.ReactNode;
125
130
  }) => React.JSX.Element;
@@ -174,4 +179,4 @@ type UseInternalStateOptions<TValue> = {
174
179
  };
175
180
  declare const useSyncExternalState: <TValue>({ external, setExternal, persistWhen, fallback, }: UseInternalStateOptions<TValue>) => readonly [TValue, (setter: ((value: TValue) => TValue) | TValue) => void];
176
181
 
177
- export { BackgroundOverlayRepeaterControl, BoundPropProvider, BoxShadowRepeaterControl, ColorControl, ControlActionsProvider, type ControlComponent, ControlLabel, ControlReplacementProvider, ControlToggleButtonGroup, type EqualUnequalItems, EqualUnequalSizesControl, FontFamilyControl, ImageControl, LinkControl, LinkedDimensionsControl, NumberControl, SelectControl, SizeControl, StrokeControl, TextAreaControl, TextControl, type ToggleButtonGroupItem, ToggleControl, UrlControl, createControlReplacement, useBoundProp, useControlActions, useSyncExternalState };
182
+ export { BackgroundOverlayRepeaterControl, BoundPropProvider, BoxShadowRepeaterControl, ColorControl, ControlActionsProvider, type ControlComponent, ControlLabel, ControlReplacementProvider, ControlToggleButtonGroup, type EqualUnequalItems, EqualUnequalSizesControl, FontFamilyControl, GapControl, ImageControl, LinkControl, LinkedDimensionsControl, NumberControl, SelectControl, SizeControl, StrokeControl, TextAreaControl, TextControl, type ToggleButtonGroupItem, ToggleControl, UrlControl, createControlReplacement, useBoundProp, useControlActions, useSyncExternalState };
package/dist/index.js CHANGED
@@ -28,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
33
  BackgroundOverlayRepeaterControl: () => BackgroundOverlayRepeaterControl,
34
34
  BoundPropProvider: () => BoundPropProvider,
35
35
  BoxShadowRepeaterControl: () => BoxShadowRepeaterControl,
@@ -40,6 +40,7 @@ __export(src_exports, {
40
40
  ControlToggleButtonGroup: () => ControlToggleButtonGroup,
41
41
  EqualUnequalSizesControl: () => EqualUnequalSizesControl,
42
42
  FontFamilyControl: () => FontFamilyControl,
43
+ GapControl: () => GapControl,
43
44
  ImageControl: () => ImageControl,
44
45
  LinkControl: () => LinkControl,
45
46
  LinkedDimensionsControl: () => LinkedDimensionsControl,
@@ -56,7 +57,7 @@ __export(src_exports, {
56
57
  useControlActions: () => useControlActions,
57
58
  useSyncExternalState: () => useSyncExternalState
58
59
  });
59
- module.exports = __toCommonJS(src_exports);
60
+ module.exports = __toCommonJS(index_exports);
60
61
 
61
62
  // src/controls/image-control.tsx
62
63
  var React9 = __toESM(require("react"));
@@ -236,9 +237,10 @@ var ImageMediaControl = createControl(() => {
236
237
  var React8 = __toESM(require("react"));
237
238
  var import_editor_props2 = require("@elementor/editor-props");
238
239
  var import_ui5 = require("@elementor/ui");
239
- var SelectControl = createControl(({ options }) => {
240
+ var SelectControl = createControl(({ options, onChange }) => {
240
241
  const { value, setValue } = useBoundProp(import_editor_props2.stringPropTypeUtil);
241
242
  const handleChange = (event) => {
243
+ onChange?.(event.target.value, value);
242
244
  setValue(event.target.value);
243
245
  };
244
246
  return /* @__PURE__ */ React8.createElement(ControlActions, null, /* @__PURE__ */ React8.createElement(import_ui5.Select, { displayEmpty: true, size: "tiny", value: value ?? "", onChange: handleChange, fullWidth: true }, options.map(({ label, ...props }) => /* @__PURE__ */ React8.createElement(import_ui5.MenuItem, { key: props.value, ...props }, label))));
@@ -1389,6 +1391,63 @@ var LinkControl = createControl(() => {
1389
1391
  var SwitchControl = ({ value, onSwitch }) => {
1390
1392
  return /* @__PURE__ */ React26.createElement(import_ui22.Grid, { container: true, alignItems: "center", flexWrap: "nowrap", justifyContent: "space-between" }, /* @__PURE__ */ React26.createElement(import_ui22.Grid, { item: true }, /* @__PURE__ */ React26.createElement(ControlLabel, null, (0, import_i18n11.__)("Open in new tab", "elementor"))), /* @__PURE__ */ React26.createElement(import_ui22.Grid, { item: true }, /* @__PURE__ */ React26.createElement(import_ui22.Switch, { checked: value, onChange: onSwitch })));
1391
1393
  };
1394
+
1395
+ // src/controls/gap-control.tsx
1396
+ var React27 = __toESM(require("react"));
1397
+ var import_editor_props16 = require("@elementor/editor-props");
1398
+ var import_icons6 = require("@elementor/icons");
1399
+ var import_ui23 = require("@elementor/ui");
1400
+ var import_i18n12 = require("@wordpress/i18n");
1401
+ var GapControl = createControl(({ label }) => {
1402
+ const { value, setValue } = useBoundProp(import_editor_props16.gapPropTypeUtil);
1403
+ const { column, row, isLinked = true } = value || {};
1404
+ const setLinkedValue = (gap, newValue) => {
1405
+ const updatedValue = {
1406
+ isLinked,
1407
+ column: isLinked ? newValue : column,
1408
+ row: isLinked ? newValue : row,
1409
+ [gap]: newValue
1410
+ };
1411
+ setValue(updatedValue);
1412
+ };
1413
+ const toggleLinked = () => {
1414
+ const updatedValue = {
1415
+ isLinked: !isLinked,
1416
+ column,
1417
+ row: !isLinked ? column : row
1418
+ };
1419
+ setValue(updatedValue);
1420
+ };
1421
+ const LinkedIcon = isLinked ? import_icons6.LinkIcon : import_icons6.DetachIcon;
1422
+ return /* @__PURE__ */ React27.createElement(React27.Fragment, null, /* @__PURE__ */ React27.createElement(import_ui23.Stack, { direction: "row", gap: 2, flexWrap: "nowrap" }, /* @__PURE__ */ React27.createElement(ControlLabel, null, label), /* @__PURE__ */ React27.createElement(
1423
+ import_ui23.ToggleButton,
1424
+ {
1425
+ "aria-label": (0, import_i18n12.__)("Link Inputs", "elementor"),
1426
+ size: "tiny",
1427
+ value: "check",
1428
+ selected: isLinked,
1429
+ sx: { marginLeft: "auto" },
1430
+ onChange: toggleLinked
1431
+ },
1432
+ /* @__PURE__ */ React27.createElement(LinkedIcon, { fontSize: "tiny" })
1433
+ )), /* @__PURE__ */ React27.createElement(import_ui23.Stack, { direction: "row", gap: 2, flexWrap: "nowrap" }, /* @__PURE__ */ React27.createElement(import_ui23.Grid, { container: true, gap: 1, alignItems: "center" }, /* @__PURE__ */ React27.createElement(import_ui23.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React27.createElement(ControlLabel, null, (0, import_i18n12.__)("Column", "elementor"))), /* @__PURE__ */ React27.createElement(import_ui23.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React27.createElement(
1434
+ BoundPropProvider,
1435
+ {
1436
+ setValue: (newValue) => setLinkedValue("column", newValue),
1437
+ value: column,
1438
+ bind: "column"
1439
+ },
1440
+ /* @__PURE__ */ React27.createElement(SizeControl, null)
1441
+ ))), /* @__PURE__ */ React27.createElement(import_ui23.Grid, { container: true, gap: 1, alignItems: "center" }, /* @__PURE__ */ React27.createElement(import_ui23.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React27.createElement(ControlLabel, null, (0, import_i18n12.__)("Row", "elementor"))), /* @__PURE__ */ React27.createElement(import_ui23.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React27.createElement(
1442
+ BoundPropProvider,
1443
+ {
1444
+ setValue: (newValue) => setLinkedValue("row", newValue),
1445
+ value: row,
1446
+ bind: "row"
1447
+ },
1448
+ /* @__PURE__ */ React27.createElement(SizeControl, null)
1449
+ )))));
1450
+ });
1392
1451
  // Annotate the CommonJS export names for ESM import in node:
1393
1452
  0 && (module.exports = {
1394
1453
  BackgroundOverlayRepeaterControl,
@@ -1401,6 +1460,7 @@ var SwitchControl = ({ value, onSwitch }) => {
1401
1460
  ControlToggleButtonGroup,
1402
1461
  EqualUnequalSizesControl,
1403
1462
  FontFamilyControl,
1463
+ GapControl,
1404
1464
  ImageControl,
1405
1465
  LinkControl,
1406
1466
  LinkedDimensionsControl,