@mintplayer/react-bootstrap 19.20.0 → 19.21.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.
@@ -1,4 +1,4 @@
1
- import { jsx as a } from "react/jsx-runtime";
1
+ import { jsx as d } from "react/jsx-runtime";
2
2
  import * as n from "react";
3
3
  import { createComponent as f } from "@lit/react";
4
4
  import { MpDropdownMenu as u } from "@mintplayer/web-components/dropdown-menu";
@@ -9,8 +9,8 @@ const m = f({
9
9
  events: {
10
10
  onSelect: "select"
11
11
  }
12
- }), v = n.forwardRef(function({ maxHeight: e, ...o }, r) {
13
- return /* @__PURE__ */ a(
12
+ }), R = n.forwardRef(function({ maxHeight: e, ...o }, r) {
13
+ return /* @__PURE__ */ d(
14
14
  m,
15
15
  {
16
16
  ref: r,
@@ -18,29 +18,29 @@ const m = f({
18
18
  ...o
19
19
  }
20
20
  );
21
- }), R = n.forwardRef(
22
- function({ active: e, disabled: o, value: r, className: t, children: i, ...c }, l) {
21
+ }), v = n.forwardRef(
22
+ function({ active: e, disabled: o, value: r, className: t, children: i, ...c }, p) {
23
23
  const s = n.useRef(null);
24
- n.useImperativeHandle(l, () => s.current), n.useEffect(() => {
25
- s.current && (s.current.value = r);
24
+ n.useImperativeHandle(p, () => s.current), n.useEffect(() => {
25
+ s.current && (s.current.dropdownValue = r);
26
26
  }, [r]);
27
- const p = ["dropdown-item", e ? "active" : "", o ? "disabled" : "", t ?? ""].filter(Boolean).join(" ");
28
- return /* @__PURE__ */ a("li", { ref: s, className: p, "aria-disabled": o ? !0 : void 0, ...c, children: i });
27
+ const l = ["dropdown-item", e ? "active" : "", o ? "disabled" : "", t ?? ""].filter(Boolean).join(" ");
28
+ return /* @__PURE__ */ d("li", { ref: s, className: l, "aria-disabled": o ? !0 : void 0, ...c, children: i });
29
29
  }
30
30
  ), M = n.forwardRef(
31
31
  function({ className: e, ...o }, r) {
32
32
  const t = ["dropdown-divider", e ?? ""].filter(Boolean).join(" ");
33
- return /* @__PURE__ */ a("li", { ref: r, role: "separator", className: t, ...o });
33
+ return /* @__PURE__ */ d("li", { ref: r, role: "separator", className: t, ...o });
34
34
  }
35
35
  ), j = n.forwardRef(
36
36
  function({ className: e, children: o, ...r }, t) {
37
37
  const i = ["dropdown-header", e ?? ""].filter(Boolean).join(" ");
38
- return /* @__PURE__ */ a("li", { ref: t, className: i, ...r, children: o });
38
+ return /* @__PURE__ */ d("li", { ref: t, className: i, ...r, children: o });
39
39
  }
40
40
  );
41
41
  export {
42
42
  M as BsDropdownDivider,
43
43
  j as BsDropdownHeader,
44
- R as BsDropdownItem,
45
- v as BsDropdownMenu
44
+ v as BsDropdownItem,
45
+ R as BsDropdownMenu
46
46
  };
@@ -13,7 +13,9 @@ export interface BsDropdownItemProps extends Omit<React.LiHTMLAttributes<HTMLLIE
13
13
  * light-DOM `<li class="dropdown-item">` that the menu WC styles via its shadow
14
14
  * `::slotted(.dropdown-item)` rule. Put the navigable content inside, e.g.
15
15
  * `<BsDropdownItem><a href="/x">Action</a></BsDropdownItem>` (the companion
16
- * stylesheet resets the nested link). The opaque `value` is assigned as a `value`
17
- * property on the `<li>` so the menu can carry it in its `select` event.
16
+ * stylesheet resets the nested link). The opaque `value` is assigned as the
17
+ * `dropdownValue` property on the `<li>` so the menu can carry it in its `select`
18
+ * event — not as `value`, which `HTMLLIElement` owns as a native long (an object
19
+ * or a string written there becomes 0).
18
20
  */
19
21
  export declare const BsDropdownItem: React.ForwardRefExoticComponent<BsDropdownItemProps & React.RefAttributes<HTMLLIElement>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintplayer/react-bootstrap",
3
- "version": "19.20.0",
3
+ "version": "19.21.0",
4
4
  "description": "React 19 wrappers around @mintplayer/web-components. Each sub-entry maps one-to-one with a WC sub-entry and exposes typed React components via @lit/react's createComponent.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -150,6 +150,10 @@
150
150
  "types": "./tab-control/src/index.d.ts",
151
151
  "import": "./tab-control/index.mjs"
152
152
  },
153
+ "./theming": {
154
+ "types": "./theming/src/index.d.ts",
155
+ "import": "./theming/index.mjs"
156
+ },
153
157
  "./tile-manager": {
154
158
  "types": "./tile-manager/src/index.d.ts",
155
159
  "import": "./tile-manager/index.mjs"
@@ -179,7 +183,7 @@
179
183
  "react": "^19.0.0",
180
184
  "react-dom": "^19.0.0",
181
185
  "@lit/react": "^1.0.0",
182
- "@mintplayer/web-components": "^2.0.0"
186
+ "@mintplayer/web-components": "^2.17.0"
183
187
  },
184
188
  "dependencies": {
185
189
  "tslib": "^2.3.0"
@@ -0,0 +1,49 @@
1
+ import * as f from "react";
2
+ import { useSyncExternalStore as c, useMemo as d } from "react";
3
+ import { getBsThemeStore as s, resolveMode as M, MpThemeToggle as T, BS_THEME_DEFAULT_MODES as a } from "@mintplayer/web-components/theming";
4
+ import { BS_THEME_COOKIE_NAME as w, BS_THEME_DEFAULT_MODES as H, BS_THEME_DEFAULT_MODE_META as x, configureBsTheme as R, getBsThemeStore as j, injectThemeAttribute as F, isValidThemeMode as L, readDefaultModeMeta as N, readThemeCookie as U, resolveMode as k, resolveServerTheme as y, writeThemeCookie as V } from "@mintplayer/web-components/theming";
5
+ import { jsx as E } from "react/jsx-runtime";
6
+ import { createComponent as h } from "@lit/react";
7
+ const m = Object.freeze({
8
+ mode: "auto",
9
+ effectiveMode: M("auto", !1)
10
+ }), n = () => typeof window < "u", u = (e) => n() ? s().subscribe(e) : () => {
11
+ };
12
+ let r = m;
13
+ const S = () => {
14
+ if (!n()) return m;
15
+ const e = s(), o = e.getMode(), t = e.effectiveMode();
16
+ return (r.mode !== o || r.effectiveMode !== t) && (r = { mode: o, effectiveMode: t }), r;
17
+ }, g = () => m, p = (e) => {
18
+ n() && s().setMode(e);
19
+ };
20
+ function D() {
21
+ const e = c(u, S, g);
22
+ return d(
23
+ () => ({ mode: e.mode, effectiveMode: e.effectiveMode, setMode: p }),
24
+ [e]
25
+ );
26
+ }
27
+ const l = h({
28
+ react: f,
29
+ tagName: "mp-theme-toggle",
30
+ elementClass: T
31
+ }), O = f.forwardRef(function({ modes: o, ...t }, i) {
32
+ return /* @__PURE__ */ E(l, { ref: i, modes: o ?? a, ...t });
33
+ });
34
+ export {
35
+ w as BS_THEME_COOKIE_NAME,
36
+ H as BS_THEME_DEFAULT_MODES,
37
+ x as BS_THEME_DEFAULT_MODE_META,
38
+ O as BsThemeToggle,
39
+ R as configureBsTheme,
40
+ j as getBsThemeStore,
41
+ F as injectThemeAttribute,
42
+ L as isValidThemeMode,
43
+ N as readDefaultModeMeta,
44
+ U as readThemeCookie,
45
+ k as resolveMode,
46
+ y as resolveServerTheme,
47
+ D as useBsTheme,
48
+ V as writeThemeCookie
49
+ };
@@ -0,0 +1,22 @@
1
+ import { MpThemeToggle, BsThemeToggleMode } from '@mintplayer/web-components/theming';
2
+ import * as React from 'react';
3
+ export interface BsThemeToggleProps extends React.HTMLAttributes<MpThemeToggle> {
4
+ /**
5
+ * The modes the toggle cycles through, in order. Defaults to
6
+ * `BS_THEME_DEFAULT_MODES` (auto, light, dark). Assigned to the element as a
7
+ * JS property: an array cannot travel as an attribute.
8
+ */
9
+ modes?: readonly BsThemeToggleMode[];
10
+ }
11
+ /**
12
+ * React wrapper for `<mp-theme-toggle>`, the colour-mode toggle button.
13
+ * Side-effect-registers the WC on import.
14
+ *
15
+ * The toggle talks to the shared theme store itself, so it needs no props to
16
+ * work; read or drive the same state from code with `useBsTheme()`. Any other
17
+ * prop (`aria-label`, `id`, `className`, ...) is forwarded to the element.
18
+ *
19
+ * <BsThemeToggle />
20
+ * <BsThemeToggle modes={[...BS_THEME_DEFAULT_MODES, sepia]} />
21
+ */
22
+ export declare const BsThemeToggle: React.ForwardRefExoticComponent<BsThemeToggleProps & React.RefAttributes<MpThemeToggle>>;
@@ -0,0 +1,3 @@
1
+ export { useBsTheme, type UseBsThemeResult } from './useBsTheme';
2
+ export { BsThemeToggle, type BsThemeToggleProps } from './BsThemeToggle';
3
+ export { BS_THEME_COOKIE_NAME, BS_THEME_DEFAULT_MODE_META, BS_THEME_DEFAULT_MODES, configureBsTheme, getBsThemeStore, injectThemeAttribute, isValidThemeMode, readDefaultModeMeta, readThemeCookie, resolveMode, resolveServerTheme, writeThemeCookie, type BsEffectiveThemeMode, type BsThemeConfig, type BsThemeMode, type BsThemeStore, type BsThemeToggleMode, type ResolveServerThemeOptions, type WriteThemeCookieOptions, } from '@mintplayer/web-components/theming';
@@ -0,0 +1,19 @@
1
+ import { BsEffectiveThemeMode, BsThemeMode } from '@mintplayer/web-components/theming';
2
+ export interface UseBsThemeResult {
3
+ /** The mode the user picked: `auto`, `light`, `dark` or a custom mode. */
4
+ mode: 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; a no-op on the server. */
8
+ setMode: (mode: BsThemeMode) => void;
9
+ }
10
+ /**
11
+ * The document's colour mode, backed by the shared browser store
12
+ * (`@mintplayer/web-components/theming`). Re-renders when the mode changes
13
+ * from anywhere: this hook, a `<BsThemeToggle>`, another framework's adapter
14
+ * on the same page, another tab, or the OS preference while in `auto`.
15
+ *
16
+ * SSR-safe: on the server the store is never touched and the hook returns
17
+ * the server snapshot documented on `SERVER_SNAPSHOT`.
18
+ */
19
+ export declare function useBsTheme(): UseBsThemeResult;