@burdenoff/fe-libs 2026.1118.7 → 2026.1118.8

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.
@@ -10,17 +10,23 @@ export declare const BACKGROUND_PREFERENCE_KEY = "boff-background";
10
10
  export interface UseBackgroundPreferenceOptions {
11
11
  /** The keys' namespace (default `boff-background`). */
12
12
  storageKey?: string;
13
+ /**
14
+ * This product's own default, merged over the library default (dotted waves, accent, subtle).
15
+ * It applies wherever nothing valid is stored, and `reset()` returns to it. Pass a stable
16
+ * value (a module constant); its fields, not its identity, are what is used.
17
+ */
18
+ defaults?: Partial<BackgroundPreference>;
13
19
  }
14
20
  export interface BackgroundPreferenceControls extends BackgroundPreference {
15
21
  setEffect(effect: BackgroundEffectName): void;
16
22
  setColors(colors: BackgroundColorMode): void;
17
23
  setStrength(strength: BackgroundStrength): void;
18
- /** Back to the default. */
24
+ /** Back to the default (the `defaults` option merged over the library default). */
19
25
  reset(): void;
20
26
  }
21
- /** The stored choice (each field validated; anything else is the default). */
22
- export declare function readBackgroundPreference(storageKey?: string): BackgroundPreference;
27
+ /** The stored choice (each field validated; anything else is the default, or the given `defaults`). */
28
+ export declare function readBackgroundPreference(storageKey?: string, defaults?: Partial<BackgroundPreference>): BackgroundPreference;
23
29
  /** The person's background choice and its setters. */
24
- export declare function useBackgroundPreference({ storageKey, }?: UseBackgroundPreferenceOptions): BackgroundPreferenceControls;
30
+ export declare function useBackgroundPreference({ storageKey, defaults, }?: UseBackgroundPreferenceOptions): BackgroundPreferenceControls;
25
31
  /** Tests only: forget the in-memory channels (the stored values stay). */
26
32
  export declare function resetBackgroundPreferenceChannels(): void;
@@ -24,86 +24,108 @@ function u() {
24
24
  function d(e, t) {
25
25
  return l[e].includes(t);
26
26
  }
27
- function f(e = s) {
28
- let t = u(), n = (n) => {
29
- let r = null;
27
+ function f(e) {
28
+ let t = { ...o };
29
+ if (!e) return t;
30
+ let n = (n) => {
31
+ let r = e[n];
32
+ d(n, r) && (t[n] = r);
33
+ };
34
+ return n("effect"), n("colors"), n("strength"), t;
35
+ }
36
+ function p(e = s, t) {
37
+ let n = f(t), r = u(), i = (t) => {
38
+ let i = null;
30
39
  try {
31
- r = t?.getItem(`${e}-${n}`) ?? null;
40
+ i = r?.getItem(`${e}-${t}`) ?? null;
32
41
  } catch {
33
- r = null;
42
+ i = null;
34
43
  }
35
- return d(n, r) ? r : o[n];
44
+ return d(t, i) ? i : n[t];
36
45
  };
37
46
  return {
38
- effect: n("effect"),
39
- colors: n("colors"),
40
- strength: n("strength")
47
+ effect: i("effect"),
48
+ colors: i("colors"),
49
+ strength: i("strength")
41
50
  };
42
51
  }
43
- var p = /* @__PURE__ */ new Map(), m = (e, t) => c.every((n) => e[n] === t[n]);
44
- function h(e) {
45
- let t = p.get(e);
46
- if (!t) t = {
47
- value: f(e),
48
- listeners: /* @__PURE__ */ new Set(),
49
- unpersisted: !1
50
- }, p.set(e, t);
51
- else if (t.listeners.size === 0 && !t.unpersisted) {
52
- let n = f(e);
53
- m(n, t.value) || (t.value = n);
52
+ var m = /* @__PURE__ */ new Map(), h = (e, t) => c.every((n) => e[n] === t[n]);
53
+ function g(e, t) {
54
+ let n = m.get(e);
55
+ if (!n) {
56
+ let r = f(t);
57
+ n = {
58
+ value: p(e, r),
59
+ defaults: r,
60
+ listeners: /* @__PURE__ */ new Set(),
61
+ unpersisted: !1
62
+ }, m.set(e, n);
63
+ } else if (n.listeners.size === 0 && !n.unpersisted) {
64
+ t && (n.defaults = f(t));
65
+ let r = p(e, n.defaults);
66
+ h(r, n.value) || (n.value = r);
54
67
  }
55
- return t;
68
+ return n;
56
69
  }
57
- function g(e, t) {
58
- let n = h(e);
59
- if (!m(n.value, t)) {
70
+ function _(e, t) {
71
+ let n = g(e);
72
+ if (!h(n.value, t)) {
60
73
  n.value = t;
61
74
  for (let e of [...n.listeners]) e();
62
75
  }
63
76
  }
64
- function _(e, t) {
77
+ function v(e, t) {
65
78
  let n = u(), r = n !== null;
66
79
  for (let i of c) try {
67
80
  n?.setItem(`${e}-${i}`, t[i]);
68
81
  } catch {
69
82
  r = !1;
70
83
  }
71
- h(e).unpersisted = !r, g(e, t);
84
+ g(e).unpersisted = !r, _(e, t);
72
85
  }
73
- var v = 0;
74
- function y(e) {
75
- for (let [t, n] of p) (e.key === null || e.key.startsWith(`${t}-`)) && (n.unpersisted = !1, g(t, f(t)));
86
+ var y = 0;
87
+ function b(e) {
88
+ for (let [t, n] of m) (e.key === null || e.key.startsWith(`${t}-`)) && (n.unpersisted = !1, _(t, p(t, n.defaults)));
76
89
  }
77
- function b() {
90
+ function x() {
78
91
  if (typeof window > "u") return () => void 0;
79
- v === 0 && window.addEventListener("storage", y), v += 1;
92
+ y === 0 && window.addEventListener("storage", b), y += 1;
80
93
  let e = !1;
81
94
  return () => {
82
- e || (e = !0, --v, v === 0 && window.removeEventListener("storage", y));
95
+ e || (e = !0, --y, y === 0 && window.removeEventListener("storage", b));
83
96
  };
84
97
  }
85
- function x({ storageKey: e = s } = {}) {
86
- let t = r((t) => {
87
- let n = b(), r = h(e);
98
+ function S({ storageKey: e = s, defaults: t } = {}) {
99
+ let { effect: n, colors: o, strength: c } = t ?? {}, l = i(() => f({
100
+ effect: n,
101
+ colors: o,
102
+ strength: c
103
+ }), [
104
+ n,
105
+ o,
106
+ c
107
+ ]), u = r((t) => {
108
+ let n = x(), r = g(e, l);
88
109
  return r.listeners.add(t), () => {
89
110
  r.listeners.delete(t), n();
90
111
  };
91
- }, [e]), n = r(() => h(e).value, [e]), c = a(t, n, () => o), l = r((t, n) => {
92
- d(t, n) && _(e, {
93
- ...h(e).value,
112
+ }, [e, l]), p = r(() => g(e, l).value, [e, l]), m = a(u, p, () => l), h = r((t, n) => {
113
+ d(t, n) && v(e, {
114
+ ...g(e).value,
94
115
  [t]: n
95
116
  });
96
117
  }, [e]);
97
118
  return i(() => ({
98
- ...c,
99
- setEffect: (e) => l("effect", e),
100
- setColors: (e) => l("colors", e),
101
- setStrength: (e) => l("strength", e),
102
- reset: () => _(e, { ...o })
119
+ ...m,
120
+ setEffect: (e) => h("effect", e),
121
+ setColors: (e) => h("colors", e),
122
+ setStrength: (e) => h("strength", e),
123
+ reset: () => v(e, { ...g(e, l).defaults })
103
124
  }), [
104
- c,
105
- l,
106
- e
125
+ m,
126
+ h,
127
+ e,
128
+ l
107
129
  ]);
108
130
  }
109
- export { s as BACKGROUND_PREFERENCE_KEY, o as DEFAULT_BACKGROUND_PREFERENCE, f as readBackgroundPreference, x as useBackgroundPreference };
131
+ export { s as BACKGROUND_PREFERENCE_KEY, o as DEFAULT_BACKGROUND_PREFERENCE, p as readBackgroundPreference, S as useBackgroundPreference };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/fe-libs",
3
- "version": "2026.1118.7",
3
+ "version": "2026.1118.8",
4
4
  "description": "Burdenoff frontend primitives and domain libraries",
5
5
  "repository": {
6
6
  "type": "git",