@tetrascience-npm/tetrascience-react-ui 1.0.0-beta.144.1 → 1.0.0-beta.145.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.
- package/dist/ai/context.cjs +1 -1
- package/dist/ai/context.cjs.map +1 -1
- package/dist/ai/context.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +381 -373
- package/dist/index.js.map +1 -1
- package/dist/index.tailwind.css +1 -1
- package/dist/ui/progress.cjs +2 -0
- package/dist/ui/progress.cjs.map +1 -0
- package/dist/{components/ui → ui}/progress.js +14 -13
- package/dist/ui/progress.js.map +1 -0
- package/dist/ui/snippet.cjs +2 -0
- package/dist/ui/snippet.cjs.map +1 -0
- package/dist/ui/snippet.js +81 -0
- package/dist/ui/snippet.js.map +1 -0
- package/package.json +1 -1
- package/dist/components/ui/progress.cjs +0 -2
- package/dist/components/ui/progress.cjs.map +0 -1
- package/dist/components/ui/progress.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("radix-ui"),l=require("../lib/utils.cjs");function i({className:t,value:r,...o}){return e.jsx(s.Progress.Root,{"data-slot":"progress",value:r,className:l.cn("bg-primary/20 relative h-2 w-full overflow-hidden rounded-full",t),...o,children:e.jsx(s.Progress.Indicator,{"data-slot":"progress-indicator",className:"bg-primary h-full w-full flex-1 transition-all",style:{transform:`translateX(-${100-(r||0)}%)`}})})}exports.Progress=i;
|
|
2
|
+
//# sourceMappingURL=progress.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.cjs","sources":["../../src/components/ui/progress.tsx"],"sourcesContent":["import { Progress as ProgressPrimitive } from \"radix-ui\"\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nfunction Progress({\n className,\n value,\n ...props\n}: React.ComponentProps<typeof ProgressPrimitive.Root>) {\n return (\n <ProgressPrimitive.Root\n data-slot=\"progress\"\n value={value}\n className={cn(\n \"bg-primary/20 relative h-2 w-full overflow-hidden rounded-full\",\n className\n )}\n {...props}\n >\n <ProgressPrimitive.Indicator\n data-slot=\"progress-indicator\"\n className=\"bg-primary h-full w-full flex-1 transition-all\"\n style={{ transform: `translateX(-${100 - (value || 0)}%)` }}\n />\n </ProgressPrimitive.Root>\n )\n}\n\nexport { Progress }\n"],"names":["Progress","className","value","props","jsx","ProgressPrimitive","cn"],"mappings":"yKAKA,SAASA,EAAS,CAChB,UAAAC,EACA,MAAAC,EACA,GAAGC,CACL,EAAwD,CACtD,OACEC,EAAAA,IAACC,EAAAA,SAAkB,KAAlB,CACC,YAAU,WACV,MAAAH,EACA,UAAWI,EAAAA,GACT,iEACAL,CAAA,EAED,GAAGE,EAEJ,SAAAC,EAAAA,IAACC,EAAAA,SAAkB,UAAlB,CACC,YAAU,qBACV,UAAU,iDACV,MAAO,CAAE,UAAW,eAAe,KAAOH,GAAS,EAAE,IAAA,CAAK,CAAA,CAC5D,CAAA,CAGN"}
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Progress as
|
|
3
|
-
import { cn as a } from "
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { Progress as s } from "radix-ui";
|
|
3
|
+
import { cn as a } from "../lib/utils.js";
|
|
4
4
|
function f({
|
|
5
|
-
className:
|
|
6
|
-
value:
|
|
7
|
-
...
|
|
5
|
+
className: t,
|
|
6
|
+
value: r,
|
|
7
|
+
...l
|
|
8
8
|
}) {
|
|
9
|
-
return /* @__PURE__ */
|
|
10
|
-
|
|
9
|
+
return /* @__PURE__ */ o(
|
|
10
|
+
s.Root,
|
|
11
11
|
{
|
|
12
12
|
"data-slot": "progress",
|
|
13
|
+
value: r,
|
|
13
14
|
className: a(
|
|
14
15
|
"bg-primary/20 relative h-2 w-full overflow-hidden rounded-full",
|
|
15
|
-
|
|
16
|
+
t
|
|
16
17
|
),
|
|
17
|
-
...
|
|
18
|
-
children: /* @__PURE__ */
|
|
19
|
-
|
|
18
|
+
...l,
|
|
19
|
+
children: /* @__PURE__ */ o(
|
|
20
|
+
s.Indicator,
|
|
20
21
|
{
|
|
21
22
|
"data-slot": "progress-indicator",
|
|
22
23
|
className: "bg-primary h-full w-full flex-1 transition-all",
|
|
23
|
-
style: { transform: `translateX(-${100 - (
|
|
24
|
+
style: { transform: `translateX(-${100 - (r || 0)}%)` }
|
|
24
25
|
}
|
|
25
26
|
)
|
|
26
27
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sources":["../../src/components/ui/progress.tsx"],"sourcesContent":["import { Progress as ProgressPrimitive } from \"radix-ui\"\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nfunction Progress({\n className,\n value,\n ...props\n}: React.ComponentProps<typeof ProgressPrimitive.Root>) {\n return (\n <ProgressPrimitive.Root\n data-slot=\"progress\"\n value={value}\n className={cn(\n \"bg-primary/20 relative h-2 w-full overflow-hidden rounded-full\",\n className\n )}\n {...props}\n >\n <ProgressPrimitive.Indicator\n data-slot=\"progress-indicator\"\n className=\"bg-primary h-full w-full flex-1 transition-all\"\n style={{ transform: `translateX(-${100 - (value || 0)}%)` }}\n />\n </ProgressPrimitive.Root>\n )\n}\n\nexport { Progress }\n"],"names":["Progress","className","value","props","jsx","ProgressPrimitive","cn"],"mappings":";;;AAKA,SAASA,EAAS;AAAA,EAChB,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,GAAGC;AACL,GAAwD;AACtD,SACE,gBAAAC;AAAA,IAACC,EAAkB;AAAA,IAAlB;AAAA,MACC,aAAU;AAAA,MACV,OAAAH;AAAA,MACA,WAAWI;AAAA,QACT;AAAA,QACAL;AAAA,MAAA;AAAA,MAED,GAAGE;AAAA,MAEJ,UAAA,gBAAAC;AAAA,QAACC,EAAkB;AAAA,QAAlB;AAAA,UACC,aAAU;AAAA,UACV,WAAU;AAAA,UACV,OAAO,EAAE,WAAW,eAAe,OAAOH,KAAS,EAAE,KAAA;AAAA,QAAK;AAAA,MAAA;AAAA,IAC5D;AAAA,EAAA;AAGN;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),C=require("lucide-react"),n=require("react"),r=require("./input-group.cjs"),p=require("../lib/utils.cjs"),a=n.createContext({code:""}),y=({code:e,className:t,children:i,...s})=>{const u=n.useMemo(()=>({code:e}),[e]);return o.jsx(a.Provider,{value:u,children:o.jsx(r.InputGroup,{className:p.cn("font-mono",t),...s,children:i})})},b=e=>o.jsx(r.InputGroupAddon,{...e}),w=({className:e,...t})=>o.jsx(r.InputGroupText,{className:p.cn("pl-2 font-normal text-muted-foreground",e),...t}),j=({className:e,...t})=>{const{code:i}=n.useContext(a);return o.jsx(r.InputGroupInput,{"aria-label":"Code snippet",className:p.cn("text-foreground",e),readOnly:!0,value:i,...t})},T=({onCopy:e,onError:t,timeout:i=2e3,children:s,className:u,...f})=>{const[c,l]=n.useState(!1),d=n.useRef(0),{code:x}=n.useContext(a),S=n.useCallback(async()=>{if(typeof window>"u"||!navigator?.clipboard?.writeText){t?.(new Error("Clipboard API not available"));return}try{c||(await navigator.clipboard.writeText(x),l(!0),e?.(),d.current=window.setTimeout(()=>l(!1),i))}catch(I){t?.(I)}},[x,e,t,i,c]);n.useEffect(()=>()=>{window.clearTimeout(d.current)},[]);const m=c?C.CheckIcon:C.CopyIcon;return o.jsx(r.InputGroupButton,{"aria-label":"Copy",className:u,onClick:S,size:"icon-sm",title:"Copy",...f,children:s??o.jsx(m,{className:"size-3.5",size:14})})};exports.Snippet=y;exports.SnippetAddon=b;exports.SnippetCopyButton=T;exports.SnippetInput=j;exports.SnippetText=w;
|
|
2
|
+
//# sourceMappingURL=snippet.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippet.cjs","sources":["../../src/components/ui/snippet.tsx"],"sourcesContent":["\"use client\";\n\nimport { CheckIcon, CopyIcon } from \"lucide-react\";\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport type { ComponentProps } from \"react\";\n\nimport {\n InputGroup,\n InputGroupAddon,\n InputGroupButton,\n InputGroupInput,\n InputGroupText,\n} from \"@/components/ui/input-group\";\nimport { cn } from \"@/lib/utils\";\n\n\ninterface SnippetContextType {\n code: string;\n}\n\nconst SnippetContext = createContext<SnippetContextType>({\n code: \"\",\n});\n\nexport type SnippetProps = ComponentProps<typeof InputGroup> & {\n code: string;\n};\n\nexport const Snippet = ({\n code,\n className,\n children,\n ...props\n}: SnippetProps) => {\n const contextValue = useMemo(() => ({ code }), [code]);\n\n return (\n <SnippetContext.Provider value={contextValue}>\n <InputGroup className={cn(\"font-mono\", className)} {...props}>\n {children}\n </InputGroup>\n </SnippetContext.Provider>\n );\n};\n\nexport type SnippetAddonProps = ComponentProps<typeof InputGroupAddon>;\n\nexport const SnippetAddon = (props: SnippetAddonProps) => (\n <InputGroupAddon {...props} />\n);\n\nexport type SnippetTextProps = ComponentProps<typeof InputGroupText>;\n\nexport const SnippetText = ({ className, ...props }: SnippetTextProps) => (\n <InputGroupText\n className={cn(\"pl-2 font-normal text-muted-foreground\", className)}\n {...props}\n />\n);\n\nexport type SnippetInputProps = Omit<\n ComponentProps<typeof InputGroupInput>,\n \"readOnly\" | \"value\"\n>;\n\nexport const SnippetInput = ({ className, ...props }: SnippetInputProps) => {\n const { code } = useContext(SnippetContext);\n\n return (\n <InputGroupInput\n aria-label=\"Code snippet\"\n className={cn(\"text-foreground\", className)}\n readOnly\n value={code}\n {...props}\n />\n );\n};\n\nexport type SnippetCopyButtonProps = ComponentProps<typeof InputGroupButton> & {\n onCopy?: () => void;\n onError?: (error: Error) => void;\n timeout?: number;\n};\n\nexport const SnippetCopyButton = ({\n onCopy,\n onError,\n timeout = 2000,\n children,\n className,\n ...props\n}: SnippetCopyButtonProps) => {\n const [isCopied, setIsCopied] = useState(false);\n const timeoutRef = useRef<number>(0);\n const { code } = useContext(SnippetContext);\n\n const copyToClipboard = useCallback(async () => {\n if (typeof window === \"undefined\" || !navigator?.clipboard?.writeText) {\n onError?.(new Error(\"Clipboard API not available\"));\n return;\n }\n\n try {\n if (!isCopied) {\n await navigator.clipboard.writeText(code);\n setIsCopied(true);\n onCopy?.();\n timeoutRef.current = window.setTimeout(\n () => setIsCopied(false),\n timeout\n );\n }\n } catch (error) {\n onError?.(error as Error);\n }\n }, [code, onCopy, onError, timeout, isCopied]);\n\n useEffect(\n () => () => {\n window.clearTimeout(timeoutRef.current);\n },\n []\n );\n\n const Icon = isCopied ? CheckIcon : CopyIcon;\n\n return (\n <InputGroupButton\n aria-label=\"Copy\"\n className={className}\n onClick={copyToClipboard}\n size=\"icon-sm\"\n title=\"Copy\"\n {...props}\n >\n {children ?? <Icon className=\"size-3.5\" size={14} />}\n </InputGroupButton>\n );\n};\n"],"names":["SnippetContext","createContext","Snippet","code","className","children","props","contextValue","useMemo","jsx","InputGroup","cn","SnippetAddon","InputGroupAddon","SnippetText","InputGroupText","SnippetInput","useContext","InputGroupInput","SnippetCopyButton","onCopy","onError","timeout","isCopied","setIsCopied","useState","timeoutRef","useRef","copyToClipboard","useCallback","error","useEffect","Icon","CheckIcon","CopyIcon","InputGroupButton"],"mappings":"+NA6BMA,EAAiBC,EAAAA,cAAkC,CACvD,KAAM,EACR,CAAC,EAMYC,EAAU,CAAC,CACtB,KAAAC,EACA,UAAAC,EACA,SAAAC,EACA,GAAGC,CACL,IAAoB,CAClB,MAAMC,EAAeC,EAAAA,QAAQ,KAAO,CAAE,KAAAL,IAAS,CAACA,CAAI,CAAC,EAErD,aACGH,EAAe,SAAf,CAAwB,MAAOO,EAC9B,SAAAE,MAACC,EAAAA,WAAA,CAAW,UAAWC,EAAAA,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,UACE,IAAM,IAAM,CACV,OAAO,aAAaL,EAAW,OAAO,CACxC,EACA,CAAA,CAAC,EAGH,MAAMM,EAAOT,EAAWU,EAAAA,UAAYC,EAAAA,SAEpC,OACEzB,EAAAA,IAAC0B,EAAAA,iBAAA,CACC,aAAW,OACX,UAAA/B,EACA,QAASwB,EACT,KAAK,UACL,MAAM,OACL,GAAGtB,EAEH,YAAYG,EAAAA,IAACuB,EAAA,CAAK,UAAU,WAAW,KAAM,EAAA,CAAI,CAAA,CAAA,CAGxD"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { CheckIcon as I, CopyIcon as x } from "lucide-react";
|
|
3
|
+
import { createContext as w, useMemo as b, useState as y, useRef as S, useContext as d, useCallback as T, useEffect as v } from "react";
|
|
4
|
+
import { InputGroup as G, InputGroupAddon as g, InputGroupButton as h, InputGroupInput as N, InputGroupText as k } from "./input-group.js";
|
|
5
|
+
import { cn as c } from "../lib/utils.js";
|
|
6
|
+
const a = w({
|
|
7
|
+
code: ""
|
|
8
|
+
}), M = ({
|
|
9
|
+
code: t,
|
|
10
|
+
className: e,
|
|
11
|
+
children: n,
|
|
12
|
+
...r
|
|
13
|
+
}) => {
|
|
14
|
+
const i = b(() => ({ code: t }), [t]);
|
|
15
|
+
return /* @__PURE__ */ o(a.Provider, { value: i, children: /* @__PURE__ */ o(G, { className: c("font-mono", e), ...r, children: n }) });
|
|
16
|
+
}, O = (t) => /* @__PURE__ */ o(g, { ...t }), V = ({ className: t, ...e }) => /* @__PURE__ */ o(
|
|
17
|
+
k,
|
|
18
|
+
{
|
|
19
|
+
className: c("pl-2 font-normal text-muted-foreground", t),
|
|
20
|
+
...e
|
|
21
|
+
}
|
|
22
|
+
), q = ({ className: t, ...e }) => {
|
|
23
|
+
const { code: n } = d(a);
|
|
24
|
+
return /* @__PURE__ */ o(
|
|
25
|
+
N,
|
|
26
|
+
{
|
|
27
|
+
"aria-label": "Code snippet",
|
|
28
|
+
className: c("text-foreground", t),
|
|
29
|
+
readOnly: !0,
|
|
30
|
+
value: n,
|
|
31
|
+
...e
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}, D = ({
|
|
35
|
+
onCopy: t,
|
|
36
|
+
onError: e,
|
|
37
|
+
timeout: n = 2e3,
|
|
38
|
+
children: r,
|
|
39
|
+
className: i,
|
|
40
|
+
...m
|
|
41
|
+
}) => {
|
|
42
|
+
const [p, s] = y(!1), u = S(0), { code: l } = d(a), f = T(async () => {
|
|
43
|
+
if (typeof window > "u" || !navigator?.clipboard?.writeText) {
|
|
44
|
+
e?.(new Error("Clipboard API not available"));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
p || (await navigator.clipboard.writeText(l), s(!0), t?.(), u.current = window.setTimeout(
|
|
49
|
+
() => s(!1),
|
|
50
|
+
n
|
|
51
|
+
));
|
|
52
|
+
} catch (C) {
|
|
53
|
+
e?.(C);
|
|
54
|
+
}
|
|
55
|
+
}, [l, t, e, n, p]);
|
|
56
|
+
return v(
|
|
57
|
+
() => () => {
|
|
58
|
+
window.clearTimeout(u.current);
|
|
59
|
+
},
|
|
60
|
+
[]
|
|
61
|
+
), /* @__PURE__ */ o(
|
|
62
|
+
h,
|
|
63
|
+
{
|
|
64
|
+
"aria-label": "Copy",
|
|
65
|
+
className: i,
|
|
66
|
+
onClick: f,
|
|
67
|
+
size: "icon-sm",
|
|
68
|
+
title: "Copy",
|
|
69
|
+
...m,
|
|
70
|
+
children: r ?? /* @__PURE__ */ o(p ? I : x, { className: "size-3.5", size: 14 })
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
export {
|
|
75
|
+
M as Snippet,
|
|
76
|
+
O as SnippetAddon,
|
|
77
|
+
D as SnippetCopyButton,
|
|
78
|
+
q as SnippetInput,
|
|
79
|
+
V as SnippetText
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=snippet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippet.js","sources":["../../src/components/ui/snippet.tsx"],"sourcesContent":["\"use client\";\n\nimport { CheckIcon, CopyIcon } from \"lucide-react\";\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport type { ComponentProps } from \"react\";\n\nimport {\n InputGroup,\n InputGroupAddon,\n InputGroupButton,\n InputGroupInput,\n InputGroupText,\n} from \"@/components/ui/input-group\";\nimport { cn } from \"@/lib/utils\";\n\n\ninterface SnippetContextType {\n code: string;\n}\n\nconst SnippetContext = createContext<SnippetContextType>({\n code: \"\",\n});\n\nexport type SnippetProps = ComponentProps<typeof InputGroup> & {\n code: string;\n};\n\nexport const Snippet = ({\n code,\n className,\n children,\n ...props\n}: SnippetProps) => {\n const contextValue = useMemo(() => ({ code }), [code]);\n\n return (\n <SnippetContext.Provider value={contextValue}>\n <InputGroup className={cn(\"font-mono\", className)} {...props}>\n {children}\n </InputGroup>\n </SnippetContext.Provider>\n );\n};\n\nexport type SnippetAddonProps = ComponentProps<typeof InputGroupAddon>;\n\nexport const SnippetAddon = (props: SnippetAddonProps) => (\n <InputGroupAddon {...props} />\n);\n\nexport type SnippetTextProps = ComponentProps<typeof InputGroupText>;\n\nexport const SnippetText = ({ className, ...props }: SnippetTextProps) => (\n <InputGroupText\n className={cn(\"pl-2 font-normal text-muted-foreground\", className)}\n {...props}\n />\n);\n\nexport type SnippetInputProps = Omit<\n ComponentProps<typeof InputGroupInput>,\n \"readOnly\" | \"value\"\n>;\n\nexport const SnippetInput = ({ className, ...props }: SnippetInputProps) => {\n const { code } = useContext(SnippetContext);\n\n return (\n <InputGroupInput\n aria-label=\"Code snippet\"\n className={cn(\"text-foreground\", className)}\n readOnly\n value={code}\n {...props}\n />\n );\n};\n\nexport type SnippetCopyButtonProps = ComponentProps<typeof InputGroupButton> & {\n onCopy?: () => void;\n onError?: (error: Error) => void;\n timeout?: number;\n};\n\nexport const SnippetCopyButton = ({\n onCopy,\n onError,\n timeout = 2000,\n children,\n className,\n ...props\n}: SnippetCopyButtonProps) => {\n const [isCopied, setIsCopied] = useState(false);\n const timeoutRef = useRef<number>(0);\n const { code } = useContext(SnippetContext);\n\n const copyToClipboard = useCallback(async () => {\n if (typeof window === \"undefined\" || !navigator?.clipboard?.writeText) {\n onError?.(new Error(\"Clipboard API not available\"));\n return;\n }\n\n try {\n if (!isCopied) {\n await navigator.clipboard.writeText(code);\n setIsCopied(true);\n onCopy?.();\n timeoutRef.current = window.setTimeout(\n () => setIsCopied(false),\n timeout\n );\n }\n } catch (error) {\n onError?.(error as Error);\n }\n }, [code, onCopy, onError, timeout, isCopied]);\n\n useEffect(\n () => () => {\n window.clearTimeout(timeoutRef.current);\n },\n []\n );\n\n const Icon = isCopied ? CheckIcon : CopyIcon;\n\n return (\n <InputGroupButton\n aria-label=\"Copy\"\n className={className}\n onClick={copyToClipboard}\n size=\"icon-sm\"\n title=\"Copy\"\n {...props}\n >\n {children ?? <Icon className=\"size-3.5\" size={14} />}\n </InputGroupButton>\n );\n};\n"],"names":["SnippetContext","createContext","Snippet","code","className","children","props","contextValue","useMemo","jsx","InputGroup","cn","SnippetAddon","InputGroupAddon","SnippetText","InputGroupText","SnippetInput","useContext","InputGroupInput","SnippetCopyButton","onCopy","onError","timeout","isCopied","setIsCopied","useState","timeoutRef","useRef","copyToClipboard","useCallback","error","useEffect","InputGroupButton","CheckIcon","CopyIcon"],"mappings":";;;;;AA6BA,MAAMA,IAAiBC,EAAkC;AAAA,EACvD,MAAM;AACR,CAAC,GAMYC,IAAU,CAAC;AAAA,EACtB,MAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,MAAoB;AAClB,QAAMC,IAAeC,EAAQ,OAAO,EAAE,MAAAL,MAAS,CAACA,CAAI,CAAC;AAErD,2BACGH,EAAe,UAAf,EAAwB,OAAOO,GAC9B,UAAA,gBAAAE,EA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,SAASQ,GAAO;AACd,MAAAT,IAAUS,CAAc;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC3B,GAAMiB,GAAQC,GAASC,GAASC,CAAQ,CAAC;AAE7C,SAAAQ;AAAA,IACE,MAAM,MAAM;AACV,aAAO,aAAaL,EAAW,OAAO;AAAA,IACxC;AAAA,IACA,CAAA;AAAA,EAAC,GAMD,gBAAAjB;AAAA,IAACuB;AAAA,IAAA;AAAA,MACC,cAAW;AAAA,MACX,WAAA5B;AAAA,MACA,SAASwB;AAAA,MACT,MAAK;AAAA,MACL,OAAM;AAAA,MACL,GAAGtB;AAAA,MAEH,eAAY,gBAAAG,EAXJc,IAAWU,IAAYC,GAWlB,EAAK,WAAU,YAAW,MAAM,GAAA,CAAI;AAAA,IAAA;AAAA,EAAA;AAGxD;"}
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),e=require("radix-ui"),l=require("../../lib/utils.cjs");function a({className:s,value:t,...o}){return r.jsx(e.Progress.Root,{"data-slot":"progress",className:l.cn("bg-primary/20 relative h-2 w-full overflow-hidden rounded-full",s),...o,children:r.jsx(e.Progress.Indicator,{"data-slot":"progress-indicator",className:"bg-primary h-full w-full flex-1 transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})})}exports.Progress=a;
|
|
2
|
-
//# sourceMappingURL=progress.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"progress.cjs","sources":["../../../src/components/ui/progress.tsx"],"sourcesContent":["import { Progress as ProgressPrimitive } from \"radix-ui\"\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nfunction Progress({\n className,\n value,\n ...props\n}: React.ComponentProps<typeof ProgressPrimitive.Root>) {\n return (\n <ProgressPrimitive.Root\n data-slot=\"progress\"\n className={cn(\n \"bg-primary/20 relative h-2 w-full overflow-hidden rounded-full\",\n className\n )}\n {...props}\n >\n <ProgressPrimitive.Indicator\n data-slot=\"progress-indicator\"\n className=\"bg-primary h-full w-full flex-1 transition-all\"\n style={{ transform: `translateX(-${100 - (value || 0)}%)` }}\n />\n </ProgressPrimitive.Root>\n )\n}\n\nexport { Progress }\n"],"names":["Progress","className","value","props","jsx","ProgressPrimitive","cn"],"mappings":"4KAKA,SAASA,EAAS,CAChB,UAAAC,EACA,MAAAC,EACA,GAAGC,CACL,EAAwD,CACtD,OACEC,EAAAA,IAACC,EAAAA,SAAkB,KAAlB,CACC,YAAU,WACV,UAAWC,EAAAA,GACT,iEACAL,CAAA,EAED,GAAGE,EAEJ,SAAAC,EAAAA,IAACC,EAAAA,SAAkB,UAAlB,CACC,YAAU,qBACV,UAAU,iDACV,MAAO,CAAE,UAAW,eAAe,KAAOH,GAAS,EAAE,IAAA,CAAK,CAAA,CAC5D,CAAA,CAGN"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"progress.js","sources":["../../../src/components/ui/progress.tsx"],"sourcesContent":["import { Progress as ProgressPrimitive } from \"radix-ui\"\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nfunction Progress({\n className,\n value,\n ...props\n}: React.ComponentProps<typeof ProgressPrimitive.Root>) {\n return (\n <ProgressPrimitive.Root\n data-slot=\"progress\"\n className={cn(\n \"bg-primary/20 relative h-2 w-full overflow-hidden rounded-full\",\n className\n )}\n {...props}\n >\n <ProgressPrimitive.Indicator\n data-slot=\"progress-indicator\"\n className=\"bg-primary h-full w-full flex-1 transition-all\"\n style={{ transform: `translateX(-${100 - (value || 0)}%)` }}\n />\n </ProgressPrimitive.Root>\n )\n}\n\nexport { Progress }\n"],"names":["Progress","className","value","props","jsx","ProgressPrimitive","cn"],"mappings":";;;AAKA,SAASA,EAAS;AAAA,EAChB,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,GAAGC;AACL,GAAwD;AACtD,SACE,gBAAAC;AAAA,IAACC,EAAkB;AAAA,IAAlB;AAAA,MACC,aAAU;AAAA,MACV,WAAWC;AAAA,QACT;AAAA,QACAL;AAAA,MAAA;AAAA,MAED,GAAGE;AAAA,MAEJ,UAAA,gBAAAC;AAAA,QAACC,EAAkB;AAAA,QAAlB;AAAA,UACC,aAAU;AAAA,UACV,WAAU;AAAA,UACV,OAAO,EAAE,WAAW,eAAe,OAAOH,KAAS,EAAE,KAAA;AAAA,QAAK;AAAA,MAAA;AAAA,IAC5D;AAAA,EAAA;AAGN;"}
|