@tendaui/react 1.1.1
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/LICENSE +21 -0
- package/README.md +2 -0
- package/es/_chunks/dep-0QH2Ee4R.js +34 -0
- package/es/_chunks/dep-0QH2Ee4R.js.map +1 -0
- package/es/_chunks/dep-B7HmDtze.js +199 -0
- package/es/_chunks/dep-B7HmDtze.js.map +1 -0
- package/es/_chunks/dep-BH5n5r1M.js +55 -0
- package/es/_chunks/dep-BH5n5r1M.js.map +1 -0
- package/es/_chunks/dep-BP0-apUT.js +9 -0
- package/es/_chunks/dep-BP0-apUT.js.map +1 -0
- package/es/_chunks/dep-C1XcmShP.js +18 -0
- package/es/_chunks/dep-C1XcmShP.js.map +1 -0
- package/es/_chunks/dep-C36au4Ip.js +104 -0
- package/es/_chunks/dep-C36au4Ip.js.map +1 -0
- package/es/_chunks/dep-CgyDw_YI.js +20 -0
- package/es/_chunks/dep-CgyDw_YI.js.map +1 -0
- package/es/_chunks/dep-CoIiHOgo.js +162 -0
- package/es/_chunks/dep-CoIiHOgo.js.map +1 -0
- package/es/_chunks/dep-Cwish4GD.js +29 -0
- package/es/_chunks/dep-Cwish4GD.js.map +1 -0
- package/es/_chunks/dep-CzLhKWCf.js +56 -0
- package/es/_chunks/dep-CzLhKWCf.js.map +1 -0
- package/es/_chunks/dep-D-UKOauR.js +12 -0
- package/es/_chunks/dep-D-UKOauR.js.map +1 -0
- package/es/_chunks/dep-D6YxJv-F.js +31 -0
- package/es/_chunks/dep-D6YxJv-F.js.map +1 -0
- package/es/_chunks/dep-D7LanWes.js +171 -0
- package/es/_chunks/dep-D7LanWes.js.map +1 -0
- package/es/_chunks/dep-D8jki30S.js +31 -0
- package/es/_chunks/dep-D8jki30S.js.map +1 -0
- package/es/_chunks/dep-DB5wmwh1.js +48 -0
- package/es/_chunks/dep-DB5wmwh1.js.map +1 -0
- package/es/_chunks/dep-DGvfel3I.js +16 -0
- package/es/_chunks/dep-DGvfel3I.js.map +1 -0
- package/es/_chunks/dep-DHWwZ2Nj.js +139 -0
- package/es/_chunks/dep-DHWwZ2Nj.js.map +1 -0
- package/es/_chunks/dep-DN7d1SzH.js +24 -0
- package/es/_chunks/dep-DN7d1SzH.js.map +1 -0
- package/es/_chunks/dep-DZ_0EvBk.js +440 -0
- package/es/_chunks/dep-DZ_0EvBk.js.map +1 -0
- package/es/_chunks/dep-Dk2xX8lh.js +691 -0
- package/es/_chunks/dep-Dk2xX8lh.js.map +1 -0
- package/es/_chunks/dep-DwWrhxkd.js +26 -0
- package/es/_chunks/dep-DwWrhxkd.js.map +1 -0
- package/es/_chunks/dep-EcrDKDlu.js +1677 -0
- package/es/_chunks/dep-EcrDKDlu.js.map +1 -0
- package/es/_chunks/dep-PPA-yoAy.js +16 -0
- package/es/_chunks/dep-PPA-yoAy.js.map +1 -0
- package/es/_chunks/dep-U1T8CQY9.js +4 -0
- package/es/_chunks/dep-U1T8CQY9.js.map +1 -0
- package/es/_chunks/dep-bWaVq_y3.js +14 -0
- package/es/_chunks/dep-bWaVq_y3.js.map +1 -0
- package/es/_chunks/dep-u1x3x6MJ.js +9 -0
- package/es/_chunks/dep-u1x3x6MJ.js.map +1 -0
- package/es/alert/Alert.js +153 -0
- package/es/alert/Alert.js.map +1 -0
- package/es/alert/index.js +23 -0
- package/es/alert/index.js.map +1 -0
- package/es/alert/style/css.js +1 -0
- package/es/alert/style/index.css +172 -0
- package/es/alert/style/index.js +2 -0
- package/es/alert/style/index.js.map +1 -0
- package/es/badge/Badge.js +81 -0
- package/es/badge/Badge.js.map +1 -0
- package/es/badge/index.js +15 -0
- package/es/badge/index.js.map +1 -0
- package/es/badge/style/css.js +1 -0
- package/es/badge/style/index.css +60 -0
- package/es/badge/style/index.js +2 -0
- package/es/badge/style/index.js.map +1 -0
- package/es/button/Button.js +94 -0
- package/es/button/Button.js.map +1 -0
- package/es/button/index.js +28 -0
- package/es/button/index.js.map +1 -0
- package/es/button/style/css.js +1 -0
- package/es/button/style/index.css +1206 -0
- package/es/button/style/index.js +2 -0
- package/es/button/style/index.js.map +1 -0
- package/es/checkbox/Checkbox.js +17 -0
- package/es/checkbox/Checkbox.js.map +1 -0
- package/es/checkbox/CheckboxGroup.js +17 -0
- package/es/checkbox/CheckboxGroup.js.map +1 -0
- package/es/checkbox/index.js +22 -0
- package/es/checkbox/index.js.map +1 -0
- package/es/checkbox/style/css.js +1 -0
- package/es/checkbox/style/index.css +151 -0
- package/es/checkbox/style/index.js +2 -0
- package/es/checkbox/style/index.js.map +1 -0
- package/es/common/Check.js +101 -0
- package/es/common/Check.js.map +1 -0
- package/es/common/FakeArrow.js +28 -0
- package/es/common/FakeArrow.js.map +1 -0
- package/es/common/PluginContainer.js +19 -0
- package/es/common/PluginContainer.js.map +1 -0
- package/es/common/Portal.js +53 -0
- package/es/common/Portal.js.map +1 -0
- package/es/config-provider/ConfigContext.js +17 -0
- package/es/config-provider/ConfigContext.js.map +1 -0
- package/es/config-provider/ConfigProvider.js +45 -0
- package/es/config-provider/ConfigProvider.js.map +1 -0
- package/es/config-provider/index.js +12 -0
- package/es/config-provider/index.js.map +1 -0
- package/es/dialog/Dialog.js +575 -0
- package/es/dialog/Dialog.js.map +1 -0
- package/es/dialog/DialogCard.js +28 -0
- package/es/dialog/DialogCard.js.map +1 -0
- package/es/dialog/index.js +44 -0
- package/es/dialog/index.js.map +1 -0
- package/es/dialog/plugin.js +199 -0
- package/es/dialog/plugin.js.map +1 -0
- package/es/dialog/style/css.js +1 -0
- package/es/dialog/style/index.css +510 -0
- package/es/dialog/style/index.js +2 -0
- package/es/dialog/style/index.js.map +1 -0
- package/es/form/Form.js +190 -0
- package/es/form/Form.js.map +1 -0
- package/es/form/FormContext.js +38 -0
- package/es/form/FormContext.js.map +1 -0
- package/es/form/FormItem.js +39 -0
- package/es/form/FormItem.js.map +1 -0
- package/es/form/FormList.js +306 -0
- package/es/form/FormList.js.map +1 -0
- package/es/form/hooks/useFormItemStyle.js +10 -0
- package/es/form/hooks/useFormItemStyle.js.map +1 -0
- package/es/form/hooks/useInstance.js +326 -0
- package/es/form/hooks/useInstance.js.map +1 -0
- package/es/form/index.js +47 -0
- package/es/form/index.js.map +1 -0
- package/es/form/style/css.js +1 -0
- package/es/form/style/index.css +296 -0
- package/es/form/style/index.js +2 -0
- package/es/form/style/index.js.map +1 -0
- package/es/form/utils/index.js +75 -0
- package/es/form/utils/index.js.map +1 -0
- package/es/hooks/useDragSorter.js +137 -0
- package/es/hooks/useDragSorter.js.map +1 -0
- package/es/index.js +103 -0
- package/es/index.js.map +1 -0
- package/es/input/Input.js +375 -0
- package/es/input/Input.js.map +1 -0
- package/es/input/InputGroup.js +23 -0
- package/es/input/InputGroup.js.map +1 -0
- package/es/input/index.js +23 -0
- package/es/input/index.js.map +1 -0
- package/es/input/style/css.js +1 -0
- package/es/input/style/index.css +450 -0
- package/es/input/style/index.js +2 -0
- package/es/input/style/index.js.map +1 -0
- package/es/loading/Gradient.js +86 -0
- package/es/loading/Gradient.js.map +1 -0
- package/es/loading/Loading.js +147 -0
- package/es/loading/Loading.js.map +1 -0
- package/es/loading/index.js +24 -0
- package/es/loading/index.js.map +1 -0
- package/es/loading/style/css.js +1 -0
- package/es/loading/style/index.css +191 -0
- package/es/loading/style/index.js +2 -0
- package/es/loading/style/index.js.map +1 -0
- package/es/myform/index.js +2 -0
- package/es/myform/index.js.map +1 -0
- package/es/notification/NotifyContainer.js +78 -0
- package/es/notification/NotifyContainer.js.map +1 -0
- package/es/notification/NotifyContext.js +149 -0
- package/es/notification/NotifyContext.js.map +1 -0
- package/es/notification/NotifyItem.js +150 -0
- package/es/notification/NotifyItem.js.map +1 -0
- package/es/notification/index.js +32 -0
- package/es/notification/index.js.map +1 -0
- package/es/notification/style/css.js +1 -0
- package/es/notification/style/index.css +142 -0
- package/es/notification/style/index.js +2 -0
- package/es/notification/style/index.js.map +1 -0
- package/es/popup/Popup.js +790 -0
- package/es/popup/Popup.js.map +1 -0
- package/es/popup/index.js +28 -0
- package/es/popup/index.js.map +1 -0
- package/es/popup/style/css.js +1 -0
- package/es/popup/style/index.css +186 -0
- package/es/popup/style/index.js +2 -0
- package/es/popup/style/index.js.map +1 -0
- package/es/portal/Portal.js +48 -0
- package/es/portal/Portal.js.map +1 -0
- package/es/portal/index.js +7 -0
- package/es/portal/index.js.map +1 -0
- package/es/select/Option.js +118 -0
- package/es/select/Option.js.map +1 -0
- package/es/select/OptionGroup.js +9 -0
- package/es/select/OptionGroup.js.map +1 -0
- package/es/select/PopupContent.js +16 -0
- package/es/select/PopupContent.js.map +1 -0
- package/es/select/Select.js +709 -0
- package/es/select/Select.js.map +1 -0
- package/es/select/index.js +66 -0
- package/es/select/index.js.map +1 -0
- package/es/select/style/css.js +1 -0
- package/es/select/style/index.css +437 -0
- package/es/select/style/index.js +2 -0
- package/es/select/style/index.js.map +1 -0
- package/es/select-input/SelectInput.js +202 -0
- package/es/select-input/SelectInput.js.map +1 -0
- package/es/select-input/hook/useMultiple.js +118 -0
- package/es/select-input/hook/useMultiple.js.map +1 -0
- package/es/select-input/hook/useSingle.js +105 -0
- package/es/select-input/hook/useSingle.js.map +1 -0
- package/es/select-input/index.js +51 -0
- package/es/select-input/index.js.map +1 -0
- package/es/select-input/style/css.js +1 -0
- package/es/select-input/style/index.css +0 -0
- package/es/select-input/style/index.js +2 -0
- package/es/select-input/style/index.js.map +1 -0
- package/es/space/index.js +2 -0
- package/es/space/index.js.map +1 -0
- package/es/style/index.css +490 -0
- package/es/style/index.js +2 -0
- package/es/style/index.js.map +1 -0
- package/es/switch/Switch.js +174 -0
- package/es/switch/Switch.js.map +1 -0
- package/es/switch/index.js +28 -0
- package/es/switch/index.js.map +1 -0
- package/es/switch/style/css.js +1 -0
- package/es/switch/style/index.css +239 -0
- package/es/switch/style/index.js +2 -0
- package/es/switch/style/index.js.map +1 -0
- package/es/tag/Tag.js +1312 -0
- package/es/tag/Tag.js.map +1 -0
- package/es/tag/index.js +21 -0
- package/es/tag/index.js.map +1 -0
- package/es/tag/style/css.js +1 -0
- package/es/tag/style/index.css +236 -0
- package/es/tag/style/index.js +2 -0
- package/es/tag/style/index.js.map +1 -0
- package/es/tag-input/TagInput.js +360 -0
- package/es/tag-input/TagInput.js.map +1 -0
- package/es/tag-input/hooks/useTagList.js +167 -0
- package/es/tag-input/hooks/useTagList.js.map +1 -0
- package/es/tag-input/index.js +35 -0
- package/es/tag-input/index.js.map +1 -0
- package/es/tag-input/style/css.js +1 -0
- package/es/tag-input/style/index.css +223 -0
- package/es/tag-input/style/index.js +2 -0
- package/es/tag-input/style/index.js.map +1 -0
- package/es/tag-input/useTagList.js +167 -0
- package/es/tag-input/useTagList.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { _ as _defineProperty } from '../_chunks/dep-Cwish4GD.js';
|
|
2
|
+
import { _ as _slicedToArray } from '../_chunks/dep-CzLhKWCf.js';
|
|
3
|
+
import React, { useState, useEffect, useMemo } from 'react';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { c as canUseDocument } from '../_chunks/dep-0QH2Ee4R.js';
|
|
6
|
+
import { u as useConfig } from '../_chunks/dep-u1x3x6MJ.js';
|
|
7
|
+
import Portal from '../common/Portal.js';
|
|
8
|
+
import GradientLoading from './Gradient.js';
|
|
9
|
+
import { u as useDefaultProps } from '../_chunks/dep-DGvfel3I.js';
|
|
10
|
+
import { a as addClass, r as removeClass } from '../_chunks/dep-BH5n5r1M.js';
|
|
11
|
+
import '../_chunks/dep-D-UKOauR.js';
|
|
12
|
+
import 'lodash-es';
|
|
13
|
+
import '../config-provider/ConfigContext.js';
|
|
14
|
+
import 'react-dom';
|
|
15
|
+
import '../_chunks/dep-DHWwZ2Nj.js';
|
|
16
|
+
import '../_chunks/dep-DN7d1SzH.js';
|
|
17
|
+
import '../_chunks/dep-PPA-yoAy.js';
|
|
18
|
+
|
|
19
|
+
var loadingDefaultProps = {
|
|
20
|
+
delay: 0,
|
|
21
|
+
fullscreen: false,
|
|
22
|
+
indicator: true,
|
|
23
|
+
inheritColor: false,
|
|
24
|
+
loading: true,
|
|
25
|
+
preventScrollThrough: true,
|
|
26
|
+
showOverlay: true,
|
|
27
|
+
size: "medium"
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
31
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
32
|
+
var Loading = function Loading(props) {
|
|
33
|
+
var _useDefaultProps = useDefaultProps(props, loadingDefaultProps),
|
|
34
|
+
attach = _useDefaultProps.attach,
|
|
35
|
+
indicator = _useDefaultProps.indicator,
|
|
36
|
+
text = _useDefaultProps.text,
|
|
37
|
+
loading = _useDefaultProps.loading,
|
|
38
|
+
size = _useDefaultProps.size,
|
|
39
|
+
delay = _useDefaultProps.delay,
|
|
40
|
+
fullscreen = _useDefaultProps.fullscreen,
|
|
41
|
+
preventScrollThrough = _useDefaultProps.preventScrollThrough,
|
|
42
|
+
showOverlay = _useDefaultProps.showOverlay,
|
|
43
|
+
content = _useDefaultProps.content,
|
|
44
|
+
children = _useDefaultProps.children,
|
|
45
|
+
inheritColor = _useDefaultProps.inheritColor,
|
|
46
|
+
zIndex = _useDefaultProps.zIndex,
|
|
47
|
+
className = _useDefaultProps.className,
|
|
48
|
+
style = _useDefaultProps.style;
|
|
49
|
+
var _useState = useState(function () {
|
|
50
|
+
return delay ? false : loading;
|
|
51
|
+
}),
|
|
52
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
53
|
+
showLoading = _useState2[0],
|
|
54
|
+
setShowLoading = _useState2[1];
|
|
55
|
+
var _useConfig = useConfig(),
|
|
56
|
+
classPrefix = _useConfig.classPrefix;
|
|
57
|
+
var name = "".concat(classPrefix, "-loading");
|
|
58
|
+
var centerClass = "".concat(classPrefix, "-loading--center");
|
|
59
|
+
var inheritColorClass = "".concat(classPrefix, "-loading--inherit-color");
|
|
60
|
+
var fullClass = "".concat(classPrefix, "-loading--full");
|
|
61
|
+
var fullscreenClass = "".concat(classPrefix, "-loading__fullscreen");
|
|
62
|
+
var lockClass = "".concat(classPrefix, "-loading--lock");
|
|
63
|
+
var overlayClass = "".concat(classPrefix, "-loading__overlay");
|
|
64
|
+
var relativeClass = "".concat(classPrefix, "-loading__parent");
|
|
65
|
+
var textClass = "".concat(classPrefix, "-loading__text");
|
|
66
|
+
useEffect(function () {
|
|
67
|
+
var timer;
|
|
68
|
+
if (delay && loading) {
|
|
69
|
+
timer = setTimeout(function () {
|
|
70
|
+
setShowLoading(loading);
|
|
71
|
+
}, delay);
|
|
72
|
+
} else {
|
|
73
|
+
setTimeout(function () {
|
|
74
|
+
setShowLoading(loading);
|
|
75
|
+
}, 0);
|
|
76
|
+
}
|
|
77
|
+
return function () {
|
|
78
|
+
clearTimeout(timer);
|
|
79
|
+
};
|
|
80
|
+
}, [delay, loading]);
|
|
81
|
+
var calcStyles = useMemo(function () {
|
|
82
|
+
var styles = {};
|
|
83
|
+
if (zIndex !== void 0) {
|
|
84
|
+
styles.zIndex = zIndex;
|
|
85
|
+
}
|
|
86
|
+
if (!["small", "medium", "large"].includes(size)) {
|
|
87
|
+
styles.fontSize = size;
|
|
88
|
+
}
|
|
89
|
+
return styles;
|
|
90
|
+
}, [size, zIndex]);
|
|
91
|
+
var sizeMap = {
|
|
92
|
+
large: "".concat(classPrefix, "-size-l"),
|
|
93
|
+
small: "".concat(classPrefix, "-size-s"),
|
|
94
|
+
medium: "".concat(classPrefix, "-size-m")
|
|
95
|
+
};
|
|
96
|
+
var baseClasses = classNames(centerClass, sizeMap[size], _defineProperty({}, inheritColorClass, inheritColor), className);
|
|
97
|
+
useEffect(function () {
|
|
98
|
+
if (preventScrollThrough && fullscreen && canUseDocument && loading) {
|
|
99
|
+
addClass(document.body, lockClass);
|
|
100
|
+
}
|
|
101
|
+
return function () {
|
|
102
|
+
removeClass(document.body, lockClass);
|
|
103
|
+
};
|
|
104
|
+
}, [loading, preventScrollThrough, fullscreen, lockClass]);
|
|
105
|
+
var commonContent = function commonContent() {
|
|
106
|
+
var renderIndicator = /* @__PURE__ */React.createElement(GradientLoading, null);
|
|
107
|
+
if (indicator && typeof indicator !== "boolean") {
|
|
108
|
+
renderIndicator = indicator;
|
|
109
|
+
}
|
|
110
|
+
return /* @__PURE__ */React.createElement(React.Fragment, null, indicator ? renderIndicator : null, text ? /* @__PURE__ */React.createElement("div", {
|
|
111
|
+
className: textClass
|
|
112
|
+
}, text) : null);
|
|
113
|
+
};
|
|
114
|
+
if (fullscreen) {
|
|
115
|
+
return loading ? /* @__PURE__ */React.createElement("div", {
|
|
116
|
+
className: classNames(name, fullscreenClass, centerClass, overlayClass),
|
|
117
|
+
style: _objectSpread(_objectSpread({}, calcStyles), style)
|
|
118
|
+
}, /* @__PURE__ */React.createElement("div", {
|
|
119
|
+
className: baseClasses
|
|
120
|
+
}, commonContent())) : null;
|
|
121
|
+
}
|
|
122
|
+
if (content || children) {
|
|
123
|
+
return /* @__PURE__ */React.createElement("div", {
|
|
124
|
+
className: relativeClass,
|
|
125
|
+
style: style
|
|
126
|
+
}, content || children, showLoading ? /* @__PURE__ */React.createElement("div", {
|
|
127
|
+
className: classNames(name, baseClasses, fullClass, _defineProperty({}, overlayClass, showOverlay)),
|
|
128
|
+
style: calcStyles
|
|
129
|
+
}, commonContent()) : null);
|
|
130
|
+
}
|
|
131
|
+
if (attach) {
|
|
132
|
+
return /* @__PURE__ */React.createElement(Portal, {
|
|
133
|
+
attach: attach
|
|
134
|
+
}, loading ? /* @__PURE__ */React.createElement("div", {
|
|
135
|
+
className: classNames(name, baseClasses, fullClass, _defineProperty({}, overlayClass, showOverlay)),
|
|
136
|
+
style: _objectSpread(_objectSpread({}, calcStyles), style)
|
|
137
|
+
}, commonContent()) : null);
|
|
138
|
+
}
|
|
139
|
+
return loading ? /* @__PURE__ */React.createElement("div", {
|
|
140
|
+
className: classNames(name, baseClasses),
|
|
141
|
+
style: _objectSpread(_objectSpread({}, calcStyles), style)
|
|
142
|
+
}, commonContent()) : null;
|
|
143
|
+
};
|
|
144
|
+
Loading.displayName = "Loading";
|
|
145
|
+
|
|
146
|
+
export { Loading as default };
|
|
147
|
+
//# sourceMappingURL=Loading.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Loading.js","sources":["../../../components/loading/defaultProps.ts","../../../components/loading/Loading.tsx"],"sourcesContent":["import { TdLoadingProps } from \"./type\";\n\nexport const loadingDefaultProps: TdLoadingProps = {\n delay: 0,\n fullscreen: false,\n indicator: true,\n inheritColor: false,\n loading: true,\n preventScrollThrough: true,\n showOverlay: true,\n size: \"medium\"\n};\n","import React, { useState, useEffect, useMemo, CSSProperties } from \"react\";\nimport classnames from \"classnames\";\nimport { canUseDocument } from \"../utils/dom\";\nimport useConfig from \"../hooks/useConfig\";\nimport { StyledProps } from \"../common\";\nimport { TdLoadingProps } from \"./type\";\nimport Portal from \"../common/Portal\";\nimport Gradient from \"./Gradient\";\nimport { loadingDefaultProps } from \"./defaultProps\";\nimport useDefaultProps from \"../hooks/useDefaultProps\";\nimport { addClass, removeClass } from \"../utils/style\";\n\nexport interface LoadingProps extends TdLoadingProps, StyledProps {}\n\nconst Loading: React.FC<LoadingProps> = (props) => {\n const {\n attach,\n indicator,\n text,\n loading,\n size,\n delay,\n fullscreen,\n preventScrollThrough,\n showOverlay,\n content,\n children,\n inheritColor,\n zIndex,\n className,\n style\n } = useDefaultProps<LoadingProps>(props, loadingDefaultProps);\n\n const [showLoading, setShowLoading] = useState(() => (delay ? false : loading));\n\n const { classPrefix } = useConfig();\n\n const name = `${classPrefix}-loading`;\n const centerClass = `${classPrefix}-loading--center`;\n const inheritColorClass = `${classPrefix}-loading--inherit-color`;\n const fullClass = `${classPrefix}-loading--full`;\n const fullscreenClass = `${classPrefix}-loading__fullscreen`;\n const lockClass = `${classPrefix}-loading--lock`;\n const overlayClass = `${classPrefix}-loading__overlay`;\n const relativeClass = `${classPrefix}-loading__parent`;\n const textClass = `${classPrefix}-loading__text`;\n\n useEffect(() => {\n let timer: NodeJS.Timeout;\n\n if (delay && loading) {\n timer = setTimeout(() => {\n setShowLoading(loading);\n }, delay);\n } else {\n // Use setTimeout to avoid calling setState synchronously within an effect\n setTimeout(() => {\n setShowLoading(loading);\n }, 0);\n }\n return () => {\n clearTimeout(timer);\n };\n }, [delay, loading]);\n\n const calcStyles = useMemo<React.CSSProperties>(() => {\n const styles: CSSProperties = {};\n\n if (zIndex !== undefined) {\n styles.zIndex = zIndex;\n }\n\n if (![\"small\", \"medium\", \"large\"].includes(size)) {\n styles.fontSize = size;\n }\n\n return styles;\n }, [size, zIndex]);\n\n const sizeMap = {\n large: `${classPrefix}-size-l`,\n small: `${classPrefix}-size-s`,\n medium: `${classPrefix}-size-m`\n };\n\n const baseClasses = classnames(\n centerClass,\n sizeMap[size],\n {\n [inheritColorClass]: inheritColor\n },\n className\n );\n\n useEffect(() => {\n if (preventScrollThrough && fullscreen && canUseDocument && loading) {\n addClass(document.body, lockClass);\n }\n return () => {\n removeClass(document.body, lockClass);\n };\n }, [loading, preventScrollThrough, fullscreen, lockClass]);\n\n const commonContent = () => {\n let renderIndicator = <Gradient />;\n\n if (indicator && typeof indicator !== \"boolean\") {\n renderIndicator = indicator as React.ReactElement;\n }\n return (\n <>\n {indicator ? renderIndicator : null}\n {text ? <div className={textClass}>{text}</div> : null}\n </>\n );\n };\n\n if (fullscreen) {\n return loading ? (\n <div className={classnames(name, fullscreenClass, centerClass, overlayClass)} style={{ ...calcStyles, ...style }}>\n <div className={baseClasses}>{commonContent()}</div>\n </div>\n ) : null;\n }\n\n if (content || children) {\n return (\n <div className={relativeClass} style={style}>\n {content || children}\n {showLoading ? (\n <div\n className={classnames(name, baseClasses, fullClass, {\n [overlayClass]: showOverlay\n })}\n style={calcStyles}\n >\n {commonContent()}\n </div>\n ) : null}\n </div>\n );\n }\n if (attach) {\n return (\n <Portal attach={attach}>\n {loading ? (\n <div\n className={classnames(name, baseClasses, fullClass, {\n [overlayClass]: showOverlay\n })}\n style={{ ...calcStyles, ...style }}\n >\n {commonContent()}\n </div>\n ) : null}\n </Portal>\n );\n }\n\n return loading ? (\n <div className={classnames(name, baseClasses)} style={{ ...calcStyles, ...style }}>\n {commonContent()}\n </div>\n ) : null;\n};\n\nLoading.displayName = \"Loading\";\n\nexport default Loading;\n"],"names":["loadingDefaultProps","delay","fullscreen","indicator","inheritColor","loading","preventScrollThrough","showOverlay","size","Loading","props","_useDefaultProps","useDefaultProps","attach","text","content","children","zIndex","className","style","_useState","useState","_useState2","_slicedToArray","showLoading","setShowLoading","_useConfig","useConfig","classPrefix","name","concat","centerClass","inheritColorClass","fullClass","fullscreenClass","lockClass","overlayClass","relativeClass","textClass","useEffect","timer","setTimeout","clearTimeout","calcStyles","useMemo","styles","includes","fontSize","sizeMap","large","small","medium","baseClasses","classnames","_defineProperty","canUseDocument","addClass","document","body","removeClass","commonContent","renderIndicator","Gradient","React","createElement","Fragment","_objectSpread","Portal","displayName"],"mappings":";;;;;;;;;;;;;;;;;;AAEO,IAAMA,mBAAA,GAAsC;AACjDC,EAAAA,KAAA,EAAO,CAAA;AACPC,EAAAA,UAAA,EAAY,KAAA;AACZC,EAAAA,SAAA,EAAW,IAAA;AACXC,EAAAA,YAAA,EAAc,KAAA;AACdC,EAAAA,OAAA,EAAS,IAAA;AACTC,EAAAA,oBAAA,EAAsB,IAAA;AACtBC,EAAAA,WAAA,EAAa,I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CAACG,MAAA,EAAA;AAAOtD,MAAAA,MAAA,EAAAA;KAAA,EACLR,OAAA,kBACC0D,KAAA,CAAAC,aAAA,CAAC,KAAA,EAAA;AACC9C,MAAAA,SAAA,EAAWmC,UAAA,CAAWxB,IAAA,EAAMuB,WAAA,EAAanB,SAAA,EAAAqB,eAAA,CAAA,EAAA,EACtClB,YAAY,EAAG7B,WAAA,CACjB,CAAA;AACDY,MAAAA,KAAA,EAAA+C,aAAA,CAAAA,aAAA,CAAA,EAAA,EAAYvB,UAAA,GAAexB,KAAA;AAAM,KAAA,EAEhCyC,aAAA,EACH,IACE,IACN,CAAA;AAEJ,EAAA;EAEA,OAAOvD,yBACL0D,KAAA,CAAAC,aAAA,CAAC,KAAA,EAAA;AAAI9C,IAAAA,SAAA,EAAWmC,UAAA,CAAWxB,MAAMuB,WAAW,CAAA;AAAGjC,IAAAA,KAAA,EAAA+C,aAAA,CAAAA,aAAA,CAAA,EAAA,EAAYvB,UAAA,GAAexB;AAAM,GAAA,EAC7EyC,aAAA,EACH,CAAA,GACE,IAAA;AACN;AAEAnD,OAAA,CAAQ2D,WAAA,GAAc,SAAA;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Loading$1 from './Loading.js';
|
|
2
|
+
import './style/css.js';
|
|
3
|
+
import '../_chunks/dep-Cwish4GD.js';
|
|
4
|
+
import '../_chunks/dep-D-UKOauR.js';
|
|
5
|
+
import '../_chunks/dep-CzLhKWCf.js';
|
|
6
|
+
import 'react';
|
|
7
|
+
import 'classnames';
|
|
8
|
+
import '../_chunks/dep-0QH2Ee4R.js';
|
|
9
|
+
import 'lodash-es';
|
|
10
|
+
import '../_chunks/dep-u1x3x6MJ.js';
|
|
11
|
+
import '../config-provider/ConfigContext.js';
|
|
12
|
+
import '../common/Portal.js';
|
|
13
|
+
import 'react-dom';
|
|
14
|
+
import './Gradient.js';
|
|
15
|
+
import '../_chunks/dep-DHWwZ2Nj.js';
|
|
16
|
+
import '../_chunks/dep-DN7d1SzH.js';
|
|
17
|
+
import '../_chunks/dep-PPA-yoAy.js';
|
|
18
|
+
import '../_chunks/dep-DGvfel3I.js';
|
|
19
|
+
import '../_chunks/dep-BH5n5r1M.js';
|
|
20
|
+
|
|
21
|
+
var Loading = Loading$1;
|
|
22
|
+
|
|
23
|
+
export { Loading, Loading as default };
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../components/loading/index.ts"],"sourcesContent":["import _Loading from \"./Loading\";\n// import { LoadingPlugin as _LoadingPlugin } from './plugin';\n\nimport \"./style/index.js\";\n\nexport type { LoadingProps } from \"./Loading\";\nexport * from \"./type\";\n\nexport const Loading = _Loading;\n// export const loading = _LoadingPlugin;\n// export const LoadingPlugin = _LoadingPlugin;\n\nexport default Loading;\n"],"names":["Loading","_Loading"],"mappings":";;;;;;;;;;;;;;;;;;;;AAQO,IAAMA,OAAA,GAAUC;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./index.css";
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
@charset "UTF-8";
|
|
2
|
+
@-webkit-keyframes t-fade-in {
|
|
3
|
+
from {
|
|
4
|
+
opacity: 0;
|
|
5
|
+
}
|
|
6
|
+
to {
|
|
7
|
+
opacity: 1;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
@keyframes t-fade-in {
|
|
11
|
+
from {
|
|
12
|
+
opacity: 0;
|
|
13
|
+
}
|
|
14
|
+
to {
|
|
15
|
+
opacity: 1;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
@-webkit-keyframes t-fade-out {
|
|
19
|
+
from {
|
|
20
|
+
opacity: 1;
|
|
21
|
+
}
|
|
22
|
+
to {
|
|
23
|
+
opacity: 0;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
@keyframes t-fade-out {
|
|
27
|
+
from {
|
|
28
|
+
opacity: 1;
|
|
29
|
+
}
|
|
30
|
+
to {
|
|
31
|
+
opacity: 0;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
@-webkit-keyframes t-spin {
|
|
35
|
+
from {
|
|
36
|
+
-webkit-transform: rotate(0deg);
|
|
37
|
+
transform: rotate(0deg);
|
|
38
|
+
}
|
|
39
|
+
to {
|
|
40
|
+
-webkit-transform: rotate(360deg);
|
|
41
|
+
transform: rotate(360deg);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
@keyframes t-spin {
|
|
45
|
+
from {
|
|
46
|
+
-webkit-transform: rotate(0deg);
|
|
47
|
+
transform: rotate(0deg);
|
|
48
|
+
}
|
|
49
|
+
to {
|
|
50
|
+
-webkit-transform: rotate(360deg);
|
|
51
|
+
transform: rotate(360deg);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
.t-icon-loading {
|
|
55
|
+
-webkit-animation: t-spin 1s linear infinite;
|
|
56
|
+
animation: t-spin 1s linear infinite;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@-webkit-keyframes t-zoom-out {
|
|
60
|
+
from {
|
|
61
|
+
-webkit-transform: scale(0.2);
|
|
62
|
+
transform: scale(0.2);
|
|
63
|
+
}
|
|
64
|
+
to {
|
|
65
|
+
-webkit-transform: scale(1);
|
|
66
|
+
transform: scale(1);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@keyframes t-zoom-out {
|
|
71
|
+
from {
|
|
72
|
+
-webkit-transform: scale(0.2);
|
|
73
|
+
transform: scale(0.2);
|
|
74
|
+
}
|
|
75
|
+
to {
|
|
76
|
+
-webkit-transform: scale(1);
|
|
77
|
+
transform: scale(1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
.t-loading {
|
|
81
|
+
font: var(--td-font-body-medium);
|
|
82
|
+
color: var(--td-text-color-primary);
|
|
83
|
+
-webkit-box-sizing: border-box;
|
|
84
|
+
box-sizing: border-box;
|
|
85
|
+
margin: 0;
|
|
86
|
+
padding: 0;
|
|
87
|
+
list-style: none;
|
|
88
|
+
position: relative;
|
|
89
|
+
color: var(--td-brand-color);
|
|
90
|
+
font-size: var(--td-comp-size-l);
|
|
91
|
+
}
|
|
92
|
+
.t-loading--lock {
|
|
93
|
+
overflow: hidden;
|
|
94
|
+
}
|
|
95
|
+
.t-loading.t-size-s {
|
|
96
|
+
font-size: var(--td-comp-size-xxxs);
|
|
97
|
+
}
|
|
98
|
+
.t-loading.t-size-l {
|
|
99
|
+
font-size: var(--td-comp-size-xxxl);
|
|
100
|
+
}
|
|
101
|
+
.t-loading__parent--relative {
|
|
102
|
+
position: relative !important;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.t-loading__fullscreen {
|
|
106
|
+
position: fixed;
|
|
107
|
+
top: 0;
|
|
108
|
+
left: 0;
|
|
109
|
+
width: 100%;
|
|
110
|
+
height: 100%;
|
|
111
|
+
z-index: 3500;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.t-loading--center {
|
|
115
|
+
display: -webkit-inline-box;
|
|
116
|
+
display: -ms-inline-flexbox;
|
|
117
|
+
display: inline-flex;
|
|
118
|
+
-webkit-box-align: center;
|
|
119
|
+
-ms-flex-align: center;
|
|
120
|
+
align-items: center;
|
|
121
|
+
vertical-align: middle;
|
|
122
|
+
-webkit-box-pack: center;
|
|
123
|
+
-ms-flex-pack: center;
|
|
124
|
+
justify-content: center;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.t-loading__content {
|
|
128
|
+
position: absolute;
|
|
129
|
+
left: 48%;
|
|
130
|
+
top: 20%;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.t-loading--inherit-color {
|
|
134
|
+
color: inherit;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.t-loading__parent {
|
|
138
|
+
position: relative;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.t-loading__overlay {
|
|
142
|
+
background-color: var(--td-mask-disabled);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** 仅用于作为包裹元素时 */
|
|
146
|
+
.t-loading--full {
|
|
147
|
+
position: absolute;
|
|
148
|
+
top: 0;
|
|
149
|
+
left: 0;
|
|
150
|
+
width: 100%;
|
|
151
|
+
height: 100%;
|
|
152
|
+
z-index: 3500;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.t-loading--hidden {
|
|
156
|
+
visibility: hidden;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.t-loading--visible {
|
|
160
|
+
visibility: visible;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.t-loading__text {
|
|
164
|
+
width: auto;
|
|
165
|
+
display: inline-block;
|
|
166
|
+
vertical-align: middle;
|
|
167
|
+
font: var(--td-font-body-medium);
|
|
168
|
+
margin-left: var(--td-comp-margin-xs);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.t-loading__gradient {
|
|
172
|
+
display: -webkit-inline-box;
|
|
173
|
+
display: -ms-inline-flexbox;
|
|
174
|
+
display: inline-flex;
|
|
175
|
+
-webkit-box-pack: center;
|
|
176
|
+
-ms-flex-pack: center;
|
|
177
|
+
justify-content: center;
|
|
178
|
+
-webkit-box-align: center;
|
|
179
|
+
-ms-flex-align: center;
|
|
180
|
+
align-items: center;
|
|
181
|
+
vertical-align: middle;
|
|
182
|
+
}
|
|
183
|
+
.t-loading__gradient-conic {
|
|
184
|
+
width: 100%;
|
|
185
|
+
height: 100%;
|
|
186
|
+
border-radius: var(--td-radius-circle);
|
|
187
|
+
/* stylelint-disable-next-line color-no-hex */
|
|
188
|
+
background: conic-gradient(from 90deg at 50% 50%, #fff 0deg, currentcolor 360deg);
|
|
189
|
+
-webkit-mask: radial-gradient(transparent calc(50% - 0.5px), #fff 50%);
|
|
190
|
+
mask: radial-gradient(transparent calc(50% - 0.5px), #fff 50%);
|
|
191
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { _ as _defineProperty } from '../_chunks/dep-Cwish4GD.js';
|
|
2
|
+
import { _ as _slicedToArray } from '../_chunks/dep-CzLhKWCf.js';
|
|
3
|
+
import React, { useState, useCallback } from 'react';
|
|
4
|
+
import NotificationItem from './NotifyItem.js';
|
|
5
|
+
import { u as useConfig } from '../_chunks/dep-u1x3x6MJ.js';
|
|
6
|
+
import '../_chunks/dep-D-UKOauR.js';
|
|
7
|
+
import '../_chunks/dep-CgyDw_YI.js';
|
|
8
|
+
import '@tendaui/icons';
|
|
9
|
+
import '../config-provider/ConfigContext.js';
|
|
10
|
+
|
|
11
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
+
var GAP = 14;
|
|
14
|
+
var TOAST_WIDTH = 356;
|
|
15
|
+
var NotificationContainer = function NotificationContainer(_ref) {
|
|
16
|
+
var _heights$;
|
|
17
|
+
var notifications = _ref.notifications,
|
|
18
|
+
onRemove = _ref.onRemove,
|
|
19
|
+
onHoverStart = _ref.onHoverStart,
|
|
20
|
+
onHoverEnd = _ref.onHoverEnd,
|
|
21
|
+
maxStack = _ref.maxStack,
|
|
22
|
+
position = _ref.position;
|
|
23
|
+
var _useState = useState(false),
|
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
+
isHovering = _useState2[0],
|
|
26
|
+
setIsHovering = _useState2[1];
|
|
27
|
+
var latestNotifications = notifications.slice(0, maxStack);
|
|
28
|
+
var _position$split = position.split("-"),
|
|
29
|
+
_position$split2 = _slicedToArray(_position$split, 2),
|
|
30
|
+
y = _position$split2[0],
|
|
31
|
+
x = _position$split2[1];
|
|
32
|
+
var handleMouseEnter = useCallback(function () {
|
|
33
|
+
setIsHovering(true);
|
|
34
|
+
onHoverStart();
|
|
35
|
+
}, [onHoverStart]);
|
|
36
|
+
var handleMouseLeave = useCallback(function () {
|
|
37
|
+
setIsHovering(false);
|
|
38
|
+
onHoverEnd();
|
|
39
|
+
}, [onHoverEnd]);
|
|
40
|
+
var _useState3 = useState([]),
|
|
41
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
42
|
+
heights = _useState4[0],
|
|
43
|
+
setHeights = _useState4[1];
|
|
44
|
+
var _useConfig = useConfig(),
|
|
45
|
+
prefix = _useConfig.classPrefix;
|
|
46
|
+
return /* @__PURE__ */React.createElement("div", {
|
|
47
|
+
className: "".concat(prefix, "-notify"),
|
|
48
|
+
style: {
|
|
49
|
+
height: isHovering ? "".concat(notifications.length * 100 + 16, "px") : "auto",
|
|
50
|
+
minHeight: "80px",
|
|
51
|
+
"--front-toast-height": (((_heights$ = heights[0]) === null || _heights$ === void 0 ? void 0 : _heights$.height) || 0) + "px",
|
|
52
|
+
"--toast-width": TOAST_WIDTH + "px"
|
|
53
|
+
},
|
|
54
|
+
"data-toaster": true,
|
|
55
|
+
onMouseEnter: handleMouseEnter,
|
|
56
|
+
onMouseLeave: handleMouseLeave,
|
|
57
|
+
"data-x-position": x,
|
|
58
|
+
"data-y-position": y
|
|
59
|
+
}, /* @__PURE__ */React.createElement("div", {
|
|
60
|
+
className: "".concat(prefix, "-notify__container"),
|
|
61
|
+
style: {
|
|
62
|
+
pointerEvents: "all"
|
|
63
|
+
}
|
|
64
|
+
}, latestNotifications.map(function (notification) {
|
|
65
|
+
return /* @__PURE__ */React.createElement(NotificationItem, _objectSpread(_objectSpread({
|
|
66
|
+
key: notification.id,
|
|
67
|
+
heights: heights,
|
|
68
|
+
setHeights: setHeights,
|
|
69
|
+
gap: GAP
|
|
70
|
+
}, notification), {}, {
|
|
71
|
+
onRemove: onRemove,
|
|
72
|
+
isExpanded: isHovering
|
|
73
|
+
}));
|
|
74
|
+
})));
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export { GAP, TOAST_WIDTH, NotificationContainer as default };
|
|
78
|
+
//# sourceMappingURL=NotifyContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotifyContainer.js","sources":["../../../components/notification/NotifyContainer.tsx"],"sourcesContent":["import React, { useCallback, useState } from \"react\";\nimport { TdNotificationProps } from \"./type\";\nimport NotificationItem from \"./NotifyItem\";\nimport useConfig from \"../hooks/useConfig\";\nexport const GAP = 14;\nexport const TOAST_WIDTH = 356;\nconst NotificationContainer = ({\n notifications,\n onRemove,\n onHoverStart,\n onHoverEnd,\n maxStack,\n position\n}: {\n notifications: TdNotificationProps[];\n onRemove: (id: string) => void;\n onHoverStart: () => void;\n onHoverEnd: () => void;\n maxStack: number;\n position: string;\n}) => {\n const [isHovering, setIsHovering] = useState(false);\n const latestNotifications = notifications.slice(0, maxStack);\n const [y, x] = position.split(\"-\");\n const handleMouseEnter = useCallback(() => {\n setIsHovering(true);\n onHoverStart();\n }, [onHoverStart]);\n\n const handleMouseLeave = useCallback(() => {\n setIsHovering(false);\n onHoverEnd();\n }, [onHoverEnd]);\n\n const [heights, setHeights] = useState<{ toastId: string; height: number }[]>([]);\n\n const { classPrefix: prefix } = useConfig();\n\n return (\n <div\n className={`${prefix}-notify`}\n style={\n {\n height: isHovering ? `${notifications.length * 100 + 16}px` : \"auto\",\n minHeight: \"80px\",\n \"--front-toast-height\": (heights[0]?.height || 0) + \"px\",\n \"--toast-width\": TOAST_WIDTH + \"px\"\n } as React.CSSProperties\n }\n data-toaster\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n data-x-position={x}\n data-y-position={y}\n >\n <div\n className={`${prefix}-notify__container`}\n style={{\n pointerEvents: \"all\"\n }}\n >\n {latestNotifications.map((notification) => {\n // const stackedStyle = !isHovering && !isLast;\n\n // let offsetY = isHovering\n // ? index * 100 // 展开时,索引0在顶部\n // : stackedStyle\n // ? index * 8\n // : 0;\n\n // const scale = stackedStyle ? 1 - index * 0.01 : 1;\n // const opacity = stackedStyle ? 1 - index * 0.15 : 1;\n return (\n <NotificationItem\n key={notification.id}\n heights={heights}\n setHeights={setHeights}\n gap={GAP}\n {...notification}\n onRemove={onRemove}\n isExpanded={isHovering}\n />\n );\n })}\n </div>\n </div>\n );\n};\n\nexport default NotificationContainer;\n"],"names":["GAP","TOAST_WIDTH","NotificationContainer","_heights$","notifications","_ref","onRemove","onHoverStart","onHoverEnd","maxStack","position","_useState","useState","_useState2","_slicedToArray","isHovering","setIsHovering","latestNotifications","slice","_position$split","split","_position$split2","y","x","handleMouseEnter","useCallback","handleMouseLeave","_useState3","_useState4","heights","setHeights","_useConfig","useConfig","prefix","classPrefix","React","createElement","className","concat","style","height","length","minHeight","onMouseEnter","onMouseLeave","pointerEvents","map","notification","NotificationItem","_objectSpread","key","id","gap","isExpanded"],"mappings":";;;;;;;;;;;;AAIO,IAAMA,GAAA,GAAM;AACZ,IAAMC,WAAA,GAAc;AAC3B,IAAMC,wBAAwB,SAAxBA,4BAcA;AAAA,EAAA,IAAAC,SAAA;AAAA,EAAA,IAbJC,aAAA,GAAAC,IAAA,CAAAD,aAAA;IACAE,QAAA,GAAAD,IAAA,CAAAC,QAAA;IACAC,YAAA,GAAAF,IAAA,CAAAE,YAAA;IACAC,UAAA,GAAAH,IAAA,CAAAG,UAAA;IACAC,QAAA,GAAAJ,IAAA,CAAAI,QAAA;IACAC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A;AAEJ;;;;"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { _ as _toConsumableArray } from '../_chunks/dep-CgyDw_YI.js';
|
|
2
|
+
import { _ as _defineProperty } from '../_chunks/dep-Cwish4GD.js';
|
|
3
|
+
import { _ as _slicedToArray } from '../_chunks/dep-CzLhKWCf.js';
|
|
4
|
+
import React, { createContext, useState, useRef, useCallback, useContext } from 'react';
|
|
5
|
+
import { createPortal } from 'react-dom';
|
|
6
|
+
import NotificationContainer from './NotifyContainer.js';
|
|
7
|
+
import '../_chunks/dep-D-UKOauR.js';
|
|
8
|
+
import './NotifyItem.js';
|
|
9
|
+
import '@tendaui/icons';
|
|
10
|
+
import '../_chunks/dep-u1x3x6MJ.js';
|
|
11
|
+
import '../config-provider/ConfigContext.js';
|
|
12
|
+
|
|
13
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
+
var NotificationContext = /*#__PURE__*/createContext(null);
|
|
16
|
+
var generateId = function generateId() {
|
|
17
|
+
return Math.random().toString(36).substr(2, 9);
|
|
18
|
+
};
|
|
19
|
+
var NotificationProvider = function NotificationProvider(_ref) {
|
|
20
|
+
var children = _ref.children,
|
|
21
|
+
_ref$maxStack = _ref.maxStack,
|
|
22
|
+
maxStack = _ref$maxStack === void 0 ? 5 : _ref$maxStack,
|
|
23
|
+
_ref$displayDuration = _ref.displayDuration,
|
|
24
|
+
displayDuration = _ref$displayDuration === void 0 ? 3e3 : _ref$displayDuration,
|
|
25
|
+
_ref$position = _ref.position,
|
|
26
|
+
position = _ref$position === void 0 ? "top-right" : _ref$position;
|
|
27
|
+
var _useState = useState([]),
|
|
28
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
+
notifications = _useState2[0],
|
|
30
|
+
setNotifications = _useState2[1];
|
|
31
|
+
var timersRef = useRef(/* @__PURE__ */new Map());
|
|
32
|
+
var pausedAtRef = useRef(/* @__PURE__ */new Map());
|
|
33
|
+
var clearNotificationTimer = useCallback(function (id) {
|
|
34
|
+
var timer = timersRef.current.get(id);
|
|
35
|
+
if (timer) {
|
|
36
|
+
clearTimeout(timer);
|
|
37
|
+
timersRef.current["delete"](id);
|
|
38
|
+
}
|
|
39
|
+
}, []);
|
|
40
|
+
var startTimer = useCallback(function (notification, remainingTime) {
|
|
41
|
+
var duration = remainingTime !== null && remainingTime !== void 0 ? remainingTime : displayDuration;
|
|
42
|
+
var timer = setTimeout(function () {
|
|
43
|
+
setNotifications(function (prev) {
|
|
44
|
+
return prev.map(function (n) {
|
|
45
|
+
return n.id === notification.id ? _objectSpread(_objectSpread({}, n), {}, {
|
|
46
|
+
isRemoved: true
|
|
47
|
+
}) : n;
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
setTimeout(function () {
|
|
51
|
+
setNotifications(function (prev) {
|
|
52
|
+
return prev.filter(function (t) {
|
|
53
|
+
return t.id !== notification.id;
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
clearNotificationTimer(notification.id);
|
|
57
|
+
pausedAtRef.current["delete"](notification.id);
|
|
58
|
+
}, 400);
|
|
59
|
+
}, duration);
|
|
60
|
+
timersRef.current.set(notification.id, timer);
|
|
61
|
+
}, [displayDuration, clearNotificationTimer]);
|
|
62
|
+
var addNotification = useCallback(function (type, message) {
|
|
63
|
+
var newNotification = {
|
|
64
|
+
id: generateId(),
|
|
65
|
+
type: type,
|
|
66
|
+
title: message.title,
|
|
67
|
+
message: message.message,
|
|
68
|
+
createdAt: Date.now(),
|
|
69
|
+
isRemoved: false
|
|
70
|
+
};
|
|
71
|
+
setNotifications(function (prev) {
|
|
72
|
+
var newNotifications = [newNotification].concat(_toConsumableArray(prev));
|
|
73
|
+
var removedNotifications = newNotifications.slice(maxStack);
|
|
74
|
+
removedNotifications.forEach(function (notification) {
|
|
75
|
+
clearNotificationTimer(notification.id);
|
|
76
|
+
pausedAtRef.current["delete"](notification.id);
|
|
77
|
+
});
|
|
78
|
+
return newNotifications.slice(0, maxStack);
|
|
79
|
+
});
|
|
80
|
+
startTimer(newNotification);
|
|
81
|
+
}, [maxStack, startTimer, clearNotificationTimer]);
|
|
82
|
+
var contextValue = React.useMemo(function () {
|
|
83
|
+
return {
|
|
84
|
+
notify: addNotification,
|
|
85
|
+
success: function success(message) {
|
|
86
|
+
return addNotification("success", message);
|
|
87
|
+
},
|
|
88
|
+
error: function error(message) {
|
|
89
|
+
return addNotification("error", message);
|
|
90
|
+
},
|
|
91
|
+
warning: function warning(message) {
|
|
92
|
+
return addNotification("warning", message);
|
|
93
|
+
},
|
|
94
|
+
info: function info(message) {
|
|
95
|
+
return addNotification("info", message);
|
|
96
|
+
},
|
|
97
|
+
removeNotification: function removeNotification(id) {
|
|
98
|
+
setNotifications(function (prev) {
|
|
99
|
+
return prev.filter(function (t) {
|
|
100
|
+
return t.id !== id;
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
clearNotificationTimer(id);
|
|
104
|
+
pausedAtRef.current["delete"](id);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}, [addNotification, clearNotificationTimer]);
|
|
108
|
+
var clearAllTimers = useCallback(function () {
|
|
109
|
+
var now = Date.now();
|
|
110
|
+
notifications.forEach(function (notification) {
|
|
111
|
+
pausedAtRef.current.set(notification.id, now);
|
|
112
|
+
clearNotificationTimer(notification.id);
|
|
113
|
+
});
|
|
114
|
+
}, [notifications, clearNotificationTimer]);
|
|
115
|
+
var restartAllTimers = useCallback(function () {
|
|
116
|
+
notifications.forEach(function (notification) {
|
|
117
|
+
var pausedAt = pausedAtRef.current.get(notification.id);
|
|
118
|
+
if (pausedAt) {
|
|
119
|
+
var elapsedTime = pausedAt - notification.createdAt;
|
|
120
|
+
var remainingTime = Math.max(0, displayDuration - elapsedTime);
|
|
121
|
+
startTimer(notification, remainingTime);
|
|
122
|
+
pausedAtRef.current["delete"](notification.id);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}, [notifications, displayDuration, startTimer]);
|
|
126
|
+
return /* @__PURE__ */React.createElement(NotificationContext.Provider, {
|
|
127
|
+
value: contextValue
|
|
128
|
+
}, children, /*#__PURE__*/createPortal(/* @__PURE__ */React.createElement(NotificationContainer, {
|
|
129
|
+
notifications: notifications,
|
|
130
|
+
onRemove: function onRemove(id) {
|
|
131
|
+
return contextValue.removeNotification(id);
|
|
132
|
+
},
|
|
133
|
+
onHoverStart: clearAllTimers,
|
|
134
|
+
onHoverEnd: restartAllTimers,
|
|
135
|
+
"data-testid": "notification-container",
|
|
136
|
+
maxStack: maxStack,
|
|
137
|
+
position: position
|
|
138
|
+
}), document.body));
|
|
139
|
+
};
|
|
140
|
+
var useNotification = function useNotification() {
|
|
141
|
+
var context = useContext(NotificationContext);
|
|
142
|
+
if (!context) {
|
|
143
|
+
throw new Error("useNotification must be used within a NotificationProvider");
|
|
144
|
+
}
|
|
145
|
+
return context;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export { NotificationProvider, useNotification };
|
|
149
|
+
//# sourceMappingURL=NotifyContext.js.map
|