@ojiepermana/angular 22.2.10 → 22.2.12

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 (110) hide show
  1. package/component/icon/README.md +17 -0
  2. package/fesm2022/ojiepermana-angular-chart-area.mjs +3 -3
  3. package/fesm2022/ojiepermana-angular-chart-bar.mjs +3 -3
  4. package/fesm2022/ojiepermana-angular-chart-core.mjs +34 -34
  5. package/fesm2022/ojiepermana-angular-chart-line.mjs +3 -3
  6. package/fesm2022/ojiepermana-angular-chart-pie.mjs +3 -3
  7. package/fesm2022/ojiepermana-angular-chart-primitives.mjs +33 -33
  8. package/fesm2022/ojiepermana-angular-chart-radar.mjs +3 -3
  9. package/fesm2022/ojiepermana-angular-chart-radial.mjs +3 -3
  10. package/fesm2022/ojiepermana-angular-chart-scatter.mjs +3 -3
  11. package/fesm2022/ojiepermana-angular-component-accordion.mjs +15 -15
  12. package/fesm2022/ojiepermana-angular-component-alert-dialog.mjs +27 -27
  13. package/fesm2022/ojiepermana-angular-component-alert.mjs +12 -12
  14. package/fesm2022/ojiepermana-angular-component-aspect-ratio.mjs +3 -3
  15. package/fesm2022/ojiepermana-angular-component-avatar.mjs +18 -18
  16. package/fesm2022/ojiepermana-angular-component-badge.mjs +3 -3
  17. package/fesm2022/ojiepermana-angular-component-breadcrumb.mjs +21 -21
  18. package/fesm2022/ojiepermana-angular-component-button-group.mjs +9 -9
  19. package/fesm2022/ojiepermana-angular-component-button.mjs +3 -3
  20. package/fesm2022/ojiepermana-angular-component-calendar.mjs +3 -3
  21. package/fesm2022/ojiepermana-angular-component-card.mjs +21 -21
  22. package/fesm2022/ojiepermana-angular-component-carousel.mjs +18 -18
  23. package/fesm2022/ojiepermana-angular-component-checkbox.mjs +3 -3
  24. package/fesm2022/ojiepermana-angular-component-collapsible.mjs +12 -12
  25. package/fesm2022/ojiepermana-angular-component-combobox.mjs +3 -3
  26. package/fesm2022/ojiepermana-angular-component-command.mjs +27 -27
  27. package/fesm2022/ojiepermana-angular-component-composer.mjs +21 -21
  28. package/fesm2022/ojiepermana-angular-component-context-menu.mjs +3 -3
  29. package/fesm2022/ojiepermana-angular-component-date-picker.mjs +3 -3
  30. package/fesm2022/ojiepermana-angular-component-dialog.mjs +21 -21
  31. package/fesm2022/ojiepermana-angular-component-dropdown-menu.mjs +39 -39
  32. package/fesm2022/ojiepermana-angular-component-editor.mjs +18 -18
  33. package/fesm2022/ojiepermana-angular-component-empty.mjs +18 -18
  34. package/fesm2022/ojiepermana-angular-component-form.mjs +36 -36
  35. package/fesm2022/ojiepermana-angular-component-hover-card.mjs +9 -9
  36. package/fesm2022/ojiepermana-angular-component-icon.mjs +6 -6
  37. package/fesm2022/ojiepermana-angular-component-input-group.mjs +18 -18
  38. package/fesm2022/ojiepermana-angular-component-input-otp.mjs +15 -15
  39. package/fesm2022/ojiepermana-angular-component-input.mjs +3 -3
  40. package/fesm2022/ojiepermana-angular-component-item.mjs +30 -30
  41. package/fesm2022/ojiepermana-angular-component-kanban.mjs +27 -27
  42. package/fesm2022/ojiepermana-angular-component-kbd.mjs +6 -6
  43. package/fesm2022/ojiepermana-angular-component-label.mjs +3 -3
  44. package/fesm2022/ojiepermana-angular-component-menubar.mjs +12 -12
  45. package/fesm2022/ojiepermana-angular-component-native-select.mjs +9 -9
  46. package/fesm2022/ojiepermana-angular-component-navigation-menu.mjs +21 -21
  47. package/fesm2022/ojiepermana-angular-component-pagination.mjs +3 -3
  48. package/fesm2022/ojiepermana-angular-component-pillbox.mjs +15 -15
  49. package/fesm2022/ojiepermana-angular-component-popover.mjs +6 -6
  50. package/fesm2022/ojiepermana-angular-component-progress.mjs +3 -3
  51. package/fesm2022/ojiepermana-angular-component-radio.mjs +6 -6
  52. package/fesm2022/ojiepermana-angular-component-resizable.mjs +12 -12
  53. package/fesm2022/ojiepermana-angular-component-scroll-area.mjs +3 -3
  54. package/fesm2022/ojiepermana-angular-component-segmented-control.mjs +9 -7
  55. package/fesm2022/ojiepermana-angular-component-select.mjs +6 -6
  56. package/fesm2022/ojiepermana-angular-component-separator.mjs +3 -3
  57. package/fesm2022/ojiepermana-angular-component-sheet.mjs +32 -24
  58. package/fesm2022/ojiepermana-angular-component-skeleton.mjs +3 -3
  59. package/fesm2022/ojiepermana-angular-component-slider.mjs +6 -6
  60. package/fesm2022/ojiepermana-angular-component-spinner.mjs +3 -3
  61. package/fesm2022/ojiepermana-angular-component-switch.mjs +3 -3
  62. package/fesm2022/ojiepermana-angular-component-table.mjs +24 -24
  63. package/fesm2022/ojiepermana-angular-component-tabs.mjs +18 -18
  64. package/fesm2022/ojiepermana-angular-component-textarea.mjs +3 -3
  65. package/fesm2022/ojiepermana-angular-component-timeline.mjs +18 -18
  66. package/fesm2022/ojiepermana-angular-component-toast.mjs +3 -3
  67. package/fesm2022/ojiepermana-angular-component-toggle-group.mjs +9 -9
  68. package/fesm2022/ojiepermana-angular-component-toggle.mjs +3 -3
  69. package/fesm2022/ojiepermana-angular-component-tooltip.mjs +15 -15
  70. package/fesm2022/ojiepermana-angular-component-utils-core.mjs +420 -4
  71. package/fesm2022/ojiepermana-angular-component-utils-scale.mjs +3 -3
  72. package/fesm2022/ojiepermana-angular-navigation-icon.mjs +3 -3
  73. package/fesm2022/{ojiepermana-angular-navigation-navigation-badge-count.component-BxWVj145.mjs → ojiepermana-angular-navigation-navigation-badge-count.component-Bx89vXtg.mjs} +3 -3
  74. package/fesm2022/{ojiepermana-angular-navigation-navigation-dockbar-menu.component-DTPbCqmL.mjs → ojiepermana-angular-navigation-navigation-dockbar-menu.component-DwOSHmKC.mjs} +41 -10
  75. package/fesm2022/{ojiepermana-angular-navigation-navigation-entry-grid.component-Bw532lfJ.mjs → ojiepermana-angular-navigation-navigation-entry-grid.component-DtRHbiBM.mjs} +71 -24
  76. package/fesm2022/{ojiepermana-angular-navigation-navigation-flyout-menu.component-vLVcVQDd.mjs → ojiepermana-angular-navigation-navigation-flyout-menu.component-Bo2nIOJk.mjs} +28 -10
  77. package/fesm2022/{ojiepermana-angular-navigation-navigation-horizontal.component-A1zBBMDS.mjs → ojiepermana-angular-navigation-navigation-horizontal.component-DUyMjBKb.mjs} +10 -8
  78. package/fesm2022/{ojiepermana-angular-navigation-navigation-item.component-C-nz2md7.mjs → ojiepermana-angular-navigation-navigation-item.component-BKmO7Pqa.mjs} +188 -56
  79. package/fesm2022/{ojiepermana-angular-navigation-navigation-list.component-CjcoYtil.mjs → ojiepermana-angular-navigation-navigation-list.component-DI-En6rE.mjs} +24 -4
  80. package/fesm2022/ojiepermana-angular-navigation-service.mjs +7 -7
  81. package/fesm2022/ojiepermana-angular-navigation.mjs +119 -71
  82. package/fesm2022/ojiepermana-angular-theme-component-settings.mjs +329 -69
  83. package/fesm2022/ojiepermana-angular-theme-layout-services.mjs +7 -7
  84. package/fesm2022/ojiepermana-angular-theme-layout-wrapper.mjs +83 -35
  85. package/fesm2022/ojiepermana-angular-theme-layout.mjs +25 -25
  86. package/fesm2022/ojiepermana-angular-theme-on-fill.mjs +3 -3
  87. package/fesm2022/ojiepermana-angular-theme-page-core.mjs +3 -3
  88. package/fesm2022/ojiepermana-angular-theme-page-filter.mjs +6 -6
  89. package/fesm2022/ojiepermana-angular-theme-page-overview.mjs +3 -3
  90. package/fesm2022/ojiepermana-angular-theme-page-root.mjs +15 -6
  91. package/fesm2022/ojiepermana-angular-theme-page-side.mjs +6 -6
  92. package/fesm2022/ojiepermana-angular-theme-page-slots.mjs +12 -12
  93. package/fesm2022/ojiepermana-angular-theme-shell-services.mjs +4 -4
  94. package/fesm2022/ojiepermana-angular-theme-shell.mjs +21 -12
  95. package/fesm2022/ojiepermana-angular-theme-styles.mjs +109 -178
  96. package/navigation/README.md +32 -2
  97. package/package.json +3 -2
  98. package/theme/README.md +5 -0
  99. package/theme/component/settings/README.md +15 -0
  100. package/theme/styles/README.md +71 -1
  101. package/theme/styles/css/base/components.css +29 -75
  102. package/theme/styles/css/base/theme.css +3 -3
  103. package/theme/styles/css/base/tokens.css +8 -0
  104. package/types/ojiepermana-angular-component-segmented-control.d.ts +3 -3
  105. package/types/ojiepermana-angular-component-utils-core.d.ts +147 -3
  106. package/types/ojiepermana-angular-navigation-types.d.ts +2 -0
  107. package/types/ojiepermana-angular-navigation.d.ts +8 -1
  108. package/types/ojiepermana-angular-theme-component-settings.d.ts +11 -3
  109. package/types/ojiepermana-angular-theme-layout-wrapper.d.ts +8 -1
  110. package/types/ojiepermana-angular-theme-styles.d.ts +30 -26
@@ -141,12 +141,254 @@ function uniqueId(prefix) {
141
141
  counter += 1;
142
142
  return `${prefix}-${counter}`;
143
143
  }
144
+ const STORAGE_VERSION_KEY = "theme-storage-version";
145
+ const LOCK_NAME = "ui-theme-storage-reset";
146
+ const LOCK_WAIT_MS = 2e3;
147
+ function parseStorageVersion(value) {
148
+ if (value === null || !/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(value)) return null;
149
+ const parts = value.split(".").map(Number);
150
+ return parts.every(Number.isSafeInteger) ? parts : null;
151
+ }
152
+ function compareVersions(left, right) {
153
+ for (let index = 0; index < 3; index++) if (left[index] !== right[index]) return left[index] > right[index] ? 1 : -1;
154
+ return 0;
155
+ }
156
+ const roots = /* @__PURE__ */ new WeakMap();
157
+ function registerStorageRoot(documentRef, coordinator) {
158
+ const existing = roots.get(documentRef);
159
+ if (existing && (coordinator || existing.coordinator)) throw new Error("Automatic theme storage reset permits only one theme root per Document.");
160
+ const root = existing ?? {
161
+ owners: /* @__PURE__ */ new Set(),
162
+ coordinator
163
+ };
164
+ const owner = {};
165
+ root.owners.add(owner);
166
+ roots.set(documentRef, root);
167
+ coordinator?.listen();
168
+ return () => {
169
+ coordinator?.destroy();
170
+ root.owners.delete(owner);
171
+ if (roots.get(documentRef) === root && root.owners.size === 0) roots.delete(documentRef);
172
+ };
173
+ }
174
+ function storageCoordinator(documentRef) {
175
+ return documentRef ? roots.get(documentRef)?.coordinator ?? null : null;
176
+ }
177
+ var StorageCoordinator = class {
178
+ documentRef;
179
+ version;
180
+ preserveKeys;
181
+ setStatus;
182
+ state = "pending";
183
+ versionParts;
184
+ invalidations = /* @__PURE__ */ new Set();
185
+ requests = /* @__PURE__ */ new Set();
186
+ tail = Promise.resolve();
187
+ initialization;
188
+ destroyed = false;
189
+ reloadPending = false;
190
+ lastReloadTarget = null;
191
+ window;
192
+ constructor(documentRef, version, preserveKeys, setStatus) {
193
+ this.documentRef = documentRef;
194
+ this.version = version;
195
+ this.preserveKeys = preserveKeys;
196
+ this.setStatus = setStatus;
197
+ const parts = parseStorageVersion(version);
198
+ if (!parts) throw new Error("Theme package version must use stable MAJOR.MINOR.PATCH.");
199
+ this.versionParts = parts;
200
+ this.window = documentRef.defaultView;
201
+ setStatus("pending");
202
+ }
203
+ listen() {
204
+ this.window?.addEventListener("storage", this.onStorage);
205
+ this.window?.addEventListener("focus", this.onWake);
206
+ this.window?.addEventListener("pageshow", this.onWake);
207
+ }
208
+ initialize(hydrate) {
209
+ this.initialization ??= this.bootstrap(hydrate);
210
+ return this.initialization;
211
+ }
212
+ async bootstrap(hydrate) {
213
+ try {
214
+ if (!this.window) this.transition("unavailable");
215
+ else if (!this.window.navigator.locks) this.transition("unsupported");
216
+ else await this.lock(() => {
217
+ const storage = this.nativeStorage();
218
+ const previous = parseStorageVersion(storage.getItem(STORAGE_VERSION_KEY));
219
+ if (!previous) {
220
+ storage.setItem(STORAGE_VERSION_KEY, this.version);
221
+ this.transition("adopted");
222
+ } else {
223
+ const order = compareVersions(this.versionParts, previous);
224
+ if (order < 0) {
225
+ this.lastReloadTarget = previous;
226
+ this.transition("stale");
227
+ } else if (order === 0) this.transition("ready");
228
+ else {
229
+ const keys = [];
230
+ for (let index = 0; index < storage.length; index++) {
231
+ const key = storage.key(index);
232
+ if (key !== null) keys.push(key);
233
+ }
234
+ for (const key of keys) if (key !== "theme-storage-version" && !this.preserveKeys.has(key)) storage.removeItem(key);
235
+ storage.setItem(STORAGE_VERSION_KEY, this.version);
236
+ this.transition("reset");
237
+ }
238
+ }
239
+ if (this.canPersist() && this.observeMarker(storage)) hydrate();
240
+ });
241
+ } catch {
242
+ this.fail();
243
+ }
244
+ if (!this.destroyed && !this.canPersist()) hydrate();
245
+ }
246
+ nativeStorage() {
247
+ const storage = this.window?.localStorage;
248
+ if (!storage) throw new Error("Storage unavailable.");
249
+ return storage;
250
+ }
251
+ canPersist() {
252
+ return !this.destroyed && [
253
+ "ready",
254
+ "adopted",
255
+ "reset"
256
+ ].includes(this.state);
257
+ }
258
+ assertInitialized() {
259
+ if (!this.destroyed && this.state === "pending") throw new Error("Theme storage is pending. Await ThemeStorageVersionService.initialize() before reading preferences.");
260
+ }
261
+ read(key) {
262
+ this.assertInitialized();
263
+ if (!this.canPersist()) return null;
264
+ try {
265
+ return this.nativeStorage().getItem(key);
266
+ } catch {
267
+ this.fail();
268
+ return null;
269
+ }
270
+ }
271
+ write(key, value, owner) {
272
+ this.mutate((storage) => storage.setItem(key, value), owner);
273
+ }
274
+ remove(key, owner) {
275
+ this.mutate((storage) => storage.removeItem(key), owner);
276
+ }
277
+ mutate(action, owner) {
278
+ this.assertInitialized();
279
+ if (!this.canPersist()) return;
280
+ this.tail = this.tail.then(async () => {
281
+ if (!this.canPersist() || owner?.destroyed) return;
282
+ await this.lock(() => {
283
+ if (!this.canPersist() || owner?.destroyed) return;
284
+ const storage = this.nativeStorage();
285
+ if (this.observeMarker(storage)) action(storage);
286
+ });
287
+ });
288
+ }
289
+ onInvalidation(callback) {
290
+ this.invalidations.add(callback);
291
+ return () => this.invalidations.delete(callback);
292
+ }
293
+ transition(status) {
294
+ if (this.destroyed) return;
295
+ this.state = status;
296
+ this.setStatus(status);
297
+ }
298
+ fail() {
299
+ if (this.destroyed || [
300
+ "failed",
301
+ "unsupported",
302
+ "unavailable"
303
+ ].includes(this.state)) return;
304
+ this.transition("failed");
305
+ for (const request of this.requests) request.abort();
306
+ for (const callback of this.invalidations) callback();
307
+ }
308
+ observeMarker(storage) {
309
+ const marker = parseStorageVersion(storage.getItem(STORAGE_VERSION_KEY));
310
+ if (this.state === "stale" && (!marker || compareVersions(marker, this.lastReloadTarget ?? this.versionParts) <= 0)) return false;
311
+ if (!marker) {
312
+ this.fail();
313
+ return false;
314
+ }
315
+ const order = compareVersions(marker, this.versionParts);
316
+ if (order > 0) {
317
+ this.transition("stale");
318
+ if (!this.lastReloadTarget || compareVersions(marker, this.lastReloadTarget) > 0) {
319
+ this.lastReloadTarget = marker;
320
+ this.reloadPending = true;
321
+ }
322
+ return false;
323
+ }
324
+ if (order < 0) {
325
+ this.fail();
326
+ return false;
327
+ }
328
+ return true;
329
+ }
330
+ async lock(action) {
331
+ if (this.destroyed) return;
332
+ const controller = new AbortController();
333
+ this.requests.add(controller);
334
+ const timeout = setTimeout(() => controller.abort(), LOCK_WAIT_MS);
335
+ try {
336
+ const manager = this.window?.navigator.locks;
337
+ if (!manager) {
338
+ this.fail();
339
+ return;
340
+ }
341
+ await manager.request(LOCK_NAME, {
342
+ mode: "exclusive",
343
+ signal: controller.signal
344
+ }, () => {
345
+ clearTimeout(timeout);
346
+ if (!this.destroyed && !controller.signal.aborted) action();
347
+ });
348
+ } catch {
349
+ this.fail();
350
+ } finally {
351
+ clearTimeout(timeout);
352
+ this.requests.delete(controller);
353
+ }
354
+ if (this.reloadPending) {
355
+ this.reloadPending = false;
356
+ if (!this.destroyed && this.state === "stale") this.window?.location.reload();
357
+ }
358
+ }
359
+ onStorage = (event) => {
360
+ if (event.storageArea && event.storageArea !== this.window?.localStorage) return;
361
+ if (event.key === null || event.key === "theme-storage-version") this.onWake();
362
+ };
363
+ onWake = () => {
364
+ if (this.destroyed || this.state === "pending" || [
365
+ "failed",
366
+ "unsupported",
367
+ "unavailable"
368
+ ].includes(this.state)) return;
369
+ this.lock(() => {
370
+ if (!this.destroyed && ![
371
+ "failed",
372
+ "unsupported",
373
+ "unavailable"
374
+ ].includes(this.state)) this.observeMarker(this.nativeStorage());
375
+ });
376
+ };
377
+ destroy() {
378
+ this.destroyed = true;
379
+ for (const request of this.requests) request.abort();
380
+ this.invalidations.clear();
381
+ this.window?.removeEventListener("storage", this.onStorage);
382
+ this.window?.removeEventListener("focus", this.onWake);
383
+ this.window?.removeEventListener("pageshow", this.onWake);
384
+ }
385
+ };
144
386
  const UNAVAILABLE = {
145
387
  read: () => null,
146
388
  write: () => {},
147
389
  remove: () => {}
148
390
  };
149
- function documentLocalStorage(documentRef) {
391
+ function documentLocalStorage(documentRef, owner) {
150
392
  const resolve = () => {
151
393
  try {
152
394
  return documentRef?.defaultView?.localStorage ?? null;
@@ -156,6 +398,8 @@ function documentLocalStorage(documentRef) {
156
398
  };
157
399
  return {
158
400
  read: (key) => {
401
+ const coordinator = storageCoordinator(documentRef);
402
+ if (coordinator) return coordinator.read(key);
159
403
  try {
160
404
  return resolve()?.getItem(key) ?? null;
161
405
  } catch {
@@ -163,19 +407,191 @@ function documentLocalStorage(documentRef) {
163
407
  }
164
408
  },
165
409
  write: (key, value) => {
410
+ const coordinator = storageCoordinator(documentRef);
411
+ if (owner?.destroyed) return;
412
+ if (coordinator) {
413
+ coordinator.write(key, value, owner);
414
+ return;
415
+ }
166
416
  try {
167
417
  resolve()?.setItem(key, value);
168
418
  } catch {}
169
419
  },
170
420
  remove: (key) => {
421
+ const coordinator = storageCoordinator(documentRef);
422
+ if (owner?.destroyed) return;
423
+ if (coordinator) {
424
+ coordinator.remove(key, owner);
425
+ return;
426
+ }
171
427
  try {
172
428
  resolve()?.removeItem(key);
173
429
  } catch {}
174
430
  }
175
431
  };
176
432
  }
177
- function globalLocalStorage(isBrowser) {
433
+ function globalLocalStorage(isBrowser, owner) {
178
434
  if (!isBrowser) return UNAVAILABLE;
179
- return documentLocalStorage(typeof document === "undefined" ? null : document);
435
+ return documentLocalStorage(typeof document === "undefined" ? null : document, owner);
436
+ }
437
+ const TEXT_CONTRAST_MIN = 4.5;
438
+ const NON_TEXT_CONTRAST_MIN = 3;
439
+ const SOLVE_MARGIN = .02;
440
+ const NUMBER = "[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)";
441
+ const SEPARATOR = "(?:\\s*,\\s*|\\s+)";
442
+ let hslTriplet;
443
+ const hslTripletPattern = () => hslTriplet ??= new RegExp(`^\\s*(${NUMBER})(deg|grad|rad|turn)?${SEPARATOR}(${NUMBER})%${SEPARATOR}(${NUMBER})%\\s*$`, "i");
444
+ const HEX_COLOR = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
445
+ const DEGREES_PER_UNIT = {
446
+ deg: 1,
447
+ grad: .9,
448
+ rad: 57.29577951308232,
449
+ turn: 360
450
+ };
451
+ const clamp = (value, min, max) => Math.max(min, Math.min(max, value));
452
+ const normalizeHue = (hue) => (hue % 360 + 360) % 360;
453
+ function parseHslTriplet(value) {
454
+ const match = hslTripletPattern().exec(value);
455
+ if (!match) return null;
456
+ const [h, s, l] = [
457
+ Number(match[1]),
458
+ Number(match[3]),
459
+ Number(match[4])
460
+ ];
461
+ if (![
462
+ h,
463
+ s,
464
+ l
465
+ ].every(Number.isFinite)) return null;
466
+ return {
467
+ h: normalizeHue(h * DEGREES_PER_UNIT[match[2]?.toLowerCase() ?? "deg"]),
468
+ s,
469
+ l
470
+ };
471
+ }
472
+ function formatHslTriplet({ h, s, l }) {
473
+ return `${h} ${clamp(Math.round(s), 0, 100)}% ${clamp(Math.round(l), 0, 100)}%`;
474
+ }
475
+ function hexToHslTriplet(value) {
476
+ const exact = hexToHsl(value);
477
+ return exact ? formatHslTriplet({
478
+ h: Math.round(exact.h),
479
+ s: exact.s,
480
+ l: exact.l
481
+ }) : null;
482
+ }
483
+ function hexToHsl(value) {
484
+ const match = HEX_COLOR.exec(value.trim());
485
+ if (!match) return null;
486
+ const digits = match[1];
487
+ const expanded = digits.length === 3 ? digits.split("").map((digit) => digit + digit).join("") : digits;
488
+ const [red, green, blue] = [
489
+ 0,
490
+ 2,
491
+ 4
492
+ ].map((offset) => Number.parseInt(expanded.slice(offset, offset + 2), 16) / 255);
493
+ const largest = Math.max(red, green, blue);
494
+ const smallest = Math.min(red, green, blue);
495
+ const delta = largest - smallest;
496
+ const lightness = (largest + smallest) / 2;
497
+ let hue = 0;
498
+ if (delta !== 0) {
499
+ if (largest === red) hue = 60 * (((green - blue) / delta + 6) % 6);
500
+ else if (largest === green) hue = 60 * ((blue - red) / delta + 2);
501
+ else hue = 60 * ((red - green) / delta + 4);
502
+ }
503
+ const saturation = delta === 0 ? 0 : delta / (1 - Math.abs(2 * lightness - 1));
504
+ return {
505
+ h: hue,
506
+ s: saturation * 100,
507
+ l: lightness * 100
508
+ };
509
+ }
510
+ function hslToRgb({ h, s, l }) {
511
+ const saturation = clamp(s, 0, 100) / 100;
512
+ const lightness = clamp(l, 0, 100) / 100;
513
+ const k = (n) => (n + h / 30) % 12;
514
+ const a = saturation * Math.min(lightness, 1 - lightness);
515
+ const channel = (n) => lightness - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
516
+ return [
517
+ channel(0),
518
+ channel(8),
519
+ channel(4)
520
+ ];
521
+ }
522
+ const toLinear = (channel) => channel <= .03928 ? channel / 12.92 : Math.pow((channel + .055) / 1.055, 2.4);
523
+ const toPainted = (channel) => Math.round(clamp(channel, 0, 1) * 255) / 255;
524
+ function relativeLuminance(triplet) {
525
+ const parsed = parseHslTriplet(triplet);
526
+ if (!parsed) return 0;
527
+ const [r, g, b] = hslToRgb(parsed).map(toPainted);
528
+ return .2126 * toLinear(r) + .7152 * toLinear(g) + .0722 * toLinear(b);
529
+ }
530
+ function contrastRatio(a, b) {
531
+ const ya = relativeLuminance(a);
532
+ const yb = relativeLuminance(b);
533
+ return (Math.max(ya, yb) + .05) / (Math.min(ya, yb) + .05);
534
+ }
535
+ function solveLightnessNearest(options) {
536
+ const target = options.min + (options.margin ?? .02);
537
+ const start = Math.round(clamp(options.from, 0, 100));
538
+ for (let delta = 0; delta <= 100; delta += 1) for (const candidate of delta === 0 ? [start] : [start - delta, start + delta]) {
539
+ if (candidate < 0 || candidate > 100) continue;
540
+ const triplet = formatHslTriplet({
541
+ h: options.h,
542
+ s: options.s,
543
+ l: candidate
544
+ });
545
+ if (options.against.every((background) => contrastRatio(triplet, background) >= target)) return triplet;
546
+ }
547
+ return null;
548
+ }
549
+ function fitForeground(options) {
550
+ const min = options.min ?? 4.5;
551
+ if (contrastRatio(options.foreground, options.background) >= min) return options.foreground;
552
+ const parsed = parseHslTriplet(options.foreground);
553
+ if (!parsed) return options.foreground;
554
+ return solveLightnessNearest({
555
+ h: parsed.h,
556
+ s: parsed.s,
557
+ against: [options.background],
558
+ min,
559
+ from: parsed.l
560
+ }) ?? options.foreground;
561
+ }
562
+ const ON_FILL_INK = /* @__PURE__ */ Object.freeze({
563
+ light: "0 0% 12%",
564
+ dark: "0 0% 10%"
565
+ });
566
+ const ON_FILL_WHITE = "0 0% 100%";
567
+ function pickFillForeground(fill, dark, min = TEXT_CONTRAST_MIN) {
568
+ const lightRatio = contrastRatio(ON_FILL_WHITE, fill);
569
+ const darkRatio = contrastRatio(dark, fill);
570
+ const preferred = lightRatio >= darkRatio ? ON_FILL_WHITE : dark;
571
+ if (Math.max(lightRatio, darkRatio) >= min) return preferred;
572
+ const ink = parseHslTriplet(dark);
573
+ return solveLightnessNearest({
574
+ h: ink.h,
575
+ s: ink.s,
576
+ against: [fill],
577
+ min,
578
+ from: ink.l
579
+ }) ?? formatHslTriplet({
580
+ h: ink.h,
581
+ s: ink.s,
582
+ l: 0
583
+ });
584
+ }
585
+ function toFillTriplet(fill) {
586
+ const parsed = parseHslTriplet(fill);
587
+ if (parsed) return `${parsed.h} ${parsed.s}% ${parsed.l}%`;
588
+ const hex = hexToHsl(fill);
589
+ return hex ? `${hex.h} ${hex.s}% ${hex.l}%` : null;
590
+ }
591
+ function foregroundFor(fill, mode = "light") {
592
+ if (typeof fill !== "string") return null;
593
+ const triplet = toFillTriplet(fill.trim());
594
+ if (!triplet) return null;
595
+ return pickFillForeground(triplet, ON_FILL_INK[mode === "dark" ? "dark" : "light"]);
180
596
  }
181
- export { COMPONENT_DENSITIES, COMPONENT_RADII, RovingRow, UI_ID_GENERATOR, UiIdGenerator, cn, densityBaseValue, documentLocalStorage, globalLocalStorage, injectUniqueId, radiusBaseValue, uniqueId };
597
+ export { COMPONENT_DENSITIES, COMPONENT_RADII, NON_TEXT_CONTRAST_MIN, ON_FILL_INK, RovingRow, SOLVE_MARGIN, STORAGE_VERSION_KEY, StorageCoordinator, TEXT_CONTRAST_MIN, UI_ID_GENERATOR, UiIdGenerator, cn, contrastRatio, densityBaseValue, documentLocalStorage, fitForeground, foregroundFor, formatHslTriplet, globalLocalStorage, hexToHslTriplet, injectUniqueId, parseHslTriplet, parseStorageVersion, radiusBaseValue, registerStorageRoot, relativeLuminance, solveLightnessNearest, storageCoordinator, uniqueId };
@@ -8,7 +8,7 @@ var ComponentScaleDirective = class ComponentScaleDirective {
8
8
  densityBase = computed(() => densityBaseValue(this.density()), ...ngDevMode ? [{ debugName: "densityBase" }] : /* istanbul ignore next */ []);
9
9
  static ɵfac = i0.ɵɵngDeclareFactory({
10
10
  minVersion: "12.0.0",
11
- version: "22.2.4",
11
+ version: "22.2.6",
12
12
  ngImport: i0,
13
13
  type: ComponentScaleDirective,
14
14
  deps: [],
@@ -16,7 +16,7 @@ var ComponentScaleDirective = class ComponentScaleDirective {
16
16
  });
17
17
  static ɵdir = i0.ɵɵngDeclareDirective({
18
18
  minVersion: "17.1.0",
19
- version: "22.2.4",
19
+ version: "22.2.6",
20
20
  type: ComponentScaleDirective,
21
21
  isStandalone: true,
22
22
  inputs: {
@@ -44,7 +44,7 @@ var ComponentScaleDirective = class ComponentScaleDirective {
44
44
  };
45
45
  i0.ɵɵngDeclareClassMetadata({
46
46
  minVersion: "12.0.0",
47
- version: "22.2.4",
47
+ version: "22.2.6",
48
48
  ngImport: i0,
49
49
  type: ComponentScaleDirective,
50
50
  decorators: [{
@@ -7,7 +7,7 @@ var NavigationIconDirective = class NavigationIconDirective {
7
7
  }
8
8
  static ɵfac = i0.ɵɵngDeclareFactory({
9
9
  minVersion: "12.0.0",
10
- version: "22.2.4",
10
+ version: "22.2.6",
11
11
  ngImport: i0,
12
12
  type: NavigationIconDirective,
13
13
  deps: [],
@@ -15,7 +15,7 @@ var NavigationIconDirective = class NavigationIconDirective {
15
15
  });
16
16
  static ɵdir = i0.ɵɵngDeclareDirective({
17
17
  minVersion: "14.0.0",
18
- version: "22.2.4",
18
+ version: "22.2.6",
19
19
  type: NavigationIconDirective,
20
20
  isStandalone: true,
21
21
  selector: "ng-template[NavigationIcon]",
@@ -24,7 +24,7 @@ var NavigationIconDirective = class NavigationIconDirective {
24
24
  };
25
25
  i0.ɵɵngDeclareClassMetadata({
26
26
  minVersion: "12.0.0",
27
- version: "22.2.4",
27
+ version: "22.2.6",
28
28
  ngImport: i0,
29
29
  type: NavigationIconDirective,
30
30
  decorators: [{
@@ -124,7 +124,7 @@ var NavigationBadgeCountComponent = class NavigationBadgeCountComponent {
124
124
  badgeClasses = computed(() => cn("nav-count pointer-events-none ml-auto inline-flex shrink-0 items-center justify-center self-center rounded-full bg-destructive text-destructive-foreground", this.badge()?.classes, this.class()), ...ngDevMode ? [{ debugName: "badgeClasses" }] : /* istanbul ignore next */ []);
125
125
  static ɵfac = i0.ɵɵngDeclareFactory({
126
126
  minVersion: "12.0.0",
127
- version: "22.2.4",
127
+ version: "22.2.6",
128
128
  ngImport: i0,
129
129
  type: NavigationBadgeCountComponent,
130
130
  deps: [],
@@ -132,7 +132,7 @@ var NavigationBadgeCountComponent = class NavigationBadgeCountComponent {
132
132
  });
133
133
  static ɵcmp = i0.ɵɵngDeclareComponent({
134
134
  minVersion: "17.0.0",
135
- version: "22.2.4",
135
+ version: "22.2.6",
136
136
  type: NavigationBadgeCountComponent,
137
137
  isStandalone: true,
138
138
  selector: "NavigationBadgeCount",
@@ -180,7 +180,7 @@ var NavigationBadgeCountComponent = class NavigationBadgeCountComponent {
180
180
  };
181
181
  i0.ɵɵngDeclareClassMetadata({
182
182
  minVersion: "12.0.0",
183
- version: "22.2.4",
183
+ version: "22.2.6",
184
184
  ngImport: i0,
185
185
  type: NavigationBadgeCountComponent,
186
186
  decorators: [{