@cahyo-dimas/freeday 3.22.0 → 3.23.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/CHANGELOG.md +54 -0
- package/COMPONENTS.md +50 -2
- package/README.id.md +1 -1
- package/README.md +1 -1
- package/adapters/react/useFreeday.js +31 -0
- package/adapters/vue/useFreeday.js +32 -1
- package/dist/freeday-tabs.js +76 -0
- package/dist/freeday.bundle.css +53 -0
- package/dist/freeday.css +53 -0
- package/dist/freeday.js +76 -0
- package/docs/getting-started.md +1 -1
- package/docs/reference-screen.html +1 -1
- package/package.json +2 -2
- package/src/components/link.css +14 -0
- package/src/components/tabs.css +38 -0
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,60 @@ benar. Perubahan seperti itu ditulis di bawah `### Changed: BREAKING (types)`
|
|
|
9
9
|
lama → tipe baru, dan cara menyempitkannya — bukan di bawah `### Added`, betapapun aditifnya dari
|
|
10
10
|
sisi kit.
|
|
11
11
|
|
|
12
|
+
## [3.23.0] - 2026-11-26
|
|
13
|
+
|
|
14
|
+
**Empat catatan dari app ronda (`CATATAN-FREEDAY.md` §29 sampai §31, dan satu temuan di §26).**
|
|
15
|
+
Formulir di komponen anak kini tervalidasi, tautan teks punya nama di daftar kelas, tab bisa berganti
|
|
16
|
+
menjadi pemilih di wadah sempit, dan layar rujukan tidak lagi kehilangan `<h1>`-nya di HP.
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- **`.fdy-tabs--picker-narrow` dan `.fdy-tabs__picker`** (`#121`, §31). Saat lebar tab itu sendiri
|
|
20
|
+
40rem atau kurang, satu combo berisi bagian yang sama menggantikan daftar tab. Ini container query,
|
|
21
|
+
jadi tab di laci 20rem pada desktop ikut berganti; di bawah Safari 16 aturan yang sama berlaku
|
|
22
|
+
menurut lebar viewport. Di jalur mentah `freeday-tabs.js` membangun pemilihnya, menamainya dengan
|
|
23
|
+
label tablist (atau `data-fdy-text-picker`, bawaan `Section`), dan menyinkronkan keduanya. Di Vue,
|
|
24
|
+
React dan Blazor pemilihnya `FdyCombo` yang diikat ke state yang sama, di dalam
|
|
25
|
+
`.fdy-tabs__picker` sebelum daftar. Daftar hanya disembunyikan bila ada pemilih di depannya, jadi
|
|
26
|
+
kelas ini tanpa pemilih tidak mengubah apa pun.
|
|
27
|
+
- **`.fdy-link` dan `.fdy-link--muted`** (`#120`, §30). `<a>` polos sudah lama dilukis sebagai tautan
|
|
28
|
+
oleh `base.css`, tetapi tidak ada kelas di `COMPONENTS.md` yang mengatakannya, dan daftar kelas itu
|
|
29
|
+
tertutup. `--muted` untuk kolom nama yang masing-masing membuka catatannya sendiri: tinta teks
|
|
30
|
+
dengan garis bawah redup, primary saat hover. Keduanya mempertahankan garis bawah saat diam, supaya
|
|
31
|
+
tautan tidak dikenali dari warna saja. Aturan tautan lawan tombol ditulis di sebelahnya.
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
- **`useFreeday` menjangkau DOM yang dipasang komponen anak belakangan** (`#119`, §29), di Vue dan
|
|
35
|
+
React. Formulir `data-fdy-validate` yang dirender anak di balik `v-if` atau kondisinya sendiri tidak
|
|
36
|
+
pernah terhidrasi: `onUpdated` dan efek React milik komponen yang berubah, yaitu anak, bukan
|
|
37
|
+
pemanggil `useFreeday`. Isian wajib yang kosong lolos terkirim. Kini `useFreeday` mengamati
|
|
38
|
+
subtree-nya dan menghidrasi ulang di microtask yang sama, sebelum layar dilukis. `takeRecords()`
|
|
39
|
+
membuang mutasi yang dibuat enhancer sendiri, jadi satu hidrasi tidak menjadwalkan hidrasi
|
|
40
|
+
berikutnya.
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
- **`docs/reference-screen.html` punya `<h1>` di setiap lebar** (`#122`, temuan di §26). Judul topbar
|
|
44
|
+
memakai `fdy-hide-below-md`, yang `display:none`, jadi di bawah 960px layar yang disalin setiap app
|
|
45
|
+
baru tidak punya `<h1>` sama sekali. Judulnya sudah terpotong rapi di topbar sempit; diukur muat di
|
|
46
|
+
320, 375 dan 412px tanpa gulir samping. `COMPONENTS.md` kini mengatakan bahwa utilitas `hide-below`
|
|
47
|
+
juga mengeluarkan isinya dari pohon aksesibilitas, dan bahwa judul yang tidak boleh terlihat memakai
|
|
48
|
+
`.fdy-visually-hidden`.
|
|
49
|
+
|
|
50
|
+
### Catatan
|
|
51
|
+
- **§31 tidak menjadi pembungkus bertipe `FdyTabs`.** Usulannya menyebut kunci, ARIA dan sinkronisasi
|
|
52
|
+
sebagai milik kit. Di jalur mentah memang demikian. Di stack bertipe, tab yang statenya dipegang
|
|
53
|
+
framework sudah sinkron lewat nilai yang sama, dan ARIA pemilihnya milik `FdyCombo`. Navigasi
|
|
54
|
+
papan ketik daftar tab tetap ditulis app sampai ada pemakai kedua yang membutuhkan pembungkusnya.
|
|
55
|
+
- Diuji di `browser/child-hydration.mjs` (Vue dan React: formulir anak tervalidasi, dan pengamat
|
|
56
|
+
diam sesudah halaman tenang), `browser/tabs-picker.mjs` (tiga kasus, masing-masing terbukti merah
|
|
57
|
+
oleh mutasi), uji kembar container query lawan cadangannya di `test/baseline.test.mjs`, dan
|
|
58
|
+
penjaga `<h1>` tersembunyi di `test/docs.test.mjs`. Keempatnya merah pada kode lama.
|
|
59
|
+
- **Harness peramban: bundle uji kini mendarat lewat rename** (`browser/harness.mjs`). Setiap berkas
|
|
60
|
+
spesifikasi berjalan di prosesnya sendiri dan memanggil `buildEntries()`, dan esbuild menulis dengan
|
|
61
|
+
mengosongkan berkas dulu. Terukur di laptop: 27 dari 90.477 pembacaan selama pembangunan ulang
|
|
62
|
+
serentak mendapati berkas 0 byte, dan halaman yang memuat skrip kosong tidak pernah terpasang. Di CI
|
|
63
|
+
itu muncul sebagai `cfl-narrow` yang gagal dua kali pada tag ini sementara commit yang sama lulus
|
|
64
|
+
di `main`. Sesudahnya 0 dari 102.634. Hanya alat uji; tidak ada yang terkirim di paket.
|
|
65
|
+
|
|
12
66
|
## [3.22.0] - 2026-11-24
|
|
13
67
|
|
|
14
68
|
**Sebuah app yang dipakai di HP punya tombol berukuran ibu jari, isian primary yang lebih dalam, dan
|
package/COMPONENTS.md
CHANGED
|
@@ -52,7 +52,12 @@ live docs.
|
|
|
52
52
|
never enhanced logs one `console.warn` naming it, with the element attached. The usual cause is
|
|
53
53
|
a `useFreeday()` ref on a wrapper that does not contain it. `freeday-unhydrated.js` does this,
|
|
54
54
|
and it ships in the root import.
|
|
55
|
-
|
|
55
|
+
**`useFreeday` also reaches DOM a child component mounts later**, such as a form a child renders
|
|
56
|
+
behind its own `v-if` or condition. It watches its subtree for added elements and rehydrates in
|
|
57
|
+
the same microtask, before the browser paints, so one call in a page component covers the dialogs
|
|
58
|
+
and panels its children open. Before 3.23.0 it ran only when the calling component itself
|
|
59
|
+
re-rendered, and a child's form went unvalidated without a sound.
|
|
60
|
+
**A `useFreeday(ref)` whose ref is still null at mount says so too.** That is a ref left off the
|
|
56
61
|
template, or one on an element behind `v-if` / a condition, and the call falls back to the whole
|
|
57
62
|
document: everything works, wider than asked, and other markup on the page can come to rely on
|
|
58
63
|
that scan unnoticed. It logs one `console.warn` per component. Put the ref on an element that is
|
|
@@ -429,6 +434,12 @@ One role per level of hierarchy. Never re-use a card title for a page title.
|
|
|
429
434
|
| `.fdy-text-success` · `.fdy-text-warning` · `.fdy-text-danger` | any | Inline text that carries **state** — a sentence, not a status. Use when a badge is wrong (it is prose) and an alert is wrong (it is one line inside a row): "Amount changed from X to Y", "No approver assigned". **Do not stack two colour roles** (`.fdy-help.fdy-text-warning`): both are single classes, so the one that happens to come later in the stylesheet wins — put the state class on its own element, and use `.fdy-help--error` for help text. |
|
|
430
435
|
| `.fdy-icon` | `<svg>` or a wrapper | Icon box: `1em` square, `flex:none`, so the glyph tracks the text beside it at every scale. The kit ships no paths — bring your own, use the box. |
|
|
431
436
|
| `.fdy-mono` | any | Tabular/monospace data (codes, amounts, ids). |
|
|
437
|
+
| `.fdy-link` · `.fdy-link--muted` | `<a>` (a router's link component renders one) | A text link, in a sentence or a table cell. A bare `<a>` already looks like `.fdy-link`; the class sets the underline the same way in every browser. `--muted` is for a column of names that each open their own record (accounts in a balance sheet, each linking to its ledger): text ink with a muted underline, primary on hover. Both keep the underline at rest, so a link is never told apart by colour alone. |
|
|
438
|
+
|
|
439
|
+
**A link goes somewhere; a button does something.** If activating it changes the URL, or would make
|
|
440
|
+
sense opened in a new tab, it is an `<a>` with `.fdy-link`, or a whole row as
|
|
441
|
+
`<a class="fdy-list__row">`. If it saves, deletes, opens a dialog or toggles a state, it is a
|
|
442
|
+
`<button>`, and `.fdy-btn--text` is the one that looks like text.
|
|
432
443
|
|
|
433
444
|
## Utilities
|
|
434
445
|
`.fdy-hidden` · `.fdy-visually-hidden` (screen-reader-only) · `.fdy-list-reset` (strip native
|
|
@@ -440,7 +451,10 @@ The browser's own `display:none` for `[hidden]` loses to any class that sets `di
|
|
|
440
451
|
layer restates it with `!important`. `hidden="until-found"` is left to the browser, which keeps it
|
|
441
452
|
findable with find-in-page.
|
|
442
453
|
|
|
443
|
-
Responsive display: `.fdy-hide-below-sm|md|lg` · `.fdy-hide-above-sm|md|lg`.
|
|
454
|
+
Responsive display: `.fdy-hide-below-sm|md|lg` · `.fdy-hide-above-sm|md|lg`. These are `display:none`, so
|
|
455
|
+
what they hide leaves the accessibility tree as well. Never put one on a heading: a page whose `<h1>`
|
|
456
|
+
is hidden below a width has no `<h1>` there. A title that must not be painted takes
|
|
457
|
+
`.fdy-visually-hidden`, which a screen reader still reads.
|
|
444
458
|
Breakpoints (min-width): `sm` 600 · `md` 960 · `lg` 1280 · `xl` 1920, importable as
|
|
445
459
|
`import { breakpoints } from '@cahyo-dimas/freeday/breakpoints'`.
|
|
446
460
|
|
|
@@ -2334,6 +2348,40 @@ settings screen whose sections are a list, not a strip.
|
|
|
2334
2348
|
is why the axis is read from the attribute and never from the painted layout.
|
|
2335
2349
|
- Measured in `browser/tabs-vertical.mjs`, which also holds the line that a strip with no
|
|
2336
2350
|
`aria-orientation` behaves and paints exactly as it did before the variant existed.
|
|
2351
|
+
- **A picker in a narrow container: `.fdy-tabs--picker-narrow`**, opt-in, on the strip or the
|
|
2352
|
+
vertical variant. When the tabs' own width is 40rem or less, a `.fdy-tabs__picker` (a wrapper
|
|
2353
|
+
holding one combo of the same sections) replaces the list. It is a container query, so tabs in a
|
|
2354
|
+
20rem drawer on a desktop switch too. Below Safari 16 the same rule applies by viewport width, which
|
|
2355
|
+
covers phones and leaves a narrow drawer on a wide screen with its list.
|
|
2356
|
+
- **Raw path:** add the class. `freeday-tabs.js` builds the picker first in the root, names it
|
|
2357
|
+
after the tablist's `aria-labelledby` or `aria-label` (else `data-fdy-text-picker`, default
|
|
2358
|
+
`Section`), and keeps tab and picker in step both ways. It needs `freeday-select.js`, which
|
|
2359
|
+
`dist/freeday.js` carries.
|
|
2360
|
+
- **Vue, React, Blazor:** tabs whose state lives in your framework render the picker themselves:
|
|
2361
|
+
a `FdyCombo` bound to the same value as the tabs, inside `<div class="fdy-tabs__picker">`, placed
|
|
2362
|
+
**before** `.fdy-tabs__list`.
|
|
2363
|
+
- The list is hidden only when a picker precedes it, so the class on tabs with no picker changes
|
|
2364
|
+
nothing, and no width can leave a screen without a way between its sections.
|
|
2365
|
+
- Use it when the labels are long or there are more than about four tabs. A strip of three short
|
|
2366
|
+
labels fits a phone as it is.
|
|
2367
|
+
|
|
2368
|
+
```html
|
|
2369
|
+
<div class="fdy-tabs fdy-tabs--vertical fdy-tabs--picker-narrow" data-fdy-tabs>
|
|
2370
|
+
<div class="fdy-tabs__list" role="tablist" aria-label="Settings sections">…</div>
|
|
2371
|
+
<div class="fdy-tabs__panel" role="tabpanel" …>…</div>
|
|
2372
|
+
</div>
|
|
2373
|
+
|
|
2374
|
+
<!-- Vue: the picker is yours, bound to the state the tabs already read. One label names both:
|
|
2375
|
+
FdyCombo takes ariaLabelledby, and an aria-label on it would land on its root, not its button. -->
|
|
2376
|
+
<span id="sections" class="fdy-visually-hidden">Settings sections</span>
|
|
2377
|
+
<div class="fdy-tabs fdy-tabs--vertical fdy-tabs--picker-narrow">
|
|
2378
|
+
<div class="fdy-tabs__picker">
|
|
2379
|
+
<FdyCombo v-model="tab" :options="sections" aria-labelledby="sections" />
|
|
2380
|
+
</div>
|
|
2381
|
+
<div class="fdy-tabs__list" role="tablist" aria-orientation="vertical" aria-labelledby="sections">…</div>
|
|
2382
|
+
…
|
|
2383
|
+
</div>
|
|
2384
|
+
```
|
|
2337
2385
|
|
|
2338
2386
|
---
|
|
2339
2387
|
|
package/README.id.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
> **Lebih banyak _free day_ buat dev. UI kit-nya sudah siap pakai.**
|
|
6
6
|
|
|
7
7
|
[](https://cahyo-dimas.github.io/freeday-ui-kit/)
|
|
8
|
-
[](https://github.com/cahyo-dimas/freeday-ui-kit/tree/v3.23.0)
|
|
9
9
|
|
|
10
10
|
UI KIT yang token-driven & framework-agnostic. Satu sumber kebenaran untuk warna, tipografi,
|
|
11
11
|
spasi, dan komponen. Blueprint: `docs/superpowers/specs/2026-07-21-freeday-ui-kit-design.md`.
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
> **More free days for devs. The UI kit is ready to use.**
|
|
6
6
|
|
|
7
7
|
[](https://cahyo-dimas.github.io/freeday-ui-kit/)
|
|
8
|
-
[](https://github.com/cahyo-dimas/freeday-ui-kit/tree/v3.23.0)
|
|
9
9
|
|
|
10
10
|
A token-driven, framework-agnostic UI kit. One source of truth for color, typography,
|
|
11
11
|
spacing, and components. Blueprint: `docs/superpowers/specs/2026-07-21-freeday-ui-kit-design.md`.
|
|
@@ -47,8 +47,19 @@ var EMPTY_REF = 'Freeday: useFreeday(ref) got a ref that is still null after the
|
|
|
47
47
|
+ 'element that is not rendered yet (a condition). Put the ref on an element that is always rendered, or '
|
|
48
48
|
+ 'call useFreeday() with no argument if the whole document is what you mean.';
|
|
49
49
|
|
|
50
|
+
/* True when a batch of mutation records added at least one element. Text edits and removals cannot
|
|
51
|
+
bring a new enhancer hook into the tree, so they do not cost a scan. */
|
|
52
|
+
function addedElement(records) {
|
|
53
|
+
for (var i = 0; i < records.length; i++) {
|
|
54
|
+
var nodes = records[i].addedNodes;
|
|
55
|
+
for (var j = 0; j < nodes.length; j++) if (nodes[j].nodeType === 1) return true;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
|
|
50
60
|
export function useFreeday(rootRef) {
|
|
51
61
|
var checked = useRef(false);
|
|
62
|
+
var observerRef = useRef(null);
|
|
52
63
|
var rehydrate = useCallback(function () {
|
|
53
64
|
var el = rootRef && rootRef.current ? rootRef.current : undefined;
|
|
54
65
|
var apis = freedayApis();
|
|
@@ -62,6 +73,26 @@ export function useFreeday(rootRef) {
|
|
|
62
73
|
if (rootRef && !rootRef.current) console.warn(EMPTY_REF);
|
|
63
74
|
}
|
|
64
75
|
rehydrate();
|
|
76
|
+
if (observerRef.current) observerRef.current.takeRecords();
|
|
65
77
|
});
|
|
78
|
+
/* DOM a CHILD component commits later is hydrated too. The effect above runs when THIS component
|
|
79
|
+
commits, and a child that renders a form behind its own state never makes the parent commit, so
|
|
80
|
+
the form's `data-fdy-validate` silently did nothing (CATATAN-FREEDAY §29). The observer rehydrates
|
|
81
|
+
in its callback, a microtask, so the widget is enhanced before the browser paints it raw, and
|
|
82
|
+
takeRecords() drops what the enhancers just built, so one rehydrate never schedules the next. */
|
|
83
|
+
useEffect(function () {
|
|
84
|
+
var target = rootRef && rootRef.current ? rootRef.current : document.body;
|
|
85
|
+
var observer = new MutationObserver(function (records) {
|
|
86
|
+
if (!addedElement(records)) return;
|
|
87
|
+
rehydrate();
|
|
88
|
+
observer.takeRecords();
|
|
89
|
+
});
|
|
90
|
+
observerRef.current = observer;
|
|
91
|
+
observer.observe(target, { childList: true, subtree: true });
|
|
92
|
+
return function () {
|
|
93
|
+
observer.disconnect();
|
|
94
|
+
observerRef.current = null;
|
|
95
|
+
};
|
|
96
|
+
}, [rehydrate]);
|
|
66
97
|
return { rehydrate: rehydrate };
|
|
67
98
|
}
|
|
@@ -21,11 +21,16 @@
|
|
|
21
21
|
* mount. Pass no argument, useFreeday(), when the whole document is what you mean; and put the ref
|
|
22
22
|
* on an element that is always rendered, not one behind v-if.
|
|
23
23
|
*
|
|
24
|
+
* DOM a CHILD component mounts later is hydrated too. Vue calls onUpdated on the component whose
|
|
25
|
+
* render changed, so a form behind a v-if in a child never reached the parent's hook, and its
|
|
26
|
+
* `data-fdy-validate` silently did nothing (CATATAN-FREEDAY §29). A MutationObserver on the subtree
|
|
27
|
+
* closes that: any element added under it triggers one rehydrate.
|
|
28
|
+
*
|
|
24
29
|
* Events come straight through as native bubbling CustomEvents, bind them with
|
|
25
30
|
* plain v-on (e.g. @fdy-cascade-change) and read event.detail. See index.d.ts
|
|
26
31
|
* for the detail types.
|
|
27
32
|
*/
|
|
28
|
-
import { onMounted, onUpdated, nextTick } from 'vue';
|
|
33
|
+
import { onBeforeUnmount, onMounted, onUpdated, nextTick } from 'vue';
|
|
29
34
|
|
|
30
35
|
// Discover Freeday enhancer namespaces once (all registered by the time an app
|
|
31
36
|
// mounts, since `import 'freeday'` runs first). Each exposes initAll(el?).
|
|
@@ -47,17 +52,43 @@ var EMPTY_REF = 'Freeday: useFreeday(ref) got a ref that is still null after mou
|
|
|
47
52
|
+ 'that is not rendered yet (v-if). Put the ref on an element that is always rendered, or call useFreeday() '
|
|
48
53
|
+ 'with no argument if the whole document is what you mean.';
|
|
49
54
|
|
|
55
|
+
/* True when a batch of mutation records added at least one element. Text edits and removals cannot
|
|
56
|
+
bring a new enhancer hook into the tree, so they do not cost a scan. */
|
|
57
|
+
function addedElement(records) {
|
|
58
|
+
for (var i = 0; i < records.length; i++) {
|
|
59
|
+
var nodes = records[i].addedNodes;
|
|
60
|
+
for (var j = 0; j < nodes.length; j++) if (nodes[j].nodeType === 1) return true;
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
|
|
50
65
|
export function useFreeday(rootRef) {
|
|
51
66
|
var apis = null;
|
|
67
|
+
var observer = null;
|
|
52
68
|
function rehydrate() {
|
|
53
69
|
if (!apis) apis = freedayApis();
|
|
54
70
|
var el = rootRef && 'value' in rootRef ? (rootRef.value || undefined) : undefined;
|
|
55
71
|
for (var i = 0; i < apis.length; i++) apis[i].initAll(el);
|
|
72
|
+
/* Whatever the enhancers just built is in the observer's queue now. Dropping it here is what
|
|
73
|
+
keeps one rehydrate from scheduling the next: initAll is synchronous, so every record it
|
|
74
|
+
caused is already queued when it returns. */
|
|
75
|
+
if (observer) observer.takeRecords();
|
|
56
76
|
}
|
|
57
77
|
onMounted(function () {
|
|
58
78
|
if (rootRef && 'value' in rootRef && !rootRef.value) console.warn(EMPTY_REF);
|
|
59
79
|
rehydrate();
|
|
80
|
+
/* In the callback itself rather than a frame later: the callback is a microtask, so a child's
|
|
81
|
+
widget is enhanced before the browser paints it raw. */
|
|
82
|
+
var target = rootRef && 'value' in rootRef && rootRef.value ? rootRef.value : document.body;
|
|
83
|
+
observer = new MutationObserver(function (records) {
|
|
84
|
+
if (addedElement(records)) rehydrate();
|
|
85
|
+
});
|
|
86
|
+
observer.observe(target, { childList: true, subtree: true });
|
|
60
87
|
});
|
|
61
88
|
onUpdated(function () { nextTick(rehydrate); });
|
|
89
|
+
onBeforeUnmount(function () {
|
|
90
|
+
if (observer) observer.disconnect();
|
|
91
|
+
observer = null;
|
|
92
|
+
});
|
|
62
93
|
return { rehydrate: rehydrate };
|
|
63
94
|
}
|
package/dist/freeday-tabs.js
CHANGED
|
@@ -10,10 +10,73 @@
|
|
|
10
10
|
* other pair is left entirely alone rather than bound as a second axis: Left and Right over a
|
|
11
11
|
* column of tabs belong to whatever else is on the page, and a widget that preventDefaults a key
|
|
12
12
|
* it has no meaning for has taken it from the page silently. Home/End answer on both.
|
|
13
|
+
*
|
|
14
|
+
* `.fdy-tabs--picker-narrow` on the root: this builds a `.fdy-tabs__picker` holding one combo of
|
|
15
|
+
* the same tabs, first in the root, and keeps the two in step both ways. tabs.css shows it instead
|
|
16
|
+
* of the list in a container of 40rem or less. It needs freeday-select.js (FreedayCombo), which
|
|
17
|
+
* dist/freeday.js carries; without it the list simply stays. A picker the author wrote is left alone.
|
|
13
18
|
*/
|
|
14
19
|
(function () {
|
|
15
20
|
'use strict';
|
|
16
21
|
|
|
22
|
+
/* The picker's accessible name when the tablist has none of its own to lend it. */
|
|
23
|
+
var TEXT = {
|
|
24
|
+
picker: 'Section'
|
|
25
|
+
};
|
|
26
|
+
function textOf(root, key) {
|
|
27
|
+
var kebab = key.replace(/[A-Z]/g, function (c) { return '-' + c.toLowerCase(); });
|
|
28
|
+
var custom = root.getAttribute('data-fdy-text-' + kebab);
|
|
29
|
+
return custom != null && custom !== '' ? custom : TEXT[key];
|
|
30
|
+
}
|
|
31
|
+
var uidSeq = 0;
|
|
32
|
+
function uid(p) { uidSeq += 1; return p + '-' + uidSeq; }
|
|
33
|
+
|
|
34
|
+
/* The combo freeday-select.js reads, built from the tabs themselves: one option per tab, its value
|
|
35
|
+
the tab's id. Named by the tablist's own label when it has one, so the two read as one control. */
|
|
36
|
+
function buildPicker(root, list, tabs) {
|
|
37
|
+
var wrap = document.createElement('div');
|
|
38
|
+
wrap.className = 'fdy-tabs__picker';
|
|
39
|
+
var combo = document.createElement('div');
|
|
40
|
+
combo.className = 'fdy-combo';
|
|
41
|
+
combo.setAttribute('data-fdy-combo', '');
|
|
42
|
+
var button = document.createElement('button');
|
|
43
|
+
button.type = 'button';
|
|
44
|
+
button.className = 'fdy-combo__button';
|
|
45
|
+
button.setAttribute('role', 'combobox');
|
|
46
|
+
button.setAttribute('aria-haspopup', 'listbox');
|
|
47
|
+
button.setAttribute('aria-expanded', 'false');
|
|
48
|
+
var value = document.createElement('span');
|
|
49
|
+
value.className = 'fdy-combo__value';
|
|
50
|
+
value.id = uid('fdy-tabs-picker-value');
|
|
51
|
+
button.appendChild(value);
|
|
52
|
+
var labelledby = list ? list.getAttribute('aria-labelledby') : null;
|
|
53
|
+
var label = list ? list.getAttribute('aria-label') : null;
|
|
54
|
+
if (labelledby) button.setAttribute('aria-labelledby', labelledby + ' ' + value.id);
|
|
55
|
+
else button.setAttribute('aria-label', label || textOf(root, 'picker'));
|
|
56
|
+
var listbox = document.createElement('ul');
|
|
57
|
+
listbox.className = 'fdy-combo__listbox';
|
|
58
|
+
listbox.setAttribute('role', 'listbox');
|
|
59
|
+
listbox.hidden = true;
|
|
60
|
+
tabs.forEach(function (tab) {
|
|
61
|
+
if (!tab.id) tab.id = uid('fdy-tab');
|
|
62
|
+
var opt = document.createElement('li');
|
|
63
|
+
opt.className = 'fdy-combo__option';
|
|
64
|
+
opt.setAttribute('role', 'option');
|
|
65
|
+
opt.setAttribute('data-value', tab.id);
|
|
66
|
+
opt.setAttribute('aria-selected', 'false');
|
|
67
|
+
var check = document.createElement('span');
|
|
68
|
+
check.className = 'fdy-combo__check';
|
|
69
|
+
opt.appendChild(check);
|
|
70
|
+
opt.appendChild(document.createTextNode((tab.textContent || '').replace(/\s+/g, ' ').trim()));
|
|
71
|
+
listbox.appendChild(opt);
|
|
72
|
+
});
|
|
73
|
+
combo.appendChild(button);
|
|
74
|
+
combo.appendChild(listbox);
|
|
75
|
+
wrap.appendChild(combo);
|
|
76
|
+
root.insertBefore(wrap, root.firstChild);
|
|
77
|
+
return combo;
|
|
78
|
+
}
|
|
79
|
+
|
|
17
80
|
function initTabs(root) {
|
|
18
81
|
if (root.dataset.fdyTabsReady === '1') return;
|
|
19
82
|
if (root.closest('[data-fdy-ignore]')) return;
|
|
@@ -31,6 +94,17 @@
|
|
|
31
94
|
list.setAttribute('aria-orientation', 'vertical');
|
|
32
95
|
}
|
|
33
96
|
var vertical = list !== null && list.getAttribute('aria-orientation') === 'vertical';
|
|
97
|
+
var picker = null;
|
|
98
|
+
if (root.classList.contains('fdy-tabs--picker-narrow') && window.FreedayCombo
|
|
99
|
+
&& root.querySelector(':scope > .fdy-tabs__picker') === null) {
|
|
100
|
+
picker = buildPicker(root, list, tabs);
|
|
101
|
+
window.FreedayCombo.init(picker);
|
|
102
|
+
picker.addEventListener('fdy-change', function (e) {
|
|
103
|
+
var id = e.detail && e.detail.value;
|
|
104
|
+
var tab = tabs.filter(function (t) { return t.id === id; })[0];
|
|
105
|
+
if (tab) select(tab, false);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
34
108
|
var NEXT_KEY = vertical ? 'ArrowDown' : 'ArrowRight';
|
|
35
109
|
var PREV_KEY = vertical ? 'ArrowUp' : 'ArrowLeft';
|
|
36
110
|
|
|
@@ -46,6 +120,8 @@
|
|
|
46
120
|
var panel = panelFor(t);
|
|
47
121
|
if (panel) panel.hidden = !on;
|
|
48
122
|
});
|
|
123
|
+
/* Silent: setValue raises no fdy-change, so the picker cannot echo a pick back here. */
|
|
124
|
+
if (picker) window.FreedayCombo.setValue(picker, tab.id);
|
|
49
125
|
if (focus) tab.focus();
|
|
50
126
|
}
|
|
51
127
|
|
package/dist/freeday.bundle.css
CHANGED
|
@@ -3489,6 +3489,21 @@ fieldset.fdy-field>legend{padding:0;float:none;margin-bottom:var(--space-2);}
|
|
|
3489
3489
|
/* Freeday. Keyboard key */
|
|
3490
3490
|
.fdy-kbd{display:inline-flex;align-items:center;justify-content:center;min-width:1.5rem;height:1.5rem;padding:0 var(--space-2);font-family:var(--font-mono);font-size:var(--text-xs);color:var(--color-text);background:var(--color-surface-2);border:var(--bw) solid var(--color-border-strong);border-bottom-width:2px;border-radius:var(--radius-sm);}
|
|
3491
3491
|
|
|
3492
|
+
/* Freeday. Text link
|
|
3493
|
+
* A bare `<a>` is already a link here: base.css paints it `--color-primary-strong` and the browser
|
|
3494
|
+
* underlines it. `.fdy-link` names that look so it can be found in COMPONENTS.md, sets the underline
|
|
3495
|
+
* the same way in every browser, and is the base the muted variant modifies.
|
|
3496
|
+
*
|
|
3497
|
+
* The underline stays in both, at rest. A link told apart by colour alone fails WCAG 1.4.1, and in
|
|
3498
|
+
* the muted variant there is no colour to tell it by. Hover thickens it; focus is base.css's ring. */
|
|
3499
|
+
.fdy-link{color:var(--color-primary-strong);text-decoration-line:underline;text-underline-offset:.2em;text-decoration-thickness:.06em;}
|
|
3500
|
+
.fdy-link:hover{text-decoration-thickness:.12em;}
|
|
3501
|
+
/* For a column of names that each open their own record: a table of accounts, each linking to its
|
|
3502
|
+
ledger. Twenty primary-coloured links in one column outweigh the numbers beside them. The text
|
|
3503
|
+
ink with a muted underline keeps every name reading as a link without competing with the data. */
|
|
3504
|
+
.fdy-link--muted{color:var(--color-text);text-decoration-color:var(--color-text-muted);}
|
|
3505
|
+
.fdy-link--muted:hover{color:var(--color-primary-strong);text-decoration-color:currentColor;}
|
|
3506
|
+
|
|
3492
3507
|
/* Freeday. List: the FLAT row container.
|
|
3493
3508
|
*
|
|
3494
3509
|
* USAGE.md §3 puts list rows among the surfaces that should be flat, but until now the only
|
|
@@ -4023,6 +4038,44 @@ fieldset.fdy-field>legend{padding:0;float:none;margin-bottom:var(--space-2);}
|
|
|
4023
4038
|
.fdy-tabs--vertical .fdy-tabs__tab[aria-selected="true"],.fdy-tabs--vertical .fdy-tabs__tab[aria-current="page"]{background:var(--color-primary-soft);color:var(--color-primary-strong);font-weight:var(--weight-semibold);}
|
|
4024
4039
|
.fdy-tabs--vertical .fdy-tabs__panel{flex:1;min-width:0;padding:0;}
|
|
4025
4040
|
|
|
4041
|
+
/* PICKER IN A NARROW CONTAINER: `.fdy-tabs--picker-narrow`, opt-in, on either variant.
|
|
4042
|
+
*
|
|
4043
|
+
* At 40rem of its own width or less, the tab list gives way to `.fdy-tabs__picker`, a wrapper
|
|
4044
|
+
* holding one combo of the same sections. Six tabs with real labels do not fit a phone as a strip,
|
|
4045
|
+
* and as a column they fill the screen before the panel starts. A container query rather than a
|
|
4046
|
+
* viewport one, because the same tabs can sit in a page or in a 20rem drawer.
|
|
4047
|
+
*
|
|
4048
|
+
* The list is hidden only through `.fdy-tabs__picker ~ .fdy-tabs__list`, so the picker has to come
|
|
4049
|
+
* BEFORE the list, and tabs with no picker in them keep their list at every width: the class alone
|
|
4050
|
+
* can never leave a screen with no way between its sections. On the raw path freeday-tabs.js builds
|
|
4051
|
+
* the picker; in a typed stack it is a `FdyCombo` bound to the same state as the tabs.
|
|
4052
|
+
*
|
|
4053
|
+
* `flex-wrap` is what makes the vertical variant work: a container query styles what is inside the
|
|
4054
|
+
* container, never the container itself, so `.fdy-tabs--vertical` stays a flex row. The picker takes
|
|
4055
|
+
* a whole line and the panel wraps under it. While the list shows, the panel's `min-width:0` means it
|
|
4056
|
+
* never wraps.
|
|
4057
|
+
*
|
|
4058
|
+
* 40rem: a column of labels and a panel worth reading do not both fit under it. Below Safari 16
|
|
4059
|
+
* there are no container queries, and the same body applies by viewport width instead; that answers
|
|
4060
|
+
* every phone, and leaves tabs in a narrow drawer on a wide screen as lists. The two bodies are
|
|
4061
|
+
* copies, compared in test/baseline.test.mjs. */
|
|
4062
|
+
.fdy-tabs__picker{display:none;}
|
|
4063
|
+
.fdy-tabs--picker-narrow{flex-wrap:wrap;}
|
|
4064
|
+
.fdy-tabs__picker > .fdy-combo{max-width:none;}
|
|
4065
|
+
@supports (container-type:inline-size){
|
|
4066
|
+
.fdy-tabs--picker-narrow{container:fdy-tabs / inline-size;}
|
|
4067
|
+
@container fdy-tabs (max-width: 40rem){
|
|
4068
|
+
.fdy-tabs--picker-narrow > .fdy-tabs__picker{display:block;flex:0 0 100%;}
|
|
4069
|
+
.fdy-tabs--picker-narrow > .fdy-tabs__picker ~ .fdy-tabs__list{display:none;}
|
|
4070
|
+
}
|
|
4071
|
+
}
|
|
4072
|
+
@supports not (container-type:inline-size){
|
|
4073
|
+
@media (max-width:40rem){
|
|
4074
|
+
.fdy-tabs--picker-narrow > .fdy-tabs__picker{display:block;flex:0 0 100%;}
|
|
4075
|
+
.fdy-tabs--picker-narrow > .fdy-tabs__picker ~ .fdy-tabs__list{display:none;}
|
|
4076
|
+
}
|
|
4077
|
+
}
|
|
4078
|
+
|
|
4026
4079
|
/* Freeday. Timeline (vertical event feed: dot markers on a connector line). Pure CSS. */
|
|
4027
4080
|
.fdy-timeline{list-style:none;margin:0;padding:0;}
|
|
4028
4081
|
.fdy-timeline__item{position:relative;padding:0 0 var(--space-5) var(--space-6);border-left:2px solid var(--color-border);}
|
package/dist/freeday.css
CHANGED
|
@@ -1653,6 +1653,21 @@ fieldset.fdy-field>legend{padding:0;float:none;margin-bottom:var(--space-2);}
|
|
|
1653
1653
|
/* Freeday. Keyboard key */
|
|
1654
1654
|
.fdy-kbd{display:inline-flex;align-items:center;justify-content:center;min-width:1.5rem;height:1.5rem;padding:0 var(--space-2);font-family:var(--font-mono);font-size:var(--text-xs);color:var(--color-text);background:var(--color-surface-2);border:var(--bw) solid var(--color-border-strong);border-bottom-width:2px;border-radius:var(--radius-sm);}
|
|
1655
1655
|
|
|
1656
|
+
/* Freeday. Text link
|
|
1657
|
+
* A bare `<a>` is already a link here: base.css paints it `--color-primary-strong` and the browser
|
|
1658
|
+
* underlines it. `.fdy-link` names that look so it can be found in COMPONENTS.md, sets the underline
|
|
1659
|
+
* the same way in every browser, and is the base the muted variant modifies.
|
|
1660
|
+
*
|
|
1661
|
+
* The underline stays in both, at rest. A link told apart by colour alone fails WCAG 1.4.1, and in
|
|
1662
|
+
* the muted variant there is no colour to tell it by. Hover thickens it; focus is base.css's ring. */
|
|
1663
|
+
.fdy-link{color:var(--color-primary-strong);text-decoration-line:underline;text-underline-offset:.2em;text-decoration-thickness:.06em;}
|
|
1664
|
+
.fdy-link:hover{text-decoration-thickness:.12em;}
|
|
1665
|
+
/* For a column of names that each open their own record: a table of accounts, each linking to its
|
|
1666
|
+
ledger. Twenty primary-coloured links in one column outweigh the numbers beside them. The text
|
|
1667
|
+
ink with a muted underline keeps every name reading as a link without competing with the data. */
|
|
1668
|
+
.fdy-link--muted{color:var(--color-text);text-decoration-color:var(--color-text-muted);}
|
|
1669
|
+
.fdy-link--muted:hover{color:var(--color-primary-strong);text-decoration-color:currentColor;}
|
|
1670
|
+
|
|
1656
1671
|
/* Freeday. List: the FLAT row container.
|
|
1657
1672
|
*
|
|
1658
1673
|
* USAGE.md §3 puts list rows among the surfaces that should be flat, but until now the only
|
|
@@ -2187,6 +2202,44 @@ fieldset.fdy-field>legend{padding:0;float:none;margin-bottom:var(--space-2);}
|
|
|
2187
2202
|
.fdy-tabs--vertical .fdy-tabs__tab[aria-selected="true"],.fdy-tabs--vertical .fdy-tabs__tab[aria-current="page"]{background:var(--color-primary-soft);color:var(--color-primary-strong);font-weight:var(--weight-semibold);}
|
|
2188
2203
|
.fdy-tabs--vertical .fdy-tabs__panel{flex:1;min-width:0;padding:0;}
|
|
2189
2204
|
|
|
2205
|
+
/* PICKER IN A NARROW CONTAINER: `.fdy-tabs--picker-narrow`, opt-in, on either variant.
|
|
2206
|
+
*
|
|
2207
|
+
* At 40rem of its own width or less, the tab list gives way to `.fdy-tabs__picker`, a wrapper
|
|
2208
|
+
* holding one combo of the same sections. Six tabs with real labels do not fit a phone as a strip,
|
|
2209
|
+
* and as a column they fill the screen before the panel starts. A container query rather than a
|
|
2210
|
+
* viewport one, because the same tabs can sit in a page or in a 20rem drawer.
|
|
2211
|
+
*
|
|
2212
|
+
* The list is hidden only through `.fdy-tabs__picker ~ .fdy-tabs__list`, so the picker has to come
|
|
2213
|
+
* BEFORE the list, and tabs with no picker in them keep their list at every width: the class alone
|
|
2214
|
+
* can never leave a screen with no way between its sections. On the raw path freeday-tabs.js builds
|
|
2215
|
+
* the picker; in a typed stack it is a `FdyCombo` bound to the same state as the tabs.
|
|
2216
|
+
*
|
|
2217
|
+
* `flex-wrap` is what makes the vertical variant work: a container query styles what is inside the
|
|
2218
|
+
* container, never the container itself, so `.fdy-tabs--vertical` stays a flex row. The picker takes
|
|
2219
|
+
* a whole line and the panel wraps under it. While the list shows, the panel's `min-width:0` means it
|
|
2220
|
+
* never wraps.
|
|
2221
|
+
*
|
|
2222
|
+
* 40rem: a column of labels and a panel worth reading do not both fit under it. Below Safari 16
|
|
2223
|
+
* there are no container queries, and the same body applies by viewport width instead; that answers
|
|
2224
|
+
* every phone, and leaves tabs in a narrow drawer on a wide screen as lists. The two bodies are
|
|
2225
|
+
* copies, compared in test/baseline.test.mjs. */
|
|
2226
|
+
.fdy-tabs__picker{display:none;}
|
|
2227
|
+
.fdy-tabs--picker-narrow{flex-wrap:wrap;}
|
|
2228
|
+
.fdy-tabs__picker > .fdy-combo{max-width:none;}
|
|
2229
|
+
@supports (container-type:inline-size){
|
|
2230
|
+
.fdy-tabs--picker-narrow{container:fdy-tabs / inline-size;}
|
|
2231
|
+
@container fdy-tabs (max-width: 40rem){
|
|
2232
|
+
.fdy-tabs--picker-narrow > .fdy-tabs__picker{display:block;flex:0 0 100%;}
|
|
2233
|
+
.fdy-tabs--picker-narrow > .fdy-tabs__picker ~ .fdy-tabs__list{display:none;}
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
@supports not (container-type:inline-size){
|
|
2237
|
+
@media (max-width:40rem){
|
|
2238
|
+
.fdy-tabs--picker-narrow > .fdy-tabs__picker{display:block;flex:0 0 100%;}
|
|
2239
|
+
.fdy-tabs--picker-narrow > .fdy-tabs__picker ~ .fdy-tabs__list{display:none;}
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2190
2243
|
/* Freeday. Timeline (vertical event feed: dot markers on a connector line). Pure CSS. */
|
|
2191
2244
|
.fdy-timeline{list-style:none;margin:0;padding:0;}
|
|
2192
2245
|
.fdy-timeline__item{position:relative;padding:0 0 var(--space-5) var(--space-6);border-left:2px solid var(--color-border);}
|
package/dist/freeday.js
CHANGED
|
@@ -5361,10 +5361,73 @@
|
|
|
5361
5361
|
* other pair is left entirely alone rather than bound as a second axis: Left and Right over a
|
|
5362
5362
|
* column of tabs belong to whatever else is on the page, and a widget that preventDefaults a key
|
|
5363
5363
|
* it has no meaning for has taken it from the page silently. Home/End answer on both.
|
|
5364
|
+
*
|
|
5365
|
+
* `.fdy-tabs--picker-narrow` on the root: this builds a `.fdy-tabs__picker` holding one combo of
|
|
5366
|
+
* the same tabs, first in the root, and keeps the two in step both ways. tabs.css shows it instead
|
|
5367
|
+
* of the list in a container of 40rem or less. It needs freeday-select.js (FreedayCombo), which
|
|
5368
|
+
* dist/freeday.js carries; without it the list simply stays. A picker the author wrote is left alone.
|
|
5364
5369
|
*/
|
|
5365
5370
|
(function () {
|
|
5366
5371
|
'use strict';
|
|
5367
5372
|
|
|
5373
|
+
/* The picker's accessible name when the tablist has none of its own to lend it. */
|
|
5374
|
+
var TEXT = {
|
|
5375
|
+
picker: 'Section'
|
|
5376
|
+
};
|
|
5377
|
+
function textOf(root, key) {
|
|
5378
|
+
var kebab = key.replace(/[A-Z]/g, function (c) { return '-' + c.toLowerCase(); });
|
|
5379
|
+
var custom = root.getAttribute('data-fdy-text-' + kebab);
|
|
5380
|
+
return custom != null && custom !== '' ? custom : TEXT[key];
|
|
5381
|
+
}
|
|
5382
|
+
var uidSeq = 0;
|
|
5383
|
+
function uid(p) { uidSeq += 1; return p + '-' + uidSeq; }
|
|
5384
|
+
|
|
5385
|
+
/* The combo freeday-select.js reads, built from the tabs themselves: one option per tab, its value
|
|
5386
|
+
the tab's id. Named by the tablist's own label when it has one, so the two read as one control. */
|
|
5387
|
+
function buildPicker(root, list, tabs) {
|
|
5388
|
+
var wrap = document.createElement('div');
|
|
5389
|
+
wrap.className = 'fdy-tabs__picker';
|
|
5390
|
+
var combo = document.createElement('div');
|
|
5391
|
+
combo.className = 'fdy-combo';
|
|
5392
|
+
combo.setAttribute('data-fdy-combo', '');
|
|
5393
|
+
var button = document.createElement('button');
|
|
5394
|
+
button.type = 'button';
|
|
5395
|
+
button.className = 'fdy-combo__button';
|
|
5396
|
+
button.setAttribute('role', 'combobox');
|
|
5397
|
+
button.setAttribute('aria-haspopup', 'listbox');
|
|
5398
|
+
button.setAttribute('aria-expanded', 'false');
|
|
5399
|
+
var value = document.createElement('span');
|
|
5400
|
+
value.className = 'fdy-combo__value';
|
|
5401
|
+
value.id = uid('fdy-tabs-picker-value');
|
|
5402
|
+
button.appendChild(value);
|
|
5403
|
+
var labelledby = list ? list.getAttribute('aria-labelledby') : null;
|
|
5404
|
+
var label = list ? list.getAttribute('aria-label') : null;
|
|
5405
|
+
if (labelledby) button.setAttribute('aria-labelledby', labelledby + ' ' + value.id);
|
|
5406
|
+
else button.setAttribute('aria-label', label || textOf(root, 'picker'));
|
|
5407
|
+
var listbox = document.createElement('ul');
|
|
5408
|
+
listbox.className = 'fdy-combo__listbox';
|
|
5409
|
+
listbox.setAttribute('role', 'listbox');
|
|
5410
|
+
listbox.hidden = true;
|
|
5411
|
+
tabs.forEach(function (tab) {
|
|
5412
|
+
if (!tab.id) tab.id = uid('fdy-tab');
|
|
5413
|
+
var opt = document.createElement('li');
|
|
5414
|
+
opt.className = 'fdy-combo__option';
|
|
5415
|
+
opt.setAttribute('role', 'option');
|
|
5416
|
+
opt.setAttribute('data-value', tab.id);
|
|
5417
|
+
opt.setAttribute('aria-selected', 'false');
|
|
5418
|
+
var check = document.createElement('span');
|
|
5419
|
+
check.className = 'fdy-combo__check';
|
|
5420
|
+
opt.appendChild(check);
|
|
5421
|
+
opt.appendChild(document.createTextNode((tab.textContent || '').replace(/\s+/g, ' ').trim()));
|
|
5422
|
+
listbox.appendChild(opt);
|
|
5423
|
+
});
|
|
5424
|
+
combo.appendChild(button);
|
|
5425
|
+
combo.appendChild(listbox);
|
|
5426
|
+
wrap.appendChild(combo);
|
|
5427
|
+
root.insertBefore(wrap, root.firstChild);
|
|
5428
|
+
return combo;
|
|
5429
|
+
}
|
|
5430
|
+
|
|
5368
5431
|
function initTabs(root) {
|
|
5369
5432
|
if (root.dataset.fdyTabsReady === '1') return;
|
|
5370
5433
|
if (root.closest('[data-fdy-ignore]')) return;
|
|
@@ -5382,6 +5445,17 @@
|
|
|
5382
5445
|
list.setAttribute('aria-orientation', 'vertical');
|
|
5383
5446
|
}
|
|
5384
5447
|
var vertical = list !== null && list.getAttribute('aria-orientation') === 'vertical';
|
|
5448
|
+
var picker = null;
|
|
5449
|
+
if (root.classList.contains('fdy-tabs--picker-narrow') && window.FreedayCombo
|
|
5450
|
+
&& root.querySelector(':scope > .fdy-tabs__picker') === null) {
|
|
5451
|
+
picker = buildPicker(root, list, tabs);
|
|
5452
|
+
window.FreedayCombo.init(picker);
|
|
5453
|
+
picker.addEventListener('fdy-change', function (e) {
|
|
5454
|
+
var id = e.detail && e.detail.value;
|
|
5455
|
+
var tab = tabs.filter(function (t) { return t.id === id; })[0];
|
|
5456
|
+
if (tab) select(tab, false);
|
|
5457
|
+
});
|
|
5458
|
+
}
|
|
5385
5459
|
var NEXT_KEY = vertical ? 'ArrowDown' : 'ArrowRight';
|
|
5386
5460
|
var PREV_KEY = vertical ? 'ArrowUp' : 'ArrowLeft';
|
|
5387
5461
|
|
|
@@ -5397,6 +5471,8 @@
|
|
|
5397
5471
|
var panel = panelFor(t);
|
|
5398
5472
|
if (panel) panel.hidden = !on;
|
|
5399
5473
|
});
|
|
5474
|
+
/* Silent: setValue raises no fdy-change, so the picker cannot echo a pick back here. */
|
|
5475
|
+
if (picker) window.FreedayCombo.setValue(picker, tab.id);
|
|
5400
5476
|
if (focus) tab.focus();
|
|
5401
5477
|
}
|
|
5402
5478
|
|
package/docs/getting-started.md
CHANGED
|
@@ -198,7 +198,7 @@ live docs also have a copy button per component.
|
|
|
198
198
|
```bash
|
|
199
199
|
npm i @cahyo-dimas/freeday
|
|
200
200
|
```
|
|
201
|
-
Lands in `package.json` as `"@cahyo-dimas/freeday": "^3.
|
|
201
|
+
Lands in `package.json` as `"@cahyo-dimas/freeday": "^3.23.0"` (public npm package). `dist/` is
|
|
202
202
|
committed and published → no build step; `npm ci` runs without auth.
|
|
203
203
|
|
|
204
204
|
### 2. Import the CSS + enhancers **once** in your entry (`src/main.ts`)
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
|
|
82
82
|
<!-- .fdy-app__title carries an auto-spacer (margin-right:auto): everything after it sits at
|
|
83
83
|
the right edge. -->
|
|
84
|
-
<h1 class="fdy-app__title
|
|
84
|
+
<h1 class="fdy-app__title">Receivables</h1>
|
|
85
85
|
|
|
86
86
|
<div class="fdy-input-group fdy-hide-below-md" style="max-width:14rem">
|
|
87
87
|
<span class="fdy-input-group__addon fdy-input-group__addon--icon">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cahyo-dimas/freeday",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.23.0",
|
|
4
4
|
"description": "Freeday: token-driven, framework-agnostic UI KIT (design source-of-truth).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"scripts": {
|
|
98
98
|
"build": "node tokens/build.mjs",
|
|
99
99
|
"test": "node --test",
|
|
100
|
-
"test:browser": "node --test --test-concurrency=3 browser/color-mix.mjs browser/vanilla.mjs browser/adapter.mjs browser/layout.mjs browser/theme.mjs browser/axis-nesting.mjs browser/palette-os-dark.mjs browser/primary-fill.mjs browser/state.mjs browser/root-init.mjs browser/upload-states.mjs browser/number.mjs browser/card-stretch.mjs browser/stretch-warn.mjs browser/hidden-attr.mjs browser/form-grid-rows.mjs browser/theme-pref.mjs browser/text-override.mjs browser/control-heights.mjs browser/field-width.mjs browser/cfl-multi.mjs browser/cfl-dialog-only.mjs browser/crowding.mjs browser/over-dialog.mjs browser/chart-scale.mjs browser/overlay-stack.mjs browser/chart-a11y.mjs browser/app-shell.mjs browser/bottom-nav.mjs browser/actionbar.mjs browser/picker-states.mjs browser/tabs-strip.mjs browser/tabs-vertical.mjs browser/menu-align.mjs browser/cfl-narrow.mjs browser/form-reveal.mjs browser/confirm-search-copy.mjs browser/daterange-settled.mjs browser/daterange-single.mjs browser/display-parts.mjs browser/table-empty.mjs browser/table-footer-text.mjs browser/month-mode.mjs browser/monthpicker.mjs browser/page-columns.mjs browser/table-hover.mjs browser/typed-popover.mjs browser/filter-parity.mjs browser/filter-wrap.mjs browser/filter-stack.mjs browser/timepicker.mjs browser/form-kit-required.mjs browser/form-required-rest.mjs browser/autocomplete-open.mjs browser/picker-in-modal.mjs browser/harness-contract.mjs browser/app-owned.mjs browser/sortable.mjs browser/modal-phone.mjs browser/empty-ref.mjs browser/stack-standalone.mjs",
|
|
100
|
+
"test:browser": "node --test --test-concurrency=3 browser/color-mix.mjs browser/vanilla.mjs browser/adapter.mjs browser/layout.mjs browser/theme.mjs browser/axis-nesting.mjs browser/palette-os-dark.mjs browser/primary-fill.mjs browser/state.mjs browser/root-init.mjs browser/upload-states.mjs browser/number.mjs browser/card-stretch.mjs browser/stretch-warn.mjs browser/hidden-attr.mjs browser/form-grid-rows.mjs browser/theme-pref.mjs browser/text-override.mjs browser/control-heights.mjs browser/field-width.mjs browser/cfl-multi.mjs browser/cfl-dialog-only.mjs browser/crowding.mjs browser/over-dialog.mjs browser/chart-scale.mjs browser/overlay-stack.mjs browser/chart-a11y.mjs browser/app-shell.mjs browser/bottom-nav.mjs browser/actionbar.mjs browser/picker-states.mjs browser/tabs-strip.mjs browser/tabs-vertical.mjs browser/menu-align.mjs browser/cfl-narrow.mjs browser/form-reveal.mjs browser/confirm-search-copy.mjs browser/daterange-settled.mjs browser/daterange-single.mjs browser/child-hydration.mjs browser/tabs-picker.mjs browser/display-parts.mjs browser/table-empty.mjs browser/table-footer-text.mjs browser/month-mode.mjs browser/monthpicker.mjs browser/page-columns.mjs browser/table-hover.mjs browser/typed-popover.mjs browser/filter-parity.mjs browser/filter-wrap.mjs browser/filter-stack.mjs browser/timepicker.mjs browser/form-kit-required.mjs browser/form-required-rest.mjs browser/autocomplete-open.mjs browser/picker-in-modal.mjs browser/harness-contract.mjs browser/app-owned.mjs browser/sortable.mjs browser/modal-phone.mjs browser/empty-ref.mjs browser/stack-standalone.mjs",
|
|
101
101
|
"prepack": "node tokens/build.mjs",
|
|
102
102
|
"version": "node tokens/build.mjs && git add dist",
|
|
103
103
|
"typecheck:react": "tsc -p adapters/react/tsconfig.json --noEmit",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* Freeday. Text link
|
|
2
|
+
* A bare `<a>` is already a link here: base.css paints it `--color-primary-strong` and the browser
|
|
3
|
+
* underlines it. `.fdy-link` names that look so it can be found in COMPONENTS.md, sets the underline
|
|
4
|
+
* the same way in every browser, and is the base the muted variant modifies.
|
|
5
|
+
*
|
|
6
|
+
* The underline stays in both, at rest. A link told apart by colour alone fails WCAG 1.4.1, and in
|
|
7
|
+
* the muted variant there is no colour to tell it by. Hover thickens it; focus is base.css's ring. */
|
|
8
|
+
.fdy-link{color:var(--color-primary-strong);text-decoration-line:underline;text-underline-offset:.2em;text-decoration-thickness:.06em;}
|
|
9
|
+
.fdy-link:hover{text-decoration-thickness:.12em;}
|
|
10
|
+
/* For a column of names that each open their own record: a table of accounts, each linking to its
|
|
11
|
+
ledger. Twenty primary-coloured links in one column outweigh the numbers beside them. The text
|
|
12
|
+
ink with a muted underline keeps every name reading as a link without competing with the data. */
|
|
13
|
+
.fdy-link--muted{color:var(--color-text);text-decoration-color:var(--color-text-muted);}
|
|
14
|
+
.fdy-link--muted:hover{color:var(--color-primary-strong);text-decoration-color:currentColor;}
|
package/src/components/tabs.css
CHANGED
|
@@ -63,3 +63,41 @@
|
|
|
63
63
|
.fdy-tabs--vertical .fdy-tabs__tab:focus-visible{border-radius:var(--radius-md);}
|
|
64
64
|
.fdy-tabs--vertical .fdy-tabs__tab[aria-selected="true"],.fdy-tabs--vertical .fdy-tabs__tab[aria-current="page"]{background:var(--color-primary-soft);color:var(--color-primary-strong);font-weight:var(--weight-semibold);}
|
|
65
65
|
.fdy-tabs--vertical .fdy-tabs__panel{flex:1;min-width:0;padding:0;}
|
|
66
|
+
|
|
67
|
+
/* PICKER IN A NARROW CONTAINER: `.fdy-tabs--picker-narrow`, opt-in, on either variant.
|
|
68
|
+
*
|
|
69
|
+
* At 40rem of its own width or less, the tab list gives way to `.fdy-tabs__picker`, a wrapper
|
|
70
|
+
* holding one combo of the same sections. Six tabs with real labels do not fit a phone as a strip,
|
|
71
|
+
* and as a column they fill the screen before the panel starts. A container query rather than a
|
|
72
|
+
* viewport one, because the same tabs can sit in a page or in a 20rem drawer.
|
|
73
|
+
*
|
|
74
|
+
* The list is hidden only through `.fdy-tabs__picker ~ .fdy-tabs__list`, so the picker has to come
|
|
75
|
+
* BEFORE the list, and tabs with no picker in them keep their list at every width: the class alone
|
|
76
|
+
* can never leave a screen with no way between its sections. On the raw path freeday-tabs.js builds
|
|
77
|
+
* the picker; in a typed stack it is a `FdyCombo` bound to the same state as the tabs.
|
|
78
|
+
*
|
|
79
|
+
* `flex-wrap` is what makes the vertical variant work: a container query styles what is inside the
|
|
80
|
+
* container, never the container itself, so `.fdy-tabs--vertical` stays a flex row. The picker takes
|
|
81
|
+
* a whole line and the panel wraps under it. While the list shows, the panel's `min-width:0` means it
|
|
82
|
+
* never wraps.
|
|
83
|
+
*
|
|
84
|
+
* 40rem: a column of labels and a panel worth reading do not both fit under it. Below Safari 16
|
|
85
|
+
* there are no container queries, and the same body applies by viewport width instead; that answers
|
|
86
|
+
* every phone, and leaves tabs in a narrow drawer on a wide screen as lists. The two bodies are
|
|
87
|
+
* copies, compared in test/baseline.test.mjs. */
|
|
88
|
+
.fdy-tabs__picker{display:none;}
|
|
89
|
+
.fdy-tabs--picker-narrow{flex-wrap:wrap;}
|
|
90
|
+
.fdy-tabs__picker > .fdy-combo{max-width:none;}
|
|
91
|
+
@supports (container-type:inline-size){
|
|
92
|
+
.fdy-tabs--picker-narrow{container:fdy-tabs / inline-size;}
|
|
93
|
+
@container fdy-tabs (max-width: 40rem){
|
|
94
|
+
.fdy-tabs--picker-narrow > .fdy-tabs__picker{display:block;flex:0 0 100%;}
|
|
95
|
+
.fdy-tabs--picker-narrow > .fdy-tabs__picker ~ .fdy-tabs__list{display:none;}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
@supports not (container-type:inline-size){
|
|
99
|
+
@media (max-width:40rem){
|
|
100
|
+
.fdy-tabs--picker-narrow > .fdy-tabs__picker{display:block;flex:0 0 100%;}
|
|
101
|
+
.fdy-tabs--picker-narrow > .fdy-tabs__picker ~ .fdy-tabs__list{display:none;}
|
|
102
|
+
}
|
|
103
|
+
}
|