@elementor/editor-controls 0.4.1 → 0.6.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 CHANGED
@@ -1,5 +1,34 @@
1
1
  # @elementor/editor-controls
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 45038fc: Added background image overlay control
8
+ - e742340: Revert background overlay control unneeded change
9
+ - dab01fd: Created an autocomplete control and extended link control.
10
+ - 43f1684: Save previous link value in session
11
+ - 499c531: Add binds path to prop context.
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [45038fc]
16
+ - Updated dependencies [43f1684]
17
+ - @elementor/editor-props@0.7.0
18
+ - @elementor/session@0.1.0
19
+
20
+ ## 0.5.0
21
+
22
+ ### Minor Changes
23
+
24
+ - a2245c5: Change prop provider infra to support nested props.
25
+
26
+ ### Patch Changes
27
+
28
+ - 5fc8d7b: Removed extra prop provider from background control.
29
+ - Updated dependencies [a2245c5]
30
+ - @elementor/editor-props@0.6.0
31
+
3
32
  ## 0.4.1
4
33
 
5
34
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { ComponentType, ReactNode, PropsWithChildren } from 'react';
3
- import { StringPropValue, PropValue, PropKey, SizePropValue, PropTypeUtil, CreateOptions } from '@elementor/editor-props';
3
+ import { urlPropTypeUtil, stringPropTypeUtil, StringPropValue, PropTypeUtil, PropValue, PropKey, SizePropValue, CreateOptions, PropType } from '@elementor/editor-props';
4
4
  import { UnstableColorFieldProps, ToggleButtonProps, StackProps } from '@elementor/ui';
5
5
 
6
6
  type AnyComponentType = ComponentType<any>;
@@ -17,14 +17,31 @@ type ImageControlProps = {
17
17
  };
18
18
  declare const ImageControl: ControlComponent<(props: ImageControlProps) => React.JSX.Element>;
19
19
 
20
+ type Option = {
21
+ label: string;
22
+ groupLabel?: never;
23
+ };
24
+ type GroupedOption = {
25
+ label: string;
26
+ groupLabel: string;
27
+ };
28
+ type Props$6 = {
29
+ options: Record<string, Option> | Record<string, GroupedOption>;
30
+ allowCustomValues?: boolean;
31
+ placeholder?: string;
32
+ propType?: typeof urlPropTypeUtil | typeof stringPropTypeUtil;
33
+ minInputLength?: number;
34
+ };
35
+ declare const AutocompleteControl: ControlComponent<({ options, placeholder, allowCustomValues, propType, minInputLength, }: Props$6) => React.JSX.Element>;
36
+
20
37
  declare const TextControl: ControlComponent<({ placeholder }: {
21
38
  placeholder?: string;
22
39
  }) => React.JSX.Element>;
23
40
 
24
- type Props$3 = {
41
+ type Props$5 = {
25
42
  placeholder?: string;
26
43
  };
27
- declare const TextAreaControl: ControlComponent<({ placeholder }: Props$3) => React.JSX.Element>;
44
+ declare const TextAreaControl: ControlComponent<({ placeholder }: Props$5) => React.JSX.Element>;
28
45
 
29
46
  type Unit = 'px' | '%' | 'em' | 'rem' | 'vw' | 'vh';
30
47
  type SizeControlProps = {
@@ -38,7 +55,7 @@ declare const StrokeControl: ControlComponent<() => React.JSX.Element>;
38
55
 
39
56
  declare const BoxShadowRepeaterControl: ControlComponent<() => React.JSX.Element>;
40
57
 
41
- type Props$2 = {
58
+ type Props$4 = {
42
59
  options: Array<{
43
60
  label: string;
44
61
  value: StringPropValue['value'];
@@ -46,9 +63,12 @@ type Props$2 = {
46
63
  }>;
47
64
  onChange?: (newValue: string | null, previousValue: string | null | undefined) => void;
48
65
  };
49
- declare const SelectControl: ControlComponent<({ options, onChange }: Props$2) => React.JSX.Element>;
66
+ declare const SelectControl: ControlComponent<({ options, onChange }: Props$4) => React.JSX.Element>;
50
67
 
51
- declare const ColorControl: ControlComponent<(props: Partial<Omit<UnstableColorFieldProps, "value" | "onChange">>) => React.JSX.Element>;
68
+ type Props$3 = Partial<Omit<UnstableColorFieldProps, 'value' | 'onChange'>> & {
69
+ propTypeUtil?: PropTypeUtil<string, string>;
70
+ };
71
+ declare const ColorControl: ControlComponent<({ propTypeUtil, ...props }: Props$3) => React.JSX.Element>;
52
72
 
53
73
  type RenderContentProps = {
54
74
  size: ToggleButtonProps['size'];
@@ -61,7 +81,7 @@ type ToggleButtonGroupItem<TValue> = {
61
81
  };
62
82
  type ExclusiveValue<TValue> = TValue;
63
83
  type NonExclusiveValue<TValue> = TValue[];
64
- type Props$1<TValue> = {
84
+ type Props$2<TValue> = {
65
85
  justify?: StackProps['justifyContent'];
66
86
  size?: ToggleButtonProps['size'];
67
87
  items: ToggleButtonGroupItem<TValue | null>[];
@@ -75,7 +95,7 @@ type Props$1<TValue> = {
75
95
  value: ExclusiveValue<TValue>;
76
96
  onChange: (value: ExclusiveValue<TValue>) => void;
77
97
  });
78
- declare const ControlToggleButtonGroup: <TValue>({ justify, size, value, onChange, items, exclusive, fullWidth, }: Props$1<TValue>) => React.JSX.Element;
98
+ declare const ControlToggleButtonGroup: <TValue>({ justify, size, value, onChange, items, exclusive, fullWidth, }: Props$2<TValue>) => React.JSX.Element;
79
99
 
80
100
  type ToggleControlProps<T extends PropValue> = {
81
101
  options: ToggleButtonGroupItem<T>[];
@@ -99,13 +119,13 @@ type Item = {
99
119
  bind: PropKey;
100
120
  };
101
121
  type EqualUnequalItems = [Item, Item, Item, Item];
102
- type Props<TMultiPropType extends string, TPropValue extends MultiSizePropValue> = {
122
+ type Props$1<TMultiPropType extends string, TPropValue extends MultiSizePropValue> = {
103
123
  label: string;
104
124
  icon: ReactNode;
105
125
  items: EqualUnequalItems;
106
126
  multiSizePropTypeUtil: PropTypeUtil<TMultiPropType, TPropValue>;
107
127
  };
108
- declare function EqualUnequalSizesControl<TMultiPropType extends string, TPropValue extends MultiSizePropValue>({ label, icon, items, multiSizePropTypeUtil, }: Props<TMultiPropType, TPropValue>): React.JSX.Element;
128
+ declare function EqualUnequalSizesControl<TMultiPropType extends string, TPropValue extends MultiSizePropValue>({ label, icon, items, multiSizePropTypeUtil, }: Props$1<TMultiPropType, TPropValue>): React.JSX.Element;
109
129
 
110
130
  declare const LinkedDimensionsControl: ControlComponent<({ label }: {
111
131
  label: string;
@@ -117,7 +137,12 @@ declare const UrlControl: ControlComponent<({ placeholder }: {
117
137
  placeholder?: string;
118
138
  }) => React.JSX.Element>;
119
139
 
120
- declare const LinkControl: ControlComponent<() => React.JSX.Element>;
140
+ type Props = {
141
+ options?: Record<string, Option> | Record<string, GroupedOption>;
142
+ allowCustomValues?: boolean;
143
+ placeholder?: string;
144
+ };
145
+ declare const LinkControl: ControlComponent<(props?: Props) => React.JSX.Element>;
121
146
 
122
147
  declare const GapControl: ControlComponent<({ label }: {
123
148
  label: string;
@@ -140,23 +165,39 @@ type ControlActionsProviderProps = PropsWithChildren<ControlActionsContext>;
140
165
  declare const ControlActionsProvider: ({ children, items }: ControlActionsProviderProps) => React.JSX.Element;
141
166
  declare const useControlActions: () => ControlActionsContext;
142
167
 
143
- type BoundPropContext<T extends PropValue> = {
168
+ type SetValueMeta = {
169
+ bind?: PropKey;
170
+ };
171
+ type SetValue<T> = (value: T, options?: CreateOptions, meta?: SetValueMeta) => void;
172
+ type PropContext<T extends PropValue, P extends PropType> = {
173
+ setValue: SetValue<T>;
174
+ value: T | null;
175
+ propType: P;
176
+ };
177
+ declare const PropContext: React.Context<PropContext<PropValue, PropType> | null>;
178
+ type PropProviderProps<T extends PropValue, P extends PropType> = React.PropsWithChildren<PropContext<T, P>>;
179
+ declare const PropProvider: <T extends PropValue, P extends PropType>({ children, value, setValue, propType, }: PropProviderProps<T, P>) => React.JSX.Element;
180
+
181
+ type PropKeyContextValue<T, P> = {
144
182
  bind: PropKey;
145
- setValue: (value: T | null) => void;
183
+ setValue: SetValue<T>;
146
184
  value: T;
185
+ propType: P;
186
+ path: PropKey[];
147
187
  };
148
- type BoundPropProviderProps<T extends PropValue> = BoundPropContext<T> & {
149
- children: React.ReactNode;
150
- setValue: (value: T | null) => void;
151
- };
152
- declare const BoundPropProvider: ({ children, value, setValue, bind }: BoundPropProviderProps<PropValue>) => React.JSX.Element;
153
- type SetValue<T> = (value: T | null, options?: CreateOptions) => void;
154
- type UseBoundProp<TValue> = {
188
+ type PropKeyProviderProps = React.PropsWithChildren<{
189
+ bind: PropKey;
190
+ }>;
191
+ declare const PropKeyProvider: ({ children, bind }: PropKeyProviderProps) => React.JSX.Element;
192
+
193
+ type UseBoundProp<TValue extends PropValue> = {
155
194
  bind: PropKey;
156
- setValue: SetValue<TValue>;
195
+ setValue: SetValue<TValue | null>;
157
196
  value: TValue;
197
+ propType: PropType;
198
+ path: PropKey[];
158
199
  };
159
- declare function useBoundProp<TValue extends PropValue>(): BoundPropContext<TValue>;
200
+ declare function useBoundProp<T extends PropValue = PropValue>(): PropKeyContextValue<T, PropType>;
160
201
  declare function useBoundProp<TKey extends string, TValue extends PropValue>(propTypeUtil: PropTypeUtil<TKey, TValue>): UseBoundProp<TValue>;
161
202
 
162
203
  type ReplaceWhenParams = {
@@ -180,4 +221,4 @@ type UseInternalStateOptions<TValue> = {
180
221
  };
181
222
  declare const useSyncExternalState: <TValue>({ external, setExternal, persistWhen, fallback, }: UseInternalStateOptions<TValue>) => readonly [TValue, (setter: ((value: TValue) => TValue) | TValue) => void];
182
223
 
183
- export { BackgroundControl, BoundPropProvider, type BoundPropProviderProps, BoxShadowRepeaterControl, ColorControl, type ControlActionsItems, ControlActionsProvider, type ControlComponent, ControlLabel, ControlReplacementProvider, ControlToggleButtonGroup, type EqualUnequalItems, EqualUnequalSizesControl, FontFamilyControl, GapControl, ImageControl, LinkControl, LinkedDimensionsControl, NumberControl, SelectControl, SizeControl, StrokeControl, TextAreaControl, TextControl, type ToggleButtonGroupItem, ToggleControl, UrlControl, createControlReplacement, useBoundProp, useControlActions, useSyncExternalState };
224
+ export { AutocompleteControl, BackgroundControl, BoxShadowRepeaterControl, ColorControl, type ControlActionsItems, ControlActionsProvider, type ControlComponent, ControlLabel, ControlReplacementProvider, ControlToggleButtonGroup, type EqualUnequalItems, EqualUnequalSizesControl, FontFamilyControl, GapControl, ImageControl, LinkControl, LinkedDimensionsControl, NumberControl, PropKeyProvider, PropProvider, type PropProviderProps, SelectControl, type SetValue, SizeControl, StrokeControl, TextAreaControl, TextControl, type ToggleButtonGroupItem, ToggleControl, UrlControl, createControlReplacement, useBoundProp, useControlActions, useSyncExternalState };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { ComponentType, ReactNode, PropsWithChildren } from 'react';
3
- import { StringPropValue, PropValue, PropKey, SizePropValue, PropTypeUtil, CreateOptions } from '@elementor/editor-props';
3
+ import { urlPropTypeUtil, stringPropTypeUtil, StringPropValue, PropTypeUtil, PropValue, PropKey, SizePropValue, CreateOptions, PropType } from '@elementor/editor-props';
4
4
  import { UnstableColorFieldProps, ToggleButtonProps, StackProps } from '@elementor/ui';
5
5
 
6
6
  type AnyComponentType = ComponentType<any>;
@@ -17,14 +17,31 @@ type ImageControlProps = {
17
17
  };
18
18
  declare const ImageControl: ControlComponent<(props: ImageControlProps) => React.JSX.Element>;
19
19
 
20
+ type Option = {
21
+ label: string;
22
+ groupLabel?: never;
23
+ };
24
+ type GroupedOption = {
25
+ label: string;
26
+ groupLabel: string;
27
+ };
28
+ type Props$6 = {
29
+ options: Record<string, Option> | Record<string, GroupedOption>;
30
+ allowCustomValues?: boolean;
31
+ placeholder?: string;
32
+ propType?: typeof urlPropTypeUtil | typeof stringPropTypeUtil;
33
+ minInputLength?: number;
34
+ };
35
+ declare const AutocompleteControl: ControlComponent<({ options, placeholder, allowCustomValues, propType, minInputLength, }: Props$6) => React.JSX.Element>;
36
+
20
37
  declare const TextControl: ControlComponent<({ placeholder }: {
21
38
  placeholder?: string;
22
39
  }) => React.JSX.Element>;
23
40
 
24
- type Props$3 = {
41
+ type Props$5 = {
25
42
  placeholder?: string;
26
43
  };
27
- declare const TextAreaControl: ControlComponent<({ placeholder }: Props$3) => React.JSX.Element>;
44
+ declare const TextAreaControl: ControlComponent<({ placeholder }: Props$5) => React.JSX.Element>;
28
45
 
29
46
  type Unit = 'px' | '%' | 'em' | 'rem' | 'vw' | 'vh';
30
47
  type SizeControlProps = {
@@ -38,7 +55,7 @@ declare const StrokeControl: ControlComponent<() => React.JSX.Element>;
38
55
 
39
56
  declare const BoxShadowRepeaterControl: ControlComponent<() => React.JSX.Element>;
40
57
 
41
- type Props$2 = {
58
+ type Props$4 = {
42
59
  options: Array<{
43
60
  label: string;
44
61
  value: StringPropValue['value'];
@@ -46,9 +63,12 @@ type Props$2 = {
46
63
  }>;
47
64
  onChange?: (newValue: string | null, previousValue: string | null | undefined) => void;
48
65
  };
49
- declare const SelectControl: ControlComponent<({ options, onChange }: Props$2) => React.JSX.Element>;
66
+ declare const SelectControl: ControlComponent<({ options, onChange }: Props$4) => React.JSX.Element>;
50
67
 
51
- declare const ColorControl: ControlComponent<(props: Partial<Omit<UnstableColorFieldProps, "value" | "onChange">>) => React.JSX.Element>;
68
+ type Props$3 = Partial<Omit<UnstableColorFieldProps, 'value' | 'onChange'>> & {
69
+ propTypeUtil?: PropTypeUtil<string, string>;
70
+ };
71
+ declare const ColorControl: ControlComponent<({ propTypeUtil, ...props }: Props$3) => React.JSX.Element>;
52
72
 
53
73
  type RenderContentProps = {
54
74
  size: ToggleButtonProps['size'];
@@ -61,7 +81,7 @@ type ToggleButtonGroupItem<TValue> = {
61
81
  };
62
82
  type ExclusiveValue<TValue> = TValue;
63
83
  type NonExclusiveValue<TValue> = TValue[];
64
- type Props$1<TValue> = {
84
+ type Props$2<TValue> = {
65
85
  justify?: StackProps['justifyContent'];
66
86
  size?: ToggleButtonProps['size'];
67
87
  items: ToggleButtonGroupItem<TValue | null>[];
@@ -75,7 +95,7 @@ type Props$1<TValue> = {
75
95
  value: ExclusiveValue<TValue>;
76
96
  onChange: (value: ExclusiveValue<TValue>) => void;
77
97
  });
78
- declare const ControlToggleButtonGroup: <TValue>({ justify, size, value, onChange, items, exclusive, fullWidth, }: Props$1<TValue>) => React.JSX.Element;
98
+ declare const ControlToggleButtonGroup: <TValue>({ justify, size, value, onChange, items, exclusive, fullWidth, }: Props$2<TValue>) => React.JSX.Element;
79
99
 
80
100
  type ToggleControlProps<T extends PropValue> = {
81
101
  options: ToggleButtonGroupItem<T>[];
@@ -99,13 +119,13 @@ type Item = {
99
119
  bind: PropKey;
100
120
  };
101
121
  type EqualUnequalItems = [Item, Item, Item, Item];
102
- type Props<TMultiPropType extends string, TPropValue extends MultiSizePropValue> = {
122
+ type Props$1<TMultiPropType extends string, TPropValue extends MultiSizePropValue> = {
103
123
  label: string;
104
124
  icon: ReactNode;
105
125
  items: EqualUnequalItems;
106
126
  multiSizePropTypeUtil: PropTypeUtil<TMultiPropType, TPropValue>;
107
127
  };
108
- declare function EqualUnequalSizesControl<TMultiPropType extends string, TPropValue extends MultiSizePropValue>({ label, icon, items, multiSizePropTypeUtil, }: Props<TMultiPropType, TPropValue>): React.JSX.Element;
128
+ declare function EqualUnequalSizesControl<TMultiPropType extends string, TPropValue extends MultiSizePropValue>({ label, icon, items, multiSizePropTypeUtil, }: Props$1<TMultiPropType, TPropValue>): React.JSX.Element;
109
129
 
110
130
  declare const LinkedDimensionsControl: ControlComponent<({ label }: {
111
131
  label: string;
@@ -117,7 +137,12 @@ declare const UrlControl: ControlComponent<({ placeholder }: {
117
137
  placeholder?: string;
118
138
  }) => React.JSX.Element>;
119
139
 
120
- declare const LinkControl: ControlComponent<() => React.JSX.Element>;
140
+ type Props = {
141
+ options?: Record<string, Option> | Record<string, GroupedOption>;
142
+ allowCustomValues?: boolean;
143
+ placeholder?: string;
144
+ };
145
+ declare const LinkControl: ControlComponent<(props?: Props) => React.JSX.Element>;
121
146
 
122
147
  declare const GapControl: ControlComponent<({ label }: {
123
148
  label: string;
@@ -140,23 +165,39 @@ type ControlActionsProviderProps = PropsWithChildren<ControlActionsContext>;
140
165
  declare const ControlActionsProvider: ({ children, items }: ControlActionsProviderProps) => React.JSX.Element;
141
166
  declare const useControlActions: () => ControlActionsContext;
142
167
 
143
- type BoundPropContext<T extends PropValue> = {
168
+ type SetValueMeta = {
169
+ bind?: PropKey;
170
+ };
171
+ type SetValue<T> = (value: T, options?: CreateOptions, meta?: SetValueMeta) => void;
172
+ type PropContext<T extends PropValue, P extends PropType> = {
173
+ setValue: SetValue<T>;
174
+ value: T | null;
175
+ propType: P;
176
+ };
177
+ declare const PropContext: React.Context<PropContext<PropValue, PropType> | null>;
178
+ type PropProviderProps<T extends PropValue, P extends PropType> = React.PropsWithChildren<PropContext<T, P>>;
179
+ declare const PropProvider: <T extends PropValue, P extends PropType>({ children, value, setValue, propType, }: PropProviderProps<T, P>) => React.JSX.Element;
180
+
181
+ type PropKeyContextValue<T, P> = {
144
182
  bind: PropKey;
145
- setValue: (value: T | null) => void;
183
+ setValue: SetValue<T>;
146
184
  value: T;
185
+ propType: P;
186
+ path: PropKey[];
147
187
  };
148
- type BoundPropProviderProps<T extends PropValue> = BoundPropContext<T> & {
149
- children: React.ReactNode;
150
- setValue: (value: T | null) => void;
151
- };
152
- declare const BoundPropProvider: ({ children, value, setValue, bind }: BoundPropProviderProps<PropValue>) => React.JSX.Element;
153
- type SetValue<T> = (value: T | null, options?: CreateOptions) => void;
154
- type UseBoundProp<TValue> = {
188
+ type PropKeyProviderProps = React.PropsWithChildren<{
189
+ bind: PropKey;
190
+ }>;
191
+ declare const PropKeyProvider: ({ children, bind }: PropKeyProviderProps) => React.JSX.Element;
192
+
193
+ type UseBoundProp<TValue extends PropValue> = {
155
194
  bind: PropKey;
156
- setValue: SetValue<TValue>;
195
+ setValue: SetValue<TValue | null>;
157
196
  value: TValue;
197
+ propType: PropType;
198
+ path: PropKey[];
158
199
  };
159
- declare function useBoundProp<TValue extends PropValue>(): BoundPropContext<TValue>;
200
+ declare function useBoundProp<T extends PropValue = PropValue>(): PropKeyContextValue<T, PropType>;
160
201
  declare function useBoundProp<TKey extends string, TValue extends PropValue>(propTypeUtil: PropTypeUtil<TKey, TValue>): UseBoundProp<TValue>;
161
202
 
162
203
  type ReplaceWhenParams = {
@@ -180,4 +221,4 @@ type UseInternalStateOptions<TValue> = {
180
221
  };
181
222
  declare const useSyncExternalState: <TValue>({ external, setExternal, persistWhen, fallback, }: UseInternalStateOptions<TValue>) => readonly [TValue, (setter: ((value: TValue) => TValue) | TValue) => void];
182
223
 
183
- export { BackgroundControl, BoundPropProvider, type BoundPropProviderProps, BoxShadowRepeaterControl, ColorControl, type ControlActionsItems, ControlActionsProvider, type ControlComponent, ControlLabel, ControlReplacementProvider, ControlToggleButtonGroup, type EqualUnequalItems, EqualUnequalSizesControl, FontFamilyControl, GapControl, ImageControl, LinkControl, LinkedDimensionsControl, NumberControl, SelectControl, SizeControl, StrokeControl, TextAreaControl, TextControl, type ToggleButtonGroupItem, ToggleControl, UrlControl, createControlReplacement, useBoundProp, useControlActions, useSyncExternalState };
224
+ export { AutocompleteControl, BackgroundControl, BoxShadowRepeaterControl, ColorControl, type ControlActionsItems, ControlActionsProvider, type ControlComponent, ControlLabel, ControlReplacementProvider, ControlToggleButtonGroup, type EqualUnequalItems, EqualUnequalSizesControl, FontFamilyControl, GapControl, ImageControl, LinkControl, LinkedDimensionsControl, NumberControl, PropKeyProvider, PropProvider, type PropProviderProps, SelectControl, type SetValue, SizeControl, StrokeControl, TextAreaControl, TextControl, type ToggleButtonGroupItem, ToggleControl, UrlControl, createControlReplacement, useBoundProp, useControlActions, useSyncExternalState };