@datum-cloud/datum-ui 0.2.0-alpha.3 → 0.2.0-alpha.5
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/README.md +66 -32
- package/dist/alert/index.mjs +3 -0
- package/dist/alert-BC2Mccfo.mjs +95 -0
- package/dist/autocomplete/index.mjs +7 -0
- package/dist/autocomplete-DZtI97HP.mjs +295 -0
- package/dist/avatar-stack/index.mjs +5 -0
- package/dist/avatar-stack-JCfBlPB9.mjs +80 -0
- package/dist/badge/index.mjs +3 -0
- package/dist/badge-bFgeYceE.mjs +185 -0
- package/dist/breadcrumb/index.mjs +4 -0
- package/dist/breadcrumb-BGYJgom_.mjs +71 -0
- package/dist/button/index.mjs +4 -0
- package/dist/button-AzpnV-WB.mjs +49 -0
- package/dist/button-C1wRfGtT.mjs +230 -0
- package/dist/button-group/index.mjs +5 -0
- package/dist/button-group-C1IB2K5s.mjs +40 -0
- package/dist/calendar/index.mjs +5 -0
- package/dist/calendar-DlIHeWb0.mjs +113 -0
- package/dist/card/index.mjs +4 -0
- package/dist/card-3Kd0VdNf.mjs +63 -0
- package/dist/chart/index.mjs +4 -0
- package/dist/chart-BZqUKpkh.mjs +143 -0
- package/dist/checkbox/index.mjs +4 -0
- package/dist/checkbox-LG1OKTpG.mjs +34 -0
- package/dist/col-lrLMZaTJ.mjs +184 -0
- package/dist/collapsible/index.mjs +3 -0
- package/dist/collapsible-Bt9UYfv3.mjs +9 -0
- package/dist/command/index.mjs +5 -0
- package/dist/command-s0Yv3abE.mjs +86 -0
- package/dist/components/features/date-picker/index.d.ts +3 -0
- package/dist/components/features/date-picker/index.d.ts.map +1 -0
- package/dist/components/features/dropzone/index.d.ts +1 -0
- package/dist/components/features/dropzone/index.d.ts.map +1 -1
- package/dist/components/themes/index.d.ts +1 -1
- package/dist/components/themes/index.d.ts.map +1 -1
- package/dist/components/themes/types.d.ts +0 -2
- package/dist/components/themes/types.d.ts.map +1 -1
- package/dist/date-picker/index.mjs +9 -0
- package/dist/dialog/index.mjs +5 -0
- package/dist/dialog-DXBaT9gA.mjs +86 -0
- package/dist/dialog-bnMMf9GD.mjs +73 -0
- package/dist/dropdown/index.mjs +3 -0
- package/dist/dropdown-DtSa_lqc.mjs +112 -0
- package/dist/dropzone/index.mjs +5 -0
- package/dist/dropzone-BkOnwrS4.mjs +221 -0
- package/dist/empty-content/index.mjs +3 -0
- package/dist/empty-content-BM9rzI13.mjs +196 -0
- package/dist/exports/map.d.ts +3 -0
- package/dist/exports/map.d.ts.map +1 -0
- package/dist/fonts/AllianceNo1-Medium.ttf +0 -0
- package/dist/fonts/AllianceNo1-Regular.ttf +0 -0
- package/dist/fonts/AllianceNo1-SemiBold.ttf +0 -0
- package/dist/form/index.mjs +146 -0
- package/dist/grid/index.mjs +3 -0
- package/dist/hooks/index.mjs +2 -3
- package/dist/hover-card/index.mjs +4 -0
- package/dist/hover-card-CUPfFUqE.mjs +33 -0
- package/dist/icon-wrapper-9ticVbRL.mjs +14 -0
- package/dist/icons/index.mjs +3 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +65 -9
- package/dist/input/index.mjs +5 -0
- package/dist/input-DuyjEKEW.mjs +17 -0
- package/dist/input-fzXBheCN.mjs +17 -0
- package/dist/input-group/index.mjs +7 -0
- package/dist/input-group-CPaFSTEV.mjs +80 -0
- package/dist/input-number/index.mjs +6 -0
- package/dist/input-number-9o62JHRl.mjs +106 -0
- package/dist/input-with-addons/index.mjs +3 -0
- package/dist/input-with-addons-BQn7KCTU.mjs +30 -0
- package/dist/label/index.mjs +4 -0
- package/dist/label-_ste_Re3.mjs +44 -0
- package/dist/link-button-TIF2Zdrk.mjs +36 -0
- package/dist/loader-overlay/index.mjs +3 -0
- package/dist/loader-overlay-DUaQSZQP.mjs +17 -0
- package/dist/map/index.mjs +13 -0
- package/dist/map-WL6jhkSM.mjs +1094 -0
- package/dist/more-actions/index.mjs +5 -0
- package/dist/more-actions-Ch1f6Mh3.mjs +54 -0
- package/dist/nprogress/index.mjs +32 -0
- package/dist/page-title/index.mjs +3 -0
- package/dist/page-title-BJuo81rT.mjs +26 -0
- package/dist/popover/index.mjs +4 -0
- package/dist/popover-SQlKSz6L.mjs +36 -0
- package/dist/radio-group/index.mjs +4 -0
- package/dist/radio-group-Oshv0b-U.mjs +49 -0
- package/dist/select/index.mjs +4 -0
- package/dist/select-DVlEzD2W.mjs +166 -0
- package/dist/separator/index.mjs +4 -0
- package/dist/separator-T2ppyD-8.mjs +18 -0
- package/dist/sheet/index.mjs +5 -0
- package/dist/sheet-BKiCwtNO.mjs +45 -0
- package/dist/sheet-CtnP6gTD.mjs +77 -0
- package/dist/sidebar/index.mjs +11 -0
- package/dist/sidebar-DfqezV8t.mjs +945 -0
- package/dist/skeleton/index.mjs +4 -0
- package/dist/skeleton-vzbxA-DQ.mjs +13 -0
- package/dist/spinner/index.mjs +4 -0
- package/dist/spinner-BE7k2bAD.mjs +16 -0
- package/dist/{icon-wrapper-BgPkifId.mjs → spinner.icon-Bg8zgGh0.mjs} +1 -12
- package/dist/stepper/index.mjs +5 -0
- package/dist/stepper-SWB-u_nM.mjs +323 -0
- package/dist/{style.css → styles.css} +317 -575
- package/dist/styles.mjs +1 -0
- package/dist/switch/index.mjs +4 -0
- package/dist/switch-Calk7Gyw.mjs +32 -0
- package/dist/table/index.mjs +4 -0
- package/dist/table-CsXBcQLI.mjs +68 -0
- package/dist/tabs/index.mjs +3 -0
- package/dist/tabs-D8n-dqnw.mjs +52 -0
- package/dist/tag-input/index.mjs +5 -0
- package/dist/tag-input-Di7SDNbK.mjs +284 -0
- package/dist/task-queue/index.mjs +7 -0
- package/dist/task-queue-dropdown-DW72ikDH.mjs +1356 -0
- package/dist/textarea/index.mjs +5 -0
- package/dist/textarea-CxE3YbC7.mjs +17 -0
- package/dist/textarea-QYRcDEpK.mjs +15 -0
- package/dist/theme/index.mjs +3 -0
- package/dist/{theme.provider-DpFLwtHe.mjs → theme.provider-CzCxEFFh.mjs} +63 -1
- package/dist/to-api-format-C2xjQUcI.mjs +1506 -0
- package/dist/toast/index.mjs +3 -0
- package/dist/tooltip/index.mjs +4 -0
- package/dist/tooltip-Dd3ActSS.mjs +74 -0
- package/dist/typography/index.mjs +3 -0
- package/dist/typography-UA7ZZvgJ.mjs +200 -0
- package/dist/use-copy-to-clipboard-ki-WoTml.mjs +31 -0
- package/dist/use-stepper-BaToCYMs.mjs +2017 -0
- package/dist/{use-copy-to-clipboard-BfrpD6G8.mjs → use-toast-mdn_CqRY.mjs} +34 -27
- package/dist/utils/index.mjs +0 -1
- package/dist/utils-Bfgoe-Gm.mjs +20 -0
- package/dist/visually-hidden/index.mjs +3 -0
- package/dist/visuallyhidden-aaTUk4Yo.mjs +7 -0
- package/package.json +223 -24
- package/dist/components/index.mjs +0 -8
- package/dist/datum.provider-D6VMjSV0.mjs +0 -37
- package/dist/providers/datum.provider.d.ts +0 -20
- package/dist/providers/datum.provider.d.ts.map +0 -1
- package/dist/providers/index.d.ts +0 -3
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.mjs +0 -4
- package/dist/theme-script-DHyLk25i.mjs +0 -11128
- /package/dist/{close.icon-chkXPAUC.mjs → close.icon-CMNMoXM_.mjs} +0 -0
- /package/dist/{map-leaflet-imports-OKaoesjZ.mjs → map-leaflet-imports-C4JYls8q.mjs} +0 -0
- /package/dist/{use-debounce-BYB-jPeX.mjs → use-debounce-B6wPrZV8.mjs} +0 -0
package/dist/styles.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { t as cn } from "./cn-DWCc1QRE.mjs";
|
|
2
|
+
import { t as cn$1 } from "./utils-Bfgoe-Gm.mjs";
|
|
3
|
+
import "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import * as SwitchPrimitive from "@radix-ui/react-switch";
|
|
6
|
+
|
|
7
|
+
//#region ../shadcn/ui/switch.tsx
|
|
8
|
+
function Switch$1({ className, ...props }) {
|
|
9
|
+
return /* @__PURE__ */ jsx(SwitchPrimitive.Root, {
|
|
10
|
+
"data-slot": "switch",
|
|
11
|
+
className: cn$1("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50", className),
|
|
12
|
+
...props,
|
|
13
|
+
children: /* @__PURE__ */ jsx(SwitchPrimitive.Thumb, {
|
|
14
|
+
"data-slot": "switch-thumb",
|
|
15
|
+
className: cn$1("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/components/base/switch/switch.tsx
|
|
22
|
+
function Switch({ ref, className, ...props }) {
|
|
23
|
+
return /* @__PURE__ */ jsx(Switch$1, {
|
|
24
|
+
ref,
|
|
25
|
+
className: cn(className),
|
|
26
|
+
...props
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
Switch.displayName = "Switch";
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { Switch as t };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import "../utils-Bfgoe-Gm.mjs";
|
|
2
|
+
import { a as TableFooter, c as TableRow, i as TableCell, n as TableBody, o as TableHead, r as TableCaption, s as TableHeader, t as Table } from "../table-CsXBcQLI.mjs";
|
|
3
|
+
|
|
4
|
+
export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { t as cn } from "./utils-Bfgoe-Gm.mjs";
|
|
2
|
+
import "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region ../shadcn/ui/table.tsx
|
|
6
|
+
const Table = ({ className, ...props }) => {
|
|
7
|
+
return /* @__PURE__ */ jsx("div", {
|
|
8
|
+
"data-slot": "table-container",
|
|
9
|
+
className: "relative w-full overflow-x-auto",
|
|
10
|
+
children: /* @__PURE__ */ jsx("table", {
|
|
11
|
+
"data-slot": "table",
|
|
12
|
+
className: cn("w-full caption-bottom text-sm", className),
|
|
13
|
+
...props
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
const TableHeader = ({ className, ...props }) => {
|
|
18
|
+
return /* @__PURE__ */ jsx("thead", {
|
|
19
|
+
"data-slot": "table-header",
|
|
20
|
+
className: cn("[&_tr]:border-b", className),
|
|
21
|
+
...props
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const TableBody = ({ className, ...props }) => {
|
|
25
|
+
return /* @__PURE__ */ jsx("tbody", {
|
|
26
|
+
"data-slot": "table-body",
|
|
27
|
+
className: cn("[&_tr:last-child]:border-0", className),
|
|
28
|
+
...props
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
const TableFooter = ({ className, ...props }) => {
|
|
32
|
+
return /* @__PURE__ */ jsx("tfoot", {
|
|
33
|
+
"data-slot": "table-footer",
|
|
34
|
+
className: cn("bg-muted/50 border-t font-medium [&>tr]:last:border-b-0", className),
|
|
35
|
+
...props
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
const TableRow = ({ className, ...props }) => {
|
|
39
|
+
return /* @__PURE__ */ jsx("tr", {
|
|
40
|
+
"data-slot": "table-row",
|
|
41
|
+
className: cn("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors", className),
|
|
42
|
+
...props
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
const TableHead = ({ className, ...props }) => {
|
|
46
|
+
return /* @__PURE__ */ jsx("th", {
|
|
47
|
+
"data-slot": "table-head",
|
|
48
|
+
className: cn("text-muted-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className),
|
|
49
|
+
...props
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const TableCell = ({ className, ...props }) => {
|
|
53
|
+
return /* @__PURE__ */ jsx("td", {
|
|
54
|
+
"data-slot": "table-cell",
|
|
55
|
+
className: cn("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className),
|
|
56
|
+
...props
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
const TableCaption = ({ className, ...props }) => {
|
|
60
|
+
return /* @__PURE__ */ jsx("caption", {
|
|
61
|
+
"data-slot": "table-caption",
|
|
62
|
+
className: cn("text-muted-foreground mt-4 text-sm", className),
|
|
63
|
+
...props
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
export { TableFooter as a, TableRow as c, TableCell as i, TableBody as n, TableHead as o, TableCaption as r, TableHeader as s, Table as t };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { t as cn } from "./cn-DWCc1QRE.mjs";
|
|
2
|
+
import "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
5
|
+
|
|
6
|
+
//#region src/components/base/tabs/tabs.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Datum Tabs Component
|
|
9
|
+
* Extends shadcn Tabs with:
|
|
10
|
+
* - TabsLinkTrigger for router-agnostic link integration
|
|
11
|
+
* - Dark mode customizations
|
|
12
|
+
*/
|
|
13
|
+
function Tabs({ className, ...props }) {
|
|
14
|
+
return /* @__PURE__ */ jsx(TabsPrimitive.Root, {
|
|
15
|
+
className: cn("flex flex-col gap-2", className),
|
|
16
|
+
...props
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function TabsList({ className, ...props }) {
|
|
20
|
+
return /* @__PURE__ */ jsx(TabsPrimitive.List, {
|
|
21
|
+
className: cn("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-1", className),
|
|
22
|
+
...props
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function TabsTrigger({ className, ...props }) {
|
|
26
|
+
return /* @__PURE__ */ jsx(TabsPrimitive.Trigger, {
|
|
27
|
+
className: cn("data-[state=active]:bg-background dark:data-[state=active]:text-foreground data-[state=active]:text-foreground dark:hover:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring inline-flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
|
|
28
|
+
...props
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function TabsContent({ className, ...props }) {
|
|
32
|
+
return /* @__PURE__ */ jsx(TabsPrimitive.Content, {
|
|
33
|
+
className: cn("flex-1 outline-none", className),
|
|
34
|
+
...props
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function TabsLinkTrigger({ value, href, linkComponent: LinkComp = "a", children, className, ...props }) {
|
|
38
|
+
const linkProps = LinkComp === "a" ? { href } : { to: href };
|
|
39
|
+
return /* @__PURE__ */ jsx(TabsTrigger, {
|
|
40
|
+
value,
|
|
41
|
+
asChild: true,
|
|
42
|
+
className,
|
|
43
|
+
...props,
|
|
44
|
+
children: /* @__PURE__ */ jsx(LinkComp, {
|
|
45
|
+
...linkProps,
|
|
46
|
+
children
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { TabsTrigger as a, TabsList as i, TabsContent as n, TabsLinkTrigger as r, Tabs as t };
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { t as cn } from "./cn-DWCc1QRE.mjs";
|
|
2
|
+
import { t as Badge } from "./badge-bFgeYceE.mjs";
|
|
3
|
+
import { t as Icon } from "./icon-wrapper-9ticVbRL.mjs";
|
|
4
|
+
import { t as Input } from "./input-fzXBheCN.mjs";
|
|
5
|
+
import { X } from "lucide-react";
|
|
6
|
+
import React from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
|
|
10
|
+
//#region src/components/features/tag-input/tag-input.tsx
|
|
11
|
+
/**
|
|
12
|
+
* Used for identifying split characters when pasting
|
|
13
|
+
* Splits on: newlines, tabs, semicolons, commas, and pipes
|
|
14
|
+
* Does NOT split on dots (.) or slashes (/) to preserve email addresses and URLs
|
|
15
|
+
*/
|
|
16
|
+
const SPLITTER_REGEX = /[\n\t;,|]+/;
|
|
17
|
+
/**
|
|
18
|
+
* Used for trimming leading/trailing whitespace and special characters
|
|
19
|
+
* Preserves alphanumeric characters, dots, @, hyphens, and underscores
|
|
20
|
+
*/
|
|
21
|
+
const FORMATTING_REGEX = /^[\s"'<>]+|[\s"'<>]+$/g;
|
|
22
|
+
const TagInputContext = React.createContext(null);
|
|
23
|
+
function TagsInput({ ref, value, onValueChange, placeholder, maxItems, minItems, className, dir, validator, onValidationError, error, showValidationErrors = true, name, key, ...props }) {
|
|
24
|
+
const [activeIndex, setActiveIndex] = React.useState(-1);
|
|
25
|
+
const [inputValue, setInputValue] = React.useState("");
|
|
26
|
+
const [disableInput, setDisableInput] = React.useState(false);
|
|
27
|
+
const [disableButton, setDisableButton] = React.useState(false);
|
|
28
|
+
const [isValueSelected, setIsValueSelected] = React.useState(false);
|
|
29
|
+
const [selectedValue, setSelectedValue] = React.useState("");
|
|
30
|
+
const [validationError, setValidationError] = React.useState(null);
|
|
31
|
+
const parseMinItems = minItems ?? 0;
|
|
32
|
+
const parseMaxItems = maxItems ?? Infinity;
|
|
33
|
+
const onValueChangeHandler = React.useCallback((val) => {
|
|
34
|
+
const setError = (errorMessage) => {
|
|
35
|
+
setValidationError(errorMessage);
|
|
36
|
+
if (onValidationError) onValidationError(errorMessage);
|
|
37
|
+
};
|
|
38
|
+
setError(null);
|
|
39
|
+
if (!val.trim()) return;
|
|
40
|
+
if (value.includes(val)) {
|
|
41
|
+
setError("This tag already exists");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (value.length >= parseMaxItems) {
|
|
45
|
+
setError(`Maximum of ${parseMaxItems} tags allowed`);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (validator) try {
|
|
49
|
+
validator.parse(val);
|
|
50
|
+
onValueChange([...value, val]);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
if (error instanceof z.ZodError) setError(error.issues[0]?.message || "Invalid input");
|
|
53
|
+
else setError("Validation failed");
|
|
54
|
+
}
|
|
55
|
+
else onValueChange([...value, val]);
|
|
56
|
+
}, [
|
|
57
|
+
value,
|
|
58
|
+
validator,
|
|
59
|
+
parseMaxItems
|
|
60
|
+
]);
|
|
61
|
+
const RemoveValue = React.useCallback((val) => {
|
|
62
|
+
if (value.includes(val) && value.length > parseMinItems) onValueChange(value.filter((item) => item !== val));
|
|
63
|
+
}, [value]);
|
|
64
|
+
const handlePaste = React.useCallback((e) => {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
const pastedText = e.clipboardData.getData("text");
|
|
67
|
+
if (!pastedText) return;
|
|
68
|
+
const values = pastedText.split(SPLITTER_REGEX).map((val) => val.trim()).filter(Boolean).map((val) => val.replace(FORMATTING_REGEX, ""));
|
|
69
|
+
if (values.length === 0) return;
|
|
70
|
+
if (values.length === 1) {
|
|
71
|
+
onValueChangeHandler(values[0]);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const validValues = [];
|
|
75
|
+
let hasError = false;
|
|
76
|
+
for (const val of values) {
|
|
77
|
+
if (value.includes(val) || validValues.includes(val)) continue;
|
|
78
|
+
if (value.length + validValues.length >= parseMaxItems) break;
|
|
79
|
+
if (validator) try {
|
|
80
|
+
validator.parse(val);
|
|
81
|
+
validValues.push(val);
|
|
82
|
+
} catch {
|
|
83
|
+
hasError = true;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
else validValues.push(val);
|
|
87
|
+
}
|
|
88
|
+
if (validValues.length > 0) onValueChange([...value, ...validValues]);
|
|
89
|
+
if (hasError && validator) {
|
|
90
|
+
setValidationError("Some pasted values were invalid and skipped");
|
|
91
|
+
if (onValidationError) onValidationError("Some pasted values were invalid and skipped");
|
|
92
|
+
setTimeout(() => {
|
|
93
|
+
setValidationError(null);
|
|
94
|
+
if (onValidationError) onValidationError(null);
|
|
95
|
+
}, 3e3);
|
|
96
|
+
}
|
|
97
|
+
}, [
|
|
98
|
+
value,
|
|
99
|
+
onValueChangeHandler,
|
|
100
|
+
validator,
|
|
101
|
+
parseMaxItems,
|
|
102
|
+
onValidationError
|
|
103
|
+
]);
|
|
104
|
+
const handleSelect = React.useCallback((e) => {
|
|
105
|
+
const target = e.target;
|
|
106
|
+
const selection = inputValue.substring(target.selectionStart ?? 0, target.selectionEnd ?? 0);
|
|
107
|
+
setSelectedValue(selection);
|
|
108
|
+
setIsValueSelected(selection === inputValue);
|
|
109
|
+
}, [inputValue]);
|
|
110
|
+
React.useEffect(() => {
|
|
111
|
+
const VerifyDisable = () => {
|
|
112
|
+
if (value.length - 1 >= parseMinItems) setDisableButton(false);
|
|
113
|
+
else setDisableButton(true);
|
|
114
|
+
if (value.length + 1 <= parseMaxItems) setDisableInput(false);
|
|
115
|
+
else setDisableInput(true);
|
|
116
|
+
};
|
|
117
|
+
VerifyDisable();
|
|
118
|
+
}, [
|
|
119
|
+
value,
|
|
120
|
+
parseMinItems,
|
|
121
|
+
parseMaxItems
|
|
122
|
+
]);
|
|
123
|
+
const handleKeyDown = React.useCallback(async (e) => {
|
|
124
|
+
e.stopPropagation();
|
|
125
|
+
const moveNext = () => {
|
|
126
|
+
setActiveIndex(activeIndex + 1 > value.length - 1 ? -1 : activeIndex + 1);
|
|
127
|
+
};
|
|
128
|
+
const movePrev = () => {
|
|
129
|
+
setActiveIndex(activeIndex - 1 < 0 ? value.length - 1 : activeIndex - 1);
|
|
130
|
+
};
|
|
131
|
+
const moveCurrent = () => {
|
|
132
|
+
setActiveIndex(activeIndex - 1 <= 0 ? value.length - 1 === 0 ? -1 : 0 : activeIndex - 1);
|
|
133
|
+
};
|
|
134
|
+
const target = e.currentTarget;
|
|
135
|
+
switch (e.key) {
|
|
136
|
+
case "ArrowLeft":
|
|
137
|
+
if (dir === "rtl") {
|
|
138
|
+
if (value.length > 0 && activeIndex !== -1) moveNext();
|
|
139
|
+
} else if (value.length > 0 && target.selectionStart === 0) movePrev();
|
|
140
|
+
break;
|
|
141
|
+
case "ArrowRight":
|
|
142
|
+
if (dir === "rtl") {
|
|
143
|
+
if (value.length > 0 && target.selectionStart === 0) movePrev();
|
|
144
|
+
} else if (value.length > 0 && activeIndex !== -1) moveNext();
|
|
145
|
+
break;
|
|
146
|
+
case "Backspace":
|
|
147
|
+
case "Delete":
|
|
148
|
+
if (value.length > 0) {
|
|
149
|
+
if (activeIndex !== -1 && activeIndex < value.length) {
|
|
150
|
+
RemoveValue(value[activeIndex]);
|
|
151
|
+
moveCurrent();
|
|
152
|
+
} else if (target.selectionStart === 0) {
|
|
153
|
+
if (selectedValue === inputValue || isValueSelected) RemoveValue(value[value.length - 1]);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
break;
|
|
157
|
+
case "Escape":
|
|
158
|
+
setActiveIndex(activeIndex === -1 ? value.length - 1 : -1);
|
|
159
|
+
break;
|
|
160
|
+
case "Enter":
|
|
161
|
+
case ",":
|
|
162
|
+
if (inputValue.trim() !== "") {
|
|
163
|
+
e.preventDefault();
|
|
164
|
+
onValueChangeHandler(inputValue);
|
|
165
|
+
setInputValue("");
|
|
166
|
+
}
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
}, [
|
|
170
|
+
activeIndex,
|
|
171
|
+
value,
|
|
172
|
+
inputValue,
|
|
173
|
+
RemoveValue,
|
|
174
|
+
dir,
|
|
175
|
+
selectedValue,
|
|
176
|
+
isValueSelected,
|
|
177
|
+
onValueChangeHandler
|
|
178
|
+
]);
|
|
179
|
+
const mousePreventDefault = React.useCallback((e) => {
|
|
180
|
+
e.preventDefault();
|
|
181
|
+
e.stopPropagation();
|
|
182
|
+
}, []);
|
|
183
|
+
const handleChange = React.useCallback((e) => {
|
|
184
|
+
setInputValue(e.currentTarget.value);
|
|
185
|
+
}, []);
|
|
186
|
+
const handleBlur = React.useCallback((e) => {
|
|
187
|
+
const relatedTarget = e.relatedTarget;
|
|
188
|
+
if (!(relatedTarget?.tagName === "BUTTON" && (relatedTarget?.getAttribute("type") === "submit" || relatedTarget?.closest("button[type=\"submit\"]"))) && inputValue.trim() !== "") {
|
|
189
|
+
onValueChangeHandler(inputValue);
|
|
190
|
+
setInputValue("");
|
|
191
|
+
}
|
|
192
|
+
}, [inputValue, onValueChangeHandler]);
|
|
193
|
+
return /* @__PURE__ */ jsxs(TagInputContext, {
|
|
194
|
+
value: React.useMemo(() => ({
|
|
195
|
+
value,
|
|
196
|
+
onValueChange,
|
|
197
|
+
inputValue,
|
|
198
|
+
setInputValue,
|
|
199
|
+
activeIndex,
|
|
200
|
+
setActiveIndex,
|
|
201
|
+
validator,
|
|
202
|
+
validationError,
|
|
203
|
+
setValidationError
|
|
204
|
+
}), [
|
|
205
|
+
value,
|
|
206
|
+
onValueChange,
|
|
207
|
+
inputValue,
|
|
208
|
+
activeIndex,
|
|
209
|
+
validator,
|
|
210
|
+
validationError
|
|
211
|
+
]),
|
|
212
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
213
|
+
...props,
|
|
214
|
+
ref,
|
|
215
|
+
dir,
|
|
216
|
+
className: cn("border-input-border bg-input-background/50 text-input-foreground flex min-h-10 flex-wrap items-center gap-1 overflow-hidden rounded-lg border px-3 py-2 transition-all", activeIndex === -1 ? "focus-within:border-input-focus-border focus-within:shadow-(--input-focus-shadow) focus-within:ring-0 focus-within:ring-offset-0 focus-within:outline-hidden" : "focus-within:ring-0 focus-within:ring-offset-0 focus-within:outline-hidden", className),
|
|
217
|
+
suppressHydrationWarning: true,
|
|
218
|
+
children: [
|
|
219
|
+
(showValidationErrors && validationError || error) && /* @__PURE__ */ jsx("div", {
|
|
220
|
+
className: "mb-1 w-full text-sm text-red-500",
|
|
221
|
+
children: error ? Array.isArray(error) ? error[0] : error : validationError
|
|
222
|
+
}),
|
|
223
|
+
value.map((item, index) => /* @__PURE__ */ jsxs(Badge, {
|
|
224
|
+
tabIndex: activeIndex !== -1 ? 0 : activeIndex,
|
|
225
|
+
"aria-disabled": disableButton,
|
|
226
|
+
"data-active": activeIndex === index,
|
|
227
|
+
className: cn("data-[active='true']:ring-muted-foreground relative flex items-center gap-1 truncate rounded px-1 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 data-[active='true']:ring-2"),
|
|
228
|
+
type: "secondary",
|
|
229
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
230
|
+
className: "text-xs",
|
|
231
|
+
children: item
|
|
232
|
+
}), /* @__PURE__ */ jsxs("button", {
|
|
233
|
+
type: "button",
|
|
234
|
+
"aria-label": `Remove ${item} option`,
|
|
235
|
+
"aria-roledescription": "button to remove option",
|
|
236
|
+
disabled: disableButton,
|
|
237
|
+
onMouseDown: mousePreventDefault,
|
|
238
|
+
onClick: () => RemoveValue(item),
|
|
239
|
+
className: "disabled:cursor-not-allowed",
|
|
240
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
241
|
+
className: "sr-only",
|
|
242
|
+
children: [
|
|
243
|
+
"Remove",
|
|
244
|
+
item,
|
|
245
|
+
" ",
|
|
246
|
+
"option"
|
|
247
|
+
]
|
|
248
|
+
}), /* @__PURE__ */ jsx(Icon, {
|
|
249
|
+
icon: X,
|
|
250
|
+
className: "hover:stroke-destructive h-4 w-4"
|
|
251
|
+
})]
|
|
252
|
+
})]
|
|
253
|
+
}, item)),
|
|
254
|
+
/* @__PURE__ */ jsx(Input, {
|
|
255
|
+
tabIndex: 0,
|
|
256
|
+
"aria-label": "input tag",
|
|
257
|
+
disabled: disableInput,
|
|
258
|
+
onKeyDown: handleKeyDown,
|
|
259
|
+
onPaste: handlePaste,
|
|
260
|
+
onBlur: handleBlur,
|
|
261
|
+
value: inputValue,
|
|
262
|
+
onSelect: handleSelect,
|
|
263
|
+
onChange: activeIndex === -1 ? handleChange : void 0,
|
|
264
|
+
placeholder,
|
|
265
|
+
onClick: () => setActiveIndex(-1),
|
|
266
|
+
className: cn("text-input-foreground h-6 min-w-fit flex-1 border-0 bg-transparent p-0 py-1 shadow-none", "placeholder:text-input-placeholder", "focus-visible:border-transparent focus-visible:shadow-none focus-visible:ring-0 focus-visible:ring-offset-0", activeIndex !== -1 && "caret-transparent")
|
|
267
|
+
})
|
|
268
|
+
]
|
|
269
|
+
}), /* @__PURE__ */ jsxs("select", {
|
|
270
|
+
name,
|
|
271
|
+
id: props.id,
|
|
272
|
+
multiple: true,
|
|
273
|
+
value,
|
|
274
|
+
defaultValue: void 0,
|
|
275
|
+
className: "absolute top-0 left-0 h-0 w-0",
|
|
276
|
+
onChange: () => void 0,
|
|
277
|
+
children: [/* @__PURE__ */ jsx("option", { value: "" }), value.map((option, idx) => /* @__PURE__ */ jsx("option", { value: option }, `${option}-${idx}`))]
|
|
278
|
+
}, key)]
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
TagsInput.displayName = "TagsInput";
|
|
282
|
+
|
|
283
|
+
//#endregion
|
|
284
|
+
export { TagsInput as t };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "../utils-Bfgoe-Gm.mjs";
|
|
2
|
+
import "../dialog-DXBaT9gA.mjs";
|
|
3
|
+
import "../table-CsXBcQLI.mjs";
|
|
4
|
+
import "../tooltip-Dd3ActSS.mjs";
|
|
5
|
+
import { _ as RedisTaskStorage, a as TaskPanelItem, b as createProjectMetadata, c as TaskPanelHeader, d as useCurrentScope, f as useTasksWithLabels, g as detectStorage, h as TaskQueue, i as TaskPanel, l as getContextLabel, m as TaskQueueProvider, n as TaskSummaryDialog, o as TaskPanelCounter, p as useTaskQueue, r as TaskQueueTrigger, s as TaskPanelActions, t as TaskQueueDropdown, u as matchesCurrentScope, v as LocalTaskStorage, x as createUserMetadata, y as createOrgMetadata } from "../task-queue-dropdown-DW72ikDH.mjs";
|
|
6
|
+
|
|
7
|
+
export { LocalTaskStorage, RedisTaskStorage, TaskPanel, TaskPanelActions, TaskPanelCounter, TaskPanelHeader, TaskPanelItem, TaskQueue, TaskQueueDropdown, TaskQueueProvider, TaskQueueTrigger, TaskSummaryDialog, createOrgMetadata, createProjectMetadata, createUserMetadata, detectStorage, getContextLabel, matchesCurrentScope, useCurrentScope, useTaskQueue, useTasksWithLabels };
|