@elementor/editor-controls 0.1.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 +22 -0
- package/README.md +4 -0
- package/dist/index.d.mts +148 -0
- package/dist/index.d.ts +148 -0
- package/dist/index.js +1346 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1320 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +52 -0
- package/src/bound-prop-context.tsx +30 -0
- package/src/components/control-label.tsx +10 -0
- package/src/components/control-toggle-button-group.tsx +84 -0
- package/src/components/repeater.tsx +200 -0
- package/src/components/text-field-inner-selection.tsx +76 -0
- package/src/control-actions/control-actions-context.tsx +27 -0
- package/src/control-actions/control-actions.tsx +32 -0
- package/src/controls/background-overlay-repeater-control.tsx +119 -0
- package/src/controls/box-shadow-repeater-control.tsx +227 -0
- package/src/controls/color-control.tsx +32 -0
- package/src/controls/equal-unequal-sizes-control.tsx +231 -0
- package/src/controls/font-family-control.tsx +154 -0
- package/src/controls/image-control.tsx +64 -0
- package/src/controls/image-media-control.tsx +71 -0
- package/src/controls/linked-dimensions-control.tsx +140 -0
- package/src/controls/number-control.tsx +31 -0
- package/src/controls/select-control.tsx +31 -0
- package/src/controls/size-control.tsx +77 -0
- package/src/controls/stroke-control.tsx +106 -0
- package/src/controls/text-area-control.tsx +32 -0
- package/src/controls/text-control.tsx +18 -0
- package/src/controls/toggle-control.tsx +34 -0
- package/src/create-control-replacement.tsx +54 -0
- package/src/create-control.tsx +41 -0
- package/src/hooks/use-filtered-font-families.ts +38 -0
- package/src/hooks/use-sync-external-state.tsx +51 -0
- package/src/index.ts +31 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# @elementor/editor-controls
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e4c6e3b: update @elementor/ui version
|
|
8
|
+
fix color picker position in box shadow repeater control
|
|
9
|
+
make the color control full width
|
|
10
|
+
- 00bdd7e: Added layout section with display field, updated toggle button group to match new children elements
|
|
11
|
+
- cecdfba: Updated display field with a flex option, together with a "justify content" field
|
|
12
|
+
- 6d5475d: Show spinner in image media control `CardMedia` on initial fetch.
|
|
13
|
+
- 55962f8: Add background color overlay control
|
|
14
|
+
- e2ee013: Created the `editor-controls` packages.
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 7781969: Update `@elementor/ui` version
|
|
19
|
+
- 5c3d546: Fix some style issues in the editing panel and controls
|
|
20
|
+
- Updated dependencies [6e240a8]
|
|
21
|
+
- @elementor/editor-props@0.3.0
|
|
22
|
+
- @elementor/wp-media@0.2.2
|
package/README.md
ADDED
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentType, ReactNode, PropsWithChildren } from 'react';
|
|
3
|
+
import { PropValue, TransformablePropValue, SizePropValue, PropKey } from '@elementor/editor-props';
|
|
4
|
+
import { UnstableColorFieldProps, ToggleButtonProps } from '@elementor/ui';
|
|
5
|
+
|
|
6
|
+
type AnyComponentType = ComponentType<any>;
|
|
7
|
+
declare const brandSymbol: unique symbol;
|
|
8
|
+
type ControlComponent<TComponent extends AnyComponentType = AnyComponentType> = TComponent & {
|
|
9
|
+
[brandSymbol]: true;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type ImageControlProps = {
|
|
13
|
+
sizes: {
|
|
14
|
+
label: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
declare const ImageControl: ControlComponent<(props: ImageControlProps) => React.JSX.Element>;
|
|
19
|
+
|
|
20
|
+
declare const TextControl: ControlComponent<({ placeholder }: {
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
}) => React.JSX.Element>;
|
|
23
|
+
|
|
24
|
+
type Props$2 = {
|
|
25
|
+
placeholder?: string;
|
|
26
|
+
};
|
|
27
|
+
declare const TextAreaControl: ControlComponent<({ placeholder }: Props$2) => React.JSX.Element>;
|
|
28
|
+
|
|
29
|
+
type Unit = 'px' | '%' | 'em' | 'rem' | 'vw' | 'vh';
|
|
30
|
+
type SizeControlProps = {
|
|
31
|
+
placeholder?: string;
|
|
32
|
+
startIcon?: React.ReactNode;
|
|
33
|
+
units?: Unit[];
|
|
34
|
+
};
|
|
35
|
+
declare const SizeControl: ControlComponent<({ units, placeholder, startIcon }: SizeControlProps) => React.JSX.Element>;
|
|
36
|
+
|
|
37
|
+
declare const StrokeControl: ControlComponent<() => React.JSX.Element>;
|
|
38
|
+
|
|
39
|
+
declare const BoxShadowRepeaterControl: ControlComponent<() => React.JSX.Element>;
|
|
40
|
+
|
|
41
|
+
declare const BackgroundOverlayRepeaterControl: ControlComponent<() => React.JSX.Element>;
|
|
42
|
+
|
|
43
|
+
type Props$1<T> = {
|
|
44
|
+
options: Array<{
|
|
45
|
+
label: string;
|
|
46
|
+
value: T;
|
|
47
|
+
disabled?: boolean;
|
|
48
|
+
}>;
|
|
49
|
+
};
|
|
50
|
+
declare const SelectControl: ControlComponent<(<T extends PropValue>({ options }: Props$1<T>) => React.JSX.Element)>;
|
|
51
|
+
|
|
52
|
+
declare const ColorControl: ControlComponent<(props: Partial<Omit<UnstableColorFieldProps, "value" | "onChange">>) => React.JSX.Element>;
|
|
53
|
+
|
|
54
|
+
type RenderContentProps = {
|
|
55
|
+
size: ToggleButtonProps['size'];
|
|
56
|
+
};
|
|
57
|
+
type ToggleButtonGroupItem<TValue> = {
|
|
58
|
+
value: TValue;
|
|
59
|
+
label: string;
|
|
60
|
+
renderContent: ({ size }: RenderContentProps) => React.ReactNode;
|
|
61
|
+
showTooltip?: boolean;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
type ToggleControlProps<T extends PropValue> = {
|
|
65
|
+
options: ToggleButtonGroupItem<T>[];
|
|
66
|
+
fullWidth?: boolean;
|
|
67
|
+
size?: ToggleButtonProps['size'];
|
|
68
|
+
};
|
|
69
|
+
declare const ToggleControl: ControlComponent<(<T extends PropValue>({ options, fullWidth, size }: ToggleControlProps<T>) => React.JSX.Element)>;
|
|
70
|
+
|
|
71
|
+
declare const NumberControl: ControlComponent<({ placeholder }: {
|
|
72
|
+
placeholder?: string;
|
|
73
|
+
}) => React.JSX.Element>;
|
|
74
|
+
|
|
75
|
+
type MultiSizePropValue<TMultiPropType extends string> = TransformablePropValue<TMultiPropType, Record<string, SizePropValue>>;
|
|
76
|
+
type Item<TMultiPropType extends string, TPropValue extends MultiSizePropValue<TMultiPropType>> = {
|
|
77
|
+
icon: ReactNode;
|
|
78
|
+
label: string;
|
|
79
|
+
bind: keyof TPropValue['value'];
|
|
80
|
+
};
|
|
81
|
+
type EqualUnequalItems<TMultiPropType extends string, TPropValue extends MultiSizePropValue<TMultiPropType>> = [
|
|
82
|
+
Item<TMultiPropType, TPropValue>,
|
|
83
|
+
Item<TMultiPropType, TPropValue>,
|
|
84
|
+
Item<TMultiPropType, TPropValue>,
|
|
85
|
+
Item<TMultiPropType, TPropValue>
|
|
86
|
+
];
|
|
87
|
+
type Props<TMultiPropType extends string, TPropValue extends MultiSizePropValue<TMultiPropType>> = {
|
|
88
|
+
label: string;
|
|
89
|
+
icon: ReactNode;
|
|
90
|
+
items: EqualUnequalItems<TMultiPropType, TPropValue>;
|
|
91
|
+
multiSizeType: TMultiPropType;
|
|
92
|
+
};
|
|
93
|
+
declare function EqualUnequalSizesControl<TMultiPropType extends string, TPropValue extends MultiSizePropValue<TMultiPropType>>({ label, icon, items, multiSizeType }: Props<TMultiPropType, TPropValue>): React.JSX.Element;
|
|
94
|
+
|
|
95
|
+
declare const LinkedDimensionsControl: ControlComponent<({ label }: {
|
|
96
|
+
label: string;
|
|
97
|
+
}) => React.JSX.Element>;
|
|
98
|
+
|
|
99
|
+
declare const FontFamilyControl: ControlComponent<({ fontFamilies }: any) => React.JSX.Element | null>;
|
|
100
|
+
|
|
101
|
+
declare const ControlLabel: ({ children }: {
|
|
102
|
+
children: React.ReactNode;
|
|
103
|
+
}) => React.JSX.Element;
|
|
104
|
+
|
|
105
|
+
type ReplaceWhenParams = {
|
|
106
|
+
value: PropValue;
|
|
107
|
+
};
|
|
108
|
+
type CreateControlReplacement = {
|
|
109
|
+
component: ComponentType;
|
|
110
|
+
condition: ({ value }: ReplaceWhenParams) => boolean;
|
|
111
|
+
};
|
|
112
|
+
declare const ControlReplacementProvider: ({ component, condition, children, }: React.PropsWithChildren<CreateControlReplacement>) => React.JSX.Element;
|
|
113
|
+
declare const createControlReplacement: () => {
|
|
114
|
+
replaceControl: ({ component, condition }: CreateControlReplacement) => void;
|
|
115
|
+
getControlReplacement: () => CreateControlReplacement;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
type BoundPropContext<T extends PropValue> = {
|
|
119
|
+
bind: PropKey;
|
|
120
|
+
setValue: (value: T | undefined) => void;
|
|
121
|
+
value: T | undefined;
|
|
122
|
+
};
|
|
123
|
+
type BoundPropProviderProps<T extends PropValue> = BoundPropContext<T> & {
|
|
124
|
+
children: React.ReactNode;
|
|
125
|
+
};
|
|
126
|
+
declare const BoundPropProvider: ({ children, value, setValue, bind }: BoundPropProviderProps<PropValue>) => React.JSX.Element;
|
|
127
|
+
declare function useBoundProp<T extends PropValue>(): BoundPropContext<T | undefined>;
|
|
128
|
+
declare function useBoundProp<T extends PropValue>(defaultValue: T): BoundPropContext<T>;
|
|
129
|
+
|
|
130
|
+
type ControlActionsContext = {
|
|
131
|
+
items: Array<{
|
|
132
|
+
id: string;
|
|
133
|
+
MenuItem: React.ComponentType;
|
|
134
|
+
}>;
|
|
135
|
+
};
|
|
136
|
+
type ControlActionsProviderProps = PropsWithChildren<ControlActionsContext>;
|
|
137
|
+
declare const ControlActionsProvider: ({ children, items }: ControlActionsProviderProps) => React.JSX.Element;
|
|
138
|
+
declare const useControlActions: () => ControlActionsContext;
|
|
139
|
+
|
|
140
|
+
type UseInternalStateOptions<TValue> = {
|
|
141
|
+
external: TValue | undefined;
|
|
142
|
+
setExternal: (value: TValue | undefined) => void;
|
|
143
|
+
persistWhen: (value: TValue | undefined) => boolean;
|
|
144
|
+
fallback: (value: TValue | undefined) => TValue;
|
|
145
|
+
};
|
|
146
|
+
declare const useSyncExternalState: <TValue>({ external, setExternal, persistWhen, fallback, }: UseInternalStateOptions<TValue>) => readonly [TValue, (setter: ((value: TValue) => TValue) | TValue) => void];
|
|
147
|
+
|
|
148
|
+
export { BackgroundOverlayRepeaterControl, BoundPropProvider, BoxShadowRepeaterControl, ColorControl, ControlActionsProvider, type ControlComponent, ControlLabel, ControlReplacementProvider, type EqualUnequalItems, EqualUnequalSizesControl, FontFamilyControl, ImageControl, LinkedDimensionsControl, NumberControl, SelectControl, SizeControl, StrokeControl, TextAreaControl, TextControl, type ToggleButtonGroupItem, ToggleControl, createControlReplacement, useBoundProp, useControlActions, useSyncExternalState };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentType, ReactNode, PropsWithChildren } from 'react';
|
|
3
|
+
import { PropValue, TransformablePropValue, SizePropValue, PropKey } from '@elementor/editor-props';
|
|
4
|
+
import { UnstableColorFieldProps, ToggleButtonProps } from '@elementor/ui';
|
|
5
|
+
|
|
6
|
+
type AnyComponentType = ComponentType<any>;
|
|
7
|
+
declare const brandSymbol: unique symbol;
|
|
8
|
+
type ControlComponent<TComponent extends AnyComponentType = AnyComponentType> = TComponent & {
|
|
9
|
+
[brandSymbol]: true;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type ImageControlProps = {
|
|
13
|
+
sizes: {
|
|
14
|
+
label: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
declare const ImageControl: ControlComponent<(props: ImageControlProps) => React.JSX.Element>;
|
|
19
|
+
|
|
20
|
+
declare const TextControl: ControlComponent<({ placeholder }: {
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
}) => React.JSX.Element>;
|
|
23
|
+
|
|
24
|
+
type Props$2 = {
|
|
25
|
+
placeholder?: string;
|
|
26
|
+
};
|
|
27
|
+
declare const TextAreaControl: ControlComponent<({ placeholder }: Props$2) => React.JSX.Element>;
|
|
28
|
+
|
|
29
|
+
type Unit = 'px' | '%' | 'em' | 'rem' | 'vw' | 'vh';
|
|
30
|
+
type SizeControlProps = {
|
|
31
|
+
placeholder?: string;
|
|
32
|
+
startIcon?: React.ReactNode;
|
|
33
|
+
units?: Unit[];
|
|
34
|
+
};
|
|
35
|
+
declare const SizeControl: ControlComponent<({ units, placeholder, startIcon }: SizeControlProps) => React.JSX.Element>;
|
|
36
|
+
|
|
37
|
+
declare const StrokeControl: ControlComponent<() => React.JSX.Element>;
|
|
38
|
+
|
|
39
|
+
declare const BoxShadowRepeaterControl: ControlComponent<() => React.JSX.Element>;
|
|
40
|
+
|
|
41
|
+
declare const BackgroundOverlayRepeaterControl: ControlComponent<() => React.JSX.Element>;
|
|
42
|
+
|
|
43
|
+
type Props$1<T> = {
|
|
44
|
+
options: Array<{
|
|
45
|
+
label: string;
|
|
46
|
+
value: T;
|
|
47
|
+
disabled?: boolean;
|
|
48
|
+
}>;
|
|
49
|
+
};
|
|
50
|
+
declare const SelectControl: ControlComponent<(<T extends PropValue>({ options }: Props$1<T>) => React.JSX.Element)>;
|
|
51
|
+
|
|
52
|
+
declare const ColorControl: ControlComponent<(props: Partial<Omit<UnstableColorFieldProps, "value" | "onChange">>) => React.JSX.Element>;
|
|
53
|
+
|
|
54
|
+
type RenderContentProps = {
|
|
55
|
+
size: ToggleButtonProps['size'];
|
|
56
|
+
};
|
|
57
|
+
type ToggleButtonGroupItem<TValue> = {
|
|
58
|
+
value: TValue;
|
|
59
|
+
label: string;
|
|
60
|
+
renderContent: ({ size }: RenderContentProps) => React.ReactNode;
|
|
61
|
+
showTooltip?: boolean;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
type ToggleControlProps<T extends PropValue> = {
|
|
65
|
+
options: ToggleButtonGroupItem<T>[];
|
|
66
|
+
fullWidth?: boolean;
|
|
67
|
+
size?: ToggleButtonProps['size'];
|
|
68
|
+
};
|
|
69
|
+
declare const ToggleControl: ControlComponent<(<T extends PropValue>({ options, fullWidth, size }: ToggleControlProps<T>) => React.JSX.Element)>;
|
|
70
|
+
|
|
71
|
+
declare const NumberControl: ControlComponent<({ placeholder }: {
|
|
72
|
+
placeholder?: string;
|
|
73
|
+
}) => React.JSX.Element>;
|
|
74
|
+
|
|
75
|
+
type MultiSizePropValue<TMultiPropType extends string> = TransformablePropValue<TMultiPropType, Record<string, SizePropValue>>;
|
|
76
|
+
type Item<TMultiPropType extends string, TPropValue extends MultiSizePropValue<TMultiPropType>> = {
|
|
77
|
+
icon: ReactNode;
|
|
78
|
+
label: string;
|
|
79
|
+
bind: keyof TPropValue['value'];
|
|
80
|
+
};
|
|
81
|
+
type EqualUnequalItems<TMultiPropType extends string, TPropValue extends MultiSizePropValue<TMultiPropType>> = [
|
|
82
|
+
Item<TMultiPropType, TPropValue>,
|
|
83
|
+
Item<TMultiPropType, TPropValue>,
|
|
84
|
+
Item<TMultiPropType, TPropValue>,
|
|
85
|
+
Item<TMultiPropType, TPropValue>
|
|
86
|
+
];
|
|
87
|
+
type Props<TMultiPropType extends string, TPropValue extends MultiSizePropValue<TMultiPropType>> = {
|
|
88
|
+
label: string;
|
|
89
|
+
icon: ReactNode;
|
|
90
|
+
items: EqualUnequalItems<TMultiPropType, TPropValue>;
|
|
91
|
+
multiSizeType: TMultiPropType;
|
|
92
|
+
};
|
|
93
|
+
declare function EqualUnequalSizesControl<TMultiPropType extends string, TPropValue extends MultiSizePropValue<TMultiPropType>>({ label, icon, items, multiSizeType }: Props<TMultiPropType, TPropValue>): React.JSX.Element;
|
|
94
|
+
|
|
95
|
+
declare const LinkedDimensionsControl: ControlComponent<({ label }: {
|
|
96
|
+
label: string;
|
|
97
|
+
}) => React.JSX.Element>;
|
|
98
|
+
|
|
99
|
+
declare const FontFamilyControl: ControlComponent<({ fontFamilies }: any) => React.JSX.Element | null>;
|
|
100
|
+
|
|
101
|
+
declare const ControlLabel: ({ children }: {
|
|
102
|
+
children: React.ReactNode;
|
|
103
|
+
}) => React.JSX.Element;
|
|
104
|
+
|
|
105
|
+
type ReplaceWhenParams = {
|
|
106
|
+
value: PropValue;
|
|
107
|
+
};
|
|
108
|
+
type CreateControlReplacement = {
|
|
109
|
+
component: ComponentType;
|
|
110
|
+
condition: ({ value }: ReplaceWhenParams) => boolean;
|
|
111
|
+
};
|
|
112
|
+
declare const ControlReplacementProvider: ({ component, condition, children, }: React.PropsWithChildren<CreateControlReplacement>) => React.JSX.Element;
|
|
113
|
+
declare const createControlReplacement: () => {
|
|
114
|
+
replaceControl: ({ component, condition }: CreateControlReplacement) => void;
|
|
115
|
+
getControlReplacement: () => CreateControlReplacement;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
type BoundPropContext<T extends PropValue> = {
|
|
119
|
+
bind: PropKey;
|
|
120
|
+
setValue: (value: T | undefined) => void;
|
|
121
|
+
value: T | undefined;
|
|
122
|
+
};
|
|
123
|
+
type BoundPropProviderProps<T extends PropValue> = BoundPropContext<T> & {
|
|
124
|
+
children: React.ReactNode;
|
|
125
|
+
};
|
|
126
|
+
declare const BoundPropProvider: ({ children, value, setValue, bind }: BoundPropProviderProps<PropValue>) => React.JSX.Element;
|
|
127
|
+
declare function useBoundProp<T extends PropValue>(): BoundPropContext<T | undefined>;
|
|
128
|
+
declare function useBoundProp<T extends PropValue>(defaultValue: T): BoundPropContext<T>;
|
|
129
|
+
|
|
130
|
+
type ControlActionsContext = {
|
|
131
|
+
items: Array<{
|
|
132
|
+
id: string;
|
|
133
|
+
MenuItem: React.ComponentType;
|
|
134
|
+
}>;
|
|
135
|
+
};
|
|
136
|
+
type ControlActionsProviderProps = PropsWithChildren<ControlActionsContext>;
|
|
137
|
+
declare const ControlActionsProvider: ({ children, items }: ControlActionsProviderProps) => React.JSX.Element;
|
|
138
|
+
declare const useControlActions: () => ControlActionsContext;
|
|
139
|
+
|
|
140
|
+
type UseInternalStateOptions<TValue> = {
|
|
141
|
+
external: TValue | undefined;
|
|
142
|
+
setExternal: (value: TValue | undefined) => void;
|
|
143
|
+
persistWhen: (value: TValue | undefined) => boolean;
|
|
144
|
+
fallback: (value: TValue | undefined) => TValue;
|
|
145
|
+
};
|
|
146
|
+
declare const useSyncExternalState: <TValue>({ external, setExternal, persistWhen, fallback, }: UseInternalStateOptions<TValue>) => readonly [TValue, (setter: ((value: TValue) => TValue) | TValue) => void];
|
|
147
|
+
|
|
148
|
+
export { BackgroundOverlayRepeaterControl, BoundPropProvider, BoxShadowRepeaterControl, ColorControl, ControlActionsProvider, type ControlComponent, ControlLabel, ControlReplacementProvider, type EqualUnequalItems, EqualUnequalSizesControl, FontFamilyControl, ImageControl, LinkedDimensionsControl, NumberControl, SelectControl, SizeControl, StrokeControl, TextAreaControl, TextControl, type ToggleButtonGroupItem, ToggleControl, createControlReplacement, useBoundProp, useControlActions, useSyncExternalState };
|