@elementor/editor-interactions 4.0.0-528 → 4.0.0-530
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.js +37 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -8
- package/src/components/interaction-settings.tsx +58 -38
- package/src/components/interactions-list-item.tsx +1 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-interactions",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-530",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -39,15 +39,16 @@
|
|
|
39
39
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@elementor/editor-controls": "4.0.0-
|
|
43
|
-
"@elementor/editor-elements": "4.0.0-
|
|
44
|
-
"@elementor/editor-props": "4.0.0-
|
|
45
|
-
"@elementor/editor-
|
|
46
|
-
"@elementor/editor-
|
|
42
|
+
"@elementor/editor-controls": "4.0.0-530",
|
|
43
|
+
"@elementor/editor-elements": "4.0.0-530",
|
|
44
|
+
"@elementor/editor-props": "4.0.0-530",
|
|
45
|
+
"@elementor/editor-responsive": "4.0.0-530",
|
|
46
|
+
"@elementor/editor-ui": "4.0.0-530",
|
|
47
|
+
"@elementor/editor-v1-adapters": "4.0.0-530",
|
|
47
48
|
"@elementor/icons": "^1.63.0",
|
|
48
|
-
"@elementor/session": "4.0.0-
|
|
49
|
+
"@elementor/session": "4.0.0-530",
|
|
49
50
|
"@elementor/ui": "1.36.17",
|
|
50
|
-
"@elementor/utils": "4.0.0-
|
|
51
|
+
"@elementor/utils": "4.0.0-530",
|
|
51
52
|
"@wordpress/i18n": "^5.13.0"
|
|
52
53
|
},
|
|
53
54
|
"peerDependencies": {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { type SyntheticEvent, useState } from 'react';
|
|
2
|
+
import { type SyntheticEvent, useCallback, useMemo, useState } from 'react';
|
|
3
3
|
import { ControlFormLabel, PopoverContent } from '@elementor/editor-controls';
|
|
4
|
-
import {
|
|
4
|
+
import { useBreakpoints } from '@elementor/editor-responsive';
|
|
5
|
+
import { Autocomplete, Chip, Grid, Stack, TextField } from '@elementor/ui';
|
|
5
6
|
import { __ } from '@wordpress/i18n';
|
|
6
7
|
|
|
7
8
|
import type { InteractionItemValue } from '../types';
|
|
@@ -12,63 +13,82 @@ type BreakpointOption = {
|
|
|
12
13
|
value: string;
|
|
13
14
|
};
|
|
14
15
|
|
|
15
|
-
const availableBreakpoints: BreakpointOption[] = [
|
|
16
|
-
{ label: __( 'Desktop', 'elementor' ), value: 'desktop' },
|
|
17
|
-
{ label: __( 'Tablet', 'elementor' ), value: 'tablet' },
|
|
18
|
-
{ label: __( 'Mobile', 'elementor' ), value: 'mobile' },
|
|
19
|
-
];
|
|
20
|
-
|
|
21
16
|
type InteractionSettingsProps = {
|
|
22
17
|
interaction: InteractionItemValue;
|
|
23
18
|
onChange: ( interaction: InteractionItemValue ) => void;
|
|
24
19
|
};
|
|
25
20
|
|
|
21
|
+
const SIZE = 'tiny';
|
|
22
|
+
|
|
26
23
|
export const InteractionSettings = ( { interaction, onChange }: InteractionSettingsProps ) => {
|
|
24
|
+
const breakpoints = useBreakpoints();
|
|
25
|
+
|
|
26
|
+
const availableBreakpoints = useMemo(
|
|
27
|
+
() => breakpoints.map( ( breakpoint ) => ( { label: breakpoint.label, value: String( breakpoint.id ) } ) ),
|
|
28
|
+
[ breakpoints ]
|
|
29
|
+
);
|
|
30
|
+
|
|
27
31
|
const [ selectedBreakpoints, setSelectedBreakpoints ] = useState< BreakpointOption[] >( () => {
|
|
28
|
-
const excluded = extractExcludedBreakpoints( interaction.breakpoints )
|
|
32
|
+
const excluded = extractExcludedBreakpoints( interaction.breakpoints ).filter( ( excludedBreakpoint ) => {
|
|
33
|
+
return availableBreakpoints.some( ( { value } ) => value === excludedBreakpoint );
|
|
34
|
+
} );
|
|
35
|
+
|
|
29
36
|
return availableBreakpoints.filter( ( { value } ) => {
|
|
30
37
|
return ! excluded.includes( value );
|
|
31
38
|
} );
|
|
32
39
|
} );
|
|
33
40
|
|
|
34
|
-
const handleBreakpointChange = (
|
|
35
|
-
|
|
41
|
+
const handleBreakpointChange = useCallback(
|
|
42
|
+
( _: SyntheticEvent, newValue: BreakpointOption[] ) => {
|
|
43
|
+
setSelectedBreakpoints( newValue );
|
|
36
44
|
|
|
37
|
-
|
|
38
|
-
const newExcluded = availableBreakpoints
|
|
39
|
-
.filter( ( bp ) => ! selectedValues.includes( bp.value ) )
|
|
40
|
-
.map( ( bp ) => bp.value );
|
|
45
|
+
const selectedValues = newValue.map( ( option ) => option.value );
|
|
41
46
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
breakpoints: createInteractionBreakpoints( newExcluded ),
|
|
46
|
-
} ),
|
|
47
|
-
};
|
|
47
|
+
const newExcluded = availableBreakpoints
|
|
48
|
+
.filter( ( breakpoint ) => ! selectedValues.includes( breakpoint.value ) )
|
|
49
|
+
.map( ( breakpoint ) => breakpoint.value );
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
const updatedInteraction: InteractionItemValue = {
|
|
52
|
+
...interaction,
|
|
53
|
+
...( newExcluded.length > 0 && {
|
|
54
|
+
breakpoints: createInteractionBreakpoints( newExcluded ),
|
|
55
|
+
} ),
|
|
56
|
+
};
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
if ( newExcluded.length === 0 ) {
|
|
59
|
+
delete updatedInteraction.breakpoints;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
onChange( updatedInteraction );
|
|
63
|
+
},
|
|
64
|
+
[ interaction, availableBreakpoints, onChange ]
|
|
65
|
+
);
|
|
55
66
|
|
|
56
67
|
return (
|
|
57
68
|
<PopoverContent p={ 1.5 }>
|
|
58
69
|
<Grid container spacing={ 1.5 }>
|
|
59
70
|
<Grid item xs={ 12 }>
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
<Stack direction="column" gap={ 1 }>
|
|
72
|
+
<ControlFormLabel sx={ { width: '100%' } }>
|
|
73
|
+
{ __( 'Trigger on', 'elementor' ) }
|
|
74
|
+
</ControlFormLabel>
|
|
75
|
+
<Autocomplete
|
|
76
|
+
fullWidth
|
|
77
|
+
multiple
|
|
78
|
+
value={ selectedBreakpoints }
|
|
79
|
+
onChange={ handleBreakpointChange }
|
|
80
|
+
size={ SIZE }
|
|
81
|
+
options={ availableBreakpoints }
|
|
82
|
+
isOptionEqualToValue={ ( option, value ) => option.value === value.value }
|
|
83
|
+
renderInput={ ( params ) => <TextField { ...params } /> }
|
|
84
|
+
renderTags={ ( values, getTagProps ) =>
|
|
85
|
+
values.map( ( option, index ) => {
|
|
86
|
+
const { key, ...chipProps } = getTagProps( { index } );
|
|
87
|
+
return <Chip key={ key } size={ SIZE } label={ option.label } { ...chipProps } />;
|
|
88
|
+
} )
|
|
89
|
+
}
|
|
90
|
+
/>
|
|
91
|
+
</Stack>
|
|
72
92
|
</Grid>
|
|
73
93
|
</Grid>
|
|
74
94
|
</PopoverContent>
|
|
@@ -45,7 +45,6 @@ export const InteractionsListItem = ( { index, value }: { index: number; value:
|
|
|
45
45
|
|
|
46
46
|
<TabPanel sx={ { p: 0 } } { ...getTabPanelProps( 'details' ) }>
|
|
47
47
|
<InteractionDetails
|
|
48
|
-
key={ `details-${ index }` }
|
|
49
48
|
interaction={ value.value }
|
|
50
49
|
onChange={ handleChange }
|
|
51
50
|
onPlayInteraction={ handlePlayInteraction }
|
|
@@ -53,11 +52,7 @@ export const InteractionsListItem = ( { index, value }: { index: number; value:
|
|
|
53
52
|
</TabPanel>
|
|
54
53
|
|
|
55
54
|
<TabPanel sx={ { p: 0 } } { ...getTabPanelProps( 'settings' ) }>
|
|
56
|
-
<InteractionSettings
|
|
57
|
-
key={ `settings-${ index }` }
|
|
58
|
-
interaction={ value.value }
|
|
59
|
-
onChange={ handleChange }
|
|
60
|
-
/>
|
|
55
|
+
<InteractionSettings interaction={ value.value } onChange={ handleChange } />
|
|
61
56
|
</TabPanel>
|
|
62
57
|
</>
|
|
63
58
|
);
|