@funstack/ui 0.1.0-alpha.20 → 0.1.0-alpha.22
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/dist/alert-dialog/alert-dialog-root.mjs +2 -1
- package/dist/alert-dialog/alert-dialog-root.mjs.map +1 -1
- package/dist/avatar/avatar-context.mjs +24 -0
- package/dist/avatar/avatar-context.mjs.map +1 -0
- package/dist/avatar/avatar-fallback.d.mts +32 -0
- package/dist/avatar/avatar-fallback.d.mts.map +1 -0
- package/dist/avatar/avatar-fallback.mjs +31 -0
- package/dist/avatar/avatar-fallback.mjs.map +1 -0
- package/dist/avatar/avatar-image.d.mts +37 -0
- package/dist/avatar/avatar-image.d.mts.map +1 -0
- package/dist/avatar/avatar-image.mjs +91 -0
- package/dist/avatar/avatar-image.mjs.map +1 -0
- package/dist/avatar/avatar-root.d.mts +48 -0
- package/dist/avatar/avatar-root.d.mts.map +1 -0
- package/dist/avatar/avatar-root.mjs +81 -0
- package/dist/avatar/avatar-root.mjs.map +1 -0
- package/dist/avatar/index.d.mts +24 -0
- package/dist/avatar/index.d.mts.map +1 -0
- package/dist/avatar/index.mjs +24 -0
- package/dist/avatar/index.mjs.map +1 -0
- package/dist/dialog/dialog-close.d.mts.map +1 -1
- package/dist/dialog/dialog-close.mjs +14 -3
- package/dist/dialog/dialog-close.mjs.map +1 -1
- package/dist/dialog/dialog-context.mjs +7 -1
- package/dist/dialog/dialog-context.mjs.map +1 -1
- package/dist/dialog/dialog-popup.d.mts +1 -0
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +20 -2
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.mjs +6 -4
- package/dist/dialog/dialog-root.mjs.map +1 -1
- package/dist/docs/components/avatar.md +354 -0
- package/dist/docs/components/drawer.md +622 -0
- package/dist/docs/components/menu.md +1 -1
- package/dist/docs/components/menubar.md +309 -0
- package/dist/docs/components/meter.md +1 -1
- package/dist/docs/components/navigation-menu.md +501 -0
- package/dist/docs/components/number-field.md +2 -2
- package/dist/docs/components/otp-field.md +508 -0
- package/dist/docs/components/progress.md +1 -1
- package/dist/docs/components/radio-group.md +1 -1
- package/dist/docs/components/scroll-area.md +294 -0
- package/dist/docs/components/slider.md +1 -1
- package/dist/docs/concepts/direction-and-locales.md +106 -0
- package/dist/docs/index.md +8 -1
- package/dist/docs/roadmap.md +13 -0
- package/dist/drawer/drawer-close.d.mts +26 -0
- package/dist/drawer/drawer-close.d.mts.map +1 -0
- package/dist/drawer/drawer-close.mjs +19 -0
- package/dist/drawer/drawer-close.mjs.map +1 -0
- package/dist/drawer/drawer-description.d.mts +23 -0
- package/dist/drawer/drawer-description.d.mts.map +1 -0
- package/dist/drawer/drawer-description.mjs +18 -0
- package/dist/drawer/drawer-description.mjs.map +1 -0
- package/dist/drawer/drawer-form.d.mts +24 -0
- package/dist/drawer/drawer-form.d.mts.map +1 -0
- package/dist/drawer/drawer-form.mjs +19 -0
- package/dist/drawer/drawer-form.mjs.map +1 -0
- package/dist/drawer/drawer-popup.d.mts +77 -0
- package/dist/drawer/drawer-popup.d.mts.map +1 -0
- package/dist/drawer/drawer-popup.mjs +124 -0
- package/dist/drawer/drawer-popup.mjs.map +1 -0
- package/dist/drawer/drawer-root.d.mts +31 -0
- package/dist/drawer/drawer-root.d.mts.map +1 -0
- package/dist/drawer/drawer-root.mjs +23 -0
- package/dist/drawer/drawer-root.mjs.map +1 -0
- package/dist/drawer/drawer-swipe.d.mts +5 -0
- package/dist/drawer/drawer-swipe.d.mts.map +1 -0
- package/dist/drawer/drawer-swipe.mjs +193 -0
- package/dist/drawer/drawer-swipe.mjs.map +1 -0
- package/dist/drawer/drawer-title.d.mts +23 -0
- package/dist/drawer/drawer-title.d.mts.map +1 -0
- package/dist/drawer/drawer-title.mjs +18 -0
- package/dist/drawer/drawer-title.mjs.map +1 -0
- package/dist/drawer/drawer-trigger.d.mts +23 -0
- package/dist/drawer/drawer-trigger.d.mts.map +1 -0
- package/dist/drawer/drawer-trigger.mjs +18 -0
- package/dist/drawer/drawer-trigger.mjs.map +1 -0
- package/dist/drawer/index.d.mts +34 -0
- package/dist/drawer/index.d.mts.map +1 -0
- package/dist/drawer/index.mjs +33 -0
- package/dist/drawer/index.mjs.map +1 -0
- package/dist/index.d.mts +29 -2
- package/dist/index.mjs +6 -1
- package/dist/internal/menubar-context.mjs +12 -0
- package/dist/internal/menubar-context.mjs.map +1 -0
- package/dist/internal/overlay/trigger-ref.mjs +1 -1
- package/dist/internal/overlay/trigger-ref.mjs.map +1 -1
- package/dist/internal/overlay/use-overlay-root.mjs +3 -2
- package/dist/internal/overlay/use-overlay-root.mjs.map +1 -1
- package/dist/internal/overlay/use-popover-trigger.mjs +2 -2
- package/dist/internal/overlay/use-popover-trigger.mjs.map +1 -1
- package/dist/internal/range-value.mjs +5 -3
- package/dist/internal/range-value.mjs.map +1 -1
- package/dist/internal/swipe-arithmetic.mjs +75 -0
- package/dist/internal/swipe-arithmetic.mjs.map +1 -0
- package/dist/internal/swipe.mjs +169 -0
- package/dist/internal/swipe.mjs.map +1 -0
- package/dist/menu/menu-context-trigger.mjs +1 -1
- package/dist/menu/menu-popup.d.mts.map +1 -1
- package/dist/menu/menu-popup.mjs +34 -7
- package/dist/menu/menu-popup.mjs.map +1 -1
- package/dist/menu/menu-trigger.d.mts +10 -3
- package/dist/menu/menu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-trigger.mjs +53 -5
- package/dist/menu/menu-trigger.mjs.map +1 -1
- package/dist/menubar/index.d.mts +3 -0
- package/dist/menubar/index.mjs +1 -0
- package/dist/menubar/menubar.d.mts +49 -0
- package/dist/menubar/menubar.d.mts.map +1 -0
- package/dist/menubar/menubar.mjs +147 -0
- package/dist/menubar/menubar.mjs.map +1 -0
- package/dist/meter/meter-root.d.mts +3 -2
- package/dist/meter/meter-root.d.mts.map +1 -1
- package/dist/meter/meter-root.mjs.map +1 -1
- package/dist/multi-select/multi-select-root.mjs +1 -1
- package/dist/multi-select/multi-select-trigger.mjs +1 -1
- package/dist/navigation-menu/index.d.mts +32 -0
- package/dist/navigation-menu/index.d.mts.map +1 -0
- package/dist/navigation-menu/index.mjs +32 -0
- package/dist/navigation-menu/index.mjs.map +1 -0
- package/dist/navigation-menu/navigation-menu-context.mjs +19 -0
- package/dist/navigation-menu/navigation-menu-context.mjs.map +1 -0
- package/dist/navigation-menu/navigation-menu-item.d.mts +79 -0
- package/dist/navigation-menu/navigation-menu-item.d.mts.map +1 -0
- package/dist/navigation-menu/navigation-menu-item.mjs +80 -0
- package/dist/navigation-menu/navigation-menu-item.mjs.map +1 -0
- package/dist/navigation-menu/navigation-menu-link.d.mts +48 -0
- package/dist/navigation-menu/navigation-menu-link.d.mts.map +1 -0
- package/dist/navigation-menu/navigation-menu-link.mjs +66 -0
- package/dist/navigation-menu/navigation-menu-link.mjs.map +1 -0
- package/dist/navigation-menu/navigation-menu-list.d.mts +33 -0
- package/dist/navigation-menu/navigation-menu-list.d.mts.map +1 -0
- package/dist/navigation-menu/navigation-menu-list.mjs +30 -0
- package/dist/navigation-menu/navigation-menu-list.mjs.map +1 -0
- package/dist/navigation-menu/navigation-menu-popup.d.mts +102 -0
- package/dist/navigation-menu/navigation-menu-popup.d.mts.map +1 -0
- package/dist/navigation-menu/navigation-menu-popup.mjs +93 -0
- package/dist/navigation-menu/navigation-menu-popup.mjs.map +1 -0
- package/dist/navigation-menu/navigation-menu-root.d.mts +33 -0
- package/dist/navigation-menu/navigation-menu-root.d.mts.map +1 -0
- package/dist/navigation-menu/navigation-menu-root.mjs +27 -0
- package/dist/navigation-menu/navigation-menu-root.mjs.map +1 -0
- package/dist/navigation-menu/navigation-menu-trigger.d.mts +32 -0
- package/dist/navigation-menu/navigation-menu-trigger.d.mts.map +1 -0
- package/dist/navigation-menu/navigation-menu-trigger.mjs +42 -0
- package/dist/navigation-menu/navigation-menu-trigger.mjs.map +1 -0
- package/dist/otp-field/index.d.mts +23 -0
- package/dist/otp-field/index.d.mts.map +1 -0
- package/dist/otp-field/index.mjs +23 -0
- package/dist/otp-field/index.mjs.map +1 -0
- package/dist/otp-field/otp-field-context.mjs +13 -0
- package/dist/otp-field/otp-field-context.mjs.map +1 -0
- package/dist/otp-field/otp-field-filter.d.mts +5 -0
- package/dist/otp-field/otp-field-filter.d.mts.map +1 -0
- package/dist/otp-field/otp-field-filter.mjs +135 -0
- package/dist/otp-field/otp-field-filter.mjs.map +1 -0
- package/dist/otp-field/otp-field-input.d.mts +41 -0
- package/dist/otp-field/otp-field-input.d.mts.map +1 -0
- package/dist/otp-field/otp-field-input.mjs +177 -0
- package/dist/otp-field/otp-field-input.mjs.map +1 -0
- package/dist/otp-field/otp-field-root.d.mts +152 -0
- package/dist/otp-field/otp-field-root.d.mts.map +1 -0
- package/dist/otp-field/otp-field-root.mjs +400 -0
- package/dist/otp-field/otp-field-root.mjs.map +1 -0
- package/dist/otp-field/otp-field-slot.d.mts +52 -0
- package/dist/otp-field/otp-field-slot.d.mts.map +1 -0
- package/dist/otp-field/otp-field-slot.mjs +67 -0
- package/dist/otp-field/otp-field-slot.mjs.map +1 -0
- package/dist/popover/index.d.mts +1 -1
- package/dist/popover/popover-trigger.mjs +1 -1
- package/dist/progress/progress-root.d.mts +3 -2
- package/dist/progress/progress-root.d.mts.map +1 -1
- package/dist/progress/progress-root.mjs.map +1 -1
- package/package.json +7 -1
- package/skills/funstack-ui-knowledge/SKILL.md +8 -1
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
# Scroll areas
|
|
2
|
+
|
|
3
|
+
FUNSTACK UI has no ScrollArea part, by decision. A ScrollArea in other libraries hides the native scrollbar and draws one out of `div`s, because restyling a scrollbar once needed a different hack per engine. Today the standard properties work in all three engines, the fades at the edges are a scroll-driven animation, and the one gap a native scroller still has (keyboard access in Safari) is an attribute. This page is the recipe: plain CSS and HTML, no JavaScript, no part.
|
|
4
|
+
|
|
5
|
+
```tsx title="ScrollAreaNotes.tsx"
|
|
6
|
+
// No "use client": a Server Component, and there is no FUNSTACK UI part in it. Two native
|
|
7
|
+
// scrollers styled by scroll-area.css. The release notes have no focusable content, so the
|
|
8
|
+
// scroller is a Tab stop itself (tabindex="0", a role and a name): without it Safari gives the
|
|
9
|
+
// keyboard no way to scroll them. The links list needs none of that: Tab reaches the links, and
|
|
10
|
+
// the browser scrolls each into view.
|
|
11
|
+
// A pretend product's changelog.
|
|
12
|
+
const notes = [
|
|
13
|
+
"Invoices can be exported as CSV.",
|
|
14
|
+
"The search box remembers your last five queries.",
|
|
15
|
+
"Fixed: dates in the calendar view used the wrong week start.",
|
|
16
|
+
"Team owners can transfer a project to another team.",
|
|
17
|
+
"The mobile layout keeps the toolbar visible while scrolling.",
|
|
18
|
+
"Fixed: a long project name no longer overlaps the menu.",
|
|
19
|
+
"Comments can be edited for ten minutes after posting.",
|
|
20
|
+
"Keyboard shortcuts are listed under Help.",
|
|
21
|
+
"Fixed: the dark theme used a light scrollbar in the sidebar.",
|
|
22
|
+
"Archived projects are hidden from the dashboard.",
|
|
23
|
+
"Uploads show their progress in the status bar.",
|
|
24
|
+
"Fixed: pasting a link into a comment kept its formatting.",
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const pages = [
|
|
28
|
+
"Getting started",
|
|
29
|
+
"Action props",
|
|
30
|
+
"Pending & optimistic state",
|
|
31
|
+
"Transitions & ViewTransition",
|
|
32
|
+
"Suspense",
|
|
33
|
+
"Browser-owned state",
|
|
34
|
+
"Server Components",
|
|
35
|
+
"Replacing the element",
|
|
36
|
+
"Experimental features",
|
|
37
|
+
"Content Security Policy",
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
export function ScrollAreaNotes() {
|
|
41
|
+
return (
|
|
42
|
+
<div className="demo-scroll-area-row">
|
|
43
|
+
<section className="demo-scroll-area-frame" aria-labelledby="demo-scroll-notes-title">
|
|
44
|
+
<h4 id="demo-scroll-notes-title">Release notes</h4>
|
|
45
|
+
<div
|
|
46
|
+
className="demo-scroll-area demo-scroll-fade"
|
|
47
|
+
tabIndex={0}
|
|
48
|
+
role="region"
|
|
49
|
+
aria-label="Release notes, scrollable"
|
|
50
|
+
>
|
|
51
|
+
<ul className="demo-scroll-area-list">
|
|
52
|
+
{notes.map((note) => (
|
|
53
|
+
<li key={note}>{note}</li>
|
|
54
|
+
))}
|
|
55
|
+
</ul>
|
|
56
|
+
</div>
|
|
57
|
+
</section>
|
|
58
|
+
<nav className="demo-scroll-area-frame" aria-labelledby="demo-scroll-pages-title">
|
|
59
|
+
<h4 id="demo-scroll-pages-title">Pages</h4>
|
|
60
|
+
<div className="demo-scroll-area demo-scroll-fade">
|
|
61
|
+
<ul className="demo-scroll-area-list">
|
|
62
|
+
{pages.map((page) => (
|
|
63
|
+
<li key={page}>
|
|
64
|
+
<a href="#keyboard">{page}</a>
|
|
65
|
+
</li>
|
|
66
|
+
))}
|
|
67
|
+
</ul>
|
|
68
|
+
</div>
|
|
69
|
+
</nav>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```css title="scroll-area.css"
|
|
76
|
+
/* Scroll areas: a native scroller, styled with the standard scrollbar properties, with edge
|
|
77
|
+
fades driven by a scroll timeline (no script). Run in Chromium, Firefox and WebKit by
|
|
78
|
+
packages/ui/src/__tests__/scroll-area-recipe.browser.test.tsx, which reads this file. */
|
|
79
|
+
|
|
80
|
+
.demo-scroll-area {
|
|
81
|
+
max-block-size: 12rem;
|
|
82
|
+
overflow: auto;
|
|
83
|
+
/* auto | thin | none. The thumb's shape and exact width stay the engine's. */
|
|
84
|
+
scrollbar-width: thin;
|
|
85
|
+
/* thumb, then track. */
|
|
86
|
+
scrollbar-color: var(--color-border) transparent;
|
|
87
|
+
/* Space for the bar even before the content overflows: no shift when it starts to. */
|
|
88
|
+
scrollbar-gutter: stable;
|
|
89
|
+
/* Reaching an end does not scroll the page behind. */
|
|
90
|
+
overscroll-behavior: contain;
|
|
91
|
+
}
|
|
92
|
+
.demo-scroll-area:hover,
|
|
93
|
+
.demo-scroll-area:focus-visible {
|
|
94
|
+
scrollbar-color: var(--color-text-secondary) transparent;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* Edge fades. The two lengths are 0 unless the timeline moves them: when nothing overflows the
|
|
98
|
+
timeline is inactive and no fade is drawn. Each fade grows over the first (last) 2rem of
|
|
99
|
+
scrolling, whatever the length of the content. Behind @supports: an engine without scroll
|
|
100
|
+
timelines would run the animations once on the document clock and keep their end values,
|
|
101
|
+
a fade over the top of the content for ever. */
|
|
102
|
+
@property --scroll-fade-start {
|
|
103
|
+
syntax: "<length>";
|
|
104
|
+
inherits: false;
|
|
105
|
+
initial-value: 0px;
|
|
106
|
+
}
|
|
107
|
+
@property --scroll-fade-end {
|
|
108
|
+
syntax: "<length>";
|
|
109
|
+
inherits: false;
|
|
110
|
+
initial-value: 0px;
|
|
111
|
+
}
|
|
112
|
+
@supports (animation-timeline: scroll()) {
|
|
113
|
+
.demo-scroll-fade {
|
|
114
|
+
mask-image: linear-gradient(
|
|
115
|
+
to bottom,
|
|
116
|
+
transparent,
|
|
117
|
+
#000 var(--scroll-fade-start),
|
|
118
|
+
#000 calc(100% - var(--scroll-fade-end)),
|
|
119
|
+
transparent
|
|
120
|
+
);
|
|
121
|
+
/* The shorthand resets the timeline, so the timeline and the ranges come after it. */
|
|
122
|
+
animation:
|
|
123
|
+
scroll-fade-start linear both,
|
|
124
|
+
scroll-fade-end linear both;
|
|
125
|
+
animation-timeline: scroll(self), scroll(self);
|
|
126
|
+
animation-range:
|
|
127
|
+
0 2rem,
|
|
128
|
+
calc(100% - 2rem) 100%;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
@keyframes scroll-fade-start {
|
|
132
|
+
from {
|
|
133
|
+
--scroll-fade-start: 0px;
|
|
134
|
+
}
|
|
135
|
+
to {
|
|
136
|
+
--scroll-fade-start: 2rem;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
@keyframes scroll-fade-end {
|
|
140
|
+
from {
|
|
141
|
+
--scroll-fade-end: 2rem;
|
|
142
|
+
}
|
|
143
|
+
to {
|
|
144
|
+
--scroll-fade-end: 0px;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* The demo's content. */
|
|
149
|
+
.demo-scroll-area-list {
|
|
150
|
+
margin: 0;
|
|
151
|
+
padding: 0.5rem 0.75rem;
|
|
152
|
+
list-style: none;
|
|
153
|
+
display: grid;
|
|
154
|
+
gap: 0.5rem;
|
|
155
|
+
}
|
|
156
|
+
.demo-scroll-area-row {
|
|
157
|
+
display: grid;
|
|
158
|
+
grid-template-columns: repeat(2, minmax(0, 16rem));
|
|
159
|
+
gap: 1rem;
|
|
160
|
+
}
|
|
161
|
+
.demo-scroll-area-frame {
|
|
162
|
+
border: 1px solid var(--color-border);
|
|
163
|
+
border-radius: 0.5rem;
|
|
164
|
+
}
|
|
165
|
+
.demo-scroll-area-frame h4 {
|
|
166
|
+
margin: 0;
|
|
167
|
+
padding: 0.5rem 0.75rem;
|
|
168
|
+
border-block-end: 1px solid var(--color-border);
|
|
169
|
+
font-size: 0.875rem;
|
|
170
|
+
}
|
|
171
|
+
/* The focus ring goes on the frame, not on the scroller: the fade mask would fade the
|
|
172
|
+
scroller's own outline away at an edge with content beyond it. */
|
|
173
|
+
.demo-scroll-area:focus-visible {
|
|
174
|
+
outline: none;
|
|
175
|
+
}
|
|
176
|
+
.demo-scroll-area-frame:has(> .demo-scroll-area:focus-visible) {
|
|
177
|
+
outline: 2px solid var(--color-primary);
|
|
178
|
+
outline-offset: 2px;
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
This example is a Server Component with no library code in it. Scroll either list: the fade at an edge appears once there is content beyond it.
|
|
183
|
+
|
|
184
|
+
## The scrollbar
|
|
185
|
+
|
|
186
|
+
```css
|
|
187
|
+
.scroll-area {
|
|
188
|
+
overflow: auto;
|
|
189
|
+
scrollbar-width: thin; /* auto | thin | none */
|
|
190
|
+
scrollbar-color: var(--thumb) transparent; /* thumb, then track */
|
|
191
|
+
scrollbar-gutter: stable; /* space for the bar before the content overflows */
|
|
192
|
+
overscroll-behavior: contain; /* reaching an end does not scroll the page */
|
|
193
|
+
}
|
|
194
|
+
.scroll-area:hover,
|
|
195
|
+
.scroll-area:focus-visible { scrollbar-color: var(--thumb-strong) transparent; }
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
| Property | Chrome | Firefox | Safari |
|
|
199
|
+
| - | - | - | - |
|
|
200
|
+
| `scrollbar-width` | 121 | 64 | 18.2 |
|
|
201
|
+
| `scrollbar-color` | 121 | 64 | 26.2 |
|
|
202
|
+
| `scrollbar-gutter` | 94 | 97 | 18.2 |
|
|
203
|
+
|
|
204
|
+
- `scrollbar-gutter: stable` reserves the bar's space where scrollbars take space (classic scrollbars on Windows and most Linux desktops), so the content does not shift when it starts to overflow. Where scrollbars overlay the content (macOS by default, mobile) it reserves nothing.
|
|
205
|
+
- The user's settings keep working: "always show scroll bars", the system scrollbar size, forced colours. A drawn bar loses all three.
|
|
206
|
+
- `thin` is the only size: its pixels, and the thumb's shape, are the engine's.
|
|
207
|
+
|
|
208
|
+
### A rounded thumb in Chromium and desktop Safari
|
|
209
|
+
|
|
210
|
+
`::-webkit-scrollbar` and its relatives still exist in Chromium and desktop Safari (not in Firefox; iOS honours only `display: none`), and give the thumb a radius and an inset. Chromium ignores them as soon as `scrollbar-width` or `scrollbar-color` is not `auto`, so choose one or the other per engine:
|
|
211
|
+
|
|
212
|
+
```css
|
|
213
|
+
.scroll-area::-webkit-scrollbar { inline-size: 10px; block-size: 10px; }
|
|
214
|
+
.scroll-area::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: 5px; background: var(--thumb) padding-box; }
|
|
215
|
+
|
|
216
|
+
/* Firefox, and any engine without the pseudo-elements. */
|
|
217
|
+
@supports not selector(::-webkit-scrollbar) {
|
|
218
|
+
.scroll-area { scrollbar-width: thin; scrollbar-color: var(--thumb) transparent; }
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
The pseudo-elements are non-standard: forced colours and the user's scrollbar settings do not reach a thumb drawn with them either. **iOS Safari** matches the selector (so the `@supports not selector(…)` block does not apply there) but honours only `display: none` on it, so iOS gets neither the drawn thumb nor the standard properties: its overlay scrollbar stays the system's. If you want `scrollbar-color` on iOS, use the standard properties everywhere instead.
|
|
223
|
+
|
|
224
|
+
## Edge fades
|
|
225
|
+
|
|
226
|
+
A fade at an edge that has more content beyond it, with no script: a scroll-driven animation moves two registered lengths that a mask gradient uses. When nothing overflows the timeline is inactive, the lengths keep their initial `0px`, and no fade is drawn. Each fade grows over the first (and last) `2rem` of scrolling, whatever the length of the content.
|
|
227
|
+
|
|
228
|
+
```css
|
|
229
|
+
@property --scroll-fade-start { syntax: "<length>"; inherits: false; initial-value: 0px; }
|
|
230
|
+
@property --scroll-fade-end { syntax: "<length>"; inherits: false; initial-value: 0px; }
|
|
231
|
+
|
|
232
|
+
@supports (animation-timeline: scroll()) {
|
|
233
|
+
.scroll-fade {
|
|
234
|
+
mask-image: linear-gradient(to bottom,
|
|
235
|
+
transparent, #000 var(--scroll-fade-start),
|
|
236
|
+
#000 calc(100% - var(--scroll-fade-end)), transparent);
|
|
237
|
+
/* The shorthand resets the timeline: the timeline and the ranges come after it. */
|
|
238
|
+
animation: scroll-fade-start linear both, scroll-fade-end linear both;
|
|
239
|
+
animation-timeline: scroll(self), scroll(self);
|
|
240
|
+
animation-range: 0 2rem, calc(100% - 2rem) 100%;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
@keyframes scroll-fade-start { from { --scroll-fade-start: 0px; } to { --scroll-fade-start: 2rem; } }
|
|
244
|
+
@keyframes scroll-fade-end { from { --scroll-fade-end: 2rem; } to { --scroll-fade-end: 0px; } }
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
| Feature | Chrome | Firefox | Safari |
|
|
248
|
+
| - | - | - | - |
|
|
249
|
+
| Scroll-driven animations (`animation-timeline: scroll()`) | 115 | 159 | 26 |
|
|
250
|
+
| `@property` | 85 | 128 | 16.4 |
|
|
251
|
+
| `mask-image` (unprefixed) | 120 | 53 | 15.4 |
|
|
252
|
+
|
|
253
|
+
- Keep the `@supports`. In an engine without scroll timelines the animations would run once on the document clock and keep their end values: a permanent fade over the top of the content.
|
|
254
|
+
- The mask also fades the ends of a classic scrollbar, which is part of the masked box. If that matters, put the scroller inside a wrapper and draw the fades as overlays in the wrapper's background colour, driven by a named timeline (`scroll-timeline` on the scroller, `timeline-scope` on the wrapper; `timeline-scope` is Chrome 116, Firefox 159, Safari 26). That variant is a sketch: the browser test below does not run it.
|
|
255
|
+
- The fade is a mask, not motion: `prefers-reduced-motion` needs nothing here.
|
|
256
|
+
|
|
257
|
+
## <a id="keyboard"></a>Keyboard access
|
|
258
|
+
|
|
259
|
+
A keyboard user scrolls a scroller by focusing something inside it. When the content has nothing focusable (text, images), Chrome (since 132, per the update note in Chrome's [Keyboard focusable scrollers](https://developer.chrome.com/blog/keyboard-focusable-scrollers) post: first announced for 130, then pushed back) and Firefox make the scroller itself a Tab stop; **Safari does not** (WebKit bug 277290), so there the content is out of reach. Make such a scroller focusable, and give it a role and a name so that the Tab stop is announced as something:
|
|
260
|
+
|
|
261
|
+
```html
|
|
262
|
+
<!-- Only when the content has nothing focusable. -->
|
|
263
|
+
<div class="scroll-area" tabindex="0" role="region" aria-label="Release notes">…</div>
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
- Once focused, the arrow keys and Page Up / Page Down scroll it, in every engine (the browser's own scrolling keys; no script).
|
|
267
|
+
- Give it a visible focus ring, but **not on the scroller itself** when it has the edge fades: the mask fades its own outline away at an edge with content beyond it. Draw the ring on a frame around it instead:
|
|
268
|
+
```css
|
|
269
|
+
.scroll-area:focus-visible { outline: none; }
|
|
270
|
+
.scroll-frame:has(> .scroll-area:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
|
|
271
|
+
```
|
|
272
|
+
- Do not add it when the content has links, buttons or fields: Tab reaches them and the browser scrolls each into view, and the extra Tab stop is noise.
|
|
273
|
+
- `role="region"` with a name makes it a landmark. For a scroller that is a minor part of the page, `role="group"` with the same name avoids adding to the landmark list.
|
|
274
|
+
- Whether the content has something focusable is a decision about your content, which you make better than a measuring script would. That is why this is not a part that adds `tabindex` when it overflows.
|
|
275
|
+
|
|
276
|
+
## Why there is no part
|
|
277
|
+
|
|
278
|
+
What a native scroller still cannot do:
|
|
279
|
+
|
|
280
|
+
- a thumb shape (radius, inset, exact thickness) in Firefox and on iOS;
|
|
281
|
+
- an overlay scrollbar that takes no layout space on a platform whose scrollbars are classic, or one that hides until hover there.
|
|
282
|
+
|
|
283
|
+
What a drawn scrollbar costs:
|
|
284
|
+
|
|
285
|
+
- the user's settings stop applying ("always show scroll bars", scrollbar size, forced colours, where a `div` thumb is a background colour that disappears);
|
|
286
|
+
- a small pointer target unless you size it, and track clicks and drag behaviour that are reimplemented, never quite native;
|
|
287
|
+
- script on every scroll and resize to place and size the thumb;
|
|
288
|
+
- nothing for assistive technology: every library that draws one hides it from it.
|
|
289
|
+
|
|
290
|
+
And there is nothing asynchronous in it: no state the library would own, no action, nothing pending. If you need a drawn bar anyway, a dedicated scrollbar library is a better home for it than a headless kit.
|
|
291
|
+
|
|
292
|
+
> **Checked in three engines**
|
|
293
|
+
>
|
|
294
|
+
> The stylesheet of the example above is run by a browser test in Chromium, Firefox and WebKit (`scroll-area-recipe.browser.test.tsx` in the repository): the computed scrollbar properties, a gutter that is reserved before the content overflows where the bar takes space, the fade lengths at the top, in the middle and at the bottom, no fade without overflow, no fade at all in an engine without scroll timelines, the focusable region scrolled with the arrow keys and Page Down, and its focus ring on the frame. The Firefox the test runs (Playwright's build, 157) hides every scrollbar and predates scroll timelines, so there it checks the no-gutter and no-fade branches; the fade branch was run in it once with the feature's preference on. The `::-webkit-scrollbar` and overlay variants above are not run.
|
|
@@ -344,7 +344,7 @@ Every key is the browser's, except ArrowLeft / ArrowRight on vertical and on RTL
|
|
|
344
344
|
| Home / End | the thumb's min / max (its neighbour with several thumbs) | same |
|
|
345
345
|
| Tab / Shift+Tab | between thumbs | same |
|
|
346
346
|
|
|
347
|
-
- Each key press is one step and one commit. Firefox decreases a vertical range on ArrowRight; the library handles ArrowLeft / ArrowRight on vertical sliders so every engine follows the APG (Right increases). Under RTL (the input's computed `direction`) the track is mirrored, so ArrowLeft increases; Chromium and Firefox mirror a native range, Safari does not, so the library handles these two keys there as well. Left-to-right horizontal keys stay native.
|
|
347
|
+
- Each key press is one step and one commit. Firefox decreases a vertical range on ArrowRight; the library handles ArrowLeft / ArrowRight on vertical sliders so every engine follows the APG (Right increases). Under RTL (the input's computed `direction`) the track is mirrored, so ArrowLeft increases; Chromium and Firefox mirror a native range, Safari does not, so the library handles these two keys there as well. Left-to-right horizontal keys stay native. Set the direction with `dir` on the page, a container or the Root; there is no provider ([Direction and locales](../concepts/direction-and-locales.md)).
|
|
348
348
|
- No `aria-valuemin`, `aria-valuemax`, `aria-valuenow` or `aria-orientation`: the native `min`, `max`, value and writing mode provide them (Chromium even lets the ARIA ones override the real values).
|
|
349
349
|
- A pointer press focuses the input without a focus ring, as on a native range; the page still scrolls along the other axis (`touch-action`).
|
|
350
350
|
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Direction and locales
|
|
2
|
+
|
|
3
|
+
FUNSTACK UI has no `DirectionProvider` and no `LocaleProvider`. Direction comes from the page, the way the browser reads it; a locale is a plain prop on the Root of each component that formats numbers.
|
|
4
|
+
|
|
5
|
+
## Direction
|
|
6
|
+
|
|
7
|
+
**`dir` is the only switch.** Set it where the platform expects it: `<html dir="rtl">`, a container, or a part itself (every part passes native attributes through, so `<Tabs.List dir="rtl">` works). Each component reads the computed CSS `direction` of the relevant element (the table below) when a key is pressed or a gesture starts, so nothing is needed at render and Server Components and the server HTML are unaffected.
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
// <html lang="ar" dir="rtl"> in your document, then no setup:
|
|
11
|
+
<Tabs.Root defaultValue="a">
|
|
12
|
+
<Tabs.List>…</Tabs.List> {/* ArrowLeft moves to the next tab */}
|
|
13
|
+
</Tabs.Root>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- **Why no provider.** A provider would be a second source of truth next to `dir`, the attribute the browser already uses for layout, logical properties, `:dir()` and anchor positioning. Libraries that have one ask you to set both, and when the two disagree the arrow keys and the layout point different ways. Reading the CSS cannot disagree with the layout, and a page with `<html dir="rtl">` needs no setup at all.
|
|
17
|
+
- **Direction islands work.** An RTL block inside an LTR page (a quoted Arabic form, a Hebrew sidebar), or the reverse, is handled per component, because each reads its own element. Nothing has to be nested to match the markup.
|
|
18
|
+
- Placement of popups follows direction in CSS: `side="inline-start"` / `"inline-end"` and `align="start"` / `"end"` use anchor-positioning keywords that resolve against the popup's direction. Drawer's `side` takes `"inline-start"` / `"inline-end"` too.
|
|
19
|
+
- A locale never sets the direction: `locale="ar"` on a NumberField changes its digits and separators, not its layout.
|
|
20
|
+
|
|
21
|
+
### What mirrors
|
|
22
|
+
|
|
23
|
+
**Only ArrowLeft and ArrowRight in a horizontal orientation swap.** ArrowUp / ArrowDown, Home / End, PageUp / PageDown and every vertical orientation do the same under RTL as under LTR. `writing-mode` is not read.
|
|
24
|
+
|
|
25
|
+
| Component | What follows direction | Read from |
|
|
26
|
+
| - | - | - |
|
|
27
|
+
| [Tabs](../components/tabs.md) | ArrowLeft / ArrowRight between tabs (horizontal list) | the List |
|
|
28
|
+
| [ToggleGroup](../components/toggle-group.md), [Toolbar](../components/toolbar.md) | ArrowLeft / ArrowRight between items (horizontal) | the Root |
|
|
29
|
+
| [Slider](../components/slider.md) | ArrowLeft / ArrowRight follow the mirrored track (Right decreases); the value under the pointer | the thumb's input; the Track |
|
|
30
|
+
| [Menu](../components/menu.md) | the arrow that opens and closes a submenu (the inline-end one); the open key of a Trigger in a vertical Toolbar; which edge of a menu opened at a point sits at the pointer; the wheel hand-off of a horizontal scroller | the popup or its parent popup; the Trigger; the scroller |
|
|
31
|
+
| [Combobox](../components/combobox.md) `multiple` | the inline-start arrow from the input to the chips, and arrows between chips | the input; the chip |
|
|
32
|
+
| [Drawer](../components/drawer.md) | which way an `inline-start` / `inline-end` drawer swipes closed | the dialog |
|
|
33
|
+
| Tooltip, Popover, HoverCard, Menu, Select, Combobox, MultiSelect | logical sides and alignment; `data-side` / `data-align` report where the popup is | CSS anchor positioning |
|
|
34
|
+
| [RadioGroup](../components/radio-group.md) | arrows between radios (native; not in Safari, below) | the browser |
|
|
35
|
+
| [OTPField](../components/otp-field.md) | nothing: the Root is `ltr` by default (below) | – |
|
|
36
|
+
| Accordion, NumberField | nothing: vertical keys only | – |
|
|
37
|
+
|
|
38
|
+
### Engine differences
|
|
39
|
+
|
|
40
|
+
- **RadioGroup in Safari, by design.** Radio arrows are the browser's own, and WebKit neither mirrors ArrowLeft / ArrowRight under RTL nor wraps at the ends: Right and Down always go to the next radio in document order. A FUNSTACK radio group behaves like every native radio group in Safari; the library adds no key handler ([RadioGroup](../components/radio-group.md#keyboard-and-aria)). Slider is the exception, because there the value moved against the drawn track.
|
|
41
|
+
- **Firefox misplaces popups in a direction island.** When a popup's parent box has another direction than the root element (an RTL block in an LTR page, or the reverse), Firefox mirrors the inline offset of its anchored position, physical sides included, so the popup lands away from its trigger ([#89](https://github.com/uhyo/funstack-ui/issues/89), Mozilla bug 2019601). Chromium and Safari place it correctly, a page whose `<html dir>` matches is unaffected, and the library ships no workaround.
|
|
42
|
+
|
|
43
|
+
### OTPField is left to right
|
|
44
|
+
|
|
45
|
+
A one-time code is read left to right in every locale, so `OTPField.Root` renders `dir="ltr"` unless you pass `dir`: inside an RTL page Slot 0 stays the leftmost box and ArrowLeft moves to the previous character. The label and the messages outside the Root follow the page. Without the attribute the boxes would mirror while the input's text would not, and the engines disagree on the arrow keys there. See [OTPField](../components/otp-field.md#right-to-left-pages).
|
|
46
|
+
|
|
47
|
+
## <a id="locale"></a>Locales
|
|
48
|
+
|
|
49
|
+
Components that format or parse numbers take a `locale` prop on their Root: [NumberField](../components/number-field.md), [Progress](../components/progress.md) and [Meter](../components/meter.md). The type is `string | readonly string[]`, what the `Intl` constructors take (a list is a preference order). The parts get the formatter from the Root.
|
|
50
|
+
|
|
51
|
+
- **The default is the runtime's locale**, on the server and in the browser. That suits a client-only app.
|
|
52
|
+
- **Pass it when the page is server-rendered.** The server's locale and the browser's can differ, and the formatted text would then not match at hydration. NumberField warns in development when `<html lang>` names another language and no `locale` was given.
|
|
53
|
+
- The library never reads `navigator.language` and never derives the locale from `lang`.
|
|
54
|
+
|
|
55
|
+
### Why there is no LocaleProvider
|
|
56
|
+
|
|
57
|
+
`Progress.Root` and `Meter.Root` have no `"use client"` directive, so a Server Component renders them once, on the server. A context cannot reach them there, so a provider would silently not apply to them. And an app that localises already has a locale source, its i18n library; a second provider would have to be kept in step with it. The question is reopened by the first date or time component.
|
|
58
|
+
|
|
59
|
+
### Recipe: the locale from your i18n library
|
|
60
|
+
|
|
61
|
+
Wrap the Root once in a client component that reads the locale from your i18n library, and use the wrapper everywhere:
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
"use client";
|
|
65
|
+
import { NumberField } from "@funstack/ui/number-field";
|
|
66
|
+
import type { ComponentProps } from "react";
|
|
67
|
+
import { useLocale } from "./i18n"; // your i18n library's hook
|
|
68
|
+
|
|
69
|
+
export function NumberFieldRoot(props: ComponentProps<typeof NumberField.Root>) {
|
|
70
|
+
const locale = useLocale();
|
|
71
|
+
return <NumberField.Root locale={locale} {...props} />;
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Recipe: from a Server Component
|
|
76
|
+
|
|
77
|
+
`locale` is plain data, so a Server Component passes it directly. Progress and Meter then format on the server, with nothing to mismatch:
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import { Progress } from "@funstack/ui/progress";
|
|
81
|
+
import { getLocale } from "./i18n/server"; // however your server knows the request's locale
|
|
82
|
+
|
|
83
|
+
export async function UploadStatus({ done }: { done: number }) {
|
|
84
|
+
const locale = await getLocale(); // for example "ar-EG" or ["de-CH", "de"]
|
|
85
|
+
return (
|
|
86
|
+
<Progress.Root value={done} locale={locale} aria-label="Upload">
|
|
87
|
+
<Progress.Value />
|
|
88
|
+
<Progress.Track><Progress.Indicator /></Progress.Track>
|
|
89
|
+
</Progress.Root>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Built-in strings
|
|
95
|
+
|
|
96
|
+
A few parts have an English default text, each with its own override; there is no strings provider either.
|
|
97
|
+
|
|
98
|
+
| Component | Default | Override |
|
|
99
|
+
| - | - | - |
|
|
100
|
+
| [Combobox](../components/combobox.md#props) | `"No results"`, `"1 result"`, `"N results"`; `"Japan removed"` with `multiple` | `announce`, `announceRemoved` on the Root |
|
|
101
|
+
| [Toast](../components/toast.md#props) | `"Notifications (F8)"`, the Viewport's name | `aria-label` on `Toast.Viewport` |
|
|
102
|
+
| [NumberField](../components/number-field.md#props) | `"Increase"` / `"Decrease"`, the buttons' names | `aria-label` on `Increment` / `Decrement` |
|
|
103
|
+
|
|
104
|
+
> **Not formatted by the library**
|
|
105
|
+
>
|
|
106
|
+
> Slider's `aria-valuetext` and Combobox filtering are yours: format and compare with `Intl` in your own function.
|
package/dist/docs/index.md
CHANGED
|
@@ -118,7 +118,7 @@ npm install @funstack/ui@alpha
|
|
|
118
118
|
|
|
119
119
|
React 19.3 or later. Supported browsers: **the latest stable Blink, WebKit and Gecko. No fallbacks.** Platform features not yet in all three are opt-in [experimental props](concepts/experimental.md).
|
|
120
120
|
|
|
121
|
-
Components: [Button](components/button.md), [Toggle](components/toggle.md), [ToggleGroup](components/toggle-group.md), [Toolbar](components/toolbar.md), [Tabs](components/tabs.md), [Accordion](components/accordion.md), [Collapsible](components/collapsible.md), [Tooltip](components/tooltip.md), [HoverCard](components/hover-card.md), [Popover](components/popover.md), [Dialog](components/dialog.md), [AlertDialog](components/alert-dialog.md), [Menu](components/menu.md), [Context menu (Menu)](components/context-menu.md), [Toast](components/toast.md), [Field and Form](components/field.md), [Checkbox](components/checkbox.md), [CheckboxGroup](components/checkbox-group.md), [RadioGroup](components/radio-group.md), [Switch](components/switch.md), [Select](components/select.md), [Combobox](components/combobox.md), [MultiSelect](components/multi-select.md), [Slider](components/slider.md), [NumberField](components/number-field.md), [Progress](components/progress.md), [Meter](components/meter.md)
|
|
121
|
+
Components: [Button](components/button.md), [Toggle](components/toggle.md), [ToggleGroup](components/toggle-group.md), [Toolbar](components/toolbar.md), [Tabs](components/tabs.md), [Accordion](components/accordion.md), [Collapsible](components/collapsible.md), [NavigationMenu](components/navigation-menu.md), [Tooltip](components/tooltip.md), [HoverCard](components/hover-card.md), [Popover](components/popover.md), [Dialog](components/dialog.md), [AlertDialog](components/alert-dialog.md), [Drawer](components/drawer.md), [Menu](components/menu.md), [Context menu (Menu)](components/context-menu.md), [Menubar (Menu)](components/menubar.md), [Toast](components/toast.md), [Field and Form](components/field.md), [Checkbox](components/checkbox.md), [CheckboxGroup](components/checkbox-group.md), [RadioGroup](components/radio-group.md), [Switch](components/switch.md), [Select](components/select.md), [Combobox](components/combobox.md), [MultiSelect](components/multi-select.md), [Slider](components/slider.md), [NumberField](components/number-field.md), [OTPField](components/otp-field.md), [Progress](components/progress.md), [Meter](components/meter.md), [Avatar](components/avatar.md), [Separator](components/separator.md) and [Scroll areas (recipe)](components/scroll-area.md). More are coming; see the [roadmap](roadmap.md).
|
|
122
122
|
|
|
123
123
|
## The FUNSTACK family
|
|
124
124
|
|
|
@@ -147,6 +147,7 @@ FUNSTACK UI is part of the FUNSTACK family, which aims to be the most modern Rea
|
|
|
147
147
|
### Guides
|
|
148
148
|
|
|
149
149
|
- [Replacing the element (render)](concepts/render.md): How the render prop replaces the element a FUNSTACK UI part renders: the element form, the function form, and how the part's props are merged into yours.
|
|
150
|
+
- [Direction and locales](concepts/direction-and-locales.md): Right-to-left pages and number formatting in FUNSTACK UI: dir is the only direction switch (no DirectionProvider), which keys mirror, the engine differences, OTPField's ltr default, and the locale prop per Root (no LocaleProvider) with SSR recipes.
|
|
150
151
|
- [Experimental features](concepts/experimental.md): Platform features that are not in every engine yet are opt-in through experimental\_\* props on the part that uses them.
|
|
151
152
|
- [Content Security Policy](concepts/content-security-policy.md): What a strict style-src needs for FUNSTACK UI: the SHA-256 of the two shipped stylesheets (STYLE_SHA256) or a nonce through CSPProvider, and style-src-attr for server-rendered inline styles.
|
|
152
153
|
- [Using with AI agents](concepts/ai-agents.md): Give a coding agent FUNSTACK UI knowledge: install the funstack-ui-knowledge skill from the npm package, or point the agent at the Markdown docs bundled in the package and published as llms.txt.
|
|
@@ -160,13 +161,16 @@ FUNSTACK UI is part of the FUNSTACK family, which aims to be the most modern Rea
|
|
|
160
161
|
- [Tabs](components/tabs.md): Tabs with optimistic selection, committed panels that may suspend, automatic or manual activation, an anchor-positioned indicator, and find-in-page support.
|
|
161
162
|
- [Accordion](components/accordion.md): An accordion built on \<details>/\<summary>: no JavaScript when you need no state; actions, optimistic data-open and Suspense-friendly panels when you do.
|
|
162
163
|
- [Collapsible](components/collapsible.md): One disclosure built on \<details>/\<summary>: no JavaScript when you need no state; actions, optimistic data-open and Suspense-friendly content when you do.
|
|
164
|
+
- [NavigationMenu](components/navigation-menu.md): A site's main navigation: a row of links and buttons that open panels of more links, built on the Popover API. It needs no JavaScript; a panel whose content loads on open is a transition.
|
|
163
165
|
- [Tooltip](components/tooltip.md): A tooltip built on the Popover API and CSS Anchor Positioning, with a native interestfor path in Chromium. Open state belongs to the browser.
|
|
164
166
|
- [HoverCard](components/hover-card.md): A rich preview that appears when the user rests the pointer on a link or focuses it: the open is a transition, so the content loads on interest and the card appears when it is ready; every close is a fact.
|
|
165
167
|
- [Popover](components/popover.md): A non-modal popover on the Popover API: JS-free when you need no state; a transition-driven open, library-owned closes with a ViewTransition exit in every engine, and Suspense-ready content when you do.
|
|
166
168
|
- [Dialog](components/dialog.md): A dialog built on \<dialog> and Invoker Commands: JS-free when you need no state; a transition-driven open with a pending trigger, Suspense-ready content, and library-owned closes with a ViewTransition exit in every engine when you do.
|
|
167
169
|
- [AlertDialog](components/alert-dialog.md): A Dialog with alert defaults: role alertdialog, always modal, no light dismiss, focus on Cancel. The confirm button runs your async action with its own pending state, closes when it resolves and stays open when it rejects.
|
|
170
|
+
- [Drawer](components/drawer.md): A dialog attached to an edge of the viewport that the user can swipe back to it, with mouse, pen or touch. A Dialog underneath: top layer, focus, Escape, the JS-free mode; the swipe is a dismissal reported to onOpenChange, and your CSS moves the drawer through three custom properties.
|
|
168
171
|
- [Menu](components/menu.md): A menu button on the Popover API: items whose actions run in their own transition with pending state, optimistic checkbox and radio items, the APG keyboard model with typeahead, and submenus with hover intent.
|
|
169
172
|
- [Context menu (Menu)](components/context-menu.md): Menu.ContextTrigger: a region whose right-click, Shift+F10 or touch long-press opens a Menu at the pointer, with the menu's pending items, optimistic checkbox and radio items and submenus unchanged.
|
|
173
|
+
- [Menubar (Menu)](components/menubar.md): The application menu of a desktop-style app: a row of ordinary Menu.Roots with one Tab stop, arrow keys between the menus and hover switching while a menu is open.
|
|
170
174
|
- [Toast](components/toast.md): Notifications fed by a toast() function and rendered by your own Viewport: an urgent queue that shows while the action it reports on is still pending, promise toasts, an Undo action prop, an onClose handler for the Undo window, ariaNotify announcements, and a region that stays interactive above modal dialogs.
|
|
171
175
|
- [Field and Form](components/field.md): Labelled, described, validated form fields on top of native constraint validation and :user-invalid, and a Form that runs its action in a transition, routes server errors to fields and resets only on success.
|
|
172
176
|
- [Checkbox](components/checkbox.md): A native \<input type=checkbox> with an async checkedChangeAction, optimistic checked state, a controlled indeterminate state and native form participation.
|
|
@@ -178,9 +182,12 @@ FUNSTACK UI is part of the FUNSTACK family, which aims to be the most modern Rea
|
|
|
178
182
|
- [MultiSelect](components/multi-select.md): A select-only combobox with a multi-select listbox: a button that shows the selection, options that load on open inside Suspense, a pick that toggles with an optimistic selection and the option pending, the open state as actions and facts, forms and required.
|
|
179
183
|
- [Slider](components/slider.md): A slider on a visually hidden native \<input type=range> per thumb: every step a transition, each gesture saved once with rollback, multi-thumb, vertical and RTL.
|
|
180
184
|
- [NumberField](components/number-field.md): A text field that holds a number: typed in the user's locale, stepped with keys and press-and-hold buttons, posted as a plain number through a hidden native number input, saved once per gesture with rollback.
|
|
185
|
+
- [OTPField](components/otp-field.md): A field for a one-time code: one input with autocomplete one-time-code drawn as a row of boxes, a filter that keeps the text a code, and completeAction, the moment the code is complete as an awaited request with data-pending.
|
|
181
186
|
- [Progress](components/progress.md): A progress bar on div\[role=progressbar]: the display of someone else's action, correct in every lane, localised aria-valuetext, and a Root that is itself a Server Component.
|
|
182
187
|
- [Meter](components/meter.md): A gauge on div\[role=meter] with the platform's low / high / optimum regions, localised aria-valuetext, and a Root that is itself a Server Component.
|
|
188
|
+
- [Avatar](components/avatar.md): A picture of a person or a thing with initials or an icon in its place: the image is in the server HTML, the fallback sits under it, the name is on the Root, and React's commit wait for images under a ViewTransition still applies.
|
|
183
189
|
- [Separator](components/separator.md): A line between two pieces of content: an hr with aria-orientation and data-orientation, a decorative mode, and a component that is itself a Server Component.
|
|
190
|
+
- [Scroll areas (recipe)](components/scroll-area.md): There is no ScrollArea part: a native scroller with scrollbar-width, scrollbar-color and scrollbar-gutter, edge fades from a scroll-driven animation, and a Tab stop for content with nothing focusable. A recipe, run in Chromium, Firefox and WebKit.
|
|
184
191
|
|
|
185
192
|
### Resources
|
|
186
193
|
|
package/dist/docs/roadmap.md
CHANGED
|
@@ -10,6 +10,18 @@ Alpha releases (`0.1.0-alpha.N`) are published on npm under the `alpha` dist-tag
|
|
|
10
10
|
|
|
11
11
|
Changes an upgrade may notice, newest first. Each component page documents the current behaviour.
|
|
12
12
|
|
|
13
|
+
- New component [Menubar](components/menubar.md) ([#170](https://github.com/uhyo/funstack-ui/issues/170)): a `<div role="menubar">` around ordinary `Menu.Root`s. A `Menu.Trigger` inside it renders `role="menuitem"`, and its `disabled` renders `aria-disabled` (it stays focusable); outside a bar nothing changes.
|
|
14
|
+
|
|
15
|
+
- New component [NavigationMenu](components/navigation-menu.md) ([#170](https://github.com/uhyo/funstack-ui/issues/170)): a site's main navigation as the disclosure pattern, each panel a `popover="auto"` next to its `popovertarget` button. It needs no JavaScript by default; after hydration focus leaving a panel and a followed `NavigationMenu.Link` close it. A panel whose content loads on open opts into library mode (`openChangeAction`, transition types `fsui-navigation-menu*`). Hover opening and arrow keys are not in this version.
|
|
16
|
+
|
|
17
|
+
- Direction and locale are decided ([#172](https://github.com/uhyo/funstack-ui/issues/172), [#188](https://github.com/uhyo/funstack-ui/issues/188)): `dir` is the only direction switch and there is no provider; `locale` is a prop of each Root that formats. See [Direction and locales](concepts/direction-and-locales.md). `OTPField.Root` now renders `dir="ltr"` unless you pass `dir`, so inside an RTL page its boxes no longer mirror. `locale` on `Progress.Root` and `Meter.Root` also takes a list of tags (`string | readonly string[]`), as on NumberField.
|
|
18
|
+
|
|
19
|
+
- New component [Drawer](components/drawer.md) ([#168](https://github.com/uhyo/funstack-ui/issues/168)): a Dialog attached to an edge (`side`, rendered as `data-side`) that the user can swipe back to it with mouse, pen or touch. The swipe writes `data-swiping` and `--drawer-swipe-x` / `-y` / `-progress` for your CSS, finishes the slide, and closes the drawer as a dismissal reported to `onOpenChange`. Its transition types are `fsui-drawer*`. Snap points and the pull from a scrolled-to-top list are not in this version.
|
|
20
|
+
|
|
21
|
+
- New component [OTPField](components/otp-field.md) ([#171](https://github.com/uhyo/funstack-ui/issues/171)): a one-time-code field that is one `autocomplete="one-time-code"` input drawn as a row of boxes, with `completeAction` for the complete code, `submitOnComplete` and `experimental_webOTP`.
|
|
22
|
+
|
|
23
|
+
- New component [Avatar](components/avatar.md) ([#171](https://github.com/uhyo/funstack-ui/issues/171)), and a [Scroll areas](components/scroll-area.md) recipe page instead of a ScrollArea part.
|
|
24
|
+
|
|
13
25
|
- A `Dialog.Close` or `Popover.Close` with an `action` no longer renders `commandfor` / `command` ([#182](https://github.com/uhyo/funstack-ui/issues/182)). A click before hydration used to close the dialog or popover natively without running the action; it now does nothing until the page has hydrated, and then runs the action and closes. A Close without `action` is unchanged (a native invoker). Selectors on `[command]` no longer match such a button.
|
|
14
26
|
|
|
15
27
|
- New component [AlertDialog](components/alert-dialog.md) ([#167](https://github.com/uhyo/funstack-ui/issues/167)): a Dialog with `role="alertdialog"`, no light dismiss and focus on Cancel, whose `Action` runs an async action and closes when it resolves. Development messages of a Dialog part outside its Root now name the Root of its own namespace.
|
|
@@ -127,6 +139,7 @@ Changes an upgrade may notice, newest first. Each component page documents the c
|
|
|
127
139
|
- [Tooltip skip-delay](components/tooltip.md#skip-delay) ([#21](https://github.com/uhyo/funstack-ui/issues/21)).
|
|
128
140
|
- [Content Security Policy](concepts/content-security-policy.md): `STYLE_SHA256` and `<CSPProvider nonce>` ([#88](https://github.com/uhyo/funstack-ui/issues/88)).
|
|
129
141
|
- Directive-free variants of platform-native parts: considered and not built ([#19](https://github.com/uhyo/funstack-ui/issues/19)); [Server Components](concepts/server-components.md#js-free) defines "JS-free" and the form-control pages show the plain HTML alternative.
|
|
142
|
+
- Direction and locales: CSS `direction` is the one source, read per component at the event; a `locale` prop per Root, no provider ([#172](https://github.com/uhyo/funstack-ui/issues/172)). Guide: [Direction and locales](concepts/direction-and-locales.md).
|
|
130
143
|
|
|
131
144
|
## Next
|
|
132
145
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DialogCloseDetails, DialogCloseProps, DialogCloseState } from "../dialog/dialog-close.mjs";
|
|
2
|
+
//#region src/drawer/drawer-close.d.ts
|
|
3
|
+
/** State of `Drawer.Close`: Dialog's. */
|
|
4
|
+
export type DrawerCloseState = DialogCloseState;
|
|
5
|
+
/** Details passed to `Drawer.Close`'s `action`: Dialog's. */
|
|
6
|
+
export type DrawerCloseDetails = DialogCloseDetails;
|
|
7
|
+
/**
|
|
8
|
+
* Props of `Drawer.Close`: `Dialog.Close`'s.
|
|
9
|
+
*
|
|
10
|
+
* @see https://ui.funstack.work/components/drawer
|
|
11
|
+
*/
|
|
12
|
+
export type DrawerCloseProps = DialogCloseProps;
|
|
13
|
+
/**
|
|
14
|
+
* A close button: exactly `Dialog.Close` (`<button type="button" commandfor
|
|
15
|
+
* command="request-close">` in JS-free mode, a close through the Root in library mode; with
|
|
16
|
+
* `action`, the action runs first). Render one in every drawer: it closes it before hydration
|
|
17
|
+
* on a phone, and it is the alternative to the swipe (WCAG 2.5.1).
|
|
18
|
+
*
|
|
19
|
+
* @see https://ui.funstack.work/components/drawer
|
|
20
|
+
*/
|
|
21
|
+
export declare function DrawerClose(props: DrawerCloseProps): import("react").ReactNode;
|
|
22
|
+
export declare namespace DrawerClose {
|
|
23
|
+
var displayName: string;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//# sourceMappingURL=drawer-close.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawer-close.d.mts","names":[],"sources":["../../src/drawer/drawer-close.tsx"],"mappings":";;;YASY,mBAAmB;;YAGnB,qBAAqB;;;;;;YAOrB,mBAAmB;;;;;;;;;wBAUf,YAAY,OAAO,mCAAgB;yBAAnC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useDialogClose } from "../dialog/dialog-close.mjs";
|
|
3
|
+
//#region src/drawer/drawer-close.tsx
|
|
4
|
+
/**
|
|
5
|
+
* A close button: exactly `Dialog.Close` (`<button type="button" commandfor
|
|
6
|
+
* command="request-close">` in JS-free mode, a close through the Root in library mode; with
|
|
7
|
+
* `action`, the action runs first). Render one in every drawer: it closes it before hydration
|
|
8
|
+
* on a phone, and it is the alternative to the swipe (WCAG 2.5.1).
|
|
9
|
+
*
|
|
10
|
+
* @see https://ui.funstack.work/components/drawer
|
|
11
|
+
*/
|
|
12
|
+
function DrawerClose(props) {
|
|
13
|
+
return useDialogClose(props, { part: "Drawer.Close" });
|
|
14
|
+
}
|
|
15
|
+
DrawerClose.displayName = "DrawerClose";
|
|
16
|
+
//#endregion
|
|
17
|
+
export { DrawerClose };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=drawer-close.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawer-close.mjs","names":[],"sources":["../../src/drawer/drawer-close.tsx"],"sourcesContent":["\"use client\";\nimport { useDialogClose } from \"../dialog/dialog-close.js\";\nimport type {\n DialogCloseDetails,\n DialogCloseProps,\n DialogCloseState,\n} from \"../dialog/dialog-close.js\";\n\n/** State of `Drawer.Close`: Dialog's. */\nexport type DrawerCloseState = DialogCloseState;\n\n/** Details passed to `Drawer.Close`'s `action`: Dialog's. */\nexport type DrawerCloseDetails = DialogCloseDetails;\n\n/**\n * Props of `Drawer.Close`: `Dialog.Close`'s.\n *\n * @see https://ui.funstack.work/components/drawer\n */\nexport type DrawerCloseProps = DialogCloseProps;\n\n/**\n * A close button: exactly `Dialog.Close` (`<button type=\"button\" commandfor\n * command=\"request-close\">` in JS-free mode, a close through the Root in library mode; with\n * `action`, the action runs first). Render one in every drawer: it closes it before hydration\n * on a phone, and it is the alternative to the swipe (WCAG 2.5.1).\n *\n * @see https://ui.funstack.work/components/drawer\n */\nexport function DrawerClose(props: DrawerCloseProps) {\n return useDialogClose(props, { part: \"Drawer.Close\" });\n}\n\nDrawerClose.displayName = \"DrawerClose\";\n"],"mappings":";;;;;;;;;;;AA6BA,SAAgB,YAAY,OAAyB;CACnD,OAAO,eAAe,OAAO,EAAE,MAAM,eAAe,CAAC;AACvD;AAEA,YAAY,cAAc"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DialogDescriptionProps, DialogDescriptionState } from "../dialog/dialog-description.mjs";
|
|
2
|
+
//#region src/drawer/drawer-description.d.ts
|
|
3
|
+
/** State of `Drawer.Description`: Dialog's (the Popup's `open` and `modal`). */
|
|
4
|
+
export type DrawerDescriptionState = DialogDescriptionState;
|
|
5
|
+
/**
|
|
6
|
+
* Props of `Drawer.Description`: `Dialog.Description`'s.
|
|
7
|
+
*
|
|
8
|
+
* @see https://ui.funstack.work/components/drawer
|
|
9
|
+
*/
|
|
10
|
+
export type DrawerDescriptionProps = DialogDescriptionProps;
|
|
11
|
+
/**
|
|
12
|
+
* Describes the drawer: a `<p>` whose id the Popup references with `aria-describedby`.
|
|
13
|
+
*
|
|
14
|
+
* Owned key (conventions 1.2): `id`.
|
|
15
|
+
*
|
|
16
|
+
* @see https://ui.funstack.work/components/drawer
|
|
17
|
+
*/
|
|
18
|
+
export declare function DrawerDescription(props: DrawerDescriptionProps): import("react").ReactNode;
|
|
19
|
+
export declare namespace DrawerDescription {
|
|
20
|
+
var displayName: string;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//# sourceMappingURL=drawer-description.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawer-description.d.mts","names":[],"sources":["../../src/drawer/drawer-description.tsx"],"mappings":";;;YAQY,yBAAyB;;;;;;YAOzB,yBAAyB;;;;;;;;wBASrB,kBAAkB,OAAO,yCAAsB;yBAA/C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useDialogDescription } from "../dialog/dialog-description.mjs";
|
|
3
|
+
//#region src/drawer/drawer-description.tsx
|
|
4
|
+
/**
|
|
5
|
+
* Describes the drawer: a `<p>` whose id the Popup references with `aria-describedby`.
|
|
6
|
+
*
|
|
7
|
+
* Owned key (conventions 1.2): `id`.
|
|
8
|
+
*
|
|
9
|
+
* @see https://ui.funstack.work/components/drawer
|
|
10
|
+
*/
|
|
11
|
+
function DrawerDescription(props) {
|
|
12
|
+
return useDialogDescription(props, "Drawer");
|
|
13
|
+
}
|
|
14
|
+
DrawerDescription.displayName = "DrawerDescription";
|
|
15
|
+
//#endregion
|
|
16
|
+
export { DrawerDescription };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=drawer-description.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawer-description.mjs","names":[],"sources":["../../src/drawer/drawer-description.tsx"],"sourcesContent":["\"use client\";\nimport { useDialogDescription } from \"../dialog/dialog-description.js\";\nimport type {\n DialogDescriptionProps,\n DialogDescriptionState,\n} from \"../dialog/dialog-description.js\";\n\n/** State of `Drawer.Description`: Dialog's (the Popup's `open` and `modal`). */\nexport type DrawerDescriptionState = DialogDescriptionState;\n\n/**\n * Props of `Drawer.Description`: `Dialog.Description`'s.\n *\n * @see https://ui.funstack.work/components/drawer\n */\nexport type DrawerDescriptionProps = DialogDescriptionProps;\n\n/**\n * Describes the drawer: a `<p>` whose id the Popup references with `aria-describedby`.\n *\n * Owned key (conventions 1.2): `id`.\n *\n * @see https://ui.funstack.work/components/drawer\n */\nexport function DrawerDescription(props: DrawerDescriptionProps) {\n return useDialogDescription(props, \"Drawer\");\n}\n\nDrawerDescription.displayName = \"DrawerDescription\";\n"],"mappings":";;;;;;;;;;AAwBA,SAAgB,kBAAkB,OAA+B;CAC/D,OAAO,qBAAqB,OAAO,QAAQ;AAC7C;AAEA,kBAAkB,cAAc"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DialogFormProps, DialogFormState } from "../dialog/dialog-form.mjs";
|
|
2
|
+
//#region src/drawer/drawer-form.d.ts
|
|
3
|
+
/** State of `Drawer.Form`: Dialog's (`useFormStatus().pending` of this form). */
|
|
4
|
+
export type DrawerFormState = DialogFormState;
|
|
5
|
+
/**
|
|
6
|
+
* Props of `Drawer.Form`: `Dialog.Form`'s.
|
|
7
|
+
*
|
|
8
|
+
* @see https://ui.funstack.work/components/drawer
|
|
9
|
+
*/
|
|
10
|
+
export type DrawerFormProps = DialogFormProps;
|
|
11
|
+
/**
|
|
12
|
+
* A form whose submission closes the drawer: exactly `Dialog.Form` (`method="dialog"` without
|
|
13
|
+
* `action`; with a function `action`, the drawer closes when its transition settles).
|
|
14
|
+
*
|
|
15
|
+
* Owned keys (conventions 1.2): `method` (except with a string `action`), `action`.
|
|
16
|
+
*
|
|
17
|
+
* @see https://ui.funstack.work/components/drawer
|
|
18
|
+
*/
|
|
19
|
+
export declare function DrawerForm(props: DrawerFormProps): import("react").ReactNode;
|
|
20
|
+
export declare namespace DrawerForm {
|
|
21
|
+
var displayName: string;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//# sourceMappingURL=drawer-form.d.mts.map
|