@nutui/nutui 4.1.0-beta.6 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { toRefs, ref, computed, onMounted, nextTick, resolveComponent, openBlock, createElementBlock, createElementVNode, normalizeClass, normalizeStyle, renderSlot, createVNode, createCommentVNode, toDisplayString } from "vue";
1
+ import { toRefs, ref, computed, onMounted, nextTick, resolveComponent, openBlock, createElementBlock, normalizeStyle, createElementVNode, normalizeClass, renderSlot, createVNode, createCommentVNode, toDisplayString } from "vue";
2
2
  import { c as createComponent } from "./component-0fbad28e.js";
3
3
  import { Left } from "@nutui/icons-vue";
4
4
  import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
@@ -41,10 +41,9 @@ const _sfc_main = create({
41
41
  },
42
42
  emits: ["on-click-back", "on-click-title", "on-click-icon", "on-click-right"],
43
43
  setup(props, { emit }) {
44
- const { border, fixed, safeAreaInsetTop, placeholder, zIndex } = toRefs(props);
45
- const navBarWrap = ref(null);
46
- const navBarHtml = ref(null);
47
- let navHeight = ref();
44
+ const { border, fixed, safeAreaInsetTop, placeholder } = toRefs(props);
45
+ const navHeight = ref("auto");
46
+ const navbarRef = ref();
48
47
  const classes = computed(() => {
49
48
  const prefixCls = componentName;
50
49
  return {
@@ -54,37 +53,44 @@ const _sfc_main = create({
54
53
  [`${prefixCls}--safe-area-inset-top`]: safeAreaInsetTop.value
55
54
  };
56
55
  });
57
- const styles = computed(() => {
58
- return {
59
- zIndex: zIndex.value
60
- };
56
+ const rootStyle = computed(() => {
57
+ if (fixed.value && placeholder.value) {
58
+ return {
59
+ height: navHeight.value
60
+ };
61
+ }
62
+ return {};
61
63
  });
64
+ const getNavHeight = () => {
65
+ if (navbarRef.value) {
66
+ const rect = navbarRef.value.getBoundingClientRect();
67
+ navHeight.value = `${rect.height}px`;
68
+ }
69
+ };
62
70
  onMounted(() => {
63
71
  if (fixed.value && placeholder.value) {
64
72
  nextTick(() => {
65
- var _a;
66
- navHeight.value = (_a = navBarHtml == null ? void 0 : navBarHtml.value) == null ? void 0 : _a.getBoundingClientRect().height;
67
- navBarWrap.value.style.height = navHeight.value + "px";
73
+ getNavHeight();
68
74
  });
69
75
  }
70
76
  });
71
- function handleLeft() {
77
+ const handleLeft = () => {
72
78
  emit("on-click-back");
73
- }
74
- function handleCenter() {
79
+ };
80
+ const handleCenter = () => {
75
81
  emit("on-click-title");
76
- }
77
- function handleCenterIcon() {
82
+ };
83
+ const handleCenterIcon = () => {
78
84
  emit("on-click-icon");
79
- }
80
- function handleRight() {
85
+ };
86
+ const handleRight = () => {
81
87
  emit("on-click-right");
82
- }
88
+ };
83
89
  return {
84
- navBarWrap,
85
- navBarHtml,
90
+ navbarRef,
91
+ rootStyle,
86
92
  classes,
87
- styles,
93
+ navHeight,
88
94
  handleLeft,
89
95
  handleCenter,
90
96
  handleCenterIcon,
@@ -93,35 +99,24 @@ const _sfc_main = create({
93
99
  }
94
100
  });
95
101
  const _hoisted_1 = {
96
- key: 0,
97
- class: "nut-navbar--placeholder",
98
- ref: "navBarWrap"
99
- };
100
- const _hoisted_2 = {
101
- key: 1,
102
- class: "nut-navbar__text"
103
- };
104
- const _hoisted_3 = { class: "nut-navbar__title" };
105
- const _hoisted_4 = {
106
- key: 0,
107
- class: "nut-navbar__text"
108
- };
109
- const _hoisted_5 = {
110
102
  key: 1,
111
103
  class: "nut-navbar__text"
112
104
  };
113
- const _hoisted_6 = { class: "nut-navbar__title" };
114
- const _hoisted_7 = {
105
+ const _hoisted_2 = { class: "nut-navbar__title" };
106
+ const _hoisted_3 = {
115
107
  key: 0,
116
108
  class: "nut-navbar__text"
117
109
  };
118
110
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
119
111
  const _component_Left = resolveComponent("Left");
120
- return _ctx.fixed && _ctx.placeholder ? (openBlock(), createElementBlock("view", _hoisted_1, [
112
+ return openBlock(), createElementBlock("view", {
113
+ class: "nut-navbar--placeholder",
114
+ style: normalizeStyle(_ctx.rootStyle)
115
+ }, [
121
116
  createElementVNode("view", {
122
117
  class: normalizeClass(_ctx.classes),
123
- style: normalizeStyle(_ctx.styles),
124
- ref: "navBarHtml"
118
+ style: normalizeStyle({ zIndex: _ctx.zIndex }),
119
+ ref: "navbarRef"
125
120
  }, [
126
121
  createElementVNode("view", {
127
122
  class: "nut-navbar__left",
@@ -133,10 +128,10 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
133
128
  color: "#979797"
134
129
  })
135
130
  ]) : createCommentVNode("", true),
136
- _ctx.leftText ? (openBlock(), createElementBlock("view", _hoisted_2, toDisplayString(_ctx.leftText), 1)) : createCommentVNode("", true),
131
+ _ctx.leftText ? (openBlock(), createElementBlock("view", _hoisted_1, toDisplayString(_ctx.leftText), 1)) : createCommentVNode("", true),
137
132
  renderSlot(_ctx.$slots, "left")
138
133
  ]),
139
- createElementVNode("view", _hoisted_3, [
134
+ createElementVNode("view", _hoisted_2, [
140
135
  _ctx.title ? (openBlock(), createElementBlock("view", {
141
136
  key: 0,
142
137
  class: "title",
@@ -157,53 +152,11 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
157
152
  class: "nut-navbar__right",
158
153
  onClick: _cache[4] || (_cache[4] = (...args) => _ctx.handleRight && _ctx.handleRight(...args))
159
154
  }, [
160
- _ctx.desc ? (openBlock(), createElementBlock("view", _hoisted_4, toDisplayString(_ctx.desc), 1)) : createCommentVNode("", true),
155
+ _ctx.desc ? (openBlock(), createElementBlock("view", _hoisted_3, toDisplayString(_ctx.desc), 1)) : createCommentVNode("", true),
161
156
  renderSlot(_ctx.$slots, "right")
162
157
  ])
163
158
  ], 6)
164
- ], 512)) : (openBlock(), createElementBlock("view", {
165
- key: 1,
166
- class: normalizeClass(_ctx.classes),
167
- style: normalizeStyle(_ctx.styles)
168
- }, [
169
- createElementVNode("view", {
170
- class: "nut-navbar__left",
171
- onClick: _cache[5] || (_cache[5] = (...args) => _ctx.handleLeft && _ctx.handleLeft(...args))
172
- }, [
173
- _ctx.leftShow ? renderSlot(_ctx.$slots, "left-show", { key: 0 }, () => [
174
- createVNode(_component_Left, {
175
- height: "12px",
176
- color: "#979797"
177
- })
178
- ]) : createCommentVNode("", true),
179
- _ctx.leftText ? (openBlock(), createElementBlock("view", _hoisted_5, toDisplayString(_ctx.leftText), 1)) : createCommentVNode("", true),
180
- renderSlot(_ctx.$slots, "left")
181
- ]),
182
- createElementVNode("view", _hoisted_6, [
183
- _ctx.title ? (openBlock(), createElementBlock("view", {
184
- key: 0,
185
- class: "title",
186
- onClick: _cache[6] || (_cache[6] = (...args) => _ctx.handleCenter && _ctx.handleCenter(...args))
187
- }, toDisplayString(_ctx.title), 1)) : createCommentVNode("", true),
188
- _ctx.titleIcon ? (openBlock(), createElementBlock("view", {
189
- key: 1,
190
- class: "icon",
191
- onClick: _cache[8] || (_cache[8] = (...args) => _ctx.handleCenterIcon && _ctx.handleCenterIcon(...args))
192
- }, [
193
- renderSlot(_ctx.$slots, "title-icon", {
194
- onClick: _cache[7] || (_cache[7] = (...args) => _ctx.handleCenterIcon && _ctx.handleCenterIcon(...args))
195
- })
196
- ])) : createCommentVNode("", true),
197
- renderSlot(_ctx.$slots, "content")
198
- ]),
199
- createElementVNode("view", {
200
- class: "nut-navbar__right",
201
- onClick: _cache[9] || (_cache[9] = (...args) => _ctx.handleRight && _ctx.handleRight(...args))
202
- }, [
203
- _ctx.desc ? (openBlock(), createElementBlock("view", _hoisted_7, toDisplayString(_ctx.desc), 1)) : createCommentVNode("", true),
204
- renderSlot(_ctx.$slots, "right")
205
- ])
206
- ], 6));
159
+ ], 4);
207
160
  }
208
161
  const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
209
162
  export {
@@ -34,6 +34,7 @@ const _sfc_main = create({
34
34
  const state = reactive({
35
35
  fixed: false,
36
36
  height: 0,
37
+ width: 0,
37
38
  transform: 0
38
39
  });
39
40
  const threshold = computed(() => {
@@ -49,6 +50,8 @@ const _sfc_main = create({
49
50
  return {};
50
51
  return {
51
52
  [props.position]: `${threshold.value}px`,
53
+ height: `${state.height}px`,
54
+ width: `${state.width}px`,
52
55
  transform: state.transform ? `translate3d(0, ${state.transform}px, 0)` : void 0,
53
56
  position: state.fixed ? "fixed" : void 0,
54
57
  zIndex: Number(props.zIndex)
@@ -63,6 +66,7 @@ const _sfc_main = create({
63
66
  const stickyRect = useRect(stCurrent);
64
67
  const containerRect = useRect(containerEle);
65
68
  state.height = rootRect.height;
69
+ state.width = rootRect.width;
66
70
  const getFixed = () => {
67
71
  let fixed = false;
68
72
  if (props.position === "top") {
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- import { reactive, computed, h, resolveComponent, openBlock, createElementBlock, normalizeClass, renderSlot, createBlock, resolveDynamicComponent, createCommentVNode, Fragment, renderList, createElementVNode, toDisplayString, createVNode } from "vue";
7
+ import { ref, watch, computed, h, reactive, resolveComponent, openBlock, createElementBlock, normalizeClass, renderSlot, createBlock, resolveDynamicComponent, createCommentVNode, Fragment, renderList, createElementVNode, toDisplayString, createVNode } from "vue";
8
8
  import { c as createComponent } from "./component-0fbad28e.js";
9
9
  import { f as funInterceptor } from "./Interceptor-c05a39f2.js";
10
10
  import Progress from "./Progress.js";
@@ -151,8 +151,14 @@ const _sfc_main = create({
151
151
  "file-item-click"
152
152
  ],
153
153
  setup(props, { emit }) {
154
- const fileList = reactive(props.fileList);
155
- let uploadQueue = [];
154
+ const fileList = ref(props.fileList);
155
+ const uploadQueue = ref([]);
156
+ watch(
157
+ () => props.fileList,
158
+ () => {
159
+ fileList.value = props.fileList;
160
+ }
161
+ );
156
162
  const classes = computed(() => {
157
163
  const prefixCls = componentName;
158
164
  return {
@@ -213,7 +219,7 @@ const _sfc_main = create({
213
219
  option,
214
220
  fileItem
215
221
  });
216
- emit("update:fileList", fileList);
222
+ emit("update:fileList", fileList.value);
217
223
  };
218
224
  uploadOption.onFailure = (responseText, option) => {
219
225
  fileItem.status = "error";
@@ -228,7 +234,7 @@ const _sfc_main = create({
228
234
  if (props.autoUpload) {
229
235
  task.upload();
230
236
  } else {
231
- uploadQueue.push(
237
+ uploadQueue.value.push(
232
238
  new Promise((resolve) => {
233
239
  resolve(task);
234
240
  })
@@ -237,14 +243,15 @@ const _sfc_main = create({
237
243
  };
238
244
  const clearUploadQueue = (index2 = -1) => {
239
245
  if (index2 > -1) {
240
- uploadQueue.splice(index2, 1);
246
+ uploadQueue.value.splice(index2, 1);
241
247
  } else {
242
- uploadQueue = [];
243
- fileList.splice(0, fileList.length);
248
+ uploadQueue.value = [];
249
+ fileList.value = [];
250
+ emit("update:fileList", fileList.value);
244
251
  }
245
252
  };
246
253
  const submit = () => {
247
- Promise.all(uploadQueue).then((res) => {
254
+ Promise.all(uploadQueue.value).then((res) => {
248
255
  res.forEach((i) => i.upload());
249
256
  });
250
257
  };
@@ -266,11 +273,11 @@ const _sfc_main = create({
266
273
  const reader = new FileReader();
267
274
  reader.onload = (event) => {
268
275
  fileItem.url = event.target.result;
269
- fileList.push(fileItem);
276
+ fileList.value.push(fileItem);
270
277
  };
271
278
  reader.readAsDataURL(file);
272
279
  } else {
273
- fileList.push(fileItem);
280
+ fileList.value.push(fileItem);
274
281
  }
275
282
  });
276
283
  };
@@ -289,24 +296,24 @@ const _sfc_main = create({
289
296
  if (oversizes.length) {
290
297
  emit("oversize", oversizes);
291
298
  }
292
- let currentFileLength = files.length + fileList.length;
299
+ let currentFileLength = files.length + fileList.value.length;
293
300
  if (currentFileLength > maximum) {
294
301
  files.splice(files.length - (currentFileLength - maximum));
295
302
  }
296
303
  return files;
297
304
  };
298
305
  const deleted = (file, index2) => {
299
- fileList.splice(index2, 1);
306
+ fileList.value.splice(index2, 1);
300
307
  emit("delete", {
301
308
  file,
302
- fileList,
309
+ fileList: fileList.value,
303
310
  index: index2
304
311
  });
305
312
  };
306
313
  const onDelete = (file, index2) => {
307
314
  clearUploadQueue(index2);
308
315
  funInterceptor(props.beforeDelete, {
309
- args: [file, fileList],
316
+ args: [file, fileList.value],
310
317
  done: () => deleted(file, index2)
311
318
  });
312
319
  };
@@ -322,7 +329,7 @@ const _sfc_main = create({
322
329
  changeReadFile(files);
323
330
  }
324
331
  emit("change", {
325
- fileList,
332
+ fileList: fileList.value,
326
333
  event
327
334
  });
328
335
  if (props.clearInput) {
@@ -33,6 +33,7 @@
33
33
  width: 100%;
34
34
  }
35
35
  &--placeholder {
36
+ display: block;
36
37
  width: 100%;
37
38
  }
38
39
  &--safe-area-inset-top {
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "framework": "vue",
4
4
  "name": "NutUI",
5
- "version": "4.1.0-beta.6",
5
+ "version": "4.1.0",
6
6
  "contributions": {
7
7
  "html": {
8
8
  "tags": [
@@ -917,7 +917,7 @@
917
917
  {
918
918
  "name": "img-url",
919
919
  "default": "-",
920
- "description": "左侧图片 `Url`",
920
+ "description": "左侧图片 `URL`",
921
921
  "value": {
922
922
  "type": "string",
923
923
  "kind": "expression"
@@ -2730,13 +2730,139 @@
2730
2730
  "events": [],
2731
2731
  "attributes": [
2732
2732
  {
2733
- "name": "src",
2734
- "default": "undefined",
2735
- "description": "预览图片链接",
2733
+ "name": "show",
2734
+ "default": "`false`",
2735
+ "description": "是否展示预览图片",
2736
+ "value": {
2737
+ "type": "boolean",
2738
+ "kind": "expression"
2739
+ }
2740
+ },
2741
+ {
2742
+ "name": "videos",
2743
+ "default": "`[]`",
2744
+ "description": "预览的视频数组(视频自动放到图片之前)",
2745
+ "value": {
2746
+ "type": "videoarray[]",
2747
+ "kind": "expression"
2748
+ }
2749
+ },
2750
+ {
2751
+ "name": "images",
2752
+ "default": "`[]`",
2753
+ "description": "预览图片数组",
2754
+ "value": {
2755
+ "type": "imagearray[]",
2756
+ "kind": "expression"
2757
+ }
2758
+ },
2759
+ {
2760
+ "name": "autoplay",
2761
+ "default": "`3000`",
2762
+ "description": "自动轮播时长,0 表示不会自动轮播",
2763
+ "value": {
2764
+ "type": "number | string",
2765
+ "kind": "expression"
2766
+ }
2767
+ },
2768
+ {
2769
+ "name": "init-no",
2770
+ "default": "`0`",
2771
+ "description": "初始页码",
2772
+ "value": {
2773
+ "type": "number",
2774
+ "kind": "expression"
2775
+ }
2776
+ },
2777
+ {
2778
+ "name": "pagination-visible",
2779
+ "default": "`false`",
2780
+ "description": "分页指示器是否展示",
2781
+ "value": {
2782
+ "type": "boolean",
2783
+ "kind": "expression"
2784
+ }
2785
+ },
2786
+ {
2787
+ "name": "pagination-color",
2788
+ "default": "`#fff`",
2789
+ "description": "分页指示器选中的颜色",
2736
2790
  "value": {
2737
2791
  "type": "string",
2738
2792
  "kind": "expression"
2739
2793
  }
2794
+ },
2795
+ {
2796
+ "name": "content-close",
2797
+ "default": "`true`",
2798
+ "description": "点击图片可以退出预览",
2799
+ "value": {
2800
+ "type": "boolean",
2801
+ "kind": "expression"
2802
+ }
2803
+ },
2804
+ {
2805
+ "name": "show-index",
2806
+ "default": "`true`",
2807
+ "description": "是否显示页码",
2808
+ "value": {
2809
+ "type": "boolean",
2810
+ "kind": "expression"
2811
+ }
2812
+ },
2813
+ {
2814
+ "name": "closeable",
2815
+ "default": "`false`",
2816
+ "description": "是否显示关闭图标",
2817
+ "value": {
2818
+ "type": "boolean",
2819
+ "kind": "expression"
2820
+ }
2821
+ },
2822
+ {
2823
+ "name": "close-icon-position",
2824
+ "default": "`top-right`",
2825
+ "description": "关闭图标位置,可选值:`top-left`",
2826
+ "value": {
2827
+ "type": "string",
2828
+ "kind": "expression"
2829
+ }
2830
+ },
2831
+ {
2832
+ "name": "before-close",
2833
+ "default": "-",
2834
+ "description": "关闭前的回调函数,返回 `false` 可阻止关闭,支持返回 `Promise`",
2835
+ "value": {
2836
+ "type": "(active: number) => boolean | promise<`boolean`>",
2837
+ "kind": "expression"
2838
+ }
2839
+ },
2840
+ {
2841
+ "name": "max-zoom",
2842
+ "default": "`3`",
2843
+ "description": "手势缩放时,最大缩放比例",
2844
+ "value": {
2845
+ "type": "number",
2846
+ "kind": "expression"
2847
+ }
2848
+ },
2849
+ {
2850
+ "name": "min-zoom",
2851
+ "default": "`1/3`",
2852
+ "description": "手势缩放时,最小缩放比例",
2853
+ "value": {
2854
+ "type": "number",
2855
+ "kind": "expression"
2856
+ }
2857
+ },
2858
+ {
2859
+ "name": "is-loop",
2860
+ "default": "`true`",
2861
+ "description": "是否循环播放",
2862
+ "value": {
2863
+ "type": "boolean",
2864
+ "kind": "expression"
2865
+ }
2740
2866
  }
2741
2867
  ]
2742
2868
  },
@@ -5947,7 +6073,7 @@
5947
6073
  },
5948
6074
  {
5949
6075
  "name": "placeholder",
5950
- "default": "`'请输入内容'`",
6076
+ "default": "`'请输入'`",
5951
6077
  "description": "设置占位提示文字",
5952
6078
  "value": {
5953
6079
  "type": "string",