@nikala-ui/core 0.6.2 → 0.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nikala-ui/core",
3
- "version": "0.6.2",
3
+ "version": "0.7.0",
4
4
  "description": "Core component definitions, design tokens, and registry for Nikala UI",
5
5
  "type": "module",
6
6
  "private": false,
@@ -16,9 +16,12 @@
16
16
  },
17
17
  "devDependencies": {
18
18
  "@kobalte/core": "^0.13.12",
19
+ "@types/fs-extra": "^11.0.4",
19
20
  "class-variance-authority": "^0.7.1",
20
21
  "clsx": "^2.1.1",
21
22
  "corvu": "^0.7.2",
23
+ "fs-extra": "^11.4.0",
24
+ "picocolors": "^1.1.1",
22
25
  "solid-js": "^1.9.14",
23
26
  "tailwind-merge": "^3.6.0"
24
27
  }
@@ -293,5 +293,29 @@
293
293
  "button",
294
294
  "dropdown-menu"
295
295
  ]
296
+ },
297
+ {
298
+ "name": "toast",
299
+ "title": "Toast / Sonner",
300
+ "description": "A succinct message displayed temporarily in a toast region, built on Kobalte primitives.",
301
+ "type": "registry:ui",
302
+ "dependencies": [
303
+ "clsx",
304
+ "tailwind-merge",
305
+ "class-variance-authority",
306
+ "lucide-solid",
307
+ "@kobalte/core"
308
+ ]
309
+ },
310
+ {
311
+ "name": "tooltip",
312
+ "title": "Tooltip",
313
+ "description": "A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it, built on Kobalte primitives.",
314
+ "type": "registry:ui",
315
+ "dependencies": [
316
+ "clsx",
317
+ "tailwind-merge",
318
+ "@kobalte/core"
319
+ ]
296
320
  }
297
321
  ]
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "toast",
3
+ "title": "Toast / Sonner",
4
+ "description": "A succinct message displayed temporarily in a toast region, built on Kobalte primitives.",
5
+ "type": "registry:ui",
6
+ "dependencies": [
7
+ "clsx",
8
+ "tailwind-merge",
9
+ "class-variance-authority",
10
+ "lucide-solid",
11
+ "@kobalte/core"
12
+ ],
13
+ "files": [
14
+ {
15
+ "path": "ui/toast.tsx",
16
+ "content": "import { splitProps, type Component, type JSX, type ComponentProps } from \"solid-js\";\nimport { Toast as KobalteToast, toaster } from \"@kobalte/core/toast\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { X, CircleCheck, Info, CircleAlert, TriangleAlert } from \"lucide-solid\";\nimport { cn } from \"@/lib/cn\";\n\nexport const toastVariants = cva(\n \"group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-lg border p-4 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--kb-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--kb-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[opened]:animate-in data-[closed]:animate-out data-[swipe=end]:animate-out data-[closed]:fade-out-80 data-[closed]:slide-out-to-right-full data-[opened]:slide-in-from-top-full data-[opened]:sm:slide-in-from-bottom-full\",\n {\n variants: {\n variant: {\n default: \"border-border bg-background text-foreground\",\n success: \"border-emerald-500/20 bg-emerald-500/10 text-emerald-900 dark:text-emerald-200 border-emerald-500/30\",\n destructive: \"border-destructive/30 bg-destructive/10 text-destructive dark:text-red-300\",\n warning: \"border-amber-500/20 bg-amber-500/10 text-amber-900 dark:text-amber-200 border-amber-500/30\",\n info: \"border-sky-500/20 bg-sky-500/10 text-sky-900 dark:text-sky-200 border-sky-500/30\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n }\n);\n\nexport interface ToastProps\n extends ComponentProps<typeof KobalteToast>,\n VariantProps<typeof toastVariants> {\n class?: string;\n}\n\nexport const Toast: Component<ToastProps> = (props) => {\n const [local, rest] = splitProps(props, [\"class\", \"variant\"]);\n\n return (\n <KobalteToast\n class={cn(toastVariants({ variant: local.variant }), local.class)}\n {...rest}\n />\n );\n};\n\nexport const ToastTitle: Component<ComponentProps<typeof KobalteToast.Title>> = (props) => {\n const [local, rest] = splitProps(props, [\"class\"]);\n\n return (\n <KobalteToast.Title\n class={cn(\"text-sm font-semibold [&+div]:text-xs\", local.class)}\n {...rest}\n />\n );\n};\n\nexport const ToastDescription: Component<ComponentProps<typeof KobalteToast.Description>> = (props) => {\n const [local, rest] = splitProps(props, [\"class\"]);\n\n return (\n <KobalteToast.Description\n class={cn(\"text-sm opacity-90\", local.class)}\n {...rest}\n />\n );\n};\n\nexport const ToastCloseButton: Component<ComponentProps<typeof KobalteToast.CloseButton>> = (props) => {\n const [local, rest] = splitProps(props, [\"class\", \"children\"]);\n\n return (\n <KobalteToast.CloseButton\n class={cn(\n \"absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100\",\n local.class\n )}\n {...rest}\n >\n {local.children || <X class=\"h-4 w-4\" />}\n </KobalteToast.CloseButton>\n );\n};\n\nexport const ToastRegion: Component<ComponentProps<typeof KobalteToast.Region>> = (props) => {\n const [local, rest] = splitProps(props, [\"class\"]);\n\n return (\n <KobalteToast.Region\n class={cn(\n \"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]\",\n local.class\n )}\n {...rest}\n />\n );\n};\n\nexport const ToastList: Component<ComponentProps<typeof KobalteToast.List>> = (props) => {\n const [local, rest] = splitProps(props, [\"class\"]);\n\n return <KobalteToast.List class={cn(\"flex flex-col gap-2\", local.class)} {...rest} />;\n};\n\n/* --- Helper Function to Trigger Toast Notifications --- */\nexport interface ShowToastOptions {\n title: string;\n description?: string;\n variant?: \"default\" | \"success\" | \"destructive\" | \"warning\" | \"info\";\n duration?: number;\n}\n\nexport const showToast = (options: ShowToastOptions) => {\n return toaster.show((props) => (\n <Toast toastId={props.toastId} variant={options.variant || \"default\"}>\n <div class=\"flex items-start gap-3\">\n {options.variant === \"success\" && <CircleCheck class=\"h-5 w-5 text-emerald-500 shrink-0 mt-0.5\" />}\n {options.variant === \"destructive\" && <CircleAlert class=\"h-5 w-5 text-red-500 shrink-0 mt-0.5\" />}\n {options.variant === \"warning\" && <TriangleAlert class=\"h-5 w-5 text-amber-500 shrink-0 mt-0.5\" />}\n {options.variant === \"info\" && <Info class=\"h-5 w-5 text-sky-500 shrink-0 mt-0.5\" />}\n <div class=\"grid gap-1\">\n <ToastTitle>{options.title}</ToastTitle>\n {options.description && <ToastDescription>{options.description}</ToastDescription>}\n </div>\n </div>\n <ToastCloseButton />\n </Toast>\n ));\n};",
17
+ "type": "registry:ui"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "tooltip",
3
+ "title": "Tooltip",
4
+ "description": "A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it, built on Kobalte primitives.",
5
+ "type": "registry:ui",
6
+ "dependencies": [
7
+ "clsx",
8
+ "tailwind-merge",
9
+ "@kobalte/core"
10
+ ],
11
+ "files": [
12
+ {
13
+ "path": "ui/tooltip.tsx",
14
+ "content": "import { splitProps, type Component, type ComponentProps } from \"solid-js\";\nimport { Tooltip as KobalteTooltip } from \"@kobalte/core/tooltip\";\nimport { cn } from \"@/lib/cn\";\n\nexport const Tooltip: Component<ComponentProps<typeof KobalteTooltip>> = (props) => {\n return <KobalteTooltip gutter={4} {...props} />;\n};\n\nexport const TooltipTrigger = KobalteTooltip.Trigger;\n\nexport interface TooltipContentProps extends ComponentProps<typeof KobalteTooltip.Content> {\n class?: string;\n}\n\nexport const TooltipContent: Component<TooltipContentProps> = (props) => {\n const [local, rest] = splitProps(props, [\"class\"]);\n\n return (\n <KobalteTooltip.Portal>\n <KobalteTooltip.Content\n class={cn(\n \"z-50 overflow-hidden rounded-md border border-border bg-popover px-3 py-1.5 text-xs text-popover-foreground shadow-md transition-all animate-in fade-in-0 zoom-in-95 data-[closed]:animate-out data-[closed]:fade-out-0 data-[closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2\",\n local.class\n )}\n {...rest}\n />\n </KobalteTooltip.Portal>\n );\n};",
15
+ "type": "registry:ui"
16
+ }
17
+ ]
18
+ }
@@ -0,0 +1,124 @@
1
+ import { splitProps, type Component, type JSX, type ComponentProps } from "solid-js";
2
+ import { Toast as KobalteToast, toaster } from "@kobalte/core/toast";
3
+ import { cva, type VariantProps } from "class-variance-authority";
4
+ import { X, CircleCheck, Info, CircleAlert, TriangleAlert } from "lucide-solid";
5
+ import { cn } from "@/lib/cn";
6
+
7
+ export const toastVariants = cva(
8
+ "group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-lg border p-4 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--kb-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--kb-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[opened]:animate-in data-[closed]:animate-out data-[swipe=end]:animate-out data-[closed]:fade-out-80 data-[closed]:slide-out-to-right-full data-[opened]:slide-in-from-top-full data-[opened]:sm:slide-in-from-bottom-full",
9
+ {
10
+ variants: {
11
+ variant: {
12
+ default: "border-border bg-background text-foreground",
13
+ success: "border-emerald-500/20 bg-emerald-500/10 text-emerald-900 dark:text-emerald-200 border-emerald-500/30",
14
+ destructive: "border-destructive/30 bg-destructive/10 text-destructive dark:text-red-300",
15
+ warning: "border-amber-500/20 bg-amber-500/10 text-amber-900 dark:text-amber-200 border-amber-500/30",
16
+ info: "border-sky-500/20 bg-sky-500/10 text-sky-900 dark:text-sky-200 border-sky-500/30",
17
+ },
18
+ },
19
+ defaultVariants: {
20
+ variant: "default",
21
+ },
22
+ }
23
+ );
24
+
25
+ export interface ToastProps
26
+ extends ComponentProps<typeof KobalteToast>,
27
+ VariantProps<typeof toastVariants> {
28
+ class?: string;
29
+ }
30
+
31
+ export const Toast: Component<ToastProps> = (props) => {
32
+ const [local, rest] = splitProps(props, ["class", "variant"]);
33
+
34
+ return (
35
+ <KobalteToast
36
+ class={cn(toastVariants({ variant: local.variant }), local.class)}
37
+ {...rest}
38
+ />
39
+ );
40
+ };
41
+
42
+ export const ToastTitle: Component<ComponentProps<typeof KobalteToast.Title>> = (props) => {
43
+ const [local, rest] = splitProps(props, ["class"]);
44
+
45
+ return (
46
+ <KobalteToast.Title
47
+ class={cn("text-sm font-semibold [&+div]:text-xs", local.class)}
48
+ {...rest}
49
+ />
50
+ );
51
+ };
52
+
53
+ export const ToastDescription: Component<ComponentProps<typeof KobalteToast.Description>> = (props) => {
54
+ const [local, rest] = splitProps(props, ["class"]);
55
+
56
+ return (
57
+ <KobalteToast.Description
58
+ class={cn("text-sm opacity-90", local.class)}
59
+ {...rest}
60
+ />
61
+ );
62
+ };
63
+
64
+ export const ToastCloseButton: Component<ComponentProps<typeof KobalteToast.CloseButton>> = (props) => {
65
+ const [local, rest] = splitProps(props, ["class", "children"]);
66
+
67
+ return (
68
+ <KobalteToast.CloseButton
69
+ class={cn(
70
+ "absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100",
71
+ local.class
72
+ )}
73
+ {...rest}
74
+ >
75
+ {local.children || <X class="h-4 w-4" />}
76
+ </KobalteToast.CloseButton>
77
+ );
78
+ };
79
+
80
+ export const ToastRegion: Component<ComponentProps<typeof KobalteToast.Region>> = (props) => {
81
+ const [local, rest] = splitProps(props, ["class"]);
82
+
83
+ return (
84
+ <KobalteToast.Region
85
+ class={cn(
86
+ "fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
87
+ local.class
88
+ )}
89
+ {...rest}
90
+ />
91
+ );
92
+ };
93
+
94
+ export const ToastList: Component<ComponentProps<typeof KobalteToast.List>> = (props) => {
95
+ const [local, rest] = splitProps(props, ["class"]);
96
+
97
+ return <KobalteToast.List class={cn("flex flex-col gap-2", local.class)} {...rest} />;
98
+ };
99
+
100
+ /* --- Helper Function to Trigger Toast Notifications --- */
101
+ export interface ShowToastOptions {
102
+ title: string;
103
+ description?: string;
104
+ variant?: "default" | "success" | "destructive" | "warning" | "info";
105
+ duration?: number;
106
+ }
107
+
108
+ export const showToast = (options: ShowToastOptions) => {
109
+ return toaster.show((props) => (
110
+ <Toast toastId={props.toastId} variant={options.variant || "default"}>
111
+ <div class="flex items-start gap-3">
112
+ {options.variant === "success" && <CircleCheck class="h-5 w-5 text-emerald-500 shrink-0 mt-0.5" />}
113
+ {options.variant === "destructive" && <CircleAlert class="h-5 w-5 text-red-500 shrink-0 mt-0.5" />}
114
+ {options.variant === "warning" && <TriangleAlert class="h-5 w-5 text-amber-500 shrink-0 mt-0.5" />}
115
+ {options.variant === "info" && <Info class="h-5 w-5 text-sky-500 shrink-0 mt-0.5" />}
116
+ <div class="grid gap-1">
117
+ <ToastTitle>{options.title}</ToastTitle>
118
+ {options.description && <ToastDescription>{options.description}</ToastDescription>}
119
+ </div>
120
+ </div>
121
+ <ToastCloseButton />
122
+ </Toast>
123
+ ));
124
+ };
@@ -0,0 +1,29 @@
1
+ import { splitProps, type Component, type ComponentProps } from "solid-js";
2
+ import { Tooltip as KobalteTooltip } from "@kobalte/core/tooltip";
3
+ import { cn } from "@/lib/cn";
4
+
5
+ export const Tooltip: Component<ComponentProps<typeof KobalteTooltip>> = (props) => {
6
+ return <KobalteTooltip gutter={4} {...props} />;
7
+ };
8
+
9
+ export const TooltipTrigger = KobalteTooltip.Trigger;
10
+
11
+ export interface TooltipContentProps extends ComponentProps<typeof KobalteTooltip.Content> {
12
+ class?: string;
13
+ }
14
+
15
+ export const TooltipContent: Component<TooltipContentProps> = (props) => {
16
+ const [local, rest] = splitProps(props, ["class"]);
17
+
18
+ return (
19
+ <KobalteTooltip.Portal>
20
+ <KobalteTooltip.Content
21
+ class={cn(
22
+ "z-50 overflow-hidden rounded-md border border-border bg-popover px-3 py-1.5 text-xs text-popover-foreground shadow-md transition-all animate-in fade-in-0 zoom-in-95 data-[closed]:animate-out data-[closed]:fade-out-0 data-[closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
23
+ local.class
24
+ )}
25
+ {...rest}
26
+ />
27
+ </KobalteTooltip.Portal>
28
+ );
29
+ };
@@ -149,4 +149,14 @@ export const COMPONENT_METADATA: Record<string, ComponentMeta> = {
149
149
  ],
150
150
  registryDependencies: ["kbd", "input-group", "list"],
151
151
  },
152
+ toast: {
153
+ title: "Toast / Sonner",
154
+ description: "A succinct message displayed temporarily in a toast region, built on Kobalte primitives.",
155
+ dependencies: ["clsx", "tailwind-merge", "class-variance-authority", "lucide-solid", "@kobalte/core"],
156
+ },
157
+ tooltip: {
158
+ title: "Tooltip",
159
+ description: "A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it, built on Kobalte primitives.",
160
+ dependencies: ["clsx", "tailwind-merge", "@kobalte/core"],
161
+ },
152
162
  };