@seanyeh77/ui 0.44.0 → 0.45.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 +1 -1
- package/dist/bundle.js +20 -20
- package/dist/components/AccentPicker/AccentPicker.d.ts +1 -0
- package/dist/components/AccentPicker/AccentPicker.js +92 -72
- package/dist/components/AccentPicker/AccentPicker.js.map +1 -1
- package/dist/components/ActionBar/ActionBar.d.ts +2 -0
- package/dist/components/ActionBar/ActionBar.js.map +1 -1
- package/dist/components/AiMark/AiMark.d.ts +1 -0
- package/dist/components/AiMark/AiMark.js.map +1 -1
- package/dist/components/Alert/Alert.d.ts +5 -2
- package/dist/components/Alert/Alert.js +17 -14
- package/dist/components/Alert/Alert.js.map +1 -1
- package/dist/components/AppShell/AppShell.d.ts +10 -4
- package/dist/components/AppShell/AppShell.js +30 -19
- package/dist/components/AppShell/AppShell.js.map +1 -1
- package/dist/components/Badge/Badge.d.ts +24 -7
- package/dist/components/Badge/Badge.js +78 -21
- package/dist/components/Badge/Badge.js.map +1 -1
- package/dist/components/BarChart/BarChart.d.ts +14 -1
- package/dist/components/BarChart/BarChart.js +88 -59
- package/dist/components/BarChart/BarChart.js.map +1 -1
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +1 -0
- package/dist/components/Breadcrumb/Breadcrumb.js.map +1 -1
- package/dist/components/Button/Button.d.ts +4 -1
- package/dist/components/Button/Button.js +17 -3
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Calendar/Calendar.d.ts +11 -2
- package/dist/components/Calendar/Calendar.js +16 -5
- package/dist/components/Calendar/Calendar.js.map +1 -1
- package/dist/components/Card/Card.d.ts +1 -0
- package/dist/components/Card/Card.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.d.ts +24 -8
- package/dist/components/Checkbox/Checkbox.js +22 -9
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/CodeView/CodeView.d.ts +3 -0
- package/dist/components/CodeView/CodeView.js +6 -6
- package/dist/components/CodeView/CodeView.js.map +1 -1
- package/dist/components/CommandPalette/CommandPalette.d.ts +16 -4
- package/dist/components/CommandPalette/CommandPalette.js +38 -11
- package/dist/components/CommandPalette/CommandPalette.js.map +1 -1
- package/dist/components/ConsoleLayout/ConsoleLayout.d.ts +2 -3
- package/dist/components/ConsoleLayout/ConsoleLayout.js +4 -1
- package/dist/components/ConsoleLayout/ConsoleLayout.js.map +1 -1
- package/dist/components/DangerZone/DangerZone.d.ts +2 -1
- package/dist/components/DangerZone/DangerZone.js +1 -1
- package/dist/components/DangerZone/DangerZone.js.map +1 -1
- package/dist/components/DataTable/DataTable.d.ts +8 -1
- package/dist/components/DataTable/DataTable.js +213 -167
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/DataTable/SortButton.js +48 -5
- package/dist/components/DataTable/SortButton.js.map +1 -1
- package/dist/components/DataTable/filters.js +2 -1
- package/dist/components/DataTable/filters.js.map +1 -1
- package/dist/components/DataTable/parts.js +1 -1
- package/dist/components/DataTable/parts.js.map +1 -1
- package/dist/components/DataTable/types.d.ts +10 -3
- package/dist/components/DatePicker/DatePicker.d.ts +7 -5
- package/dist/components/DatePicker/DatePicker.js +16 -6
- package/dist/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.d.ts +12 -7
- package/dist/components/DateRangePicker/DateRangePicker.js +81 -45
- package/dist/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/components/DetailList/DetailList.d.ts +2 -0
- package/dist/components/DetailList/DetailList.js.map +1 -1
- package/dist/components/Dialog/Dialog.d.ts +56 -20
- package/dist/components/Dialog/Dialog.js +45 -14
- package/dist/components/Dialog/Dialog.js.map +1 -1
- package/dist/components/Drawer/Drawer.d.ts +17 -5
- package/dist/components/Drawer/Drawer.js +86 -24
- package/dist/components/Drawer/Drawer.js.map +1 -1
- package/dist/components/ErrorPage/ErrorPage.d.ts +3 -0
- package/dist/components/ErrorPage/ErrorPage.js.map +1 -1
- package/dist/components/EventTimeline/EventTimeline.d.ts +22 -4
- package/dist/components/EventTimeline/EventTimeline.js +63 -20
- package/dist/components/EventTimeline/EventTimeline.js.map +1 -1
- package/dist/components/FileUpload/FileUpload.d.ts +9 -1
- package/dist/components/FileUpload/FileUpload.js +3 -1
- package/dist/components/FileUpload/FileUpload.js.map +1 -1
- package/dist/components/FormGrid/FormGrid.d.ts +3 -1
- package/dist/components/FormGrid/FormGrid.js +5 -2
- package/dist/components/FormGrid/FormGrid.js.map +1 -1
- package/dist/components/Graph/Graph.d.ts +1 -0
- package/dist/components/Graph/Graph.js +8 -4
- package/dist/components/Graph/Graph.js.map +1 -1
- package/dist/components/Grid/Grid.d.ts +11 -4
- package/dist/components/Grid/Grid.js +14 -2
- package/dist/components/Grid/Grid.js.map +1 -1
- package/dist/components/IconButton/IconButton.d.ts +2 -1
- package/dist/components/IconButton/IconButton.js +10 -1
- package/dist/components/IconButton/IconButton.js.map +1 -1
- package/dist/components/InlineCode/InlineCode.d.ts +6 -0
- package/dist/components/InlineCode/InlineCode.js.map +1 -1
- package/dist/components/KpiCard/KpiCard.d.ts +5 -1
- package/dist/components/KpiCard/KpiCard.js +35 -21
- package/dist/components/KpiCard/KpiCard.js.map +1 -1
- package/dist/components/LayerGraph/LayerGraph.d.ts +68 -23
- package/dist/components/LayerGraph/LayerGraph.js +159 -88
- package/dist/components/LayerGraph/LayerGraph.js.map +1 -1
- package/dist/components/LineChart/LineChart.d.ts +10 -3
- package/dist/components/LineChart/LineChart.js +55 -23
- package/dist/components/LineChart/LineChart.js.map +1 -1
- package/dist/components/Link/Link.d.ts +17 -0
- package/dist/components/Link/Link.js +47 -0
- package/dist/components/Link/Link.js.map +1 -0
- package/dist/components/LoadingBar/LoadingBar.d.ts +1 -0
- package/dist/components/LoadingBar/LoadingBar.js.map +1 -1
- package/dist/components/LoginCard/LoginCard.d.ts +9 -3
- package/dist/components/LoginCard/LoginCard.js +99 -78
- package/dist/components/LoginCard/LoginCard.js.map +1 -1
- package/dist/components/Markdown/Markdown.d.ts +1 -0
- package/dist/components/Markdown/Markdown.js +1 -1
- package/dist/components/Markdown/Markdown.js.map +1 -1
- package/dist/components/Menu/Menu.d.ts +4 -2
- package/dist/components/Menu/Menu.js +43 -33
- package/dist/components/Menu/Menu.js.map +1 -1
- package/dist/components/Meter/Meter.d.ts +4 -0
- package/dist/components/Meter/Meter.js.map +1 -1
- package/dist/components/MobileTabBar/MobileTabBar.d.ts +3 -0
- package/dist/components/MobileTabBar/MobileTabBar.js.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.d.ts +7 -6
- package/dist/components/MultiSelect/MultiSelect.js +27 -9
- package/dist/components/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/components/NotificationBell/NotificationBell.d.ts +3 -0
- package/dist/components/NotificationBell/NotificationBell.js +2 -2
- package/dist/components/NotificationBell/NotificationBell.js.map +1 -1
- package/dist/components/PageHeader/PageHeader.d.ts +34 -0
- package/dist/components/PageHeader/PageHeader.js +68 -0
- package/dist/components/PageHeader/PageHeader.js.map +1 -0
- package/dist/components/Popover/Popover.d.ts +11 -4
- package/dist/components/Popover/Popover.js +17 -7
- package/dist/components/Popover/Popover.js.map +1 -1
- package/dist/components/ProgressBar/ProgressBar.d.ts +2 -0
- package/dist/components/ProgressBar/ProgressBar.js.map +1 -1
- package/dist/components/ProgressRing/ProgressRing.d.ts +1 -0
- package/dist/components/ProgressRing/ProgressRing.js.map +1 -1
- package/dist/components/ProjectSwitcher/ProjectSwitcher.d.ts +5 -1
- package/dist/components/ProjectSwitcher/ProjectSwitcher.js +16 -3
- package/dist/components/ProjectSwitcher/ProjectSwitcher.js.map +1 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +22 -5
- package/dist/components/RadioGroup/RadioGroup.js +48 -47
- package/dist/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/components/RelativeTime/RelativeTime.d.ts +10 -0
- package/dist/components/RelativeTime/RelativeTime.js +44 -0
- package/dist/components/RelativeTime/RelativeTime.js.map +1 -0
- package/dist/components/SearchField/SearchField.d.ts +2 -0
- package/dist/components/SearchField/SearchField.js.map +1 -1
- package/dist/components/Section/Section.d.ts +4 -0
- package/dist/components/Section/Section.js +8 -22
- package/dist/components/Section/Section.js.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +22 -9
- package/dist/components/SegmentedControl/SegmentedControl.js +20 -19
- package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/components/Select/Select.d.ts +7 -11
- package/dist/components/Select/Select.js +7 -3
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/SettingsLayout/SettingsLayout.d.ts +32 -3
- package/dist/components/SettingsLayout/SettingsLayout.js +60 -13
- package/dist/components/SettingsLayout/SettingsLayout.js.map +1 -1
- package/dist/components/SideNav/SideNav.d.ts +2 -0
- package/dist/components/SideNav/SideNav.js +3 -3
- package/dist/components/SideNav/SideNav.js.map +1 -1
- package/dist/components/SplitPane/SplitPane.d.ts +1 -0
- package/dist/components/SplitPane/SplitPane.js.map +1 -1
- package/dist/components/StatusBand/StatusBand.d.ts +1 -0
- package/dist/components/StatusBand/StatusBand.js.map +1 -1
- package/dist/components/Suggestion/Suggestion.d.ts +6 -0
- package/dist/components/Suggestion/Suggestion.js.map +1 -1
- package/dist/components/Switch/Switch.d.ts +13 -3
- package/dist/components/Switch/Switch.js +16 -7
- package/dist/components/Switch/Switch.js.map +1 -1
- package/dist/components/Tabs/Tabs.d.ts +4 -0
- package/dist/components/Tabs/Tabs.js +1 -1
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/Tag/Tag.d.ts +15 -7
- package/dist/components/Tag/Tag.js +22 -10
- package/dist/components/Tag/Tag.js.map +1 -1
- package/dist/components/Term/Term.d.ts +8 -3
- package/dist/components/Term/Term.js +1 -1
- package/dist/components/Term/Term.js.map +1 -1
- package/dist/components/TextArea/TextArea.d.ts +6 -10
- package/dist/components/TextArea/TextArea.js +22 -10
- package/dist/components/TextArea/TextArea.js.map +1 -1
- package/dist/components/TextField/TextField.d.ts +8 -11
- package/dist/components/TextField/TextField.js +9 -7
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/ThemePicker/ThemePicker.d.ts +1 -0
- package/dist/components/ThemePicker/ThemePicker.js +35 -34
- package/dist/components/ThemePicker/ThemePicker.js.map +1 -1
- package/dist/components/TimeControl/TimeControl.d.ts +1 -0
- package/dist/components/TimeControl/TimeControl.js.map +1 -1
- package/dist/components/Toast/Toast.d.ts +55 -2
- package/dist/components/Toast/Toast.js +190 -8
- package/dist/components/Toast/Toast.js.map +1 -1
- package/dist/components/TopBar/TopBar.d.ts +6 -2
- package/dist/components/TopBar/TopBar.js +7 -1
- package/dist/components/TopBar/TopBar.js.map +1 -1
- package/dist/components/Tour/Tour.d.ts +14 -3
- package/dist/components/Tour/Tour.js +26 -14
- package/dist/components/Tour/Tour.js.map +1 -1
- package/dist/components/TreeList/TreeList.d.ts +28 -4
- package/dist/components/TreeList/TreeList.js +32 -20
- package/dist/components/TreeList/TreeList.js.map +1 -1
- package/dist/components/Workbench/Workbench.d.ts +1 -0
- package/dist/components/Workbench/Workbench.js +24 -12
- package/dist/components/Workbench/Workbench.js.map +1 -1
- package/dist/components/ZoneMap/ZoneMap.d.ts +12 -2
- package/dist/components/ZoneMap/ZoneMap.js +13 -5
- package/dist/components/ZoneMap/ZoneMap.js.map +1 -1
- package/dist/components/useFormErrors/useFormErrors.d.ts +20 -0
- package/dist/components/useFormErrors/useFormErrors.js +55 -0
- package/dist/components/useFormErrors/useFormErrors.js.map +1 -0
- package/dist/css/AccentPicker.css +1 -0
- package/dist/css/Alert.css +7 -19
- package/dist/css/AppShell.css +1 -0
- package/dist/css/Badge.css +19 -45
- package/dist/css/BarChart.css +21 -3
- package/dist/css/Button.css +5 -1
- package/dist/css/Card.css +8 -8
- package/dist/css/Checkbox.css +19 -0
- package/dist/css/CodeView.css +2 -1
- package/dist/css/DangerZone.css +4 -3
- package/dist/css/DataTable.css +129 -34
- package/dist/css/DateRangePicker.css +23 -2
- package/dist/css/Drawer.css +30 -0
- package/dist/css/ErrorPage.css +3 -1
- package/dist/css/EventTimeline.css +33 -5
- package/dist/css/FormGrid.css +12 -3
- package/dist/css/Graph.css +9 -1
- package/dist/css/Grid.css +8 -0
- package/dist/css/KpiCard.css +12 -1
- package/dist/css/LayerGraph.css +40 -15
- package/dist/css/Link.css +23 -0
- package/dist/css/LoginCard.css +16 -11
- package/dist/css/Markdown.css +2 -1
- package/dist/css/Menu.css +0 -2
- package/dist/css/Meter.css +16 -0
- package/dist/css/PageHeader.css +50 -0
- package/dist/css/ProgressBar.css +12 -0
- package/dist/css/ProjectSwitcher.css +23 -26
- package/dist/css/RelativeTime.css +2 -0
- package/dist/css/SegmentedControl.css +38 -10
- package/dist/css/SettingsLayout.css +28 -8
- package/dist/css/SideNav.css +4 -1
- package/dist/css/Skeleton.css +22 -1
- package/dist/css/Switch.css +27 -0
- package/dist/css/Tabs.css +2 -1
- package/dist/css/Tag.css +19 -12
- package/dist/css/Toast.css +100 -4
- package/dist/css/TopBar.css +21 -2
- package/dist/css/TreeList.css +6 -3
- package/dist/css/Workbench.css +1 -1
- package/dist/css/ZoneMap.css +0 -1
- package/dist/css/base.css +45 -0
- package/dist/css/end.css +119 -5
- package/dist/deprecated.d.ts +3 -0
- package/dist/deprecated.js +13 -0
- package/dist/deprecated.js.map +1 -0
- package/dist/fonts.css +2 -7543
- package/dist/format.d.ts +3 -1
- package/dist/format.js +12 -4
- package/dist/format.js.map +1 -1
- package/dist/generated/themeDefaults.d.ts +8 -0
- package/dist/generated/themeDefaults.js +35 -0
- package/dist/generated/themeDefaults.js.map +1 -0
- package/dist/i18n.d.ts +7 -2
- package/dist/i18n.js +65 -10
- package/dist/i18n.js.map +1 -1
- package/dist/icons/Icon.d.ts +3 -1
- package/dist/icons/Icon.js.map +1 -1
- package/dist/index.d.ts +23 -14
- package/dist/index.js +14 -8
- package/dist/internal/Field.d.ts +19 -0
- package/dist/internal/Field.js +10 -4
- package/dist/internal/Field.js.map +1 -1
- package/dist/internal/FloatingPanel.js +2 -1
- package/dist/internal/FloatingPanel.js.map +1 -1
- package/dist/internal/chart.d.ts +4 -0
- package/dist/internal/chart.js +89 -19
- package/dist/internal/chart.js.map +1 -1
- package/dist/internal/dev.js +9 -4
- package/dist/internal/dev.js.map +1 -1
- package/dist/internal/focus.js +27 -3
- package/dist/internal/focus.js.map +1 -1
- package/dist/internal/focusMain.js +6 -2
- package/dist/internal/focusMain.js.map +1 -1
- package/dist/internal/open.d.ts +14 -0
- package/dist/internal/open.js +28 -0
- package/dist/internal/open.js.map +1 -0
- package/dist/internal/roving.js +37 -0
- package/dist/internal/roving.js.map +1 -0
- package/dist/internal/shell.js +12 -0
- package/dist/internal/shell.js.map +1 -0
- package/dist/internal/stored.js +89 -0
- package/dist/internal/stored.js.map +1 -0
- package/dist/internal/tableTools.js +46 -4
- package/dist/internal/tableTools.js.map +1 -1
- package/dist/internal/util.js +8 -17
- package/dist/internal/util.js.map +1 -1
- package/dist/locale.d.ts +17 -0
- package/dist/locale.js +29 -0
- package/dist/locale.js.map +1 -0
- package/dist/styles.css +944 -231
- package/dist/theme.d.ts +23 -5
- package/dist/theme.js +85 -25
- package/dist/theme.js.map +1 -1
- package/dist/tokens.css +3 -0
- package/docs/AccentPicker.md +3 -1
- package/docs/Alert.md +4 -4
- package/docs/AppShell.md +11 -10
- package/docs/Badge.md +26 -16
- package/docs/BarChart.md +7 -4
- package/docs/Button.md +4 -5
- package/docs/Calendar.md +2 -2
- package/docs/Card.md +8 -7
- package/docs/Checkbox.md +4 -1
- package/docs/CodeView.md +30 -43
- package/docs/CommandPalette.md +3 -2
- package/docs/ConsoleLayout.md +5 -5
- package/docs/DangerZone.md +3 -3
- package/docs/DataColors.md +2 -2
- package/docs/DataTable.md +26 -148
- package/docs/DatePicker.md +1 -1
- package/docs/DateRangePicker.md +3 -0
- package/docs/DetailList.md +9 -9
- package/docs/Dialog.md +8 -5
- package/docs/Drawer.md +7 -5
- package/docs/EmptyState.md +0 -1
- package/docs/ErrorPage.md +1 -2
- package/docs/EventTimeline.md +23 -13
- package/docs/FileUpload.md +1 -2
- package/docs/FormGrid.md +2 -1
- package/docs/Format.md +4 -2
- package/docs/Graph.md +1 -1
- package/docs/Grid.md +5 -1
- package/docs/KpiCard.md +6 -5
- package/docs/LayerGraph.md +18 -53
- package/docs/LineChart.md +5 -3
- package/docs/Link.md +22 -0
- package/docs/LoginCard.md +7 -4
- package/docs/Markdown.md +2 -15
- package/docs/Menu.md +2 -0
- package/docs/Meter.md +1 -0
- package/docs/MultiSelect.md +2 -2
- package/docs/NotificationBell.md +1 -1
- package/docs/PageHeader.md +34 -0
- package/docs/Popover.md +3 -1
- package/docs/ProgressBar.md +3 -1
- package/docs/ProjectSwitcher.md +14 -14
- package/docs/RadioGroup.md +2 -0
- package/docs/RelativeTime.md +23 -0
- package/docs/Section.md +1 -1
- package/docs/SegmentedControl.md +9 -6
- package/docs/Select.md +2 -2
- package/docs/SettingsLayout.md +19 -5
- package/docs/SideNav.md +1 -1
- package/docs/Skeleton.md +2 -1
- package/docs/Switch.md +3 -1
- package/docs/Tabs.md +2 -1
- package/docs/Tag.md +9 -7
- package/docs/Term.md +3 -4
- package/docs/TextArea.md +2 -2
- package/docs/TextField.md +5 -4
- package/docs/ThemePicker.md +3 -1
- package/docs/Toast.md +17 -6
- package/docs/TopBar.md +8 -5
- package/docs/Tour.md +3 -2
- package/docs/TreeList.md +10 -37
- package/docs/Workbench.md +1 -48
- package/docs/ZoneMap.md +5 -5
- package/docs/agents.md +82 -0
- package/docs/code.md +2 -2
- package/docs/components.json +314 -0
- package/docs/data.md +9 -19
- package/docs/forms.md +6 -5
- package/docs/guidelines.md +39 -31
- package/docs/icons.md +9 -0
- package/docs/layout.md +16 -20
- package/docs/motion.md +31 -56
- package/docs/theme.md +15 -18
- package/docs/useFormErrors.md +35 -0
- package/package.json +8 -7
- package/dist/bundle.js.map +0 -1
- package/dist/fonts/LICENSE-OFL.txt +0 -93
- package/dist/fonts/geist-mono-cyrillic-400-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-cyrillic-500-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-cyrillic-600-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-cyrillic-700-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-cyrillic-ext-400-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-cyrillic-ext-500-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-cyrillic-ext-600-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-cyrillic-ext-700-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-latin-400-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-latin-500-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-latin-600-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-latin-700-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-latin-ext-400-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-latin-ext-500-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-latin-ext-600-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-latin-ext-700-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-symbols2-400-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-symbols2-500-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-symbols2-600-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-symbols2-700-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-vietnamese-400-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-vietnamese-500-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-vietnamese-600-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-vietnamese-700-normal.woff2 +0 -0
- package/dist/fonts/inter-cyrillic-400-normal.woff2 +0 -0
- package/dist/fonts/inter-cyrillic-500-normal.woff2 +0 -0
- package/dist/fonts/inter-cyrillic-600-normal.woff2 +0 -0
- package/dist/fonts/inter-cyrillic-700-normal.woff2 +0 -0
- package/dist/fonts/inter-cyrillic-ext-400-normal.woff2 +0 -0
- package/dist/fonts/inter-cyrillic-ext-500-normal.woff2 +0 -0
- package/dist/fonts/inter-cyrillic-ext-600-normal.woff2 +0 -0
- package/dist/fonts/inter-cyrillic-ext-700-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-400-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-500-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-600-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-700-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-ext-400-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-ext-500-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-ext-600-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-ext-700-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-400-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-500-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-600-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-700-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-400-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-500-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-600-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-700-normal.woff2 +0 -0
- package/dist/fonts/inter-vietnamese-400-normal.woff2 +0 -0
- package/dist/fonts/inter-vietnamese-500-normal.woff2 +0 -0
- package/dist/fonts/inter-vietnamese-600-normal.woff2 +0 -0
- package/dist/fonts/inter-vietnamese-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-0-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-0-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-0-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-0-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-1-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-1-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-1-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-1-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-10-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-10-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-10-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-10-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-101-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-101-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-101-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-101-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-102-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-102-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-102-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-102-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-103-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-103-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-103-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-103-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-104-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-104-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-104-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-104-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-105-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-105-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-105-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-105-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-106-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-106-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-106-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-106-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-107-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-107-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-107-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-107-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-108-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-108-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-108-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-108-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-109-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-109-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-109-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-109-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-11-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-11-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-11-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-11-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-110-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-110-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-110-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-110-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-111-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-111-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-111-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-111-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-112-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-112-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-112-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-112-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-113-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-113-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-113-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-113-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-114-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-114-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-114-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-114-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-115-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-115-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-115-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-115-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-116-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-116-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-116-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-116-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-117-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-117-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-117-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-117-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-118-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-118-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-118-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-118-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-119-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-119-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-119-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-119-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-12-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-12-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-12-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-12-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-120-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-120-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-120-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-120-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-121-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-121-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-121-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-121-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-122-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-122-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-122-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-122-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-123-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-123-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-123-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-123-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-2-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-2-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-2-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-2-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-23-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-23-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-23-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-23-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-24-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-24-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-24-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-24-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-25-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-25-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-25-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-25-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-26-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-26-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-26-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-26-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-27-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-27-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-27-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-27-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-28-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-28-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-28-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-28-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-29-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-29-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-29-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-29-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-30-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-30-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-30-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-30-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-31-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-31-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-31-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-31-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-32-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-32-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-32-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-32-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-33-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-33-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-33-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-33-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-34-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-34-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-34-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-34-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-35-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-35-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-35-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-35-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-36-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-36-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-36-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-36-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-37-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-37-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-37-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-37-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-38-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-38-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-38-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-38-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-39-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-39-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-39-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-39-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-4-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-4-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-4-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-4-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-40-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-40-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-40-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-40-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-41-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-41-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-41-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-41-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-42-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-42-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-42-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-42-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-43-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-43-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-43-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-43-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-44-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-44-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-44-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-44-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-45-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-45-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-45-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-45-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-46-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-46-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-46-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-46-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-47-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-47-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-47-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-47-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-48-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-48-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-48-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-48-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-49-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-49-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-49-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-49-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-50-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-50-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-50-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-50-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-51-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-51-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-51-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-51-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-52-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-52-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-52-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-52-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-53-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-53-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-53-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-53-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-54-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-54-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-54-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-54-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-55-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-55-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-55-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-55-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-56-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-56-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-56-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-56-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-57-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-57-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-57-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-57-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-58-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-58-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-58-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-58-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-59-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-59-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-59-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-59-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-60-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-60-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-60-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-60-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-61-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-61-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-61-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-61-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-62-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-62-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-62-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-62-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-63-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-63-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-63-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-63-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-64-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-64-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-64-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-64-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-65-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-65-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-65-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-65-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-66-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-66-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-66-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-66-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-67-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-67-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-67-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-67-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-68-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-68-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-68-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-68-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-69-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-69-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-69-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-69-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-70-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-70-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-70-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-70-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-71-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-71-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-71-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-71-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-72-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-72-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-72-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-72-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-73-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-73-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-73-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-73-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-74-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-74-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-74-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-74-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-75-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-75-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-75-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-75-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-76-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-76-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-76-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-76-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-77-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-77-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-77-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-77-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-78-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-78-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-78-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-78-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-79-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-79-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-79-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-79-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-80-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-80-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-80-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-80-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-81-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-81-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-81-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-81-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-82-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-82-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-82-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-82-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-83-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-83-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-83-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-83-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-84-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-84-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-84-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-84-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-85-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-85-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-85-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-85-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-86-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-86-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-86-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-86-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-87-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-87-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-87-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-87-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-88-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-88-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-88-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-88-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-89-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-89-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-89-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-89-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-90-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-90-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-90-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-90-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-91-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-91-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-91-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-91-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-92-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-92-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-92-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-92-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-93-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-93-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-93-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-93-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-94-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-94-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-94-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-94-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-95-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-95-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-95-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-95-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-96-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-96-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-96-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-96-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-cyrillic-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-cyrillic-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-cyrillic-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-cyrillic-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-latin-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-latin-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-latin-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-latin-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-latin-ext-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-latin-ext-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-latin-ext-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-latin-ext-700-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-vietnamese-400-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-vietnamese-500-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-vietnamese-600-normal.woff2 +0 -0
- package/dist/fonts/noto-sans-tc-vietnamese-700-normal.woff2 +0 -0
|
@@ -17,7 +17,7 @@ includeIcons(caret_right_default, push_pin_default, sidebar_simple_default);
|
|
|
17
17
|
const isBrand = (b) => !!b && typeof b === "object" && !React.isValidElement(b) && !Array.isArray(b) && typeof b.name === "string";
|
|
18
18
|
function NavBrandRow({ brand, collapsed }) {
|
|
19
19
|
const spec = isBrand(brand) ? brand : typeof brand === "string" ? { name: brand } : null;
|
|
20
|
-
devWarn(!spec && collapsed, "SideNav", "brand
|
|
20
|
+
devWarn(!spec && collapsed, "SideNav", "brand is an element, so the collapsed sidebar cannot tell which part is the logo and hides all of it. Pass brand={{ mark, name, href }}: collapsed shows mark, expanded adds the name.");
|
|
21
21
|
if (!spec) return /* @__PURE__ */ jsx("div", {
|
|
22
22
|
className: "ui-nav-brand",
|
|
23
23
|
children: collapsed ? null : brand
|
|
@@ -197,7 +197,7 @@ function SideNav({ sections, value, onChange, collapsed = false, onToggle, onPin
|
|
|
197
197
|
onClick: onPin,
|
|
198
198
|
children: /* @__PURE__ */ jsx(Icon, {
|
|
199
199
|
name: "push-pin",
|
|
200
|
-
size:
|
|
200
|
+
size: 22,
|
|
201
201
|
filled: pinned
|
|
202
202
|
})
|
|
203
203
|
})
|
|
@@ -212,7 +212,7 @@ function SideNav({ sections, value, onChange, collapsed = false, onToggle, onPin
|
|
|
212
212
|
onClick: onToggle,
|
|
213
213
|
children: /* @__PURE__ */ jsx(Icon, {
|
|
214
214
|
name: "sidebar-simple",
|
|
215
|
-
size:
|
|
215
|
+
size: 22
|
|
216
216
|
})
|
|
217
217
|
})
|
|
218
218
|
}) : null]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SideNav.js","names":["phCaretRight","phPushPin","phSidebarSimple"],"sources":["../../../src/components/SideNav/SideNav.tsx"],"sourcesContent":["import * as React from 'react';\nimport { tr } from '../../i18n';\nimport { Icon, IconOf, type IconSource } from '../../icons/Icon';\nimport { dropTransition, useMoving } from '../../motion';\nimport { announce } from '../../announce';\nimport { cx } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { Tooltip } from '../Tooltip/Tooltip';\nimport { includeIcons } from '../../icons/store';\nimport phCaretRight from '../../icons/ph/caret-right';\nimport phPushPin from '../../icons/ph/push-pin';\nimport phSidebarSimple from '../../icons/ph/sidebar-simple';\n\nincludeIcons(phCaretRight, phPushPin, phSidebarSimple);\n\nexport interface NavItem {\n id: string;\n label: string;\n /** Top-level items have an icon; the selected one is filled. */\n icon?: IconSource;\n /** Second level, shown under the item; it opens and closes. */\n children?: NavItem[];\n}\n\nexport interface NavSection {\n items: NavItem[];\n}\n\n/** The product at the top of the sidebar. */\nexport interface NavBrand {\n /** Logo or colour block, at most 24 px: stays where it is, collapsed and open. Default: the first character of\n * `name` in an accent square. */\n mark?: React.ReactNode;\n /** The product name: shown beside the mark when the sidebar is open, the link's name when collapsed. */\n name: string;\n /** Usually the home page. */\n href?: string;\n onClick?: (e: React.MouseEvent<HTMLElement>) => void;\n}\n\nconst isBrand = (b: unknown): b is NavBrand =>\n !!b && typeof b === 'object' && !React.isValidElement(b) && !Array.isArray(b) && typeof (b as NavBrand).name === 'string';\n\nfunction NavBrandRow({ brand, collapsed }: { brand: React.ReactNode | NavBrand; collapsed: boolean }) {\n const spec: NavBrand | null = isBrand(brand) ? brand : typeof brand === 'string' ? { name: brand } : null;\n devWarn(\n !spec && collapsed,\n 'SideNav',\n 'brand 是一個元素,收合時讀不出哪部分是 logo,只能整塊藏起來。改傳 brand={{ mark, name, href }}:收合時顯示 mark,展開時加上名稱。',\n );\n if (!spec) return <div className=\"ui-nav-brand\">{collapsed ? null : (brand as React.ReactNode)}</div>;\n const inner = (\n <>\n <span className=\"ui-nav-mark\" aria-hidden=\"true\">\n {spec.mark ?? <span className=\"ui-nav-monogram\">{Array.from(spec.name)[0]}</span>}\n </span>\n <span className=\"ui-nav-brand-name\">{spec.name}</span>\n </>\n );\n // Collapsed, the name is invisible but the link keeps it as its label.\n const label = collapsed ? spec.name : undefined;\n return (\n <div className=\"ui-nav-brand has-mark\">\n {spec.href ? (\n <a className=\"ui-nav-brand-link\" href={spec.href} onClick={spec.onClick} aria-label={label}>\n {inner}\n </a>\n ) : spec.onClick ? (\n <button type=\"button\" className=\"ui-nav-brand-link\" onClick={spec.onClick} aria-label={label}>\n {inner}\n </button>\n ) : (\n <span className=\"ui-nav-brand-link\" aria-label={label} role={label ? 'img' : undefined}>\n {inner}\n </span>\n )}\n </div>\n );\n}\n\nexport interface SideNavProps {\n /** Groups separated by a divider. */\n sections: NavSection[];\n /** Id of the current page. */\n value: string;\n onChange?: (id: string) => void;\n /** 72 px with icons only, labels as tooltips. */\n collapsed?: boolean;\n /** Adds the collapse button at the bottom left. */\n onToggle?: () => void;\n /** Adds the pin button at the bottom left (AppShell): pinned, the sidebar stays; not pinned, it hides to icons. */\n onPin?: () => void;\n /** Whether the sidebar is pinned: the pin button is filled and says 「取消釘選」. */\n pinned?: boolean;\n /** The product at the top. Prefer { mark, name, href }: collapsed (72 px) it shows only the mark, still a link\n * named by `name`; open, the mark with the name fading in beside it. Text alone gets its first character in an\n * accent square as the mark. Any other element is hidden while collapsed. */\n brand?: React.ReactNode | NavBrand;\n /** Default 「主要導覽」. */\n label?: string;\n className?: string;\n}\n\n/** The 240 px dashboard sidebar (72 px collapsed). The selection bar moves like a droplet. */\nexport function SideNav({ sections, value, onChange, collapsed = false, onToggle, onPin, pinned = false, brand, label, className }: SideNavProps) {\n const refs = React.useRef<Record<string, HTMLButtonElement | null>>({});\n const wrap = React.useRef<HTMLDivElement>(null);\n const [bar, setBar] = React.useState({ top: 0, bottom: 0, show: false, down: true });\n const last = React.useRef<{ top: number; bottom: number } | null>(null);\n const [moving, bump] = useMoving();\n // A page change is announced (not the first page): screen readers hear where they are now.\n const firstValue = React.useRef<string | undefined>(value);\n React.useEffect(() => {\n if (value === firstValue.current) return;\n firstValue.current = undefined;\n const all = sections.flatMap((sec) => sec.items.flatMap((it) => [it, ...(it.children ?? [])]));\n const it = all.find((x) => x.id === value);\n if (it) announce(it.label);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- only when the page changes\n }, [value]);\n const [closed, setClosed] = React.useState<Record<string, boolean>>({});\n const closedKey = Object.keys(closed)\n .filter((k) => closed[k])\n .join();\n React.useLayoutEffect(() => {\n let el = refs.current[value];\n if (!el) {\n const parent = sections.flatMap((s) => s.items).find((it) => it.children?.some((c) => c.id === value));\n el = parent ? refs.current[parent.id] : null;\n }\n const box = wrap.current;\n if (!el || !box) return;\n const y = el.getBoundingClientRect().top - box.getBoundingClientRect().top;\n const top = Math.round(y) + 8;\n const bottom = Math.round(box.clientHeight - y - el.offsetHeight) + 8;\n const prev = last.current;\n if (prev && prev.top === top && prev.bottom === bottom) return;\n if (prev && prev.top !== top) bump();\n last.current = { top, bottom };\n setBar({ top, bottom, show: true, down: !prev || top >= prev.top });\n }, [value, collapsed, closedKey, sections, bump]);\n\n const row = (it: NavItem, sub: boolean): React.ReactNode[] => {\n const kids = it.children ?? [];\n const hasKids = kids.length > 0 && !collapsed;\n const isOpen = !closed[it.id];\n const selected = value === it.id || ((!hasKids || !isOpen) && kids.some((c) => c.id === value));\n const out: React.ReactNode[] = [\n <div key={it.id} className=\"ui-nav-row\">\n <button\n type=\"button\"\n ref={(n) => {\n refs.current[it.id] = n;\n }}\n className={cx('ui-nav-item', sub && 'is-sub', selected && 'is-selected')}\n aria-current={selected ? 'page' : undefined}\n aria-expanded={hasKids ? isOpen : undefined}\n aria-label={collapsed ? it.label : undefined}\n // Collapsed, a parent opens its first page; the page switches between its siblings itself.\n onClick={() => (hasKids ? setClosed({ ...closed, [it.id]: isOpen }) : onChange?.(kids[0]?.id ?? it.id))}\n >\n {it.icon && !sub ? <IconOf icon={it.icon} size={22} filled={selected} className=\"ui-nav-icon\" /> : null}\n {collapsed ? null : <span className=\"ui-nav-label\">{it.label}</span>}\n {hasKids ? <Icon name=\"caret-right\" size={16} className={cx('ui-nav-chev', isOpen && 'is-open')} /> : null}\n </button>\n {collapsed ? (\n <span className=\"ui-nav-tip\" role=\"tooltip\">\n {it.label}\n </span>\n ) : null}\n </div>,\n ];\n if (hasKids && isOpen) for (const c of kids) out.push(...row(c, true));\n return out;\n };\n\n const toggleLabel = collapsed ? tr('展開側邊欄') : tr('收合側邊欄');\n return (\n <aside className={cx('ui-sidenav', collapsed && 'is-collapsed', className)}>\n {brand ? <NavBrandRow brand={brand} collapsed={collapsed} /> : null}\n <nav className=\"ui-nav-list\" aria-label={label || tr('主要導覽')}>\n <div ref={wrap} className=\"ui-nav-inner\">\n {bar.show ? (\n <span\n className=\"ui-nav-bar\"\n aria-hidden=\"true\"\n style={{ top: bar.top, bottom: bar.bottom, transform: moving ? 'scaleX(.7)' : 'none', transition: dropTransition('top', 'bottom', bar.down) }}\n />\n ) : null}\n {sections.map((sec, i) => (\n <React.Fragment key={i}>\n {i > 0 ? <div className=\"ui-nav-divider\" role=\"separator\" /> : null}\n {sec.items.flatMap((it) => row(it, false))}\n </React.Fragment>\n ))}\n </div>\n </nav>\n {onToggle || onPin ? (\n <div className=\"ui-nav-foot\">\n {onPin ? (\n <Tooltip label={pinned ? tr('取消釘選') : tr('釘選側邊欄')} side=\"right\" describe={false}>\n <button\n type=\"button\"\n className={cx('ui-nav-collapse', 'ui-nav-pin', pinned && 'is-on')}\n aria-pressed={pinned}\n aria-label={pinned ? tr('取消釘選') : tr('釘選側邊欄')}\n onClick={onPin}\n >\n <Icon name=\"push-pin\" size={20} filled={pinned} />\n </button>\n </Tooltip>\n ) : null}\n {onToggle ? (\n <Tooltip label={toggleLabel} side=\"right\" describe={false}>\n <button type=\"button\" className=\"ui-nav-collapse\" aria-label={toggleLabel} onClick={onToggle}>\n <Icon name=\"sidebar-simple\" size={20} />\n </button>\n </Tooltip>\n ) : null}\n </div>\n ) : null}\n </aside>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAaA,aAAaA,qBAAcC,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;MACL,WAAW,GAAG,mBAAmB,cAAc,UAAU,OAAO;MAChE,gBAAc;MACd,cAAY,SAAS,GAAG,MAAM,IAAI,GAAG,OAAO;MAC5C,SAAS;MAET,UAAA,oBAAC,MAAD;OAAM,MAAK;OAAW,MAAM;OAAI,QAAQ;MAAS,CAAA;KAC3C,CAAA;IACD,CAAA,IACP,MACH,WACC,oBAAC,SAAD;KAAS,OAAO;KAAa,MAAK;KAAQ,UAAU;KAClD,UAAA,oBAAC,UAAD;MAAQ,MAAK;MAAS,WAAU;MAAkB,cAAY;MAAa,SAAS;MAClF,UAAA,oBAAC,MAAD;OAAM,MAAK;OAAiB,MAAM;MAAK,CAAA;KACjC,CAAA;IACD,CAAA,IACP,IACD;GACH,CAAA,IAAA;EACC;;AAEX"}
|
|
1
|
+
{"version":3,"file":"SideNav.js","names":["phCaretRight","phPushPin","phSidebarSimple"],"sources":["../../../src/components/SideNav/SideNav.tsx"],"sourcesContent":["import * as React from 'react';\nimport { tr } from '../../i18n';\nimport { Icon, IconOf, type IconSource } from '../../icons/Icon';\nimport { dropTransition, useMoving } from '../../motion';\nimport { announce } from '../../announce';\nimport { cx } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { Tooltip } from '../Tooltip/Tooltip';\nimport { includeIcons } from '../../icons/store';\nimport phCaretRight from '../../icons/ph/caret-right';\nimport phPushPin from '../../icons/ph/push-pin';\nimport phSidebarSimple from '../../icons/ph/sidebar-simple';\n\nincludeIcons(phCaretRight, phPushPin, phSidebarSimple);\n\nexport interface NavItem {\n id: string;\n label: string;\n /** Top-level items have an icon; the selected one is filled. */\n icon?: IconSource;\n /** Second level, shown under the item; it opens and closes. */\n children?: NavItem[];\n}\n\nexport interface NavSection {\n items: NavItem[];\n}\n\n/** The product at the top of the sidebar. */\nexport interface NavBrand {\n /** Logo or colour block, at most 24 px: stays where it is, collapsed and open. Default: the first character of\n * `name` in an accent square. */\n mark?: React.ReactNode;\n /** The product name: shown beside the mark when the sidebar is open, the link's name when collapsed. */\n name: string;\n /** Usually the home page. */\n href?: string;\n onClick?: (e: React.MouseEvent<HTMLElement>) => void;\n}\n\nconst isBrand = (b: unknown): b is NavBrand =>\n !!b && typeof b === 'object' && !React.isValidElement(b) && !Array.isArray(b) && typeof (b as NavBrand).name === 'string';\n\nfunction NavBrandRow({ brand, collapsed }: { brand: React.ReactNode | NavBrand; collapsed: boolean }) {\n const spec: NavBrand | null = isBrand(brand) ? brand : typeof brand === 'string' ? { name: brand } : null;\n devWarn(\n !spec && collapsed,\n 'SideNav',\n 'brand is an element, so the collapsed sidebar cannot tell which part is the logo and hides all of it. Pass brand={{ mark, name, href }}: collapsed shows mark, expanded adds the name.',\n );\n if (!spec) return <div className=\"ui-nav-brand\">{collapsed ? null : (brand as React.ReactNode)}</div>;\n const inner = (\n <>\n <span className=\"ui-nav-mark\" aria-hidden=\"true\">\n {spec.mark ?? <span className=\"ui-nav-monogram\">{Array.from(spec.name)[0]}</span>}\n </span>\n <span className=\"ui-nav-brand-name\">{spec.name}</span>\n </>\n );\n // Collapsed, the name is invisible but the link keeps it as its label.\n const label = collapsed ? spec.name : undefined;\n return (\n <div className=\"ui-nav-brand has-mark\">\n {spec.href ? (\n <a className=\"ui-nav-brand-link\" href={spec.href} onClick={spec.onClick} aria-label={label}>\n {inner}\n </a>\n ) : spec.onClick ? (\n <button type=\"button\" className=\"ui-nav-brand-link\" onClick={spec.onClick} aria-label={label}>\n {inner}\n </button>\n ) : (\n <span className=\"ui-nav-brand-link\" aria-label={label} role={label ? 'img' : undefined}>\n {inner}\n </span>\n )}\n </div>\n );\n}\n\nexport interface SideNavProps {\n /** Groups separated by a divider. */\n sections: NavSection[];\n /** Id of the current page. */\n value: string;\n /** Called with the id of the item the person picks. */\n onChange?: (id: string) => void;\n /** 72 px with icons only, labels as tooltips. */\n collapsed?: boolean;\n /** Adds the collapse button at the bottom left. */\n onToggle?: () => void;\n /** Adds the pin button at the bottom left (AppShell): pinned, the sidebar stays; not pinned, it hides to icons. */\n onPin?: () => void;\n /** Whether the sidebar is pinned: the pin button is filled and says 「取消釘選」. */\n pinned?: boolean;\n /** The product at the top. Prefer { mark, name, href }: collapsed (72 px) it shows only the mark, still a link\n * named by `name`; open, the mark with the name fading in beside it. Text alone gets its first character in an\n * accent square as the mark. Any other element is hidden while collapsed. */\n brand?: React.ReactNode | NavBrand;\n /** Default 「主要導覽」. */\n label?: string;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** The 240 px dashboard sidebar (72 px collapsed). The selection bar moves like a droplet. */\nexport function SideNav({ sections, value, onChange, collapsed = false, onToggle, onPin, pinned = false, brand, label, className }: SideNavProps) {\n const refs = React.useRef<Record<string, HTMLButtonElement | null>>({});\n const wrap = React.useRef<HTMLDivElement>(null);\n const [bar, setBar] = React.useState({ top: 0, bottom: 0, show: false, down: true });\n const last = React.useRef<{ top: number; bottom: number } | null>(null);\n const [moving, bump] = useMoving();\n // A page change is announced (not the first page): screen readers hear where they are now.\n const firstValue = React.useRef<string | undefined>(value);\n React.useEffect(() => {\n if (value === firstValue.current) return;\n firstValue.current = undefined;\n const all = sections.flatMap((sec) => sec.items.flatMap((it) => [it, ...(it.children ?? [])]));\n const it = all.find((x) => x.id === value);\n if (it) announce(it.label);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- only when the page changes\n }, [value]);\n const [closed, setClosed] = React.useState<Record<string, boolean>>({});\n const closedKey = Object.keys(closed)\n .filter((k) => closed[k])\n .join();\n React.useLayoutEffect(() => {\n let el = refs.current[value];\n if (!el) {\n const parent = sections.flatMap((s) => s.items).find((it) => it.children?.some((c) => c.id === value));\n el = parent ? refs.current[parent.id] : null;\n }\n const box = wrap.current;\n if (!el || !box) return;\n const y = el.getBoundingClientRect().top - box.getBoundingClientRect().top;\n const top = Math.round(y) + 8;\n const bottom = Math.round(box.clientHeight - y - el.offsetHeight) + 8;\n const prev = last.current;\n if (prev && prev.top === top && prev.bottom === bottom) return;\n if (prev && prev.top !== top) bump();\n last.current = { top, bottom };\n setBar({ top, bottom, show: true, down: !prev || top >= prev.top });\n }, [value, collapsed, closedKey, sections, bump]);\n\n const row = (it: NavItem, sub: boolean): React.ReactNode[] => {\n const kids = it.children ?? [];\n const hasKids = kids.length > 0 && !collapsed;\n const isOpen = !closed[it.id];\n const selected = value === it.id || ((!hasKids || !isOpen) && kids.some((c) => c.id === value));\n const out: React.ReactNode[] = [\n <div key={it.id} className=\"ui-nav-row\">\n <button\n type=\"button\"\n ref={(n) => {\n refs.current[it.id] = n;\n }}\n className={cx('ui-nav-item', sub && 'is-sub', selected && 'is-selected')}\n aria-current={selected ? 'page' : undefined}\n aria-expanded={hasKids ? isOpen : undefined}\n aria-label={collapsed ? it.label : undefined}\n // Collapsed, a parent opens its first page; the page switches between its siblings itself.\n onClick={() => (hasKids ? setClosed({ ...closed, [it.id]: isOpen }) : onChange?.(kids[0]?.id ?? it.id))}\n >\n {it.icon && !sub ? <IconOf icon={it.icon} size={22} filled={selected} className=\"ui-nav-icon\" /> : null}\n {collapsed ? null : <span className=\"ui-nav-label\">{it.label}</span>}\n {hasKids ? <Icon name=\"caret-right\" size={16} className={cx('ui-nav-chev', isOpen && 'is-open')} /> : null}\n </button>\n {collapsed ? (\n <span className=\"ui-nav-tip\" role=\"tooltip\">\n {it.label}\n </span>\n ) : null}\n </div>,\n ];\n if (hasKids && isOpen) for (const c of kids) out.push(...row(c, true));\n return out;\n };\n\n const toggleLabel = collapsed ? tr('展開側邊欄') : tr('收合側邊欄');\n return (\n <aside className={cx('ui-sidenav', collapsed && 'is-collapsed', className)}>\n {brand ? <NavBrandRow brand={brand} collapsed={collapsed} /> : null}\n <nav className=\"ui-nav-list\" aria-label={label || tr('主要導覽')}>\n <div ref={wrap} className=\"ui-nav-inner\">\n {bar.show ? (\n <span\n className=\"ui-nav-bar\"\n aria-hidden=\"true\"\n style={{ top: bar.top, bottom: bar.bottom, transform: moving ? 'scaleX(.7)' : 'none', transition: dropTransition('top', 'bottom', bar.down) }}\n />\n ) : null}\n {sections.map((sec, i) => (\n <React.Fragment key={i}>\n {i > 0 ? <div className=\"ui-nav-divider\" role=\"separator\" /> : null}\n {sec.items.flatMap((it) => row(it, false))}\n </React.Fragment>\n ))}\n </div>\n </nav>\n {onToggle || onPin ? (\n <div className=\"ui-nav-foot\">\n {onPin ? (\n <Tooltip label={pinned ? tr('取消釘選') : tr('釘選側邊欄')} side=\"right\" describe={false}>\n <button\n type=\"button\"\n className={cx('ui-nav-collapse', 'ui-nav-pin', pinned && 'is-on')}\n aria-pressed={pinned}\n aria-label={pinned ? tr('取消釘選') : tr('釘選側邊欄')}\n onClick={onPin}\n >\n <Icon name=\"push-pin\" size={22} filled={pinned} />\n </button>\n </Tooltip>\n ) : null}\n {onToggle ? (\n <Tooltip label={toggleLabel} side=\"right\" describe={false}>\n <button type=\"button\" className=\"ui-nav-collapse\" aria-label={toggleLabel} onClick={onToggle}>\n <Icon name=\"sidebar-simple\" size={22} />\n </button>\n </Tooltip>\n ) : null}\n </div>\n ) : null}\n </aside>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAaA,aAAaA,qBAAcC,kBAAWC,sBAAe;AA2BrD,MAAM,WAAW,MACf,CAAC,CAAC,KAAK,OAAO,MAAM,YAAY,CAAC,MAAM,eAAe,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,KAAK,OAAQ,EAAe,SAAS;AAEnH,SAAS,YAAY,EAAE,OAAO,aAAwE;CACpG,MAAM,OAAwB,QAAQ,KAAK,IAAI,QAAQ,OAAO,UAAU,WAAW,EAAE,MAAM,MAAM,IAAI;CACrG,QACE,CAAC,QAAQ,WACT,WACA,wLACF;CACA,IAAI,CAAC,MAAM,OAAO,oBAAC,OAAD;EAAK,WAAU;EAAgB,UAAA,YAAY,OAAQ;CAA+B,CAAA;CACpG,MAAM,QACJ,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,QAAD;EAAM,WAAU;EAAc,eAAY;EACvC,UAAA,KAAK,QAAQ,oBAAC,QAAD;GAAM,WAAU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
|
/** After every change, with the side panel's new width in px. */
|
|
18
18
|
onResize?: (b: number) => void;
|
|
19
|
+
/** Extra class on the root element. */
|
|
19
20
|
className?: string;
|
|
20
21
|
}
|
|
21
22
|
/** A main area and a side panel with a divider between them that can be dragged, moved with the arrow keys and reset
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SplitPane.js","names":[],"sources":["../../../src/components/SplitPane/SplitPane.tsx"],"sourcesContent":["import * as React from 'react';\nimport { tr } from '../../i18n';\nimport { browserKey, cx, resizeObserver } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\n\nexport interface SplitPaneProps {\n /** The main area, on the left. */\n a: React.ReactNode;\n /** The side panel, on the right; its width is what the divider changes. */\n b: React.ReactNode;\n /** px. The side panel's width at first and after a double-click on the divider. Default 420. */\n defaultB?: number;\n /** px. The main area never gets narrower than this. Default 360. */\n minA?: number;\n /** px. The side panel never gets narrower than this. Default 280. */\n minB?: number;\n /** Remembers the side panel's width in localStorage under this name. Without it the width lasts until the page reloads. */\n storageKey?: string;\n /** Names the divider for screen readers. Default 「調整面板寬度」. */\n label?: string;\n /** After every change, with the side panel's new width in px. */\n onResize?: (b: number) => void;\n className?: string;\n}\n\n/** Width of the divider between the two areas, in px; a 48 px hit area is drawn over it. */\nconst HANDLE = 16;\n/** Narrower than this (px, the component's own width), the two areas stack and the divider goes away. */\nconst STACK = 960;\n/** One arrow key press, in px. */\nconst STEP = 16;\n\nconst read = (key: string | undefined): number | null => {\n if (!key) return null;\n try {\n const v = Number(window.localStorage.getItem('ui-split:' + key));\n return Number.isFinite(v) && v > 0 ? v : null;\n } catch {\n return null;\n }\n};\nconst write = (key: string | undefined, v: number) => {\n if (!key) return;\n try {\n window.localStorage.setItem('ui-split:' + key, String(Math.round(v)));\n } catch {\n // Storage blocked or full: the width still changes, it is just not remembered.\n }\n};\n\n/** A main area and a side panel with a divider between them that can be dragged, moved with the arrow keys and reset\n * with a double-click. Under 960 px (its own width) the two stack, side panel below, without the divider. */\nexport function SplitPane({ a, b, defaultB = 420, minA = 360, minB = 280, storageKey, label, onResize, className }: SplitPaneProps) {\n devWarn(defaultB < minB, 'SplitPane', `defaultB (${defaultB} px) is under minB (${minB} px): the panel starts at ${minB} px. Raise defaultB or lower minB.`);\n const root = React.useRef<HTMLDivElement>(null);\n const [width, setWidth] = React.useState(0);\n // The stored width, read on the first render in the browser. The grid columns are set only once the component has\n // measured itself, so the server's render and the first one in the browser match.\n const [side, setSide] = React.useState(() => (typeof window === 'undefined' ? null : read(storageKey)) ?? defaultB);\n const [drag, setDrag] = React.useState(false);\n // Read by the move and up handlers: a move can come before the render that follows the press.\n const dragging = React.useRef(false);\n const id = React.useId();\n React.useLayoutEffect(() => {\n const el = root.current;\n if (!el) return;\n const measure = () => setWidth(el.clientWidth);\n measure();\n const ro = resizeObserver(measure);\n ro?.observe(el);\n return () => ro?.disconnect();\n }, []);\n const stacked = width > 0 && width < STACK;\n // The side panel's width as it can be now: both areas keep their minimum.\n const maxB = Math.max(minB, width - HANDLE - minA);\n const shown = Math.round(Math.min(maxB, Math.max(minB, side)));\n const valueA = Math.max(0, width - HANDLE - shown);\n // The width after the last move, for the release that stores it (the render with it may not have happened yet).\n const latest = React.useRef(shown);\n const set = (v: number, keep = true) => {\n const next = Math.round(Math.min(maxB, Math.max(minB, v)));\n latest.current = next;\n setSide(next);\n if (keep) write(storageKey, next);\n onResize?.(next);\n };\n const onKey = (e: React.KeyboardEvent) => {\n if (browserKey(e)) return;\n // The value is the main area's width: ← makes it narrower (the panel wider), Home makes it as narrow as it goes.\n const to =\n e.key === 'ArrowLeft'\n ? shown + STEP\n : e.key === 'ArrowRight'\n ? shown - STEP\n : e.key === 'Home'\n ? maxB\n : e.key === 'End'\n ? minB\n : e.key === 'Enter'\n ? defaultB\n : null;\n if (to == null) return;\n e.preventDefault();\n set(to);\n };\n const onDown = (e: React.PointerEvent<HTMLDivElement>) => {\n if (e.button !== 0) return;\n e.preventDefault();\n // Keeps getting the moves when the pointer leaves the divider (a fast drag).\n try {\n e.currentTarget.setPointerCapture?.(e.pointerId);\n } catch {\n // No such pointer (a synthetic event): moves still come while over the divider.\n }\n e.currentTarget.focus({ preventScroll: true });\n dragging.current = true;\n setDrag(true);\n };\n const onMove = (e: React.PointerEvent<HTMLDivElement>) => {\n if (!dragging.current || !root.current) return;\n const r = root.current.getBoundingClientRect();\n set(r.right - e.clientX - HANDLE / 2, false);\n };\n const onUp = (e: React.PointerEvent<HTMLDivElement>) => {\n if (!dragging.current) return;\n dragging.current = false;\n setDrag(false);\n try {\n if (e.currentTarget.hasPointerCapture?.(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId);\n } catch {\n // Already released.\n }\n if (root.current) write(storageKey, latest.current);\n };\n return (\n <div\n ref={root}\n className={cx('ui-split', stacked && 'is-stacked', drag && 'is-dragging', className)}\n style={stacked || !width ? undefined : { gridTemplateColumns: `minmax(0, 1fr) ${HANDLE}px ${shown}px` }}\n >\n <div className=\"ui-split-a\">{a}</div>\n {stacked ? null : (\n <div\n role=\"separator\"\n tabIndex={0}\n aria-orientation=\"vertical\"\n aria-label={label || tr('調整面板寬度')}\n aria-controls={id}\n aria-valuenow={valueA}\n aria-valuemin={minA}\n aria-valuemax={Math.max(minA, width - HANDLE - minB)}\n aria-valuetext={tr('主要區域 {a} px,面板 {b} px', { a: valueA, b: shown })}\n className=\"ui-split-handle\"\n onKeyDown={onKey}\n onPointerDown={onDown}\n onPointerMove={onMove}\n onPointerUp={onUp}\n onPointerCancel={onUp}\n onDoubleClick={() => set(defaultB)}\n >\n {/* GB: a small handle in the middle of the line, so the divider reads as something to drag. */}\n <span className=\"ui-split-grip\" aria-hidden=\"true\">\n <i />\n <i />\n <i />\n </span>\n </div>\n )}\n <div id={id} className=\"ui-split-b\">\n {b}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AA0BA,MAAM,SAAS;;AAEf,MAAM,QAAQ;;AAEd,MAAM,OAAO;AAEb,MAAM,QAAQ,QAA2C;CAC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O;CACpD;CACA,OACE,qBAAC,OAAD;EACE,KAAK;EACL,WAAW,GAAG,YAAY,WAAW,cAAc,QAAQ,eAAe,SAAS;EACnF,OAAO,WAAW,CAAC,QAAQ,KAAA,IAAY,EAAE,qBAAqB,kBAAkB,OAAO,KAAK,MAAM,IAAI;EAHxG,UAAA;GAKE,oBAAC,OAAD;IAAK,WAAU;IAAc,UAAA;GAAO,CAAA;GACnC,UAAU,OACT,oBAAC,OAAD;IACE,MAAK;IACL,UAAU;IACV,oBAAiB;IACjB,cAAY,SAAS,GAAG,QAAQ;IAChC,iBAAe;IACf,iBAAe;IACf,iBAAe;IACf,iBAAe,KAAK,IAAI,MAAM,QAAQ,SAAS,IAAI;IACnD,kBAAgB,GAAG,yBAAyB;KAAE,GAAG;KAAQ,GAAG;IAAM,CAAC;IACnE,WAAU;IACV,WAAW;IACX,eAAe;IACf,eAAe;IACf,aAAa;IACb,iBAAiB;IACjB,qBAAqB,IAAI,QAAQ;IAGjC,UAAA,qBAAC,QAAD;KAAM,WAAU;KAAgB,eAAY;KAA5C,UAAA;MACE,oBAAC,KAAD,CAAI,CAAA;MACJ,oBAAC,KAAD,CAAI,CAAA;MACJ,oBAAC,KAAD,CAAI,CAAA;KACA;;GACH,CAAA;GAEP,oBAAC,OAAD;IAAS;IAAI,WAAU;IACpB,UAAA;GACE,CAAA;EACF;;AAET"}
|
|
1
|
+
{"version":3,"file":"SplitPane.js","names":[],"sources":["../../../src/components/SplitPane/SplitPane.tsx"],"sourcesContent":["import * as React from 'react';\nimport { tr } from '../../i18n';\nimport { browserKey, cx, resizeObserver } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\n\nexport interface SplitPaneProps {\n /** The main area, on the left. */\n a: React.ReactNode;\n /** The side panel, on the right; its width is what the divider changes. */\n b: React.ReactNode;\n /** px. The side panel's width at first and after a double-click on the divider. Default 420. */\n defaultB?: number;\n /** px. The main area never gets narrower than this. Default 360. */\n minA?: number;\n /** px. The side panel never gets narrower than this. Default 280. */\n minB?: number;\n /** Remembers the side panel's width in localStorage under this name. Without it the width lasts until the page reloads. */\n storageKey?: string;\n /** Names the divider for screen readers. Default 「調整面板寬度」. */\n label?: string;\n /** After every change, with the side panel's new width in px. */\n onResize?: (b: number) => void;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** Width of the divider between the two areas, in px; a 48 px hit area is drawn over it. */\nconst HANDLE = 16;\n/** Narrower than this (px, the component's own width), the two areas stack and the divider goes away. */\nconst STACK = 960;\n/** One arrow key press, in px. */\nconst STEP = 16;\n\nconst read = (key: string | undefined): number | null => {\n if (!key) return null;\n try {\n const v = Number(window.localStorage.getItem('ui-split:' + key));\n return Number.isFinite(v) && v > 0 ? v : null;\n } catch {\n return null;\n }\n};\nconst write = (key: string | undefined, v: number) => {\n if (!key) return;\n try {\n window.localStorage.setItem('ui-split:' + key, String(Math.round(v)));\n } catch {\n // Storage blocked or full: the width still changes, it is just not remembered.\n }\n};\n\n/** A main area and a side panel with a divider between them that can be dragged, moved with the arrow keys and reset\n * with a double-click. Under 960 px (its own width) the two stack, side panel below, without the divider. */\nexport function SplitPane({ a, b, defaultB = 420, minA = 360, minB = 280, storageKey, label, onResize, className }: SplitPaneProps) {\n devWarn(defaultB < minB, 'SplitPane', `defaultB (${defaultB} px) is under minB (${minB} px): the panel starts at ${minB} px. Raise defaultB or lower minB.`);\n const root = React.useRef<HTMLDivElement>(null);\n const [width, setWidth] = React.useState(0);\n // The stored width, read on the first render in the browser. The grid columns are set only once the component has\n // measured itself, so the server's render and the first one in the browser match.\n const [side, setSide] = React.useState(() => (typeof window === 'undefined' ? null : read(storageKey)) ?? defaultB);\n const [drag, setDrag] = React.useState(false);\n // Read by the move and up handlers: a move can come before the render that follows the press.\n const dragging = React.useRef(false);\n const id = React.useId();\n React.useLayoutEffect(() => {\n const el = root.current;\n if (!el) return;\n const measure = () => setWidth(el.clientWidth);\n measure();\n const ro = resizeObserver(measure);\n ro?.observe(el);\n return () => ro?.disconnect();\n }, []);\n const stacked = width > 0 && width < STACK;\n // The side panel's width as it can be now: both areas keep their minimum.\n const maxB = Math.max(minB, width - HANDLE - minA);\n const shown = Math.round(Math.min(maxB, Math.max(minB, side)));\n const valueA = Math.max(0, width - HANDLE - shown);\n // The width after the last move, for the release that stores it (the render with it may not have happened yet).\n const latest = React.useRef(shown);\n const set = (v: number, keep = true) => {\n const next = Math.round(Math.min(maxB, Math.max(minB, v)));\n latest.current = next;\n setSide(next);\n if (keep) write(storageKey, next);\n onResize?.(next);\n };\n const onKey = (e: React.KeyboardEvent) => {\n if (browserKey(e)) return;\n // The value is the main area's width: ← makes it narrower (the panel wider), Home makes it as narrow as it goes.\n const to =\n e.key === 'ArrowLeft'\n ? shown + STEP\n : e.key === 'ArrowRight'\n ? shown - STEP\n : e.key === 'Home'\n ? maxB\n : e.key === 'End'\n ? minB\n : e.key === 'Enter'\n ? defaultB\n : null;\n if (to == null) return;\n e.preventDefault();\n set(to);\n };\n const onDown = (e: React.PointerEvent<HTMLDivElement>) => {\n if (e.button !== 0) return;\n e.preventDefault();\n // Keeps getting the moves when the pointer leaves the divider (a fast drag).\n try {\n e.currentTarget.setPointerCapture?.(e.pointerId);\n } catch {\n // No such pointer (a synthetic event): moves still come while over the divider.\n }\n e.currentTarget.focus({ preventScroll: true });\n dragging.current = true;\n setDrag(true);\n };\n const onMove = (e: React.PointerEvent<HTMLDivElement>) => {\n if (!dragging.current || !root.current) return;\n const r = root.current.getBoundingClientRect();\n set(r.right - e.clientX - HANDLE / 2, false);\n };\n const onUp = (e: React.PointerEvent<HTMLDivElement>) => {\n if (!dragging.current) return;\n dragging.current = false;\n setDrag(false);\n try {\n if (e.currentTarget.hasPointerCapture?.(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId);\n } catch {\n // Already released.\n }\n if (root.current) write(storageKey, latest.current);\n };\n return (\n <div\n ref={root}\n className={cx('ui-split', stacked && 'is-stacked', drag && 'is-dragging', className)}\n style={stacked || !width ? undefined : { gridTemplateColumns: `minmax(0, 1fr) ${HANDLE}px ${shown}px` }}\n >\n <div className=\"ui-split-a\">{a}</div>\n {stacked ? null : (\n <div\n role=\"separator\"\n tabIndex={0}\n aria-orientation=\"vertical\"\n aria-label={label || tr('調整面板寬度')}\n aria-controls={id}\n aria-valuenow={valueA}\n aria-valuemin={minA}\n aria-valuemax={Math.max(minA, width - HANDLE - minB)}\n aria-valuetext={tr('主要區域 {a} px,面板 {b} px', { a: valueA, b: shown })}\n className=\"ui-split-handle\"\n onKeyDown={onKey}\n onPointerDown={onDown}\n onPointerMove={onMove}\n onPointerUp={onUp}\n onPointerCancel={onUp}\n onDoubleClick={() => set(defaultB)}\n >\n {/* GB: a small handle in the middle of the line, so the divider reads as something to drag. */}\n <span className=\"ui-split-grip\" aria-hidden=\"true\">\n <i />\n <i />\n <i />\n </span>\n </div>\n )}\n <div id={id} className=\"ui-split-b\">\n {b}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AA2BA,MAAM,SAAS;;AAEf,MAAM,QAAQ;;AAEd,MAAM,OAAO;AAEb,MAAM,QAAQ,QAA2C;CACvD,IAAI,CAAC,KAAK,OAAO;CACjB,IAAI;EACF,MAAM,IAAI,OAAO,OAAO,aAAa,QAAQ,cAAc,GAAG,CAAC;EAC/D,OAAO,OAAO,SAAS,CAAC,KAAK,IAAI,IAAI,IAAI;CAC3C,QAAQ;EACN,OAAO;CACT;AACF;AACA,MAAM,SAAS,KAAyB,MAAc;CACpD,IAAI,CAAC,KAAK;CACV,IAAI;EACF,OAAO,aAAa,QAAQ,cAAc,KAAK,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC;CACtE,QAAQ,CAER;AACF;;;AAIA,SAAgB,UAAU,EAAE,GAAG,GAAG,WAAW,KAAK,OAAO,KAAK,OAAO,KAAK,YAAY,OAAO,UAAU,aAA6B;CAClI,QAAQ,WAAW,MAAM,aAAa,aAAa,SAAS,sBAAsB,KAAK,4BAA4B,KAAK,mCAAmC;CAC3J,MAAM,OAAO,MAAM,OAA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ACb,iBAAiB;IACjB,qBAAqB,IAAI,QAAQ;IAGjC,UAAA,qBAAC,QAAD;KAAM,WAAU;KAAgB,eAAY;KAA5C,UAAA;MACE,oBAAC,KAAD,CAAI,CAAA;MACJ,oBAAC,KAAD,CAAI,CAAA;MACJ,oBAAC,KAAD,CAAI,CAAA;KACA;;GACH,CAAA;GAEP,oBAAC,OAAD;IAAS;IAAI,WAAU;IACpB,UAAA;GACE,CAAA;EACF;;AAET"}
|
|
@@ -22,6 +22,7 @@ export interface StatusBandProps {
|
|
|
22
22
|
times?: string[];
|
|
23
23
|
/** The legend under the band. Default true. */
|
|
24
24
|
legend?: boolean;
|
|
25
|
+
/** Extra class on the root element. */
|
|
25
26
|
className?: string;
|
|
26
27
|
}
|
|
27
28
|
/** A 12 px band along a time axis, one color per class (chart-1 to chart-4), e.g. which strategy was in use every
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusBand.js","names":[],"sources":["../../../src/components/StatusBand/StatusBand.tsx"],"sourcesContent":["import { seriesColor } from '../../internal/chart';\nimport { cx } from '../../internal/util';\nimport { tr } from '../../i18n';\n\nexport interface StatusSegment {\n /** First point of the segment (index). */\n from: number;\n /** The point after the last one (index), so segments meet: { from: 0, to: 6 }, { from: 6, to: 10 }. */\n to: number;\n /** One of the classes' values. */\n value: string;\n}\n\nexport interface StatusBandProps {\n /** Who held each stretch of time, e.g. which control strategy was in use. */\n segments: StatusSegment[];\n /** The classes in color order (chart-1 to chart-4) with their legend words; at most 4. */\n classes: { value: string; label: string }[];\n /** What the band shows, for screen readers, e.g. 「採用的策略」. */\n label: string;\n /** How many points the time axis has; the band spans all of them. */\n count: number;\n /** One label per point (the chart's x labels), so screen readers hear 「13:00 到 14:00 AI 最佳化」. */\n times?: string[];\n /** The legend under the band. Default true. */\n legend?: boolean;\n className?: string;\n}\n\n/** A 12 px band along a time axis, one color per class (chart-1 to chart-4), e.g. which strategy was in use every\n * 10 minutes; under a LineChart (its `status`) or on its own. The legend below gives the words. */\nexport function StatusBand({ segments, classes, label, count, times, legend = true, className }: StatusBandProps) {\n const color = (v: string) =>\n seriesColor(\n Math.max(\n 0,\n classes.findIndex((c) => c.value === v),\n ),\n );\n const name = (v: string) => classes.find((c) => c.value === v)?.label ?? v;\n const said = segments\n .map((s) => (times ? times[s.from] + ' ' + tr('到') + ' ' + (times[s.to] ?? times[times.length - 1]) + ' ' : '') + name(s.value))\n .join(tr(','));\n return (\n <div className={cx('ui-statusband', className)}>\n <div className=\"ui-statusband-bar\" role=\"img\" aria-label={label + tr(':') + (said || tr('沒有資料'))}>\n {segments.map((s, i) => (\n <span\n key={i}\n style={{ left: (s.from / count) * 100 + '%', width: ((Math.min(count, s.to) - s.from) / count) * 100 + '%', background: color(s.value) }}\n />\n ))}\n </div>\n {legend ? <StatusLegend classes={classes} label={label} /> : null}\n </div>\n );\n}\n\n/** The legend of a StatusBand: its label, then a swatch and the words for each class. */\nexport function StatusLegend({ classes, label }: Pick<StatusBandProps, 'classes' | 'label'>) {\n return (\n <div className=\"ui-chart-legend ui-statusband-legend\" aria-hidden=\"true\">\n <span>{label}</span>\n {classes.map((c, i) => (\n <span key={c.value}>\n <span className=\"ui-chart-swatch\" style={{ background: seriesColor(i) }} />\n {c.label}\n </span>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"StatusBand.js","names":[],"sources":["../../../src/components/StatusBand/StatusBand.tsx"],"sourcesContent":["import { seriesColor } from '../../internal/chart';\nimport { cx } from '../../internal/util';\nimport { tr } from '../../i18n';\n\nexport interface StatusSegment {\n /** First point of the segment (index). */\n from: number;\n /** The point after the last one (index), so segments meet: { from: 0, to: 6 }, { from: 6, to: 10 }. */\n to: number;\n /** One of the classes' values. */\n value: string;\n}\n\nexport interface StatusBandProps {\n /** Who held each stretch of time, e.g. which control strategy was in use. */\n segments: StatusSegment[];\n /** The classes in color order (chart-1 to chart-4) with their legend words; at most 4. */\n classes: { value: string; label: string }[];\n /** What the band shows, for screen readers, e.g. 「採用的策略」. */\n label: string;\n /** How many points the time axis has; the band spans all of them. */\n count: number;\n /** One label per point (the chart's x labels), so screen readers hear 「13:00 到 14:00 AI 最佳化」. */\n times?: string[];\n /** The legend under the band. Default true. */\n legend?: boolean;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** A 12 px band along a time axis, one color per class (chart-1 to chart-4), e.g. which strategy was in use every\n * 10 minutes; under a LineChart (its `status`) or on its own. The legend below gives the words. */\nexport function StatusBand({ segments, classes, label, count, times, legend = true, className }: StatusBandProps) {\n const color = (v: string) =>\n seriesColor(\n Math.max(\n 0,\n classes.findIndex((c) => c.value === v),\n ),\n );\n const name = (v: string) => classes.find((c) => c.value === v)?.label ?? v;\n const said = segments\n .map((s) => (times ? times[s.from] + ' ' + tr('到') + ' ' + (times[s.to] ?? times[times.length - 1]) + ' ' : '') + name(s.value))\n .join(tr(','));\n return (\n <div className={cx('ui-statusband', className)}>\n <div className=\"ui-statusband-bar\" role=\"img\" aria-label={label + tr(':') + (said || tr('沒有資料'))}>\n {segments.map((s, i) => (\n <span\n key={i}\n style={{ left: (s.from / count) * 100 + '%', width: ((Math.min(count, s.to) - s.from) / count) * 100 + '%', background: color(s.value) }}\n />\n ))}\n </div>\n {legend ? <StatusLegend classes={classes} label={label} /> : null}\n </div>\n );\n}\n\n/** The legend of a StatusBand: its label, then a swatch and the words for each class. */\nexport function StatusLegend({ classes, label }: Pick<StatusBandProps, 'classes' | 'label'>) {\n return (\n <div className=\"ui-chart-legend ui-statusband-legend\" aria-hidden=\"true\">\n <span>{label}</span>\n {classes.map((c, i) => (\n <span key={c.value}>\n <span className=\"ui-chart-swatch\" style={{ background: seriesColor(i) }} />\n {c.label}\n </span>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAgCA,SAAgB,WAAW,EAAE,UAAU,SAAS,OAAO,OAAO,OAAO,SAAS,MAAM,aAA8B;CAChH,MAAM,SAAS,MACb,YACE,KAAK,IACH,GACA,QAAQ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/** Default 「複製修正」. */
|
|
13
13
|
copyLabel?: string;
|
|
14
|
+
/** Called with the copied text after a copy. */
|
|
14
15
|
onCopy?: (text: string) => void;
|
|
16
|
+
/** Called when the clipboard refuses the copy. */
|
|
15
17
|
onCopyError?: () => void;
|
|
18
|
+
/** Spans that look like file.c:86 become links; return undefined when the reference has no target. */
|
|
16
19
|
refHref?: RefHref;
|
|
20
|
+
/** Called when a reference is pressed, for apps that open it themselves. */
|
|
17
21
|
onRef?: OnRef;
|
|
22
|
+
/** Which spans are references. Default: a file name with a line number. */
|
|
18
23
|
isRef?: (span: string) => boolean;
|
|
24
|
+
/** Extra class on the root element. */
|
|
19
25
|
className?: string;
|
|
20
26
|
}
|
|
21
27
|
/** A proposed fix: the old line (−) above the new one (+), with a copy button at the top right. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Suggestion.js","names":["phCopy"],"sources":["../../../src/components/Suggestion/Suggestion.tsx"],"sourcesContent":["import * as React from 'react';\nimport { tr } from '../../i18n';\nimport { CHECK } from '../../icons/Icon';\nimport { copyText, cx } from '../../internal/util';\nimport { IconButton } from '../IconButton/IconButton';\nimport { CodeText, type OnRef, type RefHref } from '../InlineCode/InlineCode';\nimport { includeIcons } from '../../icons/store';\nimport phCopy from '../../icons/ph/copy';\n\nincludeIcons(phCopy);\n\nexport interface SuggestionProps {\n /** Default 「建議修正」. */\n title?: string;\n /** The current line, shown with −. Text in `backticks` is code. */\n before?: string;\n /** The proposed line, shown with +. */\n after: string;\n /** What the copy button copies. Default: after. */\n copyText?: string;\n /** Default 「複製修正」. */\n copyLabel?: string;\n onCopy?: (text: string) => void;\n onCopyError?: () => void;\n refHref?: RefHref;\n onRef?: OnRef;\n isRef?: (span: string) => boolean;\n className?: string;\n}\n\n/** A proposed fix: the old line (−) above the new one (+), with a copy button at the top right. */\nexport function Suggestion({ title, before, after, copyText: copyValue, copyLabel, onCopy, onCopyError, refHref, onRef, isRef, className }: SuggestionProps) {\n const [copied, setCopied] = React.useState(false);\n const tm = React.useRef<ReturnType<typeof setTimeout>>(undefined);\n React.useEffect(() => () => clearTimeout(tm.current), []);\n const copy = () => {\n const text = copyValue ?? after;\n copyText(text).then(\n () => {\n setCopied(true);\n clearTimeout(tm.current);\n tm.current = setTimeout(() => setCopied(false), 2000);\n onCopy?.(text);\n },\n () => onCopyError?.(),\n );\n };\n const line = (kind: 'del' | 'add', text: string) => (\n <div className={'ui-sug-line is-' + kind}>\n <span className=\"ui-sug-mark\" aria-hidden=\"true\">\n {kind === 'del' ? '−' : '+'}\n </span>\n <span className=\"ui-visually-hidden\">{kind === 'del' ? tr('原本:') : tr('改成:')}</span>\n <CodeText className=\"ui-sug-text\" text={text} refHref={refHref} onRef={onRef} isRef={isRef} />\n </div>\n );\n return (\n <div className={cx('ui-sug', className)}>\n <div className=\"ui-sug-head\">\n <span className=\"ui-sug-title\">{title || tr('建議修正')}</span>\n <IconButton\n className={cx('ui-sug-copy', copied && 'is-copied')}\n label={copied ? tr('已複製') : copyLabel || tr('複製修正')}\n icon={copied ? CHECK : 'copy'}\n onClick={copy}\n />\n </div>\n {before != null ? line('del', before) : null}\n {line('add', after)}\n <span className=\"ui-visually-hidden\" aria-live=\"polite\">\n {copied ? tr('已複製') : ''}\n </span>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AASA,aAAaA,YAAM;;
|
|
1
|
+
{"version":3,"file":"Suggestion.js","names":["phCopy"],"sources":["../../../src/components/Suggestion/Suggestion.tsx"],"sourcesContent":["import * as React from 'react';\nimport { tr } from '../../i18n';\nimport { CHECK } from '../../icons/Icon';\nimport { copyText, cx } from '../../internal/util';\nimport { IconButton } from '../IconButton/IconButton';\nimport { CodeText, type OnRef, type RefHref } from '../InlineCode/InlineCode';\nimport { includeIcons } from '../../icons/store';\nimport phCopy from '../../icons/ph/copy';\n\nincludeIcons(phCopy);\n\nexport interface SuggestionProps {\n /** Default 「建議修正」. */\n title?: string;\n /** The current line, shown with −. Text in `backticks` is code. */\n before?: string;\n /** The proposed line, shown with +. */\n after: string;\n /** What the copy button copies. Default: after. */\n copyText?: string;\n /** Default 「複製修正」. */\n copyLabel?: string;\n /** Called with the copied text after a copy. */\n onCopy?: (text: string) => void;\n /** Called when the clipboard refuses the copy. */\n onCopyError?: () => void;\n /** Spans that look like file.c:86 become links; return undefined when the reference has no target. */\n refHref?: RefHref;\n /** Called when a reference is pressed, for apps that open it themselves. */\n onRef?: OnRef;\n /** Which spans are references. Default: a file name with a line number. */\n isRef?: (span: string) => boolean;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** A proposed fix: the old line (−) above the new one (+), with a copy button at the top right. */\nexport function Suggestion({ title, before, after, copyText: copyValue, copyLabel, onCopy, onCopyError, refHref, onRef, isRef, className }: SuggestionProps) {\n const [copied, setCopied] = React.useState(false);\n const tm = React.useRef<ReturnType<typeof setTimeout>>(undefined);\n React.useEffect(() => () => clearTimeout(tm.current), []);\n const copy = () => {\n const text = copyValue ?? after;\n copyText(text).then(\n () => {\n setCopied(true);\n clearTimeout(tm.current);\n tm.current = setTimeout(() => setCopied(false), 2000);\n onCopy?.(text);\n },\n () => onCopyError?.(),\n );\n };\n const line = (kind: 'del' | 'add', text: string) => (\n <div className={'ui-sug-line is-' + kind}>\n <span className=\"ui-sug-mark\" aria-hidden=\"true\">\n {kind === 'del' ? '−' : '+'}\n </span>\n <span className=\"ui-visually-hidden\">{kind === 'del' ? tr('原本:') : tr('改成:')}</span>\n <CodeText className=\"ui-sug-text\" text={text} refHref={refHref} onRef={onRef} isRef={isRef} />\n </div>\n );\n return (\n <div className={cx('ui-sug', className)}>\n <div className=\"ui-sug-head\">\n <span className=\"ui-sug-title\">{title || tr('建議修正')}</span>\n <IconButton\n className={cx('ui-sug-copy', copied && 'is-copied')}\n label={copied ? tr('已複製') : copyLabel || tr('複製修正')}\n icon={copied ? CHECK : 'copy'}\n onClick={copy}\n />\n </div>\n {before != null ? line('del', before) : null}\n {line('add', after)}\n <span className=\"ui-visually-hidden\" aria-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S;IACV,CAAA,CACE;;GACJ,UAAU,OAAO,KAAK,OAAO,MAAM,IAAI;GACvC,KAAK,OAAO,KAAK;GAClB,oBAAC,QAAD;IAAM,WAAU;IAAqB,aAAU;IAC5C,UAAA,SAAS,GAAG,KAAK,IAAI;GAClB,CAAA;EACH;;AAET"}
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
export interface SwitchProps {
|
|
3
|
+
/** Controlled: on or off. */
|
|
3
4
|
checked?: boolean;
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
/** Uncontrolled: whether it starts on; the switch then keeps its own state. */
|
|
6
|
+
defaultChecked?: boolean;
|
|
7
|
+
/** Receives the new state, then the click event. */
|
|
8
|
+
onChange?: (checked: boolean, event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
9
|
+
/** What it turns on; becomes aria-label. Put the visible text next to it in the row (15 px, text-control). */
|
|
6
10
|
label: string;
|
|
11
|
+
/** Grayed out and skipped by Tab. */
|
|
7
12
|
disabled?: boolean;
|
|
13
|
+
/** Id of a sentence that explains the setting (SettingsRow sets it). */
|
|
14
|
+
'aria-describedby'?: string;
|
|
15
|
+
/** Form field name: an on switch sends 'on' with a native form. */
|
|
16
|
+
name?: string;
|
|
17
|
+
/** Extra class on the root element. */
|
|
8
18
|
className?: string;
|
|
9
19
|
}
|
|
10
20
|
/** An on/off setting that applies at once. The thumb stretches like a droplet while it moves. */
|
|
11
|
-
export declare function Switch({ checked, onChange, label, disabled, className }: SwitchProps): React.JSX.Element;
|
|
21
|
+
export declare function Switch({ checked, defaultChecked, onChange, label, disabled, name, 'aria-describedby': describedBy, className }: SwitchProps): React.JSX.Element;
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
import { dropTransition } from "../../motion.js";
|
|
3
3
|
import { cx } from "../../internal/util.js";
|
|
4
4
|
import * as React from "react";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
// src/components/Switch/Switch.tsx
|
|
7
7
|
/** An on/off setting that applies at once. The thumb stretches like a droplet while it moves. */
|
|
8
|
-
function Switch({ checked, onChange, label, disabled, className }) {
|
|
9
|
-
const
|
|
8
|
+
function Switch({ checked, defaultChecked, onChange, label, disabled, name, "aria-describedby": describedBy, className }) {
|
|
9
|
+
const [own, setOwn] = React.useState(!!defaultChecked);
|
|
10
|
+
const on = checked !== void 0 ? !!checked : own;
|
|
10
11
|
const [pressing, setPressing] = React.useState(false);
|
|
11
12
|
const W = 48;
|
|
12
13
|
const H = 28;
|
|
@@ -15,19 +16,23 @@ function Switch({ checked, onChange, label, disabled, className }) {
|
|
|
15
16
|
const stretch = pressing ? 6 : 0;
|
|
16
17
|
const left = on ? W - gap - th - stretch : gap;
|
|
17
18
|
const right = on ? gap : W - gap - th - stretch;
|
|
18
|
-
return /* @__PURE__ */
|
|
19
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
19
20
|
type: "button",
|
|
20
21
|
role: "switch",
|
|
21
22
|
"aria-checked": on,
|
|
22
23
|
"aria-label": label,
|
|
24
|
+
"aria-describedby": describedBy,
|
|
23
25
|
disabled,
|
|
24
26
|
className: cx("ui-switch", on && "is-on", className),
|
|
25
|
-
onClick: () =>
|
|
27
|
+
onClick: (e) => {
|
|
28
|
+
if (checked === void 0) setOwn(!on);
|
|
29
|
+
onChange?.(!on, e);
|
|
30
|
+
},
|
|
26
31
|
onPointerDown: () => setPressing(true),
|
|
27
32
|
onPointerUp: () => setPressing(false),
|
|
28
33
|
onPointerLeave: () => setPressing(false),
|
|
29
34
|
onPointerCancel: () => setPressing(false),
|
|
30
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
35
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
31
36
|
className: "ui-switch-thumb",
|
|
32
37
|
style: {
|
|
33
38
|
left,
|
|
@@ -48,7 +53,11 @@ function Switch({ checked, onChange, label, disabled, className }) {
|
|
|
48
53
|
"aria-hidden": "true",
|
|
49
54
|
children: /* @__PURE__ */ jsx("path", { d: on ? "M5 12.5l4.5 4.5L19 7" : "M7 7l10 10M17 7L7 17" })
|
|
50
55
|
})
|
|
51
|
-
})
|
|
56
|
+
}), name && on ? /* @__PURE__ */ jsx("input", {
|
|
57
|
+
type: "hidden",
|
|
58
|
+
name,
|
|
59
|
+
value: "on"
|
|
60
|
+
}) : null]
|
|
52
61
|
});
|
|
53
62
|
}
|
|
54
63
|
export { Switch };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.js","names":[],"sources":["../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import * as React from 'react';\nimport { dropTransition } from '../../motion';\nimport { cx } from '../../internal/util';\n\nexport interface SwitchProps {\n checked?: boolean;\n onChange?: (checked: boolean) => void;\n /** What it turns on; becomes aria-label. Put the visible text next to it in the row. */\n label: string;\n disabled?: boolean;\n className?: string;\n}\n\n/** An on/off setting that applies at once. The thumb stretches like a droplet while it moves. */\nexport function Switch({ checked, onChange, label, disabled, className }: SwitchProps) {\n const on = !!checked;\n const [pressing, setPressing] = React.useState(false);\n const W = 48;\n const H = 28;\n const th = pressing ? 28 : on ? 24 : 16;\n const gap = (H - th) / 2;\n const stretch = pressing ? 6 : 0;\n const left = on ? W - gap - th - stretch : gap;\n const right = on ? gap : W - gap - th - stretch;\n return (\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={on}\n aria-label={label}\n disabled={disabled}\n className={cx('ui-switch', on && 'is-on', className)}\n onClick={() => onChange?.(!on)}\n onPointerDown={() => setPressing(true)}\n onPointerUp={() => setPressing(false)}\n onPointerLeave={() => setPressing(false)}\n // A touch that turns into a scroll is cancelled, not released: the thumb goes back too.\n onPointerCancel={() => setPressing(false)}\n >\n <span\n className=\"ui-switch-thumb\"\n style={{\n left,\n right,\n height: th,\n marginTop: -th / 2,\n transition: `${dropTransition('left', 'right', on)}, height var(--dur-hover) ease, margin-top var(--dur-hover) ease, background-color var(--dur-nav) ease`,\n }}\n >\n <svg\n width={12}\n height={12}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={3.5}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d={on ? 'M5 12.5l4.5 4.5L19 7' : 'M7 7l10 10M17 7L7 17'} />\n </svg>\n </span>\n </button>\n );\n}\n"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"Switch.js","names":[],"sources":["../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import * as React from 'react';\nimport { dropTransition } from '../../motion';\nimport { cx } from '../../internal/util';\n\nexport interface SwitchProps {\n /** Controlled: on or off. */\n checked?: boolean;\n /** Uncontrolled: whether it starts on; the switch then keeps its own state. */\n defaultChecked?: boolean;\n /** Receives the new state, then the click event. */\n onChange?: (checked: boolean, event: React.MouseEvent<HTMLButtonElement>) => void;\n /** What it turns on; becomes aria-label. Put the visible text next to it in the row (15 px, text-control). */\n label: string;\n /** Grayed out and skipped by Tab. */\n disabled?: boolean;\n /** Id of a sentence that explains the setting (SettingsRow sets it). */\n 'aria-describedby'?: string;\n /** Form field name: an on switch sends 'on' with a native form. */\n name?: string;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** An on/off setting that applies at once. The thumb stretches like a droplet while it moves. */\nexport function Switch({ checked, defaultChecked, onChange, label, disabled, name, 'aria-describedby': describedBy, className }: SwitchProps) {\n const [own, setOwn] = React.useState(!!defaultChecked);\n const on = checked !== undefined ? !!checked : own;\n const [pressing, setPressing] = React.useState(false);\n const W = 48;\n const H = 28;\n const th = pressing ? 28 : on ? 24 : 16;\n const gap = (H - th) / 2;\n const stretch = pressing ? 6 : 0;\n const left = on ? W - gap - th - stretch : gap;\n const right = on ? gap : W - gap - th - stretch;\n return (\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={on}\n aria-label={label}\n aria-describedby={describedBy}\n disabled={disabled}\n className={cx('ui-switch', on && 'is-on', className)}\n onClick={(e) => {\n if (checked === undefined) setOwn(!on);\n onChange?.(!on, e);\n }}\n onPointerDown={() => setPressing(true)}\n onPointerUp={() => setPressing(false)}\n onPointerLeave={() => setPressing(false)}\n // A touch that turns into a scroll is cancelled, not released: the thumb goes back too.\n onPointerCancel={() => setPressing(false)}\n >\n <span\n className=\"ui-switch-thumb\"\n style={{\n left,\n right,\n height: th,\n marginTop: -th / 2,\n transition: `${dropTransition('left', 'right', on)}, height var(--dur-hover) ease, margin-top var(--dur-hover) ease, background-color var(--dur-nav) ease`,\n }}\n >\n <svg\n width={12}\n height={12}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={3.5}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d={on ? 'M5 12.5l4.5 4.5L19 7' : 'M7 7l10 10M17 7L7 17'} />\n </svg>\n </span>\n {name && on ? <input type=\"hidden\" name={name} value=\"on\" /> : null}\n </button>\n );\n}\n"],"mappings":";;;;;;;AAwBA,SAAgB,OAAO,EAAE,SAAS,gBAAgB,UAAU,OAAO,UAAU,MAAM,oBAAoB,aAAa,aAA0B;CAC5I,MAAM,CAAC,KAAK,UAAU,MAAM,SAAS,CAAC,CAAC,cAAc;CACrD,MAAM,KAAK,YAAY,KAAA,IAAY,CAAC,CAAC,UAAU;CAC/C,MAAM,CAAC,UAAU,eAAe,MAAM,SAAS,KAAK;CACpD,MAAM,IAAI;CACV,MAAM,IAAI;CACV,MAAM,KAAK,WAAW,KAAK,KAAK,KAAK;CACrC,MAAM,OAAO,IAAI,MAAM;CACvB,MAAM,UAAU,WAAW,IAAI;CAC/B,MAAM,OAAO,KAAK,IAAI,MAAM,KAAK,UAAU;CAC3C,MAAM,QAAQ,KAAK,MAAM,IAAI,MAAM,KAAK;CACxC,OACE,qBAAC,UAAD;EACE,MAAK;EACL,MAAK;EACL,gBAAc;EACd,cAAY;EACZ,oBAAkB;EACR;EACV,WAAW,GAAG,aAAa,MAAM,SAAS,SAAS;EACnD,UAAU,MAAM;GACd,IAAI,YAAY,KAAA,GAAW,OAAO,CAAC,EAAE;GACrC,WAAW,CAAC,IAAI,CAAC;EACnB;EACA,qBAAqB,YAAY,IAAI;EACrC,mBAAmB,YAAY,KAAK;EACpC,sBAAsB,YAAY,KAAK;EAEvC,uBAAuB,YAAY,KAAK;EAhB1C,UAAA,CAkBE,oBAAC,QAAD;GACE,WAAU;GACV,OAAO;IACL;IACA;IACA,QAAQ;IACR,WAAW,CAAC,KAAK;IACjB,YAAY,GAAG,eAAe,QAAQ,SAAS,EAAE,EAAE;GACrD;GAEA,UAAA,oBAAC,OAAD;IACE,OAAO;IACP,QAAQ;IACR,SAAQ;IACR,MAAK;IACL,QAAO;IACP,aAAa;IACb,eAAc;IACd,gBAAe;IACf,eAAY;IAEZ,UAAA,oBAAC,QAAD,EAAM,GAAG,KAAK,yBAAyB,uBAAyB,CAAA;GAC7D,CAAA;EACD,CAAA,GACL,QAAQ,KAAK,oBAAC,SAAD;GAAO,MAAK;GAAe;GAAM,OAAM;EAAM,CAAA,IAAI,IACzD;;AAEZ"}
|
|
@@ -9,8 +9,11 @@ export interface TabItem<V extends string = string> {
|
|
|
9
9
|
unit?: CountUnit;
|
|
10
10
|
}
|
|
11
11
|
export interface TabsProps<V extends string = string> {
|
|
12
|
+
/** The tabs, in order. */
|
|
12
13
|
items: TabItem<V>[];
|
|
14
|
+
/** The id of the selected tab (controlled). */
|
|
13
15
|
value: V;
|
|
16
|
+
/** Called with the id of the tab the person picks. */
|
|
14
17
|
onChange?: (id: V) => void;
|
|
15
18
|
/** aria-label of the tab list. */
|
|
16
19
|
label?: string;
|
|
@@ -20,6 +23,7 @@ export interface TabsProps<V extends string = string> {
|
|
|
20
23
|
/** Counts show the number only; the unit is still read by screen readers and announced. For a row of status counts
|
|
21
24
|
* (DataTable's summary) where the unit is the same on every tab. Default false. */
|
|
22
25
|
hideUnit?: boolean;
|
|
26
|
+
/** Extra class on the root element. */
|
|
23
27
|
className?: string;
|
|
24
28
|
}
|
|
25
29
|
/** Views of the same content. The underline moves like a droplet; arrow keys move between tabs. */
|
|
@@ -33,7 +33,7 @@ function Tabs({ items, value, onChange, label, unit, hideUnit = false, className
|
|
|
33
33
|
});
|
|
34
34
|
}, []);
|
|
35
35
|
useFocusRescue(track, () => refs.current[Math.max(0, items.findIndex((t) => t.id === value))]);
|
|
36
|
-
devWarn(items.some((t) => t.count != null && !(t.unit || unit)), "Tabs", "a count has no unit, so it reads as a bare number. Pass unit, e.g. unit: '筆', on Tabs or on the item.");
|
|
36
|
+
devWarn(() => items.some((t) => t.count != null && !(t.unit || unit)), "Tabs", "a count has no unit, so it reads as a bare number. Pass unit, e.g. unit: '筆', on Tabs or on the item.");
|
|
37
37
|
const idx = Math.max(0, items.findIndex((t) => t.id === value));
|
|
38
38
|
React.useLayoutEffect(() => {
|
|
39
39
|
const el = refs.current[idx];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.js","names":[],"sources":["../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import * as React from 'react';\nimport { format } from '../../format';\nimport { dropTransition, useMoving } from '../../motion';\nimport { cx, browserKey, resizeObserver } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { useFocusRescue } from '../../internal/focus';\nimport { announce } from '../../announce';\nimport { unitFor, type CountUnit } from '../../i18n';\n\nexport interface TabItem<V extends string = string> {\n id: V;\n label: string;\n /** A count after the label, e.g. how many rows a view has. */\n count?: number;\n /** Unit after this tab's count, e.g. 「筆」, or a function of the count for plurals. Default: the list's unit. */\n unit?: CountUnit;\n}\n\nexport interface TabsProps<V extends string = string> {\n items: TabItem<V>[];\n value: V;\n onChange?: (id: V) => void;\n /** aria-label of the tab list. */\n label?: string;\n /** Unit after every count, e.g. 「筆」 or 「個」: a number carries its unit. A function gets the count, for plurals:\n * `(n) => (n === 1 ? 'item' : 'items')`. */\n unit?: CountUnit;\n /** Counts show the number only; the unit is still read by screen readers and announced. For a row of status counts\n * (DataTable's summary) where the unit is the same on every tab. Default false. */\n hideUnit?: boolean;\n className?: string;\n}\n\n/** Views of the same content. The underline moves like a droplet; arrow keys move between tabs. */\nexport function Tabs<V extends string = string>({ items, value, onChange, label, unit, hideUnit = false, className }: TabsProps<V>) {\n const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n const track = React.useRef<HTMLDivElement>(null);\n const [box, setBox] = React.useState<{ left: number; right: number } | null>(null);\n const [forward, setForward] = React.useState(true);\n const [moving, bump] = useMoving();\n // Wider than its box (G0): a fade on the side that has more tabs, and the selected tab kept in view.\n const [more, setMore] = React.useState({ left: false, right: false });\n const edges = React.useCallback(() => {\n const el = track.current;\n if (!el) return;\n const left = el.scrollLeft > 1;\n // The end of the last tab, not scrollWidth: the moving indicator can stick out for a moment and leave a fade on a\n // row that fits.\n const last = refs.current.filter(Boolean).pop();\n const end = last ? last.offsetLeft + last.offsetWidth : el.scrollWidth;\n const right = el.scrollLeft + el.clientWidth < end - 1;\n setMore((m) => (m.left === left && m.right === right ? m : { left, right }));\n }, []);\n // The focused tab re-rendered away (new items, the app swapped the list): focus goes to the selected tab.\n useFocusRescue(\n track,\n () =>\n refs.current[\n Math.max(\n 0,\n items.findIndex((t) => t.id === value),\n )\n ],\n );\n devWarn(\n items.some((t) => t.count != null && !(t.unit || unit)),\n 'Tabs',\n \"a count has no unit, so it reads as a bare number. Pass unit, e.g. unit: '筆', on Tabs or on the item.\",\n );\n const idx = Math.max(\n 0,\n items.findIndex((t) => t.id === value),\n );\n React.useLayoutEffect(() => {\n const el = refs.current[idx];\n const tr = track.current;\n if (!el || !tr) return;\n // Counts, fonts and the container change tab widths without changing the selection.\n const measure = () => {\n // Both sides from the row's own box: a tab past the visible part gets a negative right, and scrolls with the row.\n setBox({ left: el.offsetLeft, right: tr.clientWidth - el.offsetLeft - el.offsetWidth });\n edges();\n };\n measure();\n // The selected tab in view, without scrolling the page.\n if (el.offsetLeft < tr.scrollLeft) tr.scrollLeft = el.offsetLeft - 4;\n else if (el.offsetLeft + el.offsetWidth > tr.scrollLeft + tr.clientWidth) tr.scrollLeft = el.offsetLeft + el.offsetWidth - tr.clientWidth + 4;\n const ro = resizeObserver(measure);\n ro?.observe(tr);\n for (const t of refs.current) if (t) ro?.observe(t);\n return () => ro?.disconnect();\n }, [idx, items.length, edges]);\n const go = (i: number) => {\n if (i === idx || !items[i]) return;\n setForward(i > idx);\n bump();\n onChange?.(items[i].id);\n announce(\n items[i].label +\n (items[i].count != null\n ? ' ' + format.number(items[i].count ?? 0) + (items[i].unit || unit ? ' ' + unitFor(items[i].unit || unit, items[i].count ?? 0) : '')\n : ''),\n );\n };\n return (\n <div\n ref={track}\n className={cx('ui-tabs', more.left && 'has-more-left', more.right && 'has-more-right', className)}\n role=\"tablist\"\n aria-label={label}\n onScroll={edges}\n >\n {box ? (\n <span\n className=\"ui-tabs-ind\"\n aria-hidden=\"true\"\n style={{ left: box.left, right: box.right, transform: moving ? 'scaleY(.82)' : 'none', transition: dropTransition('left', 'right', forward) }}\n />\n ) : null}\n {items.map((t, i) => (\n <button\n key={t.id}\n ref={(n) => {\n refs.current[i] = n;\n }}\n type=\"button\"\n role=\"tab\"\n aria-selected={i === idx}\n tabIndex={i === idx ? 0 : -1}\n className={cx('ui-tab', i === idx && 'is-selected')}\n onClick={() => go(i)}\n onKeyDown={(e) => {\n if (browserKey(e)) return;\n const to = e.key === 'ArrowRight' ? (i + 1) % items.length : e.key === 'ArrowLeft' ? (i - 1 + items.length) % items.length : -1;\n if (to < 0) return;\n e.preventDefault();\n refs.current[to]?.focus();\n go(to);\n }}\n >\n {t.label}\n {/* A space between the name and its count, also for screen readers: 「全部 26 個」. */}\n {t.count != null ? ' ' : null}\n {t.count != null ? (\n <span className=\"ui-tab-count\">\n {format.number(t.count)}\n {t.unit || unit ? (\n hideUnit ? (\n <span className=\"ui-visually-hidden\"> {unitFor(t.unit || unit, t.count)}</span>\n ) : (\n <>\n {' '}\n <span className=\"ui-unit\">{unitFor(t.unit || unit, t.count)}</span>\n </>\n )\n ) : null}\n </span>\n ) : null}\n </button>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Tabs.js","names":[],"sources":["../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import * as React from 'react';\nimport { format } from '../../format';\nimport { dropTransition, useMoving } from '../../motion';\nimport { cx, browserKey, resizeObserver } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { useFocusRescue } from '../../internal/focus';\nimport { announce } from '../../announce';\nimport { unitFor, type CountUnit } from '../../i18n';\n\nexport interface TabItem<V extends string = string> {\n id: V;\n label: string;\n /** A count after the label, e.g. how many rows a view has. */\n count?: number;\n /** Unit after this tab's count, e.g. 「筆」, or a function of the count for plurals. Default: the list's unit. */\n unit?: CountUnit;\n}\n\nexport interface TabsProps<V extends string = string> {\n /** The tabs, in order. */\n items: TabItem<V>[];\n /** The id of the selected tab (controlled). */\n value: V;\n /** Called with the id of the tab the person picks. */\n onChange?: (id: V) => void;\n /** aria-label of the tab list. */\n label?: string;\n /** Unit after every count, e.g. 「筆」 or 「個」: a number carries its unit. A function gets the count, for plurals:\n * `(n) => (n === 1 ? 'item' : 'items')`. */\n unit?: CountUnit;\n /** Counts show the number only; the unit is still read by screen readers and announced. For a row of status counts\n * (DataTable's summary) where the unit is the same on every tab. Default false. */\n hideUnit?: boolean;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** Views of the same content. The underline moves like a droplet; arrow keys move between tabs. */\nexport function Tabs<V extends string = string>({ items, value, onChange, label, unit, hideUnit = false, className }: TabsProps<V>) {\n const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n const track = React.useRef<HTMLDivElement>(null);\n const [box, setBox] = React.useState<{ left: number; right: number } | null>(null);\n const [forward, setForward] = React.useState(true);\n const [moving, bump] = useMoving();\n // Wider than its box (G0): a fade on the side that has more tabs, and the selected tab kept in view.\n const [more, setMore] = React.useState({ left: false, right: false });\n const edges = React.useCallback(() => {\n const el = track.current;\n if (!el) return;\n const left = el.scrollLeft > 1;\n // The end of the last tab, not scrollWidth: the moving indicator can stick out for a moment and leave a fade on a\n // row that fits.\n const last = refs.current.filter(Boolean).pop();\n const end = last ? last.offsetLeft + last.offsetWidth : el.scrollWidth;\n const right = el.scrollLeft + el.clientWidth < end - 1;\n setMore((m) => (m.left === left && m.right === right ? m : { left, right }));\n }, []);\n // The focused tab re-rendered away (new items, the app swapped the list): focus goes to the selected tab.\n useFocusRescue(\n track,\n () =>\n refs.current[\n Math.max(\n 0,\n items.findIndex((t) => t.id === value),\n )\n ],\n );\n devWarn(\n () => items.some((t) => t.count != null && !(t.unit || unit)),\n 'Tabs',\n \"a count has no unit, so it reads as a bare number. Pass unit, e.g. unit: '筆', on Tabs or on the item.\",\n );\n const idx = Math.max(\n 0,\n items.findIndex((t) => t.id === value),\n );\n React.useLayoutEffect(() => {\n const el = refs.current[idx];\n const tr = track.current;\n if (!el || !tr) return;\n // Counts, fonts and the container change tab widths without changing the selection.\n const measure = () => {\n // Both sides from the row's own box: a tab past the visible part gets a negative right, and scrolls with the row.\n setBox({ left: el.offsetLeft, right: tr.clientWidth - el.offsetLeft - el.offsetWidth });\n edges();\n };\n measure();\n // The selected tab in view, without scrolling the page.\n if (el.offsetLeft < tr.scrollLeft) tr.scrollLeft = el.offsetLeft - 4;\n else if (el.offsetLeft + el.offsetWidth > tr.scrollLeft + tr.clientWidth) tr.scrollLeft = el.offsetLeft + el.offsetWidth - tr.clientWidth + 4;\n const ro = resizeObserver(measure);\n ro?.observe(tr);\n for (const t of refs.current) if (t) ro?.observe(t);\n return () => ro?.disconnect();\n }, [idx, items.length, edges]);\n const go = (i: number) => {\n if (i === idx || !items[i]) return;\n setForward(i > idx);\n bump();\n onChange?.(items[i].id);\n announce(\n items[i].label +\n (items[i].count != null\n ? ' ' + format.number(items[i].count ?? 0) + (items[i].unit || unit ? ' ' + unitFor(items[i].unit || unit, items[i].count ?? 0) : '')\n : ''),\n );\n };\n return (\n <div\n ref={track}\n className={cx('ui-tabs', more.left && 'has-more-left', more.right && 'has-more-right', className)}\n role=\"tablist\"\n aria-label={label}\n onScroll={edges}\n >\n {box ? (\n <span\n className=\"ui-tabs-ind\"\n aria-hidden=\"true\"\n style={{ left: box.left, right: box.right, transform: moving ? 'scaleY(.82)' : 'none', transition: dropTransition('left', 'right', forward) }}\n />\n ) : null}\n {items.map((t, i) => (\n <button\n key={t.id}\n ref={(n) => {\n refs.current[i] = n;\n }}\n type=\"button\"\n role=\"tab\"\n aria-selected={i === idx}\n tabIndex={i === idx ? 0 : -1}\n className={cx('ui-tab', i === idx && 'is-selected')}\n onClick={() => go(i)}\n onKeyDown={(e) => {\n if (browserKey(e)) return;\n const to = e.key === 'ArrowRight' ? (i + 1) % items.length : e.key === 'ArrowLeft' ? (i - 1 + items.length) % items.length : -1;\n if (to < 0) return;\n e.preventDefault();\n refs.current[to]?.focus();\n go(to);\n }}\n >\n {t.label}\n {/* A space between the name and its count, also for screen readers: 「全部 26 個」. */}\n {t.count != null ? ' ' : null}\n {t.count != null ? (\n <span className=\"ui-tab-count\">\n {format.number(t.count)}\n {t.unit || unit ? (\n hideUnit ? (\n <span className=\"ui-visually-hidden\"> {unitFor(t.unit || unit, t.count)}</span>\n ) : (\n <>\n {' '}\n <span className=\"ui-unit\">{unitFor(t.unit || unit, t.count)}</span>\n </>\n )\n ) : null}\n </span>\n ) : null}\n </button>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAsCA,SAAgB,KAAgC,EAAE,OAAO,OAAO,UAAU,OAAO,MAAM,WAAW,OAAO,aAA2B;CAClI,MAAM,OAAO,MAAM,OAAqC,CAAC,CAAC;CAC1D,MAAM,QAAQ,MAAM,OAAuB,IAAI;CAC/C,MAAM,CAAC,KAAK,UAAU,MAAM,SAAiD,IAAI;CACjF,MAAM,CAAC,SAAS,cAAc,MAAM,SAAS,IAAI;CACjD,MAAM,CAAC,QAAQ,QAAQ,UAAU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AI,KAAK,GAAG;IACZ,EAAE,eAAe;IACjB,KAAK,QAAQ,GAAG,EAAE,MAAM;IACxB,GAAG,EAAE;GACP;GAlBF,UAAA;IAoBG,EAAE;IAEF,EAAE,SAAS,OAAO,MAAM;IACxB,EAAE,SAAS,OACV,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CACG,OAAO,OAAO,EAAE,KAAK,GACrB,EAAE,QAAQ,OACT,WACE,qBAAC,QAAD;MAAM,WAAU;MAAhB,UAAA,CAAqC,KAAE,QAAQ,EAAE,QAAQ,MAAM,EAAE,KAAK,CAAQ;KAE9E,CAAA,IAAA,qBAAA,UAAA,EAAA,UAAA,CACG,KACD,oBAAC,QAAD;MAAM,WAAU;MAAW,UAAA,QAAQ,EAAE,QAAQ,MAAM,EAAE,KAAK;KAAQ,CAAA,CAClE,EAAA,CAAA,IAEF,IACA;IACJ,CAAA,IAAA;GACE;EArCD,GAAA,EAAE,EAqCD,CACT,CACE;;AAET"}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import { IconSource } from "../../icons/Icon.js";
|
|
1
2
|
import * as React from "react";
|
|
3
|
+
/** Text colour of a Tag. Categories stay 'neutral'; a colour only for a mark that says where values come from. */
|
|
4
|
+
export type TagTone = 'neutral' | 'info' | 'success' | 'warning' | 'danger';
|
|
2
5
|
export interface TagProps {
|
|
6
|
+
/** The words, e.g. 「外部」 or 「預測」. */
|
|
3
7
|
children?: React.ReactNode;
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
/** An icon before the words: the tag then takes the size of the text beside it, e.g. 'trend-up' with 「預測」, 'info'
|
|
9
|
+
* with 「示範資料」 beside the brand. */
|
|
10
|
+
icon?: IconSource;
|
|
11
|
+
/** Without an icon the text is ink-muted; with an icon it keeps the colour of the text beside it. 'info' is accent
|
|
12
|
+
* text, e.g. for forecast values. */
|
|
13
|
+
tone?: TagTone;
|
|
14
|
+
/** @deprecated Use icon and tone: 'forecast' is icon="trend-up" tone="info", 'demo' is icon="info". */
|
|
8
15
|
variant?: 'plain' | 'forecast' | 'demo';
|
|
16
|
+
/** Extra class on the root element. */
|
|
9
17
|
className?: string;
|
|
10
18
|
}
|
|
11
|
-
/** What kind of thing an item is (「外部」「範本」): small gray text. Status uses Badge instead.
|
|
12
|
-
*
|
|
13
|
-
export declare function Tag({ children, variant, className }: TagProps): React.JSX.Element;
|
|
19
|
+
/** What kind of thing an item is (「外部」「範本」): small gray text. Status uses Badge instead. With an icon it marks where
|
|
20
|
+
* values come from (預測, 示範資料), at the size of the text beside it. */
|
|
21
|
+
export declare function Tag({ children, icon, tone, variant, className }: TagProps): React.JSX.Element;
|
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { IconOf } from "../../icons/Icon.js";
|
|
3
3
|
import { cx } from "../../internal/util.js";
|
|
4
|
+
import { devWarn } from "../../internal/dev.js";
|
|
4
5
|
import { includeIcons } from "../../icons/store.js";
|
|
5
6
|
import info_default from "../../icons/ph/info.js";
|
|
6
7
|
import trend_up_default from "../../icons/ph/trend-up.js";
|
|
7
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
9
|
// src/components/Tag/Tag.tsx
|
|
9
10
|
includeIcons(info_default, trend_up_default);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const LEGACY = {
|
|
12
|
+
forecast: {
|
|
13
|
+
icon: "trend-up",
|
|
14
|
+
tone: "info"
|
|
15
|
+
},
|
|
16
|
+
demo: {
|
|
17
|
+
icon: "info",
|
|
18
|
+
tone: void 0
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
/** What kind of thing an item is (「外部」「範本」): small gray text. Status uses Badge instead. With an icon it marks where
|
|
22
|
+
* values come from (預測, 示範資料), at the size of the text beside it. */
|
|
23
|
+
function Tag({ children, icon, tone, variant, className }) {
|
|
24
|
+
devWarn(variant !== void 0 && variant !== "plain", "Tag", `variant="${String(variant)}" is deprecated. Use icon and tone: forecast is icon="trend-up" tone="info", demo is icon="info".`);
|
|
25
|
+
const legacy = variant && variant !== "plain" ? LEGACY[variant] : void 0;
|
|
26
|
+
const ic = icon ?? legacy?.icon;
|
|
27
|
+
const t = tone ?? legacy?.tone;
|
|
13
28
|
return /* @__PURE__ */ jsxs("span", {
|
|
14
|
-
className: cx("ui-tag",
|
|
15
|
-
children: [
|
|
16
|
-
|
|
17
|
-
size: 16
|
|
18
|
-
}) : variant === "demo" ? /* @__PURE__ */ jsx(Icon, {
|
|
19
|
-
name: "info",
|
|
29
|
+
className: cx("ui-tag", ic && "has-icon", t && "is-" + t, className),
|
|
30
|
+
children: [ic ? /* @__PURE__ */ jsx(IconOf, {
|
|
31
|
+
icon: ic,
|
|
20
32
|
size: 16
|
|
21
33
|
}) : null, children]
|
|
22
34
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.js","names":["phInfo","phTrendUp"],"sources":["../../../src/components/Tag/Tag.tsx"],"sourcesContent":["import type * as React from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"Tag.js","names":["phInfo","phTrendUp"],"sources":["../../../src/components/Tag/Tag.tsx"],"sourcesContent":["import type * as React from 'react';\nimport { IconOf, type IconSource } from '../../icons/Icon';\nimport { cx } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { includeIcons } from '../../icons/store';\nimport phInfo from '../../icons/ph/info';\nimport phTrendUp from '../../icons/ph/trend-up';\n\nincludeIcons(phInfo, phTrendUp);\n\n/** Text colour of a Tag. Categories stay 'neutral'; a colour only for a mark that says where values come from. */\nexport type TagTone = 'neutral' | 'info' | 'success' | 'warning' | 'danger';\n\nexport interface TagProps {\n /** The words, e.g. 「外部」 or 「預測」. */\n children?: React.ReactNode;\n /** An icon before the words: the tag then takes the size of the text beside it, e.g. 'trend-up' with 「預測」, 'info'\n * with 「示範資料」 beside the brand. */\n icon?: IconSource;\n /** Without an icon the text is ink-muted; with an icon it keeps the colour of the text beside it. 'info' is accent\n * text, e.g. for forecast values. */\n tone?: TagTone;\n /** @deprecated Use icon and tone: 'forecast' is icon=\"trend-up\" tone=\"info\", 'demo' is icon=\"info\". */\n variant?: 'plain' | 'forecast' | 'demo';\n /** Extra class on the root element. */\n className?: string;\n}\n\nconst LEGACY = { forecast: { icon: 'trend-up', tone: 'info' }, demo: { icon: 'info', tone: undefined } } as const;\n\n/** What kind of thing an item is (「外部」「範本」): small gray text. Status uses Badge instead. With an icon it marks where\n * values come from (預測, 示範資料), at the size of the text beside it. */\nexport function Tag({ children, icon, tone, variant, className }: TagProps) {\n devWarn(\n variant !== undefined && variant !== 'plain',\n 'Tag',\n `variant=\"${String(variant)}\" is deprecated. Use icon and tone: forecast is icon=\"trend-up\" tone=\"info\", demo is icon=\"info\".`,\n );\n const legacy = variant && variant !== 'plain' ? LEGACY[variant] : undefined;\n const ic = icon ?? legacy?.icon;\n const t = tone ?? legacy?.tone;\n return (\n <span className={cx('ui-tag', ic && 'has-icon', t && 'is-' + t, className)}>\n {ic ? <IconOf icon={ic} size={16} /> : null}\n {children}\n </span>\n );\n}\n"],"mappings":";;;;;;;;;AAQA,aAAaA,cAAQC,gBAAS;AAoB9B,MAAM,SAAS;CAAE,UAAU;EAAE,MAAM;EAAY,MAAM;CAAO;CAAG,MAAM;EAAE,MAAM;EAAQ,MAAM,KAAA;CAAU;AAAE;;;AAIvG,SAAgB,IAAI,EAAE,UAAU,MAAM,MAAM,SAAS,aAAuB;CAC1E,QACE,YAAY,KAAA,KAAa,YAAY,SACrC,OACA,YAAY,OAAO,OAAO,EAAE,kGAC9B;CACA,MAAM,SAAS,WAAW,YAAY,UAAU,OAAO,WAAW,KAAA;CAClE,MAAM,KAAK,QAAQ,QAAQ;CAC3B,MAAM,IAAI,QAAQ,QAAQ;CAC1B,OACE,qBAAC,QAAD;EAAM,WAAW,GAAG,UAAU,MAAM,YAAY,KAAK,QAAQ,GAAG,SAAS;EAAzE,UAAA,CACG,KAAK,oBAAC,QAAD;GAAQ,MAAM;GAAI,MAAM;EAAK,CAAA,IAAI,MACtC,QACG;;AAEV"}
|
|
@@ -16,17 +16,22 @@ export interface TermProps {
|
|
|
16
16
|
label: string;
|
|
17
17
|
onClick?: () => void;
|
|
18
18
|
};
|
|
19
|
+
/** Spans in text that look like file.c:86 become links; return undefined when the reference has no target. */
|
|
19
20
|
refHref?: RefHref;
|
|
21
|
+
/** Called when a reference is pressed, for apps that open it themselves. */
|
|
20
22
|
onRef?: OnRef;
|
|
23
|
+
/** Which spans are references. Default: a file name with a line number. */
|
|
21
24
|
isRef?: (span: string) => boolean;
|
|
22
25
|
/** `icon` (default): the word with a small question mark, opened by a press. `inline`: a dashed underline inside a
|
|
23
|
-
* sentence; the card opens after resting on the word for 500 ms,
|
|
26
|
+
* sentence; the card opens on Enter or a press, after resting the pointer on the word for 500 ms, and as a sheet on
|
|
27
|
+
* phones. */
|
|
24
28
|
variant?: 'icon' | 'inline';
|
|
25
|
-
/** inline only: keyboard focus opens the card at once. Default
|
|
26
|
-
*
|
|
29
|
+
/** inline only: keyboard focus opens the card at once. Default false: Enter or a press opens it, so tabbing past a
|
|
30
|
+
* word does not read its whole card. */
|
|
27
31
|
openOnFocus?: boolean;
|
|
28
32
|
/** -1 inside a widget that moves focus with its own keys (CodeView). */
|
|
29
33
|
tabIndex?: number;
|
|
34
|
+
/** Extra class on the root element. */
|
|
30
35
|
className?: string;
|
|
31
36
|
}
|
|
32
37
|
/** A word that opens its explanation: a floating card from 600 px, a sheet from the bottom on phones. `icon` adds a small
|
|
@@ -15,7 +15,7 @@ import { Popover } from "@base-ui/react/popover";
|
|
|
15
15
|
includeIcons(question_default, x_default);
|
|
16
16
|
/** A word that opens its explanation: a floating card from 600 px, a sheet from the bottom on phones. `icon` adds a small
|
|
17
17
|
* question mark; `inline` marks the word with a dashed underline and opens on hover or keyboard focus. */
|
|
18
|
-
function Term({ children, title, text, content, code, action, refHref, onRef, isRef, variant = "icon", openOnFocus =
|
|
18
|
+
function Term({ children, title, text, content, code, action, refHref, onRef, isRef, variant = "icon", openOnFocus = false, tabIndex, className }) {
|
|
19
19
|
const [open, setOpen] = React.useState(false);
|
|
20
20
|
const narrow = useNarrow();
|
|
21
21
|
const inlineV = variant === "inline";
|