@elementor/editor-variables 0.16.0 → 3.32.0-20
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 +22 -0
- package/dist/index.d.mts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +1397 -885
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1399 -871
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -14
- package/src/api.ts +18 -2
- package/src/components/fields/color-field.tsx +3 -3
- package/src/components/fields/font-field.tsx +21 -10
- package/src/components/fields/label-field.tsx +31 -5
- package/src/components/ui/delete-confirmation-dialog.tsx +4 -7
- package/src/components/ui/deleted-variable-alert.tsx +47 -0
- package/src/components/ui/edit-confirmation-dialog.tsx +75 -0
- package/src/components/ui/missing-variable-alert.tsx +39 -0
- package/src/components/ui/no-variables.tsx +59 -26
- package/src/components/ui/tags/assigned-tag.tsx +21 -19
- package/src/components/ui/tags/deleted-tag.tsx +29 -18
- package/src/components/ui/tags/missing-tag.tsx +25 -0
- package/src/components/ui/variable/assigned-variable.tsx +11 -14
- package/src/components/ui/variable/deleted-variable.tsx +115 -7
- package/src/components/ui/variable/missing-variable.tsx +44 -0
- package/src/components/variable-creation.tsx +135 -0
- package/src/components/variable-edit.tsx +221 -0
- package/src/components/variable-restore.tsx +117 -0
- package/src/components/variable-selection-popover.tsx +91 -92
- package/src/components/variables-manager/variables-manager-panel.tsx +115 -0
- package/src/components/variables-selection.tsx +148 -0
- package/src/context/variable-selection-popover.context.tsx +19 -0
- package/src/context/variable-type-context.tsx +23 -0
- package/src/controls/variable-control.tsx +26 -0
- package/src/create-style-variables-repository.ts +44 -5
- package/src/hooks/use-initial-value.ts +22 -0
- package/src/hooks/use-permissions.ts +15 -0
- package/src/hooks/use-prop-variable-action.tsx +53 -0
- package/src/hooks/use-prop-variables.ts +6 -0
- package/src/index.ts +1 -0
- package/src/init.ts +33 -4
- package/src/register-variable-types.tsx +29 -0
- package/src/renderers/style-variables-renderer.tsx +10 -4
- package/src/repeater-injections.ts +5 -1
- package/src/service.ts +8 -4
- package/src/sync/enqueue-font.ts +7 -0
- package/src/sync/types.ts +5 -0
- package/src/transformers/inheritance-transformer.tsx +30 -0
- package/src/transformers/utils/resolve-css-variable.ts +24 -0
- package/src/transformers/variable-transformer.ts +8 -3
- package/src/types.ts +1 -1
- package/src/utils/tracking.ts +39 -0
- package/src/utils/validations.ts +40 -6
- package/src/variables-registry/create-variable-type-registry.ts +77 -0
- package/src/variables-registry/variable-type-registry.ts +3 -0
- package/src/components/color-variable-creation.tsx +0 -86
- package/src/components/color-variable-edit.tsx +0 -138
- package/src/components/color-variables-selection.tsx +0 -130
- package/src/components/font-variable-creation.tsx +0 -86
- package/src/components/font-variable-edit.tsx +0 -138
- package/src/components/font-variables-selection.tsx +0 -129
- package/src/components/variable-selection-popover.context.ts +0 -7
- package/src/controls/color-variable-control.tsx +0 -33
- package/src/controls/font-variable-control.tsx +0 -31
- package/src/hooks/use-prop-color-variable-action.tsx +0 -25
- package/src/hooks/use-prop-font-variable-action.tsx +0 -25
- package/src/init-color-variables.ts +0 -27
- package/src/init-font-variables.ts +0 -24
- package/src/utils.ts +0 -20
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useBoundProp } from '@elementor/editor-controls';
|
|
3
|
-
import { colorPropTypeUtil } from '@elementor/editor-props';
|
|
4
|
-
|
|
5
|
-
import { ColorIndicator } from '../components/ui/color-indicator';
|
|
6
|
-
import { AssignedVariable } from '../components/ui/variable/assigned-variable';
|
|
7
|
-
import { DeletedVariable } from '../components/ui/variable/deleted-variable';
|
|
8
|
-
import { useVariable } from '../hooks/use-prop-variables';
|
|
9
|
-
import { colorVariablePropTypeUtil } from '../prop-types/color-variable-prop-type';
|
|
10
|
-
|
|
11
|
-
export const ColorVariableControl = () => {
|
|
12
|
-
const { value: variableValue } = useBoundProp( colorVariablePropTypeUtil );
|
|
13
|
-
const assignedVariable = useVariable( variableValue );
|
|
14
|
-
|
|
15
|
-
if ( ! assignedVariable ) {
|
|
16
|
-
throw new Error( `Global color variable ${ variableValue } not found` );
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const isVariableDeleted = assignedVariable?.deleted;
|
|
20
|
-
|
|
21
|
-
if ( isVariableDeleted ) {
|
|
22
|
-
return <DeletedVariable variable={ assignedVariable } />;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<AssignedVariable
|
|
27
|
-
variable={ assignedVariable }
|
|
28
|
-
variablePropTypeUtil={ colorVariablePropTypeUtil }
|
|
29
|
-
fallbackPropTypeUtil={ colorPropTypeUtil }
|
|
30
|
-
additionalStartIcon={ <ColorIndicator size="inherit" value={ assignedVariable.value } component="span" /> }
|
|
31
|
-
/>
|
|
32
|
-
);
|
|
33
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useBoundProp } from '@elementor/editor-controls';
|
|
3
|
-
import { stringPropTypeUtil } from '@elementor/editor-props';
|
|
4
|
-
|
|
5
|
-
import { AssignedVariable } from '../components/ui/variable/assigned-variable';
|
|
6
|
-
import { DeletedVariable } from '../components/ui/variable/deleted-variable';
|
|
7
|
-
import { useVariable } from '../hooks/use-prop-variables';
|
|
8
|
-
import { fontVariablePropTypeUtil } from '../prop-types/font-variable-prop-type';
|
|
9
|
-
|
|
10
|
-
export const FontVariableControl = () => {
|
|
11
|
-
const { value: variableValue } = useBoundProp( fontVariablePropTypeUtil );
|
|
12
|
-
const assignedVariable = useVariable( variableValue );
|
|
13
|
-
|
|
14
|
-
if ( ! assignedVariable ) {
|
|
15
|
-
throw new Error( `Global font variable ${ variableValue } not found` );
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const isVariableDeleted = assignedVariable?.deleted;
|
|
19
|
-
|
|
20
|
-
if ( isVariableDeleted ) {
|
|
21
|
-
return <DeletedVariable variable={ assignedVariable } />;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<AssignedVariable
|
|
26
|
-
variable={ assignedVariable }
|
|
27
|
-
variablePropTypeUtil={ fontVariablePropTypeUtil }
|
|
28
|
-
fallbackPropTypeUtil={ stringPropTypeUtil }
|
|
29
|
-
/>
|
|
30
|
-
);
|
|
31
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { type PopoverActionProps, useBoundProp } from '@elementor/editor-editing-panel';
|
|
3
|
-
import { ColorFilterIcon } from '@elementor/icons';
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
5
|
-
|
|
6
|
-
import { VariableSelectionPopover } from '../components/variable-selection-popover';
|
|
7
|
-
import { colorVariablePropTypeUtil } from '../prop-types/color-variable-prop-type';
|
|
8
|
-
import { supportsColorVariables } from '../utils';
|
|
9
|
-
|
|
10
|
-
export const usePropColorVariableAction = (): PopoverActionProps => {
|
|
11
|
-
const { propType } = useBoundProp();
|
|
12
|
-
|
|
13
|
-
const visible = !! propType && supportsColorVariables( propType );
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
visible,
|
|
17
|
-
icon: ColorFilterIcon,
|
|
18
|
-
title: __( 'Variables', 'elementor' ),
|
|
19
|
-
content: ( { close: closePopover } ) => {
|
|
20
|
-
return (
|
|
21
|
-
<VariableSelectionPopover closePopover={ closePopover } propTypeKey={ colorVariablePropTypeUtil.key } />
|
|
22
|
-
);
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { type PopoverActionProps, useBoundProp } from '@elementor/editor-editing-panel';
|
|
3
|
-
import { ColorFilterIcon } from '@elementor/icons';
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
5
|
-
|
|
6
|
-
import { VariableSelectionPopover } from '../components/variable-selection-popover';
|
|
7
|
-
import { fontVariablePropTypeUtil } from '../prop-types/font-variable-prop-type';
|
|
8
|
-
import { supportsFontVariables } from '../utils';
|
|
9
|
-
|
|
10
|
-
export const usePropFontVariableAction = (): PopoverActionProps => {
|
|
11
|
-
const { propType } = useBoundProp();
|
|
12
|
-
|
|
13
|
-
const visible = !! propType && supportsFontVariables( propType );
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
visible,
|
|
17
|
-
icon: ColorFilterIcon,
|
|
18
|
-
title: __( 'Variables', 'elementor' ),
|
|
19
|
-
content: ( { close: closePopover } ) => {
|
|
20
|
-
return (
|
|
21
|
-
<VariableSelectionPopover closePopover={ closePopover } propTypeKey={ fontVariablePropTypeUtil.key } />
|
|
22
|
-
);
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { styleTransformersRegistry } from '@elementor/editor-canvas';
|
|
2
|
-
import { controlActionsMenu, registerControlReplacement } from '@elementor/editor-editing-panel';
|
|
3
|
-
|
|
4
|
-
import { ColorVariableControl } from './controls/color-variable-control';
|
|
5
|
-
import { usePropColorVariableAction } from './hooks/use-prop-color-variable-action';
|
|
6
|
-
import { colorVariablePropTypeUtil } from './prop-types/color-variable-prop-type';
|
|
7
|
-
import { registerRepeaterInjections } from './repeater-injections';
|
|
8
|
-
import { variableTransformer } from './transformers/variable-transformer';
|
|
9
|
-
import { hasAssignedColorVariable } from './utils';
|
|
10
|
-
|
|
11
|
-
const { registerPopoverAction } = controlActionsMenu;
|
|
12
|
-
|
|
13
|
-
export function initColorVariables() {
|
|
14
|
-
registerControlReplacement( {
|
|
15
|
-
component: ColorVariableControl,
|
|
16
|
-
condition: ( { value } ) => hasAssignedColorVariable( value ),
|
|
17
|
-
} );
|
|
18
|
-
|
|
19
|
-
registerPopoverAction( {
|
|
20
|
-
id: 'color-variables',
|
|
21
|
-
useProps: usePropColorVariableAction,
|
|
22
|
-
} );
|
|
23
|
-
|
|
24
|
-
styleTransformersRegistry.register( colorVariablePropTypeUtil.key, variableTransformer );
|
|
25
|
-
|
|
26
|
-
registerRepeaterInjections();
|
|
27
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { styleTransformersRegistry } from '@elementor/editor-canvas';
|
|
2
|
-
import { controlActionsMenu, registerControlReplacement } from '@elementor/editor-editing-panel';
|
|
3
|
-
|
|
4
|
-
import { FontVariableControl } from './controls/font-variable-control';
|
|
5
|
-
import { usePropFontVariableAction } from './hooks/use-prop-font-variable-action';
|
|
6
|
-
import { fontVariablePropTypeUtil } from './prop-types/font-variable-prop-type';
|
|
7
|
-
import { variableTransformer } from './transformers/variable-transformer';
|
|
8
|
-
import { hasAssignedFontVariable } from './utils';
|
|
9
|
-
|
|
10
|
-
const { registerPopoverAction } = controlActionsMenu;
|
|
11
|
-
|
|
12
|
-
export function initFontVariables() {
|
|
13
|
-
registerControlReplacement( {
|
|
14
|
-
component: FontVariableControl,
|
|
15
|
-
condition: ( { value } ) => hasAssignedFontVariable( value ),
|
|
16
|
-
} );
|
|
17
|
-
|
|
18
|
-
registerPopoverAction( {
|
|
19
|
-
id: 'font-variables',
|
|
20
|
-
useProps: usePropFontVariableAction,
|
|
21
|
-
} );
|
|
22
|
-
|
|
23
|
-
styleTransformersRegistry.register( fontVariablePropTypeUtil.key, variableTransformer );
|
|
24
|
-
}
|
package/src/utils.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type PropType, type PropValue } from '@elementor/editor-props';
|
|
2
|
-
|
|
3
|
-
import { colorVariablePropTypeUtil } from './prop-types/color-variable-prop-type';
|
|
4
|
-
import { fontVariablePropTypeUtil } from './prop-types/font-variable-prop-type';
|
|
5
|
-
|
|
6
|
-
export const hasAssignedColorVariable = ( propValue: PropValue ): boolean => {
|
|
7
|
-
return !! colorVariablePropTypeUtil.isValid( propValue );
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const supportsColorVariables = ( propType: PropType ): boolean => {
|
|
11
|
-
return propType.kind === 'union' && colorVariablePropTypeUtil.key in propType.prop_types;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const hasAssignedFontVariable = ( propValue: PropValue ): boolean => {
|
|
15
|
-
return !! fontVariablePropTypeUtil.isValid( propValue );
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const supportsFontVariables = ( propType: PropType ): boolean => {
|
|
19
|
-
return propType.kind === 'union' && fontVariablePropTypeUtil.key in propType.prop_types;
|
|
20
|
-
};
|