@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.js CHANGED
@@ -27,20 +27,21 @@ var import_editor = require("@elementor/editor");
27
27
  var import_editor_editing_panel = require("@elementor/editor-editing-panel");
28
28
  var import_editor_panels2 = require("@elementor/editor-panels");
29
29
  var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
30
- var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
30
+ var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
31
31
  var import_store16 = require("@elementor/store");
32
32
 
33
33
  // src/components/class-manager/class-manager-button.tsx
34
- var React7 = __toESM(require("react"));
34
+ var React8 = __toESM(require("react"));
35
35
  var import_editor_documents = require("@elementor/editor-documents");
36
- var import_icons6 = require("@elementor/icons");
37
36
  var import_ui7 = require("@elementor/ui");
38
37
  var import_i18n6 = require("@wordpress/i18n");
39
38
 
40
39
  // src/components/class-manager/class-manager-panel.tsx
41
- var React6 = __toESM(require("react"));
40
+ var React7 = __toESM(require("react"));
41
+ var import_react4 = require("react");
42
42
  var import_editor_panels = require("@elementor/editor-panels");
43
- var import_icons5 = require("@elementor/icons");
43
+ var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
44
+ var import_icons6 = require("@elementor/icons");
44
45
  var import_ui6 = require("@elementor/ui");
45
46
  var import_i18n5 = require("@wordpress/i18n");
46
47
 
@@ -85,8 +86,8 @@ var slice = (0, import_store.__createSlice)({
85
86
  state.isDirty = true;
86
87
  },
87
88
  delete(state, { payload }) {
88
- state.items = Object.fromEntries(Object.entries(state.items).filter(([id]) => id !== payload));
89
- state.order = state.order.filter((id) => id !== payload);
89
+ state.items = Object.fromEntries(Object.entries(state.items).filter(([id2]) => id2 !== payload));
90
+ state.order = state.order.filter((id2) => id2 !== payload);
90
91
  state.isDirty = true;
91
92
  },
92
93
  setOrder(state, { payload }) {
@@ -127,9 +128,9 @@ var selectGlobalClasses = (state) => state[SLICE_NAME].items;
127
128
  var selectOrderedClasses = (0, import_store.__createSelector)(
128
129
  selectGlobalClasses,
129
130
  selectOrder,
130
- (items, order) => order.map((id) => items[id])
131
+ (items, order) => order.map((id2) => items[id2])
131
132
  );
132
- var selectClass = (state, id) => state[SLICE_NAME].items[id] ?? null;
133
+ var selectClass = (state, id2) => state[SLICE_NAME].items[id2] ?? null;
133
134
  var selectIsDirty = (state) => state.globalClasses.isDirty;
134
135
 
135
136
  // src/hooks/use-dirty-state.ts
@@ -200,11 +201,16 @@ var IntroductionContent = () => {
200
201
  ))));
201
202
  };
202
203
 
204
+ // src/components/class-manager/flipped-color-swatch-icon.tsx
205
+ var React2 = __toESM(require("react"));
206
+ var import_icons = require("@elementor/icons");
207
+ var FlippedColorSwatchIcon = ({ sx, ...props }) => /* @__PURE__ */ React2.createElement(import_icons.ColorSwatchIcon, { sx: { transform: "rotate(90deg)", ...sx }, ...props });
208
+
203
209
  // src/components/class-manager/global-classes-list.tsx
204
- var React4 = __toESM(require("react"));
210
+ var React5 = __toESM(require("react"));
205
211
  var import_editor_styles_repository = require("@elementor/editor-styles-repository");
206
212
  var import_editor_ui2 = require("@elementor/editor-ui");
207
- var import_icons3 = require("@elementor/icons");
213
+ var import_icons4 = require("@elementor/icons");
208
214
  var import_ui4 = require("@elementor/ui");
209
215
  var import_i18n4 = require("@wordpress/i18n");
210
216
 
@@ -217,7 +223,7 @@ var globalClassesStylesProvider = {
217
223
  priority: 30,
218
224
  actions: {
219
225
  get: () => selectOrderedClasses((0, import_store6.__getState)()),
220
- getById: (id) => selectClass((0, import_store6.__getState)(), id),
226
+ getById: (id2) => selectClass((0, import_store6.__getState)(), id2),
221
227
  create: (label) => {
222
228
  const classes = selectGlobalClasses((0, import_store6.__getState)());
223
229
  const existingLabels = Object.values(classes).map((style) => style.label);
@@ -225,16 +231,16 @@ var globalClassesStylesProvider = {
225
231
  throw new GlobalClassLabelAlreadyExistsError({ context: { label } });
226
232
  }
227
233
  const existingIds = Object.keys(classes);
228
- const id = (0, import_editor_styles2.generateId)("g-", existingIds);
234
+ const id2 = (0, import_editor_styles2.generateId)("g-", existingIds);
229
235
  (0, import_store6.__dispatch)(
230
236
  slice.actions.add({
231
- id,
237
+ id: id2,
232
238
  type: "class",
233
239
  label,
234
240
  variants: []
235
241
  })
236
242
  );
237
- return id;
243
+ return id2;
238
244
  },
239
245
  update: (payload) => {
240
246
  (0, import_store6.__dispatch)(
@@ -243,8 +249,8 @@ var globalClassesStylesProvider = {
243
249
  })
244
250
  );
245
251
  },
246
- delete: (id) => {
247
- (0, import_store6.__dispatch)(slice.actions.delete(id));
252
+ delete: (id2) => {
253
+ (0, import_store6.__dispatch)(slice.actions.delete(id2));
248
254
  },
249
255
  setOrder: (order) => {
250
256
  (0, import_store6.__dispatch)(slice.actions.setOrder(order));
@@ -279,9 +285,9 @@ var useOrderedClasses = () => {
279
285
  };
280
286
 
281
287
  // src/components/class-manager/delete-confirmation-dialog.tsx
282
- var React2 = __toESM(require("react"));
288
+ var React3 = __toESM(require("react"));
283
289
  var import_react2 = require("react");
284
- var import_icons = require("@elementor/icons");
290
+ var import_icons2 = require("@elementor/icons");
285
291
  var import_ui2 = require("@elementor/ui");
286
292
  var import_i18n3 = require("@wordpress/i18n");
287
293
  var context = (0, import_react2.createContext)(null);
@@ -293,19 +299,19 @@ var DeleteConfirmationProvider = ({ children }) => {
293
299
  const closeDialog = () => {
294
300
  setDialogProps(null);
295
301
  };
296
- return /* @__PURE__ */ React2.createElement(context.Provider, { value: { openDialog, closeDialog, dialogProps } }, children, !!dialogProps && /* @__PURE__ */ React2.createElement(DeleteConfirmationDialog, { ...dialogProps }));
302
+ return /* @__PURE__ */ React3.createElement(context.Provider, { value: { openDialog, closeDialog, dialogProps } }, children, !!dialogProps && /* @__PURE__ */ React3.createElement(DeleteConfirmationDialog, { ...dialogProps }));
297
303
  };
298
304
  var TITLE_ID = "delete-class-dialog";
299
- var DeleteConfirmationDialog = ({ label, id }) => {
305
+ var DeleteConfirmationDialog = ({ label, id: id2 }) => {
300
306
  const { closeDialog } = useDeleteConfirmation();
301
307
  const onConfirm = () => {
302
- globalClassesStylesProvider.actions.delete(id);
308
+ globalClassesStylesProvider.actions.delete(id2);
303
309
  closeDialog();
304
310
  };
305
- return /* @__PURE__ */ React2.createElement(import_ui2.Dialog, { open: true, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React2.createElement(import_ui2.DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React2.createElement(import_icons.AlertOctagonFilledIcon, { color: "error" }), (0, import_i18n3.__)("Delete global class", "elementor")), /* @__PURE__ */ React2.createElement(import_ui2.DialogContent, null, /* @__PURE__ */ React2.createElement(import_ui2.DialogContentText, { variant: "body2", color: "textPrimary" }, (0, import_i18n3.__)("Deleting", "elementor"), /* @__PURE__ */ React2.createElement(import_ui2.Typography, { variant: "subtitle2", component: "span" }, "\xA0", label, "\xA0"), (0, import_i18n3.__)(
311
+ 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 global 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.__)(
306
312
  "will permanently remove it from your project and may affect the design across all elements using it. This action cannot be undone.",
307
313
  "elementor"
308
- ))), /* @__PURE__ */ React2.createElement(import_ui2.DialogActions, null, /* @__PURE__ */ React2.createElement(import_ui2.Button, { color: "secondary", onClick: closeDialog }, (0, import_i18n3.__)("Cancel", "elementor")), /* @__PURE__ */ React2.createElement(import_ui2.Button, { variant: "contained", color: "error", onClick: onConfirm }, (0, import_i18n3.__)("Delete", "elementor"))));
314
+ ))), /* @__PURE__ */ React3.createElement(import_ui2.DialogActions, null, /* @__PURE__ */ React3.createElement(import_ui2.Button, { color: "secondary", onClick: closeDialog }, (0, import_i18n3.__)("Cancel", "elementor")), /* @__PURE__ */ React3.createElement(import_ui2.Button, { variant: "contained", color: "error", onClick: onConfirm }, (0, import_i18n3.__)("Delete", "elementor"))));
309
315
  };
310
316
  var useDeleteConfirmation = () => {
311
317
  const contextValue = (0, import_react2.useContext)(context);
@@ -316,16 +322,17 @@ var useDeleteConfirmation = () => {
316
322
  };
317
323
 
318
324
  // src/components/class-manager/sortable.tsx
319
- var React3 = __toESM(require("react"));
320
- var import_icons2 = require("@elementor/icons");
325
+ var React4 = __toESM(require("react"));
326
+ var import_icons3 = require("@elementor/icons");
321
327
  var import_ui3 = require("@elementor/ui");
322
- var SortableProvider = (props) => /* @__PURE__ */ React3.createElement(import_ui3.UnstableSortableProvider, { restrictAxis: true, variant: "static", dragPlaceholderStyle: { opacity: "1" }, ...props });
323
- var SortableTrigger = (props) => /* @__PURE__ */ React3.createElement("div", { ...props, role: "button", className: "class-item-sortable-trigger" }, /* @__PURE__ */ React3.createElement(import_icons2.GripVerticalIcon, { fontSize: "tiny" }));
324
- var SortableItem = ({ children, id }) => {
325
- return /* @__PURE__ */ React3.createElement(
328
+ var SortableProvider = (props) => /* @__PURE__ */ React4.createElement(import_ui3.UnstableSortableProvider, { restrictAxis: true, variant: "static", dragPlaceholderStyle: { opacity: "1" }, ...props });
329
+ var SortableTrigger = (props) => /* @__PURE__ */ React4.createElement(StyledSortableTrigger, { ...props, role: "button", className: "class-item-sortable-trigger" }, /* @__PURE__ */ React4.createElement(import_icons3.GripVerticalIcon, { fontSize: "tiny" }));
330
+ var SortableItem = ({ children, id: id2, ...props }) => {
331
+ return /* @__PURE__ */ React4.createElement(
326
332
  import_ui3.UnstableSortableItem,
327
333
  {
328
- id,
334
+ ...props,
335
+ id: id2,
329
336
  render: ({
330
337
  itemProps,
331
338
  isDragged,
@@ -333,42 +340,45 @@ var SortableItem = ({ children, id }) => {
333
340
  itemStyle,
334
341
  triggerStyle,
335
342
  dropIndicationStyle,
336
- showDropIndication
343
+ showDropIndication,
344
+ isDragOverlay,
345
+ isDragPlaceholder
337
346
  }) => {
338
- return /* @__PURE__ */ React3.createElement(StyledSortableItem, { ...itemProps, elevation: 0, sx: itemStyle, role: "listitem" }, /* @__PURE__ */ React3.createElement(SortableTrigger, { ...triggerProps, style: triggerStyle }), children({
339
- itemProps,
340
- isDragged,
341
- triggerProps,
342
- itemStyle,
343
- triggerStyle,
344
- dropIndicationStyle,
345
- showDropIndication
346
- }));
347
+ return /* @__PURE__ */ React4.createElement(
348
+ import_ui3.Box,
349
+ {
350
+ ...itemProps,
351
+ style: itemStyle,
352
+ component: "li",
353
+ role: "listitem",
354
+ sx: {
355
+ backgroundColor: isDragOverlay ? "background.paper" : void 0
356
+ }
357
+ },
358
+ children({
359
+ itemProps,
360
+ isDragged,
361
+ triggerProps,
362
+ itemStyle,
363
+ triggerStyle,
364
+ isDragPlaceholder
365
+ }),
366
+ showDropIndication && /* @__PURE__ */ React4.createElement(SortableItemIndicator, { style: dropIndicationStyle })
367
+ );
347
368
  }
348
369
  }
349
370
  );
350
371
  };
351
- var StyledSortableItem = (0, import_ui3.styled)(import_ui3.Paper)`
352
- position: relative;
353
-
354
- &:hover {
355
- & .class-item-sortable-trigger {
356
- visibility: visible;
357
- }
358
- }
359
-
360
- & .class-item-sortable-trigger {
361
- visibility: hidden;
362
- position: absolute;
363
- left: 0;
364
- top: 50%;
365
- transform: translate( -75%, -50% );
366
- }
367
- `;
372
+ var StyledSortableTrigger = (0, import_ui3.styled)("div")(({ theme }) => ({
373
+ position: "absolute",
374
+ left: 0,
375
+ top: "50%",
376
+ transform: `translate( -${theme.spacing(1.5)}, -50% )`,
377
+ color: theme.palette.action.active
378
+ }));
368
379
  var SortableItemIndicator = (0, import_ui3.styled)(import_ui3.Box)`
369
380
  width: 100%;
370
- height: 3px;
371
- border-radius: ${({ theme }) => theme.spacing(0.5)};
381
+ height: 1px;
372
382
  background-color: ${({ theme }) => theme.palette.text.primary};
373
383
  `;
374
384
 
@@ -377,21 +387,22 @@ var GlobalClassesList = () => {
377
387
  const cssClasses = useOrderedClasses();
378
388
  const [classesOrder, reorderClasses] = useReorder();
379
389
  if (!cssClasses?.length) {
380
- return /* @__PURE__ */ React4.createElement(EmptyState, null);
390
+ return /* @__PURE__ */ React5.createElement(EmptyState, null);
381
391
  }
382
- return /* @__PURE__ */ React4.createElement(DeleteConfirmationProvider, null, /* @__PURE__ */ React4.createElement(import_ui4.List, { sx: { display: "flex", flexDirection: "column", gap: 0.5 } }, /* @__PURE__ */ React4.createElement(SortableProvider, { value: classesOrder, onChange: reorderClasses }, cssClasses?.map(({ id, label }) => {
392
+ 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 }) => {
383
393
  const renameClass = (newLabel) => {
384
- globalClassesStylesProvider.actions.update({ label: newLabel, id });
394
+ globalClassesStylesProvider.actions.update({ label: newLabel, id: id2 });
385
395
  };
386
- return /* @__PURE__ */ React4.createElement(SortableItem, { key: id, id }, ({ isDragged, showDropIndication, dropIndicationStyle }) => /* @__PURE__ */ React4.createElement(
396
+ return /* @__PURE__ */ React5.createElement(SortableItem, { key: id2, id: id2 }, ({ isDragged, isDragPlaceholder, triggerProps, triggerStyle }) => /* @__PURE__ */ React5.createElement(
387
397
  ClassItem,
388
398
  {
389
- id,
399
+ id: id2,
390
400
  label,
391
401
  renameClass,
392
- selected: isDragged
393
- },
394
- showDropIndication && /* @__PURE__ */ React4.createElement(SortableItemIndicator, { style: dropIndicationStyle })
402
+ selected: isDragged,
403
+ disabled: isDragPlaceholder,
404
+ sortableTriggerProps: { ...triggerProps, style: triggerStyle }
405
+ }
395
406
  ));
396
407
  }))));
397
408
  };
@@ -402,13 +413,7 @@ var useReorder = () => {
402
413
  };
403
414
  return [order, reorder];
404
415
  };
405
- var ClassItem = ({
406
- id,
407
- label,
408
- renameClass,
409
- selected,
410
- children
411
- }) => {
416
+ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTriggerProps }) => {
412
417
  const {
413
418
  ref: editableRef,
414
419
  openEditMode,
@@ -425,99 +430,101 @@ var ClassItem = ({
425
430
  variant: "popover",
426
431
  disableAutoFocus: true
427
432
  });
428
- return /* @__PURE__ */ React4.createElement(import_ui4.Stack, { direction: "row", alignItems: "center", gap: 1, flexGrow: 1, flexShrink: 0 }, /* @__PURE__ */ React4.createElement(
429
- StyledListItem,
433
+ const isSelected = (selected || popupState.isOpen) && !disabled;
434
+ return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(
435
+ StyledListItemButton,
430
436
  {
431
- component: "div",
432
- disablePadding: true,
437
+ dense: true,
433
438
  disableGutters: true,
434
- secondaryAction: /* @__PURE__ */ React4.createElement(
435
- import_ui4.Tooltip,
436
- {
437
- placement: "top",
438
- className: "class-item-more-actions",
439
- title: (0, import_i18n4.__)("More actions", "elementor")
440
- },
441
- /* @__PURE__ */ React4.createElement(import_ui4.IconButton, { size: "tiny", ...(0, import_ui4.bindTrigger)(popupState), "aria-label": "More actions" }, /* @__PURE__ */ React4.createElement(import_icons3.DotsVerticalIcon, { fontSize: "tiny" }))
442
- )
439
+ showActions: isSelected || isEditing,
440
+ shape: "rounded",
441
+ onDoubleClick: openEditMode,
442
+ selected: isSelected,
443
+ disabled,
444
+ focusVisibleClassName: "visible-class-item"
443
445
  },
444
- /* @__PURE__ */ React4.createElement(
445
- import_ui4.ListItemButton,
446
+ /* @__PURE__ */ React5.createElement(SortableTrigger, { ...sortableTriggerProps }),
447
+ /* @__PURE__ */ React5.createElement(Indicator, { isActive: isEditing, isError: !!error }, isEditing ? /* @__PURE__ */ React5.createElement(
448
+ import_editor_ui2.EditableField,
446
449
  {
447
- dense: true,
448
- disableGutters: true,
449
- shape: "rounded",
450
- onDoubleClick: openEditMode,
451
- selected: selected || popupState.isOpen,
452
- focusVisibleClassName: "visible-class-item",
453
- sx: {
454
- minHeight: "36px",
455
- display: "flex",
456
- "&.visible-class-item": {
457
- boxShadow: "none !important"
458
- }
459
- }
450
+ ref: editableRef,
451
+ error,
452
+ as: import_ui4.Typography,
453
+ variant: "caption",
454
+ ...getEditableProps()
455
+ }
456
+ ) : /* @__PURE__ */ React5.createElement(import_editor_ui2.EllipsisWithTooltip, { title: label, as: import_ui4.Typography, variant: "caption" })),
457
+ /* @__PURE__ */ React5.createElement(
458
+ import_ui4.Tooltip,
459
+ {
460
+ placement: "top",
461
+ className: "class-item-more-actions",
462
+ title: (0, import_i18n4.__)("More actions", "elementor")
463
+ },
464
+ /* @__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" }))
465
+ )
466
+ ), /* @__PURE__ */ React5.createElement(
467
+ import_ui4.Menu,
468
+ {
469
+ ...(0, import_ui4.bindMenu)(popupState),
470
+ anchorOrigin: {
471
+ vertical: "bottom",
472
+ horizontal: "right"
460
473
  },
461
- /* @__PURE__ */ React4.createElement(Indicator, { isActive: isEditing, isError: !!error }, isEditing ? /* @__PURE__ */ React4.createElement(
462
- import_editor_ui2.EditableField,
463
- {
464
- ref: editableRef,
465
- error,
466
- as: import_ui4.Typography,
467
- variant: "caption",
468
- ...getEditableProps()
474
+ transformOrigin: {
475
+ vertical: "top",
476
+ horizontal: "right"
477
+ }
478
+ },
479
+ /* @__PURE__ */ React5.createElement(
480
+ import_ui4.MenuItem,
481
+ {
482
+ sx: { minWidth: "160px" },
483
+ onClick: () => {
484
+ popupState.close();
485
+ openEditMode();
469
486
  }
470
- ) : /* @__PURE__ */ React4.createElement(import_editor_ui2.EllipsisWithTooltip, { title: label, as: import_ui4.Typography, variant: "caption" }))
487
+ },
488
+ /* @__PURE__ */ React5.createElement(import_ui4.ListItemText, { primary: (0, import_i18n4.__)("Rename", "elementor") })
471
489
  ),
472
- children,
473
- /* @__PURE__ */ React4.createElement(
474
- import_ui4.Menu,
490
+ /* @__PURE__ */ React5.createElement(
491
+ import_ui4.MenuItem,
475
492
  {
476
- ...(0, import_ui4.bindMenu)(popupState),
477
- anchorOrigin: {
478
- vertical: "bottom",
479
- horizontal: "right"
480
- },
481
- transformOrigin: {
482
- vertical: "top",
483
- horizontal: "right"
493
+ onClick: () => {
494
+ popupState.close();
495
+ openDialog({ id: id2, label });
484
496
  }
485
497
  },
486
- /* @__PURE__ */ React4.createElement(
487
- import_ui4.MenuItem,
488
- {
489
- sx: { minWidth: "160px" },
490
- onClick: () => {
491
- popupState.close();
492
- openEditMode();
493
- }
494
- },
495
- /* @__PURE__ */ React4.createElement(import_ui4.ListItemText, { primary: (0, import_i18n4.__)("Rename", "elementor") })
496
- ),
497
- /* @__PURE__ */ React4.createElement(
498
- import_ui4.MenuItem,
499
- {
500
- onClick: () => {
501
- popupState.close();
502
- openDialog({ id, label });
503
- }
504
- },
505
- /* @__PURE__ */ React4.createElement(import_ui4.ListItemText, { primary: (0, import_i18n4.__)("Delete", "elementor"), sx: { color: "error.light" } })
506
- )
498
+ /* @__PURE__ */ React5.createElement(import_ui4.ListItemText, { primary: (0, import_i18n4.__)("Delete", "elementor"), sx: { color: "error.light" } })
507
499
  )
508
500
  ));
509
501
  };
510
- var StyledListItem = (0, import_ui4.styled)(import_ui4.ListItem)`
511
- .class-item-more-actions {
512
- visibility: hidden;
502
+ var StyledListItemButton = (0, import_ui4.styled)(import_ui4.ListItemButton, {
503
+ shouldForwardProp: (prop) => !["showActions"].includes(prop)
504
+ })(
505
+ ({ showActions }) => `
506
+ min-height: 36px;
507
+
508
+ &.visible-class-item {
509
+ box-shadow: none !important;
510
+ }
511
+
512
+ .class-item-more-actions, .class-item-sortable-trigger {
513
+ visibility: ${showActions ? "visible" : "hidden"};
514
+ }
515
+
516
+ .class-item-sortable-trigger {
517
+ visibility: ${showActions ? "visible" : "hidden"};
513
518
  }
514
- &:hover {
515
- .class-item-more-actions {
519
+
520
+ &:hover&:not(:disabled) {
521
+ .class-item-more-actions, .class-item-sortable-trigger {
516
522
  visibility: visible;
517
523
  }
518
524
  }
519
- `;
520
- var EmptyState = () => /* @__PURE__ */ React4.createElement(import_ui4.Stack, { alignItems: "center", gap: 3, pt: 4, px: 0.5 }, /* @__PURE__ */ React4.createElement(import_icons3.PhotoIcon, { fontSize: "large" }), /* @__PURE__ */ React4.createElement(StyledHeader, { variant: "subtitle2", component: "h2", color: "text.secondary" }, (0, import_i18n4.__)("No CSS classes created yet", "elementor")), /* @__PURE__ */ React4.createElement(import_ui4.Typography, { align: "center", variant: "caption", color: "text.secondary" }, (0, import_i18n4.__)(
525
+ `
526
+ );
527
+ 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.__)(
521
528
  "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.",
522
529
  "elementor"
523
530
  )));
@@ -535,7 +542,8 @@ var Indicator = (0, import_ui4.styled)(import_ui4.Box, {
535
542
  borderRadius: theme.spacing(0.5),
536
543
  border: getIndicatorBorder({ isActive, isError, theme }),
537
544
  padding: `0 ${theme.spacing(1)}`,
538
- marginLeft: isActive ? theme.spacing(1) : 0
545
+ marginLeft: isActive ? theme.spacing(1) : 0,
546
+ minWidth: 0
539
547
  }));
540
548
  var getIndicatorBorder = ({ isActive, isError, theme }) => {
541
549
  if (isError) {
@@ -557,15 +565,15 @@ var validateLabel = (newLabel) => {
557
565
  };
558
566
 
559
567
  // src/components/class-manager/save-changes-dialog.tsx
560
- var React5 = __toESM(require("react"));
568
+ var React6 = __toESM(require("react"));
561
569
  var import_react3 = require("react");
562
- var import_icons4 = require("@elementor/icons");
570
+ var import_icons5 = require("@elementor/icons");
563
571
  var import_ui5 = require("@elementor/ui");
564
572
  var TITLE_ID2 = "save-changes-dialog";
565
- var SaveChangesDialog = ({ children, onClose }) => /* @__PURE__ */ React5.createElement(import_ui5.Dialog, { open: true, onClose, "aria-labelledby": TITLE_ID2, maxWidth: "xs" }, children);
566
- var SaveChangesDialogTitle = ({ children }) => /* @__PURE__ */ React5.createElement(import_ui5.DialogTitle, { id: TITLE_ID2, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React5.createElement(import_icons4.AlertTriangleFilledIcon, { color: "secondary" }), children);
567
- var SaveChangesDialogContent = ({ children }) => /* @__PURE__ */ React5.createElement(import_ui5.DialogContent, null, children);
568
- var SaveChangesDialogContentText = (props) => /* @__PURE__ */ React5.createElement(import_ui5.DialogContentText, { variant: "body2", color: "textPrimary", display: "flex", flexDirection: "column", ...props });
573
+ var SaveChangesDialog = ({ children, onClose }) => /* @__PURE__ */ React6.createElement(import_ui5.Dialog, { open: true, onClose, "aria-labelledby": TITLE_ID2, maxWidth: "xs" }, children);
574
+ 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);
575
+ var SaveChangesDialogContent = ({ children }) => /* @__PURE__ */ React6.createElement(import_ui5.DialogContent, null, children);
576
+ var SaveChangesDialogContentText = (props) => /* @__PURE__ */ React6.createElement(import_ui5.DialogContentText, { variant: "body2", color: "textPrimary", display: "flex", flexDirection: "column", ...props });
569
577
  var SaveChangesDialogActions = ({ actions }) => {
570
578
  const [isConfirming, setIsConfirming] = (0, import_react3.useState)(false);
571
579
  const { cancel, confirm } = actions;
@@ -574,7 +582,7 @@ var SaveChangesDialogActions = ({ actions }) => {
574
582
  await confirm.action();
575
583
  setIsConfirming(false);
576
584
  };
577
- return /* @__PURE__ */ React5.createElement(import_ui5.DialogActions, null, /* @__PURE__ */ React5.createElement(import_ui5.Button, { variant: "text", color: "secondary", onClick: cancel.action }, cancel.label), /* @__PURE__ */ React5.createElement(import_ui5.Button, { variant: "contained", color: "secondary", onClick: onConfirm, loading: isConfirming }, confirm.label));
585
+ 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));
578
586
  };
579
587
  SaveChangesDialog.Title = SaveChangesDialogTitle;
580
588
  SaveChangesDialog.Content = SaveChangesDialogContent;
@@ -588,15 +596,20 @@ var useDialog = () => {
588
596
  };
589
597
 
590
598
  // src/components/class-manager/class-manager-panel.tsx
599
+ var id = "global-classes-manager";
591
600
  var { panel, usePanelActions } = (0, import_editor_panels.__createPanel)({
592
- id: "class-manager-panel",
593
- component: ClassManagerPanel
601
+ id,
602
+ component: ClassManagerPanel,
603
+ onOpen: () => (0, import_editor_v1_adapters.changeEditMode)(id),
604
+ onClose: () => (0, import_editor_v1_adapters.changeEditMode)("edit"),
605
+ allowedEditModes: ["edit", id]
594
606
  });
595
607
  function ClassManagerPanel() {
596
608
  const isDirty3 = useDirtyState();
597
609
  const { close: closePanel } = usePanelActions();
598
610
  const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
599
- return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(import_ui6.ErrorBoundary, { fallback: /* @__PURE__ */ React6.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React6.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React6.createElement(import_editor_panels.PanelHeader, null, /* @__PURE__ */ React6.createElement(import_ui6.Stack, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React6.createElement(import_editor_panels.PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React6.createElement(import_icons5.ColorSwatchIcon, { fontSize: "inherit", sx: { transform: "rotate(90deg)" } }), (0, import_i18n5.__)("CSS Class manager", "elementor")), /* @__PURE__ */ React6.createElement(
611
+ usePreventUnload();
612
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, 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.__)("CSS Class manager", "elementor")), /* @__PURE__ */ React7.createElement(
600
613
  CloseButton,
601
614
  {
602
615
  sx: { marginLeft: "auto" },
@@ -608,7 +621,7 @@ function ClassManagerPanel() {
608
621
  closePanel();
609
622
  }
610
623
  }
611
- ))), /* @__PURE__ */ React6.createElement(import_editor_panels.PanelBody, { px: 2 }, /* @__PURE__ */ React6.createElement(GlobalClassesList, null)), /* @__PURE__ */ React6.createElement(import_editor_panels.PanelFooter, null, /* @__PURE__ */ React6.createElement(
624
+ ))), /* @__PURE__ */ React7.createElement(import_editor_panels.PanelBody, { px: 2 }, /* @__PURE__ */ React7.createElement(GlobalClassesList, null)), /* @__PURE__ */ React7.createElement(import_editor_panels.PanelFooter, null, /* @__PURE__ */ React7.createElement(
612
625
  import_ui6.Button,
613
626
  {
614
627
  fullWidth: true,
@@ -619,7 +632,7 @@ function ClassManagerPanel() {
619
632
  onClick: publishGlobalClasses
620
633
  },
621
634
  (0, import_i18n5.__)("Save changes", "elementor")
622
- )))), /* @__PURE__ */ React6.createElement(ClassManagerIntroduction, null), isSaveChangesDialogOpen && /* @__PURE__ */ React6.createElement(SaveChangesDialog, null, /* @__PURE__ */ React6.createElement(SaveChangesDialog.Title, null, (0, import_i18n5.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React6.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React6.createElement(SaveChangesDialog.ContentText, null, (0, import_i18n5.__)("You have unsaved changes in the Class Manager.", "elementor")), /* @__PURE__ */ React6.createElement(SaveChangesDialog.ContentText, null, (0, import_i18n5.__)("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React6.createElement(
635
+ )))), /* @__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(
623
636
  SaveChangesDialog.Actions,
624
637
  {
625
638
  actions: {
@@ -639,8 +652,22 @@ function ClassManagerPanel() {
639
652
  }
640
653
  )));
641
654
  }
642
- var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */ React6.createElement(import_ui6.IconButton, { size: "small", color: "secondary", onClick: onClose, "aria-label": "Close", ...props }, /* @__PURE__ */ React6.createElement(import_icons5.XIcon, { fontSize: "small" }));
643
- var ErrorBoundaryFallback = () => /* @__PURE__ */ React6.createElement(import_ui6.Box, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React6.createElement(import_ui6.Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React6.createElement("strong", null, (0, import_i18n5.__)("Something went wrong", "elementor"))));
655
+ 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" }));
656
+ 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"))));
657
+ var usePreventUnload = () => {
658
+ const isDirty3 = useDirtyState();
659
+ (0, import_react4.useEffect)(() => {
660
+ const handleBeforeUnload = (event) => {
661
+ if (isDirty3) {
662
+ event.preventDefault();
663
+ }
664
+ };
665
+ window.addEventListener("beforeunload", handleBeforeUnload);
666
+ return () => {
667
+ window.removeEventListener("beforeunload", handleBeforeUnload);
668
+ };
669
+ }, [isDirty3]);
670
+ };
644
671
 
645
672
  // src/components/class-manager/class-manager-button.tsx
646
673
  var ClassManagerButton = () => {
@@ -655,10 +682,10 @@ var ClassManagerButton = () => {
655
682
  }
656
683
  openPanel();
657
684
  };
658
- return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(import_ui7.Tooltip, { title: (0, import_i18n6.__)("Class manager", "elementor"), placement: "top" }, /* @__PURE__ */ React7.createElement(import_ui7.IconButton, { onClick: handleOpenPanel }, /* @__PURE__ */ React7.createElement(import_icons6.ColorSwatchIcon, { fontSize: "tiny" }))), isSaveChangesDialogOpen && /* @__PURE__ */ React7.createElement(SaveChangesDialog, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.Title, null, (0, import_i18n6.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React7.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.ContentText, { sx: { mb: 2 } }, (0, import_i18n6.__)(
685
+ 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, { onClick: handleOpenPanel }, /* @__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.__)(
659
686
  "Save your changes before moving to the class manager to ensure all updates are applied and saved.",
660
687
  "elementor"
661
- )), /* @__PURE__ */ React7.createElement(SaveChangesDialog.ContentText, null, (0, import_i18n6.__)("If you leave without saving, all changes will be discarded.", "elementor"))), /* @__PURE__ */ React7.createElement(
688
+ )), /* @__PURE__ */ React8.createElement(SaveChangesDialog.ContentText, null, (0, import_i18n6.__)("If you leave without saving, all changes will be discarded.", "elementor"))), /* @__PURE__ */ React8.createElement(
662
689
  SaveChangesDialog.Actions,
663
690
  {
664
691
  actions: {
@@ -680,11 +707,11 @@ var ClassManagerButton = () => {
680
707
  };
681
708
 
682
709
  // src/components/populate-store.tsx
683
- var import_react4 = require("react");
710
+ var import_react5 = require("react");
684
711
  var import_store12 = require("@elementor/store");
685
712
  function PopulateStore() {
686
713
  const dispatch3 = (0, import_store12.__useDispatch)();
687
- (0, import_react4.useEffect)(() => {
714
+ (0, import_react5.useEffect)(() => {
688
715
  apiClient.all().then((res) => {
689
716
  const { data, meta } = res.data;
690
717
  dispatch3(slice.actions.init({ items: data, order: meta.order }));
@@ -694,7 +721,7 @@ function PopulateStore() {
694
721
  }
695
722
 
696
723
  // src/sync-with-document-save.ts
697
- var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
724
+ var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
698
725
  var import_store14 = require("@elementor/store");
699
726
  function syncWithDocumentSave() {
700
727
  const unsubscribe = syncDirtyState();
@@ -706,11 +733,11 @@ function syncDirtyState() {
706
733
  if (!isDirty2()) {
707
734
  return;
708
735
  }
709
- (0, import_editor_v1_adapters.__privateRunCommandSync)("document/save/set-is-modified", { status: true }, { internal: true });
736
+ (0, import_editor_v1_adapters2.__privateRunCommandSync)("document/save/set-is-modified", { status: true }, { internal: true });
710
737
  });
711
738
  }
712
739
  function bindSaveAction() {
713
- (0, import_editor_v1_adapters.registerDataHook)("after", "document/save/save", publishGlobalClasses);
740
+ (0, import_editor_v1_adapters2.registerDataHook)("after", "document/save/save", publishGlobalClasses);
714
741
  }
715
742
  function isDirty2() {
716
743
  return selectIsDirty((0, import_store14.__getState)());
@@ -729,7 +756,7 @@ function init() {
729
756
  id: "global-classes-manager-button",
730
757
  component: ClassManagerButton
731
758
  });
732
- (0, import_editor_v1_adapters2.__privateListenTo)((0, import_editor_v1_adapters2.v1ReadyEvent)(), () => {
759
+ (0, import_editor_v1_adapters3.__privateListenTo)((0, import_editor_v1_adapters3.v1ReadyEvent)(), () => {
733
760
  syncWithDocumentSave();
734
761
  });
735
762
  }