@helpai/elements 0.62.1 → 0.63.0
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/configurator.d.ts +59 -93
- package/configurator.mjs +2 -1540
- package/elements-web-component.esm.js +28 -28
- package/elements-web-component.esm.js.map +3 -3
- package/elements.cjs.js +28 -28
- package/elements.cjs.js.map +3 -3
- package/elements.esm.js +28 -28
- package/elements.esm.js.map +3 -3
- package/elements.js +28 -28
- package/elements.js.map +3 -3
- package/index.d.ts +2966 -1097
- package/index.mjs +13 -9741
- package/package.json +1 -1
- package/schema.d.ts +2612 -731
- package/schema.json +16 -4
- package/schema.mjs +2 -964
- package/style.css +1 -1
- package/web-component.d.ts +3 -1
- package/web-component.mjs +13 -9577
package/configurator.d.ts
CHANGED
|
@@ -1,104 +1,69 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { FunctionalComponent } from
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { FunctionalComponent } from "preact";
|
|
3
|
+
//#region src/configurator/configurator.d.ts
|
|
5
4
|
/** Generic record — the configurator handles any object-shaped Zod schema. */
|
|
6
5
|
type ConfigValue = Record<string, unknown>;
|
|
7
6
|
interface ConfiguratorProps {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
7
|
+
/**
|
|
8
|
+
* The schema to drive the form. Defaults to `widgetConfigSchema` (full
|
|
9
|
+
* surface). Pass `widgetSettingsSchema` for the dashboard-pushable UX
|
|
10
|
+
* subset, `connectionConfigSchema` for developer-facing API/auth, or
|
|
11
|
+
* any other `z.ZodObject` for arbitrary forms.
|
|
12
|
+
*/
|
|
13
|
+
schema?: z.ZodObject<z.ZodRawShape>;
|
|
14
|
+
/** Current value — partial of whichever schema you passed. */
|
|
15
|
+
value: ConfigValue;
|
|
16
|
+
/** Fires on every change. Receives the full value object. */
|
|
17
|
+
onChange: (next: ConfigValue) => void;
|
|
18
|
+
/** Optional title rendered above the form. */
|
|
19
|
+
title?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Top-level layout columns. `1` (default) — single flex column,
|
|
22
|
+
* suitable for narrow dashboards. `2` — two independent flex
|
|
23
|
+
* columns ("masonry"): top-level fields alternate by schema order
|
|
24
|
+
* (item 1 → col 1, item 2 → col 2, item 3 → col 1, …) so reading
|
|
25
|
+
* order matches schema order while each column flows
|
|
26
|
+
* independently. Expanding a collapsible grows it within its
|
|
27
|
+
* column without shifting the other column. Only affects the
|
|
28
|
+
* **top level** — nested object subforms stay single-column.
|
|
29
|
+
*/
|
|
30
|
+
columns?: 1 | 2;
|
|
32
31
|
}
|
|
33
|
-
declare function Configurator({ schema, value, onChange, title, columns }: ConfiguratorProps): preact.JSX.Element;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* Walks a Zod object schema and renders one form field per property.
|
|
37
|
-
* Recursive — nested objects render as collapsible fieldsets.
|
|
38
|
-
*
|
|
39
|
-
* The dispatcher is a switch on the unwrapped `kindOf()` and a few
|
|
40
|
-
* heuristics on field names (color, css length). Two annotations on
|
|
41
|
-
* the schema influence the UI:
|
|
42
|
-
*
|
|
43
|
-
* - `.describe("…")` → help text shown inside the field's
|
|
44
|
-
* info popover (next to the label)
|
|
45
|
-
* - `.meta({ examples: […] })` → "Insert example" buttons inside the
|
|
46
|
-
* same popover, plus the first example
|
|
47
|
-
* becomes the textarea placeholder for
|
|
48
|
-
* JSON-fallback fields
|
|
49
|
-
*
|
|
50
|
-
* Description + examples are hidden behind a small `?` icon next to
|
|
51
|
-
* each label so the form stays clean. Click the icon → an inline help
|
|
52
|
-
* card expands beneath the field with the description text and one
|
|
53
|
-
* button per example. The card is in the natural document flow so the
|
|
54
|
-
* overlay's `overflow-y: auto` can't clip it.
|
|
55
|
-
*/
|
|
56
|
-
|
|
32
|
+
declare function Configurator({ schema, value, onChange, title, columns }: ConfiguratorProps): import("preact").JSX.Element;
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/configurator/object-field.d.ts
|
|
57
35
|
interface ObjectFieldProps {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
36
|
+
schema: z.ZodObject<z.ZodRawShape>;
|
|
37
|
+
value: Record<string, unknown> | undefined;
|
|
38
|
+
path: string[];
|
|
39
|
+
onChange: (next: Record<string, unknown> | undefined) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Top-level layout columns. `1` (default) — single column.
|
|
42
|
+
* `2` — render top-level fields into two independent flex
|
|
43
|
+
* columns ("masonry"). Each column flows independently so
|
|
44
|
+
* expanding one card doesn't push the other column down. Items
|
|
45
|
+
* are distributed by a greedy bin-pack on a value-aware weight
|
|
46
|
+
* estimate so the columns end up roughly balanced visually (see
|
|
47
|
+
* `estimateFieldWeight` below) — naive odd/even put every heavy
|
|
48
|
+
* card on one side. Order within each column matches schema
|
|
49
|
+
* order. Only honoured at the top level (`path.length === 0`);
|
|
50
|
+
* nested object subforms always render single-column.
|
|
51
|
+
*/
|
|
52
|
+
columns?: 1 | 2;
|
|
75
53
|
}
|
|
76
54
|
declare const ObjectField: FunctionalComponent<ObjectFieldProps>;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
* Zod 4 schema introspection helpers. The configurator walks a Zod
|
|
80
|
-
* object tree and dispatches per-field renderers based on the underlying
|
|
81
|
-
* type — these helpers normalize wrapped schemas (`.optional()`,
|
|
82
|
-
* `.default(...)`, `.nullable()`) so the renderer dispatcher only has
|
|
83
|
-
* to inspect the inner schema.
|
|
84
|
-
*
|
|
85
|
-
* Zod 4 stores its definition under `._def` with a lowercase `type`
|
|
86
|
-
* field — `"string"`, `"object"`, `"optional"`, `"default"`, etc.
|
|
87
|
-
* Wrappers expose `.innerType` for the wrapped schema. This file
|
|
88
|
-
* deliberately couples to those internals; the alternative
|
|
89
|
-
* (`.safeParse(undefined)` heuristics) is slower and brittler.
|
|
90
|
-
*/
|
|
91
|
-
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/configurator/introspect.d.ts
|
|
92
57
|
/**
|
|
93
58
|
* Strip outer `.optional()` / `.default(...)` / `.nullable()` wrappers
|
|
94
59
|
* to find the inner schema. Returns the unwrapped schema and a meta
|
|
95
60
|
* record describing what was unwrapped.
|
|
96
61
|
*/
|
|
97
62
|
declare function unwrap(schema: z.ZodTypeAny): {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
63
|
+
inner: z.ZodTypeAny;
|
|
64
|
+
optional: boolean;
|
|
65
|
+
nullable: boolean;
|
|
66
|
+
defaultValue: unknown;
|
|
102
67
|
};
|
|
103
68
|
/** Discriminate the unwrapped schema kind. Used by the renderer dispatcher. */
|
|
104
69
|
type FieldKind = "string" | "number" | "boolean" | "enum" | "object" | "array" | "union" | "literal" | "record" | "unknown";
|
|
@@ -113,9 +78,9 @@ declare function objectFields(schema: z.ZodTypeAny): Record<string, z.ZodTypeAny
|
|
|
113
78
|
* a flat `_def.checks` array, so introspection is best-effort.
|
|
114
79
|
*/
|
|
115
80
|
declare function stringHints(schema: z.ZodTypeAny): {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
81
|
+
maxLength?: number;
|
|
82
|
+
minLength?: number;
|
|
83
|
+
pattern?: string;
|
|
119
84
|
};
|
|
120
85
|
/**
|
|
121
86
|
* Heuristic: is this field probably a CSS color? A schema that's just
|
|
@@ -142,5 +107,6 @@ declare function schemaDescription(schema: z.ZodTypeAny): string | undefined;
|
|
|
142
107
|
declare function schemaExamples(schema: z.ZodTypeAny): readonly unknown[];
|
|
143
108
|
/** Pretty-print the first example as a JSON placeholder. Used by JSON-fallback fields. */
|
|
144
109
|
declare function placeholderFromExamples(schema: z.ZodTypeAny): string | undefined;
|
|
145
|
-
|
|
146
|
-
export { Configurator, type ConfiguratorProps,
|
|
110
|
+
//#endregion
|
|
111
|
+
export { Configurator, type ConfiguratorProps, FieldKind, ObjectField, enumValues, kindOf, looksLikeColor, objectFields, placeholderFromExamples, schemaDescription, schemaExamples, stringHints, unwrap };
|
|
112
|
+
//# sourceMappingURL=configurator.d.ts.map
|