@makoai/app-sdk 2.20.0 → 2.22.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/README.md +54 -0
- package/components/alert.tsx +65 -0
- package/components/avatar.tsx +108 -0
- package/components/badge.tsx +47 -0
- package/components/button.tsx +63 -0
- package/components/card.tsx +91 -0
- package/components/collapsible.tsx +33 -0
- package/components/dialog.tsx +158 -0
- package/components/index.ts +31 -0
- package/components/input.tsx +20 -0
- package/components/label.tsx +23 -0
- package/components/popover.tsx +88 -0
- package/components/progress.tsx +30 -0
- package/components/select.tsx +189 -0
- package/components/separator.tsx +27 -0
- package/components/sheet.tsx +142 -0
- package/components/skeleton.tsx +13 -0
- package/components/slider.tsx +62 -0
- package/components/switch.tsx +34 -0
- package/components/table.tsx +115 -0
- package/components/tabs.tsx +90 -0
- package/components/toggle-group.tsx +83 -0
- package/components/toggle.tsx +46 -0
- package/components/tooltip.tsx +56 -0
- package/index.d.ts +38 -0
- package/index.js +2 -1
- package/lint.js +79 -0
- package/package.json +19 -2
- package/tailwind.css +60 -0
- package/time.js +110 -0
- package/ui.d.ts +3 -0
- package/ui.js +1 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cn } from "../menu/utils"
|
|
5
|
+
|
|
6
|
+
function Table({ className, ...props }: React.ComponentProps<"table">) {
|
|
7
|
+
return (
|
|
8
|
+
<div
|
|
9
|
+
data-slot="table-container"
|
|
10
|
+
className="relative w-full overflow-x-auto"
|
|
11
|
+
>
|
|
12
|
+
<table
|
|
13
|
+
data-slot="table"
|
|
14
|
+
className={cn("w-full caption-bottom text-sm", className)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
</div>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
|
|
22
|
+
return (
|
|
23
|
+
<thead
|
|
24
|
+
data-slot="table-header"
|
|
25
|
+
className={cn("[&_tr]:border-b", className)}
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function TableBody({ className, ...props }: React.ComponentProps<"tbody">) {
|
|
32
|
+
return (
|
|
33
|
+
<tbody
|
|
34
|
+
data-slot="table-body"
|
|
35
|
+
className={cn("[&_tr:last-child]:border-0", className)}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
|
|
42
|
+
return (
|
|
43
|
+
<tfoot
|
|
44
|
+
data-slot="table-footer"
|
|
45
|
+
className={cn(
|
|
46
|
+
"border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
|
|
47
|
+
className
|
|
48
|
+
)}
|
|
49
|
+
{...props}
|
|
50
|
+
/>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
|
|
55
|
+
return (
|
|
56
|
+
<tr
|
|
57
|
+
data-slot="table-row"
|
|
58
|
+
className={cn(
|
|
59
|
+
"border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",
|
|
60
|
+
className
|
|
61
|
+
)}
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function TableHead({ className, ...props }: React.ComponentProps<"th">) {
|
|
68
|
+
return (
|
|
69
|
+
<th
|
|
70
|
+
data-slot="table-head"
|
|
71
|
+
className={cn(
|
|
72
|
+
"h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
|
73
|
+
className
|
|
74
|
+
)}
|
|
75
|
+
{...props}
|
|
76
|
+
/>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function TableCell({ className, ...props }: React.ComponentProps<"td">) {
|
|
81
|
+
return (
|
|
82
|
+
<td
|
|
83
|
+
data-slot="table-cell"
|
|
84
|
+
className={cn(
|
|
85
|
+
"p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
|
86
|
+
className
|
|
87
|
+
)}
|
|
88
|
+
{...props}
|
|
89
|
+
/>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function TableCaption({
|
|
94
|
+
className,
|
|
95
|
+
...props
|
|
96
|
+
}: React.ComponentProps<"caption">) {
|
|
97
|
+
return (
|
|
98
|
+
<caption
|
|
99
|
+
data-slot="table-caption"
|
|
100
|
+
className={cn("mt-4 text-sm text-muted-foreground", className)}
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export {
|
|
107
|
+
Table,
|
|
108
|
+
TableHeader,
|
|
109
|
+
TableBody,
|
|
110
|
+
TableFooter,
|
|
111
|
+
TableHead,
|
|
112
|
+
TableRow,
|
|
113
|
+
TableCell,
|
|
114
|
+
TableCaption,
|
|
115
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
|
+
import { cn } from "../menu/utils"
|
|
6
|
+
import { Tabs as TabsPrimitive } from "radix-ui"
|
|
7
|
+
|
|
8
|
+
function Tabs({
|
|
9
|
+
className,
|
|
10
|
+
orientation = "horizontal",
|
|
11
|
+
...props
|
|
12
|
+
}: React.ComponentProps<typeof TabsPrimitive.Root>) {
|
|
13
|
+
return (
|
|
14
|
+
<TabsPrimitive.Root
|
|
15
|
+
data-slot="tabs"
|
|
16
|
+
data-orientation={orientation}
|
|
17
|
+
orientation={orientation}
|
|
18
|
+
className={cn(
|
|
19
|
+
"group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",
|
|
20
|
+
className
|
|
21
|
+
)}
|
|
22
|
+
{...props}
|
|
23
|
+
/>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const tabsListVariants = cva(
|
|
28
|
+
"group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none",
|
|
29
|
+
{
|
|
30
|
+
variants: {
|
|
31
|
+
variant: {
|
|
32
|
+
default: "bg-muted",
|
|
33
|
+
line: "gap-1 bg-transparent",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
defaultVariants: {
|
|
37
|
+
variant: "default",
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
function TabsList({
|
|
43
|
+
className,
|
|
44
|
+
variant = "default",
|
|
45
|
+
...props
|
|
46
|
+
}: React.ComponentProps<typeof TabsPrimitive.List> &
|
|
47
|
+
VariantProps<typeof tabsListVariants>) {
|
|
48
|
+
return (
|
|
49
|
+
<TabsPrimitive.List
|
|
50
|
+
data-slot="tabs-list"
|
|
51
|
+
data-variant={variant}
|
|
52
|
+
className={cn(tabsListVariants({ variant }), className)}
|
|
53
|
+
{...props}
|
|
54
|
+
/>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function TabsTrigger({
|
|
59
|
+
className,
|
|
60
|
+
...props
|
|
61
|
+
}: React.ComponentProps<typeof TabsPrimitive.Trigger>) {
|
|
62
|
+
return (
|
|
63
|
+
<TabsPrimitive.Trigger
|
|
64
|
+
data-slot="tabs-trigger"
|
|
65
|
+
className={cn(
|
|
66
|
+
"relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
67
|
+
"group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent",
|
|
68
|
+
"data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground",
|
|
69
|
+
"after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",
|
|
70
|
+
className
|
|
71
|
+
)}
|
|
72
|
+
{...props}
|
|
73
|
+
/>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function TabsContent({
|
|
78
|
+
className,
|
|
79
|
+
...props
|
|
80
|
+
}: React.ComponentProps<typeof TabsPrimitive.Content>) {
|
|
81
|
+
return (
|
|
82
|
+
<TabsPrimitive.Content
|
|
83
|
+
data-slot="tabs-content"
|
|
84
|
+
className={cn("flex-1 outline-none", className)}
|
|
85
|
+
{...props}
|
|
86
|
+
/>
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants }
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { type VariantProps } from "class-variance-authority"
|
|
5
|
+
import { cn } from "../menu/utils"
|
|
6
|
+
import { ToggleGroup as ToggleGroupPrimitive } from "radix-ui"
|
|
7
|
+
|
|
8
|
+
import { toggleVariants } from "./toggle"
|
|
9
|
+
|
|
10
|
+
const ToggleGroupContext = React.createContext<
|
|
11
|
+
VariantProps<typeof toggleVariants> & {
|
|
12
|
+
spacing?: number
|
|
13
|
+
}
|
|
14
|
+
>({
|
|
15
|
+
size: "default",
|
|
16
|
+
variant: "default",
|
|
17
|
+
spacing: 0,
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
function ToggleGroup({
|
|
21
|
+
className,
|
|
22
|
+
variant,
|
|
23
|
+
size,
|
|
24
|
+
spacing = 0,
|
|
25
|
+
children,
|
|
26
|
+
...props
|
|
27
|
+
}: React.ComponentProps<typeof ToggleGroupPrimitive.Root> &
|
|
28
|
+
VariantProps<typeof toggleVariants> & {
|
|
29
|
+
spacing?: number
|
|
30
|
+
}) {
|
|
31
|
+
return (
|
|
32
|
+
<ToggleGroupPrimitive.Root
|
|
33
|
+
data-slot="toggle-group"
|
|
34
|
+
data-variant={variant}
|
|
35
|
+
data-size={size}
|
|
36
|
+
data-spacing={spacing}
|
|
37
|
+
style={{ "--gap": spacing } as React.CSSProperties}
|
|
38
|
+
className={cn(
|
|
39
|
+
"group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))] rounded-md data-[spacing=default]:data-[variant=outline]:shadow-xs",
|
|
40
|
+
className
|
|
41
|
+
)}
|
|
42
|
+
{...props}
|
|
43
|
+
>
|
|
44
|
+
<ToggleGroupContext.Provider value={{ variant, size, spacing }}>
|
|
45
|
+
{children}
|
|
46
|
+
</ToggleGroupContext.Provider>
|
|
47
|
+
</ToggleGroupPrimitive.Root>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function ToggleGroupItem({
|
|
52
|
+
className,
|
|
53
|
+
children,
|
|
54
|
+
variant,
|
|
55
|
+
size,
|
|
56
|
+
...props
|
|
57
|
+
}: React.ComponentProps<typeof ToggleGroupPrimitive.Item> &
|
|
58
|
+
VariantProps<typeof toggleVariants>) {
|
|
59
|
+
const context = React.useContext(ToggleGroupContext)
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<ToggleGroupPrimitive.Item
|
|
63
|
+
data-slot="toggle-group-item"
|
|
64
|
+
data-variant={context.variant || variant}
|
|
65
|
+
data-size={context.size || size}
|
|
66
|
+
data-spacing={context.spacing}
|
|
67
|
+
className={cn(
|
|
68
|
+
toggleVariants({
|
|
69
|
+
variant: context.variant || variant,
|
|
70
|
+
size: context.size || size,
|
|
71
|
+
}),
|
|
72
|
+
"w-auto min-w-0 shrink-0 px-3 focus:z-10 focus-visible:z-10",
|
|
73
|
+
"data-[spacing=0]:rounded-none data-[spacing=0]:shadow-none data-[spacing=0]:first:rounded-l-md data-[spacing=0]:last:rounded-r-md data-[spacing=0]:data-[variant=outline]:border-l-0 data-[spacing=0]:data-[variant=outline]:first:border-l",
|
|
74
|
+
className
|
|
75
|
+
)}
|
|
76
|
+
{...props}
|
|
77
|
+
>
|
|
78
|
+
{children}
|
|
79
|
+
</ToggleGroupPrimitive.Item>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { ToggleGroup, ToggleGroupItem }
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
|
+
import { cn } from "../menu/utils"
|
|
6
|
+
import { Toggle as TogglePrimitive } from "radix-ui"
|
|
7
|
+
|
|
8
|
+
const toggleVariants = cva(
|
|
9
|
+
"inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-[color,box-shadow] outline-none hover:bg-muted hover:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
10
|
+
{
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
default: "bg-transparent",
|
|
14
|
+
outline:
|
|
15
|
+
"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground",
|
|
16
|
+
},
|
|
17
|
+
size: {
|
|
18
|
+
default: "h-9 min-w-9 px-2",
|
|
19
|
+
sm: "h-8 min-w-8 px-1.5",
|
|
20
|
+
lg: "h-10 min-w-10 px-2.5",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
variant: "default",
|
|
25
|
+
size: "default",
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
function Toggle({
|
|
31
|
+
className,
|
|
32
|
+
variant,
|
|
33
|
+
size,
|
|
34
|
+
...props
|
|
35
|
+
}: React.ComponentProps<typeof TogglePrimitive.Root> &
|
|
36
|
+
VariantProps<typeof toggleVariants>) {
|
|
37
|
+
return (
|
|
38
|
+
<TogglePrimitive.Root
|
|
39
|
+
data-slot="toggle"
|
|
40
|
+
className={cn(toggleVariants({ variant, size, className }))}
|
|
41
|
+
{...props}
|
|
42
|
+
/>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { Toggle, toggleVariants }
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cn } from "../menu/utils"
|
|
5
|
+
import { Tooltip as TooltipPrimitive } from "radix-ui"
|
|
6
|
+
|
|
7
|
+
function TooltipProvider({
|
|
8
|
+
delayDuration = 0,
|
|
9
|
+
...props
|
|
10
|
+
}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
|
|
11
|
+
return (
|
|
12
|
+
<TooltipPrimitive.Provider
|
|
13
|
+
data-slot="tooltip-provider"
|
|
14
|
+
delayDuration={delayDuration}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function Tooltip({
|
|
21
|
+
...props
|
|
22
|
+
}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
|
|
23
|
+
return <TooltipPrimitive.Root data-slot="tooltip" {...props} />
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function TooltipTrigger({
|
|
27
|
+
...props
|
|
28
|
+
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
|
|
29
|
+
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function TooltipContent({
|
|
33
|
+
className,
|
|
34
|
+
sideOffset = 0,
|
|
35
|
+
children,
|
|
36
|
+
...props
|
|
37
|
+
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
|
|
38
|
+
return (
|
|
39
|
+
<TooltipPrimitive.Portal>
|
|
40
|
+
<TooltipPrimitive.Content
|
|
41
|
+
data-slot="tooltip-content"
|
|
42
|
+
sideOffset={sideOffset}
|
|
43
|
+
className={cn(
|
|
44
|
+
"z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-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 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
|
|
45
|
+
className
|
|
46
|
+
)}
|
|
47
|
+
{...props}
|
|
48
|
+
>
|
|
49
|
+
{children}
|
|
50
|
+
<TooltipPrimitive.Arrow className="z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground" />
|
|
51
|
+
</TooltipPrimitive.Content>
|
|
52
|
+
</TooltipPrimitive.Portal>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
|
package/index.d.ts
CHANGED
|
@@ -432,3 +432,41 @@ export function hostShortcutFor(event: {
|
|
|
432
432
|
altKey: boolean;
|
|
433
433
|
shiftKey: boolean;
|
|
434
434
|
}): "mod+k" | null;
|
|
435
|
+
|
|
436
|
+
// ---------------------------------------------------------------------------
|
|
437
|
+
// Times and dates (2.21): instants in the viewer's zone, day buckets unshifted
|
|
438
|
+
// ---------------------------------------------------------------------------
|
|
439
|
+
|
|
440
|
+
/** A time value an app may hold: a Date, epoch ms, epoch µs (bigint), an ISO string, or a zone-less "YYYY-MM-DD[ hh:mm[:ss]]" read as UTC. */
|
|
441
|
+
export type TimeValue = Date | number | bigint | string | null | undefined;
|
|
442
|
+
|
|
443
|
+
/** Any time value as a Date; null when empty or unparsable. A zone-less string is UTC (DuckDB runs in UTC). */
|
|
444
|
+
export function toInstant(value: TimeValue): Date | null;
|
|
445
|
+
|
|
446
|
+
/** The UTC calendar day, "YYYY-MM-DD": the key for URL state, joins and maps. Null when unparsable. */
|
|
447
|
+
export function toDayKey(value: TimeValue): string | null;
|
|
448
|
+
|
|
449
|
+
export interface FormatTimeOptions {
|
|
450
|
+
/** "auto" (default): the date only when it is not today in the viewer's zone. */
|
|
451
|
+
date?: boolean | "auto";
|
|
452
|
+
seconds?: boolean;
|
|
453
|
+
/** Append the zone's short name ("CET"). Default true. */
|
|
454
|
+
zoneName?: boolean;
|
|
455
|
+
locale?: string;
|
|
456
|
+
/** The viewer's zone by default. Set it only for tests or an explicit "as seen from" view. */
|
|
457
|
+
timeZone?: string;
|
|
458
|
+
now?: Date;
|
|
459
|
+
}
|
|
460
|
+
/** An instant in the viewer's zone with its zone label: "14:05 CET", "18 Nov, 14:05 CET". "—" for null. */
|
|
461
|
+
export function formatTime(value: TimeValue, opts?: FormatTimeOptions): string;
|
|
462
|
+
|
|
463
|
+
export interface FormatDateOptions {
|
|
464
|
+
/** "auto" (default): the year only when it is not the current year. */
|
|
465
|
+
year?: boolean | "auto";
|
|
466
|
+
weekday?: false | "short" | "long";
|
|
467
|
+
month?: "short" | "long" | "numeric";
|
|
468
|
+
locale?: string;
|
|
469
|
+
now?: Date;
|
|
470
|
+
}
|
|
471
|
+
/** A calendar day printed with no zone shift: "18 Nov 2026". "—" for null. */
|
|
472
|
+
export function formatDate(value: TimeValue, opts?: FormatDateOptions): string;
|
package/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
readBytes,
|
|
9
9
|
readProgressStream,
|
|
10
10
|
} from "./progress.js";
|
|
11
|
+
export { formatDate, formatTime, toDayKey, toInstant } from "./time.js";
|
|
11
12
|
export {
|
|
12
13
|
BINDING_PHASES,
|
|
13
14
|
BINDING_PHASE_LABELS,
|
|
@@ -37,7 +38,7 @@ import {
|
|
|
37
38
|
* in a page (or this export) says which SDK a deployed app actually runs.
|
|
38
39
|
* Kept in step with package.json by snapshot.test.mjs.
|
|
39
40
|
*/
|
|
40
|
-
export const SDK_VERSION = "2.
|
|
41
|
+
export const SDK_VERSION = "2.22.0";
|
|
41
42
|
if (typeof window !== "undefined") {
|
|
42
43
|
try {
|
|
43
44
|
window.__MAKO_APP_SDK__ = SDK_VERSION;
|
package/lint.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// mako-app-lint (2.21): the 2 app rules a reviewer kept repeating.
|
|
3
|
+
//
|
|
4
|
+
// utc-display getUTC*, timeZone: "UTC" or toISOString().slice in display
|
|
5
|
+
// code. Instants show in the viewer's zone (formatTime), day
|
|
6
|
+
// buckets unshifted (formatDate), keys come from toDayKey.
|
|
7
|
+
// local-shadcn src/components/ui/<name>.tsx where @makoai/app-sdk ships
|
|
8
|
+
// that component (/components, /menu). Import it instead.
|
|
9
|
+
//
|
|
10
|
+
// Usage: npx mako-app-lint [app dir …] [--warn]. Exit 1 on findings unless
|
|
11
|
+
// --warn. A line ending in `// mako-lint-ignore utc-display` is skipped (a
|
|
12
|
+
// date key the helpers cannot build, with the reason on the line above).
|
|
13
|
+
import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
|
|
17
|
+
export const SDK_COMPONENTS = [
|
|
18
|
+
"alert", "avatar", "badge", "button", "card", "checkbox", "collapsible",
|
|
19
|
+
"dialog", "dropdown-menu", "input", "label", "popover", "progress",
|
|
20
|
+
"select", "separator", "sheet", "skeleton", "slider", "switch", "table",
|
|
21
|
+
"tabs", "toggle", "toggle-group", "tooltip",
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const UTC_DISPLAY = /\.getUTC(?:FullYear|Month|Date|Day|Hours|Minutes|Seconds)\(|timeZone:\s*["']UTC["']|toISOString\(\)\s*\.\s*(?:slice|substring|substr)\(/;
|
|
25
|
+
|
|
26
|
+
function walk(dir, out = []) {
|
|
27
|
+
if (!existsSync(dir)) return out;
|
|
28
|
+
for (const name of readdirSync(dir)) {
|
|
29
|
+
if (name === "node_modules" || name === "dist" || name.startsWith(".")) continue;
|
|
30
|
+
const p = path.join(dir, name);
|
|
31
|
+
if (statSync(p).isDirectory()) walk(p, out);
|
|
32
|
+
else if (/\.(m?[jt]sx?)$/.test(name) && !/\.test\./.test(name)) out.push(p);
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Findings for one app folder: { file, line, rule, message }. */
|
|
38
|
+
export function lintApp(appDir) {
|
|
39
|
+
const findings = [];
|
|
40
|
+
const src = path.join(appDir, "src");
|
|
41
|
+
for (const file of walk(src)) {
|
|
42
|
+
const rel = path.relative(appDir, file);
|
|
43
|
+
const ui = /^src[\\/]components[\\/]ui[\\/]([a-z-]+)\.tsx$/.exec(rel);
|
|
44
|
+
if (ui && SDK_COMPONENTS.includes(ui[1])) {
|
|
45
|
+
const from = ["dropdown-menu", "checkbox"].includes(ui[1]) ? "@makoai/app-sdk/menu" : "@makoai/app-sdk/components";
|
|
46
|
+
findings.push({ file: rel, line: 1, rule: "local-shadcn", message: `the SDK ships ${ui[1]}: import it from "${from}" and delete this copy` });
|
|
47
|
+
}
|
|
48
|
+
readFileSync(file, "utf8")
|
|
49
|
+
.split("\n")
|
|
50
|
+
.forEach((text, i) => {
|
|
51
|
+
if (!UTC_DISPLAY.test(text) || /mako-lint-ignore utc-display/.test(text)) return;
|
|
52
|
+
findings.push({
|
|
53
|
+
file: rel,
|
|
54
|
+
line: i + 1,
|
|
55
|
+
rule: "utc-display",
|
|
56
|
+
message: "UTC in display code: formatTime(instant) for times, formatDate(day) for day buckets, toDayKey(value) for keys",
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return findings;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function main(argv) {
|
|
64
|
+
const warn = argv.includes("--warn");
|
|
65
|
+
const dirs = argv.filter(a => !a.startsWith("--"));
|
|
66
|
+
let total = 0;
|
|
67
|
+
for (const dir of dirs.length ? dirs : ["."]) {
|
|
68
|
+
for (const f of lintApp(path.resolve(dir))) {
|
|
69
|
+
total++;
|
|
70
|
+
console.log(`${path.join(dir, f.file)}:${f.line} ${f.rule} ${f.message}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (total) console.log(`\n${total} finding${total === 1 ? "" : "s"}`);
|
|
74
|
+
return total && !warn ? 1 : 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Installed bins run through a symlink (node_modules/.bin, pnpm's .pnpm
|
|
78
|
+
// store); import.meta.url is resolved and argv[1] is not, so compare real paths.
|
|
79
|
+
if (process.argv[1] && realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url))) process.exit(main(process.argv.slice(2)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@makoai/app-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.0",
|
|
4
4
|
"description": "Mako app SDK: data bindings (useQuery/useDuckDB), URL state, theme, and the house dashboard kit (/ui).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
"type": "module",
|
|
20
20
|
"main": "./index.js",
|
|
21
21
|
"types": "./index.d.ts",
|
|
22
|
+
"bin": {
|
|
23
|
+
"mako-app-lint": "./lint.js"
|
|
24
|
+
},
|
|
22
25
|
"exports": {
|
|
23
26
|
".": {
|
|
24
27
|
"types": "./index.d.ts",
|
|
@@ -40,12 +43,19 @@
|
|
|
40
43
|
"types": "./menu/index.ts",
|
|
41
44
|
"default": "./menu/index.ts"
|
|
42
45
|
},
|
|
43
|
-
"./
|
|
46
|
+
"./components": {
|
|
47
|
+
"types": "./components/index.ts",
|
|
48
|
+
"default": "./components/index.ts"
|
|
49
|
+
},
|
|
50
|
+
"./ui.css": "./ui.css",
|
|
51
|
+
"./tailwind.css": "./tailwind.css"
|
|
44
52
|
},
|
|
45
53
|
"files": [
|
|
46
54
|
"index.js",
|
|
47
55
|
"index.d.ts",
|
|
48
56
|
"progress.js",
|
|
57
|
+
"time.js",
|
|
58
|
+
"lint.js",
|
|
49
59
|
"data-core.js",
|
|
50
60
|
"vite.js",
|
|
51
61
|
"vite.d.ts",
|
|
@@ -55,10 +65,13 @@
|
|
|
55
65
|
"ui-core.js",
|
|
56
66
|
"ui.d.ts",
|
|
57
67
|
"ui.css",
|
|
68
|
+
"tailwind.css",
|
|
58
69
|
"menu/",
|
|
70
|
+
"components/",
|
|
59
71
|
"README.md"
|
|
60
72
|
],
|
|
61
73
|
"peerDependencies": {
|
|
74
|
+
"class-variance-authority": ">=0.7",
|
|
62
75
|
"clsx": ">=2",
|
|
63
76
|
"lucide-react": ">=0.400",
|
|
64
77
|
"radix-ui": ">=1.4",
|
|
@@ -67,6 +80,9 @@
|
|
|
67
80
|
"tailwind-merge": ">=2"
|
|
68
81
|
},
|
|
69
82
|
"peerDependenciesMeta": {
|
|
83
|
+
"class-variance-authority": {
|
|
84
|
+
"optional": true
|
|
85
|
+
},
|
|
70
86
|
"clsx": {
|
|
71
87
|
"optional": true
|
|
72
88
|
},
|
|
@@ -88,6 +104,7 @@
|
|
|
88
104
|
},
|
|
89
105
|
"devDependencies": {
|
|
90
106
|
"apache-arrow": "17.0.0",
|
|
107
|
+
"class-variance-authority": "^0.7.1",
|
|
91
108
|
"clsx": "^2.1.1",
|
|
92
109
|
"esbuild": "^0.28.2",
|
|
93
110
|
"jsdom": "^30.1.2",
|
package/tailwind.css
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* @makoai/app-sdk/tailwind.css (2.21): import it after Tailwind in the app's
|
|
2
|
+
CSS (`@import "@makoai/app-sdk/tailwind.css";`). It lets Tailwind see the
|
|
3
|
+
classes of the SDK's stock shadcn components (/components, /menu) and maps
|
|
4
|
+
the house theme tokens the SDK injects (--background, --brand, …) onto
|
|
5
|
+
Tailwind's colour names, so `bg-popover` or `text-muted-foreground` follow
|
|
6
|
+
the house theme in light and dark. */
|
|
7
|
+
@source "./components";
|
|
8
|
+
@source "./menu";
|
|
9
|
+
|
|
10
|
+
@theme inline {
|
|
11
|
+
--color-background: var(--background);
|
|
12
|
+
--color-foreground: var(--foreground);
|
|
13
|
+
--color-card: var(--card);
|
|
14
|
+
--color-card-foreground: var(--card-foreground);
|
|
15
|
+
--color-popover: var(--popover);
|
|
16
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
17
|
+
--color-primary: var(--primary);
|
|
18
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
19
|
+
--color-secondary: var(--secondary);
|
|
20
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
21
|
+
--color-muted: var(--muted);
|
|
22
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
23
|
+
--color-accent: var(--accent);
|
|
24
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
25
|
+
--color-destructive: var(--destructive);
|
|
26
|
+
--color-border: var(--border);
|
|
27
|
+
--color-input: var(--input);
|
|
28
|
+
--color-ring: var(--ring);
|
|
29
|
+
--color-brand: var(--brand);
|
|
30
|
+
--color-chart-1: var(--chart-1);
|
|
31
|
+
--color-chart-2: var(--chart-2);
|
|
32
|
+
--color-chart-3: var(--chart-3);
|
|
33
|
+
--color-chart-4: var(--chart-4);
|
|
34
|
+
--color-chart-5: var(--chart-5);
|
|
35
|
+
--color-positive: var(--positive);
|
|
36
|
+
--color-negative: var(--negative);
|
|
37
|
+
--color-warning: var(--warning);
|
|
38
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
39
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
40
|
+
--radius-lg: var(--radius);
|
|
41
|
+
--radius-xl: calc(var(--radius) + 4px);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* The slice of preflight the shadcn components rely on, scoped to them, for
|
|
45
|
+
apps that load Tailwind without its preflight (the kit's ui.css keeps the
|
|
46
|
+
page's base rules). */
|
|
47
|
+
@layer base {
|
|
48
|
+
[data-slot], [data-slot] * {
|
|
49
|
+
box-sizing: border-box;
|
|
50
|
+
border: 0 solid var(--border);
|
|
51
|
+
}
|
|
52
|
+
[data-slot] button, button[data-slot] {
|
|
53
|
+
background: transparent;
|
|
54
|
+
color: inherit;
|
|
55
|
+
font: inherit;
|
|
56
|
+
margin: 0;
|
|
57
|
+
padding: 0;
|
|
58
|
+
}
|
|
59
|
+
[data-slot] table { border-collapse: collapse; }
|
|
60
|
+
}
|