@sylwellsoftware/fray 0.1.0-alpha.1

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 (94) hide show
  1. package/EXPERIMENTAL.md +75 -0
  2. package/LICENSE +55 -0
  3. package/NOTICE +2 -0
  4. package/README.md +521 -0
  5. package/dist/Components/Placeholder.d.ts +14 -0
  6. package/dist/Components/Placeholder.d.ts.map +1 -0
  7. package/dist/Components/component.d.ts +187 -0
  8. package/dist/Components/component.d.ts.map +1 -0
  9. package/dist/Components/controlUtils.d.ts +20 -0
  10. package/dist/Components/controlUtils.d.ts.map +1 -0
  11. package/dist/Components/data/descriptionList.d.ts +21 -0
  12. package/dist/Components/data/descriptionList.d.ts.map +1 -0
  13. package/dist/Components/data/listview/listview.d.ts +39 -0
  14. package/dist/Components/data/listview/listview.d.ts.map +1 -0
  15. package/dist/Components/data/selectionhandler.d.ts +68 -0
  16. package/dist/Components/data/selectionhandler.d.ts.map +1 -0
  17. package/dist/Components/data/table/DataTable.d.ts +72 -0
  18. package/dist/Components/data/table/DataTable.d.ts.map +1 -0
  19. package/dist/Components/data/table/FilterPanel.d.ts +35 -0
  20. package/dist/Components/data/table/FilterPanel.d.ts.map +1 -0
  21. package/dist/Components/data/table/TableHeader.d.ts +21 -0
  22. package/dist/Components/data/table/TableHeader.d.ts.map +1 -0
  23. package/dist/Components/data/table/TableHeaderCell.d.ts +39 -0
  24. package/dist/Components/data/table/TableHeaderCell.d.ts.map +1 -0
  25. package/dist/Components/data/table/tableQuery.d.ts +25 -0
  26. package/dist/Components/data/table/tableQuery.d.ts.map +1 -0
  27. package/dist/Components/data/treeview/treeitem.d.ts +20 -0
  28. package/dist/Components/data/treeview/treeitem.d.ts.map +1 -0
  29. package/dist/Components/data/treeview/treeview.d.ts +42 -0
  30. package/dist/Components/data/treeview/treeview.d.ts.map +1 -0
  31. package/dist/Components/dialog/dialog.d.ts +37 -0
  32. package/dist/Components/dialog/dialog.d.ts.map +1 -0
  33. package/dist/Components/layout/panel.d.ts +20 -0
  34. package/dist/Components/layout/panel.d.ts.map +1 -0
  35. package/dist/Components/layout/sidebar.d.ts +18 -0
  36. package/dist/Components/layout/sidebar.d.ts.map +1 -0
  37. package/dist/Components/layout/splitView.d.ts +18 -0
  38. package/dist/Components/layout/splitView.d.ts.map +1 -0
  39. package/dist/Components/layout/tabpanel/tab.d.ts +12 -0
  40. package/dist/Components/layout/tabpanel/tab.d.ts.map +1 -0
  41. package/dist/Components/layout/tabpanel/tabline.d.ts +32 -0
  42. package/dist/Components/layout/tabpanel/tabline.d.ts.map +1 -0
  43. package/dist/Components/layout/tabpanel/tabpanel.d.ts +34 -0
  44. package/dist/Components/layout/tabpanel/tabpanel.d.ts.map +1 -0
  45. package/dist/Components/lineinputs/checkbox/Checkbox.d.ts +35 -0
  46. package/dist/Components/lineinputs/checkbox/Checkbox.d.ts.map +1 -0
  47. package/dist/Components/lineinputs/checkbox/QuadCheckbox.d.ts +12 -0
  48. package/dist/Components/lineinputs/checkbox/QuadCheckbox.d.ts.map +1 -0
  49. package/dist/Components/lineinputs/checkbox/TriCheckbox.d.ts +12 -0
  50. package/dist/Components/lineinputs/checkbox/TriCheckbox.d.ts.map +1 -0
  51. package/dist/Components/lineinputs/dropdown.d.ts +37 -0
  52. package/dist/Components/lineinputs/dropdown.d.ts.map +1 -0
  53. package/dist/Components/lineinputs/textbox.d.ts +36 -0
  54. package/dist/Components/lineinputs/textbox.d.ts.map +1 -0
  55. package/dist/Components/lineinputs/toggle.d.ts +30 -0
  56. package/dist/Components/lineinputs/toggle.d.ts.map +1 -0
  57. package/dist/Components/menu/button.d.ts +24 -0
  58. package/dist/Components/menu/button.d.ts.map +1 -0
  59. package/dist/Components/menu/toolbar.d.ts +15 -0
  60. package/dist/Components/menu/toolbar.d.ts.map +1 -0
  61. package/dist/Components/status/progressBar.d.ts +21 -0
  62. package/dist/Components/status/progressBar.d.ts.map +1 -0
  63. package/dist/button-BRDkmR1C.js +203 -0
  64. package/dist/button-BRDkmR1C.js.map +1 -0
  65. package/dist/experimental.d.ts +16 -0
  66. package/dist/experimental.d.ts.map +1 -0
  67. package/dist/experimental.js +1361 -0
  68. package/dist/experimental.js.map +1 -0
  69. package/dist/index.d.ts +23 -0
  70. package/dist/index.d.ts.map +1 -0
  71. package/dist/index.js +1014 -0
  72. package/dist/index.js.map +1 -0
  73. package/dist/jsx-dev-runtime-CarwHDyL.js +1155 -0
  74. package/dist/jsx-dev-runtime-CarwHDyL.js.map +1 -0
  75. package/dist/jsx-dev-runtime.d.ts +2 -0
  76. package/dist/jsx-dev-runtime.d.ts.map +1 -0
  77. package/dist/jsx-dev-runtime.js +6 -0
  78. package/dist/jsx-dev-runtime.js.map +1 -0
  79. package/dist/jsx-runtime.d.ts +26 -0
  80. package/dist/jsx-runtime.d.ts.map +1 -0
  81. package/dist/jsx-runtime.js +9 -0
  82. package/dist/jsx-runtime.js.map +1 -0
  83. package/dist/runtime.d.ts +29 -0
  84. package/dist/runtime.d.ts.map +1 -0
  85. package/dist/styling/baseStyleDefinitions.d.ts +154 -0
  86. package/dist/styling/baseStyleDefinitions.d.ts.map +1 -0
  87. package/dist/styling/styleRegistry.d.ts +19 -0
  88. package/dist/styling/styleRegistry.d.ts.map +1 -0
  89. package/dist/util/filterMode.d.ts +13 -0
  90. package/dist/util/filterMode.d.ts.map +1 -0
  91. package/package.json +83 -0
  92. package/themes/README.md +30 -0
  93. package/themes/dark.css +39 -0
  94. package/themes/light.css +39 -0
@@ -0,0 +1,75 @@
1
+ # Fray experimental data APIs
2
+
3
+ Everything imported from `@sylwellsoftware/fray/experimental` is outside Fray's stable
4
+ alpha compatibility surface. It may change in any `0.x` release without a
5
+ deprecation window. The stable package root does not export these symbols.
6
+
7
+ `TreeView` is a controlled, single-select ARIA tree. Stable node keys reconcile
8
+ selection and expansion across data replacement. Arrow keys navigate and
9
+ expand/collapse, Home/End jump, Enter/Space select, and printable keys perform
10
+ type-ahead. `TreeItem` supplies an optional declarative node form. The initial
11
+ contract does not include virtualization, multi-selection, editing, or drag
12
+ reordering.
13
+
14
+ `Dialog` wraps the native modal element with a controlled boolean emitter,
15
+ label/description relationships, cancel handling, initial focus, focus
16
+ restoration, and deterministic cleanup. Applications provide actions and own
17
+ all async work; the dialog does not infer promise or confirmation policy.
18
+
19
+ ## Current behavior
20
+
21
+ `ListView` and `DataTable` use stable item/row keys and expose their selected
22
+ items through writable emitters. Single selection replaces the prior item.
23
+ Multi-selection supports Control/Command toggles, Shift ranges, primary-button
24
+ drag ranges, arrow/Home/End focus movement, and Space/Enter selection. A data
25
+ refresh reconciles selected keys to the new row objects.
26
+
27
+ `DataTable` requires an explicit `mode`:
28
+
29
+ - `local` accepts an array or emitter, and performs sorting/filtering in the
30
+ browser;
31
+ - `remote` accepts a query emitter/handler or REST configuration, and sends
32
+ sort/filter arguments through the documented table serializer.
33
+
34
+ Filter state lives in the table's `filtersEmitter`, so opening a panel,
35
+ changing a filter, rerendering, and refreshing data do not reset it. Remote
36
+ tables distinguish these states:
37
+
38
+ - initial/loading with no rows: status plus placeholder rows;
39
+ - loading with retained rows: busy status plus the partial/previous rows;
40
+ - ready with no rows: the configured empty message;
41
+ - error with retained rows: an alert plus those rows;
42
+ - error with no rows: an alert without a misleading empty message;
43
+ - retryable query: a native Retry button that calls `query.retry()`.
44
+
45
+ Pagination is not built in. A remote query may implement pagination arguments,
46
+ but Fray does not currently supply pagination controls or a page model.
47
+
48
+ ## Measured alpha boundary
49
+
50
+ The alpha regression boundary is **1,000 rows with four to six simple columns
51
+ on a modern desktop browser**. Larger datasets, expensive custom cell
52
+ renderers, and mobile devices are not covered; paginate or filter them before
53
+ rendering.
54
+
55
+ The browser fixture measures a 1,000-row/four-column local table using stable
56
+ keys. It times initial DOM creation, a full data refresh, numeric sorting, a
57
+ filter that retains 500 rows, and one selection update. On the 2026-09-01 local
58
+ arm64 macOS verification host with Playwright 1.62.1, the results were:
59
+
60
+ | Engine | Initial | Rerender | Sort | Filter | Selection |
61
+ | --- | ---: | ---: | ---: | ---: | ---: |
62
+ | Chromium | 19.0 ms | 9.3 ms | 9.2 ms | 6.0 ms | 20.9 ms |
63
+ | Firefox | 62.0 ms | 16.0 ms | 14.0 ms | 11.0 ms | 32.0 ms |
64
+ | WebKit | 18.0 ms | 12.0 ms | 22.0 ms | 6.0 ms | 4.0 ms |
65
+
66
+ These are synchronous headless-browser regression measurements, not a promise
67
+ of end-to-end frame or device performance. The automated budget allows two
68
+ seconds for initial creation and one second for each subsequent operation to
69
+ remain robust on slower verification hosts while still catching a material
70
+ regression.
71
+
72
+ Virtualization is deliberately deferred: the measured boundary does not
73
+ justify its lifecycle, focus, and accessibility complexity. Revisit it only
74
+ with a demonstrated consumer above 1,000 rows and browser measurements showing
75
+ that server-side pagination/filtering is insufficient.
package/LICENSE ADDED
@@ -0,0 +1,55 @@
1
+ Apache License
2
+
3
+ Version 2.0, January 2004
4
+
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
16
+
17
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
18
+
19
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
20
+
21
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
22
+
23
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
24
+
25
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
26
+
27
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
28
+
29
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
30
+
31
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
32
+
33
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
34
+
35
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
36
+
37
+ You must give any other recipients of the Work or Derivative Works a copy of this License; and
38
+
39
+ You must cause any modified files to carry prominent notices stating that You changed the files; and
40
+
41
+ You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
42
+
43
+ If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
44
+
45
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
46
+
47
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
48
+
49
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
50
+
51
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
52
+
53
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
54
+
55
+ END OF TERMS AND CONDITIONS
package/NOTICE ADDED
@@ -0,0 +1,2 @@
1
+ Fray
2
+ Copyright 2026 Sylwell Software
package/README.md ADDED
@@ -0,0 +1,521 @@
1
+ # Fray
2
+
3
+ Fray is an experimental, browser-only component and DOM runtime built around
4
+ Glue emitters. It targets modern evergreen browsers. Its `0.x` API may change
5
+ with documented migration notes.
6
+
7
+ After publication, install Fray together with its Glue peer:
8
+
9
+ ```bash
10
+ pnpm add @sylwellsoftware/glue @sylwellsoftware/fray
11
+ ```
12
+
13
+ Fray is ESM-only and targets the current and previous major versions of
14
+ Chromium, Firefox, and Safari at candidate time. Its reproducible test matrix
15
+ uses Playwright's pinned Chromium, Firefox, and WebKit builds. Repository
16
+ tooling requires Node 22+ and pnpm 10; Fray's runtime itself is browser-only.
17
+
18
+ ## Set up a browser application
19
+
20
+ Fray ships ESM, TypeScript declarations, automatic/classic JSX runtimes, and
21
+ two supported CSS theme subpaths. Glue is a peer dependency.
22
+
23
+ ```ts
24
+ import {Emitter} from '@sylwellsoftware/glue'
25
+ import {
26
+ Button,
27
+ Component,
28
+ Panel,
29
+ Sidebar,
30
+ Textbox,
31
+ Toolbar,
32
+ createFrayRuntime,
33
+ h,
34
+ } from '@sylwellsoftware/fray'
35
+ import '@sylwellsoftware/fray/themes/light.css'
36
+
37
+ const name = new Emitter('Ada')
38
+
39
+ class App extends Component {
40
+ static dependencies = [Button, Panel, Textbox, Toolbar]
41
+
42
+ render() {
43
+ return h(Panel, {header: 'Profile'},
44
+ h(Textbox, {label: 'Name', valueEmitter: name}),
45
+ h(Toolbar, {label: 'Profile actions'},
46
+ h(Button, {label: 'Save', onClick: () => save(name.get())})))
47
+ }
48
+ }
49
+
50
+ const runtime = createFrayRuntime()
51
+ runtime.registerStyles(App).injectStyles(document)
52
+ runtime.mount(runtime.create(App), document.querySelector('#app')!)
53
+
54
+ function save(value: string) {
55
+ console.log(value)
56
+ }
57
+ ```
58
+
59
+ Register the root component's dependencies before injecting styles. Injection
60
+ is idempotent within a runtime, so another application root may register
61
+ additional component styles and inject again safely.
62
+
63
+ For automatic JSX, configure TypeScript with `"jsx": "react-jsx"` and
64
+ `"jsxImportSource": "@sylwellsoftware/fray"`. Classic JSX uses `h` as `jsxFactory` and
65
+ `Fragment` as `jsxFragmentFactory`. JSX and `h()` produce the same vnodes.
66
+
67
+ The same root can be written with automatic JSX:
68
+
69
+ ```tsx
70
+ class App extends Component {
71
+ render() {
72
+ return <Panel header="Profile">
73
+ <Textbox label="Name" valueEmitter={name} />
74
+ <Button label="Save" onClick={() => save(name.get())} />
75
+ </Panel>
76
+ }
77
+
78
+ static dependencies = [Button, Panel, Textbox]
79
+ }
80
+ ```
81
+
82
+ ## Component host elements
83
+
84
+ Fray components with a wrapper render a standards-valid custom host element,
85
+ not a framework identity class. The default application runtime therefore
86
+ produces DOM such as:
87
+
88
+ ```html
89
+ <fray-panel data-fray-component="panel">
90
+ <fray-textbox data-fray-component="textbox">
91
+ <input type="text">
92
+ </fray-textbox>
93
+ <button data-fray-component="button">Save</button>
94
+ </fray-panel>
95
+ ```
96
+
97
+ Native semantics remain native: `Button` renders `button`, `Toggle` renders
98
+ `fieldset`, `Sidebar` renders `aside`, and table header components render
99
+ `thead`/`th`. `Tab` is a declarative child consumed by `TabPanel` and has no
100
+ independent root. The
101
+ `data-fray-component` attribute keeps diagnostics unambiguous without taking
102
+ ownership of the consumer's `class`/`className`.
103
+
104
+ Element naming is an immutable application-runtime setting:
105
+
106
+ ```ts
107
+ const defaultNames = createFrayRuntime()
108
+ // <fray-panel>, <fray-list-view>, ...
109
+
110
+ const productNames = createFrayRuntime({
111
+ elementNames: {prefix: 'acme'},
112
+ })
113
+ // <acme-panel>, <acme-list-view>, ...
114
+
115
+ const prefixlessNames = createFrayRuntime({
116
+ elementNames: {prefix: null},
117
+ })
118
+ // <layout-panel>, <list-view>, <text-box>, ...
119
+
120
+ const selectedOverrides = createFrayRuntime({
121
+ elementNames: {
122
+ prefix: null,
123
+ overrides: {'panel': 'change-panel'},
124
+ },
125
+ })
126
+ // <change-panel>, with standalone names for the other components
127
+ ```
128
+
129
+ HTML custom-element names must contain a hyphen, so prefixless mode uses each
130
+ component's standards-valid standalone name rather than invalid names such as
131
+ `<panel>` or `<listview>`. Prefixes and overrides must be lowercase kebab-case;
132
+ an exact override must itself be a non-reserved custom-element name.
133
+
134
+ Each runtime owns its element-name mapping and structural-style registry.
135
+ Create the runtime once at application startup, then create and mount the root
136
+ through that runtime. Nested components inherit it automatically. A separate
137
+ compiled Fray build is unnecessary. Two runtimes with different mappings can
138
+ coexist in one document without their component-host selectors colliding.
139
+ Styles still live in the document's global cascade because these hosts are
140
+ deliberately unregistered light-DOM elements, not Web Components or Shadow DOM
141
+ boundaries.
142
+
143
+ ## Reactive templates
144
+
145
+ TypeScript TSX is Fray's supported template syntax. Classic JSX and direct
146
+ `h()` calls are equivalent frontends: both lower to the same vnode tree and
147
+ use the same renderer. A future template-file syntax can target this vnode
148
+ contract without changing Glue binding semantics.
149
+
150
+ Fray's own stable and experimental built-ins are authored in TSX. Direct
151
+ `h()` remains supported for consumers that do not use JSX and as the renderer's
152
+ canonical vnode operation, but it is not the built-in component authoring
153
+ format. The workspace lint gate rejects new `h()` templates under
154
+ `packages/fray/src/Components`.
155
+
156
+ Configured custom hosts are also available inside a TSX component through its
157
+ protected `Host` template component:
158
+
159
+ ```tsx
160
+ interface BadgeProps extends ComponentProps {
161
+ tone?: 'neutral' | 'positive'
162
+ }
163
+
164
+ class Badge extends Component<BadgeProps> {
165
+ render() {
166
+ const Host = this.Host
167
+ return <Host data-tone={this.props.tone ?? 'neutral'}>
168
+ {this.props.children}
169
+ </Host>
170
+ }
171
+
172
+ static override hostName = 'badge'
173
+ static override standaloneHostName = 'ui-badge'
174
+ }
175
+ ```
176
+
177
+ At runtime that template produces `<fray-badge>` by default,
178
+ `<acme-badge>` under an `acme` prefix, or `<ui-badge>` in prefixless mode.
179
+ Native-root components such as `Button` use their native tag directly in TSX
180
+ instead of `Host`.
181
+
182
+ Glue values have explicit behavior at each template boundary:
183
+
184
+ | Template form | Meaning |
185
+ | --- | --- |
186
+ | `{emitter}` | Render the current value and patch only that child range on emission. |
187
+ | `<Child source={emitter} />` | Pass the emitter object unchanged; the child owns how it consumes it. |
188
+ | `prop={live(emitter)}` | Subscribe a scalar DOM or component prop one way to the emitter's current value. |
189
+ | `<input bind:value={emitter} />` | Bind a writable string emitter and native `value` two ways. |
190
+ | `<input bind:checked={emitter} />` | Bind a writable boolean emitter and native `checked` two ways. |
191
+ | `this.read(emitter)` | Read during `render()` and rerender the component while that dependency is used. |
192
+ | `this.snapshot(emitter)` | Track and read `{value, fetchState, error}` for stateful rendering. |
193
+
194
+ Direct child and `live()` subscriptions are renderer-owned and are released
195
+ when their nodes disappear. Render-time `read()`/`snapshot()` dependencies are
196
+ reconciled after every render, so conditional dependencies are also released.
197
+ The component still owns and disposes emitters it creates. Direct rendering
198
+ uses only an emitter's value; use `snapshot()` when loading and error state
199
+ must affect the markup.
200
+
201
+ This complete example uses mutable and derived emitters, direct emitter
202
+ children, raw emitter props, native two-way bindings, a one-way live property,
203
+ conditional tracked state, and a `LiveQuery` passed to a child:
204
+
205
+ ```tsx
206
+ import {
207
+ DerivedEmitter,
208
+ Emitter,
209
+ FetchState,
210
+ LiveQuery,
211
+ QueryHandler,
212
+ } from '@sylwellsoftware/glue'
213
+ import type {ReadableEmitter} from '@sylwellsoftware/glue'
214
+ import {
215
+ Button,
216
+ Component,
217
+ Panel,
218
+ Textbox,
219
+ createFrayRuntime,
220
+ live,
221
+ } from '@sylwellsoftware/fray'
222
+ import type {ComponentProps, WritableEmitter} from '@sylwellsoftware/fray'
223
+
224
+ interface Change {
225
+ id: number
226
+ title: string
227
+ }
228
+
229
+ const fixtures: readonly Change[] = [
230
+ {id: 101, title: 'Add release attestations'},
231
+ {id: 102, title: 'Migrate the demo to TypeScript'},
232
+ ]
233
+
234
+ class ChangeQueryHandler extends QueryHandler<{filter: string}, readonly Change[]> {
235
+ override fetch({filter}: {filter: string}): readonly Change[] {
236
+ const needle = filter.trim().toLocaleLowerCase()
237
+ return needle === ''
238
+ ? fixtures
239
+ : fixtures.filter(({title}) =>
240
+ title.toLocaleLowerCase().includes(needle))
241
+ }
242
+ }
243
+
244
+ interface PreviewProps extends ComponentProps {
245
+ heading: ReadableEmitter<string, unknown>
246
+ approved: WritableEmitter<boolean>
247
+ }
248
+
249
+ class Preview extends Component<PreviewProps> {
250
+ render() {
251
+ return <section aria-label="Live change preview">
252
+ <h3>{this.props.heading}</h3>
253
+ <label>
254
+ <input type="checkbox" bind:checked={this.props.approved} />
255
+ Approved
256
+ </label>
257
+ </section>
258
+ }
259
+ }
260
+
261
+ interface ResultsProps extends ComponentProps {
262
+ results: ReadableEmitter<readonly Change[] | undefined, unknown>
263
+ }
264
+
265
+ class Results extends Component<ResultsProps> {
266
+ render() {
267
+ const {value, fetchState, error} = this.snapshot(this.props.results)
268
+ if (fetchState === FetchState.Error) {
269
+ return <p role="alert">{String(error)}</p>
270
+ }
271
+ return <ul aria-busy={fetchState === FetchState.Loading}>
272
+ {(value ?? []).map(({id, title}) => <li key={id}>{title}</li>)}
273
+ </ul>
274
+ }
275
+ }
276
+
277
+ class ChangeApp extends Component {
278
+ readonly title = new Emitter('Add native Glue template bindings')
279
+ readonly approved = new Emitter(false)
280
+ readonly filter = new Emitter('')
281
+ readonly showPreview = new Emitter(true)
282
+ readonly heading = new DerivedEmitter(
283
+ [this.title, this.approved] as const,
284
+ ([title, approved]) => `${title} — ${approved ? 'approved' : 'draft'}`,
285
+ )
286
+ readonly results = new LiveQuery({
287
+ handler: new ChangeQueryHandler(),
288
+ args: {filter: this.filter},
289
+ })
290
+
291
+ render() {
292
+ return <Panel header={this.heading}>
293
+ <Textbox label="Title" valueEmitter={this.title} />
294
+ <label>Search <input bind:value={this.filter} /></label>
295
+
296
+ <output title={live(this.heading)}>Current title: {this.title}</output>
297
+
298
+ <label>
299
+ <input type="checkbox" bind:checked={this.showPreview} />
300
+ Show preview
301
+ </label>
302
+ {this.read(this.showPreview)
303
+ ? <Preview heading={this.heading} approved={this.approved} />
304
+ : null}
305
+
306
+ <Results results={this.results} />
307
+ <Button
308
+ label="Refresh results"
309
+ onClick={() => void this.results.refresh()}
310
+ />
311
+ </Panel>
312
+ }
313
+
314
+ onDestroy(): void {
315
+ this.results.dispose()
316
+ this.heading.dispose()
317
+ this.showPreview.dispose()
318
+ this.filter.dispose()
319
+ this.approved.dispose()
320
+ this.title.dispose()
321
+ }
322
+
323
+ static dependencies = [Button, Panel, Preview, Results, Textbox]
324
+ }
325
+
326
+ const runtime = createFrayRuntime({elementNames: {prefix: 'acme'}})
327
+ runtime.registerStyles(ChangeApp).injectStyles(document)
328
+ runtime.mount(runtime.create(ChangeApp), document.querySelector('#app')!)
329
+ ```
330
+
331
+ Emitter props are raw by default on purpose: automatically unwrapping every
332
+ prop would make it impossible for controls such as `Textbox` and application
333
+ components such as `Preview` to receive a stable emitter. Use `live()` only
334
+ when the receiver expects a scalar prop and one-way updates are desired.
335
+
336
+ ## State convention
337
+
338
+ Every stateful control follows one ownership rule:
339
+
340
+ - pass a writable `valueEmitter` to share and externally update state;
341
+ - otherwise pass `defaultValue` to initialize the control's owned emitter;
342
+ - read the active emitter from the component instance's `valueEmitter`
343
+ property;
344
+ - use `onInput` or `onChange` to observe user actions. The callback runs after
345
+ the emitter changes and does not replace the emitter contract.
346
+
347
+ `value` remains an initial-value alias for imported `0.x` call-site
348
+ compatibility; it is not a prop-driven controlled mode. Prefer `valueEmitter`
349
+ or `defaultValue` in new code.
350
+
351
+ ## Stable component reference
352
+
353
+ All components also accept `children`, `className` (`class` is an alias), and a
354
+ sibling-local `key` through the common component props.
355
+
356
+ | Component | Important props | User callback | State/emitter behavior |
357
+ | --- | --- | --- | --- |
358
+ | `Button` | `label`, `type`, `disabled`, `pressed`, `busy`, `busyLabel`, `ariaLabel`, native `id`/`name`/`value`/`title` | `onClick(event)` | Stateless native button; busy state disables activation and is presentation only. |
359
+ | `Toolbar` | `label`, `orientation`, `id`, `children` | None | Stateless named toolbar; orientation is horizontal or vertical. |
360
+ | `Textbox` | `label` or `ariaLabel`, value props, `disabled`, `required`, `readOnly`, `error`, native text constraints, `inputRef` | `onInput(value, event)`, `onChange(value, event)` | String `valueEmitter`; external emitter changes patch the native input without replacing it. |
361
+ | `Dropdown<T>` | `options`, `label` or `ariaLabel`, value props, `disabled`, `required`, `error`, `placeholder`, `name` | `onChange(value, event)` | Typed string/number `valueEmitter`; `options` may be an array or readable emitter. |
362
+ | `Toggle<T>` | `options`, `label` or `ariaLabel`, value props, `disabled`, `required` | `onChange(value, event)` | One selected value; arrow keys, Home, and End move and select within the radio group. |
363
+ | `Checkbox<T>` | `symbols`, `label`, value props, `disabled`, `required`, `name` | `onChange(value, event)` | Two-state semantic value by default; click/Space advances and arrow keys move in either direction. |
364
+ | `TriCheckbox` | Checkbox props except `symbols` | `onChange(value, event)` | Cycles deny → neutral → prefer using `FilterMode`. |
365
+ | `QuadCheckbox` | Checkbox props except `symbols` | `onChange(value, event)` | Cycles deny → neutral → prefer → require using `FilterMode`. |
366
+ | `Panel` | `header`, `toolbar`, `orientation`, `disabled`, `id`, `children` | None | Stateless labelled section when a header exists; `disabled` describes the region but does not mutate descendant controls. |
367
+ | `Sidebar` | `header`, `toolbar`, `ariaLabel`, `id`, `children` | None | Native complementary region with fixed header/toolbar parts and independently scrolling content. |
368
+ | `SplitView` | `primary`, `secondary`, `direction`, `primarySize`, pane labels | None | Stateless, non-resizable two-pane layout with explicit overflow ownership. |
369
+ | `DescriptionList` / `DescriptionItem` | list `label`; item `term`, `value` or children | None | Native `dl`/`dt`/`dd` record summary with responsive term/value wrapping. |
370
+ | `ProgressBar` | `label`, `value` or `valueEmitter`, `max`, `valueText` | None | Labelled native progress; a null value is indeterminate. |
371
+ | `Tab` | `id`, `label`, `disabled`, `children` | None | Declarative content marker consumed by `TabPanel`; not rendered as a tab by itself. |
372
+ | `TabLine` | `tabs`, `label`, `baseId`, value props | `onChange(id, event)` | Active-tab `valueEmitter`; arrow keys skip disabled tabs, with Home/End support. |
373
+ | `TabPanel` | `tabs` or `Tab` children, `label`, `id`, value props | `onChange(id, event)` | Owns or consumes the active-tab emitter and wires the selected tab to its tabpanel. |
374
+
375
+ Invalid option arrays, duplicate tab IDs, unsupported orientations, malformed
376
+ emitters, and non-function callbacks fail with descriptive errors.
377
+
378
+ ## Component examples
379
+
380
+ ### Actions and toolbar
381
+
382
+ ```ts
383
+ h(Toolbar, {label: 'Editor actions'},
384
+ h(Button, {label: 'Save', onClick: save}),
385
+ h(Button, {label: 'Delete', disabled: true}))
386
+ ```
387
+
388
+ ### Textbox
389
+
390
+ ```ts
391
+ const query = new Emitter('')
392
+
393
+ h(Textbox, {
394
+ label: 'Search',
395
+ valueEmitter: query,
396
+ required: true,
397
+ error: query.get() === '' ? 'Enter a search term' : null,
398
+ onInput: (value) => console.log('search changed', value),
399
+ })
400
+ ```
401
+
402
+ ### Dropdown
403
+
404
+ ```ts
405
+ const role = new Emitter<'author' | 'reviewer'>('author')
406
+
407
+ h(Dropdown, {
408
+ label: 'Role',
409
+ valueEmitter: role,
410
+ options: [
411
+ {value: 'author', label: 'Author'},
412
+ {value: 'reviewer', label: 'Reviewer'},
413
+ ],
414
+ onChange: (value) => console.log(value),
415
+ })
416
+ ```
417
+
418
+ ### Toggle
419
+
420
+ ```ts
421
+ h(Toggle, {
422
+ label: 'View',
423
+ defaultValue: 'list',
424
+ options: [['list', 'List'], ['grid', 'Grid']],
425
+ onChange: (value) => console.log(value),
426
+ })
427
+ ```
428
+
429
+ ### Checkbox variants
430
+
431
+ ```ts
432
+ h(Checkbox, {label: 'Include archived'})
433
+ h(TriCheckbox, {label: 'Match policy', defaultValue: FilterMode.Neutral})
434
+ h(QuadCheckbox, {label: 'Required tags', defaultValue: FilterMode.Require})
435
+ ```
436
+
437
+ `FilterMode` values are `Deny`, `Neutral`, `Prefer`, and `Require`. The basic
438
+ checkbox uses neutral/prefer, while the variants expose the additional states.
439
+
440
+ ### Panel
441
+
442
+ ```ts
443
+ h(Panel, {
444
+ header: 'Account',
445
+ orientation: 'vertical',
446
+ toolbar: h(Toolbar, {label: 'Account actions'},
447
+ h(Button, {label: 'Edit'})),
448
+ }, h('p', null, 'Account details'))
449
+ ```
450
+
451
+ ### Sidebar
452
+
453
+ ```ts
454
+ h(Sidebar, {
455
+ id: 'project-navigation',
456
+ header: 'Projects',
457
+ toolbar: h(Toolbar, {label: 'Project filters'},
458
+ h(Textbox, {label: 'Search projects'})),
459
+ }, h('ul', null, h('li', null, 'Release automation')))
460
+ ```
461
+
462
+ The surrounding grid or flex layout must bound the Sidebar's height. Its
463
+ header and toolbar remain fixed while the dedicated content part owns vertical
464
+ scrolling and is keyboard-focusable. Supply `ariaLabel` when there is no visible
465
+ `header`.
466
+
467
+ ### Declarative tabs
468
+
469
+ ```ts
470
+ h(TabPanel, {id: 'profile', label: 'Profile sections'},
471
+ h(Tab, {id: 'summary', label: 'Summary'}, 'Summary content'),
472
+ h(Tab, {id: 'details', label: 'Details'}, 'Details content'))
473
+ ```
474
+
475
+ ### Standalone tab line
476
+
477
+ ```ts
478
+ h(TabLine, {
479
+ baseId: 'settings',
480
+ label: 'Settings sections',
481
+ defaultValue: 'general',
482
+ tabs: [
483
+ {id: 'general', label: 'General'},
484
+ {id: 'advanced', label: 'Advanced'},
485
+ ],
486
+ onChange: (id) => console.log('active tab', id),
487
+ })
488
+ ```
489
+
490
+ Use `TabPanel` when Fray should render content and ARIA relationships. Use a
491
+ standalone `TabLine` only when the consumer owns the corresponding tabpanel
492
+ content and IDs.
493
+
494
+ ## Styling and accessibility
495
+
496
+ Structural styles use semantic custom properties and leave colors to the
497
+ supported light/dark bundles. See [`themes/README.md`](themes/README.md) for the
498
+ public variable contract and consumer overrides.
499
+
500
+ Stable examples are tested with axe in Chromium, Firefox, and WebKit and have
501
+ no serious or critical automated violations. Browser tests also cover keyboard
502
+ operation, labelled roles, reduced motion, 200% configured text sizing, and
503
+ forced-colors focus visibility. A formal manual screen-reader pass is still a
504
+ release-candidate requirement; automated checks are not a substitute for it.
505
+
506
+ ## Experimental data components
507
+
508
+ `ListView`, `DataTable`, `TreeView`, `TreeItem`, `Dialog`, filters, selection
509
+ handlers, and `Placeholder` are available only from
510
+ `@sylwellsoftware/fray/experimental`. They are outside the stable alpha
511
+ compatibility surface and may change without a migration bridge. Their state
512
+ model, keyboard behavior, measured data boundary, and current limitations are
513
+ documented in [EXPERIMENTAL.md](EXPERIMENTAL.md).
514
+
515
+ Fray is not a replacement for an SSR/hydration framework, Web Components,
516
+ React/Vue adapters, a broad design system, a virtualized production data grid,
517
+ legacy-browser support, or a stable `1.0` API. See the [workspace
518
+ overview](../../README.md), [alpha API surface](../../docs/API_SURFACE.md),
519
+ [architecture overview](../../docs/architecture.md),
520
+ [changelog](../../CHANGELOG.md), [contribution guide](../../CONTRIBUTING.md),
521
+ and [security policy](../../SECURITY.md).
@@ -0,0 +1,14 @@
1
+ import { Component } from './component.js';
2
+ import type { ComponentProps } from './component.js';
3
+ export interface PlaceholderProps extends ComponentProps {
4
+ width?: number | string;
5
+ }
6
+ /** Deterministic loading placeholder for experimental data components. */
7
+ export declare class Placeholder extends Component<PlaceholderProps> {
8
+ render(): import("@sylwellsoftware/fray/jsx-runtime").JSX.Element;
9
+ static hostName: string;
10
+ static standaloneHostName: string;
11
+ static baseStyles: (string | string[])[][];
12
+ static css: string;
13
+ }
14
+ //# sourceMappingURL=Placeholder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Placeholder.d.ts","sourceRoot":"","sources":["../../src/Components/Placeholder.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAM,MAAM,gBAAgB,CAAA;AAC7C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAA;AAElD,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACpD,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAC1B;AAED,0EAA0E;AAC1E,qBAAa,WAAY,SAAQ,SAAS,CAAC,gBAAgB,CAAC;IACxD,MAAM;IAMN,OAAgB,QAAQ,SAAgB;IACxC,OAAgB,kBAAkB,SAAwB;IAE1D,MAAM,CAAC,UAAU,0BAEhB;IAED,MAAM,CAAC,GAAG,SAgBT;CACJ"}