@knkcs/anker 0.0.1

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.
Files changed (39) hide show
  1. package/LICENSE +30 -0
  2. package/README.md +129 -0
  3. package/dist/atoms/index.d.ts +536 -0
  4. package/dist/atoms/index.js +845 -0
  5. package/dist/atoms/index.js.map +1 -0
  6. package/dist/avatar-DhqkKdqc.d.ts +29 -0
  7. package/dist/chunk-4D3EY2W2.js +1628 -0
  8. package/dist/chunk-4D3EY2W2.js.map +1 -0
  9. package/dist/chunk-4T32UC26.js +81 -0
  10. package/dist/chunk-4T32UC26.js.map +1 -0
  11. package/dist/chunk-FGKGX4UF.js +36 -0
  12. package/dist/chunk-FGKGX4UF.js.map +1 -0
  13. package/dist/chunk-PZCL4M6I.js +62 -0
  14. package/dist/chunk-PZCL4M6I.js.map +1 -0
  15. package/dist/chunk-QSCNXHMU.js +32 -0
  16. package/dist/chunk-QSCNXHMU.js.map +1 -0
  17. package/dist/chunk-RJPEVNMJ.js +23 -0
  18. package/dist/chunk-RJPEVNMJ.js.map +1 -0
  19. package/dist/chunk-YXTW5OAJ.js +303 -0
  20. package/dist/chunk-YXTW5OAJ.js.map +1 -0
  21. package/dist/components/index.d.ts +413 -0
  22. package/dist/components/index.js +982 -0
  23. package/dist/components/index.js.map +1 -0
  24. package/dist/feedback/index.d.ts +27 -0
  25. package/dist/feedback/index.js +100 -0
  26. package/dist/feedback/index.js.map +1 -0
  27. package/dist/forms/index.d.ts +272 -0
  28. package/dist/forms/index.js +947 -0
  29. package/dist/forms/index.js.map +1 -0
  30. package/dist/number-input-D2X0rWOg.d.ts +18 -0
  31. package/dist/primitives/index.d.ts +396 -0
  32. package/dist/primitives/index.js +478 -0
  33. package/dist/primitives/index.js.map +1 -0
  34. package/dist/search-input-C_Cl2OEx.d.ts +17 -0
  35. package/dist/switch-B0o6G2XE.d.ts +28 -0
  36. package/dist/theme/index.d.ts +496 -0
  37. package/dist/theme/index.js +3 -0
  38. package/dist/theme/index.js.map +1 -0
  39. package/package.json +96 -0
@@ -0,0 +1,845 @@
1
+ import { Prose, Avatar } from '../chunk-YXTW5OAJ.js';
2
+ import { Tooltip } from '../chunk-QSCNXHMU.js';
3
+ export { SearchInput, text_input_default as TextInput } from '../chunk-PZCL4M6I.js';
4
+ import { DataList as DataList$1, Text, Box, Icon, IconButton, Circle, useCheckboxGroup, Stack, Clipboard, Input, chakra, HStack, Button, Textarea, Flex, ButtonGroup, Heading, Table, Square, Spinner, Badge } from '@chakra-ui/react';
5
+ import { jsx, jsxs } from 'react/jsx-runtime';
6
+ import { ChevronRight, ChevronDown, Pencil, Filter as Filter$1, GripVertical, X, Clipboard as Clipboard$1, Check, Link } from 'lucide-react';
7
+ import React, { createContext, memo, useRef, useState, useCallback, useEffect, useMemo, useContext } from 'react';
8
+ import dayjs2 from 'dayjs';
9
+ import calendarPlugin from 'dayjs/plugin/calendar.js';
10
+ import relativeTime from 'dayjs/plugin/relativeTime.js';
11
+ import utcPlugin from 'dayjs/plugin/utc.js';
12
+ import { Select, chakraComponents } from 'chakra-react-select';
13
+ export { Select as ChakraReactSelect, CreatableSelect, chakraComponents } from 'chakra-react-select';
14
+ import { readableColor } from 'color2k';
15
+
16
+ var Action = ({
17
+ ref,
18
+ cursor,
19
+ color,
20
+ ...props
21
+ }) => {
22
+ return /* @__PURE__ */ jsx(
23
+ Box,
24
+ {
25
+ display: "flex",
26
+ alignItems: "center",
27
+ justifyContent: "center",
28
+ borderRadius: "5px",
29
+ p: "15px",
30
+ tabIndex: 0,
31
+ cursor,
32
+ transition: "background-color 150ms, color 150ms, opacity 150ms",
33
+ bg: color,
34
+ asChild: true,
35
+ children: /* @__PURE__ */ jsx("button", { type: "button", ref, ...props })
36
+ }
37
+ );
38
+ };
39
+ Action.displayName = "Action";
40
+ var Collapse = ({
41
+ ref,
42
+ collapseLabel = "Collapse",
43
+ ...props
44
+ }) => {
45
+ const { collapsed, ...rest } = props;
46
+ return /* @__PURE__ */ jsx(Action, { ref, cursor: "pointer", "aria-label": collapseLabel, ...rest, children: /* @__PURE__ */ jsx(Icon, { color: "subtle", children: collapsed ? /* @__PURE__ */ jsx(ChevronRight, {}) : /* @__PURE__ */ jsx(ChevronDown, {}) }) });
47
+ };
48
+ Collapse.displayName = "Collapse";
49
+ var Edit = ({
50
+ ref,
51
+ editLabel = "Edit",
52
+ ...props
53
+ }) => {
54
+ return /* @__PURE__ */ jsx(Action, { ref, cursor: "pointer", "aria-label": editLabel, ...props, children: /* @__PURE__ */ jsx(Icon, { color: "subtle", asChild: true, children: /* @__PURE__ */ jsx(Pencil, {}) }) });
55
+ };
56
+ Edit.displayName = "Edit";
57
+ var Filter = ({
58
+ ref,
59
+ filterLabel = "Filter",
60
+ ...props
61
+ }) => {
62
+ const { activeFilterCount, ...rest } = props;
63
+ return /* @__PURE__ */ jsxs(Box, { position: "relative", children: [
64
+ /* @__PURE__ */ jsx(IconButton, { cursor: "pointer", ref, "aria-label": filterLabel, ...rest, children: /* @__PURE__ */ jsx(Filter$1, {}) }),
65
+ activeFilterCount && activeFilterCount > 0 ? /* @__PURE__ */ jsx(
66
+ Circle,
67
+ {
68
+ size: "24px",
69
+ bg: "accent",
70
+ color: "on-accent",
71
+ position: "absolute",
72
+ top: 5,
73
+ insetInlineEnd: -1.5,
74
+ children: /* @__PURE__ */ jsx(Text, { fontSize: "xs", fontWeight: 800, children: activeFilterCount })
75
+ }
76
+ ) : null
77
+ ] });
78
+ };
79
+ Filter.displayName = "Filter";
80
+ var Handle = ({
81
+ ref,
82
+ handleLabel = "Drag to reorder",
83
+ ...props
84
+ }) => {
85
+ return /* @__PURE__ */ jsx(Action, { ref, cursor: "grab", "aria-label": handleLabel, ...props, children: /* @__PURE__ */ jsx(Icon, { color: "subtle", asChild: true, children: /* @__PURE__ */ jsx(GripVertical, {}) }) });
86
+ };
87
+ Handle.displayName = "Handle";
88
+ var Remove = ({
89
+ ref,
90
+ removeLabel = "Remove",
91
+ ...props
92
+ }) => {
93
+ return /* @__PURE__ */ jsx(Action, { ref, "aria-label": removeLabel, ...props, children: /* @__PURE__ */ jsx(Icon, { color: "subtle", asChild: true, children: /* @__PURE__ */ jsx(X, {}) }) });
94
+ };
95
+ Remove.displayName = "Remove";
96
+ var CheckboxCardGroup = (props) => {
97
+ const { children, defaultValue, value, onValueChange, ...rest } = props;
98
+ const group = useCheckboxGroup({
99
+ defaultValue,
100
+ value,
101
+ onValueChange
102
+ });
103
+ const cards = React.useMemo(
104
+ () => React.Children.toArray(children).filter(React.isValidElement).map((card) => {
105
+ return React.cloneElement(card, {
106
+ checkboxProps: group.getItemProps({
107
+ value: card.props.value
108
+ })
109
+ });
110
+ }),
111
+ [children, group]
112
+ );
113
+ return /* @__PURE__ */ jsx(Stack, { ...rest, children: cards });
114
+ };
115
+ CheckboxCardGroup.displayName = "CheckboxCardGroup";
116
+ var CheckboxCard = (props) => {
117
+ const { checkboxProps, children, ...rest } = props;
118
+ const id = React.useId();
119
+ return /* @__PURE__ */ jsx(
120
+ Box,
121
+ {
122
+ cursor: "pointer",
123
+ css: {
124
+ "& .focus-visible + [data-focus]": {
125
+ boxShadow: "outline",
126
+ zIndex: 1
127
+ }
128
+ },
129
+ asChild: true,
130
+ children: /* @__PURE__ */ jsxs("label", { children: [
131
+ /* @__PURE__ */ jsx("input", { type: "checkbox", "aria-labelledby": id, ...checkboxProps }),
132
+ /* @__PURE__ */ jsx(Box, { ...rest, children: /* @__PURE__ */ jsx(Stack, { direction: "row", children: /* @__PURE__ */ jsx(Box, { flex: "1", id, children }) }) })
133
+ ] })
134
+ }
135
+ );
136
+ };
137
+ CheckboxCard.displayName = "CheckboxCard";
138
+ var ClipboardButton = function ClipboardButton2({
139
+ ref,
140
+ ...props
141
+ }) {
142
+ const { label = "Copy", ...rest } = props;
143
+ return /* @__PURE__ */ jsx(Clipboard.Root, { ref, ...rest, children: /* @__PURE__ */ jsx(Clipboard.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(IconButton, { variant: "ghost", size: "sm", "aria-label": label, children: /* @__PURE__ */ jsx(Clipboard.Indicator, { copied: /* @__PURE__ */ jsx(Check, { size: 16 }), children: /* @__PURE__ */ jsx(Clipboard$1, { size: 16 }) }) }) }) });
144
+ };
145
+ ClipboardButton.displayName = "ClipboardButton";
146
+ var ClipboardInput = function ClipboardInput2({
147
+ ref,
148
+ ...props
149
+ }) {
150
+ const { inputProps, label = "Copy", ...rest } = props;
151
+ return /* @__PURE__ */ jsx(Clipboard.Root, { ref, ...rest, children: /* @__PURE__ */ jsxs(Clipboard.Control, { children: [
152
+ /* @__PURE__ */ jsx(Clipboard.Input, { asChild: true, children: /* @__PURE__ */ jsx(Input, { readOnly: true, ...inputProps }) }),
153
+ /* @__PURE__ */ jsx(Clipboard.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(IconButton, { variant: "outline", size: "sm", "aria-label": label, children: /* @__PURE__ */ jsx(Clipboard.Indicator, { copied: /* @__PURE__ */ jsx(Check, { size: 16 }), children: /* @__PURE__ */ jsx(Clipboard$1, { size: 16 }) }) }) })
154
+ ] }) });
155
+ };
156
+ ClipboardInput.displayName = "ClipboardInput";
157
+ var ClipboardLink = function ClipboardLink2({
158
+ ref,
159
+ ...props
160
+ }) {
161
+ const { label = "Copy Link", ...rest } = props;
162
+ return /* @__PURE__ */ jsx(Clipboard.Root, { ref, ...rest, children: /* @__PURE__ */ jsx(Clipboard.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(IconButton, { variant: "ghost", size: "xs", "aria-label": label, children: /* @__PURE__ */ jsx(Clipboard.Indicator, { copied: /* @__PURE__ */ jsx(Check, { size: 14 }), children: /* @__PURE__ */ jsx(Link, { size: 14 }) }) }) }) });
163
+ };
164
+ ClipboardLink.displayName = "ClipboardLink";
165
+ dayjs2.extend(utcPlugin);
166
+ function formatDateAndTime(date, format = "full") {
167
+ let template;
168
+ switch (format) {
169
+ case "day":
170
+ template = "DD MMM YYYY";
171
+ break;
172
+ case "weekday":
173
+ template = "ddd, DD MMM";
174
+ break;
175
+ case "time":
176
+ template = "h:mm A";
177
+ break;
178
+ case "fullWithSeconds":
179
+ template = "ddd, DD MMM YYYY [at] h:mm:ss A";
180
+ break;
181
+ default:
182
+ template = "ddd, DD MMM YYYY [at] h:mm A";
183
+ }
184
+ return dayjs2(date).format(template);
185
+ }
186
+ function formatMachineReadableDateTime(date, format = "full") {
187
+ let template;
188
+ switch (format) {
189
+ case "day":
190
+ template = "YYYY-MM-DD";
191
+ break;
192
+ case "weekday":
193
+ template = "MM-DD";
194
+ break;
195
+ case "time":
196
+ template = "HH:mm:ss.SSS";
197
+ break;
198
+ default:
199
+ template = "YYYY-MM-DDTHH:mm:ss.SSS[Z]";
200
+ }
201
+ return dayjs2(date).utc().format(template);
202
+ }
203
+ var formatDate = (date) => {
204
+ return formatDateAndTime(date, "day");
205
+ };
206
+ var formatTime = (date) => {
207
+ return formatDateAndTime(date, "time");
208
+ };
209
+ var formatWeekdayDate = (date) => {
210
+ return formatDateAndTime(date, "weekday");
211
+ };
212
+ dayjs2.extend(utcPlugin);
213
+ dayjs2.extend(relativeTime);
214
+ dayjs2.extend(calendarPlugin);
215
+ function formatRelativeDateTime(date, baseDate = /* @__PURE__ */ new Date()) {
216
+ return dayjs2(date).from(baseDate);
217
+ }
218
+ function formatRelativeToCurrentWeekDateTime(date, baseDate = /* @__PURE__ */ new Date()) {
219
+ const isToday = dayjs2(date).isSame(baseDate, "day");
220
+ if (!isToday) {
221
+ return dayjs2(date).calendar(baseDate, {
222
+ sameElse: "DD MMM YYYY"
223
+ });
224
+ }
225
+ return formatRelativeDateTime(date, baseDate);
226
+ }
227
+ dayjs2.extend(utcPlugin);
228
+ dayjs2.extend(relativeTime);
229
+ dayjs2.extend(calendarPlugin);
230
+ var RelativeDateTime = (props) => {
231
+ const { date, baseDate, isRelativeToCurrentWeek, ...otherProps } = props;
232
+ const now = /* @__PURE__ */ new Date();
233
+ const referenceDate = baseDate ?? now;
234
+ const dayjsDate = dayjs2(date);
235
+ const machineReadableDate = formatMachineReadableDateTime(date);
236
+ let relativeDate;
237
+ if (isRelativeToCurrentWeek && !dayjsDate.isSame(referenceDate, "day")) {
238
+ relativeDate = formatRelativeToCurrentWeekDateTime(date, referenceDate);
239
+ } else {
240
+ relativeDate = formatRelativeDateTime(date, referenceDate);
241
+ }
242
+ return /* @__PURE__ */ jsx("time", { dateTime: machineReadableDate, ...otherProps, children: relativeDate });
243
+ };
244
+ var CommentStylesContext = createContext({});
245
+ var useStyles = () => useContext(CommentStylesContext);
246
+ var Comment = (props) => {
247
+ const {
248
+ avatar,
249
+ content,
250
+ children,
251
+ author,
252
+ commentedAt,
253
+ actions,
254
+ id,
255
+ isDeleted,
256
+ deletedLabel = "This comment has been deleted",
257
+ ...rest
258
+ } = props;
259
+ const styles = {};
260
+ const headerProps = {
261
+ author,
262
+ commentedAt
263
+ };
264
+ const footerProps = {
265
+ actions
266
+ };
267
+ return /* @__PURE__ */ jsx(chakra.div, { css: styles.container, "data-id": id, ...rest, children: /* @__PURE__ */ jsxs(CommentStylesContext.Provider, { value: styles, children: [
268
+ avatar && /* @__PURE__ */ jsx(AvatarSlot, { children: avatar }),
269
+ (content || isDeleted) && /* @__PURE__ */ jsx(ContentContainer, { children: /* @__PURE__ */ jsxs(Stack, { gap: 3, children: [
270
+ /* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
271
+ /* @__PURE__ */ jsx(CommentHeader, { ...headerProps }),
272
+ /* @__PURE__ */ jsx(
273
+ Prose,
274
+ {
275
+ css: {
276
+ "& p": {
277
+ fontSize: "inherit!important"
278
+ },
279
+ "& *:first-child": {
280
+ marginTop: 0
281
+ },
282
+ "& *:last-child": {
283
+ marginBottom: 0
284
+ }
285
+ },
286
+ children: isDeleted ? /* @__PURE__ */ jsx(chakra.span, { css: styles.deletedText, children: deletedLabel }) : content
287
+ }
288
+ )
289
+ ] }),
290
+ /* @__PURE__ */ jsx(CommentFooter, { ...footerProps })
291
+ ] }) }),
292
+ children && /* @__PURE__ */ jsx(Stack, { gap: 4, css: styles.children, children })
293
+ ] }) });
294
+ };
295
+ Comment.displayName = "Comment";
296
+ var AvatarSlot = ({ children }) => {
297
+ const styles = useStyles();
298
+ return /* @__PURE__ */ jsx(chakra.div, { css: styles.avatar, children });
299
+ };
300
+ var ContentContainer = ({ children }) => {
301
+ const styles = useStyles();
302
+ return /* @__PURE__ */ jsx(chakra.div, { css: styles.contentContainer, children });
303
+ };
304
+ var CommentHeader = (props) => {
305
+ const { author, commentedAt } = props;
306
+ const shouldRender = !!author || !!commentedAt;
307
+ return shouldRender ? /* @__PURE__ */ jsxs(HStack, { children: [
308
+ author && /* @__PURE__ */ jsx(Author, { children: author.name }),
309
+ commentedAt && /* @__PURE__ */ jsx(RelativeDateTime, { date: commentedAt })
310
+ ] }) : null;
311
+ };
312
+ var Author = (props) => {
313
+ const { children } = props;
314
+ const styles = useStyles();
315
+ return /* @__PURE__ */ jsx(chakra.span, { css: styles.field, children });
316
+ };
317
+ var CommentFooter = (props) => {
318
+ const { actions } = props;
319
+ return /* @__PURE__ */ jsx(HStack, { alignItems: "center", gap: 4, flexWrap: "wrap", children: actions?.map((item, key) => Object.assign({}, item, { key })) });
320
+ };
321
+ var CommentAction = (props) => {
322
+ return /* @__PURE__ */ jsx(Button, { variant: "outline", size: "xs", ...props });
323
+ };
324
+ var CommentReplyBox = ({
325
+ ref,
326
+ ...props
327
+ }) => {
328
+ const {
329
+ onReply,
330
+ onCancel,
331
+ placeholder = "Write a reply...",
332
+ cancelLabel = "Cancel",
333
+ replyLabel = "Reply"
334
+ } = props;
335
+ const textBoxRef = useRef(null);
336
+ const mergedRef = (node) => {
337
+ textBoxRef.current = node;
338
+ if (typeof ref === "function") {
339
+ ref(node);
340
+ } else if (ref) {
341
+ ref.current = node;
342
+ }
343
+ };
344
+ const [isFocused, setIsFocused] = useState(false);
345
+ const [isSubmitting, setIsSubmitting] = useState(false);
346
+ const [value, setValue] = useState("");
347
+ const handleReply = async (e) => {
348
+ e.preventDefault();
349
+ e.stopPropagation();
350
+ if (!value || !value.trim() || value === "") {
351
+ return;
352
+ }
353
+ try {
354
+ setIsSubmitting(true);
355
+ await onReply?.(value);
356
+ setValue("");
357
+ setIsFocused(false);
358
+ } catch (e2) {
359
+ console.error(e2);
360
+ }
361
+ setIsSubmitting(false);
362
+ };
363
+ const handleCancel = () => {
364
+ setValue("");
365
+ setIsFocused(false);
366
+ onCancel?.();
367
+ };
368
+ return /* @__PURE__ */ jsx(Box, { w: "full", onFocus: () => setIsFocused(true), children: /* @__PURE__ */ jsxs("form", { onSubmit: handleReply, children: [
369
+ /* @__PURE__ */ jsx(
370
+ Textarea,
371
+ {
372
+ value: String(value),
373
+ onChange: (e) => setValue(e.target.value),
374
+ minH: isFocused ? void 0 : "2.5rem",
375
+ placeholder,
376
+ ref: mergedRef,
377
+ onKeyDown: (e) => {
378
+ if ((e.ctrlKey || e.metaKey) && e.key === "Enter") {
379
+ handleReply(e);
380
+ }
381
+ },
382
+ disabled: isSubmitting
383
+ }
384
+ ),
385
+ /* @__PURE__ */ jsx(
386
+ Flex,
387
+ {
388
+ mt: 2,
389
+ display: isFocused ? "flex" : "none",
390
+ justifyContent: "flex-end",
391
+ children: /* @__PURE__ */ jsxs(ButtonGroup, { marginInlineStart: "auto", size: "sm", children: [
392
+ /* @__PURE__ */ jsx(
393
+ Button,
394
+ {
395
+ variant: "outline",
396
+ loading: isSubmitting,
397
+ onClick: handleCancel,
398
+ children: cancelLabel
399
+ }
400
+ ),
401
+ /* @__PURE__ */ jsx(Button, { type: "submit", variant: "solid", loading: isSubmitting, children: replyLabel })
402
+ ] })
403
+ }
404
+ )
405
+ ] }) });
406
+ };
407
+ CommentReplyBox.displayName = "CommentReplyBox";
408
+ var DataList = function DataList2({
409
+ ref,
410
+ ...props
411
+ }) {
412
+ const { items, children, ...rest } = props;
413
+ return /* @__PURE__ */ jsx(DataList$1.Root, { ref, ...rest, children: items ? items.map((item) => /* @__PURE__ */ jsxs(DataList$1.Item, { children: [
414
+ /* @__PURE__ */ jsx(DataList$1.ItemLabel, { children: item.label }),
415
+ /* @__PURE__ */ jsx(DataList$1.ItemValue, { children: item.value })
416
+ ] }, String(item.label))) : children });
417
+ };
418
+ DataList.displayName = "DataList";
419
+ var DataListItem = DataList$1.Item;
420
+ DataListItem.displayName = "DataListItem";
421
+ var DataListItemLabel = DataList$1.ItemLabel;
422
+ DataListItemLabel.displayName = "DataListItemLabel";
423
+ var DataListItemValue = DataList$1.ItemValue;
424
+ DataListItemValue.displayName = "DataListItemValue";
425
+ var datePattern = /^\d{4}-\d{2}-\d{2}$/;
426
+ function toDateString(value) {
427
+ if (!value) return "";
428
+ if (datePattern.test(value)) return value;
429
+ try {
430
+ const date = new Date(value);
431
+ if (Number.isNaN(date.getTime())) return "";
432
+ return date.toISOString().slice(0, 10);
433
+ } catch {
434
+ return "";
435
+ }
436
+ }
437
+ var DateInput = ({
438
+ ref,
439
+ ...props
440
+ }) => {
441
+ const { value, minDate, maxDate, onChange, ...rest } = props;
442
+ const dateValue = value ? toDateString(value) : "";
443
+ return /* @__PURE__ */ jsx(
444
+ Input,
445
+ {
446
+ type: "date",
447
+ value: dateValue,
448
+ min: minDate,
449
+ max: maxDate,
450
+ onChange,
451
+ ref,
452
+ ...rest
453
+ }
454
+ );
455
+ };
456
+ DateInput.displayName = "DateInput";
457
+ var date_input_default = DateInput;
458
+ var EmptyState = (props) => {
459
+ const { header, description, icon, actions } = props;
460
+ return /* @__PURE__ */ jsxs(
461
+ Stack,
462
+ {
463
+ justifyContent: "center",
464
+ alignItems: "center",
465
+ textAlign: "center",
466
+ gap: 4,
467
+ p: 16,
468
+ borderRadius: "lg",
469
+ children: [
470
+ icon,
471
+ /* @__PURE__ */ jsx(Heading, { size: "lg", children: header }),
472
+ description && /* @__PURE__ */ jsx(Text, { color: "muted", fontSize: "sm", children: description }),
473
+ actions && /* @__PURE__ */ jsx(Stack, { pt: 4, gap: 2, children: actions })
474
+ ]
475
+ }
476
+ );
477
+ };
478
+ EmptyState.displayName = "EmptyState";
479
+ var PersonaStylesContext = createContext({});
480
+ var usePersonaStyles = () => useContext(PersonaStylesContext);
481
+ var Persona = (props) => {
482
+ const { name, size = "sm", hideDetails, label, interactive } = props;
483
+ return /* @__PURE__ */ jsxs(PersonaContainer, { interactive, children: [
484
+ /* @__PURE__ */ jsx(PersonaAvatar, { name, size }),
485
+ !hideDetails && /* @__PURE__ */ jsx(PersonaDetails, { children: /* @__PURE__ */ jsx(PersonaLabel, { children: label || name }) })
486
+ ] });
487
+ };
488
+ Persona.displayName = "Persona";
489
+ var PersonaContainer = ({
490
+ ref,
491
+ ...props
492
+ }) => {
493
+ const { children, styles = {}, interactive, ...rest } = props;
494
+ return /* @__PURE__ */ jsx(PersonaStylesContext.Provider, { value: styles, children: /* @__PURE__ */ jsx(
495
+ chakra.div,
496
+ {
497
+ ref,
498
+ display: "flex",
499
+ flexDirection: "row",
500
+ alignItems: "center",
501
+ ...interactive && {
502
+ cursor: "pointer",
503
+ borderRadius: "md",
504
+ transition: "background-color 150ms",
505
+ _hover: { bg: "bg-subtle" },
506
+ px: 2,
507
+ py: 1
508
+ },
509
+ ...rest,
510
+ children
511
+ }
512
+ ) });
513
+ };
514
+ var PersonaAvatar = ({
515
+ ref,
516
+ ...props
517
+ }) => {
518
+ const { name, size, ...rest } = props;
519
+ return /* @__PURE__ */ jsx(Avatar, { ref, name, size, ...rest });
520
+ };
521
+ var PersonaDetails = ({
522
+ ref,
523
+ ...props
524
+ }) => {
525
+ const { children, ...rest } = props;
526
+ const styles = usePersonaStyles();
527
+ return /* @__PURE__ */ jsx(
528
+ chakra.div,
529
+ {
530
+ ref,
531
+ display: "flex",
532
+ flexDirection: "column",
533
+ style: styles.details,
534
+ ...rest,
535
+ children
536
+ }
537
+ );
538
+ };
539
+ var PersonaLabel = ({
540
+ ref,
541
+ ...props
542
+ }) => {
543
+ const styles = usePersonaStyles();
544
+ return /* @__PURE__ */ jsx(chakra.span, { ref, style: styles.label, ...props });
545
+ };
546
+ var BaseSingleValue = ({
547
+ data,
548
+ ...props
549
+ }) => {
550
+ return /* @__PURE__ */ jsx(chakraComponents.SingleValue, { data, ...props, children: /* @__PURE__ */ jsxs(HStack, { gap: 2, children: [
551
+ data.avatar && /* @__PURE__ */ jsx(Avatar, { name: data.avatar, size: "xs" }),
552
+ data.color && /* @__PURE__ */ jsx(Circle, { bg: data.color, size: 5 }),
553
+ data.icon && data.icon,
554
+ /* @__PURE__ */ jsx(Text, { children: data.label })
555
+ ] }) });
556
+ };
557
+ var BaseMultiValue = ({
558
+ children,
559
+ ...props
560
+ }) => {
561
+ const { data } = props;
562
+ return (
563
+ // @ts-expect-error -- strict mode: duplicate property
564
+ /* @__PURE__ */ jsx(chakraComponents.MultiValue, { data, ...props, children: /* @__PURE__ */ jsxs(HStack, { gap: 2, children: [
565
+ data.avatar && /* @__PURE__ */ jsx(Avatar, { name: data.avatar, size: "xs" }),
566
+ data.color && /* @__PURE__ */ jsx(Circle, { bg: data.color, size: 5 }),
567
+ data.icon && data.icon,
568
+ /* @__PURE__ */ jsx(Text, { children: data.label })
569
+ ] }) })
570
+ );
571
+ };
572
+ var BaseSelectOption = ({
573
+ data,
574
+ ...props
575
+ }) => {
576
+ return /* @__PURE__ */ jsx(chakraComponents.Option, { data, ...props, children: /* @__PURE__ */ jsxs(HStack, { gap: 2, children: [
577
+ data.avatar && /* @__PURE__ */ jsx(Avatar, { name: data.avatar, size: "xs" }),
578
+ data.color && /* @__PURE__ */ jsx(Circle, { bg: data.color, size: 5 }),
579
+ data.icon && data.icon,
580
+ /* @__PURE__ */ jsx(Text, { children: data.label })
581
+ ] }) });
582
+ };
583
+ var getSelectComponents = (variant, customComponents) => ({
584
+ ...variant === "link" ? {
585
+ DropdownIndicator: null,
586
+ IndicatorSeparator: null
587
+ } : {},
588
+ SingleValue: BaseSingleValue,
589
+ MultiValue: BaseMultiValue,
590
+ Option: BaseSelectOption,
591
+ ...customComponents
592
+ });
593
+ var BaseSelect = ({
594
+ ref,
595
+ value,
596
+ onChange,
597
+ options,
598
+ isMulti = false,
599
+ loading = false,
600
+ disabled = false,
601
+ isClearable = true,
602
+ placeholder,
603
+ menuPortalTarget = document.body,
604
+ variant = "outline",
605
+ styles,
606
+ ...restSelectProps
607
+ }) => {
608
+ return /* @__PURE__ */ jsx(
609
+ Select,
610
+ {
611
+ ...restSelectProps,
612
+ ref,
613
+ value,
614
+ variant,
615
+ onChange,
616
+ options,
617
+ isMulti,
618
+ isLoading: loading,
619
+ isDisabled: disabled,
620
+ isClearable,
621
+ placeholder,
622
+ menuPortalTarget,
623
+ styles: {
624
+ menuPortal: (provided) => ({
625
+ ...provided,
626
+ zIndex: 1800,
627
+ pointerEvents: "auto"
628
+ }),
629
+ ...styles
630
+ },
631
+ getOptionValue: (option) => option.id,
632
+ getOptionLabel: (option) => option.label,
633
+ components: getSelectComponents(
634
+ variant,
635
+ // @ts-expect-error -- strict mode: argument type
636
+ restSelectProps.components
637
+ )
638
+ }
639
+ );
640
+ };
641
+ BaseSelect.displayName = "BaseSelect";
642
+ var TableMenuList = ({
643
+ children,
644
+ columns,
645
+ minWidth = "400px",
646
+ maxWidth = "600px",
647
+ ...props
648
+ }) => {
649
+ const { options } = props;
650
+ const derivedColumns = useMemo(() => {
651
+ if (columns) return columns;
652
+ const firstOption = options?.[0];
653
+ if (!firstOption?.data) {
654
+ return [{ key: "label", header: "Name" }];
655
+ }
656
+ return [
657
+ { key: "label", header: "Name" },
658
+ ...Object.keys(firstOption.data).map((key) => ({
659
+ key,
660
+ header: key.charAt(0).toUpperCase() + key.slice(1).replace(/_/g, " ")
661
+ }))
662
+ ];
663
+ }, [columns, options]);
664
+ return /* @__PURE__ */ jsx(chakraComponents.MenuList, { ...props, children: /* @__PURE__ */ jsx(
665
+ Box,
666
+ {
667
+ overflowX: "auto",
668
+ minWidth,
669
+ maxWidth,
670
+ width: "max-content",
671
+ children: /* @__PURE__ */ jsxs(Table.Root, { size: "sm", children: [
672
+ /* @__PURE__ */ jsx(Table.Header, { children: /* @__PURE__ */ jsx(Table.Row, { children: derivedColumns.map((col) => /* @__PURE__ */ jsx(
673
+ Table.ColumnHeader,
674
+ {
675
+ width: col.width,
676
+ whiteSpace: "nowrap",
677
+ children: col.header
678
+ },
679
+ col.key
680
+ )) }) }),
681
+ /* @__PURE__ */ jsx(Table.Body, { children })
682
+ ] })
683
+ }
684
+ ) });
685
+ };
686
+ TableMenuList.displayName = "TableMenuList";
687
+ var TableOption = ({
688
+ data,
689
+ innerProps,
690
+ isSelected,
691
+ isFocused,
692
+ columns
693
+ }) => {
694
+ const derivedColumns = useMemo(() => {
695
+ if (columns) return columns;
696
+ if (!data.data) {
697
+ return [{ key: "label", header: "Name" }];
698
+ }
699
+ return [
700
+ { key: "label", header: "Name" },
701
+ ...Object.keys(data.data).map((key) => ({
702
+ key,
703
+ header: key
704
+ }))
705
+ ];
706
+ }, [columns, data.data]);
707
+ const getCellValue = (col) => {
708
+ if (col.key === "label") {
709
+ return data.label;
710
+ }
711
+ if (col.key === "id") {
712
+ return data.id;
713
+ }
714
+ if (data.data && col.key in data.data) {
715
+ const value = data.data[col.key];
716
+ if (value === null || value === void 0) return "-";
717
+ return String(value);
718
+ }
719
+ return "-";
720
+ };
721
+ const { ref: _ref, ...rowProps } = innerProps;
722
+ return /* @__PURE__ */ jsx(
723
+ Table.Row,
724
+ {
725
+ ...rowProps,
726
+ _hover: { bg: isFocused ? "bg-muted" : "bg-subtle" },
727
+ cursor: "pointer",
728
+ _even: {
729
+ bg: isSelected ? "primary.subtle" : isFocused ? "bg-muted" : void 0
730
+ },
731
+ children: derivedColumns.map((col) => /* @__PURE__ */ jsx(Table.Cell, { width: col.width, whiteSpace: "nowrap", children: getCellValue(col) }, col.key))
732
+ }
733
+ );
734
+ };
735
+ TableOption.displayName = "TableOption";
736
+ var createTableMenuComponents = (options) => ({
737
+ MenuList: (props) => /* @__PURE__ */ jsx(
738
+ TableMenuList,
739
+ {
740
+ ...props,
741
+ columns: options.columns,
742
+ minWidth: options.minWidth,
743
+ maxWidth: options.maxWidth
744
+ }
745
+ ),
746
+ Option: (props) => /* @__PURE__ */ jsx(TableOption, { ...props, columns: options.columns })
747
+ });
748
+ var Stat = (props) => {
749
+ const { label, value, icon, loading, ...boxProps } = props;
750
+ return /* @__PURE__ */ jsx(
751
+ Box,
752
+ {
753
+ px: { base: "4", md: "6" },
754
+ py: { base: "5", md: "6" },
755
+ bg: "bg-surface",
756
+ borderRadius: "lg",
757
+ boxShadow: "sm",
758
+ ...boxProps,
759
+ children: /* @__PURE__ */ jsxs(Stack, { gap: { base: "5", md: "6" }, children: [
760
+ /* @__PURE__ */ jsx(Stack, { direction: "row", justify: "space-between", children: /* @__PURE__ */ jsxs(HStack, { gap: "4", children: [
761
+ icon && /* @__PURE__ */ jsx(Square, { size: "8", bg: "bg-accent-subtle", borderRadius: "md", children: icon }),
762
+ /* @__PURE__ */ jsx(Text, { fontWeight: "medium", children: label })
763
+ ] }) }),
764
+ /* @__PURE__ */ jsx(Stack, { gap: "4", children: loading ? /* @__PURE__ */ jsx(Spinner, {}) : /* @__PURE__ */ jsx(Heading, { size: { base: "sm", md: "md" }, children: value ?? 0 }) })
765
+ ] })
766
+ }
767
+ );
768
+ };
769
+ Stat.displayName = "Stat";
770
+ var StatusBadge = (props) => {
771
+ const { label, color } = props;
772
+ const textColor = useMemo(() => {
773
+ try {
774
+ return readableColor(color);
775
+ } catch {
776
+ return "black";
777
+ }
778
+ }, [color]);
779
+ return /* @__PURE__ */ jsx(
780
+ Badge,
781
+ {
782
+ bg: color,
783
+ color: textColor,
784
+ rounded: "base",
785
+ px: 2,
786
+ marginInlineStart: 1,
787
+ children: label
788
+ }
789
+ );
790
+ };
791
+ StatusBadge.displayName = "StatusBadge";
792
+ var TextOverflow = memo((props) => {
793
+ const { children, ...rest } = props;
794
+ const textElementRef = useRef(null);
795
+ const [isOverflown, setIsOverflown] = useState(false);
796
+ const compareSize = useCallback(() => {
797
+ const element = textElementRef.current;
798
+ const compare = element ? element.scrollWidth > element.clientWidth || element.offsetWidth < element.scrollWidth || element.offsetHeight < element.scrollHeight : false;
799
+ setIsOverflown(compare);
800
+ }, []);
801
+ useEffect(() => {
802
+ compareSize();
803
+ const element = textElementRef.current;
804
+ if (!element) return;
805
+ const observer = new ResizeObserver(compareSize);
806
+ observer.observe(element);
807
+ return () => {
808
+ observer.disconnect();
809
+ };
810
+ }, [compareSize]);
811
+ return /* @__PURE__ */ jsx(Tooltip, { content: children, disabled: !isOverflown, children: /* @__PURE__ */ jsx(
812
+ Text,
813
+ {
814
+ as: "div",
815
+ position: "relative",
816
+ whiteSpace: isOverflown ? "nowrap" : "normal",
817
+ ...rest,
818
+ ref: textElementRef,
819
+ children
820
+ }
821
+ ) });
822
+ });
823
+ TextOverflow.displayName = "TextOverflow";
824
+ var TypeBadge = ({
825
+ name,
826
+ colorPalette = "gray",
827
+ ...rest
828
+ }) => {
829
+ return /* @__PURE__ */ jsx(
830
+ Badge,
831
+ {
832
+ rounded: "base",
833
+ px: 2,
834
+ marginInlineStart: 1,
835
+ colorPalette,
836
+ ...rest,
837
+ children: name
838
+ }
839
+ );
840
+ };
841
+ TypeBadge.displayName = "TypeBadge";
842
+
843
+ export { Action, BaseSelect, CheckboxCard, CheckboxCardGroup, ClipboardButton, ClipboardInput, ClipboardLink, Collapse, Comment, CommentAction, CommentReplyBox, DataList, DataListItem, DataListItemLabel, DataListItemValue, date_input_default as DateInput, Edit, EmptyState, Filter, Handle, Persona, PersonaAvatar, PersonaContainer, PersonaDetails, PersonaLabel, RelativeDateTime, Remove, Stat, StatusBadge, TableMenuList, TableOption, TextOverflow, TypeBadge, createTableMenuComponents, formatDate, formatDateAndTime, formatMachineReadableDateTime, formatRelativeDateTime, formatRelativeToCurrentWeekDateTime, formatTime, formatWeekdayDate };
844
+ //# sourceMappingURL=index.js.map
845
+ //# sourceMappingURL=index.js.map