@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 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/helpText: helper copy under the control
50
- - errorText: force an error message (or rely on validation)
49
+ - description, helpText: helper copy under the control
50
+ - errorText: force an error message (visual override)
51
51
  - required, disabled, readOnly
52
- - icon, prefix, suffix, leadingControl, trailingControl: decorate the input content
53
- - contain: force the input and label to share a tile-like container
54
- - validate(value, report): return true | false | string for simple inline validation
55
- - onChange(detail): detail.value holds the new value; prevent default if you need to override
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
- - Nice extras: mask, slotChar, unmask, autoClear (phone-like masking); icon/prefix/suffix; searchable isn’t applicable here
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: min, max, step, showButtons
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: showToggle; strengthMeter; meterStyle="rules" | "bar" (depending on preset)
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="pwd" label="Password" variant="password" showToggle strengthMeter meterStyle="rules" />
150
+ <InputField name="appointment" variant="date" kind="datetime" label="Appointment" />
115
151
  ```
116
152
 
117
- 4) color
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
- 5) phone
161
+ 6) phone
126
162
  - Value: string | undefined
127
- - Typical usage uses masking controls the same way as text: mask, slotChar, unmask, autoClear
128
- - Example (from playground labeled "Phone"):
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="text" // or a dedicated phone variant if enabled in your build
134
- mask="+99 99 999 999? x999"
135
- slotChar="_"
136
- autoClear
174
+ variant="phone"
175
+ defaultCountry="US"
176
+ valueMode="e164"
137
177
  />
138
178
  ```
139
179
 
140
- 6) textarea
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
- 7) toggle
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
- 8) toggle-group
156
- - Value: string | number | undefined (selected item)
157
- - Props: options (primitives or objects), layout/density sizing depending on preset
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
- 9) radio
160
- - Value: string | number | undefined
211
+ 10) radio
212
+ - Value: any (selected value)
161
213
  - Props:
162
- - options: primitives or objects with { value, label, description?, disabled? }
163
- - layout?: "list" | "grid" (default "list"); columns?: number (when layout="grid")
164
- - size?: "sm" | "md" | "lg"; density?: "compact" | "comfortable" | "loose"
165
- - You can also map custom item shapes via optionValue/optionLabel style mappers depending on preset
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
- 10) checkbox
180
- - Value: boolean | string[] | number[] depending on single vs group usage
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
- - Extras:
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 (high‑use):
208
- - options: (string|number)[] | { label?, value?, description?, disabled?, icon?, ... }[]
209
- - searchable?: boolean (inline search box)
210
- - searchPlaceholder?: string (placeholder inside the search box)
211
- - clearable?: boolean (show clear button)
212
- - placeholder?: string
213
- - autoCap?: boolean (capitalise label text)
214
- - emptyLabel?: React.ReactNode (shown when there are no options)
215
- - emptySearchText?: React.ReactNode (shown when search returns no results)
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
- 12) multi-select
232
- - Value: (string|number)[] | undefined
233
- - Props: same mapping props as select (optionLabel, optionValue, optionDescription, optionDisabled, optionIcon, optionKey)
234
- - searchable?: boolean; searchPlaceholder?: string
235
- - clearable?: boolean; placeholder?: React.ReactNode
236
- - autoCap?: boolean
237
- - emptyLabel?: React.ReactNode; emptySearchText?: React.ReactNode
238
- - renderOption?: (ctx) => ReactNode (custom row rendering; per‑option render overrides this)
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
- 13) chips
250
- - Value: string[] | number[] | undefined
251
- - Free‑form or from options; often used to add/remove tokens
252
-
253
- 14) treeselect
254
- - Value: (string|number)[] | string | number | undefined (single or multiple tree selection)
255
- - Option type: TreeSelectOption = { label, value, icon?, description?, children?: TreeSelectOption[] }
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
- import { TreeSelectOption } from "@timeax/form-palette/presets/shadcn-variants/tree-select-types";
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
- - Props (high‑use):
274
- - multiple?: boolean (default true). If false, single‑select behaviour.
275
- - searchable?: boolean; searchPlaceholder?: string
276
- - clearable?: boolean; placeholder?: React.ReactNode
277
- - autoCap?: boolean
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
- - emptyLabel?: React.ReactNode; emptySearchText?: React.ReactNode
280
- - renderOption?: ({ item, selected, option, click }) => ReactNode
281
- - renderValue?: ({ selectedItems, placeholder }) => ReactNode (custom trigger content)
282
- - expandAll?: boolean; defaultExpandedValues?: (string|number)[]
283
- - leafOnly?: boolean (only leaf nodes are selectable)
284
- - mode?: "default" | "button"; when "button", you can provide a custom trigger and show a selected‑count badge
330
+ - renderOption, renderValue
331
+ - triggerClassName, contentClassName
332
+ - Example:
333
+ ```tsx
334
+ <InputField name="regions" variant="treeselect" options={regionOptions} />
335
+ ```
285
336
 
286
- 15) slider
287
- - Value: number | [number, number] depending on range mode
288
- - Props: min, max, step; possibly range/multiple depending on preset
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
- 16) file
291
- - Value: File | File[] | Custom file shape depending on configuration
292
- - Types: FileItem, CustomFileLoader, FileLike are exported from the preset if you need advanced control
293
- - Example (simple):
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="avatar" label="Avatar" variant="file" />
362
+ <InputField name="attachments" variant="file" multiple />
296
363
  ```
297
364
 
298
- 17) keyvalue
365
+ 18) keyvalue
299
366
  - Value: Record<string, string> | undefined
300
- - Use to capture arbitrary key/value pairs
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
- 18) editor
377
+ 19) editor
303
378
  - Value: string | undefined (HTML or Markdown)
304
- - Requires host CSS import once in your app:
305
- - import "@toast-ui/editor/dist/toastui-editor.css";
306
- - Props (high‑use):
307
- - format?: "html" | "markdown" (stored value format; default "html")
308
- - toolbar?: "default" | "none" | ToastToolbarItem[][]
309
- - height?: string (e.g., "400px"), placeholder?: string
310
- - editType?: "wysiwyg" | "markdown"; previewStyle?: "vertical" | "tab"
311
- - pastePlainText?: boolean (force plain text on paste)
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="content"
316
- label="Content"
317
- variant="editor"
318
- format="markdown"
319
- toolbar="default"
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
- 19) custom
325
- - Bring your own control but still benefit from InputField’s layout and validation chrome
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; for a single boolean, omit options.
424
- - Keep labels short and place longer helper copy into description/helpText.
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