@epam/ai-dial-starter-buttons 0.0.0-dev.0

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.
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { StarterButtonsProps } from '../../models/starter-props';
3
+ export declare const StarterButtons: FC<StarterButtonsProps>;
4
+ //# sourceMappingURL=StarterButtons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StarterButtons.d.ts","sourceRoot":"","sources":["../../../src/components/StarterButtons/StarterButtons.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,EAAE,EAA4C,MAAM,OAAO,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAMtE,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAuIlD,CAAC"}
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { StarterButtons } from './components/StarterButtons/StarterButtons';
2
+ export type { StarterButtonsProps, StarterButtonsAriaLabels, } from './models/starter-props';
3
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +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,wBAAwB,GACzB,MAAM,wBAAwB,CAAC"}
package/index.js ADDED
@@ -0,0 +1,75 @@
1
+ import { DIAL_ICON_SIZE as e, DialDropdown as t, DialRoundedButton as n } from "@epam/ai-dial-ui-kit";
2
+ import { IconDots as r, IconDotsVertical as i } from "@tabler/icons-react";
3
+ import { useCallback as a, useEffect as o, useRef as s, useState as c } from "react";
4
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
5
+ //#region src/components/StarterButtons/StarterButtons.tsx
6
+ var d = 4, f = 8, p = ({ starters: p, onSelect: m, isMobile: h, ariaLabels: g }) => {
7
+ let _ = s(null), v = s([]), y = s([]), [b, x] = c(() => Math.min(p.length, d)), S = a((e) => {
8
+ let t = _.current;
9
+ if (!t) return;
10
+ let n = t.getBoundingClientRect().width;
11
+ if (n === 0) return;
12
+ let r = Math.min(e, d);
13
+ v.current.slice(0, r).every((e) => e != null) && (y.current = v.current.slice(0, r).map((e) => e?.getBoundingClientRect().width ?? 0));
14
+ let i = (e) => y.current[e] ?? 120, a = 0, o = 0;
15
+ for (let t = 0; t < r; t++) {
16
+ let r = i(t), s = e - (t + 1) > 0;
17
+ if (a + (t > 0 ? f : 0) + r + (s ? 64 : 0) > n) break;
18
+ a += (t > 0 ? f : 0) + r, o = t + 1;
19
+ }
20
+ x(Math.max(1, o));
21
+ }, []);
22
+ if (o(() => {
23
+ y.current = [], x(Math.min(p.length, d));
24
+ }, [p.length]), o(() => {
25
+ let e = _.current;
26
+ if (!e) return;
27
+ let t = new ResizeObserver(() => {
28
+ S(p.length);
29
+ });
30
+ return t.observe(e), () => t.disconnect();
31
+ }, [S, p.length]), o(() => {
32
+ S(p.length);
33
+ }), p.length === 0) return null;
34
+ let C = Math.min(b, d), w = p.slice(0, C), T = p.slice(C), E = T.map((e, t) => ({
35
+ key: String(t),
36
+ label: e.title,
37
+ onClick: () => m(e)
38
+ }));
39
+ return /* @__PURE__ */ l("div", {
40
+ ref: _,
41
+ className: "mt-4 w-full",
42
+ children: /* @__PURE__ */ u("div", {
43
+ role: "list",
44
+ "aria-label": g.list,
45
+ className: "flex flex-wrap justify-center gap-2",
46
+ children: [w.map((e, t) => /* @__PURE__ */ l("div", {
47
+ role: "listitem",
48
+ ref: (e) => {
49
+ v.current[t] = e;
50
+ },
51
+ children: /* @__PURE__ */ l(n, {
52
+ label: e.title,
53
+ onClick: () => m(e)
54
+ })
55
+ }, e.const)), T.length > 0 && /* @__PURE__ */ l("div", {
56
+ role: "listitem",
57
+ children: /* @__PURE__ */ l(t, {
58
+ items: E,
59
+ placement: "bottom-end",
60
+ matchReferenceWidth: !1,
61
+ listClassName: "cp-dropdown-overlay",
62
+ children: /* @__PURE__ */ l(n, {
63
+ iconAfter: l(h ? r : i, {
64
+ stroke: 1.5,
65
+ size: e.MD
66
+ }),
67
+ "aria-label": g.overflow
68
+ })
69
+ })
70
+ })]
71
+ })
72
+ });
73
+ };
74
+ //#endregion
75
+ export { p as StarterButtons };
@@ -0,0 +1,12 @@
1
+ import { StarterOption } from '@epam/ai-dial-chat-shared';
2
+ export interface StarterButtonsAriaLabels {
3
+ list: string;
4
+ overflow: string;
5
+ }
6
+ export interface StarterButtonsProps {
7
+ starters: StarterOption[];
8
+ onSelect: (starter: StarterOption) => void;
9
+ isMobile?: boolean;
10
+ ariaLabels: StarterButtonsAriaLabels;
11
+ }
12
+ //# sourceMappingURL=starter-props.d.ts.map
@@ -0,0 +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,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,wBAAwB,CAAC;CACtC"}
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@epam/ai-dial-starter-buttons",
3
+ "version": "0.0.0-dev.0",
4
+ "license": "Apache-2.0",
5
+ "type": "module",
6
+ "main": "./index.js",
7
+ "module": "./index.js",
8
+ "types": "./index.d.ts",
9
+ "exports": {
10
+ "./package.json": "./package.json",
11
+ ".": {
12
+ "types": "./index.d.ts",
13
+ "import": "./index.js",
14
+ "default": "./index.js"
15
+ }
16
+ },
17
+ "peerDependencies": {
18
+ "@epam/ai-dial-chat-shared": "0.0.0-dev.0",
19
+ "@epam/ai-dial-ui-kit": "0.12.0-dev.21",
20
+ "@tabler/icons-react": "^3.44.0",
21
+ "react": "^19.0.0"
22
+ }
23
+ }
@@ -0,0 +1,6 @@
1
+ declare class ResizeObserverMock {
2
+ observe(): void;
3
+ unobserve(): void;
4
+ disconnect(): void;
5
+ }
6
+ //# sourceMappingURL=test-setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-setup.d.ts","sourceRoot":"","sources":["../src/test-setup.ts"],"names":[],"mappings":"AAEA,cAAM,kBAAkB;IACtB,OAAO;IACP,SAAS;IACT,UAAU;CACX"}