@makoai/app-sdk 2.20.0 → 2.21.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 +51 -0
- package/components/badge.tsx +47 -0
- package/components/button.tsx +63 -0
- package/components/card.tsx +91 -0
- package/components/dialog.tsx +158 -0
- package/components/index.ts +19 -0
- package/components/input.tsx +20 -0
- package/components/popover.tsx +88 -0
- package/components/separator.tsx +27 -0
- package/components/skeleton.tsx +13 -0
- package/components/tabs.tsx +90 -0
- package/components/tooltip.tsx +56 -0
- package/index.d.ts +38 -0
- package/index.js +2 -1
- package/lint.js +77 -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
package/README.md
CHANGED
|
@@ -541,6 +541,57 @@ classes. Add one line to the app's CSS, after the Tailwind imports:
|
|
|
541
541
|
@source "../node_modules/@makoai/app-sdk/menu";
|
|
542
542
|
```
|
|
543
543
|
|
|
544
|
+
### shadcn/ui: `@makoai/app-sdk/components` (2.21)
|
|
545
|
+
|
|
546
|
+
Stock shadcn/ui new-york-v4, as the shadcn registry ships it: `Badge`,
|
|
547
|
+
`Button`, `Card`, `Dialog`, `Input`, `Popover`, `Separator`, `Skeleton`,
|
|
548
|
+
`Tabs`, `Tooltip`, plus `DropdownMenu` and `Checkbox` (one copy, in
|
|
549
|
+
`/menu`, re-exported here). Only the `cn` import path differs from the
|
|
550
|
+
registry. Never keep a `src/components/ui/` copy of one of them; a missing
|
|
551
|
+
component or prop is an SDK pull request.
|
|
552
|
+
|
|
553
|
+
```css
|
|
554
|
+
/* src/index.css, after Tailwind */
|
|
555
|
+
@import "@makoai/app-sdk/tailwind.css";
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
`tailwind.css` lets Tailwind see the SDK's classes (`@source`) and maps the
|
|
559
|
+
house tokens onto Tailwind's colour names (`bg-popover`,
|
|
560
|
+
`text-muted-foreground`, `bg-brand`, `--radius-*`). It replaces the
|
|
561
|
+
`@theme inline` block each app pasted. The shadcn stack (`radix-ui`,
|
|
562
|
+
`lucide-react`, `clsx`, `tailwind-merge`, `class-variance-authority`) is an
|
|
563
|
+
optional peer set: apps that import neither `/components` nor `/menu` need
|
|
564
|
+
none of it.
|
|
565
|
+
|
|
566
|
+
### Times and dates (2.21)
|
|
567
|
+
|
|
568
|
+
DuckDB runs in UTC, and that stays. Display code decides the zone.
|
|
569
|
+
|
|
570
|
+
```ts
|
|
571
|
+
import { formatDate, formatTime, toDayKey } from "@makoai/app-sdk";
|
|
572
|
+
|
|
573
|
+
formatTime(row.updated_at); // "14:05 CET", "17 Nov, 14:05 CET": the viewer's zone, labelled
|
|
574
|
+
formatDate(row.day); // "18 Nov": a day bucket, never shifted by the viewer's zone
|
|
575
|
+
toDayKey(new Date()); // "2026-11-18": the UTC key for URL state and joins
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
- `formatTime` reads a zone-less timestamp ("2026-11-18 13:05:00", how
|
|
579
|
+
DuckDB renders `TIMESTAMP`) as UTC. It shows the date when the instant
|
|
580
|
+
is not today in the viewer's zone, and the year when it is not this year.
|
|
581
|
+
- `formatDate` takes a "YYYY-MM-DD" string or a parquet `date` (its UTC
|
|
582
|
+
midnight) and prints that calendar day in every zone.
|
|
583
|
+
- `toInstant` turns any of these, epoch ms or epoch µs (bigint), into a `Date`.
|
|
584
|
+
|
|
585
|
+
### Lint: `npx mako-app-lint` (2.21)
|
|
586
|
+
|
|
587
|
+
Run it in an app folder (or pass several). It exits 1 on a finding;
|
|
588
|
+
`--warn` only prints.
|
|
589
|
+
|
|
590
|
+
- `utc-display`: `getUTC*`, `timeZone: "UTC"` or `toISOString().slice` in
|
|
591
|
+
`src/`. A date key the helpers cannot build takes
|
|
592
|
+
`// mako-lint-ignore utc-display` on its line.
|
|
593
|
+
- `local-shadcn`: a `src/components/ui/<name>.tsx` the SDK ships.
|
|
594
|
+
|
|
544
595
|
### Chart tooltips: `TableTooltip` (2.10+, every series from 2.15)
|
|
545
596
|
|
|
546
597
|
Every chart tooltip is a table, never recharts' coloured `name : value` list:
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
|
+
import { cn } from "../menu/utils"
|
|
4
|
+
import { Slot } from "radix-ui"
|
|
5
|
+
|
|
6
|
+
const badgeVariants = cva(
|
|
7
|
+
"inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: "bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
|
|
12
|
+
secondary:
|
|
13
|
+
"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
|
|
14
|
+
destructive:
|
|
15
|
+
"bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",
|
|
16
|
+
outline:
|
|
17
|
+
"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
|
18
|
+
ghost: "[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
|
19
|
+
link: "text-primary underline-offset-4 [a&]:hover:underline",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
variant: "default",
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
function Badge({
|
|
29
|
+
className,
|
|
30
|
+
variant = "default",
|
|
31
|
+
asChild = false,
|
|
32
|
+
...props
|
|
33
|
+
}: React.ComponentProps<"span"> &
|
|
34
|
+
VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
|
|
35
|
+
const Comp = asChild ? Slot.Root : "span"
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Comp
|
|
39
|
+
data-slot="badge"
|
|
40
|
+
data-variant={variant}
|
|
41
|
+
className={cn(badgeVariants({ variant }), className)}
|
|
42
|
+
{...props}
|
|
43
|
+
/>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { Badge, badgeVariants }
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
|
+
import { cn } from "../menu/utils"
|
|
4
|
+
import { Slot } from "radix-ui"
|
|
5
|
+
|
|
6
|
+
const buttonVariants = cva(
|
|
7
|
+
"inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none 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 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
12
|
+
destructive:
|
|
13
|
+
"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",
|
|
14
|
+
outline:
|
|
15
|
+
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
16
|
+
secondary:
|
|
17
|
+
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
18
|
+
ghost:
|
|
19
|
+
"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
20
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
21
|
+
},
|
|
22
|
+
size: {
|
|
23
|
+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
24
|
+
xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
25
|
+
sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
|
|
26
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
27
|
+
icon: "size-9",
|
|
28
|
+
"icon-xs": "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
|
|
29
|
+
"icon-sm": "size-8",
|
|
30
|
+
"icon-lg": "size-10",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
defaultVariants: {
|
|
34
|
+
variant: "default",
|
|
35
|
+
size: "default",
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
function Button({
|
|
41
|
+
className,
|
|
42
|
+
variant = "default",
|
|
43
|
+
size = "default",
|
|
44
|
+
asChild = false,
|
|
45
|
+
...props
|
|
46
|
+
}: React.ComponentProps<"button"> &
|
|
47
|
+
VariantProps<typeof buttonVariants> & {
|
|
48
|
+
asChild?: boolean
|
|
49
|
+
}) {
|
|
50
|
+
const Comp = asChild ? Slot.Root : "button"
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<Comp
|
|
54
|
+
data-slot="button"
|
|
55
|
+
data-variant={variant}
|
|
56
|
+
data-size={size}
|
|
57
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
58
|
+
{...props}
|
|
59
|
+
/>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { Button, buttonVariants }
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cn } from "../menu/utils"
|
|
3
|
+
|
|
4
|
+
function Card({ className, ...props }: React.ComponentProps<"div">) {
|
|
5
|
+
return (
|
|
6
|
+
<div
|
|
7
|
+
data-slot="card"
|
|
8
|
+
className={cn(
|
|
9
|
+
"flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",
|
|
10
|
+
className
|
|
11
|
+
)}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
data-slot="card-header"
|
|
21
|
+
className={cn(
|
|
22
|
+
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
|
|
23
|
+
className
|
|
24
|
+
)}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
31
|
+
return (
|
|
32
|
+
<div
|
|
33
|
+
data-slot="card-title"
|
|
34
|
+
className={cn("leading-none font-semibold", className)}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
data-slot="card-description"
|
|
44
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
45
|
+
{...props}
|
|
46
|
+
/>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
data-slot="card-action"
|
|
54
|
+
className={cn(
|
|
55
|
+
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
|
56
|
+
className
|
|
57
|
+
)}
|
|
58
|
+
{...props}
|
|
59
|
+
/>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
64
|
+
return (
|
|
65
|
+
<div
|
|
66
|
+
data-slot="card-content"
|
|
67
|
+
className={cn("px-6", className)}
|
|
68
|
+
{...props}
|
|
69
|
+
/>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
74
|
+
return (
|
|
75
|
+
<div
|
|
76
|
+
data-slot="card-footer"
|
|
77
|
+
className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
|
|
78
|
+
{...props}
|
|
79
|
+
/>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export {
|
|
84
|
+
Card,
|
|
85
|
+
CardHeader,
|
|
86
|
+
CardFooter,
|
|
87
|
+
CardTitle,
|
|
88
|
+
CardAction,
|
|
89
|
+
CardDescription,
|
|
90
|
+
CardContent,
|
|
91
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cn } from "../menu/utils"
|
|
5
|
+
import { XIcon } from "lucide-react"
|
|
6
|
+
import { Dialog as DialogPrimitive } from "radix-ui"
|
|
7
|
+
|
|
8
|
+
import { Button } from "./button"
|
|
9
|
+
|
|
10
|
+
function Dialog({
|
|
11
|
+
...props
|
|
12
|
+
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
|
13
|
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function DialogTrigger({
|
|
17
|
+
...props
|
|
18
|
+
}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
|
19
|
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function DialogPortal({
|
|
23
|
+
...props
|
|
24
|
+
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
|
25
|
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function DialogClose({
|
|
29
|
+
...props
|
|
30
|
+
}: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
|
31
|
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function DialogOverlay({
|
|
35
|
+
className,
|
|
36
|
+
...props
|
|
37
|
+
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
|
38
|
+
return (
|
|
39
|
+
<DialogPrimitive.Overlay
|
|
40
|
+
data-slot="dialog-overlay"
|
|
41
|
+
className={cn(
|
|
42
|
+
"fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
|
|
43
|
+
className
|
|
44
|
+
)}
|
|
45
|
+
{...props}
|
|
46
|
+
/>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function DialogContent({
|
|
51
|
+
className,
|
|
52
|
+
children,
|
|
53
|
+
showCloseButton = true,
|
|
54
|
+
...props
|
|
55
|
+
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
56
|
+
showCloseButton?: boolean
|
|
57
|
+
}) {
|
|
58
|
+
return (
|
|
59
|
+
<DialogPortal data-slot="dialog-portal">
|
|
60
|
+
<DialogOverlay />
|
|
61
|
+
<DialogPrimitive.Content
|
|
62
|
+
data-slot="dialog-content"
|
|
63
|
+
className={cn(
|
|
64
|
+
"fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",
|
|
65
|
+
className
|
|
66
|
+
)}
|
|
67
|
+
{...props}
|
|
68
|
+
>
|
|
69
|
+
{children}
|
|
70
|
+
{showCloseButton && (
|
|
71
|
+
<DialogPrimitive.Close
|
|
72
|
+
data-slot="dialog-close"
|
|
73
|
+
className="absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
|
74
|
+
>
|
|
75
|
+
<XIcon />
|
|
76
|
+
<span className="sr-only">Close</span>
|
|
77
|
+
</DialogPrimitive.Close>
|
|
78
|
+
)}
|
|
79
|
+
</DialogPrimitive.Content>
|
|
80
|
+
</DialogPortal>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
85
|
+
return (
|
|
86
|
+
<div
|
|
87
|
+
data-slot="dialog-header"
|
|
88
|
+
className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
|
|
89
|
+
{...props}
|
|
90
|
+
/>
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function DialogFooter({
|
|
95
|
+
className,
|
|
96
|
+
showCloseButton = false,
|
|
97
|
+
children,
|
|
98
|
+
...props
|
|
99
|
+
}: React.ComponentProps<"div"> & {
|
|
100
|
+
showCloseButton?: boolean
|
|
101
|
+
}) {
|
|
102
|
+
return (
|
|
103
|
+
<div
|
|
104
|
+
data-slot="dialog-footer"
|
|
105
|
+
className={cn(
|
|
106
|
+
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
|
107
|
+
className
|
|
108
|
+
)}
|
|
109
|
+
{...props}
|
|
110
|
+
>
|
|
111
|
+
{children}
|
|
112
|
+
{showCloseButton && (
|
|
113
|
+
<DialogPrimitive.Close asChild>
|
|
114
|
+
<Button variant="outline">Close</Button>
|
|
115
|
+
</DialogPrimitive.Close>
|
|
116
|
+
)}
|
|
117
|
+
</div>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function DialogTitle({
|
|
122
|
+
className,
|
|
123
|
+
...props
|
|
124
|
+
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
|
125
|
+
return (
|
|
126
|
+
<DialogPrimitive.Title
|
|
127
|
+
data-slot="dialog-title"
|
|
128
|
+
className={cn("text-lg leading-none font-semibold", className)}
|
|
129
|
+
{...props}
|
|
130
|
+
/>
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function DialogDescription({
|
|
135
|
+
className,
|
|
136
|
+
...props
|
|
137
|
+
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
|
138
|
+
return (
|
|
139
|
+
<DialogPrimitive.Description
|
|
140
|
+
data-slot="dialog-description"
|
|
141
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
142
|
+
{...props}
|
|
143
|
+
/>
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export {
|
|
148
|
+
Dialog,
|
|
149
|
+
DialogClose,
|
|
150
|
+
DialogContent,
|
|
151
|
+
DialogDescription,
|
|
152
|
+
DialogFooter,
|
|
153
|
+
DialogHeader,
|
|
154
|
+
DialogOverlay,
|
|
155
|
+
DialogPortal,
|
|
156
|
+
DialogTitle,
|
|
157
|
+
DialogTrigger,
|
|
158
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// @makoai/app-sdk/components (2.21): stock shadcn/ui (new-york-v4, as
|
|
2
|
+
// shipped by the shadcn registry; only the `cn` import path changed). One
|
|
3
|
+
// copy per component: DropdownMenu and Checkbox live in ../menu and are
|
|
4
|
+
// re-exported here. A missing component or prop is an SDK pull request,
|
|
5
|
+
// never an app copy. TypeScript source: the app's Vite compiles it, and the
|
|
6
|
+
// app's CSS imports "@makoai/app-sdk/tailwind.css" so Tailwind sees it.
|
|
7
|
+
export * from "./badge";
|
|
8
|
+
export * from "./button";
|
|
9
|
+
export * from "./card";
|
|
10
|
+
export * from "./dialog";
|
|
11
|
+
export * from "./input";
|
|
12
|
+
export * from "./popover";
|
|
13
|
+
export * from "./separator";
|
|
14
|
+
export * from "./skeleton";
|
|
15
|
+
export * from "./tabs";
|
|
16
|
+
export * from "./tooltip";
|
|
17
|
+
export * from "../menu/dropdown-menu";
|
|
18
|
+
export { Checkbox } from "../menu/checkbox";
|
|
19
|
+
export { cn } from "../menu/utils";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cn } from "../menu/utils"
|
|
3
|
+
|
|
4
|
+
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
|
5
|
+
return (
|
|
6
|
+
<input
|
|
7
|
+
type={type}
|
|
8
|
+
data-slot="input"
|
|
9
|
+
className={cn(
|
|
10
|
+
"h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30",
|
|
11
|
+
"focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
|
|
12
|
+
"aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",
|
|
13
|
+
className
|
|
14
|
+
)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { Input }
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cn } from "../menu/utils"
|
|
5
|
+
import { Popover as PopoverPrimitive } from "radix-ui"
|
|
6
|
+
|
|
7
|
+
function Popover({
|
|
8
|
+
...props
|
|
9
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Root>) {
|
|
10
|
+
return <PopoverPrimitive.Root data-slot="popover" {...props} />
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function PopoverTrigger({
|
|
14
|
+
...props
|
|
15
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
|
|
16
|
+
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function PopoverContent({
|
|
20
|
+
className,
|
|
21
|
+
align = "center",
|
|
22
|
+
sideOffset = 4,
|
|
23
|
+
...props
|
|
24
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
|
|
25
|
+
return (
|
|
26
|
+
<PopoverPrimitive.Portal>
|
|
27
|
+
<PopoverPrimitive.Content
|
|
28
|
+
data-slot="popover-content"
|
|
29
|
+
align={align}
|
|
30
|
+
sideOffset={sideOffset}
|
|
31
|
+
className={cn(
|
|
32
|
+
"z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden 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 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
|
33
|
+
className
|
|
34
|
+
)}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
</PopoverPrimitive.Portal>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function PopoverAnchor({
|
|
42
|
+
...props
|
|
43
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
|
|
44
|
+
return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function PopoverHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
48
|
+
return (
|
|
49
|
+
<div
|
|
50
|
+
data-slot="popover-header"
|
|
51
|
+
className={cn("flex flex-col gap-1 text-sm", className)}
|
|
52
|
+
{...props}
|
|
53
|
+
/>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function PopoverTitle({ className, ...props }: React.ComponentProps<"h2">) {
|
|
58
|
+
return (
|
|
59
|
+
<div
|
|
60
|
+
data-slot="popover-title"
|
|
61
|
+
className={cn("font-medium", className)}
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function PopoverDescription({
|
|
68
|
+
className,
|
|
69
|
+
...props
|
|
70
|
+
}: React.ComponentProps<"p">) {
|
|
71
|
+
return (
|
|
72
|
+
<p
|
|
73
|
+
data-slot="popover-description"
|
|
74
|
+
className={cn("text-muted-foreground", className)}
|
|
75
|
+
{...props}
|
|
76
|
+
/>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export {
|
|
81
|
+
Popover,
|
|
82
|
+
PopoverTrigger,
|
|
83
|
+
PopoverContent,
|
|
84
|
+
PopoverAnchor,
|
|
85
|
+
PopoverHeader,
|
|
86
|
+
PopoverTitle,
|
|
87
|
+
PopoverDescription,
|
|
88
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cn } from "../menu/utils"
|
|
5
|
+
import { Separator as SeparatorPrimitive } from "radix-ui"
|
|
6
|
+
|
|
7
|
+
function Separator({
|
|
8
|
+
className,
|
|
9
|
+
orientation = "horizontal",
|
|
10
|
+
decorative = true,
|
|
11
|
+
...props
|
|
12
|
+
}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
|
|
13
|
+
return (
|
|
14
|
+
<SeparatorPrimitive.Root
|
|
15
|
+
data-slot="separator"
|
|
16
|
+
decorative={decorative}
|
|
17
|
+
orientation={orientation}
|
|
18
|
+
className={cn(
|
|
19
|
+
"shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",
|
|
20
|
+
className
|
|
21
|
+
)}
|
|
22
|
+
{...props}
|
|
23
|
+
/>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { Separator }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cn } from "../menu/utils"
|
|
2
|
+
|
|
3
|
+
function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
|
|
4
|
+
return (
|
|
5
|
+
<div
|
|
6
|
+
data-slot="skeleton"
|
|
7
|
+
className={cn("animate-pulse rounded-md bg-accent", className)}
|
|
8
|
+
{...props}
|
|
9
|
+
/>
|
|
10
|
+
)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { Skeleton }
|
|
@@ -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,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.21.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,77 @@
|
|
|
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
|
+
"badge", "button", "card", "checkbox", "dialog", "dropdown-menu",
|
|
19
|
+
"input", "popover", "separator", "skeleton", "tabs", "tooltip",
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const UTC_DISPLAY = /\.getUTC(?:FullYear|Month|Date|Day|Hours|Minutes|Seconds)\(|timeZone:\s*["']UTC["']|toISOString\(\)\s*\.\s*(?:slice|substring|substr)\(/;
|
|
23
|
+
|
|
24
|
+
function walk(dir, out = []) {
|
|
25
|
+
if (!existsSync(dir)) return out;
|
|
26
|
+
for (const name of readdirSync(dir)) {
|
|
27
|
+
if (name === "node_modules" || name === "dist" || name.startsWith(".")) continue;
|
|
28
|
+
const p = path.join(dir, name);
|
|
29
|
+
if (statSync(p).isDirectory()) walk(p, out);
|
|
30
|
+
else if (/\.(m?[jt]sx?)$/.test(name) && !/\.test\./.test(name)) out.push(p);
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Findings for one app folder: { file, line, rule, message }. */
|
|
36
|
+
export function lintApp(appDir) {
|
|
37
|
+
const findings = [];
|
|
38
|
+
const src = path.join(appDir, "src");
|
|
39
|
+
for (const file of walk(src)) {
|
|
40
|
+
const rel = path.relative(appDir, file);
|
|
41
|
+
const ui = /^src[\\/]components[\\/]ui[\\/]([a-z-]+)\.tsx$/.exec(rel);
|
|
42
|
+
if (ui && SDK_COMPONENTS.includes(ui[1])) {
|
|
43
|
+
const from = ["dropdown-menu", "checkbox"].includes(ui[1]) ? "@makoai/app-sdk/menu" : "@makoai/app-sdk/components";
|
|
44
|
+
findings.push({ file: rel, line: 1, rule: "local-shadcn", message: `the SDK ships ${ui[1]}: import it from "${from}" and delete this copy` });
|
|
45
|
+
}
|
|
46
|
+
readFileSync(file, "utf8")
|
|
47
|
+
.split("\n")
|
|
48
|
+
.forEach((text, i) => {
|
|
49
|
+
if (!UTC_DISPLAY.test(text) || /mako-lint-ignore utc-display/.test(text)) return;
|
|
50
|
+
findings.push({
|
|
51
|
+
file: rel,
|
|
52
|
+
line: i + 1,
|
|
53
|
+
rule: "utc-display",
|
|
54
|
+
message: "UTC in display code: formatTime(instant) for times, formatDate(day) for day buckets, toDayKey(value) for keys",
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return findings;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function main(argv) {
|
|
62
|
+
const warn = argv.includes("--warn");
|
|
63
|
+
const dirs = argv.filter(a => !a.startsWith("--"));
|
|
64
|
+
let total = 0;
|
|
65
|
+
for (const dir of dirs.length ? dirs : ["."]) {
|
|
66
|
+
for (const f of lintApp(path.resolve(dir))) {
|
|
67
|
+
total++;
|
|
68
|
+
console.log(`${path.join(dir, f.file)}:${f.line} ${f.rule} ${f.message}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (total) console.log(`\n${total} finding${total === 1 ? "" : "s"}`);
|
|
72
|
+
return total && !warn ? 1 : 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Installed bins run through a symlink (node_modules/.bin, pnpm's .pnpm
|
|
76
|
+
// store); import.meta.url is resolved and argv[1] is not, so compare real paths.
|
|
77
|
+
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.21.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
|
+
}
|
package/time.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Times and dates (2.21). The SDK runs DuckDB in UTC, and that stays: display
|
|
2
|
+
// code decides the zone. Two kinds of value reach an app:
|
|
3
|
+
//
|
|
4
|
+
// - Instants (an event time, "updated at", a deploy): shown in the VIEWER's
|
|
5
|
+
// zone with a zone label, "14:05 CET". formatTime().
|
|
6
|
+
// - Day buckets (a dbt `date`, a UTC `date_trunc('day', …)`): a calendar day,
|
|
7
|
+
// printed with no shift. formatDate(). A stored day never goes through the
|
|
8
|
+
// viewer's zone, so 18 Nov stays 18 Nov in Los Angeles.
|
|
9
|
+
//
|
|
10
|
+
// toDayKey() is the one place a UTC "YYYY-MM-DD" key is built (URL state,
|
|
11
|
+
// joins, Map keys). Display code never calls getUTC*, never sets
|
|
12
|
+
// timeZone: "UTC" and never slices toISOString(): `mako-app-lint` flags it.
|
|
13
|
+
|
|
14
|
+
const DAY_RE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
15
|
+
// "2026-11-18 14:05:00", "2026-11-18T14:05:00.123": a DuckDB TIMESTAMP rendered
|
|
16
|
+
// without a zone. DuckDB runs in UTC, so it is a UTC wall time.
|
|
17
|
+
const NAIVE_RE = /^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?$/;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Any time value an app holds as a Date: a Date, epoch milliseconds, a bigint
|
|
21
|
+
* of epoch microseconds (DuckDB TIMESTAMP through Arrow), an ISO string with
|
|
22
|
+
* a zone, or a zone-less "YYYY-MM-DD hh:mm[:ss]" read as UTC. A bare
|
|
23
|
+
* "YYYY-MM-DD" is that day's UTC midnight. Null, "" and unparsable values
|
|
24
|
+
* give null.
|
|
25
|
+
*/
|
|
26
|
+
export function toInstant(value) {
|
|
27
|
+
if (value == null || value === "") return null;
|
|
28
|
+
if (value instanceof Date) return Number.isNaN(value.getTime()) ? null : value;
|
|
29
|
+
if (typeof value === "bigint") return new Date(Number(value / 1000n));
|
|
30
|
+
if (typeof value === "number") return Number.isFinite(value) ? new Date(value) : null;
|
|
31
|
+
const s = String(value).trim();
|
|
32
|
+
let m = DAY_RE.exec(s);
|
|
33
|
+
if (m) return new Date(Date.UTC(+m[1], +m[2] - 1, +m[3]));
|
|
34
|
+
m = NAIVE_RE.exec(s);
|
|
35
|
+
if (m) {
|
|
36
|
+
const ms = m[7] ? Math.round(Number(`0.${m[7]}`) * 1000) : 0;
|
|
37
|
+
return new Date(Date.UTC(+m[1], +m[2] - 1, +m[3], +m[4], +m[5], +(m[6] ?? 0), ms));
|
|
38
|
+
}
|
|
39
|
+
const d = new Date(s);
|
|
40
|
+
return Number.isNaN(d.getTime()) ? null : d;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The UTC calendar day of a value, "YYYY-MM-DD": the key for URL state, joins and maps. Null when unparsable. */
|
|
44
|
+
export function toDayKey(value) {
|
|
45
|
+
if (typeof value === "string" && DAY_RE.test(value.trim())) return value.trim();
|
|
46
|
+
const d = toInstant(value);
|
|
47
|
+
if (!d) return null;
|
|
48
|
+
const p = n => String(n).padStart(2, "0");
|
|
49
|
+
return `${d.getUTCFullYear()}-${p(d.getUTCMonth() + 1)}-${p(d.getUTCDate())}`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const sameDay = (a, b, timeZone) => {
|
|
53
|
+
const f = new Intl.DateTimeFormat("en-CA", { timeZone, year: "numeric", month: "2-digit", day: "2-digit" });
|
|
54
|
+
return f.format(a) === f.format(b);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* An instant in the viewer's zone, with the zone's short name: "14:05 CET",
|
|
59
|
+
* "18 Nov, 14:05 CET" when it is not today there, "18 Nov 2025, 14:05 CET"
|
|
60
|
+
* in another year.
|
|
61
|
+
*
|
|
62
|
+
* Options: `date` ("auto" default, true, false), `seconds` (false),
|
|
63
|
+
* `zoneName` (true: "CET"), `locale` (the browser's), `timeZone` (the
|
|
64
|
+
* viewer's; tests and "as seen from Zurich" views only), `now` (for "auto").
|
|
65
|
+
* Null or unparsable input gives "—".
|
|
66
|
+
*/
|
|
67
|
+
export function formatTime(value, opts = {}) {
|
|
68
|
+
const d = toInstant(value);
|
|
69
|
+
if (!d) return "—";
|
|
70
|
+
const { date = "auto", seconds = false, zoneName = true, locale, timeZone, now = new Date() } = opts;
|
|
71
|
+
const showDate = date === true || (date === "auto" && !sameDay(d, now, timeZone));
|
|
72
|
+
const otherYear =
|
|
73
|
+
showDate &&
|
|
74
|
+
new Intl.DateTimeFormat("en", { timeZone, year: "numeric" }).format(d) !==
|
|
75
|
+
new Intl.DateTimeFormat("en", { timeZone, year: "numeric" }).format(now);
|
|
76
|
+
return new Intl.DateTimeFormat(locale, {
|
|
77
|
+
timeZone,
|
|
78
|
+
hour: "2-digit",
|
|
79
|
+
minute: "2-digit",
|
|
80
|
+
...(seconds ? { second: "2-digit" } : {}),
|
|
81
|
+
hourCycle: "h23",
|
|
82
|
+
...(showDate ? { day: "numeric", month: "short" } : {}),
|
|
83
|
+
...(otherYear ? { year: "numeric" } : {}),
|
|
84
|
+
...(zoneName ? { timeZoneName: "short" } : {}),
|
|
85
|
+
}).format(d);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* A calendar day with no zone shift: "18 Nov 2026". Takes a "YYYY-MM-DD"
|
|
90
|
+
* string, a day's UTC midnight (a parquet `date`), or anything toInstant
|
|
91
|
+
* reads (its UTC day). Options: `year` ("auto" default: shown unless it is
|
|
92
|
+
* the current UTC year; true; false), `weekday` (false; "short" or "long"),
|
|
93
|
+
* `month` ("short" default; "long", "numeric"), `locale`, `now`.
|
|
94
|
+
* Null or unparsable input gives "—".
|
|
95
|
+
*/
|
|
96
|
+
export function formatDate(value, opts = {}) {
|
|
97
|
+
const key = toDayKey(value);
|
|
98
|
+
if (!key) return "—";
|
|
99
|
+
const { year = "auto", weekday = false, month = "short", locale, now = new Date() } = opts;
|
|
100
|
+
const [y, m, d] = key.split("-").map(Number);
|
|
101
|
+
const showYear = year === true || (year === "auto" && y !== now.getUTCFullYear());
|
|
102
|
+
// The day's UTC noon, formatted in UTC: the printed day is the stored day, whatever the viewer's zone.
|
|
103
|
+
return new Intl.DateTimeFormat(locale, {
|
|
104
|
+
timeZone: "UTC",
|
|
105
|
+
day: "numeric",
|
|
106
|
+
month,
|
|
107
|
+
...(showYear ? { year: "numeric" } : {}),
|
|
108
|
+
...(weekday ? { weekday } : {}),
|
|
109
|
+
}).format(new Date(Date.UTC(y, m - 1, d, 12)));
|
|
110
|
+
}
|
package/ui.d.ts
CHANGED
|
@@ -482,3 +482,6 @@ export function csvDate(date: Date): string;
|
|
|
482
482
|
export function csvToTsv(text: string): string;
|
|
483
483
|
/** Download CSV text as a file. Works inside Mako's app frame. */
|
|
484
484
|
export function saveCsv(filename: string, text: string): "downloaded" | "failed";
|
|
485
|
+
|
|
486
|
+
export { formatDate, formatTime, toDayKey, toInstant } from "./index";
|
|
487
|
+
export type { FormatDateOptions, FormatTimeOptions, TimeValue } from "./index";
|