@epam/ai-dial-starter-buttons 1.1.0-dev.74 → 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":"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"}
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 { DialDropdown as t, NeutralButton as n } from "@epam/ai-dial-ui-kit";
3
- import { IconDots as r, IconDotsVertical as i } from "@tabler/icons-react";
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";
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 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;
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, 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;
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 ? p : 0) + r + (s ? 64 : 0) > n) break;
19
- a += (t > 0 ? p : 0) + r, o = t + 1;
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
- C(Math.max(1, o));
21
+ T(Math.max(1, o));
22
22
  }, []);
23
- o(() => {
24
- x.current = [], C(Math.min(m.length, f));
25
- }, [m.length]), o(() => {
26
- let e = y.current;
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
- w(m.length);
29
+ E(g.length);
30
30
  });
31
31
  return t.observe(e), () => t.disconnect();
32
- }, [w, m.length]), o(() => {
33
- w(m.length);
32
+ }, [E, g.length]), c(() => {
33
+ E(g.length);
34
34
  });
35
- let T = s(() => ({
35
+ let D = l(() => ({
36
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) => ({
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: () => h(e)
44
+ onClick: () => _(e)
45
45
  }));
46
- return /* @__PURE__ */ u("div", {
47
- ref: y,
46
+ return /* @__PURE__ */ f("div", {
47
+ ref: x,
48
48
  className: "mb-4 w-full",
49
- children: /* @__PURE__ */ d("div", {
49
+ children: /* @__PURE__ */ p("div", {
50
50
  role: "list",
51
- "aria-label": _.list,
51
+ "aria-label": y.list,
52
52
  className: "flex flex-wrap justify-center gap-2",
53
- children: [D.map((e, t) => /* @__PURE__ */ u("div", {
53
+ children: [k.map((e, n) => /* @__PURE__ */ f("div", {
54
54
  role: "listitem",
55
55
  ref: (e) => {
56
- b.current[t] = e;
56
+ S.current[n] = e;
57
57
  },
58
- children: /* @__PURE__ */ u(n, {
58
+ children: /* @__PURE__ */ f(r, {
59
59
  label: e.title,
60
- onClick: () => h(e)
60
+ appearance: t.Outlined,
61
+ onClick: () => _(e)
61
62
  })
62
- }, e.const)), O.length > 0 && /* @__PURE__ */ u("div", {
63
+ }, e.const)), A.length > 0 && /* @__PURE__ */ f("div", {
63
64
  role: "listitem",
64
- children: /* @__PURE__ */ u(t, {
65
- items: k,
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__ */ u(n, {
70
- iconAfter: u(g ? r : i, { ...T }),
71
- "aria-label": _.overflow
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 { m as StarterButtons };
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.74",
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.74",
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.23"
22
+ "@epam/ai-dial-ui-kit": "^0.13.0-dev.25"
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",