niuma-ui 2.0.4 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +67 -0
- package/NOTICE +0 -1
- package/README.md +3 -3
- package/README.zh-CN.md +3 -3
- package/dist/components/_shared/index.d.ts +2 -2
- package/dist/components/_shared/src/overlay-utils.d.ts +44 -1
- package/dist/components/_shared/src/overlay-utils.js +87 -2
- package/dist/components/alert/index.d.ts +1 -0
- package/dist/components/alert/src/RsAlert.css +120 -65
- package/dist/components/alert/src/RsAlert.d.ts +24 -5
- package/dist/components/alert/src/RsAlert.impl.js +108 -36
- package/dist/components/alert/src/RsAlert.js +1 -1
- package/dist/components/alert/src/alert-utils.d.ts +37 -0
- package/dist/components/alert/src/alert-utils.js +71 -0
- package/dist/components/auto-complete/src/RsAutoComplete.d.ts +1 -1
- package/dist/components/button/src/RsButton.css +75 -72
- package/dist/components/button/src/RsButton.d.ts +1 -4
- package/dist/components/button/src/RsButton.impl.js +3 -7
- package/dist/components/button/src/RsButton.js +1 -1
- package/dist/components/card/src/RsCard.d.ts +1 -1
- package/dist/components/code-block/index.d.ts +1 -0
- package/dist/components/code-block/src/RsCodeBlock.css +93 -52
- package/dist/components/code-block/src/RsCodeBlock.d.ts +36 -9
- package/dist/components/code-block/src/RsCodeBlock.impl.js +203 -84
- package/dist/components/code-block/src/RsCodeBlock.js +1 -1
- package/dist/components/code-block/src/code-block-highlight.d.ts +4 -0
- package/dist/components/code-block/src/code-block-highlight.js +34 -0
- package/dist/components/code-block/src/code-block-utils.d.ts +23 -0
- package/dist/components/code-block/src/code-block-utils.js +71 -0
- package/dist/components/code-editor/index.d.ts +1 -1
- package/dist/components/code-editor/src/RsCodeEditor.css +118 -92
- package/dist/components/code-editor/src/RsCodeEditor.d.ts +14 -3
- package/dist/components/code-editor/src/RsCodeEditor.impl.js +261 -94
- package/dist/components/code-editor/src/RsCodeEditor.js +1 -1
- package/dist/components/code-editor/src/code-editor-utils.d.ts +15 -0
- package/dist/components/code-editor/src/code-editor-utils.js +36 -1
- package/dist/components/code-editor/src/code-mirror-completion.d.ts +1 -1
- package/dist/components/code-editor/src/code-mirror-completion.js +8 -5
- package/dist/components/code-editor/src/code-mirror-diagnostics.d.ts +2 -3
- package/dist/components/code-editor/src/code-mirror-diagnostics.js +3 -4
- package/dist/components/code-editor/src/code-mirror-ghost.d.ts +1 -1
- package/dist/components/code-editor/src/code-mirror-ghost.js +12 -3
- package/dist/components/code-editor/src/code-mirror-inline-edit.js +8 -3
- package/dist/components/code-editor/src/code-mirror-intel.d.ts +2 -2
- package/dist/components/code-editor/src/code-mirror-intel.js +50 -39
- package/dist/components/code-editor/src/code-mirror-lang.js +4 -0
- package/dist/components/code-editor/src/code-mirror-session.d.ts +13 -0
- package/dist/components/code-editor/src/code-mirror-session.js +30 -0
- package/dist/components/config-provider/src/RsConfigProvider.css +1 -1
- package/dist/components/config-provider/src/RsConfigProvider.d.ts +2 -2
- package/dist/components/config-provider/src/RsConfigProvider.impl.js +7 -16
- package/dist/components/config-provider/src/RsConfigProvider.js +1 -1
- package/dist/components/context-menu/index.d.ts +1 -1
- package/dist/components/context-menu/src/RsContextMenu.css +115 -89
- package/dist/components/context-menu/src/RsContextMenu.d.ts +32 -11
- package/dist/components/context-menu/src/RsContextMenu.impl.js +795 -48
- package/dist/components/context-menu/src/RsContextMenuItems.d.ts +25 -1
- package/dist/components/context-menu/src/RsContextMenuItems.impl.js +110 -61
- package/dist/components/context-menu/src/context-menu-utils.d.ts +89 -3
- package/dist/components/context-menu/src/context-menu-utils.js +168 -3
- package/dist/components/date-picker/src/RsDatePicker.d.ts +2 -2
- package/dist/components/date-picker/src/RsDateTimePicker.d.ts +2 -2
- package/dist/components/descriptions/index.d.ts +1 -1
- package/dist/components/descriptions/src/RsDescriptions.css +38 -11
- package/dist/components/descriptions/src/RsDescriptions.d.ts +20 -4
- package/dist/components/descriptions/src/RsDescriptions.impl.js +89 -19
- package/dist/components/descriptions/src/RsDescriptionsItem.impl.js +13 -6
- package/dist/components/descriptions/src/descriptions-utils.d.ts +19 -0
- package/dist/components/descriptions/src/descriptions-utils.js +39 -1
- package/dist/components/dialog/index.d.ts +1 -1
- package/dist/components/dialog/src/RsConfirmDialog.css +47 -21
- package/dist/components/dialog/src/RsConfirmDialog.d.ts +19 -7
- package/dist/components/dialog/src/RsConfirmDialog.impl.js +349 -119
- package/dist/components/dialog/src/RsConfirmDialog.js +2 -1
- package/dist/components/dialog/src/RsDialog.css +102 -109
- package/dist/components/dialog/src/RsDialog.d.ts +34 -24
- package/dist/components/dialog/src/RsDialog.impl.js +410 -177
- package/dist/components/dialog/src/RsDialog.js +2 -1
- package/dist/components/dialog/src/dialog-utils.d.ts +40 -1
- package/dist/components/dialog/src/dialog-utils.js +152 -1
- package/dist/components/dialog/src/dialog-window.js +29 -8
- package/dist/components/drawer/index.d.ts +1 -1
- package/dist/components/drawer/src/RsDrawer.css +61 -29
- package/dist/components/drawer/src/RsDrawer.d.ts +37 -21
- package/dist/components/drawer/src/RsDrawer.impl.js +441 -223
- package/dist/components/drawer/src/drawer-utils.d.ts +35 -0
- package/dist/components/drawer/src/drawer-utils.js +131 -1
- package/dist/components/dropdown/index.d.ts +1 -1
- package/dist/components/dropdown/src/RsDropdown.css +140 -61
- package/dist/components/dropdown/src/RsDropdown.d.ts +39 -6
- package/dist/components/dropdown/src/RsDropdown.impl.js +693 -63
- package/dist/components/dropdown/src/RsDropdownItemView.impl.js +17 -7
- package/dist/components/dropdown/src/RsDropdownItems.d.ts +32 -3
- package/dist/components/dropdown/src/RsDropdownItems.impl.js +171 -59
- package/dist/components/dropdown/src/dropdown-utils.d.ts +50 -0
- package/dist/components/dropdown/src/dropdown-utils.js +103 -3
- package/dist/components/empty/index.d.ts +1 -0
- package/dist/components/empty/src/RsEmpty.css +105 -23
- package/dist/components/empty/src/RsEmpty.d.ts +27 -4
- package/dist/components/empty/src/RsEmpty.impl.js +154 -11
- package/dist/components/empty/src/RsEmpty.js +2 -1
- package/dist/components/empty/src/empty-utils.d.ts +28 -0
- package/dist/components/empty/src/empty-utils.js +55 -0
- package/dist/components/form/src/RsForm.d.ts +1 -1
- package/dist/components/input-number/src/RsInputNumber.d.ts +1 -1
- package/dist/components/label/src/RsLabel.d.ts +1 -1
- package/dist/components/loading/index.d.ts +1 -0
- package/dist/components/loading/src/RsLoading.css +13 -97
- package/dist/components/loading/src/RsLoading.d.ts +52 -2
- package/dist/components/loading/src/RsLoading.impl.js +216 -33
- package/dist/components/loading/src/RsLoading.js +2 -1
- package/dist/components/loading/src/loading-status.css +210 -0
- package/dist/components/loading/src/loading-status.d.ts +34 -0
- package/dist/components/loading/src/loading-status.impl.js +84 -0
- package/dist/components/loading/src/loading-status.js +8 -0
- package/dist/components/loading/src/loading-utils.d.ts +51 -4
- package/dist/components/loading/src/loading-utils.js +122 -0
- package/dist/components/loading-bar/index.d.ts +1 -0
- package/dist/components/loading-bar/src/RsLoadingBar.css +72 -8
- package/dist/components/loading-bar/src/RsLoadingBar.d.ts +55 -11
- package/dist/components/loading-bar/src/RsLoadingBar.impl.js +298 -57
- package/dist/components/loading-bar/src/RsLoadingBar.js +1 -1
- package/dist/components/loading-bar/src/loading-bar-utils.d.ts +69 -0
- package/dist/components/loading-bar/src/loading-bar-utils.js +97 -0
- package/dist/components/log/src/RsLog.css +52 -144
- package/dist/components/log/src/RsLog.d.ts +12 -11
- package/dist/components/log/src/RsLog.impl.js +181 -148
- package/dist/components/log/src/RsLog.js +1 -1
- package/dist/components/log/src/RsLogRow.css +152 -0
- package/dist/components/log/src/RsLogRow.d.ts +35 -0
- package/dist/components/log/src/RsLogRow.impl.js +91 -0
- package/dist/components/log/src/RsLogRow.js +8 -0
- package/dist/components/log/src/log-utils.d.ts +8 -0
- package/dist/components/log/src/log-utils.js +71 -10
- package/dist/components/markdown/index.d.ts +1 -1
- package/dist/components/markdown/src/RsMarkdown.css +75 -32
- package/dist/components/markdown/src/RsMarkdown.d.ts +6 -2
- package/dist/components/markdown/src/RsMarkdown.impl.js +185 -17
- package/dist/components/markdown/src/markdown-utils.d.ts +26 -0
- package/dist/components/markdown/src/markdown-utils.js +114 -12
- package/dist/components/mentions/src/RsMentions.d.ts +2 -2
- package/dist/components/menu/index.d.ts +1 -1
- package/dist/components/menu/src/RsMenu.css +70 -29
- package/dist/components/menu/src/RsMenu.d.ts +58 -4
- package/dist/components/menu/src/RsMenu.impl.js +93 -46
- package/dist/components/menu/src/RsMenuItems.d.ts +22 -5
- package/dist/components/menu/src/RsMenuItems.impl.js +506 -154
- package/dist/components/menu/src/menu-utils.d.ts +56 -0
- package/dist/components/menu/src/menu-utils.js +139 -6
- package/dist/components/monaco-editor/index.d.ts +1 -1
- package/dist/components/monaco-editor/src/RsMonacoEditor.css +28 -16
- package/dist/components/monaco-editor/src/RsMonacoEditor.d.ts +39 -41
- package/dist/components/monaco-editor/src/RsMonacoEditor.impl.js +212 -133
- package/dist/components/monaco-editor/src/RsMonacoEditor.js +1 -1
- package/dist/components/monaco-editor/src/monaco-editor-utils.d.ts +126 -0
- package/dist/components/monaco-editor/src/monaco-editor-utils.js +302 -0
- package/dist/components/pagination/index.d.ts +2 -2
- package/dist/components/pagination/src/RsPagination.css +93 -46
- package/dist/components/pagination/src/RsPagination.d.ts +68 -8
- package/dist/components/pagination/src/RsPagination.impl.js +229 -86
- package/dist/components/pagination/src/RsPagination.js +1 -1
- package/dist/components/pagination/src/pagination-utils.d.ts +59 -0
- package/dist/components/pagination/src/pagination-utils.js +105 -1
- package/dist/components/popover/index.d.ts +1 -0
- package/dist/components/popover/src/RsPopover.css +124 -14
- package/dist/components/popover/src/RsPopover.d.ts +38 -7
- package/dist/components/popover/src/RsPopover.impl.js +546 -35
- package/dist/components/popover/src/RsPopover.js +2 -1
- package/dist/components/popover/src/popover-utils.d.ts +24 -2
- package/dist/components/popover/src/popover-utils.js +55 -0
- package/dist/components/sidebar/index.d.ts +1 -0
- package/dist/components/sidebar/src/RsSidebar.css +91 -33
- package/dist/components/sidebar/src/RsSidebar.d.ts +17 -9
- package/dist/components/sidebar/src/RsSidebar.impl.js +124 -22
- package/dist/components/sidebar/src/RsSidebar.js +1 -1
- package/dist/components/sidebar/src/RsSidebarGroup.css +23 -6
- package/dist/components/sidebar/src/RsSidebarGroup.d.ts +6 -2
- package/dist/components/sidebar/src/RsSidebarGroup.impl.js +17 -4
- package/dist/components/sidebar/src/RsSidebarGroup.js +1 -1
- package/dist/components/sidebar/src/RsSidebarItem.css +50 -20
- package/dist/components/sidebar/src/RsSidebarItem.d.ts +21 -3
- package/dist/components/sidebar/src/RsSidebarItem.impl.js +71 -20
- package/dist/components/sidebar/src/RsSidebarItem.js +1 -1
- package/dist/components/sidebar/src/sidebar-utils.d.ts +47 -0
- package/dist/components/sidebar/src/sidebar-utils.js +72 -0
- package/dist/components/split-pane/index.d.ts +2 -2
- package/dist/components/split-pane/src/RsSplitPane.css +41 -30
- package/dist/components/split-pane/src/RsSplitPane.d.ts +6 -2
- package/dist/components/split-pane/src/RsSplitPane.impl.js +153 -45
- package/dist/components/split-pane/src/split-pane-utils.d.ts +23 -0
- package/dist/components/split-pane/src/split-pane-utils.js +18 -1
- package/dist/components/stat-card/index.d.ts +1 -0
- package/dist/components/stat-card/src/RsStatCard.css +129 -25
- package/dist/components/stat-card/src/RsStatCard.d.ts +40 -4
- package/dist/components/stat-card/src/RsStatCard.impl.js +106 -12
- package/dist/components/stat-card/src/RsStatCard.js +1 -1
- package/dist/components/stat-card/src/stat-card-utils.d.ts +39 -0
- package/dist/components/stat-card/src/stat-card-utils.js +113 -0
- package/dist/components/steps/index.d.ts +1 -1
- package/dist/components/steps/src/RsSteps.css +158 -37
- package/dist/components/steps/src/RsSteps.d.ts +69 -5
- package/dist/components/steps/src/RsSteps.impl.js +168 -28
- package/dist/components/steps/src/RsSteps.js +1 -1
- package/dist/components/steps/src/steps-utils.d.ts +51 -1
- package/dist/components/steps/src/steps-utils.js +67 -1
- package/dist/components/table/src/RsTable.impl.js +4 -2
- package/dist/components/table/src/composables/useRsTableContextMenu.d.ts +16 -0
- package/dist/components/table/src/composables/useRsTableContextMenu.js +1 -1
- package/dist/components/table/src/composables/useRsTableEngine.js +6 -2
- package/dist/components/table/src/composables/useRsTableScrollLayout.js +2 -0
- package/dist/components/table/src/composables/useRsTableShell.d.ts +16 -0
- package/dist/components/table/src/rs-table-props.d.ts +1 -1
- package/dist/components/table/src/rs-table-props.js +0 -1
- package/dist/components/table/src/table-body/RsTableBody.impl.js +1 -0
- package/dist/components/table/src/table-body/RsTableCell.impl.js +1 -1
- package/dist/components/table/src/table-body/RsTableCellEditor.impl.js +10 -2
- package/dist/components/table/src/table-body/RsTableColGroup.impl.js +1 -0
- package/dist/components/table/src/table-footer/RsTableSummaryRow.impl.js +1 -0
- package/dist/components/table/src/table-header/RsTableHeader.impl.js +1 -0
- package/dist/components/table/src/utils/table-utils.d.ts +10 -6
- package/dist/components/table/src/utils/table-utils.js +27 -25
- package/dist/components/table/style/rs-table.css +86 -28
- package/dist/components/tabs/index.d.ts +2 -2
- package/dist/components/tabs/src/RsTabs.css +225 -101
- package/dist/components/tabs/src/RsTabs.d.ts +37 -8
- package/dist/components/tabs/src/RsTabs.impl.js +400 -270
- package/dist/components/tabs/src/tabs-utils.d.ts +41 -2
- package/dist/components/tabs/src/tabs-utils.js +55 -1
- package/dist/components/terminal/index.d.ts +1 -1
- package/dist/components/terminal/src/RsTerminal.css +60 -37
- package/dist/components/terminal/src/RsTerminal.d.ts +36 -4
- package/dist/components/terminal/src/RsTerminal.impl.js +288 -68
- package/dist/components/terminal/src/RsTerminal.js +1 -1
- package/dist/components/terminal/src/terminal-utils.d.ts +42 -4
- package/dist/components/terminal/src/terminal-utils.js +113 -10
- package/dist/components/textarea/src/RsTextarea.d.ts +1 -1
- package/dist/components/time-picker/src/RsTimePicker.d.ts +2 -2
- package/dist/components/toaster/src/RsToaster.css +156 -203
- package/dist/components/toaster/src/RsToaster.d.ts +32 -2
- package/dist/components/toaster/src/RsToaster.impl.js +309 -34
- package/dist/components/toaster/src/toast-store.d.ts +95 -0
- package/dist/components/toaster/src/toast-store.js +177 -0
- package/dist/components/toaster/src/toast-utils.d.ts +60 -0
- package/dist/components/toaster/src/toast-utils.js +86 -0
- package/dist/components/toolbar/index.d.ts +1 -1
- package/dist/components/toolbar/src/RsToolbar.css +206 -32
- package/dist/components/toolbar/src/RsToolbar.d.ts +41 -16
- package/dist/components/toolbar/src/RsToolbar.impl.js +146 -18
- package/dist/components/toolbar/src/RsToolbar.js +2 -1
- package/dist/components/toolbar/src/toolbar-utils.d.ts +20 -0
- package/dist/components/toolbar/src/toolbar-utils.js +105 -0
- package/dist/components/tooltip/index.d.ts +1 -0
- package/dist/components/tooltip/src/RsTooltip.css +104 -26
- package/dist/components/tooltip/src/RsTooltip.d.ts +38 -16
- package/dist/components/tooltip/src/RsTooltip.impl.js +420 -51
- package/dist/components/tooltip/src/RsTooltip.js +2 -1
- package/dist/components/tooltip/src/RsTooltipProvider.d.ts +4 -4
- package/dist/components/tooltip/src/RsTooltipProvider.impl.js +51 -14
- package/dist/components/tooltip/src/tooltip-utils.d.ts +30 -0
- package/dist/components/tooltip/src/tooltip-utils.js +23 -0
- package/dist/components/tree/index.d.ts +2 -2
- package/dist/components/tree/src/RsTree.css +84 -75
- package/dist/components/tree/src/RsTree.d.ts +20 -20
- package/dist/components/tree/src/RsTree.impl.js +292 -66
- package/dist/components/tree/src/RsTree.js +1 -1
- package/dist/components/tree/src/tree-utils.d.ts +22 -0
- package/dist/components/tree/src/tree-utils.js +18 -4
- package/dist/components/tree-select/src/RsTreeSelect.d.ts +1 -1
- package/dist/components/virtual-list/index.d.ts +1 -1
- package/dist/components/virtual-list/src/RsVirtualList.css +64 -9
- package/dist/components/virtual-list/src/RsVirtualList.d.ts +31 -5
- package/dist/components/virtual-list/src/RsVirtualList.impl.js +425 -76
- package/dist/components/virtual-list/src/RsVirtualList.js +1 -1
- package/dist/components/virtual-list/src/virtual-list-utils.d.ts +64 -1
- package/dist/components/virtual-list/src/virtual-list-utils.js +215 -1
- package/dist/composables/useRsLoadingBar.d.ts +2 -5
- package/dist/composables/useRsLoadingBar.js +21 -5
- package/dist/composables/useRsTabsNav.d.ts +3 -1
- package/dist/composables/useRsTabsNav.js +96 -28
- package/dist/composables/useRsToast.d.ts +11 -13
- package/dist/composables/useRsToast.js +66 -17
- package/dist/index.d.ts +30 -21
- package/dist/index.js +14 -0
- package/dist/locale/apply.js +6 -1
- package/dist/locale/messages.js +128 -2
- package/dist/styles.css +465 -808
- package/dist/theme/brand.example.css +3 -2
- package/dist/vite-plugins/niuma-ui-host.js +1 -1
- package/package.json +2 -5
- package/dist/components/_shared/src/reka.d.ts +0 -2
- package/dist/components/_shared/src/reka.js +0 -2
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { useRsConfigOptional } from "../../../composables/useRsConfig.js";
|
|
2
|
+
import { resolveDirMode } from "../../../locale/apply.js";
|
|
1
3
|
import { useRsI18n } from "../../../composables/useRsI18n.js";
|
|
2
|
-
import
|
|
4
|
+
import { useResolvedRsComponentSize } from "../../_shared/src/resolve-size.js";
|
|
3
5
|
import RsInput_default from "../../input/src/RsInput.js";
|
|
4
6
|
import RsSelect_default from "../../select/src/RsSelect.js";
|
|
5
|
-
import { DEFAULT_PAGE_SIZE_OPTIONS, clampPage, getPageCount, getPaginationRange } from "./pagination-utils.js";
|
|
6
|
-
import { Fragment, computed,
|
|
7
|
+
import { DEFAULT_PAGE_SIZE_OPTIONS, buildPaginationPagerItems, clampPage, getPageCount, getPaginationRange, paginationItemKey, resolveAdjacentPagerKey, resolveFocusablePagerKeys, resolvePaginationKeyboardMove, resolvePaginationSize, shouldHidePagination } from "./pagination-utils.js";
|
|
8
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, guardReactiveProps, mergeModels, mergeProps, normalizeClass, normalizeProps, openBlock, ref, renderList, renderSlot, toDisplayString, unref, useModel, watch } from "vue";
|
|
7
9
|
//#region src/components/pagination/src/RsPagination.vue?vue&type=script&setup=true&lang.ts
|
|
8
|
-
var _hoisted_1 = ["aria-label"];
|
|
10
|
+
var _hoisted_1 = ["id", "aria-label"];
|
|
9
11
|
var _hoisted_2 = {
|
|
10
12
|
key: 0,
|
|
11
13
|
class: "rs-pagination__summary"
|
|
@@ -13,24 +15,39 @@ var _hoisted_2 = {
|
|
|
13
15
|
var _hoisted_3 = { class: "rs-pagination__buttons" };
|
|
14
16
|
var _hoisted_4 = {
|
|
15
17
|
key: 0,
|
|
16
|
-
class: "rs-pagination__ellipsis"
|
|
18
|
+
class: "rs-pagination__ellipsis",
|
|
19
|
+
"aria-hidden": "true"
|
|
17
20
|
};
|
|
18
21
|
var _hoisted_5 = {
|
|
22
|
+
key: 1,
|
|
23
|
+
class: "rs-pagination__simple"
|
|
24
|
+
};
|
|
25
|
+
var _hoisted_6 = [
|
|
26
|
+
"data-rs-pagination",
|
|
27
|
+
"disabled",
|
|
28
|
+
"tabindex",
|
|
29
|
+
"aria-current",
|
|
30
|
+
"aria-label",
|
|
31
|
+
"onClick"
|
|
32
|
+
];
|
|
33
|
+
var _hoisted_7 = {
|
|
19
34
|
key: 1,
|
|
20
35
|
class: "rs-pagination__jumper"
|
|
21
36
|
};
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var
|
|
37
|
+
var _hoisted_8 = { class: "rs-pagination__jumper-label" };
|
|
38
|
+
var _hoisted_9 = { class: "rs-pagination__jumper-input" };
|
|
39
|
+
var _hoisted_10 = {
|
|
25
40
|
key: 0,
|
|
26
41
|
class: "rs-pagination__jumper-suffix"
|
|
27
42
|
};
|
|
28
|
-
var
|
|
43
|
+
var _hoisted_11 = ["disabled"];
|
|
44
|
+
var _hoisted_12 = {
|
|
29
45
|
key: 2,
|
|
30
46
|
class: "rs-pagination__size"
|
|
31
47
|
};
|
|
32
48
|
var controlRadius = "sm";
|
|
33
49
|
var RsPagination_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
50
|
+
name: "RsPagination",
|
|
34
51
|
__name: "RsPagination",
|
|
35
52
|
props: /*@__PURE__*/ mergeModels({
|
|
36
53
|
total: {},
|
|
@@ -51,32 +68,74 @@ var RsPagination_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
51
68
|
type: Boolean,
|
|
52
69
|
default: false
|
|
53
70
|
},
|
|
71
|
+
showFirstLast: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: false
|
|
74
|
+
},
|
|
75
|
+
simple: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
default: false
|
|
78
|
+
},
|
|
79
|
+
hideOnSinglePage: {
|
|
80
|
+
type: Boolean,
|
|
81
|
+
default: false
|
|
82
|
+
},
|
|
54
83
|
pageSizeOptions: { default: () => DEFAULT_PAGE_SIZE_OPTIONS },
|
|
55
84
|
disabled: {
|
|
56
85
|
type: Boolean,
|
|
57
86
|
default: false
|
|
58
87
|
},
|
|
59
|
-
size: {
|
|
88
|
+
size: {},
|
|
89
|
+
align: { default: "start" },
|
|
90
|
+
ariaLabel: {},
|
|
91
|
+
id: {}
|
|
60
92
|
}, {
|
|
61
93
|
"page": { default: 1 },
|
|
62
94
|
"pageModifiers": {},
|
|
63
95
|
"pageSize": { default: 20 },
|
|
64
96
|
"pageSizeModifiers": {}
|
|
65
97
|
}),
|
|
66
|
-
emits: ["update:page", "update:pageSize"],
|
|
67
|
-
setup(__props) {
|
|
98
|
+
emits: /*@__PURE__*/ mergeModels(["change", "pageSizeChange"], ["update:page", "update:pageSize"]),
|
|
99
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
68
100
|
const page = useModel(__props, "page");
|
|
69
101
|
const pageSize = useModel(__props, "pageSize");
|
|
70
102
|
const props = __props;
|
|
71
|
-
const
|
|
103
|
+
const emit = __emit;
|
|
104
|
+
const { t, locale } = useRsI18n();
|
|
105
|
+
const config = useRsConfigOptional();
|
|
106
|
+
const rootRef = ref(null);
|
|
72
107
|
const jumpPageInput = ref(String(page.value));
|
|
108
|
+
const inheritedSize = useResolvedRsComponentSize(() => props.size);
|
|
109
|
+
const resolvedSize = computed(() => resolvePaginationSize(inheritedSize.value));
|
|
110
|
+
const writingDir = computed(() => resolveDirMode(config?.dir.value ?? "auto", locale.value));
|
|
73
111
|
const pageCount = computed(() => getPageCount(props.total, pageSize.value));
|
|
112
|
+
const hidden = computed(() => shouldHidePagination(props.hideOnSinglePage, pageCount.value));
|
|
74
113
|
const range = computed(() => getPaginationRange(page.value, pageCount.value, props.siblingCount));
|
|
114
|
+
const pagerItems = computed(() => buildPaginationPagerItems({
|
|
115
|
+
page: page.value,
|
|
116
|
+
pageCount: pageCount.value,
|
|
117
|
+
range: range.value,
|
|
118
|
+
simple: props.simple,
|
|
119
|
+
showFirstLast: props.showFirstLast,
|
|
120
|
+
disabled: props.disabled
|
|
121
|
+
}));
|
|
122
|
+
const focusableKeys = computed(() => resolveFocusablePagerKeys(pagerItems.value));
|
|
75
123
|
const summaryText = computed(() => t("pagination.summary", "{total, plural, one {# item} other {# items}}", { total: props.total }));
|
|
124
|
+
const simpleText = computed(() => t("pagination.simple", "{page} / {pageCount}", {
|
|
125
|
+
page: page.value,
|
|
126
|
+
pageCount: pageCount.value
|
|
127
|
+
}));
|
|
128
|
+
const navLabel = computed(() => props.ariaLabel || t("pagination.label"));
|
|
129
|
+
const summarySlot = computed(() => ({
|
|
130
|
+
total: props.total,
|
|
131
|
+
page: page.value,
|
|
132
|
+
pageSize: pageSize.value,
|
|
133
|
+
pageCount: pageCount.value
|
|
134
|
+
}));
|
|
76
135
|
const pageSizeSelectValue = computed({
|
|
77
136
|
get: () => String(pageSize.value),
|
|
78
137
|
set: (value) => {
|
|
79
|
-
|
|
138
|
+
setPageSize(Number(value));
|
|
80
139
|
}
|
|
81
140
|
});
|
|
82
141
|
const pageSizeSelectOptions = computed(() => props.pageSizeOptions.map((option) => ({
|
|
@@ -84,17 +143,67 @@ var RsPagination_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
84
143
|
value: String(option)
|
|
85
144
|
})));
|
|
86
145
|
const showJumper = computed(() => props.showQuickJumper && pageCount.value > 1);
|
|
87
|
-
|
|
88
|
-
const controlSize = computed(() => props.size);
|
|
146
|
+
const controlSize = computed(() => resolvedSize.value);
|
|
89
147
|
watch(pageCount, (count) => {
|
|
90
|
-
|
|
148
|
+
const next = clampPage(page.value, count);
|
|
149
|
+
if (next === page.value) return;
|
|
150
|
+
page.value = next;
|
|
151
|
+
emit("change", next, pageSize.value);
|
|
91
152
|
});
|
|
92
153
|
watch(page, (value) => {
|
|
93
154
|
jumpPageInput.value = String(value);
|
|
94
155
|
});
|
|
95
|
-
function
|
|
96
|
-
if (props.disabled) return;
|
|
97
|
-
|
|
156
|
+
function setPage(next) {
|
|
157
|
+
if (props.disabled) return false;
|
|
158
|
+
const clamped = clampPage(next, pageCount.value);
|
|
159
|
+
if (clamped === page.value) {
|
|
160
|
+
jumpPageInput.value = String(clamped);
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
page.value = clamped;
|
|
164
|
+
emit("change", clamped, pageSize.value);
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
function setPageSize(next) {
|
|
168
|
+
if (props.disabled) return false;
|
|
169
|
+
const size = Number.isFinite(next) && next > 0 ? Math.floor(next) : pageSize.value;
|
|
170
|
+
const sizeChanged = size !== pageSize.value;
|
|
171
|
+
if (sizeChanged) pageSize.value = size;
|
|
172
|
+
const nextPage = clampPage(page.value, getPageCount(props.total, size));
|
|
173
|
+
const pageChanged = nextPage !== page.value;
|
|
174
|
+
if (pageChanged) page.value = nextPage;
|
|
175
|
+
if (sizeChanged) emit("pageSizeChange", size, nextPage);
|
|
176
|
+
if (sizeChanged || pageChanged) emit("change", nextPage, size);
|
|
177
|
+
return sizeChanged;
|
|
178
|
+
}
|
|
179
|
+
function goTo(next) {
|
|
180
|
+
return setPage(next);
|
|
181
|
+
}
|
|
182
|
+
function prev() {
|
|
183
|
+
if (page.value <= 1) return void 0;
|
|
184
|
+
return setPage(page.value - 1) ? page.value : void 0;
|
|
185
|
+
}
|
|
186
|
+
function next() {
|
|
187
|
+
if (page.value >= pageCount.value) return void 0;
|
|
188
|
+
return setPage(page.value + 1) ? page.value : void 0;
|
|
189
|
+
}
|
|
190
|
+
function first() {
|
|
191
|
+
if (page.value <= 1) return void 0;
|
|
192
|
+
return setPage(1) ? page.value : void 0;
|
|
193
|
+
}
|
|
194
|
+
function last() {
|
|
195
|
+
if (page.value >= pageCount.value) return void 0;
|
|
196
|
+
return setPage(pageCount.value) ? page.value : void 0;
|
|
197
|
+
}
|
|
198
|
+
function findPager(key) {
|
|
199
|
+
return rootRef.value?.querySelector(`[data-rs-pagination="${key}"]`) ?? null;
|
|
200
|
+
}
|
|
201
|
+
function focus(targetPage) {
|
|
202
|
+
(findPager(targetPage != null ? paginationItemKey("page", clampPage(targetPage, pageCount.value)) : paginationItemKey("page", page.value)) ?? findPager(focusableKeys.value[0] ?? ""))?.focus();
|
|
203
|
+
}
|
|
204
|
+
function activate(item) {
|
|
205
|
+
if (item.disabled || item.type === "ellipsis" || item.type === "simple") return;
|
|
206
|
+
setPage(item.page);
|
|
98
207
|
}
|
|
99
208
|
function confirmJump() {
|
|
100
209
|
if (props.disabled) return;
|
|
@@ -103,90 +212,124 @@ var RsPagination_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
103
212
|
jumpPageInput.value = String(page.value);
|
|
104
213
|
return;
|
|
105
214
|
}
|
|
106
|
-
|
|
215
|
+
setPage(parsed);
|
|
107
216
|
jumpPageInput.value = String(page.value);
|
|
108
217
|
}
|
|
218
|
+
function itemAriaLabel(item) {
|
|
219
|
+
if (item.type === "page") return item.active ? t("pagination.current", "Page {page}, current", { page: item.page }) : t("pagination.pageN", "Page {page}", { page: item.page });
|
|
220
|
+
if (item.type === "first") return t("pagination.first");
|
|
221
|
+
if (item.type === "last") return t("pagination.last");
|
|
222
|
+
if (item.type === "prev") return t("pagination.prev");
|
|
223
|
+
if (item.type === "next") return t("pagination.next");
|
|
224
|
+
}
|
|
225
|
+
function defaultItemLabel(item) {
|
|
226
|
+
if (item.type === "page") return String(item.page);
|
|
227
|
+
if (item.type === "first") return t("pagination.first");
|
|
228
|
+
if (item.type === "last") return t("pagination.last");
|
|
229
|
+
if (item.type === "prev") return t("pagination.prev");
|
|
230
|
+
if (item.type === "next") return t("pagination.next");
|
|
231
|
+
if (item.type === "simple") return simpleText.value;
|
|
232
|
+
return "…";
|
|
233
|
+
}
|
|
234
|
+
function slotProps(item) {
|
|
235
|
+
return {
|
|
236
|
+
type: item.type,
|
|
237
|
+
page: item.page,
|
|
238
|
+
active: item.active,
|
|
239
|
+
disabled: item.disabled
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
function isButton(type) {
|
|
243
|
+
return type !== "ellipsis" && type !== "simple";
|
|
244
|
+
}
|
|
245
|
+
function onKeydown(event) {
|
|
246
|
+
if (props.disabled || hidden.value) return;
|
|
247
|
+
const target = event.target;
|
|
248
|
+
if (!(target instanceof HTMLElement) || !target.closest("[data-rs-pagination]")) return;
|
|
249
|
+
if (target.closest("input, textarea, select, [contenteditable=\"true\"]")) return;
|
|
250
|
+
if (target.closest(".rs-pagination__jumper, .rs-pagination__size")) return;
|
|
251
|
+
const move = resolvePaginationKeyboardMove(event.key, writingDir.value === "rtl");
|
|
252
|
+
if (move == null) return;
|
|
253
|
+
const nextKey = resolveAdjacentPagerKey(focusableKeys.value, target.closest("[data-rs-pagination]")?.dataset.rsPagination, move);
|
|
254
|
+
if (!nextKey) return;
|
|
255
|
+
event.preventDefault();
|
|
256
|
+
findPager(nextKey)?.focus();
|
|
257
|
+
}
|
|
258
|
+
__expose({
|
|
259
|
+
goTo,
|
|
260
|
+
prev,
|
|
261
|
+
next,
|
|
262
|
+
first,
|
|
263
|
+
last,
|
|
264
|
+
focus
|
|
265
|
+
});
|
|
109
266
|
return (_ctx, _cache) => {
|
|
110
|
-
return openBlock(), createElementBlock("nav", {
|
|
111
|
-
|
|
112
|
-
|
|
267
|
+
return !hidden.value ? (openBlock(), createElementBlock("nav", {
|
|
268
|
+
key: 0,
|
|
269
|
+
id: __props.id,
|
|
270
|
+
ref_key: "rootRef",
|
|
271
|
+
ref: rootRef,
|
|
272
|
+
class: normalizeClass(["rs-pagination", [
|
|
273
|
+
`rs-pagination--${resolvedSize.value}`,
|
|
274
|
+
`rs-pagination--align-${__props.align}`,
|
|
275
|
+
{
|
|
276
|
+
"rs-pagination--no-jump-confirm": !__props.showJumpConfirm,
|
|
277
|
+
"rs-pagination--disabled": __props.disabled,
|
|
278
|
+
"rs-pagination--simple": __props.simple
|
|
279
|
+
}
|
|
280
|
+
]]),
|
|
281
|
+
"aria-label": navLabel.value,
|
|
282
|
+
onKeydown
|
|
113
283
|
}, [
|
|
114
|
-
__props.showSummary ? (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString(summaryText.value), 1)) : createCommentVNode("", true),
|
|
115
|
-
createElementVNode("div", _hoisted_3, [
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
onClick: ($event) => go(item)
|
|
136
|
-
}, {
|
|
137
|
-
default: withCtx(() => [createTextVNode(toDisplayString(item), 1)]),
|
|
138
|
-
_: 2
|
|
139
|
-
}, 1032, [
|
|
140
|
-
"tone",
|
|
141
|
-
"size",
|
|
142
|
-
"class",
|
|
143
|
-
"disabled",
|
|
144
|
-
"onClick"
|
|
145
|
-
]))], 64);
|
|
146
|
-
}), 128)),
|
|
147
|
-
createVNode(RsButton_default, {
|
|
148
|
-
variant: "ghost",
|
|
149
|
-
size: controlSize.value,
|
|
150
|
-
radius: controlRadius,
|
|
151
|
-
disabled: __props.disabled || page.value >= pageCount.value,
|
|
152
|
-
onClick: _cache[1] || (_cache[1] = ($event) => go(page.value + 1))
|
|
153
|
-
}, {
|
|
154
|
-
default: withCtx(() => [createTextVNode(toDisplayString(unref(t)("pagination.next")), 1)]),
|
|
155
|
-
_: 1
|
|
156
|
-
}, 8, ["size", "disabled"])
|
|
157
|
-
]),
|
|
158
|
-
showJumper.value ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
159
|
-
createElementVNode("span", _hoisted_6, toDisplayString(unref(t)("pagination.jumpTo")), 1),
|
|
160
|
-
createElementVNode("div", _hoisted_7, [createVNode(RsInput_default, {
|
|
284
|
+
__props.showSummary ? (openBlock(), createElementBlock("span", _hoisted_2, [renderSlot(_ctx.$slots, "summary", normalizeProps(guardReactiveProps(summarySlot.value)), () => [createTextVNode(toDisplayString(summaryText.value), 1)], true)])) : createCommentVNode("", true),
|
|
285
|
+
createElementVNode("div", _hoisted_3, [(openBlock(true), createElementBlock(Fragment, null, renderList(pagerItems.value, (item) => {
|
|
286
|
+
return openBlock(), createElementBlock(Fragment, { key: item.key }, [item.type === "ellipsis" ? (openBlock(), createElementBlock("span", _hoisted_4, [renderSlot(_ctx.$slots, "item", mergeProps({ ref_for: true }, slotProps(item)), () => [_cache[2] || (_cache[2] = createTextVNode("…", -1))], true)])) : item.type === "simple" ? (openBlock(), createElementBlock("span", _hoisted_5, [renderSlot(_ctx.$slots, "item", mergeProps({ ref_for: true }, slotProps(item)), () => [createTextVNode(toDisplayString(simpleText.value), 1)], true)])) : isButton(item.type) ? (openBlock(), createElementBlock("button", {
|
|
287
|
+
key: 2,
|
|
288
|
+
type: "button",
|
|
289
|
+
class: normalizeClass(["rs-pagination__item", {
|
|
290
|
+
"rs-pagination__page": item.type === "page",
|
|
291
|
+
"rs-pagination__page--active": item.active,
|
|
292
|
+
"rs-pagination__item--active": item.active
|
|
293
|
+
}]),
|
|
294
|
+
"data-rs-pagination": item.key,
|
|
295
|
+
disabled: item.disabled,
|
|
296
|
+
tabindex: item.disabled ? -1 : 0,
|
|
297
|
+
"aria-current": item.active ? "page" : void 0,
|
|
298
|
+
"aria-label": itemAriaLabel(item),
|
|
299
|
+
onClick: ($event) => activate(item)
|
|
300
|
+
}, [renderSlot(_ctx.$slots, "item", mergeProps({ ref_for: true }, slotProps(item)), () => [createTextVNode(toDisplayString(defaultItemLabel(item)), 1)], true)], 10, _hoisted_6)) : createCommentVNode("", true)], 64);
|
|
301
|
+
}), 128))]),
|
|
302
|
+
showJumper.value ? (openBlock(), createElementBlock("div", _hoisted_7, [
|
|
303
|
+
createElementVNode("span", _hoisted_8, toDisplayString(unref(t)("pagination.jumpTo")), 1),
|
|
304
|
+
createElementVNode("div", _hoisted_9, [createVNode(RsInput_default, {
|
|
161
305
|
modelValue: jumpPageInput.value,
|
|
162
|
-
"onUpdate:modelValue": _cache[
|
|
306
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => jumpPageInput.value = $event),
|
|
163
307
|
size: controlSize.value,
|
|
164
308
|
radius: controlRadius,
|
|
165
309
|
disabled: __props.disabled,
|
|
310
|
+
"show-validate-message": false,
|
|
311
|
+
"aria-label": unref(t)("pagination.jumpTo"),
|
|
166
312
|
onPressEnter: confirmJump,
|
|
167
313
|
onBlur: confirmJump
|
|
168
314
|
}, null, 8, [
|
|
169
315
|
"modelValue",
|
|
170
316
|
"size",
|
|
171
|
-
"disabled"
|
|
317
|
+
"disabled",
|
|
318
|
+
"aria-label"
|
|
172
319
|
])]),
|
|
173
|
-
unref(t)("pagination.jumpPageSuffix") ? (openBlock(), createElementBlock("span",
|
|
174
|
-
__props.showJumpConfirm ? (openBlock(),
|
|
320
|
+
unref(t)("pagination.jumpPageSuffix") ? (openBlock(), createElementBlock("span", _hoisted_10, toDisplayString(unref(t)("pagination.jumpPageSuffix")), 1)) : createCommentVNode("", true),
|
|
321
|
+
__props.showJumpConfirm ? (openBlock(), createElementBlock("button", {
|
|
175
322
|
key: 1,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
class: "rs-pagination__jumper-btn",
|
|
323
|
+
type: "button",
|
|
324
|
+
class: "rs-pagination__item rs-pagination__jumper-btn",
|
|
325
|
+
"data-rs-pagination": "confirm",
|
|
180
326
|
disabled: __props.disabled,
|
|
181
327
|
onClick: confirmJump
|
|
182
|
-
},
|
|
183
|
-
default: withCtx(() => [createTextVNode(toDisplayString(unref(t)("pagination.jumpConfirm")), 1)]),
|
|
184
|
-
_: 1
|
|
185
|
-
}, 8, ["size", "disabled"])) : createCommentVNode("", true)
|
|
328
|
+
}, toDisplayString(unref(t)("pagination.jumpConfirm")), 9, _hoisted_11)) : createCommentVNode("", true)
|
|
186
329
|
])) : createCommentVNode("", true),
|
|
187
|
-
__props.showPageSize ? (openBlock(), createElementBlock("div",
|
|
330
|
+
__props.showPageSize ? (openBlock(), createElementBlock("div", _hoisted_12, [createVNode(RsSelect_default, {
|
|
188
331
|
modelValue: pageSizeSelectValue.value,
|
|
189
|
-
"onUpdate:modelValue": _cache[
|
|
332
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => pageSizeSelectValue.value = $event),
|
|
190
333
|
options: pageSizeSelectOptions.value,
|
|
191
334
|
size: controlSize.value,
|
|
192
335
|
radius: controlRadius,
|
|
@@ -200,7 +343,7 @@ var RsPagination_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
200
343
|
"disabled",
|
|
201
344
|
"placeholder"
|
|
202
345
|
])])) : createCommentVNode("", true)
|
|
203
|
-
],
|
|
346
|
+
], 42, _hoisted_1)) : createCommentVNode("", true);
|
|
204
347
|
};
|
|
205
348
|
}
|
|
206
349
|
});
|
|
@@ -3,6 +3,6 @@ import _plugin_vue_export_helper_default from "../../../_virtual/_plugin-vue_exp
|
|
|
3
3
|
import RsPagination_vue_vue_type_script_setup_true_lang_default from "./RsPagination.impl.js";
|
|
4
4
|
|
|
5
5
|
//#region src/components/pagination/src/RsPagination.vue
|
|
6
|
-
var RsPagination_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RsPagination_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-
|
|
6
|
+
var RsPagination_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RsPagination_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-84ae3155"]]);
|
|
7
7
|
//#endregion
|
|
8
8
|
export { RsPagination_default as default };
|
|
@@ -1,4 +1,44 @@
|
|
|
1
|
+
import type { RsComponentSize } from '../../../theme/types';
|
|
1
2
|
export declare const DEFAULT_PAGE_SIZE_OPTIONS: readonly [10, 20, 50, 100];
|
|
3
|
+
/**
|
|
4
|
+
* 分页尺寸(对齐 Ant Design Pagination:small / medium / large)。
|
|
5
|
+
* 不提供 ssm:页码按钮过小不利于点击。ConfigProvider 的 ssm 会落到 sm。
|
|
6
|
+
*/
|
|
7
|
+
export type RsPaginationSize = Extract<RsComponentSize, 'sm' | 'md' | 'lg'>;
|
|
8
|
+
export type RsPaginationAlign = 'start' | 'center' | 'end';
|
|
9
|
+
export type RsPaginationItemType = 'page' | 'prev' | 'next' | 'first' | 'last' | 'ellipsis' | 'simple';
|
|
10
|
+
export interface RsPaginationItemSlot {
|
|
11
|
+
type: RsPaginationItemType;
|
|
12
|
+
page: number;
|
|
13
|
+
active: boolean;
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface RsPaginationSummarySlot {
|
|
17
|
+
total: number;
|
|
18
|
+
page: number;
|
|
19
|
+
pageSize: number;
|
|
20
|
+
pageCount: number;
|
|
21
|
+
}
|
|
22
|
+
export interface RsPaginationPagerItem extends RsPaginationItemSlot {
|
|
23
|
+
key: string;
|
|
24
|
+
}
|
|
25
|
+
export interface RsPaginationExpose {
|
|
26
|
+
/** 跳到指定页。越界会夹紧。禁用或未变化时返回 false。 */
|
|
27
|
+
goTo: (page: number) => boolean;
|
|
28
|
+
/** 上一页。已在首页或禁用时返回 undefined。 */
|
|
29
|
+
prev: () => number | undefined;
|
|
30
|
+
/** 下一页。已在末页或禁用时返回 undefined。 */
|
|
31
|
+
next: () => number | undefined;
|
|
32
|
+
/** 第一页。已在首页或禁用时返回 undefined。 */
|
|
33
|
+
first: () => number | undefined;
|
|
34
|
+
/** 最后一页。已在末页或禁用时返回 undefined。 */
|
|
35
|
+
last: () => number | undefined;
|
|
36
|
+
/** 焦点落到指定页码按钮;未传则落到当前页。 */
|
|
37
|
+
focus: (page?: number) => void;
|
|
38
|
+
}
|
|
39
|
+
export type RsPaginationInstance = RsPaginationExpose & {
|
|
40
|
+
$el: HTMLElement;
|
|
41
|
+
};
|
|
2
42
|
export declare function getPageCount(total: number, pageSize: number): number;
|
|
3
43
|
export declare function clampPage(page: number, pageCount: number): number;
|
|
4
44
|
export declare function getPaginationRange(page: number, pageCount: number, siblingCount?: number): Array<number | 'ellipsis'>;
|
|
@@ -7,3 +47,22 @@ export declare function createPageSizeSelectOptions(options?: readonly number[])
|
|
|
7
47
|
label: string;
|
|
8
48
|
value: string;
|
|
9
49
|
}[];
|
|
50
|
+
/** 未传或非法尺寸落到 md;ssm 与 sm 都按 sm。 */
|
|
51
|
+
export declare function resolvePaginationSize(size?: RsComponentSize | null): RsPaginationSize;
|
|
52
|
+
export declare function shouldHidePagination(hideOnSinglePage: boolean, pageCount: number): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* 页码条键盘位移。左右在 RTL 下对调。
|
|
55
|
+
* Home / End 返回端点;不处理的键返回 null。
|
|
56
|
+
*/
|
|
57
|
+
export declare function resolvePaginationKeyboardMove(key: string, rtl?: boolean): number | 'start' | 'end' | null;
|
|
58
|
+
export declare function paginationItemKey(type: RsPaginationItemType, page?: number): string;
|
|
59
|
+
export declare function buildPaginationPagerItems(options: {
|
|
60
|
+
page: number;
|
|
61
|
+
pageCount: number;
|
|
62
|
+
range: ReadonlyArray<number | 'ellipsis'>;
|
|
63
|
+
simple: boolean;
|
|
64
|
+
showFirstLast: boolean;
|
|
65
|
+
disabled: boolean;
|
|
66
|
+
}): RsPaginationPagerItem[];
|
|
67
|
+
export declare function resolveFocusablePagerKeys(items: readonly RsPaginationPagerItem[]): string[];
|
|
68
|
+
export declare function resolveAdjacentPagerKey(keys: readonly string[], current: string | undefined, move: number | 'start' | 'end'): string | undefined;
|
|
@@ -49,5 +49,109 @@ function createPageSizeSelectOptions(options = DEFAULT_PAGE_SIZE_OPTIONS) {
|
|
|
49
49
|
value: String(value)
|
|
50
50
|
}));
|
|
51
51
|
}
|
|
52
|
+
/** 未传或非法尺寸落到 md;ssm 与 sm 都按 sm。 */
|
|
53
|
+
function resolvePaginationSize(size) {
|
|
54
|
+
if (size === "lg") return "lg";
|
|
55
|
+
if (size === "sm" || size === "ssm") return "sm";
|
|
56
|
+
return "md";
|
|
57
|
+
}
|
|
58
|
+
function shouldHidePagination(hideOnSinglePage, pageCount) {
|
|
59
|
+
return hideOnSinglePage && pageCount <= 1;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 页码条键盘位移。左右在 RTL 下对调。
|
|
63
|
+
* Home / End 返回端点;不处理的键返回 null。
|
|
64
|
+
*/
|
|
65
|
+
function resolvePaginationKeyboardMove(key, rtl = false) {
|
|
66
|
+
if (key === "Home") return "start";
|
|
67
|
+
if (key === "End") return "end";
|
|
68
|
+
if (key === "ArrowLeft") return rtl ? 1 : -1;
|
|
69
|
+
if (key === "ArrowRight") return rtl ? -1 : 1;
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
function paginationItemKey(type, page = 0) {
|
|
73
|
+
return type === "page" ? `page-${page}` : type;
|
|
74
|
+
}
|
|
75
|
+
function buildPaginationPagerItems(options) {
|
|
76
|
+
const { page, pageCount, range, simple, showFirstLast, disabled } = options;
|
|
77
|
+
const items = [];
|
|
78
|
+
const atFirst = page <= 1;
|
|
79
|
+
const atLast = page >= pageCount;
|
|
80
|
+
if (showFirstLast) items.push({
|
|
81
|
+
key: "first",
|
|
82
|
+
type: "first",
|
|
83
|
+
page: 1,
|
|
84
|
+
active: false,
|
|
85
|
+
disabled: disabled || atFirst
|
|
86
|
+
});
|
|
87
|
+
items.push({
|
|
88
|
+
key: "prev",
|
|
89
|
+
type: "prev",
|
|
90
|
+
page: Math.max(1, page - 1),
|
|
91
|
+
active: false,
|
|
92
|
+
disabled: disabled || atFirst
|
|
93
|
+
});
|
|
94
|
+
if (simple) items.push({
|
|
95
|
+
key: "simple",
|
|
96
|
+
type: "simple",
|
|
97
|
+
page,
|
|
98
|
+
active: false,
|
|
99
|
+
disabled: false
|
|
100
|
+
});
|
|
101
|
+
else {
|
|
102
|
+
let ellipsisIndex = 0;
|
|
103
|
+
for (const entry of range) {
|
|
104
|
+
if (entry === "ellipsis") {
|
|
105
|
+
items.push({
|
|
106
|
+
key: `ellipsis-${ellipsisIndex}`,
|
|
107
|
+
type: "ellipsis",
|
|
108
|
+
page: 0,
|
|
109
|
+
active: false,
|
|
110
|
+
disabled: false
|
|
111
|
+
});
|
|
112
|
+
ellipsisIndex += 1;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
items.push({
|
|
116
|
+
key: paginationItemKey("page", entry),
|
|
117
|
+
type: "page",
|
|
118
|
+
page: entry,
|
|
119
|
+
active: entry === page,
|
|
120
|
+
disabled
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
items.push({
|
|
125
|
+
key: "next",
|
|
126
|
+
type: "next",
|
|
127
|
+
page: Math.min(pageCount, page + 1),
|
|
128
|
+
active: false,
|
|
129
|
+
disabled: disabled || atLast
|
|
130
|
+
});
|
|
131
|
+
if (showFirstLast) items.push({
|
|
132
|
+
key: "last",
|
|
133
|
+
type: "last",
|
|
134
|
+
page: pageCount,
|
|
135
|
+
active: false,
|
|
136
|
+
disabled: disabled || atLast
|
|
137
|
+
});
|
|
138
|
+
return items;
|
|
139
|
+
}
|
|
140
|
+
function resolveFocusablePagerKeys(items) {
|
|
141
|
+
const keys = [];
|
|
142
|
+
for (const item of items) {
|
|
143
|
+
if (item.type === "ellipsis" || item.type === "simple" || item.disabled) continue;
|
|
144
|
+
keys.push(item.key);
|
|
145
|
+
}
|
|
146
|
+
return keys;
|
|
147
|
+
}
|
|
148
|
+
function resolveAdjacentPagerKey(keys, current, move) {
|
|
149
|
+
if (keys.length === 0) return void 0;
|
|
150
|
+
if (move === "start") return keys[0];
|
|
151
|
+
if (move === "end") return keys.at(-1);
|
|
152
|
+
let from = current ? keys.indexOf(current) : -1;
|
|
153
|
+
if (from < 0) from = move > 0 ? -1 : keys.length;
|
|
154
|
+
return keys[from + move];
|
|
155
|
+
}
|
|
52
156
|
//#endregion
|
|
53
|
-
export { DEFAULT_PAGE_SIZE_OPTIONS, clampPage, createPageSizeSelectOptions, getPageCount, getPaginationRange, slicePageData };
|
|
157
|
+
export { DEFAULT_PAGE_SIZE_OPTIONS, buildPaginationPagerItems, clampPage, createPageSizeSelectOptions, getPageCount, getPaginationRange, paginationItemKey, resolveAdjacentPagerKey, resolveFocusablePagerKeys, resolvePaginationKeyboardMove, resolvePaginationSize, shouldHidePagination, slicePageData };
|