@elementor/editor-controls 3.33.0-276 → 3.33.0-278
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 +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +136 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +140 -42
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/control-repeater/actions/duplicate-item-action.tsx +9 -3
- package/src/components/control-repeater/context/repeater-context.tsx +4 -0
- package/src/components/control-repeater/control-repeater.tsx +12 -3
- package/src/components/control-repeater/items/item.tsx +19 -2
- package/src/controls/repeatable-control.tsx +2 -1
- package/src/controls/transition-control/data.ts +16 -1
- package/src/controls/transition-control/transition-repeater-control.tsx +103 -25
- package/src/controls/transition-control/transition-selector.tsx +20 -7
- package/src/hooks/use-repeatable-control-context.ts +3 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React$1 from 'react';
|
|
2
2
|
import { RefObject, ReactNode, FC, PropsWithChildren, ReactElement, ComponentType } from 'react';
|
|
3
3
|
import { SxProps, SelectProps, UnstableColorFieldProps, ToggleButtonProps, StackProps, PopupState, Theme, FormLabelProps } from '@elementor/ui';
|
|
4
|
-
import { StringPropValue, PropTypeUtil, PropValue, PropKey, SizePropValue, LinkPropValue, PropType, CreateOptions } from '@elementor/editor-props';
|
|
4
|
+
import { StringPropValue, PropTypeUtil, PropValue, PropKey, SizePropValue, LinkPropValue, TransformablePropValue, PropType, CreateOptions } from '@elementor/editor-props';
|
|
5
5
|
import { StyleDefinitionState } from '@elementor/editor-styles';
|
|
6
6
|
import * as _elementor_locations from '@elementor/locations';
|
|
7
7
|
|
|
@@ -160,12 +160,12 @@ declare const NumberControl: ControlComponent<({ placeholder: labelPlaceholder,
|
|
|
160
160
|
}) => React$1.JSX.Element>;
|
|
161
161
|
|
|
162
162
|
type MultiSizePropValue = Record<PropKey, SizePropValue>;
|
|
163
|
-
type Item = {
|
|
163
|
+
type Item$1 = {
|
|
164
164
|
icon: ReactNode;
|
|
165
165
|
label: string;
|
|
166
166
|
bind: PropKey;
|
|
167
167
|
};
|
|
168
|
-
type EqualUnequalItems = [Item, Item, Item, Item];
|
|
168
|
+
type EqualUnequalItems = [Item$1, Item$1, Item$1, Item$1];
|
|
169
169
|
type Props$4<TMultiPropType extends string, TPropValue extends MultiSizePropValue> = {
|
|
170
170
|
label: string;
|
|
171
171
|
icon: ReactNode;
|
|
@@ -292,11 +292,17 @@ type TooltipAddItemActionProps = {
|
|
|
292
292
|
ariaLabel?: string;
|
|
293
293
|
};
|
|
294
294
|
|
|
295
|
+
type Item<T> = {
|
|
296
|
+
disabled?: boolean;
|
|
297
|
+
} & T;
|
|
298
|
+
type RepeatablePropValue = TransformablePropValue<PropKey, PropValue>;
|
|
299
|
+
|
|
295
300
|
type ChildControlConfig = {
|
|
296
301
|
component: React.ComponentType;
|
|
297
302
|
props?: Record<string, unknown>;
|
|
298
303
|
propTypeUtil: PropTypeUtil<string, any>;
|
|
299
304
|
label?: string;
|
|
305
|
+
isItemDisabled?: (item: Item<RepeatablePropValue>) => boolean;
|
|
300
306
|
};
|
|
301
307
|
|
|
302
308
|
type RepeatableControlProps = {
|
|
@@ -350,6 +356,7 @@ type TransitionProperty = {
|
|
|
350
356
|
label: string;
|
|
351
357
|
value: string;
|
|
352
358
|
unavailable?: boolean;
|
|
359
|
+
isDisabled?: boolean;
|
|
353
360
|
};
|
|
354
361
|
type TransitionCategory = {
|
|
355
362
|
label: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React$1 from 'react';
|
|
2
2
|
import { RefObject, ReactNode, FC, PropsWithChildren, ReactElement, ComponentType } from 'react';
|
|
3
3
|
import { SxProps, SelectProps, UnstableColorFieldProps, ToggleButtonProps, StackProps, PopupState, Theme, FormLabelProps } from '@elementor/ui';
|
|
4
|
-
import { StringPropValue, PropTypeUtil, PropValue, PropKey, SizePropValue, LinkPropValue, PropType, CreateOptions } from '@elementor/editor-props';
|
|
4
|
+
import { StringPropValue, PropTypeUtil, PropValue, PropKey, SizePropValue, LinkPropValue, TransformablePropValue, PropType, CreateOptions } from '@elementor/editor-props';
|
|
5
5
|
import { StyleDefinitionState } from '@elementor/editor-styles';
|
|
6
6
|
import * as _elementor_locations from '@elementor/locations';
|
|
7
7
|
|
|
@@ -160,12 +160,12 @@ declare const NumberControl: ControlComponent<({ placeholder: labelPlaceholder,
|
|
|
160
160
|
}) => React$1.JSX.Element>;
|
|
161
161
|
|
|
162
162
|
type MultiSizePropValue = Record<PropKey, SizePropValue>;
|
|
163
|
-
type Item = {
|
|
163
|
+
type Item$1 = {
|
|
164
164
|
icon: ReactNode;
|
|
165
165
|
label: string;
|
|
166
166
|
bind: PropKey;
|
|
167
167
|
};
|
|
168
|
-
type EqualUnequalItems = [Item, Item, Item, Item];
|
|
168
|
+
type EqualUnequalItems = [Item$1, Item$1, Item$1, Item$1];
|
|
169
169
|
type Props$4<TMultiPropType extends string, TPropValue extends MultiSizePropValue> = {
|
|
170
170
|
label: string;
|
|
171
171
|
icon: ReactNode;
|
|
@@ -292,11 +292,17 @@ type TooltipAddItemActionProps = {
|
|
|
292
292
|
ariaLabel?: string;
|
|
293
293
|
};
|
|
294
294
|
|
|
295
|
+
type Item<T> = {
|
|
296
|
+
disabled?: boolean;
|
|
297
|
+
} & T;
|
|
298
|
+
type RepeatablePropValue = TransformablePropValue<PropKey, PropValue>;
|
|
299
|
+
|
|
295
300
|
type ChildControlConfig = {
|
|
296
301
|
component: React.ComponentType;
|
|
297
302
|
props?: Record<string, unknown>;
|
|
298
303
|
propTypeUtil: PropTypeUtil<string, any>;
|
|
299
304
|
label?: string;
|
|
305
|
+
isItemDisabled?: (item: Item<RepeatablePropValue>) => boolean;
|
|
300
306
|
};
|
|
301
307
|
|
|
302
308
|
type RepeatableControlProps = {
|
|
@@ -350,6 +356,7 @@ type TransitionProperty = {
|
|
|
350
356
|
label: string;
|
|
351
357
|
value: string;
|
|
352
358
|
unavailable?: boolean;
|
|
359
|
+
isDisabled?: boolean;
|
|
353
360
|
};
|
|
354
361
|
type TransitionCategory = {
|
|
355
362
|
label: string;
|
package/dist/index.js
CHANGED
|
@@ -1339,7 +1339,8 @@ var useRepeaterContext = () => {
|
|
|
1339
1339
|
var RepeaterContextProvider = ({
|
|
1340
1340
|
children,
|
|
1341
1341
|
initial,
|
|
1342
|
-
propTypeUtil
|
|
1342
|
+
propTypeUtil,
|
|
1343
|
+
isItemDisabled: isItemDisabled2 = () => false
|
|
1343
1344
|
}) => {
|
|
1344
1345
|
const { value: repeaterValues, setValue: setRepeaterValues } = useBoundProp(propTypeUtil);
|
|
1345
1346
|
const [items2, setItems] = useSyncExternalState({
|
|
@@ -1406,7 +1407,8 @@ var RepeaterContextProvider = ({
|
|
|
1406
1407
|
addItem,
|
|
1407
1408
|
removeItem,
|
|
1408
1409
|
rowRef,
|
|
1409
|
-
setRowRef
|
|
1410
|
+
setRowRef,
|
|
1411
|
+
isItemDisabled: (index) => isItemDisabled2(itemsWithKeys[index].item)
|
|
1410
1412
|
}
|
|
1411
1413
|
},
|
|
1412
1414
|
children
|
|
@@ -1598,12 +1600,20 @@ var { Slot: RepeaterItemActionsSlot, inject: injectIntoRepeaterItemActions } = (
|
|
|
1598
1600
|
|
|
1599
1601
|
// src/components/control-repeater/items/item.tsx
|
|
1600
1602
|
var Item = ({ Label: Label3, Icon, actions }) => {
|
|
1601
|
-
const {
|
|
1603
|
+
const {
|
|
1604
|
+
popoverState,
|
|
1605
|
+
setRowRef,
|
|
1606
|
+
openItemIndex,
|
|
1607
|
+
setOpenItemIndex,
|
|
1608
|
+
index = -1,
|
|
1609
|
+
value,
|
|
1610
|
+
isItemDisabled: isItemDisabled2
|
|
1611
|
+
} = useRepeaterContext();
|
|
1602
1612
|
const repeatableContext = React27.useContext(RepeatableControlContext);
|
|
1603
1613
|
const disableOpen = !!repeatableContext?.props?.readOnly;
|
|
1604
1614
|
const triggerProps = (0, import_ui21.bindTrigger)(popoverState);
|
|
1605
1615
|
const onClick = (ev) => {
|
|
1606
|
-
if (disableOpen) {
|
|
1616
|
+
if (disableOpen || isItemDisabled2(index)) {
|
|
1607
1617
|
return;
|
|
1608
1618
|
}
|
|
1609
1619
|
triggerProps.onClick(ev);
|
|
@@ -1625,6 +1635,14 @@ var Item = ({ Label: Label3, Icon, actions }) => {
|
|
|
1625
1635
|
...triggerProps,
|
|
1626
1636
|
onClick,
|
|
1627
1637
|
startIcon: /* @__PURE__ */ React27.createElement(RepeaterItemIconSlot, { value }, /* @__PURE__ */ React27.createElement(Icon, { value })),
|
|
1638
|
+
sx: {
|
|
1639
|
+
minHeight: (theme) => theme.spacing(3.5),
|
|
1640
|
+
...isItemDisabled2(index) && {
|
|
1641
|
+
'[role="button"]': {
|
|
1642
|
+
cursor: "not-allowed"
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
},
|
|
1628
1646
|
actions: /* @__PURE__ */ React27.createElement(React27.Fragment, null, /* @__PURE__ */ React27.createElement(RepeaterItemActionsSlot, { index: index ?? -1 }), actions)
|
|
1629
1647
|
}
|
|
1630
1648
|
);
|
|
@@ -1635,9 +1653,18 @@ var React28 = __toESM(require("react"));
|
|
|
1635
1653
|
var ControlRepeater = ({
|
|
1636
1654
|
children,
|
|
1637
1655
|
initial,
|
|
1638
|
-
propTypeUtil
|
|
1656
|
+
propTypeUtil,
|
|
1657
|
+
isItemDisabled: isItemDisabled2
|
|
1639
1658
|
}) => {
|
|
1640
|
-
return /* @__PURE__ */ React28.createElement(SectionContent, null, /* @__PURE__ */ React28.createElement(
|
|
1659
|
+
return /* @__PURE__ */ React28.createElement(SectionContent, null, /* @__PURE__ */ React28.createElement(
|
|
1660
|
+
RepeaterContextProvider,
|
|
1661
|
+
{
|
|
1662
|
+
initial,
|
|
1663
|
+
propTypeUtil,
|
|
1664
|
+
isItemDisabled: isItemDisabled2
|
|
1665
|
+
},
|
|
1666
|
+
children
|
|
1667
|
+
));
|
|
1641
1668
|
};
|
|
1642
1669
|
|
|
1643
1670
|
// src/components/control-repeater/actions/disable-item-action.tsx
|
|
@@ -1671,16 +1698,26 @@ var import_ui23 = require("@elementor/ui");
|
|
|
1671
1698
|
var import_i18n9 = require("@wordpress/i18n");
|
|
1672
1699
|
var SIZE4 = "tiny";
|
|
1673
1700
|
var DuplicateItemAction = () => {
|
|
1674
|
-
const { items: items2, addItem, index = -1 } = useRepeaterContext();
|
|
1701
|
+
const { items: items2, addItem, index = -1, isItemDisabled: isItemDisabled2 } = useRepeaterContext();
|
|
1675
1702
|
if (index === -1) {
|
|
1676
1703
|
return null;
|
|
1677
1704
|
}
|
|
1678
1705
|
const duplicateLabel = (0, import_i18n9.__)("Duplicate", "elementor");
|
|
1706
|
+
const item = items2[index]?.item;
|
|
1679
1707
|
const onClick = (ev) => {
|
|
1680
|
-
const newItem = structuredClone(
|
|
1708
|
+
const newItem = structuredClone(item);
|
|
1681
1709
|
addItem(ev, { item: newItem, index: index + 1 });
|
|
1682
1710
|
};
|
|
1683
|
-
return /* @__PURE__ */ React30.createElement(import_ui23.Tooltip, { title: duplicateLabel, placement: "top" }, /* @__PURE__ */ React30.createElement(
|
|
1711
|
+
return /* @__PURE__ */ React30.createElement(import_ui23.Tooltip, { title: duplicateLabel, placement: "top" }, /* @__PURE__ */ React30.createElement(
|
|
1712
|
+
import_ui23.IconButton,
|
|
1713
|
+
{
|
|
1714
|
+
size: SIZE4,
|
|
1715
|
+
onClick,
|
|
1716
|
+
"aria-label": duplicateLabel,
|
|
1717
|
+
disabled: isItemDisabled2(index)
|
|
1718
|
+
},
|
|
1719
|
+
/* @__PURE__ */ React30.createElement(import_icons7.CopyIcon, { fontSize: SIZE4 })
|
|
1720
|
+
));
|
|
1684
1721
|
};
|
|
1685
1722
|
|
|
1686
1723
|
// src/components/control-repeater/actions/remove-item-action.tsx
|
|
@@ -2193,8 +2230,8 @@ var FilterRepeaterControl = createControl(({ filterPropName = "filter" }) => {
|
|
|
2193
2230
|
)));
|
|
2194
2231
|
});
|
|
2195
2232
|
var Repeater = ({ propTypeUtil, label, filterPropName }) => {
|
|
2196
|
-
const { getInitialValue } = useFilterConfig();
|
|
2197
|
-
return /* @__PURE__ */ React48.createElement(ControlRepeater, { initial:
|
|
2233
|
+
const { getInitialValue: getInitialValue2 } = useFilterConfig();
|
|
2234
|
+
return /* @__PURE__ */ React48.createElement(ControlRepeater, { initial: getInitialValue2(), propTypeUtil }, /* @__PURE__ */ React48.createElement(RepeaterHeader, { label }, /* @__PURE__ */ React48.createElement(
|
|
2198
2235
|
TooltipAddItemAction,
|
|
2199
2236
|
{
|
|
2200
2237
|
newItemIndex: 0,
|
|
@@ -4529,11 +4566,11 @@ var RepeatableControl = createControl(
|
|
|
4529
4566
|
propKey,
|
|
4530
4567
|
addItemTooltipProps
|
|
4531
4568
|
}) => {
|
|
4532
|
-
const { propTypeUtil: childPropTypeUtil } = childControlConfig;
|
|
4569
|
+
const { propTypeUtil: childPropTypeUtil, isItemDisabled: isItemDisabled2 } = childControlConfig;
|
|
4533
4570
|
if (!childPropTypeUtil) {
|
|
4534
4571
|
return null;
|
|
4535
4572
|
}
|
|
4536
|
-
const
|
|
4573
|
+
const childArrayPropTypeUtil2 = (0, import_react41.useMemo)(
|
|
4537
4574
|
() => (0, import_editor_props35.createArrayPropUtils)(childPropTypeUtil.key, childPropTypeUtil.schema, propKey),
|
|
4538
4575
|
[childPropTypeUtil.key, childPropTypeUtil.schema, propKey]
|
|
4539
4576
|
);
|
|
@@ -4545,12 +4582,13 @@ var RepeatableControl = createControl(
|
|
|
4545
4582
|
}),
|
|
4546
4583
|
[childControlConfig, placeholder, patternLabel]
|
|
4547
4584
|
);
|
|
4548
|
-
const { propType, value, setValue } = useBoundProp(
|
|
4585
|
+
const { propType, value, setValue } = useBoundProp(childArrayPropTypeUtil2);
|
|
4549
4586
|
return /* @__PURE__ */ React79.createElement(PropProvider, { propType, value, setValue }, /* @__PURE__ */ React79.createElement(RepeatableControlContext.Provider, { value: contextValue }, /* @__PURE__ */ React79.createElement(
|
|
4550
4587
|
ControlRepeater,
|
|
4551
4588
|
{
|
|
4552
4589
|
initial: childPropTypeUtil.create(initialValues || null),
|
|
4553
|
-
propTypeUtil:
|
|
4590
|
+
propTypeUtil: childArrayPropTypeUtil2,
|
|
4591
|
+
isItemDisabled: isItemDisabled2
|
|
4554
4592
|
},
|
|
4555
4593
|
/* @__PURE__ */ React79.createElement(RepeaterHeader, { label: repeaterLabel }, /* @__PURE__ */ React79.createElement(
|
|
4556
4594
|
TooltipAddItemAction,
|
|
@@ -5362,14 +5400,14 @@ var Repeater2 = ({
|
|
|
5362
5400
|
const transformFunctionsContext = useBoundProp(import_editor_props46.transformFunctionsPropTypeUtil);
|
|
5363
5401
|
const availableValues = [initialTransformValue, initialScaleValue, initialRotateValue, initialSkewValue];
|
|
5364
5402
|
const { value: transformValues, bind } = transformFunctionsContext;
|
|
5365
|
-
const
|
|
5403
|
+
const getInitialValue2 = () => {
|
|
5366
5404
|
return availableValues.find((value) => !transformValues?.some((item) => item.$$type === value.$$type));
|
|
5367
5405
|
};
|
|
5368
|
-
const shouldDisableAddItem = !
|
|
5406
|
+
const shouldDisableAddItem = !getInitialValue2();
|
|
5369
5407
|
return /* @__PURE__ */ React94.createElement(PropProvider, { ...transformFunctionsContext }, /* @__PURE__ */ React94.createElement(
|
|
5370
5408
|
ControlRepeater,
|
|
5371
5409
|
{
|
|
5372
|
-
initial:
|
|
5410
|
+
initial: getInitialValue2() ?? initialTransformValue,
|
|
5373
5411
|
propTypeUtil: import_editor_props46.transformFunctionsPropTypeUtil
|
|
5374
5412
|
},
|
|
5375
5413
|
/* @__PURE__ */ React94.createElement(
|
|
@@ -5525,13 +5563,23 @@ var toTransitionSelectorValue = (label) => {
|
|
|
5525
5563
|
}
|
|
5526
5564
|
return null;
|
|
5527
5565
|
};
|
|
5528
|
-
|
|
5566
|
+
function getTransitionPropertyByValue(item) {
|
|
5567
|
+
if (!item?.value) {
|
|
5568
|
+
return null;
|
|
5569
|
+
}
|
|
5529
5570
|
for (const category of transitionProperties) {
|
|
5530
|
-
const property
|
|
5531
|
-
|
|
5532
|
-
|
|
5571
|
+
for (const property of category.properties) {
|
|
5572
|
+
if (property.value === item.value) {
|
|
5573
|
+
return property;
|
|
5574
|
+
}
|
|
5533
5575
|
}
|
|
5534
5576
|
}
|
|
5577
|
+
return null;
|
|
5578
|
+
}
|
|
5579
|
+
var includeCurrentValueInOptions = (value, disabledItems) => {
|
|
5580
|
+
return disabledItems.filter((item) => {
|
|
5581
|
+
return item !== value.key.value;
|
|
5582
|
+
});
|
|
5535
5583
|
};
|
|
5536
5584
|
var TransitionSelector = ({
|
|
5537
5585
|
recentlyUsedList = [],
|
|
@@ -5544,7 +5592,7 @@ var TransitionSelector = ({
|
|
|
5544
5592
|
const defaultRef = (0, import_react50.useRef)(null);
|
|
5545
5593
|
const popoverState = (0, import_ui82.usePopupState)({ variant: "popover" });
|
|
5546
5594
|
const getItemList = () => {
|
|
5547
|
-
const recentItems = recentlyUsedList.map((item) =>
|
|
5595
|
+
const recentItems = recentlyUsedList.map((item) => getTransitionPropertyByValue({ value: item, $$type: "string" })?.label).filter((item) => !!item);
|
|
5548
5596
|
const filteredItems = transitionsItemsList.map((category) => {
|
|
5549
5597
|
return {
|
|
5550
5598
|
...category,
|
|
@@ -5612,7 +5660,7 @@ var TransitionSelector = ({
|
|
|
5612
5660
|
sectionWidth: 268,
|
|
5613
5661
|
title: (0, import_i18n48.__)("Transition Property", "elementor"),
|
|
5614
5662
|
icon: import_icons31.VariationsIcon,
|
|
5615
|
-
disabledItems
|
|
5663
|
+
disabledItems: includeCurrentValueInOptions(value, disabledItems)
|
|
5616
5664
|
}
|
|
5617
5665
|
)
|
|
5618
5666
|
));
|
|
@@ -5624,6 +5672,21 @@ var DURATION_CONFIG = {
|
|
|
5624
5672
|
units: ["s", "ms"],
|
|
5625
5673
|
defaultUnit: "ms"
|
|
5626
5674
|
};
|
|
5675
|
+
var childArrayPropTypeUtil = (0, import_editor_props49.createArrayPropUtils)(
|
|
5676
|
+
import_editor_props49.selectionSizePropTypeUtil.key,
|
|
5677
|
+
import_editor_props49.selectionSizePropTypeUtil.schema,
|
|
5678
|
+
"transition"
|
|
5679
|
+
);
|
|
5680
|
+
subscribeToTransitionEvent();
|
|
5681
|
+
var areAllPropertiesUsed = (value = []) => {
|
|
5682
|
+
return value?.length ? transitionProperties.every((category) => {
|
|
5683
|
+
return category.properties.every((property) => {
|
|
5684
|
+
return property.isDisabled || !!value?.find((item) => {
|
|
5685
|
+
return item.value?.selection?.value?.value?.value === property.value;
|
|
5686
|
+
});
|
|
5687
|
+
});
|
|
5688
|
+
}) : false;
|
|
5689
|
+
};
|
|
5627
5690
|
var getSelectionSizeProps = (recentlyUsedList, disabledItems) => {
|
|
5628
5691
|
return {
|
|
5629
5692
|
selectionLabel: (0, import_i18n49.__)("Type", "elementor"),
|
|
@@ -5649,13 +5712,56 @@ var getSelectionSizeProps = (recentlyUsedList, disabledItems) => {
|
|
|
5649
5712
|
}
|
|
5650
5713
|
};
|
|
5651
5714
|
};
|
|
5652
|
-
|
|
5715
|
+
var isItemDisabled = (item) => {
|
|
5716
|
+
const property = getTransitionPropertyByValue(item.value.selection.value?.value);
|
|
5717
|
+
return !property ? false : !!property.isDisabled;
|
|
5718
|
+
};
|
|
5719
|
+
var getChildControlConfig = (recentlyUsedList, disabledItems) => {
|
|
5653
5720
|
return {
|
|
5654
5721
|
propTypeUtil: import_editor_props49.selectionSizePropTypeUtil,
|
|
5655
5722
|
component: SelectionSizeControl,
|
|
5656
|
-
props: getSelectionSizeProps(recentlyUsedList, disabledItems)
|
|
5723
|
+
props: getSelectionSizeProps(recentlyUsedList, disabledItems),
|
|
5724
|
+
isItemDisabled
|
|
5657
5725
|
};
|
|
5658
|
-
}
|
|
5726
|
+
};
|
|
5727
|
+
var isPropertyUsed = (value, property) => {
|
|
5728
|
+
return (value ?? []).some((item) => {
|
|
5729
|
+
return item?.value?.selection?.value?.value?.value === property.value;
|
|
5730
|
+
});
|
|
5731
|
+
};
|
|
5732
|
+
var getDisabledItemLabels = (values = []) => {
|
|
5733
|
+
const disabledLabels = (values || []).map(
|
|
5734
|
+
(item) => item.value?.selection?.value?.key?.value
|
|
5735
|
+
);
|
|
5736
|
+
transitionProperties.forEach((category) => {
|
|
5737
|
+
const disabledProperties = category.properties.filter((property) => property.isDisabled && !disabledLabels.includes(property.label)).map((property) => property.label);
|
|
5738
|
+
disabledLabels.push(...disabledProperties);
|
|
5739
|
+
});
|
|
5740
|
+
return disabledLabels;
|
|
5741
|
+
};
|
|
5742
|
+
var getInitialValue = (values = []) => {
|
|
5743
|
+
if (!values?.length) {
|
|
5744
|
+
return initialTransitionValue;
|
|
5745
|
+
}
|
|
5746
|
+
for (const category of transitionProperties) {
|
|
5747
|
+
for (const property of category.properties) {
|
|
5748
|
+
if (isPropertyUsed(values, property)) {
|
|
5749
|
+
continue;
|
|
5750
|
+
}
|
|
5751
|
+
return {
|
|
5752
|
+
...initialTransitionValue,
|
|
5753
|
+
selection: {
|
|
5754
|
+
$$type: "key-value",
|
|
5755
|
+
value: {
|
|
5756
|
+
key: { value: property.label, $$type: "string" },
|
|
5757
|
+
value: { value: property.value, $$type: "string" }
|
|
5758
|
+
}
|
|
5759
|
+
}
|
|
5760
|
+
};
|
|
5761
|
+
}
|
|
5762
|
+
}
|
|
5763
|
+
return initialTransitionValue;
|
|
5764
|
+
};
|
|
5659
5765
|
var disableAddItemTooltipContent = /* @__PURE__ */ React97.createElement(
|
|
5660
5766
|
import_ui83.Alert,
|
|
5661
5767
|
{
|
|
@@ -5669,13 +5775,6 @@ var disableAddItemTooltipContent = /* @__PURE__ */ React97.createElement(
|
|
|
5669
5775
|
/* @__PURE__ */ React97.createElement(import_ui83.AlertTitle, null, (0, import_i18n49.__)("Transitions", "elementor")),
|
|
5670
5776
|
/* @__PURE__ */ React97.createElement(import_ui83.Box, { component: "span" }, /* @__PURE__ */ React97.createElement(import_ui83.Typography, { variant: "body2" }, (0, import_i18n49.__)("Switch to 'Normal' state to add a transition.", "elementor")))
|
|
5671
5777
|
);
|
|
5672
|
-
subscribeToTransitionEvent();
|
|
5673
|
-
var getTransitionLabel = (item) => {
|
|
5674
|
-
return item.value.selection.value?.key?.value ?? "";
|
|
5675
|
-
};
|
|
5676
|
-
var getDisabledItems = (value) => {
|
|
5677
|
-
return value?.map(getTransitionLabel) ?? [];
|
|
5678
|
-
};
|
|
5679
5778
|
var TransitionRepeaterControl = createControl(
|
|
5680
5779
|
({
|
|
5681
5780
|
recentlyUsedListGetter,
|
|
@@ -5683,12 +5782,8 @@ var TransitionRepeaterControl = createControl(
|
|
|
5683
5782
|
}) => {
|
|
5684
5783
|
const currentStyleIsNormal = currentStyleState === null;
|
|
5685
5784
|
const [recentlyUsedList, setRecentlyUsedList] = (0, import_react51.useState)([]);
|
|
5686
|
-
const childArrayPropTypeUtil = (0, import_react51.useMemo)(
|
|
5687
|
-
() => (0, import_editor_props49.createArrayPropUtils)(import_editor_props49.selectionSizePropTypeUtil.key, import_editor_props49.selectionSizePropTypeUtil.schema, "transition"),
|
|
5688
|
-
[]
|
|
5689
|
-
);
|
|
5690
5785
|
const { value, setValue } = useBoundProp(childArrayPropTypeUtil);
|
|
5691
|
-
const disabledItems = (0, import_react51.useMemo)(() =>
|
|
5786
|
+
const disabledItems = (0, import_react51.useMemo)(() => getDisabledItemLabels(value), [value]);
|
|
5692
5787
|
const allowedTransitionSet = (0, import_react51.useMemo)(() => {
|
|
5693
5788
|
const set = /* @__PURE__ */ new Set();
|
|
5694
5789
|
transitionProperties.forEach((category) => {
|
|
@@ -5711,7 +5806,7 @@ var TransitionRepeaterControl = createControl(
|
|
|
5711
5806
|
(0, import_react51.useEffect)(() => {
|
|
5712
5807
|
recentlyUsedListGetter().then(setRecentlyUsedList);
|
|
5713
5808
|
}, [recentlyUsedListGetter]);
|
|
5714
|
-
const allPropertiesUsed = value
|
|
5809
|
+
const allPropertiesUsed = (0, import_react51.useMemo)(() => areAllPropertiesUsed(value), [value]);
|
|
5715
5810
|
const isAddItemDisabled = !currentStyleIsNormal || allPropertiesUsed;
|
|
5716
5811
|
return /* @__PURE__ */ React97.createElement(
|
|
5717
5812
|
RepeatableControl,
|
|
@@ -5722,7 +5817,7 @@ var TransitionRepeaterControl = createControl(
|
|
|
5722
5817
|
placeholder: (0, import_i18n49.__)("Empty Transition", "elementor"),
|
|
5723
5818
|
showDuplicate: false,
|
|
5724
5819
|
showToggle: true,
|
|
5725
|
-
initialValues:
|
|
5820
|
+
initialValues: getInitialValue(value),
|
|
5726
5821
|
childControlConfig: getChildControlConfig(recentlyUsedList, disabledItems),
|
|
5727
5822
|
propKey: "transition",
|
|
5728
5823
|
addItemTooltipProps: {
|