@elementor/editor-controls 0.17.0 → 0.18.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 +11 -0
- package/dist/index.d.mts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/control-adornments/control-adornments-context.tsx +25 -0
- package/src/control-adornments/control-adornments.tsx +19 -0
- package/src/control-adornments/control-label-with-adornments.tsx +15 -0
- package/src/index.ts +2 -1
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": "0.
|
|
4
|
+
"version": "0.18.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@elementor/editor-current-user": "0.3.0",
|
|
44
|
-
"@elementor/editor-elements": "0.6.
|
|
44
|
+
"@elementor/editor-elements": "0.6.4",
|
|
45
45
|
"@elementor/editor-props": "0.11.0",
|
|
46
46
|
"@elementor/env": "0.3.5",
|
|
47
47
|
"@elementor/http": "0.1.4",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ComponentType, createContext, type PropsWithChildren, useContext } from 'react';
|
|
3
|
+
|
|
4
|
+
type ControlAdornmentsItems = Array< {
|
|
5
|
+
id: string;
|
|
6
|
+
Adornment: ComponentType;
|
|
7
|
+
} >;
|
|
8
|
+
|
|
9
|
+
type ControlAdornmentsContext = {
|
|
10
|
+
items?: ControlAdornmentsItems;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const Context = createContext< ControlAdornmentsContext | null >( null );
|
|
14
|
+
|
|
15
|
+
type ControlAdornmentsProviderProps = PropsWithChildren< ControlAdornmentsContext >;
|
|
16
|
+
|
|
17
|
+
export const ControlAdornmentsProvider = ( { children, items }: ControlAdornmentsProviderProps ) => (
|
|
18
|
+
<Context.Provider value={ { items } }>{ children }</Context.Provider>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export const useControlAdornments = () => {
|
|
22
|
+
const context = useContext( Context );
|
|
23
|
+
|
|
24
|
+
return context?.items ?? [];
|
|
25
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { useControlAdornments } from './control-adornments-context';
|
|
4
|
+
|
|
5
|
+
export function ControlAdornments() {
|
|
6
|
+
const items = useControlAdornments();
|
|
7
|
+
|
|
8
|
+
if ( items?.length === 0 ) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<>
|
|
14
|
+
{ items.map( ( { Adornment, id } ) => (
|
|
15
|
+
<Adornment key={ id } />
|
|
16
|
+
) ) }
|
|
17
|
+
</>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type PropsWithChildren } from 'react';
|
|
3
|
+
import { Stack } from '@elementor/ui';
|
|
4
|
+
|
|
5
|
+
import { ControlLabel } from '../components/control-label';
|
|
6
|
+
import { ControlAdornments } from './control-adornments';
|
|
7
|
+
|
|
8
|
+
export const ControlLabelWithAdornments = ( { children }: PropsWithChildren< object > ) => {
|
|
9
|
+
return (
|
|
10
|
+
<Stack direction="row" alignItems="center" justifyItems="start" gap={ 1 }>
|
|
11
|
+
<ControlLabel>{ children }</ControlLabel>
|
|
12
|
+
<ControlAdornments />
|
|
13
|
+
</Stack>
|
|
14
|
+
);
|
|
15
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -37,6 +37,7 @@ export type { FontCategory } from './controls/font-family-control/font-family-co
|
|
|
37
37
|
export { createControlReplacement, ControlReplacementProvider } from './create-control-replacement';
|
|
38
38
|
export { ControlActionsProvider, useControlActions } from './control-actions/control-actions-context';
|
|
39
39
|
export { useBoundProp, PropProvider, PropKeyProvider } from './bound-prop-context';
|
|
40
|
-
|
|
40
|
+
export { ControlAdornmentsProvider } from './control-adornments/control-adornments-context';
|
|
41
|
+
export { ControlAdornments } from './control-adornments/control-adornments';
|
|
41
42
|
// hooks
|
|
42
43
|
export { useSyncExternalState } from './hooks/use-sync-external-state';
|