@cahyo-dimas/freeday 3.16.0 → 3.17.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 +82 -0
- package/COMPONENTS.md +28 -0
- package/README.id.md +1 -1
- package/README.md +1 -1
- package/adapters/blazor/freeday-blazor.js +13 -4
- package/adapters/react/index.d.ts +26 -0
- package/adapters/react/index.js +1 -0
- package/adapters/react/useTheme.js +35 -0
- package/adapters/vue/index.d.ts +26 -0
- package/adapters/vue/index.js +1 -0
- package/adapters/vue/useTheme.js +47 -0
- package/dist/freeday-theme.js +115 -0
- package/dist/freeday.bundle.css +7 -7
- package/dist/freeday.css +7 -7
- package/dist/freeday.js +116 -0
- package/docs/getting-started.md +4 -3
- package/package.json +2 -2
- package/src/components/alert.css +1 -1
- package/src/components/composition.css +2 -2
- package/src/components/file-upload.css +1 -1
- package/src/components/input.css +1 -1
- package/src/components/list.css +1 -1
- package/src/components/states.css +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,88 @@ 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.17.0] - 2026-11-05
|
|
13
|
+
|
|
14
|
+
**Pengalih tema terang/gelap, siap pakai di semua stack.** Setiap app sebelumnya menulis sendiri
|
|
15
|
+
penyimpanan pilihan, pembacaan `prefers-color-scheme`, dan pemasangan `data-theme`, sambil menebak
|
|
16
|
+
kontrak kit dari dokumen (`CATATAN-FREEDAY.md` §23). Catatan itu menyebut Blazor sudah punya.
|
|
17
|
+
Sebenarnya `FreedayBlazor.toggleTheme()` hanya pembantu demo: ia membalik atribut di `<html>`,
|
|
18
|
+
tidak menyimpan apa pun, dan tidak bisa kembali ke "ikuti sistem". Jadi tidak ada satu stack pun
|
|
19
|
+
yang punya.
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
- **`freeday-theme.js` → `window.FreedayTheme`** (`#113`), ikut di `freeday.js`:
|
|
23
|
+
- `get()`, `resolved()`, `set(theme)`, `toggle()`, `attach(el)`, dan event `fdy-theme-change`
|
|
24
|
+
di `document` dengan detail `{ theme, resolved }`.
|
|
25
|
+
- Satu pilihan per perangkat: `'light'`, `'dark'`, atau `'system'`, disimpan di `localStorage`
|
|
26
|
+
dan diterapkan ke `<html>`. Nilai lain ditolak dengan `TypeError`.
|
|
27
|
+
- `'system'` **mencabut** `data-theme`, tidak menghitung nilainya. Token sudah mengikuti OS
|
|
28
|
+
selama tidak ada `data-theme`, jadi pergantian OS langsung terlihat tanpa listener yang
|
|
29
|
+
memutuskan apa pun. Event tetap dikirim supaya ikon tombol ikut berganti.
|
|
30
|
+
- `toggle()` membalik yang **tampil** di layar, bukan pilihannya. Di OS gelap dengan pilihan
|
|
31
|
+
`'system'`, tekan pertama menuju terang.
|
|
32
|
+
- `attach(el)` menyerahkan wilayah yang `data-theme`-nya ditulis tetap di markup kepada pilihan
|
|
33
|
+
pengguna, dan mengembalikan fungsi pelepas. Tanpa itu, atribut subtree selalu menang atas
|
|
34
|
+
atribut dokumen.
|
|
35
|
+
- Pilihan yang tersimpan diterapkan saat dimuat. Kalau tidak ada yang tersimpan, tidak ada yang
|
|
36
|
+
disentuh, jadi markup yang membawa `data-theme` sendiri tetap utuh.
|
|
37
|
+
- **`useTheme(rootRef?)` di Vue dan React**, mengembalikan `theme`, `resolved`, `setTheme`, dan
|
|
38
|
+
`toggleTheme`. Kedua adapter memuat inti yang sama sendiri, jadi tidak perlu impor akar, dan
|
|
39
|
+
inti hanya terdaftar sekali walaupun dimuat dari dua jalur. Semua pemanggil di satu halaman
|
|
40
|
+
tetap sinkron. Ref yang diberikan di-`attach` saat mount dan dilepas saat unmount.
|
|
41
|
+
- **Blazor:** `FreedayBlazor.setTheme`, `getTheme`, dan `getResolvedTheme`. `toggleTheme()` kini
|
|
42
|
+
memakai inti yang sama, jadi ikut menyimpan dan mengenal `'system'`.
|
|
43
|
+
- **Cuplikan satu baris untuk `<head>`** di `COMPONENTS.md`, untuk menerapkan pilihan sebelum paint
|
|
44
|
+
pertama. Gate baru di `test/docs.test.mjs` memastikan cuplikan itu membaca kunci yang ditulis inti,
|
|
45
|
+
dan fixture uji menjalankan cuplikan yang persis sama.
|
|
46
|
+
|
|
47
|
+
### Changed
|
|
48
|
+
- `FreedayBlazor.toggleTheme()` kini **menyimpan** pilihannya di `localStorage` dan membutuhkan
|
|
49
|
+
`freeday.js` sudah dimuat. Tanpa itu ia melempar `Error` yang menyebut berkas yang kurang.
|
|
50
|
+
Sebelumnya ia hanya membalik atribut di `<html>`.
|
|
51
|
+
|
|
52
|
+
### Catatan
|
|
53
|
+
- Uji baru `browser/theme-pref.mjs` (6 uji) memeriksa atribut, nilai tersimpan, dan **warna kartu
|
|
54
|
+
yang benar-benar dicat**, dicocokkan dengan kartu acuan terang dan gelap. Pengaturan OS diemulasi
|
|
55
|
+
sebagai fitur media sungguhan lewat CDP, bukan `matchMedia` palsu. Sembilan mutasi (system
|
|
56
|
+
menghitung nilai, tanpa listener OS, toggle membalik pilihan, tanpa penerapan saat dimuat, root
|
|
57
|
+
diabaikan, tanpa validasi, dan dua adapter tanpa pelepas atau tanpa listener) semuanya merah.
|
|
58
|
+
- Harness mendapat `setColorScheme()`. Event `change` dari `MediaQueryList` dikirim pada langkah
|
|
59
|
+
rendering, dan polling lewat CDP tidak pernah menjalankan langkah itu. Tanpa menunggu dua frame,
|
|
60
|
+
listener tetap diam: terukur tanpa event selama 4 detik polling, lalu satu event sesudah dua
|
|
61
|
+
frame.
|
|
62
|
+
- Gate string `#016` kini juga melewati pesan `throw new …Error(…)`, dengan alasan yang sama seperti
|
|
63
|
+
`console.warn`: teks itu untuk devtools pengembang, tidak pernah masuk DOM.
|
|
64
|
+
- `examples/vue-faktur` berhenti menulis pengalih temanya sendiri dan memakai `useTheme()`.
|
|
65
|
+
- Sinkronisasi antar-tab sengaja tidak dibuat. Tab lain mengikuti pilihan baru saat dimuat ulang.
|
|
66
|
+
|
|
67
|
+
## [3.16.1] - 2026-11-04
|
|
68
|
+
|
|
69
|
+
**Slot teks kit di atas `<p>` tidak lagi membawa margin bawaan peramban.** `<p>` punya margin 1em
|
|
70
|
+
dari peramban, dan kelas yang tidak menolkannya mewarisi jarak yang tidak pernah ditulis siapa pun.
|
|
71
|
+
Ini kelas cacat yang sama dengan `.fdy-eyebrow` di `#010`. Kali ini terbuka saat menulis contoh
|
|
72
|
+
untuk 3.16.0: `p.fdy-help` yang dipakai app (`CATATAN-FREEDAY.md` §22) membawa 12px di atas dan di
|
|
73
|
+
bawah.
|
|
74
|
+
|
|
75
|
+
### Fixed
|
|
76
|
+
- **`margin:0` pada tujuh slot teks** (`#112`): `.fdy-help`, `.fdy-state__text`, `.fdy-alert__text`,
|
|
77
|
+
`.fdy-list__meta`, `.fdy-stat__label`, `.fdy-stat__meta`, dan `.fdy-dropzone__hint`. Diukur di
|
|
78
|
+
Chrome sebelum perbaikan: 12px sampai 16px di tiap sisi. Jarak di antara bagian komponen sudah
|
|
79
|
+
diatur `gap` milik komponennya.
|
|
80
|
+
- **`docs/screen-states.md` sendiri mencontohkan `<p class="fdy-state__text">`** sejak 3.15.0, dan
|
|
81
|
+
kelas itu membawa 14px di tiap sisi. Contoh `docs/index.html` yang memasang `.fdy-state` di
|
|
82
|
+
`<p>` diganti `<div>`, karena state adalah wadah, bukan paragraf.
|
|
83
|
+
|
|
84
|
+
### Catatan
|
|
85
|
+
- Gate `#010` di `test/css.test.mjs` sebelumnya buta di dua tempat. Ia hanya membaca dua dokumen,
|
|
86
|
+
jadi `screen-states.md` dan `docs/index.html` lolos. Kelas tanpa aturan sendiri juga dilewati,
|
|
87
|
+
bukan dihitung gagal. Kini ia membaca setiap dokumen yang dikirim, menilai kelas-kelas satu
|
|
88
|
+
paragraf bersama-sama, dan menjaga ketujuh slot di atas walaupun dokumennya mencontohkan span.
|
|
89
|
+
Mencabut `margin:0` dari salah satunya membuat gate merah.
|
|
90
|
+
- Yang berubah di layar: paragraf dengan kelas-kelas itu kehilangan jarak 12–16px yang tidak
|
|
91
|
+
disengaja. Kelas utilitas warna (`.fdy-text-muted` dan kawan-kawan) sengaja tidak disentuh,
|
|
92
|
+
karena paragraf biasa yang hanya diwarnai tetap butuh jarak paragrafnya.
|
|
93
|
+
|
|
12
94
|
## [3.16.0] - 2026-11-04
|
|
13
95
|
|
|
14
96
|
**Di `.fdy-form-grid`, yang bukan isian adalah baris.** Grid itu `auto-fit`, jadi setiap anak yang
|
package/COMPONENTS.md
CHANGED
|
@@ -126,6 +126,7 @@ element is fine. Events are bubbling
|
|
|
126
126
|
| — (imperative, returns `Promise<boolean>`) | `freeday-confirm.js` | `Freeday.confirm()` | — |
|
|
127
127
|
| — (stamps `<html data-breakpoint>`) | `freeday-breakpoint.js` | `FreedayBreakpoint` | `fdy-breakpoint-change` |
|
|
128
128
|
| — (internal positioning) | `freeday-popover.js` | `FreedayPopover` | — |
|
|
129
|
+
| — (theme preference, see below) | `freeday-theme.js` | `FreedayTheme` | `fdy-theme-change` (on `document`) |
|
|
129
130
|
|
|
130
131
|
**Shared conventions across the select-type widgets** (combo, cascade, datepicker, daterange,
|
|
131
132
|
timepicker, autocomplete, cfl): `data-value` seeds the value, `data-placeholder` the empty text,
|
|
@@ -497,6 +498,33 @@ lightness that a panel four times more transparent still passed. So glass here i
|
|
|
497
498
|
the effect people actually see comes from the blur, not from the alpha. Put a photo or a gradient
|
|
498
499
|
behind a panel and the promise still holds; that is what "over any ground" buys.
|
|
499
500
|
|
|
501
|
+
**Theme preference: `FreedayTheme` / `useTheme()`.** The light/dark switch, ready made. One choice
|
|
502
|
+
per device, `'light'`, `'dark'` or `'system'`, stored in `localStorage` and applied to `<html>`.
|
|
503
|
+
`'system'` removes `data-theme`, so the tokens follow the OS and an OS switch repaints the page
|
|
504
|
+
without a reload.
|
|
505
|
+
|
|
506
|
+
| | Vue / React | Blazor | Anything else |
|
|
507
|
+
|---|---|---|---|
|
|
508
|
+
| read | `useTheme()` → `theme`, `resolved` | `FreedayBlazor.getTheme()`, `getResolvedTheme()` | `FreedayTheme.get()`, `.resolved()` |
|
|
509
|
+
| change | `setTheme(t)`, `toggleTheme()` | `FreedayBlazor.setTheme(t)`, `toggleTheme()` | `FreedayTheme.set(t)`, `.toggle()` |
|
|
510
|
+
|
|
511
|
+
- **Label the button from `resolved`, not `theme`.** `resolved` is what is on screen; `theme` is
|
|
512
|
+
`'system'` until someone chooses. `toggle` flips what is on screen, so the first press always
|
|
513
|
+
changes it.
|
|
514
|
+
- **Every caller shares one preference.** Two toggles in two shells stay in step, through
|
|
515
|
+
`fdy-theme-change` (detail `{ theme, resolved }`).
|
|
516
|
+
- **A region with its own `data-theme` in markup keeps it**, because a subtree's attribute beats the
|
|
517
|
+
document's. To hand it to the preference, pass its ref (`useTheme(regionRef)`) or call
|
|
518
|
+
`FreedayTheme.attach(el)`, which returns a detacher. Under `'system'` that removes the fixed value.
|
|
519
|
+
- `useTheme()` loads the core itself; no `import '@cahyo-dimas/freeday'` is needed for it.
|
|
520
|
+
- **Apply the stored choice before first paint** with this line as the first script in `<head>`.
|
|
521
|
+
Without it the kit still applies the choice once it loads, but the page shows the default for a
|
|
522
|
+
moment first:
|
|
523
|
+
|
|
524
|
+
```html
|
|
525
|
+
<script>try{var t=localStorage.getItem('fdy-theme');if(t==='light'||t==='dark')document.documentElement.setAttribute('data-theme',t)}catch(e){}</script>
|
|
526
|
+
```
|
|
527
|
+
|
|
500
528
|
**Primary palette: `data-primary`.** 18 options — `azure` (the default, and what you get with no
|
|
501
529
|
attribute) · `sky` `blue` `indigo` `violet` `purple` `fuchsia` `pink` `rose` · `orange` `amber`
|
|
502
530
|
`yellow` `lime` `green` `emerald` `teal` `cyan` · `noir`. Set it anywhere `data-theme` works,
|
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.17.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.17.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`.
|
|
@@ -175,14 +175,23 @@
|
|
|
175
175
|
if (element) element.indeterminate = !!value;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
//
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
// The device's theme preference, through the same core Vue and React use (freeday-theme.js, in
|
|
179
|
+
// freeday.js): stored per device, 'system' follows the OS, and every toggle on the page agrees.
|
|
180
|
+
function themeCore() {
|
|
181
|
+
if (!window.FreedayTheme) {
|
|
182
|
+
throw new Error('FreedayBlazor: window.FreedayTheme is missing. Load freeday.js (which includes '
|
|
183
|
+
+ 'freeday-theme.js) before freeday-blazor.js.');
|
|
184
|
+
}
|
|
185
|
+
return window.FreedayTheme;
|
|
182
186
|
}
|
|
187
|
+
function toggleTheme() { themeCore().toggle(); }
|
|
188
|
+
function setTheme(theme) { themeCore().set(theme); }
|
|
189
|
+
function getTheme() { return themeCore().get(); }
|
|
190
|
+
function getResolvedTheme() { return themeCore().resolved(); }
|
|
183
191
|
|
|
184
192
|
window.FreedayBlazor = {
|
|
185
193
|
initAll: initAll, on: on, off: off, onOutside: onOutside, toast: toast, toggleTheme: toggleTheme,
|
|
194
|
+
setTheme: setTheme, getTheme: getTheme, getResolvedTheme: getResolvedTheme,
|
|
186
195
|
comboSetValue: comboSetValue, dateRangeOn: dateRangeOn, chartUpdate: chartUpdate,
|
|
187
196
|
setIndeterminate: setIndeterminate,
|
|
188
197
|
dialogInit: dialogInit, dialogShow: dialogShow, dialogClose: dialogClose, dialogDispose: dialogDispose,
|
|
@@ -13,6 +13,32 @@ export interface UseFreedayReturn {
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function useFreeday(rootRef?: RefObject<HTMLElement | null>): UseFreedayReturn;
|
|
15
15
|
|
|
16
|
+
/** A theme preference. `'system'` removes `data-theme`, so the tokens follow the OS, live. */
|
|
17
|
+
export type FdyTheme = 'light' | 'dark' | 'system';
|
|
18
|
+
/** What is actually on screen once `'system'` is resolved against the OS. */
|
|
19
|
+
export type FdyResolvedTheme = 'light' | 'dark';
|
|
20
|
+
/** `event.detail` of `fdy-theme-change`, fired on `document`. */
|
|
21
|
+
export interface FdyThemeChangeDetail { theme: FdyTheme; resolved: FdyResolvedTheme }
|
|
22
|
+
|
|
23
|
+
export interface UseThemeReturn {
|
|
24
|
+
/** The stored preference, per device; `'system'` until one is chosen. */
|
|
25
|
+
theme: FdyTheme;
|
|
26
|
+
/** The theme on screen. Use it for the toggle's icon and label, not `theme`. */
|
|
27
|
+
resolved: FdyResolvedTheme;
|
|
28
|
+
/** Store and apply a preference. Throws a TypeError for any other value. */
|
|
29
|
+
setTheme: (theme: FdyTheme) => void;
|
|
30
|
+
/** Switch to the opposite of what is on screen, so the first press always changes it. */
|
|
31
|
+
toggleTheme: () => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The device's light/dark preference, applied to `<html>`, kept in `localStorage` and shared by
|
|
36
|
+
* every caller on the page. Pass a ref to also apply it to that element, for a region whose markup
|
|
37
|
+
* fixes its own `data-theme`. Loads the theme core itself: no `import '@cahyo-dimas/freeday'`
|
|
38
|
+
* needed. Apply the stored value before first paint with the `<head>` snippet in COMPONENTS.md.
|
|
39
|
+
*/
|
|
40
|
+
export declare function useTheme(rootRef?: RefObject<HTMLElement | null>): UseThemeReturn;
|
|
41
|
+
|
|
16
42
|
/** `event.detail` shapes for the bubbling `fdy-*` CustomEvents. */
|
|
17
43
|
export interface FdyChangeDetail { value: string }
|
|
18
44
|
export interface FdyAutocompleteSelectDetail { value: string }
|
package/adapters/react/index.js
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* Freeday. React theme preference (CATATAN-FREEDAY §23). A thin view over window.FreedayTheme,
|
|
2
|
+
* which this file loads itself, so it needs no `import 'freeday'` first and a page still has one
|
|
3
|
+
* preference if the root import is there too (the core registers once).
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* const { theme, resolved, setTheme, toggleTheme } = useTheme();
|
|
7
|
+
* // <button onClick={toggleTheme} aria-label={resolved === 'dark' ? 'Light theme' : 'Dark theme'}>
|
|
8
|
+
*
|
|
9
|
+
* Pass a ref to also put the preference on that element, for a region whose markup fixes its own
|
|
10
|
+
* data-theme. Every instance reads the same store through useSyncExternalStore, so two toggles on
|
|
11
|
+
* one page never disagree.
|
|
12
|
+
*/
|
|
13
|
+
import { useEffect, useSyncExternalStore } from 'react';
|
|
14
|
+
import '../../dist/freeday-theme.js';
|
|
15
|
+
|
|
16
|
+
function subscribe(onChange) {
|
|
17
|
+
document.addEventListener('fdy-theme-change', onChange);
|
|
18
|
+
return function () { document.removeEventListener('fdy-theme-change', onChange); };
|
|
19
|
+
}
|
|
20
|
+
function getTheme() { return window.FreedayTheme.get(); }
|
|
21
|
+
function getResolved() { return window.FreedayTheme.resolved(); }
|
|
22
|
+
function serverTheme() { return 'system'; }
|
|
23
|
+
function serverResolved() { return 'light'; }
|
|
24
|
+
function setTheme(next) { window.FreedayTheme.set(next); }
|
|
25
|
+
function toggleTheme() { window.FreedayTheme.toggle(); }
|
|
26
|
+
|
|
27
|
+
export function useTheme(rootRef) {
|
|
28
|
+
var theme = useSyncExternalStore(subscribe, getTheme, serverTheme);
|
|
29
|
+
var resolved = useSyncExternalStore(subscribe, getResolved, serverResolved);
|
|
30
|
+
useEffect(function () {
|
|
31
|
+
if (rootRef && rootRef.current) return window.FreedayTheme.attach(rootRef.current);
|
|
32
|
+
return undefined;
|
|
33
|
+
}, [rootRef]);
|
|
34
|
+
return { theme: theme, resolved: resolved, setTheme: setTheme, toggleTheme: toggleTheme };
|
|
35
|
+
}
|
package/adapters/vue/index.d.ts
CHANGED
|
@@ -13,6 +13,32 @@ export interface UseFreedayReturn {
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function useFreeday(rootRef?: Ref<HTMLElement | null>): UseFreedayReturn;
|
|
15
15
|
|
|
16
|
+
/** A theme preference. `'system'` removes `data-theme`, so the tokens follow the OS, live. */
|
|
17
|
+
export type FdyTheme = 'light' | 'dark' | 'system';
|
|
18
|
+
/** What is actually on screen once `'system'` is resolved against the OS. */
|
|
19
|
+
export type FdyResolvedTheme = 'light' | 'dark';
|
|
20
|
+
/** `event.detail` of `fdy-theme-change`, fired on `document`. */
|
|
21
|
+
export interface FdyThemeChangeDetail { theme: FdyTheme; resolved: FdyResolvedTheme }
|
|
22
|
+
|
|
23
|
+
export interface UseThemeReturn {
|
|
24
|
+
/** The stored preference, per device; `'system'` until one is chosen. */
|
|
25
|
+
theme: Readonly<Ref<FdyTheme>>;
|
|
26
|
+
/** The theme on screen. Use it for the toggle's icon and label, not `theme`. */
|
|
27
|
+
resolved: Readonly<Ref<FdyResolvedTheme>>;
|
|
28
|
+
/** Store and apply a preference. Throws a TypeError for any other value. */
|
|
29
|
+
setTheme: (theme: FdyTheme) => void;
|
|
30
|
+
/** Switch to the opposite of what is on screen, so the first press always changes it. */
|
|
31
|
+
toggleTheme: () => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The device's light/dark preference, applied to `<html>`, kept in `localStorage` and shared by
|
|
36
|
+
* every caller on the page. Pass a ref to also apply it to that element, for a region whose markup
|
|
37
|
+
* fixes its own `data-theme`. Loads the theme core itself: no `import '@cahyo-dimas/freeday'`
|
|
38
|
+
* needed. Apply the stored value before first paint with the `<head>` snippet in COMPONENTS.md.
|
|
39
|
+
*/
|
|
40
|
+
export declare function useTheme(rootRef?: Ref<HTMLElement | null>): UseThemeReturn;
|
|
41
|
+
|
|
16
42
|
/**
|
|
17
43
|
* Which of the panel's edges lines up with the trigger's. `'start'` (the default) puts the panel's
|
|
18
44
|
* LEFT edge on the trigger's left edge, right for an input-shaped dropdown; `'end'` puts its RIGHT
|
package/adapters/vue/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { useFreeday } from './useFreeday.js';
|
|
2
|
+
export { useTheme } from './useTheme.js';
|
|
2
3
|
export { usePopover } from './usePopover.ts';
|
|
3
4
|
export { default as FdyCombo } from './components/FdyCombo.vue';
|
|
4
5
|
export { default as FdyDatepicker } from './components/FdyDatepicker.vue';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* Freeday. Vue 3 theme preference (CATATAN-FREEDAY §23). A thin view over window.FreedayTheme,
|
|
2
|
+
* which this file loads itself, so it needs no `import 'freeday'` first and a page still has one
|
|
3
|
+
* preference if the root import is there too (the core registers once).
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* const { theme, resolved, setTheme, toggleTheme } = useTheme();
|
|
7
|
+
* // <button @click="toggleTheme" :aria-label="resolved === 'dark' ? 'Light theme' : 'Dark theme'">
|
|
8
|
+
*
|
|
9
|
+
* Pass a template ref to also put the preference on that element, for a region whose markup fixes
|
|
10
|
+
* its own data-theme. Every instance stays in step through the core's fdy-theme-change event.
|
|
11
|
+
*/
|
|
12
|
+
import { onBeforeUnmount, onMounted, readonly, ref } from 'vue';
|
|
13
|
+
import '../../dist/freeday-theme.js';
|
|
14
|
+
|
|
15
|
+
function core() {
|
|
16
|
+
return typeof window === 'undefined' ? null : window.FreedayTheme;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function useTheme(rootRef) {
|
|
20
|
+
var api = core();
|
|
21
|
+
var theme = ref(api ? api.get() : 'system');
|
|
22
|
+
var resolved = ref(api ? api.resolved() : 'light');
|
|
23
|
+
var detach = null;
|
|
24
|
+
|
|
25
|
+
function sync(e) {
|
|
26
|
+
theme.value = e.detail.theme;
|
|
27
|
+
resolved.value = e.detail.resolved;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
onMounted(function () {
|
|
31
|
+
if (rootRef && rootRef.value) detach = api.attach(rootRef.value);
|
|
32
|
+
theme.value = api.get();
|
|
33
|
+
resolved.value = api.resolved();
|
|
34
|
+
document.addEventListener('fdy-theme-change', sync);
|
|
35
|
+
});
|
|
36
|
+
onBeforeUnmount(function () {
|
|
37
|
+
document.removeEventListener('fdy-theme-change', sync);
|
|
38
|
+
if (detach) detach();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
theme: readonly(theme),
|
|
43
|
+
resolved: readonly(resolved),
|
|
44
|
+
setTheme: function (next) { core().set(next); },
|
|
45
|
+
toggleTheme: function () { core().toggle(); }
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/* Freeday, theme preference (optional, zero-dependency, no markup of its own).
|
|
2
|
+
* The light/dark switch every app needs and each one used to write for itself, guessing the kit's
|
|
3
|
+
* contract from the docs (CATATAN-FREEDAY §23). One preference per device: 'light', 'dark' or
|
|
4
|
+
* 'system'.
|
|
5
|
+
*
|
|
6
|
+
* 'system' REMOVES data-theme instead of computing one. The tokens already follow
|
|
7
|
+
* prefers-color-scheme whenever no data-theme says otherwise, so the page tracks an OS switch live,
|
|
8
|
+
* with no listener deciding anything.
|
|
9
|
+
*
|
|
10
|
+
* The preference always lands on <html>. attach(el) adds another root that gets it too: a region
|
|
11
|
+
* that carries its own data-theme in markup (a dark kiosk shell inside a light app) would otherwise
|
|
12
|
+
* keep that fixed value, because a subtree's attribute wins over the document's. Attaching hands the
|
|
13
|
+
* region to the user: with the preference at 'system' its fixed value is removed and it follows the
|
|
14
|
+
* OS like the rest of the page.
|
|
15
|
+
*
|
|
16
|
+
* Every change fires "fdy-theme-change" on document, detail {theme, resolved}; so does an OS switch
|
|
17
|
+
* while the preference is 'system', since `resolved` (what is actually shown) moved. The Vue and
|
|
18
|
+
* React useTheme() import this same file, so a page has one preference whichever way it loaded.
|
|
19
|
+
*
|
|
20
|
+
* Only a script in <head> can apply the stored value before the first paint; this file runs too
|
|
21
|
+
* late for that, and catches up on load. COMPONENTS.md has the one-line snippet. Exposes
|
|
22
|
+
* window.FreedayTheme.
|
|
23
|
+
*/
|
|
24
|
+
(function () {
|
|
25
|
+
'use strict';
|
|
26
|
+
if (typeof window === 'undefined' || window.FreedayTheme) return;
|
|
27
|
+
|
|
28
|
+
var KEY = 'fdy-theme';
|
|
29
|
+
var THEMES = ['light', 'dark', 'system'];
|
|
30
|
+
var roots = [];
|
|
31
|
+
var memory = null;
|
|
32
|
+
var media = window.matchMedia ? window.matchMedia('(prefers-color-scheme: dark)') : null;
|
|
33
|
+
|
|
34
|
+
function valid(theme) {
|
|
35
|
+
return THEMES.indexOf(theme) !== -1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Storage can throw (private mode, a blocked origin); the preference then lasts the page. */
|
|
39
|
+
function read() {
|
|
40
|
+
try {
|
|
41
|
+
var stored = window.localStorage.getItem(KEY);
|
|
42
|
+
if (valid(stored)) return stored;
|
|
43
|
+
} catch (e) { /* fall through to the in-memory value */ }
|
|
44
|
+
return memory !== null ? memory : 'system';
|
|
45
|
+
}
|
|
46
|
+
function write(theme) {
|
|
47
|
+
memory = theme;
|
|
48
|
+
try {
|
|
49
|
+
if (theme === 'system') window.localStorage.removeItem(KEY);
|
|
50
|
+
else window.localStorage.setItem(KEY, theme);
|
|
51
|
+
} catch (e) { /* kept in memory only */ }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function applyTo(el, theme) {
|
|
55
|
+
if (theme === 'system') el.removeAttribute('data-theme');
|
|
56
|
+
else el.setAttribute('data-theme', theme);
|
|
57
|
+
}
|
|
58
|
+
function targets() {
|
|
59
|
+
return [document.documentElement].concat(roots);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* What <html> shows: its own attribute if it has one, the OS otherwise. Read from the DOM, not
|
|
63
|
+
from the preference, so markup that ships data-theme="light" before anything is stored is
|
|
64
|
+
reported as light, which is what the user sees. */
|
|
65
|
+
function resolved() {
|
|
66
|
+
var own = document.documentElement.getAttribute('data-theme');
|
|
67
|
+
if (own === 'light' || own === 'dark') return own;
|
|
68
|
+
return media && media.matches ? 'dark' : 'light';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function emit() {
|
|
72
|
+
document.dispatchEvent(new CustomEvent('fdy-theme-change', { detail: { theme: read(), resolved: resolved() } }));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function set(theme) {
|
|
76
|
+
if (!valid(theme)) {
|
|
77
|
+
throw new TypeError('FreedayTheme.set: theme must be one of ' + THEMES.join(', ') + ', got ' + JSON.stringify(theme));
|
|
78
|
+
}
|
|
79
|
+
write(theme);
|
|
80
|
+
targets().forEach(function (el) { applyTo(el, theme); });
|
|
81
|
+
emit();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* Flips what is SHOWN, so the first press always changes the screen, even from 'system'. */
|
|
85
|
+
function toggle() {
|
|
86
|
+
set(resolved() === 'dark' ? 'light' : 'dark');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function attach(el) {
|
|
90
|
+
if (!el || roots.indexOf(el) !== -1) return detacher(el);
|
|
91
|
+
roots.push(el);
|
|
92
|
+
applyTo(el, read());
|
|
93
|
+
return detacher(el);
|
|
94
|
+
}
|
|
95
|
+
function detacher(el) {
|
|
96
|
+
return function () {
|
|
97
|
+
var i = roots.indexOf(el);
|
|
98
|
+
if (i !== -1) roots.splice(i, 1);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* A stored choice is applied on load as well. The <head> snippet does it before first paint;
|
|
103
|
+
without it the page shows the CSS default for a moment, and then still ends up right. Nothing
|
|
104
|
+
stored means nothing is touched, so markup that ships its own data-theme keeps it. */
|
|
105
|
+
var initial = read();
|
|
106
|
+
if (initial !== 'system') applyTo(document.documentElement, initial);
|
|
107
|
+
|
|
108
|
+
if (media) {
|
|
109
|
+
var onOs = function () { if (read() === 'system') emit(); };
|
|
110
|
+
if (media.addEventListener) media.addEventListener('change', onOs);
|
|
111
|
+
else if (media.addListener) media.addListener(onOs);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
window.FreedayTheme = { get: read, resolved: resolved, set: set, toggle: toggle, attach: attach };
|
|
115
|
+
})();
|
package/dist/freeday.bundle.css
CHANGED
|
@@ -1272,7 +1272,7 @@ a { color: var(--color-primary-strong); }
|
|
|
1272
1272
|
.fdy-alert__icon svg{width:100%;height:100%;}
|
|
1273
1273
|
.fdy-alert__body{flex:1;min-width:0;display:flex;flex-direction:column;gap:var(--space-1);}
|
|
1274
1274
|
.fdy-alert__title{font-size:inherit;font-weight:var(--weight-semibold);color:var(--color-text);margin:0;}
|
|
1275
|
-
.fdy-alert__text{color:var(--color-text);line-height:var(--leading-normal);}
|
|
1275
|
+
.fdy-alert__text{margin:0;color:var(--color-text);line-height:var(--leading-normal);}
|
|
1276
1276
|
.fdy-alert__close{flex:none;align-self:flex-start;border:0;background:transparent;color:var(--color-text-muted);cursor:pointer;font-size:var(--text-lg);line-height:1;padding:0 var(--space-1);border-radius:var(--radius-sm);}
|
|
1277
1277
|
.fdy-alert__close:hover{color:var(--color-text);}
|
|
1278
1278
|
.fdy-alert__close:focus-visible{outline:none;box-shadow:0 0 0 3px rgba(var(--color-primary-rgb),.26);}
|
|
@@ -2296,10 +2296,10 @@ a { color: var(--color-primary-strong); }
|
|
|
2296
2296
|
/* --color-text-muted, not -subtle: this is a LABEL, i.e. text, and -subtle is deliberately gated at
|
|
2297
2297
|
3.0 (placeholders, dividers, decorative glyphs). On surface-2 -subtle measures 4.41, under AA
|
|
2298
2298
|
for text, and a stat label is often the only thing naming the number above it. */
|
|
2299
|
-
.fdy-stat__label{font-size:var(--text-xs);font-weight:var(--weight-semibold);letter-spacing:var(--tracking-wide);text-transform:uppercase;color:var(--color-text-muted);}
|
|
2299
|
+
.fdy-stat__label{margin:0;font-size:var(--text-xs);font-weight:var(--weight-semibold);letter-spacing:var(--tracking-wide);text-transform:uppercase;color:var(--color-text-muted);}
|
|
2300
2300
|
.fdy-stat__value{font-family:var(--font-display);font-size:var(--text-3xl);font-weight:var(--weight-bold);letter-spacing:var(--tracking-tighter);line-height:1;color:var(--color-text);font-variant-numeric:tabular-nums;}
|
|
2301
2301
|
.fdy-stat__value small{font-size:var(--text-lg);font-weight:var(--weight-semibold);color:var(--color-text-muted);}
|
|
2302
|
-
.fdy-stat__meta{font-size:var(--text-sm);color:var(--color-text-muted);display:flex;align-items:center;gap:var(--space-2);}
|
|
2302
|
+
.fdy-stat__meta{margin:0;font-size:var(--text-sm);color:var(--color-text-muted);display:flex;align-items:center;gap:var(--space-2);}
|
|
2303
2303
|
/* A stat value is display type sized for a COUNT, "1,284", and a back office puts money in it.
|
|
2304
2304
|
"IDR 300,000.00" needs 224px at --text-3xl and the grid's own track is 11rem, so it wrapped
|
|
2305
2305
|
between the currency and the number: two lines of 31px where the design says one. Measured, not
|
|
@@ -2532,7 +2532,7 @@ a { color: var(--color-primary-strong); }
|
|
|
2532
2532
|
.fdy-dropzone.is-dragover .fdy-dropzone__icon{color:var(--color-primary-strong);}
|
|
2533
2533
|
.fdy-dropzone__icon svg{display:block;width:2rem;height:2rem;}
|
|
2534
2534
|
.fdy-dropzone__title{font-size:inherit;font-weight:var(--weight-medium);color:var(--color-text);margin:0;}
|
|
2535
|
-
.fdy-dropzone__hint{font-size:var(--text-xs);}
|
|
2535
|
+
.fdy-dropzone__hint{margin:0;font-size:var(--text-xs);}
|
|
2536
2536
|
/* Wide (horizontal) layout, icon beside the copy instead of stacked, for full-width
|
|
2537
2537
|
* sections. Wrap the title + hint in .fdy-dropzone__text. */
|
|
2538
2538
|
.fdy-dropzone--row{flex-direction:row;align-items:center;justify-content:center;text-align:left;gap:var(--space-4);}
|
|
@@ -2729,7 +2729,7 @@ fieldset.fdy-field>legend{padding:0;float:none;margin-bottom:var(--space-2);}
|
|
|
2729
2729
|
screen reader does not read "star" after every label. That is stricter than a <span> an app has to
|
|
2730
2730
|
remember to mark aria-hidden, and it cannot be forgotten. */
|
|
2731
2731
|
.fdy-label--required::after{content:"*" / "";margin-left:var(--space-1);color:var(--color-danger);}
|
|
2732
|
-
.fdy-help{font-size:var(--text-xs);color:var(--color-text-muted);}
|
|
2732
|
+
.fdy-help{margin:0;font-size:var(--text-xs);color:var(--color-text-muted);}
|
|
2733
2733
|
/* --danger is the tone word everywhere else in the kit; help text takes either (CATATAN-FREEDAY §11). */
|
|
2734
2734
|
.fdy-help--error,.fdy-help--danger{color:var(--color-danger);}
|
|
2735
2735
|
|
|
@@ -2776,7 +2776,7 @@ fieldset.fdy-field>legend{padding:0;float:none;margin-bottom:var(--space-2);}
|
|
|
2776
2776
|
/* Row internals: a title/meta stack that truncates, and a trailing slot pinned right. */
|
|
2777
2777
|
.fdy-list__main{display:flex;flex-direction:column;gap:var(--space-1);min-width:0;flex:1;}
|
|
2778
2778
|
.fdy-list__title{font-family:var(--font-body);font-size:var(--text-base);font-weight:var(--weight-medium);letter-spacing:normal;color:var(--color-text);margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
|
2779
|
-
.fdy-list__meta{font-size:var(--text-sm);color:var(--color-text-muted);display:flex;align-items:center;gap:var(--space-2);flex-wrap:wrap;}
|
|
2779
|
+
.fdy-list__meta{margin:0;font-size:var(--text-sm);color:var(--color-text-muted);display:flex;align-items:center;gap:var(--space-2);flex-wrap:wrap;}
|
|
2780
2780
|
.fdy-list__aside{flex:none;display:flex;align-items:center;gap:var(--space-2);}
|
|
2781
2781
|
/* Density: rows tighten with the rest of the kit (--space-* mid-range steps under compact). */
|
|
2782
2782
|
|
|
@@ -2973,7 +2973,7 @@ fieldset.fdy-field>legend{padding:0;float:none;margin-bottom:var(--space-2);}
|
|
|
2973
2973
|
.fdy-state__icon{display:inline-flex;align-items:center;justify-content:center;width:2.5rem;height:2.5rem;color:var(--color-text-subtle);}
|
|
2974
2974
|
.fdy-state__icon svg{width:100%;height:100%;}
|
|
2975
2975
|
.fdy-state__title{font-family:var(--font-display);font-size:var(--text-lg);font-weight:var(--weight-semibold);color:var(--color-text);margin:0;}
|
|
2976
|
-
.fdy-state__text{font-size:var(--text-sm);color:var(--color-text-muted);max-width:24rem;line-height:var(--leading-normal);}
|
|
2976
|
+
.fdy-state__text{margin:0;font-size:var(--text-sm);color:var(--color-text-muted);max-width:24rem;line-height:var(--leading-normal);}
|
|
2977
2977
|
.fdy-state__actions{margin-top:var(--space-2);display:flex;gap:var(--space-2);flex-wrap:wrap;justify-content:center;}
|
|
2978
2978
|
.fdy-state--danger .fdy-state__icon{color:var(--color-danger-strong);}
|
|
2979
2979
|
/* Compact (#069): the same state inside a small card, one line of icon and text instead of a
|
package/dist/freeday.css
CHANGED
|
@@ -95,7 +95,7 @@ a { color: var(--color-primary-strong); }
|
|
|
95
95
|
.fdy-alert__icon svg{width:100%;height:100%;}
|
|
96
96
|
.fdy-alert__body{flex:1;min-width:0;display:flex;flex-direction:column;gap:var(--space-1);}
|
|
97
97
|
.fdy-alert__title{font-size:inherit;font-weight:var(--weight-semibold);color:var(--color-text);margin:0;}
|
|
98
|
-
.fdy-alert__text{color:var(--color-text);line-height:var(--leading-normal);}
|
|
98
|
+
.fdy-alert__text{margin:0;color:var(--color-text);line-height:var(--leading-normal);}
|
|
99
99
|
.fdy-alert__close{flex:none;align-self:flex-start;border:0;background:transparent;color:var(--color-text-muted);cursor:pointer;font-size:var(--text-lg);line-height:1;padding:0 var(--space-1);border-radius:var(--radius-sm);}
|
|
100
100
|
.fdy-alert__close:hover{color:var(--color-text);}
|
|
101
101
|
.fdy-alert__close:focus-visible{outline:none;box-shadow:0 0 0 3px rgba(var(--color-primary-rgb),.26);}
|
|
@@ -1119,10 +1119,10 @@ a { color: var(--color-primary-strong); }
|
|
|
1119
1119
|
/* --color-text-muted, not -subtle: this is a LABEL, i.e. text, and -subtle is deliberately gated at
|
|
1120
1120
|
3.0 (placeholders, dividers, decorative glyphs). On surface-2 -subtle measures 4.41, under AA
|
|
1121
1121
|
for text, and a stat label is often the only thing naming the number above it. */
|
|
1122
|
-
.fdy-stat__label{font-size:var(--text-xs);font-weight:var(--weight-semibold);letter-spacing:var(--tracking-wide);text-transform:uppercase;color:var(--color-text-muted);}
|
|
1122
|
+
.fdy-stat__label{margin:0;font-size:var(--text-xs);font-weight:var(--weight-semibold);letter-spacing:var(--tracking-wide);text-transform:uppercase;color:var(--color-text-muted);}
|
|
1123
1123
|
.fdy-stat__value{font-family:var(--font-display);font-size:var(--text-3xl);font-weight:var(--weight-bold);letter-spacing:var(--tracking-tighter);line-height:1;color:var(--color-text);font-variant-numeric:tabular-nums;}
|
|
1124
1124
|
.fdy-stat__value small{font-size:var(--text-lg);font-weight:var(--weight-semibold);color:var(--color-text-muted);}
|
|
1125
|
-
.fdy-stat__meta{font-size:var(--text-sm);color:var(--color-text-muted);display:flex;align-items:center;gap:var(--space-2);}
|
|
1125
|
+
.fdy-stat__meta{margin:0;font-size:var(--text-sm);color:var(--color-text-muted);display:flex;align-items:center;gap:var(--space-2);}
|
|
1126
1126
|
/* A stat value is display type sized for a COUNT, "1,284", and a back office puts money in it.
|
|
1127
1127
|
"IDR 300,000.00" needs 224px at --text-3xl and the grid's own track is 11rem, so it wrapped
|
|
1128
1128
|
between the currency and the number: two lines of 31px where the design says one. Measured, not
|
|
@@ -1355,7 +1355,7 @@ a { color: var(--color-primary-strong); }
|
|
|
1355
1355
|
.fdy-dropzone.is-dragover .fdy-dropzone__icon{color:var(--color-primary-strong);}
|
|
1356
1356
|
.fdy-dropzone__icon svg{display:block;width:2rem;height:2rem;}
|
|
1357
1357
|
.fdy-dropzone__title{font-size:inherit;font-weight:var(--weight-medium);color:var(--color-text);margin:0;}
|
|
1358
|
-
.fdy-dropzone__hint{font-size:var(--text-xs);}
|
|
1358
|
+
.fdy-dropzone__hint{margin:0;font-size:var(--text-xs);}
|
|
1359
1359
|
/* Wide (horizontal) layout, icon beside the copy instead of stacked, for full-width
|
|
1360
1360
|
* sections. Wrap the title + hint in .fdy-dropzone__text. */
|
|
1361
1361
|
.fdy-dropzone--row{flex-direction:row;align-items:center;justify-content:center;text-align:left;gap:var(--space-4);}
|
|
@@ -1552,7 +1552,7 @@ fieldset.fdy-field>legend{padding:0;float:none;margin-bottom:var(--space-2);}
|
|
|
1552
1552
|
screen reader does not read "star" after every label. That is stricter than a <span> an app has to
|
|
1553
1553
|
remember to mark aria-hidden, and it cannot be forgotten. */
|
|
1554
1554
|
.fdy-label--required::after{content:"*" / "";margin-left:var(--space-1);color:var(--color-danger);}
|
|
1555
|
-
.fdy-help{font-size:var(--text-xs);color:var(--color-text-muted);}
|
|
1555
|
+
.fdy-help{margin:0;font-size:var(--text-xs);color:var(--color-text-muted);}
|
|
1556
1556
|
/* --danger is the tone word everywhere else in the kit; help text takes either (CATATAN-FREEDAY §11). */
|
|
1557
1557
|
.fdy-help--error,.fdy-help--danger{color:var(--color-danger);}
|
|
1558
1558
|
|
|
@@ -1599,7 +1599,7 @@ fieldset.fdy-field>legend{padding:0;float:none;margin-bottom:var(--space-2);}
|
|
|
1599
1599
|
/* Row internals: a title/meta stack that truncates, and a trailing slot pinned right. */
|
|
1600
1600
|
.fdy-list__main{display:flex;flex-direction:column;gap:var(--space-1);min-width:0;flex:1;}
|
|
1601
1601
|
.fdy-list__title{font-family:var(--font-body);font-size:var(--text-base);font-weight:var(--weight-medium);letter-spacing:normal;color:var(--color-text);margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
|
1602
|
-
.fdy-list__meta{font-size:var(--text-sm);color:var(--color-text-muted);display:flex;align-items:center;gap:var(--space-2);flex-wrap:wrap;}
|
|
1602
|
+
.fdy-list__meta{margin:0;font-size:var(--text-sm);color:var(--color-text-muted);display:flex;align-items:center;gap:var(--space-2);flex-wrap:wrap;}
|
|
1603
1603
|
.fdy-list__aside{flex:none;display:flex;align-items:center;gap:var(--space-2);}
|
|
1604
1604
|
/* Density: rows tighten with the rest of the kit (--space-* mid-range steps under compact). */
|
|
1605
1605
|
|
|
@@ -1796,7 +1796,7 @@ fieldset.fdy-field>legend{padding:0;float:none;margin-bottom:var(--space-2);}
|
|
|
1796
1796
|
.fdy-state__icon{display:inline-flex;align-items:center;justify-content:center;width:2.5rem;height:2.5rem;color:var(--color-text-subtle);}
|
|
1797
1797
|
.fdy-state__icon svg{width:100%;height:100%;}
|
|
1798
1798
|
.fdy-state__title{font-family:var(--font-display);font-size:var(--text-lg);font-weight:var(--weight-semibold);color:var(--color-text);margin:0;}
|
|
1799
|
-
.fdy-state__text{font-size:var(--text-sm);color:var(--color-text-muted);max-width:24rem;line-height:var(--leading-normal);}
|
|
1799
|
+
.fdy-state__text{margin:0;font-size:var(--text-sm);color:var(--color-text-muted);max-width:24rem;line-height:var(--leading-normal);}
|
|
1800
1800
|
.fdy-state__actions{margin-top:var(--space-2);display:flex;gap:var(--space-2);flex-wrap:wrap;justify-content:center;}
|
|
1801
1801
|
.fdy-state--danger .fdy-state__icon{color:var(--color-danger-strong);}
|
|
1802
1802
|
/* Compact (#069): the same state inside a small card, one line of icon and text instead of a
|
package/dist/freeday.js
CHANGED
|
@@ -5221,6 +5221,122 @@
|
|
|
5221
5221
|
window.FreedayTabs = { init: initTabs, initAll: initAll };
|
|
5222
5222
|
})();
|
|
5223
5223
|
|
|
5224
|
+
/* Freeday, theme preference (optional, zero-dependency, no markup of its own).
|
|
5225
|
+
* The light/dark switch every app needs and each one used to write for itself, guessing the kit's
|
|
5226
|
+
* contract from the docs (CATATAN-FREEDAY §23). One preference per device: 'light', 'dark' or
|
|
5227
|
+
* 'system'.
|
|
5228
|
+
*
|
|
5229
|
+
* 'system' REMOVES data-theme instead of computing one. The tokens already follow
|
|
5230
|
+
* prefers-color-scheme whenever no data-theme says otherwise, so the page tracks an OS switch live,
|
|
5231
|
+
* with no listener deciding anything.
|
|
5232
|
+
*
|
|
5233
|
+
* The preference always lands on <html>. attach(el) adds another root that gets it too: a region
|
|
5234
|
+
* that carries its own data-theme in markup (a dark kiosk shell inside a light app) would otherwise
|
|
5235
|
+
* keep that fixed value, because a subtree's attribute wins over the document's. Attaching hands the
|
|
5236
|
+
* region to the user: with the preference at 'system' its fixed value is removed and it follows the
|
|
5237
|
+
* OS like the rest of the page.
|
|
5238
|
+
*
|
|
5239
|
+
* Every change fires "fdy-theme-change" on document, detail {theme, resolved}; so does an OS switch
|
|
5240
|
+
* while the preference is 'system', since `resolved` (what is actually shown) moved. The Vue and
|
|
5241
|
+
* React useTheme() import this same file, so a page has one preference whichever way it loaded.
|
|
5242
|
+
*
|
|
5243
|
+
* Only a script in <head> can apply the stored value before the first paint; this file runs too
|
|
5244
|
+
* late for that, and catches up on load. COMPONENTS.md has the one-line snippet. Exposes
|
|
5245
|
+
* window.FreedayTheme.
|
|
5246
|
+
*/
|
|
5247
|
+
(function () {
|
|
5248
|
+
'use strict';
|
|
5249
|
+
if (typeof window === 'undefined' || window.FreedayTheme) return;
|
|
5250
|
+
|
|
5251
|
+
var KEY = 'fdy-theme';
|
|
5252
|
+
var THEMES = ['light', 'dark', 'system'];
|
|
5253
|
+
var roots = [];
|
|
5254
|
+
var memory = null;
|
|
5255
|
+
var media = window.matchMedia ? window.matchMedia('(prefers-color-scheme: dark)') : null;
|
|
5256
|
+
|
|
5257
|
+
function valid(theme) {
|
|
5258
|
+
return THEMES.indexOf(theme) !== -1;
|
|
5259
|
+
}
|
|
5260
|
+
|
|
5261
|
+
/* Storage can throw (private mode, a blocked origin); the preference then lasts the page. */
|
|
5262
|
+
function read() {
|
|
5263
|
+
try {
|
|
5264
|
+
var stored = window.localStorage.getItem(KEY);
|
|
5265
|
+
if (valid(stored)) return stored;
|
|
5266
|
+
} catch (e) { /* fall through to the in-memory value */ }
|
|
5267
|
+
return memory !== null ? memory : 'system';
|
|
5268
|
+
}
|
|
5269
|
+
function write(theme) {
|
|
5270
|
+
memory = theme;
|
|
5271
|
+
try {
|
|
5272
|
+
if (theme === 'system') window.localStorage.removeItem(KEY);
|
|
5273
|
+
else window.localStorage.setItem(KEY, theme);
|
|
5274
|
+
} catch (e) { /* kept in memory only */ }
|
|
5275
|
+
}
|
|
5276
|
+
|
|
5277
|
+
function applyTo(el, theme) {
|
|
5278
|
+
if (theme === 'system') el.removeAttribute('data-theme');
|
|
5279
|
+
else el.setAttribute('data-theme', theme);
|
|
5280
|
+
}
|
|
5281
|
+
function targets() {
|
|
5282
|
+
return [document.documentElement].concat(roots);
|
|
5283
|
+
}
|
|
5284
|
+
|
|
5285
|
+
/* What <html> shows: its own attribute if it has one, the OS otherwise. Read from the DOM, not
|
|
5286
|
+
from the preference, so markup that ships data-theme="light" before anything is stored is
|
|
5287
|
+
reported as light, which is what the user sees. */
|
|
5288
|
+
function resolved() {
|
|
5289
|
+
var own = document.documentElement.getAttribute('data-theme');
|
|
5290
|
+
if (own === 'light' || own === 'dark') return own;
|
|
5291
|
+
return media && media.matches ? 'dark' : 'light';
|
|
5292
|
+
}
|
|
5293
|
+
|
|
5294
|
+
function emit() {
|
|
5295
|
+
document.dispatchEvent(new CustomEvent('fdy-theme-change', { detail: { theme: read(), resolved: resolved() } }));
|
|
5296
|
+
}
|
|
5297
|
+
|
|
5298
|
+
function set(theme) {
|
|
5299
|
+
if (!valid(theme)) {
|
|
5300
|
+
throw new TypeError('FreedayTheme.set: theme must be one of ' + THEMES.join(', ') + ', got ' + JSON.stringify(theme));
|
|
5301
|
+
}
|
|
5302
|
+
write(theme);
|
|
5303
|
+
targets().forEach(function (el) { applyTo(el, theme); });
|
|
5304
|
+
emit();
|
|
5305
|
+
}
|
|
5306
|
+
|
|
5307
|
+
/* Flips what is SHOWN, so the first press always changes the screen, even from 'system'. */
|
|
5308
|
+
function toggle() {
|
|
5309
|
+
set(resolved() === 'dark' ? 'light' : 'dark');
|
|
5310
|
+
}
|
|
5311
|
+
|
|
5312
|
+
function attach(el) {
|
|
5313
|
+
if (!el || roots.indexOf(el) !== -1) return detacher(el);
|
|
5314
|
+
roots.push(el);
|
|
5315
|
+
applyTo(el, read());
|
|
5316
|
+
return detacher(el);
|
|
5317
|
+
}
|
|
5318
|
+
function detacher(el) {
|
|
5319
|
+
return function () {
|
|
5320
|
+
var i = roots.indexOf(el);
|
|
5321
|
+
if (i !== -1) roots.splice(i, 1);
|
|
5322
|
+
};
|
|
5323
|
+
}
|
|
5324
|
+
|
|
5325
|
+
/* A stored choice is applied on load as well. The <head> snippet does it before first paint;
|
|
5326
|
+
without it the page shows the CSS default for a moment, and then still ends up right. Nothing
|
|
5327
|
+
stored means nothing is touched, so markup that ships its own data-theme keeps it. */
|
|
5328
|
+
var initial = read();
|
|
5329
|
+
if (initial !== 'system') applyTo(document.documentElement, initial);
|
|
5330
|
+
|
|
5331
|
+
if (media) {
|
|
5332
|
+
var onOs = function () { if (read() === 'system') emit(); };
|
|
5333
|
+
if (media.addEventListener) media.addEventListener('change', onOs);
|
|
5334
|
+
else if (media.addListener) media.addListener(onOs);
|
|
5335
|
+
}
|
|
5336
|
+
|
|
5337
|
+
window.FreedayTheme = { get: read, resolved: resolved, set: set, toggle: toggle, attach: attach };
|
|
5338
|
+
})();
|
|
5339
|
+
|
|
5224
5340
|
/* Freeday, time picker enhancer (optional, zero-dependency).
|
|
5225
5341
|
* Builds an input-styled trigger + scrollable time-list popover (WAI-ARIA listbox)
|
|
5226
5342
|
* from an empty [data-fdy-timepicker] wrapper. 24h HH:MM. Options run from
|
package/docs/getting-started.md
CHANGED
|
@@ -198,7 +198,7 @@ live docs also have a copy button per component.
|
|
|
198
198
|
```bash
|
|
199
199
|
npm i @cahyo-dimas/freeday
|
|
200
200
|
```
|
|
201
|
-
Lands in `package.json` as `"@cahyo-dimas/freeday": "^3.
|
|
201
|
+
Lands in `package.json` as `"@cahyo-dimas/freeday": "^3.17.0"` (public npm package). `dist/` is
|
|
202
202
|
committed and published → no build step; `npm ci` runs without auth.
|
|
203
203
|
|
|
204
204
|
### 2. Import the CSS + enhancers **once** in your entry (`src/main.ts`)
|
|
@@ -424,8 +424,9 @@ public partial class Panel : ComponentBase, IAsyncDisposable
|
|
|
424
424
|
<div data-fdy-datepicker></div>
|
|
425
425
|
</div>
|
|
426
426
|
```
|
|
427
|
-
Extras: `FreedayBlazor.toast(new { variant, title, message })` for toasts; `FreedayBlazor.toggleTheme()
|
|
428
|
-
|
|
427
|
+
Extras: `FreedayBlazor.toast(new { variant, title, message })` for toasts; `FreedayBlazor.toggleTheme()`,
|
|
428
|
+
`setTheme("light" | "dark" | "system")`, `getTheme()` and `getResolvedTheme()` for the stored theme
|
|
429
|
+
preference (COMPONENTS.md, "Theme preference"). Event DTOs are deserialized case-insensitively by Blazor.
|
|
429
430
|
|
|
430
431
|
### 4. Recommended: native typed components (`Freeday.Blazor` RCL)
|
|
431
432
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cahyo-dimas/freeday",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.17.0",
|
|
4
4
|
"description": "Freeday: token-driven, framework-agnostic UI KIT (design source-of-truth).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"scripts": {
|
|
98
98
|
"build": "node tokens/build.mjs",
|
|
99
99
|
"test": "node --test",
|
|
100
|
-
"test:browser": "node --test --test-concurrency=3 browser/color-mix.mjs browser/vanilla.mjs browser/adapter.mjs browser/layout.mjs browser/theme.mjs browser/state.mjs browser/root-init.mjs browser/upload-states.mjs browser/number.mjs browser/card-stretch.mjs browser/stretch-warn.mjs browser/hidden-attr.mjs browser/form-grid-rows.mjs browser/text-override.mjs browser/control-heights.mjs browser/field-width.mjs browser/cfl-multi.mjs browser/cfl-dialog-only.mjs browser/crowding.mjs browser/over-dialog.mjs browser/chart-scale.mjs browser/overlay-stack.mjs browser/chart-a11y.mjs browser/app-shell.mjs browser/bottom-nav.mjs browser/picker-states.mjs browser/tabs-strip.mjs browser/tabs-vertical.mjs browser/menu-align.mjs browser/cfl-narrow.mjs browser/form-reveal.mjs browser/confirm-search-copy.mjs browser/daterange-settled.mjs browser/display-parts.mjs browser/table-empty.mjs browser/table-footer-text.mjs browser/month-mode.mjs browser/monthpicker.mjs browser/page-columns.mjs browser/table-hover.mjs browser/typed-popover.mjs browser/filter-parity.mjs browser/filter-wrap.mjs browser/filter-stack.mjs browser/timepicker.mjs browser/form-kit-required.mjs browser/picker-in-modal.mjs browser/harness-contract.mjs browser/app-owned.mjs browser/sortable.mjs browser/modal-phone.mjs browser/empty-ref.mjs browser/stack-standalone.mjs",
|
|
100
|
+
"test:browser": "node --test --test-concurrency=3 browser/color-mix.mjs browser/vanilla.mjs browser/adapter.mjs browser/layout.mjs browser/theme.mjs browser/state.mjs browser/root-init.mjs browser/upload-states.mjs browser/number.mjs browser/card-stretch.mjs browser/stretch-warn.mjs browser/hidden-attr.mjs browser/form-grid-rows.mjs browser/theme-pref.mjs browser/text-override.mjs browser/control-heights.mjs browser/field-width.mjs browser/cfl-multi.mjs browser/cfl-dialog-only.mjs browser/crowding.mjs browser/over-dialog.mjs browser/chart-scale.mjs browser/overlay-stack.mjs browser/chart-a11y.mjs browser/app-shell.mjs browser/bottom-nav.mjs browser/picker-states.mjs browser/tabs-strip.mjs browser/tabs-vertical.mjs browser/menu-align.mjs browser/cfl-narrow.mjs browser/form-reveal.mjs browser/confirm-search-copy.mjs browser/daterange-settled.mjs browser/display-parts.mjs browser/table-empty.mjs browser/table-footer-text.mjs browser/month-mode.mjs browser/monthpicker.mjs browser/page-columns.mjs browser/table-hover.mjs browser/typed-popover.mjs browser/filter-parity.mjs browser/filter-wrap.mjs browser/filter-stack.mjs browser/timepicker.mjs browser/form-kit-required.mjs browser/picker-in-modal.mjs browser/harness-contract.mjs browser/app-owned.mjs browser/sortable.mjs browser/modal-phone.mjs browser/empty-ref.mjs browser/stack-standalone.mjs",
|
|
101
101
|
"prepack": "node tokens/build.mjs",
|
|
102
102
|
"version": "node tokens/build.mjs && git add dist",
|
|
103
103
|
"typecheck:react": "tsc -p adapters/react/tsconfig.json --noEmit",
|
package/src/components/alert.css
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
.fdy-alert__icon svg{width:100%;height:100%;}
|
|
5
5
|
.fdy-alert__body{flex:1;min-width:0;display:flex;flex-direction:column;gap:var(--space-1);}
|
|
6
6
|
.fdy-alert__title{font-size:inherit;font-weight:var(--weight-semibold);color:var(--color-text);margin:0;}
|
|
7
|
-
.fdy-alert__text{color:var(--color-text);line-height:var(--leading-normal);}
|
|
7
|
+
.fdy-alert__text{margin:0;color:var(--color-text);line-height:var(--leading-normal);}
|
|
8
8
|
.fdy-alert__close{flex:none;align-self:flex-start;border:0;background:transparent;color:var(--color-text-muted);cursor:pointer;font-size:var(--text-lg);line-height:1;padding:0 var(--space-1);border-radius:var(--radius-sm);}
|
|
9
9
|
.fdy-alert__close:hover{color:var(--color-text);}
|
|
10
10
|
.fdy-alert__close:focus-visible{outline:none;box-shadow:0 0 0 3px rgba(var(--color-primary-rgb),.26);}
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
/* --color-text-muted, not -subtle: this is a LABEL, i.e. text, and -subtle is deliberately gated at
|
|
48
48
|
3.0 (placeholders, dividers, decorative glyphs). On surface-2 -subtle measures 4.41, under AA
|
|
49
49
|
for text, and a stat label is often the only thing naming the number above it. */
|
|
50
|
-
.fdy-stat__label{font-size:var(--text-xs);font-weight:var(--weight-semibold);letter-spacing:var(--tracking-wide);text-transform:uppercase;color:var(--color-text-muted);}
|
|
50
|
+
.fdy-stat__label{margin:0;font-size:var(--text-xs);font-weight:var(--weight-semibold);letter-spacing:var(--tracking-wide);text-transform:uppercase;color:var(--color-text-muted);}
|
|
51
51
|
.fdy-stat__value{font-family:var(--font-display);font-size:var(--text-3xl);font-weight:var(--weight-bold);letter-spacing:var(--tracking-tighter);line-height:1;color:var(--color-text);font-variant-numeric:tabular-nums;}
|
|
52
52
|
.fdy-stat__value small{font-size:var(--text-lg);font-weight:var(--weight-semibold);color:var(--color-text-muted);}
|
|
53
|
-
.fdy-stat__meta{font-size:var(--text-sm);color:var(--color-text-muted);display:flex;align-items:center;gap:var(--space-2);}
|
|
53
|
+
.fdy-stat__meta{margin:0;font-size:var(--text-sm);color:var(--color-text-muted);display:flex;align-items:center;gap:var(--space-2);}
|
|
54
54
|
/* A stat value is display type sized for a COUNT, "1,284", and a back office puts money in it.
|
|
55
55
|
"IDR 300,000.00" needs 224px at --text-3xl and the grid's own track is 11rem, so it wrapped
|
|
56
56
|
between the currency and the number: two lines of 31px where the design says one. Measured, not
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
.fdy-dropzone.is-dragover .fdy-dropzone__icon{color:var(--color-primary-strong);}
|
|
10
10
|
.fdy-dropzone__icon svg{display:block;width:2rem;height:2rem;}
|
|
11
11
|
.fdy-dropzone__title{font-size:inherit;font-weight:var(--weight-medium);color:var(--color-text);margin:0;}
|
|
12
|
-
.fdy-dropzone__hint{font-size:var(--text-xs);}
|
|
12
|
+
.fdy-dropzone__hint{margin:0;font-size:var(--text-xs);}
|
|
13
13
|
/* Wide (horizontal) layout, icon beside the copy instead of stacked, for full-width
|
|
14
14
|
* sections. Wrap the title + hint in .fdy-dropzone__text. */
|
|
15
15
|
.fdy-dropzone--row{flex-direction:row;align-items:center;justify-content:center;text-align:left;gap:var(--space-4);}
|
package/src/components/input.css
CHANGED
|
@@ -55,6 +55,6 @@ fieldset.fdy-field>legend{padding:0;float:none;margin-bottom:var(--space-2);}
|
|
|
55
55
|
screen reader does not read "star" after every label. That is stricter than a <span> an app has to
|
|
56
56
|
remember to mark aria-hidden, and it cannot be forgotten. */
|
|
57
57
|
.fdy-label--required::after{content:"*" / "";margin-left:var(--space-1);color:var(--color-danger);}
|
|
58
|
-
.fdy-help{font-size:var(--text-xs);color:var(--color-text-muted);}
|
|
58
|
+
.fdy-help{margin:0;font-size:var(--text-xs);color:var(--color-text-muted);}
|
|
59
59
|
/* --danger is the tone word everywhere else in the kit; help text takes either (CATATAN-FREEDAY §11). */
|
|
60
60
|
.fdy-help--error,.fdy-help--danger{color:var(--color-danger);}
|
package/src/components/list.css
CHANGED
|
@@ -38,6 +38,6 @@
|
|
|
38
38
|
/* Row internals: a title/meta stack that truncates, and a trailing slot pinned right. */
|
|
39
39
|
.fdy-list__main{display:flex;flex-direction:column;gap:var(--space-1);min-width:0;flex:1;}
|
|
40
40
|
.fdy-list__title{font-family:var(--font-body);font-size:var(--text-base);font-weight:var(--weight-medium);letter-spacing:normal;color:var(--color-text);margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
|
41
|
-
.fdy-list__meta{font-size:var(--text-sm);color:var(--color-text-muted);display:flex;align-items:center;gap:var(--space-2);flex-wrap:wrap;}
|
|
41
|
+
.fdy-list__meta{margin:0;font-size:var(--text-sm);color:var(--color-text-muted);display:flex;align-items:center;gap:var(--space-2);flex-wrap:wrap;}
|
|
42
42
|
.fdy-list__aside{flex:none;display:flex;align-items:center;gap:var(--space-2);}
|
|
43
43
|
/* Density: rows tighten with the rest of the kit (--space-* mid-range steps under compact). */
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
.fdy-state__icon{display:inline-flex;align-items:center;justify-content:center;width:2.5rem;height:2.5rem;color:var(--color-text-subtle);}
|
|
4
4
|
.fdy-state__icon svg{width:100%;height:100%;}
|
|
5
5
|
.fdy-state__title{font-family:var(--font-display);font-size:var(--text-lg);font-weight:var(--weight-semibold);color:var(--color-text);margin:0;}
|
|
6
|
-
.fdy-state__text{font-size:var(--text-sm);color:var(--color-text-muted);max-width:24rem;line-height:var(--leading-normal);}
|
|
6
|
+
.fdy-state__text{margin:0;font-size:var(--text-sm);color:var(--color-text-muted);max-width:24rem;line-height:var(--leading-normal);}
|
|
7
7
|
.fdy-state__actions{margin-top:var(--space-2);display:flex;gap:var(--space-2);flex-wrap:wrap;justify-content:center;}
|
|
8
8
|
.fdy-state--danger .fdy-state__icon{color:var(--color-danger-strong);}
|
|
9
9
|
/* Compact (#069): the same state inside a small card, one line of icon and text instead of a
|