@asanchez-sa/abby 0.0.0-stage → 0.1.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/README.md +245 -2
- package/dist/_virtual/_rolldown/runtime.js +26 -0
- package/dist/agents/approvals.d.ts +46 -0
- package/dist/agents/approvals.js +58 -0
- package/dist/agents/changes.d.ts +21 -0
- package/dist/agents/changes.js +21 -0
- package/dist/agents/hooks.d.ts +20 -0
- package/dist/agents/hooks.js +58 -0
- package/dist/agents/index.d.ts +11 -0
- package/dist/agents/index.js +9 -0
- package/dist/agents/run-tool.d.ts +44 -0
- package/dist/agents/run-tool.js +79 -0
- package/dist/agents/ui-sdk.d.ts +5 -0
- package/dist/agents/ui-sdk.js +3 -0
- package/dist/behaviors/canvas/index.d.ts +2 -0
- package/dist/behaviors/canvas/index.js +1 -0
- package/dist/behaviors/canvas/ui-sdk.d.ts +2 -0
- package/dist/behaviors/canvas/ui-sdk.js +1 -0
- package/dist/behaviors/drag-and-drop/index.d.ts +2 -0
- package/dist/behaviors/drag-and-drop/index.js +1 -0
- package/dist/behaviors/drag-and-drop/ui-sdk.d.ts +2 -0
- package/dist/behaviors/drag-and-drop/ui-sdk.js +1 -0
- package/dist/behaviors/dragging/index.d.ts +2 -0
- package/dist/behaviors/dragging/index.js +1 -0
- package/dist/behaviors/dragging/ui-sdk.d.ts +2 -0
- package/dist/behaviors/dragging/ui-sdk.js +1 -0
- package/dist/behaviors/focus/index.d.ts +2 -0
- package/dist/behaviors/focus/index.js +1 -0
- package/dist/behaviors/focus/ui-sdk.d.ts +2 -0
- package/dist/behaviors/focus/ui-sdk.js +1 -0
- package/dist/behaviors/lists/index.d.ts +3 -0
- package/dist/behaviors/lists/index.js +3 -0
- package/dist/behaviors/lists/ui-sdk.d.ts +3 -0
- package/dist/behaviors/lists/ui-sdk.js +3 -0
- package/dist/behaviors/popups/index.d.ts +3 -0
- package/dist/behaviors/popups/index.js +3 -0
- package/dist/behaviors/popups/ui-sdk.d.ts +3 -0
- package/dist/behaviors/popups/ui-sdk.js +3 -0
- package/dist/behaviors/preferences/index.d.ts +3 -0
- package/dist/behaviors/preferences/index.js +3 -0
- package/dist/behaviors/preferences/ui-sdk.d.ts +3 -0
- package/dist/behaviors/preferences/ui-sdk.js +3 -0
- package/dist/behaviors/selection/index.d.ts +3 -0
- package/dist/behaviors/selection/index.js +3 -0
- package/dist/behaviors/selection/indicator.d.ts +13 -0
- package/dist/behaviors/selection/indicator.js +20 -0
- package/dist/behaviors/selection/ui-sdk.d.ts +2 -0
- package/dist/behaviors/selection/ui-sdk.js +1 -0
- package/dist/behaviors/transitions/index.d.ts +3 -0
- package/dist/behaviors/transitions/index.js +3 -0
- package/dist/behaviors/transitions/ui-sdk.d.ts +3 -0
- package/dist/behaviors/transitions/ui-sdk.js +3 -0
- package/dist/behaviors/trees/index.d.ts +2 -0
- package/dist/behaviors/trees/index.js +1 -0
- package/dist/behaviors/trees/ui-sdk.d.ts +2 -0
- package/dist/behaviors/trees/ui-sdk.js +1 -0
- package/dist/components/accordion/accordion.d.ts +13 -0
- package/dist/components/accordion/accordion.js +165 -0
- package/dist/components/alert/alert.d.ts +13 -0
- package/dist/components/alert/alert.js +131 -0
- package/dist/components/alert-dialog/alert-dialog.d.ts +15 -0
- package/dist/components/alert-dialog/alert-dialog.js +257 -0
- package/dist/components/aspect-ratio/aspect-ratio.d.ts +7 -0
- package/dist/components/aspect-ratio/aspect-ratio.js +57 -0
- package/dist/components/attachment/attachment.d.ts +48 -0
- package/dist/components/attachment/attachment.js +372 -0
- package/dist/components/autocomplete/autocomplete.d.ts +32 -0
- package/dist/components/autocomplete/autocomplete.js +466 -0
- package/dist/components/avatar/avatar.d.ts +6 -0
- package/dist/components/avatar/avatar.js +100 -0
- package/dist/components/avatar-group/avatar-group.d.ts +9 -0
- package/dist/components/avatar-group/avatar-group.js +75 -0
- package/dist/components/badge/badge.d.ts +15 -0
- package/dist/components/badge/badge.js +31 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts +24 -0
- package/dist/components/breadcrumb/breadcrumb.js +279 -0
- package/dist/components/bubble/bubble.d.ts +26 -0
- package/dist/components/bubble/bubble.js +173 -0
- package/dist/components/button/button.d.ts +18 -0
- package/dist/components/button/button.js +91 -0
- package/dist/components/button-group/button-group.d.ts +15 -0
- package/dist/components/button-group/button-group.js +71 -0
- package/dist/components/calendar/calendar.d.ts +29 -0
- package/dist/components/calendar/calendar.js +453 -0
- package/dist/components/card/card.d.ts +14 -0
- package/dist/components/card/card.js +213 -0
- package/dist/components/carousel/carousel.d.ts +16 -0
- package/dist/components/carousel/carousel.js +364 -0
- package/dist/components/chain-of-thought/chain-of-thought.d.ts +72 -0
- package/dist/components/chain-of-thought/chain-of-thought.js +491 -0
- package/dist/components/chat/chat.d.ts +48 -0
- package/dist/components/chat/chat.js +207 -0
- package/dist/components/checkbox/checkbox.d.ts +10 -0
- package/dist/components/checkbox/checkbox.js +118 -0
- package/dist/components/checkpoint/checkpoint.d.ts +24 -0
- package/dist/components/checkpoint/checkpoint.js +178 -0
- package/dist/components/choice-cards/choice-cards.d.ts +38 -0
- package/dist/components/choice-cards/choice-cards.js +255 -0
- package/dist/components/code-block/code-block.d.ts +58 -0
- package/dist/components/code-block/code-block.js +506 -0
- package/dist/components/code-block/highlighter.js +96 -0
- package/dist/components/code-block/use-highlighted-code.d.ts +11 -0
- package/dist/components/code-block/use-highlighted-code.js +54 -0
- package/dist/components/collapsible/collapsible.d.ts +10 -0
- package/dist/components/collapsible/collapsible.js +92 -0
- package/dist/components/color-picker/color-picker.d.ts +17 -0
- package/dist/components/color-picker/color-picker.js +395 -0
- package/dist/components/combobox/combobox.d.ts +54 -0
- package/dist/components/combobox/combobox.js +683 -0
- package/dist/components/command/command.d.ts +23 -0
- package/dist/components/command/command.js +373 -0
- package/dist/components/command-dock/command-dock.d.ts +118 -0
- package/dist/components/command-dock/command-dock.js +944 -0
- package/dist/components/confirmation/confirmation.d.ts +58 -0
- package/dist/components/confirmation/confirmation.js +181 -0
- package/dist/components/context/context.d.ts +82 -0
- package/dist/components/context/context.js +490 -0
- package/dist/components/date-input/date-input.d.ts +16 -0
- package/dist/components/date-input/date-input.js +89 -0
- package/dist/components/date-picker/date-picker.d.ts +28 -0
- package/dist/components/date-picker/date-picker.js +361 -0
- package/dist/components/dialog/dialog.d.ts +14 -0
- package/dist/components/dialog/dialog.js +261 -0
- package/dist/components/drawer/drawer.d.ts +16 -0
- package/dist/components/drawer/drawer.js +309 -0
- package/dist/components/empty/empty.d.ts +18 -0
- package/dist/components/empty/empty.js +192 -0
- package/dist/components/field/field.d.ts +15 -0
- package/dist/components/field/field.js +261 -0
- package/dist/components/file-input/file-input.d.ts +12 -0
- package/dist/components/file-input/file-input.js +216 -0
- package/dist/components/file-tree/file-tree.d.ts +45 -0
- package/dist/components/file-tree/file-tree.js +283 -0
- package/dist/components/hover-card/hover-card.d.ts +10 -0
- package/dist/components/hover-card/hover-card.js +118 -0
- package/dist/components/icon/icon.d.ts +14 -0
- package/dist/components/icon/icon.js +60 -0
- package/dist/components/image-cropper/image-cropper.d.ts +15 -0
- package/dist/components/image-cropper/image-cropper.js +334 -0
- package/dist/components/inline-citation/inline-citation.d.ts +46 -0
- package/dist/components/inline-citation/inline-citation.js +269 -0
- package/dist/components/input/input.d.ts +9 -0
- package/dist/components/input/input.js +43 -0
- package/dist/components/input-group/input-group.d.ts +42 -0
- package/dist/components/input-group/input-group.js +192 -0
- package/dist/components/item/item.d.ts +32 -0
- package/dist/components/item/item.js +394 -0
- package/dist/components/kbd/kbd.d.ts +9 -0
- package/dist/components/kbd/kbd.js +75 -0
- package/dist/components/label/label.d.ts +6 -0
- package/dist/components/label/label.js +40 -0
- package/dist/components/link/link.d.ts +21 -0
- package/dist/components/link/link.js +126 -0
- package/dist/components/listbox/listbox.d.ts +20 -0
- package/dist/components/listbox/listbox.js +199 -0
- package/dist/components/marker/marker.d.ts +11 -0
- package/dist/components/marker/marker.js +88 -0
- package/dist/components/menu/menu.d.ts +38 -0
- package/dist/components/menu/menu.js +553 -0
- package/dist/components/menubar/menubar.d.ts +9 -0
- package/dist/components/menubar/menubar.js +47 -0
- package/dist/components/message/message.d.ts +44 -0
- package/dist/components/message/message.js +328 -0
- package/dist/components/message-scroller/message-scroller.d.ts +111 -0
- package/dist/components/message-scroller/message-scroller.js +957 -0
- package/dist/components/meter/meter.d.ts +8 -0
- package/dist/components/meter/meter.js +162 -0
- package/dist/components/model-selector/model-selector.d.ts +155 -0
- package/dist/components/model-selector/model-selector.js +905 -0
- package/dist/components/native-select/native-select.d.ts +27 -0
- package/dist/components/native-select/native-select.js +226 -0
- package/dist/components/navigation-menu/navigation-menu.d.ts +29 -0
- package/dist/components/navigation-menu/navigation-menu.js +318 -0
- package/dist/components/not-label.js +9 -0
- package/dist/components/note-editor/blocks.d.ts +22 -0
- package/dist/components/note-editor/blocks.js +245 -0
- package/dist/components/note-editor/diff.d.ts +19 -0
- package/dist/components/note-editor/diff.js +64 -0
- package/dist/components/note-editor/editor.js +249 -0
- package/dist/components/note-editor/note-editor.d.ts +109 -0
- package/dist/components/note-editor/note-editor.js +954 -0
- package/dist/components/note-editor/parts/comments.d.ts +24 -0
- package/dist/components/note-editor/parts/comments.js +337 -0
- package/dist/components/note-editor/parts/header.d.ts +25 -0
- package/dist/components/note-editor/parts/header.js +263 -0
- package/dist/components/note-editor/parts/history.d.ts +56 -0
- package/dist/components/note-editor/parts/history.js +409 -0
- package/dist/components/note-editor/parts/presence.d.ts +31 -0
- package/dist/components/note-editor/parts/presence.js +140 -0
- package/dist/components/note-editor/parts/suggestions.d.ts +45 -0
- package/dist/components/note-editor/parts/suggestions.js +316 -0
- package/dist/components/note-editor/parts/toolbar.d.ts +38 -0
- package/dist/components/note-editor/parts/toolbar.js +687 -0
- package/dist/components/note-editor/people.d.ts +84 -0
- package/dist/components/note-editor/people.js +276 -0
- package/dist/components/note-editor/person.d.ts +11 -0
- package/dist/components/note-editor/person.js +15 -0
- package/dist/components/note-place/note-place.d.ts +42 -0
- package/dist/components/note-place/note-place.js +256 -0
- package/dist/components/note-status/note-status.d.ts +59 -0
- package/dist/components/note-status/note-status.js +380 -0
- package/dist/components/number-input/number-input.d.ts +12 -0
- package/dist/components/number-input/number-input.js +252 -0
- package/dist/components/otp-input/otp-input.d.ts +12 -0
- package/dist/components/otp-input/otp-input.js +136 -0
- package/dist/components/pagination/pagination.d.ts +23 -0
- package/dist/components/pagination/pagination.js +218 -0
- package/dist/components/password-input/password-input.d.ts +11 -0
- package/dist/components/password-input/password-input.js +117 -0
- package/dist/components/plan/plan.d.ts +51 -0
- package/dist/components/plan/plan.js +320 -0
- package/dist/components/popover/popover.d.ts +16 -0
- package/dist/components/popover/popover.js +268 -0
- package/dist/components/preferences/preferences.d.ts +5 -0
- package/dist/components/preferences/preferences.js +18 -0
- package/dist/components/progress/progress.d.ts +8 -0
- package/dist/components/progress/progress.js +162 -0
- package/dist/components/prompt-input/prompt-input.d.ts +247 -0
- package/dist/components/prompt-input/prompt-input.js +1367 -0
- package/dist/components/questionnaire/questionnaire.d.ts +174 -0
- package/dist/components/questionnaire/questionnaire.js +1628 -0
- package/dist/components/queue/queue.d.ts +82 -0
- package/dist/components/queue/queue.js +471 -0
- package/dist/components/radio/radio.d.ts +7 -0
- package/dist/components/radio/radio.js +101 -0
- package/dist/components/rating/rating.d.ts +10 -0
- package/dist/components/rating/rating.js +95 -0
- package/dist/components/reasoning/reasoning.d.ts +50 -0
- package/dist/components/reasoning/reasoning.js +233 -0
- package/dist/components/resizable/resizable.d.ts +6 -0
- package/dist/components/resizable/resizable.js +100 -0
- package/dist/components/scroll-area/scroll-area.d.ts +17 -0
- package/dist/components/scroll-area/scroll-area.js +211 -0
- package/dist/components/segmented-control/segmented-control.d.ts +16 -0
- package/dist/components/segmented-control/segmented-control.js +142 -0
- package/dist/components/select/select.d.ts +43 -0
- package/dist/components/select/select.js +577 -0
- package/dist/components/separator/separator.d.ts +4 -0
- package/dist/components/separator/separator.js +38 -0
- package/dist/components/sheet/sheet.d.ts +24 -0
- package/dist/components/sheet/sheet.js +330 -0
- package/dist/components/sidebar/sidebar.d.ts +138 -0
- package/dist/components/sidebar/sidebar.js +1374 -0
- package/dist/components/skeleton/skeleton.d.ts +4 -0
- package/dist/components/skeleton/skeleton.js +40 -0
- package/dist/components/slider/slider.d.ts +9 -0
- package/dist/components/slider/slider.js +193 -0
- package/dist/components/sources/sources.d.ts +35 -0
- package/dist/components/sources/sources.js +209 -0
- package/dist/components/spinner/spinner.d.ts +11 -0
- package/dist/components/spinner/spinner.js +59 -0
- package/dist/components/stack-trace/parse-stack-trace.d.ts +21 -0
- package/dist/components/stack-trace/parse-stack-trace.js +61 -0
- package/dist/components/stack-trace/stack-trace.d.ts +79 -0
- package/dist/components/stack-trace/stack-trace.js +434 -0
- package/dist/components/subagent/subagent.d.ts +71 -0
- package/dist/components/subagent/subagent.js +450 -0
- package/dist/components/suggestion/suggestion.d.ts +21 -0
- package/dist/components/suggestion/suggestion.js +130 -0
- package/dist/components/switch/switch.d.ts +6 -0
- package/dist/components/switch/switch.js +70 -0
- package/dist/components/table/table.d.ts +19 -0
- package/dist/components/table/table.js +284 -0
- package/dist/components/table-of-contents/spy.js +84 -0
- package/dist/components/table-of-contents/table-of-contents.d.ts +92 -0
- package/dist/components/table-of-contents/table-of-contents.js +787 -0
- package/dist/components/tabs/tabs.d.ts +25 -0
- package/dist/components/tabs/tabs.js +273 -0
- package/dist/components/task/task.d.ts +40 -0
- package/dist/components/task/task.js +262 -0
- package/dist/components/terminal/terminal.d.ts +82 -0
- package/dist/components/terminal/terminal.js +457 -0
- package/dist/components/test-results/test-results.d.ts +127 -0
- package/dist/components/test-results/test-results.js +687 -0
- package/dist/components/textarea/textarea.d.ts +8 -0
- package/dist/components/textarea/textarea.js +43 -0
- package/dist/components/time-input/time-input.d.ts +7 -0
- package/dist/components/time-input/time-input.js +82 -0
- package/dist/components/timeline/timeline.d.ts +19 -0
- package/dist/components/timeline/timeline.js +247 -0
- package/dist/components/toast/toast.d.ts +12 -0
- package/dist/components/toast/toast.js +285 -0
- package/dist/components/toggle/toggle.d.ts +15 -0
- package/dist/components/toggle/toggle.js +137 -0
- package/dist/components/token-input/token-input.d.ts +7 -0
- package/dist/components/token-input/token-input.js +117 -0
- package/dist/components/tool/tool.d.ts +66 -0
- package/dist/components/tool/tool.js +413 -0
- package/dist/components/toolbar/toolbar.d.ts +91 -0
- package/dist/components/toolbar/toolbar.js +655 -0
- package/dist/components/tooltip/tooltip.d.ts +8 -0
- package/dist/components/tooltip/tooltip.js +97 -0
- package/dist/components/trace/trace.d.ts +31 -0
- package/dist/components/trace/trace.js +309 -0
- package/dist/components/tree/tree.d.ts +13 -0
- package/dist/components/tree/tree.js +258 -0
- package/dist/components/trigger-menu/trigger-menu.d.ts +30 -0
- package/dist/components/trigger-menu/trigger-menu.js +352 -0
- package/dist/components/usage/usage.d.ts +132 -0
- package/dist/components/usage/usage.js +1368 -0
- package/dist/components/waterfall/waterfall.d.ts +20 -0
- package/dist/components/waterfall/waterfall.js +360 -0
- package/dist/components/week-strip/week-strip.d.ts +177 -0
- package/dist/components/week-strip/week-strip.js +1081 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.js +27 -0
- package/dist/core/ui-sdk.d.ts +3 -0
- package/dist/core/ui-sdk.js +3 -0
- package/dist/core/use-primitive-state.d.ts +14 -0
- package/dist/core/use-primitive-state.js +25 -0
- package/dist/styles/LICENSE-shadcn.md +21 -0
- package/dist/styles/color-scheme.css +32 -0
- package/dist/styles/components.css +303 -0
- package/dist/styles/index.css +41 -0
- package/dist/styles/tokens.css +474 -0
- package/dist/styles/typeset/shadcn.css +506 -0
- package/dist/styles/typeset.css +70 -0
- package/dist/styles/utilities.css +555 -0
- package/dist/tools/observe/index.d.ts +2 -0
- package/dist/tools/observe/index.js +3 -0
- package/dist/tools/observe/ui-sdk.d.ts +1 -0
- package/dist/tools/observe/ui-sdk.js +2 -0
- package/dist/tools/testing/check-agent.d.ts +28 -0
- package/dist/tools/testing/check-agent.js +42 -0
- package/dist/tools/testing/index.d.ts +4 -0
- package/dist/tools/testing/index.js +4 -0
- package/dist/tools/testing/ui-sdk.d.ts +1 -0
- package/dist/tools/testing/ui-sdk.js +2 -0
- package/dist/utilities/cn/index.d.ts +12 -0
- package/dist/utilities/cn/index.js +47 -0
- package/dist/utilities/color/index.d.ts +2 -0
- package/dist/utilities/color/index.js +3 -0
- package/dist/utilities/color/ui-sdk.d.ts +1 -0
- package/dist/utilities/color/ui-sdk.js +2 -0
- package/dist/utilities/date/index.d.ts +2 -0
- package/dist/utilities/date/index.js +6 -0
- package/dist/utilities/date/ui-sdk.d.ts +1 -0
- package/dist/utilities/date/ui-sdk.js +2 -0
- package/dist/utilities/image/index.d.ts +2 -0
- package/dist/utilities/image/index.js +3 -0
- package/dist/utilities/image/ui-sdk.d.ts +1 -0
- package/dist/utilities/image/ui-sdk.js +2 -0
- package/dist/utilities/mobile/index.d.ts +2 -0
- package/dist/utilities/mobile/index.js +1 -0
- package/dist/utilities/mobile/ui-sdk.d.ts +2 -0
- package/dist/utilities/mobile/ui-sdk.js +1 -0
- package/dist/utilities/number/index.d.ts +2 -0
- package/dist/utilities/number/index.js +3 -0
- package/dist/utilities/number/ui-sdk.d.ts +1 -0
- package/dist/utilities/number/ui-sdk.js +2 -0
- package/dist/utilities/platform/index.d.ts +3 -0
- package/dist/utilities/platform/index.js +14 -0
- package/dist/utilities/platform/ui-sdk.d.ts +3 -0
- package/dist/utilities/platform/ui-sdk.js +3 -0
- package/dist/utilities/storage/index.d.ts +2 -0
- package/dist/utilities/storage/index.js +1 -0
- package/dist/utilities/storage/ui-sdk.d.ts +2 -0
- package/dist/utilities/storage/ui-sdk.js +1 -0
- package/dist/utilities/text/index.d.ts +3 -0
- package/dist/utilities/text/index.js +3 -0
- package/dist/utilities/text/ui-sdk.d.ts +3 -0
- package/dist/utilities/text/ui-sdk.js +3 -0
- package/package.json +192 -4
- package/skills/agent-ready-ui/SKILL.md +229 -0
- package/skills/blocks/SKILL.md +262 -0
- package/skills/compose-screens/SKILL.md +354 -0
- package/skills/note-editor/SKILL.md +493 -0
- package/skills/note-status/SKILL.md +295 -0
- package/skills/setup/SKILL.md +136 -0
- package/skills/theming/SKILL.md +216 -0
- package/src/blocks/notes/adapters.ts +77 -0
- package/src/blocks/notes/data.ts +508 -0
- package/src/blocks/notes/notes-block.tsx +244 -0
- package/src/blocks/notes/parts/home.tsx +219 -0
- package/src/blocks/notes/parts/no-access.tsx +84 -0
- package/src/blocks/notes/parts/note-screen.tsx +412 -0
- package/src/blocks/notes/parts/notes-sidebar.tsx +277 -0
- package/src/blocks/notes/parts/panels.tsx +393 -0
- package/src/blocks/notes/parts/place.ts +15 -0
- package/src/blocks/notes/parts/review-dialog.tsx +159 -0
- package/src/blocks/notes/parts/share.tsx +172 -0
- package/src/blocks/notes/texts.ts +135 -0
- package/src/blocks/shell/adapters.ts +69 -0
- package/src/blocks/shell/data.ts +281 -0
- package/src/blocks/shell/parts/compose.tsx +292 -0
- package/src/blocks/shell/parts/home.tsx +203 -0
- package/src/blocks/shell/parts/marks.tsx +144 -0
- package/src/blocks/shell/parts/rail.tsx +166 -0
- package/src/blocks/shell/parts/rooms-column.tsx +326 -0
- package/src/blocks/shell/shell-block.tsx +210 -0
- package/src/blocks/shell/texts.ts +80 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { NoteBlock } from "abby/note-editor";
|
|
4
|
+
import { SidebarInset, SidebarProvider, SidebarTrigger } from "abby/sidebar";
|
|
5
|
+
import { useShortcut } from "abby/utilities/platform";
|
|
6
|
+
import { useRef, useState } from "react";
|
|
7
|
+
import type { NotesAdapter } from "./adapters.ts";
|
|
8
|
+
import { templates as defaultTemplates, type NotesNote, type NotesWorkspace } from "./data.ts";
|
|
9
|
+
import { Home } from "./parts/home.tsx";
|
|
10
|
+
import { NoAccess } from "./parts/no-access.tsx";
|
|
11
|
+
import { NoteScreen, type NotesPanel } from "./parts/note-screen.tsx";
|
|
12
|
+
import { NotesSidebar } from "./parts/notes-sidebar.tsx";
|
|
13
|
+
import { notesTexts, type NotesTexts } from "./texts.ts";
|
|
14
|
+
|
|
15
|
+
// The Notes block: a whole notes screen, from abby's public entries only, so
|
|
16
|
+
// this folder can be copied into an app as it is. The sidebar lists the notes
|
|
17
|
+
// by area; the page is home, a note, or a note the person can't open. The
|
|
18
|
+
// block keeps what's on screen and calls the adapter for everything that
|
|
19
|
+
// leaves it: saving, a review, a restored version, the assistant.
|
|
20
|
+
|
|
21
|
+
type NotesStart = {
|
|
22
|
+
/** The note on screen. Home without one. */
|
|
23
|
+
note?: string;
|
|
24
|
+
panel?: NotesPanel;
|
|
25
|
+
focus?: boolean;
|
|
26
|
+
/** A past version of the note, read-only, with the history beside it. */
|
|
27
|
+
version?: string;
|
|
28
|
+
/** Opens the share popover or the review dialog. */
|
|
29
|
+
open?: "share" | "review";
|
|
30
|
+
/** Starts as if the last save had failed. */
|
|
31
|
+
saveFailed?: boolean;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** The person's changes to one note, each with the app's value it replaced. */
|
|
35
|
+
type Changes = { [Key in keyof NotesNote]?: { base: unknown; value: unknown } };
|
|
36
|
+
|
|
37
|
+
/** The app's note with the person's changes over it, for the fields the app hasn't changed since. */
|
|
38
|
+
function mine(note: NotesNote, changes: Changes | undefined): NotesNote {
|
|
39
|
+
if (!changes) return note;
|
|
40
|
+
const kept = Object.entries(changes).filter(([key, change]) =>
|
|
41
|
+
Object.is(note[key as keyof NotesNote], change.base),
|
|
42
|
+
);
|
|
43
|
+
return kept.length
|
|
44
|
+
? { ...note, ...Object.fromEntries(kept.map(([key, change]) => [key, change.value])) }
|
|
45
|
+
: note;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type NotesBlockProps = {
|
|
49
|
+
workspace: NotesWorkspace;
|
|
50
|
+
adapter: NotesAdapter;
|
|
51
|
+
/** Replaces any of the block's texts, to translate it. */
|
|
52
|
+
texts?: Partial<NotesTexts>;
|
|
53
|
+
/** The templates a note can start with. */
|
|
54
|
+
templates?: typeof defaultTemplates;
|
|
55
|
+
/** Where each note lives, for its link. `#<id>` by default. */
|
|
56
|
+
href?: (id: string) => string;
|
|
57
|
+
/** What the block shows first. */
|
|
58
|
+
initial?: NotesStart;
|
|
59
|
+
/** The tree is still loading: the sidebar shows its shape. */
|
|
60
|
+
loading?: boolean;
|
|
61
|
+
/** The app lost its connection: the note says so and keeps working. */
|
|
62
|
+
offline?: boolean;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export function NotesBlock({
|
|
66
|
+
workspace,
|
|
67
|
+
adapter,
|
|
68
|
+
texts: own,
|
|
69
|
+
templates = defaultTemplates,
|
|
70
|
+
href = (id) => `#${id}`,
|
|
71
|
+
initial = {},
|
|
72
|
+
loading,
|
|
73
|
+
offline,
|
|
74
|
+
}: NotesBlockProps) {
|
|
75
|
+
const texts = { ...notesTexts, ...own };
|
|
76
|
+
// The notes are the app's: new data (the tree loaded, someone else's cursor)
|
|
77
|
+
// shows as it arrives. The block keeps what the person changed here, each
|
|
78
|
+
// field against the app's value it replaced: once the app sends a new value
|
|
79
|
+
// for that field (its save echoed, someone else's edit), the app's wins.
|
|
80
|
+
const [changed, setChanged] = useState<Record<string, Changes>>({});
|
|
81
|
+
const [created, setCreated] = useState<NotesNote[]>([]);
|
|
82
|
+
const theirs = [
|
|
83
|
+
...workspace.notes,
|
|
84
|
+
...created.filter((fresh) => !workspace.notes.some((each) => each.id === fresh.id)),
|
|
85
|
+
];
|
|
86
|
+
const notes = theirs.map((each) => mine(each, changed[each.id]));
|
|
87
|
+
const [current, setCurrent] = useState<string | null>(initial.note ?? null);
|
|
88
|
+
const [panel, setPanel] = useState<NotesPanel>(initial.panel ?? null);
|
|
89
|
+
const [focus, setFocus] = useState(initial.focus ?? false);
|
|
90
|
+
const [sidebar, setSidebar] = useState(!initial.focus);
|
|
91
|
+
const [version, setVersion] = useState(initial.version);
|
|
92
|
+
const [saveFailed, setSaveFailed] = useState(initial.saveFailed ?? false);
|
|
93
|
+
const [opening, setOpening] = useState(initial.open);
|
|
94
|
+
const title = useRef<HTMLInputElement>(null);
|
|
95
|
+
const note = notes.find((each) => each.id === current);
|
|
96
|
+
|
|
97
|
+
const update = (id: string, change: Partial<NotesNote>) =>
|
|
98
|
+
setChanged((all) => {
|
|
99
|
+
const base = theirs.find((each) => each.id === id);
|
|
100
|
+
const next: Changes = { ...all[id] };
|
|
101
|
+
for (const key of Object.keys(change) as (keyof NotesNote)[]) {
|
|
102
|
+
next[key] = { base: base?.[key], value: change[key] };
|
|
103
|
+
}
|
|
104
|
+
return { ...all, [id]: next };
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
/** Runs a save; a failure shows the bar with Retry, and the edit stays on screen. */
|
|
108
|
+
const save = (run: () => Promise<void>) => {
|
|
109
|
+
run().then(
|
|
110
|
+
() => setSaveFailed(false),
|
|
111
|
+
() => setSaveFailed(true),
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const open = (id: string | null) => {
|
|
116
|
+
setCurrent(id);
|
|
117
|
+
setVersion(undefined);
|
|
118
|
+
setOpening(undefined);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const startNote = () => {
|
|
122
|
+
open(null);
|
|
123
|
+
setFocus(false);
|
|
124
|
+
setSidebar(true);
|
|
125
|
+
// Home's title field is where a note starts.
|
|
126
|
+
requestAnimationFrame(() => title.current?.focus());
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const toggleFocus = () => {
|
|
130
|
+
setFocus(!focus);
|
|
131
|
+
setSidebar(focus);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
useShortcut("mod+shift+n", startNote, { description: texts.newNote });
|
|
135
|
+
useShortcut("mod+\\", toggleFocus, { description: texts.outline, when: () => Boolean(note) });
|
|
136
|
+
|
|
137
|
+
let page;
|
|
138
|
+
if (note?.locked) {
|
|
139
|
+
page = (
|
|
140
|
+
<>
|
|
141
|
+
<header className="flex h-12 shrink-0 items-center border-b border-border px-3">
|
|
142
|
+
<SidebarTrigger aria-label={texts.sidebar} />
|
|
143
|
+
</header>
|
|
144
|
+
<NoAccess
|
|
145
|
+
key={note.id}
|
|
146
|
+
note={note}
|
|
147
|
+
texts={texts}
|
|
148
|
+
onRequest={(message) => adapter.requestAccess(note.id, message)}
|
|
149
|
+
onBack={() => open(null)}
|
|
150
|
+
/>
|
|
151
|
+
</>
|
|
152
|
+
);
|
|
153
|
+
} else if (note) {
|
|
154
|
+
page = (
|
|
155
|
+
<NoteScreen
|
|
156
|
+
note={note}
|
|
157
|
+
workspace={workspace}
|
|
158
|
+
texts={texts}
|
|
159
|
+
templates={templates}
|
|
160
|
+
panel={panel}
|
|
161
|
+
focus={focus}
|
|
162
|
+
version={version}
|
|
163
|
+
offline={offline}
|
|
164
|
+
saveFailed={saveFailed}
|
|
165
|
+
open={opening}
|
|
166
|
+
onPanel={(next) => {
|
|
167
|
+
setPanel(next);
|
|
168
|
+
if (next !== "history") setVersion(undefined);
|
|
169
|
+
}}
|
|
170
|
+
onVersion={setVersion}
|
|
171
|
+
onBlocks={(blocks: NoteBlock[]) => {
|
|
172
|
+
update(note.id, { blocks });
|
|
173
|
+
save(() => adapter.saveBlocks(note.id, blocks));
|
|
174
|
+
}}
|
|
175
|
+
onTitle={(next) => {
|
|
176
|
+
update(note.id, { title: next });
|
|
177
|
+
save(() => adapter.saveTitle(note.id, next));
|
|
178
|
+
}}
|
|
179
|
+
onStatus={(status) => {
|
|
180
|
+
update(note.id, { status });
|
|
181
|
+
save(() => adapter.setStatus(note.id, status));
|
|
182
|
+
}}
|
|
183
|
+
onAccess={(access) => update(note.id, { access })}
|
|
184
|
+
onComments={(comments) => update(note.id, { comments })}
|
|
185
|
+
onSuggestions={(suggestions) => update(note.id, { suggestions })}
|
|
186
|
+
onReview={async (input) => {
|
|
187
|
+
await adapter.requestReview(note.id, input);
|
|
188
|
+
update(note.id, { status: "review" });
|
|
189
|
+
}}
|
|
190
|
+
onRestore={async (id) => {
|
|
191
|
+
const blocks = await adapter.restoreVersion(note.id, id);
|
|
192
|
+
update(note.id, { blocks });
|
|
193
|
+
setVersion(undefined);
|
|
194
|
+
}}
|
|
195
|
+
onRetry={() => save(() => adapter.saveBlocks(note.id, note.blocks as NoteBlock[]))}
|
|
196
|
+
onAsk={(question) => adapter.ask(note.id, question)}
|
|
197
|
+
/>
|
|
198
|
+
);
|
|
199
|
+
} else {
|
|
200
|
+
page = (
|
|
201
|
+
<>
|
|
202
|
+
<header className="flex h-12 shrink-0 items-center gap-2 border-b border-border px-3">
|
|
203
|
+
<SidebarTrigger aria-label={texts.sidebar} />
|
|
204
|
+
<h1 className="text-label">{texts.home}</h1>
|
|
205
|
+
</header>
|
|
206
|
+
<div className="min-h-0 flex-1 overflow-y-auto">
|
|
207
|
+
<Home
|
|
208
|
+
workspace={workspace}
|
|
209
|
+
notes={loading ? [] : notes}
|
|
210
|
+
loading={loading}
|
|
211
|
+
texts={texts}
|
|
212
|
+
templates={templates.map((each) => each.name)}
|
|
213
|
+
href={href}
|
|
214
|
+
titleRef={title}
|
|
215
|
+
onOpen={open}
|
|
216
|
+
onCreate={async (input) => {
|
|
217
|
+
const created = await adapter.createNote(input);
|
|
218
|
+
const template = templates.find((each) => each.name === input.template);
|
|
219
|
+
const fresh = template ? { ...created, blocks: template.blocks } : created;
|
|
220
|
+
setCreated((all) => [...all, fresh]);
|
|
221
|
+
open(fresh.id);
|
|
222
|
+
}}
|
|
223
|
+
/>
|
|
224
|
+
</div>
|
|
225
|
+
</>
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return (
|
|
230
|
+
<SidebarProvider open={sidebar} onOpenChange={setSidebar} className="h-dvh min-h-0">
|
|
231
|
+
<NotesSidebar
|
|
232
|
+
workspace={workspace}
|
|
233
|
+
notes={notes}
|
|
234
|
+
current={current}
|
|
235
|
+
loading={loading}
|
|
236
|
+
texts={texts}
|
|
237
|
+
href={href}
|
|
238
|
+
onOpen={open}
|
|
239
|
+
onNew={startNote}
|
|
240
|
+
/>
|
|
241
|
+
<SidebarInset className="min-h-0 overflow-hidden">{page}</SidebarInset>
|
|
242
|
+
</SidebarProvider>
|
|
243
|
+
);
|
|
244
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { SquareLock02Icon } from "@hugeicons/core-free-icons";
|
|
4
|
+
import { Button } from "abby/button";
|
|
5
|
+
import { Icon } from "abby/icon";
|
|
6
|
+
import { Input } from "abby/input";
|
|
7
|
+
import { Kbd } from "abby/kbd";
|
|
8
|
+
import { Link } from "abby/link";
|
|
9
|
+
import { NotePlaceSelect } from "abby/note-place";
|
|
10
|
+
import { NoteLiveDots, NoteStatusIcon } from "abby/note-status";
|
|
11
|
+
import { Toggle } from "abby/toggle";
|
|
12
|
+
import { useState, type Ref } from "react";
|
|
13
|
+
import type { NoteAccess, NotesNote, NotesWorkspace } from "../data.ts";
|
|
14
|
+
import type { NotesTexts } from "../texts.ts";
|
|
15
|
+
import { placeOf } from "./place.ts";
|
|
16
|
+
|
|
17
|
+
// Home: start a note by writing its title, then what waits for your review
|
|
18
|
+
// and what changed lately. No big button: writing the title is starting.
|
|
19
|
+
|
|
20
|
+
type HomeProps = {
|
|
21
|
+
workspace: NotesWorkspace;
|
|
22
|
+
notes: NotesNote[];
|
|
23
|
+
texts: NotesTexts;
|
|
24
|
+
templates: readonly string[];
|
|
25
|
+
href: (id: string) => string;
|
|
26
|
+
titleRef?: Ref<HTMLInputElement>;
|
|
27
|
+
/** The notes are still loading: no lists yet, and no first-day line either. */
|
|
28
|
+
loading?: boolean;
|
|
29
|
+
onCreate: (input: {
|
|
30
|
+
title: string;
|
|
31
|
+
place: string;
|
|
32
|
+
access: NoteAccess;
|
|
33
|
+
template?: string;
|
|
34
|
+
}) => void;
|
|
35
|
+
onOpen: (id: string) => void;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export function Home({
|
|
39
|
+
workspace,
|
|
40
|
+
notes,
|
|
41
|
+
texts,
|
|
42
|
+
templates,
|
|
43
|
+
href,
|
|
44
|
+
titleRef,
|
|
45
|
+
loading,
|
|
46
|
+
onCreate,
|
|
47
|
+
onOpen,
|
|
48
|
+
}: HomeProps) {
|
|
49
|
+
const [title, setTitle] = useState("");
|
|
50
|
+
const [place, setPlace] = useState(workspace.areas[0]?.value ?? "");
|
|
51
|
+
const [onlyMe, setOnlyMe] = useState(true);
|
|
52
|
+
const [template, setTemplate] = useState<string | undefined>();
|
|
53
|
+
const create = () => {
|
|
54
|
+
if (!title.trim()) return;
|
|
55
|
+
onCreate({ title: title.trim(), place, access: onlyMe ? "private" : "area", template });
|
|
56
|
+
};
|
|
57
|
+
const review = notes.filter((note) => note.reviewBy && note.status === "review");
|
|
58
|
+
const recent = notes.filter((note) => !note.reviewBy && !note.locked).slice(0, 5);
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<div className="mx-auto flex w-full max-w-[40rem] flex-col gap-14 px-6 py-16">
|
|
62
|
+
<form
|
|
63
|
+
className="flex flex-col gap-4"
|
|
64
|
+
onSubmit={(event) => {
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
create();
|
|
67
|
+
}}
|
|
68
|
+
>
|
|
69
|
+
<p className="text-sm text-subtle">{workspace.today}</p>
|
|
70
|
+
<Input
|
|
71
|
+
ref={titleRef}
|
|
72
|
+
aria-label={texts.newTitle}
|
|
73
|
+
placeholder={texts.newTitlePlaceholder}
|
|
74
|
+
value={title}
|
|
75
|
+
onValueChange={setTitle}
|
|
76
|
+
// The form has other controls and no submit button, so Enter wouldn't submit it.
|
|
77
|
+
onKeyDown={(event) => {
|
|
78
|
+
if (event.key !== "Enter" || event.nativeEvent.isComposing) return;
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
create();
|
|
81
|
+
}}
|
|
82
|
+
// The title is the field: no edge, the size of a title.
|
|
83
|
+
className="h-auto rounded-none border-0 bg-transparent px-0 py-0 text-display-3 shadow-none focus-visible:shadow-none md:text-display-3 dark:bg-transparent"
|
|
84
|
+
/>
|
|
85
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
86
|
+
<NotePlaceSelect
|
|
87
|
+
areas={workspace.areas}
|
|
88
|
+
value={place}
|
|
89
|
+
onValueChange={(value) => value && setPlace(value)}
|
|
90
|
+
/>
|
|
91
|
+
<Toggle variant="outline" size="sm" pressed={onlyMe} onPressedChange={setOnlyMe}>
|
|
92
|
+
<Icon icon={SquareLock02Icon} />
|
|
93
|
+
{texts.onlyMe}
|
|
94
|
+
</Toggle>
|
|
95
|
+
<span aria-hidden="true" className="mx-1 h-4 w-px bg-border" />
|
|
96
|
+
<div role="group" aria-label={texts.startWith} className="flex items-center gap-1">
|
|
97
|
+
<span aria-hidden="true" className="me-1 text-sm text-subtle">
|
|
98
|
+
{texts.startWith}
|
|
99
|
+
</span>
|
|
100
|
+
{templates.map((name) => (
|
|
101
|
+
<Toggle
|
|
102
|
+
key={name}
|
|
103
|
+
size="sm"
|
|
104
|
+
pressed={template === name}
|
|
105
|
+
onPressedChange={(pressed) => setTemplate(pressed ? name : undefined)}
|
|
106
|
+
>
|
|
107
|
+
{name}
|
|
108
|
+
</Toggle>
|
|
109
|
+
))}
|
|
110
|
+
</div>
|
|
111
|
+
<span
|
|
112
|
+
aria-hidden="true"
|
|
113
|
+
className="ms-auto flex items-center gap-1.5 text-sm text-subtle"
|
|
114
|
+
>
|
|
115
|
+
<Kbd>↵</Kbd>
|
|
116
|
+
{texts.create}
|
|
117
|
+
</span>
|
|
118
|
+
</div>
|
|
119
|
+
</form>
|
|
120
|
+
|
|
121
|
+
{!loading && notes.length === 0 && (
|
|
122
|
+
<p className="text-sm text-muted-foreground">{texts.firstDay}</p>
|
|
123
|
+
)}
|
|
124
|
+
|
|
125
|
+
{review.length > 0 && (
|
|
126
|
+
<section aria-labelledby="notes-home-review" className="flex flex-col gap-3">
|
|
127
|
+
<h2 id="notes-home-review" className="flex items-center gap-2 text-label">
|
|
128
|
+
{texts.toReviewHeading}
|
|
129
|
+
<span className="font-normal text-subtle">{review.length}</span>
|
|
130
|
+
</h2>
|
|
131
|
+
<ul className="flex flex-col">
|
|
132
|
+
{review.map((note) => {
|
|
133
|
+
const { area } = placeOf(workspace, note.place);
|
|
134
|
+
return (
|
|
135
|
+
<li key={note.id} className="flex items-center gap-3 py-2">
|
|
136
|
+
<div className="min-w-0 flex-1">
|
|
137
|
+
<p className="truncate text-label">{note.title}</p>
|
|
138
|
+
<p className="flex items-center gap-1.5 text-sm text-muted-foreground">
|
|
139
|
+
<span
|
|
140
|
+
aria-hidden="true"
|
|
141
|
+
className={`size-2 rounded-2xs ${area?.mark ?? ""}`}
|
|
142
|
+
/>
|
|
143
|
+
{area?.label} · {note.summary} · {note.updated}
|
|
144
|
+
</p>
|
|
145
|
+
</div>
|
|
146
|
+
<Button
|
|
147
|
+
variant="outline"
|
|
148
|
+
size="sm"
|
|
149
|
+
aria-label={texts.review(note.title)}
|
|
150
|
+
onClick={() => onOpen(note.id)}
|
|
151
|
+
>
|
|
152
|
+
{texts.reviewShort}
|
|
153
|
+
</Button>
|
|
154
|
+
</li>
|
|
155
|
+
);
|
|
156
|
+
})}
|
|
157
|
+
</ul>
|
|
158
|
+
</section>
|
|
159
|
+
)}
|
|
160
|
+
|
|
161
|
+
{recent.length > 0 && (
|
|
162
|
+
<section aria-labelledby="notes-home-recent" className="flex flex-col gap-3">
|
|
163
|
+
<div className="flex items-center">
|
|
164
|
+
<h2 id="notes-home-recent" className="flex-1 text-label">
|
|
165
|
+
{texts.recent}
|
|
166
|
+
</h2>
|
|
167
|
+
<Link href={href("all")} className="text-sm">
|
|
168
|
+
{texts.seeAll}
|
|
169
|
+
</Link>
|
|
170
|
+
</div>
|
|
171
|
+
<ul className="flex flex-col">
|
|
172
|
+
{recent.map((note) => {
|
|
173
|
+
const { area } = placeOf(workspace, note.place);
|
|
174
|
+
return (
|
|
175
|
+
<li key={note.id} className="flex items-center gap-3 py-2">
|
|
176
|
+
<div className="min-w-0 flex-1">
|
|
177
|
+
<Link
|
|
178
|
+
href={href(note.id)}
|
|
179
|
+
onClick={(event) => {
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
onOpen(note.id);
|
|
182
|
+
}}
|
|
183
|
+
className="block truncate text-label text-foreground no-underline hover:underline"
|
|
184
|
+
>
|
|
185
|
+
{note.title}
|
|
186
|
+
</Link>
|
|
187
|
+
<p className="flex items-center gap-1.5 text-sm text-muted-foreground">
|
|
188
|
+
<span
|
|
189
|
+
aria-hidden="true"
|
|
190
|
+
className={`size-2 rounded-2xs ${area?.mark ?? ""}`}
|
|
191
|
+
/>
|
|
192
|
+
{area?.label}
|
|
193
|
+
{note.summary && (
|
|
194
|
+
<>
|
|
195
|
+
<span aria-hidden="true" className="text-subtle">
|
|
196
|
+
·
|
|
197
|
+
</span>
|
|
198
|
+
{note.writing && <NoteLiveDots people={note.writing} />}
|
|
199
|
+
{note.summary}
|
|
200
|
+
</>
|
|
201
|
+
)}
|
|
202
|
+
</p>
|
|
203
|
+
</div>
|
|
204
|
+
<NoteStatusIcon
|
|
205
|
+
status={note.status}
|
|
206
|
+
label={texts[note.status === "review" ? "inReview" : note.status]}
|
|
207
|
+
/>
|
|
208
|
+
<span className="w-20 shrink-0 text-end font-mono text-xs whitespace-nowrap text-subtle">
|
|
209
|
+
{note.updated}
|
|
210
|
+
</span>
|
|
211
|
+
</li>
|
|
212
|
+
);
|
|
213
|
+
})}
|
|
214
|
+
</ul>
|
|
215
|
+
</section>
|
|
216
|
+
)}
|
|
217
|
+
</div>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { CheckmarkCircle02Icon, SquareLock02Icon } from "@hugeicons/core-free-icons";
|
|
4
|
+
import { Button } from "abby/button";
|
|
5
|
+
import {
|
|
6
|
+
Empty,
|
|
7
|
+
EmptyContent,
|
|
8
|
+
EmptyDescription,
|
|
9
|
+
EmptyHeader,
|
|
10
|
+
EmptyMedia,
|
|
11
|
+
EmptyTitle,
|
|
12
|
+
} from "abby/empty";
|
|
13
|
+
import { Icon } from "abby/icon";
|
|
14
|
+
import { Textarea } from "abby/textarea";
|
|
15
|
+
import { useState } from "react";
|
|
16
|
+
import type { NotesNote } from "../data.ts";
|
|
17
|
+
import type { NotesTexts } from "../texts.ts";
|
|
18
|
+
|
|
19
|
+
// A link to a note the person can't open. It shows neither its title nor its
|
|
20
|
+
// text: only its area, who decides, and a way to ask.
|
|
21
|
+
|
|
22
|
+
type NoAccessProps = {
|
|
23
|
+
note: NotesNote;
|
|
24
|
+
texts: NotesTexts;
|
|
25
|
+
onRequest: (message: string) => Promise<void>;
|
|
26
|
+
onBack: () => void;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export function NoAccess({ note, texts, onRequest, onBack }: NoAccessProps) {
|
|
30
|
+
const [message, setMessage] = useState("");
|
|
31
|
+
const [requested, setRequested] = useState(false);
|
|
32
|
+
const locked = note.locked ?? { owner: "", area: "" };
|
|
33
|
+
const owner = locked.owner.split(" ")[0] ?? locked.owner;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Empty className="m-auto max-w-md">
|
|
37
|
+
<EmptyHeader>
|
|
38
|
+
<EmptyMedia variant="icon">
|
|
39
|
+
<Icon icon={SquareLock02Icon} />
|
|
40
|
+
</EmptyMedia>
|
|
41
|
+
<EmptyTitle>{texts.noAccess}</EmptyTitle>
|
|
42
|
+
<EmptyDescription>{texts.noAccessDetail(locked.area, locked.owner)}</EmptyDescription>
|
|
43
|
+
</EmptyHeader>
|
|
44
|
+
<EmptyContent className="w-full items-stretch">
|
|
45
|
+
{requested ? (
|
|
46
|
+
<p
|
|
47
|
+
role="status"
|
|
48
|
+
className="flex items-center justify-center gap-2 text-sm text-muted-foreground"
|
|
49
|
+
>
|
|
50
|
+
<Icon icon={CheckmarkCircle02Icon} className="size-4 text-success" />
|
|
51
|
+
{texts.requested(owner)}
|
|
52
|
+
</p>
|
|
53
|
+
) : (
|
|
54
|
+
<>
|
|
55
|
+
<div className="flex flex-col gap-1.5 text-start">
|
|
56
|
+
<Textarea
|
|
57
|
+
aria-label={texts.accessMessage(owner)}
|
|
58
|
+
placeholder={texts.accessMessage(owner)}
|
|
59
|
+
value={message}
|
|
60
|
+
onValueChange={setMessage}
|
|
61
|
+
rows={2}
|
|
62
|
+
/>
|
|
63
|
+
<p className="text-xs text-subtle">{texts.accessHint(owner)}</p>
|
|
64
|
+
</div>
|
|
65
|
+
<div className="flex gap-2">
|
|
66
|
+
<Button
|
|
67
|
+
size="sm"
|
|
68
|
+
onClick={async () => {
|
|
69
|
+
await onRequest(message);
|
|
70
|
+
setRequested(true);
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
{texts.requestAccess}
|
|
74
|
+
</Button>
|
|
75
|
+
<Button variant="outline" size="sm" onClick={onBack}>
|
|
76
|
+
{texts.backToNotes}
|
|
77
|
+
</Button>
|
|
78
|
+
</div>
|
|
79
|
+
</>
|
|
80
|
+
)}
|
|
81
|
+
</EmptyContent>
|
|
82
|
+
</Empty>
|
|
83
|
+
);
|
|
84
|
+
}
|