@cahyo-dimas/freeday 3.17.0 → 3.19.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 +95 -0
- package/COMPONENTS.md +44 -24
- package/README.id.md +1 -1
- package/README.md +1 -1
- package/USAGE.md +1 -1
- package/adapters/blazor/FdyAutocomplete.razor +3 -3
- package/adapters/blazor/FdyAutocomplete.razor.cs +21 -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/react/components/FdyAutocomplete.tsx +27 -8
- package/adapters/react/components/FdyCfl.tsx +11 -1
- package/adapters/react/components/FdyDateRange.tsx +5 -0
- package/adapters/vue/components/FdyAutocomplete.vue +30 -3
- package/adapters/vue/components/FdyCfl.vue +11 -1
- package/adapters/vue/components/FdyDateRange.vue +5 -0
- package/dist/freeday-autocomplete.js +20 -2
- 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-timepicker.js +13 -2
- package/dist/freeday.js +100 -15
- package/docs/agent-onboarding.md +2 -1
- package/docs/getting-started.md +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,101 @@ 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.19.0] - 2026-11-09
|
|
13
|
+
|
|
14
|
+
**`FdyAutocomplete` kini berlaku seperti input.** Keduanya ketahuan saat tiga isian `<input list>`
|
|
15
|
+
dipindahkan ke komponen ini (`CATATAN-FREEDAY.md` §25): `maxlength` dan pesan per-kolom hilang tanpa
|
|
16
|
+
suara, dan isian yang punya nilai bawaan membuka daftar berisi satu saran.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- **Atribut yang tidak dikenal `FdyAutocomplete` mendarat di `<input>`-nya** (`#115`), di ketiga
|
|
20
|
+
stack: `maxlength`, `inputmode`, `name`, `data-fdy-msg-required`, dan listener. Sebelumnya atribut
|
|
21
|
+
itu jatuh ke `div` pembungkus di Vue, dan hilang di React serta Blazor. `class` dan `style` tetap
|
|
22
|
+
di akar. **Di Vue ini perubahan perilaku:** atribut seperti `data-testid` yang dulu ada di akar kini
|
|
23
|
+
ada di input. Yang menjadi kontrak combobox (`role`, `type`, `autocomplete`, ARIA) tetap milik
|
|
24
|
+
komponen. React menerima atribut input lewat tipenya; Blazor lewat `AdditionalAttributes`.
|
|
25
|
+
- **Daftar autocomplete terbuka utuh, dan hanya ketikan yang menyaringnya** (`#115`), di Vue, React,
|
|
26
|
+
dan enhancer yang dipakai Blazor serta jalur mentah. Nilai yang sudah ada di isian bukan kueri.
|
|
27
|
+
Penyaringan dilupakan saat daftar ditutup, jadi tombol panah juga membukanya utuh; di enhancer
|
|
28
|
+
sebelumnya tombol panah membuka opsi sisa saringan terakhir.
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
- **Pesan per-kontrol `FdyAutocomplete` kini sampai ke aturan form** (`#115`), sebab aturan itu
|
|
32
|
+
membacanya dari input.
|
|
33
|
+
|
|
34
|
+
### Docs
|
|
35
|
+
- **`.fdy-title-page` di dalam `.fdy-app` adalah `<h2>`** (`#116`, §26). `COMPONENTS.md` sudah
|
|
36
|
+
menyebutnya, tetapi `USAGE.md` dan `docs/agent-onboarding.md` masih berbunyi `<h1>` saja. Blok
|
|
37
|
+
onboarding berubah di butir 4, jadi salinannya di proyek konsumen perlu diganti saat naik versi.
|
|
38
|
+
- **`title` di `FdyAppShell` adalah nama halaman yang sedang dibuka**, bukan nama produk. Ia
|
|
39
|
+
dirender sebagai `<h1>` dokumen; nama produk tempatnya di merek sidebar (`brand`, Blazor
|
|
40
|
+
`BrandContent`).
|
|
41
|
+
|
|
42
|
+
### Catatan
|
|
43
|
+
- **§26 tidak mengganti `<h1>` shell menjadi `<p>`.** Contoh kit selalu mengisi `title` dengan nama
|
|
44
|
+
halaman, jadi `<h1>`-nya memang benar. Yang keliru adalah mengisinya dengan merek.
|
|
45
|
+
- **§25b tidak diambil.** Premisnya, bahwa string kit lain dapat disetel sekali di `<form>`, hanya
|
|
46
|
+
berlaku untuk pesan validasi. Autocomplete juga dapat dipakai di luar form, dan bawaan Inggris yang
|
|
47
|
+
sama ada di `FdyCfl` serta `FdyTable`. Kalau dibutuhkan, bentuknya teks bawaan untuk seluruh kit.
|
|
48
|
+
|
|
49
|
+
## [3.18.0] - 2026-11-07
|
|
50
|
+
|
|
51
|
+
**Setiap kontrol bernilai kini dapat dijadikan wajib, di ketiga stack.** 3.12.0 (`#096`) memberi
|
|
52
|
+
`required` ke lima kontrol berpemicu tombol dan meninggalkan tiga (`CATATAN-FREEDAY.md` §24).
|
|
53
|
+
Akibatnya, menukar isian wajib ke `FdyAutocomplete` **membuang validasinya tanpa suara**: tidak ada
|
|
54
|
+
galat dan tidak ada peringatan. Formulirnya hanya berhenti menuntut isian itu. Audit kelasnya
|
|
55
|
+
menemukan dua kontrol lain dengan celah yang sama, dua cacat di aturan validasinya sendiri, dan
|
|
56
|
+
satu cacat di semua jembatan Blazor.
|
|
57
|
+
|
|
58
|
+
### Added
|
|
59
|
+
- **`required` di `FdyAutocomplete`** (`#114`), Vue · React · Blazor (`Required`). Ini `required`
|
|
60
|
+
**native**, dipasang di input-nya. Input itu dapat disunting, jadi validasi bawaan peramban
|
|
61
|
+
sudah berlaku seperti pada `<input>` lain.
|
|
62
|
+
- **`required` di `FdyCfl`** (`#114`), ketiga stack. Ia merender `data-fdy-required` di grup
|
|
63
|
+
isiannya, dan grup itu kini mencerminkan kunci baris terpilih (`rowKey`, dipisah koma bila
|
|
64
|
+
`multiple`) di `data-value`. Penolakan menandai dan memfokuskan tombol pembuka.
|
|
65
|
+
- **`required` di `FdyDateRange`** (`#114`), ketiga stack, diteruskan ke **kedua** ujung. Prop ini
|
|
66
|
+
tidak ada di daftar §24. Masing-masing datepicker sudah punya `required`, tetapi tidak ada prop
|
|
67
|
+
rentang yang meneruskannya.
|
|
68
|
+
- **Jalur mentah `freeday-cfl.js` mencerminkan `data-value`** di grup isiannya setiap kali baris
|
|
69
|
+
dipilih. Nilainya `data-value` baris itu, atau kunci tampilannya bila baris tidak punya. Dengan
|
|
70
|
+
begitu `data-fdy-required` di grup bekerja tanpa pembungkus.
|
|
71
|
+
- **`setState(root, { required })`** di kelima enhancer yang punya `setState` (combo, datepicker
|
|
72
|
+
termasuk mode bulan, timepicker, cascade, autocomplete).
|
|
73
|
+
|
|
74
|
+
### Fixed
|
|
75
|
+
- **Dua kontrol dalam satu `.fdy-field` saling menghapus pesan** (`#114`). Slot pesan dicari per
|
|
76
|
+
field, jadi mengisi ujung "dari" pada rentang menghapus pesan yang masih dibutuhkan ujung
|
|
77
|
+
"sampai". Akibatnya ujung itu tetap merah tanpa keterangan. Cacat yang sama mengenai dua input
|
|
78
|
+
native yang berdampingan. Kini slotnya tetap tampil selama masih ada kontrol yang merujuknya dan
|
|
79
|
+
masih invalid.
|
|
80
|
+
- **`Required` di Blazor hanya terbaca saat render pertama** (`#114`), di kelima kontrol 3.12.0.
|
|
81
|
+
Sesudah hidrasi komponennya berhenti merender, dan `setState` tidak membawa `required`. Isian
|
|
82
|
+
yang wajib secara bersyarat (`Required="@isPerusahaan"`) tidak pernah ikut berubah. Kini
|
|
83
|
+
`Required` ikut didorong bersama tiga state lainnya.
|
|
84
|
+
- **Mencabut syarat wajib tidak menghapus galat yang sedang tampil.** `MutationObserver` aturan
|
|
85
|
+
form kini juga mengamati `data-fdy-required`, dan akar yang tak lagi wajib tidak pernah ditolak.
|
|
86
|
+
- **Dorongan `setState` yang tidak mengubah apa pun menghapus tanda merah dari form** (`#114`).
|
|
87
|
+
Blazor mendorong semua state setiap kali induknya merender ulang. Menulis ulang `invalid: false`
|
|
88
|
+
yang tidak berubah mencabut `aria-invalid` yang dipasang `freeday-form.js`, sehingga pesannya
|
|
89
|
+
tertinggal di bawah isian yang tidak lagi merah. Kelima enhancer kini menulis `aria-invalid`
|
|
90
|
+
hanya bila `invalid` dari host benar-benar berubah. Vue dan React tidak terkena: keduanya hanya
|
|
91
|
+
menambal atribut yang ikatannya berubah.
|
|
92
|
+
- **Tombol pembuka `FdyCfl` di Blazor tidak punya `aria-haspopup="dialog"`**, padahal Vue dan
|
|
93
|
+
React memilikinya. Aturan form mencari elemen yang ditandai lewat atribut itu.
|
|
94
|
+
|
|
95
|
+
### Catatan
|
|
96
|
+
- **Koreksi atas 3.12.0.** Catatan rilis itu menulis bahwa `FdyAutocomplete` dan `FdyCfl`
|
|
97
|
+
"merender `<input>` asli, jadi `required` native yang cocok". Untuk Cfl itu keliru. Input-nya
|
|
98
|
+
`readonly`, dan input readonly dikecualikan dari validasi bawaan peramban (`willValidate`
|
|
99
|
+
bernilai `false`), jadi `required` di sana tidak pernah menolak apa pun. Usulan §24 menyalin
|
|
100
|
+
kekeliruan itu. Seandainya diterapkan apa adanya, Cfl akan tampak wajib tanpa pernah menolak.
|
|
101
|
+
Ujinya kini menegaskan `willValidate === false` di fixture, supaya tidak ada yang mengembalikan
|
|
102
|
+
Cfl ke jalur native.
|
|
103
|
+
- Penimpaan pesan per-kontrol (`data-fdy-msg-required`) pada `FdyDateRange` Vue jatuh ke akar
|
|
104
|
+
`.fdy-daterange`, bukan ke kedua datepicker yang membacanya. Pakai `data-fdy-text-required` di
|
|
105
|
+
`<form>`, seperti di React dan Blazor.
|
|
106
|
+
|
|
12
107
|
## [3.17.0] - 2026-11-05
|
|
13
108
|
|
|
14
109
|
**Pengalih tema terang/gelap, siap pakai di semua stack.** Setiap app sebelumnya menulis sendiri
|
package/COMPONENTS.md
CHANGED
|
@@ -156,7 +156,7 @@ which is why React's list is longer while offering the same thing.
|
|
|
156
156
|
| `navOpen?` | `boolean` | Whether the nav is visible. Optional because the default is the **viewport's**, and a caller cannot state that in one initial value. Vue binds `v-model:navOpen`. |
|
|
157
157
|
| `onNavOpenChange?` | `(open: boolean) => void` | React. Visibility changed: the toggle, Escape, the backdrop, or a followed nav item. Vue emits `update:navOpen`. |
|
|
158
158
|
| `navMode?` | `'push' \| 'overlay'` | How a **visible** nav sits on a **wide** viewport: `push` (default) is the column that displaces the content, `overlay` floats it over the page with a backdrop. Below the nav breakpoint it is ignored — the nav is off-canvas there by definition, so there is nothing to choose. Blazor takes the enum `FdyNavMode`. |
|
|
159
|
-
| `title?` | `string` (Vue) · `ReactNode` | Topbar title. |
|
|
159
|
+
| `title?` | `string` (Vue) · `ReactNode` | Topbar title, rendered as the document's `<h1>`: the name of the **current page**, not the product. The product's name goes in the sidebar brand (Vue slot `brand`, React `brand`, Blazor `BrandContent`), and the page's own `.fdy-title-page` steps down to `<h2>`. |
|
|
160
160
|
| `toggleLabel?` | `string` | Accessible name for the nav toggle button. |
|
|
161
161
|
| `toggleIcon?` | `ReactNode` | React. Replaces the default hamburger; Vue uses the slot of that name. |
|
|
162
162
|
| `skip?` | `ReactNode` | React. Skip link, rendered first in the tab order. |
|
|
@@ -317,7 +317,7 @@ carry the doctrine in markup.
|
|
|
317
317
|
<header class="fdy-page__header">
|
|
318
318
|
<div class="fdy-page__heading">
|
|
319
319
|
<p class="fdy-eyebrow">Sales</p>
|
|
320
|
-
<h1 class="fdy-title-page">Invoices</h1>
|
|
320
|
+
<h1 class="fdy-title-page">Invoices</h1><!-- <h2> inside .fdy-app: the topbar title is the <h1> -->
|
|
321
321
|
<p class="fdy-page__desc">Every invoice issued this period.</p>
|
|
322
322
|
</div>
|
|
323
323
|
<div class="fdy-page__actions"><button class="fdy-btn">New invoice</button></div>
|
|
@@ -807,8 +807,11 @@ while each line referenced directly would be read even when hidden. Zero JS; wor
|
|
|
807
807
|
| `describedby?` | `string` | Id of the help or error text (`aria-describedby`). |
|
|
808
808
|
|
|
809
809
|
Blazor: the same names in `PascalCase`, bound with `@bind-Value` (`Value` / `ValueChanged`).
|
|
810
|
-
`FreedayCombo.setState(root, { disabled, readonly, invalid })` pushes a state change onto
|
|
811
|
-
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.
|
|
812
815
|
|
|
813
816
|
Fully styleable dropdown, APG combobox+listbox. Needs `freeday-select.js`.
|
|
814
817
|
|
|
@@ -851,13 +854,21 @@ keeps matching after selection. Do not put a glyph in that span.
|
|
|
851
854
|
| `placeholder?` | `string` | |
|
|
852
855
|
| `id?` · `ariaLabel?` · `ariaLabelledby?` · `describedby?` | `string` | Input id; its accessible name as text or as a reference; the help/error text it points at. |
|
|
853
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`. |
|
|
854
858
|
|
|
855
859
|
Blazor carries all of these. The states live on the input natively, and
|
|
856
|
-
`FreedayAutocomplete.setState(root, { disabled, readonly, invalid })` changes them after the first
|
|
860
|
+
`FreedayAutocomplete.setState(root, { disabled, readonly, invalid, required })` changes them after the first
|
|
857
861
|
render. A `readonly` input no longer opens its suggestion list, which it used to do over a field
|
|
858
862
|
nobody could edit.
|
|
859
863
|
|
|
860
|
-
|
|
864
|
+
**Anything the table does not name lands on the `<input>`** — `maxlength` (`maxLength` in React),
|
|
865
|
+
`inputmode`, `name`, a per-control `data-fdy-msg-required`, an event listener. `class` and `style`
|
|
866
|
+
stay on the root, which is what sizes the control. What the combobox contract depends on (`role`,
|
|
867
|
+
`type`, `autocomplete`, the ARIA wiring) is set by the component and cannot be overridden.
|
|
868
|
+
|
|
869
|
+
Editable combobox: **the list opens whole, and typing narrows it.** A value already in the field (a
|
|
870
|
+
default, a saved record) is not a query, so opening shows every option; filtering starts on the first
|
|
871
|
+
keystroke and is forgotten when the list closes. Needs `freeday-autocomplete.js`.
|
|
861
872
|
|
|
862
873
|
- `.fdy-autocomplete` · `__listbox` `__option` `__empty`
|
|
863
874
|
- The `<input>` carries `role="combobox"`, `aria-expanded`, `aria-autocomplete="list"`,
|
|
@@ -882,7 +893,7 @@ Editable combobox that filters as you type. Needs `freeday-autocomplete.js`.
|
|
|
882
893
|
| `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`. |
|
|
883
894
|
|
|
884
895
|
Raw path: `data-disabled` / `data-readonly` / `data-invalid`, `data-id`, `data-describedby`, and
|
|
885
|
-
`FreedayCascade.setState(root, { disabled, readonly, invalid })` for a host that rendered once.
|
|
896
|
+
`FreedayCascade.setState(root, { disabled, readonly, invalid, required })` for a host that rendered once.
|
|
886
897
|
Blazor calls the tree `Nodes`, adds `SubmenuLabel`, and carries everything else except
|
|
887
898
|
`ariaLabelledby` — the trigger it builds is named by `Label`.
|
|
888
899
|
|
|
@@ -940,6 +951,7 @@ Four of these are required and carry the whole component: `fetchPage`, `columns`
|
|
|
940
951
|
| `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. |
|
|
941
952
|
| `clearLabel?` | `string` | Accessible name for that button. Default `Clear selection`. |
|
|
942
953
|
| `disabled?` · `readonly?` · `invalid?` | `boolean` | `readonly` keeps the picked value visible, focusable and copyable, but the dialog cannot be opened. |
|
|
954
|
+
| `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`. |
|
|
943
955
|
| `id?` · `ariaLabelledby?` · `describedby?` | `string` | Field id; the element that labels it; the help/error text it points at. |
|
|
944
956
|
| `dialogOnly?` | `boolean` | Render the **dialog and no field**, for a caller whose trigger is already its own. See below. |
|
|
945
957
|
|
|
@@ -976,7 +988,10 @@ A read-only field backed by master data: the button opens a searchable dialog, t
|
|
|
976
988
|
the field. The value is always **chosen, never typed**. Needs `freeday-cfl.js`.
|
|
977
989
|
|
|
978
990
|
- Field: `.fdy-input-group` + `data-fdy-cfl="<dialog id>"`, `data-fdy-cfl-display="code"`,
|
|
979
|
-
`data-fdy-cfl-summary="{n} selected"` (multi)
|
|
991
|
+
`data-fdy-cfl-summary="{n} selected"` (multi). On pick the group mirrors the row's `data-value`
|
|
992
|
+
(else its display key; comma-joined in multi) into its own `data-value`, so `data-fdy-required`
|
|
993
|
+
on the group lets a `data-fdy-validate` form require it. Give the trigger `aria-haspopup="dialog"`:
|
|
994
|
+
that is the element the refusal marks and focuses.
|
|
980
995
|
- Dialog: `<dialog class="fdy-modal fdy-modal--cfl">` + `data-fdy-cfl-multiple` for multi-select
|
|
981
996
|
- Inside: `.fdy-cfl__search` `__results` `__row` `__check` `__empty` `__count` `__actions`
|
|
982
997
|
- Hooks: `data-fdy-cfl-search` (the search input), `data-fdy-cfl-empty`, `data-fdy-cfl-count`,
|
|
@@ -1070,8 +1085,8 @@ them do not: without these, a Spanish calendar would be navigated by English arr
|
|
|
1070
1085
|
On the **raw path** these all have hooks now: `data-disabled` / `data-readonly` / `data-invalid`,
|
|
1071
1086
|
`data-id`, `data-describedby`, and one `data-fdy-text-<key>` per label above
|
|
1072
1087
|
(`data-fdy-text-prev-month`, …). A host that renders its markup once and cannot re-render it can
|
|
1073
|
-
change the
|
|
1074
|
-
invalid })`.
|
|
1088
|
+
change the states afterwards with `FreedayDatepicker.setState(root, { disabled, readonly,
|
|
1089
|
+
invalid, required })`.
|
|
1075
1090
|
|
|
1076
1091
|
Blazor carries the same surface bar four: `locale` (the enhancer formats through `Intl` from the
|
|
1077
1092
|
page's `<html lang>`), `clearable` and `clearLabel` (this path builds no clear button), and
|
|
@@ -1117,6 +1132,7 @@ grid's own title.
|
|
|
1117
1132
|
| `startPlaceholder?` · `endPlaceholder?` | `string` | One per field. |
|
|
1118
1133
|
| `ariaLabel?` · `ariaLabelledby?` · `describedby?` | `string` | Names the group (`role="group"`), or points at the text that does. |
|
|
1119
1134
|
| `disabled?` · `readonly?` · `invalid?` | `boolean` | Applied to both pickers together. |
|
|
1135
|
+
| `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`. |
|
|
1120
1136
|
| `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. |
|
|
1121
1137
|
|
|
1122
1138
|
Blazor splits the value into two scalars, `From` / `FromChanged` and `To` / `ToChanged`, because a
|
|
@@ -1214,7 +1230,7 @@ Seed attributes: `data-step` (minutes, default 30), `data-min` (default `00:00`)
|
|
|
1214
1230
|
(default `23:59`), `data-value`, `data-label`, `data-placeholder` (default `--:--`), `data-id`,
|
|
1215
1231
|
`data-describedby`, `data-disabled`, `data-readonly`, `data-invalid`. Emits a bubbling
|
|
1216
1232
|
`fdy-time-select` (`detail {value}`). `FreedayTimepicker.setState(root, { disabled, readonly,
|
|
1217
|
-
invalid })` changes the
|
|
1233
|
+
invalid, required })` changes the states afterwards, which is what a host that renders its seed once
|
|
1218
1234
|
and never again (Blazor) needs.
|
|
1219
1235
|
|
|
1220
1236
|
**Use this instead of `<input type="time">`**, and not for theming alone: the native picker is
|
|
@@ -1325,21 +1341,25 @@ blur/input. Needs `freeday-form.js`.
|
|
|
1325
1341
|
- Emits `fdy-form-valid` / `fdy-form-invalid`.
|
|
1326
1342
|
- **A kit control can be required too** — `data-fdy-required` on its root. Combo, datepicker,
|
|
1327
1343
|
monthpicker, timepicker and cascade build a `<button>` trigger, and a button's `willValidate` is
|
|
1328
|
-
false, so `form.elements` never offered one and `required` on it meant nothing.
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
the
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
Re-validation watches
|
|
1339
|
-
itself
|
|
1344
|
+
false, so `form.elements` never offered one and `required` on it meant nothing. A
|
|
1345
|
+
choose-from-list is in the same position for a different reason: its `<input>` is `readonly`,
|
|
1346
|
+
and a readonly input is barred from constraint validation. The enhancer collects these roots
|
|
1347
|
+
alongside the native controls: empty `data-value` refuses the submit, the message lands in the
|
|
1348
|
+
same `.fdy-field` slot, and the focus goes to the trigger. It names no component — the value is
|
|
1349
|
+
read from `data-value` and the trigger is found by `aria-haspopup`. In the typed stacks pass
|
|
1350
|
+
`required` / `Required` instead of writing the attribute; every value-bearing wrapper has it.
|
|
1351
|
+
**An autocomplete is the one that takes the native `required`**, on its input: the input is
|
|
1352
|
+
editable, so constraint validation already covers it, and routing it through the kit path would
|
|
1353
|
+
give one field two sources of truth.
|
|
1354
|
+
Re-validation watches `data-value` and `data-fdy-required` with a `MutationObserver`, so no
|
|
1355
|
+
control has to announce itself, and lifting the requirement clears an error already on screen.
|
|
1356
|
+
- **Two controls in one `.fdy-field` share its message slot** — a date range's two ends, or two
|
|
1357
|
+
native inputs side by side. The message stays up while any control pointing at it is still
|
|
1358
|
+
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
|
|
1340
1359
|
attributes reach the root — the raw path, and Vue, where an unknown attribute falls through. In
|
|
1341
1360
|
React and Blazor they do not, so use the form-level `data-fdy-text-required`, which reads the
|
|
1342
|
-
same in every stack.
|
|
1361
|
+
same in every stack. `FdyAutocomplete` is the exception: it is validated on its input, and
|
|
1362
|
+
forwards the attribute there in all three.
|
|
1343
1363
|
- **`data-value` on a control's root is the live value**, not just the seed it used to be on the
|
|
1344
1364
|
datepicker, timepicker and cascade (the combo always kept it current). That is what makes the
|
|
1345
1365
|
rule above possible, and it is also the handle a test or a CSS empty-state rule can read.
|
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.19.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.19.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`.
|
package/USAGE.md
CHANGED
|
@@ -18,7 +18,7 @@ the single biggest cause of "flat grey mush". Pick the role, not the size:
|
|
|
18
18
|
| Role | Class | When |
|
|
19
19
|
|---|---|---|
|
|
20
20
|
| Eyebrow | `.fdy-eyebrow` | A small uppercase label above a page/section title. Optional. |
|
|
21
|
-
| Page title | `.fdy-title-page` | One per screen. The `<h1
|
|
21
|
+
| Page title | `.fdy-title-page` | One per screen. The `<h1>` on a standalone page; `<h2>` inside `.fdy-app`, whose `.fdy-app__title` is already the `<h1>` and names the current page. |
|
|
22
22
|
| Section title | `.fdy-title-section` | A region within the page (`<h2>`). |
|
|
23
23
|
| Card / row title | `.fdy-title-card` (or `.fdy-card__title`) | A title inside a card or list row (`<h3>`). |
|
|
24
24
|
| Body | *(default)* | Running text. |
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
option list as the user types and, on pick, fills the input + emits fdy-autocomplete-select
|
|
6
6
|
with the chosen text. Value is that text. The enhancer owns the input/listbox after
|
|
7
7
|
hydration (ShouldRender => false); the initial value seeds the input. *@
|
|
8
|
-
<div @ref="Root" data-fdy-autocomplete class="
|
|
9
|
-
<input class="fdy-input" role="combobox" aria-expanded="false" aria-autocomplete="list"
|
|
8
|
+
<div @ref="Root" data-fdy-autocomplete class="@RootClass" style="@RootStyle">
|
|
9
|
+
<input @attributes="InputAttributes" class="fdy-input" role="combobox" aria-expanded="false" aria-autocomplete="list"
|
|
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,33 @@ 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
|
+
|
|
52
|
+
/// <summary>Any other attribute (<c>maxlength</c>, <c>inputmode</c>, <c>name</c>, a per-control
|
|
53
|
+
/// <c>data-fdy-msg-required</c>) lands on the <c><input></c>; <c>class</c> and <c>style</c>
|
|
54
|
+
/// stay on the root, which is what sizes the control. The attributes the component sets itself
|
|
55
|
+
/// win, since they are written after these (#115).</summary>
|
|
56
|
+
[Parameter(CaptureUnmatchedValues = true)]
|
|
57
|
+
public IReadOnlyDictionary<string, object>? AdditionalAttributes { get; set; }
|
|
58
|
+
|
|
59
|
+
private string RootClass => Unmatched("class") is { } extra ? $"fdy-autocomplete {extra}" : "fdy-autocomplete";
|
|
60
|
+
private string? RootStyle => Unmatched("style");
|
|
61
|
+
private IEnumerable<KeyValuePair<string, object>> InputAttributes =>
|
|
62
|
+
(AdditionalAttributes ?? new Dictionary<string, object>()).Where(a => a.Key is not ("class" or "style"));
|
|
63
|
+
|
|
64
|
+
private string? Unmatched(string name) =>
|
|
65
|
+
AdditionalAttributes is not null && AdditionalAttributes.TryGetValue(name, out object? value) ? value?.ToString() : null;
|
|
66
|
+
|
|
47
67
|
protected override bool ShouldRender() => !Hydrated;
|
|
48
68
|
|
|
49
69
|
protected override async Task OnParametersSetAsync()
|
|
50
70
|
{
|
|
51
71
|
if (!Hydrated) return;
|
|
52
72
|
await JS.InvokeVoidAsync("FreedayAutocomplete.setState", Root,
|
|
53
|
-
new { disabled = Disabled, @readonly = Readonly, invalid = Invalid });
|
|
73
|
+
new { disabled = Disabled, @readonly = Readonly, invalid = Invalid, required = Required });
|
|
54
74
|
}
|
|
55
75
|
|
|
56
76
|
/// <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>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JSX } from 'react';
|
|
1
|
+
import type { InputHTMLAttributes, JSX } from 'react';
|
|
2
2
|
import { useEffect, useId, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { usePopover } from '../usePopover';
|
|
4
4
|
|
|
@@ -9,7 +9,12 @@ import { usePopover } from '../usePopover';
|
|
|
9
9
|
// (case-insensitive substring on the trimmed query); pass server-filtered `options` and it
|
|
10
10
|
// stays a no-op re-filter. `onSelect` fires only on commit (the enhancer's select event).
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
/** What the component owns on its <input>, or redefines with another signature. */
|
|
13
|
+
type OwnedInputAttrs = 'value' | 'defaultValue' | 'onChange' | 'onSelect' | 'type' | 'role' | 'autoComplete' | 'list' | 'readOnly' | 'children' | 'dangerouslySetInnerHTML';
|
|
14
|
+
|
|
15
|
+
/** Any other input attribute (maxLength, inputMode, name, a per-control data-fdy-msg-required) lands
|
|
16
|
+
* on the <input>; className and style stay on the root, which is what sizes the control (#115). */
|
|
17
|
+
export interface FdyAutocompleteProps extends Omit<InputHTMLAttributes<HTMLInputElement>, OwnedInputAttrs> {
|
|
13
18
|
value: string;
|
|
14
19
|
onChange: (value: string) => void;
|
|
15
20
|
options: ReadonlyArray<string>;
|
|
@@ -24,10 +29,20 @@ export interface FdyAutocompleteProps {
|
|
|
24
29
|
/** 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
30
|
readonly?: boolean;
|
|
26
31
|
invalid?: boolean;
|
|
32
|
+
/** The native `required`, on the input itself: it is editable, so constraint validation (and so a
|
|
33
|
+
* `data-fdy-validate` form) applies to it as to any input. Not `data-fdy-required`, which is for
|
|
34
|
+
* controls whose trigger is a button (#114). */
|
|
35
|
+
required?: boolean;
|
|
27
36
|
describedby?: string;
|
|
28
37
|
}
|
|
29
38
|
|
|
30
39
|
export function FdyAutocomplete(props: FdyAutocompleteProps): JSX.Element {
|
|
40
|
+
const {
|
|
41
|
+
value: _value, onChange: _onChange, options: _options, onSelect: _onSelect, emptyText: _emptyText,
|
|
42
|
+
placeholder: _placeholder, id: _id, ariaLabel: _ariaLabel, ariaLabelledby: _ariaLabelledby,
|
|
43
|
+
disabled: _disabled, readonly: _readonly, invalid: _invalid, required: _required,
|
|
44
|
+
describedby: _describedby, className, style, onFocus, ...inputAttrs
|
|
45
|
+
} = props;
|
|
31
46
|
const baseId: string = useId();
|
|
32
47
|
const inputId: string = props.id ?? `${baseId}-input`;
|
|
33
48
|
const listboxId: string = `${baseId}-listbox`;
|
|
@@ -38,6 +53,8 @@ export function FdyAutocomplete(props: FdyAutocompleteProps): JSX.Element {
|
|
|
38
53
|
const listboxRef = useRef<HTMLUListElement>(null);
|
|
39
54
|
const [open, setOpen] = useState<boolean>(false);
|
|
40
55
|
const [active, setActive] = useState<number>(-1);
|
|
56
|
+
/* Typed since this list opened. Until then the field's value is not a query (#115). */
|
|
57
|
+
const [typed, setTyped] = useState<boolean>(false);
|
|
41
58
|
|
|
42
59
|
usePopover(listboxRef, inputRef, open);
|
|
43
60
|
// Popover attr for React 18/19 JSX typing: set once on mount (same as FdyCombo).
|
|
@@ -50,15 +67,15 @@ export function FdyAutocomplete(props: FdyAutocompleteProps): JSX.Element {
|
|
|
50
67
|
const isInvalid: boolean = props.invalid === true;
|
|
51
68
|
|
|
52
69
|
const filtered: string[] = useMemo((): string[] => {
|
|
53
|
-
const q: string = props.value.trim().toLowerCase();
|
|
70
|
+
const q: string = typed ? props.value.trim().toLowerCase() : '';
|
|
54
71
|
return q === '' ? props.options.slice() : props.options.filter((o: string): boolean => o.toLowerCase().includes(q));
|
|
55
|
-
}, [props.options, props.value]);
|
|
72
|
+
}, [props.options, props.value, typed]);
|
|
56
73
|
|
|
57
74
|
const activeDescendant: string | undefined =
|
|
58
75
|
open && active >= 0 && active < filtered.length ? optionId(active) : undefined;
|
|
59
76
|
|
|
60
77
|
const openList = (): void => { if (!isDisabled && !isReadonly) setOpen(true); };
|
|
61
|
-
const closeList = (): void => { setOpen(false); setActive(-1); };
|
|
78
|
+
const closeList = (): void => { setOpen(false); setActive(-1); setTyped(false); };
|
|
62
79
|
|
|
63
80
|
const choose = (label: string): void => {
|
|
64
81
|
props.onChange(label);
|
|
@@ -113,8 +130,9 @@ export function FdyAutocomplete(props: FdyAutocompleteProps): JSX.Element {
|
|
|
113
130
|
}, [active, open]);
|
|
114
131
|
|
|
115
132
|
return (
|
|
116
|
-
<div ref={rootRef} className=
|
|
133
|
+
<div ref={rootRef} className={className === undefined ? 'fdy-autocomplete' : `fdy-autocomplete ${className}`} style={style} onKeyDown={onKeyDown}>
|
|
117
134
|
<input
|
|
135
|
+
{...inputAttrs}
|
|
118
136
|
ref={inputRef}
|
|
119
137
|
id={inputId}
|
|
120
138
|
className={isInvalid ? 'fdy-input fdy-input--error' : 'fdy-input'}
|
|
@@ -132,9 +150,10 @@ export function FdyAutocomplete(props: FdyAutocompleteProps): JSX.Element {
|
|
|
132
150
|
placeholder={props.placeholder}
|
|
133
151
|
disabled={isDisabled}
|
|
134
152
|
readOnly={isReadonly}
|
|
153
|
+
required={props.required === true}
|
|
135
154
|
value={props.value}
|
|
136
|
-
onChange={(e: React.ChangeEvent<HTMLInputElement>): void => { props.onChange(e.target.value); setActive(-1); openList(); }}
|
|
137
|
-
onFocus={openList}
|
|
155
|
+
onChange={(e: React.ChangeEvent<HTMLInputElement>): void => { props.onChange(e.target.value); setTyped(true); setActive(-1); openList(); }}
|
|
156
|
+
onFocus={(e: React.FocusEvent<HTMLInputElement>): void => { openList(); onFocus?.(e); }}
|
|
138
157
|
/>
|
|
139
158
|
<ul
|
|
140
159
|
ref={listboxRef}
|
|
@@ -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
|