@mintplayer/react-bootstrap 19.24.0 → 19.25.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-CKk_Kufi.mjs +24 -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 +9 -0
- package/machine/src/useMachine.d.ts +16 -0
- package/package.json +11 -2
- 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,24 @@
|
|
|
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]));
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { a as n, i 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 useMachine, r as useSnapshot } from "../chunks/react-props-CKk_Kufi.mjs";
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
export declare function reactProps(bag: AttrBag): Record<string, string | boolean>;
|
|
@@ -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.25.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.0.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": "^2.
|
|
195
|
+
"@mintplayer/web-components": "^2.21.0"
|
|
187
196
|
},
|
|
188
197
|
"dependencies": {
|
|
189
198
|
"tslib": "^2.3.0"
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { n as e, t } from "../chunks/react-props-CKk_Kufi.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';
|