@elementor/editor-controls 0.1.0 → 0.1.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 +6 -0
- package/dist/index.d.mts +28 -7
- package/dist/index.d.ts +28 -7
- package/dist/index.js +65 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/components/control-toggle-button-group.tsx +12 -1
- package/src/controls/number-control.tsx +45 -21
- package/src/controls/stroke-control.tsx +15 -36
- package/src/index.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -397,28 +397,12 @@ var ColorControl = createControl(
|
|
|
397
397
|
);
|
|
398
398
|
|
|
399
399
|
// src/controls/stroke-control.tsx
|
|
400
|
-
var defaultStrokeControlValue = {
|
|
401
|
-
$$type: "stroke",
|
|
402
|
-
value: {
|
|
403
|
-
color: {
|
|
404
|
-
$$type: "color",
|
|
405
|
-
value: "#000000"
|
|
406
|
-
},
|
|
407
|
-
width: {
|
|
408
|
-
$$type: "size",
|
|
409
|
-
value: {
|
|
410
|
-
unit: "px",
|
|
411
|
-
size: NaN
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
};
|
|
416
400
|
var units = ["px", "em", "rem"];
|
|
417
401
|
var StrokeControl = createControl(() => {
|
|
418
|
-
const { value, setValue } = useBoundProp(
|
|
402
|
+
const { value, setValue } = useBoundProp();
|
|
419
403
|
const setStrokeWidth = (newValue) => {
|
|
420
404
|
const updatedValue = {
|
|
421
|
-
...value?.value
|
|
405
|
+
...value?.value,
|
|
422
406
|
width: newValue
|
|
423
407
|
};
|
|
424
408
|
setValue({
|
|
@@ -428,7 +412,7 @@ var StrokeControl = createControl(() => {
|
|
|
428
412
|
};
|
|
429
413
|
const setStrokeColor = (newValue) => {
|
|
430
414
|
const updatedValue = {
|
|
431
|
-
...value?.value
|
|
415
|
+
...value?.value,
|
|
432
416
|
color: newValue
|
|
433
417
|
};
|
|
434
418
|
setValue({
|
|
@@ -441,7 +425,7 @@ var StrokeControl = createControl(() => {
|
|
|
441
425
|
{
|
|
442
426
|
bind: "width",
|
|
443
427
|
label: __3("Stroke Width", "elementor"),
|
|
444
|
-
value: value?.value.width
|
|
428
|
+
value: value?.value.width,
|
|
445
429
|
setValue: setStrokeWidth
|
|
446
430
|
},
|
|
447
431
|
/* @__PURE__ */ React15.createElement(SizeControl, { units })
|
|
@@ -450,19 +434,13 @@ var StrokeControl = createControl(() => {
|
|
|
450
434
|
{
|
|
451
435
|
bind: "color",
|
|
452
436
|
label: __3("Stroke Color", "elementor"),
|
|
453
|
-
value: value?.value.color
|
|
437
|
+
value: value?.value.color,
|
|
454
438
|
setValue: setStrokeColor
|
|
455
439
|
},
|
|
456
440
|
/* @__PURE__ */ React15.createElement(ColorControl, null)
|
|
457
441
|
));
|
|
458
442
|
});
|
|
459
|
-
var Control = ({
|
|
460
|
-
bind,
|
|
461
|
-
value,
|
|
462
|
-
setValue,
|
|
463
|
-
label,
|
|
464
|
-
children
|
|
465
|
-
}) => /* @__PURE__ */ React15.createElement(BoundPropProvider, { bind, value, setValue }, /* @__PURE__ */ React15.createElement(Grid2, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React15.createElement(Grid2, { item: true, xs: 6 }, /* @__PURE__ */ React15.createElement(ControlLabel, null, label)), /* @__PURE__ */ React15.createElement(Grid2, { item: true, xs: 6 }, children)));
|
|
443
|
+
var Control = ({ bind, value, setValue, label, children }) => /* @__PURE__ */ React15.createElement(BoundPropProvider, { bind, value, setValue }, /* @__PURE__ */ React15.createElement(Grid2, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React15.createElement(Grid2, { item: true, xs: 6 }, /* @__PURE__ */ React15.createElement(ControlLabel, null, label)), /* @__PURE__ */ React15.createElement(Grid2, { item: true, xs: 6 }, children)));
|
|
466
444
|
|
|
467
445
|
// src/controls/box-shadow-repeater-control.tsx
|
|
468
446
|
import * as React17 from "react";
|
|
@@ -853,7 +831,8 @@ import {
|
|
|
853
831
|
styled as styled2,
|
|
854
832
|
ToggleButton,
|
|
855
833
|
ToggleButtonGroup,
|
|
856
|
-
Tooltip
|
|
834
|
+
Tooltip,
|
|
835
|
+
useTheme
|
|
857
836
|
} from "@elementor/ui";
|
|
858
837
|
var StyledToggleButtonGroup = styled2(ToggleButtonGroup)`
|
|
859
838
|
${({ justify }) => `justify-content: ${justify};`}
|
|
@@ -867,22 +846,35 @@ var ControlToggleButtonGroup = ({
|
|
|
867
846
|
exclusive = false,
|
|
868
847
|
fullWidth = false
|
|
869
848
|
}) => {
|
|
849
|
+
const isRtl = "rtl" === useTheme().direction;
|
|
870
850
|
const handleChange = (_, newValue) => {
|
|
871
851
|
onChange(newValue);
|
|
872
852
|
};
|
|
873
|
-
return /* @__PURE__ */ React19.createElement(
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
}
|
|
883
|
-
|
|
853
|
+
return /* @__PURE__ */ React19.createElement(
|
|
854
|
+
StyledToggleButtonGroup,
|
|
855
|
+
{
|
|
856
|
+
justify,
|
|
857
|
+
value,
|
|
858
|
+
onChange: handleChange,
|
|
859
|
+
exclusive,
|
|
860
|
+
sx: {
|
|
861
|
+
direction: isRtl ? "rtl /* @noflip */" : "ltr /* @noflip */"
|
|
862
|
+
}
|
|
863
|
+
},
|
|
864
|
+
items.map(
|
|
865
|
+
({ label, value: buttonValue, renderContent: Content, showTooltip }) => showTooltip ? /* @__PURE__ */ React19.createElement(Tooltip, { key: buttonValue, title: label, disableFocusListener: true, placement: "top" }, /* @__PURE__ */ React19.createElement(ToggleButton, { value: buttonValue, "aria-label": label, size, fullWidth }, /* @__PURE__ */ React19.createElement(Content, { size }))) : /* @__PURE__ */ React19.createElement(
|
|
866
|
+
ToggleButton,
|
|
867
|
+
{
|
|
868
|
+
key: buttonValue,
|
|
869
|
+
value: buttonValue,
|
|
870
|
+
"aria-label": label,
|
|
871
|
+
size,
|
|
872
|
+
fullWidth
|
|
873
|
+
},
|
|
874
|
+
/* @__PURE__ */ React19.createElement(Content, { size })
|
|
875
|
+
)
|
|
884
876
|
)
|
|
885
|
-
)
|
|
877
|
+
);
|
|
886
878
|
};
|
|
887
879
|
|
|
888
880
|
// src/controls/toggle-control.tsx
|
|
@@ -910,24 +902,38 @@ var ToggleControl = createControl(
|
|
|
910
902
|
import * as React21 from "react";
|
|
911
903
|
import { TextField as TextField4 } from "@elementor/ui";
|
|
912
904
|
var isEmptyOrNaN = (value) => value === void 0 || value === "" || Number.isNaN(Number(value));
|
|
913
|
-
var NumberControl = createControl(
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
{
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
}
|
|
905
|
+
var NumberControl = createControl(
|
|
906
|
+
({
|
|
907
|
+
placeholder,
|
|
908
|
+
max = Number.MAX_VALUE,
|
|
909
|
+
min = -Number.MAX_VALUE,
|
|
910
|
+
step = 1,
|
|
911
|
+
shouldForceInt = false
|
|
912
|
+
}) => {
|
|
913
|
+
const { value, setValue } = useBoundProp();
|
|
914
|
+
const handleChange = (event) => {
|
|
915
|
+
const eventValue = event.target.value;
|
|
916
|
+
if (isEmptyOrNaN(eventValue)) {
|
|
917
|
+
setValue(void 0);
|
|
918
|
+
return;
|
|
919
|
+
}
|
|
920
|
+
const formattedValue = shouldForceInt ? +parseFloat(eventValue) : Number(eventValue);
|
|
921
|
+
setValue(Math.min(Math.max(formattedValue, min), max));
|
|
922
|
+
};
|
|
923
|
+
return /* @__PURE__ */ React21.createElement(ControlActions, null, /* @__PURE__ */ React21.createElement(
|
|
924
|
+
TextField4,
|
|
925
|
+
{
|
|
926
|
+
size: "tiny",
|
|
927
|
+
type: "number",
|
|
928
|
+
fullWidth: true,
|
|
929
|
+
value: isEmptyOrNaN(value) ? "" : value,
|
|
930
|
+
onChange: handleChange,
|
|
931
|
+
placeholder,
|
|
932
|
+
inputProps: { step }
|
|
933
|
+
}
|
|
934
|
+
));
|
|
935
|
+
}
|
|
936
|
+
);
|
|
931
937
|
|
|
932
938
|
// src/controls/equal-unequal-sizes-control.tsx
|
|
933
939
|
import * as React22 from "react";
|
|
@@ -1301,6 +1307,7 @@ export {
|
|
|
1301
1307
|
ControlActionsProvider,
|
|
1302
1308
|
ControlLabel,
|
|
1303
1309
|
ControlReplacementProvider,
|
|
1310
|
+
ControlToggleButtonGroup,
|
|
1304
1311
|
EqualUnequalSizesControl,
|
|
1305
1312
|
FontFamilyControl,
|
|
1306
1313
|
ImageControl,
|