laif-ds 0.2.63 → 0.2.65
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/dist/_virtual/index4.js +5 -5
- package/dist/_virtual/index5.js +5 -5
- package/dist/components/ui/app-radio-group.js +50 -46
- package/dist/components/ui/app-select.js +57 -53
- package/dist/components/ui/app-stepper.js +89 -78
- package/dist/components/ui/async-select.js +82 -79
- package/dist/components/ui/date-picker.js +53 -50
- package/dist/components/ui/file-uploader.js +81 -73
- package/dist/components/ui/input-selector.js +26 -22
- package/dist/components/ui/message-input.js +80 -78
- package/dist/components/ui/tables/data-table/components/data-table-actions.js +15 -13
- package/dist/components/ui/tables/data-table/components/data-table-searchbar.js +41 -38
- package/dist/components/ui/tables/data-table/data-table-constants.js +35 -33
- package/dist/components/ui/tables/data-table/data-table.js +86 -81
- package/dist/components/ui/tables/data-table/data-table.service.js +87 -87
- package/dist/index.d.ts +28 -7
- package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.js +1 -1
- package/dist/node_modules/unified/lib/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,41 +1,42 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs as o, jsx as e } from "react/jsx-runtime";
|
|
3
|
-
import { useState as y, useEffect as S, useRef as J } from "react";
|
|
4
3
|
import { AnimatePresence as v, motion as w } from "framer-motion";
|
|
4
|
+
import { useState as y, useEffect as S, useRef as Q } from "react";
|
|
5
5
|
import { omit as T } from "../../node_modules/remeda/dist/omit-HZOiLuMO.js";
|
|
6
|
-
import {
|
|
7
|
-
import { useAudioRecording as Q } from "../../hooks/use-audio-recording.js";
|
|
8
|
-
import { useAutosizeTextArea as X } from "../../hooks/use-autosize-textarea.js";
|
|
9
|
-
import { AudioVisualizer as Y } from "./audio-visualizer.js";
|
|
6
|
+
import { AudioVisualizer as X } from "./audio-visualizer.js";
|
|
10
7
|
import { Button as g } from "./button.js";
|
|
11
|
-
import { FilePreview as
|
|
12
|
-
import { InterruptPrompt as
|
|
8
|
+
import { FilePreview as Y } from "./file-preview.js";
|
|
9
|
+
import { InterruptPrompt as Z } from "./interrupt-prompt.js";
|
|
10
|
+
import { useAudioRecording as _ } from "../../hooks/use-audio-recording.js";
|
|
11
|
+
import { useAutosizeTextArea as $ } from "../../hooks/use-autosize-textarea.js";
|
|
12
|
+
import { cn as C } from "../../lib/utils.js";
|
|
13
13
|
import P from "../../node_modules/lucide-react/dist/esm/icons/paperclip.js";
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
function
|
|
14
|
+
import G from "../../node_modules/lucide-react/dist/esm/icons/mic.js";
|
|
15
|
+
import ee from "../../node_modules/lucide-react/dist/esm/icons/square.js";
|
|
16
|
+
import te from "../../node_modules/lucide-react/dist/esm/icons/arrow-up.js";
|
|
17
|
+
import re from "../../node_modules/lucide-react/dist/esm/icons/info.js";
|
|
18
|
+
import ie from "../../node_modules/lucide-react/dist/esm/icons/loader-circle.js";
|
|
19
|
+
function ae({
|
|
20
20
|
placeholder: i = "Ask AI...",
|
|
21
|
-
className:
|
|
21
|
+
className: n,
|
|
22
22
|
onKeyDown: d,
|
|
23
23
|
submitOnEnter: l = !0,
|
|
24
24
|
stop: s,
|
|
25
25
|
isGenerating: u,
|
|
26
26
|
enableInterrupt: A = !0,
|
|
27
27
|
transcribeAudio: I,
|
|
28
|
+
"data-testid": R,
|
|
28
29
|
...r
|
|
29
30
|
}) {
|
|
30
|
-
const [
|
|
31
|
-
isListening:
|
|
32
|
-
isSpeechSupported:
|
|
31
|
+
const [F, x] = y(!1), [N, f] = y(!1), {
|
|
32
|
+
isListening: L,
|
|
33
|
+
isSpeechSupported: M,
|
|
33
34
|
isRecording: D,
|
|
34
|
-
isTranscribing:
|
|
35
|
-
audioStream:
|
|
36
|
-
toggleListening:
|
|
35
|
+
isTranscribing: O,
|
|
36
|
+
audioStream: j,
|
|
37
|
+
toggleListening: q,
|
|
37
38
|
stopRecording: k
|
|
38
|
-
} =
|
|
39
|
+
} = _({
|
|
39
40
|
transcribeAudio: I,
|
|
40
41
|
onTranscriptionComplete: (t) => {
|
|
41
42
|
r.onChange?.({ target: { value: t } });
|
|
@@ -45,32 +46,32 @@ function ie({
|
|
|
45
46
|
u || f(!1);
|
|
46
47
|
}, [u]);
|
|
47
48
|
const h = (t) => {
|
|
48
|
-
r.allowAttachments && r.setFiles((
|
|
49
|
-
}, q = (t) => {
|
|
50
|
-
r.allowAttachments === !0 && (t.preventDefault(), x(!0));
|
|
49
|
+
r.allowAttachments && r.setFiles((a) => a === null ? t : t === null ? a : [...a, ...t]);
|
|
51
50
|
}, E = (t) => {
|
|
52
|
-
r.allowAttachments === !0 && (t.preventDefault(), x(!
|
|
51
|
+
r.allowAttachments === !0 && (t.preventDefault(), x(!0));
|
|
53
52
|
}, H = (t) => {
|
|
53
|
+
r.allowAttachments === !0 && (t.preventDefault(), x(!1));
|
|
54
|
+
}, K = (t) => {
|
|
54
55
|
if (x(!1), r.allowAttachments !== !0) return;
|
|
55
56
|
t.preventDefault();
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
},
|
|
59
|
-
const
|
|
60
|
-
if (!
|
|
57
|
+
const a = t.dataTransfer;
|
|
58
|
+
a.files.length && h(Array.from(a.files));
|
|
59
|
+
}, U = (t) => {
|
|
60
|
+
const a = t.clipboardData?.items;
|
|
61
|
+
if (!a) return;
|
|
61
62
|
const c = t.clipboardData.getData("text");
|
|
62
63
|
if (c && c.length > 500 && r.allowAttachments) {
|
|
63
64
|
t.preventDefault();
|
|
64
|
-
const m = new Blob([c], { type: "text/plain" }),
|
|
65
|
+
const m = new Blob([c], { type: "text/plain" }), J = new File([m], "Pasted text", {
|
|
65
66
|
type: "text/plain",
|
|
66
67
|
lastModified: Date.now()
|
|
67
68
|
});
|
|
68
|
-
h([
|
|
69
|
+
h([J]);
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
71
|
-
const b = Array.from(
|
|
72
|
+
const b = Array.from(a).map((m) => m.getAsFile()).filter((m) => m !== null);
|
|
72
73
|
r.allowAttachments && b.length > 0 && h(b);
|
|
73
|
-
},
|
|
74
|
+
}, V = (t) => {
|
|
74
75
|
if (l && t.key === "Enter" && !t.shiftKey) {
|
|
75
76
|
if (t.preventDefault(), u && s && A) {
|
|
76
77
|
if (N)
|
|
@@ -83,14 +84,14 @@ function ie({
|
|
|
83
84
|
t.currentTarget.form?.requestSubmit();
|
|
84
85
|
}
|
|
85
86
|
d?.(t);
|
|
86
|
-
}, p =
|
|
87
|
+
}, p = Q(
|
|
87
88
|
null
|
|
88
|
-
), [
|
|
89
|
+
), [B, W] = y(0);
|
|
89
90
|
S(() => {
|
|
90
|
-
p.current &&
|
|
91
|
+
p.current && W(p.current.offsetHeight);
|
|
91
92
|
}, [r.value]);
|
|
92
93
|
const z = r.allowAttachments && r.files && r.files.length > 0;
|
|
93
|
-
return
|
|
94
|
+
return $({
|
|
94
95
|
ref: p,
|
|
95
96
|
maxHeight: 240,
|
|
96
97
|
borderWidth: 1,
|
|
@@ -99,19 +100,19 @@ function ie({
|
|
|
99
100
|
"div",
|
|
100
101
|
{
|
|
101
102
|
className: "relative flex w-full",
|
|
102
|
-
onDragOver:
|
|
103
|
-
onDragLeave:
|
|
104
|
-
onDrop:
|
|
103
|
+
onDragOver: E,
|
|
104
|
+
onDragLeave: H,
|
|
105
|
+
onDrop: K,
|
|
105
106
|
children: [
|
|
106
107
|
A && /* @__PURE__ */ e(
|
|
107
|
-
|
|
108
|
+
Z,
|
|
108
109
|
{
|
|
109
110
|
isOpen: N,
|
|
110
111
|
close: () => f(!1)
|
|
111
112
|
}
|
|
112
113
|
),
|
|
113
114
|
/* @__PURE__ */ e(
|
|
114
|
-
|
|
115
|
+
se,
|
|
115
116
|
{
|
|
116
117
|
isVisible: D,
|
|
117
118
|
onStopRecording: k
|
|
@@ -124,24 +125,25 @@ function ie({
|
|
|
124
125
|
"aria-label": "Write your prompt here",
|
|
125
126
|
placeholder: i,
|
|
126
127
|
ref: p,
|
|
127
|
-
onPaste:
|
|
128
|
-
onKeyDown:
|
|
128
|
+
onPaste: U,
|
|
129
|
+
onKeyDown: V,
|
|
130
|
+
"data-testid": R,
|
|
129
131
|
className: C(
|
|
130
132
|
"border-d-input bg-d-input ring-offset-d-background placeholder:text-d-muted-foreground focus-visible:border-d-primary z-10 w-full grow resize-none rounded-xl border p-3 pr-24 text-sm transition-[border] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
131
133
|
z && "pb-16",
|
|
132
|
-
|
|
134
|
+
n
|
|
133
135
|
),
|
|
134
136
|
...r.allowAttachments ? T(r, ["allowAttachments", "files", "setFiles"]) : T(r, ["allowAttachments"])
|
|
135
137
|
}
|
|
136
138
|
),
|
|
137
139
|
r.allowAttachments && /* @__PURE__ */ e("div", { className: "absolute inset-x-3 bottom-2 z-20 overflow-x-scroll py-3 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden", children: /* @__PURE__ */ e("div", { className: "flex space-x-3", children: /* @__PURE__ */ e(v, { mode: "popLayout", children: r.files?.map((t) => /* @__PURE__ */ e(
|
|
138
|
-
|
|
140
|
+
Y,
|
|
139
141
|
{
|
|
140
142
|
file: t,
|
|
141
143
|
onRemove: () => {
|
|
142
|
-
r.setFiles((
|
|
143
|
-
if (!
|
|
144
|
-
const c = Array.from(
|
|
144
|
+
r.setFiles((a) => {
|
|
145
|
+
if (!a) return null;
|
|
146
|
+
const c = Array.from(a).filter(
|
|
145
147
|
(b) => b !== t
|
|
146
148
|
);
|
|
147
149
|
return c.length === 0 ? null : c;
|
|
@@ -161,22 +163,22 @@ function ie({
|
|
|
161
163
|
className: "h-8 w-8",
|
|
162
164
|
"aria-label": "Attach a file",
|
|
163
165
|
onClick: async () => {
|
|
164
|
-
const t = await
|
|
166
|
+
const t = await le();
|
|
165
167
|
h(t);
|
|
166
168
|
},
|
|
167
169
|
children: /* @__PURE__ */ e(P, { className: "h-4 w-4" })
|
|
168
170
|
}
|
|
169
171
|
),
|
|
170
|
-
|
|
172
|
+
M && /* @__PURE__ */ e(
|
|
171
173
|
g,
|
|
172
174
|
{
|
|
173
175
|
type: "button",
|
|
174
176
|
variant: "outline",
|
|
175
|
-
className: C("h-8 w-8",
|
|
177
|
+
className: C("h-8 w-8", L && "text-d-primary"),
|
|
176
178
|
"aria-label": "Voice input",
|
|
177
179
|
size: "icon",
|
|
178
|
-
onClick:
|
|
179
|
-
children: /* @__PURE__ */ e(
|
|
180
|
+
onClick: q,
|
|
181
|
+
children: /* @__PURE__ */ e(G, { className: "h-4 w-4" })
|
|
180
182
|
}
|
|
181
183
|
),
|
|
182
184
|
u && s ? /* @__PURE__ */ e(
|
|
@@ -187,7 +189,7 @@ function ie({
|
|
|
187
189
|
className: "h-8 w-8",
|
|
188
190
|
"aria-label": "Stop generating",
|
|
189
191
|
onClick: s,
|
|
190
|
-
children: /* @__PURE__ */ e(
|
|
192
|
+
children: /* @__PURE__ */ e(ee, { className: "h-3 w-3 animate-pulse", fill: "currentColor" })
|
|
191
193
|
}
|
|
192
194
|
) : /* @__PURE__ */ e(
|
|
193
195
|
g,
|
|
@@ -197,18 +199,18 @@ function ie({
|
|
|
197
199
|
className: "h-8 w-8 transition-opacity",
|
|
198
200
|
"aria-label": "Send message",
|
|
199
201
|
disabled: r.value === "" || u,
|
|
200
|
-
children: /* @__PURE__ */ e(
|
|
202
|
+
children: /* @__PURE__ */ e(te, { className: "h-5 w-5" })
|
|
201
203
|
}
|
|
202
204
|
)
|
|
203
205
|
] }),
|
|
204
|
-
r.allowAttachments && /* @__PURE__ */ e(ne, { isDragging:
|
|
206
|
+
r.allowAttachments && /* @__PURE__ */ e(ne, { isDragging: F }),
|
|
205
207
|
/* @__PURE__ */ e(
|
|
206
|
-
|
|
208
|
+
ce,
|
|
207
209
|
{
|
|
208
210
|
isRecording: D,
|
|
209
|
-
isTranscribing:
|
|
210
|
-
audioStream:
|
|
211
|
-
textAreaHeight:
|
|
211
|
+
isTranscribing: O,
|
|
212
|
+
audioStream: j,
|
|
213
|
+
textAreaHeight: B,
|
|
212
214
|
onStopRecording: k
|
|
213
215
|
}
|
|
214
216
|
)
|
|
@@ -216,7 +218,7 @@ function ie({
|
|
|
216
218
|
}
|
|
217
219
|
);
|
|
218
220
|
}
|
|
219
|
-
|
|
221
|
+
ae.displayName = "MessageInput";
|
|
220
222
|
function ne({ isDragging: i }) {
|
|
221
223
|
return /* @__PURE__ */ e(v, { children: i && /* @__PURE__ */ o(
|
|
222
224
|
w.div,
|
|
@@ -234,22 +236,22 @@ function ne({ isDragging: i }) {
|
|
|
234
236
|
}
|
|
235
237
|
) });
|
|
236
238
|
}
|
|
237
|
-
function
|
|
239
|
+
function le() {
|
|
238
240
|
if (typeof document > "u")
|
|
239
241
|
return Promise.resolve(null);
|
|
240
242
|
const i = document.createElement("input");
|
|
241
|
-
return i.type = "file", i.multiple = !0, i.accept = "*/*", i.click(), new Promise((
|
|
243
|
+
return i.type = "file", i.multiple = !0, i.accept = "*/*", i.click(), new Promise((n) => {
|
|
242
244
|
i.onchange = (d) => {
|
|
243
245
|
const l = d.currentTarget.files;
|
|
244
246
|
if (l) {
|
|
245
|
-
|
|
247
|
+
n(Array.from(l));
|
|
246
248
|
return;
|
|
247
249
|
}
|
|
248
|
-
|
|
250
|
+
n(null);
|
|
249
251
|
};
|
|
250
252
|
});
|
|
251
253
|
}
|
|
252
|
-
function
|
|
254
|
+
function oe() {
|
|
253
255
|
return /* @__PURE__ */ o(
|
|
254
256
|
w.div,
|
|
255
257
|
{
|
|
@@ -260,7 +262,7 @@ function le() {
|
|
|
260
262
|
transition: { duration: 0.2 },
|
|
261
263
|
children: [
|
|
262
264
|
/* @__PURE__ */ o("div", { className: "relative", children: [
|
|
263
|
-
/* @__PURE__ */ e(
|
|
265
|
+
/* @__PURE__ */ e(ie, { className: "text-d-primary h-8 w-8 animate-spin" }),
|
|
264
266
|
/* @__PURE__ */ e(
|
|
265
267
|
w.div,
|
|
266
268
|
{
|
|
@@ -281,7 +283,7 @@ function le() {
|
|
|
281
283
|
}
|
|
282
284
|
);
|
|
283
285
|
}
|
|
284
|
-
function
|
|
286
|
+
function se({ isVisible: i, onStopRecording: n }) {
|
|
285
287
|
return /* @__PURE__ */ e(v, { children: i && /* @__PURE__ */ e(
|
|
286
288
|
w.div,
|
|
287
289
|
{
|
|
@@ -296,17 +298,17 @@ function oe({ isVisible: i, onStopRecording: a }) {
|
|
|
296
298
|
},
|
|
297
299
|
exit: { top: 0, filter: "blur(5px)" },
|
|
298
300
|
className: "bg-d-background border-d-border text-d-secondary-foreground absolute left-1/2 flex -translate-x-1/2 cursor-pointer overflow-hidden rounded-full border py-1 text-center text-sm whitespace-nowrap",
|
|
299
|
-
onClick:
|
|
301
|
+
onClick: n,
|
|
300
302
|
children: /* @__PURE__ */ o("span", { className: "mx-2.5 flex items-center", children: [
|
|
301
|
-
/* @__PURE__ */ e(
|
|
303
|
+
/* @__PURE__ */ e(re, { className: "mr-2 h-3 w-3" }),
|
|
302
304
|
"Click to finish recording"
|
|
303
305
|
] })
|
|
304
306
|
}
|
|
305
307
|
) });
|
|
306
308
|
}
|
|
307
|
-
function
|
|
309
|
+
function ce({
|
|
308
310
|
isRecording: i,
|
|
309
|
-
isTranscribing:
|
|
311
|
+
isTranscribing: n,
|
|
310
312
|
audioStream: d,
|
|
311
313
|
textAreaHeight: l,
|
|
312
314
|
onStopRecording: s
|
|
@@ -317,7 +319,7 @@ function se({
|
|
|
317
319
|
className: "absolute inset-[1px] z-50 overflow-hidden rounded-xl",
|
|
318
320
|
style: { height: l - 2 },
|
|
319
321
|
children: /* @__PURE__ */ e(
|
|
320
|
-
|
|
322
|
+
X,
|
|
321
323
|
{
|
|
322
324
|
stream: d,
|
|
323
325
|
isRecording: i,
|
|
@@ -325,15 +327,15 @@ function se({
|
|
|
325
327
|
}
|
|
326
328
|
)
|
|
327
329
|
}
|
|
328
|
-
) :
|
|
330
|
+
) : n ? /* @__PURE__ */ e(
|
|
329
331
|
"div",
|
|
330
332
|
{
|
|
331
333
|
className: "absolute inset-[1px] z-50 overflow-hidden rounded-xl",
|
|
332
334
|
style: { height: l - 2 },
|
|
333
|
-
children: /* @__PURE__ */ e(
|
|
335
|
+
children: /* @__PURE__ */ e(oe, {})
|
|
334
336
|
}
|
|
335
337
|
) : null;
|
|
336
338
|
}
|
|
337
339
|
export {
|
|
338
|
-
|
|
340
|
+
ae as MessageInput
|
|
339
341
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as t, jsxs as
|
|
2
|
+
import { jsx as t, jsxs as a } from "react/jsx-runtime";
|
|
3
3
|
import { Button as l } from "../../../button.js";
|
|
4
|
-
import { Popover as
|
|
5
|
-
function
|
|
6
|
-
actions:
|
|
7
|
-
i18n:
|
|
4
|
+
import { Popover as o, PopoverTrigger as s, PopoverContent as r } from "../../../popover.js";
|
|
5
|
+
function h({
|
|
6
|
+
actions: i,
|
|
7
|
+
i18n: n
|
|
8
8
|
}) {
|
|
9
|
-
if (!
|
|
10
|
-
if (
|
|
11
|
-
const [e] =
|
|
9
|
+
if (!i?.length) return null;
|
|
10
|
+
if (i.length === 1) {
|
|
11
|
+
const [e] = i;
|
|
12
12
|
return /* @__PURE__ */ t(
|
|
13
13
|
l,
|
|
14
14
|
{
|
|
@@ -17,11 +17,12 @@ function x({
|
|
|
17
17
|
variant: "default",
|
|
18
18
|
onClick: e.onClick,
|
|
19
19
|
className: "h-6 max-h-6 text-xs",
|
|
20
|
+
"data-testid": e["data-testid"],
|
|
20
21
|
children: e.label
|
|
21
22
|
}
|
|
22
23
|
);
|
|
23
24
|
}
|
|
24
|
-
return /* @__PURE__ */ o
|
|
25
|
+
return /* @__PURE__ */ a(o, { children: [
|
|
25
26
|
/* @__PURE__ */ t(s, { asChild: !0, children: /* @__PURE__ */ t(
|
|
26
27
|
l,
|
|
27
28
|
{
|
|
@@ -29,16 +30,16 @@ function x({
|
|
|
29
30
|
iconRight: "ChevronDown",
|
|
30
31
|
variant: "default",
|
|
31
32
|
className: "h-6 max-h-6 !px-2 text-xs",
|
|
32
|
-
children:
|
|
33
|
+
children: n.tableActions.actions
|
|
33
34
|
}
|
|
34
35
|
) }),
|
|
35
36
|
/* @__PURE__ */ t(
|
|
36
|
-
|
|
37
|
+
r,
|
|
37
38
|
{
|
|
38
39
|
side: "top",
|
|
39
40
|
className: "flex w-auto flex-col p-2",
|
|
40
41
|
align: "end",
|
|
41
|
-
children:
|
|
42
|
+
children: i.map((e) => /* @__PURE__ */ t(
|
|
42
43
|
l,
|
|
43
44
|
{
|
|
44
45
|
variant: "ghost",
|
|
@@ -46,6 +47,7 @@ function x({
|
|
|
46
47
|
size: "sm",
|
|
47
48
|
onClick: e.onClick,
|
|
48
49
|
className: "justify-start text-xs",
|
|
50
|
+
"data-testid": e["data-testid"],
|
|
49
51
|
children: e.label
|
|
50
52
|
},
|
|
51
53
|
e.label
|
|
@@ -55,5 +57,5 @@ function x({
|
|
|
55
57
|
] });
|
|
56
58
|
}
|
|
57
59
|
export {
|
|
58
|
-
|
|
60
|
+
h as DataTableActionsComponent
|
|
59
61
|
};
|
|
@@ -1,65 +1,67 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
2
|
+
import { jsx as a, jsxs as l } from "react/jsx-runtime";
|
|
3
3
|
import { Button as g } from "../../../button.js";
|
|
4
|
-
import { cn as
|
|
4
|
+
import { cn as z } from "../../../../../lib/utils.js";
|
|
5
5
|
import { useState as p, useRef as x, useEffect as v } from "react";
|
|
6
|
-
import { Tooltip as
|
|
7
|
-
function
|
|
6
|
+
import { Tooltip as D, TooltipTrigger as E, TooltipContent as L } from "../../../tooltip.js";
|
|
7
|
+
function K({
|
|
8
8
|
searchableColumnsHeaders: b = [],
|
|
9
9
|
i18n: i,
|
|
10
10
|
className: T = "",
|
|
11
11
|
onSearch: u,
|
|
12
|
-
debounceMs:
|
|
13
|
-
initialValue: t
|
|
12
|
+
debounceMs: h = 300,
|
|
13
|
+
initialValue: t,
|
|
14
|
+
id: S,
|
|
15
|
+
"data-testid": C
|
|
14
16
|
}) {
|
|
15
|
-
const [
|
|
17
|
+
const [s, c] = p(t || ""), [f, o] = p(
|
|
16
18
|
!!(t && t.length > 0)
|
|
17
|
-
),
|
|
19
|
+
), B = "search_input_" + Math.random().toString(36).substring(2, 9), N = S ?? B, d = x(null), n = x(null);
|
|
18
20
|
v(() => {
|
|
19
|
-
t && t.length > 0 ? (
|
|
21
|
+
t && t.length > 0 ? (c(t), o(!0)) : (t === "" || t === void 0) && (c(""), o(!1));
|
|
20
22
|
}, [t]), v(() => (u && (n.current && clearTimeout(n.current), n.current = setTimeout(() => {
|
|
21
|
-
u(
|
|
22
|
-
},
|
|
23
|
+
u(s);
|
|
24
|
+
}, h)), () => {
|
|
23
25
|
n.current && clearTimeout(n.current);
|
|
24
|
-
}), [
|
|
25
|
-
const
|
|
26
|
-
f ?
|
|
27
|
-
|
|
26
|
+
}), [s, u, h]);
|
|
27
|
+
const k = () => {
|
|
28
|
+
f ? d.current?.focus() : (o(!0), setTimeout(() => {
|
|
29
|
+
d.current?.focus();
|
|
28
30
|
}, 10));
|
|
29
|
-
},
|
|
30
|
-
e.preventDefault(), e.stopPropagation(),
|
|
31
|
+
}, w = (e) => {
|
|
32
|
+
e.preventDefault(), e.stopPropagation(), c(""), o(!1), setTimeout(() => {
|
|
31
33
|
e?.currentTarget?.closest(".relative")?.querySelector('button[aria-label="Search"]')?.focus();
|
|
32
34
|
}, 0);
|
|
33
|
-
},
|
|
34
|
-
const r = e.relatedTarget, m = !e.currentTarget.contains(r),
|
|
35
|
+
}, y = (e) => {
|
|
36
|
+
const r = e.relatedTarget, m = !e.currentTarget.contains(r), q = r?.parentElement?.getAttribute("aria-label") === "Search", I = r?.closest(
|
|
35
37
|
'button[aria-label="Clear search"]'
|
|
36
38
|
);
|
|
37
|
-
m && !
|
|
39
|
+
m && !q && !I && s === "" && (o(!1), setTimeout(() => {
|
|
38
40
|
e?.currentTarget?.closest(".relative")?.querySelector('button[aria-label="Search"]')?.focus();
|
|
39
41
|
}, 0));
|
|
40
42
|
};
|
|
41
|
-
return /* @__PURE__ */
|
|
42
|
-
/* @__PURE__ */ l(
|
|
43
|
-
/* @__PURE__ */
|
|
43
|
+
return /* @__PURE__ */ a("div", { className: z("relative", T), children: /* @__PURE__ */ l("div", { className: "flex items-center", children: [
|
|
44
|
+
/* @__PURE__ */ l(D, { children: [
|
|
45
|
+
/* @__PURE__ */ a(E, { asChild: !0, children: /* @__PURE__ */ a(
|
|
44
46
|
g,
|
|
45
47
|
{
|
|
46
48
|
className: "h-6 w-6",
|
|
47
49
|
iconLeft: "Search",
|
|
48
50
|
size: "icon",
|
|
49
51
|
variant: "ghost",
|
|
50
|
-
onClick:
|
|
52
|
+
onClick: k,
|
|
51
53
|
"aria-label": i.search
|
|
52
54
|
}
|
|
53
55
|
) }),
|
|
54
56
|
/* @__PURE__ */ l(
|
|
55
|
-
|
|
57
|
+
L,
|
|
56
58
|
{
|
|
57
59
|
className: "flex max-h-24 min-h-0 flex-col gap-0 px-2 py-1.5",
|
|
58
60
|
variant: "card",
|
|
59
61
|
align: "end",
|
|
60
62
|
children: [
|
|
61
|
-
/* @__PURE__ */
|
|
62
|
-
/* @__PURE__ */
|
|
63
|
+
/* @__PURE__ */ a("div", { className: "text-d-foreground/90 text-xs", children: i.searchTooltipLabel }),
|
|
64
|
+
/* @__PURE__ */ a("ul", { className: "flex flex-col gap-0 overflow-auto", children: b.map((e) => /* @__PURE__ */ l("li", { className: "text-d-foreground/75 text-xs", children: [
|
|
63
65
|
"⋅ ",
|
|
64
66
|
e
|
|
65
67
|
] }, e)) })
|
|
@@ -67,41 +69,42 @@ function P({
|
|
|
67
69
|
}
|
|
68
70
|
)
|
|
69
71
|
] }),
|
|
70
|
-
/* @__PURE__ */
|
|
72
|
+
/* @__PURE__ */ a(
|
|
71
73
|
"div",
|
|
72
74
|
{
|
|
73
75
|
className: `overflow-hidden transition-all duration-300 ease-in-out ${f ? "w-52" : "w-0"}`,
|
|
74
|
-
onBlur:
|
|
76
|
+
onBlur: y,
|
|
75
77
|
children: /* @__PURE__ */ l("div", { className: "flex w-52 items-center", children: [
|
|
76
|
-
/* @__PURE__ */
|
|
78
|
+
/* @__PURE__ */ a(
|
|
77
79
|
"input",
|
|
78
80
|
{
|
|
79
|
-
ref:
|
|
80
|
-
id:
|
|
81
|
+
ref: d,
|
|
82
|
+
id: N,
|
|
83
|
+
"data-testid": C,
|
|
81
84
|
className: "bg-background placeholder:text-muted-foreground h-8 flex-1 rounded-md border-0 px-2 py-1 text-xs outline-none",
|
|
82
85
|
placeholder: i.searchPlaceholder,
|
|
83
|
-
value:
|
|
86
|
+
value: s,
|
|
84
87
|
onChange: (e) => {
|
|
85
|
-
|
|
88
|
+
c(e.target.value);
|
|
86
89
|
},
|
|
87
90
|
onKeyDown: (e) => {
|
|
88
91
|
if (e.key === "Escape") {
|
|
89
92
|
const r = e.target;
|
|
90
|
-
r.value ? (
|
|
93
|
+
r.value ? (c(""), r.focus()) : (o(!1), r.closest(".relative")?.querySelector(
|
|
91
94
|
'button[aria-label="Search"]'
|
|
92
95
|
)?.focus());
|
|
93
96
|
}
|
|
94
97
|
}
|
|
95
98
|
}
|
|
96
99
|
),
|
|
97
|
-
|
|
100
|
+
s !== "" && /* @__PURE__ */ a(
|
|
98
101
|
g,
|
|
99
102
|
{
|
|
100
103
|
className: "text-muted-foreground hover:text-foreground hover:text-d-destructive absolute top-1 right-0 size-6",
|
|
101
104
|
iconLeft: "X",
|
|
102
105
|
size: "icon",
|
|
103
106
|
variant: "ghost",
|
|
104
|
-
onClick:
|
|
107
|
+
onClick: w,
|
|
105
108
|
"aria-label": i.clearSearch
|
|
106
109
|
}
|
|
107
110
|
)
|
|
@@ -111,5 +114,5 @@ function P({
|
|
|
111
114
|
] }) });
|
|
112
115
|
}
|
|
113
116
|
export {
|
|
114
|
-
|
|
117
|
+
K as DataTableSearchbar
|
|
115
118
|
};
|