@epam/ai-dial-starter-buttons 1.2.0-dev.6 → 1.2.0-dev.69
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":"AAWA,OAAO,EAAE,EAAE,EAAqD,MAAM,OAAO,CAAC;AAE9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAMtE;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAuKlD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const STARTER_BUTTONS_CLASS: {
|
|
2
|
+
/** The component's outer wrapper. */
|
|
3
|
+
readonly root: "dial-starter-buttons-root";
|
|
4
|
+
/** The `role="list"` box holding the buttons, in both layouts. */
|
|
5
|
+
readonly list: "dial-starter-buttons-list";
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=public-class-names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-class-names.d.ts","sourceRoot":"","sources":["../../src/constants/public-class-names.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,qBAAqB;IAChC,qCAAqC;;IAErC,kEAAkE;;CAE1D,CAAC"}
|
package/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.visible{visibility:visible}.collapse{visibility:collapse}.mb-4{margin-bottom:1rem}.flex{display:flex}.w-full{width:100%}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-center{justify-content:center}.gap-2{gap:.5rem}
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { StarterButtons } from './components/StarterButtons/StarterButtons';
|
|
2
2
|
export type { StarterButtonsProps, StarterButtonsLabels, StarterButtonsStyles, } from './models/starter-props';
|
|
3
|
+
export { STARTER_BUTTONS_CLASS } from './constants/public-class-names';
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,86 +1,89 @@
|
|
|
1
1
|
import { BASE_MD_ICON_PROPS as e } from "@epam/ai-dial-chat-shared";
|
|
2
|
-
import { ButtonAppearance as t, DIAL_KIT_ICON_STROKE as n, Dropdown as r, NeutralButton as i, NeutralIconButton as a } from "@epam/ai-dial-ui-kit";
|
|
3
|
-
import { IconDots as
|
|
4
|
-
import { useCallback as
|
|
5
|
-
import { jsx as
|
|
6
|
-
//#region src/
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import { ButtonAppearance as t, DIAL_KIT_ICON_STROKE as n, Dropdown as r, NeutralButton as i, NeutralIconButton as a, mergeClasses as o } from "@epam/ai-dial-ui-kit";
|
|
3
|
+
import { IconDots as s, IconDotsVertical as c } from "@tabler/icons-react";
|
|
4
|
+
import { useCallback as l, useEffect as u, useMemo as d, useRef as f, useState as p } from "react";
|
|
5
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
6
|
+
//#region src/constants/public-class-names.ts
|
|
7
|
+
var g = {
|
|
8
|
+
root: "dial-starter-buttons-root",
|
|
9
|
+
list: "dial-starter-buttons-list"
|
|
10
|
+
}, _ = 4, v = 8, y = ({ starters: y, onSelect: b, isMobile: x, isCollapsible: S = !0, labels: C, styles: w }) => {
|
|
11
|
+
let T = f(null), E = f([]), D = f([]), [O, k] = p(() => Math.min(y.length, _)), A = l((e) => {
|
|
12
|
+
let t = T.current;
|
|
13
|
+
if (!t || !S) return;
|
|
11
14
|
let n = t.getBoundingClientRect().width;
|
|
12
15
|
if (n === 0) return;
|
|
13
|
-
let r = Math.min(e,
|
|
14
|
-
|
|
15
|
-
let i = (e) =>
|
|
16
|
+
let r = Math.min(e, _);
|
|
17
|
+
E.current.slice(0, r).every((e) => e != null) && (D.current = E.current.slice(0, r).map((e) => e?.getBoundingClientRect().width ?? 0));
|
|
18
|
+
let i = (e) => D.current[e] ?? 120, a = 0, o = 0;
|
|
16
19
|
for (let t = 0; t < r; t++) {
|
|
17
20
|
let r = i(t), s = e - (t + 1) > 0;
|
|
18
|
-
if (a + (t > 0 ?
|
|
19
|
-
a += (t > 0 ?
|
|
21
|
+
if (a + (t > 0 ? v : 0) + r + (s ? 64 : 0) > n) break;
|
|
22
|
+
a += (t > 0 ? v : 0) + r, o = t + 1;
|
|
20
23
|
}
|
|
21
|
-
|
|
22
|
-
}, [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}, [
|
|
26
|
-
let e =
|
|
27
|
-
if (!e || !
|
|
24
|
+
k(Math.max(1, o));
|
|
25
|
+
}, [S]);
|
|
26
|
+
u(() => {
|
|
27
|
+
D.current = [], k(Math.min(y.length, _));
|
|
28
|
+
}, [y.length]), u(() => {
|
|
29
|
+
let e = T.current;
|
|
30
|
+
if (!e || !S) return;
|
|
28
31
|
let t = new ResizeObserver(() => {
|
|
29
|
-
|
|
32
|
+
A(y.length);
|
|
30
33
|
});
|
|
31
34
|
return t.observe(e), () => t.disconnect();
|
|
32
35
|
}, [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
]),
|
|
37
|
-
|
|
36
|
+
A,
|
|
37
|
+
S,
|
|
38
|
+
y.length
|
|
39
|
+
]), u(() => {
|
|
40
|
+
A(y.length);
|
|
38
41
|
}, [
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
A,
|
|
43
|
+
y.length,
|
|
44
|
+
O
|
|
42
45
|
]);
|
|
43
|
-
let
|
|
46
|
+
let j = d(() => ({
|
|
44
47
|
...e,
|
|
45
|
-
stroke:
|
|
46
|
-
size:
|
|
47
|
-
}), [
|
|
48
|
-
if (
|
|
49
|
-
let
|
|
48
|
+
stroke: w?.iconStrokeWidth ?? e.stroke,
|
|
49
|
+
size: w?.iconSize ?? e.size
|
|
50
|
+
}), [w?.iconStrokeWidth, w?.iconSize]);
|
|
51
|
+
if (y.length === 0) return null;
|
|
52
|
+
let M = S ? y.slice(0, O) : y, N = S ? y.slice(O) : [], P = N.map((e, t) => ({
|
|
50
53
|
key: String(t),
|
|
51
54
|
label: e.title,
|
|
52
|
-
onClick: () =>
|
|
55
|
+
onClick: () => b(e)
|
|
53
56
|
}));
|
|
54
|
-
return /* @__PURE__ */
|
|
55
|
-
ref:
|
|
56
|
-
className: "mb-4 w-full",
|
|
57
|
-
children: /* @__PURE__ */
|
|
57
|
+
return /* @__PURE__ */ m("div", {
|
|
58
|
+
ref: T,
|
|
59
|
+
className: o("mb-4 w-full", g.root),
|
|
60
|
+
children: /* @__PURE__ */ h("div", {
|
|
58
61
|
role: "list",
|
|
59
|
-
"aria-label":
|
|
60
|
-
className:
|
|
61
|
-
children: [
|
|
62
|
+
"aria-label": C.list,
|
|
63
|
+
className: o(S ? "flex flex-wrap justify-center gap-2" : "flex flex-col items-center gap-2", g.list),
|
|
64
|
+
children: [M.map((e, n) => /* @__PURE__ */ m("div", {
|
|
62
65
|
role: "listitem",
|
|
63
66
|
ref: (e) => {
|
|
64
|
-
|
|
67
|
+
E.current[n] = e;
|
|
65
68
|
},
|
|
66
|
-
children: /* @__PURE__ */
|
|
69
|
+
children: /* @__PURE__ */ m(i, {
|
|
67
70
|
label: e.title,
|
|
68
71
|
appearance: t.Outlined,
|
|
69
|
-
onClick: () =>
|
|
72
|
+
onClick: () => b(e)
|
|
70
73
|
})
|
|
71
|
-
}, e.const)),
|
|
74
|
+
}, e.const)), N.length > 0 && /* @__PURE__ */ m("div", {
|
|
72
75
|
role: "listitem",
|
|
73
|
-
children: /* @__PURE__ */
|
|
74
|
-
items:
|
|
76
|
+
children: /* @__PURE__ */ m(r, {
|
|
77
|
+
items: P,
|
|
75
78
|
placement: "bottom-end",
|
|
76
79
|
matchReferenceWidth: !1,
|
|
77
|
-
children: /* @__PURE__ */
|
|
80
|
+
children: /* @__PURE__ */ m(a, {
|
|
78
81
|
appearance: t.Outlined,
|
|
79
|
-
icon:
|
|
80
|
-
...
|
|
82
|
+
icon: m(x ? s : c, {
|
|
83
|
+
...j,
|
|
81
84
|
stroke: n
|
|
82
85
|
}),
|
|
83
|
-
"aria-label":
|
|
86
|
+
"aria-label": C.overflow
|
|
84
87
|
})
|
|
85
88
|
})
|
|
86
89
|
})]
|
|
@@ -88,4 +91,4 @@ var h = 4, g = 8, _ = ({ starters: _, onSelect: v, isMobile: y, isCollapsible: b
|
|
|
88
91
|
});
|
|
89
92
|
};
|
|
90
93
|
//#endregion
|
|
91
|
-
export {
|
|
94
|
+
export { g as STARTER_BUTTONS_CLASS, y 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.2.0-dev.
|
|
4
|
+
"version": "1.2.0-dev.69",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"types": "./index.d.ts",
|
|
10
10
|
"exports": {
|
|
11
11
|
"./package.json": "./package.json",
|
|
12
|
+
"./styles.css": "./index.css",
|
|
12
13
|
".": {
|
|
13
14
|
"types": "./index.d.ts",
|
|
14
15
|
"import": "./index.js",
|
|
@@ -19,9 +20,9 @@
|
|
|
19
20
|
"@tabler/icons-react": "^3.44.0"
|
|
20
21
|
},
|
|
21
22
|
"peerDependencies": {
|
|
22
|
-
"@epam/ai-dial-chat-shared": "1.2.0-dev.
|
|
23
|
+
"@epam/ai-dial-chat-shared": "1.2.0-dev.69",
|
|
23
24
|
"react": "^19.2.8",
|
|
24
|
-
"@epam/ai-dial-ui-kit": "^0.
|
|
25
|
+
"@epam/ai-dial-ui-kit": "^0.15.0-dev.9"
|
|
25
26
|
},
|
|
26
27
|
"repository": {
|
|
27
28
|
"type": "git",
|