@mintplayer/react-bootstrap 19.25.0 → 19.26.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.
@@ -18,7 +18,10 @@ var o = {
18
18
  readonly: "readOnly"
19
19
  };
20
20
  function s(e) {
21
- return Object.fromEntries(Object.entries(e).filter((e) => e[1] !== null).map(([e, t]) => [o[e] ?? e, t]));
21
+ return Object.fromEntries(Object.entries(e).filter((e) => e[1] !== null).map(([e, t]) => [o[e] ?? e, t === !0 && e.includes("-") ? "" : t]));
22
+ }
23
+ function c(e) {
24
+ return Object.fromEntries(Object.entries(e).filter((e) => e[1] !== null).map(([e, t]) => [e.startsWith("--") ? e : e.replace(/-([a-z])/g, (e, t) => t.toUpperCase()), t]));
22
25
  }
23
26
  //#endregion
24
- export { a as n, i as r, s as t };
27
+ export { i, c as n, a as r, s as t };
package/machine/index.mjs CHANGED
@@ -1 +1 @@
1
- export { t as reactProps, n as useMachine, r as useSnapshot } from "../chunks/react-props-CKk_Kufi.mjs";
1
+ export { t as reactProps, n as reactStyle, r as useMachine, i as useSnapshot } from "../chunks/react-props-iXE6Az5D.mjs";
@@ -5,5 +5,16 @@ export type AttrBag = Record<string, string | boolean | null>;
5
5
  * dropped and DOM names are mapped to React's. The React counterpart of the
6
6
  * Angular `[mpProps]` directive and Lit's attribute bindings — every front
7
7
  * applies the same bag, so ARIA cannot drift between them.
8
+ *
9
+ * `true` means present-and-empty. React stringifies it on a hyphenated
10
+ * (`data-*`, `aria-*`) attribute, so those get `''`; a known boolean property
11
+ * (`hidden`, `inert`) keeps `true`, because React drops it when given `''`.
8
12
  */
9
13
  export declare function reactProps(bag: AttrBag): Record<string, string | boolean>;
14
+ /** A style bag as a core's `connect()` returns it: CSS property names, `null` = unset. */
15
+ export type StyleBag = Record<string, string | null>;
16
+ /**
17
+ * Turn a core's style bag into a React `style` object: `null` is dropped and
18
+ * `grid-column` becomes `gridColumn`. Custom properties (`--x`) keep their name.
19
+ */
20
+ export declare function reactStyle(bag: StyleBag): React.CSSProperties;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintplayer/react-bootstrap",
3
- "version": "19.25.0",
3
+ "version": "19.26.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": {
@@ -188,11 +188,11 @@
188
188
  }
189
189
  },
190
190
  "peerDependencies": {
191
- "@mintplayer/ui-core": "^1.0.0",
191
+ "@mintplayer/ui-core": "^1.1.0",
192
192
  "react": "^19.0.0",
193
193
  "react-dom": "^19.0.0",
194
194
  "@lit/react": "^1.0.0",
195
- "@mintplayer/web-components": "^2.21.0"
195
+ "@mintplayer/web-components": "^3.0.0"
196
196
  },
197
197
  "dependencies": {
198
198
  "tslib": "^2.3.0"
@@ -1,16 +1,193 @@
1
- import * as e from "react";
2
- import { createComponent as t } from "@lit/react";
3
- import { MintTileManagerElement as n } from "@mintplayer/web-components/tile-manager";
1
+ import { n as e, r as t, t as n } from "../chunks/react-props-iXE6Az5D.mjs";
2
+ import { useEffect as r, useId as i, useImperativeHandle as a, useLayoutEffect as o, useMemo as s, useRef as c } from "react";
3
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
4
+ import { installLightStyles as ee } from "@mintplayer/ui-core/scoped-styles";
5
+ import { DEFAULT_GAP as te, DEFAULT_MIN_COLUMN_WIDTH as ne, TILE_MANAGER_SCOPE as d, TileFlip as re, TileManagerMachine as ie, breakpointCss as f, connect as p, gridPointer as m, readCellMetrics as h, tileManagerScopedStyles as ae, withoutNarrowerLayouts as g } from "@mintplayer/ui-core/tile-manager";
4
6
  //#region libs/mintplayer-react-bootstrap/tile-manager/src/BsTileManager.tsx
5
- var r = t({
6
- react: e,
7
- tagName: "mp-tile-manager",
8
- elementClass: n,
9
- events: {
10
- onTilelayoutchange: "tilelayoutchange",
11
- onTilepositionchange: "tilepositionchange",
12
- onTilegestureblocked: "tilegestureblocked"
13
- }
14
- });
7
+ var _ = {};
8
+ function v(g) {
9
+ let { ref: v, tiles: y, renderHeader: oe, renderContent: se, layouts: b, defaultLayouts: x, onLayoutsChange: S, breakpoints: C = null, stackBelow: w = null, maxColumns: T = 6, minColumnWidth: E = ne, minRowHeight: D = "8rem", gap: O = te, dragMode: k = "header", resizeMode: A = "hover", animateReflow: j = !0, label: M = null, messages: N = _, onLayoutPreview: P, onLayoutChange: F, onColumnCountChange: I, onGestureBlocked: L, className: R, style: z, "aria-describedby": B, ...V } = g, H = c({
10
+ onLayoutsChange: S,
11
+ onLayoutPreview: P,
12
+ onLayoutChange: F,
13
+ onColumnCountChange: I,
14
+ onGestureBlocked: L
15
+ });
16
+ H.current = {
17
+ onLayoutsChange: S,
18
+ onLayoutPreview: P,
19
+ onLayoutChange: F,
20
+ onColumnCountChange: I,
21
+ onGestureBlocked: L
22
+ };
23
+ let U = c(j);
24
+ U.current = j;
25
+ let W = `bs-tile-manager-${i().replace(/[^a-zA-Z0-9_-]/g, "")}`, [G, K] = t(() => {
26
+ let e = new ie({ vibrate: (e) => navigator.vibrate?.(e) });
27
+ return e.setInputs({
28
+ tiles: y,
29
+ layouts: b ?? x ?? {},
30
+ breakpoints: C,
31
+ stackBelow: w,
32
+ maxColumns: T,
33
+ minColumnWidth: E,
34
+ minRowHeight: D,
35
+ gap: O,
36
+ dragMode: k,
37
+ resizeMode: A,
38
+ label: M,
39
+ messages: N
40
+ }), e;
41
+ });
42
+ ee(d, ae), r(() => G.setInputs({ tiles: y }), [G, y]), r(() => G.setInputs({ breakpoints: C }), [G, C]), r(() => G.setInputs({ stackBelow: w }), [G, w]), r(() => G.setInputs({ maxColumns: T }), [G, T]), r(() => G.setInputs({ minColumnWidth: E }), [G, E]), r(() => G.setInputs({ minRowHeight: D }), [G, D]), r(() => G.setInputs({ gap: O }), [G, O]), r(() => G.setInputs({ dragMode: k }), [G, k]), r(() => G.setInputs({ resizeMode: A }), [G, A]), r(() => G.setInputs({ label: M }), [G, M]), r(() => G.setInputs({ messages: N }), [G, N]), r(() => {
43
+ b !== void 0 && b !== G.snapshot.layouts && G.setInputs({ layouts: b });
44
+ }, [G, b]), r(() => G.onEvent((e) => {
45
+ let { type: t, ...n } = e;
46
+ switch (t) {
47
+ case "layoutchange": {
48
+ let e = n;
49
+ H.current.onLayoutsChange?.(e.layouts), H.current.onLayoutChange?.(e);
50
+ break;
51
+ }
52
+ case "layoutpreview":
53
+ H.current.onLayoutPreview?.(n);
54
+ break;
55
+ case "columncountchange":
56
+ H.current.onColumnCountChange?.(n);
57
+ break;
58
+ case "gestureblocked": H.current.onGestureBlocked?.(n);
59
+ }
60
+ }), [G]);
61
+ let q = c(null), J = c(null), Y = s(() => new re(), []), X = c({
62
+ flip: !1,
63
+ focusSeq: 0,
64
+ lastRendered: null
65
+ });
66
+ r(() => G.subscribe(() => {
67
+ let e = G.rendered;
68
+ if (e === X.current.lastRendered) return;
69
+ X.current.lastRendered = e;
70
+ let t = q.current;
71
+ t && U.current && G.snapshot.measured && (Y.first(t), X.current.flip = !0);
72
+ }), [G, Y]), o(() => {
73
+ let e = q.current;
74
+ if (X.current.flip && e && (X.current.flip = !1, Y.play(e, K.gesture.kind === "drag" ? K.gesture.tileId : null)), K.focusRequest && K.focusRequest.seq !== X.current.focusSeq) {
75
+ X.current.focusSeq = K.focusRequest.seq;
76
+ let e = K.focusRequest.tileId;
77
+ Array.from(J.current?.querySelectorAll("[data-tile-id]") ?? []).find((t) => t.dataset.tileId === e)?.focus();
78
+ }
79
+ }, [K, Y]), r(() => {
80
+ let e = q.current;
81
+ if (!e || typeof ResizeObserver > "u") return;
82
+ let t = 0, n = 0, r = new ResizeObserver((e) => {
83
+ let r = e[e.length - 1];
84
+ n = r.contentBoxSize?.[0]?.inlineSize ?? r.contentRect.width, !t && (t = requestAnimationFrame(() => {
85
+ t = 0, G.measure(n);
86
+ }));
87
+ });
88
+ r.observe(e);
89
+ let i = () => {
90
+ document.visibilityState === "hidden" && G.cancelGesture();
91
+ };
92
+ return document.addEventListener("visibilitychange", i), () => {
93
+ r.disconnect(), cancelAnimationFrame(t), document.removeEventListener("visibilitychange", i);
94
+ };
95
+ }, [G]), a(v, () => ({
96
+ captureLayout: () => ({
97
+ columnCount: G.snapshot.columnCount,
98
+ layout: G.rendered.map((e) => ({
99
+ id: e.id,
100
+ position: { ...e.position }
101
+ }))
102
+ }),
103
+ resetLayout: (e) => G.resetLayout(e),
104
+ get isGestureActive() {
105
+ let e = G.snapshot.gesture.kind;
106
+ return e === "drag" || e === "resize";
107
+ }
108
+ }), [G]);
109
+ let Z = (e, t, n) => {
110
+ let r = q.current;
111
+ r && G.pointerDown(t, n, m(e.nativeEvent, r), h(r, G.snapshot.columnCount)) === "capture" && (e.preventDefault(), e.currentTarget.closest("[data-tile-id]")?.setPointerCapture(e.pointerId));
112
+ }, ce = (e) => {
113
+ let t = q.current;
114
+ t && G.pointerMove(m(e.nativeEvent, t)) === "capture" && e.currentTarget.setPointerCapture(e.pointerId);
115
+ }, Q = p(G, W), le = s(() => new Map(y.map((e) => [e.id, e])), [y]), $ = s(() => K.measured ? null : f(K.layouts, K.tiles, K, W), [K, W]), { class: ue, "aria-describedby": de, ...fe } = Q.board.attrs;
116
+ return /* @__PURE__ */ u("div", {
117
+ ref: J,
118
+ ...n(fe),
119
+ ...V,
120
+ className: [
121
+ "mp-tile-manager",
122
+ ue,
123
+ R
124
+ ].filter(Boolean).join(" "),
125
+ role: "region",
126
+ "aria-describedby": [de, B].filter(Boolean).join(" ") || void 0,
127
+ style: {
128
+ ...e(Q.board.style),
129
+ ...z
130
+ },
131
+ children: [
132
+ $ && /* @__PURE__ */ l("style", { children: $ }),
133
+ /* @__PURE__ */ l("div", {
134
+ className: "tile-container",
135
+ ...n(Q.container),
136
+ children: /* @__PURE__ */ l("div", {
137
+ ref: q,
138
+ className: "tile-grid",
139
+ ...n(Q.grid.attrs),
140
+ style: e(Q.grid.style),
141
+ children: Q.tiles.map((t) => {
142
+ let r = le.get(t.id);
143
+ return /* @__PURE__ */ u("div", {
144
+ className: "tile",
145
+ ...n(t.attrs),
146
+ style: e(t.style),
147
+ onPointerDown: (e) => Z(e, t.id, "body"),
148
+ onPointerMove: ce,
149
+ onPointerUp: (e) => G.pointerUp(e.nativeEvent),
150
+ onPointerCancel: (e) => G.pointerCancel(e.nativeEvent),
151
+ onLostPointerCapture: (e) => G.pointerCancel(e.nativeEvent),
152
+ onKeyDown: (e) => {
153
+ G.keydown(t.id, e.key, { shift: e.shiftKey }) && e.preventDefault();
154
+ },
155
+ onFocus: (e) => e.target === e.currentTarget && G.focus(t.id),
156
+ onBlur: (e) => e.target === e.currentTarget && G.blur(t.id),
157
+ children: [
158
+ /* @__PURE__ */ l("div", {
159
+ className: "tile-header",
160
+ ...n(t.header),
161
+ onPointerDown: (e) => Z(e, t.id, "header"),
162
+ children: r && oe?.(r)
163
+ }),
164
+ /* @__PURE__ */ l("div", {
165
+ className: "tile-content",
166
+ ...n(t.content),
167
+ children: r && se?.(r)
168
+ }),
169
+ t.grips.map((e) => /* @__PURE__ */ l("span", {
170
+ className: "tile-grip",
171
+ ...n(e.attrs),
172
+ onPointerDown: (n) => Z(n, t.id, e.handle)
173
+ }, e.handle))
174
+ ]
175
+ }, t.id);
176
+ })
177
+ })
178
+ }),
179
+ Q.descriptions.map((e) => /* @__PURE__ */ l("div", {
180
+ className: "tile-sr-only",
181
+ ...n(e.attrs),
182
+ children: e.text
183
+ }, e.key)),
184
+ /* @__PURE__ */ l("span", {
185
+ className: "tile-sr-only",
186
+ ...n(Q.live.attrs),
187
+ children: Q.live.text
188
+ })
189
+ ]
190
+ });
191
+ }
15
192
  //#endregion
16
- export { r as BsTileManager };
193
+ export { v as BsTileManager, g as withoutNarrowerLayouts };
@@ -1,23 +1,78 @@
1
- import { EventName } from '@lit/react';
2
- import { MintTileManagerElement, TileLayoutSnapshot, TileGestureBlocked, TilePosition } from '@mintplayer/web-components/tile-manager';
1
+ import { MintTile, TileBreakpoint, TileDragMode, TileGestureBlocked, TileLayoutChange, TileLayouts, TileLayoutSnapshot, TileManagerMessages, TileResizeMode } from '@mintplayer/ui-core/tile-manager';
2
+ import * as React from 'react';
3
+ /** Payload of `onColumnCountChange`. */
4
+ export interface BsTileColumnCountChange {
5
+ columnCount: number;
6
+ previous: number | null;
7
+ }
8
+ /** What a `ref` on `<BsTileManager>` exposes. */
9
+ export interface BsTileManagerHandle {
10
+ /** What is rendered: the resolved column count and its layout (the preview while editing). */
11
+ captureLayout(): {
12
+ columnCount: number;
13
+ layout: TileLayoutSnapshot;
14
+ };
15
+ /** Drops `layouts[count]` and commits, so that count derives again (D15). */
16
+ resetLayout(count: number): void;
17
+ /** True while a pointer drag or resize is in flight. */
18
+ readonly isGestureActive: boolean;
19
+ }
20
+ type BoardAttributes = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'role' | 'defaultValue'>;
21
+ export interface BsTileManagerProps<T extends MintTile = MintTile> extends BoardAttributes {
22
+ ref?: React.Ref<BsTileManagerHandle>;
23
+ /** The visible tiles, in DOM order. */
24
+ tiles: readonly T[];
25
+ /** Renders a tile's header. */
26
+ renderHeader?: (tile: T) => React.ReactNode;
27
+ /** Renders a tile's body. */
28
+ renderContent?: (tile: T) => React.ReactNode;
29
+ /** Controlled: one layout per column count. Pair with `onLayoutsChange`. */
30
+ layouts?: TileLayouts;
31
+ /** Uncontrolled initial layouts. */
32
+ defaultLayouts?: TileLayouts;
33
+ /** A commit wrote the full next layouts record. */
34
+ onLayoutsChange?: (layouts: TileLayouts) => void;
35
+ /** Explicit `{ minWidth, columns }` map. Wins over `stackBelow` and the generated map. */
36
+ breakpoints?: readonly TileBreakpoint[] | null;
37
+ /** px. Below this width the tiles stack in one column. */
38
+ stackBelow?: number | null;
39
+ /** Upper bound of the generated map when `layouts` is empty. */
40
+ maxColumns?: number;
41
+ /** px. No column is narrower than this, except at one column. */
42
+ minColumnWidth?: number;
43
+ /** CSS length of one grid row. */
44
+ minRowHeight?: string;
45
+ /** px between tiles. */
46
+ gap?: number;
47
+ dragMode?: TileDragMode;
48
+ resizeMode?: TileResizeMode;
49
+ /** Animate tiles to their new place when the layout reflows. Off under reduced motion. */
50
+ animateReflow?: boolean;
51
+ /** Accessible name of the board. An `aria-label` / `aria-labelledby` prop wins. */
52
+ label?: string | null;
53
+ /** Localized strings for the board's descriptions and announcements. */
54
+ messages?: Partial<TileManagerMessages>;
55
+ /** Each step of a gesture or keyboard move: the layout as it would be committed. */
56
+ onLayoutPreview?: (change: TileLayoutChange) => void;
57
+ /** A commit, with the full layouts record and the stale narrower counts (D15). */
58
+ onLayoutChange?: (change: TileLayoutChange) => void;
59
+ onColumnCountChange?: (change: BsTileColumnCountChange) => void;
60
+ onGestureBlocked?: (blocked: TileGestureBlocked) => void;
61
+ }
3
62
  /**
4
- * React wrapper for `<mp-tile-manager>`. Side-effect-registers the WC.
63
+ * Tile manager: a dashboard grid whose tiles the user moves and resizes, with one layout per
64
+ * column count (#440).
5
65
  *
6
- * The WC takes a `.tiles` JS prop (array of `{id, position, disableMove?,
7
- * disableResize?, label?}`) and projects each tile's header + body into
8
- * `${id}-header` / `${id}-content` named slots. Consumers render slot
9
- * content as light-DOM children:
66
+ * The React front of `TileManagerMachine` (`@mintplayer/ui-core/tile-manager`). Every decision
67
+ * (layout per column count, gestures, keyboard, ARIA) is the machine's; this component renders
68
+ * its own JSX from `connect()`'s bags, measures the grid, owns pointer capture and the FLIP
69
+ * animation, and turns the machine's events into callbacks. Consumer props land on the board,
70
+ * whose `region` role is part of the contract.
10
71
  *
11
- * <BsTileManager tiles={[{id:'t1', position:{...}}]}>
12
- * <div slot="t1-header">Title</div>
13
- * <div slot="t1-content">Body</div>
14
- * </BsTileManager>
72
+ * SSR: until the first measure the board carries a `<style>` with the `@container` rules that
73
+ * place every tile at every column count (D14), so the server HTML paints the right layout with
74
+ * no JS. No-JS tier 2: before the first measure the tiles are named groups with no tab stop or
75
+ * grips.
15
76
  */
16
- export declare const BsTileManager: import('@lit/react').ReactWebComponent<MintTileManagerElement, {
17
- onTilelayoutchange: EventName<CustomEvent<TileLayoutSnapshot>>;
18
- onTilepositionchange: EventName<CustomEvent<{
19
- id: string;
20
- position: TilePosition;
21
- }>>;
22
- onTilegestureblocked: EventName<CustomEvent<TileGestureBlocked>>;
23
- }>;
77
+ export declare function BsTileManager<T extends MintTile = MintTile>(props: BsTileManagerProps<T>): React.ReactElement;
78
+ export {};
@@ -1 +1,4 @@
1
1
  export { BsTileManager } from './BsTileManager';
2
+ export type { BsTileManagerProps, BsTileManagerHandle, BsTileColumnCountChange } from './BsTileManager';
3
+ export type { MintTile, TileBreakpoint, TileDragMode, TileGestureBlocked, TileLayoutChange, TileLayouts, TileLayoutSnapshot, TileManagerMessages, TilePosition, TileResizeMode, TileSize, } from '@mintplayer/ui-core/tile-manager';
4
+ export { withoutNarrowerLayouts } from '@mintplayer/ui-core/tile-manager';
@@ -1,4 +1,4 @@
1
- import { n as e, t } from "../chunks/react-props-CKk_Kufi.mjs";
1
+ import { r as e, t } from "../chunks/react-props-iXE6Az5D.mjs";
2
2
  import { useEffect as n, useId as r, useRef as i } from "react";
3
3
  import { jsx as a, jsxs as o } from "react/jsx-runtime";
4
4
  import { installLightStyles as s } from "@mintplayer/ui-core/scoped-styles";