@bzync/rui 0.0.4 → 0.0.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 +5 -0
- package/dist/components/aspect-ratio.cjs +1 -0
- package/dist/components/aspect-ratio.d.ts +5 -0
- package/dist/components/aspect-ratio.js +20 -0
- package/dist/components/avatar-group.cjs +1 -0
- package/dist/components/avatar-group.d.ts +14 -0
- package/dist/components/avatar-group.js +35 -0
- package/dist/components/blockquote.cjs +1 -0
- package/dist/components/blockquote.d.ts +10 -0
- package/dist/components/blockquote.js +32 -0
- package/dist/components/button-group.cjs +1 -0
- package/dist/components/button-group.d.ts +7 -0
- package/dist/components/button-group.js +26 -0
- package/dist/components/code.cjs +1 -1
- package/dist/components/code.d.ts +4 -4
- package/dist/components/code.js +59 -57
- package/dist/components/copy-button.cjs +1 -1
- package/dist/components/copy-button.js +3 -3
- package/dist/components/currency.cjs +1 -0
- package/dist/components/currency.d.ts +18 -0
- package/dist/components/currency.js +62 -0
- package/dist/components/description-list.cjs +1 -0
- package/dist/components/description-list.d.ts +14 -0
- package/dist/components/description-list.js +38 -0
- package/dist/components/divider.cjs +1 -0
- package/dist/components/divider.d.ts +12 -0
- package/dist/components/divider.js +45 -0
- package/dist/components/rating.cjs +1 -0
- package/dist/components/rating.d.ts +15 -0
- package/dist/components/rating.js +75 -0
- package/dist/components/scroll-area.cjs +1 -0
- package/dist/components/scroll-area.d.ts +8 -0
- package/dist/components/scroll-area.js +19 -0
- package/dist/components/time-picker.cjs +1 -0
- package/dist/components/time-picker.d.ts +29 -0
- package/dist/components/time-picker.js +336 -0
- package/dist/components/toggle.cjs +1 -0
- package/dist/components/toggle.d.ts +42 -0
- package/dist/components/toggle.js +116 -0
- package/dist/components/typography.cjs +1 -0
- package/dist/components/typography.d.ts +51 -0
- package/dist/components/typography.js +189 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.js +102 -90
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -72,6 +72,11 @@ The component documentation and live demos are published to
|
|
|
72
72
|
the latest documentation through GitHub Pages; maintainers can also run the
|
|
73
73
|
**Deploy documentation** workflow manually from the Actions tab.
|
|
74
74
|
|
|
75
|
+
## Support
|
|
76
|
+
|
|
77
|
+
If `@bzync/rui` is useful to you, you can support its continued development on
|
|
78
|
+
[Buy Me a Coffee](https://buymeacoffee.com/adminjw).
|
|
79
|
+
|
|
75
80
|
## Releasing to npm
|
|
76
81
|
|
|
77
82
|
Add an npm publishing token to the GitHub repository as an Actions secret named
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../cn-BdjraxxU.cjs");let t=require("react"),n=require("react/jsx-runtime");var r=(0,t.forwardRef)(({ratio:t=16/9,className:r,style:i,...a},o)=>{let s=Number.isFinite(t)&&t>0?t:16/9,c={aspectRatio:s,...i};return(0,n.jsx)(`div`,{ref:o,"data-ratio":s,className:e.t(`relative w-full overflow-hidden`,r),style:c,...a})});r.displayName=`AspectRatio`,exports.AspectRatio=r;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
export interface AspectRatioProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
ratio?: number;
|
|
4
|
+
}
|
|
5
|
+
export declare const AspectRatio: import('react').ForwardRefExoticComponent<AspectRatioProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { t as e } from "../cn-DpgY2leY.js";
|
|
2
|
+
import { forwardRef as t } from "react";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/aspect-ratio.tsx
|
|
5
|
+
var r = t(({ ratio: t = 16 / 9, className: r, style: i, ...a }, o) => {
|
|
6
|
+
let s = Number.isFinite(t) && t > 0 ? t : 16 / 9, c = {
|
|
7
|
+
aspectRatio: s,
|
|
8
|
+
...i
|
|
9
|
+
};
|
|
10
|
+
return /* @__PURE__ */ n("div", {
|
|
11
|
+
ref: o,
|
|
12
|
+
"data-ratio": s,
|
|
13
|
+
className: e("relative w-full overflow-hidden", r),
|
|
14
|
+
style: c,
|
|
15
|
+
...a
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
r.displayName = "AspectRatio";
|
|
19
|
+
//#endregion
|
|
20
|
+
export { r as AspectRatio };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../cn-BdjraxxU.cjs");let t=require("react"),n=require("react/jsx-runtime");var r={tight:`-space-x-3`,normal:`-space-x-2`,loose:`-space-x-1`},i={xs:`size-6 text-[9px]`,sm:`size-8 text-[10px]`,md:`size-9 text-xs`,lg:`size-11 text-xs`,xl:`size-14 text-sm`},a=(0,t.forwardRef)(({spacing:t=`normal`,className:i,children:a,...o},s)=>(0,n.jsx)(`div`,{ref:s,role:`group`,className:e.t(`flex w-fit max-w-full items-center justify-start overflow-x-auto overscroll-x-contain px-0.5 py-0.5 scrollbar-none [&>*]:shrink-0 [&>*]:ring-2 [&>*]:ring-surface`,r[t],i),...o,children:a}));a.displayName=`AvatarGroup`;var o=(0,t.forwardRef)(({count:t,size:r=`md`,label:a,className:o,...s},c)=>{let l=Number.isFinite(t)?Math.max(0,Math.floor(t)):0,u=a??`${l} more people`;return(0,n.jsxs)(`span`,{ref:c,"aria-label":u,className:e.t(`inline-flex shrink-0 items-center justify-center rounded-full bg-surface-muted font-semibold text-muted-foreground`,i[r],o),...s,children:[`+`,l]})});o.displayName=`AvatarGroupOverflow`,exports.AvatarGroup=a,exports.AvatarGroupOverflow=o;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type AvatarGroupSpacing = "tight" | "normal" | "loose";
|
|
3
|
+
export type AvatarGroupOverflowSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
4
|
+
export interface AvatarGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
spacing?: AvatarGroupSpacing;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const AvatarGroup: import('react').ForwardRefExoticComponent<AvatarGroupProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
9
|
+
export interface AvatarGroupOverflowProps extends HTMLAttributes<HTMLSpanElement> {
|
|
10
|
+
count: number;
|
|
11
|
+
size?: AvatarGroupOverflowSize;
|
|
12
|
+
label?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const AvatarGroupOverflow: import('react').ForwardRefExoticComponent<AvatarGroupOverflowProps & import('react').RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { t as e } from "../cn-DpgY2leY.js";
|
|
2
|
+
import { forwardRef as t } from "react";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/avatar-group.tsx
|
|
5
|
+
var i = {
|
|
6
|
+
tight: "-space-x-3",
|
|
7
|
+
normal: "-space-x-2",
|
|
8
|
+
loose: "-space-x-1"
|
|
9
|
+
}, a = {
|
|
10
|
+
xs: "size-6 text-[9px]",
|
|
11
|
+
sm: "size-8 text-[10px]",
|
|
12
|
+
md: "size-9 text-xs",
|
|
13
|
+
lg: "size-11 text-xs",
|
|
14
|
+
xl: "size-14 text-sm"
|
|
15
|
+
}, o = t(({ spacing: t = "normal", className: r, children: a, ...o }, s) => /* @__PURE__ */ n("div", {
|
|
16
|
+
ref: s,
|
|
17
|
+
role: "group",
|
|
18
|
+
className: e("flex w-fit max-w-full items-center justify-start overflow-x-auto overscroll-x-contain px-0.5 py-0.5 scrollbar-none [&>*]:shrink-0 [&>*]:ring-2 [&>*]:ring-surface", i[t], r),
|
|
19
|
+
...o,
|
|
20
|
+
children: a
|
|
21
|
+
}));
|
|
22
|
+
o.displayName = "AvatarGroup";
|
|
23
|
+
var s = t(({ count: t, size: n = "md", label: i, className: o, ...s }, c) => {
|
|
24
|
+
let l = Number.isFinite(t) ? Math.max(0, Math.floor(t)) : 0, u = i ?? `${l} more people`;
|
|
25
|
+
return /* @__PURE__ */ r("span", {
|
|
26
|
+
ref: c,
|
|
27
|
+
"aria-label": u,
|
|
28
|
+
className: e("inline-flex shrink-0 items-center justify-center rounded-full bg-surface-muted font-semibold text-muted-foreground", a[n], o),
|
|
29
|
+
...s,
|
|
30
|
+
children: ["+", l]
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
s.displayName = "AvatarGroupOverflow";
|
|
34
|
+
//#endregion
|
|
35
|
+
export { o as AvatarGroup, s as AvatarGroupOverflow };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../cn-BdjraxxU.cjs");require("../component-styles-DOUctc8_.cjs");let t=require("react"),n=require("react/jsx-runtime");var r={default:`border-l-border-strong bg-transparent`,accent:`border-l-accent-500 bg-accent-50/60 dark:bg-accent-900/15`,subtle:`border-l-border bg-surface-muted`},i={sm:`px-4 py-3 text-sm leading-6`,md:`px-5 py-4 text-base leading-7`,lg:`px-6 py-5 text-lg leading-8`},a=(0,t.forwardRef)(({variant:t=`default`,size:a=`md`,source:o,sourceHref:s,className:c,children:l,...u},d)=>(0,n.jsxs)(`blockquote`,{ref:d,className:e.t(`min-w-0 break-words rounded-r-[var(--radius-lg)] border-l-4 text-foreground`,r[t],i[a],c),...u,children:[(0,n.jsx)(`div`,{children:l}),o&&(0,n.jsxs)(`footer`,{className:`mt-2 text-xs font-medium text-muted-foreground`,children:[(0,n.jsx)(`span`,{"aria-hidden":`true`,children:`— `}),s?(0,n.jsx)(`a`,{href:s,className:e.t(`rounded-sm underline decoration-border-strong underline-offset-4 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/35 focus-visible:ring-offset-2 focus-visible:ring-offset-bg`),children:o}):o]})]}));a.displayName=`Blockquote`,exports.Blockquote=a;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BlockquoteHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type BlockquoteVariant = "default" | "accent" | "subtle";
|
|
3
|
+
export type BlockquoteSize = "sm" | "md" | "lg";
|
|
4
|
+
export interface BlockquoteProps extends BlockquoteHTMLAttributes<HTMLQuoteElement> {
|
|
5
|
+
variant?: BlockquoteVariant;
|
|
6
|
+
size?: BlockquoteSize;
|
|
7
|
+
source?: ReactNode;
|
|
8
|
+
sourceHref?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const Blockquote: import('react').ForwardRefExoticComponent<BlockquoteProps & import('react').RefAttributes<HTMLQuoteElement>>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { t as e } from "../cn-DpgY2leY.js";
|
|
2
|
+
import "../component-styles-Bgy44fc8.js";
|
|
3
|
+
import { forwardRef as t } from "react";
|
|
4
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/blockquote.tsx
|
|
6
|
+
var i = {
|
|
7
|
+
default: "border-l-border-strong bg-transparent",
|
|
8
|
+
accent: "border-l-accent-500 bg-accent-50/60 dark:bg-accent-900/15",
|
|
9
|
+
subtle: "border-l-border bg-surface-muted"
|
|
10
|
+
}, a = {
|
|
11
|
+
sm: "px-4 py-3 text-sm leading-6",
|
|
12
|
+
md: "px-5 py-4 text-base leading-7",
|
|
13
|
+
lg: "px-6 py-5 text-lg leading-8"
|
|
14
|
+
}, o = t(({ variant: t = "default", size: o = "md", source: s, sourceHref: c, className: l, children: u, ...d }, f) => /* @__PURE__ */ r("blockquote", {
|
|
15
|
+
ref: f,
|
|
16
|
+
className: e("min-w-0 break-words rounded-r-[var(--radius-lg)] border-l-4 text-foreground", i[t], a[o], l),
|
|
17
|
+
...d,
|
|
18
|
+
children: [/* @__PURE__ */ n("div", { children: u }), s && /* @__PURE__ */ r("footer", {
|
|
19
|
+
className: "mt-2 text-xs font-medium text-muted-foreground",
|
|
20
|
+
children: [/* @__PURE__ */ n("span", {
|
|
21
|
+
"aria-hidden": "true",
|
|
22
|
+
children: "— "
|
|
23
|
+
}), c ? /* @__PURE__ */ n("a", {
|
|
24
|
+
href: c,
|
|
25
|
+
className: e("rounded-sm underline decoration-border-strong underline-offset-4 hover:text-foreground", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/35 focus-visible:ring-offset-2 focus-visible:ring-offset-bg"),
|
|
26
|
+
children: s
|
|
27
|
+
}) : s]
|
|
28
|
+
})]
|
|
29
|
+
}));
|
|
30
|
+
o.displayName = "Blockquote";
|
|
31
|
+
//#endregion
|
|
32
|
+
export { o as Blockquote };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../cn-BdjraxxU.cjs");let t=require("react"),n=require("react/jsx-runtime");var r={horizontal:[`max-w-full flex-row items-center overflow-x-auto overscroll-x-contain p-0.5 scrollbar-none [&>*]:shrink-0`,`[&>*:not(:first-child)]:-ml-px [&>*:not(:first-child)]:rounded-l-none`,`[&>*:not(:last-child)]:rounded-r-none`].join(` `),vertical:[`flex-col items-stretch`,`[&>*:not(:first-child)]:-mt-px [&>*:not(:first-child)]:rounded-t-none`,`[&>*:not(:last-child)]:rounded-b-none`].join(` `)},i=(0,t.forwardRef)(({orientation:t=`horizontal`,className:i,children:a,...o},s)=>(0,n.jsx)(`div`,{ref:s,role:`group`,"data-orientation":t,className:e.t(`inline-flex w-fit [&>*:focus-visible]:relative [&>*:focus-visible]:z-10`,r[t],i),...o,children:a}));i.displayName=`ButtonGroup`,exports.ButtonGroup=i;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type ButtonGroupOrientation = "horizontal" | "vertical";
|
|
3
|
+
export interface ButtonGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
orientation?: ButtonGroupOrientation;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const ButtonGroup: import('react').ForwardRefExoticComponent<ButtonGroupProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { t as e } from "../cn-DpgY2leY.js";
|
|
2
|
+
import { forwardRef as t } from "react";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/button-group.tsx
|
|
5
|
+
var r = {
|
|
6
|
+
horizontal: [
|
|
7
|
+
"max-w-full flex-row items-center overflow-x-auto overscroll-x-contain p-0.5 scrollbar-none [&>*]:shrink-0",
|
|
8
|
+
"[&>*:not(:first-child)]:-ml-px [&>*:not(:first-child)]:rounded-l-none",
|
|
9
|
+
"[&>*:not(:last-child)]:rounded-r-none"
|
|
10
|
+
].join(" "),
|
|
11
|
+
vertical: [
|
|
12
|
+
"flex-col items-stretch",
|
|
13
|
+
"[&>*:not(:first-child)]:-mt-px [&>*:not(:first-child)]:rounded-t-none",
|
|
14
|
+
"[&>*:not(:last-child)]:rounded-b-none"
|
|
15
|
+
].join(" ")
|
|
16
|
+
}, i = t(({ orientation: t = "horizontal", className: i, children: a, ...o }, s) => /* @__PURE__ */ n("div", {
|
|
17
|
+
ref: s,
|
|
18
|
+
role: "group",
|
|
19
|
+
"data-orientation": t,
|
|
20
|
+
className: e("inline-flex w-fit [&>*:focus-visible]:relative [&>*:focus-visible]:z-10", r[t], i),
|
|
21
|
+
...o,
|
|
22
|
+
children: a
|
|
23
|
+
}));
|
|
24
|
+
i.displayName = "ButtonGroup";
|
|
25
|
+
//#endregion
|
|
26
|
+
export { i as ButtonGroup };
|
package/dist/components/code.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../cn-BdjraxxU.cjs");let t=require("react"),n=require("react/jsx-runtime");var r={js:`const.let.var.function.return.if.else.for.while.class.import.export.default.from.async.await.new.typeof.instanceof.true.false.null.undefined.throw.try.catch.finally.switch.case.break.continue.extends.super.this.of.in.delete.void`.split(`.`),python:`def.return.if.else.elif.for.while.class.import.from.as.with.try.except.finally.raise.pass.break.continue.and.or.not.in.is.True.False.None.lambda.yield.global.nonlocal.del.print.async.await`.split(`.`),bash:[`if`,`then`,`else`,`elif`,`fi`,`for`,`do`,`done`,`while`,`case`,`esac`,`in`,`function`,`return`,`exit`,`echo`,`export`,`source`,`local`,`readonly`],sql:`SELECT.FROM.WHERE.AND.OR.NOT.INSERT.INTO.VALUES.UPDATE.SET.DELETE.CREATE.TABLE.DROP.ALTER.INDEX.JOIN.INNER.LEFT.RIGHT.ON.GROUP.BY.ORDER.HAVING.LIMIT.OFFSET.AS.DISTINCT.COUNT.SUM.AVG.MAX.MIN.NULL.IS.IN.LIKE.BETWEEN.EXISTS`.split(`.`)};r.ts=r.js,r.tsx=r.js,r.jsx=r.js,r.json=[];function i(e,t){let n=new Set(r[t.toLowerCase()]??r.js),i=[],a=0;for(;a<e.length;){if(t===`bash`&&e[a]===`#`||e.slice(a,a+2)===`//`&&t!==`bash`){let t=e.indexOf(`
|
|
2
2
|
`,a),n=t===-1?e.slice(a):e.slice(a,t);i.push({type:`comment`,value:n}),a+=n.length;continue}if(e.slice(a,a+2)===`/*`){let t=e.indexOf(`*/`,a+2),n=t===-1?e.slice(a):e.slice(a,t+2);i.push({type:`comment`,value:n}),a+=n.length;continue}if(e[a]===`#`&&(t===`python`||t===`sql`)){let t=e.indexOf(`
|
|
3
3
|
`,a),n=t===-1?e.slice(a):e.slice(a,t);i.push({type:`comment`,value:n}),a+=n.length;continue}if(e[a]===`"`||e[a]===`'`||e[a]==="`"){let t=e[a],n=a+1;for(;n<e.length;){if(e[n]===`\\`&&n+1<e.length){n+=2;continue}if(e[n]===t){n++;break}n++}i.push({type:`string`,value:e.slice(a,n)}),a=n;continue}if(/[0-9]/.test(e[a])||e[a]===`.`&&/[0-9]/.test(e[a+1]??``)){let t=a;for(;t<e.length&&/[0-9._xXa-fA-F]/.test(e[t]);)t++;i.push({type:`number`,value:e.slice(a,t)}),a=t;continue}if(/[a-zA-Z_$]/.test(e[a])){let t=a;for(;t<e.length&&/[a-zA-Z0-9_$]/.test(e[t]);)t++;let r=e.slice(a,t);i.push({type:n.has(r)?`keyword`:`plain`,value:r}),a=t;continue}if(/[=<>!&|+\-*/%^~?:,;.()[\]{}]/.test(e[a])){i.push({type:`operator`,value:e[a]}),a++;continue}i.push({type:`plain`,value:e[a]}),a++}return i}var a={keyword:`text-violet-500 dark:text-violet-400`,string:`text-emerald-600 dark:text-emerald-400`,comment:`text-slate-400 dark:text-slate-500 italic`,number:`text-amber-600 dark:text-amber-400`,operator:`text-slate-500 dark:text-slate-400`,builtin:`text-sky-500 dark:text-sky-400`,plain:`text-slate-800 dark:text-slate-200`};function o({code:r,language:o=`js`,filename:s,showLineNumbers:c=!1,className:l}){let[u,d]=(0,t.useState)(!1),f=r.replace(/^\n/,``).replace(/\n$/,``),p=f.split(`
|
|
4
|
-
`);async function m(){let e=!1;try{if(!navigator.clipboard?.writeText)throw Error(`Clipboard API unavailable`);await navigator.clipboard.writeText(f),e=!0}catch{let t=document.createElement(`textarea`);t.value=f,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),e=document.execCommand(`copy`),t.remove()}e&&(d(!0),window.setTimeout(()=>d(!1),1500))}return(0,n.jsxs)(`div`,{className:e.t(`group relative rounded-xl overflow-hidden border border-black/10 dark:border-white/10 bg-slate-50 dark:bg-[#0d1117]`,l),children:[(0,n.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2.5 border-b border-black/[0.07] dark:border-white/[0.07] bg-black/3 dark:bg-white/3`,children:[(0,n.jsx)(`div`,{className:`flex items-center gap-2`,children:s&&(0,n.jsx)(`span`,{className:`text-xs font-mono text-slate-500 dark:text-slate-400`,children:s})}),(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!s&&(0,n.jsx)(`span`,{className:`text-xs font-mono text-slate-400 dark:text-slate-500 uppercase`,children:o}),(0,n.jsx)(`button`,{type:`button`,onClick:m,"aria-label":u?`Copied code`:`Copy code`,className:`h-6 px-2 flex items-center gap-1 rounded text-xs text-slate-500 dark:text-slate-400 hover:text-gray-900 dark:hover:text-white hover:bg-black/6 dark:hover:bg-white/8 transition-colors`,children:u?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,n.jsx)(`path`,{d:`M20 6 9 17l-5-5`})}),`Copied`]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`}),(0,n.jsx)(`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`})]}),`Copy`]})})]})]}),(0,n.jsx)(`div`,{className:`overflow-x-auto`,children:(0,n.jsx)(`table`,{className:`w-full border-collapse text-sm font-mono leading-6`,children:(0,n.jsx)(`tbody`,{children:p.map((e,t)=>(0,n.jsxs)(`tr`,{className:`hover:bg-black/3 dark:hover:bg-white/3`,children:[c&&(0,n.jsx)(`td`,{className:`select-none w-10 pr-4 pl-4 text-right text-slate-400 dark:text-slate-600 border-r border-black/6 dark:border-white/6`,children:t+1}),(0,n.jsx)(`td`,{className:`px-4 py-0 whitespace-pre`,children:i(e,o).map((e,t)=>(0,n.jsx)(`span`,{className:a[e.type],children:e.value},t))})]},t))})})})]})}
|
|
4
|
+
`);async function m(){let e=!1;try{if(!navigator.clipboard?.writeText)throw Error(`Clipboard API unavailable`);await navigator.clipboard.writeText(f),e=!0}catch{let t=document.createElement(`textarea`);t.value=f,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),e=document.execCommand(`copy`),t.remove()}e&&(d(!0),window.setTimeout(()=>d(!1),1500))}return(0,n.jsxs)(`div`,{className:e.t(`group relative rounded-xl overflow-hidden border border-black/10 dark:border-white/10 bg-slate-50 dark:bg-[#0d1117]`,l),children:[(0,n.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2.5 border-b border-black/[0.07] dark:border-white/[0.07] bg-black/3 dark:bg-white/3`,children:[(0,n.jsx)(`div`,{className:`flex items-center gap-2`,children:s&&(0,n.jsx)(`span`,{className:`text-xs font-mono text-slate-500 dark:text-slate-400`,children:s})}),(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!s&&(0,n.jsx)(`span`,{className:`text-xs font-mono text-slate-400 dark:text-slate-500 uppercase`,children:o}),(0,n.jsx)(`button`,{type:`button`,onClick:m,"aria-label":u?`Copied code`:`Copy code`,className:`h-6 shrink-0 px-2 flex items-center gap-1 whitespace-nowrap rounded text-xs text-slate-500 dark:text-slate-400 hover:text-gray-900 dark:hover:text-white hover:bg-black/6 dark:hover:bg-white/8 transition-colors`,children:u?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`svg`,{className:`shrink-0`,width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,n.jsx)(`path`,{d:`M20 6 9 17l-5-5`})}),`Copied`]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`svg`,{className:`shrink-0`,width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`}),(0,n.jsx)(`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`})]}),`Copy`]})})]})]}),(0,n.jsx)(`div`,{className:`overflow-x-auto`,children:(0,n.jsx)(`table`,{className:`w-full border-collapse text-sm font-mono leading-6`,children:(0,n.jsx)(`tbody`,{children:p.map((e,t)=>(0,n.jsxs)(`tr`,{className:`hover:bg-black/3 dark:hover:bg-white/3`,children:[c&&(0,n.jsx)(`td`,{className:`select-none w-10 pr-4 pl-4 text-right text-slate-400 dark:text-slate-600 border-r border-black/6 dark:border-white/6`,children:t+1}),(0,n.jsx)(`td`,{className:`px-4 py-0 whitespace-pre`,children:i(e,o).map((e,t)=>(0,n.jsx)(`span`,{className:a[e.type],children:e.value},t))})]},t))})})})]})}var s=(0,t.forwardRef)(({className:t,...r},i)=>(0,n.jsx)(`code`,{ref:i,className:e.t(`break-words rounded-md border border-border bg-surface-muted px-1.5 py-0.5 font-mono text-[0.85em] text-foreground`,t),...r}));s.displayName=`InlineCode`;function c({value:r,onChange:i,language:a=`js`,placeholder:o=`// Start typing…`,minRows:s=6,maxRows:c=24,readOnly:l=!1,className:u}){let d=(0,t.useRef)(null),f=Math.min(c,Math.max(s,r.split(`
|
|
5
5
|
`).length));function p(e){let t=e.currentTarget,{selectionStart:n,selectionEnd:a}=t;if(e.key===`Tab`){e.preventDefault();let o=r.slice(0,n)+` `+r.slice(a);i?.(o),requestAnimationFrame(()=>{t.selectionStart=t.selectionEnd=n+2})}if(e.key===`Enter`){let o=r.lastIndexOf(`
|
|
6
6
|
`,n-1)+1,s=r.slice(o).match(/^(\s*)/)?.[1]??``;e.preventDefault();let c=r.slice(0,n)+`
|
|
7
7
|
`+s+r.slice(a);i?.(c),requestAnimationFrame(()=>{t.selectionStart=t.selectionEnd=n+1+s.length})}let o={"(":`)`,"[":`]`,"{":`}`,'"':`"`,"'":`'`,"`":"`"};if(o[e.key]&&n===a){e.preventDefault();let s=r.slice(0,n)+e.key+o[e.key]+r.slice(a);i?.(s),requestAnimationFrame(()=>{t.selectionStart=t.selectionEnd=n+1})}}return(0,n.jsxs)(`div`,{className:e.t(`relative rounded-xl overflow-hidden border border-black/10 dark:border-white/10 bg-slate-50 dark:bg-[#0d1117]`,u),children:[(0,n.jsx)(`div`,{className:`flex items-center gap-1.5 px-4 py-2.5 border-b border-black/[0.07] dark:border-white/[0.07] bg-black/3 dark:bg-white/3`,children:(0,n.jsx)(`span`,{className:`text-xs font-mono text-slate-400 dark:text-slate-500 uppercase`,children:a})}),(0,n.jsxs)(`div`,{className:`relative flex`,children:[(0,n.jsx)(`div`,{className:`select-none shrink-0 py-3 px-3 text-right text-sm font-mono leading-6 text-slate-400 dark:text-slate-600 border-r border-black/6 dark:border-white/6 bg-black/2 dark:bg-black/20`,"aria-hidden":!0,children:Array.from({length:f},(e,t)=>(0,n.jsx)(`div`,{children:t+1},t))}),(0,n.jsx)(`textarea`,{ref:d,value:r,onChange:e=>i?.(e.target.value),onKeyDown:p,readOnly:l,placeholder:o,spellCheck:!1,rows:f,className:`flex-1 py-3 px-4 text-sm font-mono leading-6 bg-transparent text-slate-800 dark:text-slate-200 placeholder:text-slate-400 dark:placeholder:text-slate-600 focus:outline-none resize-none`})]})]})}exports.CodeBlock=o,exports.CodeEditor=c,exports.InlineCode=s;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
1
2
|
export interface CodeBlockProps {
|
|
2
3
|
code: string;
|
|
3
4
|
language?: string;
|
|
@@ -6,10 +7,9 @@ export interface CodeBlockProps {
|
|
|
6
7
|
className?: string;
|
|
7
8
|
}
|
|
8
9
|
export declare function CodeBlock({ code, language, filename, showLineNumbers, className }: CodeBlockProps): import("react").JSX.Element;
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}): import("react").JSX.Element;
|
|
10
|
+
export interface InlineCodeProps extends HTMLAttributes<HTMLElement> {
|
|
11
|
+
}
|
|
12
|
+
export declare const InlineCode: import('react').ForwardRefExoticComponent<InlineCodeProps & import('react').RefAttributes<HTMLElement>>;
|
|
13
13
|
export interface CodeEditorProps {
|
|
14
14
|
value: string;
|
|
15
15
|
onChange?: (value: string) => void;
|
package/dist/components/code.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { t as e } from "../cn-DpgY2leY.js";
|
|
3
|
-
import {
|
|
4
|
-
import { Fragment as
|
|
3
|
+
import { forwardRef as t, useRef as n, useState as r } from "react";
|
|
4
|
+
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
5
5
|
//#region src/components/code.tsx
|
|
6
|
-
var
|
|
6
|
+
var s = {
|
|
7
7
|
js: /* @__PURE__ */ "const.let.var.function.return.if.else.for.while.class.import.export.default.from.async.await.new.typeof.instanceof.true.false.null.undefined.throw.try.catch.finally.switch.case.break.continue.extends.super.this.of.in.delete.void".split("."),
|
|
8
8
|
python: /* @__PURE__ */ "def.return.if.else.elif.for.while.class.import.from.as.with.try.except.finally.raise.pass.break.continue.and.or.not.in.is.True.False.None.lambda.yield.global.nonlocal.del.print.async.await".split("."),
|
|
9
9
|
bash: [
|
|
@@ -30,9 +30,9 @@ var o = {
|
|
|
30
30
|
],
|
|
31
31
|
sql: /* @__PURE__ */ "SELECT.FROM.WHERE.AND.OR.NOT.INSERT.INTO.VALUES.UPDATE.SET.DELETE.CREATE.TABLE.DROP.ALTER.INDEX.JOIN.INNER.LEFT.RIGHT.ON.GROUP.BY.ORDER.HAVING.LIMIT.OFFSET.AS.DISTINCT.COUNT.SUM.AVG.MAX.MIN.NULL.IS.IN.LIKE.BETWEEN.EXISTS".split(".")
|
|
32
32
|
};
|
|
33
|
-
|
|
34
|
-
function
|
|
35
|
-
let n = new Set(
|
|
33
|
+
s.ts = s.js, s.tsx = s.js, s.jsx = s.js, s.json = [];
|
|
34
|
+
function c(e, t) {
|
|
35
|
+
let n = new Set(s[t.toLowerCase()] ?? s.js), r = [], i = 0;
|
|
36
36
|
for (; i < e.length;) {
|
|
37
37
|
if (t === "bash" && e[i] === "#" || e.slice(i, i + 2) === "//" && t !== "bash") {
|
|
38
38
|
let t = e.indexOf("\n", i), n = t === -1 ? e.slice(i) : e.slice(i, t);
|
|
@@ -110,7 +110,7 @@ function s(e, t) {
|
|
|
110
110
|
}
|
|
111
111
|
return r;
|
|
112
112
|
}
|
|
113
|
-
var
|
|
113
|
+
var l = {
|
|
114
114
|
keyword: "text-violet-500 dark:text-violet-400",
|
|
115
115
|
string: "text-emerald-600 dark:text-emerald-400",
|
|
116
116
|
comment: "text-slate-400 dark:text-slate-500 italic",
|
|
@@ -119,8 +119,8 @@ var c = {
|
|
|
119
119
|
builtin: "text-sky-500 dark:text-sky-400",
|
|
120
120
|
plain: "text-slate-800 dark:text-slate-200"
|
|
121
121
|
};
|
|
122
|
-
function
|
|
123
|
-
let [f, p] =
|
|
122
|
+
function u({ code: t, language: n = "js", filename: s, showLineNumbers: u = !1, className: d }) {
|
|
123
|
+
let [f, p] = r(!1), m = t.replace(/^\n/, "").replace(/\n$/, ""), h = m.split("\n");
|
|
124
124
|
async function g() {
|
|
125
125
|
let e = !1;
|
|
126
126
|
try {
|
|
@@ -132,27 +132,28 @@ function l({ code: t, language: o = "js", filename: l, showLineNumbers: u = !1,
|
|
|
132
132
|
}
|
|
133
133
|
e && (p(!0), window.setTimeout(() => p(!1), 1500));
|
|
134
134
|
}
|
|
135
|
-
return /* @__PURE__ */
|
|
135
|
+
return /* @__PURE__ */ o("div", {
|
|
136
136
|
className: e("group relative rounded-xl overflow-hidden border border-black/10 dark:border-white/10 bg-slate-50 dark:bg-[#0d1117]", d),
|
|
137
|
-
children: [/* @__PURE__ */
|
|
137
|
+
children: [/* @__PURE__ */ o("div", {
|
|
138
138
|
className: "flex items-center justify-between px-4 py-2.5 border-b border-black/[0.07] dark:border-white/[0.07] bg-black/3 dark:bg-white/3",
|
|
139
|
-
children: [/* @__PURE__ */
|
|
139
|
+
children: [/* @__PURE__ */ a("div", {
|
|
140
140
|
className: "flex items-center gap-2",
|
|
141
|
-
children:
|
|
141
|
+
children: s && /* @__PURE__ */ a("span", {
|
|
142
142
|
className: "text-xs font-mono text-slate-500 dark:text-slate-400",
|
|
143
|
-
children:
|
|
143
|
+
children: s
|
|
144
144
|
})
|
|
145
|
-
}), /* @__PURE__ */
|
|
145
|
+
}), /* @__PURE__ */ o("div", {
|
|
146
146
|
className: "flex items-center gap-2",
|
|
147
|
-
children: [!
|
|
147
|
+
children: [!s && /* @__PURE__ */ a("span", {
|
|
148
148
|
className: "text-xs font-mono text-slate-400 dark:text-slate-500 uppercase",
|
|
149
|
-
children:
|
|
150
|
-
}), /* @__PURE__ */
|
|
149
|
+
children: n
|
|
150
|
+
}), /* @__PURE__ */ a("button", {
|
|
151
151
|
type: "button",
|
|
152
152
|
onClick: g,
|
|
153
153
|
"aria-label": f ? "Copied code" : "Copy code",
|
|
154
|
-
className: "h-6 px-2 flex items-center gap-1 rounded text-xs text-slate-500 dark:text-slate-400 hover:text-gray-900 dark:hover:text-white hover:bg-black/6 dark:hover:bg-white/8 transition-colors",
|
|
155
|
-
children: f ? /* @__PURE__ */
|
|
154
|
+
className: "h-6 shrink-0 px-2 flex items-center gap-1 whitespace-nowrap rounded text-xs text-slate-500 dark:text-slate-400 hover:text-gray-900 dark:hover:text-white hover:bg-black/6 dark:hover:bg-white/8 transition-colors",
|
|
155
|
+
children: f ? /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ a("svg", {
|
|
156
|
+
className: "shrink-0",
|
|
156
157
|
width: "11",
|
|
157
158
|
height: "11",
|
|
158
159
|
viewBox: "0 0 24 24",
|
|
@@ -161,8 +162,9 @@ function l({ code: t, language: o = "js", filename: l, showLineNumbers: u = !1,
|
|
|
161
162
|
strokeWidth: "2.5",
|
|
162
163
|
strokeLinecap: "round",
|
|
163
164
|
strokeLinejoin: "round",
|
|
164
|
-
children: /* @__PURE__ */
|
|
165
|
-
}), "Copied"] }) : /* @__PURE__ */
|
|
165
|
+
children: /* @__PURE__ */ a("path", { d: "M20 6 9 17l-5-5" })
|
|
166
|
+
}), "Copied"] }) : /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ o("svg", {
|
|
167
|
+
className: "shrink-0",
|
|
166
168
|
width: "11",
|
|
167
169
|
height: "11",
|
|
168
170
|
viewBox: "0 0 24 24",
|
|
@@ -171,30 +173,30 @@ function l({ code: t, language: o = "js", filename: l, showLineNumbers: u = !1,
|
|
|
171
173
|
strokeWidth: "2",
|
|
172
174
|
strokeLinecap: "round",
|
|
173
175
|
strokeLinejoin: "round",
|
|
174
|
-
children: [/* @__PURE__ */
|
|
176
|
+
children: [/* @__PURE__ */ a("rect", {
|
|
175
177
|
width: "14",
|
|
176
178
|
height: "14",
|
|
177
179
|
x: "8",
|
|
178
180
|
y: "8",
|
|
179
181
|
rx: "2",
|
|
180
182
|
ry: "2"
|
|
181
|
-
}), /* @__PURE__ */
|
|
183
|
+
}), /* @__PURE__ */ a("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })]
|
|
182
184
|
}), "Copy"] })
|
|
183
185
|
})]
|
|
184
186
|
})]
|
|
185
|
-
}), /* @__PURE__ */
|
|
187
|
+
}), /* @__PURE__ */ a("div", {
|
|
186
188
|
className: "overflow-x-auto",
|
|
187
|
-
children: /* @__PURE__ */
|
|
189
|
+
children: /* @__PURE__ */ a("table", {
|
|
188
190
|
className: "w-full border-collapse text-sm font-mono leading-6",
|
|
189
|
-
children: /* @__PURE__ */
|
|
191
|
+
children: /* @__PURE__ */ a("tbody", { children: h.map((e, t) => /* @__PURE__ */ o("tr", {
|
|
190
192
|
className: "hover:bg-black/3 dark:hover:bg-white/3",
|
|
191
|
-
children: [u && /* @__PURE__ */
|
|
193
|
+
children: [u && /* @__PURE__ */ a("td", {
|
|
192
194
|
className: "select-none w-10 pr-4 pl-4 text-right text-slate-400 dark:text-slate-600 border-r border-black/6 dark:border-white/6",
|
|
193
195
|
children: t + 1
|
|
194
|
-
}), /* @__PURE__ */
|
|
196
|
+
}), /* @__PURE__ */ a("td", {
|
|
195
197
|
className: "px-4 py-0 whitespace-pre",
|
|
196
|
-
children:
|
|
197
|
-
className:
|
|
198
|
+
children: c(e, n).map((e, t) => /* @__PURE__ */ a("span", {
|
|
199
|
+
className: l[e.type],
|
|
198
200
|
children: e.value
|
|
199
201
|
}, t))
|
|
200
202
|
})]
|
|
@@ -203,29 +205,29 @@ function l({ code: t, language: o = "js", filename: l, showLineNumbers: u = !1,
|
|
|
203
205
|
})]
|
|
204
206
|
});
|
|
205
207
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
function
|
|
213
|
-
let f =
|
|
208
|
+
var d = t(({ className: t, ...n }, r) => /* @__PURE__ */ a("code", {
|
|
209
|
+
ref: r,
|
|
210
|
+
className: e("break-words rounded-md border border-border bg-surface-muted px-1.5 py-0.5 font-mono text-[0.85em] text-foreground", t),
|
|
211
|
+
...n
|
|
212
|
+
}));
|
|
213
|
+
d.displayName = "InlineCode";
|
|
214
|
+
function f({ value: t, onChange: r, language: i = "js", placeholder: s = "// Start typing…", minRows: c = 6, maxRows: l = 24, readOnly: u = !1, className: d }) {
|
|
215
|
+
let f = n(null), p = Math.min(l, Math.max(c, t.split("\n").length));
|
|
214
216
|
function m(e) {
|
|
215
|
-
let
|
|
217
|
+
let n = e.currentTarget, { selectionStart: i, selectionEnd: a } = n;
|
|
216
218
|
if (e.key === "Tab") {
|
|
217
219
|
e.preventDefault();
|
|
218
|
-
let o =
|
|
220
|
+
let o = t.slice(0, i) + " " + t.slice(a);
|
|
219
221
|
r?.(o), requestAnimationFrame(() => {
|
|
220
|
-
|
|
222
|
+
n.selectionStart = n.selectionEnd = i + 2;
|
|
221
223
|
});
|
|
222
224
|
}
|
|
223
225
|
if (e.key === "Enter") {
|
|
224
|
-
let o =
|
|
226
|
+
let o = t.lastIndexOf("\n", i - 1) + 1, s = t.slice(o).match(/^(\s*)/)?.[1] ?? "";
|
|
225
227
|
e.preventDefault();
|
|
226
|
-
let c =
|
|
228
|
+
let c = t.slice(0, i) + "\n" + s + t.slice(a);
|
|
227
229
|
r?.(c), requestAnimationFrame(() => {
|
|
228
|
-
|
|
230
|
+
n.selectionStart = n.selectionEnd = i + 1 + s.length;
|
|
229
231
|
});
|
|
230
232
|
}
|
|
231
233
|
let o = {
|
|
@@ -238,29 +240,29 @@ function d({ value: n, onChange: r, language: o = "js", placeholder: s = "// Sta
|
|
|
238
240
|
};
|
|
239
241
|
if (o[e.key] && i === a) {
|
|
240
242
|
e.preventDefault();
|
|
241
|
-
let s =
|
|
243
|
+
let s = t.slice(0, i) + e.key + o[e.key] + t.slice(a);
|
|
242
244
|
r?.(s), requestAnimationFrame(() => {
|
|
243
|
-
|
|
245
|
+
n.selectionStart = n.selectionEnd = i + 1;
|
|
244
246
|
});
|
|
245
247
|
}
|
|
246
248
|
}
|
|
247
|
-
return /* @__PURE__ */
|
|
249
|
+
return /* @__PURE__ */ o("div", {
|
|
248
250
|
className: e("relative rounded-xl overflow-hidden border border-black/10 dark:border-white/10 bg-slate-50 dark:bg-[#0d1117]", d),
|
|
249
|
-
children: [/* @__PURE__ */
|
|
251
|
+
children: [/* @__PURE__ */ a("div", {
|
|
250
252
|
className: "flex items-center gap-1.5 px-4 py-2.5 border-b border-black/[0.07] dark:border-white/[0.07] bg-black/3 dark:bg-white/3",
|
|
251
|
-
children: /* @__PURE__ */
|
|
253
|
+
children: /* @__PURE__ */ a("span", {
|
|
252
254
|
className: "text-xs font-mono text-slate-400 dark:text-slate-500 uppercase",
|
|
253
|
-
children:
|
|
255
|
+
children: i
|
|
254
256
|
})
|
|
255
|
-
}), /* @__PURE__ */
|
|
257
|
+
}), /* @__PURE__ */ o("div", {
|
|
256
258
|
className: "relative flex",
|
|
257
|
-
children: [/* @__PURE__ */
|
|
259
|
+
children: [/* @__PURE__ */ a("div", {
|
|
258
260
|
className: "select-none shrink-0 py-3 px-3 text-right text-sm font-mono leading-6 text-slate-400 dark:text-slate-600 border-r border-black/6 dark:border-white/6 bg-black/2 dark:bg-black/20",
|
|
259
261
|
"aria-hidden": !0,
|
|
260
|
-
children: Array.from({ length: p }, (e, t) => /* @__PURE__ */
|
|
261
|
-
}), /* @__PURE__ */
|
|
262
|
+
children: Array.from({ length: p }, (e, t) => /* @__PURE__ */ a("div", { children: t + 1 }, t))
|
|
263
|
+
}), /* @__PURE__ */ a("textarea", {
|
|
262
264
|
ref: f,
|
|
263
|
-
value:
|
|
265
|
+
value: t,
|
|
264
266
|
onChange: (e) => r?.(e.target.value),
|
|
265
267
|
onKeyDown: m,
|
|
266
268
|
readOnly: u,
|
|
@@ -273,4 +275,4 @@ function d({ value: n, onChange: r, language: o = "js", placeholder: s = "// Sta
|
|
|
273
275
|
});
|
|
274
276
|
}
|
|
275
277
|
//#endregion
|
|
276
|
-
export {
|
|
278
|
+
export { u as CodeBlock, f as CodeEditor, d as InlineCode };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../cn-BdjraxxU.cjs");let t=require("framer-motion"),n=require("react"),r=require("react/jsx-runtime");var i=()=>(0,r.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,r.jsx)(`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`}),(0,r.jsx)(`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`})]}),a=()=>(0,r.jsx)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,r.jsx)(`path`,{d:`m20 6-11 11-5-5`})});function o({value:o,timeout:s=2e3,label:c,size:l=`sm`,className:u,...d}){let[f,p]=(0,n.useState)(!1);async function m(){try{await navigator.clipboard.writeText(o),p(!0),setTimeout(()=>p(!1),s)}catch{}}return(0,r.jsx)(`button`,{type:`button`,onClick:m,className:e.t(`inline-flex items-center font-medium transition-colors select-none`,`border border-black/10 dark:border-white/10`,f?`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`:`bg-black/4 dark:bg-white/4 text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-200 hover:bg-black/8 dark:hover:bg-white/8`,l===`sm`?`h-6 px-2 text-xs gap-1 rounded-md`:`h-8 px-3 text-sm gap-1.5 rounded-lg`,u),...d,children:(0,r.jsx)(t.AnimatePresence,{mode:`wait`,initial:!1,children:f?(0,r.jsxs)(t.motion.span,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.8,opacity:0},transition:{duration:.1},className:`flex items-center gap-1`,children:[(0,r.jsx)(a,{}),c&&`Copied`]},`check`):(0,r.jsxs)(t.motion.span,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.8,opacity:0},transition:{duration:.1},className:`flex items-center gap-1`,children:[(0,r.jsx)(i,{}),c&&c]},`copy`)})})}exports.CopyButton=o;
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../cn-BdjraxxU.cjs");let t=require("framer-motion"),n=require("react"),r=require("react/jsx-runtime");var i=()=>(0,r.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,r.jsx)(`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`}),(0,r.jsx)(`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`})]}),a=()=>(0,r.jsx)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,r.jsx)(`path`,{d:`m20 6-11 11-5-5`})});function o({value:o,timeout:s=2e3,label:c,size:l=`sm`,className:u,...d}){let[f,p]=(0,n.useState)(!1);async function m(){try{await navigator.clipboard.writeText(o),p(!0),setTimeout(()=>p(!1),s)}catch{}}return(0,r.jsx)(`button`,{type:`button`,onClick:m,className:e.t(`inline-flex shrink-0 items-center justify-center whitespace-nowrap font-medium transition-colors select-none`,`border border-black/10 dark:border-white/10`,f?`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`:`bg-black/4 dark:bg-white/4 text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-200 hover:bg-black/8 dark:hover:bg-white/8`,l===`sm`?`h-6 px-2 text-xs gap-1 rounded-md`:`h-8 px-3 text-sm gap-1.5 rounded-lg`,u),...d,children:(0,r.jsx)(t.AnimatePresence,{mode:`wait`,initial:!1,children:f?(0,r.jsxs)(t.motion.span,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.8,opacity:0},transition:{duration:.1},className:`inline-flex items-center gap-1 whitespace-nowrap`,children:[(0,r.jsx)(a,{}),c&&`Copied`]},`check`):(0,r.jsxs)(t.motion.span,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.8,opacity:0},transition:{duration:.1},className:`inline-flex items-center gap-1 whitespace-nowrap`,children:[(0,r.jsx)(i,{}),c&&c]},`copy`)})})}exports.CopyButton=o;
|
|
@@ -42,7 +42,7 @@ function c({ value: c, timeout: l = 2e3, label: u, size: d = "sm", className: f,
|
|
|
42
42
|
return /* @__PURE__ */ i("button", {
|
|
43
43
|
type: "button",
|
|
44
44
|
onClick: g,
|
|
45
|
-
className: e("inline-flex items-center font-medium transition-colors select-none", "border border-black/10 dark:border-white/10", m ? "bg-emerald-500/10 text-emerald-400 border-emerald-500/20" : "bg-black/4 dark:bg-white/4 text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-200 hover:bg-black/8 dark:hover:bg-white/8", d === "sm" ? "h-6 px-2 text-xs gap-1 rounded-md" : "h-8 px-3 text-sm gap-1.5 rounded-lg", f),
|
|
45
|
+
className: e("inline-flex shrink-0 items-center justify-center whitespace-nowrap font-medium transition-colors select-none", "border border-black/10 dark:border-white/10", m ? "bg-emerald-500/10 text-emerald-400 border-emerald-500/20" : "bg-black/4 dark:bg-white/4 text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-200 hover:bg-black/8 dark:hover:bg-white/8", d === "sm" ? "h-6 px-2 text-xs gap-1 rounded-md" : "h-8 px-3 text-sm gap-1.5 rounded-lg", f),
|
|
46
46
|
...p,
|
|
47
47
|
children: /* @__PURE__ */ i(t, {
|
|
48
48
|
mode: "wait",
|
|
@@ -61,7 +61,7 @@ function c({ value: c, timeout: l = 2e3, label: u, size: d = "sm", className: f,
|
|
|
61
61
|
opacity: 0
|
|
62
62
|
},
|
|
63
63
|
transition: { duration: .1 },
|
|
64
|
-
className: "flex items-center gap-1",
|
|
64
|
+
className: "inline-flex items-center gap-1 whitespace-nowrap",
|
|
65
65
|
children: [/* @__PURE__ */ i(s, {}), u && "Copied"]
|
|
66
66
|
}, "check") : /* @__PURE__ */ a(n.span, {
|
|
67
67
|
initial: {
|
|
@@ -77,7 +77,7 @@ function c({ value: c, timeout: l = 2e3, label: u, size: d = "sm", className: f,
|
|
|
77
77
|
opacity: 0
|
|
78
78
|
},
|
|
79
79
|
transition: { duration: .1 },
|
|
80
|
-
className: "flex items-center gap-1",
|
|
80
|
+
className: "inline-flex items-center gap-1 whitespace-nowrap",
|
|
81
81
|
children: [/* @__PURE__ */ i(o, {}), u && u]
|
|
82
82
|
}, "copy")
|
|
83
83
|
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../cn-BdjraxxU.cjs");let t=require("react"),n=require("react/jsx-runtime");var r={default:`text-foreground`,positive:`text-success`,negative:`text-destructive`,muted:`text-muted-foreground`},i={xs:`text-xs`,sm:`text-sm`,md:`text-base`,lg:`text-lg`,xl:`text-2xl`};function a(e){return typeof e==`bigint`?e<0n:e<0}function o(e){return typeof e==`bigint`||Number.isFinite(e)}function s(e,{currency:t=`USD`,locale:n=`en-US`,accounting:r=!1,options:i}={}){if(!o(e))return null;try{return new Intl.NumberFormat(n,{...i,style:`currency`,currency:t,currencySign:r?`accounting`:`standard`}).format(e)}catch{return null}}var c=(0,t.forwardRef)(({value:t,currency:o=`USD`,locale:c=`en-US`,accounting:l=!1,options:u,tone:d=`auto`,size:f=`md`,fallback:p=`—`,className:m,...h},g)=>{let _=s(t,{currency:o,locale:c,accounting:l,options:u}),v=d===`auto`?a(t)?`negative`:`default`:d,y=u?.notation===`compact`?s(t,{currency:o,locale:c,accounting:l,options:{...u,notation:`standard`}})??void 0:void 0;return(0,n.jsx)(`span`,{ref:g,"data-invalid":_===null||void 0,"aria-label":y,className:e.t(`inline whitespace-nowrap font-medium tabular-nums`,r[v],i[f],m),...h,children:_??p})});c.displayName=`Currency`,exports.Currency=c,exports.formatCurrency=s;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type CurrencyTone = "auto" | "default" | "positive" | "negative" | "muted";
|
|
3
|
+
export type CurrencySize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
4
|
+
export type CurrencyFormatOptions = Omit<Intl.NumberFormatOptions, "style" | "currency" | "currencySign">;
|
|
5
|
+
export interface FormatCurrencyOptions {
|
|
6
|
+
currency?: string;
|
|
7
|
+
locale?: Intl.LocalesArgument;
|
|
8
|
+
accounting?: boolean;
|
|
9
|
+
options?: CurrencyFormatOptions;
|
|
10
|
+
}
|
|
11
|
+
export declare function formatCurrency(value: number | bigint, { currency, locale, accounting, options, }?: FormatCurrencyOptions): string | null;
|
|
12
|
+
export interface CurrencyProps extends Omit<HTMLAttributes<HTMLSpanElement>, "children">, FormatCurrencyOptions {
|
|
13
|
+
value: number | bigint;
|
|
14
|
+
tone?: CurrencyTone;
|
|
15
|
+
size?: CurrencySize;
|
|
16
|
+
fallback?: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
export declare const Currency: import('react').ForwardRefExoticComponent<CurrencyProps & import('react').RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { t as e } from "../cn-DpgY2leY.js";
|
|
2
|
+
import { forwardRef as t } from "react";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/currency.tsx
|
|
5
|
+
var r = {
|
|
6
|
+
default: "text-foreground",
|
|
7
|
+
positive: "text-success",
|
|
8
|
+
negative: "text-destructive",
|
|
9
|
+
muted: "text-muted-foreground"
|
|
10
|
+
}, i = {
|
|
11
|
+
xs: "text-xs",
|
|
12
|
+
sm: "text-sm",
|
|
13
|
+
md: "text-base",
|
|
14
|
+
lg: "text-lg",
|
|
15
|
+
xl: "text-2xl"
|
|
16
|
+
};
|
|
17
|
+
function a(e) {
|
|
18
|
+
return typeof e == "bigint" ? e < 0n : e < 0;
|
|
19
|
+
}
|
|
20
|
+
function o(e) {
|
|
21
|
+
return typeof e == "bigint" || Number.isFinite(e);
|
|
22
|
+
}
|
|
23
|
+
function s(e, { currency: t = "USD", locale: n = "en-US", accounting: r = !1, options: i } = {}) {
|
|
24
|
+
if (!o(e)) return null;
|
|
25
|
+
try {
|
|
26
|
+
return new Intl.NumberFormat(n, {
|
|
27
|
+
...i,
|
|
28
|
+
style: "currency",
|
|
29
|
+
currency: t,
|
|
30
|
+
currencySign: r ? "accounting" : "standard"
|
|
31
|
+
}).format(e);
|
|
32
|
+
} catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
var c = t(({ value: t, currency: o = "USD", locale: c = "en-US", accounting: l = !1, options: u, tone: d = "auto", size: f = "md", fallback: p = "—", className: m, ...h }, g) => {
|
|
37
|
+
let _ = s(t, {
|
|
38
|
+
currency: o,
|
|
39
|
+
locale: c,
|
|
40
|
+
accounting: l,
|
|
41
|
+
options: u
|
|
42
|
+
}), v = d === "auto" ? a(t) ? "negative" : "default" : d, y = u?.notation === "compact" ? s(t, {
|
|
43
|
+
currency: o,
|
|
44
|
+
locale: c,
|
|
45
|
+
accounting: l,
|
|
46
|
+
options: {
|
|
47
|
+
...u,
|
|
48
|
+
notation: "standard"
|
|
49
|
+
}
|
|
50
|
+
}) ?? void 0 : void 0;
|
|
51
|
+
return /* @__PURE__ */ n("span", {
|
|
52
|
+
ref: g,
|
|
53
|
+
"data-invalid": _ === null || void 0,
|
|
54
|
+
"aria-label": y,
|
|
55
|
+
className: e("inline whitespace-nowrap font-medium tabular-nums", r[v], i[f], m),
|
|
56
|
+
...h,
|
|
57
|
+
children: _ ?? p
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
c.displayName = "Currency";
|
|
61
|
+
//#endregion
|
|
62
|
+
export { c as Currency, s as formatCurrency };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../cn-BdjraxxU.cjs");let t=require("react"),n=require("react/jsx-runtime");var r={1:`grid-cols-1`,2:`grid-cols-1 sm:grid-cols-2`,3:`grid-cols-1 sm:grid-cols-2 lg:grid-cols-3`},i={compact:`gap-x-4 gap-y-3`,default:`gap-x-6 gap-y-5`,relaxed:`gap-x-8 gap-y-7`},a=(0,t.forwardRef)(({columns:t=1,density:a=`default`,className:o,...s},c)=>(0,n.jsx)(`dl`,{ref:c,className:e.t(`grid min-w-0`,r[t],i[a],o),...s}));a.displayName=`DescriptionList`;var o=(0,t.forwardRef)(({orientation:t=`stacked`,className:r,...i},a)=>(0,n.jsx)(`div`,{ref:a,className:e.t(`min-w-0`,t===`inline`?`flex flex-col gap-1 sm:flex-row sm:items-baseline sm:justify-between sm:gap-4`:`flex flex-col gap-1`,r),...i}));o.displayName=`DescriptionItem`;var s=(0,t.forwardRef)(({className:t,...r},i)=>(0,n.jsx)(`dt`,{ref:i,className:e.t(`text-xs font-medium text-muted-foreground`,t),...r}));s.displayName=`DescriptionTerm`;var c=(0,t.forwardRef)(({className:t,...r},i)=>(0,n.jsx)(`dd`,{ref:i,className:e.t(`min-w-0 break-words text-sm font-medium text-foreground`,t),...r}));c.displayName=`DescriptionDetails`,exports.DescriptionDetails=c,exports.DescriptionItem=o,exports.DescriptionList=a,exports.DescriptionTerm=s;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
export type DescriptionListColumns = 1 | 2 | 3;
|
|
3
|
+
export type DescriptionListDensity = "compact" | "default" | "relaxed";
|
|
4
|
+
export interface DescriptionListProps extends HTMLAttributes<HTMLDListElement> {
|
|
5
|
+
columns?: DescriptionListColumns;
|
|
6
|
+
density?: DescriptionListDensity;
|
|
7
|
+
}
|
|
8
|
+
export declare const DescriptionList: import('react').ForwardRefExoticComponent<DescriptionListProps & import('react').RefAttributes<HTMLDListElement>>;
|
|
9
|
+
export interface DescriptionItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
10
|
+
orientation?: "stacked" | "inline";
|
|
11
|
+
}
|
|
12
|
+
export declare const DescriptionItem: import('react').ForwardRefExoticComponent<DescriptionItemProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
13
|
+
export declare const DescriptionTerm: import('react').ForwardRefExoticComponent<HTMLAttributes<HTMLElement> & import('react').RefAttributes<HTMLElement>>;
|
|
14
|
+
export declare const DescriptionDetails: import('react').ForwardRefExoticComponent<HTMLAttributes<HTMLElement> & import('react').RefAttributes<HTMLElement>>;
|