@elementor/editor-ui 4.0.0-552 → 4.0.0-573
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.d.mts +28 -7
- package/dist/index.d.ts +28 -7
- package/dist/index.js +358 -263
- package/dist/index.mjs +298 -203
- package/package.json +2 -2
- package/src/components/collapsible-content.tsx +66 -0
- package/src/components/confirmation-dialog.tsx +59 -13
- package/src/components/form.tsx +8 -2
- package/src/components/{promotion-infotip.tsx → promotions/promotion-infotip.tsx} +3 -14
- package/src/components/{promotion-popover.tsx → promotions/promotion-popover.tsx} +8 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-canvas-click-handler.tsx +16 -0
- package/src/index.ts +6 -4
- /package/src/components/{promotion-alert.tsx → promotions/promotion-alert.tsx} +0 -0
- /package/src/components/{promotion-chip.tsx → promotions/promotion-chip.tsx} +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-ui",
|
|
3
3
|
"description": "Elementor Editor UI",
|
|
4
|
-
"version": "4.0.0-
|
|
4
|
+
"version": "4.0.0-573",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"react-dom": "^18.3.1"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@elementor/editor-v1-adapters": "4.0.0-
|
|
40
|
+
"@elementor/editor-v1-adapters": "4.0.0-573",
|
|
41
41
|
"@elementor/icons": "^1.63.0",
|
|
42
42
|
"@elementor/ui": "1.36.17",
|
|
43
43
|
"@tanstack/react-virtual": "^3.13.3",
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ReactNode, useState } from 'react';
|
|
3
|
+
import { Button, Collapse, Stack, styled } from '@elementor/ui';
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
|
|
6
|
+
import { CollapseIcon } from './collapse-icon';
|
|
7
|
+
|
|
8
|
+
type StaticItem< T = unknown > = T extends ( ...args: unknown[] ) => unknown ? never : T;
|
|
9
|
+
|
|
10
|
+
type CallbackItem< T > = ( isOpen: boolean ) => T;
|
|
11
|
+
export type CollapsibleValue< T > = CallbackItem< T > | StaticItem< T >;
|
|
12
|
+
|
|
13
|
+
type CollapsibleContentProps = React.PropsWithChildren< {
|
|
14
|
+
defaultOpen?: boolean;
|
|
15
|
+
titleEnd?: CollapsibleValue< ReactNode | string > | null;
|
|
16
|
+
} >;
|
|
17
|
+
|
|
18
|
+
const IndicatorsWrapper = styled( 'div' )`
|
|
19
|
+
position: absolute;
|
|
20
|
+
top: 0;
|
|
21
|
+
right: ${ ( { theme } ) => theme.spacing( 3 ) };
|
|
22
|
+
height: 100%;
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
align-items: center;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
export const CollapsibleContent = ( { children, defaultOpen = false, titleEnd = null }: CollapsibleContentProps ) => {
|
|
30
|
+
const [ open, setOpen ] = useState( defaultOpen );
|
|
31
|
+
|
|
32
|
+
const handleToggle = () => {
|
|
33
|
+
setOpen( ( prevOpen ) => ! prevOpen );
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Stack>
|
|
38
|
+
<Stack sx={ { position: 'relative' } }>
|
|
39
|
+
<Button
|
|
40
|
+
fullWidth
|
|
41
|
+
size="small"
|
|
42
|
+
color="secondary"
|
|
43
|
+
variant="outlined"
|
|
44
|
+
onClick={ handleToggle }
|
|
45
|
+
endIcon={ <CollapseIcon open={ open } /> }
|
|
46
|
+
sx={ { my: 0.5 } }
|
|
47
|
+
aria-label={ open ? 'Show less' : 'Show more' }
|
|
48
|
+
>
|
|
49
|
+
{ open ? __( 'Show less', 'elementor' ) : __( 'Show more', 'elementor' ) }
|
|
50
|
+
</Button>
|
|
51
|
+
{ titleEnd && <IndicatorsWrapper>{ getCollapsibleValue( titleEnd, open ) }</IndicatorsWrapper> }
|
|
52
|
+
</Stack>
|
|
53
|
+
<Collapse in={ open } timeout="auto" unmountOnExit>
|
|
54
|
+
{ children }
|
|
55
|
+
</Collapse>
|
|
56
|
+
</Stack>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export function getCollapsibleValue< T >( value: CollapsibleValue< T >, isOpen: boolean ): T {
|
|
61
|
+
if ( typeof value === 'function' ) {
|
|
62
|
+
return ( value as CallbackItem< T > )( isOpen );
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { useState } from 'react';
|
|
2
3
|
import { AlertOctagonFilledIcon } from '@elementor/icons';
|
|
3
4
|
import {
|
|
4
5
|
Button,
|
|
6
|
+
Checkbox,
|
|
5
7
|
Dialog,
|
|
6
8
|
DialogActions,
|
|
7
9
|
DialogContent,
|
|
@@ -9,6 +11,8 @@ import {
|
|
|
9
11
|
type DialogContentTextProps,
|
|
10
12
|
type DialogProps,
|
|
11
13
|
DialogTitle,
|
|
14
|
+
FormControlLabel,
|
|
15
|
+
Typography,
|
|
12
16
|
} from '@elementor/ui';
|
|
13
17
|
import { __ } from '@wordpress/i18n';
|
|
14
18
|
|
|
@@ -22,9 +26,18 @@ export const ConfirmationDialog = ( { open, onClose, children }: ConfirmationDia
|
|
|
22
26
|
</Dialog>
|
|
23
27
|
);
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
type ConfirmationDialogTitleProps = React.PropsWithChildren< {
|
|
30
|
+
icon?: React.ElementType;
|
|
31
|
+
iconColor?: 'error' | 'secondary';
|
|
32
|
+
} >;
|
|
33
|
+
|
|
34
|
+
const ConfirmationDialogTitle = ( {
|
|
35
|
+
children,
|
|
36
|
+
icon: Icon = AlertOctagonFilledIcon,
|
|
37
|
+
iconColor = 'error',
|
|
38
|
+
}: ConfirmationDialogTitleProps ) => (
|
|
26
39
|
<DialogTitle id={ TITLE_ID } display="flex" alignItems="center" gap={ 1 } sx={ { lineHeight: 1 } }>
|
|
27
|
-
<
|
|
40
|
+
<Icon color={ iconColor } />
|
|
28
41
|
{ children }
|
|
29
42
|
</DialogTitle>
|
|
30
43
|
);
|
|
@@ -42,6 +55,9 @@ type ConfirmationDialogActionsProps = {
|
|
|
42
55
|
onConfirm: () => void;
|
|
43
56
|
cancelLabel?: string;
|
|
44
57
|
confirmLabel?: string;
|
|
58
|
+
color?: 'error' | 'secondary';
|
|
59
|
+
onSuppressMessage?: () => void;
|
|
60
|
+
suppressLabel?: string;
|
|
45
61
|
};
|
|
46
62
|
|
|
47
63
|
const ConfirmationDialogActions = ( {
|
|
@@ -49,17 +65,47 @@ const ConfirmationDialogActions = ( {
|
|
|
49
65
|
onConfirm,
|
|
50
66
|
cancelLabel,
|
|
51
67
|
confirmLabel,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
);
|
|
68
|
+
color = 'error',
|
|
69
|
+
onSuppressMessage,
|
|
70
|
+
suppressLabel = __( "Don't show this again", 'elementor' ),
|
|
71
|
+
}: ConfirmationDialogActionsProps ) => {
|
|
72
|
+
const [ dontShowAgain, setDontShowAgain ] = useState( false );
|
|
73
|
+
|
|
74
|
+
const handleConfirm = () => {
|
|
75
|
+
if ( dontShowAgain && onSuppressMessage ) {
|
|
76
|
+
onSuppressMessage();
|
|
77
|
+
}
|
|
78
|
+
onConfirm();
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<DialogActions sx={ onSuppressMessage ? { justifyContent: 'space-between', alignItems: 'center' } : undefined }>
|
|
83
|
+
{ onSuppressMessage && (
|
|
84
|
+
<FormControlLabel
|
|
85
|
+
control={
|
|
86
|
+
<Checkbox
|
|
87
|
+
checked={ dontShowAgain }
|
|
88
|
+
onChange={ ( event: React.ChangeEvent< HTMLInputElement > ) =>
|
|
89
|
+
setDontShowAgain( event.target.checked )
|
|
90
|
+
}
|
|
91
|
+
size="small"
|
|
92
|
+
/>
|
|
93
|
+
}
|
|
94
|
+
label={ <Typography variant="body2">{ suppressLabel }</Typography> }
|
|
95
|
+
/>
|
|
96
|
+
) }
|
|
97
|
+
<div>
|
|
98
|
+
<Button color="secondary" onClick={ onClose }>
|
|
99
|
+
{ cancelLabel ?? __( 'Not now', 'elementor' ) }
|
|
100
|
+
</Button>
|
|
101
|
+
{ /* eslint-disable-next-line jsx-a11y/no-autofocus */ }
|
|
102
|
+
<Button autoFocus variant="contained" color={ color } onClick={ handleConfirm } sx={ { ml: 1 } }>
|
|
103
|
+
{ confirmLabel ?? __( 'Delete', 'elementor' ) }
|
|
104
|
+
</Button>
|
|
105
|
+
</div>
|
|
106
|
+
</DialogActions>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
63
109
|
|
|
64
110
|
ConfirmationDialog.Title = ConfirmationDialogTitle;
|
|
65
111
|
ConfirmationDialog.Content = ConfirmationDialogContent;
|
package/src/components/form.tsx
CHANGED
|
@@ -3,8 +3,9 @@ import { type FormEvent as FormEvent, type KeyboardEvent, type PropsWithChildren
|
|
|
3
3
|
|
|
4
4
|
type Props = PropsWithChildren< {
|
|
5
5
|
onSubmit?: () => void;
|
|
6
|
+
'data-testid'?: string;
|
|
6
7
|
} >;
|
|
7
|
-
export const Form = ( { children, onSubmit }: Props ) => {
|
|
8
|
+
export const Form = ( { children, onSubmit, 'data-testid': dataTestId }: Props ) => {
|
|
8
9
|
const formRef = useRef< HTMLFormElement >( null );
|
|
9
10
|
|
|
10
11
|
const handleSubmit = ( e: FormEvent< HTMLFormElement > | SubmitEvent ) => {
|
|
@@ -23,7 +24,12 @@ export const Form = ( { children, onSubmit }: Props ) => {
|
|
|
23
24
|
|
|
24
25
|
return (
|
|
25
26
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
26
|
-
<form
|
|
27
|
+
<form
|
|
28
|
+
onSubmit={ handleSubmit }
|
|
29
|
+
ref={ formRef }
|
|
30
|
+
onKeyDown={ handleKeyDown }
|
|
31
|
+
{ ...( dataTestId ? { 'data-testid': dataTestId } : {} ) }
|
|
32
|
+
>
|
|
27
33
|
{ children }
|
|
28
34
|
</form>
|
|
29
35
|
);
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useEffect } from 'react';
|
|
3
|
-
import { getCanvasIframeDocument } from '@elementor/editor-v1-adapters';
|
|
4
2
|
import {
|
|
5
3
|
Card,
|
|
6
4
|
CardActions,
|
|
@@ -13,7 +11,8 @@ import {
|
|
|
13
11
|
Typography,
|
|
14
12
|
} from '@elementor/ui';
|
|
15
13
|
|
|
16
|
-
import {
|
|
14
|
+
import { useCanvasClickHandler } from '../../hooks';
|
|
15
|
+
import { CtaButton } from '../cta-button';
|
|
17
16
|
|
|
18
17
|
type InfotipCardProps = {
|
|
19
18
|
title: string;
|
|
@@ -30,17 +29,7 @@ type PromotionInfotipProps = React.PropsWithChildren<
|
|
|
30
29
|
>;
|
|
31
30
|
|
|
32
31
|
export const PromotionInfotip = ( { children, open, onClose, ...cardProps }: PromotionInfotipProps ) => {
|
|
33
|
-
|
|
34
|
-
const canvasDocument = open ? getCanvasIframeDocument() : null;
|
|
35
|
-
|
|
36
|
-
if ( ! canvasDocument ) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
canvasDocument.addEventListener( 'mousedown', onClose );
|
|
41
|
-
|
|
42
|
-
return () => canvasDocument.removeEventListener( 'mousedown', onClose );
|
|
43
|
-
}, [ open, onClose ] );
|
|
32
|
+
useCanvasClickHandler( !! open, onClose );
|
|
44
33
|
|
|
45
34
|
return (
|
|
46
35
|
<Infotip placement="right" content={ <InfotipCard onClose={ onClose } { ...cardProps } /> } open={ open }>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { type MouseEvent, type RefObject } from 'react';
|
|
2
3
|
import { CrownFilledIcon } from '@elementor/icons';
|
|
3
4
|
import {
|
|
4
5
|
Alert,
|
|
@@ -16,7 +17,7 @@ type PromotionPopoverCardProps = {
|
|
|
16
17
|
content: string;
|
|
17
18
|
ctaUrl: string;
|
|
18
19
|
ctaText?: string;
|
|
19
|
-
onClose: () => void;
|
|
20
|
+
onClose: ( e: MouseEvent ) => void;
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
type PromotionPopoverProps = React.PropsWithChildren<
|
|
@@ -24,6 +25,7 @@ type PromotionPopoverProps = React.PropsWithChildren<
|
|
|
24
25
|
open: boolean;
|
|
25
26
|
placement?: InfotipProps[ 'placement' ];
|
|
26
27
|
slotProps?: InfotipProps[ 'slotProps' ];
|
|
28
|
+
anchorRef?: RefObject< HTMLElement | null >;
|
|
27
29
|
}
|
|
28
30
|
>;
|
|
29
31
|
|
|
@@ -32,15 +34,19 @@ export const PromotionPopover = ( {
|
|
|
32
34
|
open,
|
|
33
35
|
placement = 'right',
|
|
34
36
|
slotProps,
|
|
37
|
+
anchorRef,
|
|
35
38
|
...cardProps
|
|
36
39
|
}: PromotionPopoverProps ) => {
|
|
40
|
+
const anchorEl = anchorRef?.current;
|
|
41
|
+
|
|
37
42
|
const defaultSlotProps: InfotipProps[ 'slotProps' ] = {
|
|
38
43
|
popper: {
|
|
44
|
+
...( anchorEl && { anchorEl } ),
|
|
39
45
|
modifiers: [
|
|
40
46
|
{
|
|
41
47
|
name: 'offset',
|
|
42
48
|
options: {
|
|
43
|
-
offset: [ 0, 10 ],
|
|
49
|
+
offset: anchorRef ? [ 0, 4 ] : [ 0, 10 ],
|
|
44
50
|
},
|
|
45
51
|
},
|
|
46
52
|
],
|
package/src/hooks/index.ts
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { getCanvasIframeDocument } from '@elementor/editor-v1-adapters';
|
|
3
|
+
|
|
4
|
+
export const useCanvasClickHandler = ( isActive: boolean, onClickAway: ( e: MouseEvent ) => void ) => {
|
|
5
|
+
useEffect( () => {
|
|
6
|
+
const canvasDocument = isActive ? getCanvasIframeDocument() : null;
|
|
7
|
+
|
|
8
|
+
if ( ! canvasDocument ) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
canvasDocument.addEventListener( 'mousedown', onClickAway );
|
|
13
|
+
|
|
14
|
+
return () => canvasDocument.removeEventListener( 'mousedown', onClickAway );
|
|
15
|
+
}, [ isActive, onClickAway ] );
|
|
16
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// components
|
|
2
2
|
export { CollapseIcon } from './components/collapse-icon';
|
|
3
|
+
export { CollapsibleContent, getCollapsibleValue, type CollapsibleValue } from './components/collapsible-content';
|
|
3
4
|
export { EllipsisWithTooltip } from './components/ellipsis-with-tooltip';
|
|
4
5
|
export { EditableField } from './components/editable-field';
|
|
5
6
|
export { IntroductionModal } from './components/introduction-modal';
|
|
@@ -12,10 +13,10 @@ export { GlobalDialog, openDialog, closeDialog } from './components/global-dialo
|
|
|
12
13
|
export { SearchField } from './components/search-field';
|
|
13
14
|
export { Form } from './components/form';
|
|
14
15
|
export { CtaButton } from './components/cta-button';
|
|
15
|
-
export { PromotionInfotip } from './components/promotion-infotip';
|
|
16
|
-
export { PromotionPopover } from './components/promotion-popover';
|
|
17
|
-
export { PromotionChip } from './components/promotion-chip';
|
|
18
|
-
export { PromotionAlert } from './components/promotion-alert';
|
|
16
|
+
export { PromotionInfotip } from './components/promotions/promotion-infotip';
|
|
17
|
+
export { PromotionPopover } from './components/promotions/promotion-popover';
|
|
18
|
+
export { PromotionChip } from './components/promotions/promotion-chip';
|
|
19
|
+
export { PromotionAlert } from './components/promotions/promotion-alert';
|
|
19
20
|
export { FloatingActionsBar, useFloatingActionsBar } from './components/floating-bar';
|
|
20
21
|
|
|
21
22
|
export * from './components/popover';
|
|
@@ -28,3 +29,4 @@ export { SectionRefContext, useSectionWidth } from './contexts/section-context';
|
|
|
28
29
|
// hooks
|
|
29
30
|
export { useEditable } from './hooks/use-editable';
|
|
30
31
|
export { useTextFieldAutoSelect } from './hooks/use-text-field-auto-select';
|
|
32
|
+
export { useCanvasClickHandler } from './hooks/use-canvas-click-handler';
|
|
File without changes
|
|
File without changes
|