@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,70 @@
|
|
|
1
|
+
// 余白と角の丸みの決まり(docs/spacing/scale.md、docs/spacing/radius.md)。
|
|
2
|
+
// 調べるのは、画面を描くコードのすべて(部品、ストーリー、見本のページ)のクラス。
|
|
3
|
+
// CSS のファイル(sets.css)は、Tailwind と tokens.css を読み込むだけで余白も角の丸みも書かないので、見ない。
|
|
4
|
+
//
|
|
5
|
+
// SPACING-002(子要素に余白を配って間隔を作らない)は登録しない。fieldset の legend の下の余白(親の space-y が効かない)、
|
|
6
|
+
// 条件で出し入れする要素の上の余白、空の読み上げの領域に高さを出さない FieldError の *:mt-2 のように、
|
|
7
|
+
// 子の mt-* と mb-* には決まりに沿った使い方が多く、クラスだけでは「間隔を作るために配った」かを見分けられないため。
|
|
8
|
+
|
|
9
|
+
import { classes, sets, splitClass } from "./shared.mjs";
|
|
10
|
+
|
|
11
|
+
// 余白と間隔のクラス。長い名前を先に並べ、gap-x-4 を gap の x-4 と読まないようにする
|
|
12
|
+
const spacingRe = /^(gap-x|gap-y|gap|space-x|space-y|px|py|pt|pb|pl|pr|ps|pe|p|mx|my|mt|mb|ml|mr|ms|me|m)-(.+)$/;
|
|
13
|
+
// 5段階(docs/spacing/scale.md の表)。0 は余白を消すだけ、auto は余白の量ではなく寄せ方なので、段階の外に数えない
|
|
14
|
+
const steps = new Set(["1", "2", "4", "6", "8", "0"]);
|
|
15
|
+
|
|
16
|
+
function* spacingClasses() {
|
|
17
|
+
for (const file of sets.code) {
|
|
18
|
+
for (const { token, line } of classes(file)) {
|
|
19
|
+
const c = splitClass(token);
|
|
20
|
+
const m = c.utility.match(spacingRe);
|
|
21
|
+
// 値のない gap- は、テンプレートの `gap-${i}` の残り(key の文字列)で、クラスではない
|
|
22
|
+
if (!m || !m[2]) continue;
|
|
23
|
+
yield { file, line, token, kind: m[1], value: m[2], negative: c.negative };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const rules = [
|
|
29
|
+
{
|
|
30
|
+
// 段階の外の値:任意値、5段階の間の値(3、5、0.5 など)、32pxを超える値(12、16 など)、px(1px)。
|
|
31
|
+
// 例外:画面の端のセーフエリアの余白(env(safe-area-inset-*))を含む任意値(docs/spacing/scale.md)。
|
|
32
|
+
// 負の余白は SPACING-003 で見るので、ここでは数えない(同じクラスを2つの決まりで重ねて出さない)
|
|
33
|
+
id: "SPACING-001",
|
|
34
|
+
check: () =>
|
|
35
|
+
[...spacingClasses()]
|
|
36
|
+
.filter(({ kind, value, negative }) => {
|
|
37
|
+
if (negative || /^\[(-|calc\(-)/.test(value)) return false;
|
|
38
|
+
if (steps.has(value)) return false;
|
|
39
|
+
if (value === "auto" && kind.startsWith("m")) return false;
|
|
40
|
+
if (value === "reverse" && kind.startsWith("space-")) return false;
|
|
41
|
+
if (/^\[.*env\(safe-area-inset-[a-z]+\).*\]$/.test(value)) return false;
|
|
42
|
+
return true;
|
|
43
|
+
})
|
|
44
|
+
.map(({ file, line, token }) => ({ file, line, detail: `${token}(余白と間隔は 1、2、4、6、8 の5段階から選ぶ)` })),
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
// 負の余白:-mt-2 のような負の margin と space-*、mt-[-4px] のような負の任意値。
|
|
48
|
+
// 見えない押せる範囲を広げる after:-inset-* は余白ではないので、対象にしない
|
|
49
|
+
id: "SPACING-003",
|
|
50
|
+
check: () =>
|
|
51
|
+
[...spacingClasses()]
|
|
52
|
+
.filter(({ kind, value, negative }) => (kind.startsWith("m") || kind.startsWith("space-")) && (negative || /^\[(-|calc\(-)/.test(value)))
|
|
53
|
+
.map(({ file, line, token }) => ({ file, line, detail: `${token}(負の余白でずれを直さず、ずれの元の余白を直す)` })),
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
// 角の丸み:rounded-lg、rounded-md、rounded-sm、rounded-full と、丸めない rounded-none だけを使う。
|
|
57
|
+
// rounded-t-md、rounded-s-none のような辺と角の指定も、同じ値だけを使う(くっつけて並べる部品は docs/spacing/placement.md)。
|
|
58
|
+
// 値のない rounded(4px)、rounded-xs、rounded-xl 以上、任意値は段階の外
|
|
59
|
+
id: "SPACING-004",
|
|
60
|
+
check: () =>
|
|
61
|
+
sets.code.flatMap(file =>
|
|
62
|
+
classes(file, { bare: true })
|
|
63
|
+
.filter(({ token }) => {
|
|
64
|
+
const m = splitClass(token).utility.match(/^rounded(?:-(?:t|b|l|r|s|e|tl|tr|bl|br|ss|se|es|ee))?(?:-(.+))?$/);
|
|
65
|
+
return m && !["lg", "md", "sm", "full", "none"].includes(m[1]);
|
|
66
|
+
})
|
|
67
|
+
.map(({ token, line }) => ({ file, line, detail: `${token}(角の丸みは rounded-lg、rounded-md、rounded-sm、rounded-full から選ぶ)` })),
|
|
68
|
+
),
|
|
69
|
+
},
|
|
70
|
+
];
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// 文字の決まり(docs/typography.md)。
|
|
2
|
+
// クラスと JSX の属性は、画面を描くコードのすべて(部品、ストーリー、見本のページ)で調べる。
|
|
3
|
+
// CSS の宣言(font-size、font-family など)は、CSS のファイル(sets.css)で調べる。tokens.css は生成物で、
|
|
4
|
+
// font-sans と font-mono の書体を結び付ける場所なので、sets.css に入っていない。
|
|
5
|
+
|
|
6
|
+
import { classes, jsxTags, lineAt, read, sets, splitClass, stripComments } from "./shared.mjs";
|
|
7
|
+
|
|
8
|
+
const utilities = function* (options) {
|
|
9
|
+
for (const file of sets.code) {
|
|
10
|
+
for (const { token, line } of classes(file, options)) yield { file, line, token, utility: splitClass(token).utility };
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const byClass = (id, test, why, options) => ({
|
|
14
|
+
id,
|
|
15
|
+
check: () =>
|
|
16
|
+
[...utilities(options)].filter(({ utility }) => test(utility)).map(({ file, line, token }) => ({ file, line, detail: `${token}(${why})` })),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// JSX の style={{ … }} の中の名前(fontSize など)と、SVG の属性(fontSize=、font-size=)
|
|
20
|
+
function jsxStyles(names) {
|
|
21
|
+
const re = new RegExp(`(?:^|[\\s{,])(${names.join("|")})\\s*([:=])\\s*([^,}\\n]*)`, "g");
|
|
22
|
+
return sets.code.flatMap(file =>
|
|
23
|
+
jsxTags(file).flatMap(({ name, attrs, line }) => {
|
|
24
|
+
const found = [];
|
|
25
|
+
for (const m of attrs.matchAll(re)) {
|
|
26
|
+
// fontSize= の形は、SVG の要素(小文字の名前)の属性だけを見る。部品の props の fontSize= は、文字の大きさの直接の指定とは限らない
|
|
27
|
+
if (m[2] === "=" && !/^[a-z]/.test(name)) continue;
|
|
28
|
+
// 属性はタグの名前の後ろから始まるので、属性の中の行の番号を足す
|
|
29
|
+
found.push({ file, line: line + (attrs.slice(0, m.index).match(/\n/g)?.length ?? 0), name: m[1], value: m[3].replace(/^\{/, "").trim() });
|
|
30
|
+
}
|
|
31
|
+
return found;
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// CSS の宣言
|
|
37
|
+
function cssDeclarations(property) {
|
|
38
|
+
const re = new RegExp(`(?:^|[\\s;{])(${property})\\s*:\\s*([^;}]*)`, "g");
|
|
39
|
+
return sets.css.flatMap(file => {
|
|
40
|
+
const text = stripComments(read(file));
|
|
41
|
+
return [...text.matchAll(re)].map(m => ({ file, line: lineAt(text, m.index), value: m[2].trim() }));
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 文字の大きさの任意値(text-[15px]、text-[0.8rem]、text-[length:…]、text-(length:--x))。
|
|
46
|
+
// text-[#fff] のような色の任意値は、色の決まりで見る
|
|
47
|
+
const arbitrarySize = u => /^text-\[(length:.*|[\d.]+(px|rem|em|pt|%|vw|vh|vmin|vmax|cqw|cqi)?|(calc|clamp|min|max)\(.*)\]$/.test(u) || /^text-\(length:.*\)$/.test(u);
|
|
48
|
+
// 太さの任意値(font-[600]、font-[weight:…]、font-(weight:--x))
|
|
49
|
+
const arbitraryWeight = u => /^font-\[(\d+|weight:.*)\]$/.test(u) || /^font-\(weight:.*\)$/.test(u);
|
|
50
|
+
// 入力欄(中の文字を text-base にする要素)と、文字を入れない種類の input
|
|
51
|
+
const inputTags = new Set(["input", "textarea", "select", "Input", "Textarea", "Select", "SearchField", "NumberField", "TimeField", "PasswordInput", "TokenInput", "OtpInput"]);
|
|
52
|
+
const noTextTypes = /\btype=["'{]?["']?(checkbox|radio|range|hidden|file|color|submit|button|reset|image)\b/;
|
|
53
|
+
|
|
54
|
+
export const rules = [
|
|
55
|
+
{
|
|
56
|
+
// 文字の大きさの任意値のクラスと、style の fontSize と、SVG の fontSize 属性と、CSS の font-size
|
|
57
|
+
id: "TYPOGRAPHY-001",
|
|
58
|
+
check: () => [
|
|
59
|
+
...[...utilities()].filter(({ utility }) => arbitrarySize(utility)).map(({ file, line, token }) => ({ file, line, detail: `${token}(サイズの表のクラスから選ぶ)` })),
|
|
60
|
+
...jsxStyles(["fontSize", "font-size"]).map(({ file, line, name, value }) => ({ file, line, detail: `${name}: ${value}(サイズの表のクラスから選ぶ)` })),
|
|
61
|
+
...cssDeclarations("font-size").map(({ file, line, value }) => ({ file, line, detail: `font-size: ${value}(サイズの表のクラスから選ぶ)` })),
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
// tracking-*(既定の値に戻すだけの tracking-normal は除く)と、style の letterSpacing と、CSS の letter-spacing
|
|
66
|
+
id: "TYPOGRAPHY-002",
|
|
67
|
+
check: () => [
|
|
68
|
+
...[...utilities()].filter(({ utility }) => /^tracking-/.test(utility) && utility !== "tracking-normal").map(({ file, line, token }) => ({ file, line, detail: `${token}(字間は既定のまま使う)` })),
|
|
69
|
+
...jsxStyles(["letterSpacing", "letter-spacing"]).map(({ file, line, name, value }) => ({ file, line, detail: `${name}: ${value}(字間は既定のまま使う)` })),
|
|
70
|
+
...cssDeclarations("letter-spacing").map(({ file, line, value }) => ({ file, line, detail: `letter-spacing: ${value}(字間は既定のまま使う)` })),
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
// 書体:font-sans と font-mono のほかの書体のクラス(font-serif、font-['…']、font-(family-name:…))と、
|
|
75
|
+
// style の fontFamily と、SVG の fontFamily 属性と、CSS の font-family。
|
|
76
|
+
// 太さの任意値(font-[600])は TYPOGRAPHY-008 で見る。font-mono を使ってよい場面(TYPOGRAPHY-004)は、レビューで見る
|
|
77
|
+
id: "TYPOGRAPHY-003",
|
|
78
|
+
check: () => [
|
|
79
|
+
...[...utilities()]
|
|
80
|
+
.filter(({ utility }) => utility === "font-serif" || (/^font-[[(]/.test(utility) && !arbitraryWeight(utility)))
|
|
81
|
+
.map(({ file, line, token }) => ({ file, line, detail: `${token}(書体は font-sans か font-mono で選ぶ)` })),
|
|
82
|
+
...jsxStyles(["fontFamily", "font-family"]).map(({ file, line, name, value }) => ({ file, line, detail: `${name}: ${value}(書体は font-sans か font-mono で選ぶ)` })),
|
|
83
|
+
...cssDeclarations("font-family").map(({ file, line, value }) => ({ file, line, detail: `font-family: ${value}(書体は font-sans か font-mono で選ぶ)` })),
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
// 斜体:italic のクラスと、style の fontStyle と、CSS の font-style: italic / oblique。
|
|
88
|
+
// ブラウザが斜体で描く要素(em、i、cite、var、dfn、address)も、not-italic を付けないかぎり斜体になるので数える
|
|
89
|
+
id: "TYPOGRAPHY-005",
|
|
90
|
+
check: () => [
|
|
91
|
+
...[...utilities({ bare: true })].filter(({ utility }) => utility === "italic").map(({ file, line, token }) => ({ file, line, detail: `${token}(強調は太さで表す)` })),
|
|
92
|
+
...jsxStyles(["fontStyle", "font-style"])
|
|
93
|
+
.filter(({ value }) => /italic|oblique/.test(value))
|
|
94
|
+
.map(({ file, line, name, value }) => ({ file, line, detail: `${name}: ${value}(強調は太さで表す)` })),
|
|
95
|
+
...cssDeclarations("font-style")
|
|
96
|
+
.filter(({ value }) => /italic|oblique/.test(value))
|
|
97
|
+
.map(({ file, line, value }) => ({ file, line, detail: `font-style: ${value}(強調は太さで表す)` })),
|
|
98
|
+
...sets.code.flatMap(file =>
|
|
99
|
+
jsxTags(file)
|
|
100
|
+
.filter(({ name, attrs }) => ["em", "i", "cite", "var", "dfn", "address"].includes(name) && !/\bnot-italic\b/.test(attrs))
|
|
101
|
+
.map(({ name, line }) => ({ file, line, detail: `<${name}>(ブラウザが斜体で描く。強調は <strong> と太さで表す)` })),
|
|
102
|
+
),
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
// 入力欄の要素(input、textarea、select と、それを包む部品)のタグに、text-sm か text-xs を書いたもの。
|
|
107
|
+
// 部品の中で変数に入れたクラス(inputStyle など)はタグの外にあるので、ここでは見ない
|
|
108
|
+
id: "TYPOGRAPHY-006",
|
|
109
|
+
check: () =>
|
|
110
|
+
sets.code.flatMap(file =>
|
|
111
|
+
jsxTags(file)
|
|
112
|
+
.filter(({ name, attrs }) => inputTags.has(name) && !noTextTypes.test(attrs))
|
|
113
|
+
.flatMap(({ name, attrs, line }) =>
|
|
114
|
+
[...attrs.matchAll(/(?<=["'`\s])((?:[^\s"'`:]+:)*)(text-(?:xs|sm))(?=["'`\s/])/g)].map(m => ({ file, line, detail: `<${name}> の ${m[1]}${m[2]}(入力欄の文字は text-base にする)` })),
|
|
115
|
+
),
|
|
116
|
+
),
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
// サイズの表にない大きさ(text-3xl、text-5xl〜text-9xl)と、太さの表にない太さ(font-thin、font-extralight、font-light、
|
|
120
|
+
// font-extrabold、font-black、太さの任意値)。表にある text-xs(注釈、メタ情報、バッジ、アバターの頭文字)は数えない。
|
|
121
|
+
// text-xs を本文や操作要素に使っていないか(TYPOGRAPHY-007)は、レビューで見る
|
|
122
|
+
id: "TYPOGRAPHY-008",
|
|
123
|
+
check: () =>
|
|
124
|
+
[...utilities()]
|
|
125
|
+
.filter(({ utility }) => /^text-(3xl|[5-9]xl)(\/.*)?$/.test(utility) || /^font-(thin|extralight|light|extrabold|black)$/.test(utility) || arbitraryWeight(utility))
|
|
126
|
+
.map(({ file, line, token }) => ({ file, line, detail: `${token}(サイズと太さの表から選ぶ)` })),
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
// 英字の大文字:uppercase のクラスと、style の textTransform と、CSS の text-transform: uppercase
|
|
130
|
+
id: "TYPOGRAPHY-009",
|
|
131
|
+
check: () => [
|
|
132
|
+
...[...utilities({ bare: true })].filter(({ utility }) => utility === "uppercase").map(({ file, line, token }) => ({ file, line, detail: `${token}(英字の大文字の小見出しを付けない)` })),
|
|
133
|
+
...jsxStyles(["textTransform", "text-transform"])
|
|
134
|
+
.filter(({ value }) => /uppercase/.test(value))
|
|
135
|
+
.map(({ file, line, name, value }) => ({ file, line, detail: `${name}: ${value}(英字の大文字の小見出しを付けない)` })),
|
|
136
|
+
...cssDeclarations("text-transform")
|
|
137
|
+
.filter(({ value }) => /uppercase/.test(value))
|
|
138
|
+
.map(({ file, line, value }) => ({ file, line, detail: `text-transform: ${value}(英字の大文字の小見出しを付けない)` })),
|
|
139
|
+
],
|
|
140
|
+
},
|
|
141
|
+
];
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// 画面の文言の決まり(docs/writing/)。
|
|
2
|
+
// 調べるファイルは、部品、ストーリー、見本のページのすべて(sets.code)。部品の既定の文言も、ストーリーと見本のページの文言も、
|
|
3
|
+
// 利用者が読む文言として同じ決まりを守る。コメントは読まない(stripComments)。
|
|
4
|
+
// 画面の文言かどうかは、構文木なしには決めきれないので、決まりごとに、文言と分かる所だけを見る:
|
|
5
|
+
// - JSX の要素の中の文字(jsxTexts、jsxChildrenText)
|
|
6
|
+
// - 文言を渡す属性(label、title、description、confirmLabel など)の、文字だけの値
|
|
7
|
+
// - 文字列の値(strings)。日本語の言い回しや絵文字のように、コードの文字列には出ないものを探すときだけ使う
|
|
8
|
+
|
|
9
|
+
import { jsxAttrs, jsxChildrenText, jsxLiteral, jsxTags, jsxTexts, sets, strings } from "./shared.mjs";
|
|
10
|
+
|
|
11
|
+
// 属性の値が、文字だけ("…"、{"…"}、{`…`})なら、その文字を返す
|
|
12
|
+
const literal = jsxLiteral;
|
|
13
|
+
|
|
14
|
+
// 文言を渡す属性。ボタンの文言を渡す属性は、*Label の形のうち、ボタンに出すもの
|
|
15
|
+
const buttonLabelProps = new Set(["confirmLabel", "cancelLabel", "actionLabel", "acceptLabel", "submitLabel", "removeLabel", "pendingLabel"]);
|
|
16
|
+
const textProps = new Set(["label", "title", "description", "message", "aria-label", "placeholder", "alt", "heading", ...buttonLabelProps]);
|
|
17
|
+
|
|
18
|
+
// ボタンとリンクの要素の名前
|
|
19
|
+
const isButton = name => name === "button" || /^[A-Z]\w*Button$/.test(name) || name === "Button";
|
|
20
|
+
const isLink = name => name === "a" || /^[A-Z]\w*Link$/.test(name) || name === "LinkButton";
|
|
21
|
+
|
|
22
|
+
// 属性のうち、文言を渡すものの文字だけの値を、行の番号つきで返す
|
|
23
|
+
function textAttrs(file, names = textProps) {
|
|
24
|
+
return jsxTags(file).flatMap(tag =>
|
|
25
|
+
[...jsxAttrs(tag.attrs)].flatMap(([name, value]) => {
|
|
26
|
+
const text = names.has(name) ? literal(value) : null;
|
|
27
|
+
return text ? [{ tag, name, value: text, line: tag.line }] : [];
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 絵文字(絵文字で表示する文字と、異体字セレクタ U+FE0F で絵文字にした文字)。© や → のような記号は入れない
|
|
33
|
+
const emoji = /\p{Emoji_Presentation}|\p{Extended_Pictographic}\u{FE0F}/u;
|
|
34
|
+
// 調子を強める !。英字の ! は、否定の演算子(!open)と区別するため、語の後に付いて、後ろに識別子が続かないものだけ
|
|
35
|
+
const exclamation = /!|(?<=[\p{L}\p{N}))」])!(?![\w=(!.])/u;
|
|
36
|
+
// 日本語の文字
|
|
37
|
+
const japanese = /[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u;
|
|
38
|
+
// 呼びかけ(「さあ、」で始まる文)。docs の例の「さあ」だけを探す。ほかの呼びかけは、言い方が決まらないので見ない
|
|
39
|
+
const callout = /(?:^|[。\s])さあ[、,!!]/;
|
|
40
|
+
|
|
41
|
+
export const rules = [
|
|
42
|
+
{
|
|
43
|
+
// ボタンの中の文字か、ボタンの文言を渡す属性が「OK」「はい」「いいえ」だけのもの。<input type="submit" value="OK"> も見る
|
|
44
|
+
id: "WRITING-004",
|
|
45
|
+
check: () => {
|
|
46
|
+
const vague = /^(?:OK|Ok|ok|オーケー|はい|いいえ|Yes|No)[。.]?$/;
|
|
47
|
+
return sets.code.flatMap(file => {
|
|
48
|
+
const found = [];
|
|
49
|
+
for (const tag of jsxTags(file)) {
|
|
50
|
+
const attrs = jsxAttrs(tag.attrs);
|
|
51
|
+
const isSubmit = tag.name === "input" && /^(?:submit|button|reset)$/.test(literal(attrs.get("type")) ?? "");
|
|
52
|
+
const text = isButton(tag.name) ? jsxChildrenText(file, tag) : isSubmit ? literal(attrs.get("value")) : null;
|
|
53
|
+
if (text && vague.test(text)) found.push({ file, line: tag.line, detail: `<${tag.name}>${text}:押すと何が起きるかを書く` });
|
|
54
|
+
}
|
|
55
|
+
for (const { tag, name, value, line } of textAttrs(file, buttonLabelProps)) {
|
|
56
|
+
if (vague.test(value)) found.push({ file, line, detail: `<${tag.name} ${name}="${value}">:押すと何が起きるかを書く` });
|
|
57
|
+
}
|
|
58
|
+
return found;
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
// docs に挙げた回りくどい言い方:〜することができ(ます)、〜が可能です、〜を行います(過去の形も)。
|
|
64
|
+
// 日本語の言い回しなので、文字列の値と JSX の中の文字のすべてを見る
|
|
65
|
+
id: "WRITING-010",
|
|
66
|
+
check: () => {
|
|
67
|
+
const wordy = /することができ|が可能(?:です|でした|となります|になります)|を行(?:います|いました)/;
|
|
68
|
+
return sets.code.flatMap(file =>
|
|
69
|
+
[...strings(file), ...jsxTexts(file)].flatMap(({ value, line }) => (wordy.test(value) ? [{ file, line, detail: `「${value.match(wordy)[0]}」:「〜できます」「〜します」と短く書く` }] : [])),
|
|
70
|
+
);
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
// 絵文字、!、「さあ、」。絵文字と全角の ! と「さあ」は、コードの文字列には出ないので、文字列の値のすべてを見る。
|
|
75
|
+
// 英字の ! は、JSX の中の文字と、文言を渡す属性の値と、日本語を含む文字列の値だけを見る
|
|
76
|
+
id: "WRITING-014",
|
|
77
|
+
check: () =>
|
|
78
|
+
sets.code.flatMap(file => {
|
|
79
|
+
const found = new Map(); // 行 -> 説明(同じ行の重なりを1つにする)
|
|
80
|
+
const add = (line, value, what) => found.has(line) || found.set(line, `「${value.length > 30 ? `${value.slice(0, 30)}…` : value}」:${what}`);
|
|
81
|
+
const test = (value, line, ascii) => {
|
|
82
|
+
if (emoji.test(value)) add(line, value, "絵文字で調子を強めない");
|
|
83
|
+
else if ((ascii ? exclamation : /!/).test(value)) add(line, value, "感嘆符で調子を強めない");
|
|
84
|
+
else if (callout.test(value)) add(line, value, "「さあ」のような呼びかけを書かない");
|
|
85
|
+
};
|
|
86
|
+
// 日本語を含む文字列は画面の文言なので、英字の ! も見る
|
|
87
|
+
for (const { value, line } of strings(file)) test(value, line, japanese.test(value));
|
|
88
|
+
for (const { value, line } of jsxTexts(file)) test(value, line, true);
|
|
89
|
+
for (const { value, line } of textAttrs(file)) test(value, line, true);
|
|
90
|
+
return [...found].map(([line, detail]) => ({ file, line, detail }));
|
|
91
|
+
}),
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
// リンク(a、TextLink、LinkButton、*Link)の中の文字が「こちら」「ここ」「詳しくはこちら」のようなもの
|
|
95
|
+
id: "WRITING-018",
|
|
96
|
+
check: () => {
|
|
97
|
+
const vague = /^(?:詳しくは|詳細は)?(?:こちら|ここ)(?:から|へ|を(?:クリック|押す|見る|参照))?[。.]?$|^(?:click here|here)$/i;
|
|
98
|
+
return sets.code.flatMap(file =>
|
|
99
|
+
jsxTags(file).flatMap(tag => {
|
|
100
|
+
if (!isLink(tag.name)) return [];
|
|
101
|
+
const text = jsxChildrenText(file, tag);
|
|
102
|
+
return text && vague.test(text) ? [{ file, line: tag.line, detail: `<${tag.name}>${text}:リンク先が分かる言葉にする` }] : [];
|
|
103
|
+
}),
|
|
104
|
+
);
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
];
|
package/scripts/lint.mjs
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// 部品と見本のページのコードを、docs/ の決まりで検査する(#26)。
|
|
2
|
+
// node scripts/lint.mjs すべての分野
|
|
3
|
+
// node scripts/lint.mjs colors 分野を選ぶ(pnpm lint:colors)
|
|
4
|
+
// 分野ごとのルールは scripts/lint/<分野>.mjs に置き、export const rules = [{ id, check }] で書き出す。
|
|
5
|
+
// check() は、決まりから外れた所を [{ file, line, detail }] で返す。
|
|
6
|
+
//
|
|
7
|
+
// エラーには、決まりの名前、題、ドキュメントの場所を出す(#26 で決めた形)。名前と題と場所は docs/ から引く。
|
|
8
|
+
// docs/ の決まりの検査の行(決まり:`COLOR-001`、検査:`lint:colors`)と、登録したルールが食い違うときも落とす。
|
|
9
|
+
// 決まりの例外は、その行かすぐ上の行に、理由を付けて書く:
|
|
10
|
+
// // lint-ignore COLOR-001 理由
|
|
11
|
+
// {/* lint-ignore COLOR-001 理由 */}
|
|
12
|
+
// ファイル全体の例外は、先頭の20行のどこかに書く:// lint-ignore-file COLOR-001 理由
|
|
13
|
+
// 理由のない lint-ignore と、何も止めていない lint-ignore も落とす。
|
|
14
|
+
// 依存パッケージを使わず、Node.js に入っているモジュールだけで読む(RULES-004)。
|
|
15
|
+
//
|
|
16
|
+
// 使う側のプロジェクトでは、scripts/plain-ui-lint.mjs(npx plain-ui-lint)から、調べるフォルダを決めて走らせる。
|
|
17
|
+
// 決まりと tokens.css はパッケージの中から読み、コードと package.json は使う側から読む。
|
|
18
|
+
// plain-ui の中の作り方だけの決まり(internal: true のルール)は、使う側では走らせない。
|
|
19
|
+
|
|
20
|
+
import { readFileSync, readdirSync } from "node:fs";
|
|
21
|
+
import { basename, join, relative } from "node:path";
|
|
22
|
+
import { pathToFileURL } from "node:url";
|
|
23
|
+
import { consumer, packageRoot, read, rel, root, sets } from "./lint/shared.mjs";
|
|
24
|
+
|
|
25
|
+
const docsDir = join(packageRoot, "docs");
|
|
26
|
+
const lintDir = join(packageRoot, "scripts", "lint");
|
|
27
|
+
const errors = [];
|
|
28
|
+
|
|
29
|
+
/* 1. docs/ の決まり:名前 -> 題、場所、検査 */
|
|
30
|
+
function listMarkdown(dir) {
|
|
31
|
+
return readdirSync(dir, { withFileTypes: true }).flatMap(e => {
|
|
32
|
+
const p = join(dir, e.name);
|
|
33
|
+
return e.isDirectory() ? listMarkdown(p) : e.name.endsWith(".md") ? [p] : [];
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const docRules = new Map();
|
|
37
|
+
for (const path of listMarkdown(docsDir)) {
|
|
38
|
+
// 決まりの書き方を説明する rules.md の例は、本物の決まりではない
|
|
39
|
+
if (relative(docsDir, path) === "rules.md") continue;
|
|
40
|
+
const lines = readFileSync(path, "utf8").split("\n");
|
|
41
|
+
let fence = false;
|
|
42
|
+
lines.forEach((line, i) => {
|
|
43
|
+
if (line.startsWith("```")) fence = !fence;
|
|
44
|
+
if (fence) return;
|
|
45
|
+
const m = line.match(/^決まり:`([A-Z0-9]+-\d{3})`、検査:(.*)$/);
|
|
46
|
+
if (m) docRules.set(m[1], { title: lines[i - 2].replace(/^### /, ""), file: relative(root, path), check: m[2] });
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
// rules.md の中の本物の決まり(RULES-NNN)だけは読む
|
|
50
|
+
{
|
|
51
|
+
const lines = readFileSync(join(docsDir, "rules.md"), "utf8").split("\n");
|
|
52
|
+
let fence = false;
|
|
53
|
+
lines.forEach((line, i) => {
|
|
54
|
+
if (line.startsWith("```")) fence = !fence;
|
|
55
|
+
if (fence) return;
|
|
56
|
+
const m = line.match(/^決まり:`(RULES-\d{3})`、検査:(.*)$/);
|
|
57
|
+
if (m) docRules.set(m[1], { title: lines[i - 2].replace(/^### /, ""), file: relative(root, join(docsDir, "rules.md")), check: m[2] });
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* 2. 分野とルール */
|
|
62
|
+
const allAreas = readdirSync(lintDir)
|
|
63
|
+
.filter(f => f.endsWith(".mjs") && f !== "shared.mjs")
|
|
64
|
+
.map(f => basename(f, ".mjs"))
|
|
65
|
+
.sort();
|
|
66
|
+
const asked = process.argv.slice(2);
|
|
67
|
+
for (const a of asked) if (!allAreas.includes(a)) errors.push(`分野「${a}」がない(${allAreas.join("、")})`);
|
|
68
|
+
const areas = asked.length ? asked.filter(a => allAreas.includes(a)) : allAreas;
|
|
69
|
+
|
|
70
|
+
const registered = new Map(); // 決まりの名前 -> 分野
|
|
71
|
+
const runs = [];
|
|
72
|
+
for (const area of areas) {
|
|
73
|
+
// ファイルのパスのままでは、Windows で読めない。file: の URL にして読む
|
|
74
|
+
const { rules } = await import(pathToFileURL(join(lintDir, `${area}.mjs`)).href);
|
|
75
|
+
for (const rule of rules) {
|
|
76
|
+
const doc = docRules.get(rule.id);
|
|
77
|
+
if (!doc) errors.push(`${rule.id}:docs/ に、この名前の決まりがない(scripts/lint/${area}.mjs)`);
|
|
78
|
+
else if (doc.check !== `\`lint:${area}\``) errors.push(`${rule.id}:docs の検査の行が ${doc.check} で、\`lint:${area}\` ではない(${doc.file})`);
|
|
79
|
+
registered.set(rule.id, area);
|
|
80
|
+
if (consumer && rule.internal) continue;
|
|
81
|
+
runs.push({ area, rule });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// docs で lint:<分野> と書いた決まりが、その分野にあるか
|
|
85
|
+
for (const [id, doc] of docRules) {
|
|
86
|
+
const m = doc.check.match(/^`lint:([a-z0-9-]+)`$/);
|
|
87
|
+
if (!m || !areas.includes(m[1])) continue;
|
|
88
|
+
if (registered.get(id) !== m[1]) errors.push(`${id}:docs は \`lint:${m[1]}\` で検査すると書くが、scripts/lint/${m[1]}.mjs にない(${doc.file})`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* 3. lint-ignore */
|
|
92
|
+
const ignoreRe = /lint-ignore(-file)? ((?:[A-Z0-9]+-\d{3})(?:[、, ]+[A-Z0-9]+-\d{3})*)(.*)$/;
|
|
93
|
+
const ignores = new Map(); // path -> [{ ids, line, file, used }]
|
|
94
|
+
function ignoresOf(path) {
|
|
95
|
+
if (!ignores.has(path)) {
|
|
96
|
+
const list = [];
|
|
97
|
+
read(path)
|
|
98
|
+
.split("\n")
|
|
99
|
+
.forEach((text, i) => {
|
|
100
|
+
const m = text.match(ignoreRe);
|
|
101
|
+
if (!m) return;
|
|
102
|
+
const reason = m[3].replace(/\*\/\s*\}?\s*$/, "").trim();
|
|
103
|
+
// 行の先頭からコメントだけの行(// … か {/* … */})なら、次の行も止める。コードの後ろに書いたものは、その行だけを止める
|
|
104
|
+
const alone = /^\s*(?:\/\/|\{\s*\/\*|\/\*)/.test(text);
|
|
105
|
+
const entry = { ids: m[2].split(/[、, ]+/), line: i + 1, file: Boolean(m[1]), alone, reason, used: new Set() };
|
|
106
|
+
if (entry.file && i >= 20) errors.push(`${rel(path)}:${i + 1} lint-ignore-file は、先頭の20行に書く`);
|
|
107
|
+
if (!reason) errors.push(`${rel(path)}:${i + 1} lint-ignore に理由がない(${entry.ids.join("、")})`);
|
|
108
|
+
list.push(entry);
|
|
109
|
+
});
|
|
110
|
+
ignores.set(path, list);
|
|
111
|
+
}
|
|
112
|
+
return ignores.get(path);
|
|
113
|
+
}
|
|
114
|
+
function ignored(path, line, id) {
|
|
115
|
+
for (const entry of ignoresOf(path)) {
|
|
116
|
+
if (!entry.ids.includes(id)) continue;
|
|
117
|
+
if (entry.file || entry.line === line || (entry.alone && entry.line === line - 1)) {
|
|
118
|
+
entry.used.add(id);
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* 4. 実行 */
|
|
126
|
+
const found = new Map(); // 決まりの名前 -> [行]
|
|
127
|
+
for (const { rule } of runs) {
|
|
128
|
+
for (const issue of rule.check()) {
|
|
129
|
+
if (issue.file && issue.line && ignored(issue.file, issue.line, rule.id)) continue;
|
|
130
|
+
if (!found.has(rule.id)) found.set(rule.id, []);
|
|
131
|
+
found.get(rule.id).push(`${issue.file ? rel(issue.file) : ""}${issue.line ? `:${issue.line}` : ""} ${issue.detail}`.trim());
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// lint-ignore の点検。見つかったもののないファイルの lint-ignore も読む(理由のないもの、何も止めていないものを残さない)
|
|
135
|
+
for (const path of new Set([...sets.code, ...sets.css])) ignoresOf(path);
|
|
136
|
+
const fullRun = areas.length === allAreas.length;
|
|
137
|
+
for (const [path, list] of ignores) {
|
|
138
|
+
for (const entry of list) {
|
|
139
|
+
for (const id of entry.ids) {
|
|
140
|
+
const where = `${rel(path)}:${entry.line}`;
|
|
141
|
+
if (!docRules.has(id)) errors.push(`${where} lint-ignore ${id} という決まりが、docs/ にない`);
|
|
142
|
+
// すべての分野を走らせたときは、どの分野にもない決まりの lint-ignore も落とす(何も止めない)
|
|
143
|
+
else if (fullRun && !registered.has(id)) errors.push(`${where} lint-ignore ${id} は、リントで検査していない決まり。消す`);
|
|
144
|
+
// 何も止めていない lint-ignore(今回走らせた決まりの分だけ)
|
|
145
|
+
else if (registered.has(id) && !entry.used.has(id)) errors.push(`${where} lint-ignore ${id} が、何も止めていない。消す`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// 使う側で、調べるファイルが1つもないときは、フォルダの指定の誤りとして落とす(何も調べずに「問題なし」と出さない)
|
|
151
|
+
if (consumer && sets.code.length + sets.css.length + (sets.html?.length ?? 0) === 0) errors.push("調べるファイル(.tsx、.ts、.jsx、.js、.css、.html)が、指定したフォルダの中にない");
|
|
152
|
+
|
|
153
|
+
const total = [...found.values()].reduce((n, l) => n + l.length, 0) + errors.length;
|
|
154
|
+
const label = consumer ? "Plain UI のリント" : asked.length ? `リント(${areas.join("、")})` : "リント";
|
|
155
|
+
if (total === 0) {
|
|
156
|
+
console.log(`${label}:問題なし(決まり${runs.length}個、分野${areas.length}つ${consumer ? `、ファイル${new Set([...sets.code, ...sets.css, ...sets.html]).size}個` : ""})`);
|
|
157
|
+
process.exit(0);
|
|
158
|
+
}
|
|
159
|
+
console.error(`${label}:${total}件の問題`);
|
|
160
|
+
for (const e of errors) console.error(`- ${e}`);
|
|
161
|
+
for (const [id, lines] of [...found].sort(([a], [b]) => a.localeCompare(b))) {
|
|
162
|
+
const doc = docRules.get(id);
|
|
163
|
+
console.error(`${id} ${doc?.title ?? ""}(${doc?.file ?? "docs にない"})`);
|
|
164
|
+
for (const l of lines) console.error(` - ${l}`);
|
|
165
|
+
}
|
|
166
|
+
process.exit(1);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// 使う側のプロジェクトのコードが、Plain UI の決まり(docs/)を守っているかを調べる。パッケージの bin(plain-ui-lint)。
|
|
3
|
+
// npx plain-ui-lint コマンドを実行したフォルダの中をすべて調べる
|
|
4
|
+
// npx plain-ui-lint src app フォルダ(かファイル)を選ぶ
|
|
5
|
+
// 決まりの検査そのものは scripts/lint.mjs で、plain-ui の中の pnpm lint と同じルールを使う。
|
|
6
|
+
// node_modules、dist、build、out、coverage、. で始まるフォルダ、テスト、設定のファイルは調べない。
|
|
7
|
+
// package.json は、コマンドを実行したフォルダのものを読む(入れてはいけない依存パッケージを調べる)。
|
|
8
|
+
// 決まりの例外は、pnpm lint と同じく、理由を付けた // lint-ignore <決まりの名前> <理由> で書く。
|
|
9
|
+
|
|
10
|
+
import { existsSync } from "node:fs";
|
|
11
|
+
import { resolve } from "node:path";
|
|
12
|
+
|
|
13
|
+
const args = process.argv.slice(2);
|
|
14
|
+
if (args.includes("-h") || args.includes("--help")) {
|
|
15
|
+
console.log(`使い方:plain-ui-lint [フォルダ…]
|
|
16
|
+
|
|
17
|
+
使う側のコードが、Plain UI の決まりを守っているかを調べます。
|
|
18
|
+
フォルダを省くと、コマンドを実行したフォルダの中をすべて調べます。
|
|
19
|
+
決まりのドキュメントは node_modules/@knk1313/plain-ui/docs/ にあります。`);
|
|
20
|
+
process.exit(0);
|
|
21
|
+
}
|
|
22
|
+
const unknown = args.filter(a => a.startsWith("-"));
|
|
23
|
+
const missing = args.filter(a => !a.startsWith("-") && !existsSync(a));
|
|
24
|
+
if (unknown.length || missing.length) {
|
|
25
|
+
for (const a of unknown) console.error(`plain-ui-lint:${a} というオプションはない(--help で使い方を出す)`);
|
|
26
|
+
for (const a of missing) console.error(`plain-ui-lint:${a} が見つからない`);
|
|
27
|
+
process.exit(2);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// lint.mjs と shared.mjs は、読み込むときにこの値を見る。分野の引数と取り違えないように、引数は渡さない
|
|
31
|
+
process.env.PLAIN_UI_LINT_TARGETS = JSON.stringify((args.length ? args : ["."]).map(a => resolve(a)));
|
|
32
|
+
process.argv = process.argv.slice(0, 2);
|
|
33
|
+
await import("./lint.mjs");
|