@epam/ai-dial-starter-buttons 1.1.0-dev.39 → 1.1.0-dev.44

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