@grafctory/clay-widgets 0.0.0-stage → 0.5.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.
- package/LICENSE +201 -0
- package/README.md +56 -2
- package/dist/content/empty.css +107 -0
- package/dist/content/empty.d.ts +40 -0
- package/dist/content/empty.d.ts.map +1 -0
- package/dist/content/empty.js +42 -0
- package/dist/content/empty.js.map +1 -0
- package/dist/content/heading.css +34 -0
- package/dist/content/heading.d.ts +45 -0
- package/dist/content/heading.d.ts.map +1 -0
- package/dist/content/heading.js +49 -0
- package/dist/content/heading.js.map +1 -0
- package/dist/content/image.css +198 -0
- package/dist/content/image.d.ts +77 -0
- package/dist/content/image.d.ts.map +1 -0
- package/dist/content/image.js +67 -0
- package/dist/content/image.js.map +1 -0
- package/dist/content/infobox.css +186 -0
- package/dist/content/infobox.d.ts +72 -0
- package/dist/content/infobox.d.ts.map +1 -0
- package/dist/content/infobox.js +63 -0
- package/dist/content/infobox.js.map +1 -0
- package/dist/content/pill.css +76 -0
- package/dist/content/pill.d.ts +57 -0
- package/dist/content/pill.d.ts.map +1 -0
- package/dist/content/pill.js +48 -0
- package/dist/content/pill.js.map +1 -0
- package/dist/content/text.css +44 -0
- package/dist/content/text.d.ts +30 -0
- package/dist/content/text.d.ts.map +1 -0
- package/dist/content/text.js +42 -0
- package/dist/content/text.js.map +1 -0
- package/dist/controls/button.css +469 -0
- package/dist/controls/button.d.ts +116 -0
- package/dist/controls/button.d.ts.map +1 -0
- package/dist/controls/button.js +61 -0
- package/dist/controls/button.js.map +1 -0
- package/dist/controls/checkbox.css +23 -0
- package/dist/controls/checkbox.d.ts +54 -0
- package/dist/controls/checkbox.d.ts.map +1 -0
- package/dist/controls/checkbox.js +49 -0
- package/dist/controls/checkbox.js.map +1 -0
- package/dist/controls/choice.css +288 -0
- package/dist/controls/choice.d.ts +63 -0
- package/dist/controls/choice.d.ts.map +1 -0
- package/dist/controls/choice.js +52 -0
- package/dist/controls/choice.js.map +1 -0
- package/dist/controls/fieldset.css +37 -0
- package/dist/controls/fieldset.d.ts +49 -0
- package/dist/controls/fieldset.d.ts.map +1 -0
- package/dist/controls/fieldset.js +51 -0
- package/dist/controls/fieldset.js.map +1 -0
- package/dist/controls/form.css +50 -0
- package/dist/controls/form.d.ts +64 -0
- package/dist/controls/form.d.ts.map +1 -0
- package/dist/controls/form.js +62 -0
- package/dist/controls/form.js.map +1 -0
- package/dist/controls/input.css +57 -0
- package/dist/controls/input.d.ts +129 -0
- package/dist/controls/input.d.ts.map +1 -0
- package/dist/controls/input.js +71 -0
- package/dist/controls/input.js.map +1 -0
- package/dist/controls/label.css +73 -0
- package/dist/controls/label.d.ts +76 -0
- package/dist/controls/label.d.ts.map +1 -0
- package/dist/controls/label.js +73 -0
- package/dist/controls/label.js.map +1 -0
- package/dist/controls/radio.css +23 -0
- package/dist/controls/radio.d.ts +60 -0
- package/dist/controls/radio.d.ts.map +1 -0
- package/dist/controls/radio.js +50 -0
- package/dist/controls/radio.js.map +1 -0
- package/dist/controls/select.css +37 -0
- package/dist/controls/select.d.ts +71 -0
- package/dist/controls/select.d.ts.map +1 -0
- package/dist/controls/select.js +59 -0
- package/dist/controls/select.js.map +1 -0
- package/dist/controls/switch.css +154 -0
- package/dist/controls/switch.d.ts +44 -0
- package/dist/controls/switch.d.ts.map +1 -0
- package/dist/controls/switch.js +48 -0
- package/dist/controls/switch.js.map +1 -0
- package/dist/controls/textarea.css +50 -0
- package/dist/controls/textarea.d.ts +106 -0
- package/dist/controls/textarea.d.ts.map +1 -0
- package/dist/controls/textarea.js +68 -0
- package/dist/controls/textarea.js.map +1 -0
- package/dist/glyphs/icon.core.d.ts +52 -0
- package/dist/glyphs/icon.core.d.ts.map +1 -0
- package/dist/glyphs/icon.core.js +67 -0
- package/dist/glyphs/icon.core.js.map +1 -0
- package/dist/glyphs/icon.css +32 -0
- package/dist/glyphs/icon.d.ts +152 -0
- package/dist/glyphs/icon.d.ts.map +1 -0
- package/dist/glyphs/icon.js +167 -0
- package/dist/glyphs/icon.js.map +1 -0
- package/dist/glyphs/icon.md +76 -0
- package/dist/glyphs/logo.css +73 -0
- package/dist/glyphs/logo.d.ts +27 -0
- package/dist/glyphs/logo.d.ts.map +1 -0
- package/dist/glyphs/logo.js +49 -0
- package/dist/glyphs/logo.js.map +1 -0
- package/dist/index.core.d.ts +18 -0
- package/dist/index.core.d.ts.map +1 -0
- package/dist/index.core.js +36 -0
- package/dist/index.core.js.map +1 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts/card.css +190 -0
- package/dist/layouts/card.d.ts +75 -0
- package/dist/layouts/card.d.ts.map +1 -0
- package/dist/layouts/card.js +62 -0
- package/dist/layouts/card.js.map +1 -0
- package/dist/layouts/stack.css +58 -0
- package/dist/layouts/stack.d.ts +64 -0
- package/dist/layouts/stack.d.ts.map +1 -0
- package/dist/layouts/stack.js +69 -0
- package/dist/layouts/stack.js.map +1 -0
- package/dist/layouts/strip.css +58 -0
- package/dist/layouts/strip.d.ts +72 -0
- package/dist/layouts/strip.d.ts.map +1 -0
- package/dist/layouts/strip.js +73 -0
- package/dist/layouts/strip.js.map +1 -0
- package/dist/layouts/tabs.core.d.ts +73 -0
- package/dist/layouts/tabs.core.d.ts.map +1 -0
- package/dist/layouts/tabs.core.js +65 -0
- package/dist/layouts/tabs.core.js.map +1 -0
- package/dist/layouts/tabs.css +260 -0
- package/dist/layouts/tabs.d.ts +57 -0
- package/dist/layouts/tabs.d.ts.map +1 -0
- package/dist/layouts/tabs.js +128 -0
- package/dist/layouts/tabs.js.map +1 -0
- package/dist/layouts/tree.css +138 -0
- package/dist/layouts/tree.d.ts +46 -0
- package/dist/layouts/tree.d.ts.map +1 -0
- package/dist/layouts/tree.js +69 -0
- package/dist/layouts/tree.js.map +1 -0
- package/dist/navigation/link.css +229 -0
- package/dist/navigation/link.d.ts +89 -0
- package/dist/navigation/link.d.ts.map +1 -0
- package/dist/navigation/link.js +91 -0
- package/dist/navigation/link.js.map +1 -0
- package/dist/navigation/path.css +122 -0
- package/dist/navigation/path.d.ts +42 -0
- package/dist/navigation/path.d.ts.map +1 -0
- package/dist/navigation/path.js +49 -0
- package/dist/navigation/path.js.map +1 -0
- package/dist/navigation/toc.core.d.ts +111 -0
- package/dist/navigation/toc.core.d.ts.map +1 -0
- package/dist/navigation/toc.core.js +60 -0
- package/dist/navigation/toc.core.js.map +1 -0
- package/dist/navigation/toc.css +53 -0
- package/dist/navigation/toc.d.ts +112 -0
- package/dist/navigation/toc.d.ts.map +1 -0
- package/dist/navigation/toc.js +321 -0
- package/dist/navigation/toc.js.map +1 -0
- package/dist/scopes/guard.css +26 -0
- package/dist/scopes/guard.d.ts +37 -0
- package/dist/scopes/guard.d.ts.map +1 -0
- package/dist/scopes/guard.js +60 -0
- package/dist/scopes/guard.js.map +1 -0
- package/dist/scopes/style.css +26 -0
- package/dist/scopes/style.d.ts +68 -0
- package/dist/scopes/style.d.ts.map +1 -0
- package/dist/scopes/style.js +108 -0
- package/dist/scopes/style.js.map +1 -0
- package/dist/shells/tool.css +770 -0
- package/dist/shells/tool.d.ts +167 -0
- package/dist/shells/tool.d.ts.map +1 -0
- package/dist/shells/tool.js +286 -0
- package/dist/shells/tool.js.map +1 -0
- package/dist/signals/more.css +42 -0
- package/dist/signals/more.d.ts +28 -0
- package/dist/signals/more.d.ts.map +1 -0
- package/dist/signals/more.js +61 -0
- package/dist/signals/more.js.map +1 -0
- package/dist/signals/note.css +221 -0
- package/dist/signals/note.d.ts +83 -0
- package/dist/signals/note.d.ts.map +1 -0
- package/dist/signals/note.js +72 -0
- package/dist/signals/note.js.map +1 -0
- package/dist/signals/toasts.css +463 -0
- package/dist/signals/toasts.d.ts +68 -0
- package/dist/signals/toasts.d.ts.map +1 -0
- package/dist/signals/toasts.js +160 -0
- package/dist/signals/toasts.js.map +1 -0
- package/package.json +331 -4
|
@@ -0,0 +1,167 @@
|
|
|
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. The content of a body
|
|
10
|
+
* keeps its width whether the body scrolls or not, so it never reflows where the platform shows a classic scrollbar.
|
|
11
|
+
* Content made sticky in a body pins flush against the head or foot of its column, with no strip of scrolled content
|
|
12
|
+
* showing between them. Everything else keeps the gutter of the body, so only pinned content meets the bars.
|
|
13
|
+
*
|
|
14
|
+
* Heads and feet lay what they hold out as a single row of flex items, centred vertically and never wrapping, so each
|
|
15
|
+
* bar keeps the height of a single line. An item keeps its own width unless it states flex properties of its own, as
|
|
16
|
+
* one growing to fill the bar does, and an item too wide for the bar shrinks, ending its clipped text with an ellipsis.
|
|
17
|
+
*
|
|
18
|
+
* The shell fills the height its host gives it and sets none of its own. Without a definite height, the bodies grow
|
|
19
|
+
* with their content instead of scrolling, and the heads and feet scroll out of view with the page.
|
|
20
|
+
*
|
|
21
|
+
* The main column grows up to a width limit, past which both columns stand centred in the frame. The limit, the width
|
|
22
|
+
* of the side column, the gutters, and the font sizes of heads and feet are tuned through custom properties named
|
|
23
|
+
* after what they tune, such as `--clay-tool-side-width` or `--clay-tool-head-gutter`. Each retunes the shell it is
|
|
24
|
+
* set on, or every shell inside the element it is set on, leaving the other properties of the shell to their defaults.
|
|
25
|
+
*
|
|
26
|
+
* Waiting is stated by the app through `busy`, as when it has to let its state settle before the reader acts again:
|
|
27
|
+
* the frame marks itself busy for assistive technology and ignores pointer and keyboard input aimed inside it, while
|
|
28
|
+
* the focus stays where it stands and the content stays readable. After a short delay, the frame is also veiled, shows
|
|
29
|
+
* a turning glyph at the end of the main head in place of the menu, and announces waiting to screen readers.
|
|
30
|
+
*
|
|
31
|
+
* The main column is named after `head` and takes the focus as the {@link @grafctory/clay!router.Router router} lands a
|
|
32
|
+
* screen, without adding a tab stop, so a reader hears which screen they are on rather than a control of the last one.
|
|
33
|
+
* The column hands that focus on to the main body, so the keys scroll the content at once, while a control inside the
|
|
34
|
+
* column keeps the focus it takes. The main body then opens at its top, or on the element a link targets, set below
|
|
35
|
+
* the head at the gutter of the body, as it stands before any scrolling. The side body keeps its place, so a reader
|
|
36
|
+
* never loses their position in it. A screen replacing its content without a landing, as a catalogue does on a change
|
|
37
|
+
* of filters, states it through the `gist`, and the main body opens at its top again, so the reader never lands halfway
|
|
38
|
+
* down a list they have not read. Under the Clay router, going back or forward in the browser history returns the main
|
|
39
|
+
* body to where the reader left it. The router finds the body again by the fixed ids of the shell boxes, so a page
|
|
40
|
+
* shows one shell at a time, since a second one would repeat those ids and leave the router unable to tell them apart.
|
|
41
|
+
*
|
|
42
|
+
* On a viewport too narrow for two columns, the main column takes the whole frame and the side column becomes a drawer
|
|
43
|
+
* opened from a menu button leading the main head. The drawer covers the main column, across the whole width of a
|
|
44
|
+
* phone and as wide as the side column on a tablet, while the main column stays in place underneath and keeps its
|
|
45
|
+
* state. A close button leads the head of the drawer, and focus moves to it as the drawer opens. Escape, a click
|
|
46
|
+
* outside the drawer, or a link followed inside it closes the drawer and returns focus to the menu button.
|
|
47
|
+
*
|
|
48
|
+
* On such a viewport the heading of the screen also moves from the main head to the top of the main body, and scrolls
|
|
49
|
+
* away with the content it names, keeping the head gutter above and below it so it stands apart from that content as
|
|
50
|
+
* it does in the main head. The mark moves from the side head to stand next to the menu button. The main head keeps
|
|
51
|
+
* only the menu button, the mark and the menu, leaving the room to content. Both heads stand close to the top of the
|
|
52
|
+
* window, with the same narrow spacing above and below them, whatever head gutter the shell is tuned to.
|
|
53
|
+
*
|
|
54
|
+
* While the side column is locked on such a viewport, the menu button is left out and the mark leads the main head.
|
|
55
|
+
* The heading of the screen keeps its place in the main head, as on a wider viewport, so the actions it holds, such
|
|
56
|
+
* as unsafe ones, stay apart from those in the menu rather than scrolling away with the content.
|
|
57
|
+
*
|
|
58
|
+
* @param options The widget configuration
|
|
59
|
+
*
|
|
60
|
+
* @returns The tool shell
|
|
61
|
+
*/
|
|
62
|
+
export declare function Tool({ wide, busy, locked, tucked, gist, mark, meta, tray, more, head, menu, copy, foot, children }: {
|
|
63
|
+
/**
|
|
64
|
+
* Whether the shell spans the whole frame rather than standing centred within its width limit. The main column then
|
|
65
|
+
* takes all the room the side column leaves. Set it for content that never has too much room, such as a table, a
|
|
66
|
+
* chart or a map, and leave it off for prose, which long lines make hard to read. Capped and centred if omitted.
|
|
67
|
+
*/
|
|
68
|
+
wide?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Whether the app is waiting on work the reader has to let settle, such as the exchanges a change of filters
|
|
71
|
+
* starts. While it is set, the shell ignores input aimed inside it, and content rendered outside it, such as a
|
|
72
|
+
* dialog, answers as usual. The focus never moves, so a field keeps its editing state, though its caret is hidden
|
|
73
|
+
* until the shell is idle again. Waiting shows and clears after a short delay, so a brief stretch shows nothing and
|
|
74
|
+
* close stretches show as one. Idle if omitted, so the shell answers input as usual.
|
|
75
|
+
*/
|
|
76
|
+
busy?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Whether the side column stays in view but takes no input, as while the main column needs the full attention of
|
|
79
|
+
* the reader. What it holds fades while the column keeps its place, and drops out of the tab order and the
|
|
80
|
+
* accessibility tree until it is unlocked. A control inside it loses the focus as it is locked. On a narrow
|
|
81
|
+
* viewport locking closes the drawer and leaves the menu button out, so the drawer stays shut. The `mark` in the
|
|
82
|
+
* main head fades and takes no input, as in the side column. The `head` keeps its place in the main head, so the
|
|
83
|
+
* actions it holds, such as unsafe ones, stay apart from those in the `menu`. Usable if omitted.
|
|
84
|
+
*/
|
|
85
|
+
locked?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Whether the side column is tucked away, left out of the frame rather than locked, until the app brings it back.
|
|
88
|
+
* The main column takes the room the side column held, and nothing passed to `mark`, `meta`, `tray` or `more` is
|
|
89
|
+
* shown. Set it for screens seen through rather than moved around in, such as a sign-in or a splash. Shown if
|
|
90
|
+
* omitted, so every screen leaving it off keeps the standing controls of the app within reach of the reader.
|
|
91
|
+
*/
|
|
92
|
+
tucked?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* What the main body shows, as the app tells one content from another, such as the criteria a catalogue draws its
|
|
95
|
+
* results from rather than the results themselves. A change of gist brings the main body back to its top, as a
|
|
96
|
+
* landing does, while the side body keeps its place. Gists are compared by content, so a gist rebuilt with equal
|
|
97
|
+
* values moves nothing, and neither does loading more results under the same criteria. A gist must be plain data
|
|
98
|
+
* free of cycles: objects and arrays are compared member by member, and any other value by identity. The gist the
|
|
99
|
+
* shell is first shown with moves nothing, as the screen has just landed, but a gist set later where none stood
|
|
100
|
+
* counts as a change. Without a gist, the main body keeps its place until the router lands another screen.
|
|
101
|
+
*/
|
|
102
|
+
gist?: unknown;
|
|
103
|
+
/**
|
|
104
|
+
* The identity of the app, such as its logo and name linking to its home, in the head of the side column. On a
|
|
105
|
+
* viewport too narrow for two columns it moves to the main head instead, so the app stays named while the drawer is
|
|
106
|
+
* closed. There it stands next to the menu button, or leads the head while the side column is locked, fading and
|
|
107
|
+
* taking no input as it would in the side column, so it never offers a way out of a locked screen.
|
|
108
|
+
*/
|
|
109
|
+
mark?: ComponentChildren;
|
|
110
|
+
/**
|
|
111
|
+
* The details of the app, such as its release or the environment it runs in, at the end of the head of the side
|
|
112
|
+
* column. It keeps its full width and is never clipped, while the other items of the head give way to it. It stays
|
|
113
|
+
* within the height of a single line, so a button shown or removed in it never changes the height of the head.
|
|
114
|
+
*/
|
|
115
|
+
meta?: ComponentChildren;
|
|
116
|
+
/**
|
|
117
|
+
* The standing controls of the app, such as its sections and the filters in force, in the body of the side column.
|
|
118
|
+
* They stand in a column filling the body, so each can grow, shrink or align through its own flex properties. Their
|
|
119
|
+
* margins add up rather than collapsing, so controls spaced by margins stand further apart than in the plain flow
|
|
120
|
+
* of a page; controls wrapped in a single element keep their usual spacing.
|
|
121
|
+
*/
|
|
122
|
+
tray?: ComponentChildren;
|
|
123
|
+
/**
|
|
124
|
+
* The secondary controls of the app, such as settings, help and signing out, in the foot of the side column.
|
|
125
|
+
*/
|
|
126
|
+
more?: ComponentChildren;
|
|
127
|
+
/**
|
|
128
|
+
* The heading of the screen, such as its title, in the head of the main column. Its items stand in a row filling
|
|
129
|
+
* the head up to the `menu` within a single line, so showing or removing a button never changes the height of the
|
|
130
|
+
* head. On a viewport too narrow for two columns it opens the main body instead, scrolling away with the content
|
|
131
|
+
* rather than standing over it, so the narrow screen gives its whole height to the content once the reader starts
|
|
132
|
+
* scrolling. While the side column is locked it keeps its place in the main head whatever the viewport.
|
|
133
|
+
*/
|
|
134
|
+
head?: ComponentChildren;
|
|
135
|
+
/**
|
|
136
|
+
* The menu of the screen, such as its actions, at the end of the head of the main column. It keeps its full width
|
|
137
|
+
* and is never clipped, while the other items of the head give way to it. While the shell shows waiting, a turning
|
|
138
|
+
* glyph stands in its place, and the head keeps its height and layout until waiting ends.
|
|
139
|
+
*/
|
|
140
|
+
menu?: ComponentChildren;
|
|
141
|
+
/**
|
|
142
|
+
* The closing notice of the content, such as a copyright, at the end of the body of the main column. It scrolls
|
|
143
|
+
* with the content rather than standing in view like the `foot`, and rests at the bottom of a body the content is
|
|
144
|
+
* too short to fill. It takes the font size and block gutter of the feet, set through the same custom properties.
|
|
145
|
+
*/
|
|
146
|
+
copy?: ComponentChildren;
|
|
147
|
+
/**
|
|
148
|
+
* The standing notes of the screen, such as a status line or the terms, in the foot of the main column.
|
|
149
|
+
*/
|
|
150
|
+
foot?: ComponentChildren;
|
|
151
|
+
/**
|
|
152
|
+
* The content of the moment, scrolling in the body of the main column. It is laid out in the plain flow of a page,
|
|
153
|
+
* so floated images wrap text and the margins of adjacent blocks collapse. Content that has to fill the room the
|
|
154
|
+
* body leaves, such as a map or an empty state centred on the screen, passes a lone element stating
|
|
155
|
+
* `block-size: 100%`, which fills the body less its inset and the `copy`; one that may grow taller states
|
|
156
|
+
* `min-block-size: 100%` instead, pushing the `copy` further down once it grows taller than the body, as a lone
|
|
157
|
+
* {@link form!Form Form} told to grow does, so a single long text fills the body and still runs on past it.
|
|
158
|
+
*/
|
|
159
|
+
children?: ComponentChildren;
|
|
160
|
+
}): import("preact").VNode<{
|
|
161
|
+
wide: boolean;
|
|
162
|
+
waiting: boolean;
|
|
163
|
+
locked: boolean;
|
|
164
|
+
tucked: boolean;
|
|
165
|
+
"aria-busy": boolean;
|
|
166
|
+
}>;
|
|
167
|
+
//# 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,EAAuF,MAAM,QAAQ,CAAC;AAGrI,OAAO,YAAY,CAAC;AAwCpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;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;;;;;;GA6MA"}
|
|
@@ -0,0 +1,286 @@
|
|
|
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 id of the main body, which takes the focus the main column passes on and scrolls back to its top on a new gist.
|
|
40
|
+
*/
|
|
41
|
+
const Body = `${Id}-body`;
|
|
42
|
+
/**
|
|
43
|
+
* The delay a change of `busy` waits out before the frame shows it (ms).
|
|
44
|
+
*/
|
|
45
|
+
const BusyDelay = 300;
|
|
46
|
+
/**
|
|
47
|
+
* The handlers a busy shell takes on. They cancel every gesture that would act on a control inside the shell, from
|
|
48
|
+
* typing and editing to dragging and pressing, and leave the focus where it stands and the content open to a reader.
|
|
49
|
+
*/
|
|
50
|
+
const Ignored = Object.fromEntries([
|
|
51
|
+
"onKeyDownCapture",
|
|
52
|
+
"onBeforeInputCapture",
|
|
53
|
+
"onPasteCapture",
|
|
54
|
+
"onCutCapture",
|
|
55
|
+
"onDropCapture",
|
|
56
|
+
"onDragStartCapture",
|
|
57
|
+
"onMouseDownCapture",
|
|
58
|
+
"onClickCapture",
|
|
59
|
+
"onAuxClickCapture",
|
|
60
|
+
"onDblClickCapture",
|
|
61
|
+
"onContextMenuCapture"
|
|
62
|
+
].map(handler => [handler, ignore]));
|
|
63
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
64
|
+
/**
|
|
65
|
+
* Creates a tool shell.
|
|
66
|
+
*
|
|
67
|
+
* Lays a screen out as two columns, the side column beside the main one, each with a head, a body and a foot. The
|
|
68
|
+
* heads of the two columns share one row, so they always match in height, and the feet do the same. A column with
|
|
69
|
+
* nothing for its foot shows none, its body running down to the bottom of the frame. The body of each column scrolls
|
|
70
|
+
* on its own, while its head and foot stay in view, so what they hold is always within reach. The content of a body
|
|
71
|
+
* keeps its width whether the body scrolls or not, so it never reflows where the platform shows a classic scrollbar.
|
|
72
|
+
* Content made sticky in a body pins flush against the head or foot of its column, with no strip of scrolled content
|
|
73
|
+
* showing between them. Everything else keeps the gutter of the body, so only pinned content meets the bars.
|
|
74
|
+
*
|
|
75
|
+
* Heads and feet lay what they hold out as a single row of flex items, centred vertically and never wrapping, so each
|
|
76
|
+
* bar keeps the height of a single line. An item keeps its own width unless it states flex properties of its own, as
|
|
77
|
+
* one growing to fill the bar does, and an item too wide for the bar shrinks, ending its clipped text with an ellipsis.
|
|
78
|
+
*
|
|
79
|
+
* The shell fills the height its host gives it and sets none of its own. Without a definite height, the bodies grow
|
|
80
|
+
* with their content instead of scrolling, and the heads and feet scroll out of view with the page.
|
|
81
|
+
*
|
|
82
|
+
* The main column grows up to a width limit, past which both columns stand centred in the frame. The limit, the width
|
|
83
|
+
* of the side column, the gutters, and the font sizes of heads and feet are tuned through custom properties named
|
|
84
|
+
* after what they tune, such as `--clay-tool-side-width` or `--clay-tool-head-gutter`. Each retunes the shell it is
|
|
85
|
+
* set on, or every shell inside the element it is set on, leaving the other properties of the shell to their defaults.
|
|
86
|
+
*
|
|
87
|
+
* Waiting is stated by the app through `busy`, as when it has to let its state settle before the reader acts again:
|
|
88
|
+
* the frame marks itself busy for assistive technology and ignores pointer and keyboard input aimed inside it, while
|
|
89
|
+
* the focus stays where it stands and the content stays readable. After a short delay, the frame is also veiled, shows
|
|
90
|
+
* a turning glyph at the end of the main head in place of the menu, and announces waiting to screen readers.
|
|
91
|
+
*
|
|
92
|
+
* The main column is named after `head` and takes the focus as the {@link @grafctory/clay!router.Router router} lands a
|
|
93
|
+
* screen, without adding a tab stop, so a reader hears which screen they are on rather than a control of the last one.
|
|
94
|
+
* The column hands that focus on to the main body, so the keys scroll the content at once, while a control inside the
|
|
95
|
+
* column keeps the focus it takes. The main body then opens at its top, or on the element a link targets, set below
|
|
96
|
+
* the head at the gutter of the body, as it stands before any scrolling. The side body keeps its place, so a reader
|
|
97
|
+
* never loses their position in it. A screen replacing its content without a landing, as a catalogue does on a change
|
|
98
|
+
* of filters, states it through the `gist`, and the main body opens at its top again, so the reader never lands halfway
|
|
99
|
+
* down a list they have not read. Under the Clay router, going back or forward in the browser history returns the main
|
|
100
|
+
* body to where the reader left it. The router finds the body again by the fixed ids of the shell boxes, so a page
|
|
101
|
+
* shows one shell at a time, since a second one would repeat those ids and leave the router unable to tell them apart.
|
|
102
|
+
*
|
|
103
|
+
* On a viewport too narrow for two columns, the main column takes the whole frame and the side column becomes a drawer
|
|
104
|
+
* opened from a menu button leading the main head. The drawer covers the main column, across the whole width of a
|
|
105
|
+
* phone and as wide as the side column on a tablet, while the main column stays in place underneath and keeps its
|
|
106
|
+
* state. A close button leads the head of the drawer, and focus moves to it as the drawer opens. Escape, a click
|
|
107
|
+
* outside the drawer, or a link followed inside it closes the drawer and returns focus to the menu button.
|
|
108
|
+
*
|
|
109
|
+
* On such a viewport the heading of the screen also moves from the main head to the top of the main body, and scrolls
|
|
110
|
+
* away with the content it names, keeping the head gutter above and below it so it stands apart from that content as
|
|
111
|
+
* it does in the main head. The mark moves from the side head to stand next to the menu button. The main head keeps
|
|
112
|
+
* only the menu button, the mark and the menu, leaving the room to content. Both heads stand close to the top of the
|
|
113
|
+
* window, with the same narrow spacing above and below them, whatever head gutter the shell is tuned to.
|
|
114
|
+
*
|
|
115
|
+
* While the side column is locked on such a viewport, the menu button is left out and the mark leads the main head.
|
|
116
|
+
* The heading of the screen keeps its place in the main head, as on a wider viewport, so the actions it holds, such
|
|
117
|
+
* as unsafe ones, stay apart from those in the menu rather than scrolling away with the content.
|
|
118
|
+
*
|
|
119
|
+
* @param options The widget configuration
|
|
120
|
+
*
|
|
121
|
+
* @returns The tool shell
|
|
122
|
+
*/
|
|
123
|
+
export function Tool({ wide = false, busy = false, locked = false, tucked = false, gist, mark, meta, tray, more, head, menu, copy, foot, children }) {
|
|
124
|
+
const side = `${Id}-side`;
|
|
125
|
+
// the landmark is named by the head on show, so the reference stands or falls with its target and never dangles
|
|
126
|
+
const title = head ? `${Id}-title` : undefined;
|
|
127
|
+
const { waiting, settle } = useModel(() => createState({
|
|
128
|
+
waiting: false,
|
|
129
|
+
settle(waiting) {
|
|
130
|
+
return { waiting };
|
|
131
|
+
}
|
|
132
|
+
}));
|
|
133
|
+
// only what waiting shows follows `busy` after the delay, while input is ignored as soon as it is set
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
const timer = setTimeout(() => settle(busy), BusyDelay);
|
|
136
|
+
return () => clearTimeout(timer);
|
|
137
|
+
}, [busy]);
|
|
138
|
+
// a locked side column drops the control holding the focus, as browsers do on their own as it turns inert, so the
|
|
139
|
+
// focus leaves it at once and alike everywhere rather than whenever the browser gets round to it
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
if (locked) {
|
|
142
|
+
release(document.getElementById(side));
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
// an unlocked side column keeps the focus where the reader left it
|
|
146
|
+
}
|
|
147
|
+
}, [locked]);
|
|
148
|
+
const { changes, track } = useModel(() => createState({
|
|
149
|
+
gist,
|
|
150
|
+
changes: 0,
|
|
151
|
+
track(gist) {
|
|
152
|
+
return equals(gist, this.gist) ? {} : { gist, changes: this.changes + 1 };
|
|
153
|
+
}
|
|
154
|
+
}));
|
|
155
|
+
// a gist built anew on every render reaches the model each time, which counts only a change of content
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
if (track(gist).changes > changes) {
|
|
158
|
+
document.getElementById(Body)?.scrollTo(0, 0);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
// the same content keeps the reader where they are
|
|
162
|
+
}
|
|
163
|
+
}, [gist]);
|
|
164
|
+
const { open, toggle } = useModel(() => createState({
|
|
165
|
+
open: false,
|
|
166
|
+
toggle(open) {
|
|
167
|
+
return { open };
|
|
168
|
+
}
|
|
169
|
+
}));
|
|
170
|
+
const { split, sync } = useModel(() => createState({
|
|
171
|
+
split: medium(),
|
|
172
|
+
sync() {
|
|
173
|
+
return { split: medium() };
|
|
174
|
+
}
|
|
175
|
+
}));
|
|
176
|
+
// the head stays in the main head where two columns fit or the side column is locked
|
|
177
|
+
const headed = split || locked;
|
|
178
|
+
// the switch lives in the cascade, which notifies no change, so the shell reads it again as the window is resized;
|
|
179
|
+
// a resize observer would raise loop notices as the layout switch reshapes the root it watches, and a transition
|
|
180
|
+
// starts from the state the render read, so the listener is renewed with every crossing it reports
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
window.addEventListener("resize", sync);
|
|
183
|
+
return () => window.removeEventListener("resize", sync);
|
|
184
|
+
}, [sync]);
|
|
185
|
+
// input is ignored rather than the columns turned inert, as an inert column drops the focus: a field switching
|
|
186
|
+
// between reading and editing as it loses and takes the focus would flicker across every stretch of waiting;
|
|
187
|
+
// the handlers sit on the frame, so they see only input aimed inside it, the drawer included
|
|
188
|
+
return createElement("clay-tool", {
|
|
189
|
+
"aria-busy": busy,
|
|
190
|
+
...(busy ? Ignored : undefined),
|
|
191
|
+
wide,
|
|
192
|
+
waiting,
|
|
193
|
+
locked,
|
|
194
|
+
tucked
|
|
195
|
+
}, _jsxs(_Fragment, { children: [!tucked && _jsxs("aside", { id: side, "aria-label": "Menu", popover: locked ? "manual" : "auto", inert: locked, onClick: follow, onToggle: event => {
|
|
196
|
+
reveal(event);
|
|
197
|
+
toggle(opened(event));
|
|
198
|
+
}, children: [_jsxs("header", { children: [split ? mark :
|
|
199
|
+
_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", { children: _jsx("div", { children: tray }) }), more && _jsx("footer", { children: more })] }), _jsxs("main", { id: `${Id}-main`, "aria-labelledby": title, tabIndex: -1, inert: open, onFocus: relay, 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: -1, 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" : "" })] }));
|
|
200
|
+
}
|
|
201
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
202
|
+
/**
|
|
203
|
+
* Tells whether the viewport fits two columns, reading the switch the design system turns on from the medium width up,
|
|
204
|
+
* so the shell follows the threshold wherever the design system sets it and whatever an app forces it to.
|
|
205
|
+
*
|
|
206
|
+
* @returns `true` if the medium viewport switch is on
|
|
207
|
+
*/
|
|
208
|
+
function medium() {
|
|
209
|
+
return getComputedStyle(document.documentElement).getPropertyValue(skin.viewportMedium).trim() === "on";
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Tells whether a toggle of the side column left it open.
|
|
213
|
+
*
|
|
214
|
+
* @param event The toggle the side column went through
|
|
215
|
+
*
|
|
216
|
+
* @returns `true` if the side column is now open as a drawer
|
|
217
|
+
*/
|
|
218
|
+
function opened(event) {
|
|
219
|
+
return "newState" in event && event.newState === "open";
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Moves the focus to the close button as the drawer opens, so a keyboard lands inside what now covers the main column;
|
|
223
|
+
* `autofocus` would take it there too, but browsers flag it on every page loaded from an address with a fragment.
|
|
224
|
+
*
|
|
225
|
+
* @param event The toggle the side column went through
|
|
226
|
+
*/
|
|
227
|
+
function reveal(event) {
|
|
228
|
+
if (opened(event)) {
|
|
229
|
+
event.currentTarget.querySelector(":scope > header > button")?.focus();
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
// the platform returns the focus to the menu button as the drawer closes
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Passes the focus the main column takes on to its body, so the keys scroll the content while a screen reader still
|
|
237
|
+
* announces the landmark entered. The body takes no tab stop: the focus reaches it from code alone, as on a navigation.
|
|
238
|
+
*
|
|
239
|
+
* @param event The focus the main column or an element inside it took
|
|
240
|
+
*/
|
|
241
|
+
function relay(event) {
|
|
242
|
+
if (event.target === event.currentTarget) {
|
|
243
|
+
document.getElementById(Body)?.focus({ preventScroll: true });
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
// a control inside the main column keeps the focus it took
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Takes the focus off the control holding it inside a column.
|
|
251
|
+
*
|
|
252
|
+
* @param column The column whose control is to lose the focus
|
|
253
|
+
*/
|
|
254
|
+
function release(column) {
|
|
255
|
+
const control = document.activeElement;
|
|
256
|
+
if (control instanceof HTMLElement && column?.contains(control)) {
|
|
257
|
+
control.blur();
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
// the focus rests outside the column
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Cancels a gesture aimed inside a busy shell, stopping its default action and the handlers of the control it targets.
|
|
265
|
+
*
|
|
266
|
+
* @param event The gesture to cancel
|
|
267
|
+
*/
|
|
268
|
+
function ignore(event) {
|
|
269
|
+
event.preventDefault();
|
|
270
|
+
event.stopPropagation();
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Closes the drawer once a link inside it is followed, so the reader lands on the destination rather than on the
|
|
274
|
+
* drawer still covering it; a click landing anywhere else in the drawer leaves it open.
|
|
275
|
+
*
|
|
276
|
+
* @param event The click inside the side column
|
|
277
|
+
*/
|
|
278
|
+
function follow(event) {
|
|
279
|
+
if (event.target instanceof Element && event.target.closest("a[href]")) {
|
|
280
|
+
event.currentTarget.togglePopover(false);
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
// a click elsewhere in the drawer leaves it open
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
//# 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,EAAwE,MAAM,QAAQ,CAAC;AACrI,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,IAAI,GAAG,GAAG,EAAE,OAAO,CAAC;AAE1B;;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,CAA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AAa,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;SAAM,CAAC;QACP,iDAAiD;IAClD,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,c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