@epam/ai-dial-starter-buttons 1.1.0-dev.9 → 1.1.0-dev.90

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":"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,72 +1,76 @@
1
1
  import { BASE_MD_ICON_PROPS as e } from "@epam/ai-dial-chat-shared";
2
- import { DialDropdown as t, DialRoundedButton 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, useRef as s, useState as c } from "react";
5
- import { jsx as l, jsxs as u } 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 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 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, 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, 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 ? f : 0) + r + (s ? 64 : 0) > n) break;
19
- a += (t > 0 ? f : 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
- S(Math.max(1, o));
21
+ T(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
+ 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
- C(p.length);
29
+ E(g.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
+ }, [E, g.length]), c(() => {
33
+ E(g.length);
34
+ });
35
+ let D = l(() => ({
36
+ ...e,
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) => ({
36
42
  key: String(t),
37
43
  label: e.title,
38
- onClick: () => m(e)
44
+ onClick: () => _(e)
39
45
  }));
40
- return /* @__PURE__ */ l("div", {
41
- ref: v,
46
+ return /* @__PURE__ */ f("div", {
47
+ ref: x,
42
48
  className: "mb-4 w-full",
43
- children: /* @__PURE__ */ u("div", {
49
+ children: /* @__PURE__ */ p("div", {
44
50
  role: "list",
45
- "aria-label": g.list,
51
+ "aria-label": y.list,
46
52
  className: "flex flex-wrap justify-center gap-2",
47
- children: [T.map((e, t) => /* @__PURE__ */ l("div", {
53
+ children: [k.map((e, n) => /* @__PURE__ */ f("div", {
48
54
  role: "listitem",
49
55
  ref: (e) => {
50
- y.current[t] = e;
56
+ S.current[n] = e;
51
57
  },
52
- children: /* @__PURE__ */ l(n, {
58
+ children: /* @__PURE__ */ f(r, {
53
59
  label: e.title,
54
- onClick: () => m(e)
60
+ appearance: t.Outlined,
61
+ onClick: () => _(e)
55
62
  })
56
- }, e.const)), E.length > 0 && /* @__PURE__ */ l("div", {
63
+ }, e.const)), A.length > 0 && /* @__PURE__ */ f("div", {
57
64
  role: "listitem",
58
- children: /* @__PURE__ */ l(t, {
59
- items: D,
65
+ children: /* @__PURE__ */ f(n, {
66
+ items: j,
60
67
  placement: "bottom-end",
61
68
  matchReferenceWidth: !1,
62
69
  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
70
+ children: /* @__PURE__ */ f(i, {
71
+ appearance: t.Outlined,
72
+ icon: f(v ? a : o, { ...D }),
73
+ "aria-label": y.overflow
70
74
  })
71
75
  })
72
76
  })]
@@ -74,4 +78,4 @@ var d = 4, f = 8, p = ({ starters: p, onSelect: m, isMobile: h, labels: g, style
74
78
  });
75
79
  };
76
80
  //#endregion
77
- export { p as StarterButtons };
81
+ export { g as StarterButtons };
@@ -1,18 +1,19 @@
1
1
  import { StarterOption } from '@epam/ai-dial-chat-shared';
2
- /** Localized text strings used by the StarterButtons component. */
2
+ /** Accessible labels used by the `StarterButtons` component. */
3
3
  export interface StarterButtonsLabels {
4
- /** Label for the visible list of starter buttons. */
4
+ /** Accessible label (`aria-label`) for the visible buttons list. */
5
5
  list: string;
6
- /** Label for the overflow menu that holds buttons that do not fit. */
6
+ /** Accessible label (`aria-label`) for the overflow menu button. */
7
7
  overflow: string;
8
8
  }
9
+ /** Style overrides for the `StarterButtons` component. */
9
10
  export interface StarterButtonsStyles {
10
- /** Extra CSS class applied to the outer container div. */
11
+ /** Icon size in px for the overflow menu icon. Defaults to `BASE_MD_ICON_PROPS.size`. */
11
12
  iconSize?: number;
12
- /** Stroke width of the search and clear icons. Defaults to the icon's own default. */
13
+ /** Stroke width for the overflow menu icon. Defaults to `BASE_MD_ICON_PROPS.stroke`. */
13
14
  iconStrokeWidth?: number;
14
15
  }
15
- /** Props for the StarterButtons component. */
16
+ /** Props for the `StarterButtons` component. */
16
17
  export interface StarterButtonsProps {
17
18
  /** Starter prompt options to display as buttons. */
18
19
  starters: StarterOption[];
@@ -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,mEAAmE;AACnE,MAAM,WAAW,oBAAoB;IACnC,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAA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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.9",
4
+ "version": "1.1.0-dev.90",
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.9",
20
- "@epam/ai-dial-ui-kit": "0.12.0-dev.36",
19
+ "@epam/ai-dial-chat-shared": "1.1.0-dev.90",
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.26"
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",