@timeax/form-palette 0.0.29 → 0.0.30
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 +416 -122
- package/dist/adapter-CvjXO9Gi.d.mts +253 -0
- package/dist/adapter-CvjXO9Gi.d.ts +253 -0
- package/dist/adapters.d.mts +5 -252
- package/dist/adapters.d.ts +5 -252
- package/dist/adapters.js +13 -2618
- package/dist/adapters.js.map +1 -1
- package/dist/adapters.mjs +11 -2620
- package/dist/adapters.mjs.map +1 -1
- package/dist/extra.d.mts +127 -0
- package/dist/extra.d.ts +127 -0
- package/dist/extra.js +26347 -0
- package/dist/extra.js.map +1 -0
- package/dist/extra.mjs +26303 -0
- package/dist/extra.mjs.map +1 -0
- package/dist/index.d.mts +11 -3792
- package/dist/index.d.ts +11 -3792
- package/dist/index.js +4514 -3996
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4438 -3921
- package/dist/index.mjs.map +1 -1
- package/dist/variant-BPDyK780.d.mts +4337 -0
- package/dist/variant-v0LBdshU.d.ts +4337 -0
- package/package.json +8 -2
package/Readme.md
CHANGED
|
@@ -46,13 +46,24 @@ Common props (apply to most variants):
|
|
|
46
46
|
- name: unique field key
|
|
47
47
|
- variant: which control to render (see Variant reference below)
|
|
48
48
|
- label, sublabel: title and a small inline hint
|
|
49
|
-
- description
|
|
50
|
-
- errorText: force an error message (
|
|
49
|
+
- description, helpText: helper copy under the control
|
|
50
|
+
- errorText: force an error message (visual override)
|
|
51
51
|
- required, disabled, readOnly
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
52
|
+
- onChange(e): e.value holds the new value; e.detail provides extra context (source, meta)
|
|
53
|
+
- onValidate(value, field, form): custom validation logic (returns string | boolean)
|
|
54
|
+
- size: "sm" | "md" | "lg"
|
|
55
|
+
- density: "compact" | "comfortable" | "loose"
|
|
56
|
+
- labelPlacement, sublabelPlacement, descriptionPlacement, helpTextPlacement, errorTextPlacement: customize layout ("top" | "bottom" | "left" | "right" | "below")
|
|
57
|
+
- inline, fullWidth, contain: layout flags
|
|
58
|
+
- tags: array of tag objects { label, icon, className, color, bgColor }
|
|
59
|
+
- className, labelClassName, sublabelClassName, descriptionClassName, helpTextClassName, errorClassName, groupClassName, contentClassName, variantClassName: targeting specific parts of the field chrome
|
|
60
|
+
|
|
61
|
+
Input decoration props (available for text, number, color, phone, select, multi-select, date):
|
|
62
|
+
- icon, prefix, suffix, leadingControl, trailingControl: decorate the input box
|
|
63
|
+
- leadingIcons, trailingIcons: arrays of React nodes
|
|
64
|
+
- iconGap, leadingIconSpacing, trailingIconSpacing: spacing controls
|
|
65
|
+
- joinControls, extendBoxToControls: visual integration for controls
|
|
66
|
+
- leadingControlClassName, trailingControlClassName: decoration styling
|
|
56
67
|
|
|
57
68
|
Example with decorations and validation:
|
|
58
69
|
|
|
@@ -92,7 +103,7 @@ Note on options: selection controls accept options as primitives ("US") or objec
|
|
|
92
103
|
|
|
93
104
|
1) text
|
|
94
105
|
- Value: string | undefined
|
|
95
|
-
-
|
|
106
|
+
- Props: mask, slotChar, unmask, autoClear (phone-like masking); prefix, suffix, stripPrefix, stripSuffix, inputClassName
|
|
96
107
|
- Example:
|
|
97
108
|
```tsx
|
|
98
109
|
<InputField name="email" label="Email" variant="text" />
|
|
@@ -100,7 +111,12 @@ Note on options: selection controls accept options as primitives ("US") or objec
|
|
|
100
111
|
|
|
101
112
|
2) number
|
|
102
113
|
- Value: number | undefined
|
|
103
|
-
- Props:
|
|
114
|
+
- Props:
|
|
115
|
+
- min, max, step, showButtons, buttonLayout ("stacked" | "inline")
|
|
116
|
+
- mode: "decimal" | "currency"
|
|
117
|
+
- currency, currencyDisplay, currencySymbol
|
|
118
|
+
- locale, useGrouping, minFractionDigits, maxFractionDigits
|
|
119
|
+
- roundingMode, allowEmpty
|
|
104
120
|
- Example:
|
|
105
121
|
```tsx
|
|
106
122
|
<InputField name="age" label="Age" variant="number" min={0} max={120} step={1} showButtons />
|
|
@@ -108,61 +124,100 @@ Note on options: selection controls accept options as primitives ("US") or objec
|
|
|
108
124
|
|
|
109
125
|
3) password
|
|
110
126
|
- Value: string | undefined
|
|
111
|
-
- Props:
|
|
127
|
+
- Props:
|
|
128
|
+
- revealToggle: boolean (show eye icon); default true
|
|
129
|
+
- defaultRevealed, onRevealChange, renderToggleIcon, toggleAriaLabel, toggleButtonClassName
|
|
130
|
+
- strengthMeter: boolean | StrengthOptions (calc, labels, thresholds, minScore, showLabel, display)
|
|
131
|
+
- meterStyle: "simple" | "rules"
|
|
132
|
+
- ruleDefinitions, ruleUses: customize validation rules
|
|
133
|
+
- meterWrapperClassName, meterContainerClassName, meterBarClassName, meterLabelClassName
|
|
134
|
+
- Example:
|
|
135
|
+
```tsx
|
|
136
|
+
<InputField name="pwd" label="Password" variant="password" revealToggle strengthMeter meterStyle="rules" />
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
4) date
|
|
140
|
+
- Value: Date | DateRange | undefined
|
|
141
|
+
- Props:
|
|
142
|
+
- mode: "single" | "range"
|
|
143
|
+
- kind: "date" | "datetime" | "time" | "hour" | "monthYear" | "year"
|
|
144
|
+
- formatSingle, formatRange, rangeSeparator
|
|
145
|
+
- minDate, maxDate, disabledDays, stayOpenOnSelect
|
|
146
|
+
- showTime, timeMode ("dropdown" | "input"), timeStep, timeLabel
|
|
147
|
+
- clearable, calendarClassName, popoverClassName
|
|
112
148
|
- Example:
|
|
113
149
|
```tsx
|
|
114
|
-
<InputField name="
|
|
150
|
+
<InputField name="appointment" variant="date" kind="datetime" label="Appointment" />
|
|
115
151
|
```
|
|
116
152
|
|
|
117
|
-
|
|
153
|
+
5) color
|
|
118
154
|
- Value: string | undefined (hex or css color)
|
|
119
|
-
- Props: showPreview, previewButtonClassName
|
|
155
|
+
- Props: showPreview, showPickerToggle, previewSize, previewButtonClassName, previewSwatchClassName, pickerInputClassName, pickerToggleIcon, wrapperClassName
|
|
120
156
|
- Example:
|
|
121
157
|
```tsx
|
|
122
158
|
<InputField name="color" label="Favorite colour" variant="color" showPreview />
|
|
123
159
|
```
|
|
124
160
|
|
|
125
|
-
|
|
161
|
+
6) phone
|
|
126
162
|
- Value: string | undefined
|
|
127
|
-
-
|
|
128
|
-
-
|
|
163
|
+
- Props:
|
|
164
|
+
- countries: PhoneCountry[] (custom list of available countries)
|
|
165
|
+
- defaultCountry: string (ISO code, e.g. "US")
|
|
166
|
+
- valueMode: "masked" | "e164" | "national"
|
|
167
|
+
- showFlag, showSelectedDial, showDialInList, showCountry, showSelectedLabel
|
|
168
|
+
- keepCharPositions, countrySelectClassName, countryTriggerClassName
|
|
169
|
+
- Typical usage:
|
|
129
170
|
```tsx
|
|
130
171
|
<InputField
|
|
131
172
|
name="phone"
|
|
132
173
|
label="Phone"
|
|
133
|
-
variant="
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
autoClear
|
|
174
|
+
variant="phone"
|
|
175
|
+
defaultCountry="US"
|
|
176
|
+
valueMode="e164"
|
|
137
177
|
/>
|
|
138
178
|
```
|
|
139
179
|
|
|
140
|
-
|
|
180
|
+
7) textarea
|
|
141
181
|
- Value: string | undefined
|
|
142
|
-
- Usual textarea props like placeholder, rows, etc.
|
|
182
|
+
- Usual textarea props like placeholder, rows, cols, resize, etc.
|
|
143
183
|
- Example:
|
|
144
184
|
```tsx
|
|
145
185
|
<InputField name="bio" label="Bio" variant="textarea" description="Tell us about you" />
|
|
146
186
|
```
|
|
147
187
|
|
|
148
|
-
|
|
188
|
+
8) toggle
|
|
149
189
|
- Value: boolean | undefined
|
|
190
|
+
- Props: size, density, controlPlacement ("left" | "right"), onText, offText, switchClassName, switchThumbClassName
|
|
150
191
|
- Example:
|
|
151
192
|
```tsx
|
|
152
|
-
<InputField name="tos" variant="toggle" label="Accept Terms" required />
|
|
193
|
+
<InputField name="tos" variant="toggle" label="Accept Terms" onText="Yes" offText="No" required />
|
|
153
194
|
```
|
|
154
195
|
|
|
155
|
-
|
|
156
|
-
- Value: string | number | undefined
|
|
157
|
-
- Props:
|
|
196
|
+
9) toggle-group
|
|
197
|
+
- Value: string | string[] | number | undefined
|
|
198
|
+
- Props:
|
|
199
|
+
- options: primitives or objects
|
|
200
|
+
- multiple, variant ("default" | "outline"), layout ("horizontal" | "vertical" | "grid"), gridCols, fillWidth
|
|
201
|
+
- optionValue, optionLabel, optionIcon, optionDisabled, optionTooltip, optionMeta: mapping keys
|
|
202
|
+
- Example:
|
|
203
|
+
```tsx
|
|
204
|
+
<InputField
|
|
205
|
+
name="size"
|
|
206
|
+
variant="toggle-group"
|
|
207
|
+
options={["sm", "md", "lg"]}
|
|
208
|
+
/>
|
|
209
|
+
```
|
|
158
210
|
|
|
159
|
-
|
|
160
|
-
- Value:
|
|
211
|
+
10) radio
|
|
212
|
+
- Value: any (selected value)
|
|
161
213
|
- Props:
|
|
162
|
-
- options: primitives or objects
|
|
163
|
-
- layout
|
|
164
|
-
- size
|
|
165
|
-
-
|
|
214
|
+
- options: primitives or objects
|
|
215
|
+
- layout: "list" | "grid"; columns, itemGapPx
|
|
216
|
+
- size, density, autoCap
|
|
217
|
+
- optionValue, optionLabel, optionDescription, optionDisabled
|
|
218
|
+
- mappers: { getValue, getLabel, getDescription, isDisabled, getKey }
|
|
219
|
+
- renderOption: (ctx) => ReactNode
|
|
220
|
+
- groupClassName, optionClassName, labelClassName, descriptionClassName
|
|
166
221
|
- Example:
|
|
167
222
|
```tsx
|
|
168
223
|
<InputField
|
|
@@ -176,8 +231,17 @@ Note on options: selection controls accept options as primitives ("US") or objec
|
|
|
176
231
|
/>
|
|
177
232
|
```
|
|
178
233
|
|
|
179
|
-
|
|
180
|
-
- Value: boolean
|
|
234
|
+
11) checkbox
|
|
235
|
+
- Value: boolean (single) | CheckboxGroupEntry[] (group)
|
|
236
|
+
- Props:
|
|
237
|
+
- options: primitives or objects (for group mode)
|
|
238
|
+
- single: boolean (switches to single-checkbox mode)
|
|
239
|
+
- tristate: boolean (enables indeterminate state)
|
|
240
|
+
- layout: "list" | "grid"; columns, itemGapPx
|
|
241
|
+
- size, density, autoCap
|
|
242
|
+
- optionValue, optionLabel, renderOption
|
|
243
|
+
- mappers: { getValue, getLabel, getDescription, isDisabled, getKey, getTristate }
|
|
244
|
+
- groupClassName, optionClassName, labelClassName, optionLabelClassName, descriptionClassName
|
|
181
245
|
- Single boolean checkbox:
|
|
182
246
|
```tsx
|
|
183
247
|
<InputField variant="checkbox" label="Remember me" />
|
|
@@ -191,30 +255,21 @@ Note on options: selection controls accept options as primitives ("US") or objec
|
|
|
191
255
|
options={[
|
|
192
256
|
{ value: "read", label: "Read content" },
|
|
193
257
|
{ value: "write", label: "Write content" },
|
|
194
|
-
{ value: "delete", label: "Delete content" },
|
|
195
258
|
]}
|
|
196
259
|
/>
|
|
197
260
|
```
|
|
198
261
|
|
|
199
|
-
|
|
200
|
-
- single?: boolean switches to single‑checkbox mode (value becomes boolean | undefined)
|
|
201
|
-
- tristate?: boolean enables an indeterminate state for single or per‑item
|
|
202
|
-
- layout?: "list" | "grid"; columns?: number (grid mode)
|
|
203
|
-
- size?: "sm" | "md" | "lg"; density?: "compact" | "comfortable" | "loose"
|
|
204
|
-
|
|
205
|
-
11) select
|
|
262
|
+
12) select
|
|
206
263
|
- Value: string | number | undefined
|
|
207
|
-
- Props
|
|
208
|
-
- options:
|
|
209
|
-
- searchable
|
|
210
|
-
-
|
|
211
|
-
-
|
|
212
|
-
-
|
|
213
|
-
-
|
|
214
|
-
-
|
|
215
|
-
-
|
|
216
|
-
- optionLabel, optionValue, optionDescription, optionDisabled, optionIcon, optionKey: map/compute option pieces
|
|
217
|
-
- renderOption?: (ctx) => ReactNode (custom row rendering; per‑option render overrides this)
|
|
264
|
+
- Props:
|
|
265
|
+
- options: primitives or objects
|
|
266
|
+
- searchable, searchPlaceholder, clearable, placeholder, autoCap
|
|
267
|
+
- emptyLabel, emptySearchText
|
|
268
|
+
- mode: "default" | "button"; button: ReactNode | ((ctx) => ReactNode)
|
|
269
|
+
- virtualScroll, virtualScrollPageSize, virtualScrollThreshold
|
|
270
|
+
- optionLabel, optionValue, optionDescription, optionDisabled, optionIcon, optionKey
|
|
271
|
+
- renderOption, renderValue: custom renderers
|
|
272
|
+
- triggerClassName, contentClassName
|
|
218
273
|
- Example:
|
|
219
274
|
```tsx
|
|
220
275
|
<InputField
|
|
@@ -222,20 +277,22 @@ Note on options: selection controls accept options as primitives ("US") or objec
|
|
|
222
277
|
variant="select"
|
|
223
278
|
label="Country"
|
|
224
279
|
options={[{ label: "USA", value: "US" }, { label: "Canada", value: "CA" }]}
|
|
225
|
-
placeholder="Select a country"
|
|
226
280
|
searchable
|
|
227
281
|
clearable
|
|
228
282
|
/>
|
|
229
283
|
```
|
|
230
284
|
|
|
231
|
-
|
|
232
|
-
- Value: (string|number)[] | undefined
|
|
233
|
-
- Props:
|
|
234
|
-
-
|
|
235
|
-
- clearable
|
|
236
|
-
-
|
|
237
|
-
-
|
|
238
|
-
-
|
|
285
|
+
13) multi-select
|
|
286
|
+
- Value: (string | number)[] | undefined
|
|
287
|
+
- Props:
|
|
288
|
+
- options: primitives or objects
|
|
289
|
+
- searchable, searchPlaceholder, clearable, placeholder, autoCap
|
|
290
|
+
- showSelectAll, selectAllLabel, selectAllPosition
|
|
291
|
+
- mode: "default" | "button"; button: ReactNode | ((ctx) => ReactNode)
|
|
292
|
+
- maxListHeight
|
|
293
|
+
- optionLabel, optionValue, optionDescription, optionDisabled, optionIcon, optionKey
|
|
294
|
+
- renderOption, renderValue, renderCheckbox
|
|
295
|
+
- triggerClassName, contentClassName
|
|
239
296
|
- Example:
|
|
240
297
|
```tsx
|
|
241
298
|
<InputField
|
|
@@ -246,83 +303,155 @@ Note on options: selection controls accept options as primitives ("US") or objec
|
|
|
246
303
|
/>
|
|
247
304
|
```
|
|
248
305
|
|
|
249
|
-
|
|
250
|
-
- Value: string[] |
|
|
251
|
-
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
-
|
|
255
|
-
-
|
|
306
|
+
14) chips
|
|
307
|
+
- Value: string[] | undefined
|
|
308
|
+
- Props:
|
|
309
|
+
- placeholder, separators (string | RegExp), allowDuplicates, maxChips
|
|
310
|
+
- addOnEnter, addOnTab, addOnBlur, backspaceRemovesLast
|
|
311
|
+
- clearable, textareaMode, placement ("inline" | "below")
|
|
312
|
+
- maxVisibleChips, maxChipChars, maxChipWidth
|
|
313
|
+
- renderChip, renderOverflowChip
|
|
314
|
+
- onAddChips, onRemoveChips
|
|
315
|
+
- chipsClassName, chipClassName, chipLabelClassName, chipRemoveClassName, inputClassName
|
|
256
316
|
- Example:
|
|
257
317
|
```tsx
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
const regionOptions: TreeSelectOption[] = [
|
|
261
|
-
{ label: "Africa", value: "africa", children: [{ label: "Nigeria", value: "ng" }] },
|
|
262
|
-
{ label: "Europe", value: "europe" },
|
|
263
|
-
];
|
|
264
|
-
|
|
265
|
-
<InputField
|
|
266
|
-
name="regions"
|
|
267
|
-
label="Regions"
|
|
268
|
-
variant="treeselect"
|
|
269
|
-
options={regionOptions}
|
|
270
|
-
/>
|
|
318
|
+
<InputField name="keywords" variant="chips" label="Keywords" />
|
|
271
319
|
```
|
|
272
320
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
-
|
|
277
|
-
- autoCap
|
|
321
|
+
15) treeselect
|
|
322
|
+
- Value: TreeKey | TreeKey[] | undefined
|
|
323
|
+
- Props:
|
|
324
|
+
- options: TreeSelectOption[]
|
|
325
|
+
- multiple, searchable, clearable, placeholder, autoCap
|
|
326
|
+
- expandAll, defaultExpandedValues, leafOnly
|
|
327
|
+
- mode: "default" | "button"; button: ReactNode | ((ctx) => ReactNode)
|
|
328
|
+
- selectedBadge, selectedBadgeVariant, selectedBadgePlacement
|
|
278
329
|
- optionLabel, optionValue, optionDescription, optionDisabled, optionIcon, optionKey
|
|
279
|
-
-
|
|
280
|
-
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
330
|
+
- renderOption, renderValue
|
|
331
|
+
- triggerClassName, contentClassName
|
|
332
|
+
- Example:
|
|
333
|
+
```tsx
|
|
334
|
+
<InputField name="regions" variant="treeselect" options={regionOptions} />
|
|
335
|
+
```
|
|
285
336
|
|
|
286
|
-
|
|
287
|
-
- Value: number |
|
|
288
|
-
- Props:
|
|
337
|
+
16) slider
|
|
338
|
+
- Value: number | undefined
|
|
339
|
+
- Props:
|
|
340
|
+
- min, max, step
|
|
341
|
+
- showValue, valuePlacement ("start" | "end")
|
|
342
|
+
- formatValue: (val) => ReactNode
|
|
343
|
+
- sliderClassName, valueClassName
|
|
344
|
+
- Example:
|
|
345
|
+
```tsx
|
|
346
|
+
<InputField name="volume" variant="slider" min={0} max={100} />
|
|
347
|
+
```
|
|
289
348
|
|
|
290
|
-
|
|
291
|
-
- Value:
|
|
292
|
-
-
|
|
293
|
-
-
|
|
349
|
+
17) file
|
|
350
|
+
- Value: FileItem[] | undefined
|
|
351
|
+
- Props:
|
|
352
|
+
- multiple, accept, maxFiles, maxTotalSize
|
|
353
|
+
- showDropArea, dropIcon, dropTitle, dropDescription
|
|
354
|
+
- renderDropArea, renderFileItem, showCheckboxes
|
|
355
|
+
- onFilesAdded, customLoader, mergeMode ("append" | "replace")
|
|
356
|
+
- formatFileName, formatFileSize
|
|
357
|
+
- mode: "default" | "button"; button: ReactNode | ((ctx) => ReactNode)
|
|
358
|
+
- selectedBadge, selectedBadgeVariant, selectedBadgePlacement
|
|
359
|
+
- dropAreaClassName, listClassName, triggerClassName
|
|
360
|
+
- Example:
|
|
294
361
|
```tsx
|
|
295
|
-
<InputField name="
|
|
362
|
+
<InputField name="attachments" variant="file" multiple />
|
|
296
363
|
```
|
|
297
364
|
|
|
298
|
-
|
|
365
|
+
18) keyvalue
|
|
299
366
|
- Value: Record<string, string> | undefined
|
|
300
|
-
-
|
|
367
|
+
- Props:
|
|
368
|
+
- min, max, minVisible, maxVisible
|
|
369
|
+
- showAddButton, showMenuButton, dialogTitle
|
|
370
|
+
- keyLabel, valueLabel, submitLabel, emptyLabel, moreLabel
|
|
371
|
+
- chipsClassName, chipClassName, renderChip
|
|
372
|
+
- Example:
|
|
373
|
+
```tsx
|
|
374
|
+
<InputField name="headers" variant="keyvalue" label="HTTP Headers" />
|
|
375
|
+
```
|
|
301
376
|
|
|
302
|
-
|
|
377
|
+
19) editor
|
|
303
378
|
- Value: string | undefined (HTML or Markdown)
|
|
304
|
-
-
|
|
305
|
-
-
|
|
306
|
-
-
|
|
307
|
-
-
|
|
308
|
-
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
379
|
+
- Props:
|
|
380
|
+
- format: "html" | "markdown"
|
|
381
|
+
- toolbar: "default" | "none" | ToastToolbarItem[][]
|
|
382
|
+
- height, placeholder, editType ("wysiwyg" | "markdown"), previewStyle ("vertical" | "tab")
|
|
383
|
+
- pastePlainText, useCommandShortcut
|
|
384
|
+
- Example:
|
|
385
|
+
```tsx
|
|
386
|
+
<InputField name="content" variant="editor" format="markdown" />
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
20) lister
|
|
390
|
+
- Value: ListerId | ListerId[] | undefined
|
|
391
|
+
- Advanced picker for remote/large datasets. Requires `ListerProvider` and `ListerUI` from `@timeax/form-palette/extra`.
|
|
392
|
+
- Props:
|
|
393
|
+
- def: `ListerDefinition` (the remote data engine)
|
|
394
|
+
- endpoint, method, buildRequest, selector: inline remote config
|
|
395
|
+
- filters, filtersSpec, initialQuery: initial state and filter UI configuration
|
|
396
|
+
- search, searchTarget, searchMode: control search behavior and targets
|
|
397
|
+
- mode: "single" | "multiple"
|
|
398
|
+
- confirm: boolean (for single mode); permissions: array of strings
|
|
399
|
+
- title, clearable, maxDisplayItems, showRefresh, refreshMode
|
|
400
|
+
- optionValue, optionLabel, optionIcon, optionDescription, optionDisabled, optionGroup, optionMeta: mapping keys (accepts key string or mapper function)
|
|
401
|
+
- renderTrigger, renderOption: custom rendering hooks
|
|
402
|
+
- panelClassName, contentClassName, triggerClassName
|
|
403
|
+
- leadingIcons, trailingIcons, icon, leadingControl, trailingControl, joinControls, extendBoxToControls: standard input decoration
|
|
404
|
+
- Example:
|
|
405
|
+
```tsx
|
|
406
|
+
<InputField
|
|
407
|
+
name="user"
|
|
408
|
+
variant="lister"
|
|
409
|
+
endpoint="/api/users"
|
|
410
|
+
optionLabel="fullName"
|
|
411
|
+
optionValue="id"
|
|
412
|
+
/>
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
21) json-editor
|
|
416
|
+
- Value: JsonObject | undefined
|
|
417
|
+
- Advanced visual editor for complex JSON structures.
|
|
418
|
+
- Props:
|
|
419
|
+
- title, schema: header text and validation schema (JSON Schema or ID)
|
|
420
|
+
- fieldMap, layout, defaults: configure how JSON keys are rendered as form fields
|
|
421
|
+
- nav, filters, permissions, callbacks: behavior and access control
|
|
422
|
+
- mode: "popover" | "accordion" (wrapper display mode)
|
|
423
|
+
- triggerLabel, triggerVariant, triggerSize: customize the trigger button (popover mode)
|
|
424
|
+
- route, defaultRoute, onRouteChange: navigation control (JSON path)
|
|
425
|
+
- viewMode, defaultViewMode, onViewModeChange: "split" | "visual" | "raw"
|
|
426
|
+
- renderRouteLabel, renderField: custom rendering hooks
|
|
427
|
+
- contentClassName, navClassName, triggerClassName, popoverClassName, panelClassName
|
|
428
|
+
- leadingIcons, trailingIcons, icon, leadingControl, trailingControl, joinControls, extendBoxToControls: standard input decoration (for popover trigger)
|
|
312
429
|
- Example:
|
|
313
430
|
```tsx
|
|
314
431
|
<InputField
|
|
315
|
-
name="
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
height="400px"
|
|
432
|
+
name="config"
|
|
433
|
+
variant="json-editor"
|
|
434
|
+
title="App Configuration"
|
|
435
|
+
mode="popover"
|
|
436
|
+
triggerLabel="Edit App Config"
|
|
321
437
|
/>
|
|
322
438
|
```
|
|
323
439
|
|
|
324
|
-
|
|
325
|
-
-
|
|
440
|
+
22) custom
|
|
441
|
+
- Props:
|
|
442
|
+
- component: ReactComponent to render
|
|
443
|
+
- valueProp, changeProp, disabledProp, readOnlyProp, errorProp, idProp, nameProp, placeholderProp
|
|
444
|
+
- mapValue, mapDetail: transform values on the way out/in
|
|
445
|
+
- Example:
|
|
446
|
+
```tsx
|
|
447
|
+
<InputField
|
|
448
|
+
name="custom"
|
|
449
|
+
variant="custom"
|
|
450
|
+
component={MyCustomInput}
|
|
451
|
+
valueProp="currentValue"
|
|
452
|
+
changeProp="onMyChange"
|
|
453
|
+
/>
|
|
454
|
+
```
|
|
326
455
|
|
|
327
456
|
---
|
|
328
457
|
|
|
@@ -351,6 +480,7 @@ Password with strength meter:
|
|
|
351
480
|
placeholder="Enter your password"
|
|
352
481
|
strengthMeter
|
|
353
482
|
meterStyle="rules"
|
|
483
|
+
revealToggle
|
|
354
484
|
/>
|
|
355
485
|
```
|
|
356
486
|
|
|
@@ -420,8 +550,172 @@ function Example() {
|
|
|
420
550
|
- Prefer InputField over wiring controls by hand; it gives you consistent labels, descriptions, and error placement.
|
|
421
551
|
- Use options as primitives for quick setups, or objects when you need description/disabled/icon per item.
|
|
422
552
|
- Use validate for quick client checks; you can also set errorText manually.
|
|
423
|
-
- For grouped controls (radios/checkbox groups), pass options
|
|
424
|
-
-
|
|
553
|
+
- For grouped controls (radios/checkbox groups), pass `options`; for a single boolean, omit `options` and use `variant="checkbox"`.
|
|
554
|
+
- Use `variant="date"` with `kind` to switch between date, time, and datetime pickers.
|
|
555
|
+
- For complex data, `variant="lister"` provides a powerful remote search/picker UI.
|
|
556
|
+
- Use `onValidate` for quick client checks; return a string for the error message or `true` if valid.
|
|
557
|
+
|
|
558
|
+
---
|
|
559
|
+
|
|
560
|
+
### Advanced providers and standalone usage
|
|
561
|
+
|
|
562
|
+
Some components like `lister` or `json-editor` can be used as standalone utilities outside of `InputField` or even outside of a `Form`.
|
|
563
|
+
|
|
564
|
+
#### 1. Lister System (ListerProvider & ListerUI)
|
|
565
|
+
|
|
566
|
+
The `lister` variant relies on a global engine for remote data fetching, caching, and state management. You must place `ListerProvider` at the root of your app and include `ListerUI` to render the floating selection panels.
|
|
567
|
+
|
|
568
|
+
```tsx
|
|
569
|
+
import { ListerProvider, ListerUI } from "@timeax/form-palette/extra";
|
|
570
|
+
|
|
571
|
+
const listerHost = {
|
|
572
|
+
can: (perms) => true,
|
|
573
|
+
log: (entry) => console.log(entry.message),
|
|
574
|
+
};
|
|
575
|
+
|
|
576
|
+
function App() {
|
|
577
|
+
return (
|
|
578
|
+
<ListerProvider host={listerHost}>
|
|
579
|
+
{/* ... your app ... */}
|
|
580
|
+
<ListerUI />
|
|
581
|
+
</ListerProvider>
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
**ListerProvider props:**
|
|
587
|
+
- `host`: `ListerProviderHost` (Required) - Handles permissions (`can`) and global logging (`log`).
|
|
588
|
+
- `presets`: `PresetMap` - Registry of named `ListerDefinition` objects.
|
|
589
|
+
- `http`: `ListerHttpClient` - Custom HTTP client (e.g., axios wrapper).
|
|
590
|
+
- `remoteDebounceMs`: `number` (default: 300).
|
|
591
|
+
|
|
592
|
+
**Programmatic usage with `useLister`:**
|
|
593
|
+
|
|
594
|
+
You can trigger a lister picker from anywhere in your app (e.g., a custom button) using the `useLister` hook.
|
|
595
|
+
|
|
596
|
+
```tsx
|
|
597
|
+
import { useLister } from "@timeax/form-palette/extra";
|
|
598
|
+
|
|
599
|
+
function CustomButton() {
|
|
600
|
+
const { api } = useLister();
|
|
601
|
+
|
|
602
|
+
async function pickUser() {
|
|
603
|
+
// Open the lister UI and wait for selection
|
|
604
|
+
const result = await api.open({
|
|
605
|
+
source: { endpoint: "/api/users" },
|
|
606
|
+
mapping: { optionLabel: "fullName", optionValue: "id" }
|
|
607
|
+
}, {}, {
|
|
608
|
+
title: "Select a User",
|
|
609
|
+
mode: "single"
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
if (result.reason === "apply") {
|
|
613
|
+
console.log("Selected user ID:", result.value);
|
|
614
|
+
console.log("Full user object:", result.details.raw);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
return <button onClick={pickUser}>Choose User</button>;
|
|
619
|
+
}
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
- `api.open(def | kind, filters, options)`: Returns a promise that resolves when the user applies, cancels, or closes the lister.
|
|
623
|
+
- `api.fetch(def | kind, filters, options)`: Fetches data using the lister engine without opening the UI.
|
|
624
|
+
|
|
625
|
+
---
|
|
626
|
+
|
|
627
|
+
#### 2. JSON Editor Standalone
|
|
628
|
+
|
|
629
|
+
While `InputField variant="json-editor"` is convenient for forms, you can use the `JsonEditor` component directly for full-page editors or custom configuration screens.
|
|
630
|
+
|
|
631
|
+
```tsx
|
|
632
|
+
import { JsonEditor } from "@timeax/form-palette/extra";
|
|
633
|
+
|
|
634
|
+
function ConfigPage() {
|
|
635
|
+
const [config, setConfig] = useState({ theme: "dark", notifications: true });
|
|
636
|
+
|
|
637
|
+
return (
|
|
638
|
+
<div className="h-[600px] border rounded">
|
|
639
|
+
<JsonEditor
|
|
640
|
+
root={config}
|
|
641
|
+
onRoot={setConfig}
|
|
642
|
+
title="Site Configuration"
|
|
643
|
+
mode="accordion"
|
|
644
|
+
viewMode="split"
|
|
645
|
+
fieldMap={{
|
|
646
|
+
"theme": { variant: "select", options: ["light", "dark"] },
|
|
647
|
+
"notifications": { variant: "toggle" }
|
|
648
|
+
}}
|
|
649
|
+
/>
|
|
650
|
+
</div>
|
|
651
|
+
);
|
|
652
|
+
}
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
##### Props for `JsonEditor` (Standalone)
|
|
656
|
+
|
|
657
|
+
| Prop | Type | Description |
|
|
658
|
+
| :--- | :--- | :--- |
|
|
659
|
+
| `root` | `JsonObject` | The JSON object to edit (Controlled). |
|
|
660
|
+
| `onRoot` | `(next: JsonObject, detail: ChangeDetail) => void` | Callback when the JSON structure changes. |
|
|
661
|
+
| `title` | `ReactNode` | Header title displayed at the top. |
|
|
662
|
+
| `schema` | `string \| JsonObject` | Optional JSON Schema for validation. |
|
|
663
|
+
| `mode` | `"popover" \| "accordion"` | `"popover"` shows a trigger; `"accordion"` is inline. |
|
|
664
|
+
| `viewMode` | `"split" \| "visual" \| "raw"` | Visual vs Code editor vs both. |
|
|
665
|
+
| `fieldMap` | `JsonEditorFieldMap` | Map JSON paths to specific `InputField` variants. |
|
|
666
|
+
| `layout` | `JsonEditorLayoutMap` | Define the visual order and grouping of fields. |
|
|
667
|
+
| `defaults` | `JsonEditorDefaults` | Default values and variant-level defaults. |
|
|
668
|
+
| `nav` | `JsonEditorNavOptions` | Configure sidebar navigation and hierarchical views. |
|
|
669
|
+
| `filters` | `JsonEditorFilters` | Include or exclude specific JSON paths. |
|
|
670
|
+
| `permissions` | `JsonEditorPermissions` | Read-only vs Read-Write controls per path. |
|
|
671
|
+
| `callbacks` | `JsonEditorCallbacks` | Callbacks for `onAdd`, `onDelete`, `onEdit`. |
|
|
672
|
+
|
|
673
|
+
---
|
|
674
|
+
|
|
675
|
+
### Full Technical Reference (Advanced)
|
|
676
|
+
|
|
677
|
+
#### Lister System Types
|
|
678
|
+
|
|
679
|
+
**ListerProvider Props**
|
|
680
|
+
|
|
681
|
+
| Prop | Type | Description |
|
|
682
|
+
| :--- | :--- | :--- |
|
|
683
|
+
| `host` | `ListerProviderHost` | **Required**. Handles permissions (`can`) and logging (`log`). |
|
|
684
|
+
| `presets` | `PresetMap` | Map of pre-defined lister configurations. |
|
|
685
|
+
| `http` | `ListerHttpClient` | Custom client for data fetching. |
|
|
686
|
+
| `remoteDebounceMs`| `number` | Debounce for remote search (default 300ms). |
|
|
687
|
+
|
|
688
|
+
**ListerDefinition (Engine config)**
|
|
689
|
+
|
|
690
|
+
| Prop | Type | Description |
|
|
691
|
+
| :--- | :--- | :--- |
|
|
692
|
+
| `source` | `ListerSource` | Remote URL and request builder. |
|
|
693
|
+
| `mapping` | `ListerMapping` | How raw data maps to value/label/icon/etc. |
|
|
694
|
+
| `selector` | `Selector` | Extraction path from API response (default `body.data`). |
|
|
695
|
+
| `search` | `ListerSearchSpec` | Search behavior and column targets. |
|
|
696
|
+
|
|
697
|
+
**ListerOpenOptions (api.open / api.fetch options)**
|
|
698
|
+
|
|
699
|
+
| Prop | Type | Description |
|
|
700
|
+
| :--- | :--- | :--- |
|
|
701
|
+
| `mode` | `"single" \| "multiple"` | Selection mode. |
|
|
702
|
+
| `confirm` | `boolean` | Require explicit "Apply" button in single mode. |
|
|
703
|
+
| `defaultValue`| `any` | Initial selection. |
|
|
704
|
+
| `permissions`| `string[]` | Permission keys required for this session. |
|
|
705
|
+
| `searchMode` | `ListerSearchMode` | "local", "remote", or "hybrid". |
|
|
706
|
+
| `title` | `string` | UI title for the popover. |
|
|
707
|
+
| `filtersSpec` | `ListerFilterSpec` | Specification for the filter UI. |
|
|
708
|
+
|
|
709
|
+
#### JSON Editor Types
|
|
710
|
+
|
|
711
|
+
**JsonEditorFieldMap Entry**
|
|
712
|
+
|
|
713
|
+
| Prop | Type | Description |
|
|
714
|
+
| :--- | :--- | :--- |
|
|
715
|
+
| `variant` | `VariantKey` | Which `@timeax/form-palette` variant to use. |
|
|
716
|
+
| `props` | `VariantProps` | Props passed to the variant. |
|
|
717
|
+
| `label` | `string` | Display label for this field. |
|
|
718
|
+
| `description`| `string` | Help text shown under the field. |
|
|
425
719
|
|
|
426
720
|
---
|
|
427
721
|
|