@cahyo-dimas/freeday 3.22.0 → 3.24.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/COMPONENTS.md +77 -2
  3. package/README.id.md +1 -1
  4. package/README.md +1 -1
  5. package/adapters/blazor/FdyCfl.razor.cs +44 -8
  6. package/adapters/blazor/FdyTable.razor.cs +23 -1
  7. package/adapters/blazor/freeday-blazor.js +16 -2
  8. package/adapters/core/load-state.d.ts +17 -0
  9. package/adapters/core/load-state.js +37 -0
  10. package/adapters/react/components/FdyCfl.tsx +20 -5
  11. package/adapters/react/components/FdyDatepicker.tsx +10 -1
  12. package/adapters/react/components/FdyDrawer.tsx +8 -0
  13. package/adapters/react/components/FdyModal.tsx +11 -0
  14. package/adapters/react/components/FdyTable.tsx +28 -5
  15. package/adapters/react/index.d.ts +18 -0
  16. package/adapters/react/index.js +1 -0
  17. package/adapters/react/useFreeday.js +31 -0
  18. package/adapters/react/useLoad.js +53 -0
  19. package/adapters/vue/components/FdyCfl.vue +20 -6
  20. package/adapters/vue/components/FdyDatepicker.vue +10 -1
  21. package/adapters/vue/components/FdyDrawer.vue +10 -0
  22. package/adapters/vue/components/FdyModal.vue +12 -0
  23. package/adapters/vue/index.d.ts +18 -0
  24. package/adapters/vue/index.js +1 -0
  25. package/adapters/vue/useFreeday.js +32 -1
  26. package/adapters/vue/useLoad.js +47 -0
  27. package/dist/freeday-datepicker.js +25 -1
  28. package/dist/freeday-form.js +3 -0
  29. package/dist/freeday-stepper.js +14 -5
  30. package/dist/freeday-table.js +5 -1
  31. package/dist/freeday-tabs.js +76 -0
  32. package/dist/freeday-upload.js +17 -7
  33. package/dist/freeday.bundle.css +53 -0
  34. package/dist/freeday.css +53 -0
  35. package/dist/freeday.js +140 -14
  36. package/docs/getting-started.md +1 -1
  37. package/docs/reference-screen.html +1 -1
  38. package/docs/screen-states.md +3 -0
  39. package/package.json +2 -2
  40. package/src/components/link.css +14 -0
  41. package/src/components/tabs.css +38 -0
package/CHANGELOG.md CHANGED
@@ -9,6 +9,118 @@ 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.24.0] - 2026-11-27
13
+
14
+ **Satu keadaan, satu pintu.** Audit state machine implisit di kit (dan di app ronda yang memakainya)
15
+ menemukan keadaan yang disimpan sebagai beberapa variabel terpisah, yang bisa saling bertentangan.
16
+ Rilis ini menambah `useLoad` untuk app, dan menutup sembilan cacat kit dari kelas yang sama
17
+ (`#123`). Setiap cacat direproduksi di peramban atau bUnit dulu, dan ujinya terbukti merah pada kode
18
+ lama.
19
+
20
+ ### Added
21
+ - **`useLoad`** di Vue dan React (`/vue`, `/react`). Satu muatan data sebagai satu nilai:
22
+ `idle`, `loading` (dengan `previous`), `ready` (dengan `data`), atau `error` (dengan `error` dan
23
+ `previous`), sesuai keadaan yang `docs/screen-states.md` sebut untuk area data. `load()`
24
+ membatalkan permintaan sebelumnya lewat `AbortSignal` dan membuang jawaban yang datang sesudah
25
+ muatan yang lebih baru dimulai. Data lama hanya bisa diambil lewat nama `previous`, jadi menampilkan
26
+ data basi selalu keputusan yang terlihat di template. Tipe `LoadState<T>` ikut diekspor.
27
+
28
+ ### Fixed
29
+ - **`FdyCfl` tidak lagi mencampur baris dua kueri**, di Vue, React dan Blazor. "Load more" di dalam
30
+ jeda debounce membaca kotak pencarian yang sudah berisi ketikan baru, lalu menambahkan halaman 1
31
+ kueri baru di bawah halaman 0 kueri lama. Kini ia meminta halaman berikut untuk kueri baris yang
32
+ tampil. Pencarian baru yang gagal tidak meninggalkan baris kueri lama di bawah teks baru, dan
33
+ "Try again" mengulang permintaan yang gagal beserta kuerinya.
34
+ - **`FdyCfl` Blazor saat dibuka ulang dan ditutup.** Membuka ulang tidak lagi menampilkan baris
35
+ pencarian terakhir sampai halaman baru tiba. Menutup membatalkan permintaan yang sedang berjalan
36
+ dan pencarian yang menunggu debounce. "Try again" mengulang halaman yang gagal, sama seperti Vue
37
+ dan React, alih-alih memuat ulang halaman 0.
38
+ - **`FdyTable` tidak lagi berputar me-render tanpa henti** saat induk menyimpan hasil `onProcess` /
39
+ `Process` ke state-nya. React: tabel mode server tanpa prop `filters` membuat objek filter baru
40
+ setiap render, dan literal `columns`/`page` di induk berbuat sama; terukur 8.625 laporan dalam
41
+ setengah detik. Blazor: render queue meluap sampai stack overflow. Kini laporan hanya dikirim saat
42
+ baris di halaman atau totalnya berubah, di kedua stack. Vue sudah aman dan kini ikut dijaga uji.
43
+ - **`FdyModal` dan `FdyDrawer`: `open` tidak lagi menyimpang dari `<dialog>`**, di Vue, React dan
44
+ Blazor. Chrome menghormati `cancel` yang dicegah hanya sekali per aktivasi pengguna, jadi Escape
45
+ kedua menutup dialog sementara app masih memegang `open=true`, dan tidak bisa membukanya lagi.
46
+ Kini yang `dismissible` melaporkan penutupan itu, dan yang tidak dibuka kembali.
47
+ - **Datepicker: Escape menutup panel dari mana pun di dalamnya**, di ketiga stack. Sebelumnya hanya
48
+ dari grid, jadi fokus di panah bulan membuat Escape tidak berbuat apa-apa. Di jalur mentah panah
49
+ yang dibangun ulang kini mempertahankan fokus, dan panel menutup saat fokus keluar dari field,
50
+ sama dengan Vue dan React (sekaligus membuang setengah rentang yang tertunda).
51
+ - **Stepper: selama penjaga `waitFor` memutuskan, tidak ada navigasi yang lolos.** Klik header
52
+ langkah dulu lolos, dan saat penjaga menjawab, Next bergerak dari posisi yang baru: perpindahan
53
+ yang tidak pernah ditanyakan ke penjaga, sementara yang disetujui hilang.
54
+ - **Upload:** `setProgress` sesudah `done()`/`fail()` mengembalikan baris ke keadaan mengunggah,
55
+ bukan bilah progres di bawah tulisan "Uploaded". Sorotan `is-dragover` hilang saat seretan keluar
56
+ dari zona lewat elemen anak atau dibatalkan dengan Escape.
57
+ - **Form:** tombol `<button type="reset">` milik form kini menghapus pesan galat dan status
58
+ "sudah dikirim", seperti `api.reset()`.
59
+ - **Tabel mentah:** Escape yang menutup panel filter tidak lagi ikut menutup modal di belakangnya.
60
+
61
+ ### Catatan
62
+ - **Belum dikerjakan, dicatat di `NEXT-UP.md`:** pembungkus Blazor `FdyAutocomplete`,
63
+ `FdyDatepicker` dan `FdyDateRange` tidak mendorong `Value`/`From`/`To` atau `Options` yang
64
+ berubah sesudah hidrasi (butuh API `setValue` di enhancer, jadi dirancang terpisah); opsi
65
+ autocomplete mentah yang ditambahkan belakangan; dan carousel (indeks ditimpa saat gulir halus,
66
+ autoplay saat fokus di dalam), yang baru dilacak di kode.
67
+ - `FdyModal`/`FdyDrawer` Blazor diperbaiki di jembatan JS, jadi tidak tercakup bUnit; jalurnya sama
68
+ dengan Vue dan React yang diuji di peramban.
69
+
70
+ ## [3.23.0] - 2026-11-26
71
+
72
+ **Empat catatan dari app ronda (`CATATAN-FREEDAY.md` §29 sampai §31, dan satu temuan di §26).**
73
+ Formulir di komponen anak kini tervalidasi, tautan teks punya nama di daftar kelas, tab bisa berganti
74
+ menjadi pemilih di wadah sempit, dan layar rujukan tidak lagi kehilangan `<h1>`-nya di HP.
75
+
76
+ ### Added
77
+ - **`.fdy-tabs--picker-narrow` dan `.fdy-tabs__picker`** (`#121`, §31). Saat lebar tab itu sendiri
78
+ 40rem atau kurang, satu combo berisi bagian yang sama menggantikan daftar tab. Ini container query,
79
+ jadi tab di laci 20rem pada desktop ikut berganti; di bawah Safari 16 aturan yang sama berlaku
80
+ menurut lebar viewport. Di jalur mentah `freeday-tabs.js` membangun pemilihnya, menamainya dengan
81
+ label tablist (atau `data-fdy-text-picker`, bawaan `Section`), dan menyinkronkan keduanya. Di Vue,
82
+ React dan Blazor pemilihnya `FdyCombo` yang diikat ke state yang sama, di dalam
83
+ `.fdy-tabs__picker` sebelum daftar. Daftar hanya disembunyikan bila ada pemilih di depannya, jadi
84
+ kelas ini tanpa pemilih tidak mengubah apa pun.
85
+ - **`.fdy-link` dan `.fdy-link--muted`** (`#120`, §30). `<a>` polos sudah lama dilukis sebagai tautan
86
+ oleh `base.css`, tetapi tidak ada kelas di `COMPONENTS.md` yang mengatakannya, dan daftar kelas itu
87
+ tertutup. `--muted` untuk kolom nama yang masing-masing membuka catatannya sendiri: tinta teks
88
+ dengan garis bawah redup, primary saat hover. Keduanya mempertahankan garis bawah saat diam, supaya
89
+ tautan tidak dikenali dari warna saja. Aturan tautan lawan tombol ditulis di sebelahnya.
90
+
91
+ ### Changed
92
+ - **`useFreeday` menjangkau DOM yang dipasang komponen anak belakangan** (`#119`, §29), di Vue dan
93
+ React. Formulir `data-fdy-validate` yang dirender anak di balik `v-if` atau kondisinya sendiri tidak
94
+ pernah terhidrasi: `onUpdated` dan efek React milik komponen yang berubah, yaitu anak, bukan
95
+ pemanggil `useFreeday`. Isian wajib yang kosong lolos terkirim. Kini `useFreeday` mengamati
96
+ subtree-nya dan menghidrasi ulang di microtask yang sama, sebelum layar dilukis. `takeRecords()`
97
+ membuang mutasi yang dibuat enhancer sendiri, jadi satu hidrasi tidak menjadwalkan hidrasi
98
+ berikutnya.
99
+
100
+ ### Fixed
101
+ - **`docs/reference-screen.html` punya `<h1>` di setiap lebar** (`#122`, temuan di §26). Judul topbar
102
+ memakai `fdy-hide-below-md`, yang `display:none`, jadi di bawah 960px layar yang disalin setiap app
103
+ baru tidak punya `<h1>` sama sekali. Judulnya sudah terpotong rapi di topbar sempit; diukur muat di
104
+ 320, 375 dan 412px tanpa gulir samping. `COMPONENTS.md` kini mengatakan bahwa utilitas `hide-below`
105
+ juga mengeluarkan isinya dari pohon aksesibilitas, dan bahwa judul yang tidak boleh terlihat memakai
106
+ `.fdy-visually-hidden`.
107
+
108
+ ### Catatan
109
+ - **§31 tidak menjadi pembungkus bertipe `FdyTabs`.** Usulannya menyebut kunci, ARIA dan sinkronisasi
110
+ sebagai milik kit. Di jalur mentah memang demikian. Di stack bertipe, tab yang statenya dipegang
111
+ framework sudah sinkron lewat nilai yang sama, dan ARIA pemilihnya milik `FdyCombo`. Navigasi
112
+ papan ketik daftar tab tetap ditulis app sampai ada pemakai kedua yang membutuhkan pembungkusnya.
113
+ - Diuji di `browser/child-hydration.mjs` (Vue dan React: formulir anak tervalidasi, dan pengamat
114
+ diam sesudah halaman tenang), `browser/tabs-picker.mjs` (tiga kasus, masing-masing terbukti merah
115
+ oleh mutasi), uji kembar container query lawan cadangannya di `test/baseline.test.mjs`, dan
116
+ penjaga `<h1>` tersembunyi di `test/docs.test.mjs`. Keempatnya merah pada kode lama.
117
+ - **Harness peramban: bundle uji kini mendarat lewat rename** (`browser/harness.mjs`). Setiap berkas
118
+ spesifikasi berjalan di prosesnya sendiri dan memanggil `buildEntries()`, dan esbuild menulis dengan
119
+ mengosongkan berkas dulu. Terukur di laptop: 27 dari 90.477 pembacaan selama pembangunan ulang
120
+ serentak mendapati berkas 0 byte, dan halaman yang memuat skrip kosong tidak pernah terpasang. Di CI
121
+ itu muncul sebagai `cfl-narrow` yang gagal dua kali pada tag ini sementara commit yang sama lulus
122
+ di `main`. Sesudahnya 0 dari 102.634. Hanya alat uji; tidak ada yang terkirim di paket.
123
+
12
124
  ## [3.22.0] - 2026-11-24
13
125
 
14
126
  **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
- **A `useFreeday(ref)` whose ref is still null at mount says so too.** That is a ref left off the
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
 
@@ -1860,6 +1874,33 @@ replaces.
1860
1874
  rather than rendering zero: a widget that shows 0 for a request that failed reads as "nothing to
1861
1875
  do", the opposite of what happened.
1862
1876
 
1877
+ **Which state to render: `useLoad`** (Vue and React, from the same import path). One data load as
1878
+ one value, so a screen cannot be loading and failed at once, show its empty state beside its error,
1879
+ or show a form filled with defaults after the load meant to fill it failed:
1880
+
1881
+ | `state.status` | Also holds | Render |
1882
+ |---|---|---|
1883
+ | `'idle'` | nothing | nothing yet |
1884
+ | `'loading'` | `previous`: the last good data, or `null` | skeleton or `FdyTable`'s `loading` |
1885
+ | `'error'` | `error`, `previous` | `.fdy-state--danger` with Try again. Never the empty state. |
1886
+ | `'ready'` | `data` | the data, or one of the three empty states when it has none |
1887
+
1888
+ ```js
1889
+ const { state, load } = useLoad((signal) => fetchInvoices(month.value, signal));
1890
+ onMounted(load);
1891
+ watch(month, load);
1892
+ ```
1893
+
1894
+ - `load()` aborts the request before it (the fetcher receives an `AbortSignal`) and discards any
1895
+ answer that arrives after a newer load started, so a quick change of filter never leaves the
1896
+ older result on screen. Unmounting aborts what is in flight.
1897
+ - It returns a promise that settles when that load does and never rejects; the error is in `state`.
1898
+ - Data from an earlier load is reachable only as `previous`, so showing stale rows while reloading,
1899
+ or beside an error, is a decision visible in the template. A form that edits loaded data renders
1900
+ only under `'ready'`.
1901
+ - In React `load` is stable and calls the latest fetcher, so `useEffect(() => { void load(); },
1902
+ [month, load])` is enough.
1903
+
1863
1904
  ## Charts — `data-fdy-chart`
1864
1905
  > **Typed wrapper: `<FdyChart>`**. data props in all three (`type` + `values` / `series`); it repaints on data change, so `FreedayChart.update(el)` is only for the raw path below. It paints through the enhancer: on Vue and React it needs `import '@cahyo-dimas/freeday'` once at app entry, the one typed wrapper that does. Without it the slot content stays and no chart is drawn.
1865
1906
 
@@ -2334,6 +2375,40 @@ settings screen whose sections are a list, not a strip.
2334
2375
  is why the axis is read from the attribute and never from the painted layout.
2335
2376
  - Measured in `browser/tabs-vertical.mjs`, which also holds the line that a strip with no
2336
2377
  `aria-orientation` behaves and paints exactly as it did before the variant existed.
2378
+ - **A picker in a narrow container: `.fdy-tabs--picker-narrow`**, opt-in, on the strip or the
2379
+ vertical variant. When the tabs' own width is 40rem or less, a `.fdy-tabs__picker` (a wrapper
2380
+ holding one combo of the same sections) replaces the list. It is a container query, so tabs in a
2381
+ 20rem drawer on a desktop switch too. Below Safari 16 the same rule applies by viewport width, which
2382
+ covers phones and leaves a narrow drawer on a wide screen with its list.
2383
+ - **Raw path:** add the class. `freeday-tabs.js` builds the picker first in the root, names it
2384
+ after the tablist's `aria-labelledby` or `aria-label` (else `data-fdy-text-picker`, default
2385
+ `Section`), and keeps tab and picker in step both ways. It needs `freeday-select.js`, which
2386
+ `dist/freeday.js` carries.
2387
+ - **Vue, React, Blazor:** tabs whose state lives in your framework render the picker themselves:
2388
+ a `FdyCombo` bound to the same value as the tabs, inside `<div class="fdy-tabs__picker">`, placed
2389
+ **before** `.fdy-tabs__list`.
2390
+ - The list is hidden only when a picker precedes it, so the class on tabs with no picker changes
2391
+ nothing, and no width can leave a screen without a way between its sections.
2392
+ - Use it when the labels are long or there are more than about four tabs. A strip of three short
2393
+ labels fits a phone as it is.
2394
+
2395
+ ```html
2396
+ <div class="fdy-tabs fdy-tabs--vertical fdy-tabs--picker-narrow" data-fdy-tabs>
2397
+ <div class="fdy-tabs__list" role="tablist" aria-label="Settings sections">…</div>
2398
+ <div class="fdy-tabs__panel" role="tabpanel" …>…</div>
2399
+ </div>
2400
+
2401
+ <!-- Vue: the picker is yours, bound to the state the tabs already read. One label names both:
2402
+ FdyCombo takes ariaLabelledby, and an aria-label on it would land on its root, not its button. -->
2403
+ <span id="sections" class="fdy-visually-hidden">Settings sections</span>
2404
+ <div class="fdy-tabs fdy-tabs--vertical fdy-tabs--picker-narrow">
2405
+ <div class="fdy-tabs__picker">
2406
+ <FdyCombo v-model="tab" :options="sections" aria-labelledby="sections" />
2407
+ </div>
2408
+ <div class="fdy-tabs__list" role="tablist" aria-orientation="vertical" aria-labelledby="sections">…</div>
2409
+ …
2410
+ </div>
2411
+ ```
2337
2412
 
2338
2413
  ---
2339
2414
 
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
  [![Live docs](https://img.shields.io/badge/docs-live-2050d8?style=flat-square)](https://cahyo-dimas.github.io/freeday-ui-kit/)
8
- [![Release](https://img.shields.io/badge/release-v3.22.0-0078d4?style=flat-square)](https://github.com/cahyo-dimas/freeday-ui-kit/tree/v3.22.0)
8
+ [![Release](https://img.shields.io/badge/release-v3.24.0-0078d4?style=flat-square)](https://github.com/cahyo-dimas/freeday-ui-kit/tree/v3.24.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
  [![Live docs](https://img.shields.io/badge/docs-live-2050d8?style=flat-square)](https://cahyo-dimas.github.io/freeday-ui-kit/)
8
- [![Release](https://img.shields.io/badge/release-v3.22.0-0078d4?style=flat-square)](https://github.com/cahyo-dimas/freeday-ui-kit/tree/v3.22.0)
8
+ [![Release](https://img.shields.io/badge/release-v3.24.0-0078d4?style=flat-square)](https://github.com/cahyo-dimas/freeday-ui-kit/tree/v3.24.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`.
@@ -97,6 +97,13 @@ public partial class FdyCfl<TRow>
97
97
  private string? _error;
98
98
  private int _reqSeq; // out-of-order response guard
99
99
  private int _debounceSeq; // supersedes stale debounced searches
100
+ /* The query the rows on screen came from, which is not always _query: during the debounce the
101
+ box holds a search not yet sent, and "Load more" appends to the ROWS (#123). */
102
+ private string _shownQuery = string.Empty;
103
+ /* The request that last ran, so Try again repeats it: the page that failed, with its query,
104
+ the same as the Vue and React pickers. It used to reload page 0, dropping appended pages. */
105
+ private string _lastQuery = string.Empty;
106
+ private bool _lastReset = true;
100
107
 
101
108
  private string DisplayValue => Value is null ? string.Empty : Display(Value);
102
109
  /* The live value on the group, as every value-bearing kit control mirrors it: the picked keys. */
@@ -121,11 +128,18 @@ public partial class FdyCfl<TRow>
121
128
  if (Disabled || Readonly || _open) return;
122
129
  _open = true;
123
130
  _query = string.Empty;
131
+ /* Nothing from the last opening survives into this one: its rows answered another search,
132
+ and showing them under an empty box until the new page lands reads as this search's
133
+ results, or stays on screen beside the error if that page fails. */
134
+ _rows.Clear();
135
+ _error = null;
136
+ _hasMore = false;
137
+ _page = 0;
124
138
  /* Re-seeded per open, so Cancel really is a cancel: the ticks start as whatever the caller holds. */
125
139
  _picked.Clear();
126
140
  if (Multiple && Values is not null) _picked.AddRange(Values);
127
141
  await JS.InvokeVoidAsync("FreedayBlazor.dialogShow", Root);
128
- await LoadAsync(reset: true);
142
+ await LoadAsync(_query, reset: true);
129
143
  }
130
144
 
131
145
  /// <summary>Close the picker without committing, the same path Esc and the footer button take.</summary>
@@ -133,6 +147,12 @@ public partial class FdyCfl<TRow>
133
147
  {
134
148
  if (!_open) return;
135
149
  _open = false;
150
+ /* A response in flight, or a search still waiting out its debounce, belongs to the dialog
151
+ that just closed. Bumping both counters drops them; without it a search typed just before
152
+ closing was still sent, and its rows landed in the next opening. */
153
+ ++_reqSeq;
154
+ ++_debounceSeq;
155
+ _loading = false;
136
156
  await JS.InvokeVoidAsync("FreedayBlazor.dialogClose", Root);
137
157
  }
138
158
 
@@ -148,27 +168,43 @@ public partial class FdyCfl<TRow>
148
168
  await Task.Delay(SearchDebounceMs);
149
169
  if (seq != _debounceSeq) return; // a newer keystroke superseded this one
150
170
  }
151
- await LoadAsync(reset: true);
171
+ await LoadAsync(_query, reset: true);
152
172
  }
153
173
 
154
- private async Task LoadAsync(bool reset)
174
+ private async Task LoadAsync(string query, bool reset)
155
175
  {
176
+ _lastQuery = query;
177
+ _lastReset = reset;
156
178
  _loading = true;
157
179
  _error = null;
158
180
  StateHasChanged();
159
181
  int seq = ++_reqSeq;
160
182
  try
161
183
  {
162
- CflPage<TRow> result = await LoadPage(_query, reset ? 0 : _page);
184
+ CflPage<TRow> result = await LoadPage(query, reset ? 0 : _page);
163
185
  if (seq != _reqSeq) return; // a newer request superseded this response
164
- if (reset) _rows.Clear();
186
+ if (reset)
187
+ {
188
+ _rows.Clear();
189
+ _shownQuery = query;
190
+ }
165
191
  _rows.AddRange(result.Rows);
166
192
  _hasMore = result.HasMore;
167
193
  _page = reset ? 1 : _page + 1;
168
194
  }
169
195
  catch (Exception ex)
170
196
  {
171
- if (seq == _reqSeq) _error = string.IsNullOrEmpty(ex.Message) ? ErrorText : ex.Message;
197
+ if (seq == _reqSeq)
198
+ {
199
+ /* A failed new search leaves no rows from the old one under the new text. A failed
200
+ next page keeps the rows it was adding to, which still answer their own query. */
201
+ if (reset)
202
+ {
203
+ _rows.Clear();
204
+ _hasMore = false;
205
+ }
206
+ _error = string.IsNullOrEmpty(ex.Message) ? ErrorText : ex.Message;
207
+ }
172
208
  }
173
209
  finally
174
210
  {
@@ -180,9 +216,9 @@ public partial class FdyCfl<TRow>
180
216
  }
181
217
  }
182
218
 
183
- private Task LoadMoreAsync() => _hasMore && !_loading ? LoadAsync(reset: false) : Task.CompletedTask;
219
+ private Task LoadMoreAsync() => _hasMore && !_loading ? LoadAsync(_shownQuery, reset: false) : Task.CompletedTask;
184
220
 
185
- private Task RetryAsync() => LoadAsync(reset: true);
221
+ private Task RetryAsync() => LoadAsync(_lastQuery, _lastReset);
186
222
 
187
223
  /// <summary>Unset the value. Not "choosing nothing": the dialog is not involved, so this neither
188
224
  /// opens nor closes it.</summary>
@@ -159,6 +159,12 @@ public partial class FdyTable<TRow>
159
159
  // Both notifications are therefore queued here and flushed in OnAfterRenderAsync.
160
160
  private int? _pendingClamp;
161
161
  private bool _processDirty;
162
+ /* What was last reported through Process. Every parent render re-sets this component's
163
+ parameters, Recompute runs, and the page comes out as a new list of the same rows; reporting
164
+ that again made a parent that stores the report render the table again, until the render queue
165
+ overflowed the stack. A report goes out when the rows on the page or the total change. */
166
+ private IReadOnlyList<TRow>? _reportedRows;
167
+ private int _reportedTotal = -1;
162
168
 
163
169
  private static readonly IReadOnlyDictionary<string, FdyColumnFilter> EmptyFilters = new Dictionary<string, FdyColumnFilter>();
164
170
 
@@ -240,7 +246,23 @@ public partial class FdyTable<TRow>
240
246
  _displayRows = filteredSorted;
241
247
  }
242
248
 
243
- _processDirty = true;
249
+ if (_reportedRows is null || _reportedTotal != _totalCount || !SameRows(_reportedRows, _displayRows))
250
+ {
251
+ _reportedRows = _displayRows;
252
+ _reportedTotal = _totalCount;
253
+ _processDirty = true;
254
+ }
255
+ }
256
+
257
+ /// <summary>The same rows in the same order: one page, compared element by element.</summary>
258
+ private static bool SameRows(IReadOnlyList<TRow> a, IReadOnlyList<TRow> b)
259
+ {
260
+ if (a.Count != b.Count) return false;
261
+ for (int i = 0; i < a.Count; i++)
262
+ {
263
+ if (!EqualityComparer<TRow>.Default.Equals(a[i], b[i])) return false;
264
+ }
265
+ return true;
244
266
  }
245
267
 
246
268
  private FdyColumnFilter? GetFilter(string key) => EffectiveFilters.TryGetValue(key, out FdyColumnFilter? f) ? f : null;
@@ -144,10 +144,20 @@
144
144
  // itself (not its content) is a backdrop click.
145
145
  if (dismissible && e.target === dialog) dotNetRef.invokeMethodAsync(dismissMethod);
146
146
  };
147
+ /* A close nobody here asked for: Chrome honours a prevented `cancel` once per user activation,
148
+ so a second Escape closes the dialog regardless, while .NET still holds Open=true and cannot
149
+ reopen it. dialogClose marks its own closes; any other one is reported when dismissible, and
150
+ undone when not, because that is what Dismissible=false promises. */
151
+ var onClose = function () {
152
+ if (dialog._fdyClosing) { dialog._fdyClosing = false; return; }
153
+ if (dismissible) dotNetRef.invokeMethodAsync(dismissMethod);
154
+ else if (typeof dialog.showModal === 'function') dialog.showModal();
155
+ };
147
156
  dialog.addEventListener('cancel', onCancel);
148
157
  dialog.addEventListener('click', onClick);
158
+ dialog.addEventListener('close', onClose);
149
159
  var token = ++dialogSeq;
150
- dialogSubs[token] = { el: dialog, cancel: onCancel, click: onClick };
160
+ dialogSubs[token] = { el: dialog, cancel: onCancel, click: onClick, close: onClose };
151
161
  return token;
152
162
  }
153
163
 
@@ -156,7 +166,10 @@
156
166
  }
157
167
 
158
168
  function dialogClose(dialog) {
159
- if (dialog && dialog.open) dialog.close();
169
+ if (dialog && dialog.open) {
170
+ dialog._fdyClosing = true;
171
+ dialog.close();
172
+ }
160
173
  }
161
174
 
162
175
  function dialogDispose(token) {
@@ -164,6 +177,7 @@
164
177
  if (s) {
165
178
  s.el.removeEventListener('cancel', s.cancel);
166
179
  s.el.removeEventListener('click', s.click);
180
+ s.el.removeEventListener('close', s.close);
167
181
  delete dialogSubs[token];
168
182
  }
169
183
  }
@@ -0,0 +1,17 @@
1
+ // Types for the load state (adapters/core/load-state.js), shared by useLoad in Vue and React.
2
+
3
+ /**
4
+ * One data load. `previous` is what an earlier load returned, kept through a reload or a failure so a
5
+ * screen can choose to show it; it is never mixed into `data`, which only a successful load sets.
6
+ */
7
+ export type LoadState<T> =
8
+ | { readonly status: 'idle' }
9
+ | { readonly status: 'loading'; readonly previous: T | null }
10
+ | { readonly status: 'ready'; readonly data: T }
11
+ | { readonly status: 'error'; readonly error: Error; readonly previous: T | null };
12
+
13
+ export declare const IDLE: LoadState<never>;
14
+ export declare function dataOf<T>(state: LoadState<T>): T | null;
15
+ export declare function loadingFrom<T>(state: LoadState<T>): LoadState<T>;
16
+ export declare function readyWith<T>(data: T): LoadState<T>;
17
+ export declare function failedFrom<T>(state: LoadState<T>, error: Error): LoadState<T>;
@@ -0,0 +1,37 @@
1
+ // Freeday, the state of one data load, framework-agnostic (pure, zero dependencies).
2
+ //
3
+ // The states docs/screen-states.md names for a data area (loading, load error, ideal), as ONE value
4
+ // instead of a loading flag, an error string and the data held side by side. Three separate values
5
+ // let a screen be "loading" and "failed" at once, render its empty state beside its error, or show a
6
+ // form filled with defaults after the load that should have filled it failed. A union cannot.
7
+ //
8
+ // Data from an earlier load survives a reload and a failure only as `previous`, so showing stale data
9
+ // is always a choice a reader can see in the code, never an accident of what was left in a variable.
10
+ //
11
+ // Shared by useLoad in the Vue and React adapters. Each function returns a new state and never
12
+ // changes the one it is given.
13
+
14
+ /** Nothing asked for yet. */
15
+ export const IDLE = Object.freeze({ status: 'idle' });
16
+
17
+ /** The data a state still holds: the loaded data, or what was there before this load started. */
18
+ export function dataOf(state) {
19
+ if (state.status === 'ready') return state.data;
20
+ if (state.status === 'loading' || state.status === 'error') return state.previous;
21
+ return null;
22
+ }
23
+
24
+ /** A load started; whatever was shown before is kept as `previous`. */
25
+ export function loadingFrom(state) {
26
+ return Object.freeze({ status: 'loading', previous: dataOf(state) });
27
+ }
28
+
29
+ /** A load answered. */
30
+ export function readyWith(data) {
31
+ return Object.freeze({ status: 'ready', data });
32
+ }
33
+
34
+ /** A load failed; the data from before it, if any, is kept as `previous`. */
35
+ export function failedFrom(state, error) {
36
+ return Object.freeze({ status: 'error', error, previous: dataOf(state) });
37
+ }
@@ -138,6 +138,11 @@ function FdyCflInner<Row extends Record<string, unknown>>(
138
138
  const cacheRef = useRef<Map<string, CflPage<Row>>>(new Map<string, CflPage<Row>>());
139
139
  const lastPageRef = useRef<number>(0);
140
140
  const lastAppendRef = useRef<boolean>(false);
141
+ const lastQueryRef = useRef<string>('');
142
+ /* The query the rows on screen came from, which is not always the one in the search box: for 250 ms
143
+ after typing, the box holds a search that has not been sent. "Load more" appends to the ROWS, so
144
+ it asks for their query; reading the box appended page 1 of "ab" under page 0 of "a". */
145
+ const shownQueryRef = useRef<string>('');
141
146
  const searchTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
142
147
 
143
148
  const isDisabled: boolean = props.disabled === true;
@@ -174,6 +179,7 @@ function FdyCflInner<Row extends Record<string, unknown>>(
174
179
 
175
180
  // --- Async engine ----------------------------------------------------------------------
176
181
  async function load(targetQuery: string, targetPage: number, append: boolean): Promise<void> {
182
+ lastQueryRef.current = targetQuery;
177
183
  lastPageRef.current = targetPage;
178
184
  lastAppendRef.current = append;
179
185
  const token: number = ++reqIdRef.current;
@@ -187,27 +193,36 @@ function FdyCflInner<Row extends Record<string, unknown>>(
187
193
  if (cached === undefined) cacheRef.current.set(key, res);
188
194
  const copy: Row[] = res.rows.slice(); // never mutate the caller's array
189
195
  setRows((prev: Row[]): Row[] => (append ? prev.concat(copy) : copy));
196
+ if (!append) shownQueryRef.current = targetQuery;
190
197
  setHasMore(res.hasMore);
191
198
  setPage(targetPage);
192
199
  if (!append) setActiveIndex(copy.length > 0 ? 0 : -1);
193
200
  } catch (err: unknown) {
194
201
  if (token !== reqIdRef.current) return;
202
+ /* A new search that failed leaves no rows behind: the old ones answer a different query, and
203
+ under the new text they would read as its results. A failed NEXT page keeps the rows it was
204
+ adding to, which still belong to the query they say they do. */
205
+ if (!append) {
206
+ setRows([]);
207
+ setHasMore(false);
208
+ setActiveIndex(-1);
209
+ }
195
210
  setError(err instanceof Error ? err : new Error(String(err)));
196
211
  } finally {
197
212
  if (token === reqIdRef.current) setLoading(false);
198
213
  }
199
214
  }
200
215
 
201
- // Mirrors Vue's `retry()`: only `lastPage`/`lastAppend` are frozen from the failed request,
202
- // the query is re-read live so a retry after editing the search box (within the debounce
203
- // window) uses what's currently typed, not a stale snapshot.
216
+ /* Repeats the request that failed, query included. Re-reading the box instead paired a page
217
+ number from one query with the text of another; a newer search, if one was typed, follows on
218
+ its own debounce. */
204
219
  function retry(): void {
205
- void load(query, lastPageRef.current, lastAppendRef.current);
220
+ void load(lastQueryRef.current, lastPageRef.current, lastAppendRef.current);
206
221
  }
207
222
 
208
223
  function loadMore(): void {
209
224
  if (loading || !hasMore) return;
210
- void load(query, page + 1, true);
225
+ void load(shownQueryRef.current, page + 1, true);
211
226
  }
212
227
 
213
228
  function onSearchInput(e: React.ChangeEvent<HTMLInputElement>): void {
@@ -589,6 +589,14 @@ export function FdyDatepicker(props: FdyDatepickerProps): JSX.Element {
589
589
  }
590
590
  }
591
591
 
592
+ /* Escape from anywhere in the panel. The grids handle it first and say so with preventDefault; this
593
+ answers for the arrows and the title, where it used to do nothing. */
594
+ function onPanelKeydown(e: React.KeyboardEvent<HTMLDivElement>): void {
595
+ if (e.key !== 'Escape' || e.defaultPrevented) return;
596
+ e.preventDefault();
597
+ closePanel(true);
598
+ }
599
+
592
600
  // Close when focus leaves the control entirely (e.g. Shift+Tab off the trigger).
593
601
  /* A null relatedTarget means focus fell to <body>, which is what happens when the element the
594
602
  user just pressed is REMOVED by the click it triggered (drilling into the month grid replaces
@@ -655,7 +663,8 @@ export function FdyDatepicker(props: FdyDatepickerProps): JSX.Element {
655
663
  </button>
656
664
  ) : null}
657
665
 
658
- <div ref={panelRef} className="fdy-datepicker__panel" role="dialog" aria-modal="false" aria-labelledby={titleId} hidden={!open}>
666
+ <div ref={panelRef} className="fdy-datepicker__panel" role="dialog" aria-modal="false" aria-labelledby={titleId} hidden={!open}
667
+ onKeyDown={onPanelKeydown}>
659
668
  {/* ONE head for both modes on purpose: swapping it destroys the very button the user just
660
669
  pressed, focus falls to <body>, and the panel's own focusout handler closes it. */}
661
670
  <div className="fdy-cal__head">
@@ -49,6 +49,14 @@ export function FdyDrawer(props: FdyDrawerProps): JSX.Element {
49
49
  onClick={(e): void => {
50
50
  if (dismissible && e.target === dialogRef.current) props.onClose();
51
51
  }}
52
+ onClose={(): void => {
53
+ /* Closed while the app still says open: Chrome honours a prevented `cancel` once per user
54
+ activation. Reported when dismissible, shown again when not; see FdyModal.tsx. */
55
+ const el: HTMLDialogElement | null = dialogRef.current;
56
+ if (!props.open || el === null) return;
57
+ if (dismissible) props.onClose();
58
+ else el.showModal();
59
+ }}
52
60
  >
53
61
  <div className="fdy-drawer__header">
54
62
  <h3 id={titleId} className="fdy-drawer__title">{props.title}</h3>
@@ -46,6 +46,17 @@ export function FdyModal(props: FdyModalProps): JSX.Element {
46
46
  e.preventDefault(); // stop the native close; app state stays the single source of truth
47
47
  if (dismissible) props.onClose();
48
48
  }}
49
+ onClose={(): void => {
50
+ /* The dialog closed while the app still says open. Chrome's close watcher honours a prevented
51
+ `cancel` once per user activation, so a second Escape with no click between closes the
52
+ dialog regardless. Left alone, the app held open=true over a closed dialog and could not
53
+ reopen it, since the value never changed. A dismissible modal reports the close; one that
54
+ may not be dismissed is shown again, because that is what dismissible=false promises. */
55
+ const el: HTMLDialogElement | null = dialogRef.current;
56
+ if (!props.open || el === null) return;
57
+ if (dismissible) props.onClose();
58
+ else el.showModal();
59
+ }}
49
60
  onClick={(e): void => {
50
61
  // The ::backdrop is not a separate element, target === the dialog box means a backdrop click.
51
62
  if (dismissible && e.target === dialogRef.current) props.onClose();