luxen-ui 0.18.3 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +1 -0
  2. package/cdn/color-scheme.d.ts +76 -0
  3. package/cdn/color-scheme.d.ts.map +1 -0
  4. package/cdn/color-scheme.js +2 -0
  5. package/cdn/color-scheme.js.map +1 -0
  6. package/cdn/config.d.ts +23 -0
  7. package/cdn/config.d.ts.map +1 -1
  8. package/cdn/custom-elements.json +136 -1
  9. package/cdn/elements/color-scheme-icon/color-scheme-icon.d.ts +55 -0
  10. package/cdn/elements/color-scheme-icon/color-scheme-icon.d.ts.map +1 -0
  11. package/cdn/elements/color-scheme-icon/color-scheme-icon.js +44 -0
  12. package/cdn/elements/color-scheme-icon/color-scheme-icon.js.map +1 -0
  13. package/cdn/elements/color-scheme-icon/index.d.ts +2 -0
  14. package/cdn/elements/color-scheme-icon/index.d.ts.map +1 -0
  15. package/cdn/elements/color-scheme-icon/index.js +2 -0
  16. package/cdn/elements/color-scheme-icon/index.js.map +1 -0
  17. package/cdn/elements/dropdown-item/dropdown-item.d.ts +9 -1
  18. package/cdn/elements/dropdown-item/dropdown-item.d.ts.map +1 -1
  19. package/cdn/elements/dropdown-item/dropdown-item.js +32 -23
  20. package/cdn/elements/dropdown-item/dropdown-item.js.map +1 -1
  21. package/cdn/elements/segmented-control/segmented-control.d.ts +2 -0
  22. package/cdn/elements/segmented-control/segmented-control.d.ts.map +1 -1
  23. package/cdn/elements/segmented-control/segmented-control.js +1 -1
  24. package/cdn/elements/segmented-control/segmented-control.js.map +1 -1
  25. package/cdn/elements/tabs/tabs.d.ts +7 -2
  26. package/cdn/elements/tabs/tabs.d.ts.map +1 -1
  27. package/cdn/elements/tabs/tabs.js.map +1 -1
  28. package/cdn/index.d.ts +2 -0
  29. package/cdn/index.d.ts.map +1 -1
  30. package/cdn/index.js +1 -1
  31. package/cdn/registry.d.ts +1 -1
  32. package/cdn/registry.d.ts.map +1 -1
  33. package/cdn/registry.js.map +1 -1
  34. package/cdn/standalone.js.map +1 -1
  35. package/dist/color-scheme.d.ts +76 -0
  36. package/dist/color-scheme.d.ts.map +1 -0
  37. package/dist/color-scheme.js +203 -0
  38. package/dist/config.d.ts +23 -0
  39. package/dist/config.d.ts.map +1 -1
  40. package/dist/custom-elements.json +136 -1
  41. package/dist/elements/color-scheme-icon/color-scheme-icon.css +98 -0
  42. package/dist/elements/color-scheme-icon/color-scheme-icon.d.ts +55 -0
  43. package/dist/elements/color-scheme-icon/color-scheme-icon.d.ts.map +1 -0
  44. package/dist/elements/color-scheme-icon/color-scheme-icon.js +138 -0
  45. package/dist/elements/color-scheme-icon/index.d.ts +2 -0
  46. package/dist/elements/color-scheme-icon/index.d.ts.map +1 -0
  47. package/dist/elements/color-scheme-icon/index.js +4 -0
  48. package/dist/elements/dropdown-item/dropdown-item.d.ts +9 -1
  49. package/dist/elements/dropdown-item/dropdown-item.d.ts.map +1 -1
  50. package/dist/elements/dropdown-item/dropdown-item.js +49 -26
  51. package/dist/elements/segmented-control/segmented-control.d.ts +2 -0
  52. package/dist/elements/segmented-control/segmented-control.d.ts.map +1 -1
  53. package/dist/elements/segmented-control/segmented-control.js +11 -1
  54. package/dist/elements/tabs/tabs.d.ts +7 -2
  55. package/dist/elements/tabs/tabs.d.ts.map +1 -1
  56. package/dist/elements/tabs/tabs.js +7 -2
  57. package/dist/index.d.ts +2 -0
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +1 -0
  60. package/dist/metadata/color-scheme-icon.json +66 -0
  61. package/dist/metadata/dropdown-item.json +9 -1
  62. package/dist/metadata/index.json +76 -2
  63. package/dist/registry.d.ts +1 -1
  64. package/dist/registry.d.ts.map +1 -1
  65. package/dist/templates/elements/color-scheme-icon.md +279 -0
  66. package/dist/templates/elements/dropdown.md +54 -1
  67. package/dist/templates/elements/tabs.md +4 -1
  68. package/elements.json +8 -0
  69. package/package.json +5 -1
  70. package/vite-plugin.ts +71 -8
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Page-level light/dark state, shared by every control that shows or changes it.
3
+ *
4
+ * Deliberately not an element: the scheme is one value per document, and a
5
+ * document can hold several controls for it — a header button, a menu row, a
6
+ * settings page. Whichever one the user touches, all of them have to agree, so
7
+ * the state belongs to the page rather than to any of them.
8
+ *
9
+ * The model is the one argued in Lea Verou's *Dark mode toggles should be a
10
+ * two-state switch* (2026): three values — an explicit `light`, an explicit
11
+ * `dark`, or no preference at all — but only two ever shown. That falls out of
12
+ * two rules, both implemented here:
13
+ *
14
+ * 1. An override is stored **only when it differs from the OS preference**.
15
+ * Choosing the scheme the OS already reports removes the override instead,
16
+ * handing control back to the system. So a user on a dark OS who switches to
17
+ * light and back is following the system again, not pinned to dark — and
18
+ * "system" stays reachable without a third button.
19
+ * 2. The stored value is read **only when the user acts**. If the OS flips while
20
+ * an explicit override exists, the override survives: the user asked for it,
21
+ * and nothing they did says otherwise.
22
+ *
23
+ * SSR-safe: nothing here touches `window`, `document` or `localStorage` at
24
+ * module scope, and listeners are attached lazily on the first subscription.
25
+ */
26
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
27
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
28
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
29
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
30
+ };
31
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
32
+ if (kind === "m") throw new TypeError("Private method is not writable");
33
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
34
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
35
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
36
+ };
37
+ var _ColorSchemeStore_instances, _ColorSchemeStore_session, _ColorSchemeStore_listeners, _ColorSchemeStore_media, _ColorSchemeStore_last, _ColorSchemeStore_lastOverridden, _ColorSchemeStore_onOsChange, _ColorSchemeStore_onStorageChange, _ColorSchemeStore_override_get, _ColorSchemeStore_applyToRoot, _ColorSchemeStore_notify, _ColorSchemeStore_bind, _ColorSchemeStore_unbind;
38
+ /*
39
+ * Defaults live as module-level bindings, not class fields, so that
40
+ * `luxen-ui/vite-plugin` can bake a project's `luxen.config.mjs` values in at
41
+ * build time by rewriting these two initialisers — the same mechanism it uses
42
+ * for `_elementPrefix` / `_cssPrefix` in `registry.ts`. `configure()` stays the
43
+ * runtime path for anything the build cannot know.
44
+ */
45
+ let _storageKey = 'luxen-color-scheme';
46
+ let _apply = false;
47
+ const DARK_QUERY = '(prefers-color-scheme: dark)';
48
+ /** The OS-level preference. `light` when the query is unsupported. */
49
+ function osScheme() {
50
+ return globalThis.matchMedia?.(DARK_QUERY).matches ? 'dark' : 'light';
51
+ }
52
+ function readStored(key) {
53
+ if (!key)
54
+ return null;
55
+ try {
56
+ const value = localStorage.getItem(key);
57
+ return value === 'light' || value === 'dark' ? value : null;
58
+ }
59
+ catch {
60
+ // Safari private mode, disabled storage, sandboxed iframe.
61
+ return null;
62
+ }
63
+ }
64
+ class ColorSchemeStore {
65
+ constructor() {
66
+ _ColorSchemeStore_instances.add(this);
67
+ /**
68
+ * In-memory copy of the override, used when persistence is off or when the
69
+ * browser refuses to write. Without it a blocked write would leave every
70
+ * control unable to move at all.
71
+ */
72
+ _ColorSchemeStore_session.set(this, null);
73
+ _ColorSchemeStore_listeners.set(this, new Set());
74
+ _ColorSchemeStore_media.set(this, null);
75
+ _ColorSchemeStore_last.set(this, null);
76
+ _ColorSchemeStore_lastOverridden.set(this, false);
77
+ _ColorSchemeStore_onOsChange.set(this, () => __classPrivateFieldGet(this, _ColorSchemeStore_instances, "m", _ColorSchemeStore_notify).call(this));
78
+ _ColorSchemeStore_onStorageChange.set(this, (event) => {
79
+ // `key === null` means the whole store was cleared.
80
+ if (event.key !== null && event.key !== _storageKey)
81
+ return;
82
+ // Another tab is the authority now: drop this page's session copy so a
83
+ // release made over there is not undone by a stale local value.
84
+ if (_storageKey)
85
+ __classPrivateFieldSet(this, _ColorSchemeStore_session, null, "f");
86
+ __classPrivateFieldGet(this, _ColorSchemeStore_instances, "m", _ColorSchemeStore_notify).call(this);
87
+ });
88
+ }
89
+ /** The scheme actually in effect: a stored override, else the OS preference. */
90
+ get current() {
91
+ return __classPrivateFieldGet(this, _ColorSchemeStore_instances, "a", _ColorSchemeStore_override_get) ?? osScheme();
92
+ }
93
+ /** Whether an override is in place, rather than the OS preference being followed. */
94
+ get overridden() {
95
+ return __classPrivateFieldGet(this, _ColorSchemeStore_instances, "a", _ColorSchemeStore_override_get) !== null;
96
+ }
97
+ /**
98
+ * Choose a scheme. Rule 1 lives here: the override is written only when it
99
+ * disagrees with the OS, and released when it agrees.
100
+ */
101
+ set(next) {
102
+ const release = next === osScheme();
103
+ if (_storageKey) {
104
+ try {
105
+ if (release)
106
+ localStorage.removeItem(_storageKey);
107
+ else
108
+ localStorage.setItem(_storageKey, next);
109
+ // Storage took it, so it is the single authority — drop any session copy
110
+ // left over from a period when it was unavailable.
111
+ __classPrivateFieldSet(this, _ColorSchemeStore_session, null, "f");
112
+ __classPrivateFieldGet(this, _ColorSchemeStore_instances, "m", _ColorSchemeStore_applyToRoot).call(this);
113
+ __classPrivateFieldGet(this, _ColorSchemeStore_instances, "m", _ColorSchemeStore_notify).call(this);
114
+ return;
115
+ }
116
+ catch {
117
+ // Refused — fall through to memory.
118
+ }
119
+ }
120
+ __classPrivateFieldSet(this, _ColorSchemeStore_session, release ? null : next, "f");
121
+ __classPrivateFieldGet(this, _ColorSchemeStore_instances, "m", _ColorSchemeStore_applyToRoot).call(this);
122
+ __classPrivateFieldGet(this, _ColorSchemeStore_instances, "m", _ColorSchemeStore_notify).call(this);
123
+ }
124
+ /** Flip to the other scheme. Returns the scheme now in effect. */
125
+ toggle() {
126
+ this.set(this.current === 'dark' ? 'light' : 'dark');
127
+ return this.current;
128
+ }
129
+ /**
130
+ * Observe the effective scheme. The listener is called **immediately with the
131
+ * current value**, then on a user change, on an OS change with no override in
132
+ * place, and on a change made in another tab. Returns an unsubscribe function;
133
+ * the last unsubscribe releases the listeners.
134
+ *
135
+ * The immediate call is deliberate. A subscriber's job is almost always to
136
+ * mirror the scheme somewhere — an `aria-pressed`, a `checked`, a class — and
137
+ * a change-only contract leaves that mirror wrong until the first change,
138
+ * which is a bug nobody sees until a screen reader hits it. Callers that only
139
+ * want transitions can ignore the first call.
140
+ */
141
+ subscribe(listener) {
142
+ __classPrivateFieldGet(this, _ColorSchemeStore_listeners, "f").add(listener);
143
+ __classPrivateFieldGet(this, _ColorSchemeStore_instances, "m", _ColorSchemeStore_bind).call(this);
144
+ listener(this.current, this.overridden);
145
+ return () => {
146
+ __classPrivateFieldGet(this, _ColorSchemeStore_listeners, "f").delete(listener);
147
+ if (__classPrivateFieldGet(this, _ColorSchemeStore_listeners, "f").size === 0)
148
+ __classPrivateFieldGet(this, _ColorSchemeStore_instances, "m", _ColorSchemeStore_unbind).call(this);
149
+ };
150
+ }
151
+ /** Set the storage key and whether the store writes `color-scheme` on `<html>`. */
152
+ configure(config) {
153
+ if (config.storageKey !== undefined)
154
+ _storageKey = config.storageKey;
155
+ if (config.apply !== undefined) {
156
+ const wasApplying = _apply === 'root';
157
+ _apply = config.apply;
158
+ // Leave no trace when application is switched off.
159
+ if (wasApplying && config.apply === false) {
160
+ globalThis.document?.documentElement.style.removeProperty('color-scheme');
161
+ }
162
+ }
163
+ __classPrivateFieldGet(this, _ColorSchemeStore_instances, "m", _ColorSchemeStore_applyToRoot).call(this);
164
+ __classPrivateFieldGet(this, _ColorSchemeStore_instances, "m", _ColorSchemeStore_notify).call(this);
165
+ }
166
+ }
167
+ _ColorSchemeStore_session = new WeakMap(), _ColorSchemeStore_listeners = new WeakMap(), _ColorSchemeStore_media = new WeakMap(), _ColorSchemeStore_last = new WeakMap(), _ColorSchemeStore_lastOverridden = new WeakMap(), _ColorSchemeStore_onOsChange = new WeakMap(), _ColorSchemeStore_onStorageChange = new WeakMap(), _ColorSchemeStore_instances = new WeakSet(), _ColorSchemeStore_override_get = function _ColorSchemeStore_override_get() {
168
+ return readStored(_storageKey) ?? __classPrivateFieldGet(this, _ColorSchemeStore_session, "f");
169
+ }, _ColorSchemeStore_applyToRoot = function _ColorSchemeStore_applyToRoot() {
170
+ if (_apply !== 'root')
171
+ return;
172
+ const root = globalThis.document?.documentElement;
173
+ if (root)
174
+ root.style.colorScheme = __classPrivateFieldGet(this, _ColorSchemeStore_instances, "a", _ColorSchemeStore_override_get) ?? 'light dark';
175
+ }, _ColorSchemeStore_notify = function _ColorSchemeStore_notify() {
176
+ const next = this.current;
177
+ const overridden = this.overridden;
178
+ // Both halves of the payload are compared, not just the scheme: releasing an
179
+ // override that already agreed with the OS leaves `current` untouched while
180
+ // `overridden` flips, and a subscriber mirroring it — a "following the
181
+ // system" badge, a tri-state settings control — would never hear about it.
182
+ if (next === __classPrivateFieldGet(this, _ColorSchemeStore_last, "f") && overridden === __classPrivateFieldGet(this, _ColorSchemeStore_lastOverridden, "f"))
183
+ return;
184
+ __classPrivateFieldSet(this, _ColorSchemeStore_last, next, "f");
185
+ __classPrivateFieldSet(this, _ColorSchemeStore_lastOverridden, overridden, "f");
186
+ for (const listener of __classPrivateFieldGet(this, _ColorSchemeStore_listeners, "f"))
187
+ listener(next, overridden);
188
+ }, _ColorSchemeStore_bind = function _ColorSchemeStore_bind() {
189
+ if (__classPrivateFieldGet(this, _ColorSchemeStore_media, "f"))
190
+ return;
191
+ __classPrivateFieldSet(this, _ColorSchemeStore_media, globalThis.matchMedia?.(DARK_QUERY) ?? null, "f");
192
+ __classPrivateFieldGet(this, _ColorSchemeStore_media, "f")?.addEventListener('change', __classPrivateFieldGet(this, _ColorSchemeStore_onOsChange, "f"));
193
+ globalThis.addEventListener?.('storage', __classPrivateFieldGet(this, _ColorSchemeStore_onStorageChange, "f"));
194
+ __classPrivateFieldSet(this, _ColorSchemeStore_last, this.current, "f");
195
+ __classPrivateFieldSet(this, _ColorSchemeStore_lastOverridden, this.overridden, "f");
196
+ __classPrivateFieldGet(this, _ColorSchemeStore_instances, "m", _ColorSchemeStore_applyToRoot).call(this);
197
+ }, _ColorSchemeStore_unbind = function _ColorSchemeStore_unbind() {
198
+ __classPrivateFieldGet(this, _ColorSchemeStore_media, "f")?.removeEventListener('change', __classPrivateFieldGet(this, _ColorSchemeStore_onOsChange, "f"));
199
+ __classPrivateFieldSet(this, _ColorSchemeStore_media, null, "f");
200
+ globalThis.removeEventListener?.('storage', __classPrivateFieldGet(this, _ColorSchemeStore_onStorageChange, "f"));
201
+ };
202
+ /** The document's light/dark state. One instance per page. */
203
+ export const colorScheme = new ColorSchemeStore();
package/dist/config.d.ts CHANGED
@@ -43,6 +43,24 @@ export interface LuxenEmitTypesConfig {
43
43
  /** Overwrite the file even when it exists. Default `false`. */
44
44
  force?: boolean;
45
45
  }
46
+ /** Build-time defaults for the `luxen-ui/color-scheme` store. */
47
+ export interface LuxenColorSchemeConfig {
48
+ /**
49
+ * `localStorage` key holding the light/dark override. Default
50
+ * `'luxen-color-scheme'`. Set to `''` to disable persistence entirely.
51
+ *
52
+ * Change it here and the before-first-paint snippet in your `<head>` has to
53
+ * read the same key — that snippet runs before any module and cannot be
54
+ * rewritten by the build.
55
+ */
56
+ storageKey?: string;
57
+ /**
58
+ * Have the store write `color-scheme` on `<html>` itself. Default `false`,
59
+ * because most applications already own a color-mode story; `'root'` is the
60
+ * batteries-included path for a plain page.
61
+ */
62
+ apply?: 'root' | false;
63
+ }
46
64
  /**
47
65
  * Shape of `luxen.config.mjs`. Both the Vite plugin and the CLI read this
48
66
  * file; each tool ignores the fields that don't apply to it.
@@ -66,6 +84,11 @@ export interface LuxenConfig {
66
84
  cssImportPath?: string;
67
85
  /** npm specifier used in `import` examples in `references/`. Default `'luxen-ui'`. */
68
86
  jsImportPath?: string;
87
+ /**
88
+ * Defaults for `luxen-ui/color-scheme`, baked in at build time so a project
89
+ * never has to call `colorScheme.configure()` from its entry point.
90
+ */
91
+ colorScheme?: LuxenColorSchemeConfig;
69
92
  /**
70
93
  * Emit a prefix-aware `.d.ts` for `HTMLElementTagNameMap` (and optionally
71
94
  * Vue's `GlobalComponents`). Pass a path string for the default behaviour,
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/html/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAmD;AACnD,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAE1C,kEAAkE;AAClE,MAAM,WAAW,oBAAoB;IACnC,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IACvB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC3C;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+DAA+D;IAC/D,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAE1B,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,uDAAuD;IACvD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,0FAA0F;IAC1F,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2FAA2F;IAC3F,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sFAAsF;IACtF,YAAY,CAAC,EAAE,MAAM,CAAC;IAGtB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,oBAAoB,CAAC;CAC3C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,WAAW,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAEhE"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/html/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAmD;AACnD,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAE1C,kEAAkE;AAClE,MAAM,WAAW,oBAAoB;IACnC,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IACvB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC3C;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+DAA+D;IAC/D,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,iEAAiE;AACjE,MAAM,WAAW,sBAAsB;IACrC;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAE1B,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,uDAAuD;IACvD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,0FAA0F;IAC1F,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2FAA2F;IAC3F,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sFAAsF;IACtF,YAAY,CAAC,EAAE,MAAM,CAAC;IAGtB;;;OAGG;IACH,WAAW,CAAC,EAAE,sBAAsB,CAAC;IAGrC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,oBAAoB,CAAC;CAC3C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,WAAW,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAEhE"}
@@ -2205,6 +2205,121 @@
2205
2205
  }
2206
2206
  ]
2207
2207
  },
2208
+ {
2209
+ "kind": "javascript-module",
2210
+ "path": "src/html/elements/color-scheme-icon/color-scheme-icon.ts",
2211
+ "declarations": [
2212
+ {
2213
+ "kind": "class",
2214
+ "description": "",
2215
+ "name": "ColorSchemeIcon",
2216
+ "cssProperties": [
2217
+ {
2218
+ "description": "Width and height of the glyph.",
2219
+ "name": "--size",
2220
+ "default": "1em"
2221
+ },
2222
+ {
2223
+ "description": "Glyph color.",
2224
+ "name": "--color",
2225
+ "default": "currentColor"
2226
+ }
2227
+ ],
2228
+ "cssParts": [
2229
+ {
2230
+ "description": "The root `<svg>`, for overriding the morph's timing or tilt.",
2231
+ "name": "base"
2232
+ }
2233
+ ],
2234
+ "members": [
2235
+ {
2236
+ "kind": "field",
2237
+ "name": "scheme",
2238
+ "type": {
2239
+ "text": "ColorScheme | undefined"
2240
+ },
2241
+ "description": "Which glyph to show. Leave it unset and the icon follows the page's scheme\n(`colorScheme.current` — a stored override, else the OS preference), so it\nstays in step with every other control without wiring. Set it to pin the\nglyph, for a legend or a preview that must not move.",
2242
+ "attribute": "scheme",
2243
+ "reflects": true
2244
+ },
2245
+ {
2246
+ "kind": "field",
2247
+ "name": "label",
2248
+ "type": {
2249
+ "text": "string | undefined"
2250
+ },
2251
+ "description": "Accessible label. When set, the glyph becomes meaningful (`role=\"img\"`);\nwhen absent it is decorative and hidden from assistive tech — the right\ndefault inside a row or button that already carries the name.",
2252
+ "attribute": "label"
2253
+ }
2254
+ ],
2255
+ "attributes": [
2256
+ {
2257
+ "name": "scheme",
2258
+ "type": {
2259
+ "text": "ColorScheme | undefined"
2260
+ },
2261
+ "description": "Which glyph to show. Leave it unset and the icon follows the page's scheme\n(`colorScheme.current` — a stored override, else the OS preference), so it\nstays in step with every other control without wiring. Set it to pin the\nglyph, for a legend or a preview that must not move.",
2262
+ "fieldName": "scheme"
2263
+ },
2264
+ {
2265
+ "name": "label",
2266
+ "type": {
2267
+ "text": "string | undefined"
2268
+ },
2269
+ "description": "Accessible label. When set, the glyph becomes meaningful (`role=\"img\"`);\nwhen absent it is decorative and hidden from assistive tech — the right\ndefault inside a row or button that already carries the name.",
2270
+ "fieldName": "label"
2271
+ }
2272
+ ],
2273
+ "superclass": {
2274
+ "name": "LuxenElement",
2275
+ "module": "/src/html/shared/luxen-element.js"
2276
+ },
2277
+ "tagName": "l-color-scheme-icon",
2278
+ "customElement": true,
2279
+ "summary": "A sun that morphs into a moon. Purely presentational: it shows a\ncolor scheme, it does not choose or store one.\n\nThe two glyphs are a single shape — the disc grows, a mask slides in to carve\nthe crescent, and the rays retract in a ripple — so the change reads as one\nobject turning rather than two icons swapping. That is why this is authored\nSVG rather than an `<l-icon>`: an Iconify icon is opaque, and you cannot grow\none into another or animate a mask inside it.\n\nUse it wherever a scheme needs a glyph and the surrounding element is already\nthe control — a `menuitemcheckbox` row, a button, a legend. With no `scheme`\nit follows the page's scheme from `luxen-ui/color-scheme`, so it needs no\nwiring; set `scheme` to pin it.",
2280
+ "examples": [
2281
+ {
2282
+ "title": "In a menu row, where the row is the control",
2283
+ "language": "html",
2284
+ "code": "```html\n<l-dropdown-item type=\"checkbox\" checked>\n<l-color-scheme-icon slot=\"prefix\" scheme=\"dark\"></l-color-scheme-icon>\nDark theme\n</l-dropdown-item>\n```"
2285
+ }
2286
+ ]
2287
+ }
2288
+ ],
2289
+ "exports": [
2290
+ {
2291
+ "kind": "js",
2292
+ "name": "ColorScheme",
2293
+ "declaration": {
2294
+ "name": "ColorScheme",
2295
+ "module": "src/html/elements/color-scheme-icon/color-scheme-icon.ts"
2296
+ }
2297
+ },
2298
+ {
2299
+ "kind": "js",
2300
+ "name": "ColorSchemeIcon",
2301
+ "declaration": {
2302
+ "name": "ColorSchemeIcon",
2303
+ "module": "src/html/elements/color-scheme-icon/color-scheme-icon.ts"
2304
+ }
2305
+ }
2306
+ ]
2307
+ },
2308
+ {
2309
+ "kind": "javascript-module",
2310
+ "path": "src/html/elements/color-scheme-icon/index.ts",
2311
+ "declarations": [],
2312
+ "exports": [
2313
+ {
2314
+ "kind": "js",
2315
+ "name": "*",
2316
+ "declaration": {
2317
+ "name": "*",
2318
+ "module": "src/html/elements/color-scheme-icon/color-scheme-icon.js"
2319
+ }
2320
+ }
2321
+ ]
2322
+ },
2208
2323
  {
2209
2324
  "kind": "javascript-module",
2210
2325
  "path": "src/html/elements/combobox/combobox.ts",
@@ -3706,7 +3821,7 @@
3706
3821
  "name": ""
3707
3822
  },
3708
3823
  {
3709
- "description": "Leading content (e.g. icon).",
3824
+ "description": "Leading content (e.g. icon). A `type=\"checkbox\"` item ignores it unless `check-placement=\"end\"` frees the leading column.",
3710
3825
  "name": "prefix"
3711
3826
  },
3712
3827
  {
@@ -3783,6 +3898,17 @@
3783
3898
  "attribute": "submenu-open",
3784
3899
  "reflects": true
3785
3900
  },
3901
+ {
3902
+ "kind": "field",
3903
+ "name": "checkPlacement",
3904
+ "type": {
3905
+ "text": "'start' | 'end'"
3906
+ },
3907
+ "default": "'start'",
3908
+ "description": "Which side of a `type=\"checkbox\"` item carries the check mark. `start` (the\ndefault) puts it in the leading column, where it takes the place of any\n`prefix`. `end` moves it to the trailing edge, freeing that column so the\nitem can show its own icon alongside the state.",
3909
+ "attribute": "check-placement",
3910
+ "reflects": true
3911
+ },
3786
3912
  {
3787
3913
  "kind": "field",
3788
3914
  "name": "hasSubmenu",
@@ -3877,6 +4003,15 @@
3877
4003
  "default": "false",
3878
4004
  "description": "Whether this item's submenu is open. Managed by the parent `l-dropdown`.",
3879
4005
  "fieldName": "submenuOpen"
4006
+ },
4007
+ {
4008
+ "name": "check-placement",
4009
+ "type": {
4010
+ "text": "'start' | 'end'"
4011
+ },
4012
+ "default": "'start'",
4013
+ "description": "Which side of a `type=\"checkbox\"` item carries the check mark. `start` (the\ndefault) puts it in the leading column, where it takes the place of any\n`prefix`. `end` moves it to the trailing edge, freeing that column so the\nitem can show its own icon alongside the state.",
4014
+ "fieldName": "checkPlacement"
3880
4015
  }
3881
4016
  ],
3882
4017
  "superclass": {
@@ -0,0 +1,98 @@
1
+ /* Sun ↔ moon, morphed rather than swapped.
2
+
3
+ The two glyphs are one shape: a disc that grows, a mask circle that slides in
4
+ to bite a crescent out of it, and eight ray dots that collapse to nothing.
5
+ Nothing is added or removed between the states — which is the whole reason
6
+ this is authored SVG and not an `<l-icon>`. An Iconify icon is an opaque
7
+ document fetched from a set: you can cross-fade two of them, but you cannot
8
+ grow one into the other or animate a mask inside it.
9
+
10
+ Shadow DOM is doing real work here beyond encapsulation: the mask needs an
11
+ `id`, and ids are global in light DOM. Two icons on one page would collide and
12
+ the second would render through the first's mask. A shadow root scopes them
13
+ per instance for free. */
14
+
15
+ :host {
16
+ --size: 1em;
17
+ --color: currentColor;
18
+
19
+ flex: none;
20
+ display: inline-flex;
21
+ inline-size: var(--size);
22
+ block-size: var(--size);
23
+ color: var(--color);
24
+ }
25
+
26
+ svg {
27
+ inline-size: 100%;
28
+ block-size: 100%;
29
+ fill: currentColor;
30
+ /* The tilt is what sells the transition: the glyph turns as it changes, so the
31
+ eye reads one object moving instead of two states cross-fading. */
32
+ rotate: 0deg;
33
+ transition: rotate 500ms cubic-bezier(0.16, 1, 0.3, 1);
34
+ }
35
+
36
+ /* Every animated part scales about its own centre. `fill-box` is what makes
37
+ `center` mean the shape's own box rather than the whole viewBox. */
38
+ .disc,
39
+ .ray,
40
+ .biter {
41
+ transform-box: fill-box;
42
+ transform-origin: center;
43
+ }
44
+
45
+ .disc {
46
+ /* Sun-sized. The dark state grows it to the full radius; the mask then takes
47
+ the bite that turns it into a crescent. */
48
+ scale: 0.56;
49
+ transition: scale 500ms cubic-bezier(0.16, 1, 0.3, 1);
50
+ }
51
+
52
+ .biter {
53
+ /* Parked far enough out that it clears the sun entirely. The clearance must be
54
+ computed against the disc's *authored* r=9, not the 5.04 the sun appears to
55
+ be: masking happens in the element's own user space, before its `scale` is
56
+ applied, so the mask sees the full-size circle. 16px on both axes puts the
57
+ centres 22.6 apart against a 9+11 sum — the earlier 13px looked ample and
58
+ still bit a notch out of the sun's upper right.
59
+ It slides in rather than fading, so the crescent is carved, never dissolved. */
60
+ translate: 16px -16px;
61
+ transition: translate 500ms cubic-bezier(0.16, 1, 0.3, 1);
62
+ }
63
+
64
+ .ray {
65
+ scale: 1;
66
+ transition: scale 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
67
+ /* Staggered from the index each ray carries, so they retract and return as a
68
+ ripple around the disc instead of blinking in unison. */
69
+ transition-delay: calc(var(--i) * 18ms);
70
+ }
71
+
72
+ :host([data-scheme='dark']) {
73
+ svg {
74
+ rotate: 40deg;
75
+ }
76
+
77
+ .disc {
78
+ scale: 1;
79
+ }
80
+
81
+ .biter {
82
+ translate: 5px -5px;
83
+ }
84
+
85
+ .ray {
86
+ scale: 0;
87
+ }
88
+ }
89
+
90
+ @media (prefers-reduced-motion: reduce) {
91
+ svg,
92
+ .disc,
93
+ .biter,
94
+ .ray {
95
+ transition-duration: 0ms;
96
+ transition-delay: 0ms;
97
+ }
98
+ }
@@ -0,0 +1,55 @@
1
+ import { type ColorScheme } from '../../color-scheme.js';
2
+ import { LuxenElement } from '../../shared/luxen-element.js';
3
+ export type { ColorScheme };
4
+ /**
5
+ * @summary A sun that morphs into a moon. Purely presentational: it shows a
6
+ * color scheme, it does not choose or store one.
7
+ *
8
+ * The two glyphs are a single shape — the disc grows, a mask slides in to carve
9
+ * the crescent, and the rays retract in a ripple — so the change reads as one
10
+ * object turning rather than two icons swapping. That is why this is authored
11
+ * SVG rather than an `<l-icon>`: an Iconify icon is opaque, and you cannot grow
12
+ * one into another or animate a mask inside it.
13
+ *
14
+ * Use it wherever a scheme needs a glyph and the surrounding element is already
15
+ * the control — a `menuitemcheckbox` row, a button, a legend. With no `scheme`
16
+ * it follows the page's scheme from `luxen-ui/color-scheme`, so it needs no
17
+ * wiring; set `scheme` to pin it.
18
+ *
19
+ * @example In a menu row, where the row is the control
20
+ * ```html
21
+ * <l-dropdown-item type="checkbox" checked>
22
+ * <l-color-scheme-icon slot="prefix" scheme="dark"></l-color-scheme-icon>
23
+ * Dark theme
24
+ * </l-dropdown-item>
25
+ * ```
26
+ *
27
+ * @cssproperty [--size=1em] - Width and height of the glyph.
28
+ * @cssproperty [--color=currentColor] - Glyph color.
29
+ *
30
+ * @csspart base - The root `<svg>`, for overriding the morph's timing or tilt.
31
+ *
32
+ * @customElement l-color-scheme-icon
33
+ */
34
+ export declare class ColorSchemeIcon extends LuxenElement {
35
+ static styles: import("lit").CSSResult[];
36
+ /**
37
+ * Which glyph to show. Leave it unset and the icon follows the page's scheme
38
+ * (`colorScheme.current` — a stored override, else the OS preference), so it
39
+ * stays in step with every other control without wiring. Set it to pin the
40
+ * glyph, for a legend or a preview that must not move.
41
+ */
42
+ scheme?: ColorScheme;
43
+ /**
44
+ * Accessible label. When set, the glyph becomes meaningful (`role="img"`);
45
+ * when absent it is decorative and hidden from assistive tech — the right
46
+ * default inside a row or button that already carries the name.
47
+ */
48
+ label?: string;
49
+ private _unsubscribe?;
50
+ connectedCallback(): void;
51
+ disconnectedCallback(): void;
52
+ willUpdate(): void;
53
+ render(): import("lit").TemplateResult<1>;
54
+ }
55
+ //# sourceMappingURL=color-scheme-icon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-scheme-icon.d.ts","sourceRoot":"","sources":["../../../src/html/elements/color-scheme-icon/color-scheme-icon.ts"],"names":[],"mappings":"AAEA,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAM7D,YAAY,EAAE,WAAW,EAAE,CAAC;AAY5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,eAAgB,SAAQ,YAAY;IAC/C,OAAgB,MAAM,4BAAwB;IAE9C;;;;;OAKG;IAEH,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB;;;;OAIG;IAEH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,OAAO,CAAC,YAAY,CAAC,CAAa;IAEzB,iBAAiB;IAOjB,oBAAoB;IAMpB,UAAU;IAsBV,MAAM;CA+ChB"}