@oyolincc/create 0.4.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 +3 -3
- package/templates/hono-fullstack/apps/stack/frontend/routes/__root.tsx +1 -1
- package/templates/hono-fullstack/apps/stack/frontend/routes/index.tsx +16 -4
- 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 +30 -4
- 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 +30 -4
- 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 +6 -4
- 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,145 @@
|
|
|
1
|
+
import { Button, CloseButton, Spinner, Toast, Toaster, createToaster } from '@repo/ui'
|
|
2
|
+
import { useEffect, useState } from 'react'
|
|
3
|
+
import { css } from 'styled-system/css'
|
|
4
|
+
|
|
5
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
title: 'Feedback/Toast',
|
|
9
|
+
component: Toast.Root,
|
|
10
|
+
parameters: {
|
|
11
|
+
controls: { disable: true },
|
|
12
|
+
docs: {
|
|
13
|
+
source: { type: 'code' },
|
|
14
|
+
description: { component: '通知类型、加载更新、操作回调、自定义内容和实例清理。' },
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
} satisfies Meta<typeof Toast.Root>
|
|
18
|
+
export default meta
|
|
19
|
+
type Story = StoryObj<typeof meta>
|
|
20
|
+
export const Lifecycle: Story = {
|
|
21
|
+
render: function Lifecycle() {
|
|
22
|
+
const [toaster] = useState(() =>
|
|
23
|
+
createToaster({
|
|
24
|
+
placement: 'bottom-end',
|
|
25
|
+
pauseOnPageIdle: true,
|
|
26
|
+
overlap: true,
|
|
27
|
+
max: 3,
|
|
28
|
+
}),
|
|
29
|
+
)
|
|
30
|
+
const [loadingId, setLoadingId] = useState<string>()
|
|
31
|
+
const [actions, setActions] = useState(0)
|
|
32
|
+
const [status, setStatus] = useState('尚未操作')
|
|
33
|
+
const [customContent, setCustomContent] = useState(false)
|
|
34
|
+
useEffect(() => () => toaster.remove(), [toaster])
|
|
35
|
+
return (
|
|
36
|
+
<div className={css({ display: 'grid', gap: '4', maxWidth: '4xl' })}>
|
|
37
|
+
<p>通知在右下角显示;悬停时暂停关闭,离开后继续计时。离开此示例后清理通知。</p>
|
|
38
|
+
<Toaster toaster={toaster} label="组件预览通知">
|
|
39
|
+
{customContent
|
|
40
|
+
? (toast) => (
|
|
41
|
+
<Toast.Root>
|
|
42
|
+
{toast.type === 'loading' ? <Spinner /> : <Toast.Indicator />}
|
|
43
|
+
<div>
|
|
44
|
+
<Toast.Title>{toast.title}</Toast.Title>
|
|
45
|
+
<Toast.Description>{toast.description}</Toast.Description>
|
|
46
|
+
{toast.action && (
|
|
47
|
+
<Toast.ActionTrigger>{toast.action.label}</Toast.ActionTrigger>
|
|
48
|
+
)}
|
|
49
|
+
</div>
|
|
50
|
+
{toast.closable && (
|
|
51
|
+
<Toast.CloseTrigger asChild>
|
|
52
|
+
<CloseButton size="sm" />
|
|
53
|
+
</Toast.CloseTrigger>
|
|
54
|
+
)}
|
|
55
|
+
</Toast.Root>
|
|
56
|
+
)
|
|
57
|
+
: undefined}
|
|
58
|
+
</Toaster>
|
|
59
|
+
<div className={css({ display: 'flex', flexWrap: 'wrap', gap: '3' })}>
|
|
60
|
+
<Button variant="outline" onClick={() => setCustomContent((value) => !value)}>
|
|
61
|
+
{customContent ? '切换默认通知内容' : '切换自定义通知内容'}
|
|
62
|
+
</Button>
|
|
63
|
+
{(['info', 'success', 'warning', 'error'] as const).map((type) => (
|
|
64
|
+
<Button
|
|
65
|
+
key={type}
|
|
66
|
+
variant="outline"
|
|
67
|
+
onClick={() =>
|
|
68
|
+
toaster.create({
|
|
69
|
+
type,
|
|
70
|
+
title: `${type} 通知`,
|
|
71
|
+
description: '4 秒后自动关闭,也可点击关闭按钮。',
|
|
72
|
+
duration: 4000,
|
|
73
|
+
closable: true,
|
|
74
|
+
onStatusChange: (details) => setStatus(`${type}: ${details.status}`),
|
|
75
|
+
})
|
|
76
|
+
}>
|
|
77
|
+
{type}
|
|
78
|
+
</Button>
|
|
79
|
+
))}
|
|
80
|
+
<Button
|
|
81
|
+
onClick={() => {
|
|
82
|
+
const id = toaster.create({
|
|
83
|
+
type: 'loading',
|
|
84
|
+
title: '等待操作完成',
|
|
85
|
+
description: '点击“更新为成功”更新同一条通知。',
|
|
86
|
+
closable: true,
|
|
87
|
+
})
|
|
88
|
+
setLoadingId(id)
|
|
89
|
+
}}>
|
|
90
|
+
创建 loading
|
|
91
|
+
</Button>
|
|
92
|
+
<Button
|
|
93
|
+
variant="outline"
|
|
94
|
+
disabled={!loadingId}
|
|
95
|
+
onClick={() => {
|
|
96
|
+
if (!loadingId) return
|
|
97
|
+
toaster.update(loadingId, {
|
|
98
|
+
type: 'success',
|
|
99
|
+
title: '操作完成',
|
|
100
|
+
description: '这条通知由 loading 更新而来。',
|
|
101
|
+
duration: 4000,
|
|
102
|
+
})
|
|
103
|
+
setLoadingId(undefined)
|
|
104
|
+
}}>
|
|
105
|
+
更新为成功
|
|
106
|
+
</Button>
|
|
107
|
+
<Button
|
|
108
|
+
variant="outline"
|
|
109
|
+
onClick={() =>
|
|
110
|
+
toaster.create({
|
|
111
|
+
type: 'info',
|
|
112
|
+
title: '带操作的通知',
|
|
113
|
+
description: '操作按钮应执行一次并关闭通知。',
|
|
114
|
+
duration: Infinity,
|
|
115
|
+
closable: true,
|
|
116
|
+
action: { label: '执行操作', onClick: () => setActions((count) => count + 1) },
|
|
117
|
+
})
|
|
118
|
+
}>
|
|
119
|
+
带操作的通知
|
|
120
|
+
</Button>
|
|
121
|
+
<Button
|
|
122
|
+
variant="outline"
|
|
123
|
+
onClick={() => {
|
|
124
|
+
for (let index = 1; index <= 5; index++) {
|
|
125
|
+
toaster.create({ title: `批量通知 ${index}`, duration: Infinity, closable: true })
|
|
126
|
+
}
|
|
127
|
+
}}>
|
|
128
|
+
连续创建 5 条
|
|
129
|
+
</Button>
|
|
130
|
+
<Button
|
|
131
|
+
variant="outline"
|
|
132
|
+
onClick={() => {
|
|
133
|
+
toaster.dismiss()
|
|
134
|
+
setLoadingId(undefined)
|
|
135
|
+
}}>
|
|
136
|
+
关闭全部
|
|
137
|
+
</Button>
|
|
138
|
+
</div>
|
|
139
|
+
<p role="status">
|
|
140
|
+
操作执行 {actions} 次;生命周期:{status}
|
|
141
|
+
</p>
|
|
142
|
+
</div>
|
|
143
|
+
)
|
|
144
|
+
},
|
|
145
|
+
}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { fn } from 'storybook/test'
|
|
2
|
+
import { Button, Checkbox, CheckboxGroup, Field } from '@repo/ui'
|
|
3
|
+
import { useState } from 'react'
|
|
4
|
+
import { css } from 'styled-system/css'
|
|
5
|
+
|
|
6
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
7
|
+
const channels = ['邮件', '站内通知']
|
|
8
|
+
|
|
9
|
+
const meta = {
|
|
10
|
+
title: 'Forms/Checkbox',
|
|
11
|
+
component: Checkbox.Root,
|
|
12
|
+
args: { size: 'md', variant: 'solid', disabled: false, onCheckedChange: fn() },
|
|
13
|
+
argTypes: {
|
|
14
|
+
size: { control: 'select', options: ['lg', 'md', 'sm', 'unstyled'] },
|
|
15
|
+
variant: {
|
|
16
|
+
control: 'select',
|
|
17
|
+
options: ['outline', 'plain', 'solid', 'subtle', 'surface', 'unstyled'],
|
|
18
|
+
},
|
|
19
|
+
disabled: { control: 'boolean' },
|
|
20
|
+
onCheckedChange: { control: false },
|
|
21
|
+
},
|
|
22
|
+
parameters: {
|
|
23
|
+
controls: { disable: true },
|
|
24
|
+
docs: {
|
|
25
|
+
source: { type: 'code' },
|
|
26
|
+
description: { component: '半选、全选联动、分组表单及自定义指示器。' },
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
} satisfies Meta<typeof Checkbox.Root>
|
|
30
|
+
export default meta
|
|
31
|
+
type Story = StoryObj<typeof meta>
|
|
32
|
+
export const Playground: Story = {
|
|
33
|
+
parameters: {
|
|
34
|
+
controls: { disable: false, include: ['size', 'variant', 'disabled'] },
|
|
35
|
+
docs: { source: { type: 'dynamic' } },
|
|
36
|
+
},
|
|
37
|
+
render: (args) => (
|
|
38
|
+
<div className={css({ maxWidth: '2xl' })}>
|
|
39
|
+
<Checkbox.Root {...args}>
|
|
40
|
+
<Checkbox.HiddenInput />
|
|
41
|
+
<Checkbox.Control />
|
|
42
|
+
<Checkbox.Label>同意选项</Checkbox.Label>
|
|
43
|
+
</Checkbox.Root>
|
|
44
|
+
</div>
|
|
45
|
+
),
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const ValidationAndGroup: Story = {
|
|
49
|
+
render: function ValidationAndGroup() {
|
|
50
|
+
const [selected, setSelected] = useState(['邮件'])
|
|
51
|
+
const [accepted, setAccepted] = useState(false)
|
|
52
|
+
const [validated, setValidated] = useState(false)
|
|
53
|
+
const [submitted, setSubmitted] = useState('尚未提交')
|
|
54
|
+
const allChecked = selected.length === channels.length
|
|
55
|
+
const checked: Checkbox.CheckedState = allChecked
|
|
56
|
+
? true
|
|
57
|
+
: selected.length > 0
|
|
58
|
+
? 'indeterminate'
|
|
59
|
+
: false
|
|
60
|
+
return (
|
|
61
|
+
<div className={css({ display: 'grid', gap: '4', maxWidth: '4xl' })}>
|
|
62
|
+
<p>点击文字或使用 Tab + 空格切换。通知全选应随子项显示未选、半选、全选。</p>
|
|
63
|
+
<form
|
|
64
|
+
noValidate
|
|
65
|
+
className={css({ display: 'grid', gap: '4', maxWidth: 'md' })}
|
|
66
|
+
onReset={() => {
|
|
67
|
+
setSelected(['邮件'])
|
|
68
|
+
setAccepted(false)
|
|
69
|
+
setValidated(false)
|
|
70
|
+
setSubmitted('尚未提交')
|
|
71
|
+
}}
|
|
72
|
+
onSubmit={(event) => {
|
|
73
|
+
event.preventDefault()
|
|
74
|
+
setValidated(true)
|
|
75
|
+
if (!accepted) {
|
|
76
|
+
setSubmitted('请先同意使用条款')
|
|
77
|
+
const input = event.currentTarget.elements.namedItem('terms')
|
|
78
|
+
if (input instanceof HTMLInputElement) input.focus()
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
const data = new FormData(event.currentTarget)
|
|
82
|
+
setSubmitted(
|
|
83
|
+
JSON.stringify({
|
|
84
|
+
channels: data.getAll('channels'),
|
|
85
|
+
terms: data.get('terms'),
|
|
86
|
+
digest: data.get('digest'),
|
|
87
|
+
disabled: data.get('disabled'),
|
|
88
|
+
customSize: data.get('custom-checkbox-size'),
|
|
89
|
+
customAppearance: data.get('custom-checkbox-appearance'),
|
|
90
|
+
}),
|
|
91
|
+
)
|
|
92
|
+
}}>
|
|
93
|
+
<Checkbox.Root
|
|
94
|
+
checked={checked}
|
|
95
|
+
onCheckedChange={(details) =>
|
|
96
|
+
setSelected(details.checked === true ? [...channels] : [])
|
|
97
|
+
}>
|
|
98
|
+
<Checkbox.Control>
|
|
99
|
+
<Checkbox.Indicator
|
|
100
|
+
checked={
|
|
101
|
+
<svg>
|
|
102
|
+
<path d="M5 12l4 4L19 6" />
|
|
103
|
+
</svg>
|
|
104
|
+
}
|
|
105
|
+
indeterminate={
|
|
106
|
+
<svg>
|
|
107
|
+
<circle cx="12" cy="12" r="4" />
|
|
108
|
+
</svg>
|
|
109
|
+
}
|
|
110
|
+
/>
|
|
111
|
+
</Checkbox.Control>
|
|
112
|
+
<Checkbox.Label>全部通知渠道</Checkbox.Label>
|
|
113
|
+
<Checkbox.HiddenInput />
|
|
114
|
+
<Checkbox.Context>
|
|
115
|
+
{(api) => (
|
|
116
|
+
<span>({api.indeterminate ? '半选' : api.checked ? '全选' : '未选'})</span>
|
|
117
|
+
)}
|
|
118
|
+
</Checkbox.Context>
|
|
119
|
+
</Checkbox.Root>
|
|
120
|
+
<CheckboxGroup
|
|
121
|
+
name="channels"
|
|
122
|
+
value={selected}
|
|
123
|
+
onValueChange={setSelected}
|
|
124
|
+
className={css({ display: 'grid', gap: '3', pl: '8' })}>
|
|
125
|
+
{channels.map((channel) => (
|
|
126
|
+
<Checkbox.Root key={channel} value={channel} variant="outline" size="sm">
|
|
127
|
+
<Checkbox.Control>
|
|
128
|
+
<Checkbox.Indicator />
|
|
129
|
+
</Checkbox.Control>
|
|
130
|
+
<Checkbox.Label>{channel}</Checkbox.Label>
|
|
131
|
+
<Checkbox.HiddenInput />
|
|
132
|
+
</Checkbox.Root>
|
|
133
|
+
))}
|
|
134
|
+
</CheckboxGroup>
|
|
135
|
+
<p role="status">通知渠道:{selected.join('、') || '无'}</p>
|
|
136
|
+
|
|
137
|
+
<Field.Root required invalid={validated && !accepted}>
|
|
138
|
+
<Checkbox.Root
|
|
139
|
+
name="terms"
|
|
140
|
+
value="accepted"
|
|
141
|
+
checked={accepted}
|
|
142
|
+
onCheckedChange={(details) => setAccepted(details.checked === true)}>
|
|
143
|
+
<Checkbox.Control>
|
|
144
|
+
<Checkbox.Indicator />
|
|
145
|
+
</Checkbox.Control>
|
|
146
|
+
<Checkbox.Label>
|
|
147
|
+
同意使用条款 <Field.RequiredIndicator>(必选)</Field.RequiredIndicator>
|
|
148
|
+
</Checkbox.Label>
|
|
149
|
+
<Checkbox.HiddenInput />
|
|
150
|
+
</Checkbox.Root>
|
|
151
|
+
<Field.HelperText>验证状态由 Field.Root 提供。</Field.HelperText>
|
|
152
|
+
<Field.ErrorText>请先同意使用条款。</Field.ErrorText>
|
|
153
|
+
</Field.Root>
|
|
154
|
+
|
|
155
|
+
<Checkbox.Root name="digest" value="enabled" defaultChecked variant="surface" size="lg">
|
|
156
|
+
<Checkbox.Control>
|
|
157
|
+
<Checkbox.Indicator />
|
|
158
|
+
</Checkbox.Control>
|
|
159
|
+
<Checkbox.Label>每日摘要(非受控,默认选中)</Checkbox.Label>
|
|
160
|
+
<Checkbox.HiddenInput />
|
|
161
|
+
</Checkbox.Root>
|
|
162
|
+
<Field.Root disabled>
|
|
163
|
+
<Checkbox.Root name="disabled" defaultChecked>
|
|
164
|
+
<Checkbox.Control>
|
|
165
|
+
<Checkbox.Indicator />
|
|
166
|
+
</Checkbox.Control>
|
|
167
|
+
<Checkbox.Label>禁用选项(不参与提交)</Checkbox.Label>
|
|
168
|
+
<Checkbox.HiddenInput />
|
|
169
|
+
</Checkbox.Root>
|
|
170
|
+
</Field.Root>
|
|
171
|
+
<Checkbox.Root defaultChecked>
|
|
172
|
+
<Checkbox.Control>
|
|
173
|
+
<Checkbox.Indicator>
|
|
174
|
+
<circle cx="12" cy="12" r="6" />
|
|
175
|
+
</Checkbox.Indicator>
|
|
176
|
+
</Checkbox.Control>
|
|
177
|
+
<Checkbox.Label>自定义 SVG 内容</Checkbox.Label>
|
|
178
|
+
<Checkbox.HiddenInput />
|
|
179
|
+
</Checkbox.Root>
|
|
180
|
+
<Checkbox.Root defaultChecked>
|
|
181
|
+
<Checkbox.Control>
|
|
182
|
+
<Checkbox.Indicator asChild>
|
|
183
|
+
<svg aria-hidden="true">
|
|
184
|
+
<path d="M5 12l4 4L19 6" />
|
|
185
|
+
</svg>
|
|
186
|
+
</Checkbox.Indicator>
|
|
187
|
+
</Checkbox.Control>
|
|
188
|
+
<Checkbox.Label>asChild 自定义图标</Checkbox.Label>
|
|
189
|
+
<Checkbox.HiddenInput />
|
|
190
|
+
</Checkbox.Root>
|
|
191
|
+
<div className={css({ display: 'grid', gap: '4' })}>
|
|
192
|
+
<h3 className={css({ textStyle: 'lg', fontWeight: 'semibold' })}>
|
|
193
|
+
复选框:尺寸与外观独立自定义
|
|
194
|
+
</h3>
|
|
195
|
+
<Checkbox.Root
|
|
196
|
+
size="unstyled"
|
|
197
|
+
name="custom-checkbox-size"
|
|
198
|
+
value="yes"
|
|
199
|
+
gap="4"
|
|
200
|
+
defaultChecked>
|
|
201
|
+
<Checkbox.Control boxSize="32px" _icon={{ boxSize: '24px' }}>
|
|
202
|
+
<Checkbox.Indicator />
|
|
203
|
+
</Checkbox.Control>
|
|
204
|
+
<Checkbox.Label textStyle="lg">自定 32px 复选框,保留 solid</Checkbox.Label>
|
|
205
|
+
<Checkbox.HiddenInput />
|
|
206
|
+
</Checkbox.Root>
|
|
207
|
+
<Checkbox.Root
|
|
208
|
+
variant="unstyled"
|
|
209
|
+
name="custom-checkbox-appearance"
|
|
210
|
+
value="yes"
|
|
211
|
+
defaultChecked>
|
|
212
|
+
<Checkbox.Control
|
|
213
|
+
borderWidth="2px"
|
|
214
|
+
borderColor="gray.8"
|
|
215
|
+
borderRadius="full"
|
|
216
|
+
focusVisibleRing="outside"
|
|
217
|
+
_checked={{ bg: 'lime.9', color: 'black' }}>
|
|
218
|
+
<Checkbox.Indicator />
|
|
219
|
+
</Checkbox.Control>
|
|
220
|
+
<Checkbox.Label>自定圆形外观,保留 md 尺寸</Checkbox.Label>
|
|
221
|
+
<Checkbox.HiddenInput />
|
|
222
|
+
</Checkbox.Root>
|
|
223
|
+
</div>
|
|
224
|
+
|
|
225
|
+
<div className={css({ display: 'flex', gap: '3' })}>
|
|
226
|
+
<Button colorPalette="lime" type="submit">
|
|
227
|
+
提交 Checkbox 表单
|
|
228
|
+
</Button>
|
|
229
|
+
<Button type="reset" variant="outline">
|
|
230
|
+
重置 Checkbox 表单
|
|
231
|
+
</Button>
|
|
232
|
+
</div>
|
|
233
|
+
<p role="status">Checkbox 提交结果:{submitted}</p>
|
|
234
|
+
</form>
|
|
235
|
+
</div>
|
|
236
|
+
)
|
|
237
|
+
},
|
|
238
|
+
}
|
|
239
|
+
export const Indicators: Story = {
|
|
240
|
+
render: function Indicators() {
|
|
241
|
+
const [checked, setChecked] = useState<Checkbox.CheckedState>(true)
|
|
242
|
+
const [customChecked, setCustomChecked] = useState(true)
|
|
243
|
+
|
|
244
|
+
return (
|
|
245
|
+
<div className={css({ display: 'grid', gap: '4', maxWidth: '4xl' })}>
|
|
246
|
+
<div className={css({ display: 'grid', gap: '3' })}>
|
|
247
|
+
<Checkbox.Root checked={checked} onCheckedChange={({ checked }) => setChecked(checked)}>
|
|
248
|
+
<Checkbox.HiddenInput />
|
|
249
|
+
<Checkbox.Control />
|
|
250
|
+
<Checkbox.Label>Control 默认提供指示器</Checkbox.Label>
|
|
251
|
+
</Checkbox.Root>
|
|
252
|
+
<Checkbox.Root checked="indeterminate">
|
|
253
|
+
<Checkbox.HiddenInput />
|
|
254
|
+
<Checkbox.Control />
|
|
255
|
+
<Checkbox.Label>默认半选指示器</Checkbox.Label>
|
|
256
|
+
</Checkbox.Root>
|
|
257
|
+
<Checkbox.Root
|
|
258
|
+
checked={customChecked}
|
|
259
|
+
onCheckedChange={({ checked }) => setCustomChecked(checked === true)}>
|
|
260
|
+
<Checkbox.HiddenInput />
|
|
261
|
+
<Checkbox.Control>
|
|
262
|
+
{customChecked && (
|
|
263
|
+
<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
|
264
|
+
<path d="m9 17-5-5 2-2 3 3 9-9 2 2Z" />
|
|
265
|
+
</svg>
|
|
266
|
+
)}
|
|
267
|
+
</Checkbox.Control>
|
|
268
|
+
<Checkbox.Label>自定义 children 替换默认指示器</Checkbox.Label>
|
|
269
|
+
</Checkbox.Root>
|
|
270
|
+
<Checkbox.Root defaultChecked>
|
|
271
|
+
<Checkbox.HiddenInput />
|
|
272
|
+
<Checkbox.Control>
|
|
273
|
+
<Checkbox.Indicator />
|
|
274
|
+
</Checkbox.Control>
|
|
275
|
+
<Checkbox.Label>原有显式 Indicator 用法继续有效</Checkbox.Label>
|
|
276
|
+
</Checkbox.Root>
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
)
|
|
280
|
+
},
|
|
281
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Button, Editable } from '@repo/ui'
|
|
2
|
+
import { useState } from 'react'
|
|
3
|
+
import { css } from 'styled-system/css'
|
|
4
|
+
|
|
5
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
title: 'Forms/Editable',
|
|
9
|
+
component: Editable.Root,
|
|
10
|
+
parameters: {
|
|
11
|
+
controls: { disable: true },
|
|
12
|
+
docs: {
|
|
13
|
+
source: { type: 'code' },
|
|
14
|
+
description: { component: '编辑、提交、取消与外部 store。' },
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
} satisfies Meta<typeof Editable.Root>
|
|
18
|
+
export default meta
|
|
19
|
+
type Story = StoryObj<typeof meta>
|
|
20
|
+
export const CommitAndCancel: Story = {
|
|
21
|
+
render: function CommitAndCancel() {
|
|
22
|
+
const [title, setTitle] = useState('可编辑的标题')
|
|
23
|
+
const [savedTitle, setSavedTitle] = useState(title)
|
|
24
|
+
|
|
25
|
+
const editable = Editable.useEditable({
|
|
26
|
+
value: title,
|
|
27
|
+
onValueChange: ({ value }) => setTitle(value),
|
|
28
|
+
onValueCommit: ({ value }) => setSavedTitle(value),
|
|
29
|
+
activationMode: 'none',
|
|
30
|
+
submitMode: 'enter',
|
|
31
|
+
})
|
|
32
|
+
return (
|
|
33
|
+
<div className={css({ display: 'grid', gap: '4', maxWidth: '4xl' })}>
|
|
34
|
+
<div className={css({ display: 'grid', gap: '3', maxWidth: 'xl' })}>
|
|
35
|
+
<h3 className={css({ textStyle: 'lg', fontWeight: 'semibold' })}>提交与取消编辑</h3>
|
|
36
|
+
<Editable.RootProvider value={editable} size="md">
|
|
37
|
+
<Editable.Label className={css({ srOnly: true })}>标题</Editable.Label>
|
|
38
|
+
<Editable.Area>
|
|
39
|
+
<Editable.Input />
|
|
40
|
+
<Editable.Preview />
|
|
41
|
+
</Editable.Area>
|
|
42
|
+
<Editable.Control>
|
|
43
|
+
<Editable.Context>
|
|
44
|
+
{(context) =>
|
|
45
|
+
context.editing ? (
|
|
46
|
+
<>
|
|
47
|
+
<Editable.SubmitTrigger asChild>
|
|
48
|
+
<Button size="sm">保存</Button>
|
|
49
|
+
</Editable.SubmitTrigger>
|
|
50
|
+
<Editable.CancelTrigger asChild>
|
|
51
|
+
<Button size="sm" variant="outline">
|
|
52
|
+
取消
|
|
53
|
+
</Button>
|
|
54
|
+
</Editable.CancelTrigger>
|
|
55
|
+
</>
|
|
56
|
+
) : (
|
|
57
|
+
<Editable.EditTrigger asChild>
|
|
58
|
+
<Button size="sm" variant="outline">
|
|
59
|
+
编辑
|
|
60
|
+
</Button>
|
|
61
|
+
</Editable.EditTrigger>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
</Editable.Context>
|
|
65
|
+
</Editable.Control>
|
|
66
|
+
</Editable.RootProvider>
|
|
67
|
+
<p role="status">最后提交:{savedTitle};Enter 保存,Escape 取消。</p>
|
|
68
|
+
<Editable.Root defaultValue="只读文本" readOnly size="sm">
|
|
69
|
+
<Editable.Label className={css({ srOnly: true })}>只读标题</Editable.Label>
|
|
70
|
+
<Editable.Area>
|
|
71
|
+
<Editable.Input />
|
|
72
|
+
<Editable.Preview />
|
|
73
|
+
</Editable.Area>
|
|
74
|
+
</Editable.Root>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
)
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
export const CustomSize: Story = {
|
|
81
|
+
render: function CustomSize() {
|
|
82
|
+
return (
|
|
83
|
+
<div className={css({ display: 'grid', gap: '4', maxWidth: '4xl' })}>
|
|
84
|
+
<Editable.Root size="unstyled" defaultValue="点击编辑标题" gap="2">
|
|
85
|
+
<Editable.Label className={css({ srOnly: true })}>自定尺寸的标题</Editable.Label>
|
|
86
|
+
<Editable.Area>
|
|
87
|
+
<Editable.Preview minHeight="36px" px="2" textStyle="sm" />
|
|
88
|
+
<Editable.Input minHeight="36px" px="2" textStyle="sm" />
|
|
89
|
+
</Editable.Area>
|
|
90
|
+
</Editable.Root>
|
|
91
|
+
</div>
|
|
92
|
+
)
|
|
93
|
+
},
|
|
94
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Button, Field } from '@repo/ui'
|
|
2
|
+
import { useState } from 'react'
|
|
3
|
+
import { css } from 'styled-system/css'
|
|
4
|
+
|
|
5
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
title: 'Forms/Field',
|
|
9
|
+
component: Field.Root,
|
|
10
|
+
parameters: {
|
|
11
|
+
controls: { disable: true },
|
|
12
|
+
docs: {
|
|
13
|
+
source: { type: 'code' },
|
|
14
|
+
description: { component: '标签关联、必填校验、错误提示、只读与禁用。' },
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
} satisfies Meta<typeof Field.Root>
|
|
18
|
+
export default meta
|
|
19
|
+
type Story = StoryObj<typeof meta>
|
|
20
|
+
export const Validation: Story = {
|
|
21
|
+
render: function Validation() {
|
|
22
|
+
const [username, setUsername] = useState('')
|
|
23
|
+
const [validated, setValidated] = useState(false)
|
|
24
|
+
const [submitted, setSubmitted] = useState('尚未提交')
|
|
25
|
+
const invalid = validated && username.trim().length < 3
|
|
26
|
+
return (
|
|
27
|
+
<div className={css({ display: 'grid', gap: '4', maxWidth: '4xl' })}>
|
|
28
|
+
<p>点击标签应聚焦输入框;提交空值或不足 3 个字符时显示错误,修改后自动恢复。</p>
|
|
29
|
+
<form
|
|
30
|
+
noValidate
|
|
31
|
+
className={css({ display: 'grid', gap: '4', maxWidth: 'md' })}
|
|
32
|
+
onSubmit={(event) => {
|
|
33
|
+
event.preventDefault()
|
|
34
|
+
setValidated(true)
|
|
35
|
+
if (username.trim().length < 3) {
|
|
36
|
+
setSubmitted('验证未通过')
|
|
37
|
+
const input = event.currentTarget.elements.namedItem('username')
|
|
38
|
+
if (input instanceof HTMLInputElement) input.focus()
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
setSubmitted(JSON.stringify(Object.fromEntries(new FormData(event.currentTarget))))
|
|
42
|
+
}}>
|
|
43
|
+
<Field.Root required invalid={invalid}>
|
|
44
|
+
<Field.Label>
|
|
45
|
+
用户名 <Field.RequiredIndicator>(必填)</Field.RequiredIndicator>
|
|
46
|
+
</Field.Label>
|
|
47
|
+
<Field.Input
|
|
48
|
+
name="username"
|
|
49
|
+
value={username}
|
|
50
|
+
onChange={(event) => setUsername(event.target.value)}
|
|
51
|
+
placeholder="输入至少 3 个字符"
|
|
52
|
+
/>
|
|
53
|
+
<Field.HelperText>用于公开展示,至少 3 个字符。</Field.HelperText>
|
|
54
|
+
<Field.ErrorText>用户名至少需要 3 个字符。</Field.ErrorText>
|
|
55
|
+
</Field.Root>
|
|
56
|
+
<Field.Root disabled>
|
|
57
|
+
<Field.Label>禁用字段</Field.Label>
|
|
58
|
+
<Field.Input name="disabled" defaultValue="不可编辑,也不参与提交" variant="surface" />
|
|
59
|
+
<Field.HelperText>禁用状态从 Field.Root 传给输入框。</Field.HelperText>
|
|
60
|
+
</Field.Root>
|
|
61
|
+
<Field.Root readOnly>
|
|
62
|
+
<Field.Label>只读字段</Field.Label>
|
|
63
|
+
<Field.Input name="account" defaultValue="demo-account" variant="subtle" />
|
|
64
|
+
<Field.HelperText>可聚焦和复制,参与表单提交。</Field.HelperText>
|
|
65
|
+
</Field.Root>
|
|
66
|
+
<Button type="submit">验证并读取表单</Button>
|
|
67
|
+
<p role="status">Field 提交结果:{submitted}</p>
|
|
68
|
+
</form>
|
|
69
|
+
</div>
|
|
70
|
+
)
|
|
71
|
+
},
|
|
72
|
+
}
|