@varlet/ui 1.22.0-alpha.4 → 1.22.0-alpha.65

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.
Files changed (42) hide show
  1. package/es/counter/Counter.js +1 -1
  2. package/es/index.js +10 -0
  3. package/es/input/input.css +1 -1
  4. package/es/input/input.less +3 -1
  5. package/es/less.js +2 -0
  6. package/es/locale/en-US.js +5 -1
  7. package/es/locale/zh-CN.js +5 -1
  8. package/es/menu/Menu.js +1 -2
  9. package/es/pagination/Pagination.js +350 -0
  10. package/es/pagination/PaginationSfc.css +0 -0
  11. package/es/pagination/PaginationSfc.less +0 -0
  12. package/es/pagination/index.js +8 -0
  13. package/es/pagination/pagination.css +1 -0
  14. package/es/pagination/pagination.less +148 -0
  15. package/es/pagination/porps.js +43 -0
  16. package/es/pagination/style/index.js +8 -0
  17. package/es/pagination/style/less.js +8 -0
  18. package/es/ripple/ripple.css +1 -1
  19. package/es/ripple/ripple.less +7 -1
  20. package/es/skeleton/skeleton.css +1 -1
  21. package/es/skeleton/skeleton.less +3 -1
  22. package/es/snackbar/style/index.js +1 -1
  23. package/es/snackbar/style/less.js +1 -1
  24. package/es/style.js +2 -0
  25. package/es/table/Table.js +43 -0
  26. package/es/table/TableSfc.css +0 -0
  27. package/es/table/TableSfc.less +0 -0
  28. package/es/table/index.js +8 -0
  29. package/es/table/style/index.js +4 -0
  30. package/es/table/style/less.js +4 -0
  31. package/es/table/table.css +1 -0
  32. package/es/table/table.less +103 -0
  33. package/es/umdIndex.js +10 -0
  34. package/es/utils/elements.js +6 -6
  35. package/highlight/attributes.json +46 -2
  36. package/highlight/tags.json +19 -0
  37. package/highlight/web-types.json +138 -2
  38. package/package.json +4 -3
  39. package/types/index.d.ts +2 -0
  40. package/types/pagination.d.ts +23 -0
  41. package/types/table.d.ts +11 -0
  42. package/umd/varlet.js +3 -2
@@ -28,7 +28,7 @@ export function render(_ctx, _cache) {
28
28
  return _openBlock(), _createElementBlock("div", _hoisted_1, [_createElementVNode("div", _mergeProps({
29
29
  class: ["var-counter__controller var-elevation--2", [_ctx.disabled || _ctx.formDisabled ? 'var-counter--disabled' : null, _ctx.errorMessage ? 'var-counter--error' : null]],
30
30
  style: {
31
- background: _ctx.color ? _ctx.color : null
31
+ background: _ctx.color ? _ctx.color : undefined
32
32
  }
33
33
  }, _ctx.$attrs), [_withDirectives(_createVNode(_component_var_icon, {
34
34
  class: _normalizeClass(["var-counter__decrement-button", [!_ctx.decrementButton ? 'var-counter--hidden' : null]]),
package/es/index.js CHANGED
@@ -31,6 +31,7 @@ import Loading, * as LoadingModule from './loading'
31
31
  import Locale, * as LocaleModule from './locale'
32
32
  import Menu, * as MenuModule from './menu'
33
33
  import Option, * as OptionModule from './option'
34
+ import Pagination, * as PaginationModule from './pagination'
34
35
  import Picker, * as PickerModule from './picker'
35
36
  import Popup, * as PopupModule from './popup'
36
37
  import Progress, * as ProgressModule from './progress'
@@ -53,6 +54,7 @@ import SwipeItem, * as SwipeItemModule from './swipe-item'
53
54
  import Switch, * as SwitchModule from './switch'
54
55
  import Tab, * as TabModule from './tab'
55
56
  import TabItem, * as TabItemModule from './tab-item'
57
+ import Table, * as TableModule from './table'
56
58
  import Tabs, * as TabsModule from './tabs'
57
59
  import TabsItems, * as TabsItemsModule from './tabs-items'
58
60
  import TimePicker, * as TimePickerModule from './time-picker'
@@ -91,6 +93,7 @@ export const _LoadingComponent = LoadingModule._LoadingComponent || {}
91
93
  export const _LocaleComponent = LocaleModule._LocaleComponent || {}
92
94
  export const _MenuComponent = MenuModule._MenuComponent || {}
93
95
  export const _OptionComponent = OptionModule._OptionComponent || {}
96
+ export const _PaginationComponent = PaginationModule._PaginationComponent || {}
94
97
  export const _PickerComponent = PickerModule._PickerComponent || {}
95
98
  export const _PopupComponent = PopupModule._PopupComponent || {}
96
99
  export const _ProgressComponent = ProgressModule._ProgressComponent || {}
@@ -113,6 +116,7 @@ export const _SwipeItemComponent = SwipeItemModule._SwipeItemComponent || {}
113
116
  export const _SwitchComponent = SwitchModule._SwitchComponent || {}
114
117
  export const _TabComponent = TabModule._TabComponent || {}
115
118
  export const _TabItemComponent = TabItemModule._TabItemComponent || {}
119
+ export const _TableComponent = TableModule._TableComponent || {}
116
120
  export const _TabsComponent = TabsModule._TabsComponent || {}
117
121
  export const _TabsItemsComponent = TabsItemsModule._TabsItemsComponent || {}
118
122
  export const _TimePickerComponent = TimePickerModule._TimePickerComponent || {}
@@ -153,6 +157,7 @@ function install(app) {
153
157
  Locale.install && app.use(Locale)
154
158
  Menu.install && app.use(Menu)
155
159
  Option.install && app.use(Option)
160
+ Pagination.install && app.use(Pagination)
156
161
  Picker.install && app.use(Picker)
157
162
  Popup.install && app.use(Popup)
158
163
  Progress.install && app.use(Progress)
@@ -175,6 +180,7 @@ function install(app) {
175
180
  Switch.install && app.use(Switch)
176
181
  Tab.install && app.use(Tab)
177
182
  TabItem.install && app.use(TabItem)
183
+ Table.install && app.use(Table)
178
184
  Tabs.install && app.use(Tabs)
179
185
  TabsItems.install && app.use(TabsItems)
180
186
  TimePicker.install && app.use(TimePicker)
@@ -216,6 +222,7 @@ export {
216
222
  Locale,
217
223
  Menu,
218
224
  Option,
225
+ Pagination,
219
226
  Picker,
220
227
  Popup,
221
228
  Progress,
@@ -238,6 +245,7 @@ export {
238
245
  Switch,
239
246
  Tab,
240
247
  TabItem,
248
+ Table,
241
249
  Tabs,
242
250
  TabsItems,
243
251
  TimePicker,
@@ -279,6 +287,7 @@ export default {
279
287
  Locale,
280
288
  Menu,
281
289
  Option,
290
+ Pagination,
282
291
  Picker,
283
292
  Popup,
284
293
  Progress,
@@ -301,6 +310,7 @@ export default {
301
310
  Switch,
302
311
  Tab,
303
312
  TabItem,
313
+ Table,
304
314
  Tabs,
305
315
  TabsItems,
306
316
  TimePicker,
@@ -1 +1 @@
1
- :root { --input-input-text-color: #555; --input-error-color: var(--color-danger); --input-blur-color: #888; --input-focus-color: var(--color-primary); --input-placeholder-size: 16px; --input-textarea-height: auto; --input-textarea-padding-top: 8px; --input-icon-padding: 16px 0 0; --input-icon-size: 20px; --input-line-size: 1px; --input-line-spread-size: 2px; --input-disabled-color: #aaa;}.var-input-footer-margin-enter-from,.var-input-footer-margin-leave-to { opacity: 0; margin-top: 2px !important;}.var-input-footer-margin-enter-active,.var-input-footer-margin-leave-active { transition: 0.2s all var(--cubic-bezier);}.var-input { width: 100%; color: var(--input-input-text-color);}.var-input__controller { width: 100%; display: flex; position: relative;}.var-input__wrap { position: relative; flex-grow: 1; display: flex; flex-direction: column; padding-top: var(--input-placeholder-size);}.var-input__icon { display: flex; align-items: center; padding: var(--input-icon-padding); font-size: 20px;}.var-input__placeholder { position: absolute; top: 50%; left: 0; transform-origin: left; transition-property: top, transform; transition-duration: 0.3s; transform: translate(0, calc(-50% + var(--input-placeholder-size) / 2)) scale(1); font-size: var(--input-placeholder-size);}.var-input__textarea-placeholder { position: absolute; top: 0; left: 0; transform-origin: left; transition: transform 0.3s; transform: translate(0, calc(var(--input-textarea-padding-top) + var(--input-placeholder-size))) scale(1); font-size: var(--input-placeholder-size);}.var-input__autocomplete { width: 0; height: 0; padding: 0; border: none; outline: none; font-size: 0;}.var-input__input { width: 100%; height: 32px; padding: 0; outline: none; border: none; font-size: inherit; background: transparent; color: var(--input-input-text-color); caret-color: var(--input-focus-color);}.var-input__line { width: 100%; height: var(--input-line-size); background: var(--input-blur-color);}.var-input__dot { width: 100%; height: var(--input-line-spread-size); background: var(--input-focus-color); transform: scaleX(0); transform-origin: center; transition: transform 0.3s var(--cubic-bezier);}.var-input__clear-icon[var-input-cover] { display: flex; margin-left: 4px;}.var-input--textarea { padding-top: var(--input-textarea-padding-top); height: var(--input-textarea-height);}.var-input--placeholder-hint { top: 0; transform: translate(0, 0) scale(0.75);}.var-input--placeholder-non-hint { top: 50%; transform: translate(0, -50%) scale(1);}.var-input--non-hint { padding-top: 0;}.var-input--placeholder-hidden { visibility: hidden;}.var-input--focus { color: var(--input-focus-color);}.var-input--spread { transform: scaleX(1);}.var-input--disabled { color: var(--input-disabled-color);}.var-input--error { color: var(--input-error-color);}.var-input--line-disabled { background: var(--input-disabled-color);}.var-input--line-error { background: var(--input-error-color);}.var-input--caret-error { caret-color: var(--input-error-color);}
1
+ :root { --input-input-text-color: #555; --input-error-color: var(--color-danger); --input-blur-color: #888; --input-focus-color: var(--color-primary); --input-placeholder-size: 16px; --input-textarea-height: auto; --input-textarea-padding-top: 8px; --input-icon-padding: 16px 0 0; --input-icon-size: 20px; --input-line-size: 1px; --input-line-spread-size: 2px; --input-disabled-color: var(--color-disabled);}.var-input-footer-margin-enter-from,.var-input-footer-margin-leave-to { opacity: 0; margin-top: 2px !important;}.var-input-footer-margin-enter-active,.var-input-footer-margin-leave-active { transition: 0.2s all var(--cubic-bezier);}.var-input { width: 100%; color: var(--input-input-text-color);}.var-input__controller { width: 100%; display: flex; position: relative;}.var-input__wrap { position: relative; flex-grow: 1; display: flex; flex-direction: column; padding-top: var(--input-placeholder-size);}.var-input__icon { display: flex; align-items: center; padding: var(--input-icon-padding); font-size: 20px;}.var-input__placeholder { position: absolute; top: 50%; left: 0; transform-origin: left; transition-property: top, transform; transition-duration: 0.3s; transform: translate(0, calc(-50% + var(--input-placeholder-size) / 2)) scale(1); font-size: var(--input-placeholder-size);}.var-input__textarea-placeholder { position: absolute; top: 0; left: 0; transform-origin: left; transition: transform 0.3s; transform: translate(0, calc(var(--input-textarea-padding-top) + var(--input-placeholder-size))) scale(1); font-size: var(--input-placeholder-size);}.var-input__autocomplete { width: 0; height: 0; padding: 0; border: none; outline: none; font-size: 0;}.var-input__input { width: 100%; height: 32px; padding: 0; outline: none; border: none; font-size: inherit; background: transparent; color: var(--input-input-text-color); caret-color: var(--input-focus-color);}.var-input__line { width: 100%; height: var(--input-line-size); background: var(--input-blur-color);}.var-input__dot { width: 100%; height: var(--input-line-spread-size); background: var(--input-focus-color); transform: scaleX(0); transform-origin: center; transition: transform 0.3s var(--cubic-bezier);}.var-input__clear-icon[var-input-cover] { display: flex; margin-left: 4px;}.var-input--textarea { padding-top: var(--input-textarea-padding-top); height: var(--input-textarea-height);}.var-input--placeholder-hint { top: 0; transform: translate(0, 0) scale(0.75);}.var-input--placeholder-non-hint { top: 50%; transform: translate(0, -50%) scale(1);}.var-input--non-hint { padding-top: 0;}.var-input--placeholder-hidden { visibility: hidden;}.var-input--focus { color: var(--input-focus-color);}.var-input--spread { transform: scaleX(1);}.var-input--disabled { -webkit-text-fill-color: var(--input-disabled-color); opacity: 1; color: var(--input-disabled-color);}.var-input--error { color: var(--input-error-color);}.var-input--line-disabled { background: var(--input-disabled-color);}.var-input--line-error { background: var(--input-error-color);}.var-input--caret-error { caret-color: var(--input-error-color);}
@@ -9,7 +9,7 @@
9
9
  @input-icon-size: 20px;
10
10
  @input-line-size: 1px;
11
11
  @input-line-spread-size: 2px;
12
- @input-disabled-color: #aaa;
12
+ @input-disabled-color: var(--color-disabled);
13
13
 
14
14
  :root {
15
15
  --input-input-text-color: @input-input-text-color;
@@ -158,6 +158,8 @@
158
158
  }
159
159
 
160
160
  &--disabled {
161
+ -webkit-text-fill-color: var(--input-disabled-color);
162
+ opacity: 1;
161
163
  color: var(--input-disabled-color);
162
164
  }
163
165
 
package/es/less.js CHANGED
@@ -31,6 +31,7 @@ import './loading/style/less'
31
31
  import './locale/style/less'
32
32
  import './menu/style/less'
33
33
  import './option/style/less'
34
+ import './pagination/style/less'
34
35
  import './picker/style/less'
35
36
  import './popup/style/less'
36
37
  import './progress/style/less'
@@ -53,6 +54,7 @@ import './swipe-item/style/less'
53
54
  import './switch/style/less'
54
55
  import './tab/style/less'
55
56
  import './tab-item/style/less'
57
+ import './table/style/less'
56
58
  import './tabs/style/less'
57
59
  import './tabs-items/style/less'
58
60
  import './time-picker/style/less'
@@ -94,5 +94,9 @@ export default {
94
94
  abbr: 'S'
95
95
  }
96
96
  },
97
- selected: ' selected'
97
+ selected: ' selected',
98
+ // pagination
99
+ paginationItem: '',
100
+ paginationPage: 'page',
101
+ paginationJump: 'Go to'
98
102
  };
@@ -94,5 +94,9 @@ export default {
94
94
  abbr: '六'
95
95
  }
96
96
  },
97
- selected: '个被选择'
97
+ selected: '个被选择',
98
+ // pagination
99
+ paginationItem: '条',
100
+ paginationPage: '页',
101
+ paginationJump: '前往'
98
102
  };
package/es/menu/Menu.js CHANGED
@@ -2,7 +2,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
2
2
 
3
3
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
4
4
 
5
- import { defineComponent, ref, watch, onMounted, onUnmounted, nextTick } from 'vue';
5
+ import { defineComponent, ref, watch, onMounted, onUnmounted } from 'vue';
6
6
  import { props } from './props';
7
7
  import { getLeft, getTop, toSizeUnit } from '../utils/elements';
8
8
  import { useZIndex } from '../context/zIndex';
@@ -93,7 +93,6 @@ export default defineComponent({
93
93
  onOpen,
94
94
  onClose
95
95
  } = props;
96
- yield nextTick();
97
96
  newValue && resize();
98
97
  newValue ? onOpen == null ? void 0 : onOpen() : onClose == null ? void 0 : onClose();
99
98
  });
@@ -0,0 +1,350 @@
1
+ import Menu from '../menu';
2
+ import Ripple from '../ripple';
3
+ import Icon from '../icon';
4
+ import Cell from '../cell';
5
+ import Input from '../input';
6
+ import { defineComponent, ref, computed, watch } from 'vue';
7
+ import { props } from './porps';
8
+ import { isNumber, toNumber } from '../utils/shared';
9
+ import { pack } from '../locale';
10
+ import { renderSlot as _renderSlot, resolveComponent as _resolveComponent, createVNode as _createVNode, normalizeClass as _normalizeClass, resolveDirective as _resolveDirective, createElementVNode as _createElementVNode, withDirectives as _withDirectives, withKeys as _withKeys, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, renderList as _renderList, Fragment as _Fragment, withCtx as _withCtx, createBlock as _createBlock, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
11
+
12
+ var _withScopeId = n => (_pushScopeId(""), n = n(), _popScopeId(), n);
13
+
14
+ var _hoisted_1 = {
15
+ class: "var-pagination"
16
+ };
17
+ var _hoisted_2 = ["item-mode", "onClick"];
18
+ var _hoisted_3 = {
19
+ key: 4,
20
+ class: "var-pagination__total"
21
+ };
22
+ export function render(_ctx, _cache) {
23
+ var _component_var_icon = _resolveComponent("var-icon");
24
+
25
+ var _component_var_input = _resolveComponent("var-input");
26
+
27
+ var _component_var_cell = _resolveComponent("var-cell");
28
+
29
+ var _component_var_menu = _resolveComponent("var-menu");
30
+
31
+ var _directive_ripple = _resolveDirective("ripple");
32
+
33
+ return _openBlock(), _createElementBlock("ul", _hoisted_1, [_withDirectives(_createElementVNode("li", {
34
+ class: _normalizeClass(["var-pagination__item var-pagination__prev", {
35
+ 'var-pagination__item-disabled': _ctx.current <= 1 || _ctx.disabled,
36
+ 'var-elevation--2': !_ctx.simple
37
+ }]),
38
+ onClick: _cache[0] || (_cache[0] = $event => _ctx.clickItem('prev'))
39
+ }, [_renderSlot(_ctx.$slots, "prev", {}, () => [_createVNode(_component_var_icon, {
40
+ name: "chevron-left"
41
+ })])], 2
42
+ /* CLASS */
43
+ ), [[_directive_ripple, {
44
+ disabled: _ctx.current <= 1 || _ctx.disabled
45
+ }]]), _ctx.simple ? (_openBlock(), _createElementBlock("li", {
46
+ key: 0,
47
+ class: _normalizeClass(["var-pagination__simple", {
48
+ 'var-pagination__item-disabled': _ctx.disabled
49
+ }])
50
+ }, [_createVNode(_component_var_input, {
51
+ modelValue: _ctx.simpleValue,
52
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = $event => _ctx.simpleValue = $event),
53
+ disabled: _ctx.disabled,
54
+ "var-pagination-cover": "",
55
+ onBlur: _cache[2] || (_cache[2] = $event => _ctx.setPage('simple', _ctx.simpleValue, $event)),
56
+ onKeydown: _cache[3] || (_cache[3] = _withKeys($event => _ctx.setPage('simple', _ctx.simpleValue, $event), ["enter"]))
57
+ }, null, 8
58
+ /* PROPS */
59
+ , ["modelValue", "disabled"]), _createTextVNode(" / " + _toDisplayString(_ctx.pageCount), 1
60
+ /* TEXT */
61
+ )], 2
62
+ /* CLASS */
63
+ )) : (_openBlock(true), _createElementBlock(_Fragment, {
64
+ key: 1
65
+ }, _renderList(_ctx.pageList, (item, index) => {
66
+ return _withDirectives((_openBlock(), _createElementBlock("li", {
67
+ key: item + index,
68
+ "item-mode": _ctx.getMode(item, index),
69
+ class: _normalizeClass(["var-pagination__item var-elevation--2", {
70
+ 'var-pagination__item-active': item === _ctx.current,
71
+ 'var-pagination__item-hide': _ctx.isHideEllipsis(item, index),
72
+ 'var-pagination__item-disabled': _ctx.disabled
73
+ }]),
74
+ onClick: $event => _ctx.clickItem(item, index)
75
+ }, [_createTextVNode(_toDisplayString(item), 1
76
+ /* TEXT */
77
+ )], 10
78
+ /* CLASS, PROPS */
79
+ , _hoisted_2)), [[_directive_ripple, {
80
+ disabled: _ctx.disabled
81
+ }]]);
82
+ }), 128
83
+ /* KEYED_FRAGMENT */
84
+ )), _withDirectives(_createElementVNode("li", {
85
+ class: _normalizeClass(["var-pagination__item var-pagination__next", {
86
+ 'var-pagination__item-disabled': _ctx.current >= _ctx.pageCount || _ctx.disabled,
87
+ 'var-elevation--2': !_ctx.simple
88
+ }]),
89
+ onClick: _cache[4] || (_cache[4] = $event => _ctx.clickItem('next'))
90
+ }, [_renderSlot(_ctx.$slots, "next", {}, () => [_createVNode(_component_var_icon, {
91
+ name: "chevron-right"
92
+ })])], 2
93
+ /* CLASS */
94
+ ), [[_directive_ripple, {
95
+ disabled: _ctx.current >= _ctx.pageCount || _ctx.disabled
96
+ }]]), _ctx.showSizeChanger ? (_openBlock(), _createElementBlock("li", {
97
+ key: 2,
98
+ class: _normalizeClass(["var-pagination__size", {
99
+ 'var-pagination__item-disabled': _ctx.disabled
100
+ }])
101
+ }, [_createVNode(_component_var_menu, {
102
+ show: _ctx.menuVisible,
103
+ "onUpdate:show": _cache[6] || (_cache[6] = $event => _ctx.menuVisible = $event),
104
+ "offset-x": -4
105
+ }, {
106
+ menu: _withCtx(() => [(_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.sizeOption, (option, index) => {
107
+ return _withDirectives((_openBlock(), _createBlock(_component_var_cell, {
108
+ class: _normalizeClass(["var-pagination__list", {
109
+ 'var-pagination__list-active': _ctx.size === option
110
+ }]),
111
+ key: index,
112
+ onClick: $event => _ctx.clickSize(option)
113
+ }, {
114
+ default: _withCtx(() => [_createTextVNode(_toDisplayString(option) + _toDisplayString(_ctx.pack.paginationItem) + " / " + _toDisplayString(_ctx.pack.paginationPage), 1
115
+ /* TEXT */
116
+ )]),
117
+ _: 2
118
+ /* DYNAMIC */
119
+
120
+ }, 1032
121
+ /* PROPS, DYNAMIC_SLOTS */
122
+ , ["class", "onClick"])), [[_directive_ripple]]);
123
+ }), 128
124
+ /* KEYED_FRAGMENT */
125
+ ))]),
126
+ default: _withCtx(() => [_createElementVNode("div", {
127
+ class: "var-pagination__size-open",
128
+ style: {
129
+ "display": "flex"
130
+ },
131
+ onClick: _cache[5] || (_cache[5] = (...args) => _ctx.showMenu && _ctx.showMenu(...args))
132
+ }, [_createElementVNode("span", null, _toDisplayString(_ctx.size) + _toDisplayString(_ctx.pack.paginationItem) + " / " + _toDisplayString(_ctx.pack.paginationPage), 1
133
+ /* TEXT */
134
+ ), _createVNode(_component_var_icon, {
135
+ class: "var-pagination__size-open-icon",
136
+ "var-pagination-cover": "",
137
+ name: "menu-down"
138
+ })])]),
139
+ _: 1
140
+ /* STABLE */
141
+
142
+ }, 8
143
+ /* PROPS */
144
+ , ["show"])], 2
145
+ /* CLASS */
146
+ )) : _createCommentVNode("v-if", true), _ctx.showQuickJumper && !_ctx.simple ? (_openBlock(), _createElementBlock("li", {
147
+ key: 3,
148
+ class: _normalizeClass(["var-pagination__quickly", {
149
+ 'var-pagination__item-disabled': _ctx.disabled
150
+ }])
151
+ }, [_createTextVNode(_toDisplayString(_ctx.pack.paginationJump) + " ", 1
152
+ /* TEXT */
153
+ ), _createVNode(_component_var_input, {
154
+ modelValue: _ctx.inputValue,
155
+ "onUpdate:modelValue": _cache[7] || (_cache[7] = $event => _ctx.inputValue = $event),
156
+ disabled: _ctx.disabled,
157
+ "var-pagination-cover": "",
158
+ onBlur: _cache[8] || (_cache[8] = $event => _ctx.setPage('quick', _ctx.inputValue, $event)),
159
+ onKeydown: _cache[9] || (_cache[9] = _withKeys($event => _ctx.setPage('quick', _ctx.inputValue, $event), ["enter"]))
160
+ }, null, 8
161
+ /* PROPS */
162
+ , ["modelValue", "disabled"])], 2
163
+ /* CLASS */
164
+ )) : _createCommentVNode("v-if", true), _ctx.totalText ? (_openBlock(), _createElementBlock("li", _hoisted_3, _toDisplayString(_ctx.totalText), 1
165
+ /* TEXT */
166
+ )) : _createCommentVNode("v-if", true)]);
167
+ }
168
+ export default defineComponent({
169
+ render,
170
+ name: 'VarPagination',
171
+ components: {
172
+ [Menu.name]: Menu,
173
+ [Icon.name]: Icon,
174
+ [Cell.name]: Cell,
175
+ [Input.name]: Input
176
+ },
177
+ directives: {
178
+ Ripple
179
+ },
180
+ props,
181
+
182
+ setup(props) {
183
+ var menuVisible = ref(false);
184
+ var inputValue = ref('');
185
+ var simpleValue = ref('1');
186
+ var isHideEllipsisHead = ref(false);
187
+ var isHideEllipsisTail = ref(false);
188
+ var current = ref(toNumber(props.current) || 1);
189
+ var size = ref(toNumber(props.size) || 10);
190
+ var pageList = ref([]);
191
+ var activePosition = computed(() => Math.ceil(props.maxPagerCount / 2));
192
+ var pageCount = computed(() => Math.ceil(toNumber(props.total) / toNumber(size.value)));
193
+ var range = computed(() => {
194
+ var start = size.value * (current.value - 1) + 1;
195
+ var end = Math.min(size.value * current.value, toNumber(props.total));
196
+ return [start, end];
197
+ });
198
+ var totalText = computed(() => {
199
+ if (!props.showTotal) return '';
200
+ return props.showTotal(toNumber(props.total), range.value);
201
+ });
202
+
203
+ var isHideEllipsis = (item, index) => {
204
+ if (isNumber(item)) return false;
205
+ return index === 1 ? isHideEllipsisHead.value : isHideEllipsisTail.value;
206
+ };
207
+
208
+ var getMode = (item, index) => {
209
+ if (isNumber(item)) return 'basic';
210
+ return index === 1 ? 'head' : 'tail';
211
+ };
212
+
213
+ var clickItem = (item, index) => {
214
+ if (item === current.value || props.disabled) return;
215
+ if (isNumber(item)) current.value = item;else if (item === 'prev') current.value > 1 && (current.value -= 1);else if (item === 'next') current.value < pageCount.value && (current.value += 1);else if (item === '...') {
216
+ if (index === 1) {
217
+ current.value = Math.max(current.value - props.maxPagerCount, 1);
218
+ } else {
219
+ current.value = Math.min(current.value + props.maxPagerCount, pageCount.value);
220
+ }
221
+ }
222
+ };
223
+
224
+ var showMenu = () => {
225
+ if (props.disabled) return;
226
+ menuVisible.value = true;
227
+ };
228
+
229
+ var clickSize = option => {
230
+ size.value = option;
231
+ menuVisible.value = false;
232
+ };
233
+
234
+ var isValidatePage = value => {
235
+ var pattern = /^[1-9][0-9]*$/;
236
+ return pattern.test(value);
237
+ };
238
+
239
+ var setPage = (type, value, event) => {
240
+ ;
241
+ event.target.blur();
242
+
243
+ if (isValidatePage(value)) {
244
+ var valueNum = toNumber(value);
245
+
246
+ if (valueNum > pageCount.value) {
247
+ valueNum = pageCount.value;
248
+ simpleValue.value = "" + valueNum;
249
+ }
250
+
251
+ if (valueNum !== current.value) current.value = valueNum;
252
+ }
253
+
254
+ if (type === 'quick') inputValue.value = '';
255
+ if (type === 'simple' && !isValidatePage(value)) simpleValue.value = "" + current.value;
256
+ };
257
+
258
+ watch([() => props.current, () => props.size], ([newCurrent, newSize]) => {
259
+ current.value = toNumber(newCurrent) || 1;
260
+ size.value = toNumber(newSize || 10);
261
+ });
262
+ watch([current, pageCount], ([newCurrent, newCount], [oldCurrent, oldCount]) => {
263
+ if (newCurrent > newCount) {
264
+ current.value = newCount;
265
+ return;
266
+ }
267
+
268
+ var list = [];
269
+ var {
270
+ maxPagerCount
271
+ } = props;
272
+ var rEllipseSign = newCount - (maxPagerCount - activePosition.value) - 1;
273
+ simpleValue.value = "" + newCurrent;
274
+
275
+ if (newCount - 2 > maxPagerCount) {
276
+ if (oldCurrent === undefined || newCount !== oldCount) {
277
+ for (var i = 2; i < maxPagerCount + 2; i++) {
278
+ list.push(i);
279
+ }
280
+ } // 左边不需要出现省略符号占位
281
+
282
+
283
+ if (newCurrent <= maxPagerCount && newCurrent < rEllipseSign) {
284
+ list = [];
285
+
286
+ for (var _i = 1; _i < maxPagerCount + 1; _i++) {
287
+ list.push(_i + 1);
288
+ }
289
+
290
+ isHideEllipsisHead.value = true;
291
+ isHideEllipsisTail.value = false;
292
+ } // 两边都需要出现省略符号占位
293
+
294
+
295
+ if (newCurrent > maxPagerCount && newCurrent < rEllipseSign) {
296
+ list = [];
297
+
298
+ for (var _i2 = 1; _i2 < maxPagerCount + 1; _i2++) {
299
+ list.push(newCurrent + _i2 - activePosition.value);
300
+ } // 针对 maxPagerCount===1 的特殊处理
301
+
302
+
303
+ isHideEllipsisHead.value = newCurrent === 2 && maxPagerCount === 1;
304
+ isHideEllipsisTail.value = false;
305
+ } // 右边不需要出现省略符号占位
306
+
307
+
308
+ if (newCurrent >= rEllipseSign) {
309
+ list = [];
310
+
311
+ for (var _i3 = 1; _i3 < maxPagerCount + 1; _i3++) {
312
+ list.push(newCount - (maxPagerCount - _i3) - 1);
313
+ }
314
+
315
+ isHideEllipsisHead.value = false;
316
+ isHideEllipsisTail.value = true;
317
+ }
318
+
319
+ list = [1, '...', ...list, '...', newCount];
320
+ } else {
321
+ for (var _i4 = 1; _i4 <= newCount; _i4++) {
322
+ list.push(_i4);
323
+ }
324
+ }
325
+
326
+ pageList.value = list;
327
+ if (oldCurrent !== undefined) props.onChange == null ? void 0 : props.onChange(newCurrent, size.value);
328
+ }, {
329
+ immediate: true
330
+ });
331
+ return {
332
+ pack,
333
+ current,
334
+ menuVisible,
335
+ size,
336
+ pageCount,
337
+ pageList,
338
+ inputValue,
339
+ simpleValue,
340
+ totalText,
341
+ getMode,
342
+ isHideEllipsis,
343
+ clickItem,
344
+ showMenu,
345
+ clickSize,
346
+ setPage
347
+ };
348
+ }
349
+
350
+ });
File without changes
File without changes
@@ -0,0 +1,8 @@
1
+ import Pagination from './Pagination.js'
2
+
3
+ Pagination.install = function (app) {
4
+ app.component(Pagination.name, Pagination);
5
+ };
6
+
7
+ export var _PaginationComponent = Pagination;
8
+ export default Pagination;
@@ -0,0 +1 @@
1
+ :root { --pagination-font-size: var(--font-size-md); --pagination-active-color: #fff; --pagination-active-bg-color: var(--color-primary); --pagination-hover-bg-color: #f5f5f5; --pagination-total-margin: 0 12px; --pagination-item-width: 32px; --pagination-item-height: 32px; --pagination-item-margin: 0 6px; --pagination-item-border-radius: 4px; --pagination-list-bg-color: #fff; --pagination-list-active-bg-color: #dbe4fd; --pagination-list-active-color: var(--color-primary); --pagination-input-width: 32px; --pagination-simple-padding: 0 0 2px 0; --pagination-disabled-color: var(--color-disabled);}.pagination-flex-nowrap { display: flex; white-space: nowrap; align-items: center;}.var-pagination { display: flex; list-style: none; margin: 0; font-size: var(--pagination-font-size); padding: 0;}.var-pagination__item { display: inline-flex; min-width: var(--pagination-item-width); align-items: center; justify-content: center; margin: var(--pagination-item-margin); height: var(--pagination-item-height); cursor: pointer; border-radius: var(--pagination-item-border-radius); outline: none; transition: all 0.3s; user-select: none;}.var-pagination__item:hover { background-color: var(--pagination-hover-bg-color);}.var-pagination__item-active { color: var(--pagination-active-color); background-color: var(--pagination-active-bg-color) !important;}.var-pagination__item-hide { display: none;}.var-pagination__item-disabled { cursor: default !important; color: var(--pagination-disabled-color);}.var-pagination__item-disabled:hover { background-color: unset;}.var-pagination__prev { margin-left: 0;}.var-pagination__total { margin: var(--pagination-total-margin); display: flex; white-space: nowrap; align-items: center;}.var-pagination__size { display: flex; white-space: nowrap; align-items: center; margin: var(--pagination-item-margin); cursor: pointer;}.var-pagination__list { background-color: var(--pagination-list-bg-color); cursor: pointer;}.var-pagination__list:hover { background-color: var(--pagination-hover-bg-color);}.var-pagination__list-active { background-color: var(--pagination-list-active-bg-color) !important; color: var(--pagination-list-active-color);}.var-pagination__quickly,.var-pagination__simple { display: flex; white-space: nowrap; align-items: center;}.var-pagination__quickly [var-pagination-cover],.var-pagination__simple [var-pagination-cover] { width: var(--pagination-input-width);}.var-pagination__quickly [var-pagination-cover] .var-input__wrap,.var-pagination__simple [var-pagination-cover] .var-input__wrap { padding: 0;}.var-pagination__quickly [var-pagination-cover] .var-input__input,.var-pagination__simple [var-pagination-cover] .var-input__input { height: auto; text-align: center;}.var-pagination__quickly { margin: var(--pagination-item-margin);}.var-pagination__quickly [var-pagination-cover] { margin-left: 6px;}.var-pagination__size-open-icon { font-size: inherit;}.var-pagination--simple-padding { padding: var(--pagination-simple-padding);}