@nutui/nutui-react-taro 1.4.4-beta.0 → 1.4.5-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/esm/Address.js +5 -5
- package/dist/esm/Audio.js +5 -5
- package/dist/esm/AvatarContext-7153ad2b.js +3 -1
- package/dist/esm/AvatarGroup.js +4 -4
- package/dist/esm/Calendar.js +5 -5
- package/dist/esm/CalendarItem.js +4 -4
- package/dist/esm/Card.js +4 -3
- package/dist/esm/Cell.js +2 -2
- package/dist/esm/ConfigProvider.js +3 -3
- package/dist/esm/CountDown.js +4 -4
- package/dist/esm/DatePicker.js +5 -5
- package/dist/esm/Dialog.js +4 -4
- package/dist/esm/Ellipsis.js +4 -4
- package/dist/esm/Empty.js +4 -4
- package/dist/esm/FixedNav.js +4 -4
- package/dist/esm/Form.js +4 -4
- package/dist/esm/FormItem.js +3 -3
- package/dist/esm/Grid.js +4 -4
- package/dist/esm/GridItem.js +4 -4
- package/dist/esm/Image.js +4 -4
- package/dist/esm/Infiniteloading.js +4 -4
- package/dist/esm/Input.js +4 -4
- package/dist/esm/MenuItem.js +4 -4
- package/dist/esm/NoticeBar.js +2 -2
- package/dist/esm/NumberKeyboard.js +4 -4
- package/dist/esm/Pagination.js +4 -4
- package/dist/esm/Picker.js +4 -4
- package/dist/esm/PullToRefresh.js +4 -4
- package/dist/esm/Range.js +4 -4
- package/dist/esm/SearchBar.js +4 -4
- package/dist/esm/ShortPassword.js +4 -4
- package/dist/esm/SideNavBar.js +4 -4
- package/dist/esm/Signature.js +4 -4
- package/dist/esm/Sticky.js +4 -4
- package/dist/esm/Table.js +4 -4
- package/dist/esm/Tag.js +3 -2
- package/dist/esm/TextArea.js +4 -4
- package/dist/esm/TimeDetail.js +4 -4
- package/dist/esm/TimePannel.js +4 -4
- package/dist/esm/TimeSelect.js +6 -6
- package/dist/esm/Uploader.js +4 -4
- package/dist/esm/UserContext-68f62e66.js +3 -1
- package/dist/esm/UserContext-b4181162.js +3 -1
- package/dist/esm/UserContext-be8097d2.js +3 -1
- package/dist/esm/VirtualList.js +6 -4
- package/dist/esm/WaterMark.js +4 -4
- package/dist/esm/actionsheet.taro-a58d3d12.js +45 -83
- package/dist/esm/address.taro-79cc7c96.js +461 -0
- package/dist/esm/animate.taro-b0e83dd5.js +32 -46
- package/dist/esm/animatingnumbers.taro-6f40a2e9.js +93 -134
- package/dist/esm/audio.taro-4fadc583.js +161 -0
- package/dist/esm/avatar.taro-85ced995.js +93 -119
- package/dist/esm/avatargroup-1d900174.js +34 -0
- package/dist/esm/backtop.taro-99107c30.js +39 -62
- package/dist/esm/badge.taro-fe9171ec.js +40 -58
- package/dist/esm/barrage.taro-0e157b5e.js +61 -91
- package/dist/esm/bem-893ad28d.js +3 -6
- package/dist/esm/button.taro-4ce133b9.js +87 -98
- package/dist/esm/calendar.taro-4ed72058.js +38 -0
- package/dist/esm/calendaritem.taro-1ebe428d.js +571 -0
- package/dist/esm/card.taro-39055e82.js +32 -0
- package/dist/esm/cascader.taro-d8cb1c3e.js +397 -636
- package/dist/esm/cell.taro-9a04a92e.js +64 -0
- package/dist/esm/cellgroup.taro-e094471c.js +18 -27
- package/dist/esm/checkbox.taro-0bda9796.js +160 -232
- package/dist/esm/circleprogress.taro-47db537c.js +99 -120
- package/dist/esm/col.taro-b61c7cba.js +33 -50
- package/dist/esm/collapse.taro-af58206c.js +73 -86
- package/dist/esm/collapseitem-ce1849d2.js +75 -139
- package/dist/esm/configprovider-5eea4f5d.js +19 -0
- package/dist/esm/configprovider.taro-26882dd2.js +42 -0
- package/dist/esm/countdown.taro-9e40de9c.js +225 -0
- package/dist/esm/datepicker.taro-7220e495.js +270 -0
- package/dist/esm/dialog.taro-1c03960e.js +123 -0
- package/dist/esm/divider.taro-5236fe6a.js +27 -27
- package/dist/esm/drag.taro-82b6b27a.js +99 -138
- package/dist/esm/elevator.taro-d7d65470.js +185 -259
- package/dist/esm/ellipsis.taro-49b6db0c.js +232 -0
- package/dist/esm/empty.taro-7bd813f9.js +62 -0
- package/dist/esm/fixednav.taro-5ad15202.js +53 -0
- package/dist/esm/form.taro-71d32671.js +179 -0
- package/dist/esm/formitem.taro-3089489b.js +89 -0
- package/dist/esm/grid.taro-e6decfce.js +58 -0
- package/dist/esm/grid.taro.context-39636af9.js +4 -2
- package/dist/esm/griditem.taro-4cade72e.js +90 -0
- package/dist/esm/icon-8dc4de10.js +43 -51
- package/dist/esm/icon.taro-1d0d4fb7.js +43 -51
- package/dist/esm/image.taro-e6dc5867.js +64 -0
- package/dist/esm/imagepreview.taro-3400ea03.js +158 -205
- package/dist/esm/index.taro-a36f96fb.js +149 -210
- package/dist/esm/indicator.taro-183ea169.js +29 -43
- package/dist/esm/infiniteloading.taro-6c2a2e95.js +142 -0
- package/dist/esm/input.taro-fd566407.js +243 -0
- package/dist/esm/inputnumber.taro-dc39b853.js +129 -177
- package/dist/esm/layout.taro-358f014f.js +6 -9
- package/dist/esm/menu.taro-4abed328.js +89 -132
- package/dist/esm/menuitem.taro-6e8b27c3.js +130 -0
- package/dist/esm/navbar.taro-c931c078.js +69 -105
- package/dist/esm/noticebar.taro-69ea7673.js +450 -0
- package/dist/esm/notify.taro-308e5892.js +66 -97
- package/dist/esm/numberkeyboard.taro-194519e4.js +158 -0
- package/dist/esm/nutui-react.es.js +44 -44
- package/dist/esm/offsetContext-bfb02c25.js +3 -1
- package/dist/esm/overlay.taro-98367bc1.js +59 -74
- package/dist/esm/pagination.taro-bb490de9.js +124 -0
- package/dist/esm/picker.taro-2a8ded7c.js +420 -0
- package/dist/esm/popover.taro-46d813e8.js +132 -222
- package/dist/esm/popup.taro-cb777e09.js +125 -178
- package/dist/esm/price.taro-8801462e.js +75 -86
- package/dist/esm/progress.taro-623bc807.js +84 -118
- package/dist/esm/pulltorefresh.taro-cab7b51c.js +221 -0
- package/dist/esm/range.taro-5d6ff217.js +332 -0
- package/dist/esm/rate.taro-10197384.js +64 -111
- package/dist/esm/row.taro-37a895de.js +38 -42
- package/dist/esm/searchbar.taro-839dd622.js +148 -0
- package/dist/esm/shortpassword.taro-182d46f7.js +111 -0
- package/dist/esm/sidenavbar.taro-006cf38b.js +35 -0
- package/dist/esm/sidenavbaritem.taro-fee11d26.js +9 -22
- package/dist/esm/signature.taro-33632585.js +143 -0
- package/dist/esm/skeleton.taro-853ce460.js +51 -88
- package/dist/esm/step.taro-1c94e067.js +49 -78
- package/dist/esm/steps.taro-acf205a0.js +21 -30
- package/dist/esm/sticky.taro-d0553f48.js +13 -0
- package/dist/esm/subsidenavbar.taro-f46b4c73.js +58 -75
- package/dist/esm/swipe.taro-83bc248f.js +164 -254
- package/dist/esm/swiper.taro-852f6615.js +424 -505
- package/dist/esm/swiperitem-86a3578a.js +20 -28
- package/dist/esm/switch.taro-bae2dca0.js +43 -64
- package/dist/esm/tabbar.taro-86cece39.js +47 -57
- package/dist/esm/tabbaritem.taro-8dfb8055.js +51 -79
- package/dist/esm/table.taro-cb4dd2c3.js +92 -0
- package/dist/esm/tabpane.taro-91cd6cf4.js +17 -22
- package/dist/esm/tabs.taro-e71875fa.js +121 -165
- package/dist/esm/tag.taro-00fe554d.js +89 -0
- package/dist/esm/textarea.taro-42600f8c.js +74 -0
- package/dist/esm/timedetail.taro-c5f564fd.js +44 -0
- package/dist/esm/timepannel.taro-29f9dd86.js +22 -0
- package/dist/esm/timeselect.taro-3ecce65d.js +133 -0
- package/dist/esm/toast.taro-0804b6b4.js +99 -137
- package/dist/esm/trendarrow.taro-5a7153e4.js +63 -90
- package/dist/esm/types/src/packages/cell/cell.taro.d.ts +0 -1
- package/dist/esm/types/src/packages/noticebar/noticebar.d.ts +5 -4
- package/dist/esm/types/src/packages/noticebar/noticebar.taro.d.ts +5 -4
- package/dist/esm/types/src/packages/uploader/uploader.d.ts +1 -1
- package/dist/esm/types/src/packages/virtuallist/virtuallist.taro.d.ts +13 -2
- package/dist/esm/typings-1c5f2628.js +7 -6
- package/dist/esm/uploader.taro-f80d76d9.js +392 -0
- package/dist/esm/useClientRect-bf69d7b3.js +5 -25
- package/dist/esm/useTouch-a2ea68c6.js +63 -93
- package/dist/esm/video-8a3518c5.js +59 -83
- package/dist/esm/virtuallist.taro-e3345ced.js +215 -0
- package/dist/esm/watermark.taro-cd9db98a.js +114 -0
- package/dist/esm/zh-CN-dfc384d0.js +128 -133
- 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.es.js +634 -5664
- package/dist/nutui.react.umd.js +634 -5664
- package/dist/packages/noticebar/noticebar.scss +17 -0
- package/dist/packages/radio/radio.scss +3 -1
- package/dist/packages/row/row.scss +2 -0
- package/dist/packages/searchbar/searchbar.scss +1 -1
- package/dist/packages/tag/tag.scss +13 -5
- package/dist/packages/virtuallist/virtuallist.scss +24 -0
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/styles/temp.scss +2340 -0
- package/dist/styles/theme-dark.scss +7 -0
- package/dist/styles/theme-default.scss +11 -0
- package/dist/styles/variables.scss +1945 -710
- package/dist/types/index.d.ts +16 -23
- package/package.json +9 -4
- package/dist/esm/address.taro-1e2aea24.js +0 -615
- package/dist/esm/audio.taro-fddcdfc0.js +0 -228
- package/dist/esm/avatargroup-f7f600ff.js +0 -42
- package/dist/esm/calendar.taro-72974415.js +0 -83
- package/dist/esm/calendaritem.taro-84e889eb.js +0 -580
- package/dist/esm/card.taro-a530dfb3.js +0 -61
- package/dist/esm/cell.taro-cf50c4f2.js +0 -109
- package/dist/esm/configprovider-c7d60e20.js +0 -18
- package/dist/esm/configprovider.taro-8bdb3a28.js +0 -50
- package/dist/esm/countdown.taro-d7dc8681.js +0 -246
- package/dist/esm/datepicker.taro-7199f521.js +0 -304
- package/dist/esm/dialog.taro-f54cfbf0.js +0 -187
- package/dist/esm/ellipsis.taro-c0de6ff4.js +0 -309
- package/dist/esm/empty.taro-dbc66496.js +0 -81
- package/dist/esm/fixednav.taro-9e759320.js +0 -97
- package/dist/esm/form.taro-880014b1.js +0 -181
- package/dist/esm/formitem.taro-3695f4a7.js +0 -136
- package/dist/esm/grid.taro-c2cc12d6.js +0 -81
- package/dist/esm/griditem.taro-892153cd.js +0 -122
- package/dist/esm/image.taro-c30973d5.js +0 -105
- package/dist/esm/infiniteloading.taro-b5ddf3cc.js +0 -188
- package/dist/esm/input.taro-104130c1.js +0 -361
- package/dist/esm/menuitem.taro-216e9f7d.js +0 -193
- package/dist/esm/noticebar.taro-94002898.js +0 -368
- package/dist/esm/numberkeyboard.taro-5e8f0ddf.js +0 -245
- package/dist/esm/pagination.taro-9925ffab.js +0 -169
- package/dist/esm/picker.taro-3b5cc054.js +0 -540
- package/dist/esm/pulltorefresh.taro-f26a20dd.js +0 -302
- package/dist/esm/range.taro-c41e9b90.js +0 -469
- package/dist/esm/searchbar.taro-01ed4ea4.js +0 -236
- package/dist/esm/shortpassword.taro-3a3bf412.js +0 -190
- package/dist/esm/sidenavbar.taro-06026f31.js +0 -66
- package/dist/esm/signature.taro-17648cac.js +0 -192
- package/dist/esm/sticky.taro-36013e97.js +0 -16
- package/dist/esm/table.taro-adda6622.js +0 -139
- package/dist/esm/tag.taro-bd900990.js +0 -104
- package/dist/esm/textarea.taro-83d5fe73.js +0 -102
- package/dist/esm/timedetail.taro-105f5380.js +0 -68
- package/dist/esm/timepannel.taro-c66c63dd.js +0 -30
- package/dist/esm/timeselect.taro-fc7ec6ee.js +0 -172
- package/dist/esm/uploader.taro-a1edf38f.js +0 -529
- package/dist/esm/virtuallist.taro-4add61c3.js +0 -315
- package/dist/esm/watermark.taro-323d1cf3.js +0 -132
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import React__default, { useRef, useState, useEffect } from 'react';
|
|
2
|
+
import Taro from '@tarojs/taro';
|
|
3
|
+
import { c as cn } from './bem-893ad28d.js';
|
|
4
|
+
import { u as useConfig } from './configprovider.taro-26882dd2.js';
|
|
5
|
+
import { I as Icon } from './icon.taro-1d0d4fb7.js';
|
|
6
|
+
import { C as ComponentDefaults } from './typings-1c5f2628.js';
|
|
7
|
+
|
|
8
|
+
const defaultProps = {
|
|
9
|
+
...ComponentDefaults,
|
|
10
|
+
placeholder: '',
|
|
11
|
+
shape: 'square',
|
|
12
|
+
disabled: false,
|
|
13
|
+
maxLength: 9999,
|
|
14
|
+
clearable: true,
|
|
15
|
+
align: 'left',
|
|
16
|
+
readonly: true,
|
|
17
|
+
autoFocus: false,
|
|
18
|
+
label: '',
|
|
19
|
+
leftinIcon: React__default.createElement(Icon, { name: "search", size: "12" }),
|
|
20
|
+
};
|
|
21
|
+
const SearchBar = (props) => {
|
|
22
|
+
const searchbarBem = cn('searchbar');
|
|
23
|
+
const { locale } = useConfig();
|
|
24
|
+
const searchRef = useRef(null);
|
|
25
|
+
const [value, setValue] = useState(() => props.value);
|
|
26
|
+
const { placeholder, shape, className, disabled, maxLength, clearable, align, readOnly, autoFocus, label, actionText, leftinIcon, rightinIcon, leftoutIcon, rightoutIcon, onChange, onFocus, onBlur, onClear, onCancel, onSearch, onClickInput, onClickLeftinIcon, onClickLeftoutIcon, onClickRightinIcon, onClickRightoutIcon, iconClassPrefix, iconFontClassName, } = {
|
|
27
|
+
...defaultProps,
|
|
28
|
+
...props,
|
|
29
|
+
};
|
|
30
|
+
const alignClass = `${align}`;
|
|
31
|
+
const change = (event) => {
|
|
32
|
+
const { value } = event.target;
|
|
33
|
+
onChange && onChange?.(value, event);
|
|
34
|
+
setValue(value);
|
|
35
|
+
};
|
|
36
|
+
const focus = (event) => {
|
|
37
|
+
const { value } = event.target;
|
|
38
|
+
onFocus && onFocus?.(value, event);
|
|
39
|
+
};
|
|
40
|
+
const blur = (event) => {
|
|
41
|
+
const searchSelf = searchRef.current;
|
|
42
|
+
searchSelf && searchSelf.blur();
|
|
43
|
+
const { value } = event.target;
|
|
44
|
+
onBlur && onBlur?.(value, event);
|
|
45
|
+
};
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
setValue(props.value);
|
|
48
|
+
}, [props.value]);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (autoFocus) {
|
|
51
|
+
const searchSelf = searchRef.current;
|
|
52
|
+
searchSelf && searchSelf.focus();
|
|
53
|
+
}
|
|
54
|
+
}, [autoFocus]);
|
|
55
|
+
const renderField = () => {
|
|
56
|
+
return (React__default.createElement("input", { className: `${searchbarBem('input')} ${searchbarBem(alignClass)} ${shape === 'round' ? searchbarBem('round') : ''} ${clearable ? searchbarBem('input-clear') : ''}`, ref: searchRef, style: { ...props.style, background: props.inputBackground }, value: value || '', placeholder: placeholder || locale.placeholder, disabled: disabled, readOnly: readOnly, maxLength: maxLength, onKeyPress: onKeypress, onChange: (e) => change(e), onFocus: (e) => focus(e), onBlur: (e) => blur(e), onClick: (e) => clickInput(e) }));
|
|
57
|
+
};
|
|
58
|
+
const clickInput = (e) => {
|
|
59
|
+
onClickInput && onClickInput(e);
|
|
60
|
+
};
|
|
61
|
+
const renderLeftinIcon = () => {
|
|
62
|
+
if (!leftinIcon)
|
|
63
|
+
return null;
|
|
64
|
+
return (React__default.createElement("div", { className: `${searchbarBem('leftin-icon')} ${searchbarBem('icon')}`, onClick: (e) => clickLeftIcon('in-left', e) }, leftinIcon));
|
|
65
|
+
};
|
|
66
|
+
const renderLeftoutIcon = () => {
|
|
67
|
+
if (!leftoutIcon)
|
|
68
|
+
return null;
|
|
69
|
+
return (React__default.createElement("div", { className: `${searchbarBem('leftout-icon')}`, onClick: (e) => clickLeftIcon('out-left', e) }, leftoutIcon));
|
|
70
|
+
};
|
|
71
|
+
const clickLeftIcon = (flag, event) => {
|
|
72
|
+
if (flag === 'in-left') {
|
|
73
|
+
onClickLeftinIcon && onClickLeftinIcon(value, event);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
onClickLeftoutIcon && onClickLeftoutIcon(value, event);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const renderRightinIcon = () => {
|
|
80
|
+
if (!rightinIcon)
|
|
81
|
+
return null;
|
|
82
|
+
return (React__default.createElement("div", { className: `${searchbarBem('rightin-icon')} ${searchbarBem('icon')}`, onClick: (e) => clickRightIcon('in-right', e) }, rightinIcon));
|
|
83
|
+
};
|
|
84
|
+
const renderRightoutIcon = () => {
|
|
85
|
+
if (!rightoutIcon)
|
|
86
|
+
return null;
|
|
87
|
+
return (React__default.createElement("div", { className: `${searchbarBem('rightout-icon')}`, onClick: (e) => clickRightIcon('out-right', e) }, rightoutIcon));
|
|
88
|
+
};
|
|
89
|
+
const clickRightIcon = (flag, event) => {
|
|
90
|
+
if (flag === 'in-left') {
|
|
91
|
+
onClickRightinIcon && onClickRightinIcon(value, event);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
onClickRightoutIcon && onClickRightoutIcon(value, event);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const handleClear = () => {
|
|
98
|
+
return (React__default.createElement("div", { className: `${searchbarBem('clear')} ${rightinIcon ? 'pos-right' : ''}`, onClick: (e) => clearaVal(e) },
|
|
99
|
+
React__default.createElement(Icon, { classPrefix: iconClassPrefix, fontClassName: iconFontClassName, name: "circle-close", size: "12", color: "#555" })));
|
|
100
|
+
};
|
|
101
|
+
const clearaVal = (event) => {
|
|
102
|
+
if (disabled || readOnly) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
setValue('');
|
|
106
|
+
onClear && onClear(event);
|
|
107
|
+
};
|
|
108
|
+
const renderRightLabel = () => {
|
|
109
|
+
if (actionText) {
|
|
110
|
+
return (React__default.createElement("div", { className: searchbarBem('action-text'), onClick: search }, actionText));
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
};
|
|
114
|
+
const onKeypress = (e) => {
|
|
115
|
+
if (e.keyCode === 13) {
|
|
116
|
+
if (typeof e.cancelable !== 'boolean' || e.cancelable) {
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
}
|
|
119
|
+
onSearch && onSearch(value);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const search = () => {
|
|
123
|
+
onSearch && onSearch(value);
|
|
124
|
+
};
|
|
125
|
+
const renderLabel = () => {
|
|
126
|
+
if (label) {
|
|
127
|
+
return React__default.createElement("div", { className: searchbarBem('label') }, label);
|
|
128
|
+
}
|
|
129
|
+
return null;
|
|
130
|
+
};
|
|
131
|
+
const envClass = () => {
|
|
132
|
+
return Taro.getEnv() === 'WEB' ? 'nut-searchbar-taro' : '';
|
|
133
|
+
};
|
|
134
|
+
return (React__default.createElement("div", { className: `${searchbarBem()} ${envClass()} ${disabled ? searchbarBem('disabled') : ''} ${className || ''}`, style: { ...props.style, background: props.background } },
|
|
135
|
+
renderLeftoutIcon(),
|
|
136
|
+
renderLabel(),
|
|
137
|
+
React__default.createElement("div", { className: `${searchbarBem('content')}` },
|
|
138
|
+
renderLeftinIcon(),
|
|
139
|
+
React__default.createElement("div", { className: "nut-searchbar__input-box" }, renderField()),
|
|
140
|
+
renderRightinIcon(),
|
|
141
|
+
clearable && value && handleClear()),
|
|
142
|
+
renderRightoutIcon(),
|
|
143
|
+
renderRightLabel()));
|
|
144
|
+
};
|
|
145
|
+
SearchBar.defaultProps = defaultProps;
|
|
146
|
+
SearchBar.displayName = 'NutSearchBar';
|
|
147
|
+
|
|
148
|
+
export { SearchBar as S };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React__default, { useRef, useState, useEffect } from 'react';
|
|
2
|
+
import { c as cn } from './bem-893ad28d.js';
|
|
3
|
+
import { P as Popup } from './popup.taro-cb777e09.js';
|
|
4
|
+
import { I as Icon } from './icon.taro-1d0d4fb7.js';
|
|
5
|
+
import { u as useConfig } from './configprovider.taro-26882dd2.js';
|
|
6
|
+
import { C as ComponentDefaults } from './typings-1c5f2628.js';
|
|
7
|
+
|
|
8
|
+
const defaultProps = {
|
|
9
|
+
...ComponentDefaults,
|
|
10
|
+
title: '',
|
|
11
|
+
desc: '',
|
|
12
|
+
tips: '',
|
|
13
|
+
visible: false,
|
|
14
|
+
modelValue: '',
|
|
15
|
+
errorMsg: '',
|
|
16
|
+
noButton: true,
|
|
17
|
+
closeOnClickOverlay: true,
|
|
18
|
+
length: 6,
|
|
19
|
+
className: '',
|
|
20
|
+
onChange: (value) => { },
|
|
21
|
+
onOk: (value) => { },
|
|
22
|
+
onCancel: () => { },
|
|
23
|
+
onClose: () => { },
|
|
24
|
+
onTips: () => { },
|
|
25
|
+
onComplete: (value) => { },
|
|
26
|
+
};
|
|
27
|
+
const ShortPassword = (props) => {
|
|
28
|
+
const { locale } = useConfig();
|
|
29
|
+
const { title, desc, tips, visible, modelValue, errorMsg, noButton, closeOnClickOverlay, length, style, className, onChange, onOk, onTips, onCancel, onClose, onComplete, iconClassPrefix, iconFontClassName, ...reset } = props;
|
|
30
|
+
const b = cn('shortpassword');
|
|
31
|
+
const textInput = useRef(null);
|
|
32
|
+
const range = (val) => {
|
|
33
|
+
return Math.min(Math.max(4, val), 6);
|
|
34
|
+
};
|
|
35
|
+
const [innerVisible, setInnerVisible] = useState(visible);
|
|
36
|
+
const [comLen, setComLen] = useState(range(Number(length)));
|
|
37
|
+
const [inputValue, setInputValue] = useState('');
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
setInnerVisible(visible);
|
|
40
|
+
}, [visible]);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (typeof modelValue !== 'undefined') {
|
|
43
|
+
setInputValue(modelValue);
|
|
44
|
+
}
|
|
45
|
+
}, [modelValue]);
|
|
46
|
+
const changeValue = (e) => {
|
|
47
|
+
let inputValue = e.target.value;
|
|
48
|
+
if (String(inputValue).length > comLen) {
|
|
49
|
+
inputValue = inputValue.slice(0, comLen);
|
|
50
|
+
}
|
|
51
|
+
setInputValue(inputValue);
|
|
52
|
+
if (String(inputValue).length === comLen) {
|
|
53
|
+
onComplete && onComplete(inputValue);
|
|
54
|
+
}
|
|
55
|
+
onChange && onChange(inputValue);
|
|
56
|
+
};
|
|
57
|
+
const systemStyle = () => {
|
|
58
|
+
const u = navigator.userAgent;
|
|
59
|
+
const isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; // g
|
|
60
|
+
const isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
|
|
61
|
+
let style = {};
|
|
62
|
+
console.log(isIOS, isAndroid);
|
|
63
|
+
if (isIOS) {
|
|
64
|
+
style = {
|
|
65
|
+
paddingRight: '1200px',
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (isAndroid) {
|
|
69
|
+
style = {
|
|
70
|
+
opacity: 0,
|
|
71
|
+
zIndex: 10,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return style;
|
|
75
|
+
};
|
|
76
|
+
const focus = () => {
|
|
77
|
+
if (textInput.current) {
|
|
78
|
+
textInput.current.focus();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const sure = () => {
|
|
82
|
+
onOk && onOk(inputValue);
|
|
83
|
+
};
|
|
84
|
+
return (React__default.createElement("div", null,
|
|
85
|
+
React__default.createElement(Popup, { style: {
|
|
86
|
+
padding: '32px 24px 28px 24px',
|
|
87
|
+
borderRadius: '12px',
|
|
88
|
+
textAlign: 'center',
|
|
89
|
+
}, visible: innerVisible, closeable: true, "close-on-click-overlay": closeOnClickOverlay, onClickOverlay: onClose, onClickCloseIcon: onClose },
|
|
90
|
+
React__default.createElement("div", { className: `${b()} ${className}`, style: { ...style }, ...reset },
|
|
91
|
+
React__default.createElement("div", { className: b('title') }, title || locale.shortpassword.title),
|
|
92
|
+
React__default.createElement("div", { className: b('subtitle') }, desc || locale.shortpassword.desc),
|
|
93
|
+
React__default.createElement("div", { className: b('input') },
|
|
94
|
+
React__default.createElement("input", { ref: textInput, className: b('input-real'), type: "number", style: systemStyle(), maxLength: 6, value: inputValue, onChange: (e) => changeValue(e) }),
|
|
95
|
+
React__default.createElement("div", { className: b('input-site') }),
|
|
96
|
+
React__default.createElement("div", { className: b('input-fake'), onClick: () => focus() }, [...new Array(comLen).keys()].map((item, index) => {
|
|
97
|
+
return (React__default.createElement("div", { className: b('input-fake__li'), key: index }, String(inputValue).length > index ? (React__default.createElement("div", { className: b('input-fake__li__icon') })) : null));
|
|
98
|
+
}))),
|
|
99
|
+
React__default.createElement("div", { className: b('message') },
|
|
100
|
+
React__default.createElement("div", { className: b('message__error') }, errorMsg),
|
|
101
|
+
tips || locale.shortpassword.tips ? (React__default.createElement("div", { className: b('message__forget') },
|
|
102
|
+
React__default.createElement(Icon, { classPrefix: iconClassPrefix, fontClassName: iconFontClassName, className: "icon", size: "11px", name: "tips" }),
|
|
103
|
+
React__default.createElement("div", { onClick: onTips }, tips || locale.shortpassword.tips))) : null),
|
|
104
|
+
!noButton ? (React__default.createElement("div", { className: b('footer') },
|
|
105
|
+
React__default.createElement("div", { className: b('footer__cancel'), onClick: onCancel }, locale.cancel),
|
|
106
|
+
React__default.createElement("div", { className: b('footer__sure'), onClick: () => sure() }, locale.confirm))) : null))));
|
|
107
|
+
};
|
|
108
|
+
ShortPassword.defaultProps = defaultProps;
|
|
109
|
+
ShortPassword.displayName = 'NutShortPassword';
|
|
110
|
+
|
|
111
|
+
export { ShortPassword as S };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React__default, { useState } from 'react';
|
|
2
|
+
import { u as useConfig } from './configprovider.taro-26882dd2.js';
|
|
3
|
+
import { P as Popup } from './popup.taro-cb777e09.js';
|
|
4
|
+
import { O as OffsetContext } from './offsetContext-bfb02c25.js';
|
|
5
|
+
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
showhead: false,
|
|
8
|
+
position: 'left',
|
|
9
|
+
width: '80%',
|
|
10
|
+
};
|
|
11
|
+
const SideNavBar = (props) => {
|
|
12
|
+
useConfig();
|
|
13
|
+
const { title, visible, width, position, children, className, showhead, onClose, ...rest } = {
|
|
14
|
+
...defaultProps,
|
|
15
|
+
...props,
|
|
16
|
+
};
|
|
17
|
+
const offset = props.offset ? Number(props.offset) : 20;
|
|
18
|
+
const [sidenavbarShow, setSidenavbarShow] = useState(true);
|
|
19
|
+
const handleClick = () => {
|
|
20
|
+
setSidenavbarShow(!sidenavbarShow);
|
|
21
|
+
};
|
|
22
|
+
return (React__default.createElement(Popup, { visible: visible, style: { width, height: '100%' }, position: position, onClose: onClose },
|
|
23
|
+
React__default.createElement("div", { className: className ? `${className} nut-sidenavbar` : 'nut-sidenavbar', ...rest },
|
|
24
|
+
React__default.createElement("div", { className: "nut-sidenavbar__content" },
|
|
25
|
+
React__default.createElement("div", { className: `nut-sidenavbar__list ${sidenavbarShow ? 'nutShow' : 'nutHide'}`, onClick: handleClick },
|
|
26
|
+
React__default.createElement("div", { className: "nut-sidenavbar__title border-bt ", style: { paddingLeft: `${offset}px` } },
|
|
27
|
+
title,
|
|
28
|
+
React__default.createElement("i", { className: `arrow-icon ${sidenavbarShow ? 'arrow-up' : 'arrow-down'}` })),
|
|
29
|
+
React__default.createElement(OffsetContext.Provider, { value: offset },
|
|
30
|
+
React__default.createElement("div", { className: "nut-sidenavbar__content" }, children)))))));
|
|
31
|
+
};
|
|
32
|
+
SideNavBar.defaultProps = defaultProps;
|
|
33
|
+
SideNavBar.displayName = 'NutSideNavBar';
|
|
34
|
+
|
|
35
|
+
export { SideNavBar as S };
|
|
@@ -1,25 +1,12 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["title", "ikey", "children", "onClick"];
|
|
4
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
1
|
import React__default from 'react';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
ikey = props
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
onClick && onClick({
|
|
16
|
-
title: title,
|
|
17
|
-
ikey: ikey
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
return React__default.createElement("div", _objectSpread({
|
|
21
|
-
className: "nut-subsidenavbar__item border-bt",
|
|
22
|
-
onClick: clickFn
|
|
23
|
-
}, rest), title);
|
|
2
|
+
|
|
3
|
+
const SideNavBarItem = (props) => {
|
|
4
|
+
const { title, ikey, children, onClick, ...rest } = props;
|
|
5
|
+
const clickFn = (e) => {
|
|
6
|
+
e.stopPropagation();
|
|
7
|
+
onClick && onClick({ title, ikey });
|
|
8
|
+
};
|
|
9
|
+
return (React__default.createElement("div", { className: "nut-subsidenavbar__item border-bt", onClick: clickFn, ...rest }, title));
|
|
24
10
|
};
|
|
11
|
+
|
|
25
12
|
export { SideNavBarItem as S };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import React__default, { useRef, useState, useEffect } from 'react';
|
|
2
|
+
import Taro from '@tarojs/taro';
|
|
3
|
+
import { B as Button } from './button.taro-4ce133b9.js';
|
|
4
|
+
import { c as cn } from './bem-893ad28d.js';
|
|
5
|
+
import { u as useConfig } from './configprovider.taro-26882dd2.js';
|
|
6
|
+
|
|
7
|
+
/* eslint-disable react/no-unknown-property */
|
|
8
|
+
const defaultProps = {
|
|
9
|
+
canvasId: 'spcanvas',
|
|
10
|
+
type: 'png',
|
|
11
|
+
lineWidth: 2,
|
|
12
|
+
strokeStyle: '#000',
|
|
13
|
+
className: '',
|
|
14
|
+
};
|
|
15
|
+
const Signature = (props) => {
|
|
16
|
+
const { locale } = useConfig();
|
|
17
|
+
const { canvasId, type, lineWidth, strokeStyle, unSupportTpl, className, confirm, clear, onConfirm, onClear, ...rest } = {
|
|
18
|
+
...defaultProps,
|
|
19
|
+
...props,
|
|
20
|
+
};
|
|
21
|
+
const b = cn('signature');
|
|
22
|
+
const canvasRef = useRef(null);
|
|
23
|
+
const wrapRef = useRef(null);
|
|
24
|
+
const [canvasHeight, setCanvasHeight] = useState(0);
|
|
25
|
+
const [canvasWidth, setCanvasWidth] = useState(0);
|
|
26
|
+
const ctx = useRef(null);
|
|
27
|
+
const [disalbeScroll] = useState('true');
|
|
28
|
+
const startEventHandler = (event) => {
|
|
29
|
+
if (ctx.current) {
|
|
30
|
+
ctx.current.beginPath();
|
|
31
|
+
ctx.current.lineWidth = lineWidth;
|
|
32
|
+
ctx.current.strokeStyle = strokeStyle;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const moveEventHandler = (event) => {
|
|
36
|
+
if (ctx.current) {
|
|
37
|
+
const evt = event.changedTouches[0];
|
|
38
|
+
let mouseX = evt.x || evt.clientX;
|
|
39
|
+
let mouseY = evt.y || evt.clientY;
|
|
40
|
+
if (Taro.getEnv() === 'WEB' && canvasRef.current) {
|
|
41
|
+
const coverPos = canvasRef.current.getBoundingClientRect();
|
|
42
|
+
mouseX = evt.clientX - coverPos.left;
|
|
43
|
+
mouseY = evt.clientY - coverPos.top;
|
|
44
|
+
}
|
|
45
|
+
Taro.nextTick(() => {
|
|
46
|
+
// ctx.current.lineCap = 'round'
|
|
47
|
+
// ctx.current.lineJoin = 'round'
|
|
48
|
+
ctx.current?.lineTo(mouseX, mouseY);
|
|
49
|
+
ctx.current?.stroke();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const endEventHandler = (event) => { };
|
|
54
|
+
const handleClearBtn = () => {
|
|
55
|
+
if (ctx.current) {
|
|
56
|
+
ctx.current.clearRect(0, 0, canvasWidth, canvasHeight);
|
|
57
|
+
ctx.current.closePath();
|
|
58
|
+
}
|
|
59
|
+
clear && clear();
|
|
60
|
+
onClear && onClear();
|
|
61
|
+
};
|
|
62
|
+
const handleConfirmBtn = () => {
|
|
63
|
+
onSave();
|
|
64
|
+
};
|
|
65
|
+
const onSave = () => {
|
|
66
|
+
Taro.createSelectorQuery()
|
|
67
|
+
.select(`#${canvasId}`)
|
|
68
|
+
.fields({
|
|
69
|
+
node: true,
|
|
70
|
+
size: true,
|
|
71
|
+
})
|
|
72
|
+
.exec((res) => {
|
|
73
|
+
Taro.canvasToTempFilePath({
|
|
74
|
+
canvas: res[0].node,
|
|
75
|
+
fileType: props.type,
|
|
76
|
+
canvasId: `${canvasId}`,
|
|
77
|
+
success: (res) => {
|
|
78
|
+
handleClearBtn();
|
|
79
|
+
confirm && confirm(res.tempFilePath);
|
|
80
|
+
onConfirm && onConfirm(res.tempFilePath);
|
|
81
|
+
},
|
|
82
|
+
fail: (res) => {
|
|
83
|
+
console.log('保存失败');
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
const canvasSetting = (canvasDom, width, height) => {
|
|
89
|
+
const canvas = canvasDom;
|
|
90
|
+
canvas.current = canvas;
|
|
91
|
+
ctx.current = canvas.getContext('2d');
|
|
92
|
+
setCanvasWidth(width);
|
|
93
|
+
setCanvasHeight(height);
|
|
94
|
+
canvas.width = width;
|
|
95
|
+
canvas.height = height;
|
|
96
|
+
if (ctx.current) {
|
|
97
|
+
ctx.current.clearRect(0, 0, width, height);
|
|
98
|
+
ctx.current.beginPath();
|
|
99
|
+
ctx.current.lineWidth = lineWidth;
|
|
100
|
+
ctx.current.strokeStyle = strokeStyle;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const initCanvas = () => {
|
|
104
|
+
Taro.nextTick(() => {
|
|
105
|
+
setTimeout(() => {
|
|
106
|
+
if (Taro.getEnv() === 'WEAPP' || Taro.getEnv() === 'JD') {
|
|
107
|
+
Taro.createSelectorQuery()
|
|
108
|
+
.select(`#${canvasId}`)
|
|
109
|
+
.fields({
|
|
110
|
+
node: true,
|
|
111
|
+
size: true,
|
|
112
|
+
}, (res) => {
|
|
113
|
+
const { node, width, height } = res;
|
|
114
|
+
canvasSetting(node, width, height);
|
|
115
|
+
})
|
|
116
|
+
.exec();
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
const canvasDom = document.getElementById(`${canvasId}`);
|
|
120
|
+
let canvas = canvasDom;
|
|
121
|
+
if (canvasDom?.tagName !== 'CANVAS') {
|
|
122
|
+
canvas = canvasDom?.getElementsByTagName('canvas')[0];
|
|
123
|
+
}
|
|
124
|
+
canvasSetting(canvas, canvasDom?.offsetWidth, canvasDom?.offsetHeight);
|
|
125
|
+
}
|
|
126
|
+
}, 1000);
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
initCanvas();
|
|
131
|
+
}, []);
|
|
132
|
+
return (React__default.createElement("div", { className: `${b()} ${className}`, ...rest },
|
|
133
|
+
React__default.createElement("div", { className: `${b('inner')} spcanvas_WEAPP`, ref: wrapRef }, Taro.getEnv() === 'WEAPP' || Taro.getEnv() === 'JD' ? (React__default.createElement("canvas", { id: canvasId, ref: canvasRef,
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
135
|
+
// @ts-ignore
|
|
136
|
+
canvasId: canvasId, disalbeScroll: true, type: "2d", onTouchStart: startEventHandler, onTouchMove: moveEventHandler, onTouchEnd: endEventHandler })) : (React__default.createElement("canvas", { id: canvasId, ref: canvasRef, "canvas-id": canvasId, "disalbe-scroll": disalbeScroll, onTouchStart: startEventHandler, onTouchMove: moveEventHandler, onTouchEnd: endEventHandler, onTouchCancel: endEventHandler }))),
|
|
137
|
+
React__default.createElement(Button, { className: `${b('btn')}`, type: "default", onClick: () => handleClearBtn() }, locale.signature.reSign),
|
|
138
|
+
React__default.createElement(Button, { className: `${b('btn')}`, type: "primary", onClick: () => handleConfirmBtn() }, locale.confirm)));
|
|
139
|
+
};
|
|
140
|
+
Signature.defaultProps = defaultProps;
|
|
141
|
+
Signature.displayName = 'NutSignature';
|
|
142
|
+
|
|
143
|
+
export { Signature as S };
|
|
@@ -1,99 +1,62 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["className", "width", "height", "animated", "row", "title", "avatar", "avatarSize", "round", "loading", "children", "avatarShape"];
|
|
4
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
1
|
import React__default from 'react';
|
|
7
2
|
import classNames from 'classnames';
|
|
8
3
|
import { A as Avatar } from './avatar.taro-85ced995.js';
|
|
9
4
|
import { c as cn } from './bem-893ad28d.js';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
width: '100px',
|
|
8
|
+
height: '100px',
|
|
9
|
+
row: 1,
|
|
10
|
+
animated: false,
|
|
11
|
+
title: false,
|
|
12
|
+
avatar: false,
|
|
13
|
+
round: false,
|
|
14
|
+
avatarSize: '50px',
|
|
15
|
+
loading: false,
|
|
16
|
+
avatarShape: 'round',
|
|
21
17
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
height = _defaultProps$props.height,
|
|
27
|
-
animated = _defaultProps$props.animated,
|
|
28
|
-
row = _defaultProps$props.row,
|
|
29
|
-
title = _defaultProps$props.title,
|
|
30
|
-
avatar = _defaultProps$props.avatar,
|
|
31
|
-
avatarSize = _defaultProps$props.avatarSize,
|
|
32
|
-
round = _defaultProps$props.round,
|
|
33
|
-
loading = _defaultProps$props.loading,
|
|
34
|
-
children = _defaultProps$props.children,
|
|
35
|
-
avatarShape = _defaultProps$props.avatarShape,
|
|
36
|
-
restProps = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
37
|
-
var b = cn('skeleton');
|
|
38
|
-
var classes = classNames(className, b());
|
|
39
|
-
var blockClass = classNames({
|
|
40
|
-
blockClass: true,
|
|
41
|
-
'blockClass--round': round
|
|
42
|
-
});
|
|
43
|
-
var avatarClass = classNames(_defineProperty({
|
|
44
|
-
avatarClass: true
|
|
45
|
-
}, "avatarClass--".concat(avatarShape), avatarShape));
|
|
46
|
-
var repeatLines = function repeatLines(num) {
|
|
47
|
-
return Array.from({
|
|
48
|
-
length: num
|
|
49
|
-
}, function (v, i) {
|
|
50
|
-
return i;
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
var getStyle = function getStyle() {
|
|
54
|
-
if (avatarSize) {
|
|
55
|
-
return {
|
|
56
|
-
width: avatarSize,
|
|
57
|
-
height: avatarSize
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
width: '50px',
|
|
62
|
-
height: '50px'
|
|
18
|
+
const Skeleton = (props) => {
|
|
19
|
+
const { className, width, height, animated, row, title, avatar, avatarSize, round, loading, children, avatarShape, ...restProps } = {
|
|
20
|
+
...defaultProps,
|
|
21
|
+
...props,
|
|
63
22
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
bgColor: "rgb(239, 239, 239)",
|
|
74
|
-
shape: avatarShape,
|
|
75
|
-
style: getStyle()
|
|
76
|
-
}), row === 1 && React__default.createElement("div", {
|
|
77
|
-
className: blockClass,
|
|
78
|
-
style: {
|
|
79
|
-
width: width,
|
|
80
|
-
height: height
|
|
81
|
-
}
|
|
82
|
-
}), React__default.createElement("div", {
|
|
83
|
-
className: "skeleton-content-line"
|
|
84
|
-
}, title && React__default.createElement("div", {
|
|
85
|
-
className: "skeleton-title"
|
|
86
|
-
}), repeatLines(row).map(function (item, index) {
|
|
87
|
-
return React__default.createElement("div", {
|
|
88
|
-
className: blockClass,
|
|
89
|
-
key: index,
|
|
90
|
-
style: {
|
|
91
|
-
width: width,
|
|
92
|
-
height: height
|
|
93
|
-
}
|
|
23
|
+
const b = cn('skeleton');
|
|
24
|
+
const classes = classNames(className, b());
|
|
25
|
+
const blockClass = classNames({
|
|
26
|
+
blockClass: true,
|
|
27
|
+
'blockClass--round': round,
|
|
28
|
+
});
|
|
29
|
+
const avatarClass = classNames({
|
|
30
|
+
avatarClass: true,
|
|
31
|
+
[`avatarClass--${avatarShape}`]: avatarShape,
|
|
94
32
|
});
|
|
95
|
-
|
|
33
|
+
const repeatLines = (num) => {
|
|
34
|
+
return Array.from({ length: num }, (v, i) => i);
|
|
35
|
+
};
|
|
36
|
+
const getStyle = () => {
|
|
37
|
+
if (avatarSize) {
|
|
38
|
+
return {
|
|
39
|
+
width: avatarSize,
|
|
40
|
+
height: avatarSize,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
width: '50px',
|
|
45
|
+
height: '50px',
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
return (React__default.createElement(React__default.Fragment, null, loading ? (React__default.createElement("div", null, children)) : (React__default.createElement("div", { className: classes, ...restProps },
|
|
49
|
+
animated && React__default.createElement("div", { className: "skeleton-animation" }),
|
|
50
|
+
React__default.createElement("div", { className: "nut-skeleton-content" },
|
|
51
|
+
avatar && (React__default.createElement(Avatar, { className: avatarClass, bgColor: "rgb(239, 239, 239)", shape: avatarShape, style: getStyle() })),
|
|
52
|
+
row === 1 && (React__default.createElement("div", { className: blockClass, style: { width, height } })),
|
|
53
|
+
React__default.createElement("div", { className: "skeleton-content-line" },
|
|
54
|
+
title && React__default.createElement("div", { className: "skeleton-title" }),
|
|
55
|
+
repeatLines(row).map((item, index) => {
|
|
56
|
+
return (React__default.createElement("div", { className: blockClass, key: index, style: { width, height } }));
|
|
57
|
+
})))))));
|
|
96
58
|
};
|
|
97
59
|
Skeleton.defaultProps = defaultProps;
|
|
98
60
|
Skeleton.displayName = 'NutSkeleton';
|
|
61
|
+
|
|
99
62
|
export { Skeleton as S };
|