@opentiny/vue-renderless 3.12.0 → 3.13.0-alpha.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.
Files changed (298) hide show
  1. package/action-sheet/index.js +20 -13
  2. package/action-sheet/vue.js +8 -7
  3. package/alert/index.js +50 -1
  4. package/alert/vue.js +36 -9
  5. package/amount/index.js +100 -25
  6. package/amount/vue.js +102 -26
  7. package/anchor/index.js +1 -0
  8. package/area/index.js +8 -8
  9. package/area/vue.js +5 -5
  10. package/async-flowchart/index.js +16 -3
  11. package/autocomplete/index.js +58 -14
  12. package/autocomplete/vue.js +40 -12
  13. package/badge/index.js +12 -0
  14. package/badge/vue.js +6 -4
  15. package/breadcrumb/vue.js +3 -1
  16. package/breadcrumb-item/vue.js +6 -2
  17. package/button/index.js +5 -1
  18. package/calendar/index.js +2 -86
  19. package/calendar-bar/index.js +20 -6
  20. package/calendar-view/index.js +10 -12
  21. package/calendar-view/vue.js +17 -4
  22. package/cascader/index.js +80 -34
  23. package/cascader/vue.js +49 -19
  24. package/cascader-menu/index.js +7 -7
  25. package/cascader-menu/vue.js +2 -3
  26. package/cascader-mobile/index.js +37 -24
  27. package/cascader-mobile/vue.js +7 -1
  28. package/cascader-node/index.js +13 -1
  29. package/cascader-node/vue.js +15 -4
  30. package/cascader-panel/index.js +1 -1
  31. package/cascader-select/column-index.js +150 -0
  32. package/cascader-select/column.js +120 -0
  33. package/cascader-select/index.js +29 -165
  34. package/cascader-select/usePicker.js +251 -0
  35. package/cascader-select/useTouch.js +65 -0
  36. package/cascader-select/vue.js +35 -47
  37. package/cascader-view/index.js +1 -1
  38. package/cell/vue.js +2 -1
  39. package/chart-bar/index.js +2 -3
  40. package/chart-core/deps/constants.js +43 -43
  41. package/chart-core/index.js +1 -1
  42. package/chart-gauge/index.js +2 -2
  43. package/chart-heatmap/index.js +17 -10
  44. package/chart-line/index.js +8 -9
  45. package/chart-tree/index.js +2 -2
  46. package/chart-waterfall/index.js +4 -6
  47. package/checkbox/index.js +17 -0
  48. package/checkbox/vue.js +16 -7
  49. package/checkbox-group/vue.js +2 -0
  50. package/col/index.js +7 -2
  51. package/col/vue.js +1 -1
  52. package/collapse/index.js +3 -3
  53. package/color-select-panel/vue.js +0 -7
  54. package/column-list-item/index.js +17 -1
  55. package/column-list-item/vue.js +8 -3
  56. package/common/date.js +2 -0
  57. package/common/deps/dom.js +19 -4
  58. package/common/deps/popper.js +48 -5
  59. package/common/deps/touch-emulator.js +4 -1
  60. package/common/deps/tree-model/node.js +1 -1
  61. package/common/deps/tree-model/tree-store.js +2 -13
  62. package/common/deps/useRect.js +25 -0
  63. package/common/deps/vue-popper.js +22 -10
  64. package/common/index.js +1 -1
  65. package/common/runtime.js +1 -1
  66. package/common/type.js +2 -1
  67. package/common/validate/rules/enum.js +1 -1
  68. package/common/validate/rules/pattern.js +2 -2
  69. package/common/validate/rules/range.js +8 -5
  70. package/common/validate/rules/required.js +1 -1
  71. package/common/validate/rules/type.js +5 -5
  72. package/common/validate/rules/whitespace.js +1 -1
  73. package/common/validate/util.js +15 -16
  74. package/common/validate/validations/integer.js +1 -1
  75. package/common/validate/validations/method.js +1 -1
  76. package/container/index.js +17 -1
  77. package/container/vue.js +12 -3
  78. package/currency/index.js +74 -7
  79. package/currency/vue.js +21 -5
  80. package/date-panel/index.js +16 -0
  81. package/date-panel/vue.js +8 -2
  82. package/date-picker-mobile/index.js +12 -0
  83. package/date-picker-mobile/vue.js +7 -1
  84. package/date-range/vue.js +12 -5
  85. package/date-table/index.js +5 -0
  86. package/date-table/vue.js +3 -1
  87. package/dialog-box/index.js +17 -6
  88. package/dialog-select/index.js +6 -3
  89. package/dialog-select/vue.js +8 -4
  90. package/drawer/index.js +26 -5
  91. package/drawer/vue.js +13 -7
  92. package/dropdown/index.js +7 -7
  93. package/dropdown/vue.js +6 -2
  94. package/dropdown-item/index.js +9 -1
  95. package/dropdown-item/mf.js +6 -10
  96. package/dropdown-item/vue.js +21 -8
  97. package/dropdown-menu/index.js +20 -7
  98. package/dropdown-menu/vue.js +4 -3
  99. package/exception/index.js +2 -7
  100. package/exception/vue.js +7 -10
  101. package/fall-menu/index.js +5 -1
  102. package/fall-menu/vue.js +13 -2
  103. package/file-upload/index.js +47 -12
  104. package/file-upload/vue.js +38 -8
  105. package/filter-box/index.js +1 -0
  106. package/floating-button/index.js +62 -16
  107. package/floating-button/vue.js +27 -9
  108. package/flowchart/index.js +134 -25
  109. package/flowchart/node.js +13 -4
  110. package/flowchart/vue.js +16 -4
  111. package/form/vue.js +3 -1
  112. package/form-item/index.js +4 -4
  113. package/form-item/vue.js +3 -1
  114. package/fullscreen/index.js +5 -5
  115. package/fullscreen/vue.js +3 -3
  116. package/grid/utils/common.js +10 -5
  117. package/grid/utils/dom.js +7 -1
  118. package/image/index.js +6 -0
  119. package/image/vue.js +6 -3
  120. package/image-viewer/index.js +62 -51
  121. package/image-viewer/vue.js +17 -5
  122. package/input/index.js +89 -22
  123. package/input/vue.js +52 -21
  124. package/ip-address/index.js +61 -19
  125. package/ip-address/vue.js +22 -4
  126. package/label/index.js +56 -0
  127. package/label/vue.js +26 -0
  128. package/link/vue.js +3 -1
  129. package/loading/vue.js +8 -2
  130. package/logout/index.js +1 -1
  131. package/mask/index.js +13 -0
  132. package/mask/vue.js +18 -0
  133. package/mind-map/index.js +47 -0
  134. package/mind-map/vue.js +53 -0
  135. package/multi-select/index.js +150 -10
  136. package/multi-select/vue.js +46 -11
  137. package/multi-select-item/index.js +17 -0
  138. package/multi-select-item/vue.js +31 -0
  139. package/numeric/index.js +51 -9
  140. package/numeric/vue.js +44 -14
  141. package/option/index.js +12 -5
  142. package/option/vue.js +15 -7
  143. package/option-group/index.js +3 -3
  144. package/package.json +1 -1
  145. package/pager/index.js +372 -0
  146. package/pager/vue.js +125 -2
  147. package/picker/index.js +253 -48
  148. package/picker/mb.js +42 -0
  149. package/picker/vue.js +70 -17
  150. package/picker-column/index.js +1 -1
  151. package/pop-upload/index.js +0 -2
  152. package/pop-upload/vue.js +3 -4
  153. package/popconfirm/index.js +3 -6
  154. package/popconfirm/vue.js +1 -1
  155. package/popeditor/index.js +55 -24
  156. package/popeditor/vue.js +15 -11
  157. package/popover/index.js +4 -4
  158. package/popover/vue.js +6 -6
  159. package/popup/index.js +3 -3
  160. package/popup/vue.js +5 -5
  161. package/pull-refresh/index.js +57 -65
  162. package/pull-refresh/vue.js +23 -7
  163. package/radio/index.js +0 -17
  164. package/radio/vue.js +4 -10
  165. package/rate/index.js +1 -1
  166. package/rate/vue.js +0 -2
  167. package/record/index.js +4 -1
  168. package/{rich-text-edtior → rich-text-editor}/index.js +2 -2
  169. package/{rich-text-edtior → rich-text-editor}/vue.js +2 -5
  170. package/scrollbar/index.js +11 -11
  171. package/scrollbar/vue-bar.js +3 -3
  172. package/scrollbar/vue.js +5 -5
  173. package/search/index.js +1 -1
  174. package/search/vue.js +3 -1
  175. package/select/index.js +185 -113
  176. package/select/vue.js +105 -20
  177. package/select-dropdown/index.js +62 -4
  178. package/select-dropdown/vue.js +85 -8
  179. package/select-view/index.js +3 -1
  180. package/signature/index.js +241 -0
  181. package/signature/vue.js +88 -0
  182. package/skeleton/index.js +14 -0
  183. package/skeleton/vue.js +15 -0
  184. package/skeleton-item/vue.js +15 -0
  185. package/slider/index.js +27 -7
  186. package/slider/vue.js +26 -7
  187. package/split/index.js +1 -1
  188. package/split/vue.js +4 -6
  189. package/standard-list-item/index.js +15 -1
  190. package/standard-list-item/vue.js +6 -5
  191. package/steps/index.js +25 -2
  192. package/steps/slide-bar.js +8 -1
  193. package/steps/vue.js +15 -3
  194. package/tab-item-mf/vue.js +14 -8
  195. package/tab-nav/index.js +9 -4
  196. package/tab-nav/vue.js +6 -2
  197. package/tabbar/vue.js +9 -3
  198. package/tabbar-item/vue.js +3 -2
  199. package/tabs/index.js +1 -1
  200. package/tabs/vue.js +1 -0
  201. package/tabs-mf/index.js +20 -6
  202. package/tabs-mf/vue-nav.js +26 -11
  203. package/tabs-mf/vue.js +7 -7
  204. package/tag/index.js +1 -1
  205. package/tag/vue.js +5 -1
  206. package/tag-group/index.js +2 -1
  207. package/tall-storage/index.js +4 -5
  208. package/time/index.js +4 -1
  209. package/time/vue.js +1 -1
  210. package/time-line/vue.js +1 -1
  211. package/time-picker-mobile/index.js +24 -5
  212. package/time-picker-mobile/vue.js +17 -7
  213. package/time-range/index.js +2 -0
  214. package/time-spinner/index.js +0 -3
  215. package/time-spinner/vue.js +2 -3
  216. package/timeline-item/vue.js +1 -1
  217. package/tooltip/index.js +1 -2
  218. package/tooltip/vue.js +3 -3
  219. package/transfer/index.js +20 -22
  220. package/transfer/vue.js +1 -6
  221. package/transfer-panel/vue.js +3 -5
  222. package/tree/index.js +21 -4
  223. package/tree/vue.js +10 -8
  224. package/tree-menu/index.js +27 -3
  225. package/tree-menu/vue.js +27 -14
  226. package/tree-node/index.js +12 -10
  227. package/tree-node/vue.js +6 -5
  228. package/types/action-menu.type.d.ts +5 -0
  229. package/types/action-sheet.type.d.ts +118 -1
  230. package/types/alert.type.d.ts +16 -1
  231. package/types/amount.type.d.ts +168 -1
  232. package/types/area.type.d.ts +134 -1
  233. package/types/async-flowchart.type.d.ts +72 -0
  234. package/types/autocomplete.type.d.ts +199 -1
  235. package/types/badge.type.d.ts +3 -1
  236. package/types/breadcrumb-item.type.d.ts +2 -0
  237. package/types/breadcrumb.type.d.ts +2 -0
  238. package/types/button.type.d.ts +5 -0
  239. package/types/cascader-menu.type.d.ts +3 -4
  240. package/types/cascader-node.type.d.ts +5 -2
  241. package/types/cascader-panel.type-2bd03be3.d.ts +241 -0
  242. package/types/cascader-panel.type.d.ts +3 -241
  243. package/types/cascader.type.d.ts +327 -1
  244. package/types/checkbox.type.d.ts +9 -0
  245. package/types/collapse.type.d.ts +19 -2
  246. package/types/date-picker.type.d.ts +33 -0
  247. package/types/dialog-box.type.d.ts +5 -1
  248. package/types/drawer.type.d.ts +132 -1
  249. package/types/{dropdown-item.type-bf83e929.d.ts → dropdown-item.type-8475a549.d.ts} +8 -14
  250. package/types/dropdown-item.type.d.ts +1 -1
  251. package/types/dropdown-menu.type.d.ts +1 -1
  252. package/types/dropdown.type.d.ts +2 -5
  253. package/types/fall-menu.type.d.ts +94 -1
  254. package/types/file-upload.type.d.ts +1 -1
  255. package/types/form-item.type.d.ts +1 -1
  256. package/types/{form.type-d0fd42f3.d.ts → form.type-d88482e4.d.ts} +3 -0
  257. package/types/form.type.d.ts +1 -1
  258. package/types/input.type.d.ts +23 -9
  259. package/types/ip-address.type.d.ts +160 -1
  260. package/types/label.type.d.ts +81 -0
  261. package/types/link.type.d.ts +6 -3
  262. package/types/mind-map.type.d.ts +20 -0
  263. package/types/modal.type.d.ts +4 -2
  264. package/types/numeric.type.d.ts +36 -9
  265. package/types/pager.type.d.ts +171 -1
  266. package/types/picker.type.d.ts +14 -0
  267. package/types/popconfirm.type.d.ts +85 -1
  268. package/types/popeditor.type.d.ts +4 -0
  269. package/types/popover.type.d.ts +3 -3
  270. package/types/radio.type.d.ts +0 -4
  271. package/types/rate.type.d.ts +236 -1
  272. package/types/search.type.d.ts +88 -1
  273. package/types/shared.type.d.ts +1 -1
  274. package/types/skeleton-item.type.d.ts +38 -0
  275. package/types/skeleton.type.d.ts +45 -0
  276. package/types/slider.type.d.ts +8 -1
  277. package/types/steps.type.d.ts +14 -3
  278. package/types/tab-item.type.d.ts +0 -1
  279. package/types/tab-nav.type.d.ts +6 -1
  280. package/types/tabs.type.d.ts +5 -0
  281. package/types/tag-group.type.d.ts +64 -1
  282. package/types/tag.type.d.ts +12 -0
  283. package/types/tooltip.type.d.ts +1 -1
  284. package/types/transfer.type.d.ts +183 -1
  285. package/types/tree-menu.type.d.ts +210 -1
  286. package/types/upload-dragger.type.d.ts +1 -1
  287. package/types/{upload-list.type-343e8c11.d.ts → upload-list.type-1078fba2.d.ts} +27 -6
  288. package/types/upload-list.type.d.ts +1 -1
  289. package/types/upload.type.d.ts +1 -1
  290. package/types/wizard.type.d.ts +1 -0
  291. package/upload/index.js +59 -29
  292. package/upload/vue.js +6 -4
  293. package/upload-list/index.js +14 -14
  294. package/upload-list/vue.js +5 -2
  295. package/user/index.js +5 -4
  296. package/user-head/index.js +1 -1
  297. package/wheel/index.js +3 -0
  298. package/wizard/vue.js +4 -2
package/option/vue.js CHANGED
@@ -16,7 +16,7 @@ const initState = ({ reactive, computed, props, api: api2, markRaw, select, pare
16
16
  created: computed(() => props.created),
17
17
  index: -1,
18
18
  select: markRaw(select),
19
- hover: false,
19
+ hover: computed(() => !state.select.optimization && state.select.state.hoverIndex === state.index || false),
20
20
  visible: true,
21
21
  hitState: false,
22
22
  groupDisabled: false,
@@ -24,17 +24,18 @@ const initState = ({ reactive, computed, props, api: api2, markRaw, select, pare
24
24
  isObject: computed(() => Object.prototype.toString.call(props.value).toLowerCase() === "[object object]"),
25
25
  currentLabel: computed(() => props.label || (state.isObject ? "" : props.value)),
26
26
  currentValue: computed(() => props.value || props.label || ""),
27
+ showTitle: false,
27
28
  itemSelected: computed(() => {
28
29
  if (!select.multiple) {
29
- return api2.isEqual(props.value, select.modelValue);
30
+ return api2.isEqual(props.value, select.state.modelValue);
30
31
  } else {
31
- return api2.contains(select.modelValue, props.value);
32
+ return api2.contains(select.state.modelValue, props.value);
32
33
  }
33
34
  }),
34
35
  limitReached: computed(() => {
35
36
  if (select.multiple) {
36
37
  const multipleLimit = select.state.multipleLimit;
37
- return !state.itemSelected && (select.modelValue || []).length >= multipleLimit && multipleLimit > 0;
38
+ return !state.itemSelected && (select.state.modelValue || []).length >= multipleLimit && multipleLimit > 0;
38
39
  } else {
39
40
  return false;
40
41
  }
@@ -49,9 +50,9 @@ const initApi = ({ api: api2, props, state, select, constants, vm }) => {
49
50
  isEqual: isEqual({ select, state }),
50
51
  contains: contains({ select, state }),
51
52
  hoverItem: hoverItem({ select, vm, props, state }),
52
- queryChange: queryChange({ select, props, state }),
53
+ queryChange: queryChange({ props, state }),
53
54
  selectOptionClick: selectOptionClick({ constants, vm, props, state, select }),
54
- handleGroupDisabled: handleGroupDisabled(state),
55
+ handleGroupDisabled: handleGroupDisabled({ state, vm }),
55
56
  initValue: initValue({ select, props, constants, vm })
56
57
  });
57
58
  };
@@ -76,6 +77,12 @@ const initWatch = ({ watch, props, state, select, constants }) => {
76
77
  }
77
78
  }
78
79
  );
80
+ watch(
81
+ () => state.visible,
82
+ () => {
83
+ select.state.filteredOptionsCount += state.visible ? 1 : -1;
84
+ }
85
+ );
79
86
  };
80
87
  const initOnMounted = ({ onMounted, props, api: api2, vm, state, constants, select }) => {
81
88
  onMounted(() => {
@@ -106,9 +113,10 @@ const renderless = (props, { computed, onMounted, onBeforeUnmount, reactive, wat
106
113
  initOnBeforeUnmount({ onBeforeUnmount, props, select, vm });
107
114
  select.state.options.push(markRaw(vm));
108
115
  select.state.cachedOptions.push(markRaw(vm));
116
+ state.index = select.state.optionsCount;
109
117
  select.state.optionsCount++;
110
118
  select.state.filteredOptionsCount++;
111
- vm.$on(constants.EVENT_NAME.handleGroupDisabled, api2.handleGroupDisabled);
119
+ parent.$on(constants.EVENT_NAME.handleGroupDisabled, api2.handleGroupDisabled);
112
120
  return api2;
113
121
  };
114
122
  export {
@@ -2,9 +2,9 @@ import "../chunk-G2ADBYYC.js";
2
2
  const queryChange = ({ select, state, vm }) => () => {
3
3
  state.visible = true;
4
4
  if (Array.isArray(select.state.options)) {
5
- const groupOptions = select.state.options.filter(
6
- (option) => option.state.parent && vm && option.state.parent.label === vm.label
7
- );
5
+ const groupOptions = select.state.options.filter((option) => {
6
+ return option.state.parent.$parent && vm && option.state.parent.$parent.label === vm.label;
7
+ });
8
8
  if (Array.isArray(groupOptions)) {
9
9
  state.visible = groupOptions.some((option) => option.visible === true);
10
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentiny/vue-renderless",
3
- "version": "3.12.0",
3
+ "version": "3.13.0-alpha.0",
4
4
  "description": "An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.",
5
5
  "homepage": "https://opentiny.design/tiny-vue",
6
6
  "keywords": [
package/pager/index.js ADDED
@@ -0,0 +1,372 @@
1
+ import {
2
+ __spreadValues
3
+ } from "../chunk-G2ADBYYC.js";
4
+ import { emitEvent } from "../common/event";
5
+ const computedShowPager = ({ props, state }) => () => {
6
+ const hidePager = props.hideOnSinglePage && (!state.internalPageCount || state.internalPageCount === 1);
7
+ return state.internalLayout.length > 0 && !hidePager;
8
+ };
9
+ const computedInternalLayout = ({ props }) => () => {
10
+ let layout = "";
11
+ if (props.mode && !props.layout) {
12
+ props.mode === "number" && (layout = "total, sizes, prev, pager, next, jumper");
13
+ props.mode === "simple" && (layout = "sizes, total, prev, current, next");
14
+ props.mode === "complete" && (layout = "sizes, total, prev, pager, next, jumper");
15
+ props.mode === "fixed" && (layout = "prev,pager,next");
16
+ } else if (!props.mode && props.layout || props.mode && props.layout) {
17
+ layout = props.layout;
18
+ } else {
19
+ layout = "total, prev, pager, next, jumper";
20
+ }
21
+ if (!layout) {
22
+ return [];
23
+ } else {
24
+ const components = layout.split(",").map((item) => item.trim());
25
+ return components;
26
+ }
27
+ };
28
+ const computedTotalText = ({ props, t }) => () => {
29
+ if (typeof props.customTotal === "string")
30
+ return props.customTotal;
31
+ const totals = Number(props.total);
32
+ if (isNaN(totals))
33
+ return "0";
34
+ const HUNDRED_THOUSAND = 1e5;
35
+ const MILLION = 1e6;
36
+ const TEN_MILLION = 1e7;
37
+ if (totals < HUNDRED_THOUSAND) {
38
+ return String(totals);
39
+ } else if (totals < MILLION) {
40
+ return t("ui.page.hundredThousand");
41
+ } else if (totals < TEN_MILLION) {
42
+ return t("ui.page.million");
43
+ } else {
44
+ return t("ui.page.tenMillion");
45
+ }
46
+ };
47
+ const computedInternalPageCount = ({ props, state }) => () => {
48
+ if (typeof props.total === "number") {
49
+ return Math.max(1, Math.ceil(props.total / state.internalPageSize));
50
+ } else if (typeof props.pageCount === "number") {
51
+ return Math.max(1, props.pageCount);
52
+ }
53
+ return null;
54
+ };
55
+ const handleJumperFocus = ({ state }) => (e) => {
56
+ var _a;
57
+ state.jumperBackup = (_a = e.target) == null ? void 0 : _a.value;
58
+ };
59
+ const watchInternalCurrentPage = ({ state, emit }) => (currentPage) => {
60
+ const value = String(currentPage);
61
+ if (state.jumperValue !== value) {
62
+ state.jumperValue = value;
63
+ }
64
+ emit("update:current-page", currentPage);
65
+ emit("current-change", currentPage);
66
+ state.lastEmittedPage = -1;
67
+ };
68
+ const watchPageSizes = ({ state, props }) => (newVal) => {
69
+ if (Array.isArray(newVal)) {
70
+ state.internalPageSize = newVal.includes(props.pageSize) ? props.pageSize : newVal[0];
71
+ }
72
+ };
73
+ const watchCurrentPage = ({ state, api }) => (curPage) => {
74
+ state.internalCurrentPage = api.getValidCurrentPage(curPage);
75
+ };
76
+ const watchInternalPageCount = ({ state, api }) => (pageCount) => {
77
+ const oldCurPage = state.internalCurrentPage;
78
+ if (pageCount && pageCount > 0 && oldCurPage === 0) {
79
+ state.internalCurrentPage = 1;
80
+ } else if (oldCurPage > Number(pageCount)) {
81
+ state.internalCurrentPage = pageCount || 1;
82
+ state.userChangePageSize && api.emitChange();
83
+ }
84
+ state.userChangePageSize = false;
85
+ };
86
+ const watchPageSize = ({ state }) => (pageSize) => {
87
+ state.internalPageSize = isNaN(pageSize) ? 10 : pageSize;
88
+ };
89
+ const watchTotal = ({ state }) => (total) => {
90
+ state.internalTotal = total;
91
+ };
92
+ const watchShowSizes = ({ nextTick, vm }) => (newVal) => {
93
+ if (newVal) {
94
+ nextTick(() => {
95
+ const width = vm.$refs.pageSize[0].getBoundingClientRect().width;
96
+ const popover = document.querySelectorAll(".tiny-pager__selector");
97
+ Array.from(popover).forEach((ele) => {
98
+ ele.style.width = width + "px";
99
+ });
100
+ });
101
+ }
102
+ };
103
+ const handleSizeChange = ({ props, state, api, emit, vm }) => (val) => {
104
+ val = Number(val);
105
+ if (val !== state.internalPageSize) {
106
+ const callback = () => {
107
+ if (!api.beforeChangeHandler()) {
108
+ return;
109
+ }
110
+ state.internalPageSize = val;
111
+ state.userChangePageSize = true;
112
+ state.showSizes = false;
113
+ emit("update:pageSize", val);
114
+ emit("size-change", val);
115
+ emit("page-change", {
116
+ currentPage: state.internalCurrentPage,
117
+ pageSize: val,
118
+ total: state.internalTotal
119
+ });
120
+ vm.$refs.sizesList[0].state.showPopper = false;
121
+ };
122
+ if (props.isBeforePageChange) {
123
+ let newPageSize = val;
124
+ let currentPageSize = state.internalPageSize;
125
+ let params = { newPageSize, currentPageSize, callback };
126
+ api.beforeSizeChangeHandler(params);
127
+ } else {
128
+ callback();
129
+ }
130
+ }
131
+ };
132
+ const handleJumperInput = ({ state }) => (e) => {
133
+ const target = e.target;
134
+ if (!target.value) {
135
+ state.jumperValue = "";
136
+ } else if (/^\d+$/.test(target.value)) {
137
+ state.jumperValue = target.value || "1";
138
+ }
139
+ target.value = state.jumperValue;
140
+ };
141
+ const handleJumperChange = ({ props, state, api }) => () => {
142
+ api.parseValueNumber();
143
+ const callback = () => {
144
+ api.handleJumperClick();
145
+ };
146
+ const rollback = () => {
147
+ state.jumperValue = String(state.jumperBackup);
148
+ };
149
+ const newPage = state.jumperValue;
150
+ const currentPage = state.jumperBackup;
151
+ if (props.isBeforePageChange && newPage !== currentPage) {
152
+ const params = { newPage, currentPage, callback, rollback };
153
+ api.beforePagerChangeHandler(params);
154
+ } else {
155
+ callback();
156
+ }
157
+ };
158
+ const handleJumperClick = ({ props, state, api }) => () => {
159
+ if (!api.canJumperGo() || props.disabled)
160
+ return;
161
+ state.internalCurrentPage = api.getValidCurrentPage(state.jumperValue);
162
+ api.emitChange();
163
+ };
164
+ const isValueNumber = ({ state }) => () => {
165
+ return !isNaN(Number(state.jumperValue));
166
+ };
167
+ const parseValueNumber = ({ state }) => () => {
168
+ let value = Number(
169
+ String(state.jumperValue).split(/[^0-9-+.]/).join("")
170
+ );
171
+ if (isNaN(value)) {
172
+ value = 1;
173
+ }
174
+ value = Number(value.toFixed(0));
175
+ const min = 1;
176
+ const max = state.internalPageCount || 1;
177
+ if (value >= max) {
178
+ state.jumperValue = String(max);
179
+ } else if (value <= min) {
180
+ state.jumperValue = String(min);
181
+ } else {
182
+ state.jumperValue = String(value);
183
+ }
184
+ };
185
+ const handleSizeShowPopover = ({ state, props }) => () => {
186
+ if (props.disabled) {
187
+ state.showSizes = false;
188
+ return;
189
+ }
190
+ state.showSizes = true;
191
+ };
192
+ const handleSizeHidePopover = ({ state }) => () => {
193
+ state.showSizes = false;
194
+ };
195
+ const canJumperGo = ({ props, state, vm }) => () => {
196
+ const inputValue = Number(vm.$refs.jumperInput[0].value || 0);
197
+ const currentPage = Number(state.internalCurrentPage || 0);
198
+ return props.accurateJumper ? inputValue !== currentPage : true;
199
+ };
200
+ const beforeSizeChangeHandler = ({ state, emit }) => (params) => {
201
+ const { newPageSize, currentPageSize, callback } = params;
202
+ const newPage = 1;
203
+ const currentPage = state.internalCurrentPage;
204
+ const temp = {
205
+ newPage,
206
+ newPageSize,
207
+ currentPage,
208
+ currentPageSize,
209
+ callback
210
+ };
211
+ emit("before-page-change", temp);
212
+ };
213
+ const beforePagerChangeHandler = ({ state, emit }) => (params) => {
214
+ const { newPage, currentPage, callback, rollback } = params;
215
+ const newPageSize = state.internalPageSize;
216
+ const currentPageSize = state.internalPageSize;
217
+ const temp = {
218
+ newPage,
219
+ newPageSize,
220
+ currentPage,
221
+ currentPageSize,
222
+ callback,
223
+ rollback
224
+ };
225
+ emit("before-page-change", temp);
226
+ };
227
+ const beforeJumperChangeHandler = ({ state, emit }) => (params) => {
228
+ const { newPage, currentPage, callback, rollback } = params;
229
+ const newPageSize = state.internalPageSize;
230
+ const currentPageSize = state.internalPageSize;
231
+ const temp = {
232
+ newPage,
233
+ newPageSize,
234
+ currentPage,
235
+ currentPageSize,
236
+ callback,
237
+ rollback
238
+ };
239
+ emit("before-page-change", temp);
240
+ };
241
+ const copyEmit = ({ emit }) => (...args) => {
242
+ emit(args[0], ...args.slice(1));
243
+ };
244
+ const beforeChangeHandler = ({ state, api }) => (val = -1) => {
245
+ return emitEvent(api.copyEmit, "before-change", state.internalCurrentPage, void 0, val);
246
+ };
247
+ const handleCurrentChange = ({ state, api }) => (val) => {
248
+ if (!api.beforeChangeHandler(val)) {
249
+ return;
250
+ }
251
+ state.internalCurrentPage = api.getValidCurrentPage(val);
252
+ state.userChangePageSize = true;
253
+ api.emitChange();
254
+ };
255
+ const prev = ({ state, props, api, emit }) => () => {
256
+ const callback = () => {
257
+ if (props.disabled || !api.beforeChangeHandler(state.internalCurrentPage - 1)) {
258
+ return;
259
+ }
260
+ const newVal = state.internalCurrentPage - 1;
261
+ state.internalCurrentPage = api.getValidCurrentPage(newVal);
262
+ emit("prev-click", state.internalCurrentPage);
263
+ api.emitChange();
264
+ };
265
+ if (props.isBeforePageChange) {
266
+ const newPage = state.internalCurrentPage - 1;
267
+ const temp = api.buildBeforePageChangeParam({ newPage, callback });
268
+ emit("before-page-change", temp);
269
+ } else {
270
+ callback();
271
+ }
272
+ };
273
+ const next = ({ props, state, api, emit }) => () => {
274
+ const callback = () => {
275
+ if (props.disabled || !api.beforeChangeHandler(state.internalCurrentPage + 1)) {
276
+ return;
277
+ }
278
+ const newVal = state.internalCurrentPage + 1;
279
+ state.internalCurrentPage = api.getValidCurrentPage(newVal);
280
+ emit("next-click", state.internalCurrentPage);
281
+ api.emitChange();
282
+ };
283
+ if (props.isBeforePageChange) {
284
+ const newPage = state.internalCurrentPage + 1;
285
+ const temp = api.buildBeforePageChangeParam({ newPage, callback });
286
+ emit("before-page-change", temp);
287
+ } else {
288
+ callback();
289
+ }
290
+ };
291
+ const buildBeforePageChangeParam = ({ state }) => (param) => {
292
+ const currentPage = state.internalCurrentPage;
293
+ const newPageSize = state.internalPageSize;
294
+ const currentPageSize = state.internalPageSize;
295
+ return __spreadValues({ currentPage, newPageSize, currentPageSize }, param);
296
+ };
297
+ const getValidCurrentPage = ({ state }) => (val) => {
298
+ const parseVal = Number(val);
299
+ const hasPageCount = typeof state.internalPageCount === "number";
300
+ let resetVal;
301
+ if (hasPageCount) {
302
+ if (parseVal < 1) {
303
+ resetVal = 1;
304
+ } else if (parseVal > (state.internalPageCount || 0)) {
305
+ resetVal = state.internalPageCount;
306
+ }
307
+ } else {
308
+ if (isNaN(parseVal) || parseVal < 1) {
309
+ resetVal = 1;
310
+ }
311
+ }
312
+ if (resetVal === void 0 && isNaN(parseVal)) {
313
+ resetVal = 1;
314
+ } else if (resetVal === 0) {
315
+ resetVal = 1;
316
+ }
317
+ return resetVal === void 0 ? parseVal : resetVal;
318
+ };
319
+ const emitChange = ({ state, nextTick, emit }) => () => {
320
+ nextTick(() => {
321
+ if (state.internalCurrentPage !== state.lastEmittedPage || state.userChangePageSize) {
322
+ emit("update:current-page", state.internalCurrentPage);
323
+ emit("page-change", {
324
+ currentPage: state.internalCurrentPage,
325
+ pageSize: state.internalPageSize,
326
+ total: state.internalTotal
327
+ });
328
+ state.lastEmittedPage = state.internalCurrentPage;
329
+ state.userChangePageSize = false;
330
+ }
331
+ });
332
+ };
333
+ const setTotal = ({ state }) => (val) => {
334
+ state.internalTotal = val;
335
+ };
336
+ const clickSizes = () => (e) => e.stopPropagation();
337
+ export {
338
+ beforeChangeHandler,
339
+ beforeJumperChangeHandler,
340
+ beforePagerChangeHandler,
341
+ beforeSizeChangeHandler,
342
+ buildBeforePageChangeParam,
343
+ canJumperGo,
344
+ clickSizes,
345
+ computedInternalLayout,
346
+ computedInternalPageCount,
347
+ computedShowPager,
348
+ computedTotalText,
349
+ copyEmit,
350
+ emitChange,
351
+ getValidCurrentPage,
352
+ handleCurrentChange,
353
+ handleJumperChange,
354
+ handleJumperClick,
355
+ handleJumperFocus,
356
+ handleJumperInput,
357
+ handleSizeChange,
358
+ handleSizeHidePopover,
359
+ handleSizeShowPopover,
360
+ isValueNumber,
361
+ next,
362
+ parseValueNumber,
363
+ prev,
364
+ setTotal,
365
+ watchCurrentPage,
366
+ watchInternalCurrentPage,
367
+ watchInternalPageCount,
368
+ watchPageSize,
369
+ watchPageSizes,
370
+ watchShowSizes,
371
+ watchTotal
372
+ };
package/pager/vue.js CHANGED
@@ -1,7 +1,130 @@
1
1
  import "../chunk-G2ADBYYC.js";
2
- const api = [];
3
- const renderless = () => {
2
+ import {
3
+ computedShowPager,
4
+ computedInternalLayout,
5
+ computedTotalText,
6
+ computedInternalPageCount,
7
+ handleJumperFocus,
8
+ handleSizeChange,
9
+ handleJumperInput,
10
+ handleJumperChange,
11
+ handleJumperClick,
12
+ isValueNumber,
13
+ parseValueNumber,
14
+ handleSizeShowPopover,
15
+ handleSizeHidePopover,
16
+ canJumperGo,
17
+ beforeSizeChangeHandler,
18
+ beforePagerChangeHandler,
19
+ copyEmit,
20
+ beforeChangeHandler,
21
+ handleCurrentChange,
22
+ prev,
23
+ next,
24
+ buildBeforePageChangeParam,
25
+ getValidCurrentPage,
26
+ emitChange,
27
+ setTotal,
28
+ clickSizes,
29
+ watchInternalCurrentPage,
30
+ watchPageSizes,
31
+ watchCurrentPage,
32
+ watchInternalPageCount,
33
+ watchPageSize,
34
+ watchTotal,
35
+ watchShowSizes
36
+ } from "./index";
37
+ const api = [
38
+ "state",
39
+ "handleJumperFocus",
40
+ "handleSizeChange",
41
+ "handleJumperInput",
42
+ "handleJumperChange",
43
+ "handleJumperClick",
44
+ "isValueNumber",
45
+ "parseValueNumber",
46
+ "handleSizeShowPopover",
47
+ "handleSizeHidePopover",
48
+ "canJumperGo",
49
+ "beforeSizeChangeHandler",
50
+ "beforePagerChangeHandler",
51
+ "beforeJumperChangeHandler",
52
+ "beforeChangeHandler",
53
+ "handleCurrentChange",
54
+ "prev",
55
+ "next",
56
+ "buildBeforePageChangeParam",
57
+ "getValidCurrentPage",
58
+ "emitChange",
59
+ "setTotal",
60
+ "clickSizes"
61
+ ];
62
+ const renderless = (props, { reactive, computed, watch }, { emit, vm, nextTick, t, designConfig }) => {
63
+ var _a, _b, _c;
4
64
  const api2 = {};
65
+ const state = reactive({
66
+ showSizes: false,
67
+ internalCurrentPage: 1,
68
+ internalPageSize: props.pageSize,
69
+ lastEmittedPage: -1,
70
+ userChangePageSize: false,
71
+ internalTotal: props.total,
72
+ jumperValue: "1",
73
+ jumperBackup: "1",
74
+ showPager: computed(() => api2.computedShowPager()),
75
+ internalLayout: computed(() => api2.computedInternalLayout()),
76
+ totalText: computed(() => api2.computedTotalText()),
77
+ internalPageCount: computed(() => api2.computedInternalPageCount()),
78
+ showJumperSufix: (_a = designConfig == null ? void 0 : designConfig.state.showJumperSufix) != null ? _a : true,
79
+ align: props.align || (designConfig == null ? void 0 : designConfig.state.align) || "left",
80
+ totalI18n: (designConfig == null ? void 0 : designConfig.state.totalI18n) || "totals",
81
+ totalFixedLeft: (_c = (_b = props.totalFixedLeft) != null ? _b : designConfig == null ? void 0 : designConfig.state.totalFixedLeft) != null ? _c : false
82
+ });
83
+ Object.assign(api2, {
84
+ state,
85
+ computedShowPager: computedShowPager({ props, state }),
86
+ computedInternalLayout: computedInternalLayout({ props }),
87
+ computedTotalText: computedTotalText({ props, t }),
88
+ computedInternalPageCount: computedInternalPageCount({ props, state }),
89
+ getValidCurrentPage: getValidCurrentPage({ state }),
90
+ handleJumperFocus: handleJumperFocus({ state }),
91
+ handleSizeChange: handleSizeChange({ props, state, api: api2, emit, vm }),
92
+ handleJumperInput: handleJumperInput({ state }),
93
+ handleJumperChange: handleJumperChange({ props, state, api: api2 }),
94
+ handleJumperClick: handleJumperClick({ props, state, api: api2 }),
95
+ isValueNumber: isValueNumber({ state }),
96
+ parseValueNumber: parseValueNumber({ state }),
97
+ handleSizeShowPopover: handleSizeShowPopover({ state, props }),
98
+ handleSizeHidePopover: handleSizeHidePopover({ state }),
99
+ canJumperGo: canJumperGo({ props, state, vm }),
100
+ beforeSizeChangeHandler: beforeSizeChangeHandler({ state, emit }),
101
+ beforePagerChangeHandler: beforePagerChangeHandler({ state, emit }),
102
+ copyEmit: copyEmit({ emit }),
103
+ beforeChangeHandler: beforeChangeHandler({ state, api: api2 }),
104
+ handleCurrentChange: handleCurrentChange({ state, api: api2 }),
105
+ prev: prev({ state, props, api: api2, emit }),
106
+ next: next({ props, state, api: api2, emit }),
107
+ buildBeforePageChangeParam: buildBeforePageChangeParam({ state }),
108
+ emitChange: emitChange({ state, nextTick, emit }),
109
+ setTotal: setTotal({ state }),
110
+ clickSizes: clickSizes(),
111
+ // watch
112
+ watchInternalCurrentPage: watchInternalCurrentPage({ state, emit }),
113
+ watchPageSizes: watchPageSizes({ state, props }),
114
+ watchCurrentPage: watchCurrentPage({ state, api: api2 }),
115
+ watchInternalPageCount: watchInternalPageCount({ state, api: api2 }),
116
+ watchPageSize: watchPageSize({ state }),
117
+ watchTotal: watchTotal({ state }),
118
+ watchShowSizes: watchShowSizes({ nextTick, vm })
119
+ });
120
+ state.internalCurrentPage = api2.getValidCurrentPage(props.currentPage);
121
+ watch(() => state.internalCurrentPage, api2.watchInternalCurrentPage);
122
+ watch(() => props.pageSizes, api2.watchPageSizes, { immediate: true });
123
+ watch(() => props.currentPage, api2.watchCurrentPage);
124
+ watch(() => state.internalPageCount, api2.watchInternalPageCount);
125
+ watch(() => props.pageSize, api2.watchPageSize, { immediate: true });
126
+ watch(() => props.total, api2.watchTotal);
127
+ watch(() => state.showSizes, api2.watchShowSizes);
5
128
  return api2;
6
129
  };
7
130
  export {