@elementor/editor-controls 0.2.0 → 0.3.0
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/CHANGELOG.md +12 -0
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +62 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/controls/gap-control.tsx +88 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { gapPropTypeUtil, type PropValue } from '@elementor/editor-props';
|
|
3
|
+
import { DetachIcon, LinkIcon } from '@elementor/icons';
|
|
4
|
+
import { Grid, Stack, ToggleButton } from '@elementor/ui';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
|
|
7
|
+
import { BoundPropProvider, useBoundProp } from '../bound-prop-context';
|
|
8
|
+
import { ControlLabel } from '../components/control-label';
|
|
9
|
+
import { createControl } from '../create-control';
|
|
10
|
+
import { SizeControl } from './size-control';
|
|
11
|
+
|
|
12
|
+
export type Gap = 'row' | 'column';
|
|
13
|
+
|
|
14
|
+
export const GapControl = createControl( ( { label }: { label: string } ) => {
|
|
15
|
+
const { value, setValue } = useBoundProp( gapPropTypeUtil );
|
|
16
|
+
const { column, row, isLinked = true } = value || {};
|
|
17
|
+
|
|
18
|
+
const setLinkedValue = ( gap: Gap, newValue: PropValue ) => {
|
|
19
|
+
const updatedValue = {
|
|
20
|
+
isLinked,
|
|
21
|
+
column: isLinked ? newValue : column,
|
|
22
|
+
row: isLinked ? newValue : row,
|
|
23
|
+
[ gap ]: newValue,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
setValue( updatedValue );
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const toggleLinked = () => {
|
|
30
|
+
const updatedValue = {
|
|
31
|
+
isLinked: ! isLinked,
|
|
32
|
+
column,
|
|
33
|
+
row: ! isLinked ? column : row,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
setValue( updatedValue );
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const LinkedIcon = isLinked ? LinkIcon : DetachIcon;
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<>
|
|
43
|
+
<Stack direction="row" gap={ 2 } flexWrap="nowrap">
|
|
44
|
+
<ControlLabel>{ label }</ControlLabel>
|
|
45
|
+
<ToggleButton
|
|
46
|
+
aria-label={ __( 'Link Inputs', 'elementor' ) }
|
|
47
|
+
size={ 'tiny' }
|
|
48
|
+
value={ 'check' }
|
|
49
|
+
selected={ isLinked }
|
|
50
|
+
sx={ { marginLeft: 'auto' } }
|
|
51
|
+
onChange={ toggleLinked }
|
|
52
|
+
>
|
|
53
|
+
<LinkedIcon fontSize={ 'tiny' } />
|
|
54
|
+
</ToggleButton>
|
|
55
|
+
</Stack>
|
|
56
|
+
<Stack direction="row" gap={ 2 } flexWrap="nowrap">
|
|
57
|
+
<Grid container gap={ 1 } alignItems="center">
|
|
58
|
+
<Grid item xs={ 12 }>
|
|
59
|
+
<ControlLabel>{ __( 'Column', 'elementor' ) }</ControlLabel>
|
|
60
|
+
</Grid>
|
|
61
|
+
<Grid item xs={ 12 }>
|
|
62
|
+
<BoundPropProvider
|
|
63
|
+
setValue={ ( newValue ) => setLinkedValue( 'column', newValue ) }
|
|
64
|
+
value={ column }
|
|
65
|
+
bind="column"
|
|
66
|
+
>
|
|
67
|
+
<SizeControl />
|
|
68
|
+
</BoundPropProvider>
|
|
69
|
+
</Grid>
|
|
70
|
+
</Grid>
|
|
71
|
+
<Grid container gap={ 1 } alignItems="center">
|
|
72
|
+
<Grid item xs={ 12 }>
|
|
73
|
+
<ControlLabel>{ __( 'Row', 'elementor' ) }</ControlLabel>
|
|
74
|
+
</Grid>
|
|
75
|
+
<Grid item xs={ 12 }>
|
|
76
|
+
<BoundPropProvider
|
|
77
|
+
setValue={ ( newValue ) => setLinkedValue( 'row', newValue ) }
|
|
78
|
+
value={ row }
|
|
79
|
+
bind="row"
|
|
80
|
+
>
|
|
81
|
+
<SizeControl />
|
|
82
|
+
</BoundPropProvider>
|
|
83
|
+
</Grid>
|
|
84
|
+
</Grid>
|
|
85
|
+
</Stack>
|
|
86
|
+
</>
|
|
87
|
+
);
|
|
88
|
+
} );
|
package/src/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ export { LinkedDimensionsControl } from './controls/linked-dimensions-control';
|
|
|
15
15
|
export { FontFamilyControl } from './controls/font-family-control';
|
|
16
16
|
export { UrlControl } from './controls/url-control';
|
|
17
17
|
export { LinkControl } from './controls/link-control';
|
|
18
|
+
export { GapControl } from './controls/gap-control';
|
|
18
19
|
|
|
19
20
|
// components
|
|
20
21
|
export { ControlLabel } from './components/control-label';
|