@nutui/nutui-react-taro 2.0.0-alpha.4 → 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 (107) hide show
  1. package/CHANGELOG.md +15 -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/ConfigProvider.js +2 -3
  12. package/dist/esm/CountDown.js +2 -3
  13. package/dist/esm/DatePicker.js +3 -4
  14. package/dist/esm/Dialog.js +2 -3
  15. package/dist/esm/Elevator.js +1 -1
  16. package/dist/esm/Ellipsis.js +3 -4
  17. package/dist/esm/Empty.js +3 -5
  18. package/dist/esm/FixedNav.js +2 -3
  19. package/dist/esm/Form.js +2 -2
  20. package/dist/esm/Grid.js +3 -4
  21. package/dist/esm/GridItem.js +2 -3
  22. package/dist/esm/Image.js +2 -3
  23. package/dist/esm/Infiniteloading.js +2 -3
  24. package/dist/esm/Input.js +2 -3
  25. package/dist/esm/NumberKeyboard.js +2 -3
  26. package/dist/esm/Pagination.js +2 -3
  27. package/dist/esm/Picker.js +2 -3
  28. package/dist/esm/PullToRefresh.js +2 -3
  29. package/dist/esm/Range.js +2 -3
  30. package/dist/esm/SearchBar.js +2 -3
  31. package/dist/esm/ShortPassword.js +2 -3
  32. package/dist/esm/Signature.js +2 -3
  33. package/dist/esm/Skeleton.js +8 -5
  34. package/dist/esm/Swipe.js +1 -1
  35. package/dist/esm/Tabbar/style/index.js +1 -1
  36. package/dist/esm/Table.js +2 -3
  37. package/dist/esm/TextArea.js +2 -3
  38. package/dist/esm/TimeDetail.js +2 -3
  39. package/dist/esm/TimePannel.js +2 -3
  40. package/dist/esm/TimeSelect.js +4 -5
  41. package/dist/esm/Uploader.js +2 -3
  42. package/dist/esm/VirtualList.js +2 -3
  43. package/dist/esm/WaterMark.js +2 -3
  44. package/dist/esm/{address.taro-67e32c33.js → address.taro-cab0ea22.js} +18 -4
  45. package/dist/esm/{audio.taro-51eafc9d.js → audio.taro-ff280f5e.js} +2 -2
  46. package/dist/esm/{avatar.taro-a840f345.js → avatar.taro-6e8f1f5c.js} +31 -29
  47. package/dist/esm/{avatargroup-0eadb514.js → avatargroup-f4375806.js} +9 -12
  48. package/dist/esm/{calendar.taro-b3ebdc35.js → calendar.taro-2fc9b899.js} +2 -2
  49. package/dist/esm/{calendaritem.taro-ab1ec154.js → calendaritem.taro-2d4a8c34.js} +1 -1
  50. package/dist/esm/{cellgroup.taro-660faffc.js → cellgroup.taro-e05ea802.js} +3 -2
  51. package/dist/esm/checkbox.taro-9d02f86c.js +175 -0
  52. package/dist/esm/{zh-CN-b4f493ba.js → configprovider.taro-ce34d482.js} +44 -1
  53. package/dist/esm/{countdown.taro-c14b5c1f.js → countdown.taro-3118ba23.js} +1 -1
  54. package/dist/esm/{datepicker.taro-7d522ff8.js → datepicker.taro-2e3e955b.js} +2 -2
  55. package/dist/esm/{dialog.taro-f9ca73a2.js → dialog.taro-eab19eab.js} +1 -1
  56. package/dist/esm/{elevator.taro-360a831f.js → elevator.taro-1a4e3356.js} +16 -8
  57. package/dist/esm/{ellipsis.taro-79044d54.js → ellipsis.taro-e1ac99a1.js} +7 -4
  58. package/dist/esm/{empty.taro-f8585835.js → empty.taro-26363c66.js} +12 -18
  59. package/dist/esm/{fixednav.taro-cca9a6df.js → fixednav.taro-ddb21e87.js} +1 -1
  60. package/dist/esm/{form.taro-7413d868.js → form.taro-423b0f0a.js} +1 -1
  61. package/dist/esm/{grid.taro-10eb7716.js → grid.taro-883a9c35.js} +1 -1
  62. package/dist/esm/{griditem.taro-fb15eeec.js → griditem.taro-16c7055b.js} +1 -1
  63. package/dist/esm/{image.taro-b897a058.js → image.taro-3025e659.js} +1 -1
  64. package/dist/esm/{infiniteloading.taro-cce53c60.js → infiniteloading.taro-721bca1f.js} +1 -1
  65. package/dist/esm/{input.taro-1aca4a45.js → input.taro-06c1e4d5.js} +1 -1
  66. package/dist/esm/{numberkeyboard.taro-10ab54d6.js → numberkeyboard.taro-d9b1721b.js} +1 -1
  67. package/dist/esm/nutui-react.es.js +41 -43
  68. package/dist/esm/{pagination.taro-df441058.js → pagination.taro-94f9be5e.js} +1 -1
  69. package/dist/esm/{picker.taro-9f1bb6a4.js → picker.taro-e16b4312.js} +1 -1
  70. package/dist/esm/{pulltorefresh.taro-37dadbc5.js → pulltorefresh.taro-016d0079.js} +1 -1
  71. package/dist/esm/{range.taro-432d20d7.js → range.taro-8953e8c3.js} +1 -1
  72. package/dist/esm/{searchbar.taro-4aa300df.js → searchbar.taro-4467040f.js} +1 -1
  73. package/dist/esm/{shortpassword.taro-99645f99.js → shortpassword.taro-433b86a4.js} +1 -1
  74. package/dist/esm/{signature.taro-e5ede25a.js → signature.taro-a4d9b5c9.js} +1 -1
  75. package/dist/esm/{skeleton.taro-fabd423a.js → skeleton.taro-8ec11af9.js} +2 -2
  76. package/dist/esm/{swipe.taro-b18a73ff.js → swipe.taro-0b8cc872.js} +3 -5
  77. package/dist/esm/{table.taro-eca757f3.js → table.taro-327b4248.js} +1 -1
  78. package/dist/esm/{textarea.taro-e256e741.js → textarea.taro-add72cf3.js} +1 -1
  79. package/dist/esm/{timedetail.taro-cae362b9.js → timedetail.taro-82a2900b.js} +1 -1
  80. package/dist/esm/{timepannel.taro-d6f4cf80.js → timepannel.taro-0573bb65.js} +1 -1
  81. package/dist/esm/{timeselect.taro-804199f9.js → timeselect.taro-29124a34.js} +3 -3
  82. package/dist/esm/{uploader.taro-716f9a50.js → uploader.taro-c70d00de.js} +1 -1
  83. package/dist/esm/{virtuallist.taro-0bd611cb.js → virtuallist.taro-ba8e1f21.js} +1 -1
  84. package/dist/esm/{watermark.taro-8966896a.js → watermark.taro-168cdac5.js} +1 -1
  85. package/dist/locales/base.js +1 -1
  86. package/dist/locales/en-US.js +1 -1
  87. package/dist/locales/id-ID.js +1 -1
  88. package/dist/locales/zh-CN.js +1 -1
  89. package/dist/locales/zh-TW.js +1 -1
  90. package/dist/locales/zh-UG.js +1 -1
  91. package/dist/nutui.react.mjs +421 -331
  92. package/dist/nutui.react.umd.js +421 -331
  93. package/dist/packages/cellgroup/cellgroup.scss +20 -16
  94. package/dist/packages/checkbox/checkbox.scss +8 -11
  95. package/dist/packages/empty/empty.scss +0 -9
  96. package/dist/packages/tabbar/tabbar.scss +1 -0
  97. package/dist/style.css +1 -1
  98. package/dist/style.mjs +1 -1
  99. package/dist/styles/themes/default.scss +0 -1
  100. package/dist/types/index.d.ts +38 -45
  101. package/package.json +1 -1
  102. package/dist/esm/Icon.js +0 -64
  103. package/dist/esm/checkbox.taro-ae460d3a.js +0 -168
  104. package/dist/esm/configprovider-9960f0fb.js +0 -19
  105. package/dist/esm/configprovider.taro-43a3c646.js +0 -45
  106. package/dist/packages/icon/icon.scss +0 -0
  107. /package/dist/esm/{AvatarContext-c96afdcc.js → context-c96afdcc.js} +0 -0
@@ -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,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 };
@@ -1,6 +1,6 @@
1
1
  import React, { useState, useRef, useImperativeHandle, useEffect } from 'react';
2
2
  import { c as cn } from './bem-350c1702.js';
3
- import { u as useConfig } from './configprovider.taro-43a3c646.js';
3
+ import { u as useConfig } from './configprovider.taro-ce34d482.js';
4
4
 
5
5
  const defaultProps = {
6
6
  paused: false,
@@ -1,6 +1,6 @@
1
1
  import React, { useState, useRef, useEffect } from 'react';
2
- import { P as Picker } from './picker.taro-9f1bb6a4.js';
3
- import { u as useConfig } from './configprovider.taro-43a3c646.js';
2
+ import { P as Picker } from './picker.taro-e16b4312.js';
3
+ import { u as useConfig } from './configprovider.taro-ce34d482.js';
4
4
  import { View } from '@tarojs/components';
5
5
 
6
6
  const currentYear = new Date().getFullYear();
@@ -5,7 +5,7 @@ import { B as Button } from './button.taro-b50bc217.js';
5
5
  import { CSSTransition } from 'react-transition-group';
6
6
  import { d as defaultOverlayProps, O as Overlay } from './overlay.taro-067b7202.js';
7
7
  import { C as ComponentDefaults } from './typings-d8491423.js';
8
- import { u as useConfig } from './configprovider.taro-43a3c646.js';
8
+ import { u as useConfig } from './configprovider.taro-ce34d482.js';
9
9
 
10
10
  const Content = (props) => {
11
11
  const { visible, title, footer, footerDirection, onClick, children } = props;
@@ -1,5 +1,5 @@
1
1
  import React, { createContext, useRef, useState, useEffect } from 'react';
2
- import { nextTick, createSelectorQuery } from '@tarojs/taro';
2
+ import Taro, { nextTick, createSelectorQuery } from '@tarojs/taro';
3
3
  import { ScrollView } from '@tarojs/components';
4
4
  import classNames from 'classnames';
5
5
  import { C as ComponentDefaults } from './typings-d8491423.js';
@@ -39,6 +39,7 @@ const Elevator = (props) => {
39
39
  const [scrollStart, setScrollStart] = useState(false);
40
40
  const state = useRef(initData);
41
41
  const [scrollTop, setScrollTop] = useState(0);
42
+ const [scrollY, setScrollY] = useState(0);
42
43
  // 重置滚动参数
43
44
  const resetScrollState = () => {
44
45
  setScrollStart(false);
@@ -81,7 +82,11 @@ const Elevator = (props) => {
81
82
  cacheIndex = state.current.listHeight.length - 2;
82
83
  }
83
84
  setCodeIndex(cacheIndex);
84
- setScrollTop(state.current.listHeight[cacheIndex]);
85
+ const scrollTop = state.current.listHeight[cacheIndex];
86
+ setScrollTop(scrollTop);
87
+ if (sticky && scrollY !== scrollTop) {
88
+ setScrollY(Math.floor(scrollTop) > 0 ? 1 : 0);
89
+ }
85
90
  };
86
91
  const touchMove = (e) => {
87
92
  const firstTouch = e.touches[0];
@@ -132,7 +137,10 @@ const Elevator = (props) => {
132
137
  const target = e.target;
133
138
  const { scrollTop } = target;
134
139
  state.current.scrollY = Math.floor(scrollTop);
135
- setScrollTop(scrollTop);
140
+ Taro.getEnv() === 'WEB' && setScrollTop(scrollTop);
141
+ if (sticky && scrollTop !== scrollY) {
142
+ setScrollY(Math.floor(scrollTop) > 0 ? 1 : 0);
143
+ }
136
144
  for (let i = 0; i < listHeight.length - 1; i++) {
137
145
  const height1 = listHeight[i];
138
146
  const height2 = listHeight[i + 1];
@@ -141,7 +149,7 @@ const Elevator = (props) => {
141
149
  return;
142
150
  }
143
151
  }
144
- setCurrentIndex(listHeight.length - 2);
152
+ // setCurrentIndex(listHeight.length - 2)
145
153
  };
146
154
  useEffect(() => {
147
155
  if (listview.current) {
@@ -151,10 +159,8 @@ const Elevator = (props) => {
151
159
  }
152
160
  }, [listview]);
153
161
  return (React.createElement("div", { className: `${classPrefix} ${className}`, style: style, ...rest },
154
- sticky && scrollTop > 0 ? (React.createElement("div", { className: `${classPrefix}__list__fixed` },
155
- React.createElement("span", { className: `${classPrefix}__list__fixed__title` }, list[currentIndex][floorKey]))) : null,
156
162
  React.createElement("div", { className: `${classPrefix}__list`, style: { height: Number.isNaN(+height) ? height : `${height}px` } },
157
- React.createElement(ScrollView, { scrollTop: scrollTop, scrollY: true, className: `${classPrefix}__list__inner`, type: "list", ref: listview, onScroll: listViewScroll }, list.map((item, idx) => {
163
+ React.createElement(ScrollView, { scrollTop: scrollTop, scrollY: true, scrollWithAnimation: true, scrollAnchoring: true, className: `${classPrefix}__list__inner`, type: "list", ref: listview, onScroll: listViewScroll }, list.map((item, idx) => {
158
164
  return (React.createElement("div", { className: `${classPrefix}__list__item nut-elevator__item__${idx}`, key: idx },
159
165
  React.createElement("div", { className: `${classPrefix}__list__item__code` }, item[floorKey]),
160
166
  React.createElement(React.Fragment, null, item.list.map((subitem) => {
@@ -176,7 +182,9 @@ const Elevator = (props) => {
176
182
  [`${classPrefix}__bars__inner__item`]: true,
177
183
  [`${classPrefix}__bars__inner__item--active`]: item[floorKey] === list[currentIndex][floorKey],
178
184
  }), "data-index": index, key: index, onClick: () => handleClickIndex(item[floorKey]) }, item[floorKey]));
179
- })))));
185
+ }))),
186
+ sticky && scrollY > 0 ? (React.createElement("div", { className: `${classPrefix}__list__fixed` },
187
+ React.createElement("span", { className: `${classPrefix}__list__fixed__title` }, list[currentIndex][floorKey]))) : null));
180
188
  };
181
189
  Elevator.defaultProps = defaultProps;
182
190
  Elevator.displayName = 'NutElevator';
@@ -1,9 +1,11 @@
1
1
  import React, { useState, useRef, useEffect } from 'react';
2
2
  import { useReady, nextTick, createSelectorQuery } from '@tarojs/taro';
3
- import { u as useConfig } from './configprovider.taro-43a3c646.js';
4
3
  import { g as getRectByTaro } from './use-client-rect-1f8ed1fe.js';
4
+ import { C as ComponentDefaults } from './typings-d8491423.js';
5
+ import classNames from 'classnames';
5
6
 
6
7
  const defaultProps = {
8
+ ...ComponentDefaults,
7
9
  content: '',
8
10
  direction: 'end',
9
11
  rows: 1,
@@ -12,9 +14,9 @@ const defaultProps = {
12
14
  symbol: '...',
13
15
  lineHeight: '20',
14
16
  };
17
+ const classPrefix = `nut-ellipsis`;
15
18
  const Ellipsis = (props) => {
16
- useConfig();
17
- const { children, content, direction, rows, expandText, collapseText, symbol, lineHeight, onClick, onChange, } = { ...defaultProps, ...props };
19
+ const { children, content, direction, rows, className, expandText, collapseText, symbol, lineHeight, onClick, onChange, ...rest } = { ...defaultProps, ...props };
18
20
  let maxHeight = 0; // 当行的最大高度
19
21
  const [exceeded, setExceeded] = useState(false);
20
22
  const [expanded, setExpanded] = useState(false);
@@ -36,6 +38,7 @@ const Ellipsis = (props) => {
36
38
  const digitReg = /^[0-9]+$/; // 数字
37
39
  const letterUpperReg = /^[A-Z]+$/; // 字母
38
40
  const letterLowerReg = /^[a-z]+$/; // 字母
41
+ const classes = classNames(classPrefix, className);
39
42
  const init = () => {
40
43
  setExceeded(false);
41
44
  setExpanded(false);
@@ -212,7 +215,7 @@ const Ellipsis = (props) => {
212
215
  onClick && onClick();
213
216
  };
214
217
  return (React.createElement(React.Fragment, null,
215
- React.createElement("div", { className: "nut-ellipsis", onClick: handleClick, ref: root, id: `root${refRandomId}` },
218
+ React.createElement("div", { className: classes, onClick: handleClick, ref: root, id: `root${refRandomId}`, ...rest },
216
219
  React.createElement("div", null,
217
220
  !exceeded ? (React.createElement("div", { className: "nut-ellipsis-wordbreak" }, content)) : null,
218
221
  exceeded && !expanded ? (React.createElement(React.Fragment, null,