@epam/ai-dial-starter-buttons 1.1.0-dev.75 → 1.1.0-dev.78
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StarterButtons.d.ts","sourceRoot":"","sources":["../../../src/components/StarterButtons/StarterButtons.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StarterButtons.d.ts","sourceRoot":"","sources":["../../../src/components/StarterButtons/StarterButtons.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,EAAE,EAAqD,MAAM,OAAO,CAAC;AAC9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAMtE,uIAAuI;AACvI,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAkJlD,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,74 +1,76 @@
|
|
|
1
1
|
import { BASE_MD_ICON_PROPS as e } from "@epam/ai-dial-chat-shared";
|
|
2
|
-
import {
|
|
3
|
-
import { IconDots as
|
|
4
|
-
import { useCallback as
|
|
5
|
-
import { jsx as
|
|
2
|
+
import { ButtonAppearance as t, DialDropdown as n, NeutralButton as r, NeutralIconButton as i } from "@epam/ai-dial-ui-kit";
|
|
3
|
+
import { IconDots as a, IconDotsVertical as o } from "@tabler/icons-react";
|
|
4
|
+
import { useCallback as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
5
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/StarterButtons/StarterButtons.tsx
|
|
7
|
-
var
|
|
8
|
-
let
|
|
9
|
-
let t =
|
|
7
|
+
var m = 4, h = 8, g = ({ starters: g, onSelect: _, isMobile: v, labels: y, styles: b }) => {
|
|
8
|
+
let x = u(null), S = u([]), C = u([]), [w, T] = d(() => Math.min(g.length, m)), E = s((e) => {
|
|
9
|
+
let t = x.current;
|
|
10
10
|
if (!t) return;
|
|
11
11
|
let n = t.getBoundingClientRect().width;
|
|
12
12
|
if (n === 0) return;
|
|
13
|
-
let r = Math.min(e,
|
|
14
|
-
|
|
15
|
-
let i = (e) =>
|
|
13
|
+
let r = Math.min(e, m);
|
|
14
|
+
S.current.slice(0, r).every((e) => e != null) && (C.current = S.current.slice(0, r).map((e) => e?.getBoundingClientRect().width ?? 0));
|
|
15
|
+
let i = (e) => C.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
|
-
if (a + (t > 0 ?
|
|
19
|
-
a += (t > 0 ?
|
|
18
|
+
if (a + (t > 0 ? h : 0) + r + (s ? 64 : 0) > n) break;
|
|
19
|
+
a += (t > 0 ? h : 0) + r, o = t + 1;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
T(Math.max(1, o));
|
|
22
22
|
}, []);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}, [
|
|
26
|
-
let e =
|
|
23
|
+
c(() => {
|
|
24
|
+
C.current = [], T(Math.min(g.length, m));
|
|
25
|
+
}, [g.length]), c(() => {
|
|
26
|
+
let e = x.current;
|
|
27
27
|
if (!e) return;
|
|
28
28
|
let t = new ResizeObserver(() => {
|
|
29
|
-
|
|
29
|
+
E(g.length);
|
|
30
30
|
});
|
|
31
31
|
return t.observe(e), () => t.disconnect();
|
|
32
|
-
}, [
|
|
33
|
-
|
|
32
|
+
}, [E, g.length]), c(() => {
|
|
33
|
+
E(g.length);
|
|
34
34
|
});
|
|
35
|
-
let
|
|
35
|
+
let D = l(() => ({
|
|
36
36
|
...e,
|
|
37
|
-
stroke:
|
|
38
|
-
size:
|
|
39
|
-
}), [
|
|
40
|
-
if (
|
|
41
|
-
let
|
|
37
|
+
stroke: b?.iconStrokeWidth ?? e.stroke,
|
|
38
|
+
size: b?.iconSize ?? e.size
|
|
39
|
+
}), [b?.iconStrokeWidth, b?.iconSize]);
|
|
40
|
+
if (g.length === 0) return null;
|
|
41
|
+
let O = Math.min(w, m), k = g.slice(0, O), A = g.slice(O), j = A.map((e, t) => ({
|
|
42
42
|
key: String(t),
|
|
43
43
|
label: e.title,
|
|
44
|
-
onClick: () =>
|
|
44
|
+
onClick: () => _(e)
|
|
45
45
|
}));
|
|
46
|
-
return /* @__PURE__ */
|
|
47
|
-
ref:
|
|
46
|
+
return /* @__PURE__ */ f("div", {
|
|
47
|
+
ref: x,
|
|
48
48
|
className: "mb-4 w-full",
|
|
49
|
-
children: /* @__PURE__ */
|
|
49
|
+
children: /* @__PURE__ */ p("div", {
|
|
50
50
|
role: "list",
|
|
51
|
-
"aria-label":
|
|
51
|
+
"aria-label": y.list,
|
|
52
52
|
className: "flex flex-wrap justify-center gap-2",
|
|
53
|
-
children: [
|
|
53
|
+
children: [k.map((e, n) => /* @__PURE__ */ f("div", {
|
|
54
54
|
role: "listitem",
|
|
55
55
|
ref: (e) => {
|
|
56
|
-
|
|
56
|
+
S.current[n] = e;
|
|
57
57
|
},
|
|
58
|
-
children: /* @__PURE__ */
|
|
58
|
+
children: /* @__PURE__ */ f(r, {
|
|
59
59
|
label: e.title,
|
|
60
|
-
|
|
60
|
+
appearance: t.Outlined,
|
|
61
|
+
onClick: () => _(e)
|
|
61
62
|
})
|
|
62
|
-
}, e.const)),
|
|
63
|
+
}, e.const)), A.length > 0 && /* @__PURE__ */ f("div", {
|
|
63
64
|
role: "listitem",
|
|
64
|
-
children: /* @__PURE__ */
|
|
65
|
-
items:
|
|
65
|
+
children: /* @__PURE__ */ f(n, {
|
|
66
|
+
items: j,
|
|
66
67
|
placement: "bottom-end",
|
|
67
68
|
matchReferenceWidth: !1,
|
|
68
69
|
listClassName: "cp-dropdown-overlay",
|
|
69
|
-
children: /* @__PURE__ */
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
children: /* @__PURE__ */ f(i, {
|
|
71
|
+
appearance: t.Outlined,
|
|
72
|
+
icon: f(v ? a : o, { ...D }),
|
|
73
|
+
"aria-label": y.overflow
|
|
72
74
|
})
|
|
73
75
|
})
|
|
74
76
|
})]
|
|
@@ -76,4 +78,4 @@ var f = 4, p = 8, m = ({ starters: m, onSelect: h, isMobile: g, labels: _, style
|
|
|
76
78
|
});
|
|
77
79
|
};
|
|
78
80
|
//#endregion
|
|
79
|
-
export {
|
|
81
|
+
export { g as StarterButtons };
|
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.78",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@epam/ai-dial-chat-shared": "1.1.0-dev.
|
|
19
|
+
"@epam/ai-dial-chat-shared": "1.1.0-dev.78",
|
|
20
20
|
"@tabler/icons-react": "^3.44.0",
|
|
21
21
|
"react": "^19.0.0",
|
|
22
|
-
"@epam/ai-dial-ui-kit": "^0.13.0-dev.
|
|
22
|
+
"@epam/ai-dial-ui-kit": "^0.13.0-dev.25"
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|