@timeax/form-palette 0.0.19 → 0.0.21

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.ts CHANGED
@@ -2,14 +2,14 @@ import * as React from 'react';
2
2
  import React__default, { RefObject, ComponentType } from 'react';
3
3
  import { z } from 'zod';
4
4
  import { Method, AdapterResult, AdapterKey, AdapterProps, AdapterSubmit } from './adapters.js';
5
- export { AdapterCallbacks, AdapterConfig, AdapterError, AdapterFactory, AdapterOk, Adapters, NamedAdapterConfig, NamedAdapterFactory, createAxiosAdapter, createInertiaAdapter, getAdapter, hasAdapter, localAdapter, registerAdapter, registerAxiosAdapter, registerInertiaAdapter, registerKnownAdapter } from './adapters.js';
5
+ export { AdapterCallbacks, AdapterConfig, AdapterError, AdapterFactory, AdapterOk, Adapters, NamedAdapterConfig, NamedAdapterFactory, createAxiosAdapter, createInertiaAdapter, getAdapter, hasAdapter, localAdapter, registerAdapter, registerAllAdapters, registerAxiosAdapter, registerInertiaAdapter, registerKnownAdapter } from './adapters.js';
6
6
  import * as react_jsx_runtime from 'react/jsx-runtime';
7
7
  import { DayPicker } from 'react-day-picker';
8
8
  import * as class_variance_authority_types from 'class-variance-authority/types';
9
9
  import { VariantProps } from 'class-variance-authority';
10
10
  import * as SwitchPrimitive from '@radix-ui/react-switch';
11
11
  import { $ZodError } from 'zod/v4/core';
12
- import './../../../../node_modules/@inertiajs/core/types/types.d';
12
+ import '@inertiajs/core';
13
13
  import 'axios';
14
14
 
15
15
  /**
@@ -251,21 +251,40 @@ declare class BinderRegistry<V extends Dict = Dict> {
251
251
  /**
252
252
  * Central store for all fields registered with the core runtime.
253
253
  *
254
- * Responsibilities:
255
- * - Keep a stable list of Field instances (no duplicates).
256
- * - Only track fields that have at least one identifier:
257
- * - name (non-empty, trimmed)
258
- * - bindId
259
- * - groupId
260
- * - Provide convenient lookup methods:
261
- * - all / getAllNamed / getAllBound / getAllGrouped
262
- * - getByName / getAllByName
263
- * - getByGroupId / getAllByGroupId
264
- * - getByBind / getAllByBind (binder semantics, prefer mounted)
254
+ * Goals:
255
+ * - Keep stable Field references (no cloning).
256
+ * - Prefer mounted fields for all “get” operations.
257
+ * - Prune stale/detached fields opportunistically.
265
258
  */
266
259
  declare class FieldRegistry {
267
260
  #private;
268
261
  private list;
262
+ private getEl;
263
+ /** Mounted = has an element and that element is currently in the DOM. */
264
+ private isMounted;
265
+ /**
266
+ * Detached = has an element but it is NOT currently in the DOM.
267
+ * Note: if ref.current is null, we treat it as “unknown” (do NOT prune).
268
+ */
269
+ private isDetached;
270
+ /** Mounted-first stable ordering (does not mutate input). */
271
+ private sortMountedFirst;
272
+ /** Prefer the first mounted candidate; else fall back to first candidate. */
273
+ private pickPreferred;
274
+ /**
275
+ * Remove detached fields.
276
+ *
277
+ * IMPORTANT: We only remove entries that have a non-null ref.current AND are
278
+ * not in the DOM. We do not remove “unknown” (null-ref) fields because they
279
+ * may be in the process of mounting.
280
+ */
281
+ private pruneDetached;
282
+ /**
283
+ * Remove detached fields that conflict with an incoming field by identifier.
284
+ * This prevents stale “same-name / same-bindId / same-groupId” entries from
285
+ * hijacking lookups.
286
+ */
287
+ private pruneDetachedConflicts;
269
288
  /**
270
289
  * Whether this field should be tracked at all.
271
290
  *
@@ -274,7 +293,12 @@ declare class FieldRegistry {
274
293
  hasIdentifier(field: Field): boolean;
275
294
  /**
276
295
  * Add a field to the registry if it has an identifier.
277
- * Duplicate instances are ignored.
296
+ *
297
+ * Rules:
298
+ * - Opportunistically prune detached fields.
299
+ * - Prune detached conflicts (same name/bindId/groupId) before adding.
300
+ * - If the same field instance is already tracked, ignore.
301
+ * - If the same key already exists (rare), prefer mounted; otherwise replace.
278
302
  */
279
303
  add(field: Field): void;
280
304
  /**
@@ -286,40 +310,37 @@ declare class FieldRegistry {
286
310
  */
287
311
  clear(): void;
288
312
  /**
289
- * All fields tracked by this registry.
313
+ * All fields tracked by this registry (mounted-first).
290
314
  */
291
315
  all(): Field[];
292
- /** All fields that have a non-empty name. */
316
+ /** All fields that have a non-empty name (mounted-first). */
293
317
  getAllNamed(): Field[];
294
- /** All fields that have a bindId. */
318
+ /** All fields that have a bindId (mounted-first). */
295
319
  getAllBound(): Field[];
296
- /** All fields that have a groupId. */
320
+ /** All fields that have a groupId (mounted-first). */
297
321
  getAllGrouped(): Field[];
298
322
  /**
299
323
  * First field with a given name (exact, trimmed match).
300
324
  *
301
- * Note: expects the raw name used by the field, e.g.:
302
- * "email" or "tags[]"
325
+ * Behaviour:
326
+ * - Prefer a field whose ref is currently in the DOM.
327
+ * - If none are mounted, fall back to the first matching field.
303
328
  */
304
329
  getByName(name: string): Field | undefined;
305
330
  /**
306
- * All fields with a given name (exact, trimmed match).
331
+ * All fields with a given name (exact, trimmed match), mounted-first.
307
332
  */
308
333
  getAllByName(name: string): Field[];
309
- /** First field with the given groupId. */
334
+ /** First field with the given groupId (prefer mounted). */
310
335
  getByGroupId(id: string): Field | undefined;
311
- /** All fields with the given groupId. */
336
+ /** All fields with the given groupId (mounted-first). */
312
337
  getAllByGroupId(id: string): Field[];
313
338
  /**
314
- * All fields that share the given bindId.
339
+ * All fields that share the given bindId (mounted-first).
315
340
  */
316
341
  getAllByBind(id: string): Field[];
317
342
  /**
318
- * First field with the given bindId.
319
- *
320
- * Behaviour:
321
- * - Prefer a field whose ref is currently in the DOM.
322
- * - If none are mounted, fall back to the first matching field.
343
+ * First field with the given bindId (prefer mounted).
323
344
  */
324
345
  getByBind(id: string): Field | undefined;
325
346
  getBind(id: string): Field | undefined;
@@ -1136,7 +1157,7 @@ interface InputNumberProps extends Omit<ShadcnTextVariantProps, 'min' | 'max' |
1136
1157
  size?: FieldSize;
1137
1158
  invalid?: boolean;
1138
1159
  }
1139
- declare const InputNumber: React.MemoExoticComponent<React.ForwardRefExoticComponent<InputNumberProps & React.RefAttributes<HTMLInputElement>>>;
1160
+ declare const InputNumber: React.NamedExoticComponent<InputNumberProps & React.RefAttributes<HTMLInputElement>>;
1140
1161
 
1141
1162
  type ShadcnNumberVariantProps = Omit<InputNumberProps, "onValueChange" | "onChange" | "leadingControl" | "trailingControl"> & {
1142
1163
  /**
@@ -2263,7 +2284,7 @@ type NormalizedMultiItem = {
2263
2284
  icon?: React.ReactNode;
2264
2285
  raw: MultiSelectOption;
2265
2286
  };
2266
- interface ShadcnMultiSelectVariantProps extends Pick<VariantBaseProps<SelectPrimitive$1[] | undefined>, "value" | "onValue" | "error" | "disabled" | "readOnly" | "size" | "density"> {
2287
+ type MultiSelectBaseProps = Pick<VariantBaseProps<SelectPrimitive$1[] | undefined>, "value" | "onValue" | "error" | "disabled" | "readOnly" | "size" | "density"> & {
2267
2288
  /**
2268
2289
  * Options for the multi-select.
2269
2290
  *
@@ -2394,62 +2415,62 @@ interface ShadcnMultiSelectVariantProps extends Pick<VariantBaseProps<SelectPrim
2394
2415
  * Extra classes for the popover content.
2395
2416
  */
2396
2417
  contentClassName?: string;
2397
- /**
2398
- * One or more icons displayed inside the trigger, on the left.
2399
- *
2400
- * If not provided and `icon` is set, that single icon
2401
- * is treated as `leadingIcons[0]`.
2402
- */
2418
+ };
2419
+ type MultiSelectDefaultModeProps = {
2420
+ mode?: "default";
2403
2421
  leadingIcons?: React.ReactNode[];
2404
- /**
2405
- * Icons displayed on the right side of the trigger,
2406
- * near the clear button / chevron area.
2407
- */
2408
2422
  trailingIcons?: React.ReactNode[];
2409
- /**
2410
- * Convenience single-icon prop for the left side.
2411
- */
2412
2423
  icon?: React.ReactNode;
2413
- /**
2414
- * Base gap between icons and text.
2415
- * Defaults to 4px-ish via `gap-1`.
2416
- */
2417
2424
  iconGap?: number;
2418
- /**
2419
- * Extra spacing to apply between leading icons and the text.
2420
- */
2421
2425
  leadingIconSpacing?: number;
2422
- /**
2423
- * Extra spacing to apply between trailing icons and the clear button.
2424
- */
2425
2426
  trailingIconSpacing?: number;
2426
- /**
2427
- * Arbitrary React node rendered before the select (e.g. a button).
2428
- */
2429
2427
  leadingControl?: React.ReactNode;
2430
- /**
2431
- * Arbitrary React node rendered after the select (e.g. a button).
2432
- */
2433
2428
  trailingControl?: React.ReactNode;
2434
- /**
2435
- * Extra classes for the leading control wrapper.
2436
- */
2437
2429
  leadingControlClassName?: string;
2438
- /**
2439
- * Extra classes for the trailing control wrapper.
2440
- */
2441
2430
  trailingControlClassName?: string;
2442
- /**
2443
- * If true and there are controls, the select trigger + controls share
2444
- * a single visual box (borders, radius, focus states).
2445
- */
2446
2431
  joinControls?: boolean;
2447
- /**
2448
- * When joinControls is true, whether the box styling extends over controls
2449
- * (true) or controls are visually separate (false).
2450
- */
2451
2432
  extendBoxToControls?: boolean;
2452
- }
2433
+ button?: never;
2434
+ children?: never;
2435
+ selectedBadge?: never;
2436
+ selectedBadgeHiddenWhenZero?: never;
2437
+ selectedBadgeClassName?: never;
2438
+ selectedBadgePlacement?: never;
2439
+ };
2440
+ type MultiSelectButtonModeButton = React.ReactNode | ((ctx: {
2441
+ open: boolean;
2442
+ selectedItems: NormalizedMultiItem[];
2443
+ selectedCount: number;
2444
+ }) => React.ReactNode);
2445
+ type MultiSelectButtonModeProps = {
2446
+ mode: "button";
2447
+ /**
2448
+ * Used when mode="button". If provided, this is the trigger.
2449
+ * If not provided, `children` is used.
2450
+ */
2451
+ button?: MultiSelectButtonModeButton;
2452
+ children?: MultiSelectButtonModeButton;
2453
+ /**
2454
+ * Selected-count badge (mode="button" only)
2455
+ */
2456
+ selectedBadge?: boolean;
2457
+ selectedBadgeHiddenWhenZero?: boolean;
2458
+ selectedBadgeClassName?: string;
2459
+ selectedBadgePlacement?: "end" | "corner";
2460
+ leadingIcons?: never;
2461
+ trailingIcons?: never;
2462
+ icon?: never;
2463
+ iconGap?: never;
2464
+ leadingIconSpacing?: never;
2465
+ trailingIconSpacing?: never;
2466
+ leadingControl?: never;
2467
+ trailingControl?: never;
2468
+ leadingControlClassName?: never;
2469
+ trailingControlClassName?: never;
2470
+ joinControls?: never;
2471
+ extendBoxToControls?: never;
2472
+ };
2473
+ type ShadcnMultiSelectVariantProps = MultiSelectBaseProps & (MultiSelectDefaultModeProps | MultiSelectButtonModeProps);
2453
2474
 
2454
2475
  type SliderValue$1 = number | undefined;
2455
2476
  interface ShadcnSliderVariantProps extends Pick<VariantBaseProps<SliderValue$1>, "value" | "onValue" | "error" | "disabled" | "readOnly" | "size" | "density"> {
@@ -2732,7 +2753,8 @@ type NormalizedTreeItem = {
2732
2753
  children: NormalizedTreeItem[];
2733
2754
  raw: TreeSelectOption;
2734
2755
  };
2735
- interface ShadcnTreeSelectVariantProps extends Pick<VariantBaseProps<TreeValue>, "value" | "onValue" | "error" | "disabled" | "readOnly" | "size" | "density"> {
2756
+ type BadgeVariant$1 = "default" | "secondary" | "destructive" | "outline";
2757
+ type TreeSelectBaseProps = Pick<VariantBaseProps<TreeValue>, "value" | "onValue" | "error" | "disabled" | "readOnly" | "size" | "density"> & {
2736
2758
  options?: TreeSelectOption[];
2737
2759
  /**
2738
2760
  * If true, allows multiple selection (checkboxes).
@@ -2770,6 +2792,9 @@ interface ShadcnTreeSelectVariantProps extends Pick<VariantBaseProps<TreeValue>,
2770
2792
  expandAll?: boolean;
2771
2793
  defaultExpandedValues?: TreeKey[];
2772
2794
  leafOnly?: boolean;
2795
+ };
2796
+ type TreeSelectDefaultModeProps = {
2797
+ mode?: "default";
2773
2798
  leadingIcons?: React.ReactNode[];
2774
2799
  trailingIcons?: React.ReactNode[];
2775
2800
  icon?: React.ReactNode;
@@ -2782,7 +2807,56 @@ interface ShadcnTreeSelectVariantProps extends Pick<VariantBaseProps<TreeValue>,
2782
2807
  trailingControlClassName?: string;
2783
2808
  joinControls?: boolean;
2784
2809
  extendBoxToControls?: boolean;
2785
- }
2810
+ button?: never;
2811
+ children?: never;
2812
+ selectedBadge?: never;
2813
+ selectedBadgeHiddenWhenZero?: never;
2814
+ selectedBadgeVariant?: never;
2815
+ selectedBadgeClassName?: never;
2816
+ selectedBadgePlacement?: never;
2817
+ };
2818
+ type TreeSelectButtonModeButton = React.ReactNode | ((ctx: {
2819
+ open: boolean;
2820
+ selectedItems: NormalizedTreeItem[];
2821
+ selectedCount: number;
2822
+ }) => React.ReactNode);
2823
+ type TreeSelectButtonModeProps = {
2824
+ mode: "button";
2825
+ /**
2826
+ * Used when mode="button". If provided, this is the trigger.
2827
+ * If not provided, `children` is used.
2828
+ */
2829
+ button?: TreeSelectButtonModeButton;
2830
+ children?: TreeSelectButtonModeButton;
2831
+ /**
2832
+ * Selected-count badge (mode="button" only)
2833
+ */
2834
+ selectedBadge?: boolean;
2835
+ selectedBadgeHiddenWhenZero?: boolean;
2836
+ selectedBadgeVariant?: BadgeVariant$1;
2837
+ selectedBadgeClassName?: string;
2838
+ selectedBadgePlacement?: "end" | "corner";
2839
+ leadingIcons?: never;
2840
+ trailingIcons?: never;
2841
+ icon?: never;
2842
+ iconGap?: never;
2843
+ leadingIconSpacing?: never;
2844
+ trailingIconSpacing?: never;
2845
+ leadingControl?: never;
2846
+ trailingControl?: never;
2847
+ leadingControlClassName?: never;
2848
+ trailingControlClassName?: never;
2849
+ joinControls?: never;
2850
+ extendBoxToControls?: never;
2851
+ };
2852
+ type ShadcnTreeSelectVariantProps = TreeSelectBaseProps & (TreeSelectDefaultModeProps | TreeSelectButtonModeProps);
2853
+
2854
+ declare const badgeVariants: (props?: ({
2855
+ variant?: "default" | "destructive" | "outline" | "secondary" | null | undefined;
2856
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
2857
+ declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
2858
+ asChild?: boolean;
2859
+ }): react_jsx_runtime.JSX.Element;
2786
2860
 
2787
2861
  type FileSourceKind = "native" | "path" | "url" | "custom";
2788
2862
  interface FileItem {
@@ -2816,7 +2890,8 @@ type CustomFileLoader = (ctx: {
2816
2890
  multiple: boolean;
2817
2891
  current: FileItem[];
2818
2892
  }) => Promise<CustomFileLoaderResult> | CustomFileLoaderResult;
2819
- interface ShadcnFileVariantProps extends Pick<VariantBaseProps<FileItem[]>, "value" | "onValue" | "error" | "disabled" | "readOnly" | "size" | "density"> {
2893
+ type BadgeVariant = React.ComponentProps<typeof Badge>["variant"];
2894
+ type FileVariantBaseProps = Pick<VariantBaseProps<FileItem[]>, "value" | "onValue" | "error" | "disabled" | "readOnly" | "size" | "density"> & {
2820
2895
  multiple?: boolean;
2821
2896
  accept?: string | string[];
2822
2897
  maxFiles?: number;
@@ -2848,6 +2923,10 @@ interface ShadcnFileVariantProps extends Pick<VariantBaseProps<FileItem[]>, "val
2848
2923
  className?: string;
2849
2924
  dropAreaClassName?: string;
2850
2925
  listClassName?: string;
2926
+ triggerClassName?: string;
2927
+ };
2928
+ type FileDefaultModeProps = {
2929
+ mode?: "default";
2851
2930
  leadingIcons?: React.ReactNode[];
2852
2931
  trailingIcons?: React.ReactNode[];
2853
2932
  icon?: React.ReactNode;
@@ -2857,7 +2936,42 @@ interface ShadcnFileVariantProps extends Pick<VariantBaseProps<FileItem[]>, "val
2857
2936
  trailingControlClassName?: string;
2858
2937
  joinControls?: boolean;
2859
2938
  extendBoxToControls?: boolean;
2860
- }
2939
+ button?: never;
2940
+ children?: never;
2941
+ selectedBadge?: never;
2942
+ selectedBadgeHiddenWhenZero?: never;
2943
+ selectedBadgeVariant?: never;
2944
+ selectedBadgeClassName?: never;
2945
+ selectedBadgePlacement?: never;
2946
+ };
2947
+ type FileButtonTrigger = React.ReactNode | ((ctx: {
2948
+ open: boolean;
2949
+ items: FileItem[];
2950
+ selectedCount: number;
2951
+ disabled: boolean;
2952
+ }) => React.ReactNode);
2953
+ type FileButtonModeProps = {
2954
+ mode: "button";
2955
+ /** Used when mode="button". If provided, this is the trigger. If not, `children` is used. */
2956
+ button?: FileButtonTrigger;
2957
+ children?: FileButtonTrigger;
2958
+ /** Selected-count badge (mode="button" only) */
2959
+ selectedBadge?: boolean;
2960
+ selectedBadgeHiddenWhenZero?: boolean;
2961
+ selectedBadgeVariant?: BadgeVariant;
2962
+ selectedBadgeClassName?: string;
2963
+ selectedBadgePlacement?: "end" | "corner";
2964
+ leadingIcons?: never;
2965
+ trailingIcons?: never;
2966
+ icon?: never;
2967
+ leadingControl?: never;
2968
+ trailingControl?: never;
2969
+ leadingControlClassName?: never;
2970
+ trailingControlClassName?: never;
2971
+ joinControls?: never;
2972
+ extendBoxToControls?: never;
2973
+ };
2974
+ type ShadcnFileVariantProps = FileVariantBaseProps & (FileDefaultModeProps | FileButtonModeProps);
2861
2975
 
2862
2976
  type SelectPrimitive = string | number;
2863
2977
  type SelectOption = SelectPrimitive | {
@@ -3322,7 +3436,7 @@ type Props<V extends Dict, S extends z.ZodType | undefined, K extends AdapterKey
3322
3436
  * - named inputs via `name`
3323
3437
  * - bound inputs via `bindId`
3324
3438
  * - grouped inputs via `groupId`
3325
- * - Manages errors + uncaught messages
3439
+ * - Manages errors and uncaught messages
3326
3440
  * - Builds values snapshots (including bucket values)
3327
3441
  * - Orchestrates submission via the adapter registry
3328
3442
  */
@@ -3909,7 +4023,7 @@ interface InputMaskProps$1 extends Omit<React.InputHTMLAttributes<HTMLInputEleme
3909
4023
  onChange?: (e: InputMaskChangeEvent) => void;
3910
4024
  onComplete?: (e: InputMaskCompleteEvent) => void;
3911
4025
  }
3912
- declare const InputMask: React.MemoExoticComponent<React.ForwardRefExoticComponent<InputMaskProps$1 & React.RefAttributes<InputMaskRef>>>;
4026
+ declare const InputMask: React.NamedExoticComponent<InputMaskProps$1 & React.RefAttributes<InputMaskRef>>;
3913
4027
 
3914
4028
  type MaskMode = "raw" | "masked";
3915
4029
  interface InputMaskProps {