@oyolincc/create 0.3.0 → 0.5.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/package.json +2 -2
- package/templates/hono-fullstack/.codegraph/.gitignore +5 -0
- package/templates/hono-fullstack/README.md +22 -1
- package/templates/hono-fullstack/_gitignore +1 -0
- package/templates/hono-fullstack/apps/server/package.json +7 -2
- package/templates/hono-fullstack/apps/server/src/adapters/cloudflare/entry.ts +4 -30
- package/templates/hono-fullstack/apps/server/src/adapters/nodejs/bootstrap.ts +20 -12
- package/templates/hono-fullstack/apps/server/src/adapters/nodejs/entry.ts +7 -57
- package/templates/hono-fullstack/apps/server/src/app.ts +37 -21
- package/templates/hono-fullstack/apps/server/src/config.ts +1 -1
- package/templates/hono-fullstack/apps/server/src/di-container.ts +51 -0
- package/templates/hono-fullstack/apps/server/src/infra/logger/getter.ts +1 -1
- package/templates/hono-fullstack/apps/server/src/infra/logger/pino.ts +21 -34
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/errors.ts +22 -0
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/pass-through/runner.ts +28 -22
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/piscina/runner.ts +11 -34
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/{example → piscina}/worker-entry.ts +6 -2
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/types.ts +2 -16
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/utils/business-error.ts +10 -5
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/utils/message.ts +5 -17
- package/templates/hono-fullstack/apps/server/src/middlewares/cors.ts +16 -22
- package/templates/hono-fullstack/apps/server/src/middlewares/logger.ts +34 -0
- package/templates/hono-fullstack/apps/server/src/modules/example/module.ts +8 -0
- package/templates/hono-fullstack/apps/server/src/modules/example/queries.ts +8 -0
- package/templates/hono-fullstack/apps/server/src/modules/example/routes.ts +74 -68
- package/templates/hono-fullstack/apps/server/src/modules/example/service.test.ts +53 -0
- package/templates/hono-fullstack/apps/server/src/modules/example/service.ts +54 -0
- package/templates/hono-fullstack/apps/server/src/modules/example/types.ts +12 -0
- package/templates/hono-fullstack/apps/server/src/modules/example/work-task/tasks.test.ts +9 -35
- package/templates/hono-fullstack/apps/server/src/modules/example/work-task/tasks.ts +15 -46
- package/templates/hono-fullstack/apps/server/src/shared/errors/defs/index.ts +6 -1
- package/templates/hono-fullstack/apps/server/src/shared/errors/handler.ts +1 -1
- package/templates/hono-fullstack/apps/server/src/shared/network/openapi/index.ts +1 -1
- package/templates/hono-fullstack/apps/server/src/shared/types/app.ts +51 -0
- package/templates/hono-fullstack/apps/server/src/shared/types/db.ts +126 -0
- package/templates/hono-fullstack/apps/server/src/shared/utils/data-access/check.ts +19 -0
- package/templates/hono-fullstack/apps/server/src/shared/utils/data-access/model.ts +47 -0
- package/templates/hono-fullstack/apps/server/src/shared/utils/data-access/params.ts +105 -0
- package/templates/hono-fullstack/apps/server/src/shared/utils/data-access/query.test.ts +139 -0
- package/templates/hono-fullstack/apps/server/src/shared/utils/data-access/query.ts +236 -0
- package/templates/hono-fullstack/apps/server/vite.config.ts +2 -2
- package/templates/hono-fullstack/apps/server/wrangler.jsonc +1 -1
- package/templates/hono-fullstack/apps/stack/frontend/assets/styles.css +6 -0
- package/templates/hono-fullstack/apps/stack/frontend/components/general/ErrorMessage.tsx +3 -1
- package/templates/hono-fullstack/apps/stack/frontend/components/layouts/AppLayout.tsx +2 -1
- package/templates/hono-fullstack/apps/stack/frontend/components/layouts/Header.tsx +14 -2
- package/templates/hono-fullstack/apps/stack/frontend/components/layouts/Page.tsx +2 -1
- package/templates/hono-fullstack/apps/stack/frontend/components/layouts/PageContainer.tsx +4 -1
- package/templates/hono-fullstack/apps/stack/frontend/modules/example/api.ts +16 -9
- package/templates/hono-fullstack/apps/stack/frontend/modules/example/components/ExampleForm.tsx +25 -12
- package/templates/hono-fullstack/apps/stack/frontend/modules/example/components/ExampleList.tsx +13 -4
- package/templates/hono-fullstack/apps/stack/frontend/modules/example/hooks/api-hooks.ts +21 -8
- package/templates/hono-fullstack/apps/stack/frontend/routes/__root.tsx +1 -1
- package/templates/hono-fullstack/apps/stack/frontend/routes/index.tsx +35 -12
- package/templates/hono-fullstack/apps/stack/frontend/shared/network/query-hooks.ts +33 -0
- package/templates/hono-fullstack/apps/stack/package.json +9 -4
- package/templates/hono-fullstack/apps/stack/panda.config.ts +31 -0
- package/templates/hono-fullstack/apps/stack/tsconfig.json +1 -0
- package/templates/hono-fullstack/apps/stack/turbo.json +20 -0
- package/templates/hono-fullstack/apps/stack/vite.config.ts +48 -12
- package/templates/hono-fullstack/apps/stack/wrangler.jsonc +1 -1
- package/templates/hono-fullstack/envs/.env.example.sqlite-d1 +1 -0
- package/templates/hono-fullstack/libs/db/drizzle-kit/sqlite-d1.config.ts +29 -10
- package/templates/hono-fullstack/libs/db/package.json +1 -0
- package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/columns.ts +1 -1
- package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/modules/examples/examples.ts +6 -3
- package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/vo.ts +7 -1
- package/templates/hono-fullstack/libs/definition/README.md +81 -0
- package/templates/hono-fullstack/libs/definition/package.json +3 -1
- package/templates/hono-fullstack/libs/definition/src/constants/index.ts +1 -0
- package/templates/hono-fullstack/libs/definition/src/constants/pagination.ts +3 -0
- package/templates/hono-fullstack/libs/definition/src/modules/common-contracts.ts +24 -0
- package/templates/hono-fullstack/libs/definition/src/modules/example/contracts.ts +34 -0
- package/templates/hono-fullstack/libs/definition/src/modules/example/index.ts +1 -16
- package/templates/hono-fullstack/libs/definition/src/modules/index.ts +2 -0
- package/templates/hono-fullstack/libs/definition/src/modules/vo-generated-types.ts +12 -0
- package/templates/hono-fullstack/libs/ui/.storybook/main.ts +32 -0
- package/templates/hono-fullstack/libs/ui/.storybook/panda.config.ts +22 -0
- package/templates/hono-fullstack/libs/ui/.storybook/preview.tsx +79 -0
- package/templates/hono-fullstack/libs/ui/.storybook/styles.css +1 -0
- package/templates/hono-fullstack/libs/ui/.storybook/vite.config.ts +37 -0
- package/templates/hono-fullstack/libs/ui/components.json +15 -0
- package/templates/hono-fullstack/libs/ui/package.json +114 -0
- package/templates/hono-fullstack/libs/ui/panda.config.ts +41 -0
- package/templates/hono-fullstack/libs/ui/src/Tooltip.tsx +47 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/buttons/Button.tsx +80 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/buttons/CloseButton.tsx +15 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/buttons/IconButton.tsx +10 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/collections/Combobox.tsx +91 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/collections/Select.tsx +88 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/collections/TreeView.tsx +142 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/data-display/Avatar.tsx +64 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/data-display/Badge.tsx +7 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/data-display/Card.tsx +23 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/data-display/Clipboard.tsx +77 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/data-display/Icon.tsx +9 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/data-display/Table.tsx +51 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/data-display/Tag.tsx +23 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/data-display/Timeline.tsx +33 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/date-and-time/DatePicker.tsx +255 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/disclosure/Accordion.tsx +48 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/disclosure/Breadcrumb.tsx +50 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/disclosure/Collapsible.tsx +34 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/disclosure/Pagination.tsx +74 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/disclosure/Steps.tsx +91 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/disclosure/Tabs.tsx +37 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/feedback/Alert.tsx +52 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/feedback/Progress.tsx +41 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/feedback/ProgressCircle.tsx +40 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/feedback/Skeleton.tsx +37 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/feedback/Spinner.tsx +7 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/feedback/Toast.tsx +99 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/Checkbox.tsx +95 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/ColorPicker.tsx +148 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/Editable.tsx +44 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/Field.tsx +36 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/Fieldset.tsx +34 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/FileUpload.tsx +143 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/Input.tsx +7 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/InputAddon.tsx +7 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/InputGroup.tsx +61 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/NativeSelect.tsx +81 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/NumberInput.tsx +63 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/PasswordInput.tsx +76 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/PinInput.tsx +36 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/RadioCard.tsx +96 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/RadioGroup.tsx +61 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/RatingGroup.tsx +106 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/SegmentGroup.tsx +68 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/Slider.tsx +87 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/Switch.tsx +74 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/TagsInput.tsx +77 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/Textarea.tsx +7 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/index.ts +98 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/internal/AbsoluteCenter.tsx +7 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/internal/Loader.tsx +69 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/internal/Span.tsx +5 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/internal/create-layout.ts +18 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/layout/Float.tsx +7 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/layout/Grid.tsx +17 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/layout/Group.tsx +7 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/layout/ScrollArea.tsx +46 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/layout/Separator.tsx +26 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/layout/Stack.tsx +54 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/overlays/Dialog.tsx +69 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/overlays/Drawer.tsx +49 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/overlays/HoverCard.tsx +37 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/overlays/Menu.tsx +74 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/overlays/OverlayManager.test.ts +124 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/overlays/OverlayManager.tsx +189 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/overlays/Popover.tsx +57 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/overlays/Tooltip.tsx +37 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/typography/Heading.tsx +6 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/typography/Link.tsx +7 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/typography/LinkOverlay.tsx +21 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/typography/Text.tsx +6 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/utilities/VisuallyHidden.tsx +13 -0
- package/templates/hono-fullstack/libs/ui/src/hooks.ts +242 -0
- package/templates/hono-fullstack/libs/ui/src/index.ts +19 -0
- package/templates/hono-fullstack/libs/ui/src/theme/animation-styles.ts +50 -0
- package/templates/hono-fullstack/libs/ui/src/theme/breakpoints.ts +7 -0
- package/templates/hono-fullstack/libs/ui/src/theme/conditions.ts +12 -0
- package/templates/hono-fullstack/libs/ui/src/theme/containers.ts +16 -0
- package/templates/hono-fullstack/libs/ui/src/theme/global-css.ts +12 -0
- package/templates/hono-fullstack/libs/ui/src/theme/keyframes.ts +157 -0
- package/templates/hono-fullstack/libs/ui/src/theme/layer-styles.ts +11 -0
- package/templates/hono-fullstack/libs/ui/src/theme/patterns/grid.ts +51 -0
- package/templates/hono-fullstack/libs/ui/src/theme/patterns/index.ts +60 -0
- package/templates/hono-fullstack/libs/ui/src/theme/patterns/stack.ts +46 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/absolute-center.ts +38 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/accordion.ts +68 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/alert.ts +83 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/avatar.ts +155 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/badge.ts +67 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/breadcrumb.ts +69 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/button.ts +149 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/card.ts +36 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/checkbox.ts +120 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/clipboard.ts +22 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/collapsible.ts +26 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/color-picker.ts +299 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/combobox.ts +141 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/date-picker.ts +302 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/dialog.ts +191 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/drawer.ts +170 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/editable.ts +64 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/field.ts +41 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/fieldset.ts +47 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/file-upload.ts +86 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/group.ts +78 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/heading.ts +24 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/hover-card.ts +47 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/icon.ts +25 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/index.ts +120 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/input-addon.ts +51 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/input-group.ts +77 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/input.ts +99 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/link.ts +36 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/menu.ts +114 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/native-select.ts +92 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/number-input.ts +91 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/pagination.ts +9 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/pin-input.ts +33 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/popover.ts +78 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/progress-circle.ts +50 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/progress.ts +112 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/radio-card.ts +223 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/radio-group.ts +78 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/rating-group.ts +98 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/scroll-area.ts +119 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/segment-group.ts +162 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/select.ts +157 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/separator.ts +25 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/skeleton.ts +65 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/slider.ts +164 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/spinner.ts +34 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/steps.ts +162 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/switch.ts +150 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/table.ts +150 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/tabs.ts +128 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/tag.ts +114 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/tags-input.ts +201 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/text.ts +7 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/textarea.ts +90 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/timeline.ts +137 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/toast.ts +52 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/tooltip.ts +44 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/tree-view.ts +200 -0
- package/templates/hono-fullstack/libs/ui/src/theme/semanticTokens/colors/amber.ts +91 -0
- package/templates/hono-fullstack/libs/ui/src/theme/semanticTokens/colors/gray.ts +103 -0
- package/templates/hono-fullstack/libs/ui/src/theme/semanticTokens/colors/green.ts +88 -0
- package/templates/hono-fullstack/libs/ui/src/theme/semanticTokens/colors/index.ts +14 -0
- package/templates/hono-fullstack/libs/ui/src/theme/semanticTokens/colors/lime.ts +91 -0
- package/templates/hono-fullstack/libs/ui/src/theme/semanticTokens/colors/red.ts +88 -0
- package/templates/hono-fullstack/libs/ui/src/theme/semanticTokens/index.ts +8 -0
- package/templates/hono-fullstack/libs/ui/src/theme/semanticTokens/shadows.ts +46 -0
- package/templates/hono-fullstack/libs/ui/src/theme/text-styles.ts +82 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/animations.ts +8 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/aspect-ratio.ts +6 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/borders.ts +5 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/colors.ts +35 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/durations.ts +11 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/easings.ts +9 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/index.ts +42 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/radii.ts +13 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/sizes.ts +27 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/spacing.ts +41 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/typography.ts +86 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/z-index.ts +43 -0
- package/templates/hono-fullstack/libs/ui/stories/README.md +107 -0
- package/templates/hono-fullstack/libs/ui/stories/actions/Button.stories.tsx +260 -0
- package/templates/hono-fullstack/libs/ui/stories/actions/Clipboard.stories.tsx +87 -0
- package/templates/hono-fullstack/libs/ui/stories/actions/IconButton.stories.tsx +33 -0
- package/templates/hono-fullstack/libs/ui/stories/collections/Combobox.stories.tsx +334 -0
- package/templates/hono-fullstack/libs/ui/stories/collections/Select.stories.tsx +342 -0
- package/templates/hono-fullstack/libs/ui/stories/collections/TreeView.stories.tsx +252 -0
- package/templates/hono-fullstack/libs/ui/stories/color/ColorPicker.stories.tsx +217 -0
- package/templates/hono-fullstack/libs/ui/stories/date/DatePicker.stories.tsx +302 -0
- package/templates/hono-fullstack/libs/ui/stories/disclosure/Accordion.stories.tsx +105 -0
- package/templates/hono-fullstack/libs/ui/stories/disclosure/Collapsible.stories.tsx +55 -0
- package/templates/hono-fullstack/libs/ui/stories/disclosure/Steps.stories.tsx +208 -0
- package/templates/hono-fullstack/libs/ui/stories/disclosure/Tabs.stories.tsx +176 -0
- package/templates/hono-fullstack/libs/ui/stories/display/Avatar.stories.tsx +108 -0
- package/templates/hono-fullstack/libs/ui/stories/display/Badge.stories.tsx +90 -0
- package/templates/hono-fullstack/libs/ui/stories/display/Card.stories.tsx +121 -0
- package/templates/hono-fullstack/libs/ui/stories/display/Heading.stories.tsx +62 -0
- package/templates/hono-fullstack/libs/ui/stories/display/Icon.stories.tsx +51 -0
- package/templates/hono-fullstack/libs/ui/stories/display/Table.stories.tsx +222 -0
- package/templates/hono-fullstack/libs/ui/stories/display/Tag.stories.tsx +168 -0
- package/templates/hono-fullstack/libs/ui/stories/display/Text.stories.tsx +32 -0
- package/templates/hono-fullstack/libs/ui/stories/display/Timeline.stories.tsx +241 -0
- package/templates/hono-fullstack/libs/ui/stories/feedback/Alert.stories.tsx +122 -0
- package/templates/hono-fullstack/libs/ui/stories/feedback/Progress.stories.tsx +163 -0
- package/templates/hono-fullstack/libs/ui/stories/feedback/ProgressCircle.stories.tsx +176 -0
- package/templates/hono-fullstack/libs/ui/stories/feedback/Skeleton.stories.tsx +75 -0
- package/templates/hono-fullstack/libs/ui/stories/feedback/Spinner.stories.tsx +49 -0
- package/templates/hono-fullstack/libs/ui/stories/feedback/Toast.stories.tsx +145 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/Checkbox.stories.tsx +281 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/Editable.stories.tsx +94 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/Field.stories.tsx +72 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/Fieldset.stories.tsx +109 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/FileUpload.stories.tsx +115 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/Form.stories.tsx +120 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/Input.stories.tsx +155 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/InputGroup.stories.tsx +79 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/NativeSelect.stories.tsx +160 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/NumberInput.stories.tsx +149 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/PasswordInput.stories.tsx +141 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/PinInput.stories.tsx +155 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/RadioCard.stories.tsx +265 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/RadioGroup.stories.tsx +109 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/RatingGroup.stories.tsx +123 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/SegmentGroup.stories.tsx +130 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/Slider.stories.tsx +190 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/Switch.stories.tsx +124 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/TagsInput.stories.tsx +154 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/Textarea.stories.tsx +148 -0
- package/templates/hono-fullstack/libs/ui/stories/layout/Grid.stories.tsx +60 -0
- package/templates/hono-fullstack/libs/ui/stories/layout/Positioning.stories.tsx +90 -0
- package/templates/hono-fullstack/libs/ui/stories/layout/ScrollArea.stories.tsx +68 -0
- package/templates/hono-fullstack/libs/ui/stories/layout/Stack.stories.tsx +87 -0
- package/templates/hono-fullstack/libs/ui/stories/navigation/Breadcrumb.stories.tsx +104 -0
- package/templates/hono-fullstack/libs/ui/stories/navigation/Link.stories.tsx +62 -0
- package/templates/hono-fullstack/libs/ui/stories/navigation/LinkBox.stories.tsx +45 -0
- package/templates/hono-fullstack/libs/ui/stories/navigation/Pagination.stories.tsx +74 -0
- package/templates/hono-fullstack/libs/ui/stories/overlays/Dialog.stories.tsx +255 -0
- package/templates/hono-fullstack/libs/ui/stories/overlays/Drawer.stories.tsx +114 -0
- package/templates/hono-fullstack/libs/ui/stories/overlays/HoverCard.stories.tsx +47 -0
- package/templates/hono-fullstack/libs/ui/stories/overlays/Menu.stories.tsx +133 -0
- package/templates/hono-fullstack/libs/ui/stories/overlays/OverlayManager.stories.tsx +206 -0
- package/templates/hono-fullstack/libs/ui/stories/overlays/Popover.stories.tsx +73 -0
- package/templates/hono-fullstack/libs/ui/stories/overlays/Tooltip.stories.tsx +114 -0
- package/templates/hono-fullstack/libs/ui/stories/tsconfig.json +14 -0
- package/templates/hono-fullstack/libs/ui/tsconfig.build.json +5 -0
- package/templates/hono-fullstack/libs/ui/tsconfig.json +13 -0
- package/templates/hono-fullstack/libs/ui/turbo.json +28 -0
- package/templates/hono-fullstack/libs/ui/vite.config.ts +33 -0
- package/templates/hono-fullstack/oyo.config.json +31 -1
- package/templates/hono-fullstack/package.json +1 -0
- package/templates/hono-fullstack/pnpm-workspace.yaml +20 -10
- package/templates/hono-fullstack/turbo.json +10 -0
- package/templates/hono-server/.codegraph/.gitignore +5 -0
- package/templates/hono-server/README.md +9 -1
- package/templates/hono-server/_gitignore +1 -0
- package/templates/hono-server/apps/server/package.json +7 -2
- package/templates/hono-server/apps/server/src/adapters/cloudflare/entry.ts +4 -30
- package/templates/hono-server/apps/server/src/adapters/nodejs/bootstrap.ts +20 -12
- package/templates/hono-server/apps/server/src/adapters/nodejs/entry.ts +7 -57
- package/templates/hono-server/apps/server/src/app.ts +37 -21
- package/templates/hono-server/apps/server/src/config.ts +1 -1
- package/templates/hono-server/apps/server/src/di-container.ts +51 -0
- package/templates/hono-server/apps/server/src/infra/logger/getter.ts +1 -1
- package/templates/hono-server/apps/server/src/infra/logger/pino.ts +21 -34
- package/templates/hono-server/apps/server/src/infra/work-runner/errors.ts +22 -0
- package/templates/hono-server/apps/server/src/infra/work-runner/pass-through/runner.ts +28 -22
- package/templates/hono-server/apps/server/src/infra/work-runner/piscina/runner.ts +11 -34
- package/templates/hono-server/apps/server/src/infra/work-runner/{example → piscina}/worker-entry.ts +6 -2
- package/templates/hono-server/apps/server/src/infra/work-runner/types.ts +2 -16
- package/templates/hono-server/apps/server/src/infra/work-runner/utils/business-error.ts +10 -5
- package/templates/hono-server/apps/server/src/infra/work-runner/utils/message.ts +5 -17
- package/templates/hono-server/apps/server/src/middlewares/cors.ts +16 -22
- package/templates/hono-server/apps/server/src/middlewares/logger.ts +34 -0
- package/templates/hono-server/apps/server/src/modules/example/module.ts +8 -0
- package/templates/hono-server/apps/server/src/modules/example/queries.ts +8 -0
- package/templates/hono-server/apps/server/src/modules/example/routes.ts +74 -68
- package/templates/hono-server/apps/server/src/modules/example/service.test.ts +53 -0
- package/templates/hono-server/apps/server/src/modules/example/service.ts +54 -0
- package/templates/hono-server/apps/server/src/modules/example/types.ts +12 -0
- package/templates/hono-server/apps/server/src/modules/example/work-task/tasks.test.ts +9 -35
- package/templates/hono-server/apps/server/src/modules/example/work-task/tasks.ts +15 -46
- package/templates/hono-server/apps/server/src/shared/errors/defs/index.ts +6 -1
- package/templates/hono-server/apps/server/src/shared/errors/handler.ts +1 -1
- package/templates/hono-server/apps/server/src/shared/network/openapi/index.ts +1 -1
- package/templates/hono-server/apps/server/src/shared/types/app.ts +51 -0
- package/templates/hono-server/apps/server/src/shared/types/db.ts +126 -0
- package/templates/hono-server/apps/server/src/shared/utils/data-access/check.ts +19 -0
- package/templates/hono-server/apps/server/src/shared/utils/data-access/model.ts +47 -0
- package/templates/hono-server/apps/server/src/shared/utils/data-access/params.ts +105 -0
- package/templates/hono-server/apps/server/src/shared/utils/data-access/query.test.ts +139 -0
- package/templates/hono-server/apps/server/src/shared/utils/data-access/query.ts +236 -0
- package/templates/hono-server/apps/server/vite.config.ts +2 -2
- package/templates/hono-server/apps/server/wrangler.jsonc +1 -1
- package/templates/hono-server/docker/README.md +1 -1
- package/templates/hono-server/envs/.env.example.sqlite-d1 +1 -0
- package/templates/hono-server/libs/db/drizzle-kit/sqlite-d1.config.ts +29 -10
- package/templates/hono-server/libs/db/package.json +1 -0
- package/templates/hono-server/libs/db/src/dialects/sqlite/schema/columns.ts +1 -1
- package/templates/hono-server/libs/db/src/dialects/sqlite/schema/modules/examples/examples.ts +6 -3
- package/templates/hono-server/libs/db/src/dialects/sqlite/schema/vo.ts +7 -1
- package/templates/hono-server/libs/definition/README.md +81 -0
- package/templates/hono-server/libs/definition/package.json +3 -1
- package/templates/hono-server/libs/definition/src/constants/index.ts +1 -0
- package/templates/hono-server/libs/definition/src/constants/pagination.ts +3 -0
- package/templates/hono-server/libs/definition/src/modules/common-contracts.ts +24 -0
- package/templates/hono-server/libs/definition/src/modules/example/contracts.ts +34 -0
- package/templates/hono-server/libs/definition/src/modules/example/index.ts +1 -16
- package/templates/hono-server/libs/definition/src/modules/index.ts +2 -0
- package/templates/hono-server/libs/definition/src/modules/vo-generated-types.ts +12 -0
- package/templates/hono-server/oyo.config.json +31 -1
- package/templates/hono-server/package.json +1 -0
- package/templates/hono-server/pnpm-workspace.yaml +9 -7
- package/templates/hono-server/turbo.json +10 -0
- package/templates/monorepo/.codegraph/.gitignore +5 -0
- package/templates/monorepo/_gitignore +1 -0
- package/templates/monorepo/oyo.config.json +7 -1
- package/templates/monorepo/pnpm-workspace.yaml +4 -4
- package/templates/monorepo/turbo.json +10 -0
- package/templates/hono-fullstack/apps/server/src/modules/example/contracts.ts +0 -9
- package/templates/hono-fullstack/apps/server/src/shared/app/types.ts +0 -44
- package/templates/hono-fullstack/apps/stack/frontend/styles.css +0 -23
- package/templates/hono-server/apps/server/src/modules/example/contracts.ts +0 -9
- package/templates/hono-server/apps/server/src/shared/app/types.ts +0 -44
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { Menu } from '@ark-ui/react/menu'
|
|
3
|
+
import { CheckIcon, ChevronDownIcon } from 'lucide-react'
|
|
4
|
+
import type { ComponentProps } from 'react'
|
|
5
|
+
import { createSlotRecipeContext } from 'styled-system/jsx'
|
|
6
|
+
import { menu } from 'styled-system/recipes'
|
|
7
|
+
|
|
8
|
+
const { withRootProvider, withContext } = createSlotRecipeContext(menu)
|
|
9
|
+
|
|
10
|
+
export type RootProps = ComponentProps<typeof Root>
|
|
11
|
+
export const Root = withRootProvider(Menu.Root, {
|
|
12
|
+
defaultProps: { unmountOnExit: true, lazyMount: true },
|
|
13
|
+
})
|
|
14
|
+
export const RootProvider = withRootProvider(Menu.RootProvider, {
|
|
15
|
+
defaultProps: { unmountOnExit: true, lazyMount: true },
|
|
16
|
+
})
|
|
17
|
+
export const Arrow = withContext(Menu.Arrow, 'arrow')
|
|
18
|
+
export const ArrowTip = withContext(Menu.ArrowTip, 'arrowTip')
|
|
19
|
+
export const CheckboxItem = withContext(Menu.CheckboxItem, 'item')
|
|
20
|
+
export const Content = withContext(Menu.Content, 'content')
|
|
21
|
+
export const ContextTrigger = withContext(Menu.ContextTrigger, 'contextTrigger')
|
|
22
|
+
export const Indicator = withContext(Menu.Indicator, 'indicator', {
|
|
23
|
+
defaultProps: { children: <ChevronDownIcon /> },
|
|
24
|
+
})
|
|
25
|
+
export const Item = withContext(Menu.Item, 'item')
|
|
26
|
+
export const ItemGroup = withContext(Menu.ItemGroup, 'itemGroup')
|
|
27
|
+
export const ItemGroupLabel = withContext(Menu.ItemGroupLabel, 'itemGroupLabel')
|
|
28
|
+
export const ItemText = withContext(Menu.ItemText, 'itemText')
|
|
29
|
+
export const Positioner = withContext(Menu.Positioner, 'positioner')
|
|
30
|
+
export const RadioItem = withContext(Menu.RadioItem, 'item')
|
|
31
|
+
export const RadioItemGroup = withContext(Menu.RadioItemGroup, 'itemGroup')
|
|
32
|
+
export const Separator = withContext(Menu.Separator, 'separator')
|
|
33
|
+
export const Trigger = withContext(Menu.Trigger, 'trigger')
|
|
34
|
+
export const TriggerItem = withContext(Menu.TriggerItem, 'item')
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
MenuContext as Context,
|
|
38
|
+
MenuItemContext as ItemContext,
|
|
39
|
+
type MenuSelectionDetails as SelectionDetails,
|
|
40
|
+
} from '@ark-ui/react/menu'
|
|
41
|
+
|
|
42
|
+
export const ItemIndicator = withContext(Menu.ItemIndicator, 'itemIndicator', {
|
|
43
|
+
defaultProps: { children: <CheckIcon /> },
|
|
44
|
+
})
|
|
45
|
+
export type ItemIndicatorProps = ComponentProps<typeof ItemIndicator>
|
|
46
|
+
|
|
47
|
+
export { useMenu, type UseMenuProps, type UseMenuReturn } from '@ark-ui/react/menu'
|
|
48
|
+
|
|
49
|
+
export type RootProviderProps = ComponentProps<typeof RootProvider>
|
|
50
|
+
export type ArrowProps = ComponentProps<typeof Arrow>
|
|
51
|
+
export type ArrowTipProps = ComponentProps<typeof ArrowTip>
|
|
52
|
+
export type CheckboxItemProps = ComponentProps<typeof CheckboxItem>
|
|
53
|
+
export type ContentProps = ComponentProps<typeof Content>
|
|
54
|
+
export type ContextTriggerProps = ComponentProps<typeof ContextTrigger>
|
|
55
|
+
export type IndicatorProps = ComponentProps<typeof Indicator>
|
|
56
|
+
export type ItemProps = ComponentProps<typeof Item>
|
|
57
|
+
export type ItemGroupProps = ComponentProps<typeof ItemGroup>
|
|
58
|
+
export type ItemGroupLabelProps = ComponentProps<typeof ItemGroupLabel>
|
|
59
|
+
export type ItemTextProps = ComponentProps<typeof ItemText>
|
|
60
|
+
export type PositionerProps = ComponentProps<typeof Positioner>
|
|
61
|
+
export type RadioItemProps = ComponentProps<typeof RadioItem>
|
|
62
|
+
export type RadioItemGroupProps = ComponentProps<typeof RadioItemGroup>
|
|
63
|
+
export type SeparatorProps = ComponentProps<typeof Separator>
|
|
64
|
+
export type TriggerProps = ComponentProps<typeof Trigger>
|
|
65
|
+
export type TriggerItemProps = ComponentProps<typeof TriggerItem>
|
|
66
|
+
|
|
67
|
+
export {
|
|
68
|
+
useMenuContext,
|
|
69
|
+
useMenuItemContext,
|
|
70
|
+
type MenuHighlightChangeDetails as HighlightChangeDetails,
|
|
71
|
+
type MenuOpenChangeDetails as OpenChangeDetails,
|
|
72
|
+
type MenuTriggerValueChangeDetails as TriggerValueChangeDetails,
|
|
73
|
+
type MenuValueChangeDetails as ValueChangeDetails,
|
|
74
|
+
} from '@ark-ui/react/menu'
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vite-plus/test'
|
|
2
|
+
import { createOverlay } from './OverlayManager'
|
|
3
|
+
|
|
4
|
+
const Component = () => null
|
|
5
|
+
|
|
6
|
+
describe('createOverlay', () => {
|
|
7
|
+
it('settles a replaced instance without allowing stale callbacks to close its replacement', async () => {
|
|
8
|
+
const overlay = createOverlay<{ title: string }, boolean>(Component)
|
|
9
|
+
const first = overlay.open('confirm', { title: 'First' })
|
|
10
|
+
const stale = overlay.get('confirm')
|
|
11
|
+
const second = overlay.open('confirm', { title: 'Second' })
|
|
12
|
+
await expect(first).resolves.toBeUndefined()
|
|
13
|
+
stale.onOpenChange?.({ open: false })
|
|
14
|
+
stale.onExitComplete?.()
|
|
15
|
+
expect(overlay.get('confirm').title).toBe('Second')
|
|
16
|
+
expect(overlay.get('confirm').open).toBe(true)
|
|
17
|
+
await overlay.close('confirm', false)
|
|
18
|
+
await expect(second).resolves.toBe(false)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('preserves falsy return values and handles closing before Viewport mounts', async () => {
|
|
22
|
+
const overlay = createOverlay<{}, number>(Component)
|
|
23
|
+
const result = overlay.open('queued', {})
|
|
24
|
+
const exit = overlay.waitForExit('queued')
|
|
25
|
+
await overlay.close('queued', 0)
|
|
26
|
+
await expect(result).resolves.toBe(0)
|
|
27
|
+
await exit
|
|
28
|
+
expect(overlay.has('queued')).toBe(false)
|
|
29
|
+
await overlay.close('queued')
|
|
30
|
+
await overlay.waitForExit('missing')
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('removes one instance without affecting others or stranding its pending promises', async () => {
|
|
34
|
+
const overlay = createOverlay<{}>(Component)
|
|
35
|
+
const first = overlay.open('first', {})
|
|
36
|
+
const second = overlay.open('second', {})
|
|
37
|
+
const exit = overlay.waitForExit('first')
|
|
38
|
+
overlay.remove('first')
|
|
39
|
+
await expect(first).resolves.toBeUndefined()
|
|
40
|
+
await exit
|
|
41
|
+
expect(overlay.has('second')).toBe(true)
|
|
42
|
+
overlay.removeAll()
|
|
43
|
+
await expect(second).resolves.toBeUndefined()
|
|
44
|
+
expect(overlay.getSnapshot()).toEqual([])
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('settles every result and exit promise on removeAll', async () => {
|
|
48
|
+
const overlay = createOverlay<{}>(Component)
|
|
49
|
+
const results = [overlay.open('a', {}), overlay.open('b', {})]
|
|
50
|
+
const exits = [overlay.waitForExit('a'), overlay.waitForExit('b')]
|
|
51
|
+
overlay.removeAll()
|
|
52
|
+
await expect(Promise.all(results)).resolves.toEqual([undefined, undefined])
|
|
53
|
+
await Promise.all(exits)
|
|
54
|
+
overlay.removeAll()
|
|
55
|
+
overlay.remove('missing')
|
|
56
|
+
expect(overlay.getSnapshot()).toEqual([])
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('updates business props and callbacks while retaining manager-owned controls', async () => {
|
|
60
|
+
const initialChange = vi.fn()
|
|
61
|
+
const nextChange = vi.fn()
|
|
62
|
+
const injectedReturn = vi.fn()
|
|
63
|
+
const overlay = createOverlay<{ title: string }>(Component, {
|
|
64
|
+
props: { onOpenChange: initialChange },
|
|
65
|
+
})
|
|
66
|
+
const result = overlay.open('edit', { title: 'Initial' })
|
|
67
|
+
const before = overlay.get('edit')
|
|
68
|
+
const snapshot = overlay.getSnapshot()
|
|
69
|
+
expect(overlay.getSnapshot()).toBe(snapshot)
|
|
70
|
+
overlay.update('edit', {
|
|
71
|
+
title: 'Updated',
|
|
72
|
+
open: false,
|
|
73
|
+
onOpenChange: nextChange,
|
|
74
|
+
setReturnValue: injectedReturn,
|
|
75
|
+
})
|
|
76
|
+
const after = overlay.get('edit')
|
|
77
|
+
expect(after.title).toBe('Updated')
|
|
78
|
+
expect(after.open).toBe(true)
|
|
79
|
+
expect(after.onOpenChange).toBe(before.onOpenChange)
|
|
80
|
+
expect(after.setReturnValue).toBe(before.setReturnValue)
|
|
81
|
+
expect(overlay.getSnapshot()).not.toBe(snapshot)
|
|
82
|
+
after.onOpenChange?.({ open: false })
|
|
83
|
+
await expect(result).resolves.toBeUndefined()
|
|
84
|
+
expect(nextChange).toHaveBeenCalledWith({ open: false })
|
|
85
|
+
expect(initialChange).not.toHaveBeenCalled()
|
|
86
|
+
expect(injectedReturn).not.toHaveBeenCalled()
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it('keeps closing even if a user callback throws', async () => {
|
|
90
|
+
const overlay = createOverlay<{}>(Component, {
|
|
91
|
+
props: {
|
|
92
|
+
onOpenChange: () => {
|
|
93
|
+
throw new Error('User callback')
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
})
|
|
97
|
+
const result = overlay.open('error', {})
|
|
98
|
+
expect(() => overlay.get('error').onOpenChange?.({ open: false })).toThrow('User callback')
|
|
99
|
+
await expect(result).resolves.toBeUndefined()
|
|
100
|
+
expect(overlay.has('error')).toBe(false)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('does not close a replacement opened from a user callback', async () => {
|
|
104
|
+
const overlay = createOverlay<{}>(Component)
|
|
105
|
+
let replacement: Promise<unknown> | undefined
|
|
106
|
+
const original = overlay.open('reentrant', {
|
|
107
|
+
onOpenChange: () => {
|
|
108
|
+
replacement = overlay.open('reentrant', {})
|
|
109
|
+
},
|
|
110
|
+
})
|
|
111
|
+
overlay.get('reentrant').onOpenChange?.({ open: false })
|
|
112
|
+
await expect(original).resolves.toBeUndefined()
|
|
113
|
+
expect(overlay.get('reentrant').open).toBe(true)
|
|
114
|
+
overlay.removeAll()
|
|
115
|
+
await replacement
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
it('rejects reads and updates of unknown IDs without creating phantom entries', () => {
|
|
119
|
+
const overlay = createOverlay<{}>(Component)
|
|
120
|
+
expect(() => overlay.get('missing')).toThrow('not found')
|
|
121
|
+
expect(() => overlay.update('missing', {})).toThrow('not found')
|
|
122
|
+
expect(overlay.getSnapshot()).toEqual([])
|
|
123
|
+
})
|
|
124
|
+
})
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { useEffect, useState, useSyncExternalStore, type ComponentType, type JSX } from 'react'
|
|
3
|
+
|
|
4
|
+
export interface CreateOverlayProps<TReturn = unknown> {
|
|
5
|
+
open?: boolean
|
|
6
|
+
onOpenChange?: (details: { open: boolean }) => void
|
|
7
|
+
onExitComplete?: () => void
|
|
8
|
+
setReturnValue?: (value: TReturn) => void
|
|
9
|
+
setExitComplete?: () => void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface OverlayOptions<TProps extends object, TReturn = unknown> {
|
|
13
|
+
props?: Partial<TProps> & CreateOverlayProps<TReturn>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface CreateOverlayReturn<TProps extends object, TReturn = unknown> {
|
|
17
|
+
Viewport: () => JSX.Element
|
|
18
|
+
open: (id: string, props: TProps) => Promise<TReturn | undefined>
|
|
19
|
+
close: (id: string, value?: TReturn) => Promise<void>
|
|
20
|
+
update: (id: string, props: Partial<TProps> & CreateOverlayProps<TReturn>) => void
|
|
21
|
+
remove: (id: string) => void
|
|
22
|
+
removeAll: () => void
|
|
23
|
+
get: (id: string) => TProps & CreateOverlayProps<TReturn>
|
|
24
|
+
has: (id: string) => boolean
|
|
25
|
+
getSnapshot: () => (TProps & CreateOverlayProps<TReturn>)[]
|
|
26
|
+
waitForExit: (id: string) => Promise<void>
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function createOverlay<TProps extends object, TReturn = unknown>(
|
|
30
|
+
Component: ComponentType<TProps & CreateOverlayProps<TReturn>>,
|
|
31
|
+
options?: OverlayOptions<TProps, TReturn>,
|
|
32
|
+
): CreateOverlayReturn<TProps, TReturn> {
|
|
33
|
+
type Props = TProps & CreateOverlayProps<TReturn>
|
|
34
|
+
interface Entry {
|
|
35
|
+
key: number
|
|
36
|
+
props: Props
|
|
37
|
+
userProps: Props
|
|
38
|
+
presented: boolean
|
|
39
|
+
exited: Promise<void>
|
|
40
|
+
resolveResult: (value: TReturn | undefined) => void
|
|
41
|
+
resolveExit: () => void
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const entries = new Map<string, Entry>()
|
|
45
|
+
const subscribers = new Set<() => void>()
|
|
46
|
+
let snapshot: Entry[] = []
|
|
47
|
+
let propsSnapshot: Props[] = []
|
|
48
|
+
let nextKey = 0
|
|
49
|
+
const serverSnapshot: Entry[] = []
|
|
50
|
+
const getStoreSnapshot = () => snapshot
|
|
51
|
+
const getServerSnapshot = () => serverSnapshot
|
|
52
|
+
const subscribe = (callback: () => void) => {
|
|
53
|
+
subscribers.add(callback)
|
|
54
|
+
return () => {
|
|
55
|
+
subscribers.delete(callback)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const publish = () => {
|
|
59
|
+
snapshot = Array.from(entries.values())
|
|
60
|
+
propsSnapshot = snapshot.map((entry) => entry.props)
|
|
61
|
+
for (const callback of subscribers) callback()
|
|
62
|
+
}
|
|
63
|
+
const remove = (id: string) => {
|
|
64
|
+
const entry = entries.get(id)
|
|
65
|
+
if (!entry) return
|
|
66
|
+
entries.delete(id)
|
|
67
|
+
entry.resolveResult(undefined)
|
|
68
|
+
entry.resolveExit()
|
|
69
|
+
publish()
|
|
70
|
+
}
|
|
71
|
+
const getEntry = (id: string) => {
|
|
72
|
+
const entry = entries.get(id)
|
|
73
|
+
if (!entry) throw new Error(`[@repo/ui] Overlay with id "${id}" not found`)
|
|
74
|
+
return entry
|
|
75
|
+
}
|
|
76
|
+
const close = (id: string, value?: TReturn) => {
|
|
77
|
+
const entry = entries.get(id)
|
|
78
|
+
if (!entry) return Promise.resolve()
|
|
79
|
+
if (!entry.props.open) return entry.exited
|
|
80
|
+
entry.props = { ...entry.props, open: false }
|
|
81
|
+
entry.resolveResult(value)
|
|
82
|
+
// An overlay closed before its first open render has no exit animation to await.
|
|
83
|
+
if (!entry.presented) remove(id)
|
|
84
|
+
else publish()
|
|
85
|
+
return entry.exited
|
|
86
|
+
}
|
|
87
|
+
const open = (id: string, props: TProps) => {
|
|
88
|
+
remove(id)
|
|
89
|
+
let resolveResult!: Entry['resolveResult']
|
|
90
|
+
let resolveExit!: Entry['resolveExit']
|
|
91
|
+
const result = new Promise<TReturn | undefined>((resolve) => {
|
|
92
|
+
resolveResult = resolve
|
|
93
|
+
})
|
|
94
|
+
const exited = new Promise<void>((resolve) => {
|
|
95
|
+
resolveExit = resolve
|
|
96
|
+
})
|
|
97
|
+
const userProps = { ...options?.props, ...props } as Props
|
|
98
|
+
const entry: Entry = {
|
|
99
|
+
key: nextKey++,
|
|
100
|
+
userProps,
|
|
101
|
+
props: {
|
|
102
|
+
...userProps,
|
|
103
|
+
open: true,
|
|
104
|
+
onOpenChange: (details) => {
|
|
105
|
+
if (entries.get(id) !== entry) return
|
|
106
|
+
try {
|
|
107
|
+
entry.userProps.onOpenChange?.(details)
|
|
108
|
+
} finally {
|
|
109
|
+
if (!details.open && entries.get(id) === entry) void close(id)
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
onExitComplete: () => {
|
|
113
|
+
if (entries.get(id) !== entry || entry.props.open) return
|
|
114
|
+
try {
|
|
115
|
+
entry.userProps.onExitComplete?.()
|
|
116
|
+
} finally {
|
|
117
|
+
if (entries.get(id) === entry) remove(id)
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
setReturnValue: resolveResult,
|
|
121
|
+
setExitComplete: resolveExit,
|
|
122
|
+
},
|
|
123
|
+
presented: false,
|
|
124
|
+
exited,
|
|
125
|
+
resolveResult,
|
|
126
|
+
resolveExit,
|
|
127
|
+
}
|
|
128
|
+
entries.set(id, entry)
|
|
129
|
+
publish()
|
|
130
|
+
return result
|
|
131
|
+
}
|
|
132
|
+
const update = (id: string, props: Partial<TProps> & CreateOverlayProps<TReturn>) => {
|
|
133
|
+
const entry = getEntry(id)
|
|
134
|
+
entry.userProps = { ...entry.userProps, ...props }
|
|
135
|
+
entry.props = {
|
|
136
|
+
...entry.props,
|
|
137
|
+
...props,
|
|
138
|
+
open: entry.props.open,
|
|
139
|
+
onOpenChange: entry.props.onOpenChange,
|
|
140
|
+
onExitComplete: entry.props.onExitComplete,
|
|
141
|
+
setReturnValue: entry.props.setReturnValue,
|
|
142
|
+
setExitComplete: entry.props.setExitComplete,
|
|
143
|
+
}
|
|
144
|
+
publish()
|
|
145
|
+
}
|
|
146
|
+
const removeAll = () => {
|
|
147
|
+
for (const entry of entries.values()) {
|
|
148
|
+
entry.resolveResult(undefined)
|
|
149
|
+
entry.resolveExit()
|
|
150
|
+
}
|
|
151
|
+
entries.clear()
|
|
152
|
+
publish()
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function ViewportItem({ entry, props }: { entry: Entry; props: Props }) {
|
|
156
|
+
const [mounted, setMounted] = useState(false)
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
setMounted(true)
|
|
159
|
+
}, [])
|
|
160
|
+
useEffect(() => {
|
|
161
|
+
if (mounted && props.open) entry.presented = true
|
|
162
|
+
}, [entry, mounted, props.open])
|
|
163
|
+
return <Component {...props} open={mounted && !!props.open} />
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function Viewport() {
|
|
167
|
+
const current = useSyncExternalStore(subscribe, getStoreSnapshot, getServerSnapshot)
|
|
168
|
+
return (
|
|
169
|
+
<>
|
|
170
|
+
{current.map((entry) => (
|
|
171
|
+
<ViewportItem key={entry.key} entry={entry} props={entry.props} />
|
|
172
|
+
))}
|
|
173
|
+
</>
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return {
|
|
178
|
+
Viewport,
|
|
179
|
+
open,
|
|
180
|
+
close,
|
|
181
|
+
update,
|
|
182
|
+
remove,
|
|
183
|
+
removeAll,
|
|
184
|
+
get: (id) => getEntry(id).props,
|
|
185
|
+
has: (id) => entries.has(id),
|
|
186
|
+
getSnapshot: () => propsSnapshot,
|
|
187
|
+
waitForExit: (id) => entries.get(id)?.exited || Promise.resolve(),
|
|
188
|
+
}
|
|
189
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { ark } from '@ark-ui/react/factory'
|
|
3
|
+
import { Popover } from '@ark-ui/react/popover'
|
|
4
|
+
import type { ComponentProps } from 'react'
|
|
5
|
+
import { createSlotRecipeContext } from 'styled-system/jsx'
|
|
6
|
+
import { popover } from 'styled-system/recipes'
|
|
7
|
+
|
|
8
|
+
const { withRootProvider, withContext } = createSlotRecipeContext(popover)
|
|
9
|
+
|
|
10
|
+
export type RootProps = ComponentProps<typeof Root>
|
|
11
|
+
export const Root = withRootProvider(Popover.Root, {
|
|
12
|
+
defaultProps: { unmountOnExit: true, lazyMount: true },
|
|
13
|
+
})
|
|
14
|
+
export const RootProvider = withRootProvider(Popover.RootProvider, {
|
|
15
|
+
defaultProps: { unmountOnExit: true, lazyMount: true },
|
|
16
|
+
})
|
|
17
|
+
export const Anchor = withContext(Popover.Anchor, 'anchor')
|
|
18
|
+
export const ArrowTip = withContext(Popover.ArrowTip, 'arrowTip')
|
|
19
|
+
export const Arrow = withContext(Popover.Arrow, 'arrow', {
|
|
20
|
+
defaultProps: { children: <ArrowTip /> },
|
|
21
|
+
})
|
|
22
|
+
export const CloseTrigger = withContext(Popover.CloseTrigger, 'closeTrigger')
|
|
23
|
+
export const Content = withContext(Popover.Content, 'content')
|
|
24
|
+
export const Description = withContext(Popover.Description, 'description')
|
|
25
|
+
export const Indicator = withContext(Popover.Indicator, 'indicator')
|
|
26
|
+
export const Positioner = withContext(Popover.Positioner, 'positioner')
|
|
27
|
+
export const Title = withContext(Popover.Title, 'title')
|
|
28
|
+
export const Trigger = withContext(Popover.Trigger, 'trigger')
|
|
29
|
+
|
|
30
|
+
export const Body = withContext(ark.div, 'body')
|
|
31
|
+
export const Header = withContext(ark.div, 'header')
|
|
32
|
+
export const Footer = withContext(ark.div, 'footer')
|
|
33
|
+
|
|
34
|
+
export { PopoverContext as Context } from '@ark-ui/react/popover'
|
|
35
|
+
|
|
36
|
+
export { usePopover, type UsePopoverProps, type UsePopoverReturn } from '@ark-ui/react/popover'
|
|
37
|
+
|
|
38
|
+
export type RootProviderProps = ComponentProps<typeof RootProvider>
|
|
39
|
+
export type AnchorProps = ComponentProps<typeof Anchor>
|
|
40
|
+
export type ArrowTipProps = ComponentProps<typeof ArrowTip>
|
|
41
|
+
export type ArrowProps = ComponentProps<typeof Arrow>
|
|
42
|
+
export type CloseTriggerProps = ComponentProps<typeof CloseTrigger>
|
|
43
|
+
export type ContentProps = ComponentProps<typeof Content>
|
|
44
|
+
export type DescriptionProps = ComponentProps<typeof Description>
|
|
45
|
+
export type IndicatorProps = ComponentProps<typeof Indicator>
|
|
46
|
+
export type PositionerProps = ComponentProps<typeof Positioner>
|
|
47
|
+
export type TitleProps = ComponentProps<typeof Title>
|
|
48
|
+
export type TriggerProps = ComponentProps<typeof Trigger>
|
|
49
|
+
export type BodyProps = ComponentProps<typeof Body>
|
|
50
|
+
export type HeaderProps = ComponentProps<typeof Header>
|
|
51
|
+
export type FooterProps = ComponentProps<typeof Footer>
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
usePopoverContext,
|
|
55
|
+
type PopoverOpenChangeDetails as OpenChangeDetails,
|
|
56
|
+
type PopoverTriggerValueChangeDetails as TriggerValueChangeDetails,
|
|
57
|
+
} from '@ark-ui/react/popover'
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { Tooltip as ArkTooltip } from '@ark-ui/react/tooltip'
|
|
3
|
+
import type { ComponentProps } from 'react'
|
|
4
|
+
import { createSlotRecipeContext } from 'styled-system/jsx'
|
|
5
|
+
import { tooltip } from 'styled-system/recipes'
|
|
6
|
+
|
|
7
|
+
const { withRootProvider, withContext } = createSlotRecipeContext(tooltip)
|
|
8
|
+
|
|
9
|
+
export const Root = withRootProvider(ArkTooltip.Root, {
|
|
10
|
+
defaultProps: { unmountOnExit: true, lazyMount: true },
|
|
11
|
+
})
|
|
12
|
+
export const RootProvider = withRootProvider(ArkTooltip.RootProvider, {
|
|
13
|
+
defaultProps: { unmountOnExit: true, lazyMount: true },
|
|
14
|
+
})
|
|
15
|
+
export const Arrow = withContext(ArkTooltip.Arrow, 'arrow')
|
|
16
|
+
export const ArrowTip = withContext(ArkTooltip.ArrowTip, 'arrowTip')
|
|
17
|
+
export const Content = withContext(ArkTooltip.Content, 'content')
|
|
18
|
+
export const Positioner = withContext(ArkTooltip.Positioner, 'positioner')
|
|
19
|
+
export const Trigger = withContext(ArkTooltip.Trigger, 'trigger')
|
|
20
|
+
|
|
21
|
+
export type RootProps = ComponentProps<typeof Root>
|
|
22
|
+
export type RootProviderProps = ComponentProps<typeof RootProvider>
|
|
23
|
+
export type ArrowProps = ComponentProps<typeof Arrow>
|
|
24
|
+
export type ArrowTipProps = ComponentProps<typeof ArrowTip>
|
|
25
|
+
export type ContentProps = ComponentProps<typeof Content>
|
|
26
|
+
export type PositionerProps = ComponentProps<typeof Positioner>
|
|
27
|
+
export type TriggerProps = ComponentProps<typeof Trigger>
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
TooltipContext as Context,
|
|
31
|
+
useTooltip,
|
|
32
|
+
useTooltipContext,
|
|
33
|
+
type UseTooltipProps,
|
|
34
|
+
type UseTooltipReturn,
|
|
35
|
+
type TooltipOpenChangeDetails as OpenChangeDetails,
|
|
36
|
+
type TooltipTriggerValueChangeDetails as TriggerValueChangeDetails,
|
|
37
|
+
} from '@ark-ui/react/tooltip'
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ark } from '@ark-ui/react/factory'
|
|
2
|
+
import type { ComponentProps } from 'react'
|
|
3
|
+
import { styled } from 'styled-system/jsx'
|
|
4
|
+
import { link } from 'styled-system/recipes'
|
|
5
|
+
|
|
6
|
+
export type LinkProps = ComponentProps<typeof Link>
|
|
7
|
+
export const Link = styled(ark.a, link)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { ark } from '@ark-ui/react/factory'
|
|
3
|
+
import {
|
|
4
|
+
LinkBox as PandaLinkBox,
|
|
5
|
+
type LinkBoxProps as PandaLinkBoxProps,
|
|
6
|
+
LinkOverlay as PandaLinkOverlay,
|
|
7
|
+
type LinkOverlayProps as PandaLinkOverlayProps,
|
|
8
|
+
} from 'styled-system/jsx'
|
|
9
|
+
import { createLayout } from '@/components/atoms/internal/create-layout'
|
|
10
|
+
|
|
11
|
+
export type LinkBoxProps = PandaLinkBoxProps & { asChild?: boolean }
|
|
12
|
+
export const LinkBox = /* @__PURE__ */ createLayout<LinkBoxProps, HTMLDivElement>(
|
|
13
|
+
PandaLinkBox,
|
|
14
|
+
ark.div,
|
|
15
|
+
)
|
|
16
|
+
export type LinkOverlayProps = PandaLinkOverlayProps & { asChild?: boolean }
|
|
17
|
+
export const LinkOverlay = /* @__PURE__ */ createLayout<LinkOverlayProps, HTMLAnchorElement>(
|
|
18
|
+
PandaLinkOverlay,
|
|
19
|
+
ark.a,
|
|
20
|
+
{ 'data-link-overlay': '' },
|
|
21
|
+
)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { ark } from '@ark-ui/react/factory'
|
|
3
|
+
import {
|
|
4
|
+
VisuallyHidden as PandaVisuallyHidden,
|
|
5
|
+
type VisuallyHiddenProps as PandaVisuallyHiddenProps,
|
|
6
|
+
} from 'styled-system/jsx'
|
|
7
|
+
import { createLayout } from '@/components/atoms/internal/create-layout'
|
|
8
|
+
|
|
9
|
+
export type VisuallyHiddenProps = PandaVisuallyHiddenProps & { asChild?: boolean }
|
|
10
|
+
export const VisuallyHidden = /* @__PURE__ */ createLayout<VisuallyHiddenProps, HTMLDivElement>(
|
|
11
|
+
PandaVisuallyHidden,
|
|
12
|
+
ark.div,
|
|
13
|
+
)
|