@elementor/editor-global-classes 0.10.0 → 0.11.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/dist/index.mjs CHANGED
@@ -7,17 +7,17 @@ import { __privateListenTo as listenTo, v1ReadyEvent } from "@elementor/editor-v
7
7
  import { __registerSlice as registerSlice } from "@elementor/store";
8
8
 
9
9
  // src/components/class-manager/class-manager-button.tsx
10
- import * as React7 from "react";
10
+ import * as React8 from "react";
11
11
  import {
12
12
  __useActiveDocument as useActiveDocument,
13
13
  __useActiveDocumentActions as useActiveDocumentActions
14
14
  } from "@elementor/editor-documents";
15
- import { ColorSwatchIcon as ColorSwatchIcon2 } from "@elementor/icons";
16
15
  import { IconButton as IconButton3, Tooltip as Tooltip2 } from "@elementor/ui";
17
16
  import { __ as __6 } from "@wordpress/i18n";
18
17
 
19
18
  // src/components/class-manager/class-manager-panel.tsx
20
- import * as React6 from "react";
19
+ import * as React7 from "react";
20
+ import { useEffect } from "react";
21
21
  import {
22
22
  __createPanel as createPanel,
23
23
  Panel,
@@ -26,7 +26,8 @@ import {
26
26
  PanelHeader,
27
27
  PanelHeaderTitle
28
28
  } from "@elementor/editor-panels";
29
- import { ColorSwatchIcon, XIcon } from "@elementor/icons";
29
+ import { changeEditMode } from "@elementor/editor-v1-adapters";
30
+ import { XIcon } from "@elementor/icons";
30
31
  import { Alert, Box as Box4, Button as Button3, ErrorBoundary, IconButton as IconButton2, Stack as Stack3 } from "@elementor/ui";
31
32
  import { __ as __5 } from "@wordpress/i18n";
32
33
 
@@ -76,8 +77,8 @@ var slice = createSlice({
76
77
  state.isDirty = true;
77
78
  },
78
79
  delete(state, { payload }) {
79
- state.items = Object.fromEntries(Object.entries(state.items).filter(([id]) => id !== payload));
80
- state.order = state.order.filter((id) => id !== payload);
80
+ state.items = Object.fromEntries(Object.entries(state.items).filter(([id2]) => id2 !== payload));
81
+ state.order = state.order.filter((id2) => id2 !== payload);
81
82
  state.isDirty = true;
82
83
  },
83
84
  setOrder(state, { payload }) {
@@ -118,9 +119,9 @@ var selectGlobalClasses = (state) => state[SLICE_NAME].items;
118
119
  var selectOrderedClasses = createSelector(
119
120
  selectGlobalClasses,
120
121
  selectOrder,
121
- (items, order) => order.map((id) => items[id])
122
+ (items, order) => order.map((id2) => items[id2])
122
123
  );
123
- var selectClass = (state, id) => state[SLICE_NAME].items[id] ?? null;
124
+ var selectClass = (state, id2) => state[SLICE_NAME].items[id2] ?? null;
124
125
  var selectIsDirty = (state) => state.globalClasses.isDirty;
125
126
 
126
127
  // src/hooks/use-dirty-state.ts
@@ -191,11 +192,16 @@ var IntroductionContent = () => {
191
192
  ))));
192
193
  };
193
194
 
195
+ // src/components/class-manager/flipped-color-swatch-icon.tsx
196
+ import * as React2 from "react";
197
+ import { ColorSwatchIcon } from "@elementor/icons";
198
+ var FlippedColorSwatchIcon = ({ sx, ...props }) => /* @__PURE__ */ React2.createElement(ColorSwatchIcon, { sx: { transform: "rotate(90deg)", ...sx }, ...props });
199
+
194
200
  // src/components/class-manager/global-classes-list.tsx
195
- import * as React4 from "react";
201
+ import * as React5 from "react";
196
202
  import { stylesRepository } from "@elementor/editor-styles-repository";
197
203
  import { EditableField, EllipsisWithTooltip, useEditable } from "@elementor/editor-ui";
198
- import { DotsVerticalIcon, PhotoIcon } from "@elementor/icons";
204
+ import { DotsVerticalIcon } from "@elementor/icons";
199
205
  import {
200
206
  bindMenu,
201
207
  bindTrigger,
@@ -228,7 +234,7 @@ var globalClassesStylesProvider = {
228
234
  priority: 30,
229
235
  actions: {
230
236
  get: () => selectOrderedClasses(getState2()),
231
- getById: (id) => selectClass(getState2(), id),
237
+ getById: (id2) => selectClass(getState2(), id2),
232
238
  create: (label) => {
233
239
  const classes = selectGlobalClasses(getState2());
234
240
  const existingLabels = Object.values(classes).map((style) => style.label);
@@ -236,16 +242,16 @@ var globalClassesStylesProvider = {
236
242
  throw new GlobalClassLabelAlreadyExistsError({ context: { label } });
237
243
  }
238
244
  const existingIds = Object.keys(classes);
239
- const id = generateId("g-", existingIds);
245
+ const id2 = generateId("g-", existingIds);
240
246
  dispatch2(
241
247
  slice.actions.add({
242
- id,
248
+ id: id2,
243
249
  type: "class",
244
250
  label,
245
251
  variants: []
246
252
  })
247
253
  );
248
- return id;
254
+ return id2;
249
255
  },
250
256
  update: (payload) => {
251
257
  dispatch2(
@@ -254,8 +260,8 @@ var globalClassesStylesProvider = {
254
260
  })
255
261
  );
256
262
  },
257
- delete: (id) => {
258
- dispatch2(slice.actions.delete(id));
263
+ delete: (id2) => {
264
+ dispatch2(slice.actions.delete(id2));
259
265
  },
260
266
  setOrder: (order) => {
261
267
  dispatch2(slice.actions.setOrder(order));
@@ -290,7 +296,7 @@ var useOrderedClasses = () => {
290
296
  };
291
297
 
292
298
  // src/components/class-manager/delete-confirmation-dialog.tsx
293
- import * as React2 from "react";
299
+ import * as React3 from "react";
294
300
  import { createContext, useContext, useState as useState2 } from "react";
295
301
  import { AlertOctagonFilledIcon } from "@elementor/icons";
296
302
  import {
@@ -312,19 +318,19 @@ var DeleteConfirmationProvider = ({ children }) => {
312
318
  const closeDialog = () => {
313
319
  setDialogProps(null);
314
320
  };
315
- return /* @__PURE__ */ React2.createElement(context.Provider, { value: { openDialog, closeDialog, dialogProps } }, children, !!dialogProps && /* @__PURE__ */ React2.createElement(DeleteConfirmationDialog, { ...dialogProps }));
321
+ return /* @__PURE__ */ React3.createElement(context.Provider, { value: { openDialog, closeDialog, dialogProps } }, children, !!dialogProps && /* @__PURE__ */ React3.createElement(DeleteConfirmationDialog, { ...dialogProps }));
316
322
  };
317
323
  var TITLE_ID = "delete-class-dialog";
318
- var DeleteConfirmationDialog = ({ label, id }) => {
324
+ var DeleteConfirmationDialog = ({ label, id: id2 }) => {
319
325
  const { closeDialog } = useDeleteConfirmation();
320
326
  const onConfirm = () => {
321
- globalClassesStylesProvider.actions.delete(id);
327
+ globalClassesStylesProvider.actions.delete(id2);
322
328
  closeDialog();
323
329
  };
324
- return /* @__PURE__ */ React2.createElement(Dialog, { open: true, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React2.createElement(DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React2.createElement(AlertOctagonFilledIcon, { color: "error" }), __3("Delete global class", "elementor")), /* @__PURE__ */ React2.createElement(DialogContent, null, /* @__PURE__ */ React2.createElement(DialogContentText, { variant: "body2", color: "textPrimary" }, __3("Deleting", "elementor"), /* @__PURE__ */ React2.createElement(Typography2, { variant: "subtitle2", component: "span" }, "\xA0", label, "\xA0"), __3(
330
+ return /* @__PURE__ */ React3.createElement(Dialog, { open: true, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React3.createElement(DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React3.createElement(AlertOctagonFilledIcon, { color: "error" }), __3("Delete global class", "elementor")), /* @__PURE__ */ React3.createElement(DialogContent, null, /* @__PURE__ */ React3.createElement(DialogContentText, { variant: "body2", color: "textPrimary" }, __3("Deleting", "elementor"), /* @__PURE__ */ React3.createElement(Typography2, { variant: "subtitle2", component: "span" }, "\xA0", label, "\xA0"), __3(
325
331
  "will permanently remove it from your project and may affect the design across all elements using it. This action cannot be undone.",
326
332
  "elementor"
327
- ))), /* @__PURE__ */ React2.createElement(DialogActions, null, /* @__PURE__ */ React2.createElement(Button, { color: "secondary", onClick: closeDialog }, __3("Cancel", "elementor")), /* @__PURE__ */ React2.createElement(Button, { variant: "contained", color: "error", onClick: onConfirm }, __3("Delete", "elementor"))));
333
+ ))), /* @__PURE__ */ React3.createElement(DialogActions, null, /* @__PURE__ */ React3.createElement(Button, { color: "secondary", onClick: closeDialog }, __3("Cancel", "elementor")), /* @__PURE__ */ React3.createElement(Button, { variant: "contained", color: "error", onClick: onConfirm }, __3("Delete", "elementor"))));
328
334
  };
329
335
  var useDeleteConfirmation = () => {
330
336
  const contextValue = useContext(context);
@@ -335,7 +341,7 @@ var useDeleteConfirmation = () => {
335
341
  };
336
342
 
337
343
  // src/components/class-manager/sortable.tsx
338
- import * as React3 from "react";
344
+ import * as React4 from "react";
339
345
  import { GripVerticalIcon } from "@elementor/icons";
340
346
  import {
341
347
  Box as Box2,
@@ -344,13 +350,14 @@ import {
344
350
  UnstableSortableItem,
345
351
  UnstableSortableProvider
346
352
  } from "@elementor/ui";
347
- var SortableProvider = (props) => /* @__PURE__ */ React3.createElement(UnstableSortableProvider, { restrictAxis: true, variant: "static", dragPlaceholderStyle: { opacity: "1" }, ...props });
348
- var SortableTrigger = (props) => /* @__PURE__ */ React3.createElement("div", { ...props, role: "button", className: "class-item-sortable-trigger" }, /* @__PURE__ */ React3.createElement(GripVerticalIcon, { fontSize: "tiny" }));
349
- var SortableItem = ({ children, id }) => {
350
- return /* @__PURE__ */ React3.createElement(
353
+ var SortableProvider = (props) => /* @__PURE__ */ React4.createElement(UnstableSortableProvider, { restrictAxis: true, variant: "static", dragPlaceholderStyle: { opacity: "1" }, ...props });
354
+ var SortableTrigger = (props) => /* @__PURE__ */ React4.createElement("div", { ...props, role: "button", className: "class-item-sortable-trigger" }, /* @__PURE__ */ React4.createElement(GripVerticalIcon, { fontSize: "tiny" }));
355
+ var SortableItem = ({ children, id: id2, ...props }) => {
356
+ return /* @__PURE__ */ React4.createElement(
351
357
  UnstableSortableItem,
352
358
  {
353
- id,
359
+ ...props,
360
+ id: id2,
354
361
  render: ({
355
362
  itemProps,
356
363
  isDragged,
@@ -358,22 +365,35 @@ var SortableItem = ({ children, id }) => {
358
365
  itemStyle,
359
366
  triggerStyle,
360
367
  dropIndicationStyle,
361
- showDropIndication
368
+ showDropIndication,
369
+ isDragOverlay,
370
+ isDragPlaceholder
362
371
  }) => {
363
- return /* @__PURE__ */ React3.createElement(StyledSortableItem, { ...itemProps, elevation: 0, sx: itemStyle, role: "listitem" }, /* @__PURE__ */ React3.createElement(SortableTrigger, { ...triggerProps, style: triggerStyle }), children({
364
- itemProps,
365
- isDragged,
366
- triggerProps,
367
- itemStyle,
368
- triggerStyle,
369
- dropIndicationStyle,
370
- showDropIndication
371
- }));
372
+ return /* @__PURE__ */ React4.createElement(
373
+ StyledSortableItem,
374
+ {
375
+ ...itemProps,
376
+ sx: itemStyle,
377
+ role: "listitem",
378
+ ...isDragOverlay ? { component: Paper, elevation: 0 } : {}
379
+ },
380
+ /* @__PURE__ */ React4.createElement(SortableTrigger, { ...triggerProps, style: triggerStyle }),
381
+ children({
382
+ itemProps,
383
+ isDragged,
384
+ triggerProps,
385
+ itemStyle,
386
+ triggerStyle,
387
+ dropIndicationStyle,
388
+ showDropIndication,
389
+ isDragPlaceholder
390
+ })
391
+ );
372
392
  }
373
393
  }
374
394
  );
375
395
  };
376
- var StyledSortableItem = styled(Paper)`
396
+ var StyledSortableItem = styled(Box2)`
377
397
  position: relative;
378
398
 
379
399
  &:hover {
@@ -402,21 +422,22 @@ var GlobalClassesList = () => {
402
422
  const cssClasses = useOrderedClasses();
403
423
  const [classesOrder, reorderClasses] = useReorder();
404
424
  if (!cssClasses?.length) {
405
- return /* @__PURE__ */ React4.createElement(EmptyState, null);
425
+ return /* @__PURE__ */ React5.createElement(EmptyState, null);
406
426
  }
407
- return /* @__PURE__ */ React4.createElement(DeleteConfirmationProvider, null, /* @__PURE__ */ React4.createElement(List, { sx: { display: "flex", flexDirection: "column", gap: 0.5 } }, /* @__PURE__ */ React4.createElement(SortableProvider, { value: classesOrder, onChange: reorderClasses }, cssClasses?.map(({ id, label }) => {
427
+ return /* @__PURE__ */ React5.createElement(DeleteConfirmationProvider, null, /* @__PURE__ */ React5.createElement(List, { sx: { display: "flex", flexDirection: "column", gap: 0.5 } }, /* @__PURE__ */ React5.createElement(SortableProvider, { value: classesOrder, onChange: reorderClasses }, cssClasses?.map(({ id: id2, label }) => {
408
428
  const renameClass = (newLabel) => {
409
- globalClassesStylesProvider.actions.update({ label: newLabel, id });
429
+ globalClassesStylesProvider.actions.update({ label: newLabel, id: id2 });
410
430
  };
411
- return /* @__PURE__ */ React4.createElement(SortableItem, { key: id, id }, ({ isDragged, showDropIndication, dropIndicationStyle }) => /* @__PURE__ */ React4.createElement(
431
+ return /* @__PURE__ */ React5.createElement(SortableItem, { key: id2, id: id2 }, ({ isDragged, showDropIndication, dropIndicationStyle, isDragPlaceholder }) => /* @__PURE__ */ React5.createElement(
412
432
  ClassItem,
413
433
  {
414
- id,
434
+ id: id2,
415
435
  label,
416
436
  renameClass,
417
- selected: isDragged
437
+ selected: isDragged,
438
+ disabled: isDragPlaceholder
418
439
  },
419
- showDropIndication && /* @__PURE__ */ React4.createElement(SortableItemIndicator, { style: dropIndicationStyle })
440
+ showDropIndication && /* @__PURE__ */ React5.createElement(SortableItemIndicator, { style: dropIndicationStyle })
420
441
  ));
421
442
  }))));
422
443
  };
@@ -428,11 +449,12 @@ var useReorder = () => {
428
449
  return [order, reorder];
429
450
  };
430
451
  var ClassItem = ({
431
- id,
452
+ id: id2,
432
453
  label,
433
454
  renameClass,
434
455
  selected,
435
- children
456
+ children,
457
+ disabled
436
458
  }) => {
437
459
  const {
438
460
  ref: editableRef,
@@ -450,23 +472,23 @@ var ClassItem = ({
450
472
  variant: "popover",
451
473
  disableAutoFocus: true
452
474
  });
453
- return /* @__PURE__ */ React4.createElement(Stack2, { direction: "row", alignItems: "center", gap: 1, flexGrow: 1, flexShrink: 0 }, /* @__PURE__ */ React4.createElement(
475
+ return /* @__PURE__ */ React5.createElement(Stack2, { direction: "row", alignItems: "center", gap: 1, flexGrow: 1, flexShrink: 0 }, /* @__PURE__ */ React5.createElement(
454
476
  StyledListItem,
455
477
  {
456
478
  component: "div",
457
479
  disablePadding: true,
458
480
  disableGutters: true,
459
- secondaryAction: /* @__PURE__ */ React4.createElement(
481
+ secondaryAction: /* @__PURE__ */ React5.createElement(
460
482
  Tooltip,
461
483
  {
462
484
  placement: "top",
463
485
  className: "class-item-more-actions",
464
486
  title: __4("More actions", "elementor")
465
487
  },
466
- /* @__PURE__ */ React4.createElement(IconButton, { size: "tiny", ...bindTrigger(popupState), "aria-label": "More actions" }, /* @__PURE__ */ React4.createElement(DotsVerticalIcon, { fontSize: "tiny" }))
488
+ /* @__PURE__ */ React5.createElement(IconButton, { size: "tiny", ...bindTrigger(popupState), "aria-label": "More actions" }, /* @__PURE__ */ React5.createElement(DotsVerticalIcon, { fontSize: "tiny" }))
467
489
  )
468
490
  },
469
- /* @__PURE__ */ React4.createElement(
491
+ /* @__PURE__ */ React5.createElement(
470
492
  ListItemButton,
471
493
  {
472
494
  dense: true,
@@ -474,6 +496,7 @@ var ClassItem = ({
474
496
  shape: "rounded",
475
497
  onDoubleClick: openEditMode,
476
498
  selected: selected || popupState.isOpen,
499
+ disabled,
477
500
  focusVisibleClassName: "visible-class-item",
478
501
  sx: {
479
502
  minHeight: "36px",
@@ -483,7 +506,7 @@ var ClassItem = ({
483
506
  }
484
507
  }
485
508
  },
486
- /* @__PURE__ */ React4.createElement(Indicator, { isActive: isEditing, isError: !!error }, isEditing ? /* @__PURE__ */ React4.createElement(
509
+ /* @__PURE__ */ React5.createElement(Indicator, { isActive: isEditing, isError: !!error }, isEditing ? /* @__PURE__ */ React5.createElement(
487
510
  EditableField,
488
511
  {
489
512
  ref: editableRef,
@@ -492,10 +515,10 @@ var ClassItem = ({
492
515
  variant: "caption",
493
516
  ...getEditableProps()
494
517
  }
495
- ) : /* @__PURE__ */ React4.createElement(EllipsisWithTooltip, { title: label, as: Typography3, variant: "caption" }))
518
+ ) : /* @__PURE__ */ React5.createElement(EllipsisWithTooltip, { title: label, as: Typography3, variant: "caption" }))
496
519
  ),
497
520
  children,
498
- /* @__PURE__ */ React4.createElement(
521
+ /* @__PURE__ */ React5.createElement(
499
522
  Menu,
500
523
  {
501
524
  ...bindMenu(popupState),
@@ -508,7 +531,7 @@ var ClassItem = ({
508
531
  horizontal: "right"
509
532
  }
510
533
  },
511
- /* @__PURE__ */ React4.createElement(
534
+ /* @__PURE__ */ React5.createElement(
512
535
  MenuItem,
513
536
  {
514
537
  sx: { minWidth: "160px" },
@@ -517,17 +540,17 @@ var ClassItem = ({
517
540
  openEditMode();
518
541
  }
519
542
  },
520
- /* @__PURE__ */ React4.createElement(ListItemText, { primary: __4("Rename", "elementor") })
543
+ /* @__PURE__ */ React5.createElement(ListItemText, { primary: __4("Rename", "elementor") })
521
544
  ),
522
- /* @__PURE__ */ React4.createElement(
545
+ /* @__PURE__ */ React5.createElement(
523
546
  MenuItem,
524
547
  {
525
548
  onClick: () => {
526
549
  popupState.close();
527
- openDialog({ id, label });
550
+ openDialog({ id: id2, label });
528
551
  }
529
552
  },
530
- /* @__PURE__ */ React4.createElement(ListItemText, { primary: __4("Delete", "elementor"), sx: { color: "error.light" } })
553
+ /* @__PURE__ */ React5.createElement(ListItemText, { primary: __4("Delete", "elementor"), sx: { color: "error.light" } })
531
554
  )
532
555
  )
533
556
  ));
@@ -542,7 +565,7 @@ var StyledListItem = styled2(ListItem)`
542
565
  }
543
566
  }
544
567
  `;
545
- var EmptyState = () => /* @__PURE__ */ React4.createElement(Stack2, { alignItems: "center", gap: 3, pt: 4, px: 0.5 }, /* @__PURE__ */ React4.createElement(PhotoIcon, { fontSize: "large" }), /* @__PURE__ */ React4.createElement(StyledHeader, { variant: "subtitle2", component: "h2", color: "text.secondary" }, __4("No CSS classes created yet", "elementor")), /* @__PURE__ */ React4.createElement(Typography3, { align: "center", variant: "caption", color: "text.secondary" }, __4(
568
+ var EmptyState = () => /* @__PURE__ */ React5.createElement(Stack2, { 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" }, __4("There are no global classes yet.", "elementor")), /* @__PURE__ */ React5.createElement(Typography3, { align: "center", variant: "caption", color: "text.secondary" }, __4(
546
569
  "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.",
547
570
  "elementor"
548
571
  )));
@@ -582,7 +605,7 @@ var validateLabel = (newLabel) => {
582
605
  };
583
606
 
584
607
  // src/components/class-manager/save-changes-dialog.tsx
585
- import * as React5 from "react";
608
+ import * as React6 from "react";
586
609
  import { useState as useState3 } from "react";
587
610
  import { AlertTriangleFilledIcon } from "@elementor/icons";
588
611
  import {
@@ -594,10 +617,10 @@ import {
594
617
  DialogTitle as DialogTitle2
595
618
  } from "@elementor/ui";
596
619
  var TITLE_ID2 = "save-changes-dialog";
597
- var SaveChangesDialog = ({ children, onClose }) => /* @__PURE__ */ React5.createElement(Dialog2, { open: true, onClose, "aria-labelledby": TITLE_ID2, maxWidth: "xs" }, children);
598
- var SaveChangesDialogTitle = ({ children }) => /* @__PURE__ */ React5.createElement(DialogTitle2, { id: TITLE_ID2, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React5.createElement(AlertTriangleFilledIcon, { color: "secondary" }), children);
599
- var SaveChangesDialogContent = ({ children }) => /* @__PURE__ */ React5.createElement(DialogContent2, null, children);
600
- var SaveChangesDialogContentText = (props) => /* @__PURE__ */ React5.createElement(DialogContentText2, { variant: "body2", color: "textPrimary", display: "flex", flexDirection: "column", ...props });
620
+ var SaveChangesDialog = ({ children, onClose }) => /* @__PURE__ */ React6.createElement(Dialog2, { open: true, onClose, "aria-labelledby": TITLE_ID2, maxWidth: "xs" }, children);
621
+ var SaveChangesDialogTitle = ({ children }) => /* @__PURE__ */ React6.createElement(DialogTitle2, { id: TITLE_ID2, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React6.createElement(AlertTriangleFilledIcon, { color: "secondary" }), children);
622
+ var SaveChangesDialogContent = ({ children }) => /* @__PURE__ */ React6.createElement(DialogContent2, null, children);
623
+ var SaveChangesDialogContentText = (props) => /* @__PURE__ */ React6.createElement(DialogContentText2, { variant: "body2", color: "textPrimary", display: "flex", flexDirection: "column", ...props });
601
624
  var SaveChangesDialogActions = ({ actions }) => {
602
625
  const [isConfirming, setIsConfirming] = useState3(false);
603
626
  const { cancel, confirm } = actions;
@@ -606,7 +629,7 @@ var SaveChangesDialogActions = ({ actions }) => {
606
629
  await confirm.action();
607
630
  setIsConfirming(false);
608
631
  };
609
- return /* @__PURE__ */ React5.createElement(DialogActions2, null, /* @__PURE__ */ React5.createElement(Button2, { variant: "text", color: "secondary", onClick: cancel.action }, cancel.label), /* @__PURE__ */ React5.createElement(Button2, { variant: "contained", color: "secondary", onClick: onConfirm, loading: isConfirming }, confirm.label));
632
+ return /* @__PURE__ */ React6.createElement(DialogActions2, null, /* @__PURE__ */ React6.createElement(Button2, { variant: "text", color: "secondary", onClick: cancel.action }, cancel.label), /* @__PURE__ */ React6.createElement(Button2, { variant: "contained", color: "secondary", onClick: onConfirm, loading: isConfirming }, confirm.label));
610
633
  };
611
634
  SaveChangesDialog.Title = SaveChangesDialogTitle;
612
635
  SaveChangesDialog.Content = SaveChangesDialogContent;
@@ -620,15 +643,20 @@ var useDialog = () => {
620
643
  };
621
644
 
622
645
  // src/components/class-manager/class-manager-panel.tsx
646
+ var id = "global-classes-manager";
623
647
  var { panel, usePanelActions } = createPanel({
624
- id: "class-manager-panel",
625
- component: ClassManagerPanel
648
+ id,
649
+ component: ClassManagerPanel,
650
+ onOpen: () => changeEditMode(id),
651
+ onClose: () => changeEditMode("edit"),
652
+ allowedEditModes: ["edit", id]
626
653
  });
627
654
  function ClassManagerPanel() {
628
655
  const isDirty3 = useDirtyState();
629
656
  const { close: closePanel } = usePanelActions();
630
657
  const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
631
- return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(ErrorBoundary, { fallback: /* @__PURE__ */ React6.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React6.createElement(Panel, null, /* @__PURE__ */ React6.createElement(PanelHeader, null, /* @__PURE__ */ React6.createElement(Stack3, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React6.createElement(PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React6.createElement(ColorSwatchIcon, { fontSize: "inherit", sx: { transform: "rotate(90deg)" } }), __5("CSS Class manager", "elementor")), /* @__PURE__ */ React6.createElement(
658
+ usePreventUnload();
659
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(ErrorBoundary, { fallback: /* @__PURE__ */ React7.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React7.createElement(Panel, null, /* @__PURE__ */ React7.createElement(PanelHeader, null, /* @__PURE__ */ React7.createElement(Stack3, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React7.createElement(PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React7.createElement(FlippedColorSwatchIcon, { fontSize: "inherit" }), __5("CSS Class manager", "elementor")), /* @__PURE__ */ React7.createElement(
632
660
  CloseButton,
633
661
  {
634
662
  sx: { marginLeft: "auto" },
@@ -640,7 +668,7 @@ function ClassManagerPanel() {
640
668
  closePanel();
641
669
  }
642
670
  }
643
- ))), /* @__PURE__ */ React6.createElement(PanelBody, { px: 2 }, /* @__PURE__ */ React6.createElement(GlobalClassesList, null)), /* @__PURE__ */ React6.createElement(PanelFooter, null, /* @__PURE__ */ React6.createElement(
671
+ ))), /* @__PURE__ */ React7.createElement(PanelBody, { px: 2 }, /* @__PURE__ */ React7.createElement(GlobalClassesList, null)), /* @__PURE__ */ React7.createElement(PanelFooter, null, /* @__PURE__ */ React7.createElement(
644
672
  Button3,
645
673
  {
646
674
  fullWidth: true,
@@ -651,7 +679,7 @@ function ClassManagerPanel() {
651
679
  onClick: publishGlobalClasses
652
680
  },
653
681
  __5("Save changes", "elementor")
654
- )))), /* @__PURE__ */ React6.createElement(ClassManagerIntroduction, null), isSaveChangesDialogOpen && /* @__PURE__ */ React6.createElement(SaveChangesDialog, null, /* @__PURE__ */ React6.createElement(SaveChangesDialog.Title, null, __5("You have unsaved changes", "elementor")), /* @__PURE__ */ React6.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React6.createElement(SaveChangesDialog.ContentText, null, __5("You have unsaved changes in the Class Manager.", "elementor")), /* @__PURE__ */ React6.createElement(SaveChangesDialog.ContentText, null, __5("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React6.createElement(
682
+ )))), /* @__PURE__ */ React7.createElement(ClassManagerIntroduction, null), isSaveChangesDialogOpen && /* @__PURE__ */ React7.createElement(SaveChangesDialog, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.Title, null, __5("You have unsaved changes", "elementor")), /* @__PURE__ */ React7.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.ContentText, null, __5("You have unsaved changes in the Class Manager.", "elementor")), /* @__PURE__ */ React7.createElement(SaveChangesDialog.ContentText, null, __5("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React7.createElement(
655
683
  SaveChangesDialog.Actions,
656
684
  {
657
685
  actions: {
@@ -671,8 +699,22 @@ function ClassManagerPanel() {
671
699
  }
672
700
  )));
673
701
  }
674
- var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */ React6.createElement(IconButton2, { size: "small", color: "secondary", onClick: onClose, "aria-label": "Close", ...props }, /* @__PURE__ */ React6.createElement(XIcon, { fontSize: "small" }));
675
- var ErrorBoundaryFallback = () => /* @__PURE__ */ React6.createElement(Box4, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React6.createElement(Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React6.createElement("strong", null, __5("Something went wrong", "elementor"))));
702
+ var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */ React7.createElement(IconButton2, { size: "small", color: "secondary", onClick: onClose, "aria-label": "Close", ...props }, /* @__PURE__ */ React7.createElement(XIcon, { fontSize: "small" }));
703
+ var ErrorBoundaryFallback = () => /* @__PURE__ */ React7.createElement(Box4, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React7.createElement(Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React7.createElement("strong", null, __5("Something went wrong", "elementor"))));
704
+ var usePreventUnload = () => {
705
+ const isDirty3 = useDirtyState();
706
+ useEffect(() => {
707
+ const handleBeforeUnload = (event) => {
708
+ if (isDirty3) {
709
+ event.preventDefault();
710
+ }
711
+ };
712
+ window.addEventListener("beforeunload", handleBeforeUnload);
713
+ return () => {
714
+ window.removeEventListener("beforeunload", handleBeforeUnload);
715
+ };
716
+ }, [isDirty3]);
717
+ };
676
718
 
677
719
  // src/components/class-manager/class-manager-button.tsx
678
720
  var ClassManagerButton = () => {
@@ -687,10 +729,10 @@ var ClassManagerButton = () => {
687
729
  }
688
730
  openPanel();
689
731
  };
690
- return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(Tooltip2, { title: __6("Class manager", "elementor"), placement: "top" }, /* @__PURE__ */ React7.createElement(IconButton3, { onClick: handleOpenPanel }, /* @__PURE__ */ React7.createElement(ColorSwatchIcon2, { fontSize: "tiny" }))), isSaveChangesDialogOpen && /* @__PURE__ */ React7.createElement(SaveChangesDialog, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.Title, null, __6("You have unsaved changes", "elementor")), /* @__PURE__ */ React7.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.ContentText, { sx: { mb: 2 } }, __6(
732
+ return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(Tooltip2, { title: __6("Class manager", "elementor"), placement: "top" }, /* @__PURE__ */ React8.createElement(IconButton3, { onClick: handleOpenPanel }, /* @__PURE__ */ React8.createElement(FlippedColorSwatchIcon, { fontSize: "tiny" }))), isSaveChangesDialogOpen && /* @__PURE__ */ React8.createElement(SaveChangesDialog, null, /* @__PURE__ */ React8.createElement(SaveChangesDialog.Title, null, __6("You have unsaved changes", "elementor")), /* @__PURE__ */ React8.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React8.createElement(SaveChangesDialog.ContentText, { sx: { mb: 2 } }, __6(
691
733
  "Save your changes before moving to the class manager to ensure all updates are applied and saved.",
692
734
  "elementor"
693
- )), /* @__PURE__ */ React7.createElement(SaveChangesDialog.ContentText, null, __6("If you leave without saving, all changes will be discarded.", "elementor"))), /* @__PURE__ */ React7.createElement(
735
+ )), /* @__PURE__ */ React8.createElement(SaveChangesDialog.ContentText, null, __6("If you leave without saving, all changes will be discarded.", "elementor"))), /* @__PURE__ */ React8.createElement(
694
736
  SaveChangesDialog.Actions,
695
737
  {
696
738
  actions: {
@@ -712,11 +754,11 @@ var ClassManagerButton = () => {
712
754
  };
713
755
 
714
756
  // src/components/populate-store.tsx
715
- import { useEffect } from "react";
757
+ import { useEffect as useEffect2 } from "react";
716
758
  import { __useDispatch as useDispatch } from "@elementor/store";
717
759
  function PopulateStore() {
718
760
  const dispatch3 = useDispatch();
719
- useEffect(() => {
761
+ useEffect2(() => {
720
762
  apiClient.all().then((res) => {
721
763
  const { data, meta } = res.data;
722
764
  dispatch3(slice.actions.init({ items: data, order: meta.order }));