@grafctory/clay-widgets 0.0.0-stage → 0.4.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 (185) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +46 -2
  3. package/dist/content/empty.css +107 -0
  4. package/dist/content/empty.d.ts +40 -0
  5. package/dist/content/empty.d.ts.map +1 -0
  6. package/dist/content/empty.js +42 -0
  7. package/dist/content/empty.js.map +1 -0
  8. package/dist/content/heading.css +34 -0
  9. package/dist/content/heading.d.ts +45 -0
  10. package/dist/content/heading.d.ts.map +1 -0
  11. package/dist/content/heading.js +49 -0
  12. package/dist/content/heading.js.map +1 -0
  13. package/dist/content/image.css +176 -0
  14. package/dist/content/image.d.ts +71 -0
  15. package/dist/content/image.d.ts.map +1 -0
  16. package/dist/content/image.js +63 -0
  17. package/dist/content/image.js.map +1 -0
  18. package/dist/content/infobox.css +186 -0
  19. package/dist/content/infobox.d.ts +72 -0
  20. package/dist/content/infobox.d.ts.map +1 -0
  21. package/dist/content/infobox.js +63 -0
  22. package/dist/content/infobox.js.map +1 -0
  23. package/dist/content/pill.css +76 -0
  24. package/dist/content/pill.d.ts +57 -0
  25. package/dist/content/pill.d.ts.map +1 -0
  26. package/dist/content/pill.js +48 -0
  27. package/dist/content/pill.js.map +1 -0
  28. package/dist/content/text.css +44 -0
  29. package/dist/content/text.d.ts +30 -0
  30. package/dist/content/text.d.ts.map +1 -0
  31. package/dist/content/text.js +42 -0
  32. package/dist/content/text.js.map +1 -0
  33. package/dist/controls/button.css +469 -0
  34. package/dist/controls/button.d.ts +116 -0
  35. package/dist/controls/button.d.ts.map +1 -0
  36. package/dist/controls/button.js +61 -0
  37. package/dist/controls/button.js.map +1 -0
  38. package/dist/controls/checkbox.css +23 -0
  39. package/dist/controls/checkbox.d.ts +54 -0
  40. package/dist/controls/checkbox.d.ts.map +1 -0
  41. package/dist/controls/checkbox.js +49 -0
  42. package/dist/controls/checkbox.js.map +1 -0
  43. package/dist/controls/choice.css +288 -0
  44. package/dist/controls/choice.d.ts +63 -0
  45. package/dist/controls/choice.d.ts.map +1 -0
  46. package/dist/controls/choice.js +52 -0
  47. package/dist/controls/choice.js.map +1 -0
  48. package/dist/controls/fieldset.css +37 -0
  49. package/dist/controls/fieldset.d.ts +49 -0
  50. package/dist/controls/fieldset.d.ts.map +1 -0
  51. package/dist/controls/fieldset.js +51 -0
  52. package/dist/controls/fieldset.js.map +1 -0
  53. package/dist/controls/form.css +50 -0
  54. package/dist/controls/form.d.ts +64 -0
  55. package/dist/controls/form.d.ts.map +1 -0
  56. package/dist/controls/form.js +62 -0
  57. package/dist/controls/form.js.map +1 -0
  58. package/dist/controls/input.css +57 -0
  59. package/dist/controls/input.d.ts +120 -0
  60. package/dist/controls/input.d.ts.map +1 -0
  61. package/dist/controls/input.js +78 -0
  62. package/dist/controls/input.js.map +1 -0
  63. package/dist/controls/label.css +73 -0
  64. package/dist/controls/label.d.ts +76 -0
  65. package/dist/controls/label.d.ts.map +1 -0
  66. package/dist/controls/label.js +73 -0
  67. package/dist/controls/label.js.map +1 -0
  68. package/dist/controls/radio.css +23 -0
  69. package/dist/controls/radio.d.ts +60 -0
  70. package/dist/controls/radio.d.ts.map +1 -0
  71. package/dist/controls/radio.js +50 -0
  72. package/dist/controls/radio.js.map +1 -0
  73. package/dist/controls/select.css +37 -0
  74. package/dist/controls/select.d.ts +62 -0
  75. package/dist/controls/select.d.ts.map +1 -0
  76. package/dist/controls/select.js +59 -0
  77. package/dist/controls/select.js.map +1 -0
  78. package/dist/controls/switch.css +154 -0
  79. package/dist/controls/switch.d.ts +44 -0
  80. package/dist/controls/switch.d.ts.map +1 -0
  81. package/dist/controls/switch.js +48 -0
  82. package/dist/controls/switch.js.map +1 -0
  83. package/dist/controls/textarea.css +50 -0
  84. package/dist/controls/textarea.d.ts +97 -0
  85. package/dist/controls/textarea.d.ts.map +1 -0
  86. package/dist/controls/textarea.js +75 -0
  87. package/dist/controls/textarea.js.map +1 -0
  88. package/dist/glyphs/icon.core.d.ts +52 -0
  89. package/dist/glyphs/icon.core.d.ts.map +1 -0
  90. package/dist/glyphs/icon.core.js +67 -0
  91. package/dist/glyphs/icon.core.js.map +1 -0
  92. package/dist/glyphs/icon.css +32 -0
  93. package/dist/glyphs/icon.d.ts +152 -0
  94. package/dist/glyphs/icon.d.ts.map +1 -0
  95. package/dist/glyphs/icon.js +167 -0
  96. package/dist/glyphs/icon.js.map +1 -0
  97. package/dist/glyphs/icon.md +76 -0
  98. package/dist/glyphs/logo.css +73 -0
  99. package/dist/glyphs/logo.d.ts +27 -0
  100. package/dist/glyphs/logo.d.ts.map +1 -0
  101. package/dist/glyphs/logo.js +49 -0
  102. package/dist/glyphs/logo.js.map +1 -0
  103. package/dist/index.d.ts +65 -0
  104. package/dist/index.d.ts.map +1 -0
  105. package/dist/index.js +95 -0
  106. package/dist/index.js.map +1 -0
  107. package/dist/layouts/card.css +166 -0
  108. package/dist/layouts/card.d.ts +69 -0
  109. package/dist/layouts/card.d.ts.map +1 -0
  110. package/dist/layouts/card.js +57 -0
  111. package/dist/layouts/card.js.map +1 -0
  112. package/dist/layouts/stack.css +58 -0
  113. package/dist/layouts/stack.d.ts +64 -0
  114. package/dist/layouts/stack.d.ts.map +1 -0
  115. package/dist/layouts/stack.js +69 -0
  116. package/dist/layouts/stack.js.map +1 -0
  117. package/dist/layouts/strip.css +58 -0
  118. package/dist/layouts/strip.d.ts +72 -0
  119. package/dist/layouts/strip.d.ts.map +1 -0
  120. package/dist/layouts/strip.js +73 -0
  121. package/dist/layouts/strip.js.map +1 -0
  122. package/dist/layouts/tabs.core.d.ts +73 -0
  123. package/dist/layouts/tabs.core.d.ts.map +1 -0
  124. package/dist/layouts/tabs.core.js +65 -0
  125. package/dist/layouts/tabs.core.js.map +1 -0
  126. package/dist/layouts/tabs.css +260 -0
  127. package/dist/layouts/tabs.d.ts +57 -0
  128. package/dist/layouts/tabs.d.ts.map +1 -0
  129. package/dist/layouts/tabs.js +128 -0
  130. package/dist/layouts/tabs.js.map +1 -0
  131. package/dist/layouts/tree.css +138 -0
  132. package/dist/layouts/tree.d.ts +46 -0
  133. package/dist/layouts/tree.d.ts.map +1 -0
  134. package/dist/layouts/tree.js +69 -0
  135. package/dist/layouts/tree.js.map +1 -0
  136. package/dist/navigation/link.css +229 -0
  137. package/dist/navigation/link.d.ts +89 -0
  138. package/dist/navigation/link.d.ts.map +1 -0
  139. package/dist/navigation/link.js +91 -0
  140. package/dist/navigation/link.js.map +1 -0
  141. package/dist/navigation/path.css +122 -0
  142. package/dist/navigation/path.d.ts +42 -0
  143. package/dist/navigation/path.d.ts.map +1 -0
  144. package/dist/navigation/path.js +49 -0
  145. package/dist/navigation/path.js.map +1 -0
  146. package/dist/navigation/toc.core.d.ts +111 -0
  147. package/dist/navigation/toc.core.d.ts.map +1 -0
  148. package/dist/navigation/toc.core.js +60 -0
  149. package/dist/navigation/toc.core.js.map +1 -0
  150. package/dist/navigation/toc.css +53 -0
  151. package/dist/navigation/toc.d.ts +112 -0
  152. package/dist/navigation/toc.d.ts.map +1 -0
  153. package/dist/navigation/toc.js +321 -0
  154. package/dist/navigation/toc.js.map +1 -0
  155. package/dist/scopes/guard.css +26 -0
  156. package/dist/scopes/guard.d.ts +37 -0
  157. package/dist/scopes/guard.d.ts.map +1 -0
  158. package/dist/scopes/guard.js +60 -0
  159. package/dist/scopes/guard.js.map +1 -0
  160. package/dist/scopes/style.css +26 -0
  161. package/dist/scopes/style.d.ts +68 -0
  162. package/dist/scopes/style.d.ts.map +1 -0
  163. package/dist/scopes/style.js +108 -0
  164. package/dist/scopes/style.js.map +1 -0
  165. package/dist/shells/tool.css +778 -0
  166. package/dist/shells/tool.d.ts +164 -0
  167. package/dist/shells/tool.d.ts.map +1 -0
  168. package/dist/shells/tool.js +251 -0
  169. package/dist/shells/tool.js.map +1 -0
  170. package/dist/signals/more.css +42 -0
  171. package/dist/signals/more.d.ts +28 -0
  172. package/dist/signals/more.d.ts.map +1 -0
  173. package/dist/signals/more.js +61 -0
  174. package/dist/signals/more.js.map +1 -0
  175. package/dist/signals/note.css +221 -0
  176. package/dist/signals/note.d.ts +83 -0
  177. package/dist/signals/note.d.ts.map +1 -0
  178. package/dist/signals/note.js +72 -0
  179. package/dist/signals/note.js.map +1 -0
  180. package/dist/signals/toasts.css +463 -0
  181. package/dist/signals/toasts.d.ts +68 -0
  182. package/dist/signals/toasts.d.ts.map +1 -0
  183. package/dist/signals/toasts.js +160 -0
  184. package/dist/signals/toasts.js.map +1 -0
  185. package/package.json +331 -4
@@ -0,0 +1,164 @@
1
+ import { type ComponentChildren } from "preact";
2
+ import "./tool.css";
3
+ /**
4
+ * Creates a tool shell.
5
+ *
6
+ * Lays a screen out as two columns, the side column beside the main one, each with a head, a body and a foot. The
7
+ * heads of the two columns share one row, so they always match in height, and the feet do the same. A column with
8
+ * nothing for its foot shows none, its body running down to the bottom of the frame. The body of each column scrolls
9
+ * on its own, while its head and foot stay in view, so what they hold is always within reach. Content made sticky in a
10
+ * body pins flush against the head or foot of its column, leaving no strip of scrolled content showing between them,
11
+ * while the body keeps its gutter around everything else, so only what is meant to stand pinned meets the bars.
12
+ *
13
+ * Heads and feet lay what they hold out as a single row of flex items, centred vertically and never wrapping, so each
14
+ * bar keeps the height of a single line. An item keeps its own width unless it states flex properties of its own, as
15
+ * one growing to fill the bar does, and an item too wide for the bar shrinks, ending its clipped text with an ellipsis.
16
+ *
17
+ * The shell fills the height its host gives it and sets none of its own. Without a definite height, the bodies grow
18
+ * with their content instead of scrolling, and the heads and feet scroll out of view with the page.
19
+ *
20
+ * The main column grows up to a width limit, past which both columns stand centred in the frame. The limit, the width
21
+ * of the side column, the gutters, and the font sizes of heads and feet are tuned through custom properties named
22
+ * after what they tune, such as `--clay-tool-side-width` or `--clay-tool-head-gutter`. Each retunes the shell it is
23
+ * set on, or every shell inside the element it is set on, leaving the other properties of the shell to their defaults.
24
+ *
25
+ * Waiting is stated by the app through `busy`, as when it has to let its state settle before the reader acts again:
26
+ * the frame marks itself busy for assistive technology and ignores pointer and keyboard input aimed inside it, while
27
+ * the focus stays where it stands and the content stays readable. After a short delay, the frame is also veiled, shows
28
+ * a turning glyph at the end of the main head in place of the menu, and announces waiting to screen readers.
29
+ *
30
+ * The main column is named after `head` and takes the focus as the {@link @grafctory/clay!router.Router router} lands a
31
+ * screen, without adding a tab stop, so a reader hears which screen they are on rather than a control of the last one.
32
+ * The main body then opens at its top, or on the element a link targets, set below the head at the gutter of the
33
+ * body, as it stands before any scrolling. The side body keeps its place, so a reader never loses their position in it.
34
+ * A screen replacing its content without a landing, as a catalogue does on a change of filters, states it through the
35
+ * `gist`, and the main body opens at its top again, so the reader never lands halfway down a list they have not read.
36
+ * Under the Clay router, going back or forward through the browser history returns the main body to where the reader
37
+ * left it. The router finds the body again by the fixed ids of the shell boxes, so a page shows a single shell at a
38
+ * time, since a second shell on the same page would repeat those ids and leave the router unable to tell them apart.
39
+ *
40
+ * On a viewport too narrow for two columns, the main column takes the whole frame and the side column becomes a drawer
41
+ * opened from a menu button leading the main head. The drawer covers the main column, across the whole width of a
42
+ * phone and as wide as the side column on a tablet, while the main column stays in place underneath and keeps its
43
+ * state. A close button leads the head of the drawer, and focus moves to it as the drawer opens. Escape, a click
44
+ * outside the drawer, or a link followed inside it closes the drawer and returns focus to the menu button.
45
+ *
46
+ * On such a viewport the heading of the screen also moves from the main head to the top of the main body, and scrolls
47
+ * away with the content it names, while the mark moves from the side head to stand next to the menu button. The main
48
+ * head keeps only the menu button, the mark and the menu, leaving the room to content. Both heads stand close to the
49
+ * top of the window, with the same narrow spacing above and below them, whatever head gutter the shell is tuned to.
50
+ *
51
+ * While the side column is locked on such a viewport, the menu button is left out and the mark leads the main head.
52
+ * The heading of the screen keeps its place in the main head, as on a wider viewport, so the actions it holds, such
53
+ * as unsafe ones, stay apart from those in the menu rather than scrolling away with the content.
54
+ *
55
+ * @param options The widget configuration
56
+ *
57
+ * @returns The tool shell
58
+ */
59
+ export declare function Tool({ wide, busy, locked, tucked, gist, mark, meta, tray, more, head, menu, copy, foot, children }: {
60
+ /**
61
+ * Whether the shell spans the whole frame rather than standing centred within its width limit. The main column then
62
+ * takes all the room the side column leaves. Set it for content that never has too much room, such as a table, a
63
+ * chart or a map, and leave it off for prose, which long lines make hard to read. Capped and centred if omitted.
64
+ */
65
+ wide?: boolean;
66
+ /**
67
+ * Whether the app is waiting on work the reader has to let settle, such as the exchanges a change of filters
68
+ * starts. While it is set, the shell ignores input aimed inside it, and content rendered outside it, such as a
69
+ * dialog, answers as usual. The focus never moves, so a field keeps its editing state, though its caret is hidden
70
+ * until the shell is idle again. Waiting shows and clears after a short delay, so a brief stretch shows nothing and
71
+ * close stretches show as one. Idle if omitted, so the shell answers input as usual.
72
+ */
73
+ busy?: boolean;
74
+ /**
75
+ * Whether the side column stays in view but takes no input, as while the main column needs the full attention of
76
+ * the reader. What it holds fades while the column keeps its place, and drops out of the tab order and the
77
+ * accessibility tree until it is unlocked. A control inside it loses the focus as it is locked. On a narrow
78
+ * viewport locking closes the drawer and leaves the menu button out, so the drawer stays shut. The `mark` in the
79
+ * main head fades and takes no input, as in the side column. The `head` keeps its place in the main head, so the
80
+ * actions it holds, such as unsafe ones, stay apart from those in the `menu`. Usable if omitted.
81
+ */
82
+ locked?: boolean;
83
+ /**
84
+ * Whether the side column is tucked away, left out of the frame rather than locked, until the app brings it back.
85
+ * The main column takes the room the side column held, and nothing passed to `mark`, `meta`, `tray` or `more` is
86
+ * shown. Set it for screens seen through rather than moved around in, such as a sign-in or a splash. Shown if
87
+ * omitted, so every screen leaving it off keeps the standing controls of the app within reach of the reader.
88
+ */
89
+ tucked?: boolean;
90
+ /**
91
+ * What the main body shows, as the app tells one content from another, such as the criteria a catalogue draws its
92
+ * results from rather than the results themselves. A change of gist brings the main body back to its top, as a
93
+ * landing does, while the side body keeps its place. Gists are compared by content, so a gist rebuilt with equal
94
+ * values moves nothing, and neither does loading more results under the same criteria. A gist must be plain data
95
+ * free of cycles: objects and arrays are compared member by member, and any other value by identity. The gist the
96
+ * shell is first shown with moves nothing, as the screen has just landed, but a gist set later where none stood
97
+ * counts as a change. Without a gist, the main body keeps its place until the router lands another screen.
98
+ */
99
+ gist?: unknown;
100
+ /**
101
+ * The identity of the app, such as its logo and name linking to its home, in the head of the side column. On a
102
+ * viewport too narrow for two columns it moves to the main head instead, so the app stays named while the drawer is
103
+ * closed. There it stands next to the menu button, or leads the head while the side column is locked, fading and
104
+ * taking no input as it would in the side column, so it never offers a way out of a locked screen.
105
+ */
106
+ mark?: ComponentChildren;
107
+ /**
108
+ * The details of the app, such as its release or the environment it runs in, at the end of the head of the side
109
+ * column. It keeps its full width and is never clipped, while the other items of the head give way to it. It stays
110
+ * within the height of a single line, so a button shown or removed in it never changes the height of the head.
111
+ */
112
+ meta?: ComponentChildren;
113
+ /**
114
+ * The standing controls of the app, such as its sections and the filters in force, in the body of the side column.
115
+ * They stand in a column filling the body, so each can grow, shrink or align through its own flex properties. Their
116
+ * margins add up rather than collapsing, so controls spaced by margins stand further apart than in the plain flow
117
+ * of a page; controls wrapped in a single element keep their usual spacing.
118
+ */
119
+ tray?: ComponentChildren;
120
+ /**
121
+ * The secondary controls of the app, such as settings, help and signing out, in the foot of the side column.
122
+ */
123
+ more?: ComponentChildren;
124
+ /**
125
+ * The heading of the screen, such as its title, in the head of the main column. Its items stand in a row filling
126
+ * the head up to the `menu` within a single line, so showing or removing a button never changes the height of the
127
+ * head. On a viewport too narrow for two columns it opens the main body instead, scrolling away with the content
128
+ * rather than standing over it, so the narrow screen gives its whole height to the content once the reader starts
129
+ * scrolling. While the side column is locked it keeps its place in the main head whatever the viewport.
130
+ */
131
+ head?: ComponentChildren;
132
+ /**
133
+ * The menu of the screen, such as its actions, at the end of the head of the main column. It keeps its full width
134
+ * and is never clipped, while the other items of the head give way to it. While the shell shows waiting, a turning
135
+ * glyph stands in its place, and the head keeps its height and layout until waiting ends.
136
+ */
137
+ menu?: ComponentChildren;
138
+ /**
139
+ * The closing notice of the content, such as a copyright, at the end of the body of the main column. It scrolls
140
+ * with the content rather than standing in view like the `foot`, and rests at the bottom of a body the content is
141
+ * too short to fill. It takes the font size and block gutter of the feet, set through the same custom properties.
142
+ */
143
+ copy?: ComponentChildren;
144
+ /**
145
+ * The standing notes of the screen, such as a status line or the terms, in the foot of the main column.
146
+ */
147
+ foot?: ComponentChildren;
148
+ /**
149
+ * The content of the moment, scrolling in the body of the main column. It is laid out in the plain flow of a page,
150
+ * so floated images wrap text and the margins of adjacent blocks collapse. Content that has to fill the room the
151
+ * body leaves, such as a map or an empty state centred on the screen, passes a lone element stating
152
+ * `block-size: 100%`, which fills the body less its inset and the `copy`; one that may grow taller states
153
+ * `min-block-size: 100%` instead, pushing the `copy` further down once it grows taller than the body, as a lone
154
+ * {@link form!Form Form} told to grow does, so a single long text fills the body and still runs on past it.
155
+ */
156
+ children?: ComponentChildren;
157
+ }): import("preact").VNode<{
158
+ wide: boolean;
159
+ waiting: boolean;
160
+ locked: boolean;
161
+ tucked: boolean;
162
+ "aria-busy": boolean;
163
+ }>;
164
+ //# sourceMappingURL=tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../src/shells/tool.tsx"],"names":[],"mappings":"AA6BA,OAAO,EAAE,KAAK,iBAAiB,EAA8D,MAAM,QAAQ,CAAC;AAG5G,OAAO,YAAY,CAAC;AAmCpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,wBAAgB,IAAI,CAAC,EAEpB,IAAY,EACZ,IAAY,EAEZ,MAAc,EACd,MAAc,EAEd,IAAI,EAEJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EAEJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EAEJ,QAAQ,EAER,EAAE;IAEF;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IAGd;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAEhB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAGhB;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IAGd;;;;;OAKG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAA;IAExB;;;;OAIG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAA;IAExB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAA;IAExB;;OAEG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAA;IAGxB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAA;IAExB;;;;OAIG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAA;IAExB;;;;OAIG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAA;IAExB;;OAEG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAA;IAGxB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAE5B;;;;;;GA2MA"}
@@ -0,0 +1,251 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
2
+ /*
3
+ * Copyright © 2026 Metreeca srl
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Tool shell.
19
+ *
20
+ * Lays out the screens of an app or a tool in the familiar app shell arrangement: a side column of standing controls
21
+ * beside a main column holding the content of the moment. A screen fills the slots, and the shell arranges them.
22
+ *
23
+ * @module tool
24
+ */
25
+ import { useModel } from "@grafctory/clay/model";
26
+ import { createState } from "@grafctory/core/state";
27
+ import { equals } from "@grafctory/core/values";
28
+ import { skin } from "@grafctory/skin";
29
+ import { createElement } from "preact";
30
+ import { useEffect } from "preact/hooks";
31
+ import { Icon } from "../glyphs/icon.js";
32
+ import "./tool.css";
33
+ /**
34
+ * The prefix of the ids of the shell boxes. It stays the same each time a screen mounts, so the router finds the main
35
+ * body again on a history traversal and returns it to the position the reader left it at.
36
+ */
37
+ const Id = "clay-tool";
38
+ /**
39
+ * The delay a change of `busy` waits out before the frame shows it (ms).
40
+ */
41
+ const BusyDelay = 300;
42
+ /**
43
+ * The handlers a busy shell takes on. They cancel every gesture that would act on a control inside the shell, from
44
+ * typing and editing to dragging and pressing, and leave the focus where it stands and the content open to a reader.
45
+ */
46
+ const Ignored = Object.fromEntries([
47
+ "onKeyDownCapture",
48
+ "onBeforeInputCapture",
49
+ "onPasteCapture",
50
+ "onCutCapture",
51
+ "onDropCapture",
52
+ "onDragStartCapture",
53
+ "onMouseDownCapture",
54
+ "onClickCapture",
55
+ "onAuxClickCapture",
56
+ "onDblClickCapture",
57
+ "onContextMenuCapture"
58
+ ].map(handler => [handler, ignore]));
59
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
60
+ /**
61
+ * Creates a tool shell.
62
+ *
63
+ * Lays a screen out as two columns, the side column beside the main one, each with a head, a body and a foot. The
64
+ * heads of the two columns share one row, so they always match in height, and the feet do the same. A column with
65
+ * nothing for its foot shows none, its body running down to the bottom of the frame. The body of each column scrolls
66
+ * on its own, while its head and foot stay in view, so what they hold is always within reach. Content made sticky in a
67
+ * body pins flush against the head or foot of its column, leaving no strip of scrolled content showing between them,
68
+ * while the body keeps its gutter around everything else, so only what is meant to stand pinned meets the bars.
69
+ *
70
+ * Heads and feet lay what they hold out as a single row of flex items, centred vertically and never wrapping, so each
71
+ * bar keeps the height of a single line. An item keeps its own width unless it states flex properties of its own, as
72
+ * one growing to fill the bar does, and an item too wide for the bar shrinks, ending its clipped text with an ellipsis.
73
+ *
74
+ * The shell fills the height its host gives it and sets none of its own. Without a definite height, the bodies grow
75
+ * with their content instead of scrolling, and the heads and feet scroll out of view with the page.
76
+ *
77
+ * The main column grows up to a width limit, past which both columns stand centred in the frame. The limit, the width
78
+ * of the side column, the gutters, and the font sizes of heads and feet are tuned through custom properties named
79
+ * after what they tune, such as `--clay-tool-side-width` or `--clay-tool-head-gutter`. Each retunes the shell it is
80
+ * set on, or every shell inside the element it is set on, leaving the other properties of the shell to their defaults.
81
+ *
82
+ * Waiting is stated by the app through `busy`, as when it has to let its state settle before the reader acts again:
83
+ * the frame marks itself busy for assistive technology and ignores pointer and keyboard input aimed inside it, while
84
+ * the focus stays where it stands and the content stays readable. After a short delay, the frame is also veiled, shows
85
+ * a turning glyph at the end of the main head in place of the menu, and announces waiting to screen readers.
86
+ *
87
+ * The main column is named after `head` and takes the focus as the {@link @grafctory/clay!router.Router router} lands a
88
+ * screen, without adding a tab stop, so a reader hears which screen they are on rather than a control of the last one.
89
+ * The main body then opens at its top, or on the element a link targets, set below the head at the gutter of the
90
+ * body, as it stands before any scrolling. The side body keeps its place, so a reader never loses their position in it.
91
+ * A screen replacing its content without a landing, as a catalogue does on a change of filters, states it through the
92
+ * `gist`, and the main body opens at its top again, so the reader never lands halfway down a list they have not read.
93
+ * Under the Clay router, going back or forward through the browser history returns the main body to where the reader
94
+ * left it. The router finds the body again by the fixed ids of the shell boxes, so a page shows a single shell at a
95
+ * time, since a second shell on the same page would repeat those ids and leave the router unable to tell them apart.
96
+ *
97
+ * On a viewport too narrow for two columns, the main column takes the whole frame and the side column becomes a drawer
98
+ * opened from a menu button leading the main head. The drawer covers the main column, across the whole width of a
99
+ * phone and as wide as the side column on a tablet, while the main column stays in place underneath and keeps its
100
+ * state. A close button leads the head of the drawer, and focus moves to it as the drawer opens. Escape, a click
101
+ * outside the drawer, or a link followed inside it closes the drawer and returns focus to the menu button.
102
+ *
103
+ * On such a viewport the heading of the screen also moves from the main head to the top of the main body, and scrolls
104
+ * away with the content it names, while the mark moves from the side head to stand next to the menu button. The main
105
+ * head keeps only the menu button, the mark and the menu, leaving the room to content. Both heads stand close to the
106
+ * top of the window, with the same narrow spacing above and below them, whatever head gutter the shell is tuned to.
107
+ *
108
+ * While the side column is locked on such a viewport, the menu button is left out and the mark leads the main head.
109
+ * The heading of the screen keeps its place in the main head, as on a wider viewport, so the actions it holds, such
110
+ * as unsafe ones, stay apart from those in the menu rather than scrolling away with the content.
111
+ *
112
+ * @param options The widget configuration
113
+ *
114
+ * @returns The tool shell
115
+ */
116
+ export function Tool({ wide = false, busy = false, locked = false, tucked = false, gist, mark, meta, tray, more, head, menu, copy, foot, children }) {
117
+ const side = `${Id}-side`;
118
+ // the landmark is named by the head on show, so the reference stands or falls with its target and never dangles
119
+ const title = head ? `${Id}-title` : undefined;
120
+ const body = `${Id}-body`;
121
+ const { waiting, settle } = useModel(() => createState({
122
+ waiting: false,
123
+ settle(waiting) {
124
+ return { waiting };
125
+ }
126
+ }));
127
+ // only what waiting shows follows `busy` after the delay, while input is ignored as soon as it is set
128
+ useEffect(() => {
129
+ const timer = setTimeout(() => settle(busy), BusyDelay);
130
+ return () => clearTimeout(timer);
131
+ }, [busy]);
132
+ // a locked side column drops the control holding the focus, as browsers do on their own as it turns inert, so the
133
+ // focus leaves it at once and alike everywhere rather than whenever the browser gets round to it
134
+ useEffect(() => {
135
+ if (locked) {
136
+ release(document.getElementById(side));
137
+ }
138
+ }, [locked]);
139
+ const { changes, track } = useModel(() => createState({
140
+ gist,
141
+ changes: 0,
142
+ track(gist) {
143
+ return equals(gist, this.gist) ? {} : { gist, changes: this.changes + 1 };
144
+ }
145
+ }));
146
+ // a gist built anew on every render reaches the model each time, which counts only a change of content
147
+ useEffect(() => {
148
+ if (track(gist).changes > changes) {
149
+ document.getElementById(body)?.scrollTo(0, 0);
150
+ }
151
+ }, [gist]);
152
+ const { open, toggle } = useModel(() => createState({
153
+ open: false,
154
+ toggle(open) {
155
+ return { open };
156
+ }
157
+ }));
158
+ const { split, sync } = useModel(() => createState({
159
+ split: medium(),
160
+ sync() {
161
+ return { split: medium() };
162
+ }
163
+ }));
164
+ // the head stays in the main head where two columns fit or the side column is locked
165
+ const headed = split || locked;
166
+ // the switch lives in the cascade, which notifies no change, so the shell reads it again as the window is resized;
167
+ // a resize observer would raise loop notices as the layout switch reshapes the root it watches, and a transition
168
+ // starts from the state the render read, so the listener is renewed with every crossing it reports
169
+ useEffect(() => {
170
+ window.addEventListener("resize", sync);
171
+ return () => window.removeEventListener("resize", sync);
172
+ }, [sync]);
173
+ // input is ignored rather than the columns turned inert, as an inert column drops the focus: a field switching
174
+ // between reading and editing as it loses and takes the focus would flicker across every stretch of waiting;
175
+ // the handlers sit on the frame, so they see only input aimed inside it, the drawer included
176
+ return createElement("clay-tool", {
177
+ "aria-busy": busy,
178
+ ...(busy ? Ignored : undefined),
179
+ wide,
180
+ waiting,
181
+ locked,
182
+ tucked
183
+ }, _jsxs(_Fragment, { children: [!tucked && _jsxs("aside", { id: side, "aria-label": "Menu", popover: locked ? "manual" : "auto", inert: locked, onClick: follow, onToggle: event => {
184
+ reveal(event);
185
+ toggle(opened(event));
186
+ }, children: [_jsxs("header", { children: [split ? mark :
187
+ _jsx("button", { type: "button", popovertarget: side, popovertargetaction: "hide", "aria-label": "Close menu", children: _jsx(Icon.Close, {}) }), meta && _jsx("div", { class: "meta", children: meta })] }), _jsx("div", { tabIndex: 0, children: _jsx("div", { children: tray }) }), more && _jsx("footer", { children: more })] }), _jsxs("main", { id: `${Id}-main`, "aria-labelledby": title, tabIndex: -1, inert: open, children: [_jsxs("header", { children: [!tucked && !locked && _jsx("button", { type: "button", popovertarget: side, "aria-label": "Open menu", children: _jsx(Icon.Menu, {}) }), !tucked && !split && mark && _jsx("div", { class: "mark", inert: locked, children: mark }), headed && head && _jsx("div", { id: title, children: head }), menu && _jsx("div", { class: "menu", children: menu }), waiting && _jsx("span", { class: "busy", inert: true, children: _jsx(Icon.Busy, {}) })] }), _jsxs("div", { id: body, tabIndex: 0, children: [!headed && head && _jsx("header", { id: title, children: head }), _jsx("div", { children: children }), copy && _jsx("footer", { children: copy })] }), foot && _jsx("footer", { children: foot })] }), _jsx("span", { role: "status", "data-offscreen": true, children: waiting ? "Busy" : "" })] }));
188
+ }
189
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
190
+ /**
191
+ * Tells whether the viewport fits two columns, reading the switch the design system turns on from the medium width up,
192
+ * so the shell follows the threshold wherever the design system sets it and whatever an app forces it to.
193
+ *
194
+ * @returns `true` if the medium viewport switch is on
195
+ */
196
+ function medium() {
197
+ return getComputedStyle(document.documentElement).getPropertyValue(skin.viewportMedium).trim() === "on";
198
+ }
199
+ /**
200
+ * Tells whether a toggle of the side column left it open.
201
+ *
202
+ * @param event The toggle the side column went through
203
+ *
204
+ * @returns `true` if the side column is now open as a drawer
205
+ */
206
+ function opened(event) {
207
+ return "newState" in event && event.newState === "open";
208
+ }
209
+ /**
210
+ * Moves the focus to the close button as the drawer opens, so a keyboard lands inside what now covers the main column;
211
+ * `autofocus` would take it there too, but browsers flag it on every page loaded from an address with a fragment.
212
+ *
213
+ * @param event The toggle the side column went through
214
+ */
215
+ function reveal(event) {
216
+ if (opened(event)) {
217
+ event.currentTarget.querySelector(":scope > header > button")?.focus();
218
+ }
219
+ }
220
+ /**
221
+ * Takes the focus off the control holding it inside a column.
222
+ *
223
+ * @param column The column whose control is to lose the focus
224
+ */
225
+ function release(column) {
226
+ const control = document.activeElement;
227
+ if (control instanceof HTMLElement && column?.contains(control)) {
228
+ control.blur();
229
+ }
230
+ }
231
+ /**
232
+ * Cancels a gesture aimed inside a busy shell, stopping its default action and the handlers of the control it targets.
233
+ *
234
+ * @param event The gesture to cancel
235
+ */
236
+ function ignore(event) {
237
+ event.preventDefault();
238
+ event.stopPropagation();
239
+ }
240
+ /**
241
+ * Closes the drawer once a link inside it is followed, so the reader lands on the destination rather than on the
242
+ * drawer still covering it; a click landing anywhere else in the drawer leaves it open.
243
+ *
244
+ * @param event The click inside the side column
245
+ */
246
+ function follow(event) {
247
+ if (event.target instanceof Element && event.target.closest("a[href]")) {
248
+ event.currentTarget.togglePopover(false);
249
+ }
250
+ }
251
+ //# sourceMappingURL=tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.js","sourceRoot":"","sources":["../../src/shells/tool.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAA0B,aAAa,EAA+C,MAAM,QAAQ,CAAC;AAC5G,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,YAAY,CAAC;AAGpB;;;GAGG;AACH,MAAM,EAAE,GAAG,WAAW,CAAC;AAEvB;;GAEG;AACH,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB;;;GAGG;AACH,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC;IAClC,kBAAkB;IAClB,sBAAsB;IACtB,gBAAgB;IAChB,cAAc;IACd,eAAe;IACf,oBAAoB;IACpB,oBAAoB;IACpB,gBAAgB;IAChB,mBAAmB;IACnB,mBAAmB;IACnB,sBAAsB;CACtB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;AAGrC,wHAAwH;AAExH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAG,CAAC;QACrB,KAAK,CAAC,aAAa,CAAC,aAAa,CAAc,0BAA0B,CAAC,EAAE,KAAK,EAAE,CAAC;IACrF,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,SAAS,OAAO,CAAC,MAA0B;IAE1C,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC;IAEvC,IAAK,OAAO,YAAY,WAAW,IAAI,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAG,CAAC;QACnE,OAAO,CAAC,IAAI,EAAE,CAAC;IAChB,CAAC;AAEF,CAAC;AAED;;;;GAIG;AACH,SAAS,MAAM,CAAC,KAAY;IAC3B,KAAK,CAAC,cAAc,EAAE,CAAC;IACvB,KAAK,CAAC,eAAe,EAAE,CAAC;AACzB,CAAC;AAED;;;;;GAKG;AACH,SAAS,MAAM,CAAC,KAAsC;IACrD,IAAK,KAAK,CAAC,MAAM,YAAY,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAG,CAAC;QAC1E,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;AACF,CAAC"}
@@ -0,0 +1,42 @@
1
+ /*
2
+ * Copyright © 2026 Metreeca srl
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ /* A `More` trigger closes the list it grows, centring the mark saying that more is on its way. */
18
+
19
+ clay-more {
20
+
21
+ display: grid;
22
+ place-items: center;
23
+
24
+ padding: var(--skin--spacing-050);
25
+
26
+ color: var(--skin--color-disabled);
27
+
28
+ /* The mark turns at the spin period whatever motion the reader asked for, as the busy mark of a tool shell does. */
29
+
30
+ & > svg {
31
+ animation: clay-more-turn var(--skin--duration-spin) linear infinite;
32
+ }
33
+
34
+ }
35
+
36
+ @keyframes clay-more-turn {
37
+
38
+ to {
39
+ rotate: 1turn;
40
+ }
41
+
42
+ }
@@ -0,0 +1,28 @@
1
+ import { type ComponentChildren } from "preact";
2
+ import "./more.css";
3
+ /**
4
+ * Creates an incremental loading trigger.
5
+ *
6
+ * Placed after the last item a list shows, it asks for more as soon as it comes into view, and stands in the list
7
+ * meanwhile as a turning mark saying that more is on its way. A list with nothing left to fetch stops rendering it.
8
+ *
9
+ * A trigger still in view once the batch it asked for has landed asks again as soon as it is handed a new `onLoad`,
10
+ * so a batch too short to push it out of view is followed by the next one without the reader having to scroll.
11
+ *
12
+ * The mark is decorative: waiting is for the list the trigger closes to state, for instance through `aria-busy`.
13
+ *
14
+ * @param options The widget configuration
15
+ *
16
+ * @returns The trigger
17
+ */
18
+ export declare function More({ onLoad, children }: {
19
+ /**
20
+ * What the request for the next batch is handed to, each time the trigger comes into view.
21
+ */
22
+ onLoad: () => void;
23
+ /**
24
+ * The content standing in the list while the trigger waits; a turning mark if omitted.
25
+ */
26
+ children?: ComponentChildren;
27
+ }): import("preact").VNode<import("preact").ClassAttributes<HTMLElement> & import("preact").HTMLAttributes<EventTarget> & import("preact").SVGAttributes<SVGElement>>;
28
+ //# sourceMappingURL=more.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"more.d.ts","sourceRoot":"","sources":["../../src/signals/more.tsx"],"names":[],"mappings":"AA0BA,OAAO,EAAE,KAAK,iBAAiB,EAAiB,MAAM,QAAQ,CAAC;AAG/D,OAAO,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,EAEpB,MAAM,EAEN,QAAQ,EAER,EAAE;IAEF;;OAEG;IACH,MAAM,EAAE,MAAM,IAAI,CAAA;IAGlB;;OAEG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAE5B,qKAyBA"}
@@ -0,0 +1,61 @@
1
+ import { jsx as _jsx } from "preact/jsx-runtime";
2
+ /*
3
+ * Copyright © 2026 Metreeca srl
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Incremental loading trigger.
19
+ *
20
+ * Offers the trigger a growing list closes with, asking for the next batch as soon as the reader scrolls it into view,
21
+ * so a long collection is fetched as it is read rather than all at once.
22
+ *
23
+ * @module more
24
+ */
25
+ import { opt } from "@grafctory/core";
26
+ import { createElement } from "preact";
27
+ import { useEffect, useId } from "preact/hooks";
28
+ import { Icon } from "../glyphs/icon.js";
29
+ import "./more.css";
30
+ /**
31
+ * Creates an incremental loading trigger.
32
+ *
33
+ * Placed after the last item a list shows, it asks for more as soon as it comes into view, and stands in the list
34
+ * meanwhile as a turning mark saying that more is on its way. A list with nothing left to fetch stops rendering it.
35
+ *
36
+ * A trigger still in view once the batch it asked for has landed asks again as soon as it is handed a new `onLoad`,
37
+ * so a batch too short to push it out of view is followed by the next one without the reader having to scroll.
38
+ *
39
+ * The mark is decorative: waiting is for the list the trigger closes to state, for instance through `aria-busy`.
40
+ *
41
+ * @param options The widget configuration
42
+ *
43
+ * @returns The trigger
44
+ */
45
+ export function More({ onLoad, children }) {
46
+ const id = useId();
47
+ /*
48
+ * Whether the trigger is in view is known to the browser alone, so an observer is held for as long as the trigger
49
+ * is rendered. It is handed over again with each new handler, which is what lets a trigger left in view by a short
50
+ * batch ask again: a fresh observer tells of the trigger's state as soon as it starts watching.
51
+ */
52
+ useEffect(() => opt(document.getElementById(id) ?? undefined, element => {
53
+ const observer = new IntersectionObserver(entries => entries
54
+ .filter(entry => entry.isIntersecting)
55
+ .forEach(() => onLoad()));
56
+ observer.observe(element);
57
+ return () => observer.disconnect();
58
+ }), [id, onLoad]);
59
+ return createElement("clay-more", { id }, children ?? _jsx(Icon.RefreshCw, {}));
60
+ }
61
+ //# sourceMappingURL=more.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"more.js","sourceRoot":"","sources":["../../src/signals/more.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAA0B,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,IAAI,CAAC,EAEpB,MAAM,EAEN,QAAQ,EAeR;IAEA,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IAEnB;;;;OAIG;IAEH,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,IAAI,SAAS,EAAE,OAAO,CAAC,EAAE;QAEvE,MAAM,QAAQ,GAAG,IAAI,oBAAoB,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO;aAC1D,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC;aACrC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CACxB,CAAC;QAEF,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAE1B,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IAEpC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IAElB,OAAO,aAAa,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,EAAE,QAAQ,IAAI,KAAC,IAAI,CAAC,SAAS,KAAE,CAAC,CAAC;AAE1E,CAAC"}