@elementor/editor-global-classes 0.20.5 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/dist/index.js +440 -161
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +427 -140
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -13
- package/src/components/class-manager/class-item.tsx +238 -0
- package/src/components/class-manager/class-manager-class-not-found.tsx +56 -0
- package/src/components/class-manager/class-manager-panel.tsx +72 -9
- package/src/components/class-manager/class-manager-search.tsx +33 -0
- package/src/components/class-manager/global-classes-list.tsx +88 -239
- package/src/components/class-manager/save-changes-dialog.tsx +13 -5
- package/src/global-classes-styles-provider.ts +3 -1
- package/src/init.ts +7 -2
- package/src/store.ts +39 -0
- package/src/utils/snapshot-history.ts +73 -0
package/dist/index.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
// src/init.ts
|
|
2
2
|
import { injectIntoLogic } from "@elementor/editor";
|
|
3
|
-
import { injectIntoClassSelectorActions } from "@elementor/editor-editing-panel";
|
|
3
|
+
import { injectIntoClassSelectorActions, registerStyleProviderToColors } from "@elementor/editor-editing-panel";
|
|
4
4
|
import { __registerPanel as registerPanel } from "@elementor/editor-panels";
|
|
5
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
|
|
|
9
9
|
// src/components/class-manager/class-manager-button.tsx
|
|
10
|
-
import * as
|
|
10
|
+
import * as React11 from "react";
|
|
11
11
|
import {
|
|
12
12
|
__useActiveDocument as useActiveDocument,
|
|
13
13
|
__useActiveDocumentActions as useActiveDocumentActions
|
|
14
14
|
} from "@elementor/editor-documents";
|
|
15
15
|
import { useUserStylesCapability } from "@elementor/editor-styles-repository";
|
|
16
16
|
import { IconButton as IconButton3, Tooltip as Tooltip2 } from "@elementor/ui";
|
|
17
|
-
import { __ as
|
|
17
|
+
import { __ as __9 } from "@wordpress/i18n";
|
|
18
18
|
|
|
19
19
|
// src/global-classes-styles-provider.ts
|
|
20
20
|
import { generateId } from "@elementor/editor-styles";
|
|
@@ -63,6 +63,69 @@ import {
|
|
|
63
63
|
__createSelector as createSelector,
|
|
64
64
|
__createSlice as createSlice
|
|
65
65
|
} from "@elementor/store";
|
|
66
|
+
|
|
67
|
+
// src/utils/snapshot-history.ts
|
|
68
|
+
function createLink({ value, next, prev }) {
|
|
69
|
+
return {
|
|
70
|
+
value,
|
|
71
|
+
prev: prev || null,
|
|
72
|
+
next: next || null
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
var SnapshotHistory = class _SnapshotHistory {
|
|
76
|
+
constructor(namespace) {
|
|
77
|
+
this.namespace = namespace;
|
|
78
|
+
}
|
|
79
|
+
static registry = {};
|
|
80
|
+
static get(namespace) {
|
|
81
|
+
if (!_SnapshotHistory.registry[namespace]) {
|
|
82
|
+
_SnapshotHistory.registry[namespace] = new _SnapshotHistory(namespace);
|
|
83
|
+
}
|
|
84
|
+
return _SnapshotHistory.registry[namespace];
|
|
85
|
+
}
|
|
86
|
+
first = null;
|
|
87
|
+
current = null;
|
|
88
|
+
transform(item) {
|
|
89
|
+
return JSON.parse(JSON.stringify(item));
|
|
90
|
+
}
|
|
91
|
+
reset() {
|
|
92
|
+
this.first = this.current = null;
|
|
93
|
+
}
|
|
94
|
+
prev() {
|
|
95
|
+
if (!this.current || this.current === this.first) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
this.current = this.current.prev;
|
|
99
|
+
return this.current?.value || null;
|
|
100
|
+
}
|
|
101
|
+
isLast() {
|
|
102
|
+
return !this.current || !this.current.next;
|
|
103
|
+
}
|
|
104
|
+
next(value) {
|
|
105
|
+
if (value) {
|
|
106
|
+
if (!this.current) {
|
|
107
|
+
this.first = createLink({ value: this.transform(value) });
|
|
108
|
+
this.current = this.first;
|
|
109
|
+
return this.current.value;
|
|
110
|
+
}
|
|
111
|
+
const nextLink = createLink({
|
|
112
|
+
value: this.transform(value),
|
|
113
|
+
prev: this.current
|
|
114
|
+
});
|
|
115
|
+
this.current.next = nextLink;
|
|
116
|
+
this.current = nextLink;
|
|
117
|
+
return this.current.value;
|
|
118
|
+
}
|
|
119
|
+
if (!this.current || !this.current.next) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
this.current = this.current.next;
|
|
123
|
+
return this.current.value;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// src/store.ts
|
|
128
|
+
var localHistory = SnapshotHistory.get("global-classes");
|
|
66
129
|
var initialState = {
|
|
67
130
|
data: { items: {}, order: [] },
|
|
68
131
|
initialData: {
|
|
@@ -85,11 +148,13 @@ var slice = createSlice({
|
|
|
85
148
|
state.isDirty = false;
|
|
86
149
|
},
|
|
87
150
|
add(state, { payload }) {
|
|
151
|
+
localHistory.next(state.data);
|
|
88
152
|
state.data.items[payload.id] = payload;
|
|
89
153
|
state.data.order.unshift(payload.id);
|
|
90
154
|
state.isDirty = true;
|
|
91
155
|
},
|
|
92
156
|
delete(state, { payload }) {
|
|
157
|
+
localHistory.next(state.data);
|
|
93
158
|
state.data.items = Object.fromEntries(
|
|
94
159
|
Object.entries(state.data.items).filter(([id2]) => id2 !== payload)
|
|
95
160
|
);
|
|
@@ -97,10 +162,12 @@ var slice = createSlice({
|
|
|
97
162
|
state.isDirty = true;
|
|
98
163
|
},
|
|
99
164
|
setOrder(state, { payload }) {
|
|
165
|
+
localHistory.next(state.data);
|
|
100
166
|
state.data.order = payload;
|
|
101
167
|
state.isDirty = true;
|
|
102
168
|
},
|
|
103
169
|
update(state, { payload }) {
|
|
170
|
+
localHistory.next(state.data);
|
|
104
171
|
const style = state.data.items[payload.style.id];
|
|
105
172
|
const mergedData = {
|
|
106
173
|
...style,
|
|
@@ -116,6 +183,7 @@ var slice = createSlice({
|
|
|
116
183
|
if (!style) {
|
|
117
184
|
throw new GlobalClassNotFoundError({ context: { styleId: payload.id } });
|
|
118
185
|
}
|
|
186
|
+
localHistory.next(state.data);
|
|
119
187
|
const variant = getVariantByMeta(style, payload.meta);
|
|
120
188
|
if (variant) {
|
|
121
189
|
variant.props = mergeProps(variant.props, payload.props);
|
|
@@ -129,10 +197,38 @@ var slice = createSlice({
|
|
|
129
197
|
},
|
|
130
198
|
reset(state, { payload: { context: context2 } }) {
|
|
131
199
|
if (context2 === "frontend") {
|
|
200
|
+
localHistory.reset();
|
|
132
201
|
state.initialData.frontend = state.data;
|
|
133
202
|
state.isDirty = false;
|
|
134
203
|
}
|
|
135
204
|
state.initialData.preview = state.data;
|
|
205
|
+
},
|
|
206
|
+
undo(state) {
|
|
207
|
+
if (localHistory.isLast()) {
|
|
208
|
+
localHistory.next(state.data);
|
|
209
|
+
}
|
|
210
|
+
const data = localHistory.prev();
|
|
211
|
+
if (data) {
|
|
212
|
+
state.data = data;
|
|
213
|
+
state.isDirty = true;
|
|
214
|
+
} else {
|
|
215
|
+
state.data = state.initialData.preview;
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
resetToInitialState(state, { payload: { context: context2 } }) {
|
|
219
|
+
localHistory.reset();
|
|
220
|
+
state.data = state.initialData[context2];
|
|
221
|
+
state.isDirty = false;
|
|
222
|
+
},
|
|
223
|
+
redo(state) {
|
|
224
|
+
const data = localHistory.next();
|
|
225
|
+
if (localHistory.isLast()) {
|
|
226
|
+
localHistory.prev();
|
|
227
|
+
}
|
|
228
|
+
if (data) {
|
|
229
|
+
state.data = data;
|
|
230
|
+
state.isDirty = true;
|
|
231
|
+
}
|
|
136
232
|
}
|
|
137
233
|
}
|
|
138
234
|
});
|
|
@@ -151,8 +247,9 @@ var selectClass = (state, id2) => state[SLICE_NAME].data.items[id2] ?? null;
|
|
|
151
247
|
|
|
152
248
|
// src/global-classes-styles-provider.ts
|
|
153
249
|
var MAX_CLASSES = 50;
|
|
250
|
+
var GLOBAL_CLASSES_PROVIDER_KEY = "global-classes";
|
|
154
251
|
var globalClassesStylesProvider = createStylesProvider({
|
|
155
|
-
key:
|
|
252
|
+
key: GLOBAL_CLASSES_PROVIDER_KEY,
|
|
156
253
|
priority: 30,
|
|
157
254
|
limit: MAX_CLASSES,
|
|
158
255
|
labels: {
|
|
@@ -211,9 +308,10 @@ var globalClassesStylesProvider = createStylesProvider({
|
|
|
211
308
|
});
|
|
212
309
|
|
|
213
310
|
// src/components/class-manager/class-manager-panel.tsx
|
|
214
|
-
import
|
|
215
|
-
import
|
|
311
|
+
import { useEffect as useEffect2 } from "react";
|
|
312
|
+
import * as React10 from "react";
|
|
216
313
|
import { setDocumentModifiedStatus } from "@elementor/editor-documents";
|
|
314
|
+
import { EXPERIMENTAL_FEATURES as EXPERIMENTAL_FEATURES2 } from "@elementor/editor-editing-panel";
|
|
217
315
|
import {
|
|
218
316
|
__createPanel as createPanel,
|
|
219
317
|
Panel,
|
|
@@ -223,11 +321,22 @@ import {
|
|
|
223
321
|
PanelHeaderTitle
|
|
224
322
|
} from "@elementor/editor-panels";
|
|
225
323
|
import { ThemeProvider } from "@elementor/editor-ui";
|
|
226
|
-
import { changeEditMode } from "@elementor/editor-v1-adapters";
|
|
324
|
+
import { changeEditMode, isExperimentActive as isExperimentActive4 } from "@elementor/editor-v1-adapters";
|
|
227
325
|
import { XIcon } from "@elementor/icons";
|
|
228
326
|
import { useMutation } from "@elementor/query";
|
|
229
|
-
import {
|
|
230
|
-
import {
|
|
327
|
+
import { __dispatch as dispatch4 } from "@elementor/store";
|
|
328
|
+
import {
|
|
329
|
+
Alert,
|
|
330
|
+
Box as Box6,
|
|
331
|
+
Button as Button3,
|
|
332
|
+
DialogHeader,
|
|
333
|
+
Divider,
|
|
334
|
+
ErrorBoundary,
|
|
335
|
+
IconButton as IconButton2,
|
|
336
|
+
Stack as Stack5
|
|
337
|
+
} from "@elementor/ui";
|
|
338
|
+
import { useDebounceState } from "@elementor/utils";
|
|
339
|
+
import { __ as __8 } from "@wordpress/i18n";
|
|
231
340
|
|
|
232
341
|
// src/hooks/use-dirty-state.ts
|
|
233
342
|
import { __useSelector as useSelector } from "@elementor/store";
|
|
@@ -343,6 +452,26 @@ var IntroductionContent = () => {
|
|
|
343
452
|
)));
|
|
344
453
|
};
|
|
345
454
|
|
|
455
|
+
// src/components/class-manager/class-manager-search.tsx
|
|
456
|
+
import * as React2 from "react";
|
|
457
|
+
import { SearchIcon } from "@elementor/icons";
|
|
458
|
+
import { Box as Box2, Grid, InputAdornment, Stack, TextField } from "@elementor/ui";
|
|
459
|
+
import { __ as __3 } from "@wordpress/i18n";
|
|
460
|
+
var ClassManagerSearch = ({ searchValue, onChange }) => /* @__PURE__ */ React2.createElement(Grid, { item: true, xs: 6, px: 2, pb: 1 }, /* @__PURE__ */ React2.createElement(Stack, { direction: "row", gap: 0.5, sx: { width: "100%" } }, /* @__PURE__ */ React2.createElement(Box2, { sx: { flexGrow: 1 } }, /* @__PURE__ */ React2.createElement(
|
|
461
|
+
TextField,
|
|
462
|
+
{
|
|
463
|
+
role: "search",
|
|
464
|
+
fullWidth: true,
|
|
465
|
+
size: "tiny",
|
|
466
|
+
value: searchValue,
|
|
467
|
+
placeholder: __3("Search", "elementor"),
|
|
468
|
+
onChange: (e) => onChange(e.target.value),
|
|
469
|
+
InputProps: {
|
|
470
|
+
startAdornment: /* @__PURE__ */ React2.createElement(InputAdornment, { position: "start" }, /* @__PURE__ */ React2.createElement(SearchIcon, { fontSize: "tiny" }))
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
))));
|
|
474
|
+
|
|
346
475
|
// src/components/class-manager/delete-class.ts
|
|
347
476
|
import { getCurrentDocument, getV1DocumentsManager } from "@elementor/editor-documents";
|
|
348
477
|
import { __privateRunCommand as runCommand } from "@elementor/editor-v1-adapters";
|
|
@@ -369,47 +498,54 @@ var reloadDocument = () => {
|
|
|
369
498
|
};
|
|
370
499
|
|
|
371
500
|
// src/components/class-manager/flipped-color-swatch-icon.tsx
|
|
372
|
-
import * as
|
|
501
|
+
import * as React3 from "react";
|
|
373
502
|
import { ColorSwatchIcon } from "@elementor/icons";
|
|
374
|
-
var FlippedColorSwatchIcon = ({ sx, ...props }) => /* @__PURE__ */
|
|
503
|
+
var FlippedColorSwatchIcon = ({ sx, ...props }) => /* @__PURE__ */ React3.createElement(ColorSwatchIcon, { sx: { transform: "rotate(90deg)", ...sx }, ...props });
|
|
375
504
|
|
|
376
505
|
// src/components/class-manager/global-classes-list.tsx
|
|
377
|
-
import * as
|
|
506
|
+
import * as React8 from "react";
|
|
507
|
+
import { useEffect, useMemo } from "react";
|
|
508
|
+
import { __useDispatch as useDispatch } from "@elementor/store";
|
|
509
|
+
import { List, Stack as Stack4, styled as styled3, Typography as Typography5 } from "@elementor/ui";
|
|
510
|
+
import { __ as __7 } from "@wordpress/i18n";
|
|
511
|
+
|
|
512
|
+
// src/hooks/use-classes-order.ts
|
|
513
|
+
import { __useSelector as useSelector2 } from "@elementor/store";
|
|
514
|
+
var useClassesOrder = () => {
|
|
515
|
+
return useSelector2(selectOrder);
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
// src/hooks/use-ordered-classes.ts
|
|
519
|
+
import { __useSelector as useSelector3 } from "@elementor/store";
|
|
520
|
+
var useOrderedClasses = () => {
|
|
521
|
+
return useSelector3(selectOrderedClasses);
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
// src/components/class-manager/class-item.tsx
|
|
525
|
+
import * as React6 from "react";
|
|
378
526
|
import { useRef } from "react";
|
|
527
|
+
import { EXPERIMENTAL_FEATURES } from "@elementor/editor-editing-panel";
|
|
379
528
|
import { validateStyleLabel } from "@elementor/editor-styles-repository";
|
|
380
529
|
import { EditableField, EllipsisWithTooltip, MenuListItem, useEditable, WarningInfotip } from "@elementor/editor-ui";
|
|
530
|
+
import { isExperimentActive as isExperimentActive3 } from "@elementor/editor-v1-adapters";
|
|
381
531
|
import { DotsVerticalIcon } from "@elementor/icons";
|
|
382
|
-
import { __useDispatch as useDispatch } from "@elementor/store";
|
|
383
532
|
import {
|
|
384
533
|
bindMenu,
|
|
385
534
|
bindTrigger,
|
|
386
|
-
Box as
|
|
535
|
+
Box as Box4,
|
|
387
536
|
IconButton,
|
|
388
|
-
List,
|
|
389
537
|
ListItemButton,
|
|
390
538
|
Menu,
|
|
391
|
-
Stack,
|
|
539
|
+
Stack as Stack2,
|
|
392
540
|
styled as styled2,
|
|
393
541
|
Tooltip,
|
|
394
542
|
Typography as Typography3,
|
|
395
543
|
usePopupState
|
|
396
544
|
} from "@elementor/ui";
|
|
397
|
-
import { __ as
|
|
398
|
-
|
|
399
|
-
// src/hooks/use-classes-order.ts
|
|
400
|
-
import { __useSelector as useSelector2 } from "@elementor/store";
|
|
401
|
-
var useClassesOrder = () => {
|
|
402
|
-
return useSelector2(selectOrder);
|
|
403
|
-
};
|
|
404
|
-
|
|
405
|
-
// src/hooks/use-ordered-classes.ts
|
|
406
|
-
import { __useSelector as useSelector3 } from "@elementor/store";
|
|
407
|
-
var useOrderedClasses = () => {
|
|
408
|
-
return useSelector3(selectOrderedClasses);
|
|
409
|
-
};
|
|
545
|
+
import { __ as __5 } from "@wordpress/i18n";
|
|
410
546
|
|
|
411
547
|
// src/components/class-manager/delete-confirmation-dialog.tsx
|
|
412
|
-
import * as
|
|
548
|
+
import * as React4 from "react";
|
|
413
549
|
import { createContext, useContext, useState as useState2 } from "react";
|
|
414
550
|
import { AlertOctagonFilledIcon } from "@elementor/icons";
|
|
415
551
|
import {
|
|
@@ -421,7 +557,7 @@ import {
|
|
|
421
557
|
DialogTitle,
|
|
422
558
|
Typography as Typography2
|
|
423
559
|
} from "@elementor/ui";
|
|
424
|
-
import { __ as
|
|
560
|
+
import { __ as __4 } from "@wordpress/i18n";
|
|
425
561
|
var context = createContext(null);
|
|
426
562
|
var DeleteConfirmationProvider = ({ children }) => {
|
|
427
563
|
const [dialogProps, setDialogProps] = useState2(null);
|
|
@@ -431,7 +567,7 @@ var DeleteConfirmationProvider = ({ children }) => {
|
|
|
431
567
|
const closeDialog = () => {
|
|
432
568
|
setDialogProps(null);
|
|
433
569
|
};
|
|
434
|
-
return /* @__PURE__ */
|
|
570
|
+
return /* @__PURE__ */ React4.createElement(context.Provider, { value: { openDialog, closeDialog, dialogProps } }, children, !!dialogProps && /* @__PURE__ */ React4.createElement(DeleteConfirmationDialog, { ...dialogProps }));
|
|
435
571
|
};
|
|
436
572
|
var TITLE_ID = "delete-class-dialog";
|
|
437
573
|
var DeleteConfirmationDialog = ({ label, id: id2 }) => {
|
|
@@ -440,10 +576,10 @@ var DeleteConfirmationDialog = ({ label, id: id2 }) => {
|
|
|
440
576
|
deleteClass(id2);
|
|
441
577
|
closeDialog();
|
|
442
578
|
};
|
|
443
|
-
return /* @__PURE__ */
|
|
579
|
+
return /* @__PURE__ */ React4.createElement(Dialog, { open: true, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React4.createElement(DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React4.createElement(AlertOctagonFilledIcon, { color: "error" }), __4("Delete this class?", "elementor")), /* @__PURE__ */ React4.createElement(DialogContent, null, /* @__PURE__ */ React4.createElement(DialogContentText, { variant: "body2", color: "textPrimary" }, __4("Deleting", "elementor"), /* @__PURE__ */ React4.createElement(Typography2, { variant: "subtitle2", component: "span" }, "\xA0", label, "\xA0"), __4(
|
|
444
580
|
"will permanently remove it from your project and may affect the design across all elements using it. This action cannot be undone.",
|
|
445
581
|
"elementor"
|
|
446
|
-
))), /* @__PURE__ */
|
|
582
|
+
))), /* @__PURE__ */ React4.createElement(DialogActions, null, /* @__PURE__ */ React4.createElement(Button, { color: "secondary", onClick: closeDialog }, __4("Not now", "elementor")), /* @__PURE__ */ React4.createElement(Button, { variant: "contained", color: "error", onClick: onConfirm }, __4("Delete", "elementor"))));
|
|
447
583
|
};
|
|
448
584
|
var useDeleteConfirmation = () => {
|
|
449
585
|
const contextValue = useContext(context);
|
|
@@ -454,18 +590,18 @@ var useDeleteConfirmation = () => {
|
|
|
454
590
|
};
|
|
455
591
|
|
|
456
592
|
// src/components/class-manager/sortable.tsx
|
|
457
|
-
import * as
|
|
593
|
+
import * as React5 from "react";
|
|
458
594
|
import { GripVerticalIcon } from "@elementor/icons";
|
|
459
595
|
import {
|
|
460
|
-
Box as
|
|
596
|
+
Box as Box3,
|
|
461
597
|
styled,
|
|
462
598
|
UnstableSortableItem,
|
|
463
599
|
UnstableSortableProvider
|
|
464
600
|
} from "@elementor/ui";
|
|
465
|
-
var SortableProvider = (props) => /* @__PURE__ */
|
|
466
|
-
var SortableTrigger = (props) => /* @__PURE__ */
|
|
601
|
+
var SortableProvider = (props) => /* @__PURE__ */ React5.createElement(UnstableSortableProvider, { restrictAxis: true, variant: "static", dragPlaceholderStyle: { opacity: "1" }, ...props });
|
|
602
|
+
var SortableTrigger = (props) => /* @__PURE__ */ React5.createElement(StyledSortableTrigger, { ...props, role: "button", className: "class-item-sortable-trigger" }, /* @__PURE__ */ React5.createElement(GripVerticalIcon, { fontSize: "tiny" }));
|
|
467
603
|
var SortableItem = ({ children, id: id2, ...props }) => {
|
|
468
|
-
return /* @__PURE__ */
|
|
604
|
+
return /* @__PURE__ */ React5.createElement(
|
|
469
605
|
UnstableSortableItem,
|
|
470
606
|
{
|
|
471
607
|
...props,
|
|
@@ -481,8 +617,8 @@ var SortableItem = ({ children, id: id2, ...props }) => {
|
|
|
481
617
|
isDragOverlay,
|
|
482
618
|
isDragPlaceholder
|
|
483
619
|
}) => {
|
|
484
|
-
return /* @__PURE__ */
|
|
485
|
-
|
|
620
|
+
return /* @__PURE__ */ React5.createElement(
|
|
621
|
+
Box3,
|
|
486
622
|
{
|
|
487
623
|
...itemProps,
|
|
488
624
|
style: itemStyle,
|
|
@@ -500,7 +636,7 @@ var SortableItem = ({ children, id: id2, ...props }) => {
|
|
|
500
636
|
triggerStyle,
|
|
501
637
|
isDragPlaceholder
|
|
502
638
|
}),
|
|
503
|
-
showDropIndication && /* @__PURE__ */
|
|
639
|
+
showDropIndication && /* @__PURE__ */ React5.createElement(SortableItemIndicator, { style: dropIndicationStyle })
|
|
504
640
|
);
|
|
505
641
|
}
|
|
506
642
|
}
|
|
@@ -513,53 +649,23 @@ var StyledSortableTrigger = styled("div")(({ theme }) => ({
|
|
|
513
649
|
transform: `translate( -${theme.spacing(1.5)}, -50% )`,
|
|
514
650
|
color: theme.palette.action.active
|
|
515
651
|
}));
|
|
516
|
-
var SortableItemIndicator = styled(
|
|
652
|
+
var SortableItemIndicator = styled(Box3)`
|
|
517
653
|
width: 100%;
|
|
518
654
|
height: 1px;
|
|
519
655
|
background-color: ${({ theme }) => theme.palette.text.primary};
|
|
520
656
|
`;
|
|
521
657
|
|
|
522
|
-
// src/components/class-manager/
|
|
523
|
-
var
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
slice.actions.update({
|
|
534
|
-
style: {
|
|
535
|
-
id: id2,
|
|
536
|
-
label: newLabel
|
|
537
|
-
}
|
|
538
|
-
})
|
|
539
|
-
);
|
|
540
|
-
};
|
|
541
|
-
return /* @__PURE__ */ React5.createElement(SortableItem, { key: id2, id: id2 }, ({ isDragged, isDragPlaceholder, triggerProps, triggerStyle }) => /* @__PURE__ */ React5.createElement(
|
|
542
|
-
ClassItem,
|
|
543
|
-
{
|
|
544
|
-
id: id2,
|
|
545
|
-
label,
|
|
546
|
-
renameClass,
|
|
547
|
-
selected: isDragged,
|
|
548
|
-
disabled: disabled || isDragPlaceholder,
|
|
549
|
-
sortableTriggerProps: { ...triggerProps, style: triggerStyle }
|
|
550
|
-
}
|
|
551
|
-
));
|
|
552
|
-
}))));
|
|
553
|
-
};
|
|
554
|
-
var useReorder = () => {
|
|
555
|
-
const dispatch4 = useDispatch();
|
|
556
|
-
const order = useClassesOrder();
|
|
557
|
-
const reorder = (newIds) => {
|
|
558
|
-
dispatch4(slice.actions.setOrder(newIds));
|
|
559
|
-
};
|
|
560
|
-
return [order, reorder];
|
|
561
|
-
};
|
|
562
|
-
var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTriggerProps }) => {
|
|
658
|
+
// src/components/class-manager/class-item.tsx
|
|
659
|
+
var isVersion311IsActive = isExperimentActive3(EXPERIMENTAL_FEATURES.V_3_31);
|
|
660
|
+
var ClassItem = ({
|
|
661
|
+
id: id2,
|
|
662
|
+
label,
|
|
663
|
+
renameClass,
|
|
664
|
+
selected,
|
|
665
|
+
disabled,
|
|
666
|
+
sortableTriggerProps,
|
|
667
|
+
isSearchActive
|
|
668
|
+
}) => {
|
|
563
669
|
const itemRef = useRef(null);
|
|
564
670
|
const {
|
|
565
671
|
ref: editableRef,
|
|
@@ -578,7 +684,7 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
|
|
|
578
684
|
disableAutoFocus: true
|
|
579
685
|
});
|
|
580
686
|
const isSelected = (selected || popupState.isOpen) && !disabled;
|
|
581
|
-
return /* @__PURE__ */
|
|
687
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(Stack2, { p: 0 }, /* @__PURE__ */ React6.createElement(
|
|
582
688
|
WarningInfotip,
|
|
583
689
|
{
|
|
584
690
|
open: Boolean(error),
|
|
@@ -587,12 +693,13 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
|
|
|
587
693
|
width: itemRef.current?.getBoundingClientRect().width,
|
|
588
694
|
offset: [0, -15]
|
|
589
695
|
},
|
|
590
|
-
/* @__PURE__ */
|
|
696
|
+
/* @__PURE__ */ React6.createElement(
|
|
591
697
|
StyledListItemButton,
|
|
592
698
|
{
|
|
593
699
|
ref: itemRef,
|
|
594
700
|
dense: true,
|
|
595
701
|
disableGutters: true,
|
|
702
|
+
showSortIndicator: isSearchActive,
|
|
596
703
|
showActions: isSelected || isEditing,
|
|
597
704
|
shape: "rounded",
|
|
598
705
|
onDoubleClick: openEditMode,
|
|
@@ -600,8 +707,8 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
|
|
|
600
707
|
disabled,
|
|
601
708
|
focusVisibleClassName: "visible-class-item"
|
|
602
709
|
},
|
|
603
|
-
/* @__PURE__ */
|
|
604
|
-
/* @__PURE__ */
|
|
710
|
+
/* @__PURE__ */ React6.createElement(SortableTrigger, { ...sortableTriggerProps }),
|
|
711
|
+
/* @__PURE__ */ React6.createElement(Indicator, { isActive: isEditing, isError: !!error }, isEditing ? /* @__PURE__ */ React6.createElement(
|
|
605
712
|
EditableField,
|
|
606
713
|
{
|
|
607
714
|
ref: editableRef,
|
|
@@ -609,18 +716,18 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
|
|
|
609
716
|
variant: "caption",
|
|
610
717
|
...getEditableProps()
|
|
611
718
|
}
|
|
612
|
-
) : /* @__PURE__ */
|
|
613
|
-
/* @__PURE__ */
|
|
719
|
+
) : /* @__PURE__ */ React6.createElement(EllipsisWithTooltip, { title: label, as: Typography3, variant: "caption" })),
|
|
720
|
+
/* @__PURE__ */ React6.createElement(
|
|
614
721
|
Tooltip,
|
|
615
722
|
{
|
|
616
723
|
placement: "top",
|
|
617
724
|
className: "class-item-more-actions",
|
|
618
|
-
title:
|
|
725
|
+
title: __5("More actions", "elementor")
|
|
619
726
|
},
|
|
620
|
-
/* @__PURE__ */
|
|
727
|
+
/* @__PURE__ */ React6.createElement(IconButton, { size: "tiny", ...bindTrigger(popupState), "aria-label": "More actions" }, /* @__PURE__ */ React6.createElement(DotsVerticalIcon, { fontSize: "tiny" }))
|
|
621
728
|
)
|
|
622
729
|
)
|
|
623
|
-
)), /* @__PURE__ */
|
|
730
|
+
)), /* @__PURE__ */ React6.createElement(
|
|
624
731
|
Menu,
|
|
625
732
|
{
|
|
626
733
|
...bindMenu(popupState),
|
|
@@ -633,7 +740,7 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
|
|
|
633
740
|
horizontal: "right"
|
|
634
741
|
}
|
|
635
742
|
},
|
|
636
|
-
/* @__PURE__ */
|
|
743
|
+
/* @__PURE__ */ React6.createElement(
|
|
637
744
|
MenuListItem,
|
|
638
745
|
{
|
|
639
746
|
sx: { minWidth: "160px" },
|
|
@@ -642,9 +749,9 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
|
|
|
642
749
|
openEditMode();
|
|
643
750
|
}
|
|
644
751
|
},
|
|
645
|
-
/* @__PURE__ */
|
|
752
|
+
/* @__PURE__ */ React6.createElement(Typography3, { variant: "caption", sx: { color: "text.primary" } }, __5("Rename", "elementor"))
|
|
646
753
|
),
|
|
647
|
-
/* @__PURE__ */
|
|
754
|
+
/* @__PURE__ */ React6.createElement(
|
|
648
755
|
MenuListItem,
|
|
649
756
|
{
|
|
650
757
|
onClick: () => {
|
|
@@ -652,28 +759,43 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
|
|
|
652
759
|
openDialog({ id: id2, label });
|
|
653
760
|
}
|
|
654
761
|
},
|
|
655
|
-
/* @__PURE__ */
|
|
762
|
+
/* @__PURE__ */ React6.createElement(Typography3, { variant: "caption", sx: { color: "error.light" } }, __5("Delete", "elementor"))
|
|
656
763
|
)
|
|
657
764
|
));
|
|
658
765
|
};
|
|
659
|
-
var
|
|
660
|
-
shouldForwardProp: (prop) => !["showActions"].includes(prop)
|
|
766
|
+
var StyledListItemButtonV2 = styled2(ListItemButton, {
|
|
767
|
+
shouldForwardProp: (prop) => !["showActions", "showSortIndicator"].includes(prop)
|
|
661
768
|
})(
|
|
662
|
-
({ showActions }) => `
|
|
769
|
+
({ showActions, showSortIndicator }) => `
|
|
663
770
|
min-height: 36px;
|
|
664
771
|
|
|
665
772
|
&.visible-class-item {
|
|
666
773
|
box-shadow: none !important;
|
|
667
774
|
}
|
|
668
|
-
|
|
775
|
+
.class-item-sortable-trigger {
|
|
776
|
+
visibility: ${showSortIndicator && showActions ? "visible" : "hidden"};
|
|
777
|
+
}
|
|
778
|
+
&:hover&:not(:disabled) {
|
|
779
|
+
.class-item-sortable-trigger {
|
|
780
|
+
visibility: ${showSortIndicator ? "visible" : "hidden"};
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
`
|
|
784
|
+
);
|
|
785
|
+
var StyledListItemButtonV1 = styled2(ListItemButton, {
|
|
786
|
+
shouldForwardProp: (prop) => !["showActions", "showSortIndicator"].includes(prop)
|
|
787
|
+
})(
|
|
788
|
+
({ showActions }) => `
|
|
789
|
+
min-height: 36px;
|
|
790
|
+
&.visible-class-item {
|
|
791
|
+
box-shadow: none !important;
|
|
792
|
+
}
|
|
669
793
|
.class-item-more-actions, .class-item-sortable-trigger {
|
|
670
794
|
visibility: ${showActions ? "visible" : "hidden"};
|
|
671
795
|
}
|
|
672
|
-
|
|
673
796
|
.class-item-sortable-trigger {
|
|
674
797
|
visibility: ${showActions ? "visible" : "hidden"};
|
|
675
798
|
}
|
|
676
|
-
|
|
677
799
|
&:hover&:not(:disabled) {
|
|
678
800
|
.class-item-more-actions, .class-item-sortable-trigger {
|
|
679
801
|
visibility: visible;
|
|
@@ -681,16 +803,8 @@ var StyledListItemButton = styled2(ListItemButton, {
|
|
|
681
803
|
}
|
|
682
804
|
`
|
|
683
805
|
);
|
|
684
|
-
var
|
|
685
|
-
|
|
686
|
-
"elementor"
|
|
687
|
-
)));
|
|
688
|
-
var StyledHeader = styled2(Typography3)(({ theme, variant }) => ({
|
|
689
|
-
"&.MuiTypography-root": {
|
|
690
|
-
...theme.typography[variant]
|
|
691
|
-
}
|
|
692
|
-
}));
|
|
693
|
-
var Indicator = styled2(Box3, {
|
|
806
|
+
var StyledListItemButton = isVersion311IsActive ? StyledListItemButtonV2 : StyledListItemButtonV1;
|
|
807
|
+
var Indicator = styled2(Box4, {
|
|
694
808
|
shouldForwardProp: (prop) => !["isActive", "isError"].includes(prop)
|
|
695
809
|
})(({ theme, isActive, isError }) => ({
|
|
696
810
|
display: "flex",
|
|
@@ -719,6 +833,129 @@ var validateLabel = (newLabel) => {
|
|
|
719
833
|
return result.errorMessage;
|
|
720
834
|
};
|
|
721
835
|
|
|
836
|
+
// src/components/class-manager/class-manager-class-not-found.tsx
|
|
837
|
+
import * as React7 from "react";
|
|
838
|
+
import { Box as Box5, Link, Stack as Stack3, Typography as Typography4 } from "@elementor/ui";
|
|
839
|
+
import { __ as __6 } from "@wordpress/i18n";
|
|
840
|
+
var CssClassNotFound = ({ onClear, searchValue }) => /* @__PURE__ */ React7.createElement(
|
|
841
|
+
Stack3,
|
|
842
|
+
{
|
|
843
|
+
color: "text.secondary",
|
|
844
|
+
pt: 5,
|
|
845
|
+
alignItems: "center",
|
|
846
|
+
gap: 1,
|
|
847
|
+
overflow: "hidden",
|
|
848
|
+
maxWidth: "170px",
|
|
849
|
+
justifySelf: "center"
|
|
850
|
+
},
|
|
851
|
+
/* @__PURE__ */ React7.createElement(FlippedColorSwatchIcon, { color: "inherit", fontSize: "large" }),
|
|
852
|
+
/* @__PURE__ */ React7.createElement(Box5, null, /* @__PURE__ */ React7.createElement(Typography4, { align: "center", variant: "subtitle2", color: "inherit" }, __6("Sorry, nothing matched", "elementor")), /* @__PURE__ */ React7.createElement(
|
|
853
|
+
Typography4,
|
|
854
|
+
{
|
|
855
|
+
variant: "subtitle2",
|
|
856
|
+
color: "inherit",
|
|
857
|
+
sx: {
|
|
858
|
+
display: "flex",
|
|
859
|
+
width: "100%",
|
|
860
|
+
justifyContent: "center"
|
|
861
|
+
}
|
|
862
|
+
},
|
|
863
|
+
/* @__PURE__ */ React7.createElement("span", null, "\u201C"),
|
|
864
|
+
/* @__PURE__ */ React7.createElement(
|
|
865
|
+
"span",
|
|
866
|
+
{
|
|
867
|
+
style: {
|
|
868
|
+
maxWidth: "80%",
|
|
869
|
+
overflow: "hidden",
|
|
870
|
+
textOverflow: "ellipsis"
|
|
871
|
+
}
|
|
872
|
+
},
|
|
873
|
+
searchValue
|
|
874
|
+
),
|
|
875
|
+
/* @__PURE__ */ React7.createElement("span", null, "\u201D.")
|
|
876
|
+
)),
|
|
877
|
+
/* @__PURE__ */ React7.createElement(Typography4, { align: "center", variant: "caption", color: "inherit" }, __6("Try something else.", "elementor"), /* @__PURE__ */ React7.createElement(Link, { color: "secondary", variant: "caption", component: "button", onClick: onClear }, __6("Clear & try again", "elementor")))
|
|
878
|
+
);
|
|
879
|
+
|
|
880
|
+
// src/components/class-manager/global-classes-list.tsx
|
|
881
|
+
var GlobalClassesList = ({ disabled, searchValue, onSearch }) => {
|
|
882
|
+
const cssClasses = useOrderedClasses();
|
|
883
|
+
const dispatch5 = useDispatch();
|
|
884
|
+
const [classesOrder, reorderClasses] = useReorder();
|
|
885
|
+
const lowercaseLabels = useMemo(
|
|
886
|
+
() => cssClasses.map((cssClass) => ({
|
|
887
|
+
...cssClass,
|
|
888
|
+
lowerLabel: cssClass.label.toLowerCase()
|
|
889
|
+
})),
|
|
890
|
+
[cssClasses]
|
|
891
|
+
);
|
|
892
|
+
const filteredClasses = useMemo(() => {
|
|
893
|
+
return searchValue.length > 1 ? lowercaseLabels.filter(
|
|
894
|
+
(cssClass) => cssClass.lowerLabel.toLowerCase().includes(searchValue.toLowerCase())
|
|
895
|
+
) : cssClasses;
|
|
896
|
+
}, [searchValue, cssClasses, lowercaseLabels]);
|
|
897
|
+
useEffect(() => {
|
|
898
|
+
const handler = (event) => {
|
|
899
|
+
if (event.key === "z" && (event.ctrlKey || event.metaKey)) {
|
|
900
|
+
event.stopImmediatePropagation();
|
|
901
|
+
event.preventDefault();
|
|
902
|
+
if (event.shiftKey) {
|
|
903
|
+
dispatch5(slice.actions.redo());
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
dispatch5(slice.actions.undo());
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
window.addEventListener("keydown", handler, {
|
|
910
|
+
capture: true
|
|
911
|
+
});
|
|
912
|
+
return () => window.removeEventListener("keydown", handler);
|
|
913
|
+
}, [dispatch5]);
|
|
914
|
+
if (!cssClasses?.length) {
|
|
915
|
+
return /* @__PURE__ */ React8.createElement(EmptyState, null);
|
|
916
|
+
}
|
|
917
|
+
return /* @__PURE__ */ React8.createElement(DeleteConfirmationProvider, null, filteredClasses.length <= 0 && searchValue.length > 1 ? /* @__PURE__ */ React8.createElement(CssClassNotFound, { onClear: () => onSearch(""), searchValue }) : /* @__PURE__ */ React8.createElement(List, { sx: { display: "flex", flexDirection: "column", gap: 0.5 } }, /* @__PURE__ */ React8.createElement(SortableProvider, { value: classesOrder, onChange: reorderClasses }, filteredClasses?.map(({ id: id2, label }) => {
|
|
918
|
+
return /* @__PURE__ */ React8.createElement(SortableItem, { key: id2, id: id2 }, ({ isDragged, isDragPlaceholder, triggerProps, triggerStyle }) => /* @__PURE__ */ React8.createElement(
|
|
919
|
+
ClassItem,
|
|
920
|
+
{
|
|
921
|
+
isSearchActive: searchValue.length < 2,
|
|
922
|
+
id: id2,
|
|
923
|
+
label,
|
|
924
|
+
renameClass: (newLabel) => {
|
|
925
|
+
dispatch5(
|
|
926
|
+
slice.actions.update({
|
|
927
|
+
style: {
|
|
928
|
+
id: id2,
|
|
929
|
+
label: newLabel
|
|
930
|
+
}
|
|
931
|
+
})
|
|
932
|
+
);
|
|
933
|
+
},
|
|
934
|
+
selected: isDragged,
|
|
935
|
+
disabled: disabled || isDragPlaceholder,
|
|
936
|
+
sortableTriggerProps: { ...triggerProps, style: triggerStyle }
|
|
937
|
+
}
|
|
938
|
+
));
|
|
939
|
+
}))));
|
|
940
|
+
};
|
|
941
|
+
var EmptyState = () => /* @__PURE__ */ React8.createElement(Stack4, { alignItems: "center", gap: 1.5, pt: 10, px: 0.5, maxWidth: "260px", margin: "auto" }, /* @__PURE__ */ React8.createElement(FlippedColorSwatchIcon, { fontSize: "large" }), /* @__PURE__ */ React8.createElement(StyledHeader, { variant: "subtitle2", component: "h2", color: "text.secondary" }, __7("There are no global classes yet.", "elementor")), /* @__PURE__ */ React8.createElement(Typography5, { align: "center", variant: "caption", color: "text.secondary" }, __7(
|
|
942
|
+
"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.",
|
|
943
|
+
"elementor"
|
|
944
|
+
)));
|
|
945
|
+
var StyledHeader = styled3(Typography5)(({ theme, variant }) => ({
|
|
946
|
+
"&.MuiTypography-root": {
|
|
947
|
+
...theme.typography[variant]
|
|
948
|
+
}
|
|
949
|
+
}));
|
|
950
|
+
var useReorder = () => {
|
|
951
|
+
const dispatch5 = useDispatch();
|
|
952
|
+
const order = useClassesOrder();
|
|
953
|
+
const reorder = (newIds) => {
|
|
954
|
+
dispatch5(slice.actions.setOrder(newIds));
|
|
955
|
+
};
|
|
956
|
+
return [order, reorder];
|
|
957
|
+
};
|
|
958
|
+
|
|
722
959
|
// src/components/class-manager/panel-interactions.ts
|
|
723
960
|
function blockPanelInteractions() {
|
|
724
961
|
const extendedWindow = window;
|
|
@@ -730,7 +967,7 @@ function unblockPanelInteractions() {
|
|
|
730
967
|
}
|
|
731
968
|
|
|
732
969
|
// src/components/class-manager/save-changes-dialog.tsx
|
|
733
|
-
import * as
|
|
970
|
+
import * as React9 from "react";
|
|
734
971
|
import { useState as useState3 } from "react";
|
|
735
972
|
import { AlertTriangleFilledIcon } from "@elementor/icons";
|
|
736
973
|
import {
|
|
@@ -742,19 +979,19 @@ import {
|
|
|
742
979
|
DialogTitle as DialogTitle2
|
|
743
980
|
} from "@elementor/ui";
|
|
744
981
|
var TITLE_ID2 = "save-changes-dialog";
|
|
745
|
-
var SaveChangesDialog = ({ children, onClose }) => /* @__PURE__ */
|
|
746
|
-
var SaveChangesDialogTitle = ({ children }) => /* @__PURE__ */
|
|
747
|
-
var SaveChangesDialogContent = ({ children }) => /* @__PURE__ */
|
|
748
|
-
var SaveChangesDialogContentText = (props) => /* @__PURE__ */
|
|
982
|
+
var SaveChangesDialog = ({ children, onClose }) => /* @__PURE__ */ React9.createElement(Dialog2, { open: true, onClose, "aria-labelledby": TITLE_ID2, maxWidth: "xs" }, children);
|
|
983
|
+
var SaveChangesDialogTitle = ({ children }) => /* @__PURE__ */ React9.createElement(DialogTitle2, { id: TITLE_ID2, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React9.createElement(AlertTriangleFilledIcon, { color: "secondary" }), children);
|
|
984
|
+
var SaveChangesDialogContent = ({ children }) => /* @__PURE__ */ React9.createElement(DialogContent2, null, children);
|
|
985
|
+
var SaveChangesDialogContentText = (props) => /* @__PURE__ */ React9.createElement(DialogContentText2, { variant: "body2", color: "textPrimary", display: "flex", flexDirection: "column", ...props });
|
|
749
986
|
var SaveChangesDialogActions = ({ actions }) => {
|
|
750
987
|
const [isConfirming, setIsConfirming] = useState3(false);
|
|
751
|
-
const { cancel, confirm } = actions;
|
|
988
|
+
const { cancel, confirm, discard } = actions;
|
|
752
989
|
const onConfirm = async () => {
|
|
753
990
|
setIsConfirming(true);
|
|
754
991
|
await confirm.action();
|
|
755
992
|
setIsConfirming(false);
|
|
756
993
|
};
|
|
757
|
-
return /* @__PURE__ */
|
|
994
|
+
return /* @__PURE__ */ React9.createElement(DialogActions2, null, cancel && /* @__PURE__ */ React9.createElement(Button2, { variant: "text", color: "secondary", onClick: cancel.action }, cancel.label), discard && /* @__PURE__ */ React9.createElement(Button2, { variant: "text", color: "secondary", onClick: discard.action }, discard.label), /* @__PURE__ */ React9.createElement(Button2, { variant: "contained", color: "secondary", onClick: onConfirm, loading: isConfirming }, confirm.label));
|
|
758
995
|
};
|
|
759
996
|
SaveChangesDialog.Title = SaveChangesDialogTitle;
|
|
760
997
|
SaveChangesDialog.Content = SaveChangesDialogContent;
|
|
@@ -768,6 +1005,7 @@ var useDialog = () => {
|
|
|
768
1005
|
};
|
|
769
1006
|
|
|
770
1007
|
// src/components/class-manager/class-manager-panel.tsx
|
|
1008
|
+
var isVersion311IsActive2 = isExperimentActive4(EXPERIMENTAL_FEATURES2.V_3_31);
|
|
771
1009
|
var id = "global-classes-manager";
|
|
772
1010
|
var { panel, usePanelActions } = createPanel({
|
|
773
1011
|
id,
|
|
@@ -783,12 +1021,20 @@ var { panel, usePanelActions } = createPanel({
|
|
|
783
1021
|
}
|
|
784
1022
|
});
|
|
785
1023
|
function ClassManagerPanel() {
|
|
1024
|
+
const { debouncedValue, inputValue, handleChange } = useDebounceState({
|
|
1025
|
+
delay: 300,
|
|
1026
|
+
initialValue: ""
|
|
1027
|
+
});
|
|
786
1028
|
const isDirty2 = useDirtyState();
|
|
787
1029
|
const { close: closePanel } = usePanelActions();
|
|
788
1030
|
const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
|
|
789
1031
|
const { mutateAsync: publish, isPending: isPublishing } = usePublish();
|
|
1032
|
+
const resetAndClosePanel = () => {
|
|
1033
|
+
dispatch4(slice.actions.resetToInitialState({ context: "frontend" }));
|
|
1034
|
+
closeSaveChangesDialog();
|
|
1035
|
+
};
|
|
790
1036
|
usePreventUnload();
|
|
791
|
-
return /* @__PURE__ */
|
|
1037
|
+
return /* @__PURE__ */ React10.createElement(ThemeProvider, null, /* @__PURE__ */ React10.createElement(ErrorBoundary, { fallback: /* @__PURE__ */ React10.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React10.createElement(Panel, null, /* @__PURE__ */ React10.createElement(PanelHeader, null, /* @__PURE__ */ React10.createElement(Stack5, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React10.createElement(PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React10.createElement(FlippedColorSwatchIcon, { fontSize: "inherit" }), __8("Class Manager", "elementor")), /* @__PURE__ */ React10.createElement(
|
|
792
1038
|
CloseButton,
|
|
793
1039
|
{
|
|
794
1040
|
sx: { marginLeft: "auto" },
|
|
@@ -801,7 +1047,42 @@ function ClassManagerPanel() {
|
|
|
801
1047
|
closePanel();
|
|
802
1048
|
}
|
|
803
1049
|
}
|
|
804
|
-
))), /* @__PURE__ */
|
|
1050
|
+
))), /* @__PURE__ */ React10.createElement(
|
|
1051
|
+
PanelBody,
|
|
1052
|
+
{
|
|
1053
|
+
sx: {
|
|
1054
|
+
display: "flex",
|
|
1055
|
+
flexDirection: "column",
|
|
1056
|
+
height: "100%"
|
|
1057
|
+
}
|
|
1058
|
+
},
|
|
1059
|
+
isVersion311IsActive2 && /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(ClassManagerSearch, { searchValue: inputValue, onChange: handleChange }), /* @__PURE__ */ React10.createElement(
|
|
1060
|
+
Divider,
|
|
1061
|
+
{
|
|
1062
|
+
sx: {
|
|
1063
|
+
borderWidth: "1px 0 0 0"
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
)),
|
|
1067
|
+
/* @__PURE__ */ React10.createElement(
|
|
1068
|
+
Box6,
|
|
1069
|
+
{
|
|
1070
|
+
px: 2,
|
|
1071
|
+
sx: {
|
|
1072
|
+
flexGrow: 1,
|
|
1073
|
+
overflowY: "auto"
|
|
1074
|
+
}
|
|
1075
|
+
},
|
|
1076
|
+
/* @__PURE__ */ React10.createElement(
|
|
1077
|
+
GlobalClassesList,
|
|
1078
|
+
{
|
|
1079
|
+
disabled: isPublishing,
|
|
1080
|
+
searchValue: debouncedValue,
|
|
1081
|
+
onSearch: handleChange
|
|
1082
|
+
}
|
|
1083
|
+
)
|
|
1084
|
+
)
|
|
1085
|
+
), /* @__PURE__ */ React10.createElement(PanelFooter, null, /* @__PURE__ */ React10.createElement(
|
|
805
1086
|
Button3,
|
|
806
1087
|
{
|
|
807
1088
|
fullWidth: true,
|
|
@@ -812,17 +1093,19 @@ function ClassManagerPanel() {
|
|
|
812
1093
|
disabled: !isDirty2,
|
|
813
1094
|
loading: isPublishing
|
|
814
1095
|
},
|
|
815
|
-
|
|
816
|
-
)))), /* @__PURE__ */
|
|
1096
|
+
__8("Save changes", "elementor")
|
|
1097
|
+
)))), /* @__PURE__ */ React10.createElement(ClassManagerIntroduction, null), isSaveChangesDialogOpen && /* @__PURE__ */ React10.createElement(SaveChangesDialog, null, /* @__PURE__ */ React10.createElement(DialogHeader, { onClose: closeSaveChangesDialog, logo: false }, /* @__PURE__ */ React10.createElement(SaveChangesDialog.Title, null, __8("You have unsaved changes", "elementor"))), /* @__PURE__ */ React10.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React10.createElement(SaveChangesDialog.ContentText, null, __8("You have unsaved changes in the Class Manager.", "elementor")), /* @__PURE__ */ React10.createElement(SaveChangesDialog.ContentText, null, __8("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React10.createElement(
|
|
817
1098
|
SaveChangesDialog.Actions,
|
|
818
1099
|
{
|
|
819
1100
|
actions: {
|
|
820
|
-
|
|
821
|
-
label:
|
|
822
|
-
action:
|
|
1101
|
+
discard: {
|
|
1102
|
+
label: __8("Discard", "elementor"),
|
|
1103
|
+
action: () => {
|
|
1104
|
+
resetAndClosePanel();
|
|
1105
|
+
}
|
|
823
1106
|
},
|
|
824
1107
|
confirm: {
|
|
825
|
-
label:
|
|
1108
|
+
label: __8("Save & Continue", "elementor"),
|
|
826
1109
|
action: async () => {
|
|
827
1110
|
await publish();
|
|
828
1111
|
closeSaveChangesDialog();
|
|
@@ -833,11 +1116,11 @@ function ClassManagerPanel() {
|
|
|
833
1116
|
}
|
|
834
1117
|
)));
|
|
835
1118
|
}
|
|
836
|
-
var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */
|
|
837
|
-
var ErrorBoundaryFallback = () => /* @__PURE__ */
|
|
1119
|
+
var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */ React10.createElement(IconButton2, { size: "small", color: "secondary", onClick: onClose, "aria-label": "Close", ...props }, /* @__PURE__ */ React10.createElement(XIcon, { fontSize: "small" }));
|
|
1120
|
+
var ErrorBoundaryFallback = () => /* @__PURE__ */ React10.createElement(Box6, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React10.createElement(Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React10.createElement("strong", null, __8("Something went wrong", "elementor"))));
|
|
838
1121
|
var usePreventUnload = () => {
|
|
839
1122
|
const isDirty2 = useDirtyState();
|
|
840
|
-
|
|
1123
|
+
useEffect2(() => {
|
|
841
1124
|
const handleBeforeUnload = (event) => {
|
|
842
1125
|
if (isDirty2) {
|
|
843
1126
|
event.preventDefault();
|
|
@@ -879,19 +1162,19 @@ var ClassManagerButton = () => {
|
|
|
879
1162
|
}
|
|
880
1163
|
openPanel();
|
|
881
1164
|
};
|
|
882
|
-
return /* @__PURE__ */
|
|
1165
|
+
return /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(Tooltip2, { title: __9("Class Manager", "elementor"), placement: "top" }, /* @__PURE__ */ React11.createElement(IconButton3, { size: "tiny", onClick: handleOpenPanel, sx: { marginInlineEnd: -0.75 } }, /* @__PURE__ */ React11.createElement(FlippedColorSwatchIcon, { fontSize: "tiny" }))), isSaveChangesDialogOpen && /* @__PURE__ */ React11.createElement(SaveChangesDialog, null, /* @__PURE__ */ React11.createElement(SaveChangesDialog.Title, null, __9("You have unsaved changes", "elementor")), /* @__PURE__ */ React11.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React11.createElement(SaveChangesDialog.ContentText, { sx: { mb: 2 } }, __9(
|
|
883
1166
|
"To open the Class Manager, save your page first. You can't continue without saving.",
|
|
884
1167
|
"elementor"
|
|
885
|
-
))), /* @__PURE__ */
|
|
1168
|
+
))), /* @__PURE__ */ React11.createElement(
|
|
886
1169
|
SaveChangesDialog.Actions,
|
|
887
1170
|
{
|
|
888
1171
|
actions: {
|
|
889
1172
|
cancel: {
|
|
890
|
-
label:
|
|
1173
|
+
label: __9("Stay here", "elementor"),
|
|
891
1174
|
action: closeSaveChangesDialog
|
|
892
1175
|
},
|
|
893
1176
|
confirm: {
|
|
894
|
-
label:
|
|
1177
|
+
label: __9("Save & Continue", "elementor"),
|
|
895
1178
|
action: async () => {
|
|
896
1179
|
await saveDocument();
|
|
897
1180
|
closeSaveChangesDialog();
|
|
@@ -904,16 +1187,16 @@ var ClassManagerButton = () => {
|
|
|
904
1187
|
};
|
|
905
1188
|
|
|
906
1189
|
// src/components/populate-store.tsx
|
|
907
|
-
import { useEffect as
|
|
1190
|
+
import { useEffect as useEffect3 } from "react";
|
|
908
1191
|
import { __useDispatch as useDispatch2 } from "@elementor/store";
|
|
909
1192
|
function PopulateStore() {
|
|
910
|
-
const
|
|
911
|
-
|
|
1193
|
+
const dispatch5 = useDispatch2();
|
|
1194
|
+
useEffect3(() => {
|
|
912
1195
|
Promise.all([apiClient.all("preview"), apiClient.all("frontend")]).then(
|
|
913
1196
|
([previewRes, frontendRes]) => {
|
|
914
1197
|
const { data: previewData } = previewRes;
|
|
915
1198
|
const { data: frontendData } = frontendRes;
|
|
916
|
-
|
|
1199
|
+
dispatch5(
|
|
917
1200
|
slice.actions.load({
|
|
918
1201
|
preview: {
|
|
919
1202
|
items: previewData.data,
|
|
@@ -927,7 +1210,7 @@ function PopulateStore() {
|
|
|
927
1210
|
);
|
|
928
1211
|
}
|
|
929
1212
|
);
|
|
930
|
-
}, [
|
|
1213
|
+
}, [dispatch5]);
|
|
931
1214
|
return null;
|
|
932
1215
|
}
|
|
933
1216
|
|
|
@@ -972,6 +1255,10 @@ function init() {
|
|
|
972
1255
|
id: "global-classes-manager-button",
|
|
973
1256
|
component: ClassManagerButton
|
|
974
1257
|
});
|
|
1258
|
+
registerStyleProviderToColors(GLOBAL_CLASSES_PROVIDER_KEY, {
|
|
1259
|
+
name: "global",
|
|
1260
|
+
getThemeColor: (theme) => theme.palette.global.dark
|
|
1261
|
+
});
|
|
975
1262
|
listenTo(v1ReadyEvent(), () => {
|
|
976
1263
|
syncWithDocumentSave();
|
|
977
1264
|
});
|