@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/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-286",
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-286",
44
- "@elementor/editor-elements": "3.33.0-286",
45
- "@elementor/editor-props": "3.33.0-286",
46
- "@elementor/editor-responsive": "3.33.0-286",
47
- "@elementor/editor-ui": "3.33.0-286",
48
- "@elementor/editor-v1-adapters": "3.33.0-286",
49
- "@elementor/env": "3.33.0-286",
50
- "@elementor/http-client": "3.33.0-286",
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-286",
53
- "@elementor/mixpanel": "3.33.0-286",
54
- "@elementor/query": "3.33.0-286",
55
- "@elementor/session": "3.33.0-286",
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-286",
58
- "@elementor/wp-media": "3.33.0-286",
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 = < TValue, >( {
84
- justify = 'end',
85
- size = 'tiny',
86
- value,
87
- onChange,
88
- items,
89
- maxItems,
90
- exclusive = false,
91
- fullWidth = false,
92
- disabled,
93
- placeholder,
94
- }: Props< TValue > ) => {
95
- const shouldSliceItems = exclusive && maxItems !== undefined && items.length > maxItems;
96
- const menuItems = shouldSliceItems ? items.slice( maxItems - 1 ) : [];
97
- const fixedItems = shouldSliceItems ? items.slice( 0, maxItems - 1 ) : items;
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
- onChange( newValue as never );
107
- };
108
-
109
- const getGridTemplateColumns = useMemo( () => {
110
- const isOffLimits = menuItems?.length;
111
- const itemsCount = isOffLimits ? fixedItems.length + 1 : fixedItems.length;
112
- const templateColumnsSuffix = isOffLimits ? 'auto' : '';
113
- return `repeat(${ itemsCount }, minmax(0, 25%)) ${ templateColumnsSuffix }`;
114
- }, [ menuItems?.length, fixedItems.length ] );
115
-
116
- const shouldShowExclusivePlaceholder = exclusive && ( value === null || value === undefined || value === '' );
117
-
118
- const nonExclusiveSelectedValues =
119
- ! exclusive && Array.isArray( value )
120
- ? value
121
- .map( ( v ) => ( typeof v === 'string' ? v : '' ) )
122
- .join( ' ' )
123
- .trim()
124
- .split( /\s+/ )
125
- .filter( Boolean )
126
- : [];
127
-
128
- const shouldShowNonExclusivePlaceholder = ! exclusive && nonExclusiveSelectedValues.length === 0;
129
-
130
- const getPlaceholderArray = ( placeholderValue: TValue | TValue[] | undefined ): string[] => {
131
- if ( Array.isArray( placeholderValue ) ) {
132
- return placeholderValue.flatMap( ( p ) => {
133
- if ( typeof p === 'string' ) {
134
- return p.trim().split( /\s+/ ).filter( Boolean );
135
- }
136
- return [];
137
- } );
138
- }
139
-
140
- if ( typeof placeholderValue === 'string' ) {
141
- return placeholderValue.trim().split( /\s+/ ).filter( Boolean );
142
- }
143
-
144
- return [];
145
- };
146
-
147
- const placeholderArray = getPlaceholderArray( placeholder );
148
-
149
- return (
150
- <StyledToggleButtonGroup
151
- justify={ justify }
152
- value={ value }
153
- onChange={ handleChange }
154
- exclusive={ exclusive }
155
- disabled={ disabled }
156
- sx={ {
157
- direction: isRtl ? 'rtl /* @noflip */' : 'ltr /* @noflip */',
158
- display: 'grid',
159
- gridTemplateColumns: getGridTemplateColumns,
160
- width: `100%`,
161
- } }
162
- >
163
- { fixedItems.map( ( { label, value: buttonValue, renderContent: Content, showTooltip } ) => {
164
- const isPlaceholder =
165
- placeholderArray.length > 0 &&
166
- placeholderArray.includes( buttonValue as string ) &&
167
- ( shouldShowExclusivePlaceholder || shouldShowNonExclusivePlaceholder );
168
-
169
- return (
170
- <ConditionalTooltip
171
- key={ buttonValue as string }
172
- label={ label }
173
- showTooltip={ showTooltip || false }
174
- >
175
- <StyledToggleButton
176
- value={ buttonValue }
177
- aria-label={ label }
178
- size={ size }
179
- fullWidth={ fullWidth }
180
- isPlaceholder={ isPlaceholder }
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
- <Content size={ size } />
183
- </StyledToggleButton>
184
- </ConditionalTooltip>
185
- );
186
- } ) }
187
-
188
- { menuItems.length && exclusive && (
189
- <SplitButtonGroup
190
- size={ size }
191
- value={ ( value as ExclusiveValue< TValue > ) || null }
192
- onChange={ onChange as ( v: ExclusiveValue< TValue > ) => void }
193
- items={ menuItems }
194
- fullWidth={ fullWidth }
195
- />
196
- ) }
197
- </StyledToggleButtonGroup>
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>