@mintplayer/react-bootstrap 19.23.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/accordion/index.mjs +38 -58
- package/calendar/index.mjs +9 -9
- package/card/index.mjs +102 -67
- package/card/src/BsCardBody.d.ts +2 -2
- package/card/src/BsCardFooter.d.ts +2 -2
- package/card/src/BsCardGroup.d.ts +4 -3
- package/card/src/BsCardHeader.d.ts +2 -2
- package/card/src/BsCardImg.d.ts +1 -1
- package/card/src/BsCardLink.d.ts +2 -2
- package/card/src/BsCardSubtitle.d.ts +2 -2
- package/card/src/BsCardText.d.ts +2 -2
- package/card/src/BsCardTitle.d.ts +2 -2
- package/carousel/index.mjs +27 -30
- package/charts/hierarchy/index.mjs +16 -16
- package/charts/sparkline/index.mjs +9 -9
- package/charts/trend/index.mjs +12 -12
- package/checkbox/index.mjs +10 -12
- package/chunks/react-props-CKk_Kufi.mjs +24 -0
- package/code-snippet/index.mjs +12 -12
- package/datatable/index.mjs +35 -34
- package/datepicker/index.mjs +13 -13
- package/datetime-picker/index.mjs +13 -13
- package/dock/index.mjs +10 -12
- package/dropdown-menu/index.mjs +53 -46
- 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/file-manager/index.mjs +17 -17
- package/index.mjs +0 -1
- package/input-group/index.mjs +11 -11
- 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/multi-range/index.mjs +12 -12
- package/navbar/index.mjs +37 -48
- package/otp-input/index.mjs +12 -12
- package/package.json +11 -2
- package/pagination/index.mjs +11 -13
- package/phone-input/index.mjs +13 -13
- package/query-builder/index.mjs +18 -18
- package/radio/index.mjs +10 -12
- package/radio-group/index.mjs +11 -13
- package/react-bootstrap.css +2 -1
- package/ribbon/index.mjs +90 -129
- package/scheduler/index.mjs +21 -27
- package/select/index.mjs +9 -11
- package/shell/index.mjs +18 -23
- package/signature-pad/index.mjs +9 -11
- package/splitter/index.mjs +13 -13
- package/tab-control/index.mjs +15 -18
- package/theming/index.mjs +39 -46
- package/tile-manager/index.mjs +13 -13
- package/timeline/index.mjs +82 -97
- package/timepicker/index.mjs +14 -19
- package/toggle-button/index.mjs +11 -13
- package/tree-select/index.mjs +17 -19
- package/treeview/index.mjs +14 -14
- package/typeahead/index.mjs +107 -0
- package/typeahead/src/BsTypeahead.d.ts +48 -0
- package/typeahead/src/index.d.ts +4 -0
package/theming/index.mjs
CHANGED
|
@@ -1,49 +1,42 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}),
|
|
1
|
+
import * as e from "react";
|
|
2
|
+
import { useMemo as t, useSyncExternalStore as n } from "react";
|
|
3
|
+
import { createComponent as r } from "@lit/react";
|
|
4
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
5
|
+
import { BS_THEME_COOKIE_NAME as a, BS_THEME_DEFAULT_MODES as o, BS_THEME_DEFAULT_MODES as s, BS_THEME_DEFAULT_MODE_META as c, MpThemeToggle as l, configureBsTheme as u, getBsThemeStore as d, getBsThemeStore as f, injectThemeAttribute as p, isValidThemeMode as m, readDefaultModeMeta as h, readThemeCookie as g, resolveMode as _, resolveMode as v, resolveServerTheme as y, writeThemeCookie as b } from "@mintplayer/web-components/theming";
|
|
6
|
+
//#region libs/mintplayer-react-bootstrap/theming/src/useBsTheme.ts
|
|
7
|
+
var x = Object.freeze({
|
|
8
|
+
mode: "auto",
|
|
9
|
+
effectiveMode: v("auto", !1)
|
|
10
|
+
}), S = () => typeof window < "u", C = (e) => S() ? f().subscribe(e) : () => void 0, w = x, T = () => {
|
|
11
|
+
if (!S()) return x;
|
|
12
|
+
let e = f(), t = e.getMode(), n = e.effectiveMode();
|
|
13
|
+
return (w.mode !== t || w.effectiveMode !== n) && (w = {
|
|
14
|
+
mode: t,
|
|
15
|
+
effectiveMode: n
|
|
16
|
+
}), w;
|
|
17
|
+
}, E = () => x, D = (e) => {
|
|
18
|
+
S() && f().setMode(e);
|
|
11
19
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
);
|
|
20
|
+
function O() {
|
|
21
|
+
let e = n(C, T, E);
|
|
22
|
+
return t(() => ({
|
|
23
|
+
mode: e.mode,
|
|
24
|
+
effectiveMode: e.effectiveMode,
|
|
25
|
+
setMode: D
|
|
26
|
+
}), [e]);
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region libs/mintplayer-react-bootstrap/theming/src/BsThemeToggle.tsx
|
|
30
|
+
var k = r({
|
|
31
|
+
react: e,
|
|
32
|
+
tagName: "mp-theme-toggle",
|
|
33
|
+
elementClass: l
|
|
34
|
+
}), A = e.forwardRef(function({ modes: e, ...t }, n) {
|
|
35
|
+
return /* @__PURE__ */ i(k, {
|
|
36
|
+
ref: n,
|
|
37
|
+
modes: e ?? s,
|
|
38
|
+
...t
|
|
39
|
+
});
|
|
33
40
|
});
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { a as BS_THEME_COOKIE_NAME, o as BS_THEME_DEFAULT_MODES, c as BS_THEME_DEFAULT_MODE_META, A as BsThemeToggle, u as configureBsTheme, d as getBsThemeStore, p as injectThemeAttribute, m as isValidThemeMode, h as readDefaultModeMeta, g as readThemeCookie, _ as resolveMode, y as resolveServerTheme, O as useBsTheme, b as writeThemeCookie };
|
package/tile-manager/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
2
|
import { createComponent as t } from "@lit/react";
|
|
3
|
-
import { MintTileManagerElement as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
import { MintTileManagerElement as n } from "@mintplayer/web-components/tile-manager";
|
|
4
|
+
//#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
|
+
}
|
|
13
14
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { r as BsTileManager };
|
package/timeline/index.mjs
CHANGED
|
@@ -1,98 +1,83 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
children: [
|
|
82
|
-
r && /* @__PURE__ */ l("span", { slot: "marker", children: r(e, i) }),
|
|
83
|
-
d && /* @__PURE__ */ l("span", { slot: "title", children: d(e, i) }),
|
|
84
|
-
m && /* @__PURE__ */ l("span", { slot: "opposite", children: m(e, i) }),
|
|
85
|
-
p && /* @__PURE__ */ l("span", { slot: "opposite", children: p(e, i) }),
|
|
86
|
-
h && /* @__PURE__ */ l("div", { slot: "content", children: h(e, i) })
|
|
87
|
-
]
|
|
88
|
-
},
|
|
89
|
-
e.id ?? t
|
|
90
|
-
);
|
|
91
|
-
}) : k ? null : B
|
|
92
|
-
}
|
|
93
|
-
);
|
|
1
|
+
import * as e from "react";
|
|
2
|
+
import { createComponent as t } from "@lit/react";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
import { MpTimeline as i, MpTimelineItem as a, resolveSides as o } from "@mintplayer/web-components/timeline";
|
|
5
|
+
//#region libs/mintplayer-react-bootstrap/timeline/src/BsTimelineItem.tsx
|
|
6
|
+
var s = t({
|
|
7
|
+
react: e,
|
|
8
|
+
tagName: "mp-timeline-item",
|
|
9
|
+
elementClass: a
|
|
10
|
+
}), c = t({
|
|
11
|
+
react: e,
|
|
12
|
+
tagName: "mp-timeline",
|
|
13
|
+
elementClass: i,
|
|
14
|
+
events: {
|
|
15
|
+
onItemClick: "item-click",
|
|
16
|
+
onSelectionChange: "selection-change"
|
|
17
|
+
}
|
|
18
|
+
}), l = (e, t) => e.id ?? t;
|
|
19
|
+
function u(e) {
|
|
20
|
+
let { items: t, orientation: i = "vertical", align: a = "start", reverse: u = !1, selectable: d = "none", selection: f, onSelectionChange: p, onItemClick: m, renderMarker: h, renderTitle: g, renderTimestamp: _, renderOpposite: v, renderContent: y, className: b, children: x, ...S } = e, C = !!(h || g || _ || v || y), w = !!t && !C, T = C && !!t, E = (e) => m?.(e.detail), D = (e) => {
|
|
21
|
+
let n = e.detail;
|
|
22
|
+
if (t && t.length) {
|
|
23
|
+
let e = new Map(t.map((e, t) => [String(l(e, t)), e]));
|
|
24
|
+
p?.(n.selected.map((t) => e.get(String(t.id ?? "")) ?? t));
|
|
25
|
+
} else p?.(n.selected);
|
|
26
|
+
}, O = o(t?.length ?? 0, a, u);
|
|
27
|
+
return /* @__PURE__ */ n(c, {
|
|
28
|
+
orientation: i,
|
|
29
|
+
align: a,
|
|
30
|
+
reverse: u,
|
|
31
|
+
selectable: d,
|
|
32
|
+
className: b,
|
|
33
|
+
onItemClick: E,
|
|
34
|
+
onSelectionChange: D,
|
|
35
|
+
...S,
|
|
36
|
+
...w ? { items: t } : {},
|
|
37
|
+
...d === "none" ? {} : { selectedIds: f ? f.map((e, t) => l(e, t)) : [] },
|
|
38
|
+
children: T && t ? t.map((e, a) => {
|
|
39
|
+
let o = t.length, c = u ? o - 1 - a : a, l = {
|
|
40
|
+
index: a,
|
|
41
|
+
visualIndex: c,
|
|
42
|
+
isFirst: c === 0,
|
|
43
|
+
isLast: c === o - 1,
|
|
44
|
+
orientation: i,
|
|
45
|
+
side: O[a] ?? "start"
|
|
46
|
+
}, d = e.time instanceof Date ? e.time.toLocaleDateString() : e.time;
|
|
47
|
+
return /* @__PURE__ */ r(s, {
|
|
48
|
+
itemId: e.id,
|
|
49
|
+
title: e.title,
|
|
50
|
+
description: e.description,
|
|
51
|
+
time: d ?? void 0,
|
|
52
|
+
icon: e.icon,
|
|
53
|
+
color: e.color,
|
|
54
|
+
itemClass: e.cssClass,
|
|
55
|
+
disabled: e.disabled,
|
|
56
|
+
children: [
|
|
57
|
+
h && /* @__PURE__ */ n("span", {
|
|
58
|
+
slot: "marker",
|
|
59
|
+
children: h(e, l)
|
|
60
|
+
}),
|
|
61
|
+
g && /* @__PURE__ */ n("span", {
|
|
62
|
+
slot: "title",
|
|
63
|
+
children: g(e, l)
|
|
64
|
+
}),
|
|
65
|
+
_ && /* @__PURE__ */ n("span", {
|
|
66
|
+
slot: "opposite",
|
|
67
|
+
children: _(e, l)
|
|
68
|
+
}),
|
|
69
|
+
v && /* @__PURE__ */ n("span", {
|
|
70
|
+
slot: "opposite",
|
|
71
|
+
children: v(e, l)
|
|
72
|
+
}),
|
|
73
|
+
y && /* @__PURE__ */ n("div", {
|
|
74
|
+
slot: "content",
|
|
75
|
+
children: y(e, l)
|
|
76
|
+
})
|
|
77
|
+
]
|
|
78
|
+
}, e.id ?? a);
|
|
79
|
+
}) : w ? null : x
|
|
80
|
+
});
|
|
94
81
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
z as BsTimelineItem
|
|
98
|
-
};
|
|
82
|
+
//#endregion
|
|
83
|
+
export { u as BsTimeline, s as BsTimelineItem };
|
package/timepicker/index.mjs
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
2
|
import { createComponent as t } from "@lit/react";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
events: {
|
|
16
|
-
onSelectedTimeChange: "selected-time-change"
|
|
17
|
-
}
|
|
3
|
+
import { MpTimeListElement as n, MpTimepickerElement as r } from "@mintplayer/web-components/timepicker";
|
|
4
|
+
//#region libs/mintplayer-react-bootstrap/timepicker/src/BsTimepicker.tsx
|
|
5
|
+
var i = t({
|
|
6
|
+
react: e,
|
|
7
|
+
tagName: "mp-timepicker",
|
|
8
|
+
elementClass: r,
|
|
9
|
+
events: { onSelectedTimeChange: "selected-time-change" }
|
|
10
|
+
}), a = t({
|
|
11
|
+
react: e,
|
|
12
|
+
tagName: "mp-time-list",
|
|
13
|
+
elementClass: n,
|
|
14
|
+
events: { onSelectedTimeChange: "selected-time-change" }
|
|
18
15
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
a as BsTimepicker
|
|
22
|
-
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { a as BsTimeList, i as BsTimepicker };
|
package/toggle-button/index.mjs
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { createComponent as
|
|
3
|
-
import { MpToggleButton as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
1
|
+
import * as e from "react";
|
|
2
|
+
import { createComponent as t } from "@lit/react";
|
|
3
|
+
import { MpToggleButton as n } from "@mintplayer/web-components/toggle-button";
|
|
4
|
+
//#region libs/mintplayer-react-bootstrap/toggle-button/src/BsToggleButton.tsx
|
|
5
|
+
var r = t({
|
|
6
|
+
react: e,
|
|
7
|
+
tagName: "mp-toggle-button",
|
|
8
|
+
elementClass: n,
|
|
9
|
+
events: { onChange: "change" }
|
|
11
10
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { r as BsToggleButton };
|
package/tree-select/index.mjs
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
|
-
import { createComponent as
|
|
3
|
-
import { MpTreeSelect as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
import { createComponent as t } from "@lit/react";
|
|
3
|
+
import { InMemoryTreeSelectProvider as n, MpTreeSelect as r } from "@mintplayer/web-components/tree-select";
|
|
4
|
+
//#region libs/mintplayer-react-bootstrap/tree-select/src/BsTreeSelect.tsx
|
|
5
|
+
var i = t({
|
|
6
|
+
react: e,
|
|
7
|
+
tagName: "mp-tree-select",
|
|
8
|
+
elementClass: r,
|
|
9
|
+
events: {
|
|
10
|
+
onValueChange: "value-change",
|
|
11
|
+
onOpen: "open",
|
|
12
|
+
onClose: "close",
|
|
13
|
+
onClear: "clear",
|
|
14
|
+
onSearch: "search",
|
|
15
|
+
onLoadError: "load-error"
|
|
16
|
+
}
|
|
17
17
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
m as InMemoryTreeSelectProvider
|
|
21
|
-
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { i as BsTreeSelect, n as InMemoryTreeSelectProvider };
|
package/treeview/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
|
-
import { createComponent as
|
|
3
|
-
import { MpTreeview as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
import { createComponent as t } from "@lit/react";
|
|
3
|
+
import { MpTreeview as n } from "@mintplayer/web-components/treeview";
|
|
4
|
+
//#region libs/mintplayer-react-bootstrap/treeview/src/BsTreeview.tsx
|
|
5
|
+
var r = t({
|
|
6
|
+
react: e,
|
|
7
|
+
tagName: "mp-treeview",
|
|
8
|
+
elementClass: n,
|
|
9
|
+
events: {
|
|
10
|
+
onTreeNodeSelect: "tree-node-select",
|
|
11
|
+
onTreeNodeExpand: "tree-node-expand",
|
|
12
|
+
onTreeNodeCollapse: "tree-node-collapse"
|
|
13
|
+
}
|
|
13
14
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { r as BsTreeview };
|
|
@@ -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';
|