@nutui/nutui-react-taro 2.0.8-beta.0 → 2.0.9
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 +11 -0
- package/dist/esm/Notify.js +2 -1
- package/dist/esm/{notify.taro-05bd231c.js → notify.taro-687d6f8c.js} +41 -9
- package/dist/esm/nutui-react.es.js +1 -1
- package/dist/esm/types/src/packages/notify/notify.taro.d.ts +11 -4
- package/dist/esm/types/src/utils/use-custom-event.d.ts +3 -0
- 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 +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 +65 -35
- package/dist/nutui.react.umd.js +64 -34
- package/dist/style.mjs +1 -1
- package/dist/types/packages/cascader/cascader.taro.d.ts +5 -1
- package/dist/types/packages/notify/notify.taro.d.ts +11 -4
- package/dist/types/utils/use-custom-event.d.ts +3 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
# v2.0.9
|
|
2
|
+
`2023-08-02`
|
|
3
|
+
|
|
4
|
+
* :sparkles: feat(notify): 支持函数调用的展开和关闭 (#1271) @oasis-cloud
|
|
5
|
+
* :bug: fix: space 版本号修改为 2.0 (#1265) @oasis-cloud
|
|
6
|
+
* 🔨 chore(config): 优化 taro demo 环境配置文件 (#1266) @oasis-cloud
|
|
7
|
+
* 📖 docs: cascader 文档更新 (#1270) @vapao
|
|
8
|
+
* 📖 docs: tag 文档和 demo 同步 (#1275) @oasis-cloud
|
|
9
|
+
* 📖 docs: 升级文档更新 (#1274) @oasis-cloud
|
|
10
|
+
|
|
11
|
+
|
|
1
12
|
# v2.0.8
|
|
2
13
|
`2023-07-28`
|
|
3
14
|
|
package/dist/esm/Notify.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { N as Notify } from "./notify.taro-
|
|
1
|
+
import { N as Notify } from "./notify.taro-687d6f8c.js";
|
|
2
2
|
import "react";
|
|
3
3
|
import "classnames";
|
|
4
4
|
import "react-transition-group";
|
|
5
5
|
import "./typings-11d83a22.js";
|
|
6
|
+
import "@tarojs/taro";
|
|
6
7
|
export {
|
|
7
8
|
Notify as default
|
|
8
9
|
};
|
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
import React__default, {
|
|
1
|
+
import React__default, { useEffect, useState } from "react";
|
|
2
2
|
import classNames from "classnames";
|
|
3
3
|
import { CSSTransition } from "react-transition-group";
|
|
4
4
|
import { C as ComponentDefaults } from "./typings-11d83a22.js";
|
|
5
|
+
import { Events, getCurrentInstance } from "@tarojs/taro";
|
|
6
|
+
const customEvents = new Events();
|
|
7
|
+
function useCustomEventsPath(selector) {
|
|
8
|
+
var _a;
|
|
9
|
+
const path = (_a = getCurrentInstance().router) == null ? void 0 : _a.path;
|
|
10
|
+
return path ? `${path}__${selector}` : selector;
|
|
11
|
+
}
|
|
12
|
+
function useCustomEvent(selector, cb) {
|
|
13
|
+
const path = useCustomEventsPath(selector);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
customEvents.on(path, cb);
|
|
16
|
+
return () => {
|
|
17
|
+
customEvents.off(path);
|
|
18
|
+
};
|
|
19
|
+
}, []);
|
|
20
|
+
const trigger = (args) => {
|
|
21
|
+
customEvents.trigger(path, args);
|
|
22
|
+
};
|
|
23
|
+
const off = () => {
|
|
24
|
+
customEvents.off(path);
|
|
25
|
+
};
|
|
26
|
+
return [trigger, off];
|
|
27
|
+
}
|
|
5
28
|
const defaultProps = {
|
|
6
29
|
...ComponentDefaults,
|
|
7
30
|
id: "",
|
|
@@ -16,12 +39,14 @@ const defaultProps = {
|
|
|
16
39
|
};
|
|
17
40
|
const classPrefix = "nut-notify";
|
|
18
41
|
const Notify = (props) => {
|
|
19
|
-
const { id, children, style, type, className, position, visible, duration, onClose, onClick
|
|
42
|
+
const { id, children, style, type, className, position, visible, duration, onClose, onClick } = { ...defaultProps, ...props };
|
|
43
|
+
useCustomEvent(id, (status) => {
|
|
44
|
+
status ? show() : hide();
|
|
45
|
+
});
|
|
20
46
|
let timer;
|
|
21
|
-
const [showNotify,
|
|
47
|
+
const [showNotify, setShowNotify] = useState(false);
|
|
22
48
|
useEffect(() => {
|
|
23
49
|
if (visible) {
|
|
24
|
-
SetShow(true);
|
|
25
50
|
show();
|
|
26
51
|
} else {
|
|
27
52
|
hide();
|
|
@@ -31,6 +56,7 @@ const Notify = (props) => {
|
|
|
31
56
|
onClick();
|
|
32
57
|
};
|
|
33
58
|
const show = () => {
|
|
59
|
+
setShowNotify(true);
|
|
34
60
|
clearTimer();
|
|
35
61
|
if (duration) {
|
|
36
62
|
timer = window.setTimeout(() => {
|
|
@@ -45,11 +71,7 @@ const Notify = (props) => {
|
|
|
45
71
|
}
|
|
46
72
|
};
|
|
47
73
|
const hide = () => {
|
|
48
|
-
|
|
49
|
-
if (id) {
|
|
50
|
-
const element = document.getElementById(id);
|
|
51
|
-
element && element.parentNode && element.parentNode.removeChild(element);
|
|
52
|
-
}
|
|
74
|
+
setShowNotify(false);
|
|
53
75
|
onClose();
|
|
54
76
|
};
|
|
55
77
|
const classes = classNames({
|
|
@@ -68,8 +90,18 @@ const Notify = (props) => {
|
|
|
68
90
|
)
|
|
69
91
|
);
|
|
70
92
|
};
|
|
93
|
+
function open(selector) {
|
|
94
|
+
const path = useCustomEventsPath(selector);
|
|
95
|
+
customEvents.trigger(path, true);
|
|
96
|
+
}
|
|
97
|
+
function close(selector) {
|
|
98
|
+
const path = useCustomEventsPath(selector);
|
|
99
|
+
customEvents.trigger(path, false);
|
|
100
|
+
}
|
|
71
101
|
Notify.defaultProps = defaultProps;
|
|
72
102
|
Notify.displayName = "NutNotify";
|
|
103
|
+
Notify.open = open;
|
|
104
|
+
Notify.close = close;
|
|
73
105
|
export {
|
|
74
106
|
Notify as N
|
|
75
107
|
};
|
|
@@ -53,7 +53,7 @@ import { D as D3 } from "./drag.taro-ce333e51.js";
|
|
|
53
53
|
import { E as E2 } from "./empty.taro-bfe29449.js";
|
|
54
54
|
import { I as I4 } from "./infiniteloading.taro-87006d3e.js";
|
|
55
55
|
import { N as N3 } from "./noticebar.taro-d95c13b6.js";
|
|
56
|
-
import { N as N4 } from "./notify.taro-
|
|
56
|
+
import { N as N4 } from "./notify.taro-687d6f8c.js";
|
|
57
57
|
import { P as P2 } from "./popover.taro-fbf1ba5e.js";
|
|
58
58
|
import { P as P3 } from "./popup.taro-6ecef0f4.js";
|
|
59
59
|
import { P as P4 } from "./pulltorefresh.taro-efb36521.js";
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
2
|
import { BasicComponent } from '@/utils/typings';
|
|
3
|
+
export type NotifyPosition = 'top' | 'bottom';
|
|
4
|
+
export type NotifyType = 'primary' | 'success' | 'danger' | 'waring';
|
|
3
5
|
export interface NotifyProps extends BasicComponent {
|
|
4
6
|
id?: string;
|
|
5
7
|
duration: number;
|
|
6
|
-
type:
|
|
7
|
-
position:
|
|
8
|
+
type: NotifyType;
|
|
9
|
+
position: NotifyPosition;
|
|
8
10
|
visible: boolean;
|
|
9
11
|
onClose: () => void;
|
|
10
12
|
onClick: () => void;
|
|
11
13
|
}
|
|
12
|
-
export declare const Notify: FunctionComponent<Partial<NotifyProps
|
|
14
|
+
export declare const Notify: FunctionComponent<Partial<NotifyProps>> & {
|
|
15
|
+
open: typeof open;
|
|
16
|
+
close: typeof close;
|
|
17
|
+
};
|
|
18
|
+
export declare function open(selector: string): void;
|
|
19
|
+
export declare function close(selector: string): void;
|
package/dist/locales/base.js
CHANGED
package/dist/locales/en-US.js
CHANGED
package/dist/locales/id-ID.js
CHANGED
package/dist/locales/tr-TR.js
CHANGED
package/dist/locales/zh-CN.js
CHANGED
package/dist/locales/zh-TW.js
CHANGED
package/dist/locales/zh-UG.js
CHANGED
package/dist/nutui.react.es.js
CHANGED
|
@@ -5,13 +5,13 @@ var __publicField = (obj, key, value) => {
|
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
7
|
/*!
|
|
8
|
-
* @nutui/nutui-react-taro v2.0.
|
|
8
|
+
* @nutui/nutui-react-taro v2.0.9 Wed Aug 02 2023 15:38:56 GMT+0800 (China Standard Time)
|
|
9
9
|
* (c) 2023 @jdf2e.
|
|
10
10
|
* Released under the MIT License.
|
|
11
11
|
*/
|
|
12
12
|
import * as React from "react";
|
|
13
13
|
import React__default, { useCallback, createContext, useContext, useState, useEffect, useRef, useMemo as useMemo$1, isValidElement, forwardRef, useImperativeHandle, Component, Children } from "react";
|
|
14
|
-
import Taro, { getEnv, usePageScroll, getSystemInfoSync, pageScrollTo, nextTick, createSelectorQuery, ENV_TYPE, canvasToTempFilePath, uploadFile, chooseMedia, chooseImage, useReady, createInnerAudioContext, getSystemInfo, createOffscreenCanvas } from "@tarojs/taro";
|
|
14
|
+
import Taro, { getEnv, usePageScroll, getSystemInfoSync, pageScrollTo, nextTick, createSelectorQuery, ENV_TYPE, canvasToTempFilePath, uploadFile, chooseMedia, chooseImage, Events, getCurrentInstance, useReady, createInnerAudioContext, getSystemInfo, createOffscreenCanvas } from "@tarojs/taro";
|
|
15
15
|
import { Image as Image$2, View, ScrollView, PickerView, PickerViewColumn, Input as Input$1, Textarea, Swiper as Swiper$1, SwiperItem as SwiperItem$1, Video as Video$1 } from "@tarojs/components";
|
|
16
16
|
import ReactDOM, { createPortal } from "react-dom";
|
|
17
17
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
@@ -6097,7 +6097,7 @@ const Popup = (props) => {
|
|
|
6097
6097
|
[`${classPrefix2}__close-icon`]: true,
|
|
6098
6098
|
[`${classPrefix2}__close-icon--${closeIconPosition}`]: true
|
|
6099
6099
|
});
|
|
6100
|
-
const
|
|
6100
|
+
const open2 = () => {
|
|
6101
6101
|
if (!innerVisible) {
|
|
6102
6102
|
setInnerVisible(true);
|
|
6103
6103
|
setIndex(++_zIndex);
|
|
@@ -6107,7 +6107,7 @@ const Popup = (props) => {
|
|
|
6107
6107
|
}
|
|
6108
6108
|
onOpen && onOpen();
|
|
6109
6109
|
};
|
|
6110
|
-
const
|
|
6110
|
+
const close2 = () => {
|
|
6111
6111
|
if (innerVisible) {
|
|
6112
6112
|
setInnerVisible(false);
|
|
6113
6113
|
if (destroyOnClose) {
|
|
@@ -6122,7 +6122,7 @@ const Popup = (props) => {
|
|
|
6122
6122
|
e.stopPropagation();
|
|
6123
6123
|
if (closeOnOverlayClick) {
|
|
6124
6124
|
const closed = onOverlayClick && onOverlayClick(e);
|
|
6125
|
-
closed &&
|
|
6125
|
+
closed && close2();
|
|
6126
6126
|
}
|
|
6127
6127
|
};
|
|
6128
6128
|
const onHandleClick = (e) => {
|
|
@@ -6130,7 +6130,7 @@ const Popup = (props) => {
|
|
|
6130
6130
|
};
|
|
6131
6131
|
const onHandleClickCloseIcon = (e) => {
|
|
6132
6132
|
const closed = onCloseIconClick && onCloseIconClick(e);
|
|
6133
|
-
closed &&
|
|
6133
|
+
closed && close2();
|
|
6134
6134
|
};
|
|
6135
6135
|
const onHandleOpened = (e) => {
|
|
6136
6136
|
afterShow && afterShow();
|
|
@@ -6198,8 +6198,8 @@ const Popup = (props) => {
|
|
|
6198
6198
|
), renderPop()) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, renderPop()));
|
|
6199
6199
|
};
|
|
6200
6200
|
useEffect(() => {
|
|
6201
|
-
visible &&
|
|
6202
|
-
!visible &&
|
|
6201
|
+
visible && open2();
|
|
6202
|
+
!visible && close2();
|
|
6203
6203
|
}, [visible]);
|
|
6204
6204
|
useEffect(() => {
|
|
6205
6205
|
setTransitionName(transition || `${classPrefix2}-slide-${position}`);
|
|
@@ -6290,11 +6290,11 @@ const defaultProps$1a = {
|
|
|
6290
6290
|
};
|
|
6291
6291
|
const SubSideNavBar = (props) => {
|
|
6292
6292
|
const classPrefix2 = "nut-subsidenavbar";
|
|
6293
|
-
const { title, value, children, onClick, open, ...rest } = {
|
|
6293
|
+
const { title, value, children, onClick, open: open2, ...rest } = {
|
|
6294
6294
|
...defaultProps$1a,
|
|
6295
6295
|
...props
|
|
6296
6296
|
};
|
|
6297
|
-
const [subShow, setSubShow] = useState(
|
|
6297
|
+
const [subShow, setSubShow] = useState(open2);
|
|
6298
6298
|
const offset = useContext(OffsetContext);
|
|
6299
6299
|
const listRef = useRef(null);
|
|
6300
6300
|
const setListLevel = useCallback(
|
|
@@ -7206,11 +7206,11 @@ const InternalCascader = (props, ref) => {
|
|
|
7206
7206
|
node.loading = false;
|
|
7207
7207
|
state.lazyLoadMap.delete(node);
|
|
7208
7208
|
};
|
|
7209
|
-
const
|
|
7209
|
+
const close2 = () => {
|
|
7210
7210
|
onClose && onClose();
|
|
7211
7211
|
};
|
|
7212
7212
|
const closePopup = () => {
|
|
7213
|
-
|
|
7213
|
+
close2();
|
|
7214
7214
|
};
|
|
7215
7215
|
const chooseItem = async (node, type4) => {
|
|
7216
7216
|
if (!type4 && node.disabled || !state.panes[state.tabsCursor]) {
|
|
@@ -7228,7 +7228,7 @@ const InternalCascader = (props, ref) => {
|
|
|
7228
7228
|
setInnerValue(optionParams);
|
|
7229
7229
|
}
|
|
7230
7230
|
setOptionsData(state.panes);
|
|
7231
|
-
|
|
7231
|
+
close2();
|
|
7232
7232
|
return;
|
|
7233
7233
|
}
|
|
7234
7234
|
if (state.tree.hasChildren(node, isLazy())) {
|
|
@@ -8466,15 +8466,15 @@ const Calendar = React__default.forwardRef((props, ref) => {
|
|
|
8466
8466
|
onPageChange
|
|
8467
8467
|
} = { ...defaultProps$$, ...props };
|
|
8468
8468
|
const calendarRef = useRef(null);
|
|
8469
|
-
const
|
|
8469
|
+
const close2 = () => {
|
|
8470
8470
|
onClose && onClose();
|
|
8471
8471
|
};
|
|
8472
8472
|
const choose = (param) => {
|
|
8473
|
-
|
|
8473
|
+
close2();
|
|
8474
8474
|
onConfirm && onConfirm(param);
|
|
8475
8475
|
};
|
|
8476
8476
|
const closePopup = () => {
|
|
8477
|
-
|
|
8477
|
+
close2();
|
|
8478
8478
|
};
|
|
8479
8479
|
const select = (param) => {
|
|
8480
8480
|
onDayClick && onDayClick(param);
|
|
@@ -14469,7 +14469,7 @@ const NoticeBar = (props) => {
|
|
|
14469
14469
|
delay,
|
|
14470
14470
|
scrollable,
|
|
14471
14471
|
speed,
|
|
14472
|
-
close,
|
|
14472
|
+
close: close2,
|
|
14473
14473
|
click,
|
|
14474
14474
|
onClose,
|
|
14475
14475
|
onClick,
|
|
@@ -14584,7 +14584,7 @@ const NoticeBar = (props) => {
|
|
|
14584
14584
|
const onClickIcon = (event) => {
|
|
14585
14585
|
event.stopPropagation();
|
|
14586
14586
|
SetShowNoticeBar(!closeable);
|
|
14587
|
-
|
|
14587
|
+
close2 && close2(event);
|
|
14588
14588
|
onClose && onClose(event);
|
|
14589
14589
|
};
|
|
14590
14590
|
const onAnimationEnd = () => {
|
|
@@ -14612,7 +14612,7 @@ const NoticeBar = (props) => {
|
|
|
14612
14612
|
const handleClickIcon = (event) => {
|
|
14613
14613
|
event.stopPropagation();
|
|
14614
14614
|
SetShowNoticeBar(!closeable);
|
|
14615
|
-
|
|
14615
|
+
close2 && close2(event);
|
|
14616
14616
|
onClose && onClose(event);
|
|
14617
14617
|
};
|
|
14618
14618
|
const isEllipsis = () => {
|
|
@@ -14839,6 +14839,28 @@ const NoticeBar = (props) => {
|
|
|
14839
14839
|
};
|
|
14840
14840
|
NoticeBar.defaultProps = defaultProps$z;
|
|
14841
14841
|
NoticeBar.displayName = "NutNoticeBar";
|
|
14842
|
+
const customEvents = new Events();
|
|
14843
|
+
function useCustomEventsPath(selector) {
|
|
14844
|
+
var _a;
|
|
14845
|
+
const path = (_a = getCurrentInstance().router) == null ? void 0 : _a.path;
|
|
14846
|
+
return path ? `${path}__${selector}` : selector;
|
|
14847
|
+
}
|
|
14848
|
+
function useCustomEvent(selector, cb) {
|
|
14849
|
+
const path = useCustomEventsPath(selector);
|
|
14850
|
+
useEffect(() => {
|
|
14851
|
+
customEvents.on(path, cb);
|
|
14852
|
+
return () => {
|
|
14853
|
+
customEvents.off(path);
|
|
14854
|
+
};
|
|
14855
|
+
}, []);
|
|
14856
|
+
const trigger = (args) => {
|
|
14857
|
+
customEvents.trigger(path, args);
|
|
14858
|
+
};
|
|
14859
|
+
const off = () => {
|
|
14860
|
+
customEvents.off(path);
|
|
14861
|
+
};
|
|
14862
|
+
return [trigger, off];
|
|
14863
|
+
}
|
|
14842
14864
|
const defaultProps$y = {
|
|
14843
14865
|
...ComponentDefaults,
|
|
14844
14866
|
id: "",
|
|
@@ -14864,14 +14886,15 @@ const Notify = (props) => {
|
|
|
14864
14886
|
visible,
|
|
14865
14887
|
duration,
|
|
14866
14888
|
onClose,
|
|
14867
|
-
onClick
|
|
14868
|
-
...rest
|
|
14889
|
+
onClick
|
|
14869
14890
|
} = { ...defaultProps$y, ...props };
|
|
14891
|
+
useCustomEvent(id, (status) => {
|
|
14892
|
+
status ? show() : hide();
|
|
14893
|
+
});
|
|
14870
14894
|
let timer;
|
|
14871
|
-
const [showNotify,
|
|
14895
|
+
const [showNotify, setShowNotify] = useState(false);
|
|
14872
14896
|
useEffect(() => {
|
|
14873
14897
|
if (visible) {
|
|
14874
|
-
SetShow(true);
|
|
14875
14898
|
show();
|
|
14876
14899
|
} else {
|
|
14877
14900
|
hide();
|
|
@@ -14881,6 +14904,7 @@ const Notify = (props) => {
|
|
|
14881
14904
|
onClick();
|
|
14882
14905
|
};
|
|
14883
14906
|
const show = () => {
|
|
14907
|
+
setShowNotify(true);
|
|
14884
14908
|
clearTimer();
|
|
14885
14909
|
if (duration) {
|
|
14886
14910
|
timer = window.setTimeout(() => {
|
|
@@ -14895,11 +14919,7 @@ const Notify = (props) => {
|
|
|
14895
14919
|
}
|
|
14896
14920
|
};
|
|
14897
14921
|
const hide = () => {
|
|
14898
|
-
|
|
14899
|
-
if (id) {
|
|
14900
|
-
const element = document.getElementById(id);
|
|
14901
|
-
element && element.parentNode && element.parentNode.removeChild(element);
|
|
14902
|
-
}
|
|
14922
|
+
setShowNotify(false);
|
|
14903
14923
|
onClose();
|
|
14904
14924
|
};
|
|
14905
14925
|
const classes = classNames({
|
|
@@ -14930,8 +14950,18 @@ const Notify = (props) => {
|
|
|
14930
14950
|
)
|
|
14931
14951
|
));
|
|
14932
14952
|
};
|
|
14953
|
+
function open(selector) {
|
|
14954
|
+
const path = useCustomEventsPath(selector);
|
|
14955
|
+
customEvents.trigger(path, true);
|
|
14956
|
+
}
|
|
14957
|
+
function close(selector) {
|
|
14958
|
+
const path = useCustomEventsPath(selector);
|
|
14959
|
+
customEvents.trigger(path, false);
|
|
14960
|
+
}
|
|
14933
14961
|
Notify.defaultProps = defaultProps$y;
|
|
14934
14962
|
Notify.displayName = "NutNotify";
|
|
14963
|
+
Notify.open = open;
|
|
14964
|
+
Notify.close = close;
|
|
14935
14965
|
const defaultProps$x = {
|
|
14936
14966
|
...ComponentDefaults,
|
|
14937
14967
|
list: [],
|
|
@@ -15604,12 +15634,12 @@ const Swipe = forwardRef((props, instanceRef) => {
|
|
|
15604
15634
|
const baseNum = opened ? 1 - base : base;
|
|
15605
15635
|
const width = side === "left" ? leftWidth : rightWidth;
|
|
15606
15636
|
if (width && offset > Number(width) * baseNum) {
|
|
15607
|
-
|
|
15637
|
+
open2(side);
|
|
15608
15638
|
} else {
|
|
15609
|
-
|
|
15639
|
+
close2(side);
|
|
15610
15640
|
}
|
|
15611
15641
|
};
|
|
15612
|
-
const
|
|
15642
|
+
const open2 = (side) => {
|
|
15613
15643
|
var _a;
|
|
15614
15644
|
opened.current = true;
|
|
15615
15645
|
const offset = side === "left" ? leftWidth : -rightWidth;
|
|
@@ -15617,7 +15647,7 @@ const Swipe = forwardRef((props, instanceRef) => {
|
|
|
15617
15647
|
(_a = props.onOpen) == null ? void 0 : _a.call(props, { name, position: side });
|
|
15618
15648
|
setState((v) => ({ ...v, offset: Number(offset) || 0 }));
|
|
15619
15649
|
};
|
|
15620
|
-
const
|
|
15650
|
+
const close2 = (position) => {
|
|
15621
15651
|
var _a;
|
|
15622
15652
|
if (opened.current) {
|
|
15623
15653
|
opened.current = false;
|
|
@@ -15657,8 +15687,8 @@ const Swipe = forwardRef((props, instanceRef) => {
|
|
|
15657
15687
|
}
|
|
15658
15688
|
};
|
|
15659
15689
|
useImperativeHandle(instanceRef, () => ({
|
|
15660
|
-
open,
|
|
15661
|
-
close: () =>
|
|
15690
|
+
open: open2,
|
|
15691
|
+
close: () => close2()
|
|
15662
15692
|
}));
|
|
15663
15693
|
useEffect(() => {
|
|
15664
15694
|
const handler = (event) => {
|
|
@@ -15669,7 +15699,7 @@ const Swipe = forwardRef((props, instanceRef) => {
|
|
|
15669
15699
|
})) {
|
|
15670
15700
|
return;
|
|
15671
15701
|
}
|
|
15672
|
-
|
|
15702
|
+
close2();
|
|
15673
15703
|
};
|
|
15674
15704
|
document.addEventListener("touchstart", handler);
|
|
15675
15705
|
return () => {
|
package/dist/nutui.react.umd.js
CHANGED
|
@@ -8,7 +8,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8
8
|
return value;
|
|
9
9
|
};
|
|
10
10
|
/*!
|
|
11
|
-
* @nutui/nutui-react-taro v2.0.
|
|
11
|
+
* @nutui/nutui-react-taro v2.0.9 Wed Aug 02 2023 15:38:56 GMT+0800 (China Standard Time)
|
|
12
12
|
* (c) 2023 @jdf2e.
|
|
13
13
|
* Released under the MIT License.
|
|
14
14
|
*/
|
|
@@ -6113,7 +6113,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6113
6113
|
[`${classPrefix2}__close-icon`]: true,
|
|
6114
6114
|
[`${classPrefix2}__close-icon--${closeIconPosition}`]: true
|
|
6115
6115
|
});
|
|
6116
|
-
const
|
|
6116
|
+
const open2 = () => {
|
|
6117
6117
|
if (!innerVisible) {
|
|
6118
6118
|
setInnerVisible(true);
|
|
6119
6119
|
setIndex(++_zIndex);
|
|
@@ -6123,7 +6123,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6123
6123
|
}
|
|
6124
6124
|
onOpen && onOpen();
|
|
6125
6125
|
};
|
|
6126
|
-
const
|
|
6126
|
+
const close2 = () => {
|
|
6127
6127
|
if (innerVisible) {
|
|
6128
6128
|
setInnerVisible(false);
|
|
6129
6129
|
if (destroyOnClose) {
|
|
@@ -6138,7 +6138,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6138
6138
|
e.stopPropagation();
|
|
6139
6139
|
if (closeOnOverlayClick) {
|
|
6140
6140
|
const closed = onOverlayClick && onOverlayClick(e);
|
|
6141
|
-
closed &&
|
|
6141
|
+
closed && close2();
|
|
6142
6142
|
}
|
|
6143
6143
|
};
|
|
6144
6144
|
const onHandleClick = (e) => {
|
|
@@ -6146,7 +6146,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6146
6146
|
};
|
|
6147
6147
|
const onHandleClickCloseIcon = (e) => {
|
|
6148
6148
|
const closed = onCloseIconClick && onCloseIconClick(e);
|
|
6149
|
-
closed &&
|
|
6149
|
+
closed && close2();
|
|
6150
6150
|
};
|
|
6151
6151
|
const onHandleOpened = (e) => {
|
|
6152
6152
|
afterShow && afterShow();
|
|
@@ -6214,8 +6214,8 @@ var __publicField = (obj, key, value) => {
|
|
|
6214
6214
|
), renderPop()) : /* @__PURE__ */ React.createElement(React.Fragment, null, renderPop()));
|
|
6215
6215
|
};
|
|
6216
6216
|
React.useEffect(() => {
|
|
6217
|
-
visible &&
|
|
6218
|
-
!visible &&
|
|
6217
|
+
visible && open2();
|
|
6218
|
+
!visible && close2();
|
|
6219
6219
|
}, [visible]);
|
|
6220
6220
|
React.useEffect(() => {
|
|
6221
6221
|
setTransitionName(transition || `${classPrefix2}-slide-${position}`);
|
|
@@ -6306,11 +6306,11 @@ var __publicField = (obj, key, value) => {
|
|
|
6306
6306
|
};
|
|
6307
6307
|
const SubSideNavBar = (props) => {
|
|
6308
6308
|
const classPrefix2 = "nut-subsidenavbar";
|
|
6309
|
-
const { title, value, children, onClick, open, ...rest } = {
|
|
6309
|
+
const { title, value, children, onClick, open: open2, ...rest } = {
|
|
6310
6310
|
...defaultProps$1a,
|
|
6311
6311
|
...props
|
|
6312
6312
|
};
|
|
6313
|
-
const [subShow, setSubShow] = React.useState(
|
|
6313
|
+
const [subShow, setSubShow] = React.useState(open2);
|
|
6314
6314
|
const offset = React.useContext(OffsetContext);
|
|
6315
6315
|
const listRef = React.useRef(null);
|
|
6316
6316
|
const setListLevel = React.useCallback(
|
|
@@ -7222,11 +7222,11 @@ var __publicField = (obj, key, value) => {
|
|
|
7222
7222
|
node.loading = false;
|
|
7223
7223
|
state.lazyLoadMap.delete(node);
|
|
7224
7224
|
};
|
|
7225
|
-
const
|
|
7225
|
+
const close2 = () => {
|
|
7226
7226
|
onClose && onClose();
|
|
7227
7227
|
};
|
|
7228
7228
|
const closePopup = () => {
|
|
7229
|
-
|
|
7229
|
+
close2();
|
|
7230
7230
|
};
|
|
7231
7231
|
const chooseItem = async (node, type2) => {
|
|
7232
7232
|
if (!type2 && node.disabled || !state.panes[state.tabsCursor]) {
|
|
@@ -7244,7 +7244,7 @@ var __publicField = (obj, key, value) => {
|
|
|
7244
7244
|
setInnerValue(optionParams);
|
|
7245
7245
|
}
|
|
7246
7246
|
setOptionsData(state.panes);
|
|
7247
|
-
|
|
7247
|
+
close2();
|
|
7248
7248
|
return;
|
|
7249
7249
|
}
|
|
7250
7250
|
if (state.tree.hasChildren(node, isLazy())) {
|
|
@@ -8482,15 +8482,15 @@ var __publicField = (obj, key, value) => {
|
|
|
8482
8482
|
onPageChange
|
|
8483
8483
|
} = { ...defaultProps$$, ...props };
|
|
8484
8484
|
const calendarRef = React.useRef(null);
|
|
8485
|
-
const
|
|
8485
|
+
const close2 = () => {
|
|
8486
8486
|
onClose && onClose();
|
|
8487
8487
|
};
|
|
8488
8488
|
const choose = (param) => {
|
|
8489
|
-
|
|
8489
|
+
close2();
|
|
8490
8490
|
onConfirm && onConfirm(param);
|
|
8491
8491
|
};
|
|
8492
8492
|
const closePopup = () => {
|
|
8493
|
-
|
|
8493
|
+
close2();
|
|
8494
8494
|
};
|
|
8495
8495
|
const select = (param) => {
|
|
8496
8496
|
onDayClick && onDayClick(param);
|
|
@@ -14485,7 +14485,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14485
14485
|
delay,
|
|
14486
14486
|
scrollable,
|
|
14487
14487
|
speed,
|
|
14488
|
-
close,
|
|
14488
|
+
close: close2,
|
|
14489
14489
|
click,
|
|
14490
14490
|
onClose,
|
|
14491
14491
|
onClick,
|
|
@@ -14600,7 +14600,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14600
14600
|
const onClickIcon = (event) => {
|
|
14601
14601
|
event.stopPropagation();
|
|
14602
14602
|
SetShowNoticeBar(!closeable);
|
|
14603
|
-
|
|
14603
|
+
close2 && close2(event);
|
|
14604
14604
|
onClose && onClose(event);
|
|
14605
14605
|
};
|
|
14606
14606
|
const onAnimationEnd = () => {
|
|
@@ -14628,7 +14628,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14628
14628
|
const handleClickIcon = (event) => {
|
|
14629
14629
|
event.stopPropagation();
|
|
14630
14630
|
SetShowNoticeBar(!closeable);
|
|
14631
|
-
|
|
14631
|
+
close2 && close2(event);
|
|
14632
14632
|
onClose && onClose(event);
|
|
14633
14633
|
};
|
|
14634
14634
|
const isEllipsis = () => {
|
|
@@ -14855,6 +14855,28 @@ var __publicField = (obj, key, value) => {
|
|
|
14855
14855
|
};
|
|
14856
14856
|
NoticeBar.defaultProps = defaultProps$z;
|
|
14857
14857
|
NoticeBar.displayName = "NutNoticeBar";
|
|
14858
|
+
const customEvents = new Taro.Events();
|
|
14859
|
+
function useCustomEventsPath(selector) {
|
|
14860
|
+
var _a;
|
|
14861
|
+
const path = (_a = Taro.getCurrentInstance().router) == null ? void 0 : _a.path;
|
|
14862
|
+
return path ? `${path}__${selector}` : selector;
|
|
14863
|
+
}
|
|
14864
|
+
function useCustomEvent(selector, cb) {
|
|
14865
|
+
const path = useCustomEventsPath(selector);
|
|
14866
|
+
React.useEffect(() => {
|
|
14867
|
+
customEvents.on(path, cb);
|
|
14868
|
+
return () => {
|
|
14869
|
+
customEvents.off(path);
|
|
14870
|
+
};
|
|
14871
|
+
}, []);
|
|
14872
|
+
const trigger = (args) => {
|
|
14873
|
+
customEvents.trigger(path, args);
|
|
14874
|
+
};
|
|
14875
|
+
const off = () => {
|
|
14876
|
+
customEvents.off(path);
|
|
14877
|
+
};
|
|
14878
|
+
return [trigger, off];
|
|
14879
|
+
}
|
|
14858
14880
|
const defaultProps$y = {
|
|
14859
14881
|
...ComponentDefaults,
|
|
14860
14882
|
id: "",
|
|
@@ -14880,14 +14902,15 @@ var __publicField = (obj, key, value) => {
|
|
|
14880
14902
|
visible,
|
|
14881
14903
|
duration,
|
|
14882
14904
|
onClose,
|
|
14883
|
-
onClick
|
|
14884
|
-
...rest
|
|
14905
|
+
onClick
|
|
14885
14906
|
} = { ...defaultProps$y, ...props };
|
|
14907
|
+
useCustomEvent(id, (status) => {
|
|
14908
|
+
status ? show() : hide();
|
|
14909
|
+
});
|
|
14886
14910
|
let timer;
|
|
14887
|
-
const [showNotify,
|
|
14911
|
+
const [showNotify, setShowNotify] = React.useState(false);
|
|
14888
14912
|
React.useEffect(() => {
|
|
14889
14913
|
if (visible) {
|
|
14890
|
-
SetShow(true);
|
|
14891
14914
|
show();
|
|
14892
14915
|
} else {
|
|
14893
14916
|
hide();
|
|
@@ -14897,6 +14920,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14897
14920
|
onClick();
|
|
14898
14921
|
};
|
|
14899
14922
|
const show = () => {
|
|
14923
|
+
setShowNotify(true);
|
|
14900
14924
|
clearTimer();
|
|
14901
14925
|
if (duration) {
|
|
14902
14926
|
timer = window.setTimeout(() => {
|
|
@@ -14911,11 +14935,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14911
14935
|
}
|
|
14912
14936
|
};
|
|
14913
14937
|
const hide = () => {
|
|
14914
|
-
|
|
14915
|
-
if (id) {
|
|
14916
|
-
const element = document.getElementById(id);
|
|
14917
|
-
element && element.parentNode && element.parentNode.removeChild(element);
|
|
14918
|
-
}
|
|
14938
|
+
setShowNotify(false);
|
|
14919
14939
|
onClose();
|
|
14920
14940
|
};
|
|
14921
14941
|
const classes = classNames({
|
|
@@ -14946,8 +14966,18 @@ var __publicField = (obj, key, value) => {
|
|
|
14946
14966
|
)
|
|
14947
14967
|
));
|
|
14948
14968
|
};
|
|
14969
|
+
function open(selector) {
|
|
14970
|
+
const path = useCustomEventsPath(selector);
|
|
14971
|
+
customEvents.trigger(path, true);
|
|
14972
|
+
}
|
|
14973
|
+
function close(selector) {
|
|
14974
|
+
const path = useCustomEventsPath(selector);
|
|
14975
|
+
customEvents.trigger(path, false);
|
|
14976
|
+
}
|
|
14949
14977
|
Notify.defaultProps = defaultProps$y;
|
|
14950
14978
|
Notify.displayName = "NutNotify";
|
|
14979
|
+
Notify.open = open;
|
|
14980
|
+
Notify.close = close;
|
|
14951
14981
|
const defaultProps$x = {
|
|
14952
14982
|
...ComponentDefaults,
|
|
14953
14983
|
list: [],
|
|
@@ -15620,12 +15650,12 @@ var __publicField = (obj, key, value) => {
|
|
|
15620
15650
|
const baseNum = opened ? 1 - base : base;
|
|
15621
15651
|
const width = side === "left" ? leftWidth : rightWidth;
|
|
15622
15652
|
if (width && offset > Number(width) * baseNum) {
|
|
15623
|
-
|
|
15653
|
+
open2(side);
|
|
15624
15654
|
} else {
|
|
15625
|
-
|
|
15655
|
+
close2(side);
|
|
15626
15656
|
}
|
|
15627
15657
|
};
|
|
15628
|
-
const
|
|
15658
|
+
const open2 = (side) => {
|
|
15629
15659
|
var _a;
|
|
15630
15660
|
opened.current = true;
|
|
15631
15661
|
const offset = side === "left" ? leftWidth : -rightWidth;
|
|
@@ -15633,7 +15663,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15633
15663
|
(_a = props.onOpen) == null ? void 0 : _a.call(props, { name, position: side });
|
|
15634
15664
|
setState((v) => ({ ...v, offset: Number(offset) || 0 }));
|
|
15635
15665
|
};
|
|
15636
|
-
const
|
|
15666
|
+
const close2 = (position) => {
|
|
15637
15667
|
var _a;
|
|
15638
15668
|
if (opened.current) {
|
|
15639
15669
|
opened.current = false;
|
|
@@ -15673,8 +15703,8 @@ var __publicField = (obj, key, value) => {
|
|
|
15673
15703
|
}
|
|
15674
15704
|
};
|
|
15675
15705
|
React.useImperativeHandle(instanceRef, () => ({
|
|
15676
|
-
open,
|
|
15677
|
-
close: () =>
|
|
15706
|
+
open: open2,
|
|
15707
|
+
close: () => close2()
|
|
15678
15708
|
}));
|
|
15679
15709
|
React.useEffect(() => {
|
|
15680
15710
|
const handler = (event) => {
|
|
@@ -15685,7 +15715,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15685
15715
|
})) {
|
|
15686
15716
|
return;
|
|
15687
15717
|
}
|
|
15688
|
-
|
|
15718
|
+
close2();
|
|
15689
15719
|
};
|
|
15690
15720
|
document.addEventListener("touchstart", handler);
|
|
15691
15721
|
return () => {
|
package/dist/style.mjs
CHANGED
|
@@ -37,7 +37,11 @@ export interface CascaderProps extends PopupProps {
|
|
|
37
37
|
* @default -
|
|
38
38
|
*/
|
|
39
39
|
defaultValue?: CascaderValue
|
|
40
|
-
|
|
40
|
+
/**
|
|
41
|
+
* 自定义options中的关键字,valueKey、textKey、childrenKey
|
|
42
|
+
* @default {valueKey: 'value', textKey: 'text', childrenKey: 'children'}
|
|
43
|
+
*/
|
|
44
|
+
optionKey: CascaderOptionKey
|
|
41
45
|
/**
|
|
42
46
|
* 当options为可转换为树形结构的扁平结构时,配置转换规则
|
|
43
47
|
* @default -
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
2
|
import { BasicComponent } from '../../utils/typings';
|
|
3
|
+
export type NotifyPosition = 'top' | 'bottom';
|
|
4
|
+
export type NotifyType = 'primary' | 'success' | 'danger' | 'waring';
|
|
3
5
|
export interface NotifyProps extends BasicComponent {
|
|
4
6
|
id?: string;
|
|
5
7
|
/**
|
|
@@ -11,12 +13,12 @@ export interface NotifyProps extends BasicComponent {
|
|
|
11
13
|
* 提示的信息类型(primary,success ,danger,warning)
|
|
12
14
|
* @default danger
|
|
13
15
|
*/
|
|
14
|
-
type:
|
|
16
|
+
type: NotifyType
|
|
15
17
|
/**
|
|
16
18
|
* 自定义位置 (top, bottom)
|
|
17
19
|
* @default top
|
|
18
20
|
*/
|
|
19
|
-
position:
|
|
21
|
+
position: NotifyPosition
|
|
20
22
|
/**
|
|
21
23
|
* 消息框是否展示
|
|
22
24
|
* @default false
|
|
@@ -33,4 +35,9 @@ export interface NotifyProps extends BasicComponent {
|
|
|
33
35
|
*/
|
|
34
36
|
onClick: () => void
|
|
35
37
|
}
|
|
36
|
-
export declare const Notify: FunctionComponent<Partial<NotifyProps
|
|
38
|
+
export declare const Notify: FunctionComponent<Partial<NotifyProps>> & {
|
|
39
|
+
open: typeof open;
|
|
40
|
+
close: typeof close;
|
|
41
|
+
};
|
|
42
|
+
export declare function open(selector: string): void;
|
|
43
|
+
export declare function close(selector: string): void;
|