@softure-ai/theme-notion 0.10.2 → 0.11.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/CHANGELOG.md +30 -0
- package/README.md +73 -2
- 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/messages/en.d.ts +17 -0
- package/dist/messages/en.d.ts.map +1 -1
- package/dist/messages/en.js +17 -0
- package/dist/messages/en.js.map +1 -1
- package/dist/messages/index.d.ts +17 -0
- package/dist/messages/index.d.ts.map +1 -1
- package/dist/notion/RouteLoading.d.ts +14 -0
- package/dist/notion/RouteLoading.d.ts.map +1 -0
- package/dist/notion/RouteLoading.js +11 -0
- package/dist/notion/RouteLoading.js.map +1 -0
- package/dist/notion/TopLoadingBar.d.ts +15 -0
- package/dist/notion/TopLoadingBar.d.ts.map +1 -0
- package/dist/notion/TopLoadingBar.js +10 -0
- package/dist/notion/TopLoadingBar.js.map +1 -0
- package/dist/notion/Upload.d.ts +66 -0
- package/dist/notion/Upload.d.ts.map +1 -0
- package/dist/notion/Upload.js +128 -0
- package/dist/notion/Upload.js.map +1 -0
- package/dist/ui/dialog.d.ts +1 -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/progress.d.ts.map +1 -1
- package/dist/ui/progress.js +17 -2
- package/dist/ui/progress.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +15 -0
- package/src/messages/en.ts +17 -0
- package/src/notion/RouteLoading.tsx +34 -0
- package/src/notion/TopLoadingBar.tsx +28 -0
- package/src/notion/Upload.tsx +339 -0
- package/src/ui/dialog.tsx +7 -2
- package/src/ui/progress.tsx +18 -1
package/dist/ui/dialog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/ui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C/B,eAAe,CAAC,EAAE,OAAO,CAAA;IAEzB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,qBAkBA;AAED,iBAAS,WAAW,CAAC,EACnB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,qBAQpD;AAED,iBAAS,iBAAiB,CAAC,EACzB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,WAAW,CAAC,qBAQ1D;AAED,OAAO,EACL,MAAM,EACN,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,WAAW,EACX,aAAa,GACd,CAAA"}
|
package/dist/ui/dialog.js
CHANGED
|
@@ -22,14 +22,15 @@ function DialogOverlay({ className, ...props }) {
|
|
|
22
22
|
return (_jsx(DialogPrimitive.Overlay, { "data-slot": "dialog-overlay", className: cn("fixed inset-0 z-50 bg-overlay data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0", className), ...props }));
|
|
23
23
|
}
|
|
24
24
|
function DialogContent({ className, children, showCloseButton = true, closeLabel = messages.dialog.close, closeButtonSize = "default", size = "default", ...props }) {
|
|
25
|
-
return (_jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, { "data-slot": "dialog-content", className: cn("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-xl bg-background p-6 shadow-dialog duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg", size === "wide" && "lg:max-w-1/2",
|
|
25
|
+
return (_jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, { "data-slot": "dialog-content", className: cn("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-xl bg-background p-6 shadow-dialog duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg", size === "wide" && "lg:max-w-1/2", size === "lg" &&
|
|
26
|
+
"flex h-[calc(100dvh-2rem)] flex-col overflow-y-auto sm:h-3/4 sm:max-w-3/4 lg:h-1/2 lg:min-h-96 lg:max-w-1/2", size === "sm" && "max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-md", className), ...props, children: [children, showCloseButton && (_jsxs(DialogPrimitive.Close, { "data-slot": "dialog-close", className: cn("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", closeButtonSize === "touch" &&
|
|
26
27
|
"top-0.5 right-0.5 inline-flex size-touch-target items-center justify-center rounded-md"), children: [_jsx(XIcon, {}), _jsx("span", { className: "sr-only", children: closeLabel })] }))] })] }));
|
|
27
28
|
}
|
|
28
29
|
function DialogHeader({ className, ...props }) {
|
|
29
30
|
return (_jsx("div", { "data-slot": "dialog-header", className: cn("flex flex-col gap-2 text-center sm:text-left", className), ...props }));
|
|
30
31
|
}
|
|
31
32
|
function DialogFooter({ className, showCloseButton = false, closeLabel = messages.dialog.close, children, ...props }) {
|
|
32
|
-
return (_jsxs("div", { "data-slot": "dialog-footer", className: cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className), ...props, children: [
|
|
33
|
+
return (_jsxs("div", { "data-slot": "dialog-footer", className: cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className), ...props, children: [showCloseButton && (_jsx(DialogPrimitive.Close, { asChild: true, children: _jsx(Button, { variant: "outline", children: closeLabel }) })), children] }));
|
|
33
34
|
}
|
|
34
35
|
function DialogTitle({ className, ...props }) {
|
|
35
36
|
return (_jsx(DialogPrimitive.Title, { "data-slot": "dialog-title", className: cn("text-lg leading-none font-semibold", className), ...props }));
|
package/dist/ui/dialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/ui/dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,EAAE,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,UAAU,CAAA;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,SAAS,MAAM,CAAC,EACd,GAAG,KAAK,EAC0C;IAClD,OAAO,KAAC,eAAe,CAAC,IAAI,iBAAW,QAAQ,KAAK,KAAK,GAAI,CAAA;AAC/D,CAAC;AAED,SAAS,aAAa,CAAC,EACrB,GAAG,KAAK,EAC6C;IACrD,OAAO,KAAC,eAAe,CAAC,OAAO,iBAAW,gBAAgB,KAAK,KAAK,GAAI,CAAA;AAC1E,CAAC;AAED,SAAS,YAAY,CAAC,EACpB,GAAG,KAAK,EAC4C;IACpD,OAAO,KAAC,eAAe,CAAC,MAAM,iBAAW,eAAe,KAAK,KAAK,GAAI,CAAA;AACxE,CAAC;AAED,SAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EAC2C;IACnD,OAAO,KAAC,eAAe,CAAC,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,EACzB,SAAS,EAAE,EAAE,CAAC,8CAA8C,EAAE,SAAS,CAAC,KACpE,KAAK,GACT,CACH,CAAA;AACH,CAAC;AAED,SAAS,YAAY,CAAC,EACpB,SAAS,EACT,eAAe,GAAG,KAAK,EACvB,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,EAClC,QAAQ,EACR,GAAG,KAAK,EAKT;IACC,OAAO,CACL,4BACY,eAAe,EACzB,SAAS,EAAE,EAAE,CACX,wDAAwD,EACxD,SAAS,CACV,KACG,KAAK,aAER,eAAe,IAAI,CAClB,KAAC,eAAe,CAAC,KAAK,IAAC,OAAO,kBAC5B,KAAC,MAAM,IAAC,OAAO,EAAC,SAAS,YAAE,UAAU,GAAU,GACzB,CACzB,EACA,QAAQ,IACL,CACP,CAAA;AACH,CAAC;AAED,SAAS,WAAW,CAAC,EACnB,SAAS,EACT,GAAG,KAAK,EAC2C;IACnD,OAAO,CACL,KAAC,eAAe,CAAC,KAAK,iBACV,cAAc,EACxB,SAAS,EAAE,EAAE,CAAC,oCAAoC,EAAE,SAAS,CAAC,KAC1D,KAAK,GACT,CACH,CAAA;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,EACzB,SAAS,EACT,GAAG,KAAK,EACiD;IACzD,OAAO,CACL,KAAC,eAAe,CAAC,WAAW,iBAChB,oBAAoB,EAC9B,SAAS,EAAE,EAAE,CAAC,+BAA+B,EAAE,SAAS,CAAC,KACrD,KAAK,GACT,CACH,CAAA;AACH,CAAC;AAED,OAAO,EACL,MAAM,EACN,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,WAAW,EACX,aAAa,GACd,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../src/ui/progress.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../src/ui/progress.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAwBxD,iBAAS,QAAQ,CAAC,EAChB,SAAS,EACT,kBAAkB,EAClB,KAAK,EACL,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,iBAAiB,CAAC,IAAI,CAAC,GAAG;IACvD,qEAAqE;IACrE,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B,qBAyBA;AAED,OAAO,EAAE,QAAQ,EAAE,CAAA"}
|
package/dist/ui/progress.js
CHANGED
|
@@ -4,14 +4,29 @@ import * as React from "react";
|
|
|
4
4
|
import { cn } from "../lib/utils.js";
|
|
5
5
|
import { Progress as ProgressPrimitive } from "radix-ui";
|
|
6
6
|
const FILL_CLASS = /(^|\s)bg-/;
|
|
7
|
+
// Without a value the fill is a third of the track sliding across it for ever (tw-animate-css's exit slide, which
|
|
8
|
+
// adds to the `translate` that parks it left of the track); with reduced motion it stands still, full and faint.
|
|
9
|
+
const INDETERMINATE_CLASS = [
|
|
10
|
+
"data-[state=indeterminate]:w-1/3",
|
|
11
|
+
"data-[state=indeterminate]:-translate-x-full",
|
|
12
|
+
"data-[state=indeterminate]:animate-out",
|
|
13
|
+
"data-[state=indeterminate]:slide-out-to-right-[400%]",
|
|
14
|
+
"data-[state=indeterminate]:repeat-infinite",
|
|
15
|
+
"data-[state=indeterminate]:duration-1500",
|
|
16
|
+
"data-[state=indeterminate]:ease-in-out",
|
|
17
|
+
"motion-reduce:data-[state=indeterminate]:animate-none",
|
|
18
|
+
"motion-reduce:data-[state=indeterminate]:w-full",
|
|
19
|
+
"motion-reduce:data-[state=indeterminate]:translate-x-0",
|
|
20
|
+
"motion-reduce:data-[state=indeterminate]:opacity-50",
|
|
21
|
+
].join(" ");
|
|
7
22
|
function hasFillClass(className) {
|
|
8
23
|
return className !== undefined && FILL_CLASS.test(className);
|
|
9
24
|
}
|
|
10
25
|
function Progress({ className, indicatorClassName, value, ...props }) {
|
|
11
|
-
return (_jsx(ProgressPrimitive.Root, { "data-slot": "progress", value: value, className: cn("relative h-1.5 w-full overflow-hidden rounded-full bg-primary/20", className), ...props, children: _jsx(ProgressPrimitive.Indicator, { "data-slot": "progress-indicator", className: cn("h-full w-full flex-1 bg-primary transition-all",
|
|
26
|
+
return (_jsx(ProgressPrimitive.Root, { "data-slot": "progress", value: value, className: cn("relative h-1.5 w-full overflow-hidden rounded-full bg-primary/20", className), ...props, children: _jsx(ProgressPrimitive.Indicator, { "data-slot": "progress-indicator", className: cn("h-full w-full flex-1 bg-primary transition-all", INDETERMINATE_CLASS,
|
|
12
27
|
// In dark the default fill is the lighter link blue, so it reaches 3:1 against its track; a fill colour of
|
|
13
28
|
// the caller's own replaces both.
|
|
14
|
-
!hasFillClass(indicatorClassName) && "dark:bg-link", indicatorClassName), style: { transform: `translateX(-${100 -
|
|
29
|
+
!hasFillClass(indicatorClassName) && "dark:bg-link", indicatorClassName), style: value == null ? undefined : { transform: `translateX(-${100 - value}%)` } }) }));
|
|
15
30
|
}
|
|
16
31
|
export { Progress };
|
|
17
32
|
//# sourceMappingURL=progress.js.map
|
package/dist/ui/progress.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../../src/ui/progress.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAExD,MAAM,UAAU,GAAG,WAAW,CAAA;AAE9B,SAAS,YAAY,CAAC,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,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,EAAE,CACX,kEAAkE,EAClE,SAAS,CACV,KACG,KAAK,YAET,KAAC,iBAAiB,CAAC,SAAS,iBAChB,oBAAoB,EAC9B,SAAS,EAAE,EAAE,CACX,gDAAgD,EAChD,mBAAmB;YACnB,2GAA2G;YAC3G,kCAAkC;YAClC,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,cAAc,EACnD,kBAAkB,CACnB,EACD,KAAK,EAAE,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,eAAe,GAAG,GAAG,KAAK,IAAI,EAAE,GAChF,GACqB,CAC1B,CAAA;AACH,CAAC;AAED,OAAO,EAAE,QAAQ,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.11.0",
|
|
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
|
@@ -56,6 +56,7 @@ export { MiniProgress, type MiniProgressProps } from "./notion/MiniProgress.js";
|
|
|
56
56
|
export { PageFrame, type PageFrameProps } from "./notion/PageFrame.js";
|
|
57
57
|
export { PageHeader, type PageCrumb, type PageHeaderProps } from "./notion/PageHeader.js";
|
|
58
58
|
export { PropertyList, type Property, type PropertyListProps } from "./notion/PropertyList.js";
|
|
59
|
+
export { RouteLoading, type RouteLoadingProps } from "./notion/RouteLoading.js";
|
|
59
60
|
export { SheetMenu, SheetMenuButton, SheetMenuItem, type SheetMenuButtonProps } from "./notion/SheetMenu.js";
|
|
60
61
|
export { SidePanel, type SidePanelLayout, type SidePanelProps } from "./notion/SidePanel.js";
|
|
61
62
|
export {
|
|
@@ -86,5 +87,19 @@ export { Status, type StatusProps } from "./notion/Status.js";
|
|
|
86
87
|
export { Steps, type StepItem, type StepState, type StepsLayout, type StepsProps } from "./notion/Steps.js";
|
|
87
88
|
export { TabBar, type TabBarItem, type TabBarProps } from "./notion/TabBar.js";
|
|
88
89
|
export { Timeline, type TimelineItem, type TimelineItemFold, type TimelineItemSize, type TimelineLine, type TimelineProps } from "./notion/Timeline.js";
|
|
90
|
+
export { TopLoadingBar, type TopLoadingBarProps } from "./notion/TopLoadingBar.js";
|
|
91
|
+
export {
|
|
92
|
+
UploadField,
|
|
93
|
+
UploadItem,
|
|
94
|
+
UploadList,
|
|
95
|
+
formatFileSize,
|
|
96
|
+
type UploadFieldProps,
|
|
97
|
+
type UploadFileItem,
|
|
98
|
+
type UploadItemProps,
|
|
99
|
+
type UploadListProps,
|
|
100
|
+
type UploadMessages,
|
|
101
|
+
type UploadMessagesOverride,
|
|
102
|
+
type UploadState,
|
|
103
|
+
} from "./notion/Upload.js";
|
|
89
104
|
export { UpdatePrompt, type UpdatePromptProps } from "./notion/UpdatePrompt.js";
|
|
90
105
|
export { TONES, TONE_COLORS, TONE_EDGE, TONE_FILL, TONE_TEXT, type Tone } from "./notion/tones.js";
|
package/src/messages/en.ts
CHANGED
|
@@ -19,6 +19,23 @@ export const en = {
|
|
|
19
19
|
cancelled: "Cancelled. {item} is back in place.",
|
|
20
20
|
handle: "Drag to reorder",
|
|
21
21
|
},
|
|
22
|
+
upload: {
|
|
23
|
+
choose: "Choose files",
|
|
24
|
+
chooseOne: "Choose a file",
|
|
25
|
+
drop: "or drop them here",
|
|
26
|
+
dropOne: "or drop it here",
|
|
27
|
+
dropping: "Drop to add",
|
|
28
|
+
retry: "Retry",
|
|
29
|
+
pause: "Pause {name}",
|
|
30
|
+
resume: "Resume {name}",
|
|
31
|
+
remove: "Remove {name}",
|
|
32
|
+
progress: "Upload of {name}",
|
|
33
|
+
queued: "Queued",
|
|
34
|
+
uploading: "Uploading",
|
|
35
|
+
paused: "Paused",
|
|
36
|
+
done: "Done",
|
|
37
|
+
failed: "Failed",
|
|
38
|
+
},
|
|
22
39
|
steps: { done: "Done", current: "Current", todo: "To do", failed: "Failed" },
|
|
23
40
|
command: { title: "Command Palette", description: "Search for a command to run..." },
|
|
24
41
|
} as const;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { LaunchScreen } from "./LaunchScreen.js";
|
|
2
|
+
import { TopLoadingBar } from "./TopLoadingBar.js";
|
|
3
|
+
|
|
4
|
+
export interface RouteLoadingProps {
|
|
5
|
+
/** The app's name, on the launch screen. */
|
|
6
|
+
readonly name: string;
|
|
7
|
+
/** The app's icon, on the launch screen. */
|
|
8
|
+
readonly iconSrc: string;
|
|
9
|
+
/** Both bars' accessible name (`pwaMessages.en.launch.label` in `@softure-ai/pwa`). */
|
|
10
|
+
readonly label: string;
|
|
11
|
+
/** The launch screen's counter: `buildLaunchProgressScript()`. */
|
|
12
|
+
readonly launchScript?: string;
|
|
13
|
+
/** The top bar's counter: `buildLaunchProgressScript({ rootSlot: "top-loading-bar" })`. */
|
|
14
|
+
readonly barScript?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// The loading state for `app/loading.tsx`, picked by the browser so the page stays static: the full-screen
|
|
18
|
+
// `LaunchScreen` below the `md` breakpoint or in an installed app (`display-mode: standalone`), the thin
|
|
19
|
+
// `TopLoadingBar` on a wide screen in a browser tab (`display-mode: browser`). Both are streamed; CSS hides the other,
|
|
20
|
+
// so screen readers meet one. The wrapper draws no box (`contents`). Each rule is one stacked media query, so no two display rules compete on order.
|
|
21
|
+
export function RouteLoading({ name, iconSrc, label, launchScript, barScript }: RouteLoadingProps) {
|
|
22
|
+
return (
|
|
23
|
+
<div data-slot="route-loading" className="contents">
|
|
24
|
+
<LaunchScreen
|
|
25
|
+
name={name}
|
|
26
|
+
iconSrc={iconSrc}
|
|
27
|
+
label={label}
|
|
28
|
+
script={launchScript}
|
|
29
|
+
className="md:[@media(display-mode:browser)]:hidden"
|
|
30
|
+
/>
|
|
31
|
+
<TopLoadingBar label={label} script={barScript} className="hidden md:[@media(display-mode:browser)]:block" />
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { cn } from "../lib/utils.js";
|
|
2
|
+
import { Progress } from "../ui/progress.js";
|
|
3
|
+
|
|
4
|
+
export interface TopLoadingBarProps {
|
|
5
|
+
/** The progress bar's accessible name (`pwaMessages.en.launch.label` in `@softure-ai/pwa`). */
|
|
6
|
+
readonly label: string;
|
|
7
|
+
/** 0–100 when the app knows the progress; left out, the bar slides indeterminately. */
|
|
8
|
+
readonly value?: number;
|
|
9
|
+
/**
|
|
10
|
+
* The counter's inline script (`buildLaunchProgressScript({ rootSlot: "top-loading-bar" })` from `@softure-ai/pwa`).
|
|
11
|
+
* Where the browser runs it (a streamed first load) its first value makes the bar determinate; where it does not
|
|
12
|
+
* (a client-side navigation) the bar keeps sliding.
|
|
13
|
+
*/
|
|
14
|
+
readonly script?: string;
|
|
15
|
+
readonly className?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// A thin bar along the top edge while a route loads on a wide screen: 2 px, square, on a transparent track, above the
|
|
19
|
+
// page and never in the way of a pointer, so the page under it stays usable. `LaunchScreen` is its full-screen
|
|
20
|
+
// counterpart for a phone or an installed app; `RouteLoading` picks one of the two in the browser.
|
|
21
|
+
export function TopLoadingBar({ label, value, script, className }: TopLoadingBarProps) {
|
|
22
|
+
return (
|
|
23
|
+
<div data-slot="top-loading-bar" className={cn("pointer-events-none fixed inset-x-0 top-0 z-50", className)}>
|
|
24
|
+
<Progress value={value} aria-label={label} className="h-0.5 rounded-none bg-transparent" />
|
|
25
|
+
{script === undefined ? null : <script dangerouslySetInnerHTML={{ __html: script }} />}
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { CircleAlert, CircleCheck, Clock, File as FileIcon, Pause, Play, RotateCw, Upload as UploadIcon, X, type LucideIcon } from "lucide-react";
|
|
4
|
+
import { useId, useRef, useState, type DragEvent, type ReactNode } from "react";
|
|
5
|
+
|
|
6
|
+
import { en } from "../messages/en.js";
|
|
7
|
+
import { cn } from "../lib/utils.js";
|
|
8
|
+
import { Button } from "../ui/button.js";
|
|
9
|
+
import { Field, FieldDescription, FieldError, FieldLabel } from "../ui/field.js";
|
|
10
|
+
import { Progress } from "../ui/progress.js";
|
|
11
|
+
|
|
12
|
+
import { ICON_STROKE_WIDTH } from "./icon-stroke.js";
|
|
13
|
+
import type { PaletteColor } from "./palette.js";
|
|
14
|
+
import { Status } from "./Status.js";
|
|
15
|
+
|
|
16
|
+
export type UploadState = "queued" | "uploading" | "paused" | "done" | "failed";
|
|
17
|
+
|
|
18
|
+
/** One file of an upload, as the app or its transport (e.g. `@softure-ai/files`) tracks it. */
|
|
19
|
+
export interface UploadFileItem {
|
|
20
|
+
// Kept on the row as `data-upload`.
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly name: string;
|
|
23
|
+
// In bytes.
|
|
24
|
+
readonly size: number;
|
|
25
|
+
readonly state: UploadState;
|
|
26
|
+
// 0–100, drawn while uploading or paused; clamped, and a non-finite value reads as 0.
|
|
27
|
+
readonly progress?: number;
|
|
28
|
+
// Why the upload failed, shown under a failed row.
|
|
29
|
+
readonly error?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The texts of the upload parts; `{name}` stands for the file's name. Built-in English: `notionMessages.en.upload`. */
|
|
33
|
+
export interface UploadMessages {
|
|
34
|
+
readonly choose: string;
|
|
35
|
+
readonly chooseOne: string;
|
|
36
|
+
readonly drop: string;
|
|
37
|
+
readonly dropOne: string;
|
|
38
|
+
readonly dropping: string;
|
|
39
|
+
readonly retry: string;
|
|
40
|
+
readonly pause: string;
|
|
41
|
+
readonly resume: string;
|
|
42
|
+
readonly remove: string;
|
|
43
|
+
readonly progress: string;
|
|
44
|
+
// Each state's word, e.g. `failed`.
|
|
45
|
+
readonly queued: string;
|
|
46
|
+
readonly uploading: string;
|
|
47
|
+
readonly paused: string;
|
|
48
|
+
readonly done: string;
|
|
49
|
+
readonly failed: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The app's wording for the upload parts; each text left out keeps the built-in English one. */
|
|
53
|
+
export type UploadMessagesOverride = Partial<UploadMessages>;
|
|
54
|
+
|
|
55
|
+
const SIZE_UNITS = ["kilobyte", "megabyte", "gigabyte", "terabyte"] as const;
|
|
56
|
+
|
|
57
|
+
/** A file size for people, in decimal steps (1 kB = 1000 bytes), written by the locale: `formatFileSize(1500)` is "1.5 kB". */
|
|
58
|
+
export function formatFileSize(bytes: number, locale = "en"): string {
|
|
59
|
+
const size = Number.isFinite(bytes) ? Math.max(0, bytes) : 0;
|
|
60
|
+
// Bytes in full ("820 bytes"): the short form of the unit is the bare word "byte" in English.
|
|
61
|
+
if (size < 1000) return new Intl.NumberFormat(locale, { style: "unit", unit: "byte", unitDisplay: "long" }).format(Math.round(size));
|
|
62
|
+
let value = size / 1000;
|
|
63
|
+
let unit = 0;
|
|
64
|
+
while (value >= 1000 && unit < SIZE_UNITS.length - 1) {
|
|
65
|
+
value /= 1000;
|
|
66
|
+
unit += 1;
|
|
67
|
+
}
|
|
68
|
+
return new Intl.NumberFormat(locale, { style: "unit", unit: SIZE_UNITS[unit], unitDisplay: "short", maximumFractionDigits: 1 }).format(value);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function mergeMessages(override: UploadMessagesOverride | undefined): UploadMessages {
|
|
72
|
+
return { ...en.upload, ...override };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function fillName(template: string, name: string): string {
|
|
76
|
+
return template.replaceAll("{name}", name);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Whether a file matches an `accept` list (".pdf", "video/*", "image/png"), the way the browser's picker reads it. */
|
|
80
|
+
function isAccepted(file: File, accept: string | undefined): boolean {
|
|
81
|
+
if (accept === undefined || accept.trim() === "") return true;
|
|
82
|
+
const name = file.name.toLowerCase();
|
|
83
|
+
const type = file.type.toLowerCase();
|
|
84
|
+
return accept
|
|
85
|
+
.split(",")
|
|
86
|
+
.map((entry) => entry.trim().toLowerCase())
|
|
87
|
+
.filter((entry) => entry !== "")
|
|
88
|
+
.some((entry) => {
|
|
89
|
+
if (entry.startsWith(".")) return name.endsWith(entry);
|
|
90
|
+
if (entry.endsWith("/*")) return type.startsWith(entry.slice(0, -1));
|
|
91
|
+
return type === entry;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface UploadFieldProps {
|
|
96
|
+
// The field's visible label.
|
|
97
|
+
readonly label: ReactNode;
|
|
98
|
+
readonly description?: ReactNode;
|
|
99
|
+
// A message under the area, e.g. "Choose at least one file"; marks the field invalid.
|
|
100
|
+
readonly error?: ReactNode;
|
|
101
|
+
// Passed to the native file input: file types, several files, the camera on a phone.
|
|
102
|
+
readonly accept?: string;
|
|
103
|
+
readonly multiple?: boolean;
|
|
104
|
+
readonly capture?: "user" | "environment";
|
|
105
|
+
readonly disabled?: boolean;
|
|
106
|
+
// The files picked or dropped (those matching `accept`; only the first without `multiple`).
|
|
107
|
+
readonly onFilesSelected: (files: File[]) => void;
|
|
108
|
+
// Dropped files that do not match `accept`; the picker never offers them.
|
|
109
|
+
readonly onFilesRejected?: (files: File[]) => void;
|
|
110
|
+
readonly messages?: UploadMessagesOverride;
|
|
111
|
+
// The native input's id; generated when left out.
|
|
112
|
+
readonly id?: string;
|
|
113
|
+
readonly className?: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// A labelled area to add files: a touch-sized button opens the native picker (so a phone offers its files, photos and
|
|
117
|
+
// camera), and on a wide screen files can also be dropped on the area. It holds no files of its own: it hands each pick
|
|
118
|
+
// or drop to `onFilesSelected`, and the app or its transport keeps the list (`UploadList`).
|
|
119
|
+
export function UploadField({
|
|
120
|
+
label,
|
|
121
|
+
description,
|
|
122
|
+
error,
|
|
123
|
+
accept,
|
|
124
|
+
multiple = false,
|
|
125
|
+
capture,
|
|
126
|
+
disabled = false,
|
|
127
|
+
onFilesSelected,
|
|
128
|
+
onFilesRejected,
|
|
129
|
+
messages,
|
|
130
|
+
id,
|
|
131
|
+
className,
|
|
132
|
+
}: UploadFieldProps) {
|
|
133
|
+
const words = mergeMessages(messages);
|
|
134
|
+
const generatedId = useId();
|
|
135
|
+
const inputId = id ?? generatedId;
|
|
136
|
+
const descriptionId = `${inputId}-description`;
|
|
137
|
+
const errorId = `${inputId}-error`;
|
|
138
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
139
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
140
|
+
const isInvalid = error !== undefined && error !== null && error !== false;
|
|
141
|
+
const describedBy = [description === undefined ? undefined : descriptionId, isInvalid ? errorId : undefined].filter(Boolean).join(" ") || undefined;
|
|
142
|
+
|
|
143
|
+
const handOver = (files: File[]) => {
|
|
144
|
+
const accepted = files.filter((file) => isAccepted(file, accept));
|
|
145
|
+
const rejected = files.filter((file) => !isAccepted(file, accept));
|
|
146
|
+
const selected = multiple ? accepted : accepted.slice(0, 1);
|
|
147
|
+
if (selected.length > 0) onFilesSelected(selected);
|
|
148
|
+
if (rejected.length > 0) onFilesRejected?.(rejected);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const handleDragOver = (event: DragEvent<HTMLDivElement>) => {
|
|
152
|
+
if (disabled) return;
|
|
153
|
+
event.preventDefault();
|
|
154
|
+
event.dataTransfer.dropEffect = "copy";
|
|
155
|
+
setIsDragging(true);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const handleDragLeave = (event: DragEvent<HTMLDivElement>) => {
|
|
159
|
+
// Moving onto a child fires a leave on the area too; only leaving the area itself ends the highlight.
|
|
160
|
+
if (event.relatedTarget instanceof Node && event.currentTarget.contains(event.relatedTarget)) return;
|
|
161
|
+
setIsDragging(false);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const handleDrop = (event: DragEvent<HTMLDivElement>) => {
|
|
165
|
+
if (disabled) return;
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
setIsDragging(false);
|
|
168
|
+
handOver(Array.from(event.dataTransfer.files));
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<Field data-slot="upload-field" data-invalid={isInvalid || undefined} data-disabled={disabled || undefined} className={className}>
|
|
173
|
+
<FieldLabel htmlFor={inputId}>{label}</FieldLabel>
|
|
174
|
+
<div
|
|
175
|
+
data-slot="upload-drop-area"
|
|
176
|
+
data-dragging={isDragging || undefined}
|
|
177
|
+
onDragOver={handleDragOver}
|
|
178
|
+
onDragEnter={handleDragOver}
|
|
179
|
+
onDragLeave={handleDragLeave}
|
|
180
|
+
onDrop={handleDrop}
|
|
181
|
+
className={cn(
|
|
182
|
+
"flex flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-input p-4 text-center text-sm text-muted-foreground transition-colors duration-120",
|
|
183
|
+
"md:flex-row md:gap-3",
|
|
184
|
+
"data-[dragging=true]:border-primary data-[dragging=true]:bg-blue-bg",
|
|
185
|
+
"group-data-[invalid=true]/field:border-destructive group-data-[disabled=true]/field:opacity-50",
|
|
186
|
+
)}
|
|
187
|
+
>
|
|
188
|
+
<UploadIcon aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} className="hidden size-5 shrink-0 md:block" />
|
|
189
|
+
<Button
|
|
190
|
+
type="button"
|
|
191
|
+
variant="outline"
|
|
192
|
+
size="touch"
|
|
193
|
+
className="md:h-7"
|
|
194
|
+
disabled={disabled}
|
|
195
|
+
aria-describedby={describedBy}
|
|
196
|
+
onClick={() => inputRef.current?.click()}
|
|
197
|
+
>
|
|
198
|
+
<UploadIcon aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} className="md:hidden" />
|
|
199
|
+
{multiple ? words.choose : words.chooseOne}
|
|
200
|
+
</Button>
|
|
201
|
+
{/* A phone has nothing to drop, so the hint shows on a wide screen only. */}
|
|
202
|
+
<span data-slot="upload-drop-hint" aria-hidden="true" className="hidden md:inline">
|
|
203
|
+
{isDragging ? words.dropping : multiple ? words.drop : words.dropOne}
|
|
204
|
+
</span>
|
|
205
|
+
<input
|
|
206
|
+
ref={inputRef}
|
|
207
|
+
id={inputId}
|
|
208
|
+
type="file"
|
|
209
|
+
accept={accept}
|
|
210
|
+
multiple={multiple}
|
|
211
|
+
capture={capture}
|
|
212
|
+
disabled={disabled}
|
|
213
|
+
tabIndex={-1}
|
|
214
|
+
aria-describedby={describedBy}
|
|
215
|
+
aria-invalid={isInvalid || undefined}
|
|
216
|
+
className="sr-only"
|
|
217
|
+
onChange={(event) => {
|
|
218
|
+
handOver(Array.from(event.currentTarget.files ?? []));
|
|
219
|
+
// Cleared, so picking the same file again after removing it is a change too.
|
|
220
|
+
event.currentTarget.value = "";
|
|
221
|
+
}}
|
|
222
|
+
/>
|
|
223
|
+
</div>
|
|
224
|
+
{description === undefined ? null : <FieldDescription id={descriptionId}>{description}</FieldDescription>}
|
|
225
|
+
{isInvalid ? <FieldError id={errorId}>{error}</FieldError> : null}
|
|
226
|
+
</Field>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface UploadListProps {
|
|
231
|
+
// The list's accessible name, e.g. "Files".
|
|
232
|
+
readonly label: string;
|
|
233
|
+
// `UploadItem` rows.
|
|
234
|
+
readonly children: ReactNode;
|
|
235
|
+
readonly className?: string;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// The files of an upload, one `UploadItem` per row.
|
|
239
|
+
export function UploadList({ label, children, className }: UploadListProps) {
|
|
240
|
+
return (
|
|
241
|
+
<ul aria-label={label} data-slot="upload-list" className={cn("flex flex-col gap-1", className)}>
|
|
242
|
+
{children}
|
|
243
|
+
</ul>
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const STATE_STATUS: Readonly<Record<UploadState, { readonly color: PaletteColor; readonly icon: LucideIcon }>> = {
|
|
248
|
+
queued: { color: "gray", icon: Clock },
|
|
249
|
+
uploading: { color: "blue", icon: UploadIcon },
|
|
250
|
+
paused: { color: "orange", icon: Pause },
|
|
251
|
+
done: { color: "green", icon: CircleCheck },
|
|
252
|
+
failed: { color: "red", icon: CircleAlert },
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
function clampProgress(value: number | undefined): number {
|
|
256
|
+
if (value === undefined || !Number.isFinite(value)) return 0;
|
|
257
|
+
return Math.min(100, Math.max(0, value));
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export interface UploadItemProps {
|
|
261
|
+
readonly item: UploadFileItem;
|
|
262
|
+
// Each button shows only with its callback: Retry on a failed row, Pause while uploading, Resume when paused.
|
|
263
|
+
readonly onRetry?: (item: UploadFileItem) => void;
|
|
264
|
+
readonly onPause?: (item: UploadFileItem) => void;
|
|
265
|
+
readonly onResume?: (item: UploadFileItem) => void;
|
|
266
|
+
readonly onRemove?: (item: UploadFileItem) => void;
|
|
267
|
+
// Formats the size, e.g. "de" writes "1,5 kB".
|
|
268
|
+
readonly locale?: string;
|
|
269
|
+
readonly messages?: UploadMessagesOverride;
|
|
270
|
+
readonly className?: string;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// One file of an upload: its name, size and state word, a progress bar while it uploads or waits paused, the reason and
|
|
274
|
+
// a Retry button when it failed, and a Remove button. The buttons are touch sized on a phone.
|
|
275
|
+
export function UploadItem({ item, onRetry, onPause, onResume, onRemove, locale = "en", messages, className }: UploadItemProps) {
|
|
276
|
+
const words = mergeMessages(messages);
|
|
277
|
+
const errorId = `${useId()}-error`;
|
|
278
|
+
const status = STATE_STATUS[item.state];
|
|
279
|
+
const hasProgress = item.state === "uploading" || item.state === "paused";
|
|
280
|
+
const hasError = item.state === "failed" && item.error !== undefined && item.error !== "";
|
|
281
|
+
return (
|
|
282
|
+
<li
|
|
283
|
+
data-slot="upload-item"
|
|
284
|
+
data-upload={item.id}
|
|
285
|
+
data-state={item.state}
|
|
286
|
+
className={cn("flex min-w-0 items-start gap-2 rounded-md px-2 py-1.5", className)}
|
|
287
|
+
>
|
|
288
|
+
<FileIcon aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
|
|
289
|
+
<div className="flex min-w-0 flex-1 flex-col gap-1">
|
|
290
|
+
<div className="flex min-w-0 flex-wrap items-center gap-x-2">
|
|
291
|
+
<span data-slot="upload-item-name" title={item.name} className="min-w-0 truncate text-sm font-medium">
|
|
292
|
+
{item.name}
|
|
293
|
+
</span>
|
|
294
|
+
<span data-slot="upload-item-size" className="shrink-0 text-small text-muted-foreground tabular-nums">
|
|
295
|
+
{formatFileSize(item.size, locale)}
|
|
296
|
+
</span>
|
|
297
|
+
<Status color={status.color} icon={status.icon} className="shrink-0 text-small">
|
|
298
|
+
{words[item.state]}
|
|
299
|
+
</Status>
|
|
300
|
+
</div>
|
|
301
|
+
{hasProgress ? (
|
|
302
|
+
<Progress
|
|
303
|
+
value={clampProgress(item.progress)}
|
|
304
|
+
aria-label={fillName(words.progress, item.name)}
|
|
305
|
+
indicatorClassName={item.state === "paused" ? "bg-orange" : undefined}
|
|
306
|
+
/>
|
|
307
|
+
) : null}
|
|
308
|
+
{hasError ? (
|
|
309
|
+
<p id={errorId} data-slot="upload-item-error" className="text-small text-destructive">
|
|
310
|
+
{item.error}
|
|
311
|
+
</p>
|
|
312
|
+
) : null}
|
|
313
|
+
</div>
|
|
314
|
+
<div data-slot="upload-item-actions" className="flex shrink-0 items-center gap-1">
|
|
315
|
+
{item.state === "failed" && onRetry !== undefined ? (
|
|
316
|
+
<Button type="button" variant="outline" size="touch" className="md:h-7" aria-describedby={hasError ? errorId : undefined} onClick={() => onRetry(item)}>
|
|
317
|
+
<RotateCw aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} />
|
|
318
|
+
{words.retry}
|
|
319
|
+
</Button>
|
|
320
|
+
) : null}
|
|
321
|
+
{item.state === "uploading" && onPause !== undefined ? (
|
|
322
|
+
<ItemIconButton icon={Pause} label={fillName(words.pause, item.name)} onClick={() => onPause(item)} />
|
|
323
|
+
) : null}
|
|
324
|
+
{item.state === "paused" && onResume !== undefined ? (
|
|
325
|
+
<ItemIconButton icon={Play} label={fillName(words.resume, item.name)} onClick={() => onResume(item)} />
|
|
326
|
+
) : null}
|
|
327
|
+
{onRemove === undefined ? null : <ItemIconButton icon={X} label={fillName(words.remove, item.name)} onClick={() => onRemove(item)} />}
|
|
328
|
+
</div>
|
|
329
|
+
</li>
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function ItemIconButton({ icon: Icon, label, onClick }: { readonly icon: LucideIcon; readonly label: string; readonly onClick: () => void }) {
|
|
334
|
+
return (
|
|
335
|
+
<Button type="button" variant="ghost" size="icon-touch" className="text-muted-foreground md:size-7" aria-label={label} title={label} onClick={onClick}>
|
|
336
|
+
<Icon aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} />
|
|
337
|
+
</Button>
|
|
338
|
+
);
|
|
339
|
+
}
|
package/src/ui/dialog.tsx
CHANGED
|
@@ -63,7 +63,9 @@ function DialogContent({
|
|
|
63
63
|
// `touch` draws the close button 44 x 44, centred on the same icon.
|
|
64
64
|
closeButtonSize?: "default" | "touch"
|
|
65
65
|
// `wide` is half the viewport from `lg`, `max-w-lg` below it.
|
|
66
|
-
|
|
66
|
+
// `lg` is the standard popup: a quarter of the viewport free on every side from `lg`, its content scrolling.
|
|
67
|
+
// `sm` is a small popup for little data, narrower than the default.
|
|
68
|
+
size?: "sm" | "default" | "wide" | "lg"
|
|
67
69
|
}) {
|
|
68
70
|
return (
|
|
69
71
|
<DialogPortal data-slot="dialog-portal">
|
|
@@ -73,6 +75,9 @@ function DialogContent({
|
|
|
73
75
|
className={cn(
|
|
74
76
|
"fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-xl bg-background p-6 shadow-dialog duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",
|
|
75
77
|
size === "wide" && "lg:max-w-1/2",
|
|
78
|
+
size === "lg" &&
|
|
79
|
+
"flex h-[calc(100dvh-2rem)] flex-col overflow-y-auto sm:h-3/4 sm:max-w-3/4 lg:h-1/2 lg:min-h-96 lg:max-w-1/2",
|
|
80
|
+
size === "sm" && "max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-md",
|
|
76
81
|
className
|
|
77
82
|
)}
|
|
78
83
|
{...props}
|
|
@@ -126,12 +131,12 @@ function DialogFooter({
|
|
|
126
131
|
)}
|
|
127
132
|
{...props}
|
|
128
133
|
>
|
|
129
|
-
{children}
|
|
130
134
|
{showCloseButton && (
|
|
131
135
|
<DialogPrimitive.Close asChild>
|
|
132
136
|
<Button variant="outline">{closeLabel}</Button>
|
|
133
137
|
</DialogPrimitive.Close>
|
|
134
138
|
)}
|
|
139
|
+
{children}
|
|
135
140
|
</div>
|
|
136
141
|
)
|
|
137
142
|
}
|
package/src/ui/progress.tsx
CHANGED
|
@@ -6,6 +6,22 @@ import { Progress as ProgressPrimitive } from "radix-ui"
|
|
|
6
6
|
|
|
7
7
|
const FILL_CLASS = /(^|\s)bg-/
|
|
8
8
|
|
|
9
|
+
// Without a value the fill is a third of the track sliding across it for ever (tw-animate-css's exit slide, which
|
|
10
|
+
// adds to the `translate` that parks it left of the track); with reduced motion it stands still, full and faint.
|
|
11
|
+
const INDETERMINATE_CLASS = [
|
|
12
|
+
"data-[state=indeterminate]:w-1/3",
|
|
13
|
+
"data-[state=indeterminate]:-translate-x-full",
|
|
14
|
+
"data-[state=indeterminate]:animate-out",
|
|
15
|
+
"data-[state=indeterminate]:slide-out-to-right-[400%]",
|
|
16
|
+
"data-[state=indeterminate]:repeat-infinite",
|
|
17
|
+
"data-[state=indeterminate]:duration-1500",
|
|
18
|
+
"data-[state=indeterminate]:ease-in-out",
|
|
19
|
+
"motion-reduce:data-[state=indeterminate]:animate-none",
|
|
20
|
+
"motion-reduce:data-[state=indeterminate]:w-full",
|
|
21
|
+
"motion-reduce:data-[state=indeterminate]:translate-x-0",
|
|
22
|
+
"motion-reduce:data-[state=indeterminate]:opacity-50",
|
|
23
|
+
].join(" ")
|
|
24
|
+
|
|
9
25
|
function hasFillClass(className: string | undefined): boolean {
|
|
10
26
|
return className !== undefined && FILL_CLASS.test(className)
|
|
11
27
|
}
|
|
@@ -33,12 +49,13 @@ function Progress({
|
|
|
33
49
|
data-slot="progress-indicator"
|
|
34
50
|
className={cn(
|
|
35
51
|
"h-full w-full flex-1 bg-primary transition-all",
|
|
52
|
+
INDETERMINATE_CLASS,
|
|
36
53
|
// In dark the default fill is the lighter link blue, so it reaches 3:1 against its track; a fill colour of
|
|
37
54
|
// the caller's own replaces both.
|
|
38
55
|
!hasFillClass(indicatorClassName) && "dark:bg-link",
|
|
39
56
|
indicatorClassName
|
|
40
57
|
)}
|
|
41
|
-
style={{ transform: `translateX(-${100 -
|
|
58
|
+
style={value == null ? undefined : { transform: `translateX(-${100 - value}%)` }}
|
|
42
59
|
/>
|
|
43
60
|
</ProgressPrimitive.Root>
|
|
44
61
|
)
|