@mintplayer/react-bootstrap 19.24.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.
- package/chunks/react-props-iXE6Az5D.mjs +27 -0
- package/dropdown-menu/src/BsDropdownItem.d.ts +1 -1
- package/dropdown-menu/src/BsDropdownMenu.d.ts +2 -5
- package/dropdown-menu/src/index.d.ts +1 -1
- package/machine/index.mjs +1 -0
- package/machine/src/index.d.ts +2 -0
- package/machine/src/react-props.d.ts +20 -0
- package/machine/src/useMachine.d.ts +16 -0
- package/package.json +11 -2
- package/tile-manager/index.mjs +191 -14
- package/tile-manager/src/BsTileManager.d.ts +74 -19
- package/tile-manager/src/index.d.ts +3 -0
- package/typeahead/index.mjs +107 -0
- package/typeahead/src/BsTypeahead.d.ts +48 -0
- package/typeahead/src/index.d.ts +4 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useCallback as e, useEffect as t, useState as n, useSyncExternalStore as r } from "react";
|
|
2
|
+
//#region libs/mintplayer-react-bootstrap/machine/src/useMachine.ts
|
|
3
|
+
function i(t) {
|
|
4
|
+
let n = e((e) => t.subscribe(e), [t]), i = e(() => t.snapshot, [t]);
|
|
5
|
+
return r(n, i, i);
|
|
6
|
+
}
|
|
7
|
+
function a(e) {
|
|
8
|
+
let [r] = n(e);
|
|
9
|
+
return t(() => () => r.destroy(), [r]), [r, i(r)];
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region libs/mintplayer-react-bootstrap/machine/src/react-props.ts
|
|
13
|
+
var o = {
|
|
14
|
+
autocomplete: "autoComplete",
|
|
15
|
+
class: "className",
|
|
16
|
+
for: "htmlFor",
|
|
17
|
+
tabindex: "tabIndex",
|
|
18
|
+
readonly: "readOnly"
|
|
19
|
+
};
|
|
20
|
+
function s(e) {
|
|
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]));
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { i, c as n, a as r, s as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export interface BsDropdownItemProps extends Omit<React.LiHTMLAttributes<HTMLLIElement>, 'value'> {
|
|
3
|
-
/** Bootstrap `.active` appearance
|
|
3
|
+
/** Bootstrap `.active` appearance. */
|
|
4
4
|
active?: boolean;
|
|
5
5
|
/** Non-interactive; removed from the menu's roving order. */
|
|
6
6
|
disabled?: boolean;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { MpDropdownMenu,
|
|
1
|
+
import { MpDropdownMenu, DropdownSelectEventDetail } from '@mintplayer/web-components/dropdown-menu';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
export interface BsDropdownMenuProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onSelect'> {
|
|
4
|
-
/** `menu` (default, roving-tabindex keyboard nav) | `listbox`. */
|
|
5
|
-
mode?: DropdownMode;
|
|
6
4
|
/** px cap on the menu height; scrolls beyond. Maps to the `max-height` attribute. */
|
|
7
5
|
maxHeight?: number;
|
|
8
6
|
/** Fires when an enabled item is activated; `detail.value` carries the item's value. */
|
|
@@ -17,8 +15,7 @@ export interface BsDropdownMenuProps extends Omit<React.HTMLAttributes<HTMLEleme
|
|
|
17
15
|
* The menu chrome is server-rendered as Declarative Shadow DOM (see
|
|
18
16
|
* `injectMpDropdownDsd` in `@mintplayer/web-components/dropdown-menu/ssr`), so it
|
|
19
17
|
* renders styled with JavaScript disabled. Slot `<BsDropdownItem>` /
|
|
20
|
-
* `<BsDropdownDivider>` / `<BsDropdownHeader>` children.
|
|
21
|
-
* the menu provides roving-tabindex keyboard navigation over the enabled items.
|
|
18
|
+
* `<BsDropdownDivider>` / `<BsDropdownHeader>` children. The menu provides roving-tabindex keyboard navigation over the enabled items.
|
|
22
19
|
*
|
|
23
20
|
* <BsDropdownMenu onSelect={(e) => console.log(e.detail.value)}>
|
|
24
21
|
* <BsDropdownHeader>Section</BsDropdownHeader>
|
|
@@ -4,4 +4,4 @@ export { BsDropdownItem } from './BsDropdownItem';
|
|
|
4
4
|
export type { BsDropdownItemProps } from './BsDropdownItem';
|
|
5
5
|
export { BsDropdownDivider } from './BsDropdownDivider';
|
|
6
6
|
export { BsDropdownHeader } from './BsDropdownHeader';
|
|
7
|
-
export type {
|
|
7
|
+
export type { DropdownSelectEventDetail } from '@mintplayer/web-components/dropdown-menu';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as reactProps, n as reactStyle, r as useMachine, i as useSnapshot } from "../chunks/react-props-iXE6Az5D.mjs";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** An attribute bag as a `@mintplayer/ui-core` `connect()` returns it. */
|
|
2
|
+
export type AttrBag = Record<string, string | boolean | null>;
|
|
3
|
+
/**
|
|
4
|
+
* Turn a core's attribute bag into JSX props: `null` (attribute absent) is
|
|
5
|
+
* dropped and DOM names are mapped to React's. The React counterpart of the
|
|
6
|
+
* Angular `[mpProps]` directive and Lit's attribute bindings — every front
|
|
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 `''`.
|
|
12
|
+
*/
|
|
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;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SnapshotOf, Store } from '@mintplayer/ui-core/store';
|
|
2
|
+
/**
|
|
3
|
+
* Read a `@mintplayer/ui-core` store from a React component. Backed by
|
|
4
|
+
* `useSyncExternalStore`, so a committed snapshot re-renders the component
|
|
5
|
+
* once and never tears under concurrent rendering (spike S1,
|
|
6
|
+
* `_conformance/behaviour/useMachine.spec.tsx`). The server snapshot is the
|
|
7
|
+
* same object, which keeps SSR output and the first client render identical.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useSnapshot<S extends object>(store: Store<S>): S;
|
|
10
|
+
/**
|
|
11
|
+
* Own a machine for the lifetime of the component: created once, destroyed on
|
|
12
|
+
* unmount. Returns the machine and its live snapshot.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useMachine<M extends Store<object> & {
|
|
15
|
+
destroy(): void;
|
|
16
|
+
}>(create: () => M): [M, SnapshotOf<M>];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintplayer/react-bootstrap",
|
|
3
|
-
"version": "19.
|
|
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": {
|
|
@@ -90,6 +90,10 @@
|
|
|
90
90
|
"types": "./input-group/src/index.d.ts",
|
|
91
91
|
"import": "./input-group/index.mjs"
|
|
92
92
|
},
|
|
93
|
+
"./machine": {
|
|
94
|
+
"types": "./machine/src/index.d.ts",
|
|
95
|
+
"import": "./machine/index.mjs"
|
|
96
|
+
},
|
|
93
97
|
"./multi-range": {
|
|
94
98
|
"types": "./multi-range/src/index.d.ts",
|
|
95
99
|
"import": "./multi-range/index.mjs"
|
|
@@ -177,13 +181,18 @@
|
|
|
177
181
|
"./treeview": {
|
|
178
182
|
"types": "./treeview/src/index.d.ts",
|
|
179
183
|
"import": "./treeview/index.mjs"
|
|
184
|
+
},
|
|
185
|
+
"./typeahead": {
|
|
186
|
+
"types": "./typeahead/src/index.d.ts",
|
|
187
|
+
"import": "./typeahead/index.mjs"
|
|
180
188
|
}
|
|
181
189
|
},
|
|
182
190
|
"peerDependencies": {
|
|
191
|
+
"@mintplayer/ui-core": "^1.1.0",
|
|
183
192
|
"react": "^19.0.0",
|
|
184
193
|
"react-dom": "^19.0.0",
|
|
185
194
|
"@lit/react": "^1.0.0",
|
|
186
|
-
"@mintplayer/web-components": "^
|
|
195
|
+
"@mintplayer/web-components": "^3.0.0"
|
|
187
196
|
},
|
|
188
197
|
"dependencies": {
|
|
189
198
|
"tslib": "^2.3.0"
|
package/tile-manager/index.mjs
CHANGED
|
@@ -1,16 +1,193 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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 {
|
|
193
|
+
export { v as BsTileManager, g as withoutNarrowerLayouts };
|
|
@@ -1,23 +1,78 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
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
|
-
*
|
|
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
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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
|
|
17
|
-
|
|
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';
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { r as e, t } from "../chunks/react-props-iXE6Az5D.mjs";
|
|
2
|
+
import { useEffect as n, useId as r, useRef as i } from "react";
|
|
3
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
4
|
+
import { installLightStyles as s } from "@mintplayer/ui-core/scoped-styles";
|
|
5
|
+
import { TYPEAHEAD_SCOPE as c, TypeaheadMachine as l, connect as u, inMemoryTypeaheadProvider as d, typeaheadScopedStyles as f } from "@mintplayer/ui-core/typeahead";
|
|
6
|
+
//#region libs/mintplayer-react-bootstrap/typeahead/src/BsTypeahead.tsx
|
|
7
|
+
function p(d) {
|
|
8
|
+
let { provider: p, debounceMs: m, minLength: h, itemText: g, itemKey: _, renderItem: v, value: y, defaultValue: b, onValueChange: x, onSelect: S, onSubmit: C, onOpen: w, onClose: T, onLoadError: E, inputLabel: D, loadingLabel: O, noResultsLabel: k, resultsLabel: A, errorText: j, disabled: M, name: N, onKeyDown: P, onBlur: F, ...I } = d, L = i({
|
|
9
|
+
onValueChange: x,
|
|
10
|
+
onSelect: S,
|
|
11
|
+
onSubmit: C,
|
|
12
|
+
onOpen: w,
|
|
13
|
+
onClose: T,
|
|
14
|
+
onLoadError: E
|
|
15
|
+
});
|
|
16
|
+
L.current = {
|
|
17
|
+
onValueChange: x,
|
|
18
|
+
onSelect: S,
|
|
19
|
+
onSubmit: C,
|
|
20
|
+
onOpen: w,
|
|
21
|
+
onClose: T,
|
|
22
|
+
onLoadError: E
|
|
23
|
+
};
|
|
24
|
+
let R = `bs-typeahead-${r().replace(/[^a-zA-Z0-9_-]/g, "")}`, [z, B] = e(() => new l({
|
|
25
|
+
id: R,
|
|
26
|
+
value: y ?? b ?? "",
|
|
27
|
+
onChange: (e) => L.current.onValueChange?.(e),
|
|
28
|
+
onSelect: (e, t) => L.current.onSelect?.(e, t),
|
|
29
|
+
onSubmit: (e) => L.current.onSubmit?.(e),
|
|
30
|
+
onOpen: () => L.current.onOpen?.(),
|
|
31
|
+
onClose: () => L.current.onClose?.(),
|
|
32
|
+
onError: (e) => L.current.onLoadError?.(e)
|
|
33
|
+
}));
|
|
34
|
+
s(c, f), n(() => {
|
|
35
|
+
z.provider = p ?? null;
|
|
36
|
+
}, [z, p]), n(() => {
|
|
37
|
+
z.debounceMs = m;
|
|
38
|
+
}, [z, m]), n(() => {
|
|
39
|
+
z.minLength = h;
|
|
40
|
+
}, [z, h]), n(() => {
|
|
41
|
+
z.itemText = g, z.itemKey = _;
|
|
42
|
+
}, [
|
|
43
|
+
z,
|
|
44
|
+
g,
|
|
45
|
+
_
|
|
46
|
+
]), n(() => z.setDisabled(!!M), [z, M]), n(() => z.setErrorText(j), [z, j]), n(() => {
|
|
47
|
+
let e = { input: D ?? null };
|
|
48
|
+
O !== void 0 && (e.loading = O), k !== void 0 && (e.noResults = k), A !== void 0 && (e.results = A), z.setLabels(e);
|
|
49
|
+
}, [
|
|
50
|
+
z,
|
|
51
|
+
D,
|
|
52
|
+
O,
|
|
53
|
+
k,
|
|
54
|
+
A
|
|
55
|
+
]), n(() => {
|
|
56
|
+
y !== void 0 && y !== z.snapshot.term && z.setValue(y);
|
|
57
|
+
}, [z, y]);
|
|
58
|
+
let V = u(B, R, { name: N ?? null }), { value: H, ...U } = t(V.input);
|
|
59
|
+
return /* @__PURE__ */ o("div", {
|
|
60
|
+
className: "mp-typeahead",
|
|
61
|
+
...t(V.root),
|
|
62
|
+
children: [
|
|
63
|
+
/* @__PURE__ */ a("input", {
|
|
64
|
+
className: "form-control",
|
|
65
|
+
type: "text",
|
|
66
|
+
...U,
|
|
67
|
+
...I,
|
|
68
|
+
role: "combobox",
|
|
69
|
+
value: String(H ?? ""),
|
|
70
|
+
onChange: (e) => z.setTerm(e.target.value),
|
|
71
|
+
onKeyDown: (e) => {
|
|
72
|
+
P?.(e), !e.defaultPrevented && z.keydown(e.key, e) && e.preventDefault();
|
|
73
|
+
},
|
|
74
|
+
onBlur: (e) => {
|
|
75
|
+
F?.(e), z.blur();
|
|
76
|
+
}
|
|
77
|
+
}),
|
|
78
|
+
/* @__PURE__ */ o("ul", {
|
|
79
|
+
className: "dropdown-menu",
|
|
80
|
+
...t(V.listbox),
|
|
81
|
+
children: [V.status && /* @__PURE__ */ a("li", {
|
|
82
|
+
className: "ta-status",
|
|
83
|
+
...t(V.status.attrs),
|
|
84
|
+
children: V.status.text
|
|
85
|
+
}), B.items.map((e, n) => /* @__PURE__ */ a("li", {
|
|
86
|
+
className: "dropdown-item",
|
|
87
|
+
...t(V.option(n)),
|
|
88
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
89
|
+
onClick: () => z.pick(n),
|
|
90
|
+
children: v ? v(e, B.term) : z.itemTextOf(e)
|
|
91
|
+
}, (_ ? _(e) : z.itemTextOf(e)) || n))]
|
|
92
|
+
}),
|
|
93
|
+
/* @__PURE__ */ a("span", {
|
|
94
|
+
className: "visually-hidden",
|
|
95
|
+
...t(V.live.attrs),
|
|
96
|
+
children: V.live.text
|
|
97
|
+
}),
|
|
98
|
+
V.error && /* @__PURE__ */ a("div", {
|
|
99
|
+
className: "ta-error",
|
|
100
|
+
...t(V.error.attrs),
|
|
101
|
+
children: V.error.text
|
|
102
|
+
})
|
|
103
|
+
]
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
export { p as BsTypeahead, d as inMemoryTypeaheadProvider };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { TypeaheadProvider } from '@mintplayer/ui-core/typeahead';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
type InputAttributes = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultValue' | 'onChange' | 'onSelect' | 'onSubmit' | 'children' | 'role' | 'type'>;
|
|
4
|
+
export interface BsTypeaheadProps<T> extends InputAttributes {
|
|
5
|
+
/** Supplies suggestions for a settled term; a newer term aborts the previous request through `request.signal`. */
|
|
6
|
+
provider?: TypeaheadProvider<T> | null;
|
|
7
|
+
/** Quiet time after the last keystroke, ms (default 200). 0 requests synchronously. */
|
|
8
|
+
debounceMs?: number;
|
|
9
|
+
/** A trimmed term shorter than this closes the list without querying (default 1). */
|
|
10
|
+
minLength?: number;
|
|
11
|
+
/** The text a pick writes into the input. Default: `item.text`, else `String(item)`. */
|
|
12
|
+
itemText?: (item: T) => string;
|
|
13
|
+
/** Row identity for React keys. Default: `itemText`. */
|
|
14
|
+
itemKey?: (item: T) => React.Key;
|
|
15
|
+
/** Renders one suggestion row; receives the current term for highlighting. Default: the item text. */
|
|
16
|
+
renderItem?: (item: T, term: string) => React.ReactNode;
|
|
17
|
+
/** Controlled term. Pair with `onValueChange`. */
|
|
18
|
+
value?: string;
|
|
19
|
+
/** Uncontrolled initial term. */
|
|
20
|
+
defaultValue?: string;
|
|
21
|
+
/** The term changed by typing or by a pick. */
|
|
22
|
+
onValueChange?: (value: string) => void;
|
|
23
|
+
/** A suggestion was picked; `value` is the text written into the input. */
|
|
24
|
+
onSelect?: (item: T, value: string) => void;
|
|
25
|
+
/** Enter with no suggestion highlighted. */
|
|
26
|
+
onSubmit?: (value: string) => void;
|
|
27
|
+
onOpen?: () => void;
|
|
28
|
+
onClose?: () => void;
|
|
29
|
+
onLoadError?: (error: unknown) => void;
|
|
30
|
+
/** Accessible name of the input. An `aria-label` / `aria-labelledby` prop wins. */
|
|
31
|
+
inputLabel?: string;
|
|
32
|
+
loadingLabel?: string;
|
|
33
|
+
noResultsLabel?: string;
|
|
34
|
+
resultsLabel?: (count: number) => string;
|
|
35
|
+
/** A persistent validation message, wired to the input with aria-errormessage. */
|
|
36
|
+
errorText?: string | null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Typeahead: a text input with asynchronous suggestions and free text.
|
|
40
|
+
*
|
|
41
|
+
* A front of the headless `TypeaheadMachine` (`@mintplayer/ui-core/typeahead`,
|
|
42
|
+
* #436): React renders its own JSX from the machine's snapshot and spreads the
|
|
43
|
+
* core's ARIA bags, so it behaves and reads exactly like the Angular, Vue and
|
|
44
|
+
* web-component typeaheads. Consumer props land on the role-bearing `<input>`;
|
|
45
|
+
* `role` is not accepted, the input is a `combobox` by contract.
|
|
46
|
+
*/
|
|
47
|
+
export declare function BsTypeahead<T = unknown>(props: BsTypeaheadProps<T>): React.ReactElement;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { BsTypeahead } from './BsTypeahead';
|
|
2
|
+
export type { BsTypeaheadProps } from './BsTypeahead';
|
|
3
|
+
export { inMemoryTypeaheadProvider } from '@mintplayer/ui-core/typeahead';
|
|
4
|
+
export type { TypeaheadProvider, TypeaheadRequest, TypeaheadLabels } from '@mintplayer/ui-core/typeahead';
|