@epam/ai-dial-ui-kit 0.15.0-dev.31 → 0.15.0-dev.35

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,70 @@
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import { useState as C } from "react";
3
+ import { DIAL_KIT_CLASS as b } from "../../../constants/public-class-names.js";
4
+ import { AvatarShape as d } from "../../../types/avatar.js";
5
+ import { pickAvatarColor as w, extractInitials as I } from "../../../utils/avatar.js";
6
+ import { mergeClasses as e } from "../../../utils/merge-classes.js";
7
+ const N = {
8
+ [d.Circle]: "rounded-full",
9
+ [d.Square]: "rounded-md"
10
+ }, E = ({
11
+ name: s,
12
+ initials: c,
13
+ src: r,
14
+ alt: t = "",
15
+ size: o = 32,
16
+ shape: f = d.Circle,
17
+ className: h,
18
+ textClassName: l,
19
+ onImageError: u
20
+ }) => {
21
+ const [S, p] = C(), v = !!r && S !== r, i = t !== "", m = (n) => e(
22
+ "inline-flex shrink-0 select-none items-center justify-center overflow-hidden",
23
+ N[f],
24
+ n,
25
+ h,
26
+ b.avatar
27
+ );
28
+ if (v)
29
+ return /* @__PURE__ */ a(
30
+ "img",
31
+ {
32
+ src: r,
33
+ alt: t,
34
+ width: o,
35
+ height: o,
36
+ className: e(m(), "object-cover"),
37
+ onError: (n) => {
38
+ p(r), u?.(n);
39
+ }
40
+ }
41
+ );
42
+ const { background: g, foreground: A } = w(s);
43
+ return /* @__PURE__ */ a(
44
+ "span",
45
+ {
46
+ role: i ? "img" : void 0,
47
+ "aria-label": i ? t : void 0,
48
+ "aria-hidden": i ? void 0 : !0,
49
+ className: m(e(g, A)),
50
+ style: {
51
+ width: o,
52
+ height: o,
53
+ fontSize: l ? void 0 : Math.round(o * 0.4)
54
+ },
55
+ children: /* @__PURE__ */ a(
56
+ "span",
57
+ {
58
+ className: e(
59
+ "leading-none",
60
+ l ?? "font-semibold"
61
+ ),
62
+ children: c ?? I(s)
63
+ }
64
+ )
65
+ }
66
+ );
67
+ };
68
+ export {
69
+ E as Avatar
70
+ };
@@ -0,0 +1,45 @@
1
+ import { jsxs as g, jsx as i } from "react/jsx-runtime";
2
+ import { DIAL_KIT_CLASS as m } from "../../../constants/public-class-names.js";
3
+ import { BadgeVariant as t, BadgeColor as e } from "../../../types/badge.js";
4
+ import { mergeClasses as x } from "../../../utils/merge-classes.js";
5
+ const b = {
6
+ [e.Blue]: "bg-blue text-blue",
7
+ [e.Green]: "bg-green-2 text-green-1",
8
+ [e.Violet]: "bg-violet-2 text-violet-1",
9
+ [e.Indigo]: "bg-violet-1 text-violet-2",
10
+ [e.Brown]: "bg-brown text-brown-2",
11
+ [e.Red]: "bg-red text-red"
12
+ }, c = {
13
+ [t.Outlined]: "rounded-md border border-tertiary bg-layer-sunken text-secondary",
14
+ [t.Filled]: "rounded-full"
15
+ }, p = {
16
+ [t.Outlined]: "dial-tiny-text",
17
+ [t.Filled]: "dial-caption-lead-semi-text"
18
+ }, L = ({
19
+ label: n,
20
+ variant: r = t.Outlined,
21
+ color: d = e.Blue,
22
+ icon: l,
23
+ textClassName: o,
24
+ className: s,
25
+ ...a
26
+ }) => /* @__PURE__ */ g(
27
+ "span",
28
+ {
29
+ ...a,
30
+ className: x(
31
+ "inline-flex h-6 w-fit shrink-0 items-center gap-1 whitespace-nowrap px-2",
32
+ c[r],
33
+ r === t.Filled && b[d],
34
+ s,
35
+ m.badge
36
+ ),
37
+ children: [
38
+ l && /* @__PURE__ */ i("span", { className: "flex shrink-0 items-center", "aria-hidden": "true", children: l }),
39
+ /* @__PURE__ */ i("span", { className: o ?? p[r], children: n })
40
+ ]
41
+ }
42
+ );
43
+ export {
44
+ L as Badge
45
+ };
@@ -0,0 +1,114 @@
1
+ import { jsx as e, jsxs as m } from "react/jsx-runtime";
2
+ import { useFloating as C, useRole as L, useDismiss as _, useInteractions as k, FloatingPortal as A, FloatingOverlay as O, FloatingFocusManager as w } from "@floating-ui/react";
3
+ import { IconArrowLeft as z } from "@tabler/icons-react";
4
+ import { useId as D } from "react";
5
+ import { CloseButton as T } from "../CloseButton/CloseButton.js";
6
+ import { DIAL_KIT_ICON_STROKE as j } from "../constants/icon.js";
7
+ import { GhostIconButton as B } from "../IconButton/IconButtonWrappers.js";
8
+ import { useThemeScope as E } from "../ThemeScope/ThemeScope.js";
9
+ import { DIAL_ICON_SIZE as K } from "../../../constants/icon.js";
10
+ import { DIAL_KIT_CLASS as P } from "../../../constants/public-class-names.js";
11
+ import { ElementSize as G } from "../../../types/size.js";
12
+ import { mergeClasses as t } from "../../../utils/merge-classes.js";
13
+ const Y = ({
14
+ open: i,
15
+ onClose: a,
16
+ title: o,
17
+ ariaLabel: c,
18
+ onBack: s,
19
+ backAriaLabel: d = "Back",
20
+ closeAriaLabel: u = "Close",
21
+ closeOnOutsideClick: f = !0,
22
+ children: p,
23
+ className: h,
24
+ overlayClassName: b,
25
+ bodyClassName: g,
26
+ titleClassName: x,
27
+ portalId: I
28
+ }) => {
29
+ const S = E(), l = `bottom-sheet-title-${D()}`, { refs: n, context: r } = C({
30
+ open: i,
31
+ onOpenChange: (F) => {
32
+ F || a();
33
+ }
34
+ }), N = L(r, { role: "dialog" }), v = _(r, { outsidePress: f }), { getFloatingProps: y } = k([N, v]);
35
+ return i ? /* @__PURE__ */ e(A, { id: I, children: /* @__PURE__ */ e(
36
+ O,
37
+ {
38
+ lockScroll: !0,
39
+ className: t(
40
+ "z-popup flex items-end bg-backdrop",
41
+ S,
42
+ b
43
+ ),
44
+ children: /* @__PURE__ */ e(w, { context: r, initialFocus: n.floating, children: /* @__PURE__ */ m(
45
+ "div",
46
+ {
47
+ ref: n.setFloating,
48
+ ...y(),
49
+ role: "dialog",
50
+ "aria-modal": "true",
51
+ "aria-labelledby": o ? l : void 0,
52
+ "aria-label": o ? void 0 : c,
53
+ className: t(
54
+ "flex max-h-[85dvh] w-full flex-col rounded-t-lg bg-layer-raised outline-none",
55
+ "animate-slideUp motion-reduce:animate-none",
56
+ h,
57
+ P.bottomSheet
58
+ ),
59
+ children: [
60
+ o && /* @__PURE__ */ m("div", { className: "relative flex h-[60px] shrink-0 items-center justify-center border-b border-tertiary px-14", children: [
61
+ s && /* @__PURE__ */ e(
62
+ B,
63
+ {
64
+ "aria-label": d,
65
+ className: "absolute start-4",
66
+ onClick: s,
67
+ icon: /* @__PURE__ */ e(
68
+ z,
69
+ {
70
+ size: K.LG,
71
+ stroke: j,
72
+ className: "rtl:-scale-x-100",
73
+ "aria-hidden": "true"
74
+ }
75
+ )
76
+ }
77
+ ),
78
+ /* @__PURE__ */ e(
79
+ "h2",
80
+ {
81
+ id: l,
82
+ className: t(
83
+ "min-w-0 truncate text-primary",
84
+ x ?? "dial-body-semi-text"
85
+ ),
86
+ children: o
87
+ }
88
+ ),
89
+ /* @__PURE__ */ e(
90
+ T,
91
+ {
92
+ ariaLabel: u,
93
+ onClose: a,
94
+ size: G.Standard,
95
+ className: "absolute end-4"
96
+ }
97
+ )
98
+ ] }),
99
+ /* @__PURE__ */ e(
100
+ "div",
101
+ {
102
+ className: t("min-h-0 overflow-y-auto", g),
103
+ children: p
104
+ }
105
+ )
106
+ ]
107
+ }
108
+ ) })
109
+ }
110
+ ) }) : null;
111
+ };
112
+ export {
113
+ Y as BottomSheet
114
+ };
@@ -0,0 +1,144 @@
1
+ import { jsx as e, jsxs as c } from "react/jsx-runtime";
2
+ import { useFloating as O, useRole as z, useDismiss as A, useInteractions as E, FloatingPortal as K, FloatingOverlay as P, FloatingFocusManager as j } from "@floating-ui/react";
3
+ import { IconChevronLeft as M } from "@tabler/icons-react";
4
+ import { useId as R } from "react";
5
+ import { CloseButton as B } from "../CloseButton/CloseButton.js";
6
+ import { DIAL_KIT_ICON_STROKE as G } from "../constants/icon.js";
7
+ import { GhostIconButton as H } from "../IconButton/IconButtonWrappers.js";
8
+ import { useThemeScope as Z } from "../ThemeScope/ThemeScope.js";
9
+ import { DIAL_ICON_SIZE as $ } from "../../../constants/icon.js";
10
+ import { DIAL_KIT_CLASS as q } from "../../../constants/public-class-names.js";
11
+ import { ElementSize as J } from "../../../types/size.js";
12
+ import { mergeClasses as r } from "../../../utils/merge-classes.js";
13
+ const ae = ({
14
+ open: t,
15
+ onClose: l,
16
+ header: o,
17
+ ariaLabel: f,
18
+ headerActions: p,
19
+ onBack: i,
20
+ backAriaLabel: u = "Back",
21
+ backDisabled: x = !1,
22
+ closeAriaLabel: g = "Close",
23
+ closeDisabled: b = !1,
24
+ hideClose: n = !1,
25
+ closeOnOutsideClick: h = !0,
26
+ children: y,
27
+ className: I,
28
+ overlayClassName: v,
29
+ headerClassName: S,
30
+ bodyClassName: w,
31
+ titleClassName: N,
32
+ portalId: k
33
+ }) => {
34
+ const F = Z(), d = `side-drawer-title-${R()}`, s = typeof o == "string", { refs: m, context: a } = O({
35
+ open: t,
36
+ onOpenChange: (T) => {
37
+ T || l();
38
+ }
39
+ }), C = z(a, { role: "dialog" }), D = A(a, { outsidePress: h }), { getFloatingProps: _ } = E([C, D]), L = o != null || i != null || !n;
40
+ return /* @__PURE__ */ e(K, { id: k, children: /* @__PURE__ */ e(
41
+ P,
42
+ {
43
+ lockScroll: t,
44
+ className: r(
45
+ "z-popup bg-backdrop transition-opacity duration-300 motion-reduce:transition-none",
46
+ t ? "opacity-100" : "pointer-events-none opacity-0",
47
+ F,
48
+ v
49
+ ),
50
+ children: /* @__PURE__ */ e(
51
+ j,
52
+ {
53
+ context: a,
54
+ disabled: !t,
55
+ initialFocus: m.floating,
56
+ children: /* @__PURE__ */ c(
57
+ "div",
58
+ {
59
+ ref: m.setFloating,
60
+ ..._(),
61
+ role: "dialog",
62
+ "aria-modal": "true",
63
+ "aria-labelledby": s ? d : void 0,
64
+ "aria-label": s ? void 0 : f,
65
+ inert: !t,
66
+ className: r(
67
+ "fixed inset-y-0 end-0 flex w-full flex-col overflow-hidden bg-layer-raised outline-none",
68
+ "desktop:w-[540px] desktop:rounded-s-xl desktop:border-s desktop:border-secondary",
69
+ "transition-transform duration-300 motion-reduce:transition-none",
70
+ t ? "translate-x-0" : "translate-x-full rtl:-translate-x-full",
71
+ I,
72
+ q.sideDrawer
73
+ ),
74
+ children: [
75
+ L && /* @__PURE__ */ c(
76
+ "div",
77
+ {
78
+ className: r(
79
+ "flex shrink-0 items-center gap-2 border-b border-tertiary px-6 py-3",
80
+ S
81
+ ),
82
+ children: [
83
+ i && /* @__PURE__ */ e(
84
+ H,
85
+ {
86
+ "aria-label": u,
87
+ disabled: x,
88
+ onClick: i,
89
+ icon: /* @__PURE__ */ e(
90
+ M,
91
+ {
92
+ size: $.MD,
93
+ stroke: G,
94
+ className: "rtl:-scale-x-100",
95
+ "aria-hidden": "true"
96
+ }
97
+ )
98
+ }
99
+ ),
100
+ s ? /* @__PURE__ */ e(
101
+ "h2",
102
+ {
103
+ id: d,
104
+ className: r(
105
+ "min-w-0 flex-1 truncate text-primary",
106
+ N ?? "dial-h2-text"
107
+ ),
108
+ children: o
109
+ }
110
+ ) : /* @__PURE__ */ e("div", { className: "min-w-0 flex-1", children: o }),
111
+ p,
112
+ !n && /* @__PURE__ */ e(
113
+ B,
114
+ {
115
+ ariaLabel: g,
116
+ onClose: l,
117
+ disabled: b,
118
+ size: J.Standard
119
+ }
120
+ )
121
+ ]
122
+ }
123
+ ),
124
+ /* @__PURE__ */ e(
125
+ "div",
126
+ {
127
+ className: r(
128
+ "min-h-0 flex-1 overflow-y-auto",
129
+ w
130
+ ),
131
+ children: y
132
+ }
133
+ )
134
+ ]
135
+ }
136
+ )
137
+ }
138
+ )
139
+ }
140
+ ) });
141
+ };
142
+ export {
143
+ ae as SideDrawer
144
+ };