@nutui/nutui-react-taro 2.0.0-alpha.11 → 2.0.0-alpha.12
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 +14 -0
- package/dist/esm/ActionSheet/style/style.css +1 -1
- package/dist/esm/ActionSheet.js +1 -3
- package/dist/esm/CountDown/style/style.css +1 -1
- package/dist/esm/CountDown.js +2 -3
- package/dist/esm/Ellipsis/style/style.css +1 -1
- package/dist/esm/Ellipsis.js +1 -1
- package/dist/esm/SearchBar/style/style.css +1 -1
- package/dist/esm/SearchBar.js +1 -4
- package/dist/esm/ShortPassword/style/style.css +1 -1
- package/dist/esm/ShortPassword.js +3 -4
- package/dist/esm/Toast/style/style.css +1 -1
- package/dist/esm/Toast.js +2 -3
- package/dist/esm/VirtualList/style/style.css +1 -1
- package/dist/esm/VirtualList.js +2 -2
- package/dist/esm/actionsheet.taro-697a594b.js +54 -0
- package/dist/esm/{countdown.taro-22200811.js → countdown.taro-c399cc08.js} +17 -10
- package/dist/esm/{ellipsis.taro-02765890.js → ellipsis.taro-f423affa.js} +13 -6
- package/dist/esm/nutui-react.es.js +7 -7
- package/dist/esm/searchbar.taro-09468fff.js +122 -0
- package/dist/esm/shortpassword.taro-eabbde1b.js +90 -0
- package/dist/esm/toast.taro-b2937e7c.js +171 -0
- package/dist/esm/types/src/packages/actionsheet/actionsheet.d.ts +11 -15
- package/dist/esm/types/src/packages/actionsheet/actionsheet.taro.d.ts +11 -15
- package/dist/esm/types/src/packages/actionsheet/index.d.ts +1 -0
- package/dist/esm/types/src/packages/actionsheet/index.taro.d.ts +1 -0
- package/dist/esm/types/src/packages/configprovider/configprovider.d.ts +2 -1
- package/dist/esm/types/src/packages/configprovider/configprovider.taro.d.ts +2 -1
- package/dist/esm/types/src/packages/configprovider/index.d.ts +1 -0
- package/dist/esm/types/src/packages/configprovider/index.taro.d.ts +1 -0
- package/dist/esm/types/src/packages/configprovider/types.d.ts +1 -0
- package/dist/esm/types/src/packages/countdown/countdown.d.ts +5 -4
- package/dist/esm/types/src/packages/countdown/countdown.taro.d.ts +5 -4
- package/dist/esm/types/src/packages/countdown/index.d.ts +1 -0
- package/dist/esm/types/src/packages/countdown/index.taro.d.ts +1 -0
- package/dist/esm/types/src/packages/ellipsis/ellipsis.taro.d.ts +1 -0
- package/dist/esm/types/src/packages/searchbar/index.d.ts +1 -0
- package/dist/esm/types/src/packages/searchbar/index.taro.d.ts +1 -0
- package/dist/esm/types/src/packages/searchbar/searchbar.d.ts +4 -31
- package/dist/esm/types/src/packages/searchbar/searchbar.taro.d.ts +4 -31
- package/dist/esm/types/src/packages/shortpassword/index.d.ts +1 -0
- package/dist/esm/types/src/packages/shortpassword/index.taro.d.ts +1 -0
- package/dist/esm/types/src/packages/shortpassword/shortpassword.d.ts +17 -20
- package/dist/esm/types/src/packages/shortpassword/shortpassword.taro.d.ts +17 -20
- package/dist/esm/types/src/packages/toast/Notification.d.ts +9 -13
- package/dist/esm/types/src/packages/toast/index.d.ts +1 -0
- package/dist/esm/types/src/packages/toast/index.taro.d.ts +1 -0
- package/dist/esm/types/src/packages/toast/toast.d.ts +19 -26
- package/dist/esm/types/src/packages/toast/toast.taro.d.ts +9 -11
- package/dist/esm/types/src/packages/virtuallist/index.d.ts +1 -0
- package/dist/esm/types/src/packages/virtuallist/index.taro.d.ts +1 -0
- package/dist/esm/types/src/packages/virtuallist/type.d.ts +0 -18
- package/dist/esm/types/src/packages/virtuallist/utils.d.ts +3 -3
- package/dist/esm/types/src/packages/virtuallist/virtuallist.d.ts +15 -4
- package/dist/esm/types/src/packages/virtuallist/virtuallist.taro.d.ts +13 -14
- package/dist/esm/{virtuallist.taro-99f03769.js → virtuallist.taro-97d3403a.js} +27 -30
- 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/tr-TR.js +10 -2
- 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 +393 -422
- package/dist/nutui.react.umd.js +393 -422
- package/dist/packages/actionsheet/actionsheet.scss +26 -73
- package/dist/packages/countdown/countdown.scss +2 -0
- package/dist/packages/ellipsis/ellipsis.scss +4 -0
- package/dist/packages/searchbar/searchbar.scss +13 -71
- package/dist/packages/shortpassword/shortpassword.scss +1 -88
- package/dist/packages/toast/toast.scss +20 -7
- package/dist/packages/virtuallist/virtuallist.scss +0 -12
- package/dist/style.css +1 -1
- package/dist/style.mjs +1 -1
- package/dist/styles/variables-jmapp.scss +56 -60
- package/dist/styles/variables.scss +30 -53
- package/dist/types/packages/actionsheet/actionsheet.taro.d.ts +11 -15
- package/dist/types/packages/actionsheet/index.taro.d.ts +1 -0
- package/dist/types/packages/configprovider/configprovider.d.ts +2 -1
- package/dist/types/packages/configprovider/configprovider.taro.d.ts +2 -1
- package/dist/types/packages/configprovider/index.d.ts +1 -0
- package/dist/types/packages/configprovider/index.taro.d.ts +1 -0
- package/dist/types/packages/configprovider/types.d.ts +1 -0
- package/dist/types/packages/countdown/countdown.taro.d.ts +5 -4
- package/dist/types/packages/countdown/index.taro.d.ts +1 -0
- package/dist/types/packages/ellipsis/ellipsis.taro.d.ts +1 -0
- package/dist/types/packages/overlay/index.d.ts +3 -0
- package/dist/types/packages/overlay/overlay.d.ts +14 -0
- package/dist/types/packages/searchbar/index.taro.d.ts +1 -0
- package/dist/types/packages/searchbar/searchbar.taro.d.ts +4 -31
- package/dist/types/packages/shortpassword/index.taro.d.ts +1 -0
- package/dist/types/packages/shortpassword/shortpassword.taro.d.ts +17 -20
- package/dist/types/packages/toast/index.taro.d.ts +1 -0
- package/dist/types/packages/toast/toast.taro.d.ts +9 -11
- package/dist/types/packages/virtuallist/index.taro.d.ts +1 -0
- package/dist/types/packages/virtuallist/type.d.ts +0 -17
- package/dist/types/packages/virtuallist/utils.d.ts +3 -3
- package/dist/types/packages/virtuallist/virtuallist.taro.d.ts +13 -14
- package/package.json +1 -1
- package/dist/esm/actionsheet.taro-d2217152.js +0 -61
- package/dist/esm/searchbar.taro-37ade36e.js +0 -159
- package/dist/esm/shortpassword.taro-f7292032.js +0 -146
- package/dist/esm/toast.taro-92c10e1d.js +0 -114
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
export interface ShortPasswordProps extends
|
|
4
|
-
|
|
5
|
-
description: string;
|
|
6
|
-
tips: string;
|
|
7
|
-
tipsIcon: React.ReactNode;
|
|
8
|
-
iconSize: string | number;
|
|
1
|
+
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
+
import { PopupProps } from '../../packages/popup/popup.taro';
|
|
3
|
+
export interface ShortPasswordProps extends PopupProps {
|
|
4
|
+
value: string;
|
|
9
5
|
visible: boolean;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
autoFocus
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
plain: boolean;
|
|
7
|
+
title: ReactNode;
|
|
8
|
+
description: ReactNode;
|
|
9
|
+
tips: ReactNode;
|
|
10
|
+
hideFooter: boolean;
|
|
11
|
+
length: number;
|
|
12
|
+
error: ReactNode;
|
|
13
|
+
autoFocus: boolean;
|
|
14
|
+
onFocus: () => void;
|
|
15
|
+
onChange: (value: string) => void;
|
|
16
|
+
onConfirm: (value: string) => void;
|
|
20
17
|
onCancel: () => void;
|
|
21
18
|
onClose: () => void;
|
|
22
19
|
onTips: () => void;
|
|
23
|
-
onComplete: (value: string
|
|
20
|
+
onComplete: (value: string) => void;
|
|
24
21
|
}
|
|
25
|
-
export declare const ShortPassword: FunctionComponent<Partial<ShortPasswordProps
|
|
22
|
+
export declare const ShortPassword: FunctionComponent<Partial<ShortPasswordProps>>;
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import React, { FunctionComponent } from 'react';
|
|
2
|
-
|
|
2
|
+
import { BasicComponent } from '../../utils/typings';
|
|
3
|
+
export type ToastPositionType = 'top' | 'bottom' | 'center';
|
|
4
|
+
export interface ToastProps extends BasicComponent {
|
|
3
5
|
id?: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
maskClassName?: string;
|
|
7
|
+
contentClassName?: string;
|
|
8
|
+
contentStyle?: React.CSSProperties;
|
|
9
|
+
icon: string | React.ReactNode;
|
|
6
10
|
iconSize: string;
|
|
7
11
|
msg: string | React.ReactNode;
|
|
8
|
-
bottom: number | string;
|
|
9
12
|
duration: number;
|
|
10
|
-
|
|
13
|
+
position?: ToastPositionType;
|
|
11
14
|
type: string;
|
|
12
15
|
title: string;
|
|
13
|
-
|
|
16
|
+
closeOnOverlayClick: boolean;
|
|
14
17
|
size: string | number;
|
|
15
|
-
textAlignCenter: boolean;
|
|
16
|
-
bgColor: string;
|
|
17
|
-
cover: boolean;
|
|
18
|
-
coverColor: string;
|
|
19
|
-
closeOnClickOverlay: boolean;
|
|
20
18
|
visible: boolean;
|
|
21
19
|
onClose: () => void;
|
|
22
20
|
}
|
|
@@ -14,20 +14,3 @@ export interface PositionType {
|
|
|
14
14
|
left?: number;
|
|
15
15
|
right: number;
|
|
16
16
|
}
|
|
17
|
-
export interface BasicVirtualListProps {
|
|
18
|
-
className?: string;
|
|
19
|
-
style?: React.CSSProperties;
|
|
20
|
-
sourceData: Array<Data>;
|
|
21
|
-
containerSize?: number;
|
|
22
|
-
ItemRender?: React.FC<any>;
|
|
23
|
-
itemSize?: number;
|
|
24
|
-
itemEqualSize?: boolean;
|
|
25
|
-
horizontal?: boolean;
|
|
26
|
-
overscan?: number;
|
|
27
|
-
handleScroll?: (...args: any[]) => any;
|
|
28
|
-
onScroll?: (...args: any[]) => any;
|
|
29
|
-
key?: string;
|
|
30
|
-
locale?: {
|
|
31
|
-
[key in string]: string;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
@@ -2,11 +2,11 @@ import { PositionType, Data } from './type';
|
|
|
2
2
|
declare const initPositinoCache: (reaItemSize: number, length?: number) => PositionType[];
|
|
3
3
|
declare const getListTotalSize: (positions: Array<PositionType>, horizontal: true | false) => number;
|
|
4
4
|
declare const binarySearch: (positionsList: Array<PositionType>, value: number | undefined, horizontal: true | false) => number;
|
|
5
|
-
declare const getEndIndex: ({
|
|
6
|
-
|
|
5
|
+
declare const getEndIndex: ({ list, startIndex, visibleCount, itemEqual, positions, offSetSize, overscan, sizeKey, }: {
|
|
6
|
+
list: Array<Data>;
|
|
7
7
|
startIndex: number;
|
|
8
8
|
visibleCount: number;
|
|
9
|
-
|
|
9
|
+
itemEqual?: boolean | undefined;
|
|
10
10
|
positions: PositionType[];
|
|
11
11
|
offSetSize: number;
|
|
12
12
|
overscan: number;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import React, { FunctionComponent } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
ItemRender
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
overscan
|
|
11
|
-
onScroll
|
|
12
|
-
key
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export declare const VirtualList: FunctionComponent<VirtualListProps & React.HTMLAttributes<HTMLDivElement>>;
|
|
2
|
+
import { Data } from './type';
|
|
3
|
+
import { BasicComponent } from '../../utils/typings';
|
|
4
|
+
export interface VirtualListProps extends BasicComponent {
|
|
5
|
+
list: Array<Data>;
|
|
6
|
+
containerHeight: number;
|
|
7
|
+
ItemRender: React.FC<any>;
|
|
8
|
+
itemHeight: number;
|
|
9
|
+
itemEqual: boolean;
|
|
10
|
+
overscan: number;
|
|
11
|
+
onScroll: () => void;
|
|
12
|
+
key: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const VirtualList: FunctionComponent<Partial<VirtualListProps>>;
|
package/package.json
CHANGED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { P as Popup } from "./popup.taro-e756f3fc.js";
|
|
3
|
-
import { c as cn } from "./bem-cdccae08.js";
|
|
4
|
-
const defaultProps = {
|
|
5
|
-
cancelText: "",
|
|
6
|
-
optionTag: "name",
|
|
7
|
-
optionSubTag: "subname",
|
|
8
|
-
chooseTagValue: "",
|
|
9
|
-
title: "",
|
|
10
|
-
color: "#ee0a24",
|
|
11
|
-
description: "",
|
|
12
|
-
menuItems: [],
|
|
13
|
-
onCancel: () => {
|
|
14
|
-
},
|
|
15
|
-
onChoose: () => {
|
|
16
|
-
},
|
|
17
|
-
visible: false,
|
|
18
|
-
className: "",
|
|
19
|
-
style: {}
|
|
20
|
-
};
|
|
21
|
-
const ActionSheet = (props) => {
|
|
22
|
-
const { children, cancelText, optionTag, optionSubTag, chooseTagValue, title, color, description, menuItems, onCancel, onChoose, visible, className, style, ...rest } = { ...defaultProps, ...props };
|
|
23
|
-
const b = cn("actionsheet");
|
|
24
|
-
const isHighlight = (item) => {
|
|
25
|
-
return props.chooseTagValue && props.chooseTagValue === item[props.optionTag || "name"] ? props.color : "#1a1a1a";
|
|
26
|
-
};
|
|
27
|
-
const cancelActionSheet = () => {
|
|
28
|
-
onCancel && onCancel();
|
|
29
|
-
};
|
|
30
|
-
const chooseItem = (item, index) => {
|
|
31
|
-
if (!item.disable) {
|
|
32
|
-
onChoose && onChoose(item, index);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
return React.createElement(
|
|
36
|
-
Popup,
|
|
37
|
-
{ round: true, visible, position: "bottom", onClose: () => {
|
|
38
|
-
onCancel && onCancel();
|
|
39
|
-
} },
|
|
40
|
-
React.createElement(
|
|
41
|
-
"div",
|
|
42
|
-
{ className: `${b()} ${className}`, style, ...rest },
|
|
43
|
-
title && React.createElement("div", { className: b("title") }, title),
|
|
44
|
-
description && React.createElement("div", { className: `${b("item")} description` }, description),
|
|
45
|
-
menuItems.length ? React.createElement("div", { className: b("menu") }, menuItems.map((item, index) => {
|
|
46
|
-
return React.createElement(
|
|
47
|
-
"div",
|
|
48
|
-
{ className: `${b("item")} ${item.disable ? b("item-disabled") : ""}`, style: { color: isHighlight(item) }, key: index, onClick: () => chooseItem(item, index) },
|
|
49
|
-
item[optionTag],
|
|
50
|
-
React.createElement("div", { className: "subdesc" }, item[optionSubTag])
|
|
51
|
-
);
|
|
52
|
-
})) : children,
|
|
53
|
-
cancelText && React.createElement("div", { className: b("cancel"), onClick: () => cancelActionSheet() }, cancelText)
|
|
54
|
-
)
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
ActionSheet.defaultProps = defaultProps;
|
|
58
|
-
ActionSheet.displayName = "NutActionSheet";
|
|
59
|
-
export {
|
|
60
|
-
ActionSheet as A
|
|
61
|
-
};
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useState, useEffect } from "react";
|
|
2
|
-
import { getEnv } from "@tarojs/taro";
|
|
3
|
-
import { Search, CircleClose } from "@nutui/icons-react-taro";
|
|
4
|
-
import { c as cn } from "./bem-cdccae08.js";
|
|
5
|
-
import { u as useConfig } from "./configprovider.taro-25758d9f.js";
|
|
6
|
-
import { C as ComponentDefaults } from "./typings-11d83a22.js";
|
|
7
|
-
const defaultProps = {
|
|
8
|
-
...ComponentDefaults,
|
|
9
|
-
placeholder: "",
|
|
10
|
-
shape: "square",
|
|
11
|
-
disabled: false,
|
|
12
|
-
maxLength: 9999,
|
|
13
|
-
clearable: true,
|
|
14
|
-
clearSize: "12px",
|
|
15
|
-
align: "left",
|
|
16
|
-
readonly: true,
|
|
17
|
-
autoFocus: false,
|
|
18
|
-
label: "",
|
|
19
|
-
leftinIcon: React.createElement(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, clearSize, align, readOnly, autoFocus, label, actionText, leftinIcon, rightinIcon, leftoutIcon, rightoutIcon, onChange, onFocus, onBlur, onClear, onCancel, onSearch, onClickInput, onClickLeftinIcon, onClickLeftoutIcon, onClickRightinIcon, onClickRightoutIcon } = {
|
|
27
|
-
...defaultProps,
|
|
28
|
-
...props
|
|
29
|
-
};
|
|
30
|
-
const alignClass = `${align}`;
|
|
31
|
-
const forceFocus = () => {
|
|
32
|
-
const searchSelf = searchRef.current;
|
|
33
|
-
searchSelf && searchSelf.focus();
|
|
34
|
-
};
|
|
35
|
-
const change = (event) => {
|
|
36
|
-
const { value: value2 } = event.target;
|
|
37
|
-
onChange && (onChange == null ? void 0 : onChange(value2, event));
|
|
38
|
-
setValue(value2);
|
|
39
|
-
value2 === "" && forceFocus();
|
|
40
|
-
};
|
|
41
|
-
const focus = (event) => {
|
|
42
|
-
const { value: value2 } = event.target;
|
|
43
|
-
onFocus && (onFocus == null ? void 0 : onFocus(value2, event));
|
|
44
|
-
};
|
|
45
|
-
const blur = (event) => {
|
|
46
|
-
const searchSelf = searchRef.current;
|
|
47
|
-
searchSelf && searchSelf.blur();
|
|
48
|
-
const { value: value2 } = event.target;
|
|
49
|
-
onBlur && (onBlur == null ? void 0 : onBlur(value2, event));
|
|
50
|
-
};
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
setValue(props.value);
|
|
53
|
-
}, [props.value]);
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
autoFocus && forceFocus();
|
|
56
|
-
}, [autoFocus]);
|
|
57
|
-
const renderField = () => {
|
|
58
|
-
return React.createElement("input", { className: `${searchbarBem("input")} ${searchbarBem(alignClass)} ${shape === "round" ? searchbarBem("round") : ""} ${clearable ? searchbarBem("input-clear") : ""}`, ref: searchRef, style: { ...props.style }, value: value || "", placeholder: placeholder || locale.placeholder, disabled, readOnly, maxLength, onKeyPress: onKeypress, onChange: (e) => change(e), onFocus: (e) => focus(e), onBlur: (e) => blur(e), onClick: (e) => clickInput(e) });
|
|
59
|
-
};
|
|
60
|
-
const clickInput = (e) => {
|
|
61
|
-
onClickInput && onClickInput(e);
|
|
62
|
-
};
|
|
63
|
-
const renderLeftinIcon = () => {
|
|
64
|
-
if (!leftinIcon)
|
|
65
|
-
return null;
|
|
66
|
-
return React.createElement("div", { className: `${searchbarBem("leftin-icon")} ${searchbarBem("icon")}`, onClick: (e) => clickLeftIcon("in-left", e) }, leftinIcon);
|
|
67
|
-
};
|
|
68
|
-
const renderLeftoutIcon = () => {
|
|
69
|
-
if (!leftoutIcon)
|
|
70
|
-
return null;
|
|
71
|
-
return React.createElement("div", { className: `${searchbarBem("leftout-icon")}`, onClick: (e) => clickLeftIcon("out-left", e) }, leftoutIcon);
|
|
72
|
-
};
|
|
73
|
-
const clickLeftIcon = (flag, event) => {
|
|
74
|
-
if (flag === "in-left") {
|
|
75
|
-
onClickLeftinIcon && onClickLeftinIcon(value, event);
|
|
76
|
-
} else {
|
|
77
|
-
onClickLeftoutIcon && onClickLeftoutIcon(value, event);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
const renderRightinIcon = () => {
|
|
81
|
-
if (!rightinIcon)
|
|
82
|
-
return null;
|
|
83
|
-
return React.createElement("div", { className: `${searchbarBem("rightin-icon")} ${searchbarBem("icon")}`, onClick: (e) => clickRightIcon("in-right", e) }, rightinIcon);
|
|
84
|
-
};
|
|
85
|
-
const renderRightoutIcon = () => {
|
|
86
|
-
if (!rightoutIcon)
|
|
87
|
-
return null;
|
|
88
|
-
return React.createElement("div", { className: `${searchbarBem("rightout-icon")}`, onClick: (e) => clickRightIcon("out-right", e) }, rightoutIcon);
|
|
89
|
-
};
|
|
90
|
-
const clickRightIcon = (flag, event) => {
|
|
91
|
-
if (flag === "in-left") {
|
|
92
|
-
onClickRightinIcon && onClickRightinIcon(value, event);
|
|
93
|
-
} else {
|
|
94
|
-
onClickRightoutIcon && onClickRightoutIcon(value, event);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
const handleClear = () => {
|
|
98
|
-
return React.createElement(
|
|
99
|
-
"div",
|
|
100
|
-
{ className: `${searchbarBem("clear")} ${rightinIcon ? "pos-right" : ""}`, onClick: (e) => clearaVal(e) },
|
|
101
|
-
React.createElement(CircleClose, { size: clearSize, color: "#555" })
|
|
102
|
-
);
|
|
103
|
-
};
|
|
104
|
-
const clearaVal = (event) => {
|
|
105
|
-
if (disabled || readOnly) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
setValue("");
|
|
109
|
-
onClear && onClear(event);
|
|
110
|
-
forceFocus();
|
|
111
|
-
};
|
|
112
|
-
const renderRightLabel = () => {
|
|
113
|
-
if (actionText) {
|
|
114
|
-
return React.createElement("div", { className: searchbarBem("action-text"), onClick: search }, actionText);
|
|
115
|
-
}
|
|
116
|
-
return null;
|
|
117
|
-
};
|
|
118
|
-
const onKeypress = (e) => {
|
|
119
|
-
if (e.keyCode === 13) {
|
|
120
|
-
if (typeof e.cancelable !== "boolean" || e.cancelable) {
|
|
121
|
-
e.preventDefault();
|
|
122
|
-
}
|
|
123
|
-
onSearch && onSearch(value);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
const search = () => {
|
|
127
|
-
onSearch && onSearch(value);
|
|
128
|
-
};
|
|
129
|
-
const renderLabel = () => {
|
|
130
|
-
if (label) {
|
|
131
|
-
return React.createElement("div", { className: searchbarBem("label") }, label);
|
|
132
|
-
}
|
|
133
|
-
return null;
|
|
134
|
-
};
|
|
135
|
-
const envClass = () => {
|
|
136
|
-
return getEnv() === "WEB" ? "nut-searchbar-taro" : "";
|
|
137
|
-
};
|
|
138
|
-
return React.createElement(
|
|
139
|
-
"div",
|
|
140
|
-
{ className: `${searchbarBem()} ${envClass()} ${disabled ? searchbarBem("disabled") : ""} ${className || ""}`, style: { ...props.style, background: props.background } },
|
|
141
|
-
renderLeftoutIcon(),
|
|
142
|
-
renderLabel(),
|
|
143
|
-
React.createElement(
|
|
144
|
-
"div",
|
|
145
|
-
{ className: `${searchbarBem("content")}`, style: { background: props.inputBackground } },
|
|
146
|
-
renderLeftinIcon(),
|
|
147
|
-
React.createElement("div", { className: "nut-searchbar__input-box" }, renderField()),
|
|
148
|
-
renderRightinIcon(),
|
|
149
|
-
clearable && value && handleClear()
|
|
150
|
-
),
|
|
151
|
-
renderRightoutIcon(),
|
|
152
|
-
renderRightLabel()
|
|
153
|
-
);
|
|
154
|
-
};
|
|
155
|
-
SearchBar.defaultProps = defaultProps;
|
|
156
|
-
SearchBar.displayName = "NutSearchBar";
|
|
157
|
-
export {
|
|
158
|
-
SearchBar as S
|
|
159
|
-
};
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useState, useEffect } from "react";
|
|
2
|
-
import { Tips } from "@nutui/icons-react-taro";
|
|
3
|
-
import { c as cn } from "./bem-cdccae08.js";
|
|
4
|
-
import { P as Popup } from "./popup.taro-e756f3fc.js";
|
|
5
|
-
import { u as useConfig } from "./configprovider.taro-25758d9f.js";
|
|
6
|
-
import { C as ComponentDefaults } from "./typings-11d83a22.js";
|
|
7
|
-
const defaultProps = {
|
|
8
|
-
...ComponentDefaults,
|
|
9
|
-
title: "",
|
|
10
|
-
description: "",
|
|
11
|
-
tips: "",
|
|
12
|
-
tipsIcon: null,
|
|
13
|
-
iconSize: 11,
|
|
14
|
-
visible: false,
|
|
15
|
-
modelValue: "",
|
|
16
|
-
errorMsg: "",
|
|
17
|
-
noButton: true,
|
|
18
|
-
closeOnClickOverlay: true,
|
|
19
|
-
length: 6,
|
|
20
|
-
className: "",
|
|
21
|
-
autoFocus: false,
|
|
22
|
-
onChange: (value) => {
|
|
23
|
-
},
|
|
24
|
-
onOk: (value) => {
|
|
25
|
-
},
|
|
26
|
-
onCancel: () => {
|
|
27
|
-
},
|
|
28
|
-
onClose: () => {
|
|
29
|
-
},
|
|
30
|
-
onTips: () => {
|
|
31
|
-
},
|
|
32
|
-
onComplete: (value) => {
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const ShortPassword = (props) => {
|
|
36
|
-
const { locale } = useConfig();
|
|
37
|
-
const { title, description, tips, tipsIcon, iconSize, visible, modelValue, errorMsg, noButton, closeOnClickOverlay, length, style, className, onChange, onOk, onTips, onCancel, onClose, onComplete, autoFocus, ...reset } = props;
|
|
38
|
-
const b = cn("shortpassword");
|
|
39
|
-
const textInput = useRef(null);
|
|
40
|
-
const range = (val) => {
|
|
41
|
-
return Math.min(Math.max(4, val), 6);
|
|
42
|
-
};
|
|
43
|
-
const [innerVisible, setInnerVisible] = useState(visible);
|
|
44
|
-
const [comLen, setComLen] = useState(range(Number(length)));
|
|
45
|
-
const [inputValue, setInputValue] = useState("");
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
setInnerVisible(visible);
|
|
48
|
-
}, [visible]);
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
if (typeof modelValue !== "undefined") {
|
|
51
|
-
setInputValue(modelValue);
|
|
52
|
-
}
|
|
53
|
-
}, [modelValue]);
|
|
54
|
-
const changeValue = (e) => {
|
|
55
|
-
let inputValue2 = e.target.value;
|
|
56
|
-
if (String(inputValue2).length > comLen) {
|
|
57
|
-
inputValue2 = inputValue2.slice(0, comLen);
|
|
58
|
-
}
|
|
59
|
-
setInputValue(inputValue2);
|
|
60
|
-
if (String(inputValue2).length === comLen) {
|
|
61
|
-
onComplete && onComplete(inputValue2);
|
|
62
|
-
}
|
|
63
|
-
onChange && onChange(inputValue2);
|
|
64
|
-
};
|
|
65
|
-
const systemStyle = () => {
|
|
66
|
-
const u = navigator.userAgent;
|
|
67
|
-
const isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1;
|
|
68
|
-
const isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
|
|
69
|
-
let style2 = {};
|
|
70
|
-
if (isIOS) {
|
|
71
|
-
style2 = {
|
|
72
|
-
paddingRight: "1200px"
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
if (isAndroid) {
|
|
76
|
-
style2 = {
|
|
77
|
-
opacity: 0,
|
|
78
|
-
zIndex: 10
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
return style2;
|
|
82
|
-
};
|
|
83
|
-
const focus = () => {
|
|
84
|
-
if (textInput.current) {
|
|
85
|
-
textInput.current.focus();
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
const sure = () => {
|
|
89
|
-
onOk && onOk(inputValue);
|
|
90
|
-
};
|
|
91
|
-
const renderIcon = (size = "11px") => {
|
|
92
|
-
return React.isValidElement(tipsIcon) ? React.cloneElement(tipsIcon, {
|
|
93
|
-
...tipsIcon.props,
|
|
94
|
-
size
|
|
95
|
-
}) : React.createElement(Tips, { size });
|
|
96
|
-
};
|
|
97
|
-
return React.createElement(
|
|
98
|
-
"div",
|
|
99
|
-
null,
|
|
100
|
-
React.createElement(
|
|
101
|
-
Popup,
|
|
102
|
-
{ style: {
|
|
103
|
-
padding: "32px 24px 28px 24px",
|
|
104
|
-
borderRadius: "12px",
|
|
105
|
-
textAlign: "center"
|
|
106
|
-
}, visible: innerVisible, closeable: true, "close-on-click-overlay": closeOnClickOverlay, onClickOverlay: onClose, onClickCloseIcon: onClose },
|
|
107
|
-
React.createElement(
|
|
108
|
-
"div",
|
|
109
|
-
{ className: `${b()} ${className}`, style: { ...style }, ...reset },
|
|
110
|
-
React.createElement("div", { className: b("title") }, title || locale.shortpassword.title),
|
|
111
|
-
React.createElement("div", { className: b("subtitle") }, description || locale.shortpassword.description),
|
|
112
|
-
React.createElement(
|
|
113
|
-
"div",
|
|
114
|
-
{ className: b("input") },
|
|
115
|
-
React.createElement("input", { ref: textInput, className: b("input-real"), type: "number", style: systemStyle(), maxLength: 6, value: inputValue, autoFocus, onChange: (e) => changeValue(e) }),
|
|
116
|
-
React.createElement("div", { className: b("input-site") }),
|
|
117
|
-
React.createElement("div", { className: b("input-fake"), onClick: () => focus() }, [...new Array(comLen).keys()].map((item, index) => {
|
|
118
|
-
return React.createElement("div", { className: b("input-fake__li"), key: index }, String(inputValue).length > index ? React.createElement("div", { className: b("input-fake__li__icon") }) : null);
|
|
119
|
-
}))
|
|
120
|
-
),
|
|
121
|
-
React.createElement(
|
|
122
|
-
"div",
|
|
123
|
-
{ className: b("message") },
|
|
124
|
-
React.createElement("div", { className: b("message__error") }, errorMsg),
|
|
125
|
-
tips || locale.shortpassword.tips ? React.createElement(
|
|
126
|
-
"div",
|
|
127
|
-
{ className: b("message__forget") },
|
|
128
|
-
renderIcon(iconSize),
|
|
129
|
-
React.createElement("div", { className: b("message__forget-tips"), onClick: onTips }, tips || locale.shortpassword.tips)
|
|
130
|
-
) : null
|
|
131
|
-
),
|
|
132
|
-
!noButton ? React.createElement(
|
|
133
|
-
"div",
|
|
134
|
-
{ className: b("footer") },
|
|
135
|
-
React.createElement("div", { className: b("footer__cancel"), onClick: onCancel }, locale.cancel),
|
|
136
|
-
React.createElement("div", { className: b("footer__sure"), onClick: () => sure() }, locale.confirm)
|
|
137
|
-
) : null
|
|
138
|
-
)
|
|
139
|
-
)
|
|
140
|
-
);
|
|
141
|
-
};
|
|
142
|
-
ShortPassword.defaultProps = defaultProps;
|
|
143
|
-
ShortPassword.displayName = "NutShortPassword";
|
|
144
|
-
export {
|
|
145
|
-
ShortPassword as S
|
|
146
|
-
};
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from "react";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
import { Success, Failure, Tips, Loading } from "@nutui/icons-react-taro";
|
|
4
|
-
import { c as cn } from "./bem-cdccae08.js";
|
|
5
|
-
const defaultProps = {
|
|
6
|
-
id: "",
|
|
7
|
-
style: {},
|
|
8
|
-
icon: null,
|
|
9
|
-
iconSize: "20",
|
|
10
|
-
msg: "",
|
|
11
|
-
bottom: "30px",
|
|
12
|
-
duration: 2,
|
|
13
|
-
center: true,
|
|
14
|
-
type: "text",
|
|
15
|
-
title: "",
|
|
16
|
-
customClass: "",
|
|
17
|
-
size: "base",
|
|
18
|
-
textAlignCenter: true,
|
|
19
|
-
bgColor: "rgba(0, 0, 0, .8)",
|
|
20
|
-
cover: false,
|
|
21
|
-
coverColor: "rgba(0, 0, 0, 0)",
|
|
22
|
-
closeOnClickOverlay: false,
|
|
23
|
-
visible: false,
|
|
24
|
-
onClose: () => {
|
|
25
|
-
}
|
|
26
|
-
// 未实现
|
|
27
|
-
};
|
|
28
|
-
const Toast = (props) => {
|
|
29
|
-
const { children, id, style, icon, iconSize, msg, bottom, duration, center, type, title, customClass, size, textAlignCenter, bgColor, cover, coverColor, closeOnClickOverlay, visible, onClose, ...rest } = { ...defaultProps, ...props };
|
|
30
|
-
let timer;
|
|
31
|
-
const [openState, SetOpenState] = useState(false);
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
if (visible) {
|
|
34
|
-
SetOpenState(true);
|
|
35
|
-
show();
|
|
36
|
-
} else {
|
|
37
|
-
hide();
|
|
38
|
-
}
|
|
39
|
-
}, [visible]);
|
|
40
|
-
const clearTimer = () => {
|
|
41
|
-
if (timer) {
|
|
42
|
-
clearTimeout(timer);
|
|
43
|
-
timer = null;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
const hide = () => {
|
|
47
|
-
SetOpenState(false);
|
|
48
|
-
onClose();
|
|
49
|
-
};
|
|
50
|
-
const show = () => {
|
|
51
|
-
clearTimer();
|
|
52
|
-
if (duration) {
|
|
53
|
-
timer = window.setTimeout(() => {
|
|
54
|
-
hide();
|
|
55
|
-
}, duration * 1e3);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
const clickCover = () => {
|
|
59
|
-
if (closeOnClickOverlay) {
|
|
60
|
-
hide();
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const toastBem = cn("toast");
|
|
64
|
-
const hasIcon = () => {
|
|
65
|
-
if (type !== "text") {
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
return !!icon;
|
|
69
|
-
};
|
|
70
|
-
const iconName = () => {
|
|
71
|
-
if (icon) {
|
|
72
|
-
return icon;
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
success: React.createElement(Success, { color: "#ffffff", width: iconSize, height: iconSize }),
|
|
76
|
-
fail: React.createElement(Failure, { color: "#ffffff", width: iconSize, height: iconSize }),
|
|
77
|
-
warn: React.createElement(Tips, { color: "#ffffff", width: iconSize, height: iconSize }),
|
|
78
|
-
loading: React.createElement(Loading, { color: "#ffffff", width: iconSize, height: iconSize })
|
|
79
|
-
}[type];
|
|
80
|
-
};
|
|
81
|
-
const classes = classNames({
|
|
82
|
-
"nut-toast-center": center,
|
|
83
|
-
"nut-toast-has-icon": icon,
|
|
84
|
-
"nut-toast-cover": cover,
|
|
85
|
-
"nut-toast-loading": type === "loading",
|
|
86
|
-
[`${customClass}`]: true,
|
|
87
|
-
[`nut-toast-${size}`]: true
|
|
88
|
-
});
|
|
89
|
-
return React.createElement(React.Fragment, null, openState ? React.createElement(
|
|
90
|
-
"div",
|
|
91
|
-
{ className: `${toastBem()} ${classes}`, id, style: {
|
|
92
|
-
bottom: center ? "auto" : `${bottom}`,
|
|
93
|
-
backgroundColor: cover ? coverColor : "",
|
|
94
|
-
...style
|
|
95
|
-
}, onClick: () => {
|
|
96
|
-
clickCover();
|
|
97
|
-
} },
|
|
98
|
-
React.createElement(
|
|
99
|
-
"div",
|
|
100
|
-
{ className: toastBem("inner"), style: {
|
|
101
|
-
textAlign: textAlignCenter ? "center" : "left",
|
|
102
|
-
backgroundColor: bgColor
|
|
103
|
-
} },
|
|
104
|
-
hasIcon() ? React.createElement("p", { className: toastBem("icon-wrapper") }, iconName()) : null,
|
|
105
|
-
title ? React.createElement("div", { className: "nut-toast-title" }, title) : null,
|
|
106
|
-
React.createElement("span", { className: toastBem("text") }, msg)
|
|
107
|
-
)
|
|
108
|
-
) : null);
|
|
109
|
-
};
|
|
110
|
-
Toast.defaultProps = defaultProps;
|
|
111
|
-
Toast.displayName = "NutToast";
|
|
112
|
-
export {
|
|
113
|
-
Toast as T
|
|
114
|
-
};
|