@mintplayer/web-components 2.16.0 → 2.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.
Files changed (117) hide show
  1. package/accordion/index.mjs +5 -5
  2. package/calendar/index.mjs +1 -1
  3. package/carousel/index.mjs +57 -143
  4. package/charts/core/index.mjs +30 -20
  5. package/charts/core/src/attributes.d.ts +18 -0
  6. package/charts/core/src/index.d.ts +2 -0
  7. package/charts/core/src/view-window.d.ts +46 -0
  8. package/charts/hierarchy/index.mjs +245 -256
  9. package/charts/hierarchy/src/components/mp-hierarchy-chart.d.ts +1 -3
  10. package/charts/sparkline/index.mjs +27 -26
  11. package/charts/trend/index.mjs +21 -20
  12. package/checkbox/index.mjs +1 -1
  13. package/checkbox/src/components/mp-checkbox.d.ts +1 -0
  14. package/chunks/attributes-L3eKsbdy.mjs +16 -0
  15. package/chunks/color-mode-warning-71FmlzWX.mjs +13 -0
  16. package/chunks/{form-check.styles-B0pxJ6YC.mjs → form-check.styles-DqvBnspm.mjs} +24 -3
  17. package/chunks/{mp-calendar.element-CJ8-t-Zn.mjs → mp-calendar.element-BIHS9SZZ.mjs} +11 -6
  18. package/chunks/{mp-checkbox-CzwS7Y_t.mjs → mp-checkbox-zV83gILn.mjs} +44 -36
  19. package/chunks/{mp-datatable-B7st6G-I.mjs → mp-datatable-eRpl7-2V.mjs} +173 -173
  20. package/chunks/{mp-datetime-picker.element-DsWA1AFs.mjs → mp-datetime-picker.element-Cxu5-qRE.mjs} +29 -32
  21. package/chunks/{mp-pagination-Dea75mD4.mjs → mp-pagination-hGy4dL7p.mjs} +9 -4
  22. package/chunks/{mp-radio-cL46sUA0.mjs → mp-radio-BhRVNdKp.mjs} +32 -28
  23. package/chunks/{mp-select-BNrbPwN4.mjs → mp-select-CgqYFvUj.mjs} +41 -26
  24. package/chunks/{mp-splitter-Ckn1kN4v.mjs → mp-splitter-DLehrw3Y.mjs} +144 -120
  25. package/chunks/{mp-timepicker.element-CwaAAOcm.mjs → mp-timepicker.element-BiB9lkgc.mjs} +58 -45
  26. package/chunks/{mp-toggle-button-eo_aTQtu.mjs → mp-toggle-button-CaS9uYLE.mjs} +26 -24
  27. package/chunks/{mp-treeview-C8iltDbq.mjs → mp-treeview-CaMTDrvY.mjs} +51 -50
  28. package/chunks/{overlay-controller-DifgO6jT.mjs → overlay-controller-BHDagokg.mjs} +96 -92
  29. package/chunks/{id-DNZVAnGC.mjs → resource.service--lqLwEqk.mjs} +144 -206
  30. package/chunks/view-window-DGvFiDnW.mjs +263 -0
  31. package/code-snippet/index.mjs +70 -66
  32. package/code-snippet/src/hljs-loaders.generated.d.ts +1 -1
  33. package/custom-elements.json +65750 -0
  34. package/datatable/index.mjs +1 -1
  35. package/datatable/src/components/column-resize.d.ts +11 -0
  36. package/datatable/src/components/mp-datatable.d.ts +5 -0
  37. package/datepicker/index.mjs +10 -9
  38. package/datetime-picker/index.mjs +1 -1
  39. package/datetime-picker/src/mp-datetime-picker.element.d.ts +3 -0
  40. package/dock/index.mjs +430 -463
  41. package/dock/src/components/mint-dock-manager.element.d.ts +25 -2
  42. package/dock/src/core/resize.d.ts +60 -0
  43. package/dropdown-menu/index.mjs +4 -2
  44. package/dropdown-menu/src/components/mp-dropdown-menu.d.ts +6 -1
  45. package/dropdown-menu/src/index.d.ts +1 -1
  46. package/dropdown-menu/src/types/dropdown.d.ts +14 -1
  47. package/dropdown-menu/src/types/index.d.ts +1 -1
  48. package/file-manager/index.mjs +63 -61
  49. package/file-manager/src/components/mp-file-manager.d.ts +4 -3
  50. package/multi-range/index.mjs +56 -50
  51. package/multi-range/src/mint-multi-range.element.d.ts +4 -10
  52. package/multi-range/src/pointer-geometry.d.ts +31 -0
  53. package/navbar/index.mjs +89 -439
  54. package/overlay/index.mjs +1 -1
  55. package/overlay/src/overlay-controller.d.ts +0 -14
  56. package/overlay/src/placement.d.ts +48 -0
  57. package/package.json +7 -1
  58. package/pagination/index.mjs +1 -1
  59. package/phone-input/index.mjs +44 -40
  60. package/phone-input/src/components/stack.d.ts +8 -0
  61. package/query-builder/index.mjs +418 -466
  62. package/query-builder/src/dnd/drag-controller.d.ts +12 -8
  63. package/query-builder/src/mp-query-builder.element.d.ts +5 -1
  64. package/query-builder/src/mp-query-condition.element.d.ts +1 -0
  65. package/radio/index.mjs +1 -1
  66. package/radio-group/index.mjs +1 -1
  67. package/ribbon/index.mjs +477 -498
  68. package/ribbon/src/core/band-text-color.d.ts +10 -0
  69. package/ribbon/src/core/key-tip-allocator.d.ts +10 -0
  70. package/ribbon/src/core/plan-reduce-steps.d.ts +62 -0
  71. package/ribbon/src/mp-ribbon.element.d.ts +0 -27
  72. package/scheduler/index.mjs +726 -711
  73. package/scheduler/src/components/mp-scheduler.d.ts +19 -3
  74. package/scheduler/src/drag/drag-manager.d.ts +1 -9
  75. package/scheduler/src/input/input-handler.d.ts +12 -2
  76. package/scheduler/src/utils/geometry.d.ts +39 -0
  77. package/scheduler/src/views/timeline-view.d.ts +0 -1
  78. package/scheduler-core/index.mjs +84 -71
  79. package/scheduler-core/src/services/resource.service.d.ts +0 -12
  80. package/scheduler-core/src/services/timeline.service.d.ts +0 -9
  81. package/select/index.mjs +1 -1
  82. package/select/src/components/mp-select.d.ts +1 -0
  83. package/signature-pad/index.mjs +21 -23
  84. package/signature-pad/src/canvas-point.d.ts +26 -0
  85. package/signature-pad/src/mp-signature-pad.element.d.ts +1 -7
  86. package/splitter/index.mjs +1 -1
  87. package/splitter/src/components/mp-splitter.d.ts +16 -0
  88. package/splitter/src/managers/index.d.ts +1 -0
  89. package/splitter/src/managers/rescale-panel-sizes.d.ts +14 -0
  90. package/swiper-core/index.mjs +2 -2
  91. package/theming/bs-theme-preboot.js +1 -0
  92. package/theming/color-mode.css +36 -0
  93. package/theming/index.d.ts +1 -0
  94. package/theming/index.mjs +327 -0
  95. package/theming/src/components/mp-theme-toggle.d.ts +71 -0
  96. package/theming/src/cookie.d.ts +31 -0
  97. package/theming/src/index.d.ts +5 -0
  98. package/theming/src/preboot.d.ts +1 -0
  99. package/theming/src/resolve.d.ts +36 -0
  100. package/theming/src/store.d.ts +27 -0
  101. package/theming/src/styles/theme-toggle.styles.d.ts +2 -0
  102. package/theming/src/testing/fake-broadcast-channel.d.ts +35 -0
  103. package/theming/src/toggle-modes.d.ts +23 -0
  104. package/tile-manager/index.mjs +252 -211
  105. package/tile-manager/src/components/mint-tile-manager.element.d.ts +8 -0
  106. package/tile-manager/src/utils/grid-geometry.d.ts +49 -0
  107. package/timeline/index.mjs +156 -164
  108. package/timeline/src/components/mp-timeline.d.ts +41 -7
  109. package/timepicker/index.mjs +7 -4
  110. package/timepicker/src/mp-time-list.element.d.ts +26 -0
  111. package/timepicker/src/mp-timepicker.element.d.ts +3 -0
  112. package/toggle-button/index.mjs +1 -1
  113. package/tree-select/index.mjs +21 -9
  114. package/treeview/index.mjs +1 -1
  115. package/treeview/src/components/mp-treeview.d.ts +6 -4
  116. package/chunks/color-DIeST-IS.mjs +0 -224
  117. package/query-builder/src/mp-query-condition.element.template.d.ts +0 -2
@@ -99,7 +99,7 @@ class l {
99
99
  relative(t) {
100
100
  this.interrupt();
101
101
  const s = this.index + t, i = this.resolve(s);
102
- i !== null && (!this.wrap && i === this.index && !this.dragging || this.transitionTo(s, i));
102
+ i !== null && (i === this.index && !this.dragging || this.transitionTo(s, i));
103
103
  }
104
104
  // ---- drag -----------------------------------------------------------------
105
105
  /** A drag began: interrupt any in-flight transition so the finger owns the track. */
@@ -120,7 +120,7 @@ class l {
120
120
  endDrag(t, s) {
121
121
  if (!this.dragging) return;
122
122
  const e = Math.abs(t) >= this.minimumOffsetPx ? this.index + (t < 0 ? 1 : -1) : this.index, n = this.resolve(e);
123
- if (n === null || !this.wrap && n === this.index && e !== this.index) {
123
+ if (n === null || n === this.index && e !== this.index) {
124
124
  this.transitionTo(this.index, this.index);
125
125
  return;
126
126
  }
@@ -0,0 +1 @@
1
+ "use strict";(function(){var i="bs-theme-mode",l=/^[a-z0-9-]{1,32}$/i;function o(e){return typeof e=="string"&&l.test(e)}function c(e){try{return decodeURIComponent(e)}catch(t){return null}}function f(e){if(!e)return null;var t=i+"=",n=e.split(";").map(function(u){return u.trim()}).filter(function(u){return u.slice(0,t.length)===t});if(n.length===0)return null;var a=c(m(n[0].slice(t.length).trim()));return o(a)?a.toLowerCase():null}function m(e){return e.length>1&&e.charAt(0)==='"'&&e.charAt(e.length-1)==='"'?e.slice(1,-1):e}var s="bs-theme-default-mode";function h(e,t){return e==="auto"?t?"dark":"light":e}function d(e){if(!e||typeof e.querySelector!="function")return null;var t=e.querySelector('meta[name="'+s+'"]'),n=t?t.getAttribute("content"):null;return o(n)?n.toLowerCase():null}try{var r=document,E=f(r.cookie)||d(r)||"auto",M=!!(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches);r.documentElement.setAttribute("data-bs-theme",h(E,M))}catch(e){}})();
@@ -0,0 +1,36 @@
1
+ /*
2
+ * @mintplayer/web-components/theming/color-mode.css (PRD dark-mode D6, D7)
3
+ *
4
+ * --mp-color-mode is the token component sheets query with
5
+ * "@container style(--mp-color-mode: dark)". Custom-property style queries see
6
+ * through shadow roots and survive the light-tier rescoper, which Bootstrap's
7
+ * [data-bs-theme=dark] descendant rules cannot. The nearest themed ancestor wins,
8
+ * so a nested data-bs-theme=light section is light again.
9
+ *
10
+ * Angular gets this through _bootstrap.scss. React/Vue consumers @import it next
11
+ * to bootstrap.min.css. A custom theme declares its own --mp-color-mode (light or
12
+ * dark) in its [data-bs-theme=...] block.
13
+ */
14
+ :root,
15
+ [data-bs-theme=light] {
16
+ --mp-color-mode: light;
17
+ }
18
+
19
+ [data-bs-theme=dark] {
20
+ --mp-color-mode: dark;
21
+ }
22
+
23
+ /*
24
+ * Reserve the toggle's box before the element upgrades, so defining it causes
25
+ * no layout shift. It renders nothing until then: the toggle has no no-JS tier.
26
+ * Every box-affecting declaration must match :host in theme-toggle.styles.scss,
27
+ * vertical-align included: an empty inline-block sits on the baseline by default,
28
+ * 4px lower than the upgraded, middle-aligned host.
29
+ */
30
+ mp-theme-toggle:not(:defined) {
31
+ display: inline-block;
32
+ width: 1.5em;
33
+ height: 1.5em;
34
+ vertical-align: middle;
35
+ line-height: 1;
36
+ }
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -0,0 +1,327 @@
1
+ import { unsafeCSS as C, LitElement as g, svg as k, html as _, nothing as L } from "lit";
2
+ import { L as v } from "../chunks/live-announcer-Bi0orG4n.mjs";
3
+ const d = "bs-theme-mode", x = /^[a-z0-9-]{1,32}$/i, D = 31536e3;
4
+ function c(e) {
5
+ return typeof e == "string" && x.test(e);
6
+ }
7
+ function z(e) {
8
+ try {
9
+ return decodeURIComponent(e);
10
+ } catch {
11
+ return null;
12
+ }
13
+ }
14
+ function w(e) {
15
+ if (!e) return null;
16
+ const t = d + "=", n = e.split(";").map((r) => r.trim()).filter((r) => r.slice(0, t.length) === t);
17
+ if (n.length === 0) return null;
18
+ const o = z(O(n[0].slice(t.length).trim()));
19
+ return c(o) ? o.toLowerCase() : null;
20
+ }
21
+ function O(e) {
22
+ return e.length > 1 && e.charAt(0) === '"' && e.charAt(e.length - 1) === '"' ? e.slice(1, -1) : e;
23
+ }
24
+ function I(e, t, n) {
25
+ if (!c(e)) return;
26
+ const o = n || (typeof document < "u" ? document : void 0);
27
+ if (!o) return;
28
+ const r = [
29
+ d + "=" + encodeURIComponent(e.toLowerCase()),
30
+ "Path=/",
31
+ "SameSite=Lax",
32
+ "Max-Age=" + D
33
+ ];
34
+ t.cookieDomain && (o.cookie = d + "=; Path=/; Max-Age=0", r.push("Domain=" + t.cookieDomain)), t.secure && r.push("Secure"), o.cookie = r.join("; ");
35
+ }
36
+ const $ = "bs-theme-default-mode";
37
+ function B(e, t) {
38
+ return e === "auto" ? t ? "dark" : "light" : e;
39
+ }
40
+ function F(e) {
41
+ if (!e || typeof e.querySelector != "function") return null;
42
+ const t = e.querySelector('meta[name="' + $ + '"]'), n = t ? t.getAttribute("content") : null;
43
+ return c(n) ? n.toLowerCase() : null;
44
+ }
45
+ function Z(e, t) {
46
+ const n = w(e), o = t && c(t.defaultMode) ? t.defaultMode.toLowerCase() : null, r = n || o || "auto";
47
+ return r === "auto" ? null : r;
48
+ }
49
+ const R = /<html(?=[\s>])([^>]*)>/i, H = /\sdata-bs-theme(?![\w-])(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]+))?/gi;
50
+ function ee(e, t) {
51
+ if (t === null || !c(t)) return e;
52
+ const n = t.toLowerCase();
53
+ return e.replace(R, (o, r) => "<html" + r.replace(H, "").replace(/\s+$/, "") + ' data-bs-theme="' + n + '">');
54
+ }
55
+ const p = Symbol.for("mintplayer.bs-theme"), U = d, N = "(prefers-color-scheme: dark)", S = () => globalThis;
56
+ function T() {
57
+ return typeof window < "u" && typeof document < "u" && !!document.documentElement;
58
+ }
59
+ function j(e) {
60
+ console.warn(
61
+ `[bs-theme] setMode(${JSON.stringify(e)}) ignored: a mode must match /^[a-z0-9-]{1,32}$/i.`
62
+ );
63
+ }
64
+ function q() {
65
+ const e = /* @__PURE__ */ new Set();
66
+ let t = {}, n = w(document.cookie) ?? F(document) ?? "auto";
67
+ const o = typeof window.matchMedia == "function" ? window.matchMedia(N) : null;
68
+ let r = o?.matches ?? !1;
69
+ const a = () => B(n, r), l = () => document.documentElement.setAttribute("data-bs-theme", a()), m = () => [...e].map((s) => {
70
+ try {
71
+ s();
72
+ } catch (i) {
73
+ setTimeout(() => {
74
+ throw i;
75
+ });
76
+ }
77
+ }), b = (s) => {
78
+ const i = a();
79
+ r = s.matches, a() !== i && (l(), m());
80
+ };
81
+ o?.addEventListener("change", b);
82
+ const u = typeof BroadcastChannel == "function" ? new BroadcastChannel(U) : null;
83
+ return u && (u.onmessage = (s) => {
84
+ const i = s.data;
85
+ !c(i) || i.toLowerCase() === n || (n = i.toLowerCase(), l(), m());
86
+ }), l(), {
87
+ getMode: () => n,
88
+ effectiveMode: a,
89
+ /**
90
+ * Set the user's mode: validate, persist to the `bs-theme-mode` cookie
91
+ * (renewed on every call, `Secure` on `https:`), write
92
+ * `<html data-bs-theme>`, notify subscribers and tell the other tabs.
93
+ *
94
+ * BsThemeService (libs/mintplayer-ng-bootstrap/theming) is a pure mirror of
95
+ * this store; any behaviour change here must be reflected there; pinned by
96
+ * bs-theme.service.spec.ts mirror tests.
97
+ */
98
+ setMode(s) {
99
+ if (!c(s)) {
100
+ j(s);
101
+ return;
102
+ }
103
+ const i = s.toLowerCase();
104
+ I(i, {
105
+ cookieDomain: t.cookieDomain,
106
+ secure: location.protocol === "https:"
107
+ }), i !== n && (n = i, l(), m(), u?.postMessage(i));
108
+ },
109
+ subscribe(s) {
110
+ return e.add(s), () => {
111
+ e.delete(s);
112
+ };
113
+ },
114
+ configure(s) {
115
+ t = { ...t, ...s };
116
+ },
117
+ dispose() {
118
+ o?.removeEventListener("change", b), u?.close(), e.clear();
119
+ }
120
+ };
121
+ }
122
+ function A() {
123
+ if (!T())
124
+ throw new Error(
125
+ "[bs-theme] getBsThemeStore() is browser-only. On a server, use resolveServerTheme() and injectThemeAttribute()."
126
+ );
127
+ const e = S();
128
+ return e[p] ??= q();
129
+ }
130
+ function h() {
131
+ return A();
132
+ }
133
+ function te(e) {
134
+ T() && A().configure(e);
135
+ }
136
+ function ne() {
137
+ const e = S();
138
+ e[p]?.dispose(), delete e[p];
139
+ }
140
+ const P = "M8 15A7 7 0 1 0 8 1zm0 1A8 8 0 1 1 8 0a8 8 0 0 1 0 16", K = "M8 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8M8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0m0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13m8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5M3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8m10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0m-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0m9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707M4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708", G = [
141
+ "M6 .278a.77.77 0 0 1 .08.858 7.2 7.2 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277q.792-.001 1.533-.16a.79.79 0 0 1 .81.316.73.73 0 0 1-.031.893A8.35 8.35 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.75.75 0 0 1 6 .278",
142
+ "M10.794 3.148a.217.217 0 0 1 .412 0l.387 1.162c.173.518.579.924 1.097 1.097l1.162.387a.217.217 0 0 1 0 .412l-1.162.387a1.73 1.73 0 0 0-1.097 1.097l-.387 1.162a.217.217 0 0 1-.412 0l-.387-1.162A1.73 1.73 0 0 0 9.31 6.593l-1.162-.387a.217.217 0 0 1 0-.412l1.162-.387a1.73 1.73 0 0 0 1.097-1.097zM13.863.099a.145.145 0 0 1 .274 0l.258.774c.115.346.386.617.732.732l.774.258a.145.145 0 0 1 0 .274l-.774.258a1.16 1.16 0 0 0-.732.732l-.258.774a.145.145 0 0 1-.274 0l-.258-.774a1.16 1.16 0 0 0-.732-.732l-.774-.258a.145.145 0 0 1 0-.274l.774-.258c.346-.115.617-.386.732-.732z"
143
+ ], f = Object.freeze([
144
+ Object.freeze({
145
+ mode: "auto",
146
+ label: "Switch to auto theme",
147
+ announcement: "Auto theme",
148
+ icon: P
149
+ }),
150
+ Object.freeze({
151
+ mode: "light",
152
+ label: "Switch to light theme",
153
+ announcement: "Light theme",
154
+ icon: K
155
+ }),
156
+ Object.freeze({
157
+ mode: "dark",
158
+ label: "Switch to dark theme",
159
+ announcement: "Dark theme",
160
+ icon: G
161
+ })
162
+ ]), J = C(`:host {
163
+ display: inline-block;
164
+ inline-size: 1.5em;
165
+ block-size: 1.5em;
166
+ vertical-align: middle;
167
+ line-height: 1;
168
+ }
169
+
170
+ :host([hidden]) {
171
+ display: none;
172
+ }
173
+
174
+ button {
175
+ display: flex;
176
+ align-items: center;
177
+ justify-content: center;
178
+ box-sizing: border-box;
179
+ inline-size: 100%;
180
+ block-size: 100%;
181
+ margin: 0;
182
+ padding: 0;
183
+ border: 0;
184
+ border-radius: var(--bs-border-radius-sm, 0.25rem);
185
+ background: none;
186
+ color: inherit;
187
+ font: inherit;
188
+ cursor: pointer;
189
+ outline: none;
190
+ }
191
+
192
+ button:focus-visible {
193
+ outline: 2px solid currentColor;
194
+ outline-offset: 2px;
195
+ }
196
+
197
+ svg {
198
+ display: block;
199
+ inline-size: 1.5em;
200
+ block-size: 1.5em;
201
+ fill: currentColor;
202
+ }
203
+
204
+ .visually-hidden {
205
+ position: absolute;
206
+ inline-size: 1px;
207
+ block-size: 1px;
208
+ margin: -1px;
209
+ padding: 0;
210
+ overflow: hidden;
211
+ clip: rect(0, 0, 0, 0);
212
+ white-space: nowrap;
213
+ border: 0;
214
+ }`), E = "current-theme";
215
+ function M() {
216
+ return typeof window < "u" && typeof document < "u" && !!document.documentElement;
217
+ }
218
+ function V(e) {
219
+ console.warn(
220
+ "[mp-theme-toggle] dropped a modes entry: its mode must match /^[a-z0-9-]{1,32}$/i.",
221
+ e
222
+ );
223
+ }
224
+ function X() {
225
+ console.warn("[mp-theme-toggle] modes has no usable entry; falling back to BS_THEME_DEFAULT_MODES.");
226
+ }
227
+ function y(e) {
228
+ return !!e && typeof e == "object" && c(e.mode);
229
+ }
230
+ class Y extends g {
231
+ constructor() {
232
+ super(...arguments), this._modes = f, this._currentMode = null, this._unsubscribe = null, this._announcer = new v(this, { politeness: "polite" });
233
+ }
234
+ static {
235
+ this.styles = [J];
236
+ }
237
+ static {
238
+ this.shadowRootOptions = {
239
+ ...g.shadowRootOptions,
240
+ delegatesFocus: !0
241
+ };
242
+ }
243
+ /** The cycle, in order. Property only: it has no attribute form. */
244
+ get modes() {
245
+ return this._modes;
246
+ }
247
+ /**
248
+ * `null`/`undefined` resets to `BS_THEME_DEFAULT_MODES`. So does a list with no
249
+ * usable entry (empty, or every entry invalid), with a warning: a toggle with
250
+ * zero modes would be a broken control.
251
+ */
252
+ set modes(t) {
253
+ if (t == null) {
254
+ this._modes = f, this.requestUpdate();
255
+ return;
256
+ }
257
+ const n = Array.isArray(t) ? t : [];
258
+ n.filter((r) => !y(r)).map(V);
259
+ const o = n.filter(y);
260
+ o.length === 0 && X(), this._modes = o.length > 0 ? o : f, this.requestUpdate();
261
+ }
262
+ connectedCallback() {
263
+ if (super.connectedCallback(), !M()) return;
264
+ const t = h();
265
+ this._unsubscribe = t.subscribe(() => this._syncFromStore()), this._syncFromStore();
266
+ }
267
+ disconnectedCallback() {
268
+ super.disconnectedCallback(), this._unsubscribe?.(), this._unsubscribe = null;
269
+ }
270
+ _syncFromStore() {
271
+ const t = h().getMode();
272
+ t !== this._currentMode && (this._currentMode = t, this.requestUpdate());
273
+ }
274
+ /** Index of the current mode in `modes`, or -1 when it is not in the list. */
275
+ _currentIndex() {
276
+ const t = this._currentMode?.toLowerCase() ?? null;
277
+ return this._modes.findIndex((n) => n.mode.toLowerCase() === t);
278
+ }
279
+ _entries() {
280
+ const t = this._modes.length;
281
+ if (t === 0) return null;
282
+ const n = this._currentIndex(), o = n < 0 ? 0 : n;
283
+ return { current: this._modes[o], next: this._modes[(o + 1) % t] };
284
+ }
285
+ _onClick() {
286
+ const t = this._entries();
287
+ !t || !M() || (h().setMode(t.next.mode), this._syncFromStore(), this._announcer.announce(t.next.announcement));
288
+ }
289
+ _renderIcon(t) {
290
+ const n = typeof t == "string" ? [t] : [...t];
291
+ return _`<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">${n.map(
292
+ (o) => k`<path d=${o}></path>`
293
+ )}</svg>`;
294
+ }
295
+ render() {
296
+ const t = this._entries();
297
+ if (!t) return L;
298
+ const { current: n, next: o } = t;
299
+ return _`
300
+ <button
301
+ type="button"
302
+ aria-label=${o.label}
303
+ aria-describedby=${E}
304
+ @click=${this._onClick}
305
+ >${this._renderIcon(n.icon)}</button>
306
+ <span id=${E} class="visually-hidden">${n.announcement}</span>
307
+ ${this._announcer.template()}
308
+ `;
309
+ }
310
+ }
311
+ typeof customElements < "u" && !customElements.get("mp-theme-toggle") && customElements.define("mp-theme-toggle", Y);
312
+ export {
313
+ d as BS_THEME_COOKIE_NAME,
314
+ f as BS_THEME_DEFAULT_MODES,
315
+ $ as BS_THEME_DEFAULT_MODE_META,
316
+ Y as MpThemeToggle,
317
+ ne as __resetBsThemeStoreForTests,
318
+ te as configureBsTheme,
319
+ h as getBsThemeStore,
320
+ ee as injectThemeAttribute,
321
+ c as isValidThemeMode,
322
+ F as readDefaultModeMeta,
323
+ w as readThemeCookie,
324
+ B as resolveMode,
325
+ Z as resolveServerTheme,
326
+ I as writeThemeCookie
327
+ };
@@ -0,0 +1,71 @@
1
+ import { LitElement, nothing, TemplateResult } from 'lit';
2
+ import { BsThemeToggleMode } from '../toggle-modes';
3
+ /**
4
+ * `<mp-theme-toggle>` — a button that cycles the document's colour mode
5
+ * through a list of modes (PRD dark-mode D7).
6
+ *
7
+ * Tier: shadow (it mounts no consumer DOM). no-JS: none (control requires
8
+ * script). There is no DSD chrome and nothing in codegen-ssr-chrome: a toggle
9
+ * cannot work without script and must never render enabled when it cannot
10
+ * function. No-JS visitors still get OS-following colours from the pre-boot
11
+ * script and the stylesheet. `color-mode.css` reserves the element's 1.5em box
12
+ * before it upgrades, so defining it causes no layout shift.
13
+ *
14
+ * State lives in the theme store (`getBsThemeStore()`), never here: the element
15
+ * subscribes on connect, unsubscribes on disconnect, and a click calls
16
+ * `setMode()`. Anything else that changes the mode (a framework service, another
17
+ * tab) re-renders it.
18
+ *
19
+ * `modes` (property only, default `BS_THEME_DEFAULT_MODES`) is the cycle, in
20
+ * array order. Entries whose `mode` fails `isValidThemeMode` are dropped with a
21
+ * warning; `null`, `undefined`, or a list with no usable entry falls back to
22
+ * the default, so the control is never left with nothing to cycle. A current mode that is not in the list shows entry 0 and cycles to
23
+ * entry 1. More than about three modes wants a menu (radio group) instead.
24
+ *
25
+ * Accessibility:
26
+ * - a native `<button type="button">`: Enter and Space cycle, no custom keymap;
27
+ * - its name is the NEXT entry's `label` (the action);
28
+ * - `aria-describedby` points at a visually hidden node in this shadow root
29
+ * holding the CURRENT entry's `announcement`, rewritten in the same render;
30
+ * - after a click the new entry's `announcement` goes out once through a
31
+ * polite live region (transient), while the description stays re-readable;
32
+ * - the icon is `aria-hidden` and `focusable="false"`.
33
+ */
34
+ export declare class MpThemeToggle extends LitElement {
35
+ static styles: import('lit').CSSResult[];
36
+ static shadowRootOptions: {
37
+ delegatesFocus: boolean;
38
+ clonable?: boolean;
39
+ customElementRegistry?: CustomElementRegistry | null;
40
+ mode: ShadowRootMode;
41
+ serializable?: boolean;
42
+ slotAssignment?: SlotAssignmentMode;
43
+ };
44
+ private _modes;
45
+ /** The store's mode, mirrored for rendering. `null` until connected in a browser. */
46
+ private _currentMode;
47
+ private _unsubscribe;
48
+ private readonly _announcer;
49
+ /** The cycle, in order. Property only: it has no attribute form. */
50
+ get modes(): readonly BsThemeToggleMode[];
51
+ /**
52
+ * `null`/`undefined` resets to `BS_THEME_DEFAULT_MODES`. So does a list with no
53
+ * usable entry (empty, or every entry invalid), with a warning: a toggle with
54
+ * zero modes would be a broken control.
55
+ */
56
+ set modes(value: readonly BsThemeToggleMode[] | null | undefined);
57
+ connectedCallback(): void;
58
+ disconnectedCallback(): void;
59
+ private _syncFromStore;
60
+ /** Index of the current mode in `modes`, or -1 when it is not in the list. */
61
+ private _currentIndex;
62
+ private _entries;
63
+ private _onClick;
64
+ private _renderIcon;
65
+ protected render(): TemplateResult | typeof nothing;
66
+ }
67
+ declare global {
68
+ interface HTMLElementTagNameMap {
69
+ 'mp-theme-toggle': MpThemeToggle;
70
+ }
71
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Theme cookie contract (PRD dark-mode D3). Pure and SSR-safe: nothing here
3
+ * touches `window` or `document` at module level.
4
+ *
5
+ * This module is bundled into the GENERATED `bs-theme-preboot.js` (ES5 IIFE),
6
+ * so it may only use ES5 runtime APIs: no `Array.prototype.find` / `includes`,
7
+ * no `String.prototype.startsWith`, no `Object.assign`. The build's acorn check
8
+ * catches ES2015+ syntax, not ES2015+ runtime calls.
9
+ */
10
+ /** Name of the cookie that persists the user's chosen theme mode. */
11
+ export declare const BS_THEME_COOKIE_NAME = "bs-theme-mode";
12
+ /** True when `value` is a syntactically valid theme mode (see the security invariant above). */
13
+ export declare function isValidThemeMode(value: unknown): value is string;
14
+ /**
15
+ * Read the theme mode from a `Cookie` header or `document.cookie` string.
16
+ * Takes the FIRST `bs-theme-mode=` pair only; an undecodable or invalid value
17
+ * counts as absent (`null`). The result is lower-cased.
18
+ */
19
+ export declare function readThemeCookie(cookieString: string | null | undefined): string | null;
20
+ export interface WriteThemeCookieOptions {
21
+ /** Passed through verbatim as `Domain=`; never derived. Omitted when not given. */
22
+ cookieDomain?: string;
23
+ /** Adds `Secure`; set it only when the page is served over `https:`. */
24
+ secure: boolean;
25
+ }
26
+ /**
27
+ * Persist `mode` in the theme cookie: `Path=/`, `SameSite=Lax`, one year,
28
+ * not HttpOnly (the pre-boot script and the store read it). An invalid mode is
29
+ * ignored. `doc` defaults to the global `document`; with neither, it is a no-op.
30
+ */
31
+ export declare function writeThemeCookie(mode: string, opts: WriteThemeCookieOptions, doc?: Document): void;
@@ -0,0 +1,5 @@
1
+ export * from './cookie';
2
+ export * from './resolve';
3
+ export * from './store';
4
+ export * from './toggle-modes';
5
+ export { MpThemeToggle } from './components/mp-theme-toggle';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ /** `<meta name="bs-theme-default-mode" content="dark">` declares the site's default mode (D5b). */
2
+ export declare const BS_THEME_DEFAULT_MODE_META = "bs-theme-default-mode";
3
+ /** The mode a user picked: `auto` follows `prefers-color-scheme`; any other valid mode is a custom theme. */
4
+ export type BsThemeMode = 'auto' | 'light' | 'dark' | (string & {});
5
+ /** The mode actually applied to `<html data-bs-theme>`: never `auto`. */
6
+ export type BsEffectiveThemeMode = 'light' | 'dark' | (string & {});
7
+ /** Resolve `auto` against the OS preference; every other mode passes through. */
8
+ export declare function resolveMode(mode: BsThemeMode, prefersDark: boolean): BsEffectiveThemeMode;
9
+ /**
10
+ * Read the declared default mode from `<meta name="bs-theme-default-mode">`.
11
+ * Absent or invalid → `null`. The result is lower-cased.
12
+ */
13
+ export declare function readDefaultModeMeta(doc: Document): string | null;
14
+ export interface ResolveServerThemeOptions {
15
+ /** The value of the `bs-theme-default-mode` meta, if the page declares one. */
16
+ defaultMode?: string | null;
17
+ }
18
+ /**
19
+ * The `data-bs-theme` value a server should render, or `null` for `auto`
20
+ * (render no attribute; the pre-boot script resolves it on the client).
21
+ *
22
+ * Precedence: a valid cookie wins, including a valid `auto` cookie over a
23
+ * non-auto default (the user's explicit choice beats the site default); then
24
+ * a valid `defaultMode`; then `auto`. An invalid cookie counts as absent.
25
+ *
26
+ * The result always satisfies the `isValidThemeMode` SECURITY INVARIANT, so it
27
+ * is safe to splice into markup.
28
+ */
29
+ export declare function resolveServerTheme(cookieHeader: string | null | undefined, opts?: ResolveServerThemeOptions): string | null;
30
+ /**
31
+ * Set `data-bs-theme="<mode>"` on the document's `<html ...>` open tag,
32
+ * keeping every other attribute (`lang`, `dir`, ...). Idempotent: an existing
33
+ * `data-bs-theme` is replaced, never duplicated. `null` (auto) or an invalid
34
+ * mode returns the markup unchanged; so does markup with no `<html>` tag.
35
+ */
36
+ export declare function injectThemeAttribute(html: string, mode: string | null): string;
@@ -0,0 +1,27 @@
1
+ import { BsEffectiveThemeMode, BsThemeMode } from './resolve';
2
+ export interface BsThemeStore {
3
+ /** The mode the user picked (`auto`, `light`, `dark` or a custom mode). */
4
+ getMode(): BsThemeMode;
5
+ /** The mode applied to `<html data-bs-theme>`: `auto` resolved against the OS preference. */
6
+ effectiveMode(): BsEffectiveThemeMode;
7
+ /** Set, persist and apply a mode. An invalid mode is a no-op with a warning. */
8
+ setMode(mode: BsThemeMode): void;
9
+ /** Called after every change of `getMode()` or `effectiveMode()`. Returns the unsubscribe. */
10
+ subscribe(listener: () => void): () => void;
11
+ }
12
+ export interface BsThemeConfig {
13
+ /** Passed through verbatim as the cookie's `Domain=`; never derived. */
14
+ cookieDomain?: string;
15
+ }
16
+ /**
17
+ * The document's theme store, created on first call. Browser-only: throws when
18
+ * there is no `window`/`document` (guard with a platform check on the server).
19
+ */
20
+ export declare function getBsThemeStore(): BsThemeStore;
21
+ /**
22
+ * Configure the store (the only runtime option is `cookieDomain`). A no-op on
23
+ * the server, where no store exists.
24
+ */
25
+ export declare function configureBsTheme(opts: BsThemeConfig): void;
26
+ /** Test-only: dispose the singleton (closing its BroadcastChannel) so the next access creates a fresh one. */
27
+ export declare function __resetBsThemeStoreForTests(): void;
@@ -0,0 +1,2 @@
1
+ export declare const themeToggleStyles: import('lit').CSSResult;
2
+ export default themeToggleStyles;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Test-only: an in-memory stand-in for `BroadcastChannel`.
3
+ *
4
+ * Node's real BroadcastChannel crosses worker threads in one process, so under
5
+ * `--pool=threads` a theme store in one spec file receives the modes another
6
+ * spec file's store posts on 'bs-theme-mode' (store.spec.ts flaked on exactly
7
+ * that). This fake lives in module state, and vitest gives every spec file its
8
+ * own module graph, so the channel is scoped to the file that installs it.
9
+ *
10
+ * It keeps the platform contract the store relies on: a post is delivered to
11
+ * every OTHER open channel of the same name, never to the sender, as a later
12
+ * task, as a structured clone; nothing is delivered to a closed channel, and
13
+ * posting on one throws. Every post is logged in `posted`, so a no-echo check
14
+ * can count posts instead of waiting for silence.
15
+ */
16
+ export declare class FakeBroadcastChannel {
17
+ #private;
18
+ readonly name: string;
19
+ static readonly open: Set<FakeBroadcastChannel>;
20
+ static readonly posted: {
21
+ name: string;
22
+ data: unknown;
23
+ }[];
24
+ onmessage: ((event: MessageEvent) => void) | null;
25
+ constructor(name: string);
26
+ postMessage(data: unknown): void;
27
+ close(): void;
28
+ /** Close every channel and forget the post log. */
29
+ static reset(): void;
30
+ }
31
+ /**
32
+ * Replace the global `BroadcastChannel` with the fake around every test of the
33
+ * calling spec file (or describe block), and reset it afterwards.
34
+ */
35
+ export declare function installFakeBroadcastChannel(): typeof FakeBroadcastChannel;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * One entry in `<mp-theme-toggle>`'s cycle (PRD dark-mode D7).
3
+ *
4
+ * - `mode` is what the toggle passes to `setMode()`; it must satisfy
5
+ * `isValidThemeMode`, or the entry is dropped.
6
+ * - `label` names the button while this entry is the NEXT one: it describes
7
+ * the action ("Switch to dark theme").
8
+ * - `announcement` names this entry while it is CURRENT ("Dark theme"). It is
9
+ * the button's description, and it is announced once after a click selects it.
10
+ * - `icon` is SVG path data for a 16x16 viewBox, one string per `<path>`.
11
+ */
12
+ export interface BsThemeToggleMode {
13
+ mode: string;
14
+ label: string;
15
+ announcement: string;
16
+ icon: string | readonly string[];
17
+ }
18
+ /**
19
+ * The default cycle: auto, then light, then dark. Localize by spreading it and
20
+ * overriding the strings, e.g.
21
+ * `BS_THEME_DEFAULT_MODES.map((m) => ({ ...m, label: t(m.label), announcement: t(m.announcement) }))`.
22
+ */
23
+ export declare const BS_THEME_DEFAULT_MODES: readonly BsThemeToggleMode[];