@timeax/form-palette 0.0.26 → 0.0.28
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/dist/index.d.mts +330 -8
- package/dist/index.d.ts +330 -8
- package/dist/index.js +3195 -683
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3194 -684
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -7
package/dist/index.d.mts
CHANGED
|
@@ -3014,7 +3014,7 @@ type NormalizedSelectItem = {
|
|
|
3014
3014
|
/**
|
|
3015
3015
|
* Shadcn-based Select variant.
|
|
3016
3016
|
*/
|
|
3017
|
-
interface
|
|
3017
|
+
interface SelectBaseProps extends Pick<VariantBaseProps<SelectPrimitive | undefined>, "value" | "onValue" | "error" | "disabled" | "readOnly" | "size" | "density"> {
|
|
3018
3018
|
/**
|
|
3019
3019
|
* Options for the select.
|
|
3020
3020
|
*
|
|
@@ -3119,13 +3119,6 @@ interface ShadcnSelectVariantProps extends Pick<VariantBaseProps<SelectPrimitive
|
|
|
3119
3119
|
selectedItem: NormalizedSelectItem | null;
|
|
3120
3120
|
placeholder?: React.ReactNode;
|
|
3121
3121
|
}) => React.ReactNode;
|
|
3122
|
-
/**
|
|
3123
|
-
* One or more icons displayed inside the trigger, on the left.
|
|
3124
|
-
*
|
|
3125
|
-
* If not provided and `icon` is set, that single icon
|
|
3126
|
-
* is treated as `leadingIcons[0]`.
|
|
3127
|
-
*/
|
|
3128
|
-
leadingIcons?: React.ReactNode[];
|
|
3129
3122
|
/**
|
|
3130
3123
|
* Icons displayed on the right side of the trigger,
|
|
3131
3124
|
* near the clear button / chevron area.
|
|
@@ -3192,6 +3185,51 @@ interface ShadcnSelectVariantProps extends Pick<VariantBaseProps<SelectPrimitive
|
|
|
3192
3185
|
*/
|
|
3193
3186
|
virtualScrollThreshold?: number;
|
|
3194
3187
|
}
|
|
3188
|
+
type SelectDefaultModeProps = {
|
|
3189
|
+
mode?: "default";
|
|
3190
|
+
leadingIcons?: React.ReactNode[];
|
|
3191
|
+
trailingIcons?: React.ReactNode[];
|
|
3192
|
+
icon?: React.ReactNode;
|
|
3193
|
+
iconGap?: number;
|
|
3194
|
+
leadingIconSpacing?: number;
|
|
3195
|
+
trailingIconSpacing?: number;
|
|
3196
|
+
leadingControl?: React.ReactNode;
|
|
3197
|
+
trailingControl?: React.ReactNode;
|
|
3198
|
+
leadingControlClassName?: string;
|
|
3199
|
+
trailingControlClassName?: string;
|
|
3200
|
+
joinControls?: boolean;
|
|
3201
|
+
extendBoxToControls?: boolean;
|
|
3202
|
+
button?: never;
|
|
3203
|
+
children?: never;
|
|
3204
|
+
};
|
|
3205
|
+
type SelectButtonModeButton = React.ReactNode | ((ctx: {
|
|
3206
|
+
open: boolean;
|
|
3207
|
+
selectedItem: NormalizedSelectItem | null;
|
|
3208
|
+
selectedValue: SelectPrimitive | undefined;
|
|
3209
|
+
placeholder?: React.ReactNode;
|
|
3210
|
+
}) => React.ReactNode);
|
|
3211
|
+
type SelectButtonModeProps = {
|
|
3212
|
+
mode: "button";
|
|
3213
|
+
/**
|
|
3214
|
+
* Used when mode="button". If provided, this is the trigger.
|
|
3215
|
+
* If not provided, `children` is used.
|
|
3216
|
+
*/
|
|
3217
|
+
button?: SelectButtonModeButton;
|
|
3218
|
+
children?: SelectButtonModeButton;
|
|
3219
|
+
leadingIcons?: never;
|
|
3220
|
+
trailingIcons?: never;
|
|
3221
|
+
icon?: never;
|
|
3222
|
+
iconGap?: never;
|
|
3223
|
+
leadingIconSpacing?: never;
|
|
3224
|
+
trailingIconSpacing?: never;
|
|
3225
|
+
leadingControl?: never;
|
|
3226
|
+
trailingControl?: never;
|
|
3227
|
+
leadingControlClassName?: never;
|
|
3228
|
+
trailingControlClassName?: never;
|
|
3229
|
+
joinControls?: never;
|
|
3230
|
+
extendBoxToControls?: never;
|
|
3231
|
+
};
|
|
3232
|
+
type ShadcnSelectVariantProps = SelectBaseProps & (SelectDefaultModeProps | SelectButtonModeProps);
|
|
3195
3233
|
|
|
3196
3234
|
type SelectVariantProps = ShadcnSelectVariantProps;
|
|
3197
3235
|
|
|
@@ -3319,6 +3357,289 @@ interface ShadcnEditorVariantProps extends Pick<VariantBaseProps<string | undefi
|
|
|
3319
3357
|
className?: string;
|
|
3320
3358
|
}
|
|
3321
3359
|
|
|
3360
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
3361
|
+
type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
|
|
3362
|
+
type JsonObject = Record<string, JsonValue>;
|
|
3363
|
+
type JsonPath = string;
|
|
3364
|
+
type JsonWildcard = string;
|
|
3365
|
+
|
|
3366
|
+
/**
|
|
3367
|
+
* A "variant spec" can be:
|
|
3368
|
+
* - a plain VariantKey ("text", "number", "toggle", ...)
|
|
3369
|
+
* - a variant key + props to pass into that variant
|
|
3370
|
+
*/
|
|
3371
|
+
type JsonEditorVariantSpec = VariantKey | {
|
|
3372
|
+
variant: VariantKey;
|
|
3373
|
+
props?: VariantPropsFor<any>;
|
|
3374
|
+
};
|
|
3375
|
+
/**
|
|
3376
|
+
* Map a key-path (or wildcard) to a variant spec.
|
|
3377
|
+
*
|
|
3378
|
+
* Keys are matched against:
|
|
3379
|
+
* - full path: "config.apiEndpoint"
|
|
3380
|
+
* - leaf key: "apiEndpoint"
|
|
3381
|
+
*
|
|
3382
|
+
* Wild examples:
|
|
3383
|
+
* - "*api*" (segment contains "api")
|
|
3384
|
+
* - "config.*" (direct children)
|
|
3385
|
+
* - "config.**" (subtree)
|
|
3386
|
+
* - "**.*token*" (any route/leaf)
|
|
3387
|
+
*/
|
|
3388
|
+
type JsonEditorFieldMap = Record<JsonWildcard, JsonEditorVariantSpec>;
|
|
3389
|
+
/**
|
|
3390
|
+
* Layout is scoped to a "page" (object route path).
|
|
3391
|
+
*
|
|
3392
|
+
* Each entry is a "row":
|
|
3393
|
+
* - string: render a single field row
|
|
3394
|
+
* - string[]: render these fields side-by-side (grid row)
|
|
3395
|
+
*
|
|
3396
|
+
* Example:
|
|
3397
|
+
* layout: {
|
|
3398
|
+
* "": [["projectName","version"], "description"],
|
|
3399
|
+
* "config": [["maxEntries","apiEndpoint"], "retry"]
|
|
3400
|
+
* }
|
|
3401
|
+
*/
|
|
3402
|
+
type JsonEditorLayoutRow = string | string[];
|
|
3403
|
+
type JsonEditorLayoutMap = Record<JsonWildcard, JsonEditorLayoutRow[]>;
|
|
3404
|
+
interface JsonEditorFilters {
|
|
3405
|
+
/** Hide entire object routes/pages (navigation + rendering) */
|
|
3406
|
+
excludeRoutes?: JsonWildcard[];
|
|
3407
|
+
includeRoutes?: JsonWildcard[];
|
|
3408
|
+
/** Hide specific fields (by full path or leaf/wild patterns) */
|
|
3409
|
+
excludeFields?: JsonWildcard[];
|
|
3410
|
+
includeFields?: JsonWildcard[];
|
|
3411
|
+
/**
|
|
3412
|
+
* If true, excluding "config" also excludes "config.**".
|
|
3413
|
+
* Default: true
|
|
3414
|
+
*/
|
|
3415
|
+
excludeRouteSubtree?: boolean;
|
|
3416
|
+
}
|
|
3417
|
+
/**
|
|
3418
|
+
* Default value for a newly created key (or a new array item).
|
|
3419
|
+
* Can be a constant JsonValue, or a function.
|
|
3420
|
+
*/
|
|
3421
|
+
type JsonEditorDefaultValueSpec = JsonValue | ((ctx: {
|
|
3422
|
+
parentPath: JsonPath;
|
|
3423
|
+
key: string;
|
|
3424
|
+
current: JsonValue | undefined;
|
|
3425
|
+
}) => JsonValue);
|
|
3426
|
+
interface JsonEditorDefaults {
|
|
3427
|
+
/**
|
|
3428
|
+
* When adding a new array item, you can pick from allowed variants.
|
|
3429
|
+
* You can pass VariantKey or a {variant, props} spec.
|
|
3430
|
+
*/
|
|
3431
|
+
array?: JsonEditorVariantSpec[];
|
|
3432
|
+
/**
|
|
3433
|
+
* Optional default values for new keys.
|
|
3434
|
+
* Keyed by wildcard path (full path / leaf / patterns).
|
|
3435
|
+
*/
|
|
3436
|
+
values?: Record<JsonWildcard, JsonEditorDefaultValueSpec>;
|
|
3437
|
+
}
|
|
3438
|
+
type JsonEditorNavMode = "sidebar" | "tabs" | "drawer";
|
|
3439
|
+
interface JsonEditorNavOptions {
|
|
3440
|
+
mode?: JsonEditorNavMode;
|
|
3441
|
+
/** Show root "" as a page in navigation. Default: true */
|
|
3442
|
+
showRoot?: boolean;
|
|
3443
|
+
/** Initial active route/page. Default: "" */
|
|
3444
|
+
defaultRoute?: JsonPath;
|
|
3445
|
+
/** Optional label overrides for route nodes */
|
|
3446
|
+
routeLabels?: Record<JsonWildcard, React.ReactNode>;
|
|
3447
|
+
/** Max object nesting to generate routes for. Optional safety */
|
|
3448
|
+
maxDepth?: number;
|
|
3449
|
+
/**
|
|
3450
|
+
* Whether arrays containing objects can contribute routes.
|
|
3451
|
+
* - "none": arrays never create routes (default)
|
|
3452
|
+
* - "objects": array items that are objects become routes like "config.items.0"
|
|
3453
|
+
*/
|
|
3454
|
+
arrayRoutes?: "none" | "objects";
|
|
3455
|
+
}
|
|
3456
|
+
interface JsonRouteNode {
|
|
3457
|
+
path: JsonPath;
|
|
3458
|
+
key: string;
|
|
3459
|
+
label: React.ReactNode;
|
|
3460
|
+
children: JsonRouteNode[];
|
|
3461
|
+
}
|
|
3462
|
+
type JsonEditorViewMode = "split" | "visual" | "raw";
|
|
3463
|
+
interface JsonEditorPermissions {
|
|
3464
|
+
canAdd?: boolean;
|
|
3465
|
+
canDelete?: boolean;
|
|
3466
|
+
canViewRaw?: boolean;
|
|
3467
|
+
canEditRaw?: boolean;
|
|
3468
|
+
/**
|
|
3469
|
+
* Keys/paths in this shape cannot be deleted even if canDelete is true.
|
|
3470
|
+
* (treated as "locked")
|
|
3471
|
+
*/
|
|
3472
|
+
defaultShape?: JsonObject;
|
|
3473
|
+
/**
|
|
3474
|
+
* Optional finer-grain locks by wildcard.
|
|
3475
|
+
* If true, this key/path cannot be added/deleted/edited.
|
|
3476
|
+
*/
|
|
3477
|
+
lockPaths?: JsonWildcard[];
|
|
3478
|
+
}
|
|
3479
|
+
type JsonEditorEditAction = "add" | "delete" | "edit" | "edit-raw";
|
|
3480
|
+
interface JsonEditorEditMeta {
|
|
3481
|
+
action: JsonEditorEditAction;
|
|
3482
|
+
/** the page (object route) currently being edited */
|
|
3483
|
+
route: JsonPath;
|
|
3484
|
+
/** the exact key path being changed (field path) */
|
|
3485
|
+
path: JsonPath;
|
|
3486
|
+
/** parent object path of the key */
|
|
3487
|
+
parent: JsonPath;
|
|
3488
|
+
/** leaf key (segment) */
|
|
3489
|
+
key: string;
|
|
3490
|
+
}
|
|
3491
|
+
interface JsonEditorCallbacks {
|
|
3492
|
+
onAdd?: (nextRoot: JsonObject, meta: JsonEditorEditMeta) => void;
|
|
3493
|
+
onDelete?: (nextRoot: JsonObject, meta: JsonEditorEditMeta) => void;
|
|
3494
|
+
onEdit?: (nextRoot: JsonObject, meta: JsonEditorEditMeta) => void;
|
|
3495
|
+
}
|
|
3496
|
+
interface JsonEditorResolvedField {
|
|
3497
|
+
path: JsonPath;
|
|
3498
|
+
key: string;
|
|
3499
|
+
value: JsonValue;
|
|
3500
|
+
valueType: "string" | "number" | "boolean" | "null" | "object" | "array";
|
|
3501
|
+
variant?: JsonEditorVariantSpec;
|
|
3502
|
+
hidden?: boolean;
|
|
3503
|
+
}
|
|
3504
|
+
/**
|
|
3505
|
+
* This is the "shared" props contract for the JSON editor variant UI.
|
|
3506
|
+
*
|
|
3507
|
+
* NOTE:
|
|
3508
|
+
* - `title` is purely UI (header text)
|
|
3509
|
+
* - `schema` is NOT a title — it’s a schema id/key for validation (later use)
|
|
3510
|
+
*/
|
|
3511
|
+
interface ShadcnJsonEditorVariantProps extends Pick<VariantBaseProps<JsonObject | undefined>, "value" | "onValue" | "error" | "disabled" | "readOnly"> {
|
|
3512
|
+
/** Header title (UI only) */
|
|
3513
|
+
title?: React.ReactNode;
|
|
3514
|
+
/** Optional schema id/key or raw JSON Schema object for validation */
|
|
3515
|
+
schema?: string | JsonObject;
|
|
3516
|
+
/** Primary config */
|
|
3517
|
+
fieldMap?: JsonEditorFieldMap;
|
|
3518
|
+
layout?: JsonEditorLayoutMap;
|
|
3519
|
+
defaults?: JsonEditorDefaults;
|
|
3520
|
+
/** Navigation derived from JSON structure */
|
|
3521
|
+
nav?: JsonEditorNavOptions;
|
|
3522
|
+
/** include/exclude for routes + fields */
|
|
3523
|
+
filters?: JsonEditorFilters;
|
|
3524
|
+
/** permissions + locks */
|
|
3525
|
+
permissions?: JsonEditorPermissions;
|
|
3526
|
+
/** callbacks */
|
|
3527
|
+
callbacks?: JsonEditorCallbacks;
|
|
3528
|
+
/**
|
|
3529
|
+
* Page rendering mode:
|
|
3530
|
+
* - "accordion": page sections expand/collapse in main panel
|
|
3531
|
+
* - "popover": nested objects open as overlays (optional UX)
|
|
3532
|
+
*/
|
|
3533
|
+
mode?: "accordion" | "popover";
|
|
3534
|
+
/**
|
|
3535
|
+
* Routing:
|
|
3536
|
+
* - route: controlled current page
|
|
3537
|
+
* - defaultRoute: uncontrolled initial page (overrides nav.defaultRoute)
|
|
3538
|
+
* - onRouteChange: called whenever the editor navigates
|
|
3539
|
+
*/
|
|
3540
|
+
route?: JsonPath;
|
|
3541
|
+
defaultRoute?: JsonPath;
|
|
3542
|
+
onRouteChange?: (route: JsonPath) => void;
|
|
3543
|
+
/**
|
|
3544
|
+
* View mode (top toggle):
|
|
3545
|
+
* - "split": raw sidebar + visual editor (default)
|
|
3546
|
+
* - "visual": visual editor only
|
|
3547
|
+
* - "raw": raw editor only
|
|
3548
|
+
*
|
|
3549
|
+
* If viewMode is provided, it is controlled.
|
|
3550
|
+
* Otherwise, the defaultViewMode seeds the internal state.
|
|
3551
|
+
*/
|
|
3552
|
+
viewMode?: JsonEditorViewMode;
|
|
3553
|
+
defaultViewMode?: JsonEditorViewMode;
|
|
3554
|
+
onViewModeChange?: (mode: JsonEditorViewMode) => void;
|
|
3555
|
+
/** Close button intent (optional). Actual close UI is controlled by the wrapper (index.tsx). */
|
|
3556
|
+
onClose?: () => void;
|
|
3557
|
+
/** Visual (editor-level styling) */
|
|
3558
|
+
className?: string;
|
|
3559
|
+
contentClassName?: string;
|
|
3560
|
+
navClassName?: string;
|
|
3561
|
+
/**
|
|
3562
|
+
* Optional hooks to customize nav + page rendering.
|
|
3563
|
+
*/
|
|
3564
|
+
renderRouteLabel?: (ctx: {
|
|
3565
|
+
node: JsonRouteNode;
|
|
3566
|
+
active: boolean;
|
|
3567
|
+
}) => React.ReactNode;
|
|
3568
|
+
renderField?: (ctx: {
|
|
3569
|
+
field: JsonEditorResolvedField;
|
|
3570
|
+
route: JsonPath;
|
|
3571
|
+
}) => React.ReactNode;
|
|
3572
|
+
}
|
|
3573
|
+
/**
|
|
3574
|
+
* Wrapper mode:
|
|
3575
|
+
* - "popover": show trigger + popover
|
|
3576
|
+
* - "accordion": inline panel that can expand/collapse
|
|
3577
|
+
*/
|
|
3578
|
+
type JsonEditorMode = "popover" | "accordion";
|
|
3579
|
+
/**
|
|
3580
|
+
* Typed to match your shadcn button variants/sizes.
|
|
3581
|
+
* If your project differs, change these unions here once.
|
|
3582
|
+
*/
|
|
3583
|
+
type JsonEditorTriggerVariant = "default" | "destructive" | "outline" | "secondary" | "ghost" | "link";
|
|
3584
|
+
type JsonEditorTriggerSize = "default" | "sm" | "lg" | "icon";
|
|
3585
|
+
/**
|
|
3586
|
+
* Standalone wiring:
|
|
3587
|
+
* - caller provides root/onRoot directly
|
|
3588
|
+
*/
|
|
3589
|
+
type JsonEditorStandaloneWiring = {
|
|
3590
|
+
root: JsonObject;
|
|
3591
|
+
onRoot: (nextRoot: JsonObject, detail?: any) => void;
|
|
3592
|
+
value?: never;
|
|
3593
|
+
onValue?: never;
|
|
3594
|
+
};
|
|
3595
|
+
/**
|
|
3596
|
+
* Variant wiring:
|
|
3597
|
+
* - InputField variant uses value/onValue
|
|
3598
|
+
*/
|
|
3599
|
+
type JsonEditorVariantWiring = Pick<VariantBaseProps<JsonObject | undefined>, "value" | "onValue" | "disabled" | "readOnly" | "error" | "size" | "density"> & {
|
|
3600
|
+
root?: never;
|
|
3601
|
+
onRoot?: never;
|
|
3602
|
+
};
|
|
3603
|
+
/**
|
|
3604
|
+
* Props for the exported component (index.tsx):
|
|
3605
|
+
* - accepts standalone OR variant wiring
|
|
3606
|
+
* - wrapper owns mode/open/trigger UI
|
|
3607
|
+
* - editor-specific props are passed through, without redefining a second type list
|
|
3608
|
+
*
|
|
3609
|
+
* IMPORTANT:
|
|
3610
|
+
* - wrapper uses `wrapperClassName` (outer container)
|
|
3611
|
+
* - editor uses `className` (inner editor surface)
|
|
3612
|
+
*/
|
|
3613
|
+
interface JsonEditorWrapperProps {
|
|
3614
|
+
/** Wrapper mode (popover vs accordion). */
|
|
3615
|
+
mode?: JsonEditorMode;
|
|
3616
|
+
/** Trigger UI (popover mode) */
|
|
3617
|
+
triggerLabel?: React.ReactNode;
|
|
3618
|
+
triggerVariant?: JsonEditorTriggerVariant;
|
|
3619
|
+
triggerSize?: JsonEditorTriggerSize;
|
|
3620
|
+
/** Popover sizing/skin */
|
|
3621
|
+
popoverClassName?: string;
|
|
3622
|
+
/** Inline/accordion container class */
|
|
3623
|
+
panelClassName?: string;
|
|
3624
|
+
/** Outer wrapper class */
|
|
3625
|
+
wrapperClassName?: string;
|
|
3626
|
+
/** Optional: controlled popover open state */
|
|
3627
|
+
open?: boolean;
|
|
3628
|
+
onOpenChange?: (open: boolean) => void;
|
|
3629
|
+
/** Accessibility (useful when rendered as an InputField variant) */
|
|
3630
|
+
id?: string;
|
|
3631
|
+
describedBy?: string;
|
|
3632
|
+
/** Called when the wrapper closes (popover close / accordion hide). */
|
|
3633
|
+
onClose?: () => void;
|
|
3634
|
+
}
|
|
3635
|
+
/**
|
|
3636
|
+
* Single source of truth for what index.tsx accepts:
|
|
3637
|
+
* - (standalone OR variant wiring)
|
|
3638
|
+
* - wrapper props
|
|
3639
|
+
* - editor props (minus a few keys owned by wrapper)
|
|
3640
|
+
*/
|
|
3641
|
+
type ShadcnJsonEditorProps = (JsonEditorStandaloneWiring | JsonEditorVariantWiring) & JsonEditorWrapperProps & Omit<ShadcnJsonEditorVariantProps, "onValue" | "value" | "disabled" | "readOnly" | "error" | "size" | "density" | "onClose">;
|
|
3642
|
+
|
|
3322
3643
|
/**
|
|
3323
3644
|
* Helper type for a single variant registry entry.
|
|
3324
3645
|
*
|
|
@@ -3374,6 +3695,7 @@ interface Variants<H = unknown> {
|
|
|
3374
3695
|
treeselect: VariantEntry<string | number | undefined, ShadcnTreeSelectVariantProps>;
|
|
3375
3696
|
file: VariantEntry<FileLike, ShadcnFileVariantProps>;
|
|
3376
3697
|
editor: VariantEntry<string | undefined, ShadcnEditorVariantProps>;
|
|
3698
|
+
'json-editor': VariantEntry<JsonObject | undefined, ShadcnJsonEditorProps>;
|
|
3377
3699
|
}
|
|
3378
3700
|
/**
|
|
3379
3701
|
* Union of all variant keys.
|