@dotcms/uve 1.2.1-next.13 → 1.2.1-next.14
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/README.md +1143 -0
- package/index.cjs.js +96 -183
- package/index.esm.js +97 -183
- package/internal.cjs.js +0 -4
- package/internal.esm.js +1 -1
- package/package.json +1 -1
- package/public.cjs.js +8 -78
- package/public.esm.js +9 -75
- package/src/internal/constants.d.ts +0 -2
- package/src/lib/core/core.utils.d.ts +0 -48
- package/src/lib/dom/dom.utils.d.ts +1 -10
- package/src/lib/style-editor/internal.d.ts +7 -7
- package/src/lib/style-editor/public.d.ts +83 -165
- package/src/lib/style-editor/types.d.ts +72 -179
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StyleEditorCheckboxGroupField, StyleEditorDropdownField, StyleEditorFieldInputType, StyleEditorForm, StyleEditorFormSchema, StyleEditorInputField, StyleEditorInputFieldConfig, StyleEditorRadioField } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Helper functions for creating style editor field definitions.
|
|
4
4
|
*
|
|
@@ -28,19 +28,19 @@ import { StyleEditorFormSchema, StyleEditorForm, StyleEditorInputField, StyleEdi
|
|
|
28
28
|
* title: 'Typography',
|
|
29
29
|
* fields: [
|
|
30
30
|
* styleEditorField.input({
|
|
31
|
+
* id: 'font-size',
|
|
31
32
|
* label: 'Font Size',
|
|
32
|
-
* inputType: 'number'
|
|
33
|
-
* defaultValue: 16
|
|
33
|
+
* inputType: 'number'
|
|
34
34
|
* }),
|
|
35
35
|
* styleEditorField.dropdown({
|
|
36
|
+
* id: 'font-family',
|
|
36
37
|
* label: 'Font Family',
|
|
37
|
-
* options: ['Arial', 'Helvetica']
|
|
38
|
-
* defaultValue: 'Arial'
|
|
38
|
+
* options: ['Arial', 'Helvetica']
|
|
39
39
|
* }),
|
|
40
40
|
* styleEditorField.radio({
|
|
41
|
+
* id: 'alignment',
|
|
41
42
|
* label: 'Alignment',
|
|
42
|
-
* options: ['Left', 'Center', 'Right']
|
|
43
|
-
* defaultValue: 'Left'
|
|
43
|
+
* options: ['Left', 'Center', 'Right']
|
|
44
44
|
* })
|
|
45
45
|
* ]
|
|
46
46
|
* }
|
|
@@ -50,140 +50,93 @@ import { StyleEditorFormSchema, StyleEditorForm, StyleEditorInputField, StyleEdi
|
|
|
50
50
|
*/
|
|
51
51
|
export declare const styleEditorField: {
|
|
52
52
|
/**
|
|
53
|
-
* Creates an input field definition
|
|
53
|
+
* Creates an input field definition.
|
|
54
54
|
*
|
|
55
|
-
* Supports both text and number input types
|
|
56
|
-
* enforced based on the `inputType` using TypeScript generics:
|
|
57
|
-
* - When `inputType` is `'number'`, `defaultValue` must be a `number`
|
|
58
|
-
* - When `inputType` is `'text'`, `defaultValue` must be a `string`
|
|
59
|
-
*
|
|
60
|
-
* This provides compile-time type checking to prevent mismatched types,
|
|
61
|
-
* such as passing a string when a number is expected.
|
|
55
|
+
* Supports both text and number input types for different value types.
|
|
62
56
|
*
|
|
63
57
|
* @experimental This method is experimental and may be subject to change.
|
|
64
58
|
*
|
|
65
59
|
* @typeParam T - The input type ('text' or 'number'), inferred from `config.inputType`
|
|
66
60
|
* @param config - Input field configuration
|
|
61
|
+
* @param config.id - The unique identifier for this field
|
|
67
62
|
* @param config.label - The label displayed for this input field
|
|
68
63
|
* @param config.inputType - The type of input ('text' or 'number')
|
|
69
64
|
* @param config.placeholder - Optional placeholder text for the input
|
|
70
|
-
* @param config.defaultValue - Optional default value (type enforced based on inputType)
|
|
71
65
|
* @returns A complete input field definition with type 'input'
|
|
72
66
|
*
|
|
73
67
|
* @example
|
|
74
68
|
* ```typescript
|
|
75
|
-
* // Number input
|
|
69
|
+
* // Number input
|
|
76
70
|
* styleEditorField.input({
|
|
71
|
+
* id: 'font-size',
|
|
77
72
|
* label: 'Font Size',
|
|
78
73
|
* inputType: 'number',
|
|
79
|
-
* placeholder: 'Enter font size'
|
|
80
|
-
* defaultValue: 16 // ✓ Correct: number
|
|
74
|
+
* placeholder: 'Enter font size'
|
|
81
75
|
* })
|
|
82
76
|
*
|
|
83
|
-
* // Text input
|
|
77
|
+
* // Text input
|
|
84
78
|
* styleEditorField.input({
|
|
79
|
+
* id: 'font-name',
|
|
85
80
|
* label: 'Font Name',
|
|
86
81
|
* inputType: 'text',
|
|
87
|
-
* placeholder: 'Enter font name'
|
|
88
|
-
* defaultValue: 'Arial' // ✓ Correct: string
|
|
89
|
-
* })
|
|
90
|
-
*
|
|
91
|
-
* // TypeScript error - type mismatch
|
|
92
|
-
* styleEditorField.input({
|
|
93
|
-
* label: 'Font Size',
|
|
94
|
-
* inputType: 'number',
|
|
95
|
-
* defaultValue: '16' // ✗ Error: Type 'string' is not assignable to type 'number'
|
|
82
|
+
* placeholder: 'Enter font name'
|
|
96
83
|
* })
|
|
97
84
|
* ```
|
|
98
85
|
*/
|
|
99
86
|
input: <T extends StyleEditorFieldInputType>(config: StyleEditorInputFieldConfig<T>) => StyleEditorInputField;
|
|
100
87
|
/**
|
|
101
|
-
* Creates a dropdown field definition
|
|
88
|
+
* Creates a dropdown field definition.
|
|
102
89
|
*
|
|
103
90
|
* Allows users to select a single value from a list of options.
|
|
104
91
|
* Options can be provided as simple strings or as objects with label and value.
|
|
105
92
|
*
|
|
106
|
-
* **
|
|
93
|
+
* **Best Practice:** Use `as const` when defining options for better type safety:
|
|
107
94
|
* ```typescript
|
|
108
|
-
* const
|
|
109
|
-
* { label: '
|
|
110
|
-
* { label: '
|
|
95
|
+
* const OPTIONS = [
|
|
96
|
+
* { label: '18', value: '18px' },
|
|
97
|
+
* { label: '24', value: '24px' }
|
|
111
98
|
* ] as const;
|
|
112
99
|
*
|
|
113
100
|
* styleEditorField.dropdown({
|
|
114
|
-
* id: '
|
|
115
|
-
* label: '
|
|
116
|
-
* options
|
|
117
|
-
*
|
|
118
|
-
* // defaultValue: 'three' // ✗ TypeScript error: not assignable
|
|
119
|
-
* })
|
|
120
|
-
* ```
|
|
121
|
-
*
|
|
122
|
-
* Without `as const`, the function still works but won't provide autocomplete:
|
|
123
|
-
* ```typescript
|
|
124
|
-
* styleEditorField.dropdown({
|
|
125
|
-
* id: 'my-field',
|
|
126
|
-
* label: 'Select option',
|
|
127
|
-
* options: [
|
|
128
|
-
* { label: 'The one', value: 'one' },
|
|
129
|
-
* { label: 'The two', value: 'two' }
|
|
130
|
-
* ],
|
|
131
|
-
* defaultValue: 'one' // Works, but no autocomplete
|
|
132
|
-
* })
|
|
101
|
+
* id: 'size',
|
|
102
|
+
* label: 'Size',
|
|
103
|
+
* options: OPTIONS
|
|
104
|
+
* });
|
|
133
105
|
* ```
|
|
134
106
|
*
|
|
135
107
|
* @experimental This method is experimental and may be subject to change.
|
|
136
108
|
*
|
|
137
|
-
* @typeParam TOptions - The options array type (inferred from config, use `as const` for type safety)
|
|
138
109
|
* @param config - Dropdown field configuration (without the 'type' property)
|
|
139
110
|
* @param config.id - The unique identifier for this field
|
|
140
111
|
* @param config.label - The label displayed for this dropdown field
|
|
141
|
-
* @param config.options - Array of options. Use `as const` for type safety
|
|
142
|
-
* @param config.defaultValue - Optional default selected value (type-safe when options are `as const`)
|
|
112
|
+
* @param config.options - Array of options. Can be strings or objects with label and value. Use `as const` for best type safety.
|
|
143
113
|
* @returns A complete dropdown field definition with type 'dropdown'
|
|
144
114
|
*
|
|
145
115
|
* @example
|
|
146
116
|
* ```typescript
|
|
147
|
-
* // With type safety - use 'as const' for autocomplete
|
|
148
|
-
* const options = [
|
|
149
|
-
* { label: 'The one', value: 'one' },
|
|
150
|
-
* { label: 'The two', value: 'two' }
|
|
151
|
-
* ] as const;
|
|
152
|
-
*
|
|
153
|
-
* styleEditorField.dropdown({
|
|
154
|
-
* id: 'my-field',
|
|
155
|
-
* label: 'Select option',
|
|
156
|
-
* options,
|
|
157
|
-
* defaultValue: 'one' // ✓ Autocomplete works!
|
|
158
|
-
* })
|
|
159
|
-
*
|
|
160
117
|
* // Simple string options
|
|
161
118
|
* styleEditorField.dropdown({
|
|
162
119
|
* id: 'font-family',
|
|
163
120
|
* label: 'Font Family',
|
|
164
|
-
* options: ['Arial', 'Helvetica', 'Times New Roman']
|
|
165
|
-
* defaultValue: 'Arial',
|
|
166
|
-
* placeholder: 'Select a font'
|
|
121
|
+
* options: ['Arial', 'Helvetica', 'Times New Roman']
|
|
167
122
|
* })
|
|
168
123
|
*
|
|
169
|
-
* // Object options with custom labels
|
|
124
|
+
* // Object options with custom labels (recommended: use 'as const')
|
|
125
|
+
* const OPTIONS = [
|
|
126
|
+
* { label: 'Light Theme', value: 'light' },
|
|
127
|
+
* { label: 'Dark Theme', value: 'dark' }
|
|
128
|
+
* ] as const;
|
|
129
|
+
*
|
|
170
130
|
* styleEditorField.dropdown({
|
|
171
131
|
* id: 'theme',
|
|
172
132
|
* label: 'Theme',
|
|
173
|
-
* options:
|
|
174
|
-
* { label: 'Light Theme', value: 'light' },
|
|
175
|
-
* { label: 'Dark Theme', value: 'dark' }
|
|
176
|
-
* ],
|
|
177
|
-
* defaultValue: 'light'
|
|
133
|
+
* options: OPTIONS
|
|
178
134
|
* })
|
|
179
135
|
* ```
|
|
180
136
|
*/
|
|
181
|
-
dropdown:
|
|
182
|
-
options: TOptions;
|
|
183
|
-
defaultValue?: StyleEditorOptionValues<TOptions>;
|
|
184
|
-
}) => StyleEditorDropdownField;
|
|
137
|
+
dropdown: (config: Omit<StyleEditorDropdownField, "type">) => StyleEditorDropdownField;
|
|
185
138
|
/**
|
|
186
|
-
* Creates a radio button field definition
|
|
139
|
+
* Creates a radio button field definition.
|
|
187
140
|
*
|
|
188
141
|
* Allows users to select a single option from a list. Supports visual
|
|
189
142
|
* options with background images for enhanced UI. Options can be provided
|
|
@@ -193,96 +146,63 @@ export declare const styleEditorField: {
|
|
|
193
146
|
* - `columns: 1` (default): Single column list layout
|
|
194
147
|
* - `columns: 2`: Two-column grid layout, ideal for visual options with images
|
|
195
148
|
*
|
|
196
|
-
* **
|
|
149
|
+
* **Best Practice:** Use `as const` when defining options for better type safety:
|
|
197
150
|
* ```typescript
|
|
198
|
-
* const
|
|
199
|
-
* { label: '
|
|
200
|
-
* { label: '
|
|
151
|
+
* const RADIO_OPTIONS = [
|
|
152
|
+
* { label: 'Left', value: 'left' },
|
|
153
|
+
* { label: 'Right', value: 'right' }
|
|
201
154
|
* ] as const;
|
|
202
155
|
*
|
|
203
156
|
* styleEditorField.radio({
|
|
204
|
-
* id: '
|
|
205
|
-
* label: '
|
|
206
|
-
* options
|
|
207
|
-
*
|
|
208
|
-
* // defaultValue: 'three' // ✗ TypeScript error: not assignable
|
|
209
|
-
* })
|
|
210
|
-
* ```
|
|
211
|
-
*
|
|
212
|
-
* Without `as const`, the function still works but won't provide autocomplete:
|
|
213
|
-
* ```typescript
|
|
214
|
-
* styleEditorField.radio({
|
|
215
|
-
* id: 'my-field',
|
|
216
|
-
* label: 'Select option',
|
|
217
|
-
* options: [
|
|
218
|
-
* { label: 'The one', value: 'one' },
|
|
219
|
-
* { label: 'The two', value: 'two' }
|
|
220
|
-
* ],
|
|
221
|
-
* defaultValue: 'one' // Works, but no autocomplete
|
|
222
|
-
* })
|
|
157
|
+
* id: 'layout',
|
|
158
|
+
* label: 'Layout',
|
|
159
|
+
* options: RADIO_OPTIONS
|
|
160
|
+
* });
|
|
223
161
|
* ```
|
|
224
162
|
*
|
|
225
163
|
* @experimental This method is experimental and may be subject to change.
|
|
226
164
|
*
|
|
227
|
-
* @typeParam TOptions - The options array type (inferred from config, use `as const` for type safety)
|
|
228
165
|
* @param config - Radio field configuration (without the 'type' property)
|
|
229
166
|
* @param config.id - The unique identifier for this field
|
|
230
167
|
* @param config.label - The label displayed for this radio group
|
|
231
|
-
* @param config.options - Array of options. Use `as const` for type safety
|
|
232
|
-
* @param config.defaultValue - Optional default selected value (type-safe when options are `as const`)
|
|
168
|
+
* @param config.options - Array of options. Can be strings or objects with label, value, and optional image properties. Use `as const` for best type safety.
|
|
233
169
|
* @param config.columns - Optional number of columns (1 or 2). Defaults to 1 (single column)
|
|
234
170
|
* @returns A complete radio field definition with type 'radio'
|
|
235
171
|
*
|
|
236
172
|
* @example
|
|
237
173
|
* ```typescript
|
|
238
|
-
* // With type safety - use 'as const' for autocomplete
|
|
239
|
-
* const options = [
|
|
240
|
-
* { label: 'The one', value: 'one' },
|
|
241
|
-
* { label: 'The two', value: 'two' }
|
|
242
|
-
* ] as const;
|
|
243
|
-
*
|
|
244
|
-
* styleEditorField.radio({
|
|
245
|
-
* id: 'my-field',
|
|
246
|
-
* label: 'Select option',
|
|
247
|
-
* options,
|
|
248
|
-
* defaultValue: 'one' // ✓ Autocomplete works!
|
|
249
|
-
* })
|
|
250
|
-
*
|
|
251
174
|
* // Simple string options (single column)
|
|
252
175
|
* styleEditorField.radio({
|
|
253
176
|
* id: 'alignment',
|
|
254
177
|
* label: 'Alignment',
|
|
255
|
-
* options: ['Left', 'Center', 'Right']
|
|
256
|
-
* defaultValue: 'Left'
|
|
178
|
+
* options: ['Left', 'Center', 'Right']
|
|
257
179
|
* })
|
|
258
180
|
*
|
|
259
|
-
* // Two-column grid layout with images
|
|
181
|
+
* // Two-column grid layout with images (recommended: use 'as const')
|
|
182
|
+
* const LAYOUT_OPTIONS = [
|
|
183
|
+
* {
|
|
184
|
+
* label: 'Left',
|
|
185
|
+
* value: 'left',
|
|
186
|
+
* imageURL: 'https://example.com/layout-left.png',
|
|
187
|
+
* },
|
|
188
|
+
* {
|
|
189
|
+
* label: 'Right',
|
|
190
|
+
* value: 'right',
|
|
191
|
+
* imageURL: 'https://example.com/layout-right.png',
|
|
192
|
+
* },
|
|
193
|
+
* { label: 'Center', value: 'center' },
|
|
194
|
+
* { label: 'Overlap', value: 'overlap' }
|
|
195
|
+
* ] as const;
|
|
196
|
+
*
|
|
260
197
|
* styleEditorField.radio({
|
|
261
198
|
* id: 'layout',
|
|
262
199
|
* label: 'Layout',
|
|
263
200
|
* columns: 2,
|
|
264
|
-
* options:
|
|
265
|
-
* {
|
|
266
|
-
* label: 'Left',
|
|
267
|
-
* value: 'left',
|
|
268
|
-
* imageURL: 'https://example.com/layout-left.png',
|
|
269
|
-
* },
|
|
270
|
-
* {
|
|
271
|
-
* label: 'Right',
|
|
272
|
-
* value: 'right',
|
|
273
|
-
* imageURL: 'https://example.com/layout-right.png',
|
|
274
|
-
* },
|
|
275
|
-
* { label: 'Center', value: 'center' },
|
|
276
|
-
* { label: 'Overlap', value: 'overlap' }
|
|
277
|
-
* ],
|
|
278
|
-
* defaultValue: 'right'
|
|
201
|
+
* options: LAYOUT_OPTIONS
|
|
279
202
|
* })
|
|
280
203
|
* ```
|
|
281
204
|
*/
|
|
282
|
-
radio:
|
|
283
|
-
options: TOptions;
|
|
284
|
-
defaultValue?: StyleEditorRadioOptionValues<TOptions>;
|
|
285
|
-
}) => StyleEditorRadioField;
|
|
205
|
+
radio: (config: Omit<StyleEditorRadioField, "type">) => StyleEditorRadioField;
|
|
286
206
|
/**
|
|
287
207
|
* Creates a checkbox group field definition.
|
|
288
208
|
*
|
|
@@ -292,8 +212,7 @@ export declare const styleEditorField: {
|
|
|
292
212
|
*
|
|
293
213
|
* **Key Differences from Other Field Types:**
|
|
294
214
|
* - Uses `key` instead of `value` for the identifier (to avoid confusion)
|
|
295
|
-
* -
|
|
296
|
-
* - No separate `defaultValue` property - defaults are embedded in options
|
|
215
|
+
* - Checked state is managed by the form system, not stored in the option definition
|
|
297
216
|
*
|
|
298
217
|
* **Why `key` instead of `value`?**
|
|
299
218
|
* In dropdown and radio fields, `value` represents the actual selected value (string).
|
|
@@ -306,7 +225,7 @@ export declare const styleEditorField: {
|
|
|
306
225
|
* @param config - Checkbox group field configuration (without the 'type' property)
|
|
307
226
|
* @param config.id - The unique identifier for this field
|
|
308
227
|
* @param config.label - The label displayed for this checkbox group
|
|
309
|
-
* @param config.options - Array of checkbox options with label
|
|
228
|
+
* @param config.options - Array of checkbox options with label and key
|
|
310
229
|
* @returns A complete checkbox group field definition with type 'checkboxGroup'
|
|
311
230
|
*
|
|
312
231
|
* @example
|
|
@@ -315,11 +234,10 @@ export declare const styleEditorField: {
|
|
|
315
234
|
* id: 'text-decoration',
|
|
316
235
|
* label: 'Text Decoration',
|
|
317
236
|
* options: [
|
|
318
|
-
* { label: 'Underline', key: 'underline'
|
|
319
|
-
* { label: 'Overline', key: 'overline'
|
|
320
|
-
* { label: 'Line Through', key: 'line-through'
|
|
237
|
+
* { label: 'Underline', key: 'underline' },
|
|
238
|
+
* { label: 'Overline', key: 'overline' },
|
|
239
|
+
* { label: 'Line Through', key: 'line-through' }
|
|
321
240
|
* ]
|
|
322
|
-
* // No defaultValue needed - it's automatically derived from options
|
|
323
241
|
* })
|
|
324
242
|
*
|
|
325
243
|
* // Example with type settings
|
|
@@ -327,10 +245,10 @@ export declare const styleEditorField: {
|
|
|
327
245
|
* id: 'type-settings',
|
|
328
246
|
* label: 'Type settings',
|
|
329
247
|
* options: [
|
|
330
|
-
* { label: 'Bold', key: 'bold'
|
|
331
|
-
* { label: 'Italic', key: 'italic'
|
|
332
|
-
* { label: 'Underline', key: 'underline'
|
|
333
|
-
* { label: 'Strikethrough', key: 'strikethrough'
|
|
248
|
+
* { label: 'Bold', key: 'bold' },
|
|
249
|
+
* { label: 'Italic', key: 'italic' },
|
|
250
|
+
* { label: 'Underline', key: 'underline' },
|
|
251
|
+
* { label: 'Strikethrough', key: 'strikethrough' }
|
|
334
252
|
* ]
|
|
335
253
|
* })
|
|
336
254
|
* ```
|
|
@@ -368,14 +286,14 @@ export declare const styleEditorField: {
|
|
|
368
286
|
* title: 'Typography',
|
|
369
287
|
* fields: [
|
|
370
288
|
* styleEditorField.input({
|
|
289
|
+
* id: 'font-size',
|
|
371
290
|
* label: 'Font Size',
|
|
372
|
-
* inputType: 'number'
|
|
373
|
-
* defaultValue: 16
|
|
291
|
+
* inputType: 'number'
|
|
374
292
|
* }),
|
|
375
293
|
* styleEditorField.dropdown({
|
|
294
|
+
* id: 'font-family',
|
|
376
295
|
* label: 'Font Family',
|
|
377
|
-
* options: ['Arial', 'Helvetica']
|
|
378
|
-
* defaultValue: 'Arial'
|
|
296
|
+
* options: ['Arial', 'Helvetica']
|
|
379
297
|
* })
|
|
380
298
|
* ]
|
|
381
299
|
* },
|
|
@@ -383,14 +301,14 @@ export declare const styleEditorField: {
|
|
|
383
301
|
* title: 'Colors',
|
|
384
302
|
* fields: [
|
|
385
303
|
* styleEditorField.input({
|
|
304
|
+
* id: 'primary-color',
|
|
386
305
|
* label: 'Primary Color',
|
|
387
|
-
* inputType: 'text'
|
|
388
|
-
* defaultValue: '#000000'
|
|
306
|
+
* inputType: 'text'
|
|
389
307
|
* }),
|
|
390
308
|
* styleEditorField.input({
|
|
309
|
+
* id: 'secondary-color',
|
|
391
310
|
* label: 'Secondary Color',
|
|
392
|
-
* inputType: 'text'
|
|
393
|
-
* defaultValue: '#FFFFFF'
|
|
311
|
+
* inputType: 'text'
|
|
394
312
|
* })
|
|
395
313
|
* ]
|
|
396
314
|
* }
|
|
@@ -433,9 +351,9 @@ export declare function defineStyleEditorSchema(form: StyleEditorForm): StyleEdi
|
|
|
433
351
|
* title: 'Typography',
|
|
434
352
|
* fields: [
|
|
435
353
|
* styleEditorField.input({
|
|
354
|
+
* id: 'font-size',
|
|
436
355
|
* label: 'Font Size',
|
|
437
|
-
* inputType: 'number'
|
|
438
|
-
* defaultValue: 16
|
|
356
|
+
* inputType: 'number'
|
|
439
357
|
* })
|
|
440
358
|
* ]
|
|
441
359
|
* }
|