@elementor/editor-global-classes 0.15.3 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  import { injectIntoLogic } from "@elementor/editor";
3
3
  import { injectIntoClassSelectorActions } from "@elementor/editor-editing-panel";
4
4
  import { __registerPanel as registerPanel } from "@elementor/editor-panels";
5
- import { stylesRepository as stylesRepository2 } from "@elementor/editor-styles-repository";
5
+ import { stylesRepository } from "@elementor/editor-styles-repository";
6
6
  import { __privateListenTo as listenTo, v1ReadyEvent } from "@elementor/editor-v1-adapters";
7
7
  import { __registerSlice as registerSlice } from "@elementor/store";
8
8
 
@@ -13,7 +13,7 @@ import {
13
13
  __useActiveDocumentActions as useActiveDocumentActions
14
14
  } from "@elementor/editor-documents";
15
15
  import { IconButton as IconButton3, Tooltip as Tooltip2 } from "@elementor/ui";
16
- import { __ as __6 } from "@wordpress/i18n";
16
+ import { __ as __5 } from "@wordpress/i18n";
17
17
 
18
18
  // src/components/class-manager/class-manager-panel.tsx
19
19
  import * as React7 from "react";
@@ -32,7 +32,7 @@ import { changeEditMode } from "@elementor/editor-v1-adapters";
32
32
  import { XIcon } from "@elementor/icons";
33
33
  import { useMutation } from "@elementor/query";
34
34
  import { Alert, Box as Box4, Button as Button3, ErrorBoundary, IconButton as IconButton2, Stack as Stack2 } from "@elementor/ui";
35
- import { __ as __5 } from "@wordpress/i18n";
35
+ import { __ as __4 } from "@wordpress/i18n";
36
36
 
37
37
  // src/hooks/use-dirty-state.ts
38
38
  import { __useSelector as useSelector } from "@elementor/store";
@@ -176,7 +176,7 @@ import * as React from "react";
176
176
  import { useState } from "react";
177
177
  import { useSuppressedMessage } from "@elementor/editor-current-user";
178
178
  import { IntroductionModal } from "@elementor/editor-ui";
179
- import { Box, Typography } from "@elementor/ui";
179
+ import { Box, Image, Typography } from "@elementor/ui";
180
180
  import { __ } from "@wordpress/i18n";
181
181
  var MESSAGE_KEY = "global-class-manager";
182
182
  var ClassManagerIntroduction = () => {
@@ -187,18 +187,22 @@ var ClassManagerIntroduction = () => {
187
187
  {
188
188
  open: shouldShowIntroduction,
189
189
  title: __("Class Manager", "elementor"),
190
- content: /* @__PURE__ */ React.createElement(IntroductionContent, null),
191
- image: {
192
- src: "https://assets.elementor.com/packages/v1/images/class-manager-intro.svg",
193
- alt: ""
194
- },
195
190
  handleClose: (shouldShowAgain) => {
196
191
  if (!shouldShowAgain) {
197
192
  suppressMessage();
198
193
  }
199
194
  setShouldShowIntroduction(false);
200
195
  }
201
- }
196
+ },
197
+ /* @__PURE__ */ React.createElement(
198
+ Image,
199
+ {
200
+ sx: { width: "100%", aspectRatio: "16 / 9" },
201
+ src: "https://assets.elementor.com/packages/v1/images/class-manager-intro.svg",
202
+ alt: ""
203
+ }
204
+ ),
205
+ /* @__PURE__ */ React.createElement(IntroductionContent, null)
202
206
  );
203
207
  };
204
208
  var IntroductionContent = () => {
@@ -214,75 +218,10 @@ var IntroductionContent = () => {
214
218
  // src/components/class-manager/delete-class.ts
215
219
  import { getCurrentDocument, getV1DocumentsManager } from "@elementor/editor-documents";
216
220
  import { __privateRunCommand as runCommand } from "@elementor/editor-v1-adapters";
217
-
218
- // src/global-classes-styles-provider.ts
219
- import { generateId } from "@elementor/editor-styles";
220
- import {
221
- __dispatch as dispatch2,
222
- __getState as getState2,
223
- __subscribeWithSelector as subscribeWithSelector
224
- } from "@elementor/store";
225
- import { __ as __2 } from "@wordpress/i18n";
226
- var MAX_CLASSES = 50;
227
- var globalClassesStylesProvider = {
228
- key: "global-classes",
229
- priority: 30,
230
- limit: MAX_CLASSES,
231
- actions: {
232
- get: () => selectOrderedClasses(getState2()),
233
- getById: (id2) => selectClass(getState2(), id2),
234
- create: (label) => {
235
- const classes = selectGlobalClasses(getState2());
236
- const existingLabels = Object.values(classes).map((style) => style.label);
237
- if (existingLabels.includes(label)) {
238
- throw new GlobalClassLabelAlreadyExistsError({ context: { label } });
239
- }
240
- const existingIds = Object.keys(classes);
241
- const id2 = generateId("g-", existingIds);
242
- dispatch2(
243
- slice.actions.add({
244
- id: id2,
245
- type: "class",
246
- label,
247
- variants: []
248
- })
249
- );
250
- return id2;
251
- },
252
- update: (payload) => {
253
- dispatch2(
254
- slice.actions.update({
255
- style: payload
256
- })
257
- );
258
- },
259
- delete: (id2) => {
260
- dispatch2(slice.actions.delete(id2));
261
- },
262
- setOrder: (order) => {
263
- dispatch2(slice.actions.setOrder(order));
264
- },
265
- updateProps: (args) => {
266
- dispatch2(
267
- slice.actions.updateProps({
268
- id: args.id,
269
- meta: args.meta,
270
- props: args.props
271
- })
272
- );
273
- }
274
- },
275
- subscribe: (cb) => subscribeWithSelector((state) => state.globalClasses, cb),
276
- labels: {
277
- singular: __2("class", "elementor"),
278
- plural: __2("classes", "elementor")
279
- }
280
- };
281
-
282
- // src/components/class-manager/delete-class.ts
221
+ import { __dispatch as dispatch2 } from "@elementor/store";
283
222
  var isDeleted = false;
284
223
  var deleteClass = (id2) => {
285
- globalClassesStylesProvider.actions.delete(id2);
224
+ dispatch2(slice.actions.delete(id2));
286
225
  isDeleted = true;
287
226
  };
288
227
  var onDelete = async () => {
@@ -308,9 +247,10 @@ var FlippedColorSwatchIcon = ({ sx, ...props }) => /* @__PURE__ */ React2.create
308
247
 
309
248
  // src/components/class-manager/global-classes-list.tsx
310
249
  import * as React5 from "react";
311
- import { stylesRepository } from "@elementor/editor-styles-repository";
250
+ import { validateStyleLabel } from "@elementor/editor-styles-repository";
312
251
  import { EditableField, EllipsisWithTooltip, MenuListItem, useEditable } from "@elementor/editor-ui";
313
252
  import { DotsVerticalIcon } from "@elementor/icons";
253
+ import { __useDispatch as useDispatch } from "@elementor/store";
314
254
  import {
315
255
  bindMenu,
316
256
  bindTrigger,
@@ -325,7 +265,7 @@ import {
325
265
  Typography as Typography3,
326
266
  usePopupState
327
267
  } from "@elementor/ui";
328
- import { __ as __4 } from "@wordpress/i18n";
268
+ import { __ as __3 } from "@wordpress/i18n";
329
269
 
330
270
  // src/hooks/use-classes-order.ts
331
271
  import { __useSelector as useSelector2 } from "@elementor/store";
@@ -352,7 +292,7 @@ import {
352
292
  DialogTitle,
353
293
  Typography as Typography2
354
294
  } from "@elementor/ui";
355
- import { __ as __3 } from "@wordpress/i18n";
295
+ import { __ as __2 } from "@wordpress/i18n";
356
296
  var context = createContext(null);
357
297
  var DeleteConfirmationProvider = ({ children }) => {
358
298
  const [dialogProps, setDialogProps] = useState2(null);
@@ -371,10 +311,10 @@ var DeleteConfirmationDialog = ({ label, id: id2 }) => {
371
311
  deleteClass(id2);
372
312
  closeDialog();
373
313
  };
374
- 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 this 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(
314
+ 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" }), __2("Delete this class?", "elementor")), /* @__PURE__ */ React3.createElement(DialogContent, null, /* @__PURE__ */ React3.createElement(DialogContentText, { variant: "body2", color: "textPrimary" }, __2("Deleting", "elementor"), /* @__PURE__ */ React3.createElement(Typography2, { variant: "subtitle2", component: "span" }, "\xA0", label, "\xA0"), __2(
375
315
  "will permanently remove it from your project and may affect the design across all elements using it. This action cannot be undone.",
376
316
  "elementor"
377
- ))), /* @__PURE__ */ React3.createElement(DialogActions, null, /* @__PURE__ */ React3.createElement(Button, { color: "secondary", onClick: closeDialog }, __3("Not now", "elementor")), /* @__PURE__ */ React3.createElement(Button, { variant: "contained", color: "error", onClick: onConfirm }, __3("Delete", "elementor"))));
317
+ ))), /* @__PURE__ */ React3.createElement(DialogActions, null, /* @__PURE__ */ React3.createElement(Button, { color: "secondary", onClick: closeDialog }, __2("Not now", "elementor")), /* @__PURE__ */ React3.createElement(Button, { variant: "contained", color: "error", onClick: onConfirm }, __2("Delete", "elementor"))));
378
318
  };
379
319
  var useDeleteConfirmation = () => {
380
320
  const contextValue = useContext(context);
@@ -453,13 +393,21 @@ var SortableItemIndicator = styled(Box2)`
453
393
  // src/components/class-manager/global-classes-list.tsx
454
394
  var GlobalClassesList = ({ disabled }) => {
455
395
  const cssClasses = useOrderedClasses();
396
+ const dispatch4 = useDispatch();
456
397
  const [classesOrder, reorderClasses] = useReorder();
457
398
  if (!cssClasses?.length) {
458
399
  return /* @__PURE__ */ React5.createElement(EmptyState, null);
459
400
  }
460
401
  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 }) => {
461
402
  const renameClass = (newLabel) => {
462
- globalClassesStylesProvider.actions.update({ label: newLabel, id: id2 });
403
+ dispatch4(
404
+ slice.actions.update({
405
+ style: {
406
+ id: id2,
407
+ label: newLabel
408
+ }
409
+ })
410
+ );
463
411
  };
464
412
  return /* @__PURE__ */ React5.createElement(SortableItem, { key: id2, id: id2 }, ({ isDragged, isDragPlaceholder, triggerProps, triggerStyle }) => /* @__PURE__ */ React5.createElement(
465
413
  ClassItem,
@@ -475,9 +423,10 @@ var GlobalClassesList = ({ disabled }) => {
475
423
  }))));
476
424
  };
477
425
  var useReorder = () => {
426
+ const dispatch4 = useDispatch();
478
427
  const order = useClassesOrder();
479
428
  const reorder = (newIds) => {
480
- globalClassesStylesProvider.actions.setOrder(newIds);
429
+ dispatch4(slice.actions.setOrder(newIds));
481
430
  };
482
431
  return [order, reorder];
483
432
  };
@@ -527,7 +476,7 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
527
476
  {
528
477
  placement: "top",
529
478
  className: "class-item-more-actions",
530
- title: __4("More actions", "elementor")
479
+ title: __3("More actions", "elementor")
531
480
  },
532
481
  /* @__PURE__ */ React5.createElement(IconButton, { size: "tiny", ...bindTrigger(popupState), "aria-label": "More actions" }, /* @__PURE__ */ React5.createElement(DotsVerticalIcon, { fontSize: "tiny" }))
533
482
  )
@@ -553,7 +502,7 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
553
502
  openEditMode();
554
503
  }
555
504
  },
556
- /* @__PURE__ */ React5.createElement(Typography3, { variant: "caption", sx: { color: "text.primary" } }, __4("Rename", "elementor"))
505
+ /* @__PURE__ */ React5.createElement(Typography3, { variant: "caption", sx: { color: "text.primary" } }, __3("Rename", "elementor"))
557
506
  ),
558
507
  /* @__PURE__ */ React5.createElement(
559
508
  MenuListItem,
@@ -563,7 +512,7 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
563
512
  openDialog({ id: id2, label });
564
513
  }
565
514
  },
566
- /* @__PURE__ */ React5.createElement(Typography3, { variant: "caption", sx: { color: "error.light" } }, __4("Delete", "elementor"))
515
+ /* @__PURE__ */ React5.createElement(Typography3, { variant: "caption", sx: { color: "error.light" } }, __3("Delete", "elementor"))
567
516
  )
568
517
  ));
569
518
  };
@@ -592,7 +541,7 @@ var StyledListItemButton = styled2(ListItemButton, {
592
541
  }
593
542
  `
594
543
  );
595
- var EmptyState = () => /* @__PURE__ */ React5.createElement(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" }, __4("There are no global classes yet.", "elementor")), /* @__PURE__ */ React5.createElement(Typography3, { align: "center", variant: "caption", color: "text.secondary" }, __4(
544
+ var EmptyState = () => /* @__PURE__ */ React5.createElement(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" }, __3("There are no global classes yet.", "elementor")), /* @__PURE__ */ React5.createElement(Typography3, { align: "center", variant: "caption", color: "text.secondary" }, __3(
596
545
  "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.",
597
546
  "elementor"
598
547
  )));
@@ -623,15 +572,23 @@ var getIndicatorBorder = ({ isActive, isError, theme }) => {
623
572
  return "none";
624
573
  };
625
574
  var validateLabel = (newLabel) => {
626
- if (!stylesRepository.isLabelValid(newLabel)) {
627
- return __4("Invalid format", "elementor");
575
+ const result = validateStyleLabel(newLabel);
576
+ if (result.isValid) {
577
+ return null;
628
578
  }
629
- if (stylesRepository.isLabelExist(newLabel)) {
630
- return __4("Name exists", "elementor");
631
- }
632
- return null;
579
+ return result.error;
633
580
  };
634
581
 
582
+ // src/components/class-manager/panel-interactions.ts
583
+ function blockPanelInteractions() {
584
+ const extendedWindow = window;
585
+ extendedWindow.$e?.components?.get?.("panel")?.blockUserInteractions?.();
586
+ }
587
+ function unblockPanelInteractions() {
588
+ const extendedWindow = window;
589
+ extendedWindow.$e?.components?.get?.("panel")?.unblockUserInteractions?.();
590
+ }
591
+
635
592
  // src/components/class-manager/save-changes-dialog.tsx
636
593
  import * as React6 from "react";
637
594
  import { useState as useState3 } from "react";
@@ -678,9 +635,11 @@ var { panel, usePanelActions } = createPanel({
678
635
  allowedEditModes: ["edit", id],
679
636
  onOpen: () => {
680
637
  changeEditMode(id);
638
+ blockPanelInteractions();
681
639
  },
682
640
  onClose: () => {
683
641
  changeEditMode("edit");
642
+ unblockPanelInteractions();
684
643
  }
685
644
  });
686
645
  function ClassManagerPanel() {
@@ -689,7 +648,7 @@ function ClassManagerPanel() {
689
648
  const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
690
649
  const { mutateAsync: publish, isPending: isPublishing } = usePublish();
691
650
  usePreventUnload();
692
- return /* @__PURE__ */ React7.createElement(ThemeProvider, null, /* @__PURE__ */ React7.createElement(ErrorBoundary, { fallback: /* @__PURE__ */ React7.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React7.createElement(Panel, null, /* @__PURE__ */ React7.createElement(PanelHeader, null, /* @__PURE__ */ React7.createElement(Stack2, { 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("Class Manager", "elementor")), /* @__PURE__ */ React7.createElement(
651
+ return /* @__PURE__ */ React7.createElement(ThemeProvider, null, /* @__PURE__ */ React7.createElement(ErrorBoundary, { fallback: /* @__PURE__ */ React7.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React7.createElement(Panel, null, /* @__PURE__ */ React7.createElement(PanelHeader, null, /* @__PURE__ */ React7.createElement(Stack2, { 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" }), __4("Class Manager", "elementor")), /* @__PURE__ */ React7.createElement(
693
652
  CloseButton,
694
653
  {
695
654
  sx: { marginLeft: "auto" },
@@ -713,17 +672,17 @@ function ClassManagerPanel() {
713
672
  disabled: !isDirty2,
714
673
  loading: isPublishing
715
674
  },
716
- __5("Save changes", "elementor")
717
- )))), /* @__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(
675
+ __4("Save changes", "elementor")
676
+ )))), /* @__PURE__ */ React7.createElement(ClassManagerIntroduction, null), isSaveChangesDialogOpen && /* @__PURE__ */ React7.createElement(SaveChangesDialog, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.Title, null, __4("You have unsaved changes", "elementor")), /* @__PURE__ */ React7.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.ContentText, null, __4("You have unsaved changes in the Class Manager.", "elementor")), /* @__PURE__ */ React7.createElement(SaveChangesDialog.ContentText, null, __4("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React7.createElement(
718
677
  SaveChangesDialog.Actions,
719
678
  {
720
679
  actions: {
721
680
  cancel: {
722
- label: __5("Cancel", "elementor"),
681
+ label: __4("Cancel", "elementor"),
723
682
  action: closeSaveChangesDialog
724
683
  },
725
684
  confirm: {
726
- label: __5("Save & Continue", "elementor"),
685
+ label: __4("Save & Continue", "elementor"),
727
686
  action: async () => {
728
687
  await publish();
729
688
  closeSaveChangesDialog();
@@ -735,7 +694,7 @@ function ClassManagerPanel() {
735
694
  )));
736
695
  }
737
696
  var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */ React7.createElement(IconButton2, { size: "small", color: "secondary", onClick: onClose, "aria-label": "Close", ...props }, /* @__PURE__ */ React7.createElement(XIcon, { fontSize: "small" }));
738
- 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"))));
697
+ 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, __4("Something went wrong", "elementor"))));
739
698
  var usePreventUnload = () => {
740
699
  const isDirty2 = useDirtyState();
741
700
  useEffect(() => {
@@ -775,7 +734,7 @@ var ClassManagerButton = () => {
775
734
  }
776
735
  openPanel();
777
736
  };
778
- 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(
737
+ return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(Tooltip2, { title: __5("Class Manager", "elementor"), placement: "top" }, /* @__PURE__ */ React8.createElement(IconButton3, { size: "tiny", onClick: handleOpenPanel, sx: { marginInlineEnd: -0.75 } }, /* @__PURE__ */ React8.createElement(FlippedColorSwatchIcon, { fontSize: "tiny" }))), isSaveChangesDialogOpen && /* @__PURE__ */ React8.createElement(SaveChangesDialog, null, /* @__PURE__ */ React8.createElement(SaveChangesDialog.Title, null, __5("You have unsaved changes", "elementor")), /* @__PURE__ */ React8.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React8.createElement(SaveChangesDialog.ContentText, { sx: { mb: 2 } }, __5(
779
738
  "To open the Class Manager, save your page first. You can't continue without saving.",
780
739
  "elementor"
781
740
  ))), /* @__PURE__ */ React8.createElement(
@@ -783,11 +742,11 @@ var ClassManagerButton = () => {
783
742
  {
784
743
  actions: {
785
744
  cancel: {
786
- label: __6("Stay here", "elementor"),
745
+ label: __5("Stay here", "elementor"),
787
746
  action: closeSaveChangesDialog
788
747
  },
789
748
  confirm: {
790
- label: __6("Save & Continue", "elementor"),
749
+ label: __5("Save & Continue", "elementor"),
791
750
  action: async () => {
792
751
  await saveDocument();
793
752
  closeSaveChangesDialog();
@@ -801,18 +760,80 @@ var ClassManagerButton = () => {
801
760
 
802
761
  // src/components/populate-store.tsx
803
762
  import { useEffect as useEffect2 } from "react";
804
- import { __useDispatch as useDispatch } from "@elementor/store";
763
+ import { __useDispatch as useDispatch2 } from "@elementor/store";
805
764
  function PopulateStore() {
806
- const dispatch3 = useDispatch();
765
+ const dispatch4 = useDispatch2();
807
766
  useEffect2(() => {
808
767
  apiClient.all().then((res) => {
809
768
  const { data, meta } = res.data;
810
- dispatch3(slice.actions.init({ items: data, order: meta.order }));
769
+ dispatch4(slice.actions.init({ items: data, order: meta.order }));
811
770
  });
812
- }, [dispatch3]);
771
+ }, [dispatch4]);
813
772
  return null;
814
773
  }
815
774
 
775
+ // src/global-classes-styles-provider.ts
776
+ import { generateId } from "@elementor/editor-styles";
777
+ import { createStylesProvider } from "@elementor/editor-styles-repository";
778
+ import {
779
+ __dispatch as dispatch3,
780
+ __getState as getState2,
781
+ __subscribeWithSelector as subscribeWithSelector
782
+ } from "@elementor/store";
783
+ import { __ as __6 } from "@wordpress/i18n";
784
+ var MAX_CLASSES = 50;
785
+ var globalClassesStylesProvider = createStylesProvider({
786
+ key: "global-classes",
787
+ priority: 30,
788
+ limit: MAX_CLASSES,
789
+ labels: {
790
+ singular: __6("class", "elementor"),
791
+ plural: __6("classes", "elementor")
792
+ },
793
+ subscribe: (cb) => subscribeWithSelector((state) => state.globalClasses, cb),
794
+ actions: {
795
+ all: () => selectOrderedClasses(getState2()),
796
+ get: (id2) => selectClass(getState2(), id2),
797
+ create: (label) => {
798
+ const classes = selectGlobalClasses(getState2());
799
+ const existingLabels = Object.values(classes).map((style) => style.label);
800
+ if (existingLabels.includes(label)) {
801
+ throw new GlobalClassLabelAlreadyExistsError({ context: { label } });
802
+ }
803
+ const existingIds = Object.keys(classes);
804
+ const id2 = generateId("g-", existingIds);
805
+ dispatch3(
806
+ slice.actions.add({
807
+ id: id2,
808
+ type: "class",
809
+ label,
810
+ variants: []
811
+ })
812
+ );
813
+ return id2;
814
+ },
815
+ update: (payload) => {
816
+ dispatch3(
817
+ slice.actions.update({
818
+ style: payload
819
+ })
820
+ );
821
+ },
822
+ delete: (id2) => {
823
+ dispatch3(slice.actions.delete(id2));
824
+ },
825
+ updateProps: (args) => {
826
+ dispatch3(
827
+ slice.actions.updateProps({
828
+ id: args.id,
829
+ meta: args.meta,
830
+ props: args.props
831
+ })
832
+ );
833
+ }
834
+ }
835
+ });
836
+
816
837
  // src/sync-with-document-save.ts
817
838
  import { setDocumentModifiedStatus as setDocumentModifiedStatus2 } from "@elementor/editor-documents";
818
839
  import { registerDataHook } from "@elementor/editor-v1-adapters";
@@ -845,7 +866,7 @@ function isDirty() {
845
866
  function init() {
846
867
  registerSlice(slice);
847
868
  registerPanel(panel);
848
- stylesRepository2.register(globalClassesStylesProvider);
869
+ stylesRepository.register(globalClassesStylesProvider);
849
870
  injectIntoLogic({
850
871
  id: "global-classes-populate-store",
851
872
  component: PopulateStore
@@ -858,7 +879,7 @@ function init() {
858
879
  syncWithDocumentSave();
859
880
  });
860
881
  }
861
-
862
- // src/index.ts
863
- init();
882
+ export {
883
+ init
884
+ };
864
885
  //# sourceMappingURL=index.mjs.map