@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,190 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState, } from "react";
|
|
4
|
+
import { Button } from "../button/Button.js";
|
|
5
|
+
import { CloseButton } from "../close-button/CloseButton.js";
|
|
6
|
+
// 並べる上限。超えたら古いものから消す
|
|
7
|
+
const MAX_TOASTS = 3;
|
|
8
|
+
// 消えるまでの時間(ミリ秒)。操作を含むトーストは、押すまでの時間を残すため長くする
|
|
9
|
+
const DURATION = 5000;
|
|
10
|
+
const DURATION_WITH_ACTION = 10000;
|
|
11
|
+
const ToastContext = createContext(null);
|
|
12
|
+
// モーダルのダイアログを開いているか。:modal に対応しないブラウザでは、開いているダイアログをモーダルとみなす
|
|
13
|
+
function modalDialogOpen(doc) {
|
|
14
|
+
return Array.from(doc.querySelectorAll("dialog[open]")).some(dialog => {
|
|
15
|
+
try {
|
|
16
|
+
return dialog.matches(":modal");
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
// 戻す先の要素にフォーカスを移す。移せたら true。ページから消えた要素や、押せなくなった要素には移せない
|
|
24
|
+
function focusIfPossible(element) {
|
|
25
|
+
if (!element || !element.isConnected)
|
|
26
|
+
return false;
|
|
27
|
+
element.focus();
|
|
28
|
+
return element.ownerDocument.activeElement === element;
|
|
29
|
+
}
|
|
30
|
+
// 戻す先がないときの移し先。body に落とすと、キーボードと読み上げの位置がページの先頭に飛ぶので、
|
|
31
|
+
// 使う側の本文(main)へ移す。main がフォーカスできなければ、Tabキーの順に入らない tabindex="-1" を
|
|
32
|
+
// 移している間だけ付け、外れたら取り除く。main がページになければ false を返す
|
|
33
|
+
function focusMain(doc) {
|
|
34
|
+
const main = doc.querySelector("main, [role='main']");
|
|
35
|
+
if (!main)
|
|
36
|
+
return false;
|
|
37
|
+
if (!main.hasAttribute("tabindex")) {
|
|
38
|
+
main.setAttribute("tabindex", "-1");
|
|
39
|
+
main.addEventListener("blur", () => main.removeAttribute("tabindex"), { once: true });
|
|
40
|
+
}
|
|
41
|
+
// 見ていた位置が動かないように、スクロールせずに移す
|
|
42
|
+
main.focus({ preventScroll: true });
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
// トーストを出す仕組み。画面の右下(768px未満では下の中央)の、最前面の層(popover="manual")に並べる
|
|
46
|
+
export function ToastProvider({ children }) {
|
|
47
|
+
const [toasts, setToasts] = useState([]);
|
|
48
|
+
const [hovering, setHovering] = useState(false);
|
|
49
|
+
const [focused, setFocused] = useState(false);
|
|
50
|
+
const regionRef = useRef(null);
|
|
51
|
+
const nextId = useRef(0);
|
|
52
|
+
// モーダルのダイアログを開いている間の、操作のあるトーストを、出すたびではなく1回だけ知らせる
|
|
53
|
+
const warned = useRef(false);
|
|
54
|
+
// フォーカスが乗っているトーストの id と、トーストに移る前にフォーカスがあった要素。
|
|
55
|
+
// 閉じたトーストからフォーカスを移す先を決めるのに使う
|
|
56
|
+
const focusedId = useRef(null);
|
|
57
|
+
const returnFocus = useRef(null);
|
|
58
|
+
// 前の描画での並び。閉じたトーストが並びのどこにあったかを知るのに使う
|
|
59
|
+
const previousToasts = useRef([]);
|
|
60
|
+
const dismiss = useCallback((id) => {
|
|
61
|
+
setToasts(prev => prev.filter(toast => toast.id !== id));
|
|
62
|
+
}, []);
|
|
63
|
+
const show = useCallback((message, options) => {
|
|
64
|
+
const region = regionRef.current;
|
|
65
|
+
if (options?.action && region && modalDialogOpen(region.ownerDocument) && !warned.current) {
|
|
66
|
+
warned.current = true;
|
|
67
|
+
console.warn("Toast: モーダルのダイアログを開いている間は、操作のあるトーストを出さない。操作の要る知らせはダイアログの中に出す");
|
|
68
|
+
}
|
|
69
|
+
const id = nextId.current++;
|
|
70
|
+
// 出したときにフォーカスがあった要素を覚える。トーストの中や body は、戻す先にならないので覚えない
|
|
71
|
+
const active = region?.ownerDocument.activeElement;
|
|
72
|
+
const opener = active instanceof HTMLElement && active !== active.ownerDocument.body && !region?.contains(active) ? active : null;
|
|
73
|
+
// 新しい順に並べ、上限を超えた古いものを消す
|
|
74
|
+
setToasts(prev => [{ id, message, action: options?.action, opener }, ...prev].slice(0, MAX_TOASTS));
|
|
75
|
+
}, []);
|
|
76
|
+
// 読み上げの領域は、トーストを足す前から置いておく必要があるので、出ている間ずっと最前面の層に出しておく。
|
|
77
|
+
// 中が空のときも領域は残るが、押す操作を通す(pointer-events-none)ので、後ろの画面の操作を妨げない
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
const region = regionRef.current;
|
|
80
|
+
if (!region || typeof region.showPopover !== "function")
|
|
81
|
+
return;
|
|
82
|
+
region.showPopover();
|
|
83
|
+
// 最前面の層では後から出したものが手前に重なる。ダイアログを開いたら、トーストを手前に出し直す
|
|
84
|
+
const observer = new MutationObserver(records => {
|
|
85
|
+
const dialogOpened = records.some(record => record.target instanceof HTMLDialogElement && record.target.hasAttribute("open"));
|
|
86
|
+
if (!dialogOpened || !region.matches(":popover-open"))
|
|
87
|
+
return;
|
|
88
|
+
region.hidePopover();
|
|
89
|
+
region.showPopover();
|
|
90
|
+
});
|
|
91
|
+
observer.observe(region.ownerDocument.documentElement, { attributes: true, attributeFilter: ["open"], subtree: true });
|
|
92
|
+
return () => {
|
|
93
|
+
observer.disconnect();
|
|
94
|
+
if (region.matches(":popover-open"))
|
|
95
|
+
region.hidePopover();
|
|
96
|
+
};
|
|
97
|
+
}, []);
|
|
98
|
+
// フォーカスが乗っていたトーストが消えたら(閉じるボタン、操作のボタン、時間切れ、上限を超えたとき)、
|
|
99
|
+
// 次のトーストの閉じるボタンへ、なければトーストに移る前の要素へ、フォーカスを移す。
|
|
100
|
+
// その要素がもうなければ main へ、main もなければトーストを出したときの要素へ、それもなければ body に残す。
|
|
101
|
+
// 操作の onClick がフォーカスをほかへ移したときは、移した先を優先して何もしない
|
|
102
|
+
useLayoutEffect(() => {
|
|
103
|
+
const previous = previousToasts.current;
|
|
104
|
+
previousToasts.current = toasts;
|
|
105
|
+
const region = regionRef.current;
|
|
106
|
+
const id = focusedId.current;
|
|
107
|
+
if (!region || id === null || toasts.some(toast => toast.id === id))
|
|
108
|
+
return;
|
|
109
|
+
focusedId.current = null;
|
|
110
|
+
const doc = region.ownerDocument;
|
|
111
|
+
if (doc.activeElement && doc.activeElement !== doc.body)
|
|
112
|
+
return;
|
|
113
|
+
// 次のトーストは、閉じたものの1つ下(古いほう)。一番下だったときは、1つ上
|
|
114
|
+
const index = previous.findIndex(toast => toast.id === id);
|
|
115
|
+
const remaining = new Set(toasts.map(toast => toast.id));
|
|
116
|
+
const after = previous.slice(index + 1).find(toast => remaining.has(toast.id));
|
|
117
|
+
const before = previous.slice(0, Math.max(index, 0)).reverse().find(toast => remaining.has(toast.id));
|
|
118
|
+
const next = after ?? before;
|
|
119
|
+
const close = next && region.querySelector(`[data-toast-id="${next.id}"] [data-toast-close]`);
|
|
120
|
+
if (close) {
|
|
121
|
+
close.focus();
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
// トーストに移る前の要素、使う側の main、トーストを出したときの要素の順に試す。
|
|
125
|
+
// どれもなければ、フォーカスは body に残る(main のないページで、ほかに移せる先がないため)
|
|
126
|
+
const closed = previous[index];
|
|
127
|
+
if (!focusIfPossible(returnFocus.current) && !focusMain(doc))
|
|
128
|
+
focusIfPossible(closed?.opener ?? null);
|
|
129
|
+
returnFocus.current = null;
|
|
130
|
+
}, [toasts]);
|
|
131
|
+
// 閉じたトーストの中にフォーカスがあったときは、blur が届かないことがあるので、並びが変わるたびに確かめ直す
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
const region = regionRef.current;
|
|
134
|
+
if (!region)
|
|
135
|
+
return;
|
|
136
|
+
setFocused(region.contains(region.ownerDocument.activeElement));
|
|
137
|
+
}, [toasts]);
|
|
138
|
+
function handleFocus(e) {
|
|
139
|
+
setFocused(true);
|
|
140
|
+
// 外から入ってきたときだけ、戻す先を覚える
|
|
141
|
+
if (!e.currentTarget.contains(e.relatedTarget) && e.relatedTarget instanceof HTMLElement) {
|
|
142
|
+
returnFocus.current = e.relatedTarget;
|
|
143
|
+
}
|
|
144
|
+
const item = e.target.closest("[data-toast-id]");
|
|
145
|
+
focusedId.current = item ? Number(item.dataset.toastId) : null;
|
|
146
|
+
}
|
|
147
|
+
function handleBlur(e) {
|
|
148
|
+
if (e.currentTarget.contains(e.relatedTarget))
|
|
149
|
+
return;
|
|
150
|
+
setFocused(false);
|
|
151
|
+
// ほかの要素へ移ったときだけ、乗っていたトーストを忘れる。
|
|
152
|
+
// 移る先がない(relatedTarget が null)のは、ウィンドウを離れたときか、トーストが消えたときなので覚えておく
|
|
153
|
+
if (e.relatedTarget)
|
|
154
|
+
focusedId.current = null;
|
|
155
|
+
}
|
|
156
|
+
// マウスやフォーカスがどれかに乗っている間は、すべてのトーストの時間を止める。
|
|
157
|
+
// 1つだけ止めると、ほかのトーストが消えて、乗せているトーストの位置が動く
|
|
158
|
+
const paused = hovering || focused;
|
|
159
|
+
return (_jsxs(ToastContext.Provider, { value: show, children: [children, _jsx("div", { ref: regionRef, popover: "manual", role: "status", onPointerEnter: () => setHovering(true), onPointerLeave: () => setHovering(false), onFocus: handleFocus, onBlur: handleBlur,
|
|
160
|
+
// 最前面の層に出るので z- は付けない。popover の既定の枠、余白、地の色を外す。
|
|
161
|
+
// 768px未満は下の中央、768px以上は右下に置き、ホームバーに重ならないようにセーフエリアの分を空ける。
|
|
162
|
+
// トーストの間の隙間は、後ろのページを押せるように、押せる範囲から外す
|
|
163
|
+
className: "pointer-events-none top-auto inset-x-0 bottom-0 mx-auto my-0 w-full max-w-sm overflow-visible border-0 bg-transparent p-4 pb-[max(1rem,env(safe-area-inset-bottom))] md:left-auto md:mx-0 md:pr-[max(1rem,env(safe-area-inset-right))]", children: _jsx("div", { className: "flex flex-col gap-2", children: toasts.map(toast => (_jsx(ToastItem, { toast: toast, paused: paused, onDismiss: dismiss }, toast.id))) }) })] }));
|
|
164
|
+
}
|
|
165
|
+
// 1件のトースト。止めている間は残りの時間を覚えておき、再開したら残りの時間で消す
|
|
166
|
+
function ToastItem({ toast, paused, onDismiss }) {
|
|
167
|
+
const { id, message, action } = toast;
|
|
168
|
+
const remaining = useRef(action ? DURATION_WITH_ACTION : DURATION);
|
|
169
|
+
useEffect(() => {
|
|
170
|
+
if (paused)
|
|
171
|
+
return;
|
|
172
|
+
const startedAt = Date.now();
|
|
173
|
+
const timer = setTimeout(() => onDismiss(id), remaining.current);
|
|
174
|
+
return () => {
|
|
175
|
+
clearTimeout(timer);
|
|
176
|
+
remaining.current -= Date.now() - startedAt;
|
|
177
|
+
};
|
|
178
|
+
}, [paused, id, onDismiss]);
|
|
179
|
+
return (_jsxs("div", { "data-toast-id": id, className: "pointer-events-auto flex items-start gap-2 rounded-lg border bg-popover py-2 pl-4 pr-2 text-popover-foreground shadow-md transition-opacity duration-150 starting:opacity-0 motion-reduce:transition-none", children: [_jsx("p", { className: "flex-1 py-[calc((2.75rem-1lh)/2)] text-sm", children: message }), action && (_jsx(Button, { onClick: () => {
|
|
180
|
+
action.onClick();
|
|
181
|
+
onDismiss(id);
|
|
182
|
+
}, children: action.label })), _jsx(CloseButton, { "data-toast-close": "", onClick: () => onDismiss(id) })] }));
|
|
183
|
+
}
|
|
184
|
+
// トーストを出す関数を返す。ToastProvider の中で使う
|
|
185
|
+
export function useToast() {
|
|
186
|
+
const show = useContext(ToastContext);
|
|
187
|
+
if (!show)
|
|
188
|
+
throw new Error("useToast: ToastProvider の中で使う");
|
|
189
|
+
return show;
|
|
190
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Toast.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Toast.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type InputHTMLAttributes } from "react";
|
|
2
|
+
type NativeInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "defaultValue" | "onChange" | "className" | "name" | "multiple">;
|
|
3
|
+
type ValidateProps = {
|
|
4
|
+
/** 1つの値を確かめる。直し方を書いたエラーを返し、問題がなければ undefined を返す(例:メールアドレスの形) */
|
|
5
|
+
validate: (text: string) => string | undefined;
|
|
6
|
+
/** エラーが出た・変わった・消えたときに呼ぶ。受け取った文言を Field の error に渡す */
|
|
7
|
+
onErrorChange: (error: string | undefined) => void;
|
|
8
|
+
} | {
|
|
9
|
+
validate?: undefined;
|
|
10
|
+
onErrorChange?: undefined;
|
|
11
|
+
};
|
|
12
|
+
export type TokenInputProps = NativeInputProps & ValidateProps & {
|
|
13
|
+
/** 入れた値。並べた順にチップを出す。同じ値は2つ入れない */
|
|
14
|
+
value: readonly string[];
|
|
15
|
+
/** 値を入れたとき、外したときに、新しい値の並びで呼ぶ */
|
|
16
|
+
onChange: (values: string[]) => void;
|
|
17
|
+
/** チップの並びの名前(「入れたメールアドレス」) */
|
|
18
|
+
listLabel: string;
|
|
19
|
+
/** 外すボタンの読み上げの名前。何を外すかを含める(例:value => `「${value}」を外す`) */
|
|
20
|
+
removeLabel: (value: string) => string;
|
|
21
|
+
/** 入力欄の種類。メールアドレスなら email にする(docs/components/input.md の COMPONENTS-019)。省いたときは text */
|
|
22
|
+
type?: "text" | "email";
|
|
23
|
+
/** 外側の配置(余白と幅)だけに使う */
|
|
24
|
+
className?: string;
|
|
25
|
+
};
|
|
26
|
+
export declare function TokenInput({ value, onChange, listLabel, removeLabel, validate, onErrorChange, type, required, disabled, className, onKeyDown, onBlur, onPaste, onCompositionStart, onCompositionEnd, ...props }: TokenInputProps): import("react").JSX.Element;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef, useState, } from "react";
|
|
4
|
+
import { TagGroup } from "../tag-group/TagGroup.js";
|
|
5
|
+
import { cn } from "../../lib/cn.js";
|
|
6
|
+
// トークン入力。メールアドレスやタグのような複数の値を、1つの枠の中の入力欄に入れ、チップで並べる
|
|
7
|
+
// (docs/components/token-input.md の「トークン入力の作り方」)。
|
|
8
|
+
// 入力欄の前に TagGroup を置き、チップの移動と外す操作、外した後のフォーカスは TagGroup に任せる。
|
|
9
|
+
// 値の確かめは使う側から関数で受け取り、エラーは Field(FieldError)に出させる
|
|
10
|
+
// 入力中に値を区切る文字:読点、カンマ(半角と全角)
|
|
11
|
+
const TYPED_SEPARATOR = /[、,,]/;
|
|
12
|
+
// 貼り付けで値を分ける文字:入力中の区切りに、改行とタブを足す(表計算やメールの宛先から貼ったとき)
|
|
13
|
+
const PASTED_SEPARATOR = /[、,,\r\n\t]/;
|
|
14
|
+
function split(text, separator) {
|
|
15
|
+
return text
|
|
16
|
+
.split(new RegExp(separator.source, "g"))
|
|
17
|
+
.map(part => part.trim())
|
|
18
|
+
.filter(part => part !== "");
|
|
19
|
+
}
|
|
20
|
+
export function TokenInput({ value, onChange, listLabel, removeLabel, validate, onErrorChange, type = "text", required, disabled, className, onKeyDown, onBlur, onPaste, onCompositionStart, onCompositionEnd, ...props }) {
|
|
21
|
+
const inputRef = useRef(null);
|
|
22
|
+
const tagsRef = useRef(null);
|
|
23
|
+
const composingRef = useRef(false);
|
|
24
|
+
// 値になる前の、入力中の文字
|
|
25
|
+
const [draft, setDraft] = useState("");
|
|
26
|
+
// 入れた・外したことを読み上げる文。領域は空のときも置いておく(docs/a11y.md の A11Y-011)
|
|
27
|
+
const [status, setStatus] = useState("");
|
|
28
|
+
// 最後に知らせたエラー。エラーが出ている間だけ、入力中にも確かめ直す(docs/form/clearing-errors.md)
|
|
29
|
+
const errorRef = useRef(undefined);
|
|
30
|
+
function reportError(error) {
|
|
31
|
+
if (!onErrorChange || error === errorRef.current)
|
|
32
|
+
return;
|
|
33
|
+
errorRef.current = error;
|
|
34
|
+
onErrorChange(error);
|
|
35
|
+
}
|
|
36
|
+
// 区切った値のうち、確かめて通ったものを値に入れる。通らなかったものは入力欄に残し、最初のエラーを知らせる。
|
|
37
|
+
// 入れてある値と同じ値は、もう入っているので、入れずに捨てる
|
|
38
|
+
function add(parts, rest) {
|
|
39
|
+
const added = [];
|
|
40
|
+
const rejected = [];
|
|
41
|
+
let error;
|
|
42
|
+
for (const part of parts) {
|
|
43
|
+
if (value.includes(part) || added.includes(part))
|
|
44
|
+
continue;
|
|
45
|
+
const message = validate?.(part);
|
|
46
|
+
if (message) {
|
|
47
|
+
rejected.push(part);
|
|
48
|
+
error ??= message;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
added.push(part);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (added.length > 0) {
|
|
55
|
+
onChange([...value, ...added]);
|
|
56
|
+
setStatus(added.length === 1 ? `「${added[0]}」を入れました` : `${added.length}件を入れました`);
|
|
57
|
+
}
|
|
58
|
+
setDraft([...rejected, rest].filter(text => text !== "").join(", "));
|
|
59
|
+
reportError(error);
|
|
60
|
+
}
|
|
61
|
+
function removeValue(target) {
|
|
62
|
+
onChange(value.filter(item => item !== target));
|
|
63
|
+
setStatus(`「${target}」を外しました`);
|
|
64
|
+
}
|
|
65
|
+
// 入力中の文字に区切りの文字が入ったら、最後の区切りより前を値にし、後ろを入力欄に残す
|
|
66
|
+
function update(text) {
|
|
67
|
+
const match = [...text.matchAll(new RegExp(TYPED_SEPARATOR.source, "g"))].at(-1);
|
|
68
|
+
if (match?.index !== undefined) {
|
|
69
|
+
add(split(text.slice(0, match.index), TYPED_SEPARATOR), text.slice(match.index + 1).trimStart());
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
setDraft(text);
|
|
73
|
+
if (errorRef.current !== undefined) {
|
|
74
|
+
const parts = split(text, TYPED_SEPARATOR);
|
|
75
|
+
reportError(parts.map(part => validate?.(part)).find(Boolean));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function handleKeyDown(event) {
|
|
79
|
+
onKeyDown?.(event);
|
|
80
|
+
if (event.defaultPrevented)
|
|
81
|
+
return;
|
|
82
|
+
// かな漢字の変換を確定する Enter と Backspace では、値を入れず、外さない
|
|
83
|
+
if (event.nativeEvent.isComposing || composingRef.current)
|
|
84
|
+
return;
|
|
85
|
+
if (event.altKey || event.ctrlKey || event.metaKey)
|
|
86
|
+
return;
|
|
87
|
+
if (event.key === "Enter" && draft.trim() !== "") {
|
|
88
|
+
// フォームを送信せずに、入力中の文字を値にする。空のときの Enter は、ネイティブのまま送信させる
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
add(split(draft, TYPED_SEPARATOR), "");
|
|
91
|
+
}
|
|
92
|
+
else if (event.key === "Backspace" && draft === "" && value.length > 0) {
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
removeValue(value[value.length - 1]);
|
|
95
|
+
}
|
|
96
|
+
else if (event.key === "ArrowLeft" && draft === "" && value.length > 0 && !disabled) {
|
|
97
|
+
// 空のときだけ、末尾のチップへ移る。文字があるときは、カーソルの移動に使う
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
const buttons = tagsRef.current?.querySelectorAll("button");
|
|
100
|
+
buttons?.[buttons.length - 1]?.focus();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// 入力欄から離れたら、入力中の文字を値にする。送信したときに、入れたつもりの値が落ちないようにする
|
|
104
|
+
function handleBlur(event) {
|
|
105
|
+
onBlur?.(event);
|
|
106
|
+
if (draft.trim() !== "")
|
|
107
|
+
add(split(draft, TYPED_SEPARATOR), "");
|
|
108
|
+
}
|
|
109
|
+
// 区切りの文字か改行を含む文字を貼り付けたら、分けてすべて値にする。含まないときは、ネイティブのまま貼り付ける
|
|
110
|
+
function handlePaste(event) {
|
|
111
|
+
onPaste?.(event);
|
|
112
|
+
if (event.defaultPrevented)
|
|
113
|
+
return;
|
|
114
|
+
const pasted = event.clipboardData.getData("text");
|
|
115
|
+
if (!PASTED_SEPARATOR.test(pasted))
|
|
116
|
+
return;
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
const input = event.currentTarget;
|
|
119
|
+
const before = draft.slice(0, input.selectionStart ?? draft.length);
|
|
120
|
+
const after = draft.slice(input.selectionEnd ?? draft.length);
|
|
121
|
+
add(split(before + pasted + after, PASTED_SEPARATOR), "");
|
|
122
|
+
}
|
|
123
|
+
// 末尾のチップで右矢印キーを押したら、入力欄へ戻る。TagGroup は端でイベントを止めずに渡す(docs/components/tag-group.md)
|
|
124
|
+
function handleTagsKeyDown(event) {
|
|
125
|
+
if (event.defaultPrevented || event.key !== "ArrowRight")
|
|
126
|
+
return;
|
|
127
|
+
if (event.altKey || event.ctrlKey || event.metaKey)
|
|
128
|
+
return;
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
inputRef.current?.focus();
|
|
131
|
+
}
|
|
132
|
+
const items = value.map(item => ({ key: item, label: item }));
|
|
133
|
+
return (_jsxs("div", { className: cn(
|
|
134
|
+
// 枠は Input と同じ見た目にする。フォーカスの輪は、入力欄にフォーカスがあるときだけ枠に描く(チップの外すボタンは自分の輪を描く)
|
|
135
|
+
"flex min-h-11 w-full flex-col rounded-md border border-input bg-background text-foreground has-[input:focus-visible]:ring-2 has-[input:focus-visible]:ring-ring has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50 has-[input[aria-invalid=true]]:border-danger-icon", className), children: [_jsx("div", { ref: tagsRef, onKeyDown: handleTagsKeyDown, className: "px-4 pt-2 empty:hidden", children: disabled ? (_jsx(TagGroup, { "aria-label": listLabel, items: items })) : (_jsx(TagGroup, { "aria-label": listLabel, items: items, onRemove: removeValue, removeLabel: item => removeLabel(item.key), onEmpty: () => inputRef.current?.focus() })) }), _jsx("input", { ref: inputRef, type: type, value: draft, disabled: disabled,
|
|
136
|
+
// 値が1つもないときだけ、ネイティブの required で送信を止める。値があるときに空の入力欄で止めない
|
|
137
|
+
required: required ? value.length === 0 : undefined, "aria-required": required || undefined, onChange: event => {
|
|
138
|
+
if (composingRef.current)
|
|
139
|
+
setDraft(event.target.value);
|
|
140
|
+
else
|
|
141
|
+
update(event.target.value);
|
|
142
|
+
}, onKeyDown: handleKeyDown, onBlur: handleBlur, onPaste: handlePaste, onCompositionStart: (event) => {
|
|
143
|
+
composingRef.current = true;
|
|
144
|
+
onCompositionStart?.(event);
|
|
145
|
+
}, onCompositionEnd: (event) => {
|
|
146
|
+
composingRef.current = false;
|
|
147
|
+
// 変換で確定した読点を、区切りとして扱う
|
|
148
|
+
update(event.currentTarget.value);
|
|
149
|
+
onCompositionEnd?.(event);
|
|
150
|
+
},
|
|
151
|
+
// 入力欄の文字は、画面の密度にかかわらず text-base にする(docs/typography.md)。枠と輪は外側に描く
|
|
152
|
+
className: "min-w-0 flex-1 bg-transparent px-4 py-2 text-base outline-none disabled:cursor-not-allowed", ...props }), _jsx("span", { role: "status", className: "sr-only", children: status })] }));
|
|
153
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./TokenInput.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./TokenInput.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type CSSProperties, type FocusEvent, type PointerEvent, type ReactElement } from "react";
|
|
2
|
+
export interface TooltipProps {
|
|
3
|
+
/** ツールチップに出す短い文字。押せるものや大事な情報は入れない(タッチの画面では見えない) */
|
|
4
|
+
content: string;
|
|
5
|
+
/** 対象の要素を1つ。Button のように、受け取った props を DOM の要素へそのまま渡す部品にする */
|
|
6
|
+
children: ReactElement<TooltipTriggerProps>;
|
|
7
|
+
}
|
|
8
|
+
interface TooltipTriggerProps {
|
|
9
|
+
"aria-describedby"?: string;
|
|
10
|
+
style?: CSSProperties;
|
|
11
|
+
onPointerEnter?: (e: PointerEvent<HTMLElement>) => void;
|
|
12
|
+
onPointerLeave?: (e: PointerEvent<HTMLElement>) => void;
|
|
13
|
+
onFocus?: (e: FocusEvent<HTMLElement>) => void;
|
|
14
|
+
onBlur?: (e: FocusEvent<HTMLElement>) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function Tooltip({ content, children }: TooltipProps): import("react").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cloneElement, useEffect, useId, useRef, useState, } from "react";
|
|
4
|
+
import { placeBelowAnchor, supportsAnchorPositioning } from "../../lib/anchor.js";
|
|
5
|
+
// マウスを乗せてから出るまでと、離してから消えるまでの待ち時間(#59 で決めた値)
|
|
6
|
+
const SHOW_DELAY = 500;
|
|
7
|
+
const HIDE_DELAY = 100;
|
|
8
|
+
// 対象とツールチップの間の隙間(anchor positioning の my-1 と同じ4px)
|
|
9
|
+
const GAP = 4;
|
|
10
|
+
// 画面の端から離す幅(代わりの計算で、画面の外へはみ出さないようにする)
|
|
11
|
+
const EDGE = 8;
|
|
12
|
+
// キーボードで移ったフォーカスか。マウスで押したときのフォーカスでは、すぐには出さない
|
|
13
|
+
function isFocusVisible(el) {
|
|
14
|
+
try {
|
|
15
|
+
return el.matches(":focus-visible");
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// マウスを乗せたとき(0.5秒後)と、キーボードでフォーカスしたとき(すぐ)に、対象の名前や短い補足を出す。
|
|
22
|
+
// popover="manual" で最前面の層に出し、Esc キーで消す。ツールチップの上へマウスを移しても消さない(WCAG 1.4.13)
|
|
23
|
+
export function Tooltip({ content, children }) {
|
|
24
|
+
const id = useId();
|
|
25
|
+
// anchor-name に使える形にする(useId の値には、名前に使えない文字が入る)
|
|
26
|
+
const anchorName = `--tooltip-${id.replace(/[^A-Za-z0-9_-]/g, "")}`;
|
|
27
|
+
const tipRef = useRef(null);
|
|
28
|
+
const triggerRef = useRef(null);
|
|
29
|
+
const timer = useRef(undefined);
|
|
30
|
+
// マウスが対象かツールチップの上にあるか、キーボードのフォーカスがあるか。どちらかがあれば消さない
|
|
31
|
+
const hovering = useRef(false);
|
|
32
|
+
const focused = useRef(false);
|
|
33
|
+
const [open, setOpen] = useState(false);
|
|
34
|
+
// 出ているか。toggle イベントは後から届くので、先に届く beforetoggle で書き換え、二重に出さないようにする
|
|
35
|
+
const shown = useRef(false);
|
|
36
|
+
function clearTimer() {
|
|
37
|
+
clearTimeout(timer.current);
|
|
38
|
+
timer.current = undefined;
|
|
39
|
+
}
|
|
40
|
+
function show() {
|
|
41
|
+
clearTimer();
|
|
42
|
+
const tip = tipRef.current;
|
|
43
|
+
if (!tip || shown.current)
|
|
44
|
+
return;
|
|
45
|
+
tip.showPopover();
|
|
46
|
+
if (!supportsAnchorPositioning())
|
|
47
|
+
place(tip);
|
|
48
|
+
}
|
|
49
|
+
function hide() {
|
|
50
|
+
clearTimer();
|
|
51
|
+
const tip = tipRef.current;
|
|
52
|
+
if (tip && shown.current)
|
|
53
|
+
tip.hidePopover();
|
|
54
|
+
}
|
|
55
|
+
// 代わりの計算(lib/anchor.ts):対象の真下に、対象の中央に合わせて置く。下に入らなければ上に出し、左右は画面の中に収める。
|
|
56
|
+
// ツールチップの大きさを測るので、出した後に呼ぶ
|
|
57
|
+
function place(tip) {
|
|
58
|
+
// my-1 の余白は anchor positioning のためのもの。計算で置くときに残すと GAP と二重になる(上に出すときは対象に重なる)ので、外す
|
|
59
|
+
tip.style.margin = "0";
|
|
60
|
+
placeBelowAnchor(tip, triggerRef.current, { align: "center", gap: GAP, edge: EDGE });
|
|
61
|
+
}
|
|
62
|
+
function handlePointerEnter(e) {
|
|
63
|
+
if (e.pointerType === "touch")
|
|
64
|
+
return;
|
|
65
|
+
hovering.current = true;
|
|
66
|
+
clearTimer();
|
|
67
|
+
if (!shown.current)
|
|
68
|
+
timer.current = setTimeout(show, SHOW_DELAY);
|
|
69
|
+
}
|
|
70
|
+
function handlePointerLeave(e) {
|
|
71
|
+
if (e.pointerType === "touch")
|
|
72
|
+
return;
|
|
73
|
+
hovering.current = false;
|
|
74
|
+
clearTimer();
|
|
75
|
+
if (!focused.current)
|
|
76
|
+
timer.current = setTimeout(hide, HIDE_DELAY);
|
|
77
|
+
}
|
|
78
|
+
function handleFocus(e) {
|
|
79
|
+
if (!isFocusVisible(e.currentTarget))
|
|
80
|
+
return;
|
|
81
|
+
focused.current = true;
|
|
82
|
+
show();
|
|
83
|
+
}
|
|
84
|
+
function handleBlur() {
|
|
85
|
+
focused.current = false;
|
|
86
|
+
if (!hovering.current)
|
|
87
|
+
hide();
|
|
88
|
+
}
|
|
89
|
+
// 消えている間に外されたときに、待ち時間の後で出さないようにする
|
|
90
|
+
useEffect(() => clearTimer, []);
|
|
91
|
+
// 出ている間は、フォーカスがどこにあっても Esc キーで消せるようにする。
|
|
92
|
+
// ダイアログの中で出したときは、1回目の Esc キーでツールチップだけを消し、ダイアログは閉じない
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (!open)
|
|
95
|
+
return;
|
|
96
|
+
const doc = tipRef.current?.ownerDocument;
|
|
97
|
+
if (!doc)
|
|
98
|
+
return;
|
|
99
|
+
function handleKeyDown(e) {
|
|
100
|
+
if (e.key !== "Escape")
|
|
101
|
+
return;
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
e.stopPropagation();
|
|
104
|
+
hide();
|
|
105
|
+
}
|
|
106
|
+
doc.addEventListener("keydown", handleKeyDown, true);
|
|
107
|
+
return () => doc.removeEventListener("keydown", handleKeyDown, true);
|
|
108
|
+
}, [open]);
|
|
109
|
+
function handleBeforeToggle(e) {
|
|
110
|
+
shown.current = e.newState === "open";
|
|
111
|
+
}
|
|
112
|
+
function handleToggle(e) {
|
|
113
|
+
setOpen(e.newState === "open");
|
|
114
|
+
}
|
|
115
|
+
// 使う側が渡した props と、ツールチップの props の両方を呼ぶ
|
|
116
|
+
const own = children.props;
|
|
117
|
+
const trigger = cloneElement(children, {
|
|
118
|
+
"aria-describedby": [own["aria-describedby"], id].filter(Boolean).join(" "),
|
|
119
|
+
// anchor positioning で、ツールチップを対象に結ぶ
|
|
120
|
+
style: { ...own.style, anchorName },
|
|
121
|
+
onPointerEnter: e => {
|
|
122
|
+
triggerRef.current = e.currentTarget;
|
|
123
|
+
own.onPointerEnter?.(e);
|
|
124
|
+
handlePointerEnter(e);
|
|
125
|
+
},
|
|
126
|
+
onPointerLeave: e => {
|
|
127
|
+
own.onPointerLeave?.(e);
|
|
128
|
+
handlePointerLeave(e);
|
|
129
|
+
},
|
|
130
|
+
onFocus: e => {
|
|
131
|
+
triggerRef.current = e.currentTarget;
|
|
132
|
+
own.onFocus?.(e);
|
|
133
|
+
handleFocus(e);
|
|
134
|
+
},
|
|
135
|
+
onBlur: e => {
|
|
136
|
+
own.onBlur?.(e);
|
|
137
|
+
handleBlur();
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
return (_jsxs(_Fragment, { children: [trigger, _jsx("span", { ref: tipRef, id: id, popover: "manual", role: "tooltip", onBeforeToggle: handleBeforeToggle, onToggle: handleToggle, onPointerEnter: handlePointerEnter, onPointerLeave: handlePointerLeave, style: { positionAnchor: anchorName },
|
|
141
|
+
// 手前の層に出るので z- は付けない。anchor positioning では、対象の真下・中央に置き、
|
|
142
|
+
// 下に入らなければ上に出す。popover の既定の inset と margin を外して、置き場所の既定の揃えを使う
|
|
143
|
+
className: "inset-auto mx-0 my-1 max-w-xs rounded-sm border bg-popover px-2 py-1 text-sm text-popover-foreground shadow-md [position-area:block-end] [position-try-fallbacks:flip-block]", children: content })] }));
|
|
144
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Tooltip.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Tooltip.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface TreeViewItem {
|
|
3
|
+
/** 項目を見分ける値。ツリーの中で重ならない文字列にする */
|
|
4
|
+
id: string;
|
|
5
|
+
/** 項目の名前 */
|
|
6
|
+
label: string;
|
|
7
|
+
/** 名前の前に置くアイコン(フォルダ、ファイル)。大きさ(size-4)と aria-hidden="true" を付けて渡す */
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
/** 入れ子の項目。1つ以上あると、開閉できる項目になる */
|
|
10
|
+
children?: TreeViewItem[];
|
|
11
|
+
}
|
|
12
|
+
export interface TreeViewProps {
|
|
13
|
+
/** ツリーの名前(「フォルダ」)。見える見出しがあれば aria-labelledby で結ぶ */
|
|
14
|
+
"aria-label"?: string;
|
|
15
|
+
"aria-labelledby"?: string;
|
|
16
|
+
/** 項目の並び */
|
|
17
|
+
items: TreeViewItem[];
|
|
18
|
+
/** 選択中の項目の id。渡すと、選択を使う側で持つ。何も選ばないときは null */
|
|
19
|
+
value?: string | null;
|
|
20
|
+
/** value を省いたときの、初めの選択 */
|
|
21
|
+
defaultValue?: string | null;
|
|
22
|
+
/** 項目を選んだとき(押したとき、Enter キー、Space キー)に、その id で呼ぶ */
|
|
23
|
+
onChange?: (id: string) => void;
|
|
24
|
+
/** 初めに開いておく項目の id。開いた後の開閉は、部品の中に持つ */
|
|
25
|
+
defaultExpanded?: string[];
|
|
26
|
+
/** 外側の配置(余白と幅)だけに使う */
|
|
27
|
+
className?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare function TreeView({ items, value, defaultValue, onChange, defaultExpanded, className, ...props }: TreeViewProps): import("react").JSX.Element;
|