@elementor/editor-global-classes 0.9.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/dist/index.js +182 -104
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +177 -96
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -13
- package/src/components/class-manager/class-manager-button.tsx +58 -7
- package/src/components/class-manager/class-manager-introduction.tsx +1 -1
- package/src/components/class-manager/class-manager-panel.tsx +54 -27
- package/src/components/class-manager/flipped-color-swatch-icon.tsx +7 -0
- package/src/components/class-manager/global-classes-list.tsx +10 -5
- package/src/components/class-manager/save-changes-dialog.tsx +84 -0
- package/src/components/class-manager/sortable.tsx +13 -3
- package/src/global-classes-styles-provider.ts +1 -1
- package/src/components/class-manager/unsaved-changes-dialog.tsx +0 -76
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { AlertTriangleFilledIcon } from '@elementor/icons';
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
Dialog,
|
|
7
|
+
DialogActions,
|
|
8
|
+
DialogContent,
|
|
9
|
+
DialogContentText,
|
|
10
|
+
type DialogContentTextProps,
|
|
11
|
+
type DialogProps,
|
|
12
|
+
DialogTitle,
|
|
13
|
+
} from '@elementor/ui';
|
|
14
|
+
|
|
15
|
+
const TITLE_ID = 'save-changes-dialog';
|
|
16
|
+
|
|
17
|
+
const SaveChangesDialog = ( { children, onClose }: Pick< DialogProps, 'children' | 'onClose' > ) => (
|
|
18
|
+
<Dialog open onClose={ onClose } aria-labelledby={ TITLE_ID } maxWidth="xs">
|
|
19
|
+
{ children }
|
|
20
|
+
</Dialog>
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const SaveChangesDialogTitle = ( { children }: React.PropsWithChildren ) => (
|
|
24
|
+
<DialogTitle id={ TITLE_ID } display="flex" alignItems="center" gap={ 1 } sx={ { lineHeight: 1 } }>
|
|
25
|
+
<AlertTriangleFilledIcon color="secondary" />
|
|
26
|
+
{ children }
|
|
27
|
+
</DialogTitle>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const SaveChangesDialogContent = ( { children }: React.PropsWithChildren ) => (
|
|
31
|
+
<DialogContent>{ children }</DialogContent>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const SaveChangesDialogContentText = ( props: DialogContentTextProps ) => (
|
|
35
|
+
<DialogContentText variant="body2" color="textPrimary" display="flex" flexDirection="column" { ...props } />
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
type Action = {
|
|
39
|
+
label: string;
|
|
40
|
+
action: () => void | Promise< void >;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
type ConfirmationDialogActionsProps = {
|
|
44
|
+
actions: {
|
|
45
|
+
cancel: Action;
|
|
46
|
+
confirm: Action;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
const SaveChangesDialogActions = ( { actions }: ConfirmationDialogActionsProps ) => {
|
|
50
|
+
const [ isConfirming, setIsConfirming ] = useState( false );
|
|
51
|
+
const { cancel, confirm } = actions;
|
|
52
|
+
|
|
53
|
+
const onConfirm = async () => {
|
|
54
|
+
setIsConfirming( true );
|
|
55
|
+
await confirm.action();
|
|
56
|
+
setIsConfirming( false );
|
|
57
|
+
};
|
|
58
|
+
return (
|
|
59
|
+
<DialogActions>
|
|
60
|
+
<Button variant="text" color="secondary" onClick={ cancel.action }>
|
|
61
|
+
{ cancel.label }
|
|
62
|
+
</Button>
|
|
63
|
+
<Button variant="contained" color="secondary" onClick={ onConfirm } loading={ isConfirming }>
|
|
64
|
+
{ confirm.label }
|
|
65
|
+
</Button>
|
|
66
|
+
</DialogActions>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
SaveChangesDialog.Title = SaveChangesDialogTitle;
|
|
71
|
+
SaveChangesDialog.Content = SaveChangesDialogContent;
|
|
72
|
+
SaveChangesDialog.ContentText = SaveChangesDialogContentText;
|
|
73
|
+
SaveChangesDialog.Actions = SaveChangesDialogActions;
|
|
74
|
+
|
|
75
|
+
const useDialog = () => {
|
|
76
|
+
const [ isOpen, setIsOpen ] = useState( false );
|
|
77
|
+
|
|
78
|
+
const open = () => setIsOpen( true );
|
|
79
|
+
const close = () => setIsOpen( false );
|
|
80
|
+
|
|
81
|
+
return { isOpen, open, close };
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export { SaveChangesDialog, useDialog };
|
|
@@ -25,6 +25,7 @@ type ItemRenderProps = Record< string, unknown > & {
|
|
|
25
25
|
isDragged: boolean;
|
|
26
26
|
showDropIndication: boolean;
|
|
27
27
|
dropIndicationStyle: React.CSSProperties;
|
|
28
|
+
isDragPlaceholder: boolean;
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
type SortableItemProps = {
|
|
@@ -32,9 +33,10 @@ type SortableItemProps = {
|
|
|
32
33
|
children: ( props: ItemRenderProps ) => React.ReactNode;
|
|
33
34
|
};
|
|
34
35
|
|
|
35
|
-
export const SortableItem = ( { children, id }: SortableItemProps ) => {
|
|
36
|
+
export const SortableItem = ( { children, id, ...props }: SortableItemProps ) => {
|
|
36
37
|
return (
|
|
37
38
|
<UnstableSortableItem
|
|
39
|
+
{ ...props }
|
|
38
40
|
id={ id }
|
|
39
41
|
render={ ( {
|
|
40
42
|
itemProps,
|
|
@@ -44,9 +46,16 @@ export const SortableItem = ( { children, id }: SortableItemProps ) => {
|
|
|
44
46
|
triggerStyle,
|
|
45
47
|
dropIndicationStyle,
|
|
46
48
|
showDropIndication,
|
|
49
|
+
isDragOverlay,
|
|
50
|
+
isDragPlaceholder,
|
|
47
51
|
}: UnstableSortableItemRenderProps ) => {
|
|
48
52
|
return (
|
|
49
|
-
<StyledSortableItem
|
|
53
|
+
<StyledSortableItem
|
|
54
|
+
{ ...itemProps }
|
|
55
|
+
sx={ itemStyle }
|
|
56
|
+
role="listitem"
|
|
57
|
+
{ ...( isDragOverlay ? { component: Paper, elevation: 0 } : {} ) }
|
|
58
|
+
>
|
|
50
59
|
<SortableTrigger { ...triggerProps } style={ triggerStyle } />
|
|
51
60
|
{ children( {
|
|
52
61
|
itemProps,
|
|
@@ -56,6 +65,7 @@ export const SortableItem = ( { children, id }: SortableItemProps ) => {
|
|
|
56
65
|
triggerStyle,
|
|
57
66
|
dropIndicationStyle,
|
|
58
67
|
showDropIndication,
|
|
68
|
+
isDragPlaceholder,
|
|
59
69
|
} ) }
|
|
60
70
|
</StyledSortableItem>
|
|
61
71
|
);
|
|
@@ -64,7 +74,7 @@ export const SortableItem = ( { children, id }: SortableItemProps ) => {
|
|
|
64
74
|
);
|
|
65
75
|
};
|
|
66
76
|
|
|
67
|
-
const StyledSortableItem = styled(
|
|
77
|
+
const StyledSortableItem = styled( Box )`
|
|
68
78
|
position: relative;
|
|
69
79
|
|
|
70
80
|
&:hover {
|
|
@@ -65,6 +65,6 @@ export const globalClassesStylesProvider = {
|
|
|
65
65
|
subscribe: ( cb ) => subscribeWithSelector( ( state: StateWithGlobalClasses ) => state.globalClasses, cb ),
|
|
66
66
|
labels: {
|
|
67
67
|
singular: __( 'Global class', 'elementor' ),
|
|
68
|
-
plural: __( 'Global CSS
|
|
68
|
+
plural: __( 'Global CSS classes', 'elementor' ),
|
|
69
69
|
},
|
|
70
70
|
} satisfies StylesProvider;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import { AlertTriangleFilledIcon } from '@elementor/icons';
|
|
4
|
-
import {
|
|
5
|
-
Button,
|
|
6
|
-
Dialog,
|
|
7
|
-
DialogActions,
|
|
8
|
-
DialogContent,
|
|
9
|
-
DialogContentText,
|
|
10
|
-
type DialogProps,
|
|
11
|
-
DialogTitle,
|
|
12
|
-
} from '@elementor/ui';
|
|
13
|
-
|
|
14
|
-
const TITLE_ID = 'unsaved-changes-dialog';
|
|
15
|
-
|
|
16
|
-
const UnsavedChangesDialog = ( { children, onClose }: Pick< DialogProps, 'children' | 'onClose' > ) => (
|
|
17
|
-
<Dialog open onClose={ onClose } aria-labelledby={ TITLE_ID } maxWidth="xs">
|
|
18
|
-
{ children }
|
|
19
|
-
</Dialog>
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
const UnsavedChangesDialogTitle = ( { children }: React.PropsWithChildren ) => (
|
|
23
|
-
<DialogTitle id={ TITLE_ID } display="flex" alignItems="center" gap={ 1 } sx={ { lineHeight: 1 } }>
|
|
24
|
-
<AlertTriangleFilledIcon color="secondary" />
|
|
25
|
-
{ children }
|
|
26
|
-
</DialogTitle>
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const UnsavedChangesDialogContent = ( { children }: React.PropsWithChildren ) => (
|
|
30
|
-
<DialogContent>
|
|
31
|
-
<DialogContentText variant="body2" color="textPrimary">
|
|
32
|
-
{ children }
|
|
33
|
-
</DialogContentText>
|
|
34
|
-
</DialogContent>
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
type Action = {
|
|
38
|
-
label: string;
|
|
39
|
-
action: () => void;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
type ConfirmationDialogActionsProps = {
|
|
43
|
-
actions: {
|
|
44
|
-
cancel: Action;
|
|
45
|
-
confirm: Action;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
const UnsavedChangesDialogActions = ( { actions }: ConfirmationDialogActionsProps ) => {
|
|
49
|
-
const { cancel, confirm } = actions;
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<DialogActions>
|
|
53
|
-
<Button variant="text" color="secondary" onClick={ cancel.action }>
|
|
54
|
-
{ cancel.label }
|
|
55
|
-
</Button>
|
|
56
|
-
<Button variant="contained" color="secondary" onClick={ confirm.action }>
|
|
57
|
-
{ confirm.label }
|
|
58
|
-
</Button>
|
|
59
|
-
</DialogActions>
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
UnsavedChangesDialog.Title = UnsavedChangesDialogTitle;
|
|
64
|
-
UnsavedChangesDialog.Content = UnsavedChangesDialogContent;
|
|
65
|
-
UnsavedChangesDialog.Actions = UnsavedChangesDialogActions;
|
|
66
|
-
|
|
67
|
-
const useDialog = () => {
|
|
68
|
-
const [ isOpen, setIsOpen ] = useState( false );
|
|
69
|
-
|
|
70
|
-
const open = () => setIsOpen( true );
|
|
71
|
-
const close = () => setIsOpen( false );
|
|
72
|
-
|
|
73
|
-
return { isOpen, open, close };
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export { UnsavedChangesDialog, useDialog };
|