@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.
Files changed (61) hide show
  1. package/accordion/index.mjs +38 -58
  2. package/calendar/index.mjs +9 -9
  3. package/card/index.mjs +102 -67
  4. package/card/src/BsCardBody.d.ts +2 -2
  5. package/card/src/BsCardFooter.d.ts +2 -2
  6. package/card/src/BsCardGroup.d.ts +4 -3
  7. package/card/src/BsCardHeader.d.ts +2 -2
  8. package/card/src/BsCardImg.d.ts +1 -1
  9. package/card/src/BsCardLink.d.ts +2 -2
  10. package/card/src/BsCardSubtitle.d.ts +2 -2
  11. package/card/src/BsCardText.d.ts +2 -2
  12. package/card/src/BsCardTitle.d.ts +2 -2
  13. package/carousel/index.mjs +27 -30
  14. package/charts/hierarchy/index.mjs +16 -16
  15. package/charts/sparkline/index.mjs +9 -9
  16. package/charts/trend/index.mjs +12 -12
  17. package/checkbox/index.mjs +10 -12
  18. package/chunks/react-props-CKk_Kufi.mjs +24 -0
  19. package/code-snippet/index.mjs +12 -12
  20. package/datatable/index.mjs +35 -34
  21. package/datepicker/index.mjs +13 -13
  22. package/datetime-picker/index.mjs +13 -13
  23. package/dock/index.mjs +10 -12
  24. package/dropdown-menu/index.mjs +53 -46
  25. package/dropdown-menu/src/BsDropdownItem.d.ts +1 -1
  26. package/dropdown-menu/src/BsDropdownMenu.d.ts +2 -5
  27. package/dropdown-menu/src/index.d.ts +1 -1
  28. package/file-manager/index.mjs +17 -17
  29. package/index.mjs +0 -1
  30. package/input-group/index.mjs +11 -11
  31. package/machine/index.mjs +1 -0
  32. package/machine/src/index.d.ts +2 -0
  33. package/machine/src/react-props.d.ts +9 -0
  34. package/machine/src/useMachine.d.ts +16 -0
  35. package/multi-range/index.mjs +12 -12
  36. package/navbar/index.mjs +37 -48
  37. package/otp-input/index.mjs +12 -12
  38. package/package.json +11 -2
  39. package/pagination/index.mjs +11 -13
  40. package/phone-input/index.mjs +13 -13
  41. package/query-builder/index.mjs +18 -18
  42. package/radio/index.mjs +10 -12
  43. package/radio-group/index.mjs +11 -13
  44. package/react-bootstrap.css +2 -1
  45. package/ribbon/index.mjs +90 -129
  46. package/scheduler/index.mjs +21 -27
  47. package/select/index.mjs +9 -11
  48. package/shell/index.mjs +18 -23
  49. package/signature-pad/index.mjs +9 -11
  50. package/splitter/index.mjs +13 -13
  51. package/tab-control/index.mjs +15 -18
  52. package/theming/index.mjs +39 -46
  53. package/tile-manager/index.mjs +13 -13
  54. package/timeline/index.mjs +82 -97
  55. package/timepicker/index.mjs +14 -19
  56. package/toggle-button/index.mjs +11 -13
  57. package/tree-select/index.mjs +17 -19
  58. package/treeview/index.mjs +14 -14
  59. package/typeahead/index.mjs +107 -0
  60. package/typeahead/src/BsTypeahead.d.ts +48 -0
  61. package/typeahead/src/index.d.ts +4 -0
package/theming/index.mjs CHANGED
@@ -1,49 +1,42 @@
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) : () => {
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
- 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
- );
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
- 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 });
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
- 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
- };
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 };
@@ -1,16 +1,16 @@
1
1
  import * as e from "react";
2
2
  import { createComponent as t } from "@lit/react";
3
- import { MintTileManagerElement as o } from "@mintplayer/web-components/tile-manager";
4
- const i = t({
5
- react: e,
6
- tagName: "mp-tile-manager",
7
- elementClass: o,
8
- events: {
9
- onTilelayoutchange: "tilelayoutchange",
10
- onTilepositionchange: "tilepositionchange",
11
- onTilegestureblocked: "tilegestureblocked"
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
- export {
15
- i as BsTileManager
16
- };
15
+ //#endregion
16
+ export { r as BsTileManager };
@@ -1,98 +1,83 @@
1
- import { jsx as l, jsxs as y } from "react/jsx-runtime";
2
- import * as x from "react";
3
- import { createComponent as M } from "@lit/react";
4
- import { MpTimelineItem as F, MpTimeline as R, resolveSides as q } from "@mintplayer/web-components/timeline";
5
- const z = M({
6
- react: x,
7
- tagName: "mp-timeline-item",
8
- elementClass: F
9
- }), A = M({
10
- react: x,
11
- tagName: "mp-timeline",
12
- elementClass: R,
13
- events: {
14
- onItemClick: "item-click",
15
- onSelectionChange: "selection-change"
16
- }
17
- }), v = (c, n) => c.id ?? n;
18
- function J(c) {
19
- const {
20
- items: n,
21
- orientation: g = "vertical",
22
- align: C = "start",
23
- reverse: a = !1,
24
- selectable: I = "none",
25
- selection: f,
26
- onSelectionChange: S,
27
- onItemClick: u,
28
- renderMarker: r,
29
- renderTitle: d,
30
- renderTimestamp: m,
31
- renderOpposite: p,
32
- renderContent: h,
33
- className: b,
34
- children: B,
35
- // Everything else is the consumer's — role, id, tabIndex, data-*, aria-*.
36
- // Without this the wrapper silently swallowed them.
37
- ...N
38
- } = c, T = !!(r || d || m || p || h), k = !!n && !T, j = T && !!n, w = (e) => u?.(e.detail), D = (e) => {
39
- const t = e.detail;
40
- if (n && n.length) {
41
- const o = new Map(n.map((s, i) => [String(v(s, i)), s]));
42
- S?.(
43
- t.selected.map((s) => o.get(String(s.id ?? "")) ?? s)
44
- );
45
- } else
46
- S?.(t.selected);
47
- }, L = q(n?.length ?? 0, C, a);
48
- return /* @__PURE__ */ l(
49
- A,
50
- {
51
- orientation: g,
52
- align: C,
53
- reverse: a,
54
- selectable: I,
55
- className: b,
56
- onItemClick: w,
57
- onSelectionChange: D,
58
- ...N,
59
- ...k ? { items: n } : {},
60
- ...I !== "none" ? { selectedIds: f ? f.map((e, t) => v(e, t)) : [] } : {},
61
- children: j && n ? n.map((e, t) => {
62
- const o = n.length, s = a ? o - 1 - t : t, i = {
63
- index: t,
64
- visualIndex: s,
65
- isFirst: s === 0,
66
- isLast: s === o - 1,
67
- orientation: g,
68
- side: L[t] ?? "start"
69
- }, O = e.time instanceof Date ? e.time.toLocaleDateString() : e.time;
70
- return /* @__PURE__ */ y(
71
- z,
72
- {
73
- itemId: e.id,
74
- title: e.title,
75
- description: e.description,
76
- time: O ?? void 0,
77
- icon: e.icon,
78
- color: e.color,
79
- itemClass: e.cssClass,
80
- disabled: e.disabled,
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
- export {
96
- J as BsTimeline,
97
- z as BsTimelineItem
98
- };
82
+ //#endregion
83
+ export { u as BsTimeline, s as BsTimelineItem };
@@ -1,22 +1,17 @@
1
1
  import * as e from "react";
2
2
  import { createComponent as t } from "@lit/react";
3
- import { MpTimepickerElement as m, MpTimeListElement as i } from "@mintplayer/web-components/timepicker";
4
- const a = t({
5
- react: e,
6
- tagName: "mp-timepicker",
7
- elementClass: m,
8
- events: {
9
- onSelectedTimeChange: "selected-time-change"
10
- }
11
- }), c = t({
12
- react: e,
13
- tagName: "mp-time-list",
14
- elementClass: i,
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
- export {
20
- c as BsTimeList,
21
- a as BsTimepicker
22
- };
16
+ //#endregion
17
+ export { a as BsTimeList, i as BsTimepicker };
@@ -1,14 +1,12 @@
1
- import * as t from "react";
2
- import { createComponent as e } from "@lit/react";
3
- import { MpToggleButton as o } from "@mintplayer/web-components/toggle-button";
4
- const a = e({
5
- react: t,
6
- tagName: "mp-toggle-button",
7
- elementClass: o,
8
- events: {
9
- onChange: "change"
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
- export {
13
- a as BsToggleButton
14
- };
11
+ //#endregion
12
+ export { r as BsToggleButton };
@@ -1,21 +1,19 @@
1
1
  import * as e from "react";
2
- import { createComponent as r } from "@lit/react";
3
- import { MpTreeSelect as o } from "@mintplayer/web-components/tree-select";
4
- import { InMemoryTreeSelectProvider as m } from "@mintplayer/web-components/tree-select";
5
- const n = r({
6
- react: e,
7
- tagName: "mp-tree-select",
8
- elementClass: o,
9
- events: {
10
- onValueChange: "value-change",
11
- onOpen: "open",
12
- onClose: "close",
13
- onClear: "clear",
14
- onSearch: "search",
15
- onLoadError: "load-error"
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
- export {
19
- n as BsTreeSelect,
20
- m as InMemoryTreeSelectProvider
21
- };
18
+ //#endregion
19
+ export { i as BsTreeSelect, n as InMemoryTreeSelectProvider };
@@ -1,16 +1,16 @@
1
1
  import * as e from "react";
2
- import { createComponent as o } from "@lit/react";
3
- import { MpTreeview as r } from "@mintplayer/web-components/treeview";
4
- const a = o({
5
- react: e,
6
- tagName: "mp-treeview",
7
- elementClass: r,
8
- events: {
9
- onTreeNodeSelect: "tree-node-select",
10
- onTreeNodeExpand: "tree-node-expand",
11
- onTreeNodeCollapse: "tree-node-collapse"
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
- export {
15
- a as BsTreeview
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';