@nutui/nutui-react-taro 1.4.4 → 1.4.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 +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
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
-
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; }
|
|
6
|
-
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; }
|
|
7
|
-
import React__default, { useState, useRef, useLayoutEffect } from 'react';
|
|
8
|
-
import Taro from '@tarojs/taro';
|
|
9
|
-
import { u as useConfig } from './configprovider.taro-8bdb3a28.js';
|
|
10
|
-
import { g as getRectByTaro } from './useClientRect-bf69d7b3.js';
|
|
11
|
-
var defaultProps = {
|
|
12
|
-
content: '',
|
|
13
|
-
direction: 'end',
|
|
14
|
-
rows: 1,
|
|
15
|
-
expandText: '',
|
|
16
|
-
collapseText: '',
|
|
17
|
-
symbol: '...',
|
|
18
|
-
lineHeight: '20'
|
|
19
|
-
};
|
|
20
|
-
var Ellipsis = function Ellipsis(props) {
|
|
21
|
-
var _ellipsis$current9, _ellipsis$current10, _ellipsis$current11, _ellipsis$current12;
|
|
22
|
-
useConfig();
|
|
23
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
24
|
-
children = _defaultProps$props.children,
|
|
25
|
-
content = _defaultProps$props.content,
|
|
26
|
-
direction = _defaultProps$props.direction,
|
|
27
|
-
rows = _defaultProps$props.rows,
|
|
28
|
-
expandText = _defaultProps$props.expandText,
|
|
29
|
-
collapseText = _defaultProps$props.collapseText,
|
|
30
|
-
symbol = _defaultProps$props.symbol,
|
|
31
|
-
lineHeight = _defaultProps$props.lineHeight,
|
|
32
|
-
onClick = _defaultProps$props.onClick,
|
|
33
|
-
onChange = _defaultProps$props.onChange;
|
|
34
|
-
var maxHeight = 0; // 当行的最大高度
|
|
35
|
-
var _useState = useState(false),
|
|
36
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
37
|
-
exceeded = _useState2[0],
|
|
38
|
-
setExceeded = _useState2[1];
|
|
39
|
-
var _useState3 = useState(false),
|
|
40
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
41
|
-
expanded = _useState4[0],
|
|
42
|
-
setExpanded = _useState4[1];
|
|
43
|
-
var ellipsis = useRef({
|
|
44
|
-
leading: '',
|
|
45
|
-
tailing: ''
|
|
46
|
-
});
|
|
47
|
-
var root = useRef(null);
|
|
48
|
-
var rootContain = useRef(null);
|
|
49
|
-
var symbolContain = useRef(null);
|
|
50
|
-
var contantCopy = useRef(content);
|
|
51
|
-
var lineH = 0; // 当行的最大高度
|
|
52
|
-
var originHeight = 0; // 原始高度
|
|
53
|
-
var refRandomId = Math.random().toString(36).slice(-8);
|
|
54
|
-
var widthRef = useRef('auto');
|
|
55
|
-
var widthBase = [14, 10, 7, 8.4, 10]; // 中、英(大)、英(小)、数字、其他字符的基础宽度
|
|
56
|
-
var symbolTextWidth = widthBase[0] * 0.7921;
|
|
57
|
-
var chineseReg = /^[\u4e00-\u9fa5]+$/; // 汉字
|
|
58
|
-
var digitReg = /^[0-9]+$/; // 数字
|
|
59
|
-
var letterUpperReg = /^[A-Z]+$/; // 字母
|
|
60
|
-
var letterLowerReg = /^[a-z]+$/; // 字母
|
|
61
|
-
useLayoutEffect(function () {
|
|
62
|
-
setTimeout(function () {
|
|
63
|
-
getSymbolInfo();
|
|
64
|
-
getReference();
|
|
65
|
-
}, 100);
|
|
66
|
-
}, []);
|
|
67
|
-
// 获取省略号宽度
|
|
68
|
-
var getSymbolInfo = /*#__PURE__*/function () {
|
|
69
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
70
|
-
var refe;
|
|
71
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
72
|
-
while (1) {
|
|
73
|
-
switch (_context.prev = _context.next) {
|
|
74
|
-
case 0:
|
|
75
|
-
_context.next = 2;
|
|
76
|
-
return getRectByTaro(symbolContain === null || symbolContain === void 0 ? void 0 : symbolContain.current);
|
|
77
|
-
case 2:
|
|
78
|
-
refe = _context.sent;
|
|
79
|
-
symbolTextWidth = refe.width ? Math.ceil(refe.width) : Math.ceil(widthBase[0] * 0.7921);
|
|
80
|
-
case 4:
|
|
81
|
-
case "end":
|
|
82
|
-
return _context.stop();
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}, _callee);
|
|
86
|
-
}));
|
|
87
|
-
return function getSymbolInfo() {
|
|
88
|
-
return _ref.apply(this, arguments);
|
|
89
|
-
};
|
|
90
|
-
}();
|
|
91
|
-
var symbolText = function symbolText() {
|
|
92
|
-
if (direction === 'end' || direction === 'middle') {
|
|
93
|
-
return "".concat(symbol).concat(expandText);
|
|
94
|
-
}
|
|
95
|
-
return "".concat(symbol).concat(expandText).concat(symbol);
|
|
96
|
-
};
|
|
97
|
-
var getReference = /*#__PURE__*/function () {
|
|
98
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
99
|
-
var element, query;
|
|
100
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
101
|
-
while (1) {
|
|
102
|
-
switch (_context2.prev = _context2.next) {
|
|
103
|
-
case 0:
|
|
104
|
-
element = root.current;
|
|
105
|
-
query = Taro.createSelectorQuery();
|
|
106
|
-
query.select("#".concat(element.id)) && query.select("#".concat(element.id)).fields({
|
|
107
|
-
computedStyle: ['width', 'height', 'lineHeight', 'paddingTop', 'paddingBottom', 'fontSize']
|
|
108
|
-
}, function (res) {
|
|
109
|
-
lineH = pxToNumber(res.lineHeight === 'normal' ? lineHeight : res.lineHeight);
|
|
110
|
-
maxHeight = Math.floor(lineH * (Number(rows) + 0.5) + pxToNumber(res.paddingTop) + pxToNumber(res.paddingBottom));
|
|
111
|
-
originHeight = pxToNumber(res.height);
|
|
112
|
-
widthRef.current = res.width;
|
|
113
|
-
// 设置基础字符
|
|
114
|
-
var bsize = pxToNumber(res.fontSize);
|
|
115
|
-
widthBase = [bsize, bsize * 0.72, bsize * 0.53, bsize * 0.4, bsize * 0.75];
|
|
116
|
-
calcEllipse();
|
|
117
|
-
}).exec();
|
|
118
|
-
case 3:
|
|
119
|
-
case "end":
|
|
120
|
-
return _context2.stop();
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}, _callee2);
|
|
124
|
-
}));
|
|
125
|
-
return function getReference() {
|
|
126
|
-
return _ref2.apply(this, arguments);
|
|
127
|
-
};
|
|
128
|
-
}();
|
|
129
|
-
// 计算省略号的位置
|
|
130
|
-
var calcEllipse = /*#__PURE__*/function () {
|
|
131
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
132
|
-
var refe, rowNum, end, _end, start;
|
|
133
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
134
|
-
while (1) {
|
|
135
|
-
switch (_context3.prev = _context3.next) {
|
|
136
|
-
case 0:
|
|
137
|
-
_context3.next = 2;
|
|
138
|
-
return getRectByTaro(rootContain.current);
|
|
139
|
-
case 2:
|
|
140
|
-
refe = _context3.sent;
|
|
141
|
-
if (refe.height <= maxHeight) {
|
|
142
|
-
setExceeded(false);
|
|
143
|
-
} else {
|
|
144
|
-
rowNum = Math.floor(content.length / (originHeight / lineH - 1)); // 每行的字数
|
|
145
|
-
if (direction === 'middle') {
|
|
146
|
-
end = content.length;
|
|
147
|
-
ellipsis.current.leading = tailorContent(0, rowNum * (Number(rows) + 0.5), 'end');
|
|
148
|
-
ellipsis.current.tailing = tailorContent(content.length - rowNum * (Number(rows) + 0.5), end, 'start');
|
|
149
|
-
} else if (direction === 'end') {
|
|
150
|
-
_end = rowNum * (Number(rows) + 0.5);
|
|
151
|
-
ellipsis.current.leading = tailorContent(0, _end);
|
|
152
|
-
} else {
|
|
153
|
-
start = content.length - rowNum * (Number(rows) + 0.5) - 5;
|
|
154
|
-
ellipsis.current.tailing = tailorContent(start, content.length);
|
|
155
|
-
}
|
|
156
|
-
// 进行兜底判断,是否符合要求
|
|
157
|
-
assignContent();
|
|
158
|
-
setTimeout(function () {
|
|
159
|
-
verifyEllipsis();
|
|
160
|
-
}, 100);
|
|
161
|
-
}
|
|
162
|
-
case 4:
|
|
163
|
-
case "end":
|
|
164
|
-
return _context3.stop();
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}, _callee3);
|
|
168
|
-
}));
|
|
169
|
-
return function calcEllipse() {
|
|
170
|
-
return _ref3.apply(this, arguments);
|
|
171
|
-
};
|
|
172
|
-
}();
|
|
173
|
-
// 验证省略号
|
|
174
|
-
var verifyEllipsis = /*#__PURE__*/function () {
|
|
175
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
176
|
-
var refe, _ellipsis$current, _ellipsis$current$lea, _ellipsis$current2, _ellipsis$current3, _ellipsis$current3$ta, _ellipsis$current4;
|
|
177
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
178
|
-
while (1) {
|
|
179
|
-
switch (_context4.prev = _context4.next) {
|
|
180
|
-
case 0:
|
|
181
|
-
_context4.next = 2;
|
|
182
|
-
return getRectByTaro(rootContain.current);
|
|
183
|
-
case 2:
|
|
184
|
-
refe = _context4.sent;
|
|
185
|
-
if (refe && refe.height && refe.height > maxHeight) {
|
|
186
|
-
if (direction === 'end') {
|
|
187
|
-
ellipsis.current.leading = (_ellipsis$current = ellipsis.current) === null || _ellipsis$current === void 0 ? void 0 : (_ellipsis$current$lea = _ellipsis$current.leading) === null || _ellipsis$current$lea === void 0 ? void 0 : _ellipsis$current$lea.slice(0, ((_ellipsis$current2 = ellipsis.current) === null || _ellipsis$current2 === void 0 ? void 0 : _ellipsis$current2.leading.length) - 1);
|
|
188
|
-
} else {
|
|
189
|
-
ellipsis.current.tailing = (_ellipsis$current3 = ellipsis.current) === null || _ellipsis$current3 === void 0 ? void 0 : (_ellipsis$current3$ta = _ellipsis$current3.tailing) === null || _ellipsis$current3$ta === void 0 ? void 0 : _ellipsis$current3$ta.slice(1, (_ellipsis$current4 = ellipsis.current) === null || _ellipsis$current4 === void 0 ? void 0 : _ellipsis$current4.tailing.length);
|
|
190
|
-
}
|
|
191
|
-
assignContent();
|
|
192
|
-
setTimeout(function () {
|
|
193
|
-
verifyEllipsis();
|
|
194
|
-
}, 100);
|
|
195
|
-
}
|
|
196
|
-
case 4:
|
|
197
|
-
case "end":
|
|
198
|
-
return _context4.stop();
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}, _callee4);
|
|
202
|
-
}));
|
|
203
|
-
return function verifyEllipsis() {
|
|
204
|
-
return _ref4.apply(this, arguments);
|
|
205
|
-
};
|
|
206
|
-
}();
|
|
207
|
-
var assignContent = function assignContent() {
|
|
208
|
-
var _ellipsis$current5, _ellipsis$current6, _ellipsis$current7, _ellipsis$current8;
|
|
209
|
-
contantCopy.current = "".concat(((_ellipsis$current5 = ellipsis.current) === null || _ellipsis$current5 === void 0 ? void 0 : _ellipsis$current5.leading) || '').concat((_ellipsis$current6 = ellipsis.current) !== null && _ellipsis$current6 !== void 0 && _ellipsis$current6.leading ? symbol : '').concat(expandText || '').concat((_ellipsis$current7 = ellipsis.current) !== null && _ellipsis$current7 !== void 0 && _ellipsis$current7.tailing ? symbol : '').concat(((_ellipsis$current8 = ellipsis.current) === null || _ellipsis$current8 === void 0 ? void 0 : _ellipsis$current8.tailing) || '');
|
|
210
|
-
};
|
|
211
|
-
// 计算省略号
|
|
212
|
-
var tailorContent = function tailorContent(left, right) {
|
|
213
|
-
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
214
|
-
var threeDotWidth = symbolTextWidth;
|
|
215
|
-
var direc = direction === 'middle' && type ? type : direction;
|
|
216
|
-
setExceeded(true);
|
|
217
|
-
var widthPart = -1;
|
|
218
|
-
var start = left;
|
|
219
|
-
var end = right;
|
|
220
|
-
var cutoff = 0;
|
|
221
|
-
var marking = 0;
|
|
222
|
-
if (direc === 'end') {
|
|
223
|
-
marking = start;
|
|
224
|
-
cutoff = end;
|
|
225
|
-
} else {
|
|
226
|
-
marking = end;
|
|
227
|
-
cutoff = start;
|
|
228
|
-
}
|
|
229
|
-
var contentWidth = pxToNumber(widthRef.current) * Number(rows) - threeDotWidth;
|
|
230
|
-
var contentPartWidth = direction === 'middle' ? contentWidth / 2 : contentWidth;
|
|
231
|
-
while (widthPart < contentPartWidth) {
|
|
232
|
-
var zi = content[marking];
|
|
233
|
-
if (chineseReg.test(zi)) {
|
|
234
|
-
widthPart = Number(widthPart + widthBase[0]);
|
|
235
|
-
} else if (letterUpperReg.test(zi)) {
|
|
236
|
-
widthPart = Number(widthPart + widthBase[1]);
|
|
237
|
-
} else if (letterLowerReg.test(zi)) {
|
|
238
|
-
widthPart = Number(widthPart + widthBase[2]);
|
|
239
|
-
} else if (digitReg.test(zi)) {
|
|
240
|
-
widthPart = Number(widthPart + widthBase[3]);
|
|
241
|
-
} else {
|
|
242
|
-
widthPart = Number(widthPart + widthBase[4]);
|
|
243
|
-
}
|
|
244
|
-
cutoff = marking;
|
|
245
|
-
direc === 'end' ? marking++ : marking--;
|
|
246
|
-
}
|
|
247
|
-
if (direc === 'end') {
|
|
248
|
-
return content.slice(0, cutoff);
|
|
249
|
-
}
|
|
250
|
-
return content.slice(cutoff, end);
|
|
251
|
-
};
|
|
252
|
-
var pxToNumber = function pxToNumber(value) {
|
|
253
|
-
if (!value) return 0;
|
|
254
|
-
var match = value.match(/^\d*(\.\d*)?/);
|
|
255
|
-
return match ? Number(match[0]) : 0;
|
|
256
|
-
};
|
|
257
|
-
// 展开收起
|
|
258
|
-
var clickHandle = function clickHandle(type) {
|
|
259
|
-
if (type === 1) {
|
|
260
|
-
setExpanded(true);
|
|
261
|
-
onChange && onChange('expand');
|
|
262
|
-
// emit('change', 'expand')
|
|
263
|
-
} else {
|
|
264
|
-
setExpanded(false);
|
|
265
|
-
onChange && onChange('collapse');
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
// 文本点击
|
|
269
|
-
var handleClick = function handleClick() {
|
|
270
|
-
onClick && onClick();
|
|
271
|
-
};
|
|
272
|
-
return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
273
|
-
className: "nut-ellipsis",
|
|
274
|
-
onClick: handleClick,
|
|
275
|
-
ref: root,
|
|
276
|
-
id: "root".concat(refRandomId)
|
|
277
|
-
}, React__default.createElement("div", null, !exceeded ? React__default.createElement("div", {
|
|
278
|
-
className: "nut-ellipsis-wordbreak"
|
|
279
|
-
}, content) : null, exceeded && !expanded ? React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
280
|
-
className: "nut-ellipsis-wordbreak"
|
|
281
|
-
}, (_ellipsis$current9 = ellipsis.current) === null || _ellipsis$current9 === void 0 ? void 0 : _ellipsis$current9.leading, ((_ellipsis$current10 = ellipsis.current) === null || _ellipsis$current10 === void 0 ? void 0 : _ellipsis$current10.leading) && symbol, expandText ? React__default.createElement("span", {
|
|
282
|
-
className: "nut-ellipsis-text",
|
|
283
|
-
onClick: function onClick() {
|
|
284
|
-
clickHandle(1);
|
|
285
|
-
}
|
|
286
|
-
}, expandText) : null, ((_ellipsis$current11 = ellipsis.current) === null || _ellipsis$current11 === void 0 ? void 0 : _ellipsis$current11.tailing) && symbol, (_ellipsis$current12 = ellipsis.current) === null || _ellipsis$current12 === void 0 ? void 0 : _ellipsis$current12.tailing)) : null, exceeded && expanded ? React__default.createElement(React__default.Fragment, null, content, expandText ? React__default.createElement("span", {
|
|
287
|
-
className: "nut-ellipsis-text",
|
|
288
|
-
onClick: function onClick() {
|
|
289
|
-
clickHandle(2);
|
|
290
|
-
}
|
|
291
|
-
}, collapseText) : null) : null)), React__default.createElement("div", {
|
|
292
|
-
className: "nut-ellipsis-copy",
|
|
293
|
-
ref: rootContain,
|
|
294
|
-
id: "rootContain".concat(refRandomId),
|
|
295
|
-
style: {
|
|
296
|
-
width: "".concat(widthRef)
|
|
297
|
-
}
|
|
298
|
-
}, React__default.createElement("div", null, contantCopy.current)), React__default.createElement("div", {
|
|
299
|
-
className: "nut-ellipsis-copy",
|
|
300
|
-
ref: symbolContain,
|
|
301
|
-
id: "symbolContain".concat(refRandomId),
|
|
302
|
-
style: {
|
|
303
|
-
display: 'inline'
|
|
304
|
-
}
|
|
305
|
-
}, symbolText()));
|
|
306
|
-
};
|
|
307
|
-
Ellipsis.defaultProps = defaultProps;
|
|
308
|
-
Ellipsis.displayName = 'NutEllipsis';
|
|
309
|
-
export { Ellipsis as E };
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["image", "imageSize", "description", "children", "className"];
|
|
5
|
-
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; }
|
|
6
|
-
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; }
|
|
7
|
-
import React__default, { useState, useEffect } from 'react';
|
|
8
|
-
import { c as cn } from './bem-893ad28d.js';
|
|
9
|
-
import { u as useConfig } from './configprovider.taro-8bdb3a28.js';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 内置图片地址
|
|
13
|
-
*/
|
|
14
|
-
var defaultStatus = {
|
|
15
|
-
empty: 'https://static-ftcms.jd.com/p/files/61a9e3183985005b3958672b.png',
|
|
16
|
-
error: 'https://ftcms.jd.com/p/files/61a9e33ee7dcdbcc0ce62736.png',
|
|
17
|
-
network: 'https://static-ftcms.jd.com/p/files/61a9e31de7dcdbcc0ce62734.png'
|
|
18
|
-
};
|
|
19
|
-
var defaultProps = {
|
|
20
|
-
description: '无内容',
|
|
21
|
-
image: 'empty',
|
|
22
|
-
imageSize: '',
|
|
23
|
-
className: ''
|
|
24
|
-
};
|
|
25
|
-
var Empty = function Empty(props) {
|
|
26
|
-
var _useConfig = useConfig(),
|
|
27
|
-
locale = _useConfig.locale;
|
|
28
|
-
defaultProps.description = locale.noData || defaultProps.description;
|
|
29
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
30
|
-
image = _defaultProps$props.image,
|
|
31
|
-
imageSize = _defaultProps$props.imageSize,
|
|
32
|
-
description = _defaultProps$props.description,
|
|
33
|
-
children = _defaultProps$props.children,
|
|
34
|
-
className = _defaultProps$props.className,
|
|
35
|
-
rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
36
|
-
var _useState = useState({}),
|
|
37
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
38
|
-
imgStyle = _useState2[0],
|
|
39
|
-
setImgStyle = _useState2[1];
|
|
40
|
-
var b = cn('empty');
|
|
41
|
-
var imageNode = image;
|
|
42
|
-
if (typeof image === 'string') {
|
|
43
|
-
var isHttpUrl = image.startsWith('https://') || image.startsWith('http://') || image.startsWith('//');
|
|
44
|
-
var imageUrl = isHttpUrl ? image : defaultStatus[image];
|
|
45
|
-
imageNode = React__default.createElement("img", {
|
|
46
|
-
className: "img",
|
|
47
|
-
src: imageUrl,
|
|
48
|
-
alt: "empty"
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
useEffect(function () {
|
|
52
|
-
setImgStyle(function () {
|
|
53
|
-
if (!imageSize) {
|
|
54
|
-
return {};
|
|
55
|
-
}
|
|
56
|
-
if (typeof imageSize === 'number') {
|
|
57
|
-
return {
|
|
58
|
-
width: "".concat(imageSize, "px"),
|
|
59
|
-
height: "".concat(imageSize, "px")
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
width: imageSize,
|
|
64
|
-
height: imageSize
|
|
65
|
-
};
|
|
66
|
-
});
|
|
67
|
-
}, [imageSize]);
|
|
68
|
-
return React__default.createElement("div", _objectSpread({
|
|
69
|
-
className: "".concat(b(), " ").concat(className)
|
|
70
|
-
}, rest), React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
71
|
-
className: b('image'),
|
|
72
|
-
style: imgStyle
|
|
73
|
-
}, imageNode), typeof description === 'string' ? React__default.createElement("div", {
|
|
74
|
-
className: b('description')
|
|
75
|
-
}, description) : {
|
|
76
|
-
description: description
|
|
77
|
-
}, children));
|
|
78
|
-
};
|
|
79
|
-
Empty.defaultProps = defaultProps;
|
|
80
|
-
Empty.displayName = 'NutEmpty';
|
|
81
|
-
export { Empty as E };
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
var _excluded = ["fixednavClass", "overlay", "visible", "navList", "activeText", "unActiveText", "position", "onChange", "onSelected", "type", "slotList", "slotBtn", "iconClassPrefix", "iconFontClassName"];
|
|
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
|
-
import React__default from 'react';
|
|
7
|
-
import classNames from 'classnames';
|
|
8
|
-
import { I as Icon } from './icon.taro-1d0d4fb7.js';
|
|
9
|
-
import { O as Overlay } from './overlay.taro-98367bc1.js';
|
|
10
|
-
import { c as cn } from './bem-893ad28d.js';
|
|
11
|
-
import { u as useConfig } from './configprovider.taro-8bdb3a28.js';
|
|
12
|
-
import { C as ComponentDefaults } from './typings-1c5f2628.js';
|
|
13
|
-
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
14
|
-
fixednavClass: 'nut-fixednav',
|
|
15
|
-
activeText: '',
|
|
16
|
-
unActiveText: '',
|
|
17
|
-
type: 'right',
|
|
18
|
-
position: {
|
|
19
|
-
top: 'auto',
|
|
20
|
-
bottom: 'auto'
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
var FixedNav = function FixedNav(props) {
|
|
24
|
-
var _useConfig = useConfig(),
|
|
25
|
-
locale = _useConfig.locale;
|
|
26
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
27
|
-
fixednavClass = _defaultProps$props.fixednavClass,
|
|
28
|
-
overlay = _defaultProps$props.overlay,
|
|
29
|
-
visible = _defaultProps$props.visible,
|
|
30
|
-
navList = _defaultProps$props.navList,
|
|
31
|
-
activeText = _defaultProps$props.activeText,
|
|
32
|
-
unActiveText = _defaultProps$props.unActiveText,
|
|
33
|
-
position = _defaultProps$props.position,
|
|
34
|
-
onChange = _defaultProps$props.onChange,
|
|
35
|
-
onSelected = _defaultProps$props.onSelected,
|
|
36
|
-
type = _defaultProps$props.type,
|
|
37
|
-
slotList = _defaultProps$props.slotList,
|
|
38
|
-
slotBtn = _defaultProps$props.slotBtn,
|
|
39
|
-
iconClassPrefix = _defaultProps$props.iconClassPrefix,
|
|
40
|
-
iconFontClassName = _defaultProps$props.iconFontClassName,
|
|
41
|
-
rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
42
|
-
var b = cn('fixednav');
|
|
43
|
-
var classes = classNames({
|
|
44
|
-
active: visible
|
|
45
|
-
}, type, fixednavClass, b(''));
|
|
46
|
-
var onSelectCb = function onSelectCb(event, item) {
|
|
47
|
-
onSelected(item, event);
|
|
48
|
-
};
|
|
49
|
-
var onUpdateValue = function onUpdateValue() {
|
|
50
|
-
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !visible;
|
|
51
|
-
onChange(value);
|
|
52
|
-
};
|
|
53
|
-
return React__default.createElement("div", _objectSpread({
|
|
54
|
-
className: classes,
|
|
55
|
-
style: position
|
|
56
|
-
}, rest), overlay && React__default.createElement(Overlay, {
|
|
57
|
-
visible: visible,
|
|
58
|
-
zIndex: 200,
|
|
59
|
-
onClick: function onClick() {
|
|
60
|
-
return onUpdateValue(false);
|
|
61
|
-
}
|
|
62
|
-
}), React__default.createElement("div", {
|
|
63
|
-
className: "list"
|
|
64
|
-
}, slotList || React__default.createElement("div", {
|
|
65
|
-
className: "nut-fixednav__list"
|
|
66
|
-
}, navList.map(function (item, index) {
|
|
67
|
-
return React__default.createElement("div", {
|
|
68
|
-
className: "nut-fixednav__list-item",
|
|
69
|
-
onClick: function onClick(event) {
|
|
70
|
-
return onSelectCb(event, item);
|
|
71
|
-
},
|
|
72
|
-
key: item.id || index
|
|
73
|
-
}, React__default.createElement("img", {
|
|
74
|
-
src: item.icon,
|
|
75
|
-
alt: ""
|
|
76
|
-
}), React__default.createElement("div", {
|
|
77
|
-
className: "nut-fixednav__list-text"
|
|
78
|
-
}, item.text), item.num && React__default.createElement("div", {
|
|
79
|
-
className: "b"
|
|
80
|
-
}, item.num));
|
|
81
|
-
}))), React__default.createElement("div", {
|
|
82
|
-
className: "nut-fixednav__btn",
|
|
83
|
-
onClick: function onClick() {
|
|
84
|
-
return onUpdateValue();
|
|
85
|
-
}
|
|
86
|
-
}, slotBtn || React__default.createElement(React__default.Fragment, null, React__default.createElement(Icon, {
|
|
87
|
-
classPrefix: iconClassPrefix,
|
|
88
|
-
fontClassName: iconFontClassName,
|
|
89
|
-
name: "left",
|
|
90
|
-
color: "#fff"
|
|
91
|
-
}), React__default.createElement("div", {
|
|
92
|
-
className: "text"
|
|
93
|
-
}, visible ? activeText || locale.fixednav.activeText : unActiveText || locale.fixednav.unActiveText))));
|
|
94
|
-
};
|
|
95
|
-
FixedNav.defaultProps = defaultProps;
|
|
96
|
-
FixedNav.displayName = 'NutFixedNav';
|
|
97
|
-
export { FixedNav as F };
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
5
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
|
-
var _excluded = ["children", "onFinish", "onFinishFailed", "labelPosition", "starPositon"];
|
|
7
|
-
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; }
|
|
8
|
-
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; }
|
|
9
|
-
import React__default, { useRef } from 'react';
|
|
10
|
-
import { C as ComponentDefaults } from './typings-1c5f2628.js';
|
|
11
|
-
import { C as CellGroup } from './cellgroup.taro-e094471c.js';
|
|
12
|
-
import { a as FormItemContext, F as FormItem } from './formitem.taro-3695f4a7.js';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 用于存储表单的数据
|
|
16
|
-
*/
|
|
17
|
-
var FormStore = /*#__PURE__*/_createClass(
|
|
18
|
-
// 存放表单中所有的数据 eg. {password: "ddd",username: "123"}
|
|
19
|
-
// 所有的组件实例
|
|
20
|
-
// 成功和失败的回调
|
|
21
|
-
|
|
22
|
-
function FormStore() {
|
|
23
|
-
var _this = this;
|
|
24
|
-
_classCallCheck(this, FormStore);
|
|
25
|
-
_defineProperty(this, "store", {});
|
|
26
|
-
_defineProperty(this, "fieldEntities", []);
|
|
27
|
-
_defineProperty(this, "callbacks", {});
|
|
28
|
-
_defineProperty(this, "errList", []);
|
|
29
|
-
_defineProperty(this, "registerField", function (field) {
|
|
30
|
-
_this.fieldEntities.push(field);
|
|
31
|
-
return function () {
|
|
32
|
-
_this.fieldEntities = _this.fieldEntities.filter(function (item) {
|
|
33
|
-
return item != field;
|
|
34
|
-
});
|
|
35
|
-
delete _this.store[field.props.name];
|
|
36
|
-
};
|
|
37
|
-
});
|
|
38
|
-
_defineProperty(this, "getFieldValue", function (name) {
|
|
39
|
-
return _this.store[name];
|
|
40
|
-
});
|
|
41
|
-
_defineProperty(this, "setFieldsValue", function (newStore) {
|
|
42
|
-
_this.store = _objectSpread(_objectSpread({}, _this.store), newStore);
|
|
43
|
-
_this.fieldEntities.forEach(function (enetity) {
|
|
44
|
-
var name = enetity.props.name;
|
|
45
|
-
Object.keys(newStore).forEach(function (key) {
|
|
46
|
-
if (key === name) {
|
|
47
|
-
enetity.onStoreChange();
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
_defineProperty(this, "validate", function () {
|
|
53
|
-
var err = [];
|
|
54
|
-
_this.errList.length = 0;
|
|
55
|
-
_this.fieldEntities.forEach(function (entity) {
|
|
56
|
-
var _entity$props = entity.props,
|
|
57
|
-
name = _entity$props.name,
|
|
58
|
-
_entity$props$rules = _entity$props.rules,
|
|
59
|
-
rules = _entity$props$rules === void 0 ? [] : _entity$props$rules;
|
|
60
|
-
var descriptor = {};
|
|
61
|
-
if (rules.length) {
|
|
62
|
-
// 多条校验规则
|
|
63
|
-
if (rules.length > 1) {
|
|
64
|
-
descriptor[name] = [];
|
|
65
|
-
rules.map(function (v) {
|
|
66
|
-
descriptor[name].push(v);
|
|
67
|
-
});
|
|
68
|
-
} else {
|
|
69
|
-
descriptor[name] = rules[0];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
// const validator = new Schema(descriptor)
|
|
73
|
-
// validator.validate({ [name]: this.store[name] }, (errors) => {
|
|
74
|
-
// if (errors) {
|
|
75
|
-
// err.push(...errors)
|
|
76
|
-
// this.errList.push(...errors)
|
|
77
|
-
// // 表单项更新
|
|
78
|
-
// }
|
|
79
|
-
// entity.onStoreChange()
|
|
80
|
-
// })
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
return err;
|
|
84
|
-
});
|
|
85
|
-
_defineProperty(this, "setCallback", function (callback) {
|
|
86
|
-
_this.callbacks = _objectSpread(_objectSpread({}, _this.callbacks), callback);
|
|
87
|
-
});
|
|
88
|
-
_defineProperty(this, "submit", function () {
|
|
89
|
-
var err = _this.validate();
|
|
90
|
-
if (err.length === 0) {
|
|
91
|
-
var _this$callbacks$onFin, _this$callbacks;
|
|
92
|
-
(_this$callbacks$onFin = (_this$callbacks = _this.callbacks).onFinish) === null || _this$callbacks$onFin === void 0 ? void 0 : _this$callbacks$onFin.call(_this$callbacks, _this.store);
|
|
93
|
-
} else if (err.length > 0) {
|
|
94
|
-
var _this$callbacks$onFin2, _this$callbacks2;
|
|
95
|
-
(_this$callbacks$onFin2 = (_this$callbacks2 = _this.callbacks).onFinishFailed) === null || _this$callbacks$onFin2 === void 0 ? void 0 : _this$callbacks$onFin2.call(_this$callbacks2, err);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
_defineProperty(this, "resetFields", function () {});
|
|
99
|
-
_defineProperty(this, "getForm", function () {
|
|
100
|
-
return {
|
|
101
|
-
setCallback: _this.setCallback,
|
|
102
|
-
registerField: _this.registerField,
|
|
103
|
-
getFieldValue: _this.getFieldValue,
|
|
104
|
-
setFieldsValue: _this.setFieldsValue,
|
|
105
|
-
submit: _this.submit,
|
|
106
|
-
store: _this.store,
|
|
107
|
-
errList: _this.errList,
|
|
108
|
-
fieldEntities: _this.fieldEntities
|
|
109
|
-
};
|
|
110
|
-
});
|
|
111
|
-
this.callbacks = {
|
|
112
|
-
onFinish: function onFinish(value) {},
|
|
113
|
-
onFinishFailed: function onFinishFailed() {}
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* 注册组件实例
|
|
118
|
-
* @param field
|
|
119
|
-
*/);
|
|
120
|
-
|
|
121
|
-
var useForm = function useForm(form) {
|
|
122
|
-
var formRef = useRef();
|
|
123
|
-
if (!formRef.current) {
|
|
124
|
-
if (form) {
|
|
125
|
-
formRef.current = form;
|
|
126
|
-
} else {
|
|
127
|
-
var formStore = new FormStore();
|
|
128
|
-
formRef.current = formStore.getForm();
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return [formRef.current];
|
|
132
|
-
};
|
|
133
|
-
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
134
|
-
className: '',
|
|
135
|
-
style: undefined,
|
|
136
|
-
form: {},
|
|
137
|
-
labelPosition: 'Right',
|
|
138
|
-
formGroupTitle: '',
|
|
139
|
-
onFinish: function onFinish(obj) {},
|
|
140
|
-
onFinishFailed: function onFinishFailed(value) {},
|
|
141
|
-
starPositon: 'Left'
|
|
142
|
-
});
|
|
143
|
-
var PositionInfo = {
|
|
144
|
-
Top: 'form-layout-top',
|
|
145
|
-
Left: 'form-layout-left',
|
|
146
|
-
Right: 'form-layout-right'
|
|
147
|
-
};
|
|
148
|
-
var Form = function Form(props) {
|
|
149
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
150
|
-
children = _defaultProps$props.children,
|
|
151
|
-
onFinish = _defaultProps$props.onFinish,
|
|
152
|
-
onFinishFailed = _defaultProps$props.onFinishFailed,
|
|
153
|
-
labelPosition = _defaultProps$props.labelPosition,
|
|
154
|
-
starPositon = _defaultProps$props.starPositon,
|
|
155
|
-
rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
156
|
-
console.log('46 dddd');
|
|
157
|
-
var _useForm = useForm(),
|
|
158
|
-
_useForm2 = _slicedToArray(_useForm, 1),
|
|
159
|
-
formInstance = _useForm2[0];
|
|
160
|
-
formInstance.starPositon = starPositon;
|
|
161
|
-
var setCallback = formInstance.setCallback,
|
|
162
|
-
submit = formInstance.submit;
|
|
163
|
-
setCallback({
|
|
164
|
-
onFinish: onFinish,
|
|
165
|
-
onFinishFailed: onFinishFailed
|
|
166
|
-
});
|
|
167
|
-
return React__default.createElement("form", {
|
|
168
|
-
className: "nut-form ".concat(PositionInfo[labelPosition], " ").concat(props.className),
|
|
169
|
-
style: props.style,
|
|
170
|
-
onSubmit: function onSubmit(e) {
|
|
171
|
-
e.preventDefault();
|
|
172
|
-
submit();
|
|
173
|
-
}
|
|
174
|
-
}, React__default.createElement(CellGroup, null, React__default.createElement(FormItemContext.Provider, {
|
|
175
|
-
value: formInstance
|
|
176
|
-
}, children)));
|
|
177
|
-
};
|
|
178
|
-
Form.defaultProps = defaultProps;
|
|
179
|
-
Form.displayName = 'NutForm';
|
|
180
|
-
Form.Item = FormItem;
|
|
181
|
-
export { Form as F };
|