@nutui/nutui-react-taro 2.0.0-alpha.3 → 2.0.0-alpha.5

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 (122) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/esm/Address.js +3 -5
  3. package/dist/esm/Audio.js +3 -4
  4. package/dist/esm/Avatar.js +6 -5
  5. package/dist/esm/AvatarGroup.js +3 -7
  6. package/dist/esm/Calendar.js +3 -4
  7. package/dist/esm/CalendarItem.js +2 -3
  8. package/dist/esm/CellGroup.js +1 -1
  9. package/dist/esm/Checkbox.js +3 -3
  10. package/dist/esm/CheckboxGroup.js +3 -3
  11. package/dist/esm/CircleProgress.js +2 -3
  12. package/dist/esm/ConfigProvider.js +2 -3
  13. package/dist/esm/CountDown.js +2 -3
  14. package/dist/esm/DatePicker.js +3 -4
  15. package/dist/esm/Dialog.js +2 -3
  16. package/dist/esm/Elevator.js +1 -1
  17. package/dist/esm/Ellipsis.js +3 -4
  18. package/dist/esm/Empty.js +3 -5
  19. package/dist/esm/FixedNav.js +2 -3
  20. package/dist/esm/Form.js +2 -2
  21. package/dist/esm/Grid.js +3 -4
  22. package/dist/esm/GridItem.js +2 -3
  23. package/dist/esm/Image.js +2 -3
  24. package/dist/esm/Infiniteloading.js +2 -3
  25. package/dist/esm/Input.js +5 -3
  26. package/dist/esm/NumberKeyboard.js +2 -3
  27. package/dist/esm/Pagination.js +2 -3
  28. package/dist/esm/Picker.js +2 -3
  29. package/dist/esm/PullToRefresh.js +2 -3
  30. package/dist/esm/Range.js +2 -3
  31. package/dist/esm/SearchBar.js +2 -3
  32. package/dist/esm/ShortPassword.js +2 -3
  33. package/dist/esm/Signature.js +2 -3
  34. package/dist/esm/Skeleton.js +8 -5
  35. package/dist/esm/Swipe.js +1 -1
  36. package/dist/esm/Tabbar/style/index.js +1 -1
  37. package/dist/esm/Tabbar.js +6 -3
  38. package/dist/esm/TabbarItem.js +3 -4
  39. package/dist/esm/Table.js +2 -3
  40. package/dist/esm/TextArea.js +2 -3
  41. package/dist/esm/TimeDetail.js +2 -3
  42. package/dist/esm/TimePannel.js +2 -3
  43. package/dist/esm/TimeSelect.js +4 -5
  44. package/dist/esm/Uploader.js +2 -3
  45. package/dist/esm/VirtualList.js +2 -3
  46. package/dist/esm/WaterMark.js +2 -3
  47. package/dist/esm/{address.taro-67e32c33.js → address.taro-cab0ea22.js} +18 -4
  48. package/dist/esm/{audio.taro-51eafc9d.js → audio.taro-ff280f5e.js} +2 -2
  49. package/dist/esm/{avatar.taro-a840f345.js → avatar.taro-6e8f1f5c.js} +31 -29
  50. package/dist/esm/{avatargroup-0eadb514.js → avatargroup-f4375806.js} +9 -12
  51. package/dist/esm/{calendar.taro-b3ebdc35.js → calendar.taro-2fc9b899.js} +2 -2
  52. package/dist/esm/{calendaritem.taro-ab1ec154.js → calendaritem.taro-2d4a8c34.js} +1 -1
  53. package/dist/esm/{cellgroup.taro-660faffc.js → cellgroup.taro-e05ea802.js} +3 -2
  54. package/dist/esm/checkbox.taro-9d02f86c.js +175 -0
  55. package/dist/esm/{circleprogress.taro-d8973ae9.js → circleprogress.taro-d4943109.js} +21 -27
  56. package/dist/esm/{zh-CN-b4f493ba.js → configprovider.taro-ce34d482.js} +44 -1
  57. package/dist/esm/{countdown.taro-c14b5c1f.js → countdown.taro-3118ba23.js} +1 -1
  58. package/dist/esm/{datepicker.taro-7d522ff8.js → datepicker.taro-2e3e955b.js} +2 -2
  59. package/dist/esm/{dialog.taro-f9ca73a2.js → dialog.taro-eab19eab.js} +1 -1
  60. package/dist/esm/{elevator.taro-360a831f.js → elevator.taro-1a4e3356.js} +16 -8
  61. package/dist/esm/{ellipsis.taro-79044d54.js → ellipsis.taro-e1ac99a1.js} +7 -4
  62. package/dist/esm/{empty.taro-f8585835.js → empty.taro-26363c66.js} +12 -18
  63. package/dist/esm/{fixednav.taro-cca9a6df.js → fixednav.taro-ddb21e87.js} +1 -1
  64. package/dist/esm/{form.taro-7413d868.js → form.taro-423b0f0a.js} +1 -1
  65. package/dist/esm/{grid.taro-10eb7716.js → grid.taro-883a9c35.js} +1 -1
  66. package/dist/esm/{griditem.taro-fb15eeec.js → griditem.taro-16c7055b.js} +1 -1
  67. package/dist/esm/{image.taro-b897a058.js → image.taro-3025e659.js} +1 -1
  68. package/dist/esm/{infiniteloading.taro-cce53c60.js → infiniteloading.taro-721bca1f.js} +1 -1
  69. package/dist/esm/input.taro-06c1e4d5.js +167 -0
  70. package/dist/esm/{numberkeyboard.taro-10ab54d6.js → numberkeyboard.taro-d9b1721b.js} +1 -1
  71. package/dist/esm/nutui-react.es.js +45 -47
  72. package/dist/esm/{pagination.taro-df441058.js → pagination.taro-94f9be5e.js} +1 -1
  73. package/dist/esm/{picker.taro-9f1bb6a4.js → picker.taro-e16b4312.js} +1 -1
  74. package/dist/esm/{pulltorefresh.taro-37dadbc5.js → pulltorefresh.taro-016d0079.js} +1 -1
  75. package/dist/esm/{range.taro-432d20d7.js → range.taro-8953e8c3.js} +1 -1
  76. package/dist/esm/{searchbar.taro-4aa300df.js → searchbar.taro-4467040f.js} +1 -1
  77. package/dist/esm/{shortpassword.taro-99645f99.js → shortpassword.taro-433b86a4.js} +1 -1
  78. package/dist/esm/{signature.taro-e5ede25a.js → signature.taro-a4d9b5c9.js} +1 -1
  79. package/dist/esm/{skeleton.taro-fabd423a.js → skeleton.taro-8ec11af9.js} +2 -2
  80. package/dist/esm/{swipe.taro-b18a73ff.js → swipe.taro-0b8cc872.js} +3 -5
  81. package/dist/esm/tabbar.taro-48413fb8.js +51 -0
  82. package/dist/esm/tabbaritem.taro-5afa3562.js +37 -0
  83. package/dist/esm/{table.taro-eca757f3.js → table.taro-327b4248.js} +1 -1
  84. package/dist/esm/{textarea.taro-e256e741.js → textarea.taro-add72cf3.js} +1 -1
  85. package/dist/esm/{timedetail.taro-cae362b9.js → timedetail.taro-82a2900b.js} +1 -1
  86. package/dist/esm/{timepannel.taro-d6f4cf80.js → timepannel.taro-0573bb65.js} +1 -1
  87. package/dist/esm/{timeselect.taro-804199f9.js → timeselect.taro-29124a34.js} +3 -3
  88. package/dist/esm/{uploader.taro-716f9a50.js → uploader.taro-c70d00de.js} +1 -1
  89. package/dist/esm/{virtuallist.taro-0bd611cb.js → virtuallist.taro-ba8e1f21.js} +1 -1
  90. package/dist/esm/{watermark.taro-8966896a.js → watermark.taro-168cdac5.js} +1 -1
  91. package/dist/locales/base.js +1 -1
  92. package/dist/locales/en-US.js +1 -1
  93. package/dist/locales/id-ID.js +1 -1
  94. package/dist/locales/zh-CN.js +1 -1
  95. package/dist/locales/zh-TW.js +1 -1
  96. package/dist/locales/zh-UG.js +1 -1
  97. package/dist/nutui.react.mjs +975 -1094
  98. package/dist/nutui.react.umd.js +973 -1092
  99. package/dist/packages/badge/badge.scss +0 -1
  100. package/dist/packages/cellgroup/cellgroup.scss +20 -16
  101. package/dist/packages/checkbox/checkbox.scss +8 -11
  102. package/dist/packages/circleprogress/circleprogress.scss +0 -9
  103. package/dist/packages/empty/empty.scss +0 -9
  104. package/dist/packages/input/input.scss +13 -180
  105. package/dist/packages/tabbar/tabbar.scss +16 -22
  106. package/dist/packages/tabbaritem/tabbaritem.scss +9 -70
  107. package/dist/style.css +1 -1
  108. package/dist/style.mjs +1 -1
  109. package/dist/styles/themes/default.scss +0 -1
  110. package/dist/styles/variables-jmapp.scss +12 -16
  111. package/dist/styles/variables.scss +12 -16
  112. package/dist/types/index.d.ts +86 -129
  113. package/package.json +1 -1
  114. package/dist/esm/Icon.js +0 -64
  115. package/dist/esm/checkbox.taro-ae460d3a.js +0 -168
  116. package/dist/esm/configprovider-9960f0fb.js +0 -19
  117. package/dist/esm/configprovider.taro-43a3c646.js +0 -45
  118. package/dist/esm/input.taro-f4e067f7.js +0 -237
  119. package/dist/esm/tabbar.taro-eefd0f8e.js +0 -59
  120. package/dist/esm/tabbaritem.taro-7a97e645.js +0 -55
  121. package/dist/packages/icon/icon.scss +0 -0
  122. /package/dist/esm/{AvatarContext-c96afdcc.js → context-c96afdcc.js} +0 -0
@@ -1,10 +1,9 @@
1
- import { T as TimePannel } from './timepannel.taro-d6f4cf80.js';
1
+ import { T as TimePannel } from './timepannel.taro-0573bb65.js';
2
2
  import 'react';
3
3
  import './bem-350c1702.js';
4
4
  import '@bem-react/classname';
5
- import './configprovider.taro-43a3c646.js';
5
+ import './configprovider.taro-ce34d482.js';
6
6
  import 'lodash.kebabcase';
7
- import './zh-CN-b4f493ba.js';
8
7
 
9
8
 
10
9
 
@@ -1,4 +1,4 @@
1
- import { T as TimeSelect } from './timeselect.taro-804199f9.js';
1
+ import { T as TimeSelect } from './timeselect.taro-29124a34.js';
2
2
  import 'react';
3
3
  import './popup.taro-89cc342a.js';
4
4
  import 'react-dom';
@@ -8,13 +8,12 @@ import '@nutui/icons-react-taro';
8
8
  import '@tarojs/components';
9
9
  import './overlay.taro-067b7202.js';
10
10
  import './typings-d8491423.js';
11
- import './timepannel.taro-d6f4cf80.js';
11
+ import './timepannel.taro-0573bb65.js';
12
12
  import './bem-350c1702.js';
13
13
  import '@bem-react/classname';
14
- import './configprovider.taro-43a3c646.js';
14
+ import './configprovider.taro-ce34d482.js';
15
15
  import 'lodash.kebabcase';
16
- import './zh-CN-b4f493ba.js';
17
- import './timedetail.taro-cae362b9.js';
16
+ import './timedetail.taro-82a2900b.js';
18
17
 
19
18
 
20
19
 
@@ -1,4 +1,4 @@
1
- import { U as Uploader } from './uploader.taro-716f9a50.js';
1
+ import { U as Uploader } from './uploader.taro-c70d00de.js';
2
2
  import 'react';
3
3
  import 'classnames';
4
4
  import '@tarojs/taro';
@@ -7,9 +7,8 @@ import '@tarojs/components';
7
7
  import './button.taro-b50bc217.js';
8
8
  import './typings-d8491423.js';
9
9
  import './progress.taro-1a7ac8a4.js';
10
- import './configprovider.taro-43a3c646.js';
10
+ import './configprovider.taro-ce34d482.js';
11
11
  import 'lodash.kebabcase';
12
- import './zh-CN-b4f493ba.js';
13
12
  import './index-5bcb0ff8.js';
14
13
 
15
14
 
@@ -1,10 +1,9 @@
1
- import { V as VirtualList } from './virtuallist.taro-0bd611cb.js';
1
+ import { V as VirtualList } from './virtuallist.taro-ba8e1f21.js';
2
2
  import 'react';
3
3
  import '@tarojs/components';
4
4
  import '@tarojs/taro';
5
- import './configprovider.taro-43a3c646.js';
5
+ import './configprovider.taro-ce34d482.js';
6
6
  import 'lodash.kebabcase';
7
- import './zh-CN-b4f493ba.js';
8
7
 
9
8
 
10
9
 
@@ -1,10 +1,9 @@
1
- import { W as WaterMark } from './watermark.taro-8966896a.js';
1
+ import { W as WaterMark } from './watermark.taro-168cdac5.js';
2
2
  import 'react';
3
3
  import '@tarojs/taro';
4
4
  import 'classnames';
5
- import './configprovider.taro-43a3c646.js';
5
+ import './configprovider.taro-ce34d482.js';
6
6
  import 'lodash.kebabcase';
7
- import './zh-CN-b4f493ba.js';
8
7
  import './bem-350c1702.js';
9
8
  import '@bem-react/classname';
10
9
 
@@ -1,13 +1,27 @@
1
- import React, { useEffect, useState, useRef } from 'react';
1
+ import React, { createContext, useContext, useEffect, useState, useRef } from 'react';
2
2
  import { Check, Location2, Left, CircleClose } from '@nutui/icons-react-taro';
3
3
  import { P as Popup } from './popup.taro-89cc342a.js';
4
4
  import { c as cn } from './bem-350c1702.js';
5
- import { u as useConfig } from './configprovider-9960f0fb.js';
5
+ import 'lodash.kebabcase';
6
+ import { z as zhCN, u as useConfig$1 } from './configprovider.taro-ce34d482.js';
6
7
  import { createSelectorQuery } from '@tarojs/taro';
7
- import { E as Elevator } from './elevator.taro-360a831f.js';
8
- import { u as useConfig$1 } from './configprovider.taro-43a3c646.js';
8
+ import { E as Elevator } from './elevator.taro-1a4e3356.js';
9
9
  import { C as ComponentDefaults } from './typings-d8491423.js';
10
10
 
11
+ const defaultConfigRef = {
12
+ current: {
13
+ locale: zhCN,
14
+ },
15
+ };
16
+ const getDefaultConfig = () => {
17
+ return defaultConfigRef.current;
18
+ };
19
+ // 创建一个 Context 对象
20
+ const ConfigContext = createContext(null);
21
+ const useConfig = () => {
22
+ return useContext(ConfigContext) ?? getDefaultConfig();
23
+ };
24
+
11
25
  const defaultProps$2 = {
12
26
  type: 'custom',
13
27
  existAddress: [],
@@ -1,10 +1,10 @@
1
1
  import React, { useState, useRef } from 'react';
2
2
  import { createInnerAudioContext } from '@tarojs/taro';
3
3
  import { Service } from '@nutui/icons-react-taro';
4
- import { R as Range } from './range.taro-432d20d7.js';
4
+ import { R as Range } from './range.taro-8953e8c3.js';
5
5
  import { B as Button } from './button.taro-b50bc217.js';
6
6
  import { c as cn } from './bem-350c1702.js';
7
- import { u as useConfig } from './configprovider.taro-43a3c646.js';
7
+ import { u as useConfig } from './configprovider.taro-ce34d482.js';
8
8
  import { C as ComponentDefaults } from './typings-d8491423.js';
9
9
 
10
10
  const b = cn('audio');
@@ -1,21 +1,24 @@
1
1
  import React, { useState, useRef, useContext, useEffect } from 'react';
2
2
  import classNames from 'classnames';
3
- import { Image } from '@tarojs/components';
4
- import { A as AvatarContext } from './AvatarContext-c96afdcc.js';
5
- import { c as cn } from './bem-350c1702.js';
3
+ import { I as Image } from './image.taro-3025e659.js';
4
+ import { A as AvatarContext } from './context-c96afdcc.js';
5
+ import { My } from '@nutui/icons-react-taro';
6
6
  import { C as ComponentDefaults } from './typings-d8491423.js';
7
7
 
8
8
  const defaultProps = {
9
9
  ...ComponentDefaults,
10
10
  size: '',
11
+ shape: 'round',
11
12
  icon: '',
12
- bgColor: '#eee',
13
+ fit: 'cover',
14
+ background: '#eee',
13
15
  color: '#666',
14
- prefixCls: 'nut-avatar',
15
- url: '',
16
+ src: '',
17
+ alt: '',
16
18
  };
19
+ const classPrefix = `nut-avatar`;
17
20
  const Avatar = (props) => {
18
- const { children, prefixCls, size, shape, bgColor, color, url, icon, className, style, activeAvatar, onActiveAvatar, onError, ...rest } = {
21
+ const { children, size, shape, background, color, src, icon, fit, alt, className, style, onClick, onError, ...rest } = {
19
22
  ...defaultProps,
20
23
  ...props,
21
24
  };
@@ -24,28 +27,27 @@ const Avatar = (props) => {
24
27
  const [avatarIndex, setAvatarIndex] = useState(1); // avatar的索引
25
28
  const avatarRef = useRef(null);
26
29
  const parent = useContext(AvatarContext);
27
- const b = cn('avatar');
30
+ const sizeValue = ['large', 'normal', 'small'];
28
31
  const classes = classNames({
29
- [`nut-avatar-${size || parent?.propAvatarGroup?.size || 'normal'}`]: true,
30
- [`nut-avatar-${shape || parent?.propAvatarGroup?.shape || 'round'}`]: true,
32
+ [`nut-avatar-${parent?.propAvatarGroup?.size || size || 'normal'}`]: true,
33
+ [`nut-avatar-${parent?.propAvatarGroup?.shape || shape}`]: true,
31
34
  });
32
- const cls = classNames(b(''), classes, className);
33
- const sizeValue = ['large', 'normal', 'small'];
35
+ const cls = classNames(classPrefix, classes, className);
34
36
  const styles = {
35
37
  width: sizeValue.indexOf(size) > -1 ? '' : `${size}px`,
36
38
  height: sizeValue.indexOf(size) > -1 ? '' : `${size}px`,
37
- backgroundColor: `${bgColor}`,
39
+ backgroundColor: `${background}`,
38
40
  color: `${color}`,
39
- marginLeft: avatarIndex !== 1 && parent?.propAvatarGroup?.span
40
- ? `${parent?.propAvatarGroup?.span}px`
41
+ marginLeft: avatarIndex !== 1 && parent?.propAvatarGroup?.gap
42
+ ? `${parent?.propAvatarGroup?.gap}px`
41
43
  : '',
42
- zIndex: parent?.propAvatarGroup?.zIndex === 'right'
44
+ zIndex: parent?.propAvatarGroup?.level === 'right'
43
45
  ? `${Math.abs(maxSum - avatarIndex)}`
44
46
  : '',
45
47
  ...style,
46
48
  };
47
49
  const maxStyles = {
48
- backgroundColor: `${parent?.propAvatarGroup?.maxBgColor}`,
50
+ backgroundColor: `${parent?.propAvatarGroup?.maxBackground}`,
49
51
  color: `${parent?.propAvatarGroup?.maxColor}`,
50
52
  };
51
53
  useEffect(() => {
@@ -64,7 +66,7 @@ const Avatar = (props) => {
64
66
  }
65
67
  }
66
68
  const index = avatarRef?.current?.dataset?.index;
67
- const maxCount = parent?.propAvatarGroup?.maxCount;
69
+ const maxCount = parent?.propAvatarGroup?.max;
68
70
  setMaxSum(children.length);
69
71
  setAvatarIndex(index);
70
72
  if (index === children.length &&
@@ -73,31 +75,31 @@ const Avatar = (props) => {
73
75
  setShowMax(true);
74
76
  }
75
77
  };
76
- const errorEvent = (e) => {
78
+ const errorEvent = () => {
77
79
  if (props.onError) {
78
- props.onError(e);
80
+ props.onError();
79
81
  }
80
82
  };
81
83
  const clickAvatar = (e) => {
82
- activeAvatar && activeAvatar(e);
83
- onActiveAvatar && onActiveAvatar(e);
84
+ onClick && onClick(e);
84
85
  };
85
86
  return (React.createElement(React.Fragment, null, (showMax ||
86
- !parent?.propAvatarGroup?.maxCount ||
87
- avatarIndex <= parent?.propAvatarGroup?.maxCount) && (React.createElement("div", { className: cls, ...rest, style: !showMax ? styles : maxStyles, onClick: clickAvatar, ref: avatarRef },
88
- (!parent?.propAvatarGroup?.maxCount ||
89
- avatarIndex <= parent?.propAvatarGroup?.maxCount) && (React.createElement(React.Fragment, null,
90
- url && (React.createElement(Image, { className: "avatar-img", src: url, onError: errorEvent })),
87
+ !parent?.propAvatarGroup?.max ||
88
+ avatarIndex <= parent?.propAvatarGroup?.max) && (React.createElement("div", { className: cls, ...rest, style: !showMax ? styles : maxStyles, onClick: clickAvatar, ref: avatarRef },
89
+ (!parent?.propAvatarGroup?.max ||
90
+ avatarIndex <= parent?.propAvatarGroup?.max) && (React.createElement(React.Fragment, null,
91
+ src && (React.createElement(Image, { className: "avatar-img", src: src, style: { objectFit: fit }, alt: alt, onError: errorEvent })),
91
92
  React.isValidElement(icon)
92
93
  ? React.cloneElement(icon, {
93
94
  ...icon.props,
94
95
  className: `${icon.props.className || ''} icon`,
95
96
  })
96
97
  : null,
97
- children && React.createElement("span", { className: "text" }, children))),
98
+ children && React.createElement("span", { className: "text" }, children),
99
+ !src && !icon && !children && React.createElement(My, { className: "icon" }))),
98
100
  showMax && (React.createElement("div", { className: "text" }, parent?.propAvatarGroup?.maxContent
99
101
  ? parent?.propAvatarGroup?.maxContent
100
- : `+ ${avatarIndex - parent?.propAvatarGroup?.maxCount}`))))));
102
+ : `+ ${avatarIndex - parent?.propAvatarGroup?.max}`))))));
101
103
  };
102
104
  Avatar.defaultProps = defaultProps;
103
105
  Avatar.displayName = 'NutAvatar';
@@ -1,26 +1,23 @@
1
1
  import React, { useRef } from 'react';
2
2
  import classNames from 'classnames';
3
- import { A as AvatarContext } from './AvatarContext-c96afdcc.js';
4
- import { c as cn } from './bem-350c1702.js';
5
- import { u as useConfig } from './configprovider-9960f0fb.js';
3
+ import { A as AvatarContext } from './context-c96afdcc.js';
4
+ import { C as ComponentDefaults } from './typings-d8491423.js';
6
5
 
7
6
  const defaultProps = {
7
+ ...ComponentDefaults,
8
8
  maxContent: '',
9
- maxCount: '',
10
- maxBgColor: '#eee',
9
+ max: '',
10
+ maxBackground: '#eee',
11
11
  maxColor: '#666',
12
- size: '',
13
- shape: '',
14
- span: '-8',
15
- zIndex: 'left',
12
+ gap: '-8',
13
+ level: 'left',
16
14
  };
15
+ const classPrefix = `nut-avatar-group`;
17
16
  const AvatarGroup = (props) => {
18
- useConfig();
19
17
  const propAvatarGroup = { ...defaultProps, ...props };
20
18
  const { className, style, children } = propAvatarGroup;
21
19
  const avatarGroupRef = useRef(null);
22
- const b = cn('avatar-group');
23
- const cls = classNames(b(''), className);
20
+ const cls = classNames(classPrefix, className);
24
21
  const parentAvatar = {
25
22
  propAvatarGroup,
26
23
  avatarGroupRef,
@@ -1,7 +1,7 @@
1
1
  import React, { useRef } from 'react';
2
2
  import { P as Popup } from './popup.taro-89cc342a.js';
3
- import { U as Utils, C as CalendarItem } from './calendaritem.taro-ab1ec154.js';
4
- import { u as useConfig } from './configprovider.taro-43a3c646.js';
3
+ import { U as Utils, C as CalendarItem } from './calendaritem.taro-2d4a8c34.js';
4
+ import { u as useConfig } from './configprovider.taro-ce34d482.js';
5
5
 
6
6
  const defaultProps = {
7
7
  type: 'one',
@@ -3,7 +3,7 @@ import classNames from 'classnames';
3
3
  import { ScrollView } from '@tarojs/components';
4
4
  import { nextTick } from '@tarojs/taro';
5
5
  import { c as cn } from './bem-350c1702.js';
6
- import { u as useConfig } from './configprovider.taro-43a3c646.js';
6
+ import { u as useConfig } from './configprovider.taro-ce34d482.js';
7
7
 
8
8
  const Utils = {
9
9
  /**
@@ -6,17 +6,18 @@ const defaultProps = {
6
6
  ...ComponentDefaults,
7
7
  title: '',
8
8
  description: '',
9
+ divider: true,
9
10
  };
10
11
  const classPrefix = 'nut-cell-group';
11
12
  const CellGroup = (props) => {
12
- const { children, className, style, title, description, ...rest } = {
13
+ const { children, className, style, title, description, divider, ...rest } = {
13
14
  ...defaultProps,
14
15
  ...props,
15
16
  };
16
17
  return (React.createElement("div", { className: classNames(classPrefix, className), ...rest },
17
18
  title ? React.createElement("div", { className: `${classPrefix}__title` }, title) : null,
18
19
  description ? (React.createElement("div", { className: `${classPrefix}__description` }, description)) : null,
19
- React.createElement("div", { className: `${classPrefix}__wrap` }, children)));
20
+ React.createElement("div", { className: `${classPrefix}__wrap ${divider ? `${classPrefix}__wrap--divider` : ''}` }, children)));
20
21
  };
21
22
  CellGroup.defaultProps = defaultProps;
22
23
  CellGroup.displayName = 'NutCellGroup';
@@ -0,0 +1,175 @@
1
+ import React, { createContext, useImperativeHandle, useCallback, useContext, useState, useEffect } from 'react';
2
+ import { CheckNormal, CheckDisabled, Checked } from '@nutui/icons-react-taro';
3
+ import classNames from 'classnames';
4
+ import { C as ComponentDefaults } from './typings-d8491423.js';
5
+ import { u as usePropsValue } from './use-props-value-ae7ee726.js';
6
+
7
+ const CheckboxGroupContext = createContext(null);
8
+
9
+ const defaultProps$1 = {
10
+ max: undefined,
11
+ labelPosition: 'right',
12
+ direction: 'vertical',
13
+ onChange: (value) => { },
14
+ options: [],
15
+ };
16
+ const classPrefix$1 = 'nut-checkboxgroup';
17
+ const CheckboxGroup = React.forwardRef((props, ref) => {
18
+ const { children } = { ...defaultProps$1, ...props };
19
+ const { className, disabled, onChange, value, defaultValue, max, labelPosition, direction, options, ...rest } = props;
20
+ useImperativeHandle(ref, () => ({
21
+ toggle(state) {
22
+ if (state === false) {
23
+ setValue([]);
24
+ }
25
+ else {
26
+ const childrenLabel = [];
27
+ React.Children.map(children, (child) => {
28
+ const childProps = child.props;
29
+ childrenLabel.push(childProps.value);
30
+ });
31
+ setValue(childrenLabel);
32
+ }
33
+ },
34
+ reverse() {
35
+ const childrenLabel = [];
36
+ React.Children.map(children, (child) => {
37
+ const childProps = child.props;
38
+ childrenLabel.push(childProps.value);
39
+ });
40
+ const reverse = childrenLabel.filter((c) => _value?.findIndex((v) => v === c) === -1);
41
+ setValue(reverse);
42
+ },
43
+ }));
44
+ const [_value, setValue] = usePropsValue({
45
+ value: props.value,
46
+ defaultValue: props.defaultValue,
47
+ finalValue: [],
48
+ onChange,
49
+ });
50
+ const renderOptions = useCallback(() => {
51
+ return options?.map(({ label, value, disabled, onChange, ...rest }) => {
52
+ return (React.createElement(Checkbox, { key: value?.toString(), label: label, disabled: disabled, value: value, ...rest }));
53
+ });
54
+ }, [options, max]);
55
+ return (React.createElement(CheckboxGroupContext.Provider, { value: {
56
+ labelPosition: labelPosition || 'right',
57
+ disabled,
58
+ max,
59
+ value: _value,
60
+ check: (value) => {
61
+ const combined = [..._value, value];
62
+ setValue(combined);
63
+ },
64
+ uncheck: (value) => {
65
+ const reduced = _value.filter((item) => item !== value);
66
+ setValue(reduced);
67
+ },
68
+ } },
69
+ React.createElement("div", { className: classNames(classPrefix$1, {
70
+ [`nut-checkboxgroup--${props.direction}`]: props.direction,
71
+ className,
72
+ }), ...rest }, options?.length ? renderOptions() : children)));
73
+ });
74
+ CheckboxGroup.defaultProps = defaultProps$1;
75
+ CheckboxGroup.displayName = 'NutCheckboxGroup';
76
+
77
+ const defaultProps = {
78
+ ...ComponentDefaults,
79
+ disabled: false,
80
+ labelPosition: 'right',
81
+ icon: null,
82
+ activeIcon: null,
83
+ indeterminateIcon: null,
84
+ onChange: (value) => { },
85
+ };
86
+ const classPrefix = 'nut-checkbox';
87
+ const Checkbox = (props) => {
88
+ const { children } = {
89
+ ...defaultProps,
90
+ ...props,
91
+ };
92
+ const { icon, label, className, activeIcon, checked, value, defaultChecked, disabled, onChange, indeterminate, indeterminateIcon, ...others } = props;
93
+ // eslint-disable-next-line prefer-const
94
+ let { labelPosition, ...rest } = others;
95
+ const ctx = useContext(CheckboxGroupContext);
96
+ let [innerChecked, setChecked] = usePropsValue({
97
+ value: props.checked,
98
+ defaultValue: props.defaultChecked,
99
+ finalValue: defaultChecked,
100
+ onChange,
101
+ });
102
+ // eslint-disable-next-line prefer-const
103
+ let [innerDisabled, setDisabled] = useState(disabled);
104
+ const [innerIndeterminate, setIndeterminate] = useState(indeterminate);
105
+ useEffect(() => {
106
+ setDisabled(disabled);
107
+ }, [disabled]);
108
+ useEffect(() => {
109
+ setIndeterminate(indeterminate);
110
+ }, [indeterminate]);
111
+ if (ctx) {
112
+ if (ctx.labelPosition !== undefined) {
113
+ labelPosition = ctx.labelPosition;
114
+ }
115
+ innerDisabled = ctx.disabled !== undefined ? ctx.disabled : innerDisabled;
116
+ innerChecked = ctx.value.includes(value);
117
+ setChecked = (checked) => {
118
+ if (ctx.disabled)
119
+ return;
120
+ if (checked)
121
+ ctx.check(value);
122
+ if (!checked)
123
+ ctx.uncheck(value);
124
+ };
125
+ }
126
+ const renderIcon = () => {
127
+ if (!innerChecked) {
128
+ return React.isValidElement(icon) ? (icon) : (React.createElement(CheckNormal, { className: color() }));
129
+ }
130
+ if (innerIndeterminate) {
131
+ return React.isValidElement(indeterminateIcon) ? (indeterminateIcon) : (React.createElement(CheckDisabled, { className: color() }));
132
+ }
133
+ return React.isValidElement(activeIcon) ? (activeIcon) : (React.createElement(Checked, { className: color() }));
134
+ };
135
+ const color = () => {
136
+ if (innerDisabled) {
137
+ return `${classPrefix}__icon--disable`;
138
+ }
139
+ if (innerChecked) {
140
+ if (innerIndeterminate) {
141
+ return `${classPrefix}__icon--indeterminate`;
142
+ }
143
+ return `${classPrefix}__icon`;
144
+ }
145
+ return `${classPrefix}__icon--unchecked`;
146
+ };
147
+ const renderLabel = () => {
148
+ return (React.createElement("span", { className: classNames(`${classPrefix}__label `, {
149
+ [`${classPrefix}__label--disabled`]: innerDisabled,
150
+ }) }, children || label));
151
+ };
152
+ const handleClick = () => {
153
+ // 禁用的时候直接返回
154
+ if (disabled)
155
+ return;
156
+ // 先转换状态
157
+ const latestChecked = !innerChecked;
158
+ // 判断是不是有 context 和 max,有的话需要判断是不是超过最大限制
159
+ if (ctx && ctx.max !== undefined) {
160
+ if (latestChecked && ctx.value.length >= ctx.max)
161
+ return;
162
+ }
163
+ setChecked(latestChecked);
164
+ };
165
+ return (React.createElement("div", { className: classNames(classPrefix, className, {
166
+ [`${classPrefix}--reverse`]: labelPosition === 'left',
167
+ }), ...rest, onClick: handleClick },
168
+ renderIcon(),
169
+ renderLabel()));
170
+ };
171
+ Checkbox.defaultProps = defaultProps;
172
+ Checkbox.displayName = 'NutCheckBox';
173
+ Checkbox.Group = CheckboxGroup;
174
+
175
+ export { Checkbox as C, CheckboxGroup as a };
@@ -1,35 +1,36 @@
1
- import React, { useState, useEffect } from 'react';
1
+ import React, { useState, useRef, useEffect } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import { a as isObject } from './index-5bcb0ff8.js';
4
- import { c as cn } from './bem-350c1702.js';
4
+ import { C as ComponentDefaults } from './typings-d8491423.js';
5
5
 
6
6
  const defaultProps = {
7
+ ...ComponentDefaults,
7
8
  strokeWidth: 5,
8
9
  radius: 50,
9
10
  strokeLinecap: 'round',
10
- circleColor: '#fa2c19',
11
- pathColor: '#e5e9f2',
11
+ color: '#fa2c19',
12
+ background: '#e5e9f2',
12
13
  clockwise: true,
13
14
  };
15
+ const classPrefix = `nut-circleprogress`;
14
16
  const CircleProgress = (props) => {
15
- const { children, progress, className, radius, pathColor, clockwise, circleColor, strokeWidth, style, strokeLinecap, ...restProps } = {
17
+ const { children, percent, className, radius, background, clockwise, color, strokeWidth, style, strokeLinecap, ...restProps } = {
16
18
  ...defaultProps,
17
19
  ...props,
18
20
  };
19
- const [oldValue, setOldValue] = useState(progress);
20
- const b = cn('circleprogress');
21
- const classes = classNames(className, b(''));
21
+ const [oldValue, setOldValue] = useState(percent);
22
+ const classes = classNames(className, classPrefix);
22
23
  const refRandomId = Math.random().toString(36).slice(-8);
24
+ const animateIdRef = useRef(0);
23
25
  const styles = {
24
26
  height: `${Number(radius) * 2}px`,
25
27
  width: `${Number(radius) * 2}px`,
26
28
  ...style,
27
29
  };
28
30
  useEffect(() => {
29
- let rafId;
30
31
  const startTime = Date.now();
31
32
  const startRate = Number(oldValue); // 30
32
- const endRate = Number(progress); // 40
33
+ const endRate = Number(percent); // 40
33
34
  const duration = Math.abs(((startRate - endRate) * 1000) / +100); // 100
34
35
  const animate = () => {
35
36
  const now = Date.now();
@@ -37,22 +38,17 @@ const CircleProgress = (props) => {
37
38
  const rate = progress * (endRate - startRate) + startRate;
38
39
  setOldValue(Math.min(Math.max(+rate, 0), 100));
39
40
  if (endRate > startRate ? rate < endRate : rate > endRate) {
40
- rafId = window.requestAnimationFrame(animate);
41
+ animateIdRef.current = window.requestAnimationFrame(animate);
41
42
  }
42
43
  };
43
- if (rafId) {
44
- cancelAnimationFrame(rafId);
45
- }
46
- rafId = window.requestAnimationFrame(animate);
47
- }, [progress]);
48
- const cancelAnimationFrame = function (id) {
49
- clearTimeout(id);
50
- };
44
+ animateIdRef.current = window.requestAnimationFrame(animate);
45
+ return () => window.cancelAnimationFrame(animateIdRef.current);
46
+ }, [percent]);
51
47
  const stop = () => {
52
- if (!isObject(circleColor)) {
48
+ if (!isObject(props.color)) {
53
49
  return [];
54
50
  }
55
- const color = circleColor;
51
+ const color = props.color;
56
52
  const colorArr = Object.keys(color).sort((a, b) => parseFloat(a) - parseFloat(b));
57
53
  const stopArr = [];
58
54
  colorArr.map((item) => {
@@ -84,12 +80,12 @@ const CircleProgress = (props) => {
84
80
  const progress = +oldValue;
85
81
  const offset = (perimeter * Number(format(parseFloat(progress.toFixed(1))))) / 100;
86
82
  const isWise = props.clockwise ? 1 : 0;
87
- const color = isObject(circleColor)
83
+ const color = isObject(props.color)
88
84
  ? `url(%23${refRandomId})`
89
- : transColor(circleColor);
85
+ : transColor(props.color);
90
86
  const d = `M 50 50 m 0 -45 a 45 45 0 1 ${isWise} 0 90 a 45 45 0 1, ${isWise} 0 -90`;
91
87
  const pa = `%3Cdefs%3E%3ClinearGradient id='${refRandomId}' x1='100%25' y1='0%25' x2='0%25' y2='0%25'%3E${stopDom}%3C/linearGradient%3E%3C/defs%3E`;
92
- const path = `%3Cpath d='${d}' stroke-width='${strokeWidth}' stroke='${transColor(props.pathColor)}' fill='none'/%3E`;
88
+ const path = `%3Cpath d='${d}' stroke-width='${strokeWidth}' stroke='${transColor(props.background)}' fill='none'/%3E`;
93
89
  const path1 = `%3Cpath d='${d}' stroke-width='${strokeWidth}' stroke-dasharray='${offset},${perimeter}' stroke-linecap='round' stroke='${transColor(color)}' fill='none'/%3E`;
94
90
  return {
95
91
  background: `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E${pa}${path}${path1}%3C/svg%3E")`,
@@ -99,9 +95,7 @@ const CircleProgress = (props) => {
99
95
  };
100
96
  return (React.createElement("div", { className: classes, style: styles, ...restProps },
101
97
  React.createElement("div", { style: circleStyle() }),
102
- React.createElement("div", { className: "nut-circleprogress-text" }, children || React.createElement("div", null,
103
- progress,
104
- "%"))));
98
+ React.createElement("div", { className: "nut-circleprogress-text" }, children)));
105
99
  };
106
100
  CircleProgress.defaultProps = defaultProps;
107
101
  CircleProgress.displayName = 'NutCircleProgress';
@@ -1,3 +1,6 @@
1
+ import React, { createContext, useContext, useMemo } from 'react';
2
+ import kebabCase from 'lodash.kebabcase';
3
+
1
4
  const zhCN = {
2
5
  save: '保存',
3
6
  confirm: '确认',
@@ -128,4 +131,44 @@ const zhCN = {
128
131
  },
129
132
  };
130
133
 
131
- export { zhCN as z };
134
+ const defaultProps = {
135
+ locale: zhCN,
136
+ };
137
+ const defaultConfigRef = {
138
+ current: {
139
+ locale: zhCN,
140
+ },
141
+ };
142
+ const setDefaultConfig = (config) => {
143
+ defaultConfigRef.current = config;
144
+ };
145
+ const getDefaultConfig = () => {
146
+ return defaultConfigRef.current;
147
+ };
148
+ // 创建一个 Context 对象
149
+ const ConfigContext = createContext(null);
150
+ const useConfig = () => {
151
+ return useContext(ConfigContext) ?? getDefaultConfig();
152
+ };
153
+ function convertThemeVarsToCSSVars(themeVars) {
154
+ const cssVars = {};
155
+ Object.keys(themeVars).forEach((key) => {
156
+ cssVars[`--${kebabCase(key)}`] = themeVars[key];
157
+ });
158
+ return cssVars;
159
+ }
160
+ const ConfigProvider = (props) => {
161
+ const { children, ...config } = { ...defaultProps, ...props };
162
+ const parentConfig = useConfig();
163
+ const theme = config.theme || {};
164
+ const style = useMemo(() => convertThemeVarsToCSSVars(theme), [theme]);
165
+ return (React.createElement(ConfigContext.Provider, { value: {
166
+ ...parentConfig,
167
+ ...config,
168
+ } },
169
+ React.createElement("div", { style: style }, children)));
170
+ };
171
+ ConfigProvider.defaultProps = defaultProps;
172
+ ConfigProvider.displayName = 'NutConfigProvider';
173
+
174
+ export { ConfigProvider as C, getDefaultConfig as g, setDefaultConfig as s, useConfig as u, zhCN as z };