@elementor/editor-global-classes 0.20.5 → 0.21.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/dist/index.js CHANGED
@@ -36,18 +36,18 @@ module.exports = __toCommonJS(index_exports);
36
36
 
37
37
  // src/init.ts
38
38
  var import_editor = require("@elementor/editor");
39
- var import_editor_editing_panel = require("@elementor/editor-editing-panel");
39
+ var import_editor_editing_panel3 = require("@elementor/editor-editing-panel");
40
40
  var import_editor_panels2 = require("@elementor/editor-panels");
41
41
  var import_editor_styles_repository4 = require("@elementor/editor-styles-repository");
42
- var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
43
- var import_store20 = require("@elementor/store");
42
+ var import_editor_v1_adapters7 = require("@elementor/editor-v1-adapters");
43
+ var import_store22 = require("@elementor/store");
44
44
 
45
45
  // src/components/class-manager/class-manager-button.tsx
46
- var React8 = __toESM(require("react"));
46
+ var React11 = __toESM(require("react"));
47
47
  var import_editor_documents3 = require("@elementor/editor-documents");
48
48
  var import_editor_styles_repository3 = require("@elementor/editor-styles-repository");
49
- var import_ui7 = require("@elementor/ui");
50
- var import_i18n6 = require("@wordpress/i18n");
49
+ var import_ui10 = require("@elementor/ui");
50
+ var import_i18n9 = require("@wordpress/i18n");
51
51
 
52
52
  // src/global-classes-styles-provider.ts
53
53
  var import_editor_styles2 = require("@elementor/editor-styles");
@@ -87,6 +87,69 @@ var GlobalClassLabelAlreadyExistsError = (0, import_utils.createError)({
87
87
  var import_editor_props = require("@elementor/editor-props");
88
88
  var import_editor_styles = require("@elementor/editor-styles");
89
89
  var import_store = require("@elementor/store");
90
+
91
+ // src/utils/snapshot-history.ts
92
+ function createLink({ value, next, prev }) {
93
+ return {
94
+ value,
95
+ prev: prev || null,
96
+ next: next || null
97
+ };
98
+ }
99
+ var SnapshotHistory = class _SnapshotHistory {
100
+ constructor(namespace) {
101
+ this.namespace = namespace;
102
+ }
103
+ static registry = {};
104
+ static get(namespace) {
105
+ if (!_SnapshotHistory.registry[namespace]) {
106
+ _SnapshotHistory.registry[namespace] = new _SnapshotHistory(namespace);
107
+ }
108
+ return _SnapshotHistory.registry[namespace];
109
+ }
110
+ first = null;
111
+ current = null;
112
+ transform(item) {
113
+ return JSON.parse(JSON.stringify(item));
114
+ }
115
+ reset() {
116
+ this.first = this.current = null;
117
+ }
118
+ prev() {
119
+ if (!this.current || this.current === this.first) {
120
+ return null;
121
+ }
122
+ this.current = this.current.prev;
123
+ return this.current?.value || null;
124
+ }
125
+ isLast() {
126
+ return !this.current || !this.current.next;
127
+ }
128
+ next(value) {
129
+ if (value) {
130
+ if (!this.current) {
131
+ this.first = createLink({ value: this.transform(value) });
132
+ this.current = this.first;
133
+ return this.current.value;
134
+ }
135
+ const nextLink = createLink({
136
+ value: this.transform(value),
137
+ prev: this.current
138
+ });
139
+ this.current.next = nextLink;
140
+ this.current = nextLink;
141
+ return this.current.value;
142
+ }
143
+ if (!this.current || !this.current.next) {
144
+ return null;
145
+ }
146
+ this.current = this.current.next;
147
+ return this.current.value;
148
+ }
149
+ };
150
+
151
+ // src/store.ts
152
+ var localHistory = SnapshotHistory.get("global-classes");
90
153
  var initialState = {
91
154
  data: { items: {}, order: [] },
92
155
  initialData: {
@@ -109,11 +172,13 @@ var slice = (0, import_store.__createSlice)({
109
172
  state.isDirty = false;
110
173
  },
111
174
  add(state, { payload }) {
175
+ localHistory.next(state.data);
112
176
  state.data.items[payload.id] = payload;
113
177
  state.data.order.unshift(payload.id);
114
178
  state.isDirty = true;
115
179
  },
116
180
  delete(state, { payload }) {
181
+ localHistory.next(state.data);
117
182
  state.data.items = Object.fromEntries(
118
183
  Object.entries(state.data.items).filter(([id2]) => id2 !== payload)
119
184
  );
@@ -121,10 +186,12 @@ var slice = (0, import_store.__createSlice)({
121
186
  state.isDirty = true;
122
187
  },
123
188
  setOrder(state, { payload }) {
189
+ localHistory.next(state.data);
124
190
  state.data.order = payload;
125
191
  state.isDirty = true;
126
192
  },
127
193
  update(state, { payload }) {
194
+ localHistory.next(state.data);
128
195
  const style = state.data.items[payload.style.id];
129
196
  const mergedData = {
130
197
  ...style,
@@ -140,6 +207,7 @@ var slice = (0, import_store.__createSlice)({
140
207
  if (!style) {
141
208
  throw new GlobalClassNotFoundError({ context: { styleId: payload.id } });
142
209
  }
210
+ localHistory.next(state.data);
143
211
  const variant = (0, import_editor_styles.getVariantByMeta)(style, payload.meta);
144
212
  if (variant) {
145
213
  variant.props = (0, import_editor_props.mergeProps)(variant.props, payload.props);
@@ -153,10 +221,38 @@ var slice = (0, import_store.__createSlice)({
153
221
  },
154
222
  reset(state, { payload: { context: context2 } }) {
155
223
  if (context2 === "frontend") {
224
+ localHistory.reset();
156
225
  state.initialData.frontend = state.data;
157
226
  state.isDirty = false;
158
227
  }
159
228
  state.initialData.preview = state.data;
229
+ },
230
+ undo(state) {
231
+ if (localHistory.isLast()) {
232
+ localHistory.next(state.data);
233
+ }
234
+ const data = localHistory.prev();
235
+ if (data) {
236
+ state.data = data;
237
+ state.isDirty = true;
238
+ } else {
239
+ state.data = state.initialData.preview;
240
+ }
241
+ },
242
+ resetToInitialState(state, { payload: { context: context2 } }) {
243
+ localHistory.reset();
244
+ state.data = state.initialData[context2];
245
+ state.isDirty = false;
246
+ },
247
+ redo(state) {
248
+ const data = localHistory.next();
249
+ if (localHistory.isLast()) {
250
+ localHistory.prev();
251
+ }
252
+ if (data) {
253
+ state.data = data;
254
+ state.isDirty = true;
255
+ }
160
256
  }
161
257
  }
162
258
  });
@@ -175,8 +271,9 @@ var selectClass = (state, id2) => state[SLICE_NAME].data.items[id2] ?? null;
175
271
 
176
272
  // src/global-classes-styles-provider.ts
177
273
  var MAX_CLASSES = 50;
274
+ var GLOBAL_CLASSES_PROVIDER_KEY = "global-classes";
178
275
  var globalClassesStylesProvider = (0, import_editor_styles_repository.createStylesProvider)({
179
- key: "global-classes",
276
+ key: GLOBAL_CLASSES_PROVIDER_KEY,
180
277
  priority: 30,
181
278
  limit: MAX_CLASSES,
182
279
  labels: {
@@ -235,16 +332,19 @@ var globalClassesStylesProvider = (0, import_editor_styles_repository.createStyl
235
332
  });
236
333
 
237
334
  // src/components/class-manager/class-manager-panel.tsx
238
- var React7 = __toESM(require("react"));
239
- var import_react5 = require("react");
335
+ var import_react6 = require("react");
336
+ var React10 = __toESM(require("react"));
240
337
  var import_editor_documents2 = require("@elementor/editor-documents");
338
+ var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
241
339
  var import_editor_panels = require("@elementor/editor-panels");
242
340
  var import_editor_ui3 = require("@elementor/editor-ui");
243
- var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
244
- var import_icons6 = require("@elementor/icons");
341
+ var import_editor_v1_adapters5 = require("@elementor/editor-v1-adapters");
342
+ var import_icons7 = require("@elementor/icons");
245
343
  var import_query = require("@elementor/query");
246
- var import_ui6 = require("@elementor/ui");
247
- var import_i18n5 = require("@wordpress/i18n");
344
+ var import_store16 = require("@elementor/store");
345
+ var import_ui9 = require("@elementor/ui");
346
+ var import_utils2 = require("@elementor/utils");
347
+ var import_i18n8 = require("@wordpress/i18n");
248
348
 
249
349
  // src/hooks/use-dirty-state.ts
250
350
  var import_store4 = require("@elementor/store");
@@ -360,6 +460,26 @@ var IntroductionContent = () => {
360
460
  )));
361
461
  };
362
462
 
463
+ // src/components/class-manager/class-manager-search.tsx
464
+ var React2 = __toESM(require("react"));
465
+ var import_icons = require("@elementor/icons");
466
+ var import_ui2 = require("@elementor/ui");
467
+ var import_i18n3 = require("@wordpress/i18n");
468
+ var ClassManagerSearch = ({ searchValue, onChange }) => /* @__PURE__ */ React2.createElement(import_ui2.Grid, { item: true, xs: 6, px: 2, pb: 1 }, /* @__PURE__ */ React2.createElement(import_ui2.Stack, { direction: "row", gap: 0.5, sx: { width: "100%" } }, /* @__PURE__ */ React2.createElement(import_ui2.Box, { sx: { flexGrow: 1 } }, /* @__PURE__ */ React2.createElement(
469
+ import_ui2.TextField,
470
+ {
471
+ role: "search",
472
+ fullWidth: true,
473
+ size: "tiny",
474
+ value: searchValue,
475
+ placeholder: (0, import_i18n3.__)("Search", "elementor"),
476
+ onChange: (e) => onChange(e.target.value),
477
+ InputProps: {
478
+ startAdornment: /* @__PURE__ */ React2.createElement(import_ui2.InputAdornment, { position: "start" }, /* @__PURE__ */ React2.createElement(import_icons.SearchIcon, { fontSize: "tiny" }))
479
+ }
480
+ }
481
+ ))));
482
+
363
483
  // src/components/class-manager/delete-class.ts
364
484
  var import_editor_documents = require("@elementor/editor-documents");
365
485
  var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
@@ -386,19 +506,16 @@ var reloadDocument = () => {
386
506
  };
387
507
 
388
508
  // src/components/class-manager/flipped-color-swatch-icon.tsx
389
- var React2 = __toESM(require("react"));
390
- var import_icons = require("@elementor/icons");
391
- var FlippedColorSwatchIcon = ({ sx, ...props }) => /* @__PURE__ */ React2.createElement(import_icons.ColorSwatchIcon, { sx: { transform: "rotate(90deg)", ...sx }, ...props });
509
+ var React3 = __toESM(require("react"));
510
+ var import_icons2 = require("@elementor/icons");
511
+ var FlippedColorSwatchIcon = ({ sx, ...props }) => /* @__PURE__ */ React3.createElement(import_icons2.ColorSwatchIcon, { sx: { transform: "rotate(90deg)", ...sx }, ...props });
392
512
 
393
513
  // src/components/class-manager/global-classes-list.tsx
394
- var React5 = __toESM(require("react"));
395
- var import_react3 = require("react");
396
- var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
397
- var import_editor_ui2 = require("@elementor/editor-ui");
398
- var import_icons4 = require("@elementor/icons");
514
+ var React8 = __toESM(require("react"));
515
+ var import_react4 = require("react");
399
516
  var import_store14 = require("@elementor/store");
400
- var import_ui4 = require("@elementor/ui");
401
- var import_i18n4 = require("@wordpress/i18n");
517
+ var import_ui7 = require("@elementor/ui");
518
+ var import_i18n7 = require("@wordpress/i18n");
402
519
 
403
520
  // src/hooks/use-classes-order.ts
404
521
  var import_store10 = require("@elementor/store");
@@ -412,12 +529,23 @@ var useOrderedClasses = () => {
412
529
  return (0, import_store12.__useSelector)(selectOrderedClasses);
413
530
  };
414
531
 
532
+ // src/components/class-manager/class-item.tsx
533
+ var React6 = __toESM(require("react"));
534
+ var import_react3 = require("react");
535
+ var import_editor_editing_panel = require("@elementor/editor-editing-panel");
536
+ var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
537
+ var import_editor_ui2 = require("@elementor/editor-ui");
538
+ var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
539
+ var import_icons5 = require("@elementor/icons");
540
+ var import_ui5 = require("@elementor/ui");
541
+ var import_i18n5 = require("@wordpress/i18n");
542
+
415
543
  // src/components/class-manager/delete-confirmation-dialog.tsx
416
- var React3 = __toESM(require("react"));
544
+ var React4 = __toESM(require("react"));
417
545
  var import_react2 = require("react");
418
- var import_icons2 = require("@elementor/icons");
419
- var import_ui2 = require("@elementor/ui");
420
- var import_i18n3 = require("@wordpress/i18n");
546
+ var import_icons3 = require("@elementor/icons");
547
+ var import_ui3 = require("@elementor/ui");
548
+ var import_i18n4 = require("@wordpress/i18n");
421
549
  var context = (0, import_react2.createContext)(null);
422
550
  var DeleteConfirmationProvider = ({ children }) => {
423
551
  const [dialogProps, setDialogProps] = (0, import_react2.useState)(null);
@@ -427,7 +555,7 @@ var DeleteConfirmationProvider = ({ children }) => {
427
555
  const closeDialog = () => {
428
556
  setDialogProps(null);
429
557
  };
430
- return /* @__PURE__ */ React3.createElement(context.Provider, { value: { openDialog, closeDialog, dialogProps } }, children, !!dialogProps && /* @__PURE__ */ React3.createElement(DeleteConfirmationDialog, { ...dialogProps }));
558
+ return /* @__PURE__ */ React4.createElement(context.Provider, { value: { openDialog, closeDialog, dialogProps } }, children, !!dialogProps && /* @__PURE__ */ React4.createElement(DeleteConfirmationDialog, { ...dialogProps }));
431
559
  };
432
560
  var TITLE_ID = "delete-class-dialog";
433
561
  var DeleteConfirmationDialog = ({ label, id: id2 }) => {
@@ -436,10 +564,10 @@ var DeleteConfirmationDialog = ({ label, id: id2 }) => {
436
564
  deleteClass(id2);
437
565
  closeDialog();
438
566
  };
439
- return /* @__PURE__ */ React3.createElement(import_ui2.Dialog, { open: true, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React3.createElement(import_ui2.DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React3.createElement(import_icons2.AlertOctagonFilledIcon, { color: "error" }), (0, import_i18n3.__)("Delete this class?", "elementor")), /* @__PURE__ */ React3.createElement(import_ui2.DialogContent, null, /* @__PURE__ */ React3.createElement(import_ui2.DialogContentText, { variant: "body2", color: "textPrimary" }, (0, import_i18n3.__)("Deleting", "elementor"), /* @__PURE__ */ React3.createElement(import_ui2.Typography, { variant: "subtitle2", component: "span" }, "\xA0", label, "\xA0"), (0, import_i18n3.__)(
567
+ return /* @__PURE__ */ React4.createElement(import_ui3.Dialog, { open: true, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React4.createElement(import_ui3.DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React4.createElement(import_icons3.AlertOctagonFilledIcon, { color: "error" }), (0, import_i18n4.__)("Delete this class?", "elementor")), /* @__PURE__ */ React4.createElement(import_ui3.DialogContent, null, /* @__PURE__ */ React4.createElement(import_ui3.DialogContentText, { variant: "body2", color: "textPrimary" }, (0, import_i18n4.__)("Deleting", "elementor"), /* @__PURE__ */ React4.createElement(import_ui3.Typography, { variant: "subtitle2", component: "span" }, "\xA0", label, "\xA0"), (0, import_i18n4.__)(
440
568
  "will permanently remove it from your project and may affect the design across all elements using it. This action cannot be undone.",
441
569
  "elementor"
442
- ))), /* @__PURE__ */ React3.createElement(import_ui2.DialogActions, null, /* @__PURE__ */ React3.createElement(import_ui2.Button, { color: "secondary", onClick: closeDialog }, (0, import_i18n3.__)("Not now", "elementor")), /* @__PURE__ */ React3.createElement(import_ui2.Button, { variant: "contained", color: "error", onClick: onConfirm }, (0, import_i18n3.__)("Delete", "elementor"))));
570
+ ))), /* @__PURE__ */ React4.createElement(import_ui3.DialogActions, null, /* @__PURE__ */ React4.createElement(import_ui3.Button, { color: "secondary", onClick: closeDialog }, (0, import_i18n4.__)("Not now", "elementor")), /* @__PURE__ */ React4.createElement(import_ui3.Button, { variant: "contained", color: "error", onClick: onConfirm }, (0, import_i18n4.__)("Delete", "elementor"))));
443
571
  };
444
572
  var useDeleteConfirmation = () => {
445
573
  const contextValue = (0, import_react2.useContext)(context);
@@ -450,14 +578,14 @@ var useDeleteConfirmation = () => {
450
578
  };
451
579
 
452
580
  // src/components/class-manager/sortable.tsx
453
- var React4 = __toESM(require("react"));
454
- var import_icons3 = require("@elementor/icons");
455
- var import_ui3 = require("@elementor/ui");
456
- var SortableProvider = (props) => /* @__PURE__ */ React4.createElement(import_ui3.UnstableSortableProvider, { restrictAxis: true, variant: "static", dragPlaceholderStyle: { opacity: "1" }, ...props });
457
- var SortableTrigger = (props) => /* @__PURE__ */ React4.createElement(StyledSortableTrigger, { ...props, role: "button", className: "class-item-sortable-trigger" }, /* @__PURE__ */ React4.createElement(import_icons3.GripVerticalIcon, { fontSize: "tiny" }));
581
+ var React5 = __toESM(require("react"));
582
+ var import_icons4 = require("@elementor/icons");
583
+ var import_ui4 = require("@elementor/ui");
584
+ var SortableProvider = (props) => /* @__PURE__ */ React5.createElement(import_ui4.UnstableSortableProvider, { restrictAxis: true, variant: "static", dragPlaceholderStyle: { opacity: "1" }, ...props });
585
+ var SortableTrigger = (props) => /* @__PURE__ */ React5.createElement(StyledSortableTrigger, { ...props, role: "button", className: "class-item-sortable-trigger" }, /* @__PURE__ */ React5.createElement(import_icons4.GripVerticalIcon, { fontSize: "tiny" }));
458
586
  var SortableItem = ({ children, id: id2, ...props }) => {
459
- return /* @__PURE__ */ React4.createElement(
460
- import_ui3.UnstableSortableItem,
587
+ return /* @__PURE__ */ React5.createElement(
588
+ import_ui4.UnstableSortableItem,
461
589
  {
462
590
  ...props,
463
591
  id: id2,
@@ -472,8 +600,8 @@ var SortableItem = ({ children, id: id2, ...props }) => {
472
600
  isDragOverlay,
473
601
  isDragPlaceholder
474
602
  }) => {
475
- return /* @__PURE__ */ React4.createElement(
476
- import_ui3.Box,
603
+ return /* @__PURE__ */ React5.createElement(
604
+ import_ui4.Box,
477
605
  {
478
606
  ...itemProps,
479
607
  style: itemStyle,
@@ -491,66 +619,36 @@ var SortableItem = ({ children, id: id2, ...props }) => {
491
619
  triggerStyle,
492
620
  isDragPlaceholder
493
621
  }),
494
- showDropIndication && /* @__PURE__ */ React4.createElement(SortableItemIndicator, { style: dropIndicationStyle })
622
+ showDropIndication && /* @__PURE__ */ React5.createElement(SortableItemIndicator, { style: dropIndicationStyle })
495
623
  );
496
624
  }
497
625
  }
498
626
  );
499
627
  };
500
- var StyledSortableTrigger = (0, import_ui3.styled)("div")(({ theme }) => ({
628
+ var StyledSortableTrigger = (0, import_ui4.styled)("div")(({ theme }) => ({
501
629
  position: "absolute",
502
630
  left: 0,
503
631
  top: "50%",
504
632
  transform: `translate( -${theme.spacing(1.5)}, -50% )`,
505
633
  color: theme.palette.action.active
506
634
  }));
507
- var SortableItemIndicator = (0, import_ui3.styled)(import_ui3.Box)`
635
+ var SortableItemIndicator = (0, import_ui4.styled)(import_ui4.Box)`
508
636
  width: 100%;
509
637
  height: 1px;
510
638
  background-color: ${({ theme }) => theme.palette.text.primary};
511
639
  `;
512
640
 
513
- // src/components/class-manager/global-classes-list.tsx
514
- var GlobalClassesList = ({ disabled }) => {
515
- const cssClasses = useOrderedClasses();
516
- const dispatch4 = (0, import_store14.__useDispatch)();
517
- const [classesOrder, reorderClasses] = useReorder();
518
- if (!cssClasses?.length) {
519
- return /* @__PURE__ */ React5.createElement(EmptyState, null);
520
- }
521
- return /* @__PURE__ */ React5.createElement(DeleteConfirmationProvider, null, /* @__PURE__ */ React5.createElement(import_ui4.List, { sx: { display: "flex", flexDirection: "column", gap: 0.5 } }, /* @__PURE__ */ React5.createElement(SortableProvider, { value: classesOrder, onChange: reorderClasses }, cssClasses?.map(({ id: id2, label }) => {
522
- const renameClass = (newLabel) => {
523
- dispatch4(
524
- slice.actions.update({
525
- style: {
526
- id: id2,
527
- label: newLabel
528
- }
529
- })
530
- );
531
- };
532
- return /* @__PURE__ */ React5.createElement(SortableItem, { key: id2, id: id2 }, ({ isDragged, isDragPlaceholder, triggerProps, triggerStyle }) => /* @__PURE__ */ React5.createElement(
533
- ClassItem,
534
- {
535
- id: id2,
536
- label,
537
- renameClass,
538
- selected: isDragged,
539
- disabled: disabled || isDragPlaceholder,
540
- sortableTriggerProps: { ...triggerProps, style: triggerStyle }
541
- }
542
- ));
543
- }))));
544
- };
545
- var useReorder = () => {
546
- const dispatch4 = (0, import_store14.__useDispatch)();
547
- const order = useClassesOrder();
548
- const reorder = (newIds) => {
549
- dispatch4(slice.actions.setOrder(newIds));
550
- };
551
- return [order, reorder];
552
- };
553
- var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTriggerProps }) => {
641
+ // src/components/class-manager/class-item.tsx
642
+ var isVersion311IsActive = (0, import_editor_v1_adapters4.isExperimentActive)(import_editor_editing_panel.EXPERIMENTAL_FEATURES.V_3_31);
643
+ var ClassItem = ({
644
+ id: id2,
645
+ label,
646
+ renameClass,
647
+ selected,
648
+ disabled,
649
+ sortableTriggerProps,
650
+ isSearchActive
651
+ }) => {
554
652
  const itemRef = (0, import_react3.useRef)(null);
555
653
  const {
556
654
  ref: editableRef,
@@ -564,12 +662,12 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
564
662
  validation: validateLabel
565
663
  });
566
664
  const { openDialog } = useDeleteConfirmation();
567
- const popupState = (0, import_ui4.usePopupState)({
665
+ const popupState = (0, import_ui5.usePopupState)({
568
666
  variant: "popover",
569
667
  disableAutoFocus: true
570
668
  });
571
669
  const isSelected = (selected || popupState.isOpen) && !disabled;
572
- return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(import_ui4.Stack, { p: 0 }, /* @__PURE__ */ React5.createElement(
670
+ return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(import_ui5.Stack, { p: 0 }, /* @__PURE__ */ React6.createElement(
573
671
  import_editor_ui2.WarningInfotip,
574
672
  {
575
673
  open: Boolean(error),
@@ -578,12 +676,13 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
578
676
  width: itemRef.current?.getBoundingClientRect().width,
579
677
  offset: [0, -15]
580
678
  },
581
- /* @__PURE__ */ React5.createElement(
679
+ /* @__PURE__ */ React6.createElement(
582
680
  StyledListItemButton,
583
681
  {
584
682
  ref: itemRef,
585
683
  dense: true,
586
684
  disableGutters: true,
685
+ showSortIndicator: isSearchActive,
587
686
  showActions: isSelected || isEditing,
588
687
  shape: "rounded",
589
688
  onDoubleClick: openEditMode,
@@ -591,30 +690,30 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
591
690
  disabled,
592
691
  focusVisibleClassName: "visible-class-item"
593
692
  },
594
- /* @__PURE__ */ React5.createElement(SortableTrigger, { ...sortableTriggerProps }),
595
- /* @__PURE__ */ React5.createElement(Indicator, { isActive: isEditing, isError: !!error }, isEditing ? /* @__PURE__ */ React5.createElement(
693
+ /* @__PURE__ */ React6.createElement(SortableTrigger, { ...sortableTriggerProps }),
694
+ /* @__PURE__ */ React6.createElement(Indicator, { isActive: isEditing, isError: !!error }, isEditing ? /* @__PURE__ */ React6.createElement(
596
695
  import_editor_ui2.EditableField,
597
696
  {
598
697
  ref: editableRef,
599
- as: import_ui4.Typography,
698
+ as: import_ui5.Typography,
600
699
  variant: "caption",
601
700
  ...getEditableProps()
602
701
  }
603
- ) : /* @__PURE__ */ React5.createElement(import_editor_ui2.EllipsisWithTooltip, { title: label, as: import_ui4.Typography, variant: "caption" })),
604
- /* @__PURE__ */ React5.createElement(
605
- import_ui4.Tooltip,
702
+ ) : /* @__PURE__ */ React6.createElement(import_editor_ui2.EllipsisWithTooltip, { title: label, as: import_ui5.Typography, variant: "caption" })),
703
+ /* @__PURE__ */ React6.createElement(
704
+ import_ui5.Tooltip,
606
705
  {
607
706
  placement: "top",
608
707
  className: "class-item-more-actions",
609
- title: (0, import_i18n4.__)("More actions", "elementor")
708
+ title: (0, import_i18n5.__)("More actions", "elementor")
610
709
  },
611
- /* @__PURE__ */ React5.createElement(import_ui4.IconButton, { size: "tiny", ...(0, import_ui4.bindTrigger)(popupState), "aria-label": "More actions" }, /* @__PURE__ */ React5.createElement(import_icons4.DotsVerticalIcon, { fontSize: "tiny" }))
710
+ /* @__PURE__ */ React6.createElement(import_ui5.IconButton, { size: "tiny", ...(0, import_ui5.bindTrigger)(popupState), "aria-label": "More actions" }, /* @__PURE__ */ React6.createElement(import_icons5.DotsVerticalIcon, { fontSize: "tiny" }))
612
711
  )
613
712
  )
614
- )), /* @__PURE__ */ React5.createElement(
615
- import_ui4.Menu,
713
+ )), /* @__PURE__ */ React6.createElement(
714
+ import_ui5.Menu,
616
715
  {
617
- ...(0, import_ui4.bindMenu)(popupState),
716
+ ...(0, import_ui5.bindMenu)(popupState),
618
717
  anchorOrigin: {
619
718
  vertical: "bottom",
620
719
  horizontal: "right"
@@ -624,7 +723,7 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
624
723
  horizontal: "right"
625
724
  }
626
725
  },
627
- /* @__PURE__ */ React5.createElement(
726
+ /* @__PURE__ */ React6.createElement(
628
727
  import_editor_ui2.MenuListItem,
629
728
  {
630
729
  sx: { minWidth: "160px" },
@@ -633,9 +732,9 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
633
732
  openEditMode();
634
733
  }
635
734
  },
636
- /* @__PURE__ */ React5.createElement(import_ui4.Typography, { variant: "caption", sx: { color: "text.primary" } }, (0, import_i18n4.__)("Rename", "elementor"))
735
+ /* @__PURE__ */ React6.createElement(import_ui5.Typography, { variant: "caption", sx: { color: "text.primary" } }, (0, import_i18n5.__)("Rename", "elementor"))
637
736
  ),
638
- /* @__PURE__ */ React5.createElement(
737
+ /* @__PURE__ */ React6.createElement(
639
738
  import_editor_ui2.MenuListItem,
640
739
  {
641
740
  onClick: () => {
@@ -643,28 +742,43 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
643
742
  openDialog({ id: id2, label });
644
743
  }
645
744
  },
646
- /* @__PURE__ */ React5.createElement(import_ui4.Typography, { variant: "caption", sx: { color: "error.light" } }, (0, import_i18n4.__)("Delete", "elementor"))
745
+ /* @__PURE__ */ React6.createElement(import_ui5.Typography, { variant: "caption", sx: { color: "error.light" } }, (0, import_i18n5.__)("Delete", "elementor"))
647
746
  )
648
747
  ));
649
748
  };
650
- var StyledListItemButton = (0, import_ui4.styled)(import_ui4.ListItemButton, {
651
- shouldForwardProp: (prop) => !["showActions"].includes(prop)
749
+ var StyledListItemButtonV2 = (0, import_ui5.styled)(import_ui5.ListItemButton, {
750
+ shouldForwardProp: (prop) => !["showActions", "showSortIndicator"].includes(prop)
652
751
  })(
653
- ({ showActions }) => `
752
+ ({ showActions, showSortIndicator }) => `
654
753
  min-height: 36px;
655
754
 
656
755
  &.visible-class-item {
657
756
  box-shadow: none !important;
658
757
  }
659
-
758
+ .class-item-sortable-trigger {
759
+ visibility: ${showSortIndicator && showActions ? "visible" : "hidden"};
760
+ }
761
+ &:hover&:not(:disabled) {
762
+ .class-item-sortable-trigger {
763
+ visibility: ${showSortIndicator ? "visible" : "hidden"};
764
+ }
765
+ }
766
+ `
767
+ );
768
+ var StyledListItemButtonV1 = (0, import_ui5.styled)(import_ui5.ListItemButton, {
769
+ shouldForwardProp: (prop) => !["showActions", "showSortIndicator"].includes(prop)
770
+ })(
771
+ ({ showActions }) => `
772
+ min-height: 36px;
773
+ &.visible-class-item {
774
+ box-shadow: none !important;
775
+ }
660
776
  .class-item-more-actions, .class-item-sortable-trigger {
661
777
  visibility: ${showActions ? "visible" : "hidden"};
662
778
  }
663
-
664
779
  .class-item-sortable-trigger {
665
780
  visibility: ${showActions ? "visible" : "hidden"};
666
781
  }
667
-
668
782
  &:hover&:not(:disabled) {
669
783
  .class-item-more-actions, .class-item-sortable-trigger {
670
784
  visibility: visible;
@@ -672,16 +786,8 @@ var StyledListItemButton = (0, import_ui4.styled)(import_ui4.ListItemButton, {
672
786
  }
673
787
  `
674
788
  );
675
- var EmptyState = () => /* @__PURE__ */ React5.createElement(import_ui4.Stack, { alignItems: "center", gap: 1.5, pt: 10, px: 0.5, maxWidth: "260px", margin: "auto" }, /* @__PURE__ */ React5.createElement(FlippedColorSwatchIcon, { fontSize: "large" }), /* @__PURE__ */ React5.createElement(StyledHeader, { variant: "subtitle2", component: "h2", color: "text.secondary" }, (0, import_i18n4.__)("There are no global classes yet.", "elementor")), /* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "center", variant: "caption", color: "text.secondary" }, (0, import_i18n4.__)(
676
- "CSS classes created in the editor panel will appear here. Once they are available, you can arrange their hierarchy, rename them, or delete them as needed.",
677
- "elementor"
678
- )));
679
- var StyledHeader = (0, import_ui4.styled)(import_ui4.Typography)(({ theme, variant }) => ({
680
- "&.MuiTypography-root": {
681
- ...theme.typography[variant]
682
- }
683
- }));
684
- var Indicator = (0, import_ui4.styled)(import_ui4.Box, {
789
+ var StyledListItemButton = isVersion311IsActive ? StyledListItemButtonV2 : StyledListItemButtonV1;
790
+ var Indicator = (0, import_ui5.styled)(import_ui5.Box, {
685
791
  shouldForwardProp: (prop) => !["isActive", "isError"].includes(prop)
686
792
  })(({ theme, isActive, isError }) => ({
687
793
  display: "flex",
@@ -710,6 +816,129 @@ var validateLabel = (newLabel) => {
710
816
  return result.errorMessage;
711
817
  };
712
818
 
819
+ // src/components/class-manager/class-manager-class-not-found.tsx
820
+ var React7 = __toESM(require("react"));
821
+ var import_ui6 = require("@elementor/ui");
822
+ var import_i18n6 = require("@wordpress/i18n");
823
+ var CssClassNotFound = ({ onClear, searchValue }) => /* @__PURE__ */ React7.createElement(
824
+ import_ui6.Stack,
825
+ {
826
+ color: "text.secondary",
827
+ pt: 5,
828
+ alignItems: "center",
829
+ gap: 1,
830
+ overflow: "hidden",
831
+ maxWidth: "170px",
832
+ justifySelf: "center"
833
+ },
834
+ /* @__PURE__ */ React7.createElement(FlippedColorSwatchIcon, { color: "inherit", fontSize: "large" }),
835
+ /* @__PURE__ */ React7.createElement(import_ui6.Box, null, /* @__PURE__ */ React7.createElement(import_ui6.Typography, { align: "center", variant: "subtitle2", color: "inherit" }, (0, import_i18n6.__)("Sorry, nothing matched", "elementor")), /* @__PURE__ */ React7.createElement(
836
+ import_ui6.Typography,
837
+ {
838
+ variant: "subtitle2",
839
+ color: "inherit",
840
+ sx: {
841
+ display: "flex",
842
+ width: "100%",
843
+ justifyContent: "center"
844
+ }
845
+ },
846
+ /* @__PURE__ */ React7.createElement("span", null, "\u201C"),
847
+ /* @__PURE__ */ React7.createElement(
848
+ "span",
849
+ {
850
+ style: {
851
+ maxWidth: "80%",
852
+ overflow: "hidden",
853
+ textOverflow: "ellipsis"
854
+ }
855
+ },
856
+ searchValue
857
+ ),
858
+ /* @__PURE__ */ React7.createElement("span", null, "\u201D.")
859
+ )),
860
+ /* @__PURE__ */ React7.createElement(import_ui6.Typography, { align: "center", variant: "caption", color: "inherit" }, (0, import_i18n6.__)("Try something else.", "elementor"), /* @__PURE__ */ React7.createElement(import_ui6.Link, { color: "secondary", variant: "caption", component: "button", onClick: onClear }, (0, import_i18n6.__)("Clear & try again", "elementor")))
861
+ );
862
+
863
+ // src/components/class-manager/global-classes-list.tsx
864
+ var GlobalClassesList = ({ disabled, searchValue, onSearch }) => {
865
+ const cssClasses = useOrderedClasses();
866
+ const dispatch5 = (0, import_store14.__useDispatch)();
867
+ const [classesOrder, reorderClasses] = useReorder();
868
+ const lowercaseLabels = (0, import_react4.useMemo)(
869
+ () => cssClasses.map((cssClass) => ({
870
+ ...cssClass,
871
+ lowerLabel: cssClass.label.toLowerCase()
872
+ })),
873
+ [cssClasses]
874
+ );
875
+ const filteredClasses = (0, import_react4.useMemo)(() => {
876
+ return searchValue.length > 1 ? lowercaseLabels.filter(
877
+ (cssClass) => cssClass.lowerLabel.toLowerCase().includes(searchValue.toLowerCase())
878
+ ) : cssClasses;
879
+ }, [searchValue, cssClasses, lowercaseLabels]);
880
+ (0, import_react4.useEffect)(() => {
881
+ const handler = (event) => {
882
+ if (event.key === "z" && (event.ctrlKey || event.metaKey)) {
883
+ event.stopImmediatePropagation();
884
+ event.preventDefault();
885
+ if (event.shiftKey) {
886
+ dispatch5(slice.actions.redo());
887
+ return;
888
+ }
889
+ dispatch5(slice.actions.undo());
890
+ }
891
+ };
892
+ window.addEventListener("keydown", handler, {
893
+ capture: true
894
+ });
895
+ return () => window.removeEventListener("keydown", handler);
896
+ }, [dispatch5]);
897
+ if (!cssClasses?.length) {
898
+ return /* @__PURE__ */ React8.createElement(EmptyState, null);
899
+ }
900
+ return /* @__PURE__ */ React8.createElement(DeleteConfirmationProvider, null, filteredClasses.length <= 0 && searchValue.length > 1 ? /* @__PURE__ */ React8.createElement(CssClassNotFound, { onClear: () => onSearch(""), searchValue }) : /* @__PURE__ */ React8.createElement(import_ui7.List, { sx: { display: "flex", flexDirection: "column", gap: 0.5 } }, /* @__PURE__ */ React8.createElement(SortableProvider, { value: classesOrder, onChange: reorderClasses }, filteredClasses?.map(({ id: id2, label }) => {
901
+ return /* @__PURE__ */ React8.createElement(SortableItem, { key: id2, id: id2 }, ({ isDragged, isDragPlaceholder, triggerProps, triggerStyle }) => /* @__PURE__ */ React8.createElement(
902
+ ClassItem,
903
+ {
904
+ isSearchActive: searchValue.length < 2,
905
+ id: id2,
906
+ label,
907
+ renameClass: (newLabel) => {
908
+ dispatch5(
909
+ slice.actions.update({
910
+ style: {
911
+ id: id2,
912
+ label: newLabel
913
+ }
914
+ })
915
+ );
916
+ },
917
+ selected: isDragged,
918
+ disabled: disabled || isDragPlaceholder,
919
+ sortableTriggerProps: { ...triggerProps, style: triggerStyle }
920
+ }
921
+ ));
922
+ }))));
923
+ };
924
+ var EmptyState = () => /* @__PURE__ */ React8.createElement(import_ui7.Stack, { alignItems: "center", gap: 1.5, pt: 10, px: 0.5, maxWidth: "260px", margin: "auto" }, /* @__PURE__ */ React8.createElement(FlippedColorSwatchIcon, { fontSize: "large" }), /* @__PURE__ */ React8.createElement(StyledHeader, { variant: "subtitle2", component: "h2", color: "text.secondary" }, (0, import_i18n7.__)("There are no global classes yet.", "elementor")), /* @__PURE__ */ React8.createElement(import_ui7.Typography, { align: "center", variant: "caption", color: "text.secondary" }, (0, import_i18n7.__)(
925
+ "CSS classes created in the editor panel will appear here. Once they are available, you can arrange their hierarchy, rename them, or delete them as needed.",
926
+ "elementor"
927
+ )));
928
+ var StyledHeader = (0, import_ui7.styled)(import_ui7.Typography)(({ theme, variant }) => ({
929
+ "&.MuiTypography-root": {
930
+ ...theme.typography[variant]
931
+ }
932
+ }));
933
+ var useReorder = () => {
934
+ const dispatch5 = (0, import_store14.__useDispatch)();
935
+ const order = useClassesOrder();
936
+ const reorder = (newIds) => {
937
+ dispatch5(slice.actions.setOrder(newIds));
938
+ };
939
+ return [order, reorder];
940
+ };
941
+
713
942
  // src/components/class-manager/panel-interactions.ts
714
943
  function blockPanelInteractions() {
715
944
  const extendedWindow = window;
@@ -721,58 +950,67 @@ function unblockPanelInteractions() {
721
950
  }
722
951
 
723
952
  // src/components/class-manager/save-changes-dialog.tsx
724
- var React6 = __toESM(require("react"));
725
- var import_react4 = require("react");
726
- var import_icons5 = require("@elementor/icons");
727
- var import_ui5 = require("@elementor/ui");
953
+ var React9 = __toESM(require("react"));
954
+ var import_react5 = require("react");
955
+ var import_icons6 = require("@elementor/icons");
956
+ var import_ui8 = require("@elementor/ui");
728
957
  var TITLE_ID2 = "save-changes-dialog";
729
- var SaveChangesDialog = ({ children, onClose }) => /* @__PURE__ */ React6.createElement(import_ui5.Dialog, { open: true, onClose, "aria-labelledby": TITLE_ID2, maxWidth: "xs" }, children);
730
- var SaveChangesDialogTitle = ({ children }) => /* @__PURE__ */ React6.createElement(import_ui5.DialogTitle, { id: TITLE_ID2, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React6.createElement(import_icons5.AlertTriangleFilledIcon, { color: "secondary" }), children);
731
- var SaveChangesDialogContent = ({ children }) => /* @__PURE__ */ React6.createElement(import_ui5.DialogContent, null, children);
732
- var SaveChangesDialogContentText = (props) => /* @__PURE__ */ React6.createElement(import_ui5.DialogContentText, { variant: "body2", color: "textPrimary", display: "flex", flexDirection: "column", ...props });
958
+ var SaveChangesDialog = ({ children, onClose }) => /* @__PURE__ */ React9.createElement(import_ui8.Dialog, { open: true, onClose, "aria-labelledby": TITLE_ID2, maxWidth: "xs" }, children);
959
+ var SaveChangesDialogTitle = ({ children }) => /* @__PURE__ */ React9.createElement(import_ui8.DialogTitle, { id: TITLE_ID2, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React9.createElement(import_icons6.AlertTriangleFilledIcon, { color: "secondary" }), children);
960
+ var SaveChangesDialogContent = ({ children }) => /* @__PURE__ */ React9.createElement(import_ui8.DialogContent, null, children);
961
+ var SaveChangesDialogContentText = (props) => /* @__PURE__ */ React9.createElement(import_ui8.DialogContentText, { variant: "body2", color: "textPrimary", display: "flex", flexDirection: "column", ...props });
733
962
  var SaveChangesDialogActions = ({ actions }) => {
734
- const [isConfirming, setIsConfirming] = (0, import_react4.useState)(false);
735
- const { cancel, confirm } = actions;
963
+ const [isConfirming, setIsConfirming] = (0, import_react5.useState)(false);
964
+ const { cancel, confirm, discard } = actions;
736
965
  const onConfirm = async () => {
737
966
  setIsConfirming(true);
738
967
  await confirm.action();
739
968
  setIsConfirming(false);
740
969
  };
741
- return /* @__PURE__ */ React6.createElement(import_ui5.DialogActions, null, /* @__PURE__ */ React6.createElement(import_ui5.Button, { variant: "text", color: "secondary", onClick: cancel.action }, cancel.label), /* @__PURE__ */ React6.createElement(import_ui5.Button, { variant: "contained", color: "secondary", onClick: onConfirm, loading: isConfirming }, confirm.label));
970
+ return /* @__PURE__ */ React9.createElement(import_ui8.DialogActions, null, cancel && /* @__PURE__ */ React9.createElement(import_ui8.Button, { variant: "text", color: "secondary", onClick: cancel.action }, cancel.label), discard && /* @__PURE__ */ React9.createElement(import_ui8.Button, { variant: "text", color: "secondary", onClick: discard.action }, discard.label), /* @__PURE__ */ React9.createElement(import_ui8.Button, { variant: "contained", color: "secondary", onClick: onConfirm, loading: isConfirming }, confirm.label));
742
971
  };
743
972
  SaveChangesDialog.Title = SaveChangesDialogTitle;
744
973
  SaveChangesDialog.Content = SaveChangesDialogContent;
745
974
  SaveChangesDialog.ContentText = SaveChangesDialogContentText;
746
975
  SaveChangesDialog.Actions = SaveChangesDialogActions;
747
976
  var useDialog = () => {
748
- const [isOpen, setIsOpen] = (0, import_react4.useState)(false);
977
+ const [isOpen, setIsOpen] = (0, import_react5.useState)(false);
749
978
  const open = () => setIsOpen(true);
750
979
  const close = () => setIsOpen(false);
751
980
  return { isOpen, open, close };
752
981
  };
753
982
 
754
983
  // src/components/class-manager/class-manager-panel.tsx
984
+ var isVersion311IsActive2 = (0, import_editor_v1_adapters5.isExperimentActive)(import_editor_editing_panel2.EXPERIMENTAL_FEATURES.V_3_31);
755
985
  var id = "global-classes-manager";
756
986
  var { panel, usePanelActions } = (0, import_editor_panels.__createPanel)({
757
987
  id,
758
988
  component: ClassManagerPanel,
759
989
  allowedEditModes: ["edit", id],
760
990
  onOpen: () => {
761
- (0, import_editor_v1_adapters4.changeEditMode)(id);
991
+ (0, import_editor_v1_adapters5.changeEditMode)(id);
762
992
  blockPanelInteractions();
763
993
  },
764
994
  onClose: () => {
765
- (0, import_editor_v1_adapters4.changeEditMode)("edit");
995
+ (0, import_editor_v1_adapters5.changeEditMode)("edit");
766
996
  unblockPanelInteractions();
767
997
  }
768
998
  });
769
999
  function ClassManagerPanel() {
1000
+ const { debouncedValue, inputValue, handleChange } = (0, import_utils2.useDebounceState)({
1001
+ delay: 300,
1002
+ initialValue: ""
1003
+ });
770
1004
  const isDirty2 = useDirtyState();
771
1005
  const { close: closePanel } = usePanelActions();
772
1006
  const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
773
1007
  const { mutateAsync: publish, isPending: isPublishing } = usePublish();
1008
+ const resetAndClosePanel = () => {
1009
+ (0, import_store16.__dispatch)(slice.actions.resetToInitialState({ context: "frontend" }));
1010
+ closeSaveChangesDialog();
1011
+ };
774
1012
  usePreventUnload();
775
- return /* @__PURE__ */ React7.createElement(import_editor_ui3.ThemeProvider, null, /* @__PURE__ */ React7.createElement(import_ui6.ErrorBoundary, { fallback: /* @__PURE__ */ React7.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React7.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React7.createElement(import_editor_panels.PanelHeader, null, /* @__PURE__ */ React7.createElement(import_ui6.Stack, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React7.createElement(import_editor_panels.PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React7.createElement(FlippedColorSwatchIcon, { fontSize: "inherit" }), (0, import_i18n5.__)("Class Manager", "elementor")), /* @__PURE__ */ React7.createElement(
1013
+ return /* @__PURE__ */ React10.createElement(import_editor_ui3.ThemeProvider, null, /* @__PURE__ */ React10.createElement(import_ui9.ErrorBoundary, { fallback: /* @__PURE__ */ React10.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React10.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React10.createElement(import_editor_panels.PanelHeader, null, /* @__PURE__ */ React10.createElement(import_ui9.Stack, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React10.createElement(import_editor_panels.PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React10.createElement(FlippedColorSwatchIcon, { fontSize: "inherit" }), (0, import_i18n8.__)("Class Manager", "elementor")), /* @__PURE__ */ React10.createElement(
776
1014
  CloseButton,
777
1015
  {
778
1016
  sx: { marginLeft: "auto" },
@@ -785,8 +1023,43 @@ function ClassManagerPanel() {
785
1023
  closePanel();
786
1024
  }
787
1025
  }
788
- ))), /* @__PURE__ */ React7.createElement(import_editor_panels.PanelBody, { px: 2 }, /* @__PURE__ */ React7.createElement(GlobalClassesList, { disabled: isPublishing })), /* @__PURE__ */ React7.createElement(import_editor_panels.PanelFooter, null, /* @__PURE__ */ React7.createElement(
789
- import_ui6.Button,
1026
+ ))), /* @__PURE__ */ React10.createElement(
1027
+ import_editor_panels.PanelBody,
1028
+ {
1029
+ sx: {
1030
+ display: "flex",
1031
+ flexDirection: "column",
1032
+ height: "100%"
1033
+ }
1034
+ },
1035
+ isVersion311IsActive2 && /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(ClassManagerSearch, { searchValue: inputValue, onChange: handleChange }), /* @__PURE__ */ React10.createElement(
1036
+ import_ui9.Divider,
1037
+ {
1038
+ sx: {
1039
+ borderWidth: "1px 0 0 0"
1040
+ }
1041
+ }
1042
+ )),
1043
+ /* @__PURE__ */ React10.createElement(
1044
+ import_ui9.Box,
1045
+ {
1046
+ px: 2,
1047
+ sx: {
1048
+ flexGrow: 1,
1049
+ overflowY: "auto"
1050
+ }
1051
+ },
1052
+ /* @__PURE__ */ React10.createElement(
1053
+ GlobalClassesList,
1054
+ {
1055
+ disabled: isPublishing,
1056
+ searchValue: debouncedValue,
1057
+ onSearch: handleChange
1058
+ }
1059
+ )
1060
+ )
1061
+ ), /* @__PURE__ */ React10.createElement(import_editor_panels.PanelFooter, null, /* @__PURE__ */ React10.createElement(
1062
+ import_ui9.Button,
790
1063
  {
791
1064
  fullWidth: true,
792
1065
  size: "small",
@@ -796,17 +1069,19 @@ function ClassManagerPanel() {
796
1069
  disabled: !isDirty2,
797
1070
  loading: isPublishing
798
1071
  },
799
- (0, import_i18n5.__)("Save changes", "elementor")
800
- )))), /* @__PURE__ */ React7.createElement(ClassManagerIntroduction, null), isSaveChangesDialogOpen && /* @__PURE__ */ React7.createElement(SaveChangesDialog, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.Title, null, (0, import_i18n5.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React7.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.ContentText, null, (0, import_i18n5.__)("You have unsaved changes in the Class Manager.", "elementor")), /* @__PURE__ */ React7.createElement(SaveChangesDialog.ContentText, null, (0, import_i18n5.__)("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React7.createElement(
1072
+ (0, import_i18n8.__)("Save changes", "elementor")
1073
+ )))), /* @__PURE__ */ React10.createElement(ClassManagerIntroduction, null), isSaveChangesDialogOpen && /* @__PURE__ */ React10.createElement(SaveChangesDialog, null, /* @__PURE__ */ React10.createElement(import_ui9.DialogHeader, { onClose: closeSaveChangesDialog, logo: false }, /* @__PURE__ */ React10.createElement(SaveChangesDialog.Title, null, (0, import_i18n8.__)("You have unsaved changes", "elementor"))), /* @__PURE__ */ React10.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React10.createElement(SaveChangesDialog.ContentText, null, (0, import_i18n8.__)("You have unsaved changes in the Class Manager.", "elementor")), /* @__PURE__ */ React10.createElement(SaveChangesDialog.ContentText, null, (0, import_i18n8.__)("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React10.createElement(
801
1074
  SaveChangesDialog.Actions,
802
1075
  {
803
1076
  actions: {
804
- cancel: {
805
- label: (0, import_i18n5.__)("Cancel", "elementor"),
806
- action: closeSaveChangesDialog
1077
+ discard: {
1078
+ label: (0, import_i18n8.__)("Discard", "elementor"),
1079
+ action: () => {
1080
+ resetAndClosePanel();
1081
+ }
807
1082
  },
808
1083
  confirm: {
809
- label: (0, import_i18n5.__)("Save & Continue", "elementor"),
1084
+ label: (0, import_i18n8.__)("Save & Continue", "elementor"),
810
1085
  action: async () => {
811
1086
  await publish();
812
1087
  closeSaveChangesDialog();
@@ -817,11 +1092,11 @@ function ClassManagerPanel() {
817
1092
  }
818
1093
  )));
819
1094
  }
820
- var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */ React7.createElement(import_ui6.IconButton, { size: "small", color: "secondary", onClick: onClose, "aria-label": "Close", ...props }, /* @__PURE__ */ React7.createElement(import_icons6.XIcon, { fontSize: "small" }));
821
- var ErrorBoundaryFallback = () => /* @__PURE__ */ React7.createElement(import_ui6.Box, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React7.createElement(import_ui6.Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React7.createElement("strong", null, (0, import_i18n5.__)("Something went wrong", "elementor"))));
1095
+ var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */ React10.createElement(import_ui9.IconButton, { size: "small", color: "secondary", onClick: onClose, "aria-label": "Close", ...props }, /* @__PURE__ */ React10.createElement(import_icons7.XIcon, { fontSize: "small" }));
1096
+ var ErrorBoundaryFallback = () => /* @__PURE__ */ React10.createElement(import_ui9.Box, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React10.createElement(import_ui9.Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React10.createElement("strong", null, (0, import_i18n8.__)("Something went wrong", "elementor"))));
822
1097
  var usePreventUnload = () => {
823
1098
  const isDirty2 = useDirtyState();
824
- (0, import_react5.useEffect)(() => {
1099
+ (0, import_react6.useEffect)(() => {
825
1100
  const handleBeforeUnload = (event) => {
826
1101
  if (isDirty2) {
827
1102
  event.preventDefault();
@@ -863,19 +1138,19 @@ var ClassManagerButton = () => {
863
1138
  }
864
1139
  openPanel();
865
1140
  };
866
- return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(import_ui7.Tooltip, { title: (0, import_i18n6.__)("Class Manager", "elementor"), placement: "top" }, /* @__PURE__ */ React8.createElement(import_ui7.IconButton, { size: "tiny", onClick: handleOpenPanel, sx: { marginInlineEnd: -0.75 } }, /* @__PURE__ */ React8.createElement(FlippedColorSwatchIcon, { fontSize: "tiny" }))), isSaveChangesDialogOpen && /* @__PURE__ */ React8.createElement(SaveChangesDialog, null, /* @__PURE__ */ React8.createElement(SaveChangesDialog.Title, null, (0, import_i18n6.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React8.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React8.createElement(SaveChangesDialog.ContentText, { sx: { mb: 2 } }, (0, import_i18n6.__)(
1141
+ return /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(import_ui10.Tooltip, { title: (0, import_i18n9.__)("Class Manager", "elementor"), placement: "top" }, /* @__PURE__ */ React11.createElement(import_ui10.IconButton, { size: "tiny", onClick: handleOpenPanel, sx: { marginInlineEnd: -0.75 } }, /* @__PURE__ */ React11.createElement(FlippedColorSwatchIcon, { fontSize: "tiny" }))), isSaveChangesDialogOpen && /* @__PURE__ */ React11.createElement(SaveChangesDialog, null, /* @__PURE__ */ React11.createElement(SaveChangesDialog.Title, null, (0, import_i18n9.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React11.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React11.createElement(SaveChangesDialog.ContentText, { sx: { mb: 2 } }, (0, import_i18n9.__)(
867
1142
  "To open the Class Manager, save your page first. You can't continue without saving.",
868
1143
  "elementor"
869
- ))), /* @__PURE__ */ React8.createElement(
1144
+ ))), /* @__PURE__ */ React11.createElement(
870
1145
  SaveChangesDialog.Actions,
871
1146
  {
872
1147
  actions: {
873
1148
  cancel: {
874
- label: (0, import_i18n6.__)("Stay here", "elementor"),
1149
+ label: (0, import_i18n9.__)("Stay here", "elementor"),
875
1150
  action: closeSaveChangesDialog
876
1151
  },
877
1152
  confirm: {
878
- label: (0, import_i18n6.__)("Save & Continue", "elementor"),
1153
+ label: (0, import_i18n9.__)("Save & Continue", "elementor"),
879
1154
  action: async () => {
880
1155
  await saveDocument();
881
1156
  closeSaveChangesDialog();
@@ -888,16 +1163,16 @@ var ClassManagerButton = () => {
888
1163
  };
889
1164
 
890
1165
  // src/components/populate-store.tsx
891
- var import_react6 = require("react");
892
- var import_store16 = require("@elementor/store");
1166
+ var import_react7 = require("react");
1167
+ var import_store18 = require("@elementor/store");
893
1168
  function PopulateStore() {
894
- const dispatch4 = (0, import_store16.__useDispatch)();
895
- (0, import_react6.useEffect)(() => {
1169
+ const dispatch5 = (0, import_store18.__useDispatch)();
1170
+ (0, import_react7.useEffect)(() => {
896
1171
  Promise.all([apiClient.all("preview"), apiClient.all("frontend")]).then(
897
1172
  ([previewRes, frontendRes]) => {
898
1173
  const { data: previewData } = previewRes;
899
1174
  const { data: frontendData } = frontendRes;
900
- dispatch4(
1175
+ dispatch5(
901
1176
  slice.actions.load({
902
1177
  preview: {
903
1178
  items: previewData.data,
@@ -911,21 +1186,21 @@ function PopulateStore() {
911
1186
  );
912
1187
  }
913
1188
  );
914
- }, [dispatch4]);
1189
+ }, [dispatch5]);
915
1190
  return null;
916
1191
  }
917
1192
 
918
1193
  // src/sync-with-document-save.ts
919
1194
  var import_editor_documents4 = require("@elementor/editor-documents");
920
- var import_editor_v1_adapters5 = require("@elementor/editor-v1-adapters");
921
- var import_store18 = require("@elementor/store");
1195
+ var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
1196
+ var import_store20 = require("@elementor/store");
922
1197
  function syncWithDocumentSave() {
923
1198
  const unsubscribe = syncDirtyState();
924
1199
  bindSaveAction();
925
1200
  return unsubscribe;
926
1201
  }
927
1202
  function syncDirtyState() {
928
- return (0, import_store18.__subscribeWithSelector)(selectIsDirty, () => {
1203
+ return (0, import_store20.__subscribeWithSelector)(selectIsDirty, () => {
929
1204
  if (!isDirty()) {
930
1205
  return;
931
1206
  }
@@ -933,30 +1208,34 @@ function syncDirtyState() {
933
1208
  });
934
1209
  }
935
1210
  function bindSaveAction() {
936
- (0, import_editor_v1_adapters5.registerDataHook)("after", "document/save/save", (args) => {
1211
+ (0, import_editor_v1_adapters6.registerDataHook)("after", "document/save/save", (args) => {
937
1212
  return saveGlobalClasses({
938
1213
  context: args.status === "publish" ? "frontend" : "preview"
939
1214
  });
940
1215
  });
941
1216
  }
942
1217
  function isDirty() {
943
- return selectIsDirty((0, import_store18.__getState)());
1218
+ return selectIsDirty((0, import_store20.__getState)());
944
1219
  }
945
1220
 
946
1221
  // src/init.ts
947
1222
  function init() {
948
- (0, import_store20.__registerSlice)(slice);
1223
+ (0, import_store22.__registerSlice)(slice);
949
1224
  (0, import_editor_panels2.__registerPanel)(panel);
950
1225
  import_editor_styles_repository4.stylesRepository.register(globalClassesStylesProvider);
951
1226
  (0, import_editor.injectIntoLogic)({
952
1227
  id: "global-classes-populate-store",
953
1228
  component: PopulateStore
954
1229
  });
955
- (0, import_editor_editing_panel.injectIntoClassSelectorActions)({
1230
+ (0, import_editor_editing_panel3.injectIntoClassSelectorActions)({
956
1231
  id: "global-classes-manager-button",
957
1232
  component: ClassManagerButton
958
1233
  });
959
- (0, import_editor_v1_adapters6.__privateListenTo)((0, import_editor_v1_adapters6.v1ReadyEvent)(), () => {
1234
+ (0, import_editor_editing_panel3.registerStyleProviderToColors)(GLOBAL_CLASSES_PROVIDER_KEY, {
1235
+ name: "global",
1236
+ getThemeColor: (theme) => theme.palette.global.dark
1237
+ });
1238
+ (0, import_editor_v1_adapters7.__privateListenTo)((0, import_editor_v1_adapters7.v1ReadyEvent)(), () => {
960
1239
  syncWithDocumentSave();
961
1240
  });
962
1241
  }