@kayr/umbika-web-renderer 0.0.0-stage → 0.1.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.
Files changed (77) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +46 -2
  3. package/THIRD_PARTY_LICENSES.txt +20 -0
  4. package/dist/browser/umbika.min.css +23 -0
  5. package/dist/browser/umbika.min.d.mts +437 -0
  6. package/dist/browser/umbika.min.d.ts +437 -0
  7. package/dist/browser/umbika.min.js +60 -0
  8. package/dist/browser/umbika.min.mjs +60 -0
  9. package/dist/casconda.d.ts +2 -0
  10. package/dist/casconda.d.ts.map +1 -0
  11. package/dist/contracts.d.ts +165 -0
  12. package/dist/contracts.d.ts.map +1 -0
  13. package/dist/dom-identity.d.ts +17 -0
  14. package/dist/dom-identity.d.ts.map +1 -0
  15. package/dist/field-presentation.d.ts +26 -0
  16. package/dist/field-presentation.d.ts.map +1 -0
  17. package/dist/index.d.ts +16 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/layout.d.ts +25 -0
  20. package/dist/layout.d.ts.map +1 -0
  21. package/dist/mount.d.ts +14 -0
  22. package/dist/mount.d.ts.map +1 -0
  23. package/dist/render-nodes.d.ts +18 -0
  24. package/dist/render-nodes.d.ts.map +1 -0
  25. package/dist/renderers/multi-select.d.ts +18 -0
  26. package/dist/renderers/multi-select.d.ts.map +1 -0
  27. package/dist/renderers/object.d.ts +6 -0
  28. package/dist/renderers/object.d.ts.map +1 -0
  29. package/dist/renderers/output.d.ts +6 -0
  30. package/dist/renderers/output.d.ts.map +1 -0
  31. package/dist/renderers/select.d.ts +6 -0
  32. package/dist/renderers/select.d.ts.map +1 -0
  33. package/dist/renderers/table.d.ts +6 -0
  34. package/dist/renderers/table.d.ts.map +1 -0
  35. package/dist/renderers/text.d.ts +8 -0
  36. package/dist/renderers/text.d.ts.map +1 -0
  37. package/dist/row-details.d.ts +89 -0
  38. package/dist/row-details.d.ts.map +1 -0
  39. package/dist/standalone/contracts.d.ts +77 -0
  40. package/dist/standalone/contracts.d.ts.map +1 -0
  41. package/dist/standalone/index.d.ts +7 -0
  42. package/dist/standalone/index.d.ts.map +1 -0
  43. package/dist/standalone/mount.d.ts +9 -0
  44. package/dist/standalone/mount.d.ts.map +1 -0
  45. package/dist/summary.d.ts +29 -0
  46. package/dist/summary.d.ts.map +1 -0
  47. package/dist/tags.d.ts +32 -0
  48. package/dist/tags.d.ts.map +1 -0
  49. package/package.json +78 -4
  50. package/src/casconda.js +10 -0
  51. package/src/contracts.js +79 -0
  52. package/src/dom-identity.js +31 -0
  53. package/src/field-presentation.js +71 -0
  54. package/src/index.js +9 -0
  55. package/src/layout.js +176 -0
  56. package/src/mount.js +569 -0
  57. package/src/render-nodes.js +77 -0
  58. package/src/renderers/multi-select.js +211 -0
  59. package/src/renderers/object.js +43 -0
  60. package/src/renderers/output.js +87 -0
  61. package/src/renderers/select.js +104 -0
  62. package/src/renderers/table.js +344 -0
  63. package/src/renderers/text.js +82 -0
  64. package/src/row-details.js +305 -0
  65. package/src/standalone/contracts.js +22 -0
  66. package/src/standalone/index.js +5 -0
  67. package/src/standalone/mount.js +128 -0
  68. package/src/summary.js +135 -0
  69. package/src/tags.js +69 -0
  70. package/styles/base.css +432 -0
  71. package/styles/standalone.css +2 -0
  72. package/styles/themes/default.css +99 -0
  73. package/vendor/LICENSE +21 -0
  74. package/vendor/README.md +33 -0
  75. package/vendor/casconda.min.d.mts +340 -0
  76. package/vendor/casconda.min.d.ts +340 -0
  77. package/vendor/casconda.min.mjs +1 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kayr
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,47 @@
1
- # Temporary Holding Version
1
+ # `@kayr/umbika-web-renderer`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Render a complete Umbika form in a browser, with or without a build step. This
4
+ package is experimental.
5
+
6
+ ```sh
7
+ npm install @kayr/umbika-core @kayr/umbika-web-renderer
8
+ ```
9
+
10
+ In a browser application with CSS import support:
11
+
12
+ ```js
13
+ import { createForm } from "@kayr/umbika-core";
14
+ import { mountWebForm } from "@kayr/umbika-web-renderer";
15
+ import "@kayr/umbika-web-renderer/base.css";
16
+ import "@kayr/umbika-web-renderer/themes/default.css";
17
+
18
+ const form = createForm({
19
+ schema: [{ type: "text", id: "name", label: "Name" }],
20
+ });
21
+ const host = document.createElement("div");
22
+ document.body.append(host);
23
+ mountWebForm(host, { form });
24
+ ```
25
+
26
+ Or mount an authored form directly in an HTML page:
27
+
28
+ ```html
29
+ <link
30
+ rel="stylesheet"
31
+ href="https://cdn.jsdelivr.net/npm/@kayr/umbika-web-renderer@0.1.0/dist/browser/umbika.min.css"
32
+ />
33
+ <div id="contact-form"></div>
34
+ <script src="https://cdn.jsdelivr.net/npm/@kayr/umbika-web-renderer@0.1.0/dist/browser/umbika.min.js"></script>
35
+ <script>
36
+ Umbika.mount("#contact-form", {
37
+ source: 'form 1 contact\n\n*name "Name"',
38
+ onSubmit(data) {
39
+ console.log(data);
40
+ },
41
+ });
42
+ </script>
43
+ ```
44
+
45
+ The same self-contained assets can be served from the installed package's
46
+ `dist/browser/`. The source-first npm entry is
47
+ `@kayr/umbika-web-renderer/standalone`.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Stephen Oney, https://ericsmekens.github.io/jsep/
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,23 @@
1
+ /*! MIT License
2
+
3
+ Copyright (c) 2026 Kayr
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+ */
23
+ .umbika-form,.umbika-form *,.umbika-form *:before,.umbika-form *:after{box-sizing:border-box}.umbika-form{--umbika-font-family: ui-sans-serif, system-ui, sans-serif;--umbika-font-size: 1rem;--umbika-line-height: 1.5;--umbika-color-text: CanvasText;--umbika-color-muted: GrayText;--umbika-color-surface: Canvas;--umbika-color-border: currentColor;--umbika-color-accent: Highlight;--umbika-color-error: #a1261d;--umbika-color-error-surface: #fff3f1;--umbika-space-1: .25rem;--umbika-space-2: .5rem;--umbika-space-3: .75rem;--umbika-space-4: 1rem;--umbika-space-6: 1.5rem;--umbika-field-min-width: 15rem;--umbika-control-min-height: 2.75rem;--umbika-border-width: 1px;--umbika-radius-control: .25rem;--umbika-radius-panel: .5rem;--umbika-focus-width: .1875rem;--umbika-focus-offset: .125rem;--umbika-motion-duration: .16s;--umbika-motion-easing: ease-out;display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,var(--umbika-field-min-width)),1fr));gap:var(--umbika-space-4);max-width:100%;color:var(--umbika-color-text);font-family:var(--umbika-font-family);font-size:var(--umbika-font-size);line-height:var(--umbika-line-height)}.umbika-form button,.umbika-form input,.umbika-form select{min-height:var(--umbika-control-min-height);font:inherit}.umbika-form button,.umbika-form input:not([type=checkbox]),.umbika-form select{max-width:100%}.umbika-form button,.umbika-form [role=button],.umbika-form input,.umbika-form select,.umbika-form [tabindex]{outline-offset:var(--umbika-focus-offset)}.umbika-form :focus-visible{outline:var(--umbika-focus-width) solid var(--umbika-color-accent)}.umbika-workspace :focus{scroll-margin-block:5rem}.umbika-field,.umbika-object,.umbika-table,.umbika-field--calculated,.umbika-field:has(.umbika-field__errors:not(:empty)),.umbika-field__errors,.umbika-workspace{min-width:0}.umbika-object,.umbika-table,.umbika-field--calculated,.umbika-field__errors,.umbika-form>.umbika-calculated{grid-column:1 / -1}.umbika-object{display:grid;grid-template-columns:subgrid;gap:var(--umbika-space-4);margin:0;padding:0;border:0}.umbika-object__heading,.umbika-table__heading,.umbika-workspace__title{margin-block:0 var(--umbika-space-3)}.umbika-field__label{display:block;margin-block-end:var(--umbika-space-1)}.umbika-field__control:not([type=checkbox]){width:100%;padding:var(--umbika-space-2) var(--umbika-space-3);border:var(--umbika-border-width) solid var(--umbika-color-border);border-radius:var(--umbika-radius-control);color:inherit;background:var(--umbika-color-surface)}.umbika-field__output{display:block;min-block-size:1.5em;overflow-wrap:anywhere}.umbika-field__description,.umbika-workspace__location,.umbika-table__empty{margin-block:var(--umbika-space-1);color:var(--umbika-color-muted)}.umbika-field__errors,.umbika-data-table__row-errors{margin-block:var(--umbika-space-2) 0;color:var(--umbika-color-error)}.umbika-object[data-umbika-invalid=false]>.umbika-field__errors{display:none}.umbika-field__control[aria-invalid=true],.umbika-multi-select[data-umbika-invalid=true],.umbika-table[data-umbika-invalid=true]{border-color:var(--umbika-color-error)}.umbika-multi-select{margin:0;padding:var(--umbika-space-3);border:var(--umbika-border-width) solid var(--umbika-color-border);border-radius:var(--umbika-radius-panel)}.umbika-multi-select__choices{display:grid;gap:var(--umbika-space-2);margin-block:var(--umbika-space-2)}.umbika-multi-select__choice{display:flex;align-items:center;min-height:var(--umbika-control-min-height);gap:var(--umbika-space-2)}.umbika-multi-select__control{inline-size:1.25rem;block-size:1.25rem;flex:0 0 auto}.umbika-multi-select__choice[data-umbika-unavailable=true]{color:var(--umbika-color-muted);text-decoration:line-through}.umbika-action,.umbika-table__add-row,.umbika-table__remove-row,.umbika-workspace button{padding:var(--umbika-space-2) var(--umbika-space-3);border:var(--umbika-border-width) solid var(--umbika-color-border);border-radius:var(--umbika-radius-control);color:inherit;background:var(--umbika-color-surface);cursor:pointer}.umbika-action:disabled,.umbika-form button:disabled{cursor:not-allowed;opacity:.6}.umbika-table__rows,.umbika-table__fields,.umbika-workspace__fields{display:grid;gap:var(--umbika-space-3)}.umbika-table__row{padding:var(--umbika-space-3);border:var(--umbika-border-width) solid var(--umbika-color-border);border-radius:var(--umbika-radius-panel)}.umbika-data-table__overflow{max-width:100%;overflow-x:auto;overscroll-behavior-inline:contain}.umbika-data-table{width:100%;min-width:36rem;border-collapse:collapse}.umbika-data-table th,.umbika-data-table td{padding:var(--umbika-space-2) var(--umbika-space-3);border-block-end:var(--umbika-border-width) solid var(--umbika-color-border);text-align:start}.umbika-data-table [data-umbika-align=center]{text-align:center}.umbika-data-table [data-umbika-align=end]{text-align:end}.umbika-data-table__row[data-umbika-invalid=true]{background:var(--umbika-color-error-surface)}.umbika-data-table__actions,.umbika-workspace__actions{display:flex;flex-wrap:wrap;align-items:center;gap:var(--umbika-space-2)}.umbika-data-table__actions{white-space:nowrap}.umbika-data-table__edit{justify-self:start}.umbika-workspace{width:min(58rem,calc(100vw - 2rem));max-width:calc(100vw - 2rem);max-height:calc(100dvh - 2rem);margin:auto;padding:0;overflow:hidden;border:var(--umbika-border-width) solid var(--umbika-color-border);border-radius:var(--umbika-radius-panel);color:var(--umbika-color-text);background:var(--umbika-color-surface)}.umbika-workspace::backdrop{background:#0000008c}.umbika-workspace__panel{padding:var(--umbika-space-4)}.umbika-workspace__contents{max-block-size:inherit}.umbika-workspace__header,.umbika-workspace__confirmation-footer{display:flex;flex-wrap:wrap;align-items:center;gap:var(--umbika-space-2);background:var(--umbika-color-surface)}.umbika-workspace__panel--new{display:grid;grid-template-rows:auto minmax(0,1fr) auto;block-size:calc(100dvh - 2rem);max-block-size:calc(100dvh - 2rem);padding:0;overflow:hidden}.umbika-workspace__panel--new .umbika-workspace__header,.umbika-workspace__panel--new .umbika-workspace__confirmation-footer{position:static}.umbika-workspace__panel--new .umbika-workspace__fields{min-block-size:0;margin-block-start:0;padding:var(--umbika-space-4);overflow:auto}.umbika-workspace__header{position:sticky;z-index:1;inset-block-start:0;padding:var(--umbika-space-4);border-block-end:var(--umbika-border-width) solid var(--umbika-color-border)}.umbika-workspace__header .umbika-workspace__title,.umbika-workspace__hierarchy{inline-size:100%}.umbika-workspace__hierarchy{margin:0;color:var(--umbika-color-muted)}.umbika-workspace__navigation{inline-size:100%;justify-content:space-between}.umbika-workspace__confirmation-footer{position:sticky;z-index:1;inset-block-end:0;justify-content:space-between;padding:var(--umbika-space-4);border-block-start:var(--umbika-border-width) solid var(--umbika-color-border)}.umbika-workspace__danger-area{display:flex;justify-content:end;margin-block-start:var(--umbika-space-6);padding-block-start:var(--umbika-space-4);border-block-start:var(--umbika-border-width) solid var(--umbika-color-error)}.umbika-workspace__fields{margin-block-start:var(--umbika-space-4);grid-template-columns:repeat(auto-fit,minmax(min(100%,var(--umbika-field-min-width)),1fr))}.umbika-workspace__fields>.umbika-object,.umbika-workspace__fields>.umbika-table,.umbika-workspace__fields>.umbika-field--calculated,.umbika-workspace__fields>.umbika-field:has(.umbika-field__errors:not(:empty)),.umbika-workspace__fields>.umbika-field__errors{grid-column:1 / -1}.umbika-visually-hidden{position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;clip-path:inset(50%)}@media(max-width:44rem){.umbika-form,.umbika-workspace__fields{grid-template-columns:minmax(0,1fr)}.umbika-form>*,.umbika-workspace__fields>*{grid-column:1}.umbika-workspace{width:calc(100vw - 1rem);max-width:calc(100vw - 1rem);max-height:calc(100dvh - 1rem)}.umbika-workspace__panel,.umbika-workspace__header,.umbika-workspace__confirmation-footer{padding:var(--umbika-space-3)}.umbika-workspace__panel--new{block-size:calc(100dvh - 1rem);max-block-size:calc(100dvh - 1rem);padding:0}.umbika-workspace__panel--new .umbika-workspace__fields{padding:var(--umbika-space-3)}}@media(prefers-reduced-motion:reduce){.umbika-form,.umbika-form *,.umbika-form *:before,.umbika-form *:after,.umbika-workspace,.umbika-workspace *{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}}.umbika-form[data-umbika-theme=default]{--umbika-font-family: Inter, ui-sans-serif, system-ui, sans-serif;--umbika-color-text: #1d2a31;--umbika-color-muted: #52646d;--umbika-color-surface: #ffffff;--umbika-color-border: #aebbc0;--umbika-color-accent: #176a70;--umbika-color-error: #a1261d;--umbika-color-error-surface: #fff0ed;--umbika-radius-control: .35rem;--umbika-radius-panel: .6rem;--umbika-motion-duration: .14s;padding:clamp(1rem,2vw,1.75rem);border:1px solid #cad3d5;border-radius:.75rem;background:#fff;box-shadow:0 .75rem 2rem #1d2a3114}.umbika-form[data-umbika-theme=default] .umbika-object{padding-block-start:var(--umbika-space-3);border-block-start:2px solid #dce3e5}.umbika-form[data-umbika-theme=default] .umbika-object__heading,.umbika-form[data-umbika-theme=default] .umbika-table__heading{color:#174f53;font-weight:750;letter-spacing:-.015em}.umbika-form[data-umbika-theme=default] .umbika-field__label{font-weight:700}.umbika-form[data-umbika-theme=default] .umbika-field__control:not([type=checkbox]){transition:border-color var(--umbika-motion-duration) var(--umbika-motion-easing),box-shadow var(--umbika-motion-duration) var(--umbika-motion-easing)}.umbika-form[data-umbika-theme=default] .umbika-field__control:not([type=checkbox]):focus{border-color:var(--umbika-color-accent);box-shadow:0 0 0 .2rem #176a701f}.umbika-form[data-umbika-theme=default] .umbika-action,.umbika-form[data-umbika-theme=default] .umbika-table__add-row,.umbika-form[data-umbika-theme=default] .umbika-table__remove-row,.umbika-form[data-umbika-theme=default] .umbika-workspace button{border-color:#7f9298;background:#f7faf9;transition:background-color var(--umbika-motion-duration) var(--umbika-motion-easing),border-color var(--umbika-motion-duration) var(--umbika-motion-easing)}.umbika-form[data-umbika-theme=default] .umbika-action:hover,.umbika-form[data-umbika-theme=default] .umbika-table__add-row:hover,.umbika-form[data-umbika-theme=default] .umbika-workspace button:hover{border-color:var(--umbika-color-accent);background:#edf7f5}.umbika-form[data-umbika-theme=default] .umbika-table__remove-row,.umbika-form[data-umbika-theme=default] .umbika-workspace__discard,.umbika-form[data-umbika-theme=default] .umbika-workspace__remove{color:var(--umbika-color-error)}.umbika-form[data-umbika-theme=default] .umbika-workspace .umbika-workspace__keep{color:#fff;border-color:var(--umbika-color-accent);background:var(--umbika-color-accent)}.umbika-form[data-umbika-theme=default] .umbika-workspace__danger-area{background:#fff8f6}.umbika-form[data-umbika-theme=default] .umbika-table__row,.umbika-form[data-umbika-theme=default] .umbika-multi-select{border-color:#cad3d5;background:#fbfcfc}.umbika-form[data-umbika-theme=default] .umbika-data-table thead{color:#28454b;background:#edf3f3}.umbika-form[data-umbika-theme=default] .umbika-workspace{box-shadow:0 1.25rem 4rem #0e1f2347}
@@ -0,0 +1,437 @@
1
+ /*! MIT License
2
+
3
+ Copyright (c) 2026 Kayr
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+ */
23
+ interface SelectOption {
24
+ [metadata: string]: unknown;
25
+ /** Stable value stored in form data. */
26
+ value: string;
27
+ /** Human-readable option label. */
28
+ label: string;
29
+ }
30
+ type JsonValue = null | string | number | boolean | readonly JsonValue[] | {
31
+ readonly [key: string]: JsonValue;
32
+ };
33
+ type FormVars = Readonly<Record<string, JsonValue>>;
34
+ type OptionSource = readonly SelectOption[] | ((scope: Readonly<ConditionScope>) => readonly SelectOption[] | null | undefined);
35
+ interface TextField {
36
+ type: "text";
37
+ /** Stable identity among sibling schema nodes. */
38
+ id: string;
39
+ /** Human-readable field label. */
40
+ label: string;
41
+ onChange?: InputChange;
42
+ required?: Condition;
43
+ relevant?: Condition;
44
+ readOnly?: Condition;
45
+ validate?: CustomValidator;
46
+ }
47
+ interface SelectField {
48
+ type: "select";
49
+ /** Stable identity among sibling schema nodes. */
50
+ id: string;
51
+ /** Human-readable field label. */
52
+ label: string;
53
+ onChange?: InputChange;
54
+ required?: Condition;
55
+ relevant?: Condition;
56
+ readOnly?: Condition;
57
+ validate?: CustomValidator;
58
+ options: OptionSource;
59
+ }
60
+ interface MultiSelectField {
61
+ type: "multi-select";
62
+ /** Stable identity among sibling schema nodes. */
63
+ id: string;
64
+ /** Human-readable field label. */
65
+ label: string;
66
+ onChange?: InputChange;
67
+ required?: Condition;
68
+ relevant?: Condition;
69
+ readOnly?: Condition;
70
+ validate?: MultiSelectValidator;
71
+ options: OptionSource;
72
+ }
73
+ type CalculatedValue = string | number | boolean | null | undefined;
74
+ interface CalculatedValidatorScope extends ConditionScope {
75
+ /** Current owned calculated result. */
76
+ value: CalculatedValue;
77
+ }
78
+ interface CalculatedField {
79
+ type: "calculated";
80
+ /** Stable identity among sibling schema nodes. */
81
+ id: string;
82
+ /** Human-readable field label. */
83
+ label: string;
84
+ calculate: (scope: Readonly<ConditionScope>) => CalculatedValue;
85
+ onChange?: never;
86
+ required?: never;
87
+ readOnly?: never;
88
+ options?: never;
89
+ relevant?: Condition;
90
+ validate?: (scope: Readonly<CalculatedValidatorScope>) => string | undefined;
91
+ }
92
+ type FormField = TextField | SelectField | MultiSelectField | CalculatedField;
93
+ interface ObjectField {
94
+ type: "object";
95
+ /** Stable identity among sibling schema nodes. */
96
+ id: string;
97
+ /** Optional human-readable object label. */
98
+ label?: string;
99
+ relevant?: Condition;
100
+ readOnly?: never;
101
+ /** Validate this object as a whole after evaluating its descendants. */
102
+ validate?: ObjectValidator;
103
+ children: readonly FormNode[];
104
+ }
105
+ interface TableField {
106
+ type: "table";
107
+ /** Stable identity among sibling schema nodes. */
108
+ id: string;
109
+ /** Optional human-readable table label. */
110
+ label?: string;
111
+ relevant?: Condition;
112
+ readOnly?: never;
113
+ /** Validate the current rows as one semantic table value. */
114
+ validate?: TableValidator;
115
+ children: readonly FormNode[];
116
+ }
117
+ type FormNode = FormField | ObjectField | TableField;
118
+ type FieldPath = readonly [string, ...string[]];
119
+ type FormValues = Readonly<Record<string, unknown>>;
120
+ interface FormContext {
121
+ kind: "form" | "object" | "table" | "row";
122
+ data: FormValues | readonly FormValues[];
123
+ path: readonly string[];
124
+ parent: FormContext | null;
125
+ /** Present only for row contexts. */
126
+ id: string | null;
127
+ /** Present only for row contexts. */
128
+ index: number | null;
129
+ /** Present only for row contexts that have a preceding row. */
130
+ previous: FormContext | null;
131
+ }
132
+ interface ConditionScope {
133
+ /** Immutable supporting data, separate from answers. */
134
+ readonly vars: FormVars;
135
+ /** Current root form values. */
136
+ form: FormValues;
137
+ /** Current immediate containing-object values. */
138
+ parent: FormValues;
139
+ /** Immediate structural container with links toward the form root. */
140
+ context: FormContext;
141
+ }
142
+ type InputPayload = unknown;
143
+ interface InputAncestor extends FormValues {
144
+ readonly current: FormValues;
145
+ readonly parent: InputAncestor | undefined;
146
+ readonly form: FormValues;
147
+ }
148
+ interface InputScope {
149
+ readonly vars: FormVars;
150
+ readonly value: unknown;
151
+ readonly current: FormValues;
152
+ /** Enclosing data container, skipping table collections; absent at root. */
153
+ readonly parent: InputAncestor | undefined;
154
+ readonly form: FormValues;
155
+ readonly context: FormContext;
156
+ }
157
+ /** Short-lived, schema-aware writable view of existing stored answers. */
158
+ interface InputDataTarget {
159
+ [field: string]: any;
160
+ }
161
+ interface InputTarget {
162
+ [field: string]: any;
163
+ current: InputDataTarget;
164
+ parent: InputTarget | undefined;
165
+ form: InputTarget;
166
+ }
167
+ type InputPredicate = boolean | ((scope: Readonly<InputScope>) => boolean);
168
+ type InputResolver = (scope: Readonly<InputScope>) => unknown;
169
+ type InputSetter = (target: InputTarget, value: unknown) => void;
170
+ interface CopyAction {
171
+ to: string | InputSetter;
172
+ value: string | InputResolver;
173
+ when?: InputPredicate;
174
+ }
175
+ interface InputChange {
176
+ copy: readonly CopyAction[];
177
+ }
178
+ interface ObjectValidatorScope extends ConditionScope {
179
+ /** Current working values, including retained answers of irrelevant children. */
180
+ readonly value: FormValues;
181
+ /** Current effective relevance of a declared direct child. */
182
+ isRelevant(childId: string): boolean;
183
+ }
184
+ type ObjectValidator = (scope: Readonly<ObjectValidatorScope>) => string | undefined;
185
+ interface TableValidatorScope extends ConditionScope {
186
+ /** Current declared row values for this concrete table instance. */
187
+ readonly rows: readonly FormValues[];
188
+ }
189
+ type TableValidator = (scope: Readonly<TableValidatorScope>) => string | undefined;
190
+ type Condition = boolean | ((scope: Readonly<ConditionScope>) => boolean);
191
+ interface CustomValidatorScope extends ConditionScope {
192
+ /** Current owned field value after built-in structural validation. */
193
+ value: string;
194
+ }
195
+ type CustomValidator = (scope: Readonly<CustomValidatorScope>) => string | undefined;
196
+ interface MultiSelectValidatorScope extends ConditionScope {
197
+ /** Current owned selection after built-in array and option validation. */
198
+ value: readonly string[];
199
+ }
200
+ type MultiSelectValidator = (scope: Readonly<MultiSelectValidatorScope>) => string | undefined;
201
+ interface ValidationError {
202
+ /** Concrete path of the node that owns the error. */
203
+ path: FieldPath;
204
+ code: "required" | "type" | "option" | "custom";
205
+ message: string;
206
+ }
207
+ interface FieldState {
208
+ field: FormField;
209
+ /** Current options for a relevant select instance. */
210
+ options?: readonly SelectOption[];
211
+ /** Concrete answer path. */
212
+ path: FieldPath;
213
+ value: unknown;
214
+ touched: boolean;
215
+ relevant: boolean;
216
+ required: boolean;
217
+ /** Whether the engine currently prevents direct edits. */
218
+ readOnly: boolean;
219
+ valid: boolean;
220
+ /** Visible validation errors. */
221
+ errors: ValidationError[];
222
+ }
223
+ interface ValidationResult {
224
+ valid: boolean;
225
+ errors: ValidationError[];
226
+ }
227
+ interface SectionFacts {
228
+ path: FieldPath;
229
+ relevant: boolean;
230
+ /** Validity of the section's own validator, without descendant errors. */
231
+ ownValid: boolean;
232
+ /** Validity of the section and all relevant descendants. */
233
+ valid: boolean;
234
+ /** Visible errors owned directly by this section. */
235
+ errors: ValidationError[];
236
+ /** Visible errors from this section and its descendants. */
237
+ subtreeErrors: ValidationError[];
238
+ }
239
+ interface SectionRow {
240
+ id: string;
241
+ path: FieldPath;
242
+ }
243
+ type SectionState = SectionFacts & ({
244
+ kind: "object";
245
+ } | {
246
+ kind: "row";
247
+ } | {
248
+ kind: "table";
249
+ rows: SectionRow[];
250
+ });
251
+ interface ActiveTextField {
252
+ type: "text";
253
+ /** Stable identity among sibling schema nodes. */
254
+ id: string;
255
+ label: string;
256
+ /** Concrete answer path. */
257
+ path: FieldPath;
258
+ value: unknown;
259
+ touched: boolean;
260
+ /** Evaluated requiredness. */
261
+ required: boolean;
262
+ /** Whether the engine currently prevents direct edits. */
263
+ readOnly: boolean;
264
+ valid: boolean;
265
+ /** Visible validation errors. */
266
+ errors: ValidationError[];
267
+ }
268
+ interface ActiveSelectField {
269
+ type: "select";
270
+ /** Stable identity among sibling schema nodes. */
271
+ id: string;
272
+ label: string;
273
+ options: readonly SelectOption[];
274
+ /** Concrete answer path. */
275
+ path: FieldPath;
276
+ value: unknown;
277
+ touched: boolean;
278
+ /** Evaluated requiredness. */
279
+ required: boolean;
280
+ /** Whether the engine currently prevents direct edits. */
281
+ readOnly: boolean;
282
+ valid: boolean;
283
+ /** Visible validation errors. */
284
+ errors: ValidationError[];
285
+ }
286
+ interface ActiveMultiSelectField {
287
+ type: "multi-select";
288
+ /** Stable identity among sibling schema nodes. */
289
+ id: string;
290
+ label: string;
291
+ options: readonly SelectOption[];
292
+ /** Concrete answer path. */
293
+ path: FieldPath;
294
+ value: unknown;
295
+ touched: boolean;
296
+ /** Evaluated requiredness. */
297
+ required: boolean;
298
+ /** Whether the engine currently prevents direct edits. */
299
+ readOnly: boolean;
300
+ valid: boolean;
301
+ /** Visible validation errors. */
302
+ errors: ValidationError[];
303
+ }
304
+ interface ActiveCalculatedField {
305
+ type: "calculated";
306
+ /** Stable identity among sibling schema nodes. */
307
+ id: string;
308
+ label: string;
309
+ /** Concrete calculated-value path. */
310
+ path: FieldPath;
311
+ value: CalculatedValue;
312
+ valid: boolean;
313
+ /** Visible validation errors. */
314
+ errors: ValidationError[];
315
+ }
316
+ type ActiveField = ActiveTextField | ActiveSelectField | ActiveMultiSelectField | ActiveCalculatedField;
317
+ interface ActiveObjectField {
318
+ type: "object";
319
+ /** Stable identity among sibling schema nodes. */
320
+ id: string;
321
+ /** Optional human-readable object label. */
322
+ label?: string;
323
+ /** Concrete object path. */
324
+ path: FieldPath;
325
+ /** Visible object-owned validation errors. */
326
+ errors: ValidationError[];
327
+ /** Ordered active descendants. */
328
+ children: ActiveFieldNode[];
329
+ }
330
+ interface ActiveTableField {
331
+ type: "table";
332
+ id: string;
333
+ label?: string;
334
+ path: FieldPath;
335
+ /** Validity owned by this table's validator, excluding descendants. */
336
+ valid: boolean;
337
+ /** Visible table-owned validation errors. */
338
+ errors: ValidationError[];
339
+ rows: ActiveTableRow[];
340
+ }
341
+ interface ActiveTableRow {
342
+ type: "row";
343
+ /** Opaque identity stable for this form session. */
344
+ id: string;
345
+ path: FieldPath;
346
+ children: ActiveFieldNode[];
347
+ }
348
+ type ActiveFieldNode = ActiveField | ActiveObjectField | ActiveTableField;
349
+ /** Public operations available in the basic engine contract. */
350
+ interface Form {
351
+ getFields: () => FormNode[];
352
+ getActiveFields: () => ActiveFieldNode[];
353
+ getValue: (path: FieldPath) => unknown;
354
+ input: (path: FieldPath, payload: InputPayload) => void;
355
+ setValue: (path: FieldPath, value: unknown) => void;
356
+ appendRow: (tablePath: FieldPath, initialData?: FormValues) => string;
357
+ removeRow: (rowPath: FieldPath) => void;
358
+ touch: (path: FieldPath) => void;
359
+ getFieldState: (path: FieldPath) => FieldState;
360
+ getSectionState: (path: FieldPath) => SectionState;
361
+ isValid: () => boolean;
362
+ validate: () => ValidationResult;
363
+ validateSection: (path: FieldPath) => ValidationResult;
364
+ getData: () => Record<string, unknown>;
365
+ getVars: () => FormVars;
366
+ getSubmissionData: () => Record<string, unknown>;
367
+ }
368
+
369
+ type WebTableMode = "cards" | "table";
370
+ type WebTableColumnAlignment = "start" | "center" | "end";
371
+ type WebTableColumnLayout = {
372
+ path: FieldPath;
373
+ label?: string;
374
+ align?: WebTableColumnAlignment;
375
+ };
376
+ type WebTableLayout = {
377
+ path: FieldPath;
378
+ mode: WebTableMode;
379
+ columns?: readonly WebTableColumnLayout[];
380
+ };
381
+ type WebFormLayout$1 = {
382
+ tables?: readonly WebTableLayout[];
383
+ };
384
+
385
+ type WebFormLayout = WebFormLayout$1;
386
+
387
+ type StandaloneMountOptions$1 = {
388
+ source: string;
389
+ vars?: FormVars;
390
+ data?: FormValues;
391
+ instanceId?: string;
392
+ layout?: WebFormLayout;
393
+ theme?: string;
394
+ onSubmit?: (submission: Record<string, unknown>) => void;
395
+ submitLabel?: string;
396
+ };
397
+ type MountedStandaloneWebForm$1 = {
398
+ form: Form;
399
+ root: HTMLFormElement;
400
+ refresh: () => void;
401
+ focus: (path: FieldPath) => boolean;
402
+ dispose: () => void;
403
+ };
404
+
405
+ type FormLanguageDiagnosticCategory = "syntax" | "declaration" | "schema" | "expression" | "vars";
406
+ interface FormLanguageSourcePosition {
407
+ /** Zero-based UTF-16 source offset. */
408
+ readonly offset: number;
409
+ /** One-based line. */
410
+ readonly line: number;
411
+ /** One-based column. */
412
+ readonly column: number;
413
+ }
414
+ interface FormLanguageSourceRange {
415
+ readonly start: FormLanguageSourcePosition;
416
+ readonly end: FormLanguageSourcePosition;
417
+ }
418
+ interface FormLanguageDiagnostic {
419
+ readonly category: FormLanguageDiagnosticCategory;
420
+ readonly message: string;
421
+ readonly range: FormLanguageSourceRange;
422
+ }
423
+
424
+ declare class FormLanguageError extends Error {
425
+ readonly diagnostics: readonly FormLanguageDiagnostic[];
426
+ constructor(diagnostics: readonly FormLanguageDiagnostic[], options?: {
427
+ cause?: unknown;
428
+ });
429
+ }
430
+
431
+ declare function mount(target: string | HTMLElement, options: StandaloneMountOptions$1): MountedStandaloneWebForm$1;
432
+
433
+ type MountedStandaloneWebForm = MountedStandaloneWebForm$1;
434
+ type StandaloneMountOptions = StandaloneMountOptions$1;
435
+
436
+ export { FormLanguageError, type MountedStandaloneWebForm, type StandaloneMountOptions, mount };
437
+ export as namespace Umbika;