wssf-kage-ui 0.1.2 → 0.1.3
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/dist/cjs/Alert/index.d.ts +37 -0
- package/dist/cjs/Alert/index.js +124 -0
- package/dist/cjs/Alert/style.less +248 -0
- package/dist/cjs/Drawer/index.d.ts +57 -0
- package/dist/cjs/Drawer/index.js +203 -0
- package/dist/cjs/Drawer/style.less +215 -0
- package/dist/cjs/FloatButton/index.d.ts +54 -0
- package/dist/cjs/FloatButton/index.js +119 -0
- package/dist/cjs/FloatButton/style.less +266 -0
- package/dist/cjs/Message/index.d.ts +38 -0
- package/dist/cjs/Message/index.js +292 -0
- package/dist/cjs/Message/style.less +183 -0
- package/dist/cjs/Modal/index.d.ts +63 -0
- package/dist/cjs/Modal/index.js +254 -0
- package/dist/cjs/Modal/style.less +298 -0
- package/dist/cjs/Notification/index.d.ts +48 -0
- package/dist/cjs/Notification/index.js +340 -0
- package/dist/cjs/Notification/style.less +260 -0
- package/dist/cjs/Popconfirm/index.d.ts +58 -0
- package/dist/cjs/Popconfirm/index.js +393 -0
- package/dist/cjs/Popconfirm/style.less +417 -0
- package/dist/cjs/Progress/index.d.ts +43 -0
- package/dist/cjs/Progress/index.js +213 -0
- package/dist/cjs/Progress/style.less +206 -0
- package/dist/cjs/Result/index.d.ts +25 -0
- package/dist/cjs/Result/index.js +63 -0
- package/dist/cjs/Result/style.less +111 -0
- package/dist/cjs/Skeleton/index.d.ts +88 -0
- package/dist/cjs/Skeleton/index.js +207 -0
- package/dist/cjs/Skeleton/style.less +487 -0
- package/dist/cjs/Spin/index.d.ts +25 -0
- package/dist/cjs/Spin/index.js +98 -0
- package/dist/cjs/Spin/style.less +169 -0
- package/dist/cjs/Tree/index.d.ts +82 -0
- package/dist/cjs/Tree/index.js +226 -0
- package/dist/cjs/Tree/style.less +313 -0
- package/dist/cjs/Watermark/index.d.ts +41 -0
- package/dist/cjs/Watermark/index.js +353 -0
- package/dist/cjs/Watermark/style.less +31 -0
- package/dist/cjs/index.d.ts +27 -1
- package/dist/cjs/index.js +91 -0
- package/dist/esm/Alert/index.d.ts +37 -0
- package/dist/esm/Alert/index.js +121 -0
- package/dist/esm/Alert/style.less +248 -0
- package/dist/esm/Drawer/index.d.ts +57 -0
- package/dist/esm/Drawer/index.js +202 -0
- package/dist/esm/Drawer/style.less +215 -0
- package/dist/esm/FloatButton/index.d.ts +54 -0
- package/dist/esm/FloatButton/index.js +123 -0
- package/dist/esm/FloatButton/style.less +266 -0
- package/dist/esm/Message/index.d.ts +38 -0
- package/dist/esm/Message/index.js +294 -0
- package/dist/esm/Message/style.less +183 -0
- package/dist/esm/Modal/index.d.ts +63 -0
- package/dist/esm/Modal/index.js +251 -0
- package/dist/esm/Modal/style.less +298 -0
- package/dist/esm/Notification/index.d.ts +48 -0
- package/dist/esm/Notification/index.js +345 -0
- package/dist/esm/Notification/style.less +260 -0
- package/dist/esm/Popconfirm/index.d.ts +58 -0
- package/dist/esm/Popconfirm/index.js +389 -0
- package/dist/esm/Popconfirm/style.less +417 -0
- package/dist/esm/Progress/index.d.ts +43 -0
- package/dist/esm/Progress/index.js +208 -0
- package/dist/esm/Progress/style.less +206 -0
- package/dist/esm/Result/index.d.ts +25 -0
- package/dist/esm/Result/index.js +57 -0
- package/dist/esm/Result/style.less +111 -0
- package/dist/esm/Skeleton/index.d.ts +88 -0
- package/dist/esm/Skeleton/index.js +213 -0
- package/dist/esm/Skeleton/style.less +487 -0
- package/dist/esm/Spin/index.d.ts +25 -0
- package/dist/esm/Spin/index.js +95 -0
- package/dist/esm/Spin/style.less +169 -0
- package/dist/esm/Tree/index.d.ts +82 -0
- package/dist/esm/Tree/index.js +225 -0
- package/dist/esm/Tree/style.less +313 -0
- package/dist/esm/Watermark/index.d.ts +41 -0
- package/dist/esm/Watermark/index.js +349 -0
- package/dist/esm/Watermark/style.less +31 -0
- package/dist/esm/index.d.ts +27 -1
- package/dist/esm/index.js +14 -1
- package/package.json +1 -1
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Message = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
require("./style.less");
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
13
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
14
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
16
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
17
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
18
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
|
+
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; }
|
|
20
|
+
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; }
|
|
21
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
22
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
23
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
24
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
26
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // ============ 类型定义 ============
|
|
27
|
+
/** Message 类型 */ /** Message 配置 */ /** Message 实例 */ /** Message API */
|
|
28
|
+
// ============ 默认图标 ============
|
|
29
|
+
var defaultIcons = {
|
|
30
|
+
success: '✓',
|
|
31
|
+
info: 'ℹ',
|
|
32
|
+
warning: '⚠',
|
|
33
|
+
error: '✕',
|
|
34
|
+
loading: '⟳'
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// ============ Message 管理器 ============
|
|
38
|
+
var MessageManager = /*#__PURE__*/function () {
|
|
39
|
+
function MessageManager() {
|
|
40
|
+
_classCallCheck(this, MessageManager);
|
|
41
|
+
_defineProperty(this, "instances", []);
|
|
42
|
+
_defineProperty(this, "listeners", new Set());
|
|
43
|
+
_defineProperty(this, "keyCounter", 0);
|
|
44
|
+
}
|
|
45
|
+
_createClass(MessageManager, [{
|
|
46
|
+
key: "subscribe",
|
|
47
|
+
value: function subscribe(listener) {
|
|
48
|
+
var _this = this;
|
|
49
|
+
this.listeners.add(listener);
|
|
50
|
+
return function () {
|
|
51
|
+
_this.listeners.delete(listener);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
key: "notify",
|
|
56
|
+
value: function notify() {
|
|
57
|
+
this.listeners.forEach(function (listener) {
|
|
58
|
+
return listener();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "add",
|
|
63
|
+
value: function add(config) {
|
|
64
|
+
var _config$key,
|
|
65
|
+
_this2 = this;
|
|
66
|
+
var key = (_config$key = config.key) !== null && _config$key !== void 0 ? _config$key : "message-".concat(++this.keyCounter);
|
|
67
|
+
var instance = _objectSpread(_objectSpread({}, config), {}, {
|
|
68
|
+
key: key,
|
|
69
|
+
visible: true,
|
|
70
|
+
closing: false
|
|
71
|
+
});
|
|
72
|
+
this.instances.push(instance);
|
|
73
|
+
this.notify();
|
|
74
|
+
|
|
75
|
+
// 自动关闭
|
|
76
|
+
if (config.duration !== 0) {
|
|
77
|
+
var _config$duration;
|
|
78
|
+
var _duration = (_config$duration = config.duration) !== null && _config$duration !== void 0 ? _config$duration : 3;
|
|
79
|
+
setTimeout(function () {
|
|
80
|
+
_this2.remove(key);
|
|
81
|
+
}, _duration * 1000);
|
|
82
|
+
}
|
|
83
|
+
return key;
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
86
|
+
key: "remove",
|
|
87
|
+
value: function remove(key) {
|
|
88
|
+
var _this3 = this;
|
|
89
|
+
var instance = this.instances.find(function (item) {
|
|
90
|
+
return item.key === key;
|
|
91
|
+
});
|
|
92
|
+
if (!instance) return;
|
|
93
|
+
instance.closing = true;
|
|
94
|
+
this.notify();
|
|
95
|
+
|
|
96
|
+
// 等待动画完成
|
|
97
|
+
setTimeout(function () {
|
|
98
|
+
var index = _this3.instances.findIndex(function (item) {
|
|
99
|
+
return item.key === key;
|
|
100
|
+
});
|
|
101
|
+
if (index > -1) {
|
|
102
|
+
var _instance$onClose;
|
|
103
|
+
_this3.instances.splice(index, 1);
|
|
104
|
+
_this3.notify();
|
|
105
|
+
(_instance$onClose = instance.onClose) === null || _instance$onClose === void 0 || _instance$onClose.call(instance);
|
|
106
|
+
}
|
|
107
|
+
}, 300);
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
key: "destroy",
|
|
111
|
+
value: function destroy(key) {
|
|
112
|
+
var _this4 = this;
|
|
113
|
+
if (key) {
|
|
114
|
+
this.remove(key);
|
|
115
|
+
} else {
|
|
116
|
+
this.instances.forEach(function (instance) {
|
|
117
|
+
instance.closing = true;
|
|
118
|
+
});
|
|
119
|
+
this.notify();
|
|
120
|
+
setTimeout(function () {
|
|
121
|
+
_this4.instances.forEach(function (instance) {
|
|
122
|
+
var _instance$onClose2;
|
|
123
|
+
(_instance$onClose2 = instance.onClose) === null || _instance$onClose2 === void 0 || _instance$onClose2.call(instance);
|
|
124
|
+
});
|
|
125
|
+
_this4.instances = [];
|
|
126
|
+
_this4.notify();
|
|
127
|
+
}, 300);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}, {
|
|
131
|
+
key: "getInstances",
|
|
132
|
+
value: function getInstances() {
|
|
133
|
+
return this.instances;
|
|
134
|
+
}
|
|
135
|
+
}]);
|
|
136
|
+
return MessageManager;
|
|
137
|
+
}();
|
|
138
|
+
var messageManager = new MessageManager();
|
|
139
|
+
|
|
140
|
+
// ============ Message 容器组件 ============
|
|
141
|
+
var MessageContainer = function MessageContainer() {
|
|
142
|
+
var _useState = (0, _react.useState)({}),
|
|
143
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
144
|
+
forceUpdate = _useState2[1];
|
|
145
|
+
(0, _react.useEffect)(function () {
|
|
146
|
+
var unsubscribe = messageManager.subscribe(function () {
|
|
147
|
+
forceUpdate({});
|
|
148
|
+
});
|
|
149
|
+
return unsubscribe;
|
|
150
|
+
}, []);
|
|
151
|
+
var instances = messageManager.getInstances();
|
|
152
|
+
if (instances.length === 0) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
156
|
+
className: "kage-message-container",
|
|
157
|
+
children: instances.map(function (instance) {
|
|
158
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(MessageItem, {
|
|
159
|
+
instance: instance
|
|
160
|
+
}, instance.key);
|
|
161
|
+
})
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// ============ Message 项组件 ============
|
|
166
|
+
var MessageItem = function MessageItem(_ref) {
|
|
167
|
+
var instance = _ref.instance;
|
|
168
|
+
var content = instance.content,
|
|
169
|
+
_instance$type = instance.type,
|
|
170
|
+
type = _instance$type === void 0 ? 'info' : _instance$type,
|
|
171
|
+
icon = instance.icon,
|
|
172
|
+
_instance$className = instance.className,
|
|
173
|
+
className = _instance$className === void 0 ? '' : _instance$className,
|
|
174
|
+
style = instance.style,
|
|
175
|
+
closing = instance.closing,
|
|
176
|
+
visible = instance.visible;
|
|
177
|
+
if (!visible && !closing) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
var classNames = ['kage-message', "kage-message-".concat(type), closing && 'kage-message-closing', className].filter(Boolean).join(' ');
|
|
181
|
+
var iconNode = icon || defaultIcons[type];
|
|
182
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
183
|
+
className: classNames,
|
|
184
|
+
style: style,
|
|
185
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
186
|
+
className: "kage-message-icon",
|
|
187
|
+
children: iconNode
|
|
188
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
189
|
+
className: "kage-message-content",
|
|
190
|
+
children: content
|
|
191
|
+
})]
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// ============ Message API ============
|
|
196
|
+
var messageApi = {
|
|
197
|
+
success: function success(content, duration, onClose) {
|
|
198
|
+
messageManager.add({
|
|
199
|
+
content: content,
|
|
200
|
+
type: 'success',
|
|
201
|
+
duration: duration,
|
|
202
|
+
onClose: onClose
|
|
203
|
+
});
|
|
204
|
+
},
|
|
205
|
+
error: function error(content, duration, onClose) {
|
|
206
|
+
messageManager.add({
|
|
207
|
+
content: content,
|
|
208
|
+
type: 'error',
|
|
209
|
+
duration: duration,
|
|
210
|
+
onClose: onClose
|
|
211
|
+
});
|
|
212
|
+
},
|
|
213
|
+
info: function info(content, duration, onClose) {
|
|
214
|
+
messageManager.add({
|
|
215
|
+
content: content,
|
|
216
|
+
type: 'info',
|
|
217
|
+
duration: duration,
|
|
218
|
+
onClose: onClose
|
|
219
|
+
});
|
|
220
|
+
},
|
|
221
|
+
warning: function warning(content, duration, onClose) {
|
|
222
|
+
messageManager.add({
|
|
223
|
+
content: content,
|
|
224
|
+
type: 'warning',
|
|
225
|
+
duration: duration,
|
|
226
|
+
onClose: onClose
|
|
227
|
+
});
|
|
228
|
+
},
|
|
229
|
+
loading: function loading(content, duration, onClose) {
|
|
230
|
+
messageManager.add({
|
|
231
|
+
content: content,
|
|
232
|
+
type: 'loading',
|
|
233
|
+
duration: duration,
|
|
234
|
+
onClose: onClose
|
|
235
|
+
});
|
|
236
|
+
},
|
|
237
|
+
open: function open(config) {
|
|
238
|
+
messageManager.add(config);
|
|
239
|
+
},
|
|
240
|
+
destroy: function destroy(key) {
|
|
241
|
+
messageManager.destroy(key);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// ============ Message 组件 ============
|
|
246
|
+
var Message = exports.Message = {};
|
|
247
|
+
|
|
248
|
+
// 将 API 方法挂载到组件上
|
|
249
|
+
Object.assign(Message, messageApi);
|
|
250
|
+
Message.Container = MessageContainer;
|
|
251
|
+
|
|
252
|
+
// 初始化容器(延迟执行,避免 SSR 问题)
|
|
253
|
+
var containerElement = null;
|
|
254
|
+
var containerMounted = false;
|
|
255
|
+
var getContainer = function getContainer() {
|
|
256
|
+
if (!containerElement && typeof document !== 'undefined') {
|
|
257
|
+
containerElement = document.createElement('div');
|
|
258
|
+
containerElement.className = 'kage-message-root';
|
|
259
|
+
document.body.appendChild(containerElement);
|
|
260
|
+
}
|
|
261
|
+
return containerElement;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
// 延迟初始化容器组件
|
|
265
|
+
var initContainer = function initContainer() {
|
|
266
|
+
if (containerMounted || typeof document === 'undefined') return;
|
|
267
|
+
containerMounted = true;
|
|
268
|
+
var container = getContainer();
|
|
269
|
+
try {
|
|
270
|
+
var _React = require('react');
|
|
271
|
+
var ReactDOM = require('react-dom');
|
|
272
|
+
if (ReactDOM.createRoot) {
|
|
273
|
+
// React 18
|
|
274
|
+
ReactDOM.createRoot(container).render(_React.createElement(MessageContainer));
|
|
275
|
+
} else if (ReactDOM.render) {
|
|
276
|
+
// React 17
|
|
277
|
+
ReactDOM.render(_React.createElement(MessageContainer), container);
|
|
278
|
+
}
|
|
279
|
+
} catch (e) {
|
|
280
|
+
// 静默失败,避免影响应用启动
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// 在浏览器环境中初始化
|
|
285
|
+
if (typeof window !== 'undefined') {
|
|
286
|
+
if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
|
287
|
+
setTimeout(initContainer, 0);
|
|
288
|
+
} else {
|
|
289
|
+
document.addEventListener('DOMContentLoaded', initContainer);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
var _default = exports.default = Message;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
// Message 全局提示样式
|
|
2
|
+
|
|
3
|
+
@prefix: kage-message;
|
|
4
|
+
|
|
5
|
+
// 颜色变量
|
|
6
|
+
@message-bg: #fff;
|
|
7
|
+
@message-success-color: #52c41a;
|
|
8
|
+
@message-info-color: #1890ff;
|
|
9
|
+
@message-warning-color: #faad14;
|
|
10
|
+
@message-error-color: #ff4d4f;
|
|
11
|
+
@message-text-color: rgba(0, 0, 0, 0.85);
|
|
12
|
+
@message-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12),
|
|
13
|
+
0 9px 28px 8px rgba(0, 0, 0, 0.05);
|
|
14
|
+
|
|
15
|
+
// ============ 根容器 ============
|
|
16
|
+
.kage-message-root {
|
|
17
|
+
position: fixed;
|
|
18
|
+
top: 0;
|
|
19
|
+
left: 0;
|
|
20
|
+
right: 0;
|
|
21
|
+
pointer-events: none;
|
|
22
|
+
z-index: 1010;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ============ 消息容器 ============
|
|
26
|
+
.@{prefix}-container {
|
|
27
|
+
position: fixed;
|
|
28
|
+
top: 16px;
|
|
29
|
+
left: 50%;
|
|
30
|
+
transform: translateX(-50%);
|
|
31
|
+
z-index: 1010;
|
|
32
|
+
pointer-events: none;
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
align-items: center;
|
|
36
|
+
gap: 8px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ============ 消息项 ============
|
|
40
|
+
.@{prefix} {
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
min-width: 200px;
|
|
44
|
+
max-width: 400px;
|
|
45
|
+
padding: 9px 12px;
|
|
46
|
+
background-color: @message-bg;
|
|
47
|
+
border-radius: 6px;
|
|
48
|
+
box-shadow: @message-shadow;
|
|
49
|
+
font-size: 14px;
|
|
50
|
+
line-height: 1.5715;
|
|
51
|
+
color: @message-text-color;
|
|
52
|
+
pointer-events: auto;
|
|
53
|
+
opacity: 1;
|
|
54
|
+
transform: translateY(0);
|
|
55
|
+
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
56
|
+
|
|
57
|
+
* {
|
|
58
|
+
box-sizing: border-box;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ============ 图标 ============
|
|
63
|
+
.@{prefix}-icon {
|
|
64
|
+
display: inline-flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
width: 20px;
|
|
68
|
+
height: 20px;
|
|
69
|
+
margin-right: 8px;
|
|
70
|
+
font-size: 16px;
|
|
71
|
+
line-height: 1;
|
|
72
|
+
flex-shrink: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ============ 内容 ============
|
|
76
|
+
.@{prefix}-content {
|
|
77
|
+
flex: 1;
|
|
78
|
+
word-wrap: break-word;
|
|
79
|
+
word-break: break-word;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ============ 不同类型 ============
|
|
83
|
+
.@{prefix}-success {
|
|
84
|
+
.@{prefix}-icon {
|
|
85
|
+
color: @message-success-color;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.@{prefix}-info {
|
|
90
|
+
.@{prefix}-icon {
|
|
91
|
+
color: @message-info-color;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.@{prefix}-warning {
|
|
96
|
+
.@{prefix}-icon {
|
|
97
|
+
color: @message-warning-color;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.@{prefix}-error {
|
|
102
|
+
.@{prefix}-icon {
|
|
103
|
+
color: @message-error-color;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.@{prefix}-loading {
|
|
108
|
+
.@{prefix}-icon {
|
|
109
|
+
color: @message-info-color;
|
|
110
|
+
animation: messageLoading 1s linear infinite;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@keyframes messageLoading {
|
|
115
|
+
from {
|
|
116
|
+
transform: rotate(0deg);
|
|
117
|
+
}
|
|
118
|
+
to {
|
|
119
|
+
transform: rotate(360deg);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// ============ 关闭动画 ============
|
|
124
|
+
.@{prefix}-closing {
|
|
125
|
+
opacity: 0;
|
|
126
|
+
transform: translateY(-20px);
|
|
127
|
+
margin-top: 0 !important;
|
|
128
|
+
margin-bottom: 0 !important;
|
|
129
|
+
padding-top: 0;
|
|
130
|
+
padding-bottom: 0;
|
|
131
|
+
height: 0;
|
|
132
|
+
overflow: hidden;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// ============ 暗色模式适配 ============
|
|
136
|
+
[data-theme='dark'],
|
|
137
|
+
[data-prefers-color-scheme='dark'],
|
|
138
|
+
[data-prefers-color='dark'],
|
|
139
|
+
html.dark,
|
|
140
|
+
body.dark,
|
|
141
|
+
.dark {
|
|
142
|
+
.@{prefix} {
|
|
143
|
+
background-color: #1f1f1f;
|
|
144
|
+
color: rgba(255, 255, 255, 0.85);
|
|
145
|
+
box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.48), 0 3px 6px -4px rgba(0, 0, 0, 0.32),
|
|
146
|
+
0 9px 28px 8px rgba(0, 0, 0, 0.2);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.@{prefix}-content {
|
|
150
|
+
color: rgba(255, 255, 255, 0.85);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.@{prefix}-success {
|
|
154
|
+
.@{prefix}-icon {
|
|
155
|
+
color: #52c41a;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.@{prefix}-info {
|
|
160
|
+
.@{prefix}-icon {
|
|
161
|
+
color: #1890ff;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.@{prefix}-warning {
|
|
166
|
+
.@{prefix}-icon {
|
|
167
|
+
color: #faad14;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.@{prefix}-error {
|
|
172
|
+
.@{prefix}-icon {
|
|
173
|
+
color: #ff4d4f;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.@{prefix}-loading {
|
|
178
|
+
.@{prefix}-icon {
|
|
179
|
+
color: #1890ff;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, { ReactNode, CSSProperties } from 'react';
|
|
2
|
+
import './style.less';
|
|
3
|
+
/** Modal 属性 */
|
|
4
|
+
export interface ModalProps {
|
|
5
|
+
/** 是否显示 */
|
|
6
|
+
open?: boolean;
|
|
7
|
+
/** 默认是否显示 */
|
|
8
|
+
defaultOpen?: boolean;
|
|
9
|
+
/** 显示隐藏的回调 */
|
|
10
|
+
onClose?: (e: React.MouseEvent | React.KeyboardEvent) => void;
|
|
11
|
+
/** 关闭后的回调 */
|
|
12
|
+
afterOpenChange?: (open: boolean) => void;
|
|
13
|
+
/** 标题 */
|
|
14
|
+
title?: ReactNode;
|
|
15
|
+
/** 内容 */
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
/** 是否显示遮罩 */
|
|
18
|
+
mask?: boolean;
|
|
19
|
+
/** 点击遮罩是否关闭 */
|
|
20
|
+
maskClosable?: boolean;
|
|
21
|
+
/** 是否显示关闭按钮 */
|
|
22
|
+
closable?: boolean;
|
|
23
|
+
/** 自定义关闭图标 */
|
|
24
|
+
closeIcon?: ReactNode;
|
|
25
|
+
/** 自定义遮罩样式 */
|
|
26
|
+
maskStyle?: CSSProperties;
|
|
27
|
+
/** 自定义主体内容样式 */
|
|
28
|
+
bodyStyle?: CSSProperties;
|
|
29
|
+
/** 自定义头部样式 */
|
|
30
|
+
headerStyle?: CSSProperties;
|
|
31
|
+
/** 自定义底部样式 */
|
|
32
|
+
footerStyle?: CSSProperties;
|
|
33
|
+
/** 底部内容 */
|
|
34
|
+
footer?: ReactNode;
|
|
35
|
+
/** 宽度 */
|
|
36
|
+
width?: number | string;
|
|
37
|
+
/** 是否居中显示 */
|
|
38
|
+
centered?: boolean;
|
|
39
|
+
/** 自定义类名 */
|
|
40
|
+
className?: string;
|
|
41
|
+
/** 自定义样式 */
|
|
42
|
+
style?: CSSProperties;
|
|
43
|
+
/** z-index */
|
|
44
|
+
zIndex?: number;
|
|
45
|
+
/** 是否支持键盘 ESC 关闭 */
|
|
46
|
+
keyboard?: boolean;
|
|
47
|
+
/** 是否在关闭时销毁 Modal 里的子元素 */
|
|
48
|
+
destroyOnClose?: boolean;
|
|
49
|
+
/** 是否显示遮罩背景 */
|
|
50
|
+
maskClassName?: string;
|
|
51
|
+
/** 确认按钮文字 */
|
|
52
|
+
okText?: ReactNode;
|
|
53
|
+
/** 取消按钮文字 */
|
|
54
|
+
cancelText?: ReactNode;
|
|
55
|
+
/** 确认按钮 loading */
|
|
56
|
+
confirmLoading?: boolean;
|
|
57
|
+
/** 点击确定回调 */
|
|
58
|
+
onOk?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
59
|
+
/** 点击取消回调 */
|
|
60
|
+
onCancel?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
61
|
+
}
|
|
62
|
+
export declare const Modal: React.FC<ModalProps>;
|
|
63
|
+
export default Modal;
|