@cahyo-dimas/freeday 3.23.0 → 3.25.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 +98 -0
- package/COMPONENTS.md +39 -0
- package/README.id.md +1 -1
- package/README.md +1 -1
- package/adapters/blazor/FdyAutocomplete.razor +1 -1
- package/adapters/blazor/FdyAutocomplete.razor.cs +34 -1
- package/adapters/blazor/FdyCascade.razor.cs +15 -1
- package/adapters/blazor/FdyCfl.razor.cs +44 -8
- package/adapters/blazor/FdyDateRange.razor +1 -1
- package/adapters/blazor/FdyDateRange.razor.cs +25 -1
- package/adapters/blazor/FdyDatepicker.razor.cs +15 -1
- package/adapters/blazor/FdyMonthpicker.razor.cs +15 -1
- package/adapters/blazor/FdyTable.razor.cs +23 -1
- package/adapters/blazor/FdyTimepicker.razor.cs +15 -1
- package/adapters/blazor/freeday-blazor.js +16 -2
- package/adapters/core/load-state.d.ts +17 -0
- package/adapters/core/load-state.js +37 -0
- package/adapters/react/components/FdyCfl.tsx +20 -5
- package/adapters/react/components/FdyDatepicker.tsx +10 -1
- package/adapters/react/components/FdyDrawer.tsx +8 -0
- package/adapters/react/components/FdyModal.tsx +11 -0
- package/adapters/react/components/FdyTable.tsx +28 -5
- package/adapters/react/index.d.ts +18 -0
- package/adapters/react/index.js +1 -0
- package/adapters/react/useLoad.js +53 -0
- package/adapters/vue/components/FdyCfl.vue +20 -6
- package/adapters/vue/components/FdyDatepicker.vue +10 -1
- package/adapters/vue/components/FdyDrawer.vue +10 -0
- package/adapters/vue/components/FdyModal.vue +12 -0
- package/adapters/vue/index.d.ts +18 -0
- package/adapters/vue/index.js +1 -0
- package/adapters/vue/useLoad.js +47 -0
- package/dist/freeday-autocomplete.js +43 -11
- package/dist/freeday-cascade.js +24 -8
- package/dist/freeday-datepicker.js +61 -1
- package/dist/freeday-form.js +3 -0
- package/dist/freeday-stepper.js +14 -5
- package/dist/freeday-table.js +5 -1
- package/dist/freeday-timepicker.js +12 -1
- package/dist/freeday-upload.js +17 -7
- package/dist/freeday.js +179 -34
- package/docs/getting-started.md +1 -1
- package/docs/screen-states.md +3 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,104 @@ 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.25.0] - 2026-11-27
|
|
13
|
+
|
|
14
|
+
**Nilai dari host sampai ke layar, di setiap wrapper Blazor** (`#123`, sisa audit 3.24.0). Wrapper
|
|
15
|
+
yang menyerahkan DOM-nya ke enhancer me-render seed-nya sekali. Selama ini hanya state
|
|
16
|
+
(`Disabled`, `Readonly`, `Invalid`, `Required`) yang didorong sesudahnya, jadi `Value` yang diubah
|
|
17
|
+
host, misalnya tombol "bulan ini" atau formulir yang dimuat ulang, tidak pernah tampil. `FdyCombo`
|
|
18
|
+
satu-satunya yang benar. Diukur sebagai kelas, bukan tiga komponen yang dilaporkan: enam wrapper.
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
- **`setValue(root, value)`** di `FreedayDatepicker`, `FreedayTimepicker`, `FreedayCascade` dan
|
|
22
|
+
`FreedayAutocomplete`, **`FreedayDatepicker.setRange(root, from, to)`** untuk rentang dua picker,
|
|
23
|
+
dan **`FreedayAutocomplete.setOptions(root, labels)`**. Semuanya senyap: tidak ada event
|
|
24
|
+
perubahan, jadi binding yang menyetel nilai tidak mendengarnya kembali sebagai pilihan. Datepicker
|
|
25
|
+
menerima `YYYY-MM-DD`, `YYYY-MM` di mode bulan, dan `"awal/akhir"` di rentang satu kolom.
|
|
26
|
+
`setRange` menautkan ulang batas akhir seperti sesudah memilih. String kosong mengosongkan.
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
- **`FdyDatepicker`, `FdyMonthpicker`, `FdyTimepicker`, `FdyCascade`, `FdyAutocomplete` dan
|
|
30
|
+
`FdyDateRange` Blazor mendorong `Value` / `From` / `To` yang berubah sesudah render pertama.**
|
|
31
|
+
Nilai yang dipilih pengguna tidak didorong balik.
|
|
32
|
+
- **`FdyAutocomplete` Blazor mendorong `Options` yang berubah**, dibandingkan menurut isi, jadi host
|
|
33
|
+
yang membuat list baru dengan isi yang sama di setiap render tidak memicu apa pun.
|
|
34
|
+
- **`FdyAutocomplete` Blazor melaporkan teks bebas saat diketik**, sama seperti Vue dan React.
|
|
35
|
+
Sebelumnya hanya pilihan yang sampai ke `ValueChanged`, jadi teks yang tidak cocok dengan saran
|
|
36
|
+
tampil di isian sementara `Value` memegang nilai lama.
|
|
37
|
+
- **Autocomplete jalur mentah membaca opsinya dari daftar setiap kali dipakai.** Opsi yang
|
|
38
|
+
di-render app sesudah init tidak pernah terlihat, dan flag ready menolak init ulang.
|
|
39
|
+
|
|
40
|
+
### Catatan
|
|
41
|
+
- **`Nodes` `FdyCascade` Blazor belum didorong.** Enhancer cascade menelan `<ul>` seed-nya dan tidak
|
|
42
|
+
punya API untuk mengganti pohonnya; dicatat di `NEXT-UP.md` §1.
|
|
43
|
+
- Diuji: 9 bUnit (`FdyValuePushTests`) dan 3 uji peramban (`browser/set-value.mjs`), semuanya merah
|
|
44
|
+
pada kode lama.
|
|
45
|
+
- **Harness peramban: halaman diserahkan ke uji sesudah fixture-nya termuat** (`browser/harness.mjs`).
|
|
46
|
+
Chrome dibuka dengan fixture sebagai halaman awal, dan soket CDP bisa tersambung saat tab masih
|
|
47
|
+
`about:blank`, yang `readyState`-nya sudah `complete`. `palette-os-dark` gagal begitu di jalanan
|
|
48
|
+
rilis ini: `document.documentElement` terbaca `null` saat dokumen fixture menggantikannya. Tujuh
|
|
49
|
+
spesifikasi menunggu dengan cara yang sama. Balapannya bergantung waktu, jadi tidak bisa dibuktikan
|
|
50
|
+
merah secara deterministik; yang diukur adalah ketujuhnya hijau dan suite penuh hijau sesudahnya.
|
|
51
|
+
|
|
52
|
+
## [3.24.0] - 2026-11-27
|
|
53
|
+
|
|
54
|
+
**Satu keadaan, satu pintu.** Audit state machine implisit di kit (dan di app ronda yang memakainya)
|
|
55
|
+
menemukan keadaan yang disimpan sebagai beberapa variabel terpisah, yang bisa saling bertentangan.
|
|
56
|
+
Rilis ini menambah `useLoad` untuk app, dan menutup sembilan cacat kit dari kelas yang sama
|
|
57
|
+
(`#123`). Setiap cacat direproduksi di peramban atau bUnit dulu, dan ujinya terbukti merah pada kode
|
|
58
|
+
lama.
|
|
59
|
+
|
|
60
|
+
### Added
|
|
61
|
+
- **`useLoad`** di Vue dan React (`/vue`, `/react`). Satu muatan data sebagai satu nilai:
|
|
62
|
+
`idle`, `loading` (dengan `previous`), `ready` (dengan `data`), atau `error` (dengan `error` dan
|
|
63
|
+
`previous`), sesuai keadaan yang `docs/screen-states.md` sebut untuk area data. `load()`
|
|
64
|
+
membatalkan permintaan sebelumnya lewat `AbortSignal` dan membuang jawaban yang datang sesudah
|
|
65
|
+
muatan yang lebih baru dimulai. Data lama hanya bisa diambil lewat nama `previous`, jadi menampilkan
|
|
66
|
+
data basi selalu keputusan yang terlihat di template. Tipe `LoadState<T>` ikut diekspor.
|
|
67
|
+
|
|
68
|
+
### Fixed
|
|
69
|
+
- **`FdyCfl` tidak lagi mencampur baris dua kueri**, di Vue, React dan Blazor. "Load more" di dalam
|
|
70
|
+
jeda debounce membaca kotak pencarian yang sudah berisi ketikan baru, lalu menambahkan halaman 1
|
|
71
|
+
kueri baru di bawah halaman 0 kueri lama. Kini ia meminta halaman berikut untuk kueri baris yang
|
|
72
|
+
tampil. Pencarian baru yang gagal tidak meninggalkan baris kueri lama di bawah teks baru, dan
|
|
73
|
+
"Try again" mengulang permintaan yang gagal beserta kuerinya.
|
|
74
|
+
- **`FdyCfl` Blazor saat dibuka ulang dan ditutup.** Membuka ulang tidak lagi menampilkan baris
|
|
75
|
+
pencarian terakhir sampai halaman baru tiba. Menutup membatalkan permintaan yang sedang berjalan
|
|
76
|
+
dan pencarian yang menunggu debounce. "Try again" mengulang halaman yang gagal, sama seperti Vue
|
|
77
|
+
dan React, alih-alih memuat ulang halaman 0.
|
|
78
|
+
- **`FdyTable` tidak lagi berputar me-render tanpa henti** saat induk menyimpan hasil `onProcess` /
|
|
79
|
+
`Process` ke state-nya. React: tabel mode server tanpa prop `filters` membuat objek filter baru
|
|
80
|
+
setiap render, dan literal `columns`/`page` di induk berbuat sama; terukur 8.625 laporan dalam
|
|
81
|
+
setengah detik. Blazor: render queue meluap sampai stack overflow. Kini laporan hanya dikirim saat
|
|
82
|
+
baris di halaman atau totalnya berubah, di kedua stack. Vue sudah aman dan kini ikut dijaga uji.
|
|
83
|
+
- **`FdyModal` dan `FdyDrawer`: `open` tidak lagi menyimpang dari `<dialog>`**, di Vue, React dan
|
|
84
|
+
Blazor. Chrome menghormati `cancel` yang dicegah hanya sekali per aktivasi pengguna, jadi Escape
|
|
85
|
+
kedua menutup dialog sementara app masih memegang `open=true`, dan tidak bisa membukanya lagi.
|
|
86
|
+
Kini yang `dismissible` melaporkan penutupan itu, dan yang tidak dibuka kembali.
|
|
87
|
+
- **Datepicker: Escape menutup panel dari mana pun di dalamnya**, di ketiga stack. Sebelumnya hanya
|
|
88
|
+
dari grid, jadi fokus di panah bulan membuat Escape tidak berbuat apa-apa. Di jalur mentah panah
|
|
89
|
+
yang dibangun ulang kini mempertahankan fokus, dan panel menutup saat fokus keluar dari field,
|
|
90
|
+
sama dengan Vue dan React (sekaligus membuang setengah rentang yang tertunda).
|
|
91
|
+
- **Stepper: selama penjaga `waitFor` memutuskan, tidak ada navigasi yang lolos.** Klik header
|
|
92
|
+
langkah dulu lolos, dan saat penjaga menjawab, Next bergerak dari posisi yang baru: perpindahan
|
|
93
|
+
yang tidak pernah ditanyakan ke penjaga, sementara yang disetujui hilang.
|
|
94
|
+
- **Upload:** `setProgress` sesudah `done()`/`fail()` mengembalikan baris ke keadaan mengunggah,
|
|
95
|
+
bukan bilah progres di bawah tulisan "Uploaded". Sorotan `is-dragover` hilang saat seretan keluar
|
|
96
|
+
dari zona lewat elemen anak atau dibatalkan dengan Escape.
|
|
97
|
+
- **Form:** tombol `<button type="reset">` milik form kini menghapus pesan galat dan status
|
|
98
|
+
"sudah dikirim", seperti `api.reset()`.
|
|
99
|
+
- **Tabel mentah:** Escape yang menutup panel filter tidak lagi ikut menutup modal di belakangnya.
|
|
100
|
+
|
|
101
|
+
### Catatan
|
|
102
|
+
- **Belum dikerjakan, dicatat di `NEXT-UP.md`:** pembungkus Blazor `FdyAutocomplete`,
|
|
103
|
+
`FdyDatepicker` dan `FdyDateRange` tidak mendorong `Value`/`From`/`To` atau `Options` yang
|
|
104
|
+
berubah sesudah hidrasi (butuh API `setValue` di enhancer, jadi dirancang terpisah); opsi
|
|
105
|
+
autocomplete mentah yang ditambahkan belakangan; dan carousel (indeks ditimpa saat gulir halus,
|
|
106
|
+
autoplay saat fokus di dalam), yang baru dilacak di kode.
|
|
107
|
+
- `FdyModal`/`FdyDrawer` Blazor diperbaiki di jembatan JS, jadi tidak tercakup bUnit; jalurnya sama
|
|
108
|
+
dengan Vue dan React yang diuji di peramban.
|
|
109
|
+
|
|
12
110
|
## [3.23.0] - 2026-11-26
|
|
13
111
|
|
|
14
112
|
**Empat catatan dari app ronda (`CATATAN-FREEDAY.md` §29 sampai §31, dan satu temuan di §26).**
|
package/COMPONENTS.md
CHANGED
|
@@ -140,6 +140,18 @@ the states, `data-fdy-no-icon` drops the trailing icon, and a `<template data-fd
|
|
|
140
140
|
replaces it. `readonly` is **not** `disabled`: full contrast, still focusable and copyable, opening
|
|
141
141
|
is a no-op.
|
|
142
142
|
|
|
143
|
+
**A host that renders its markup once sets the value through the enhancer**, silently: no change
|
|
144
|
+
event, so the binding that set it does not hear it back as a pick. `FreedayCombo.setValue(root, v)`,
|
|
145
|
+
`FreedayDatepicker.setValue(root, v)` (`YYYY-MM-DD`, `YYYY-MM` in month mode, `"start/end"` on a
|
|
146
|
+
single-field range), `FreedayDatepicker.setRange(root, from, to)` on a two-picker
|
|
147
|
+
`data-fdy-daterange` root (it relinks the end's minimum as a pick would), `FreedayTimepicker.setValue`,
|
|
148
|
+
`FreedayCascade.setValue`, and `FreedayAutocomplete.setValue(root, text)` with
|
|
149
|
+
`FreedayAutocomplete.setOptions(root, labels)`. An empty string clears. The Blazor wrappers call these
|
|
150
|
+
when a bound `Value`, `From`, `To` or `Options` changes after the first render; before 3.25.0 only
|
|
151
|
+
`FdyCombo` did, and the others kept showing their first value. The autocomplete also reads its
|
|
152
|
+
options from the list each time it uses them, so options an app renders later are filtered like the
|
|
153
|
+
rest.
|
|
154
|
+
|
|
143
155
|
**State classes** the enhancers set (read them, don't hand-author them): `is-active`,
|
|
144
156
|
`is-complete`, `is-open`, `is-selected`, `is-highlighted`, `is-filled`, `is-today`, `is-dragover`,
|
|
145
157
|
`is-leaving`, `is-error`, `is-disabled`, `is-hidden`, `is-visible`, `is-outside`.
|
|
@@ -1874,6 +1886,33 @@ replaces.
|
|
|
1874
1886
|
rather than rendering zero: a widget that shows 0 for a request that failed reads as "nothing to
|
|
1875
1887
|
do", the opposite of what happened.
|
|
1876
1888
|
|
|
1889
|
+
**Which state to render: `useLoad`** (Vue and React, from the same import path). One data load as
|
|
1890
|
+
one value, so a screen cannot be loading and failed at once, show its empty state beside its error,
|
|
1891
|
+
or show a form filled with defaults after the load meant to fill it failed:
|
|
1892
|
+
|
|
1893
|
+
| `state.status` | Also holds | Render |
|
|
1894
|
+
|---|---|---|
|
|
1895
|
+
| `'idle'` | nothing | nothing yet |
|
|
1896
|
+
| `'loading'` | `previous`: the last good data, or `null` | skeleton or `FdyTable`'s `loading` |
|
|
1897
|
+
| `'error'` | `error`, `previous` | `.fdy-state--danger` with Try again. Never the empty state. |
|
|
1898
|
+
| `'ready'` | `data` | the data, or one of the three empty states when it has none |
|
|
1899
|
+
|
|
1900
|
+
```js
|
|
1901
|
+
const { state, load } = useLoad((signal) => fetchInvoices(month.value, signal));
|
|
1902
|
+
onMounted(load);
|
|
1903
|
+
watch(month, load);
|
|
1904
|
+
```
|
|
1905
|
+
|
|
1906
|
+
- `load()` aborts the request before it (the fetcher receives an `AbortSignal`) and discards any
|
|
1907
|
+
answer that arrives after a newer load started, so a quick change of filter never leaves the
|
|
1908
|
+
older result on screen. Unmounting aborts what is in flight.
|
|
1909
|
+
- It returns a promise that settles when that load does and never rejects; the error is in `state`.
|
|
1910
|
+
- Data from an earlier load is reachable only as `previous`, so showing stale rows while reloading,
|
|
1911
|
+
or beside an error, is a decision visible in the template. A form that edits loaded data renders
|
|
1912
|
+
only under `'ready'`.
|
|
1913
|
+
- In React `load` is stable and calls the latest fetcher, so `useEffect(() => { void load(); },
|
|
1914
|
+
[month, load])` is enough.
|
|
1915
|
+
|
|
1877
1916
|
## Charts — `data-fdy-chart`
|
|
1878
1917
|
> **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.
|
|
1879
1918
|
|
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.25.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.25.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`.
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
hydration (ShouldRender => false); the initial value seeds the input. *@
|
|
8
8
|
<div @ref="Root" data-fdy-autocomplete class="@RootClass" style="@RootStyle">
|
|
9
9
|
<input @attributes="InputAttributes" class="fdy-input" role="combobox" aria-expanded="false" aria-autocomplete="list"
|
|
10
|
-
aria-controls="@_listId" autocomplete="off" value="@Value"
|
|
10
|
+
aria-controls="@_listId" autocomplete="off" value="@Value" @oninput="OnInputAsync"
|
|
11
11
|
placeholder="@Placeholder" aria-label="@AriaLabel"
|
|
12
12
|
id="@Id" aria-labelledby="@AriaLabelledby" aria-describedby="@Describedby"
|
|
13
13
|
disabled="@Disabled" readonly="@Readonly" required="@Required"
|
|
@@ -66,9 +66,30 @@ public partial class FdyAutocomplete
|
|
|
66
66
|
|
|
67
67
|
protected override bool ShouldRender() => !Hydrated;
|
|
68
68
|
|
|
69
|
+
/* What the seed shows until hydration, then what was last pushed, typed or picked. The seed is
|
|
70
|
+
rendered once, so Value and Options the host changed afterwards reached nothing (#123). */
|
|
71
|
+
private string? _shownValue;
|
|
72
|
+
private IReadOnlyList<string> _shownOptions = Array.Empty<string>();
|
|
73
|
+
|
|
69
74
|
protected override async Task OnParametersSetAsync()
|
|
70
75
|
{
|
|
71
|
-
if (!Hydrated)
|
|
76
|
+
if (!Hydrated)
|
|
77
|
+
{
|
|
78
|
+
_shownValue = Value;
|
|
79
|
+
_shownOptions = Options;
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
/* Compared by content: a host that rebuilds the same list on every render is not a change. */
|
|
83
|
+
if (!_shownOptions.SequenceEqual(Options))
|
|
84
|
+
{
|
|
85
|
+
_shownOptions = Options;
|
|
86
|
+
await JS.InvokeVoidAsync("FreedayAutocomplete.setOptions", Root, Options);
|
|
87
|
+
}
|
|
88
|
+
if (Value != _shownValue)
|
|
89
|
+
{
|
|
90
|
+
_shownValue = Value;
|
|
91
|
+
await JS.InvokeVoidAsync("FreedayAutocomplete.setValue", Root, Value ?? string.Empty);
|
|
92
|
+
}
|
|
72
93
|
await JS.InvokeVoidAsync("FreedayAutocomplete.setState", Root,
|
|
73
94
|
new { disabled = Disabled, @readonly = Readonly, invalid = Invalid, required = Required });
|
|
74
95
|
}
|
|
@@ -78,9 +99,21 @@ public partial class FdyAutocomplete
|
|
|
78
99
|
public async Task OnSelect(SelectDetail detail)
|
|
79
100
|
{
|
|
80
101
|
Value = detail.Value;
|
|
102
|
+
_shownValue = detail.Value;
|
|
81
103
|
await ValueChanged.InvokeAsync(detail.Value);
|
|
82
104
|
}
|
|
83
105
|
|
|
106
|
+
/// <summary>Free text, reported as it is typed, the same as the Vue and React components. Only a
|
|
107
|
+
/// pick used to reach <c>ValueChanged</c>, so a typed value that matched no suggestion showed in
|
|
108
|
+
/// the field while <c>Value</c> kept the old one.</summary>
|
|
109
|
+
private async Task OnInputAsync(ChangeEventArgs e)
|
|
110
|
+
{
|
|
111
|
+
string? text = e.Value?.ToString();
|
|
112
|
+
Value = text;
|
|
113
|
+
_shownValue = text;
|
|
114
|
+
await ValueChanged.InvokeAsync(text);
|
|
115
|
+
}
|
|
116
|
+
|
|
84
117
|
/// <summary>The (DOM-safe) detail of the enhancer's <c>fdy-autocomplete-select</c> event.</summary>
|
|
85
118
|
public sealed record SelectDetail(string? Value);
|
|
86
119
|
}
|
|
@@ -55,11 +55,24 @@ public partial class FdyCascade
|
|
|
55
55
|
|
|
56
56
|
protected override bool ShouldRender() => !Hydrated;
|
|
57
57
|
|
|
58
|
+
private string? _shownValue;
|
|
59
|
+
|
|
58
60
|
/* Pushed, not re-rendered: the seed's <ul> is consumed and removed by the enhancer, so this
|
|
59
61
|
component can never render again. */
|
|
60
62
|
protected override async Task OnParametersSetAsync()
|
|
61
63
|
{
|
|
62
|
-
|
|
64
|
+
/* What the seed shows until hydration, then what was last pushed or picked. The seed is
|
|
65
|
+
rendered once, so a Value the host changes afterwards reached nothing (#123). */
|
|
66
|
+
if (!Hydrated)
|
|
67
|
+
{
|
|
68
|
+
_shownValue = Value;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (Value != _shownValue)
|
|
72
|
+
{
|
|
73
|
+
_shownValue = Value;
|
|
74
|
+
await JS.InvokeVoidAsync("FreedayCascade.setValue", Root, Value ?? string.Empty);
|
|
75
|
+
}
|
|
63
76
|
await JS.InvokeVoidAsync("FreedayCascade.setState", Root,
|
|
64
77
|
new { disabled = Disabled, @readonly = Readonly, invalid = Invalid, required = Required });
|
|
65
78
|
}
|
|
@@ -69,6 +82,7 @@ public partial class FdyCascade
|
|
|
69
82
|
public async Task OnChange(ChangeDetail detail)
|
|
70
83
|
{
|
|
71
84
|
Value = detail.Value;
|
|
85
|
+
_shownValue = detail.Value;
|
|
72
86
|
await ValueChanged.InvokeAsync(detail.Value);
|
|
73
87
|
}
|
|
74
88
|
|
|
@@ -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(
|
|
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)
|
|
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)
|
|
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(
|
|
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>
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
}
|
|
28
28
|
else
|
|
29
29
|
{
|
|
30
|
-
<div data-fdy-daterange role="group" aria-label="@AriaLabel">
|
|
30
|
+
<div @ref="_splitEl" data-fdy-daterange role="group" aria-label="@AriaLabel">
|
|
31
31
|
<div @ref="_fromEl" data-fdy-datepicker data-role="from" data-fdy-required="@(Required ? "" : null)"
|
|
32
32
|
data-value="@From" data-placeholder="@FromPlaceholder" data-min="@Min" data-max="@Max"
|
|
33
33
|
data-fdy-text-prev-month="@PrevMonthLabel"
|
|
@@ -68,6 +68,12 @@ public partial class FdyDateRange
|
|
|
68
68
|
private ElementReference _fromEl;
|
|
69
69
|
private ElementReference _toEl;
|
|
70
70
|
private ElementReference _singleEl;
|
|
71
|
+
private ElementReference _splitEl;
|
|
72
|
+
|
|
73
|
+
/* What the seed shows until hydration, then what was last pushed or picked. The seed is
|
|
74
|
+
rendered once, so From and To the host changed afterwards reached nothing (#123). */
|
|
75
|
+
private string? _shownFrom;
|
|
76
|
+
private string? _shownTo;
|
|
71
77
|
|
|
72
78
|
/// <summary>"from/to" (ISO 8601 interval), the one <c>data-value</c> the single field reads,
|
|
73
79
|
/// or null while either end is missing: the field never shows half a range.</summary>
|
|
@@ -90,7 +96,21 @@ public partial class FdyDateRange
|
|
|
90
96
|
|
|
91
97
|
protected override async Task OnParametersSetAsync()
|
|
92
98
|
{
|
|
93
|
-
if (!Hydrated)
|
|
99
|
+
if (!Hydrated)
|
|
100
|
+
{
|
|
101
|
+
_shownFrom = From;
|
|
102
|
+
_shownTo = To;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (From != _shownFrom || To != _shownTo)
|
|
106
|
+
{
|
|
107
|
+
_shownFrom = From;
|
|
108
|
+
_shownTo = To;
|
|
109
|
+
if (Layout == FdyDateRangeLayout.Single)
|
|
110
|
+
await JS.InvokeVoidAsync("FreedayDatepicker.setValue", _singleEl, SeedInterval ?? string.Empty);
|
|
111
|
+
else
|
|
112
|
+
await JS.InvokeVoidAsync("FreedayDatepicker.setRange", _splitEl, From ?? string.Empty, To ?? string.Empty);
|
|
113
|
+
}
|
|
94
114
|
if (Layout == FdyDateRangeLayout.Single)
|
|
95
115
|
{
|
|
96
116
|
await JS.InvokeVoidAsync("FreedayDatepicker.setState", _singleEl, new { required = Required });
|
|
@@ -107,11 +127,13 @@ public partial class FdyDateRange
|
|
|
107
127
|
if (detail.Role == "from")
|
|
108
128
|
{
|
|
109
129
|
From = detail.Value;
|
|
130
|
+
_shownFrom = detail.Value;
|
|
110
131
|
await FromChanged.InvokeAsync(detail.Value);
|
|
111
132
|
}
|
|
112
133
|
else if (detail.Role == "to")
|
|
113
134
|
{
|
|
114
135
|
To = detail.Value;
|
|
136
|
+
_shownTo = detail.Value;
|
|
115
137
|
await ToChanged.InvokeAsync(detail.Value);
|
|
116
138
|
}
|
|
117
139
|
if (string.IsNullOrEmpty(From) == string.IsNullOrEmpty(To))
|
|
@@ -127,6 +149,8 @@ public partial class FdyDateRange
|
|
|
127
149
|
{
|
|
128
150
|
From = detail.From;
|
|
129
151
|
To = detail.To;
|
|
152
|
+
_shownFrom = detail.From;
|
|
153
|
+
_shownTo = detail.To;
|
|
130
154
|
await FromChanged.InvokeAsync(detail.From);
|
|
131
155
|
await ToChanged.InvokeAsync(detail.To);
|
|
132
156
|
await Settled.InvokeAsync(new SettledRange(From, To));
|
|
@@ -89,12 +89,25 @@ public partial class FdyDatepicker
|
|
|
89
89
|
// The enhancer owns the built trigger + calendar; never let Blazor re-render the seed.
|
|
90
90
|
protected override bool ShouldRender() => !Hydrated;
|
|
91
91
|
|
|
92
|
+
private string? _shownValue;
|
|
93
|
+
|
|
92
94
|
/* Which is exactly why the three states are pushed rather than re-rendered: the seed above is
|
|
93
95
|
written once, so a page that disables this field later would otherwise be ignored in
|
|
94
96
|
silence. */
|
|
95
97
|
protected override async Task OnParametersSetAsync()
|
|
96
98
|
{
|
|
97
|
-
|
|
99
|
+
/* What the seed shows until hydration, then what was last pushed or picked. The seed is
|
|
100
|
+
rendered once, so a Value the host changes afterwards reached nothing (#123). */
|
|
101
|
+
if (!Hydrated)
|
|
102
|
+
{
|
|
103
|
+
_shownValue = Value;
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (Value != _shownValue)
|
|
107
|
+
{
|
|
108
|
+
_shownValue = Value;
|
|
109
|
+
await JS.InvokeVoidAsync("FreedayDatepicker.setValue", Root, Value ?? string.Empty);
|
|
110
|
+
}
|
|
98
111
|
await JS.InvokeVoidAsync("FreedayDatepicker.setState", Root,
|
|
99
112
|
new { disabled = Disabled, @readonly = Readonly, invalid = Invalid, required = Required });
|
|
100
113
|
}
|
|
@@ -104,6 +117,7 @@ public partial class FdyDatepicker
|
|
|
104
117
|
public async Task OnChange(ChangeDetail detail)
|
|
105
118
|
{
|
|
106
119
|
Value = detail.Value;
|
|
120
|
+
_shownValue = detail.Value;
|
|
107
121
|
await ValueChanged.InvokeAsync(detail.Value);
|
|
108
122
|
}
|
|
109
123
|
|
|
@@ -87,11 +87,24 @@ public partial class FdyMonthpicker
|
|
|
87
87
|
// The enhancer owns the built trigger + calendar; never let Blazor re-render the seed.
|
|
88
88
|
protected override bool ShouldRender() => !Hydrated;
|
|
89
89
|
|
|
90
|
+
private string? _shownValue;
|
|
91
|
+
|
|
90
92
|
/* Which is why the three states are pushed rather than re-rendered: the seed is written once,
|
|
91
93
|
so a page that disables this field later would otherwise be ignored in silence. */
|
|
92
94
|
protected override async Task OnParametersSetAsync()
|
|
93
95
|
{
|
|
94
|
-
|
|
96
|
+
/* What the seed shows until hydration, then what was last pushed or picked. The seed is
|
|
97
|
+
rendered once, so a Value the host changes afterwards reached nothing (#123). */
|
|
98
|
+
if (!Hydrated)
|
|
99
|
+
{
|
|
100
|
+
_shownValue = Value;
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (Value != _shownValue)
|
|
104
|
+
{
|
|
105
|
+
_shownValue = Value;
|
|
106
|
+
await JS.InvokeVoidAsync("FreedayDatepicker.setValue", Root, Value ?? string.Empty);
|
|
107
|
+
}
|
|
95
108
|
await JS.InvokeVoidAsync("FreedayDatepicker.setState", Root,
|
|
96
109
|
new { disabled = Disabled, @readonly = Readonly, invalid = Invalid, required = Required });
|
|
97
110
|
}
|
|
@@ -101,6 +114,7 @@ public partial class FdyMonthpicker
|
|
|
101
114
|
public async Task OnChange(ChangeDetail detail)
|
|
102
115
|
{
|
|
103
116
|
Value = detail.Value;
|
|
117
|
+
_shownValue = detail.Value;
|
|
104
118
|
await ValueChanged.InvokeAsync(detail.Value);
|
|
105
119
|
}
|
|
106
120
|
|
|
@@ -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
|
-
|
|
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;
|
|
@@ -64,11 +64,24 @@ public partial class FdyTimepicker
|
|
|
64
64
|
// The enhancer owns the built trigger + listbox; never let Blazor re-render the seed.
|
|
65
65
|
protected override bool ShouldRender() => !Hydrated;
|
|
66
66
|
|
|
67
|
+
private string? _shownValue;
|
|
68
|
+
|
|
67
69
|
/* Which is exactly why the three states are pushed rather than re-rendered: the seed above is
|
|
68
70
|
written once, so a page that disables this field later would otherwise be ignored. */
|
|
69
71
|
protected override async Task OnParametersSetAsync()
|
|
70
72
|
{
|
|
71
|
-
|
|
73
|
+
/* What the seed shows until hydration, then what was last pushed or picked. The seed is
|
|
74
|
+
rendered once, so a Value the host changes afterwards reached nothing (#123). */
|
|
75
|
+
if (!Hydrated)
|
|
76
|
+
{
|
|
77
|
+
_shownValue = Value;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (Value != _shownValue)
|
|
81
|
+
{
|
|
82
|
+
_shownValue = Value;
|
|
83
|
+
await JS.InvokeVoidAsync("FreedayTimepicker.setValue", Root, Value ?? string.Empty);
|
|
84
|
+
}
|
|
72
85
|
await JS.InvokeVoidAsync("FreedayTimepicker.setState", Root,
|
|
73
86
|
new { disabled = Disabled, @readonly = Readonly, invalid = Invalid, required = Required });
|
|
74
87
|
}
|
|
@@ -78,6 +91,7 @@ public partial class FdyTimepicker
|
|
|
78
91
|
public async Task OnSelect(SelectDetail detail)
|
|
79
92
|
{
|
|
80
93
|
Value = detail.Value;
|
|
94
|
+
_shownValue = detail.Value;
|
|
81
95
|
await ValueChanged.InvokeAsync(detail.Value);
|
|
82
96
|
}
|
|
83
97
|
|
|
@@ -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)
|
|
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>;
|