@kujoforall/paper-ui 0.0.0-stage → 0.1.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 +5 -0
- package/LICENSE +21 -0
- package/README.md +252 -2
- package/dist/components/editor/block-text.d.ts +8 -0
- package/dist/components/editor/block-text.d.ts.map +1 -0
- package/dist/components/editor/block-text.js +213 -0
- package/dist/components/editor/block-text.js.map +1 -0
- package/dist/components/editor/blocks.d.ts +33 -0
- package/dist/components/editor/blocks.d.ts.map +1 -0
- package/dist/components/editor/blocks.js +187 -0
- package/dist/components/editor/blocks.js.map +1 -0
- package/dist/components/editor/document-editor.d.ts +27 -0
- package/dist/components/editor/document-editor.d.ts.map +1 -0
- package/dist/components/editor/document-editor.js +40 -0
- package/dist/components/editor/document-editor.js.map +1 -0
- package/dist/components/editor/document-view.d.ts +22 -0
- package/dist/components/editor/document-view.d.ts.map +1 -0
- package/dist/components/editor/document-view.js +105 -0
- package/dist/components/editor/document-view.js.map +1 -0
- package/dist/components/editor/editor-state.d.ts +100 -0
- package/dist/components/editor/editor-state.d.ts.map +1 -0
- package/dist/components/editor/editor-state.js +192 -0
- package/dist/components/editor/editor-state.js.map +1 -0
- package/dist/components/editor/extensions/spoiler.d.ts +8 -0
- package/dist/components/editor/extensions/spoiler.d.ts.map +1 -0
- package/dist/components/editor/extensions/spoiler.js +36 -0
- package/dist/components/editor/extensions/spoiler.js.map +1 -0
- package/dist/components/editor/index.d.ts +9 -0
- package/dist/components/editor/index.d.ts.map +1 -0
- package/dist/components/editor/index.js +9 -0
- package/dist/components/editor/index.js.map +1 -0
- package/dist/components/editor/kinds.d.ts +99 -0
- package/dist/components/editor/kinds.d.ts.map +1 -0
- package/dist/components/editor/kinds.js +74 -0
- package/dist/components/editor/kinds.js.map +1 -0
- package/dist/components/sketch/rough.d.ts +38 -0
- package/dist/components/sketch/rough.d.ts.map +1 -0
- package/dist/components/sketch/rough.js +57 -0
- package/dist/components/sketch/rough.js.map +1 -0
- package/dist/components/ui/accent-picker.d.ts +2 -0
- package/dist/components/ui/accent-picker.d.ts.map +1 -0
- package/dist/components/ui/accent-picker.js +44 -0
- package/dist/components/ui/accent-picker.js.map +1 -0
- package/dist/components/ui/address-field.d.ts +10 -0
- package/dist/components/ui/address-field.d.ts.map +1 -0
- package/dist/components/ui/address-field.js +24 -0
- package/dist/components/ui/address-field.js.map +1 -0
- package/dist/components/ui/app-shell.d.ts +25 -0
- package/dist/components/ui/app-shell.d.ts.map +1 -0
- package/dist/components/ui/app-shell.js +69 -0
- package/dist/components/ui/app-shell.js.map +1 -0
- package/dist/components/ui/badge.d.ts +19 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/badge.js +62 -0
- package/dist/components/ui/badge.js.map +1 -0
- package/dist/components/ui/breadcrumbs.d.ts +10 -0
- package/dist/components/ui/breadcrumbs.d.ts.map +1 -0
- package/dist/components/ui/breadcrumbs.js +9 -0
- package/dist/components/ui/breadcrumbs.js.map +1 -0
- package/dist/components/ui/button.d.ts +13 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +45 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/calendar.d.ts +5 -0
- package/dist/components/ui/calendar.d.ts.map +1 -0
- package/dist/components/ui/calendar.js +64 -0
- package/dist/components/ui/calendar.js.map +1 -0
- package/dist/components/ui/callout.d.ts +13 -0
- package/dist/components/ui/callout.d.ts.map +1 -0
- package/dist/components/ui/callout.js +27 -0
- package/dist/components/ui/callout.js.map +1 -0
- package/dist/components/ui/card.d.ts +13 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/card.js +27 -0
- package/dist/components/ui/card.js.map +1 -0
- package/dist/components/ui/checkbox.d.ts +6 -0
- package/dist/components/ui/checkbox.d.ts.map +1 -0
- package/dist/components/ui/checkbox.js +10 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/command-menu.d.ts +15 -0
- package/dist/components/ui/command-menu.d.ts.map +1 -0
- package/dist/components/ui/command-menu.js +24 -0
- package/dist/components/ui/command-menu.js.map +1 -0
- package/dist/components/ui/date-picker.d.ts +35 -0
- package/dist/components/ui/date-picker.d.ts.map +1 -0
- package/dist/components/ui/date-picker.js +56 -0
- package/dist/components/ui/date-picker.js.map +1 -0
- package/dist/components/ui/date-time-picker.d.ts +19 -0
- package/dist/components/ui/date-time-picker.d.ts.map +1 -0
- package/dist/components/ui/date-time-picker.js +32 -0
- package/dist/components/ui/date-time-picker.js.map +1 -0
- package/dist/components/ui/dialog.d.ts +17 -0
- package/dist/components/ui/dialog.d.ts.map +1 -0
- package/dist/components/ui/dialog.js +33 -0
- package/dist/components/ui/dialog.js.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +20 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.js +56 -0
- package/dist/components/ui/dropdown-menu.js.map +1 -0
- package/dist/components/ui/editable-text.d.ts +17 -0
- package/dist/components/ui/editable-text.d.ts.map +1 -0
- package/dist/components/ui/editable-text.js +68 -0
- package/dist/components/ui/editable-text.js.map +1 -0
- package/dist/components/ui/field-button.d.ts +14 -0
- package/dist/components/ui/field-button.d.ts.map +1 -0
- package/dist/components/ui/field-button.js +16 -0
- package/dist/components/ui/field-button.js.map +1 -0
- package/dist/components/ui/file-preview.d.ts +5 -0
- package/dist/components/ui/file-preview.d.ts.map +1 -0
- package/dist/components/ui/file-preview.js +66 -0
- package/dist/components/ui/file-preview.js.map +1 -0
- package/dist/components/ui/file-uploader.d.ts +39 -0
- package/dist/components/ui/file-uploader.d.ts.map +1 -0
- package/dist/components/ui/file-uploader.js +110 -0
- package/dist/components/ui/file-uploader.js.map +1 -0
- package/dist/components/ui/handle-row.d.ts +15 -0
- package/dist/components/ui/handle-row.d.ts.map +1 -0
- package/dist/components/ui/handle-row.js +41 -0
- package/dist/components/ui/handle-row.js.map +1 -0
- package/dist/components/ui/image-block.d.ts +31 -0
- package/dist/components/ui/image-block.d.ts.map +1 -0
- package/dist/components/ui/image-block.js +103 -0
- package/dist/components/ui/image-block.js.map +1 -0
- package/dist/components/ui/image-card.d.ts +17 -0
- package/dist/components/ui/image-card.d.ts.map +1 -0
- package/dist/components/ui/image-card.js +38 -0
- package/dist/components/ui/image-card.js.map +1 -0
- package/dist/components/ui/image-viewer.d.ts +31 -0
- package/dist/components/ui/image-viewer.d.ts.map +1 -0
- package/dist/components/ui/image-viewer.js +81 -0
- package/dist/components/ui/image-viewer.js.map +1 -0
- package/dist/components/ui/image.d.ts +11 -0
- package/dist/components/ui/image.d.ts.map +1 -0
- package/dist/components/ui/image.js +32 -0
- package/dist/components/ui/image.js.map +1 -0
- package/dist/components/ui/index.d.ts +49 -0
- package/dist/components/ui/index.d.ts.map +1 -0
- package/dist/components/ui/index.js +49 -0
- package/dist/components/ui/index.js.map +1 -0
- package/dist/components/ui/input.d.ts +16 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +32 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/link-block.d.ts +13 -0
- package/dist/components/ui/link-block.d.ts.map +1 -0
- package/dist/components/ui/link-block.js +21 -0
- package/dist/components/ui/link-block.js.map +1 -0
- package/dist/components/ui/mac-card.d.ts +15 -0
- package/dist/components/ui/mac-card.d.ts.map +1 -0
- package/dist/components/ui/mac-card.js +9 -0
- package/dist/components/ui/mac-card.js.map +1 -0
- package/dist/components/ui/nav-tree.d.ts +16 -0
- package/dist/components/ui/nav-tree.d.ts.map +1 -0
- package/dist/components/ui/nav-tree.js +34 -0
- package/dist/components/ui/nav-tree.js.map +1 -0
- package/dist/components/ui/page.d.ts +12 -0
- package/dist/components/ui/page.d.ts.map +1 -0
- package/dist/components/ui/page.js +15 -0
- package/dist/components/ui/page.js.map +1 -0
- package/dist/components/ui/popover.d.ts +8 -0
- package/dist/components/ui/popover.d.ts.map +1 -0
- package/dist/components/ui/popover.js +18 -0
- package/dist/components/ui/popover.js.map +1 -0
- package/dist/components/ui/progress.d.ts +9 -0
- package/dist/components/ui/progress.d.ts.map +1 -0
- package/dist/components/ui/progress.js +9 -0
- package/dist/components/ui/progress.js.map +1 -0
- package/dist/components/ui/property.d.ts +15 -0
- package/dist/components/ui/property.d.ts.map +1 -0
- package/dist/components/ui/property.js +34 -0
- package/dist/components/ui/property.js.map +1 -0
- package/dist/components/ui/segmented.d.ts +13 -0
- package/dist/components/ui/segmented.d.ts.map +1 -0
- package/dist/components/ui/segmented.js +10 -0
- package/dist/components/ui/segmented.js.map +1 -0
- package/dist/components/ui/select-menu.d.ts +10 -0
- package/dist/components/ui/select-menu.d.ts.map +1 -0
- package/dist/components/ui/select-menu.js +10 -0
- package/dist/components/ui/select-menu.js.map +1 -0
- package/dist/components/ui/select.d.ts +11 -0
- package/dist/components/ui/select.d.ts.map +1 -0
- package/dist/components/ui/select.js +31 -0
- package/dist/components/ui/select.js.map +1 -0
- package/dist/components/ui/selection-bar.d.ts +12 -0
- package/dist/components/ui/selection-bar.d.ts.map +1 -0
- package/dist/components/ui/selection-bar.js +15 -0
- package/dist/components/ui/selection-bar.js.map +1 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/separator.js +12 -0
- package/dist/components/ui/separator.js.map +1 -0
- package/dist/components/ui/spotlight.d.ts +23 -0
- package/dist/components/ui/spotlight.d.ts.map +1 -0
- package/dist/components/ui/spotlight.js +107 -0
- package/dist/components/ui/spotlight.js.map +1 -0
- package/dist/components/ui/stat-tile.d.ts +8 -0
- package/dist/components/ui/stat-tile.d.ts.map +1 -0
- package/dist/components/ui/stat-tile.js +9 -0
- package/dist/components/ui/stat-tile.js.map +1 -0
- package/dist/components/ui/step-dialog.d.ts +20 -0
- package/dist/components/ui/step-dialog.d.ts.map +1 -0
- package/dist/components/ui/step-dialog.js +36 -0
- package/dist/components/ui/step-dialog.js.map +1 -0
- package/dist/components/ui/table.d.ts +8 -0
- package/dist/components/ui/table.d.ts.map +1 -0
- package/dist/components/ui/table.js +23 -0
- package/dist/components/ui/table.js.map +1 -0
- package/dist/components/ui/theme-toggle.d.ts +2 -0
- package/dist/components/ui/theme-toggle.d.ts.map +1 -0
- package/dist/components/ui/theme-toggle.js +49 -0
- package/dist/components/ui/theme-toggle.js.map +1 -0
- package/dist/components/ui/time-picker.d.ts +21 -0
- package/dist/components/ui/time-picker.d.ts.map +1 -0
- package/dist/components/ui/time-picker.js +63 -0
- package/dist/components/ui/time-picker.js.map +1 -0
- package/dist/components/ui/tooltip.d.ts +15 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/components/ui/tooltip.js +21 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/components/ui/typography.d.ts +34 -0
- package/dist/components/ui/typography.d.ts.map +1 -0
- package/dist/components/ui/typography.js +72 -0
- package/dist/components/ui/typography.js.map +1 -0
- package/dist/components/ui/video-block.d.ts +14 -0
- package/dist/components/ui/video-block.d.ts.map +1 -0
- package/dist/components/ui/video-block.js +18 -0
- package/dist/components/ui/video-block.js.map +1 -0
- package/dist/hooks/use-save-queue.d.ts +13 -0
- package/dist/hooks/use-save-queue.d.ts.map +1 -0
- package/dist/hooks/use-save-queue.js +45 -0
- package/dist/hooks/use-save-queue.js.map +1 -0
- package/dist/hooks/use-selection.d.ts +10 -0
- package/dist/hooks/use-selection.d.ts.map +1 -0
- package/dist/hooks/use-selection.js +43 -0
- package/dist/hooks/use-selection.js.map +1 -0
- package/dist/hooks/use-shared-transition.d.ts +3 -0
- package/dist/hooks/use-shared-transition.d.ts.map +1 -0
- package/dist/hooks/use-shared-transition.js +38 -0
- package/dist/hooks/use-shared-transition.js.map +1 -0
- package/dist/hooks/use-upload-queue.d.ts +22 -0
- package/dist/hooks/use-upload-queue.d.ts.map +1 -0
- package/dist/hooks/use-upload-queue.js +78 -0
- package/dist/hooks/use-upload-queue.js.map +1 -0
- package/dist/lib/accent.d.ts +5 -0
- package/dist/lib/accent.d.ts.map +1 -0
- package/dist/lib/accent.js +10 -0
- package/dist/lib/accent.js.map +1 -0
- package/dist/lib/bento.d.ts +17 -0
- package/dist/lib/bento.d.ts.map +1 -0
- package/dist/lib/bento.js +92 -0
- package/dist/lib/bento.js.map +1 -0
- package/dist/lib/dates.d.ts +14 -0
- package/dist/lib/dates.d.ts.map +1 -0
- package/dist/lib/dates.js +34 -0
- package/dist/lib/dates.js.map +1 -0
- package/dist/lib/document.d.ts +79 -0
- package/dist/lib/document.d.ts.map +1 -0
- package/dist/lib/document.js +11 -0
- package/dist/lib/document.js.map +1 -0
- package/dist/lib/embed.d.ts +14 -0
- package/dist/lib/embed.d.ts.map +1 -0
- package/dist/lib/embed.js +63 -0
- package/dist/lib/embed.js.map +1 -0
- package/dist/lib/files.d.ts +23 -0
- package/dist/lib/files.d.ts.map +1 -0
- package/dist/lib/files.js +69 -0
- package/dist/lib/files.js.map +1 -0
- package/dist/lib/justified.d.ts +50 -0
- package/dist/lib/justified.d.ts.map +1 -0
- package/dist/lib/justified.js +78 -0
- package/dist/lib/justified.js.map +1 -0
- package/dist/lib/rich-text-dom.d.ts +14 -0
- package/dist/lib/rich-text-dom.d.ts.map +1 -0
- package/dist/lib/rich-text-dom.js +143 -0
- package/dist/lib/rich-text-dom.js.map +1 -0
- package/dist/lib/rich-text.d.ts +15 -0
- package/dist/lib/rich-text.d.ts.map +1 -0
- package/dist/lib/rich-text.js +35 -0
- package/dist/lib/rich-text.js.map +1 -0
- package/dist/lib/spotlight.d.ts +22 -0
- package/dist/lib/spotlight.d.ts.map +1 -0
- package/dist/lib/spotlight.js +66 -0
- package/dist/lib/spotlight.js.map +1 -0
- package/dist/lib/tree.d.ts +17 -0
- package/dist/lib/tree.d.ts.map +1 -0
- package/dist/lib/tree.js +35 -0
- package/dist/lib/tree.js.map +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +6 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/styles/notion.css +526 -0
- package/package.json +106 -5
- package/src/components/editor/block-text.tsx +230 -0
- package/src/components/editor/blocks.tsx +368 -0
- package/src/components/editor/document-editor.tsx +101 -0
- package/src/components/editor/document-view.tsx +192 -0
- package/src/components/editor/editor-state.tsx +270 -0
- package/src/components/editor/extensions/spoiler.tsx +76 -0
- package/src/components/editor/index.ts +9 -0
- package/src/components/editor/kinds.ts +158 -0
- package/src/components/sketch/rough.tsx +90 -0
- package/src/components/ui/accent-picker.tsx +72 -0
- package/src/components/ui/address-field.tsx +57 -0
- package/src/components/ui/app-shell.tsx +138 -0
- package/src/components/ui/badge.tsx +81 -0
- package/src/components/ui/breadcrumbs.tsx +25 -0
- package/src/components/ui/button.tsx +73 -0
- package/src/components/ui/calendar.tsx +100 -0
- package/src/components/ui/callout.tsx +62 -0
- package/src/components/ui/card.tsx +90 -0
- package/src/components/ui/checkbox.tsx +32 -0
- package/src/components/ui/command-menu.tsx +72 -0
- package/src/components/ui/date-picker.tsx +170 -0
- package/src/components/ui/date-time-picker.tsx +117 -0
- package/src/components/ui/dialog.tsx +124 -0
- package/src/components/ui/dropdown-menu.tsx +183 -0
- package/src/components/ui/editable-text.tsx +109 -0
- package/src/components/ui/field-button.tsx +68 -0
- package/src/components/ui/file-preview.tsx +80 -0
- package/src/components/ui/file-uploader.tsx +376 -0
- package/src/components/ui/handle-row.tsx +116 -0
- package/src/components/ui/image-block.tsx +238 -0
- package/src/components/ui/image-card.tsx +102 -0
- package/src/components/ui/image-viewer.tsx +187 -0
- package/src/components/ui/image.tsx +96 -0
- package/src/components/ui/index.ts +83 -0
- package/src/components/ui/input.tsx +99 -0
- package/src/components/ui/link-block.tsx +82 -0
- package/src/components/ui/mac-card.tsx +46 -0
- package/src/components/ui/nav-tree.tsx +86 -0
- package/src/components/ui/page.tsx +25 -0
- package/src/components/ui/popover.tsx +42 -0
- package/src/components/ui/progress.tsx +36 -0
- package/src/components/ui/property.tsx +64 -0
- package/src/components/ui/segmented.tsx +42 -0
- package/src/components/ui/select-menu.tsx +46 -0
- package/src/components/ui/select.tsx +124 -0
- package/src/components/ui/selection-bar.tsx +50 -0
- package/src/components/ui/separator.tsx +30 -0
- package/src/components/ui/spotlight.tsx +222 -0
- package/src/components/ui/stat-tile.tsx +25 -0
- package/src/components/ui/step-dialog.tsx +104 -0
- package/src/components/ui/table.tsx +42 -0
- package/src/components/ui/theme-toggle.tsx +101 -0
- package/src/components/ui/time-picker.tsx +173 -0
- package/src/components/ui/tooltip.tsx +64 -0
- package/src/components/ui/typography.tsx +168 -0
- package/src/components/ui/video-block.tsx +60 -0
- package/src/hooks/use-save-queue.ts +66 -0
- package/src/hooks/use-selection.ts +44 -0
- package/src/hooks/use-shared-transition.ts +40 -0
- package/src/hooks/use-upload-queue.ts +111 -0
- package/src/lib/accent.ts +11 -0
- package/src/lib/bento.ts +87 -0
- package/src/lib/dates.ts +39 -0
- package/src/lib/document.ts +55 -0
- package/src/lib/embed.ts +62 -0
- package/src/lib/files.ts +73 -0
- package/src/lib/justified.ts +106 -0
- package/src/lib/rich-text-dom.ts +136 -0
- package/src/lib/rich-text.ts +50 -0
- package/src/lib/spotlight.ts +78 -0
- package/src/lib/tree.ts +41 -0
- package/src/lib/utils.ts +6 -0
- package/src/styles/notion.css +526 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
4
|
+
import { Check, ChevronDown } from "lucide-react";
|
|
5
|
+
import type { ComponentPropsWithoutRef } from "react";
|
|
6
|
+
import { fieldBase } from "./input.tsx";
|
|
7
|
+
import { cn } from "../../lib/utils.ts";
|
|
8
|
+
|
|
9
|
+
/* Pick one of a list, in a form. The trigger is the same sunken well as Input and
|
|
10
|
+
the list is the same surface as a menu, so it belongs to both. For a value shown
|
|
11
|
+
as plain text or a badge that opens a list when pressed, see SelectMenu.
|
|
12
|
+
|
|
13
|
+
An option's value cannot be the empty string: Radix keeps that for "nothing
|
|
14
|
+
chosen". Give "none" a name of its own. */
|
|
15
|
+
|
|
16
|
+
export const Select = SelectPrimitive.Root;
|
|
17
|
+
export const SelectGroup = SelectPrimitive.Group;
|
|
18
|
+
export const SelectValue = SelectPrimitive.Value;
|
|
19
|
+
|
|
20
|
+
export function SelectTrigger({
|
|
21
|
+
className,
|
|
22
|
+
children,
|
|
23
|
+
...props
|
|
24
|
+
}: ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>) {
|
|
25
|
+
return (
|
|
26
|
+
<SelectPrimitive.Trigger
|
|
27
|
+
className={cn(
|
|
28
|
+
fieldBase,
|
|
29
|
+
"flex h-8 items-center justify-between gap-2 text-left text-sm cursor-pointer",
|
|
30
|
+
"data-[placeholder]:text-ink-tertiary",
|
|
31
|
+
"data-[state=open]:bg-surface data-[state=open]:shadow-[inset_0_0_0_1px_var(--accent),0_0_0_3px_var(--accent-tint)]",
|
|
32
|
+
"[&>span]:min-w-0 [&>span]:truncate",
|
|
33
|
+
className,
|
|
34
|
+
)}
|
|
35
|
+
{...props}
|
|
36
|
+
>
|
|
37
|
+
{children}
|
|
38
|
+
<SelectPrimitive.Icon asChild>
|
|
39
|
+
<ChevronDown className="size-4 shrink-0 text-ink-tertiary" />
|
|
40
|
+
</SelectPrimitive.Icon>
|
|
41
|
+
</SelectPrimitive.Trigger>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function SelectContent({
|
|
46
|
+
className,
|
|
47
|
+
children,
|
|
48
|
+
sideOffset = 6,
|
|
49
|
+
...props
|
|
50
|
+
}: ComponentPropsWithoutRef<typeof SelectPrimitive.Content>) {
|
|
51
|
+
return (
|
|
52
|
+
<SelectPrimitive.Portal>
|
|
53
|
+
{/* Always a popper under the trigger. Radix's other mode lays the list
|
|
54
|
+
over the trigger to line the chosen item up with it, which jumps
|
|
55
|
+
about as the choice changes. */}
|
|
56
|
+
<SelectPrimitive.Content
|
|
57
|
+
position="popper"
|
|
58
|
+
sideOffset={sideOffset}
|
|
59
|
+
collisionPadding={8}
|
|
60
|
+
className={cn(
|
|
61
|
+
"z-50 overflow-hidden bg-surface-overlay shadow-popover rounded-overlay",
|
|
62
|
+
"min-w-[max(var(--radix-select-trigger-width),8rem)] max-h-[min(var(--radix-select-content-available-height),20rem)]",
|
|
63
|
+
"data-[state=open]:animate-slide-in data-[state=closed]:animate-fade-out",
|
|
64
|
+
"origin-[--radix-select-content-transform-origin]",
|
|
65
|
+
className,
|
|
66
|
+
)}
|
|
67
|
+
{...props}
|
|
68
|
+
>
|
|
69
|
+
<SelectPrimitive.Viewport className="p-1.5">{children}</SelectPrimitive.Viewport>
|
|
70
|
+
</SelectPrimitive.Content>
|
|
71
|
+
</SelectPrimitive.Portal>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function SelectItem({
|
|
76
|
+
className,
|
|
77
|
+
children,
|
|
78
|
+
...props
|
|
79
|
+
}: ComponentPropsWithoutRef<typeof SelectPrimitive.Item>) {
|
|
80
|
+
return (
|
|
81
|
+
<SelectPrimitive.Item
|
|
82
|
+
className={cn(
|
|
83
|
+
"relative flex items-center gap-2 cursor-default select-none",
|
|
84
|
+
"min-h-7 py-1 pr-8 pl-2 rounded-control text-sm text-ink outline-none",
|
|
85
|
+
"transition-colors duration-75",
|
|
86
|
+
"data-[highlighted]:bg-tint-hover",
|
|
87
|
+
"data-[disabled]:pointer-events-none data-[disabled]:text-ink-disabled",
|
|
88
|
+
className,
|
|
89
|
+
)}
|
|
90
|
+
{...props}
|
|
91
|
+
>
|
|
92
|
+
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
93
|
+
<span className="right-2 absolute flex justify-center items-center size-4">
|
|
94
|
+
<SelectPrimitive.ItemIndicator>
|
|
95
|
+
<Check className="size-4 text-ink-secondary" />
|
|
96
|
+
</SelectPrimitive.ItemIndicator>
|
|
97
|
+
</span>
|
|
98
|
+
</SelectPrimitive.Item>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function SelectLabel({
|
|
103
|
+
className,
|
|
104
|
+
...props
|
|
105
|
+
}: ComponentPropsWithoutRef<typeof SelectPrimitive.Label>) {
|
|
106
|
+
return (
|
|
107
|
+
<SelectPrimitive.Label
|
|
108
|
+
className={cn("px-2 pt-1.5 pb-1 font-medium text-ink-tertiary text-caption", className)}
|
|
109
|
+
{...props}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function SelectSeparator({
|
|
115
|
+
className,
|
|
116
|
+
...props
|
|
117
|
+
}: ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>) {
|
|
118
|
+
return (
|
|
119
|
+
<SelectPrimitive.Separator
|
|
120
|
+
className={cn("-mx-1.5 my-1.5 bg-hairline h-px", className)}
|
|
121
|
+
{...props}
|
|
122
|
+
/>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { X } from "lucide-react";
|
|
4
|
+
import type { ReactNode } from "react";
|
|
5
|
+
import { Button } from "./button.tsx";
|
|
6
|
+
import { cn } from "../../lib/utils.ts";
|
|
7
|
+
|
|
8
|
+
/* What can be done to the things picked: a bar that rises from the bottom of
|
|
9
|
+
the window while a selection is being made, saying how many and offering
|
|
10
|
+
the actions as its children (ghost buttons, small).
|
|
11
|
+
|
|
12
|
+
It centres on the page, not the window: if the app sets `--sidebar-w` (as
|
|
13
|
+
`AppShell` does) it clears the sidebar. Pair it with `useSelection`. */
|
|
14
|
+
export function SelectionBar({
|
|
15
|
+
count,
|
|
16
|
+
noun = "item",
|
|
17
|
+
empty = "Pick some",
|
|
18
|
+
onDone,
|
|
19
|
+
children,
|
|
20
|
+
className,
|
|
21
|
+
}: {
|
|
22
|
+
count: number;
|
|
23
|
+
/** Singular; an "s" is added for any count but one. */
|
|
24
|
+
noun?: string;
|
|
25
|
+
/** Said while nothing is picked yet. */
|
|
26
|
+
empty?: string;
|
|
27
|
+
onDone: () => void;
|
|
28
|
+
children: ReactNode;
|
|
29
|
+
className?: string;
|
|
30
|
+
}) {
|
|
31
|
+
return (
|
|
32
|
+
<div
|
|
33
|
+
role="toolbar"
|
|
34
|
+
aria-label="Selection"
|
|
35
|
+
className={cn(
|
|
36
|
+
"fixed bottom-5 left-[calc(50%+var(--sidebar-w,0px)/2)] z-40 flex max-w-[calc(100vw-2rem)] -translate-x-1/2 animate-slide-in items-center gap-1",
|
|
37
|
+
"rounded-overlay bg-surface-overlay py-1.5 pr-1.5 pl-4 shadow-popover",
|
|
38
|
+
className,
|
|
39
|
+
)}
|
|
40
|
+
>
|
|
41
|
+
<span className="mr-2 text-sm font-medium whitespace-nowrap text-ink tabular-nums" aria-live="polite">
|
|
42
|
+
{count === 0 ? empty : `${count.toLocaleString()} ${noun}${count === 1 ? "" : "s"} selected`}
|
|
43
|
+
</span>
|
|
44
|
+
{children}
|
|
45
|
+
<Button variant="ghost" size="icon-sm" aria-label="Stop selecting" onClick={onDone} className="ml-1">
|
|
46
|
+
<X />
|
|
47
|
+
</Button>
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
4
|
+
import type { ComponentPropsWithoutRef } from "react";
|
|
5
|
+
import { cn } from "../../lib/utils.ts";
|
|
6
|
+
|
|
7
|
+
/* Dividers whisper. 1px at 9% ink — if you can see it clearly from
|
|
8
|
+
across the room, it is too strong. */
|
|
9
|
+
|
|
10
|
+
export function Separator({
|
|
11
|
+
className,
|
|
12
|
+
orientation = "horizontal",
|
|
13
|
+
decorative = true,
|
|
14
|
+
...props
|
|
15
|
+
}: ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>) {
|
|
16
|
+
return (
|
|
17
|
+
<SeparatorPrimitive.Root
|
|
18
|
+
decorative={decorative}
|
|
19
|
+
orientation={orientation}
|
|
20
|
+
className={cn(
|
|
21
|
+
"bg-hairline shrink-0",
|
|
22
|
+
orientation === "horizontal"
|
|
23
|
+
? "w-full h-px"
|
|
24
|
+
: "w-px h-full self-stretch",
|
|
25
|
+
className,
|
|
26
|
+
)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
4
|
+
import { CornerDownLeft, Search, type LucideIcon } from "lucide-react";
|
|
5
|
+
import { Fragment, useEffect, useId, useMemo, useRef, useState, type ReactNode } from "react";
|
|
6
|
+
import { rankEntries, type SpotlightEntry } from "../../lib/spotlight.ts";
|
|
7
|
+
import { cn } from "../../lib/utils.ts";
|
|
8
|
+
import { Kbd } from "./typography.tsx";
|
|
9
|
+
|
|
10
|
+
export type SpotlightItem = SpotlightEntry & { icon?: LucideIcon };
|
|
11
|
+
|
|
12
|
+
/** Whether the platform's own shortcut modifier is ⌘ rather than Ctrl. */
|
|
13
|
+
const mac = () => typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* ⌘K (Ctrl+K elsewhere) from anywhere on the page calls `toggle`. Kept apart from
|
|
17
|
+
* the Spotlight so the owner decides what the shortcut opens and when.
|
|
18
|
+
*/
|
|
19
|
+
export function useSpotlightShortcut(toggle: () => void): void {
|
|
20
|
+
const latest = useRef(toggle);
|
|
21
|
+
latest.current = toggle;
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const onKey = (e: KeyboardEvent) => {
|
|
24
|
+
if (e.key.toLowerCase() === "k" && (e.metaKey || e.ctrlKey) && !e.altKey && !e.shiftKey) {
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
latest.current();
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
window.addEventListener("keydown", onKey);
|
|
30
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
31
|
+
}, []);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The label with the typed letters picked out. */
|
|
35
|
+
function Marked({ text, hits }: { text: string; hits: number[] }) {
|
|
36
|
+
if (hits.length === 0) return <>{text}</>;
|
|
37
|
+
const at = new Set(hits);
|
|
38
|
+
const runs: { text: string; hit: boolean }[] = [];
|
|
39
|
+
for (let i = 0; i < text.length; i++) {
|
|
40
|
+
const hit = at.has(i);
|
|
41
|
+
const last = runs.at(-1);
|
|
42
|
+
if (last && last.hit === hit) last.text += text[i];
|
|
43
|
+
else runs.push({ text: text[i]!, hit });
|
|
44
|
+
}
|
|
45
|
+
return (
|
|
46
|
+
<>
|
|
47
|
+
{runs.map((run, i) =>
|
|
48
|
+
run.hit ? (
|
|
49
|
+
<mark key={i} className="bg-transparent font-semibold text-ink underline decoration-accent/50 underline-offset-2">
|
|
50
|
+
{run.text}
|
|
51
|
+
</mark>
|
|
52
|
+
) : (
|
|
53
|
+
<Fragment key={i}>{run.text}</Fragment>
|
|
54
|
+
),
|
|
55
|
+
)}
|
|
56
|
+
</>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* Jump anywhere by typing: a search field over every place the owner lists, best
|
|
61
|
+
match first. The keyboard never leaves the field — the arrows move the highlight,
|
|
62
|
+
Enter goes, Escape closes — so a page is a few keystrokes away.
|
|
63
|
+
|
|
64
|
+
With nothing typed it lists the entries as given, under their groups, so the
|
|
65
|
+
owner decides what is offered first (the current page's neighbours, say). Once
|
|
66
|
+
something is typed it is one ranked list, each entry's group shown beside it. */
|
|
67
|
+
export function Spotlight({
|
|
68
|
+
open,
|
|
69
|
+
onOpenChange,
|
|
70
|
+
items,
|
|
71
|
+
onPick,
|
|
72
|
+
placeholder = "Search…",
|
|
73
|
+
empty = "Nothing matches",
|
|
74
|
+
title = "Go to",
|
|
75
|
+
}: {
|
|
76
|
+
open: boolean;
|
|
77
|
+
onOpenChange: (open: boolean) => void;
|
|
78
|
+
items: SpotlightItem[];
|
|
79
|
+
onPick: (item: SpotlightItem) => void;
|
|
80
|
+
placeholder?: string;
|
|
81
|
+
/** Shown in place of results when nothing matches. */
|
|
82
|
+
empty?: ReactNode;
|
|
83
|
+
/** Read out to assistive technology; not shown. */
|
|
84
|
+
title?: string;
|
|
85
|
+
}) {
|
|
86
|
+
const [query, setQuery] = useState("");
|
|
87
|
+
const [index, setIndex] = useState(0);
|
|
88
|
+
const list = useRef<HTMLDivElement>(null);
|
|
89
|
+
const id = useId();
|
|
90
|
+
|
|
91
|
+
// Every opening starts afresh.
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (!open) return;
|
|
94
|
+
setQuery("");
|
|
95
|
+
setIndex(0);
|
|
96
|
+
}, [open]);
|
|
97
|
+
|
|
98
|
+
const results = useMemo(() => rankEntries(items, query), [items, query]);
|
|
99
|
+
const browsing = query.trim() === "";
|
|
100
|
+
const active = Math.min(index, Math.max(results.length - 1, 0));
|
|
101
|
+
|
|
102
|
+
// The keyboard moves the highlight, so the list follows it out of view.
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
list.current?.querySelector('[aria-selected="true"]')?.scrollIntoView({ block: "nearest" });
|
|
105
|
+
}, [active, open]);
|
|
106
|
+
|
|
107
|
+
const pick = (item: SpotlightItem | undefined) => {
|
|
108
|
+
if (item === undefined) return;
|
|
109
|
+
onOpenChange(false);
|
|
110
|
+
onPick(item);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const move = (by: number) => {
|
|
114
|
+
if (results.length === 0) return;
|
|
115
|
+
setIndex((active + by + results.length) % results.length);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<DialogPrimitive.Root open={open} onOpenChange={onOpenChange}>
|
|
120
|
+
<DialogPrimitive.Portal>
|
|
121
|
+
<DialogPrimitive.Overlay className="z-50 fixed inset-0 bg-black/32 data-[state=open]:animate-fade-in data-[state=closed]:animate-fade-out" />
|
|
122
|
+
<DialogPrimitive.Content
|
|
123
|
+
aria-describedby={undefined}
|
|
124
|
+
className={cn(
|
|
125
|
+
"z-50 fixed top-[12dvh] left-1/2 -translate-x-1/2 flex flex-col",
|
|
126
|
+
"w-[calc(100vw-2rem)] max-w-xl max-h-[min(30rem,76dvh)] overflow-hidden outline-none",
|
|
127
|
+
"bg-surface-overlay shadow-dialog rounded-overlay",
|
|
128
|
+
"data-[state=open]:animate-scale-in data-[state=closed]:animate-scale-out",
|
|
129
|
+
)}
|
|
130
|
+
>
|
|
131
|
+
<DialogPrimitive.Title className="sr-only">{title}</DialogPrimitive.Title>
|
|
132
|
+
<div className="flex items-center gap-2.5 shadow-[inset_0_-1px_0_var(--hairline)] px-4 h-12 shrink-0">
|
|
133
|
+
<Search className="size-4 text-ink-tertiary shrink-0" />
|
|
134
|
+
<input
|
|
135
|
+
autoFocus
|
|
136
|
+
role="combobox"
|
|
137
|
+
aria-expanded
|
|
138
|
+
aria-controls={`${id}-list`}
|
|
139
|
+
aria-activedescendant={results.length > 0 ? `${id}-${active}` : undefined}
|
|
140
|
+
aria-autocomplete="list"
|
|
141
|
+
value={query}
|
|
142
|
+
placeholder={placeholder}
|
|
143
|
+
onChange={(e) => {
|
|
144
|
+
setQuery(e.target.value);
|
|
145
|
+
setIndex(0);
|
|
146
|
+
}}
|
|
147
|
+
onKeyDown={(e) => {
|
|
148
|
+
const ctrl = e.ctrlKey && !e.metaKey;
|
|
149
|
+
if (e.key === "ArrowDown" || (ctrl && e.key === "n")) {
|
|
150
|
+
e.preventDefault();
|
|
151
|
+
move(1);
|
|
152
|
+
} else if (e.key === "ArrowUp" || (ctrl && e.key === "p")) {
|
|
153
|
+
e.preventDefault();
|
|
154
|
+
move(-1);
|
|
155
|
+
} else if (e.key === "Enter" && !e.nativeEvent.isComposing) {
|
|
156
|
+
e.preventDefault();
|
|
157
|
+
pick(results[active]?.item);
|
|
158
|
+
}
|
|
159
|
+
}}
|
|
160
|
+
className="flex-1 bg-transparent min-w-0 text-ink placeholder:text-ink-tertiary outline-none"
|
|
161
|
+
/>
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
<div ref={list} id={`${id}-list`} role="listbox" aria-label={title} className="flex-1 p-1.5 min-h-0 overflow-y-auto overscroll-contain">
|
|
165
|
+
{results.length === 0 && <p className="px-3 py-6 text-ink-tertiary text-sm text-center">{empty}</p>}
|
|
166
|
+
{results.map(({ item, hits }, i) => {
|
|
167
|
+
const heading = browsing && item.group !== undefined && item.group !== results[i - 1]?.item.group;
|
|
168
|
+
const Icon = item.icon;
|
|
169
|
+
return (
|
|
170
|
+
<Fragment key={item.key}>
|
|
171
|
+
{heading && <div className="px-2 pt-2.5 pb-1 font-medium text-caption text-ink-tertiary first:pt-1">{item.group}</div>}
|
|
172
|
+
<div
|
|
173
|
+
id={`${id}-${i}`}
|
|
174
|
+
role="option"
|
|
175
|
+
aria-selected={i === active}
|
|
176
|
+
// Movement, not entry: a list scrolled under a still pointer keeps the keyboard's pick.
|
|
177
|
+
onPointerMove={() => i !== active && setIndex(i)}
|
|
178
|
+
onClick={() => pick(item)}
|
|
179
|
+
className={cn(
|
|
180
|
+
"flex items-center gap-2.5 px-2 rounded-control h-9 text-sm cursor-pointer select-none",
|
|
181
|
+
i === active && "bg-tint-hover",
|
|
182
|
+
)}
|
|
183
|
+
>
|
|
184
|
+
{Icon && <Icon className="size-4 text-ink-secondary shrink-0" />}
|
|
185
|
+
<span className="min-w-0 text-ink truncate">
|
|
186
|
+
<Marked text={item.label} hits={hits} />
|
|
187
|
+
</span>
|
|
188
|
+
{(item.hint ?? (!browsing ? item.group : undefined)) && (
|
|
189
|
+
<span className="min-w-0 text-ink-tertiary truncate">{item.hint ?? item.group}</span>
|
|
190
|
+
)}
|
|
191
|
+
{i === active && <CornerDownLeft className="ml-auto size-3.5 text-ink-tertiary shrink-0" />}
|
|
192
|
+
</div>
|
|
193
|
+
</Fragment>
|
|
194
|
+
);
|
|
195
|
+
})}
|
|
196
|
+
</div>
|
|
197
|
+
|
|
198
|
+
<div className="max-sm:hidden flex items-center gap-4 shadow-[inset_0_1px_0_var(--hairline)] px-4 h-9 text-caption text-ink-tertiary shrink-0">
|
|
199
|
+
<span className="flex items-center gap-1">
|
|
200
|
+
<Kbd>↑</Kbd>
|
|
201
|
+
<Kbd>↓</Kbd>
|
|
202
|
+
to move
|
|
203
|
+
</span>
|
|
204
|
+
<span className="flex items-center gap-1">
|
|
205
|
+
<Kbd>↵</Kbd>
|
|
206
|
+
to open
|
|
207
|
+
</span>
|
|
208
|
+
<span className="flex items-center gap-1">
|
|
209
|
+
<Kbd>esc</Kbd>
|
|
210
|
+
to close
|
|
211
|
+
</span>
|
|
212
|
+
<span className="flex items-center gap-1 ml-auto">
|
|
213
|
+
<Kbd>{mac() ? "⌘" : "Ctrl"}</Kbd>
|
|
214
|
+
<Kbd>K</Kbd>
|
|
215
|
+
anywhere
|
|
216
|
+
</span>
|
|
217
|
+
</div>
|
|
218
|
+
</DialogPrimitive.Content>
|
|
219
|
+
</DialogPrimitive.Portal>
|
|
220
|
+
</DialogPrimitive.Root>
|
|
221
|
+
);
|
|
222
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { cn } from "../../lib/utils.ts";
|
|
3
|
+
|
|
4
|
+
/* One headline figure: a quiet label, the number in the accent's text shade, and an
|
|
5
|
+
optional line of context. Lay several out in a grid; `min-w-0` lets them shrink
|
|
6
|
+
in one. */
|
|
7
|
+
export function StatTile({
|
|
8
|
+
label,
|
|
9
|
+
value,
|
|
10
|
+
note,
|
|
11
|
+
className,
|
|
12
|
+
}: {
|
|
13
|
+
label: string;
|
|
14
|
+
value: ReactNode;
|
|
15
|
+
note?: ReactNode;
|
|
16
|
+
className?: string;
|
|
17
|
+
}) {
|
|
18
|
+
return (
|
|
19
|
+
<div className={cn("min-w-0 rounded-surface bg-surface-sunken px-4 py-3", className)}>
|
|
20
|
+
<div className="text-caption font-medium text-ink-secondary">{label}</div>
|
|
21
|
+
<div className="mt-0.5 text-h3 break-all text-accent-text tabular-nums">{value}</div>
|
|
22
|
+
{note && <div className="mt-0.5 text-caption text-ink-tertiary">{note}</div>}
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Check } from "lucide-react";
|
|
4
|
+
import { useEffect, useRef, type CSSProperties, type ReactNode } from "react";
|
|
5
|
+
import { Dialog, DialogContent, DialogDescription, DialogTitle } from "./dialog.tsx";
|
|
6
|
+
import { cn } from "../../lib/utils.ts";
|
|
7
|
+
|
|
8
|
+
/* Where a sequence of steps stands: done ones ticked, the current one ringed,
|
|
9
|
+
the rest waiting. Numbered because it is a sequence; do not use it for
|
|
10
|
+
things that are merely a list. Labels drop away on a narrow screen. */
|
|
11
|
+
export function Stepper({ steps, step, className }: { steps: readonly string[]; step: number; className?: string }) {
|
|
12
|
+
return (
|
|
13
|
+
<ol className={cn("flex items-center gap-2 text-sm", className)}>
|
|
14
|
+
{steps.map((label, index) => (
|
|
15
|
+
<li key={label} className="flex items-center gap-2">
|
|
16
|
+
{index > 0 && <span aria-hidden className={cn("h-px w-5 transition-colors duration-200 sm:w-8", index <= step ? "bg-accent" : "bg-hairline-strong")} />}
|
|
17
|
+
<span
|
|
18
|
+
aria-current={index === step ? "step" : undefined}
|
|
19
|
+
className={cn(
|
|
20
|
+
"flex items-center gap-1.5 transition-colors duration-200",
|
|
21
|
+
index === step ? "font-medium text-ink" : index < step ? "text-ink-secondary" : "text-ink-tertiary",
|
|
22
|
+
)}
|
|
23
|
+
>
|
|
24
|
+
<span
|
|
25
|
+
className={cn(
|
|
26
|
+
"flex size-5 items-center justify-center rounded-full text-caption font-medium tabular-nums transition-colors duration-200",
|
|
27
|
+
index < step
|
|
28
|
+
? "bg-accent text-accent-ink"
|
|
29
|
+
: index === step
|
|
30
|
+
? "bg-accent-tint text-accent-text shadow-[inset_0_0_0_1px_var(--accent)]"
|
|
31
|
+
: "bg-tint-active text-ink-tertiary",
|
|
32
|
+
)}
|
|
33
|
+
>
|
|
34
|
+
{index < step ? <Check className="size-3" /> : index + 1}
|
|
35
|
+
</span>
|
|
36
|
+
<span className="max-sm:hidden">{label}</span>
|
|
37
|
+
</span>
|
|
38
|
+
</li>
|
|
39
|
+
))}
|
|
40
|
+
</ol>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* A dialog that is several steps long: choose, review, send, done.
|
|
45
|
+
|
|
46
|
+
It keeps one size while its content changes, so nothing jumps. The header
|
|
47
|
+
holds the stepper and a title; the body is whatever the current step is,
|
|
48
|
+
and slides in from the side the step came from; the footer holds the
|
|
49
|
+
buttons, which you supply per step.
|
|
50
|
+
|
|
51
|
+
You own `step`. Derive it from what there is where you can (files chosen
|
|
52
|
+
but not sent, work in flight, work finished) instead of advancing it by
|
|
53
|
+
hand: then closing and reopening lands on the right step for free. */
|
|
54
|
+
export function StepDialog({
|
|
55
|
+
open,
|
|
56
|
+
onOpenChange,
|
|
57
|
+
steps,
|
|
58
|
+
step,
|
|
59
|
+
title,
|
|
60
|
+
description,
|
|
61
|
+
banner,
|
|
62
|
+
children,
|
|
63
|
+
footer,
|
|
64
|
+
className,
|
|
65
|
+
}: {
|
|
66
|
+
open: boolean;
|
|
67
|
+
onOpenChange: (open: boolean) => void;
|
|
68
|
+
steps: readonly string[];
|
|
69
|
+
step: number;
|
|
70
|
+
title: ReactNode;
|
|
71
|
+
description?: ReactNode;
|
|
72
|
+
/** Between the header and the body: a progress bar, a warning. */
|
|
73
|
+
banner?: ReactNode;
|
|
74
|
+
children: ReactNode;
|
|
75
|
+
footer: ReactNode;
|
|
76
|
+
className?: string;
|
|
77
|
+
}) {
|
|
78
|
+
// Which way the last change went, so the new step arrives from that side.
|
|
79
|
+
const last = useRef(step);
|
|
80
|
+
const from = step >= last.current ? 1 : -1;
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
last.current = step;
|
|
83
|
+
}, [step]);
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
87
|
+
<DialogContent className={cn("flex h-[min(46rem,90dvh)] max-w-4xl flex-col overflow-hidden", className)} aria-describedby={undefined}>
|
|
88
|
+
<header className="shrink-0 px-6 pt-5 pr-14">
|
|
89
|
+
<Stepper steps={steps} step={step} />
|
|
90
|
+
<DialogTitle className="mt-4 text-h2">{title}</DialogTitle>
|
|
91
|
+
{/* Always there, so the body does not shift when a step has nothing to say. */}
|
|
92
|
+
<DialogDescription className="min-h-5">{description}</DialogDescription>
|
|
93
|
+
{banner}
|
|
94
|
+
</header>
|
|
95
|
+
|
|
96
|
+
<div key={step} className="min-h-0 flex-1 animate-step-in overflow-y-auto px-6 py-4" style={{ "--from": from } as CSSProperties}>
|
|
97
|
+
{children}
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<footer className="flex shrink-0 items-center gap-2 px-6 py-4 shadow-[inset_0_1px_0_var(--hairline)]">{footer}</footer>
|
|
101
|
+
</DialogContent>
|
|
102
|
+
</Dialog>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { ComponentPropsWithoutRef } from "react";
|
|
4
|
+
import { cn } from "../../lib/utils.ts";
|
|
5
|
+
|
|
6
|
+
/* Notion's simple table: a hairline grid, a sunken header row, 14px text. It scrolls
|
|
7
|
+
sideways inside its own box rather than squeezing columns below a readable width,
|
|
8
|
+
which is what keeps a page from scrolling sideways on a phone. */
|
|
9
|
+
|
|
10
|
+
export function Table({ className, children, ...props }: ComponentPropsWithoutRef<"table">) {
|
|
11
|
+
return (
|
|
12
|
+
<div className="overflow-x-auto">
|
|
13
|
+
<table className={cn("w-full border-collapse text-sm", className)} {...props}>
|
|
14
|
+
{children}
|
|
15
|
+
</table>
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const cell = "border border-hairline-strong px-[9px] py-[7px] text-left align-top";
|
|
21
|
+
|
|
22
|
+
export function Th({ className, ...props }: ComponentPropsWithoutRef<"th">) {
|
|
23
|
+
return <th scope="col" className={cn(cell, "bg-surface-sunken font-medium", className)} {...props} />;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function Td({ className, ...props }: ComponentPropsWithoutRef<"td">) {
|
|
27
|
+
return <td className={cn(cell, "min-w-28", className)} {...props} />;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* A row that opens something: hover tint, pointer, and Enter from the keyboard. */
|
|
31
|
+
export function ClickableRow({ className, onOpen, ...props }: ComponentPropsWithoutRef<"tr"> & { onOpen: () => void }) {
|
|
32
|
+
return (
|
|
33
|
+
<tr
|
|
34
|
+
tabIndex={0}
|
|
35
|
+
// A link inside a cell keeps its own click.
|
|
36
|
+
onClick={(e) => !(e.target as Element).closest("a") && onOpen()}
|
|
37
|
+
onKeyDown={(e) => e.key === "Enter" && onOpen()}
|
|
38
|
+
className={cn("cursor-pointer outline-offset-[-2px] transition-colors duration-100 hover:bg-tint-hover", className)}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
}
|