@knk1313/plain-ui 0.0.0-stage → 0.1.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 +102 -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 +152 -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/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 +115 -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
|
@@ -0,0 +1,218 @@
|
|
|
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 { Table, TableBody, TableCell, TableHead, TableHeaderCell, TableRow } from "../table/Table.js";
|
|
5
|
+
import { ChartLayout } from "../chart/ChartFrame.js";
|
|
6
|
+
import { ChartTooltip } from "../chart/ChartTooltip.js";
|
|
7
|
+
import { formatValue } from "../chart/format.js";
|
|
8
|
+
import { AXIS_FONT_SIZE, LABEL_MAX, textWidth, truncate } from "../chart/scale.js";
|
|
9
|
+
import { AREA_OPACITY, MAX_SERIES, SERIES_FILL, SERIES_STROKE, seriesIndex } from "../chart/series.js";
|
|
10
|
+
import { LABEL_GAP, NODE_GAP } from "../chart/spacing.js";
|
|
11
|
+
import { ChartTooltipContent, usePointerPick } from "../chart/useChartHover.js";
|
|
12
|
+
// 項目の棒の太さ(px)。間隔ではなく形の値(docs/chart/size-and-spacing.md の「間隔」の表の外)
|
|
13
|
+
const NODE_WIDTH = 12;
|
|
14
|
+
const RATIO_LABEL = "元に対する割合";
|
|
15
|
+
const isPositive = (v) => Number.isFinite(v) && v > 0;
|
|
16
|
+
// 流れから、項目、段、量を決める。段は、最初の元(入る流れのない項目)から数えた、いちばん長い流れの数にする。
|
|
17
|
+
// 元へ戻る流れ(循環)は、段を決められないので描かない。描かないのは戻る流れだけにし、その先の流れは描く
|
|
18
|
+
function buildGraph(links) {
|
|
19
|
+
const names = [];
|
|
20
|
+
const indexOf = new Map();
|
|
21
|
+
const nodeOf = (name) => {
|
|
22
|
+
if (!indexOf.has(name)) {
|
|
23
|
+
indexOf.set(name, names.length);
|
|
24
|
+
names.push(name);
|
|
25
|
+
}
|
|
26
|
+
return indexOf.get(name);
|
|
27
|
+
};
|
|
28
|
+
const edges = links
|
|
29
|
+
.map((link, index) => ({ source: nodeOf(link.source), target: nodeOf(link.target), value: link.value, index }))
|
|
30
|
+
.filter(edge => isPositive(edge.value));
|
|
31
|
+
// 戻る流れを見つける。入る流れのない項目から順に、流れを渡した順に深さ優先でたどり、たどっている途中の項目へ戻る流れ(後退辺)を戻る流れとする。
|
|
32
|
+
// 同じ項目への流れも、たどっている途中の項目へ戻るので、ここで見つかる。入る流れのない項目からたどれない循環は、名前が先に出た項目からたどる
|
|
33
|
+
const state = names.map(() => 0); // 0:まだ、1:たどっている途中、2:たどり終えた
|
|
34
|
+
const back = new Set();
|
|
35
|
+
const visit = (node) => {
|
|
36
|
+
state[node] = 1;
|
|
37
|
+
for (const edge of edges) {
|
|
38
|
+
if (edge.source !== node)
|
|
39
|
+
continue;
|
|
40
|
+
if (state[edge.target] === 1)
|
|
41
|
+
back.add(edge.index);
|
|
42
|
+
else if (state[edge.target] === 0)
|
|
43
|
+
visit(edge.target);
|
|
44
|
+
}
|
|
45
|
+
state[node] = 2;
|
|
46
|
+
};
|
|
47
|
+
const roots = names.map((_, i) => i).filter(i => !edges.some(edge => edge.target === i));
|
|
48
|
+
for (const node of [...roots, ...names.map((_, i) => i)])
|
|
49
|
+
if (state[node] === 0)
|
|
50
|
+
visit(node);
|
|
51
|
+
const drawn = edges.filter(edge => !back.has(edge.index));
|
|
52
|
+
// 残りの流れには循環がないので、入る流れのない項目から順に、段を決める(Kahn の方法)
|
|
53
|
+
const depth = names.map(() => 0);
|
|
54
|
+
const incoming = names.map((_, i) => drawn.filter(edge => edge.target === i).length);
|
|
55
|
+
const queue = names.map((_, i) => i).filter(i => incoming[i] === 0);
|
|
56
|
+
while (queue.length > 0) {
|
|
57
|
+
const node = queue.shift();
|
|
58
|
+
for (const edge of drawn) {
|
|
59
|
+
if (edge.source !== node)
|
|
60
|
+
continue;
|
|
61
|
+
depth[edge.target] = Math.max(depth[edge.target] ?? 0, (depth[node] ?? 0) + 1);
|
|
62
|
+
incoming[edge.target] = (incoming[edge.target] ?? 0) - 1;
|
|
63
|
+
if (incoming[edge.target] === 0)
|
|
64
|
+
queue.push(edge.target);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const used = new Set(drawn.flatMap(edge => [edge.source, edge.target]));
|
|
68
|
+
const columns = Math.max(0, ...[...used].map(i => (depth[i] ?? 0) + 1));
|
|
69
|
+
const counts = Array.from({ length: columns }, () => 0);
|
|
70
|
+
const nodes = names.map((name, i) => {
|
|
71
|
+
const sum = (key) => drawn.filter(edge => edge[key] === i).reduce((total, edge) => total + edge.value, 0);
|
|
72
|
+
const column = depth[i] ?? 0;
|
|
73
|
+
const order = used.has(i) ? (counts[column] = (counts[column] ?? 0) + 1) - 1 : -1;
|
|
74
|
+
return { name, column, order, value: Math.max(sum("source"), sum("target")) };
|
|
75
|
+
});
|
|
76
|
+
return { nodes, links: drawn, columns, cyclic: [...back].sort((a, b) => a - b) };
|
|
77
|
+
}
|
|
78
|
+
// 開発時の知らせ。1つの段に6つ以上の項目があるとき(CHART-029)、元へ戻る流れがあるとき(CHART-028)、負の量を渡したとき
|
|
79
|
+
function useSankeyWarning(graph, links) {
|
|
80
|
+
const crowded = Array.from({ length: graph.columns }, (_, c) => graph.nodes.filter(n => n.column === c && n.order >= 0).length).some(n => n > MAX_SERIES);
|
|
81
|
+
const negative = links.some(link => link.value < 0);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (crowded)
|
|
84
|
+
console.warn(`SankeyChart: 1つの段の項目は${MAX_SERIES}つまでにする。小さい項目は「その他」にまとめる(docs/chart/color.md の CHART-029)`);
|
|
85
|
+
}, [crowded]);
|
|
86
|
+
const cyclic = graph.cyclic.length > 0;
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (cyclic)
|
|
89
|
+
console.warn("SankeyChart: 元の項目へ戻る流れ(同じ項目への流れを含む)は描けない。戻る流れは、別の項目の名前にするか、表で示す(docs/chart/drawing.md の CHART-028)");
|
|
90
|
+
}, [cyclic]);
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (negative)
|
|
93
|
+
console.warn("SankeyChart: 流れの量は0以上にする。負の量の流れは描かない");
|
|
94
|
+
}, [negative]);
|
|
95
|
+
}
|
|
96
|
+
// 元の量に対する、その流れの量の割合(%)。小数第1位まで
|
|
97
|
+
function ratioOf(graph, link) {
|
|
98
|
+
const source = graph.nodes.find(node => node.name === link.source);
|
|
99
|
+
if (!source || !(source.value > 0) || !Number.isFinite(link.value))
|
|
100
|
+
return null;
|
|
101
|
+
return Math.round((link.value / source.value) * 1000) / 10;
|
|
102
|
+
}
|
|
103
|
+
// 量の流れと分かれ方を、帯の太さで示す。項目は段ごとに縦の棒で並べ、名前と量を棒の横に書く。
|
|
104
|
+
// 項目の棒は、段の中の順に系列の色(chart-1〜chart-5)で塗り、流れの帯は、元の項目の色で薄く塗って、縁を元の色の線で描く。
|
|
105
|
+
// 項目は名前で、流れは両端の項目とのつながりで見分けるので、色だけで区別させない(docs/chart/color.md の CHART-002)
|
|
106
|
+
export function SankeyChart({ links, unit, valueLabel = "量", sourceLabel = "元", targetLabel = "先", ...props }) {
|
|
107
|
+
const graph = buildGraph(links);
|
|
108
|
+
useSankeyWarning(graph, links);
|
|
109
|
+
return (_jsx(ChartLayout, { ...props, component: "SankeyChart", seriesNames: [], empty: graph.links.length === 0, swatch: () => null, table: _jsxs(_Fragment, { children: [_jsxs(Table, { children: [_jsx("caption", { className: "sr-only", children: props.label }), _jsx(TableHead, { children: _jsxs(TableRow, { children: [_jsx(TableHeaderCell, { children: sourceLabel }), _jsx(TableHeaderCell, { children: targetLabel }), _jsx(TableHeaderCell, { className: "text-right", children: valueLabel }), _jsx(TableHeaderCell, { className: "text-right", children: RATIO_LABEL })] }) }), _jsx(TableBody, { children: links.map((link, i) => (_jsxs(TableRow, { children: [_jsx(TableHeaderCell, { scope: "row", children: link.source }), _jsx(TableCell, { children: link.target }), _jsx(TableCell, { className: "whitespace-nowrap text-right tabular-nums", children: formatValue(link.value, unit) }), _jsx(TableCell, { className: "whitespace-nowrap text-right tabular-nums", children: formatValue(ratioOf(graph, link), "%") })] }, i))) })] }), graph.cyclic.length > 0 && (_jsxs("p", { className: "mt-2 text-xs text-muted-foreground", children: ["\u5143\u306E\u9805\u76EE\u3078\u623B\u308B\u6D41\u308C\uFF08", graph.cyclic.map(i => `${links[i]?.source}から${links[i]?.target}`).join("、"), "\uFF09\u306F\u3001\u56F3\u306B\u63CF\u3044\u3066\u3044\u307E\u305B\u3093\u3002"] }))] }), children: size => _jsx(SankeyPlot, { graph: graph, links: links, unit: unit, valueLabel: valueLabel, ...size }) }));
|
|
110
|
+
}
|
|
111
|
+
// 3次のベジェ曲線の、t(0〜1)の位置の値
|
|
112
|
+
const bezier = (a, b, c, d, t) => (1 - t) ** 3 * a + 3 * (1 - t) ** 2 * t * b + 3 * (1 - t) * t ** 2 * c + t ** 3 * d;
|
|
113
|
+
function SankeyPlot({ graph, links, unit, valueLabel, width, height }) {
|
|
114
|
+
const { nodes, columns } = graph;
|
|
115
|
+
const visible = nodes.filter(node => node.order >= 0);
|
|
116
|
+
// 項目の名前と量の文字。名前のあとに S をあけて量を書く
|
|
117
|
+
const valueText = (node) => formatValue(node.value, unit);
|
|
118
|
+
const labelWidth = (node) => Math.min(LABEL_MAX, textWidth(node.name)) + LABEL_GAP + textWidth(valueText(node));
|
|
119
|
+
// 最初の段の名前は棒の左に、最後の段の名前は棒の右に書くので、その幅を左右にあける。あける幅は、図の幅の1/4までにする
|
|
120
|
+
const gutter = (column) => Math.min(width / 4, Math.max(0, ...visible.filter(node => node.column === column).map(labelWidth)) + LABEL_GAP);
|
|
121
|
+
const leftGutter = gutter(0);
|
|
122
|
+
const rightGutter = columns > 1 ? gutter(columns - 1) : 0;
|
|
123
|
+
const span = Math.max(1, width - leftGutter - rightGutter - NODE_WIDTH);
|
|
124
|
+
const nodeX = (column) => leftGutter + (columns > 1 ? (span * column) / (columns - 1) : 0);
|
|
125
|
+
// 量の縦の倍率。どの段も、項目の棒と、項目どうしの間(M)が、高さに収まるようにする
|
|
126
|
+
const scale = Math.min(...Array.from({ length: columns }, (_, c) => {
|
|
127
|
+
const inColumn = visible.filter(node => node.column === c);
|
|
128
|
+
const total = inColumn.reduce((sum, node) => sum + node.value, 0);
|
|
129
|
+
return total > 0 ? Math.max(0, height - NODE_GAP * (inColumn.length - 1)) / total : Infinity;
|
|
130
|
+
}));
|
|
131
|
+
const k = Number.isFinite(scale) ? scale : 0;
|
|
132
|
+
// 項目の棒の上端。段の中で、上から順に積む
|
|
133
|
+
const nodeY = nodes.map(() => 0);
|
|
134
|
+
for (let c = 0; c < columns; c++) {
|
|
135
|
+
let y = 0;
|
|
136
|
+
for (const node of visible.filter(n => n.column === c).sort((a, b) => a.order - b.order)) {
|
|
137
|
+
nodeY[nodes.indexOf(node)] = y;
|
|
138
|
+
y += node.value * k + NODE_GAP;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// 流れの帯の、元と先での上端。元では先の項目の上下の順に、先では元の項目の上下の順に積み、帯どうしを交差させにくくする
|
|
142
|
+
const offsetOut = nodes.map(() => 0);
|
|
143
|
+
const offsetIn = nodes.map(() => 0);
|
|
144
|
+
const bands = graph.links.map(link => ({ link, sy: 0, ty: 0, thickness: link.value * k }));
|
|
145
|
+
const byTarget = [...bands].sort((a, b) => (nodeY[a.link.target] ?? 0) - (nodeY[b.link.target] ?? 0));
|
|
146
|
+
for (const band of byTarget) {
|
|
147
|
+
band.sy = (nodeY[band.link.source] ?? 0) + (offsetOut[band.link.source] ?? 0);
|
|
148
|
+
offsetOut[band.link.source] = (offsetOut[band.link.source] ?? 0) + band.thickness;
|
|
149
|
+
}
|
|
150
|
+
const bySource = [...bands].sort((a, b) => (nodeY[a.link.source] ?? 0) - (nodeY[b.link.source] ?? 0));
|
|
151
|
+
for (const band of bySource) {
|
|
152
|
+
band.ty = (nodeY[band.link.target] ?? 0) + (offsetIn[band.link.target] ?? 0);
|
|
153
|
+
offsetIn[band.link.target] = (offsetIn[band.link.target] ?? 0) + band.thickness;
|
|
154
|
+
}
|
|
155
|
+
const geometry = bands.map(band => {
|
|
156
|
+
const x0 = nodeX(nodes[band.link.source]?.column ?? 0) + NODE_WIDTH;
|
|
157
|
+
const x1 = nodeX(nodes[band.link.target]?.column ?? 0);
|
|
158
|
+
const xm = (x0 + x1) / 2;
|
|
159
|
+
const t = band.thickness;
|
|
160
|
+
const d = `M${x0} ${band.sy}C${xm} ${band.sy} ${xm} ${band.ty} ${x1} ${band.ty}L${x1} ${band.ty + t}C${xm} ${band.ty + t} ${xm} ${band.sy + t} ${x0} ${band.sy + t}Z`;
|
|
161
|
+
return { ...band, x0, x1, xm, d };
|
|
162
|
+
});
|
|
163
|
+
// マウスの位置から、乗せている項目か流れを決める。番号は、流れを 0〜、項目を流れの数〜にする。項目の棒を先に判定する
|
|
164
|
+
const hover = usePointerPick((x, y) => {
|
|
165
|
+
for (const node of visible) {
|
|
166
|
+
const i = nodes.indexOf(node);
|
|
167
|
+
const left = nodeX(node.column);
|
|
168
|
+
const top = nodeY[i] ?? 0;
|
|
169
|
+
if (x >= left - 2 && x <= left + NODE_WIDTH + 2 && y >= top - 2 && y <= top + node.value * k + 2)
|
|
170
|
+
return geometry.length + i;
|
|
171
|
+
}
|
|
172
|
+
for (let i = geometry.length - 1; i >= 0; i--) {
|
|
173
|
+
const g = geometry[i];
|
|
174
|
+
if (!g || x < g.x0 || x > g.x1)
|
|
175
|
+
continue;
|
|
176
|
+
// 横の位置 x になる t を、二分法で探す(x は t について単調に増える)
|
|
177
|
+
let lo = 0;
|
|
178
|
+
let hi = 1;
|
|
179
|
+
for (let step = 0; step < 20; step++) {
|
|
180
|
+
const mid = (lo + hi) / 2;
|
|
181
|
+
if (bezier(g.x0, g.xm, g.xm, g.x1, mid) < x)
|
|
182
|
+
lo = mid;
|
|
183
|
+
else
|
|
184
|
+
hi = mid;
|
|
185
|
+
}
|
|
186
|
+
const center = bezier(g.sy, g.sy, g.ty, g.ty, lo) + g.thickness / 2;
|
|
187
|
+
if (Math.abs(y - center) <= Math.max(g.thickness / 2, 2))
|
|
188
|
+
return i;
|
|
189
|
+
}
|
|
190
|
+
return null;
|
|
191
|
+
});
|
|
192
|
+
const active = hover.index;
|
|
193
|
+
const activeLink = active !== null && active < geometry.length ? geometry[active] : undefined;
|
|
194
|
+
const activeNode = active !== null && active >= geometry.length ? nodes[active - geometry.length] : undefined;
|
|
195
|
+
const nameOf = (i) => nodes[i]?.name ?? "";
|
|
196
|
+
const original = activeLink ? links[activeLink.link.index] : undefined;
|
|
197
|
+
return (_jsxs(_Fragment, { children: [_jsxs("svg", { "aria-hidden": "true", width: width, height: height, className: "block overflow-visible", children: [geometry.map((g, i) => {
|
|
198
|
+
const color = seriesIndex(nodes[g.link.source]?.order ?? 0);
|
|
199
|
+
return _jsx("path", { d: g.d, fillOpacity: AREA_OPACITY, strokeWidth: "1", className: `${SERIES_FILL[color]} ${SERIES_STROKE[color]}` }, i);
|
|
200
|
+
}), activeLink && _jsx("path", { d: activeLink.d, fill: "none", strokeWidth: "2", className: "stroke-foreground" }), visible.map(node => {
|
|
201
|
+
const i = nodes.indexOf(node);
|
|
202
|
+
const x = nodeX(node.column);
|
|
203
|
+
const y = nodeY[i] ?? 0;
|
|
204
|
+
const h = Math.max(1, node.value * k);
|
|
205
|
+
// 最初の段(段が1つでないとき)は棒の左に右そろえで、ほかの段は棒の右に書く
|
|
206
|
+
const onLeft = node.column === 0 && columns > 1;
|
|
207
|
+
const room = onLeft ? leftGutter - LABEL_GAP : node.column === columns - 1 ? rightGutter - LABEL_GAP : span / Math.max(columns - 1, 1) - NODE_WIDTH - LABEL_GAP * 2;
|
|
208
|
+
// 名前と量が収まらないときは、量を省いて名前を優先する(量はツールチップと値の表で読める)。それでも長い名前は「…」で切り詰める
|
|
209
|
+
const fullValue = valueText(node);
|
|
210
|
+
const both = Math.min(LABEL_MAX, textWidth(node.name)) + LABEL_GAP + textWidth(fullValue) <= room;
|
|
211
|
+
const value = both ? fullValue : "";
|
|
212
|
+
const name = truncate(node.name, Math.max(0, both ? room - LABEL_GAP - textWidth(fullValue) : room));
|
|
213
|
+
return (_jsxs("g", { children: [_jsx("rect", { x: x, y: y, width: NODE_WIDTH, height: h, className: SERIES_FILL[seriesIndex(node.order)] }), node === activeNode && _jsx("rect", { x: x - 1, y: y - 1, width: NODE_WIDTH + 2, height: h + 2, fill: "none", strokeWidth: "2", className: "stroke-foreground" }), _jsxs("text", { x: onLeft ? x - LABEL_GAP : x + NODE_WIDTH + LABEL_GAP, y: Math.min(Math.max(y + h / 2, AXIS_FONT_SIZE / 2), height - AXIS_FONT_SIZE / 2), textAnchor: onLeft ? "end" : "start", dominantBaseline: "central", className: "text-xs", children: [_jsx("tspan", { className: "fill-foreground", children: name }), value && (_jsx("tspan", { dx: LABEL_GAP, className: "fill-muted-foreground tabular-nums", children: value }))] })] }, i));
|
|
214
|
+
}), _jsx("rect", { x: 0, y: 0, width: width, height: height, fill: "transparent", ...hover.handlers })] }), _jsxs(ChartTooltip, { position: hover.position, onDismiss: hover.dismiss, children: [activeLink && original && (_jsx(ChartTooltipContent, { label: `${nameOf(activeLink.link.source)}から${nameOf(activeLink.link.target)}`, rows: [
|
|
215
|
+
{ name: valueLabel, value: formatValue(original.value, unit) },
|
|
216
|
+
{ name: RATIO_LABEL, value: formatValue(ratioOf(graph, original), "%") },
|
|
217
|
+
] })), activeNode && _jsx(ChartTooltipContent, { label: activeNode.name, rows: [{ name: valueLabel, value: valueText(activeNode) }] })] })] }));
|
|
218
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SankeyChart.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SankeyChart.js";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** 散布図の1つの点。横の値(x)と縦の値(y)の組に、名前を付ける。値のないときは null にする */
|
|
2
|
+
export interface ScatterPoint {
|
|
3
|
+
/** 点の名前(「東京店」など)。ツールチップと、値の表の1列目に出す */
|
|
4
|
+
label: string;
|
|
5
|
+
x: number | null;
|
|
6
|
+
y: number | null;
|
|
7
|
+
}
|
|
8
|
+
/** 散布図の1つの系列 */
|
|
9
|
+
export interface ScatterSeries {
|
|
10
|
+
/** 系列の名前。凡例、ツールチップ、値の表に出す */
|
|
11
|
+
name: string;
|
|
12
|
+
points: readonly ScatterPoint[];
|
|
13
|
+
}
|
|
14
|
+
export interface ScatterChartProps {
|
|
15
|
+
/** グラフの名前。図の上に出し、図と値の表の名前にもする */
|
|
16
|
+
label: string;
|
|
17
|
+
/** グラフが伝える要点を、1〜2文で書く。「売り場が広い店ほど、売上が多い傾向があります。」のようにする */
|
|
18
|
+
description: string;
|
|
19
|
+
/** 系列。5つまで */
|
|
20
|
+
series: readonly ScatterSeries[];
|
|
21
|
+
/** 横の値の軸の名前(「売り場の広さ」)。単位があれば、後ろに括弧で付けて図の右下に出す */
|
|
22
|
+
xLabel?: string;
|
|
23
|
+
/** 横の値の単位(「m²」「件」)。値の書き方は docs/writing/date-and-number.md の「日付、数値、単位」に従う */
|
|
24
|
+
xUnit?: string;
|
|
25
|
+
/** 縦の値の軸の名前(「売上」)。単位があれば、後ろに括弧で付けて図の左上に出す */
|
|
26
|
+
yLabel?: string;
|
|
27
|
+
/** 縦の値の単位 */
|
|
28
|
+
yUnit?: string;
|
|
29
|
+
/** 点の名前の列の見出し(「店舗」)。値の表の1列目の見出しにする。省いたときは「項目」 */
|
|
30
|
+
categoryLabel?: string;
|
|
31
|
+
/** 値が1つもないときの文。データがまだないときと、絞り込みの結果が0件のときで書き分ける。省いたときは「まだデータがありません。」 */
|
|
32
|
+
emptyMessage?: string;
|
|
33
|
+
/** 図の高さ(px)。省いたときは240。幅は、置いた場所の幅に合わせる */
|
|
34
|
+
height?: number;
|
|
35
|
+
/** 外側の配置(余白と幅)だけに使う */
|
|
36
|
+
className?: string;
|
|
37
|
+
}
|
|
38
|
+
export declare function ScatterChart({ series, xLabel, xUnit, yLabel, yUnit, categoryLabel, ...rest }: ScatterChartProps): 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 { useCallback, useState } from "react";
|
|
4
|
+
import { HorizontalValueAxis, ValueAxis, layoutScatterPlot } from "../chart/Axis.js";
|
|
5
|
+
import { ChartLayout } from "../chart/ChartFrame.js";
|
|
6
|
+
import { ChartTooltip } from "../chart/ChartTooltip.js";
|
|
7
|
+
import { axisTitle, formatValue } from "../chart/format.js";
|
|
8
|
+
import { PointSwatch, SeriesMarker } from "../chart/series.js";
|
|
9
|
+
import { Table, TableBody, TableCell, TableHead, TableHeaderCell, TableRow } from "../table/Table.js";
|
|
10
|
+
const isValue = (v) => typeof v === "number" && Number.isFinite(v);
|
|
11
|
+
// 2つの値の関係を、点の位置で示す。横と縦の両方を値の軸にし、どちらも 0 から始める(docs/chart/axis.md の CHART-003)。
|
|
12
|
+
// 系列は、色に加えて印の形で描き分ける(CHART-002)。点は中を半透明に塗り、重なった点を隠さない(CHART-018)。
|
|
13
|
+
// 点を線でつながない(CHART-019)
|
|
14
|
+
export function ScatterChart({ series, xLabel, xUnit, yLabel, yUnit, categoryLabel = "項目", ...rest }) {
|
|
15
|
+
const xName = xLabel ?? "横の値";
|
|
16
|
+
const yName = yLabel ?? "縦の値";
|
|
17
|
+
const multiple = series.length > 1;
|
|
18
|
+
const empty = !series.some(s => s.points.some(p => isValue(p.x) && isValue(p.y)));
|
|
19
|
+
return (_jsx(ChartLayout, { ...rest, component: "ScatterChart", seriesNames: series.map(s => s.name), empty: empty, valueTitle: axisTitle(yLabel, yUnit), horizontalValueTitle: axisTitle(xLabel, xUnit), swatch: i => _jsx(PointSwatch, { index: i }), table: _jsxs(Table, { children: [_jsx("caption", { className: "sr-only", children: rest.label }), _jsx(TableHead, { children: _jsxs(TableRow, { children: [_jsx(TableHeaderCell, { children: categoryLabel }), multiple && _jsx(TableHeaderCell, { children: "\u7CFB\u5217" }), _jsx(TableHeaderCell, { className: "text-right", children: xName }), _jsx(TableHeaderCell, { className: "text-right", children: yName })] }) }), _jsx(TableBody, { children: series.flatMap((s, i) => s.points.map((p, j) => (_jsxs(TableRow, { children: [_jsx(TableHeaderCell, { scope: "row", children: p.label }), multiple && _jsx(TableCell, { children: s.name }), _jsx(TableCell, { className: "whitespace-nowrap text-right tabular-nums", children: formatValue(p.x, xUnit) }), _jsx(TableCell, { className: "whitespace-nowrap text-right tabular-nums", children: formatValue(p.y, yUnit) })] }, `${i}-${j}`)))) })] }), children: size => _jsx(ScatterPlot, { series: series, xName: xName, yName: yName, xUnit: xUnit, yUnit: yUnit, multiple: multiple, ...size }) }));
|
|
20
|
+
}
|
|
21
|
+
// マウスから、この距離(px)までにある点を、乗せている点とする。点の印の大きさ(8px)の2倍にする
|
|
22
|
+
const HIT_RADIUS = 16;
|
|
23
|
+
function range(values) {
|
|
24
|
+
return values.length === 0 ? [0, 0] : [Math.min(...values), Math.max(...values)];
|
|
25
|
+
}
|
|
26
|
+
function ScatterPlot({ series, xName, yName, xUnit, yUnit, multiple, width, height }) {
|
|
27
|
+
const drawable = series.flatMap((s, i) => s.points.filter(p => isValue(p.x) && isValue(p.y)).map(point => ({ series: i, point })));
|
|
28
|
+
const { plot, xScale, yScale } = layoutScatterPlot(range(drawable.map(d => d.point.x)), range(drawable.map(d => d.point.y)), width, height);
|
|
29
|
+
const points = drawable.map(d => ({ ...d, x: xScale.x(d.point.x), y: yScale.y(d.point.y) }));
|
|
30
|
+
const hover = usePointHover(points);
|
|
31
|
+
const active = hover.index === null ? null : points[hover.index];
|
|
32
|
+
return (_jsxs(_Fragment, { children: [_jsxs("svg", { "aria-hidden": "true", width: width, height: height, className: "block overflow-visible", children: [_jsx(ValueAxis, { plot: plot, scale: yScale }), _jsx(HorizontalValueAxis, { plot: plot, scale: xScale }), points.map((p, k) => (_jsx(SeriesMarker, { index: p.series, x: p.x, y: p.y, paint: "translucent" }, k))), active && _jsx(SeriesMarker, { index: active.series, x: active.x, y: active.y, size: 10 }), _jsx("rect", { x: plot.left - HIT_RADIUS, y: plot.top - HIT_RADIUS, width: plot.width + HIT_RADIUS * 2, height: plot.height + HIT_RADIUS * 2, fill: "transparent", ...hover.handlers })] }), _jsx(ChartTooltip, { position: hover.position, onDismiss: hover.dismiss, children: active && (_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "font-medium", children: active.point.label }), _jsxs("ul", { className: "space-y-1", children: [multiple && (_jsxs("li", { className: "flex items-center gap-2", children: [_jsx(PointSwatch, { index: active.series }), _jsx("span", { className: "min-w-0 text-trim", children: series[active.series]?.name })] })), [
|
|
33
|
+
{ name: xName, value: formatValue(active.point.x, xUnit) },
|
|
34
|
+
{ name: yName, value: formatValue(active.point.y, yUnit) },
|
|
35
|
+
].map(row => (_jsxs("li", { className: "flex min-h-4 items-center gap-4", children: [_jsx("span", { className: "min-w-0 flex-1 text-trim", children: row.name }), _jsx("span", { className: "whitespace-nowrap text-trim tabular-nums", children: row.value })] }, row.name)))] })] })) })] }));
|
|
36
|
+
}
|
|
37
|
+
// マウスの位置から、いちばん近い点を決める。HIT_RADIUS より遠ければ、どの点にも乗せていないとする。
|
|
38
|
+
// タッチでは出さない(useChartHover とそろえる)。タッチの画面では、値の表で値を読む
|
|
39
|
+
function usePointHover(points) {
|
|
40
|
+
const [state, setState] = useState(null);
|
|
41
|
+
const dismiss = useCallback(() => setState(null), []);
|
|
42
|
+
function onPointerMove(e) {
|
|
43
|
+
if (e.pointerType === "touch")
|
|
44
|
+
return;
|
|
45
|
+
const svg = e.currentTarget.ownerSVGElement;
|
|
46
|
+
if (!svg)
|
|
47
|
+
return;
|
|
48
|
+
const box = svg.getBoundingClientRect();
|
|
49
|
+
const mx = e.clientX - box.left;
|
|
50
|
+
const my = e.clientY - box.top;
|
|
51
|
+
let index = null;
|
|
52
|
+
let best = HIT_RADIUS;
|
|
53
|
+
for (let k = 0; k < points.length; k++) {
|
|
54
|
+
const d = Math.hypot(points[k].x - mx, points[k].y - my);
|
|
55
|
+
// 同じ距離なら、後に描いた(上に重なっている)点を選ぶ
|
|
56
|
+
if (d <= best) {
|
|
57
|
+
best = d;
|
|
58
|
+
index = k;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
setState(index === null ? null : { index, position: { x: e.clientX, y: e.clientY } });
|
|
62
|
+
}
|
|
63
|
+
function onPointerLeave(e) {
|
|
64
|
+
if (e.pointerType === "touch")
|
|
65
|
+
return;
|
|
66
|
+
setState(null);
|
|
67
|
+
}
|
|
68
|
+
return { index: state?.index ?? null, position: state?.position ?? null, handlers: { onPointerMove, onPointerLeave }, dismiss };
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ScatterChart.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ScatterChart.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type InputHTMLAttributes } from "react";
|
|
2
|
+
export type SearchFieldSearchOn = "input" | "enter";
|
|
3
|
+
type NativeInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "defaultValue" | "onChange" | "className">;
|
|
4
|
+
export interface SearchFieldProps extends NativeInputProps {
|
|
5
|
+
/** 確定した検索の語。URLのクエリ(`q`)から読んだ値を渡す */
|
|
6
|
+
value: string;
|
|
7
|
+
/** 検索の語が確定したときに、新しい語で呼ぶ。確定した語と同じなら呼ばない */
|
|
8
|
+
onChange: (value: string) => void;
|
|
9
|
+
/** 知らせる時機。input は入力のたびに delay だけ待って、enter は Enter キーで知らせる。省いたときは input */
|
|
10
|
+
searchOn?: SearchFieldSearchOn;
|
|
11
|
+
/** searchOn が input のときに、入力が止まってから知らせるまでのミリ秒。省いたときは 300 */
|
|
12
|
+
delay?: number;
|
|
13
|
+
/** 外側の配置(余白と幅)だけに使う */
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function SearchField({ value, onChange, searchOn, delay, className, disabled, onKeyDown, onCompositionStart, onCompositionEnd, ...props }: SearchFieldProps): import("react").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { SearchIcon } from "lucide-react";
|
|
4
|
+
import { CloseButton } from "../close-button/CloseButton.js";
|
|
5
|
+
import { cn } from "../../lib/cn.js";
|
|
6
|
+
import { inputFieldClassName, inputFrameClassName } from "../input/inputStyle.js";
|
|
7
|
+
// 一覧の上に置く検索欄。入力中の語は部品の中に持ち、確定した語だけを onChange で知らせる。
|
|
8
|
+
// URLの書き換えは使う側で行う(docs/list/paging.md の「一覧の状態とURL」)
|
|
9
|
+
export function SearchField({ value, onChange, searchOn = "input", delay = 300, className, disabled, onKeyDown, onCompositionStart, onCompositionEnd, ...props }) {
|
|
10
|
+
const inputRef = useRef(null);
|
|
11
|
+
const timerRef = useRef(undefined);
|
|
12
|
+
// 最後に知らせた語。親から戻ってきた値で、その後の入力を上書きしないために使う
|
|
13
|
+
const sentRef = useRef(value);
|
|
14
|
+
const composingRef = useRef(false);
|
|
15
|
+
const [draft, setDraft] = useState(value);
|
|
16
|
+
const [prevValue, setPrevValue] = useState(value);
|
|
17
|
+
// 戻るボタンのように、外から値が変わったときは、入力中の語をその値にそろえる。
|
|
18
|
+
// 自分が知らせた語が戻ってきただけなら、その間に打った文字を消さない
|
|
19
|
+
if (value !== prevValue) {
|
|
20
|
+
setPrevValue(value);
|
|
21
|
+
if (value !== sentRef.current) {
|
|
22
|
+
setDraft(value);
|
|
23
|
+
// 外から来た値を、知らせ済みの語として覚える。前に知らせた語をもう一度探したときに、同じ語として捨てないようにする
|
|
24
|
+
sentRef.current = value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// 検索欄は見える名前を置かないことが多い。名前のないまま描いたときに、1回だけ知らせる(Button と同じ形)
|
|
28
|
+
const unlabeled = !props["aria-label"] && !props["aria-labelledby"] && !props.id;
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (unlabeled)
|
|
31
|
+
console.warn("SearchField: aria-label か aria-labelledby で名前を付ける");
|
|
32
|
+
}, [unlabeled]);
|
|
33
|
+
// 消えた後に、待っている知らせを残さない
|
|
34
|
+
useEffect(() => () => clearTimeout(timerRef.current), []);
|
|
35
|
+
const notify = (next) => {
|
|
36
|
+
clearTimeout(timerRef.current);
|
|
37
|
+
if (next === sentRef.current)
|
|
38
|
+
return;
|
|
39
|
+
sentRef.current = next;
|
|
40
|
+
onChange(next);
|
|
41
|
+
};
|
|
42
|
+
const schedule = (next) => {
|
|
43
|
+
clearTimeout(timerRef.current);
|
|
44
|
+
timerRef.current = setTimeout(() => notify(next), delay);
|
|
45
|
+
};
|
|
46
|
+
const clear = () => {
|
|
47
|
+
setDraft("");
|
|
48
|
+
notify("");
|
|
49
|
+
// 消すボタンが消えてもフォーカスを失わないよう、入力欄へ戻す
|
|
50
|
+
inputRef.current?.focus();
|
|
51
|
+
};
|
|
52
|
+
const handleKeyDown = (event) => {
|
|
53
|
+
onKeyDown?.(event);
|
|
54
|
+
if (event.defaultPrevented)
|
|
55
|
+
return;
|
|
56
|
+
// かな漢字の変換を確定する Enter と Esc では、検索しない
|
|
57
|
+
if (event.nativeEvent.isComposing || composingRef.current)
|
|
58
|
+
return;
|
|
59
|
+
if (event.key === "Enter") {
|
|
60
|
+
// フォームの送信でページを読み込み直さないよう、送信を止めてから知らせる
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
notify(draft);
|
|
63
|
+
}
|
|
64
|
+
else if (event.key === "Escape" && draft !== "") {
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
clear();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const showClear = draft !== "" && !disabled;
|
|
70
|
+
return (_jsxs("div", {
|
|
71
|
+
// 枠線とフォーカスの輪は、中の入力欄ではなく枠に描く(inputStyle.ts の inputFrameClassName)
|
|
72
|
+
className: inputFrameClassName(cn("pl-4",
|
|
73
|
+
// 消すボタンがないときは、Input と同じく右にもMの余白を取る。
|
|
74
|
+
// あるときは、ボタンの見た目(32px)を枠の内側(42px)の上下と同じくらいの隙間で右端に置く
|
|
75
|
+
showClear ? "pr-1" : "pr-4", className)), children: [_jsx(SearchIcon, { "aria-hidden": "true", className: "size-4 shrink-0 text-icon" }), _jsx("input", { ref: inputRef, type: "search", enterKeyHint: "search", value: draft, disabled: disabled, onChange: event => {
|
|
76
|
+
const next = event.target.value;
|
|
77
|
+
setDraft(next);
|
|
78
|
+
// 変換中の読みでは検索せず、確定してから待ち始める
|
|
79
|
+
if (searchOn === "input" && !composingRef.current)
|
|
80
|
+
schedule(next);
|
|
81
|
+
}, onKeyDown: handleKeyDown, onCompositionStart: event => {
|
|
82
|
+
composingRef.current = true;
|
|
83
|
+
onCompositionStart?.(event);
|
|
84
|
+
}, onCompositionEnd: event => {
|
|
85
|
+
composingRef.current = false;
|
|
86
|
+
if (searchOn === "input")
|
|
87
|
+
schedule(event.currentTarget.value);
|
|
88
|
+
onCompositionEnd?.(event);
|
|
89
|
+
},
|
|
90
|
+
// ブラウザーの既定の消すボタンと飾りは隠し、部品の消すボタンだけを出す
|
|
91
|
+
className: inputFieldClassName("appearance-none [&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none"), ...props }), showClear && (_jsx(CloseButton, { size: "sm", "aria-label": "\u691C\u7D22\u8A9E\u3092\u6D88\u3059", className: "shrink-0", onClick: clear }))] }));
|
|
92
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SearchField.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SearchField.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type InputHTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
export interface SegmentedControlProps {
|
|
3
|
+
/** 選択中の Segment の value */
|
|
4
|
+
value: string;
|
|
5
|
+
/** Segment を選んだとき(押したとき、矢印キーで移ったとき)に、その value で呼ぶ */
|
|
6
|
+
onChange: (value: string) => void;
|
|
7
|
+
/** 選択肢の並びの名前(「表示の形式」)。見える見出しがあれば aria-labelledby で結ぶ */
|
|
8
|
+
"aria-label"?: string;
|
|
9
|
+
"aria-labelledby"?: string;
|
|
10
|
+
/** すべての Segment を押せなくする */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** Segment を2〜5個並べる */
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
/** 外側の配置(余白)だけに使う */
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function SegmentedControl({ value, onChange, disabled, children, className, ...props }: SegmentedControlProps): import("react").JSX.Element;
|
|
18
|
+
export interface SegmentProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "name" | "value" | "checked" | "defaultChecked" | "onChange" | "children" | "className"> {
|
|
19
|
+
/** 選択肢を見分ける値。グループの中で重ならない文字列にする */
|
|
20
|
+
value: string;
|
|
21
|
+
/** 選択肢の文言。省くときは、aria-label で名前を必ず付ける(アイコンだけの選択肢) */
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
/** 文言の前に置くアイコン。色は選択の状態に合わせて部品が付けるので、大きさ(size-4)だけを指定し、aria-hidden を付ける */
|
|
24
|
+
icon?: ReactNode;
|
|
25
|
+
}
|
|
26
|
+
export declare function Segment({ value, children, icon, disabled, ...props }: SegmentProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Children, createContext, useContext, useEffect, useId } from "react";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
import { Tooltip } from "../tooltip/Tooltip.js";
|
|
5
|
+
const SegmentedControlContext = createContext(null);
|
|
6
|
+
export function SegmentedControl({ value, onChange, disabled, children, className, ...props }) {
|
|
7
|
+
// 同じ画面に2つ置いても、矢印キーで移る範囲が混ざらないように、グループごとに name を分ける
|
|
8
|
+
const name = useId();
|
|
9
|
+
const unlabeled = !props["aria-label"] && !props["aria-labelledby"];
|
|
10
|
+
const count = Children.toArray(children).length;
|
|
11
|
+
// 描くたびではなく、名前がない・数が2〜5個から外れたときに1回だけ知らせる
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (unlabeled)
|
|
14
|
+
console.warn("SegmentedControl: aria-label か aria-labelledby で、選択肢の並びの名前を付ける");
|
|
15
|
+
}, [unlabeled]);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (count < 2 || count > 5)
|
|
18
|
+
console.warn(`SegmentedControl: 選択肢は2〜5個にする(今は${count}個)。6個以上は Select を使う`);
|
|
19
|
+
}, [count]);
|
|
20
|
+
return (_jsx(SegmentedControlContext.Provider, { value: { name, value, onChange, disabled }, children: _jsx("div", { role: "radiogroup", className: cn("inline-flex max-w-full rounded-md bg-secondary p-1", className), ...props, children: children }) }));
|
|
21
|
+
}
|
|
22
|
+
// 選択は、面(primary)と文字の色で示す。文字の太さと余白は変えず、選んでも幅を変えない(docs/interaction/states.md の INTERACTION-014、INTERACTION-015)
|
|
23
|
+
export function Segment({ value, children, icon, disabled, ...props }) {
|
|
24
|
+
const group = useContext(SegmentedControlContext);
|
|
25
|
+
if (!group)
|
|
26
|
+
throw new Error("Segment: SegmentedControl の中に置く");
|
|
27
|
+
const selected = group.value === value;
|
|
28
|
+
const iconOnly = children == null;
|
|
29
|
+
const unlabeled = iconOnly && !props["aria-label"] && !props["aria-labelledby"];
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (unlabeled)
|
|
32
|
+
console.warn("Segment: 文言を省くアイコンだけの選択肢には、aria-label で名前を付ける");
|
|
33
|
+
}, [unlabeled]);
|
|
34
|
+
const input = (_jsx("input", { type: "radio", name: group.name, value: value, checked: selected, disabled: group.disabled || disabled, onChange: () => group.onChange(value), className: "absolute inset-x-0 -inset-y-1 m-0 cursor-pointer appearance-none outline-none disabled:cursor-not-allowed", ...props }));
|
|
35
|
+
return (_jsxs("label", { className: cn("relative inline-flex h-9 shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-sm text-sm leading-none font-medium", "has-focus-visible:ring-2 has-focus-visible:ring-ring has-disabled:cursor-not-allowed has-disabled:opacity-50",
|
|
36
|
+
// アイコンだけの選択肢は、名前のツールチップ(Tooltip)を label の中に置く。label の文字の太さと行の高さを受け継がないように戻す
|
|
37
|
+
iconOnly ? "w-11 [&_[role=tooltip]]:font-normal [&_[role=tooltip]]:[--tw-leading:initial]" : "min-w-11 px-4", selected ? "bg-primary text-primary-foreground" : "text-secondary-foreground has-enabled:hover:bg-muted"), children: [iconOnly && props["aria-label"] ? _jsx(Tooltip, { content: props["aria-label"], children: input }) : input, icon && _jsx("span", { className: cn("flex shrink-0", selected ? "text-primary-icon" : "text-secondary-icon"), children: icon }), !iconOnly && _jsx("span", { className: "text-trim", children: children })] }));
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SegmentedControl.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SegmentedControl.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SelectHTMLAttributes } from "react";
|
|
2
|
+
export interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, "multiple" | "size"> {
|
|
3
|
+
/** 外側の配置(余白と幅)だけに使う。select ではなく、矢印のアイコンを含む外側の要素に付く */
|
|
4
|
+
className?: string;
|
|
5
|
+
/**
|
|
6
|
+
* まだ選んでいないときに出す文字(例:「選択してください」)。渡すと、選べない空の選択肢(value="")を先頭に置く。
|
|
7
|
+
* value も defaultValue も渡さないときは、この空の選択肢を選んだ状態で始める
|
|
8
|
+
*/
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function Select({ className, children, placeholder, ...props }: SelectProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronDownIcon } from "lucide-react";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
import { inputClassName } from "../input/inputStyle.js";
|
|
5
|
+
// 決まった選択肢から1つを選ぶ入力欄。ネイティブの <select> のまま使い、キーボードと読み上げはブラウザーに任せる。
|
|
6
|
+
// 閉じた状態の見た目(枠線、高さ、角の丸み、フォーカス、エラー)は inputStyle.ts の picker の形で Input とそろえ、右端の矢印はアイコンで描く。
|
|
7
|
+
// appearance: base-select に対応するブラウザーでだけ、開いたリストの見た目も変える。対応しないブラウザーでは、
|
|
8
|
+
// 開いたリストはOSの既定のまま(docs/components/select.md の「セレクト」)
|
|
9
|
+
//
|
|
10
|
+
// placeholder を渡すと、先頭に <option value="" disabled> を置く。required のときは、この空の選択肢が選ばれたままだと
|
|
11
|
+
// ブラウザーの検査で未入力になる(placeholder label option)。disabled なので、一度選んだ後に空へ戻すことはできない。
|
|
12
|
+
// 選ばないことを許す項目は、placeholder ではなく「指定しない」のような選べる選択肢を置く(docs/components/select.md の「セレクト」)
|
|
13
|
+
export function Select({ className, children, placeholder, ...props }) {
|
|
14
|
+
// ブラウザーは、選ばれた選択肢がないと、先頭の押せる選択肢を選ぶ。空の選択肢は disabled なので、
|
|
15
|
+
// 値の指定がないときは defaultValue に "" を渡し、空の選択肢を選んだ状態で始める
|
|
16
|
+
const initial = placeholder !== undefined && props.value === undefined && props.defaultValue === undefined ? { defaultValue: "" } : {};
|
|
17
|
+
return (_jsxs("div", { className: cn("relative", className), children: [_jsxs("select", { className: inputClassName("picker", cn(
|
|
18
|
+
// 閉じた状態。peer は右端の矢印を無効のときに薄くするため
|
|
19
|
+
"peer appearance-none",
|
|
20
|
+
// 空の選択肢(placeholder)を選んでいる間は、選んだ値と見分けられるよう、文字を muted-foreground にする。
|
|
21
|
+
// 開いたリストの選択肢は select の色を受け継ぐので、文字の色を戻す(base-select では下で popover-foreground にする)
|
|
22
|
+
"[&:has(option[data-placeholder]:checked)]:text-muted-foreground not-supports-[appearance:base-select]:[&_option]:text-foreground",
|
|
23
|
+
// base-select に対応するときだけ。ブラウザーの矢印(::picker-icon)は消し、下の自作のアイコンにそろえる。
|
|
24
|
+
// 選んだ値の文字は内側の要素に入り、truncate の省略記号が効かないので、長い文字は矢印の手前(内容の箱の端)で切る
|
|
25
|
+
"supports-[appearance:base-select]:[appearance:base-select] supports-[appearance:base-select]:[&::picker-icon]:hidden supports-[appearance:base-select]:overflow-clip supports-[appearance:base-select]:[overflow-clip-margin:content-box]",
|
|
26
|
+
// 開いたリスト(::picker(select))は、メニューと同じ面にする。手前の層に出るので z- は付けない
|
|
27
|
+
"supports-[appearance:base-select]:[&::picker(select)]:[appearance:base-select] supports-[appearance:base-select]:[&::picker(select)]:my-1 supports-[appearance:base-select]:[&::picker(select)]:rounded-lg supports-[appearance:base-select]:[&::picker(select)]:border supports-[appearance:base-select]:[&::picker(select)]:border-border supports-[appearance:base-select]:[&::picker(select)]:bg-popover supports-[appearance:base-select]:[&::picker(select)]:p-1 supports-[appearance:base-select]:[&::picker(select)]:text-popover-foreground supports-[appearance:base-select]:[&::picker(select)]:shadow-md",
|
|
28
|
+
// 選択肢は、メニューの項目と同じ高さ、余白、角の丸み、押したときの面にする
|
|
29
|
+
"supports-[appearance:base-select]:[&_option]:text-popover-foreground supports-[appearance:base-select]:[&_option]:flex supports-[appearance:base-select]:[&_option]:min-h-11 supports-[appearance:base-select]:[&_option]:items-center supports-[appearance:base-select]:[&_option]:gap-2 supports-[appearance:base-select]:[&_option]:rounded-md supports-[appearance:base-select]:[&_option]:px-4 supports-[appearance:base-select]:[&_option]:outline-none supports-[appearance:base-select]:[&_option:hover]:bg-secondary supports-[appearance:base-select]:[&_option:focus-visible]:bg-secondary supports-[appearance:base-select]:[&_option:disabled]:opacity-50")), ...initial, ...props, children: [placeholder !== undefined && (_jsx("option", { value: "", disabled: true, "data-placeholder": "", children: placeholder })), children] }), _jsx(ChevronDownIcon, { "aria-hidden": "true", className: "pointer-events-none absolute right-2 top-1/2 size-4 -translate-y-1/2 text-icon peer-disabled:opacity-50" })] }));
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Select.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Select.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "react";
|
|
2
|
+
export type SeparatorOrientation = "horizontal" | "vertical";
|
|
3
|
+
export interface SeparatorProps extends HTMLAttributes<HTMLHRElement> {
|
|
4
|
+
/** 線の向き。省いたときは horizontal(横の線)。vertical は、横に並べる flex の行の中に置く */
|
|
5
|
+
orientation?: SeparatorOrientation;
|
|
6
|
+
/**
|
|
7
|
+
* 省いたときは true で、見た目だけの線として読み上げから外す。
|
|
8
|
+
* 前後のまとまりの区切りを読み上げにも伝えるときだけ false にし、role="separator" として伝える
|
|
9
|
+
*/
|
|
10
|
+
decorative?: boolean;
|
|
11
|
+
/** 外側の配置(余白)だけに使う */
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function Separator({ orientation, decorative, className, ...props }: SeparatorProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../lib/cn.js";
|
|
3
|
+
// Tailwind がクラスを読み取れるように、クラス名は組み立てずにそのまま書く。
|
|
4
|
+
// hr は preflight で height: 0 になるので、縦の線は h-auto にしてから、行の高さに伸ばす
|
|
5
|
+
const orientations = {
|
|
6
|
+
horizontal: "border-t",
|
|
7
|
+
vertical: "h-auto self-stretch border-t-0 border-l",
|
|
8
|
+
};
|
|
9
|
+
// 区切り線。ネイティブの hr で描き、色は border のトークン(tokens.css の既定の枠線の色)にする
|
|
10
|
+
export function Separator({ orientation = "horizontal", decorative = true, className, ...props }) {
|
|
11
|
+
return (_jsx("hr", { "aria-hidden": decorative ? true : undefined, "aria-orientation": !decorative && orientation === "vertical" ? "vertical" : undefined, className: cn("shrink-0", orientations[orientation], className), ...props }));
|
|
12
|
+
}
|