@bergetai/ui 0.17.0 → 0.19.0
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/components/alert-dialog/AlertDialog.cjs +3 -3
- package/dist/components/alert-dialog/AlertDialog.cjs.map +1 -1
- package/dist/components/alert-dialog/AlertDialog.d.cts +3 -3
- package/dist/components/alert-dialog/AlertDialog.d.mts +3 -3
- package/dist/components/alert-dialog/AlertDialog.mjs +3 -3
- package/dist/components/alert-dialog/AlertDialog.mjs.map +1 -1
- package/dist/components/box/Box.cjs.map +1 -1
- package/dist/components/box/Box.d.cts +3 -3
- package/dist/components/box/Box.d.mts +3 -3
- package/dist/components/box/Box.mjs.map +1 -1
- package/dist/components/button/Button.cjs +3 -1
- package/dist/components/button/Button.cjs.map +1 -1
- package/dist/components/button/Button.d.cts +1 -1
- package/dist/components/button/Button.d.mts +1 -1
- package/dist/components/button/Button.mjs +3 -1
- package/dist/components/button/Button.mjs.map +1 -1
- package/dist/components/code-block/CodeBlock.cjs +50 -48
- package/dist/components/code-block/CodeBlock.cjs.map +1 -1
- package/dist/components/code-block/CodeBlock.d.cts +27 -7
- package/dist/components/code-block/CodeBlock.d.cts.map +1 -1
- package/dist/components/code-block/CodeBlock.d.mts +27 -7
- package/dist/components/code-block/CodeBlock.d.mts.map +1 -1
- package/dist/components/code-block/CodeBlock.mjs +45 -50
- package/dist/components/code-block/CodeBlock.mjs.map +1 -1
- package/dist/components/code-block/index.d.cts +3 -0
- package/dist/components/code-block/index.d.mts +3 -0
- package/dist/components/container/Container.cjs.map +1 -1
- package/dist/components/container/Container.d.cts +3 -3
- package/dist/components/container/Container.d.mts +3 -3
- package/dist/components/container/Container.mjs.map +1 -1
- package/dist/components/country-select/CountrySelect.cjs +2 -2
- package/dist/components/country-select/CountrySelect.cjs.map +1 -1
- package/dist/components/country-select/CountrySelect.mjs +2 -2
- package/dist/components/country-select/CountrySelect.mjs.map +1 -1
- package/dist/components/dialog/Dialog.cjs +3 -3
- package/dist/components/dialog/Dialog.cjs.map +1 -1
- package/dist/components/dialog/Dialog.d.cts +1 -1
- package/dist/components/dialog/Dialog.d.mts +1 -1
- package/dist/components/dialog/Dialog.mjs +3 -3
- package/dist/components/dialog/Dialog.mjs.map +1 -1
- package/dist/components/dropdown-menu/DropdownMenu.cjs.map +1 -1
- package/dist/components/dropdown-menu/DropdownMenu.d.cts +9 -9
- package/dist/components/dropdown-menu/DropdownMenu.d.mts +9 -9
- package/dist/components/dropdown-menu/DropdownMenu.mjs.map +1 -1
- package/dist/components/grid/Grid.cjs.map +1 -1
- package/dist/components/grid/Grid.d.cts +3 -3
- package/dist/components/grid/Grid.d.mts +3 -3
- package/dist/components/grid/Grid.mjs.map +1 -1
- package/dist/components/item/Item.cjs.map +1 -1
- package/dist/components/item/Item.d.cts +1 -1
- package/dist/components/item/Item.d.mts +1 -1
- package/dist/components/item/Item.mjs.map +1 -1
- package/dist/components/typography/Typography.d.cts +1 -1
- package/dist/components/typography/Typography.d.mts +1 -1
- package/dist/hooks/use-highlighted-code.cjs +58 -0
- package/dist/hooks/use-highlighted-code.cjs.map +1 -0
- package/dist/hooks/use-highlighted-code.d.cts +5 -0
- package/dist/hooks/use-highlighted-code.d.cts.map +1 -0
- package/dist/hooks/use-highlighted-code.d.mts +5 -0
- package/dist/hooks/use-highlighted-code.d.mts.map +1 -0
- package/dist/hooks/use-highlighted-code.mjs +56 -0
- package/dist/hooks/use-highlighted-code.mjs.map +1 -0
- package/dist/index.cjs +12 -0
- package/dist/index.d.cts +6 -2
- package/dist/index.d.mts +6 -2
- package/dist/index.mjs +5 -2
- package/dist/lib/highlighter.cjs +81 -0
- package/dist/lib/highlighter.cjs.map +1 -0
- package/dist/lib/highlighter.mjs +79 -0
- package/dist/lib/highlighter.mjs.map +1 -0
- package/dist/lib/utils.cjs +4 -4
- package/dist/lib/utils.cjs.map +1 -1
- package/dist/lib/utils.d.cts +6 -0
- package/dist/lib/utils.d.cts.map +1 -0
- package/dist/lib/utils.d.mts +6 -0
- package/dist/lib/utils.d.mts.map +1 -0
- package/dist/lib/utils.mjs +4 -4
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/primitives/button.d.cts +1 -1
- package/dist/primitives/button.d.mts +1 -1
- package/dist/primitives/code-block.cjs +133 -0
- package/dist/primitives/code-block.cjs.map +1 -0
- package/dist/primitives/code-block.d.cts +29 -0
- package/dist/primitives/code-block.d.cts.map +1 -0
- package/dist/primitives/code-block.d.mts +29 -0
- package/dist/primitives/code-block.d.mts.map +1 -0
- package/dist/primitives/code-block.mjs +124 -0
- package/dist/primitives/code-block.mjs.map +1 -0
- package/dist/styles/index.css +61 -0
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-block.cjs","names":["cva","React","Button","CheckIcon","CopyIcon"],"sources":["../../src/primitives/code-block.tsx"],"sourcesContent":["import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"cn\"\n\nimport { Button } from \"@/primitives/button\"\nimport { CheckIcon, CopyIcon } from \"lucide-react\"\n\nconst codeBlockVariants = cva(\n \"group/code-block relative flex w-full min-w-0 flex-col overflow-hidden rounded-lg text-sm has-[>[data-slot=code-block-content]:focus-visible]:ring-3 has-[>[data-slot=code-block-content]:focus-visible]:ring-ring/50 data-[size=sm]:text-xs\",\n {\n variants: {\n variant: {\n default:\n \"border border-input text-foreground has-[>[data-slot=code-block-content]:focus-visible]:border-ring dark:bg-input/30\",\n destructive:\n \"border border-destructive/30 text-destructive dark:border-destructive/40\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n }\n)\n\nfunction CodeBlock({\n className,\n variant = \"default\",\n size = \"default\",\n ...props\n}: React.ComponentProps<\"div\"> &\n VariantProps<typeof codeBlockVariants> & { size?: \"default\" | \"sm\" }) {\n return (\n <div\n data-slot=\"code-block\"\n data-variant={variant}\n data-size={size}\n className={cn(codeBlockVariants({ variant }), className)}\n {...props}\n />\n )\n}\n\nfunction CodeBlockHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"code-block-header\"\n className={cn(\n \"flex min-w-0 shrink-0 items-center gap-2 px-3 pt-3 text-muted-foreground group-data-[size=sm]/code-block:px-2.5 group-data-[size=sm]/code-block:pt-2.5 group-data-[variant=destructive]/code-block:text-destructive *:has-[>[data-slot=code-block-title]]:min-w-0\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CodeBlockTitle({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"code-block-title\"\n className={cn(\n \"min-w-0 truncate font-sans text-sm font-medium text-foreground group-data-[size=sm]/code-block:text-xs group-data-[variant=destructive]/code-block:text-destructive [&_svg]:pointer-events-none [&_svg]:inline-block [&_svg]:align-middle [&_svg:not([class*='size-'])]:size-3.5 *:[svg]:me-1.5\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CodeBlockActions({\n className,\n ...props\n}: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"code-block-actions\"\n className={cn(\n \"-my-1 ms-auto -me-1.5 flex shrink-0 items-center gap-1 [[data-slot=code-block]>&]:absolute [[data-slot=code-block]>&]:end-2 [[data-slot=code-block]>&]:top-2 [[data-slot=code-block]>&]:z-10 [[data-slot=code-block]>&]:m-0 [[data-slot=code-block]>&]:opacity-0 [[data-slot=code-block]>&]:transition-opacity [[data-slot=code-block]>&]:group-focus-within/code-block:opacity-100 [[data-slot=code-block]>&]:group-hover/code-block:opacity-100 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:end-1.5 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:top-1.5 [[data-slot=code-block]>&]:pointer-coarse:opacity-100 [[data-slot=code-block]>&]:*:[button]:bg-background [[data-slot=code-block]>&]:*:[button]:ring-1 [[data-slot=code-block]>&]:*:[button]:ring-foreground/10\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CodeBlockCopyButton({\n value,\n variant = \"ghost\",\n size = \"icon-xs\",\n className,\n onClick,\n ...props\n}: React.ComponentProps<typeof Button> & { value: string }) {\n const [copied, setCopied] = React.useState(false)\n\n React.useEffect(() => {\n if (!copied) {\n return\n }\n\n const timeout = setTimeout(() => setCopied(false), 2000)\n return () => clearTimeout(timeout)\n }, [copied])\n\n return (\n <>\n <Button\n data-slot=\"code-block-copy-button\"\n data-copied={copied || undefined}\n variant={variant}\n size={size}\n aria-label={copied ? \"Copied\" : \"Copy\"}\n className={cn(className)}\n onClick={(event) => {\n onClick?.(event)\n navigator.clipboard\n .writeText(value)\n .then(() => setCopied(true))\n .catch(() => {})\n }}\n {...props}\n >\n {copied ? (\n <CheckIcon\n />\n ) : (\n <CopyIcon\n />\n )}\n </Button>\n <span aria-live=\"polite\" className=\"sr-only\">\n {copied ? \"Copied\" : \"\"}\n </span>\n </>\n )\n}\n\nfunction CodeBlockContent({\n className,\n children,\n style,\n wrap = false,\n lineNumbers = false,\n startLine = 1,\n ...props\n}: React.ComponentProps<\"pre\"> & {\n wrap?: boolean\n lineNumbers?: boolean\n startLine?: number\n}) {\n return (\n <pre\n data-slot=\"code-block-content\"\n data-wrap={wrap || undefined}\n data-numbered={lineNumbers || undefined}\n dir=\"ltr\"\n tabIndex={0}\n style={{ counterReset: `line ${startLine - 1}`, ...style }}\n className={cn(\n \"min-h-0 min-w-0 scroll-fade-x scrollbar-thin overflow-auto px-3 py-3 text-start font-mono leading-relaxed outline-none group-has-data-[slot=code-block-footer]/code-block:pb-2 group-has-data-[slot=code-block-header]/code-block:pt-2 group-data-[size=sm]/code-block:px-2.5 group-data-[size=sm]/code-block:py-2.5 group-data-[size=sm]/code-block:group-has-data-[slot=code-block-header]/code-block:pt-1.5 data-wrap:scroll-fade-y data-wrap:wrap-break-word data-wrap:whitespace-pre-wrap\",\n className\n )}\n {...props}\n >\n <code\n data-slot=\"code-block-code\"\n className=\"grid min-h-lh min-w-max content-start in-data-numbered:grid-cols-[auto_1fr] in-data-wrap:min-w-0\"\n >\n {lineNumbers && typeof children === \"string\"\n ? children\n .replace(/\\n$/, \"\")\n .split(\"\\n\")\n .map((line, index) => (\n <CodeBlockLine key={index}>{line}</CodeBlockLine>\n ))\n : children}\n </code>\n </pre>\n )\n}\n\nconst codeBlockLineVariants = cva(\n \"relative -mx-3 block min-h-lh px-3 group-data-[size=sm]/code-block:-mx-2.5 group-data-[size=sm]/code-block:px-2.5 before:min-w-6 before:text-end before:text-muted-foreground after:absolute after:start-1 after:top-0 after:text-muted-foreground after:select-none in-data-numbered:col-span-2 in-data-numbered:grid in-data-numbered:grid-cols-subgrid in-data-numbered:gap-x-3 in-data-numbered:[counter-increment:line] in-data-numbered:before:content-[counter(line)] in-data-numbered:before:select-none in-data-numbered:supports-[content:counter(line)_/_'']:before:content-[counter(line)_/_'']\",\n {\n variants: {\n variant: {\n default: \"\",\n added: \"bg-muted after:content-['+']\",\n removed: \"bg-destructive/10 after:text-destructive after:content-['−']\",\n highlighted: \"bg-muted\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n }\n)\n\nfunction CodeBlockLine({\n className,\n variant = \"default\",\n children,\n ...props\n}: React.ComponentProps<\"span\"> & VariantProps<typeof codeBlockLineVariants>) {\n // An empty line holds a newline so copying a selection keeps blank lines.\n const empty =\n children === undefined ||\n children === null ||\n children === \"\" ||\n (Array.isArray(children) && children.length === 0)\n\n return (\n <span\n data-slot=\"code-block-line\"\n data-variant={variant}\n className={cn(codeBlockLineVariants({ variant }), className)}\n {...props}\n >\n <span data-slot=\"code-block-line-content\" className=\"min-w-0\">\n {empty ? \"\\n\" : children}\n </span>\n </span>\n )\n}\n\nfunction CodeBlockFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"code-block-footer\"\n className={cn(\n \"flex min-w-0 shrink-0 items-center gap-2 px-3 pb-3 text-muted-foreground group-data-[size=sm]/code-block:px-2.5 group-data-[size=sm]/code-block:pb-2.5\",\n className\n )}\n {...props}\n />\n )\n}\n\nexport {\n CodeBlock,\n CodeBlockHeader,\n CodeBlockTitle,\n CodeBlockActions,\n CodeBlockCopyButton,\n CodeBlockContent,\n CodeBlockLine,\n CodeBlockFooter,\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Button } from "./button.cjs";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { VariantProps } from "class-variance-authority";
|
|
4
|
+
//#region src/primitives/code-block.d.ts
|
|
5
|
+
declare const codeBlockVariants: (props?: ({
|
|
6
|
+
variant?: "default" | "destructive" | null | undefined;
|
|
7
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
|
+
declare function CodeBlock({ className, variant, size, ...props }: React.ComponentProps<"div"> & VariantProps<typeof codeBlockVariants> & {
|
|
9
|
+
size?: "default" | "sm";
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare function CodeBlockHeader({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
declare function CodeBlockTitle({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
declare function CodeBlockActions({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
declare function CodeBlockCopyButton({ value, variant, size, className, onClick, ...props }: React.ComponentProps<typeof Button> & {
|
|
15
|
+
value: string;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
declare function CodeBlockContent({ className, children, style, wrap, lineNumbers, startLine, ...props }: React.ComponentProps<"pre"> & {
|
|
18
|
+
wrap?: boolean;
|
|
19
|
+
lineNumbers?: boolean;
|
|
20
|
+
startLine?: number;
|
|
21
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
declare const codeBlockLineVariants: (props?: ({
|
|
23
|
+
variant?: "default" | "added" | "removed" | "highlighted" | null | undefined;
|
|
24
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
25
|
+
declare function CodeBlockLine({ className, variant, children, ...props }: React.ComponentProps<"span"> & VariantProps<typeof codeBlockLineVariants>): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
declare function CodeBlockFooter({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { CodeBlock, CodeBlockActions, CodeBlockContent, CodeBlockCopyButton, CodeBlockFooter, CodeBlockHeader, CodeBlockLine, CodeBlockTitle };
|
|
29
|
+
//# sourceMappingURL=code-block.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-block.d.cts","names":[],"sources":["../../src/primitives/code-block.tsx"],"mappings":";;;;cAOM,oBAAiB;;6CAetB;iBAEQ,YACP,WACA,SACA,SACG,SACF,MAAM,wBACP,oBAAoB;EAAuB;gCAAyB,IAAA;iBAY7D,kBAAkB,cAAc,SAAS,MAAM,oDAAqB,IAAA;iBAapE,iBAAiB,cAAc,SAAS,MAAM,oDAAqB,IAAA;iBAanE,mBACP,cACG,SACF,MAAM,oDAAqB,IAAA;iBAarB,sBACP,OACA,SACA,MACA,WACA,YACG,SACF,MAAM,sBAAsB;EAAY;gCAAe,IAAA;iBA6CjD,mBACP,WACA,UACA,OACA,MACA,aACA,cACG,SACF,MAAM;EACP;EACA;EACA;gCACD,IAAA;cAgCK,wBAAqB;;6CAe1B;iBAEQ,gBACP,WACA,SACA,aACG,SACF,MAAM,yBAAyB,oBAAoB,qDAAsB,IAAA;iBAsBnE,kBAAkB,cAAc,SAAS,MAAM,oDAAqB,IAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Button } from "./button.mjs";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { VariantProps } from "class-variance-authority";
|
|
4
|
+
//#region src/primitives/code-block.d.ts
|
|
5
|
+
declare const codeBlockVariants: (props?: ({
|
|
6
|
+
variant?: "default" | "destructive" | null | undefined;
|
|
7
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
|
+
declare function CodeBlock({ className, variant, size, ...props }: React.ComponentProps<"div"> & VariantProps<typeof codeBlockVariants> & {
|
|
9
|
+
size?: "default" | "sm";
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare function CodeBlockHeader({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
declare function CodeBlockTitle({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
declare function CodeBlockActions({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
declare function CodeBlockCopyButton({ value, variant, size, className, onClick, ...props }: React.ComponentProps<typeof Button> & {
|
|
15
|
+
value: string;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
declare function CodeBlockContent({ className, children, style, wrap, lineNumbers, startLine, ...props }: React.ComponentProps<"pre"> & {
|
|
18
|
+
wrap?: boolean;
|
|
19
|
+
lineNumbers?: boolean;
|
|
20
|
+
startLine?: number;
|
|
21
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
declare const codeBlockLineVariants: (props?: ({
|
|
23
|
+
variant?: "default" | "added" | "removed" | "highlighted" | null | undefined;
|
|
24
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
25
|
+
declare function CodeBlockLine({ className, variant, children, ...props }: React.ComponentProps<"span"> & VariantProps<typeof codeBlockLineVariants>): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
declare function CodeBlockFooter({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { CodeBlock, CodeBlockActions, CodeBlockContent, CodeBlockCopyButton, CodeBlockFooter, CodeBlockHeader, CodeBlockLine, CodeBlockTitle };
|
|
29
|
+
//# sourceMappingURL=code-block.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-block.d.mts","names":[],"sources":["../../src/primitives/code-block.tsx"],"mappings":";;;;cAOM,oBAAiB;;6CAetB;iBAEQ,YACP,WACA,SACA,SACG,SACF,MAAM,wBACP,oBAAoB;EAAuB;gCAAyB,IAAA;iBAY7D,kBAAkB,cAAc,SAAS,MAAM,oDAAqB,IAAA;iBAapE,iBAAiB,cAAc,SAAS,MAAM,oDAAqB,IAAA;iBAanE,mBACP,cACG,SACF,MAAM,oDAAqB,IAAA;iBAarB,sBACP,OACA,SACA,MACA,WACA,YACG,SACF,MAAM,sBAAsB;EAAY;gCAAe,IAAA;iBA6CjD,mBACP,WACA,UACA,OACA,MACA,aACA,cACG,SACF,MAAM;EACP;EACA;EACA;gCACD,IAAA;cAgCK,wBAAqB;;6CAe1B;iBAEQ,gBACP,WACA,SACA,aACG,SACF,MAAM,yBAAyB,oBAAoB,qDAAsB,IAAA;iBAsBnE,kBAAkB,cAAc,SAAS,MAAM,oDAAqB,IAAA"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Button } from "./button.mjs";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { cn } from "cn";
|
|
6
|
+
import { CheckIcon, CopyIcon } from "lucide-react";
|
|
7
|
+
//#region src/primitives/code-block.tsx
|
|
8
|
+
const codeBlockVariants = cva("group/code-block relative flex w-full min-w-0 flex-col overflow-hidden rounded-lg text-sm has-[>[data-slot=code-block-content]:focus-visible]:ring-3 has-[>[data-slot=code-block-content]:focus-visible]:ring-ring/50 data-[size=sm]:text-xs", {
|
|
9
|
+
variants: { variant: {
|
|
10
|
+
default: "border border-input text-foreground has-[>[data-slot=code-block-content]:focus-visible]:border-ring dark:bg-input/30",
|
|
11
|
+
destructive: "border border-destructive/30 text-destructive dark:border-destructive/40"
|
|
12
|
+
} },
|
|
13
|
+
defaultVariants: { variant: "default" }
|
|
14
|
+
});
|
|
15
|
+
function CodeBlock({ className, variant = "default", size = "default", ...props }) {
|
|
16
|
+
return /* @__PURE__ */ jsx("div", {
|
|
17
|
+
"data-slot": "code-block",
|
|
18
|
+
"data-variant": variant,
|
|
19
|
+
"data-size": size,
|
|
20
|
+
className: cn(codeBlockVariants({ variant }), className),
|
|
21
|
+
...props
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function CodeBlockHeader({ className, ...props }) {
|
|
25
|
+
return /* @__PURE__ */ jsx("div", {
|
|
26
|
+
"data-slot": "code-block-header",
|
|
27
|
+
className: cn("flex min-w-0 shrink-0 items-center gap-2 px-3 pt-3 text-muted-foreground group-data-[size=sm]/code-block:px-2.5 group-data-[size=sm]/code-block:pt-2.5 group-data-[variant=destructive]/code-block:text-destructive *:has-[>[data-slot=code-block-title]]:min-w-0", className),
|
|
28
|
+
...props
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function CodeBlockTitle({ className, ...props }) {
|
|
32
|
+
return /* @__PURE__ */ jsx("div", {
|
|
33
|
+
"data-slot": "code-block-title",
|
|
34
|
+
className: cn("min-w-0 truncate font-sans text-sm font-medium text-foreground group-data-[size=sm]/code-block:text-xs group-data-[variant=destructive]/code-block:text-destructive [&_svg]:pointer-events-none [&_svg]:inline-block [&_svg]:align-middle [&_svg:not([class*='size-'])]:size-3.5 *:[svg]:me-1.5", className),
|
|
35
|
+
...props
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function CodeBlockActions({ className, ...props }) {
|
|
39
|
+
return /* @__PURE__ */ jsx("div", {
|
|
40
|
+
"data-slot": "code-block-actions",
|
|
41
|
+
className: cn("-my-1 ms-auto -me-1.5 flex shrink-0 items-center gap-1 [[data-slot=code-block]>&]:absolute [[data-slot=code-block]>&]:end-2 [[data-slot=code-block]>&]:top-2 [[data-slot=code-block]>&]:z-10 [[data-slot=code-block]>&]:m-0 [[data-slot=code-block]>&]:opacity-0 [[data-slot=code-block]>&]:transition-opacity [[data-slot=code-block]>&]:group-focus-within/code-block:opacity-100 [[data-slot=code-block]>&]:group-hover/code-block:opacity-100 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:end-1.5 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:top-1.5 [[data-slot=code-block]>&]:pointer-coarse:opacity-100 [[data-slot=code-block]>&]:*:[button]:bg-background [[data-slot=code-block]>&]:*:[button]:ring-1 [[data-slot=code-block]>&]:*:[button]:ring-foreground/10", className),
|
|
42
|
+
...props
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function CodeBlockCopyButton({ value, variant = "ghost", size = "icon-xs", className, onClick, ...props }) {
|
|
46
|
+
const [copied, setCopied] = React.useState(false);
|
|
47
|
+
React.useEffect(() => {
|
|
48
|
+
if (!copied) return;
|
|
49
|
+
const timeout = setTimeout(() => setCopied(false), 2e3);
|
|
50
|
+
return () => clearTimeout(timeout);
|
|
51
|
+
}, [copied]);
|
|
52
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Button, {
|
|
53
|
+
"data-slot": "code-block-copy-button",
|
|
54
|
+
"data-copied": copied || void 0,
|
|
55
|
+
variant,
|
|
56
|
+
size,
|
|
57
|
+
"aria-label": copied ? "Copied" : "Copy",
|
|
58
|
+
className: cn(className),
|
|
59
|
+
onClick: (event) => {
|
|
60
|
+
onClick?.(event);
|
|
61
|
+
navigator.clipboard.writeText(value).then(() => setCopied(true)).catch(() => {});
|
|
62
|
+
},
|
|
63
|
+
...props,
|
|
64
|
+
children: copied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {})
|
|
65
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
66
|
+
"aria-live": "polite",
|
|
67
|
+
className: "sr-only",
|
|
68
|
+
children: copied ? "Copied" : ""
|
|
69
|
+
})] });
|
|
70
|
+
}
|
|
71
|
+
function CodeBlockContent({ className, children, style, wrap = false, lineNumbers = false, startLine = 1, ...props }) {
|
|
72
|
+
return /* @__PURE__ */ jsx("pre", {
|
|
73
|
+
"data-slot": "code-block-content",
|
|
74
|
+
"data-wrap": wrap || void 0,
|
|
75
|
+
"data-numbered": lineNumbers || void 0,
|
|
76
|
+
dir: "ltr",
|
|
77
|
+
tabIndex: 0,
|
|
78
|
+
style: {
|
|
79
|
+
counterReset: `line ${startLine - 1}`,
|
|
80
|
+
...style
|
|
81
|
+
},
|
|
82
|
+
className: cn("min-h-0 min-w-0 scroll-fade-x scrollbar-thin overflow-auto px-3 py-3 text-start font-mono leading-relaxed outline-none group-has-data-[slot=code-block-footer]/code-block:pb-2 group-has-data-[slot=code-block-header]/code-block:pt-2 group-data-[size=sm]/code-block:px-2.5 group-data-[size=sm]/code-block:py-2.5 group-data-[size=sm]/code-block:group-has-data-[slot=code-block-header]/code-block:pt-1.5 data-wrap:scroll-fade-y data-wrap:wrap-break-word data-wrap:whitespace-pre-wrap", className),
|
|
83
|
+
...props,
|
|
84
|
+
children: /* @__PURE__ */ jsx("code", {
|
|
85
|
+
"data-slot": "code-block-code",
|
|
86
|
+
className: "grid min-h-lh min-w-max content-start in-data-numbered:grid-cols-[auto_1fr] in-data-wrap:min-w-0",
|
|
87
|
+
children: lineNumbers && typeof children === "string" ? children.replace(/\n$/, "").split("\n").map((line, index) => /* @__PURE__ */ jsx(CodeBlockLine, { children: line }, index)) : children
|
|
88
|
+
})
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
const codeBlockLineVariants = cva("relative -mx-3 block min-h-lh px-3 group-data-[size=sm]/code-block:-mx-2.5 group-data-[size=sm]/code-block:px-2.5 before:min-w-6 before:text-end before:text-muted-foreground after:absolute after:start-1 after:top-0 after:text-muted-foreground after:select-none in-data-numbered:col-span-2 in-data-numbered:grid in-data-numbered:grid-cols-subgrid in-data-numbered:gap-x-3 in-data-numbered:[counter-increment:line] in-data-numbered:before:content-[counter(line)] in-data-numbered:before:select-none in-data-numbered:supports-[content:counter(line)_/_'']:before:content-[counter(line)_/_'']", {
|
|
92
|
+
variants: { variant: {
|
|
93
|
+
default: "",
|
|
94
|
+
added: "bg-muted after:content-['+']",
|
|
95
|
+
removed: "bg-destructive/10 after:text-destructive after:content-['−']",
|
|
96
|
+
highlighted: "bg-muted"
|
|
97
|
+
} },
|
|
98
|
+
defaultVariants: { variant: "default" }
|
|
99
|
+
});
|
|
100
|
+
function CodeBlockLine({ className, variant = "default", children, ...props }) {
|
|
101
|
+
const empty = children === void 0 || children === null || children === "" || Array.isArray(children) && children.length === 0;
|
|
102
|
+
return /* @__PURE__ */ jsx("span", {
|
|
103
|
+
"data-slot": "code-block-line",
|
|
104
|
+
"data-variant": variant,
|
|
105
|
+
className: cn(codeBlockLineVariants({ variant }), className),
|
|
106
|
+
...props,
|
|
107
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
108
|
+
"data-slot": "code-block-line-content",
|
|
109
|
+
className: "min-w-0",
|
|
110
|
+
children: empty ? "\n" : children
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function CodeBlockFooter({ className, ...props }) {
|
|
115
|
+
return /* @__PURE__ */ jsx("div", {
|
|
116
|
+
"data-slot": "code-block-footer",
|
|
117
|
+
className: cn("flex min-w-0 shrink-0 items-center gap-2 px-3 pb-3 text-muted-foreground group-data-[size=sm]/code-block:px-2.5 group-data-[size=sm]/code-block:pb-2.5", className),
|
|
118
|
+
...props
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
export { CodeBlock, CodeBlockActions, CodeBlockContent, CodeBlockCopyButton, CodeBlockFooter, CodeBlockHeader, CodeBlockLine, CodeBlockTitle };
|
|
123
|
+
|
|
124
|
+
//# sourceMappingURL=code-block.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-block.mjs","names":[],"sources":["../../src/primitives/code-block.tsx"],"sourcesContent":["import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"cn\"\n\nimport { Button } from \"@/primitives/button\"\nimport { CheckIcon, CopyIcon } from \"lucide-react\"\n\nconst codeBlockVariants = cva(\n \"group/code-block relative flex w-full min-w-0 flex-col overflow-hidden rounded-lg text-sm has-[>[data-slot=code-block-content]:focus-visible]:ring-3 has-[>[data-slot=code-block-content]:focus-visible]:ring-ring/50 data-[size=sm]:text-xs\",\n {\n variants: {\n variant: {\n default:\n \"border border-input text-foreground has-[>[data-slot=code-block-content]:focus-visible]:border-ring dark:bg-input/30\",\n destructive:\n \"border border-destructive/30 text-destructive dark:border-destructive/40\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n }\n)\n\nfunction CodeBlock({\n className,\n variant = \"default\",\n size = \"default\",\n ...props\n}: React.ComponentProps<\"div\"> &\n VariantProps<typeof codeBlockVariants> & { size?: \"default\" | \"sm\" }) {\n return (\n <div\n data-slot=\"code-block\"\n data-variant={variant}\n data-size={size}\n className={cn(codeBlockVariants({ variant }), className)}\n {...props}\n />\n )\n}\n\nfunction CodeBlockHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"code-block-header\"\n className={cn(\n \"flex min-w-0 shrink-0 items-center gap-2 px-3 pt-3 text-muted-foreground group-data-[size=sm]/code-block:px-2.5 group-data-[size=sm]/code-block:pt-2.5 group-data-[variant=destructive]/code-block:text-destructive *:has-[>[data-slot=code-block-title]]:min-w-0\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CodeBlockTitle({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"code-block-title\"\n className={cn(\n \"min-w-0 truncate font-sans text-sm font-medium text-foreground group-data-[size=sm]/code-block:text-xs group-data-[variant=destructive]/code-block:text-destructive [&_svg]:pointer-events-none [&_svg]:inline-block [&_svg]:align-middle [&_svg:not([class*='size-'])]:size-3.5 *:[svg]:me-1.5\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CodeBlockActions({\n className,\n ...props\n}: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"code-block-actions\"\n className={cn(\n \"-my-1 ms-auto -me-1.5 flex shrink-0 items-center gap-1 [[data-slot=code-block]>&]:absolute [[data-slot=code-block]>&]:end-2 [[data-slot=code-block]>&]:top-2 [[data-slot=code-block]>&]:z-10 [[data-slot=code-block]>&]:m-0 [[data-slot=code-block]>&]:opacity-0 [[data-slot=code-block]>&]:transition-opacity [[data-slot=code-block]>&]:group-focus-within/code-block:opacity-100 [[data-slot=code-block]>&]:group-hover/code-block:opacity-100 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:end-1.5 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:top-1.5 [[data-slot=code-block]>&]:pointer-coarse:opacity-100 [[data-slot=code-block]>&]:*:[button]:bg-background [[data-slot=code-block]>&]:*:[button]:ring-1 [[data-slot=code-block]>&]:*:[button]:ring-foreground/10\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CodeBlockCopyButton({\n value,\n variant = \"ghost\",\n size = \"icon-xs\",\n className,\n onClick,\n ...props\n}: React.ComponentProps<typeof Button> & { value: string }) {\n const [copied, setCopied] = React.useState(false)\n\n React.useEffect(() => {\n if (!copied) {\n return\n }\n\n const timeout = setTimeout(() => setCopied(false), 2000)\n return () => clearTimeout(timeout)\n }, [copied])\n\n return (\n <>\n <Button\n data-slot=\"code-block-copy-button\"\n data-copied={copied || undefined}\n variant={variant}\n size={size}\n aria-label={copied ? \"Copied\" : \"Copy\"}\n className={cn(className)}\n onClick={(event) => {\n onClick?.(event)\n navigator.clipboard\n .writeText(value)\n .then(() => setCopied(true))\n .catch(() => {})\n }}\n {...props}\n >\n {copied ? (\n <CheckIcon\n />\n ) : (\n <CopyIcon\n />\n )}\n </Button>\n <span aria-live=\"polite\" className=\"sr-only\">\n {copied ? \"Copied\" : \"\"}\n </span>\n </>\n )\n}\n\nfunction CodeBlockContent({\n className,\n children,\n style,\n wrap = false,\n lineNumbers = false,\n startLine = 1,\n ...props\n}: React.ComponentProps<\"pre\"> & {\n wrap?: boolean\n lineNumbers?: boolean\n startLine?: number\n}) {\n return (\n <pre\n data-slot=\"code-block-content\"\n data-wrap={wrap || undefined}\n data-numbered={lineNumbers || undefined}\n dir=\"ltr\"\n tabIndex={0}\n style={{ counterReset: `line ${startLine - 1}`, ...style }}\n className={cn(\n \"min-h-0 min-w-0 scroll-fade-x scrollbar-thin overflow-auto px-3 py-3 text-start font-mono leading-relaxed outline-none group-has-data-[slot=code-block-footer]/code-block:pb-2 group-has-data-[slot=code-block-header]/code-block:pt-2 group-data-[size=sm]/code-block:px-2.5 group-data-[size=sm]/code-block:py-2.5 group-data-[size=sm]/code-block:group-has-data-[slot=code-block-header]/code-block:pt-1.5 data-wrap:scroll-fade-y data-wrap:wrap-break-word data-wrap:whitespace-pre-wrap\",\n className\n )}\n {...props}\n >\n <code\n data-slot=\"code-block-code\"\n className=\"grid min-h-lh min-w-max content-start in-data-numbered:grid-cols-[auto_1fr] in-data-wrap:min-w-0\"\n >\n {lineNumbers && typeof children === \"string\"\n ? children\n .replace(/\\n$/, \"\")\n .split(\"\\n\")\n .map((line, index) => (\n <CodeBlockLine key={index}>{line}</CodeBlockLine>\n ))\n : children}\n </code>\n </pre>\n )\n}\n\nconst codeBlockLineVariants = cva(\n \"relative -mx-3 block min-h-lh px-3 group-data-[size=sm]/code-block:-mx-2.5 group-data-[size=sm]/code-block:px-2.5 before:min-w-6 before:text-end before:text-muted-foreground after:absolute after:start-1 after:top-0 after:text-muted-foreground after:select-none in-data-numbered:col-span-2 in-data-numbered:grid in-data-numbered:grid-cols-subgrid in-data-numbered:gap-x-3 in-data-numbered:[counter-increment:line] in-data-numbered:before:content-[counter(line)] in-data-numbered:before:select-none in-data-numbered:supports-[content:counter(line)_/_'']:before:content-[counter(line)_/_'']\",\n {\n variants: {\n variant: {\n default: \"\",\n added: \"bg-muted after:content-['+']\",\n removed: \"bg-destructive/10 after:text-destructive after:content-['−']\",\n highlighted: \"bg-muted\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n }\n)\n\nfunction CodeBlockLine({\n className,\n variant = \"default\",\n children,\n ...props\n}: React.ComponentProps<\"span\"> & VariantProps<typeof codeBlockLineVariants>) {\n // An empty line holds a newline so copying a selection keeps blank lines.\n const empty =\n children === undefined ||\n children === null ||\n children === \"\" ||\n (Array.isArray(children) && children.length === 0)\n\n return (\n <span\n data-slot=\"code-block-line\"\n data-variant={variant}\n className={cn(codeBlockLineVariants({ variant }), className)}\n {...props}\n >\n <span data-slot=\"code-block-line-content\" className=\"min-w-0\">\n {empty ? \"\\n\" : children}\n </span>\n </span>\n )\n}\n\nfunction CodeBlockFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"code-block-footer\"\n className={cn(\n \"flex min-w-0 shrink-0 items-center gap-2 px-3 pb-3 text-muted-foreground group-data-[size=sm]/code-block:px-2.5 group-data-[size=sm]/code-block:pb-2.5\",\n className\n )}\n {...props}\n />\n )\n}\n\nexport {\n CodeBlock,\n CodeBlockHeader,\n CodeBlockTitle,\n CodeBlockActions,\n CodeBlockCopyButton,\n CodeBlockContent,\n CodeBlockLine,\n CodeBlockFooter,\n}\n"],"mappings":"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"}
|
package/dist/styles/index.css
CHANGED
|
@@ -267,6 +267,22 @@
|
|
|
267
267
|
--berget-shiki-token-parameter: var(--berget-brand-granite-50);
|
|
268
268
|
--berget-shiki-token-string-expression: var(--berget-brand-moss-300);
|
|
269
269
|
--berget-shiki-token-punctuation: var(--berget-brand-granite-50);
|
|
270
|
+
--berget-shiki-ansi-black: var(--berget-brand-granite-400);
|
|
271
|
+
--berget-shiki-ansi-red: var(--berget-brand-muscaria-400);
|
|
272
|
+
--berget-shiki-ansi-green: var(--berget-brand-moss-400);
|
|
273
|
+
--berget-shiki-ansi-yellow: var(--berget-brand-chanterelle-300);
|
|
274
|
+
--berget-shiki-ansi-blue: var(--berget-brand-fjord-400);
|
|
275
|
+
--berget-shiki-ansi-magenta: var(--berget-brand-muscaria-300);
|
|
276
|
+
--berget-shiki-ansi-cyan: var(--berget-brand-fjord-300);
|
|
277
|
+
--berget-shiki-ansi-white: var(--berget-brand-granite-50);
|
|
278
|
+
--berget-shiki-ansi-bright-black: var(--berget-brand-granite-500);
|
|
279
|
+
--berget-shiki-ansi-bright-red: var(--berget-brand-muscaria-300);
|
|
280
|
+
--berget-shiki-ansi-bright-green: var(--berget-brand-moss-300);
|
|
281
|
+
--berget-shiki-ansi-bright-yellow: var(--berget-brand-chanterelle-200);
|
|
282
|
+
--berget-shiki-ansi-bright-blue: var(--berget-brand-fjord-300);
|
|
283
|
+
--berget-shiki-ansi-bright-magenta: var(--berget-brand-muscaria-200);
|
|
284
|
+
--berget-shiki-ansi-bright-cyan: var(--berget-brand-fjord-200);
|
|
285
|
+
--berget-shiki-ansi-bright-white: var(--berget-brand-granite-50);
|
|
270
286
|
|
|
271
287
|
/* ── Badge component-scoped tokens ──────────────────────────────── */
|
|
272
288
|
/* Tinted status style: 15% brand tint bg with a same-hue accent fg.
|
|
@@ -636,6 +652,22 @@
|
|
|
636
652
|
--berget-shiki-token-parameter: var(--berget-brand-granite-900);
|
|
637
653
|
--berget-shiki-token-string-expression: var(--berget-brand-moss-500);
|
|
638
654
|
--berget-shiki-token-punctuation: var(--berget-brand-granite-900);
|
|
655
|
+
--berget-shiki-ansi-black: var(--berget-brand-granite-800);
|
|
656
|
+
--berget-shiki-ansi-red: var(--berget-brand-muscaria-600);
|
|
657
|
+
--berget-shiki-ansi-green: var(--berget-brand-moss-600);
|
|
658
|
+
--berget-shiki-ansi-yellow: var(--berget-brand-chanterelle-400);
|
|
659
|
+
--berget-shiki-ansi-blue: var(--berget-brand-fjord-600);
|
|
660
|
+
--berget-shiki-ansi-magenta: var(--berget-brand-muscaria-500);
|
|
661
|
+
--berget-shiki-ansi-cyan: var(--berget-brand-fjord-500);
|
|
662
|
+
--berget-shiki-ansi-white: var(--berget-brand-granite-600);
|
|
663
|
+
--berget-shiki-ansi-bright-black: var(--berget-brand-granite-700);
|
|
664
|
+
--berget-shiki-ansi-bright-red: var(--berget-brand-muscaria-500);
|
|
665
|
+
--berget-shiki-ansi-bright-green: var(--berget-brand-moss-500);
|
|
666
|
+
--berget-shiki-ansi-bright-yellow: var(--berget-brand-chanterelle-300);
|
|
667
|
+
--berget-shiki-ansi-bright-blue: var(--berget-brand-fjord-500);
|
|
668
|
+
--berget-shiki-ansi-bright-magenta: var(--berget-brand-muscaria-400);
|
|
669
|
+
--berget-shiki-ansi-bright-cyan: var(--berget-brand-fjord-400);
|
|
670
|
+
--berget-shiki-ansi-bright-white: var(--berget-brand-granite-600);
|
|
639
671
|
|
|
640
672
|
/* ── Badge component-scoped tokens (light) ──────────────────────── */
|
|
641
673
|
--berget-badge-default-bg: color-mix(in oklch, var(--berget-brand-moss-400) 15%, transparent);
|
|
@@ -879,6 +911,16 @@
|
|
|
879
911
|
color: var(--foreground);
|
|
880
912
|
}
|
|
881
913
|
|
|
914
|
+
/* Stock shadcn universal reset (globals.css): Tailwind v4 defaults
|
|
915
|
+
border-color to currentColor, so bare border-* utilities on shadcn
|
|
916
|
+
primitives would inherit the element's text color. Shipped here so
|
|
917
|
+
consumers don't need their own reset. */
|
|
918
|
+
*,
|
|
919
|
+
::before,
|
|
920
|
+
::after {
|
|
921
|
+
@apply border-border outline-ring/50;
|
|
922
|
+
}
|
|
923
|
+
|
|
882
924
|
p,
|
|
883
925
|
h1,
|
|
884
926
|
h2,
|
|
@@ -905,6 +947,25 @@
|
|
|
905
947
|
}
|
|
906
948
|
}
|
|
907
949
|
|
|
950
|
+
/*
|
|
951
|
+
* C2. shadcn radius scale
|
|
952
|
+
*
|
|
953
|
+
* Canonical shadcn scale derived from --radius (see ui.shadcn.com/docs/theming).
|
|
954
|
+
* The primitives emit rounded-sm/md/lg/xl classes which Tailwind compiles
|
|
955
|
+
* against the CONSUMER's theme — without this scale each app would resolve
|
|
956
|
+
* them differently (or to Tailwind defaults). Shipping it here keeps
|
|
957
|
+
* primitive corner radii package-owned. @theme inline keeps the calc()
|
|
958
|
+
* in the emitted utilities so runtime --radius changes propagate.
|
|
959
|
+
* With --radius: 0.5rem this yields 4/6/8/12px — identical to the
|
|
960
|
+
* Tailwind v4 defaults, so this is a no-op for existing consumers.
|
|
961
|
+
*/
|
|
962
|
+
@theme inline {
|
|
963
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
964
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
965
|
+
--radius-lg: var(--radius);
|
|
966
|
+
--radius-xl: calc(var(--radius) + 4px);
|
|
967
|
+
}
|
|
968
|
+
|
|
908
969
|
/*
|
|
909
970
|
* D. @theme block
|
|
910
971
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bergetai/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Berget Design System - Scandinavian-inspired design system with console aesthetic",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"clsx": "^2.1.1",
|
|
53
53
|
"cmdk": "^1.1.1",
|
|
54
54
|
"cn": "^0.2.4",
|
|
55
|
+
"shadcn": "^4.22.1",
|
|
55
56
|
"tailwind-merge": "^3.5.0"
|
|
56
57
|
},
|
|
57
58
|
"peerDependencies": {
|