@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/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @elementor/editor-global-classes
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d723ffa: Added unsaved changes dialog to global classes.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [9a5fd67]
12
+ - @elementor/editor-editing-panel@1.14.0
13
+
14
+ ## 0.8.0
15
+
16
+ ### Minor Changes
17
+
18
+ - 994025a: Added "save changes" button to global classes panel.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [994025a]
23
+ - @elementor/editor-panels@0.12.0
24
+ - @elementor/editor-editing-panel@1.13.1
25
+
3
26
  ## 0.7.1
4
27
 
5
28
  ### Patch Changes
package/dist/index.js CHANGED
@@ -28,69 +28,28 @@ 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
30
  var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
31
- var import_store9 = require("@elementor/store");
31
+ var import_store16 = require("@elementor/store");
32
32
 
33
33
  // src/components/class-manager/class-manager-button.tsx
34
- var React6 = __toESM(require("react"));
35
- var import_icons5 = require("@elementor/icons");
36
- var import_ui6 = require("@elementor/ui");
34
+ var React7 = __toESM(require("react"));
35
+ var import_icons6 = require("@elementor/icons");
36
+ var import_ui7 = require("@elementor/ui");
37
37
  var import_i18n6 = require("@wordpress/i18n");
38
38
 
39
39
  // src/components/class-manager/class-manager-panel.tsx
40
- var React5 = __toESM(require("react"));
40
+ var React6 = __toESM(require("react"));
41
41
  var import_editor_panels = require("@elementor/editor-panels");
42
- var import_icons4 = require("@elementor/icons");
43
- var import_ui5 = require("@elementor/ui");
42
+ var import_icons5 = require("@elementor/icons");
43
+ var import_ui6 = require("@elementor/ui");
44
44
  var import_i18n5 = require("@wordpress/i18n");
45
45
 
46
- // src/components/class-manager/class-manager-introduction.tsx
47
- var React = __toESM(require("react"));
48
- var import_react = require("react");
49
- var import_editor_current_user = require("@elementor/editor-current-user");
50
- var import_editor_ui = require("@elementor/editor-ui");
51
- var import_ui = require("@elementor/ui");
52
- var import_i18n = require("@wordpress/i18n");
53
- var MESSAGE_KEY = "global-class-manager-4";
54
- var ClassManagerIntroduction = () => {
55
- const [isMessageSuppressed, suppressMessage] = (0, import_editor_current_user.useSuppressedMessage)(MESSAGE_KEY);
56
- const [shouldShowIntroduction, setShouldShowIntroduction] = (0, import_react.useState)(!isMessageSuppressed);
57
- return /* @__PURE__ */ React.createElement(
58
- import_editor_ui.IntroductionModal,
59
- {
60
- open: shouldShowIntroduction,
61
- title: (0, import_i18n.__)("CSS Class manager", "elementor"),
62
- content: /* @__PURE__ */ React.createElement(IntroductionContent, null),
63
- handleClose: (shouldShowAgain) => {
64
- if (!shouldShowAgain) {
65
- suppressMessage();
66
- }
67
- setShouldShowIntroduction(false);
68
- }
69
- }
70
- );
71
- };
72
- var IntroductionContent = () => {
73
- return /* @__PURE__ */ React.createElement(import_ui.Stack, { gap: 1.5, padding: 3 }, /* @__PURE__ */ React.createElement(import_ui.Image, { sx: { width: "100%", height: "312px" }, src: "", alt: "Introduction" }), /* @__PURE__ */ React.createElement(import_ui.Box, null, /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "body2" }, (0, import_i18n.__)(
74
- "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.",
75
- "elementor"
76
- )), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "body2" }, (0, import_i18n.__)(
77
- "Changes apply globally\u2014any modifications will affect all elements using the class, impacting the class order and priority across your site.",
78
- "elementor"
79
- ))));
80
- };
81
-
82
- // src/components/class-manager/global-classes-list.tsx
83
- var React4 = __toESM(require("react"));
84
- var import_editor_styles_repository = require("@elementor/editor-styles-repository");
85
- var import_editor_ui2 = require("@elementor/editor-ui");
86
- var import_icons3 = require("@elementor/icons");
87
- var import_ui4 = require("@elementor/ui");
88
- var import_i18n4 = require("@wordpress/i18n");
89
-
90
- // src/global-classes-styles-provider.ts
91
- var import_editor_styles2 = require("@elementor/editor-styles");
46
+ // src/hooks/use-dirty-state.ts
92
47
  var import_store2 = require("@elementor/store");
93
- var import_i18n2 = require("@wordpress/i18n");
48
+
49
+ // src/store.ts
50
+ var import_editor_props = require("@elementor/editor-props");
51
+ var import_editor_styles = require("@elementor/editor-styles");
52
+ var import_store = require("@elementor/store");
94
53
 
95
54
  // src/errors.ts
96
55
  var import_utils = require("@elementor/utils");
@@ -104,9 +63,6 @@ var GlobalClassLabelAlreadyExistsError = (0, import_utils.createError)({
104
63
  });
105
64
 
106
65
  // src/store.ts
107
- var import_editor_props = require("@elementor/editor-props");
108
- var import_editor_styles = require("@elementor/editor-styles");
109
- var import_store = require("@elementor/store");
110
66
  var initialState = {
111
67
  items: {},
112
68
  order: [],
@@ -134,6 +90,7 @@ var slice = (0, import_store.__createSlice)({
134
90
  },
135
91
  setOrder(state, { payload }) {
136
92
  state.order = payload;
93
+ state.isDirty = true;
137
94
  },
138
95
  update(state, { payload }) {
139
96
  const style = state.items[payload.style.id];
@@ -166,35 +123,109 @@ var slice = (0, import_store.__createSlice)({
166
123
  });
167
124
  var selectOrder = (state) => state[SLICE_NAME].order;
168
125
  var selectGlobalClasses = (state) => state[SLICE_NAME].items;
169
- var selectOrderedGlobalClasses = (0, import_store.__createSelector)(
126
+ var selectOrderedClasses = (0, import_store.__createSelector)(
170
127
  selectGlobalClasses,
171
128
  selectOrder,
172
129
  (items, order) => order.map((id) => items[id])
173
130
  );
174
131
  var selectClass = (state, id) => state[SLICE_NAME].items[id] ?? null;
175
132
  var selectIsDirty = (state) => state.globalClasses.isDirty;
176
- var useOrderedGlobalClasses = () => {
177
- const items = (0, import_store.__useSelector)(selectOrderedGlobalClasses);
178
- return items;
133
+
134
+ // src/hooks/use-dirty-state.ts
135
+ var useDirtyState = () => {
136
+ return (0, import_store2.__useSelector)(selectIsDirty);
137
+ };
138
+
139
+ // src/publish-global-classes.ts
140
+ var import_store4 = require("@elementor/store");
141
+
142
+ // src/api.ts
143
+ var import_http = require("@elementor/http");
144
+ var RESOURCE_URL = "/global-classes";
145
+ var apiClient = {
146
+ all: () => (0, import_http.httpService)().get("elementor/v1" + RESOURCE_URL),
147
+ update: (payload) => (0, import_http.httpService)().put("elementor/v1" + RESOURCE_URL, payload)
148
+ };
149
+
150
+ // src/publish-global-classes.ts
151
+ async function publishGlobalClasses() {
152
+ if (!isDirty()) {
153
+ return;
154
+ }
155
+ const state = (0, import_store4.__getState)().globalClasses;
156
+ await apiClient.update({
157
+ items: state.items,
158
+ order: state.order
159
+ });
160
+ (0, import_store4.__dispatch)(slice.actions.setPristine());
161
+ }
162
+ function isDirty() {
163
+ return selectIsDirty((0, import_store4.__getState)());
164
+ }
165
+
166
+ // src/components/class-manager/class-manager-introduction.tsx
167
+ var React = __toESM(require("react"));
168
+ var import_react = require("react");
169
+ var import_editor_current_user = require("@elementor/editor-current-user");
170
+ var import_editor_ui = require("@elementor/editor-ui");
171
+ var import_ui = require("@elementor/ui");
172
+ var import_i18n = require("@wordpress/i18n");
173
+ var MESSAGE_KEY = "global-class-manager-4";
174
+ var ClassManagerIntroduction = () => {
175
+ const [isMessageSuppressed, suppressMessage] = (0, import_editor_current_user.useSuppressedMessage)(MESSAGE_KEY);
176
+ const [shouldShowIntroduction, setShouldShowIntroduction] = (0, import_react.useState)(!isMessageSuppressed);
177
+ return /* @__PURE__ */ React.createElement(
178
+ import_editor_ui.IntroductionModal,
179
+ {
180
+ open: shouldShowIntroduction,
181
+ title: (0, import_i18n.__)("CSS Class manager", "elementor"),
182
+ content: /* @__PURE__ */ React.createElement(IntroductionContent, null),
183
+ handleClose: (shouldShowAgain) => {
184
+ if (!shouldShowAgain) {
185
+ suppressMessage();
186
+ }
187
+ setShouldShowIntroduction(false);
188
+ }
189
+ }
190
+ );
191
+ };
192
+ var IntroductionContent = () => {
193
+ return /* @__PURE__ */ React.createElement(import_ui.Stack, { gap: 1.5, padding: 3 }, /* @__PURE__ */ React.createElement(import_ui.Image, { sx: { width: "100%", height: "312px" }, src: "", alt: "Introduction" }), /* @__PURE__ */ React.createElement(import_ui.Box, null, /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "body2" }, (0, import_i18n.__)(
194
+ "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.",
195
+ "elementor"
196
+ )), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "body2" }, (0, import_i18n.__)(
197
+ "Changes apply globally\u2014any modifications will affect all elements using the class, impacting the class order and priority across your site.",
198
+ "elementor"
199
+ ))));
179
200
  };
180
- var useGlobalClassesOrder = () => (0, import_store.__useSelector)(selectOrder);
201
+
202
+ // src/components/class-manager/global-classes-list.tsx
203
+ var React4 = __toESM(require("react"));
204
+ var import_editor_styles_repository = require("@elementor/editor-styles-repository");
205
+ var import_editor_ui2 = require("@elementor/editor-ui");
206
+ var import_icons3 = require("@elementor/icons");
207
+ var import_ui4 = require("@elementor/ui");
208
+ var import_i18n4 = require("@wordpress/i18n");
181
209
 
182
210
  // src/global-classes-styles-provider.ts
211
+ var import_editor_styles2 = require("@elementor/editor-styles");
212
+ var import_store6 = require("@elementor/store");
213
+ var import_i18n2 = require("@wordpress/i18n");
183
214
  var globalClassesStylesProvider = {
184
215
  key: "global-classes",
185
216
  priority: 30,
186
217
  actions: {
187
- get: () => selectOrderedGlobalClasses((0, import_store2.__getState)()),
188
- getById: (id) => selectClass((0, import_store2.__getState)(), id),
218
+ get: () => selectOrderedClasses((0, import_store6.__getState)()),
219
+ getById: (id) => selectClass((0, import_store6.__getState)(), id),
189
220
  create: (label) => {
190
- const classes = selectGlobalClasses((0, import_store2.__getState)());
221
+ const classes = selectGlobalClasses((0, import_store6.__getState)());
191
222
  const existingLabels = Object.values(classes).map((style) => style.label);
192
223
  if (existingLabels.includes(label)) {
193
224
  throw new GlobalClassLabelAlreadyExistsError({ context: { label } });
194
225
  }
195
226
  const existingIds = Object.keys(classes);
196
227
  const id = (0, import_editor_styles2.generateId)("g-", existingIds);
197
- (0, import_store2.__dispatch)(
228
+ (0, import_store6.__dispatch)(
198
229
  slice.actions.add({
199
230
  id,
200
231
  type: "class",
@@ -205,20 +236,20 @@ var globalClassesStylesProvider = {
205
236
  return id;
206
237
  },
207
238
  update: (payload) => {
208
- (0, import_store2.__dispatch)(
239
+ (0, import_store6.__dispatch)(
209
240
  slice.actions.update({
210
241
  style: payload
211
242
  })
212
243
  );
213
244
  },
214
245
  delete: (id) => {
215
- (0, import_store2.__dispatch)(slice.actions.delete(id));
246
+ (0, import_store6.__dispatch)(slice.actions.delete(id));
216
247
  },
217
248
  setOrder: (order) => {
218
- (0, import_store2.__dispatch)(slice.actions.setOrder(order));
249
+ (0, import_store6.__dispatch)(slice.actions.setOrder(order));
219
250
  },
220
251
  updateProps: (args) => {
221
- (0, import_store2.__dispatch)(
252
+ (0, import_store6.__dispatch)(
222
253
  slice.actions.updateProps({
223
254
  id: args.id,
224
255
  meta: args.meta,
@@ -227,13 +258,25 @@ var globalClassesStylesProvider = {
227
258
  );
228
259
  }
229
260
  },
230
- subscribe: (cb) => (0, import_store2.__subscribeWithSelector)((state) => state.globalClasses, cb),
261
+ subscribe: (cb) => (0, import_store6.__subscribeWithSelector)((state) => state.globalClasses, cb),
231
262
  labels: {
232
263
  singular: (0, import_i18n2.__)("Global class", "elementor"),
233
264
  plural: (0, import_i18n2.__)("Global CSS Classes", "elementor")
234
265
  }
235
266
  };
236
267
 
268
+ // src/hooks/use-classes-order.ts
269
+ var import_store8 = require("@elementor/store");
270
+ var useClassesOrder = () => {
271
+ return (0, import_store8.__useSelector)(selectOrder);
272
+ };
273
+
274
+ // src/hooks/use-ordered-classes.ts
275
+ var import_store10 = require("@elementor/store");
276
+ var useOrderedClasses = () => {
277
+ return (0, import_store10.__useSelector)(selectOrderedClasses);
278
+ };
279
+
237
280
  // src/components/class-manager/delete-confirmation-dialog.tsx
238
281
  var React2 = __toESM(require("react"));
239
282
  var import_react2 = require("react");
@@ -330,8 +373,8 @@ var SortableItemIndicator = (0, import_ui3.styled)(import_ui3.Box)`
330
373
 
331
374
  // src/components/class-manager/global-classes-list.tsx
332
375
  var GlobalClassesList = () => {
333
- const cssClasses = useOrderedGlobalClasses();
334
- const [classesOrder, reorderClasses] = useClassesOrder();
376
+ const cssClasses = useOrderedClasses();
377
+ const [classesOrder, reorderClasses] = useReorder();
335
378
  if (!cssClasses?.length) {
336
379
  return /* @__PURE__ */ React4.createElement(EmptyState, null);
337
380
  }
@@ -351,8 +394,8 @@ var GlobalClassesList = () => {
351
394
  ));
352
395
  }))));
353
396
  };
354
- var useClassesOrder = () => {
355
- const order = useGlobalClassesOrder();
397
+ var useReorder = () => {
398
+ const order = useClassesOrder();
356
399
  const reorder = (newIds) => {
357
400
  globalClassesStylesProvider.actions.setOrder(newIds);
358
401
  };
@@ -512,86 +555,134 @@ var validateLabel = (newLabel) => {
512
555
  return null;
513
556
  };
514
557
 
558
+ // src/components/class-manager/unsaved-changes-dialog.tsx
559
+ var React5 = __toESM(require("react"));
560
+ var import_react3 = require("react");
561
+ var import_icons4 = require("@elementor/icons");
562
+ var import_ui5 = require("@elementor/ui");
563
+ var TITLE_ID2 = "unsaved-changes-dialog";
564
+ var UnsavedChangesDialog = ({ children, onClose }) => /* @__PURE__ */ React5.createElement(import_ui5.Dialog, { open: true, onClose, "aria-labelledby": TITLE_ID2, maxWidth: "xs" }, children);
565
+ var UnsavedChangesDialogTitle = ({ 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);
566
+ var UnsavedChangesDialogContent = ({ children }) => /* @__PURE__ */ React5.createElement(import_ui5.DialogContent, null, /* @__PURE__ */ React5.createElement(import_ui5.DialogContentText, { variant: "body2", color: "textPrimary" }, children));
567
+ var UnsavedChangesDialogActions = ({ actions }) => {
568
+ const { cancel, confirm } = actions;
569
+ 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: confirm.action }, confirm.label));
570
+ };
571
+ UnsavedChangesDialog.Title = UnsavedChangesDialogTitle;
572
+ UnsavedChangesDialog.Content = UnsavedChangesDialogContent;
573
+ UnsavedChangesDialog.Actions = UnsavedChangesDialogActions;
574
+ var useDialog = () => {
575
+ const [isOpen, setIsOpen] = (0, import_react3.useState)(false);
576
+ const open = () => setIsOpen(true);
577
+ const close = () => setIsOpen(false);
578
+ return { isOpen, open, close };
579
+ };
580
+
515
581
  // src/components/class-manager/class-manager-panel.tsx
516
582
  var { panel, usePanelActions } = (0, import_editor_panels.__createPanel)({
517
583
  id: "class-manager-panel",
518
584
  component: ClassManagerPanel
519
585
  });
520
586
  function ClassManagerPanel() {
521
- return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(import_ui5.ErrorBoundary, { fallback: /* @__PURE__ */ React5.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React5.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React5.createElement(import_editor_panels.PanelHeader, null, /* @__PURE__ */ React5.createElement(import_ui5.Stack, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React5.createElement(import_editor_panels.PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React5.createElement(import_icons4.ColorSwatchIcon, { fontSize: "inherit", sx: { transform: "rotate(90deg)" } }), (0, import_i18n5.__)("CSS Class manager", "elementor")), /* @__PURE__ */ React5.createElement(CloseButton, { sx: { marginLeft: "auto" } }))), /* @__PURE__ */ React5.createElement(import_editor_panels.PanelBody, { px: 2 }, /* @__PURE__ */ React5.createElement(GlobalClassesList, null)))), /* @__PURE__ */ React5.createElement(ClassManagerIntroduction, null));
587
+ const isDirty3 = useDirtyState();
588
+ const { close: closePanel } = usePanelActions();
589
+ const {
590
+ open: openUnsavedChangesDialog,
591
+ close: closeUnsavedChangesDialog,
592
+ isOpen: isUnsavedChangesDialogOpen
593
+ } = useDialog();
594
+ 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(
595
+ CloseButton,
596
+ {
597
+ sx: { marginLeft: "auto" },
598
+ onClose: () => {
599
+ if (isDirty3) {
600
+ openUnsavedChangesDialog();
601
+ return;
602
+ }
603
+ closePanel();
604
+ }
605
+ }
606
+ ))), /* @__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(
607
+ import_ui6.Button,
608
+ {
609
+ fullWidth: true,
610
+ size: "small",
611
+ variant: "contained",
612
+ color: "global",
613
+ disabled: !isDirty3,
614
+ onClick: publishGlobalClasses
615
+ },
616
+ (0, import_i18n5.__)("Save changes", "elementor")
617
+ )))), /* @__PURE__ */ React6.createElement(ClassManagerIntroduction, null), isUnsavedChangesDialogOpen && /* @__PURE__ */ React6.createElement(UnsavedChangesDialog, null, /* @__PURE__ */ React6.createElement(UnsavedChangesDialog.Title, null, (0, import_i18n5.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React6.createElement(UnsavedChangesDialog.Content, null, (0, import_i18n5.__)("You have unsaved changes in the Class Manager.", "elementor"), /* @__PURE__ */ React6.createElement("br", null), (0, import_i18n5.__)("To avoid losing your updates, save your changes before leaving.", "elementor")), /* @__PURE__ */ React6.createElement(
618
+ UnsavedChangesDialog.Actions,
619
+ {
620
+ actions: {
621
+ cancel: {
622
+ label: (0, import_i18n5.__)("Cancel", "elementor"),
623
+ action: closeUnsavedChangesDialog
624
+ },
625
+ confirm: {
626
+ label: (0, import_i18n5.__)("Save & Continue", "elementor"),
627
+ action: () => {
628
+ publishGlobalClasses();
629
+ closeUnsavedChangesDialog();
630
+ closePanel();
631
+ }
632
+ }
633
+ }
634
+ }
635
+ )));
522
636
  }
523
- var CloseButton = (props) => {
524
- const { close } = usePanelActions();
525
- return /* @__PURE__ */ React5.createElement(import_ui5.IconButton, { size: "small", color: "secondary", onClick: close, ...props }, /* @__PURE__ */ React5.createElement(import_icons4.XIcon, { fontSize: "small" }));
526
- };
527
- var ErrorBoundaryFallback = () => /* @__PURE__ */ React5.createElement(import_ui5.Box, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React5.createElement(import_ui5.Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React5.createElement("strong", null, (0, import_i18n5.__)("Something went wrong", "elementor"))));
637
+ 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" }));
638
+ 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"))));
528
639
 
529
640
  // src/components/class-manager/class-manager-button.tsx
530
641
  var ClassManagerButton = () => {
531
642
  const { open } = usePanelActions();
532
- return /* @__PURE__ */ React6.createElement(import_ui6.Tooltip, { title: (0, import_i18n6.__)("Class manager", "elementor"), placement: "top" }, /* @__PURE__ */ React6.createElement(import_ui6.IconButton, { onClick: open }, /* @__PURE__ */ React6.createElement(import_icons5.ColorSwatchIcon, { fontSize: "tiny" })));
533
- };
534
-
535
- // src/components/populate-store.tsx
536
- var import_react3 = require("react");
537
- var import_store5 = require("@elementor/store");
538
-
539
- // src/api.ts
540
- var import_http = require("@elementor/http");
541
- var RESOURCE_URL = "/global-classes";
542
- var apiClient = {
543
- all: () => (0, import_http.httpService)().get("elementor/v1" + RESOURCE_URL),
544
- update: (payload) => (0, import_http.httpService)().put("elementor/v1" + RESOURCE_URL, payload)
643
+ return /* @__PURE__ */ React7.createElement(import_ui7.Tooltip, { title: (0, import_i18n6.__)("Class manager", "elementor"), placement: "top" }, /* @__PURE__ */ React7.createElement(import_ui7.IconButton, { onClick: open }, /* @__PURE__ */ React7.createElement(import_icons6.ColorSwatchIcon, { fontSize: "tiny" })));
545
644
  };
546
645
 
547
646
  // src/components/populate-store.tsx
647
+ var import_react4 = require("react");
648
+ var import_store12 = require("@elementor/store");
548
649
  function PopulateStore() {
549
- const dispatch2 = (0, import_store5.__useDispatch)();
550
- (0, import_react3.useEffect)(() => {
650
+ const dispatch3 = (0, import_store12.__useDispatch)();
651
+ (0, import_react4.useEffect)(() => {
551
652
  apiClient.all().then((res) => {
552
653
  const { data, meta } = res.data;
553
- dispatch2(slice.actions.init({ items: data, order: meta.order }));
654
+ dispatch3(slice.actions.init({ items: data, order: meta.order }));
554
655
  });
555
- }, [dispatch2]);
656
+ }, [dispatch3]);
556
657
  return null;
557
658
  }
558
659
 
559
660
  // src/sync-with-document-save.ts
560
661
  var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
561
- var import_store7 = require("@elementor/store");
662
+ var import_store14 = require("@elementor/store");
562
663
  function syncWithDocumentSave() {
563
664
  const unsubscribe = syncDirtyState();
564
665
  bindSaveAction();
565
666
  return unsubscribe;
566
667
  }
567
668
  function syncDirtyState() {
568
- return (0, import_store7.__subscribeWithSelector)(selectIsDirty, () => {
569
- if (!isDirty()) {
669
+ return (0, import_store14.__subscribeWithSelector)(selectIsDirty, () => {
670
+ if (!isDirty2()) {
570
671
  return;
571
672
  }
572
673
  (0, import_editor_v1_adapters.__privateRunCommandSync)("document/save/set-is-modified", { status: true }, { internal: true });
573
674
  });
574
675
  }
575
676
  function bindSaveAction() {
576
- (0, import_editor_v1_adapters.registerDataHook)("after", "document/save/save", async () => {
577
- if (!isDirty()) {
578
- return;
579
- }
580
- const state = (0, import_store7.__getState)().globalClasses;
581
- await apiClient.update({
582
- items: state.items,
583
- order: state.order
584
- });
585
- (0, import_store7.__dispatch)(slice.actions.setPristine());
586
- });
677
+ (0, import_editor_v1_adapters.registerDataHook)("after", "document/save/save", publishGlobalClasses);
587
678
  }
588
- function isDirty() {
589
- return selectIsDirty((0, import_store7.__getState)());
679
+ function isDirty2() {
680
+ return selectIsDirty((0, import_store14.__getState)());
590
681
  }
591
682
 
592
683
  // src/init.ts
593
684
  function init() {
594
- (0, import_store9.__registerSlice)(slice);
685
+ (0, import_store16.__registerSlice)(slice);
595
686
  (0, import_editor_panels2.__registerPanel)(panel);
596
687
  import_editor_styles_repository2.stylesRepository.register(globalClassesStylesProvider);
597
688
  (0, import_editor.injectIntoLogic)({