@elementor/editor-global-classes 0.7.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -7,92 +7,37 @@ import { __privateListenTo as listenTo, v1ReadyEvent } from "@elementor/editor-v
7
7
  import { __registerSlice as registerSlice } from "@elementor/store";
8
8
 
9
9
  // src/components/class-manager/class-manager-button.tsx
10
- import * as React6 from "react";
10
+ import * as React7 from "react";
11
11
  import { ColorSwatchIcon as ColorSwatchIcon2 } from "@elementor/icons";
12
12
  import { IconButton as IconButton3, Tooltip as Tooltip2 } from "@elementor/ui";
13
13
  import { __ as __6 } from "@wordpress/i18n";
14
14
 
15
15
  // src/components/class-manager/class-manager-panel.tsx
16
- import * as React5 from "react";
16
+ import * as React6 from "react";
17
17
  import {
18
18
  __createPanel as createPanel,
19
19
  Panel,
20
20
  PanelBody,
21
+ PanelFooter,
21
22
  PanelHeader,
22
23
  PanelHeaderTitle
23
24
  } from "@elementor/editor-panels";
24
25
  import { ColorSwatchIcon, XIcon } from "@elementor/icons";
25
- import { Alert, Box as Box4, ErrorBoundary, IconButton as IconButton2, Stack as Stack3 } from "@elementor/ui";
26
+ import { Alert, Box as Box4, Button as Button3, ErrorBoundary, IconButton as IconButton2, Stack as Stack3 } from "@elementor/ui";
26
27
  import { __ as __5 } from "@wordpress/i18n";
27
28
 
28
- // src/components/class-manager/class-manager-introduction.tsx
29
- import * as React from "react";
30
- import { useState } from "react";
31
- import { useSuppressedMessage } from "@elementor/editor-current-user";
32
- import { IntroductionModal } from "@elementor/editor-ui";
33
- import { Box, Image, Stack, Typography } from "@elementor/ui";
34
- import { __ } from "@wordpress/i18n";
35
- var MESSAGE_KEY = "global-class-manager-4";
36
- var ClassManagerIntroduction = () => {
37
- const [isMessageSuppressed, suppressMessage] = useSuppressedMessage(MESSAGE_KEY);
38
- const [shouldShowIntroduction, setShouldShowIntroduction] = useState(!isMessageSuppressed);
39
- return /* @__PURE__ */ React.createElement(
40
- IntroductionModal,
41
- {
42
- open: shouldShowIntroduction,
43
- title: __("CSS Class manager", "elementor"),
44
- content: /* @__PURE__ */ React.createElement(IntroductionContent, null),
45
- handleClose: (shouldShowAgain) => {
46
- if (!shouldShowAgain) {
47
- suppressMessage();
48
- }
49
- setShouldShowIntroduction(false);
50
- }
51
- }
52
- );
53
- };
54
- var IntroductionContent = () => {
55
- return /* @__PURE__ */ React.createElement(Stack, { gap: 1.5, padding: 3 }, /* @__PURE__ */ React.createElement(Image, { sx: { width: "100%", height: "312px" }, src: "", alt: "Introduction" }), /* @__PURE__ */ React.createElement(Box, null, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, __(
56
- "The CSS Class Manager allows you to manage and organize your site's CSS classes efficiently. You can reorder classes to adjust their priority, rename them to maintain clarity in your design system, and delete unused classes to keep your CSS structured.",
57
- "elementor"
58
- )), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, __(
59
- "Changes apply globally\u2014any modifications will affect all elements using the class, impacting the class order and priority across your site.",
60
- "elementor"
61
- ))));
62
- };
29
+ // src/hooks/use-dirty-state.ts
30
+ import { __useSelector as useSelector } from "@elementor/store";
63
31
 
64
- // src/components/class-manager/global-classes-list.tsx
65
- import * as React4 from "react";
66
- import { stylesRepository } from "@elementor/editor-styles-repository";
67
- import { EditableField, EllipsisWithTooltip, useEditable } from "@elementor/editor-ui";
68
- import { DotsVerticalIcon, PhotoIcon } from "@elementor/icons";
32
+ // src/store.ts
33
+ import { mergeProps } from "@elementor/editor-props";
69
34
  import {
70
- bindMenu,
71
- bindTrigger,
72
- Box as Box3,
73
- IconButton,
74
- List,
75
- ListItem,
76
- ListItemButton,
77
- ListItemText,
78
- Menu,
79
- MenuItem,
80
- Stack as Stack2,
81
- styled as styled2,
82
- Tooltip,
83
- Typography as Typography3,
84
- usePopupState
85
- } from "@elementor/ui";
86
- import { __ as __4 } from "@wordpress/i18n";
87
-
88
- // src/global-classes-styles-provider.ts
89
- import { generateId } from "@elementor/editor-styles";
35
+ getVariantByMeta
36
+ } from "@elementor/editor-styles";
90
37
  import {
91
- __dispatch as dispatch,
92
- __getState as getState,
93
- __subscribeWithSelector as subscribeWithSelector
38
+ __createSelector as createSelector,
39
+ __createSlice as createSlice
94
40
  } from "@elementor/store";
95
- import { __ as __2 } from "@wordpress/i18n";
96
41
 
97
42
  // src/errors.ts
98
43
  import { createError } from "@elementor/utils";
@@ -106,15 +51,6 @@ var GlobalClassLabelAlreadyExistsError = createError({
106
51
  });
107
52
 
108
53
  // src/store.ts
109
- import { mergeProps } from "@elementor/editor-props";
110
- import {
111
- getVariantByMeta
112
- } from "@elementor/editor-styles";
113
- import {
114
- __createSelector as createSelector,
115
- __createSlice as createSlice,
116
- __useSelector as useSelector
117
- } from "@elementor/store";
118
54
  var initialState = {
119
55
  items: {},
120
56
  order: [],
@@ -142,6 +78,7 @@ var slice = createSlice({
142
78
  },
143
79
  setOrder(state, { payload }) {
144
80
  state.order = payload;
81
+ state.isDirty = true;
145
82
  },
146
83
  update(state, { payload }) {
147
84
  const style = state.items[payload.style.id];
@@ -174,35 +111,129 @@ var slice = createSlice({
174
111
  });
175
112
  var selectOrder = (state) => state[SLICE_NAME].order;
176
113
  var selectGlobalClasses = (state) => state[SLICE_NAME].items;
177
- var selectOrderedGlobalClasses = createSelector(
114
+ var selectOrderedClasses = createSelector(
178
115
  selectGlobalClasses,
179
116
  selectOrder,
180
117
  (items, order) => order.map((id) => items[id])
181
118
  );
182
119
  var selectClass = (state, id) => state[SLICE_NAME].items[id] ?? null;
183
120
  var selectIsDirty = (state) => state.globalClasses.isDirty;
184
- var useOrderedGlobalClasses = () => {
185
- const items = useSelector(selectOrderedGlobalClasses);
186
- return items;
121
+
122
+ // src/hooks/use-dirty-state.ts
123
+ var useDirtyState = () => {
124
+ return useSelector(selectIsDirty);
125
+ };
126
+
127
+ // src/publish-global-classes.ts
128
+ import { __dispatch as dispatch, __getState as getState } from "@elementor/store";
129
+
130
+ // src/api.ts
131
+ import { httpService } from "@elementor/http";
132
+ var RESOURCE_URL = "/global-classes";
133
+ var apiClient = {
134
+ all: () => httpService().get("elementor/v1" + RESOURCE_URL),
135
+ update: (payload) => httpService().put("elementor/v1" + RESOURCE_URL, payload)
136
+ };
137
+
138
+ // src/publish-global-classes.ts
139
+ async function publishGlobalClasses() {
140
+ if (!isDirty()) {
141
+ return;
142
+ }
143
+ const state = getState().globalClasses;
144
+ await apiClient.update({
145
+ items: state.items,
146
+ order: state.order
147
+ });
148
+ dispatch(slice.actions.setPristine());
149
+ }
150
+ function isDirty() {
151
+ return selectIsDirty(getState());
152
+ }
153
+
154
+ // src/components/class-manager/class-manager-introduction.tsx
155
+ import * as React from "react";
156
+ import { useState } from "react";
157
+ import { useSuppressedMessage } from "@elementor/editor-current-user";
158
+ import { IntroductionModal } from "@elementor/editor-ui";
159
+ import { Box, Image, Stack, Typography } from "@elementor/ui";
160
+ import { __ } from "@wordpress/i18n";
161
+ var MESSAGE_KEY = "global-class-manager-4";
162
+ var ClassManagerIntroduction = () => {
163
+ const [isMessageSuppressed, suppressMessage] = useSuppressedMessage(MESSAGE_KEY);
164
+ const [shouldShowIntroduction, setShouldShowIntroduction] = useState(!isMessageSuppressed);
165
+ return /* @__PURE__ */ React.createElement(
166
+ IntroductionModal,
167
+ {
168
+ open: shouldShowIntroduction,
169
+ title: __("CSS Class manager", "elementor"),
170
+ content: /* @__PURE__ */ React.createElement(IntroductionContent, null),
171
+ handleClose: (shouldShowAgain) => {
172
+ if (!shouldShowAgain) {
173
+ suppressMessage();
174
+ }
175
+ setShouldShowIntroduction(false);
176
+ }
177
+ }
178
+ );
179
+ };
180
+ var IntroductionContent = () => {
181
+ return /* @__PURE__ */ React.createElement(Stack, { gap: 1.5, padding: 3 }, /* @__PURE__ */ React.createElement(Image, { sx: { width: "100%", height: "312px" }, src: "", alt: "Introduction" }), /* @__PURE__ */ React.createElement(Box, null, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, __(
182
+ "The CSS Class Manager allows you to manage and organize your site's CSS classes efficiently. You can reorder classes to adjust their priority, rename them to maintain clarity in your design system, and delete unused classes to keep your CSS structured.",
183
+ "elementor"
184
+ )), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, __(
185
+ "Changes apply globally\u2014any modifications will affect all elements using the class, impacting the class order and priority across your site.",
186
+ "elementor"
187
+ ))));
187
188
  };
188
- var useGlobalClassesOrder = () => useSelector(selectOrder);
189
+
190
+ // src/components/class-manager/global-classes-list.tsx
191
+ import * as React4 from "react";
192
+ import { stylesRepository } from "@elementor/editor-styles-repository";
193
+ import { EditableField, EllipsisWithTooltip, useEditable } from "@elementor/editor-ui";
194
+ import { DotsVerticalIcon, PhotoIcon } from "@elementor/icons";
195
+ import {
196
+ bindMenu,
197
+ bindTrigger,
198
+ Box as Box3,
199
+ IconButton,
200
+ List,
201
+ ListItem,
202
+ ListItemButton,
203
+ ListItemText,
204
+ Menu,
205
+ MenuItem,
206
+ Stack as Stack2,
207
+ styled as styled2,
208
+ Tooltip,
209
+ Typography as Typography3,
210
+ usePopupState
211
+ } from "@elementor/ui";
212
+ import { __ as __4 } from "@wordpress/i18n";
189
213
 
190
214
  // src/global-classes-styles-provider.ts
215
+ import { generateId } from "@elementor/editor-styles";
216
+ import {
217
+ __dispatch as dispatch2,
218
+ __getState as getState2,
219
+ __subscribeWithSelector as subscribeWithSelector
220
+ } from "@elementor/store";
221
+ import { __ as __2 } from "@wordpress/i18n";
191
222
  var globalClassesStylesProvider = {
192
223
  key: "global-classes",
193
224
  priority: 30,
194
225
  actions: {
195
- get: () => selectOrderedGlobalClasses(getState()),
196
- getById: (id) => selectClass(getState(), id),
226
+ get: () => selectOrderedClasses(getState2()),
227
+ getById: (id) => selectClass(getState2(), id),
197
228
  create: (label) => {
198
- const classes = selectGlobalClasses(getState());
229
+ const classes = selectGlobalClasses(getState2());
199
230
  const existingLabels = Object.values(classes).map((style) => style.label);
200
231
  if (existingLabels.includes(label)) {
201
232
  throw new GlobalClassLabelAlreadyExistsError({ context: { label } });
202
233
  }
203
234
  const existingIds = Object.keys(classes);
204
235
  const id = generateId("g-", existingIds);
205
- dispatch(
236
+ dispatch2(
206
237
  slice.actions.add({
207
238
  id,
208
239
  type: "class",
@@ -213,20 +244,20 @@ var globalClassesStylesProvider = {
213
244
  return id;
214
245
  },
215
246
  update: (payload) => {
216
- dispatch(
247
+ dispatch2(
217
248
  slice.actions.update({
218
249
  style: payload
219
250
  })
220
251
  );
221
252
  },
222
253
  delete: (id) => {
223
- dispatch(slice.actions.delete(id));
254
+ dispatch2(slice.actions.delete(id));
224
255
  },
225
256
  setOrder: (order) => {
226
- dispatch(slice.actions.setOrder(order));
257
+ dispatch2(slice.actions.setOrder(order));
227
258
  },
228
259
  updateProps: (args) => {
229
- dispatch(
260
+ dispatch2(
230
261
  slice.actions.updateProps({
231
262
  id: args.id,
232
263
  meta: args.meta,
@@ -242,6 +273,18 @@ var globalClassesStylesProvider = {
242
273
  }
243
274
  };
244
275
 
276
+ // src/hooks/use-classes-order.ts
277
+ import { __useSelector as useSelector2 } from "@elementor/store";
278
+ var useClassesOrder = () => {
279
+ return useSelector2(selectOrder);
280
+ };
281
+
282
+ // src/hooks/use-ordered-classes.ts
283
+ import { __useSelector as useSelector3 } from "@elementor/store";
284
+ var useOrderedClasses = () => {
285
+ return useSelector3(selectOrderedClasses);
286
+ };
287
+
245
288
  // src/components/class-manager/delete-confirmation-dialog.tsx
246
289
  import * as React2 from "react";
247
290
  import { createContext, useContext, useState as useState2 } from "react";
@@ -352,8 +395,8 @@ var SortableItemIndicator = styled(Box2)`
352
395
 
353
396
  // src/components/class-manager/global-classes-list.tsx
354
397
  var GlobalClassesList = () => {
355
- const cssClasses = useOrderedGlobalClasses();
356
- const [classesOrder, reorderClasses] = useClassesOrder();
398
+ const cssClasses = useOrderedClasses();
399
+ const [classesOrder, reorderClasses] = useReorder();
357
400
  if (!cssClasses?.length) {
358
401
  return /* @__PURE__ */ React4.createElement(EmptyState, null);
359
402
  }
@@ -373,8 +416,8 @@ var GlobalClassesList = () => {
373
416
  ));
374
417
  }))));
375
418
  };
376
- var useClassesOrder = () => {
377
- const order = useGlobalClassesOrder();
419
+ var useReorder = () => {
420
+ const order = useClassesOrder();
378
421
  const reorder = (newIds) => {
379
422
  globalClassesStylesProvider.actions.setOrder(newIds);
380
423
  };
@@ -534,53 +577,118 @@ var validateLabel = (newLabel) => {
534
577
  return null;
535
578
  };
536
579
 
580
+ // src/components/class-manager/unsaved-changes-dialog.tsx
581
+ import * as React5 from "react";
582
+ import { useState as useState3 } from "react";
583
+ import { AlertTriangleFilledIcon } from "@elementor/icons";
584
+ import {
585
+ Button as Button2,
586
+ Dialog as Dialog2,
587
+ DialogActions as DialogActions2,
588
+ DialogContent as DialogContent2,
589
+ DialogContentText as DialogContentText2,
590
+ DialogTitle as DialogTitle2
591
+ } from "@elementor/ui";
592
+ var TITLE_ID2 = "unsaved-changes-dialog";
593
+ var UnsavedChangesDialog = ({ children, onClose }) => /* @__PURE__ */ React5.createElement(Dialog2, { open: true, onClose, "aria-labelledby": TITLE_ID2, maxWidth: "xs" }, children);
594
+ var UnsavedChangesDialogTitle = ({ children }) => /* @__PURE__ */ React5.createElement(DialogTitle2, { id: TITLE_ID2, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React5.createElement(AlertTriangleFilledIcon, { color: "secondary" }), children);
595
+ var UnsavedChangesDialogContent = ({ children }) => /* @__PURE__ */ React5.createElement(DialogContent2, null, /* @__PURE__ */ React5.createElement(DialogContentText2, { variant: "body2", color: "textPrimary" }, children));
596
+ var UnsavedChangesDialogActions = ({ actions }) => {
597
+ const { cancel, confirm } = actions;
598
+ return /* @__PURE__ */ React5.createElement(DialogActions2, null, /* @__PURE__ */ React5.createElement(Button2, { variant: "text", color: "secondary", onClick: cancel.action }, cancel.label), /* @__PURE__ */ React5.createElement(Button2, { variant: "contained", color: "secondary", onClick: confirm.action }, confirm.label));
599
+ };
600
+ UnsavedChangesDialog.Title = UnsavedChangesDialogTitle;
601
+ UnsavedChangesDialog.Content = UnsavedChangesDialogContent;
602
+ UnsavedChangesDialog.Actions = UnsavedChangesDialogActions;
603
+ var useDialog = () => {
604
+ const [isOpen, setIsOpen] = useState3(false);
605
+ const open = () => setIsOpen(true);
606
+ const close = () => setIsOpen(false);
607
+ return { isOpen, open, close };
608
+ };
609
+
537
610
  // src/components/class-manager/class-manager-panel.tsx
538
611
  var { panel, usePanelActions } = createPanel({
539
612
  id: "class-manager-panel",
540
613
  component: ClassManagerPanel
541
614
  });
542
615
  function ClassManagerPanel() {
543
- return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(ErrorBoundary, { fallback: /* @__PURE__ */ React5.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React5.createElement(Panel, null, /* @__PURE__ */ React5.createElement(PanelHeader, null, /* @__PURE__ */ React5.createElement(Stack3, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React5.createElement(PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React5.createElement(ColorSwatchIcon, { fontSize: "inherit", sx: { transform: "rotate(90deg)" } }), __5("CSS Class manager", "elementor")), /* @__PURE__ */ React5.createElement(CloseButton, { sx: { marginLeft: "auto" } }))), /* @__PURE__ */ React5.createElement(PanelBody, { px: 2 }, /* @__PURE__ */ React5.createElement(GlobalClassesList, null)))), /* @__PURE__ */ React5.createElement(ClassManagerIntroduction, null));
616
+ const isDirty3 = useDirtyState();
617
+ const { close: closePanel } = usePanelActions();
618
+ const {
619
+ open: openUnsavedChangesDialog,
620
+ close: closeUnsavedChangesDialog,
621
+ isOpen: isUnsavedChangesDialogOpen
622
+ } = useDialog();
623
+ return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(ErrorBoundary, { fallback: /* @__PURE__ */ React6.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React6.createElement(Panel, null, /* @__PURE__ */ React6.createElement(PanelHeader, null, /* @__PURE__ */ React6.createElement(Stack3, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React6.createElement(PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React6.createElement(ColorSwatchIcon, { fontSize: "inherit", sx: { transform: "rotate(90deg)" } }), __5("CSS Class manager", "elementor")), /* @__PURE__ */ React6.createElement(
624
+ CloseButton,
625
+ {
626
+ sx: { marginLeft: "auto" },
627
+ onClose: () => {
628
+ if (isDirty3) {
629
+ openUnsavedChangesDialog();
630
+ return;
631
+ }
632
+ closePanel();
633
+ }
634
+ }
635
+ ))), /* @__PURE__ */ React6.createElement(PanelBody, { px: 2 }, /* @__PURE__ */ React6.createElement(GlobalClassesList, null)), /* @__PURE__ */ React6.createElement(PanelFooter, null, /* @__PURE__ */ React6.createElement(
636
+ Button3,
637
+ {
638
+ fullWidth: true,
639
+ size: "small",
640
+ variant: "contained",
641
+ color: "global",
642
+ disabled: !isDirty3,
643
+ onClick: publishGlobalClasses
644
+ },
645
+ __5("Save changes", "elementor")
646
+ )))), /* @__PURE__ */ React6.createElement(ClassManagerIntroduction, null), isUnsavedChangesDialogOpen && /* @__PURE__ */ React6.createElement(UnsavedChangesDialog, null, /* @__PURE__ */ React6.createElement(UnsavedChangesDialog.Title, null, __5("You have unsaved changes", "elementor")), /* @__PURE__ */ React6.createElement(UnsavedChangesDialog.Content, null, __5("You have unsaved changes in the Class Manager.", "elementor"), /* @__PURE__ */ React6.createElement("br", null), __5("To avoid losing your updates, save your changes before leaving.", "elementor")), /* @__PURE__ */ React6.createElement(
647
+ UnsavedChangesDialog.Actions,
648
+ {
649
+ actions: {
650
+ cancel: {
651
+ label: __5("Cancel", "elementor"),
652
+ action: closeUnsavedChangesDialog
653
+ },
654
+ confirm: {
655
+ label: __5("Save & Continue", "elementor"),
656
+ action: () => {
657
+ publishGlobalClasses();
658
+ closeUnsavedChangesDialog();
659
+ closePanel();
660
+ }
661
+ }
662
+ }
663
+ }
664
+ )));
544
665
  }
545
- var CloseButton = (props) => {
546
- const { close } = usePanelActions();
547
- return /* @__PURE__ */ React5.createElement(IconButton2, { size: "small", color: "secondary", onClick: close, ...props }, /* @__PURE__ */ React5.createElement(XIcon, { fontSize: "small" }));
548
- };
549
- var ErrorBoundaryFallback = () => /* @__PURE__ */ React5.createElement(Box4, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React5.createElement(Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React5.createElement("strong", null, __5("Something went wrong", "elementor"))));
666
+ var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */ React6.createElement(IconButton2, { size: "small", color: "secondary", onClick: onClose, "aria-label": "Close", ...props }, /* @__PURE__ */ React6.createElement(XIcon, { fontSize: "small" }));
667
+ var ErrorBoundaryFallback = () => /* @__PURE__ */ React6.createElement(Box4, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React6.createElement(Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React6.createElement("strong", null, __5("Something went wrong", "elementor"))));
550
668
 
551
669
  // src/components/class-manager/class-manager-button.tsx
552
670
  var ClassManagerButton = () => {
553
671
  const { open } = usePanelActions();
554
- return /* @__PURE__ */ React6.createElement(Tooltip2, { title: __6("Class manager", "elementor"), placement: "top" }, /* @__PURE__ */ React6.createElement(IconButton3, { onClick: open }, /* @__PURE__ */ React6.createElement(ColorSwatchIcon2, { fontSize: "tiny" })));
672
+ return /* @__PURE__ */ React7.createElement(Tooltip2, { title: __6("Class manager", "elementor"), placement: "top" }, /* @__PURE__ */ React7.createElement(IconButton3, { onClick: open }, /* @__PURE__ */ React7.createElement(ColorSwatchIcon2, { fontSize: "tiny" })));
555
673
  };
556
674
 
557
675
  // src/components/populate-store.tsx
558
676
  import { useEffect } from "react";
559
677
  import { __useDispatch as useDispatch } from "@elementor/store";
560
-
561
- // src/api.ts
562
- import { httpService } from "@elementor/http";
563
- var RESOURCE_URL = "/global-classes";
564
- var apiClient = {
565
- all: () => httpService().get("elementor/v1" + RESOURCE_URL),
566
- update: (payload) => httpService().put("elementor/v1" + RESOURCE_URL, payload)
567
- };
568
-
569
- // src/components/populate-store.tsx
570
678
  function PopulateStore() {
571
- const dispatch2 = useDispatch();
679
+ const dispatch3 = useDispatch();
572
680
  useEffect(() => {
573
681
  apiClient.all().then((res) => {
574
682
  const { data, meta } = res.data;
575
- dispatch2(slice.actions.init({ items: data, order: meta.order }));
683
+ dispatch3(slice.actions.init({ items: data, order: meta.order }));
576
684
  });
577
- }, [dispatch2]);
685
+ }, [dispatch3]);
578
686
  return null;
579
687
  }
580
688
 
581
689
  // src/sync-with-document-save.ts
582
690
  import { __privateRunCommandSync as runCommandSync, registerDataHook } from "@elementor/editor-v1-adapters";
583
- import { __dispatch, __getState as getState2, __subscribeWithSelector as subscribeWithSelector2 } from "@elementor/store";
691
+ import { __getState as getState3, __subscribeWithSelector as subscribeWithSelector2 } from "@elementor/store";
584
692
  function syncWithDocumentSave() {
585
693
  const unsubscribe = syncDirtyState();
586
694
  bindSaveAction();
@@ -588,27 +696,17 @@ function syncWithDocumentSave() {
588
696
  }
589
697
  function syncDirtyState() {
590
698
  return subscribeWithSelector2(selectIsDirty, () => {
591
- if (!isDirty()) {
699
+ if (!isDirty2()) {
592
700
  return;
593
701
  }
594
702
  runCommandSync("document/save/set-is-modified", { status: true }, { internal: true });
595
703
  });
596
704
  }
597
705
  function bindSaveAction() {
598
- registerDataHook("after", "document/save/save", async () => {
599
- if (!isDirty()) {
600
- return;
601
- }
602
- const state = getState2().globalClasses;
603
- await apiClient.update({
604
- items: state.items,
605
- order: state.order
606
- });
607
- __dispatch(slice.actions.setPristine());
608
- });
706
+ registerDataHook("after", "document/save/save", publishGlobalClasses);
609
707
  }
610
- function isDirty() {
611
- return selectIsDirty(getState2());
708
+ function isDirty2() {
709
+ return selectIsDirty(getState3());
612
710
  }
613
711
 
614
712
  // src/init.ts