@makoai/app-sdk 2.18.1 → 2.20.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 +101 -13
- package/index.js +1 -1
- package/menu/checkbox.tsx +36 -0
- package/menu/dropdown-menu.tsx +205 -0
- package/menu/filter-menu.tsx +312 -0
- package/menu/index.ts +10 -0
- package/menu/utils.ts +7 -0
- package/package.json +31 -3
- package/ui-core.js +165 -0
- package/ui.css +16 -1
- package/ui.d.ts +92 -5
- package/ui.js +207 -73
- package/vite.d.ts +24 -1
- package/vite.js +96 -1
package/README.md
CHANGED
|
@@ -388,8 +388,9 @@ import {
|
|
|
388
388
|
<MultiSelect options={["CH", "ES", "IT"]} value={countries} onChange={setCountries} allLabel="All countries" />
|
|
389
389
|
```
|
|
390
390
|
|
|
391
|
-
- `MultiSelect` — controlled (`value` / `onChange`). Options are strings
|
|
392
|
-
`{ value, label, color }`; `showOnly` adds an
|
|
391
|
+
- `MultiSelect` — controlled (`value` / `onChange`). Options are strings,
|
|
392
|
+
`{ value, label, color }`, or groups with `children`; `showOnly` adds an
|
|
393
|
+
"Only" button per row. `FilterItems` is its rows alone. On
|
|
393
394
|
phones the menu is a bottom sheet. See "MultiSelect: the All rule" below.
|
|
394
395
|
- `FreshnessBadge` — presentational: the app decides what fresh means and
|
|
395
396
|
passes `tone` (`ok` / `warn` / `bad`, or `green` / `amber` / `red`), a
|
|
@@ -420,18 +421,61 @@ import {
|
|
|
420
421
|
and declare it once (`src/vite-env.d.ts`):
|
|
421
422
|
`declare const __APP_BINDING_NAMES__: string[];`
|
|
422
423
|
|
|
423
|
-
### MultiSelect: the All rule and one open popover (2.17
|
|
424
|
+
### MultiSelect: the All rule and one open popover (2.17+, tri-state from 2.20)
|
|
424
425
|
|
|
425
|
-
**All.** Nothing is filtered when `value` is empty or holds every
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
426
|
+
**All (2.20).** Nothing is filtered when `value` is empty or holds every
|
|
427
|
+
option, and then every row is ticked, All included. Unticking one row leaves
|
|
428
|
+
All in the partial (–) state. A click on a full All unticks every row; a
|
|
429
|
+
click on a partial All ticks every row. "Nothing ticked" is a draft: it emits
|
|
430
|
+
nothing (an empty filter still means everything), the trigger reads
|
|
431
|
+
`noneLabel` ("None"), the first tick picks that row alone, and closing the
|
|
432
|
+
menu keeps the last selection. Unticking the last row gives the same draft.
|
|
429
433
|
`emptyMeansAll` (default `true`) only sets what All emits: `[]`, or every
|
|
430
|
-
option's value when `false`.
|
|
434
|
+
option's value when `false`. No prop changed: an app gets the rule by
|
|
435
|
+
updating the SDK.
|
|
431
436
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
437
|
+
Before 2.20, All showed ticked over unticked rows and a click under All
|
|
438
|
+
selected only that option.
|
|
439
|
+
|
|
440
|
+
**Groups (2.20).** An option with `children` is a group: its row ticks every
|
|
441
|
+
leaf under it and shows a dash when some are picked; its children follow it,
|
|
442
|
+
indented. A tree that needs hover submenus (Traffic → Bots → GPTBot) is a
|
|
443
|
+
`FilterMenu` from `@makoai/app-sdk/menu` (below). A flat list is a one-level tree. The value is
|
|
444
|
+
always leaf values. `filterToParam` / `filterFromParam` turn a selection into
|
|
445
|
+
a URL value and back ("bots" for a whole group, its picked children for a
|
|
446
|
+
partial one).
|
|
447
|
+
|
|
448
|
+
**Composite menus: `FilterItems` (2.20).** The rows without the trigger, for
|
|
449
|
+
an app's own menu that folds several filters into one dropdown on a phone.
|
|
450
|
+
`MultiSelect` renders the same rows, so every filter ticks alike.
|
|
451
|
+
|
|
452
|
+
```tsx
|
|
453
|
+
<DropdownMenuSubContent>
|
|
454
|
+
<FilterItems options={TRAFFIC} value={traffic} onChange={setTraffic} allLabel="All traffic" showOnly />
|
|
455
|
+
</DropdownMenuSubContent>
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
**Replacing an app's NestedFilterMenu: `FilterMenu`.** See "Menus" below:
|
|
459
|
+
`FilterMenu` and `FilterMenuItems` from `@makoai/app-sdk/menu` take
|
|
460
|
+
NestedFilterMenu's props (`label`, `options`, `selected`, `onChange`,
|
|
461
|
+
`allLabel`, `summary`, `triggerClassName`, `probes`, `sizeTo`; `drill` and
|
|
462
|
+
`root` on the items). For a flat filter, `MultiSelect` takes the same
|
|
463
|
+
props. The `nestedfilter.ts` helpers are `filterLeaves`, `filterLeavesOf`,
|
|
464
|
+
`filterFind`, `filterNormalize`, `filterTick`, `filterToggle`,
|
|
465
|
+
`filterText` (summarize), `filterPickedNode`, `filterToParam`,
|
|
466
|
+
`filterFromParam`, all from `/ui`. Delete the app's copies.
|
|
467
|
+
|
|
468
|
+
A value the options don't list (a URL pick before the options load, or a
|
|
469
|
+
market missing from this date range) stays in the selection: the trigger
|
|
470
|
+
reads it ("PT"), All shows partial, and the next tick keeps it.
|
|
471
|
+
|
|
472
|
+
**Trigger.** It reads the All label, the one picked label (a leaf or a whole
|
|
473
|
+
group), "3 selected" for a flat list, or the picked parts for a tree
|
|
474
|
+
("Humans + Bots: GPTBot"). `formatMany={n => `${n} markets`}` changes "N
|
|
475
|
+
selected"; `summary` replaces the text. Its width is fixed to the longest of
|
|
476
|
+
`sizeTo` (default: All, the top-level labels, "N selected" and "None") plus
|
|
477
|
+
`probes`, so a pick never moves the bar. The `title` lists the selected
|
|
478
|
+
labels. Chips and `maxChips` are gone.
|
|
435
479
|
|
|
436
480
|
**Checkbox.** `Checkbox` (`checked`: `true` / `false` / `"mixed"`) is the
|
|
437
481
|
kit's one checkbox. From 2.18 it ticks white on `--brand` (`--primary` when a
|
|
@@ -463,6 +507,40 @@ Pure helpers for app-side menus: `multiSelectState(value, optionValues)`,
|
|
|
463
507
|
`multiSelectToggle(value, optionValues, v, emptyMeansAll)`,
|
|
464
508
|
`multiSelectText(value, options, allLabel, formatMany)`.
|
|
465
509
|
|
|
510
|
+
### Menus: `@makoai/app-sdk/menu` (2.20)
|
|
511
|
+
|
|
512
|
+
Stock shadcn/ui `DropdownMenu` (every part, hover submenus included) and
|
|
513
|
+
`Checkbox` (new-york, as shipped; the Checkbox adds the indeterminate dash),
|
|
514
|
+
plus the `FilterMenu` built on them. Never copy these into an app: a
|
|
515
|
+
missing part or prop is an SDK pull request.
|
|
516
|
+
|
|
517
|
+
```tsx
|
|
518
|
+
import { FilterMenu, FilterMenuItems } from "@makoai/app-sdk/menu";
|
|
519
|
+
import { filterFromParam, filterToParam } from "@makoai/app-sdk/ui";
|
|
520
|
+
|
|
521
|
+
const traffic = filterFromParam(TRAFFIC, params.get("traffic"));
|
|
522
|
+
<FilterMenu label="Traffic" allLabel="All traffic" options={TRAFFIC}
|
|
523
|
+
selected={traffic} onChange={v => setParam("traffic", filterToParam(TRAFFIC, v))} />
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
- A group opens as a hover submenu (or with →) that starts with
|
|
527
|
+
"All <group>"; its own checkbox ticks the whole group without opening it.
|
|
528
|
+
- Every row has an "Only" action on hover. Rows carry no hover text: a
|
|
529
|
+
filter's definitions belong in its label's info note.
|
|
530
|
+
- The All rule and the "None" draft are `MultiSelect`'s (above).
|
|
531
|
+
- `FilterMenuItems` is the rows alone, for an app's own toolbar menu. On a
|
|
532
|
+
phone, `drill={{ open: node => … }}` opens a group in place and
|
|
533
|
+
`root={node}` lists that group's rows.
|
|
534
|
+
|
|
535
|
+
The folder ships TypeScript source; the app's Vite compiles it. It needs
|
|
536
|
+
the shadcn stack an app already has (`radix-ui`, `lucide-react`, `clsx`,
|
|
537
|
+
`tailwind-merge`, optional peers of the SDK) and Tailwind must see its
|
|
538
|
+
classes. Add one line to the app's CSS, after the Tailwind imports:
|
|
539
|
+
|
|
540
|
+
```css
|
|
541
|
+
@source "../node_modules/@makoai/app-sdk/menu";
|
|
542
|
+
```
|
|
543
|
+
|
|
466
544
|
### Chart tooltips: `TableTooltip` (2.10+, every series from 2.15)
|
|
467
545
|
|
|
468
546
|
Every chart tooltip is a table, never recharts' coloured `name : value` list:
|
|
@@ -667,8 +745,18 @@ at once. Once it is older than `revalidateMs` (five minutes), it is also
|
|
|
667
745
|
rebuilt in the background for the next load. `?refresh` waits for a
|
|
668
746
|
build. A copy from other text is never served: after an edit the cache is never served, however long
|
|
669
747
|
`revalidateMs` is, and while the API is unreachable a stale copy is served
|
|
670
|
-
only if it was built from the same text.
|
|
671
|
-
production builds
|
|
748
|
+
only if it was built from the same text. The data middleware runs in
|
|
749
|
+
`vite dev` only; production builds load the plugin for the favicon alone.
|
|
750
|
+
|
|
751
|
+
### Favicon
|
|
752
|
+
|
|
753
|
+
`makoData()` also links the app's favicon in `index.html`, in `vite dev` and
|
|
754
|
+
in `vite build`: the app's `icon.svg` (or `icon.png`) at its root, inlined
|
|
755
|
+
as a data URI so it works under any base path. An app without one gets a
|
|
756
|
+
generated letter mark: its `mako.json` title's first letter, white on a
|
|
757
|
+
rounded square whose hue comes from its id, as Mako's Apps explorer draws
|
|
758
|
+
it. An `index.html` that already has a `<link rel="icon">` is left alone;
|
|
759
|
+
`makoData({ favicon: false })` turns it off.
|
|
672
760
|
|
|
673
761
|
### dbt models you are still building
|
|
674
762
|
|
package/index.js
CHANGED
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
* in a page (or this export) says which SDK a deployed app actually runs.
|
|
38
38
|
* Kept in step with package.json by snapshot.test.mjs.
|
|
39
39
|
*/
|
|
40
|
-
export const SDK_VERSION = "2.
|
|
40
|
+
export const SDK_VERSION = "2.20.0";
|
|
41
41
|
if (typeof window !== "undefined") {
|
|
42
42
|
try {
|
|
43
43
|
window.__MAKO_APP_SDK__ = SDK_VERSION;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CheckIcon, MinusIcon } from "lucide-react";
|
|
2
|
+
import { Checkbox as CheckboxPrimitive } from "radix-ui";
|
|
3
|
+
import type * as React from "react";
|
|
4
|
+
import { cn } from "./utils";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* shadcn's Checkbox, with the indeterminate state: a white tick when checked,
|
|
8
|
+
* a white dash when indeterminate, both on the brand colour; an empty box
|
|
9
|
+
* when unchecked. The one checkbox style of the app.
|
|
10
|
+
*/
|
|
11
|
+
function Checkbox({ className, checked, ...props }: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
|
12
|
+
return (
|
|
13
|
+
<CheckboxPrimitive.Root
|
|
14
|
+
data-slot="checkbox"
|
|
15
|
+
checked={checked}
|
|
16
|
+
className={cn(
|
|
17
|
+
"peer size-4 shrink-0 rounded-[4px] border border-input bg-background shadow-xs outline-none transition-shadow",
|
|
18
|
+
"focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50",
|
|
19
|
+
"data-[state=checked]:border-[var(--brand)] data-[state=checked]:bg-[var(--brand)]",
|
|
20
|
+
"data-[state=indeterminate]:border-[var(--brand)] data-[state=indeterminate]:bg-[var(--brand)]",
|
|
21
|
+
className,
|
|
22
|
+
)}
|
|
23
|
+
{...props}
|
|
24
|
+
>
|
|
25
|
+
<CheckboxPrimitive.Indicator data-slot="checkbox-indicator" className="flex items-center justify-center">
|
|
26
|
+
{checked === "indeterminate" ? (
|
|
27
|
+
<MinusIcon className="size-3.5 text-white" strokeWidth={3} />
|
|
28
|
+
) : (
|
|
29
|
+
<CheckIcon className="size-3.5 text-white" strokeWidth={3} />
|
|
30
|
+
)}
|
|
31
|
+
</CheckboxPrimitive.Indicator>
|
|
32
|
+
</CheckboxPrimitive.Root>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { Checkbox };
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react";
|
|
2
|
+
import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui";
|
|
3
|
+
import type * as React from "react";
|
|
4
|
+
import { cn } from "./utils";
|
|
5
|
+
|
|
6
|
+
function DropdownMenu({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
|
|
7
|
+
return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function DropdownMenuPortal({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {
|
|
11
|
+
return <DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function DropdownMenuTrigger({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
|
|
15
|
+
return <DropdownMenuPrimitive.Trigger data-slot="dropdown-menu-trigger" {...props} />;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function DropdownMenuContent({ className, sideOffset = 4, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
|
|
19
|
+
return (
|
|
20
|
+
<DropdownMenuPrimitive.Portal>
|
|
21
|
+
<DropdownMenuPrimitive.Content
|
|
22
|
+
data-slot="dropdown-menu-content"
|
|
23
|
+
sideOffset={sideOffset}
|
|
24
|
+
className={cn(
|
|
25
|
+
"z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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",
|
|
26
|
+
className,
|
|
27
|
+
)}
|
|
28
|
+
{...props}
|
|
29
|
+
/>
|
|
30
|
+
</DropdownMenuPrimitive.Portal>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function DropdownMenuGroup({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
|
|
35
|
+
return <DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function DropdownMenuItem({
|
|
39
|
+
className,
|
|
40
|
+
inset,
|
|
41
|
+
variant = "default",
|
|
42
|
+
...props
|
|
43
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
|
|
44
|
+
inset?: boolean;
|
|
45
|
+
variant?: "default" | "destructive";
|
|
46
|
+
}) {
|
|
47
|
+
return (
|
|
48
|
+
<DropdownMenuPrimitive.Item
|
|
49
|
+
data-slot="dropdown-menu-item"
|
|
50
|
+
data-inset={inset}
|
|
51
|
+
data-variant={variant}
|
|
52
|
+
className={cn(
|
|
53
|
+
"relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!",
|
|
54
|
+
className,
|
|
55
|
+
)}
|
|
56
|
+
{...props}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function DropdownMenuCheckboxItem({
|
|
62
|
+
className,
|
|
63
|
+
children,
|
|
64
|
+
checked,
|
|
65
|
+
...props
|
|
66
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>) {
|
|
67
|
+
return (
|
|
68
|
+
<DropdownMenuPrimitive.CheckboxItem
|
|
69
|
+
data-slot="dropdown-menu-checkbox-item"
|
|
70
|
+
className={cn(
|
|
71
|
+
"relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
72
|
+
className,
|
|
73
|
+
)}
|
|
74
|
+
checked={checked}
|
|
75
|
+
{...props}
|
|
76
|
+
>
|
|
77
|
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
|
78
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
79
|
+
<CheckIcon className="size-4" />
|
|
80
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
81
|
+
</span>
|
|
82
|
+
{children}
|
|
83
|
+
</DropdownMenuPrimitive.CheckboxItem>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function DropdownMenuRadioGroup({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {
|
|
88
|
+
return <DropdownMenuPrimitive.RadioGroup data-slot="dropdown-menu-radio-group" {...props} />;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function DropdownMenuRadioItem({ className, children, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>) {
|
|
92
|
+
return (
|
|
93
|
+
<DropdownMenuPrimitive.RadioItem
|
|
94
|
+
data-slot="dropdown-menu-radio-item"
|
|
95
|
+
className={cn(
|
|
96
|
+
"relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
97
|
+
className,
|
|
98
|
+
)}
|
|
99
|
+
{...props}
|
|
100
|
+
>
|
|
101
|
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
|
102
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
103
|
+
<CircleIcon className="size-2 fill-current" />
|
|
104
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
105
|
+
</span>
|
|
106
|
+
{children}
|
|
107
|
+
</DropdownMenuPrimitive.RadioItem>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function DropdownMenuLabel({
|
|
112
|
+
className,
|
|
113
|
+
inset,
|
|
114
|
+
...props
|
|
115
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
|
|
116
|
+
inset?: boolean;
|
|
117
|
+
}) {
|
|
118
|
+
return (
|
|
119
|
+
<DropdownMenuPrimitive.Label
|
|
120
|
+
data-slot="dropdown-menu-label"
|
|
121
|
+
data-inset={inset}
|
|
122
|
+
className={cn("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8", className)}
|
|
123
|
+
{...props}
|
|
124
|
+
/>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function DropdownMenuSeparator({ className, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
|
|
129
|
+
return (
|
|
130
|
+
<DropdownMenuPrimitive.Separator
|
|
131
|
+
data-slot="dropdown-menu-separator"
|
|
132
|
+
className={cn("-mx-1 my-1 h-px bg-border", className)}
|
|
133
|
+
{...props}
|
|
134
|
+
/>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function DropdownMenuShortcut({ className, ...props }: React.ComponentProps<"span">) {
|
|
139
|
+
return (
|
|
140
|
+
<span
|
|
141
|
+
data-slot="dropdown-menu-shortcut"
|
|
142
|
+
className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)}
|
|
143
|
+
{...props}
|
|
144
|
+
/>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function DropdownMenuSub({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
|
|
149
|
+
return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function DropdownMenuSubTrigger({
|
|
153
|
+
className,
|
|
154
|
+
inset,
|
|
155
|
+
children,
|
|
156
|
+
...props
|
|
157
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
158
|
+
inset?: boolean;
|
|
159
|
+
}) {
|
|
160
|
+
return (
|
|
161
|
+
<DropdownMenuPrimitive.SubTrigger
|
|
162
|
+
data-slot="dropdown-menu-sub-trigger"
|
|
163
|
+
data-inset={inset}
|
|
164
|
+
className={cn(
|
|
165
|
+
"flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[inset]:pl-8 data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",
|
|
166
|
+
className,
|
|
167
|
+
)}
|
|
168
|
+
{...props}
|
|
169
|
+
>
|
|
170
|
+
{children}
|
|
171
|
+
<ChevronRightIcon className="ml-auto size-4" />
|
|
172
|
+
</DropdownMenuPrimitive.SubTrigger>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function DropdownMenuSubContent({ className, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
|
|
177
|
+
return (
|
|
178
|
+
<DropdownMenuPrimitive.SubContent
|
|
179
|
+
data-slot="dropdown-menu-sub-content"
|
|
180
|
+
className={cn(
|
|
181
|
+
"z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",
|
|
182
|
+
className,
|
|
183
|
+
)}
|
|
184
|
+
{...props}
|
|
185
|
+
/>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export {
|
|
190
|
+
DropdownMenu,
|
|
191
|
+
DropdownMenuCheckboxItem,
|
|
192
|
+
DropdownMenuContent,
|
|
193
|
+
DropdownMenuGroup,
|
|
194
|
+
DropdownMenuItem,
|
|
195
|
+
DropdownMenuLabel,
|
|
196
|
+
DropdownMenuPortal,
|
|
197
|
+
DropdownMenuRadioGroup,
|
|
198
|
+
DropdownMenuRadioItem,
|
|
199
|
+
DropdownMenuSeparator,
|
|
200
|
+
DropdownMenuShortcut,
|
|
201
|
+
DropdownMenuSub,
|
|
202
|
+
DropdownMenuSubContent,
|
|
203
|
+
DropdownMenuSubTrigger,
|
|
204
|
+
DropdownMenuTrigger,
|
|
205
|
+
};
|