@elementor/editor-variables 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.js +740 -706
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +655 -633
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/ui/variable-promotion-chip.tsx +63 -0
- package/src/components/variables-manager/ui/variable-edit-menu.tsx +14 -3
- package/src/components/variables-manager/ui/variable-table-row.tsx +210 -0
- package/src/components/variables-manager/variable-editable-cell.tsx +12 -4
- package/src/components/variables-manager/variables-manager-create-menu.tsx +11 -38
- package/src/components/variables-manager/variables-manager-panel.tsx +31 -3
- package/src/components/variables-manager/variables-manager-table.tsx +17 -188
- package/src/hooks/use-quota-permissions.ts +2 -2
- package/src/components/ui/stop-sync-confirmation-dialog.tsx +0 -77
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { EllipsisWithTooltip } from '@elementor/editor-ui';
|
|
4
|
-
import { GripVerticalIcon } from '@elementor/icons';
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
5
3
|
import {
|
|
6
|
-
IconButton,
|
|
7
|
-
Stack,
|
|
8
4
|
type SxProps,
|
|
9
5
|
Table,
|
|
10
6
|
TableBody,
|
|
@@ -19,10 +15,9 @@ import { __ } from '@wordpress/i18n';
|
|
|
19
15
|
|
|
20
16
|
import { type TVariablesList } from '../../storage';
|
|
21
17
|
import { getVariableType } from '../../variables-registry/variable-type-registry';
|
|
22
|
-
import {
|
|
23
|
-
import { VariableEditMenu, type VariableManagerMenuAction } from './ui/variable-edit-menu';
|
|
18
|
+
import { type VariableManagerMenuAction } from './ui/variable-edit-menu';
|
|
24
19
|
import { VariableTableCell } from './ui/variable-table-cell';
|
|
25
|
-
import {
|
|
20
|
+
import { type Row, VariableRow } from './ui/variable-table-row';
|
|
26
21
|
|
|
27
22
|
type Props = {
|
|
28
23
|
menuActions: ( variableId: string ) => VariableManagerMenuAction[];
|
|
@@ -33,13 +28,6 @@ type Props = {
|
|
|
33
28
|
onFieldError?: ( hasError: boolean ) => void;
|
|
34
29
|
};
|
|
35
30
|
|
|
36
|
-
type Row = ReturnType< typeof getVariableType > & {
|
|
37
|
-
id: string;
|
|
38
|
-
type: string;
|
|
39
|
-
name: string;
|
|
40
|
-
value: string;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
31
|
export const VariablesManagerTable = ( {
|
|
44
32
|
menuActions,
|
|
45
33
|
variables,
|
|
@@ -142,179 +130,19 @@ export const VariablesManagerTable = ( {
|
|
|
142
130
|
<UnstableSortableItem
|
|
143
131
|
key={ row.id }
|
|
144
132
|
id={ row.id }
|
|
145
|
-
render={ (
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return (
|
|
160
|
-
<TableRow
|
|
161
|
-
{ ...itemProps }
|
|
162
|
-
ref={ itemProps.ref }
|
|
163
|
-
selected={ isDragged }
|
|
164
|
-
sx={ {
|
|
165
|
-
...( showIndicationBefore && {
|
|
166
|
-
'& td, & th': {
|
|
167
|
-
borderTop: '2px solid',
|
|
168
|
-
borderTopColor: 'primary.main',
|
|
169
|
-
},
|
|
170
|
-
} ),
|
|
171
|
-
...( showIndicationAfter && {
|
|
172
|
-
'& td, & th': {
|
|
173
|
-
borderBottom: '2px solid',
|
|
174
|
-
borderBottomColor: 'primary.main',
|
|
175
|
-
},
|
|
176
|
-
} ),
|
|
177
|
-
'& [role="toolbar"], & [draggable]': {
|
|
178
|
-
opacity: 0,
|
|
179
|
-
},
|
|
180
|
-
'&:hover, &:focus-within': {
|
|
181
|
-
backgroundColor: 'action.hover',
|
|
182
|
-
'& [role="toolbar"], & [draggable]': {
|
|
183
|
-
opacity: 1,
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
} }
|
|
187
|
-
style={ { ...itemStyle, ...triggerStyle } }
|
|
188
|
-
>
|
|
189
|
-
<VariableTableCell noPadding width={ 10 } maxWidth={ 10 }>
|
|
190
|
-
<IconButton
|
|
191
|
-
size="small"
|
|
192
|
-
ref={ setTriggerRef }
|
|
193
|
-
{ ...triggerProps }
|
|
194
|
-
disabled={ isSorting }
|
|
195
|
-
draggable
|
|
196
|
-
>
|
|
197
|
-
<GripVerticalIcon fontSize="inherit" />
|
|
198
|
-
</IconButton>
|
|
199
|
-
</VariableTableCell>
|
|
200
|
-
<VariableTableCell>
|
|
201
|
-
<VariableEditableCell
|
|
202
|
-
initialValue={ row.name }
|
|
203
|
-
onChange={ ( value ) => {
|
|
204
|
-
if ( value !== row.name ) {
|
|
205
|
-
handleOnChange( {
|
|
206
|
-
...variables,
|
|
207
|
-
[ row.id ]: { ...variables[ row.id ], label: value },
|
|
208
|
-
} );
|
|
209
|
-
}
|
|
210
|
-
} }
|
|
211
|
-
prefixElement={ createElement( row.icon, { fontSize: 'inherit' } ) }
|
|
212
|
-
editableElement={ ( {
|
|
213
|
-
value,
|
|
214
|
-
onChange,
|
|
215
|
-
onValidationChange,
|
|
216
|
-
error,
|
|
217
|
-
} ) => (
|
|
218
|
-
<LabelField
|
|
219
|
-
id={ 'variable-label-' + row.id }
|
|
220
|
-
size="tiny"
|
|
221
|
-
value={ value }
|
|
222
|
-
onChange={ onChange }
|
|
223
|
-
onErrorChange={ ( errorMsg ) => {
|
|
224
|
-
onValidationChange?.( errorMsg );
|
|
225
|
-
onFieldError?.( !! errorMsg );
|
|
226
|
-
} }
|
|
227
|
-
error={ error }
|
|
228
|
-
focusOnShow
|
|
229
|
-
selectOnShow={ autoEditVariableId === row.id }
|
|
230
|
-
showWarningInfotip={ true }
|
|
231
|
-
variables={ variables }
|
|
232
|
-
/>
|
|
233
|
-
) }
|
|
234
|
-
autoEdit={ autoEditVariableId === row.id }
|
|
235
|
-
onRowRef={ handleRowRef( row.id ) }
|
|
236
|
-
onAutoEditComplete={
|
|
237
|
-
autoEditVariableId === row.id ? onAutoEditComplete : undefined
|
|
238
|
-
}
|
|
239
|
-
fieldType="label"
|
|
240
|
-
>
|
|
241
|
-
<EllipsisWithTooltip
|
|
242
|
-
title={ row.name }
|
|
243
|
-
sx={ { border: '4px solid transparent' } }
|
|
244
|
-
>
|
|
245
|
-
{ row.name }
|
|
246
|
-
</EllipsisWithTooltip>
|
|
247
|
-
</VariableEditableCell>
|
|
248
|
-
</VariableTableCell>
|
|
249
|
-
<VariableTableCell>
|
|
250
|
-
<VariableEditableCell
|
|
251
|
-
initialValue={ row.value }
|
|
252
|
-
onChange={ ( value ) => {
|
|
253
|
-
if ( value !== row.value ) {
|
|
254
|
-
handleOnChange( {
|
|
255
|
-
...variables,
|
|
256
|
-
[ row.id ]: { ...variables[ row.id ], value },
|
|
257
|
-
} );
|
|
258
|
-
}
|
|
259
|
-
} }
|
|
260
|
-
editableElement={ ( {
|
|
261
|
-
value,
|
|
262
|
-
onChange,
|
|
263
|
-
onValidationChange,
|
|
264
|
-
error,
|
|
265
|
-
} ) =>
|
|
266
|
-
row.valueField?.( {
|
|
267
|
-
value,
|
|
268
|
-
onChange,
|
|
269
|
-
onPropTypeKeyChange: ( type ) => {
|
|
270
|
-
handleOnChange( {
|
|
271
|
-
...variables,
|
|
272
|
-
[ row.id ]: { ...variables[ row.id ], type },
|
|
273
|
-
} );
|
|
274
|
-
},
|
|
275
|
-
propTypeKey: row.type,
|
|
276
|
-
onValidationChange: ( errorMsg ) => {
|
|
277
|
-
onValidationChange?.( errorMsg );
|
|
278
|
-
onFieldError?.( !! errorMsg );
|
|
279
|
-
},
|
|
280
|
-
error,
|
|
281
|
-
} ) ?? <></>
|
|
282
|
-
}
|
|
283
|
-
onRowRef={ handleRowRef( row.id ) }
|
|
284
|
-
gap={ 0.25 }
|
|
285
|
-
fieldType="value"
|
|
286
|
-
>
|
|
287
|
-
{ row.startIcon && row.startIcon( { value: row.value } ) }
|
|
288
|
-
<EllipsisWithTooltip
|
|
289
|
-
title={ row.value }
|
|
290
|
-
sx={ {
|
|
291
|
-
border: '4px solid transparent',
|
|
292
|
-
lineHeight: '1',
|
|
293
|
-
pt: 0.25,
|
|
294
|
-
} }
|
|
295
|
-
>
|
|
296
|
-
{ row.value }
|
|
297
|
-
</EllipsisWithTooltip>
|
|
298
|
-
</VariableEditableCell>
|
|
299
|
-
</VariableTableCell>
|
|
300
|
-
<VariableTableCell
|
|
301
|
-
align="right"
|
|
302
|
-
noPadding
|
|
303
|
-
width={ 16 }
|
|
304
|
-
maxWidth={ 16 }
|
|
305
|
-
sx={ { paddingInlineEnd: 1 } }
|
|
306
|
-
>
|
|
307
|
-
<Stack role="toolbar" direction="row" justifyContent="flex-end">
|
|
308
|
-
<VariableEditMenu
|
|
309
|
-
menuActions={ menuActions( row.id ) }
|
|
310
|
-
disabled={ isSorting }
|
|
311
|
-
itemId={ row.id }
|
|
312
|
-
/>
|
|
313
|
-
</Stack>
|
|
314
|
-
</VariableTableCell>
|
|
315
|
-
</TableRow>
|
|
316
|
-
);
|
|
317
|
-
} }
|
|
133
|
+
render={ ( props: UnstableSortableItemRenderProps ) => (
|
|
134
|
+
<VariableRow
|
|
135
|
+
{ ...props }
|
|
136
|
+
row={ row }
|
|
137
|
+
variables={ variables }
|
|
138
|
+
handleOnChange={ handleOnChange }
|
|
139
|
+
autoEditVariableId={ autoEditVariableId }
|
|
140
|
+
onAutoEditComplete={ onAutoEditComplete }
|
|
141
|
+
onFieldError={ onFieldError }
|
|
142
|
+
menuActions={ menuActions }
|
|
143
|
+
handleRowRef={ handleRowRef }
|
|
144
|
+
/>
|
|
145
|
+
) }
|
|
318
146
|
/>
|
|
319
147
|
) ) }
|
|
320
148
|
</UnstableSortableProvider>
|
|
@@ -323,6 +151,7 @@ export const VariablesManagerTable = ( {
|
|
|
323
151
|
</TableContainer>
|
|
324
152
|
);
|
|
325
153
|
};
|
|
154
|
+
|
|
326
155
|
function sortVariablesOrder( variables: TVariablesList ): ( a: string, b: string ) => number {
|
|
327
156
|
return ( a, b ) => {
|
|
328
157
|
const orderA = variables[ a ]?.order ?? Number.MAX_SAFE_INTEGER;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const useQuotaPermissions = ( variableType: string ) => {
|
|
2
2
|
const quotaConfig = {
|
|
3
|
-
...( window.ElementorVariablesQuotaConfig
|
|
4
|
-
...( window.ElementorVariablesQuotaConfigExtended
|
|
3
|
+
...( window.ElementorVariablesQuotaConfig ?? {} ),
|
|
4
|
+
...( window.ElementorVariablesQuotaConfigExtended ?? {} ),
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// BC: Remove when 4.01 is released
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import { BrushIcon } from '@elementor/icons';
|
|
4
|
-
import {
|
|
5
|
-
Button,
|
|
6
|
-
Checkbox,
|
|
7
|
-
Dialog,
|
|
8
|
-
DialogActions,
|
|
9
|
-
DialogContent,
|
|
10
|
-
DialogContentText,
|
|
11
|
-
DialogTitle,
|
|
12
|
-
FormControlLabel,
|
|
13
|
-
Typography,
|
|
14
|
-
} from '@elementor/ui';
|
|
15
|
-
import { __ } from '@wordpress/i18n';
|
|
16
|
-
|
|
17
|
-
type StopSyncConfirmationDialogProps = {
|
|
18
|
-
open: boolean;
|
|
19
|
-
closeDialog: () => void;
|
|
20
|
-
onConfirm: () => void;
|
|
21
|
-
onSuppressMessage?: () => void;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const StopSyncConfirmationDialog = ( {
|
|
25
|
-
open,
|
|
26
|
-
closeDialog,
|
|
27
|
-
onConfirm,
|
|
28
|
-
onSuppressMessage,
|
|
29
|
-
}: StopSyncConfirmationDialogProps ) => {
|
|
30
|
-
const [ dontShowAgain, setDontShowAgain ] = useState( false );
|
|
31
|
-
|
|
32
|
-
const handleConfirm = () => {
|
|
33
|
-
if ( dontShowAgain ) {
|
|
34
|
-
onSuppressMessage?.();
|
|
35
|
-
}
|
|
36
|
-
onConfirm();
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<Dialog open={ open } onClose={ closeDialog } maxWidth="xs">
|
|
41
|
-
<DialogTitle display="flex" alignItems="center" gap={ 1 }>
|
|
42
|
-
<BrushIcon color="secondary" />
|
|
43
|
-
{ __( 'Stop syncing variable color', 'elementor' ) }
|
|
44
|
-
</DialogTitle>
|
|
45
|
-
<DialogContent>
|
|
46
|
-
<DialogContentText variant="body2" color="textPrimary">
|
|
47
|
-
{ __(
|
|
48
|
-
'This will disconnect the variable color from version 3. Existing uses on your site will automatically switch to a default color.',
|
|
49
|
-
'elementor'
|
|
50
|
-
) }
|
|
51
|
-
</DialogContentText>
|
|
52
|
-
</DialogContent>
|
|
53
|
-
<DialogActions sx={ { justifyContent: 'space-between', alignItems: 'center' } }>
|
|
54
|
-
<FormControlLabel
|
|
55
|
-
control={
|
|
56
|
-
<Checkbox
|
|
57
|
-
checked={ dontShowAgain }
|
|
58
|
-
onChange={ ( event: React.ChangeEvent< HTMLInputElement > ) =>
|
|
59
|
-
setDontShowAgain( event.target.checked )
|
|
60
|
-
}
|
|
61
|
-
size="small"
|
|
62
|
-
/>
|
|
63
|
-
}
|
|
64
|
-
label={ <Typography variant="body2">{ __( "Don't show this again", 'elementor' ) }</Typography> }
|
|
65
|
-
/>
|
|
66
|
-
<div>
|
|
67
|
-
<Button color="secondary" onClick={ closeDialog }>
|
|
68
|
-
{ __( 'Cancel', 'elementor' ) }
|
|
69
|
-
</Button>
|
|
70
|
-
<Button variant="contained" color="secondary" onClick={ handleConfirm } sx={ { ml: 1 } }>
|
|
71
|
-
{ __( 'Got it', 'elementor' ) }
|
|
72
|
-
</Button>
|
|
73
|
-
</div>
|
|
74
|
-
</DialogActions>
|
|
75
|
-
</Dialog>
|
|
76
|
-
);
|
|
77
|
-
};
|