@vertz/ui 0.2.14 → 0.2.16

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.
Files changed (32) hide show
  1. package/README.md +49 -0
  2. package/dist/shared/chunk-14eqne2a.js +10 -0
  3. package/dist/shared/{chunk-dksg08fq.js → chunk-1rxa2fz4.js} +2 -8
  4. package/dist/shared/{chunk-8hsz5y4a.js → chunk-4fwcwxn6.js} +14 -4
  5. package/dist/shared/{chunk-hw67ckr3.js → chunk-4mtn7af6.js} +230 -19
  6. package/dist/shared/{chunk-2sth83bd.js → chunk-6jyt4ycw.js} +67 -2
  7. package/dist/shared/{chunk-83g4h38e.js → chunk-6wd36w21.js} +1 -0
  8. package/dist/shared/{chunk-h89w580h.js → chunk-afawz764.js} +1 -1
  9. package/dist/shared/{chunk-nn9v1zmk.js → chunk-b0qqqk03.js} +86 -21
  10. package/dist/shared/{chunk-c9xxsrat.js → chunk-dhehvmj0.js} +179 -10
  11. package/dist/shared/{chunk-mj7b4t40.js → chunk-fkbgbf3n.js} +98 -11
  12. package/dist/shared/{chunk-c30eg6wn.js → chunk-j09yyh34.js} +79 -6
  13. package/dist/shared/chunk-mtsvrj9e.js +23 -0
  14. package/dist/shared/chunk-pnv25zep.js +7 -0
  15. package/dist/shared/{chunk-j6qyxfdc.js → chunk-vndfjfdy.js} +3 -3
  16. package/dist/src/auth/public.d.ts +69 -9
  17. package/dist/src/auth/public.js +217 -13
  18. package/dist/src/css/public.d.ts +110 -2
  19. package/dist/src/css/public.js +8 -4
  20. package/dist/src/form/public.d.ts +33 -7
  21. package/dist/src/form/public.js +2 -2
  22. package/dist/src/index.d.ts +311 -20
  23. package/dist/src/index.js +161 -14
  24. package/dist/src/internals.d.ts +141 -5
  25. package/dist/src/internals.js +17 -9
  26. package/dist/src/query/public.js +4 -3
  27. package/dist/src/router/public.d.ts +39 -9
  28. package/dist/src/router/public.js +17 -11
  29. package/dist/src/test/index.d.ts +26 -23
  30. package/dist/src/test/index.js +5 -4
  31. package/package.json +3 -3
  32. package/reactivity.json +1 -11
@@ -27,6 +27,101 @@ type CSSOutput<T extends CSSInput = CSSInput> = { readonly [K in keyof T & strin
27
27
  * @returns Object with block names as keys (class name strings) and non-enumerable `css` property.
28
28
  */
29
29
  declare function css<T extends CSSInput>(input: T & { [K in keyof T & "css"]? : never }, filePath?: string): CSSOutput<T>;
30
+ interface FontSrc {
31
+ path: string;
32
+ weight?: string | number;
33
+ style?: "normal" | "italic";
34
+ }
35
+ type FallbackFontName = "Arial" | "Times New Roman" | "Courier New";
36
+ interface FontFallbackMetrics {
37
+ /** CSS ascent-override value, e.g., '94.52%' */
38
+ ascentOverride: string;
39
+ /** CSS descent-override value, e.g., '24.60%' */
40
+ descentOverride: string;
41
+ /** CSS line-gap-override value, e.g., '0.00%' */
42
+ lineGapOverride: string;
43
+ /** CSS size-adjust value, e.g., '104.88%' */
44
+ sizeAdjust: string;
45
+ /** System font used as fallback base. */
46
+ fallbackFont: FallbackFontName;
47
+ }
48
+ interface CompileFontsOptions {
49
+ /** Pre-computed fallback metrics per font key. Provided by @vertz/ui-server at build/SSR time. */
50
+ fallbackMetrics?: Record<string, FontFallbackMetrics>;
51
+ }
52
+ interface FontOptions {
53
+ /** Font weight: '100..1000' (variable) or 400 (fixed). */
54
+ weight: string | number;
55
+ /** Font style. @default 'normal' */
56
+ style?: "normal" | "italic";
57
+ /** Font-display strategy. @default 'swap' */
58
+ display?: "auto" | "block" | "swap" | "fallback" | "optional";
59
+ /** URL path(s) for local/self-hosted fonts. */
60
+ src?: string | FontSrc[];
61
+ /** Fallback font stack. */
62
+ fallback?: string[];
63
+ /** Font subsets (metadata only — subsetting is deferred to a future phase). @default ['latin'] */
64
+ subsets?: string[];
65
+ /** Unicode range for subsetting. */
66
+ unicodeRange?: string;
67
+ /**
68
+ * Control automatic fallback font metric adjustment for zero-CLS font loading.
69
+ * - true: auto-detect fallback base from `fallback` array (default)
70
+ * - false: disable
71
+ * - 'Arial' | 'Times New Roman' | 'Courier New': explicit base
72
+ * @default true
73
+ */
74
+ adjustFontFallback?: boolean | FallbackFontName;
75
+ }
76
+ type FontStyle = "normal" | "italic";
77
+ type FontDisplay = "auto" | "block" | "swap" | "fallback" | "optional";
78
+ interface FontDescriptor {
79
+ readonly __brand: "FontDescriptor";
80
+ readonly family: string;
81
+ readonly weight: string;
82
+ readonly style: FontStyle;
83
+ readonly display: FontDisplay;
84
+ readonly src?: string | FontSrc[];
85
+ readonly fallback: string[];
86
+ readonly subsets: string[];
87
+ readonly unicodeRange?: string;
88
+ readonly adjustFontFallback: boolean | FallbackFontName;
89
+ }
90
+ /** Structured description of a resource to preload. */
91
+ interface PreloadItem {
92
+ href: string;
93
+ as: "font" | "image" | "style" | "script";
94
+ type?: string;
95
+ crossorigin?: boolean;
96
+ }
97
+ interface CompiledFonts {
98
+ /** @font-face declarations. */
99
+ fontFaceCss: string;
100
+ /** :root { --font-<key>: ...; } block (for standalone use). */
101
+ cssVarsCss: string;
102
+ /** Individual CSS var lines (e.g., ' --font-sans: ...;') for merging into an existing :root. */
103
+ cssVarLines: string[];
104
+ /** <link rel="preload"> HTML tags for font files. */
105
+ preloadTags: string;
106
+ /** Structured preload data for generating HTTP Link headers. */
107
+ preloadItems: PreloadItem[];
108
+ }
109
+ /**
110
+ * Create a font descriptor for use in theme definitions.
111
+ *
112
+ * @param family - The font family name (e.g., 'DM Sans').
113
+ * @param options - Font configuration.
114
+ * @returns A FontDescriptor.
115
+ */
116
+ declare function font(family: string, options: FontOptions): FontDescriptor;
117
+ /**
118
+ * Compile font descriptors into CSS and preload tags.
119
+ *
120
+ * @param fonts - A map of token key → FontDescriptor.
121
+ * @param options - Optional compilation settings (e.g., pre-computed fallback metrics).
122
+ * @returns Compiled @font-face CSS, CSS var lines, and preload link tags.
123
+ */
124
+ declare function compileFonts(fonts: Record<string, FontDescriptor>, options?: CompileFontsOptions): CompiledFonts;
30
125
  /** Input to globalCss(): selector → property-value map. */
31
126
  type GlobalCSSInput = Record<string, Record<string, string>>;
32
127
  /** Output of globalCss(): extracted CSS string. */
@@ -65,6 +160,8 @@ interface ThemeInput {
65
160
  colors: ColorTokens;
66
161
  /** Spacing scale tokens. */
67
162
  spacing?: SpacingTokens;
163
+ /** Font descriptors keyed by token name (e.g., sans, mono, display). */
164
+ fonts?: Record<string, FontDescriptor>;
68
165
  }
69
166
  /** The structured theme object returned by defineTheme(). */
70
167
  interface Theme {
@@ -72,6 +169,8 @@ interface Theme {
72
169
  colors: ColorTokens;
73
170
  /** Spacing scale tokens. */
74
171
  spacing?: SpacingTokens;
172
+ /** Font descriptors keyed by token name. */
173
+ fonts?: Record<string, FontDescriptor>;
75
174
  }
76
175
  /** Output of compileTheme(). */
77
176
  interface CompiledTheme {
@@ -79,6 +178,15 @@ interface CompiledTheme {
79
178
  css: string;
80
179
  /** Flat list of token dot-paths (e.g., 'primary.500', 'background'). */
81
180
  tokens: string[];
181
+ /** Font preload link tags for injection into <head>. */
182
+ preloadTags: string;
183
+ /** Structured preload data for generating HTTP Link headers. */
184
+ preloadItems: PreloadItem[];
185
+ }
186
+ /** Options for compileTheme(). */
187
+ interface CompileThemeOptions {
188
+ /** Pre-computed font fallback metrics for zero-CLS font loading. */
189
+ fallbackMetrics?: CompileFontsOptions["fallbackMetrics"];
82
190
  }
83
191
  /**
84
192
  * Define a theme with raw and contextual design tokens.
@@ -97,7 +205,7 @@ declare function defineTheme(input: ThemeInput): Theme;
97
205
  * @param theme - A theme object from defineTheme().
98
206
  * @returns Compiled CSS and token list.
99
207
  */
100
- declare function compileTheme(theme: Theme): CompiledTheme;
208
+ declare function compileTheme(theme: Theme, options?: CompileThemeOptions): CompiledTheme;
101
209
  /** A child node: either a DOM Node or a string (text content). */
102
210
  type ThemeChild = Node | string;
103
211
  /** Props for ThemeProvider. */
@@ -151,4 +259,4 @@ interface VariantFunction<V extends VariantDefinitions> {
151
259
  * @returns A function that accepts variant props and returns a className string.
152
260
  */
153
261
  declare function variants<V extends VariantDefinitions>(config: VariantsConfig<V>): VariantFunction<V>;
154
- export { variants, s, globalCss, defineTheme, css, compileTheme, VariantsConfig, VariantProps, VariantFunction, ThemeProviderProps, ThemeProvider, ThemeInput, Theme, StyleEntry, GlobalCSSOutput, GlobalCSSInput, CompiledTheme, CSSOutput, CSSInput };
262
+ export { variants, s, globalCss, font, defineTheme, css, compileTheme, compileFonts, VariantsConfig, VariantProps, VariantFunction, ThemeProviderProps, ThemeProvider, ThemeInput, Theme, StyleEntry, PreloadItem, GlobalCSSOutput, GlobalCSSInput, FontSrc, FontOptions, FontFallbackMetrics, FontDescriptor, FallbackFontName, CompiledTheme, CompiledFonts, CompileThemeOptions, CompileFontsOptions, CSSOutput, CSSInput };
@@ -1,22 +1,26 @@
1
1
  import {
2
2
  ThemeProvider,
3
+ compileFonts,
3
4
  compileTheme,
4
5
  css,
5
6
  defineTheme,
7
+ font,
6
8
  globalCss,
7
9
  s,
8
10
  variants
9
- } from "../../shared/chunk-c9xxsrat.js";
10
- import"../../shared/chunk-j6qyxfdc.js";
11
+ } from "../../shared/chunk-dhehvmj0.js";
12
+ import"../../shared/chunk-vndfjfdy.js";
11
13
  import"../../shared/chunk-prj7nm08.js";
12
- import"../../shared/chunk-h89w580h.js";
13
- import"../../shared/chunk-8hsz5y4a.js";
14
+ import"../../shared/chunk-afawz764.js";
15
+ import"../../shared/chunk-4fwcwxn6.js";
14
16
  export {
15
17
  variants,
16
18
  s,
17
19
  globalCss,
20
+ font,
18
21
  defineTheme,
19
22
  css,
20
23
  compileTheme,
24
+ compileFonts,
21
25
  ThemeProvider
22
26
  };
@@ -89,20 +89,44 @@ interface SdkMethodWithMeta<
89
89
  };
90
90
  }
91
91
  /** Reserved property names that cannot be used as field names on FormInstance. */
92
- type ReservedFormNames = "submitting" | "dirty" | "valid" | "action" | "method" | "onSubmit" | "reset" | "setFieldError" | "submit" | "__bindElement";
93
- /** Mapped type providing FieldState for each field in TBody. */
92
+ type ReservedFormNames = "submitting" | "dirty" | "valid" | "action" | "method" | "onSubmit" | "reset" | "setFieldError" | "submit" | "fields" | "__bindElement";
93
+ /** Mapped type providing FieldState for each field in TBody (flat — no nested access). */
94
94
  type FieldAccessors<TBody> = { [K in keyof TBody] : FieldState<TBody[K]> };
95
+ /** Built-in object types that should NOT recurse into NestedFieldAccessors. */
96
+ type BuiltInObjects = Date | RegExp | File | Blob | Map<unknown, unknown> | Set<unknown>;
97
+ /** FieldState signal/method property names that conflict with nested field names. */
98
+ type FieldSignalReservedNames = "error" | "dirty" | "touched" | "value" | "setValue" | "reset";
99
+ /** Check if any key of T collides with FieldState property names. */
100
+ type HasReservedFieldName<T> = keyof T & FieldSignalReservedNames extends never ? false : true;
101
+ /** Recursive field accessors for nested schemas. */
102
+ type NestedFieldAccessors<T> = { [K in keyof T] : T[K] extends BuiltInObjects ? FieldState<T[K]> : T[K] extends Array<infer U> ? FieldState<T[K]> & ArrayFieldAccessors<U> : T[K] extends Record<string, unknown> ? HasReservedFieldName<T[K]> extends true ? {
103
+ __error: `Nested field name conflicts with FieldState property: ${keyof T[K] & FieldSignalReservedNames & string}`;
104
+ } : FieldState<T[K]> & NestedFieldAccessors<T[K]> : FieldState<T[K]> };
105
+ /** Array field accessors — numeric index access to element-level fields. */
106
+ type ArrayFieldAccessors<U> = {
107
+ [index: number]: U extends BuiltInObjects ? FieldState<U> : U extends Record<string, unknown> ? FieldState<U> & NestedFieldAccessors<U> : FieldState<U>;
108
+ };
109
+ /** Deep partial utility for initial values. */
110
+ type DeepPartial<T> = { [K in keyof T]? : T[K] extends Array<infer U> ? Array<DeepPartial<U>> : T[K] extends Record<string, unknown> ? DeepPartial<T[K]> : T[K] };
111
+ /** Union of all valid dot-paths through a nested type. */
112
+ type FieldPath<
113
+ T,
114
+ Prefix extends string = ""
115
+ > = `${Prefix}${keyof T & string}` | { [K in keyof T & string] : T[K] extends Record<string, unknown> ? FieldPath<T[K], `${Prefix}${K}.`> : never }[keyof T & string];
116
+ /** Mapped type providing typed field name strings for compile-time input validation. */
117
+ type FieldNames<TBody> = { readonly [K in keyof TBody & string] : K };
95
118
  /** Base properties available on every form instance. */
96
119
  interface FormBaseProperties<TBody> {
97
120
  action: string;
98
121
  method: string;
99
122
  onSubmit: (e: Event) => Promise<void>;
100
123
  reset: () => void;
101
- setFieldError: (field: keyof TBody & string, message: string) => void;
124
+ setFieldError: (field: FieldPath<TBody>, message: string) => void;
102
125
  submit: (formData?: FormData) => Promise<void>;
103
126
  submitting: Signal<boolean>;
104
127
  dirty: ReadonlySignal<boolean>;
105
128
  valid: ReadonlySignal<boolean>;
129
+ fields: FieldNames<TBody>;
106
130
  __bindElement: (el: HTMLFormElement) => void;
107
131
  }
108
132
  /**
@@ -114,7 +138,7 @@ interface FormBaseProperties<TBody> {
114
138
  type FormInstance<
115
139
  TBody,
116
140
  _TResult
117
- > = keyof TBody & ReservedFormNames extends never ? FormBaseProperties<TBody> & FieldAccessors<TBody> : {
141
+ > = keyof TBody & ReservedFormNames extends never ? FormBaseProperties<TBody> & NestedFieldAccessors<TBody> : {
118
142
  __error: `Field name conflicts with reserved form property: ${keyof TBody & ReservedFormNames & string}`;
119
143
  };
120
144
  /** Options for creating a form instance. */
@@ -124,8 +148,8 @@ interface FormOptions<
124
148
  > {
125
149
  /** Explicit schema for client-side validation before submission. */
126
150
  schema?: FormSchema<TBody>;
127
- /** Initial values for form fields. */
128
- initial?: Partial<TBody> | (() => Partial<TBody>);
151
+ /** Initial values for form fields. Supports nested partial values. */
152
+ initial?: DeepPartial<TBody> | (() => DeepPartial<TBody>);
129
153
  /** Callback invoked after a successful submission. */
130
154
  onSuccess?: (result: TResult) => void;
131
155
  /** Callback invoked when validation or submission fails. */
@@ -154,6 +178,8 @@ declare function form<
154
178
  interface FormDataOptions {
155
179
  /** When true, coerces numeric strings to numbers and "true"/"false" to booleans. */
156
180
  coerce?: boolean;
181
+ /** When true, parses dot-separated keys into nested objects (e.g., "address.street" → { address: { street: ... } }). */
182
+ nested?: boolean;
157
183
  }
158
184
  /**
159
185
  * Convert FormData to a plain object.
@@ -164,4 +190,4 @@ interface FormDataOptions {
164
190
  * "true"/"false" become booleans.
165
191
  */
166
192
  declare function formDataToObject(formData: FormData, options?: FormDataOptions): Record<string, unknown>;
167
- export { validate, formDataToObject, form, createFieldState, ValidationResult, SdkMethodWithMeta, SdkMethod, FormSchema, FormOptions, FormInstance, FormDataOptions, FieldState };
193
+ export { validate, formDataToObject, form, createFieldState, ValidationResult, SdkMethodWithMeta, SdkMethod, NestedFieldAccessors, FormSchema, FormOptions, FormInstance, FormDataOptions, FieldState, FieldPath, FieldNames, FieldAccessors, DeepPartial, ArrayFieldAccessors };
@@ -3,8 +3,8 @@ import {
3
3
  form,
4
4
  formDataToObject,
5
5
  validate
6
- } from "../../shared/chunk-c30eg6wn.js";
7
- import"../../shared/chunk-8hsz5y4a.js";
6
+ } from "../../shared/chunk-j09yyh34.js";
7
+ import"../../shared/chunk-4fwcwxn6.js";
8
8
  export {
9
9
  validate,
10
10
  formDataToObject,