@softure-ai/theme-notion 0.9.0 → 0.10.1
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/CHANGELOG.md +31 -0
- package/README.md +58 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/notion/InstallBar.d.ts +23 -0
- package/dist/notion/InstallBar.d.ts.map +1 -0
- package/dist/notion/InstallBar.js +16 -0
- package/dist/notion/InstallBar.js.map +1 -0
- package/dist/notion/MiniProgress.d.ts +13 -0
- package/dist/notion/MiniProgress.d.ts.map +1 -0
- package/dist/notion/MiniProgress.js +24 -0
- package/dist/notion/MiniProgress.js.map +1 -0
- package/dist/notion/UpdatePrompt.d.ts +13 -0
- package/dist/notion/UpdatePrompt.d.ts.map +1 -0
- package/dist/notion/UpdatePrompt.js +16 -0
- package/dist/notion/UpdatePrompt.js.map +1 -0
- package/dist/ui/accordion.d.ts +3 -1
- package/dist/ui/accordion.d.ts.map +1 -1
- package/dist/ui/accordion.js +2 -2
- package/dist/ui/accordion.js.map +1 -1
- package/dist/ui/button.d.ts +1 -1
- package/dist/ui/dialog.d.ts +2 -1
- package/dist/ui/dialog.d.ts.map +1 -1
- package/dist/ui/dialog.js +3 -2
- package/dist/ui/dialog.js.map +1 -1
- package/dist/ui/dropdown-menu.d.ts +14 -5
- package/dist/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/ui/dropdown-menu.js +21 -10
- package/dist/ui/dropdown-menu.js.map +1 -1
- package/dist/ui/tabs.d.ts +6 -2
- package/dist/ui/tabs.d.ts.map +1 -1
- package/dist/ui/tabs.js +13 -4
- package/dist/ui/tabs.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +3 -0
- package/src/notion/InstallBar.tsx +75 -0
- package/src/notion/MiniProgress.tsx +67 -0
- package/src/notion/UpdatePrompt.tsx +47 -0
- package/src/ui/accordion.tsx +5 -1
- package/src/ui/dialog.tsx +8 -1
- package/src/ui/dropdown-menu.tsx +55 -16
- package/src/ui/tabs.tsx +27 -7
package/dist/ui/dropdown-menu.js
CHANGED
|
@@ -4,6 +4,13 @@ import * as React from "react";
|
|
|
4
4
|
import { cn } from "../lib/utils.js";
|
|
5
5
|
import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react";
|
|
6
6
|
import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui";
|
|
7
|
+
// The items render in a portal, so a menu's size reaches them through context, not the DOM.
|
|
8
|
+
const DropdownMenuItemSizeContext = React.createContext("default");
|
|
9
|
+
// One height or the other: `cn` does not merge `min-h-7` with the theme's `touch-target` spacing.
|
|
10
|
+
function useItemHeight(size) {
|
|
11
|
+
const menuSize = React.useContext(DropdownMenuItemSizeContext);
|
|
12
|
+
return (size ?? menuSize) === "touch" ? "min-h-touch-target" : "min-h-7";
|
|
13
|
+
}
|
|
7
14
|
function DropdownMenu({ ...props }) {
|
|
8
15
|
return _jsx(DropdownMenuPrimitive.Root, { "data-slot": "dropdown-menu", ...props });
|
|
9
16
|
}
|
|
@@ -13,23 +20,26 @@ function DropdownMenuPortal({ ...props }) {
|
|
|
13
20
|
function DropdownMenuTrigger({ ...props }) {
|
|
14
21
|
return (_jsx(DropdownMenuPrimitive.Trigger, { "data-slot": "dropdown-menu-trigger", ...props }));
|
|
15
22
|
}
|
|
16
|
-
function DropdownMenuContent({ className, sideOffset = 4, ...props }) {
|
|
17
|
-
return (_jsx(DropdownMenuPrimitive.Portal, { children: _jsx(DropdownMenuPrimitive.Content, { "data-slot": "dropdown-menu-content", sideOffset: sideOffset, className: cn("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-xl bg-popover p-1 text-popover-foreground shadow-menu 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", className), ...props }) }));
|
|
23
|
+
function DropdownMenuContent({ className, sideOffset = 4, size = "default", ...props }) {
|
|
24
|
+
return (_jsx(DropdownMenuPrimitive.Portal, { children: _jsx(DropdownMenuItemSizeContext.Provider, { value: size, children: _jsx(DropdownMenuPrimitive.Content, { "data-slot": "dropdown-menu-content", sideOffset: sideOffset, className: cn("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-xl bg-popover p-1 text-popover-foreground shadow-menu 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", className), ...props }) }) }));
|
|
18
25
|
}
|
|
19
26
|
function DropdownMenuGroup({ ...props }) {
|
|
20
27
|
return (_jsx(DropdownMenuPrimitive.Group, { "data-slot": "dropdown-menu-group", ...props }));
|
|
21
28
|
}
|
|
22
|
-
function DropdownMenuItem({ className, inset, variant = "default", ...props }) {
|
|
23
|
-
|
|
29
|
+
function DropdownMenuItem({ className, inset, variant = "default", size, ...props }) {
|
|
30
|
+
const height = useItemHeight(size);
|
|
31
|
+
return (_jsx(DropdownMenuPrimitive.Item, { "data-slot": "dropdown-menu-item", "data-inset": inset, "data-variant": variant, className: cn("relative flex cursor-default items-center gap-2 rounded-md px-2 py-1 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/10 [&_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!", height, className), ...props }));
|
|
24
32
|
}
|
|
25
|
-
function DropdownMenuCheckboxItem({ className, children, checked, ...props }) {
|
|
26
|
-
|
|
33
|
+
function DropdownMenuCheckboxItem({ className, children, checked, size, ...props }) {
|
|
34
|
+
const height = useItemHeight(size);
|
|
35
|
+
return (_jsxs(DropdownMenuPrimitive.CheckboxItem, { "data-slot": "dropdown-menu-checkbox-item", className: cn("relative flex cursor-default items-center gap-2 rounded-md py-1 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", height, className), checked: checked, ...props, children: [_jsx("span", { className: "pointer-events-none absolute left-2 flex size-3.5 items-center justify-center", children: _jsx(DropdownMenuPrimitive.ItemIndicator, { children: _jsx(CheckIcon, { className: "size-4" }) }) }), children] }));
|
|
27
36
|
}
|
|
28
37
|
function DropdownMenuRadioGroup({ ...props }) {
|
|
29
38
|
return (_jsx(DropdownMenuPrimitive.RadioGroup, { "data-slot": "dropdown-menu-radio-group", ...props }));
|
|
30
39
|
}
|
|
31
|
-
function DropdownMenuRadioItem({ className, children, ...props }) {
|
|
32
|
-
|
|
40
|
+
function DropdownMenuRadioItem({ className, children, size, ...props }) {
|
|
41
|
+
const height = useItemHeight(size);
|
|
42
|
+
return (_jsxs(DropdownMenuPrimitive.RadioItem, { "data-slot": "dropdown-menu-radio-item", className: cn("relative flex cursor-default items-center gap-2 rounded-md py-1 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", height, className), ...props, children: [_jsx("span", { className: "pointer-events-none absolute left-2 flex size-3.5 items-center justify-center", children: _jsx(DropdownMenuPrimitive.ItemIndicator, { children: _jsx(CircleIcon, { className: "size-2 fill-current" }) }) }), children] }));
|
|
33
43
|
}
|
|
34
44
|
function DropdownMenuLabel({ className, inset, ...props }) {
|
|
35
45
|
return (_jsx(DropdownMenuPrimitive.Label, { "data-slot": "dropdown-menu-label", "data-inset": inset, className: cn("px-2 py-1.5 text-xs font-medium text-muted-foreground data-[inset]:pl-8", className), ...props }));
|
|
@@ -43,8 +53,9 @@ function DropdownMenuShortcut({ className, ...props }) {
|
|
|
43
53
|
function DropdownMenuSub({ ...props }) {
|
|
44
54
|
return _jsx(DropdownMenuPrimitive.Sub, { "data-slot": "dropdown-menu-sub", ...props });
|
|
45
55
|
}
|
|
46
|
-
function DropdownMenuSubTrigger({ className, inset, children, ...props }) {
|
|
47
|
-
|
|
56
|
+
function DropdownMenuSubTrigger({ className, inset, children, size, ...props }) {
|
|
57
|
+
const height = useItemHeight(size);
|
|
58
|
+
return (_jsxs(DropdownMenuPrimitive.SubTrigger, { "data-slot": "dropdown-menu-sub-trigger", "data-inset": inset, className: cn("flex cursor-default items-center gap-2 rounded-md px-2 py-1 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", height, className), ...props, children: [children, _jsx(ChevronRightIcon, { className: "ml-auto size-4" })] }));
|
|
48
59
|
}
|
|
49
60
|
function DropdownMenuSubContent({ className, ...props }) {
|
|
50
61
|
return (_jsx(DropdownMenuPrimitive.SubContent, { "data-slot": "dropdown-menu-sub-content", className: cn("z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-xl bg-popover p-1 text-popover-foreground shadow-menu 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", className), ...props }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown-menu.js","sourceRoot":"","sources":["../../src/ui/dropdown-menu.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACtE,OAAO,EAAE,YAAY,IAAI,qBAAqB,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"dropdown-menu.js","sourceRoot":"","sources":["../../src/ui/dropdown-menu.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACtE,OAAO,EAAE,YAAY,IAAI,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAIhE,4FAA4F;AAC5F,MAAM,2BAA2B,GAC/B,KAAK,CAAC,aAAa,CAAuB,SAAS,CAAC,CAAA;AAEtD,kGAAkG;AAClG,SAAS,aAAa,CAAC,IAAsC;IAC3D,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,2BAA2B,CAAC,CAAA;IAC9D,OAAO,CAAC,IAAI,IAAI,QAAQ,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAA;AAC1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SAAS,EAAE,EAAE,CACX,0eAA0e,EAC1e,SAAS,CACV,KACG,KAAK,GACT,CACH,CAAA;AACH,CAAC;AAED,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,GACvB,CAAA"}
|
package/dist/ui/tabs.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type VariantProps } from "class-variance-authority";
|
|
3
3
|
import { Tabs as TabsPrimitive } from "radix-ui";
|
|
4
|
+
type TabsTriggerSize = "default" | "touch";
|
|
4
5
|
declare function Tabs({ className, orientation, ...props }: React.ComponentProps<typeof TabsPrimitive.Root>): React.JSX.Element;
|
|
5
6
|
declare const tabsListVariants: (props?: ({
|
|
6
7
|
variant?: "default" | "line" | null | undefined;
|
|
8
|
+
size?: "default" | "touch" | null | undefined;
|
|
7
9
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
|
-
declare function TabsList({ className, variant, ...props }: React.ComponentProps<typeof TabsPrimitive.List> & VariantProps<typeof tabsListVariants>): React.JSX.Element;
|
|
9
|
-
declare function TabsTrigger({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Trigger>
|
|
10
|
+
declare function TabsList({ className, variant, size, ...props }: React.ComponentProps<typeof TabsPrimitive.List> & VariantProps<typeof tabsListVariants>): React.JSX.Element;
|
|
11
|
+
declare function TabsTrigger({ className, size, ...props }: React.ComponentProps<typeof TabsPrimitive.Trigger> & {
|
|
12
|
+
size?: TabsTriggerSize;
|
|
13
|
+
}): React.JSX.Element;
|
|
10
14
|
declare function TabsContent({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Content>): React.JSX.Element;
|
|
11
15
|
export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants };
|
|
12
16
|
//# sourceMappingURL=tabs.d.ts.map
|
package/dist/ui/tabs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../src/ui/tabs.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEjE,OAAO,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,UAAU,CAAA;AAEhD,iBAAS,IAAI,CAAC,EACZ,SAAS,EACT,WAA0B,EAC1B,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,IAAI,CAAC,qBAajD;AAED,QAAA,MAAM,gBAAgB
|
|
1
|
+
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../src/ui/tabs.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEjE,OAAO,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,UAAU,CAAA;AAEhD,KAAK,eAAe,GAAG,SAAS,GAAG,OAAO,CAAA;AAK1C,iBAAS,IAAI,CAAC,EACZ,SAAS,EACT,WAA0B,EAC1B,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,IAAI,CAAC,qBAajD;AAED,QAAA,MAAM,gBAAgB;;;8EAmBrB,CAAA;AAED,iBAAS,QAAQ,CAAC,EAChB,SAAS,EACT,OAAgB,EAChB,IAAgB,EAChB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,IAAI,CAAC,GAChD,YAAY,CAAC,OAAO,gBAAgB,CAAC,qBAWtC;AAED,iBAAS,WAAW,CAAC,EACnB,SAAS,EACT,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,OAAO,CAAC,GAAG;IACtD,IAAI,CAAC,EAAE,eAAe,CAAA;CACvB,qBAiBA;AAED,iBAAS,WAAW,CAAC,EACnB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,OAAO,CAAC,qBAQpD;AAED,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAA"}
|
package/dist/ui/tabs.js
CHANGED
|
@@ -4,6 +4,8 @@ import * as React from "react";
|
|
|
4
4
|
import { cva } from "class-variance-authority";
|
|
5
5
|
import { cn } from "../lib/utils.js";
|
|
6
6
|
import { Tabs as TabsPrimitive } from "radix-ui";
|
|
7
|
+
// A list's size reaches its triggers through context, so a trigger's own size can win over it.
|
|
8
|
+
const TabsTriggerSizeContext = React.createContext("default");
|
|
7
9
|
function Tabs({ className, orientation = "horizontal", ...props }) {
|
|
8
10
|
return (_jsx(TabsPrimitive.Root, { "data-slot": "tabs", "data-orientation": orientation, orientation: orientation, className: cn("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col", className), ...props }));
|
|
9
11
|
}
|
|
@@ -13,16 +15,23 @@ const tabsListVariants = cva("group/tabs-list inline-flex w-fit items-center jus
|
|
|
13
15
|
default: "bg-muted",
|
|
14
16
|
line: "gap-1 bg-transparent",
|
|
15
17
|
},
|
|
18
|
+
size: {
|
|
19
|
+
default: "",
|
|
20
|
+
// The triggers set the height: a fixed one would cap them at 35 px.
|
|
21
|
+
touch: "group-data-[orientation=horizontal]/tabs:h-auto",
|
|
22
|
+
},
|
|
16
23
|
},
|
|
17
24
|
defaultVariants: {
|
|
18
25
|
variant: "line",
|
|
26
|
+
size: "default",
|
|
19
27
|
},
|
|
20
28
|
});
|
|
21
|
-
function TabsList({ className, variant = "line", ...props }) {
|
|
22
|
-
return (_jsx(TabsPrimitive.List, { "data-slot": "tabs-list", "data-variant": variant, className: cn(tabsListVariants({ variant }), className), ...props }));
|
|
29
|
+
function TabsList({ className, variant = "line", size = "default", ...props }) {
|
|
30
|
+
return (_jsx(TabsTriggerSizeContext.Provider, { value: size ?? "default", children: _jsx(TabsPrimitive.List, { "data-slot": "tabs-list", "data-variant": variant, className: cn(tabsListVariants({ variant, size }), className), ...props }) }));
|
|
23
31
|
}
|
|
24
|
-
function TabsTrigger({ className, ...props }) {
|
|
25
|
-
|
|
32
|
+
function TabsTrigger({ className, size, ...props }) {
|
|
33
|
+
const listSize = React.useContext(TabsTriggerSizeContext);
|
|
34
|
+
return (_jsx(TabsPrimitive.Trigger, { "data-slot": "tabs-trigger", className: cn("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-muted-foreground 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-2 focus-visible:ring-ring 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:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", "group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent", "bg-clip-padding data-[state=active]:border-input data-[state=active]:bg-background data-[state=active]:text-foreground focus-visible:data-[state=active]:border-ring dark:data-[state=active]:bg-accent/40 dark:data-[state=active]:text-foreground", "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", (size ?? listSize) === "touch" && "min-h-touch-target min-w-touch-target", className), ...props }));
|
|
26
35
|
}
|
|
27
36
|
function TabsContent({ className, ...props }) {
|
|
28
37
|
return (_jsx(TabsPrimitive.Content, { "data-slot": "tabs-content", className: cn("flex-1 outline-none", className), ...props }));
|
package/dist/ui/tabs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.js","sourceRoot":"","sources":["../../src/ui/tabs.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"tabs.js","sourceRoot":"","sources":["../../src/ui/tabs.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,UAAU,CAAA;AAIhD,+FAA+F;AAC/F,MAAM,sBAAsB,GAAG,KAAK,CAAC,aAAa,CAAkB,SAAS,CAAC,CAAA;AAE9E,SAAS,IAAI,CAAC,EACZ,SAAS,EACT,WAAW,GAAG,YAAY,EAC1B,GAAG,KAAK,EACwC;IAChD,OAAO,CACL,KAAC,aAAa,CAAC,IAAI,iBAC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CAAC;AAED,SAAS,WAAW,CAAC,EACnB,SAAS,EACT,GAAG,KAAK,EAC2C;IACnD,OAAO,CACL,KAAC,aAAa,CAAC,OAAO,iBACV,cAAc,EACxB,SAAS,EAAE,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,KAC3C,KAAK,GACT,CACH,CAAA;AACH,CAAC;AAED,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softure-ai/theme-notion",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "SOFTURE AI Notion theme: shadcn/ui components (new-york v4, Radix, Tailwind CSS v4, lucide) with the Notion design system's tokens and deltas, ready to import.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/index.ts
CHANGED
|
@@ -48,8 +48,10 @@ export { Code, CodeBlock, type CodeBlockProps } from "./notion/Code.js";
|
|
|
48
48
|
export { DetailTable, type DetailRow, type DetailTableProps } from "./notion/DetailTable.js";
|
|
49
49
|
export { FilterChip, FilterChipAdd, type FilterChipAddProps, type FilterChipProps } from "./notion/FilterChip.js";
|
|
50
50
|
export { FoldRow, type FoldRowBadge, type FoldRowProps } from "./notion/FoldRow.js";
|
|
51
|
+
export { InstallBar, type InstallBarOffer, type InstallBarProps } from "./notion/InstallBar.js";
|
|
51
52
|
export { PALETTE_COLORS, type PaletteColor } from "./notion/palette.js";
|
|
52
53
|
export { MarkPopover, type MarkPopoverProps } from "./notion/MarkPopover.js";
|
|
54
|
+
export { MiniProgress, type MiniProgressProps } from "./notion/MiniProgress.js";
|
|
53
55
|
export { PageFrame, type PageFrameProps } from "./notion/PageFrame.js";
|
|
54
56
|
export { PageHeader, type PageCrumb, type PageHeaderProps } from "./notion/PageHeader.js";
|
|
55
57
|
export { PropertyList, type Property, type PropertyListProps } from "./notion/PropertyList.js";
|
|
@@ -83,4 +85,5 @@ export { Status, type StatusProps } from "./notion/Status.js";
|
|
|
83
85
|
export { Steps, type StepItem, type StepState, type StepsLayout, type StepsProps } from "./notion/Steps.js";
|
|
84
86
|
export { TabBar, type TabBarItem, type TabBarProps } from "./notion/TabBar.js";
|
|
85
87
|
export { Timeline, type TimelineItem, type TimelineItemSize, type TimelineLine, type TimelineProps } from "./notion/Timeline.js";
|
|
88
|
+
export { UpdatePrompt, type UpdatePromptProps } from "./notion/UpdatePrompt.js";
|
|
86
89
|
export { TONES, TONE_COLORS, TONE_EDGE, TONE_FILL, TONE_TEXT, type Tone } from "./notion/tones.js";
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Download, Share, SquarePlus, X } from "lucide-react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
import { Alert, AlertDescription, AlertTitle } from "../ui/alert.js";
|
|
5
|
+
import { Button } from "../ui/button.js";
|
|
6
|
+
|
|
7
|
+
import { ICON_STROKE_WIDTH } from "./icon-stroke.js";
|
|
8
|
+
|
|
9
|
+
/** The offer to show, as `useInstallOffer` in `@softure-ai/pwa/react` picks it. */
|
|
10
|
+
export type InstallBarOffer = "ios_steps" | "browser_prompt" | "none";
|
|
11
|
+
|
|
12
|
+
export interface InstallBarProps {
|
|
13
|
+
/** `offer` from `useInstallOffer`: the browser's prompt button, the iOS steps, or nothing. */
|
|
14
|
+
readonly offer: InstallBarOffer;
|
|
15
|
+
readonly title: string;
|
|
16
|
+
readonly description: string;
|
|
17
|
+
/** The prompt button's text. */
|
|
18
|
+
readonly install: string;
|
|
19
|
+
/** The first iOS step, beside the Share icon. */
|
|
20
|
+
readonly shareStep: string;
|
|
21
|
+
/** The second iOS step, beside the Add to Home Screen icon. */
|
|
22
|
+
readonly addStep: string;
|
|
23
|
+
/** The close button's accessible name. */
|
|
24
|
+
readonly close: string;
|
|
25
|
+
/** The prompt button's action (`install` from `useInstallOffer`): the browser's install sheet. */
|
|
26
|
+
readonly onInstall: () => void;
|
|
27
|
+
/** The close button's action (`close` from `useInstallOffer`): the offer stays closed on this device. */
|
|
28
|
+
readonly onClose: () => void;
|
|
29
|
+
readonly className?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// The offer to install the app on a phone: a floating alert at the bottom of the screen, inside the safe-area insets
|
|
33
|
+
// like UpdatePrompt, with the browser's install button or the two iOS steps (Share, then Add to Home Screen) and a
|
|
34
|
+
// close button, both at the touch size on a phone. A polite status: it never interrupts a screen reader. The copy is
|
|
35
|
+
// the app's (`pwaMessages.en.install` in `@softure-ai/pwa` has the English text, keyed like these props).
|
|
36
|
+
export function InstallBar({ offer, title, description, install, shareStep, addStep, close, onInstall, onClose, className }: InstallBarProps) {
|
|
37
|
+
if (offer === "none") return null;
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
data-slot="install-bar"
|
|
41
|
+
data-offer={offer}
|
|
42
|
+
className={cn(
|
|
43
|
+
"pointer-events-none fixed inset-x-0 bottom-0 z-50 flex justify-center pt-4 pr-[calc(--spacing(4)+env(safe-area-inset-right))] pb-[calc(--spacing(4)+env(safe-area-inset-bottom))] pl-[calc(--spacing(4)+env(safe-area-inset-left))]",
|
|
44
|
+
className,
|
|
45
|
+
)}
|
|
46
|
+
>
|
|
47
|
+
<Alert role="status" aria-live="polite" className="pointer-events-auto max-w-md pr-14 shadow-menu md:pr-11">
|
|
48
|
+
<Download strokeWidth={ICON_STROKE_WIDTH} />
|
|
49
|
+
<AlertTitle>{title}</AlertTitle>
|
|
50
|
+
<AlertDescription>
|
|
51
|
+
<p>{description}</p>
|
|
52
|
+
{offer === "browser_prompt" ? (
|
|
53
|
+
<Button size="touch" className="mt-1 md:h-7" onClick={onInstall}>
|
|
54
|
+
{install}
|
|
55
|
+
</Button>
|
|
56
|
+
) : (
|
|
57
|
+
<ol data-slot="install-bar-steps" className="mt-1 grid gap-1.5 text-foreground">
|
|
58
|
+
<li className="flex items-center gap-2">
|
|
59
|
+
<Share aria-hidden="true" className="size-4 shrink-0" strokeWidth={ICON_STROKE_WIDTH} />
|
|
60
|
+
{shareStep}
|
|
61
|
+
</li>
|
|
62
|
+
<li className="flex items-center gap-2">
|
|
63
|
+
<SquarePlus aria-hidden="true" className="size-4 shrink-0" strokeWidth={ICON_STROKE_WIDTH} />
|
|
64
|
+
{addStep}
|
|
65
|
+
</li>
|
|
66
|
+
</ol>
|
|
67
|
+
)}
|
|
68
|
+
</AlertDescription>
|
|
69
|
+
<Button type="button" variant="ghost" size="icon-touch" aria-label={close} className="absolute top-0 right-0 md:top-1 md:right-1 md:size-7" onClick={onClose}>
|
|
70
|
+
<X aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} />
|
|
71
|
+
</Button>
|
|
72
|
+
</Alert>
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Progress as ProgressPrimitive } from "radix-ui";
|
|
4
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
5
|
+
|
|
6
|
+
import { cn } from "../lib/utils.js";
|
|
7
|
+
|
|
8
|
+
import { TONE_FILL, type Tone } from "./tones.js";
|
|
9
|
+
|
|
10
|
+
export type MiniProgressProps = Omit<ComponentProps<typeof ProgressPrimitive.Root>, "children" | "max" | "value"> & {
|
|
11
|
+
/** 0–100, clamped; non-finite values read as 0. */
|
|
12
|
+
readonly value: number;
|
|
13
|
+
/** Text inside the bar, e.g. a formatted amount; defaults to the rounded percent. */
|
|
14
|
+
readonly label?: ReactNode;
|
|
15
|
+
/** Fill colour by meaning (the theme's tones); defaults to primary. */
|
|
16
|
+
readonly tone?: Tone;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function clampShare(value: number): number {
|
|
20
|
+
if (!Number.isFinite(value)) return 0;
|
|
21
|
+
return Math.min(100, Math.max(0, value));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const LABEL_CLASS = "absolute inset-0 flex items-center px-2 text-xs font-medium tabular-nums whitespace-nowrap";
|
|
25
|
+
|
|
26
|
+
// A share with its figure inside the bar, for a table cell or a tile: a 20 px track that takes the cell's width and
|
|
27
|
+
// carries the label, so a figure and a bar never collide in a narrow column. The label is drawn twice: in the text
|
|
28
|
+
// colour on the track, and in the page background clipped to the fill, so it reads at any value, also where the
|
|
29
|
+
// fill's edge crosses a letter. Both copies are hidden: the progress bar itself reports the value (and a string label
|
|
30
|
+
// as its value text). A label wider than the cell ends in an ellipsis.
|
|
31
|
+
export function MiniProgress({ value, label, tone, className, ...props }: MiniProgressProps) {
|
|
32
|
+
const share = clampShare(value);
|
|
33
|
+
const text = label ?? `${Math.round(share)}%`;
|
|
34
|
+
return (
|
|
35
|
+
<ProgressPrimitive.Root
|
|
36
|
+
data-slot="mini-progress"
|
|
37
|
+
data-tone={tone ?? "default"}
|
|
38
|
+
value={share}
|
|
39
|
+
max={100}
|
|
40
|
+
getValueLabel={typeof text === "string" ? () => text : undefined}
|
|
41
|
+
className={cn("relative h-5 w-full min-w-16 overflow-hidden rounded-sm bg-primary/12", className)}
|
|
42
|
+
{...props}
|
|
43
|
+
>
|
|
44
|
+
<ProgressPrimitive.Indicator
|
|
45
|
+
data-slot="mini-progress-indicator"
|
|
46
|
+
className={cn(
|
|
47
|
+
"absolute inset-y-0 left-0 transition-[width]",
|
|
48
|
+
// In dark the default fill is the lighter link blue, as in `Progress`.
|
|
49
|
+
tone === undefined ? "bg-primary dark:bg-link" : TONE_FILL[tone],
|
|
50
|
+
)}
|
|
51
|
+
style={{ width: `${share}%` }}
|
|
52
|
+
/>
|
|
53
|
+
<span aria-hidden="true" data-slot="mini-progress-label" className={cn(LABEL_CLASS, "text-foreground")}>
|
|
54
|
+
<span className="truncate">{text}</span>
|
|
55
|
+
</span>
|
|
56
|
+
{/* The page background, not `primary-foreground`: white on the dark fills stays under 4.5:1. */}
|
|
57
|
+
<span
|
|
58
|
+
aria-hidden="true"
|
|
59
|
+
data-slot="mini-progress-label"
|
|
60
|
+
className={cn(LABEL_CLASS, "text-background")}
|
|
61
|
+
style={{ clipPath: `inset(0 ${100 - share}% 0 0)` }}
|
|
62
|
+
>
|
|
63
|
+
<span className="truncate">{text}</span>
|
|
64
|
+
</span>
|
|
65
|
+
</ProgressPrimitive.Root>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { RefreshCw } from "lucide-react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
import { Alert, AlertDescription, AlertTitle } from "../ui/alert.js";
|
|
5
|
+
import { Button } from "../ui/button.js";
|
|
6
|
+
|
|
7
|
+
import { ICON_STROKE_WIDTH } from "./icon-stroke.js";
|
|
8
|
+
|
|
9
|
+
export interface UpdatePromptProps {
|
|
10
|
+
/** A new build waits (`isUpdateReady` from `useServiceWorkerUpdate` in `@softure-ai/pwa/react`). */
|
|
11
|
+
readonly open: boolean;
|
|
12
|
+
readonly title: string;
|
|
13
|
+
readonly description: string;
|
|
14
|
+
/** The button's text. */
|
|
15
|
+
readonly reload: string;
|
|
16
|
+
/** The button's action (`activate` from `useServiceWorkerUpdate`): the new build takes over and the page reloads. */
|
|
17
|
+
readonly onReload: () => void;
|
|
18
|
+
readonly className?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// The offer to reload into a new build: a floating alert at the bottom of the screen, above the home indicator and
|
|
22
|
+
// beside a notch (the safe-area insets), with a reload button at the touch height on a phone. It is a polite status,
|
|
23
|
+
// not an alert: the offer never interrupts what a screen reader is reading. The copy is the app's
|
|
24
|
+
// (`pwaMessages.en.update` in `@softure-ai/pwa` has the English text, keyed like these props).
|
|
25
|
+
export function UpdatePrompt({ open, title, description, reload, onReload, className }: UpdatePromptProps) {
|
|
26
|
+
if (!open) return null;
|
|
27
|
+
return (
|
|
28
|
+
<div
|
|
29
|
+
data-slot="update-prompt"
|
|
30
|
+
className={cn(
|
|
31
|
+
"pointer-events-none fixed inset-x-0 bottom-0 z-50 flex justify-center pt-4 pr-[calc(--spacing(4)+env(safe-area-inset-right))] pb-[calc(--spacing(4)+env(safe-area-inset-bottom))] pl-[calc(--spacing(4)+env(safe-area-inset-left))]",
|
|
32
|
+
className,
|
|
33
|
+
)}
|
|
34
|
+
>
|
|
35
|
+
<Alert role="status" aria-live="polite" className="pointer-events-auto max-w-md shadow-menu">
|
|
36
|
+
<RefreshCw strokeWidth={ICON_STROKE_WIDTH} />
|
|
37
|
+
<AlertTitle>{title}</AlertTitle>
|
|
38
|
+
<AlertDescription>
|
|
39
|
+
<p>{description}</p>
|
|
40
|
+
<Button size="touch" className="mt-1 md:h-7" onClick={onReload}>
|
|
41
|
+
{reload}
|
|
42
|
+
</Button>
|
|
43
|
+
</AlertDescription>
|
|
44
|
+
</Alert>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
package/src/ui/accordion.tsx
CHANGED
|
@@ -27,14 +27,18 @@ function AccordionItem({
|
|
|
27
27
|
function AccordionTrigger({
|
|
28
28
|
className,
|
|
29
29
|
children,
|
|
30
|
+
size = "default",
|
|
30
31
|
...props
|
|
31
|
-
}: React.ComponentProps<typeof AccordionPrimitive.Trigger>
|
|
32
|
+
}: React.ComponentProps<typeof AccordionPrimitive.Trigger> & {
|
|
33
|
+
size?: "default" | "touch"
|
|
34
|
+
}) {
|
|
32
35
|
return (
|
|
33
36
|
<AccordionPrimitive.Header className="flex">
|
|
34
37
|
<AccordionPrimitive.Trigger
|
|
35
38
|
data-slot="accordion-trigger"
|
|
36
39
|
className={cn(
|
|
37
40
|
"flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",
|
|
41
|
+
size === "touch" && "min-h-touch-target",
|
|
38
42
|
className
|
|
39
43
|
)}
|
|
40
44
|
{...props}
|
package/src/ui/dialog.tsx
CHANGED
|
@@ -53,11 +53,14 @@ function DialogContent({
|
|
|
53
53
|
children,
|
|
54
54
|
showCloseButton = true,
|
|
55
55
|
closeLabel = messages.dialog.close,
|
|
56
|
+
closeButtonSize = "default",
|
|
56
57
|
...props
|
|
57
58
|
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
58
59
|
showCloseButton?: boolean
|
|
59
60
|
// The close button's hidden text, from the app's message layer.
|
|
60
61
|
closeLabel?: string
|
|
62
|
+
// `touch` draws the close button 44 x 44, centred on the same icon.
|
|
63
|
+
closeButtonSize?: "default" | "touch"
|
|
61
64
|
}) {
|
|
62
65
|
return (
|
|
63
66
|
<DialogPortal data-slot="dialog-portal">
|
|
@@ -74,7 +77,11 @@ function DialogContent({
|
|
|
74
77
|
{showCloseButton && (
|
|
75
78
|
<DialogPrimitive.Close
|
|
76
79
|
data-slot="dialog-close"
|
|
77
|
-
className=
|
|
80
|
+
className={cn(
|
|
81
|
+
"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",
|
|
82
|
+
closeButtonSize === "touch" &&
|
|
83
|
+
"top-0.5 right-0.5 inline-flex size-touch-target items-center justify-center rounded-md"
|
|
84
|
+
)}
|
|
78
85
|
>
|
|
79
86
|
<XIcon />
|
|
80
87
|
<span className="sr-only">{closeLabel}</span>
|
package/src/ui/dropdown-menu.tsx
CHANGED
|
@@ -5,6 +5,18 @@ import { cn } from "../lib/utils.js"
|
|
|
5
5
|
import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react"
|
|
6
6
|
import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui"
|
|
7
7
|
|
|
8
|
+
type DropdownMenuItemSize = "default" | "touch"
|
|
9
|
+
|
|
10
|
+
// The items render in a portal, so a menu's size reaches them through context, not the DOM.
|
|
11
|
+
const DropdownMenuItemSizeContext =
|
|
12
|
+
React.createContext<DropdownMenuItemSize>("default")
|
|
13
|
+
|
|
14
|
+
// One height or the other: `cn` does not merge `min-h-7` with the theme's `touch-target` spacing.
|
|
15
|
+
function useItemHeight(size: DropdownMenuItemSize | undefined) {
|
|
16
|
+
const menuSize = React.useContext(DropdownMenuItemSizeContext)
|
|
17
|
+
return (size ?? menuSize) === "touch" ? "min-h-touch-target" : "min-h-7"
|
|
18
|
+
}
|
|
19
|
+
|
|
8
20
|
function DropdownMenu({
|
|
9
21
|
...props
|
|
10
22
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
|
|
@@ -33,19 +45,24 @@ function DropdownMenuTrigger({
|
|
|
33
45
|
function DropdownMenuContent({
|
|
34
46
|
className,
|
|
35
47
|
sideOffset = 4,
|
|
48
|
+
size = "default",
|
|
36
49
|
...props
|
|
37
|
-
}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>
|
|
50
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Content> & {
|
|
51
|
+
size?: DropdownMenuItemSize
|
|
52
|
+
}) {
|
|
38
53
|
return (
|
|
39
54
|
<DropdownMenuPrimitive.Portal>
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
55
|
+
<DropdownMenuItemSizeContext.Provider value={size}>
|
|
56
|
+
<DropdownMenuPrimitive.Content
|
|
57
|
+
data-slot="dropdown-menu-content"
|
|
58
|
+
sideOffset={sideOffset}
|
|
59
|
+
className={cn(
|
|
60
|
+
"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-xl bg-popover p-1 text-popover-foreground shadow-menu 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",
|
|
61
|
+
className
|
|
62
|
+
)}
|
|
63
|
+
{...props}
|
|
64
|
+
/>
|
|
65
|
+
</DropdownMenuItemSizeContext.Provider>
|
|
49
66
|
</DropdownMenuPrimitive.Portal>
|
|
50
67
|
)
|
|
51
68
|
}
|
|
@@ -62,18 +79,23 @@ function DropdownMenuItem({
|
|
|
62
79
|
className,
|
|
63
80
|
inset,
|
|
64
81
|
variant = "default",
|
|
82
|
+
size,
|
|
65
83
|
...props
|
|
66
84
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
|
|
67
85
|
inset?: boolean
|
|
68
86
|
variant?: "default" | "destructive"
|
|
87
|
+
size?: DropdownMenuItemSize
|
|
69
88
|
}) {
|
|
89
|
+
const height = useItemHeight(size)
|
|
90
|
+
|
|
70
91
|
return (
|
|
71
92
|
<DropdownMenuPrimitive.Item
|
|
72
93
|
data-slot="dropdown-menu-item"
|
|
73
94
|
data-inset={inset}
|
|
74
95
|
data-variant={variant}
|
|
75
96
|
className={cn(
|
|
76
|
-
"relative flex cursor-default items-center gap-2 rounded-md
|
|
97
|
+
"relative flex cursor-default items-center gap-2 rounded-md px-2 py-1 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/10 [&_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!",
|
|
98
|
+
height,
|
|
77
99
|
className
|
|
78
100
|
)}
|
|
79
101
|
{...props}
|
|
@@ -85,13 +107,19 @@ function DropdownMenuCheckboxItem({
|
|
|
85
107
|
className,
|
|
86
108
|
children,
|
|
87
109
|
checked,
|
|
110
|
+
size,
|
|
88
111
|
...props
|
|
89
|
-
}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>
|
|
112
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem> & {
|
|
113
|
+
size?: DropdownMenuItemSize
|
|
114
|
+
}) {
|
|
115
|
+
const height = useItemHeight(size)
|
|
116
|
+
|
|
90
117
|
return (
|
|
91
118
|
<DropdownMenuPrimitive.CheckboxItem
|
|
92
119
|
data-slot="dropdown-menu-checkbox-item"
|
|
93
120
|
className={cn(
|
|
94
|
-
"relative flex cursor-default items-center gap-2 rounded-md
|
|
121
|
+
"relative flex cursor-default items-center gap-2 rounded-md py-1 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",
|
|
122
|
+
height,
|
|
95
123
|
className
|
|
96
124
|
)}
|
|
97
125
|
checked={checked}
|
|
@@ -121,13 +149,19 @@ function DropdownMenuRadioGroup({
|
|
|
121
149
|
function DropdownMenuRadioItem({
|
|
122
150
|
className,
|
|
123
151
|
children,
|
|
152
|
+
size,
|
|
124
153
|
...props
|
|
125
|
-
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>
|
|
154
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem> & {
|
|
155
|
+
size?: DropdownMenuItemSize
|
|
156
|
+
}) {
|
|
157
|
+
const height = useItemHeight(size)
|
|
158
|
+
|
|
126
159
|
return (
|
|
127
160
|
<DropdownMenuPrimitive.RadioItem
|
|
128
161
|
data-slot="dropdown-menu-radio-item"
|
|
129
162
|
className={cn(
|
|
130
|
-
"relative flex cursor-default items-center gap-2 rounded-md
|
|
163
|
+
"relative flex cursor-default items-center gap-2 rounded-md py-1 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",
|
|
164
|
+
height,
|
|
131
165
|
className
|
|
132
166
|
)}
|
|
133
167
|
{...props}
|
|
@@ -201,16 +235,21 @@ function DropdownMenuSubTrigger({
|
|
|
201
235
|
className,
|
|
202
236
|
inset,
|
|
203
237
|
children,
|
|
238
|
+
size,
|
|
204
239
|
...props
|
|
205
240
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
206
241
|
inset?: boolean
|
|
242
|
+
size?: DropdownMenuItemSize
|
|
207
243
|
}) {
|
|
244
|
+
const height = useItemHeight(size)
|
|
245
|
+
|
|
208
246
|
return (
|
|
209
247
|
<DropdownMenuPrimitive.SubTrigger
|
|
210
248
|
data-slot="dropdown-menu-sub-trigger"
|
|
211
249
|
data-inset={inset}
|
|
212
250
|
className={cn(
|
|
213
|
-
"flex cursor-default items-center gap-2 rounded-md
|
|
251
|
+
"flex cursor-default items-center gap-2 rounded-md px-2 py-1 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",
|
|
252
|
+
height,
|
|
214
253
|
className
|
|
215
254
|
)}
|
|
216
255
|
{...props}
|