@nutui/nutui 3.1.22-beta.0 → 3.1.22-beta.3

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 (176) hide show
  1. package/dist/nutui.es.js +4019 -19251
  2. package/dist/nutui.umd.js +4012 -19344
  3. package/dist/packages/_es/ActionSheet.js +26 -157
  4. package/dist/packages/_es/Address.js +119 -542
  5. package/dist/packages/_es/AddressList.js +113 -613
  6. package/dist/packages/_es/Audio.js +62 -264
  7. package/dist/packages/_es/AudioOperate.js +18 -107
  8. package/dist/packages/_es/Avatar.js +42 -165
  9. package/dist/packages/_es/AvatarGroup.js +14 -73
  10. package/dist/packages/_es/BackTop.js +43 -156
  11. package/dist/packages/_es/Badge.js +14 -86
  12. package/dist/packages/_es/Barrage.js +41 -120
  13. package/dist/packages/_es/Button.js +23 -128
  14. package/dist/packages/_es/Calendar.js +24 -237
  15. package/dist/packages/_es/CalendarItem.js +1 -1
  16. package/dist/packages/_es/Card.js +10 -107
  17. package/dist/packages/_es/Cascader.js +156 -500
  18. package/dist/packages/_es/Category.js +15 -58
  19. package/dist/packages/_es/CategoryPane.js +11 -111
  20. package/dist/packages/_es/Cell.js +21 -100
  21. package/dist/packages/_es/CellGroup.js +9 -44
  22. package/dist/packages/_es/Checkbox.js +31 -113
  23. package/dist/packages/_es/CheckboxGroup.js +29 -58
  24. package/dist/packages/_es/CircleProgress.js +28 -151
  25. package/dist/packages/_es/Col.js +14 -56
  26. package/dist/packages/_es/Collapse.js +24 -85
  27. package/dist/packages/_es/CollapseItem.js +70 -261
  28. package/dist/packages/_es/Comment.js +64 -434
  29. package/dist/packages/_es/CountDown.js +61 -242
  30. package/dist/packages/_es/CountUp.js +149 -546
  31. package/dist/packages/_es/DatePicker.js +107 -322
  32. package/dist/packages/_es/Dialog.js +69 -261
  33. package/dist/packages/_es/Divider.js +18 -68
  34. package/dist/packages/_es/Drag.js +56 -197
  35. package/dist/packages/_es/Ecard.js +24 -159
  36. package/dist/packages/_es/Elevator.js +63 -198
  37. package/dist/packages/_es/Empty.js +12 -71
  38. package/dist/packages/_es/FixedNav.js +15 -122
  39. package/dist/packages/_es/Form.js +64 -151
  40. package/dist/packages/_es/FormItem.js +15 -110
  41. package/dist/packages/_es/Grid.js +5 -6
  42. package/dist/packages/_es/GridItem.js +33 -144
  43. package/dist/packages/_es/Icon.js +15 -40
  44. package/dist/packages/_es/ImagePreview.js +74 -298
  45. package/dist/packages/_es/Indicator.js +15 -62
  46. package/dist/packages/_es/InfiniteLoading.js +66 -258
  47. package/dist/packages/_es/Input.js +51 -413
  48. package/dist/packages/_es/InputNumber.js +41 -160
  49. package/dist/packages/_es/Layout.js +4 -5
  50. package/dist/packages/_es/List.js +23 -110
  51. package/dist/packages/_es/Menu.js +30 -118
  52. package/dist/packages/_es/MenuItem.js +34 -162
  53. package/dist/packages/_es/Navbar.js +30 -192
  54. package/dist/packages/_es/NoticeBar.js +83 -387
  55. package/dist/packages/_es/Notify.js +81 -236
  56. package/dist/packages/_es/NumberKeyboard.js +41 -272
  57. package/dist/packages/_es/OldPicker.js +140 -464
  58. package/dist/packages/_es/OverLay.js +32 -105
  59. package/dist/packages/_es/Pagination.js +39 -157
  60. package/dist/packages/_es/Picker.js +138 -459
  61. package/dist/packages/_es/Popover.js +327 -965
  62. package/dist/packages/_es/Popup.js +64 -303
  63. package/dist/packages/_es/Price.js +16 -118
  64. package/dist/packages/_es/Progress.js +14 -146
  65. package/dist/packages/_es/PullRefresh.js +92 -346
  66. package/dist/packages/_es/Radio.js +22 -90
  67. package/dist/packages/_es/RadioGroup.js +8 -37
  68. package/dist/packages/_es/Range.js +92 -417
  69. package/dist/packages/_es/Rate.js +16 -139
  70. package/dist/packages/_es/Row.js +22 -64
  71. package/dist/packages/_es/SearchBar.js +46 -247
  72. package/dist/packages/_es/ShortPassword.js +35 -225
  73. package/dist/packages/_es/SideNavBar.js +33 -89
  74. package/dist/packages/_es/SideNavBarItem.js +11 -46
  75. package/dist/packages/_es/Signature.js +46 -165
  76. package/dist/packages/_es/Skeleton.js +20 -136
  77. package/dist/packages/_es/Sku.js +93 -499
  78. package/dist/packages/_es/Step.js +25 -119
  79. package/dist/packages/_es/Steps.js +18 -53
  80. package/dist/packages/_es/Sticky.js +53 -138
  81. package/dist/packages/_es/SubSideNavBar.js +26 -90
  82. package/dist/packages/_es/Swipe.js +46 -183
  83. package/dist/packages/_es/Swiper.js +121 -433
  84. package/dist/packages/_es/SwiperItem.js +22 -53
  85. package/dist/packages/_es/Switch.js +21 -116
  86. package/dist/packages/_es/TabPane.js +12 -39
  87. package/dist/packages/_es/Tabbar.js +17 -72
  88. package/dist/packages/_es/TabbarItem.js +29 -151
  89. package/dist/packages/_es/Table.js +27 -186
  90. package/dist/packages/_es/Tabs.js +51 -209
  91. package/dist/packages/_es/Tag.js +20 -97
  92. package/dist/packages/_es/TextArea.js +42 -160
  93. package/dist/packages/_es/TimeDetail.js +23 -84
  94. package/dist/packages/_es/TimePannel.js +19 -52
  95. package/dist/packages/_es/TimeSelect.js +15 -103
  96. package/dist/packages/_es/Toast.js +80 -319
  97. package/dist/packages/_es/Uploader.js +112 -460
  98. package/dist/packages/_es/Video.js +83 -340
  99. package/dist/packages/_es/common.js +38 -128
  100. package/dist/packages/_es/component.js +35 -76
  101. package/dist/packages/_es/index.js +5 -6
  102. package/dist/packages/_es/index2.js +9 -30
  103. package/dist/packages/_es/index3.js +6 -8
  104. package/dist/packages/_es/index4.js +13 -58
  105. package/dist/packages/_es/index5.js +120 -675
  106. package/dist/packages/_es/plugin-vue_export-helper.js +7 -8
  107. package/dist/packages/_es/pxCheck.js +3 -5
  108. package/dist/packages/_es/raf.js +8 -15
  109. package/dist/packages/button/index.scss +2 -1
  110. package/dist/packages/cell/index.scss +11 -0
  111. package/dist/packages/checkbox/index.scss +6 -0
  112. package/dist/packages/dialog/index.scss +1 -0
  113. package/dist/packages/elevator/index.scss +21 -0
  114. package/dist/packages/input/index.scss +13 -1
  115. package/dist/packages/locale/lang/baseLang.d.ts +1 -0
  116. package/dist/packages/locale/lang/baseLang.js +3 -3
  117. package/dist/packages/locale/lang/en-US.d.ts +8 -0
  118. package/dist/packages/locale/lang/en-US.js +5 -97
  119. package/dist/packages/locale/lang/id-ID.d.ts +8 -0
  120. package/dist/packages/locale/lang/id-ID.js +5 -97
  121. package/dist/packages/locale/lang/index.js +16 -38
  122. package/dist/packages/locale/lang/zh-CN.d.ts +8 -0
  123. package/dist/packages/locale/lang/zh-CN.js +5 -97
  124. package/dist/packages/locale/lang/zh-TW.d.ts +8 -0
  125. package/dist/packages/locale/lang/zh-TW.js +5 -97
  126. package/dist/packages/radio/index.scss +1 -0
  127. package/dist/packages/switch/index.scss +3 -3
  128. package/dist/packages/tabpane/index.scss +1 -0
  129. package/dist/smartips/attributes.json +62 -10
  130. package/dist/smartips/tags.json +17 -4
  131. package/dist/style.css +1 -1
  132. package/dist/styles/themes/default.scss +49 -49
  133. package/dist/styles/themes/jdb.scss +49 -49
  134. package/dist/styles/themes/jdt.scss +49 -49
  135. package/dist/styles/variables-jdb.scss +10 -1
  136. package/dist/styles/variables-jdt.scss +10 -1
  137. package/dist/styles/variables.scss +10 -1
  138. package/dist/types/__VUE/address/index.vue.d.ts +5 -5
  139. package/dist/types/__VUE/addresslist/components/ItemContents.vue.d.ts +1 -0
  140. package/dist/types/__VUE/audiooperate/index.vue.d.ts +1 -0
  141. package/dist/types/__VUE/avatar/index.vue.d.ts +4 -4
  142. package/dist/types/__VUE/backtop/index.vue.d.ts +2 -2
  143. package/dist/types/__VUE/badge/index.vue.d.ts +2 -2
  144. package/dist/types/__VUE/button/index.vue.d.ts +2 -2
  145. package/dist/types/__VUE/cascader/index.vue.d.ts +1 -1
  146. package/dist/types/__VUE/cell/index.vue.d.ts +11 -4
  147. package/dist/types/__VUE/checkbox/common.d.ts +59 -0
  148. package/dist/types/__VUE/checkbox/index.vue.d.ts +18 -5
  149. package/dist/types/__VUE/checkboxgroup/index.vue.d.ts +7 -0
  150. package/dist/types/__VUE/collapseitem/index.vue.d.ts +2 -2
  151. package/dist/types/__VUE/dialog/index.d.ts +9 -2
  152. package/dist/types/__VUE/dialog/index.vue.d.ts +23 -8
  153. package/dist/types/__VUE/ecard/index.vue.d.ts +3 -3
  154. package/dist/types/__VUE/elevator/index.vue.d.ts +29 -0
  155. package/dist/types/__VUE/empty/index.vue.d.ts +2 -2
  156. package/dist/types/__VUE/formitem/index.vue.d.ts +3 -10
  157. package/dist/types/__VUE/grid/index.vue.d.ts +4 -4
  158. package/dist/types/__VUE/griditem/index.vue.d.ts +1 -1
  159. package/dist/types/__VUE/input/index.vue.d.ts +2 -2
  160. package/dist/types/__VUE/noticebar/index.vue.d.ts +1 -1
  161. package/dist/types/__VUE/oldpicker/index.vue.d.ts +2 -2
  162. package/dist/types/__VUE/picker/index.vue.d.ts +2 -2
  163. package/dist/types/__VUE/popover/index.vue.d.ts +2 -2
  164. package/dist/types/__VUE/range/index.vue.d.ts +1 -1
  165. package/dist/types/__VUE/rate/index.vue.d.ts +2 -2
  166. package/dist/types/__VUE/row/index.vue.d.ts +2 -2
  167. package/dist/types/__VUE/shortpassword/index.vue.d.ts +2 -2
  168. package/dist/types/__VUE/step/index.vue.d.ts +2 -2
  169. package/dist/types/__VUE/switch/index.vue.d.ts +2 -2
  170. package/dist/types/__VUE/tabbaritem/index.vue.d.ts +2 -2
  171. package/dist/types/__VUE/timeselect/index.vue.d.ts +9 -2
  172. package/dist/types/__VUE/toast/index.vue.d.ts +3 -3
  173. package/dist/types/__VUE/uploader/index.vue.d.ts +2 -2
  174. package/dist/types/__VUE/video/index.vue.d.ts +1 -1
  175. package/dist/types/index.d.ts +1 -1
  176. package/package.json +2 -1
@@ -5,18 +5,18 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
7
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
8
+ var __spreadValues = (a2, b2) => {
9
+ for (var prop in b2 || (b2 = {}))
10
+ if (__hasOwnProp.call(b2, prop))
11
+ __defNormalProp(a2, prop, b2[prop]);
12
12
  if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
13
+ for (var prop of __getOwnPropSymbols(b2)) {
14
+ if (__propIsEnum.call(b2, prop))
15
+ __defNormalProp(a2, prop, b2[prop]);
16
16
  }
17
- return a;
17
+ return a2;
18
18
  };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
19
+ var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2));
20
20
  var __restKey = (key) => typeof key === "symbol" ? key : key + "";
21
21
  var __objRest = (source, exclude) => {
22
22
  var target = {};
@@ -31,516 +31,172 @@ var __objRest = (source, exclude) => {
31
31
  return target;
32
32
  };
33
33
  /*!
34
- * @nutui/nutui v3.1.22-beta.0 Tue May 31 2022 21:47:10 GMT+0800 (中国标准时间)
34
+ * @nutui/nutui v3.1.22-beta.3 Wed Jun 15 2022 20:12:30 GMT+0800 (中国标准时间)
35
35
  * (c) 2022 @jdf2e.
36
36
  * Released under the MIT License.
37
37
  */
38
- import { computed, ref, watch, resolveComponent, openBlock, createBlock, withCtx, createElementBlock, Fragment, renderList, createElementVNode, normalizeClass, toDisplayString, createCommentVNode, createVNode } from "vue";
39
- import { popupProps } from "./Popup.js";
40
- import { c as createComponent } from "./component.js";
41
- import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
38
+ import { computed as e, ref as l, watch as a, resolveComponent as t, openBlock as n, createBlock as o, withCtx as i, createElementBlock as s, Fragment as r, renderList as u, createElementVNode as d, normalizeClass as c, toDisplayString as v, createCommentVNode as h, createVNode as p } from "vue";
39
+ import { popupProps as y } from "./Popup.js";
40
+ import { c as g } from "./component.js";
41
+ import { _ as f } from "./plugin-vue_export-helper.js";
42
42
  import "./OverLay.js";
43
43
  import "../locale/lang";
44
44
  import "./Icon.js";
45
45
  import "./pxCheck.js";
46
- const formatTree = (tree, parent, config) => tree.map((node) => {
47
- const { value: valueKey = "value", text: textKey = "text", children: childrenKey = "children" } = config;
48
- const _a = node, { [valueKey]: value, [textKey]: text, [childrenKey]: children } = _a, others = __objRest(_a, [__restKey(valueKey), __restKey(textKey), __restKey(childrenKey)]);
49
- const newNode = __spreadProps(__spreadValues({
50
- loading: false
51
- }, others), {
52
- level: parent ? (parent && parent.level || 0) + 1 : 0,
53
- value,
54
- text,
55
- children,
56
- _parent: parent
57
- });
58
- if (newNode.children && newNode.children.length) {
59
- newNode.children = formatTree(newNode.children, newNode, config);
46
+ const m = (e2, l2, a2) => e2.map((e3) => {
47
+ const { value: t2 = "value", text: n2 = "text", children: o2 = "children" } = a2, _a = e3, { [t2]: i2, [n2]: s2, [o2]: r2 } = _a, u2 = __objRest(_a, [__restKey(t2), __restKey(n2), __restKey(o2)]), d2 = __spreadProps(__spreadValues({ loading: false }, u2), { level: l2 ? (l2 && l2.level || 0) + 1 : 0, value: i2, text: s2, children: r2, _parent: l2 });
48
+ return d2.children && d2.children.length && (d2.children = m(d2.children, d2, a2)), d2;
49
+ }), b = (e2, l2) => {
50
+ let a2, t2 = 0;
51
+ for (; (a2 = e2[t2++]) && l2(a2) !== true; )
52
+ a2.children && a2.children.length && b(a2.children, l2);
53
+ }, C = { topId: null, idKey: "id", pidKey: "pid", sortKey: "" };
54
+ class k {
55
+ constructor(e2, l2) {
56
+ this.config = __spreadValues({ value: "value", text: "text", children: "children" }, l2 || {}), this.nodes = m(e2, null, this.config);
60
57
  }
61
- return newNode;
62
- });
63
- const eachTree = (tree, cb) => {
64
- let i = 0;
65
- let node;
66
- while (node = tree[i++]) {
67
- if (cb(node) === true) {
68
- break;
69
- }
70
- if (node.children && node.children.length) {
71
- eachTree(node.children, cb);
72
- }
58
+ updateChildren(e2, l2) {
59
+ l2 ? l2.children = m(e2, l2, this.config) : this.nodes = m(e2, null, this.config);
73
60
  }
74
- };
75
- const defaultConvertConfig = {
76
- topId: null,
77
- idKey: "id",
78
- pidKey: "pid",
79
- sortKey: ""
80
- };
81
- const convertListToOptions = (list, options) => {
82
- const mergedOptions = __spreadValues(__spreadValues({}, defaultConvertConfig), options || {});
83
- const { topId, idKey, pidKey, sortKey } = mergedOptions;
84
- let result = [];
85
- let map = {};
86
- list.forEach((node) => {
87
- node = __spreadValues({}, node);
88
- const { [idKey]: id, [pidKey]: pid } = node;
89
- const children = map[pid] = map[pid] || [];
90
- if (!result.length && pid === topId) {
91
- result = children;
92
- }
93
- children.push(node);
94
- node.children = map[id] || (map[id] = []);
95
- });
96
- if (sortKey) {
97
- Object.keys(map).forEach((i) => {
98
- if (map[i].length > 1) {
99
- map[i].sort((a, b) => a[sortKey] - b[sortKey]);
100
- }
101
- });
61
+ getNodeByValue(e2) {
62
+ let l2;
63
+ return b(this.nodes, (a2) => {
64
+ if (a2.value === e2)
65
+ return l2 = a2, true;
66
+ }), l2;
102
67
  }
103
- map = null;
104
- return result;
105
- };
106
- class Tree {
107
- constructor(nodes, config) {
108
- this.config = __spreadValues({
109
- value: "value",
110
- text: "text",
111
- children: "children"
112
- }, config || {});
113
- this.nodes = formatTree(nodes, null, this.config);
114
- }
115
- updateChildren(nodes, parent) {
116
- if (!parent) {
117
- this.nodes = formatTree(nodes, null, this.config);
118
- } else {
119
- parent.children = formatTree(nodes, parent, this.config);
120
- }
121
- }
122
- getNodeByValue(value) {
123
- let foundNode;
124
- eachTree(this.nodes, (node) => {
125
- if (node.value === value) {
126
- foundNode = node;
127
- return true;
128
- }
129
- });
130
- return foundNode;
131
- }
132
- getPathNodesByValue(value) {
133
- if (!value.length) {
68
+ getPathNodesByValue(e2) {
69
+ if (!e2.length)
134
70
  return [];
135
- }
136
- const pathNodes = [];
137
- let currentNodes = this.nodes;
138
- while (currentNodes && currentNodes.length) {
139
- const foundNode = currentNodes.find((node) => node.value === value[node.level]);
140
- if (!foundNode) {
71
+ const l2 = [];
72
+ let a2 = this.nodes;
73
+ for (; a2 && a2.length; ) {
74
+ const t2 = a2.find((l3) => l3.value === e2[l3.level]);
75
+ if (!t2)
141
76
  break;
142
- }
143
- pathNodes.push(foundNode);
144
- currentNodes = foundNode.children;
77
+ l2.push(t2), a2 = t2.children;
145
78
  }
146
- return pathNodes;
79
+ return l2;
147
80
  }
148
- isLeaf(node, lazy) {
149
- const { leaf, children } = node;
150
- const hasChildren = Array.isArray(children) && Boolean(children.length);
151
- return leaf || !hasChildren && !lazy;
81
+ isLeaf(e2, l2) {
82
+ const { leaf: a2, children: t2 } = e2, n2 = Array.isArray(t2) && Boolean(t2.length);
83
+ return a2 || !n2 && !l2;
152
84
  }
153
- hasChildren(node, lazy) {
154
- const isLeaf = this.isLeaf(node, lazy);
155
- if (isLeaf) {
85
+ hasChildren(e2, l2) {
86
+ if (this.isLeaf(e2, l2))
156
87
  return false;
157
- }
158
- const { children } = node;
159
- return Array.isArray(children) && Boolean(children.length);
88
+ const { children: a2 } = e2;
89
+ return Array.isArray(a2) && Boolean(a2.length);
160
90
  }
161
91
  }
162
- const { create: create$1, translate } = createComponent("cascader-item");
163
- const _sfc_main$1 = create$1({
164
- props: {
165
- visible: Boolean,
166
- modelValue: Array,
167
- options: {
168
- type: Array,
169
- default: () => []
170
- },
171
- lazy: Boolean,
172
- lazyLoad: Function,
173
- valueKey: {
174
- type: String,
175
- default: "value"
176
- },
177
- textKey: {
178
- type: String,
179
- default: "text"
180
- },
181
- childrenKey: {
182
- type: String,
183
- default: "children"
184
- },
185
- convertConfig: Object
186
- },
187
- components: {},
188
- emits: ["update:modelValue", "change", "pathChange"],
189
- setup(props, { emit }) {
190
- const configs = computed(() => ({
191
- lazy: props.lazy,
192
- lazyLoad: props.lazyLoad,
193
- valueKey: props.valueKey,
194
- textKey: props.textKey,
195
- childrenKey: props.childrenKey,
196
- convertConfig: props.convertConfig
197
- }));
198
- const tabsCursor = ref(0);
199
- const initLoading = ref(false);
200
- const innerValue = ref(props.modelValue);
201
- const tree = ref(new Tree([], {}));
202
- const panes = ref([]);
203
- const isLazy = computed(() => configs.value.lazy && Boolean(configs.value.lazyLoad));
204
- const lazyLoadMap = /* @__PURE__ */ new Map();
205
- let currentProcessNode;
206
- const init = async () => {
207
- lazyLoadMap.clear();
208
- panes.value = [];
209
- tabsCursor.value = 0;
210
- initLoading.value = false;
211
- currentProcessNode = null;
212
- let { options } = props;
213
- if (configs.value.convertConfig) {
214
- options = convertListToOptions(options, configs.value.convertConfig);
92
+ const { create: K, translate: V } = g("cascader-item"), x = K({ props: { visible: Boolean, modelValue: Array, options: { type: Array, default: () => [] }, lazy: Boolean, lazyLoad: Function, valueKey: { type: String, default: "value" }, textKey: { type: String, default: "text" }, childrenKey: { type: String, default: "children" }, convertConfig: Object }, components: {}, emits: ["update:modelValue", "change", "pathChange"], setup(t2, { emit: n2 }) {
93
+ const o2 = e(() => ({ lazy: t2.lazy, lazyLoad: t2.lazyLoad, valueKey: t2.valueKey, textKey: t2.textKey, childrenKey: t2.childrenKey, convertConfig: t2.convertConfig })), i2 = l(0), s2 = l(false), r2 = l(t2.modelValue), u2 = l(new k([], {})), d2 = l([]), c2 = e(() => o2.value.lazy && Boolean(o2.value.lazyLoad)), v2 = /* @__PURE__ */ new Map();
94
+ let h2;
95
+ const p2 = async () => {
96
+ v2.clear(), d2.value = [], i2.value = 0, s2.value = false, h2 = null;
97
+ let { options: e2 } = t2;
98
+ o2.value.convertConfig && (e2 = ((e3, l2) => {
99
+ const a2 = __spreadValues(__spreadValues({}, C), l2 || {}), { topId: t3, idKey: n3, pidKey: o3, sortKey: i3 } = a2;
100
+ let s3 = [], r3 = {};
101
+ return e3.forEach((e4) => {
102
+ e4 = __spreadValues({}, e4);
103
+ const { [n3]: l3, [o3]: a3 } = e4, i4 = r3[a3] = r3[a3] || [];
104
+ s3.length || a3 !== t3 || (s3 = i4), i4.push(e4), e4.children = r3[l3] || (r3[l3] = []);
105
+ }), i3 && Object.keys(r3).forEach((e4) => {
106
+ r3[e4].length > 1 && r3[e4].sort((e5, l3) => e5[i3] - l3[i3]);
107
+ }), r3 = null, s3;
108
+ })(e2, o2.value.convertConfig)), u2.value = new k(e2, { value: o2.value.valueKey, text: o2.value.textKey, children: o2.value.childrenKey }), c2.value && !u2.value.nodes.length && await g2({ root: true, loading: true, text: "", value: "" }), d2.value = [{ nodes: u2.value.nodes, selectedNode: null }], y2();
109
+ }, y2 = async () => {
110
+ const e2 = r2.value;
111
+ if (e2 === void 0 || !u2.value.nodes.length)
112
+ return;
113
+ if (e2.length === 0)
114
+ return i2.value = 0, void (d2.value = [{ nodes: u2.value.nodes, selectedNode: null }]);
115
+ let l2 = e2;
116
+ if (c2.value && Array.isArray(e2) && e2.length) {
117
+ l2 = [];
118
+ let a2 = u2.value.nodes.find((l3) => l3.value === e2[0]);
119
+ if (a2) {
120
+ l2 = [a2.value], s2.value = true;
121
+ const t3 = await e2.slice(1).reduce(async (e3, a3) => {
122
+ var _a;
123
+ const t4 = await e3;
124
+ await g2(t4);
125
+ const n3 = (_a = t4 == null ? void 0 : t4.children) == null ? void 0 : _a.find((e4) => e4.value === a3);
126
+ return n3 && l2.push(a3), Promise.resolve(n3);
127
+ }, Promise.resolve(a2));
128
+ await g2(t3), s2.value = false;
215
129
  }
216
- tree.value = new Tree(options, {
217
- value: configs.value.valueKey,
218
- text: configs.value.textKey,
219
- children: configs.value.childrenKey
130
+ }
131
+ if (l2.length && e2 === t2.modelValue) {
132
+ u2.value.getPathNodesByValue(l2).map((e3, l3) => {
133
+ i2.value = l3, f2.handleNode(e3, true);
220
134
  });
221
- if (isLazy.value && !tree.value.nodes.length) {
222
- await invokeLazyLoad({
223
- root: true,
224
- loading: true,
225
- text: "",
226
- value: ""
227
- });
228
- }
229
- panes.value = [{ nodes: tree.value.nodes, selectedNode: null }];
230
- syncValue();
231
- };
232
- const syncValue = async () => {
233
- const currentValue = innerValue.value;
234
- if (currentValue === void 0 || !tree.value.nodes.length) {
235
- return;
236
- }
237
- if (currentValue.length === 0) {
238
- tabsCursor.value = 0;
239
- panes.value = [{ nodes: tree.value.nodes, selectedNode: null }];
240
- return;
241
- }
242
- let needToSync = currentValue;
243
- if (isLazy.value && Array.isArray(currentValue) && currentValue.length) {
244
- needToSync = [];
245
- let parent = tree.value.nodes.find((node) => node.value === currentValue[0]);
246
- if (parent) {
247
- needToSync = [parent.value];
248
- initLoading.value = true;
249
- const last = await currentValue.slice(1).reduce(async (p, value) => {
250
- var _a;
251
- const parent2 = await p;
252
- await invokeLazyLoad(parent2);
253
- const node = (_a = parent2 == null ? void 0 : parent2.children) == null ? void 0 : _a.find((item) => item.value === value);
254
- if (node) {
255
- needToSync.push(value);
256
- }
257
- return Promise.resolve(node);
258
- }, Promise.resolve(parent));
259
- await invokeLazyLoad(last);
260
- initLoading.value = false;
261
- }
262
- }
263
- if (needToSync.length && currentValue === props.modelValue) {
264
- const pathNodes = tree.value.getPathNodesByValue(needToSync);
265
- pathNodes.map((node, index2) => {
266
- tabsCursor.value = index2;
267
- methods.handleNode(node, true);
268
- });
269
- }
270
- };
271
- const invokeLazyLoad = async (node) => {
272
- if (!node) {
273
- return;
274
- }
275
- if (!configs.value.lazyLoad) {
276
- node.leaf = true;
277
- return;
278
- }
279
- if (tree.value.isLeaf(node, isLazy.value) || tree.value.hasChildren(node, isLazy.value)) {
280
- return;
281
- }
282
- node.loading = true;
283
- const parent = node.root ? null : node;
284
- let lazyLoadPromise = lazyLoadMap.get(node);
285
- if (!lazyLoadPromise) {
286
- lazyLoadPromise = new Promise((resolve) => {
287
- var _a, _b;
288
- (_b = (_a = configs.value).lazyLoad) == null ? void 0 : _b.call(_a, node, resolve);
289
- });
290
- lazyLoadMap.set(node, lazyLoadPromise);
291
- }
292
- const nodes = await lazyLoadPromise;
293
- if (Array.isArray(nodes) && nodes.length > 0) {
294
- tree.value.updateChildren(nodes, parent);
295
- } else {
296
- node.leaf = true;
297
- }
298
- node.loading = false;
299
- lazyLoadMap.delete(node);
300
- };
301
- const emitChange = (pathNodes) => {
302
- const emitValue = pathNodes.map((node) => node.value);
303
- innerValue.value = emitValue;
304
- emit("change", emitValue, pathNodes);
305
- emit("update:modelValue", emitValue, pathNodes);
306
- };
307
- const methods = {
308
- async handleNode(node, silent) {
309
- const { disabled, loading } = node;
310
- if (!silent && disabled || !panes.value[tabsCursor.value]) {
311
- return;
312
- }
313
- if (tree.value.isLeaf(node, isLazy.value)) {
314
- node.leaf = true;
315
- panes.value[tabsCursor.value].selectedNode = node;
316
- panes.value = panes.value.slice(0, node.level + 1);
317
- if (!silent) {
318
- const pathNodes = panes.value.map((pane) => pane.selectedNode);
319
- emitChange(pathNodes);
320
- emit("pathChange", pathNodes);
321
- }
322
- return;
323
- }
324
- if (tree.value.hasChildren(node, isLazy.value)) {
325
- const level = node.level + 1;
326
- panes.value[tabsCursor.value].selectedNode = node;
327
- panes.value = panes.value.slice(0, level);
328
- panes.value.push({
329
- nodes: node.children || [],
330
- selectedNode: null
331
- });
332
- tabsCursor.value = level;
333
- if (!silent) {
334
- const pathNodes = panes.value.map((pane) => pane.selectedNode);
335
- emit("pathChange", pathNodes);
336
- }
337
- return;
338
- }
339
- currentProcessNode = node;
340
- if (loading) {
341
- return;
135
+ }
136
+ }, g2 = async (e2) => {
137
+ if (!e2)
138
+ return;
139
+ if (!o2.value.lazyLoad)
140
+ return void (e2.leaf = true);
141
+ if (u2.value.isLeaf(e2, c2.value) || u2.value.hasChildren(e2, c2.value))
142
+ return;
143
+ e2.loading = true;
144
+ const l2 = e2.root ? null : e2;
145
+ let a2 = v2.get(e2);
146
+ a2 || (a2 = new Promise((l3) => {
147
+ var _a, _b;
148
+ (_b = (_a = o2.value).lazyLoad) == null ? void 0 : _b.call(_a, e2, l3);
149
+ }), v2.set(e2, a2));
150
+ const t3 = await a2;
151
+ Array.isArray(t3) && t3.length > 0 ? u2.value.updateChildren(t3, l2) : e2.leaf = true, e2.loading = false, v2.delete(e2);
152
+ }, f2 = { async handleNode(e2, l2) {
153
+ const { disabled: a2, loading: t3 } = e2;
154
+ if ((l2 || !a2) && d2.value[i2.value])
155
+ if (u2.value.isLeaf(e2, c2.value)) {
156
+ if (e2.leaf = true, d2.value[i2.value].selectedNode = e2, d2.value = d2.value.slice(0, e2.level + 1), !l2) {
157
+ const e3 = d2.value.map((e4) => e4.selectedNode);
158
+ ((e4) => {
159
+ const l3 = e4.map((e5) => e5.value);
160
+ r2.value = l3, n2("change", l3, e4), n2("update:modelValue", l3, e4);
161
+ })(e3), n2("pathChange", e3);
342
162
  }
343
- await invokeLazyLoad(node);
344
- if (currentProcessNode === node) {
345
- panes.value[tabsCursor.value].selectedNode = node;
346
- methods.handleNode(node, silent);
163
+ } else if (u2.value.hasChildren(e2, c2.value)) {
164
+ const a3 = e2.level + 1;
165
+ if (d2.value[i2.value].selectedNode = e2, d2.value = d2.value.slice(0, a3), d2.value.push({ nodes: e2.children || [], selectedNode: null }), i2.value = a3, !l2) {
166
+ const e3 = d2.value.map((e4) => e4.selectedNode);
167
+ n2("pathChange", e3);
347
168
  }
348
- },
349
- handleTabClick(tab) {
350
- currentProcessNode = null;
351
- tabsCursor.value = tab.paneKey;
352
- },
353
- formatTabTitle(pane) {
354
- return pane.selectedNode ? pane.selectedNode.text : translate("select");
355
- },
356
- isSelected(pane, node) {
357
- return pane.selectedNode && pane.selectedNode.value === node.value;
358
- }
359
- };
360
- watch([configs, () => props.options], () => {
361
- init();
362
- }, {
363
- deep: true,
364
- immediate: true
365
- });
366
- watch(() => props.modelValue, (value) => {
367
- if (value !== innerValue.value) {
368
- innerValue.value = value;
369
- syncValue();
370
- }
371
- });
372
- watch(() => props.visible, (val) => {
373
- if (val && Array.isArray(innerValue.value) && innerValue.value.length > 0) {
374
- syncValue();
375
- }
376
- });
377
- return __spreadValues({ panes, initLoading, tabsCursor }, methods);
378
- }
379
- });
380
- const _hoisted_1$1 = {
381
- role: "menu",
382
- class: "nut-cascader-pane"
383
- };
384
- const _hoisted_2 = ["aria-checked", "aria-disabled", "onClick"];
385
- const _hoisted_3 = { class: "nut-cascader-item__title" };
386
- const _hoisted_4 = /* @__PURE__ */ createElementVNode("view", { class: "nut-cascader-pane" }, null, -1);
387
- function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
388
- const _component_nut_icon = resolveComponent("nut-icon");
389
- const _component_nut_tabpane = resolveComponent("nut-tabpane");
390
- const _component_nut_tabs = resolveComponent("nut-tabs");
391
- return openBlock(), createBlock(_component_nut_tabs, {
392
- class: "nut-cascader",
393
- modelValue: _ctx.tabsCursor,
394
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.tabsCursor = $event),
395
- onClick: _ctx.handleTabClick,
396
- "title-scroll": ""
397
- }, {
398
- default: withCtx(() => [
399
- !_ctx.initLoading && _ctx.panes.length ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(_ctx.panes, (pane, index2) => {
400
- return openBlock(), createBlock(_component_nut_tabpane, {
401
- title: _ctx.formatTabTitle(pane),
402
- key: index2
403
- }, {
404
- default: withCtx(() => [
405
- createElementVNode("view", _hoisted_1$1, [
406
- (openBlock(true), createElementBlock(Fragment, null, renderList(pane.nodes, (node) => {
407
- return openBlock(), createElementBlock("view", {
408
- key: node.value,
409
- class: normalizeClass(["nut-cascader-item", { active: _ctx.isSelected(pane, node), disabled: node.disabled }]),
410
- "aria-checked": _ctx.isSelected(pane, node),
411
- "aria-disabled": node.disabled || void 0,
412
- role: "menuitemradio",
413
- onClick: ($event) => _ctx.handleNode(node, false)
414
- }, [
415
- createElementVNode("view", _hoisted_3, toDisplayString(node.text), 1),
416
- node.loading ? (openBlock(), createBlock(_component_nut_icon, {
417
- key: 0,
418
- class: "nut-cascader-item__icon-loading",
419
- name: "loading"
420
- })) : (openBlock(), createBlock(_component_nut_icon, {
421
- key: 1,
422
- class: "nut-cascader-item__icon-check",
423
- name: "checklist"
424
- }))
425
- ], 10, _hoisted_2);
426
- }), 128))
427
- ])
428
- ]),
429
- _: 2
430
- }, 1032, ["title"]);
431
- }), 128)) : (openBlock(), createBlock(_component_nut_tabpane, {
432
- key: 1,
433
- title: "Loading..."
434
- }, {
435
- default: withCtx(() => [
436
- _hoisted_4
437
- ]),
438
- _: 1
439
- }))
440
- ]),
441
- _: 1
442
- }, 8, ["modelValue", "onClick"]);
443
- }
444
- var CascaderItem = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
445
- const { create } = createComponent("cascader");
446
- const _sfc_main = create({
447
- components: {
448
- [CascaderItem.name]: CascaderItem
449
- },
450
- props: __spreadProps(__spreadValues({}, popupProps), {
451
- modelValue: Array,
452
- visible: Boolean,
453
- title: String,
454
- options: {
455
- type: Array,
456
- default: () => []
457
- },
458
- lazy: Boolean,
459
- lazyLoad: Function,
460
- valueKey: {
461
- type: String,
462
- default: "value"
463
- },
464
- textKey: {
465
- type: String,
466
- default: "text"
467
- },
468
- childrenKey: {
469
- type: String,
470
- default: "children"
471
- },
472
- convertConfig: Object
473
- }),
474
- emits: ["update:modelValue", "change", "pathChange", "update:visible"],
475
- setup(props, { emit }) {
476
- const innerValue = ref(props.modelValue);
477
- const innerVisible = computed({
478
- get() {
479
- return props.visible;
480
- },
481
- set(value) {
482
- emit("update:visible", value);
483
- }
484
- });
485
- const onChange = (value, pathNodes) => {
486
- innerValue.value = value;
487
- innerVisible.value = false;
488
- emit("change", value, pathNodes);
489
- emit("update:modelValue", value);
490
- };
491
- const onPathChange = (pathNodes) => {
492
- emit("pathChange", pathNodes);
493
- };
494
- watch(() => props.modelValue, (value) => {
495
- if (value !== innerValue.value) {
496
- innerValue.value = value;
497
- }
498
- });
499
- return {
500
- onChange,
501
- onPathChange,
502
- innerValue,
503
- innerVisible
504
- };
505
- }
506
- });
507
- const _hoisted_1 = ["innerHTML"];
508
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
509
- const _component_nut_cascader_item = resolveComponent("nut-cascader-item");
510
- const _component_nut_popup = resolveComponent("nut-popup");
511
- return openBlock(), createBlock(_component_nut_popup, {
512
- visible: _ctx.innerVisible,
513
- "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => _ctx.innerVisible = $event),
514
- position: "bottom",
515
- "pop-class": "nut-cascader__popup",
516
- round: "",
517
- closeable: !_ctx.closeable,
518
- "close-icon": _ctx.closeIcon,
519
- "destroy-on-close": false,
520
- "close-icon-position": _ctx.closeIconPosition
521
- }, {
522
- default: withCtx(() => [
523
- _ctx.title ? (openBlock(), createElementBlock("view", {
524
- key: 0,
525
- class: "nut-cascader__bar",
526
- innerHTML: _ctx.title
527
- }, null, 8, _hoisted_1)) : createCommentVNode("", true),
528
- createVNode(_component_nut_cascader_item, {
529
- onChange: _ctx.onChange,
530
- onPathChange: _ctx.onPathChange,
531
- modelValue: _ctx.innerValue,
532
- options: _ctx.options,
533
- lazy: _ctx.lazy,
534
- "lazy-load": _ctx.lazyLoad,
535
- "value-key": _ctx.valueKey,
536
- "text-key": _ctx.textKey,
537
- "children-key": _ctx.childrenKey,
538
- "convert-config": _ctx.convertConfig,
539
- visible: _ctx.innerVisible
540
- }, null, 8, ["onChange", "onPathChange", "modelValue", "options", "lazy", "lazy-load", "value-key", "text-key", "children-key", "convert-config", "visible"])
541
- ]),
542
- _: 1
543
- }, 8, ["visible", "closeable", "close-icon", "close-icon-position"]);
544
- }
545
- var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
546
- export { index as default };
169
+ } else
170
+ h2 = e2, t3 || (await g2(e2), h2 === e2 && (d2.value[i2.value].selectedNode = e2, f2.handleNode(e2, l2)));
171
+ }, handleTabClick(e2) {
172
+ h2 = null, i2.value = e2.paneKey;
173
+ }, formatTabTitle: (e2) => e2.selectedNode ? e2.selectedNode.text : V("select"), isSelected: (e2, l2) => e2.selectedNode && e2.selectedNode.value === l2.value };
174
+ return a([o2, () => t2.options], () => {
175
+ p2();
176
+ }, { deep: true, immediate: true }), a(() => t2.modelValue, (e2) => {
177
+ e2 !== r2.value && (r2.value = e2, y2());
178
+ }), a(() => t2.visible, (e2) => {
179
+ e2 && Array.isArray(r2.value) && r2.value.length > 0 && y2();
180
+ }), __spreadValues({ panes: d2, initLoading: s2, tabsCursor: i2 }, f2);
181
+ } }), N = { role: "menu", class: "nut-cascader-pane" }, z = ["aria-checked", "aria-disabled", "onClick"], L = { class: "nut-cascader-item__title" }, _ = d("view", { class: "nut-cascader-pane" }, null, -1);
182
+ var w = f(x, [["render", function(e2, l2, a2, h2, p2, y2) {
183
+ const g2 = t("nut-icon"), f2 = t("nut-tabpane"), m2 = t("nut-tabs");
184
+ return n(), o(m2, { class: "nut-cascader", modelValue: e2.tabsCursor, "onUpdate:modelValue": l2[0] || (l2[0] = (l3) => e2.tabsCursor = l3), onClick: e2.handleTabClick, "title-scroll": "" }, { default: i(() => [!e2.initLoading && e2.panes.length ? (n(true), s(r, { key: 0 }, u(e2.panes, (l3, a3) => (n(), o(f2, { title: e2.formatTabTitle(l3), key: a3 }, { default: i(() => [d("view", N, [(n(true), s(r, null, u(l3.nodes, (a4) => (n(), s("view", { key: a4.value, class: c(["nut-cascader-item", { active: e2.isSelected(l3, a4), disabled: a4.disabled }]), "aria-checked": e2.isSelected(l3, a4), "aria-disabled": a4.disabled || void 0, role: "menuitemradio", onClick: (l4) => e2.handleNode(a4, false) }, [d("view", L, v(a4.text), 1), a4.loading ? (n(), o(g2, { key: 0, class: "nut-cascader-item__icon-loading", name: "loading" })) : (n(), o(g2, { key: 1, class: "nut-cascader-item__icon-check", name: "checklist" }))], 10, z))), 128))])]), _: 2 }, 1032, ["title"]))), 128)) : (n(), o(f2, { key: 1, title: "Loading..." }, { default: i(() => [_]), _: 1 }))]), _: 1 }, 8, ["modelValue", "onClick"]);
185
+ }]]);
186
+ const { create: A } = g("cascader"), P = A({ components: { [w.name]: w }, props: __spreadProps(__spreadValues({}, y), { modelValue: Array, visible: Boolean, title: String, options: { type: Array, default: () => [] }, lazy: Boolean, lazyLoad: Function, valueKey: { type: String, default: "value" }, textKey: { type: String, default: "text" }, childrenKey: { type: String, default: "children" }, convertConfig: Object }), emits: ["update:modelValue", "change", "pathChange", "update:visible"], setup(t2, { emit: n2 }) {
187
+ const o2 = l(t2.modelValue), i2 = e({ get: () => t2.visible, set(e2) {
188
+ n2("update:visible", e2);
189
+ } });
190
+ return a(() => t2.modelValue, (e2) => {
191
+ e2 !== o2.value && (o2.value = e2);
192
+ }), { onChange: (e2, l2) => {
193
+ o2.value = e2, i2.value = false, n2("change", e2, l2), n2("update:modelValue", e2);
194
+ }, onPathChange: (e2) => {
195
+ n2("pathChange", e2);
196
+ }, innerValue: o2, innerVisible: i2 };
197
+ } }), B = ["innerHTML"];
198
+ var S = f(P, [["render", function(e2, l2, a2, r2, u2, d2) {
199
+ const c2 = t("nut-cascader-item"), v2 = t("nut-popup");
200
+ return n(), o(v2, { visible: e2.innerVisible, "onUpdate:visible": l2[0] || (l2[0] = (l3) => e2.innerVisible = l3), position: "bottom", "pop-class": "nut-cascader__popup", round: "", closeable: !e2.closeable, "close-icon": e2.closeIcon, "destroy-on-close": false, "close-icon-position": e2.closeIconPosition }, { default: i(() => [e2.title ? (n(), s("view", { key: 0, class: "nut-cascader__bar", innerHTML: e2.title }, null, 8, B)) : h("", true), p(c2, { onChange: e2.onChange, onPathChange: e2.onPathChange, modelValue: e2.innerValue, options: e2.options, lazy: e2.lazy, "lazy-load": e2.lazyLoad, "value-key": e2.valueKey, "text-key": e2.textKey, "children-key": e2.childrenKey, "convert-config": e2.convertConfig, visible: e2.innerVisible }, null, 8, ["onChange", "onPathChange", "modelValue", "options", "lazy", "lazy-load", "value-key", "text-key", "children-key", "convert-config", "visible"])]), _: 1 }, 8, ["visible", "closeable", "close-icon", "close-icon-position"]);
201
+ }]]);
202
+ export { S as default };