@makoai/app-sdk 2.22.0 → 2.24.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 +24 -0
- package/components/calendar.tsx +220 -0
- package/components/command.tsx +184 -0
- package/components/select.tsx +6 -2
- package/components/sheet.tsx +4 -1
- package/index.js +1 -1
- package/lint.js +60 -11
- package/package.json +19 -1
package/README.md
CHANGED
|
@@ -558,6 +558,26 @@ component or prop is an SDK pull request.
|
|
|
558
558
|
@import "@makoai/app-sdk/tailwind.css";
|
|
559
559
|
```
|
|
560
560
|
|
|
561
|
+
Calendar and Command (2.24) ship on their own subpaths, so an app without
|
|
562
|
+
react-day-picker or cmdk never loads them:
|
|
563
|
+
|
|
564
|
+
```ts
|
|
565
|
+
import { Calendar } from "@makoai/app-sdk/components/calendar";
|
|
566
|
+
import { Command, CommandInput, CommandList } from "@makoai/app-sdk/components/command";
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
shadcn's stock components pass refs as props, so they need React 19. On
|
|
570
|
+
React 18 a ref is dropped: a Calendar's arrow keys stop moving focus. Apps
|
|
571
|
+
that use them run React 19; `mako-app-lint --rules=react-version` flags any
|
|
572
|
+
that does not.
|
|
573
|
+
|
|
574
|
+
Thin props (2.23), marked "Mako thin prop" in the source. Stock behaviour
|
|
575
|
+
stays the default:
|
|
576
|
+
|
|
577
|
+
- `SheetContent closeLabel="Fermer"`: the close button's screen-reader label.
|
|
578
|
+
- `SelectContent container={document.fullscreenElement ?? undefined}`: where
|
|
579
|
+
the list portals, for a fullscreen page.
|
|
580
|
+
|
|
561
581
|
`tailwind.css` lets Tailwind see the SDK's classes (`@source`) and maps the
|
|
562
582
|
house tokens onto Tailwind's colour names (`bg-popover`,
|
|
563
583
|
`text-muted-foreground`, `bg-brand`, `--radius-*`). It replaces the
|
|
@@ -594,6 +614,10 @@ Run it in an app folder (or pass several). It exits 1 on a finding;
|
|
|
594
614
|
`src/`. A date key the helpers cannot build takes
|
|
595
615
|
`// mako-lint-ignore utc-display` on its line.
|
|
596
616
|
- `local-shadcn`: a `src/components/ui/<name>.tsx` the SDK ships.
|
|
617
|
+
- `react-version` (2.24): React below 19 in an app that uses shadcn
|
|
618
|
+
(`src/components/ui`, radix-ui, or the SDK's `/components` or `/menu`).
|
|
619
|
+
|
|
620
|
+
`--rules=react-version` runs only the named rules (2.24).
|
|
597
621
|
|
|
598
622
|
### Chart tooltips: `TableTooltip` (2.10+, every series from 2.15)
|
|
599
623
|
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cn } from "../menu/utils"
|
|
5
|
+
import {
|
|
6
|
+
ChevronDownIcon,
|
|
7
|
+
ChevronLeftIcon,
|
|
8
|
+
ChevronRightIcon,
|
|
9
|
+
} from "lucide-react"
|
|
10
|
+
import {
|
|
11
|
+
DayPicker,
|
|
12
|
+
getDefaultClassNames,
|
|
13
|
+
type DayButton,
|
|
14
|
+
} from "react-day-picker"
|
|
15
|
+
|
|
16
|
+
import { Button, buttonVariants } from "./button"
|
|
17
|
+
|
|
18
|
+
function Calendar({
|
|
19
|
+
className,
|
|
20
|
+
classNames,
|
|
21
|
+
showOutsideDays = true,
|
|
22
|
+
captionLayout = "label",
|
|
23
|
+
buttonVariant = "ghost",
|
|
24
|
+
formatters,
|
|
25
|
+
components,
|
|
26
|
+
...props
|
|
27
|
+
}: React.ComponentProps<typeof DayPicker> & {
|
|
28
|
+
buttonVariant?: React.ComponentProps<typeof Button>["variant"]
|
|
29
|
+
}) {
|
|
30
|
+
const defaultClassNames = getDefaultClassNames()
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<DayPicker
|
|
34
|
+
showOutsideDays={showOutsideDays}
|
|
35
|
+
className={cn(
|
|
36
|
+
"group/calendar bg-background p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
|
|
37
|
+
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
|
38
|
+
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
|
39
|
+
className
|
|
40
|
+
)}
|
|
41
|
+
captionLayout={captionLayout}
|
|
42
|
+
formatters={{
|
|
43
|
+
formatMonthDropdown: (date) =>
|
|
44
|
+
date.toLocaleString("default", { month: "short" }),
|
|
45
|
+
...formatters,
|
|
46
|
+
}}
|
|
47
|
+
classNames={{
|
|
48
|
+
root: cn("w-fit", defaultClassNames.root),
|
|
49
|
+
months: cn(
|
|
50
|
+
"relative flex flex-col gap-4 md:flex-row",
|
|
51
|
+
defaultClassNames.months
|
|
52
|
+
),
|
|
53
|
+
month: cn("flex w-full flex-col gap-4", defaultClassNames.month),
|
|
54
|
+
nav: cn(
|
|
55
|
+
"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
|
|
56
|
+
defaultClassNames.nav
|
|
57
|
+
),
|
|
58
|
+
button_previous: cn(
|
|
59
|
+
buttonVariants({ variant: buttonVariant }),
|
|
60
|
+
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
|
61
|
+
defaultClassNames.button_previous
|
|
62
|
+
),
|
|
63
|
+
button_next: cn(
|
|
64
|
+
buttonVariants({ variant: buttonVariant }),
|
|
65
|
+
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
|
66
|
+
defaultClassNames.button_next
|
|
67
|
+
),
|
|
68
|
+
month_caption: cn(
|
|
69
|
+
"flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)",
|
|
70
|
+
defaultClassNames.month_caption
|
|
71
|
+
),
|
|
72
|
+
dropdowns: cn(
|
|
73
|
+
"flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium",
|
|
74
|
+
defaultClassNames.dropdowns
|
|
75
|
+
),
|
|
76
|
+
dropdown_root: cn(
|
|
77
|
+
"relative rounded-md border border-input shadow-xs has-focus:border-ring has-focus:ring-[3px] has-focus:ring-ring/50",
|
|
78
|
+
defaultClassNames.dropdown_root
|
|
79
|
+
),
|
|
80
|
+
dropdown: cn(
|
|
81
|
+
"absolute inset-0 bg-popover opacity-0",
|
|
82
|
+
defaultClassNames.dropdown
|
|
83
|
+
),
|
|
84
|
+
caption_label: cn(
|
|
85
|
+
"font-medium select-none",
|
|
86
|
+
captionLayout === "label"
|
|
87
|
+
? "text-sm"
|
|
88
|
+
: "flex h-8 items-center gap-1 rounded-md pr-1 pl-2 text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
|
|
89
|
+
defaultClassNames.caption_label
|
|
90
|
+
),
|
|
91
|
+
month_grid: cn("w-full border-collapse", defaultClassNames.month_grid),
|
|
92
|
+
weekdays: cn("flex", defaultClassNames.weekdays),
|
|
93
|
+
weekday: cn(
|
|
94
|
+
"flex-1 rounded-md text-[0.8rem] font-normal text-muted-foreground select-none",
|
|
95
|
+
defaultClassNames.weekday
|
|
96
|
+
),
|
|
97
|
+
week: cn("mt-2 flex w-full", defaultClassNames.week),
|
|
98
|
+
week_number_header: cn(
|
|
99
|
+
"w-(--cell-size) select-none",
|
|
100
|
+
defaultClassNames.week_number_header
|
|
101
|
+
),
|
|
102
|
+
week_number: cn(
|
|
103
|
+
"text-[0.8rem] text-muted-foreground select-none",
|
|
104
|
+
defaultClassNames.week_number
|
|
105
|
+
),
|
|
106
|
+
day: cn(
|
|
107
|
+
"group/day relative aspect-square h-full w-full p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-md",
|
|
108
|
+
props.showWeekNumber
|
|
109
|
+
? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-md"
|
|
110
|
+
: "[&:first-child[data-selected=true]_button]:rounded-l-md",
|
|
111
|
+
defaultClassNames.day
|
|
112
|
+
),
|
|
113
|
+
range_start: cn(
|
|
114
|
+
"rounded-l-md bg-accent",
|
|
115
|
+
defaultClassNames.range_start
|
|
116
|
+
),
|
|
117
|
+
range_middle: cn("rounded-none", defaultClassNames.range_middle),
|
|
118
|
+
range_end: cn("rounded-r-md bg-accent", defaultClassNames.range_end),
|
|
119
|
+
today: cn(
|
|
120
|
+
"rounded-md bg-accent text-accent-foreground data-[selected=true]:rounded-none",
|
|
121
|
+
defaultClassNames.today
|
|
122
|
+
),
|
|
123
|
+
outside: cn(
|
|
124
|
+
"text-muted-foreground aria-selected:text-muted-foreground",
|
|
125
|
+
defaultClassNames.outside
|
|
126
|
+
),
|
|
127
|
+
disabled: cn(
|
|
128
|
+
"text-muted-foreground opacity-50",
|
|
129
|
+
defaultClassNames.disabled
|
|
130
|
+
),
|
|
131
|
+
hidden: cn("invisible", defaultClassNames.hidden),
|
|
132
|
+
...classNames,
|
|
133
|
+
}}
|
|
134
|
+
components={{
|
|
135
|
+
Root: ({ className, rootRef, ...props }) => {
|
|
136
|
+
return (
|
|
137
|
+
<div
|
|
138
|
+
data-slot="calendar"
|
|
139
|
+
ref={rootRef}
|
|
140
|
+
className={cn(className)}
|
|
141
|
+
{...props}
|
|
142
|
+
/>
|
|
143
|
+
)
|
|
144
|
+
},
|
|
145
|
+
Chevron: ({ className, orientation, ...props }) => {
|
|
146
|
+
if (orientation === "left") {
|
|
147
|
+
return (
|
|
148
|
+
<ChevronLeftIcon className={cn("size-4", className)} {...props} />
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (orientation === "right") {
|
|
153
|
+
return (
|
|
154
|
+
<ChevronRightIcon
|
|
155
|
+
className={cn("size-4", className)}
|
|
156
|
+
{...props}
|
|
157
|
+
/>
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
<ChevronDownIcon className={cn("size-4", className)} {...props} />
|
|
163
|
+
)
|
|
164
|
+
},
|
|
165
|
+
DayButton: CalendarDayButton,
|
|
166
|
+
WeekNumber: ({ children, ...props }) => {
|
|
167
|
+
return (
|
|
168
|
+
<td {...props}>
|
|
169
|
+
<div className="flex size-(--cell-size) items-center justify-center text-center">
|
|
170
|
+
{children}
|
|
171
|
+
</div>
|
|
172
|
+
</td>
|
|
173
|
+
)
|
|
174
|
+
},
|
|
175
|
+
...components,
|
|
176
|
+
}}
|
|
177
|
+
{...props}
|
|
178
|
+
/>
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function CalendarDayButton({
|
|
183
|
+
className,
|
|
184
|
+
day,
|
|
185
|
+
modifiers,
|
|
186
|
+
...props
|
|
187
|
+
}: React.ComponentProps<typeof DayButton>) {
|
|
188
|
+
const defaultClassNames = getDefaultClassNames()
|
|
189
|
+
|
|
190
|
+
const ref = React.useRef<HTMLButtonElement>(null)
|
|
191
|
+
React.useEffect(() => {
|
|
192
|
+
if (modifiers.focused) ref.current?.focus()
|
|
193
|
+
}, [modifiers.focused])
|
|
194
|
+
|
|
195
|
+
return (
|
|
196
|
+
<Button
|
|
197
|
+
ref={ref}
|
|
198
|
+
variant="ghost"
|
|
199
|
+
size="icon"
|
|
200
|
+
data-day={day.date.toLocaleDateString()}
|
|
201
|
+
data-selected-single={
|
|
202
|
+
modifiers.selected &&
|
|
203
|
+
!modifiers.range_start &&
|
|
204
|
+
!modifiers.range_end &&
|
|
205
|
+
!modifiers.range_middle
|
|
206
|
+
}
|
|
207
|
+
data-range-start={modifiers.range_start}
|
|
208
|
+
data-range-end={modifiers.range_end}
|
|
209
|
+
data-range-middle={modifiers.range_middle}
|
|
210
|
+
className={cn(
|
|
211
|
+
"flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-accent-foreground [&>span]:text-xs [&>span]:opacity-70",
|
|
212
|
+
defaultClassNames.day,
|
|
213
|
+
className
|
|
214
|
+
)}
|
|
215
|
+
{...props}
|
|
216
|
+
/>
|
|
217
|
+
)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export { Calendar, CalendarDayButton }
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Command as CommandPrimitive } from "cmdk"
|
|
5
|
+
import { cn } from "../menu/utils"
|
|
6
|
+
import { SearchIcon } from "lucide-react"
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
Dialog,
|
|
10
|
+
DialogContent,
|
|
11
|
+
DialogDescription,
|
|
12
|
+
DialogHeader,
|
|
13
|
+
DialogTitle,
|
|
14
|
+
} from "./dialog"
|
|
15
|
+
|
|
16
|
+
function Command({
|
|
17
|
+
className,
|
|
18
|
+
...props
|
|
19
|
+
}: React.ComponentProps<typeof CommandPrimitive>) {
|
|
20
|
+
return (
|
|
21
|
+
<CommandPrimitive
|
|
22
|
+
data-slot="command"
|
|
23
|
+
className={cn(
|
|
24
|
+
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
|
|
25
|
+
className
|
|
26
|
+
)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function CommandDialog({
|
|
33
|
+
title = "Command Palette",
|
|
34
|
+
description = "Search for a command to run...",
|
|
35
|
+
children,
|
|
36
|
+
className,
|
|
37
|
+
showCloseButton = true,
|
|
38
|
+
...props
|
|
39
|
+
}: React.ComponentProps<typeof Dialog> & {
|
|
40
|
+
title?: string
|
|
41
|
+
description?: string
|
|
42
|
+
className?: string
|
|
43
|
+
showCloseButton?: boolean
|
|
44
|
+
}) {
|
|
45
|
+
return (
|
|
46
|
+
<Dialog {...props}>
|
|
47
|
+
<DialogHeader className="sr-only">
|
|
48
|
+
<DialogTitle>{title}</DialogTitle>
|
|
49
|
+
<DialogDescription>{description}</DialogDescription>
|
|
50
|
+
</DialogHeader>
|
|
51
|
+
<DialogContent
|
|
52
|
+
className={cn("overflow-hidden p-0", className)}
|
|
53
|
+
showCloseButton={showCloseButton}
|
|
54
|
+
>
|
|
55
|
+
<Command className="**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
|
|
56
|
+
{children}
|
|
57
|
+
</Command>
|
|
58
|
+
</DialogContent>
|
|
59
|
+
</Dialog>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function CommandInput({
|
|
64
|
+
className,
|
|
65
|
+
...props
|
|
66
|
+
}: React.ComponentProps<typeof CommandPrimitive.Input>) {
|
|
67
|
+
return (
|
|
68
|
+
<div
|
|
69
|
+
data-slot="command-input-wrapper"
|
|
70
|
+
className="flex h-9 items-center gap-2 border-b px-3"
|
|
71
|
+
>
|
|
72
|
+
<SearchIcon className="size-4 shrink-0 opacity-50" />
|
|
73
|
+
<CommandPrimitive.Input
|
|
74
|
+
data-slot="command-input"
|
|
75
|
+
className={cn(
|
|
76
|
+
"flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
|
77
|
+
className
|
|
78
|
+
)}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
</div>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function CommandList({
|
|
86
|
+
className,
|
|
87
|
+
...props
|
|
88
|
+
}: React.ComponentProps<typeof CommandPrimitive.List>) {
|
|
89
|
+
return (
|
|
90
|
+
<CommandPrimitive.List
|
|
91
|
+
data-slot="command-list"
|
|
92
|
+
className={cn(
|
|
93
|
+
"max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",
|
|
94
|
+
className
|
|
95
|
+
)}
|
|
96
|
+
{...props}
|
|
97
|
+
/>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function CommandEmpty({
|
|
102
|
+
...props
|
|
103
|
+
}: React.ComponentProps<typeof CommandPrimitive.Empty>) {
|
|
104
|
+
return (
|
|
105
|
+
<CommandPrimitive.Empty
|
|
106
|
+
data-slot="command-empty"
|
|
107
|
+
className="py-6 text-center text-sm"
|
|
108
|
+
{...props}
|
|
109
|
+
/>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function CommandGroup({
|
|
114
|
+
className,
|
|
115
|
+
...props
|
|
116
|
+
}: React.ComponentProps<typeof CommandPrimitive.Group>) {
|
|
117
|
+
return (
|
|
118
|
+
<CommandPrimitive.Group
|
|
119
|
+
data-slot="command-group"
|
|
120
|
+
className={cn(
|
|
121
|
+
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
|
|
122
|
+
className
|
|
123
|
+
)}
|
|
124
|
+
{...props}
|
|
125
|
+
/>
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function CommandSeparator({
|
|
130
|
+
className,
|
|
131
|
+
...props
|
|
132
|
+
}: React.ComponentProps<typeof CommandPrimitive.Separator>) {
|
|
133
|
+
return (
|
|
134
|
+
<CommandPrimitive.Separator
|
|
135
|
+
data-slot="command-separator"
|
|
136
|
+
className={cn("-mx-1 h-px bg-border", className)}
|
|
137
|
+
{...props}
|
|
138
|
+
/>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function CommandItem({
|
|
143
|
+
className,
|
|
144
|
+
...props
|
|
145
|
+
}: React.ComponentProps<typeof CommandPrimitive.Item>) {
|
|
146
|
+
return (
|
|
147
|
+
<CommandPrimitive.Item
|
|
148
|
+
data-slot="command-item"
|
|
149
|
+
className={cn(
|
|
150
|
+
"relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",
|
|
151
|
+
className
|
|
152
|
+
)}
|
|
153
|
+
{...props}
|
|
154
|
+
/>
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function CommandShortcut({
|
|
159
|
+
className,
|
|
160
|
+
...props
|
|
161
|
+
}: React.ComponentProps<"span">) {
|
|
162
|
+
return (
|
|
163
|
+
<span
|
|
164
|
+
data-slot="command-shortcut"
|
|
165
|
+
className={cn(
|
|
166
|
+
"ml-auto text-xs tracking-widest text-muted-foreground",
|
|
167
|
+
className
|
|
168
|
+
)}
|
|
169
|
+
{...props}
|
|
170
|
+
/>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export {
|
|
175
|
+
Command,
|
|
176
|
+
CommandDialog,
|
|
177
|
+
CommandInput,
|
|
178
|
+
CommandList,
|
|
179
|
+
CommandEmpty,
|
|
180
|
+
CommandGroup,
|
|
181
|
+
CommandItem,
|
|
182
|
+
CommandShortcut,
|
|
183
|
+
CommandSeparator,
|
|
184
|
+
}
|
package/components/select.tsx
CHANGED
|
@@ -54,10 +54,14 @@ function SelectContent({
|
|
|
54
54
|
children,
|
|
55
55
|
position = "item-aligned",
|
|
56
56
|
align = "center",
|
|
57
|
+
container,
|
|
57
58
|
...props
|
|
58
|
-
}: React.ComponentProps<typeof SelectPrimitive.Content>
|
|
59
|
+
}: React.ComponentProps<typeof SelectPrimitive.Content> & {
|
|
60
|
+
/** Mako thin prop (2.23): where the list portals, e.g. document.fullscreenElement in a fullscreen deck. */
|
|
61
|
+
container?: React.ComponentProps<typeof SelectPrimitive.Portal>["container"]
|
|
62
|
+
}) {
|
|
59
63
|
return (
|
|
60
|
-
<SelectPrimitive.Portal>
|
|
64
|
+
<SelectPrimitive.Portal container={container}>
|
|
61
65
|
<SelectPrimitive.Content
|
|
62
66
|
data-slot="select-content"
|
|
63
67
|
className={cn(
|
package/components/sheet.tsx
CHANGED
|
@@ -48,10 +48,13 @@ function SheetContent({
|
|
|
48
48
|
children,
|
|
49
49
|
side = "right",
|
|
50
50
|
showCloseButton = true,
|
|
51
|
+
closeLabel = "Close",
|
|
51
52
|
...props
|
|
52
53
|
}: React.ComponentProps<typeof SheetPrimitive.Content> & {
|
|
53
54
|
side?: "top" | "right" | "bottom" | "left"
|
|
54
55
|
showCloseButton?: boolean
|
|
56
|
+
/** Mako thin prop (2.23): the close button's screen-reader label, e.g. "Fermer". */
|
|
57
|
+
closeLabel?: string
|
|
55
58
|
}) {
|
|
56
59
|
return (
|
|
57
60
|
<SheetPortal>
|
|
@@ -76,7 +79,7 @@ function SheetContent({
|
|
|
76
79
|
{showCloseButton && (
|
|
77
80
|
<SheetPrimitive.Close 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-secondary">
|
|
78
81
|
<XIcon className="size-4" />
|
|
79
|
-
<span className="sr-only">
|
|
82
|
+
<span className="sr-only">{closeLabel}</span>
|
|
80
83
|
</SheetPrimitive.Close>
|
|
81
84
|
)}
|
|
82
85
|
</SheetPrimitive.Content>
|
package/index.js
CHANGED
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
* in a page (or this export) says which SDK a deployed app actually runs.
|
|
39
39
|
* Kept in step with package.json by snapshot.test.mjs.
|
|
40
40
|
*/
|
|
41
|
-
export const SDK_VERSION = "2.
|
|
41
|
+
export const SDK_VERSION = "2.24.0";
|
|
42
42
|
if (typeof window !== "undefined") {
|
|
43
43
|
try {
|
|
44
44
|
window.__MAKO_APP_SDK__ = SDK_VERSION;
|
package/lint.js
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// mako-app-lint (2.21
|
|
2
|
+
// mako-app-lint (2.21; react-version and --rules from 2.24): app rules a
|
|
3
|
+
// reviewer kept repeating.
|
|
3
4
|
//
|
|
4
5
|
// utc-display getUTC*, timeZone: "UTC" or toISOString().slice in display
|
|
5
6
|
// code. Instants show in the viewer's zone (formatTime), day
|
|
6
7
|
// buckets unshifted (formatDate), keys come from toDayKey.
|
|
7
8
|
// local-shadcn src/components/ui/<name>.tsx where @makoai/app-sdk ships
|
|
8
9
|
// that component (/components, /menu). Import it instead.
|
|
10
|
+
// react-version an app on React below 19 that uses shadcn (src/components/ui,
|
|
11
|
+
// radix-ui, or the SDK's /components or /menu). shadcn's stock
|
|
12
|
+
// components pass refs as props, which React 18 drops: on
|
|
13
|
+
// 18 Nov 2026 a Calendar's arrow keys stopped moving focus.
|
|
9
14
|
//
|
|
10
|
-
// Usage: npx mako-app-lint [app dir …] [--warn]. Exit 1 on
|
|
11
|
-
// --warn. A line ending in `// mako-lint-ignore utc-display` is skipped (a
|
|
15
|
+
// Usage: npx mako-app-lint [app dir …] [--warn] [--rules=a,b]. Exit 1 on
|
|
16
|
+
// findings unless --warn. --rules runs only the named rules. A line ending in `// mako-lint-ignore utc-display` is skipped (a
|
|
12
17
|
// date key the helpers cannot build, with the reason on the line above).
|
|
13
18
|
import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
14
19
|
import path from "node:path";
|
|
15
20
|
import { fileURLToPath } from "node:url";
|
|
16
21
|
|
|
22
|
+
/** Components on their own subpath: they need a peer most apps lack (react-day-picker, cmdk). */
|
|
23
|
+
export const SDK_SUBPATH_COMPONENTS = ["calendar", "command"];
|
|
24
|
+
|
|
17
25
|
export const SDK_COMPONENTS = [
|
|
18
26
|
"alert", "avatar", "badge", "button", "card", "checkbox", "collapsible",
|
|
19
27
|
"dialog", "dropdown-menu", "input", "label", "popover", "progress",
|
|
20
28
|
"select", "separator", "sheet", "skeleton", "slider", "switch", "table",
|
|
21
|
-
"tabs", "toggle", "toggle-group", "tooltip",
|
|
29
|
+
"tabs", "toggle", "toggle-group", "tooltip", ...SDK_SUBPATH_COMPONENTS,
|
|
22
30
|
];
|
|
23
31
|
|
|
24
32
|
const UTC_DISPLAY = /\.getUTC(?:FullYear|Month|Date|Day|Hours|Minutes|Seconds)\(|timeZone:\s*["']UTC["']|toISOString\(\)\s*\.\s*(?:slice|substring|substr)\(/;
|
|
@@ -34,21 +42,60 @@ function walk(dir, out = []) {
|
|
|
34
42
|
return out;
|
|
35
43
|
}
|
|
36
44
|
|
|
37
|
-
/**
|
|
38
|
-
export function
|
|
39
|
-
const
|
|
45
|
+
/** The lowest major a package.json range allows: "^18.2.0" → 18, ">=19" → 19; null when unreadable. */
|
|
46
|
+
export function minMajor(range) {
|
|
47
|
+
const m = /(\d+)/.exec(String(range ?? ""));
|
|
48
|
+
return m ? Number(m[1]) : null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** react-version: React below 19 with shadcn in the app. */
|
|
52
|
+
function reactVersionFindings(appDir) {
|
|
53
|
+
const pj = path.join(appDir, "package.json");
|
|
54
|
+
if (!existsSync(pj)) return [];
|
|
55
|
+
let pkg;
|
|
56
|
+
try {
|
|
57
|
+
pkg = JSON.parse(readFileSync(pj, "utf8"));
|
|
58
|
+
} catch {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
62
|
+
const major = minMajor(deps.react);
|
|
63
|
+
if (major == null || major >= 19) return [];
|
|
64
|
+
const why = [];
|
|
65
|
+
if (existsSync(path.join(appDir, "src", "components", "ui"))) why.push("src/components/ui");
|
|
66
|
+
if (Object.keys(deps).some(d => d === "radix-ui" || d.startsWith("@radix-ui/"))) why.push("radix-ui");
|
|
67
|
+
if (walk(path.join(appDir, "src")).some(f => /@makoai\/app-sdk\/(components|menu)/.test(readFileSync(f, "utf8")))) {
|
|
68
|
+
why.push("@makoai/app-sdk/components or /menu");
|
|
69
|
+
}
|
|
70
|
+
if (!why.length) return [];
|
|
71
|
+
return [{
|
|
72
|
+
file: "package.json",
|
|
73
|
+
line: 1,
|
|
74
|
+
rule: "react-version",
|
|
75
|
+
message: `React ${deps.react} with shadcn (${why.join(", ")}): shadcn passes refs as props, which React 18 drops. Move to react and react-dom ^19`,
|
|
76
|
+
}];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Findings for one app folder: { file, line, rule, message }. `rules` limits them (default: all). */
|
|
80
|
+
export function lintApp(appDir, rules) {
|
|
81
|
+
const on = name => !rules || rules.includes(name);
|
|
82
|
+
const findings = on("react-version") ? reactVersionFindings(appDir) : [];
|
|
40
83
|
const src = path.join(appDir, "src");
|
|
41
84
|
for (const file of walk(src)) {
|
|
42
85
|
const rel = path.relative(appDir, file);
|
|
43
86
|
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])
|
|
87
|
+
if (on("local-shadcn") && ui && SDK_COMPONENTS.includes(ui[1])) {
|
|
88
|
+
const from = ["dropdown-menu", "checkbox"].includes(ui[1])
|
|
89
|
+
? "@makoai/app-sdk/menu"
|
|
90
|
+
: SDK_SUBPATH_COMPONENTS.includes(ui[1])
|
|
91
|
+
? `@makoai/app-sdk/components/${ui[1]}`
|
|
92
|
+
: "@makoai/app-sdk/components";
|
|
46
93
|
findings.push({ file: rel, line: 1, rule: "local-shadcn", message: `the SDK ships ${ui[1]}: import it from "${from}" and delete this copy` });
|
|
47
94
|
}
|
|
48
95
|
readFileSync(file, "utf8")
|
|
49
96
|
.split("\n")
|
|
50
97
|
.forEach((text, i) => {
|
|
51
|
-
if (!UTC_DISPLAY.test(text) || /mako-lint-ignore utc-display/.test(text)) return;
|
|
98
|
+
if (!on("utc-display") || !UTC_DISPLAY.test(text) || /mako-lint-ignore utc-display/.test(text)) return;
|
|
52
99
|
findings.push({
|
|
53
100
|
file: rel,
|
|
54
101
|
line: i + 1,
|
|
@@ -62,10 +109,12 @@ export function lintApp(appDir) {
|
|
|
62
109
|
|
|
63
110
|
function main(argv) {
|
|
64
111
|
const warn = argv.includes("--warn");
|
|
112
|
+
const rulesArg = argv.find(a => a.startsWith("--rules="));
|
|
113
|
+
const rules = rulesArg ? rulesArg.slice("--rules=".length).split(",").filter(Boolean) : undefined;
|
|
65
114
|
const dirs = argv.filter(a => !a.startsWith("--"));
|
|
66
115
|
let total = 0;
|
|
67
116
|
for (const dir of dirs.length ? dirs : ["."]) {
|
|
68
|
-
for (const f of lintApp(path.resolve(dir))) {
|
|
117
|
+
for (const f of lintApp(path.resolve(dir), rules)) {
|
|
69
118
|
total++;
|
|
70
119
|
console.log(`${path.join(dir, f.file)}:${f.line} ${f.rule} ${f.message}`);
|
|
71
120
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@makoai/app-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.24.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": {
|
|
@@ -47,6 +47,14 @@
|
|
|
47
47
|
"types": "./components/index.ts",
|
|
48
48
|
"default": "./components/index.ts"
|
|
49
49
|
},
|
|
50
|
+
"./components/calendar": {
|
|
51
|
+
"types": "./components/calendar.tsx",
|
|
52
|
+
"default": "./components/calendar.tsx"
|
|
53
|
+
},
|
|
54
|
+
"./components/command": {
|
|
55
|
+
"types": "./components/command.tsx",
|
|
56
|
+
"default": "./components/command.tsx"
|
|
57
|
+
},
|
|
50
58
|
"./ui.css": "./ui.css",
|
|
51
59
|
"./tailwind.css": "./tailwind.css"
|
|
52
60
|
},
|
|
@@ -73,9 +81,11 @@
|
|
|
73
81
|
"peerDependencies": {
|
|
74
82
|
"class-variance-authority": ">=0.7",
|
|
75
83
|
"clsx": ">=2",
|
|
84
|
+
"cmdk": ">=1",
|
|
76
85
|
"lucide-react": ">=0.400",
|
|
77
86
|
"radix-ui": ">=1.4",
|
|
78
87
|
"react": ">=18",
|
|
88
|
+
"react-day-picker": ">=9",
|
|
79
89
|
"react-dom": ">=18",
|
|
80
90
|
"tailwind-merge": ">=2"
|
|
81
91
|
},
|
|
@@ -86,12 +96,18 @@
|
|
|
86
96
|
"clsx": {
|
|
87
97
|
"optional": true
|
|
88
98
|
},
|
|
99
|
+
"cmdk": {
|
|
100
|
+
"optional": true
|
|
101
|
+
},
|
|
89
102
|
"lucide-react": {
|
|
90
103
|
"optional": true
|
|
91
104
|
},
|
|
92
105
|
"radix-ui": {
|
|
93
106
|
"optional": true
|
|
94
107
|
},
|
|
108
|
+
"react-day-picker": {
|
|
109
|
+
"optional": true
|
|
110
|
+
},
|
|
95
111
|
"tailwind-merge": {
|
|
96
112
|
"optional": true
|
|
97
113
|
}
|
|
@@ -106,10 +122,12 @@
|
|
|
106
122
|
"apache-arrow": "17.0.0",
|
|
107
123
|
"class-variance-authority": "^0.7.1",
|
|
108
124
|
"clsx": "^2.1.1",
|
|
125
|
+
"cmdk": "^1.1.1",
|
|
109
126
|
"esbuild": "^0.28.2",
|
|
110
127
|
"jsdom": "^30.1.2",
|
|
111
128
|
"lucide-react": "^1.61.0",
|
|
112
129
|
"radix-ui": "^1.8.1",
|
|
130
|
+
"react-day-picker": "^10.0.2",
|
|
113
131
|
"tailwind-merge": "^3.7.0"
|
|
114
132
|
}
|
|
115
133
|
}
|