@elementor/editor-controls 3.33.0-286 → 3.33.0-288
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 +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +94 -92
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -94
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/control-toggle-button-group.tsx +121 -116
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-controls",
|
|
3
3
|
"description": "This package contains the controls model and utils for the Elementor editor",
|
|
4
|
-
"version": "3.33.0-
|
|
4
|
+
"version": "3.33.0-288",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -40,22 +40,22 @@
|
|
|
40
40
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@elementor/editor-current-user": "3.33.0-
|
|
44
|
-
"@elementor/editor-elements": "3.33.0-
|
|
45
|
-
"@elementor/editor-props": "3.33.0-
|
|
46
|
-
"@elementor/editor-responsive": "3.33.0-
|
|
47
|
-
"@elementor/editor-ui": "3.33.0-
|
|
48
|
-
"@elementor/editor-v1-adapters": "3.33.0-
|
|
49
|
-
"@elementor/env": "3.33.0-
|
|
50
|
-
"@elementor/http-client": "3.33.0-
|
|
43
|
+
"@elementor/editor-current-user": "3.33.0-288",
|
|
44
|
+
"@elementor/editor-elements": "3.33.0-288",
|
|
45
|
+
"@elementor/editor-props": "3.33.0-288",
|
|
46
|
+
"@elementor/editor-responsive": "3.33.0-288",
|
|
47
|
+
"@elementor/editor-ui": "3.33.0-288",
|
|
48
|
+
"@elementor/editor-v1-adapters": "3.33.0-288",
|
|
49
|
+
"@elementor/env": "3.33.0-288",
|
|
50
|
+
"@elementor/http-client": "3.33.0-288",
|
|
51
51
|
"@elementor/icons": "^1.61.0",
|
|
52
|
-
"@elementor/locations": "3.33.0-
|
|
53
|
-
"@elementor/mixpanel": "3.33.0-
|
|
54
|
-
"@elementor/query": "3.33.0-
|
|
55
|
-
"@elementor/session": "3.33.0-
|
|
52
|
+
"@elementor/locations": "3.33.0-288",
|
|
53
|
+
"@elementor/mixpanel": "3.33.0-288",
|
|
54
|
+
"@elementor/query": "3.33.0-288",
|
|
55
|
+
"@elementor/session": "3.33.0-288",
|
|
56
56
|
"@elementor/ui": "1.36.17",
|
|
57
|
-
"@elementor/utils": "3.33.0-
|
|
58
|
-
"@elementor/wp-media": "3.33.0-
|
|
57
|
+
"@elementor/utils": "3.33.0-288",
|
|
58
|
+
"@elementor/wp-media": "3.33.0-288",
|
|
59
59
|
"@wordpress/i18n": "^5.13.0",
|
|
60
60
|
"@monaco-editor/react": "^4.7.0",
|
|
61
61
|
"dayjs": "^1.11.18",
|
|
@@ -80,123 +80,129 @@ type Props< TValue > = {
|
|
|
80
80
|
onChange: ( value: ExclusiveValue< TValue > ) => void;
|
|
81
81
|
}
|
|
82
82
|
);
|
|
83
|
-
export const ToggleButtonGroupUi =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const theme = useTheme();
|
|
100
|
-
const isRtl = 'rtl' === theme.direction;
|
|
101
|
-
|
|
102
|
-
const handleChange = (
|
|
103
|
-
_: React.MouseEvent< HTMLElement >,
|
|
104
|
-
newValue: typeof exclusive extends true ? ExclusiveValue< TValue > : NonExclusiveValue< TValue >
|
|
83
|
+
export const ToggleButtonGroupUi = React.forwardRef(
|
|
84
|
+
< TValue, >(
|
|
85
|
+
{
|
|
86
|
+
justify = 'end',
|
|
87
|
+
size = 'tiny',
|
|
88
|
+
value,
|
|
89
|
+
onChange,
|
|
90
|
+
items,
|
|
91
|
+
maxItems,
|
|
92
|
+
exclusive = false,
|
|
93
|
+
fullWidth = false,
|
|
94
|
+
disabled,
|
|
95
|
+
placeholder,
|
|
96
|
+
}: Props< TValue >,
|
|
97
|
+
ref: React.Ref< HTMLDivElement >
|
|
105
98
|
) => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
99
|
+
const shouldSliceItems = exclusive && maxItems !== undefined && items.length > maxItems;
|
|
100
|
+
const menuItems = shouldSliceItems ? items.slice( maxItems - 1 ) : [];
|
|
101
|
+
const fixedItems = shouldSliceItems ? items.slice( 0, maxItems - 1 ) : items;
|
|
102
|
+
|
|
103
|
+
const theme = useTheme();
|
|
104
|
+
const isRtl = 'rtl' === theme.direction;
|
|
105
|
+
|
|
106
|
+
const handleChange = (
|
|
107
|
+
_: React.MouseEvent< HTMLElement >,
|
|
108
|
+
newValue: typeof exclusive extends true ? ExclusiveValue< TValue > : NonExclusiveValue< TValue >
|
|
109
|
+
) => {
|
|
110
|
+
onChange( newValue as never );
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const getGridTemplateColumns = useMemo( () => {
|
|
114
|
+
const isOffLimits = menuItems?.length;
|
|
115
|
+
const itemsCount = isOffLimits ? fixedItems.length + 1 : fixedItems.length;
|
|
116
|
+
const templateColumnsSuffix = isOffLimits ? 'auto' : '';
|
|
117
|
+
return `repeat(${ itemsCount }, minmax(0, 25%)) ${ templateColumnsSuffix }`;
|
|
118
|
+
}, [ menuItems?.length, fixedItems.length ] );
|
|
119
|
+
|
|
120
|
+
const shouldShowExclusivePlaceholder = exclusive && ( value === null || value === undefined || value === '' );
|
|
121
|
+
|
|
122
|
+
const nonExclusiveSelectedValues =
|
|
123
|
+
! exclusive && Array.isArray( value )
|
|
124
|
+
? value
|
|
125
|
+
.map( ( v ) => ( typeof v === 'string' ? v : '' ) )
|
|
126
|
+
.join( ' ' )
|
|
127
|
+
.trim()
|
|
128
|
+
.split( /\s+/ )
|
|
129
|
+
.filter( Boolean )
|
|
130
|
+
: [];
|
|
131
|
+
|
|
132
|
+
const shouldShowNonExclusivePlaceholder = ! exclusive && nonExclusiveSelectedValues.length === 0;
|
|
133
|
+
|
|
134
|
+
const getPlaceholderArray = ( placeholderValue: TValue | TValue[] | undefined ): string[] => {
|
|
135
|
+
if ( Array.isArray( placeholderValue ) ) {
|
|
136
|
+
return placeholderValue.flatMap( ( p ) => {
|
|
137
|
+
if ( typeof p === 'string' ) {
|
|
138
|
+
return p.trim().split( /\s+/ ).filter( Boolean );
|
|
139
|
+
}
|
|
140
|
+
return [];
|
|
141
|
+
} );
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if ( typeof placeholderValue === 'string' ) {
|
|
145
|
+
return placeholderValue.trim().split( /\s+/ ).filter( Boolean );
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return [];
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const placeholderArray = getPlaceholderArray( placeholder );
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<StyledToggleButtonGroup
|
|
155
|
+
ref={ ref }
|
|
156
|
+
justify={ justify }
|
|
157
|
+
value={ value }
|
|
158
|
+
onChange={ handleChange }
|
|
159
|
+
exclusive={ exclusive }
|
|
160
|
+
disabled={ disabled }
|
|
161
|
+
sx={ {
|
|
162
|
+
direction: isRtl ? 'rtl /* @noflip */' : 'ltr /* @noflip */',
|
|
163
|
+
display: 'grid',
|
|
164
|
+
gridTemplateColumns: getGridTemplateColumns,
|
|
165
|
+
width: `100%`,
|
|
166
|
+
} }
|
|
167
|
+
>
|
|
168
|
+
{ fixedItems.map( ( { label, value: buttonValue, renderContent: Content, showTooltip } ) => {
|
|
169
|
+
const isPlaceholder =
|
|
170
|
+
placeholderArray.length > 0 &&
|
|
171
|
+
placeholderArray.includes( buttonValue as string ) &&
|
|
172
|
+
( shouldShowExclusivePlaceholder || shouldShowNonExclusivePlaceholder );
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
<ConditionalTooltip
|
|
176
|
+
key={ buttonValue as string }
|
|
177
|
+
label={ label }
|
|
178
|
+
showTooltip={ showTooltip || false }
|
|
181
179
|
>
|
|
182
|
-
<
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
180
|
+
<StyledToggleButton
|
|
181
|
+
value={ buttonValue }
|
|
182
|
+
aria-label={ label }
|
|
183
|
+
size={ size }
|
|
184
|
+
fullWidth={ fullWidth }
|
|
185
|
+
isPlaceholder={ isPlaceholder }
|
|
186
|
+
>
|
|
187
|
+
<Content size={ size } />
|
|
188
|
+
</StyledToggleButton>
|
|
189
|
+
</ConditionalTooltip>
|
|
190
|
+
);
|
|
191
|
+
} ) }
|
|
192
|
+
|
|
193
|
+
{ menuItems.length && exclusive && (
|
|
194
|
+
<SplitButtonGroup
|
|
195
|
+
size={ size }
|
|
196
|
+
value={ ( value as ExclusiveValue< TValue > ) || null }
|
|
197
|
+
onChange={ onChange as ( v: ExclusiveValue< TValue > ) => void }
|
|
198
|
+
items={ menuItems }
|
|
199
|
+
fullWidth={ fullWidth }
|
|
200
|
+
/>
|
|
201
|
+
) }
|
|
202
|
+
</StyledToggleButtonGroup>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
) as < TValue >( props: Props< TValue > & { ref?: React.Ref< HTMLDivElement > } ) => React.ReactElement;
|
|
200
206
|
|
|
201
207
|
export const ControlToggleButtonGroup = < TValue, >( props: Props< TValue > ) => {
|
|
202
208
|
return (
|
|
@@ -252,7 +258,6 @@ const SplitButtonGroup = < TValue, >( {
|
|
|
252
258
|
ev.preventDefault();
|
|
253
259
|
onMenuItemClick( previewButton.value );
|
|
254
260
|
} }
|
|
255
|
-
ref={ menuButtonRef }
|
|
256
261
|
>
|
|
257
262
|
{ previewButton.renderContent( { size } ) }
|
|
258
263
|
</ToggleButton>
|