@kubetail/ui 2.0.5 → 2.1.2
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/elements/link.cjs +2 -0
- package/dist/elements/link.cjs.map +1 -0
- package/dist/elements/link.d.ts +47 -0
- package/dist/elements/link.js +49 -0
- package/dist/elements/link.js.map +1 -0
- package/dist/elements/link.stories.d.ts +25 -0
- package/dist/elements/link.test.d.ts +1 -0
- package/dist/index.css +10 -10
- package/package.json +9 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/rolldown:runtime.cjs`),t=require(`../lib/utils.cjs`);let n=require(`react/jsx-runtime`),r=require(`@radix-ui/react-slot`),i=require(`class-variance-authority`);var a=(0,i.cva)(`inline-flex items-center gap-1 text-primary underline-offset-4 hover:underline transition-colors outline-none focus-visible:ring-ring/50 focus-visible:ring-[3px] rounded-sm cursor-pointer`,{variants:{variant:{default:``,external:``}},defaultVariants:{variant:`default`}}),o=null;function s(e){o=e}function c(){return o}function l({className:e,variant:i,asChild:o=!1,...s}){return(0,n.jsx)(o?r.Slot:`a`,{"data-slot":`link`,className:t.cn(a({variant:i,className:e})),...i===`external`&&!o?{target:`_blank`,rel:`noopener noreferrer`}:{},...s})}function u({className:e,variant:r,...i}){let s=o||`a`;return(0,n.jsx)(s,{"data-slot":`link`,className:t.cn(a({variant:r,className:e})),...r===`external`&&s===`a`?{target:`_blank`,rel:`noopener noreferrer`}:{},...i})}exports.Link=l,exports.RouterLink=u,exports.getLinkComponent=c,exports.linkStyles=a,exports.setLinkComponent=s;
|
|
2
|
+
//# sourceMappingURL=link.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.cjs","names":["configuredLinkComponent: LinkComponent | null"],"sources":["../../src/elements/link.tsx"],"sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nimport { cn } from '@/lib/utils';\n\nconst linkStyles = cva(\n 'inline-flex items-center gap-1 text-primary underline-offset-4 hover:underline transition-colors outline-none focus-visible:ring-ring/50 focus-visible:ring-[3px] rounded-sm cursor-pointer',\n {\n variants: {\n variant: {\n default: '',\n external: '',\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n },\n);\n\nexport type LinkVariantProps = VariantProps<typeof linkStyles>;\n\ntype LinkComponent = React.ElementType;\n\nlet configuredLinkComponent: LinkComponent | null = null;\n\n/**\n * Set a custom component to be used by `RouterLink` (e.g. your router's Link component).\n *\n * @example\n * import { setLinkComponent } from '@kubetail/ui/elements/link';\n * import { Link } from 'react-router-dom';\n * setLinkComponent(Link);\n */\nfunction setLinkComponent(component: LinkComponent) {\n configuredLinkComponent = component;\n}\n\n/**\n * Get the currently configured link component.\n */\nfunction getLinkComponent(): LinkComponent | null {\n return configuredLinkComponent;\n}\n\ntype LinkProps = React.ComponentProps<'a'> &\n LinkVariantProps & {\n asChild?: boolean;\n };\n\n/**\n * `Link` renders a styled anchor element.\n *\n * Supports `asChild` via Radix UI Slot for composition with custom components.\n *\n * @param props.variant - \"default\" | \"external\" (adds target=\"_blank\" and rel=\"noopener noreferrer\")\n * @param props.asChild - render as child element via Radix Slot\n */\nfunction Link({ className, variant, asChild = false, ...props }: LinkProps) {\n const Comp = asChild ? Slot : 'a';\n\n return (\n <Comp\n data-slot=\"link\"\n className={cn(linkStyles({ variant, className }))}\n {...(variant === 'external' && !asChild ? { target: '_blank', rel: 'noopener noreferrer' } : {})}\n {...props}\n />\n );\n}\n\ntype RouterLinkProps = Omit<LinkProps, 'asChild'> & Record<string, unknown>;\n\n/**\n * `RouterLink` renders using the component set via `setLinkComponent()`,\n * falling back to a plain `<a>` tag if none has been configured.\n *\n * @example\n * // In your app entry:\n * import { setLinkComponent } from '@kubetail/ui/elements/link';\n * import { Link as RRLink } from 'react-router-dom';\n * setLinkComponent(RRLink);\n *\n * // Then use RouterLink anywhere:\n * <RouterLink to=\"/dashboard\">Dashboard</RouterLink>\n */\nfunction RouterLink({ className, variant, ...props }: RouterLinkProps) {\n const Comp = configuredLinkComponent || 'a';\n\n return (\n <Comp\n data-slot=\"link\"\n className={cn(linkStyles({ variant, className }))}\n {...(variant === 'external' && Comp === 'a' ? { target: '_blank', rel: 'noopener noreferrer' } : {})}\n {...props}\n />\n );\n}\n\nexport { Link, RouterLink, linkStyles, setLinkComponent, getLinkComponent };\n"],"mappings":"gQAKA,IAAM,GAAA,EAAA,EAAA,KACJ,8LACA,CACE,SAAU,CACR,QAAS,CACP,QAAS,GACT,SAAU,GACX,CACF,CACD,gBAAiB,CACf,QAAS,UACV,CACF,CACF,CAMGA,EAAgD,KAUpD,SAAS,EAAiB,EAA0B,CAClD,EAA0B,EAM5B,SAAS,GAAyC,CAChD,OAAO,EAgBT,SAAS,EAAK,CAAE,YAAW,UAAS,UAAU,GAAO,GAAG,GAAoB,CAG1E,OACE,EAAA,EAAA,KAHW,EAAU,EAAA,KAAO,IAG3B,CACC,YAAU,OACV,UAAW,EAAA,GAAG,EAAW,CAAE,UAAS,YAAW,CAAC,CAAC,CACjD,GAAK,IAAY,YAAc,CAAC,EAAU,CAAE,OAAQ,SAAU,IAAK,sBAAuB,CAAG,EAAE,CAC/F,GAAI,GACJ,CAmBN,SAAS,EAAW,CAAE,YAAW,UAAS,GAAG,GAA0B,CACrE,IAAM,EAAO,GAA2B,IAExC,OACE,EAAA,EAAA,KAAC,EAAA,CACC,YAAU,OACV,UAAW,EAAA,GAAG,EAAW,CAAE,UAAS,YAAW,CAAC,CAAC,CACjD,GAAK,IAAY,YAAc,IAAS,IAAM,CAAE,OAAQ,SAAU,IAAK,sBAAuB,CAAG,EAAE,CACnG,GAAI,GACJ"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { VariantProps } from 'class-variance-authority';
|
|
2
|
+
declare const linkStyles: (props?: ({
|
|
3
|
+
variant?: "default" | "external" | null | undefined;
|
|
4
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
5
|
+
export type LinkVariantProps = VariantProps<typeof linkStyles>;
|
|
6
|
+
type LinkComponent = React.ElementType;
|
|
7
|
+
/**
|
|
8
|
+
* Set a custom component to be used by `RouterLink` (e.g. your router's Link component).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { setLinkComponent } from '@kubetail/ui/elements/link';
|
|
12
|
+
* import { Link } from 'react-router-dom';
|
|
13
|
+
* setLinkComponent(Link);
|
|
14
|
+
*/
|
|
15
|
+
declare function setLinkComponent(component: LinkComponent): void;
|
|
16
|
+
/**
|
|
17
|
+
* Get the currently configured link component.
|
|
18
|
+
*/
|
|
19
|
+
declare function getLinkComponent(): LinkComponent | null;
|
|
20
|
+
type LinkProps = React.ComponentProps<'a'> & LinkVariantProps & {
|
|
21
|
+
asChild?: boolean;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* `Link` renders a styled anchor element.
|
|
25
|
+
*
|
|
26
|
+
* Supports `asChild` via Radix UI Slot for composition with custom components.
|
|
27
|
+
*
|
|
28
|
+
* @param props.variant - "default" | "external" (adds target="_blank" and rel="noopener noreferrer")
|
|
29
|
+
* @param props.asChild - render as child element via Radix Slot
|
|
30
|
+
*/
|
|
31
|
+
declare function Link({ className, variant, asChild, ...props }: LinkProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
type RouterLinkProps = Omit<LinkProps, 'asChild'> & Record<string, unknown>;
|
|
33
|
+
/**
|
|
34
|
+
* `RouterLink` renders using the component set via `setLinkComponent()`,
|
|
35
|
+
* falling back to a plain `<a>` tag if none has been configured.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // In your app entry:
|
|
39
|
+
* import { setLinkComponent } from '@kubetail/ui/elements/link';
|
|
40
|
+
* import { Link as RRLink } from 'react-router-dom';
|
|
41
|
+
* setLinkComponent(RRLink);
|
|
42
|
+
*
|
|
43
|
+
* // Then use RouterLink anywhere:
|
|
44
|
+
* <RouterLink to="/dashboard">Dashboard</RouterLink>
|
|
45
|
+
*/
|
|
46
|
+
declare function RouterLink({ className, variant, ...props }: RouterLinkProps): import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
export { Link, RouterLink, linkStyles, setLinkComponent, getLinkComponent };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { cn } from "../lib/utils.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
var linkStyles = cva("inline-flex items-center gap-1 text-primary underline-offset-4 hover:underline transition-colors outline-none focus-visible:ring-ring/50 focus-visible:ring-[3px] rounded-sm cursor-pointer", {
|
|
6
|
+
variants: { variant: {
|
|
7
|
+
default: "",
|
|
8
|
+
external: ""
|
|
9
|
+
} },
|
|
10
|
+
defaultVariants: { variant: "default" }
|
|
11
|
+
}), configuredLinkComponent = null;
|
|
12
|
+
function setLinkComponent(e) {
|
|
13
|
+
configuredLinkComponent = e;
|
|
14
|
+
}
|
|
15
|
+
function getLinkComponent() {
|
|
16
|
+
return configuredLinkComponent;
|
|
17
|
+
}
|
|
18
|
+
function Link({ className: o, variant: s, asChild: c = !1, ...l }) {
|
|
19
|
+
return /* @__PURE__ */ jsx(c ? Slot : "a", {
|
|
20
|
+
"data-slot": "link",
|
|
21
|
+
className: cn(linkStyles({
|
|
22
|
+
variant: s,
|
|
23
|
+
className: o
|
|
24
|
+
})),
|
|
25
|
+
...s === "external" && !c ? {
|
|
26
|
+
target: "_blank",
|
|
27
|
+
rel: "noopener noreferrer"
|
|
28
|
+
} : {},
|
|
29
|
+
...l
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function RouterLink({ className: a, variant: o, ...c }) {
|
|
33
|
+
let l = configuredLinkComponent || "a";
|
|
34
|
+
return /* @__PURE__ */ jsx(l, {
|
|
35
|
+
"data-slot": "link",
|
|
36
|
+
className: cn(linkStyles({
|
|
37
|
+
variant: o,
|
|
38
|
+
className: a
|
|
39
|
+
})),
|
|
40
|
+
...o === "external" && l === "a" ? {
|
|
41
|
+
target: "_blank",
|
|
42
|
+
rel: "noopener noreferrer"
|
|
43
|
+
} : {},
|
|
44
|
+
...c
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export { Link, RouterLink, getLinkComponent, linkStyles, setLinkComponent };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.js","names":["configuredLinkComponent: LinkComponent | null"],"sources":["../../src/elements/link.tsx"],"sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nimport { cn } from '@/lib/utils';\n\nconst linkStyles = cva(\n 'inline-flex items-center gap-1 text-primary underline-offset-4 hover:underline transition-colors outline-none focus-visible:ring-ring/50 focus-visible:ring-[3px] rounded-sm cursor-pointer',\n {\n variants: {\n variant: {\n default: '',\n external: '',\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n },\n);\n\nexport type LinkVariantProps = VariantProps<typeof linkStyles>;\n\ntype LinkComponent = React.ElementType;\n\nlet configuredLinkComponent: LinkComponent | null = null;\n\n/**\n * Set a custom component to be used by `RouterLink` (e.g. your router's Link component).\n *\n * @example\n * import { setLinkComponent } from '@kubetail/ui/elements/link';\n * import { Link } from 'react-router-dom';\n * setLinkComponent(Link);\n */\nfunction setLinkComponent(component: LinkComponent) {\n configuredLinkComponent = component;\n}\n\n/**\n * Get the currently configured link component.\n */\nfunction getLinkComponent(): LinkComponent | null {\n return configuredLinkComponent;\n}\n\ntype LinkProps = React.ComponentProps<'a'> &\n LinkVariantProps & {\n asChild?: boolean;\n };\n\n/**\n * `Link` renders a styled anchor element.\n *\n * Supports `asChild` via Radix UI Slot for composition with custom components.\n *\n * @param props.variant - \"default\" | \"external\" (adds target=\"_blank\" and rel=\"noopener noreferrer\")\n * @param props.asChild - render as child element via Radix Slot\n */\nfunction Link({ className, variant, asChild = false, ...props }: LinkProps) {\n const Comp = asChild ? Slot : 'a';\n\n return (\n <Comp\n data-slot=\"link\"\n className={cn(linkStyles({ variant, className }))}\n {...(variant === 'external' && !asChild ? { target: '_blank', rel: 'noopener noreferrer' } : {})}\n {...props}\n />\n );\n}\n\ntype RouterLinkProps = Omit<LinkProps, 'asChild'> & Record<string, unknown>;\n\n/**\n * `RouterLink` renders using the component set via `setLinkComponent()`,\n * falling back to a plain `<a>` tag if none has been configured.\n *\n * @example\n * // In your app entry:\n * import { setLinkComponent } from '@kubetail/ui/elements/link';\n * import { Link as RRLink } from 'react-router-dom';\n * setLinkComponent(RRLink);\n *\n * // Then use RouterLink anywhere:\n * <RouterLink to=\"/dashboard\">Dashboard</RouterLink>\n */\nfunction RouterLink({ className, variant, ...props }: RouterLinkProps) {\n const Comp = configuredLinkComponent || 'a';\n\n return (\n <Comp\n data-slot=\"link\"\n className={cn(linkStyles({ variant, className }))}\n {...(variant === 'external' && Comp === 'a' ? { target: '_blank', rel: 'noopener noreferrer' } : {})}\n {...props}\n />\n );\n}\n\nexport { Link, RouterLink, linkStyles, setLinkComponent, getLinkComponent };\n"],"mappings":";;;;AAKA,IAAM,aAAa,IACjB,+LACA;CACE,UAAU,EACR,SAAS;EACP,SAAS;EACT,UAAU;EACX,EACF;CACD,iBAAiB,EACf,SAAS,WACV;CACF,CACF,EAMGA,0BAAgD;AAUpD,SAAS,iBAAiB,GAA0B;AAClD,2BAA0B;;AAM5B,SAAS,mBAAyC;AAChD,QAAO;;AAgBT,SAAS,KAAK,EAAE,cAAW,YAAS,aAAU,IAAO,GAAG,KAAoB;AAG1E,QACE,oBAHW,IAAU,OAAO,KAG3B;EACC,aAAU;EACV,WAAW,GAAG,WAAW;GAAE;GAAS;GAAW,CAAC,CAAC;EACjD,GAAK,MAAY,cAAc,CAAC,IAAU;GAAE,QAAQ;GAAU,KAAK;GAAuB,GAAG,EAAE;EAC/F,GAAI;GACJ;;AAmBN,SAAS,WAAW,EAAE,cAAW,YAAS,GAAG,KAA0B;CACrE,IAAM,IAAO,2BAA2B;AAExC,QACE,oBAAC,GAAA;EACC,aAAU;EACV,WAAW,GAAG,WAAW;GAAE;GAAS;GAAW,CAAC,CAAC;EACjD,GAAK,MAAY,cAAc,MAAS,MAAM;GAAE,QAAQ;GAAU,KAAK;GAAuB,GAAG,EAAE;EACnG,GAAI;GACJ"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { Link } from './link';
|
|
3
|
+
declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
tags: string[];
|
|
6
|
+
component: typeof Link;
|
|
7
|
+
parameters: {
|
|
8
|
+
docs: {
|
|
9
|
+
description: {
|
|
10
|
+
component: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
argTypes: {
|
|
15
|
+
children: {
|
|
16
|
+
control: "text";
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export default meta;
|
|
21
|
+
type Story = StoryObj<typeof meta>;
|
|
22
|
+
export declare const Default: Story;
|
|
23
|
+
export declare const External: Story;
|
|
24
|
+
export declare const CustomColor: Story;
|
|
25
|
+
export declare const AsChild: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.css
CHANGED
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
--chart-5: oklch(0.769 0.188 70.08);
|
|
30
30
|
--radius: 0.625rem;
|
|
31
31
|
--sidebar: var(--color-zinc-200);
|
|
32
|
-
--sidebar-foreground: var(--
|
|
32
|
+
--sidebar-foreground: var(--color-zinc-950);
|
|
33
33
|
--sidebar-primary: var(--primary);
|
|
34
34
|
--sidebar-primary-foreground: var(--primary-foreground);
|
|
35
|
-
--sidebar-accent: var(--color-
|
|
36
|
-
--sidebar-accent-foreground: var(--
|
|
35
|
+
--sidebar-accent: var(--color-blue-200);
|
|
36
|
+
--sidebar-accent-foreground: var(--color-blue-900);
|
|
37
37
|
--sidebar-border: var(--color-zinc-300);
|
|
38
|
-
--sidebar-ring: var(--
|
|
38
|
+
--sidebar-ring: var(--color-blue-500);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
.dark {
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
--popover-foreground: var(--color-white);
|
|
48
48
|
--primary: var(--color-blue-500); /* color-bg-primary */
|
|
49
49
|
--primary-foreground: var(--color-white); /* color-text-on-color */
|
|
50
|
-
--secondary: var(--color-zinc-
|
|
50
|
+
--secondary: var(--color-zinc-800); /* color-bg-secondary */
|
|
51
51
|
--secondary-foreground: var(--color-zinc-50); /* color-text */
|
|
52
52
|
--muted: var(--color-zinc-900); /* color-bg-subtle */
|
|
53
53
|
--muted-foreground: var(--color-zinc-400); /* color-text-muted */
|
|
54
|
-
--accent: var(--color-blue-
|
|
54
|
+
--accent: var(--color-blue-950);
|
|
55
55
|
--accent-foreground: var(--color-white);
|
|
56
56
|
--destructive: var(--color-red-400); /* color-bg-error-strong */
|
|
57
57
|
--destructive-foreground: var(--color-zinc-50); /* color-text */
|
|
@@ -64,13 +64,13 @@
|
|
|
64
64
|
--chart-4: oklch(0.627 0.265 303.9);
|
|
65
65
|
--chart-5: oklch(0.645 0.246 16.439);
|
|
66
66
|
--sidebar: var(--color-zinc-950);
|
|
67
|
-
--sidebar-foreground: var(--
|
|
67
|
+
--sidebar-foreground: var(--color-zinc-50);
|
|
68
68
|
--sidebar-primary: var(--primary);
|
|
69
69
|
--sidebar-primary-foreground: var(--primary-foreground);
|
|
70
|
-
--sidebar-accent: var(--color-
|
|
71
|
-
--sidebar-accent-foreground: var(--
|
|
70
|
+
--sidebar-accent: var(--color-blue-800);
|
|
71
|
+
--sidebar-accent-foreground: var(--color-zinc-50);
|
|
72
72
|
--sidebar-border: var(--color-zinc-700);
|
|
73
|
-
--sidebar-ring: var(--
|
|
73
|
+
--sidebar-ring: var(--color-blue-500);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
@theme inline {
|
package/package.json
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubetail/ui",
|
|
3
|
-
"version": "v2.
|
|
3
|
+
"version": "v2.1.2",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/kubetail-org/kubetail-ui"
|
|
7
|
+
},
|
|
4
8
|
"type": "module",
|
|
5
9
|
"sideEffects": false,
|
|
6
10
|
"module": "./dist/index.js",
|
|
@@ -19,6 +23,10 @@
|
|
|
19
23
|
"import": "./dist/elements/*.js",
|
|
20
24
|
"require": "./dist/elements/*.cjs"
|
|
21
25
|
},
|
|
26
|
+
"./lib*": {
|
|
27
|
+
"import": "./dist/lib/*.js",
|
|
28
|
+
"require": "./dist/elements/*.cjs"
|
|
29
|
+
},
|
|
22
30
|
"./package.json": "./package.json"
|
|
23
31
|
},
|
|
24
32
|
"style": "./dist/index.css",
|