@nutui/nutui 3.1.22-beta.5 → 3.1.23-beta.1

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