@nutui/nutui-react-taro 3.0.15 → 3.0.17-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +22 -15
  2. package/dist/cjs/packages/calendaritem/calendaritem.d.ts +1 -1
  3. package/dist/cjs/packages/calendaritem/calendaritem.js +4 -4
  4. package/dist/cjs/packages/imagepreview/imagepreview.js +25 -4
  5. package/dist/cjs/packages/noticebar/noticebar.js +65 -41
  6. package/dist/cjs/packages/pulltorefresh/pulltorefresh.js +1 -1
  7. package/dist/cjs/packages/swiper/index.d.ts +1 -1
  8. package/dist/cjs/packages/swiper/swiper.js +6 -0
  9. package/dist/cjs/types/spec/calendar/base.d.ts +3 -1
  10. package/dist/cjs/types/spec/imagepreview/h5.d.ts +4 -1
  11. package/dist/cjs/types/spec/imagepreview/taro.d.ts +4 -1
  12. package/dist/cjs/types/spec/pulltorefresh/taro.d.ts +1 -0
  13. package/dist/cjs/utils/date.d.ts +2 -2
  14. package/dist/cjs/utils/date.js +2 -2
  15. package/dist/es/packages/calendaritem/calendaritem.d.ts +1 -1
  16. package/dist/es/packages/calendaritem/calendaritem.js +4 -4
  17. package/dist/es/packages/imagepreview/imagepreview.js +25 -4
  18. package/dist/es/packages/noticebar/noticebar.js +66 -42
  19. package/dist/es/packages/pulltorefresh/pulltorefresh.js +1 -1
  20. package/dist/es/packages/swiper/index.d.ts +1 -1
  21. package/dist/es/packages/swiper/swiper.js +7 -1
  22. package/dist/es/types/spec/calendar/base.d.ts +3 -1
  23. package/dist/es/types/spec/imagepreview/h5.d.ts +4 -1
  24. package/dist/es/types/spec/imagepreview/taro.d.ts +4 -1
  25. package/dist/es/types/spec/pulltorefresh/taro.d.ts +1 -0
  26. package/dist/es/utils/date.d.ts +2 -2
  27. package/dist/es/utils/date.js +2 -2
  28. package/dist/nutui.react.umd.js +101 -52
  29. package/dist/style-jmapp.css +1 -1
  30. package/dist/style-jmapp.scss +35 -35
  31. package/dist/style-jrkf.css +1 -1
  32. package/dist/style-jrkf.scss +31 -31
  33. package/dist/style.css +1 -1
  34. package/dist/style.scss +23 -23
  35. package/package.json +1 -1
@@ -3,8 +3,9 @@ import { _ as _define_property } from "@swc/helpers/_/_define_property";
3
3
  import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
4
4
  import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
5
5
  import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
6
+ import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
6
7
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
7
- import React, { useEffect, useMemo, useRef, useState } from "react";
8
+ import React, { useEffect, useMemo, useRef, useState, useCallback } from "react";
8
9
  import { View } from "@tarojs/components";
9
10
  import { Close, Notice } from "@nutui/icons-react-taro";
10
11
  import classNames from "classnames";
@@ -47,9 +48,10 @@ export var NoticeBar = function(props) {
47
48
  var _useState8 = _sliced_to_array(useState(null), 2), isCanScroll = _useState8[0], SetIsCanScroll = _useState8[1];
48
49
  var isVertical = direction === 'vertical';
49
50
  var _useState9 = _sliced_to_array(useState(null), 2), rect = _useState9[0], setRect = _useState9[1];
50
- var active = 0;
51
+ var activeRef = useRef(0);
51
52
  var _useState10 = _sliced_to_array(useState(false), 2), ready = _useState10[0], setReady = _useState10[1];
52
53
  var container = useRef(null);
54
+ var _useState11 = _sliced_to_array(useState(false), 2), isContainerReady = _useState11[0], setIsContainerReady = _useState11[1];
53
55
  var innerRef = useRef(null);
54
56
  var swiperRef = useRef({
55
57
  moving: false,
@@ -59,8 +61,8 @@ export var NoticeBar = function(props) {
59
61
  offset: 0,
60
62
  size: 0
61
63
  });
62
- var _useState11 = _sliced_to_array(useState([]), 2), childOffset = _useState11[0], setChildOffset = _useState11[1];
63
- var _useState12 = _sliced_to_array(useState(0), 2), offset = _useState12[0], setOffset = _useState12[1];
64
+ var _useState12 = _sliced_to_array(useState([]), 2), childOffset = _useState12[0], setChildOffset = _useState12[1];
65
+ var _useState13 = _sliced_to_array(useState(0), 2), offset = _useState13[0], setOffset = _useState13[1];
64
66
  var _useMemo = useMemo(function() {
65
67
  var childCount = 0;
66
68
  var childs = React.Children.map(children, function(child) {
@@ -100,7 +102,9 @@ export var NoticeBar = function(props) {
100
102
  // 销毁事件
101
103
  clearInterval(timer);
102
104
  };
103
- }, []);
105
+ }, [
106
+ childs
107
+ ]);
104
108
  useEffect(function() {
105
109
  initScrollWrap(content);
106
110
  }, [
@@ -219,7 +223,7 @@ export var NoticeBar = function(props) {
219
223
  };
220
224
  // 垂直自定义滚动方式
221
225
  var init = function() {
222
- var active = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : +0;
226
+ var activeIndex = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
223
227
  if (!(container === null || container === void 0 ? void 0 : container.current)) return;
224
228
  setTimeout(/*#__PURE__*/ _async_to_generator(function() {
225
229
  var rects, _active, _height, targetOffset;
@@ -232,17 +236,18 @@ export var NoticeBar = function(props) {
232
236
  ];
233
237
  case 1:
234
238
  rects = _state.sent();
235
- _active = Math.max(Math.min(childCount - 1, active), 0);
239
+ _active = Math.max(Math.min(childCount - 1, activeIndex), 0);
236
240
  _height = rects === null || rects === void 0 ? void 0 : rects.height;
237
241
  trackSize = childCount * Number(_height);
238
242
  targetOffset = getOffset(_active);
239
- swiperRef.current.moving = true;
240
- if (ready) {
241
- swiperRef.current.moving = false;
242
- }
243
- active = _active;
243
+ activeRef.current = _active;
244
244
  setRect(rects);
245
245
  setOffset(targetOffset);
246
+ setChildOffset(new Array(childCount).fill(0));
247
+ // 关闭动画并立即设置样式
248
+ swiperRef.current.moving = true;
249
+ setStyle(targetOffset, rects);
250
+ swiperRef.current.moving = false;
246
251
  setReady(true);
247
252
  return [
248
253
  2
@@ -253,7 +258,6 @@ export var NoticeBar = function(props) {
253
258
  };
254
259
  useEffect(function() {
255
260
  if (ready) {
256
- stopAutoPlay();
257
261
  autoplay();
258
262
  }
259
263
  return function() {
@@ -263,18 +267,19 @@ export var NoticeBar = function(props) {
263
267
  ready
264
268
  ]);
265
269
  useEffect(function() {
266
- if (isVertical && children) {
267
- init();
270
+ if (isVertical && children && isContainerReady) {
268
271
  stopAutoPlay();
269
- autoplay();
272
+ setReady(false);
273
+ init();
270
274
  }
271
275
  }, [
272
276
  children,
273
- container === null || container === void 0 ? void 0 : container.current
277
+ isContainerReady
274
278
  ]);
275
279
  // 清除定时器
276
280
  var stopAutoPlay = function() {
277
281
  clearTimeout(swiperRef.current.autoplayTimer);
282
+ swiperRef.current.moving = false;
278
283
  swiperRef.current.autoplayTimer = null;
279
284
  };
280
285
  // 定时轮播
@@ -293,23 +298,26 @@ export var NoticeBar = function(props) {
293
298
  var targetActive = getActive(pace);
294
299
  // 父级容器偏移量
295
300
  var targetOffset = getOffset(targetActive, offset);
296
- // 如果循环,调整开头结尾图片位置
297
- if (Array.isArray(children) && children[0] && targetOffset !== minOffset) {
298
- var rightBound = targetOffset < minOffset;
299
- childOffset[0] = rightBound ? trackSize : 0;
300
- }
301
- if (Array.isArray(children) && children[childCount - 1] && targetOffset !== 0) {
302
- var leftBound = targetOffset > 0;
303
- childOffset[childCount - 1] = leftBound ? -trackSize : 0;
304
- }
305
- setChildOffset(childOffset);
306
- active = targetActive;
301
+ // 循环滚动,调整开头结尾图片位置
302
+ setChildOffset(function(prevChildOffset) {
303
+ var newChildOffset = _to_consumable_array(prevChildOffset);
304
+ if (Array.isArray(children) && children[0] && targetOffset !== minOffset) {
305
+ var rightBound = targetOffset < minOffset;
306
+ newChildOffset[0] = rightBound ? trackSize : 0;
307
+ }
308
+ if (Array.isArray(children) && children[childCount - 1] && targetOffset !== 0) {
309
+ var leftBound = targetOffset > 0;
310
+ newChildOffset[childCount - 1] = leftBound ? -trackSize : 0;
311
+ }
312
+ return newChildOffset;
313
+ });
314
+ activeRef.current = targetActive;
307
315
  setOffset(targetOffset);
308
- getStyle(targetOffset);
316
+ setStyle(targetOffset);
309
317
  };
310
318
  // 下一页
311
319
  var next = function() {
312
- resettPosition();
320
+ resetPosition();
313
321
  requestFrame(function() {
314
322
  requestFrame(function() {
315
323
  swiperRef.current.moving = false;
@@ -322,16 +330,16 @@ export var NoticeBar = function(props) {
322
330
  var handleItemClick = function(event, value) {
323
331
  onItemClick && onItemClick(event, value);
324
332
  };
325
- var getStyle = function() {
326
- var moveOffset = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : offset;
333
+ var setStyle = function() {
334
+ var moveOffset = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : offset, currentRect = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : rect;
327
335
  var target = innerRef.current;
328
336
  if (!target) {
329
337
  return;
330
338
  }
331
339
  var _offset = 0;
332
- // 容器高度-元素高度
333
- var val = ((rect === null || rect === void 0 ? void 0 : rect.height) || 0) - height;
334
- _offset = moveOffset + Number(active === childCount - 1 && val / 2);
340
+ var containerHeight = (currentRect === null || currentRect === void 0 ? void 0 : currentRect.height) || height;
341
+ var val = containerHeight - Number(height);
342
+ _offset = moveOffset + Number(activeRef.current === childCount - 1 && val / 2);
335
343
  target.style.transitionDuration = "".concat(swiperRef.current.moving ? 0 : duration, "ms");
336
344
  target.style.height = "".concat(Number(height) * (childCount + 1), "px");
337
345
  target.style.transform = "translate3D(0,".concat(_offset, "px,0)");
@@ -351,11 +359,12 @@ export var NoticeBar = function(props) {
351
359
  };
352
360
  // 确定当前active 元素
353
361
  var getActive = function(pace) {
362
+ var currentActive = activeRef.current;
354
363
  if (pace) {
355
- var _active = active + pace;
364
+ var _active = currentActive + pace;
356
365
  return range(_active, -1, childCount);
357
366
  }
358
- return active;
367
+ return currentActive;
359
368
  };
360
369
  // 计算位移
361
370
  var getOffset = function(active) {
@@ -373,14 +382,15 @@ export var NoticeBar = function(props) {
373
382
  return Math.min(Math.max(num, min), max);
374
383
  };
375
384
  // 重置首尾位置信息
376
- var resettPosition = function() {
385
+ var resetPosition = function() {
386
+ var currentActive = activeRef.current;
377
387
  swiperRef.current.moving = true;
378
- if (active <= -1) {
388
+ if (currentActive <= -1) {
379
389
  move({
380
390
  pace: childCount
381
391
  });
382
392
  }
383
- if (active >= childCount) {
393
+ if (currentActive >= childCount) {
384
394
  move({
385
395
  pace: -childCount
386
396
  });
@@ -394,6 +404,20 @@ export var NoticeBar = function(props) {
394
404
  stopAutoPlay();
395
405
  };
396
406
  }, []);
407
+ var hasVerticalContent = useMemo(function() {
408
+ if (!isVertical) return false;
409
+ if (children) return (childs === null || childs === void 0 ? void 0 : childs.length) > 0;
410
+ return (list === null || list === void 0 ? void 0 : list.length) > 0;
411
+ }, [
412
+ isVertical,
413
+ childs,
414
+ list,
415
+ children
416
+ ]);
417
+ var containerRefCallback = useCallback(function(ref) {
418
+ container.current = ref;
419
+ setIsContainerReady(true);
420
+ }, []);
397
421
  return (
398
422
  /*#__PURE__*/ React.createElement(View, {
399
423
  className: cls,
@@ -419,10 +443,10 @@ export var NoticeBar = function(props) {
419
443
  onClick: onClickIcon
420
444
  }, rightIcon || /*#__PURE__*/ React.createElement(Close, {
421
445
  size: 12
422
- })) : null) : null, showNoticeBar && scrollList.current.length > 0 && isVertical ? /*#__PURE__*/ React.createElement(View, {
446
+ })) : null) : null, showNoticeBar && hasVerticalContent && isVertical ? /*#__PURE__*/ React.createElement(View, {
423
447
  className: "nut-noticebar-vertical",
424
448
  style: barStyle,
425
- ref: container,
449
+ ref: containerRefCallback,
426
450
  onClick: handleClick
427
451
  }, leftIcon ? /*#__PURE__*/ React.createElement(View, {
428
452
  className: "nut-noticebar-box-left-icon"
@@ -166,7 +166,7 @@ export var PullToRefresh = function(p) {
166
166
  return /*#__PURE__*/ React.createElement(View, {
167
167
  className: classes,
168
168
  style: props.style,
169
- catchMove: true,
169
+ catchMove: props.catchMove,
170
170
  onTouchStart: handleTouchStart,
171
171
  onTouchMove: handleTouchMove,
172
172
  onTouchEnd: handleTouchEnd
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import SwiperItem from "../swiperitem/index";
3
3
  import { TaroSwiperProps } from "../../types";
4
4
  export type { TaroSwiperProps as SwiperProps } from "../../types";
5
- type CompoundedComponent = React.ForwardRefExoticComponent<Partial<TaroSwiperProps> & Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> & React.RefAttributes<any>> & {
5
+ type CompoundedComponent = React.ForwardRefExoticComponent<Partial<TaroSwiperProps> & React.RefAttributes<any>> & {
6
6
  Item: typeof SwiperItem;
7
7
  };
8
8
  declare const InnerSwiper: CompoundedComponent;
@@ -3,7 +3,7 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
3
  import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
4
  import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
5
5
  import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
6
- import React, { Children, useImperativeHandle, useMemo, useState } from "react";
6
+ import React, { Children, useImperativeHandle, useMemo, useState, useEffect } from "react";
7
7
  import { Swiper as TaroSwiper, SwiperItem as TSwiperItem, View } from "@tarojs/components";
8
8
  import classNames from "classnames";
9
9
  import Indicator from "../indicator/index";
@@ -48,6 +48,12 @@ export var Swiper = /*#__PURE__*/ React.forwardRef(function(props, ref) {
48
48
  }, [
49
49
  children
50
50
  ]);
51
+ useEffect(function() {
52
+ setInnerValue(current || defaultValue);
53
+ }, [
54
+ defaultValue,
55
+ current
56
+ ]);
51
57
  var renderIndicator = function() {
52
58
  if (/*#__PURE__*/ React.isValidElement(indicator)) return indicator;
53
59
  if (indicator || indicatorDots) {
@@ -4,6 +4,8 @@ import { BaseProps } from '../../base/props';
4
4
  export interface CalendarDay {
5
5
  day: SimpleValue;
6
6
  type: string;
7
+ month?: SimpleValue;
8
+ year?: SimpleValue;
7
9
  }
8
10
  export interface CalendarMonthInfo {
9
11
  curData: string[] | string;
@@ -121,7 +123,7 @@ export interface BaseCalendar {
121
123
  /**
122
124
  * 点击/选择后触发
123
125
  */
124
- onDayClick: (data: string) => void
126
+ onDayClick: (data: string[]) => void
125
127
  /**
126
128
  * 年月子标题到达顶部时触发
127
129
  */
@@ -1,3 +1,6 @@
1
1
  import { BaseImagePreview } from './base';
2
- export interface WebImagePreviewProps extends BaseImagePreview {
2
+ import { WebSwiperProps } from "../../../types";
3
+ type props = BaseImagePreview & Omit<WebSwiperProps, 'autoPlay' | 'indicator'>;
4
+ export interface WebImagePreviewProps extends Omit<props, 'autoplay'> {
3
5
  }
6
+ export {};
@@ -1,5 +1,8 @@
1
1
  import { BaseImagePreview } from './base';
2
- export interface TaroImagePreviewProps extends Omit<BaseImagePreview, 'autoPlay'> {
2
+ import { TaroSwiperProps } from "../../../types";
3
+ type props = Omit<BaseImagePreview, 'autoPlay'> & Omit<TaroSwiperProps, 'autoPlay' | 'autoplay' | 'indicator'>;
4
+ export interface TaroImagePreviewProps extends props {
3
5
  autoPlay: boolean;
4
6
  showMenuByLongpress: boolean;
5
7
  }
8
+ export {};
@@ -1,4 +1,5 @@
1
1
  import { BasePullToRefresh } from './base';
2
2
  export interface TaroPullToRefreshProps extends BasePullToRefresh {
3
3
  scrollTop: number;
4
+ catchMove: boolean;
4
5
  }
@@ -60,6 +60,6 @@ export declare const getDaysStatus: (type: string, year: number, month: number)
60
60
  export declare const getPreMonthDates: (type: string, year: number, month: number, firstDayOfWeek: number) => {
61
61
  day: number;
62
62
  type: string;
63
- preYear: number;
64
- preMonth: number;
63
+ year: number;
64
+ month: number;
65
65
  }[];
@@ -229,8 +229,8 @@ export var getPreMonthDates = function(type, year, month, firstDayOfWeek) {
229
229
  return {
230
230
  day: k + 1,
231
231
  type: type,
232
- preYear: preYear,
233
- preMonth: preMonth
232
+ year: preYear,
233
+ month: preMonth
234
234
  };
235
235
  });
236
236
  return months.slice(preDates - days);