@epam/ai-dial-starter-buttons 1.1.0-dev.488 → 1.1.0-dev.491
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.
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { StarterButtonsProps } from '../../models/starter-props';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Row of starter-prompt buttons that collapses overflowing items into a
|
|
5
|
+
* dropdown menu, sized to fit the available container width. With
|
|
6
|
+
* `isCollapsible` set to `false` every starter is rendered instead, each on
|
|
7
|
+
* its own row, and no overflow menu appears.
|
|
8
|
+
*/
|
|
4
9
|
export declare const StarterButtons: FC<StarterButtonsProps>;
|
|
5
10
|
//# sourceMappingURL=StarterButtons.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StarterButtons.d.ts","sourceRoot":"","sources":["../../../src/components/StarterButtons/StarterButtons.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,EAAE,EAAqD,MAAM,OAAO,CAAC;AAC9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAMtE
|
|
1
|
+
{"version":3,"file":"StarterButtons.d.ts","sourceRoot":"","sources":["../../../src/components/StarterButtons/StarterButtons.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,EAAE,EAAqD,MAAM,OAAO,CAAC;AAC9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAMtE;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAmKlD,CAAC"}
|
package/index.js
CHANGED
|
@@ -4,79 +4,83 @@ import { IconDots as o, IconDotsVertical as s } from "@tabler/icons-react";
|
|
|
4
4
|
import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
|
|
5
5
|
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/StarterButtons/StarterButtons.tsx
|
|
7
|
-
var h = 4, g = 8, _ = ({ starters: _, onSelect: v, isMobile: y,
|
|
8
|
-
let
|
|
9
|
-
let t =
|
|
10
|
-
if (!t) return;
|
|
7
|
+
var h = 4, g = 8, _ = ({ starters: _, onSelect: v, isMobile: y, isCollapsible: b = !0, labels: x, styles: S }) => {
|
|
8
|
+
let C = d(null), w = d([]), T = d([]), [E, D] = f(() => Math.min(_.length, h)), O = c((e) => {
|
|
9
|
+
let t = C.current;
|
|
10
|
+
if (!t || !b) return;
|
|
11
11
|
let n = t.getBoundingClientRect().width;
|
|
12
12
|
if (n === 0) return;
|
|
13
13
|
let r = Math.min(e, h);
|
|
14
|
-
|
|
15
|
-
let i = (e) =>
|
|
14
|
+
w.current.slice(0, r).every((e) => e != null) && (T.current = w.current.slice(0, r).map((e) => e?.getBoundingClientRect().width ?? 0));
|
|
15
|
+
let i = (e) => T.current[e] ?? 120, a = 0, o = 0;
|
|
16
16
|
for (let t = 0; t < r; t++) {
|
|
17
17
|
let r = i(t), s = e - (t + 1) > 0;
|
|
18
18
|
if (a + (t > 0 ? g : 0) + r + (s ? 64 : 0) > n) break;
|
|
19
19
|
a += (t > 0 ? g : 0) + r, o = t + 1;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
}, []);
|
|
21
|
+
D(Math.max(1, o));
|
|
22
|
+
}, [b]);
|
|
23
23
|
l(() => {
|
|
24
|
-
|
|
24
|
+
T.current = [], D(Math.min(_.length, h));
|
|
25
25
|
}, [_.length]), l(() => {
|
|
26
|
-
let e =
|
|
27
|
-
if (!e) return;
|
|
26
|
+
let e = C.current;
|
|
27
|
+
if (!e || !b) return;
|
|
28
28
|
let t = new ResizeObserver(() => {
|
|
29
|
-
|
|
29
|
+
O(_.length);
|
|
30
30
|
});
|
|
31
31
|
return t.observe(e), () => t.disconnect();
|
|
32
|
-
}, [D, _.length]), l(() => {
|
|
33
|
-
D(_.length);
|
|
34
32
|
}, [
|
|
35
|
-
|
|
33
|
+
O,
|
|
34
|
+
b,
|
|
35
|
+
_.length
|
|
36
|
+
]), l(() => {
|
|
37
|
+
O(_.length);
|
|
38
|
+
}, [
|
|
39
|
+
O,
|
|
36
40
|
_.length,
|
|
37
|
-
|
|
41
|
+
E
|
|
38
42
|
]);
|
|
39
|
-
let
|
|
43
|
+
let k = u(() => ({
|
|
40
44
|
...e,
|
|
41
|
-
stroke:
|
|
42
|
-
size:
|
|
43
|
-
}), [
|
|
45
|
+
stroke: S?.iconStrokeWidth ?? e.stroke,
|
|
46
|
+
size: S?.iconSize ?? e.size
|
|
47
|
+
}), [S?.iconStrokeWidth, S?.iconSize]);
|
|
44
48
|
if (_.length === 0) return null;
|
|
45
|
-
let
|
|
49
|
+
let A = b ? _.slice(0, E) : _, j = b ? _.slice(E) : [], M = j.map((e, t) => ({
|
|
46
50
|
key: String(t),
|
|
47
51
|
label: e.title,
|
|
48
52
|
onClick: () => v(e)
|
|
49
53
|
}));
|
|
50
54
|
return /* @__PURE__ */ p("div", {
|
|
51
|
-
ref:
|
|
55
|
+
ref: C,
|
|
52
56
|
className: "mb-4 w-full",
|
|
53
57
|
children: /* @__PURE__ */ m("div", {
|
|
54
58
|
role: "list",
|
|
55
|
-
"aria-label":
|
|
56
|
-
className: "flex flex-wrap justify-center gap-2",
|
|
57
|
-
children: [
|
|
59
|
+
"aria-label": x.list,
|
|
60
|
+
className: b ? "flex flex-wrap justify-center gap-2" : "flex flex-col items-center gap-2",
|
|
61
|
+
children: [A.map((e, n) => /* @__PURE__ */ p("div", {
|
|
58
62
|
role: "listitem",
|
|
59
63
|
ref: (e) => {
|
|
60
|
-
|
|
64
|
+
w.current[n] = e;
|
|
61
65
|
},
|
|
62
66
|
children: /* @__PURE__ */ p(i, {
|
|
63
67
|
label: e.title,
|
|
64
68
|
appearance: t.Outlined,
|
|
65
69
|
onClick: () => v(e)
|
|
66
70
|
})
|
|
67
|
-
}, e.const)),
|
|
71
|
+
}, e.const)), j.length > 0 && /* @__PURE__ */ p("div", {
|
|
68
72
|
role: "listitem",
|
|
69
73
|
children: /* @__PURE__ */ p(r, {
|
|
70
|
-
items:
|
|
74
|
+
items: M,
|
|
71
75
|
placement: "bottom-end",
|
|
72
76
|
matchReferenceWidth: !1,
|
|
73
77
|
children: /* @__PURE__ */ p(a, {
|
|
74
78
|
appearance: t.Outlined,
|
|
75
79
|
icon: p(y ? o : s, {
|
|
76
|
-
...
|
|
80
|
+
...k,
|
|
77
81
|
stroke: n
|
|
78
82
|
}),
|
|
79
|
-
"aria-label":
|
|
83
|
+
"aria-label": x.overflow
|
|
80
84
|
})
|
|
81
85
|
})
|
|
82
86
|
})]
|
|
@@ -21,6 +21,13 @@ export interface StarterButtonsProps {
|
|
|
21
21
|
onSelect: (starter: StarterOption) => void;
|
|
22
22
|
/** When `true`, renders a mobile-optimised layout. */
|
|
23
23
|
isMobile?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* When `true` (the default), only as many starters as the measured
|
|
26
|
+
* container width allows stay on one row and the rest collapse into an
|
|
27
|
+
* overflow dropdown. When `false`, every starter is rendered, each on its
|
|
28
|
+
* own row, and no overflow menu appears.
|
|
29
|
+
*/
|
|
30
|
+
isCollapsible?: boolean;
|
|
24
31
|
/** Localized labels used within the component. */
|
|
25
32
|
labels: StarterButtonsLabels;
|
|
26
33
|
/** Optional style overrides. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"starter-props.d.ts","sourceRoot":"","sources":["../../src/models/starter-props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,gEAAgE;AAChE,MAAM,WAAW,oBAAoB;IACnC,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,0DAA0D;AAC1D,MAAM,WAAW,oBAAoB;IACnC,yFAAyF;IACzF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wFAAwF;IACxF,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,gDAAgD;AAChD,MAAM,WAAW,mBAAmB;IAClC,oDAAoD;IACpD,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,qDAAqD;IACrD,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;IAC3C,sDAAsD;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kDAAkD;IAClD,MAAM,EAAE,oBAAoB,CAAC;IAC7B,gCAAgC;IAChC,MAAM,CAAC,EAAE,oBAAoB,CAAC;CAC/B"}
|
|
1
|
+
{"version":3,"file":"starter-props.d.ts","sourceRoot":"","sources":["../../src/models/starter-props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,gEAAgE;AAChE,MAAM,WAAW,oBAAoB;IACnC,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,0DAA0D;AAC1D,MAAM,WAAW,oBAAoB;IACnC,yFAAyF;IACzF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wFAAwF;IACxF,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,gDAAgD;AAChD,MAAM,WAAW,mBAAmB;IAClC,oDAAoD;IACpD,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,qDAAqD;IACrD,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;IAC3C,sDAAsD;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kDAAkD;IAClD,MAAM,EAAE,oBAAoB,CAAC;IAC7B,gCAAgC;IAChC,MAAM,CAAC,EAAE,oBAAoB,CAAC;CAC/B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/ai-dial-starter-buttons",
|
|
3
3
|
"description": "Responsive starter prompt buttons that overflow into a dropdown when space is limited",
|
|
4
|
-
"version": "1.1.0-dev.
|
|
4
|
+
"version": "1.1.0-dev.491",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@tabler/icons-react": "^3.44.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@epam/ai-dial-chat-shared": "1.1.0-dev.
|
|
22
|
+
"@epam/ai-dial-chat-shared": "1.1.0-dev.491",
|
|
23
23
|
"react": "^19.2.8",
|
|
24
24
|
"@epam/ai-dial-ui-kit": "^0.14.2"
|
|
25
25
|
},
|