@cahyo-dimas/freeday 3.19.1 → 3.21.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 +100 -2
- package/COMPONENTS.md +47 -5
- package/README.id.md +5 -3
- package/README.md +5 -3
- package/USAGE.md +116 -2
- package/adapters/blazor/FdyDateRange.razor +42 -20
- package/adapters/blazor/FdyDateRange.razor.cs +62 -1
- package/adapters/core/date-range.d.ts +37 -0
- package/adapters/core/date-range.js +61 -0
- package/adapters/react/components/FdyDateRange.tsx +61 -5
- package/adapters/react/components/FdyDatepicker.tsx +93 -12
- package/adapters/react/index.d.ts +1 -1
- package/adapters/react/rangeField.ts +25 -0
- package/adapters/vue/components/FdyDateRange.vue +57 -7
- package/adapters/vue/components/FdyDatepicker.vue +92 -8
- package/adapters/vue/index.d.ts +1 -1
- package/adapters/vue/rangeField.ts +31 -0
- package/dist/freeday-datepicker.js +150 -7
- package/dist/freeday.bundle.css +561 -225
- package/dist/freeday.css +15 -0
- package/dist/freeday.js +150 -7
- package/dist/freeday.tokens.css +546 -225
- package/docs/agent-onboarding.md +25 -12
- package/docs/getting-started.md +3 -3
- package/package.json +2 -2
- package/src/components/datepicker.css +15 -0
- package/tokens/tokens.json +69 -45
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,104 @@ benar. Perubahan seperti itu ditulis di bawah `### Changed: BREAKING (types)`
|
|
|
9
9
|
lama → tipe baru, dan cara menyempitkannya — bukan di bawah `### Added`, betapapun aditifnya dari
|
|
10
10
|
sisi kit.
|
|
11
11
|
|
|
12
|
+
## [3.21.0] - 2026-11-20
|
|
13
|
+
|
|
14
|
+
**Sebuah app memutuskan tampilannya sendiri.** Sebelum rilis ini kit hanya menawarkan palet primary,
|
|
15
|
+
dan semua abu-abu tetap slate yang kebiruan. App yang tidak mengubah apa pun tampil persis seperti
|
|
16
|
+
halaman docs kit, jadi keputusan tampilan sering tidak pernah diambil.
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- **`data-neutral="slate|grey|stone"`, sumbu kelima.** Ia mengarahkan ulang ramp alias `--neutral-*`
|
|
20
|
+
yang dibaca setiap abu-abu: permukaan, teks, border, kontrol, dan tinta `on-*`. `slate` tetap
|
|
21
|
+
bawaan. `grey` tanpa rona; `stone` hangat. Keduanya mempertahankan kecerahan slate di tiap shade,
|
|
22
|
+
jadi rasio kontras bergeser paling banyak sekitar 0,1 (terukur: grey 0,04, stone 0,11). Gerbang kontras mengukur semua
|
|
23
|
+
pasangan di kedua tema, `soft` dan `glass`, dan di bawah 18 palet. Ramp alias kini punya 14 shade
|
|
24
|
+
karena `slate` mendapat shade `850` (`#1c2130`, nilai `--color-border-muted` gelap yang dulu
|
|
25
|
+
literal).
|
|
26
|
+
- **Kontrak identitas di `USAGE.md` §0**: apa yang dimiliki app (sumbu, keluarga huruf, bobot, bentuk,
|
|
27
|
+
kedalaman, gerak) dan apa yang tidak, ditambah brief identitas yang diisi sebelum layar pertama.
|
|
28
|
+
- **Tabel komposisi di `USAGE.md` §7b.** Tabel 15 arketipe layout kini ikut terkirim di paket;
|
|
29
|
+
sebelumnya ia hanya ada di `reference/README.md`, yang tak pernah dikirim.
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
- **Blok onboarding di `docs/agent-onboarding.md` ditulis ulang**: app baru memutuskan tampilannya
|
|
33
|
+
sebelum layar pertama. Proyek yang menyalin blok itu perlu menggantinya seluruhnya.
|
|
34
|
+
|
|
35
|
+
### Fixed (docs)
|
|
36
|
+
- **Klaim soal `data-primary` pada elemen bersarang dikoreksi.** Yang tertulis: palet bisa dipasang
|
|
37
|
+
di elemen mana pun untuk mengubah satu region. Yang benar: ramp `--primary-*` ikut berubah, tetapi
|
|
38
|
+
token semantic yang membacanya dihitung di `:root` dan tidak ikut turun. Region bersarang butuh
|
|
39
|
+
`data-theme` di elemen yang sama supaya token semantic dihitung ulang di sana. Dikoreksi di
|
|
40
|
+
`docs/index.html`, `tokens/build.mjs`, `USAGE.md` §5b, `COMPONENTS.md`, dan
|
|
41
|
+
`docs/agent-onboarding.md`, dan dijaga satu uji peramban.
|
|
42
|
+
- **Di wrapper polos, sumbu hanya setengah berlaku.** Palet menggeser tinta label tetapi tidak
|
|
43
|
+
fill-nya; netral menggeser tinta tone, border, stripe, dan border danger tetapi tidak
|
|
44
|
+
permukaannya. Jadi jangan pasang sumbu di wrapper polos: pasang di `<html>`, atau di region
|
|
45
|
+
bersama `data-theme`.
|
|
46
|
+
- **Batasan yang didokumentasikan:** island terbalik (`data-theme` di sebuah region) di app dengan
|
|
47
|
+
palet atau netral bukan-default harus mengulang `data-primary` dan `data-neutral` di elemen yang
|
|
48
|
+
sama. Tanpa itu, label di atas fill oranye, amber, lime, hijau, emerald, teal, atau cyan jatuh ke kisaran
|
|
49
|
+
2 sampai 3,8:1 (lime 1,98:1 dan oranye 2,80:1 di island gelap; island terang di app gelap 3,09 sampai 3,77:1). Sudah begitu sejak 3.20.0; akar masalahnya dicatat di `NEXT-UP.md`.
|
|
50
|
+
- `noir` kini mengikuti netral yang dipilih, dan nama token `--bw` serta `--dur-base` di docs
|
|
51
|
+
dikoreksi.
|
|
52
|
+
|
|
53
|
+
### Catatan
|
|
54
|
+
- **Tanpa `data-neutral`, keluarannya tidak berubah.** Setiap token bernilai sama dengan 3.20.0 di
|
|
55
|
+
terang, gelap, `soft`, `glass`, dan di bawah tiap palet. `test/token-snapshot.test.mjs` menjaganya
|
|
56
|
+
terhadap nilai yang direkam dari 3.20.0.
|
|
57
|
+
- **Tiga triple Tier-1 tidak lagi dikeluarkan**: `--slate-0-rgb`, `--slate-900-rgb`, dan
|
|
58
|
+
`--slate-950-rgb`. Pengganti bagi yang membacanya langsung: `--neutral-0-rgb`, `--neutral-900-rgb`,
|
|
59
|
+
`--neutral-950-rgb`. Nilainya sama di bawah slate.
|
|
60
|
+
- Tidak ada perubahan pada `src/components/*.css`, enhancer, atau pembungkus.
|
|
61
|
+
|
|
62
|
+
## [3.20.0] - 2026-11-19
|
|
63
|
+
|
|
64
|
+
**Rentang tanggal dalam satu kolom.** `FdyDateRange` selama ini dua picker bersebelahan: makan dua
|
|
65
|
+
kolom di filter bar, patah jadi dua baris di layar sempit dengan `–` tertinggal di baris pertama, dan
|
|
66
|
+
rentangnya tidak pernah terlihat utuh di satu kalender. Diminta dari app ronda (`CATATAN-FREEDAY.md`
|
|
67
|
+
§28), dengan enam filter bar yang memakainya.
|
|
68
|
+
|
|
69
|
+
### Added
|
|
70
|
+
- **`layout="single"` di `FdyDateRange`** (`#118`, §28), di Vue, React, Blazor (`Layout =
|
|
71
|
+
FdyDateRangeLayout.Single`) dan jalur mentah (`data-fdy-daterange data-layout="single"` pada `div`
|
|
72
|
+
kosong). Satu pemicu berisi kedua tanggal dan satu kalender. Hari pertama yang dipilih menjadi
|
|
73
|
+
awal dan panel tetap terbuka; hari kedua menjadi akhir dan panel menutup. Hari sebelum awal
|
|
74
|
+
menjadi awal yang baru, tidak ditukar diam-diam. Hari yang di-hover atau difokus keyboard
|
|
75
|
+
menggambar pita pratinjau dengan ujung yang belum terisi, jadi rentangnya terlihat sebelum
|
|
76
|
+
dikomit. Escape dan klik di luar membuang awal yang belum punya akhir.
|
|
77
|
+
- **Nilainya hanya berubah saat rentangnya utuh**, jadi `change` dan `settled` datang bersamaan di
|
|
78
|
+
bentuk ini. Jalur mentah memancarkan `fdy-daterange-settled` saja. `data-value` di akarnya berbentuk
|
|
79
|
+
interval ISO 8601 `"awal/akhir"`, atau kosong selama rentangnya belum utuh, sehingga
|
|
80
|
+
`data-fdy-required` berlaku tanpa aturan baru di `freeday-form.js`.
|
|
81
|
+
- **Prop baru:** `layout`, `placeholder` (bawaan `Select dates`; enhancer `Choose dates`),
|
|
82
|
+
`rangeStartLabel` dan `rangeEndLabel` (bawaan `range start` / `range end`), yang ditambahkan ke nama
|
|
83
|
+
aksesibel hari awal dan akhir supaya kedua ujung tidak dibedakan oleh warna saja. Di jalur mentah
|
|
84
|
+
kuncinya `data-fdy-text-range-start`, `-range-end`, `-label-range` dan `-placeholder-range`.
|
|
85
|
+
`FdyDateRangeLayout` diekspor sebagai tipe dari `/vue` dan `/react`.
|
|
86
|
+
- **`.fdy-datepicker--range`**, `.is-range-start` dan `.is-range-end`. Lebar maksimum pemicu 18rem,
|
|
87
|
+
sebab pasangan tanggal terpanjang yang diukur butuh 14,63rem (`id`) sampai 15,13rem (`en-US`).
|
|
88
|
+
|
|
89
|
+
### Changed
|
|
90
|
+
- **Pita `.in-range` kini menyambung.** Sel hari berjarak 2px, jadi pita di jalur mentah bentuk
|
|
91
|
+
`split` selama ini bergaris. Tiap sel di pita kini menutup celah di kedua sisinya, dan cincin fokus
|
|
92
|
+
dikembalikan pada sel pita, yang tadinya tertimpa bayangan pita.
|
|
93
|
+
|
|
94
|
+
### Catatan
|
|
95
|
+
- **Satu kalender per stack, tanpa salinan baru.** `FdyDatepicker` Vue dan React menggambar rentang
|
|
96
|
+
itu sendiri saat `FdyDateRange` menyediakan konteks internal (`provide` di Vue, Context di React).
|
|
97
|
+
Rentang tidak dijadikan prop `FdyDatepicker`, sebab bentuk nilai yang ditentukan prop lain adalah
|
|
98
|
+
cacat yang memensiunkan `mode="month"`. Aturan murninya (ujung mana yang tampil, keadaan tiap sel,
|
|
99
|
+
arti sebuah klik) ada di `adapters/core/date-range.js`; enhancer memegang salinannya sendiri karena
|
|
100
|
+
alasan yang sama dengan `month-grid.js`.
|
|
101
|
+
- **Bentuk `split` di Vue dan React tetap tanpa pewarnaan `.in-range`**, seperti sebelumnya. Tiap
|
|
102
|
+
pickernya berdiri sendiri, dan menambahkannya tidak diminta.
|
|
103
|
+
- **`Layout` di Blazor dibaca sekali**, pada render pertama, seperti setiap seed lain yang komponen
|
|
104
|
+
itu serahkan ke enhancer.
|
|
105
|
+
- Diuji di `browser/daterange-single.mjs`: 13 kasus dengan mouse dan tombol asli di ketiga
|
|
106
|
+
implementasi, termasuk form yang menolak rentang setengah jadi. Tiga mutasi (komit di klik
|
|
107
|
+
pertama, pita pratinjau hilang, setengah rentang bertahan sesudah ditutup) masing-masing membuat 5,
|
|
108
|
+
4 dan 1 kasus merah. Ditambah 3 uji bUnit dan 5 uji unit untuk `date-range.js`.
|
|
109
|
+
|
|
12
110
|
## [3.19.1] - 2026-11-09
|
|
13
111
|
|
|
14
112
|
Hanya dokumen dan uji. Tidak ada perubahan pada CSS, enhancer, atau pembungkus.
|
|
@@ -594,7 +692,7 @@ perbaikan ini terdengar jauh lebih mahal daripada yang ternyata.
|
|
|
594
692
|
|
|
595
693
|
### Catatan
|
|
596
694
|
- `FdyAutocomplete` dan `FdyCfl` **di luar** aturan ini: keduanya merender `<input>` asli, jadi
|
|
597
|
-
`required` native yang cocok. Belum ada prop yang mengeksposnya, dan atribut tak dikenal jatuh ke
|
|
695
|
+
`required` native yang cocok. Belum ada prop yang mengeksposnya, dan atribut tak dikenal jatuh ke kisaran
|
|
598
696
|
AKAR wrapper bukan ke input di dalamnya, jadi hari ini keduanya tak bisa dijadikan wajib di stack
|
|
599
697
|
mana pun. Dicatat terbuka di `NEXT-UP.md` alih-alih ditutup separuh: mengalirkannya lewat jalur
|
|
600
698
|
kit akan memberi satu field dua sumber kebenaran.
|
|
@@ -1020,7 +1118,7 @@ mentok di iOS 15.
|
|
|
1020
1118
|
|
|
1021
1119
|
Perbaikan pertama yang dicoba justru membuktikan sebabnya. Pola cadangan yang biasa dipakai orang,
|
|
1022
1120
|
nilai statis dulu lalu `color-mix()` sesudahnya, tidak bekerja ketika deklarasinya memuat `var()`:
|
|
1023
|
-
deklarasi itu sah saat parse dan baru gagal saat computed-value, dan di jalur itu properti jatuh ke
|
|
1121
|
+
deklarasi itu sah saat parse dan baru gagal saat computed-value, dan di jalur itu properti jatuh ke kisaran
|
|
1024
1122
|
nilai initial, bukan ke baris sebelumnya. Untuk `border-color` nilai initial itu `currentColor`,
|
|
1025
1123
|
yaitu hitam. Keluhan tentang garis hitam tebal di mana-mana itulah bukti mekanismenya. Jadi
|
|
1026
1124
|
`color-mix()`-nya yang dibuang.
|
package/COMPONENTS.md
CHANGED
|
@@ -22,7 +22,7 @@ live docs.
|
|
|
22
22
|
2. **Never invent a class.** If it is not in this file, it does not exist. Freeday has no
|
|
23
23
|
`fdy-grid`, no `fdy-flex`, no `fdy-mt-4`, no `fdy-primary`.
|
|
24
24
|
3. **Never write a raw hex or px value** in app CSS. Use the tokens: `var(--color-primary)`,
|
|
25
|
-
`var(--space-4)`, `var(--radius-md)`, `var(--shadow-1)`, `var(--dur-
|
|
25
|
+
`var(--space-4)`, `var(--radius-md)`, `var(--shadow-1)`, `var(--dur-base)`. Spacing is a 4px scale
|
|
26
26
|
(`--space-0`…`--space-24`); a loose value breaks density switching.
|
|
27
27
|
4. **Freeday owns components + tokens, not layout.** The only layout it ships is the shell
|
|
28
28
|
(`.fdy-app`, and `.fdy-standalone` for screens outside it), the composition primitives below, and `.fdy-hidden`/`.fdy-visually-hidden`.
|
|
@@ -525,10 +525,23 @@ without a reload.
|
|
|
525
525
|
<script>try{var t=localStorage.getItem('fdy-theme');if(t==='light'||t==='dark')document.documentElement.setAttribute('data-theme',t)}catch(e){}</script>
|
|
526
526
|
```
|
|
527
527
|
|
|
528
|
+
**Neutral: `data-neutral`.** Three options for every grey in the kit (surfaces, borders, text
|
|
529
|
+
inks, the chart grid, and the `noir` palette): `slate` (the default, and what you get with no
|
|
530
|
+
attribute), `grey` (no hue) and `stone` (warm). Each shade keeps the lightness of the slate shade
|
|
531
|
+
with the same number, and every option is contrast-gated in both themes and under all 18 palettes.
|
|
532
|
+
Set it on `<html>`; on a region, only together with `data-theme`, because on a bare wrapper it half-applies (`USAGE.md` §5b).
|
|
533
|
+
|
|
534
|
+
```html
|
|
535
|
+
<html data-neutral="stone" data-primary="noir">
|
|
536
|
+
```
|
|
537
|
+
|
|
528
538
|
**Primary palette: `data-primary`.** 18 options — `azure` (the default, and what you get with no
|
|
529
539
|
attribute) · `sky` `blue` `indigo` `violet` `purple` `fuchsia` `pink` `rose` · `orange` `amber`
|
|
530
|
-
`yellow` `lime` `green` `emerald` `teal` `cyan` · `noir`. Set it
|
|
531
|
-
|
|
540
|
+
`yellow` `lime` `green` `emerald` `teal` `cyan` · `noir`. Set it on `<html>`. To re-brand one
|
|
541
|
+
region, put it on that region together with `data-theme`: the palette only reaches the semantic
|
|
542
|
+
tokens where `data-theme` re-declares them. On a bare wrapper it half-applies: the label ink
|
|
543
|
+
moves but the fill does not, so never do that. An inverted island (`data-theme` on a region) in an
|
|
544
|
+
app with a non-default look repeats `data-primary` and `data-neutral` beside its `data-theme`.
|
|
532
545
|
|
|
533
546
|
```html
|
|
534
547
|
<html data-primary="emerald" data-theme="dark">
|
|
@@ -1125,18 +1138,31 @@ grid's own title.
|
|
|
1125
1138
|
| Prop | Type | What it does |
|
|
1126
1139
|
|---|---|---|
|
|
1127
1140
|
| `modelValue` · `value` | `DateRangeValue` = `{ start, end }`, each `string \| null` | Both ends at once, so the pair can never be half-applied. |
|
|
1141
|
+
| `layout?` | `'split' \| 'single'` | `split` (default) is two pickers side by side. `single` is one field holding both dates, with one calendar in which the first day picked is the start and the second is the end. The value changes only once the range is whole, so `change` and `settled` arrive together, and Escape or a click outside drops a start that has no end yet. Blazor takes the enum `FdyDateRangeLayout`. |
|
|
1142
|
+
| `placeholder?` | `string` | The empty field's text under `layout="single"`. Default `Select dates`. |
|
|
1143
|
+
| `rangeStartLabel?` · `rangeEndLabel?` | `string` | Under `layout="single"`, appended to the accessible name of the range's first and last day, so the ends are not told apart by colour alone. Defaults `range start` / `range end`. |
|
|
1128
1144
|
| `onChange` | `(value: DateRangeValue) => void` | React. Vue emits `update:modelValue` and `change`. Fires on **each** end, which is right for a binding and wrong for a reload. |
|
|
1129
1145
|
| `onSettled?` | `(value: DateRangeValue) => void` | React. Vue emits `settled`, Blazor `Settled` (`SettledRange(From, To)`), the raw path `fdy-daterange-settled` `{ from, to }` on the group. Fires only when **both ends are chosen or both are empty**, so a list that reloads on it never filters on half a range. |
|
|
1130
1146
|
| `min?` · `max?` | `string` | ISO bounds for both ends. The end can never precede the start. |
|
|
1131
1147
|
| `locale?` | `string` | As on the single picker. |
|
|
1132
|
-
| `startPlaceholder?` · `endPlaceholder?` | `string` | One per field
|
|
1148
|
+
| `startPlaceholder?` · `endPlaceholder?` | `string` | One per field, under `layout="split"`. |
|
|
1133
1149
|
| `ariaLabel?` · `ariaLabelledby?` · `describedby?` | `string` | Names the group (`role="group"`), or points at the text that does. |
|
|
1134
1150
|
| `disabled?` · `readonly?` · `invalid?` | `boolean` | Applied to both pickers together. |
|
|
1135
1151
|
| `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`. |
|
|
1136
1152
|
| `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. |
|
|
1137
1153
|
|
|
1138
1154
|
Blazor splits the value into two scalars, `From` / `FromChanged` and `To` / `ToChanged`, because a
|
|
1139
|
-
C# binding cannot express one object bound in two places, and it adds `Separator`.
|
|
1155
|
+
C# binding cannot express one object bound in two places, and it adds `Separator`. Under
|
|
1156
|
+
`Layout="FdyDateRangeLayout.Single"` both scalars change in the same call, followed by `Settled`, and
|
|
1157
|
+
it takes `Placeholder`, `RangeStartLabel` and `RangeEndLabel`.
|
|
1158
|
+
|
|
1159
|
+
**When to pick `single`.** It takes one field's width instead of two, and the whole range is visible
|
|
1160
|
+
in the calendar while it is being picked. In a `.fdy-filterbar`, give its field `.fdy-field--w-xl`.
|
|
1161
|
+
The widest pair measured, 28 September to 30 December, needs 14.63rem in `id`, 14.94rem in `en-GB`
|
|
1162
|
+
and 15.13rem in `en-US`, so the bar's default 12rem cuts the second date short and `--w-lg` (15rem)
|
|
1163
|
+
still clips it in `en-US`. Keep
|
|
1164
|
+
`split` where each end is its own decision, such as a start date filled in long before the end is
|
|
1165
|
+
known.
|
|
1140
1166
|
|
|
1141
1167
|
Input-styled trigger + calendar popover. Needs `freeday-datepicker.js`. **Author an empty `<div>`**
|
|
1142
1168
|
The enhancer builds everything.
|
|
@@ -1149,6 +1175,15 @@ The enhancer builds everything.
|
|
|
1149
1175
|
a start picked past the end clears the end, and that clear fires `fdy-datepicker-change` with
|
|
1150
1176
|
`value: ''` like a pick. Reload on `fdy-daterange-settled`, not on each change.
|
|
1151
1177
|
**Typed wrapper: `<FdyDateRange>`** (Vue/React/Blazor). Use it in those stacks.
|
|
1178
|
+
- Range in one field: an **empty** `<div data-fdy-daterange data-layout="single">`, with no class
|
|
1179
|
+
and no children. The enhancer builds one `.fdy-datepicker.fdy-datepicker--range`. `data-value`
|
|
1180
|
+
holds `"start/end"` (the ISO 8601 interval form) or `""`; the root mirrors it live, so
|
|
1181
|
+
`data-fdy-required` works as on any kit control, and half a range reads as empty. `data-label` or
|
|
1182
|
+
`aria-label` names the trigger. `data-min`, `data-max` and `data-placeholder` work as on one
|
|
1183
|
+
picker. It emits only `fdy-daterange-settled` `{ from, to }`, once per whole range. The ends of
|
|
1184
|
+
the band carry `.is-range-start` / `.is-range-end`, the days between `.in-range`, and the two
|
|
1185
|
+
extra strings are `data-fdy-text-range-start` / `data-fdy-text-range-end` (defaults `range start`
|
|
1186
|
+
/ `range end`), beside `data-fdy-text-label-range` and `data-fdy-text-placeholder-range`.
|
|
1152
1187
|
**Getting to a distant date.** The title is a **button**, and it drills up one level each press:
|
|
1153
1188
|
day grid → 12-cell month grid (`.fdy-cal__grid--months` of `.fdy-cal__month`) → 12-cell year grid
|
|
1154
1189
|
(`.fdy-cal__grid--years` of `.fdy-cal__year`). The arrows follow the level shown: months, then
|
|
@@ -1217,6 +1252,13 @@ it has always been, down to the `YYYY-MM-DD` it reports.
|
|
|
1217
1252
|
<span class="fdy-daterange__sep" aria-hidden="true">–</span>
|
|
1218
1253
|
<div data-fdy-datepicker data-role="to" data-placeholder="To" data-label="End date"></div>
|
|
1219
1254
|
</div>
|
|
1255
|
+
|
|
1256
|
+
<!-- The same range in one field. Typed stacks: <FdyDateRange layout="single">. -->
|
|
1257
|
+
<div class="fdy-field">
|
|
1258
|
+
<span class="fdy-label">Reporting period</span>
|
|
1259
|
+
<div data-fdy-daterange data-layout="single" data-value="2026-11-01/2026-11-30"
|
|
1260
|
+
data-label="Reporting period"></div>
|
|
1261
|
+
</div>
|
|
1220
1262
|
```
|
|
1221
1263
|
|
|
1222
1264
|
## Time picker — `data-fdy-timepicker`
|
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.21.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`.
|
|
@@ -143,7 +143,7 @@ Tabel lebar (banyak kolom) butuh wrapper untuk scroll horizontal: bungkus `.fdy-
|
|
|
143
143
|
border/shadow-nya sudah ada sendiri). Tanpa salah satu wrapper ini, tabel lebar akan overflow
|
|
144
144
|
container-nya, bukan scroll sendiri.
|
|
145
145
|
|
|
146
|
-
### 3. Theming:
|
|
146
|
+
### 3. Theming: 5 sumbu lewat `data-*` di root
|
|
147
147
|
- `data-theme="light|dark"` me-redefinisi token semantic (bind ke state tema app-mu).
|
|
148
148
|
Berlaku di **ancestor mana pun**, tak harus root: `<section data-theme="dark">` membalik region itu
|
|
149
149
|
dan semua komponen di dalamnya ikut (lihat [`USAGE.md`](USAGE.md) §5b).
|
|
@@ -151,7 +151,9 @@ container-nya, bukan scroll sendiri.
|
|
|
151
151
|
Ini auto-apply hanya ke kontrol bawaan Freeday (button, input, combo, dst); komponen
|
|
152
152
|
custom/hand-built harus baca `--control-h` sendiri (mis. `height: var(--control-h)`) supaya ikut
|
|
153
153
|
menyusut/melebar saat `data-density` berubah.
|
|
154
|
-
-
|
|
154
|
+
- `data-style="soft|glass"` memilih gaya visual, `data-primary` satu dari 18 palet primary, dan
|
|
155
|
+
`data-neutral="slate|grey|stone"` keluarga semua abu-abu. Pasang dua yang terakhir di `<html>`;
|
|
156
|
+
di sebuah region hanya bersama `data-theme` (lihat [`USAGE.md`](USAGE.md) §0 dan §5b).
|
|
155
157
|
- Skala breakpoint (`sm`/`md`/`lg`/`xl` = 600/960/1280/1920px, sama dengan utilitas
|
|
156
158
|
`src/components/breakpoints.css`) tersedia untuk app-mu dalam dua bahasa: `import { breakpoints }
|
|
157
159
|
from '@cahyo-dimas/freeday/breakpoints'` untuk JS (`matchMedia`, varian utility), dan `@import
|
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.21.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`.
|
|
@@ -145,7 +145,7 @@ Wide tables (many columns) need a wrapper for horizontal scroll: wrap `.fdy-tabl
|
|
|
145
145
|
border/shadow shell). Without one of these wrappers, a wide table overflows its container instead
|
|
146
146
|
of scrolling.
|
|
147
147
|
|
|
148
|
-
### 3. Theming:
|
|
148
|
+
### 3. Theming: 5 axes via `data-*` on the root
|
|
149
149
|
- `data-theme="light|dark"` redefines the semantic tokens (bind it to your app's theme state).
|
|
150
150
|
Works on **any ancestor**, not just the root: `<section data-theme="dark">` inverts that region
|
|
151
151
|
and every component inside it follows (see [`USAGE.md`](USAGE.md) §5b).
|
|
@@ -153,7 +153,9 @@ of scrolling.
|
|
|
153
153
|
This auto-applies only to Freeday's built-in controls (button, input, combo, etc.);
|
|
154
154
|
custom/hand-built components must read `--control-h` themselves (e.g. `height: var(--control-h)`)
|
|
155
155
|
to shrink or grow when `data-density` changes.
|
|
156
|
-
-
|
|
156
|
+
- `data-style="soft|glass"` picks the visual style, `data-primary` one of 18 primary palettes, and
|
|
157
|
+
`data-neutral="slate|grey|stone"` the family of every grey. Set the last two on `<html>`; on a
|
|
158
|
+
region only beside `data-theme` (see [`USAGE.md`](USAGE.md) §0 and §5b).
|
|
157
159
|
- The breakpoint scale (`sm`/`md`/`lg`/`xl` = 600/960/1280/1920px, matching the
|
|
158
160
|
`src/components/breakpoints.css` utilities) is available to your app in both languages: `import
|
|
159
161
|
{ breakpoints } from '@cahyo-dimas/freeday/breakpoints'` for JS (`matchMedia`, utility variants),
|
package/USAGE.md
CHANGED
|
@@ -10,6 +10,73 @@ but start here, not from a blank page.
|
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
+
## 0. App identity: what the app decides
|
|
14
|
+
|
|
15
|
+
Freeday supplies components and tokens. How an app looks is the app's decision, made inside the
|
|
16
|
+
contract below. An app that changes nothing looks like the kit's docs page. That suits the docs
|
|
17
|
+
page and wastes the decision everywhere else.
|
|
18
|
+
|
|
19
|
+
The look lives in two places: the `data-*` attributes on `<html>`, and one file,
|
|
20
|
+
`app.identity.css`, loaded after the Freeday bundle.
|
|
21
|
+
|
|
22
|
+
| The app owns | Where |
|
|
23
|
+
|---|---|
|
|
24
|
+
| Palette (18), neutral (`slate`, `grey`, `stone`), style, density, default theme | `data-primary`, `data-neutral`, `data-style`, `data-density`, `data-theme` on `<html>` |
|
|
25
|
+
| Type families: `--font-display`, `--font-body`, `--font-mono` | `app.identity.css` |
|
|
26
|
+
| Weights and tracking: `--weight-*`, `--tracking-*` | `app.identity.css` |
|
|
27
|
+
| Shape: `--radius-xs` to `--radius-xl` | `app.identity.css` |
|
|
28
|
+
| Depth: `--shadow-1` to `--shadow-4`, `--shadow-lift`, `--shadow-lift-hover` | `app.identity.css`, light and dark |
|
|
29
|
+
| Motion: `--dur-*`, `--ease-*` | `app.identity.css` |
|
|
30
|
+
| One component, locally: `--fdy-<component>-<property>` | your own CSS |
|
|
31
|
+
|
|
32
|
+
Everything else stays with the kit. Colour reaches an app only through the attributes, because
|
|
33
|
+
the attributes are what the contrast gate tests, so your CSS carries no `--color-*`, `--tone-*` or
|
|
34
|
+
`--chart-*`. Spacing (`--space-*`) and control size (`--control-*`) carry density. The type size
|
|
35
|
+
scale (`--text-*`, `--leading-*`) sets control heights and table density, so a screen that wants
|
|
36
|
+
big type uses `var(--text-xl)` and up in its own content. `--radius-full`, `--bw` and the focus
|
|
37
|
+
ring are accessibility contracts.
|
|
38
|
+
|
|
39
|
+
`app.identity.css` is the one file where literal values belong, and only as values of the tokens
|
|
40
|
+
in the table. Shadows need four blocks in this order, because the kit sets dark shadows in three
|
|
41
|
+
scopes and a lone `:root` rule loses to one of them in each dark mode:
|
|
42
|
+
|
|
43
|
+
```css
|
|
44
|
+
/* app.identity.css: load after @cahyo-dimas/freeday/css. Owned tokens only. */
|
|
45
|
+
:root {
|
|
46
|
+
--font-display: 'Fraunces', ui-serif, Georgia, serif;
|
|
47
|
+
--font-body: 'Inter', ui-sans-serif, system-ui, sans-serif;
|
|
48
|
+
--radius-sm: 2px;
|
|
49
|
+
--radius-md: 4px;
|
|
50
|
+
--shadow-1: 0 1px 0 rgba(0,0,0,.06);
|
|
51
|
+
}
|
|
52
|
+
@media (prefers-color-scheme: dark) {
|
|
53
|
+
:root:not([data-theme="light"]) { --shadow-1: 0 1px 0 rgba(0,0,0,.5); }
|
|
54
|
+
}
|
|
55
|
+
[data-theme="dark"] { --shadow-1: 0 1px 0 rgba(0,0,0,.5); }
|
|
56
|
+
[data-theme="light"] { --shadow-1: 0 1px 0 rgba(0,0,0,.06); }
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Fonts, radius and motion have no dark value and need only the `:root` block. The file loads its
|
|
60
|
+
own fonts. A replacement body or display font needs tabular figures (the OpenType `tnum` feature):
|
|
61
|
+
stat values, calendar days, chart values and the slider readout set `tabular-nums`, and without
|
|
62
|
+
it their digits shift as they change.
|
|
63
|
+
|
|
64
|
+
Decide before the first screen. A new app starts with a short brief in its own `DESIGN.md`,
|
|
65
|
+
then `app.identity.css`, then the attributes. Leaving an axis at its default is fine when the
|
|
66
|
+
brief says why.
|
|
67
|
+
|
|
68
|
+
```markdown
|
|
69
|
+
## Design brief
|
|
70
|
+
- Who uses this, and the one task they do most:
|
|
71
|
+
- Density: comfortable | compact, and why
|
|
72
|
+
- Mood, in three words (not "clean", "modern" or "intuitive"):
|
|
73
|
+
- Axes: data-primary=… data-neutral=… data-style=… default theme=…
|
|
74
|
+
- Type: display / body / mono, and why they suit these users
|
|
75
|
+
- Shape and depth: radius scale, shadow scale
|
|
76
|
+
- Screens and their archetype (§7b):
|
|
77
|
+
- One thing this app has that a default Freeday app does not:
|
|
78
|
+
```
|
|
79
|
+
|
|
13
80
|
## 1. Type roles: three title levels, not eleven
|
|
14
81
|
|
|
15
82
|
Do **not** reuse `.fdy-card__title` for a page title. Collapsing page/section/card into one style is
|
|
@@ -170,6 +237,17 @@ restating colours per element.
|
|
|
170
237
|
The **system** default (`@media (prefers-color-scheme: dark)`) stays root-scoped on purpose: that
|
|
171
238
|
rule is about the document, and un-rooting it would re-darken the children of a light island.
|
|
172
239
|
|
|
240
|
+
`data-primary` and `data-neutral` follow the same selectors, with one difference. They re-point
|
|
241
|
+
an alias ramp, and the semantic tokens resolve that ramp where they are declared: on `<html>`, or
|
|
242
|
+
on an element that carries `data-theme`. So put them on `<html>`. To re-brand or re-tint a single
|
|
243
|
+
region, put the axis on that region together with `data-theme`. Never put either axis on a bare
|
|
244
|
+
wrapper: it half-applies. A palette moves the label ink (`--color-on-primary`) but not the fill, so
|
|
245
|
+
orange, amber, lime, green, emerald, teal and cyan leave dark ink on the azure fill (2.87:1 for orange); a neutral moves
|
|
246
|
+
the tone inks, borders, stripe and danger border but not the surfaces. An inverted island inside an app
|
|
247
|
+
with a non-default look must repeat `data-primary` and `data-neutral` beside its `data-theme`.
|
|
248
|
+
Otherwise the island keeps the app's fill but takes the default label ink, and white labels on
|
|
249
|
+
those fills drop to between 2:1 and 3.8:1 (lime 1.98:1 and orange 2.80:1 in a dark island).
|
|
250
|
+
|
|
173
251
|
## 6. Density: `compact` for data-dense screens
|
|
174
252
|
|
|
175
253
|
`data-density="compact"` tightens control height **and** the mid-range spacing scale
|
|
@@ -241,7 +319,43 @@ own language; for the rest (grids, one-off spacing), pair a utility framework ru
|
|
|
241
319
|
preflight-off**, and build its theme on `var(--space-N)` so the two systems agree. See
|
|
242
320
|
`docs/getting-started.md` §Core concepts.
|
|
243
321
|
|
|
244
|
-
---
|
|
245
|
-
|
|
246
322
|
*Layout classes here live in `src/components/composition.css`. If a screen needs a primitive that
|
|
247
323
|
isn't here, it probably belongs here. Open an issue rather than re-inventing it per screen.*
|
|
324
|
+
|
|
325
|
+
## 7b. Composition: pick the screen's shape first
|
|
326
|
+
|
|
327
|
+
Decide what kind of screen this is before reaching for components. Freeday owns components and
|
|
328
|
+
tokens, not layout, so for most shapes the frame is yours and the kit fills it. This table splits
|
|
329
|
+
the work for 15 common web-app archetypes:
|
|
330
|
+
|
|
331
|
+
| # | Archetype | Freeday gives you | You build |
|
|
332
|
+
|---|---|---|---|
|
|
333
|
+
| 1 | **Dashboard / admin** | `.fdy-app` · `.fdy-page` · `.fdy-stats`/`.fdy-stat` · `.fdy-card` · `data-fdy-chart` · `.fdy-datatable` | nothing, fully covered; see [`docs/reference-screen.html`](docs/reference-screen.html) |
|
|
334
|
+
| 2 | **Master-detail** | list = `.fdy-datatable` + `.fdy-table__row--activatable`; detail = `.fdy-card` + `.fdy-dl` + `.fdy-tabs`; narrow screens = `.fdy-drawer` | the two-pane split |
|
|
335
|
+
| 3 | **Kanban board** | cards = `.fdy-card--interactive` / `--button`; labels = `.fdy-chip--tone-N`; counts = `.fdy-badge` | the column grid **and** drag-and-drop (no DnD in the kit) |
|
|
336
|
+
| 4 | **Feed / timeline** | `.fdy-timeline` (event feed) · `.fdy-card` (items) · `.fdy-avatar` · `.fdy-skeleton` while loading | the column widths |
|
|
337
|
+
| 5 | **Chat / messaging** | conversation list = `.fdy-nav`; unread = `.fdy-badge-ov`; composer = `.fdy-textarea` + `.fdy-btn`; `.fdy-avatar` | the bubbles and the scroll-to-bottom behaviour |
|
|
338
|
+
| 6 | **Canvas / whiteboard** | chrome only: `.fdy-appbar` · `.fdy-btn-group` · `.fdy-fab` · `.fdy-menu` · `.fdy-tooltip` | the canvas itself |
|
|
339
|
+
| 7 | **Calendar / scheduler** | range filter = `.fdy-daterange`; events = `.fdy-chip` / `.fdy-badge`; day detail = `.fdy-drawer` | the month grid: there is **no** calendar-view component (`.fdy-cal__grid` / `.fdy-cal__day` are datepicker internals, not public layout) |
|
|
340
|
+
| 8 | **Document editor** | `.fdy-app` shell · outline = `.fdy-tree` · `.fdy-toolbar` + `.fdy-btn-group` · `.fdy-kbd` for shortcuts | the editing surface |
|
|
341
|
+
| 9 | **Media / streaming** | tiles = `.fdy-card` · rails = `.fdy-carousel` · `.fdy-skeleton` · playback = `.fdy-progress` | the poster grid |
|
|
342
|
+
| 10 | **E-commerce account** | `.fdy-page-section` · `.fdy-dl` · orders = `.fdy-table` · status = `.fdy-badge` · `.fdy-accordion` | nothing much, mostly covered |
|
|
343
|
+
| 11 | **Analytics / BI** | `.fdy-stats` · `data-fdy-chart` (sparkline/bar/line/area/donut, palette `--chart-1`…`8`) · `.fdy-filterbar` · `.fdy-daterange` | the tile grid |
|
|
344
|
+
| 12 | **Point of sale** | `.fdy-app--nav-collapsed` for screen space · product tiles = `.fdy-card--button` · cart = `.fdy-table` + `.fdy-table__num` · totals = `.fdy-stat` · `.fdy-fab` to pay · `data-density="compact"` | the two-column till layout |
|
|
345
|
+
| 13 | **Wizard / multi-step** | `.fdy-stepper` · `.fdy-step-panels` · `.fdy-step-nav` · `.fdy-form-grid` | nothing, fully covered |
|
|
346
|
+
| 14 | **File manager** | folders = `.fdy-tree` · upload = `.fdy-dropzone` + `.fdy-filelist` + `.fdy-file` · actions = `.fdy-menu` · `.fdy-breadcrumb` | the icon grid |
|
|
347
|
+
| 15 | **Community / forum** | threads = `.fdy-card` · `.fdy-avatar--tone-N` · tags = `.fdy-chip` · `.fdy-pagination` · replies = `.fdy-timeline` | the thread list layout |
|
|
348
|
+
|
|
349
|
+
If a shape needs something the kit has no component for, build the shape and fill it with kit
|
|
350
|
+
components. Never invent an `fdy-` class for it; the complete list is `COMPONENTS.md`.
|
|
351
|
+
|
|
352
|
+
Three habits make every app look like the same template, so avoid them:
|
|
353
|
+
|
|
354
|
+
- **A stats row on top of every screen.** `.fdy-stats` belongs on a screen whose job is the
|
|
355
|
+
numbers. On a list or a form it pushes the work below the fold.
|
|
356
|
+
- **A page that is a grid of identical cards.** See §3: one raised element that matters, the rest
|
|
357
|
+
flat.
|
|
358
|
+
- **A sidebar for a handful of destinations.** An app with only a few places to go reads better
|
|
359
|
+
with `.fdy-nav.fdy-nav--horizontal` in the app bar (§6b), and gets the width back.
|
|
360
|
+
|
|
361
|
+
---
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
@namespace Freeday.Blazor
|
|
2
2
|
@inherits FreedayComponentBase<FdyDateRange>
|
|
3
3
|
|
|
4
|
-
@*
|
|
5
|
-
the start).
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
@* Split: two linked seed datepickers (freeday-datepicker.js data-fdy-daterange: the end can't
|
|
5
|
+
precede the start). Both children emit fdy-datepicker-change; the bridge's dateRangeOn tags each
|
|
6
|
+
with its data-role so From/To bind separately.
|
|
7
|
+
Single: ONE seed the enhancer turns into a field holding both dates. It answers once, with the
|
|
8
|
+
whole range, through fdy-daterange-settled.
|
|
9
|
+
Either sits INSIDE Root so initAll(Root) finds it as a descendant. Enhancer-owned DOM → render
|
|
10
|
+
once (ShouldRender => false). *@
|
|
8
11
|
<div @ref="Root">
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
@if (Layout == FdyDateRangeLayout.Single)
|
|
13
|
+
{
|
|
14
|
+
<div @ref="_singleEl" data-fdy-daterange data-layout="single" data-fdy-required="@(Required ? "" : null)"
|
|
15
|
+
data-value="@SeedInterval" data-label="@AriaLabel" data-placeholder="@Placeholder" data-min="@Min" data-max="@Max"
|
|
16
|
+
data-fdy-text-range-start="@RangeStartLabel"
|
|
17
|
+
data-fdy-text-range-end="@RangeEndLabel"
|
|
12
18
|
data-fdy-text-prev-month="@PrevMonthLabel"
|
|
13
19
|
data-fdy-text-next-month="@NextMonthLabel"
|
|
14
20
|
data-fdy-text-prev-year="@PrevYearLabel"
|
|
@@ -18,17 +24,33 @@
|
|
|
18
24
|
data-fdy-text-choose-month="@ChooseMonthLabel"
|
|
19
25
|
data-fdy-text-choose-year="@ChooseYearLabel"
|
|
20
26
|
data-fdy-text-back-to-months="@BackToMonthsLabel"></div>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
}
|
|
28
|
+
else
|
|
29
|
+
{
|
|
30
|
+
<div data-fdy-daterange role="group" aria-label="@AriaLabel">
|
|
31
|
+
<div @ref="_fromEl" data-fdy-datepicker data-role="from" data-fdy-required="@(Required ? "" : null)"
|
|
32
|
+
data-value="@From" data-placeholder="@FromPlaceholder" data-min="@Min" data-max="@Max"
|
|
33
|
+
data-fdy-text-prev-month="@PrevMonthLabel"
|
|
34
|
+
data-fdy-text-next-month="@NextMonthLabel"
|
|
35
|
+
data-fdy-text-prev-year="@PrevYearLabel"
|
|
36
|
+
data-fdy-text-next-year="@NextYearLabel"
|
|
37
|
+
data-fdy-text-prev-years="@PrevYearsLabel"
|
|
38
|
+
data-fdy-text-next-years="@NextYearsLabel"
|
|
39
|
+
data-fdy-text-choose-month="@ChooseMonthLabel"
|
|
40
|
+
data-fdy-text-choose-year="@ChooseYearLabel"
|
|
41
|
+
data-fdy-text-back-to-months="@BackToMonthsLabel"></div>
|
|
42
|
+
<span class="fdy-daterange__sep">@Separator</span>
|
|
43
|
+
<div @ref="_toEl" data-fdy-datepicker data-role="to" data-fdy-required="@(Required ? "" : null)"
|
|
44
|
+
data-value="@To" data-placeholder="@ToPlaceholder" data-min="@Min" data-max="@Max"
|
|
45
|
+
data-fdy-text-prev-month="@PrevMonthLabel"
|
|
46
|
+
data-fdy-text-next-month="@NextMonthLabel"
|
|
47
|
+
data-fdy-text-prev-year="@PrevYearLabel"
|
|
48
|
+
data-fdy-text-next-year="@NextYearLabel"
|
|
49
|
+
data-fdy-text-prev-years="@PrevYearsLabel"
|
|
50
|
+
data-fdy-text-next-years="@NextYearsLabel"
|
|
51
|
+
data-fdy-text-choose-month="@ChooseMonthLabel"
|
|
52
|
+
data-fdy-text-choose-year="@ChooseYearLabel"
|
|
53
|
+
data-fdy-text-back-to-months="@BackToMonthsLabel"></div>
|
|
54
|
+
</div>
|
|
55
|
+
}
|
|
34
56
|
</div>
|
|
@@ -23,6 +23,22 @@ public partial class FdyDateRange
|
|
|
23
23
|
[Parameter] public string? Max { get; set; }
|
|
24
24
|
[Parameter] public string Separator { get; set; } = "–";
|
|
25
25
|
|
|
26
|
+
/// <summary><see cref="FdyDateRangeLayout.Split"/> (default): two pickers.
|
|
27
|
+
/// <see cref="FdyDateRangeLayout.Single"/>: one field holding both dates, whose
|
|
28
|
+
/// <c>From</c>/<c>To</c> change only together, when the range is whole. Read on the first
|
|
29
|
+
/// render, like every other seed this component hands the enhancer.</summary>
|
|
30
|
+
[Parameter] public FdyDateRangeLayout Layout { get; set; }
|
|
31
|
+
|
|
32
|
+
/// <summary>The empty field's text under <see cref="FdyDateRangeLayout.Single"/>. Default
|
|
33
|
+
/// 'Choose dates' (the enhancer's).</summary>
|
|
34
|
+
[Parameter] public string? Placeholder { get; set; }
|
|
35
|
+
|
|
36
|
+
/// <summary>Added to the accessible name of the range's first and last day under
|
|
37
|
+
/// <see cref="FdyDateRangeLayout.Single"/>, so an end is not told by colour alone. Defaults
|
|
38
|
+
/// 'range start' / 'range end'.</summary>
|
|
39
|
+
[Parameter] public string? RangeStartLabel { get; set; }
|
|
40
|
+
[Parameter] public string? RangeEndLabel { get; set; }
|
|
41
|
+
|
|
26
42
|
/* The calendars' own navigation labels, forwarded verbatim to BOTH pickers. Month and weekday
|
|
27
43
|
NAMES follow the page's `lang` through Intl and need nothing here; these are the buttons
|
|
28
44
|
around them. Until now the range was the one picker in the kit whose nav could not be named
|
|
@@ -51,18 +67,35 @@ public partial class FdyDateRange
|
|
|
51
67
|
private int _token;
|
|
52
68
|
private ElementReference _fromEl;
|
|
53
69
|
private ElementReference _toEl;
|
|
70
|
+
private ElementReference _singleEl;
|
|
71
|
+
|
|
72
|
+
/// <summary>"from/to" (ISO 8601 interval), the one <c>data-value</c> the single field reads,
|
|
73
|
+
/// or null while either end is missing: the field never shows half a range.</summary>
|
|
74
|
+
private string? SeedInterval => string.IsNullOrEmpty(From) || string.IsNullOrEmpty(To) ? null : $"{From}/{To}";
|
|
54
75
|
|
|
55
76
|
// initAll(Root) links the daterange (descendant) and inits both child pickers.
|
|
56
77
|
protected override ValueTask HydrateAsync() => JS.InvokeVoidAsync("FreedayDatepicker.initAll", Root);
|
|
57
78
|
|
|
58
79
|
protected override async ValueTask OnHydratedAsync()
|
|
59
|
-
|
|
80
|
+
{
|
|
81
|
+
if (Layout == FdyDateRangeLayout.Single)
|
|
82
|
+
{
|
|
83
|
+
await SubscribeAsync("fdy-daterange-settled", nameof(OnSettled));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
_token = await JS.InvokeAsync<int>("FreedayBlazor.dateRangeOn", Root, Self, nameof(OnChange));
|
|
87
|
+
}
|
|
60
88
|
|
|
61
89
|
protected override bool ShouldRender() => !Hydrated;
|
|
62
90
|
|
|
63
91
|
protected override async Task OnParametersSetAsync()
|
|
64
92
|
{
|
|
65
93
|
if (!Hydrated) return;
|
|
94
|
+
if (Layout == FdyDateRangeLayout.Single)
|
|
95
|
+
{
|
|
96
|
+
await JS.InvokeVoidAsync("FreedayDatepicker.setState", _singleEl, new { required = Required });
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
66
99
|
await JS.InvokeVoidAsync("FreedayDatepicker.setState", _fromEl, new { required = Required });
|
|
67
100
|
await JS.InvokeVoidAsync("FreedayDatepicker.setState", _toEl, new { required = Required });
|
|
68
101
|
}
|
|
@@ -87,6 +120,18 @@ public partial class FdyDateRange
|
|
|
87
120
|
}
|
|
88
121
|
}
|
|
89
122
|
|
|
123
|
+
/// <summary>Invoked by the bridge when the single field commits a whole range. Both ends move
|
|
124
|
+
/// together, so <c>Settled</c> follows every call.</summary>
|
|
125
|
+
[JSInvokable]
|
|
126
|
+
public async Task OnSettled(SettledDetail detail)
|
|
127
|
+
{
|
|
128
|
+
From = detail.From;
|
|
129
|
+
To = detail.To;
|
|
130
|
+
await FromChanged.InvokeAsync(detail.From);
|
|
131
|
+
await ToChanged.InvokeAsync(detail.To);
|
|
132
|
+
await Settled.InvokeAsync(new SettledRange(From, To));
|
|
133
|
+
}
|
|
134
|
+
|
|
90
135
|
protected override async ValueTask CleanupAsync()
|
|
91
136
|
{
|
|
92
137
|
if (_token != 0)
|
|
@@ -97,6 +142,22 @@ public partial class FdyDateRange
|
|
|
97
142
|
|
|
98
143
|
public sealed record RangeDetail(string? Value, string? Role);
|
|
99
144
|
|
|
145
|
+
/// <summary>The detail of <c>fdy-daterange-settled</c>, <c>{ from, to }</c>.</summary>
|
|
146
|
+
public sealed record SettledDetail(string? From, string? To);
|
|
147
|
+
|
|
100
148
|
/// <summary>The range as it stands when it settles; both empty means "no period".</summary>
|
|
101
149
|
public sealed record SettledRange(string? From, string? To);
|
|
102
150
|
}
|
|
151
|
+
|
|
152
|
+
/// <summary>
|
|
153
|
+
/// How <see cref="FdyDateRange"/> lays the range out. The JS adapters take the same idea as the
|
|
154
|
+
/// string union <c>'split' | 'single'</c>; C# gets an enum, as <see cref="FdyNavMode"/> does.
|
|
155
|
+
/// </summary>
|
|
156
|
+
public enum FdyDateRangeLayout
|
|
157
|
+
{
|
|
158
|
+
/// <summary>Two linked pickers, one per end (the default, and what every earlier range was).</summary>
|
|
159
|
+
Split,
|
|
160
|
+
|
|
161
|
+
/// <summary>One field and one calendar: the first day picked is the start, the second the end.</summary>
|
|
162
|
+
Single,
|
|
163
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Types for the single-field date range logic (adapters/core/date-range.js).
|
|
2
|
+
// Shared by the Vue and React FdyDatepicker when FdyDateRange draws its `layout="single"` calendar.
|
|
3
|
+
|
|
4
|
+
/** The committed range, plus a start picked in this opening and the day previewed after it. */
|
|
5
|
+
export interface FdyRangeState {
|
|
6
|
+
start: Date | null;
|
|
7
|
+
end: Date | null;
|
|
8
|
+
/** A start picked and not yet answered by an end. */
|
|
9
|
+
anchor: Date | null;
|
|
10
|
+
/** The day under the pointer or the keyboard while `anchor` waits. */
|
|
11
|
+
preview: Date | null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface FdyShownEnds {
|
|
15
|
+
from: Date | null;
|
|
16
|
+
to: Date | null;
|
|
17
|
+
/** True while a start waits for its end. */
|
|
18
|
+
pending: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface FdyRangeDayState {
|
|
22
|
+
/** An end that is an answer: drawn like a picked day and `aria-selected`. */
|
|
23
|
+
filled: boolean;
|
|
24
|
+
rangeStart: boolean;
|
|
25
|
+
rangeEnd: boolean;
|
|
26
|
+
inRange: boolean;
|
|
27
|
+
/** What the day's accessible name adds. */
|
|
28
|
+
role: 'start' | 'end' | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type FdyRangePick =
|
|
32
|
+
| { kind: 'anchor'; anchor: Date }
|
|
33
|
+
| { kind: 'commit'; start: Date; end: Date };
|
|
34
|
+
|
|
35
|
+
export function shownEnds(range: FdyRangeState): FdyShownEnds;
|
|
36
|
+
export function rangeDayState(day: Date, ends: FdyShownEnds): FdyRangeDayState;
|
|
37
|
+
export function rangeAfterPick(anchor: Date | null, day: Date): FdyRangePick;
|