@seanyeh77/ui 0.40.0 → 0.42.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/README.md +32 -0
- package/dist/announce.d.ts +3 -0
- package/dist/announce.js +35 -0
- package/dist/announce.js.map +1 -0
- package/dist/bundle.js +19 -19
- package/dist/bundle.js.map +1 -1
- package/dist/components/AccentPicker/AccentPicker.d.ts +12 -0
- package/dist/components/AccentPicker/AccentPicker.js +96 -0
- package/dist/components/AccentPicker/AccentPicker.js.map +1 -0
- package/dist/components/ActionBar/ActionBar.d.ts +27 -0
- package/dist/components/ActionBar/ActionBar.js +62 -0
- package/dist/components/ActionBar/ActionBar.js.map +1 -0
- package/dist/components/AiMark/AiMark.d.ts +10 -0
- package/dist/components/AiMark/AiMark.js +21 -0
- package/dist/components/AiMark/AiMark.js.map +1 -0
- package/dist/components/Alert/Alert.d.ts +17 -0
- package/dist/components/Alert/Alert.js +56 -0
- package/dist/components/Alert/Alert.js.map +1 -0
- package/dist/components/AppShell/AppShell.d.ts +36 -0
- package/dist/components/AppShell/AppShell.js +195 -0
- package/dist/components/AppShell/AppShell.js.map +1 -0
- package/dist/components/Badge/Badge.d.ts +12 -0
- package/dist/components/Badge/Badge.js +58 -0
- package/dist/components/Badge/Badge.js.map +1 -0
- package/dist/components/BarChart/BarChart.d.ts +19 -0
- package/dist/components/BarChart/BarChart.js +78 -0
- package/dist/components/BarChart/BarChart.js.map +1 -0
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +11 -0
- package/dist/components/Breadcrumb/Breadcrumb.js +29 -0
- package/dist/components/Breadcrumb/Breadcrumb.js.map +1 -0
- package/dist/components/Button/Button.d.ts +39 -0
- package/dist/components/Button/Button.js +54 -0
- package/dist/components/Button/Button.js.map +1 -0
- package/dist/components/Calendar/Calendar.d.ts +18 -0
- package/dist/components/Calendar/Calendar.js +125 -0
- package/dist/components/Calendar/Calendar.js.map +1 -0
- package/dist/components/Card/Card.d.ts +14 -0
- package/dist/components/Card/Card.js +33 -0
- package/dist/components/Card/Card.js.map +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +14 -0
- package/dist/components/Checkbox/Checkbox.js +27 -0
- package/dist/components/Checkbox/Checkbox.js.map +1 -0
- package/dist/components/CodeView/CodeView.d.ts +111 -0
- package/dist/components/CodeView/CodeView.js +790 -0
- package/dist/components/CodeView/CodeView.js.map +1 -0
- package/dist/components/CodeView/tokens.d.ts +5 -0
- package/dist/components/CodeView/tokens.js +70 -0
- package/dist/components/CodeView/tokens.js.map +1 -0
- package/dist/components/CommandPalette/CommandPalette.d.ts +52 -0
- package/dist/components/CommandPalette/CommandPalette.js +242 -0
- package/dist/components/CommandPalette/CommandPalette.js.map +1 -0
- package/dist/components/ConsoleLayout/ConsoleLayout.d.ts +44 -0
- package/dist/components/ConsoleLayout/ConsoleLayout.js +119 -0
- package/dist/components/ConsoleLayout/ConsoleLayout.js.map +1 -0
- package/dist/components/DangerZone/DangerZone.d.ts +16 -0
- package/dist/components/DangerZone/DangerZone.js +28 -0
- package/dist/components/DangerZone/DangerZone.js.map +1 -0
- package/dist/components/DataTable/DataTable.d.ts +99 -0
- package/dist/components/DataTable/DataTable.js +1267 -0
- package/dist/components/DataTable/DataTable.js.map +1 -0
- package/dist/components/DataTable/SortButton.js +222 -0
- package/dist/components/DataTable/SortButton.js.map +1 -0
- package/dist/components/DataTable/filters.js +147 -0
- package/dist/components/DataTable/filters.js.map +1 -0
- package/dist/components/DataTable/parts.js +373 -0
- package/dist/components/DataTable/parts.js.map +1 -0
- package/dist/components/DataTable/types.d.ts +85 -0
- package/dist/components/DatePicker/DatePicker.d.ts +15 -0
- package/dist/components/DatePicker/DatePicker.js +104 -0
- package/dist/components/DatePicker/DatePicker.js.map +1 -0
- package/dist/components/DateRangePicker/DateRangePicker.d.ts +11 -0
- package/dist/components/DateRangePicker/DateRangePicker.js +88 -0
- package/dist/components/DateRangePicker/DateRangePicker.js.map +1 -0
- package/dist/components/DetailList/DetailList.d.ts +17 -0
- package/dist/components/DetailList/DetailList.js +18 -0
- package/dist/components/DetailList/DetailList.js.map +1 -0
- package/dist/components/Dialog/Dialog.d.ts +30 -0
- package/dist/components/Dialog/Dialog.js +87 -0
- package/dist/components/Dialog/Dialog.js.map +1 -0
- package/dist/components/Drawer/Drawer.d.ts +20 -0
- package/dist/components/Drawer/Drawer.js +64 -0
- package/dist/components/Drawer/Drawer.js.map +1 -0
- package/dist/components/EmptyState/EmptyState.d.ts +15 -0
- package/dist/components/EmptyState/EmptyState.js +34 -0
- package/dist/components/EmptyState/EmptyState.js.map +1 -0
- package/dist/components/ErrorPage/ErrorPage.d.ts +14 -0
- package/dist/components/ErrorPage/ErrorPage.js +47 -0
- package/dist/components/ErrorPage/ErrorPage.js.map +1 -0
- package/dist/components/EventTimeline/EventTimeline.d.ts +19 -0
- package/dist/components/EventTimeline/EventTimeline.js +63 -0
- package/dist/components/EventTimeline/EventTimeline.js.map +1 -0
- package/dist/components/FileUpload/FileUpload.d.ts +27 -0
- package/dist/components/FileUpload/FileUpload.js +121 -0
- package/dist/components/FileUpload/FileUpload.js.map +1 -0
- package/dist/components/FormGrid/FormGrid.d.ts +7 -0
- package/dist/components/FormGrid/FormGrid.js +14 -0
- package/dist/components/FormGrid/FormGrid.js.map +1 -0
- package/dist/components/Graph/Graph.d.ts +18 -0
- package/dist/components/Graph/Graph.js +97 -0
- package/dist/components/Graph/Graph.js.map +1 -0
- package/dist/components/Grid/Grid.d.ts +16 -0
- package/dist/components/Grid/Grid.js +21 -0
- package/dist/components/Grid/Grid.js.map +1 -0
- package/dist/components/IconButton/IconButton.d.ts +32 -0
- package/dist/components/IconButton/IconButton.js +104 -0
- package/dist/components/IconButton/IconButton.js.map +1 -0
- package/dist/components/InlineCode/InlineCode.d.ts +46 -0
- package/dist/components/InlineCode/InlineCode.js +71 -0
- package/dist/components/InlineCode/InlineCode.js.map +1 -0
- package/dist/components/KpiCard/KpiCard.d.ts +38 -0
- package/dist/components/KpiCard/KpiCard.js +116 -0
- package/dist/components/KpiCard/KpiCard.js.map +1 -0
- package/dist/components/LayerGraph/LayerGraph.d.ts +117 -0
- package/dist/components/LayerGraph/LayerGraph.js +1644 -0
- package/dist/components/LayerGraph/LayerGraph.js.map +1 -0
- package/dist/components/LineChart/LineChart.d.ts +73 -0
- package/dist/components/LineChart/LineChart.js +337 -0
- package/dist/components/LineChart/LineChart.js.map +1 -0
- package/dist/components/LoadingBar/LoadingBar.d.ts +7 -0
- package/dist/components/LoadingBar/LoadingBar.js +18 -0
- package/dist/components/LoadingBar/LoadingBar.js.map +1 -0
- package/dist/components/LoginCard/LoginCard.d.ts +23 -0
- package/dist/components/LoginCard/LoginCard.js +113 -0
- package/dist/components/LoginCard/LoginCard.js.map +1 -0
- package/dist/components/Markdown/Markdown.d.ts +38 -0
- package/dist/components/Markdown/Markdown.js +716 -0
- package/dist/components/Markdown/Markdown.js.map +1 -0
- package/dist/components/Menu/Menu.d.ts +33 -0
- package/dist/components/Menu/Menu.js +75 -0
- package/dist/components/Menu/Menu.js.map +1 -0
- package/dist/components/Meter/Meter.d.ts +20 -0
- package/dist/components/Meter/Meter.js +120 -0
- package/dist/components/Meter/Meter.js.map +1 -0
- package/dist/components/MobileTabBar/MobileTabBar.d.ts +21 -0
- package/dist/components/MobileTabBar/MobileTabBar.js +47 -0
- package/dist/components/MobileTabBar/MobileTabBar.js.map +1 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts +25 -0
- package/dist/components/MultiSelect/MultiSelect.js +116 -0
- package/dist/components/MultiSelect/MultiSelect.js.map +1 -0
- package/dist/components/NotificationBell/NotificationBell.d.ts +20 -0
- package/dist/components/NotificationBell/NotificationBell.js +92 -0
- package/dist/components/NotificationBell/NotificationBell.js.map +1 -0
- package/dist/components/Popover/Popover.d.ts +20 -0
- package/dist/components/Popover/Popover.js +48 -0
- package/dist/components/Popover/Popover.js.map +1 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +10 -0
- package/dist/components/ProgressBar/ProgressBar.js +38 -0
- package/dist/components/ProgressBar/ProgressBar.js.map +1 -0
- package/dist/components/ProgressRing/ProgressRing.d.ts +11 -0
- package/dist/components/ProgressRing/ProgressRing.js +53 -0
- package/dist/components/ProgressRing/ProgressRing.js.map +1 -0
- package/dist/components/ProjectSwitcher/ProjectSwitcher.d.ts +25 -0
- package/dist/components/ProjectSwitcher/ProjectSwitcher.js +97 -0
- package/dist/components/ProjectSwitcher/ProjectSwitcher.js.map +1 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +18 -0
- package/dist/components/RadioGroup/RadioGroup.js +63 -0
- package/dist/components/RadioGroup/RadioGroup.js.map +1 -0
- package/dist/components/SearchField/SearchField.d.ts +9 -0
- package/dist/components/SearchField/SearchField.js +46 -0
- package/dist/components/SearchField/SearchField.js.map +1 -0
- package/dist/components/Section/Section.d.ts +50 -0
- package/dist/components/Section/Section.js +220 -0
- package/dist/components/Section/Section.js.map +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +23 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +86 -0
- package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -0
- package/dist/components/Select/Select.d.ts +31 -0
- package/dist/components/Select/Select.js +138 -0
- package/dist/components/Select/Select.js.map +1 -0
- package/dist/components/SettingsLayout/SettingsLayout.d.ts +27 -0
- package/dist/components/SettingsLayout/SettingsLayout.js +69 -0
- package/dist/components/SettingsLayout/SettingsLayout.js.map +1 -0
- package/dist/components/SideNav/SideNav.d.ts +48 -0
- package/dist/components/SideNav/SideNav.js +220 -0
- package/dist/components/SideNav/SideNav.js.map +1 -0
- package/dist/components/Skeleton/Skeleton.d.ts +8 -0
- package/dist/components/Skeleton/Skeleton.js +17 -0
- package/dist/components/Skeleton/Skeleton.js.map +1 -0
- package/dist/components/SplitPane/SplitPane.d.ts +23 -0
- package/dist/components/SplitPane/SplitPane.js +140 -0
- package/dist/components/SplitPane/SplitPane.js.map +1 -0
- package/dist/components/StatusBand/StatusBand.d.ts +31 -0
- package/dist/components/StatusBand/StatusBand.js +43 -0
- package/dist/components/StatusBand/StatusBand.js.map +1 -0
- package/dist/components/Suggestion/Suggestion.d.ts +22 -0
- package/dist/components/Suggestion/Suggestion.js +72 -0
- package/dist/components/Suggestion/Suggestion.js.map +1 -0
- package/dist/components/Switch/Switch.d.ts +11 -0
- package/dist/components/Switch/Switch.js +56 -0
- package/dist/components/Switch/Switch.js.map +1 -0
- package/dist/components/Tabs/Tabs.d.ts +23 -0
- package/dist/components/Tabs/Tabs.js +117 -0
- package/dist/components/Tabs/Tabs.js.map +1 -0
- package/dist/components/Tag/Tag.d.ts +13 -0
- package/dist/components/Tag/Tag.js +22 -0
- package/dist/components/Tag/Tag.js.map +1 -0
- package/dist/components/Term/Term.d.ts +34 -0
- package/dist/components/Term/Term.js +138 -0
- package/dist/components/Term/Term.js.map +1 -0
- package/dist/components/TextArea/TextArea.d.ts +15 -0
- package/dist/components/TextArea/TextArea.js +75 -0
- package/dist/components/TextArea/TextArea.js.map +1 -0
- package/dist/components/TextField/TextField.d.ts +15 -0
- package/dist/components/TextField/TextField.js +43 -0
- package/dist/components/TextField/TextField.js.map +1 -0
- package/dist/components/ThemePicker/ThemePicker.d.ts +13 -0
- package/dist/components/ThemePicker/ThemePicker.js +66 -0
- package/dist/components/ThemePicker/ThemePicker.js.map +1 -0
- package/dist/components/TimeControl/TimeControl.d.ts +19 -0
- package/dist/components/TimeControl/TimeControl.js +47 -0
- package/dist/components/TimeControl/TimeControl.js.map +1 -0
- package/dist/components/Toast/Toast.d.ts +10 -0
- package/dist/components/Toast/Toast.js +27 -0
- package/dist/components/Toast/Toast.js.map +1 -0
- package/dist/components/Tooltip/Tooltip.d.ts +17 -0
- package/dist/components/Tooltip/Tooltip.js +69 -0
- package/dist/components/Tooltip/Tooltip.js.map +1 -0
- package/dist/components/TopBar/TopBar.d.ts +18 -0
- package/dist/components/TopBar/TopBar.js +55 -0
- package/dist/components/TopBar/TopBar.js.map +1 -0
- package/dist/components/Tour/Tour.d.ts +44 -0
- package/dist/components/Tour/Tour.js +440 -0
- package/dist/components/Tour/Tour.js.map +1 -0
- package/dist/components/TreeList/TreeList.d.ts +90 -0
- package/dist/components/TreeList/TreeList.js +588 -0
- package/dist/components/TreeList/TreeList.js.map +1 -0
- package/dist/components/TreeList/helpers.d.ts +2 -0
- package/dist/components/TreeList/helpers.js +104 -0
- package/dist/components/TreeList/helpers.js.map +1 -0
- package/dist/components/Workbench/Workbench.d.ts +100 -0
- package/dist/components/Workbench/Workbench.js +1137 -0
- package/dist/components/Workbench/Workbench.js.map +1 -0
- package/dist/components/ZoneMap/ZoneMap.d.ts +49 -0
- package/dist/components/ZoneMap/ZoneMap.js +89 -0
- package/dist/components/ZoneMap/ZoneMap.js.map +1 -0
- package/dist/css/AccentPicker.css +49 -0
- package/dist/css/ActionBar.css +36 -0
- package/dist/css/AiMark.css +14 -0
- package/dist/css/Alert.css +80 -0
- package/dist/css/AppShell.css +81 -0
- package/dist/css/Badge.css +68 -0
- package/dist/css/BarChart.css +66 -0
- package/dist/css/Breadcrumb.css +33 -0
- package/dist/css/Button.css +190 -0
- package/dist/css/Calendar.css +96 -0
- package/dist/css/Card.css +70 -0
- package/dist/css/Checkbox.css +38 -0
- package/dist/css/CodeView.css +302 -0
- package/dist/css/CommandPalette.css +232 -0
- package/dist/css/ConsoleLayout.css +131 -0
- package/dist/css/DangerZone.css +32 -0
- package/dist/css/DataTable.css +1195 -0
- package/dist/css/DatePicker.css +38 -0
- package/dist/css/DateRangePicker.css +70 -0
- package/dist/css/DetailList.css +69 -0
- package/dist/css/Dialog.css +3 -0
- package/dist/css/Drawer.css +90 -0
- package/dist/css/EmptyState.css +61 -0
- package/dist/css/ErrorPage.css +40 -0
- package/dist/css/EventTimeline.css +43 -0
- package/dist/css/FileUpload.css +92 -0
- package/dist/css/FormGrid.css +17 -0
- package/dist/css/Graph.css +99 -0
- package/dist/css/Grid.css +48 -0
- package/dist/css/IconButton.css +149 -0
- package/dist/css/InlineCode.css +92 -0
- package/dist/css/KpiCard.css +121 -0
- package/dist/css/LayerGraph.css +575 -0
- package/dist/css/LineChart.css +3 -0
- package/dist/css/LoadingBar.css +45 -0
- package/dist/css/LoginCard.css +65 -0
- package/dist/css/Markdown.css +266 -0
- package/dist/css/Menu.css +88 -0
- package/dist/css/Meter.css +110 -0
- package/dist/css/MobileTabBar.css +63 -0
- package/dist/css/MultiSelect.css +78 -0
- package/dist/css/NotificationBell.css +129 -0
- package/dist/css/Popover.css +57 -0
- package/dist/css/ProgressBar.css +42 -0
- package/dist/css/ProgressRing.css +19 -0
- package/dist/css/ProjectSwitcher.css +153 -0
- package/dist/css/RadioGroup.css +52 -0
- package/dist/css/SearchField.css +79 -0
- package/dist/css/Section.css +115 -0
- package/dist/css/SegmentedControl.css +67 -0
- package/dist/css/Select.css +136 -0
- package/dist/css/SettingsLayout.css +110 -0
- package/dist/css/SideNav.css +281 -0
- package/dist/css/Skeleton.css +19 -0
- package/dist/css/SplitPane.css +108 -0
- package/dist/css/StatusBand.css +23 -0
- package/dist/css/Suggestion.css +82 -0
- package/dist/css/Switch.css +46 -0
- package/dist/css/Tabs.css +91 -0
- package/dist/css/Tag.css +36 -0
- package/dist/css/Term.css +160 -0
- package/dist/css/TextArea.css +22 -0
- package/dist/css/TextField.css +2 -0
- package/dist/css/ThemePicker.css +70 -0
- package/dist/css/TimeControl.css +33 -0
- package/dist/css/Toast.css +47 -0
- package/dist/css/Tooltip.css +58 -0
- package/dist/css/TopBar.css +86 -0
- package/dist/css/Tour.css +90 -0
- package/dist/css/TreeList.css +532 -0
- package/dist/css/Workbench.css +652 -0
- package/dist/css/ZoneMap.css +203 -0
- package/dist/css/base.css +556 -0
- package/dist/css/end.css +273 -0
- package/dist/format-entry.d.ts +3 -0
- package/dist/format-entry.js +3 -0
- package/dist/format.d.ts +68 -2
- package/dist/format.js +237 -1
- package/dist/format.js.map +1 -0
- package/dist/i18n.d.ts +11 -0
- package/dist/{format-entry-C7iBqN3J.js → i18n.js} +10 -225
- package/dist/i18n.js.map +1 -0
- package/dist/icons/Icon.d.ts +23 -0
- package/dist/icons/Icon.js +90 -0
- package/dist/icons/Icon.js.map +1 -0
- package/dist/icons/data.d.ts +150 -0
- package/dist/icons/data.js +256 -0
- package/dist/icons/data.js.map +1 -0
- package/dist/index.d.ts +84 -2258
- package/dist/index.js +79 -12715
- package/dist/internal/Field.js +71 -0
- package/dist/internal/Field.js.map +1 -0
- package/dist/internal/FloatingPanel.js +41 -0
- package/dist/internal/FloatingPanel.js.map +1 -0
- package/dist/internal/chart.js +131 -0
- package/dist/internal/chart.js.map +1 -0
- package/dist/internal/dev.js +21 -0
- package/dist/internal/dev.js.map +1 -0
- package/dist/internal/focus.js +94 -0
- package/dist/internal/focus.js.map +1 -0
- package/dist/internal/focusMain.d.ts +4 -0
- package/dist/internal/focusMain.js +22 -0
- package/dist/internal/focusMain.js.map +1 -0
- package/dist/internal/scrollHint.js +75 -0
- package/dist/internal/scrollHint.js.map +1 -0
- package/dist/internal/tableTools.js +109 -0
- package/dist/internal/tableTools.js.map +1 -0
- package/dist/internal/terms.d.ts +18 -0
- package/dist/internal/terms.js +64 -0
- package/dist/internal/terms.js.map +1 -0
- package/dist/internal/util.js +107 -0
- package/dist/internal/util.js.map +1 -0
- package/dist/motion.d.ts +5 -0
- package/dist/motion.js +29 -0
- package/dist/motion.js.map +1 -0
- package/dist/styles.css +4419 -4195
- package/dist/theme.d.ts +20 -0
- package/dist/theme.js +210 -0
- package/dist/theme.js.map +1 -0
- package/dist/tokens.css +78 -19
- package/docs/AccentPicker.md +17 -2
- package/docs/ActionBar.md +6 -4
- package/docs/AiMark.md +12 -6
- package/docs/Alert.md +17 -5
- package/docs/AppShell.md +20 -11
- package/docs/Badge.md +20 -9
- package/docs/BarChart.md +21 -3
- package/docs/Breadcrumb.md +9 -4
- package/docs/Button.md +18 -8
- package/docs/Calendar.md +10 -5
- package/docs/Card.md +17 -9
- package/docs/Checkbox.md +15 -4
- package/docs/CodeView.md +16 -13
- package/docs/CommandPalette.md +18 -10
- package/docs/ConsoleLayout.md +24 -2
- package/docs/DangerZone.md +9 -3
- package/docs/DataColors.md +11 -4
- package/docs/DataTable.md +77 -28
- package/docs/DatePicker.md +16 -2
- package/docs/DateRangePicker.md +13 -1
- package/docs/DetailList.md +17 -12
- package/docs/Dialog.md +11 -6
- package/docs/Drawer.md +13 -7
- package/docs/EmptyState.md +13 -1
- package/docs/ErrorPage.md +6 -0
- package/docs/EventTimeline.md +11 -5
- package/docs/FileUpload.md +21 -5
- package/docs/FormGrid.md +11 -2
- package/docs/Format.md +19 -1
- package/docs/Graph.md +17 -2
- package/docs/Grid.md +13 -4
- package/docs/IconButton.md +16 -13
- package/docs/InlineCode.md +18 -8
- package/docs/KpiCard.md +21 -7
- package/docs/LayerGraph.md +36 -23
- package/docs/LineChart.md +22 -1
- package/docs/LoadingBar.md +7 -1
- package/docs/LoginCard.md +19 -3
- package/docs/Markdown.md +18 -2
- package/docs/Menu.md +13 -7
- package/docs/Meter.md +12 -5
- package/docs/MobileTabBar.md +18 -2
- package/docs/MultiSelect.md +13 -3
- package/docs/NotificationBell.md +13 -3
- package/docs/Popover.md +12 -2
- package/docs/ProgressBar.md +8 -2
- package/docs/ProgressRing.md +8 -2
- package/docs/ProjectSwitcher.md +15 -9
- package/docs/RadioGroup.md +21 -3
- package/docs/SearchField.md +8 -2
- package/docs/Section.md +16 -4
- package/docs/SegmentedControl.md +21 -19
- package/docs/Select.md +16 -1
- package/docs/SettingsLayout.md +19 -4
- package/docs/SideNav.md +20 -2
- package/docs/Skeleton.md +7 -1
- package/docs/SplitPane.md +7 -1
- package/docs/StatusBand.md +12 -6
- package/docs/Suggestion.md +12 -5
- package/docs/Switch.md +15 -2
- package/docs/Tabs.md +25 -6
- package/docs/Tag.md +16 -12
- package/docs/Term.md +18 -1
- package/docs/TextArea.md +12 -1
- package/docs/TextField.md +15 -5
- package/docs/ThemePicker.md +16 -4
- package/docs/TimeControl.md +10 -5
- package/docs/Toast.md +13 -3
- package/docs/Tooltip.md +17 -5
- package/docs/TopBar.md +16 -3
- package/docs/Tour.md +25 -1
- package/docs/TreeList.md +16 -9
- package/docs/Workbench.md +12 -6
- package/docs/ZoneMap.md +17 -10
- package/docs/code.md +28 -0
- package/docs/data.md +45 -0
- package/docs/forms.md +29 -0
- package/docs/guidelines.md +65 -315
- package/docs/layout.md +24 -4
- package/docs/monitoring.md +30 -0
- package/docs/motion.md +1 -1
- package/docs/theme.md +153 -0
- package/package.json +6 -5
- package/dist/format-entry-BJI8MU2K.d.ts +0 -75
- package/dist/format-entry-C7iBqN3J.js.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,1267 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Button } from "../Button/Button.js";
|
|
3
|
+
import { SearchField } from "../SearchField/SearchField.js";
|
|
4
|
+
import { Tabs } from "../Tabs/Tabs.js";
|
|
5
|
+
import { format } from "../../format.js";
|
|
6
|
+
import { tr, unitFor } from "../../i18n.js";
|
|
7
|
+
import { Icon } from "../../icons/Icon.js";
|
|
8
|
+
import { TOUCH_ONLY, copyText, cx, idPart, monoNums, reduced, seenOnly, useMedia, useNarrow } from "../../internal/util.js";
|
|
9
|
+
import { Tooltip } from "../Tooltip/Tooltip.js";
|
|
10
|
+
import { devWarn } from "../../internal/dev.js";
|
|
11
|
+
import { CheckMark } from "../../internal/Field.js";
|
|
12
|
+
import { announce } from "../../announce.js";
|
|
13
|
+
import { ScrollHint, useScrollHint } from "../../internal/scrollHint.js";
|
|
14
|
+
import { ColResize, TableDialog, markdownTable } from "../../internal/tableTools.js";
|
|
15
|
+
import { asDate, cellText, isActive, isDateCol, matches, readSort, readUrl, resolveFilters, searchHit, writeSort, writeUrl } from "./filters.js";
|
|
16
|
+
import { FilterButton, FilterChips, FullText, LongText, MoreMenu, markMatch } from "./parts.js";
|
|
17
|
+
import { SortButton, dirWord, sortSentence } from "./SortButton.js";
|
|
18
|
+
import * as React from "react";
|
|
19
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
+
import { createPortal } from "react-dom";
|
|
21
|
+
// src/components/DataTable/DataTable.tsx
|
|
22
|
+
const MOVE = {
|
|
23
|
+
dur: 320,
|
|
24
|
+
stagger: 25,
|
|
25
|
+
ease: "cubic-bezier(.2,.8,.2,1)"
|
|
26
|
+
};
|
|
27
|
+
const ARROWS = {
|
|
28
|
+
asc: "M12 19V5M6 11l6-6 6 6",
|
|
29
|
+
desc: "M12 5v14M6 13l6 6 6-6",
|
|
30
|
+
none: "M8 9l4-4 4 4M8 15l4 4 4-4"
|
|
31
|
+
};
|
|
32
|
+
const get = (row, key) => row[key];
|
|
33
|
+
const isNum = (c) => c.numeric || c.format === "money" || c.format === "percent" || c.format === "duration";
|
|
34
|
+
const isShort = (c) => isNum(c) || !!c.unit || isDateCol(c) || c.mobile === "status";
|
|
35
|
+
const TEXT_HUG_MAX = 280;
|
|
36
|
+
const HUG_START = 96;
|
|
37
|
+
const CELL_PAD = 25;
|
|
38
|
+
const isoOf = (d, dateOnly) => dateOnly ? `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}` : d.toISOString();
|
|
39
|
+
/** The width of what an element holds (its text and children, not absolutely placed parts such as the column border). */
|
|
40
|
+
function contentWidth(el) {
|
|
41
|
+
let left = Infinity;
|
|
42
|
+
let right = -Infinity;
|
|
43
|
+
const range = document.createRange();
|
|
44
|
+
for (const n of el.childNodes) {
|
|
45
|
+
let r = null;
|
|
46
|
+
if (n instanceof HTMLElement) {
|
|
47
|
+
if (n.classList.contains("ui-col-resize") || getComputedStyle(n).position === "absolute") continue;
|
|
48
|
+
r = n.getBoundingClientRect();
|
|
49
|
+
} else if (n.nodeType === Node.TEXT_NODE && n.textContent?.trim()) {
|
|
50
|
+
range.selectNodeContents(n);
|
|
51
|
+
r = range.getBoundingClientRect();
|
|
52
|
+
}
|
|
53
|
+
if (r && r.width) {
|
|
54
|
+
left = Math.min(left, r.left);
|
|
55
|
+
right = Math.max(right, r.right);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return right > left ? right - left : 0;
|
|
59
|
+
}
|
|
60
|
+
const shortcutTables = /* @__PURE__ */ new Set();
|
|
61
|
+
const shortcutListeners = /* @__PURE__ */ new Set();
|
|
62
|
+
let shortcutSizes = null;
|
|
63
|
+
const notifyShortcut = () => shortcutListeners.forEach((f) => f());
|
|
64
|
+
/** Rendered and not hidden: not display: none (itself or an ancestor), not visibility: hidden, not inert or aria-hidden. */
|
|
65
|
+
function isShown(el) {
|
|
66
|
+
if (!el.isConnected || el.closest("[inert], [aria-hidden=\"true\"]")) return false;
|
|
67
|
+
const check = el.checkVisibility;
|
|
68
|
+
if (typeof check === "function") return check.call(el, {
|
|
69
|
+
checkVisibilityCSS: true,
|
|
70
|
+
visibilityProperty: true
|
|
71
|
+
});
|
|
72
|
+
return el.getClientRects().length > 0 && getComputedStyle(el).visibility !== "hidden";
|
|
73
|
+
}
|
|
74
|
+
const shortcutInput = (el) => el.querySelector(":scope > .ui-dt-tools .ui-dt-search input");
|
|
75
|
+
const firstShortcutTable = () => [...shortcutTables].filter((el) => isShown(el) && !!shortcutInput(el)).sort((a, b) => a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1)[0] ?? null;
|
|
76
|
+
const SLASH_OWNERS = "input, textarea, select, [contenteditable]:not([contenteditable=\"false\"]), [role=\"textbox\"], [role=\"searchbox\"], [role=\"combobox\"], [role=\"listbox\"], [role=\"grid\"], [role=\"treegrid\"], [role=\"tree\"], [role=\"menu\"], [role=\"menubar\"], [role=\"dialog\"], [role=\"alertdialog\"], dialog";
|
|
77
|
+
function onSlash(e) {
|
|
78
|
+
if (e.key !== "/" || e.ctrlKey || e.metaKey || e.altKey || e.defaultPrevented || e.isComposing) return;
|
|
79
|
+
if ((e.target instanceof Element ? e.target : null)?.closest(SLASH_OWNERS)) return;
|
|
80
|
+
const table = firstShortcutTable();
|
|
81
|
+
const input = table ? shortcutInput(table) : null;
|
|
82
|
+
if (!input) return;
|
|
83
|
+
input.focus();
|
|
84
|
+
if (document.activeElement === input) e.preventDefault();
|
|
85
|
+
}
|
|
86
|
+
function registerShortcut(el, changed) {
|
|
87
|
+
if (!shortcutTables.size) document.addEventListener("keydown", onSlash);
|
|
88
|
+
if (!shortcutSizes && typeof ResizeObserver !== "undefined") shortcutSizes = new ResizeObserver(notifyShortcut);
|
|
89
|
+
shortcutTables.add(el);
|
|
90
|
+
shortcutListeners.add(changed);
|
|
91
|
+
shortcutSizes?.observe(el);
|
|
92
|
+
notifyShortcut();
|
|
93
|
+
return () => {
|
|
94
|
+
shortcutTables.delete(el);
|
|
95
|
+
shortcutListeners.delete(changed);
|
|
96
|
+
shortcutSizes?.unobserve(el);
|
|
97
|
+
if (!shortcutTables.size) {
|
|
98
|
+
document.removeEventListener("keydown", onSlash);
|
|
99
|
+
shortcutSizes?.disconnect();
|
|
100
|
+
shortcutSizes = null;
|
|
101
|
+
}
|
|
102
|
+
notifyShortcut();
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const newTab = (e) => e.ctrlKey || e.metaKey || e.shiftKey || e.button === 1;
|
|
106
|
+
const ROW_CONTROLS = "a, button, input, select, textarea, label, [role=\"checkbox\"], [role=\"button\"], [role=\"menuitem\"], [role=\"link\"], [contenteditable]";
|
|
107
|
+
function RowCheck({ v, label, onClick }) {
|
|
108
|
+
return /* @__PURE__ */ jsx("button", {
|
|
109
|
+
type: "button",
|
|
110
|
+
role: "checkbox",
|
|
111
|
+
"aria-checked": v,
|
|
112
|
+
"aria-label": label,
|
|
113
|
+
className: cx("ui-check-box", "ui-dt-check", v && "is-on"),
|
|
114
|
+
onMouseDown: (e) => e.shiftKey && e.preventDefault(),
|
|
115
|
+
onClick: (e) => {
|
|
116
|
+
e.stopPropagation();
|
|
117
|
+
onClick(e);
|
|
118
|
+
},
|
|
119
|
+
children: /* @__PURE__ */ jsx(CheckMark, { v })
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/** The table for records: sort, search, filters, page numbers, selection with a bulk bar, row actions; cards on phones. */
|
|
123
|
+
function DataTable(p) {
|
|
124
|
+
const { columns: cols, rows, pageSize = 10, urlSync = true, urlKey, search = {}, selectable = false, stickyFirst: sticky = false } = p;
|
|
125
|
+
const filters = React.useMemo(() => {
|
|
126
|
+
const list = p.filters ? [...p.filters] : [];
|
|
127
|
+
if (p.filter && !list.length) list.push({
|
|
128
|
+
key: p.filter.key,
|
|
129
|
+
label: p.filter.label || cols.find((c) => c.key === p.filter?.key)?.label || p.filter.key,
|
|
130
|
+
options: p.filter.options
|
|
131
|
+
});
|
|
132
|
+
return resolveFilters(list, rows);
|
|
133
|
+
}, [
|
|
134
|
+
p.filters,
|
|
135
|
+
p.filter,
|
|
136
|
+
cols,
|
|
137
|
+
rows
|
|
138
|
+
]);
|
|
139
|
+
const fromUrl = () => urlSync && typeof location !== "undefined" ? readUrl(urlKey, filters) : {
|
|
140
|
+
q: "",
|
|
141
|
+
values: {}
|
|
142
|
+
};
|
|
143
|
+
const maxSort = Math.max(1, p.maxSort ?? Infinity);
|
|
144
|
+
const sortCols = cols.filter((c) => c.sortable !== false).map((c) => ({
|
|
145
|
+
key: c.key,
|
|
146
|
+
label: c.label,
|
|
147
|
+
numeric: isNum(c)
|
|
148
|
+
}));
|
|
149
|
+
const firstDir = (key) => sortCols.find((c) => c.key === key)?.numeric ? "desc" : "asc";
|
|
150
|
+
const validSort = (l) => l.filter((x, i) => sortCols.some((c) => c.key === x.key) && l.findIndex((y) => y.key === x.key) === i).slice(0, maxSort).map((x) => ({
|
|
151
|
+
key: x.key,
|
|
152
|
+
dir: x.dir ?? firstDir(x.key)
|
|
153
|
+
}));
|
|
154
|
+
const initialSort = validSort(p.defaultSort ?? []);
|
|
155
|
+
const [sort, setSort] = React.useState(() => validSort((urlSync && typeof location !== "undefined" ? readSort(urlKey) : null) ?? initialSort));
|
|
156
|
+
const [page, setPage] = React.useState(0);
|
|
157
|
+
const [q, setQ] = React.useState(() => fromUrl().q);
|
|
158
|
+
const [values, setValues] = React.useState(() => fromUrl().values);
|
|
159
|
+
const [view, setView] = React.useState(p.views?.[0]?.id ?? null);
|
|
160
|
+
const colsKey = p.widthKey ? "ui-dt-cols:" + p.widthKey : null;
|
|
161
|
+
const [toggled, setToggledState] = React.useState(() => {
|
|
162
|
+
if (!colsKey) return {};
|
|
163
|
+
try {
|
|
164
|
+
const v = JSON.parse(localStorage.getItem(colsKey) || "null");
|
|
165
|
+
return v && typeof v === "object" ? v : {};
|
|
166
|
+
} catch {
|
|
167
|
+
return {};
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
const setToggled = (t) => {
|
|
171
|
+
setToggledState(t);
|
|
172
|
+
if (!colsKey) return;
|
|
173
|
+
try {
|
|
174
|
+
if (Object.keys(t).length) localStorage.setItem(colsKey, JSON.stringify(t));
|
|
175
|
+
else localStorage.removeItem(colsKey);
|
|
176
|
+
} catch {}
|
|
177
|
+
};
|
|
178
|
+
const [opened, setOpened] = React.useState({});
|
|
179
|
+
const narrow = useNarrow();
|
|
180
|
+
const touch = useMedia(TOUCH_ONLY);
|
|
181
|
+
const uid = React.useId();
|
|
182
|
+
const rootRef = React.useRef(null);
|
|
183
|
+
const [sel, setSel] = React.useState({});
|
|
184
|
+
const [sumVal, setSumVal] = React.useState("all");
|
|
185
|
+
const [fit, setFit] = React.useState({});
|
|
186
|
+
const [widths, setWidthsState] = React.useState(() => {
|
|
187
|
+
if (!p.widthKey) return null;
|
|
188
|
+
try {
|
|
189
|
+
const v = JSON.parse(localStorage.getItem("ui-dt-width:" + p.widthKey) || "null");
|
|
190
|
+
return v && typeof v === "object" ? v : null;
|
|
191
|
+
} catch {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
const setWidths = (w) => {
|
|
196
|
+
setWidthsState(w);
|
|
197
|
+
if (!p.widthKey) return;
|
|
198
|
+
try {
|
|
199
|
+
if (w) localStorage.setItem("ui-dt-width:" + p.widthKey, JSON.stringify(w));
|
|
200
|
+
else localStorage.removeItem("ui-dt-width:" + p.widthKey);
|
|
201
|
+
} catch {}
|
|
202
|
+
};
|
|
203
|
+
const [zoomed, setZoomed] = React.useState(false);
|
|
204
|
+
const [zoomWidths, setZoomWidths] = React.useState(null);
|
|
205
|
+
const zoomRef = React.useRef(null);
|
|
206
|
+
const [headSlot, setHeadSlot] = React.useState(null);
|
|
207
|
+
const noSearch = search === false && !p.caption;
|
|
208
|
+
React.useLayoutEffect(() => {
|
|
209
|
+
const prev = noSearch ? rootRef.current?.previousElementSibling : null;
|
|
210
|
+
setHeadSlot(prev instanceof HTMLElement && prev.classList.contains("ui-card-head") && prev.parentElement?.classList.contains("ui-card") ? prev : null);
|
|
211
|
+
}, [noSearch]);
|
|
212
|
+
const [resetKey, setResetKey] = React.useState(p.resetKey);
|
|
213
|
+
const resetting = resetKey !== p.resetKey;
|
|
214
|
+
if (resetting) {
|
|
215
|
+
setResetKey(p.resetKey);
|
|
216
|
+
setQ("");
|
|
217
|
+
setValues({});
|
|
218
|
+
setPage(0);
|
|
219
|
+
setSel({});
|
|
220
|
+
setSumVal("all");
|
|
221
|
+
setSort(initialSort);
|
|
222
|
+
if (!colsKey) setToggledState({});
|
|
223
|
+
setOpened({});
|
|
224
|
+
setFit({});
|
|
225
|
+
}
|
|
226
|
+
const valuesKey = JSON.stringify(values);
|
|
227
|
+
const sortKey = JSON.stringify(sort);
|
|
228
|
+
React.useEffect(() => {
|
|
229
|
+
if (urlSync && typeof location !== "undefined") writeSort(urlKey, sort, initialSort);
|
|
230
|
+
}, [sortKey]);
|
|
231
|
+
React.useEffect(() => {
|
|
232
|
+
if (urlSync && filters.length) writeUrl(urlKey, filters, values, q);
|
|
233
|
+
}, [valuesKey, q]);
|
|
234
|
+
devWarn(cols.some((c) => c.format === "percent" && !c.unit), "DataTable", "format: 'percent' sets 1 decimal and shows no % sign; add unit: '%' to that column.");
|
|
235
|
+
devWarn(rows.length > 1 && rows.every((r) => get(r, "id") == null) && selectable, "DataTable", "rows have no id, so a selection follows the position, not the row. Add an id to each row.");
|
|
236
|
+
devWarn(!!cols[0]?.hidden, "DataTable", "the first column is always shown, so its hidden: true does nothing. Move the column, or drop hidden.");
|
|
237
|
+
devWarn((p.columnMenu === false || cols.length <= 2) && cols.some((c, i) => i > 0 && c.hidden), "DataTable", "a column has hidden: true but there is no 「欄位」 menu (columnMenu is false, or the table has 2 columns or fewer), so nobody can turn it on. Turn the menu on, or leave the column out.");
|
|
238
|
+
const sumKey = p.summary?.key;
|
|
239
|
+
const twiceFilter = sumKey ? filters.find((f) => f.key === sumKey) : void 0;
|
|
240
|
+
devWarn(twiceFilter, "DataTable", `the filter 「${twiceFilter?.label}」 filters ${String(sumKey)}, which the summary tabs already filter, so the same condition is in two places. Drop it from filters (or drop summary).`);
|
|
241
|
+
const twiceView = sumKey && rows.length ? p.views?.find((v) => {
|
|
242
|
+
if (!v.filter) return false;
|
|
243
|
+
const kept = rows.filter((r) => v.filter?.(r));
|
|
244
|
+
if (!kept.length || kept.length === rows.length) return false;
|
|
245
|
+
const val = String(get(kept[0], sumKey));
|
|
246
|
+
return kept.every((r) => String(get(r, sumKey)) === val) && rows.filter((r) => String(get(r, sumKey)) === val).length === kept.length;
|
|
247
|
+
}) : void 0;
|
|
248
|
+
devWarn(twiceView, "DataTable", `the view 「${twiceView?.label}」 keeps exactly the rows of one ${String(sumKey)} value, which a summary tab already picks, so the same condition is in two places. Drop the view (or drop summary).`);
|
|
249
|
+
for (const c of cols) {
|
|
250
|
+
if (!c.unit && !c.numeric) continue;
|
|
251
|
+
const bad = rows.map((r) => get(r, c.key)).find((v) => typeof v === "string" && /\d/.test(v) && (c.unit ? v.includes(c.unit) : !/^\s*-?[\d,]*\.?\d+\s*$/.test(v)));
|
|
252
|
+
devWarn(bad !== void 0, "DataTable", `column 「${c.label}」 got the string 「${String(bad)}」. Pass a number${c.unit ? "" : " and the unit in unit"} (e.g. { numeric: true, unit: '${c.unit || "字"}' } with 1234), so it is formatted, right-aligned and sorted as a number.`);
|
|
253
|
+
}
|
|
254
|
+
const hidden = {};
|
|
255
|
+
cols.forEach((c, i) => hidden[c.key] = i > 0 && (toggled[c.key] ?? !!c.hidden));
|
|
256
|
+
const shownCols = cols.filter((c) => !hidden[c.key]);
|
|
257
|
+
const { ref: scrollRef, more: scrollMore, overflows, scrolled, onScroll } = useScrollHint();
|
|
258
|
+
const bodyRef = React.useRef(null);
|
|
259
|
+
const rowEls = React.useRef({});
|
|
260
|
+
const snap = React.useRef(null);
|
|
261
|
+
let all = rows.map((r, i) => ({
|
|
262
|
+
r,
|
|
263
|
+
i
|
|
264
|
+
}));
|
|
265
|
+
const viewObj = p.views?.find((v) => v.id === view);
|
|
266
|
+
if (viewObj?.filter) all = all.filter((x) => viewObj.filter?.(x.r));
|
|
267
|
+
const sumAll = all;
|
|
268
|
+
const summary = p.summary;
|
|
269
|
+
if (summary && sumVal !== "all") all = all.filter((x) => String(get(x.r, summary.key)) === sumVal);
|
|
270
|
+
const baseCount = all.length;
|
|
271
|
+
const searching = search !== false && !!q;
|
|
272
|
+
const passes = (r, skip) => (!searching || searchHit(r, cols, filters, q, search ? search.keys : void 0)) && filters.every((f) => f.key === skip || matches(f, r, values[f.key]));
|
|
273
|
+
let list = all.filter((x) => passes(x.r));
|
|
274
|
+
const activeN = filters.filter((f) => isActive(values[f.key])).length;
|
|
275
|
+
if (sort.length) {
|
|
276
|
+
const by = sort.map((l) => {
|
|
277
|
+
const col = cols.find((c) => c.key === l.key);
|
|
278
|
+
const val = (r) => {
|
|
279
|
+
if (col?.sortValue) return col.sortValue(r);
|
|
280
|
+
const v = get(r, l.key);
|
|
281
|
+
if (v instanceof Date || col && isDateCol(col)) return asDate(v)?.getTime() ?? -Infinity;
|
|
282
|
+
return v;
|
|
283
|
+
};
|
|
284
|
+
return {
|
|
285
|
+
val,
|
|
286
|
+
d: l.dir === "asc" ? 1 : -1
|
|
287
|
+
};
|
|
288
|
+
});
|
|
289
|
+
list = [...list].sort((a, b) => {
|
|
290
|
+
for (const { val, d } of by) {
|
|
291
|
+
const x = val(a.r);
|
|
292
|
+
const y = val(b.r);
|
|
293
|
+
const c = typeof x === "number" && typeof y === "number" ? x - y : String(x).localeCompare(String(y), "zh-Hant");
|
|
294
|
+
if (c) return c * d;
|
|
295
|
+
}
|
|
296
|
+
return a.i - b.i;
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
const shownKey = `${q}|${valuesKey}|${sumVal}|${view}`;
|
|
300
|
+
const firstKey = React.useRef(shownKey);
|
|
301
|
+
const shownN = list.length;
|
|
302
|
+
React.useEffect(() => {
|
|
303
|
+
if (shownKey === firstKey.current) return;
|
|
304
|
+
firstKey.current = "";
|
|
305
|
+
const t = setTimeout(() => announce(tr("顯示 {n} 筆", { n: format.number(shownN) })), 400);
|
|
306
|
+
return () => clearTimeout(t);
|
|
307
|
+
}, [shownKey, shownN]);
|
|
308
|
+
const pages = Math.max(1, Math.ceil(list.length / pageSize));
|
|
309
|
+
const pageNow = Math.min(page, pages - 1);
|
|
310
|
+
const start = pageNow * pageSize;
|
|
311
|
+
const vis = list.slice(start, start + pageSize);
|
|
312
|
+
const idOf = (x) => {
|
|
313
|
+
const id = get(x.r, "id");
|
|
314
|
+
return id != null ? String(id) : String(x.i);
|
|
315
|
+
};
|
|
316
|
+
const present = new Set(list.map(idOf));
|
|
317
|
+
const selIds = Object.keys(sel).filter((k) => sel[k] && present.has(k));
|
|
318
|
+
if (!resetting && Object.keys(sel).some((k) => sel[k] && !present.has(k))) setSel(Object.fromEntries(selIds.map((k) => [k, true])));
|
|
319
|
+
const visIds = vis.map(idOf);
|
|
320
|
+
const selVis = visIds.filter((id) => sel[id]).length;
|
|
321
|
+
const allOn = visIds.length > 0 && selVis === visIds.length;
|
|
322
|
+
const mixed = selVis > 0 && !allOn;
|
|
323
|
+
const capture = (kind) => {
|
|
324
|
+
const body = bodyRef.current;
|
|
325
|
+
if (!body) return;
|
|
326
|
+
const top0 = body.getBoundingClientRect().top;
|
|
327
|
+
const snapRows = {};
|
|
328
|
+
const order = [];
|
|
329
|
+
for (const id of visIds) {
|
|
330
|
+
const el = rowEls.current[id];
|
|
331
|
+
if (!el) continue;
|
|
332
|
+
snapRows[id] = {
|
|
333
|
+
top: el.getBoundingClientRect().top - top0,
|
|
334
|
+
bg: getComputedStyle(el).backgroundColor,
|
|
335
|
+
node: el
|
|
336
|
+
};
|
|
337
|
+
order.push(id);
|
|
338
|
+
}
|
|
339
|
+
snap.current = {
|
|
340
|
+
kind,
|
|
341
|
+
rows: snapRows,
|
|
342
|
+
order
|
|
343
|
+
};
|
|
344
|
+
};
|
|
345
|
+
React.useLayoutEffect(() => {
|
|
346
|
+
const sn = snap.current;
|
|
347
|
+
snap.current = null;
|
|
348
|
+
const body = bodyRef.current;
|
|
349
|
+
if (!sn || !body || reduced() || typeof Element.prototype.animate !== "function") return;
|
|
350
|
+
const top0 = body.getBoundingClientRect().top;
|
|
351
|
+
const n = Math.max(sn.order.length, visIds.length);
|
|
352
|
+
let k = 0;
|
|
353
|
+
let rh = 48;
|
|
354
|
+
visIds.forEach((id, i) => {
|
|
355
|
+
const el = rowEls.current[id];
|
|
356
|
+
if (!el) return;
|
|
357
|
+
const r = el.getBoundingClientRect();
|
|
358
|
+
rh = r.height || rh;
|
|
359
|
+
const old = sn.rows[id];
|
|
360
|
+
const timing = {
|
|
361
|
+
duration: MOVE.dur,
|
|
362
|
+
delay: i * MOVE.stagger,
|
|
363
|
+
easing: MOVE.ease,
|
|
364
|
+
fill: "backwards"
|
|
365
|
+
};
|
|
366
|
+
if (old) {
|
|
367
|
+
const from = old.top - (r.top - top0);
|
|
368
|
+
el.animate([{
|
|
369
|
+
transform: `translateY(${from}px)`,
|
|
370
|
+
backgroundColor: old.bg
|
|
371
|
+
}, {
|
|
372
|
+
transform: "none",
|
|
373
|
+
backgroundColor: getComputedStyle(el).backgroundColor
|
|
374
|
+
}], timing);
|
|
375
|
+
} else {
|
|
376
|
+
const off = sn.kind === "next" ? n : sn.kind === "prev" ? -n : n + k - i;
|
|
377
|
+
k++;
|
|
378
|
+
el.animate([{
|
|
379
|
+
transform: `translateY(${off * rh}px)`,
|
|
380
|
+
opacity: 0
|
|
381
|
+
}, {
|
|
382
|
+
transform: "none",
|
|
383
|
+
opacity: 1
|
|
384
|
+
}], timing);
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
sn.order.forEach((id, j) => {
|
|
388
|
+
if (visIds.includes(id)) return;
|
|
389
|
+
const o = sn.rows[id];
|
|
390
|
+
const ghost = o.node.cloneNode(true);
|
|
391
|
+
ghost.removeAttribute("data-rid");
|
|
392
|
+
ghost.setAttribute("aria-hidden", "true");
|
|
393
|
+
ghost.classList.add("ui-dt-ghost");
|
|
394
|
+
ghost.style.top = o.top + "px";
|
|
395
|
+
ghost.style.backgroundColor = o.bg;
|
|
396
|
+
body.appendChild(ghost);
|
|
397
|
+
const to = sn.kind === "next" ? -n : sn.kind === "prev" ? n : n + 1 - j;
|
|
398
|
+
ghost.animate([{
|
|
399
|
+
transform: "none",
|
|
400
|
+
opacity: 1
|
|
401
|
+
}, {
|
|
402
|
+
transform: `translateY(${to * rh}px)`,
|
|
403
|
+
opacity: 0
|
|
404
|
+
}], {
|
|
405
|
+
duration: MOVE.dur,
|
|
406
|
+
easing: MOVE.ease,
|
|
407
|
+
fill: "forwards"
|
|
408
|
+
}).onfinish = () => ghost.remove();
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
const changeSort = (next) => {
|
|
412
|
+
capture("sort");
|
|
413
|
+
setSort(next);
|
|
414
|
+
announce(sortSentence(next, sortCols));
|
|
415
|
+
};
|
|
416
|
+
const sortBy = (c, add = false) => {
|
|
417
|
+
if (c.sortable === false) return;
|
|
418
|
+
const first = firstDir(c.key);
|
|
419
|
+
const flip = first === "asc" ? "desc" : "asc";
|
|
420
|
+
const i = sort.findIndex((l) => l.key === c.key);
|
|
421
|
+
if (add) {
|
|
422
|
+
if (i < 0) {
|
|
423
|
+
if (sort.length < maxSort) changeSort([...sort, {
|
|
424
|
+
key: c.key,
|
|
425
|
+
dir: first
|
|
426
|
+
}]);
|
|
427
|
+
else announce(tr("最多 {n} 層排序。", { n: maxSort }));
|
|
428
|
+
} else if (sort[i].dir === first) changeSort(sort.map((l, j) => j === i ? {
|
|
429
|
+
key: l.key,
|
|
430
|
+
dir: flip
|
|
431
|
+
} : l));
|
|
432
|
+
else changeSort(sort.filter((_, j) => j !== i));
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
if (sort.length !== 1 || i !== 0) changeSort([{
|
|
436
|
+
key: c.key,
|
|
437
|
+
dir: first
|
|
438
|
+
}]);
|
|
439
|
+
else if (sort[0].dir === first) changeSort([{
|
|
440
|
+
key: c.key,
|
|
441
|
+
dir: flip
|
|
442
|
+
}]);
|
|
443
|
+
else changeSort([]);
|
|
444
|
+
};
|
|
445
|
+
const goPage = (n) => {
|
|
446
|
+
if (n === pageNow || n < 0 || n >= pages) return;
|
|
447
|
+
capture(n > pageNow ? "next" : "prev");
|
|
448
|
+
setPage(n);
|
|
449
|
+
};
|
|
450
|
+
const toggle = (ids, v) => setSel({
|
|
451
|
+
...sel,
|
|
452
|
+
...Object.fromEntries(ids.map((id) => [id, v]))
|
|
453
|
+
});
|
|
454
|
+
const clear = () => setSel({});
|
|
455
|
+
const lastPick = React.useRef(null);
|
|
456
|
+
const anchorKey = `${shownKey}|${sortKey}|${pageSize}`;
|
|
457
|
+
React.useEffect(() => {
|
|
458
|
+
lastPick.current = null;
|
|
459
|
+
}, [anchorKey]);
|
|
460
|
+
const pickRow = (id, on, shift) => {
|
|
461
|
+
const ids = list.map(idOf);
|
|
462
|
+
const from = shift && lastPick.current ? ids.indexOf(lastPick.current) : -1;
|
|
463
|
+
const to = ids.indexOf(id);
|
|
464
|
+
lastPick.current = id;
|
|
465
|
+
if (from < 0 || to < 0 || from === to) return toggle([id], !on);
|
|
466
|
+
const next = {
|
|
467
|
+
...sel,
|
|
468
|
+
...Object.fromEntries(ids.slice(Math.min(from, to), Math.max(from, to) + 1).map((k) => [k, !on]))
|
|
469
|
+
};
|
|
470
|
+
setSel(next);
|
|
471
|
+
announce(tr("已選 {n} 筆", { n: ids.filter((k) => next[k]).length }));
|
|
472
|
+
};
|
|
473
|
+
const clearFilters = () => {
|
|
474
|
+
setValues({});
|
|
475
|
+
setQ("");
|
|
476
|
+
setPage(0);
|
|
477
|
+
};
|
|
478
|
+
const hasAct = !!p.rowActions;
|
|
479
|
+
const actW = p.actionsWidth || 88;
|
|
480
|
+
const hasTitle = shownCols.some((c) => c.mobile === "title");
|
|
481
|
+
const mobileClass = (c, ci) => {
|
|
482
|
+
const m = c.mobile || (!hasTitle && ci === 0 ? "title" : null);
|
|
483
|
+
return m ? "is-m-" + m : null;
|
|
484
|
+
};
|
|
485
|
+
const longCols = shownCols.filter((c) => c.long || c.fullText);
|
|
486
|
+
const expander = longCols.length > 0 && !narrow;
|
|
487
|
+
const EXP = 40;
|
|
488
|
+
const mainKey = (shownCols.find((c) => !isShort(c) && !c.long && c.grow !== 0) ?? shownCols[0])?.key;
|
|
489
|
+
const grows = (c) => c.grow != null ? c.grow > 0 : c.long || c.key === mainKey;
|
|
490
|
+
const minOf = (c) => {
|
|
491
|
+
if (grows(c)) return Math.max(c.width || (isNum(c) ? 96 : 120), fit[c.key] || 0);
|
|
492
|
+
const cap = c.width == null && !isShort(c) ? TEXT_HUG_MAX : Infinity;
|
|
493
|
+
return Math.max(c.width || 0, 48, Math.min(fit[c.key] ?? c.width ?? HUG_START, cap));
|
|
494
|
+
};
|
|
495
|
+
const layout = (w) => {
|
|
496
|
+
const colW = (c) => w ? `${w[c.key] ?? minOf(c)}px` : grows(c) ? `minmax(${minOf(c)}px, ${c.grow || 1}fr)` : `${minOf(c)}px`;
|
|
497
|
+
return {
|
|
498
|
+
gridTemplateColumns: [
|
|
499
|
+
expander ? "40px" : null,
|
|
500
|
+
selectable ? "46px" : null,
|
|
501
|
+
...shownCols.map(colW),
|
|
502
|
+
hasAct ? actW + "px" : null
|
|
503
|
+
].filter(Boolean).join(" "),
|
|
504
|
+
minWidth: (expander ? EXP : 0) + (selectable ? 46 : 0) + shownCols.reduce((a, c) => a + (w ? w[c.key] ?? minOf(c) : minOf(c)), 0) + (hasAct ? actW : 0)
|
|
505
|
+
};
|
|
506
|
+
};
|
|
507
|
+
const pageGrid = layout(widths);
|
|
508
|
+
const zoomGrid = layout(zoomWidths);
|
|
509
|
+
const drawn = (root) => {
|
|
510
|
+
const out = {};
|
|
511
|
+
for (const c of shownCols) {
|
|
512
|
+
const el = root?.querySelector(`.ui-dt-head [data-col="${CSS.escape(c.key)}"]`);
|
|
513
|
+
out[c.key] = el ? Math.ceil(el.getBoundingClientRect().width) : minOf(c);
|
|
514
|
+
}
|
|
515
|
+
return out;
|
|
516
|
+
};
|
|
517
|
+
const headMin = (root, key) => {
|
|
518
|
+
const el = root?.querySelector(`.ui-dt-head [data-col="${CSS.escape(key)}"] > :first-child`);
|
|
519
|
+
return Math.max(48, el ? Math.ceil(el.getBoundingClientRect().width) + 24 : 48);
|
|
520
|
+
};
|
|
521
|
+
const measureRef = React.useRef(() => {});
|
|
522
|
+
React.useLayoutEffect(() => {
|
|
523
|
+
const root = rootRef.current;
|
|
524
|
+
if (!root || narrow) return;
|
|
525
|
+
const measure = () => {
|
|
526
|
+
const need = {};
|
|
527
|
+
for (const el of root.querySelectorAll(":scope > .ui-dt-scroller .ui-dt-body .ui-dt-cell[data-col]:not(.is-long):not(.is-hug)")) {
|
|
528
|
+
const over = el.scrollWidth - el.clientWidth;
|
|
529
|
+
const key = el.dataset.col;
|
|
530
|
+
if (over > 1 && key) need[key] = Math.max(need[key] ?? 0, Math.ceil(el.getBoundingClientRect().width + over));
|
|
531
|
+
}
|
|
532
|
+
const hugs = root.querySelectorAll(":scope > .ui-dt-scroller .ui-dt-cell.is-hug[data-col]");
|
|
533
|
+
if (hugs.length) {
|
|
534
|
+
root.classList.add("is-measuring");
|
|
535
|
+
for (const el of hugs) {
|
|
536
|
+
const key = el.dataset.col;
|
|
537
|
+
const inner = el.querySelector(":scope > .ui-dt-stack > .ui-dt-main") ?? el;
|
|
538
|
+
if (key) need[key] = Math.max(need[key] ?? 0, Math.ceil(contentWidth(inner) + CELL_PAD));
|
|
539
|
+
}
|
|
540
|
+
root.classList.remove("is-measuring");
|
|
541
|
+
}
|
|
542
|
+
setFit((f) => {
|
|
543
|
+
const grow = Object.entries(need).filter(([k, w]) => w > (f[k] ?? 0));
|
|
544
|
+
return grow.length ? {
|
|
545
|
+
...f,
|
|
546
|
+
...Object.fromEntries(grow)
|
|
547
|
+
} : f;
|
|
548
|
+
});
|
|
549
|
+
};
|
|
550
|
+
let frame = 0;
|
|
551
|
+
const later = () => {
|
|
552
|
+
if (frame) return;
|
|
553
|
+
frame = requestAnimationFrame(() => {
|
|
554
|
+
frame = 0;
|
|
555
|
+
measure();
|
|
556
|
+
});
|
|
557
|
+
};
|
|
558
|
+
measureRef.current = later;
|
|
559
|
+
measure();
|
|
560
|
+
const mo = new MutationObserver(later);
|
|
561
|
+
for (const el of root.querySelectorAll(":scope > .ui-dt-scroller .ui-dt-table, :scope > .ui-dt-scroller .ui-dt-body")) mo.observe(el, { childList: true });
|
|
562
|
+
document.fonts?.ready.then(later).catch(() => {});
|
|
563
|
+
return () => {
|
|
564
|
+
mo.disconnect();
|
|
565
|
+
cancelAnimationFrame(frame);
|
|
566
|
+
measureRef.current = () => {};
|
|
567
|
+
};
|
|
568
|
+
}, [narrow, resetKey]);
|
|
569
|
+
const contentKey = `${visIds.join("")}|${shownCols.map((c) => c.key).join(",")}|${list.length}|${q}|${!!p.totals}`;
|
|
570
|
+
React.useLayoutEffect(() => {
|
|
571
|
+
measureRef.current();
|
|
572
|
+
}, [contentKey, rows]);
|
|
573
|
+
const stickyStyle = (ci) => ci === 0 && sticky ? { left: (expander ? EXP : 0) + (selectable ? 46 : 0) } : void 0;
|
|
574
|
+
const cellClass = (c, ci, ...more) => cx("ui-dt-cell", isNum(c) && "is-num", !grows(c) && "is-hug", ci === 0 && sticky && "is-sticky is-sticky-end", ...more);
|
|
575
|
+
const lead = (what) => sticky ? {
|
|
576
|
+
className: "is-sticky",
|
|
577
|
+
style: { left: what === "sel" && expander ? EXP : 0 }
|
|
578
|
+
} : {
|
|
579
|
+
className: void 0,
|
|
580
|
+
style: void 0
|
|
581
|
+
};
|
|
582
|
+
const headOf = (inZoom) => {
|
|
583
|
+
const gridStyle = inZoom ? zoomGrid : pageGrid;
|
|
584
|
+
const minW = gridStyle.minWidth;
|
|
585
|
+
const w = inZoom ? zoomWidths : widths;
|
|
586
|
+
const setW = inZoom ? setZoomWidths : setWidths;
|
|
587
|
+
const root = () => inZoom ? zoomRef.current : rootRef.current;
|
|
588
|
+
return selectable && selIds.length && p.bulkActions ? /* @__PURE__ */ jsxs("div", {
|
|
589
|
+
className: "ui-dt-row ui-dt-head ui-dt-bulk",
|
|
590
|
+
role: "row",
|
|
591
|
+
style: { minWidth: minW },
|
|
592
|
+
children: [
|
|
593
|
+
/* @__PURE__ */ jsx("div", {
|
|
594
|
+
className: "ui-dt-cell",
|
|
595
|
+
role: "columnheader",
|
|
596
|
+
children: /* @__PURE__ */ jsx(RowCheck, {
|
|
597
|
+
v: allOn ? true : "mixed",
|
|
598
|
+
label: tr("全選"),
|
|
599
|
+
onClick: () => toggle(visIds, !allOn)
|
|
600
|
+
})
|
|
601
|
+
}),
|
|
602
|
+
/* @__PURE__ */ jsx("span", {
|
|
603
|
+
className: "ui-dt-bulk-count",
|
|
604
|
+
children: tr("已選 {n} 筆", { n: selIds.length })
|
|
605
|
+
}),
|
|
606
|
+
/* @__PURE__ */ jsx("span", {
|
|
607
|
+
className: "ui-dt-bulk-actions",
|
|
608
|
+
children: p.bulkActions(selIds, clear)
|
|
609
|
+
}),
|
|
610
|
+
/* @__PURE__ */ jsx("button", {
|
|
611
|
+
type: "button",
|
|
612
|
+
className: "ui-dt-bulk-close",
|
|
613
|
+
"aria-label": tr("取消選取"),
|
|
614
|
+
onClick: clear,
|
|
615
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
616
|
+
name: "x",
|
|
617
|
+
size: 14
|
|
618
|
+
})
|
|
619
|
+
})
|
|
620
|
+
]
|
|
621
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
622
|
+
className: "ui-dt-row ui-dt-head",
|
|
623
|
+
role: "row",
|
|
624
|
+
style: gridStyle,
|
|
625
|
+
children: [
|
|
626
|
+
expander ? /* @__PURE__ */ jsx("div", {
|
|
627
|
+
className: cx("ui-dt-cell ui-dt-exp", lead("exp").className),
|
|
628
|
+
style: lead("exp").style,
|
|
629
|
+
role: "columnheader",
|
|
630
|
+
"aria-label": tr("詳細")
|
|
631
|
+
}) : null,
|
|
632
|
+
selectable ? /* @__PURE__ */ jsx("div", {
|
|
633
|
+
className: cx("ui-dt-cell ui-dt-sel", lead("sel").className),
|
|
634
|
+
style: lead("sel").style,
|
|
635
|
+
role: "columnheader",
|
|
636
|
+
children: /* @__PURE__ */ jsx(RowCheck, {
|
|
637
|
+
v: allOn ? true : mixed ? "mixed" : false,
|
|
638
|
+
label: tr("全選"),
|
|
639
|
+
onClick: () => toggle(visIds, !allOn)
|
|
640
|
+
})
|
|
641
|
+
}) : null,
|
|
642
|
+
shownCols.map((c, ci) => {
|
|
643
|
+
const at = sort.findIndex((l) => l.key === c.key);
|
|
644
|
+
const cur = at >= 0;
|
|
645
|
+
const many = sort.length > 1;
|
|
646
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
647
|
+
role: "columnheader",
|
|
648
|
+
"aria-sort": at === 0 ? sort[0].dir === "asc" ? "ascending" : "descending" : "none",
|
|
649
|
+
className: cellClass(c, ci),
|
|
650
|
+
style: stickyStyle(ci),
|
|
651
|
+
"data-col": c.key,
|
|
652
|
+
children: [c.sortable === false ? c.label : /* @__PURE__ */ jsxs("button", {
|
|
653
|
+
type: "button",
|
|
654
|
+
className: cx("ui-dt-sort", cur && "is-on"),
|
|
655
|
+
"aria-label": cur && many ? tr("{name},第 {n} 排序,{dir}", {
|
|
656
|
+
name: c.label,
|
|
657
|
+
n: at + 1,
|
|
658
|
+
dir: dirWord(sort[at].dir)
|
|
659
|
+
}) : void 0,
|
|
660
|
+
"aria-keyshortcuts": "Shift+Enter",
|
|
661
|
+
onClick: (e) => sortBy(c, e.shiftKey),
|
|
662
|
+
onKeyDown: (e) => {
|
|
663
|
+
if (e.shiftKey && (e.key === "Enter" || e.key === " ")) {
|
|
664
|
+
e.preventDefault();
|
|
665
|
+
sortBy(c, true);
|
|
666
|
+
}
|
|
667
|
+
},
|
|
668
|
+
children: [
|
|
669
|
+
/* @__PURE__ */ jsx("span", { children: c.label }),
|
|
670
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
671
|
+
d: ARROWS[cur ? sort[at].dir : "none"],
|
|
672
|
+
size: 14,
|
|
673
|
+
className: "ui-dt-arrow"
|
|
674
|
+
}),
|
|
675
|
+
cur && many ? /* @__PURE__ */ jsx("span", {
|
|
676
|
+
className: "ui-dt-sortpri",
|
|
677
|
+
"aria-hidden": "true",
|
|
678
|
+
children: at + 1
|
|
679
|
+
}) : null
|
|
680
|
+
]
|
|
681
|
+
}), narrow ? null : /* @__PURE__ */ jsx(ColResize, {
|
|
682
|
+
name: c.label,
|
|
683
|
+
width: w?.[c.key] ?? minOf(c),
|
|
684
|
+
start: () => (w ?? drawn(root()))[c.key] ?? minOf(c),
|
|
685
|
+
onWidth: (px) => setW({
|
|
686
|
+
...w ?? drawn(root()),
|
|
687
|
+
[c.key]: Math.max(headMin(root(), c.key), px)
|
|
688
|
+
}),
|
|
689
|
+
onReset: () => setW(null)
|
|
690
|
+
})]
|
|
691
|
+
}, c.key);
|
|
692
|
+
}),
|
|
693
|
+
hasAct ? /* @__PURE__ */ jsx("div", {
|
|
694
|
+
className: "ui-dt-cell",
|
|
695
|
+
role: "columnheader",
|
|
696
|
+
"aria-label": tr("操作")
|
|
697
|
+
}) : null
|
|
698
|
+
]
|
|
699
|
+
});
|
|
700
|
+
};
|
|
701
|
+
const mark = searching ? q : "";
|
|
702
|
+
const absDate = (r, c) => {
|
|
703
|
+
if (c.format !== "relative" || c.render) return "";
|
|
704
|
+
const d = asDate(get(r, c.key));
|
|
705
|
+
const abs = d ? format.dateTime(d) : "";
|
|
706
|
+
return abs && abs !== format.relative(d) ? abs : "";
|
|
707
|
+
};
|
|
708
|
+
const cellInner = (r, c) => {
|
|
709
|
+
const raw = get(r, c.key);
|
|
710
|
+
let v;
|
|
711
|
+
if (c.render) v = c.render(r);
|
|
712
|
+
else if (isDateCol(c) && asDate(raw)) {
|
|
713
|
+
const d = asDate(raw);
|
|
714
|
+
const abs = absDate(r, c);
|
|
715
|
+
const t = /* @__PURE__ */ jsx("time", {
|
|
716
|
+
className: "ui-dt-time",
|
|
717
|
+
dateTime: isoOf(d, c.format === "date"),
|
|
718
|
+
children: markMatch(cellText(c, raw), mark)
|
|
719
|
+
});
|
|
720
|
+
v = abs ? /* @__PURE__ */ jsx(Tooltip, {
|
|
721
|
+
label: abs,
|
|
722
|
+
describe: false,
|
|
723
|
+
disabled: touch,
|
|
724
|
+
children: t
|
|
725
|
+
}) : t;
|
|
726
|
+
} else if (c.unit && raw !== null && raw !== void 0 && raw !== "") v = /* @__PURE__ */ jsxs("span", {
|
|
727
|
+
className: "ui-dt-qty",
|
|
728
|
+
children: [
|
|
729
|
+
markMatch(cellText({
|
|
730
|
+
...c,
|
|
731
|
+
unit: void 0
|
|
732
|
+
}, raw), mark),
|
|
733
|
+
" ",
|
|
734
|
+
/* @__PURE__ */ jsx("span", {
|
|
735
|
+
className: "ui-unit",
|
|
736
|
+
children: c.unit
|
|
737
|
+
})
|
|
738
|
+
]
|
|
739
|
+
});
|
|
740
|
+
else v = markMatch(cellText(c, raw), mark);
|
|
741
|
+
return v;
|
|
742
|
+
};
|
|
743
|
+
const rowClick = (e) => {
|
|
744
|
+
const ctl = e.target.closest(ROW_CONTROLS);
|
|
745
|
+
if (ctl && ctl !== e.currentTarget) return false;
|
|
746
|
+
const s = window.getSelection();
|
|
747
|
+
return !(s && !s.isCollapsed && String(s).trim());
|
|
748
|
+
};
|
|
749
|
+
const openRow = (r, e) => {
|
|
750
|
+
const href = p.rowHref?.(r);
|
|
751
|
+
if (href == null) return;
|
|
752
|
+
if (newTab(e)) {
|
|
753
|
+
e.preventDefault();
|
|
754
|
+
window.open(href, "_blank", "noopener");
|
|
755
|
+
} else if (p.onRowOpen) p.onRowOpen(r, e);
|
|
756
|
+
else e.currentTarget.querySelector("a.ui-dt-rowlink")?.click();
|
|
757
|
+
};
|
|
758
|
+
const cell = (r, c, ci) => {
|
|
759
|
+
let v = c.long ? /* @__PURE__ */ jsx(LongText, { children: cellInner(r, c) }) : cellInner(r, c);
|
|
760
|
+
if (c.fullText) v = /* @__PURE__ */ jsx(FullText, {
|
|
761
|
+
text: c.fullText(r),
|
|
762
|
+
children: v
|
|
763
|
+
});
|
|
764
|
+
if (ci === 0 && p.rowHref) v = /* @__PURE__ */ jsx("a", {
|
|
765
|
+
className: "ui-dt-rowlink",
|
|
766
|
+
href: p.rowHref(r),
|
|
767
|
+
onClick: p.onRowOpen ? (e) => {
|
|
768
|
+
if (newTab(e)) return;
|
|
769
|
+
e.preventDefault();
|
|
770
|
+
p.onRowOpen?.(r, e);
|
|
771
|
+
} : void 0,
|
|
772
|
+
children: v
|
|
773
|
+
});
|
|
774
|
+
const sub = c.secondary?.(r);
|
|
775
|
+
if (sub == null || sub === "" || sub === false) return v;
|
|
776
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
777
|
+
className: "ui-dt-stack",
|
|
778
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
779
|
+
className: "ui-dt-main",
|
|
780
|
+
children: v
|
|
781
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
782
|
+
className: "ui-dt-sub",
|
|
783
|
+
children: sub
|
|
784
|
+
})]
|
|
785
|
+
});
|
|
786
|
+
};
|
|
787
|
+
const total = (c, ci) => {
|
|
788
|
+
const how = p.totals?.[c.key];
|
|
789
|
+
const rowsAll = list.map((x) => x.r);
|
|
790
|
+
if (ci === 0 && !how) return /* @__PURE__ */ jsx("span", {
|
|
791
|
+
className: "ui-dt-qty",
|
|
792
|
+
children: monoNums(tr("合計 {n} 筆", { n: "" }), [format.number(rowsAll.length)])
|
|
793
|
+
});
|
|
794
|
+
if (typeof how === "function") return how(rowsAll);
|
|
795
|
+
if (how === "sum" || how === "avg") {
|
|
796
|
+
const sum = rowsAll.reduce((a, r) => a + (Number(get(r, c.key)) || 0), 0);
|
|
797
|
+
const val = how === "sum" ? sum : sum / (rowsAll.length || 1);
|
|
798
|
+
const num = cellText({
|
|
799
|
+
...how === "avg" && !c.format ? {
|
|
800
|
+
...c,
|
|
801
|
+
decimals: 1
|
|
802
|
+
} : c,
|
|
803
|
+
unit: void 0
|
|
804
|
+
}, val);
|
|
805
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
806
|
+
className: "ui-dt-qty",
|
|
807
|
+
children: [
|
|
808
|
+
how === "avg" ? /* @__PURE__ */ jsxs("span", {
|
|
809
|
+
className: "ui-unit",
|
|
810
|
+
children: [tr("平均"), " "]
|
|
811
|
+
}) : null,
|
|
812
|
+
num,
|
|
813
|
+
c.unit ? /* @__PURE__ */ jsxs(Fragment, { children: [" ", /* @__PURE__ */ jsx("span", {
|
|
814
|
+
className: "ui-unit",
|
|
815
|
+
children: c.unit
|
|
816
|
+
})] }) : null
|
|
817
|
+
]
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
return "";
|
|
821
|
+
};
|
|
822
|
+
const copyMarkdown = () => {
|
|
823
|
+
const all = list.map((x) => x.r);
|
|
824
|
+
if (p.copyText) return p.copyText(all);
|
|
825
|
+
return markdownTable(shownCols.map((c) => c.label), all.map((r) => shownCols.map((c) => String(c.fullText?.(r) ?? c.searchText?.(r) ?? cellText(c, get(r, c.key)) ?? ""))));
|
|
826
|
+
};
|
|
827
|
+
const [copied, setCopied] = React.useState(false);
|
|
828
|
+
const copiedTimer = React.useRef(void 0);
|
|
829
|
+
React.useEffect(() => () => clearTimeout(copiedTimer.current), []);
|
|
830
|
+
const doCopy = () => copyText(copyMarkdown()).then(() => {
|
|
831
|
+
setCopied(true);
|
|
832
|
+
announce(tr("已複製"));
|
|
833
|
+
clearTimeout(copiedTimer.current);
|
|
834
|
+
copiedTimer.current = setTimeout(() => setCopied(false), 2e3);
|
|
835
|
+
}, () => p.onCopyError?.());
|
|
836
|
+
const slash = search !== false && p.searchShortcut !== false;
|
|
837
|
+
const [slashOwner, setSlashOwner] = React.useState(false);
|
|
838
|
+
React.useEffect(() => {
|
|
839
|
+
const el = rootRef.current;
|
|
840
|
+
if (!slash || !el) return;
|
|
841
|
+
const changed = () => setSlashOwner(firstShortcutTable() === el);
|
|
842
|
+
const off = registerShortcut(el, changed);
|
|
843
|
+
return () => {
|
|
844
|
+
off();
|
|
845
|
+
setSlashOwner(false);
|
|
846
|
+
};
|
|
847
|
+
}, [slash]);
|
|
848
|
+
const [searchFocus, setSearchFocus] = React.useState(false);
|
|
849
|
+
const setFilter = (key, v) => {
|
|
850
|
+
setValues(v === void 0 ? Object.fromEntries(Object.entries(values).filter(([k]) => k !== key)) : {
|
|
851
|
+
...values,
|
|
852
|
+
[key]: v
|
|
853
|
+
});
|
|
854
|
+
setPage(0);
|
|
855
|
+
};
|
|
856
|
+
const chips = [];
|
|
857
|
+
for (const f of filters) {
|
|
858
|
+
const v = values[f.key];
|
|
859
|
+
if (!v || !isActive(v)) continue;
|
|
860
|
+
if (Array.isArray(v)) for (const val of v) chips.push({
|
|
861
|
+
id: f.key + "=" + val,
|
|
862
|
+
text: tr("{name}:{value}", {
|
|
863
|
+
name: f.label,
|
|
864
|
+
value: f.options.find((o) => String(o.value) === val)?.label ?? val
|
|
865
|
+
}),
|
|
866
|
+
remove: () => setFilter(f.key, v.filter((x) => x !== val))
|
|
867
|
+
});
|
|
868
|
+
else {
|
|
869
|
+
const range = v.min && v.max ? `${v.min}–${v.max}` : v.min ? `≥ ${v.min}` : `≤ ${v.max}`;
|
|
870
|
+
chips.push({
|
|
871
|
+
id: f.key,
|
|
872
|
+
text: tr("{name}:{value}", {
|
|
873
|
+
name: f.label,
|
|
874
|
+
value: range
|
|
875
|
+
}),
|
|
876
|
+
remove: () => setFilter(f.key, void 0)
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
const chipsView = (inZoom) => /* @__PURE__ */ jsx(FilterChips, {
|
|
881
|
+
chips,
|
|
882
|
+
onClear: () => {
|
|
883
|
+
setValues({});
|
|
884
|
+
setPage(0);
|
|
885
|
+
},
|
|
886
|
+
filterButton: () => (inZoom ? zoomRef : rootRef).current?.querySelector(".ui-dt-filterbtn") ?? null
|
|
887
|
+
});
|
|
888
|
+
const toolsView = (inZoom, inHead = false) => /* @__PURE__ */ jsxs("div", {
|
|
889
|
+
className: cx("ui-dt-tools", inHead && "is-inhead"),
|
|
890
|
+
children: [
|
|
891
|
+
search === false && p.caption && !inZoom && !inHead ? /* @__PURE__ */ jsx("div", {
|
|
892
|
+
className: "ui-dt-caption",
|
|
893
|
+
children: p.caption
|
|
894
|
+
}) : null,
|
|
895
|
+
search !== false ? /* @__PURE__ */ jsxs("div", {
|
|
896
|
+
className: "ui-dt-search",
|
|
897
|
+
onFocus: () => setSearchFocus(true),
|
|
898
|
+
onBlur: () => setSearchFocus(false),
|
|
899
|
+
children: [/* @__PURE__ */ jsx(SearchField, {
|
|
900
|
+
value: q,
|
|
901
|
+
onChange: (v) => {
|
|
902
|
+
setQ(v);
|
|
903
|
+
setPage(0);
|
|
904
|
+
},
|
|
905
|
+
placeholder: search.placeholder || tr("搜尋"),
|
|
906
|
+
label: search.placeholder || tr("搜尋"),
|
|
907
|
+
"aria-keyshortcuts": slashOwner && !inZoom ? "/" : void 0,
|
|
908
|
+
className: "ui-dt-searchfield"
|
|
909
|
+
}), slashOwner && !inZoom && !narrow && !q && !searchFocus ? /* @__PURE__ */ jsx("kbd", {
|
|
910
|
+
className: "ui-dt-kbd",
|
|
911
|
+
"aria-hidden": "true",
|
|
912
|
+
children: "/"
|
|
913
|
+
}) : null]
|
|
914
|
+
}) : null,
|
|
915
|
+
/* @__PURE__ */ jsxs("div", {
|
|
916
|
+
className: "ui-dt-actions",
|
|
917
|
+
children: [
|
|
918
|
+
filters.length ? /* @__PURE__ */ jsx(FilterButton, {
|
|
919
|
+
boundary: inZoom ? zoomRef : rootRef,
|
|
920
|
+
filters,
|
|
921
|
+
values,
|
|
922
|
+
activeCount: activeN,
|
|
923
|
+
count: (f, v) => all.filter((x) => passes(x.r, f.key) && matches(f, x.r, f.type === "list" ? [v] : void 0)).length,
|
|
924
|
+
onChange: (key, v) => setFilter(key, v),
|
|
925
|
+
onClear: () => {
|
|
926
|
+
setValues({});
|
|
927
|
+
setPage(0);
|
|
928
|
+
}
|
|
929
|
+
}) : null,
|
|
930
|
+
/* @__PURE__ */ jsxs("span", {
|
|
931
|
+
className: "ui-dt-result",
|
|
932
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
933
|
+
"aria-hidden": "true",
|
|
934
|
+
children: seenOnly(tr("{n} / {total} 筆", {
|
|
935
|
+
n: "",
|
|
936
|
+
total: ""
|
|
937
|
+
}), [format.number(list.length), format.number(baseCount)])
|
|
938
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
939
|
+
className: "ui-visually-hidden",
|
|
940
|
+
children: format.fractionLabel(list.length, baseCount, tr("筆"))
|
|
941
|
+
})]
|
|
942
|
+
}),
|
|
943
|
+
sortCols.length ? /* @__PURE__ */ jsx(SortButton, {
|
|
944
|
+
cols: sortCols,
|
|
945
|
+
levels: sort,
|
|
946
|
+
max: maxSort,
|
|
947
|
+
onChange: changeSort,
|
|
948
|
+
boundary: inZoom ? zoomRef : rootRef
|
|
949
|
+
}) : null,
|
|
950
|
+
narrow ? null : /* @__PURE__ */ jsx(MoreMenu, {
|
|
951
|
+
columns: p.columnMenu !== false && cols.length > 2 ? {
|
|
952
|
+
cols,
|
|
953
|
+
hidden,
|
|
954
|
+
onToggle: (k) => setToggled({
|
|
955
|
+
...toggled,
|
|
956
|
+
[k]: !hidden[k]
|
|
957
|
+
}),
|
|
958
|
+
onReset: () => {
|
|
959
|
+
setToggled({});
|
|
960
|
+
setWidths(null);
|
|
961
|
+
setZoomWidths(null);
|
|
962
|
+
announce(tr("已還原預設的欄位與欄寬"));
|
|
963
|
+
}
|
|
964
|
+
} : void 0,
|
|
965
|
+
onCopy: p.copy !== false ? doCopy : void 0,
|
|
966
|
+
onZoom: p.zoom !== false && !inZoom ? () => setZoomed(true) : void 0
|
|
967
|
+
}),
|
|
968
|
+
copied && !narrow ? /* @__PURE__ */ jsxs("span", {
|
|
969
|
+
className: "ui-dt-copied",
|
|
970
|
+
"aria-hidden": "true",
|
|
971
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
972
|
+
name: "check",
|
|
973
|
+
size: 16
|
|
974
|
+
}), tr("已複製")]
|
|
975
|
+
}) : null
|
|
976
|
+
]
|
|
977
|
+
})
|
|
978
|
+
]
|
|
979
|
+
});
|
|
980
|
+
const tableView = (inZoom) => {
|
|
981
|
+
const grid = inZoom ? zoomGrid : pageGrid;
|
|
982
|
+
const pfx = inZoom ? uid + "z" : uid;
|
|
983
|
+
return /* @__PURE__ */ jsx("div", {
|
|
984
|
+
className: cx("ui-dt-scroller", scrollMore && !inZoom && "has-more"),
|
|
985
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
986
|
+
className: cx("ui-dt-scroll", pages > 1 && "is-paged"),
|
|
987
|
+
ref: inZoom ? void 0 : scrollRef,
|
|
988
|
+
onScroll: inZoom ? void 0 : onScroll,
|
|
989
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
990
|
+
className: "ui-dt-table",
|
|
991
|
+
role: "table",
|
|
992
|
+
"aria-label": p.label || p.caption,
|
|
993
|
+
children: [
|
|
994
|
+
headOf(inZoom),
|
|
995
|
+
/* @__PURE__ */ jsx("div", {
|
|
996
|
+
ref: inZoom ? void 0 : bodyRef,
|
|
997
|
+
className: "ui-dt-body",
|
|
998
|
+
role: "rowgroup",
|
|
999
|
+
children: vis.length ? vis.map((x, i) => {
|
|
1000
|
+
const id = visIds[i];
|
|
1001
|
+
const on = !!sel[id];
|
|
1002
|
+
const open = expander && !!opened[id];
|
|
1003
|
+
const detailId = `${pfx}-d-${idPart(id)}`;
|
|
1004
|
+
const rowName = shownCols[0] ? String(cellText(shownCols[0], get(x.r, shownCols[0].key)) ?? "") : "";
|
|
1005
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
1006
|
+
"data-rid": id,
|
|
1007
|
+
ref: inZoom ? void 0 : (el) => {
|
|
1008
|
+
rowEls.current[id] = el;
|
|
1009
|
+
},
|
|
1010
|
+
role: "row",
|
|
1011
|
+
"aria-labelledby": shownCols.length ? `${pfx}-n-${start + i}` : void 0,
|
|
1012
|
+
className: cx("ui-dt-row", i % 2 && "is-even", on && "is-selected", selectable && "has-sel", expander && !p.rowHref && "has-exp", p.rowHref && "has-href"),
|
|
1013
|
+
style: grid,
|
|
1014
|
+
onClick: expander || p.rowHref ? (e) => {
|
|
1015
|
+
if (!rowClick(e)) return;
|
|
1016
|
+
if (p.rowHref) return openRow(x.r, e);
|
|
1017
|
+
setOpened({
|
|
1018
|
+
...opened,
|
|
1019
|
+
[id]: !open
|
|
1020
|
+
});
|
|
1021
|
+
} : void 0,
|
|
1022
|
+
onMouseDown: p.rowHref ? (e) => {
|
|
1023
|
+
if ((e.shiftKey || e.button === 1) && !e.target.closest(ROW_CONTROLS)) e.preventDefault();
|
|
1024
|
+
} : void 0,
|
|
1025
|
+
onAuxClick: p.rowHref ? (e) => {
|
|
1026
|
+
if (e.button === 1 && rowClick(e)) openRow(x.r, e);
|
|
1027
|
+
} : void 0,
|
|
1028
|
+
children: [
|
|
1029
|
+
expander ? /* @__PURE__ */ jsx("div", {
|
|
1030
|
+
className: cx("ui-dt-cell ui-dt-exp", lead("exp").className),
|
|
1031
|
+
style: lead("exp").style,
|
|
1032
|
+
role: "cell",
|
|
1033
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
1034
|
+
type: "button",
|
|
1035
|
+
className: cx("ui-dt-exp-btn", open && "is-open"),
|
|
1036
|
+
"aria-expanded": open,
|
|
1037
|
+
"aria-controls": open ? detailId : void 0,
|
|
1038
|
+
"aria-label": tr(open ? "收合 {name}" : "展開 {name}", { name: rowName }),
|
|
1039
|
+
onClick: () => setOpened({
|
|
1040
|
+
...opened,
|
|
1041
|
+
[id]: !open
|
|
1042
|
+
}),
|
|
1043
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
1044
|
+
name: "caret-right",
|
|
1045
|
+
size: 16
|
|
1046
|
+
})
|
|
1047
|
+
})
|
|
1048
|
+
}) : null,
|
|
1049
|
+
selectable ? /* @__PURE__ */ jsx("div", {
|
|
1050
|
+
className: cx("ui-dt-cell ui-dt-sel", lead("sel").className),
|
|
1051
|
+
style: lead("sel").style,
|
|
1052
|
+
role: "cell",
|
|
1053
|
+
children: /* @__PURE__ */ jsx(RowCheck, {
|
|
1054
|
+
v: on,
|
|
1055
|
+
label: tr("選取第 {n} 筆", { n: start + i + 1 }),
|
|
1056
|
+
onClick: (e) => pickRow(id, on, e.shiftKey)
|
|
1057
|
+
})
|
|
1058
|
+
}) : null,
|
|
1059
|
+
shownCols.map((c, ci) => /* @__PURE__ */ jsx("div", {
|
|
1060
|
+
role: "cell",
|
|
1061
|
+
id: ci === 0 ? `${pfx}-n-${start + i}` : void 0,
|
|
1062
|
+
"aria-description": [c.fullText?.(x.r), absDate(x.r, c)].filter(Boolean).join(",") || void 0,
|
|
1063
|
+
"data-label": c.label,
|
|
1064
|
+
"data-col": c.key,
|
|
1065
|
+
className: cellClass(c, ci, c.long && "is-long", mobileClass(c, ci)),
|
|
1066
|
+
style: stickyStyle(ci),
|
|
1067
|
+
children: cell(x.r, c, ci)
|
|
1068
|
+
}, c.key)),
|
|
1069
|
+
hasAct ? /* @__PURE__ */ jsx("div", {
|
|
1070
|
+
className: "ui-dt-cell ui-dt-acts",
|
|
1071
|
+
role: "cell",
|
|
1072
|
+
children: p.rowActions?.(x.r)
|
|
1073
|
+
}) : null
|
|
1074
|
+
]
|
|
1075
|
+
}), open ? /* @__PURE__ */ jsx("div", {
|
|
1076
|
+
id: detailId,
|
|
1077
|
+
role: "row",
|
|
1078
|
+
className: cx("ui-dt-detail", i % 2 && "is-even"),
|
|
1079
|
+
style: { minWidth: grid.minWidth },
|
|
1080
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1081
|
+
role: "cell",
|
|
1082
|
+
className: "ui-dt-detail-cell",
|
|
1083
|
+
style: { paddingLeft: EXP + (selectable ? 46 : 0) + 12 },
|
|
1084
|
+
children: longCols.map((c) => /* @__PURE__ */ jsxs("div", {
|
|
1085
|
+
className: "ui-dt-detail-item",
|
|
1086
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1087
|
+
className: "ui-dt-detail-label",
|
|
1088
|
+
children: c.label
|
|
1089
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1090
|
+
className: "ui-dt-detail-text",
|
|
1091
|
+
children: c.fullText ? c.fullText(x.r) : cellInner(x.r, c)
|
|
1092
|
+
})]
|
|
1093
|
+
}, c.key))
|
|
1094
|
+
})
|
|
1095
|
+
}) : null] }, id);
|
|
1096
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
1097
|
+
className: "ui-dt-empty",
|
|
1098
|
+
children: [p.emptyText || tr("沒有符合的資料"), q || activeN ? /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, {
|
|
1099
|
+
onClick: clearFilters,
|
|
1100
|
+
children: tr("清除篩選")
|
|
1101
|
+
}) }) : null]
|
|
1102
|
+
})
|
|
1103
|
+
}),
|
|
1104
|
+
p.totals && list.length ? /* @__PURE__ */ jsxs("div", {
|
|
1105
|
+
className: "ui-dt-row ui-dt-total",
|
|
1106
|
+
role: "row",
|
|
1107
|
+
style: grid,
|
|
1108
|
+
children: [
|
|
1109
|
+
expander ? /* @__PURE__ */ jsx("div", {
|
|
1110
|
+
className: cx("ui-dt-cell", lead("exp").className),
|
|
1111
|
+
style: lead("exp").style,
|
|
1112
|
+
role: "cell"
|
|
1113
|
+
}) : null,
|
|
1114
|
+
selectable ? /* @__PURE__ */ jsx("div", {
|
|
1115
|
+
className: cx("ui-dt-cell", lead("sel").className),
|
|
1116
|
+
style: lead("sel").style,
|
|
1117
|
+
role: "cell"
|
|
1118
|
+
}) : null,
|
|
1119
|
+
shownCols.map((c, ci) => /* @__PURE__ */ jsx("div", {
|
|
1120
|
+
role: "cell",
|
|
1121
|
+
className: cellClass(c, ci),
|
|
1122
|
+
style: stickyStyle(ci),
|
|
1123
|
+
"data-col": c.key,
|
|
1124
|
+
"data-label": ci > 0 && p.totals?.[c.key] ? c.label : void 0,
|
|
1125
|
+
children: total(c, ci)
|
|
1126
|
+
}, c.key)),
|
|
1127
|
+
hasAct ? /* @__PURE__ */ jsx("div", {
|
|
1128
|
+
className: "ui-dt-cell",
|
|
1129
|
+
role: "cell"
|
|
1130
|
+
}) : null
|
|
1131
|
+
]
|
|
1132
|
+
}) : null
|
|
1133
|
+
]
|
|
1134
|
+
})
|
|
1135
|
+
})
|
|
1136
|
+
});
|
|
1137
|
+
};
|
|
1138
|
+
const footView = /* @__PURE__ */ jsx(Fragment, { children: pages > 1 ? /* @__PURE__ */ jsxs("div", {
|
|
1139
|
+
className: "ui-dt-foot",
|
|
1140
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1141
|
+
className: "ui-dt-range",
|
|
1142
|
+
children: monoNums(tr("第 {a}–{b} 筆,共 {n} 筆", {
|
|
1143
|
+
a: "",
|
|
1144
|
+
b: "",
|
|
1145
|
+
n: ""
|
|
1146
|
+
}), [
|
|
1147
|
+
start + 1,
|
|
1148
|
+
Math.min(list.length, start + pageSize),
|
|
1149
|
+
format.number(list.length)
|
|
1150
|
+
])
|
|
1151
|
+
}), /* @__PURE__ */ jsxs("nav", {
|
|
1152
|
+
className: "ui-dt-pages",
|
|
1153
|
+
"aria-label": tr("分頁"),
|
|
1154
|
+
children: [
|
|
1155
|
+
/* @__PURE__ */ jsx("button", {
|
|
1156
|
+
type: "button",
|
|
1157
|
+
className: "ui-dt-page",
|
|
1158
|
+
"aria-label": tr("上一頁"),
|
|
1159
|
+
disabled: pageNow === 0,
|
|
1160
|
+
onClick: () => goPage(pageNow - 1),
|
|
1161
|
+
children: "‹"
|
|
1162
|
+
}),
|
|
1163
|
+
Array.from({ length: pages }, (_, i) => /* @__PURE__ */ jsx("button", {
|
|
1164
|
+
type: "button",
|
|
1165
|
+
className: cx("ui-dt-page", i === pageNow && "is-on"),
|
|
1166
|
+
"aria-current": i === pageNow ? "page" : void 0,
|
|
1167
|
+
onClick: () => goPage(i),
|
|
1168
|
+
children: String(i + 1)
|
|
1169
|
+
}, i)),
|
|
1170
|
+
/* @__PURE__ */ jsx("button", {
|
|
1171
|
+
type: "button",
|
|
1172
|
+
className: "ui-dt-page",
|
|
1173
|
+
"aria-label": tr("下一頁"),
|
|
1174
|
+
disabled: pageNow >= pages - 1,
|
|
1175
|
+
onClick: () => goPage(pageNow + 1),
|
|
1176
|
+
children: "›"
|
|
1177
|
+
})
|
|
1178
|
+
]
|
|
1179
|
+
})]
|
|
1180
|
+
}) : null });
|
|
1181
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1182
|
+
ref: rootRef,
|
|
1183
|
+
className: cx("ui-dt", search === false && "is-nosearch", selIds.length && "has-sel", p.className),
|
|
1184
|
+
children: [
|
|
1185
|
+
p.caption && search !== false ? /* @__PURE__ */ jsx("div", {
|
|
1186
|
+
className: "ui-dt-caption",
|
|
1187
|
+
children: p.caption
|
|
1188
|
+
}) : null,
|
|
1189
|
+
p.views ? /* @__PURE__ */ jsx("div", {
|
|
1190
|
+
className: "ui-dt-views",
|
|
1191
|
+
role: "tablist",
|
|
1192
|
+
"aria-label": tr("檢視"),
|
|
1193
|
+
children: p.views.map((v) => {
|
|
1194
|
+
const on = v.id === view;
|
|
1195
|
+
const vn = rows.filter((r) => !v.filter || v.filter(r)).length;
|
|
1196
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
1197
|
+
type: "button",
|
|
1198
|
+
role: "tab",
|
|
1199
|
+
"aria-selected": on,
|
|
1200
|
+
className: cx("ui-dt-view", on && "is-on"),
|
|
1201
|
+
onClick: () => {
|
|
1202
|
+
setView(v.id);
|
|
1203
|
+
setPage(0);
|
|
1204
|
+
},
|
|
1205
|
+
children: [v.label, /* @__PURE__ */ jsxs("span", {
|
|
1206
|
+
className: "ui-dt-view-n",
|
|
1207
|
+
children: [
|
|
1208
|
+
format.number(vn),
|
|
1209
|
+
" ",
|
|
1210
|
+
/* @__PURE__ */ jsx("span", {
|
|
1211
|
+
className: "ui-unit",
|
|
1212
|
+
children: unitFor("筆", vn)
|
|
1213
|
+
})
|
|
1214
|
+
]
|
|
1215
|
+
})]
|
|
1216
|
+
}, v.id);
|
|
1217
|
+
})
|
|
1218
|
+
}) : null,
|
|
1219
|
+
summary ? /* @__PURE__ */ jsx(Tabs, {
|
|
1220
|
+
className: "ui-dt-summary",
|
|
1221
|
+
label: summary.label || tr("依狀態篩選"),
|
|
1222
|
+
unit: summary.unit || "筆",
|
|
1223
|
+
value: sumVal,
|
|
1224
|
+
onChange: (v) => {
|
|
1225
|
+
capture("sort");
|
|
1226
|
+
setSumVal(v);
|
|
1227
|
+
setPage(0);
|
|
1228
|
+
},
|
|
1229
|
+
items: [{
|
|
1230
|
+
id: "all",
|
|
1231
|
+
label: tr("全部"),
|
|
1232
|
+
count: sumAll.length
|
|
1233
|
+
}, ...summary.items.map((it) => ({
|
|
1234
|
+
id: String(it.value),
|
|
1235
|
+
label: it.label,
|
|
1236
|
+
count: sumAll.filter((x) => String(get(x.r, summary.key)) === String(it.value)).length
|
|
1237
|
+
}))]
|
|
1238
|
+
}) : null,
|
|
1239
|
+
headSlot ? createPortal(toolsView(false, true), headSlot) : toolsView(false),
|
|
1240
|
+
chipsView(false),
|
|
1241
|
+
tableView(false),
|
|
1242
|
+
/* @__PURE__ */ jsx(ScrollHint, {
|
|
1243
|
+
show: overflows,
|
|
1244
|
+
done: scrolled
|
|
1245
|
+
}),
|
|
1246
|
+
footView,
|
|
1247
|
+
/* @__PURE__ */ jsx(TableDialog, {
|
|
1248
|
+
open: zoomed,
|
|
1249
|
+
onClose: () => setZoomed(false),
|
|
1250
|
+
title: p.caption || p.label,
|
|
1251
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1252
|
+
ref: zoomRef,
|
|
1253
|
+
className: "ui-dt ui-dt-zoomed",
|
|
1254
|
+
children: [
|
|
1255
|
+
toolsView(true),
|
|
1256
|
+
chipsView(true),
|
|
1257
|
+
tableView(true),
|
|
1258
|
+
footView
|
|
1259
|
+
]
|
|
1260
|
+
})
|
|
1261
|
+
})
|
|
1262
|
+
]
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
export { DataTable };
|
|
1266
|
+
|
|
1267
|
+
//# sourceMappingURL=DataTable.js.map
|