mlform 0.1.9 → 0.1.11

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 (224) hide show
  1. package/README.md +18 -16
  2. package/dist/builtins-D8rXH4ED.js +725 -0
  3. package/dist/{design-system-CIU_vH6O.js → design-6suKVQDo.js} +15 -15
  4. package/dist/mlform/builtins.mjs +2 -0
  5. package/dist/mlform/{design-system.mjs → design.mjs} +2 -2
  6. package/dist/mlform/kit.mjs +1896 -3
  7. package/dist/mlform/primitives.mjs +2 -2
  8. package/dist/mlform/runtime.mjs +3 -4
  9. package/dist/mlform/schema.mjs +2 -102
  10. package/dist/mlform/transport.mjs +2 -2
  11. package/dist/{primitives-Di95y_ur.js → primitives-k9HTnd72.js} +2303 -3384
  12. package/dist/{runtime-C5iTM3uu.js → runtime-CI7vlp9i.js} +655 -791
  13. package/dist/schema-DSAZ6bts.js +88 -0
  14. package/dist/{transport-B6ePTLFK.js → transport-CO6udZ6z.js} +605 -575
  15. package/dist/types/{builtins-ml/definitions/index.d.ts → builtins/definitions/collections.d.ts} +1 -15
  16. package/dist/types/{shared/object.d.ts → builtins/definitions/fields/value-helpers.d.ts} +1 -0
  17. package/dist/types/builtins/definitions/index.d.ts +16 -0
  18. package/dist/types/{builtins-ml → builtins}/definitions/shared.d.ts +2 -9
  19. package/dist/types/builtins/index.d.ts +6 -0
  20. package/dist/types/builtins/mapped-category-behavior.d.ts +2 -0
  21. package/dist/types/builtins/registry-pack.d.ts +10 -0
  22. package/dist/types/{design-system → design}/index.d.ts +1 -1
  23. package/dist/types/{design-system/recipes/index.d.ts → design/recipes/collections.d.ts} +0 -1
  24. package/dist/types/design/recipes/index.d.ts +2 -0
  25. package/dist/types/design/resolve/index.d.ts +4 -0
  26. package/dist/types/{design-system/resolve/index.d.ts → design/resolve/resolve-design.d.ts} +0 -3
  27. package/dist/types/{design-system → design}/runtime/index.d.ts +3 -3
  28. package/dist/types/{design-system/themes/index.d.ts → design/themes/collections.d.ts} +0 -2
  29. package/dist/types/design/themes/index.d.ts +3 -0
  30. package/dist/types/{design-system → design}/types.d.ts +1 -1
  31. package/dist/types/kit/constants.d.ts +2 -10
  32. package/dist/types/kit/defaults.d.ts +1 -1
  33. package/dist/types/kit/disclosure-root-styles.d.ts +1 -0
  34. package/dist/types/kit/error-navigation.d.ts +2 -1
  35. package/dist/types/kit/index.d.ts +4 -5
  36. package/dist/types/{presentation → kit/kinds}/define-field-kind.d.ts +11 -3
  37. package/dist/types/kit/kinds/define-report-kind.d.ts +40 -0
  38. package/dist/types/kit/kinds/index.d.ts +3 -0
  39. package/dist/types/kit/kinds/register-kind.d.ts +5 -0
  40. package/dist/types/kit/layout-helpers.d.ts +7 -11
  41. package/dist/types/kit/layout-node-render.d.ts +4 -4
  42. package/dist/types/kit/layout-node-resolver.d.ts +1 -1
  43. package/dist/types/kit/{accordion-root.d.ts → layout-root.d.ts} +3 -4
  44. package/dist/types/kit/layout-types.d.ts +8 -36
  45. package/dist/types/kit/layout-utils.d.ts +0 -1
  46. package/dist/types/kit/layout.d.ts +2 -2
  47. package/dist/types/kit/mount-types.d.ts +8 -7
  48. package/dist/types/kit/panel-nav.d.ts +1 -1
  49. package/dist/types/kit/tabs-root.d.ts +1 -2
  50. package/dist/types/kit/types.d.ts +2 -3
  51. package/dist/types/kit/view-core-types.d.ts +110 -0
  52. package/dist/types/kit/view-layout-state.d.ts +10 -3
  53. package/dist/types/kit/view-navigation.d.ts +3 -3
  54. package/dist/types/kit/view-snapshot-cache.d.ts +3 -3
  55. package/dist/types/kit/view-snapshot.d.ts +4 -4
  56. package/dist/types/kit/view-types.d.ts +1 -172
  57. package/dist/types/kit/view.d.ts +2 -8
  58. package/dist/types/kit/wizard-root.d.ts +1 -2
  59. package/dist/types/primitives/base-async-report-element.d.ts +1 -1
  60. package/dist/types/primitives/base-field-element.d.ts +3 -3
  61. package/dist/types/primitives/base-report-element.d.ts +3 -3
  62. package/dist/types/primitives/components/descriptor-content.d.ts +4 -0
  63. package/dist/types/primitives/components/error-focus.d.ts +3 -2
  64. package/dist/types/primitives/components/field-frame-feedback.d.ts +3 -3
  65. package/dist/types/primitives/components/field-frame.d.ts +3 -3
  66. package/dist/types/primitives/components/form-errors.d.ts +2 -2
  67. package/dist/types/primitives/components/form-root-presenters.d.ts +6 -11
  68. package/dist/types/primitives/components/form-root-state.d.ts +4 -6
  69. package/dist/types/primitives/components/form-root-templates.d.ts +4 -8
  70. package/dist/types/primitives/components/form-root.d.ts +4 -4
  71. package/dist/types/primitives/components/report-frame.d.ts +4 -4
  72. package/dist/types/primitives/components/submit-button.d.ts +2 -2
  73. package/dist/types/primitives/constants.d.ts +6 -9
  74. package/dist/types/primitives/controller-types.d.ts +96 -0
  75. package/dist/types/primitives/descriptor-resolution.d.ts +6 -0
  76. package/dist/types/primitives/descriptors/content.d.ts +61 -0
  77. package/dist/types/primitives/descriptors/field.d.ts +32 -0
  78. package/dist/types/primitives/descriptors/index.d.ts +5 -0
  79. package/dist/types/primitives/descriptors/registry.d.ts +11 -0
  80. package/dist/types/primitives/descriptors/report.d.ts +20 -0
  81. package/dist/types/primitives/index.d.ts +8 -3
  82. package/dist/types/primitives/mount-form.d.ts +2 -2
  83. package/dist/types/primitives/request-runner.d.ts +13 -0
  84. package/dist/types/primitives/types.d.ts +16 -53
  85. package/dist/types/runtime/errors.d.ts +1 -2
  86. package/dist/types/runtime/index.d.ts +2 -4
  87. package/dist/types/runtime/reports/controller.d.ts +3 -2
  88. package/dist/types/runtime/runtime-controller.d.ts +1 -5
  89. package/dist/types/runtime/state/engine.d.ts +1 -2
  90. package/dist/types/runtime/submission/create-submitter.d.ts +1 -1
  91. package/dist/types/runtime/submission/index.d.ts +1 -1
  92. package/dist/types/runtime/submission/lifecycle.d.ts +1 -2
  93. package/dist/types/runtime/submission/pipeline.d.ts +1 -1
  94. package/dist/types/runtime/submission/report-fetches.d.ts +2 -0
  95. package/dist/types/runtime/submission/types.d.ts +1 -2
  96. package/dist/types/runtime/types/form.d.ts +9 -13
  97. package/dist/types/runtime/types/index.d.ts +0 -1
  98. package/dist/types/runtime/types/pipeline.d.ts +10 -10
  99. package/dist/types/runtime/types/registry.d.ts +2 -3
  100. package/dist/types/runtime/types/report.d.ts +4 -1
  101. package/dist/types/runtime/types/transport.d.ts +3 -4
  102. package/dist/types/runtime/utils.d.ts +1 -3
  103. package/dist/types/runtime/validation/form.d.ts +1 -1
  104. package/dist/types/schema/ids.d.ts +1 -0
  105. package/dist/types/schema/index.d.ts +3 -1
  106. package/dist/types/schema/registry.d.ts +2 -4
  107. package/dist/types/schema/report-fetch-request.d.ts +6 -0
  108. package/dist/types/schema/types/form.d.ts +0 -3
  109. package/dist/types/schema/types/registry.d.ts +0 -5
  110. package/dist/types/schema/types/report.d.ts +25 -3
  111. package/dist/types/schema/types/submit.d.ts +11 -0
  112. package/dist/types/transport/errors.d.ts +1 -2
  113. package/dist/types/transport/index.d.ts +2 -0
  114. package/dist/types/transport/request-runner.d.ts +16 -0
  115. package/package.json +14 -27
  116. package/dist/builtins-ml-pjab8_gu.js +0 -3878
  117. package/dist/errors-CTNw8fwS.js +0 -8
  118. package/dist/kit-QY6zff-h.js +0 -1888
  119. package/dist/mlform/behaviors.mjs +0 -32
  120. package/dist/mlform/builtins-ml.mjs +0 -2
  121. package/dist/mlform/presentation.mjs +0 -2
  122. package/dist/mlform.mjs +0 -8
  123. package/dist/presentation-BrlVO4oV.js +0 -200
  124. package/dist/strings-CWwrrYzz.js +0 -4
  125. package/dist/types/behaviors/index.d.ts +0 -3
  126. package/dist/types/builtins-ml/index.d.ts +0 -5
  127. package/dist/types/index.d.ts +0 -13
  128. package/dist/types/kit/accordion-root-styles.d.ts +0 -1
  129. package/dist/types/kit/accordion.d.ts +0 -2
  130. package/dist/types/kit/tabs.d.ts +0 -2
  131. package/dist/types/kit/wizard.d.ts +0 -2
  132. package/dist/types/packs/default.d.ts +0 -2
  133. package/dist/types/packs/index.d.ts +0 -3
  134. package/dist/types/packs/ml.d.ts +0 -2
  135. package/dist/types/packs/shared.d.ts +0 -24
  136. package/dist/types/presentation/define-explanation-kind.d.ts +0 -11
  137. package/dist/types/presentation/define-report-kind.d.ts +0 -15
  138. package/dist/types/presentation/index.d.ts +0 -10
  139. package/dist/types/presentation/register-kind.d.ts +0 -6
  140. package/dist/types/presentation/registry.d.ts +0 -15
  141. package/dist/types/presentation/types/explanation.d.ts +0 -32
  142. package/dist/types/presentation/types/field.d.ts +0 -36
  143. package/dist/types/presentation/types/presentation.d.ts +0 -61
  144. package/dist/types/presentation/types/report.d.ts +0 -41
  145. package/dist/types/primitives/base-explanation-element.d.ts +0 -22
  146. package/dist/types/primitives/components/declarative-explanation.d.ts +0 -5
  147. package/dist/types/primitives/components/explanation-panel.d.ts +0 -24
  148. package/dist/types/primitives/components/presentation.d.ts +0 -4
  149. package/dist/types/primitives/presentation.d.ts +0 -8
  150. package/dist/types/runtime/explanations/controller.d.ts +0 -13
  151. package/dist/types/runtime/explanations/index.d.ts +0 -1
  152. package/dist/types/runtime/schema/index.d.ts +0 -7
  153. package/dist/types/runtime/submission/explanations.d.ts +0 -2
  154. package/dist/types/runtime/types/explanation.d.ts +0 -15
  155. package/dist/types/schema/types/explanation.d.ts +0 -43
  156. package/dist/types/shared/errors.d.ts +0 -3
  157. package/dist/types/shared/index.d.ts +0 -3
  158. package/dist/types/shared/strings.d.ts +0 -1
  159. package/dist/utils-J5o8lkea.js +0 -29
  160. /package/dist/types/{runtime → builtins}/constants.d.ts +0 -0
  161. /package/dist/types/{builtins-ml → builtins}/definitions/fields/boolean.d.ts +0 -0
  162. /package/dist/types/{builtins-ml → builtins}/definitions/fields/category.d.ts +0 -0
  163. /package/dist/types/{builtins-ml → builtins}/definitions/fields/date.d.ts +0 -0
  164. /package/dist/types/{builtins-ml → builtins}/definitions/fields/long-text.d.ts +0 -0
  165. /package/dist/types/{builtins-ml → builtins}/definitions/fields/mapped-category.d.ts +0 -0
  166. /package/dist/types/{builtins-ml → builtins}/definitions/fields/multi-choice.d.ts +0 -0
  167. /package/dist/types/{builtins-ml → builtins}/definitions/fields/number.d.ts +0 -0
  168. /package/dist/types/{builtins-ml → builtins}/definitions/fields/rating.d.ts +0 -0
  169. /package/dist/types/{builtins-ml → builtins}/definitions/fields/series-helpers.d.ts +0 -0
  170. /package/dist/types/{builtins-ml → builtins}/definitions/fields/series.d.ts +0 -0
  171. /package/dist/types/{builtins-ml → builtins}/definitions/fields/single-choice.d.ts +0 -0
  172. /package/dist/types/{builtins-ml → builtins}/definitions/fields/text.d.ts +0 -0
  173. /package/dist/types/{builtins-ml → builtins}/definitions/reports/classifier.d.ts +0 -0
  174. /package/dist/types/{builtins-ml → builtins}/definitions/reports/regressor.d.ts +0 -0
  175. /package/dist/types/{design-system → design}/constants.d.ts +0 -0
  176. /package/dist/types/{design-system → design}/contract/component-keys.d.ts +0 -0
  177. /package/dist/types/{design-system → design}/contract/component-tokens.d.ts +0 -0
  178. /package/dist/types/{design-system → design}/contract/global-tokens.d.ts +0 -0
  179. /package/dist/types/{design-system → design}/contract/index.d.ts +0 -0
  180. /package/dist/types/{design-system → design}/contract/token-keys.d.ts +0 -0
  181. /package/dist/types/{design-system → design}/recipes/contrast.d.ts +0 -0
  182. /package/dist/types/{design-system → design}/recipes/default.d.ts +0 -0
  183. /package/dist/types/{design-system → design}/recipes/minimal.d.ts +0 -0
  184. /package/dist/types/{design-system → design}/recipes/soft.d.ts +0 -0
  185. /package/dist/types/{design-system → design}/registry/builtins.d.ts +0 -0
  186. /package/dist/types/{design-system → design}/registry/create-registry.d.ts +0 -0
  187. /package/dist/types/{design-system → design}/registry/deep-freeze.d.ts +0 -0
  188. /package/dist/types/{design-system → design}/registry/define-recipe.d.ts +0 -0
  189. /package/dist/types/{design-system → design}/registry/define-theme.d.ts +0 -0
  190. /package/dist/types/{design-system → design}/registry/define-token-maps.d.ts +0 -0
  191. /package/dist/types/{design-system → design}/registry/index.d.ts +0 -0
  192. /package/dist/types/{design-system → design}/resolve/diagnostics.d.ts +0 -0
  193. /package/dist/types/{design-system → design}/resolve/merge-config.d.ts +0 -0
  194. /package/dist/types/{design-system → design}/resolve/migrate-tokens.d.ts +0 -0
  195. /package/dist/types/{design-system → design}/resolve/resolve-mode.d.ts +0 -0
  196. /package/dist/types/{design-system → design}/resolve/resolve-recipe.d.ts +0 -0
  197. /package/dist/types/{design-system → design}/resolve/resolve-theme.d.ts +0 -0
  198. /package/dist/types/{design-system → design}/resolve/resolve-tokens.d.ts +0 -0
  199. /package/dist/types/{design-system → design}/runtime/apply-tokens.d.ts +0 -0
  200. /package/dist/types/{design-system/runtime/attach-design-system.d.ts → design/runtime/attach-design.d.ts} +0 -0
  201. /package/dist/types/{design-system → design}/runtime/controller-helpers.d.ts +0 -0
  202. /package/dist/types/{design-system → design}/runtime/create-stylesheet.d.ts +0 -0
  203. /package/dist/types/{design-system → design}/runtime/declarations.d.ts +0 -0
  204. /package/dist/types/{design-system/runtime/design-system-controller.d.ts → design/runtime/design-controller.d.ts} +0 -0
  205. /package/dist/types/{design-system → design}/runtime/fingerprint.d.ts +0 -0
  206. /package/dist/types/{design-system → design}/runtime/host-observer.d.ts +0 -0
  207. /package/dist/types/{design-system → design}/runtime/host-state.d.ts +0 -0
  208. /package/dist/types/{design-system/runtime/hydrate-design-system.d.ts → design/runtime/hydrate-design.d.ts} +0 -0
  209. /package/dist/types/{design-system → design}/runtime/hydration-state.d.ts +0 -0
  210. /package/dist/types/{design-system → design}/runtime/inherited-scheme.d.ts +0 -0
  211. /package/dist/types/{design-system → design}/runtime/media.d.ts +0 -0
  212. /package/dist/types/{design-system → design}/themes/airbnb.d.ts +0 -0
  213. /package/dist/types/{design-system → design}/themes/clickhouse.d.ts +0 -0
  214. /package/dist/types/{design-system → design}/themes/cobalt.d.ts +0 -0
  215. /package/dist/types/{design-system → design}/themes/graphite.d.ts +0 -0
  216. /package/dist/types/{design-system → design}/themes/neutral.d.ts +0 -0
  217. /package/dist/types/{design-system → design}/themes/sage.d.ts +0 -0
  218. /package/dist/types/{design-system → design}/themes/sunset.d.ts +0 -0
  219. /package/dist/types/{design-system → design}/tokens/base.d.ts +0 -0
  220. /package/dist/types/{design-system → design}/tokens/contrast.d.ts +0 -0
  221. /package/dist/types/{design-system → design}/tokens/density.d.ts +0 -0
  222. /package/dist/types/{design-system → design}/tokens/forced-colors.d.ts +0 -0
  223. /package/dist/types/{design-system → design}/tokens/index.d.ts +0 -0
  224. /package/dist/types/{design-system → design}/tokens/motion.d.ts +0 -0
@@ -1,1888 +0,0 @@
1
- import { f as e, h as t, r as n } from "./design-system-CIU_vH6O.js";
2
- import { t as r } from "./strings-CWwrrYzz.js";
3
- import { createRegistry as i } from "./mlform/schema.mjs";
4
- import { C as a, S as o, _ as s, b as c, c as l, g as u, h as d, l as f, m as p, o as m, p as h, r as g, s as _, t as v, v as y, x as b, y as x } from "./primitives-Di95y_ur.js";
5
- import { t as ee } from "./runtime-C5iTM3uu.js";
6
- import { n as te } from "./builtins-ml-pjab8_gu.js";
7
- //#region src/kit/defaults.ts
8
- var S = { ...p }, ne = {
9
- mode: "auto",
10
- theme: "neutral",
11
- recipe: "default"
12
- }, re = (e) => {
13
- let t = i();
14
- for (let n of e.listFields()) t.registerField(n);
15
- for (let n of e.listReports()) t.registerReport(n);
16
- for (let n of e.listExplanations()) t.registerExplanation(n);
17
- return t;
18
- }, ie = (e) => e?.clone() ?? g(), ae = (e) => e?.clone() ?? t.clone(), C = (e = {}) => ({
19
- ...S,
20
- ...e
21
- }), w = (t = {}) => e(ne, t), oe = a`
22
- :host {
23
- display: block;
24
- inline-size: 100%;
25
- block-size: 100%;
26
- color: var(--mlf-shell-color, var(--mlf-color-text, #0f172a));
27
- background: var(--mlf-shell-bg, var(--mlf-color-bg, #f5f7fa));
28
- font-family: var(--mlf-font-family-body);
29
- }
30
- *,
31
- *::before,
32
- *::after {
33
- box-sizing: border-box;
34
- }
35
- .root {
36
- display: grid;
37
- grid-template-rows: auto 1fr auto;
38
- min-height: 100%;
39
- border-radius: var(--mlf-panel-radius, 12px);
40
- border: var(--mlf-border-width, 1px) solid
41
- var(--mlf-shell-panel-border, var(--mlf-color-border, #e2e8f0));
42
- background: var(--mlf-shell-panel-bg, var(--mlf-color-surface, #ffffff));
43
- box-shadow:
44
- 0 2px 4px var(--mlf-shell-panel-shadow-soft, rgba(0, 0, 0, 0.04)),
45
- 0 8px 16px var(--mlf-shell-panel-shadow, rgba(0, 0, 0, 0.04));
46
- overflow: hidden;
47
- }
48
- .header,
49
- .footer {
50
- display: flex;
51
- align-items: center;
52
- justify-content: space-between;
53
- gap: 0.75rem;
54
- padding: 0.85rem 1rem;
55
- background: var(
56
- --mlf-shell-header-bg,
57
- color-mix(in srgb, var(--mlf-color-surface, #ffffff) 76%, transparent)
58
- );
59
- border-bottom: var(--mlf-border-width, 1px) solid
60
- var(--mlf-shell-panel-border, var(--mlf-color-border, #e2e8f0));
61
- }
62
- .footer {
63
- border-bottom: none;
64
- border-top: var(--mlf-border-width, 1px) solid
65
- var(--mlf-shell-panel-border, var(--mlf-color-border, #e2e8f0));
66
- background: var(--mlf-shell-action-bg, var(--mlf-color-surface-muted, #f5f7fa));
67
- }
68
- .title {
69
- margin: 0;
70
- font-size: 1rem;
71
- font-weight: 700;
72
- }
73
- .actions {
74
- display: inline-flex;
75
- gap: 0.5rem;
76
- flex-wrap: wrap;
77
- }
78
- .body {
79
- display: grid;
80
- gap: 0;
81
- overflow-y: auto;
82
- overflow-x: hidden;
83
- }
84
- .section + .section {
85
- border-top: var(--mlf-border-width, 1px) solid
86
- var(--mlf-panel-border, var(--mlf-color-border, #e2e8f0));
87
- }
88
- .section-toggle {
89
- inline-size: 100%;
90
- display: flex;
91
- align-items: center;
92
- justify-content: space-between;
93
- gap: 0.75rem;
94
- padding: 1rem;
95
- border: none;
96
- background: transparent;
97
- color: inherit;
98
- font: inherit;
99
- text-align: left;
100
- cursor: pointer;
101
- }
102
- .section-copy,
103
- .nested-copy {
104
- display: grid;
105
- gap: 0.35rem;
106
- }
107
- .section-title {
108
- margin: 0;
109
- font-size: 0.96rem;
110
- font-weight: 700;
111
- }
112
- .section-description,
113
- .nested-description {
114
- margin: 0;
115
- font-size: var(--mlf-font-size-sm, 0.84rem);
116
- color: var(--mlf-color-text-muted, #475569);
117
- line-height: 1.5;
118
- }
119
- .chevron {
120
- font-size: 1.1rem;
121
- color: var(--mlf-color-text-muted, #475569);
122
- }
123
- .section-panel {
124
- display: grid;
125
- gap: 1rem;
126
- padding: 0 1rem 1rem;
127
- }
128
- .collection,
129
- .section-children,
130
- .nested-section,
131
- .group {
132
- display: grid;
133
- gap: var(--mlf-section-gap, 1rem);
134
- }
135
- .nested-copy {
136
- padding: 0 0.5rem;
137
- }
138
- .nested-title {
139
- margin: 0;
140
- font-size: 0.95rem;
141
- font-weight: 700;
142
- }
143
- .group.columns-2 {
144
- grid-template-columns: repeat(2, minmax(0, 1fr));
145
- }
146
- .group.columns-3 {
147
- grid-template-columns: repeat(3, minmax(0, 1fr));
148
- }
149
- .btn {
150
- display: inline-flex;
151
- align-items: center;
152
- justify-content: center;
153
- min-height: 2.5rem;
154
- padding: 0.5rem 1rem;
155
- border-radius: var(--mlf-input-radius, 12px);
156
- border: var(--mlf-border-width, 1px) solid var(--mlf-input-border, #e2e8f0);
157
- background: var(--mlf-input-bg, var(--mlf-color-surface-elevated, #ffffff));
158
- color: var(--mlf-color-text, #0f172a);
159
- font: inherit;
160
- font-size: 0.92rem;
161
- font-weight: 600;
162
- cursor: pointer;
163
- }
164
- .btn-submit {
165
- border-color: var(--mlf-submit-bg, var(--mlf-color-accent, #1e40af));
166
- background: var(--mlf-submit-bg, var(--mlf-color-accent, #1e40af));
167
- color: var(--mlf-submit-color, #ffffff);
168
- }
169
- .btn:disabled {
170
- cursor: not-allowed;
171
- opacity: 0.55;
172
- }
173
- @media (max-width: 900px) {
174
- .group.columns-2,
175
- .group.columns-3 {
176
- grid-template-columns: minmax(0, 1fr);
177
- }
178
- .header,
179
- .footer {
180
- flex-direction: column;
181
- align-items: stretch;
182
- }
183
- }
184
- `, T = {
185
- invalidDesignSystemSnapshot: "replaceDesignSystem requires an explicit mode, theme, and recipe.",
186
- fieldDuplicateInLayout: (e) => `Field "${e}" appears multiple times in layout.`,
187
- fieldMissingInLayout: (e) => `Field "${e}" is missing from layout.`,
188
- reportDuplicateInLayout: (e) => `Report "${e}" appears multiple times in layout.`,
189
- explanationDuplicateInLayout: (e) => `Explanation "${e}" appears multiple times in layout.`,
190
- unknownFieldReference: (e) => `Layout references unknown field "${e}".`,
191
- unknownReportReference: (e) => `Layout references unknown report "${e}".`,
192
- unknownExplanationReference: (e) => `Layout references unknown explanation "${e}".`,
193
- wizardRequiresSteps: "Wizard layout must define at least one step.",
194
- wizardStepEmpty: (e) => `Wizard step "${e}" must contain at least one layout node.`,
195
- tabsRequiresTabs: "Tabs layout must define at least one tab.",
196
- tabEmpty: (e) => `Tab "${e}" must contain at least one layout node.`,
197
- accordionRequiresSections: "Accordion layout must define at least one section.",
198
- accordionSectionEmpty: (e) => `Accordion section "${e}" must contain at least one layout node.`,
199
- wizardMissingLayout: "mountWizardForm requires a wizard layout.",
200
- tabsMissingLayout: "mountTabsForm requires a tabs layout.",
201
- accordionMissingLayout: "mountAccordionForm requires an accordion layout.",
202
- nonWizardNextStep: "nextStep() is only available for wizard layouts.",
203
- nonWizardGoToStep: "goToStep() is only available for wizard layouts.",
204
- nonTabsSetActiveTab: "setActiveTab() is only available for tabs layouts.",
205
- nonAccordionToggleSection: "Accordion section controls are only available for accordion layouts.",
206
- unknownTab: (e) => `Unknown tab "${e}".`,
207
- unknownWizardStep: (e) => `Unknown wizard step "${e}".`,
208
- unknownAccordionSection: (e) => `Unknown accordion section "${e}".`
209
- }, E = {
210
- wizard: "mlf-kit-wizard",
211
- tabs: "mlf-kit-tabs",
212
- accordion: "mlf-kit-accordion",
213
- stepIndicator: "mlf-kit-step-indicator"
214
- }, se = async (e) => {
215
- await Promise.resolve(), "updateComplete" in e && await e.updateComplete, await Promise.resolve();
216
- }, ce = (e, t) => e.some((e) => e.kind === "field" ? e.field === t : "children" in e && ce(e.children, t)), le = (e, t) => {
217
- let n = e.getSnapshot().layout;
218
- return n.kind === "accordion" ? n.sections.find((e) => ce(e.children, t))?.id ?? null : null;
219
- }, ue = (e) => {
220
- let t = e.getSnapshot().fields.filter((e) => e.state.visible && e.state.errors.length > 0), n = new Map(e.getLayoutReferences().fields.map((e, t) => [e, t]));
221
- return t.sort((e, t) => (n.get(e.id) ?? 0) - (n.get(t.id) ?? 0)), t[0] ?? null;
222
- }, D = async (e, t) => {
223
- let n = ue(t);
224
- if (!n) return !1;
225
- let r = t.getSnapshot().layout.kind;
226
- r === "wizard" && n.stepId && await t.goToStep(n.stepId), r === "tabs" && n.tabId && t.setActiveTab(n.tabId);
227
- let i = le(t, n.id);
228
- return i && t.openSection(i), await se(e), f(l(e.shadowRoot ?? e, n.id));
229
- }, O = ({ node: e, snapshot: t, registry: n, primitiveText: r = d, sectionClass: i, sectionCopyClass: a, sectionTitleClass: s, sectionDescriptionClass: c, childrenClass: l, groupBaseClass: u }) => {
230
- switch (e.kind) {
231
- case "section": return o`
232
- <section class=${i} data-section-id=${e.id}>
233
- ${e.title || e.description ? o`
234
- <div class=${a}>
235
- ${e.title ? o`<h2 class=${s}>${e.title}</h2>` : b}
236
- ${e.description ? o`<p class=${c}>${e.description}</p>` : b}
237
- </div>
238
- ` : b}
239
- <div class=${l}>
240
- ${m(e.children, (t, n) => `${e.id}-${n}`, (e) => O({
241
- node: e,
242
- snapshot: t,
243
- registry: n,
244
- primitiveText: r,
245
- sectionClass: i,
246
- sectionCopyClass: a,
247
- sectionTitleClass: s,
248
- sectionDescriptionClass: c,
249
- childrenClass: l,
250
- groupBaseClass: u
251
- }))}
252
- </div>
253
- </section>
254
- `;
255
- case "group": return o`
256
- <div
257
- class=${`${u}${e.columns ? ` columns-${e.columns}` : ""}`}
258
- data-group-id=${e.id}
259
- >
260
- ${m(e.children, (t, n) => `${e.id}-${n}`, (e) => O({
261
- node: e,
262
- snapshot: t,
263
- registry: n,
264
- primitiveText: r,
265
- sectionClass: i,
266
- sectionCopyClass: a,
267
- sectionTitleClass: s,
268
- sectionDescriptionClass: c,
269
- childrenClass: l,
270
- groupBaseClass: u
271
- }))}
272
- </div>
273
- `;
274
- case "field": {
275
- let i = t.fields.find((t) => t.id === e.field);
276
- return i ? o`
277
- <mlf-field-frame
278
- data-field-id=${i.id}
279
- .controller=${i.controller}
280
- .descriptor=${i.descriptor}
281
- .registry=${n}
282
- .text=${r}
283
- ></mlf-field-frame>
284
- ` : b;
285
- }
286
- case "report": {
287
- let i = t.reports.find((t) => t.id === e.report);
288
- return i ? o`
289
- <mlf-report-frame
290
- .controller=${i.controller}
291
- .descriptor=${i.descriptor}
292
- .registry=${n}
293
- .text=${r}
294
- .lastResult=${t.form.lastResult}
295
- ></mlf-report-frame>
296
- ` : b;
297
- }
298
- case "explanation": {
299
- let i = t.explanations.find((t) => t.id === e.explanation);
300
- return i ? o`
301
- <mlf-explanation-panel
302
- .controller=${i.controller}
303
- .descriptor=${i.descriptor}
304
- .registry=${n}
305
- .text=${r}
306
- .lastResult=${t.form.lastResult}
307
- ></mlf-explanation-panel>
308
- ` : b;
309
- }
310
- }
311
- }, k = class extends c {
312
- static styles = oe;
313
- #e;
314
- get view() {
315
- return this.#e;
316
- }
317
- set view(e) {
318
- this.#e = e;
319
- }
320
- #t;
321
- get registry() {
322
- return this.#t;
323
- }
324
- set registry(e) {
325
- this.#t = e;
326
- }
327
- #n = d;
328
- get primitiveText() {
329
- return this.#n;
330
- }
331
- set primitiveText(e) {
332
- this.#n = e;
333
- }
334
- #r = "Submit";
335
- get submitLabel() {
336
- return this.#r;
337
- }
338
- set submitLabel(e) {
339
- this.#r = e;
340
- }
341
- #i = "Validating...";
342
- get validatingLabel() {
343
- return this.#i;
344
- }
345
- set validatingLabel(e) {
346
- this.#i = e;
347
- }
348
- #a = "Submitting...";
349
- get submittingLabel() {
350
- return this.#a;
351
- }
352
- set submittingLabel(e) {
353
- this.#a = e;
354
- }
355
- #o = null;
356
- get snapshot() {
357
- return this.#o;
358
- }
359
- set snapshot(e) {
360
- this.#o = e;
361
- }
362
- #s = null;
363
- willUpdate(e) {
364
- e.has("view") && (this.#s?.(), this.#s = null, this.snapshot = this.view?.getSnapshot() ?? null, this.view && (this.#s = this.view.subscribe((e) => {
365
- this.snapshot = e;
366
- })));
367
- }
368
- disconnectedCallback() {
369
- this.#s?.(), this.#s = null, super.disconnectedCallback();
370
- }
371
- render() {
372
- let e = this.snapshot, t = e?.accordion;
373
- if (!e || !t || e.layout.kind !== "accordion") return o``;
374
- let n = e.form.status, r = n === "validating" ? this.validatingLabel : n === "submitting" ? this.submittingLabel : this.submitLabel;
375
- return o`
376
- <section class="root" part="accordion-panel">
377
- <header class="header">
378
- <h1 class="title">Accordion Form</h1>
379
- <div class="actions">
380
- <button type="button" class="btn" @click=${this.#c}>Open all</button>
381
- <button type="button" class="btn" @click=${this.#l}>Close all</button>
382
- </div>
383
- </header>
384
-
385
- <div class="body">
386
- ${m(e.layout.sections, (e) => e.id, (n) => {
387
- let r = t.openSectionIds.includes(n.id);
388
- return o`
389
- <section class="section">
390
- <button
391
- type="button"
392
- class="section-toggle"
393
- aria-expanded=${String(r)}
394
- @click=${() => this.view?.toggleSection(n.id)}
395
- >
396
- <span class="section-copy">
397
- <span class="section-title">${n.title}</span>
398
- ${n.description ? o`<span class="section-description">${n.description}</span>` : b}
399
- </span>
400
- <span class="chevron">${r ? "−" : "+"}</span>
401
- </button>
402
- ${r ? o`
403
- <div class="section-panel">
404
- <div class="collection">
405
- ${m(n.children, (e, t) => `${n.id}-${t}`, (t) => O({
406
- node: t,
407
- snapshot: e,
408
- registry: this.registry,
409
- primitiveText: this.primitiveText,
410
- sectionClass: "nested-section",
411
- sectionCopyClass: "nested-copy",
412
- sectionTitleClass: "nested-title",
413
- sectionDescriptionClass: "nested-description",
414
- childrenClass: "section-children",
415
- groupBaseClass: "group"
416
- }))}
417
- </div>
418
- </div>
419
- ` : b}
420
- </section>
421
- `;
422
- })}
423
- </div>
424
-
425
- <footer class="footer" part="actions">
426
- <span>${t.openSectionIds.length} / ${t.sectionCount} open</span>
427
- <button
428
- type="button"
429
- class="btn btn-submit"
430
- ?disabled=${n === "validating" || n === "submitting"}
431
- @click=${this.#u}
432
- >
433
- ${r}
434
- </button>
435
- </footer>
436
- </section>
437
- `;
438
- }
439
- #c = () => {
440
- this.view?.openAllSections();
441
- };
442
- #l = () => {
443
- this.view?.closeAllSections();
444
- };
445
- #u = async () => {
446
- if (this.view) try {
447
- await this.view.submit();
448
- } catch (e) {
449
- if (!await D(this, this.view)) throw e;
450
- }
451
- };
452
- };
453
- h([y({ attribute: !1 })], k.prototype, "view", null), h([y({ attribute: !1 })], k.prototype, "registry", null), h([y({ attribute: !1 })], k.prototype, "primitiveText", null), h([y({ type: String })], k.prototype, "submitLabel", null), h([y({ type: String })], k.prototype, "validatingLabel", null), h([y({ type: String })], k.prototype, "submittingLabel", null), h([s()], k.prototype, "snapshot", null), k = h([x(E.accordion)], k);
454
- //#endregion
455
- //#region src/kit/layout-helpers.ts
456
- var de = (e, t, n) => ({
457
- fieldIds: new Set(e.map((e) => e.id)),
458
- reportIds: new Set(t.map((e) => e.id)),
459
- explanationIds: new Set(n.map((e) => e.id))
460
- }), fe = () => ({
461
- fieldStepIds: /* @__PURE__ */ new Map(),
462
- reportStepIds: /* @__PURE__ */ new Map(),
463
- explanationStepIds: /* @__PURE__ */ new Map(),
464
- fieldTabIds: /* @__PURE__ */ new Map(),
465
- reportTabIds: /* @__PURE__ */ new Map(),
466
- explanationTabIds: /* @__PURE__ */ new Map(),
467
- fieldIdsInLayout: /* @__PURE__ */ new Set(),
468
- reportIdsInLayout: /* @__PURE__ */ new Set(),
469
- explanationIdsInLayout: /* @__PURE__ */ new Set()
470
- }), A = (e, t, n) => {
471
- let i = r(t ?? e) || e, a = n.get(i) ?? 0;
472
- return n.set(i, a + 1), a === 0 ? i : `${i}-${a + 1}`;
473
- }, pe = (e, t) => {
474
- if (!t.fieldIds.has(e)) throw TypeError(T.unknownFieldReference(e));
475
- }, me = (e, t) => {
476
- if (!t.reportIds.has(e)) throw TypeError(T.unknownReportReference(e));
477
- }, he = (e, t) => {
478
- if (!t.explanationIds.has(e)) throw TypeError(T.unknownExplanationReference(e));
479
- }, ge = (e, t, n, r) => {
480
- if (t.fieldIdsInLayout.has(e)) throw TypeError(T.fieldDuplicateInLayout(e));
481
- t.fieldIdsInLayout.add(e), n && t.fieldStepIds.set(e, n), r && t.fieldTabIds.set(e, r);
482
- }, _e = (e, t, n, r) => {
483
- if (t.reportIdsInLayout.has(e)) throw TypeError(T.reportDuplicateInLayout(e));
484
- t.reportIdsInLayout.add(e), n && t.reportStepIds.set(e, n), r && t.reportTabIds.set(e, r);
485
- }, ve = (e, t, n, r) => {
486
- if (t.explanationIdsInLayout.has(e)) throw TypeError(T.explanationDuplicateInLayout(e));
487
- t.explanationIdsInLayout.add(e), n && t.explanationStepIds.set(e, n), r && t.explanationTabIds.set(e, r);
488
- }, ye = (e, t, n) => [
489
- ...e.map((e) => ({
490
- kind: "field",
491
- field: e.id
492
- })),
493
- ...t.map((e) => ({
494
- kind: "explanation",
495
- explanation: e.id
496
- })),
497
- ...n.map((e) => ({
498
- kind: "report",
499
- report: e.id
500
- }))
501
- ], j = (e, t) => {
502
- for (let n of e) if (!t.fieldIdsInLayout.has(n.id)) throw TypeError(T.fieldMissingInLayout(n.id));
503
- }, M = (e, t, n, r, i, a) => e.map((e) => {
504
- switch (e.kind) {
505
- case "section": return {
506
- kind: "section",
507
- id: A("section", e.id ?? e.title, r),
508
- title: e.title,
509
- description: e.description,
510
- children: M(e.children, t, n, r, i, a)
511
- };
512
- case "group": return {
513
- kind: "group",
514
- id: A("group", e.id, r),
515
- columns: e.columns,
516
- children: M(e.children, t, n, r, i, a)
517
- };
518
- case "field": return pe(e.field, t), ge(e.field, n, i, a), {
519
- kind: "field",
520
- field: e.field
521
- };
522
- case "report": return me(e.report, t), _e(e.report, n, i, a), {
523
- kind: "report",
524
- report: e.report
525
- };
526
- case "explanation": return he(e.explanation, t), ve(e.explanation, n, i, a), {
527
- kind: "explanation",
528
- explanation: e.explanation
529
- };
530
- }
531
- }), be = (e, t, n, r) => {
532
- let i = de(t, n, r), a = fe(), o = /* @__PURE__ */ new Map();
533
- if (!e || e.kind === void 0 || e.kind === "single-page") {
534
- let s = M(e?.children ?? ye(t, r, n), i, a, o, null, null);
535
- return j(t, a), {
536
- layout: {
537
- kind: "single-page",
538
- children: s
539
- },
540
- maps: a
541
- };
542
- }
543
- if (e.kind === "tabs") {
544
- if (e.tabs.length === 0) throw TypeError(T.tabsRequiresTabs);
545
- let n = /* @__PURE__ */ new Map(), r = e.tabs.map((e, t) => {
546
- let r = A("tab", e.id ?? e.title ?? `tab-${t + 1}`, n), s = M(e.children, i, a, o, null, r);
547
- if (s.length === 0) throw TypeError(T.tabEmpty(r));
548
- return {
549
- id: r,
550
- title: e.title,
551
- description: e.description,
552
- children: s
553
- };
554
- });
555
- return j(t, a), {
556
- layout: {
557
- kind: "tabs",
558
- tabs: r
559
- },
560
- maps: a
561
- };
562
- }
563
- if (e.kind === "accordion") {
564
- if (e.sections.length === 0) throw TypeError(T.accordionRequiresSections);
565
- let n = /* @__PURE__ */ new Map(), r = e.sections.map((e, t) => {
566
- let r = A("section", e.id ?? e.title ?? `section-${t + 1}`, n), s = M(e.children, i, a, o, null, r);
567
- if (s.length === 0) throw TypeError(T.accordionSectionEmpty(r));
568
- return {
569
- id: r,
570
- title: e.title,
571
- description: e.description,
572
- defaultOpen: e.defaultOpen ?? t === 0,
573
- children: s
574
- };
575
- });
576
- return j(t, a), {
577
- layout: {
578
- kind: "accordion",
579
- sections: r
580
- },
581
- maps: a
582
- };
583
- }
584
- let s = e;
585
- if (s.steps.length === 0) throw TypeError(T.wizardRequiresSteps);
586
- let c = /* @__PURE__ */ new Map(), l = s.steps.map((e, t) => {
587
- let n = A("step", e.id ?? e.title ?? `step-${t + 1}`, c), r = M(e.children, i, a, o, n, null);
588
- if (r.length === 0) throw TypeError(T.wizardStepEmpty(n));
589
- return {
590
- id: n,
591
- title: e.title,
592
- description: e.description,
593
- children: r
594
- };
595
- });
596
- return j(t, a), {
597
- layout: {
598
- kind: "wizard",
599
- steps: l
600
- },
601
- maps: a
602
- };
603
- }, N = (e, t) => {
604
- if (t(e), "children" in e) for (let n of e.children) N(n, t);
605
- }, P = (e, t) => {
606
- switch (e.kind) {
607
- case "single-page":
608
- for (let n of e.children) N(n, t);
609
- return;
610
- case "wizard":
611
- for (let n of e.steps) for (let e of n.children) N(e, t);
612
- return;
613
- case "tabs":
614
- for (let n of e.tabs) for (let e of n.children) N(e, t);
615
- return;
616
- case "accordion": for (let n of e.sections) for (let e of n.children) N(e, t);
617
- }
618
- }, F = (e) => {
619
- let t = [];
620
- return P(e, (e) => {
621
- t.push(e);
622
- }), t;
623
- }, I = (e) => {
624
- let t = {
625
- fields: [],
626
- reports: [],
627
- explanations: []
628
- };
629
- for (let n of F(e)) switch (n.kind) {
630
- case "field":
631
- t.fields.push(n.field);
632
- break;
633
- case "report":
634
- t.reports.push(n.report);
635
- break;
636
- case "explanation":
637
- t.explanations.push(n.explanation);
638
- break;
639
- default: break;
640
- }
641
- return t;
642
- }, L = (e, t, n) => {
643
- if (n.length === 0) return null;
644
- let r = Math.min(Math.max(t, 0), n.length - 1);
645
- return {
646
- kind: e,
647
- index: r,
648
- count: n.length,
649
- currentId: n[r] ?? n[0],
650
- canGoNext: r < n.length - 1,
651
- canGoPrev: r > 0
652
- };
653
- }, R = ({ layout: e, stepIndex: t, formState: n }) => {
654
- let r = L("wizard-step", t, (e.kind === "wizard" ? e.steps : []).map((e) => e.id));
655
- return r ? {
656
- stepIndex: r.index,
657
- stepCount: r.count,
658
- currentStepId: r.currentId,
659
- canNext: n.status !== "validating" && n.status !== "submitting",
660
- canPrev: r.canGoPrev,
661
- isLastStep: r.index === r.count - 1
662
- } : null;
663
- }, z = ({ layout: e, activeTabIndex: t }) => {
664
- let n = L("tab", t, (e.kind === "tabs" ? e.tabs : []).map((e) => e.id));
665
- return n ? {
666
- activeTabIndex: n.index,
667
- tabCount: n.count,
668
- currentTabId: n.currentId,
669
- canGoNext: n.canGoNext,
670
- canGoPrev: n.canGoPrev
671
- } : null;
672
- }, B = ({ layout: e, openSectionIds: t }) => {
673
- let n = e.kind === "accordion" ? e.sections : [];
674
- return n.length === 0 ? null : {
675
- openSectionIds: n.map((e) => e.id).filter((e) => t.has(e)),
676
- sectionCount: n.length
677
- };
678
- }, xe = (e) => ({
679
- form: e.formState,
680
- wizard: R(e),
681
- tabs: z(e),
682
- accordion: B(e)
683
- }), V = (e, t, n, r, i, a) => e.kind === "wizard" ? i === (e.steps[t]?.id ?? null) : e.kind === "tabs" ? a === (e.tabs[n]?.id ?? null) : e.kind === "accordion" ? a !== null && r.has(a) : !0, Se = (e, t, n, r, i, a) => {
684
- let o = n.maps.fieldStepIds.get(e.id) ?? null, s = n.maps.fieldTabIds.get(e.id) ?? null, c = t.getField(e.kind);
685
- return {
686
- id: e.id,
687
- kind: e.kind,
688
- config: e.config,
689
- controller: e,
690
- state: e.state,
691
- descriptor: c?.describe(e.config, {
692
- fieldId: e.id,
693
- state: e.state,
694
- value: e.state.value
695
- }) ?? _(e),
696
- stepId: o,
697
- tabId: s,
698
- visibleInLayout: V(n.layout, r, i, a, o, s)
699
- };
700
- }, Ce = (e, t, n, r, i, a, o) => {
701
- let s = r.maps.reportStepIds.get(e.id) ?? null, c = r.maps.reportTabIds.get(e.id) ?? null, l = n.getReport(e.kind);
702
- return {
703
- id: e.id,
704
- kind: e.kind,
705
- config: e.config,
706
- controller: e,
707
- state: e.state,
708
- descriptor: l ? l.describe(e.config, {
709
- reportId: e.id,
710
- state: e.state,
711
- payload: e.state.payload,
712
- result: t.state.lastResult
713
- }) : null,
714
- stepId: s,
715
- tabId: c,
716
- visibleInLayout: V(r.layout, i, a, o, s, c)
717
- };
718
- }, we = (e, t, n, r, i, a) => {
719
- let o = n.maps.explanationStepIds.get(e.id) ?? null, s = n.maps.explanationTabIds.get(e.id) ?? null, c = t.getExplanation(e.kind);
720
- return {
721
- id: e.id,
722
- kind: e.kind,
723
- config: e.config,
724
- controller: e,
725
- state: e.state,
726
- descriptor: c ? c.describe(e.config, {
727
- explanationId: e.id,
728
- state: e.state
729
- }) : null,
730
- stepId: o,
731
- tabId: s,
732
- visibleInLayout: V(n.layout, r, i, a, o, s)
733
- };
734
- }, Te = ({ form: e, presentationRegistry: t, resolvedLayout: n, stepIndex: r, activeTabIndex: i, openSectionIds: a }) => ({
735
- form: e.state,
736
- layout: n.layout,
737
- fields: e.fields.map((e) => Se(e, t, n, r, i, a)),
738
- reports: e.reports.map((o) => Ce(o, e, t, n, r, i, a)),
739
- explanations: e.explanations.map((e) => we(e, t, n, r, i, a)),
740
- wizard: R({
741
- layout: n.layout,
742
- stepIndex: r,
743
- activeTabIndex: i,
744
- openSectionIds: a,
745
- formState: e.state
746
- }),
747
- tabs: z({
748
- layout: n.layout,
749
- stepIndex: r,
750
- activeTabIndex: i,
751
- openSectionIds: a,
752
- formState: e.state
753
- }),
754
- accordion: B({
755
- layout: n.layout,
756
- stepIndex: r,
757
- activeTabIndex: i,
758
- openSectionIds: a,
759
- formState: e.state
760
- })
761
- }), Ee = (e, t, n, r, i) => xe({
762
- formState: e.state,
763
- layout: t,
764
- stepIndex: n,
765
- activeTabIndex: r,
766
- openSectionIds: i
767
- }), De = ({ form: e, presentationRegistry: t, resolvedLayout: n, getStepIndex: r, getActiveTabIndex: i, getOpenSectionIds: a }) => {
768
- let o = e.state, s = -1, c = -1, l = "", u = null;
769
- return () => {
770
- let d = r(), f = i(), p = a(), m = e.state, h = Array.from(p).sort().join("|");
771
- return u && o === m && s === d && c === f && l === h ? u : (o = m, s = d, c = f, l = h, u = Te({
772
- form: e,
773
- presentationRegistry: t,
774
- resolvedLayout: n,
775
- stepIndex: d,
776
- activeTabIndex: f,
777
- openSectionIds: p
778
- }), u);
779
- };
780
- }, Oe = async (e, t, n) => {
781
- if (t.layout.kind !== "wizard") return !1;
782
- let r = t.layout.steps[n]?.id;
783
- if (!r) return !1;
784
- let i = e.fields.filter((e) => t.maps.fieldStepIds.get(e.id) === r && e.state.visible);
785
- return (await Promise.all(i.map((e) => e.validate()))).every((e) => e.errors.length === 0);
786
- }, ke = (e, t, n, r) => {
787
- switch (e.layout.kind) {
788
- case "single-page": return e.layout.children;
789
- case "wizard": return e.layout.steps[t]?.children ?? [];
790
- case "tabs": return e.layout.tabs[n]?.children ?? [];
791
- case "accordion": return e.layout.sections.filter((e) => r.has(e.id)).flatMap((e) => e.children);
792
- }
793
- }, H = (e, t, n) => {
794
- if (e.layout.kind !== "accordion") throw TypeError(T.nonAccordionToggleSection);
795
- if (!t.some((e) => e.id === n)) throw TypeError(T.unknownAccordionSection(n));
796
- }, U = (e) => {
797
- if (e.layout.kind !== "accordion") throw TypeError(T.nonAccordionToggleSection);
798
- }, W = (e) => {
799
- let t = !e.registry || !e.presentationRegistry || !e.behaviors ? te() : null, n = e.registry ? re(e.registry) : t.registry, r = e.presentationRegistry?.clone() ?? t.presentationRegistry, i = ie(e.primitiveRegistry), a = ae(e.designSystemRegistry), o = ee({
800
- schema: e.schema,
801
- registry: n,
802
- behaviors: e.behaviors ?? t?.behaviors,
803
- transport: e.transport,
804
- initialValues: e.initialValues,
805
- validators: e.validators,
806
- hooks: e.hooks,
807
- hookFailurePolicy: e.hookFailurePolicy,
808
- inactiveFieldPolicy: e.inactiveFieldPolicy,
809
- listenerErrorPolicy: e.listenerErrorPolicy,
810
- onListenerError: e.onListenerError
811
- }), s = be(e.layout, o.fields, o.reports, o.explanations), c = 0, l = 0, u = new Set(s.layout.kind === "accordion" ? s.layout.sections.filter((e) => e.defaultOpen).map((e) => e.id) : []), d = /* @__PURE__ */ new Set(), f = s.layout.kind === "wizard" ? s.layout.steps : [], p = s.layout.kind === "tabs" ? s.layout.tabs : [], m = s.layout.kind === "accordion" ? s.layout.sections : [], h = I(s.layout), g = /* @__PURE__ */ new Map();
812
- for (let e of F(s.layout)) "id" in e && g.set(e.id, e);
813
- let _ = () => Ee(o, s.layout, c, l, u), v = De({
814
- form: o,
815
- presentationRegistry: r,
816
- resolvedLayout: s,
817
- getStepIndex: () => c,
818
- getActiveTabIndex: () => l,
819
- getOpenSectionIds: () => u
820
- }), y = () => {
821
- let e = v();
822
- for (let t of d) t(e);
823
- };
824
- return o.subscribe(() => {
825
- y();
826
- }), Object.freeze({
827
- form: o,
828
- engineRegistry: n,
829
- presentationRegistry: r,
830
- primitiveRegistry: i,
831
- designSystemRegistry: a,
832
- get state() {
833
- return _();
834
- },
835
- getSnapshot: v,
836
- getNodeById(e) {
837
- return g.get(e);
838
- },
839
- getField(e) {
840
- return v().fields.find((t) => t.id === e);
841
- },
842
- getReport(e) {
843
- return v().reports.find((t) => t.id === e);
844
- },
845
- getExplanation(e) {
846
- return v().explanations.find((t) => t.id === e);
847
- },
848
- getVisibleFields() {
849
- return v().fields.filter((e) => e.visibleInLayout && e.state.visible);
850
- },
851
- getVisibleReports() {
852
- return v().reports.filter((e) => e.visibleInLayout);
853
- },
854
- getVisibleExplanations() {
855
- return v().explanations.filter((e) => e.visibleInLayout);
856
- },
857
- getActiveLayoutNodes() {
858
- return ke(s, c, l, u);
859
- },
860
- getLayoutReferences() {
861
- return h;
862
- },
863
- validate() {
864
- return o.validate();
865
- },
866
- submit(e) {
867
- return o.submit(e);
868
- },
869
- reset() {
870
- o.reset();
871
- },
872
- subscribe(e) {
873
- return d.add(e), () => {
874
- d.delete(e);
875
- };
876
- },
877
- async nextStep() {
878
- return s.layout.kind !== "wizard" || !await Oe(o, s, c) ? !1 : (c < f.length - 1 && (c += 1, y()), !0);
879
- },
880
- prevStep() {
881
- s.layout.kind === "wizard" && c > 0 && (--c, y());
882
- },
883
- async goToStep(e) {
884
- if (s.layout.kind !== "wizard") throw TypeError(T.nonWizardGoToStep);
885
- let t = f.findIndex((t) => t.id === e);
886
- if (t < 0) throw TypeError(T.unknownWizardStep(e));
887
- if (t <= c) return c = t, y(), !0;
888
- for (; c < t;) if (!await this.nextStep()) return !1;
889
- return !0;
890
- },
891
- setActiveTab(e) {
892
- if (s.layout.kind !== "tabs") throw TypeError(T.nonTabsSetActiveTab);
893
- let t = p.findIndex((t) => t.id === e);
894
- if (t < 0) throw TypeError(T.unknownTab(e));
895
- t !== l && (l = t, y());
896
- },
897
- nextTab() {
898
- return s.layout.kind !== "tabs" || l >= p.length - 1 ? !1 : (l += 1, y(), !0);
899
- },
900
- prevTab() {
901
- return s.layout.kind !== "tabs" || l <= 0 ? !1 : (--l, y(), !0);
902
- },
903
- toggleSection(e) {
904
- H(s, m, e), u.has(e) ? u.delete(e) : u.add(e), y();
905
- },
906
- openSection(e) {
907
- H(s, m, e), u.has(e) || (u.add(e), y());
908
- },
909
- closeSection(e) {
910
- H(s, m, e), u.delete(e) && y();
911
- },
912
- openAllSections() {
913
- U(s), u = new Set(m.map((e) => e.id)), y();
914
- },
915
- closeAllSections() {
916
- U(s), u = /* @__PURE__ */ new Set(), y();
917
- }
918
- });
919
- }, G = Symbol("mlform.kit.accordion.mounted"), Ae = (e) => "view" in e, je = (e, t) => {
920
- let r = e;
921
- r[G]?.unmount();
922
- let i = Ae(t) ? t.view : W({
923
- schema: t.schema,
924
- transport: t.transport,
925
- registry: t.registry,
926
- primitiveRegistry: t.primitiveRegistry,
927
- designSystemRegistry: t.designSystemRegistry,
928
- designSystem: t.designSystem,
929
- initialValues: t.initialValues,
930
- validators: t.validators,
931
- hooks: t.hooks,
932
- hookFailurePolicy: t.hookFailurePolicy,
933
- inactiveFieldPolicy: t.inactiveFieldPolicy,
934
- listenerErrorPolicy: t.listenerErrorPolicy,
935
- onListenerError: t.onListenerError,
936
- layout: t.layout
937
- });
938
- if (i.getSnapshot().layout.kind !== "accordion") throw TypeError(T.accordionMissingLayout);
939
- let a = C(t.labels), o = u(t.primitiveText), s = w(t.designSystem), c = document.createElement(E.accordion);
940
- c.view = i, c.registry = i.primitiveRegistry, c.primitiveText = o, c.submitLabel = a.submit, c.validatingLabel = a.validating, c.submittingLabel = a.submitting, e.replaceChildren(c);
941
- let l = n(c, {
942
- config: s,
943
- registry: i.designSystemRegistry,
944
- onChange: t.onDesignSystemChange
945
- }), d = !1, f = Object.freeze({
946
- view: i,
947
- form: i.form,
948
- host: c,
949
- designSystem: l,
950
- unmount() {
951
- d || (d = !0, r[G] === f && delete r[G], i.form.abortSubmit("unmount"), l.disconnect(), c.remove());
952
- }
953
- });
954
- return r[G] = f, f;
955
- }, K = Symbol("mlform.kit.mounted"), Me = (e) => {
956
- if (!e.mode || !e.theme || !e.recipe) throw TypeError(T.invalidDesignSystemSnapshot);
957
- }, Ne = (e, t) => {
958
- let r = e;
959
- r[K]?.unmount();
960
- let i = W({
961
- schema: t.schema,
962
- transport: t.transport,
963
- registry: t.registry,
964
- presentationRegistry: t.presentationRegistry,
965
- primitiveRegistry: t.primitiveRegistry,
966
- designSystemRegistry: t.designSystemRegistry,
967
- designSystem: t.designSystem,
968
- initialValues: t.initialValues,
969
- validators: t.validators,
970
- hooks: t.hooks,
971
- hookFailurePolicy: t.hookFailurePolicy,
972
- inactiveFieldPolicy: t.inactiveFieldPolicy,
973
- listenerErrorPolicy: t.listenerErrorPolicy,
974
- onListenerError: t.onListenerError,
975
- reportPane: t.reportPane,
976
- reportTransport: t.reportTransport,
977
- labels: t.labels,
978
- primitiveText: t.primitiveText,
979
- containerStrategy: t.containerStrategy,
980
- onDesignSystemChange: t.onDesignSystemChange
981
- }), a = C(t.labels), o = w(t.designSystem), s = v(e, i.form, {
982
- registry: i.primitiveRegistry,
983
- presentationRegistry: i.presentationRegistry,
984
- layout: t.layout,
985
- containerStrategy: t.containerStrategy,
986
- formLabel: a.form,
987
- reportsLabel: a.reports,
988
- submitLabel: a.submit,
989
- validatingLabel: a.validating,
990
- submittingLabel: a.submitting,
991
- reportPane: t.reportPane,
992
- text: t.primitiveText,
993
- reportTransport: t.reportTransport
994
- }), c = n(s.host, {
995
- config: o,
996
- registry: i.designSystemRegistry,
997
- onChange: t.onDesignSystemChange
998
- }), l = !1, u = Object.freeze({
999
- form: i.form,
1000
- host: s.host,
1001
- engineRegistry: i.engineRegistry,
1002
- presentationRegistry: i.presentationRegistry,
1003
- primitiveRegistry: i.primitiveRegistry,
1004
- designSystemRegistry: i.designSystemRegistry,
1005
- designSystem: c,
1006
- updateDesignSystem(e) {
1007
- c.update(e);
1008
- },
1009
- replaceDesignSystem(e) {
1010
- Me(e), c.replace(e);
1011
- },
1012
- resetDesignSystem() {
1013
- c.reset();
1014
- },
1015
- unmount() {
1016
- l || (l = !0, r[K] === u && delete r[K], i.form.abortSubmit("unmount"), c.disconnect(), s.unmount());
1017
- }
1018
- });
1019
- return r[K] = u, u;
1020
- }, Pe = (e) => {
1021
- e.unmount();
1022
- }, Fe = a`
1023
- :host {
1024
- display: block;
1025
- flex: 1 1 auto;
1026
- align-self: stretch;
1027
- inline-size: 100%;
1028
- block-size: 100%;
1029
- color: var(--mlf-shell-color, var(--mlf-color-text, #0f172a));
1030
- background: var(--mlf-shell-bg, var(--mlf-color-bg, #f5f7fa));
1031
- font-family: var(--mlf-font-family-body);
1032
- min-width: 0;
1033
- min-height: 0;
1034
- }
1035
- *,
1036
- *::before,
1037
- *::after {
1038
- box-sizing: border-box;
1039
- }
1040
- .root {
1041
- display: grid;
1042
- grid-template-rows: auto 1fr auto;
1043
- inline-size: 100%;
1044
- block-size: 100%;
1045
- min-width: 0;
1046
- min-height: 0;
1047
- overflow: hidden;
1048
- border-radius: var(--mlf-panel-radius, 12px);
1049
- border: var(--mlf-border-width, 1px) solid
1050
- var(--mlf-shell-panel-border, var(--mlf-color-border, #e2e8f0));
1051
- background: var(--mlf-shell-panel-bg, var(--mlf-color-surface, #ffffff));
1052
- box-shadow:
1053
- 0 2px 4px var(--mlf-shell-panel-shadow-soft, rgba(0, 0, 0, 0.04)),
1054
- 0 8px 16px var(--mlf-shell-panel-shadow, rgba(0, 0, 0, 0.04));
1055
- }
1056
- .tablist {
1057
- display: flex;
1058
- gap: 0.35rem;
1059
- overflow-x: auto;
1060
- padding: 0.85rem 1rem 0;
1061
- border-bottom: var(--mlf-border-width, 1px) solid
1062
- var(--mlf-shell-panel-border, var(--mlf-color-border, #e2e8f0));
1063
- background: var(
1064
- --mlf-shell-header-bg,
1065
- color-mix(in srgb, var(--mlf-color-surface, #ffffff) 76%, transparent)
1066
- );
1067
- scrollbar-width: thin;
1068
- }
1069
- .tab {
1070
- position: relative;
1071
- border: none;
1072
- border-radius: 12px 12px 0 0;
1073
- background: transparent;
1074
- color: var(--mlf-color-text-muted, #475569);
1075
- font: inherit;
1076
- font-size: 0.94rem;
1077
- font-weight: 600;
1078
- padding: 0.85rem 1rem 0.75rem;
1079
- cursor: pointer;
1080
- white-space: nowrap;
1081
- }
1082
- .tab[aria-selected="true"] {
1083
- color: var(--mlf-color-text, #0f172a);
1084
- background: color-mix(in srgb, var(--mlf-color-surface, #ffffff) 94%, transparent);
1085
- }
1086
- .tab[aria-selected="true"]::after {
1087
- content: "";
1088
- position: absolute;
1089
- inset-inline: 0.8rem;
1090
- inset-block-end: 0;
1091
- block-size: 3px;
1092
- border-radius: 999px;
1093
- background: var(--mlf-color-accent, #1e40af);
1094
- }
1095
- .tab-panel {
1096
- display: grid;
1097
- grid-template-rows: auto 1fr;
1098
- min-width: 0;
1099
- min-height: 0;
1100
- overflow: hidden;
1101
- }
1102
- .tab-header {
1103
- display: grid;
1104
- gap: 0.35rem;
1105
- padding: 1rem 1.25rem 0.5rem;
1106
- }
1107
- .tab-title {
1108
- margin: 0;
1109
- font-size: 1.08rem;
1110
- font-weight: 700;
1111
- color: var(--mlf-color-text, #0f172a);
1112
- line-height: 1.3;
1113
- }
1114
- .tab-description {
1115
- margin: 0;
1116
- font-size: var(--mlf-font-size-sm, 0.84rem);
1117
- color: var(--mlf-color-text-muted, #475569);
1118
- line-height: 1.5;
1119
- }
1120
- .body {
1121
- display: grid;
1122
- align-content: start;
1123
- gap: 1rem;
1124
- padding: 0.5rem 1rem 1.25rem;
1125
- overflow-y: auto;
1126
- overflow-x: hidden;
1127
- }
1128
- .collection,
1129
- .section-children,
1130
- .group {
1131
- display: grid;
1132
- gap: var(--mlf-section-gap, 1rem);
1133
- }
1134
- .section {
1135
- display: grid;
1136
- gap: 0.9rem;
1137
- }
1138
- .section-copy {
1139
- display: grid;
1140
- gap: 0.35rem;
1141
- padding: 0 0.5rem;
1142
- }
1143
- .section-title {
1144
- margin: 0;
1145
- font-size: 0.95rem;
1146
- font-weight: 700;
1147
- color: var(--mlf-color-text, #0f172a);
1148
- }
1149
- .section-description {
1150
- margin: 0;
1151
- font-size: var(--mlf-font-size-sm, 0.84rem);
1152
- color: var(--mlf-color-text-muted, #475569);
1153
- line-height: 1.5;
1154
- }
1155
- .group.columns-2 {
1156
- grid-template-columns: repeat(2, minmax(0, 1fr));
1157
- }
1158
- .group.columns-3 {
1159
- grid-template-columns: repeat(3, minmax(0, 1fr));
1160
- }
1161
- .footer {
1162
- display: flex;
1163
- align-items: center;
1164
- justify-content: space-between;
1165
- gap: 0.75rem;
1166
- padding: 0.85rem 1rem 1rem;
1167
- border-top: var(--mlf-border-width, 1px) solid
1168
- var(--mlf-shell-panel-border, var(--mlf-color-border, #e2e8f0));
1169
- background: var(--mlf-shell-action-bg, var(--mlf-color-surface-muted, #f5f7fa));
1170
- }
1171
- .nav {
1172
- display: inline-flex;
1173
- gap: 0.5rem;
1174
- }
1175
- .btn {
1176
- display: inline-flex;
1177
- align-items: center;
1178
- justify-content: center;
1179
- min-height: 2.5rem;
1180
- padding: 0.5rem 1rem;
1181
- border-radius: var(--mlf-input-radius, 12px);
1182
- border: var(--mlf-border-width, 1px) solid var(--mlf-input-border, #e2e8f0);
1183
- background: var(--mlf-input-bg, var(--mlf-color-surface-elevated, #ffffff));
1184
- color: var(--mlf-color-text, #0f172a);
1185
- font: inherit;
1186
- font-size: 0.92rem;
1187
- font-weight: 600;
1188
- cursor: pointer;
1189
- }
1190
- .btn:disabled {
1191
- cursor: not-allowed;
1192
- opacity: 0.55;
1193
- }
1194
- .btn-submit {
1195
- border-color: var(--mlf-submit-bg, var(--mlf-color-accent, #1e40af));
1196
- background: var(--mlf-submit-bg, var(--mlf-color-accent, #1e40af));
1197
- color: var(--mlf-submit-color, #ffffff);
1198
- }
1199
- @media (max-width: 900px) {
1200
- .group.columns-2,
1201
- .group.columns-3 {
1202
- grid-template-columns: minmax(0, 1fr);
1203
- }
1204
- .footer {
1205
- flex-direction: column;
1206
- align-items: stretch;
1207
- }
1208
- .nav {
1209
- justify-content: space-between;
1210
- }
1211
- }
1212
- `, q = class extends c {
1213
- static styles = Fe;
1214
- #e;
1215
- get view() {
1216
- return this.#e;
1217
- }
1218
- set view(e) {
1219
- this.#e = e;
1220
- }
1221
- #t;
1222
- get registry() {
1223
- return this.#t;
1224
- }
1225
- set registry(e) {
1226
- this.#t = e;
1227
- }
1228
- #n = d;
1229
- get primitiveText() {
1230
- return this.#n;
1231
- }
1232
- set primitiveText(e) {
1233
- this.#n = e;
1234
- }
1235
- #r = "Submit";
1236
- get submitLabel() {
1237
- return this.#r;
1238
- }
1239
- set submitLabel(e) {
1240
- this.#r = e;
1241
- }
1242
- #i = "Validating...";
1243
- get validatingLabel() {
1244
- return this.#i;
1245
- }
1246
- set validatingLabel(e) {
1247
- this.#i = e;
1248
- }
1249
- #a = "Submitting...";
1250
- get submittingLabel() {
1251
- return this.#a;
1252
- }
1253
- set submittingLabel(e) {
1254
- this.#a = e;
1255
- }
1256
- #o = null;
1257
- get snapshot() {
1258
- return this.#o;
1259
- }
1260
- set snapshot(e) {
1261
- this.#o = e;
1262
- }
1263
- #s = null;
1264
- willUpdate(e) {
1265
- e.has("view") && (this.#s?.(), this.#s = null, this.snapshot = this.view?.getSnapshot() ?? null, this.view && (this.#s = this.view.subscribe((e) => {
1266
- this.snapshot = e;
1267
- })));
1268
- }
1269
- disconnectedCallback() {
1270
- this.#s?.(), this.#s = null, super.disconnectedCallback();
1271
- }
1272
- render() {
1273
- let e = this.snapshot, t = e?.tabs;
1274
- if (!e || !t || e.layout.kind !== "tabs") return o``;
1275
- let n = e.layout.tabs[t.activeTabIndex];
1276
- if (!n) return o``;
1277
- let r = e.form.status, i = r === "validating" ? this.validatingLabel : r === "submitting" ? this.submittingLabel : this.submitLabel;
1278
- return o`
1279
- <section class="root" part="tabs-panel">
1280
- <div class="tablist" role="tablist" aria-label="Form sections">
1281
- ${m(e.layout.tabs, (e) => e.id, (e, n) => o`
1282
- <button
1283
- type="button"
1284
- class="tab"
1285
- role="tab"
1286
- aria-selected=${String(n === t.activeTabIndex)}
1287
- aria-controls=${`panel-${e.id}`}
1288
- id=${`tab-${e.id}`}
1289
- @click=${() => this.view?.setActiveTab(e.id)}
1290
- >
1291
- ${e.title}
1292
- </button>
1293
- `)}
1294
- </div>
1295
-
1296
- <div
1297
- class="tab-panel"
1298
- role="tabpanel"
1299
- id=${`panel-${n.id}`}
1300
- aria-labelledby=${`tab-${n.id}`}
1301
- >
1302
- ${n.title || n.description ? o`
1303
- <header class="tab-header">
1304
- <h1 class="tab-title">${n.title}</h1>
1305
- ${n.description ? o`<p class="tab-description">${n.description}</p>` : b}
1306
- </header>
1307
- ` : b}
1308
-
1309
- <div class="body">
1310
- <div class="collection">
1311
- ${m(n.children, (e, t) => `${n.id}-${t}`, (t) => O({
1312
- node: t,
1313
- snapshot: e,
1314
- registry: this.registry,
1315
- primitiveText: this.primitiveText,
1316
- sectionClass: "section",
1317
- sectionCopyClass: "section-copy",
1318
- sectionTitleClass: "section-title",
1319
- sectionDescriptionClass: "section-description",
1320
- childrenClass: "section-children",
1321
- groupBaseClass: "group"
1322
- }))}
1323
- </div>
1324
- </div>
1325
- </div>
1326
-
1327
- <footer class="footer" part="actions">
1328
- <div class="nav">
1329
- <button
1330
- type="button"
1331
- class="btn"
1332
- ?disabled=${!t.canGoPrev}
1333
- @click=${() => this.view?.prevTab()}
1334
- >
1335
- Previous
1336
- </button>
1337
- <button
1338
- type="button"
1339
- class="btn"
1340
- ?disabled=${!t.canGoNext}
1341
- @click=${() => this.view?.nextTab()}
1342
- >
1343
- Next
1344
- </button>
1345
- </div>
1346
- <button
1347
- type="button"
1348
- class="btn btn-submit"
1349
- ?disabled=${r === "validating" || r === "submitting"}
1350
- @click=${this.#c}
1351
- >
1352
- ${i}
1353
- </button>
1354
- </footer>
1355
- </section>
1356
- `;
1357
- }
1358
- #c = async () => {
1359
- if (this.view) try {
1360
- await this.view.submit();
1361
- } catch (e) {
1362
- if (!await D(this, this.view)) throw e;
1363
- }
1364
- };
1365
- };
1366
- h([y({ attribute: !1 })], q.prototype, "view", null), h([y({ attribute: !1 })], q.prototype, "registry", null), h([y({ attribute: !1 })], q.prototype, "primitiveText", null), h([y({ type: String })], q.prototype, "submitLabel", null), h([y({ type: String })], q.prototype, "validatingLabel", null), h([y({ type: String })], q.prototype, "submittingLabel", null), h([s()], q.prototype, "snapshot", null), q = h([x(E.tabs)], q);
1367
- //#endregion
1368
- //#region src/kit/tabs.ts
1369
- var J = Symbol("mlform.kit.tabs.mounted"), Ie = (e) => "view" in e, Le = (e, t) => {
1370
- let r = e;
1371
- r[J]?.unmount();
1372
- let i = Ie(t) ? t.view : W({
1373
- schema: t.schema,
1374
- transport: t.transport,
1375
- registry: t.registry,
1376
- primitiveRegistry: t.primitiveRegistry,
1377
- designSystemRegistry: t.designSystemRegistry,
1378
- designSystem: t.designSystem,
1379
- initialValues: t.initialValues,
1380
- validators: t.validators,
1381
- hooks: t.hooks,
1382
- hookFailurePolicy: t.hookFailurePolicy,
1383
- inactiveFieldPolicy: t.inactiveFieldPolicy,
1384
- listenerErrorPolicy: t.listenerErrorPolicy,
1385
- onListenerError: t.onListenerError,
1386
- layout: t.layout
1387
- });
1388
- if (i.getSnapshot().layout.kind !== "tabs") throw TypeError(T.tabsMissingLayout);
1389
- let a = C(t.labels), o = u(t.primitiveText), s = w(t.designSystem), c = document.createElement(E.tabs);
1390
- c.view = i, c.registry = i.primitiveRegistry, c.primitiveText = o, c.submitLabel = a.submit, c.validatingLabel = a.validating, c.submittingLabel = a.submitting, e.replaceChildren(c);
1391
- let l = n(c, {
1392
- config: s,
1393
- registry: i.designSystemRegistry,
1394
- onChange: t.onDesignSystemChange
1395
- }), d = !1, f = Object.freeze({
1396
- view: i,
1397
- form: i.form,
1398
- host: c,
1399
- designSystem: l,
1400
- unmount() {
1401
- d || (d = !0, r[J] === f && delete r[J], i.form.abortSubmit("unmount"), l.disconnect(), c.remove());
1402
- }
1403
- });
1404
- return r[J] = f, f;
1405
- }, Y = class extends c {
1406
- static styles = a`
1407
- :host {
1408
- display: block;
1409
- min-width: 0;
1410
- }
1411
-
1412
- *,
1413
- *::before,
1414
- *::after {
1415
- box-sizing: border-box;
1416
- }
1417
-
1418
- .indicator {
1419
- display: grid;
1420
- gap: 0.5rem;
1421
- }
1422
-
1423
- .header {
1424
- display: flex;
1425
- align-items: center;
1426
- justify-content: space-between;
1427
- gap: 1rem;
1428
- }
1429
-
1430
- .step-label {
1431
- font-size: var(--mlf-font-size-sm, 0.84rem);
1432
- font-weight: 600;
1433
- letter-spacing: 0.05em;
1434
- text-transform: uppercase;
1435
- color: var(--mlf-color-text-muted, #475569);
1436
- }
1437
-
1438
- .step-fraction {
1439
- font-size: var(--mlf-font-size-sm, 0.84rem);
1440
- font-weight: 700;
1441
- color: var(--mlf-color-accent, #1e40af);
1442
- }
1443
-
1444
- .track {
1445
- height: 4px;
1446
- border-radius: 999px;
1447
- background: var(--mlf-color-border, #e2e8f0);
1448
- overflow: hidden;
1449
- }
1450
-
1451
- .fill {
1452
- height: 100%;
1453
- border-radius: 999px;
1454
- background: var(--mlf-color-accent, #1e40af);
1455
- transition: width 0.3s ease;
1456
- }
1457
-
1458
- .dots {
1459
- display: flex;
1460
- gap: 0.4rem;
1461
- flex-wrap: wrap;
1462
- }
1463
-
1464
- .dot {
1465
- width: 8px;
1466
- height: 8px;
1467
- border-radius: 50%;
1468
- background: var(--mlf-color-border, #e2e8f0);
1469
- transition:
1470
- background-color 0.2s ease,
1471
- transform 0.2s ease;
1472
- }
1473
-
1474
- .dot.active {
1475
- background: var(--mlf-color-accent, #1e40af);
1476
- transform: scale(1.25);
1477
- }
1478
-
1479
- .dot.done {
1480
- background: color-mix(in srgb, var(--mlf-color-accent, #1e40af) 50%, transparent);
1481
- }
1482
- `;
1483
- #e = 1;
1484
- get current() {
1485
- return this.#e;
1486
- }
1487
- set current(e) {
1488
- this.#e = e;
1489
- }
1490
- #t = 1;
1491
- get total() {
1492
- return this.#t;
1493
- }
1494
- set total(e) {
1495
- this.#t = e;
1496
- }
1497
- #n = "Step";
1498
- get label() {
1499
- return this.#n;
1500
- }
1501
- set label(e) {
1502
- this.#n = e;
1503
- }
1504
- render() {
1505
- let e = this.total > 0 ? Math.round(this.current / this.total * 100) : 0;
1506
- return o`
1507
- <div
1508
- class="indicator"
1509
- role="status"
1510
- aria-label=${`${this.label} ${this.current} of ${this.total}`}
1511
- >
1512
- <div class="header">
1513
- <span class="step-label">${this.label}</span>
1514
- <span class="step-fraction">${this.current} / ${this.total}</span>
1515
- </div>
1516
- <div class="track" aria-hidden="true">
1517
- <div class="fill" style="width: ${e}%"></div>
1518
- </div>
1519
- <div class="dots" aria-hidden="true">
1520
- ${Array.from({ length: this.total }, (e, t) => o`<div class=${t + 1 < this.current ? "dot done" : t + 1 === this.current ? "dot active" : "dot"}></div>`)}
1521
- </div>
1522
- </div>
1523
- `;
1524
- }
1525
- };
1526
- h([y({ type: Number })], Y.prototype, "current", null), h([y({ type: Number })], Y.prototype, "total", null), h([y({ type: String })], Y.prototype, "label", null), Y = h([x(E.stepIndicator)], Y);
1527
- //#endregion
1528
- //#region src/kit/wizard-constants.ts
1529
- var X = {
1530
- prev: "Previous",
1531
- next: "Next",
1532
- submit: "Submit",
1533
- validating: "Validating...",
1534
- submitting: "Submitting..."
1535
- }, Re = Object.freeze({
1536
- stepLabel: (e, t) => `Step ${e} of ${t}`,
1537
- prevLabel: "Previous",
1538
- nextLabel: "Next",
1539
- submitLabel: "Submit",
1540
- validatingLabel: "Validating...",
1541
- submittingLabel: "Submitting..."
1542
- }), Z = (e) => e ? Object.freeze({
1543
- ...Re,
1544
- ...e
1545
- }) : Re, ze = a`
1546
- :host {
1547
- display: block;
1548
- flex: 1 1 auto;
1549
- align-self: stretch;
1550
- inline-size: 100%;
1551
- block-size: 100%;
1552
- color: var(--mlf-shell-color, var(--mlf-color-text, #0f172a));
1553
- background: var(--mlf-shell-bg, var(--mlf-color-bg, #f5f7fa));
1554
- font-family: var(--mlf-font-family-body);
1555
- min-width: 0;
1556
- min-height: 0;
1557
- }
1558
- *,
1559
- *::before,
1560
- *::after {
1561
- box-sizing: border-box;
1562
- }
1563
- .root {
1564
- display: grid;
1565
- grid-template-rows: 1fr;
1566
- gap: var(--mlf-shell-gap, 1rem);
1567
- inline-size: 100%;
1568
- block-size: 100%;
1569
- min-width: 0;
1570
- min-height: 0;
1571
- }
1572
- .panel {
1573
- display: flex;
1574
- flex-direction: column;
1575
- min-width: 0;
1576
- min-height: 0;
1577
- overflow: hidden;
1578
- border-radius: var(--mlf-panel-radius, 12px);
1579
- border: var(--mlf-border-width, 1px) solid
1580
- var(--mlf-shell-panel-border, var(--mlf-color-border, #e2e8f0));
1581
- background: var(--mlf-shell-panel-bg, var(--mlf-color-surface, #ffffff));
1582
- box-shadow:
1583
- 0 2px 4px var(--mlf-shell-panel-shadow-soft, rgba(0, 0, 0, 0.04)),
1584
- 0 8px 16px var(--mlf-shell-panel-shadow, rgba(0, 0, 0, 0.04));
1585
- }
1586
- .pane-header {
1587
- flex: 0 0 auto;
1588
- display: grid;
1589
- gap: 0.85rem;
1590
- padding: 1rem 1.5rem;
1591
- border-bottom: var(--mlf-border-width, 1px) solid
1592
- var(--mlf-shell-panel-border, var(--mlf-color-border, #e2e8f0));
1593
- background: var(
1594
- --mlf-shell-header-bg,
1595
- color-mix(in srgb, var(--mlf-color-surface, #ffffff) 76%, transparent)
1596
- );
1597
- backdrop-filter: blur(var(--mlf-shell-header-blur, 3px));
1598
- -webkit-backdrop-filter: blur(var(--mlf-shell-header-blur, 3px));
1599
- }
1600
- .step-title {
1601
- margin: 0;
1602
- font-size: 1.1rem;
1603
- font-weight: 700;
1604
- color: var(--mlf-pane-title-color, var(--mlf-color-text, #0f172a));
1605
- line-height: 1.3;
1606
- }
1607
- .step-description {
1608
- margin: 0;
1609
- font-size: var(--mlf-font-size-sm, 0.84rem);
1610
- color: var(--mlf-color-text-muted, #475569);
1611
- line-height: 1.5;
1612
- }
1613
- .pane-body {
1614
- flex: 1 1 auto;
1615
- display: grid;
1616
- align-content: start;
1617
- gap: 1rem;
1618
- padding: 1rem 1rem 1.25rem;
1619
- overflow-y: auto;
1620
- overflow-x: hidden;
1621
- }
1622
- .collection,
1623
- .section-children,
1624
- .section,
1625
- .group {
1626
- display: grid;
1627
- gap: var(--mlf-section-gap, 1rem);
1628
- }
1629
- .section-copy {
1630
- display: grid;
1631
- gap: 0.35rem;
1632
- padding: 0 0.5rem;
1633
- }
1634
- .section-title {
1635
- margin: 0;
1636
- font-size: 0.95rem;
1637
- font-weight: 700;
1638
- color: var(--mlf-color-text, #0f172a);
1639
- }
1640
- .section-description {
1641
- margin: 0;
1642
- font-size: var(--mlf-font-size-sm, 0.84rem);
1643
- color: var(--mlf-color-text-muted, #475569);
1644
- line-height: 1.5;
1645
- }
1646
- .group.columns-2 {
1647
- grid-template-columns: repeat(2, minmax(0, 1fr));
1648
- }
1649
- .group.columns-3 {
1650
- grid-template-columns: repeat(3, minmax(0, 1fr));
1651
- }
1652
- .actions {
1653
- flex: 0 0 auto;
1654
- display: flex;
1655
- align-items: center;
1656
- justify-content: space-between;
1657
- gap: 1rem;
1658
- padding: 0.75rem 1.5rem;
1659
- border-top: var(--mlf-border-width, 1px) solid
1660
- var(--mlf-shell-panel-border, var(--mlf-color-border, #e2e8f0));
1661
- background: var(--mlf-shell-action-bg, var(--mlf-color-surface-muted, #f5f7fa));
1662
- }
1663
- .btn {
1664
- display: inline-flex;
1665
- align-items: center;
1666
- justify-content: center;
1667
- gap: 0.5rem;
1668
- min-height: 2.5rem;
1669
- padding: 0.5rem 1.25rem;
1670
- border: var(--mlf-border-width, 1px) solid transparent;
1671
- border-radius: var(--mlf-input-radius, 12px);
1672
- font: inherit;
1673
- font-size: 0.95rem;
1674
- font-weight: 600;
1675
- cursor: pointer;
1676
- transition:
1677
- background-color 0.2s ease,
1678
- border-color 0.2s ease,
1679
- opacity 0.2s ease;
1680
- }
1681
- .btn:disabled {
1682
- cursor: not-allowed;
1683
- opacity: 0.55;
1684
- }
1685
- .btn-prev {
1686
- background: transparent;
1687
- border-color: var(--mlf-input-border, var(--mlf-color-border, #e2e8f0));
1688
- color: var(--mlf-color-text-muted, #475569);
1689
- }
1690
- .btn-next,
1691
- .btn-submit {
1692
- background: var(--mlf-submit-bg, var(--mlf-color-accent, #1e40af));
1693
- border-color: var(--mlf-submit-bg, var(--mlf-color-accent, #1e40af));
1694
- color: var(--mlf-submit-color, #ffffff);
1695
- }
1696
- .spacer {
1697
- flex: 1 1 auto;
1698
- }
1699
- @media (max-width: 900px) {
1700
- .group.columns-2,
1701
- .group.columns-3 {
1702
- grid-template-columns: minmax(0, 1fr);
1703
- }
1704
- }
1705
- `, Q = class extends c {
1706
- static styles = ze;
1707
- #e;
1708
- get view() {
1709
- return this.#e;
1710
- }
1711
- set view(e) {
1712
- this.#e = e;
1713
- }
1714
- #t;
1715
- get registry() {
1716
- return this.#t;
1717
- }
1718
- set registry(e) {
1719
- this.#t = e;
1720
- }
1721
- #n = d;
1722
- get primitiveText() {
1723
- return this.#n;
1724
- }
1725
- set primitiveText(e) {
1726
- this.#n = e;
1727
- }
1728
- #r = X;
1729
- get labels() {
1730
- return this.#r;
1731
- }
1732
- set labels(e) {
1733
- this.#r = e;
1734
- }
1735
- #i = Z();
1736
- get text() {
1737
- return this.#i;
1738
- }
1739
- set text(e) {
1740
- this.#i = e;
1741
- }
1742
- #a = null;
1743
- get snapshot() {
1744
- return this.#a;
1745
- }
1746
- set snapshot(e) {
1747
- this.#a = e;
1748
- }
1749
- #o = null;
1750
- willUpdate(e) {
1751
- e.has("view") && (this.#o?.(), this.#o = null, this.snapshot = this.view?.getSnapshot() ?? null, this.view && (this.#o = this.view.subscribe((e) => {
1752
- this.snapshot = e;
1753
- })));
1754
- }
1755
- disconnectedCallback() {
1756
- this.#o?.(), this.#o = null, super.disconnectedCallback();
1757
- }
1758
- render() {
1759
- let e = this.snapshot, t = e?.wizard;
1760
- if (!e || !t || e.layout.kind !== "wizard") return o``;
1761
- let n = e.layout.steps[t.stepIndex];
1762
- if (!n) return o``;
1763
- let r = e.form.status, i = r === "validating" || r === "submitting", a = t.isLastStep ? r === "validating" ? this.labels.validating : r === "submitting" ? this.labels.submitting : this.labels.submit : this.labels.next;
1764
- return o`
1765
- <div class="root">
1766
- <section class="panel" part="wizard-panel">
1767
- <header class="pane-header">
1768
- <mlf-kit-step-indicator
1769
- .current=${t.stepIndex + 1}
1770
- .total=${t.stepCount}
1771
- .label=${this.text.stepLabel(t.stepIndex + 1, t.stepCount).split(" ")[0] ?? "Step"}
1772
- ></mlf-kit-step-indicator>
1773
- <h1 class="step-title">${n.title}</h1>
1774
- ${n.description ? o`<p class="step-description">${n.description}</p>` : b}
1775
- </header>
1776
-
1777
- <div class="pane-body">
1778
- <div class="collection">
1779
- ${m(n.children, (e, t) => `${n.id}-${t}`, (t) => O({
1780
- node: t,
1781
- snapshot: e,
1782
- registry: this.registry,
1783
- primitiveText: this.primitiveText,
1784
- sectionClass: "section",
1785
- sectionCopyClass: "section-copy",
1786
- sectionTitleClass: "section-title",
1787
- sectionDescriptionClass: "section-description",
1788
- childrenClass: "section-children",
1789
- groupBaseClass: "group"
1790
- }))}
1791
- </div>
1792
- </div>
1793
-
1794
- <div class="actions" part="actions">
1795
- <button
1796
- type="button"
1797
- class="btn btn-prev"
1798
- ?disabled=${!t.canPrev || i}
1799
- @click=${this.#s}
1800
- >
1801
- ${this.labels.prev}
1802
- </button>
1803
- <span class="spacer"></span>
1804
- <button
1805
- type="button"
1806
- class=${t.isLastStep ? "btn btn-submit" : "btn btn-next"}
1807
- ?disabled=${i}
1808
- @click=${t.isLastStep ? this.#l : this.#c}
1809
- >
1810
- ${a}
1811
- </button>
1812
- </div>
1813
- </section>
1814
- </div>
1815
- `;
1816
- }
1817
- #s = () => {
1818
- this.view?.prevStep();
1819
- };
1820
- #c = async () => {
1821
- await this.view?.nextStep() === !1 && this.view && await D(this, this.view);
1822
- };
1823
- #l = async () => {
1824
- if (this.view) {
1825
- if (!await this.view.nextStep()) {
1826
- await D(this, this.view);
1827
- return;
1828
- }
1829
- try {
1830
- await this.view.submit();
1831
- } catch (e) {
1832
- if (!await D(this, this.view)) throw e;
1833
- }
1834
- }
1835
- };
1836
- };
1837
- h([y({ attribute: !1 })], Q.prototype, "view", null), h([y({ attribute: !1 })], Q.prototype, "registry", null), h([y({ attribute: !1 })], Q.prototype, "primitiveText", null), h([y({ attribute: !1 })], Q.prototype, "labels", null), h([y({ attribute: !1 })], Q.prototype, "text", null), h([s()], Q.prototype, "snapshot", null), Q = h([x(E.wizard)], Q);
1838
- //#endregion
1839
- //#region src/kit/wizard.ts
1840
- var $ = Symbol("mlform.kit.wizard.mounted"), Be = (e) => "view" in e, Ve = (e, t) => {
1841
- let r = e;
1842
- r[$]?.unmount();
1843
- let i = Be(t) ? t.view : W({
1844
- schema: t.schema,
1845
- transport: t.transport,
1846
- registry: t.registry,
1847
- primitiveRegistry: t.primitiveRegistry,
1848
- designSystemRegistry: t.designSystemRegistry,
1849
- designSystem: t.designSystem,
1850
- initialValues: t.initialValues,
1851
- validators: t.validators,
1852
- hooks: t.hooks,
1853
- hookFailurePolicy: t.hookFailurePolicy,
1854
- inactiveFieldPolicy: t.inactiveFieldPolicy,
1855
- listenerErrorPolicy: t.listenerErrorPolicy,
1856
- onListenerError: t.onListenerError,
1857
- layout: t.layout
1858
- });
1859
- if (i.getSnapshot().layout.kind !== "wizard") throw TypeError(T.wizardMissingLayout);
1860
- let a = document.createElement(E.wizard), o = {
1861
- ...X,
1862
- ...t.labels
1863
- }, s = Z({
1864
- ...t.text,
1865
- prevLabel: o.prev,
1866
- nextLabel: o.next,
1867
- submitLabel: o.submit,
1868
- validatingLabel: o.validating,
1869
- submittingLabel: o.submitting
1870
- }), c = u(t.primitiveText), l = w(t.designSystem);
1871
- a.view = i, a.registry = i.primitiveRegistry, a.primitiveText = c, a.labels = o, a.text = s, e.replaceChildren(a);
1872
- let d = n(a, {
1873
- config: l,
1874
- registry: i.designSystemRegistry,
1875
- onChange: t.onDesignSystemChange
1876
- }), f = !1, p = Object.freeze({
1877
- view: i,
1878
- form: i.form,
1879
- host: a,
1880
- designSystem: d,
1881
- unmount() {
1882
- f || (f = !0, r[$] === p && delete r[$], i.form.abortSubmit("unmount"), d.disconnect(), a.remove());
1883
- }
1884
- });
1885
- return r[$] = p, p;
1886
- };
1887
- //#endregion
1888
- export { je as a, F as c, S as d, Pe as i, P as l, Le as n, W as o, Ne as r, I as s, Ve as t, ne as u };