@elementor/editor-controls 3.33.0-268 → 3.33.0-270
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.d.mts +33 -18
- package/dist/index.d.ts +33 -18
- package/dist/index.js +15 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -56
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/repeater/repeater.tsx +44 -23
- package/src/controls/size-control.tsx +17 -10
package/dist/index.d.mts
CHANGED
|
@@ -478,35 +478,50 @@ type ToggleDisableItemMeta = {
|
|
|
478
478
|
type: 'toggle-disable';
|
|
479
479
|
};
|
|
480
480
|
type SetRepeaterValuesMeta<T> = SetValueMeta<AddItemMeta<T>> | SetValueMeta<RemoveItemMeta<T>> | SetValueMeta<DuplicateItemMeta<T>> | SetValueMeta<ReorderItemMeta> | SetValueMeta<ToggleDisableItemMeta>;
|
|
481
|
+
type BaseItemSettings<T> = {
|
|
482
|
+
initialValues: T;
|
|
483
|
+
Label: React$1.ComponentType<{
|
|
484
|
+
value: T;
|
|
485
|
+
index: number;
|
|
486
|
+
}>;
|
|
487
|
+
Icon: React$1.ComponentType<{
|
|
488
|
+
value: T;
|
|
489
|
+
}>;
|
|
490
|
+
Content: RepeaterItemContent<T>;
|
|
491
|
+
actions?: React$1.ReactNode;
|
|
492
|
+
};
|
|
493
|
+
type SortableItemSettings<T> = BaseItemSettings<T> & {
|
|
494
|
+
getId: ({ item, index }: {
|
|
495
|
+
item: T;
|
|
496
|
+
index: number;
|
|
497
|
+
}) => string;
|
|
498
|
+
};
|
|
481
499
|
type RepeaterProps<T> = {
|
|
482
500
|
label: string;
|
|
483
501
|
values?: T[];
|
|
484
|
-
addToBottom?: boolean;
|
|
485
502
|
openOnAdd?: boolean;
|
|
486
503
|
setValues: (newValue: T[], _: CreateOptions, meta?: SetRepeaterValuesMeta<T>) => void;
|
|
487
504
|
disabled?: boolean;
|
|
488
505
|
disableAddItemButton?: boolean;
|
|
489
|
-
itemSettings: {
|
|
490
|
-
getId: ({ item, index }: {
|
|
491
|
-
item: T;
|
|
492
|
-
index: number;
|
|
493
|
-
}) => string;
|
|
494
|
-
initialValues: T;
|
|
495
|
-
Label: React$1.ComponentType<{
|
|
496
|
-
value: T;
|
|
497
|
-
index: number;
|
|
498
|
-
}>;
|
|
499
|
-
Icon: React$1.ComponentType<{
|
|
500
|
-
value: T;
|
|
501
|
-
}>;
|
|
502
|
-
Content: RepeaterItemContent<T>;
|
|
503
|
-
actions?: React$1.ReactNode;
|
|
504
|
-
};
|
|
505
506
|
showDuplicate?: boolean;
|
|
506
507
|
showToggle?: boolean;
|
|
507
508
|
showRemove?: boolean;
|
|
508
509
|
openItem?: number;
|
|
509
|
-
isSortable
|
|
510
|
+
isSortable: false;
|
|
511
|
+
itemSettings: BaseItemSettings<T>;
|
|
512
|
+
} | {
|
|
513
|
+
label: string;
|
|
514
|
+
values?: T[];
|
|
515
|
+
openOnAdd?: boolean;
|
|
516
|
+
setValues: (newValue: T[], _: CreateOptions, meta?: SetRepeaterValuesMeta<T>) => void;
|
|
517
|
+
disabled?: boolean;
|
|
518
|
+
disableAddItemButton?: boolean;
|
|
519
|
+
showDuplicate?: boolean;
|
|
520
|
+
showToggle?: boolean;
|
|
521
|
+
showRemove?: boolean;
|
|
522
|
+
openItem?: number;
|
|
523
|
+
isSortable?: true;
|
|
524
|
+
itemSettings: SortableItemSettings<T>;
|
|
510
525
|
};
|
|
511
526
|
declare const Repeater: <T>({ label, itemSettings, disabled, openOnAdd, values: items, setValues: setItems, showDuplicate, showToggle, showRemove, disableAddItemButton, openItem: initialOpenItem, isSortable, }: RepeaterProps<RepeaterItem<T>>) => React$1.JSX.Element;
|
|
512
527
|
|
package/dist/index.d.ts
CHANGED
|
@@ -478,35 +478,50 @@ type ToggleDisableItemMeta = {
|
|
|
478
478
|
type: 'toggle-disable';
|
|
479
479
|
};
|
|
480
480
|
type SetRepeaterValuesMeta<T> = SetValueMeta<AddItemMeta<T>> | SetValueMeta<RemoveItemMeta<T>> | SetValueMeta<DuplicateItemMeta<T>> | SetValueMeta<ReorderItemMeta> | SetValueMeta<ToggleDisableItemMeta>;
|
|
481
|
+
type BaseItemSettings<T> = {
|
|
482
|
+
initialValues: T;
|
|
483
|
+
Label: React$1.ComponentType<{
|
|
484
|
+
value: T;
|
|
485
|
+
index: number;
|
|
486
|
+
}>;
|
|
487
|
+
Icon: React$1.ComponentType<{
|
|
488
|
+
value: T;
|
|
489
|
+
}>;
|
|
490
|
+
Content: RepeaterItemContent<T>;
|
|
491
|
+
actions?: React$1.ReactNode;
|
|
492
|
+
};
|
|
493
|
+
type SortableItemSettings<T> = BaseItemSettings<T> & {
|
|
494
|
+
getId: ({ item, index }: {
|
|
495
|
+
item: T;
|
|
496
|
+
index: number;
|
|
497
|
+
}) => string;
|
|
498
|
+
};
|
|
481
499
|
type RepeaterProps<T> = {
|
|
482
500
|
label: string;
|
|
483
501
|
values?: T[];
|
|
484
|
-
addToBottom?: boolean;
|
|
485
502
|
openOnAdd?: boolean;
|
|
486
503
|
setValues: (newValue: T[], _: CreateOptions, meta?: SetRepeaterValuesMeta<T>) => void;
|
|
487
504
|
disabled?: boolean;
|
|
488
505
|
disableAddItemButton?: boolean;
|
|
489
|
-
itemSettings: {
|
|
490
|
-
getId: ({ item, index }: {
|
|
491
|
-
item: T;
|
|
492
|
-
index: number;
|
|
493
|
-
}) => string;
|
|
494
|
-
initialValues: T;
|
|
495
|
-
Label: React$1.ComponentType<{
|
|
496
|
-
value: T;
|
|
497
|
-
index: number;
|
|
498
|
-
}>;
|
|
499
|
-
Icon: React$1.ComponentType<{
|
|
500
|
-
value: T;
|
|
501
|
-
}>;
|
|
502
|
-
Content: RepeaterItemContent<T>;
|
|
503
|
-
actions?: React$1.ReactNode;
|
|
504
|
-
};
|
|
505
506
|
showDuplicate?: boolean;
|
|
506
507
|
showToggle?: boolean;
|
|
507
508
|
showRemove?: boolean;
|
|
508
509
|
openItem?: number;
|
|
509
|
-
isSortable
|
|
510
|
+
isSortable: false;
|
|
511
|
+
itemSettings: BaseItemSettings<T>;
|
|
512
|
+
} | {
|
|
513
|
+
label: string;
|
|
514
|
+
values?: T[];
|
|
515
|
+
openOnAdd?: boolean;
|
|
516
|
+
setValues: (newValue: T[], _: CreateOptions, meta?: SetRepeaterValuesMeta<T>) => void;
|
|
517
|
+
disabled?: boolean;
|
|
518
|
+
disableAddItemButton?: boolean;
|
|
519
|
+
showDuplicate?: boolean;
|
|
520
|
+
showToggle?: boolean;
|
|
521
|
+
showRemove?: boolean;
|
|
522
|
+
openItem?: number;
|
|
523
|
+
isSortable?: true;
|
|
524
|
+
itemSettings: SortableItemSettings<T>;
|
|
510
525
|
};
|
|
511
526
|
declare const Repeater: <T>({ label, itemSettings, disabled, openOnAdd, values: items, setValues: setItems, showDuplicate, showToggle, showRemove, disableAddItemButton, openItem: initialOpenItem, isSortable, }: RepeaterProps<RepeaterItem<T>>) => React$1.JSX.Element;
|
|
512
527
|
|
package/dist/index.js
CHANGED
|
@@ -1031,13 +1031,16 @@ var SizeControl = createControl(
|
|
|
1031
1031
|
propType
|
|
1032
1032
|
} = useBoundProp(import_editor_props7.sizePropTypeUtil);
|
|
1033
1033
|
const actualDefaultUnit = defaultUnit ?? externalPlaceholder?.unit ?? defaultSelectedUnit[variant];
|
|
1034
|
-
const [internalState, setInternalState] = (0, import_react13.useState)(createStateFromSizeProp(sizeValue, actualDefaultUnit));
|
|
1035
1034
|
const activeBreakpoint = (0, import_editor_responsive.useActiveBreakpoint)();
|
|
1036
1035
|
const actualUnits = resolveUnits(propType, enablePropTypeUnits, variant, units2);
|
|
1037
1036
|
const actualExtendedOptions = useSizeExtendedOptions(extendedOptions || [], disableCustom ?? false);
|
|
1038
1037
|
const popupState = (0, import_ui13.usePopupState)({ variant: "popover" });
|
|
1038
|
+
const memorizedExternalState = (0, import_react13.useMemo)(
|
|
1039
|
+
() => createStateFromSizeProp(sizeValue, actualDefaultUnit),
|
|
1040
|
+
[sizeValue, actualDefaultUnit]
|
|
1041
|
+
);
|
|
1039
1042
|
const [state, setState] = useSyncExternalState({
|
|
1040
|
-
external:
|
|
1043
|
+
external: memorizedExternalState,
|
|
1041
1044
|
setExternal: (newState, options, meta) => setSizeValue(extractValueFromState(newState), options, meta),
|
|
1042
1045
|
persistWhen: (newState) => !!extractValueFromState(newState),
|
|
1043
1046
|
fallback: (newState) => ({
|
|
@@ -1092,7 +1095,7 @@ var SizeControl = createControl(
|
|
|
1092
1095
|
return;
|
|
1093
1096
|
}
|
|
1094
1097
|
if (state.unit === newState.unit) {
|
|
1095
|
-
|
|
1098
|
+
setState(mergedStates);
|
|
1096
1099
|
return;
|
|
1097
1100
|
}
|
|
1098
1101
|
setState(newState);
|
|
@@ -1171,11 +1174,15 @@ function extractValueFromState(state, allowEmpty = false) {
|
|
|
1171
1174
|
if (unit === "auto") {
|
|
1172
1175
|
return { size: "", unit };
|
|
1173
1176
|
}
|
|
1174
|
-
if (
|
|
1177
|
+
if (unit === "custom") {
|
|
1178
|
+
return { size: state.custom ?? "", unit: "custom" };
|
|
1179
|
+
}
|
|
1180
|
+
const numeric = state.numeric;
|
|
1181
|
+
if (!allowEmpty && (numeric === void 0 || numeric === null || Number.isNaN(numeric))) {
|
|
1175
1182
|
return null;
|
|
1176
1183
|
}
|
|
1177
1184
|
return {
|
|
1178
|
-
size:
|
|
1185
|
+
size: numeric,
|
|
1179
1186
|
unit
|
|
1180
1187
|
};
|
|
1181
1188
|
}
|
|
@@ -5915,7 +5922,9 @@ var Repeater3 = ({
|
|
|
5915
5922
|
isSortable = true
|
|
5916
5923
|
}) => {
|
|
5917
5924
|
const [openItem, setOpenItem] = (0, import_react53.useState)(initialOpenItem);
|
|
5918
|
-
const uniqueKeys = items2.map(
|
|
5925
|
+
const uniqueKeys = items2.map(
|
|
5926
|
+
(item, index) => isSortable && "getId" in itemSettings ? itemSettings.getId({ item, index }) : String(index)
|
|
5927
|
+
);
|
|
5919
5928
|
const addRepeaterItem = () => {
|
|
5920
5929
|
const newItem = structuredClone(itemSettings.initialValues);
|
|
5921
5930
|
const newIndex = items2.length;
|