@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,160 @@
|
|
|
1
|
+
import { Button, Field, Heading, NativeSelect, Text } from '@repo/ui'
|
|
2
|
+
import { useRef, useState } from 'react'
|
|
3
|
+
import { hstack } from 'styled-system/patterns'
|
|
4
|
+
import { css } from 'styled-system/css'
|
|
5
|
+
|
|
6
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: 'Forms/NativeSelect',
|
|
10
|
+
component: NativeSelect.Root,
|
|
11
|
+
args: { size: 'md', variant: 'outline', disabled: false },
|
|
12
|
+
argTypes: {
|
|
13
|
+
size: { control: 'select', options: ['2xl', '2xs', 'lg', 'md', 'sm', 'unstyled', 'xl', 'xs'] },
|
|
14
|
+
variant: {
|
|
15
|
+
control: 'select',
|
|
16
|
+
options: ['flushed', 'outline', 'subtle', 'surface', 'unstyled'],
|
|
17
|
+
},
|
|
18
|
+
disabled: { control: 'boolean' },
|
|
19
|
+
},
|
|
20
|
+
parameters: {
|
|
21
|
+
controls: { disable: true },
|
|
22
|
+
docs: {
|
|
23
|
+
source: { type: 'code' },
|
|
24
|
+
description: { component: '原生选项、分组、键盘行为和表单提交。' },
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
} satisfies Meta<typeof NativeSelect.Root>
|
|
28
|
+
export default meta
|
|
29
|
+
type Story = StoryObj<typeof meta>
|
|
30
|
+
export const Playground: Story = {
|
|
31
|
+
parameters: {
|
|
32
|
+
controls: { disable: false, include: ['size', 'variant', 'disabled'] },
|
|
33
|
+
docs: { source: { type: 'dynamic' } },
|
|
34
|
+
},
|
|
35
|
+
render: (args) => (
|
|
36
|
+
<div className={css({ maxWidth: '2xl' })}>
|
|
37
|
+
<NativeSelect.Root {...args}>
|
|
38
|
+
<NativeSelect.Field aria-label="选择框架" defaultValue="react">
|
|
39
|
+
<option value="react">React</option>
|
|
40
|
+
<option value="vue">Vue</option>
|
|
41
|
+
<option disabled value="solid">
|
|
42
|
+
Solid(禁用)
|
|
43
|
+
</option>
|
|
44
|
+
</NativeSelect.Field>
|
|
45
|
+
<NativeSelect.Indicator />
|
|
46
|
+
</NativeSelect.Root>
|
|
47
|
+
</div>
|
|
48
|
+
),
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const ControlledAndStates: Story = {
|
|
52
|
+
render: function ControlledAndStates() {
|
|
53
|
+
const [framework, setFramework] = useState('react')
|
|
54
|
+
const [disabled, setDisabled] = useState(false)
|
|
55
|
+
|
|
56
|
+
const selectRef = useRef<HTMLSelectElement>(null)
|
|
57
|
+
const [submittedForm, setSubmittedForm] = useState('尚未提交')
|
|
58
|
+
return (
|
|
59
|
+
<div className={css({ display: 'grid', gap: '4', maxWidth: '4xl' })}>
|
|
60
|
+
<form
|
|
61
|
+
noValidate
|
|
62
|
+
onSubmit={(event) => {
|
|
63
|
+
event.preventDefault()
|
|
64
|
+
setSubmittedForm(
|
|
65
|
+
JSON.stringify(Array.from(new FormData(event.currentTarget).entries())),
|
|
66
|
+
)
|
|
67
|
+
}}
|
|
68
|
+
className={css({ display: 'grid', gap: '4' })}>
|
|
69
|
+
<Field.Root required>
|
|
70
|
+
<Field.Label>
|
|
71
|
+
原生选择框
|
|
72
|
+
<Field.RequiredIndicator />
|
|
73
|
+
</Field.Label>
|
|
74
|
+
<NativeSelect.Root size="md" disabled={disabled} maxWidth="md">
|
|
75
|
+
<NativeSelect.Field
|
|
76
|
+
ref={selectRef}
|
|
77
|
+
placeholder="请选择框架"
|
|
78
|
+
value={framework}
|
|
79
|
+
onChange={(event) => setFramework(event.target.value)}
|
|
80
|
+
name="framework">
|
|
81
|
+
<optgroup label="框架">
|
|
82
|
+
<option value="react">React</option>
|
|
83
|
+
<option value="vue">Vue</option>
|
|
84
|
+
<option value="angular">Angular</option>
|
|
85
|
+
</optgroup>
|
|
86
|
+
</NativeSelect.Field>
|
|
87
|
+
<NativeSelect.Indicator />
|
|
88
|
+
</NativeSelect.Root>
|
|
89
|
+
<Field.HelperText>当前值:{framework || '未选择'}</Field.HelperText>
|
|
90
|
+
</Field.Root>
|
|
91
|
+
<div className={hstack({ gap: '3', flexWrap: 'wrap' })}>
|
|
92
|
+
<Button variant="outline" onClick={() => setDisabled((value) => !value)}>
|
|
93
|
+
选择框:{disabled ? '已禁用' : '可用'}
|
|
94
|
+
</Button>
|
|
95
|
+
<Button
|
|
96
|
+
variant="outline"
|
|
97
|
+
disabled={disabled}
|
|
98
|
+
onClick={() => selectRef.current?.focus()}>
|
|
99
|
+
通过 ref 聚焦选择框
|
|
100
|
+
</Button>
|
|
101
|
+
</div>
|
|
102
|
+
<Field.Root invalid disabled>
|
|
103
|
+
<Field.Label>Field 错误与禁用联动</Field.Label>
|
|
104
|
+
<NativeSelect.Root size="sm" variant="surface">
|
|
105
|
+
<NativeSelect.Field defaultValue="" placeholder="请选择">
|
|
106
|
+
<option value="one">选项一</option>
|
|
107
|
+
</NativeSelect.Field>
|
|
108
|
+
<NativeSelect.Indicator>⌄</NativeSelect.Indicator>
|
|
109
|
+
</NativeSelect.Root>
|
|
110
|
+
<Field.ErrorText>示例错误提示</Field.ErrorText>
|
|
111
|
+
</Field.Root>
|
|
112
|
+
<NativeSelect.Root size="lg" variant="subtle" invalid>
|
|
113
|
+
<NativeSelect.Field aria-label="根入口错误状态" placeholder="根入口 invalid">
|
|
114
|
+
<option value="one">选项一</option>
|
|
115
|
+
</NativeSelect.Field>
|
|
116
|
+
<NativeSelect.Indicator />
|
|
117
|
+
</NativeSelect.Root>
|
|
118
|
+
<Text>NativeSelect 保留原生 option / optgroup、表单提交和浏览器键盘行为。</Text>
|
|
119
|
+
<div className={css({ display: 'flex', gap: '3' })}>
|
|
120
|
+
<Button type="submit">读取本地 FormData</Button>
|
|
121
|
+
</div>
|
|
122
|
+
<pre role="status" className={css({ whiteSpace: 'pre-wrap', overflowWrap: 'anywhere' })}>
|
|
123
|
+
{submittedForm}
|
|
124
|
+
</pre>
|
|
125
|
+
</form>
|
|
126
|
+
</div>
|
|
127
|
+
)
|
|
128
|
+
},
|
|
129
|
+
}
|
|
130
|
+
export const Customization: Story = {
|
|
131
|
+
render: function Customization() {
|
|
132
|
+
return (
|
|
133
|
+
<div className={css({ display: 'grid', gap: '4', maxWidth: '4xl' })}>
|
|
134
|
+
<Heading size="md">NativeSelect · 分维度定制</Heading>
|
|
135
|
+
<NativeSelect.Root size="unstyled" maxWidth="md" textStyle="sm">
|
|
136
|
+
<NativeSelect.Field
|
|
137
|
+
height="36px"
|
|
138
|
+
px="3"
|
|
139
|
+
paddingInlineEnd="36px"
|
|
140
|
+
aria-label="自定尺寸的原生选择">
|
|
141
|
+
<option value="react">React</option>
|
|
142
|
+
<option value="vue">Vue</option>
|
|
143
|
+
</NativeSelect.Field>
|
|
144
|
+
<NativeSelect.Indicator width="36px" css={{ _icon: { boxSize: '4' } }} />
|
|
145
|
+
</NativeSelect.Root>
|
|
146
|
+
<NativeSelect.Root variant="unstyled" maxWidth="md">
|
|
147
|
+
<NativeSelect.Field
|
|
148
|
+
bg="gray.3"
|
|
149
|
+
borderRadius="lg"
|
|
150
|
+
focusVisibleRing="inside"
|
|
151
|
+
aria-label="自定外观的原生选择">
|
|
152
|
+
<option value="react">React</option>
|
|
153
|
+
<option value="vue">Vue</option>
|
|
154
|
+
</NativeSelect.Field>
|
|
155
|
+
<NativeSelect.Indicator color="lime.11" />
|
|
156
|
+
</NativeSelect.Root>
|
|
157
|
+
</div>
|
|
158
|
+
)
|
|
159
|
+
},
|
|
160
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { fn } from 'storybook/test'
|
|
2
|
+
import { Button, Field, NumberInput } from '@repo/ui'
|
|
3
|
+
import { useState, useId } from 'react'
|
|
4
|
+
import { css } from 'styled-system/css'
|
|
5
|
+
|
|
6
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: 'Forms/NumberInput',
|
|
10
|
+
component: NumberInput.Root,
|
|
11
|
+
args: {
|
|
12
|
+
size: 'md',
|
|
13
|
+
variant: 'outline',
|
|
14
|
+
min: 0,
|
|
15
|
+
max: 20,
|
|
16
|
+
step: 1,
|
|
17
|
+
disabled: false,
|
|
18
|
+
onValueChange: fn(),
|
|
19
|
+
},
|
|
20
|
+
argTypes: {
|
|
21
|
+
size: { control: 'select', options: ['lg', 'md', 'sm', 'unstyled', 'xl'] },
|
|
22
|
+
variant: { control: 'select', options: ['outline', 'surface', 'unstyled'] },
|
|
23
|
+
min: { control: 'number' },
|
|
24
|
+
max: { control: 'number' },
|
|
25
|
+
step: { control: 'number' },
|
|
26
|
+
disabled: { control: 'boolean' },
|
|
27
|
+
onValueChange: { control: false },
|
|
28
|
+
},
|
|
29
|
+
parameters: {
|
|
30
|
+
controls: { disable: true },
|
|
31
|
+
docs: {
|
|
32
|
+
source: { type: 'code' },
|
|
33
|
+
description: { component: '数值输入、步进、上下限和原生表单数据。' },
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
} satisfies Meta<typeof NumberInput.Root>
|
|
37
|
+
export default meta
|
|
38
|
+
type Story = StoryObj<typeof meta>
|
|
39
|
+
export const Playground: Story = {
|
|
40
|
+
parameters: {
|
|
41
|
+
controls: { disable: false, include: ['size', 'variant', 'min', 'max', 'step', 'disabled'] },
|
|
42
|
+
docs: { source: { type: 'dynamic' } },
|
|
43
|
+
},
|
|
44
|
+
render: (args) => (
|
|
45
|
+
<div className={css({ maxWidth: '2xl' })}>
|
|
46
|
+
<NumberInput.Root {...args} defaultValue="5">
|
|
47
|
+
<NumberInput.Label>数量</NumberInput.Label>
|
|
48
|
+
<NumberInput.Input />
|
|
49
|
+
<NumberInput.Control />
|
|
50
|
+
</NumberInput.Root>
|
|
51
|
+
</div>
|
|
52
|
+
),
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const ControlledForm: Story = {
|
|
56
|
+
render: function ControlledForm() {
|
|
57
|
+
const [quantity, setQuantity] = useState('5')
|
|
58
|
+
|
|
59
|
+
const numberInput = NumberInput.useNumberInput({
|
|
60
|
+
name: 'quantity',
|
|
61
|
+
min: 0,
|
|
62
|
+
max: 20,
|
|
63
|
+
step: 1,
|
|
64
|
+
value: quantity,
|
|
65
|
+
onValueChange: ({ value }) => setQuantity(value),
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const [submittedForm, setSubmittedForm] = useState('尚未提交')
|
|
69
|
+
const storyId = useId()
|
|
70
|
+
return (
|
|
71
|
+
<div className={css({ display: 'grid', gap: '4', maxWidth: '4xl' })}>
|
|
72
|
+
<form
|
|
73
|
+
noValidate
|
|
74
|
+
onSubmit={(event) => {
|
|
75
|
+
event.preventDefault()
|
|
76
|
+
setSubmittedForm(
|
|
77
|
+
JSON.stringify(Array.from(new FormData(event.currentTarget).entries())),
|
|
78
|
+
)
|
|
79
|
+
}}
|
|
80
|
+
onReset={() => {
|
|
81
|
+
setQuantity('5')
|
|
82
|
+
setSubmittedForm('已重置')
|
|
83
|
+
}}
|
|
84
|
+
className={css({ display: 'grid', gap: '4' })}>
|
|
85
|
+
<div className={css({ display: 'grid', gap: '3', maxWidth: 'sm' })}>
|
|
86
|
+
<h3 className={css({ textStyle: 'lg', fontWeight: 'semibold' })}>数值与边界</h3>
|
|
87
|
+
<Field.Root>
|
|
88
|
+
<Field.Label htmlFor={`${storyId}-advanced-quantity`}>数量(0–20)</Field.Label>
|
|
89
|
+
<NumberInput.RootProvider value={numberInput} size="lg" variant="outline">
|
|
90
|
+
<NumberInput.Input
|
|
91
|
+
id={`${storyId}-advanced-quantity`}
|
|
92
|
+
aria-describedby={`${storyId}-advanced-quantity-help`}
|
|
93
|
+
/>
|
|
94
|
+
<NumberInput.Control />
|
|
95
|
+
</NumberInput.RootProvider>
|
|
96
|
+
<Field.HelperText id={`${storyId}-advanced-quantity-help`}>
|
|
97
|
+
支持输入、上下键和步进按钮;空值保留为空字符串。
|
|
98
|
+
</Field.HelperText>
|
|
99
|
+
</Field.Root>
|
|
100
|
+
<NumberInput.Root defaultValue="10" disabled size="sm">
|
|
101
|
+
<NumberInput.Input aria-label="禁用的数值输入" />
|
|
102
|
+
<NumberInput.Control />
|
|
103
|
+
</NumberInput.Root>
|
|
104
|
+
<p role="status">数量:{quantity === '' ? '空值' : quantity}</p>
|
|
105
|
+
</div>
|
|
106
|
+
<div className={css({ display: 'flex', gap: '3' })}>
|
|
107
|
+
<Button type="submit">读取本地 FormData</Button>
|
|
108
|
+
<Button type="reset" variant="outline">
|
|
109
|
+
重置
|
|
110
|
+
</Button>
|
|
111
|
+
</div>
|
|
112
|
+
<pre role="status" className={css({ whiteSpace: 'pre-wrap', overflowWrap: 'anywhere' })}>
|
|
113
|
+
{submittedForm}
|
|
114
|
+
</pre>
|
|
115
|
+
</form>
|
|
116
|
+
</div>
|
|
117
|
+
)
|
|
118
|
+
},
|
|
119
|
+
}
|
|
120
|
+
export const Customization: Story = {
|
|
121
|
+
render: function Customization() {
|
|
122
|
+
return (
|
|
123
|
+
<div className={css({ display: 'grid', gap: '4', maxWidth: '4xl' })}>
|
|
124
|
+
<NumberInput.Root
|
|
125
|
+
size="unstyled"
|
|
126
|
+
name="compact-quantity"
|
|
127
|
+
defaultValue="3"
|
|
128
|
+
min={0}
|
|
129
|
+
gap="1.5"
|
|
130
|
+
css={{
|
|
131
|
+
'& [data-part=control]': { width: '20px' },
|
|
132
|
+
'& [data-part=increment-trigger], & [data-part=decrement-trigger]': {
|
|
133
|
+
lineHeight: '1',
|
|
134
|
+
_icon: { boxSize: '3' },
|
|
135
|
+
},
|
|
136
|
+
}}>
|
|
137
|
+
<NumberInput.Label textStyle="sm">自定尺寸的数量</NumberInput.Label>
|
|
138
|
+
<NumberInput.Input height="36px" px="3" paddingInlineEnd="28px" textStyle="sm" />
|
|
139
|
+
<NumberInput.Control />
|
|
140
|
+
</NumberInput.Root>
|
|
141
|
+
<NumberInput.Root variant="unstyled" name="custom-quantity" defaultValue="2" min={0}>
|
|
142
|
+
<NumberInput.Label>自定外观,保留 md 尺寸</NumberInput.Label>
|
|
143
|
+
<NumberInput.Input bg="gray.3" borderRadius="lg" focusVisibleRing="inside" />
|
|
144
|
+
<NumberInput.Control height="full" bg="lime.3" borderRadius="md" />
|
|
145
|
+
</NumberInput.Root>
|
|
146
|
+
</div>
|
|
147
|
+
)
|
|
148
|
+
},
|
|
149
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { fn } from 'storybook/test'
|
|
2
|
+
import { Button, Field, PasswordInput } from '@repo/ui'
|
|
3
|
+
import { useRef, useState } from 'react'
|
|
4
|
+
import { hstack } from 'styled-system/patterns'
|
|
5
|
+
import { css } from 'styled-system/css'
|
|
6
|
+
|
|
7
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
8
|
+
|
|
9
|
+
const meta = {
|
|
10
|
+
title: 'Forms/PasswordInput',
|
|
11
|
+
component: PasswordInput,
|
|
12
|
+
args: { size: 'md', variant: 'outline', disabled: false, readOnly: false, onVisibleChange: fn() },
|
|
13
|
+
argTypes: {
|
|
14
|
+
size: { control: 'select', options: ['2xl', '2xs', 'lg', 'md', 'sm', 'unstyled', 'xl', 'xs'] },
|
|
15
|
+
variant: {
|
|
16
|
+
control: 'select',
|
|
17
|
+
options: ['flushed', 'outline', 'subtle', 'surface', 'unstyled'],
|
|
18
|
+
},
|
|
19
|
+
disabled: { control: 'boolean' },
|
|
20
|
+
readOnly: { control: 'boolean' },
|
|
21
|
+
onVisibleChange: { control: false },
|
|
22
|
+
},
|
|
23
|
+
parameters: {
|
|
24
|
+
controls: { disable: true },
|
|
25
|
+
docs: {
|
|
26
|
+
// Docgen cannot serialize the JSX icon defaults; use the explicit argTypes above.
|
|
27
|
+
extractArgTypes: false,
|
|
28
|
+
source: { type: 'code' },
|
|
29
|
+
description: { component: '密码可见性、ref 聚焦、Field 状态与尾部空间。' },
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
} satisfies Meta<typeof PasswordInput>
|
|
33
|
+
export default meta
|
|
34
|
+
type Story = StoryObj<typeof meta>
|
|
35
|
+
export const Playground: Story = {
|
|
36
|
+
parameters: {
|
|
37
|
+
controls: { disable: false, include: ['size', 'variant', 'disabled', 'readOnly'] },
|
|
38
|
+
docs: { source: { type: 'dynamic' } },
|
|
39
|
+
},
|
|
40
|
+
render: (args) => (
|
|
41
|
+
<div className={css({ maxWidth: '2xl' })}>
|
|
42
|
+
<PasswordInput
|
|
43
|
+
{...args}
|
|
44
|
+
aria-label="密码"
|
|
45
|
+
defaultValue="demo-password"
|
|
46
|
+
autoComplete="new-password"
|
|
47
|
+
/>
|
|
48
|
+
</div>
|
|
49
|
+
),
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const ControlledAndStates: Story = {
|
|
53
|
+
render: function ControlledAndStates() {
|
|
54
|
+
const [visible, setVisible] = useState(false)
|
|
55
|
+
const [password, setPassword] = useState('demo-password')
|
|
56
|
+
|
|
57
|
+
const passwordRef = useRef<HTMLInputElement>(null)
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div className={css({ display: 'grid', gap: '4', maxWidth: '4xl' })}>
|
|
61
|
+
<Field.Root>
|
|
62
|
+
<Field.Label>受控密码和可见状态</Field.Label>
|
|
63
|
+
<PasswordInput
|
|
64
|
+
ref={passwordRef}
|
|
65
|
+
value={password}
|
|
66
|
+
onChange={(event) => setPassword(event.target.value)}
|
|
67
|
+
visible={visible}
|
|
68
|
+
onVisibleChange={setVisible}
|
|
69
|
+
autoComplete="new-password"
|
|
70
|
+
rootProps={{ maxWidth: 'md' }}
|
|
71
|
+
/>
|
|
72
|
+
<Field.HelperText>
|
|
73
|
+
显示按钮可通过 Tab 和 Enter 操作;切换显示不应提交表单。
|
|
74
|
+
</Field.HelperText>
|
|
75
|
+
</Field.Root>
|
|
76
|
+
<div className={hstack({ gap: '3', flexWrap: 'wrap' })}>
|
|
77
|
+
<Button variant="outline" onClick={() => setVisible((value) => !value)}>
|
|
78
|
+
{visible ? '隐藏密码' : '显示密码'}
|
|
79
|
+
</Button>
|
|
80
|
+
<Button variant="outline" onClick={() => passwordRef.current?.focus()}>
|
|
81
|
+
通过 ref 聚焦密码
|
|
82
|
+
</Button>
|
|
83
|
+
</div>
|
|
84
|
+
<Field.Root invalid>
|
|
85
|
+
<Field.Label>默认可见、自定义图标与错误状态</Field.Label>
|
|
86
|
+
<PasswordInput
|
|
87
|
+
defaultVisible
|
|
88
|
+
size="sm"
|
|
89
|
+
variant="surface"
|
|
90
|
+
visibilityIcon={{ on: '+', off: '−' }}
|
|
91
|
+
defaultValue="example"
|
|
92
|
+
autoComplete="new-password"
|
|
93
|
+
/>
|
|
94
|
+
<Field.ErrorText>示例错误提示</Field.ErrorText>
|
|
95
|
+
</Field.Root>
|
|
96
|
+
<Field.Root disabled>
|
|
97
|
+
<Field.Label>Field 禁用联动</Field.Label>
|
|
98
|
+
<PasswordInput size="xs" placeholder="输入与显示按钮都应禁用" />
|
|
99
|
+
</Field.Root>
|
|
100
|
+
<PasswordInput
|
|
101
|
+
aria-label="大尺寸密码输入"
|
|
102
|
+
size="2xl"
|
|
103
|
+
variant="subtle"
|
|
104
|
+
placeholder="2xl 尺寸"
|
|
105
|
+
/>
|
|
106
|
+
</div>
|
|
107
|
+
)
|
|
108
|
+
},
|
|
109
|
+
}
|
|
110
|
+
export const CustomSize: Story = {
|
|
111
|
+
render: function CustomSize() {
|
|
112
|
+
return (
|
|
113
|
+
<div className={css({ display: 'grid', gap: '4', maxWidth: '4xl' })}>
|
|
114
|
+
<Field.Root>
|
|
115
|
+
<Field.Label>PasswordInput:自定尺寸与尾部预留</Field.Label>
|
|
116
|
+
<PasswordInput
|
|
117
|
+
size="unstyled"
|
|
118
|
+
name="custom-password"
|
|
119
|
+
height="64px"
|
|
120
|
+
ps="6"
|
|
121
|
+
paddingInlineEnd="72px"
|
|
122
|
+
textStyle="lg"
|
|
123
|
+
defaultValue="custom-password"
|
|
124
|
+
autoComplete="new-password"
|
|
125
|
+
/>
|
|
126
|
+
<Field.HelperText>
|
|
127
|
+
点击眼睛并检查焦点;长密码不应被按钮遮挡。下面一项使用默认预留空间。
|
|
128
|
+
</Field.HelperText>
|
|
129
|
+
<PasswordInput
|
|
130
|
+
size="unstyled"
|
|
131
|
+
height="40px"
|
|
132
|
+
ps="4"
|
|
133
|
+
defaultValue="fallback-padding"
|
|
134
|
+
autoComplete="new-password"
|
|
135
|
+
aria-label="自动预留尾部空间的密码"
|
|
136
|
+
/>
|
|
137
|
+
</Field.Root>
|
|
138
|
+
</div>
|
|
139
|
+
)
|
|
140
|
+
},
|
|
141
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { fn } from 'storybook/test'
|
|
2
|
+
import { Button, PinInput } 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
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: 'Forms/PinInput',
|
|
10
|
+
component: PinInput.Root,
|
|
11
|
+
args: {
|
|
12
|
+
size: 'md',
|
|
13
|
+
variant: 'outline',
|
|
14
|
+
count: 4,
|
|
15
|
+
mask: false,
|
|
16
|
+
disabled: false,
|
|
17
|
+
onValueChange: fn(),
|
|
18
|
+
},
|
|
19
|
+
argTypes: {
|
|
20
|
+
size: { control: 'select', options: ['2xl', 'lg', 'md', 'sm', 'unstyled', 'xl', 'xs'] },
|
|
21
|
+
variant: { control: 'select', options: ['flushed', 'outline', 'subtle', 'unstyled'] },
|
|
22
|
+
count: { control: 'number' },
|
|
23
|
+
mask: { control: 'boolean' },
|
|
24
|
+
disabled: { control: 'boolean' },
|
|
25
|
+
onValueChange: { control: false },
|
|
26
|
+
},
|
|
27
|
+
parameters: {
|
|
28
|
+
controls: { disable: true },
|
|
29
|
+
docs: {
|
|
30
|
+
source: { type: 'code' },
|
|
31
|
+
description: { component: '验证码输入、完成事件、遮罩和只读状态。' },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
} satisfies Meta<typeof PinInput.Root>
|
|
35
|
+
export default meta
|
|
36
|
+
type Story = StoryObj<typeof meta>
|
|
37
|
+
export const Playground: Story = {
|
|
38
|
+
parameters: {
|
|
39
|
+
controls: { disable: false, include: ['size', 'variant', 'count', 'mask', 'disabled'] },
|
|
40
|
+
docs: { source: { type: 'dynamic' } },
|
|
41
|
+
},
|
|
42
|
+
render: (args) => (
|
|
43
|
+
<div className={css({ maxWidth: '2xl' })}>
|
|
44
|
+
<PinInput.Root {...args}>
|
|
45
|
+
<PinInput.Label>验证码</PinInput.Label>
|
|
46
|
+
<PinInput.Control>
|
|
47
|
+
{Array.from({ length: args.count || 4 }, (_, index) => (
|
|
48
|
+
<PinInput.Input key={index} index={index} />
|
|
49
|
+
))}
|
|
50
|
+
</PinInput.Control>
|
|
51
|
+
<PinInput.HiddenInput />
|
|
52
|
+
</PinInput.Root>
|
|
53
|
+
</div>
|
|
54
|
+
),
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const ControlledForm: Story = {
|
|
58
|
+
render: function ControlledForm() {
|
|
59
|
+
const [pin, setPin] = useState(['', '', '', ''])
|
|
60
|
+
const [completed, setCompleted] = useState(false)
|
|
61
|
+
|
|
62
|
+
const [submittedForm, setSubmittedForm] = useState('尚未提交')
|
|
63
|
+
return (
|
|
64
|
+
<div className={css({ display: 'grid', gap: '4', maxWidth: '4xl' })}>
|
|
65
|
+
<form
|
|
66
|
+
noValidate
|
|
67
|
+
onSubmit={(event) => {
|
|
68
|
+
event.preventDefault()
|
|
69
|
+
setSubmittedForm(
|
|
70
|
+
JSON.stringify(Array.from(new FormData(event.currentTarget).entries())),
|
|
71
|
+
)
|
|
72
|
+
}}
|
|
73
|
+
onReset={() => {
|
|
74
|
+
setPin(['', '', '', ''])
|
|
75
|
+
setCompleted(false)
|
|
76
|
+
setSubmittedForm('已重置')
|
|
77
|
+
}}
|
|
78
|
+
className={css({ display: 'grid', gap: '4' })}>
|
|
79
|
+
<div className={css({ display: 'grid', gap: '3' })}>
|
|
80
|
+
<h3 className={css({ textStyle: 'lg', fontWeight: 'semibold' })}>验证码输入</h3>
|
|
81
|
+
<PinInput.Root
|
|
82
|
+
name="pin"
|
|
83
|
+
count={4}
|
|
84
|
+
otp
|
|
85
|
+
value={pin}
|
|
86
|
+
onValueChange={({ value }) => {
|
|
87
|
+
setPin(value)
|
|
88
|
+
setCompleted(value.length === 4 && value.every((character) => character !== ''))
|
|
89
|
+
}}
|
|
90
|
+
onValueComplete={() => setCompleted(true)}>
|
|
91
|
+
<PinInput.Label>四位数字</PinInput.Label>
|
|
92
|
+
<PinInput.Control>
|
|
93
|
+
{[0, 1, 2, 3].map((index) => (
|
|
94
|
+
<PinInput.Input key={index} index={index} />
|
|
95
|
+
))}
|
|
96
|
+
</PinInput.Control>
|
|
97
|
+
<PinInput.HiddenInput />
|
|
98
|
+
</PinInput.Root>
|
|
99
|
+
<PinInput.Root count={4} mask defaultValue={['1', '2', '3', '4']} size="sm" readOnly>
|
|
100
|
+
<PinInput.Label>只读遮罩示例</PinInput.Label>
|
|
101
|
+
<PinInput.Control>
|
|
102
|
+
{[0, 1, 2, 3].map((index) => (
|
|
103
|
+
<PinInput.Input key={index} index={index} />
|
|
104
|
+
))}
|
|
105
|
+
</PinInput.Control>
|
|
106
|
+
</PinInput.Root>
|
|
107
|
+
<p role="status">
|
|
108
|
+
{completed ? '输入完成' : '等待输入'};仅展示本地状态,不发送验证码。
|
|
109
|
+
</p>
|
|
110
|
+
</div>
|
|
111
|
+
<div className={css({ display: 'flex', gap: '3' })}>
|
|
112
|
+
<Button type="submit">读取本地 FormData</Button>
|
|
113
|
+
<Button type="reset" variant="outline">
|
|
114
|
+
重置
|
|
115
|
+
</Button>
|
|
116
|
+
</div>
|
|
117
|
+
<pre role="status" className={css({ whiteSpace: 'pre-wrap', overflowWrap: 'anywhere' })}>
|
|
118
|
+
{submittedForm}
|
|
119
|
+
</pre>
|
|
120
|
+
</form>
|
|
121
|
+
</div>
|
|
122
|
+
)
|
|
123
|
+
},
|
|
124
|
+
}
|
|
125
|
+
export const Customization: Story = {
|
|
126
|
+
render: function Customization() {
|
|
127
|
+
return (
|
|
128
|
+
<div className={css({ display: 'grid', gap: '4', maxWidth: '4xl' })}>
|
|
129
|
+
<PinInput.Root size="unstyled" name="compact-pin" count={4} gap="1.5">
|
|
130
|
+
<PinInput.Label>自定尺寸的验证码</PinInput.Label>
|
|
131
|
+
<PinInput.Control gap="1.5">
|
|
132
|
+
{[0, 1, 2, 3].map((index) => (
|
|
133
|
+
<PinInput.Input key={index} index={index} width="36px" height="36px" textStyle="sm" />
|
|
134
|
+
))}
|
|
135
|
+
</PinInput.Control>
|
|
136
|
+
<PinInput.HiddenInput />
|
|
137
|
+
</PinInput.Root>
|
|
138
|
+
<PinInput.Root variant="unstyled" count={4} defaultValue={['1', '2', '3', '4']}>
|
|
139
|
+
<PinInput.Label>自定外观的验证码</PinInput.Label>
|
|
140
|
+
<PinInput.Control>
|
|
141
|
+
{[0, 1, 2, 3].map((index) => (
|
|
142
|
+
<PinInput.Input
|
|
143
|
+
key={index}
|
|
144
|
+
index={index}
|
|
145
|
+
bg="lime.3"
|
|
146
|
+
borderRadius="lg"
|
|
147
|
+
focusVisibleRing="inside"
|
|
148
|
+
/>
|
|
149
|
+
))}
|
|
150
|
+
</PinInput.Control>
|
|
151
|
+
</PinInput.Root>
|
|
152
|
+
</div>
|
|
153
|
+
)
|
|
154
|
+
},
|
|
155
|
+
}
|