@elementor/editor-editing-panel 1.6.0 → 1.7.0
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 +20 -0
- package/dist/index.js +354 -314
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +215 -171
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/components/css-class-selector.tsx +87 -26
- package/src/components/multi-combobox.tsx +184 -0
- package/src/components/style-sections/border-section/border-field.tsx +1 -5
- package/src/components/style-sections/position-section/position-field.tsx +1 -0
- package/src/components/style-tab.tsx +1 -1
- package/src/controls-registry/create-top-level-object-type.ts +14 -0
- package/src/controls-registry/settings-field.tsx +12 -14
- package/src/controls-registry/styles-field.tsx +17 -5
- package/src/dynamics/components/dynamic-selection-control.tsx +1 -1
- package/src/dynamics/components/dynamic-selection.tsx +3 -4
- package/src/dynamics/dynamic-control.tsx +16 -11
- package/src/dynamics/hooks/use-dynamic-tag.ts +2 -3
- package/src/dynamics/hooks/use-prop-dynamic-action.tsx +1 -4
- package/src/dynamics/hooks/use-prop-dynamic-tags.ts +3 -6
- package/src/dynamics/utils.ts +1 -1
- package/src/hooks/use-styles-fields.ts +1 -0
- package/src/components/multi-combobox/index.ts +0 -3
- package/src/components/multi-combobox/multi-combobox.tsx +0 -122
- package/src/components/multi-combobox/types.ts +0 -29
- package/src/components/multi-combobox/use-combobox-actions.ts +0 -62
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { useBoundProp as
|
|
2
|
+
import { useBoundProp as useBoundProp6 } from "@elementor/editor-controls";
|
|
3
3
|
|
|
4
4
|
// src/control-replacement.tsx
|
|
5
5
|
import { createControlReplacement } from "@elementor/editor-controls";
|
|
@@ -290,22 +290,35 @@ var getGridLayout = (layout) => ({
|
|
|
290
290
|
|
|
291
291
|
// src/controls-registry/settings-field.tsx
|
|
292
292
|
import * as React9 from "react";
|
|
293
|
-
import {
|
|
293
|
+
import { PropKeyProvider, PropProvider } from "@elementor/editor-controls";
|
|
294
294
|
import { updateSettings, useElementSetting } from "@elementor/editor-elements";
|
|
295
|
+
|
|
296
|
+
// src/controls-registry/create-top-level-object-type.ts
|
|
297
|
+
var createTopLevelOjectType = ({ schema }) => {
|
|
298
|
+
const schemaPropType = {
|
|
299
|
+
key: "",
|
|
300
|
+
kind: "object",
|
|
301
|
+
meta: {},
|
|
302
|
+
settings: {},
|
|
303
|
+
default: null,
|
|
304
|
+
shape: schema
|
|
305
|
+
};
|
|
306
|
+
return schemaPropType;
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
// src/controls-registry/settings-field.tsx
|
|
295
310
|
var SettingsField = ({ bind, children }) => {
|
|
296
311
|
const { element, elementType } = useElement();
|
|
297
|
-
const defaultValue = elementType.propsSchema[bind]?.default;
|
|
298
312
|
const settingsValue = useElementSetting(element.id, bind);
|
|
299
|
-
const value =
|
|
313
|
+
const value = { [bind]: settingsValue };
|
|
314
|
+
const propType = createTopLevelOjectType({ schema: elementType.propsSchema });
|
|
300
315
|
const setValue = (newValue) => {
|
|
301
316
|
updateSettings({
|
|
302
317
|
id: element.id,
|
|
303
|
-
props: {
|
|
304
|
-
[bind]: newValue
|
|
305
|
-
}
|
|
318
|
+
props: { ...newValue }
|
|
306
319
|
});
|
|
307
320
|
};
|
|
308
|
-
return /* @__PURE__ */ React9.createElement(
|
|
321
|
+
return /* @__PURE__ */ React9.createElement(PropProvider, { propType, value, setValue }, /* @__PURE__ */ React9.createElement(PropKeyProvider, { bind }, children));
|
|
309
322
|
};
|
|
310
323
|
|
|
311
324
|
// src/components/section.tsx
|
|
@@ -377,7 +390,7 @@ var Control2 = ({ control }) => {
|
|
|
377
390
|
|
|
378
391
|
// src/components/style-tab.tsx
|
|
379
392
|
import * as React59 from "react";
|
|
380
|
-
import { useState as
|
|
393
|
+
import { useState as useState8 } from "react";
|
|
381
394
|
import { useElementSetting as useElementSetting3, useElementStyles } from "@elementor/editor-elements";
|
|
382
395
|
import { useActiveBreakpoint } from "@elementor/editor-responsive";
|
|
383
396
|
import { Divider as Divider7 } from "@elementor/ui";
|
|
@@ -400,14 +413,18 @@ function useClassesProp() {
|
|
|
400
413
|
|
|
401
414
|
// src/components/css-class-selector.tsx
|
|
402
415
|
import * as React16 from "react";
|
|
403
|
-
import { useId as
|
|
404
|
-
import { updateSettings as updateSettings2, useElementSetting as useElementSetting2 } from "@elementor/editor-elements";
|
|
416
|
+
import { useId as useId4, useRef as useRef2 } from "react";
|
|
417
|
+
import { getElementSetting, updateSettings as updateSettings2, useElementSetting as useElementSetting2 } from "@elementor/editor-elements";
|
|
405
418
|
import { classesPropTypeUtil } from "@elementor/editor-props";
|
|
406
|
-
import {
|
|
419
|
+
import {
|
|
420
|
+
ELEMENTS_STYLES_PROVIDER_KEY,
|
|
421
|
+
useAllStylesByProvider,
|
|
422
|
+
useCreateActionsByProvider
|
|
423
|
+
} from "@elementor/editor-styles-repository";
|
|
407
424
|
import { DotsVerticalIcon } from "@elementor/icons";
|
|
408
425
|
import {
|
|
409
426
|
bindTrigger,
|
|
410
|
-
Chip
|
|
427
|
+
Chip,
|
|
411
428
|
Stack as Stack3,
|
|
412
429
|
Typography as Typography2,
|
|
413
430
|
UnstableChipGroup,
|
|
@@ -450,79 +467,25 @@ var Content = React14.forwardRef(({ maxWidth, ...tooltipProps }, ref) => /* @__P
|
|
|
450
467
|
}
|
|
451
468
|
));
|
|
452
469
|
|
|
453
|
-
// src/components/multi-combobox
|
|
470
|
+
// src/components/multi-combobox.tsx
|
|
454
471
|
import * as React15 from "react";
|
|
472
|
+
import { useId as useId3, useState as useState3 } from "react";
|
|
455
473
|
import {
|
|
456
474
|
Autocomplete,
|
|
457
475
|
Box as Box5,
|
|
458
|
-
|
|
476
|
+
createFilterOptions,
|
|
459
477
|
styled as styled4,
|
|
460
478
|
TextField
|
|
461
479
|
} from "@elementor/ui";
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
import { createFilterOptions } from "@elementor/ui";
|
|
465
|
-
var useComboboxActions = (applied, actions, optionsLabel, onSelect) => ({
|
|
466
|
-
action: {
|
|
467
|
-
is: (opt) => typeof opt !== "string" && "action" in opt,
|
|
468
|
-
getLabel: (option) => option.action.getLabel(option.label),
|
|
469
|
-
groupBy: (option) => option.action.groupLabel,
|
|
470
|
-
onChange: ({ action, label }) => action?.apply(label),
|
|
471
|
-
getFilteredActions: (optionList, params) => {
|
|
472
|
-
const actionGroups = Object.values(actions);
|
|
473
|
-
return actionGroups.reduce((groups, group) => {
|
|
474
|
-
const actionOptions = group.actions.reduce((groupActions, action) => {
|
|
475
|
-
const shouldShowAction = action.condition(optionList, params.inputValue);
|
|
476
|
-
if (shouldShowAction) {
|
|
477
|
-
const actionOption = createActionOption(group.label, action, params.inputValue);
|
|
478
|
-
groupActions.unshift(actionOption);
|
|
479
|
-
}
|
|
480
|
-
return groupActions;
|
|
481
|
-
}, []);
|
|
482
|
-
return [...groups, ...actionOptions];
|
|
483
|
-
}, []);
|
|
484
|
-
}
|
|
485
|
-
},
|
|
486
|
-
option: {
|
|
487
|
-
is: (opt) => typeof opt !== "string" && !("action" in opt),
|
|
488
|
-
getLabel: (option) => option.label,
|
|
489
|
-
groupBy: () => optionsLabel ?? "",
|
|
490
|
-
onChange: (optionValues) => onSelect?.(optionValues),
|
|
491
|
-
getFilteredOptions: (optionList, params) => {
|
|
492
|
-
const appliedValues = applied.map((option) => option.value);
|
|
493
|
-
const optionsWithoutApplied = optionList.filter((option) => !appliedValues.includes(option.value));
|
|
494
|
-
return filter(optionsWithoutApplied, params);
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
});
|
|
498
|
-
var filter = createFilterOptions();
|
|
499
|
-
var createActionOption = (groupLabel, action, inputValue) => ({
|
|
500
|
-
value: "",
|
|
501
|
-
label: inputValue,
|
|
502
|
-
action: {
|
|
503
|
-
groupLabel,
|
|
504
|
-
apply: action.apply,
|
|
505
|
-
getLabel: action.getLabel
|
|
506
|
-
}
|
|
507
|
-
});
|
|
508
|
-
|
|
509
|
-
// src/components/multi-combobox/multi-combobox.tsx
|
|
510
|
-
var MultiCombobox = ({
|
|
511
|
-
actions = {},
|
|
480
|
+
function MultiCombobox({
|
|
481
|
+
actions = [],
|
|
512
482
|
selected,
|
|
513
483
|
options: options10,
|
|
514
|
-
optionsLabel,
|
|
515
484
|
onSelect,
|
|
516
|
-
onCreate,
|
|
517
485
|
...props
|
|
518
|
-
})
|
|
519
|
-
const
|
|
520
|
-
|
|
521
|
-
actions,
|
|
522
|
-
// TODO: make the group mechanism more generic, allow passing list of groups.
|
|
523
|
-
optionsLabel,
|
|
524
|
-
onSelect
|
|
525
|
-
);
|
|
486
|
+
}) {
|
|
487
|
+
const filter = useFilterOptions();
|
|
488
|
+
const { run, loading } = useActionRunner();
|
|
526
489
|
return /* @__PURE__ */ React15.createElement(
|
|
527
490
|
Autocomplete,
|
|
528
491
|
{
|
|
@@ -533,57 +496,94 @@ var MultiCombobox = ({
|
|
|
533
496
|
selectOnFocus: true,
|
|
534
497
|
disableClearable: true,
|
|
535
498
|
handleHomeEndKeys: true,
|
|
499
|
+
disabled: loading,
|
|
536
500
|
value: selected,
|
|
537
501
|
options: options10,
|
|
538
|
-
renderGroup,
|
|
502
|
+
renderGroup: (params) => /* @__PURE__ */ React15.createElement(Group, { ...params }),
|
|
539
503
|
renderInput: (params) => /* @__PURE__ */ React15.createElement(TextField, { ...params }),
|
|
540
|
-
|
|
541
|
-
|
|
504
|
+
onChange: (_, selectedOrInputValue, reason) => {
|
|
505
|
+
const inputValue = selectedOrInputValue.find((option) => typeof option === "string");
|
|
506
|
+
const optionsAndActions = selectedOrInputValue.filter((option) => typeof option !== "string");
|
|
542
507
|
if (reason === "createOption") {
|
|
543
|
-
const
|
|
544
|
-
|
|
508
|
+
const [firstAction] = filterActions(actions, { options: options10, inputValue: inputValue ?? "" });
|
|
509
|
+
if (firstAction) {
|
|
510
|
+
return run(firstAction.apply, firstAction.value);
|
|
511
|
+
}
|
|
545
512
|
}
|
|
546
|
-
const action =
|
|
513
|
+
const action = optionsAndActions.find((value) => isAction(value));
|
|
547
514
|
if (reason === "selectOption" && action) {
|
|
548
|
-
return
|
|
515
|
+
return run(action.apply, action.value);
|
|
549
516
|
}
|
|
550
|
-
const
|
|
551
|
-
|
|
552
|
-
optionProps.onChange([.../* @__PURE__ */ new Set([...fixedValues, ...selectedValues])]);
|
|
517
|
+
const fixedValues = options10.filter((option) => !!option.fixed);
|
|
518
|
+
onSelect?.([.../* @__PURE__ */ new Set([...optionsAndActions, ...fixedValues])]);
|
|
553
519
|
},
|
|
554
|
-
getOptionLabel: (option) =>
|
|
555
|
-
|
|
556
|
-
|
|
520
|
+
getOptionLabel: (option) => typeof option === "string" ? option : option.label,
|
|
521
|
+
getOptionKey: (option) => {
|
|
522
|
+
if (typeof option === "string") {
|
|
523
|
+
return option;
|
|
557
524
|
}
|
|
558
|
-
|
|
559
|
-
return actionProps.getLabel(option);
|
|
560
|
-
}
|
|
561
|
-
return "";
|
|
525
|
+
return option.key ?? option.value;
|
|
562
526
|
},
|
|
563
527
|
filterOptions: (optionList, params) => {
|
|
564
|
-
const
|
|
565
|
-
|
|
566
|
-
|
|
528
|
+
const selectedValues = selected.map((option) => option.value);
|
|
529
|
+
return [
|
|
530
|
+
...filterActions(actions, { options: optionList, inputValue: params.inputValue }),
|
|
531
|
+
...filter(
|
|
532
|
+
optionList.filter((option) => !selectedValues.includes(option.value)),
|
|
533
|
+
params
|
|
534
|
+
)
|
|
535
|
+
];
|
|
567
536
|
},
|
|
568
|
-
groupBy: (option) =>
|
|
537
|
+
groupBy: (option) => option.group ?? ""
|
|
569
538
|
}
|
|
570
539
|
);
|
|
540
|
+
}
|
|
541
|
+
var Group = (params) => {
|
|
542
|
+
const id = `combobox-group-${useId3().replace(/:/g, "_")}`;
|
|
543
|
+
return /* @__PURE__ */ React15.createElement(StyledGroup, { role: "group", "aria-labelledby": id }, /* @__PURE__ */ React15.createElement(StyledGroupHeader, { id }, " ", params.group), /* @__PURE__ */ React15.createElement(StyledGroupItems, { role: "listbox" }, params.children));
|
|
571
544
|
};
|
|
572
|
-
var
|
|
573
|
-
var Group = styled4("li")`
|
|
545
|
+
var StyledGroup = styled4("li")`
|
|
574
546
|
&:not( :last-of-type ) {
|
|
575
547
|
border-bottom: 1px solid ${({ theme }) => theme.palette.divider};
|
|
576
548
|
}
|
|
577
549
|
`;
|
|
578
|
-
var
|
|
550
|
+
var StyledGroupHeader = styled4(Box5)(({ theme }) => ({
|
|
579
551
|
position: "sticky",
|
|
580
552
|
top: "-8px",
|
|
581
553
|
padding: theme.spacing(1, 2),
|
|
582
554
|
color: theme.palette.text.tertiary
|
|
583
555
|
}));
|
|
584
|
-
var
|
|
556
|
+
var StyledGroupItems = styled4("ul")`
|
|
585
557
|
padding: 0;
|
|
586
558
|
`;
|
|
559
|
+
function useFilterOptions() {
|
|
560
|
+
return useState3(() => createFilterOptions())[0];
|
|
561
|
+
}
|
|
562
|
+
function useActionRunner() {
|
|
563
|
+
const [loading, setLoading] = useState3(false);
|
|
564
|
+
const run = async (apply, value) => {
|
|
565
|
+
setLoading(true);
|
|
566
|
+
try {
|
|
567
|
+
await apply(value);
|
|
568
|
+
} catch {
|
|
569
|
+
}
|
|
570
|
+
setLoading(false);
|
|
571
|
+
};
|
|
572
|
+
return { run, loading };
|
|
573
|
+
}
|
|
574
|
+
function filterActions(actions, { options: options10, inputValue }) {
|
|
575
|
+
return actions.filter((action) => action.condition(options10, inputValue)).map((action, index) => ({
|
|
576
|
+
label: action.label(inputValue),
|
|
577
|
+
value: inputValue,
|
|
578
|
+
group: action.group,
|
|
579
|
+
apply: action.apply,
|
|
580
|
+
condition: action.condition,
|
|
581
|
+
key: index.toString()
|
|
582
|
+
}));
|
|
583
|
+
}
|
|
584
|
+
function isAction(option) {
|
|
585
|
+
return "apply" in option && "condition" in option;
|
|
586
|
+
}
|
|
587
587
|
|
|
588
588
|
// src/components/css-class-selector.tsx
|
|
589
589
|
var ID = "elementor-css-class-selector";
|
|
@@ -597,8 +597,9 @@ var EMPTY_OPTION = {
|
|
|
597
597
|
};
|
|
598
598
|
function CssClassSelector() {
|
|
599
599
|
const options10 = useOptions();
|
|
600
|
-
const
|
|
600
|
+
const { value: appliedIds, setValue: setAppliedIds, pushValue: pushAppliedId } = useAppliedClassesIds();
|
|
601
601
|
const { id: activeId, setId: setActiveId } = useStyle();
|
|
602
|
+
const actions = useCreateActions({ pushAppliedId, setActiveId });
|
|
602
603
|
const handleApply = useHandleApply(appliedIds, setAppliedIds);
|
|
603
604
|
const handleActivate = ({ value }) => setActiveId(value);
|
|
604
605
|
const applied = useAppliedOptions(options10, appliedIds);
|
|
@@ -612,7 +613,8 @@ function CssClassSelector() {
|
|
|
612
613
|
selected: applied,
|
|
613
614
|
onSelect: handleApply,
|
|
614
615
|
limitTags: TAGS_LIMIT,
|
|
615
|
-
|
|
616
|
+
actions,
|
|
617
|
+
getLimitTagsText: (more) => /* @__PURE__ */ React16.createElement(Chip, { size: "tiny", variant: "standard", label: `+${more}`, clickable: true }),
|
|
616
618
|
renderTags: (values, getTagProps) => values.map((value, index) => {
|
|
617
619
|
const chipProps = getTagProps({ index });
|
|
618
620
|
const isActive = value.value === active?.value;
|
|
@@ -635,15 +637,15 @@ function CssClassSelector() {
|
|
|
635
637
|
}
|
|
636
638
|
function CssClassItem({ id, label, isActive, isGlobal, color, chipProps, onClickActive }) {
|
|
637
639
|
const { meta } = useStyle();
|
|
638
|
-
const popupId =
|
|
640
|
+
const popupId = useId4().replace(/:/g, "_");
|
|
639
641
|
const popupState = usePopupState2({ variant: "popover", popupId });
|
|
640
642
|
const chipRef = useRef2(null);
|
|
641
643
|
const { onDelete, ...chipGroupProps } = chipProps;
|
|
642
644
|
return /* @__PURE__ */ React16.createElement(CssClassItemProvider, { styleId: id, isActive, isGlobal }, /* @__PURE__ */ React16.createElement(UnstableChipGroup, { ref: chipRef, ...chipGroupProps, "aria-label": `Edit ${label}`, role: "group" }, /* @__PURE__ */ React16.createElement(
|
|
643
|
-
|
|
645
|
+
Chip,
|
|
644
646
|
{
|
|
645
647
|
key: chipProps.key,
|
|
646
|
-
size: "
|
|
648
|
+
size: "tiny",
|
|
647
649
|
label: /* @__PURE__ */ React16.createElement(ConditionalTooltipWrapper, { maxWidth: "10ch", title: label }),
|
|
648
650
|
variant: isActive && !meta.state ? "filled" : "standard",
|
|
649
651
|
color,
|
|
@@ -651,10 +653,10 @@ function CssClassItem({ id, label, isActive, isGlobal, color, chipProps, onClick
|
|
|
651
653
|
"aria-pressed": isActive
|
|
652
654
|
}
|
|
653
655
|
), /* @__PURE__ */ React16.createElement(
|
|
654
|
-
|
|
656
|
+
Chip,
|
|
655
657
|
{
|
|
656
658
|
key: `${chipProps.key}-menu`,
|
|
657
|
-
size: "
|
|
659
|
+
size: "tiny",
|
|
658
660
|
label: /* @__PURE__ */ React16.createElement(Stack3, { direction: "row", gap: 0.5, alignItems: "center" }, isActive && meta.state && /* @__PURE__ */ React16.createElement(Typography2, { variant: "inherit" }, meta.state), /* @__PURE__ */ React16.createElement(DotsVerticalIcon, { fontSize: "inherit" })),
|
|
659
661
|
variant: "filled",
|
|
660
662
|
color,
|
|
@@ -665,20 +667,50 @@ function CssClassItem({ id, label, isActive, isGlobal, color, chipProps, onClick
|
|
|
665
667
|
}
|
|
666
668
|
function useOptions() {
|
|
667
669
|
const { element } = useElement();
|
|
668
|
-
return useAllStylesByProvider({ elementId: element.id }).flatMap(
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
670
|
+
return useAllStylesByProvider({ elementId: element.id }).flatMap(
|
|
671
|
+
([provider, styleDefs]) => {
|
|
672
|
+
const isElements = provider.key === ELEMENTS_STYLES_PROVIDER_KEY;
|
|
673
|
+
if (isElements && styleDefs.length === 0) {
|
|
674
|
+
return [EMPTY_OPTION];
|
|
675
|
+
}
|
|
676
|
+
return styleDefs.map((styleDef) => {
|
|
677
|
+
return {
|
|
678
|
+
label: styleDef.label,
|
|
679
|
+
value: styleDef.id,
|
|
680
|
+
fixed: isElements,
|
|
681
|
+
color: isElements ? "primary" : "global",
|
|
682
|
+
provider: provider.key,
|
|
683
|
+
group: provider.labels?.plural
|
|
684
|
+
};
|
|
685
|
+
});
|
|
672
686
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
687
|
+
);
|
|
688
|
+
}
|
|
689
|
+
function useCreateActions({
|
|
690
|
+
pushAppliedId,
|
|
691
|
+
setActiveId
|
|
692
|
+
}) {
|
|
693
|
+
return useCreateActionsByProvider().map(([provider, create]) => {
|
|
694
|
+
return {
|
|
695
|
+
// translators: %s is the label of the new class.
|
|
696
|
+
label: (value) => __2('Create new "%s"', "elementor").replace("%s", value),
|
|
697
|
+
apply: async (value) => {
|
|
698
|
+
const created = await create({ label: value });
|
|
699
|
+
if (!created) {
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
pushAppliedId(created.id);
|
|
703
|
+
setActiveId(created.id);
|
|
704
|
+
},
|
|
705
|
+
condition: (options10, inputValue) => {
|
|
706
|
+
const isUniqueLabel = !options10.some(
|
|
707
|
+
(option) => option.label.toLowerCase() === inputValue.toLowerCase()
|
|
708
|
+
);
|
|
709
|
+
return !!inputValue && isUniqueLabel;
|
|
710
|
+
},
|
|
711
|
+
// translators: %s is the singular label of css class provider (e.g "Global CSS Class").
|
|
712
|
+
group: __2("Create New %s", "elementor").replace("%s", provider.labels?.singular ?? "")
|
|
713
|
+
};
|
|
682
714
|
});
|
|
683
715
|
}
|
|
684
716
|
function useAppliedOptions(options10, appliedIds) {
|
|
@@ -703,7 +735,15 @@ function useAppliedClassesIds() {
|
|
|
703
735
|
}
|
|
704
736
|
});
|
|
705
737
|
};
|
|
706
|
-
|
|
738
|
+
const pushValue = (id) => {
|
|
739
|
+
const ids = getElementSetting(element.id, currentClassesProp)?.value || [];
|
|
740
|
+
setValue([...ids, id]);
|
|
741
|
+
};
|
|
742
|
+
return {
|
|
743
|
+
value,
|
|
744
|
+
setValue,
|
|
745
|
+
pushValue
|
|
746
|
+
};
|
|
707
747
|
}
|
|
708
748
|
function useHandleApply(appliedIds, setAppliedIds) {
|
|
709
749
|
const { id: activeId, setId: setActiveId } = useStyle();
|
|
@@ -732,7 +772,8 @@ import { BackgroundControl } from "@elementor/editor-controls";
|
|
|
732
772
|
|
|
733
773
|
// src/controls-registry/styles-field.tsx
|
|
734
774
|
import * as React17 from "react";
|
|
735
|
-
import {
|
|
775
|
+
import { PropKeyProvider as PropKeyProvider2, PropProvider as PropProvider2 } from "@elementor/editor-controls";
|
|
776
|
+
import { getStylesSchema } from "@elementor/editor-styles";
|
|
736
777
|
|
|
737
778
|
// src/hooks/use-styles-fields.ts
|
|
738
779
|
import { updateStyle, useElementStyleProps } from "@elementor/editor-elements";
|
|
@@ -775,7 +816,13 @@ function useStylesField(propName) {
|
|
|
775
816
|
// src/controls-registry/styles-field.tsx
|
|
776
817
|
var StylesField = ({ bind, children }) => {
|
|
777
818
|
const [value, setValue] = useStylesField(bind);
|
|
778
|
-
|
|
819
|
+
const stylesSchema = getStylesSchema();
|
|
820
|
+
const propType = createTopLevelOjectType({ schema: stylesSchema });
|
|
821
|
+
const values = { [bind]: value };
|
|
822
|
+
const setValues = (newValue) => {
|
|
823
|
+
setValue(newValue[bind]);
|
|
824
|
+
};
|
|
825
|
+
return /* @__PURE__ */ React17.createElement(PropProvider2, { propType, value: values, setValue: setValues }, /* @__PURE__ */ React17.createElement(PropKeyProvider2, { bind }, children));
|
|
779
826
|
};
|
|
780
827
|
|
|
781
828
|
// src/components/style-sections/background-section/background-section.tsx
|
|
@@ -882,11 +929,7 @@ var BorderWidthField = () => {
|
|
|
882
929
|
};
|
|
883
930
|
|
|
884
931
|
// src/components/style-sections/border-section/border-field.tsx
|
|
885
|
-
var
|
|
886
|
-
var initialBorderWidth = {
|
|
887
|
-
$$type: "border-width",
|
|
888
|
-
value: { top: initialSize, right: initialSize, bottom: initialSize, left: initialSize }
|
|
889
|
-
};
|
|
932
|
+
var initialBorderWidth = { $$type: "size", value: { size: 1, unit: "px" } };
|
|
890
933
|
var initialBorderColor = { $$type: "color", value: "#000000" };
|
|
891
934
|
var initialBorderStyle = "solid";
|
|
892
935
|
var BorderField = () => {
|
|
@@ -1212,7 +1255,7 @@ var FlexDirectionField = () => {
|
|
|
1212
1255
|
|
|
1213
1256
|
// src/components/style-sections/layout-section/flex-order-field.tsx
|
|
1214
1257
|
import * as React32 from "react";
|
|
1215
|
-
import { useState as
|
|
1258
|
+
import { useState as useState4 } from "react";
|
|
1216
1259
|
import {
|
|
1217
1260
|
ControlLabel as ControlLabel9,
|
|
1218
1261
|
ControlToggleButtonGroup,
|
|
@@ -1252,7 +1295,7 @@ var items = [
|
|
|
1252
1295
|
];
|
|
1253
1296
|
var FlexOrderField = () => {
|
|
1254
1297
|
const { isSiteRtl } = useDirection(), [order, setOrder] = useStylesField("order");
|
|
1255
|
-
const [groupControlValue, setGroupControlValue] =
|
|
1298
|
+
const [groupControlValue, setGroupControlValue] = useState4(getGroupControlValue(order?.value || null));
|
|
1256
1299
|
const handleToggleButtonChange = (group) => {
|
|
1257
1300
|
setGroupControlValue(group);
|
|
1258
1301
|
if (!group || group === CUSTOM) {
|
|
@@ -1489,11 +1532,11 @@ import * as React41 from "react";
|
|
|
1489
1532
|
import { Stack as Stack14 } from "@elementor/ui";
|
|
1490
1533
|
|
|
1491
1534
|
// src/hooks/use-session-storage.ts
|
|
1492
|
-
import { useEffect as useEffect2, useState as
|
|
1535
|
+
import { useEffect as useEffect2, useState as useState6 } from "react";
|
|
1493
1536
|
import { getSessionStorageItem, removeSessionStorageItem, setSessionStorageItem } from "@elementor/utils";
|
|
1494
1537
|
var useSessionStorage = (key) => {
|
|
1495
1538
|
const prefixedKey = `elementor/${key}`;
|
|
1496
|
-
const [value, setValue] =
|
|
1539
|
+
const [value, setValue] = useState6();
|
|
1497
1540
|
useEffect2(() => {
|
|
1498
1541
|
return subscribeToSessionStorage(prefixedKey, (newValue) => {
|
|
1499
1542
|
setValue(newValue ?? null);
|
|
@@ -1553,7 +1596,8 @@ var positionOptions = [
|
|
|
1553
1596
|
{ label: __20("Static", "elementor"), value: "static" },
|
|
1554
1597
|
{ label: __20("Relative", "elementor"), value: "relative" },
|
|
1555
1598
|
{ label: __20("Absolute", "elementor"), value: "absolute" },
|
|
1556
|
-
{ label: __20("Fixed", "elementor"), value: "fixed" }
|
|
1599
|
+
{ label: __20("Fixed", "elementor"), value: "fixed" },
|
|
1600
|
+
{ label: __20("Sticky", "elementor"), value: "sticky" }
|
|
1557
1601
|
];
|
|
1558
1602
|
var PositionField = ({ onChange }) => {
|
|
1559
1603
|
return /* @__PURE__ */ React39.createElement(StylesField, { bind: "position" }, /* @__PURE__ */ React39.createElement(Grid10, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React39.createElement(Grid10, { item: true, xs: 6 }, /* @__PURE__ */ React39.createElement(ControlLabel15, null, __20("Position", "elementor"))), /* @__PURE__ */ React39.createElement(Grid10, { item: true, xs: 6 }, /* @__PURE__ */ React39.createElement(SelectControl3, { options: positionOptions, onChange }))));
|
|
@@ -1665,11 +1709,11 @@ import { Divider as Divider6, Stack as Stack18 } from "@elementor/ui";
|
|
|
1665
1709
|
|
|
1666
1710
|
// src/components/collapsible-content.tsx
|
|
1667
1711
|
import * as React45 from "react";
|
|
1668
|
-
import { useState as
|
|
1712
|
+
import { useState as useState7 } from "react";
|
|
1669
1713
|
import { Button, Collapse as Collapse3, Stack as Stack17 } from "@elementor/ui";
|
|
1670
1714
|
import { __ as __25 } from "@wordpress/i18n";
|
|
1671
1715
|
var CollapsibleContent = ({ children, defaultOpen = false }) => {
|
|
1672
|
-
const [open, setOpen] =
|
|
1716
|
+
const [open, setOpen] = useState7(defaultOpen);
|
|
1673
1717
|
const handleToggle = () => {
|
|
1674
1718
|
setOpen((prevOpen) => !prevOpen);
|
|
1675
1719
|
};
|
|
@@ -1990,7 +2034,7 @@ var CLASSES_PROP_KEY = "classes";
|
|
|
1990
2034
|
var StyleTab = () => {
|
|
1991
2035
|
const currentClassesProp = useCurrentClassesProp();
|
|
1992
2036
|
const [activeStyleDefId, setActiveStyleDefId] = useActiveStyleDefId(currentClassesProp);
|
|
1993
|
-
const [activeStyleState, setActiveStyleState] =
|
|
2037
|
+
const [activeStyleState, setActiveStyleState] = useState8(null);
|
|
1994
2038
|
const breakpoint = useActiveBreakpoint();
|
|
1995
2039
|
return /* @__PURE__ */ React59.createElement(ClassesPropProvider, { prop: currentClassesProp }, /* @__PURE__ */ React59.createElement(
|
|
1996
2040
|
StyleProvider,
|
|
@@ -2009,7 +2053,7 @@ var StyleTab = () => {
|
|
|
2009
2053
|
));
|
|
2010
2054
|
};
|
|
2011
2055
|
function useActiveStyleDefId(currentClassesProp) {
|
|
2012
|
-
const [activeStyledDefId, setActiveStyledDefId] =
|
|
2056
|
+
const [activeStyledDefId, setActiveStyledDefId] = useState8(null);
|
|
2013
2057
|
const fallback = useFirstElementStyleDef(currentClassesProp);
|
|
2014
2058
|
return [activeStyledDefId || fallback?.id || null, setActiveStyledDefId];
|
|
2015
2059
|
}
|
|
@@ -2022,7 +2066,7 @@ function useFirstElementStyleDef(currentClassesProp) {
|
|
|
2022
2066
|
function useCurrentClassesProp() {
|
|
2023
2067
|
const { elementType } = useElement();
|
|
2024
2068
|
const prop = Object.entries(elementType.propsSchema).find(
|
|
2025
|
-
([, propType]) => propType.kind === "
|
|
2069
|
+
([, propType]) => propType.kind === "plain" && propType.key === CLASSES_PROP_KEY
|
|
2026
2070
|
);
|
|
2027
2071
|
if (!prop) {
|
|
2028
2072
|
throw new Error("Element does not have a classes prop");
|
|
@@ -2134,8 +2178,8 @@ function registerGlobalClassItems() {
|
|
|
2134
2178
|
|
|
2135
2179
|
// src/dynamics/components/dynamic-selection-control.tsx
|
|
2136
2180
|
import * as React64 from "react";
|
|
2137
|
-
import { useId as
|
|
2138
|
-
import { ControlLabel as ControlLabel30, useBoundProp as
|
|
2181
|
+
import { useId as useId5 } from "react";
|
|
2182
|
+
import { ControlLabel as ControlLabel30, useBoundProp as useBoundProp4 } from "@elementor/editor-controls";
|
|
2139
2183
|
import { DatabaseIcon, SettingsIcon, XIcon as XIcon2 } from "@elementor/icons";
|
|
2140
2184
|
import {
|
|
2141
2185
|
bindPopover as bindPopover2,
|
|
@@ -2165,13 +2209,14 @@ var usePersistDynamicValue = (propKey) => {
|
|
|
2165
2209
|
|
|
2166
2210
|
// src/dynamics/dynamic-control.tsx
|
|
2167
2211
|
import * as React62 from "react";
|
|
2168
|
-
import {
|
|
2212
|
+
import { PropKeyProvider as PropKeyProvider3, PropProvider as PropProvider3, useBoundProp as useBoundProp2 } from "@elementor/editor-controls";
|
|
2169
2213
|
|
|
2170
2214
|
// src/dynamics/hooks/use-dynamic-tag.ts
|
|
2171
2215
|
import { useMemo as useMemo3 } from "react";
|
|
2172
2216
|
|
|
2173
2217
|
// src/dynamics/hooks/use-prop-dynamic-tags.ts
|
|
2174
2218
|
import { useMemo as useMemo2 } from "react";
|
|
2219
|
+
import { useBoundProp } from "@elementor/editor-controls";
|
|
2175
2220
|
|
|
2176
2221
|
// src/dynamics/sync/get-elementor-config.ts
|
|
2177
2222
|
var getElementorConfig2 = () => {
|
|
@@ -2213,15 +2258,14 @@ var dynamicPropTypeUtil = createPropUtils(
|
|
|
2213
2258
|
DYNAMIC_PROP_TYPE_KEY,
|
|
2214
2259
|
z.strictObject({
|
|
2215
2260
|
name: z.string(),
|
|
2216
|
-
settings: z.
|
|
2261
|
+
settings: z.any().optional()
|
|
2217
2262
|
})
|
|
2218
2263
|
);
|
|
2219
2264
|
|
|
2220
2265
|
// src/dynamics/hooks/use-prop-dynamic-tags.ts
|
|
2221
|
-
var usePropDynamicTags = (
|
|
2266
|
+
var usePropDynamicTags = () => {
|
|
2222
2267
|
let categories = [];
|
|
2223
|
-
const {
|
|
2224
|
-
const propType = elementType.propsSchema?.[propName];
|
|
2268
|
+
const { propType } = useBoundProp();
|
|
2225
2269
|
if (propType) {
|
|
2226
2270
|
const propDynamicType = getDynamicPropType(propType);
|
|
2227
2271
|
categories = propDynamicType?.settings.categories || [];
|
|
@@ -2240,37 +2284,39 @@ var getDynamicTagsByCategories = (categories) => {
|
|
|
2240
2284
|
};
|
|
2241
2285
|
|
|
2242
2286
|
// src/dynamics/hooks/use-dynamic-tag.ts
|
|
2243
|
-
var useDynamicTag = (
|
|
2244
|
-
const dynamicTags = usePropDynamicTags(
|
|
2287
|
+
var useDynamicTag = (tagName) => {
|
|
2288
|
+
const dynamicTags = usePropDynamicTags();
|
|
2245
2289
|
return useMemo3(() => dynamicTags.find((tag) => tag.name === tagName) ?? null, [dynamicTags, tagName]);
|
|
2246
2290
|
};
|
|
2247
2291
|
|
|
2248
2292
|
// src/dynamics/dynamic-control.tsx
|
|
2249
2293
|
var DynamicControl = ({ bind, children }) => {
|
|
2250
|
-
const { value, setValue
|
|
2294
|
+
const { value, setValue } = useBoundProp2(dynamicPropTypeUtil);
|
|
2251
2295
|
const { name = "", settings } = value ?? {};
|
|
2252
|
-
const dynamicTag = useDynamicTag(
|
|
2296
|
+
const dynamicTag = useDynamicTag(name);
|
|
2253
2297
|
if (!dynamicTag) {
|
|
2254
2298
|
throw new Error(`Dynamic tag ${name} not found`);
|
|
2255
2299
|
}
|
|
2256
|
-
const
|
|
2300
|
+
const dynamicPropType = dynamicTag.props_schema[bind];
|
|
2301
|
+
const defaultValue = dynamicPropType?.default;
|
|
2257
2302
|
const dynamicValue = settings?.[bind] ?? defaultValue;
|
|
2258
|
-
const setDynamicValue = (
|
|
2303
|
+
const setDynamicValue = (newValues) => {
|
|
2259
2304
|
setValue({
|
|
2260
2305
|
name,
|
|
2261
2306
|
settings: {
|
|
2262
2307
|
...settings,
|
|
2263
|
-
|
|
2308
|
+
...newValues
|
|
2264
2309
|
}
|
|
2265
2310
|
});
|
|
2266
2311
|
};
|
|
2267
|
-
|
|
2312
|
+
const propType = createTopLevelOjectType({ schema: dynamicTag.props_schema });
|
|
2313
|
+
return /* @__PURE__ */ React62.createElement(PropProvider3, { propType, setValue: setDynamicValue, value: { [bind]: dynamicValue } }, /* @__PURE__ */ React62.createElement(PropKeyProvider3, { bind }, children));
|
|
2268
2314
|
};
|
|
2269
2315
|
|
|
2270
2316
|
// src/dynamics/components/dynamic-selection.tsx
|
|
2271
2317
|
import * as React63 from "react";
|
|
2272
|
-
import { Fragment as Fragment8, useState as
|
|
2273
|
-
import { useBoundProp as
|
|
2318
|
+
import { Fragment as Fragment8, useState as useState9 } from "react";
|
|
2319
|
+
import { useBoundProp as useBoundProp3 } from "@elementor/editor-controls";
|
|
2274
2320
|
import { PhotoIcon, SearchIcon } from "@elementor/icons";
|
|
2275
2321
|
import {
|
|
2276
2322
|
Box as Box6,
|
|
@@ -2287,13 +2333,13 @@ import {
|
|
|
2287
2333
|
import { __ as __41 } from "@wordpress/i18n";
|
|
2288
2334
|
var SIZE3 = "tiny";
|
|
2289
2335
|
var DynamicSelection = ({ onSelect }) => {
|
|
2290
|
-
const [searchValue, setSearchValue] =
|
|
2336
|
+
const [searchValue, setSearchValue] = useState9("");
|
|
2291
2337
|
const { groups: dynamicGroups } = getAtomicDynamicTags() || {};
|
|
2292
|
-
const { value: anyValue } =
|
|
2293
|
-
const { bind, value: dynamicValue, setValue } =
|
|
2338
|
+
const { value: anyValue } = useBoundProp3();
|
|
2339
|
+
const { bind, value: dynamicValue, setValue } = useBoundProp3(dynamicPropTypeUtil);
|
|
2294
2340
|
const [, updatePropValueHistory] = usePersistDynamicValue(bind);
|
|
2295
2341
|
const isCurrentValueDynamic = !!dynamicValue;
|
|
2296
|
-
const options10 = useFilteredOptions(
|
|
2342
|
+
const options10 = useFilteredOptions(searchValue);
|
|
2297
2343
|
const handleSearch = (event) => {
|
|
2298
2344
|
setSearchValue(event.target.value);
|
|
2299
2345
|
};
|
|
@@ -2340,8 +2386,8 @@ var DynamicSelection = ({ onSelect }) => {
|
|
|
2340
2386
|
__41("Clear the filters", "elementor")
|
|
2341
2387
|
), "\xA0", __41("and try again.", "elementor")))));
|
|
2342
2388
|
};
|
|
2343
|
-
var useFilteredOptions = (
|
|
2344
|
-
const dynamicTags = usePropDynamicTags(
|
|
2389
|
+
var useFilteredOptions = (searchValue) => {
|
|
2390
|
+
const dynamicTags = usePropDynamicTags();
|
|
2345
2391
|
const options10 = dynamicTags.reduce((categories, { name, label, group }) => {
|
|
2346
2392
|
const isVisible = label.toLowerCase().includes(searchValue.trim().toLowerCase());
|
|
2347
2393
|
if (!isVisible) {
|
|
@@ -2359,13 +2405,13 @@ var useFilteredOptions = (bind, searchValue) => {
|
|
|
2359
2405
|
// src/dynamics/components/dynamic-selection-control.tsx
|
|
2360
2406
|
var SIZE4 = "tiny";
|
|
2361
2407
|
var DynamicSelectionControl = () => {
|
|
2362
|
-
const { setValue: setAnyValue } =
|
|
2363
|
-
const { bind, value } =
|
|
2408
|
+
const { setValue: setAnyValue } = useBoundProp4();
|
|
2409
|
+
const { bind, value } = useBoundProp4(dynamicPropTypeUtil);
|
|
2364
2410
|
const [propValueFromHistory] = usePersistDynamicValue(bind);
|
|
2365
2411
|
const { name: tagName = "" } = value;
|
|
2366
|
-
const selectionPopoverId =
|
|
2412
|
+
const selectionPopoverId = useId5();
|
|
2367
2413
|
const selectionPopoverState = usePopupState3({ variant: "popover", popupId: selectionPopoverId });
|
|
2368
|
-
const dynamicTag = useDynamicTag(
|
|
2414
|
+
const dynamicTag = useDynamicTag(tagName);
|
|
2369
2415
|
const removeDynamicTag = () => {
|
|
2370
2416
|
setAnyValue(propValueFromHistory ?? null);
|
|
2371
2417
|
};
|
|
@@ -2402,7 +2448,7 @@ var DynamicSelectionControl = () => {
|
|
|
2402
2448
|
));
|
|
2403
2449
|
};
|
|
2404
2450
|
var DynamicSettingsPopover = ({ dynamicTag }) => {
|
|
2405
|
-
const popupId =
|
|
2451
|
+
const popupId = useId5();
|
|
2406
2452
|
const settingsPopupState = usePopupState3({ variant: "popover", popupId });
|
|
2407
2453
|
const hasDynamicSettings = !!dynamicTag.atomic_controls.length;
|
|
2408
2454
|
if (!hasDynamicSettings) {
|
|
@@ -2450,13 +2496,11 @@ var Control3 = ({ control }) => {
|
|
|
2450
2496
|
|
|
2451
2497
|
// src/dynamics/hooks/use-prop-dynamic-action.tsx
|
|
2452
2498
|
import * as React65 from "react";
|
|
2453
|
-
import { useBoundProp as
|
|
2499
|
+
import { useBoundProp as useBoundProp5 } from "@elementor/editor-controls";
|
|
2454
2500
|
import { DatabaseIcon as DatabaseIcon2 } from "@elementor/icons";
|
|
2455
2501
|
import { __ as __43 } from "@wordpress/i18n";
|
|
2456
2502
|
var usePropDynamicAction = () => {
|
|
2457
|
-
const {
|
|
2458
|
-
const { elementType } = useElement();
|
|
2459
|
-
const propType = elementType.propsSchema[bind];
|
|
2503
|
+
const { propType } = useBoundProp5();
|
|
2460
2504
|
const visible = !!propType && supportsDynamic(propType);
|
|
2461
2505
|
return {
|
|
2462
2506
|
visible,
|
|
@@ -2503,6 +2547,6 @@ export {
|
|
|
2503
2547
|
registerGlobalClassMenuItem,
|
|
2504
2548
|
registerStateMenuItem,
|
|
2505
2549
|
replaceControl,
|
|
2506
|
-
|
|
2550
|
+
useBoundProp6 as useBoundProp
|
|
2507
2551
|
};
|
|
2508
2552
|
//# sourceMappingURL=index.mjs.map
|