@nutui/nutui 3.1.18-beta.0 → 3.1.19-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 (149) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/LICENSE +1 -1
  3. package/README.md +6 -0
  4. package/dist/nutui.d.ts +39 -36
  5. package/dist/nutui.es.js +13149 -11288
  6. package/dist/nutui.umd.js +13156 -11381
  7. package/dist/packages/_es/ActionSheet.js +13 -19
  8. package/dist/packages/_es/Address.js +70 -55
  9. package/dist/packages/_es/Audio.js +13 -13
  10. package/dist/packages/_es/AudioOperate.js +125 -0
  11. package/dist/packages/_es/Avatar.js +4 -4
  12. package/dist/packages/_es/BackTop.js +69 -108
  13. package/dist/packages/_es/Badge.js +4 -4
  14. package/dist/packages/_es/Barrage.js +63 -56
  15. package/dist/packages/_es/Button.js +3 -3
  16. package/dist/packages/_es/Calendar.js +30 -702
  17. package/dist/packages/_es/CalendarItem.js +10 -0
  18. package/dist/packages/_es/Card.js +7 -6
  19. package/dist/packages/_es/Cascader.js +8 -8
  20. package/dist/packages/_es/Cell.js +27 -27
  21. package/dist/packages/_es/CellGroup.js +2 -2
  22. package/dist/packages/_es/Checkbox.js +4 -4
  23. package/dist/packages/_es/CheckboxGroup.js +3 -3
  24. package/dist/packages/_es/CircleProgress.js +150 -41
  25. package/dist/packages/_es/Col.js +2 -2
  26. package/dist/packages/_es/Collapse.js +35 -9
  27. package/dist/packages/_es/CollapseItem.js +79 -38
  28. package/dist/packages/_es/CountDown.js +8 -6
  29. package/dist/packages/_es/CountUp.js +31 -30
  30. package/dist/packages/_es/DatePicker.js +81 -44
  31. package/dist/packages/_es/Dialog.js +7 -83
  32. package/dist/packages/_es/Divider.js +5 -5
  33. package/dist/packages/_es/Drag.js +93 -55
  34. package/dist/packages/_es/Elevator.js +75 -50
  35. package/dist/packages/_es/Empty.js +4 -4
  36. package/dist/packages/_es/FixedNav.js +6 -6
  37. package/dist/packages/_es/Form.js +11 -9
  38. package/dist/packages/_es/FormItem.js +9 -6
  39. package/dist/packages/_es/Grid.js +2 -2
  40. package/dist/packages/_es/GridItem.js +9 -27
  41. package/dist/packages/_es/Icon.js +2 -2
  42. package/dist/packages/_es/ImagePreview.js +14 -83
  43. package/dist/packages/_es/Indicator.js +4 -4
  44. package/dist/packages/_es/InfiniteLoading.js +94 -108
  45. package/dist/packages/_es/Input.js +297 -73
  46. package/dist/packages/_es/InputNumber.js +24 -17
  47. package/dist/packages/_es/Layout.js +2 -2
  48. package/dist/packages/_es/List.js +131 -0
  49. package/dist/packages/_es/Menu.js +16 -13
  50. package/dist/packages/_es/MenuItem.js +8 -8
  51. package/dist/packages/_es/Navbar.js +17 -12
  52. package/dist/packages/_es/NoticeBar.js +47 -39
  53. package/dist/packages/_es/Notify.js +28 -163
  54. package/dist/packages/_es/NumberKeyboard.js +4 -4
  55. package/dist/packages/_es/OldPicker.js +486 -0
  56. package/dist/packages/_es/OverLay.js +6 -26
  57. package/dist/packages/_es/Pagination.js +8 -8
  58. package/dist/packages/_es/Picker.js +192 -163
  59. package/dist/packages/_es/Popover.js +155 -30
  60. package/dist/packages/_es/Popup.js +7 -70
  61. package/dist/packages/_es/Price.js +18 -6
  62. package/dist/packages/_es/Progress.js +29 -27
  63. package/dist/packages/_es/PullRefresh.js +363 -0
  64. package/dist/packages/_es/Radio.js +4 -4
  65. package/dist/packages/_es/RadioGroup.js +2 -2
  66. package/dist/packages/_es/Range.js +169 -46
  67. package/dist/packages/_es/Rate.js +17 -20
  68. package/dist/packages/_es/Row.js +2 -2
  69. package/dist/packages/_es/SearchBar.js +9 -7
  70. package/dist/packages/_es/ShortPassword.js +90 -68
  71. package/dist/packages/_es/SideNavBar.js +6 -17
  72. package/dist/packages/_es/SideNavBarItem.js +2 -2
  73. package/dist/packages/_es/Signature.js +70 -70
  74. package/dist/packages/_es/Skeleton.js +9 -12
  75. package/dist/packages/_es/Sku.js +40 -31
  76. package/dist/packages/_es/Step.js +28 -12
  77. package/dist/packages/_es/Steps.js +8 -3
  78. package/dist/packages/_es/Sticky.js +29 -24
  79. package/dist/packages/_es/SubSideNavBar.js +2 -2
  80. package/dist/packages/_es/Swipe.js +40 -27
  81. package/dist/packages/_es/Swiper.js +32 -14
  82. package/dist/packages/_es/SwiperItem.js +2 -2
  83. package/dist/packages/_es/Switch.js +4 -4
  84. package/dist/packages/_es/TabPane.js +2 -2
  85. package/dist/packages/_es/Tabbar.js +4 -4
  86. package/dist/packages/_es/TabbarItem.js +28 -23
  87. package/dist/packages/_es/Table.js +14 -14
  88. package/dist/packages/_es/Tabs.js +19 -15
  89. package/dist/packages/_es/Tag.js +14 -8
  90. package/dist/packages/_es/TextArea.js +49 -15
  91. package/dist/packages/_es/TimeDetail.js +5 -4
  92. package/dist/packages/_es/TimePannel.js +4 -4
  93. package/dist/packages/_es/TimeSelect.js +9 -8
  94. package/dist/packages/_es/Toast.js +42 -171
  95. package/dist/packages/_es/Uploader.js +108 -139
  96. package/dist/packages/_es/Video.js +14 -10
  97. package/dist/packages/_es/common.js +2 -2
  98. package/dist/packages/_es/component.js +2 -2
  99. package/dist/packages/_es/index.js +45 -7
  100. package/dist/packages/_es/index.taro.js +719 -0
  101. package/dist/packages/_es/index2.js +2 -2
  102. package/dist/packages/_es/index3.js +57 -29
  103. package/dist/packages/_es/index4.js +414 -57
  104. package/dist/packages/_es/plugin-vue_export-helper.js +2 -2
  105. package/dist/packages/_es/pxCheck.js +2 -2
  106. package/dist/packages/_es/use-lock-scroll.js +23 -0
  107. package/dist/packages/_es/util.js +2 -2
  108. package/dist/packages/badge/index.scss +11 -13
  109. package/dist/packages/button/index.scss +1 -0
  110. package/dist/packages/calendar/index.scss +9 -4
  111. package/dist/packages/calendaritem/index.scss +0 -207
  112. package/dist/packages/cell/index.scss +6 -6
  113. package/dist/packages/checkbox/index.scss +4 -3
  114. package/dist/packages/collapseitem/index.scss +21 -11
  115. package/dist/packages/countdown/index.scss +3 -1
  116. package/dist/packages/divider/index.scss +8 -8
  117. package/dist/packages/elevator/index.scss +36 -36
  118. package/dist/packages/formitem/index.scss +15 -8
  119. package/dist/packages/indicator/index.scss +1 -1
  120. package/dist/packages/input/index.scss +70 -24
  121. package/dist/packages/inputnumber/index.scss +4 -2
  122. package/dist/packages/list/index.scss +24 -0
  123. package/dist/packages/menu/index.scss +3 -3
  124. package/dist/packages/navbar/index.scss +28 -8
  125. package/dist/packages/noticebar/index.scss +7 -8
  126. package/dist/packages/notify/index.scss +9 -0
  127. package/dist/packages/numberkeyboard/index.scss +22 -21
  128. package/dist/packages/oldpicker/index.scss +131 -0
  129. package/dist/packages/picker/index.scss +38 -32
  130. package/dist/packages/progress/index.scss +6 -5
  131. package/dist/packages/radio/index.scss +7 -6
  132. package/dist/packages/range/index.scss +109 -2
  133. package/dist/packages/searchbar/index.scss +7 -7
  134. package/dist/packages/sidenavbaritem/index.scss +5 -5
  135. package/dist/packages/step/index.scss +29 -29
  136. package/dist/packages/subsidenavbar/index.scss +10 -8
  137. package/dist/packages/tabbaritem/index.scss +15 -0
  138. package/dist/packages/timedetail/index.scss +13 -13
  139. package/dist/packages/timepannel/index.scss +7 -7
  140. package/dist/packages/timeselect/index.scss +3 -3
  141. package/dist/packages/uploader/index.scss +6 -6
  142. package/dist/style.css +1 -1
  143. package/dist/styles/themes/default.scss +64 -62
  144. package/dist/styles/themes/jdt.scss +91 -0
  145. package/dist/styles/variables-jdt.scss +728 -0
  146. package/dist/styles/variables.scss +250 -44
  147. package/package.json +2 -1
  148. package/dist/packages/_es/raf.js +0 -19
  149. package/dist/styles/themes/jdd.scss +0 -2
@@ -18,56 +18,50 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  /*!
21
- * @nutui/nutui v3.1.18-beta.0 Tue Mar 08 2022 10:41:31 GMT+0800 (中国标准时间)
22
- * (c) 2021 @jdf2e.
21
+ * @nutui/nutui v3.1.19-beta.1 Sat Apr 02 2022 16:26:37 GMT+0800 (中国标准时间)
22
+ * (c) 2022 @jdf2e.
23
23
  * Released under the MIT License.
24
24
  */
25
- import { ref, reactive, computed, watch, onMounted, toRefs, openBlock, createElementBlock, createElementVNode, normalizeStyle, Fragment, renderList, normalizeClass, toDisplayString, createCommentVNode, toRaw, resolveComponent, createVNode, withCtx } from "vue";
25
+ import { ref, reactive, computed, watch, onMounted, toRefs, openBlock, createElementBlock, createElementVNode, normalizeStyle, Fragment, renderList, normalizeClass, toDisplayString, createCommentVNode, onBeforeUnmount, resolveComponent, createVNode, withCtx } from "vue";
26
26
  import { c as createComponent } from "./component.js";
27
+ import { popupProps } from "./Popup.js";
28
+ import { u as useTaroRect } from "./index.js";
29
+ import Taro from "@tarojs/taro";
27
30
  import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
28
- import Popup, { popupProps } from "./Popup.js";
31
+ import "./use-lock-scroll.js";
29
32
  import "./OverLay.js";
30
33
  import "./Icon.js";
31
34
  import "./pxCheck.js";
32
- const commonProps = {
33
- listData: {
34
- type: Array,
35
- default: () => {
36
- return [];
37
- }
38
- },
39
- readonly: {
40
- type: Boolean,
41
- default: false
42
- },
43
- defaultIndex: {
44
- type: [Number, String],
45
- default: 0
46
- },
47
- itemHeight: {
48
- type: [Number, String],
49
- default: 35
50
- }
51
- };
52
35
  const { create: create$1 } = createComponent("picker-column");
53
36
  const _sfc_main$1 = create$1({
54
- props: __spreadValues({
55
- dataType: String,
37
+ props: {
38
+ value: [String, Number],
39
+ columnsType: String,
56
40
  itemShow: {
57
41
  type: Boolean,
58
42
  default: false
43
+ },
44
+ column: {
45
+ type: Array,
46
+ default: () => []
47
+ },
48
+ readonly: {
49
+ type: Boolean,
50
+ default: false
59
51
  }
60
- }, commonProps),
52
+ },
61
53
  emits: ["click", "change"],
62
54
  setup(props, { emit }) {
63
55
  const wrapper = ref();
56
+ const itemref = ref();
64
57
  const state = reactive({
65
58
  touchParams: {
66
59
  startY: 0,
67
60
  endY: 0,
68
61
  startTime: 0,
69
62
  endTime: 0,
70
- lastY: 0
63
+ lastY: 0,
64
+ lastTime: 0
71
65
  },
72
66
  currIndex: 1,
73
67
  transformY: 0,
@@ -78,7 +72,7 @@ const _sfc_main$1 = create$1({
78
72
  });
79
73
  const roller = ref(null);
80
74
  const list = ref(null);
81
- const listItem = ref(null);
75
+ const listitem = ref(null);
82
76
  const touchDeg = ref(0);
83
77
  const touchTime = ref(0);
84
78
  const touchTranslateY = ref(0);
@@ -113,7 +107,7 @@ const _sfc_main$1 = create$1({
113
107
  event.preventDefault();
114
108
  let changedTouches = event.changedTouches[0];
115
109
  state.touchParams.lastY = changedTouches.pageY;
116
- state.touchParams.lastTime = event.timestamp || Date.now();
110
+ state.touchParams.lastTime = event.timeStamp || Date.now();
117
111
  let move = state.touchParams.lastY - state.touchParams.startY;
118
112
  let moveTime = state.touchParams.lastTime - state.touchParams.startTime;
119
113
  if (moveTime <= 300) {
@@ -150,8 +144,8 @@ const _sfc_main$1 = create$1({
150
144
  if (updateMove > 0) {
151
145
  updateMove = 0;
152
146
  }
153
- if (updateMove < -(props.listData.values.length - 1) * state.lineSpacing) {
154
- updateMove = -(props.listData.values.length - 1) * state.lineSpacing;
147
+ if (updateMove < -(props.column.length - 1) * state.lineSpacing) {
148
+ updateMove = -(props.column.length - 1) * state.lineSpacing;
155
149
  }
156
150
  let endMove = Math.round(updateMove / state.lineSpacing) * state.lineSpacing;
157
151
  let deg = `${(Math.abs(Math.round(endMove / state.lineSpacing)) + 1) * state.rotation}deg`;
@@ -173,45 +167,63 @@ const _sfc_main$1 = create$1({
173
167
  }
174
168
  };
175
169
  const setChooseValue = () => {
176
- emit("change", state.currIndex - 1);
170
+ emit("change", props.column[state.currIndex - 1]);
177
171
  };
178
172
  const modifyStatus = (type) => {
179
- let index = props.defaultIndex;
173
+ const { column: column2 } = props;
174
+ let index = column2.findIndex((columnItem) => columnItem.value == props.value);
180
175
  state.currIndex = index === -1 ? 1 : index + 1;
181
176
  let move = index === -1 ? 0 : index * state.lineSpacing;
182
177
  type && setChooseValue();
183
178
  setMove(-move);
184
179
  };
185
- watch(() => props.listData, (val) => {
180
+ const getReference = async () => {
181
+ const refe = await useTaroRect(list, Taro);
182
+ state.lineSpacing = refe.height / props.column.length;
183
+ modifyStatus(true);
184
+ };
185
+ watch(() => props.column, (val) => {
186
186
  state.transformY = 0;
187
187
  modifyStatus(false);
188
188
  }, {
189
189
  deep: true
190
190
  });
191
- watch(() => props.defaultIndex, (val) => {
192
- state.transformY = 0;
193
- modifyStatus(false);
191
+ watch(() => props.itemShow, (val) => {
192
+ if (val) {
193
+ setTimeout(() => {
194
+ getReference();
195
+ }, 200);
196
+ }
197
+ }, {
198
+ deep: true
194
199
  });
195
200
  onMounted(() => {
196
- modifyStatus(true);
201
+ setTimeout(() => {
202
+ getReference();
203
+ }, 200);
197
204
  });
205
+ const refRandomId = Math.random().toString(36).slice(-8);
198
206
  return __spreadProps(__spreadValues(__spreadValues({}, toRefs(state)), toRefs(props)), {
199
207
  wrapper,
208
+ itemref,
200
209
  setRollerStyle,
201
210
  isHidden,
202
211
  roller,
203
212
  list,
204
- listItem,
213
+ listitem,
205
214
  onTouchStart,
206
215
  onTouchMove,
207
216
  onTouchEnd,
208
217
  touchRollerStyle,
209
- touchListStyle
218
+ touchListStyle,
219
+ setMove,
220
+ refRandomId
210
221
  });
211
222
  }
212
223
  });
213
224
  const _hoisted_1$1 = { class: "nut-picker-content" };
214
- const _hoisted_2$1 = {
225
+ const _hoisted_2$1 = ["id"];
226
+ const _hoisted_3$1 = {
215
227
  key: 0,
216
228
  class: "nut-picker-placeholder"
217
229
  };
@@ -227,39 +239,43 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
227
239
  ref: "roller",
228
240
  style: normalizeStyle(_ctx.touchRollerStyle)
229
241
  }, [
230
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.listData.values, (item, index) => {
242
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.column, (item, index) => {
231
243
  return openBlock(), createElementBlock("view", {
232
244
  class: normalizeClass(["nut-picker-roller-item", { "nut-picker-roller-item-hidden": _ctx.isHidden(index + 1) }]),
233
245
  style: normalizeStyle(_ctx.setRollerStyle(index + 1)),
234
- key: item.label ? item.label : index
235
- }, toDisplayString(_ctx.dataType === "cascade" ? item.text : item), 7);
246
+ key: item.value ? item.value : index
247
+ }, toDisplayString(item.text), 7);
236
248
  }), 128))
237
249
  ], 4),
238
250
  createElementVNode("view", _hoisted_1$1, [
239
251
  createElementVNode("view", {
240
252
  class: "nut-picker-list-panel",
241
253
  ref: "list",
254
+ id: "list" + _ctx.refRandomId,
242
255
  style: normalizeStyle(_ctx.touchListStyle)
243
256
  }, [
244
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.listData.values, (item, index) => {
257
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.column, (item, index) => {
245
258
  return openBlock(), createElementBlock("view", {
246
- class: "nut-picker-item nut-picker-item-ref",
247
- key: item.label ? item.label : index
248
- }, toDisplayString(_ctx.dataType === "cascade" ? item.text : item), 1);
259
+ class: normalizeClass(["nut-picker-item", "nut-picker-item-ref", item.className]),
260
+ key: item.value ? item.value : index
261
+ }, toDisplayString(item.text), 3);
249
262
  }), 128)),
250
- _ctx.listData && _ctx.listData.length === 1 ? (openBlock(), createElementBlock("view", _hoisted_2$1)) : createCommentVNode("", true)
251
- ], 4)
263
+ _ctx.column && _ctx.column.length === 1 ? (openBlock(), createElementBlock("view", _hoisted_3$1)) : createCommentVNode("", true)
264
+ ], 12, _hoisted_2$1)
252
265
  ])
253
266
  ], 32);
254
267
  }
255
268
  var column = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
256
- const { create, componentName } = createComponent("picker");
269
+ const { componentName, create } = createComponent("picker");
257
270
  const _sfc_main = create({
258
271
  components: {
259
- [column.name]: column,
260
- [Popup.name]: Popup
272
+ [column.name]: column
261
273
  },
262
- props: __spreadValues(__spreadProps(__spreadValues({}, popupProps), {
274
+ props: __spreadProps(__spreadValues({}, popupProps), {
275
+ modelValue: {
276
+ type: Array,
277
+ default: () => []
278
+ },
263
279
  title: {
264
280
  type: String,
265
281
  default: ""
@@ -271,144 +287,158 @@ const _sfc_main = create({
271
287
  okText: {
272
288
  type: String,
273
289
  default: "\u786E\u5B9A"
290
+ },
291
+ columns: {
292
+ type: Array,
293
+ default: () => {
294
+ return [];
295
+ }
296
+ },
297
+ readonly: {
298
+ type: Boolean,
299
+ default: false
274
300
  }
275
- }), commonProps),
276
- emits: ["close", "change", "confirm", "update:visible"],
301
+ }),
302
+ emits: ["close", "change", "confirm", "update:visible", "update:modelValue"],
277
303
  setup(props, { emit }) {
278
- const childrenKey = "children";
279
- const valuesKey = "values";
280
304
  const state = reactive({
281
305
  show: false,
282
- formattedColumns: props.listData,
283
- defaultIndex: props.defaultIndex
306
+ formattedColumns: props.columns
284
307
  });
285
- let _defaultIndex = props.defaultIndex;
286
- let defaultIndexList = [];
308
+ let defaultValues = ref(props.modelValue);
287
309
  const classes = computed(() => {
288
310
  const prefixCls = componentName;
289
311
  return {
290
312
  [prefixCls]: true
291
313
  };
292
314
  });
293
- const dataType = computed(() => {
315
+ const selectedOptions = computed(() => {
316
+ let optins = [];
317
+ columnsList.value.map((column2, index) => {
318
+ let currOptions = [];
319
+ currOptions = column2.filter((item) => item.value == defaultValues.value[index]);
320
+ optins.push(currOptions[0]);
321
+ });
322
+ return optins;
323
+ });
324
+ const columnsType = computed(() => {
294
325
  const firstColumn = state.formattedColumns[0];
295
- if (typeof firstColumn === "object") {
296
- if (firstColumn[childrenKey]) {
326
+ if (firstColumn) {
327
+ if (Array.isArray(firstColumn)) {
328
+ return "multiple";
329
+ }
330
+ if ("children" in firstColumn) {
297
331
  return "cascade";
298
- } else if (firstColumn == null ? void 0 : firstColumn[valuesKey]) {
299
- addDefaultIndexList(props.listData);
300
- return "multipleColumns";
301
332
  }
302
333
  }
303
- return "text";
334
+ return "single";
304
335
  });
305
- const columnList = computed(() => {
306
- console.log("\u521D\u59CB\u5316", dataType.value);
307
- if (dataType.value === "text") {
308
- return [{ values: state.formattedColumns, defaultIndex: state.defaultIndex }];
309
- } else if (dataType.value === "multipleColumns") {
310
- return state.formattedColumns;
311
- } else if (dataType.value === "cascade") {
312
- return formatCascade(state.formattedColumns, state.defaultIndex);
336
+ const columnsList = computed(() => {
337
+ switch (columnsType.value) {
338
+ case "multiple":
339
+ return state.formattedColumns;
340
+ case "cascade":
341
+ return formatCascade(state.formattedColumns, defaultValues.value);
342
+ default:
343
+ return [state.formattedColumns];
313
344
  }
314
- return state.formattedColumns;
315
345
  });
316
- const addDefaultIndexList = (listData) => {
317
- defaultIndexList = [];
318
- listData.forEach((res) => {
319
- defaultIndexList.push(res.defaultIndex || 0);
320
- });
321
- };
322
- const formatCascade = (listData, defaultIndex) => {
346
+ const formatCascade = (columns, defaultValues2) => {
323
347
  const formatted = [];
324
- let children = listData;
325
- children.defaultIndex = defaultIndex;
326
- while (children) {
327
- formatted.push({
328
- values: children,
329
- defaultIndex: children.defaultIndex || 0
330
- });
331
- children = children == null ? void 0 : children[children.defaultIndex || 0].children;
348
+ let cursor = {
349
+ text: "",
350
+ value: "",
351
+ children: columns
352
+ };
353
+ let columnIndex = 0;
354
+ while (cursor && cursor.children) {
355
+ const options = cursor.children;
356
+ const value = defaultValues2[columnIndex];
357
+ let index = options.findIndex((columnItem) => columnItem.value == value);
358
+ if (index == -1)
359
+ index = 0;
360
+ cursor = cursor.children[index];
361
+ columnIndex++;
362
+ formatted.push(options);
332
363
  }
333
- addDefaultIndexList(formatted);
334
364
  return formatted;
335
365
  };
336
- const getCascadeData = (listData, defaultIndex) => {
337
- var _a;
338
- let arr = listData;
339
- arr.defaultIndex = defaultIndex;
340
- const dataList = [];
341
- while (arr) {
342
- const item = arr[(_a = arr.defaultIndex) != null ? _a : 0];
343
- dataList.push(item.text);
344
- arr = item.children;
345
- }
346
- return dataList;
347
- };
348
366
  const close = () => {
349
367
  emit("close");
350
368
  emit("update:visible", false);
351
369
  };
352
- const changeHandler = (columnIndex, dataIndex) => {
353
- if (dataType.value === "cascade") {
354
- let cursor = state.formattedColumns;
355
- if (columnIndex === 0) {
356
- state.defaultIndex = dataIndex;
357
- }
358
- let i = 0;
359
- while (cursor) {
360
- if (i === columnIndex) {
361
- cursor.defaultIndex = dataIndex;
362
- } else if (i > columnIndex) {
363
- cursor.defaultIndex = 0;
370
+ const changeHandler = (columnIndex, option) => {
371
+ if (option && Object.keys(option).length) {
372
+ if (columnsType.value === "cascade") {
373
+ defaultValues.value[columnIndex] = option.value ? option.value : "";
374
+ let index = columnIndex;
375
+ let cursor = option;
376
+ while (cursor && cursor.children) {
377
+ defaultValues.value[index + 1] = cursor.children[0].value;
378
+ index++;
379
+ cursor = cursor.children[0];
364
380
  }
365
- cursor = cursor[cursor.defaultIndex || 0].children;
366
- i++;
381
+ } else {
382
+ defaultValues.value[columnIndex] = option.value ? option.value : "";
367
383
  }
368
- } else if (dataType.value === "text") {
369
- _defaultIndex = dataIndex;
370
- } else if (dataType.value === "multipleColumns") {
371
- defaultIndexList[columnIndex] = dataIndex;
372
- const val = defaultIndexList.map((res, i) => toRaw(state.formattedColumns)[i].values[res]);
373
- emit("change", val, columnIndex, dataIndex);
384
+ emit("change", {
385
+ columnIndex,
386
+ selectedValue: defaultValues.value,
387
+ selectedOptions: selectedOptions.value
388
+ });
374
389
  }
375
390
  };
376
- const confirm = () => {
377
- if (dataType.value === "text") {
378
- state.defaultIndex = _defaultIndex;
379
- emit("confirm", state.formattedColumns[_defaultIndex]);
380
- } else if (dataType.value === "multipleColumns") {
381
- for (let i = 0; i < defaultIndexList.length; i++) {
382
- state.formattedColumns[i].defaultIndex = defaultIndexList[i];
383
- }
384
- const checkedArr = toRaw(state.formattedColumns).map((res) => res.values && res.values[res.defaultIndex]);
385
- emit("confirm", checkedArr);
386
- } else if (dataType.value === "cascade") {
387
- emit("confirm", getCascadeData(toRaw(state.formattedColumns), state.defaultIndex));
388
- }
391
+ const confirmHandler = () => {
392
+ emit("confirm", {
393
+ selectedValue: defaultValues.value,
394
+ selectedOptions: selectedOptions.value
395
+ });
389
396
  emit("update:visible", false);
390
397
  };
398
+ onMounted(() => {
399
+ if (props.visible)
400
+ state.show = props.visible;
401
+ });
402
+ onBeforeUnmount(() => {
403
+ if (props.visible)
404
+ state.show = false;
405
+ });
406
+ watch(() => props.modelValue, (newValues) => {
407
+ const isSameValue = JSON.stringify(newValues) === JSON.stringify(defaultValues.value);
408
+ if (!isSameValue) {
409
+ defaultValues.value = newValues;
410
+ }
411
+ }, { deep: true });
412
+ watch(defaultValues, (newValues) => {
413
+ const isSameValue = JSON.stringify(newValues) === JSON.stringify(props.modelValue);
414
+ if (!isSameValue) {
415
+ emit("update:modelValue", newValues);
416
+ }
417
+ }, { immediate: true });
391
418
  watch(() => props.visible, (val) => {
392
419
  state.show = val;
393
420
  });
394
- watch(() => props.listData, (val) => {
395
- state.formattedColumns = val;
421
+ watch(() => props.columns, (val) => {
422
+ if (val.length)
423
+ state.formattedColumns = val;
396
424
  });
397
425
  return __spreadProps(__spreadValues({
398
426
  classes
399
427
  }, toRefs(state)), {
400
428
  column,
401
- dataType,
402
- columnList,
429
+ columnsType,
430
+ columnsList,
403
431
  close,
404
432
  changeHandler,
405
- confirm
433
+ confirmHandler,
434
+ defaultValues
406
435
  });
407
436
  }
408
437
  });
409
438
  const _hoisted_1 = { class: "nut-picker__bar" };
410
- const _hoisted_2 = { class: "nut-picker__column" };
411
- const _hoisted_3 = /* @__PURE__ */ createElementVNode("view", { class: "nut-picker__hairline" }, null, -1);
439
+ const _hoisted_2 = { class: "nut-picker__title" };
440
+ const _hoisted_3 = { class: "nut-picker__column" };
441
+ const _hoisted_4 = /* @__PURE__ */ createElementVNode("view", { class: "nut-picker__hairline" }, null, -1);
412
442
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
413
443
  const _component_nut_picker_column = resolveComponent("nut-picker-column");
414
444
  const _component_nut_popup = resolveComponent("nut-popup");
@@ -428,33 +458,32 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
428
458
  default: withCtx(() => [
429
459
  createElementVNode("view", _hoisted_1, [
430
460
  createElementVNode("view", {
431
- class: "nut-picker__left nut-picker__button",
461
+ class: "nut-picker__cancel nut-picker__left nut-picker__button",
432
462
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.close && _ctx.close(...args))
433
463
  }, toDisplayString(_ctx.cancelText), 1),
434
- createElementVNode("view", null, toDisplayString(_ctx.title), 1),
464
+ createElementVNode("view", _hoisted_2, toDisplayString(_ctx.title), 1),
435
465
  createElementVNode("view", {
436
- class: "nut-picker__button",
437
- onClick: _cache[1] || (_cache[1] = ($event) => _ctx.confirm())
466
+ class: "nut-picker__confirm nut-picker__right nut-picker__button",
467
+ onClick: _cache[1] || (_cache[1] = ($event) => _ctx.confirmHandler())
438
468
  }, toDisplayString(_ctx.okText), 1)
439
469
  ]),
440
- createElementVNode("view", _hoisted_2, [
441
- _hoisted_3,
442
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.columnList, (item, columnIndex) => {
470
+ createElementVNode("view", _hoisted_3, [
471
+ _hoisted_4,
472
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.columnsList, (column2, columnIndex) => {
443
473
  return openBlock(), createElementBlock("view", {
444
474
  class: "nut-picker__columnitem",
445
475
  key: columnIndex
446
476
  }, [
447
477
  createVNode(_component_nut_picker_column, {
448
478
  itemShow: _ctx.show,
449
- "list-data": item,
479
+ column: column2,
450
480
  readonly: _ctx.readonly,
451
- "default-index": item.defaultIndex,
452
- "visible-item-count": _ctx.visibleItemCount,
453
- "data-type": _ctx.dataType,
454
- onChange: (dataIndex) => {
455
- _ctx.changeHandler(columnIndex, dataIndex);
481
+ columnsType: _ctx.columnsType,
482
+ value: _ctx.defaultValues[columnIndex],
483
+ onChange: (option) => {
484
+ _ctx.changeHandler(columnIndex, option);
456
485
  }
457
- }, null, 8, ["itemShow", "list-data", "readonly", "default-index", "visible-item-count", "data-type", "onChange"])
486
+ }, null, 8, ["itemShow", "column", "readonly", "columnsType", "value", "onChange"])
458
487
  ]);
459
488
  }), 128))
460
489
  ])
@@ -463,5 +492,5 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
463
492
  }, 8, ["visible", "teleport", "lock-scroll", "close-on-click-overlay", "onClose"])
464
493
  ], 2);
465
494
  }
466
- var picker = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
467
- export { picker as default };
495
+ var nutPicker = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
496
+ export { nutPicker as default };