@texaryn/web-components 0.0.0 → 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 (48) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +190 -0
  3. package/README.md +111 -0
  4. package/dist/binding.d.ts +9 -0
  5. package/dist/binding.d.ts.map +1 -0
  6. package/dist/binding.js +38 -0
  7. package/dist/binding.js.map +1 -0
  8. package/dist/containers.d.ts +11 -0
  9. package/dist/containers.d.ts.map +1 -0
  10. package/dist/containers.js +243 -0
  11. package/dist/containers.js.map +1 -0
  12. package/dist/define.d.ts +3 -0
  13. package/dist/define.d.ts.map +1 -0
  14. package/dist/define.js +11 -0
  15. package/dist/define.js.map +1 -0
  16. package/dist/element.d.ts +26 -0
  17. package/dist/element.d.ts.map +1 -0
  18. package/dist/element.js +140 -0
  19. package/dist/element.js.map +1 -0
  20. package/dist/field-state.d.ts +18 -0
  21. package/dist/field-state.d.ts.map +1 -0
  22. package/dist/field-state.js +51 -0
  23. package/dist/field-state.js.map +1 -0
  24. package/dist/fields.d.ts +8 -0
  25. package/dist/fields.d.ts.map +1 -0
  26. package/dist/fields.js +141 -0
  27. package/dist/fields.js.map +1 -0
  28. package/dist/ids.d.ts +4 -0
  29. package/dist/ids.d.ts.map +1 -0
  30. package/dist/ids.js +10 -0
  31. package/dist/ids.js.map +1 -0
  32. package/dist/index.d.ts +10 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +7 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/mount.d.ts +12 -0
  37. package/dist/mount.d.ts.map +1 -0
  38. package/dist/mount.js +39 -0
  39. package/dist/mount.js.map +1 -0
  40. package/dist/registry.d.ts +9 -0
  41. package/dist/registry.d.ts.map +1 -0
  42. package/dist/registry.js +23 -0
  43. package/dist/registry.js.map +1 -0
  44. package/dist/widget.d.ts +24 -0
  45. package/dist/widget.d.ts.map +1 -0
  46. package/dist/widget.js +2 -0
  47. package/dist/widget.js.map +1 -0
  48. package/package.json +44 -3
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @texaryn/web-components
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b87dd23: First release. A `<texaryn-form>` custom element over the unchanged `FormRuntime`, rendering native controls in light DOM and usable from any framework or none. Registration is explicit through `defineTexarynForm()`. The element either creates a runtime from a `port` and destroys it on removal, or borrows one assigned through `runtime` and never destroys it. Native events are left alone and the element adds only `texaryn-data-change` and `texaryn-submission-change`. One `<form novalidate>` turns its submit into the `Submit` command, and every DOM id carries a per-element prefix so two forms on one page share none.
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2024-2026 Hamza Hamidi
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # @texaryn/web-components
2
+
3
+ A `<texaryn-form>` custom element for Texaryn, rendering native form controls
4
+ in light DOM. Usable from any framework, or from none.
5
+
6
+ > Status: pre-1.0. Public APIs may change before 1.0.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ pnpm add @texaryn/core @texaryn/schema-json @texaryn/web-components
12
+ ```
13
+
14
+ The package depends on `@texaryn/core` only. It has no framework dependency
15
+ and loads no stylesheet.
16
+
17
+ ## Quick start
18
+
19
+ Registration is explicit, so importing the package defines nothing on its own:
20
+
21
+ ```ts
22
+ import { createJsonSchemaAdapter } from '@texaryn/schema-json'
23
+ import { createDefaultRegistry, defineTexarynForm } from '@texaryn/web-components'
24
+ import type { TexarynFormElement } from '@texaryn/web-components'
25
+
26
+ defineTexarynForm()
27
+
28
+ const port = await createJsonSchemaAdapter({
29
+ type: 'object',
30
+ properties: { name: { type: 'string', title: 'Name' } },
31
+ required: ['name'],
32
+ })
33
+
34
+ const form = document.createElement('texaryn-form') as TexarynFormElement
35
+ form.registry = createDefaultRegistry()
36
+ form.options = { initialData: { name: '' }, onSubmit: (data) => console.log(data) }
37
+ form.port = port
38
+ document.body.append(form)
39
+ ```
40
+
41
+ ## Two ownership modes
42
+
43
+ The element either creates a runtime or borrows one, and the two are mutually
44
+ exclusive: setting both throws.
45
+
46
+ - `port` plus `options` is the managed mode. The element creates a runtime and
47
+ destroys it when the element is removed from the document. `options` is read
48
+ when that runtime is created, so set it before `port`; setting `port` again
49
+ rebuilds the runtime with the current options.
50
+ - `runtime` is the primitive input. A runtime assigned this way is borrowed
51
+ and never destroyed by the element, which is what lets an application own
52
+ one runtime and render it through several bindings.
53
+
54
+ Being removed from the document is not the same as being discarded. Moving the
55
+ element between parents fires `disconnectedCallback` too, so disposal is
56
+ deferred and skipped if the element is connected again, and a reparent keeps
57
+ the runtime, the controls and their values.
58
+
59
+ ## Events
60
+
61
+ Native events are left alone. The controls are real elements in light DOM, so
62
+ `input`, `change` and `blur` bubble on their own. The element adds only its own
63
+ namespaced events, each carrying a store snapshot as `detail`:
64
+
65
+ - `texaryn-data-change`, the current form data
66
+ - `texaryn-submission-change`, the current submission state
67
+
68
+ ## Submission
69
+
70
+ The element renders one `<form novalidate>` and turns its `submit` event into
71
+ the `Submit` command, so a `type="submit"` button placed inside the form works
72
+ the way a consumer expects. The runtime owns validation, which is why the
73
+ native `novalidate` is set and required fields carry `aria-required` rather
74
+ than the native `required` attribute.
75
+
76
+ ## Ids
77
+
78
+ Every id is `<prefix>-<nodeId>-<suffix>`, where the prefix is the element's own
79
+ `id` attribute when it has one and an allocated value otherwise. Two forms on
80
+ one page therefore share no ids, and every `for` and `aria-describedby`
81
+ resolves inside its own element.
82
+
83
+ ## Key exports
84
+
85
+ - `defineTexarynForm`
86
+ - `TexarynFormElement`
87
+ - `createDefaultRegistry`
88
+ - `mountForm`
89
+ - `makeId`
90
+ - `textInput`, `numberInput`, `checkbox`, `select`, `textarea`
91
+ - `objectLayout`, `arrayControl`
92
+ - types: `DomWidget`, `WidgetFactory`, `NodeBinding`, `RenderContext`, `Mount`
93
+
94
+ ## Not in this release
95
+
96
+ Shadow DOM, `formAssociated` and `ElementInternals`, nesting inside another
97
+ `<form>`, group and layout containers beyond objects and arrays, text and
98
+ action nodes, and focus management after a failed submit.
99
+
100
+ ## Related packages
101
+
102
+ - [`@texaryn/core`](../core/README.md), runtime and renderer contracts
103
+ - [`@texaryn/schema-json`](../schema-json/README.md), JSON Schema adapter
104
+ - [`@texaryn/react`](../react/README.md), the React binding over the same runtime
105
+ - [`@texaryn/vue`](../vue/README.md), the Vue binding over the same runtime
106
+
107
+ See the [repository README](../../README.md) for the complete architecture.
108
+
109
+ ## License
110
+
111
+ Apache-2.0
@@ -0,0 +1,9 @@
1
+ import type { UINode } from '@texaryn/core';
2
+ import type { NodeBinding, RenderContext } from './widget.js';
3
+ /**
4
+ * Resolves a widget for a node and keeps it across updates while the same
5
+ * factory still matches. Visibility is a `hidden` toggle rather than an
6
+ * unmount, so a conditional reveal never rebuilds the subtree.
7
+ */
8
+ export declare function createNodeBinding(initial: UINode, ctx: RenderContext): NodeBinding;
9
+ //# sourceMappingURL=binding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../src/binding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAa,WAAW,EAAE,aAAa,EAAiB,MAAM,aAAa,CAAA;AAQvF;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,GAAG,WAAW,CA0BlF"}
@@ -0,0 +1,38 @@
1
+ function placeholder() {
2
+ const element = document.createElement('span');
3
+ element.hidden = true;
4
+ return { element, update() { }, destroy() { } };
5
+ }
6
+ /**
7
+ * Resolves a widget for a node and keeps it across updates while the same
8
+ * factory still matches. Visibility is a `hidden` toggle rather than an
9
+ * unmount, so a conditional reveal never rebuilds the subtree.
10
+ */
11
+ export function createNodeBinding(initial, ctx) {
12
+ let factory = ctx.registry.resolve(initial);
13
+ let widget = factory ? factory(initial, ctx) : placeholder();
14
+ widget.element.hidden = !initial.visible;
15
+ return {
16
+ get element() {
17
+ return widget.element;
18
+ },
19
+ update(node) {
20
+ const next = ctx.registry.resolve(node);
21
+ if (next !== factory) {
22
+ const replacement = next ? next(node, ctx) : placeholder();
23
+ widget.element.replaceWith(replacement.element);
24
+ widget.destroy();
25
+ widget = replacement;
26
+ factory = next;
27
+ }
28
+ else {
29
+ widget.update(node);
30
+ }
31
+ widget.element.hidden = !node.visible;
32
+ },
33
+ destroy() {
34
+ widget.destroy();
35
+ },
36
+ };
37
+ }
38
+ //# sourceMappingURL=binding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding.js","sourceRoot":"","sources":["../src/binding.ts"],"names":[],"mappings":"AAGA,SAAS,WAAW;IAClB,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;IAC9C,OAAO,CAAC,MAAM,GAAG,IAAI,CAAA;IACrB,OAAO,EAAE,OAAO,EAAE,MAAM,KAAI,CAAC,EAAE,OAAO,KAAI,CAAC,EAAE,CAAA;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe,EAAE,GAAkB;IACnE,IAAI,OAAO,GAA8B,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IACtE,IAAI,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;IAC5D,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,OAAO,CAAC,OAAO,CAAA;IAExC,OAAO;QACL,IAAI,OAAO;YACT,OAAO,MAAM,CAAC,OAAO,CAAA;QACvB,CAAC;QACD,MAAM,CAAC,IAAI;YACT,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YACvC,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;gBACrB,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;gBAC1D,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;gBAC/C,MAAM,CAAC,OAAO,EAAE,CAAA;gBAChB,MAAM,GAAG,WAAW,CAAA;gBACpB,OAAO,GAAG,IAAI,CAAA;YAChB,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YACrB,CAAC;YACD,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAA;QACvC,CAAC;QACD,OAAO;YACL,MAAM,CAAC,OAAO,EAAE,CAAA;QAClB,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { UINode } from '@texaryn/core';
2
+ import type { DomWidget, RenderContext } from './widget.js';
3
+ export declare function objectLayout(initial: UINode, ctx: RenderContext): DomWidget;
4
+ /**
5
+ * Rows are keyed by `StableItemId`, which survives insert, remove and move,
6
+ * and each row's binding is re-pointed at whatever positional node now sits
7
+ * at its index. Buttons resolve their index at click time for the same
8
+ * reason: an index captured at render time is stale after any mutation.
9
+ */
10
+ export declare function arrayControl(initial: UINode, ctx: RenderContext): DomWidget;
11
+ //# sourceMappingURL=containers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containers.d.ts","sourceRoot":"","sources":["../src/containers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA+B,MAAM,EAAE,MAAM,eAAe,CAAA;AACxE,OAAO,KAAK,EAAE,SAAS,EAAe,aAAa,EAAE,MAAM,aAAa,CAAA;AA4ExE,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,GAAG,SAAS,CAqE3E;AAUD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,GAAG,SAAS,CA2F3E"}
@@ -0,0 +1,243 @@
1
+ function currentNodes(ctx) {
2
+ return ctx.runtime.document.getSnapshot().nodes;
3
+ }
4
+ /**
5
+ * Moves `el` before `ref` inside `parent`. `insertBefore` on a connected node
6
+ * is a remove and an insert, and the removal runs the focus fixup, so a
7
+ * focused row blurs. `moveBefore` is the atomic move that keeps focus and
8
+ * selection where the browser has it; the fallback is plain `insertBefore`,
9
+ * made safe by the anchor rule in `reorder`.
10
+ */
11
+ function place(parent, el, ref) {
12
+ if (el.parentNode === parent && typeof parent.moveBefore === 'function') {
13
+ parent.moveBefore(el, ref);
14
+ }
15
+ else {
16
+ parent.insertBefore(el, ref);
17
+ }
18
+ }
19
+ /**
20
+ * Puts `wanted` in order under `parent` without ever moving the element that
21
+ * contains the focused control. Every other element is placed relative to
22
+ * that anchor, so the result is the same order and the focus never leaves
23
+ * the document. Elements that are not wanted must already be gone.
24
+ */
25
+ function reorder(parent, wanted) {
26
+ const active = document.activeElement;
27
+ const anchorIndex = active ? wanted.findIndex((el) => el.contains(active)) : -1;
28
+ if (anchorIndex < 0) {
29
+ wanted.forEach((el, index) => {
30
+ const at = parent.children[index] ?? null;
31
+ if (at !== el)
32
+ place(parent, el, at);
33
+ });
34
+ return;
35
+ }
36
+ const anchor = wanted[anchorIndex];
37
+ let ref = anchor;
38
+ for (let i = anchorIndex - 1; i >= 0; i--) {
39
+ const el = wanted[i];
40
+ if (el.nextSibling !== ref)
41
+ place(parent, el, ref);
42
+ ref = el;
43
+ }
44
+ let prev = anchor;
45
+ for (let i = anchorIndex + 1; i < wanted.length; i++) {
46
+ const el = wanted[i];
47
+ if (prev.nextSibling !== el)
48
+ place(parent, el, prev.nextSibling);
49
+ prev = el;
50
+ }
51
+ }
52
+ function button(label, onClick) {
53
+ const element = document.createElement('button');
54
+ element.type = 'button';
55
+ element.textContent = label;
56
+ element.addEventListener('click', onClick);
57
+ return element;
58
+ }
59
+ /**
60
+ * Object children are keyed by their property name, the last pointer
61
+ * segment, never by node id. Node ids are positional, so when the row that
62
+ * contains this object moves, every child arrives with a new id; the property
63
+ * name is what still says "this is the same field", and keeping the binding
64
+ * is what keeps its input element and the focus on it.
65
+ */
66
+ function childKey(node) {
67
+ const pointer = node.dataPointer;
68
+ if (pointer == null)
69
+ return node.id;
70
+ const index = pointer.lastIndexOf('/');
71
+ return index >= 0 ? pointer.slice(index + 1) : pointer;
72
+ }
73
+ export function objectLayout(initial, ctx) {
74
+ // Whether a node is nested is fixed for its lifetime, but its title is not:
75
+ // a conditional subschema can add or drop one on any recompile, and this
76
+ // widget survives that. So the element is chosen once and the grouping
77
+ // semantics are re-derived from the node on every reconcile.
78
+ const nested = initial.parentId !== null;
79
+ const root = document.createElement(nested ? 'fieldset' : 'div');
80
+ root.className = 'texaryn-object';
81
+ const legend = nested ? document.createElement('legend') : null;
82
+ // Children live in their own element so the legend is never a candidate for reorder.
83
+ const body = nested ? document.createElement('div') : root;
84
+ if (body !== root)
85
+ root.append(body);
86
+ const bindings = new Map();
87
+ /** The root object is the form itself, so only a nested titled object names a group. */
88
+ function applyGrouping(node) {
89
+ if (!legend)
90
+ return;
91
+ const title = node.annotations.title;
92
+ if (title === undefined) {
93
+ legend.remove();
94
+ // An unnamed group is noise, so the fieldset stops being one.
95
+ root.setAttribute('role', 'none');
96
+ return;
97
+ }
98
+ legend.textContent = title;
99
+ // A legend names its fieldset only as the first child.
100
+ if (root.firstChild !== legend)
101
+ root.prepend(legend);
102
+ root.removeAttribute('role');
103
+ }
104
+ function reconcile(node) {
105
+ applyGrouping(node);
106
+ const nodes = currentNodes(ctx);
107
+ const wanted = node.children.map((id) => nodes[id]).filter((n) => n != null);
108
+ const keep = new Set();
109
+ const elements = [];
110
+ for (const child of wanted) {
111
+ const key = childKey(child);
112
+ keep.add(key);
113
+ let binding = bindings.get(key);
114
+ if (binding) {
115
+ binding.update(child);
116
+ }
117
+ else {
118
+ binding = ctx.mountChild(child);
119
+ bindings.set(key, binding);
120
+ }
121
+ elements.push(binding.element);
122
+ }
123
+ for (const [key, binding] of bindings) {
124
+ if (keep.has(key))
125
+ continue;
126
+ binding.destroy();
127
+ binding.element.remove();
128
+ bindings.delete(key);
129
+ }
130
+ reorder(body, elements);
131
+ }
132
+ reconcile(initial);
133
+ return {
134
+ element: root,
135
+ update(node) {
136
+ reconcile(node);
137
+ },
138
+ destroy() {
139
+ for (const binding of bindings.values())
140
+ binding.destroy();
141
+ bindings.clear();
142
+ },
143
+ };
144
+ }
145
+ /**
146
+ * Rows are keyed by `StableItemId`, which survives insert, remove and move,
147
+ * and each row's binding is re-pointed at whatever positional node now sits
148
+ * at its index. Buttons resolve their index at click time for the same
149
+ * reason: an index captured at render time is stale after any mutation.
150
+ */
151
+ export function arrayControl(initial, ctx) {
152
+ let node = initial;
153
+ const root = document.createElement('div');
154
+ root.className = 'texaryn-array';
155
+ const list = document.createElement('div');
156
+ const add = button('Add', () => {
157
+ ctx.runtime.dispatch({
158
+ type: 'InsertItem',
159
+ containerId: node.id,
160
+ index: node.arrayMeta?.itemIds.length ?? 0,
161
+ });
162
+ });
163
+ root.append(list, add);
164
+ const rows = new Map();
165
+ function indexOf(itemId) {
166
+ return node.arrayMeta?.itemIds.indexOf(itemId) ?? -1;
167
+ }
168
+ function createRow(itemId) {
169
+ const element = document.createElement('div');
170
+ element.className = 'texaryn-array-item';
171
+ element.dataset.itemId = itemId;
172
+ const slot = document.createElement('div');
173
+ const up = button('Up', () => {
174
+ const index = indexOf(itemId);
175
+ if (index > 0) {
176
+ ctx.runtime.dispatch({ type: 'MoveItem', containerId: node.id, from: index, to: index - 1 });
177
+ }
178
+ });
179
+ const remove = button('Remove', () => {
180
+ const index = indexOf(itemId);
181
+ if (index >= 0)
182
+ ctx.runtime.dispatch({ type: 'RemoveItem', containerId: node.id, index });
183
+ });
184
+ element.append(slot, up, remove);
185
+ return { element, slot, binding: null, up, remove };
186
+ }
187
+ function reconcile(next) {
188
+ node = next;
189
+ const meta = node.arrayMeta;
190
+ const nodes = currentNodes(ctx);
191
+ const itemIds = meta?.itemIds ?? [];
192
+ const keep = new Set();
193
+ const elements = [];
194
+ itemIds.forEach((itemId, index) => {
195
+ keep.add(itemId);
196
+ let row = rows.get(itemId);
197
+ if (!row) {
198
+ row = createRow(itemId);
199
+ rows.set(itemId, row);
200
+ }
201
+ const child = nodes[node.children[index]];
202
+ if (child) {
203
+ if (row.binding) {
204
+ row.binding.update(child);
205
+ }
206
+ else {
207
+ row.binding = ctx.mountChild(child);
208
+ row.slot.append(row.binding.element);
209
+ }
210
+ }
211
+ else if (row.binding) {
212
+ row.binding.destroy();
213
+ row.binding.element.remove();
214
+ row.binding = null;
215
+ }
216
+ row.remove.hidden = !(meta?.canRemove ?? false);
217
+ row.up.hidden = !(meta?.canReorder ?? false) || index === 0;
218
+ elements.push(row.element);
219
+ });
220
+ for (const [itemId, row] of rows) {
221
+ if (keep.has(itemId))
222
+ continue;
223
+ row.binding?.destroy();
224
+ row.element.remove();
225
+ rows.delete(itemId);
226
+ }
227
+ reorder(list, elements);
228
+ add.hidden = !(meta?.canAdd ?? false);
229
+ }
230
+ reconcile(node);
231
+ return {
232
+ element: root,
233
+ update(next) {
234
+ reconcile(next);
235
+ },
236
+ destroy() {
237
+ for (const row of rows.values())
238
+ row.binding?.destroy();
239
+ rows.clear();
240
+ },
241
+ };
242
+ }
243
+ //# sourceMappingURL=containers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containers.js","sourceRoot":"","sources":["../src/containers.ts"],"names":[],"mappings":"AAGA,SAAS,YAAY,CAAC,GAAkB;IACtC,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,CAAA;AACjD,CAAC;AAID;;;;;;GAMG;AACH,SAAS,KAAK,CAAC,MAAe,EAAE,EAAe,EAAE,GAAgB;IAC/D,IAAI,EAAE,CAAC,UAAU,KAAK,MAAM,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;QACxE,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;IAC5B,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,YAAY,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;IAC9B,CAAC;AACH,CAAC;AAED;;;;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EAAE,CAAA;YACpB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACrB,CAAC;QACD,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;QACvB,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,IAAI,KAAK,CAAC,CAAA;IACvC,CAAC;IAED,SAAS,CAAC,IAAI,CAAC,CAAA;IAEf,OAAO;QACL,OAAO,EAAE,IAAI;QACb,MAAM,CAAC,IAAI;YACT,SAAS,CAAC,IAAqB,CAAC,CAAA;QAClC,CAAC;QACD,OAAO;YACL,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE;gBAAE,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,CAAA;YACvD,IAAI,CAAC,KAAK,EAAE,CAAA;QACd,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Registers the element once; a second call for the same tag returns what is already registered. */
2
+ export declare function defineTexarynForm(tagName?: string): CustomElementConstructor;
3
+ //# sourceMappingURL=define.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAEA,qGAAqG;AACrG,wBAAgB,iBAAiB,CAAC,OAAO,SAAiB,GAAG,wBAAwB,CAMpF"}
package/dist/define.js ADDED
@@ -0,0 +1,11 @@
1
+ import { texarynFormElementClass } from './element.js';
2
+ /** Registers the element once; a second call for the same tag returns what is already registered. */
3
+ export function defineTexarynForm(tagName = 'texaryn-form') {
4
+ const existing = customElements.get(tagName);
5
+ if (existing)
6
+ return existing;
7
+ const constructor = texarynFormElementClass();
8
+ customElements.define(tagName, constructor);
9
+ return constructor;
10
+ }
11
+ //# sourceMappingURL=define.js.map