@w6w/ui 0.2.66 → 0.2.68

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 (56) hide show
  1. package/CHANGELOG.md +19 -1
  2. package/README.md +5 -3
  3. package/dist/{CodeBlock-C1IC5_6O.cjs → CodeBlock-85y9qvE3.cjs} +4 -4
  4. package/dist/{CodeBlock-C1IC5_6O.cjs.map → CodeBlock-85y9qvE3.cjs.map} +1 -1
  5. package/dist/{CodeBlock-CsdRXzb0.js → CodeBlock-a5QVaIGk.js} +158 -131
  6. package/dist/{CodeBlock-CsdRXzb0.js.map → CodeBlock-a5QVaIGk.js.map} +1 -1
  7. package/dist/FormBuilder.d.ts +19 -0
  8. package/dist/ManualWebhookPanel.d.ts +34 -0
  9. package/dist/NodeConfigForm.d.ts +8 -2
  10. package/dist/StepBuilderModal.d.ts +2 -0
  11. package/dist/TriggerFillForm.d.ts +3 -0
  12. package/dist/WebhookListenPanel.d.ts +8 -1
  13. package/dist/code.cjs +1 -1
  14. package/dist/code.mjs +1 -1
  15. package/dist/components/AuthFieldsForm.d.ts +10 -0
  16. package/dist/components/AuthGuide.d.ts +19 -1
  17. package/dist/components/CallableList.d.ts +30 -4
  18. package/dist/components/Combobox.d.ts +5 -0
  19. package/dist/components/ExecutionLogDock.d.ts +44 -0
  20. package/dist/components/ExecutionLogPanel.d.ts +66 -0
  21. package/dist/components/ExecutionLogView.d.ts +30 -0
  22. package/dist/components/ExpressionOptions.d.ts +22 -0
  23. package/dist/components/icons.d.ts +1 -1
  24. package/dist/connection-app-meta-DID4zDg-.cjs +29 -0
  25. package/dist/connection-app-meta-DID4zDg-.cjs.map +1 -0
  26. package/dist/{connection-app-meta-CKBbgN7e.js → connection-app-meta-mmyKM3H9.js} +5725 -4161
  27. package/dist/connection-app-meta-mmyKM3H9.js.map +1 -0
  28. package/dist/dynamic-fields.d.ts +3 -0
  29. package/dist/flow-types.d.ts +27 -1
  30. package/dist/flow.cjs +8 -5
  31. package/dist/flow.cjs.map +1 -1
  32. package/dist/flow.mjs +3681 -2463
  33. package/dist/flow.mjs.map +1 -1
  34. package/dist/form-schema.d.ts +270 -0
  35. package/dist/form-trigger.d.ts +8 -0
  36. package/dist/index.cjs +3 -2
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.ts +8 -4
  39. package/dist/index.mjs +1766 -1343
  40. package/dist/index.mjs.map +1 -1
  41. package/dist/provider.d.ts +14 -0
  42. package/dist/resolve-params.d.ts +2 -0
  43. package/dist/types.d.ts +17 -1
  44. package/dist/workflow-connections.d.ts +11 -0
  45. package/package.json +2 -2
  46. package/src/styles/_callable-list.scss +37 -3
  47. package/src/styles/_connections.scss +29 -0
  48. package/src/styles/_execution-log-view.scss +322 -0
  49. package/src/styles/_expression-modal.scss +7 -0
  50. package/src/styles/_form-builder.scss +245 -0
  51. package/src/styles/_sections.scss +29 -0
  52. package/src/styles.css +725 -7
  53. package/src/styles.scss +2 -0
  54. package/dist/connection-app-meta-CKBbgN7e.js.map +0 -1
  55. package/dist/connection-app-meta-DfA6Yqhh.cjs +0 -28
  56. package/dist/connection-app-meta-DfA6Yqhh.cjs.map +0 -1
@@ -0,0 +1,270 @@
1
+ /**
2
+ * The `@w6w/form` **form definition** — Studio's copy of
3
+ * `packages/internal-apps/apps/form/schema.ts`, the canonical module the host renders and
4
+ * validates with. `@w6w/ui` cannot import that Deno package, so this file carries the same pure
5
+ * code; `__tests__/form-node-parity.test.ts` imports BOTH and pins their exports and behaviour
6
+ * equal, so the builder can never author a form the host reads differently.
7
+ */
8
+ /** Every field type, in the order the builder's palette lists them. */
9
+ export declare const FIELD_TYPES: readonly ["text", "textarea", "email", "number", "phone", "url", "password", "date", "time", "datetime", "select", "radio", "checkboxes", "checkbox", "rating", "file", "hidden", "heading", "paragraph", "pageBreak"];
10
+ export type FieldType = (typeof FIELD_TYPES)[number];
11
+ /** Field types that only lay the form out: they collect nothing and have no `name`. */
12
+ export declare const LAYOUT_FIELD_TYPES: ReadonlySet<FieldType>;
13
+ /** Field types whose answer comes from a fixed list of `options`. */
14
+ export declare const CHOICE_FIELD_TYPES: ReadonlySet<FieldType>;
15
+ /** Field types a submitter types free text into (placeholder, length and pattern apply). */
16
+ export declare const TEXT_FIELD_TYPES: ReadonlySet<FieldType>;
17
+ /** True when the field collects a value (everything except heading, paragraph and page break). */
18
+ export declare function isInputField(type: FieldType): boolean;
19
+ /** One choice of a `select`, `radio` or `checkboxes` field. */
20
+ export interface FormOption {
21
+ label: string;
22
+ /** What the submission records. Defaults to `label` when omitted. */
23
+ value?: string;
24
+ }
25
+ /** Operators a field's `showIf` can test another field's answer with. */
26
+ export declare const CONDITION_OPS: readonly ["equals", "notEquals", "contains", "notContains", "isEmpty", "isNotEmpty", "greaterThan", "lessThan"];
27
+ export type ConditionOp = (typeof CONDITION_OPS)[number];
28
+ /** Show a field only when an EARLIER field's answer matches. */
29
+ export interface FieldCondition {
30
+ /** The `name` of a field that comes before this one. */
31
+ field: string;
32
+ op: ConditionOp;
33
+ /** Compared as text (numbers for `greaterThan`/`lessThan`). Unused by `isEmpty`/`isNotEmpty`. */
34
+ value?: string;
35
+ }
36
+ /** One entry of {@link FormDefinition.fields}: an input, a piece of copy, or a page break. */
37
+ export interface FormField {
38
+ /** Stable id the builder keys and reorders by. Never shown, never in the output. */
39
+ id: string;
40
+ type: FieldType;
41
+ /** The key the answer is recorded under. Required for input fields; letters, digits, `_`. */
42
+ name?: string;
43
+ /** The question. For `heading` it is the heading text; for `pageBreak` the next page's title. */
44
+ label?: string;
45
+ /** Help text under the label. For `paragraph` it is the paragraph itself. */
46
+ help?: string;
47
+ placeholder?: string;
48
+ required?: boolean;
49
+ /** Initial answer (a list for `checkboxes` and multi `select`). URL prefill overrides it. */
50
+ defaultValue?: string | number | boolean | string[];
51
+ /** `select`, `radio`, `checkboxes`. */
52
+ options?: FormOption[];
53
+ /** `select`: allow several choices. `file`: allow several files. */
54
+ multiple?: boolean;
55
+ /** `select`: offer an "Other" choice with a free-text answer? (`radio`/`checkboxes` too.) */
56
+ allowOther?: boolean;
57
+ /** `text`, `textarea`, `email`, `phone`, `url`, `password`. */
58
+ minLength?: number;
59
+ maxLength?: number;
60
+ /** A JavaScript regular expression the whole answer must match (no slashes, no flags). */
61
+ pattern?: string;
62
+ /** Shown when `pattern` does not match. */
63
+ patternMessage?: string;
64
+ /** `number`: bounds and step. `rating`: `max` is the number of stars (default 5). */
65
+ min?: number;
66
+ max?: number;
67
+ step?: number;
68
+ /** `date`/`datetime`/`time`: the earliest and latest allowed answer, as the input writes it. */
69
+ minDate?: string;
70
+ maxDate?: string;
71
+ /** `checkboxes` (and multi `select`): how many choices must / may be picked. */
72
+ minSelected?: number;
73
+ maxSelected?: number;
74
+ /** `textarea`: visible rows. */
75
+ rows?: number;
76
+ /** `file`: accepted types, as the HTML `accept` attribute (".pdf,image/*"). */
77
+ accept?: string;
78
+ /** `file`: per-file size cap in MB (never above the host's own 10 MB). */
79
+ maxFileSizeMb?: number;
80
+ /** `file` with `multiple`: most files one answer may carry. */
81
+ maxFiles?: number;
82
+ /** Lay the field out at half width beside its neighbour on wide screens. */
83
+ width?: "full" | "half";
84
+ /** Show (and require, and record) this field only when the condition holds. */
85
+ showIf?: FieldCondition;
86
+ /**
87
+ * `select`, `radio`, `checkboxes`: take the choices from data instead of the fixed `options` —
88
+ * typically the output of a step wired INTO the form trigger, which runs each time the page opens
89
+ * (a "pre-form step"). Once resolved, the list replaces `options`, so the server checks every
90
+ * answer against it exactly as against a fixed list.
91
+ */
92
+ optionsFrom?: FormDataSource;
93
+ /** `text`: values offered as the submitter types (autocomplete). Free text is still accepted. */
94
+ suggestions?: string[];
95
+ /** `text`: take the autocomplete values from data, as {@link optionsFrom} does for choices. */
96
+ suggestionsFrom?: FormDataSource;
97
+ }
98
+ /**
99
+ * A list of choices read from data: the `{{ }}` expression in `items` names it (usually the output
100
+ * of a pre-form step, e.g. `{{ nodes.get_products.output.items }}`). The host resolves it before
101
+ * the form is read, so the parser sees the list itself; while it is still an expression (the
102
+ * builder, a form with no pre-form steps) the field falls back to its fixed `options`.
103
+ */
104
+ export interface FormDataSource {
105
+ /** The list: an expression that resolves to an array (of strings, numbers or objects). */
106
+ items: unknown;
107
+ /** For objects: the dotted path of each item's label. Default: `label`, `name`, `title`, then the value. */
108
+ label?: string;
109
+ /** For objects: the dotted path of each item's recorded value. Default: `value`, `id`, then the label. */
110
+ value?: string;
111
+ }
112
+ /** What the submitter sees after a successful submission. */
113
+ export interface FormCompletion {
114
+ /** `message` (default) shows a thank-you screen; `redirect` sends the browser to `redirectUrl`. */
115
+ type?: "message" | "redirect";
116
+ title?: string;
117
+ /** Plain text; `{{name}}` is replaced by that field's answer. */
118
+ message?: string;
119
+ /** `http(s)` only. `{{name}}` placeholders are URL-encoded answers. */
120
+ redirectUrl?: string;
121
+ /** Offer a "Submit another response" link on the thank-you screen. */
122
+ allowAnother?: boolean;
123
+ }
124
+ /** Presentation and access settings. */
125
+ export interface FormSettings {
126
+ /** Let `?name=value` in the form URL pre-fill fields (default true). */
127
+ allowPrefill?: boolean;
128
+ /** Show a step indicator on a multi-page form (default true). */
129
+ showProgress?: boolean;
130
+ /** `auto` (default) follows the visitor's system theme. */
131
+ theme?: "auto" | "light" | "dark";
132
+ /** Accent colour for buttons and focus rings, as `#rgb` or `#rrggbb`. */
133
+ accentColor?: string;
134
+ /** Extra CSS appended to the page's own. */
135
+ customCss?: string;
136
+ /** Hide the "Powered by w6w" footer. */
137
+ hideBranding?: boolean;
138
+ /** Stop accepting responses: the page shows `closedMessage` instead of the form. */
139
+ closed?: boolean;
140
+ closedMessage?: string;
141
+ }
142
+ /** The whole form. */
143
+ export interface FormDefinition {
144
+ /** Document version; this module reads version 1. */
145
+ version?: 1;
146
+ title: string;
147
+ /** Plain text under the title; blank lines separate paragraphs. */
148
+ description?: string;
149
+ fields: FormField[];
150
+ /** Label of the final submit button (default "Submit"). */
151
+ submitLabel?: string;
152
+ completion?: FormCompletion;
153
+ settings?: FormSettings;
154
+ }
155
+ /** Host ceiling on one uploaded file (mirrors `@w6w/types` `FILE_MAX_BYTES`). */
156
+ export declare const FORM_FILE_MAX_BYTES: number;
157
+ /** Host ceiling on all files of one submission (mirrors `RUN_FILE_MAX_TOTAL_BYTES`). */
158
+ export declare const FORM_FILES_MAX_TOTAL_BYTES: number;
159
+ /** Most fields one form may hold. */
160
+ export declare const FORM_MAX_FIELDS = 200;
161
+ /** Longest free-text answer accepted when a field sets no `maxLength` of its own. */
162
+ export declare const FORM_TEXT_MAX_CHARS = 20000;
163
+ /** Most choices (or autocomplete values) one field takes from data; the rest are dropped. */
164
+ export declare const FORM_MAX_DATA_OPTIONS = 1000;
165
+ /** A field `name`: a letter or `_` first, then letters, digits or `_`, at most 64 characters. */
166
+ export declare const FIELD_NAME_RE: RegExp;
167
+ /** The value of the hidden honeypot input; a filled one marks a bot. */
168
+ export declare const HONEYPOT_FIELD = "_w6w_hp";
169
+ /** The accent colour when the form sets no `settings.accentColor`. */
170
+ export declare const FORM_DEFAULT_ACCENT = "#4f46e5";
171
+ /**
172
+ * The form page's colour variables: each one's light and dark value, and what it paints. The
173
+ * page's stylesheet is built from this list, and so is the Custom CSS template, so the template
174
+ * always names exactly the variables the page reads.
175
+ */
176
+ export declare const FORM_CSS_VARIABLES: readonly {
177
+ name: string;
178
+ light: string;
179
+ dark: string;
180
+ use: string;
181
+ }[];
182
+ /**
183
+ * The Custom CSS box's starting text: every colour variable and page part, commented out, so the
184
+ * author sees what can be changed. Uncommenting a line applies it; left as is, it changes nothing.
185
+ */
186
+ export declare function customCssTemplate(): string;
187
+ /** The form a new Form trigger starts with. */
188
+ export declare function defaultFormDefinition(): FormDefinition;
189
+ /** The values a new field of `type` starts with (the builder's "add field"). */
190
+ export declare function newField(type: FieldType, id: string, taken: ReadonlySet<string>): FormField;
191
+ /** Human names of the field types (the builder's palette). */
192
+ export declare const FIELD_TYPE_LABELS: Record<FieldType, string>;
193
+ /** `"Email address"` → `"email_address"`; never empty, never starts with a digit. */
194
+ export declare function slugName(label: string): string;
195
+ /** `base`, else `base_2`, `base_3`, … — the first not in `taken`. */
196
+ export declare function uniqueName(base: string, taken: ReadonlySet<string>): string;
197
+ /** An option's recorded value. */
198
+ export declare function optionValue(o: FormOption): string;
199
+ /** One problem with a form definition, pinned to a field when it has one. */
200
+ export interface FormProblem {
201
+ fieldId?: string;
202
+ message: string;
203
+ }
204
+ /**
205
+ * Read an authored value as a form definition. Accepts the object or its JSON text, drops unknown
206
+ * keys and wrongly typed values, and reports every problem it finds — a form with problems still
207
+ * comes back as far as it could be read, so the builder can show it and the page can serve what
208
+ * is valid. `null` only when the value is not a form at all.
209
+ */
210
+ export declare function parseFormDefinition(raw: unknown): {
211
+ form: FormDefinition;
212
+ problems: FormProblem[];
213
+ } | null;
214
+ /**
215
+ * A resolved data list as choices: a scalar item is its own label and value; an object item reads
216
+ * its label and value through the source's paths (or the usual keys). Items with no label are
217
+ * skipped, a repeated value keeps its first item, and at most {@link FORM_MAX_DATA_OPTIONS} come
218
+ * through.
219
+ */
220
+ export declare function dataOptions(items: readonly unknown[], from?: Pick<FormDataSource, "label" | "value">): FormOption[];
221
+ /** Split the fields at each `pageBreak`. A form always has at least one page. */
222
+ export declare function formPages(fields: readonly FormField[]): {
223
+ title?: string;
224
+ fields: FormField[];
225
+ }[];
226
+ /** Does `cond` hold for these answers? (The browser runs the same rules.) */
227
+ export declare function conditionHolds(cond: FieldCondition, answers: Record<string, unknown>): boolean;
228
+ /**
229
+ * Which fields are visible for these answers, in form order. A field is visible when it has no
230
+ * condition, or its condition holds AND the field it depends on is itself visible — so hiding a
231
+ * question also hides everything that hangs off it.
232
+ */
233
+ export declare function visibleFields(fields: readonly FormField[], answers: Record<string, unknown>): FormField[];
234
+ /** An uploaded file before the host stores it. */
235
+ export interface UploadedFile {
236
+ filename: string;
237
+ contentType: string;
238
+ size: number;
239
+ }
240
+ /** What a submission carries, as the host decoded it from the request. */
241
+ export interface RawSubmission {
242
+ /** Every text value per input name (a name repeats for checkboxes / multi select). */
243
+ values: Record<string, string[]>;
244
+ /** Every uploaded file per input name. */
245
+ files: Record<string, UploadedFile[]>;
246
+ }
247
+ /** The validated answers (files still as {@link UploadedFile}) or the per-field errors. */
248
+ export type SubmissionResult = {
249
+ ok: true;
250
+ data: Record<string, unknown>;
251
+ } | {
252
+ ok: false;
253
+ errors: Record<string, string>;
254
+ };
255
+ /**
256
+ * Validate a decoded submission against the form, server-side. Fields hidden by their condition
257
+ * are neither required nor recorded; layout fields are skipped; unknown inputs are ignored.
258
+ * Answers are typed: numbers and ratings as numbers, a checkbox as a boolean, checkboxes and a
259
+ * multi select as string lists, files as lists (or one file when `multiple` is off).
260
+ */
261
+ export declare function validateSubmission(form: FormDefinition, raw: RawSubmission): SubmissionResult;
262
+ /** Does `file` match an HTML `accept` list (".pdf", "image/*", "application/json")? */
263
+ export declare function fileAccepted(accept: string, file: UploadedFile): boolean;
264
+ /**
265
+ * Fill `{{name}}` placeholders from the answers. `encode` URL-encodes each answer (a redirect URL);
266
+ * otherwise answers are inserted as text and the caller escapes the result for its medium.
267
+ */
268
+ export declare function fillPlaceholders(template: string, data: Record<string, unknown>, encode?: boolean): string;
269
+ /** The initial answer of each field for the page: its default, overridden by URL prefill. */
270
+ export declare function initialAnswers(form: FormDefinition, query: Record<string, string | string[]>): Record<string, string | string[] | boolean>;
@@ -0,0 +1,8 @@
1
+ import { SubscriptionSummary } from './types.ts';
2
+ /**
3
+ * The `@w6w/form` subscription that serves `stepId`'s page, picked as the server's
4
+ * `formSubscriptionFor` picks it: the one whose `params.node` names the node, else one bound to no
5
+ * node. A form subscription names its node in `params.node` rather than `nodeId`, because a
6
+ * node-bound row is reserved for app triggers the publish reconcile manages.
7
+ */
8
+ export declare function pickFormSubscription(subs: readonly SubscriptionSummary[], stepId: string): SubscriptionSummary | null;