@knk1313/plain-ui 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +86 -2
- package/dist/components/accordion/Accordion.d.ts +27 -0
- package/dist/components/accordion/Accordion.js +18 -0
- package/dist/components/accordion/index.d.ts +1 -0
- package/dist/components/accordion/index.js +1 -0
- package/dist/components/agent-form/AgentForm.d.ts +40 -0
- package/dist/components/agent-form/AgentForm.js +100 -0
- package/dist/components/agent-form/index.d.ts +1 -0
- package/dist/components/agent-form/index.js +1 -0
- package/dist/components/agent-steps/AgentSteps.d.ts +21 -0
- package/dist/components/agent-steps/AgentSteps.js +42 -0
- package/dist/components/agent-steps/index.d.ts +1 -0
- package/dist/components/agent-steps/index.js +1 -0
- package/dist/components/agent-thinking/AgentThinking.d.ts +12 -0
- package/dist/components/agent-thinking/AgentThinking.js +18 -0
- package/dist/components/agent-thinking/index.d.ts +1 -0
- package/dist/components/agent-thinking/index.js +1 -0
- package/dist/components/area-chart/AreaChart.d.ts +10 -0
- package/dist/components/area-chart/AreaChart.js +83 -0
- package/dist/components/area-chart/index.d.ts +1 -0
- package/dist/components/area-chart/index.js +1 -0
- package/dist/components/auth-card/AuthCard.d.ts +14 -0
- package/dist/components/auth-card/AuthCard.js +9 -0
- package/dist/components/auth-card/PasswordInput.d.ts +13 -0
- package/dist/components/auth-card/PasswordInput.js +26 -0
- package/dist/components/auth-card/index.d.ts +2 -0
- package/dist/components/auth-card/index.js +2 -0
- package/dist/components/avatar/Avatar.d.ts +14 -0
- package/dist/components/avatar/Avatar.js +42 -0
- package/dist/components/avatar/index.d.ts +1 -0
- package/dist/components/avatar/index.js +1 -0
- package/dist/components/badge/Badge.d.ts +9 -0
- package/dist/components/badge/Badge.js +15 -0
- package/dist/components/badge/index.d.ts +1 -0
- package/dist/components/badge/index.js +1 -0
- package/dist/components/banner/Banner.d.ts +9 -0
- package/dist/components/banner/Banner.js +36 -0
- package/dist/components/banner/index.d.ts +1 -0
- package/dist/components/banner/index.js +1 -0
- package/dist/components/bar-chart/BarChart.d.ts +3 -0
- package/dist/components/bar-chart/BarChart.js +47 -0
- package/dist/components/bar-chart/index.d.ts +1 -0
- package/dist/components/bar-chart/index.js +1 -0
- package/dist/components/bar-list/BarList.d.ts +26 -0
- package/dist/components/bar-list/BarList.js +24 -0
- package/dist/components/bar-list/index.d.ts +1 -0
- package/dist/components/bar-list/index.js +1 -0
- package/dist/components/breadcrumb/Breadcrumb.d.ts +12 -0
- package/dist/components/breadcrumb/Breadcrumb.js +9 -0
- package/dist/components/breadcrumb/index.d.ts +1 -0
- package/dist/components/breadcrumb/index.js +1 -0
- package/dist/components/button/Button.d.ts +24 -0
- package/dist/components/button/Button.js +31 -0
- package/dist/components/button/buttonStyle.d.ts +9 -0
- package/dist/components/button/buttonStyle.js +41 -0
- package/dist/components/button/index.d.ts +1 -0
- package/dist/components/button/index.js +1 -0
- package/dist/components/button-group/ButtonGroup.d.ts +18 -0
- package/dist/components/button-group/ButtonGroup.js +26 -0
- package/dist/components/button-group/index.d.ts +1 -0
- package/dist/components/button-group/index.js +1 -0
- package/dist/components/calendar/Calendar.d.ts +20 -0
- package/dist/components/calendar/Calendar.js +98 -0
- package/dist/components/calendar/index.d.ts +1 -0
- package/dist/components/calendar/index.js +1 -0
- package/dist/components/calendar-view/CalendarView.d.ts +34 -0
- package/dist/components/calendar-view/CalendarView.js +111 -0
- package/dist/components/calendar-view/index.d.ts +1 -0
- package/dist/components/calendar-view/index.js +1 -0
- package/dist/components/card/Card.d.ts +6 -0
- package/dist/components/card/Card.js +6 -0
- package/dist/components/card/index.d.ts +1 -0
- package/dist/components/card/index.js +1 -0
- package/dist/components/carousel/Carousel.d.ts +18 -0
- package/dist/components/carousel/Carousel.js +58 -0
- package/dist/components/carousel/index.d.ts +1 -0
- package/dist/components/carousel/index.js +1 -0
- package/dist/components/chart/Axis.d.ts +51 -0
- package/dist/components/chart/Axis.js +127 -0
- package/dist/components/chart/ChartFrame.d.ts +79 -0
- package/dist/components/chart/ChartFrame.js +80 -0
- package/dist/components/chart/ChartTooltip.d.ts +12 -0
- package/dist/components/chart/ChartTooltip.js +57 -0
- package/dist/components/chart/Legend.d.ts +11 -0
- package/dist/components/chart/Legend.js +6 -0
- package/dist/components/chart/Sparkline.d.ts +5 -0
- package/dist/components/chart/Sparkline.js +20 -0
- package/dist/components/chart/format.d.ts +2 -0
- package/dist/components/chart/format.js +17 -0
- package/dist/components/chart/heatmap.d.ts +18 -0
- package/dist/components/chart/heatmap.js +47 -0
- package/dist/components/chart/index.d.ts +1 -0
- package/dist/components/chart/index.js +1 -0
- package/dist/components/chart/line.d.ts +1 -0
- package/dist/components/chart/line.js +15 -0
- package/dist/components/chart/scale.d.ts +15 -0
- package/dist/components/chart/scale.js +100 -0
- package/dist/components/chart/series.d.ts +44 -0
- package/dist/components/chart/series.js +86 -0
- package/dist/components/chart/spacing.d.ts +29 -0
- package/dist/components/chart/spacing.js +34 -0
- package/dist/components/chart/types.d.ts +29 -0
- package/dist/components/chart/types.js +2 -0
- package/dist/components/chart/useChartHover.d.ts +34 -0
- package/dist/components/chart/useChartHover.js +97 -0
- package/dist/components/checkbox/Checkbox.d.ts +10 -0
- package/dist/components/checkbox/Checkbox.js +38 -0
- package/dist/components/checkbox/index.d.ts +1 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/chip/Chip.d.ts +21 -0
- package/dist/components/chip/Chip.js +10 -0
- package/dist/components/chip/index.d.ts +1 -0
- package/dist/components/chip/index.js +1 -0
- package/dist/components/close-button/CloseButton.d.ts +14 -0
- package/dist/components/close-button/CloseButton.js +9 -0
- package/dist/components/close-button/index.d.ts +1 -0
- package/dist/components/close-button/index.js +1 -0
- package/dist/components/color-picker/ColorPicker.d.ts +21 -0
- package/dist/components/color-picker/ColorPicker.js +20 -0
- package/dist/components/color-picker/index.d.ts +1 -0
- package/dist/components/color-picker/index.js +1 -0
- package/dist/components/combo-chart/ComboChart.d.ts +12 -0
- package/dist/components/combo-chart/ComboChart.js +84 -0
- package/dist/components/combo-chart/index.d.ts +1 -0
- package/dist/components/combo-chart/index.js +1 -0
- package/dist/components/combobox/Combobox.d.ts +33 -0
- package/dist/components/combobox/Combobox.js +246 -0
- package/dist/components/combobox/index.d.ts +1 -0
- package/dist/components/combobox/index.js +1 -0
- package/dist/components/command-palette/CommandPalette.d.ts +36 -0
- package/dist/components/command-palette/CommandPalette.js +156 -0
- package/dist/components/command-palette/index.d.ts +1 -0
- package/dist/components/command-palette/index.js +1 -0
- package/dist/components/composer/Composer.d.ts +32 -0
- package/dist/components/composer/Composer.js +101 -0
- package/dist/components/composer/index.d.ts +1 -0
- package/dist/components/composer/index.js +1 -0
- package/dist/components/composer-attachments/ComposerAttachments.d.ts +25 -0
- package/dist/components/composer-attachments/ComposerAttachments.js +52 -0
- package/dist/components/composer-attachments/index.d.ts +1 -0
- package/dist/components/composer-attachments/index.js +1 -0
- package/dist/components/composer-panel/ComposerPanel.d.ts +26 -0
- package/dist/components/composer-panel/ComposerPanel.js +154 -0
- package/dist/components/composer-panel/index.d.ts +1 -0
- package/dist/components/composer-panel/index.js +1 -0
- package/dist/components/contribution-chart/ContributionChart.d.ts +25 -0
- package/dist/components/contribution-chart/ContributionChart.js +127 -0
- package/dist/components/contribution-chart/index.d.ts +1 -0
- package/dist/components/contribution-chart/index.js +1 -0
- package/dist/components/data-grid/DataGrid.d.ts +40 -0
- package/dist/components/data-grid/DataGrid.js +157 -0
- package/dist/components/data-grid/index.d.ts +1 -0
- package/dist/components/data-grid/index.js +1 -0
- package/dist/components/data-table/DataTable.d.ts +87 -0
- package/dist/components/data-table/DataTable.js +150 -0
- package/dist/components/data-table/index.d.ts +2 -0
- package/dist/components/data-table/index.js +2 -0
- package/dist/components/data-table/query.d.ts +54 -0
- package/dist/components/data-table/query.js +70 -0
- package/dist/components/date-picker/DatePicker.d.ts +25 -0
- package/dist/components/date-picker/DatePicker.js +154 -0
- package/dist/components/date-picker/index.d.ts +1 -0
- package/dist/components/date-picker/index.js +1 -0
- package/dist/components/dialog/ConfirmDialog.d.ts +25 -0
- package/dist/components/dialog/ConfirmDialog.js +69 -0
- package/dist/components/dialog/Dialog.d.ts +25 -0
- package/dist/components/dialog/Dialog.js +11 -0
- package/dist/components/dialog/DialogFrame.d.ts +22 -0
- package/dist/components/dialog/DialogFrame.js +21 -0
- package/dist/components/dialog/DiscardChangesDialog.d.ts +10 -0
- package/dist/components/dialog/DiscardChangesDialog.js +10 -0
- package/dist/components/dialog/index.d.ts +2 -0
- package/dist/components/dialog/index.js +2 -0
- package/dist/components/dialog/useDiscardOnClose.d.ts +20 -0
- package/dist/components/dialog/useDiscardOnClose.js +26 -0
- package/dist/components/dialog/useModalDialog.d.ts +20 -0
- package/dist/components/dialog/useModalDialog.js +85 -0
- package/dist/components/drawer/Drawer.d.ts +14 -0
- package/dist/components/drawer/Drawer.js +22 -0
- package/dist/components/drawer/index.d.ts +1 -0
- package/dist/components/drawer/index.js +1 -0
- package/dist/components/empty-state/EmptyState.d.ts +11 -0
- package/dist/components/empty-state/EmptyState.js +7 -0
- package/dist/components/empty-state/index.d.ts +1 -0
- package/dist/components/empty-state/index.js +1 -0
- package/dist/components/error-state/ErrorState.d.ts +8 -0
- package/dist/components/error-state/ErrorState.js +7 -0
- package/dist/components/error-state/index.d.ts +1 -0
- package/dist/components/error-state/index.js +1 -0
- package/dist/components/error-summary/ErrorSummary.d.ts +21 -0
- package/dist/components/error-summary/ErrorSummary.js +16 -0
- package/dist/components/error-summary/index.d.ts +1 -0
- package/dist/components/error-summary/index.js +1 -0
- package/dist/components/field/Field.d.ts +23 -0
- package/dist/components/field/Field.js +20 -0
- package/dist/components/field/index.d.ts +1 -0
- package/dist/components/field/index.js +1 -0
- package/dist/components/field-error/FieldError.d.ts +10 -0
- package/dist/components/field-error/FieldError.js +52 -0
- package/dist/components/field-error/index.d.ts +1 -0
- package/dist/components/field-error/index.js +1 -0
- package/dist/components/file-upload/FileUpload.d.ts +50 -0
- package/dist/components/file-upload/FileUpload.js +169 -0
- package/dist/components/file-upload/fileSize.d.ts +1 -0
- package/dist/components/file-upload/fileSize.js +13 -0
- package/dist/components/file-upload/index.d.ts +1 -0
- package/dist/components/file-upload/index.js +1 -0
- package/dist/components/form-section/FormSection.d.ts +16 -0
- package/dist/components/form-section/FormSection.js +14 -0
- package/dist/components/form-section/index.d.ts +1 -0
- package/dist/components/form-section/index.js +1 -0
- package/dist/components/form-steps/FormSteps.d.ts +18 -0
- package/dist/components/form-steps/FormSteps.js +26 -0
- package/dist/components/form-steps/index.d.ts +1 -0
- package/dist/components/form-steps/index.js +1 -0
- package/dist/components/funnel-chart/FunnelChart.d.ts +12 -0
- package/dist/components/funnel-chart/FunnelChart.js +69 -0
- package/dist/components/funnel-chart/index.d.ts +1 -0
- package/dist/components/funnel-chart/index.js +1 -0
- package/dist/components/header/Header.d.ts +14 -0
- package/dist/components/header/Header.js +31 -0
- package/dist/components/header/index.d.ts +1 -0
- package/dist/components/header/index.js +1 -0
- package/dist/components/heatmap-chart/HeatmapChart.d.ts +10 -0
- package/dist/components/heatmap-chart/HeatmapChart.js +76 -0
- package/dist/components/heatmap-chart/index.d.ts +1 -0
- package/dist/components/heatmap-chart/index.js +1 -0
- package/dist/components/image-error/ImageError.d.ts +11 -0
- package/dist/components/image-error/ImageError.js +16 -0
- package/dist/components/image-error/index.d.ts +1 -0
- package/dist/components/image-error/index.js +1 -0
- package/dist/components/image-loader/ImageLoader.d.ts +9 -0
- package/dist/components/image-loader/ImageLoader.js +10 -0
- package/dist/components/image-loader/index.d.ts +1 -0
- package/dist/components/image-loader/index.js +1 -0
- package/dist/components/index.d.ts +98 -0
- package/dist/components/index.js +97 -0
- package/dist/components/input/Input.d.ts +6 -0
- package/dist/components/input/Input.js +8 -0
- package/dist/components/input/index.d.ts +1 -0
- package/dist/components/input/index.js +1 -0
- package/dist/components/input/inputStyle.d.ts +14 -0
- package/dist/components/input/inputStyle.js +35 -0
- package/dist/components/item-range/ItemRange.d.ts +11 -0
- package/dist/components/item-range/ItemRange.js +13 -0
- package/dist/components/item-range/index.d.ts +1 -0
- package/dist/components/item-range/index.js +1 -0
- package/dist/components/label/Label.d.ts +8 -0
- package/dist/components/label/Label.js +5 -0
- package/dist/components/label/index.d.ts +1 -0
- package/dist/components/label/index.js +1 -0
- package/dist/components/line-chart/LineChart.d.ts +10 -0
- package/dist/components/line-chart/LineChart.js +29 -0
- package/dist/components/line-chart/index.d.ts +1 -0
- package/dist/components/line-chart/index.js +1 -0
- package/dist/components/link-button/LinkButton.d.ts +29 -0
- package/dist/components/link-button/LinkButton.js +15 -0
- package/dist/components/link-button/index.d.ts +1 -0
- package/dist/components/link-button/index.js +1 -0
- package/dist/components/menu/Menu.d.ts +33 -0
- package/dist/components/menu/Menu.js +113 -0
- package/dist/components/menu/index.d.ts +1 -0
- package/dist/components/menu/index.js +1 -0
- package/dist/components/meter/Meter.d.ts +24 -0
- package/dist/components/meter/Meter.js +65 -0
- package/dist/components/meter/index.d.ts +1 -0
- package/dist/components/meter/index.js +1 -0
- package/dist/components/nav-group/NavGroup.d.ts +24 -0
- package/dist/components/nav-group/NavGroup.js +23 -0
- package/dist/components/nav-group/index.d.ts +1 -0
- package/dist/components/nav-group/index.js +1 -0
- package/dist/components/notification/Notification.d.ts +25 -0
- package/dist/components/notification/Notification.js +13 -0
- package/dist/components/notification/index.d.ts +1 -0
- package/dist/components/notification/index.js +1 -0
- package/dist/components/notification-center/NotificationCenter.d.ts +33 -0
- package/dist/components/notification-center/NotificationCenter.js +29 -0
- package/dist/components/notification-center/index.d.ts +1 -0
- package/dist/components/notification-center/index.js +1 -0
- package/dist/components/number-field/NumberField.d.ts +28 -0
- package/dist/components/number-field/NumberField.js +155 -0
- package/dist/components/number-field/index.d.ts +1 -0
- package/dist/components/number-field/index.js +1 -0
- package/dist/components/otp-input/OtpInput.d.ts +14 -0
- package/dist/components/otp-input/OtpInput.js +70 -0
- package/dist/components/otp-input/index.d.ts +1 -0
- package/dist/components/otp-input/index.js +1 -0
- package/dist/components/pagination/Pagination.d.ts +21 -0
- package/dist/components/pagination/Pagination.js +51 -0
- package/dist/components/pagination/index.d.ts +1 -0
- package/dist/components/pagination/index.js +1 -0
- package/dist/components/popover/Popover.d.ts +23 -0
- package/dist/components/popover/Popover.js +83 -0
- package/dist/components/popover/index.d.ts +1 -0
- package/dist/components/popover/index.js +1 -0
- package/dist/components/progress/Progress.d.ts +12 -0
- package/dist/components/progress/Progress.js +30 -0
- package/dist/components/progress/index.d.ts +1 -0
- package/dist/components/progress/index.js +1 -0
- package/dist/components/question-form/QuestionForm.d.ts +59 -0
- package/dist/components/question-form/QuestionForm.js +128 -0
- package/dist/components/question-form/index.d.ts +1 -0
- package/dist/components/question-form/index.js +1 -0
- package/dist/components/radar-chart/RadarChart.d.ts +3 -0
- package/dist/components/radar-chart/RadarChart.js +72 -0
- package/dist/components/radar-chart/geometry.d.ts +16 -0
- package/dist/components/radar-chart/geometry.js +56 -0
- package/dist/components/radar-chart/index.d.ts +1 -0
- package/dist/components/radar-chart/index.js +1 -0
- package/dist/components/radial-chart/RadialChart.d.ts +39 -0
- package/dist/components/radial-chart/RadialChart.js +135 -0
- package/dist/components/radial-chart/index.d.ts +1 -0
- package/dist/components/radial-chart/index.js +1 -0
- package/dist/components/radio/Radio.d.ts +31 -0
- package/dist/components/radio/Radio.js +24 -0
- package/dist/components/radio/index.d.ts +1 -0
- package/dist/components/radio/index.js +1 -0
- package/dist/components/reply-loader/ReplyLoader.d.ts +10 -0
- package/dist/components/reply-loader/ReplyLoader.js +9 -0
- package/dist/components/reply-loader/index.d.ts +1 -0
- package/dist/components/reply-loader/index.js +1 -0
- package/dist/components/sankey-chart/SankeyChart.d.ts +35 -0
- package/dist/components/sankey-chart/SankeyChart.js +218 -0
- package/dist/components/sankey-chart/index.d.ts +1 -0
- package/dist/components/sankey-chart/index.js +1 -0
- package/dist/components/scatter-chart/ScatterChart.d.ts +38 -0
- package/dist/components/scatter-chart/ScatterChart.js +69 -0
- package/dist/components/scatter-chart/index.d.ts +1 -0
- package/dist/components/scatter-chart/index.js +1 -0
- package/dist/components/search-field/SearchField.d.ts +17 -0
- package/dist/components/search-field/SearchField.js +92 -0
- package/dist/components/search-field/index.d.ts +1 -0
- package/dist/components/search-field/index.js +1 -0
- package/dist/components/segmented-control/SegmentedControl.d.ts +26 -0
- package/dist/components/segmented-control/SegmentedControl.js +38 -0
- package/dist/components/segmented-control/index.d.ts +1 -0
- package/dist/components/segmented-control/index.js +1 -0
- package/dist/components/select/Select.d.ts +11 -0
- package/dist/components/select/Select.js +30 -0
- package/dist/components/select/index.d.ts +1 -0
- package/dist/components/select/index.js +1 -0
- package/dist/components/separator/Separator.d.ts +14 -0
- package/dist/components/separator/Separator.js +12 -0
- package/dist/components/separator/index.d.ts +1 -0
- package/dist/components/separator/index.js +1 -0
- package/dist/components/settings-modal/SettingsModal.d.ts +35 -0
- package/dist/components/settings-modal/SettingsModal.js +120 -0
- package/dist/components/settings-modal/index.d.ts +1 -0
- package/dist/components/settings-modal/index.js +1 -0
- package/dist/components/sidebar/Sidebar.d.ts +30 -0
- package/dist/components/sidebar/Sidebar.js +30 -0
- package/dist/components/sidebar/index.d.ts +1 -0
- package/dist/components/sidebar/index.js +1 -0
- package/dist/components/skeleton/Skeleton.d.ts +6 -0
- package/dist/components/skeleton/Skeleton.js +6 -0
- package/dist/components/skeleton/index.d.ts +1 -0
- package/dist/components/skeleton/index.js +1 -0
- package/dist/components/skip-link/SkipLink.d.ts +8 -0
- package/dist/components/skip-link/SkipLink.js +10 -0
- package/dist/components/skip-link/index.d.ts +1 -0
- package/dist/components/skip-link/index.js +1 -0
- package/dist/components/slider/Slider.d.ts +19 -0
- package/dist/components/slider/Slider.js +49 -0
- package/dist/components/slider/index.d.ts +1 -0
- package/dist/components/slider/index.js +1 -0
- package/dist/components/spinner/Spinner.d.ts +5 -0
- package/dist/components/spinner/Spinner.js +7 -0
- package/dist/components/spinner/index.d.ts +1 -0
- package/dist/components/spinner/index.js +1 -0
- package/dist/components/stacked-bar/StackedBar.d.ts +29 -0
- package/dist/components/stacked-bar/StackedBar.js +77 -0
- package/dist/components/stacked-bar/index.d.ts +1 -0
- package/dist/components/stacked-bar/index.js +1 -0
- package/dist/components/stat-card/StatCard.d.ts +19 -0
- package/dist/components/stat-card/StatCard.js +32 -0
- package/dist/components/stat-card/index.d.ts +1 -0
- package/dist/components/stat-card/index.js +1 -0
- package/dist/components/switch/Switch.d.ts +10 -0
- package/dist/components/switch/Switch.js +22 -0
- package/dist/components/switch/index.d.ts +1 -0
- package/dist/components/switch/index.js +1 -0
- package/dist/components/table/SortableHeader.d.ts +12 -0
- package/dist/components/table/SortableHeader.js +11 -0
- package/dist/components/table/Table.d.ts +15 -0
- package/dist/components/table/Table.js +26 -0
- package/dist/components/table/align.d.ts +1 -0
- package/dist/components/table/align.js +5 -0
- package/dist/components/table/index.d.ts +4 -0
- package/dist/components/table/index.js +2 -0
- package/dist/components/tabs/Tabs.d.ts +38 -0
- package/dist/components/tabs/Tabs.js +137 -0
- package/dist/components/tabs/fitTabs.d.ts +18 -0
- package/dist/components/tabs/fitTabs.js +46 -0
- package/dist/components/tabs/index.d.ts +1 -0
- package/dist/components/tabs/index.js +1 -0
- package/dist/components/tag-group/TagGroup.d.ts +29 -0
- package/dist/components/tag-group/TagGroup.js +82 -0
- package/dist/components/tag-group/index.d.ts +1 -0
- package/dist/components/tag-group/index.js +1 -0
- package/dist/components/task-list/TaskList.d.ts +46 -0
- package/dist/components/task-list/TaskList.js +30 -0
- package/dist/components/task-list/index.d.ts +1 -0
- package/dist/components/task-list/index.js +1 -0
- package/dist/components/text-link/TextLink.d.ts +27 -0
- package/dist/components/text-link/TextLink.js +22 -0
- package/dist/components/text-link/index.d.ts +1 -0
- package/dist/components/text-link/index.js +1 -0
- package/dist/components/textarea/Textarea.d.ts +6 -0
- package/dist/components/textarea/Textarea.js +9 -0
- package/dist/components/textarea/index.d.ts +1 -0
- package/dist/components/textarea/index.js +1 -0
- package/dist/components/time-field/TimeField.d.ts +6 -0
- package/dist/components/time-field/TimeField.js +9 -0
- package/dist/components/time-field/index.d.ts +1 -0
- package/dist/components/time-field/index.js +1 -0
- package/dist/components/toast/Toast.d.ts +19 -0
- package/dist/components/toast/Toast.js +190 -0
- package/dist/components/toast/index.d.ts +1 -0
- package/dist/components/toast/index.js +1 -0
- package/dist/components/token-input/TokenInput.d.ts +27 -0
- package/dist/components/token-input/TokenInput.js +153 -0
- package/dist/components/token-input/index.d.ts +1 -0
- package/dist/components/token-input/index.js +1 -0
- package/dist/components/tooltip/Tooltip.d.ts +17 -0
- package/dist/components/tooltip/Tooltip.js +144 -0
- package/dist/components/tooltip/index.d.ts +1 -0
- package/dist/components/tooltip/index.js +1 -0
- package/dist/components/tree-view/TreeView.d.ts +29 -0
- package/dist/components/tree-view/TreeView.js +140 -0
- package/dist/components/tree-view/index.d.ts +1 -0
- package/dist/components/tree-view/index.js +1 -0
- package/dist/components/unsaved-changes/index.d.ts +1 -0
- package/dist/components/unsaved-changes/index.js +1 -0
- package/dist/components/unsaved-changes/useUnsavedChanges.d.ts +12 -0
- package/dist/components/unsaved-changes/useUnsavedChanges.js +45 -0
- package/dist/components/usage-limit/UsageLimit.d.ts +15 -0
- package/dist/components/usage-limit/UsageLimit.js +21 -0
- package/dist/components/usage-limit/index.d.ts +1 -0
- package/dist/components/usage-limit/index.js +1 -0
- package/dist/components/web-search-results/WebSearchResults.d.ts +21 -0
- package/dist/components/web-search-results/WebSearchResults.js +17 -0
- package/dist/components/web-search-results/index.d.ts +1 -0
- package/dist/components/web-search-results/index.js +1 -0
- package/dist/lib/anchor.d.ts +21 -0
- package/dist/lib/anchor.js +50 -0
- package/dist/lib/cn.d.ts +1 -0
- package/dist/lib/cn.js +5 -0
- package/dist/lib/date.d.ts +77 -0
- package/dist/lib/date.js +165 -0
- package/dist/lib/icon-message.d.ts +16 -0
- package/dist/lib/icon-message.js +7 -0
- package/dist/lib/number.d.ts +1 -0
- package/dist/lib/number.js +5 -0
- package/dist/lib/slot.d.ts +8 -0
- package/dist/lib/slot.js +53 -0
- package/dist/lib/variant.d.ts +1 -0
- package/dist/lib/variant.js +1 -0
- package/docs/a11y.md +320 -0
- package/docs/chart/axis.md +82 -0
- package/docs/chart/color.md +120 -0
- package/docs/chart/drawing.md +283 -0
- package/docs/chart/reading.md +79 -0
- package/docs/chart/size-and-spacing.md +85 -0
- package/docs/chart.md +47 -0
- package/docs/color/contrast.md +80 -0
- package/docs/color/data-viz.md +66 -0
- package/docs/color/foundation.md +91 -0
- package/docs/color/neutral.md +88 -0
- package/docs/color/state.md +111 -0
- package/docs/color.md +22 -0
- package/docs/components/accordion.md +51 -0
- package/docs/components/agent-form.md +56 -0
- package/docs/components/agent-steps.md +75 -0
- package/docs/components/agent-thinking.md +70 -0
- package/docs/components/area-chart.md +55 -0
- package/docs/components/auth-card.md +126 -0
- package/docs/components/avatar.md +38 -0
- package/docs/components/badge.md +28 -0
- package/docs/components/banner.md +19 -0
- package/docs/components/bar-list.md +77 -0
- package/docs/components/button-group.md +74 -0
- package/docs/components/button.md +49 -0
- package/docs/components/calendar-view.md +106 -0
- package/docs/components/calendar.md +44 -0
- package/docs/components/carousel.md +81 -0
- package/docs/components/chart.md +45 -0
- package/docs/components/chat-message.md +199 -0
- package/docs/components/checkbox.md +27 -0
- package/docs/components/chip.md +34 -0
- package/docs/components/choosing.md +26 -0
- package/docs/components/close-button.md +17 -0
- package/docs/components/color-picker.md +52 -0
- package/docs/components/combo-chart.md +74 -0
- package/docs/components/combobox.md +60 -0
- package/docs/components/command-palette.md +151 -0
- package/docs/components/composer-attachments.md +116 -0
- package/docs/components/composer-panel.md +106 -0
- package/docs/components/composer.md +163 -0
- package/docs/components/contribution-chart.md +70 -0
- package/docs/components/data-grid.md +132 -0
- package/docs/components/data-table.md +165 -0
- package/docs/components/date-picker.md +120 -0
- package/docs/components/dialog.md +211 -0
- package/docs/components/drawer.md +38 -0
- package/docs/components/empty-state.md +17 -0
- package/docs/components/error-state.md +13 -0
- package/docs/components/error-summary.md +49 -0
- package/docs/components/field.md +84 -0
- package/docs/components/file-upload.md +161 -0
- package/docs/components/focus.md +25 -0
- package/docs/components/form-section.md +49 -0
- package/docs/components/form-steps.md +63 -0
- package/docs/components/funnel-chart.md +49 -0
- package/docs/components/heatmap-chart.md +64 -0
- package/docs/components/image-error.md +73 -0
- package/docs/components/image-loader.md +53 -0
- package/docs/components/input.md +21 -0
- package/docs/components/item-range.md +10 -0
- package/docs/components/link-button.md +16 -0
- package/docs/components/menu.md +115 -0
- package/docs/components/meter.md +83 -0
- package/docs/components/nav-group.md +33 -0
- package/docs/components/notification-center.md +100 -0
- package/docs/components/notification.md +127 -0
- package/docs/components/number-field.md +128 -0
- package/docs/components/otp-input.md +86 -0
- package/docs/components/pagination.md +29 -0
- package/docs/components/popover.md +43 -0
- package/docs/components/progress.md +25 -0
- package/docs/components/prohibitions.md +58 -0
- package/docs/components/props.md +20 -0
- package/docs/components/question-form.md +125 -0
- package/docs/components/radar-chart.md +61 -0
- package/docs/components/radial-chart.md +74 -0
- package/docs/components/radio.md +24 -0
- package/docs/components/reply-loader.md +80 -0
- package/docs/components/sankey-chart.md +71 -0
- package/docs/components/scatter-chart.md +61 -0
- package/docs/components/search-field.md +44 -0
- package/docs/components/segmented-control.md +35 -0
- package/docs/components/select.md +28 -0
- package/docs/components/separator.md +23 -0
- package/docs/components/settings-modal.md +128 -0
- package/docs/components/sidebar.md +145 -0
- package/docs/components/skeleton.md +27 -0
- package/docs/components/skip-link.md +17 -0
- package/docs/components/slider.md +82 -0
- package/docs/components/spinner.md +8 -0
- package/docs/components/stacked-bar.md +66 -0
- package/docs/components/stat-card.md +78 -0
- package/docs/components/switch.md +61 -0
- package/docs/components/table.md +43 -0
- package/docs/components/tabs.md +104 -0
- package/docs/components/tag-group.md +115 -0
- package/docs/components/task-list.md +99 -0
- package/docs/components/text-link.md +17 -0
- package/docs/components/textarea.md +27 -0
- package/docs/components/time-field.md +97 -0
- package/docs/components/toast.md +73 -0
- package/docs/components/token-input.md +135 -0
- package/docs/components/tooltip.md +41 -0
- package/docs/components/tree-view.md +71 -0
- package/docs/components/usage-limit.md +47 -0
- package/docs/components/web-search-results.md +60 -0
- package/docs/components.md +234 -0
- package/docs/design.md +31 -0
- package/docs/form/clearing-errors.md +28 -0
- package/docs/form/error-announcement.md +69 -0
- package/docs/form/long-forms.md +103 -0
- package/docs/form/placeholder.md +40 -0
- package/docs/form/submit-errors.md +102 -0
- package/docs/form/submitting.md +72 -0
- package/docs/form/unsaved-changes.md +146 -0
- package/docs/form/validation-timing.md +44 -0
- package/docs/form.md +39 -0
- package/docs/glossary.md +169 -0
- package/docs/icon.md +245 -0
- package/docs/interaction/before.md +64 -0
- package/docs/interaction/motion.md +38 -0
- package/docs/interaction/pending.md +38 -0
- package/docs/interaction/permissions.md +133 -0
- package/docs/interaction/result.md +38 -0
- package/docs/interaction/states.md +159 -0
- package/docs/interaction.md +31 -0
- package/docs/layout/alignment.md +145 -0
- package/docs/layout/hit-area.md +58 -0
- package/docs/layout/mobile.md +200 -0
- package/docs/layout/responsive.md +73 -0
- package/docs/layout/scroll.md +51 -0
- package/docs/layout/surface.md +110 -0
- package/docs/layout.md +31 -0
- package/docs/list/board.md +85 -0
- package/docs/list/paging.md +146 -0
- package/docs/list/search.md +98 -0
- package/docs/list/toolbar.md +91 -0
- package/docs/list.md +39 -0
- package/docs/log.md +94 -0
- package/docs/manual.md +183 -0
- package/docs/navigation/header-and-transition.md +82 -0
- package/docs/navigation/location.md +68 -0
- package/docs/navigation/menu-items.md +152 -0
- package/docs/navigation/menu-structure.md +68 -0
- package/docs/navigation.md +23 -0
- package/docs/publish.md +26 -0
- package/docs/rules.md +246 -0
- package/docs/scenario.md +218 -0
- package/docs/spacing/placement.md +219 -0
- package/docs/spacing/radius.md +45 -0
- package/docs/spacing/scale.md +91 -0
- package/docs/spacing.md +17 -0
- package/docs/typography.md +233 -0
- package/docs/writing/date-and-number.md +25 -0
- package/docs/writing/error-and-empty.md +58 -0
- package/docs/writing/label-and-button.md +124 -0
- package/docs/writing/tone.md +156 -0
- package/docs/writing.md +27 -0
- package/icons/index.d.ts +1 -0
- package/icons/index.js +3 -0
- package/package.json +117 -4
- package/scripts/lint/colors.mjs +103 -0
- package/scripts/lint/deps.mjs +33 -0
- package/scripts/lint/icons.mjs +177 -0
- package/scripts/lint/interaction.mjs +163 -0
- package/scripts/lint/layout.mjs +103 -0
- package/scripts/lint/markup.mjs +271 -0
- package/scripts/lint/shared.mjs +340 -0
- package/scripts/lint/spacing.mjs +70 -0
- package/scripts/lint/typography.mjs +141 -0
- package/scripts/lint/writing.mjs +107 -0
- package/scripts/lint.mjs +166 -0
- package/scripts/plain-ui-lint.mjs +33 -0
- package/tokens/tokens.css +482 -0
- package/tokens/tokens.values.json +234 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type FieldsetHTMLAttributes } from "react";
|
|
2
|
+
/** 選んだファイルの一覧の1件 */
|
|
3
|
+
export interface FileUploadItem {
|
|
4
|
+
/** 一覧の中で重ならない値。部品がファイルを足すときに付ける。名前が同じファイルも見分けられる */
|
|
5
|
+
id: string;
|
|
6
|
+
/** 選んだファイル。送るときは、使う側で FormData などに入れる */
|
|
7
|
+
file: File;
|
|
8
|
+
/** 送っている間は true。progress を渡さなければ、スピナーと「アップロード中」を出す */
|
|
9
|
+
uploading?: boolean;
|
|
10
|
+
/** 送った割合(0〜100)。uploading の間に渡すと、スピナーの代わりに Progress の棒を出す */
|
|
11
|
+
progress?: number;
|
|
12
|
+
/** そのファイルのエラー(送れなかったなど)。次に取れる行動を書く。渡している間は、送っている間の表示より優先する */
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
15
|
+
type AcceptProps = {
|
|
16
|
+
/** 受け付ける種類。input の accept と同じ書き方(".pdf,.png"、"image/*"、"application/pdf")。ドラッグして落としたファイルも、同じ条件で確かめる */
|
|
17
|
+
accept: string;
|
|
18
|
+
/** エラーの文言に入れる、種類の言い方。「PDFかPNG」のように書く(「PDFかPNGのファイルを選択してください。」になる) */
|
|
19
|
+
acceptLabel: string;
|
|
20
|
+
} | {
|
|
21
|
+
accept?: undefined;
|
|
22
|
+
acceptLabel?: undefined;
|
|
23
|
+
};
|
|
24
|
+
export type FileUploadProps = Omit<FieldsetHTMLAttributes<HTMLFieldSetElement>, "onChange" | "children" | "disabled" | "defaultValue"> & AcceptProps & {
|
|
25
|
+
/** 項目の名前。`<legend>` に書く(例:「添付ファイル」) */
|
|
26
|
+
legend: string;
|
|
27
|
+
/** 選んだファイルの一覧。部品はファイルを持たず、使う側が持つ */
|
|
28
|
+
value: FileUploadItem[];
|
|
29
|
+
/** ファイルを足したときと、取り消したときに、次の一覧で呼ぶ */
|
|
30
|
+
onChange: (value: FileUploadItem[]) => void;
|
|
31
|
+
/** 1個のファイルの大きさの上限(バイト)。超えたファイルは足さず、エラーを出す */
|
|
32
|
+
maxSize?: number;
|
|
33
|
+
/** ファイルの数の上限。1のときは1個だけ選べ、選び直すと入れ替わる。超えるときは足さず、エラーを出す */
|
|
34
|
+
maxFiles?: number;
|
|
35
|
+
/** 必須の項目。`<legend>` の後ろに「必須」と書く。確かめるのは使う側 */
|
|
36
|
+
required?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* 押せなくする。ファイルを選ぶボタンと取り消すボタンを aria-disabled にし(フォーカスは止まる)、落としたファイルも足さない。
|
|
39
|
+
* 押せない理由を description に書く(docs/interaction/states.md の押せない状態)
|
|
40
|
+
*/
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
/** 使う側が確かめたエラー(「ファイルを添付してください。」など)。ないときは省く */
|
|
43
|
+
error?: string;
|
|
44
|
+
/** 受け付ける種類、大きさ、数のような、選ぶ前に知っておくことを書いた補足の説明 */
|
|
45
|
+
description?: string;
|
|
46
|
+
/** 外側の配置(余白と幅)だけに使う */
|
|
47
|
+
className?: string;
|
|
48
|
+
};
|
|
49
|
+
export declare function FileUpload({ legend, value, onChange, accept, acceptLabel, maxSize, maxFiles, required, disabled, error, description, className, "aria-describedby": describedBy, ...props }: FileUploadProps): import("react").JSX.Element;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
3
|
+
import { FileIcon, XIcon } from "lucide-react";
|
|
4
|
+
import { Button } from "../button/Button.js";
|
|
5
|
+
import { FieldError } from "../field-error/FieldError.js";
|
|
6
|
+
import { Progress } from "../progress/Progress.js";
|
|
7
|
+
import { Spinner } from "../spinner/Spinner.js";
|
|
8
|
+
import { cn } from "../../lib/cn.js";
|
|
9
|
+
import { formatFileSize } from "./fileSize.js";
|
|
10
|
+
// 受け付ける種類に合うか。拡張子(".pdf")は名前の末尾で、"image/*" は種類の前半で、それ以外は種類そのもので比べる
|
|
11
|
+
function matchesAccept(file, accept) {
|
|
12
|
+
const name = file.name.toLowerCase();
|
|
13
|
+
const type = file.type.toLowerCase();
|
|
14
|
+
return accept
|
|
15
|
+
.split(",")
|
|
16
|
+
.map(token => token.trim().toLowerCase())
|
|
17
|
+
.filter(Boolean)
|
|
18
|
+
.some(token => {
|
|
19
|
+
if (token.startsWith("."))
|
|
20
|
+
return name.endsWith(token);
|
|
21
|
+
if (token.endsWith("/*"))
|
|
22
|
+
return type.startsWith(token.slice(0, -1));
|
|
23
|
+
return type === token;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
// エラーの文言に入れるファイルの名前。利用者が付けた名前なので、かぎ括弧で1組だけ囲む(docs/writing.md)
|
|
27
|
+
function namesOf(files) {
|
|
28
|
+
return files.length === 1 ? `「${files[0].name}」` : `「${files[0].name}」ほか${files.length - 1}個`;
|
|
29
|
+
}
|
|
30
|
+
// ファイルを選ぶボタンを必ず置き、ドラッグして落とす操作は、その上に足す(docs/a11y.md の A11Y-003 と同じ考え方)。
|
|
31
|
+
// ファイルを選ぶ窓はネイティブの <input type="file"> に任せ、見えない input をボタンから開く。
|
|
32
|
+
// 部品は送る処理を持たない。選んだファイルを onChange で渡し、送っている間と失敗は、一覧の各件に使う側から渡す
|
|
33
|
+
export function FileUpload({ legend, value, onChange, accept, acceptLabel, maxSize, maxFiles, required, disabled = false, error, description, className, "aria-describedby": describedBy, ...props }) {
|
|
34
|
+
const baseId = useId();
|
|
35
|
+
const errorId = `${baseId}-error`;
|
|
36
|
+
const descriptionId = `${baseId}-description`;
|
|
37
|
+
const fieldsetRef = useRef(null);
|
|
38
|
+
const inputRef = useRef(null);
|
|
39
|
+
const nextId = useRef(0);
|
|
40
|
+
// 子の要素の上を通るたびに dragenter と dragleave が来るので、数えて、外に出たときだけ戻す
|
|
41
|
+
const dragDepth = useRef(0);
|
|
42
|
+
const [dragging, setDragging] = useState(false);
|
|
43
|
+
// 種類、大きさ、数で足さなかったファイルのエラー。足さなかったファイルは使う側に渡らないので、部品の中で持つ
|
|
44
|
+
const [rejections, setRejections] = useState([]);
|
|
45
|
+
// 足したこと、取り消したことを読み上げる文言(docs/a11y.md の A11Y-011)
|
|
46
|
+
const [status, setStatus] = useState("");
|
|
47
|
+
// 取り消した後にフォーカスを移す先。一覧を描き直した後に移す(docs/a11y.md の A11Y-006)
|
|
48
|
+
const focusAfter = useRef(null);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
const target = focusAfter.current;
|
|
51
|
+
if (target === null)
|
|
52
|
+
return;
|
|
53
|
+
focusAfter.current = null;
|
|
54
|
+
const buttons = fieldsetRef.current?.querySelectorAll("[data-file-upload-target]") ?? [];
|
|
55
|
+
for (const button of buttons) {
|
|
56
|
+
if (button.dataset.fileUploadTarget === target) {
|
|
57
|
+
button.focus();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}, [value]);
|
|
62
|
+
const single = maxFiles === 1;
|
|
63
|
+
const addFiles = (files) => {
|
|
64
|
+
if (disabled || files.length === 0)
|
|
65
|
+
return;
|
|
66
|
+
const accepted = [];
|
|
67
|
+
const wrongType = [];
|
|
68
|
+
const tooLarge = [];
|
|
69
|
+
for (const file of files) {
|
|
70
|
+
if (accept !== undefined && !matchesAccept(file, accept))
|
|
71
|
+
wrongType.push(file);
|
|
72
|
+
else if (maxSize !== undefined && file.size > maxSize)
|
|
73
|
+
tooLarge.push(file);
|
|
74
|
+
else
|
|
75
|
+
accepted.push(file);
|
|
76
|
+
}
|
|
77
|
+
const messages = [];
|
|
78
|
+
if (wrongType.length > 0)
|
|
79
|
+
messages.push(`${namesOf(wrongType)}は追加できませんでした。${acceptLabel}のファイルを選択してください。`);
|
|
80
|
+
if (tooLarge.length > 0 && maxSize !== undefined) {
|
|
81
|
+
messages.push(`${namesOf(tooLarge)}は追加できませんでした。${formatFileSize(maxSize)}以下のファイルを選択してください。`);
|
|
82
|
+
}
|
|
83
|
+
const toItem = (file) => ({ id: `${baseId}-${nextId.current++}`, file });
|
|
84
|
+
let next;
|
|
85
|
+
if (accepted.length > 0) {
|
|
86
|
+
if (single) {
|
|
87
|
+
// 1個だけのときは、選び直すと入れ替える
|
|
88
|
+
if (accepted.length === 1)
|
|
89
|
+
next = [toItem(accepted[0])];
|
|
90
|
+
else
|
|
91
|
+
messages.push("ファイルは1個だけ添付できます。1個を選択してください。");
|
|
92
|
+
}
|
|
93
|
+
else if (maxFiles !== undefined && value.length + accepted.length > maxFiles) {
|
|
94
|
+
// 一部だけを黙って足すと、どれが足されたか分からないので、まとめて足さない
|
|
95
|
+
const rest = maxFiles - value.length;
|
|
96
|
+
messages.push(rest > 0
|
|
97
|
+
? `ファイルは${maxFiles}個まで添付できます。あと${rest}個まで選択してください。`
|
|
98
|
+
: `ファイルは${maxFiles}個まで添付できます。追加するには、選んだファイルを取り消してください。`);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
next = [...value, ...accepted.map(toItem)];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
setRejections(messages);
|
|
105
|
+
if (next) {
|
|
106
|
+
const added = next.filter(item => !value.includes(item)).length;
|
|
107
|
+
setStatus(`${added}個のファイルを追加しました。`);
|
|
108
|
+
onChange(next);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const remove = (index) => {
|
|
112
|
+
if (disabled)
|
|
113
|
+
return;
|
|
114
|
+
const item = value[index];
|
|
115
|
+
// 次の件、なければ前の件の取り消すボタンへ。どちらもなければ、ファイルを選ぶボタンへ移す
|
|
116
|
+
focusAfter.current = value[index + 1]?.id ?? value[index - 1]?.id ?? "select";
|
|
117
|
+
setRejections([]);
|
|
118
|
+
setStatus(`「${item.file.name}」の選択を取り消しました。`);
|
|
119
|
+
onChange(value.filter((_, i) => i !== index));
|
|
120
|
+
};
|
|
121
|
+
const onInputChange = (event) => {
|
|
122
|
+
addFiles(Array.from(event.target.files ?? []));
|
|
123
|
+
// 同じファイルをもう一度選んでも change が来るように、input は空に戻す。ファイルは value で持つ
|
|
124
|
+
event.target.value = "";
|
|
125
|
+
};
|
|
126
|
+
const hasFiles = (event) => Array.from(event.dataTransfer.types).includes("Files");
|
|
127
|
+
const onDragEnter = (event) => {
|
|
128
|
+
if (!hasFiles(event))
|
|
129
|
+
return;
|
|
130
|
+
event.preventDefault();
|
|
131
|
+
// 押せない間は、落とせる場所に見せない
|
|
132
|
+
if (disabled)
|
|
133
|
+
return;
|
|
134
|
+
dragDepth.current += 1;
|
|
135
|
+
setDragging(true);
|
|
136
|
+
};
|
|
137
|
+
const onDragOver = (event) => {
|
|
138
|
+
if (!hasFiles(event))
|
|
139
|
+
return;
|
|
140
|
+
// 既定の振る舞い(ブラウザがファイルを開く)を止め、落とせる場所にする。
|
|
141
|
+
// 押せない間も既定の振る舞いは止め、落とせないこと(none)をカーソルで示す
|
|
142
|
+
event.preventDefault();
|
|
143
|
+
event.dataTransfer.dropEffect = disabled ? "none" : "copy";
|
|
144
|
+
};
|
|
145
|
+
const onDragLeave = () => {
|
|
146
|
+
dragDepth.current = Math.max(dragDepth.current - 1, 0);
|
|
147
|
+
if (dragDepth.current === 0)
|
|
148
|
+
setDragging(false);
|
|
149
|
+
};
|
|
150
|
+
const onDrop = (event) => {
|
|
151
|
+
event.preventDefault();
|
|
152
|
+
dragDepth.current = 0;
|
|
153
|
+
setDragging(false);
|
|
154
|
+
addFiles(Array.from(event.dataTransfer.files));
|
|
155
|
+
};
|
|
156
|
+
const errors = [...rejections, ...(error ? [error] : [])];
|
|
157
|
+
const hasError = errors.length > 0;
|
|
158
|
+
return (_jsxs("fieldset", { ref: fieldsetRef, className: cn("min-w-0", className), "aria-describedby": describedBy, "aria-disabled": disabled || undefined, ...props, children: [_jsxs("legend", { className: "mb-2 text-sm font-medium leading-tight text-foreground", children: [legend, required && _jsx("span", { className: "font-normal text-muted-foreground", children: "\uFF08\u5FC5\u9808\uFF09" })] }), _jsxs("div", { onDragEnter: onDragEnter, onDragOver: onDragOver, onDragLeave: onDragLeave, onDrop: onDrop, className: cn("flex flex-col items-center gap-2 rounded-lg border border-dashed p-6 text-center pointer-coarse:items-start pointer-coarse:border-0 pointer-coarse:p-0", dragging ? "border-primary bg-secondary" : "border-input",
|
|
159
|
+
// 押せない間は、枠と案内を薄くし、カーソルを禁止の形にする。ボタンは Button が薄くする
|
|
160
|
+
disabled && "cursor-not-allowed border-input/50"), children: [_jsx("input", { ref: inputRef, type: "file", hidden: true, accept: accept, multiple: !single, onChange: onInputChange }), _jsx(Button, { "data-file-upload-target": "select", disabled: disabled, onClick: () => inputRef.current?.click(), "aria-describedby": cn(hasError && errorId, description && descriptionId) || undefined, children: "\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E\u3059\u308B" }), _jsx("p", { className: cn("text-sm leading-relaxed text-muted-foreground pointer-coarse:hidden", disabled && "opacity-50"), children: "\u3053\u3053\u306B\u30C9\u30E9\u30C3\u30B0\u3057\u3066\u3082\u8FFD\u52A0\u3067\u304D\u307E\u3059\u3002" })] }), _jsx(FieldError, { id: errorId, className: "*:mt-2", children: hasError &&
|
|
161
|
+
errors.map(message => (_jsx("span", { className: "block", children: message }, message))) }), description && (_jsx("p", { id: descriptionId, className: "mt-2 text-sm leading-relaxed text-muted-foreground", children: description })), value.length > 0 && (_jsx("ul", { "aria-label": "\u9078\u3093\u3060\u30D5\u30A1\u30A4\u30EB", className: "mt-4 divide-y rounded-lg border", children: value.map((item, index) => (_jsx(FileUploadRow, { item: item, disabled: disabled, onRemove: () => remove(index) }, item.id))) })), _jsx("span", { role: "status", className: "sr-only", children: status })] }));
|
|
162
|
+
}
|
|
163
|
+
// 一覧の1行。名前と大きさの行を44pxにし、取り消すボタン(44px)と中央をそろえる。
|
|
164
|
+
// 送っている間とエラーは、名前の行の下に出す
|
|
165
|
+
function FileUploadRow({ item, disabled, onRemove }) {
|
|
166
|
+
const { id, file, uploading, progress, error } = item;
|
|
167
|
+
const errorId = `${id}-error`;
|
|
168
|
+
return (_jsxs("li", { className: "flex items-start gap-2 pl-4", children: [_jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("div", { className: "flex min-h-11 items-center gap-2 text-sm", children: [_jsx(FileIcon, { "aria-hidden": "true", className: "size-4 shrink-0 text-muted-foreground" }), _jsx("span", { className: "min-w-0 truncate text-foreground", children: file.name }), _jsx("span", { className: "shrink-0 tabular-nums text-muted-foreground", children: formatFileSize(file.size) })] }), !error && uploading && (_jsx("div", { className: "pb-4", children: progress !== undefined ? (_jsx(Progress, { value: progress, showValue: true, "aria-label": `「${file.name}」のアップロード` })) : (_jsxs("p", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [_jsx(Spinner, {}), _jsx("span", { children: "\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u4E2D" })] })) })), _jsx(FieldError, { id: errorId, className: "*:pb-2", children: error })] }), _jsx(Button, { variant: "ghost", size: "icon", "data-file-upload-target": id, "aria-label": `「${file.name}」の選択を取り消す`, "aria-describedby": error ? errorId : undefined, disabled: disabled, onClick: onRemove, children: _jsx(XIcon, { "aria-hidden": "true", className: "size-4" }) })] }));
|
|
169
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatFileSize(bytes: number): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// ファイルの大きさを「12.8 MB」のように書く(docs/writing/date-and-number.md の「日付、数値、単位」)。
|
|
2
|
+
// 1,024 ごとに単位を上げ、小数は必要な桁だけ(1桁まで)書く。数値と単位の記号の間には半角スペースを入れる
|
|
3
|
+
const formatter = new Intl.NumberFormat("ja-JP", { maximumFractionDigits: 1 });
|
|
4
|
+
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
5
|
+
export function formatFileSize(bytes) {
|
|
6
|
+
let value = Math.max(bytes, 0);
|
|
7
|
+
let unit = 0;
|
|
8
|
+
while (value >= 1024 && unit < units.length - 1) {
|
|
9
|
+
value /= 1024;
|
|
10
|
+
unit += 1;
|
|
11
|
+
}
|
|
12
|
+
return `${formatter.format(value)} ${units[unit]}`;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./FileUpload.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./FileUpload.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type FormSectionLevel = 2 | 3;
|
|
3
|
+
export interface FormSectionProps {
|
|
4
|
+
/** まとまりの見出し。「基本の情報」「共有の設定」のように、中の項目をまとめる名前を書く */
|
|
5
|
+
title: string;
|
|
6
|
+
/**
|
|
7
|
+
* 見出しの階層。ページの見出しに続けて、内容の構造で選ぶ(A11Y-001、COMPONENTS-047)。
|
|
8
|
+
* ページの h1 の下に置くなら 2、ダイアログ(タイトルが h2)の中や h2 の節の中に置くなら 3。省いたときは 2
|
|
9
|
+
*/
|
|
10
|
+
level?: FormSectionLevel;
|
|
11
|
+
/** Field のような入力欄を並べる。項目どうしは M(space-y-4)で離す */
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
/** 外側の配置(余白と幅)だけに使う */
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function FormSection({ title, level, children, className }: FormSectionProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../lib/cn.js";
|
|
3
|
+
// 見出しの大きさは、docs/typography.md のサイズの表の h2 と h3 に合わせる
|
|
4
|
+
const headingStyle = {
|
|
5
|
+
2: "text-xl font-semibold leading-normal text-foreground",
|
|
6
|
+
3: "text-lg font-medium leading-normal text-foreground",
|
|
7
|
+
};
|
|
8
|
+
// まとまりどうしは、親の space-y-8 で離す(docs/spacing/placement.md の「セクションどうしの間」)。
|
|
9
|
+
// section には名前を付けない。名前を付けるとランドマーク(region)になり、まとまりの数だけランドマークが増えて、移動の一覧が埋まるため。
|
|
10
|
+
// 見出しの一覧から、まとまりへ移れる
|
|
11
|
+
export function FormSection({ title, level = 2, children, className }) {
|
|
12
|
+
const Heading = level === 3 ? "h3" : "h2";
|
|
13
|
+
return (_jsxs("section", { className: cn("space-y-4", className), children: [_jsx(Heading, { className: headingStyle[level], children: title }), _jsx("div", { className: "space-y-4", children: children })] }));
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./FormSection.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./FormSection.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type FormStepsLevel = 2 | 3;
|
|
3
|
+
export interface FormStepsProps {
|
|
4
|
+
/** 手順の名前を、通る順に並べる(「共有する相手」「共有の範囲」「確認」)。2つ以上渡す */
|
|
5
|
+
steps: string[];
|
|
6
|
+
/** 今の手順。steps の中の位置で、0から数える。範囲の外の値は、最初か最後の手順に寄せる */
|
|
7
|
+
current: number;
|
|
8
|
+
/**
|
|
9
|
+
* 今の手順の見出しの階層。ページの見出しに続けて、内容の構造で選ぶ(A11Y-001)。
|
|
10
|
+
* ページの h1 の下に置くなら 2、ダイアログ(タイトルが h2)の中に置くなら 3。省いたときは 2
|
|
11
|
+
*/
|
|
12
|
+
level?: FormStepsLevel;
|
|
13
|
+
/** 今の手順の入力欄と、進む・戻る・送信のボタン */
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
/** 外側の配置(余白と幅)だけに使う */
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function FormSteps({ steps, current, level, children, className }: FormStepsProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
// 見出しの大きさは、docs/typography.md のサイズの表の h2 と h3 に合わせる
|
|
5
|
+
const headingStyle = {
|
|
6
|
+
2: "text-xl font-semibold leading-normal text-foreground",
|
|
7
|
+
3: "text-lg font-medium leading-normal text-foreground",
|
|
8
|
+
};
|
|
9
|
+
export function FormSteps({ steps, current, level = 2, children, className }) {
|
|
10
|
+
const index = Math.min(Math.max(current, 0), steps.length - 1);
|
|
11
|
+
const headingRef = useRef(null);
|
|
12
|
+
const shownIndex = useRef(index);
|
|
13
|
+
// 手順を移ったら、新しい手順の見出しへフォーカスを移す(FORM-016)。
|
|
14
|
+
// 最初に描いたときは移さない。ページを開いた直後に、フォーカスを勝手に動かさないため
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (shownIndex.current === index)
|
|
17
|
+
return;
|
|
18
|
+
shownIndex.current = index;
|
|
19
|
+
headingRef.current?.focus();
|
|
20
|
+
}, [index]);
|
|
21
|
+
const Heading = level === 3 ? "h3" : "h2";
|
|
22
|
+
return (_jsxs("div", { className: cn("space-y-6", className), children: [_jsx("ol", { "aria-label": "\u624B\u9806", className: "flex flex-wrap gap-x-6 gap-y-2", children: steps.map((name, i) => {
|
|
23
|
+
const isCurrent = i === index;
|
|
24
|
+
return (_jsxs("li", { "aria-current": isCurrent ? "step" : undefined, className: "flex items-center gap-2 text-sm leading-tight", children: [_jsx("span", { "aria-hidden": "true", className: cn("flex size-6 shrink-0 items-center justify-center rounded-full border text-sm leading-none tabular-nums", isCurrent ? "border-primary bg-primary text-primary-foreground" : "text-muted-foreground"), children: i + 1 }), _jsxs("span", { className: isCurrent ? "font-medium text-foreground" : "text-muted-foreground", children: [name, isCurrent && (_jsx("span", { "aria-hidden": "true", className: "font-normal text-muted-foreground", children: "\uFF08\u4ECA\u306E\u624B\u9806\uFF09" }))] })] }, i));
|
|
25
|
+
}) }), _jsxs(Heading, { ref: headingRef, tabIndex: -1, className: cn(headingStyle[level], "outline-none"), children: ["\u624B\u9806", index + 1, "/", steps.length, "\uFF1A", steps[index]] }), _jsx("div", { children: children })] }));
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./FormSteps.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./FormSteps.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ChartProps } from "../chart/types.js";
|
|
2
|
+
export interface FunnelChartProps extends Omit<ChartProps, "series" | "valueLabel" | "categoryLabel" | "height"> {
|
|
3
|
+
/** 段階の名前(「訪問」「カートに追加」「購入」)。利用者が進む順に並べる。値の大きい順に並べ替えない */
|
|
4
|
+
labels: readonly string[];
|
|
5
|
+
/** 段階ごとの数。labels と同じ順・同じ数で並べ、値のない段階は null にする */
|
|
6
|
+
values: ReadonlyArray<number | null>;
|
|
7
|
+
/** 数えるものの名前(「人数」)。値の表の列の見出しと、ツールチップに出す。省いたときは「数」 */
|
|
8
|
+
valueLabel?: string;
|
|
9
|
+
/** 段階の名前の列の見出し。値の表の1列目の見出しにする。省いたときは「段階」 */
|
|
10
|
+
categoryLabel?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function FunnelChart({ labels, values, valueLabel, categoryLabel, ...props }: FunnelChartProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import { ChartFrame } from "../chart/ChartFrame.js";
|
|
5
|
+
import { ChartTooltip } from "../chart/ChartTooltip.js";
|
|
6
|
+
import { formatValue } from "../chart/format.js";
|
|
7
|
+
import { AXIS_FONT_SIZE, textWidth, truncate } from "../chart/scale.js";
|
|
8
|
+
import { BarSwatch, SERIES_FILL, safeId } from "../chart/series.js";
|
|
9
|
+
import { LABEL_GAP, STAGE_GAP } from "../chart/spacing.js";
|
|
10
|
+
import { ChartTooltipContent, useChartHover } from "../chart/useChartHover.js";
|
|
11
|
+
// 前の段階から進んだ割合の列の見出し。値の表とツールチップで同じ言葉を使う
|
|
12
|
+
const RATE_LABEL = "前の段階から進んだ割合";
|
|
13
|
+
// 棒の太さ(px)。間隔ではなく形の値(docs/chart/size-and-spacing.md の「間隔」の表の外)
|
|
14
|
+
const BAR_HEIGHT = 24;
|
|
15
|
+
// 1つの段階の高さ:名前と値の行、名前と棒の間(S)、棒
|
|
16
|
+
const ROW_HEIGHT = AXIS_FONT_SIZE + LABEL_GAP + BAR_HEIGHT;
|
|
17
|
+
// 前の段階から進んだ割合(%)。小数第1位までにする。前の段階か、この段階の値がない(null)か、前の段階が0のときは null
|
|
18
|
+
function stageRate(values, index) {
|
|
19
|
+
if (index === 0)
|
|
20
|
+
return null;
|
|
21
|
+
const current = values[index];
|
|
22
|
+
const previous = values[index - 1];
|
|
23
|
+
if (typeof current !== "number" || !Number.isFinite(current))
|
|
24
|
+
return null;
|
|
25
|
+
if (typeof previous !== "number" || !Number.isFinite(previous) || previous <= 0)
|
|
26
|
+
return null;
|
|
27
|
+
return Math.round((current / previous) * 1000) / 10;
|
|
28
|
+
}
|
|
29
|
+
// 値の表の割合の列に書く文字。最初の段階には前の段階がないので「—」、割合を出せない段階は「値なし」にする
|
|
30
|
+
function rateCell(values, index) {
|
|
31
|
+
return index === 0 ? "—" : formatValue(stageRate(values, index), "%");
|
|
32
|
+
}
|
|
33
|
+
// 段階ごとの数と、前の段階から進んだ割合を見せる。台形ではなく、横の棒を段階の順に上から並べ、数と割合を文字で添える(docs/chart/drawing.md の CHART-016)。
|
|
34
|
+
// 棒の長さは、いちばん大きい段階の数を幅いっぱいにした割合にし、左端を0にそろえる(CHART-003)。
|
|
35
|
+
// 系列は1つなので、白黒(chart-1)で塗り、凡例は出さない。値の軸の目盛りは置かず、数は棒の上に文字で書く
|
|
36
|
+
export function FunnelChart({ labels, values, valueLabel = "数", categoryLabel = "段階", ...props }) {
|
|
37
|
+
const id = safeId(useId());
|
|
38
|
+
const series = [{ name: valueLabel, values }];
|
|
39
|
+
// 図の高さは、段階の数で決める(段階どうしの間は M)
|
|
40
|
+
const height = labels.length > 0 ? labels.length * ROW_HEIGHT + (labels.length - 1) * STAGE_GAP : undefined;
|
|
41
|
+
return (_jsx(ChartFrame, { ...props, component: "FunnelChart", labels: labels, series: series, valueLabel: valueLabel, categoryLabel: categoryLabel, height: height, valueAxis: false, extraColumns: [{ name: RATE_LABEL, cells: labels.map((_, i) => rateCell(values, i)) }], swatch: i => _jsx(BarSwatch, { id: `${id}-legend-${i}`, index: i }), children: size => _jsx(FunnelPlot, { labels: labels, values: values, valueLabel: valueLabel, unit: props.unit, ...size }) }));
|
|
42
|
+
}
|
|
43
|
+
function FunnelPlot({ labels, values, valueLabel, unit, width, height }) {
|
|
44
|
+
const plot = { left: 0, top: 0, width, height };
|
|
45
|
+
const hover = useChartHover(plot, labels.length, "y");
|
|
46
|
+
const numbers = values.filter((v) => typeof v === "number" && Number.isFinite(v));
|
|
47
|
+
const max = Math.max(0, ...numbers);
|
|
48
|
+
const valueTexts = labels.map((_, i) => formatValue(values[i] ?? null, unit));
|
|
49
|
+
const rateTexts = labels.map((_, i) => {
|
|
50
|
+
const rate = stageRate(values, i);
|
|
51
|
+
return rate === null ? "" : `前の段階の${formatValue(rate, "%")}`;
|
|
52
|
+
});
|
|
53
|
+
// 値は右端にそろえ、割合は値の列の左に M あけて右端をそろえる。名前は、割合の列(なければ値の列)の左に M あけた所までに収める
|
|
54
|
+
const valueColumn = Math.max(...valueTexts.map(t => textWidth(t)));
|
|
55
|
+
const rateColumn = Math.max(0, ...rateTexts.map(t => textWidth(t)));
|
|
56
|
+
const rateRight = width - valueColumn - STAGE_GAP;
|
|
57
|
+
const nameRoom = Math.max(0, (rateColumn > 0 ? rateRight - rateColumn : width - valueColumn) - STAGE_GAP);
|
|
58
|
+
const band = height / Math.max(labels.length, 1);
|
|
59
|
+
const active = hover.index;
|
|
60
|
+
return (_jsxs(_Fragment, { children: [_jsxs("svg", { "aria-hidden": "true", width: width, height: height, className: "block overflow-visible", children: [active !== null && _jsx("rect", { x: 0, y: band * active, width: width, height: band, className: "fill-muted" }), labels.map((label, i) => {
|
|
61
|
+
const top = i * (ROW_HEIGHT + STAGE_GAP);
|
|
62
|
+
const value = values[i];
|
|
63
|
+
const length = typeof value === "number" && Number.isFinite(value) && value > 0 && max > 0 ? Math.max(1, (value / max) * width) : 0;
|
|
64
|
+
return (_jsxs("g", { children: [_jsx("text", { x: 0, y: top, dominantBaseline: "hanging", className: "fill-muted-foreground text-xs", children: truncate(label, nameRoom) }), rateTexts[i] && (_jsx("text", { x: rateRight, y: top, textAnchor: "end", dominantBaseline: "hanging", className: "fill-muted-foreground text-xs tabular-nums", children: rateTexts[i] })), _jsx("text", { x: width, y: top, textAnchor: "end", dominantBaseline: "hanging", className: "fill-foreground text-xs tabular-nums", children: valueTexts[i] }), length > 0 && (_jsx("rect", { x: 0, y: top + AXIS_FONT_SIZE + LABEL_GAP, width: length, height: BAR_HEIGHT, className: SERIES_FILL[0] }))] }, i));
|
|
65
|
+
}), _jsx("rect", { x: 0, y: 0, width: width, height: height, fill: "transparent", ...hover.handlers })] }), _jsx(ChartTooltip, { position: hover.position, onDismiss: hover.dismiss, children: active !== null && (_jsx(ChartTooltipContent, { label: labels[active] ?? "", rows: [
|
|
66
|
+
{ name: valueLabel, value: valueTexts[active] ?? "" },
|
|
67
|
+
...(active > 0 ? [{ name: RATE_LABEL, value: rateCell(values, active) }] : []),
|
|
68
|
+
] })) })] }));
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./FunnelChart.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./FunnelChart.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface HeaderProps {
|
|
3
|
+
/** 左端に置く、アプリの名前やロゴ。ページ名は置かない */
|
|
4
|
+
brand: ReactNode;
|
|
5
|
+
/** 768px未満で、メニューのボタンから左のドロワーで開くナビゲーション。NavLink と NavGroup を並べる */
|
|
6
|
+
nav: ReactNode;
|
|
7
|
+
/** メニューの名前。ドロワーの見出しと、ドロワーの中の nav の aria-label になる。省いたときは「メニュー」 */
|
|
8
|
+
navLabel?: string;
|
|
9
|
+
/** 通知やユーザーメニューのような、どの画面にも共通の機能。その画面だけの操作は置かない */
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
/** 外側の配置だけに使う */
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function Header({ brand, nav, navLabel, children, className }: HeaderProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { MenuIcon } from "lucide-react";
|
|
5
|
+
import { Button } from "../button/Button.js";
|
|
6
|
+
import { Drawer } from "../drawer/Drawer.js";
|
|
7
|
+
import { cn } from "../../lib/cn.js";
|
|
8
|
+
// 768px(Tailwind の md)以上かどうか。md: のクラスと同じ境目で、ドロワーを閉じる
|
|
9
|
+
const WIDE_QUERY = "(min-width: 48rem)";
|
|
10
|
+
// 画面の上に固定するヘッダー。768px以上ではメニューを Sidebar で常に表示するので、開くボタンは768px未満だけに出す。
|
|
11
|
+
// 768px未満のメニューは、Sidebar のドロワーと同じく、左から出すドロワー(Drawer)で開く
|
|
12
|
+
export function Header({ brand, nav, navLabel = "メニュー", children, className }) {
|
|
13
|
+
const [open, setOpen] = useState(false);
|
|
14
|
+
// ドロワーを開いたまま画面が768px以上に広がったら閉じる。広い画面では Sidebar の区画がいつも出ているので、ドロワーは要らない
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!open || typeof matchMedia !== "function")
|
|
17
|
+
return;
|
|
18
|
+
const query = matchMedia(WIDE_QUERY);
|
|
19
|
+
const closeIfWide = () => {
|
|
20
|
+
if (query.matches)
|
|
21
|
+
setOpen(false);
|
|
22
|
+
};
|
|
23
|
+
closeIfWide();
|
|
24
|
+
query.addEventListener("change", closeIfWide);
|
|
25
|
+
return () => query.removeEventListener("change", closeIfWide);
|
|
26
|
+
}, [open]);
|
|
27
|
+
return (_jsxs("header", { className: cn("sticky top-0 z-10 border-b bg-background", className), children: [_jsxs("div", { className: "flex h-14 items-center gap-2 px-4 md:px-6", children: [_jsx("div", { className: "md:hidden", children: _jsx(Button, { variant: "ghost", size: "icon", "aria-label": "\u30E1\u30CB\u30E5\u30FC\u3092\u958B\u304F", "aria-haspopup": "dialog", onClick: () => setOpen(true), children: _jsx(MenuIcon, { "aria-hidden": "true", className: "size-4" }) }) }), _jsx("div", { className: "flex items-center font-semibold", children: brand }), _jsx("div", { className: "ml-auto flex items-center gap-2", children: children })] }), _jsx(Drawer, { open: open, onClose: () => setOpen(false), title: navLabel, side: "left", children: _jsx("nav", { "aria-label": navLabel, className: "space-y-1", onClick: event => {
|
|
28
|
+
if (event.target.closest("a[href]"))
|
|
29
|
+
setOpen(false);
|
|
30
|
+
}, children: nav }) })] }));
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Header.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Header.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ChartProps, ChartSeries } from "../chart/types.js";
|
|
2
|
+
export interface HeatmapChartProps extends Omit<ChartProps, "categoryLabel"> {
|
|
3
|
+
/** 横の軸に並べる列の名前(「9時」「12時」など) */
|
|
4
|
+
labels: readonly string[];
|
|
5
|
+
/** 行。name を縦の軸に並べ、values を labels と同じ順・同じ数で並べる。値のないセルは null にする。行の数に上限はない */
|
|
6
|
+
series: readonly ChartSeries[];
|
|
7
|
+
/** 縦の軸の名前(「曜日」)。値の表の1列目の見出しにする。省いたときは「項目」 */
|
|
8
|
+
seriesLabel?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function HeatmapChart({ seriesLabel, ...props }: HeatmapChartProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import { cn } from "../../lib/cn.js";
|
|
5
|
+
import { formatNumber } from "../../lib/number.js";
|
|
6
|
+
import { CategoryAxis } from "../chart/Axis.js";
|
|
7
|
+
import { ChartFrame } from "../chart/ChartFrame.js";
|
|
8
|
+
import { ChartTooltip } from "../chart/ChartTooltip.js";
|
|
9
|
+
import { formatValue } from "../chart/format.js";
|
|
10
|
+
import { HeatmapLegend, HeatmapSwatch, STEP_FILL, STEP_TEXT, heatmapStepOf, heatmapStepSize, isValue } from "../chart/heatmap.js";
|
|
11
|
+
import { AXIS_FONT_SIZE, LABEL_MAX, textWidth, truncate, valueRange } from "../chart/scale.js";
|
|
12
|
+
import { CELL_GAP, LABEL_GAP } from "../chart/spacing.js";
|
|
13
|
+
import { ChartTooltipContent, useChartHover } from "../chart/useChartHover.js";
|
|
14
|
+
// 正と負のある値は、薄い〜濃いの1方向の段では読み違えるので、開発時に知らせる(docs/chart/drawing.md の CHART-021)
|
|
15
|
+
function useNegativeWarning(series) {
|
|
16
|
+
const negative = series.some(s => s.values.some(v => isValue(v) && v < 0));
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (negative)
|
|
19
|
+
console.warn("HeatmapChart: 負の値は描けない。増減のように正と負のある値は、棒グラフか表で示す(docs/chart/drawing.md の CHART-021)");
|
|
20
|
+
}, [negative]);
|
|
21
|
+
}
|
|
22
|
+
// 2つの軸の組み合わせ(行と列)ごとの量を、セルの濃さで示す。
|
|
23
|
+
// 色の濃さだけで読ませず、セルに値を書き、凡例に段と値の範囲を出し、値の表とツールチップでも同じ値を読めるようにする
|
|
24
|
+
export function HeatmapChart({ seriesLabel, ...props }) {
|
|
25
|
+
useNegativeWarning(props.series);
|
|
26
|
+
const size = heatmapStepSize(Math.max(0, valueRange(props.series)[1]));
|
|
27
|
+
const hasNull = props.series.some(s => props.labels.some((_, i) => !isValue(s.values[i])));
|
|
28
|
+
const legend = _jsx(HeatmapLegend, { stepSize: size, hasNull: hasNull });
|
|
29
|
+
return (_jsx(ChartFrame, { ...props, component: "HeatmapChart", categoryLabel: seriesLabel, swatch: () => null, legend: legend, maxSeries: Infinity, seriesAsRows: true, children: box => _jsx(HeatmapPlot, { ...props, stepSize: size, ...box }) }));
|
|
30
|
+
}
|
|
31
|
+
// 描く領域の下:列の名前と描く領域の間(S)と、名前の文字の高さ(docs/chart/size-and-spacing.md の「間隔」)
|
|
32
|
+
const X_AXIS_HEIGHT = LABEL_GAP + AXIS_FONT_SIZE;
|
|
33
|
+
function HeatmapPlot({ labels, series, unit, stepSize, width, height, }) {
|
|
34
|
+
const cols = Math.max(labels.length, 1);
|
|
35
|
+
const rows = Math.max(series.length, 1);
|
|
36
|
+
// 行の名前の幅は、いちばん長い名前に合わせ、上限(96px)を超える名前は「…」で切り詰める
|
|
37
|
+
const rowLabelWidth = Math.ceil(Math.min(LABEL_MAX, Math.max(0, ...series.map(s => textWidth(s.name)))));
|
|
38
|
+
const left = rowLabelWidth + LABEL_GAP;
|
|
39
|
+
const plot = { left, top: 0, width: Math.max(width - left, 1), height: Math.max(height - X_AXIS_HEIGHT, 1) };
|
|
40
|
+
// セルどうしの間は XS(CELL_GAP)。描く領域の端には間をあけず、端のセルを領域の端にそろえる
|
|
41
|
+
const cellWidth = Math.max(1, (plot.width - CELL_GAP * (cols - 1)) / cols);
|
|
42
|
+
const cellHeight = Math.max(1, (plot.height - CELL_GAP * (rows - 1)) / rows);
|
|
43
|
+
const cellX = (col) => plot.left + col * (cellWidth + CELL_GAP);
|
|
44
|
+
const cellY = (row) => plot.top + row * (cellHeight + CELL_GAP);
|
|
45
|
+
// セルを、隣との間の半分ずつ外へ広げた帯。列の名前とマウスの位置の判定は、この帯で等分する(帯の中央がセルの中央になる)
|
|
46
|
+
const bands = { left: plot.left - CELL_GAP / 2, top: plot.top - CELL_GAP / 2, width: plot.width + CELL_GAP, height: plot.height + CELL_GAP };
|
|
47
|
+
const hover = useChartHover(bands, labels.length, "x", series.length);
|
|
48
|
+
// セルの値は、いちばん長い値がセルの端から XS 以上離れて収まるときだけ、すべてのセルに書く。
|
|
49
|
+
// 一部のセルだけに書くと、書いていないセルの値が読めないように見えるので、書くか書かないかはグラフで1つにする
|
|
50
|
+
const longest = Math.max(0, ...series.flatMap(s => s.values.filter(isValue).map(v => textWidth(formatNumber(v)))));
|
|
51
|
+
const showValues = longest + CELL_GAP * 2 <= cellWidth && AXIS_FONT_SIZE + CELL_GAP * 2 <= cellHeight;
|
|
52
|
+
// 行の名前は、上下の名前どうしが S 以上離れるように間引く
|
|
53
|
+
const rowStep = Math.max(1, Math.ceil((AXIS_FONT_SIZE + LABEL_GAP) / (cellHeight + CELL_GAP)));
|
|
54
|
+
const activeCol = hover.index;
|
|
55
|
+
const activeRow = hover.row;
|
|
56
|
+
const activeValue = activeCol !== null && activeRow !== null ? series[activeRow]?.values[activeCol] : undefined;
|
|
57
|
+
return (_jsxs(_Fragment, { children: [_jsxs("svg", { "aria-hidden": "true", width: width, height: height, className: "block overflow-visible", children: [series.map((s, row) => {
|
|
58
|
+
const y = cellY(row);
|
|
59
|
+
return (_jsxs("g", { children: [row % rowStep === 0 && (_jsx("text", { x: plot.left - LABEL_GAP, y: y + cellHeight / 2, textAnchor: "end", dominantBaseline: "middle", className: "fill-muted-foreground text-xs", children: truncate(s.name, rowLabelWidth) })), labels.map((_, col) => {
|
|
60
|
+
const x = cellX(col);
|
|
61
|
+
const value = s.values[col];
|
|
62
|
+
// 値のないセルは塗らずに、枠だけを描く(凡例の「値なし」の見本と同じ形)。0 のセルは1段目で塗り、値なしと混ぜない
|
|
63
|
+
if (!isValue(value)) {
|
|
64
|
+
return (_jsx("rect", { x: x + 0.5, y: y + 0.5, width: cellWidth - 1, height: cellHeight - 1, fill: "none", strokeWidth: "1", className: "stroke-muted-foreground" }, col));
|
|
65
|
+
}
|
|
66
|
+
const step = heatmapStepOf(value, stepSize);
|
|
67
|
+
return (_jsxs("g", { children: [_jsx("rect", { x: x, y: y, width: cellWidth, height: cellHeight, className: STEP_FILL[step] }), showValues && (_jsx("text", { x: x + cellWidth / 2, y: y + cellHeight / 2, textAnchor: "middle", dominantBaseline: "central", className: cn("text-xs tabular-nums", STEP_TEXT[step]), children: formatNumber(value) }))] }, col));
|
|
68
|
+
})] }, row));
|
|
69
|
+
}), activeCol !== null && activeRow !== null && (_jsx("rect", { x: cellX(activeCol) - 1, y: cellY(activeRow) - 1, width: cellWidth + 2, height: cellHeight + 2, fill: "none", strokeWidth: "2", className: "stroke-foreground" })), _jsx(CategoryAxis, { plot: { ...bands, height: plot.height + CELL_GAP / 2 }, labels: labels }), _jsx("rect", { x: plot.left, y: plot.top, width: plot.width, height: plot.height, fill: "transparent", ...hover.handlers })] }), _jsx(ChartTooltip, { position: hover.position, onDismiss: hover.dismiss, children: activeCol !== null && activeRow !== null && (_jsx(ChartTooltipContent, { label: labels[activeCol] ?? "", rows: [
|
|
70
|
+
{
|
|
71
|
+
name: series[activeRow]?.name ?? "",
|
|
72
|
+
swatch: _jsx(HeatmapSwatch, { step: isValue(activeValue) ? heatmapStepOf(activeValue, stepSize) : null }),
|
|
73
|
+
value: formatValue(activeValue ?? null, unit),
|
|
74
|
+
},
|
|
75
|
+
] })) })] }));
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./HeatmapChart.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./HeatmapChart.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ImageErrorProps {
|
|
2
|
+
/** 失敗した理由と、どうすればよいか。使う側が書く(例:混み合っているため、生成できませんでした。少し待ってから、もう一度生成してください。) */
|
|
3
|
+
message: string;
|
|
4
|
+
/** 「もう一度生成する」のボタンを押したときに呼ぶ。同じ頼みで生成し直す */
|
|
5
|
+
onRetry: () => void;
|
|
6
|
+
/** 失敗した旨の文言。省いたときは「画像を生成できませんでした」。並べて生成するときは「2枚目の画像を生成できませんでした」のようにする */
|
|
7
|
+
label?: string;
|
|
8
|
+
/** 生成する画像と同じ大きさ(aspect-square w-64 など)と外側の配置を渡す(ImageLoader と同じ) */
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function ImageError({ message, onRetry, label, className }: ImageErrorProps): import("react").JSX.Element;
|