@vertz/ui 0.2.0 → 0.2.1
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 +339 -857
- package/dist/css/public.d.ts +24 -27
- package/dist/css/public.js +5 -1
- package/dist/form/public.d.ts +94 -38
- package/dist/form/public.js +5 -3
- package/dist/index.d.ts +696 -167
- package/dist/index.js +461 -84
- package/dist/internals.d.ts +192 -23
- package/dist/internals.js +151 -102
- package/dist/jsx-runtime/index.d.ts +44 -17
- package/dist/jsx-runtime/index.js +26 -7
- package/dist/query/public.d.ts +62 -7
- package/dist/query/public.js +12 -4
- package/dist/router/public.d.ts +186 -26
- package/dist/router/public.js +22 -7
- package/dist/shared/{chunk-f1ynwam4.js → chunk-0p5f7gmg.js} +155 -32
- package/dist/shared/{chunk-j8vzvne3.js → chunk-9e92w0wt.js} +4 -1
- package/dist/shared/{chunk-xd9d7q5p.js → chunk-cq7xg4xe.js} +59 -10
- package/dist/shared/chunk-g4rch80a.js +33 -0
- package/dist/shared/{chunk-pgymxpn1.js → chunk-hrd0mft1.js} +136 -34
- package/dist/shared/chunk-nmjyj8p9.js +290 -0
- package/dist/shared/chunk-pp3a6xbn.js +483 -0
- package/dist/shared/chunk-prj7nm08.js +67 -0
- package/dist/shared/chunk-q6cpe5k7.js +230 -0
- package/dist/shared/chunk-ryb49346.js +374 -0
- package/dist/shared/chunk-v3yyf79g.js +48 -0
- package/dist/shared/chunk-vx0kzack.js +103 -0
- package/dist/shared/chunk-wv6kkj1w.js +464 -0
- package/dist/test/index.d.ts +67 -6
- package/dist/test/index.js +4 -3
- package/package.json +13 -8
- package/dist/shared/chunk-bp3v6s9j.js +0 -62
- package/dist/shared/chunk-d8h2eh8d.js +0 -141
- package/dist/shared/chunk-tsdpgmks.js +0 -98
- package/dist/shared/chunk-zbbvx05f.js +0 -202
package/dist/css/public.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
/** A raw CSS declaration: { property, value } for styles that can't be expressed as shorthands. */
|
|
2
|
+
interface RawDeclaration {
|
|
3
|
+
property: string;
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
/** A value within a nested selector array: shorthand string or raw declaration. */
|
|
7
|
+
type StyleValue = string | RawDeclaration;
|
|
1
8
|
/** A style entry in the array: either a shorthand string or an object for nested selectors. */
|
|
2
|
-
type StyleEntry = string | Record<string,
|
|
9
|
+
type StyleEntry = string | Record<string, StyleValue[]>;
|
|
3
10
|
/** Input to css(): a record of named style blocks. */
|
|
4
11
|
type CSSInput = Record<string, StyleEntry[]>;
|
|
5
|
-
/** Output of css():
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/** The extracted CSS string. */
|
|
10
|
-
css: string;
|
|
11
|
-
}
|
|
12
|
+
/** Output of css(): block names as top-level properties, plus non-enumerable `css`. */
|
|
13
|
+
type CSSOutput<T extends CSSInput = CSSInput> = { readonly [K in keyof T & string] : string } & {
|
|
14
|
+
readonly css: string;
|
|
15
|
+
};
|
|
12
16
|
/**
|
|
13
17
|
* Process a css() call and produce class names + extracted CSS.
|
|
14
18
|
*
|
|
@@ -20,9 +24,9 @@ interface CSSOutput {
|
|
|
20
24
|
*
|
|
21
25
|
* @param input - Named style blocks.
|
|
22
26
|
* @param filePath - Source file path for deterministic hashing.
|
|
23
|
-
* @returns
|
|
27
|
+
* @returns Object with block names as keys (class name strings) and non-enumerable `css` property.
|
|
24
28
|
*/
|
|
25
|
-
declare function css(input:
|
|
29
|
+
declare function css<T extends CSSInput>(input: T & { [K in keyof T & "css"]? : never }, filePath?: string): CSSOutput<T>;
|
|
26
30
|
/** Input to globalCss(): selector → property-value map. */
|
|
27
31
|
type GlobalCSSInput = Record<string, Record<string, string>>;
|
|
28
32
|
/** Output of globalCss(): extracted CSS string. */
|
|
@@ -94,34 +98,27 @@ declare function defineTheme(input: ThemeInput): Theme;
|
|
|
94
98
|
* @returns Compiled CSS and token list.
|
|
95
99
|
*/
|
|
96
100
|
declare function compileTheme(theme: Theme): CompiledTheme;
|
|
97
|
-
/**
|
|
98
|
-
* ThemeProvider — Sets `data-theme` attribute for contextual token switching.
|
|
99
|
-
*
|
|
100
|
-
* Creates a wrapper div element with the appropriate `data-theme` attribute
|
|
101
|
-
* so that contextual CSS custom properties (generated by compileTheme) resolve
|
|
102
|
-
* to the correct variant values.
|
|
103
|
-
*
|
|
104
|
-
* Usage:
|
|
105
|
-
* ```ts
|
|
106
|
-
* ThemeProvider({ theme: 'dark', children: [myApp] });
|
|
107
|
-
* ```
|
|
108
|
-
*/
|
|
109
101
|
/** A child node: either a DOM Node or a string (text content). */
|
|
110
102
|
type ThemeChild = Node | string;
|
|
111
103
|
/** Props for ThemeProvider. */
|
|
112
104
|
interface ThemeProviderProps {
|
|
113
105
|
/** The theme variant name (e.g., 'light', 'dark'). Defaults to 'light'. */
|
|
114
106
|
theme?: string;
|
|
115
|
-
/**
|
|
116
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Child elements to render inside the provider.
|
|
109
|
+
*
|
|
110
|
+
* Accepts a single child (what TypeScript sees in JSX), an array, or a
|
|
111
|
+
* thunk (what the compiler produces after wrapping JSX children).
|
|
112
|
+
*/
|
|
113
|
+
children: ThemeChild | ThemeChild[] | (() => ThemeChild | ThemeChild[]);
|
|
117
114
|
}
|
|
118
115
|
/**
|
|
119
116
|
* Create a wrapper div with `data-theme` attribute for theme switching.
|
|
120
117
|
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
118
|
+
* Uses __element() directly (instead of jsx()) so the hydration cursor
|
|
119
|
+
* walker can claim the existing SSR node during mount().
|
|
123
120
|
*/
|
|
124
|
-
declare function ThemeProvider(
|
|
121
|
+
declare function ThemeProvider({ theme, children }: ThemeProviderProps): HTMLElement;
|
|
125
122
|
/** A record of variant names to their possible values (each value maps to style entries). */
|
|
126
123
|
type VariantDefinitions = Record<string, Record<string, StyleEntry[]>>;
|
|
127
124
|
/** Extract the variant props type from a variant definitions object. */
|
package/dist/css/public.js
CHANGED
|
@@ -6,7 +6,11 @@ import {
|
|
|
6
6
|
globalCss,
|
|
7
7
|
s,
|
|
8
8
|
variants
|
|
9
|
-
} from "../shared/chunk-
|
|
9
|
+
} from "../shared/chunk-0p5f7gmg.js";
|
|
10
|
+
import"../shared/chunk-ryb49346.js";
|
|
11
|
+
import"../shared/chunk-g4rch80a.js";
|
|
12
|
+
import"../shared/chunk-hrd0mft1.js";
|
|
13
|
+
import"../shared/chunk-prj7nm08.js";
|
|
10
14
|
export {
|
|
11
15
|
variants,
|
|
12
16
|
s,
|
package/dist/form/public.d.ts
CHANGED
|
@@ -12,11 +12,36 @@ interface Signal<T> {
|
|
|
12
12
|
notify(): void;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
+
* A read-only reactive value derived from other signals.
|
|
16
|
+
*/
|
|
17
|
+
interface ReadonlySignal<T> {
|
|
18
|
+
/** Get the current value and subscribe to changes. */
|
|
19
|
+
readonly value: T;
|
|
20
|
+
/** Read the current value without subscribing. */
|
|
21
|
+
peek(): T;
|
|
22
|
+
}
|
|
23
|
+
interface FieldState<T = unknown> {
|
|
24
|
+
error: Signal<string | undefined>;
|
|
25
|
+
dirty: Signal<boolean>;
|
|
26
|
+
touched: Signal<boolean>;
|
|
27
|
+
value: Signal<T>;
|
|
28
|
+
setValue: (value: T) => void;
|
|
29
|
+
reset: () => void;
|
|
30
|
+
}
|
|
31
|
+
declare function createFieldState<T>(_name: string, initialValue?: T): FieldState<T>;
|
|
32
|
+
import { Result } from "@vertz/fetch";
|
|
33
|
+
/**
|
|
15
34
|
* Minimal schema interface compatible with @vertz/schema.
|
|
16
|
-
* Any object with a `parse(data: unknown):
|
|
35
|
+
* Any object with a `parse(data: unknown): Result` method satisfies this.
|
|
17
36
|
*/
|
|
18
37
|
interface FormSchema<T> {
|
|
19
|
-
parse(data: unknown):
|
|
38
|
+
parse(data: unknown): {
|
|
39
|
+
ok: true;
|
|
40
|
+
data: T;
|
|
41
|
+
} | {
|
|
42
|
+
ok: false;
|
|
43
|
+
error: unknown;
|
|
44
|
+
};
|
|
20
45
|
}
|
|
21
46
|
/** Result of a validation attempt. */
|
|
22
47
|
type ValidationResult<T> = {
|
|
@@ -44,56 +69,87 @@ interface SdkMethod<
|
|
|
44
69
|
TBody,
|
|
45
70
|
TResult
|
|
46
71
|
> {
|
|
47
|
-
(body: TBody):
|
|
72
|
+
(body: TBody): PromiseLike<Result<TResult, Error>>;
|
|
48
73
|
url: string;
|
|
49
74
|
method: string;
|
|
75
|
+
meta?: {
|
|
76
|
+
bodySchema?: FormSchema<TBody>;
|
|
77
|
+
};
|
|
50
78
|
}
|
|
51
|
-
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
79
|
+
/**
|
|
80
|
+
* An SDK method with embedded schema metadata.
|
|
81
|
+
* Generated by `@vertz/codegen` — carries `.meta.bodySchema` for auto-validation.
|
|
82
|
+
*/
|
|
83
|
+
interface SdkMethodWithMeta<
|
|
84
|
+
TBody,
|
|
85
|
+
TResult
|
|
86
|
+
> extends SdkMethod<TBody, TResult> {
|
|
87
|
+
meta: {
|
|
88
|
+
bodySchema: FormSchema<TBody>;
|
|
89
|
+
};
|
|
55
90
|
}
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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. */
|
|
94
|
+
type FieldAccessors<TBody> = { [K in keyof TBody] : FieldState<TBody[K]> };
|
|
95
|
+
/** Base properties available on every form instance. */
|
|
96
|
+
interface FormBaseProperties<TBody> {
|
|
97
|
+
action: string;
|
|
98
|
+
method: string;
|
|
99
|
+
onSubmit: (e: Event) => Promise<void>;
|
|
100
|
+
reset: () => void;
|
|
101
|
+
setFieldError: (field: keyof TBody & string, message: string) => void;
|
|
102
|
+
submit: (formData?: FormData) => Promise<void>;
|
|
103
|
+
submitting: Signal<boolean>;
|
|
104
|
+
dirty: ReadonlySignal<boolean>;
|
|
105
|
+
valid: ReadonlySignal<boolean>;
|
|
106
|
+
__bindElement: (el: HTMLFormElement) => void;
|
|
60
107
|
}
|
|
61
|
-
/**
|
|
62
|
-
|
|
108
|
+
/**
|
|
109
|
+
* A form instance bound to an SDK method.
|
|
110
|
+
* Combines base properties with per-field reactive state via Proxy.
|
|
111
|
+
* If TBody has any key that conflicts with ReservedFormNames, it produces a type error.
|
|
112
|
+
* TResult is used by form() overloads for return type inference.
|
|
113
|
+
*/
|
|
114
|
+
type FormInstance<
|
|
115
|
+
TBody,
|
|
116
|
+
_TResult
|
|
117
|
+
> = keyof TBody & ReservedFormNames extends never ? FormBaseProperties<TBody> & FieldAccessors<TBody> : {
|
|
118
|
+
__error: `Field name conflicts with reserved form property: ${keyof TBody & ReservedFormNames & string}`;
|
|
119
|
+
};
|
|
120
|
+
/** Options for creating a form instance. */
|
|
121
|
+
interface FormOptions<
|
|
63
122
|
TBody,
|
|
64
123
|
TResult
|
|
65
124
|
> {
|
|
66
|
-
/**
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
*
|
|
77
|
-
* Can also be called directly with FormData for non-DOM usage:
|
|
78
|
-
* `userForm.handleSubmit({ onSuccess })(formData)`.
|
|
79
|
-
*/
|
|
80
|
-
handleSubmit(callbacks?: SubmitCallbacks<TResult>): (formDataOrEvent: FormData | Event) => Promise<void>;
|
|
81
|
-
/** Returns the error message for a field reactively, or undefined if no error. Type-safe field names. */
|
|
82
|
-
error(field: keyof TBody & string): string | undefined;
|
|
125
|
+
/** Explicit schema for client-side validation before submission. */
|
|
126
|
+
schema?: FormSchema<TBody>;
|
|
127
|
+
/** Initial values for form fields. */
|
|
128
|
+
initial?: Partial<TBody> | (() => Partial<TBody>);
|
|
129
|
+
/** Callback invoked after a successful submission. */
|
|
130
|
+
onSuccess?: (result: TResult) => void;
|
|
131
|
+
/** Callback invoked when validation or submission fails. */
|
|
132
|
+
onError?: (errors: Record<string, string>) => void;
|
|
133
|
+
/** When true, reset the form after a successful submission. */
|
|
134
|
+
resetOnSuccess?: boolean;
|
|
83
135
|
}
|
|
84
136
|
/**
|
|
85
|
-
* Create a form instance bound to an SDK method
|
|
137
|
+
* Create a form instance bound to an SDK method.
|
|
86
138
|
*
|
|
87
|
-
* The form provides
|
|
88
|
-
* -
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
139
|
+
* The form provides direct properties for progressive enhancement (action, method, onSubmit),
|
|
140
|
+
* per-field reactive state via Proxy, and submission handling with validation.
|
|
141
|
+
*
|
|
142
|
+
* When the SDK method has `.meta.bodySchema` (generated by `@vertz/codegen`),
|
|
143
|
+
* the schema option is optional. When the SDK method lacks `.meta`, the schema option is required.
|
|
92
144
|
*/
|
|
93
145
|
declare function form<
|
|
94
146
|
TBody,
|
|
95
147
|
TResult
|
|
96
|
-
>(sdkMethod:
|
|
148
|
+
>(sdkMethod: SdkMethodWithMeta<TBody, TResult>, options?: FormOptions<TBody, TResult>): FormInstance<TBody, TResult>;
|
|
149
|
+
declare function form<
|
|
150
|
+
TBody,
|
|
151
|
+
TResult
|
|
152
|
+
>(sdkMethod: SdkMethod<TBody, TResult>, options: Required<Pick<FormOptions<TBody, TResult>, "schema">> & FormOptions<TBody, TResult>): FormInstance<TBody, TResult>;
|
|
97
153
|
/** Options for formDataToObject conversion. */
|
|
98
154
|
interface FormDataOptions {
|
|
99
155
|
/** When true, coerces numeric strings to numbers and "true"/"false" to booleans. */
|
|
@@ -108,4 +164,4 @@ interface FormDataOptions {
|
|
|
108
164
|
* "true"/"false" become booleans.
|
|
109
165
|
*/
|
|
110
166
|
declare function formDataToObject(formData: FormData, options?: FormDataOptions): Record<string, unknown>;
|
|
111
|
-
export { validate, formDataToObject, form, ValidationResult,
|
|
167
|
+
export { validate, formDataToObject, form, createFieldState, ValidationResult, SdkMethodWithMeta, SdkMethod, FormSchema, FormOptions, FormInstance, FormDataOptions, FieldState };
|
package/dist/form/public.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
createFieldState,
|
|
2
3
|
form,
|
|
3
4
|
formDataToObject,
|
|
4
5
|
validate
|
|
5
|
-
} from "../shared/chunk-
|
|
6
|
-
import"../shared/chunk-
|
|
6
|
+
} from "../shared/chunk-q6cpe5k7.js";
|
|
7
|
+
import"../shared/chunk-hrd0mft1.js";
|
|
7
8
|
export {
|
|
8
9
|
validate,
|
|
9
10
|
formDataToObject,
|
|
10
|
-
form
|
|
11
|
+
form,
|
|
12
|
+
createFieldState
|
|
11
13
|
};
|