@cahyo-dimas/freeday 3.16.1 → 3.18.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 +113 -0
- package/COMPONENTS.md +60 -20
- package/README.id.md +1 -1
- package/README.md +1 -1
- package/adapters/blazor/FdyAutocomplete.razor +1 -1
- package/adapters/blazor/FdyAutocomplete.razor.cs +6 -1
- package/adapters/blazor/FdyCascade.razor.cs +1 -1
- package/adapters/blazor/FdyCfl.razor +2 -2
- package/adapters/blazor/FdyCfl.razor.cs +13 -0
- package/adapters/blazor/FdyCombo.razor.cs +1 -1
- package/adapters/blazor/FdyDateRange.razor +2 -2
- package/adapters/blazor/FdyDateRange.razor.cs +14 -0
- package/adapters/blazor/FdyDatepicker.razor.cs +1 -1
- package/adapters/blazor/FdyMonthpicker.razor.cs +1 -1
- package/adapters/blazor/FdyTimepicker.razor.cs +1 -1
- package/adapters/blazor/freeday-blazor.js +13 -4
- package/adapters/react/components/FdyAutocomplete.tsx +5 -0
- package/adapters/react/components/FdyCfl.tsx +11 -1
- package/adapters/react/components/FdyDateRange.tsx +5 -0
- package/adapters/react/index.d.ts +26 -0
- package/adapters/react/index.js +1 -0
- package/adapters/react/useTheme.js +35 -0
- package/adapters/vue/components/FdyAutocomplete.vue +5 -0
- package/adapters/vue/components/FdyCfl.vue +11 -1
- package/adapters/vue/components/FdyDateRange.vue +5 -0
- package/adapters/vue/index.d.ts +26 -0
- package/adapters/vue/index.js +1 -0
- package/adapters/vue/useTheme.js +47 -0
- package/dist/freeday-autocomplete.js +6 -1
- package/dist/freeday-cascade.js +13 -2
- package/dist/freeday-cfl.js +12 -1
- package/dist/freeday-datepicker.js +13 -2
- package/dist/freeday-form.js +21 -5
- package/dist/freeday-select.js +8 -1
- package/dist/freeday-theme.js +115 -0
- package/dist/freeday-timepicker.js +13 -2
- package/dist/freeday.js +202 -14
- package/docs/getting-started.md +4 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,119 @@ 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.18.0] - 2026-11-07
|
|
13
|
+
|
|
14
|
+
**Setiap kontrol bernilai kini dapat dijadikan wajib, di ketiga stack.** 3.12.0 (`#096`) memberi
|
|
15
|
+
`required` ke lima kontrol berpemicu tombol dan meninggalkan tiga (`CATATAN-FREEDAY.md` §24).
|
|
16
|
+
Akibatnya, menukar isian wajib ke `FdyAutocomplete` **membuang validasinya tanpa suara**: tidak ada
|
|
17
|
+
galat dan tidak ada peringatan. Formulirnya hanya berhenti menuntut isian itu. Audit kelasnya
|
|
18
|
+
menemukan dua kontrol lain dengan celah yang sama, dua cacat di aturan validasinya sendiri, dan
|
|
19
|
+
satu cacat di semua jembatan Blazor.
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
- **`required` di `FdyAutocomplete`** (`#114`), Vue · React · Blazor (`Required`). Ini `required`
|
|
23
|
+
**native**, dipasang di input-nya. Input itu dapat disunting, jadi validasi bawaan peramban
|
|
24
|
+
sudah berlaku seperti pada `<input>` lain.
|
|
25
|
+
- **`required` di `FdyCfl`** (`#114`), ketiga stack. Ia merender `data-fdy-required` di grup
|
|
26
|
+
isiannya, dan grup itu kini mencerminkan kunci baris terpilih (`rowKey`, dipisah koma bila
|
|
27
|
+
`multiple`) di `data-value`. Penolakan menandai dan memfokuskan tombol pembuka.
|
|
28
|
+
- **`required` di `FdyDateRange`** (`#114`), ketiga stack, diteruskan ke **kedua** ujung. Prop ini
|
|
29
|
+
tidak ada di daftar §24. Masing-masing datepicker sudah punya `required`, tetapi tidak ada prop
|
|
30
|
+
rentang yang meneruskannya.
|
|
31
|
+
- **Jalur mentah `freeday-cfl.js` mencerminkan `data-value`** di grup isiannya setiap kali baris
|
|
32
|
+
dipilih. Nilainya `data-value` baris itu, atau kunci tampilannya bila baris tidak punya. Dengan
|
|
33
|
+
begitu `data-fdy-required` di grup bekerja tanpa pembungkus.
|
|
34
|
+
- **`setState(root, { required })`** di kelima enhancer yang punya `setState` (combo, datepicker
|
|
35
|
+
termasuk mode bulan, timepicker, cascade, autocomplete).
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
- **Dua kontrol dalam satu `.fdy-field` saling menghapus pesan** (`#114`). Slot pesan dicari per
|
|
39
|
+
field, jadi mengisi ujung "dari" pada rentang menghapus pesan yang masih dibutuhkan ujung
|
|
40
|
+
"sampai". Akibatnya ujung itu tetap merah tanpa keterangan. Cacat yang sama mengenai dua input
|
|
41
|
+
native yang berdampingan. Kini slotnya tetap tampil selama masih ada kontrol yang merujuknya dan
|
|
42
|
+
masih invalid.
|
|
43
|
+
- **`Required` di Blazor hanya terbaca saat render pertama** (`#114`), di kelima kontrol 3.12.0.
|
|
44
|
+
Sesudah hidrasi komponennya berhenti merender, dan `setState` tidak membawa `required`. Isian
|
|
45
|
+
yang wajib secara bersyarat (`Required="@isPerusahaan"`) tidak pernah ikut berubah. Kini
|
|
46
|
+
`Required` ikut didorong bersama tiga state lainnya.
|
|
47
|
+
- **Mencabut syarat wajib tidak menghapus galat yang sedang tampil.** `MutationObserver` aturan
|
|
48
|
+
form kini juga mengamati `data-fdy-required`, dan akar yang tak lagi wajib tidak pernah ditolak.
|
|
49
|
+
- **Dorongan `setState` yang tidak mengubah apa pun menghapus tanda merah dari form** (`#114`).
|
|
50
|
+
Blazor mendorong semua state setiap kali induknya merender ulang. Menulis ulang `invalid: false`
|
|
51
|
+
yang tidak berubah mencabut `aria-invalid` yang dipasang `freeday-form.js`, sehingga pesannya
|
|
52
|
+
tertinggal di bawah isian yang tidak lagi merah. Kelima enhancer kini menulis `aria-invalid`
|
|
53
|
+
hanya bila `invalid` dari host benar-benar berubah. Vue dan React tidak terkena: keduanya hanya
|
|
54
|
+
menambal atribut yang ikatannya berubah.
|
|
55
|
+
- **Tombol pembuka `FdyCfl` di Blazor tidak punya `aria-haspopup="dialog"`**, padahal Vue dan
|
|
56
|
+
React memilikinya. Aturan form mencari elemen yang ditandai lewat atribut itu.
|
|
57
|
+
|
|
58
|
+
### Catatan
|
|
59
|
+
- **Koreksi atas 3.12.0.** Catatan rilis itu menulis bahwa `FdyAutocomplete` dan `FdyCfl`
|
|
60
|
+
"merender `<input>` asli, jadi `required` native yang cocok". Untuk Cfl itu keliru. Input-nya
|
|
61
|
+
`readonly`, dan input readonly dikecualikan dari validasi bawaan peramban (`willValidate`
|
|
62
|
+
bernilai `false`), jadi `required` di sana tidak pernah menolak apa pun. Usulan §24 menyalin
|
|
63
|
+
kekeliruan itu. Seandainya diterapkan apa adanya, Cfl akan tampak wajib tanpa pernah menolak.
|
|
64
|
+
Ujinya kini menegaskan `willValidate === false` di fixture, supaya tidak ada yang mengembalikan
|
|
65
|
+
Cfl ke jalur native.
|
|
66
|
+
- Penimpaan pesan per-kontrol (`data-fdy-msg-required`) pada `FdyDateRange` Vue jatuh ke akar
|
|
67
|
+
`.fdy-daterange`, bukan ke kedua datepicker yang membacanya. Pakai `data-fdy-text-required` di
|
|
68
|
+
`<form>`, seperti di React dan Blazor.
|
|
69
|
+
|
|
70
|
+
## [3.17.0] - 2026-11-05
|
|
71
|
+
|
|
72
|
+
**Pengalih tema terang/gelap, siap pakai di semua stack.** Setiap app sebelumnya menulis sendiri
|
|
73
|
+
penyimpanan pilihan, pembacaan `prefers-color-scheme`, dan pemasangan `data-theme`, sambil menebak
|
|
74
|
+
kontrak kit dari dokumen (`CATATAN-FREEDAY.md` §23). Catatan itu menyebut Blazor sudah punya.
|
|
75
|
+
Sebenarnya `FreedayBlazor.toggleTheme()` hanya pembantu demo: ia membalik atribut di `<html>`,
|
|
76
|
+
tidak menyimpan apa pun, dan tidak bisa kembali ke "ikuti sistem". Jadi tidak ada satu stack pun
|
|
77
|
+
yang punya.
|
|
78
|
+
|
|
79
|
+
### Added
|
|
80
|
+
- **`freeday-theme.js` → `window.FreedayTheme`** (`#113`), ikut di `freeday.js`:
|
|
81
|
+
- `get()`, `resolved()`, `set(theme)`, `toggle()`, `attach(el)`, dan event `fdy-theme-change`
|
|
82
|
+
di `document` dengan detail `{ theme, resolved }`.
|
|
83
|
+
- Satu pilihan per perangkat: `'light'`, `'dark'`, atau `'system'`, disimpan di `localStorage`
|
|
84
|
+
dan diterapkan ke `<html>`. Nilai lain ditolak dengan `TypeError`.
|
|
85
|
+
- `'system'` **mencabut** `data-theme`, tidak menghitung nilainya. Token sudah mengikuti OS
|
|
86
|
+
selama tidak ada `data-theme`, jadi pergantian OS langsung terlihat tanpa listener yang
|
|
87
|
+
memutuskan apa pun. Event tetap dikirim supaya ikon tombol ikut berganti.
|
|
88
|
+
- `toggle()` membalik yang **tampil** di layar, bukan pilihannya. Di OS gelap dengan pilihan
|
|
89
|
+
`'system'`, tekan pertama menuju terang.
|
|
90
|
+
- `attach(el)` menyerahkan wilayah yang `data-theme`-nya ditulis tetap di markup kepada pilihan
|
|
91
|
+
pengguna, dan mengembalikan fungsi pelepas. Tanpa itu, atribut subtree selalu menang atas
|
|
92
|
+
atribut dokumen.
|
|
93
|
+
- Pilihan yang tersimpan diterapkan saat dimuat. Kalau tidak ada yang tersimpan, tidak ada yang
|
|
94
|
+
disentuh, jadi markup yang membawa `data-theme` sendiri tetap utuh.
|
|
95
|
+
- **`useTheme(rootRef?)` di Vue dan React**, mengembalikan `theme`, `resolved`, `setTheme`, dan
|
|
96
|
+
`toggleTheme`. Kedua adapter memuat inti yang sama sendiri, jadi tidak perlu impor akar, dan
|
|
97
|
+
inti hanya terdaftar sekali walaupun dimuat dari dua jalur. Semua pemanggil di satu halaman
|
|
98
|
+
tetap sinkron. Ref yang diberikan di-`attach` saat mount dan dilepas saat unmount.
|
|
99
|
+
- **Blazor:** `FreedayBlazor.setTheme`, `getTheme`, dan `getResolvedTheme`. `toggleTheme()` kini
|
|
100
|
+
memakai inti yang sama, jadi ikut menyimpan dan mengenal `'system'`.
|
|
101
|
+
- **Cuplikan satu baris untuk `<head>`** di `COMPONENTS.md`, untuk menerapkan pilihan sebelum paint
|
|
102
|
+
pertama. Gate baru di `test/docs.test.mjs` memastikan cuplikan itu membaca kunci yang ditulis inti,
|
|
103
|
+
dan fixture uji menjalankan cuplikan yang persis sama.
|
|
104
|
+
|
|
105
|
+
### Changed
|
|
106
|
+
- `FreedayBlazor.toggleTheme()` kini **menyimpan** pilihannya di `localStorage` dan membutuhkan
|
|
107
|
+
`freeday.js` sudah dimuat. Tanpa itu ia melempar `Error` yang menyebut berkas yang kurang.
|
|
108
|
+
Sebelumnya ia hanya membalik atribut di `<html>`.
|
|
109
|
+
|
|
110
|
+
### Catatan
|
|
111
|
+
- Uji baru `browser/theme-pref.mjs` (6 uji) memeriksa atribut, nilai tersimpan, dan **warna kartu
|
|
112
|
+
yang benar-benar dicat**, dicocokkan dengan kartu acuan terang dan gelap. Pengaturan OS diemulasi
|
|
113
|
+
sebagai fitur media sungguhan lewat CDP, bukan `matchMedia` palsu. Sembilan mutasi (system
|
|
114
|
+
menghitung nilai, tanpa listener OS, toggle membalik pilihan, tanpa penerapan saat dimuat, root
|
|
115
|
+
diabaikan, tanpa validasi, dan dua adapter tanpa pelepas atau tanpa listener) semuanya merah.
|
|
116
|
+
- Harness mendapat `setColorScheme()`. Event `change` dari `MediaQueryList` dikirim pada langkah
|
|
117
|
+
rendering, dan polling lewat CDP tidak pernah menjalankan langkah itu. Tanpa menunggu dua frame,
|
|
118
|
+
listener tetap diam: terukur tanpa event selama 4 detik polling, lalu satu event sesudah dua
|
|
119
|
+
frame.
|
|
120
|
+
- Gate string `#016` kini juga melewati pesan `throw new …Error(…)`, dengan alasan yang sama seperti
|
|
121
|
+
`console.warn`: teks itu untuk devtools pengembang, tidak pernah masuk DOM.
|
|
122
|
+
- `examples/vue-faktur` berhenti menulis pengalih temanya sendiri dan memakai `useTheme()`.
|
|
123
|
+
- Sinkronisasi antar-tab sengaja tidak dibuat. Tab lain mengikuti pilihan baru saat dimuat ulang.
|
|
124
|
+
|
|
12
125
|
## [3.16.1] - 2026-11-04
|
|
13
126
|
|
|
14
127
|
**Slot teks kit di atas `<p>` tidak lagi membawa margin bawaan peramban.** `<p>` punya margin 1em
|
package/COMPONENTS.md
CHANGED
|
@@ -126,6 +126,7 @@ element is fine. Events are bubbling
|
|
|
126
126
|
| — (imperative, returns `Promise<boolean>`) | `freeday-confirm.js` | `Freeday.confirm()` | — |
|
|
127
127
|
| — (stamps `<html data-breakpoint>`) | `freeday-breakpoint.js` | `FreedayBreakpoint` | `fdy-breakpoint-change` |
|
|
128
128
|
| — (internal positioning) | `freeday-popover.js` | `FreedayPopover` | — |
|
|
129
|
+
| — (theme preference, see below) | `freeday-theme.js` | `FreedayTheme` | `fdy-theme-change` (on `document`) |
|
|
129
130
|
|
|
130
131
|
**Shared conventions across the select-type widgets** (combo, cascade, datepicker, daterange,
|
|
131
132
|
timepicker, autocomplete, cfl): `data-value` seeds the value, `data-placeholder` the empty text,
|
|
@@ -497,6 +498,33 @@ lightness that a panel four times more transparent still passed. So glass here i
|
|
|
497
498
|
the effect people actually see comes from the blur, not from the alpha. Put a photo or a gradient
|
|
498
499
|
behind a panel and the promise still holds; that is what "over any ground" buys.
|
|
499
500
|
|
|
501
|
+
**Theme preference: `FreedayTheme` / `useTheme()`.** The light/dark switch, ready made. One choice
|
|
502
|
+
per device, `'light'`, `'dark'` or `'system'`, stored in `localStorage` and applied to `<html>`.
|
|
503
|
+
`'system'` removes `data-theme`, so the tokens follow the OS and an OS switch repaints the page
|
|
504
|
+
without a reload.
|
|
505
|
+
|
|
506
|
+
| | Vue / React | Blazor | Anything else |
|
|
507
|
+
|---|---|---|---|
|
|
508
|
+
| read | `useTheme()` → `theme`, `resolved` | `FreedayBlazor.getTheme()`, `getResolvedTheme()` | `FreedayTheme.get()`, `.resolved()` |
|
|
509
|
+
| change | `setTheme(t)`, `toggleTheme()` | `FreedayBlazor.setTheme(t)`, `toggleTheme()` | `FreedayTheme.set(t)`, `.toggle()` |
|
|
510
|
+
|
|
511
|
+
- **Label the button from `resolved`, not `theme`.** `resolved` is what is on screen; `theme` is
|
|
512
|
+
`'system'` until someone chooses. `toggle` flips what is on screen, so the first press always
|
|
513
|
+
changes it.
|
|
514
|
+
- **Every caller shares one preference.** Two toggles in two shells stay in step, through
|
|
515
|
+
`fdy-theme-change` (detail `{ theme, resolved }`).
|
|
516
|
+
- **A region with its own `data-theme` in markup keeps it**, because a subtree's attribute beats the
|
|
517
|
+
document's. To hand it to the preference, pass its ref (`useTheme(regionRef)`) or call
|
|
518
|
+
`FreedayTheme.attach(el)`, which returns a detacher. Under `'system'` that removes the fixed value.
|
|
519
|
+
- `useTheme()` loads the core itself; no `import '@cahyo-dimas/freeday'` is needed for it.
|
|
520
|
+
- **Apply the stored choice before first paint** with this line as the first script in `<head>`.
|
|
521
|
+
Without it the kit still applies the choice once it loads, but the page shows the default for a
|
|
522
|
+
moment first:
|
|
523
|
+
|
|
524
|
+
```html
|
|
525
|
+
<script>try{var t=localStorage.getItem('fdy-theme');if(t==='light'||t==='dark')document.documentElement.setAttribute('data-theme',t)}catch(e){}</script>
|
|
526
|
+
```
|
|
527
|
+
|
|
500
528
|
**Primary palette: `data-primary`.** 18 options — `azure` (the default, and what you get with no
|
|
501
529
|
attribute) · `sky` `blue` `indigo` `violet` `purple` `fuchsia` `pink` `rose` · `orange` `amber`
|
|
502
530
|
`yellow` `lime` `green` `emerald` `teal` `cyan` · `noir`. Set it anywhere `data-theme` works,
|
|
@@ -779,8 +807,11 @@ while each line referenced directly would be read even when hidden. Zero JS; wor
|
|
|
779
807
|
| `describedby?` | `string` | Id of the help or error text (`aria-describedby`). |
|
|
780
808
|
|
|
781
809
|
Blazor: the same names in `PascalCase`, bound with `@bind-Value` (`Value` / `ValueChanged`).
|
|
782
|
-
`FreedayCombo.setState(root, { disabled, readonly, invalid })` pushes a state change onto
|
|
783
|
-
whose host has stopped re-rendering.
|
|
810
|
+
`FreedayCombo.setState(root, { disabled, readonly, invalid, required })` pushes a state change onto
|
|
811
|
+
a combo whose host has stopped re-rendering. `invalid` is written only when it changes, so a host
|
|
812
|
+
that pushes every state on every re-render does not erase the mark a
|
|
813
|
+
[`data-fdy-validate`](#form-validation--data-fdy-validate) form painted; the same holds for every
|
|
814
|
+
`setState` below.
|
|
784
815
|
|
|
785
816
|
Fully styleable dropdown, APG combobox+listbox. Needs `freeday-select.js`.
|
|
786
817
|
|
|
@@ -823,9 +854,10 @@ keeps matching after selection. Do not put a glyph in that span.
|
|
|
823
854
|
| `placeholder?` | `string` | |
|
|
824
855
|
| `id?` · `ariaLabel?` · `ariaLabelledby?` · `describedby?` | `string` | Input id; its accessible name as text or as a reference; the help/error text it points at. |
|
|
825
856
|
| `disabled?` · `readonly?` · `invalid?` | `boolean` | `readonly` keeps focus and tab order and shows its value, but the input is not editable and the list will not open. Unlike `disabled` it is not greyed. |
|
|
857
|
+
| `required?` | `boolean` | The native `required`, on the input itself. The input is editable, so constraint validation applies to it as to any `<input>`, and a [`data-fdy-validate`](#form-validation--data-fdy-validate) form refuses it empty. Free text counts as filled: the list suggests, it does not constrain. Blazor: `Required`. |
|
|
826
858
|
|
|
827
859
|
Blazor carries all of these. The states live on the input natively, and
|
|
828
|
-
`FreedayAutocomplete.setState(root, { disabled, readonly, invalid })` changes them after the first
|
|
860
|
+
`FreedayAutocomplete.setState(root, { disabled, readonly, invalid, required })` changes them after the first
|
|
829
861
|
render. A `readonly` input no longer opens its suggestion list, which it used to do over a field
|
|
830
862
|
nobody could edit.
|
|
831
863
|
|
|
@@ -854,7 +886,7 @@ Editable combobox that filters as you type. Needs `freeday-autocomplete.js`.
|
|
|
854
886
|
| `required?` | `boolean` | Lets a [`data-fdy-validate`](#form-validation--data-fdy-validate) form demand this control be filled. Renders `data-fdy-required` on the root. Needed because the trigger is a `<button>`, whose `willValidate` is false, so a plain `required` on it has never meant anything. Blazor: `Required`. |
|
|
855
887
|
|
|
856
888
|
Raw path: `data-disabled` / `data-readonly` / `data-invalid`, `data-id`, `data-describedby`, and
|
|
857
|
-
`FreedayCascade.setState(root, { disabled, readonly, invalid })` for a host that rendered once.
|
|
889
|
+
`FreedayCascade.setState(root, { disabled, readonly, invalid, required })` for a host that rendered once.
|
|
858
890
|
Blazor calls the tree `Nodes`, adds `SubmenuLabel`, and carries everything else except
|
|
859
891
|
`ariaLabelledby` — the trigger it builds is named by `Label`.
|
|
860
892
|
|
|
@@ -912,6 +944,7 @@ Four of these are required and carry the whole component: `fetchPage`, `columns`
|
|
|
912
944
|
| `clearable?` | `boolean` | A clear button, so an **optional** foreign key can be unset. Without it the value type admits a `null` the component can never produce. |
|
|
913
945
|
| `clearLabel?` | `string` | Accessible name for that button. Default `Clear selection`. |
|
|
914
946
|
| `disabled?` · `readonly?` · `invalid?` | `boolean` | `readonly` keeps the picked value visible, focusable and copyable, but the dialog cannot be opened. |
|
|
947
|
+
| `required?` | `boolean` | Lets a [`data-fdy-validate`](#form-validation--data-fdy-validate) form demand a row be picked. Renders `data-fdy-required` on the field group, which mirrors the picked keys (`rowKey`, comma-joined under `multiple`) in `data-value`; the refusal marks and focuses the open button. **Not** a native `required`: the field's input is readonly, and a readonly input is barred from constraint validation, so `required` on it never refuses anything. Ignored with `dialogOnly`. Blazor: `Required`. |
|
|
915
948
|
| `id?` · `ariaLabelledby?` · `describedby?` | `string` | Field id; the element that labels it; the help/error text it points at. |
|
|
916
949
|
| `dialogOnly?` | `boolean` | Render the **dialog and no field**, for a caller whose trigger is already its own. See below. |
|
|
917
950
|
|
|
@@ -948,7 +981,10 @@ A read-only field backed by master data: the button opens a searchable dialog, t
|
|
|
948
981
|
the field. The value is always **chosen, never typed**. Needs `freeday-cfl.js`.
|
|
949
982
|
|
|
950
983
|
- Field: `.fdy-input-group` + `data-fdy-cfl="<dialog id>"`, `data-fdy-cfl-display="code"`,
|
|
951
|
-
`data-fdy-cfl-summary="{n} selected"` (multi)
|
|
984
|
+
`data-fdy-cfl-summary="{n} selected"` (multi). On pick the group mirrors the row's `data-value`
|
|
985
|
+
(else its display key; comma-joined in multi) into its own `data-value`, so `data-fdy-required`
|
|
986
|
+
on the group lets a `data-fdy-validate` form require it. Give the trigger `aria-haspopup="dialog"`:
|
|
987
|
+
that is the element the refusal marks and focuses.
|
|
952
988
|
- Dialog: `<dialog class="fdy-modal fdy-modal--cfl">` + `data-fdy-cfl-multiple` for multi-select
|
|
953
989
|
- Inside: `.fdy-cfl__search` `__results` `__row` `__check` `__empty` `__count` `__actions`
|
|
954
990
|
- Hooks: `data-fdy-cfl-search` (the search input), `data-fdy-cfl-empty`, `data-fdy-cfl-count`,
|
|
@@ -1042,8 +1078,8 @@ them do not: without these, a Spanish calendar would be navigated by English arr
|
|
|
1042
1078
|
On the **raw path** these all have hooks now: `data-disabled` / `data-readonly` / `data-invalid`,
|
|
1043
1079
|
`data-id`, `data-describedby`, and one `data-fdy-text-<key>` per label above
|
|
1044
1080
|
(`data-fdy-text-prev-month`, …). A host that renders its markup once and cannot re-render it can
|
|
1045
|
-
change the
|
|
1046
|
-
invalid })`.
|
|
1081
|
+
change the states afterwards with `FreedayDatepicker.setState(root, { disabled, readonly,
|
|
1082
|
+
invalid, required })`.
|
|
1047
1083
|
|
|
1048
1084
|
Blazor carries the same surface bar four: `locale` (the enhancer formats through `Intl` from the
|
|
1049
1085
|
page's `<html lang>`), `clearable` and `clearLabel` (this path builds no clear button), and
|
|
@@ -1089,6 +1125,7 @@ grid's own title.
|
|
|
1089
1125
|
| `startPlaceholder?` · `endPlaceholder?` | `string` | One per field. |
|
|
1090
1126
|
| `ariaLabel?` · `ariaLabelledby?` · `describedby?` | `string` | Names the group (`role="group"`), or points at the text that does. |
|
|
1091
1127
|
| `disabled?` · `readonly?` · `invalid?` | `boolean` | Applied to both pickers together. |
|
|
1128
|
+
| `required?` | `boolean` | Both ends must be filled for a [`data-fdy-validate`](#form-validation--data-fdy-validate) form to submit. Each picker refuses on its own, and the two share the field's one message slot, which stays up while either end is still empty. Blazor: `Required`. |
|
|
1092
1129
|
| `prevMonthLabel?` · `nextMonthLabel?` · `prevYearLabel?` · `nextYearLabel?` · `prevYearsLabel?` · `nextYearsLabel?` · `chooseMonthLabel?` · `chooseYearLabel?` | `string` | Forwarded verbatim to **both** pickers. Until 3.11.0 this was the one picker in the kit whose calendar nav could not be named in the page's own language: the single picker took these, the range dropped them. Blazor adds `BackToMonthsLabel`, since the raw seed both pickers are built from has that button. |
|
|
1093
1130
|
|
|
1094
1131
|
Blazor splits the value into two scalars, `From` / `FromChanged` and `To` / `ToChanged`, because a
|
|
@@ -1186,7 +1223,7 @@ Seed attributes: `data-step` (minutes, default 30), `data-min` (default `00:00`)
|
|
|
1186
1223
|
(default `23:59`), `data-value`, `data-label`, `data-placeholder` (default `--:--`), `data-id`,
|
|
1187
1224
|
`data-describedby`, `data-disabled`, `data-readonly`, `data-invalid`. Emits a bubbling
|
|
1188
1225
|
`fdy-time-select` (`detail {value}`). `FreedayTimepicker.setState(root, { disabled, readonly,
|
|
1189
|
-
invalid })` changes the
|
|
1226
|
+
invalid, required })` changes the states afterwards, which is what a host that renders its seed once
|
|
1190
1227
|
and never again (Blazor) needs.
|
|
1191
1228
|
|
|
1192
1229
|
**Use this instead of `<input type="time">`**, and not for theming alone: the native picker is
|
|
@@ -1297,18 +1334,21 @@ blur/input. Needs `freeday-form.js`.
|
|
|
1297
1334
|
- Emits `fdy-form-valid` / `fdy-form-invalid`.
|
|
1298
1335
|
- **A kit control can be required too** — `data-fdy-required` on its root. Combo, datepicker,
|
|
1299
1336
|
monthpicker, timepicker and cascade build a `<button>` trigger, and a button's `willValidate` is
|
|
1300
|
-
false, so `form.elements` never offered one and `required` on it meant nothing.
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
the
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
Re-validation watches
|
|
1311
|
-
itself
|
|
1337
|
+
false, so `form.elements` never offered one and `required` on it meant nothing. A
|
|
1338
|
+
choose-from-list is in the same position for a different reason: its `<input>` is `readonly`,
|
|
1339
|
+
and a readonly input is barred from constraint validation. The enhancer collects these roots
|
|
1340
|
+
alongside the native controls: empty `data-value` refuses the submit, the message lands in the
|
|
1341
|
+
same `.fdy-field` slot, and the focus goes to the trigger. It names no component — the value is
|
|
1342
|
+
read from `data-value` and the trigger is found by `aria-haspopup`. In the typed stacks pass
|
|
1343
|
+
`required` / `Required` instead of writing the attribute; every value-bearing wrapper has it.
|
|
1344
|
+
**An autocomplete is the one that takes the native `required`**, on its input: the input is
|
|
1345
|
+
editable, so constraint validation already covers it, and routing it through the kit path would
|
|
1346
|
+
give one field two sources of truth.
|
|
1347
|
+
Re-validation watches `data-value` and `data-fdy-required` with a `MutationObserver`, so no
|
|
1348
|
+
control has to announce itself, and lifting the requirement clears an error already on screen.
|
|
1349
|
+
- **Two controls in one `.fdy-field` share its message slot** — a date range's two ends, or two
|
|
1350
|
+
native inputs side by side. The message stays up while any control pointing at it is still
|
|
1351
|
+
invalid, so filling one end does not erase the message the other end still needs. The message override is per-control (`data-fdy-msg-required` on the root) wherever
|
|
1312
1352
|
attributes reach the root — the raw path, and Vue, where an unknown attribute falls through. In
|
|
1313
1353
|
React and Blazor they do not, so use the form-level `data-fdy-text-required`, which reads the
|
|
1314
1354
|
same in every stack.
|
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.18.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.18.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`.
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
aria-controls="@_listId" autocomplete="off" value="@Value"
|
|
11
11
|
placeholder="@Placeholder" aria-label="@AriaLabel"
|
|
12
12
|
id="@Id" aria-labelledby="@AriaLabelledby" aria-describedby="@Describedby"
|
|
13
|
-
disabled="@Disabled" readonly="@Readonly"
|
|
13
|
+
disabled="@Disabled" readonly="@Readonly" required="@Required"
|
|
14
14
|
aria-invalid="@(Invalid ? "true" : null)" />
|
|
15
15
|
<ul class="fdy-autocomplete__listbox" id="@_listId" role="listbox" hidden>
|
|
16
16
|
@foreach (string item in Options)
|
|
@@ -44,13 +44,18 @@ public partial class FdyAutocomplete
|
|
|
44
44
|
/// <summary>Marks the field invalid (<c>aria-invalid</c>).</summary>
|
|
45
45
|
[Parameter] public bool Invalid { get; set; }
|
|
46
46
|
|
|
47
|
+
/// <summary>The native <c>required</c>, on the input itself: it is editable, so constraint
|
|
48
|
+
/// validation (and so a <c>data-fdy-validate</c> form) applies to it as to any input. Pushed
|
|
49
|
+
/// with the other states, so a field required only under a condition follows it (#114).</summary>
|
|
50
|
+
[Parameter] public bool Required { get; set; }
|
|
51
|
+
|
|
47
52
|
protected override bool ShouldRender() => !Hydrated;
|
|
48
53
|
|
|
49
54
|
protected override async Task OnParametersSetAsync()
|
|
50
55
|
{
|
|
51
56
|
if (!Hydrated) return;
|
|
52
57
|
await JS.InvokeVoidAsync("FreedayAutocomplete.setState", Root,
|
|
53
|
-
new { disabled = Disabled, @readonly = Readonly, invalid = Invalid });
|
|
58
|
+
new { disabled = Disabled, @readonly = Readonly, invalid = Invalid, required = Required });
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
/// <summary>Invoked by the bridge when the user picks a suggestion.</summary>
|
|
@@ -61,7 +61,7 @@ public partial class FdyCascade
|
|
|
61
61
|
{
|
|
62
62
|
if (!Hydrated) return;
|
|
63
63
|
await JS.InvokeVoidAsync("FreedayCascade.setState", Root,
|
|
64
|
-
new { disabled = Disabled, @readonly = Readonly, invalid = Invalid });
|
|
64
|
+
new { disabled = Disabled, @readonly = Readonly, invalid = Invalid, required = Required });
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/// <summary>Invoked by the bridge when the user selects a leaf.</summary>
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
through @ref: `await picker.OpenAsync()`. The host generates no box. *@
|
|
13
13
|
@if (!DialogOnly)
|
|
14
14
|
{
|
|
15
|
-
<div class="@FieldGroupClass">
|
|
15
|
+
<div class="@FieldGroupClass" data-value="@ValueAttr" data-fdy-required="@(Required ? "" : null)">
|
|
16
16
|
<input class="fdy-input" type="text" readonly value="@DisplayValue"
|
|
17
17
|
placeholder="@Placeholder" aria-labelledby="@AriaLabelledby"
|
|
18
18
|
aria-invalid="@(Invalid ? "true" : null)" aria-readonly="@(Readonly ? "true" : null)" />
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
</svg>
|
|
26
26
|
</button>
|
|
27
27
|
}
|
|
28
|
-
<button class="fdy-input-group__btn" type="button" @onclick="OpenAsync"
|
|
28
|
+
<button class="fdy-input-group__btn" type="button" @onclick="OpenAsync" aria-haspopup="dialog"
|
|
29
29
|
disabled="@(Disabled || Readonly)" aria-label="@OpenLabel">
|
|
30
30
|
<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor"
|
|
31
31
|
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
@@ -60,6 +60,15 @@ public partial class FdyCfl<TRow>
|
|
|
60
60
|
/// <summary>Locked/view mode: shows the value but the search dialog can't be opened.</summary>
|
|
61
61
|
[Parameter] public bool Readonly { get; set; }
|
|
62
62
|
[Parameter] public bool Invalid { get; set; }
|
|
63
|
+
|
|
64
|
+
/// <summary>Let a <c>data-fdy-validate</c> form demand a row be picked. Renders
|
|
65
|
+
/// <c>data-fdy-required</c> on the field group, which mirrors the picked keys in
|
|
66
|
+
/// <c>data-value</c>; <c>freeday-form.js</c> refuses the submit, paints the message in the field
|
|
67
|
+
/// and focuses the open button. Not the native <c>required</c>: the field's input is readonly,
|
|
68
|
+
/// and a readonly input is barred from constraint validation (#114). Ignored with
|
|
69
|
+
/// <see cref="DialogOnly"/>, which has no field.</summary>
|
|
70
|
+
[Parameter] public bool Required { get; set; }
|
|
71
|
+
|
|
63
72
|
/// <summary>Render a clear button when a row is picked, so an OPTIONAL foreign key can be unset.
|
|
64
73
|
/// <c>Value</c> is already <c>TRow?</c>; without this the component can never produce null.</summary>
|
|
65
74
|
[Parameter] public bool Clearable { get; set; }
|
|
@@ -90,6 +99,10 @@ public partial class FdyCfl<TRow>
|
|
|
90
99
|
private int _debounceSeq; // supersedes stale debounced searches
|
|
91
100
|
|
|
92
101
|
private string DisplayValue => Value is null ? string.Empty : Display(Value);
|
|
102
|
+
/* The live value on the group, as every value-bearing kit control mirrors it: the picked keys. */
|
|
103
|
+
private string ValueAttr => Multiple
|
|
104
|
+
? string.Join(",", (Values ?? Array.Empty<TRow>()).Select(RowKey))
|
|
105
|
+
: Value is null ? string.Empty : RowKey(Value);
|
|
93
106
|
private string FieldGroupClass => Invalid ? "fdy-input-group fdy-input-group--error" : "fdy-input-group";
|
|
94
107
|
private bool IsInitialLoading => _loading && _rows.Count == 0;
|
|
95
108
|
private bool IsBlockingError => _error is not null && _rows.Count == 0;
|
|
@@ -84,7 +84,7 @@ public partial class FdyCombo<TValue>
|
|
|
84
84
|
if (_ready)
|
|
85
85
|
{
|
|
86
86
|
await JS.InvokeVoidAsync("FreedayCombo.setState", Root,
|
|
87
|
-
new { disabled = Disabled, @readonly = Readonly, invalid = Invalid });
|
|
87
|
+
new { disabled = Disabled, @readonly = Readonly, invalid = Invalid, required = Required });
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
so From/To bind separately. Enhancer-owned DOM → render once (ShouldRender => false). *@
|
|
8
8
|
<div @ref="Root">
|
|
9
9
|
<div data-fdy-daterange role="group" aria-label="@AriaLabel">
|
|
10
|
-
<div data-fdy-datepicker data-role="from"
|
|
10
|
+
<div @ref="_fromEl" data-fdy-datepicker data-role="from" data-fdy-required="@(Required ? "" : null)"
|
|
11
11
|
data-value="@From" data-placeholder="@FromPlaceholder" data-min="@Min" data-max="@Max"
|
|
12
12
|
data-fdy-text-prev-month="@PrevMonthLabel"
|
|
13
13
|
data-fdy-text-next-month="@NextMonthLabel"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
data-fdy-text-choose-year="@ChooseYearLabel"
|
|
20
20
|
data-fdy-text-back-to-months="@BackToMonthsLabel"></div>
|
|
21
21
|
<span class="fdy-daterange__sep">@Separator</span>
|
|
22
|
-
<div data-fdy-datepicker data-role="to"
|
|
22
|
+
<div @ref="_toEl" data-fdy-datepicker data-role="to" data-fdy-required="@(Required ? "" : null)"
|
|
23
23
|
data-value="@To" data-placeholder="@ToPlaceholder" data-min="@Min" data-max="@Max"
|
|
24
24
|
data-fdy-text-prev-month="@PrevMonthLabel"
|
|
25
25
|
data-fdy-text-next-month="@NextMonthLabel"
|
|
@@ -43,7 +43,14 @@ public partial class FdyDateRange
|
|
|
43
43
|
/// the Vue and React adapters build no such button.</summary>
|
|
44
44
|
[Parameter] public string? BackToMonthsLabel { get; set; }
|
|
45
45
|
|
|
46
|
+
/// <summary>Both ends must be filled for a <c>data-fdy-validate</c> form to submit. Rendered
|
|
47
|
+
/// as <c>data-fdy-required</c> on BOTH pickers, each refusing on its own, and pushed to them
|
|
48
|
+
/// afterwards, so a range required only under a condition follows it (#114).</summary>
|
|
49
|
+
[Parameter] public bool Required { get; set; }
|
|
50
|
+
|
|
46
51
|
private int _token;
|
|
52
|
+
private ElementReference _fromEl;
|
|
53
|
+
private ElementReference _toEl;
|
|
47
54
|
|
|
48
55
|
// initAll(Root) links the daterange (descendant) and inits both child pickers.
|
|
49
56
|
protected override ValueTask HydrateAsync() => JS.InvokeVoidAsync("FreedayDatepicker.initAll", Root);
|
|
@@ -53,6 +60,13 @@ public partial class FdyDateRange
|
|
|
53
60
|
|
|
54
61
|
protected override bool ShouldRender() => !Hydrated;
|
|
55
62
|
|
|
63
|
+
protected override async Task OnParametersSetAsync()
|
|
64
|
+
{
|
|
65
|
+
if (!Hydrated) return;
|
|
66
|
+
await JS.InvokeVoidAsync("FreedayDatepicker.setState", _fromEl, new { required = Required });
|
|
67
|
+
await JS.InvokeVoidAsync("FreedayDatepicker.setState", _toEl, new { required = Required });
|
|
68
|
+
}
|
|
69
|
+
|
|
56
70
|
/// <summary>Invoked by the bridge for either child's change; routes by data-role.</summary>
|
|
57
71
|
[JSInvokable]
|
|
58
72
|
public async Task OnChange(RangeDetail detail)
|
|
@@ -96,7 +96,7 @@ public partial class FdyDatepicker
|
|
|
96
96
|
{
|
|
97
97
|
if (!Hydrated) return;
|
|
98
98
|
await JS.InvokeVoidAsync("FreedayDatepicker.setState", Root,
|
|
99
|
-
new { disabled = Disabled, @readonly = Readonly, invalid = Invalid });
|
|
99
|
+
new { disabled = Disabled, @readonly = Readonly, invalid = Invalid, required = Required });
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
/// <summary>Invoked by the bridge when the user picks (or clears) a date.</summary>
|
|
@@ -93,7 +93,7 @@ public partial class FdyMonthpicker
|
|
|
93
93
|
{
|
|
94
94
|
if (!Hydrated) return;
|
|
95
95
|
await JS.InvokeVoidAsync("FreedayDatepicker.setState", Root,
|
|
96
|
-
new { disabled = Disabled, @readonly = Readonly, invalid = Invalid });
|
|
96
|
+
new { disabled = Disabled, @readonly = Readonly, invalid = Invalid, required = Required });
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
/// <summary>Invoked by the bridge when the user picks (or clears) a month.</summary>
|
|
@@ -70,7 +70,7 @@ public partial class FdyTimepicker
|
|
|
70
70
|
{
|
|
71
71
|
if (!Hydrated) return;
|
|
72
72
|
await JS.InvokeVoidAsync("FreedayTimepicker.setState", Root,
|
|
73
|
-
new { disabled = Disabled, @readonly = Readonly, invalid = Invalid });
|
|
73
|
+
new { disabled = Disabled, @readonly = Readonly, invalid = Invalid, required = Required });
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/// <summary>Invoked by the bridge when the reader picks a time (enhancer's fdy-time-select).</summary>
|
|
@@ -175,14 +175,23 @@
|
|
|
175
175
|
if (element) element.indeterminate = !!value;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
//
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
// The device's theme preference, through the same core Vue and React use (freeday-theme.js, in
|
|
179
|
+
// freeday.js): stored per device, 'system' follows the OS, and every toggle on the page agrees.
|
|
180
|
+
function themeCore() {
|
|
181
|
+
if (!window.FreedayTheme) {
|
|
182
|
+
throw new Error('FreedayBlazor: window.FreedayTheme is missing. Load freeday.js (which includes '
|
|
183
|
+
+ 'freeday-theme.js) before freeday-blazor.js.');
|
|
184
|
+
}
|
|
185
|
+
return window.FreedayTheme;
|
|
182
186
|
}
|
|
187
|
+
function toggleTheme() { themeCore().toggle(); }
|
|
188
|
+
function setTheme(theme) { themeCore().set(theme); }
|
|
189
|
+
function getTheme() { return themeCore().get(); }
|
|
190
|
+
function getResolvedTheme() { return themeCore().resolved(); }
|
|
183
191
|
|
|
184
192
|
window.FreedayBlazor = {
|
|
185
193
|
initAll: initAll, on: on, off: off, onOutside: onOutside, toast: toast, toggleTheme: toggleTheme,
|
|
194
|
+
setTheme: setTheme, getTheme: getTheme, getResolvedTheme: getResolvedTheme,
|
|
186
195
|
comboSetValue: comboSetValue, dateRangeOn: dateRangeOn, chartUpdate: chartUpdate,
|
|
187
196
|
setIndeterminate: setIndeterminate,
|
|
188
197
|
dialogInit: dialogInit, dialogShow: dialogShow, dialogClose: dialogClose, dialogDispose: dialogDispose,
|
|
@@ -24,6 +24,10 @@ export interface FdyAutocompleteProps {
|
|
|
24
24
|
/** Locked/view mode: the input is not editable and the list won't open, but it stays focusable and shows its value. Unlike `disabled`, it keeps tab order and isn't greyed. */
|
|
25
25
|
readonly?: boolean;
|
|
26
26
|
invalid?: boolean;
|
|
27
|
+
/** The native `required`, on the input itself: it is editable, so constraint validation (and so a
|
|
28
|
+
* `data-fdy-validate` form) applies to it as to any input. Not `data-fdy-required`, which is for
|
|
29
|
+
* controls whose trigger is a button (#114). */
|
|
30
|
+
required?: boolean;
|
|
27
31
|
describedby?: string;
|
|
28
32
|
}
|
|
29
33
|
|
|
@@ -132,6 +136,7 @@ export function FdyAutocomplete(props: FdyAutocompleteProps): JSX.Element {
|
|
|
132
136
|
placeholder={props.placeholder}
|
|
133
137
|
disabled={isDisabled}
|
|
134
138
|
readOnly={isReadonly}
|
|
139
|
+
required={props.required === true}
|
|
135
140
|
value={props.value}
|
|
136
141
|
onChange={(e: React.ChangeEvent<HTMLInputElement>): void => { props.onChange(e.target.value); setActive(-1); openList(); }}
|
|
137
142
|
onFocus={openList}
|
|
@@ -63,6 +63,13 @@ export interface FdyCflProps<Row extends Record<string, unknown>> {
|
|
|
63
63
|
/** Locked/view mode: shows the picked value (focusable, copyable), but the search dialog can't be opened. Unlike `disabled`, it keeps tab order and isn't greyed. */
|
|
64
64
|
readonly?: boolean;
|
|
65
65
|
invalid?: boolean;
|
|
66
|
+
/** Let a `data-fdy-validate` form demand a row be picked. It renders `data-fdy-required` on the
|
|
67
|
+
* field group, which mirrors the picked keys in `data-value`; `freeday-form.js` refuses the
|
|
68
|
+
* submit, paints the message in the field and focuses the open button. Not the native
|
|
69
|
+
* `required`: the field's input is readonly, and a readonly input is barred from constraint
|
|
70
|
+
* validation, so `required` on it never refused anything (#114). Ignored with `dialogOnly`,
|
|
71
|
+
* which has no field to paint. */
|
|
72
|
+
required?: boolean;
|
|
66
73
|
/** Render a clear button when a row is picked, so an OPTIONAL foreign key can be unset. Without it
|
|
67
74
|
* `value` accepts `Row | null` but the component can only ever produce a `Row`. */
|
|
68
75
|
clearable?: boolean;
|
|
@@ -142,6 +149,8 @@ function FdyCflInner<Row extends Record<string, unknown>>(
|
|
|
142
149
|
: props.value !== null
|
|
143
150
|
? [props.value as Row]
|
|
144
151
|
: [];
|
|
152
|
+
/* The live value on the root, as every value-bearing kit control mirrors it: the picked keys. */
|
|
153
|
+
const valueAttr: string = currentRows.map((r: Row): string => props.rowKey(r)).join(',');
|
|
145
154
|
const selectedTextFor = (n: number): string => (props.selectedText ?? '{n} selected').replace('{n}', String(n));
|
|
146
155
|
const isMultiple: boolean = props.multiple === true;
|
|
147
156
|
const showClear: boolean =
|
|
@@ -352,7 +361,8 @@ function FdyCflInner<Row extends Record<string, unknown>>(
|
|
|
352
361
|
}, []);
|
|
353
362
|
|
|
354
363
|
return (
|
|
355
|
-
<div className={props.dialogOnly === true ? 'fdy-cfl__host' : 'fdy-input-group'}
|
|
364
|
+
<div className={props.dialogOnly === true ? 'fdy-cfl__host' : 'fdy-input-group'} data-value={valueAttr}
|
|
365
|
+
data-fdy-required={props.required === true && props.dialogOnly !== true ? '' : undefined}>
|
|
356
366
|
{props.dialogOnly === true ? null : (
|
|
357
367
|
<>
|
|
358
368
|
<input
|
|
@@ -24,6 +24,9 @@ export interface FdyDateRangeProps {
|
|
|
24
24
|
/** Locked/view mode for both pickers, focusable, values shown, but can't be opened or changed. */
|
|
25
25
|
readonly?: boolean;
|
|
26
26
|
invalid?: boolean;
|
|
27
|
+
/** Both ends must be filled for a `data-fdy-validate` form to submit. Forwarded to BOTH pickers,
|
|
28
|
+
* each refusing on its own; the two share the field's one message slot (#114). */
|
|
29
|
+
required?: boolean;
|
|
27
30
|
describedby?: string;
|
|
28
31
|
startPlaceholder?: string;
|
|
29
32
|
endPlaceholder?: string;
|
|
@@ -68,6 +71,7 @@ export function FdyDateRange(props: FdyDateRangeProps): JSX.Element {
|
|
|
68
71
|
disabled={props.disabled}
|
|
69
72
|
readonly={props.readonly}
|
|
70
73
|
invalid={props.invalid}
|
|
74
|
+
required={props.required}
|
|
71
75
|
describedby={props.describedby}
|
|
72
76
|
placeholder={props.startPlaceholder ?? 'Dari'}
|
|
73
77
|
prevMonthLabel={props.prevMonthLabel}
|
|
@@ -89,6 +93,7 @@ export function FdyDateRange(props: FdyDateRangeProps): JSX.Element {
|
|
|
89
93
|
disabled={props.disabled}
|
|
90
94
|
readonly={props.readonly}
|
|
91
95
|
invalid={props.invalid}
|
|
96
|
+
required={props.required}
|
|
92
97
|
describedby={props.describedby}
|
|
93
98
|
placeholder={props.endPlaceholder ?? 'Sampai'}
|
|
94
99
|
prevMonthLabel={props.prevMonthLabel}
|
|
@@ -13,6 +13,32 @@ export interface UseFreedayReturn {
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function useFreeday(rootRef?: RefObject<HTMLElement | null>): UseFreedayReturn;
|
|
15
15
|
|
|
16
|
+
/** A theme preference. `'system'` removes `data-theme`, so the tokens follow the OS, live. */
|
|
17
|
+
export type FdyTheme = 'light' | 'dark' | 'system';
|
|
18
|
+
/** What is actually on screen once `'system'` is resolved against the OS. */
|
|
19
|
+
export type FdyResolvedTheme = 'light' | 'dark';
|
|
20
|
+
/** `event.detail` of `fdy-theme-change`, fired on `document`. */
|
|
21
|
+
export interface FdyThemeChangeDetail { theme: FdyTheme; resolved: FdyResolvedTheme }
|
|
22
|
+
|
|
23
|
+
export interface UseThemeReturn {
|
|
24
|
+
/** The stored preference, per device; `'system'` until one is chosen. */
|
|
25
|
+
theme: FdyTheme;
|
|
26
|
+
/** The theme on screen. Use it for the toggle's icon and label, not `theme`. */
|
|
27
|
+
resolved: FdyResolvedTheme;
|
|
28
|
+
/** Store and apply a preference. Throws a TypeError for any other value. */
|
|
29
|
+
setTheme: (theme: FdyTheme) => void;
|
|
30
|
+
/** Switch to the opposite of what is on screen, so the first press always changes it. */
|
|
31
|
+
toggleTheme: () => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The device's light/dark preference, applied to `<html>`, kept in `localStorage` and shared by
|
|
36
|
+
* every caller on the page. Pass a ref to also apply it to that element, for a region whose markup
|
|
37
|
+
* fixes its own `data-theme`. Loads the theme core itself: no `import '@cahyo-dimas/freeday'`
|
|
38
|
+
* needed. Apply the stored value before first paint with the `<head>` snippet in COMPONENTS.md.
|
|
39
|
+
*/
|
|
40
|
+
export declare function useTheme(rootRef?: RefObject<HTMLElement | null>): UseThemeReturn;
|
|
41
|
+
|
|
16
42
|
/** `event.detail` shapes for the bubbling `fdy-*` CustomEvents. */
|
|
17
43
|
export interface FdyChangeDetail { value: string }
|
|
18
44
|
export interface FdyAutocompleteSelectDetail { value: string }
|