@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/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # @elementor/editor-global-classes
2
2
 
3
+ ## 0.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8abbfd6: Show browser alert when trying to close tab with unsaved classes changes.
8
+ - a654cb2: Update `@elementor/icons` version
9
+ - 959e02c: Disable canvas and app bar buttons when opening the class manager panel
10
+
11
+ ### Patch Changes
12
+
13
+ - f2d98cc: Show `Paper` placeholder on class item only while dragging it.
14
+ - 10e3baf: Update global classes panel empty state, icons.
15
+ - Updated dependencies [23458d1]
16
+ - Updated dependencies [a654cb2]
17
+ - Updated dependencies [89a015d]
18
+ - Updated dependencies [cab4ddf]
19
+ - Updated dependencies [810d72f]
20
+ - Updated dependencies [f99d23c]
21
+ - Updated dependencies [f6a4d4f]
22
+ - Updated dependencies [de85397]
23
+ - Updated dependencies [959e02c]
24
+ - @elementor/editor-editing-panel@1.17.0
25
+ - @elementor/editor-props@0.9.4
26
+ - @elementor/http@0.1.4
27
+ - @elementor/editor-ui@0.4.1
28
+ - @elementor/editor-v1-adapters@0.10.2
29
+ - @elementor/editor-panels@0.12.2
30
+ - @elementor/editor-styles-repository@0.7.4
31
+ - @elementor/editor-styles@0.6.1
32
+ - @elementor/editor-current-user@0.2.2
33
+ - @elementor/editor@0.18.2
34
+ - @elementor/editor-documents@0.11.20
35
+
3
36
  ## 0.10.0
4
37
 
5
38
  ### Minor Changes
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("div", { ...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,22 +340,35 @@ 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
+ StyledSortableItem,
349
+ {
350
+ ...itemProps,
351
+ sx: itemStyle,
352
+ role: "listitem",
353
+ ...isDragOverlay ? { component: import_ui3.Paper, elevation: 0 } : {}
354
+ },
355
+ /* @__PURE__ */ React4.createElement(SortableTrigger, { ...triggerProps, style: triggerStyle }),
356
+ children({
357
+ itemProps,
358
+ isDragged,
359
+ triggerProps,
360
+ itemStyle,
361
+ triggerStyle,
362
+ dropIndicationStyle,
363
+ showDropIndication,
364
+ isDragPlaceholder
365
+ })
366
+ );
347
367
  }
348
368
  }
349
369
  );
350
370
  };
351
- var StyledSortableItem = (0, import_ui3.styled)(import_ui3.Paper)`
371
+ var StyledSortableItem = (0, import_ui3.styled)(import_ui3.Box)`
352
372
  position: relative;
353
373
 
354
374
  &:hover {
@@ -377,21 +397,22 @@ var GlobalClassesList = () => {
377
397
  const cssClasses = useOrderedClasses();
378
398
  const [classesOrder, reorderClasses] = useReorder();
379
399
  if (!cssClasses?.length) {
380
- return /* @__PURE__ */ React4.createElement(EmptyState, null);
400
+ return /* @__PURE__ */ React5.createElement(EmptyState, null);
381
401
  }
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 }) => {
402
+ 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
403
  const renameClass = (newLabel) => {
384
- globalClassesStylesProvider.actions.update({ label: newLabel, id });
404
+ globalClassesStylesProvider.actions.update({ label: newLabel, id: id2 });
385
405
  };
386
- return /* @__PURE__ */ React4.createElement(SortableItem, { key: id, id }, ({ isDragged, showDropIndication, dropIndicationStyle }) => /* @__PURE__ */ React4.createElement(
406
+ return /* @__PURE__ */ React5.createElement(SortableItem, { key: id2, id: id2 }, ({ isDragged, showDropIndication, dropIndicationStyle, isDragPlaceholder }) => /* @__PURE__ */ React5.createElement(
387
407
  ClassItem,
388
408
  {
389
- id,
409
+ id: id2,
390
410
  label,
391
411
  renameClass,
392
- selected: isDragged
412
+ selected: isDragged,
413
+ disabled: isDragPlaceholder
393
414
  },
394
- showDropIndication && /* @__PURE__ */ React4.createElement(SortableItemIndicator, { style: dropIndicationStyle })
415
+ showDropIndication && /* @__PURE__ */ React5.createElement(SortableItemIndicator, { style: dropIndicationStyle })
395
416
  ));
396
417
  }))));
397
418
  };
@@ -403,11 +424,12 @@ var useReorder = () => {
403
424
  return [order, reorder];
404
425
  };
405
426
  var ClassItem = ({
406
- id,
427
+ id: id2,
407
428
  label,
408
429
  renameClass,
409
430
  selected,
410
- children
431
+ children,
432
+ disabled
411
433
  }) => {
412
434
  const {
413
435
  ref: editableRef,
@@ -425,23 +447,23 @@ var ClassItem = ({
425
447
  variant: "popover",
426
448
  disableAutoFocus: true
427
449
  });
428
- return /* @__PURE__ */ React4.createElement(import_ui4.Stack, { direction: "row", alignItems: "center", gap: 1, flexGrow: 1, flexShrink: 0 }, /* @__PURE__ */ React4.createElement(
450
+ return /* @__PURE__ */ React5.createElement(import_ui4.Stack, { direction: "row", alignItems: "center", gap: 1, flexGrow: 1, flexShrink: 0 }, /* @__PURE__ */ React5.createElement(
429
451
  StyledListItem,
430
452
  {
431
453
  component: "div",
432
454
  disablePadding: true,
433
455
  disableGutters: true,
434
- secondaryAction: /* @__PURE__ */ React4.createElement(
456
+ secondaryAction: /* @__PURE__ */ React5.createElement(
435
457
  import_ui4.Tooltip,
436
458
  {
437
459
  placement: "top",
438
460
  className: "class-item-more-actions",
439
461
  title: (0, import_i18n4.__)("More actions", "elementor")
440
462
  },
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" }))
463
+ /* @__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" }))
442
464
  )
443
465
  },
444
- /* @__PURE__ */ React4.createElement(
466
+ /* @__PURE__ */ React5.createElement(
445
467
  import_ui4.ListItemButton,
446
468
  {
447
469
  dense: true,
@@ -449,6 +471,7 @@ var ClassItem = ({
449
471
  shape: "rounded",
450
472
  onDoubleClick: openEditMode,
451
473
  selected: selected || popupState.isOpen,
474
+ disabled,
452
475
  focusVisibleClassName: "visible-class-item",
453
476
  sx: {
454
477
  minHeight: "36px",
@@ -458,7 +481,7 @@ var ClassItem = ({
458
481
  }
459
482
  }
460
483
  },
461
- /* @__PURE__ */ React4.createElement(Indicator, { isActive: isEditing, isError: !!error }, isEditing ? /* @__PURE__ */ React4.createElement(
484
+ /* @__PURE__ */ React5.createElement(Indicator, { isActive: isEditing, isError: !!error }, isEditing ? /* @__PURE__ */ React5.createElement(
462
485
  import_editor_ui2.EditableField,
463
486
  {
464
487
  ref: editableRef,
@@ -467,10 +490,10 @@ var ClassItem = ({
467
490
  variant: "caption",
468
491
  ...getEditableProps()
469
492
  }
470
- ) : /* @__PURE__ */ React4.createElement(import_editor_ui2.EllipsisWithTooltip, { title: label, as: import_ui4.Typography, variant: "caption" }))
493
+ ) : /* @__PURE__ */ React5.createElement(import_editor_ui2.EllipsisWithTooltip, { title: label, as: import_ui4.Typography, variant: "caption" }))
471
494
  ),
472
495
  children,
473
- /* @__PURE__ */ React4.createElement(
496
+ /* @__PURE__ */ React5.createElement(
474
497
  import_ui4.Menu,
475
498
  {
476
499
  ...(0, import_ui4.bindMenu)(popupState),
@@ -483,7 +506,7 @@ var ClassItem = ({
483
506
  horizontal: "right"
484
507
  }
485
508
  },
486
- /* @__PURE__ */ React4.createElement(
509
+ /* @__PURE__ */ React5.createElement(
487
510
  import_ui4.MenuItem,
488
511
  {
489
512
  sx: { minWidth: "160px" },
@@ -492,17 +515,17 @@ var ClassItem = ({
492
515
  openEditMode();
493
516
  }
494
517
  },
495
- /* @__PURE__ */ React4.createElement(import_ui4.ListItemText, { primary: (0, import_i18n4.__)("Rename", "elementor") })
518
+ /* @__PURE__ */ React5.createElement(import_ui4.ListItemText, { primary: (0, import_i18n4.__)("Rename", "elementor") })
496
519
  ),
497
- /* @__PURE__ */ React4.createElement(
520
+ /* @__PURE__ */ React5.createElement(
498
521
  import_ui4.MenuItem,
499
522
  {
500
523
  onClick: () => {
501
524
  popupState.close();
502
- openDialog({ id, label });
525
+ openDialog({ id: id2, label });
503
526
  }
504
527
  },
505
- /* @__PURE__ */ React4.createElement(import_ui4.ListItemText, { primary: (0, import_i18n4.__)("Delete", "elementor"), sx: { color: "error.light" } })
528
+ /* @__PURE__ */ React5.createElement(import_ui4.ListItemText, { primary: (0, import_i18n4.__)("Delete", "elementor"), sx: { color: "error.light" } })
506
529
  )
507
530
  )
508
531
  ));
@@ -517,7 +540,7 @@ var StyledListItem = (0, import_ui4.styled)(import_ui4.ListItem)`
517
540
  }
518
541
  }
519
542
  `;
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.__)(
543
+ 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
544
  "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
545
  "elementor"
523
546
  )));
@@ -557,15 +580,15 @@ var validateLabel = (newLabel) => {
557
580
  };
558
581
 
559
582
  // src/components/class-manager/save-changes-dialog.tsx
560
- var React5 = __toESM(require("react"));
583
+ var React6 = __toESM(require("react"));
561
584
  var import_react3 = require("react");
562
- var import_icons4 = require("@elementor/icons");
585
+ var import_icons5 = require("@elementor/icons");
563
586
  var import_ui5 = require("@elementor/ui");
564
587
  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 });
588
+ var SaveChangesDialog = ({ children, onClose }) => /* @__PURE__ */ React6.createElement(import_ui5.Dialog, { open: true, onClose, "aria-labelledby": TITLE_ID2, maxWidth: "xs" }, children);
589
+ 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);
590
+ var SaveChangesDialogContent = ({ children }) => /* @__PURE__ */ React6.createElement(import_ui5.DialogContent, null, children);
591
+ var SaveChangesDialogContentText = (props) => /* @__PURE__ */ React6.createElement(import_ui5.DialogContentText, { variant: "body2", color: "textPrimary", display: "flex", flexDirection: "column", ...props });
569
592
  var SaveChangesDialogActions = ({ actions }) => {
570
593
  const [isConfirming, setIsConfirming] = (0, import_react3.useState)(false);
571
594
  const { cancel, confirm } = actions;
@@ -574,7 +597,7 @@ var SaveChangesDialogActions = ({ actions }) => {
574
597
  await confirm.action();
575
598
  setIsConfirming(false);
576
599
  };
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));
600
+ 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
601
  };
579
602
  SaveChangesDialog.Title = SaveChangesDialogTitle;
580
603
  SaveChangesDialog.Content = SaveChangesDialogContent;
@@ -588,15 +611,20 @@ var useDialog = () => {
588
611
  };
589
612
 
590
613
  // src/components/class-manager/class-manager-panel.tsx
614
+ var id = "global-classes-manager";
591
615
  var { panel, usePanelActions } = (0, import_editor_panels.__createPanel)({
592
- id: "class-manager-panel",
593
- component: ClassManagerPanel
616
+ id,
617
+ component: ClassManagerPanel,
618
+ onOpen: () => (0, import_editor_v1_adapters.changeEditMode)(id),
619
+ onClose: () => (0, import_editor_v1_adapters.changeEditMode)("edit"),
620
+ allowedEditModes: ["edit", id]
594
621
  });
595
622
  function ClassManagerPanel() {
596
623
  const isDirty3 = useDirtyState();
597
624
  const { close: closePanel } = usePanelActions();
598
625
  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(
626
+ usePreventUnload();
627
+ 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
628
  CloseButton,
601
629
  {
602
630
  sx: { marginLeft: "auto" },
@@ -608,7 +636,7 @@ function ClassManagerPanel() {
608
636
  closePanel();
609
637
  }
610
638
  }
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(
639
+ ))), /* @__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
640
  import_ui6.Button,
613
641
  {
614
642
  fullWidth: true,
@@ -619,7 +647,7 @@ function ClassManagerPanel() {
619
647
  onClick: publishGlobalClasses
620
648
  },
621
649
  (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(
650
+ )))), /* @__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
651
  SaveChangesDialog.Actions,
624
652
  {
625
653
  actions: {
@@ -639,8 +667,22 @@ function ClassManagerPanel() {
639
667
  }
640
668
  )));
641
669
  }
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"))));
670
+ 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" }));
671
+ 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"))));
672
+ var usePreventUnload = () => {
673
+ const isDirty3 = useDirtyState();
674
+ (0, import_react4.useEffect)(() => {
675
+ const handleBeforeUnload = (event) => {
676
+ if (isDirty3) {
677
+ event.preventDefault();
678
+ }
679
+ };
680
+ window.addEventListener("beforeunload", handleBeforeUnload);
681
+ return () => {
682
+ window.removeEventListener("beforeunload", handleBeforeUnload);
683
+ };
684
+ }, [isDirty3]);
685
+ };
644
686
 
645
687
  // src/components/class-manager/class-manager-button.tsx
646
688
  var ClassManagerButton = () => {
@@ -655,10 +697,10 @@ var ClassManagerButton = () => {
655
697
  }
656
698
  openPanel();
657
699
  };
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.__)(
700
+ 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
701
  "Save your changes before moving to the class manager to ensure all updates are applied and saved.",
660
702
  "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(
703
+ )), /* @__PURE__ */ React8.createElement(SaveChangesDialog.ContentText, null, (0, import_i18n6.__)("If you leave without saving, all changes will be discarded.", "elementor"))), /* @__PURE__ */ React8.createElement(
662
704
  SaveChangesDialog.Actions,
663
705
  {
664
706
  actions: {
@@ -680,11 +722,11 @@ var ClassManagerButton = () => {
680
722
  };
681
723
 
682
724
  // src/components/populate-store.tsx
683
- var import_react4 = require("react");
725
+ var import_react5 = require("react");
684
726
  var import_store12 = require("@elementor/store");
685
727
  function PopulateStore() {
686
728
  const dispatch3 = (0, import_store12.__useDispatch)();
687
- (0, import_react4.useEffect)(() => {
729
+ (0, import_react5.useEffect)(() => {
688
730
  apiClient.all().then((res) => {
689
731
  const { data, meta } = res.data;
690
732
  dispatch3(slice.actions.init({ items: data, order: meta.order }));
@@ -694,7 +736,7 @@ function PopulateStore() {
694
736
  }
695
737
 
696
738
  // src/sync-with-document-save.ts
697
- var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
739
+ var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
698
740
  var import_store14 = require("@elementor/store");
699
741
  function syncWithDocumentSave() {
700
742
  const unsubscribe = syncDirtyState();
@@ -706,11 +748,11 @@ function syncDirtyState() {
706
748
  if (!isDirty2()) {
707
749
  return;
708
750
  }
709
- (0, import_editor_v1_adapters.__privateRunCommandSync)("document/save/set-is-modified", { status: true }, { internal: true });
751
+ (0, import_editor_v1_adapters2.__privateRunCommandSync)("document/save/set-is-modified", { status: true }, { internal: true });
710
752
  });
711
753
  }
712
754
  function bindSaveAction() {
713
- (0, import_editor_v1_adapters.registerDataHook)("after", "document/save/save", publishGlobalClasses);
755
+ (0, import_editor_v1_adapters2.registerDataHook)("after", "document/save/save", publishGlobalClasses);
714
756
  }
715
757
  function isDirty2() {
716
758
  return selectIsDirty((0, import_store14.__getState)());
@@ -729,7 +771,7 @@ function init() {
729
771
  id: "global-classes-manager-button",
730
772
  component: ClassManagerButton
731
773
  });
732
- (0, import_editor_v1_adapters2.__privateListenTo)((0, import_editor_v1_adapters2.v1ReadyEvent)(), () => {
774
+ (0, import_editor_v1_adapters3.__privateListenTo)((0, import_editor_v1_adapters3.v1ReadyEvent)(), () => {
733
775
  syncWithDocumentSave();
734
776
  });
735
777
  }