@elementor/editor-global-classes 0.10.0 → 0.11.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.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,18 +192,22 @@ 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,
202
208
  Box as Box3,
203
209
  IconButton,
204
210
  List,
205
- ListItem,
206
211
  ListItemButton,
207
212
  ListItemText,
208
213
  Menu,
@@ -228,7 +233,7 @@ var globalClassesStylesProvider = {
228
233
  priority: 30,
229
234
  actions: {
230
235
  get: () => selectOrderedClasses(getState2()),
231
- getById: (id) => selectClass(getState2(), id),
236
+ getById: (id2) => selectClass(getState2(), id2),
232
237
  create: (label) => {
233
238
  const classes = selectGlobalClasses(getState2());
234
239
  const existingLabels = Object.values(classes).map((style) => style.label);
@@ -236,16 +241,16 @@ var globalClassesStylesProvider = {
236
241
  throw new GlobalClassLabelAlreadyExistsError({ context: { label } });
237
242
  }
238
243
  const existingIds = Object.keys(classes);
239
- const id = generateId("g-", existingIds);
244
+ const id2 = generateId("g-", existingIds);
240
245
  dispatch2(
241
246
  slice.actions.add({
242
- id,
247
+ id: id2,
243
248
  type: "class",
244
249
  label,
245
250
  variants: []
246
251
  })
247
252
  );
248
- return id;
253
+ return id2;
249
254
  },
250
255
  update: (payload) => {
251
256
  dispatch2(
@@ -254,8 +259,8 @@ var globalClassesStylesProvider = {
254
259
  })
255
260
  );
256
261
  },
257
- delete: (id) => {
258
- dispatch2(slice.actions.delete(id));
262
+ delete: (id2) => {
263
+ dispatch2(slice.actions.delete(id2));
259
264
  },
260
265
  setOrder: (order) => {
261
266
  dispatch2(slice.actions.setOrder(order));
@@ -290,7 +295,7 @@ var useOrderedClasses = () => {
290
295
  };
291
296
 
292
297
  // src/components/class-manager/delete-confirmation-dialog.tsx
293
- import * as React2 from "react";
298
+ import * as React3 from "react";
294
299
  import { createContext, useContext, useState as useState2 } from "react";
295
300
  import { AlertOctagonFilledIcon } from "@elementor/icons";
296
301
  import {
@@ -312,19 +317,19 @@ var DeleteConfirmationProvider = ({ children }) => {
312
317
  const closeDialog = () => {
313
318
  setDialogProps(null);
314
319
  };
315
- return /* @__PURE__ */ React2.createElement(context.Provider, { value: { openDialog, closeDialog, dialogProps } }, children, !!dialogProps && /* @__PURE__ */ React2.createElement(DeleteConfirmationDialog, { ...dialogProps }));
320
+ return /* @__PURE__ */ React3.createElement(context.Provider, { value: { openDialog, closeDialog, dialogProps } }, children, !!dialogProps && /* @__PURE__ */ React3.createElement(DeleteConfirmationDialog, { ...dialogProps }));
316
321
  };
317
322
  var TITLE_ID = "delete-class-dialog";
318
- var DeleteConfirmationDialog = ({ label, id }) => {
323
+ var DeleteConfirmationDialog = ({ label, id: id2 }) => {
319
324
  const { closeDialog } = useDeleteConfirmation();
320
325
  const onConfirm = () => {
321
- globalClassesStylesProvider.actions.delete(id);
326
+ globalClassesStylesProvider.actions.delete(id2);
322
327
  closeDialog();
323
328
  };
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(
329
+ 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
330
  "will permanently remove it from your project and may affect the design across all elements using it. This action cannot be undone.",
326
331
  "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"))));
332
+ ))), /* @__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
333
  };
329
334
  var useDeleteConfirmation = () => {
330
335
  const contextValue = useContext(context);
@@ -335,22 +340,22 @@ var useDeleteConfirmation = () => {
335
340
  };
336
341
 
337
342
  // src/components/class-manager/sortable.tsx
338
- import * as React3 from "react";
343
+ import * as React4 from "react";
339
344
  import { GripVerticalIcon } from "@elementor/icons";
340
345
  import {
341
346
  Box as Box2,
342
- Paper,
343
347
  styled,
344
348
  UnstableSortableItem,
345
349
  UnstableSortableProvider
346
350
  } 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(
351
+ var SortableProvider = (props) => /* @__PURE__ */ React4.createElement(UnstableSortableProvider, { restrictAxis: true, variant: "static", dragPlaceholderStyle: { opacity: "1" }, ...props });
352
+ var SortableTrigger = (props) => /* @__PURE__ */ React4.createElement(StyledSortableTrigger, { ...props, role: "button", className: "class-item-sortable-trigger" }, /* @__PURE__ */ React4.createElement(GripVerticalIcon, { fontSize: "tiny" }));
353
+ var SortableItem = ({ children, id: id2, ...props }) => {
354
+ return /* @__PURE__ */ React4.createElement(
351
355
  UnstableSortableItem,
352
356
  {
353
- id,
357
+ ...props,
358
+ id: id2,
354
359
  render: ({
355
360
  itemProps,
356
361
  isDragged,
@@ -358,42 +363,45 @@ var SortableItem = ({ children, id }) => {
358
363
  itemStyle,
359
364
  triggerStyle,
360
365
  dropIndicationStyle,
361
- showDropIndication
366
+ showDropIndication,
367
+ isDragOverlay,
368
+ isDragPlaceholder
362
369
  }) => {
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
- }));
370
+ return /* @__PURE__ */ React4.createElement(
371
+ Box2,
372
+ {
373
+ ...itemProps,
374
+ style: itemStyle,
375
+ component: "li",
376
+ role: "listitem",
377
+ sx: {
378
+ backgroundColor: isDragOverlay ? "background.paper" : void 0
379
+ }
380
+ },
381
+ children({
382
+ itemProps,
383
+ isDragged,
384
+ triggerProps,
385
+ itemStyle,
386
+ triggerStyle,
387
+ isDragPlaceholder
388
+ }),
389
+ showDropIndication && /* @__PURE__ */ React4.createElement(SortableItemIndicator, { style: dropIndicationStyle })
390
+ );
372
391
  }
373
392
  }
374
393
  );
375
394
  };
376
- var StyledSortableItem = styled(Paper)`
377
- position: relative;
378
-
379
- &:hover {
380
- & .class-item-sortable-trigger {
381
- visibility: visible;
382
- }
383
- }
384
-
385
- & .class-item-sortable-trigger {
386
- visibility: hidden;
387
- position: absolute;
388
- left: 0;
389
- top: 50%;
390
- transform: translate( -75%, -50% );
391
- }
392
- `;
395
+ var StyledSortableTrigger = styled("div")(({ theme }) => ({
396
+ position: "absolute",
397
+ left: 0,
398
+ top: "50%",
399
+ transform: `translate( -${theme.spacing(1.5)}, -50% )`,
400
+ color: theme.palette.action.active
401
+ }));
393
402
  var SortableItemIndicator = styled(Box2)`
394
403
  width: 100%;
395
- height: 3px;
396
- border-radius: ${({ theme }) => theme.spacing(0.5)};
404
+ height: 1px;
397
405
  background-color: ${({ theme }) => theme.palette.text.primary};
398
406
  `;
399
407
 
@@ -402,21 +410,22 @@ var GlobalClassesList = () => {
402
410
  const cssClasses = useOrderedClasses();
403
411
  const [classesOrder, reorderClasses] = useReorder();
404
412
  if (!cssClasses?.length) {
405
- return /* @__PURE__ */ React4.createElement(EmptyState, null);
413
+ return /* @__PURE__ */ React5.createElement(EmptyState, null);
406
414
  }
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 }) => {
415
+ 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
416
  const renameClass = (newLabel) => {
409
- globalClassesStylesProvider.actions.update({ label: newLabel, id });
417
+ globalClassesStylesProvider.actions.update({ label: newLabel, id: id2 });
410
418
  };
411
- return /* @__PURE__ */ React4.createElement(SortableItem, { key: id, id }, ({ isDragged, showDropIndication, dropIndicationStyle }) => /* @__PURE__ */ React4.createElement(
419
+ return /* @__PURE__ */ React5.createElement(SortableItem, { key: id2, id: id2 }, ({ isDragged, isDragPlaceholder, triggerProps, triggerStyle }) => /* @__PURE__ */ React5.createElement(
412
420
  ClassItem,
413
421
  {
414
- id,
422
+ id: id2,
415
423
  label,
416
424
  renameClass,
417
- selected: isDragged
418
- },
419
- showDropIndication && /* @__PURE__ */ React4.createElement(SortableItemIndicator, { style: dropIndicationStyle })
425
+ selected: isDragged,
426
+ disabled: isDragPlaceholder,
427
+ sortableTriggerProps: { ...triggerProps, style: triggerStyle }
428
+ }
420
429
  ));
421
430
  }))));
422
431
  };
@@ -427,13 +436,7 @@ var useReorder = () => {
427
436
  };
428
437
  return [order, reorder];
429
438
  };
430
- var ClassItem = ({
431
- id,
432
- label,
433
- renameClass,
434
- selected,
435
- children
436
- }) => {
439
+ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTriggerProps }) => {
437
440
  const {
438
441
  ref: editableRef,
439
442
  openEditMode,
@@ -450,99 +453,101 @@ var ClassItem = ({
450
453
  variant: "popover",
451
454
  disableAutoFocus: true
452
455
  });
453
- return /* @__PURE__ */ React4.createElement(Stack2, { direction: "row", alignItems: "center", gap: 1, flexGrow: 1, flexShrink: 0 }, /* @__PURE__ */ React4.createElement(
454
- StyledListItem,
456
+ const isSelected = (selected || popupState.isOpen) && !disabled;
457
+ return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(
458
+ StyledListItemButton,
455
459
  {
456
- component: "div",
457
- disablePadding: true,
460
+ dense: true,
458
461
  disableGutters: true,
459
- secondaryAction: /* @__PURE__ */ React4.createElement(
460
- Tooltip,
461
- {
462
- placement: "top",
463
- className: "class-item-more-actions",
464
- title: __4("More actions", "elementor")
465
- },
466
- /* @__PURE__ */ React4.createElement(IconButton, { size: "tiny", ...bindTrigger(popupState), "aria-label": "More actions" }, /* @__PURE__ */ React4.createElement(DotsVerticalIcon, { fontSize: "tiny" }))
467
- )
462
+ showActions: isSelected || isEditing,
463
+ shape: "rounded",
464
+ onDoubleClick: openEditMode,
465
+ selected: isSelected,
466
+ disabled,
467
+ focusVisibleClassName: "visible-class-item"
468
468
  },
469
- /* @__PURE__ */ React4.createElement(
470
- ListItemButton,
469
+ /* @__PURE__ */ React5.createElement(SortableTrigger, { ...sortableTriggerProps }),
470
+ /* @__PURE__ */ React5.createElement(Indicator, { isActive: isEditing, isError: !!error }, isEditing ? /* @__PURE__ */ React5.createElement(
471
+ EditableField,
471
472
  {
472
- dense: true,
473
- disableGutters: true,
474
- shape: "rounded",
475
- onDoubleClick: openEditMode,
476
- selected: selected || popupState.isOpen,
477
- focusVisibleClassName: "visible-class-item",
478
- sx: {
479
- minHeight: "36px",
480
- display: "flex",
481
- "&.visible-class-item": {
482
- boxShadow: "none !important"
483
- }
484
- }
473
+ ref: editableRef,
474
+ error,
475
+ as: Typography3,
476
+ variant: "caption",
477
+ ...getEditableProps()
478
+ }
479
+ ) : /* @__PURE__ */ React5.createElement(EllipsisWithTooltip, { title: label, as: Typography3, variant: "caption" })),
480
+ /* @__PURE__ */ React5.createElement(
481
+ Tooltip,
482
+ {
483
+ placement: "top",
484
+ className: "class-item-more-actions",
485
+ title: __4("More actions", "elementor")
485
486
  },
486
- /* @__PURE__ */ React4.createElement(Indicator, { isActive: isEditing, isError: !!error }, isEditing ? /* @__PURE__ */ React4.createElement(
487
- EditableField,
488
- {
489
- ref: editableRef,
490
- error,
491
- as: Typography3,
492
- variant: "caption",
493
- ...getEditableProps()
487
+ /* @__PURE__ */ React5.createElement(IconButton, { size: "tiny", ...bindTrigger(popupState), "aria-label": "More actions" }, /* @__PURE__ */ React5.createElement(DotsVerticalIcon, { fontSize: "tiny" }))
488
+ )
489
+ ), /* @__PURE__ */ React5.createElement(
490
+ Menu,
491
+ {
492
+ ...bindMenu(popupState),
493
+ anchorOrigin: {
494
+ vertical: "bottom",
495
+ horizontal: "right"
496
+ },
497
+ transformOrigin: {
498
+ vertical: "top",
499
+ horizontal: "right"
500
+ }
501
+ },
502
+ /* @__PURE__ */ React5.createElement(
503
+ MenuItem,
504
+ {
505
+ sx: { minWidth: "160px" },
506
+ onClick: () => {
507
+ popupState.close();
508
+ openEditMode();
494
509
  }
495
- ) : /* @__PURE__ */ React4.createElement(EllipsisWithTooltip, { title: label, as: Typography3, variant: "caption" }))
510
+ },
511
+ /* @__PURE__ */ React5.createElement(ListItemText, { primary: __4("Rename", "elementor") })
496
512
  ),
497
- children,
498
- /* @__PURE__ */ React4.createElement(
499
- Menu,
513
+ /* @__PURE__ */ React5.createElement(
514
+ MenuItem,
500
515
  {
501
- ...bindMenu(popupState),
502
- anchorOrigin: {
503
- vertical: "bottom",
504
- horizontal: "right"
505
- },
506
- transformOrigin: {
507
- vertical: "top",
508
- horizontal: "right"
516
+ onClick: () => {
517
+ popupState.close();
518
+ openDialog({ id: id2, label });
509
519
  }
510
520
  },
511
- /* @__PURE__ */ React4.createElement(
512
- MenuItem,
513
- {
514
- sx: { minWidth: "160px" },
515
- onClick: () => {
516
- popupState.close();
517
- openEditMode();
518
- }
519
- },
520
- /* @__PURE__ */ React4.createElement(ListItemText, { primary: __4("Rename", "elementor") })
521
- ),
522
- /* @__PURE__ */ React4.createElement(
523
- MenuItem,
524
- {
525
- onClick: () => {
526
- popupState.close();
527
- openDialog({ id, label });
528
- }
529
- },
530
- /* @__PURE__ */ React4.createElement(ListItemText, { primary: __4("Delete", "elementor"), sx: { color: "error.light" } })
531
- )
521
+ /* @__PURE__ */ React5.createElement(ListItemText, { primary: __4("Delete", "elementor"), sx: { color: "error.light" } })
532
522
  )
533
523
  ));
534
524
  };
535
- var StyledListItem = styled2(ListItem)`
536
- .class-item-more-actions {
537
- visibility: hidden;
525
+ var StyledListItemButton = styled2(ListItemButton, {
526
+ shouldForwardProp: (prop) => !["showActions"].includes(prop)
527
+ })(
528
+ ({ showActions }) => `
529
+ min-height: 36px;
530
+
531
+ &.visible-class-item {
532
+ box-shadow: none !important;
533
+ }
534
+
535
+ .class-item-more-actions, .class-item-sortable-trigger {
536
+ visibility: ${showActions ? "visible" : "hidden"};
537
+ }
538
+
539
+ .class-item-sortable-trigger {
540
+ visibility: ${showActions ? "visible" : "hidden"};
538
541
  }
539
- &:hover {
540
- .class-item-more-actions {
542
+
543
+ &:hover&:not(:disabled) {
544
+ .class-item-more-actions, .class-item-sortable-trigger {
541
545
  visibility: visible;
542
546
  }
543
547
  }
544
- `;
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(
548
+ `
549
+ );
550
+ 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
551
  "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
552
  "elementor"
548
553
  )));
@@ -560,7 +565,8 @@ var Indicator = styled2(Box3, {
560
565
  borderRadius: theme.spacing(0.5),
561
566
  border: getIndicatorBorder({ isActive, isError, theme }),
562
567
  padding: `0 ${theme.spacing(1)}`,
563
- marginLeft: isActive ? theme.spacing(1) : 0
568
+ marginLeft: isActive ? theme.spacing(1) : 0,
569
+ minWidth: 0
564
570
  }));
565
571
  var getIndicatorBorder = ({ isActive, isError, theme }) => {
566
572
  if (isError) {
@@ -582,7 +588,7 @@ var validateLabel = (newLabel) => {
582
588
  };
583
589
 
584
590
  // src/components/class-manager/save-changes-dialog.tsx
585
- import * as React5 from "react";
591
+ import * as React6 from "react";
586
592
  import { useState as useState3 } from "react";
587
593
  import { AlertTriangleFilledIcon } from "@elementor/icons";
588
594
  import {
@@ -594,10 +600,10 @@ import {
594
600
  DialogTitle as DialogTitle2
595
601
  } from "@elementor/ui";
596
602
  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 });
603
+ var SaveChangesDialog = ({ children, onClose }) => /* @__PURE__ */ React6.createElement(Dialog2, { open: true, onClose, "aria-labelledby": TITLE_ID2, maxWidth: "xs" }, children);
604
+ 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);
605
+ var SaveChangesDialogContent = ({ children }) => /* @__PURE__ */ React6.createElement(DialogContent2, null, children);
606
+ var SaveChangesDialogContentText = (props) => /* @__PURE__ */ React6.createElement(DialogContentText2, { variant: "body2", color: "textPrimary", display: "flex", flexDirection: "column", ...props });
601
607
  var SaveChangesDialogActions = ({ actions }) => {
602
608
  const [isConfirming, setIsConfirming] = useState3(false);
603
609
  const { cancel, confirm } = actions;
@@ -606,7 +612,7 @@ var SaveChangesDialogActions = ({ actions }) => {
606
612
  await confirm.action();
607
613
  setIsConfirming(false);
608
614
  };
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));
615
+ 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
616
  };
611
617
  SaveChangesDialog.Title = SaveChangesDialogTitle;
612
618
  SaveChangesDialog.Content = SaveChangesDialogContent;
@@ -620,15 +626,20 @@ var useDialog = () => {
620
626
  };
621
627
 
622
628
  // src/components/class-manager/class-manager-panel.tsx
629
+ var id = "global-classes-manager";
623
630
  var { panel, usePanelActions } = createPanel({
624
- id: "class-manager-panel",
625
- component: ClassManagerPanel
631
+ id,
632
+ component: ClassManagerPanel,
633
+ onOpen: () => changeEditMode(id),
634
+ onClose: () => changeEditMode("edit"),
635
+ allowedEditModes: ["edit", id]
626
636
  });
627
637
  function ClassManagerPanel() {
628
638
  const isDirty3 = useDirtyState();
629
639
  const { close: closePanel } = usePanelActions();
630
640
  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(
641
+ usePreventUnload();
642
+ 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
643
  CloseButton,
633
644
  {
634
645
  sx: { marginLeft: "auto" },
@@ -640,7 +651,7 @@ function ClassManagerPanel() {
640
651
  closePanel();
641
652
  }
642
653
  }
643
- ))), /* @__PURE__ */ React6.createElement(PanelBody, { px: 2 }, /* @__PURE__ */ React6.createElement(GlobalClassesList, null)), /* @__PURE__ */ React6.createElement(PanelFooter, null, /* @__PURE__ */ React6.createElement(
654
+ ))), /* @__PURE__ */ React7.createElement(PanelBody, { px: 2 }, /* @__PURE__ */ React7.createElement(GlobalClassesList, null)), /* @__PURE__ */ React7.createElement(PanelFooter, null, /* @__PURE__ */ React7.createElement(
644
655
  Button3,
645
656
  {
646
657
  fullWidth: true,
@@ -651,7 +662,7 @@ function ClassManagerPanel() {
651
662
  onClick: publishGlobalClasses
652
663
  },
653
664
  __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(
665
+ )))), /* @__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
666
  SaveChangesDialog.Actions,
656
667
  {
657
668
  actions: {
@@ -671,8 +682,22 @@ function ClassManagerPanel() {
671
682
  }
672
683
  )));
673
684
  }
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"))));
685
+ var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */ React7.createElement(IconButton2, { size: "small", color: "secondary", onClick: onClose, "aria-label": "Close", ...props }, /* @__PURE__ */ React7.createElement(XIcon, { fontSize: "small" }));
686
+ 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"))));
687
+ var usePreventUnload = () => {
688
+ const isDirty3 = useDirtyState();
689
+ useEffect(() => {
690
+ const handleBeforeUnload = (event) => {
691
+ if (isDirty3) {
692
+ event.preventDefault();
693
+ }
694
+ };
695
+ window.addEventListener("beforeunload", handleBeforeUnload);
696
+ return () => {
697
+ window.removeEventListener("beforeunload", handleBeforeUnload);
698
+ };
699
+ }, [isDirty3]);
700
+ };
676
701
 
677
702
  // src/components/class-manager/class-manager-button.tsx
678
703
  var ClassManagerButton = () => {
@@ -687,10 +712,10 @@ var ClassManagerButton = () => {
687
712
  }
688
713
  openPanel();
689
714
  };
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(
715
+ 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
716
  "Save your changes before moving to the class manager to ensure all updates are applied and saved.",
692
717
  "elementor"
693
- )), /* @__PURE__ */ React7.createElement(SaveChangesDialog.ContentText, null, __6("If you leave without saving, all changes will be discarded.", "elementor"))), /* @__PURE__ */ React7.createElement(
718
+ )), /* @__PURE__ */ React8.createElement(SaveChangesDialog.ContentText, null, __6("If you leave without saving, all changes will be discarded.", "elementor"))), /* @__PURE__ */ React8.createElement(
694
719
  SaveChangesDialog.Actions,
695
720
  {
696
721
  actions: {
@@ -712,11 +737,11 @@ var ClassManagerButton = () => {
712
737
  };
713
738
 
714
739
  // src/components/populate-store.tsx
715
- import { useEffect } from "react";
740
+ import { useEffect as useEffect2 } from "react";
716
741
  import { __useDispatch as useDispatch } from "@elementor/store";
717
742
  function PopulateStore() {
718
743
  const dispatch3 = useDispatch();
719
- useEffect(() => {
744
+ useEffect2(() => {
720
745
  apiClient.all().then((res) => {
721
746
  const { data, meta } = res.data;
722
747
  dispatch3(slice.actions.init({ items: data, order: meta.order }));