@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.
- package/CHANGELOG.md +15 -0
- package/dist/esm/Address.js +3 -5
- package/dist/esm/Audio.js +3 -4
- package/dist/esm/Avatar.js +6 -5
- package/dist/esm/AvatarGroup.js +3 -7
- package/dist/esm/Calendar.js +3 -4
- package/dist/esm/CalendarItem.js +2 -3
- package/dist/esm/CellGroup.js +1 -1
- package/dist/esm/Checkbox.js +3 -3
- package/dist/esm/CheckboxGroup.js +3 -3
- package/dist/esm/ConfigProvider.js +2 -3
- package/dist/esm/CountDown.js +2 -3
- package/dist/esm/DatePicker.js +3 -4
- package/dist/esm/Dialog.js +2 -3
- package/dist/esm/Elevator.js +1 -1
- package/dist/esm/Ellipsis.js +3 -4
- package/dist/esm/Empty.js +3 -5
- package/dist/esm/FixedNav.js +2 -3
- package/dist/esm/Form.js +2 -2
- package/dist/esm/Grid.js +3 -4
- package/dist/esm/GridItem.js +2 -3
- package/dist/esm/Image.js +2 -3
- package/dist/esm/Infiniteloading.js +2 -3
- package/dist/esm/Input.js +2 -3
- package/dist/esm/NumberKeyboard.js +2 -3
- package/dist/esm/Pagination.js +2 -3
- package/dist/esm/Picker.js +2 -3
- package/dist/esm/PullToRefresh.js +2 -3
- package/dist/esm/Range.js +2 -3
- package/dist/esm/SearchBar.js +2 -3
- package/dist/esm/ShortPassword.js +2 -3
- package/dist/esm/Signature.js +2 -3
- package/dist/esm/Skeleton.js +8 -5
- package/dist/esm/Swipe.js +1 -1
- package/dist/esm/Tabbar/style/index.js +1 -1
- package/dist/esm/Table.js +2 -3
- package/dist/esm/TextArea.js +2 -3
- package/dist/esm/TimeDetail.js +2 -3
- package/dist/esm/TimePannel.js +2 -3
- package/dist/esm/TimeSelect.js +4 -5
- package/dist/esm/Uploader.js +2 -3
- package/dist/esm/VirtualList.js +2 -3
- package/dist/esm/WaterMark.js +2 -3
- package/dist/esm/{address.taro-67e32c33.js → address.taro-cab0ea22.js} +18 -4
- package/dist/esm/{audio.taro-51eafc9d.js → audio.taro-ff280f5e.js} +2 -2
- package/dist/esm/{avatar.taro-a840f345.js → avatar.taro-6e8f1f5c.js} +31 -29
- package/dist/esm/{avatargroup-0eadb514.js → avatargroup-f4375806.js} +9 -12
- package/dist/esm/{calendar.taro-b3ebdc35.js → calendar.taro-2fc9b899.js} +2 -2
- package/dist/esm/{calendaritem.taro-ab1ec154.js → calendaritem.taro-2d4a8c34.js} +1 -1
- package/dist/esm/{cellgroup.taro-660faffc.js → cellgroup.taro-e05ea802.js} +3 -2
- package/dist/esm/checkbox.taro-9d02f86c.js +175 -0
- package/dist/esm/{zh-CN-b4f493ba.js → configprovider.taro-ce34d482.js} +44 -1
- package/dist/esm/{countdown.taro-c14b5c1f.js → countdown.taro-3118ba23.js} +1 -1
- package/dist/esm/{datepicker.taro-7d522ff8.js → datepicker.taro-2e3e955b.js} +2 -2
- package/dist/esm/{dialog.taro-f9ca73a2.js → dialog.taro-eab19eab.js} +1 -1
- package/dist/esm/{elevator.taro-360a831f.js → elevator.taro-1a4e3356.js} +16 -8
- package/dist/esm/{ellipsis.taro-79044d54.js → ellipsis.taro-e1ac99a1.js} +7 -4
- package/dist/esm/{empty.taro-f8585835.js → empty.taro-26363c66.js} +12 -18
- package/dist/esm/{fixednav.taro-cca9a6df.js → fixednav.taro-ddb21e87.js} +1 -1
- package/dist/esm/{form.taro-7413d868.js → form.taro-423b0f0a.js} +1 -1
- package/dist/esm/{grid.taro-10eb7716.js → grid.taro-883a9c35.js} +1 -1
- package/dist/esm/{griditem.taro-fb15eeec.js → griditem.taro-16c7055b.js} +1 -1
- package/dist/esm/{image.taro-b897a058.js → image.taro-3025e659.js} +1 -1
- package/dist/esm/{infiniteloading.taro-cce53c60.js → infiniteloading.taro-721bca1f.js} +1 -1
- package/dist/esm/{input.taro-1aca4a45.js → input.taro-06c1e4d5.js} +1 -1
- package/dist/esm/{numberkeyboard.taro-10ab54d6.js → numberkeyboard.taro-d9b1721b.js} +1 -1
- package/dist/esm/nutui-react.es.js +41 -43
- package/dist/esm/{pagination.taro-df441058.js → pagination.taro-94f9be5e.js} +1 -1
- package/dist/esm/{picker.taro-9f1bb6a4.js → picker.taro-e16b4312.js} +1 -1
- package/dist/esm/{pulltorefresh.taro-37dadbc5.js → pulltorefresh.taro-016d0079.js} +1 -1
- package/dist/esm/{range.taro-432d20d7.js → range.taro-8953e8c3.js} +1 -1
- package/dist/esm/{searchbar.taro-4aa300df.js → searchbar.taro-4467040f.js} +1 -1
- package/dist/esm/{shortpassword.taro-99645f99.js → shortpassword.taro-433b86a4.js} +1 -1
- package/dist/esm/{signature.taro-e5ede25a.js → signature.taro-a4d9b5c9.js} +1 -1
- package/dist/esm/{skeleton.taro-fabd423a.js → skeleton.taro-8ec11af9.js} +2 -2
- package/dist/esm/{swipe.taro-b18a73ff.js → swipe.taro-0b8cc872.js} +3 -5
- package/dist/esm/{table.taro-eca757f3.js → table.taro-327b4248.js} +1 -1
- package/dist/esm/{textarea.taro-e256e741.js → textarea.taro-add72cf3.js} +1 -1
- package/dist/esm/{timedetail.taro-cae362b9.js → timedetail.taro-82a2900b.js} +1 -1
- package/dist/esm/{timepannel.taro-d6f4cf80.js → timepannel.taro-0573bb65.js} +1 -1
- package/dist/esm/{timeselect.taro-804199f9.js → timeselect.taro-29124a34.js} +3 -3
- package/dist/esm/{uploader.taro-716f9a50.js → uploader.taro-c70d00de.js} +1 -1
- package/dist/esm/{virtuallist.taro-0bd611cb.js → virtuallist.taro-ba8e1f21.js} +1 -1
- package/dist/esm/{watermark.taro-8966896a.js → watermark.taro-168cdac5.js} +1 -1
- package/dist/locales/base.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/id-ID.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/locales/zh-TW.js +1 -1
- package/dist/locales/zh-UG.js +1 -1
- package/dist/nutui.react.mjs +421 -331
- package/dist/nutui.react.umd.js +421 -331
- package/dist/packages/cellgroup/cellgroup.scss +20 -16
- package/dist/packages/checkbox/checkbox.scss +8 -11
- package/dist/packages/empty/empty.scss +0 -9
- package/dist/packages/tabbar/tabbar.scss +1 -0
- package/dist/style.css +1 -1
- package/dist/style.mjs +1 -1
- package/dist/styles/themes/default.scss +0 -1
- package/dist/types/index.d.ts +38 -45
- package/package.json +1 -1
- package/dist/esm/Icon.js +0 -64
- package/dist/esm/checkbox.taro-ae460d3a.js +0 -168
- package/dist/esm/configprovider-9960f0fb.js +0 -19
- package/dist/esm/configprovider.taro-43a3c646.js +0 -45
- package/dist/packages/icon/icon.scss +0 -0
- /package/dist/esm/{AvatarContext-c96afdcc.js → context-c96afdcc.js} +0 -0
package/dist/esm/VirtualList.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { V as VirtualList } from './virtuallist.taro-
|
|
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-
|
|
5
|
+
import './configprovider.taro-ce34d482.js';
|
|
6
6
|
import 'lodash.kebabcase';
|
|
7
|
-
import './zh-CN-b4f493ba.js';
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
|
package/dist/esm/WaterMark.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { W as WaterMark } from './watermark.taro-
|
|
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-
|
|
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
|
|
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-
|
|
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-
|
|
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-
|
|
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 '
|
|
4
|
-
import { A as AvatarContext } from './
|
|
5
|
-
import {
|
|
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
|
-
|
|
13
|
+
fit: 'cover',
|
|
14
|
+
background: '#eee',
|
|
13
15
|
color: '#666',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
src: '',
|
|
17
|
+
alt: '',
|
|
16
18
|
};
|
|
19
|
+
const classPrefix = `nut-avatar`;
|
|
17
20
|
const Avatar = (props) => {
|
|
18
|
-
const { children,
|
|
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
|
|
30
|
+
const sizeValue = ['large', 'normal', 'small'];
|
|
28
31
|
const classes = classNames({
|
|
29
|
-
[`nut-avatar-${
|
|
30
|
-
[`nut-avatar-${
|
|
32
|
+
[`nut-avatar-${parent?.propAvatarGroup?.size || size || 'normal'}`]: true,
|
|
33
|
+
[`nut-avatar-${parent?.propAvatarGroup?.shape || shape}`]: true,
|
|
31
34
|
});
|
|
32
|
-
const cls = classNames(
|
|
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: `${
|
|
39
|
+
backgroundColor: `${background}`,
|
|
38
40
|
color: `${color}`,
|
|
39
|
-
marginLeft: avatarIndex !== 1 && parent?.propAvatarGroup?.
|
|
40
|
-
? `${parent?.propAvatarGroup?.
|
|
41
|
+
marginLeft: avatarIndex !== 1 && parent?.propAvatarGroup?.gap
|
|
42
|
+
? `${parent?.propAvatarGroup?.gap}px`
|
|
41
43
|
: '',
|
|
42
|
-
zIndex: parent?.propAvatarGroup?.
|
|
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?.
|
|
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?.
|
|
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 = (
|
|
78
|
+
const errorEvent = () => {
|
|
77
79
|
if (props.onError) {
|
|
78
|
-
props.onError(
|
|
80
|
+
props.onError();
|
|
79
81
|
}
|
|
80
82
|
};
|
|
81
83
|
const clickAvatar = (e) => {
|
|
82
|
-
|
|
83
|
-
onActiveAvatar && onActiveAvatar(e);
|
|
84
|
+
onClick && onClick(e);
|
|
84
85
|
};
|
|
85
86
|
return (React.createElement(React.Fragment, null, (showMax ||
|
|
86
|
-
!parent?.propAvatarGroup?.
|
|
87
|
-
avatarIndex <= parent?.propAvatarGroup?.
|
|
88
|
-
(!parent?.propAvatarGroup?.
|
|
89
|
-
avatarIndex <= parent?.propAvatarGroup?.
|
|
90
|
-
|
|
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?.
|
|
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 './
|
|
4
|
-
import {
|
|
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
|
-
|
|
10
|
-
|
|
9
|
+
max: '',
|
|
10
|
+
maxBackground: '#eee',
|
|
11
11
|
maxColor: '#666',
|
|
12
|
-
|
|
13
|
-
|
|
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
|
|
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-
|
|
4
|
-
import { u as useConfig } from './configprovider.taro-
|
|
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-
|
|
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
|
-
|
|
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-
|
|
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-
|
|
3
|
-
import { u as useConfig } from './configprovider.taro-
|
|
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-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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,
|