@purpur/library 9.0.10 → 9.1.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.
- package/CHANGELOG.json +33 -0
- package/CHANGELOG.md +15 -1
- package/dist/LICENSE.txt +45 -24
- package/dist/{autocomplete-Dy8YL7Mo.js → autocomplete-B421J7CS.js} +2 -2
- package/dist/{autocomplete-Dy8YL7Mo.js.map → autocomplete-B421J7CS.js.map} +1 -1
- package/dist/{autocomplete-Dn503hFM.mjs → autocomplete-B8L-dTmF.mjs} +3 -3
- package/dist/{autocomplete-Dn503hFM.mjs.map → autocomplete-B8L-dTmF.mjs.map} +1 -1
- package/dist/autocomplete.cjs.js +1 -1
- package/dist/autocomplete.es.js +1 -1
- package/dist/chat-field-CxOqk0-9.js +2 -0
- package/dist/chat-field-CxOqk0-9.js.map +1 -0
- package/dist/chat-field-yK-TwW0D.mjs +149 -0
- package/dist/chat-field-yK-TwW0D.mjs.map +1 -0
- package/dist/chat-field.cjs.js +2 -0
- package/dist/chat-field.cjs.js.map +1 -0
- package/dist/chat-field.es.js +5 -0
- package/dist/chat-field.es.js.map +1 -0
- package/dist/components/autocomplete/src/autocomplete.d.ts.map +1 -1
- package/dist/components/chat-field/src/chat-field.d.ts +71 -0
- package/dist/components/chat-field/src/chat-field.d.ts.map +1 -0
- package/dist/components/dismissable-chip-group/src/dismissable-chip-group-item.d.ts.map +1 -1
- package/dist/components/dismissable-chip-group/src/dismissable-chip-group.d.ts +6 -1
- package/dist/components/dismissable-chip-group/src/dismissable-chip-group.d.ts.map +1 -1
- package/dist/components/dropdown/src/dropdown-combobox.d.ts +34 -0
- package/dist/components/dropdown/src/dropdown-combobox.d.ts.map +1 -0
- package/dist/components/dropdown/src/dropdown-select.d.ts +34 -0
- package/dist/components/dropdown/src/dropdown-select.d.ts.map +1 -0
- package/dist/components/dropdown/src/dropdown-shared.d.ts +51 -0
- package/dist/components/dropdown/src/dropdown-shared.d.ts.map +1 -0
- package/dist/components/dropdown/src/dropdown.d.ts +6 -0
- package/dist/components/dropdown/src/dropdown.d.ts.map +1 -0
- package/dist/components/dropdown/src/dropdown.types.d.ts +94 -0
- package/dist/components/dropdown/src/dropdown.types.d.ts.map +1 -0
- package/dist/components/dropdown/src/useDropdown.d.ts +38 -0
- package/dist/components/dropdown/src/useDropdown.d.ts.map +1 -0
- package/dist/components/dropdown/src/useDropdownFilter.d.ts +9 -0
- package/dist/components/dropdown/src/useDropdownFilter.d.ts.map +1 -0
- package/dist/components/dropdown/src/useDropdownHighlight.d.ts +19 -0
- package/dist/components/dropdown/src/useDropdownHighlight.d.ts.map +1 -0
- package/dist/components/dropdown/src/useDropdownInput.d.ts +12 -0
- package/dist/components/dropdown/src/useDropdownInput.d.ts.map +1 -0
- package/dist/components/dropdown/src/useOnClickOutside.d.ts +2 -0
- package/dist/components/dropdown/src/useOnClickOutside.d.ts.map +1 -0
- package/dist/components/listbox/src/listbox-item.d.ts +2 -0
- package/dist/components/listbox/src/listbox-item.d.ts.map +1 -1
- package/dist/components/search-field/src/search-field-autocomplete.d.ts +73 -0
- package/dist/components/search-field/src/search-field-autocomplete.d.ts.map +1 -0
- package/dist/components/search-field/src/search-field-base.d.ts +97 -0
- package/dist/components/search-field/src/search-field-base.d.ts.map +1 -0
- package/dist/components/search-field/src/search-field.d.ts +123 -41
- package/dist/components/search-field/src/search-field.d.ts.map +1 -1
- package/dist/components/text-field/src/text-field-ai.d.ts +669 -0
- package/dist/components/text-field/src/text-field-ai.d.ts.map +1 -0
- package/dist/components/text-field/src/text-field-base.d.ts +671 -0
- package/dist/components/text-field/src/text-field-base.d.ts.map +1 -0
- package/dist/components/text-field/src/text-field.d.ts +42 -4
- package/dist/components/text-field/src/text-field.d.ts.map +1 -1
- package/dist/components-metadata.js +29 -1
- package/dist/{date-field-DACXrowI.mjs → date-field-4tYMPw89.mjs} +2 -2
- package/dist/{date-field-DACXrowI.mjs.map → date-field-4tYMPw89.mjs.map} +1 -1
- package/dist/{date-field-Z3LKO4b7.js → date-field-B7ipm5sH.js} +2 -2
- package/dist/{date-field-Z3LKO4b7.js.map → date-field-B7ipm5sH.js.map} +1 -1
- package/dist/date-field.cjs.js +1 -1
- package/dist/date-field.es.js +1 -1
- package/dist/{date-picker-5Gr_cEqA.js → date-picker-B8L1Hm8r.js} +2 -2
- package/dist/{date-picker-5Gr_cEqA.js.map → date-picker-B8L1Hm8r.js.map} +1 -1
- package/dist/{date-picker-CdVUA8NC.mjs → date-picker-Bp_XpoOF.mjs} +2 -2
- package/dist/{date-picker-CdVUA8NC.mjs.map → date-picker-Bp_XpoOF.mjs.map} +1 -1
- package/dist/date-picker.cjs.js +1 -1
- package/dist/date-picker.es.js +1 -1
- package/dist/dismissable-chip-group-Cd23yjBa.js +2 -0
- package/dist/dismissable-chip-group-Cd23yjBa.js.map +1 -0
- package/dist/dismissable-chip-group-D-gD93ON.mjs +89 -0
- package/dist/dismissable-chip-group-D-gD93ON.mjs.map +1 -0
- package/dist/dismissable-chip-group.cjs.js +1 -1
- package/dist/dismissable-chip-group.es.js +5 -2
- package/dist/dropdown-BC6evqyq.js +2 -0
- package/dist/dropdown-BC6evqyq.js.map +1 -0
- package/dist/dropdown-C-Ze4gvG.mjs +771 -0
- package/dist/dropdown-C-Ze4gvG.mjs.map +1 -0
- package/dist/dropdown.cjs.js +2 -0
- package/dist/dropdown.cjs.js.map +1 -0
- package/dist/dropdown.es.js +6 -0
- package/dist/dropdown.es.js.map +1 -0
- package/dist/libraries/library/src/chat-field.d.ts +6 -0
- package/dist/libraries/library/src/chat-field.d.ts.map +1 -0
- package/dist/libraries/library/src/dropdown.d.ts +6 -0
- package/dist/libraries/library/src/dropdown.d.ts.map +1 -0
- package/dist/libraries/library/src/library.d.ts +2 -0
- package/dist/libraries/library/src/library.d.ts.map +1 -1
- package/dist/library.cjs.js +1 -1
- package/dist/library.es.js +601 -591
- package/dist/library.es.js.map +1 -1
- package/dist/listbox-COBHLRtB.js +2 -0
- package/dist/listbox-COBHLRtB.js.map +1 -0
- package/dist/listbox-DG4KmQP_.mjs +66 -0
- package/dist/listbox-DG4KmQP_.mjs.map +1 -0
- package/dist/listbox.cjs.js +1 -1
- package/dist/listbox.es.js +1 -1
- package/dist/purpur.css +1 -1
- package/dist/{quantity-selector-w10wKMmT.mjs → quantity-selector-CsR6KTG3.mjs} +2 -2
- package/dist/{quantity-selector-w10wKMmT.mjs.map → quantity-selector-CsR6KTG3.mjs.map} +1 -1
- package/dist/{quantity-selector-D28He6R8.js → quantity-selector-DWDg4aFO.js} +2 -2
- package/dist/{quantity-selector-D28He6R8.js.map → quantity-selector-DWDg4aFO.js.map} +1 -1
- package/dist/quantity-selector.cjs.js +1 -1
- package/dist/quantity-selector.es.js +1 -1
- package/dist/search-field-Caj2dKLn.mjs +151 -0
- package/dist/search-field-Caj2dKLn.mjs.map +1 -0
- package/dist/search-field-DAktzYb0.js +2 -0
- package/dist/search-field-DAktzYb0.js.map +1 -0
- package/dist/search-field.cjs.js +1 -1
- package/dist/search-field.es.js +3 -2
- package/dist/{table-YR-bpfU0.mjs → table-DXYHrKI7.mjs} +2 -2
- package/dist/{table-YR-bpfU0.mjs.map → table-DXYHrKI7.mjs.map} +1 -1
- package/dist/{table-CJijBJsy.js → table-x3SDCR-z.js} +2 -2
- package/dist/{table-CJijBJsy.js.map → table-x3SDCR-z.js.map} +1 -1
- package/dist/table.cjs.js +1 -1
- package/dist/table.es.js +1 -1
- package/dist/text-field-BQYzwIrG.mjs +322 -0
- package/dist/text-field-BQYzwIrG.mjs.map +1 -0
- package/dist/text-field-BwxGMWds.js +2 -0
- package/dist/text-field-BwxGMWds.js.map +1 -0
- package/dist/text-field.cjs.js +1 -1
- package/dist/text-field.es.js +4 -3
- package/dist/use-autocomplete.es-BHDgQLae.js +2 -0
- package/dist/use-autocomplete.es-BHDgQLae.js.map +1 -0
- package/dist/use-autocomplete.es-CVv3z8t6.mjs +142 -0
- package/dist/use-autocomplete.es-CVv3z8t6.mjs.map +1 -0
- package/package.json +25 -23
- package/src/aliases.ts +8 -0
- package/src/chat-field.ts +6 -0
- package/src/dropdown.ts +6 -0
- package/src/entries.js +2 -0
- package/src/library.ts +4 -0
- package/dist/dismissable-chip-group-CnziecOt.js +0 -2
- package/dist/dismissable-chip-group-CnziecOt.js.map +0 -1
- package/dist/dismissable-chip-group-ZCYOt1sB.mjs +0 -79
- package/dist/dismissable-chip-group-ZCYOt1sB.mjs.map +0 -1
- package/dist/listbox-BmjBtIv8.js +0 -2
- package/dist/listbox-BmjBtIv8.js.map +0 -1
- package/dist/listbox-oDeP8FvH.mjs +0 -65
- package/dist/listbox-oDeP8FvH.mjs.map +0 -1
- package/dist/search-field-CNpJp3Tg.js +0 -2
- package/dist/search-field-CNpJp3Tg.js.map +0 -1
- package/dist/search-field-CWqLnqdo.mjs +0 -91
- package/dist/search-field-CWqLnqdo.mjs.map +0 -1
- package/dist/text-field-BMDf8j-K.mjs +0 -185
- package/dist/text-field-BMDf8j-K.mjs.map +0 -1
- package/dist/text-field-CiLEj0Fq.js +0 -2
- package/dist/text-field-CiLEj0Fq.js.map +0 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { jsxs as J, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Q, useRef as W, useState as X, useCallback as q, useEffect as T } from "react";
|
|
3
|
+
import { b as I } from "./button-Cv7NlYbv.mjs";
|
|
4
|
+
import { b as V } from "./icon.es-CZcKxTaM.mjs";
|
|
5
|
+
import { c as ee } from "./bind-CU-R61T-.mjs";
|
|
6
|
+
const te = {
|
|
7
|
+
name: "send",
|
|
8
|
+
svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M1.54 2.149a.9.9 0 0 1 .97-.131l19.514 9.212a.9.9 0 0 1 0 1.628L2.51 22.071A.9.9 0 0 1 1.263 21l2.664-8.957-2.664-8.956a.9.9 0 0 1 .277-.94Zm3.997 10.795-1.974 6.64 14.062-6.64H5.537Zm12.088-1.8H5.537L3.563 4.505l14.062 6.64Z" clip-rule="evenodd"/></svg>',
|
|
9
|
+
keywords: ["send"],
|
|
10
|
+
category: "action"
|
|
11
|
+
}, ae = {
|
|
12
|
+
name: "tv-stop",
|
|
13
|
+
svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M19 19H5V5h14v14Z"/><path fill-rule="evenodd" d="M19.9 19a.9.9 0 0 1-.9.9H5a.9.9 0 0 1-.9-.9V5a.9.9 0 0 1 .9-.9h14a.9.9 0 0 1 .9.9v14Zm-1.8-.9V5.9H5.9v12.2h12.2Z" clip-rule="evenodd"/></svg>',
|
|
14
|
+
keywords: ["tv-stop"],
|
|
15
|
+
category: "action"
|
|
16
|
+
}, re = {
|
|
17
|
+
"purpur-chat-field": "_purpur-chat-field_16tq2_1",
|
|
18
|
+
"purpur-chat-field--negative": "_purpur-chat-field--negative_16tq2_13",
|
|
19
|
+
"purpur-chat-field__frame": "_purpur-chat-field__frame_16tq2_16",
|
|
20
|
+
"purpur-chat-field__frame--negative": "_purpur-chat-field__frame--negative_16tq2_20",
|
|
21
|
+
"purpur-chat-field--filled": "_purpur-chat-field--filled_16tq2_34",
|
|
22
|
+
"purpur-chat-field__textarea": "_purpur-chat-field__textarea_16tq2_34",
|
|
23
|
+
"purpur-chat-field__textarea--negative": "_purpur-chat-field__textarea--negative_16tq2_37",
|
|
24
|
+
"purpur-chat-field__action": "_purpur-chat-field__action_16tq2_80"
|
|
25
|
+
}, d = ee.bind(re), le = (...a) => {
|
|
26
|
+
const l = a.filter(Boolean);
|
|
27
|
+
return l.length <= 1 ? l[0] || null : (n) => {
|
|
28
|
+
for (const i of l)
|
|
29
|
+
typeof i == "function" ? i(n) : i && (i.current = n);
|
|
30
|
+
};
|
|
31
|
+
}, t = "purpur-chat-field", ie = Q(
|
|
32
|
+
({
|
|
33
|
+
["data-testid"]: a,
|
|
34
|
+
value: l,
|
|
35
|
+
placeholder: n,
|
|
36
|
+
textareaAriaLabel: i,
|
|
37
|
+
generating: s = !1,
|
|
38
|
+
negative: u = !1,
|
|
39
|
+
sendAriaLabel: k,
|
|
40
|
+
sendIcon: A,
|
|
41
|
+
stopAriaLabel: B,
|
|
42
|
+
rows: f = 1,
|
|
43
|
+
maxRows: m = 4,
|
|
44
|
+
onChange: F,
|
|
45
|
+
onSend: v,
|
|
46
|
+
onStopClick: L,
|
|
47
|
+
actionButtonType: p = "button",
|
|
48
|
+
textareaProps: N,
|
|
49
|
+
className: R
|
|
50
|
+
}, Z) => {
|
|
51
|
+
const h = W(null), {
|
|
52
|
+
["aria-label"]: D,
|
|
53
|
+
["aria-labelledby"]: x,
|
|
54
|
+
defaultValue: _,
|
|
55
|
+
...S
|
|
56
|
+
} = N ?? {}, [j, z] = X(() => typeof _ == "string" || typeof _ == "number" ? String(_) : ""), g = l ?? j, c = !!g.length, E = D ?? (x ? void 0 : i ?? n), y = q(() => {
|
|
57
|
+
const e = h.current;
|
|
58
|
+
if (!e) return;
|
|
59
|
+
e.style.height = "auto", e.style.overflowY = "hidden";
|
|
60
|
+
const r = getComputedStyle(e), w = parseFloat(r.lineHeight) || 20, C = parseFloat(r.paddingTop) || 0, H = parseFloat(r.paddingBottom) || 0, G = w * f + C + H, $ = w * m + C + H;
|
|
61
|
+
e.scrollHeight > $ ? (e.style.height = `${$}px`, e.style.overflowY = "auto") : e.scrollHeight > G && (e.style.height = `${e.scrollHeight}px`);
|
|
62
|
+
}, [f, m]);
|
|
63
|
+
T(() => {
|
|
64
|
+
y();
|
|
65
|
+
}, [g, y]);
|
|
66
|
+
const b = q(
|
|
67
|
+
(e) => {
|
|
68
|
+
if (c) {
|
|
69
|
+
if (p === "submit") {
|
|
70
|
+
const r = h.current?.form;
|
|
71
|
+
if (e === "keyboard" && r) {
|
|
72
|
+
r.requestSubmit();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (e === "button" && r)
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
v();
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
[p, c, v]
|
|
82
|
+
), K = (e) => {
|
|
83
|
+
l === void 0 && z(e.target.value), F(e);
|
|
84
|
+
}, M = (e) => {
|
|
85
|
+
e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing && (e.preventDefault(), b("keyboard"));
|
|
86
|
+
}, P = () => {
|
|
87
|
+
if (s) {
|
|
88
|
+
L();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
b("button");
|
|
92
|
+
}, Y = s || !c ? "button" : p, O = d([
|
|
93
|
+
R,
|
|
94
|
+
t,
|
|
95
|
+
{
|
|
96
|
+
[`${t}--filled`]: c,
|
|
97
|
+
[`${t}--negative`]: u
|
|
98
|
+
}
|
|
99
|
+
]), U = s ? /* @__PURE__ */ o(V, { size: "xs", svg: ae }) : A ?? /* @__PURE__ */ o(V, { size: "xs", svg: te });
|
|
100
|
+
return /* @__PURE__ */ J("div", { className: O, "data-testid": a, children: [
|
|
101
|
+
/* @__PURE__ */ o(
|
|
102
|
+
"textarea",
|
|
103
|
+
{
|
|
104
|
+
...S,
|
|
105
|
+
ref: le(Z, h),
|
|
106
|
+
className: d(`${t}__textarea`, {
|
|
107
|
+
[`${t}__textarea--negative`]: u
|
|
108
|
+
}),
|
|
109
|
+
"aria-label": E,
|
|
110
|
+
"aria-labelledby": x,
|
|
111
|
+
"data-testid": a ? `${a}-textarea` : void 0,
|
|
112
|
+
onChange: K,
|
|
113
|
+
onKeyDown: M,
|
|
114
|
+
placeholder: n,
|
|
115
|
+
rows: f,
|
|
116
|
+
value: g
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
/* @__PURE__ */ o("div", { className: d(`${t}__action`), children: /* @__PURE__ */ o(
|
|
120
|
+
I,
|
|
121
|
+
{
|
|
122
|
+
"aria-label": s ? B : k,
|
|
123
|
+
"data-testid": a ? `${a}-action` : void 0,
|
|
124
|
+
iconOnly: !0,
|
|
125
|
+
negative: u,
|
|
126
|
+
size: "xs",
|
|
127
|
+
type: Y,
|
|
128
|
+
variant: "primary",
|
|
129
|
+
onClick: P,
|
|
130
|
+
children: U
|
|
131
|
+
}
|
|
132
|
+
) }),
|
|
133
|
+
/* @__PURE__ */ o(
|
|
134
|
+
"span",
|
|
135
|
+
{
|
|
136
|
+
className: d(`${t}__frame`, {
|
|
137
|
+
[`${t}__frame--negative`]: u
|
|
138
|
+
}),
|
|
139
|
+
"aria-hidden": "true"
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
] });
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
ie.displayName = "ChatField";
|
|
146
|
+
export {
|
|
147
|
+
ie as C
|
|
148
|
+
};
|
|
149
|
+
//# sourceMappingURL=chat-field-yK-TwW0D.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-field-yK-TwW0D.mjs","sources":["../../../components/icon/dist/assets/send.es.js","../../../components/icon/dist/assets/tv-stop.es.js","../../../components/chat-field/src/chat-field.tsx"],"sourcesContent":["const e = {\n name: \"send\",\n svg: '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path fill-rule=\"evenodd\" d=\"M1.54 2.149a.9.9 0 0 1 .97-.131l19.514 9.212a.9.9 0 0 1 0 1.628L2.51 22.071A.9.9 0 0 1 1.263 21l2.664-8.957-2.664-8.956a.9.9 0 0 1 .277-.94Zm3.997 10.795-1.974 6.64 14.062-6.64H5.537Zm12.088-1.8H5.537L3.563 4.505l14.062 6.64Z\" clip-rule=\"evenodd\"/></svg>',\n keywords: [\"send\"],\n category: \"action\"\n};\nexport {\n e as send\n};\n//# sourceMappingURL=send.es.js.map\n","const t = {\n name: \"tv-stop\",\n svg: '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M19 19H5V5h14v14Z\"/><path fill-rule=\"evenodd\" d=\"M19.9 19a.9.9 0 0 1-.9.9H5a.9.9 0 0 1-.9-.9V5a.9.9 0 0 1 .9-.9h14a.9.9 0 0 1 .9.9v14Zm-1.8-.9V5.9H5.9v12.2h12.2Z\" clip-rule=\"evenodd\"/></svg>',\n keywords: [\"tv-stop\"],\n category: \"action\"\n};\nexport {\n t as tvStop\n};\n//# sourceMappingURL=tv-stop.es.js.map\n","import React, {\n type ChangeEvent,\n forwardRef,\n type KeyboardEvent,\n type ReactNode,\n type Ref,\n type TextareaHTMLAttributes,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { Button } from \"@purpur/button\";\nimport { Icon } from \"@purpur/icon\";\nimport { send } from \"@purpur/icon/assets/send\";\nimport { tvStop } from \"@purpur/icon/assets/tv-stop\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./chat-field.module.scss\";\nconst cx = c.bind(styles);\n\nconst mergeRefs = <T,>(...inputRefs: (Ref<T> | undefined)[]): Ref<T> | React.RefCallback<T> => {\n const filteredInputRefs = inputRefs.filter(Boolean);\n\n if (filteredInputRefs.length <= 1) {\n return filteredInputRefs[0] || null;\n }\n\n return (ref: T | null) => {\n for (const inputRef of filteredInputRefs) {\n if (typeof inputRef === \"function\") {\n inputRef(ref);\n } else if (inputRef) {\n (inputRef as React.RefObject<T | null>).current = ref;\n }\n }\n };\n};\n\nexport type ChatFieldProps = {\n [\"data-testid\"]?: string;\n /**\n * Current value of the textarea in controlled mode.\n * When omitted, the component handles textarea state internally.\n * */\n value?: string;\n /**\n * Placeholder text shown when the textarea is empty.\n * */\n placeholder: string;\n /**\n * Accessible label for the textarea when no aria-label/aria-labelledby\n * is provided via `textareaProps`.\n * */\n textareaAriaLabel?: string;\n /**\n * Changes the action icon from send to stop.\n * */\n generating?: boolean;\n /**\n * Renders the field with negative appearance.\n * */\n negative?: boolean;\n /**\n * Accessible label for the send action icon.\n * */\n sendAriaLabel: string;\n /**\n * Custom icon for the default action button state.\n * Falls back to the standard send icon when omitted.\n * */\n sendIcon?: ReactNode;\n /**\n * Accessible label for the stop action icon.\n * */\n stopAriaLabel: string;\n /**\n * Number of visible text rows. Defaults to 1.\n * */\n rows?: number;\n /**\n * Maximum number of rows before the textarea scrolls. Defaults to 4.\n * */\n maxRows?: number;\n /**\n * Callback for textarea value changes.\n * */\n onChange: (event: ChangeEvent<HTMLTextAreaElement>) => void;\n /**\n * Callback fired when the send action is triggered (Enter key or send button click).\n * */\n onSend: () => void;\n /**\n * Callback fired when the stop button is clicked during generating state.\n * */\n onStopClick: () => void;\n /**\n * HTML type attribute for the action button. Use `\"submit\"` when ChatField\n * is placed inside a `<form>`. Defaults to `\"button\"`.\n * */\n actionButtonType?: \"button\" | \"submit\";\n /**\n * Additional props forwarded to the textarea element.\n * */\n textareaProps?: Omit<\n TextareaHTMLAttributes<HTMLTextAreaElement>,\n \"className\" | \"value\" | \"placeholder\" | \"disabled\" | \"onChange\" | \"rows\"\n >;\n className?: string;\n};\n\nconst rootClassName = \"purpur-chat-field\";\n\nexport const ChatField = forwardRef<HTMLTextAreaElement, ChatFieldProps>(\n (\n {\n [\"data-testid\"]: dataTestId,\n value,\n placeholder,\n textareaAriaLabel: textareaAriaLabelProp,\n generating = false,\n negative = false,\n sendAriaLabel,\n sendIcon,\n stopAriaLabel,\n rows = 1,\n maxRows = 4,\n onChange,\n onSend,\n onStopClick,\n actionButtonType = \"button\",\n textareaProps,\n className,\n },\n ref\n ) => {\n const internalRef = useRef<HTMLTextAreaElement>(null);\n const {\n [\"aria-label\"]: textareaPropsAriaLabel,\n [\"aria-labelledby\"]: textareaPropsAriaLabelledBy,\n defaultValue: textareaDefaultValue,\n ...textareaRestProps\n } = textareaProps ?? {};\n\n const [uncontrolledValue, setUncontrolledValue] = useState(() => {\n if (typeof textareaDefaultValue === \"string\" || typeof textareaDefaultValue === \"number\") {\n return String(textareaDefaultValue);\n }\n return \"\";\n });\n\n const textareaValue = value ?? uncontrolledValue;\n const hasValue = Boolean(textareaValue.length);\n\n const resolvedTextareaAriaLabel =\n textareaPropsAriaLabel ??\n (textareaPropsAriaLabelledBy ? undefined : textareaAriaLabelProp ?? placeholder);\n\n const adjustTextareaHeight = useCallback(() => {\n const textarea = internalRef.current;\n if (!textarea) return;\n\n textarea.style.height = \"auto\";\n textarea.style.overflowY = \"hidden\";\n\n const computed = getComputedStyle(textarea);\n const lineHeight = parseFloat(computed.lineHeight) || 20;\n const paddingTop = parseFloat(computed.paddingTop) || 0;\n const paddingBottom = parseFloat(computed.paddingBottom) || 0;\n const naturalHeight = lineHeight * rows + paddingTop + paddingBottom;\n const maxHeight = lineHeight * maxRows + paddingTop + paddingBottom;\n\n if (textarea.scrollHeight > maxHeight) {\n textarea.style.height = `${maxHeight}px`;\n textarea.style.overflowY = \"auto\";\n } else if (textarea.scrollHeight > naturalHeight) {\n textarea.style.height = `${textarea.scrollHeight}px`;\n }\n }, [rows, maxRows]);\n\n useEffect(() => {\n adjustTextareaHeight();\n }, [textareaValue, adjustTextareaHeight]);\n\n const triggerSend = useCallback(\n (source: \"button\" | \"keyboard\") => {\n if (!hasValue) return;\n\n if (actionButtonType === \"submit\") {\n const parentForm = internalRef.current?.form;\n\n if (source === \"keyboard\" && parentForm) {\n parentForm.requestSubmit();\n return;\n }\n\n if (source === \"button\" && parentForm) {\n return;\n }\n }\n\n onSend();\n },\n [actionButtonType, hasValue, onSend]\n );\n\n const handleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {\n if (value === undefined) {\n setUncontrolledValue(event.target.value);\n }\n\n onChange(event);\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {\n if (event.key === \"Enter\" && !event.shiftKey && !event.nativeEvent.isComposing) {\n event.preventDefault();\n triggerSend(\"keyboard\");\n }\n };\n\n const handleActionClick = () => {\n if (generating) {\n onStopClick();\n return;\n }\n\n triggerSend(\"button\");\n };\n\n const resolvedActionButtonType: \"button\" | \"submit\" =\n generating || !hasValue ? \"button\" : actionButtonType;\n\n const classes = cx([\n className,\n rootClassName,\n {\n [`${rootClassName}--filled`]: hasValue,\n [`${rootClassName}--negative`]: negative,\n },\n ]);\n\n const actionIcon = generating ? (\n <Icon size=\"xs\" svg={tvStop} />\n ) : (\n sendIcon ?? <Icon size=\"xs\" svg={send} />\n );\n\n return (\n <div className={classes} data-testid={dataTestId}>\n <textarea\n {...textareaRestProps}\n ref={mergeRefs(ref, internalRef)}\n className={cx(`${rootClassName}__textarea`, {\n [`${rootClassName}__textarea--negative`]: negative,\n })}\n aria-label={resolvedTextareaAriaLabel}\n aria-labelledby={textareaPropsAriaLabelledBy}\n data-testid={dataTestId ? `${dataTestId}-textarea` : undefined}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n rows={rows}\n value={textareaValue}\n />\n <div className={cx(`${rootClassName}__action`)}>\n <Button\n aria-label={generating ? stopAriaLabel : sendAriaLabel}\n data-testid={dataTestId ? `${dataTestId}-action` : undefined}\n iconOnly\n negative={negative}\n size=\"xs\"\n type={resolvedActionButtonType}\n variant=\"primary\"\n onClick={handleActionClick}\n >\n {actionIcon}\n </Button>\n </div>\n <span\n className={cx(`${rootClassName}__frame`, {\n [`${rootClassName}__frame--negative`]: negative,\n })}\n aria-hidden=\"true\"\n />\n </div>\n );\n }\n);\n\nChatField.displayName = \"ChatField\";\n"],"names":["e","t","cx","c","styles","mergeRefs","inputRefs","filteredInputRefs","ref","inputRef","rootClassName","ChatField","forwardRef","dataTestId","value","placeholder","textareaAriaLabelProp","generating","negative","sendAriaLabel","sendIcon","stopAriaLabel","rows","maxRows","onChange","onSend","onStopClick","actionButtonType","textareaProps","className","internalRef","useRef","textareaPropsAriaLabel","textareaPropsAriaLabelledBy","textareaDefaultValue","textareaRestProps","uncontrolledValue","setUncontrolledValue","useState","textareaValue","hasValue","resolvedTextareaAriaLabel","adjustTextareaHeight","useCallback","textarea","computed","lineHeight","paddingTop","paddingBottom","naturalHeight","maxHeight","useEffect","triggerSend","source","parentForm","handleChange","event","handleKeyDown","handleActionClick","resolvedAct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C,UAAA,gBAAAoD;AAAA,QAACK;AAAA,QAAA;AAAA,UACC,cAAYlD,IAAaI,IAAgBF;AAAA,UACzC,eAAaN,IAAa,GAAGA,CAAU,YAAY;AAAA,UACnD,UAAQ;AAAA,UACR,UAAAK;AAAA,UACA,MAAK;AAAA,UACL,MAAMyC;AAAA,UACN,SAAQ;AAAA,UACR,SAASD;AAAA,UAER,UAAAG;AAAA,QAAA;AAAA,MAAA,GAEL;AAAA,MACA,gBAAAC;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW5D,EAAG,GAAGQ,CAAa,WAAW;AAAA,YACvC,CAAC,GAAGA,CAAa,mBAAmB,GAAGQ;AAAA,UAAA,CACxC;AAAA,UACD,eAAY;AAAA,QAAA;AAAA,MAAA;AAAA,IACd,GACF;AAAA,EAEJ;AACF;AAEAP,GAAU,cAAc;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-field.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-field.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../../../../components/autocomplete/src/autocomplete.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,KAAmC,MAAM,OAAO,CAAC;AAOxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAEnF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIxC,KAAK,iBAAiB,CAAC,CAAC,SAAS,kBAAkB,IAAI,QAAQ,CAC7D,qBAAqB,CAAC,CAAC,CAAC,GAAG;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,WAAW,EAAE,CAAC,KAAK,EAAE,qBAAqB,CAAC,OAAO,CAAC,KAAK,SAAS,CAAC;IAClE;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,SAAS,CAAC;CACzC,CACF,CAAC;
|
|
1
|
+
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../../../../components/autocomplete/src/autocomplete.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,KAAmC,MAAM,OAAO,CAAC;AAOxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAEnF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIxC,KAAK,iBAAiB,CAAC,CAAC,SAAS,kBAAkB,IAAI,QAAQ,CAC7D,qBAAqB,CAAC,CAAC,CAAC,GAAG;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,WAAW,EAAE,CAAC,KAAK,EAAE,qBAAqB,CAAC,OAAO,CAAC,KAAK,SAAS,CAAC;IAClE;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,SAAS,CAAC;CACzC,CACF,CAAC;AA8FF,eAAO,MAAM,YAAY,8GAAoC,CAAC;AAG9D,YAAY,EACV,kBAAkB,EAClB,qBAAqB,IAAI,sBAAsB,GAChD,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { default as React, ChangeEvent, ReactNode, TextareaHTMLAttributes } from 'react';
|
|
2
|
+
export type ChatFieldProps = {
|
|
3
|
+
["data-testid"]?: string;
|
|
4
|
+
/**
|
|
5
|
+
* Current value of the textarea in controlled mode.
|
|
6
|
+
* When omitted, the component handles textarea state internally.
|
|
7
|
+
* */
|
|
8
|
+
value?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Placeholder text shown when the textarea is empty.
|
|
11
|
+
* */
|
|
12
|
+
placeholder: string;
|
|
13
|
+
/**
|
|
14
|
+
* Accessible label for the textarea when no aria-label/aria-labelledby
|
|
15
|
+
* is provided via `textareaProps`.
|
|
16
|
+
* */
|
|
17
|
+
textareaAriaLabel?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Changes the action icon from send to stop.
|
|
20
|
+
* */
|
|
21
|
+
generating?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Renders the field with negative appearance.
|
|
24
|
+
* */
|
|
25
|
+
negative?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Accessible label for the send action icon.
|
|
28
|
+
* */
|
|
29
|
+
sendAriaLabel: string;
|
|
30
|
+
/**
|
|
31
|
+
* Custom icon for the default action button state.
|
|
32
|
+
* Falls back to the standard send icon when omitted.
|
|
33
|
+
* */
|
|
34
|
+
sendIcon?: ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* Accessible label for the stop action icon.
|
|
37
|
+
* */
|
|
38
|
+
stopAriaLabel: string;
|
|
39
|
+
/**
|
|
40
|
+
* Number of visible text rows. Defaults to 1.
|
|
41
|
+
* */
|
|
42
|
+
rows?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Maximum number of rows before the textarea scrolls. Defaults to 4.
|
|
45
|
+
* */
|
|
46
|
+
maxRows?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Callback for textarea value changes.
|
|
49
|
+
* */
|
|
50
|
+
onChange: (event: ChangeEvent<HTMLTextAreaElement>) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Callback fired when the send action is triggered (Enter key or send button click).
|
|
53
|
+
* */
|
|
54
|
+
onSend: () => void;
|
|
55
|
+
/**
|
|
56
|
+
* Callback fired when the stop button is clicked during generating state.
|
|
57
|
+
* */
|
|
58
|
+
onStopClick: () => void;
|
|
59
|
+
/**
|
|
60
|
+
* HTML type attribute for the action button. Use `"submit"` when ChatField
|
|
61
|
+
* is placed inside a `<form>`. Defaults to `"button"`.
|
|
62
|
+
* */
|
|
63
|
+
actionButtonType?: "button" | "submit";
|
|
64
|
+
/**
|
|
65
|
+
* Additional props forwarded to the textarea element.
|
|
66
|
+
* */
|
|
67
|
+
textareaProps?: Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "className" | "value" | "placeholder" | "disabled" | "onChange" | "rows">;
|
|
68
|
+
className?: string;
|
|
69
|
+
};
|
|
70
|
+
export declare const ChatField: React.ForwardRefExoticComponent<ChatFieldProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
71
|
+
//# sourceMappingURL=chat-field.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-field.d.ts","sourceRoot":"","sources":["../../../../../../components/chat-field/src/chat-field.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,KAAK,WAAW,EAGhB,KAAK,SAAS,EAEd,KAAK,sBAAsB,EAK5B,MAAM,OAAO,CAAC;AA4Bf,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC;IACzB;;;SAGK;IACL,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;SAEK;IACL,WAAW,EAAE,MAAM,CAAC;IACpB;;;SAGK;IACL,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;SAEK;IACL,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;SAEK;IACL,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;SAEK;IACL,aAAa,EAAE,MAAM,CAAC;IACtB;;;SAGK;IACL,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;SAEK;IACL,aAAa,EAAE,MAAM,CAAC;IACtB;;SAEK;IACL,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;SAEK;IACL,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;SAEK;IACL,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAC;IAC5D;;SAEK;IACL,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB;;SAEK;IACL,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB;;;SAGK;IACL,gBAAgB,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACvC;;SAEK;IACL,aAAa,CAAC,EAAE,IAAI,CAClB,sBAAsB,CAAC,mBAAmB,CAAC,EAC3C,WAAW,GAAG,OAAO,GAAG,aAAa,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,CACzE,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAIF,eAAO,MAAM,SAAS,4FA+KrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dismissable-chip-group-item.d.ts","sourceRoot":"","sources":["../../../../../../components/dismissable-chip-group/src/dismissable-chip-group-item.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAmB,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"dismissable-chip-group-item.d.ts","sourceRoot":"","sources":["../../../../../../components/dismissable-chip-group/src/dismissable-chip-group-item.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAmB,KAAK,SAAS,EAAc,MAAM,OAAO,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAStD,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC,GAAG;IACjG,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC,CAAC;AAIF,eAAO,MAAM,wBAAwB;sDAMlC,6BAA6B;;CA6B/B,CAAC"}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { default as React, ReactNode } from 'react';
|
|
2
2
|
import { BaseProps } from '../../../libraries/common-types/src/common-types';
|
|
3
3
|
import { HeadingTagType } from '../../heading/src/heading';
|
|
4
|
+
export declare const sizes: readonly ["sm", "md"];
|
|
5
|
+
export declare const DEFAULT_SIZE: "md";
|
|
6
|
+
export type Size = (typeof sizes)[number];
|
|
4
7
|
export type DismissableChipGroupProps = Omit<BaseProps, "children"> & {
|
|
5
8
|
children: ReactNode;
|
|
6
9
|
fullWidth?: boolean;
|
|
10
|
+
size?: Size;
|
|
7
11
|
title?: string;
|
|
8
12
|
titleTag?: HeadingTagType;
|
|
9
13
|
};
|
|
14
|
+
export declare const SizeContext: React.Context<"sm" | "md">;
|
|
10
15
|
export declare const DismissableChipGroup: {
|
|
11
|
-
({ children, className, fullWidth, title, titleTag, ...props }: DismissableChipGroupProps): React.JSX.Element;
|
|
16
|
+
({ children, className, fullWidth, size, title, titleTag, ...props }: DismissableChipGroupProps): React.JSX.Element;
|
|
12
17
|
Item: {
|
|
13
18
|
({ children, id, onDismiss, disabled, ...props }: import('./dismissable-chip-group-item').DismissableChipGroupItemProps): React.JSX.Element;
|
|
14
19
|
displayName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dismissable-chip-group.d.ts","sourceRoot":"","sources":["../../../../../../components/dismissable-chip-group/src/dismissable-chip-group.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"dismissable-chip-group.d.ts","sourceRoot":"","sources":["../../../../../../components/dismissable-chip-group/src/dismissable-chip-group.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiB,KAAK,SAAS,EAAS,MAAM,OAAO,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAQ/D,eAAO,MAAM,KAAK,uBAAwB,CAAC;AAC3C,eAAO,MAAM,YAAY,EAAG,IAAa,CAAC;AAE1C,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1C,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG;IACpE,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,CAAC;AAEF,eAAO,MAAM,WAAW,4BAAoC,CAAC;AAI7D,eAAO,MAAM,oBAAoB;0EAQ9B,yBAAyB;;;;;;CA6B3B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { DropdownOption } from './dropdown.types';
|
|
3
|
+
export declare const DropdownCombobox: React.ForwardRefExoticComponent<{
|
|
4
|
+
id?: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
listboxLabel?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
helperText?: string;
|
|
9
|
+
errorText?: string;
|
|
10
|
+
valid?: boolean;
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
negative?: boolean;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
readOnly?: boolean;
|
|
16
|
+
className?: string;
|
|
17
|
+
"data-testid"?: string;
|
|
18
|
+
} & {
|
|
19
|
+
combobox: true;
|
|
20
|
+
options: DropdownOption[];
|
|
21
|
+
multiple?: boolean;
|
|
22
|
+
selectedOption?: DropdownOption;
|
|
23
|
+
selectedOptions?: DropdownOption[];
|
|
24
|
+
onSelect?: (option: DropdownOption | undefined, selectedOptions: DropdownOption[]) => void;
|
|
25
|
+
filterOption?: (inputValue: string | undefined, option: DropdownOption) => boolean;
|
|
26
|
+
inputValue?: string;
|
|
27
|
+
defaultInputValue?: string;
|
|
28
|
+
onInputChange?: (value: string) => void;
|
|
29
|
+
noOptionsText?: React.ReactNode;
|
|
30
|
+
highlightFirstOption?: boolean;
|
|
31
|
+
openOnFocus?: boolean;
|
|
32
|
+
listboxMaxHeight?: string | number;
|
|
33
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
34
|
+
//# sourceMappingURL=dropdown-combobox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown-combobox.d.ts","sourceRoot":"","sources":["../../../../../../components/dropdown/src/dropdown-combobox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAIjD,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAatE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCA4N3B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { DropdownOption } from './dropdown.types';
|
|
3
|
+
export declare const DropdownSelect: React.ForwardRefExoticComponent<{
|
|
4
|
+
id?: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
listboxLabel?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
helperText?: string;
|
|
9
|
+
errorText?: string;
|
|
10
|
+
valid?: boolean;
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
negative?: boolean;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
readOnly?: boolean;
|
|
16
|
+
className?: string;
|
|
17
|
+
"data-testid"?: string;
|
|
18
|
+
} & {
|
|
19
|
+
combobox?: false;
|
|
20
|
+
options: DropdownOption[];
|
|
21
|
+
multiple?: boolean;
|
|
22
|
+
selectedOption?: DropdownOption;
|
|
23
|
+
selectedOptions?: DropdownOption[];
|
|
24
|
+
onSelect?: (option: DropdownOption | undefined, selectedOptions: DropdownOption[]) => void;
|
|
25
|
+
openOnFocus?: boolean;
|
|
26
|
+
listboxMaxHeight?: string | number;
|
|
27
|
+
filterOption?: never;
|
|
28
|
+
onInputChange?: never;
|
|
29
|
+
inputValue?: never;
|
|
30
|
+
defaultInputValue?: never;
|
|
31
|
+
noOptionsText?: never;
|
|
32
|
+
highlightFirstOption?: never;
|
|
33
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
34
|
+
//# sourceMappingURL=dropdown-select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown-select.d.ts","sourceRoot":"","sources":["../../../../../../components/dropdown/src/dropdown-select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAGjD,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,kBAAkB,CAAC;AAYpE,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCAmKzB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { DropdownOption } from './dropdown.types';
|
|
3
|
+
declare const cx: (...args: import('classnames').ArgumentArray) => string;
|
|
4
|
+
export declare const rootClassName = "purpur-dropdown";
|
|
5
|
+
type GetTestId = (name: string) => string | undefined;
|
|
6
|
+
type DropdownLabelProps = {
|
|
7
|
+
fieldId: string;
|
|
8
|
+
htmlForSuffix?: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
getTestId: GetTestId;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
negative: boolean;
|
|
13
|
+
required: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare const DropdownLabel: ({ fieldId, htmlForSuffix, label, getTestId, disabled, negative, required, }: DropdownLabelProps) => React.JSX.Element | null;
|
|
16
|
+
type DropdownEndAdornmentsProps = {
|
|
17
|
+
getTestId: GetTestId;
|
|
18
|
+
loading?: boolean;
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
negative: boolean;
|
|
21
|
+
isValid: boolean;
|
|
22
|
+
isOpen?: boolean;
|
|
23
|
+
readOnly?: boolean;
|
|
24
|
+
showChevronOpen: boolean;
|
|
25
|
+
};
|
|
26
|
+
export declare const DropdownEndAdornments: ({ getTestId, loading, disabled, negative, isValid, isOpen, readOnly, showChevronOpen, }: DropdownEndAdornmentsProps) => React.JSX.Element;
|
|
27
|
+
type DropdownTagsProps = {
|
|
28
|
+
selectedItems: DropdownOption[];
|
|
29
|
+
getTestId: GetTestId;
|
|
30
|
+
disabled: boolean;
|
|
31
|
+
onRemove: (option: DropdownOption) => void;
|
|
32
|
+
isSelect?: boolean;
|
|
33
|
+
};
|
|
34
|
+
export declare const DropdownTags: ({ selectedItems, getTestId, disabled, onRemove, isSelect, }: DropdownTagsProps) => React.JSX.Element | null;
|
|
35
|
+
type DropdownFooterProps = {
|
|
36
|
+
errorText?: string;
|
|
37
|
+
helperText?: string;
|
|
38
|
+
helperTextId: string;
|
|
39
|
+
negative: boolean;
|
|
40
|
+
};
|
|
41
|
+
export declare const DropdownFooter: ({ errorText, helperText, helperTextId, negative, }: DropdownFooterProps) => React.JSX.Element;
|
|
42
|
+
type DropdownListboxItemsProps = {
|
|
43
|
+
optionsToShow: DropdownOption[];
|
|
44
|
+
getListboxItemProps: (option: DropdownOption, index: number) => Record<string, unknown>;
|
|
45
|
+
multiple?: boolean;
|
|
46
|
+
fieldId: string;
|
|
47
|
+
noOptionsText?: React.ReactNode;
|
|
48
|
+
};
|
|
49
|
+
export declare const DropdownListboxItems: ({ optionsToShow, getListboxItemProps, multiple, fieldId, noOptionsText, }: DropdownListboxItemsProps) => React.JSX.Element | React.JSX.Element[];
|
|
50
|
+
export { cx };
|
|
51
|
+
//# sourceMappingURL=dropdown-shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown-shared.d.ts","sourceRoot":"","sources":["../../../../../../components/dropdown/src/dropdown-shared.tsx"],"names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AAiB,6BA2BnB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,oDAK5B,mBAAmB,sBASrB,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC/B,aAAa,EAAE,cAAc,EAAE,CAAC;IAChC,mBAAmB,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACjC,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,2EAMlC,yBAAyB,4CA+B3B,CAAC;AAEF,OAAO,EAAE,EAAE,EAAE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { DropdownProps } from './dropdown.types';
|
|
3
|
+
export declare const Dropdown: React.ForwardRefExoticComponent<DropdownProps & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
export type { ComboboxProps, DropdownOption, DropdownProps, SelectProps } from './dropdown.types';
|
|
5
|
+
export { useDropdown } from './useDropdown';
|
|
6
|
+
//# sourceMappingURL=dropdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../../../../components/dropdown/src/dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAiB,aAAa,EAAe,MAAM,kBAAkB,CAAC;AAIlF,eAAO,MAAM,QAAQ,sFAMnB,CAAC;AAIH,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export type DropdownOption = {
|
|
2
|
+
label: string;
|
|
3
|
+
id: string;
|
|
4
|
+
value?: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
/** Shared props across all variants */
|
|
8
|
+
type DropdownBaseProps = {
|
|
9
|
+
/** Unique id used to prefix all sub-element ids. */
|
|
10
|
+
id?: string;
|
|
11
|
+
/** Visible label rendered above the field. */
|
|
12
|
+
label?: string;
|
|
13
|
+
/** Accessible label for the listbox popup (required for select/combobox). */
|
|
14
|
+
listboxLabel?: string;
|
|
15
|
+
/** Placeholder text shown when no value is selected. */
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
/** Helper text rendered below the field. */
|
|
18
|
+
helperText?: string;
|
|
19
|
+
/** Error text rendered below the field. Puts the field in an error state. */
|
|
20
|
+
errorText?: string;
|
|
21
|
+
/** Render the field with a valid (success) appearance. */
|
|
22
|
+
valid?: boolean;
|
|
23
|
+
/** Show a loading spinner inside the field. */
|
|
24
|
+
loading?: boolean;
|
|
25
|
+
/** Render on dark backgrounds. */
|
|
26
|
+
negative?: boolean;
|
|
27
|
+
/** Mark the field as required. */
|
|
28
|
+
required?: boolean;
|
|
29
|
+
/** Disable the field. */
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
/** Make the field read-only. */
|
|
32
|
+
readOnly?: boolean;
|
|
33
|
+
className?: string;
|
|
34
|
+
["data-testid"]?: string;
|
|
35
|
+
};
|
|
36
|
+
export type SelectProps = DropdownBaseProps & {
|
|
37
|
+
combobox?: false;
|
|
38
|
+
options: DropdownOption[];
|
|
39
|
+
/** Enable multi-select mode. */
|
|
40
|
+
multiple?: boolean;
|
|
41
|
+
/** Currently selected option (single-select, controlled). */
|
|
42
|
+
selectedOption?: DropdownOption;
|
|
43
|
+
/** Currently selected options (multi-select, controlled). */
|
|
44
|
+
selectedOptions?: DropdownOption[];
|
|
45
|
+
/** Fired when an option is selected or deselected. */
|
|
46
|
+
onSelect?: (option: DropdownOption | undefined, selectedOptions: DropdownOption[]) => void;
|
|
47
|
+
/** Open the listbox when the trigger receives focus. */
|
|
48
|
+
openOnFocus?: boolean;
|
|
49
|
+
/** Maximum height of the listbox popup. */
|
|
50
|
+
listboxMaxHeight?: string | number;
|
|
51
|
+
/** Not applicable. */
|
|
52
|
+
filterOption?: never;
|
|
53
|
+
/** Not applicable. */
|
|
54
|
+
onInputChange?: never;
|
|
55
|
+
/** Not applicable. */
|
|
56
|
+
inputValue?: never;
|
|
57
|
+
/** Not applicable. */
|
|
58
|
+
defaultInputValue?: never;
|
|
59
|
+
/** Not applicable. */
|
|
60
|
+
noOptionsText?: never;
|
|
61
|
+
/** Not applicable. */
|
|
62
|
+
highlightFirstOption?: never;
|
|
63
|
+
};
|
|
64
|
+
export type ComboboxProps = DropdownBaseProps & {
|
|
65
|
+
combobox: true;
|
|
66
|
+
options: DropdownOption[];
|
|
67
|
+
/** Enable multi-select mode. */
|
|
68
|
+
multiple?: boolean;
|
|
69
|
+
/** Currently selected option (single-select, controlled). */
|
|
70
|
+
selectedOption?: DropdownOption;
|
|
71
|
+
/** Currently selected options (multi-select, controlled). */
|
|
72
|
+
selectedOptions?: DropdownOption[];
|
|
73
|
+
/** Fired when an option is selected or deselected. */
|
|
74
|
+
onSelect?: (option: DropdownOption | undefined, selectedOptions: DropdownOption[]) => void;
|
|
75
|
+
/** Custom filter for autocomplete results. */
|
|
76
|
+
filterOption?: (inputValue: string | undefined, option: DropdownOption) => boolean;
|
|
77
|
+
/** Controlled input value. */
|
|
78
|
+
inputValue?: string;
|
|
79
|
+
/** Default input value (uncontrolled). */
|
|
80
|
+
defaultInputValue?: string;
|
|
81
|
+
/** Fired when the text-input value changes. */
|
|
82
|
+
onInputChange?: (value: string) => void;
|
|
83
|
+
/** Text shown when filtering yields no results. */
|
|
84
|
+
noOptionsText?: React.ReactNode;
|
|
85
|
+
/** Highlight the first option automatically. */
|
|
86
|
+
highlightFirstOption?: boolean;
|
|
87
|
+
/** Open the listbox when the input receives focus. */
|
|
88
|
+
openOnFocus?: boolean;
|
|
89
|
+
/** Maximum height of the listbox popup. */
|
|
90
|
+
listboxMaxHeight?: string | number;
|
|
91
|
+
};
|
|
92
|
+
export type DropdownProps = SelectProps | ComboboxProps;
|
|
93
|
+
export {};
|
|
94
|
+
//# sourceMappingURL=dropdown.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown.types.d.ts","sourceRoot":"","sources":["../../../../../../components/dropdown/src/dropdown.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,uCAAuC;AACvC,KAAK,iBAAiB,GAAG;IACvB,oDAAoD;IACpD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yBAAyB;IACzB,Q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Ac,CAAC;IAChC,6DAA6D;IAC7D,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IACnC,sDAAsD;IACtD,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,IAAI,CAAC;IAC3F,8CAA8C;IAC9C,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,cAAc,KAAK,OAAO,CAAC;IACnF,8BAA8B;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,+CAA+C;IAC/C,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,mDAAmD;IACnD,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAChC,gDAAgD;IAChD,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,sDAAsD;IACtD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2CAA2C;IAC3C,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,aAAa,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { ListboxItemProps, ListboxProps } from '../../listbox/src/listbox';
|
|
3
|
+
import { DropdownOption } from './dropdown.types';
|
|
4
|
+
export type UseDropdownParams = {
|
|
5
|
+
id: string;
|
|
6
|
+
variant: "select" | "combobox";
|
|
7
|
+
options: DropdownOption[];
|
|
8
|
+
listboxLabel: string;
|
|
9
|
+
multiple?: boolean;
|
|
10
|
+
selectedOption?: DropdownOption;
|
|
11
|
+
selectedOptions?: DropdownOption[];
|
|
12
|
+
onSelect?: (option: DropdownOption | undefined, selectedOptions: DropdownOption[]) => void;
|
|
13
|
+
filterOption?: (inputValue: string | undefined, option: DropdownOption) => boolean;
|
|
14
|
+
inputValue?: string;
|
|
15
|
+
defaultInputValue?: string;
|
|
16
|
+
onInputChange?: (value: string) => void;
|
|
17
|
+
noOptionsText?: React.ReactNode;
|
|
18
|
+
highlightFirstOption?: boolean;
|
|
19
|
+
openOnFocus?: boolean;
|
|
20
|
+
listboxMaxHeight?: string | number;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
readOnly?: boolean;
|
|
23
|
+
["data-testid"]?: string;
|
|
24
|
+
};
|
|
25
|
+
export type UseDropdownReturn = {
|
|
26
|
+
rootRef: React.RefObject<HTMLDivElement | null>;
|
|
27
|
+
triggerProps: Record<string, unknown>;
|
|
28
|
+
inputProps: Record<string, unknown> | null;
|
|
29
|
+
listboxProps: ListboxProps;
|
|
30
|
+
getListboxItemProps: (option: DropdownOption, index: number) => ListboxItemProps;
|
|
31
|
+
optionsToShow: DropdownOption[];
|
|
32
|
+
isOpen: boolean;
|
|
33
|
+
highlightedOption: DropdownOption | undefined;
|
|
34
|
+
selectedItems: DropdownOption[];
|
|
35
|
+
anchorStyle: CSSProperties;
|
|
36
|
+
};
|
|
37
|
+
export declare const useDropdown: ({ id, variant, options, listboxLabel, multiple, selectedOption, selectedOptions, onSelect, filterOption, inputValue: controlledInputValue, defaultInputValue, onInputChange, noOptionsText, highlightFirstOption, openOnFocus, listboxMaxHeight, disabled, readOnly, ["data-testid"]: dataTestId, }: UseDropdownParams) => UseDropdownReturn;
|
|
38
|
+
//# sourceMappingURL=useDropdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDropdown.d.ts","sourceRoot":"","sources":["../../../../../../components/dropdown/src/useDropdown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEtE,OAAO,KAAK,EAAE,cAA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,YAAY,EAAE,YAAY,CAAC;IAC3B,mBAAmB,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,KAAK,gBAAgB,CAAC;IACjF,aAAa,EAAE,cAAc,EAAE,CAAC;IAChC,MAAM,EAAE,OAAO,CAAC;IAChB,iBAAiB,EAAE,cAAc,GAAG,SAAS,CAAC;IAC9C,aAAa,EAAE,cAAc,EAAE,CAAC;IAChC,WAAW,EAAE,aAAa,CAAC;CAC5B,CAAC;AAIF,eAAO,MAAM,WAAW,GAAI,qSAoBzB,iBAAiB,KAAG,iBAiTtB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DropdownOption } from './dropdown.types';
|
|
2
|
+
export declare const getFilteredOptions: ({ options, searchTerm, filterOption, selectedOption, multiple, }: {
|
|
3
|
+
options: DropdownOption[];
|
|
4
|
+
searchTerm: string | undefined;
|
|
5
|
+
filterOption?: (inputValue: string | undefined, option: DropdownOption) => boolean;
|
|
6
|
+
selectedOption?: DropdownOption;
|
|
7
|
+
multiple: boolean;
|
|
8
|
+
}) => DropdownOption[];
|
|
9
|
+
//# sourceMappingURL=useDropdownFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDropdownFilter.d.ts","sourceRoot":"","sources":["../../../../../../components/dropdown/src/useDropdownFilter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAiBvD,eAAO,MAAM,kBAAkB,GAAI,kEAMhC;IACD,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,cAAc,KAAK,OAAO,CAAC;IACnF,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,QAAQ,EAAE,OAAO,CAAC;CACnB,KAAG,cAAc,EAKjB,CAAC"}
|