1 | (function(global2, factory) {
|
2 | typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("react-dom")) : typeof define === "function" && define.amd ? define(["exports", "react", "react-dom"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2.antdMobile = {}, global2.React, global2.ReactDOM));
|
3 | })(this, function(exports2, React$1, ReactDOM) {
|
4 | "use strict";
|
5 | function _interopNamespaceDefault(e2) {
|
6 | const n2 = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
7 | if (e2) {
|
8 | for (const k in e2) {
|
9 | if (k !== "default") {
|
10 | const d = Object.getOwnPropertyDescriptor(e2, k);
|
11 | Object.defineProperty(n2, k, d.get ? d : {
|
12 | enumerable: true,
|
13 | get: () => e2[k]
|
14 | });
|
15 | }
|
16 | }
|
17 | }
|
18 | n2.default = e2;
|
19 | return Object.freeze(n2);
|
20 | }
|
21 | const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React$1);
|
22 | const ReactDOM__namespace = /* @__PURE__ */ _interopNamespaceDefault(ReactDOM);
|
23 | const canUseDom$1 = !!(typeof window !== "undefined" && typeof document !== "undefined" && window.document && window.document.createElement);
|
24 | if (canUseDom$1) {
|
25 | document.addEventListener("touchstart", () => {
|
26 | }, true);
|
27 | }
|
28 | var __assign = function() {
|
29 | __assign = Object.assign || function __assign2(t) {
|
30 | for (var s, i2 = 1, n2 = arguments.length; i2 < n2; i2++) {
|
31 | s = arguments[i2];
|
32 | for (var p in s)
|
33 | if (Object.prototype.hasOwnProperty.call(s, p))
|
34 | t[p] = s[p];
|
35 | }
|
36 | return t;
|
37 | };
|
38 | return __assign.apply(this, arguments);
|
39 | };
|
40 | function __rest(s, e2) {
|
41 | var t = {};
|
42 | for (var p in s)
|
43 | if (Object.prototype.hasOwnProperty.call(s, p) && e2.indexOf(p) < 0)
|
44 | t[p] = s[p];
|
45 | if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
46 | for (var i2 = 0, p = Object.getOwnPropertySymbols(s); i2 < p.length; i2++) {
|
47 | if (e2.indexOf(p[i2]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i2]))
|
48 | t[p[i2]] = s[p[i2]];
|
49 | }
|
50 | return t;
|
51 | }
|
52 | function __awaiter(thisArg, _arguments, P, generator) {
|
53 | function adopt(value) {
|
54 | return value instanceof P ? value : new P(function(resolve) {
|
55 | resolve(value);
|
56 | });
|
57 | }
|
58 | return new (P || (P = Promise))(function(resolve, reject) {
|
59 | function fulfilled(value) {
|
60 | try {
|
61 | step(generator.next(value));
|
62 | } catch (e2) {
|
63 | reject(e2);
|
64 | }
|
65 | }
|
66 | function rejected(value) {
|
67 | try {
|
68 | step(generator["throw"](value));
|
69 | } catch (e2) {
|
70 | reject(e2);
|
71 | }
|
72 | }
|
73 | function step(result) {
|
74 | result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
75 | }
|
76 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
77 | });
|
78 | }
|
79 | function __generator(thisArg, body) {
|
80 | var _ = { label: 0, sent: function() {
|
81 | if (t[0] & 1)
|
82 | throw t[1];
|
83 | return t[1];
|
84 | }, trys: [], ops: [] }, f, y, t, g;
|
85 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
86 | return this;
|
87 | }), g;
|
88 | function verb(n2) {
|
89 | return function(v) {
|
90 | return step([n2, v]);
|
91 | };
|
92 | }
|
93 | function step(op) {
|
94 | if (f)
|
95 | throw new TypeError("Generator is already executing.");
|
96 | while (g && (g = 0, op[0] && (_ = 0)), _)
|
97 | try {
|
98 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
99 | return t;
|
100 | if (y = 0, t)
|
101 | op = [op[0] & 2, t.value];
|
102 | switch (op[0]) {
|
103 | case 0:
|
104 | case 1:
|
105 | t = op;
|
106 | break;
|
107 | case 4:
|
108 | _.label++;
|
109 | return { value: op[1], done: false };
|
110 | case 5:
|
111 | _.label++;
|
112 | y = op[1];
|
113 | op = [0];
|
114 | continue;
|
115 | case 7:
|
116 | op = _.ops.pop();
|
117 | _.trys.pop();
|
118 | continue;
|
119 | default:
|
120 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
121 | _ = 0;
|
122 | continue;
|
123 | }
|
124 | if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
125 | _.label = op[1];
|
126 | break;
|
127 | }
|
128 | if (op[0] === 6 && _.label < t[1]) {
|
129 | _.label = t[1];
|
130 | t = op;
|
131 | break;
|
132 | }
|
133 | if (t && _.label < t[2]) {
|
134 | _.label = t[2];
|
135 | _.ops.push(op);
|
136 | break;
|
137 | }
|
138 | if (t[2])
|
139 | _.ops.pop();
|
140 | _.trys.pop();
|
141 | continue;
|
142 | }
|
143 | op = body.call(thisArg, _);
|
144 | } catch (e2) {
|
145 | op = [6, e2];
|
146 | y = 0;
|
147 | } finally {
|
148 | f = t = 0;
|
149 | }
|
150 | if (op[0] & 5)
|
151 | throw op[1];
|
152 | return { value: op[0] ? op[1] : void 0, done: true };
|
153 | }
|
154 | }
|
155 | function __values(o) {
|
156 | var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i2 = 0;
|
157 | if (m)
|
158 | return m.call(o);
|
159 | if (o && typeof o.length === "number")
|
160 | return {
|
161 | next: function() {
|
162 | if (o && i2 >= o.length)
|
163 | o = void 0;
|
164 | return { value: o && o[i2++], done: !o };
|
165 | }
|
166 | };
|
167 | throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
168 | }
|
169 | function __read(o, n2) {
|
170 | var m = typeof Symbol === "function" && o[Symbol.iterator];
|
171 | if (!m)
|
172 | return o;
|
173 | var i2 = m.call(o), r, ar = [], e2;
|
174 | try {
|
175 | while ((n2 === void 0 || n2-- > 0) && !(r = i2.next()).done)
|
176 | ar.push(r.value);
|
177 | } catch (error) {
|
178 | e2 = { error };
|
179 | } finally {
|
180 | try {
|
181 | if (r && !r.done && (m = i2["return"]))
|
182 | m.call(i2);
|
183 | } finally {
|
184 | if (e2)
|
185 | throw e2.error;
|
186 | }
|
187 | }
|
188 | return ar;
|
189 | }
|
190 | function __spreadArray(to2, from, pack) {
|
191 | if (pack || arguments.length === 2)
|
192 | for (var i2 = 0, l = from.length, ar; i2 < l; i2++) {
|
193 | if (ar || !(i2 in from)) {
|
194 | if (!ar)
|
195 | ar = Array.prototype.slice.call(from, 0, i2);
|
196 | ar[i2] = from[i2];
|
197 | }
|
198 | }
|
199 | return to2.concat(ar || Array.prototype.slice.call(from));
|
200 | }
|
201 | typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
202 | var e2 = new Error(message);
|
203 | return e2.name = "SuppressedError", e2.error = error, e2.suppressed = suppressed, e2;
|
204 | };
|
205 | const typeTemplate$1 = "${label}不是一个有效的${type}";
|
206 | const zhCN = {
|
207 | locale: "zh-CH",
|
208 | common: {
|
209 | confirm: "确定",
|
210 | cancel: "取消",
|
211 | loading: "加载中",
|
212 | close: "关闭"
|
213 | },
|
214 | Calendar: {
|
215 | title: "日期选择",
|
216 | confirm: "确认",
|
217 | start: "开始",
|
218 | end: "结束",
|
219 | today: "今日",
|
220 | markItems: ["一", "二", "三", "四", "五", "六", "日"],
|
221 | yearAndMonth: "${year}年${month}月"
|
222 | },
|
223 | Cascader: {
|
224 | placeholder: "请选择"
|
225 | },
|
226 | Dialog: {
|
227 | ok: "我知道了"
|
228 | },
|
229 | DatePicker: {
|
230 | tillNow: "至今"
|
231 | },
|
232 | ErrorBlock: {
|
233 | default: {
|
234 | title: "页面遇到一些小问题",
|
235 | description: "待会来试试"
|
236 | },
|
237 | busy: {
|
238 | title: "前方拥堵",
|
239 | description: "刷新试试"
|
240 | },
|
241 | disconnected: {
|
242 | title: "网络有点忙",
|
243 | description: "动动手指帮忙修复"
|
244 | },
|
245 | empty: {
|
246 | title: "没有找到你需要的东西",
|
247 | description: "找找其他的吧"
|
248 | }
|
249 | },
|
250 | Form: {
|
251 | required: "必填",
|
252 | optional: "选填",
|
253 | defaultValidateMessages: {
|
254 | default: "字段验证错误${label}",
|
255 | required: "请输入${label}",
|
256 | enum: "${label}必须是其中一个[${enum}]",
|
257 | whitespace: "${label}不能为空字符",
|
258 | date: {
|
259 | format: "${label}日期格式无效",
|
260 | parse: "${label}不能转换为日期",
|
261 | invalid: "${label}是一个无效日期"
|
262 | },
|
263 | types: {
|
264 | string: typeTemplate$1,
|
265 | method: typeTemplate$1,
|
266 | array: typeTemplate$1,
|
267 | object: typeTemplate$1,
|
268 | number: typeTemplate$1,
|
269 | date: typeTemplate$1,
|
270 | boolean: typeTemplate$1,
|
271 | integer: typeTemplate$1,
|
272 | float: typeTemplate$1,
|
273 | regexp: typeTemplate$1,
|
274 | email: typeTemplate$1,
|
275 | url: typeTemplate$1,
|
276 | hex: typeTemplate$1
|
277 | },
|
278 | string: {
|
279 | len: "${label}须为${len}个字符",
|
280 | min: "${label}最少${min}个字符",
|
281 | max: "${label}最多${max}个字符",
|
282 | range: "${label}须在${min}-${max}字符之间"
|
283 | },
|
284 | number: {
|
285 | len: "${label}必须等于${len}",
|
286 | min: "${label}最小值为${min}",
|
287 | max: "${label}最大值为${max}",
|
288 | range: "${label}须在${min}-${max}之间"
|
289 | },
|
290 | array: {
|
291 | len: "须为${len}个${label}",
|
292 | min: "最少${min}个${label}",
|
293 | max: "最多${max}个${label}",
|
294 | range: "${label}数量须在${min}-${max}之间"
|
295 | },
|
296 | pattern: {
|
297 | mismatch: "${label}与模式不匹配${pattern}"
|
298 | }
|
299 | }
|
300 | },
|
301 | ImageUploader: {
|
302 | uploading: "上传中...",
|
303 | upload: "上传"
|
304 | },
|
305 | InfiniteScroll: {
|
306 | noMore: "没有更多了",
|
307 | failedToLoad: "加载失败",
|
308 | retry: "重新加载"
|
309 | },
|
310 | Input: {
|
311 | clear: "清除"
|
312 | },
|
313 | Mask: {
|
314 | name: "背景蒙层"
|
315 | },
|
316 | Modal: {
|
317 | ok: "我知道了"
|
318 | },
|
319 | PasscodeInput: {
|
320 | name: "密码输入框"
|
321 | },
|
322 | PullToRefresh: {
|
323 | pulling: "下拉刷新",
|
324 | canRelease: "释放立即刷新",
|
325 | complete: "刷新成功"
|
326 | },
|
327 | SearchBar: {
|
328 | name: "搜索框"
|
329 | },
|
330 | Slider: {
|
331 | name: "滑动输入条"
|
332 | },
|
333 | Stepper: {
|
334 | decrease: "减少",
|
335 | increase: "增加"
|
336 | },
|
337 | Switch: {
|
338 | name: "开关"
|
339 | },
|
340 | Selector: {
|
341 | name: "选择组"
|
342 | }
|
343 | };
|
344 | const zhCN$1 = zhCN;
|
345 | const defaultConfigRef = {
|
346 | current: {
|
347 | locale: zhCN$1
|
348 | }
|
349 | };
|
350 | function setDefaultConfig(config2) {
|
351 | defaultConfigRef.current = config2;
|
352 | }
|
353 | function getDefaultConfig() {
|
354 | return defaultConfigRef.current;
|
355 | }
|
356 | const ConfigContext = React$1.createContext(null);
|
357 | const ConfigProvider = (props) => {
|
358 | const {
|
359 | children
|
360 | } = props, config2 = __rest(props, ["children"]);
|
361 | const parentConfig = useConfig();
|
362 | return React$1.createElement(ConfigContext.Provider, {
|
363 | value: Object.assign(Object.assign({}, parentConfig), config2)
|
364 | }, children);
|
365 | };
|
366 | function useConfig() {
|
367 | var _a;
|
368 | return (_a = React$1.useContext(ConfigContext)) !== null && _a !== void 0 ? _a : getDefaultConfig();
|
369 | }
|
370 | function attachPropertiesToComponent(component, properties) {
|
371 | const ret = component;
|
372 | for (const key in properties) {
|
373 | if (properties.hasOwnProperty(key)) {
|
374 | ret[key] = properties[key];
|
375 | }
|
376 | }
|
377 | return ret;
|
378 | }
|
379 | var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
380 | function getDefaultExportFromCjs(x) {
|
381 | return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
382 | }
|
383 | var classnames = { exports: {} };
|
384 | |
385 |
|
386 |
|
387 |
|
388 |
|
389 | (function(module2) {
|
390 | (function() {
|
391 | var hasOwn = {}.hasOwnProperty;
|
392 | function classNames2() {
|
393 | var classes = [];
|
394 | for (var i2 = 0; i2 < arguments.length; i2++) {
|
395 | var arg = arguments[i2];
|
396 | if (!arg)
|
397 | continue;
|
398 | var argType = typeof arg;
|
399 | if (argType === "string" || argType === "number") {
|
400 | classes.push(arg);
|
401 | } else if (Array.isArray(arg)) {
|
402 | if (arg.length) {
|
403 | var inner = classNames2.apply(null, arg);
|
404 | if (inner) {
|
405 | classes.push(inner);
|
406 | }
|
407 | }
|
408 | } else if (argType === "object") {
|
409 | if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
410 | classes.push(arg.toString());
|
411 | continue;
|
412 | }
|
413 | for (var key in arg) {
|
414 | if (hasOwn.call(arg, key) && arg[key]) {
|
415 | classes.push(key);
|
416 | }
|
417 | }
|
418 | }
|
419 | }
|
420 | return classes.join(" ");
|
421 | }
|
422 | if (module2.exports) {
|
423 | classNames2.default = classNames2;
|
424 | module2.exports = classNames2;
|
425 | } else {
|
426 | window.classNames = classNames2;
|
427 | }
|
428 | })();
|
429 | })(classnames);
|
430 | var classnamesExports = classnames.exports;
|
431 | const classNames = getDefaultExportFromCjs(classnamesExports);
|
432 | function withNativeProps(props, element) {
|
433 | const p = Object.assign({}, element.props);
|
434 | if (props.className) {
|
435 | p.className = classNames(element.props.className, props.className);
|
436 | }
|
437 | if (props.style) {
|
438 | p.style = Object.assign(Object.assign({}, p.style), props.style);
|
439 | }
|
440 | if (props.tabIndex !== void 0) {
|
441 | p.tabIndex = props.tabIndex;
|
442 | }
|
443 | for (const key in props) {
|
444 | if (!props.hasOwnProperty(key))
|
445 | continue;
|
446 | if (key.startsWith("data-") || key.startsWith("aria-")) {
|
447 | p[key] = props[key];
|
448 | }
|
449 | }
|
450 | return React$1.cloneElement(element, p);
|
451 | }
|
452 | function mergeProps(...items) {
|
453 | const ret = {};
|
454 | items.forEach((item) => {
|
455 | if (item) {
|
456 | Object.keys(item).forEach((key) => {
|
457 | if (item[key] !== void 0) {
|
458 | ret[key] = item[key];
|
459 | }
|
460 | });
|
461 | }
|
462 | });
|
463 | return ret;
|
464 | }
|
465 | function mergeProp(defaultProp, ...propList) {
|
466 | for (let i2 = propList.length - 1; i2 >= 0; i2 -= 1) {
|
467 | if (propList[i2] !== void 0) {
|
468 | return propList[i2];
|
469 | }
|
470 | }
|
471 | return defaultProp;
|
472 | }
|
473 | var createUpdateEffect = function(hook) {
|
474 | return function(effect, deps) {
|
475 | var isMounted = React$1.useRef(false);
|
476 | hook(function() {
|
477 | return function() {
|
478 | isMounted.current = false;
|
479 | };
|
480 | }, []);
|
481 | hook(function() {
|
482 | if (!isMounted.current) {
|
483 | isMounted.current = true;
|
484 | } else {
|
485 | return effect();
|
486 | }
|
487 | }, deps);
|
488 | };
|
489 | };
|
490 | var isFunction = function(value) {
|
491 | return typeof value === "function";
|
492 | };
|
493 | var isNumber = function(value) {
|
494 | return typeof value === "number";
|
495 | };
|
496 | var isDev = true;
|
497 | const isDev$1 = isDev;
|
498 | function useMemoizedFn(fn) {
|
499 | if (isDev$1) {
|
500 | if (!isFunction(fn)) {
|
501 | console.error("useMemoizedFn expected parameter is a function, got ".concat(typeof fn));
|
502 | }
|
503 | }
|
504 | var fnRef = React$1.useRef(fn);
|
505 | fnRef.current = React$1.useMemo(function() {
|
506 | return fn;
|
507 | }, [fn]);
|
508 | var memoizedFn = React$1.useRef();
|
509 | if (!memoizedFn.current) {
|
510 | memoizedFn.current = function() {
|
511 | var args = [];
|
512 | for (var _i = 0; _i < arguments.length; _i++) {
|
513 | args[_i] = arguments[_i];
|
514 | }
|
515 | return fnRef.current.apply(this, args);
|
516 | };
|
517 | }
|
518 | return memoizedFn.current;
|
519 | }
|
520 | const useUpdateEffect = createUpdateEffect(React$1.useEffect);
|
521 | function depsAreSame(oldDeps, deps) {
|
522 | if (oldDeps === deps)
|
523 | return true;
|
524 | for (var i2 = 0; i2 < oldDeps.length; i2++) {
|
525 | if (!Object.is(oldDeps[i2], deps[i2]))
|
526 | return false;
|
527 | }
|
528 | return true;
|
529 | }
|
530 | function useLatest(value) {
|
531 | var ref = React$1.useRef(value);
|
532 | ref.current = value;
|
533 | return ref;
|
534 | }
|
535 | var useUnmount = function(fn) {
|
536 | if (isDev$1) {
|
537 | if (!isFunction(fn)) {
|
538 | console.error("useUnmount expected parameter is a function, got ".concat(typeof fn));
|
539 | }
|
540 | }
|
541 | var fnRef = useLatest(fn);
|
542 | React$1.useEffect(function() {
|
543 | return function() {
|
544 | fnRef.current();
|
545 | };
|
546 | }, []);
|
547 | };
|
548 | const useUnmount$1 = useUnmount;
|
549 | function isObject$4(value) {
|
550 | var type = typeof value;
|
551 | return value != null && (type == "object" || type == "function");
|
552 | }
|
553 | var isObject_1 = isObject$4;
|
554 | var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
555 | var _freeGlobal = freeGlobal$1;
|
556 | var freeGlobal = _freeGlobal;
|
557 | var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
558 | var root$2 = freeGlobal || freeSelf || Function("return this")();
|
559 | var _root = root$2;
|
560 | var root$1 = _root;
|
561 | var now$1 = function() {
|
562 | return root$1.Date.now();
|
563 | };
|
564 | var now_1 = now$1;
|
565 | var reWhitespace = /\s/;
|
566 | function trimmedEndIndex$1(string2) {
|
567 | var index2 = string2.length;
|
568 | while (index2-- && reWhitespace.test(string2.charAt(index2))) {
|
569 | }
|
570 | return index2;
|
571 | }
|
572 | var _trimmedEndIndex = trimmedEndIndex$1;
|
573 | var trimmedEndIndex = _trimmedEndIndex;
|
574 | var reTrimStart = /^\s+/;
|
575 | function baseTrim$1(string2) {
|
576 | return string2 ? string2.slice(0, trimmedEndIndex(string2) + 1).replace(reTrimStart, "") : string2;
|
577 | }
|
578 | var _baseTrim = baseTrim$1;
|
579 | var root = _root;
|
580 | var Symbol$3 = root.Symbol;
|
581 | var _Symbol = Symbol$3;
|
582 | var Symbol$2 = _Symbol;
|
583 | var objectProto$1 = Object.prototype;
|
584 | var hasOwnProperty = objectProto$1.hasOwnProperty;
|
585 | var nativeObjectToString$1 = objectProto$1.toString;
|
586 | var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : void 0;
|
587 | function getRawTag$1(value) {
|
588 | var isOwn = hasOwnProperty.call(value, symToStringTag$1), tag = value[symToStringTag$1];
|
589 | try {
|
590 | value[symToStringTag$1] = void 0;
|
591 | var unmasked = true;
|
592 | } catch (e2) {
|
593 | }
|
594 | var result = nativeObjectToString$1.call(value);
|
595 | if (unmasked) {
|
596 | if (isOwn) {
|
597 | value[symToStringTag$1] = tag;
|
598 | } else {
|
599 | delete value[symToStringTag$1];
|
600 | }
|
601 | }
|
602 | return result;
|
603 | }
|
604 | var _getRawTag = getRawTag$1;
|
605 | var objectProto = Object.prototype;
|
606 | var nativeObjectToString = objectProto.toString;
|
607 | function objectToString$1(value) {
|
608 | return nativeObjectToString.call(value);
|
609 | }
|
610 | var _objectToString = objectToString$1;
|
611 | var Symbol$1 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
|
612 | var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
|
613 | var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : void 0;
|
614 | function baseGetTag$1(value) {
|
615 | if (value == null) {
|
616 | return value === void 0 ? undefinedTag : nullTag;
|
617 | }
|
618 | return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
619 | }
|
620 | var _baseGetTag = baseGetTag$1;
|
621 | function isObjectLike$1(value) {
|
622 | return value != null && typeof value == "object";
|
623 | }
|
624 | var isObjectLike_1 = isObjectLike$1;
|
625 | var baseGetTag = _baseGetTag, isObjectLike = isObjectLike_1;
|
626 | var symbolTag = "[object Symbol]";
|
627 | function isSymbol$1(value) {
|
628 | return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag;
|
629 | }
|
630 | var isSymbol_1 = isSymbol$1;
|
631 | var baseTrim = _baseTrim, isObject$3 = isObject_1, isSymbol = isSymbol_1;
|
632 | var NAN = 0 / 0;
|
633 | var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
634 | var reIsBinary = /^0b[01]+$/i;
|
635 | var reIsOctal = /^0o[0-7]+$/i;
|
636 | var freeParseInt = parseInt;
|
637 | function toNumber$1(value) {
|
638 | if (typeof value == "number") {
|
639 | return value;
|
640 | }
|
641 | if (isSymbol(value)) {
|
642 | return NAN;
|
643 | }
|
644 | if (isObject$3(value)) {
|
645 | var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
646 | value = isObject$3(other) ? other + "" : other;
|
647 | }
|
648 | if (typeof value != "string") {
|
649 | return value === 0 ? value : +value;
|
650 | }
|
651 | value = baseTrim(value);
|
652 | var isBinary = reIsBinary.test(value);
|
653 | return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
|
654 | }
|
655 | var toNumber_1 = toNumber$1;
|
656 | var isObject$2 = isObject_1, now = now_1, toNumber = toNumber_1;
|
657 | var FUNC_ERROR_TEXT$1 = "Expected a function";
|
658 | var nativeMax = Math.max, nativeMin = Math.min;
|
659 | function debounce$1(func, wait, options) {
|
660 | var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
661 | if (typeof func != "function") {
|
662 | throw new TypeError(FUNC_ERROR_TEXT$1);
|
663 | }
|
664 | wait = toNumber(wait) || 0;
|
665 | if (isObject$2(options)) {
|
666 | leading = !!options.leading;
|
667 | maxing = "maxWait" in options;
|
668 | maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
669 | trailing = "trailing" in options ? !!options.trailing : trailing;
|
670 | }
|
671 | function invokeFunc(time) {
|
672 | var args = lastArgs, thisArg = lastThis;
|
673 | lastArgs = lastThis = void 0;
|
674 | lastInvokeTime = time;
|
675 | result = func.apply(thisArg, args);
|
676 | return result;
|
677 | }
|
678 | function leadingEdge(time) {
|
679 | lastInvokeTime = time;
|
680 | timerId = setTimeout(timerExpired, wait);
|
681 | return leading ? invokeFunc(time) : result;
|
682 | }
|
683 | function remainingWait(time) {
|
684 | var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
|
685 | return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
|
686 | }
|
687 | function shouldInvoke(time) {
|
688 | var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
|
689 | return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
|
690 | }
|
691 | function timerExpired() {
|
692 | var time = now();
|
693 | if (shouldInvoke(time)) {
|
694 | return trailingEdge(time);
|
695 | }
|
696 | timerId = setTimeout(timerExpired, remainingWait(time));
|
697 | }
|
698 | function trailingEdge(time) {
|
699 | timerId = void 0;
|
700 | if (trailing && lastArgs) {
|
701 | return invokeFunc(time);
|
702 | }
|
703 | lastArgs = lastThis = void 0;
|
704 | return result;
|
705 | }
|
706 | function cancel() {
|
707 | if (timerId !== void 0) {
|
708 | clearTimeout(timerId);
|
709 | }
|
710 | lastInvokeTime = 0;
|
711 | lastArgs = lastCallTime = lastThis = timerId = void 0;
|
712 | }
|
713 | function flush2() {
|
714 | return timerId === void 0 ? result : trailingEdge(now());
|
715 | }
|
716 | function debounced() {
|
717 | var time = now(), isInvoking = shouldInvoke(time);
|
718 | lastArgs = arguments;
|
719 | lastThis = this;
|
720 | lastCallTime = time;
|
721 | if (isInvoking) {
|
722 | if (timerId === void 0) {
|
723 | return leadingEdge(lastCallTime);
|
724 | }
|
725 | if (maxing) {
|
726 | clearTimeout(timerId);
|
727 | timerId = setTimeout(timerExpired, wait);
|
728 | return invokeFunc(lastCallTime);
|
729 | }
|
730 | }
|
731 | if (timerId === void 0) {
|
732 | timerId = setTimeout(timerExpired, wait);
|
733 | }
|
734 | return result;
|
735 | }
|
736 | debounced.cancel = cancel;
|
737 | debounced.flush = flush2;
|
738 | return debounced;
|
739 | }
|
740 | var debounce_1 = debounce$1;
|
741 | const debounce$2 = getDefaultExportFromCjs(debounce_1);
|
742 | var isBrowser$2 = !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
743 | const isBrowser$3 = isBrowser$2;
|
744 | var debounce = debounce_1, isObject$1 = isObject_1;
|
745 | var FUNC_ERROR_TEXT = "Expected a function";
|
746 | function throttle$1(func, wait, options) {
|
747 | var leading = true, trailing = true;
|
748 | if (typeof func != "function") {
|
749 | throw new TypeError(FUNC_ERROR_TEXT);
|
750 | }
|
751 | if (isObject$1(options)) {
|
752 | leading = "leading" in options ? !!options.leading : leading;
|
753 | trailing = "trailing" in options ? !!options.trailing : trailing;
|
754 | }
|
755 | return debounce(func, wait, {
|
756 | "leading": leading,
|
757 | "maxWait": wait,
|
758 | "trailing": trailing
|
759 | });
|
760 | }
|
761 | var throttle_1 = throttle$1;
|
762 | const throttle$2 = getDefaultExportFromCjs(throttle_1);
|
763 | var useMount = function(fn) {
|
764 | if (isDev$1) {
|
765 | if (!isFunction(fn)) {
|
766 | console.error('useMount: parameter `fn` expected to be a function, but got "'.concat(typeof fn, '".'));
|
767 | }
|
768 | }
|
769 | React$1.useEffect(function() {
|
770 | fn === null || fn === void 0 ? void 0 : fn();
|
771 | }, []);
|
772 | };
|
773 | const useMount$1 = useMount;
|
774 | var useUpdate = function() {
|
775 | var _a = __read(React$1.useState({}), 2), setState = _a[1];
|
776 | return React$1.useCallback(function() {
|
777 | return setState({});
|
778 | }, []);
|
779 | };
|
780 | const useUpdate$1 = useUpdate;
|
781 | function getTargetElement(target, defaultElement) {
|
782 | if (!isBrowser$3) {
|
783 | return void 0;
|
784 | }
|
785 | if (!target) {
|
786 | return defaultElement;
|
787 | }
|
788 | var targetElement;
|
789 | if (isFunction(target)) {
|
790 | targetElement = target();
|
791 | } else if ("current" in target) {
|
792 | targetElement = target.current;
|
793 | } else {
|
794 | targetElement = target;
|
795 | }
|
796 | return targetElement;
|
797 | }
|
798 | var checkIfAllInShadow = function(targets) {
|
799 | return targets.every(function(item) {
|
800 | var targetElement = getTargetElement(item);
|
801 | if (!targetElement)
|
802 | return false;
|
803 | if (targetElement.getRootNode() instanceof ShadowRoot)
|
804 | return true;
|
805 | });
|
806 | };
|
807 | var getShadow = function(node) {
|
808 | if (!node) {
|
809 | return document;
|
810 | }
|
811 | return node.getRootNode();
|
812 | };
|
813 | var getDocumentOrShadow = function(target) {
|
814 | if (!target || !document.getRootNode) {
|
815 | return document;
|
816 | }
|
817 | var targets = Array.isArray(target) ? target : [target];
|
818 | if (checkIfAllInShadow(targets)) {
|
819 | return getShadow(getTargetElement(targets[0]));
|
820 | }
|
821 | return document;
|
822 | };
|
823 | const getDocumentOrShadow$1 = getDocumentOrShadow;
|
824 | var createEffectWithTarget = function(useEffectType) {
|
825 | var useEffectWithTarget2 = function(effect, deps, target) {
|
826 | var hasInitRef = React$1.useRef(false);
|
827 | var lastElementRef = React$1.useRef([]);
|
828 | var lastDepsRef = React$1.useRef([]);
|
829 | var unLoadRef = React$1.useRef();
|
830 | useEffectType(function() {
|
831 | var _a;
|
832 | var targets = Array.isArray(target) ? target : [target];
|
833 | var els = targets.map(function(item) {
|
834 | return getTargetElement(item);
|
835 | });
|
836 | if (!hasInitRef.current) {
|
837 | hasInitRef.current = true;
|
838 | lastElementRef.current = els;
|
839 | lastDepsRef.current = deps;
|
840 | unLoadRef.current = effect();
|
841 | return;
|
842 | }
|
843 | if (els.length !== lastElementRef.current.length || !depsAreSame(els, lastElementRef.current) || !depsAreSame(deps, lastDepsRef.current)) {
|
844 | (_a = unLoadRef.current) === null || _a === void 0 ? void 0 : _a.call(unLoadRef);
|
845 | lastElementRef.current = els;
|
846 | lastDepsRef.current = deps;
|
847 | unLoadRef.current = effect();
|
848 | }
|
849 | });
|
850 | useUnmount$1(function() {
|
851 | var _a;
|
852 | (_a = unLoadRef.current) === null || _a === void 0 ? void 0 : _a.call(unLoadRef);
|
853 | hasInitRef.current = false;
|
854 | });
|
855 | };
|
856 | return useEffectWithTarget2;
|
857 | };
|
858 | const createEffectWithTarget$1 = createEffectWithTarget;
|
859 | var useEffectWithTarget$1 = createEffectWithTarget$1(React$1.useEffect);
|
860 | const useEffectWithTarget$2 = useEffectWithTarget$1;
|
861 | function useClickAway(onClickAway, target, eventName) {
|
862 | if (eventName === void 0) {
|
863 | eventName = "click";
|
864 | }
|
865 | var onClickAwayRef = useLatest(onClickAway);
|
866 | useEffectWithTarget$2(function() {
|
867 | var handler = function(event) {
|
868 | var targets = Array.isArray(target) ? target : [target];
|
869 | if (targets.some(function(item) {
|
870 | var targetElement = getTargetElement(item);
|
871 | return !targetElement || targetElement.contains(event.target);
|
872 | })) {
|
873 | return;
|
874 | }
|
875 | onClickAwayRef.current(event);
|
876 | };
|
877 | var documentOrShadow = getDocumentOrShadow$1(target);
|
878 | var eventNames = Array.isArray(eventName) ? eventName : [eventName];
|
879 | eventNames.forEach(function(event) {
|
880 | return documentOrShadow.addEventListener(event, handler);
|
881 | });
|
882 | return function() {
|
883 | eventNames.forEach(function(event) {
|
884 | return documentOrShadow.removeEventListener(event, handler);
|
885 | });
|
886 | };
|
887 | }, Array.isArray(eventName) ? eventName : [eventName], target);
|
888 | }
|
889 | var dayjs_min = { exports: {} };
|
890 | (function(module2, exports3) {
|
891 | !function(t, e2) {
|
892 | module2.exports = e2();
|
893 | }(commonjsGlobal, function() {
|
894 | var t = 1e3, e2 = 6e4, n2 = 36e5, r = "millisecond", i2 = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t2) {
|
895 | var e3 = ["th", "st", "nd", "rd"], n3 = t2 % 100;
|
896 | return "[" + t2 + (e3[(n3 - 20) % 10] || e3[n3] || e3[0]) + "]";
|
897 | } }, m = function(t2, e3, n3) {
|
898 | var r2 = String(t2);
|
899 | return !r2 || r2.length >= e3 ? t2 : "" + Array(e3 + 1 - r2.length).join(n3) + t2;
|
900 | }, v = { s: m, z: function(t2) {
|
901 | var e3 = -t2.utcOffset(), n3 = Math.abs(e3), r2 = Math.floor(n3 / 60), i3 = n3 % 60;
|
902 | return (e3 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i3, 2, "0");
|
903 | }, m: function t2(e3, n3) {
|
904 | if (e3.date() < n3.date())
|
905 | return -t2(n3, e3);
|
906 | var r2 = 12 * (n3.year() - e3.year()) + (n3.month() - e3.month()), i3 = e3.clone().add(r2, c), s2 = n3 - i3 < 0, u2 = e3.clone().add(r2 + (s2 ? -1 : 1), c);
|
907 | return +(-(r2 + (n3 - i3) / (s2 ? i3 - u2 : u2 - i3)) || 0);
|
908 | }, a: function(t2) {
|
909 | return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
|
910 | }, p: function(t2) {
|
911 | return { M: c, y: h, w: o, d: a, D: d, h: u, m: s, s: i2, ms: r, Q: f }[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
|
912 | }, u: function(t2) {
|
913 | return void 0 === t2;
|
914 | } }, g = "en", D = {};
|
915 | D[g] = M;
|
916 | var p = function(t2) {
|
917 | return t2 instanceof b;
|
918 | }, S = function t2(e3, n3, r2) {
|
919 | var i3;
|
920 | if (!e3)
|
921 | return g;
|
922 | if ("string" == typeof e3) {
|
923 | var s2 = e3.toLowerCase();
|
924 | D[s2] && (i3 = s2), n3 && (D[s2] = n3, i3 = s2);
|
925 | var u2 = e3.split("-");
|
926 | if (!i3 && u2.length > 1)
|
927 | return t2(u2[0]);
|
928 | } else {
|
929 | var a2 = e3.name;
|
930 | D[a2] = e3, i3 = a2;
|
931 | }
|
932 | return !r2 && i3 && (g = i3), i3 || !r2 && g;
|
933 | }, w = function(t2, e3) {
|
934 | if (p(t2))
|
935 | return t2.clone();
|
936 | var n3 = "object" == typeof e3 ? e3 : {};
|
937 | return n3.date = t2, n3.args = arguments, new b(n3);
|
938 | }, O = v;
|
939 | O.l = S, O.i = p, O.w = function(t2, e3) {
|
940 | return w(t2, { locale: e3.$L, utc: e3.$u, x: e3.$x, $offset: e3.$offset });
|
941 | };
|
942 | var b = function() {
|
943 | function M2(t2) {
|
944 | this.$L = S(t2.locale, null, true), this.parse(t2);
|
945 | }
|
946 | var m2 = M2.prototype;
|
947 | return m2.parse = function(t2) {
|
948 | this.$d = function(t3) {
|
949 | var e3 = t3.date, n3 = t3.utc;
|
950 | if (null === e3)
|
951 | return new Date(NaN);
|
952 | if (O.u(e3))
|
953 | return new Date();
|
954 | if (e3 instanceof Date)
|
955 | return new Date(e3);
|
956 | if ("string" == typeof e3 && !/Z$/i.test(e3)) {
|
957 | var r2 = e3.match($);
|
958 | if (r2) {
|
959 | var i3 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3);
|
960 | return n3 ? new Date(Date.UTC(r2[1], i3, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2)) : new Date(r2[1], i3, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2);
|
961 | }
|
962 | }
|
963 | return new Date(e3);
|
964 | }(t2), this.$x = t2.x || {}, this.init();
|
965 | }, m2.init = function() {
|
966 | var t2 = this.$d;
|
967 | this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
|
968 | }, m2.$utils = function() {
|
969 | return O;
|
970 | }, m2.isValid = function() {
|
971 | return !(this.$d.toString() === l);
|
972 | }, m2.isSame = function(t2, e3) {
|
973 | var n3 = w(t2);
|
974 | return this.startOf(e3) <= n3 && n3 <= this.endOf(e3);
|
975 | }, m2.isAfter = function(t2, e3) {
|
976 | return w(t2) < this.startOf(e3);
|
977 | }, m2.isBefore = function(t2, e3) {
|
978 | return this.endOf(e3) < w(t2);
|
979 | }, m2.$g = function(t2, e3, n3) {
|
980 | return O.u(t2) ? this[e3] : this.set(n3, t2);
|
981 | }, m2.unix = function() {
|
982 | return Math.floor(this.valueOf() / 1e3);
|
983 | }, m2.valueOf = function() {
|
984 | return this.$d.getTime();
|
985 | }, m2.startOf = function(t2, e3) {
|
986 | var n3 = this, r2 = !!O.u(e3) || e3, f2 = O.p(t2), l2 = function(t3, e4) {
|
987 | var i3 = O.w(n3.$u ? Date.UTC(n3.$y, e4, t3) : new Date(n3.$y, e4, t3), n3);
|
988 | return r2 ? i3 : i3.endOf(a);
|
989 | }, $2 = function(t3, e4) {
|
990 | return O.w(n3.toDate()[t3].apply(n3.toDate("s"), (r2 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e4)), n3);
|
991 | }, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
|
992 | switch (f2) {
|
993 | case h:
|
994 | return r2 ? l2(1, 0) : l2(31, 11);
|
995 | case c:
|
996 | return r2 ? l2(1, M3) : l2(0, M3 + 1);
|
997 | case o:
|
998 | var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
|
999 | return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3);
|
1000 | case a:
|
1001 | case d:
|
1002 | return $2(v2 + "Hours", 0);
|
1003 | case u:
|
1004 | return $2(v2 + "Minutes", 1);
|
1005 | case s:
|
1006 | return $2(v2 + "Seconds", 2);
|
1007 | case i2:
|
1008 | return $2(v2 + "Milliseconds", 3);
|
1009 | default:
|
1010 | return this.clone();
|
1011 | }
|
1012 | }, m2.endOf = function(t2) {
|
1013 | return this.startOf(t2, false);
|
1014 | }, m2.$set = function(t2, e3) {
|
1015 | var n3, o2 = O.p(t2), f2 = "set" + (this.$u ? "UTC" : ""), l2 = (n3 = {}, n3[a] = f2 + "Date", n3[d] = f2 + "Date", n3[c] = f2 + "Month", n3[h] = f2 + "FullYear", n3[u] = f2 + "Hours", n3[s] = f2 + "Minutes", n3[i2] = f2 + "Seconds", n3[r] = f2 + "Milliseconds", n3)[o2], $2 = o2 === a ? this.$D + (e3 - this.$W) : e3;
|
1016 | if (o2 === c || o2 === h) {
|
1017 | var y2 = this.clone().set(d, 1);
|
1018 | y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
|
1019 | } else
|
1020 | l2 && this.$d[l2]($2);
|
1021 | return this.init(), this;
|
1022 | }, m2.set = function(t2, e3) {
|
1023 | return this.clone().$set(t2, e3);
|
1024 | }, m2.get = function(t2) {
|
1025 | return this[O.p(t2)]();
|
1026 | }, m2.add = function(r2, f2) {
|
1027 | var d2, l2 = this;
|
1028 | r2 = Number(r2);
|
1029 | var $2 = O.p(f2), y2 = function(t2) {
|
1030 | var e3 = w(l2);
|
1031 | return O.w(e3.date(e3.date() + Math.round(t2 * r2)), l2);
|
1032 | };
|
1033 | if ($2 === c)
|
1034 | return this.set(c, this.$M + r2);
|
1035 | if ($2 === h)
|
1036 | return this.set(h, this.$y + r2);
|
1037 | if ($2 === a)
|
1038 | return y2(1);
|
1039 | if ($2 === o)
|
1040 | return y2(7);
|
1041 | var M3 = (d2 = {}, d2[s] = e2, d2[u] = n2, d2[i2] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r2 * M3;
|
1042 | return O.w(m3, this);
|
1043 | }, m2.subtract = function(t2, e3) {
|
1044 | return this.add(-1 * t2, e3);
|
1045 | }, m2.format = function(t2) {
|
1046 | var e3 = this, n3 = this.$locale();
|
1047 | if (!this.isValid())
|
1048 | return n3.invalidDate || l;
|
1049 | var r2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i3 = O.z(this), s2 = this.$H, u2 = this.$m, a2 = this.$M, o2 = n3.weekdays, c6 = n3.months, f2 = n3.meridiem, h2 = function(t3, n4, i4, s3) {
|
1050 | return t3 && (t3[n4] || t3(e3, r2)) || i4[n4].slice(0, s3);
|
1051 | }, d2 = function(t3) {
|
1052 | return O.s(s2 % 12 || 12, t3, "0");
|
1053 | }, $2 = f2 || function(t3, e4, n4) {
|
1054 | var r3 = t3 < 12 ? "AM" : "PM";
|
1055 | return n4 ? r3.toLowerCase() : r3;
|
1056 | };
|
1057 | return r2.replace(y, function(t3, r3) {
|
1058 | return r3 || function(t4) {
|
1059 | switch (t4) {
|
1060 | case "YY":
|
1061 | return String(e3.$y).slice(-2);
|
1062 | case "YYYY":
|
1063 | return O.s(e3.$y, 4, "0");
|
1064 | case "M":
|
1065 | return a2 + 1;
|
1066 | case "MM":
|
1067 | return O.s(a2 + 1, 2, "0");
|
1068 | case "MMM":
|
1069 | return h2(n3.monthsShort, a2, c6, 3);
|
1070 | case "MMMM":
|
1071 | return h2(c6, a2);
|
1072 | case "D":
|
1073 | return e3.$D;
|
1074 | case "DD":
|
1075 | return O.s(e3.$D, 2, "0");
|
1076 | case "d":
|
1077 | return String(e3.$W);
|
1078 | case "dd":
|
1079 | return h2(n3.weekdaysMin, e3.$W, o2, 2);
|
1080 | case "ddd":
|
1081 | return h2(n3.weekdaysShort, e3.$W, o2, 3);
|
1082 | case "dddd":
|
1083 | return o2[e3.$W];
|
1084 | case "H":
|
1085 | return String(s2);
|
1086 | case "HH":
|
1087 | return O.s(s2, 2, "0");
|
1088 | case "h":
|
1089 | return d2(1);
|
1090 | case "hh":
|
1091 | return d2(2);
|
1092 | case "a":
|
1093 | return $2(s2, u2, true);
|
1094 | case "A":
|
1095 | return $2(s2, u2, false);
|
1096 | case "m":
|
1097 | return String(u2);
|
1098 | case "mm":
|
1099 | return O.s(u2, 2, "0");
|
1100 | case "s":
|
1101 | return String(e3.$s);
|
1102 | case "ss":
|
1103 | return O.s(e3.$s, 2, "0");
|
1104 | case "SSS":
|
1105 | return O.s(e3.$ms, 3, "0");
|
1106 | case "Z":
|
1107 | return i3;
|
1108 | }
|
1109 | return null;
|
1110 | }(t3) || i3.replace(":", "");
|
1111 | });
|
1112 | }, m2.utcOffset = function() {
|
1113 | return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
|
1114 | }, m2.diff = function(r2, d2, l2) {
|
1115 | var $2, y2 = this, M3 = O.p(d2), m3 = w(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e2, g2 = this - m3, D2 = function() {
|
1116 | return O.m(y2, m3);
|
1117 | };
|
1118 | switch (M3) {
|
1119 | case h:
|
1120 | $2 = D2() / 12;
|
1121 | break;
|
1122 | case c:
|
1123 | $2 = D2();
|
1124 | break;
|
1125 | case f:
|
1126 | $2 = D2() / 3;
|
1127 | break;
|
1128 | case o:
|
1129 | $2 = (g2 - v2) / 6048e5;
|
1130 | break;
|
1131 | case a:
|
1132 | $2 = (g2 - v2) / 864e5;
|
1133 | break;
|
1134 | case u:
|
1135 | $2 = g2 / n2;
|
1136 | break;
|
1137 | case s:
|
1138 | $2 = g2 / e2;
|
1139 | break;
|
1140 | case i2:
|
1141 | $2 = g2 / t;
|
1142 | break;
|
1143 | default:
|
1144 | $2 = g2;
|
1145 | }
|
1146 | return l2 ? $2 : O.a($2);
|
1147 | }, m2.daysInMonth = function() {
|
1148 | return this.endOf(c).$D;
|
1149 | }, m2.$locale = function() {
|
1150 | return D[this.$L];
|
1151 | }, m2.locale = function(t2, e3) {
|
1152 | if (!t2)
|
1153 | return this.$L;
|
1154 | var n3 = this.clone(), r2 = S(t2, e3, true);
|
1155 | return r2 && (n3.$L = r2), n3;
|
1156 | }, m2.clone = function() {
|
1157 | return O.w(this.$d, this);
|
1158 | }, m2.toDate = function() {
|
1159 | return new Date(this.valueOf());
|
1160 | }, m2.toJSON = function() {
|
1161 | return this.isValid() ? this.toISOString() : null;
|
1162 | }, m2.toISOString = function() {
|
1163 | return this.$d.toISOString();
|
1164 | }, m2.toString = function() {
|
1165 | return this.$d.toUTCString();
|
1166 | }, M2;
|
1167 | }(), _ = b.prototype;
|
1168 | return w.prototype = _, [["$ms", r], ["$s", i2], ["$m", s], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach(function(t2) {
|
1169 | _[t2[1]] = function(e3) {
|
1170 | return this.$g(e3, t2[0], t2[1]);
|
1171 | };
|
1172 | }), w.extend = function(t2, e3) {
|
1173 | return t2.$i || (t2(e3, b, w), t2.$i = true), w;
|
1174 | }, w.locale = S, w.isDayjs = p, w.unix = function(t2) {
|
1175 | return w(1e3 * t2);
|
1176 | }, w.en = D[g], w.Ls = D, w.p = {}, w;
|
1177 | });
|
1178 | })(dayjs_min);
|
1179 | var dayjs_minExports = dayjs_min.exports;
|
1180 | const dayjs = getDefaultExportFromCjs(dayjs_minExports);
|
1181 | function useDebounceFn(fn, options) {
|
1182 | var _a;
|
1183 | if (isDev$1) {
|
1184 | if (!isFunction(fn)) {
|
1185 | console.error("useDebounceFn expected parameter is a function, got ".concat(typeof fn));
|
1186 | }
|
1187 | }
|
1188 | var fnRef = useLatest(fn);
|
1189 | var wait = (_a = options === null || options === void 0 ? void 0 : options.wait) !== null && _a !== void 0 ? _a : 1e3;
|
1190 | var debounced = React$1.useMemo(function() {
|
1191 | return debounce$2(function() {
|
1192 | var args = [];
|
1193 | for (var _i = 0; _i < arguments.length; _i++) {
|
1194 | args[_i] = arguments[_i];
|
1195 | }
|
1196 | return fnRef.current.apply(fnRef, __spreadArray([], __read(args), false));
|
1197 | }, wait, options);
|
1198 | }, []);
|
1199 | useUnmount$1(function() {
|
1200 | debounced.cancel();
|
1201 | });
|
1202 | return {
|
1203 | run: debounced,
|
1204 | cancel: debounced.cancel,
|
1205 | flush: debounced.flush
|
1206 | };
|
1207 | }
|
1208 | function useDebounceEffect(effect, deps, options) {
|
1209 | var _a = __read(React$1.useState({}), 2), flag = _a[0], setFlag = _a[1];
|
1210 | var run = useDebounceFn(function() {
|
1211 | setFlag({});
|
1212 | }, options).run;
|
1213 | React$1.useEffect(function() {
|
1214 | return run();
|
1215 | }, deps);
|
1216 | useUpdateEffect(effect, [flag]);
|
1217 | }
|
1218 | function useGetState(initialState) {
|
1219 | var _a = __read(React$1.useState(initialState), 2), state = _a[0], setState = _a[1];
|
1220 | var stateRef = React$1.useRef(state);
|
1221 | stateRef.current = state;
|
1222 | var getState = React$1.useCallback(function() {
|
1223 | return stateRef.current;
|
1224 | }, []);
|
1225 | return [state, setState, getState];
|
1226 | }
|
1227 | (function() {
|
1228 | if (typeof window !== "object") {
|
1229 | return;
|
1230 | }
|
1231 | if ("IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype) {
|
1232 | if (!("isIntersecting" in window.IntersectionObserverEntry.prototype)) {
|
1233 | Object.defineProperty(
|
1234 | window.IntersectionObserverEntry.prototype,
|
1235 | "isIntersecting",
|
1236 | {
|
1237 | get: function() {
|
1238 | return this.intersectionRatio > 0;
|
1239 | }
|
1240 | }
|
1241 | );
|
1242 | }
|
1243 | return;
|
1244 | }
|
1245 | function getFrameElement(doc) {
|
1246 | try {
|
1247 | return doc.defaultView && doc.defaultView.frameElement || null;
|
1248 | } catch (e2) {
|
1249 | return null;
|
1250 | }
|
1251 | }
|
1252 | var document2 = function(startDoc) {
|
1253 | var doc = startDoc;
|
1254 | var frame = getFrameElement(doc);
|
1255 | while (frame) {
|
1256 | doc = frame.ownerDocument;
|
1257 | frame = getFrameElement(doc);
|
1258 | }
|
1259 | return doc;
|
1260 | }(window.document);
|
1261 | var registry = [];
|
1262 | var crossOriginUpdater = null;
|
1263 | var crossOriginRect = null;
|
1264 | function IntersectionObserverEntry(entry) {
|
1265 | this.time = entry.time;
|
1266 | this.target = entry.target;
|
1267 | this.rootBounds = ensureDOMRect(entry.rootBounds);
|
1268 | this.boundingClientRect = ensureDOMRect(entry.boundingClientRect);
|
1269 | this.intersectionRect = ensureDOMRect(entry.intersectionRect || getEmptyRect());
|
1270 | this.isIntersecting = !!entry.intersectionRect;
|
1271 | var targetRect = this.boundingClientRect;
|
1272 | var targetArea = targetRect.width * targetRect.height;
|
1273 | var intersectionRect = this.intersectionRect;
|
1274 | var intersectionArea = intersectionRect.width * intersectionRect.height;
|
1275 | if (targetArea) {
|
1276 | this.intersectionRatio = Number((intersectionArea / targetArea).toFixed(4));
|
1277 | } else {
|
1278 | this.intersectionRatio = this.isIntersecting ? 1 : 0;
|
1279 | }
|
1280 | }
|
1281 | function IntersectionObserver2(callback, opt_options) {
|
1282 | var options = opt_options || {};
|
1283 | if (typeof callback != "function") {
|
1284 | throw new Error("callback must be a function");
|
1285 | }
|
1286 | if (options.root && options.root.nodeType != 1 && options.root.nodeType != 9) {
|
1287 | throw new Error("root must be a Document or Element");
|
1288 | }
|
1289 | this._checkForIntersections = throttle2(
|
1290 | this._checkForIntersections.bind(this),
|
1291 | this.THROTTLE_TIMEOUT
|
1292 | );
|
1293 | this._callback = callback;
|
1294 | this._observationTargets = [];
|
1295 | this._queuedEntries = [];
|
1296 | this._rootMarginValues = this._parseRootMargin(options.rootMargin);
|
1297 | this.thresholds = this._initThresholds(options.threshold);
|
1298 | this.root = options.root || null;
|
1299 | this.rootMargin = this._rootMarginValues.map(function(margin) {
|
1300 | return margin.value + margin.unit;
|
1301 | }).join(" ");
|
1302 | this._monitoringDocuments = [];
|
1303 | this._monitoringUnsubscribes = [];
|
1304 | }
|
1305 | IntersectionObserver2.prototype.THROTTLE_TIMEOUT = 100;
|
1306 | IntersectionObserver2.prototype.POLL_INTERVAL = null;
|
1307 | IntersectionObserver2.prototype.USE_MUTATION_OBSERVER = true;
|
1308 | IntersectionObserver2._setupCrossOriginUpdater = function() {
|
1309 | if (!crossOriginUpdater) {
|
1310 | crossOriginUpdater = function(boundingClientRect, intersectionRect) {
|
1311 | if (!boundingClientRect || !intersectionRect) {
|
1312 | crossOriginRect = getEmptyRect();
|
1313 | } else {
|
1314 | crossOriginRect = convertFromParentRect(boundingClientRect, intersectionRect);
|
1315 | }
|
1316 | registry.forEach(function(observer) {
|
1317 | observer._checkForIntersections();
|
1318 | });
|
1319 | };
|
1320 | }
|
1321 | return crossOriginUpdater;
|
1322 | };
|
1323 | IntersectionObserver2._resetCrossOriginUpdater = function() {
|
1324 | crossOriginUpdater = null;
|
1325 | crossOriginRect = null;
|
1326 | };
|
1327 | IntersectionObserver2.prototype.observe = function(target) {
|
1328 | var isTargetAlreadyObserved = this._observationTargets.some(function(item) {
|
1329 | return item.element == target;
|
1330 | });
|
1331 | if (isTargetAlreadyObserved) {
|
1332 | return;
|
1333 | }
|
1334 | if (!(target && target.nodeType == 1)) {
|
1335 | throw new Error("target must be an Element");
|
1336 | }
|
1337 | this._registerInstance();
|
1338 | this._observationTargets.push({ element: target, entry: null });
|
1339 | this._monitorIntersections(target.ownerDocument);
|
1340 | this._checkForIntersections();
|
1341 | };
|
1342 | IntersectionObserver2.prototype.unobserve = function(target) {
|
1343 | this._observationTargets = this._observationTargets.filter(function(item) {
|
1344 | return item.element != target;
|
1345 | });
|
1346 | this._unmonitorIntersections(target.ownerDocument);
|
1347 | if (this._observationTargets.length == 0) {
|
1348 | this._unregisterInstance();
|
1349 | }
|
1350 | };
|
1351 | IntersectionObserver2.prototype.disconnect = function() {
|
1352 | this._observationTargets = [];
|
1353 | this._unmonitorAllIntersections();
|
1354 | this._unregisterInstance();
|
1355 | };
|
1356 | IntersectionObserver2.prototype.takeRecords = function() {
|
1357 | var records = this._queuedEntries.slice();
|
1358 | this._queuedEntries = [];
|
1359 | return records;
|
1360 | };
|
1361 | IntersectionObserver2.prototype._initThresholds = function(opt_threshold) {
|
1362 | var threshold = opt_threshold || [0];
|
1363 | if (!Array.isArray(threshold))
|
1364 | threshold = [threshold];
|
1365 | return threshold.sort().filter(function(t, i2, a) {
|
1366 | if (typeof t != "number" || isNaN(t) || t < 0 || t > 1) {
|
1367 | throw new Error("threshold must be a number between 0 and 1 inclusively");
|
1368 | }
|
1369 | return t !== a[i2 - 1];
|
1370 | });
|
1371 | };
|
1372 | IntersectionObserver2.prototype._parseRootMargin = function(opt_rootMargin) {
|
1373 | var marginString = opt_rootMargin || "0px";
|
1374 | var margins = marginString.split(/\s+/).map(function(margin) {
|
1375 | var parts = /^(-?\d*\.?\d+)(px|%)$/.exec(margin);
|
1376 | if (!parts) {
|
1377 | throw new Error("rootMargin must be specified in pixels or percent");
|
1378 | }
|
1379 | return { value: parseFloat(parts[1]), unit: parts[2] };
|
1380 | });
|
1381 | margins[1] = margins[1] || margins[0];
|
1382 | margins[2] = margins[2] || margins[0];
|
1383 | margins[3] = margins[3] || margins[1];
|
1384 | return margins;
|
1385 | };
|
1386 | IntersectionObserver2.prototype._monitorIntersections = function(doc) {
|
1387 | var win = doc.defaultView;
|
1388 | if (!win) {
|
1389 | return;
|
1390 | }
|
1391 | if (this._monitoringDocuments.indexOf(doc) != -1) {
|
1392 | return;
|
1393 | }
|
1394 | var callback = this._checkForIntersections;
|
1395 | var monitoringInterval = null;
|
1396 | var domObserver = null;
|
1397 | if (this.POLL_INTERVAL) {
|
1398 | monitoringInterval = win.setInterval(callback, this.POLL_INTERVAL);
|
1399 | } else {
|
1400 | addEvent(win, "resize", callback, true);
|
1401 | addEvent(doc, "scroll", callback, true);
|
1402 | if (this.USE_MUTATION_OBSERVER && "MutationObserver" in win) {
|
1403 | domObserver = new win.MutationObserver(callback);
|
1404 | domObserver.observe(doc, {
|
1405 | attributes: true,
|
1406 | childList: true,
|
1407 | characterData: true,
|
1408 | subtree: true
|
1409 | });
|
1410 | }
|
1411 | }
|
1412 | this._monitoringDocuments.push(doc);
|
1413 | this._monitoringUnsubscribes.push(function() {
|
1414 | var win2 = doc.defaultView;
|
1415 | if (win2) {
|
1416 | if (monitoringInterval) {
|
1417 | win2.clearInterval(monitoringInterval);
|
1418 | }
|
1419 | removeEvent(win2, "resize", callback, true);
|
1420 | }
|
1421 | removeEvent(doc, "scroll", callback, true);
|
1422 | if (domObserver) {
|
1423 | domObserver.disconnect();
|
1424 | }
|
1425 | });
|
1426 | var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2;
|
1427 | if (doc != rootDoc) {
|
1428 | var frame = getFrameElement(doc);
|
1429 | if (frame) {
|
1430 | this._monitorIntersections(frame.ownerDocument);
|
1431 | }
|
1432 | }
|
1433 | };
|
1434 | IntersectionObserver2.prototype._unmonitorIntersections = function(doc) {
|
1435 | var index2 = this._monitoringDocuments.indexOf(doc);
|
1436 | if (index2 == -1) {
|
1437 | return;
|
1438 | }
|
1439 | var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2;
|
1440 | var hasDependentTargets = this._observationTargets.some(function(item) {
|
1441 | var itemDoc = item.element.ownerDocument;
|
1442 | if (itemDoc == doc) {
|
1443 | return true;
|
1444 | }
|
1445 | while (itemDoc && itemDoc != rootDoc) {
|
1446 | var frame2 = getFrameElement(itemDoc);
|
1447 | itemDoc = frame2 && frame2.ownerDocument;
|
1448 | if (itemDoc == doc) {
|
1449 | return true;
|
1450 | }
|
1451 | }
|
1452 | return false;
|
1453 | });
|
1454 | if (hasDependentTargets) {
|
1455 | return;
|
1456 | }
|
1457 | var unsubscribe = this._monitoringUnsubscribes[index2];
|
1458 | this._monitoringDocuments.splice(index2, 1);
|
1459 | this._monitoringUnsubscribes.splice(index2, 1);
|
1460 | unsubscribe();
|
1461 | if (doc != rootDoc) {
|
1462 | var frame = getFrameElement(doc);
|
1463 | if (frame) {
|
1464 | this._unmonitorIntersections(frame.ownerDocument);
|
1465 | }
|
1466 | }
|
1467 | };
|
1468 | IntersectionObserver2.prototype._unmonitorAllIntersections = function() {
|
1469 | var unsubscribes = this._monitoringUnsubscribes.slice(0);
|
1470 | this._monitoringDocuments.length = 0;
|
1471 | this._monitoringUnsubscribes.length = 0;
|
1472 | for (var i2 = 0; i2 < unsubscribes.length; i2++) {
|
1473 | unsubscribes[i2]();
|
1474 | }
|
1475 | };
|
1476 | IntersectionObserver2.prototype._checkForIntersections = function() {
|
1477 | if (!this.root && crossOriginUpdater && !crossOriginRect) {
|
1478 | return;
|
1479 | }
|
1480 | var rootIsInDom = this._rootIsInDom();
|
1481 | var rootRect = rootIsInDom ? this._getRootRect() : getEmptyRect();
|
1482 | this._observationTargets.forEach(function(item) {
|
1483 | var target = item.element;
|
1484 | var targetRect = getBoundingClientRect2(target);
|
1485 | var rootContainsTarget = this._rootContainsTarget(target);
|
1486 | var oldEntry = item.entry;
|
1487 | var intersectionRect = rootIsInDom && rootContainsTarget && this._computeTargetAndRootIntersection(target, targetRect, rootRect);
|
1488 | var rootBounds = null;
|
1489 | if (!this._rootContainsTarget(target)) {
|
1490 | rootBounds = getEmptyRect();
|
1491 | } else if (!crossOriginUpdater || this.root) {
|
1492 | rootBounds = rootRect;
|
1493 | }
|
1494 | var newEntry = item.entry = new IntersectionObserverEntry({
|
1495 | time: now2(),
|
1496 | target,
|
1497 | boundingClientRect: targetRect,
|
1498 | rootBounds,
|
1499 | intersectionRect
|
1500 | });
|
1501 | if (!oldEntry) {
|
1502 | this._queuedEntries.push(newEntry);
|
1503 | } else if (rootIsInDom && rootContainsTarget) {
|
1504 | if (this._hasCrossedThreshold(oldEntry, newEntry)) {
|
1505 | this._queuedEntries.push(newEntry);
|
1506 | }
|
1507 | } else {
|
1508 | if (oldEntry && oldEntry.isIntersecting) {
|
1509 | this._queuedEntries.push(newEntry);
|
1510 | }
|
1511 | }
|
1512 | }, this);
|
1513 | if (this._queuedEntries.length) {
|
1514 | this._callback(this.takeRecords(), this);
|
1515 | }
|
1516 | };
|
1517 | IntersectionObserver2.prototype._computeTargetAndRootIntersection = function(target, targetRect, rootRect) {
|
1518 | if (window.getComputedStyle(target).display == "none")
|
1519 | return;
|
1520 | var intersectionRect = targetRect;
|
1521 | var parent = getParentNode2(target);
|
1522 | var atRoot = false;
|
1523 | while (!atRoot && parent) {
|
1524 | var parentRect = null;
|
1525 | var parentComputedStyle = parent.nodeType == 1 ? window.getComputedStyle(parent) : {};
|
1526 | if (parentComputedStyle.display == "none")
|
1527 | return null;
|
1528 | if (parent == this.root || parent.nodeType ==
|
1529 | 9) {
|
1530 | atRoot = true;
|
1531 | if (parent == this.root || parent == document2) {
|
1532 | if (crossOriginUpdater && !this.root) {
|
1533 | if (!crossOriginRect || crossOriginRect.width == 0 && crossOriginRect.height == 0) {
|
1534 | parent = null;
|
1535 | parentRect = null;
|
1536 | intersectionRect = null;
|
1537 | } else {
|
1538 | parentRect = crossOriginRect;
|
1539 | }
|
1540 | } else {
|
1541 | parentRect = rootRect;
|
1542 | }
|
1543 | } else {
|
1544 | var frame = getParentNode2(parent);
|
1545 | var frameRect = frame && getBoundingClientRect2(frame);
|
1546 | var frameIntersect = frame && this._computeTargetAndRootIntersection(frame, frameRect, rootRect);
|
1547 | if (frameRect && frameIntersect) {
|
1548 | parent = frame;
|
1549 | parentRect = convertFromParentRect(frameRect, frameIntersect);
|
1550 | } else {
|
1551 | parent = null;
|
1552 | intersectionRect = null;
|
1553 | }
|
1554 | }
|
1555 | } else {
|
1556 | var doc = parent.ownerDocument;
|
1557 | if (parent != doc.body && parent != doc.documentElement && parentComputedStyle.overflow != "visible") {
|
1558 | parentRect = getBoundingClientRect2(parent);
|
1559 | }
|
1560 | }
|
1561 | if (parentRect) {
|
1562 | intersectionRect = computeRectIntersection(parentRect, intersectionRect);
|
1563 | }
|
1564 | if (!intersectionRect)
|
1565 | break;
|
1566 | parent = parent && getParentNode2(parent);
|
1567 | }
|
1568 | return intersectionRect;
|
1569 | };
|
1570 | IntersectionObserver2.prototype._getRootRect = function() {
|
1571 | var rootRect;
|
1572 | if (this.root && !isDoc(this.root)) {
|
1573 | rootRect = getBoundingClientRect2(this.root);
|
1574 | } else {
|
1575 | var doc = isDoc(this.root) ? this.root : document2;
|
1576 | var html = doc.documentElement;
|
1577 | var body = doc.body;
|
1578 | rootRect = {
|
1579 | top: 0,
|
1580 | left: 0,
|
1581 | right: html.clientWidth || body.clientWidth,
|
1582 | width: html.clientWidth || body.clientWidth,
|
1583 | bottom: html.clientHeight || body.clientHeight,
|
1584 | height: html.clientHeight || body.clientHeight
|
1585 | };
|
1586 | }
|
1587 | return this._expandRectByRootMargin(rootRect);
|
1588 | };
|
1589 | IntersectionObserver2.prototype._expandRectByRootMargin = function(rect) {
|
1590 | var margins = this._rootMarginValues.map(function(margin, i2) {
|
1591 | return margin.unit == "px" ? margin.value : margin.value * (i2 % 2 ? rect.width : rect.height) / 100;
|
1592 | });
|
1593 | var newRect = {
|
1594 | top: rect.top - margins[0],
|
1595 | right: rect.right + margins[1],
|
1596 | bottom: rect.bottom + margins[2],
|
1597 | left: rect.left - margins[3]
|
1598 | };
|
1599 | newRect.width = newRect.right - newRect.left;
|
1600 | newRect.height = newRect.bottom - newRect.top;
|
1601 | return newRect;
|
1602 | };
|
1603 | IntersectionObserver2.prototype._hasCrossedThreshold = function(oldEntry, newEntry) {
|
1604 | var oldRatio = oldEntry && oldEntry.isIntersecting ? oldEntry.intersectionRatio || 0 : -1;
|
1605 | var newRatio = newEntry.isIntersecting ? newEntry.intersectionRatio || 0 : -1;
|
1606 | if (oldRatio === newRatio)
|
1607 | return;
|
1608 | for (var i2 = 0; i2 < this.thresholds.length; i2++) {
|
1609 | var threshold = this.thresholds[i2];
|
1610 | if (threshold == oldRatio || threshold == newRatio || threshold < oldRatio !== threshold < newRatio) {
|
1611 | return true;
|
1612 | }
|
1613 | }
|
1614 | };
|
1615 | IntersectionObserver2.prototype._rootIsInDom = function() {
|
1616 | return !this.root || containsDeep(document2, this.root);
|
1617 | };
|
1618 | IntersectionObserver2.prototype._rootContainsTarget = function(target) {
|
1619 | var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2;
|
1620 | return containsDeep(rootDoc, target) && (!this.root || rootDoc == target.ownerDocument);
|
1621 | };
|
1622 | IntersectionObserver2.prototype._registerInstance = function() {
|
1623 | if (registry.indexOf(this) < 0) {
|
1624 | registry.push(this);
|
1625 | }
|
1626 | };
|
1627 | IntersectionObserver2.prototype._unregisterInstance = function() {
|
1628 | var index2 = registry.indexOf(this);
|
1629 | if (index2 != -1)
|
1630 | registry.splice(index2, 1);
|
1631 | };
|
1632 | function now2() {
|
1633 | return window.performance && performance.now && performance.now();
|
1634 | }
|
1635 | function throttle2(fn, timeout) {
|
1636 | var timer = null;
|
1637 | return function() {
|
1638 | if (!timer) {
|
1639 | timer = setTimeout(function() {
|
1640 | fn();
|
1641 | timer = null;
|
1642 | }, timeout);
|
1643 | }
|
1644 | };
|
1645 | }
|
1646 | function addEvent(node, event, fn, opt_useCapture) {
|
1647 | if (typeof node.addEventListener == "function") {
|
1648 | node.addEventListener(event, fn, opt_useCapture || false);
|
1649 | } else if (typeof node.attachEvent == "function") {
|
1650 | node.attachEvent("on" + event, fn);
|
1651 | }
|
1652 | }
|
1653 | function removeEvent(node, event, fn, opt_useCapture) {
|
1654 | if (typeof node.removeEventListener == "function") {
|
1655 | node.removeEventListener(event, fn, opt_useCapture || false);
|
1656 | } else if (typeof node.detachEvent == "function") {
|
1657 | node.detachEvent("on" + event, fn);
|
1658 | }
|
1659 | }
|
1660 | function computeRectIntersection(rect1, rect2) {
|
1661 | var top = Math.max(rect1.top, rect2.top);
|
1662 | var bottom = Math.min(rect1.bottom, rect2.bottom);
|
1663 | var left = Math.max(rect1.left, rect2.left);
|
1664 | var right = Math.min(rect1.right, rect2.right);
|
1665 | var width = right - left;
|
1666 | var height = bottom - top;
|
1667 | return width >= 0 && height >= 0 && {
|
1668 | top,
|
1669 | bottom,
|
1670 | left,
|
1671 | right,
|
1672 | width,
|
1673 | height
|
1674 | } || null;
|
1675 | }
|
1676 | function getBoundingClientRect2(el) {
|
1677 | var rect;
|
1678 | try {
|
1679 | rect = el.getBoundingClientRect();
|
1680 | } catch (err) {
|
1681 | }
|
1682 | if (!rect)
|
1683 | return getEmptyRect();
|
1684 | if (!(rect.width && rect.height)) {
|
1685 | rect = {
|
1686 | top: rect.top,
|
1687 | right: rect.right,
|
1688 | bottom: rect.bottom,
|
1689 | left: rect.left,
|
1690 | width: rect.right - rect.left,
|
1691 | height: rect.bottom - rect.top
|
1692 | };
|
1693 | }
|
1694 | return rect;
|
1695 | }
|
1696 | function getEmptyRect() {
|
1697 | return {
|
1698 | top: 0,
|
1699 | bottom: 0,
|
1700 | left: 0,
|
1701 | right: 0,
|
1702 | width: 0,
|
1703 | height: 0
|
1704 | };
|
1705 | }
|
1706 | function ensureDOMRect(rect) {
|
1707 | if (!rect || "x" in rect) {
|
1708 | return rect;
|
1709 | }
|
1710 | return {
|
1711 | top: rect.top,
|
1712 | y: rect.top,
|
1713 | bottom: rect.bottom,
|
1714 | left: rect.left,
|
1715 | x: rect.left,
|
1716 | right: rect.right,
|
1717 | width: rect.width,
|
1718 | height: rect.height
|
1719 | };
|
1720 | }
|
1721 | function convertFromParentRect(parentBoundingRect, parentIntersectionRect) {
|
1722 | var top = parentIntersectionRect.top - parentBoundingRect.top;
|
1723 | var left = parentIntersectionRect.left - parentBoundingRect.left;
|
1724 | return {
|
1725 | top,
|
1726 | left,
|
1727 | height: parentIntersectionRect.height,
|
1728 | width: parentIntersectionRect.width,
|
1729 | bottom: top + parentIntersectionRect.height,
|
1730 | right: left + parentIntersectionRect.width
|
1731 | };
|
1732 | }
|
1733 | function containsDeep(parent, child) {
|
1734 | var node = child;
|
1735 | while (node) {
|
1736 | if (node == parent)
|
1737 | return true;
|
1738 | node = getParentNode2(node);
|
1739 | }
|
1740 | return false;
|
1741 | }
|
1742 | function getParentNode2(node) {
|
1743 | var parent = node.parentNode;
|
1744 | if (node.nodeType ==
|
1745 | 9 && node != document2) {
|
1746 | return getFrameElement(node);
|
1747 | }
|
1748 | if (parent && parent.assignedSlot) {
|
1749 | parent = parent.assignedSlot.parentNode;
|
1750 | }
|
1751 | if (parent && parent.nodeType == 11 && parent.host) {
|
1752 | return parent.host;
|
1753 | }
|
1754 | return parent;
|
1755 | }
|
1756 | function isDoc(node) {
|
1757 | return node && node.nodeType === 9;
|
1758 | }
|
1759 | window.IntersectionObserver = IntersectionObserver2;
|
1760 | window.IntersectionObserverEntry = IntersectionObserverEntry;
|
1761 | })();
|
1762 | function useInViewport(target, options) {
|
1763 | var _a = __read(React$1.useState(), 2), state = _a[0], setState = _a[1];
|
1764 | var _b = __read(React$1.useState(), 2), ratio = _b[0], setRatio = _b[1];
|
1765 | useEffectWithTarget$2(function() {
|
1766 | var el = getTargetElement(target);
|
1767 | if (!el) {
|
1768 | return;
|
1769 | }
|
1770 | var observer = new IntersectionObserver(function(entries) {
|
1771 | var e_1, _a2;
|
1772 | try {
|
1773 | for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
|
1774 | var entry = entries_1_1.value;
|
1775 | setRatio(entry.intersectionRatio);
|
1776 | setState(entry.isIntersecting);
|
1777 | }
|
1778 | } catch (e_1_1) {
|
1779 | e_1 = {
|
1780 | error: e_1_1
|
1781 | };
|
1782 | } finally {
|
1783 | try {
|
1784 | if (entries_1_1 && !entries_1_1.done && (_a2 = entries_1.return))
|
1785 | _a2.call(entries_1);
|
1786 | } finally {
|
1787 | if (e_1)
|
1788 | throw e_1.error;
|
1789 | }
|
1790 | }
|
1791 | }, __assign(__assign({}, options), {
|
1792 | root: getTargetElement(options === null || options === void 0 ? void 0 : options.root)
|
1793 | }));
|
1794 | observer.observe(el);
|
1795 | return function() {
|
1796 | observer.disconnect();
|
1797 | };
|
1798 | }, [options === null || options === void 0 ? void 0 : options.rootMargin, options === null || options === void 0 ? void 0 : options.threshold], target);
|
1799 | return [state, ratio];
|
1800 | }
|
1801 | var useIsomorphicLayoutEffect$1 = isBrowser$3 ? React$1.useLayoutEffect : React$1.useEffect;
|
1802 | const useIsomorphicLayoutEffect$2 = useIsomorphicLayoutEffect$1;
|
1803 | function useLockFn(fn) {
|
1804 | var _this = this;
|
1805 | var lockRef = React$1.useRef(false);
|
1806 | return React$1.useCallback(function() {
|
1807 | var args = [];
|
1808 | for (var _i = 0; _i < arguments.length; _i++) {
|
1809 | args[_i] = arguments[_i];
|
1810 | }
|
1811 | return __awaiter(_this, void 0, void 0, function() {
|
1812 | var ret, e_1;
|
1813 | return __generator(this, function(_a) {
|
1814 | switch (_a.label) {
|
1815 | case 0:
|
1816 | if (lockRef.current)
|
1817 | return [
|
1818 | 2
|
1819 |
|
1820 | ];
|
1821 | lockRef.current = true;
|
1822 | _a.label = 1;
|
1823 | case 1:
|
1824 | _a.trys.push([1, 3, , 4]);
|
1825 | return [4, fn.apply(void 0, __spreadArray([], __read(args), false))];
|
1826 | case 2:
|
1827 | ret = _a.sent();
|
1828 | lockRef.current = false;
|
1829 | return [2, ret];
|
1830 | case 3:
|
1831 | e_1 = _a.sent();
|
1832 | lockRef.current = false;
|
1833 | throw e_1;
|
1834 | case 4:
|
1835 | return [
|
1836 | 2
|
1837 |
|
1838 | ];
|
1839 | }
|
1840 | });
|
1841 | });
|
1842 | }, [fn]);
|
1843 | }
|
1844 | function useRafState(initialState) {
|
1845 | var ref = React$1.useRef(0);
|
1846 | var _a = __read(React$1.useState(initialState), 2), state = _a[0], setState = _a[1];
|
1847 | var setRafState = React$1.useCallback(function(value) {
|
1848 | cancelAnimationFrame(ref.current);
|
1849 | ref.current = requestAnimationFrame(function() {
|
1850 | setState(value);
|
1851 | });
|
1852 | }, []);
|
1853 | useUnmount$1(function() {
|
1854 | cancelAnimationFrame(ref.current);
|
1855 | });
|
1856 | return [state, setRafState];
|
1857 | }
|
1858 | var useUnmountedRef = function() {
|
1859 | var unmountedRef = React$1.useRef(false);
|
1860 | React$1.useEffect(function() {
|
1861 | unmountedRef.current = false;
|
1862 | return function() {
|
1863 | unmountedRef.current = true;
|
1864 | };
|
1865 | }, []);
|
1866 | return unmountedRef;
|
1867 | };
|
1868 | const useUnmountedRef$1 = useUnmountedRef;
|
1869 | var MapShim = function() {
|
1870 | if (typeof Map !== "undefined") {
|
1871 | return Map;
|
1872 | }
|
1873 | function getIndex(arr, key) {
|
1874 | var result = -1;
|
1875 | arr.some(function(entry, index2) {
|
1876 | if (entry[0] === key) {
|
1877 | result = index2;
|
1878 | return true;
|
1879 | }
|
1880 | return false;
|
1881 | });
|
1882 | return result;
|
1883 | }
|
1884 | return (
|
1885 |
|
1886 | function() {
|
1887 | function class_1() {
|
1888 | this.__entries__ = [];
|
1889 | }
|
1890 | Object.defineProperty(class_1.prototype, "size", {
|
1891 | |
1892 |
|
1893 |
|
1894 | get: function() {
|
1895 | return this.__entries__.length;
|
1896 | },
|
1897 | enumerable: true,
|
1898 | configurable: true
|
1899 | });
|
1900 | class_1.prototype.get = function(key) {
|
1901 | var index2 = getIndex(this.__entries__, key);
|
1902 | var entry = this.__entries__[index2];
|
1903 | return entry && entry[1];
|
1904 | };
|
1905 | class_1.prototype.set = function(key, value) {
|
1906 | var index2 = getIndex(this.__entries__, key);
|
1907 | if (~index2) {
|
1908 | this.__entries__[index2][1] = value;
|
1909 | } else {
|
1910 | this.__entries__.push([key, value]);
|
1911 | }
|
1912 | };
|
1913 | class_1.prototype.delete = function(key) {
|
1914 | var entries = this.__entries__;
|
1915 | var index2 = getIndex(entries, key);
|
1916 | if (~index2) {
|
1917 | entries.splice(index2, 1);
|
1918 | }
|
1919 | };
|
1920 | class_1.prototype.has = function(key) {
|
1921 | return !!~getIndex(this.__entries__, key);
|
1922 | };
|
1923 | class_1.prototype.clear = function() {
|
1924 | this.__entries__.splice(0);
|
1925 | };
|
1926 | class_1.prototype.forEach = function(callback, ctx2) {
|
1927 | if (ctx2 === void 0) {
|
1928 | ctx2 = null;
|
1929 | }
|
1930 | for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {
|
1931 | var entry = _a[_i];
|
1932 | callback.call(ctx2, entry[1], entry[0]);
|
1933 | }
|
1934 | };
|
1935 | return class_1;
|
1936 | }()
|
1937 | );
|
1938 | }();
|
1939 | var isBrowser$1 = typeof window !== "undefined" && typeof document !== "undefined" && window.document === document;
|
1940 | var global$1 = function() {
|
1941 | if (typeof global !== "undefined" && global.Math === Math) {
|
1942 | return global;
|
1943 | }
|
1944 | if (typeof self !== "undefined" && self.Math === Math) {
|
1945 | return self;
|
1946 | }
|
1947 | if (typeof window !== "undefined" && window.Math === Math) {
|
1948 | return window;
|
1949 | }
|
1950 | return Function("return this")();
|
1951 | }();
|
1952 | var requestAnimationFrame$1 = function() {
|
1953 | if (typeof requestAnimationFrame === "function") {
|
1954 | return requestAnimationFrame.bind(global$1);
|
1955 | }
|
1956 | return function(callback) {
|
1957 | return setTimeout(function() {
|
1958 | return callback(Date.now());
|
1959 | }, 1e3 / 60);
|
1960 | };
|
1961 | }();
|
1962 | var trailingTimeout = 2;
|
1963 | function throttle(callback, delay) {
|
1964 | var leadingCall = false, trailingCall = false, lastCallTime = 0;
|
1965 | function resolvePending() {
|
1966 | if (leadingCall) {
|
1967 | leadingCall = false;
|
1968 | callback();
|
1969 | }
|
1970 | if (trailingCall) {
|
1971 | proxy();
|
1972 | }
|
1973 | }
|
1974 | function timeoutCallback() {
|
1975 | requestAnimationFrame$1(resolvePending);
|
1976 | }
|
1977 | function proxy() {
|
1978 | var timeStamp = Date.now();
|
1979 | if (leadingCall) {
|
1980 | if (timeStamp - lastCallTime < trailingTimeout) {
|
1981 | return;
|
1982 | }
|
1983 | trailingCall = true;
|
1984 | } else {
|
1985 | leadingCall = true;
|
1986 | trailingCall = false;
|
1987 | setTimeout(timeoutCallback, delay);
|
1988 | }
|
1989 | lastCallTime = timeStamp;
|
1990 | }
|
1991 | return proxy;
|
1992 | }
|
1993 | var REFRESH_DELAY = 20;
|
1994 | var transitionKeys = ["top", "right", "bottom", "left", "width", "height", "size", "weight"];
|
1995 | var mutationObserverSupported = typeof MutationObserver !== "undefined";
|
1996 | var ResizeObserverController = (
|
1997 |
|
1998 | function() {
|
1999 | function ResizeObserverController2() {
|
2000 | this.connected_ = false;
|
2001 | this.mutationEventsAdded_ = false;
|
2002 | this.mutationsObserver_ = null;
|
2003 | this.observers_ = [];
|
2004 | this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);
|
2005 | this.refresh = throttle(this.refresh.bind(this), REFRESH_DELAY);
|
2006 | }
|
2007 | ResizeObserverController2.prototype.addObserver = function(observer) {
|
2008 | if (!~this.observers_.indexOf(observer)) {
|
2009 | this.observers_.push(observer);
|
2010 | }
|
2011 | if (!this.connected_) {
|
2012 | this.connect_();
|
2013 | }
|
2014 | };
|
2015 | ResizeObserverController2.prototype.removeObserver = function(observer) {
|
2016 | var observers2 = this.observers_;
|
2017 | var index2 = observers2.indexOf(observer);
|
2018 | if (~index2) {
|
2019 | observers2.splice(index2, 1);
|
2020 | }
|
2021 | if (!observers2.length && this.connected_) {
|
2022 | this.disconnect_();
|
2023 | }
|
2024 | };
|
2025 | ResizeObserverController2.prototype.refresh = function() {
|
2026 | var changesDetected = this.updateObservers_();
|
2027 | if (changesDetected) {
|
2028 | this.refresh();
|
2029 | }
|
2030 | };
|
2031 | ResizeObserverController2.prototype.updateObservers_ = function() {
|
2032 | var activeObservers = this.observers_.filter(function(observer) {
|
2033 | return observer.gatherActive(), observer.hasActive();
|
2034 | });
|
2035 | activeObservers.forEach(function(observer) {
|
2036 | return observer.broadcastActive();
|
2037 | });
|
2038 | return activeObservers.length > 0;
|
2039 | };
|
2040 | ResizeObserverController2.prototype.connect_ = function() {
|
2041 | if (!isBrowser$1 || this.connected_) {
|
2042 | return;
|
2043 | }
|
2044 | document.addEventListener("transitionend", this.onTransitionEnd_);
|
2045 | window.addEventListener("resize", this.refresh);
|
2046 | if (mutationObserverSupported) {
|
2047 | this.mutationsObserver_ = new MutationObserver(this.refresh);
|
2048 | this.mutationsObserver_.observe(document, {
|
2049 | attributes: true,
|
2050 | childList: true,
|
2051 | characterData: true,
|
2052 | subtree: true
|
2053 | });
|
2054 | } else {
|
2055 | document.addEventListener("DOMSubtreeModified", this.refresh);
|
2056 | this.mutationEventsAdded_ = true;
|
2057 | }
|
2058 | this.connected_ = true;
|
2059 | };
|
2060 | ResizeObserverController2.prototype.disconnect_ = function() {
|
2061 | if (!isBrowser$1 || !this.connected_) {
|
2062 | return;
|
2063 | }
|
2064 | document.removeEventListener("transitionend", this.onTransitionEnd_);
|
2065 | window.removeEventListener("resize", this.refresh);
|
2066 | if (this.mutationsObserver_) {
|
2067 | this.mutationsObserver_.disconnect();
|
2068 | }
|
2069 | if (this.mutationEventsAdded_) {
|
2070 | document.removeEventListener("DOMSubtreeModified", this.refresh);
|
2071 | }
|
2072 | this.mutationsObserver_ = null;
|
2073 | this.mutationEventsAdded_ = false;
|
2074 | this.connected_ = false;
|
2075 | };
|
2076 | ResizeObserverController2.prototype.onTransitionEnd_ = function(_a) {
|
2077 | var _b = _a.propertyName, propertyName = _b === void 0 ? "" : _b;
|
2078 | var isReflowProperty = transitionKeys.some(function(key) {
|
2079 | return !!~propertyName.indexOf(key);
|
2080 | });
|
2081 | if (isReflowProperty) {
|
2082 | this.refresh();
|
2083 | }
|
2084 | };
|
2085 | ResizeObserverController2.getInstance = function() {
|
2086 | if (!this.instance_) {
|
2087 | this.instance_ = new ResizeObserverController2();
|
2088 | }
|
2089 | return this.instance_;
|
2090 | };
|
2091 | ResizeObserverController2.instance_ = null;
|
2092 | return ResizeObserverController2;
|
2093 | }()
|
2094 | );
|
2095 | var defineConfigurable = function(target, props) {
|
2096 | for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
|
2097 | var key = _a[_i];
|
2098 | Object.defineProperty(target, key, {
|
2099 | value: props[key],
|
2100 | enumerable: false,
|
2101 | writable: false,
|
2102 | configurable: true
|
2103 | });
|
2104 | }
|
2105 | return target;
|
2106 | };
|
2107 | var getWindowOf = function(target) {
|
2108 | var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
|
2109 | return ownerGlobal || global$1;
|
2110 | };
|
2111 | var emptyRect = createRectInit(0, 0, 0, 0);
|
2112 | function toFloat(value) {
|
2113 | return parseFloat(value) || 0;
|
2114 | }
|
2115 | function getBordersSize(styles) {
|
2116 | var positions = [];
|
2117 | for (var _i = 1; _i < arguments.length; _i++) {
|
2118 | positions[_i - 1] = arguments[_i];
|
2119 | }
|
2120 | return positions.reduce(function(size, position) {
|
2121 | var value = styles["border-" + position + "-width"];
|
2122 | return size + toFloat(value);
|
2123 | }, 0);
|
2124 | }
|
2125 | function getPaddings(styles) {
|
2126 | var positions = ["top", "right", "bottom", "left"];
|
2127 | var paddings = {};
|
2128 | for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
|
2129 | var position = positions_1[_i];
|
2130 | var value = styles["padding-" + position];
|
2131 | paddings[position] = toFloat(value);
|
2132 | }
|
2133 | return paddings;
|
2134 | }
|
2135 | function getSVGContentRect(target) {
|
2136 | var bbox = target.getBBox();
|
2137 | return createRectInit(0, 0, bbox.width, bbox.height);
|
2138 | }
|
2139 | function getHTMLElementContentRect(target) {
|
2140 | var clientWidth = target.clientWidth, clientHeight = target.clientHeight;
|
2141 | if (!clientWidth && !clientHeight) {
|
2142 | return emptyRect;
|
2143 | }
|
2144 | var styles = getWindowOf(target).getComputedStyle(target);
|
2145 | var paddings = getPaddings(styles);
|
2146 | var horizPad = paddings.left + paddings.right;
|
2147 | var vertPad = paddings.top + paddings.bottom;
|
2148 | var width = toFloat(styles.width), height = toFloat(styles.height);
|
2149 | if (styles.boxSizing === "border-box") {
|
2150 | if (Math.round(width + horizPad) !== clientWidth) {
|
2151 | width -= getBordersSize(styles, "left", "right") + horizPad;
|
2152 | }
|
2153 | if (Math.round(height + vertPad) !== clientHeight) {
|
2154 | height -= getBordersSize(styles, "top", "bottom") + vertPad;
|
2155 | }
|
2156 | }
|
2157 | if (!isDocumentElement(target)) {
|
2158 | var vertScrollbar = Math.round(width + horizPad) - clientWidth;
|
2159 | var horizScrollbar = Math.round(height + vertPad) - clientHeight;
|
2160 | if (Math.abs(vertScrollbar) !== 1) {
|
2161 | width -= vertScrollbar;
|
2162 | }
|
2163 | if (Math.abs(horizScrollbar) !== 1) {
|
2164 | height -= horizScrollbar;
|
2165 | }
|
2166 | }
|
2167 | return createRectInit(paddings.left, paddings.top, width, height);
|
2168 | }
|
2169 | var isSVGGraphicsElement = function() {
|
2170 | if (typeof SVGGraphicsElement !== "undefined") {
|
2171 | return function(target) {
|
2172 | return target instanceof getWindowOf(target).SVGGraphicsElement;
|
2173 | };
|
2174 | }
|
2175 | return function(target) {
|
2176 | return target instanceof getWindowOf(target).SVGElement && typeof target.getBBox === "function";
|
2177 | };
|
2178 | }();
|
2179 | function isDocumentElement(target) {
|
2180 | return target === getWindowOf(target).document.documentElement;
|
2181 | }
|
2182 | function getContentRect(target) {
|
2183 | if (!isBrowser$1) {
|
2184 | return emptyRect;
|
2185 | }
|
2186 | if (isSVGGraphicsElement(target)) {
|
2187 | return getSVGContentRect(target);
|
2188 | }
|
2189 | return getHTMLElementContentRect(target);
|
2190 | }
|
2191 | function createReadOnlyRect(_a) {
|
2192 | var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
|
2193 | var Constr = typeof DOMRectReadOnly !== "undefined" ? DOMRectReadOnly : Object;
|
2194 | var rect = Object.create(Constr.prototype);
|
2195 | defineConfigurable(rect, {
|
2196 | x,
|
2197 | y,
|
2198 | width,
|
2199 | height,
|
2200 | top: y,
|
2201 | right: x + width,
|
2202 | bottom: height + y,
|
2203 | left: x
|
2204 | });
|
2205 | return rect;
|
2206 | }
|
2207 | function createRectInit(x, y, width, height) {
|
2208 | return { x, y, width, height };
|
2209 | }
|
2210 | var ResizeObservation = (
|
2211 |
|
2212 | function() {
|
2213 | function ResizeObservation2(target) {
|
2214 | this.broadcastWidth = 0;
|
2215 | this.broadcastHeight = 0;
|
2216 | this.contentRect_ = createRectInit(0, 0, 0, 0);
|
2217 | this.target = target;
|
2218 | }
|
2219 | ResizeObservation2.prototype.isActive = function() {
|
2220 | var rect = getContentRect(this.target);
|
2221 | this.contentRect_ = rect;
|
2222 | return rect.width !== this.broadcastWidth || rect.height !== this.broadcastHeight;
|
2223 | };
|
2224 | ResizeObservation2.prototype.broadcastRect = function() {
|
2225 | var rect = this.contentRect_;
|
2226 | this.broadcastWidth = rect.width;
|
2227 | this.broadcastHeight = rect.height;
|
2228 | return rect;
|
2229 | };
|
2230 | return ResizeObservation2;
|
2231 | }()
|
2232 | );
|
2233 | var ResizeObserverEntry = (
|
2234 |
|
2235 | function() {
|
2236 | function ResizeObserverEntry2(target, rectInit) {
|
2237 | var contentRect = createReadOnlyRect(rectInit);
|
2238 | defineConfigurable(this, { target, contentRect });
|
2239 | }
|
2240 | return ResizeObserverEntry2;
|
2241 | }()
|
2242 | );
|
2243 | var ResizeObserverSPI = (
|
2244 |
|
2245 | function() {
|
2246 | function ResizeObserverSPI2(callback, controller, callbackCtx) {
|
2247 | this.activeObservations_ = [];
|
2248 | this.observations_ = new MapShim();
|
2249 | if (typeof callback !== "function") {
|
2250 | throw new TypeError("The callback provided as parameter 1 is not a function.");
|
2251 | }
|
2252 | this.callback_ = callback;
|
2253 | this.controller_ = controller;
|
2254 | this.callbackCtx_ = callbackCtx;
|
2255 | }
|
2256 | ResizeObserverSPI2.prototype.observe = function(target) {
|
2257 | if (!arguments.length) {
|
2258 | throw new TypeError("1 argument required, but only 0 present.");
|
2259 | }
|
2260 | if (typeof Element === "undefined" || !(Element instanceof Object)) {
|
2261 | return;
|
2262 | }
|
2263 | if (!(target instanceof getWindowOf(target).Element)) {
|
2264 | throw new TypeError('parameter 1 is not of type "Element".');
|
2265 | }
|
2266 | var observations = this.observations_;
|
2267 | if (observations.has(target)) {
|
2268 | return;
|
2269 | }
|
2270 | observations.set(target, new ResizeObservation(target));
|
2271 | this.controller_.addObserver(this);
|
2272 | this.controller_.refresh();
|
2273 | };
|
2274 | ResizeObserverSPI2.prototype.unobserve = function(target) {
|
2275 | if (!arguments.length) {
|
2276 | throw new TypeError("1 argument required, but only 0 present.");
|
2277 | }
|
2278 | if (typeof Element === "undefined" || !(Element instanceof Object)) {
|
2279 | return;
|
2280 | }
|
2281 | if (!(target instanceof getWindowOf(target).Element)) {
|
2282 | throw new TypeError('parameter 1 is not of type "Element".');
|
2283 | }
|
2284 | var observations = this.observations_;
|
2285 | if (!observations.has(target)) {
|
2286 | return;
|
2287 | }
|
2288 | observations.delete(target);
|
2289 | if (!observations.size) {
|
2290 | this.controller_.removeObserver(this);
|
2291 | }
|
2292 | };
|
2293 | ResizeObserverSPI2.prototype.disconnect = function() {
|
2294 | this.clearActive();
|
2295 | this.observations_.clear();
|
2296 | this.controller_.removeObserver(this);
|
2297 | };
|
2298 | ResizeObserverSPI2.prototype.gatherActive = function() {
|
2299 | var _this = this;
|
2300 | this.clearActive();
|
2301 | this.observations_.forEach(function(observation) {
|
2302 | if (observation.isActive()) {
|
2303 | _this.activeObservations_.push(observation);
|
2304 | }
|
2305 | });
|
2306 | };
|
2307 | ResizeObserverSPI2.prototype.broadcastActive = function() {
|
2308 | if (!this.hasActive()) {
|
2309 | return;
|
2310 | }
|
2311 | var ctx2 = this.callbackCtx_;
|
2312 | var entries = this.activeObservations_.map(function(observation) {
|
2313 | return new ResizeObserverEntry(observation.target, observation.broadcastRect());
|
2314 | });
|
2315 | this.callback_.call(ctx2, entries, ctx2);
|
2316 | this.clearActive();
|
2317 | };
|
2318 | ResizeObserverSPI2.prototype.clearActive = function() {
|
2319 | this.activeObservations_.splice(0);
|
2320 | };
|
2321 | ResizeObserverSPI2.prototype.hasActive = function() {
|
2322 | return this.activeObservations_.length > 0;
|
2323 | };
|
2324 | return ResizeObserverSPI2;
|
2325 | }()
|
2326 | );
|
2327 | var observers = typeof WeakMap !== "undefined" ? new WeakMap() : new MapShim();
|
2328 | var ResizeObserver$1 = (
|
2329 |
|
2330 | function() {
|
2331 | function ResizeObserver2(callback) {
|
2332 | if (!(this instanceof ResizeObserver2)) {
|
2333 | throw new TypeError("Cannot call a class as a function.");
|
2334 | }
|
2335 | if (!arguments.length) {
|
2336 | throw new TypeError("1 argument required, but only 0 present.");
|
2337 | }
|
2338 | var controller = ResizeObserverController.getInstance();
|
2339 | var observer = new ResizeObserverSPI(callback, controller, this);
|
2340 | observers.set(this, observer);
|
2341 | }
|
2342 | return ResizeObserver2;
|
2343 | }()
|
2344 | );
|
2345 | [
|
2346 | "observe",
|
2347 | "unobserve",
|
2348 | "disconnect"
|
2349 | ].forEach(function(method) {
|
2350 | ResizeObserver$1.prototype[method] = function() {
|
2351 | var _a;
|
2352 | return (_a = observers.get(this))[method].apply(_a, arguments);
|
2353 | };
|
2354 | });
|
2355 | var index$j = function() {
|
2356 | if (typeof global$1.ResizeObserver !== "undefined") {
|
2357 | return global$1.ResizeObserver;
|
2358 | }
|
2359 | return ResizeObserver$1;
|
2360 | }();
|
2361 | var useEffectWithTarget = createEffectWithTarget$1(React$1.useLayoutEffect);
|
2362 | const useLayoutEffectWithTarget = useEffectWithTarget;
|
2363 | var useIsomorphicLayoutEffectWithTarget = isBrowser$3 ? useLayoutEffectWithTarget : useEffectWithTarget$2;
|
2364 | const useIsomorphicLayoutEffectWithTarget$1 = useIsomorphicLayoutEffectWithTarget;
|
2365 | function useSize(target) {
|
2366 | var _a = __read(useRafState(function() {
|
2367 | var el = getTargetElement(target);
|
2368 | return el ? {
|
2369 | width: el.clientWidth,
|
2370 | height: el.clientHeight
|
2371 | } : void 0;
|
2372 | }), 2), state = _a[0], setState = _a[1];
|
2373 | useIsomorphicLayoutEffectWithTarget$1(function() {
|
2374 | var el = getTargetElement(target);
|
2375 | if (!el) {
|
2376 | return;
|
2377 | }
|
2378 | var resizeObserver = new index$j(function(entries) {
|
2379 | entries.forEach(function(entry) {
|
2380 | var _a2 = entry.target, clientWidth = _a2.clientWidth, clientHeight = _a2.clientHeight;
|
2381 | setState({
|
2382 | width: clientWidth,
|
2383 | height: clientHeight
|
2384 | });
|
2385 | });
|
2386 | });
|
2387 | resizeObserver.observe(el);
|
2388 | return function() {
|
2389 | resizeObserver.disconnect();
|
2390 | };
|
2391 | }, [], target);
|
2392 | return state;
|
2393 | }
|
2394 | function useThrottleFn(fn, options) {
|
2395 | var _a;
|
2396 | if (isDev$1) {
|
2397 | if (!isFunction(fn)) {
|
2398 | console.error("useThrottleFn expected parameter is a function, got ".concat(typeof fn));
|
2399 | }
|
2400 | }
|
2401 | var fnRef = useLatest(fn);
|
2402 | var wait = (_a = options === null || options === void 0 ? void 0 : options.wait) !== null && _a !== void 0 ? _a : 1e3;
|
2403 | var throttled = React$1.useMemo(function() {
|
2404 | return throttle$2(function() {
|
2405 | var args = [];
|
2406 | for (var _i = 0; _i < arguments.length; _i++) {
|
2407 | args[_i] = arguments[_i];
|
2408 | }
|
2409 | return fnRef.current.apply(fnRef, __spreadArray([], __read(args), false));
|
2410 | }, wait, options);
|
2411 | }, []);
|
2412 | useUnmount$1(function() {
|
2413 | throttled.cancel();
|
2414 | });
|
2415 | return {
|
2416 | run: throttled,
|
2417 | cancel: throttled.cancel,
|
2418 | flush: throttled.flush
|
2419 | };
|
2420 | }
|
2421 | var useTimeout = function(fn, delay) {
|
2422 | var timerCallback = useMemoizedFn(fn);
|
2423 | var timerRef = React$1.useRef(null);
|
2424 | var clear2 = React$1.useCallback(function() {
|
2425 | if (timerRef.current) {
|
2426 | clearTimeout(timerRef.current);
|
2427 | }
|
2428 | }, []);
|
2429 | React$1.useEffect(function() {
|
2430 | if (!isNumber(delay) || delay < 0) {
|
2431 | return;
|
2432 | }
|
2433 | timerRef.current = setTimeout(timerCallback, delay);
|
2434 | return clear2;
|
2435 | }, [delay]);
|
2436 | return clear2;
|
2437 | };
|
2438 | const useTimeout$1 = useTimeout;
|
2439 | const MIN_DISTANCE = 10;
|
2440 | function getDirection(x, y) {
|
2441 | if (x > y && x > MIN_DISTANCE) {
|
2442 | return "horizontal";
|
2443 | }
|
2444 | if (y > x && y > MIN_DISTANCE) {
|
2445 | return "vertical";
|
2446 | }
|
2447 | return "";
|
2448 | }
|
2449 | function useTouch() {
|
2450 | const startX = React$1.useRef(0);
|
2451 | const startY = React$1.useRef(0);
|
2452 | const deltaX = React$1.useRef(0);
|
2453 | const deltaY = React$1.useRef(0);
|
2454 | const offsetX = React$1.useRef(0);
|
2455 | const offsetY = React$1.useRef(0);
|
2456 | const direction = React$1.useRef("");
|
2457 | const isVertical = () => direction.current === "vertical";
|
2458 | const isHorizontal = () => direction.current === "horizontal";
|
2459 | const reset = () => {
|
2460 | deltaX.current = 0;
|
2461 | deltaY.current = 0;
|
2462 | offsetX.current = 0;
|
2463 | offsetY.current = 0;
|
2464 | direction.current = "";
|
2465 | };
|
2466 | const start2 = (event) => {
|
2467 | reset();
|
2468 | startX.current = event.touches[0].clientX;
|
2469 | startY.current = event.touches[0].clientY;
|
2470 | };
|
2471 | const move2 = (event) => {
|
2472 | const touch = event.touches[0];
|
2473 | deltaX.current = touch.clientX < 0 ? 0 : touch.clientX - startX.current;
|
2474 | deltaY.current = touch.clientY - startY.current;
|
2475 | offsetX.current = Math.abs(deltaX.current);
|
2476 | offsetY.current = Math.abs(deltaY.current);
|
2477 | if (!direction.current) {
|
2478 | direction.current = getDirection(offsetX.current, offsetY.current);
|
2479 | }
|
2480 | };
|
2481 | return {
|
2482 | move: move2,
|
2483 | start: start2,
|
2484 | reset,
|
2485 | startX,
|
2486 | startY,
|
2487 | deltaX,
|
2488 | deltaY,
|
2489 | offsetX,
|
2490 | offsetY,
|
2491 | direction,
|
2492 | isVertical,
|
2493 | isHorizontal
|
2494 | };
|
2495 | }
|
2496 | const defaultRoot = canUseDom$1 ? window : void 0;
|
2497 | const overflowStylePatterns = ["scroll", "auto", "overlay"];
|
2498 | function isElement$1(node) {
|
2499 | const ELEMENT_NODE_TYPE = 1;
|
2500 | return node.nodeType === ELEMENT_NODE_TYPE;
|
2501 | }
|
2502 | function getScrollParent(el, root2 = defaultRoot) {
|
2503 | let node = el;
|
2504 | while (node && node !== root2 && isElement$1(node)) {
|
2505 | if (node === document.body) {
|
2506 | return root2;
|
2507 | }
|
2508 | const {
|
2509 | overflowY
|
2510 | } = window.getComputedStyle(node);
|
2511 | if (overflowStylePatterns.includes(overflowY) && node.scrollHeight > node.clientHeight) {
|
2512 | return node;
|
2513 | }
|
2514 | node = node.parentNode;
|
2515 | }
|
2516 | return root2;
|
2517 | }
|
2518 | let supportsPassive = false;
|
2519 | if (canUseDom$1) {
|
2520 | try {
|
2521 | const opts = {};
|
2522 | Object.defineProperty(opts, "passive", {
|
2523 | get() {
|
2524 | supportsPassive = true;
|
2525 | }
|
2526 | });
|
2527 | window.addEventListener("test-passive", null, opts);
|
2528 | } catch (e2) {
|
2529 | }
|
2530 | }
|
2531 | let totalLockCount = 0;
|
2532 | const BODY_LOCK_CLASS = "adm-overflow-hidden";
|
2533 | function getScrollableElement(el) {
|
2534 | let current = el === null || el === void 0 ? void 0 : el.parentElement;
|
2535 | while (current) {
|
2536 | if (current.clientHeight < current.scrollHeight) {
|
2537 | return current;
|
2538 | }
|
2539 | current = current.parentElement;
|
2540 | }
|
2541 | return null;
|
2542 | }
|
2543 | function useLockScroll(rootRef, shouldLock) {
|
2544 | const touch = useTouch();
|
2545 | const onTouchMove = (event) => {
|
2546 | touch.move(event);
|
2547 | const direction = touch.deltaY.current > 0 ? "10" : "01";
|
2548 | const el = getScrollParent(event.target, rootRef.current);
|
2549 | if (!el)
|
2550 | return;
|
2551 | if (shouldLock === "strict") {
|
2552 | const scrollableParent = getScrollableElement(event.target);
|
2553 | if (scrollableParent === document.body || scrollableParent === document.documentElement) {
|
2554 | event.preventDefault();
|
2555 | return;
|
2556 | }
|
2557 | }
|
2558 | const {
|
2559 | scrollHeight,
|
2560 | offsetHeight,
|
2561 | scrollTop
|
2562 | } = el;
|
2563 | const {
|
2564 | height
|
2565 | } = el.getBoundingClientRect();
|
2566 | let status = "11";
|
2567 | if (scrollTop === 0) {
|
2568 | status = offsetHeight >= scrollHeight ? "00" : "01";
|
2569 | } else if (scrollHeight <= Math.round(height + scrollTop)) {
|
2570 | status = "10";
|
2571 | }
|
2572 | if (status !== "11" && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
|
2573 | if (event.cancelable && supportsPassive) {
|
2574 | event.preventDefault();
|
2575 | }
|
2576 | }
|
2577 | };
|
2578 | const lock = () => {
|
2579 | document.addEventListener("touchstart", touch.start);
|
2580 | document.addEventListener("touchmove", onTouchMove, supportsPassive ? {
|
2581 | passive: false
|
2582 | } : false);
|
2583 | if (!totalLockCount) {
|
2584 | document.body.classList.add(BODY_LOCK_CLASS);
|
2585 | }
|
2586 | totalLockCount++;
|
2587 | };
|
2588 | const unlock = () => {
|
2589 | if (totalLockCount) {
|
2590 | document.removeEventListener("touchstart", touch.start);
|
2591 | document.removeEventListener("touchmove", onTouchMove);
|
2592 | totalLockCount--;
|
2593 | if (!totalLockCount) {
|
2594 | document.body.classList.remove(BODY_LOCK_CLASS);
|
2595 | }
|
2596 | }
|
2597 | };
|
2598 | React$1.useEffect(() => {
|
2599 | if (shouldLock) {
|
2600 | lock();
|
2601 | return () => {
|
2602 | unlock();
|
2603 | };
|
2604 | }
|
2605 | }, [shouldLock]);
|
2606 | }
|
2607 | let updateQueue = makeQueue();
|
2608 | const raf = (fn) => schedule(fn, updateQueue);
|
2609 | let writeQueue = makeQueue();
|
2610 | raf.write = (fn) => schedule(fn, writeQueue);
|
2611 | let onStartQueue = makeQueue();
|
2612 | raf.onStart = (fn) => schedule(fn, onStartQueue);
|
2613 | let onFrameQueue = makeQueue();
|
2614 | raf.onFrame = (fn) => schedule(fn, onFrameQueue);
|
2615 | let onFinishQueue = makeQueue();
|
2616 | raf.onFinish = (fn) => schedule(fn, onFinishQueue);
|
2617 | let timeouts = [];
|
2618 | raf.setTimeout = (handler, ms) => {
|
2619 | let time = raf.now() + ms;
|
2620 | let cancel = () => {
|
2621 | let i2 = timeouts.findIndex((t) => t.cancel == cancel);
|
2622 | if (~i2)
|
2623 | timeouts.splice(i2, 1);
|
2624 | pendingCount -= ~i2 ? 1 : 0;
|
2625 | };
|
2626 | let timeout = {
|
2627 | time,
|
2628 | handler,
|
2629 | cancel
|
2630 | };
|
2631 | timeouts.splice(findTimeout(time), 0, timeout);
|
2632 | pendingCount += 1;
|
2633 | start();
|
2634 | return timeout;
|
2635 | };
|
2636 | let findTimeout = (time) => ~(~timeouts.findIndex((t) => t.time > time) || ~timeouts.length);
|
2637 | raf.cancel = (fn) => {
|
2638 | onStartQueue.delete(fn);
|
2639 | onFrameQueue.delete(fn);
|
2640 | onFinishQueue.delete(fn);
|
2641 | updateQueue.delete(fn);
|
2642 | writeQueue.delete(fn);
|
2643 | };
|
2644 | raf.sync = (fn) => {
|
2645 | sync = true;
|
2646 | raf.batchedUpdates(fn);
|
2647 | sync = false;
|
2648 | };
|
2649 | raf.throttle = (fn) => {
|
2650 | let lastArgs;
|
2651 | function queuedFn() {
|
2652 | try {
|
2653 | fn(...lastArgs);
|
2654 | } finally {
|
2655 | lastArgs = null;
|
2656 | }
|
2657 | }
|
2658 | function throttled(...args) {
|
2659 | lastArgs = args;
|
2660 | raf.onStart(queuedFn);
|
2661 | }
|
2662 | throttled.handler = fn;
|
2663 | throttled.cancel = () => {
|
2664 | onStartQueue.delete(queuedFn);
|
2665 | lastArgs = null;
|
2666 | };
|
2667 | return throttled;
|
2668 | };
|
2669 | let nativeRaf = typeof window != "undefined" ? window.requestAnimationFrame : () => {
|
2670 | };
|
2671 | raf.use = (impl) => nativeRaf = impl;
|
2672 | raf.now = typeof performance != "undefined" ? () => performance.now() : Date.now;
|
2673 | raf.batchedUpdates = (fn) => fn();
|
2674 | raf.catch = console.error;
|
2675 | raf.frameLoop = "always";
|
2676 | raf.advance = () => {
|
2677 | if (raf.frameLoop !== "demand") {
|
2678 | console.warn("Cannot call the manual advancement of rafz whilst frameLoop is not set as demand");
|
2679 | } else {
|
2680 | update();
|
2681 | }
|
2682 | };
|
2683 | let ts = -1;
|
2684 | let pendingCount = 0;
|
2685 | let sync = false;
|
2686 | function schedule(fn, queue) {
|
2687 | if (sync) {
|
2688 | queue.delete(fn);
|
2689 | fn(0);
|
2690 | } else {
|
2691 | queue.add(fn);
|
2692 | start();
|
2693 | }
|
2694 | }
|
2695 | function start() {
|
2696 | if (ts < 0) {
|
2697 | ts = 0;
|
2698 | if (raf.frameLoop !== "demand") {
|
2699 | nativeRaf(loop);
|
2700 | }
|
2701 | }
|
2702 | }
|
2703 | function stop() {
|
2704 | ts = -1;
|
2705 | }
|
2706 | function loop() {
|
2707 | if (~ts) {
|
2708 | nativeRaf(loop);
|
2709 | raf.batchedUpdates(update);
|
2710 | }
|
2711 | }
|
2712 | function update() {
|
2713 | let prevTs = ts;
|
2714 | ts = raf.now();
|
2715 | let count = findTimeout(ts);
|
2716 | if (count) {
|
2717 | eachSafely(timeouts.splice(0, count), (t) => t.handler());
|
2718 | pendingCount -= count;
|
2719 | }
|
2720 | if (!pendingCount) {
|
2721 | stop();
|
2722 | return;
|
2723 | }
|
2724 | onStartQueue.flush();
|
2725 | updateQueue.flush(prevTs ? Math.min(64, ts - prevTs) : 16.667);
|
2726 | onFrameQueue.flush();
|
2727 | writeQueue.flush();
|
2728 | onFinishQueue.flush();
|
2729 | }
|
2730 | function makeQueue() {
|
2731 | let next = new Set();
|
2732 | let current = next;
|
2733 | return {
|
2734 | add(fn) {
|
2735 | pendingCount += current == next && !next.has(fn) ? 1 : 0;
|
2736 | next.add(fn);
|
2737 | },
|
2738 | delete(fn) {
|
2739 | pendingCount -= current == next && next.has(fn) ? 1 : 0;
|
2740 | return next.delete(fn);
|
2741 | },
|
2742 | flush(arg) {
|
2743 | if (current.size) {
|
2744 | next = new Set();
|
2745 | pendingCount -= current.size;
|
2746 | eachSafely(current, (fn) => fn(arg) && next.add(fn));
|
2747 | pendingCount += next.size;
|
2748 | current = next;
|
2749 | }
|
2750 | }
|
2751 | };
|
2752 | }
|
2753 | function eachSafely(values, each2) {
|
2754 | values.forEach((value) => {
|
2755 | try {
|
2756 | each2(value);
|
2757 | } catch (e2) {
|
2758 | raf.catch(e2);
|
2759 | }
|
2760 | });
|
2761 | }
|
2762 | function noop$1() {
|
2763 | }
|
2764 | const defineHidden = (obj, key, value) => Object.defineProperty(obj, key, {
|
2765 | value,
|
2766 | writable: true,
|
2767 | configurable: true
|
2768 | });
|
2769 | const is = {
|
2770 | arr: Array.isArray,
|
2771 | obj: (a) => !!a && a.constructor.name === "Object",
|
2772 | fun: (a) => typeof a === "function",
|
2773 | str: (a) => typeof a === "string",
|
2774 | num: (a) => typeof a === "number",
|
2775 | und: (a) => a === void 0
|
2776 | };
|
2777 | function isEqual$1(a, b) {
|
2778 | if (is.arr(a)) {
|
2779 | if (!is.arr(b) || a.length !== b.length)
|
2780 | return false;
|
2781 | for (let i2 = 0; i2 < a.length; i2++) {
|
2782 | if (a[i2] !== b[i2])
|
2783 | return false;
|
2784 | }
|
2785 | return true;
|
2786 | }
|
2787 | return a === b;
|
2788 | }
|
2789 | const each = (obj, fn) => obj.forEach(fn);
|
2790 | function eachProp(obj, fn, ctx2) {
|
2791 | if (is.arr(obj)) {
|
2792 | for (let i2 = 0; i2 < obj.length; i2++) {
|
2793 | fn.call(ctx2, obj[i2], `${i2}`);
|
2794 | }
|
2795 | return;
|
2796 | }
|
2797 | for (const key in obj) {
|
2798 | if (obj.hasOwnProperty(key)) {
|
2799 | fn.call(ctx2, obj[key], key);
|
2800 | }
|
2801 | }
|
2802 | }
|
2803 | const toArray$3 = (a) => is.und(a) ? [] : is.arr(a) ? a : [a];
|
2804 | function flush(queue, iterator) {
|
2805 | if (queue.size) {
|
2806 | const items = Array.from(queue);
|
2807 | queue.clear();
|
2808 | each(items, iterator);
|
2809 | }
|
2810 | }
|
2811 | const flushCalls = (queue, ...args) => flush(queue, (fn) => fn(...args));
|
2812 | const isSSR = () => typeof window === "undefined" || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);
|
2813 | let createStringInterpolator$1;
|
2814 | let to$1;
|
2815 | let colors$1 = null;
|
2816 | let skipAnimation = false;
|
2817 | let willAdvance = noop$1;
|
2818 | const assign = (globals2) => {
|
2819 | if (globals2.to)
|
2820 | to$1 = globals2.to;
|
2821 | if (globals2.now)
|
2822 | raf.now = globals2.now;
|
2823 | if (globals2.colors !== void 0)
|
2824 | colors$1 = globals2.colors;
|
2825 | if (globals2.skipAnimation != null)
|
2826 | skipAnimation = globals2.skipAnimation;
|
2827 | if (globals2.createStringInterpolator)
|
2828 | createStringInterpolator$1 = globals2.createStringInterpolator;
|
2829 | if (globals2.requestAnimationFrame)
|
2830 | raf.use(globals2.requestAnimationFrame);
|
2831 | if (globals2.batchedUpdates)
|
2832 | raf.batchedUpdates = globals2.batchedUpdates;
|
2833 | if (globals2.willAdvance)
|
2834 | willAdvance = globals2.willAdvance;
|
2835 | if (globals2.frameLoop)
|
2836 | raf.frameLoop = globals2.frameLoop;
|
2837 | };
|
2838 | var globals = Object.freeze({
|
2839 | __proto__: null,
|
2840 | get createStringInterpolator() {
|
2841 | return createStringInterpolator$1;
|
2842 | },
|
2843 | get to() {
|
2844 | return to$1;
|
2845 | },
|
2846 | get colors() {
|
2847 | return colors$1;
|
2848 | },
|
2849 | get skipAnimation() {
|
2850 | return skipAnimation;
|
2851 | },
|
2852 | get willAdvance() {
|
2853 | return willAdvance;
|
2854 | },
|
2855 | assign
|
2856 | });
|
2857 | const startQueue = new Set();
|
2858 | let currentFrame = [];
|
2859 | let prevFrame = [];
|
2860 | let priority = 0;
|
2861 | const frameLoop = {
|
2862 | get idle() {
|
2863 | return !startQueue.size && !currentFrame.length;
|
2864 | },
|
2865 | start(animation) {
|
2866 | if (priority > animation.priority) {
|
2867 | startQueue.add(animation);
|
2868 | raf.onStart(flushStartQueue);
|
2869 | } else {
|
2870 | startSafely(animation);
|
2871 | raf(advance);
|
2872 | }
|
2873 | },
|
2874 | advance,
|
2875 | sort(animation) {
|
2876 | if (priority) {
|
2877 | raf.onFrame(() => frameLoop.sort(animation));
|
2878 | } else {
|
2879 | const prevIndex = currentFrame.indexOf(animation);
|
2880 | if (~prevIndex) {
|
2881 | currentFrame.splice(prevIndex, 1);
|
2882 | startUnsafely(animation);
|
2883 | }
|
2884 | }
|
2885 | },
|
2886 | clear() {
|
2887 | currentFrame = [];
|
2888 | startQueue.clear();
|
2889 | }
|
2890 | };
|
2891 | function flushStartQueue() {
|
2892 | startQueue.forEach(startSafely);
|
2893 | startQueue.clear();
|
2894 | raf(advance);
|
2895 | }
|
2896 | function startSafely(animation) {
|
2897 | if (!currentFrame.includes(animation))
|
2898 | startUnsafely(animation);
|
2899 | }
|
2900 | function startUnsafely(animation) {
|
2901 | currentFrame.splice(findIndex(currentFrame, (other) => other.priority > animation.priority), 0, animation);
|
2902 | }
|
2903 | function advance(dt) {
|
2904 | const nextFrame = prevFrame;
|
2905 | for (let i2 = 0; i2 < currentFrame.length; i2++) {
|
2906 | const animation = currentFrame[i2];
|
2907 | priority = animation.priority;
|
2908 | if (!animation.idle) {
|
2909 | willAdvance(animation);
|
2910 | animation.advance(dt);
|
2911 | if (!animation.idle) {
|
2912 | nextFrame.push(animation);
|
2913 | }
|
2914 | }
|
2915 | }
|
2916 | priority = 0;
|
2917 | prevFrame = currentFrame;
|
2918 | prevFrame.length = 0;
|
2919 | currentFrame = nextFrame;
|
2920 | return currentFrame.length > 0;
|
2921 | }
|
2922 | function findIndex(arr, test) {
|
2923 | const index2 = arr.findIndex(test);
|
2924 | return index2 < 0 ? arr.length : index2;
|
2925 | }
|
2926 | const clamp$2 = (min2, max2, v) => Math.min(Math.max(v, min2), max2);
|
2927 | const colors = {
|
2928 | transparent: 0,
|
2929 | aliceblue: 4042850303,
|
2930 | antiquewhite: 4209760255,
|
2931 | aqua: 16777215,
|
2932 | aquamarine: 2147472639,
|
2933 | azure: 4043309055,
|
2934 | beige: 4126530815,
|
2935 | bisque: 4293182719,
|
2936 | black: 255,
|
2937 | blanchedalmond: 4293643775,
|
2938 | blue: 65535,
|
2939 | blueviolet: 2318131967,
|
2940 | brown: 2771004159,
|
2941 | burlywood: 3736635391,
|
2942 | burntsienna: 3934150143,
|
2943 | cadetblue: 1604231423,
|
2944 | chartreuse: 2147418367,
|
2945 | chocolate: 3530104575,
|
2946 | coral: 4286533887,
|
2947 | cornflowerblue: 1687547391,
|
2948 | cornsilk: 4294499583,
|
2949 | crimson: 3692313855,
|
2950 | cyan: 16777215,
|
2951 | darkblue: 35839,
|
2952 | darkcyan: 9145343,
|
2953 | darkgoldenrod: 3095792639,
|
2954 | darkgray: 2846468607,
|
2955 | darkgreen: 6553855,
|
2956 | darkgrey: 2846468607,
|
2957 | darkkhaki: 3182914559,
|
2958 | darkmagenta: 2332068863,
|
2959 | darkolivegreen: 1433087999,
|
2960 | darkorange: 4287365375,
|
2961 | darkorchid: 2570243327,
|
2962 | darkred: 2332033279,
|
2963 | darksalmon: 3918953215,
|
2964 | darkseagreen: 2411499519,
|
2965 | darkslateblue: 1211993087,
|
2966 | darkslategray: 793726975,
|
2967 | darkslategrey: 793726975,
|
2968 | darkturquoise: 13554175,
|
2969 | darkviolet: 2483082239,
|
2970 | deeppink: 4279538687,
|
2971 | deepskyblue: 12582911,
|
2972 | dimgray: 1768516095,
|
2973 | dimgrey: 1768516095,
|
2974 | dodgerblue: 512819199,
|
2975 | firebrick: 2988581631,
|
2976 | floralwhite: 4294635775,
|
2977 | forestgreen: 579543807,
|
2978 | fuchsia: 4278255615,
|
2979 | gainsboro: 3705462015,
|
2980 | ghostwhite: 4177068031,
|
2981 | gold: 4292280575,
|
2982 | goldenrod: 3668254975,
|
2983 | gray: 2155905279,
|
2984 | green: 8388863,
|
2985 | greenyellow: 2919182335,
|
2986 | grey: 2155905279,
|
2987 | honeydew: 4043305215,
|
2988 | hotpink: 4285117695,
|
2989 | indianred: 3445382399,
|
2990 | indigo: 1258324735,
|
2991 | ivory: 4294963455,
|
2992 | khaki: 4041641215,
|
2993 | lavender: 3873897215,
|
2994 | lavenderblush: 4293981695,
|
2995 | lawngreen: 2096890111,
|
2996 | lemonchiffon: 4294626815,
|
2997 | lightblue: 2916673279,
|
2998 | lightcoral: 4034953471,
|
2999 | lightcyan: 3774873599,
|
3000 | lightgoldenrodyellow: 4210742015,
|
3001 | lightgray: 3553874943,
|
3002 | lightgreen: 2431553791,
|
3003 | lightgrey: 3553874943,
|
3004 | lightpink: 4290167295,
|
3005 | lightsalmon: 4288707327,
|
3006 | lightseagreen: 548580095,
|
3007 | lightskyblue: 2278488831,
|
3008 | lightslategray: 2005441023,
|
3009 | lightslategrey: 2005441023,
|
3010 | lightsteelblue: 2965692159,
|
3011 | lightyellow: 4294959359,
|
3012 | lime: 16711935,
|
3013 | limegreen: 852308735,
|
3014 | linen: 4210091775,
|
3015 | magenta: 4278255615,
|
3016 | maroon: 2147483903,
|
3017 | mediumaquamarine: 1724754687,
|
3018 | mediumblue: 52735,
|
3019 | mediumorchid: 3126187007,
|
3020 | mediumpurple: 2473647103,
|
3021 | mediumseagreen: 1018393087,
|
3022 | mediumslateblue: 2070474495,
|
3023 | mediumspringgreen: 16423679,
|
3024 | mediumturquoise: 1221709055,
|
3025 | mediumvioletred: 3340076543,
|
3026 | midnightblue: 421097727,
|
3027 | mintcream: 4127193855,
|
3028 | mistyrose: 4293190143,
|
3029 | moccasin: 4293178879,
|
3030 | navajowhite: 4292783615,
|
3031 | navy: 33023,
|
3032 | oldlace: 4260751103,
|
3033 | olive: 2155872511,
|
3034 | olivedrab: 1804477439,
|
3035 | orange: 4289003775,
|
3036 | orangered: 4282712319,
|
3037 | orchid: 3664828159,
|
3038 | palegoldenrod: 4008225535,
|
3039 | palegreen: 2566625535,
|
3040 | paleturquoise: 2951671551,
|
3041 | palevioletred: 3681588223,
|
3042 | papayawhip: 4293907967,
|
3043 | peachpuff: 4292524543,
|
3044 | peru: 3448061951,
|
3045 | pink: 4290825215,
|
3046 | plum: 3718307327,
|
3047 | powderblue: 2967529215,
|
3048 | purple: 2147516671,
|
3049 | rebeccapurple: 1714657791,
|
3050 | red: 4278190335,
|
3051 | rosybrown: 3163525119,
|
3052 | royalblue: 1097458175,
|
3053 | saddlebrown: 2336560127,
|
3054 | salmon: 4202722047,
|
3055 | sandybrown: 4104413439,
|
3056 | seagreen: 780883967,
|
3057 | seashell: 4294307583,
|
3058 | sienna: 2689740287,
|
3059 | silver: 3233857791,
|
3060 | skyblue: 2278484991,
|
3061 | slateblue: 1784335871,
|
3062 | slategray: 1887473919,
|
3063 | slategrey: 1887473919,
|
3064 | snow: 4294638335,
|
3065 | springgreen: 16744447,
|
3066 | steelblue: 1182971135,
|
3067 | tan: 3535047935,
|
3068 | teal: 8421631,
|
3069 | thistle: 3636451583,
|
3070 | tomato: 4284696575,
|
3071 | turquoise: 1088475391,
|
3072 | violet: 4001558271,
|
3073 | wheat: 4125012991,
|
3074 | white: 4294967295,
|
3075 | whitesmoke: 4126537215,
|
3076 | yellow: 4294902015,
|
3077 | yellowgreen: 2597139199
|
3078 | };
|
3079 | const NUMBER = "[-+]?\\d*\\.?\\d+";
|
3080 | const PERCENTAGE = NUMBER + "%";
|
3081 | function call$3(...parts) {
|
3082 | return "\\(\\s*(" + parts.join(")\\s*,\\s*(") + ")\\s*\\)";
|
3083 | }
|
3084 | const rgb = new RegExp("rgb" + call$3(NUMBER, NUMBER, NUMBER));
|
3085 | const rgba = new RegExp("rgba" + call$3(NUMBER, NUMBER, NUMBER, NUMBER));
|
3086 | const hsl = new RegExp("hsl" + call$3(NUMBER, PERCENTAGE, PERCENTAGE));
|
3087 | const hsla = new RegExp("hsla" + call$3(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
|
3088 | const hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
|
3089 | const hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
|
3090 | const hex6 = /^#([0-9a-fA-F]{6})$/;
|
3091 | const hex8 = /^#([0-9a-fA-F]{8})$/;
|
3092 | function normalizeColor(color) {
|
3093 | let match;
|
3094 | if (typeof color === "number") {
|
3095 | return color >>> 0 === color && color >= 0 && color <= 4294967295 ? color : null;
|
3096 | }
|
3097 | if (match = hex6.exec(color))
|
3098 | return parseInt(match[1] + "ff", 16) >>> 0;
|
3099 | if (colors$1 && colors$1[color] !== void 0) {
|
3100 | return colors$1[color];
|
3101 | }
|
3102 | if (match = rgb.exec(color)) {
|
3103 | return (parse255(match[1]) << 24 | parse255(match[2]) << 16 | parse255(match[3]) << 8 | 255) >>> 0;
|
3104 | }
|
3105 | if (match = rgba.exec(color)) {
|
3106 | return (parse255(match[1]) << 24 | parse255(match[2]) << 16 | parse255(match[3]) << 8 | parse1(match[4])) >>> 0;
|
3107 | }
|
3108 | if (match = hex3.exec(color)) {
|
3109 | return parseInt(match[1] + match[1] + match[2] + match[2] + match[3] + match[3] + "ff", 16) >>> 0;
|
3110 | }
|
3111 | if (match = hex8.exec(color))
|
3112 | return parseInt(match[1], 16) >>> 0;
|
3113 | if (match = hex4.exec(color)) {
|
3114 | return parseInt(match[1] + match[1] + match[2] + match[2] + match[3] + match[3] + match[4] + match[4], 16) >>> 0;
|
3115 | }
|
3116 | if (match = hsl.exec(color)) {
|
3117 | return (hslToRgb(parse360(match[1]), parsePercentage(match[2]), parsePercentage(match[3])) | 255) >>> 0;
|
3118 | }
|
3119 | if (match = hsla.exec(color)) {
|
3120 | return (hslToRgb(parse360(match[1]), parsePercentage(match[2]), parsePercentage(match[3])) | parse1(match[4])) >>> 0;
|
3121 | }
|
3122 | return null;
|
3123 | }
|
3124 | function hue2rgb(p, q, t) {
|
3125 | if (t < 0)
|
3126 | t += 1;
|
3127 | if (t > 1)
|
3128 | t -= 1;
|
3129 | if (t < 1 / 6)
|
3130 | return p + (q - p) * 6 * t;
|
3131 | if (t < 1 / 2)
|
3132 | return q;
|
3133 | if (t < 2 / 3)
|
3134 | return p + (q - p) * (2 / 3 - t) * 6;
|
3135 | return p;
|
3136 | }
|
3137 | function hslToRgb(h, s, l) {
|
3138 | const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
3139 | const p = 2 * l - q;
|
3140 | const r = hue2rgb(p, q, h + 1 / 3);
|
3141 | const g = hue2rgb(p, q, h);
|
3142 | const b = hue2rgb(p, q, h - 1 / 3);
|
3143 | return Math.round(r * 255) << 24 | Math.round(g * 255) << 16 | Math.round(b * 255) << 8;
|
3144 | }
|
3145 | function parse255(str) {
|
3146 | const int = parseInt(str, 10);
|
3147 | if (int < 0)
|
3148 | return 0;
|
3149 | if (int > 255)
|
3150 | return 255;
|
3151 | return int;
|
3152 | }
|
3153 | function parse360(str) {
|
3154 | const int = parseFloat(str);
|
3155 | return (int % 360 + 360) % 360 / 360;
|
3156 | }
|
3157 | function parse1(str) {
|
3158 | const num = parseFloat(str);
|
3159 | if (num < 0)
|
3160 | return 0;
|
3161 | if (num > 1)
|
3162 | return 255;
|
3163 | return Math.round(num * 255);
|
3164 | }
|
3165 | function parsePercentage(str) {
|
3166 | const int = parseFloat(str);
|
3167 | if (int < 0)
|
3168 | return 0;
|
3169 | if (int > 100)
|
3170 | return 1;
|
3171 | return int / 100;
|
3172 | }
|
3173 | function colorToRgba(input) {
|
3174 | let int32Color = normalizeColor(input);
|
3175 | if (int32Color === null)
|
3176 | return input;
|
3177 | int32Color = int32Color || 0;
|
3178 | let r = (int32Color & 4278190080) >>> 24;
|
3179 | let g = (int32Color & 16711680) >>> 16;
|
3180 | let b = (int32Color & 65280) >>> 8;
|
3181 | let a = (int32Color & 255) / 255;
|
3182 | return `rgba(${r}, ${g}, ${b}, ${a})`;
|
3183 | }
|
3184 | const createInterpolator = (range2, output, extrapolate) => {
|
3185 | if (is.fun(range2)) {
|
3186 | return range2;
|
3187 | }
|
3188 | if (is.arr(range2)) {
|
3189 | return createInterpolator({
|
3190 | range: range2,
|
3191 | output,
|
3192 | extrapolate
|
3193 | });
|
3194 | }
|
3195 | if (is.str(range2.output[0])) {
|
3196 | return createStringInterpolator$1(range2);
|
3197 | }
|
3198 | const config2 = range2;
|
3199 | const outputRange = config2.output;
|
3200 | const inputRange = config2.range || [0, 1];
|
3201 | const extrapolateLeft = config2.extrapolateLeft || config2.extrapolate || "extend";
|
3202 | const extrapolateRight = config2.extrapolateRight || config2.extrapolate || "extend";
|
3203 | const easing = config2.easing || ((t) => t);
|
3204 | return (input) => {
|
3205 | const range3 = findRange(input, inputRange);
|
3206 | return interpolate(input, inputRange[range3], inputRange[range3 + 1], outputRange[range3], outputRange[range3 + 1], easing, extrapolateLeft, extrapolateRight, config2.map);
|
3207 | };
|
3208 | };
|
3209 | function interpolate(input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight, map) {
|
3210 | let result = map ? map(input) : input;
|
3211 | if (result < inputMin) {
|
3212 | if (extrapolateLeft === "identity")
|
3213 | return result;
|
3214 | else if (extrapolateLeft === "clamp")
|
3215 | result = inputMin;
|
3216 | }
|
3217 | if (result > inputMax) {
|
3218 | if (extrapolateRight === "identity")
|
3219 | return result;
|
3220 | else if (extrapolateRight === "clamp")
|
3221 | result = inputMax;
|
3222 | }
|
3223 | if (outputMin === outputMax)
|
3224 | return outputMin;
|
3225 | if (inputMin === inputMax)
|
3226 | return input <= inputMin ? outputMin : outputMax;
|
3227 | if (inputMin === -Infinity)
|
3228 | result = -result;
|
3229 | else if (inputMax === Infinity)
|
3230 | result = result - inputMin;
|
3231 | else
|
3232 | result = (result - inputMin) / (inputMax - inputMin);
|
3233 | result = easing(result);
|
3234 | if (outputMin === -Infinity)
|
3235 | result = -result;
|
3236 | else if (outputMax === Infinity)
|
3237 | result = result + outputMin;
|
3238 | else
|
3239 | result = result * (outputMax - outputMin) + outputMin;
|
3240 | return result;
|
3241 | }
|
3242 | function findRange(input, inputRange) {
|
3243 | for (var i2 = 1; i2 < inputRange.length - 1; ++i2)
|
3244 | if (inputRange[i2] >= input)
|
3245 | break;
|
3246 | return i2 - 1;
|
3247 | }
|
3248 | const steps = (steps2, direction = "end") => (progress) => {
|
3249 | progress = direction === "end" ? Math.min(progress, 0.999) : Math.max(progress, 1e-3);
|
3250 | const expanded = progress * steps2;
|
3251 | const rounded = direction === "end" ? Math.floor(expanded) : Math.ceil(expanded);
|
3252 | return clamp$2(0, 1, rounded / steps2);
|
3253 | };
|
3254 | const c1 = 1.70158;
|
3255 | const c2 = c1 * 1.525;
|
3256 | const c3 = c1 + 1;
|
3257 | const c4 = 2 * Math.PI / 3;
|
3258 | const c5 = 2 * Math.PI / 4.5;
|
3259 | const bounceOut = (x) => {
|
3260 | const n1 = 7.5625;
|
3261 | const d1 = 2.75;
|
3262 | if (x < 1 / d1) {
|
3263 | return n1 * x * x;
|
3264 | } else if (x < 2 / d1) {
|
3265 | return n1 * (x -= 1.5 / d1) * x + 0.75;
|
3266 | } else if (x < 2.5 / d1) {
|
3267 | return n1 * (x -= 2.25 / d1) * x + 0.9375;
|
3268 | } else {
|
3269 | return n1 * (x -= 2.625 / d1) * x + 0.984375;
|
3270 | }
|
3271 | };
|
3272 | const easings = {
|
3273 | linear: (x) => x,
|
3274 | easeInQuad: (x) => x * x,
|
3275 | easeOutQuad: (x) => 1 - (1 - x) * (1 - x),
|
3276 | easeInOutQuad: (x) => x < 0.5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2,
|
3277 | easeInCubic: (x) => x * x * x,
|
3278 | easeOutCubic: (x) => 1 - Math.pow(1 - x, 3),
|
3279 | easeInOutCubic: (x) => x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2,
|
3280 | easeInQuart: (x) => x * x * x * x,
|
3281 | easeOutQuart: (x) => 1 - Math.pow(1 - x, 4),
|
3282 | easeInOutQuart: (x) => x < 0.5 ? 8 * x * x * x * x : 1 - Math.pow(-2 * x + 2, 4) / 2,
|
3283 | easeInQuint: (x) => x * x * x * x * x,
|
3284 | easeOutQuint: (x) => 1 - Math.pow(1 - x, 5),
|
3285 | easeInOutQuint: (x) => x < 0.5 ? 16 * x * x * x * x * x : 1 - Math.pow(-2 * x + 2, 5) / 2,
|
3286 | easeInSine: (x) => 1 - Math.cos(x * Math.PI / 2),
|
3287 | easeOutSine: (x) => Math.sin(x * Math.PI / 2),
|
3288 | easeInOutSine: (x) => -(Math.cos(Math.PI * x) - 1) / 2,
|
3289 | easeInExpo: (x) => x === 0 ? 0 : Math.pow(2, 10 * x - 10),
|
3290 | easeOutExpo: (x) => x === 1 ? 1 : 1 - Math.pow(2, -10 * x),
|
3291 | easeInOutExpo: (x) => x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? Math.pow(2, 20 * x - 10) / 2 : (2 - Math.pow(2, -20 * x + 10)) / 2,
|
3292 | easeInCirc: (x) => 1 - Math.sqrt(1 - Math.pow(x, 2)),
|
3293 | easeOutCirc: (x) => Math.sqrt(1 - Math.pow(x - 1, 2)),
|
3294 | easeInOutCirc: (x) => x < 0.5 ? (1 - Math.sqrt(1 - Math.pow(2 * x, 2))) / 2 : (Math.sqrt(1 - Math.pow(-2 * x + 2, 2)) + 1) / 2,
|
3295 | easeInBack: (x) => c3 * x * x * x - c1 * x * x,
|
3296 | easeOutBack: (x) => 1 + c3 * Math.pow(x - 1, 3) + c1 * Math.pow(x - 1, 2),
|
3297 | easeInOutBack: (x) => x < 0.5 ? Math.pow(2 * x, 2) * ((c2 + 1) * 2 * x - c2) / 2 : (Math.pow(2 * x - 2, 2) * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2,
|
3298 | easeInElastic: (x) => x === 0 ? 0 : x === 1 ? 1 : -Math.pow(2, 10 * x - 10) * Math.sin((x * 10 - 10.75) * c4),
|
3299 | easeOutElastic: (x) => x === 0 ? 0 : x === 1 ? 1 : Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1,
|
3300 | easeInOutElastic: (x) => x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? -(Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * c5)) / 2 : Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * c5) / 2 + 1,
|
3301 | easeInBounce: (x) => 1 - bounceOut(1 - x),
|
3302 | easeOutBounce: bounceOut,
|
3303 | easeInOutBounce: (x) => x < 0.5 ? (1 - bounceOut(1 - 2 * x)) / 2 : (1 + bounceOut(2 * x - 1)) / 2,
|
3304 | steps
|
3305 | };
|
3306 | function _extends$4() {
|
3307 | _extends$4 = Object.assign ? Object.assign.bind() : function(target) {
|
3308 | for (var i2 = 1; i2 < arguments.length; i2++) {
|
3309 | var source = arguments[i2];
|
3310 | for (var key in source) {
|
3311 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
3312 | target[key] = source[key];
|
3313 | }
|
3314 | }
|
3315 | }
|
3316 | return target;
|
3317 | };
|
3318 | return _extends$4.apply(this, arguments);
|
3319 | }
|
3320 | const $get = Symbol.for("FluidValue.get");
|
3321 | const $observers = Symbol.for("FluidValue.observers");
|
3322 | const hasFluidValue = (arg) => Boolean(arg && arg[$get]);
|
3323 | const getFluidValue = (arg) => arg && arg[$get] ? arg[$get]() : arg;
|
3324 | const getFluidObservers = (target) => target[$observers] || null;
|
3325 | function callFluidObserver(observer, event) {
|
3326 | if (observer.eventObserved) {
|
3327 | observer.eventObserved(event);
|
3328 | } else {
|
3329 | observer(event);
|
3330 | }
|
3331 | }
|
3332 | function callFluidObservers(target, event) {
|
3333 | let observers2 = target[$observers];
|
3334 | if (observers2) {
|
3335 | observers2.forEach((observer) => {
|
3336 | callFluidObserver(observer, event);
|
3337 | });
|
3338 | }
|
3339 | }
|
3340 | class FluidValue {
|
3341 | constructor(get2) {
|
3342 | this[$get] = void 0;
|
3343 | this[$observers] = void 0;
|
3344 | if (!get2 && !(get2 = this.get)) {
|
3345 | throw Error("Unknown getter");
|
3346 | }
|
3347 | setFluidGetter(this, get2);
|
3348 | }
|
3349 | }
|
3350 | const setFluidGetter = (target, get2) => setHidden(target, $get, get2);
|
3351 | function addFluidObserver(target, observer) {
|
3352 | if (target[$get]) {
|
3353 | let observers2 = target[$observers];
|
3354 | if (!observers2) {
|
3355 | setHidden(target, $observers, observers2 = new Set());
|
3356 | }
|
3357 | if (!observers2.has(observer)) {
|
3358 | observers2.add(observer);
|
3359 | if (target.observerAdded) {
|
3360 | target.observerAdded(observers2.size, observer);
|
3361 | }
|
3362 | }
|
3363 | }
|
3364 | return observer;
|
3365 | }
|
3366 | function removeFluidObserver(target, observer) {
|
3367 | let observers2 = target[$observers];
|
3368 | if (observers2 && observers2.has(observer)) {
|
3369 | const count = observers2.size - 1;
|
3370 | if (count) {
|
3371 | observers2.delete(observer);
|
3372 | } else {
|
3373 | target[$observers] = null;
|
3374 | }
|
3375 | if (target.observerRemoved) {
|
3376 | target.observerRemoved(count, observer);
|
3377 | }
|
3378 | }
|
3379 | }
|
3380 | const setHidden = (target, key, value) => Object.defineProperty(target, key, {
|
3381 | value,
|
3382 | writable: true,
|
3383 | configurable: true
|
3384 | });
|
3385 | const numberRegex = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;
|
3386 | const colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi;
|
3387 | const unitRegex = new RegExp(`(${numberRegex.source})(%|[a-z]+)`, "i");
|
3388 | const rgbaRegex = /rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi;
|
3389 | const cssVariableRegex = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/;
|
3390 | const variableToRgba = (input) => {
|
3391 | const [token, fallback] = parseCSSVariable(input);
|
3392 | if (!token || isSSR()) {
|
3393 | return input;
|
3394 | }
|
3395 | const value = window.getComputedStyle(document.documentElement).getPropertyValue(token);
|
3396 | if (value) {
|
3397 | return value.trim();
|
3398 | } else if (fallback && fallback.startsWith("--")) {
|
3399 | const _value = window.getComputedStyle(document.documentElement).getPropertyValue(fallback);
|
3400 | if (_value) {
|
3401 | return _value;
|
3402 | } else {
|
3403 | return input;
|
3404 | }
|
3405 | } else if (fallback && cssVariableRegex.test(fallback)) {
|
3406 | return variableToRgba(fallback);
|
3407 | } else if (fallback) {
|
3408 | return fallback;
|
3409 | }
|
3410 | return input;
|
3411 | };
|
3412 | const parseCSSVariable = (current) => {
|
3413 | const match = cssVariableRegex.exec(current);
|
3414 | if (!match)
|
3415 | return [,];
|
3416 | const [, token, fallback] = match;
|
3417 | return [token, fallback];
|
3418 | };
|
3419 | let namedColorRegex;
|
3420 | const rgbaRound = (_, p1, p2, p3, p4) => `rgba(${Math.round(p1)}, ${Math.round(p2)}, ${Math.round(p3)}, ${p4})`;
|
3421 | const createStringInterpolator = (config2) => {
|
3422 | if (!namedColorRegex)
|
3423 | namedColorRegex = colors$1 ? new RegExp(`(${Object.keys(colors$1).join("|")})(?!\\w)`, "g") : /^\b$/;
|
3424 | const output = config2.output.map((value) => {
|
3425 | return getFluidValue(value).replace(cssVariableRegex, variableToRgba).replace(colorRegex, colorToRgba).replace(namedColorRegex, colorToRgba);
|
3426 | });
|
3427 | const keyframes = output.map((value) => value.match(numberRegex).map(Number));
|
3428 | const outputRanges = keyframes[0].map((_, i2) => keyframes.map((values) => {
|
3429 | if (!(i2 in values)) {
|
3430 | throw Error('The arity of each "output" value must be equal');
|
3431 | }
|
3432 | return values[i2];
|
3433 | }));
|
3434 | const interpolators = outputRanges.map((output2) => createInterpolator(_extends$4({}, config2, {
|
3435 | output: output2
|
3436 | })));
|
3437 | return (input) => {
|
3438 | var _output$find;
|
3439 | const missingUnit = !unitRegex.test(output[0]) && ((_output$find = output.find((value) => unitRegex.test(value))) == null ? void 0 : _output$find.replace(numberRegex, ""));
|
3440 | let i2 = 0;
|
3441 | return output[0].replace(numberRegex, () => `${interpolators[i2++](input)}${missingUnit || ""}`).replace(rgbaRegex, rgbaRound);
|
3442 | };
|
3443 | };
|
3444 | const prefix = "react-spring: ";
|
3445 | const once = (fn) => {
|
3446 | const func = fn;
|
3447 | let called = false;
|
3448 | if (typeof func != "function") {
|
3449 | throw new TypeError(`${prefix}once requires a function parameter`);
|
3450 | }
|
3451 | return (...args) => {
|
3452 | if (!called) {
|
3453 | func(...args);
|
3454 | called = true;
|
3455 | }
|
3456 | };
|
3457 | };
|
3458 | const warnInterpolate = once(console.warn);
|
3459 | function deprecateInterpolate() {
|
3460 | warnInterpolate(`${prefix}The "interpolate" function is deprecated in v9 (use "to" instead)`);
|
3461 | }
|
3462 | const warnDirectCall = once(console.warn);
|
3463 | function deprecateDirectCall() {
|
3464 | warnDirectCall(`${prefix}Directly calling start instead of using the api object is deprecated in v9 (use ".start" instead), this will be removed in later 0.X.0 versions`);
|
3465 | }
|
3466 | function isAnimatedString(value) {
|
3467 | return is.str(value) && (value[0] == "#" || /\d/.test(value) || !isSSR() && cssVariableRegex.test(value) || value in (colors$1 || {}));
|
3468 | }
|
3469 | const useIsomorphicLayoutEffect = isSSR() ? React$1.useEffect : React$1.useLayoutEffect;
|
3470 | const useIsMounted = () => {
|
3471 | const isMounted = React$1.useRef(false);
|
3472 | useIsomorphicLayoutEffect(() => {
|
3473 | isMounted.current = true;
|
3474 | return () => {
|
3475 | isMounted.current = false;
|
3476 | };
|
3477 | }, []);
|
3478 | return isMounted;
|
3479 | };
|
3480 | function useForceUpdate() {
|
3481 | const update2 = React$1.useState()[1];
|
3482 | const isMounted = useIsMounted();
|
3483 | return () => {
|
3484 | if (isMounted.current) {
|
3485 | update2(Math.random());
|
3486 | }
|
3487 | };
|
3488 | }
|
3489 | function useMemoOne(getResult, inputs) {
|
3490 | const [initial] = React$1.useState(() => ({
|
3491 | inputs,
|
3492 | result: getResult()
|
3493 | }));
|
3494 | const committed = React$1.useRef();
|
3495 | const prevCache = committed.current;
|
3496 | let cache = prevCache;
|
3497 | if (cache) {
|
3498 | const useCache = Boolean(inputs && cache.inputs && areInputsEqual(inputs, cache.inputs));
|
3499 | if (!useCache) {
|
3500 | cache = {
|
3501 | inputs,
|
3502 | result: getResult()
|
3503 | };
|
3504 | }
|
3505 | } else {
|
3506 | cache = initial;
|
3507 | }
|
3508 | React$1.useEffect(() => {
|
3509 | committed.current = cache;
|
3510 | if (prevCache == initial) {
|
3511 | initial.inputs = initial.result = void 0;
|
3512 | }
|
3513 | }, [cache]);
|
3514 | return cache.result;
|
3515 | }
|
3516 | function areInputsEqual(next, prev) {
|
3517 | if (next.length !== prev.length) {
|
3518 | return false;
|
3519 | }
|
3520 | for (let i2 = 0; i2 < next.length; i2++) {
|
3521 | if (next[i2] !== prev[i2]) {
|
3522 | return false;
|
3523 | }
|
3524 | }
|
3525 | return true;
|
3526 | }
|
3527 | const useOnce = (effect) => React$1.useEffect(effect, emptyDeps);
|
3528 | const emptyDeps = [];
|
3529 | function usePrev(value) {
|
3530 | const prevRef = React$1.useRef();
|
3531 | React$1.useEffect(() => {
|
3532 | prevRef.current = value;
|
3533 | });
|
3534 | return prevRef.current;
|
3535 | }
|
3536 | const $node = Symbol.for("Animated:node");
|
3537 | const isAnimated = (value) => !!value && value[$node] === value;
|
3538 | const getAnimated = (owner) => owner && owner[$node];
|
3539 | const setAnimated = (owner, node) => defineHidden(owner, $node, node);
|
3540 | const getPayload = (owner) => owner && owner[$node] && owner[$node].getPayload();
|
3541 | class Animated {
|
3542 | constructor() {
|
3543 | this.payload = void 0;
|
3544 | setAnimated(this, this);
|
3545 | }
|
3546 | getPayload() {
|
3547 | return this.payload || [];
|
3548 | }
|
3549 | }
|
3550 | class AnimatedValue extends Animated {
|
3551 | constructor(_value) {
|
3552 | super();
|
3553 | this.done = true;
|
3554 | this.elapsedTime = void 0;
|
3555 | this.lastPosition = void 0;
|
3556 | this.lastVelocity = void 0;
|
3557 | this.v0 = void 0;
|
3558 | this.durationProgress = 0;
|
3559 | this._value = _value;
|
3560 | if (is.num(this._value)) {
|
3561 | this.lastPosition = this._value;
|
3562 | }
|
3563 | }
|
3564 | static create(value) {
|
3565 | return new AnimatedValue(value);
|
3566 | }
|
3567 | getPayload() {
|
3568 | return [this];
|
3569 | }
|
3570 | getValue() {
|
3571 | return this._value;
|
3572 | }
|
3573 | setValue(value, step) {
|
3574 | if (is.num(value)) {
|
3575 | this.lastPosition = value;
|
3576 | if (step) {
|
3577 | value = Math.round(value / step) * step;
|
3578 | if (this.done) {
|
3579 | this.lastPosition = value;
|
3580 | }
|
3581 | }
|
3582 | }
|
3583 | if (this._value === value) {
|
3584 | return false;
|
3585 | }
|
3586 | this._value = value;
|
3587 | return true;
|
3588 | }
|
3589 | reset() {
|
3590 | const {
|
3591 | done
|
3592 | } = this;
|
3593 | this.done = false;
|
3594 | if (is.num(this._value)) {
|
3595 | this.elapsedTime = 0;
|
3596 | this.durationProgress = 0;
|
3597 | this.lastPosition = this._value;
|
3598 | if (done)
|
3599 | this.lastVelocity = null;
|
3600 | this.v0 = null;
|
3601 | }
|
3602 | }
|
3603 | }
|
3604 | class AnimatedString extends AnimatedValue {
|
3605 | constructor(value) {
|
3606 | super(0);
|
3607 | this._string = null;
|
3608 | this._toString = void 0;
|
3609 | this._toString = createInterpolator({
|
3610 | output: [value, value]
|
3611 | });
|
3612 | }
|
3613 | static create(value) {
|
3614 | return new AnimatedString(value);
|
3615 | }
|
3616 | getValue() {
|
3617 | let value = this._string;
|
3618 | return value == null ? this._string = this._toString(this._value) : value;
|
3619 | }
|
3620 | setValue(value) {
|
3621 | if (is.str(value)) {
|
3622 | if (value == this._string) {
|
3623 | return false;
|
3624 | }
|
3625 | this._string = value;
|
3626 | this._value = 1;
|
3627 | } else if (super.setValue(value)) {
|
3628 | this._string = null;
|
3629 | } else {
|
3630 | return false;
|
3631 | }
|
3632 | return true;
|
3633 | }
|
3634 | reset(goal) {
|
3635 | if (goal) {
|
3636 | this._toString = createInterpolator({
|
3637 | output: [this.getValue(), goal]
|
3638 | });
|
3639 | }
|
3640 | this._value = 0;
|
3641 | super.reset();
|
3642 | }
|
3643 | }
|
3644 | const TreeContext = {
|
3645 | dependencies: null
|
3646 | };
|
3647 | class AnimatedObject extends Animated {
|
3648 | constructor(source) {
|
3649 | super();
|
3650 | this.source = source;
|
3651 | this.setValue(source);
|
3652 | }
|
3653 | getValue(animated2) {
|
3654 | const values = {};
|
3655 | eachProp(this.source, (source, key) => {
|
3656 | if (isAnimated(source)) {
|
3657 | values[key] = source.getValue(animated2);
|
3658 | } else if (hasFluidValue(source)) {
|
3659 | values[key] = getFluidValue(source);
|
3660 | } else if (!animated2) {
|
3661 | values[key] = source;
|
3662 | }
|
3663 | });
|
3664 | return values;
|
3665 | }
|
3666 | setValue(source) {
|
3667 | this.source = source;
|
3668 | this.payload = this._makePayload(source);
|
3669 | }
|
3670 | reset() {
|
3671 | if (this.payload) {
|
3672 | each(this.payload, (node) => node.reset());
|
3673 | }
|
3674 | }
|
3675 | _makePayload(source) {
|
3676 | if (source) {
|
3677 | const payload = new Set();
|
3678 | eachProp(source, this._addToPayload, payload);
|
3679 | return Array.from(payload);
|
3680 | }
|
3681 | }
|
3682 | _addToPayload(source) {
|
3683 | if (TreeContext.dependencies && hasFluidValue(source)) {
|
3684 | TreeContext.dependencies.add(source);
|
3685 | }
|
3686 | const payload = getPayload(source);
|
3687 | if (payload) {
|
3688 | each(payload, (node) => this.add(node));
|
3689 | }
|
3690 | }
|
3691 | }
|
3692 | class AnimatedArray extends AnimatedObject {
|
3693 | constructor(source) {
|
3694 | super(source);
|
3695 | }
|
3696 | static create(source) {
|
3697 | return new AnimatedArray(source);
|
3698 | }
|
3699 | getValue() {
|
3700 | return this.source.map((node) => node.getValue());
|
3701 | }
|
3702 | setValue(source) {
|
3703 | const payload = this.getPayload();
|
3704 | if (source.length == payload.length) {
|
3705 | return payload.map((node, i2) => node.setValue(source[i2])).some(Boolean);
|
3706 | }
|
3707 | super.setValue(source.map(makeAnimated));
|
3708 | return true;
|
3709 | }
|
3710 | }
|
3711 | function makeAnimated(value) {
|
3712 | const nodeType = isAnimatedString(value) ? AnimatedString : AnimatedValue;
|
3713 | return nodeType.create(value);
|
3714 | }
|
3715 | function getAnimatedType(value) {
|
3716 | const parentNode = getAnimated(value);
|
3717 | return parentNode ? parentNode.constructor : is.arr(value) ? AnimatedArray : isAnimatedString(value) ? AnimatedString : AnimatedValue;
|
3718 | }
|
3719 | function _extends$3() {
|
3720 | _extends$3 = Object.assign ? Object.assign.bind() : function(target) {
|
3721 | for (var i2 = 1; i2 < arguments.length; i2++) {
|
3722 | var source = arguments[i2];
|
3723 | for (var key in source) {
|
3724 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
3725 | target[key] = source[key];
|
3726 | }
|
3727 | }
|
3728 | }
|
3729 | return target;
|
3730 | };
|
3731 | return _extends$3.apply(this, arguments);
|
3732 | }
|
3733 | const withAnimated = (Component, host2) => {
|
3734 | const hasInstance = !is.fun(Component) || Component.prototype && Component.prototype.isReactComponent;
|
3735 | return React$1.forwardRef((givenProps, givenRef) => {
|
3736 | const instanceRef = React$1.useRef(null);
|
3737 | const ref = hasInstance && React$1.useCallback((value) => {
|
3738 | instanceRef.current = updateRef(givenRef, value);
|
3739 | }, [givenRef]);
|
3740 | const [props, deps] = getAnimatedState(givenProps, host2);
|
3741 | const forceUpdate = useForceUpdate();
|
3742 | const callback = () => {
|
3743 | const instance = instanceRef.current;
|
3744 | if (hasInstance && !instance) {
|
3745 | return;
|
3746 | }
|
3747 | const didUpdate = instance ? host2.applyAnimatedValues(instance, props.getValue(true)) : false;
|
3748 | if (didUpdate === false) {
|
3749 | forceUpdate();
|
3750 | }
|
3751 | };
|
3752 | const observer = new PropsObserver(callback, deps);
|
3753 | const observerRef = React$1.useRef();
|
3754 | useIsomorphicLayoutEffect(() => {
|
3755 | observerRef.current = observer;
|
3756 | each(deps, (dep) => addFluidObserver(dep, observer));
|
3757 | return () => {
|
3758 | if (observerRef.current) {
|
3759 | each(observerRef.current.deps, (dep) => removeFluidObserver(dep, observerRef.current));
|
3760 | raf.cancel(observerRef.current.update);
|
3761 | }
|
3762 | };
|
3763 | });
|
3764 | React$1.useEffect(callback, []);
|
3765 | useOnce(() => () => {
|
3766 | const observer2 = observerRef.current;
|
3767 | each(observer2.deps, (dep) => removeFluidObserver(dep, observer2));
|
3768 | });
|
3769 | const usedProps = host2.getComponentProps(props.getValue());
|
3770 | return React__namespace.createElement(Component, _extends$3({}, usedProps, {
|
3771 | ref
|
3772 | }));
|
3773 | });
|
3774 | };
|
3775 | class PropsObserver {
|
3776 | constructor(update2, deps) {
|
3777 | this.update = update2;
|
3778 | this.deps = deps;
|
3779 | }
|
3780 | eventObserved(event) {
|
3781 | if (event.type == "change") {
|
3782 | raf.write(this.update);
|
3783 | }
|
3784 | }
|
3785 | }
|
3786 | function getAnimatedState(props, host2) {
|
3787 | const dependencies = new Set();
|
3788 | TreeContext.dependencies = dependencies;
|
3789 | if (props.style)
|
3790 | props = _extends$3({}, props, {
|
3791 | style: host2.createAnimatedStyle(props.style)
|
3792 | });
|
3793 | props = new AnimatedObject(props);
|
3794 | TreeContext.dependencies = null;
|
3795 | return [props, dependencies];
|
3796 | }
|
3797 | function updateRef(ref, value) {
|
3798 | if (ref) {
|
3799 | if (is.fun(ref))
|
3800 | ref(value);
|
3801 | else
|
3802 | ref.current = value;
|
3803 | }
|
3804 | return value;
|
3805 | }
|
3806 | const cacheKey = Symbol.for("AnimatedComponent");
|
3807 | const createHost = (components, {
|
3808 | applyAnimatedValues: _applyAnimatedValues = () => false,
|
3809 | createAnimatedStyle: _createAnimatedStyle = (style) => new AnimatedObject(style),
|
3810 | getComponentProps: _getComponentProps = (props) => props
|
3811 | } = {}) => {
|
3812 | const hostConfig = {
|
3813 | applyAnimatedValues: _applyAnimatedValues,
|
3814 | createAnimatedStyle: _createAnimatedStyle,
|
3815 | getComponentProps: _getComponentProps
|
3816 | };
|
3817 | const animated2 = (Component) => {
|
3818 | const displayName = getDisplayName(Component) || "Anonymous";
|
3819 | if (is.str(Component)) {
|
3820 | Component = animated2[Component] || (animated2[Component] = withAnimated(Component, hostConfig));
|
3821 | } else {
|
3822 | Component = Component[cacheKey] || (Component[cacheKey] = withAnimated(Component, hostConfig));
|
3823 | }
|
3824 | Component.displayName = `Animated(${displayName})`;
|
3825 | return Component;
|
3826 | };
|
3827 | eachProp(components, (Component, key) => {
|
3828 | if (is.arr(components)) {
|
3829 | key = getDisplayName(Component);
|
3830 | }
|
3831 | animated2[key] = animated2(Component);
|
3832 | });
|
3833 | return {
|
3834 | animated: animated2
|
3835 | };
|
3836 | };
|
3837 | const getDisplayName = (arg) => is.str(arg) ? arg : arg && is.str(arg.displayName) ? arg.displayName : is.fun(arg) && arg.name || null;
|
3838 | function _extends$2() {
|
3839 | _extends$2 = Object.assign ? Object.assign.bind() : function(target) {
|
3840 | for (var i2 = 1; i2 < arguments.length; i2++) {
|
3841 | var source = arguments[i2];
|
3842 | for (var key in source) {
|
3843 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
3844 | target[key] = source[key];
|
3845 | }
|
3846 | }
|
3847 | }
|
3848 | return target;
|
3849 | };
|
3850 | return _extends$2.apply(this, arguments);
|
3851 | }
|
3852 | function callProp(value, ...args) {
|
3853 | return is.fun(value) ? value(...args) : value;
|
3854 | }
|
3855 | const matchProp = (value, key) => value === true || !!(key && value && (is.fun(value) ? value(key) : toArray$3(value).includes(key)));
|
3856 | const resolveProp = (prop, key) => is.obj(prop) ? key && prop[key] : prop;
|
3857 | const getDefaultProp = (props, key) => props.default === true ? props[key] : props.default ? props.default[key] : void 0;
|
3858 | const noopTransform = (value) => value;
|
3859 | const getDefaultProps = (props, transform = noopTransform) => {
|
3860 | let keys = DEFAULT_PROPS;
|
3861 | if (props.default && props.default !== true) {
|
3862 | props = props.default;
|
3863 | keys = Object.keys(props);
|
3864 | }
|
3865 | const defaults2 = {};
|
3866 | for (const key of keys) {
|
3867 | const value = transform(props[key], key);
|
3868 | if (!is.und(value)) {
|
3869 | defaults2[key] = value;
|
3870 | }
|
3871 | }
|
3872 | return defaults2;
|
3873 | };
|
3874 | const DEFAULT_PROPS = ["config", "onProps", "onStart", "onChange", "onPause", "onResume", "onRest"];
|
3875 | const RESERVED_PROPS = {
|
3876 | config: 1,
|
3877 | from: 1,
|
3878 | to: 1,
|
3879 | ref: 1,
|
3880 | loop: 1,
|
3881 | reset: 1,
|
3882 | pause: 1,
|
3883 | cancel: 1,
|
3884 | reverse: 1,
|
3885 | immediate: 1,
|
3886 | default: 1,
|
3887 | delay: 1,
|
3888 | onProps: 1,
|
3889 | onStart: 1,
|
3890 | onChange: 1,
|
3891 | onPause: 1,
|
3892 | onResume: 1,
|
3893 | onRest: 1,
|
3894 | onResolve: 1,
|
3895 | items: 1,
|
3896 | trail: 1,
|
3897 | sort: 1,
|
3898 | expires: 1,
|
3899 | initial: 1,
|
3900 | enter: 1,
|
3901 | update: 1,
|
3902 | leave: 1,
|
3903 | children: 1,
|
3904 | onDestroyed: 1,
|
3905 | keys: 1,
|
3906 | callId: 1,
|
3907 | parentId: 1
|
3908 | };
|
3909 | function getForwardProps(props) {
|
3910 | const forward = {};
|
3911 | let count = 0;
|
3912 | eachProp(props, (value, prop) => {
|
3913 | if (!RESERVED_PROPS[prop]) {
|
3914 | forward[prop] = value;
|
3915 | count++;
|
3916 | }
|
3917 | });
|
3918 | if (count) {
|
3919 | return forward;
|
3920 | }
|
3921 | }
|
3922 | function inferTo(props) {
|
3923 | const to2 = getForwardProps(props);
|
3924 | if (to2) {
|
3925 | const out = {
|
3926 | to: to2
|
3927 | };
|
3928 | eachProp(props, (val, key) => key in to2 || (out[key] = val));
|
3929 | return out;
|
3930 | }
|
3931 | return _extends$2({}, props);
|
3932 | }
|
3933 | function computeGoal(value) {
|
3934 | value = getFluidValue(value);
|
3935 | return is.arr(value) ? value.map(computeGoal) : isAnimatedString(value) ? globals.createStringInterpolator({
|
3936 | range: [0, 1],
|
3937 | output: [value, value]
|
3938 | })(1) : value;
|
3939 | }
|
3940 | function hasProps(props) {
|
3941 | for (const _ in props)
|
3942 | return true;
|
3943 | return false;
|
3944 | }
|
3945 | function isAsyncTo(to2) {
|
3946 | return is.fun(to2) || is.arr(to2) && is.obj(to2[0]);
|
3947 | }
|
3948 | function detachRefs(ctrl, ref) {
|
3949 | var _ctrl$ref;
|
3950 | (_ctrl$ref = ctrl.ref) == null ? void 0 : _ctrl$ref.delete(ctrl);
|
3951 | ref == null ? void 0 : ref.delete(ctrl);
|
3952 | }
|
3953 | function replaceRef(ctrl, ref) {
|
3954 | if (ref && ctrl.ref !== ref) {
|
3955 | var _ctrl$ref2;
|
3956 | (_ctrl$ref2 = ctrl.ref) == null ? void 0 : _ctrl$ref2.delete(ctrl);
|
3957 | ref.add(ctrl);
|
3958 | ctrl.ref = ref;
|
3959 | }
|
3960 | }
|
3961 | const config$1 = {
|
3962 | default: {
|
3963 | tension: 170,
|
3964 | friction: 26
|
3965 | },
|
3966 | gentle: {
|
3967 | tension: 120,
|
3968 | friction: 14
|
3969 | },
|
3970 | wobbly: {
|
3971 | tension: 180,
|
3972 | friction: 12
|
3973 | },
|
3974 | stiff: {
|
3975 | tension: 210,
|
3976 | friction: 20
|
3977 | },
|
3978 | slow: {
|
3979 | tension: 280,
|
3980 | friction: 60
|
3981 | },
|
3982 | molasses: {
|
3983 | tension: 280,
|
3984 | friction: 120
|
3985 | }
|
3986 | };
|
3987 | const defaults = _extends$2({}, config$1.default, {
|
3988 | mass: 1,
|
3989 | damping: 1,
|
3990 | easing: easings.linear,
|
3991 | clamp: false
|
3992 | });
|
3993 | class AnimationConfig {
|
3994 | constructor() {
|
3995 | this.tension = void 0;
|
3996 | this.friction = void 0;
|
3997 | this.frequency = void 0;
|
3998 | this.damping = void 0;
|
3999 | this.mass = void 0;
|
4000 | this.velocity = 0;
|
4001 | this.restVelocity = void 0;
|
4002 | this.precision = void 0;
|
4003 | this.progress = void 0;
|
4004 | this.duration = void 0;
|
4005 | this.easing = void 0;
|
4006 | this.clamp = void 0;
|
4007 | this.bounce = void 0;
|
4008 | this.decay = void 0;
|
4009 | this.round = void 0;
|
4010 | Object.assign(this, defaults);
|
4011 | }
|
4012 | }
|
4013 | function mergeConfig(config2, newConfig, defaultConfig) {
|
4014 | if (defaultConfig) {
|
4015 | defaultConfig = _extends$2({}, defaultConfig);
|
4016 | sanitizeConfig(defaultConfig, newConfig);
|
4017 | newConfig = _extends$2({}, defaultConfig, newConfig);
|
4018 | }
|
4019 | sanitizeConfig(config2, newConfig);
|
4020 | Object.assign(config2, newConfig);
|
4021 | for (const key in defaults) {
|
4022 | if (config2[key] == null) {
|
4023 | config2[key] = defaults[key];
|
4024 | }
|
4025 | }
|
4026 | let {
|
4027 | mass,
|
4028 | frequency,
|
4029 | damping
|
4030 | } = config2;
|
4031 | if (!is.und(frequency)) {
|
4032 | if (frequency < 0.01)
|
4033 | frequency = 0.01;
|
4034 | if (damping < 0)
|
4035 | damping = 0;
|
4036 | config2.tension = Math.pow(2 * Math.PI / frequency, 2) * mass;
|
4037 | config2.friction = 4 * Math.PI * damping * mass / frequency;
|
4038 | }
|
4039 | return config2;
|
4040 | }
|
4041 | function sanitizeConfig(config2, props) {
|
4042 | if (!is.und(props.decay)) {
|
4043 | config2.duration = void 0;
|
4044 | } else {
|
4045 | const isTensionConfig = !is.und(props.tension) || !is.und(props.friction);
|
4046 | if (isTensionConfig || !is.und(props.frequency) || !is.und(props.damping) || !is.und(props.mass)) {
|
4047 | config2.duration = void 0;
|
4048 | config2.decay = void 0;
|
4049 | }
|
4050 | if (isTensionConfig) {
|
4051 | config2.frequency = void 0;
|
4052 | }
|
4053 | }
|
4054 | }
|
4055 | const emptyArray = [];
|
4056 | class Animation {
|
4057 | constructor() {
|
4058 | this.changed = false;
|
4059 | this.values = emptyArray;
|
4060 | this.toValues = null;
|
4061 | this.fromValues = emptyArray;
|
4062 | this.to = void 0;
|
4063 | this.from = void 0;
|
4064 | this.config = new AnimationConfig();
|
4065 | this.immediate = false;
|
4066 | }
|
4067 | }
|
4068 | function scheduleProps(callId, {
|
4069 | key,
|
4070 | props,
|
4071 | defaultProps: defaultProps2,
|
4072 | state,
|
4073 | actions
|
4074 | }) {
|
4075 | return new Promise((resolve, reject) => {
|
4076 | var _props$cancel;
|
4077 | let delay;
|
4078 | let timeout;
|
4079 | let cancel = matchProp((_props$cancel = props.cancel) != null ? _props$cancel : defaultProps2 == null ? void 0 : defaultProps2.cancel, key);
|
4080 | if (cancel) {
|
4081 | onStart();
|
4082 | } else {
|
4083 | if (!is.und(props.pause)) {
|
4084 | state.paused = matchProp(props.pause, key);
|
4085 | }
|
4086 | let pause = defaultProps2 == null ? void 0 : defaultProps2.pause;
|
4087 | if (pause !== true) {
|
4088 | pause = state.paused || matchProp(pause, key);
|
4089 | }
|
4090 | delay = callProp(props.delay || 0, key);
|
4091 | if (pause) {
|
4092 | state.resumeQueue.add(onResume);
|
4093 | actions.pause();
|
4094 | } else {
|
4095 | actions.resume();
|
4096 | onResume();
|
4097 | }
|
4098 | }
|
4099 | function onPause() {
|
4100 | state.resumeQueue.add(onResume);
|
4101 | state.timeouts.delete(timeout);
|
4102 | timeout.cancel();
|
4103 | delay = timeout.time - raf.now();
|
4104 | }
|
4105 | function onResume() {
|
4106 | if (delay > 0 && !globals.skipAnimation) {
|
4107 | state.delayed = true;
|
4108 | timeout = raf.setTimeout(onStart, delay);
|
4109 | state.pauseQueue.add(onPause);
|
4110 | state.timeouts.add(timeout);
|
4111 | } else {
|
4112 | onStart();
|
4113 | }
|
4114 | }
|
4115 | function onStart() {
|
4116 | if (state.delayed) {
|
4117 | state.delayed = false;
|
4118 | }
|
4119 | state.pauseQueue.delete(onPause);
|
4120 | state.timeouts.delete(timeout);
|
4121 | if (callId <= (state.cancelId || 0)) {
|
4122 | cancel = true;
|
4123 | }
|
4124 | try {
|
4125 | actions.start(_extends$2({}, props, {
|
4126 | callId,
|
4127 | cancel
|
4128 | }), resolve);
|
4129 | } catch (err) {
|
4130 | reject(err);
|
4131 | }
|
4132 | }
|
4133 | });
|
4134 | }
|
4135 | const getCombinedResult = (target, results) => results.length == 1 ? results[0] : results.some((result) => result.cancelled) ? getCancelledResult(target.get()) : results.every((result) => result.noop) ? getNoopResult(target.get()) : getFinishedResult(target.get(), results.every((result) => result.finished));
|
4136 | const getNoopResult = (value) => ({
|
4137 | value,
|
4138 | noop: true,
|
4139 | finished: true,
|
4140 | cancelled: false
|
4141 | });
|
4142 | const getFinishedResult = (value, finished, cancelled = false) => ({
|
4143 | value,
|
4144 | finished,
|
4145 | cancelled
|
4146 | });
|
4147 | const getCancelledResult = (value) => ({
|
4148 | value,
|
4149 | cancelled: true,
|
4150 | finished: false
|
4151 | });
|
4152 | function runAsync(to2, props, state, target) {
|
4153 | const {
|
4154 | callId,
|
4155 | parentId,
|
4156 | onRest
|
4157 | } = props;
|
4158 | const {
|
4159 | asyncTo: prevTo,
|
4160 | promise: prevPromise
|
4161 | } = state;
|
4162 | if (!parentId && to2 === prevTo && !props.reset) {
|
4163 | return prevPromise;
|
4164 | }
|
4165 | return state.promise = (async () => {
|
4166 | state.asyncId = callId;
|
4167 | state.asyncTo = to2;
|
4168 | const defaultProps2 = getDefaultProps(props, (value, key) => key === "onRest" ? void 0 : value);
|
4169 | let preventBail;
|
4170 | let bail;
|
4171 | const bailPromise = new Promise((resolve, reject) => (preventBail = resolve, bail = reject));
|
4172 | const bailIfEnded = (bailSignal) => {
|
4173 | const bailResult = callId <= (state.cancelId || 0) && getCancelledResult(target) || callId !== state.asyncId && getFinishedResult(target, false);
|
4174 | if (bailResult) {
|
4175 | bailSignal.result = bailResult;
|
4176 | bail(bailSignal);
|
4177 | throw bailSignal;
|
4178 | }
|
4179 | };
|
4180 | const animate = (arg1, arg2) => {
|
4181 | const bailSignal = new BailSignal();
|
4182 | const skipAnimationSignal = new SkipAnimationSignal();
|
4183 | return (async () => {
|
4184 | if (globals.skipAnimation) {
|
4185 | stopAsync(state);
|
4186 | skipAnimationSignal.result = getFinishedResult(target, false);
|
4187 | bail(skipAnimationSignal);
|
4188 | throw skipAnimationSignal;
|
4189 | }
|
4190 | bailIfEnded(bailSignal);
|
4191 | const props2 = is.obj(arg1) ? _extends$2({}, arg1) : _extends$2({}, arg2, {
|
4192 | to: arg1
|
4193 | });
|
4194 | props2.parentId = callId;
|
4195 | eachProp(defaultProps2, (value, key) => {
|
4196 | if (is.und(props2[key])) {
|
4197 | props2[key] = value;
|
4198 | }
|
4199 | });
|
4200 | const result2 = await target.start(props2);
|
4201 | bailIfEnded(bailSignal);
|
4202 | if (state.paused) {
|
4203 | await new Promise((resume) => {
|
4204 | state.resumeQueue.add(resume);
|
4205 | });
|
4206 | }
|
4207 | return result2;
|
4208 | })();
|
4209 | };
|
4210 | let result;
|
4211 | if (globals.skipAnimation) {
|
4212 | stopAsync(state);
|
4213 | return getFinishedResult(target, false);
|
4214 | }
|
4215 | try {
|
4216 | let animating;
|
4217 | if (is.arr(to2)) {
|
4218 | animating = (async (queue) => {
|
4219 | for (const props2 of queue) {
|
4220 | await animate(props2);
|
4221 | }
|
4222 | })(to2);
|
4223 | } else {
|
4224 | animating = Promise.resolve(to2(animate, target.stop.bind(target)));
|
4225 | }
|
4226 | await Promise.all([animating.then(preventBail), bailPromise]);
|
4227 | result = getFinishedResult(target.get(), true, false);
|
4228 | } catch (err) {
|
4229 | if (err instanceof BailSignal) {
|
4230 | result = err.result;
|
4231 | } else if (err instanceof SkipAnimationSignal) {
|
4232 | result = err.result;
|
4233 | } else {
|
4234 | throw err;
|
4235 | }
|
4236 | } finally {
|
4237 | if (callId == state.asyncId) {
|
4238 | state.asyncId = parentId;
|
4239 | state.asyncTo = parentId ? prevTo : void 0;
|
4240 | state.promise = parentId ? prevPromise : void 0;
|
4241 | }
|
4242 | }
|
4243 | if (is.fun(onRest)) {
|
4244 | raf.batchedUpdates(() => {
|
4245 | onRest(result, target, target.item);
|
4246 | });
|
4247 | }
|
4248 | return result;
|
4249 | })();
|
4250 | }
|
4251 | function stopAsync(state, cancelId) {
|
4252 | flush(state.timeouts, (t) => t.cancel());
|
4253 | state.pauseQueue.clear();
|
4254 | state.resumeQueue.clear();
|
4255 | state.asyncId = state.asyncTo = state.promise = void 0;
|
4256 | if (cancelId)
|
4257 | state.cancelId = cancelId;
|
4258 | }
|
4259 | class BailSignal extends Error {
|
4260 | constructor() {
|
4261 | super("An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise.");
|
4262 | this.result = void 0;
|
4263 | }
|
4264 | }
|
4265 | class SkipAnimationSignal extends Error {
|
4266 | constructor() {
|
4267 | super("SkipAnimationSignal");
|
4268 | this.result = void 0;
|
4269 | }
|
4270 | }
|
4271 | const isFrameValue = (value) => value instanceof FrameValue;
|
4272 | let nextId$1 = 1;
|
4273 | class FrameValue extends FluidValue {
|
4274 | constructor(...args) {
|
4275 | super(...args);
|
4276 | this.id = nextId$1++;
|
4277 | this.key = void 0;
|
4278 | this._priority = 0;
|
4279 | }
|
4280 | get priority() {
|
4281 | return this._priority;
|
4282 | }
|
4283 | set priority(priority2) {
|
4284 | if (this._priority != priority2) {
|
4285 | this._priority = priority2;
|
4286 | this._onPriorityChange(priority2);
|
4287 | }
|
4288 | }
|
4289 | get() {
|
4290 | const node = getAnimated(this);
|
4291 | return node && node.getValue();
|
4292 | }
|
4293 | to(...args) {
|
4294 | return globals.to(this, args);
|
4295 | }
|
4296 | interpolate(...args) {
|
4297 | deprecateInterpolate();
|
4298 | return globals.to(this, args);
|
4299 | }
|
4300 | toJSON() {
|
4301 | return this.get();
|
4302 | }
|
4303 | observerAdded(count) {
|
4304 | if (count == 1)
|
4305 | this._attach();
|
4306 | }
|
4307 | observerRemoved(count) {
|
4308 | if (count == 0)
|
4309 | this._detach();
|
4310 | }
|
4311 | _attach() {
|
4312 | }
|
4313 | _detach() {
|
4314 | }
|
4315 | _onChange(value, idle = false) {
|
4316 | callFluidObservers(this, {
|
4317 | type: "change",
|
4318 | parent: this,
|
4319 | value,
|
4320 | idle
|
4321 | });
|
4322 | }
|
4323 | _onPriorityChange(priority2) {
|
4324 | if (!this.idle) {
|
4325 | frameLoop.sort(this);
|
4326 | }
|
4327 | callFluidObservers(this, {
|
4328 | type: "priority",
|
4329 | parent: this,
|
4330 | priority: priority2
|
4331 | });
|
4332 | }
|
4333 | }
|
4334 | const $P = Symbol.for("SpringPhase");
|
4335 | const HAS_ANIMATED = 1;
|
4336 | const IS_ANIMATING = 2;
|
4337 | const IS_PAUSED = 4;
|
4338 | const hasAnimated = (target) => (target[$P] & HAS_ANIMATED) > 0;
|
4339 | const isAnimating = (target) => (target[$P] & IS_ANIMATING) > 0;
|
4340 | const isPaused = (target) => (target[$P] & IS_PAUSED) > 0;
|
4341 | const setActiveBit = (target, active) => active ? target[$P] |= IS_ANIMATING | HAS_ANIMATED : target[$P] &= ~IS_ANIMATING;
|
4342 | const setPausedBit = (target, paused) => paused ? target[$P] |= IS_PAUSED : target[$P] &= ~IS_PAUSED;
|
4343 | class SpringValue extends FrameValue {
|
4344 | constructor(arg1, arg2) {
|
4345 | super();
|
4346 | this.key = void 0;
|
4347 | this.animation = new Animation();
|
4348 | this.queue = void 0;
|
4349 | this.defaultProps = {};
|
4350 | this._state = {
|
4351 | paused: false,
|
4352 | delayed: false,
|
4353 | pauseQueue: new Set(),
|
4354 | resumeQueue: new Set(),
|
4355 | timeouts: new Set()
|
4356 | };
|
4357 | this._pendingCalls = new Set();
|
4358 | this._lastCallId = 0;
|
4359 | this._lastToId = 0;
|
4360 | this._memoizedDuration = 0;
|
4361 | if (!is.und(arg1) || !is.und(arg2)) {
|
4362 | const props = is.obj(arg1) ? _extends$2({}, arg1) : _extends$2({}, arg2, {
|
4363 | from: arg1
|
4364 | });
|
4365 | if (is.und(props.default)) {
|
4366 | props.default = true;
|
4367 | }
|
4368 | this.start(props);
|
4369 | }
|
4370 | }
|
4371 | get idle() {
|
4372 | return !(isAnimating(this) || this._state.asyncTo) || isPaused(this);
|
4373 | }
|
4374 | get goal() {
|
4375 | return getFluidValue(this.animation.to);
|
4376 | }
|
4377 | get velocity() {
|
4378 | const node = getAnimated(this);
|
4379 | return node instanceof AnimatedValue ? node.lastVelocity || 0 : node.getPayload().map((node2) => node2.lastVelocity || 0);
|
4380 | }
|
4381 | get hasAnimated() {
|
4382 | return hasAnimated(this);
|
4383 | }
|
4384 | get isAnimating() {
|
4385 | return isAnimating(this);
|
4386 | }
|
4387 | get isPaused() {
|
4388 | return isPaused(this);
|
4389 | }
|
4390 | get isDelayed() {
|
4391 | return this._state.delayed;
|
4392 | }
|
4393 | advance(dt) {
|
4394 | let idle = true;
|
4395 | let changed = false;
|
4396 | const anim = this.animation;
|
4397 | let {
|
4398 | config: config2,
|
4399 | toValues
|
4400 | } = anim;
|
4401 | const payload = getPayload(anim.to);
|
4402 | if (!payload && hasFluidValue(anim.to)) {
|
4403 | toValues = toArray$3(getFluidValue(anim.to));
|
4404 | }
|
4405 | anim.values.forEach((node2, i2) => {
|
4406 | if (node2.done)
|
4407 | return;
|
4408 | const to2 = node2.constructor == AnimatedString ? 1 : payload ? payload[i2].lastPosition : toValues[i2];
|
4409 | let finished = anim.immediate;
|
4410 | let position = to2;
|
4411 | if (!finished) {
|
4412 | position = node2.lastPosition;
|
4413 | if (config2.tension <= 0) {
|
4414 | node2.done = true;
|
4415 | return;
|
4416 | }
|
4417 | let elapsed = node2.elapsedTime += dt;
|
4418 | const from = anim.fromValues[i2];
|
4419 | const v0 = node2.v0 != null ? node2.v0 : node2.v0 = is.arr(config2.velocity) ? config2.velocity[i2] : config2.velocity;
|
4420 | let velocity;
|
4421 | const precision = config2.precision || (from == to2 ? 5e-3 : Math.min(1, Math.abs(to2 - from) * 1e-3));
|
4422 | if (!is.und(config2.duration)) {
|
4423 | let p = 1;
|
4424 | if (config2.duration > 0) {
|
4425 | if (this._memoizedDuration !== config2.duration) {
|
4426 | this._memoizedDuration = config2.duration;
|
4427 | if (node2.durationProgress > 0) {
|
4428 | node2.elapsedTime = config2.duration * node2.durationProgress;
|
4429 | elapsed = node2.elapsedTime += dt;
|
4430 | }
|
4431 | }
|
4432 | p = (config2.progress || 0) + elapsed / this._memoizedDuration;
|
4433 | p = p > 1 ? 1 : p < 0 ? 0 : p;
|
4434 | node2.durationProgress = p;
|
4435 | }
|
4436 | position = from + config2.easing(p) * (to2 - from);
|
4437 | velocity = (position - node2.lastPosition) / dt;
|
4438 | finished = p == 1;
|
4439 | } else if (config2.decay) {
|
4440 | const decay = config2.decay === true ? 0.998 : config2.decay;
|
4441 | const e2 = Math.exp(-(1 - decay) * elapsed);
|
4442 | position = from + v0 / (1 - decay) * (1 - e2);
|
4443 | finished = Math.abs(node2.lastPosition - position) <= precision;
|
4444 | velocity = v0 * e2;
|
4445 | } else {
|
4446 | velocity = node2.lastVelocity == null ? v0 : node2.lastVelocity;
|
4447 | const restVelocity = config2.restVelocity || precision / 10;
|
4448 | const bounceFactor = config2.clamp ? 0 : config2.bounce;
|
4449 | const canBounce = !is.und(bounceFactor);
|
4450 | const isGrowing = from == to2 ? node2.v0 > 0 : from < to2;
|
4451 | let isMoving;
|
4452 | let isBouncing = false;
|
4453 | const step = 1;
|
4454 | const numSteps = Math.ceil(dt / step);
|
4455 | for (let n2 = 0; n2 < numSteps; ++n2) {
|
4456 | isMoving = Math.abs(velocity) > restVelocity;
|
4457 | if (!isMoving) {
|
4458 | finished = Math.abs(to2 - position) <= precision;
|
4459 | if (finished) {
|
4460 | break;
|
4461 | }
|
4462 | }
|
4463 | if (canBounce) {
|
4464 | isBouncing = position == to2 || position > to2 == isGrowing;
|
4465 | if (isBouncing) {
|
4466 | velocity = -velocity * bounceFactor;
|
4467 | position = to2;
|
4468 | }
|
4469 | }
|
4470 | const springForce = -config2.tension * 1e-6 * (position - to2);
|
4471 | const dampingForce = -config2.friction * 1e-3 * velocity;
|
4472 | const acceleration = (springForce + dampingForce) / config2.mass;
|
4473 | velocity = velocity + acceleration * step;
|
4474 | position = position + velocity * step;
|
4475 | }
|
4476 | }
|
4477 | node2.lastVelocity = velocity;
|
4478 | if (Number.isNaN(position)) {
|
4479 | console.warn(`Got NaN while animating:`, this);
|
4480 | finished = true;
|
4481 | }
|
4482 | }
|
4483 | if (payload && !payload[i2].done) {
|
4484 | finished = false;
|
4485 | }
|
4486 | if (finished) {
|
4487 | node2.done = true;
|
4488 | } else {
|
4489 | idle = false;
|
4490 | }
|
4491 | if (node2.setValue(position, config2.round)) {
|
4492 | changed = true;
|
4493 | }
|
4494 | });
|
4495 | const node = getAnimated(this);
|
4496 | const currVal = node.getValue();
|
4497 | if (idle) {
|
4498 | const finalVal = getFluidValue(anim.to);
|
4499 | if ((currVal !== finalVal || changed) && !config2.decay) {
|
4500 | node.setValue(finalVal);
|
4501 | this._onChange(finalVal);
|
4502 | } else if (changed && config2.decay) {
|
4503 | this._onChange(currVal);
|
4504 | }
|
4505 | this._stop();
|
4506 | } else if (changed) {
|
4507 | this._onChange(currVal);
|
4508 | }
|
4509 | }
|
4510 | set(value) {
|
4511 | raf.batchedUpdates(() => {
|
4512 | this._stop();
|
4513 | this._focus(value);
|
4514 | this._set(value);
|
4515 | });
|
4516 | return this;
|
4517 | }
|
4518 | pause() {
|
4519 | this._update({
|
4520 | pause: true
|
4521 | });
|
4522 | }
|
4523 | resume() {
|
4524 | this._update({
|
4525 | pause: false
|
4526 | });
|
4527 | }
|
4528 | finish() {
|
4529 | if (isAnimating(this)) {
|
4530 | const {
|
4531 | to: to2,
|
4532 | config: config2
|
4533 | } = this.animation;
|
4534 | raf.batchedUpdates(() => {
|
4535 | this._onStart();
|
4536 | if (!config2.decay) {
|
4537 | this._set(to2, false);
|
4538 | }
|
4539 | this._stop();
|
4540 | });
|
4541 | }
|
4542 | return this;
|
4543 | }
|
4544 | update(props) {
|
4545 | const queue = this.queue || (this.queue = []);
|
4546 | queue.push(props);
|
4547 | return this;
|
4548 | }
|
4549 | start(to2, arg2) {
|
4550 | let queue;
|
4551 | if (!is.und(to2)) {
|
4552 | queue = [is.obj(to2) ? to2 : _extends$2({}, arg2, {
|
4553 | to: to2
|
4554 | })];
|
4555 | } else {
|
4556 | queue = this.queue || [];
|
4557 | this.queue = [];
|
4558 | }
|
4559 | return Promise.all(queue.map((props) => {
|
4560 | const up = this._update(props);
|
4561 | return up;
|
4562 | })).then((results) => getCombinedResult(this, results));
|
4563 | }
|
4564 | stop(cancel) {
|
4565 | const {
|
4566 | to: to2
|
4567 | } = this.animation;
|
4568 | this._focus(this.get());
|
4569 | stopAsync(this._state, cancel && this._lastCallId);
|
4570 | raf.batchedUpdates(() => this._stop(to2, cancel));
|
4571 | return this;
|
4572 | }
|
4573 | reset() {
|
4574 | this._update({
|
4575 | reset: true
|
4576 | });
|
4577 | }
|
4578 | eventObserved(event) {
|
4579 | if (event.type == "change") {
|
4580 | this._start();
|
4581 | } else if (event.type == "priority") {
|
4582 | this.priority = event.priority + 1;
|
4583 | }
|
4584 | }
|
4585 | _prepareNode(props) {
|
4586 | const key = this.key || "";
|
4587 | let {
|
4588 | to: to2,
|
4589 | from
|
4590 | } = props;
|
4591 | to2 = is.obj(to2) ? to2[key] : to2;
|
4592 | if (to2 == null || isAsyncTo(to2)) {
|
4593 | to2 = void 0;
|
4594 | }
|
4595 | from = is.obj(from) ? from[key] : from;
|
4596 | if (from == null) {
|
4597 | from = void 0;
|
4598 | }
|
4599 | const range2 = {
|
4600 | to: to2,
|
4601 | from
|
4602 | };
|
4603 | if (!hasAnimated(this)) {
|
4604 | if (props.reverse)
|
4605 | [to2, from] = [from, to2];
|
4606 | from = getFluidValue(from);
|
4607 | if (!is.und(from)) {
|
4608 | this._set(from);
|
4609 | } else if (!getAnimated(this)) {
|
4610 | this._set(to2);
|
4611 | }
|
4612 | }
|
4613 | return range2;
|
4614 | }
|
4615 | _update(_ref, isLoop) {
|
4616 | let props = _extends$2({}, _ref);
|
4617 | const {
|
4618 | key,
|
4619 | defaultProps: defaultProps2
|
4620 | } = this;
|
4621 | if (props.default)
|
4622 | Object.assign(defaultProps2, getDefaultProps(props, (value, prop) => /^on/.test(prop) ? resolveProp(value, key) : value));
|
4623 | mergeActiveFn(this, props, "onProps");
|
4624 | sendEvent(this, "onProps", props, this);
|
4625 | const range2 = this._prepareNode(props);
|
4626 | if (Object.isFrozen(this)) {
|
4627 | throw Error("Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?");
|
4628 | }
|
4629 | const state = this._state;
|
4630 | return scheduleProps(++this._lastCallId, {
|
4631 | key,
|
4632 | props,
|
4633 | defaultProps: defaultProps2,
|
4634 | state,
|
4635 | actions: {
|
4636 | pause: () => {
|
4637 | if (!isPaused(this)) {
|
4638 | setPausedBit(this, true);
|
4639 | flushCalls(state.pauseQueue);
|
4640 | sendEvent(this, "onPause", getFinishedResult(this, checkFinished(this, this.animation.to)), this);
|
4641 | }
|
4642 | },
|
4643 | resume: () => {
|
4644 | if (isPaused(this)) {
|
4645 | setPausedBit(this, false);
|
4646 | if (isAnimating(this)) {
|
4647 | this._resume();
|
4648 | }
|
4649 | flushCalls(state.resumeQueue);
|
4650 | sendEvent(this, "onResume", getFinishedResult(this, checkFinished(this, this.animation.to)), this);
|
4651 | }
|
4652 | },
|
4653 | start: this._merge.bind(this, range2)
|
4654 | }
|
4655 | }).then((result) => {
|
4656 | if (props.loop && result.finished && !(isLoop && result.noop)) {
|
4657 | const nextProps = createLoopUpdate(props);
|
4658 | if (nextProps) {
|
4659 | return this._update(nextProps, true);
|
4660 | }
|
4661 | }
|
4662 | return result;
|
4663 | });
|
4664 | }
|
4665 | _merge(range2, props, resolve) {
|
4666 | if (props.cancel) {
|
4667 | this.stop(true);
|
4668 | return resolve(getCancelledResult(this));
|
4669 | }
|
4670 | const hasToProp = !is.und(range2.to);
|
4671 | const hasFromProp = !is.und(range2.from);
|
4672 | if (hasToProp || hasFromProp) {
|
4673 | if (props.callId > this._lastToId) {
|
4674 | this._lastToId = props.callId;
|
4675 | } else {
|
4676 | return resolve(getCancelledResult(this));
|
4677 | }
|
4678 | }
|
4679 | const {
|
4680 | key,
|
4681 | defaultProps: defaultProps2,
|
4682 | animation: anim
|
4683 | } = this;
|
4684 | const {
|
4685 | to: prevTo,
|
4686 | from: prevFrom
|
4687 | } = anim;
|
4688 | let {
|
4689 | to: to2 = prevTo,
|
4690 | from = prevFrom
|
4691 | } = range2;
|
4692 | if (hasFromProp && !hasToProp && (!props.default || is.und(to2))) {
|
4693 | to2 = from;
|
4694 | }
|
4695 | if (props.reverse)
|
4696 | [to2, from] = [from, to2];
|
4697 | const hasFromChanged = !isEqual$1(from, prevFrom);
|
4698 | if (hasFromChanged) {
|
4699 | anim.from = from;
|
4700 | }
|
4701 | from = getFluidValue(from);
|
4702 | const hasToChanged = !isEqual$1(to2, prevTo);
|
4703 | if (hasToChanged) {
|
4704 | this._focus(to2);
|
4705 | }
|
4706 | const hasAsyncTo = isAsyncTo(props.to);
|
4707 | const {
|
4708 | config: config2
|
4709 | } = anim;
|
4710 | const {
|
4711 | decay,
|
4712 | velocity
|
4713 | } = config2;
|
4714 | if (hasToProp || hasFromProp) {
|
4715 | config2.velocity = 0;
|
4716 | }
|
4717 | if (props.config && !hasAsyncTo) {
|
4718 | mergeConfig(config2, callProp(props.config, key), props.config !== defaultProps2.config ? callProp(defaultProps2.config, key) : void 0);
|
4719 | }
|
4720 | let node = getAnimated(this);
|
4721 | if (!node || is.und(to2)) {
|
4722 | return resolve(getFinishedResult(this, true));
|
4723 | }
|
4724 | const reset = is.und(props.reset) ? hasFromProp && !props.default : !is.und(from) && matchProp(props.reset, key);
|
4725 | const value = reset ? from : this.get();
|
4726 | const goal = computeGoal(to2);
|
4727 | const isAnimatable = is.num(goal) || is.arr(goal) || isAnimatedString(goal);
|
4728 | const immediate = !hasAsyncTo && (!isAnimatable || matchProp(defaultProps2.immediate || props.immediate, key));
|
4729 | if (hasToChanged) {
|
4730 | const nodeType = getAnimatedType(to2);
|
4731 | if (nodeType !== node.constructor) {
|
4732 | if (immediate) {
|
4733 | node = this._set(goal);
|
4734 | } else
|
4735 | throw Error(`Cannot animate between ${node.constructor.name} and ${nodeType.name}, as the "to" prop suggests`);
|
4736 | }
|
4737 | }
|
4738 | const goalType = node.constructor;
|
4739 | let started = hasFluidValue(to2);
|
4740 | let finished = false;
|
4741 | if (!started) {
|
4742 | const hasValueChanged = reset || !hasAnimated(this) && hasFromChanged;
|
4743 | if (hasToChanged || hasValueChanged) {
|
4744 | finished = isEqual$1(computeGoal(value), goal);
|
4745 | started = !finished;
|
4746 | }
|
4747 | if (!isEqual$1(anim.immediate, immediate) && !immediate || !isEqual$1(config2.decay, decay) || !isEqual$1(config2.velocity, velocity)) {
|
4748 | started = true;
|
4749 | }
|
4750 | }
|
4751 | if (finished && isAnimating(this)) {
|
4752 | if (anim.changed && !reset) {
|
4753 | started = true;
|
4754 | } else if (!started) {
|
4755 | this._stop(prevTo);
|
4756 | }
|
4757 | }
|
4758 | if (!hasAsyncTo) {
|
4759 | if (started || hasFluidValue(prevTo)) {
|
4760 | anim.values = node.getPayload();
|
4761 | anim.toValues = hasFluidValue(to2) ? null : goalType == AnimatedString ? [1] : toArray$3(goal);
|
4762 | }
|
4763 | if (anim.immediate != immediate) {
|
4764 | anim.immediate = immediate;
|
4765 | if (!immediate && !reset) {
|
4766 | this._set(prevTo);
|
4767 | }
|
4768 | }
|
4769 | if (started) {
|
4770 | const {
|
4771 | onRest
|
4772 | } = anim;
|
4773 | each(ACTIVE_EVENTS, (type) => mergeActiveFn(this, props, type));
|
4774 | const result = getFinishedResult(this, checkFinished(this, prevTo));
|
4775 | flushCalls(this._pendingCalls, result);
|
4776 | this._pendingCalls.add(resolve);
|
4777 | if (anim.changed)
|
4778 | raf.batchedUpdates(() => {
|
4779 | anim.changed = !reset;
|
4780 | onRest == null ? void 0 : onRest(result, this);
|
4781 | if (reset) {
|
4782 | callProp(defaultProps2.onRest, result);
|
4783 | } else {
|
4784 | anim.onStart == null ? void 0 : anim.onStart(result, this);
|
4785 | }
|
4786 | });
|
4787 | }
|
4788 | }
|
4789 | if (reset) {
|
4790 | this._set(value);
|
4791 | }
|
4792 | if (hasAsyncTo) {
|
4793 | resolve(runAsync(props.to, props, this._state, this));
|
4794 | } else if (started) {
|
4795 | this._start();
|
4796 | } else if (isAnimating(this) && !hasToChanged) {
|
4797 | this._pendingCalls.add(resolve);
|
4798 | } else {
|
4799 | resolve(getNoopResult(value));
|
4800 | }
|
4801 | }
|
4802 | _focus(value) {
|
4803 | const anim = this.animation;
|
4804 | if (value !== anim.to) {
|
4805 | if (getFluidObservers(this)) {
|
4806 | this._detach();
|
4807 | }
|
4808 | anim.to = value;
|
4809 | if (getFluidObservers(this)) {
|
4810 | this._attach();
|
4811 | }
|
4812 | }
|
4813 | }
|
4814 | _attach() {
|
4815 | let priority2 = 0;
|
4816 | const {
|
4817 | to: to2
|
4818 | } = this.animation;
|
4819 | if (hasFluidValue(to2)) {
|
4820 | addFluidObserver(to2, this);
|
4821 | if (isFrameValue(to2)) {
|
4822 | priority2 = to2.priority + 1;
|
4823 | }
|
4824 | }
|
4825 | this.priority = priority2;
|
4826 | }
|
4827 | _detach() {
|
4828 | const {
|
4829 | to: to2
|
4830 | } = this.animation;
|
4831 | if (hasFluidValue(to2)) {
|
4832 | removeFluidObserver(to2, this);
|
4833 | }
|
4834 | }
|
4835 | _set(arg, idle = true) {
|
4836 | const value = getFluidValue(arg);
|
4837 | if (!is.und(value)) {
|
4838 | const oldNode = getAnimated(this);
|
4839 | if (!oldNode || !isEqual$1(value, oldNode.getValue())) {
|
4840 | const nodeType = getAnimatedType(value);
|
4841 | if (!oldNode || oldNode.constructor != nodeType) {
|
4842 | setAnimated(this, nodeType.create(value));
|
4843 | } else {
|
4844 | oldNode.setValue(value);
|
4845 | }
|
4846 | if (oldNode) {
|
4847 | raf.batchedUpdates(() => {
|
4848 | this._onChange(value, idle);
|
4849 | });
|
4850 | }
|
4851 | }
|
4852 | }
|
4853 | return getAnimated(this);
|
4854 | }
|
4855 | _onStart() {
|
4856 | const anim = this.animation;
|
4857 | if (!anim.changed) {
|
4858 | anim.changed = true;
|
4859 | sendEvent(this, "onStart", getFinishedResult(this, checkFinished(this, anim.to)), this);
|
4860 | }
|
4861 | }
|
4862 | _onChange(value, idle) {
|
4863 | if (!idle) {
|
4864 | this._onStart();
|
4865 | callProp(this.animation.onChange, value, this);
|
4866 | }
|
4867 | callProp(this.defaultProps.onChange, value, this);
|
4868 | super._onChange(value, idle);
|
4869 | }
|
4870 | _start() {
|
4871 | const anim = this.animation;
|
4872 | getAnimated(this).reset(getFluidValue(anim.to));
|
4873 | if (!anim.immediate) {
|
4874 | anim.fromValues = anim.values.map((node) => node.lastPosition);
|
4875 | }
|
4876 | if (!isAnimating(this)) {
|
4877 | setActiveBit(this, true);
|
4878 | if (!isPaused(this)) {
|
4879 | this._resume();
|
4880 | }
|
4881 | }
|
4882 | }
|
4883 | _resume() {
|
4884 | if (globals.skipAnimation) {
|
4885 | this.finish();
|
4886 | } else {
|
4887 | frameLoop.start(this);
|
4888 | }
|
4889 | }
|
4890 | _stop(goal, cancel) {
|
4891 | if (isAnimating(this)) {
|
4892 | setActiveBit(this, false);
|
4893 | const anim = this.animation;
|
4894 | each(anim.values, (node) => {
|
4895 | node.done = true;
|
4896 | });
|
4897 | if (anim.toValues) {
|
4898 | anim.onChange = anim.onPause = anim.onResume = void 0;
|
4899 | }
|
4900 | callFluidObservers(this, {
|
4901 | type: "idle",
|
4902 | parent: this
|
4903 | });
|
4904 | const result = cancel ? getCancelledResult(this.get()) : getFinishedResult(this.get(), checkFinished(this, goal != null ? goal : anim.to));
|
4905 | flushCalls(this._pendingCalls, result);
|
4906 | if (anim.changed) {
|
4907 | anim.changed = false;
|
4908 | sendEvent(this, "onRest", result, this);
|
4909 | }
|
4910 | }
|
4911 | }
|
4912 | }
|
4913 | function checkFinished(target, to2) {
|
4914 | const goal = computeGoal(to2);
|
4915 | const value = computeGoal(target.get());
|
4916 | return isEqual$1(value, goal);
|
4917 | }
|
4918 | function createLoopUpdate(props, loop2 = props.loop, to2 = props.to) {
|
4919 | let loopRet = callProp(loop2);
|
4920 | if (loopRet) {
|
4921 | const overrides = loopRet !== true && inferTo(loopRet);
|
4922 | const reverse = (overrides || props).reverse;
|
4923 | const reset = !overrides || overrides.reset;
|
4924 | return createUpdate(_extends$2({}, props, {
|
4925 | loop: loop2,
|
4926 | default: false,
|
4927 | pause: void 0,
|
4928 | to: !reverse || isAsyncTo(to2) ? to2 : void 0,
|
4929 | from: reset ? props.from : void 0,
|
4930 | reset
|
4931 | }, overrides));
|
4932 | }
|
4933 | }
|
4934 | function createUpdate(props) {
|
4935 | const {
|
4936 | to: to2,
|
4937 | from
|
4938 | } = props = inferTo(props);
|
4939 | const keys = new Set();
|
4940 | if (is.obj(to2))
|
4941 | findDefined(to2, keys);
|
4942 | if (is.obj(from))
|
4943 | findDefined(from, keys);
|
4944 | props.keys = keys.size ? Array.from(keys) : null;
|
4945 | return props;
|
4946 | }
|
4947 | function declareUpdate(props) {
|
4948 | const update2 = createUpdate(props);
|
4949 | if (is.und(update2.default)) {
|
4950 | update2.default = getDefaultProps(update2);
|
4951 | }
|
4952 | return update2;
|
4953 | }
|
4954 | function findDefined(values, keys) {
|
4955 | eachProp(values, (value, key) => value != null && keys.add(key));
|
4956 | }
|
4957 | const ACTIVE_EVENTS = ["onStart", "onRest", "onChange", "onPause", "onResume"];
|
4958 | function mergeActiveFn(target, props, type) {
|
4959 | target.animation[type] = props[type] !== getDefaultProp(props, type) ? resolveProp(props[type], target.key) : void 0;
|
4960 | }
|
4961 | function sendEvent(target, type, ...args) {
|
4962 | var _target$animation$typ, _target$animation, _target$defaultProps$, _target$defaultProps;
|
4963 | (_target$animation$typ = (_target$animation = target.animation)[type]) == null ? void 0 : _target$animation$typ.call(_target$animation, ...args);
|
4964 | (_target$defaultProps$ = (_target$defaultProps = target.defaultProps)[type]) == null ? void 0 : _target$defaultProps$.call(_target$defaultProps, ...args);
|
4965 | }
|
4966 | const BATCHED_EVENTS = ["onStart", "onChange", "onRest"];
|
4967 | let nextId = 1;
|
4968 | let Controller$1 = class Controller {
|
4969 | constructor(props, flush2) {
|
4970 | this.id = nextId++;
|
4971 | this.springs = {};
|
4972 | this.queue = [];
|
4973 | this.ref = void 0;
|
4974 | this._flush = void 0;
|
4975 | this._initialProps = void 0;
|
4976 | this._lastAsyncId = 0;
|
4977 | this._active = new Set();
|
4978 | this._changed = new Set();
|
4979 | this._started = false;
|
4980 | this._item = void 0;
|
4981 | this._state = {
|
4982 | paused: false,
|
4983 | pauseQueue: new Set(),
|
4984 | resumeQueue: new Set(),
|
4985 | timeouts: new Set()
|
4986 | };
|
4987 | this._events = {
|
4988 | onStart: new Map(),
|
4989 | onChange: new Map(),
|
4990 | onRest: new Map()
|
4991 | };
|
4992 | this._onFrame = this._onFrame.bind(this);
|
4993 | if (flush2) {
|
4994 | this._flush = flush2;
|
4995 | }
|
4996 | if (props) {
|
4997 | this.start(_extends$2({
|
4998 | default: true
|
4999 | }, props));
|
5000 | }
|
5001 | }
|
5002 | get idle() {
|
5003 | return !this._state.asyncTo && Object.values(this.springs).every((spring) => {
|
5004 | return spring.idle && !spring.isDelayed && !spring.isPaused;
|
5005 | });
|
5006 | }
|
5007 | get item() {
|
5008 | return this._item;
|
5009 | }
|
5010 | set item(item) {
|
5011 | this._item = item;
|
5012 | }
|
5013 | get() {
|
5014 | const values = {};
|
5015 | this.each((spring, key) => values[key] = spring.get());
|
5016 | return values;
|
5017 | }
|
5018 | set(values) {
|
5019 | for (const key in values) {
|
5020 | const value = values[key];
|
5021 | if (!is.und(value)) {
|
5022 | this.springs[key].set(value);
|
5023 | }
|
5024 | }
|
5025 | }
|
5026 | update(props) {
|
5027 | if (props) {
|
5028 | this.queue.push(createUpdate(props));
|
5029 | }
|
5030 | return this;
|
5031 | }
|
5032 | start(props) {
|
5033 | let {
|
5034 | queue
|
5035 | } = this;
|
5036 | if (props) {
|
5037 | queue = toArray$3(props).map(createUpdate);
|
5038 | } else {
|
5039 | this.queue = [];
|
5040 | }
|
5041 | if (this._flush) {
|
5042 | return this._flush(this, queue);
|
5043 | }
|
5044 | prepareKeys(this, queue);
|
5045 | return flushUpdateQueue(this, queue);
|
5046 | }
|
5047 | stop(arg, keys) {
|
5048 | if (arg !== !!arg) {
|
5049 | keys = arg;
|
5050 | }
|
5051 | if (keys) {
|
5052 | const springs = this.springs;
|
5053 | each(toArray$3(keys), (key) => springs[key].stop(!!arg));
|
5054 | } else {
|
5055 | stopAsync(this._state, this._lastAsyncId);
|
5056 | this.each((spring) => spring.stop(!!arg));
|
5057 | }
|
5058 | return this;
|
5059 | }
|
5060 | pause(keys) {
|
5061 | if (is.und(keys)) {
|
5062 | this.start({
|
5063 | pause: true
|
5064 | });
|
5065 | } else {
|
5066 | const springs = this.springs;
|
5067 | each(toArray$3(keys), (key) => springs[key].pause());
|
5068 | }
|
5069 | return this;
|
5070 | }
|
5071 | resume(keys) {
|
5072 | if (is.und(keys)) {
|
5073 | this.start({
|
5074 | pause: false
|
5075 | });
|
5076 | } else {
|
5077 | const springs = this.springs;
|
5078 | each(toArray$3(keys), (key) => springs[key].resume());
|
5079 | }
|
5080 | return this;
|
5081 | }
|
5082 | each(iterator) {
|
5083 | eachProp(this.springs, iterator);
|
5084 | }
|
5085 | _onFrame() {
|
5086 | const {
|
5087 | onStart,
|
5088 | onChange,
|
5089 | onRest
|
5090 | } = this._events;
|
5091 | const active = this._active.size > 0;
|
5092 | const changed = this._changed.size > 0;
|
5093 | if (active && !this._started || changed && !this._started) {
|
5094 | this._started = true;
|
5095 | flush(onStart, ([onStart2, result]) => {
|
5096 | result.value = this.get();
|
5097 | onStart2(result, this, this._item);
|
5098 | });
|
5099 | }
|
5100 | const idle = !active && this._started;
|
5101 | const values = changed || idle && onRest.size ? this.get() : null;
|
5102 | if (changed && onChange.size) {
|
5103 | flush(onChange, ([onChange2, result]) => {
|
5104 | result.value = values;
|
5105 | onChange2(result, this, this._item);
|
5106 | });
|
5107 | }
|
5108 | if (idle) {
|
5109 | this._started = false;
|
5110 | flush(onRest, ([onRest2, result]) => {
|
5111 | result.value = values;
|
5112 | onRest2(result, this, this._item);
|
5113 | });
|
5114 | }
|
5115 | }
|
5116 | eventObserved(event) {
|
5117 | if (event.type == "change") {
|
5118 | this._changed.add(event.parent);
|
5119 | if (!event.idle) {
|
5120 | this._active.add(event.parent);
|
5121 | }
|
5122 | } else if (event.type == "idle") {
|
5123 | this._active.delete(event.parent);
|
5124 | } else
|
5125 | return;
|
5126 | raf.onFrame(this._onFrame);
|
5127 | }
|
5128 | };
|
5129 | function flushUpdateQueue(ctrl, queue) {
|
5130 | return Promise.all(queue.map((props) => flushUpdate(ctrl, props))).then((results) => getCombinedResult(ctrl, results));
|
5131 | }
|
5132 | async function flushUpdate(ctrl, props, isLoop) {
|
5133 | const {
|
5134 | keys,
|
5135 | to: to2,
|
5136 | from,
|
5137 | loop: loop2,
|
5138 | onRest,
|
5139 | onResolve
|
5140 | } = props;
|
5141 | const defaults2 = is.obj(props.default) && props.default;
|
5142 | if (loop2) {
|
5143 | props.loop = false;
|
5144 | }
|
5145 | if (to2 === false)
|
5146 | props.to = null;
|
5147 | if (from === false)
|
5148 | props.from = null;
|
5149 | const asyncTo = is.arr(to2) || is.fun(to2) ? to2 : void 0;
|
5150 | if (asyncTo) {
|
5151 | props.to = void 0;
|
5152 | props.onRest = void 0;
|
5153 | if (defaults2) {
|
5154 | defaults2.onRest = void 0;
|
5155 | }
|
5156 | } else {
|
5157 | each(BATCHED_EVENTS, (key) => {
|
5158 | const handler = props[key];
|
5159 | if (is.fun(handler)) {
|
5160 | const queue = ctrl["_events"][key];
|
5161 | props[key] = ({
|
5162 | finished,
|
5163 | cancelled
|
5164 | }) => {
|
5165 | const result2 = queue.get(handler);
|
5166 | if (result2) {
|
5167 | if (!finished)
|
5168 | result2.finished = false;
|
5169 | if (cancelled)
|
5170 | result2.cancelled = true;
|
5171 | } else {
|
5172 | queue.set(handler, {
|
5173 | value: null,
|
5174 | finished: finished || false,
|
5175 | cancelled: cancelled || false
|
5176 | });
|
5177 | }
|
5178 | };
|
5179 | if (defaults2) {
|
5180 | defaults2[key] = props[key];
|
5181 | }
|
5182 | }
|
5183 | });
|
5184 | }
|
5185 | const state = ctrl["_state"];
|
5186 | if (props.pause === !state.paused) {
|
5187 | state.paused = props.pause;
|
5188 | flushCalls(props.pause ? state.pauseQueue : state.resumeQueue);
|
5189 | } else if (state.paused) {
|
5190 | props.pause = true;
|
5191 | }
|
5192 | const promises = (keys || Object.keys(ctrl.springs)).map((key) => ctrl.springs[key].start(props));
|
5193 | const cancel = props.cancel === true || getDefaultProp(props, "cancel") === true;
|
5194 | if (asyncTo || cancel && state.asyncId) {
|
5195 | promises.push(scheduleProps(++ctrl["_lastAsyncId"], {
|
5196 | props,
|
5197 | state,
|
5198 | actions: {
|
5199 | pause: noop$1,
|
5200 | resume: noop$1,
|
5201 | start(props2, resolve) {
|
5202 | if (cancel) {
|
5203 | stopAsync(state, ctrl["_lastAsyncId"]);
|
5204 | resolve(getCancelledResult(ctrl));
|
5205 | } else {
|
5206 | props2.onRest = onRest;
|
5207 | resolve(runAsync(asyncTo, props2, state, ctrl));
|
5208 | }
|
5209 | }
|
5210 | }
|
5211 | }));
|
5212 | }
|
5213 | if (state.paused) {
|
5214 | await new Promise((resume) => {
|
5215 | state.resumeQueue.add(resume);
|
5216 | });
|
5217 | }
|
5218 | const result = getCombinedResult(ctrl, await Promise.all(promises));
|
5219 | if (loop2 && result.finished && !(isLoop && result.noop)) {
|
5220 | const nextProps = createLoopUpdate(props, loop2, to2);
|
5221 | if (nextProps) {
|
5222 | prepareKeys(ctrl, [nextProps]);
|
5223 | return flushUpdate(ctrl, nextProps, true);
|
5224 | }
|
5225 | }
|
5226 | if (onResolve) {
|
5227 | raf.batchedUpdates(() => onResolve(result, ctrl, ctrl.item));
|
5228 | }
|
5229 | return result;
|
5230 | }
|
5231 | function getSprings(ctrl, props) {
|
5232 | const springs = _extends$2({}, ctrl.springs);
|
5233 | if (props) {
|
5234 | each(toArray$3(props), (props2) => {
|
5235 | if (is.und(props2.keys)) {
|
5236 | props2 = createUpdate(props2);
|
5237 | }
|
5238 | if (!is.obj(props2.to)) {
|
5239 | props2 = _extends$2({}, props2, {
|
5240 | to: void 0
|
5241 | });
|
5242 | }
|
5243 | prepareSprings(springs, props2, (key) => {
|
5244 | return createSpring(key);
|
5245 | });
|
5246 | });
|
5247 | }
|
5248 | setSprings(ctrl, springs);
|
5249 | return springs;
|
5250 | }
|
5251 | function setSprings(ctrl, springs) {
|
5252 | eachProp(springs, (spring, key) => {
|
5253 | if (!ctrl.springs[key]) {
|
5254 | ctrl.springs[key] = spring;
|
5255 | addFluidObserver(spring, ctrl);
|
5256 | }
|
5257 | });
|
5258 | }
|
5259 | function createSpring(key, observer) {
|
5260 | const spring = new SpringValue();
|
5261 | spring.key = key;
|
5262 | if (observer) {
|
5263 | addFluidObserver(spring, observer);
|
5264 | }
|
5265 | return spring;
|
5266 | }
|
5267 | function prepareSprings(springs, props, create2) {
|
5268 | if (props.keys) {
|
5269 | each(props.keys, (key) => {
|
5270 | const spring = springs[key] || (springs[key] = create2(key));
|
5271 | spring["_prepareNode"](props);
|
5272 | });
|
5273 | }
|
5274 | }
|
5275 | function prepareKeys(ctrl, queue) {
|
5276 | each(queue, (props) => {
|
5277 | prepareSprings(ctrl.springs, props, (key) => {
|
5278 | return createSpring(key, ctrl);
|
5279 | });
|
5280 | });
|
5281 | }
|
5282 | function _objectWithoutPropertiesLoose$3(source, excluded) {
|
5283 | if (source == null)
|
5284 | return {};
|
5285 | var target = {};
|
5286 | var sourceKeys = Object.keys(source);
|
5287 | var key, i2;
|
5288 | for (i2 = 0; i2 < sourceKeys.length; i2++) {
|
5289 | key = sourceKeys[i2];
|
5290 | if (excluded.indexOf(key) >= 0)
|
5291 | continue;
|
5292 | target[key] = source[key];
|
5293 | }
|
5294 | return target;
|
5295 | }
|
5296 | const _excluded$6 = ["children"];
|
5297 | const SpringContext = (_ref) => {
|
5298 | let {
|
5299 | children
|
5300 | } = _ref, props = _objectWithoutPropertiesLoose$3(_ref, _excluded$6);
|
5301 | const inherited = React$1.useContext(ctx);
|
5302 | const pause = props.pause || !!inherited.pause, immediate = props.immediate || !!inherited.immediate;
|
5303 | props = useMemoOne(() => ({
|
5304 | pause,
|
5305 | immediate
|
5306 | }), [pause, immediate]);
|
5307 | const {
|
5308 | Provider
|
5309 | } = ctx;
|
5310 | return React__namespace.createElement(Provider, {
|
5311 | value: props
|
5312 | }, children);
|
5313 | };
|
5314 | const ctx = makeContext(SpringContext, {});
|
5315 | SpringContext.Provider = ctx.Provider;
|
5316 | SpringContext.Consumer = ctx.Consumer;
|
5317 | function makeContext(target, init) {
|
5318 | Object.assign(target, React__namespace.createContext(init));
|
5319 | target.Provider._context = target;
|
5320 | target.Consumer._context = target;
|
5321 | return target;
|
5322 | }
|
5323 | const SpringRef = () => {
|
5324 | const current = [];
|
5325 | const SpringRef2 = function SpringRef3(props) {
|
5326 | deprecateDirectCall();
|
5327 | const results = [];
|
5328 | each(current, (ctrl, i2) => {
|
5329 | if (is.und(props)) {
|
5330 | results.push(ctrl.start());
|
5331 | } else {
|
5332 | const update2 = _getProps(props, ctrl, i2);
|
5333 | if (update2) {
|
5334 | results.push(ctrl.start(update2));
|
5335 | }
|
5336 | }
|
5337 | });
|
5338 | return results;
|
5339 | };
|
5340 | SpringRef2.current = current;
|
5341 | SpringRef2.add = function(ctrl) {
|
5342 | if (!current.includes(ctrl)) {
|
5343 | current.push(ctrl);
|
5344 | }
|
5345 | };
|
5346 | SpringRef2.delete = function(ctrl) {
|
5347 | const i2 = current.indexOf(ctrl);
|
5348 | if (~i2)
|
5349 | current.splice(i2, 1);
|
5350 | };
|
5351 | SpringRef2.pause = function() {
|
5352 | each(current, (ctrl) => ctrl.pause(...arguments));
|
5353 | return this;
|
5354 | };
|
5355 | SpringRef2.resume = function() {
|
5356 | each(current, (ctrl) => ctrl.resume(...arguments));
|
5357 | return this;
|
5358 | };
|
5359 | SpringRef2.set = function(values) {
|
5360 | each(current, (ctrl) => ctrl.set(values));
|
5361 | };
|
5362 | SpringRef2.start = function(props) {
|
5363 | const results = [];
|
5364 | each(current, (ctrl, i2) => {
|
5365 | if (is.und(props)) {
|
5366 | results.push(ctrl.start());
|
5367 | } else {
|
5368 | const update2 = this._getProps(props, ctrl, i2);
|
5369 | if (update2) {
|
5370 | results.push(ctrl.start(update2));
|
5371 | }
|
5372 | }
|
5373 | });
|
5374 | return results;
|
5375 | };
|
5376 | SpringRef2.stop = function() {
|
5377 | each(current, (ctrl) => ctrl.stop(...arguments));
|
5378 | return this;
|
5379 | };
|
5380 | SpringRef2.update = function(props) {
|
5381 | each(current, (ctrl, i2) => ctrl.update(this._getProps(props, ctrl, i2)));
|
5382 | return this;
|
5383 | };
|
5384 | const _getProps = function _getProps2(arg, ctrl, index2) {
|
5385 | return is.fun(arg) ? arg(index2, ctrl) : arg;
|
5386 | };
|
5387 | SpringRef2._getProps = _getProps;
|
5388 | return SpringRef2;
|
5389 | };
|
5390 | function useSprings(length, props, deps) {
|
5391 | const propsFn = is.fun(props) && props;
|
5392 | if (propsFn && !deps)
|
5393 | deps = [];
|
5394 | const ref = React$1.useMemo(() => propsFn || arguments.length == 3 ? SpringRef() : void 0, []);
|
5395 | const layoutId = React$1.useRef(0);
|
5396 | const forceUpdate = useForceUpdate();
|
5397 | const state = React$1.useMemo(() => ({
|
5398 | ctrls: [],
|
5399 | queue: [],
|
5400 | flush(ctrl, updates2) {
|
5401 | const springs2 = getSprings(ctrl, updates2);
|
5402 | const canFlushSync = layoutId.current > 0 && !state.queue.length && !Object.keys(springs2).some((key) => !ctrl.springs[key]);
|
5403 | return canFlushSync ? flushUpdateQueue(ctrl, updates2) : new Promise((resolve) => {
|
5404 | setSprings(ctrl, springs2);
|
5405 | state.queue.push(() => {
|
5406 | resolve(flushUpdateQueue(ctrl, updates2));
|
5407 | });
|
5408 | forceUpdate();
|
5409 | });
|
5410 | }
|
5411 | }), []);
|
5412 | const ctrls = React$1.useRef([...state.ctrls]);
|
5413 | const updates = [];
|
5414 | const prevLength = usePrev(length) || 0;
|
5415 | React$1.useMemo(() => {
|
5416 | each(ctrls.current.slice(length, prevLength), (ctrl) => {
|
5417 | detachRefs(ctrl, ref);
|
5418 | ctrl.stop(true);
|
5419 | });
|
5420 | ctrls.current.length = length;
|
5421 | declareUpdates(prevLength, length);
|
5422 | }, [length]);
|
5423 | React$1.useMemo(() => {
|
5424 | declareUpdates(0, Math.min(prevLength, length));
|
5425 | }, deps);
|
5426 | function declareUpdates(startIndex, endIndex) {
|
5427 | for (let i2 = startIndex; i2 < endIndex; i2++) {
|
5428 | const ctrl = ctrls.current[i2] || (ctrls.current[i2] = new Controller$1(null, state.flush));
|
5429 | const update2 = propsFn ? propsFn(i2, ctrl) : props[i2];
|
5430 | if (update2) {
|
5431 | updates[i2] = declareUpdate(update2);
|
5432 | }
|
5433 | }
|
5434 | }
|
5435 | const springs = ctrls.current.map((ctrl, i2) => getSprings(ctrl, updates[i2]));
|
5436 | const context = React$1.useContext(SpringContext);
|
5437 | const prevContext = usePrev(context);
|
5438 | const hasContext = context !== prevContext && hasProps(context);
|
5439 | useIsomorphicLayoutEffect(() => {
|
5440 | layoutId.current++;
|
5441 | state.ctrls = ctrls.current;
|
5442 | const {
|
5443 | queue
|
5444 | } = state;
|
5445 | if (queue.length) {
|
5446 | state.queue = [];
|
5447 | each(queue, (cb) => cb());
|
5448 | }
|
5449 | each(ctrls.current, (ctrl, i2) => {
|
5450 | ref == null ? void 0 : ref.add(ctrl);
|
5451 | if (hasContext) {
|
5452 | ctrl.start({
|
5453 | default: context
|
5454 | });
|
5455 | }
|
5456 | const update2 = updates[i2];
|
5457 | if (update2) {
|
5458 | replaceRef(ctrl, update2.ref);
|
5459 | if (ctrl.ref) {
|
5460 | ctrl.queue.push(update2);
|
5461 | } else {
|
5462 | ctrl.start(update2);
|
5463 | }
|
5464 | }
|
5465 | });
|
5466 | });
|
5467 | useOnce(() => () => {
|
5468 | each(state.ctrls, (ctrl) => ctrl.stop(true));
|
5469 | });
|
5470 | const values = springs.map((x) => _extends$2({}, x));
|
5471 | return ref ? [values, ref] : values;
|
5472 | }
|
5473 | function useSpring(props, deps) {
|
5474 | const isFn = is.fun(props);
|
5475 | const [[values], ref] = useSprings(1, isFn ? props : [props], isFn ? deps || [] : deps);
|
5476 | return isFn || arguments.length == 2 ? [values, ref] : values;
|
5477 | }
|
5478 | let TransitionPhase;
|
5479 | (function(TransitionPhase2) {
|
5480 | TransitionPhase2["MOUNT"] = "mount";
|
5481 | TransitionPhase2["ENTER"] = "enter";
|
5482 | TransitionPhase2["UPDATE"] = "update";
|
5483 | TransitionPhase2["LEAVE"] = "leave";
|
5484 | })(TransitionPhase || (TransitionPhase = {}));
|
5485 | class Interpolation extends FrameValue {
|
5486 | constructor(source, args) {
|
5487 | super();
|
5488 | this.key = void 0;
|
5489 | this.idle = true;
|
5490 | this.calc = void 0;
|
5491 | this._active = new Set();
|
5492 | this.source = source;
|
5493 | this.calc = createInterpolator(...args);
|
5494 | const value = this._get();
|
5495 | const nodeType = getAnimatedType(value);
|
5496 | setAnimated(this, nodeType.create(value));
|
5497 | }
|
5498 | advance(_dt) {
|
5499 | const value = this._get();
|
5500 | const oldValue = this.get();
|
5501 | if (!isEqual$1(value, oldValue)) {
|
5502 | getAnimated(this).setValue(value);
|
5503 | this._onChange(value, this.idle);
|
5504 | }
|
5505 | if (!this.idle && checkIdle(this._active)) {
|
5506 | becomeIdle(this);
|
5507 | }
|
5508 | }
|
5509 | _get() {
|
5510 | const inputs = is.arr(this.source) ? this.source.map(getFluidValue) : toArray$3(getFluidValue(this.source));
|
5511 | return this.calc(...inputs);
|
5512 | }
|
5513 | _start() {
|
5514 | if (this.idle && !checkIdle(this._active)) {
|
5515 | this.idle = false;
|
5516 | each(getPayload(this), (node) => {
|
5517 | node.done = false;
|
5518 | });
|
5519 | if (globals.skipAnimation) {
|
5520 | raf.batchedUpdates(() => this.advance());
|
5521 | becomeIdle(this);
|
5522 | } else {
|
5523 | frameLoop.start(this);
|
5524 | }
|
5525 | }
|
5526 | }
|
5527 | _attach() {
|
5528 | let priority2 = 1;
|
5529 | each(toArray$3(this.source), (source) => {
|
5530 | if (hasFluidValue(source)) {
|
5531 | addFluidObserver(source, this);
|
5532 | }
|
5533 | if (isFrameValue(source)) {
|
5534 | if (!source.idle) {
|
5535 | this._active.add(source);
|
5536 | }
|
5537 | priority2 = Math.max(priority2, source.priority + 1);
|
5538 | }
|
5539 | });
|
5540 | this.priority = priority2;
|
5541 | this._start();
|
5542 | }
|
5543 | _detach() {
|
5544 | each(toArray$3(this.source), (source) => {
|
5545 | if (hasFluidValue(source)) {
|
5546 | removeFluidObserver(source, this);
|
5547 | }
|
5548 | });
|
5549 | this._active.clear();
|
5550 | becomeIdle(this);
|
5551 | }
|
5552 | eventObserved(event) {
|
5553 | if (event.type == "change") {
|
5554 | if (event.idle) {
|
5555 | this.advance();
|
5556 | } else {
|
5557 | this._active.add(event.parent);
|
5558 | this._start();
|
5559 | }
|
5560 | } else if (event.type == "idle") {
|
5561 | this._active.delete(event.parent);
|
5562 | } else if (event.type == "priority") {
|
5563 | this.priority = toArray$3(this.source).reduce((highest, parent) => Math.max(highest, (isFrameValue(parent) ? parent.priority : 0) + 1), 0);
|
5564 | }
|
5565 | }
|
5566 | }
|
5567 | function isIdle(source) {
|
5568 | return source.idle !== false;
|
5569 | }
|
5570 | function checkIdle(active) {
|
5571 | return !active.size || Array.from(active).every(isIdle);
|
5572 | }
|
5573 | function becomeIdle(self2) {
|
5574 | if (!self2.idle) {
|
5575 | self2.idle = true;
|
5576 | each(getPayload(self2), (node) => {
|
5577 | node.done = true;
|
5578 | });
|
5579 | callFluidObservers(self2, {
|
5580 | type: "idle",
|
5581 | parent: self2
|
5582 | });
|
5583 | }
|
5584 | }
|
5585 | const to = (source, ...args) => new Interpolation(source, args);
|
5586 | globals.assign({
|
5587 | createStringInterpolator,
|
5588 | to: (source, args) => new Interpolation(source, args)
|
5589 | });
|
5590 | function _objectWithoutPropertiesLoose$2(source, excluded) {
|
5591 | if (source == null)
|
5592 | return {};
|
5593 | var target = {};
|
5594 | var sourceKeys = Object.keys(source);
|
5595 | var key, i2;
|
5596 | for (i2 = 0; i2 < sourceKeys.length; i2++) {
|
5597 | key = sourceKeys[i2];
|
5598 | if (excluded.indexOf(key) >= 0)
|
5599 | continue;
|
5600 | target[key] = source[key];
|
5601 | }
|
5602 | return target;
|
5603 | }
|
5604 | const _excluded$2$1 = ["style", "children", "scrollTop", "scrollLeft", "viewBox"];
|
5605 | const isCustomPropRE = /^--/;
|
5606 | function dangerousStyleValue(name, value) {
|
5607 | if (value == null || typeof value === "boolean" || value === "")
|
5608 | return "";
|
5609 | if (typeof value === "number" && value !== 0 && !isCustomPropRE.test(name) && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name]))
|
5610 | return value + "px";
|
5611 | return ("" + value).trim();
|
5612 | }
|
5613 | const attributeCache = {};
|
5614 | function applyAnimatedValues(instance, props) {
|
5615 | if (!instance.nodeType || !instance.setAttribute) {
|
5616 | return false;
|
5617 | }
|
5618 | const isFilterElement = instance.nodeName === "filter" || instance.parentNode && instance.parentNode.nodeName === "filter";
|
5619 | const _ref = props, {
|
5620 | style,
|
5621 | children,
|
5622 | scrollTop,
|
5623 | scrollLeft,
|
5624 | viewBox
|
5625 | } = _ref, attributes = _objectWithoutPropertiesLoose$2(_ref, _excluded$2$1);
|
5626 | const values = Object.values(attributes);
|
5627 | const names = Object.keys(attributes).map((name) => isFilterElement || instance.hasAttribute(name) ? name : attributeCache[name] || (attributeCache[name] = name.replace(/([A-Z])/g, (n2) => "-" + n2.toLowerCase())));
|
5628 | if (children !== void 0) {
|
5629 | instance.textContent = children;
|
5630 | }
|
5631 | for (let name in style) {
|
5632 | if (style.hasOwnProperty(name)) {
|
5633 | const value = dangerousStyleValue(name, style[name]);
|
5634 | if (isCustomPropRE.test(name)) {
|
5635 | instance.style.setProperty(name, value);
|
5636 | } else {
|
5637 | instance.style[name] = value;
|
5638 | }
|
5639 | }
|
5640 | }
|
5641 | names.forEach((name, i2) => {
|
5642 | instance.setAttribute(name, values[i2]);
|
5643 | });
|
5644 | if (scrollTop !== void 0) {
|
5645 | instance.scrollTop = scrollTop;
|
5646 | }
|
5647 | if (scrollLeft !== void 0) {
|
5648 | instance.scrollLeft = scrollLeft;
|
5649 | }
|
5650 | if (viewBox !== void 0) {
|
5651 | instance.setAttribute("viewBox", viewBox);
|
5652 | }
|
5653 | }
|
5654 | let isUnitlessNumber = {
|
5655 | animationIterationCount: true,
|
5656 | borderImageOutset: true,
|
5657 | borderImageSlice: true,
|
5658 | borderImageWidth: true,
|
5659 | boxFlex: true,
|
5660 | boxFlexGroup: true,
|
5661 | boxOrdinalGroup: true,
|
5662 | columnCount: true,
|
5663 | columns: true,
|
5664 | flex: true,
|
5665 | flexGrow: true,
|
5666 | flexPositive: true,
|
5667 | flexShrink: true,
|
5668 | flexNegative: true,
|
5669 | flexOrder: true,
|
5670 | gridRow: true,
|
5671 | gridRowEnd: true,
|
5672 | gridRowSpan: true,
|
5673 | gridRowStart: true,
|
5674 | gridColumn: true,
|
5675 | gridColumnEnd: true,
|
5676 | gridColumnSpan: true,
|
5677 | gridColumnStart: true,
|
5678 | fontWeight: true,
|
5679 | lineClamp: true,
|
5680 | lineHeight: true,
|
5681 | opacity: true,
|
5682 | order: true,
|
5683 | orphans: true,
|
5684 | tabSize: true,
|
5685 | widows: true,
|
5686 | zIndex: true,
|
5687 | zoom: true,
|
5688 | fillOpacity: true,
|
5689 | floodOpacity: true,
|
5690 | stopOpacity: true,
|
5691 | strokeDasharray: true,
|
5692 | strokeDashoffset: true,
|
5693 | strokeMiterlimit: true,
|
5694 | strokeOpacity: true,
|
5695 | strokeWidth: true
|
5696 | };
|
5697 | const prefixKey = (prefix2, key) => prefix2 + key.charAt(0).toUpperCase() + key.substring(1);
|
5698 | const prefixes = ["Webkit", "Ms", "Moz", "O"];
|
5699 | isUnitlessNumber = Object.keys(isUnitlessNumber).reduce((acc, prop) => {
|
5700 | prefixes.forEach((prefix2) => acc[prefixKey(prefix2, prop)] = acc[prop]);
|
5701 | return acc;
|
5702 | }, isUnitlessNumber);
|
5703 | const _excluded$1$1 = ["x", "y", "z"];
|
5704 | const domTransforms = /^(matrix|translate|scale|rotate|skew)/;
|
5705 | const pxTransforms = /^(translate)/;
|
5706 | const degTransforms = /^(rotate|skew)/;
|
5707 | const addUnit = (value, unit) => is.num(value) && value !== 0 ? value + unit : value;
|
5708 | const isValueIdentity = (value, id) => is.arr(value) ? value.every((v) => isValueIdentity(v, id)) : is.num(value) ? value === id : parseFloat(value) === id;
|
5709 | class AnimatedStyle extends AnimatedObject {
|
5710 | constructor(_ref) {
|
5711 | let {
|
5712 | x,
|
5713 | y,
|
5714 | z
|
5715 | } = _ref, style = _objectWithoutPropertiesLoose$2(_ref, _excluded$1$1);
|
5716 | const inputs = [];
|
5717 | const transforms = [];
|
5718 | if (x || y || z) {
|
5719 | inputs.push([x || 0, y || 0, z || 0]);
|
5720 | transforms.push((xyz) => [`translate3d(${xyz.map((v) => addUnit(v, "px")).join(",")})`, isValueIdentity(xyz, 0)]);
|
5721 | }
|
5722 | eachProp(style, (value, key) => {
|
5723 | if (key === "transform") {
|
5724 | inputs.push([value || ""]);
|
5725 | transforms.push((transform) => [transform, transform === ""]);
|
5726 | } else if (domTransforms.test(key)) {
|
5727 | delete style[key];
|
5728 | if (is.und(value))
|
5729 | return;
|
5730 | const unit = pxTransforms.test(key) ? "px" : degTransforms.test(key) ? "deg" : "";
|
5731 | inputs.push(toArray$3(value));
|
5732 | transforms.push(key === "rotate3d" ? ([x2, y2, z2, deg]) => [`rotate3d(${x2},${y2},${z2},${addUnit(deg, unit)})`, isValueIdentity(deg, 0)] : (input) => [`${key}(${input.map((v) => addUnit(v, unit)).join(",")})`, isValueIdentity(input, key.startsWith("scale") ? 1 : 0)]);
|
5733 | }
|
5734 | });
|
5735 | if (inputs.length) {
|
5736 | style.transform = new FluidTransform(inputs, transforms);
|
5737 | }
|
5738 | super(style);
|
5739 | }
|
5740 | }
|
5741 | class FluidTransform extends FluidValue {
|
5742 | constructor(inputs, transforms) {
|
5743 | super();
|
5744 | this._value = null;
|
5745 | this.inputs = inputs;
|
5746 | this.transforms = transforms;
|
5747 | }
|
5748 | get() {
|
5749 | return this._value || (this._value = this._get());
|
5750 | }
|
5751 | _get() {
|
5752 | let transform = "";
|
5753 | let identity2 = true;
|
5754 | each(this.inputs, (input, i2) => {
|
5755 | const arg1 = getFluidValue(input[0]);
|
5756 | const [t, id] = this.transforms[i2](is.arr(arg1) ? arg1 : input.map(getFluidValue));
|
5757 | transform += " " + t;
|
5758 | identity2 = identity2 && id;
|
5759 | });
|
5760 | return identity2 ? "none" : transform;
|
5761 | }
|
5762 | observerAdded(count) {
|
5763 | if (count == 1)
|
5764 | each(this.inputs, (input) => each(input, (value) => hasFluidValue(value) && addFluidObserver(value, this)));
|
5765 | }
|
5766 | observerRemoved(count) {
|
5767 | if (count == 0)
|
5768 | each(this.inputs, (input) => each(input, (value) => hasFluidValue(value) && removeFluidObserver(value, this)));
|
5769 | }
|
5770 | eventObserved(event) {
|
5771 | if (event.type == "change") {
|
5772 | this._value = null;
|
5773 | }
|
5774 | callFluidObservers(this, event);
|
5775 | }
|
5776 | }
|
5777 | const primitives = ["a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "big", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "menu", "menuitem", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var", "video", "wbr", "circle", "clipPath", "defs", "ellipse", "foreignObject", "g", "image", "line", "linearGradient", "mask", "path", "pattern", "polygon", "polyline", "radialGradient", "rect", "stop", "svg", "text", "tspan"];
|
5778 | const _excluded$4 = ["scrollTop", "scrollLeft"];
|
5779 | globals.assign({
|
5780 | batchedUpdates: ReactDOM.unstable_batchedUpdates,
|
5781 | createStringInterpolator,
|
5782 | colors
|
5783 | });
|
5784 | const host = createHost(primitives, {
|
5785 | applyAnimatedValues,
|
5786 | createAnimatedStyle: (style) => new AnimatedStyle(style),
|
5787 | getComponentProps: (_ref) => {
|
5788 | let props = _objectWithoutPropertiesLoose$2(_ref, _excluded$4);
|
5789 | return props;
|
5790 | }
|
5791 | });
|
5792 | const animated = host.animated;
|
5793 | function resolveContainer(getContainer) {
|
5794 | const container = typeof getContainer === "function" ? getContainer() : getContainer;
|
5795 | return container || document.body;
|
5796 | }
|
5797 | function renderToContainer(getContainer, node) {
|
5798 | if (canUseDom$1 && getContainer) {
|
5799 | const container = resolveContainer(getContainer);
|
5800 | return ReactDOM.createPortal(node, container);
|
5801 | }
|
5802 | return node;
|
5803 | }
|
5804 | function useInitialized(check) {
|
5805 | const initializedRef = React$1.useRef(check);
|
5806 | if (check) {
|
5807 | initializedRef.current = true;
|
5808 | }
|
5809 | return !!initializedRef.current;
|
5810 | }
|
5811 | const ShouldRender = (props) => {
|
5812 | const shouldRender = useShouldRender(props.active, props.forceRender, props.destroyOnClose);
|
5813 | return shouldRender ? props.children : null;
|
5814 | };
|
5815 | function useShouldRender(active, forceRender, destroyOnClose) {
|
5816 | const initialized = useInitialized(active);
|
5817 | if (forceRender)
|
5818 | return true;
|
5819 | if (active)
|
5820 | return true;
|
5821 | if (!initialized)
|
5822 | return false;
|
5823 | return !destroyOnClose;
|
5824 | }
|
5825 | const eventToPropRecord$1 = {
|
5826 | "click": "onClick",
|
5827 | "touchstart": "onTouchStart"
|
5828 | };
|
5829 | function withStopPropagation(events, element) {
|
5830 | const props = Object.assign({}, element.props);
|
5831 | for (const key of events) {
|
5832 | const prop = eventToPropRecord$1[key];
|
5833 | props[prop] = function(e2) {
|
5834 | var _a, _b;
|
5835 | e2.stopPropagation();
|
5836 | (_b = (_a = element.props)[prop]) === null || _b === void 0 ? void 0 : _b.call(_a, e2);
|
5837 | };
|
5838 | }
|
5839 | return React$1.cloneElement(element, props);
|
5840 | }
|
5841 | const classPrefix$1p = `adm-mask`;
|
5842 | const opacityRecord = {
|
5843 | default: 0.55,
|
5844 | thin: 0.35,
|
5845 | thick: 0.75
|
5846 | };
|
5847 | const colorRecord$4 = {
|
5848 | black: "0, 0, 0",
|
5849 | white: "255, 255, 255"
|
5850 | };
|
5851 | const defaultProps$14 = {
|
5852 | visible: true,
|
5853 | destroyOnClose: false,
|
5854 | forceRender: false,
|
5855 | color: "black",
|
5856 | opacity: "default",
|
5857 | disableBodyScroll: true,
|
5858 | getContainer: null,
|
5859 | stopPropagation: ["click"]
|
5860 | };
|
5861 | const Mask = (p) => {
|
5862 | const props = mergeProps(defaultProps$14, p);
|
5863 | const {
|
5864 | locale
|
5865 | } = useConfig();
|
5866 | const ref = React$1.useRef(null);
|
5867 | useLockScroll(ref, props.visible && props.disableBodyScroll);
|
5868 | const background = React$1.useMemo(() => {
|
5869 | var _a;
|
5870 | const opacity2 = (_a = opacityRecord[props.opacity]) !== null && _a !== void 0 ? _a : props.opacity;
|
5871 | const rgb2 = colorRecord$4[props.color];
|
5872 | return rgb2 ? `rgba(${rgb2}, ${opacity2})` : props.color;
|
5873 | }, [props.color, props.opacity]);
|
5874 | const [active, setActive] = React$1.useState(props.visible);
|
5875 | const unmountedRef = useUnmountedRef$1();
|
5876 | const {
|
5877 | opacity
|
5878 | } = useSpring({
|
5879 | opacity: props.visible ? 1 : 0,
|
5880 | config: {
|
5881 | precision: 0.01,
|
5882 | mass: 1,
|
5883 | tension: 250,
|
5884 | friction: 30,
|
5885 | clamp: true
|
5886 | },
|
5887 | onStart: () => {
|
5888 | setActive(true);
|
5889 | },
|
5890 | onRest: () => {
|
5891 | var _a, _b;
|
5892 | if (unmountedRef.current)
|
5893 | return;
|
5894 | setActive(props.visible);
|
5895 | if (props.visible) {
|
5896 | (_a = props.afterShow) === null || _a === void 0 ? void 0 : _a.call(props);
|
5897 | } else {
|
5898 | (_b = props.afterClose) === null || _b === void 0 ? void 0 : _b.call(props);
|
5899 | }
|
5900 | }
|
5901 | });
|
5902 | const node = withStopPropagation(props.stopPropagation, withNativeProps(props, React$1.createElement(animated.div, {
|
5903 | className: classPrefix$1p,
|
5904 | ref,
|
5905 | "aria-hidden": true,
|
5906 | style: Object.assign(Object.assign({}, props.style), {
|
5907 | background,
|
5908 | opacity,
|
5909 | display: active ? void 0 : "none"
|
5910 | }),
|
5911 | onClick: (e2) => {
|
5912 | var _a;
|
5913 | if (e2.target === e2.currentTarget) {
|
5914 | (_a = props.onMaskClick) === null || _a === void 0 ? void 0 : _a.call(props, e2);
|
5915 | }
|
5916 | }
|
5917 | }, props.onMaskClick && React$1.createElement("div", {
|
5918 | className: `${classPrefix$1p}-aria-button`,
|
5919 | role: "button",
|
5920 | "aria-label": locale.Mask.name,
|
5921 | onClick: props.onMaskClick
|
5922 | }), React$1.createElement("div", {
|
5923 | className: `${classPrefix$1p}-content`
|
5924 | }, props.children))));
|
5925 | return React$1.createElement(ShouldRender, {
|
5926 | active,
|
5927 | forceRender: props.forceRender,
|
5928 | destroyOnClose: props.destroyOnClose
|
5929 | }, renderToContainer(props.getContainer, node));
|
5930 | };
|
5931 | function AddOutline(props) {
|
5932 | return React__namespace.createElement("svg", Object.assign({
|
5933 | width: "1em",
|
5934 | height: "1em",
|
5935 | viewBox: "0 0 48 48",
|
5936 | xmlns: "http://www.w3.org/2000/svg",
|
5937 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
5938 | }, props, {
|
5939 | style: Object.assign({
|
5940 | verticalAlign: "-0.125em"
|
5941 | }, props.style),
|
5942 | className: ["antd-mobile-icon", props.className].filter(Boolean).join(" ")
|
5943 | }), React__namespace.createElement("g", {
|
5944 | id: "AddOutline-AddOutline",
|
5945 | stroke: "none",
|
5946 | strokeWidth: 1,
|
5947 | fill: "none",
|
5948 | fillRule: "evenodd"
|
5949 | }, React__namespace.createElement("g", {
|
5950 | id: "AddOutline-add"
|
5951 | }, React__namespace.createElement("rect", {
|
5952 | id: "AddOutline-矩形",
|
5953 | fill: "#FFFFFF",
|
5954 | opacity: 0,
|
5955 | x: 0,
|
5956 | y: 0,
|
5957 | width: 48,
|
5958 | height: 48
|
5959 | }), React__namespace.createElement("path", {
|
5960 | d: "M25.1,6.5 C25.3209139,6.5 25.5,6.6790861 25.5,6.9 L25.5,22.5 L41.1,22.5 C41.3209139,22.5 41.5,22.6790861 41.5,22.9 L41.5,25.1 C41.5,25.3209139 41.3209139,25.5 41.1,25.5 L25.5,25.5 L25.5,41.1 C25.5,41.3209139 25.3209139,41.5 25.1,41.5 L22.9,41.5 C22.6790861,41.5 22.5,41.3209139 22.5,41.1 L22.5,25.5 L6.9,25.5 C6.6790861,25.5 6.5,25.3209139 6.5,25.1 L6.5,22.9 C6.5,22.6790861 6.6790861,22.5 6.9,22.5 L22.5,22.5 L22.5,6.9 C22.5,6.6790861 22.6790861,6.5 22.9,6.5 L25.1,6.5 Z",
|
5961 | id: "AddOutline-路径",
|
5962 | fill: "currentColor",
|
5963 | fillRule: "nonzero"
|
5964 | }))));
|
5965 | }
|
5966 | function CheckCircleFill(props) {
|
5967 | return React__namespace.createElement("svg", Object.assign({
|
5968 | width: "1em",
|
5969 | height: "1em",
|
5970 | viewBox: "0 0 48 48",
|
5971 | xmlns: "http://www.w3.org/2000/svg",
|
5972 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
5973 | }, props, {
|
5974 | style: Object.assign({
|
5975 | verticalAlign: "-0.125em"
|
5976 | }, props.style),
|
5977 | className: ["antd-mobile-icon", props.className].filter(Boolean).join(" ")
|
5978 | }), React__namespace.createElement("g", {
|
5979 | id: "CheckCircleFill-CheckCircleFill",
|
5980 | stroke: "none",
|
5981 | strokeWidth: 1,
|
5982 | fill: "none",
|
5983 | fillRule: "evenodd"
|
5984 | }, React__namespace.createElement("g", {
|
5985 | id: "CheckCircleFill-编组"
|
5986 | }, React__namespace.createElement("rect", {
|
5987 | id: "CheckCircleFill-矩形",
|
5988 | fill: "#FFFFFF",
|
5989 | opacity: 0,
|
5990 | x: 0,
|
5991 | y: 0,
|
5992 | width: 48,
|
5993 | height: 48
|
5994 | }), React__namespace.createElement("path", {
|
5995 | d: "M24,2 C36.1502645,2 46,11.8497355 46,24 C46,36.1502645 36.1502645,46 24,46 C11.8497355,46 2,36.1502645 2,24 C2,11.8497355 11.8497355,2 24,2 Z M35.8202936,17 L32.7086692,17 C32.6025922,17 32.500859,17.0421352 32.4258461,17.1171378 L32.4258461,17.1171378 L21.3922352,28.1492247 L16.3591562,23.1163755 C16.2841422,23.0413649 16.1824034,22.9992247 16.0763199,22.9992247 L16.0763199,22.9992247 L12.9653996,22.9992247 C12.859342,22.9992247 12.7576259,23.0413445 12.6826161,23.1163228 C12.5263737,23.2724998 12.5263207,23.5257658 12.6824977,23.6820082 C12.8583452,23.8579294 13.0341927,24.0338505 13.2100402,24.2097716 C13.2577488,24.2575002 13.3065097,24.3063074 13.3562592,24.3561283 L13.6661084,24.6666997 C14.3074913,25.3100963 15.0728595,26.0807873 15.8520136,26.8666654 L16.4372421,27.4571699 C18.2552812,29.2922548 19.9983838,31.0574343 20.2666114,31.3285298 L20.301004,31.3632341 C20.8867904,31.9490205 21.8365379,31.9490205 22.4223243,31.3632341 L22.4223243,31.3632341 L36.1031319,17.6828471 C36.1781492,17.6078322 36.2202936,17.5060887 36.2202936,17.4 C36.2202936,17.1790861 36.0412075,17 35.8202936,17 L35.8202936,17 Z",
|
5996 | id: "CheckCircleFill-形状结合",
|
5997 | fill: "currentColor",
|
5998 | fillRule: "nonzero"
|
5999 | }))));
|
6000 | }
|
6001 | function CheckOutline(props) {
|
6002 | return React__namespace.createElement("svg", Object.assign({
|
6003 | width: "1em",
|
6004 | height: "1em",
|
6005 | viewBox: "0 0 48 48",
|
6006 | xmlns: "http://www.w3.org/2000/svg",
|
6007 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
6008 | }, props, {
|
6009 | style: Object.assign({
|
6010 | verticalAlign: "-0.125em"
|
6011 | }, props.style),
|
6012 | className: ["antd-mobile-icon", props.className].filter(Boolean).join(" ")
|
6013 | }), React__namespace.createElement("g", {
|
6014 | id: "CheckOutline-CheckOutline",
|
6015 | stroke: "none",
|
6016 | strokeWidth: 1,
|
6017 | fill: "none",
|
6018 | fillRule: "evenodd"
|
6019 | }, React__namespace.createElement("g", {
|
6020 | id: "CheckOutline-编组"
|
6021 | }, React__namespace.createElement("rect", {
|
6022 | id: "CheckOutline-矩形",
|
6023 | fill: "#FFFFFF",
|
6024 | opacity: 0,
|
6025 | x: 0,
|
6026 | y: 0,
|
6027 | width: 48,
|
6028 | height: 48
|
6029 | }), React__namespace.createElement("path", {
|
6030 | d: "M44.309608,12.6841286 L21.2180499,35.5661955 L21.2180499,35.5661955 C20.6343343,36.1446015 19.6879443,36.1446015 19.1042286,35.5661955 C19.0538201,35.5162456 19.0077648,35.4636155 18.9660627,35.4087682 C18.9113105,35.368106 18.8584669,35.3226694 18.808302,35.2729607 L3.6903839,20.2920499 C3.53346476,20.1365529 3.53231192,19.8832895 3.68780898,19.7263704 C3.7629255,19.6505669 3.86521855,19.6079227 3.97193622,19.6079227 L7.06238923,19.6079227 C7.16784214,19.6079227 7.26902895,19.6495648 7.34393561,19.7237896 L20.160443,32.4236157 L20.160443,32.4236157 L40.656066,12.115858 C40.7309719,12.0416387 40.8321549,12 40.9376034,12 L44.0280571,12 C44.248971,12 44.4280571,12.1790861 44.4280571,12.4 C44.4280571,12.5067183 44.3854124,12.609012 44.309608,12.6841286 Z",
|
6031 | id: "CheckOutline-路径",
|
6032 | fill: "currentColor",
|
6033 | fillRule: "nonzero"
|
6034 | }))));
|
6035 | }
|
6036 | function ClockCircleFill(props) {
|
6037 | return React__namespace.createElement("svg", Object.assign({
|
6038 | width: "1em",
|
6039 | height: "1em",
|
6040 | viewBox: "0 0 48 48",
|
6041 | xmlns: "http://www.w3.org/2000/svg",
|
6042 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
6043 | }, props, {
|
6044 | style: Object.assign({
|
6045 | verticalAlign: "-0.125em"
|
6046 | }, props.style),
|
6047 | className: ["antd-mobile-icon", props.className].filter(Boolean).join(" ")
|
6048 | }), React__namespace.createElement("g", {
|
6049 | id: "ClockCircleFill-ClockCircleFill",
|
6050 | stroke: "none",
|
6051 | strokeWidth: 1,
|
6052 | fill: "none",
|
6053 | fillRule: "evenodd"
|
6054 | }, React__namespace.createElement("g", {
|
6055 | id: "ClockCircleFill-编组"
|
6056 | }, React__namespace.createElement("rect", {
|
6057 | id: "ClockCircleFill-矩形",
|
6058 | fill: "#FFFFFF",
|
6059 | opacity: 0,
|
6060 | x: 0,
|
6061 | y: 0,
|
6062 | width: 48,
|
6063 | height: 48
|
6064 | }), React__namespace.createElement("path", {
|
6065 | d: "M24,2 C36.1502645,2 46,11.8497355 46,24 C46,36.1502645 36.1502645,46 24,46 C11.8497355,46 2,36.1502645 2,24 C2,11.8497355 11.8497355,2 24,2 Z M24.6,14 L22.4,14 C22.1790861,14 22,14.1790861 22,14.4 L22,14.4 L22,23.1715729 L22.0065089,23.3850222 C22.0584325,24.2354066 22.4192395,25.0405598 23.0251263,25.6464466 L23.0251263,25.6464466 L31.1564971,33.7778175 C31.3127068,33.9340272 31.5659728,33.9340272 31.7221825,33.7778175 L31.7221825,33.7778175 L33.2778175,32.2221825 C33.4340272,32.0659728 33.4340272,31.8127068 33.2778175,31.6564971 L33.2778175,31.6564971 L25.1464466,23.5251263 L25.0952092,23.4650801 C25.0337142,23.38027 25,23.2776595 25,23.1715729 L25,23.1715729 L25,14.4 C25,14.1790861 24.8209139,14 24.6,14 L24.6,14 Z",
|
6066 | id: "ClockCircleFill-形状结合",
|
6067 | fill: "currentColor",
|
6068 | fillRule: "nonzero"
|
6069 | }))));
|
6070 | }
|
6071 | function CloseCircleFill(props) {
|
6072 | return React__namespace.createElement("svg", Object.assign({
|
6073 | width: "1em",
|
6074 | height: "1em",
|
6075 | viewBox: "0 0 48 48",
|
6076 | xmlns: "http://www.w3.org/2000/svg",
|
6077 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
6078 | }, props, {
|
6079 | style: Object.assign({
|
6080 | verticalAlign: "-0.125em"
|
6081 | }, props.style),
|
6082 | className: ["antd-mobile-icon", props.className].filter(Boolean).join(" ")
|
6083 | }), React__namespace.createElement("g", {
|
6084 | id: "CloseCircleFill-CloseCircleFill",
|
6085 | stroke: "none",
|
6086 | strokeWidth: 1,
|
6087 | fill: "none",
|
6088 | fillRule: "evenodd"
|
6089 | }, React__namespace.createElement("g", {
|
6090 | id: "CloseCircleFill-编组"
|
6091 | }, React__namespace.createElement("rect", {
|
6092 | id: "CloseCircleFill-矩形",
|
6093 | fill: "#FFFFFF",
|
6094 | opacity: 0,
|
6095 | x: 0,
|
6096 | y: 0,
|
6097 | width: 48,
|
6098 | height: 48
|
6099 | }), React__namespace.createElement("path", {
|
6100 | d: "M24,2 C36.1502645,2 46,11.8497355 46,24 C46,36.1502645 36.1502645,46 24,46 C11.8497355,46 2,36.1502645 2,24 C2,11.8497355 11.8497355,2 24,2 Z M18.6753876,16 L15.5637812,16 C15.4576916,16 15.3559474,16.0421451 15.2809323,16.1171635 C15.124726,16.2733766 15.1247316,16.5266426 15.2809447,16.6828489 L15.2809447,16.6828489 L22.299066,23.7006641 L14.6828159,31.3171619 C14.6078042,31.3921761 14.5656632,31.4939157 14.5656632,31.6 C14.5656632,31.8209139 14.7447493,32 14.9656632,32 L14.9656632,32 L18.0753284,32 C18.1814068,32 18.2831412,31.9578638 18.3581544,31.8828594 L18.3581544,31.8828594 L24.420066,25.8216641 L30.4818451,31.8828564 C30.5568585,31.9578626 30.6585942,32 30.7646741,32 L30.7646741,32 L33.8763476,32 C33.9824309,32 34.0841695,31.9578599 34.1591835,31.8828496 C34.315397,31.7266436 34.3154031,31.4733776 34.1591972,31.3171641 L34.1591972,31.3171641 L26.542066,23.6996641 L33.5591874,16.6828489 C33.6342057,16.6078338 33.6763508,16.5060896 33.6763508,16.4 C33.6763508,16.1790861 33.4972647,16 33.2763508,16 L33.2763508,16 L30.1637654,16 C30.0576705,16 29.9559218,16.0421493 29.8809058,16.1171741 L29.8809058,16.1171741 L24.420066,21.5786641 L18.9582218,16.1171488 C18.883208,16.0421394 18.7814701,16 18.6753876,16 L18.6753876,16 Z",
|
6101 | id: "CloseCircleFill-形状结合",
|
6102 | fill: "currentColor",
|
6103 | fillRule: "nonzero"
|
6104 | }))));
|
6105 | }
|
6106 | function CloseOutline(props) {
|
6107 | return React__namespace.createElement("svg", Object.assign({
|
6108 | width: "1em",
|
6109 | height: "1em",
|
6110 | viewBox: "0 0 48 48",
|
6111 | xmlns: "http://www.w3.org/2000/svg",
|
6112 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
6113 | }, props, {
|
6114 | style: Object.assign({
|
6115 | verticalAlign: "-0.125em"
|
6116 | }, props.style),
|
6117 | className: ["antd-mobile-icon", props.className].filter(Boolean).join(" ")
|
6118 | }), React__namespace.createElement("g", {
|
6119 | id: "CloseOutline-CloseOutline",
|
6120 | stroke: "none",
|
6121 | strokeWidth: 1,
|
6122 | fill: "none",
|
6123 | fillRule: "evenodd"
|
6124 | }, React__namespace.createElement("g", {
|
6125 | id: "CloseOutline-编组"
|
6126 | }, React__namespace.createElement("rect", {
|
6127 | id: "CloseOutline-矩形",
|
6128 | fill: "#FFFFFF",
|
6129 | opacity: 0,
|
6130 | x: 0,
|
6131 | y: 0,
|
6132 | width: 48,
|
6133 | height: 48
|
6134 | }), React__namespace.createElement("path", {
|
6135 | d: "M10.6085104,8.11754663 L24.1768397,21.8195031 L24.1768397,21.8195031 L37.7443031,8.1175556 C37.8194278,8.04168616 37.9217669,7.999 38.0285372,7.999 L41.1040268,7.999 C41.3249407,7.999 41.5040268,8.1780861 41.5040268,8.399 C41.5040268,8.50440471 41.4624226,8.60554929 41.3882578,8.68044752 L26.2773302,23.9408235 L26.2773302,23.9408235 L41.5021975,39.3175645 C41.65763,39.4745475 41.6563731,39.7278104 41.4993901,39.8832429 C41.4244929,39.9574004 41.3233534,39.999 41.2179546,39.999 L38.1434012,39.999 C38.0366291,39.999 37.9342885,39.9563124 37.8591634,39.8804408 L24.1768397,26.0621438 L24.1768397,26.0621438 L10.4936501,39.8804497 C10.4185257,39.9563159 10.3161889,39.999 10.2094212,39.999 L7.13584526,39.999 C6.91493136,39.999 6.73584526,39.8199139 6.73584526,39.599 C6.73584526,39.4936017 6.77744443,39.3924627 6.85160121,39.3175656 L22.0763492,23.9408235 L22.0763492,23.9408235 L6.96554081,8.68044639 C6.81010226,8.52346929 6.81134951,8.27020637 6.9683266,8.11476782 C7.04322474,8.04060377 7.14436883,7.999 7.24977299,7.999 L10.3242852,7.999 C10.4310511,7.999 10.5333863,8.04168267 10.6085104,8.11754663 Z",
|
6136 | id: "CloseOutline-路径",
|
6137 | fill: "currentColor",
|
6138 | fillRule: "nonzero"
|
6139 | }))));
|
6140 | }
|
6141 | function DownFill(props) {
|
6142 | return React__namespace.createElement("svg", Object.assign({
|
6143 | width: "1em",
|
6144 | height: "1em",
|
6145 | viewBox: "0 0 48 48",
|
6146 | xmlns: "http://www.w3.org/2000/svg",
|
6147 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
6148 | }, props, {
|
6149 | style: Object.assign({
|
6150 | verticalAlign: "-0.125em"
|
6151 | }, props.style),
|
6152 | className: ["antd-mobile-icon", props.className].filter(Boolean).join(" ")
|
6153 | }), React__namespace.createElement("g", {
|
6154 | id: "DownFill-DownFill",
|
6155 | stroke: "none",
|
6156 | strokeWidth: 1,
|
6157 | fill: "none",
|
6158 | fillRule: "evenodd"
|
6159 | }, React__namespace.createElement("g", {
|
6160 | id: "DownFill-编组"
|
6161 | }, React__namespace.createElement("rect", {
|
6162 | id: "DownFill-矩形",
|
6163 | fill: "#FFFFFF",
|
6164 | opacity: 0,
|
6165 | x: 0,
|
6166 | y: 0,
|
6167 | width: 48,
|
6168 | height: 48
|
6169 | }), React__namespace.createElement("path", {
|
6170 | d: "M40.6640052,13 L7.34128264,13 C6.57572302,13 5.83336217,13.2619065 5.23947349,13.7351762 C3.80578911,14.8838891 3.58308085,16.9699517 4.74301968,18.3897608 L21.404381,38.7725222 C21.5528531,38.9517214 21.7152446,39.1171361 21.9008348,39.2641713 C23.3345192,40.4128842 25.4363283,40.1923313 26.6009069,38.7725222 L43.2576284,18.3897608 C43.740163,17.8016198 44,17.0664436 44,16.3082931 C44.004629,14.4795422 42.505988,13 40.6640052,13 Z",
|
6171 | id: "DownFill-路径",
|
6172 | fill: "currentColor",
|
6173 | fillRule: "nonzero"
|
6174 | }))));
|
6175 | }
|
6176 | function DownOutline(props) {
|
6177 | return React__namespace.createElement("svg", Object.assign({
|
6178 | width: "1em",
|
6179 | height: "1em",
|
6180 | viewBox: "0 0 48 48",
|
6181 | xmlns: "http://www.w3.org/2000/svg",
|
6182 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
6183 | }, props, {
|
6184 | style: Object.assign({
|
6185 | verticalAlign: "-0.125em"
|
6186 | }, props.style),
|
6187 | className: ["antd-mobile-icon", props.className].filter(Boolean).join(" ")
|
6188 | }), React__namespace.createElement("g", {
|
6189 | id: "DownOutline-DownOutline",
|
6190 | stroke: "none",
|
6191 | strokeWidth: 1,
|
6192 | fill: "none",
|
6193 | fillRule: "evenodd"
|
6194 | }, React__namespace.createElement("g", null, React__namespace.createElement("rect", {
|
6195 | id: "DownOutline-矩形",
|
6196 | fill: "#FFFFFF",
|
6197 | opacity: 0,
|
6198 | x: 0,
|
6199 | y: 0,
|
6200 | width: 48,
|
6201 | height: 48
|
6202 | }), React__namespace.createElement("path", {
|
6203 | d: "M5.11219264,16.3947957 L22.6612572,34.5767382 L22.6612572,34.5767382 C23.2125856,35.1304785 24.0863155,35.1630514 24.6755735,34.6744571 L24.7825775,34.5767382 L42.8834676,16.3956061 C42.9580998,16.320643 43,16.2191697 43,16.1133896 L43,12.9866673 C43,12.7657534 42.8209139,12.5866673 42.6,12.5866673 C42.4936115,12.5866673 42.391606,12.6290496 42.316542,12.7044413 L23.7816937,31.3201933 L23.7816937,31.3201933 L5.6866816,12.7237117 C5.53262122,12.5653818 5.27937888,12.5619207 5.121049,12.7159811 C5.04365775,12.7912854 5,12.8946805 5,13.0026627 L5,16.1170064 C5,16.2206403 5.04022164,16.3202292 5.11219264,16.3947957 Z",
|
6204 | id: "DownOutline-down",
|
6205 | fill: "currentColor",
|
6206 | fillRule: "nonzero"
|
6207 | }))));
|
6208 | }
|
6209 | function ExclamationCircleFill(props) {
|
6210 | return React__namespace.createElement("svg", Object.assign({
|
6211 | width: "1em",
|
6212 | height: "1em",
|
6213 | viewBox: "0 0 48 48",
|
6214 | xmlns: "http://www.w3.org/2000/svg",
|
6215 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
6216 | }, props, {
|
6217 | style: Object.assign({
|
6218 | verticalAlign: "-0.125em"
|
6219 | }, props.style),
|
6220 | className: ["antd-mobile-icon", props.className].filter(Boolean).join(" ")
|
6221 | }), React__namespace.createElement("g", {
|
6222 | id: "ExclamationCircleFill-ExclamationCircleFill",
|
6223 | stroke: "none",
|
6224 | strokeWidth: 1,
|
6225 | fill: "none",
|
6226 | fillRule: "evenodd"
|
6227 | }, React__namespace.createElement("g", null, React__namespace.createElement("rect", {
|
6228 | id: "ExclamationCircleFill-矩形",
|
6229 | fill: "#D76060",
|
6230 | opacity: 0,
|
6231 | x: 0,
|
6232 | y: 0,
|
6233 | width: 48,
|
6234 | height: 48
|
6235 | }), React__namespace.createElement("path", {
|
6236 | d: "M24,2 C36.1502645,2 46,11.8497355 46,24 C46,36.1502645 36.1502645,46 24,46 C11.8497355,46 2,36.1502645 2,24 C2,11.8497355 11.8497355,2 24,2 Z M25.1,31 L22.9,31 C22.6790861,31 22.5,31.1790861 22.5,31.4 L22.5,31.4 L22.5,33.6 C22.5,33.8209139 22.6790861,34 22.9,34 L22.9,34 L25.1,34 C25.3209139,34 25.5,33.8209139 25.5,33.6 L25.5,33.6 L25.5,31.4 C25.5,31.1790861 25.3209139,31 25.1,31 L25.1,31 Z M25.1,14 L22.9,14 C22.6790861,14 22.5,14.1790861 22.5,14.4 L22.5,14.4 L22.5,27.6 C22.5,27.8209139 22.6790861,28 22.9,28 L22.9,28 L25.1,28 C25.3209139,28 25.5,27.8209139 25.5,27.6 L25.5,27.6 L25.5,14.4 C25.5,14.1790861 25.3209139,14 25.1,14 L25.1,14 Z",
|
6237 | id: "ExclamationCircleFill-形状结合",
|
6238 | fill: "currentColor",
|
6239 | fillRule: "nonzero"
|
6240 | }))));
|
6241 | }
|
6242 | function InformationCircleFill(props) {
|
6243 | return React__namespace.createElement("svg", Object.assign({
|
6244 | width: "1em",
|
6245 | height: "1em",
|
6246 | viewBox: "0 0 48 48",
|
6247 | xmlns: "http://www.w3.org/2000/svg",
|
6248 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
6249 | }, props, {
|
6250 | style: Object.assign({
|
6251 | verticalAlign: "-0.125em"
|
6252 | }, props.style),
|
6253 | className: ["antd-mobile-icon", props.className].filter(Boolean).join(" ")
|
6254 | }), React__namespace.createElement("g", {
|
6255 | id: "InformationCircleFill-InformationCircleFill",
|
6256 | stroke: "none",
|
6257 | strokeWidth: 1,
|
6258 | fill: "none",
|
6259 | fillRule: "evenodd"
|
6260 | }, React__namespace.createElement("g", {
|
6261 | id: "InformationCircleFill-编组"
|
6262 | }, React__namespace.createElement("rect", {
|
6263 | id: "InformationCircleFill-矩形",
|
6264 | fill: "#FFFFFF",
|
6265 | opacity: 0,
|
6266 | x: 0,
|
6267 | y: 0,
|
6268 | width: 48,
|
6269 | height: 48
|
6270 | }), React__namespace.createElement("path", {
|
6271 | d: "M24,2 C36.1502645,2 46,11.8497355 46,24 C46,36.1502645 36.1502645,46 24,46 C11.8497355,46 2,36.1502645 2,24 C2,11.8497355 11.8497355,2 24,2 Z M25.6,20 L21.4,20 C21.1790861,20 21,20.1790861 21,20.4 L21,20.4 L21,22.6 C21,22.8209139 21.1790861,23 21.4,23 L21.4,23 L22.6,23 C22.8209139,23 23,23.1790861 23,23.4 L23,23.4 L23,34.6 C23,34.8209139 23.1790861,35 23.4,35 L23.4,35 L25.6,35 C25.8209139,35 26,34.8209139 26,34.6 L26,34.6 L26,20.4 C26,20.1790861 25.8209139,20 25.6,20 L25.6,20 Z M25.6,14 L23.4,14 C23.1790861,14 23,14.1790861 23,14.4 L23,14.4 L23,16.6 C23,16.8209139 23.1790861,17 23.4,17 L23.4,17 L25.6,17 C25.8209139,17 26,16.8209139 26,16.6 L26,16.6 L26,14.4 C26,14.1790861 25.8209139,14 25.6,14 L25.6,14 Z",
|
6272 | id: "InformationCircleFill-形状结合",
|
6273 | fill: "currentColor",
|
6274 | fillRule: "nonzero"
|
6275 | }))));
|
6276 | }
|
6277 | function LeftOutline(props) {
|
6278 | return React__namespace.createElement("svg", Object.assign({
|
6279 | width: "1em",
|
6280 | height: "1em",
|
6281 | viewBox: "0 0 48 48",
|
6282 | xmlns: "http://www.w3.org/2000/svg",
|
6283 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
6284 | }, props, {
|
6285 | style: Object.assign({
|
6286 | verticalAlign: "-0.125em"
|
6287 | }, props.style),
|
6288 | className: ["antd-mobile-icon", props.className].filter(Boolean).join(" ")
|
6289 | }), React__namespace.createElement("g", {
|
6290 | id: "LeftOutline-LeftOutline",
|
6291 | stroke: "none",
|
6292 | strokeWidth: 1,
|
6293 | fill: "none",
|
6294 | fillRule: "evenodd"
|
6295 | }, React__namespace.createElement("g", {
|
6296 | id: "LeftOutline-编组"
|
6297 | }, React__namespace.createElement("rect", {
|
6298 | id: "LeftOutline-矩形",
|
6299 | fill: "#FFFFFF",
|
6300 | opacity: 0,
|
6301 | x: 0,
|
6302 | y: 0,
|
6303 | width: 48,
|
6304 | height: 48
|
6305 | }), React__namespace.createElement("path", {
|
6306 | d: "M31.7053818,5.11219264 L13.5234393,22.6612572 L13.5234393,22.6612572 C12.969699,23.2125856 12.9371261,24.0863155 13.4257204,24.6755735 L13.5234393,24.7825775 L31.7045714,42.8834676 C31.7795345,42.9580998 31.8810078,43 31.9867879,43 L35.1135102,43 C35.3344241,43 35.5135102,42.8209139 35.5135102,42.6 C35.5135102,42.4936115 35.4711279,42.391606 35.3957362,42.316542 L16.7799842,23.7816937 L16.7799842,23.7816937 L35.3764658,5.6866816 C35.5347957,5.53262122 35.5382568,5.27937888 35.3841964,5.121049 C35.3088921,5.04365775 35.205497,5 35.0975148,5 L31.9831711,5 C31.8795372,5 31.7799483,5.04022164 31.7053818,5.11219264 Z",
|
6307 | id: "LeftOutline-路径",
|
6308 | fill: "currentColor",
|
6309 | fillRule: "nonzero"
|
6310 | }))));
|
6311 | }
|
6312 | function MinusOutline(props) {
|
6313 | return React__namespace.createElement("svg", Object.assign({
|
6314 | width: "1em",
|
6315 | height: "1em",
|
6316 | viewBox: "0 0 48 48",
|
6317 | xmlns: "http://www.w3.org/2000/svg",
|
6318 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
6319 | }, props, {
|
6320 | style: Object.assign({
|
6321 | verticalAlign: "-0.125em"
|
6322 | }, props.style),
|
6323 | className: ["antd-mobile-icon", props.className].filter(Boolean).join(" ")
|
6324 | }), React__namespace.createElement("g", {
|
6325 | id: "MinusOutline-MinusOutline",
|
6326 | stroke: "none",
|
6327 | strokeWidth: 1,
|
6328 | fill: "none",
|
6329 | fillRule: "evenodd"
|
6330 | }, React__namespace.createElement("g", {
|
6331 | id: "MinusOutline-add"
|
6332 | }, React__namespace.createElement("rect", {
|
6333 | id: "MinusOutline-矩形",
|
6334 | fill: "#FFFFFF",
|
6335 | opacity: 0,
|
6336 | x: 0,
|
6337 | y: 0,
|
6338 | width: 48,
|
6339 | height: 48
|
6340 | }), React__namespace.createElement("path", {
|
6341 | d: "M41.1,22.5 C41.3209139,22.5 41.5,22.6790861 41.5,22.9 L41.5,25.1 C41.5,25.3209139 41.3209139,25.5 41.1,25.5 L6.9,25.5 C6.6790861,25.5 6.5,25.3209139 6.5,25.1 L6.5,22.9 C6.5,22.6790861 6.6790861,22.5 6.9,22.5 L41.1,22.5 Z",
|
6342 | id: "MinusOutline-路径",
|
6343 | fill: "currentColor",
|
6344 | fillRule: "nonzero"
|
6345 | }))));
|
6346 | }
|
6347 | function QuestionCircleOutline(props) {
|
6348 | return React__namespace.createElement("svg", Object.assign({
|
6349 | width: "1em",
|
6350 | height: "1em",
|
6351 | viewBox: "0 0 48 48",
|
6352 | xmlns: "http://www.w3.org/2000/svg",
|
6353 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
6354 | }, props, {
|
6355 | style: Object.assign({
|
6356 | verticalAlign: "-0.125em"
|
6357 | }, props.style),
|
6358 | className: ["antd-mobile-icon", props.className].filter(Boolean).join(" ")
|
6359 | }), React__namespace.createElement("g", {
|
6360 | id: "QuestionCircleOutline-QuestionCircleOutline",
|
6361 | stroke: "none",
|
6362 | strokeWidth: 1,
|
6363 | fill: "none",
|
6364 | fillRule: "evenodd"
|
6365 | }, React__namespace.createElement("g", {
|
6366 | id: "QuestionCircleOutline-编组"
|
6367 | }, React__namespace.createElement("rect", {
|
6368 | id: "QuestionCircleOutline-矩形",
|
6369 | fill: "#FFFFFF",
|
6370 | opacity: 0,
|
6371 | x: 0,
|
6372 | y: 0,
|
6373 | width: 48,
|
6374 | height: 48
|
6375 | }), React__namespace.createElement("path", {
|
6376 | d: "M24,2 C36.1502645,2 46,11.8497355 46,24 C46,36.1502645 36.1502645,46 24,46 C11.8497355,46 2,36.1502645 2,24 C2,11.8497355 11.8497355,2 24,2 Z M24,5 C13.5065898,5 5,13.5065898 5,24 C5,34.4934102 13.5065898,43 24,43 C34.4934102,43 43,34.4934102 43,24 C43,13.5065898 34.4934102,5 24,5 Z M26,32.4 L26,34.6 C26,34.8209139 25.8209139,35 25.6,35 L23.4,35 C23.1790861,35 23,34.8209139 23,34.6 L23,32.4 C23,32.1790861 23.1790861,32 23.4,32 L25.6,32 C25.8209139,32 26,32.1790861 26,32.4 Z M24,12 C27.8659932,12 31,15.1340068 31,19 C31,22.1706393 28.8919961,24.8489278 26.0010432,25.7098107 L26.0001268,28.6 C25.9999299,28.8208643 25.8208644,28.9998731 25.6,29 L23.4,29 C23.1790861,29 23,28.8209139 23,28.6 L23,23.4 C23,23.1790861 23.1790861,23 23.4,23 L24,23 L24,23 C26.209139,23 28,21.209139 28,19 C28,16.790861 26.209139,15 24,15 C21.790861,15 20,16.790861 20,19 L17,19 C17,15.1340068 20.1340068,12 24,12 Z",
|
6377 | id: "QuestionCircleOutline-形状",
|
6378 | fill: "currentColor",
|
6379 | fillRule: "nonzero"
|
6380 | }))));
|
6381 | }
|
6382 | function RightOutline(props) {
|
6383 | return React__namespace.createElement("svg", Object.assign({
|
6384 | width: "1em",
|
6385 | height: "1em",
|
6386 | viewBox: "0 0 48 48",
|
6387 | xmlns: "http://www.w3.org/2000/svg",
|
6388 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
6389 | }, props, {
|
6390 | style: Object.assign({
|
6391 | verticalAlign: "-0.125em"
|
6392 | }, props.style),
|
6393 | className: ["antd-mobile-icon", props.className].filter(Boolean).join(" ")
|
6394 | }), React__namespace.createElement("g", {
|
6395 | id: "RightOutline-RightOutline",
|
6396 | stroke: "none",
|
6397 | strokeWidth: 1,
|
6398 | fill: "none",
|
6399 | fillRule: "evenodd"
|
6400 | }, React__namespace.createElement("g", {
|
6401 | id: "RightOutline-RightOutlined"
|
6402 | }, React__namespace.createElement("rect", {
|
6403 | id: "RightOutline-矩形",
|
6404 | fill: "#FFFFFF",
|
6405 | opacity: 0,
|
6406 | x: 0,
|
6407 | y: 0,
|
6408 | width: 48,
|
6409 | height: 48
|
6410 | }), React__namespace.createElement("path", {
|
6411 | d: "M17.3947957,5.11219264 L35.5767382,22.6612572 L35.5767382,22.6612572 C36.1304785,23.2125856 36.1630514,24.0863155 35.6744571,24.6755735 L35.5767382,24.7825775 L17.3956061,42.8834676 C17.320643,42.9580998 17.2191697,43 17.1133896,43 L13.9866673,43 C13.7657534,43 13.5866673,42.8209139 13.5866673,42.6 C13.5866673,42.4936115 13.6290496,42.391606 13.7044413,42.316542 L32.3201933,23.7816937 L32.3201933,23.7816937 L13.7237117,5.6866816 C13.5653818,5.53262122 13.5619207,5.27937888 13.7159811,5.121049 C13.7912854,5.04365775 13.8946805,5 14.0026627,5 L17.1170064,5 C17.2206403,5 17.3202292,5.04022164 17.3947957,5.11219264 Z",
|
6412 | id: "RightOutline-right",
|
6413 | fill: "currentColor",
|
6414 | fillRule: "nonzero"
|
6415 | }))));
|
6416 | }
|
6417 | function SearchOutline(props) {
|
6418 | return React__namespace.createElement("svg", Object.assign({
|
6419 | width: "1em",
|
6420 | height: "1em",
|
6421 | viewBox: "0 0 48 48",
|
6422 | xmlns: "http://www.w3.org/2000/svg",
|
6423 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
6424 | }, props, {
|
6425 | style: Object.assign({
|
6426 | verticalAlign: "-0.125em"
|
6427 | }, props.style),
|
6428 | className: ["antd-mobile-icon", props.className].filter(Boolean).join(" ")
|
6429 | }), React__namespace.createElement("g", {
|
6430 | id: "SearchOutline-SearchOutline",
|
6431 | stroke: "none",
|
6432 | strokeWidth: 1,
|
6433 | fill: "none",
|
6434 | fillRule: "evenodd"
|
6435 | }, React__namespace.createElement("g", {
|
6436 | id: "SearchOutline-编组"
|
6437 | }, React__namespace.createElement("rect", {
|
6438 | id: "SearchOutline-矩形",
|
6439 | fill: "#FFFFFF",
|
6440 | opacity: 0,
|
6441 | x: 0,
|
6442 | y: 0,
|
6443 | width: 48,
|
6444 | height: 48
|
6445 | }), React__namespace.createElement("path", {
|
6446 | d: "M10.2434135,10.1505371 C17.2346315,3.28315429 28.5696354,3.28315429 35.5608534,10.1505371 C42.3159331,16.7859644 42.5440954,27.4048667 36.2453405,34.3093889 L43.7095294,41.6422249 C43.8671196,41.7970419 43.8693677,42.0502979 43.7145508,42.2078881 C43.7128864,42.2095822 43.7112069,42.2112616 43.7095126,42.2129259 L42.1705322,43.7246464 C42.014915,43.8775072 41.7655181,43.8775006 41.6099089,43.7246316 L34.0775268,36.3248916 L34.0775268,36.3248916 C27.0485579,41.8551751 16.7593545,41.4200547 10.2434135,35.0195303 C3.25219551,28.1521474 3.25219551,17.0179199 10.2434135,10.1505371 Z M12.3532001,12.2229532 C6.52718516,17.9457722 6.52718516,27.2242951 12.3532001,32.9471142 C18.1792151,38.6699332 27.6250517,38.6699332 33.4510667,32.9471142 C39.2770817,27.2242951 39.2770817,17.9457722 33.4510667,12.2229532 C27.6250517,6.50013419 18.1792151,6.50013419 12.3532001,12.2229532 Z",
|
6447 | id: "SearchOutline-形状",
|
6448 | fill: "currentColor",
|
6449 | fillRule: "nonzero"
|
6450 | }))));
|
6451 | }
|
6452 | function SoundOutline(props) {
|
6453 | return React__namespace.createElement("svg", Object.assign({
|
6454 | width: "1em",
|
6455 | height: "1em",
|
6456 | viewBox: "0 0 48 48",
|
6457 | xmlns: "http://www.w3.org/2000/svg",
|
6458 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
6459 | }, props, {
|
6460 | style: Object.assign({
|
6461 | verticalAlign: "-0.125em"
|
6462 | }, props.style),
|
6463 | className: ["antd-mobile-icon", props.className].filter(Boolean).join(" ")
|
6464 | }), React__namespace.createElement("g", {
|
6465 | id: "SoundOutline-SoundOutline",
|
6466 | stroke: "none",
|
6467 | strokeWidth: 1,
|
6468 | fill: "none",
|
6469 | fillRule: "evenodd"
|
6470 | }, React__namespace.createElement("g", {
|
6471 | id: "SoundOutline-编组"
|
6472 | }, React__namespace.createElement("rect", {
|
6473 | id: "SoundOutline-矩形",
|
6474 | fill: "#FFFFFF",
|
6475 | opacity: 0,
|
6476 | x: 0,
|
6477 | y: 0,
|
6478 | width: 48,
|
6479 | height: 48
|
6480 | }), React__namespace.createElement("path", {
|
6481 | d: "M28.267333,7.42364522 C28.6217345,7.94869119 28.8108515,8.56559899 28.8108515,9.19662571 L28.8108515,38.803714 C28.8108515,40.568974 27.3619563,42 25.5746535,42 C24.9357472,42 24.311136,41.8132153 23.7795338,41.4631847 L13.5176584,34.7058449 L8.3149307,34.706256 C5.93186028,34.706256 4,32.7982213 4,30.4445413 L4,17.6593971 C4,15.3057171 5.93186028,13.3976824 8.3149307,13.3976824 L13.3601634,13.3972713 L23.7795338,6.53715498 C25.2666597,5.55796489 27.2759158,5.95486009 28.267333,7.42364522 Z M40.4649231,8.99868666 C40.5511218,9.17742383 40.619996,9.32223121 40.6715457,9.43310881 C42.8085201,14.0295034 44,19.1437027 44,24.532755 C44,29.7837404 42.8687892,34.7737758 40.8339269,39.2781083 C40.7469512,39.4706362 40.6237802,39.7330988 40.4644141,40.0654961 C40.3689469,40.2647533 40.1300031,40.3488277 39.9307715,40.2533072 C39.9306414,40.2532448 39.9305113,40.2531824 39.9303812,40.2531198 C39.6706542,40.1282492 39.4751102,40.0342363 39.3437492,39.9710811 C38.9410401,39.777468 38.6130663,39.619786 38.3598279,39.498035 C38.2070716,39.4245934 38.0007263,39.3253875 37.740792,39.2004172 C37.5419104,39.104853 37.4580092,38.8662856 37.5532468,38.6672473 C37.7034937,38.3532445 37.8197479,38.104744 37.9020095,37.9217457 C39.7416376,33.8293278 40.763802,29.2989389 40.763802,24.532755 C40.763802,19.6931433 39.7099001,15.0966478 37.8164042,10.9549334 C37.7526807,10.8155487 37.6652043,10.6300308 37.5539748,10.3983796 C37.4585265,10.1993116 37.5423279,9.96050973 37.7412949,9.8648511 C37.9298799,9.7741839 38.0818373,9.70112639 38.1971671,9.64567856 C38.5403397,9.48068928 39.0100918,9.2548436 39.6064234,8.9681415 C39.6867211,8.9295363 39.7949893,8.87748349 39.9312282,8.81198307 C40.1301627,8.71623553 40.3690201,8.79982709 40.4649231,8.99868666 Z M24.954689,9.60481048 L14.4401642,16.5275765 C14.3748695,16.5705665 14.2984086,16.5934809 14.2202323,16.5934873 L8.3149307,16.5939685 L8.3149307,16.5939685 C7.76171792,16.5939685 7.30576856,17.0052668 7.24345545,17.5351457 L7.23619803,17.6593971 L7.23619803,30.4445413 C7.23619803,30.9909313 7.65263219,31.4412574 8.18892037,31.502802 L8.31467178,31.50997 L14.3775506,31.5094909 C14.4557573,31.5094847 14.5322502,31.5324045 14.5975676,31.5754153 L24.9546682,38.39546 C25.139173,38.5169545 25.3872345,38.4658746 25.508729,38.2813698 C25.5517339,38.2160614 25.5746535,38.1395804 25.5746535,38.0613845 L25.5746535,9.93889975 C25.5746535,9.71798585 25.3955674,9.53889975 25.1746535,9.53889975 C25.0964661,9.53889975 25.019993,9.56181436 24.954689,9.60481048 Z M34.6436115,11.798648 C34.7547335,12.030794 34.8419854,12.2167889 34.9053671,12.3566328 C36.590502,16.0746763 37.5276039,20.1956294 37.5276039,24.532755 C37.5276039,28.7641394 36.635639,32.7897635 35.0272837,36.4362183 C34.9380427,36.6385449 34.8101552,36.9146706 34.6436211,37.2645952 C34.5486602,37.4640326 34.3100191,37.5487723 34.1105639,37.4538487 C34.1101091,37.4536323 34.1096547,37.453415 34.1092007,37.4531968 C33.9190573,37.3618222 33.7721424,37.2912213 33.6684561,37.2413942 C33.186467,37.0097713 32.80073,36.824403 32.5112451,36.6852892 C32.3647538,36.6148919 32.1675294,36.5201144 31.9195719,36.4009569 C31.7210538,36.3055358 31.6370188,36.067582 31.7316042,35.8686644 C31.8690322,35.5796464 31.9753727,35.3500122 32.0506255,35.1797617 C33.4919206,31.9190071 34.2914059,28.3180945 34.2914059,24.532755 C34.2914059,20.6930477 33.46879,17.0431031 31.9881259,13.7454591 C31.9261905,13.6075203 31.840749,13.424362 31.7318014,13.1959842 C31.636885,12.9969991 31.7208632,12.7587263 31.919573,12.6632348 C32.0929373,12.5799233 32.2332164,12.5125112 32.3404102,12.4609985 C32.6888449,12.2935556 33.1655706,12.0644616 33.7705875,11.7737163 C33.8540198,11.7336223 33.9670458,11.6793068 34.1096655,11.6107699 C34.3087736,11.5152168 34.5476881,11.5990382 34.6433466,11.7980956 C34.643435,11.7982797 34.6435233,11.7984638 34.6436115,11.798648 Z",
|
6482 | id: "SoundOutline-形状",
|
6483 | fill: "currentColor",
|
6484 | fillRule: "nonzero"
|
6485 | }))));
|
6486 | }
|
6487 | function TextDeletionOutline(props) {
|
6488 | return React__namespace.createElement("svg", Object.assign({
|
6489 | width: "1em",
|
6490 | height: "1em",
|
6491 | viewBox: "0 0 48 48",
|
6492 | xmlns: "http://www.w3.org/2000/svg",
|
6493 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
6494 | }, props, {
|
6495 | style: Object.assign({
|
6496 | verticalAlign: "-0.125em"
|
6497 | }, props.style),
|
6498 | className: ["antd-mobile-icon", props.className].filter(Boolean).join(" ")
|
6499 | }), React__namespace.createElement("g", {
|
6500 | id: "TextDeletionOutline-TextDeletionOutline",
|
6501 | stroke: "none",
|
6502 | strokeWidth: 1,
|
6503 | fill: "none",
|
6504 | fillRule: "evenodd"
|
6505 | }, React__namespace.createElement("g", {
|
6506 | id: "TextDeletionOutline-编组"
|
6507 | }, React__namespace.createElement("rect", {
|
6508 | id: "TextDeletionOutline-矩形",
|
6509 | fill: "#FFFFFF",
|
6510 | opacity: 0,
|
6511 | x: 0,
|
6512 | y: 0,
|
6513 | width: 48,
|
6514 | height: 48
|
6515 | }), React__namespace.createElement("path", {
|
6516 | d: "M38.5492302,6 C41.5596051,6 44,8.46240906 44,11.499981 L44,35.5 C44,38.5375742 41.5596051,41.000013 38.54923,41.000013 L17.3058462,41.000013 C14.6665152,41.000013 12.2347138,39.555982 10.9529738,37.2279238 L4.91451284,27.0612608 C3.6951623,24.8464932 3.6951623,22.1535354 4.91451335,19.9387516 L10.9529743,9.77208856 C12.234697,7.44403098 14.6665154,6 17.3058464,6 L38.5492302,6 Z M38.5492273,8.74994707 L17.3058465,8.74994707 C15.7329163,8.74994707 14.2719651,9.57120176 13.4439762,10.9206455 L13.3349608,11.1076457 L7.29739408,21.2743087 C6.57566975,22.5850072 6.53495505,24.1690434 7.18837846,25.5157286 L7.29739386,25.7265623 L13.3349605,35.8932253 C14.0992225,37.2803788 15.5202936,38.1698544 17.0914483,38.2444783 L17.3058454,38.2499783 L38.5492292,38.2499783 C39.9923716,38.2499783 41.1854088,37.114979 41.2700704,35.6613101 L41.2746127,35.4999769 L41.2746127,11.4999513 C41.2746127,10.0436198 40.1496291,8.83987037 38.7089651,8.75452144 L38.5492273,8.74994707 Z M22.3492842,17 C22.4547968,17 22.556036,17.0416892 22.6309531,17.1159883 L26.757,21.208 L30.8830469,17.1159883 C30.957964,17.0416892 31.0592032,17 31.1647158,17 L34.2719196,17 C34.4928335,17 34.6719196,17.1790861 34.6719196,17.4 C34.6719196,17.5067321 34.6292639,17.6090378 34.5534423,17.6841566 L28.879,23.306 L34.8245071,29.1968543 C34.9814364,29.3523411 34.9826059,29.6056044 34.8271191,29.7625337 C34.7520011,29.8383486 34.6497001,29.881 34.5429734,29.881 L31.4366959,29.881 C31.331195,29.881 31.2299662,29.8393201 31.1550512,29.7650357 L26.758,25.405 L22.3599432,29.7650669 C22.2850309,29.8393322 22.1838155,29.881 22.07833,29.881 L18.9720266,29.881 C18.7511127,29.881 18.5720266,29.7019139 18.5720266,29.481 C18.5720266,29.3742733 18.614678,29.2719723 18.6904929,29.1968543 L24.636,23.306 L18.9624269,17.6841345 C18.8055037,17.5286415 18.8043444,17.2753782 18.9598374,17.118455 C19.0349545,17.042647 19.1372506,17 19.2439719,17 L22.3492842,17 Z",
|
6517 | id: "TextDeletionOutline-形状结合",
|
6518 | fill: "currentColor",
|
6519 | fillRule: "nonzero"
|
6520 | }))));
|
6521 | }
|
6522 | const defaultPopupBaseProps = {
|
6523 | closeOnMaskClick: false,
|
6524 | closeIcon: React$1.createElement(CloseOutline, null),
|
6525 | destroyOnClose: false,
|
6526 | disableBodyScroll: true,
|
6527 | forceRender: false,
|
6528 | getContainer: () => document.body,
|
6529 | mask: true,
|
6530 | showCloseButton: false,
|
6531 | stopPropagation: ["click"],
|
6532 | visible: false
|
6533 | };
|
6534 | function useInnerVisible(outerVisible) {
|
6535 | const [innerVisible, setInnerVisible] = React$1.useState(outerVisible);
|
6536 | useIsomorphicLayoutEffect$2(() => {
|
6537 | setInnerVisible(outerVisible);
|
6538 | }, [outerVisible]);
|
6539 | return innerVisible;
|
6540 | }
|
6541 | function clamp$1(v, min2, max2) {
|
6542 | return Math.max(min2, Math.min(v, max2));
|
6543 | }
|
6544 | const V = {
|
6545 | toVector(v, fallback) {
|
6546 | if (v === void 0)
|
6547 | v = fallback;
|
6548 | return Array.isArray(v) ? v : [v, v];
|
6549 | },
|
6550 | add(v1, v2) {
|
6551 | return [v1[0] + v2[0], v1[1] + v2[1]];
|
6552 | },
|
6553 | sub(v1, v2) {
|
6554 | return [v1[0] - v2[0], v1[1] - v2[1]];
|
6555 | },
|
6556 | addTo(v1, v2) {
|
6557 | v1[0] += v2[0];
|
6558 | v1[1] += v2[1];
|
6559 | },
|
6560 | subTo(v1, v2) {
|
6561 | v1[0] -= v2[0];
|
6562 | v1[1] -= v2[1];
|
6563 | }
|
6564 | };
|
6565 | function rubberband$1(distance, dimension, constant) {
|
6566 | if (dimension === 0 || Math.abs(dimension) === Infinity)
|
6567 | return Math.pow(distance, constant * 5);
|
6568 | return distance * dimension * constant / (dimension + constant * distance);
|
6569 | }
|
6570 | function rubberbandIfOutOfBounds$1(position, min2, max2, constant = 0.15) {
|
6571 | if (constant === 0)
|
6572 | return clamp$1(position, min2, max2);
|
6573 | if (position < min2)
|
6574 | return -rubberband$1(min2 - position, max2 - min2, constant) + min2;
|
6575 | if (position > max2)
|
6576 | return +rubberband$1(position - max2, max2 - min2, constant) + max2;
|
6577 | return position;
|
6578 | }
|
6579 | function computeRubberband(bounds, [Vx, Vy], [Rx, Ry]) {
|
6580 | const [[X0, X1], [Y0, Y1]] = bounds;
|
6581 | return [rubberbandIfOutOfBounds$1(Vx, X0, X1, Rx), rubberbandIfOutOfBounds$1(Vy, Y0, Y1, Ry)];
|
6582 | }
|
6583 | function _toPrimitive$1(input, hint) {
|
6584 | if (typeof input !== "object" || input === null)
|
6585 | return input;
|
6586 | var prim = input[Symbol.toPrimitive];
|
6587 | if (prim !== void 0) {
|
6588 | var res = prim.call(input, hint || "default");
|
6589 | if (typeof res !== "object")
|
6590 | return res;
|
6591 | throw new TypeError("@@toPrimitive must return a primitive value.");
|
6592 | }
|
6593 | return (hint === "string" ? String : Number)(input);
|
6594 | }
|
6595 | function _toPropertyKey$1(arg) {
|
6596 | var key = _toPrimitive$1(arg, "string");
|
6597 | return typeof key === "symbol" ? key : String(key);
|
6598 | }
|
6599 | function _defineProperty$1(obj, key, value) {
|
6600 | key = _toPropertyKey$1(key);
|
6601 | if (key in obj) {
|
6602 | Object.defineProperty(obj, key, {
|
6603 | value,
|
6604 | enumerable: true,
|
6605 | configurable: true,
|
6606 | writable: true
|
6607 | });
|
6608 | } else {
|
6609 | obj[key] = value;
|
6610 | }
|
6611 | return obj;
|
6612 | }
|
6613 | function ownKeys$1(e2, r) {
|
6614 | var t = Object.keys(e2);
|
6615 | if (Object.getOwnPropertySymbols) {
|
6616 | var o = Object.getOwnPropertySymbols(e2);
|
6617 | r && (o = o.filter(function(r2) {
|
6618 | return Object.getOwnPropertyDescriptor(e2, r2).enumerable;
|
6619 | })), t.push.apply(t, o);
|
6620 | }
|
6621 | return t;
|
6622 | }
|
6623 | function _objectSpread2$1(e2) {
|
6624 | for (var r = 1; r < arguments.length; r++) {
|
6625 | var t = null != arguments[r] ? arguments[r] : {};
|
6626 | r % 2 ? ownKeys$1(Object(t), true).forEach(function(r2) {
|
6627 | _defineProperty$1(e2, r2, t[r2]);
|
6628 | }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function(r2) {
|
6629 | Object.defineProperty(e2, r2, Object.getOwnPropertyDescriptor(t, r2));
|
6630 | });
|
6631 | }
|
6632 | return e2;
|
6633 | }
|
6634 | const EVENT_TYPE_MAP = {
|
6635 | pointer: {
|
6636 | start: "down",
|
6637 | change: "move",
|
6638 | end: "up"
|
6639 | },
|
6640 | mouse: {
|
6641 | start: "down",
|
6642 | change: "move",
|
6643 | end: "up"
|
6644 | },
|
6645 | touch: {
|
6646 | start: "start",
|
6647 | change: "move",
|
6648 | end: "end"
|
6649 | },
|
6650 | gesture: {
|
6651 | start: "start",
|
6652 | change: "change",
|
6653 | end: "end"
|
6654 | }
|
6655 | };
|
6656 | function capitalize(string2) {
|
6657 | if (!string2)
|
6658 | return "";
|
6659 | return string2[0].toUpperCase() + string2.slice(1);
|
6660 | }
|
6661 | const actionsWithoutCaptureSupported = ["enter", "leave"];
|
6662 | function hasCapture(capture = false, actionKey) {
|
6663 | return capture && !actionsWithoutCaptureSupported.includes(actionKey);
|
6664 | }
|
6665 | function toHandlerProp(device, action = "", capture = false) {
|
6666 | const deviceProps = EVENT_TYPE_MAP[device];
|
6667 | const actionKey = deviceProps ? deviceProps[action] || action : action;
|
6668 | return "on" + capitalize(device) + capitalize(actionKey) + (hasCapture(capture, actionKey) ? "Capture" : "");
|
6669 | }
|
6670 | const pointerCaptureEvents = ["gotpointercapture", "lostpointercapture"];
|
6671 | function parseProp(prop) {
|
6672 | let eventKey = prop.substring(2).toLowerCase();
|
6673 | const passive = !!~eventKey.indexOf("passive");
|
6674 | if (passive)
|
6675 | eventKey = eventKey.replace("passive", "");
|
6676 | const captureKey = pointerCaptureEvents.includes(eventKey) ? "capturecapture" : "capture";
|
6677 | const capture = !!~eventKey.indexOf(captureKey);
|
6678 | if (capture)
|
6679 | eventKey = eventKey.replace("capture", "");
|
6680 | return {
|
6681 | device: eventKey,
|
6682 | capture,
|
6683 | passive
|
6684 | };
|
6685 | }
|
6686 | function toDomEventType(device, action = "") {
|
6687 | const deviceProps = EVENT_TYPE_MAP[device];
|
6688 | const actionKey = deviceProps ? deviceProps[action] || action : action;
|
6689 | return device + actionKey;
|
6690 | }
|
6691 | function isTouch(event) {
|
6692 | return "touches" in event;
|
6693 | }
|
6694 | function getPointerType(event) {
|
6695 | if (isTouch(event))
|
6696 | return "touch";
|
6697 | if ("pointerType" in event)
|
6698 | return event.pointerType;
|
6699 | return "mouse";
|
6700 | }
|
6701 | function getCurrentTargetTouchList(event) {
|
6702 | return Array.from(event.touches).filter((e2) => {
|
6703 | var _event$currentTarget, _event$currentTarget$;
|
6704 | return e2.target === event.currentTarget || ((_event$currentTarget = event.currentTarget) === null || _event$currentTarget === void 0 || (_event$currentTarget$ = _event$currentTarget.contains) === null || _event$currentTarget$ === void 0 ? void 0 : _event$currentTarget$.call(_event$currentTarget, e2.target));
|
6705 | });
|
6706 | }
|
6707 | function getTouchList(event) {
|
6708 | return event.type === "touchend" || event.type === "touchcancel" ? event.changedTouches : event.targetTouches;
|
6709 | }
|
6710 | function getValueEvent(event) {
|
6711 | return isTouch(event) ? getTouchList(event)[0] : event;
|
6712 | }
|
6713 | function distanceAngle(P1, P2) {
|
6714 | try {
|
6715 | const dx = P2.clientX - P1.clientX;
|
6716 | const dy = P2.clientY - P1.clientY;
|
6717 | const cx = (P2.clientX + P1.clientX) / 2;
|
6718 | const cy = (P2.clientY + P1.clientY) / 2;
|
6719 | const distance = Math.hypot(dx, dy);
|
6720 | const angle = -(Math.atan2(dx, dy) * 180) / Math.PI;
|
6721 | const origin = [cx, cy];
|
6722 | return {
|
6723 | angle,
|
6724 | distance,
|
6725 | origin
|
6726 | };
|
6727 | } catch (_unused) {
|
6728 | }
|
6729 | return null;
|
6730 | }
|
6731 | function touchIds(event) {
|
6732 | return getCurrentTargetTouchList(event).map((touch) => touch.identifier);
|
6733 | }
|
6734 | function touchDistanceAngle(event, ids) {
|
6735 | const [P1, P2] = Array.from(event.touches).filter((touch) => ids.includes(touch.identifier));
|
6736 | return distanceAngle(P1, P2);
|
6737 | }
|
6738 | function pointerId(event) {
|
6739 | const valueEvent = getValueEvent(event);
|
6740 | return isTouch(event) ? valueEvent.identifier : valueEvent.pointerId;
|
6741 | }
|
6742 | function pointerValues(event) {
|
6743 | const valueEvent = getValueEvent(event);
|
6744 | return [valueEvent.clientX, valueEvent.clientY];
|
6745 | }
|
6746 | const LINE_HEIGHT = 40;
|
6747 | const PAGE_HEIGHT = 800;
|
6748 | function wheelValues(event) {
|
6749 | let {
|
6750 | deltaX,
|
6751 | deltaY,
|
6752 | deltaMode
|
6753 | } = event;
|
6754 | if (deltaMode === 1) {
|
6755 | deltaX *= LINE_HEIGHT;
|
6756 | deltaY *= LINE_HEIGHT;
|
6757 | } else if (deltaMode === 2) {
|
6758 | deltaX *= PAGE_HEIGHT;
|
6759 | deltaY *= PAGE_HEIGHT;
|
6760 | }
|
6761 | return [deltaX, deltaY];
|
6762 | }
|
6763 | function getEventDetails(event) {
|
6764 | const payload = {};
|
6765 | if ("buttons" in event)
|
6766 | payload.buttons = event.buttons;
|
6767 | if ("shiftKey" in event) {
|
6768 | const {
|
6769 | shiftKey,
|
6770 | altKey,
|
6771 | metaKey,
|
6772 | ctrlKey
|
6773 | } = event;
|
6774 | Object.assign(payload, {
|
6775 | shiftKey,
|
6776 | altKey,
|
6777 | metaKey,
|
6778 | ctrlKey
|
6779 | });
|
6780 | }
|
6781 | return payload;
|
6782 | }
|
6783 | function call$2(v, ...args) {
|
6784 | if (typeof v === "function") {
|
6785 | return v(...args);
|
6786 | } else {
|
6787 | return v;
|
6788 | }
|
6789 | }
|
6790 | function noop() {
|
6791 | }
|
6792 | function chain(...fns) {
|
6793 | if (fns.length === 0)
|
6794 | return noop;
|
6795 | if (fns.length === 1)
|
6796 | return fns[0];
|
6797 | return function() {
|
6798 | let result;
|
6799 | for (const fn of fns) {
|
6800 | result = fn.apply(this, arguments) || result;
|
6801 | }
|
6802 | return result;
|
6803 | };
|
6804 | }
|
6805 | function assignDefault(value, fallback) {
|
6806 | return Object.assign({}, fallback, value || {});
|
6807 | }
|
6808 | const BEFORE_LAST_KINEMATICS_DELAY = 32;
|
6809 | class Engine {
|
6810 | constructor(ctrl, args, key) {
|
6811 | this.ctrl = ctrl;
|
6812 | this.args = args;
|
6813 | this.key = key;
|
6814 | if (!this.state) {
|
6815 | this.state = {};
|
6816 | this.computeValues([0, 0]);
|
6817 | this.computeInitial();
|
6818 | if (this.init)
|
6819 | this.init();
|
6820 | this.reset();
|
6821 | }
|
6822 | }
|
6823 | get state() {
|
6824 | return this.ctrl.state[this.key];
|
6825 | }
|
6826 | set state(state) {
|
6827 | this.ctrl.state[this.key] = state;
|
6828 | }
|
6829 | get shared() {
|
6830 | return this.ctrl.state.shared;
|
6831 | }
|
6832 | get eventStore() {
|
6833 | return this.ctrl.gestureEventStores[this.key];
|
6834 | }
|
6835 | get timeoutStore() {
|
6836 | return this.ctrl.gestureTimeoutStores[this.key];
|
6837 | }
|
6838 | get config() {
|
6839 | return this.ctrl.config[this.key];
|
6840 | }
|
6841 | get sharedConfig() {
|
6842 | return this.ctrl.config.shared;
|
6843 | }
|
6844 | get handler() {
|
6845 | return this.ctrl.handlers[this.key];
|
6846 | }
|
6847 | reset() {
|
6848 | const {
|
6849 | state,
|
6850 | shared,
|
6851 | ingKey,
|
6852 | args
|
6853 | } = this;
|
6854 | shared[ingKey] = state._active = state.active = state._blocked = state._force = false;
|
6855 | state._step = [false, false];
|
6856 | state.intentional = false;
|
6857 | state._movement = [0, 0];
|
6858 | state._distance = [0, 0];
|
6859 | state._direction = [0, 0];
|
6860 | state._delta = [0, 0];
|
6861 | state._bounds = [[-Infinity, Infinity], [-Infinity, Infinity]];
|
6862 | state.args = args;
|
6863 | state.axis = void 0;
|
6864 | state.memo = void 0;
|
6865 | state.elapsedTime = state.timeDelta = 0;
|
6866 | state.direction = [0, 0];
|
6867 | state.distance = [0, 0];
|
6868 | state.overflow = [0, 0];
|
6869 | state._movementBound = [false, false];
|
6870 | state.velocity = [0, 0];
|
6871 | state.movement = [0, 0];
|
6872 | state.delta = [0, 0];
|
6873 | state.timeStamp = 0;
|
6874 | }
|
6875 | start(event) {
|
6876 | const state = this.state;
|
6877 | const config2 = this.config;
|
6878 | if (!state._active) {
|
6879 | this.reset();
|
6880 | this.computeInitial();
|
6881 | state._active = true;
|
6882 | state.target = event.target;
|
6883 | state.currentTarget = event.currentTarget;
|
6884 | state.lastOffset = config2.from ? call$2(config2.from, state) : state.offset;
|
6885 | state.offset = state.lastOffset;
|
6886 | state.startTime = state.timeStamp = event.timeStamp;
|
6887 | }
|
6888 | }
|
6889 | computeValues(values) {
|
6890 | const state = this.state;
|
6891 | state._values = values;
|
6892 | state.values = this.config.transform(values);
|
6893 | }
|
6894 | computeInitial() {
|
6895 | const state = this.state;
|
6896 | state._initial = state._values;
|
6897 | state.initial = state.values;
|
6898 | }
|
6899 | compute(event) {
|
6900 | const {
|
6901 | state,
|
6902 | config: config2,
|
6903 | shared
|
6904 | } = this;
|
6905 | state.args = this.args;
|
6906 | let dt = 0;
|
6907 | if (event) {
|
6908 | state.event = event;
|
6909 | if (config2.preventDefault && event.cancelable)
|
6910 | state.event.preventDefault();
|
6911 | state.type = event.type;
|
6912 | shared.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size;
|
6913 | shared.locked = !!document.pointerLockElement;
|
6914 | Object.assign(shared, getEventDetails(event));
|
6915 | shared.down = shared.pressed = shared.buttons % 2 === 1 || shared.touches > 0;
|
6916 | dt = event.timeStamp - state.timeStamp;
|
6917 | state.timeStamp = event.timeStamp;
|
6918 | state.elapsedTime = state.timeStamp - state.startTime;
|
6919 | }
|
6920 | if (state._active) {
|
6921 | const _absoluteDelta = state._delta.map(Math.abs);
|
6922 | V.addTo(state._distance, _absoluteDelta);
|
6923 | }
|
6924 | if (this.axisIntent)
|
6925 | this.axisIntent(event);
|
6926 | const [_m0, _m1] = state._movement;
|
6927 | const [t0, t1] = config2.threshold;
|
6928 | const {
|
6929 | _step,
|
6930 | values
|
6931 | } = state;
|
6932 | if (config2.hasCustomTransform) {
|
6933 | if (_step[0] === false)
|
6934 | _step[0] = Math.abs(_m0) >= t0 && values[0];
|
6935 | if (_step[1] === false)
|
6936 | _step[1] = Math.abs(_m1) >= t1 && values[1];
|
6937 | } else {
|
6938 | if (_step[0] === false)
|
6939 | _step[0] = Math.abs(_m0) >= t0 && Math.sign(_m0) * t0;
|
6940 | if (_step[1] === false)
|
6941 | _step[1] = Math.abs(_m1) >= t1 && Math.sign(_m1) * t1;
|
6942 | }
|
6943 | state.intentional = _step[0] !== false || _step[1] !== false;
|
6944 | if (!state.intentional)
|
6945 | return;
|
6946 | const movement = [0, 0];
|
6947 | if (config2.hasCustomTransform) {
|
6948 | const [v0, v1] = values;
|
6949 | movement[0] = _step[0] !== false ? v0 - _step[0] : 0;
|
6950 | movement[1] = _step[1] !== false ? v1 - _step[1] : 0;
|
6951 | } else {
|
6952 | movement[0] = _step[0] !== false ? _m0 - _step[0] : 0;
|
6953 | movement[1] = _step[1] !== false ? _m1 - _step[1] : 0;
|
6954 | }
|
6955 | if (this.restrictToAxis && !state._blocked)
|
6956 | this.restrictToAxis(movement);
|
6957 | const previousOffset = state.offset;
|
6958 | const gestureIsActive = state._active && !state._blocked || state.active;
|
6959 | if (gestureIsActive) {
|
6960 | state.first = state._active && !state.active;
|
6961 | state.last = !state._active && state.active;
|
6962 | state.active = shared[this.ingKey] = state._active;
|
6963 | if (event) {
|
6964 | if (state.first) {
|
6965 | if ("bounds" in config2)
|
6966 | state._bounds = call$2(config2.bounds, state);
|
6967 | if (this.setup)
|
6968 | this.setup();
|
6969 | }
|
6970 | state.movement = movement;
|
6971 | this.computeOffset();
|
6972 | }
|
6973 | }
|
6974 | const [ox, oy] = state.offset;
|
6975 | const [[x0, x1], [y0, y1]] = state._bounds;
|
6976 | state.overflow = [ox < x0 ? -1 : ox > x1 ? 1 : 0, oy < y0 ? -1 : oy > y1 ? 1 : 0];
|
6977 | state._movementBound[0] = state.overflow[0] ? state._movementBound[0] === false ? state._movement[0] : state._movementBound[0] : false;
|
6978 | state._movementBound[1] = state.overflow[1] ? state._movementBound[1] === false ? state._movement[1] : state._movementBound[1] : false;
|
6979 | const rubberband2 = state._active ? config2.rubberband || [0, 0] : [0, 0];
|
6980 | state.offset = computeRubberband(state._bounds, state.offset, rubberband2);
|
6981 | state.delta = V.sub(state.offset, previousOffset);
|
6982 | this.computeMovement();
|
6983 | if (gestureIsActive && (!state.last || dt > BEFORE_LAST_KINEMATICS_DELAY)) {
|
6984 | state.delta = V.sub(state.offset, previousOffset);
|
6985 | const absoluteDelta = state.delta.map(Math.abs);
|
6986 | V.addTo(state.distance, absoluteDelta);
|
6987 | state.direction = state.delta.map(Math.sign);
|
6988 | state._direction = state._delta.map(Math.sign);
|
6989 | if (!state.first && dt > 0) {
|
6990 | state.velocity = [absoluteDelta[0] / dt, absoluteDelta[1] / dt];
|
6991 | state.timeDelta = dt;
|
6992 | }
|
6993 | }
|
6994 | }
|
6995 | emit() {
|
6996 | const state = this.state;
|
6997 | const shared = this.shared;
|
6998 | const config2 = this.config;
|
6999 | if (!state._active)
|
7000 | this.clean();
|
7001 | if ((state._blocked || !state.intentional) && !state._force && !config2.triggerAllEvents)
|
7002 | return;
|
7003 | const memo = this.handler(_objectSpread2$1(_objectSpread2$1(_objectSpread2$1({}, shared), state), {}, {
|
7004 | [this.aliasKey]: state.values
|
7005 | }));
|
7006 | if (memo !== void 0)
|
7007 | state.memo = memo;
|
7008 | }
|
7009 | clean() {
|
7010 | this.eventStore.clean();
|
7011 | this.timeoutStore.clean();
|
7012 | }
|
7013 | }
|
7014 | function selectAxis([dx, dy], threshold) {
|
7015 | const absDx = Math.abs(dx);
|
7016 | const absDy = Math.abs(dy);
|
7017 | if (absDx > absDy && absDx > threshold) {
|
7018 | return "x";
|
7019 | }
|
7020 | if (absDy > absDx && absDy > threshold) {
|
7021 | return "y";
|
7022 | }
|
7023 | return void 0;
|
7024 | }
|
7025 | class CoordinatesEngine extends Engine {
|
7026 | constructor(...args) {
|
7027 | super(...args);
|
7028 | _defineProperty$1(this, "aliasKey", "xy");
|
7029 | }
|
7030 | reset() {
|
7031 | super.reset();
|
7032 | this.state.axis = void 0;
|
7033 | }
|
7034 | init() {
|
7035 | this.state.offset = [0, 0];
|
7036 | this.state.lastOffset = [0, 0];
|
7037 | }
|
7038 | computeOffset() {
|
7039 | this.state.offset = V.add(this.state.lastOffset, this.state.movement);
|
7040 | }
|
7041 | computeMovement() {
|
7042 | this.state.movement = V.sub(this.state.offset, this.state.lastOffset);
|
7043 | }
|
7044 | axisIntent(event) {
|
7045 | const state = this.state;
|
7046 | const config2 = this.config;
|
7047 | if (!state.axis && event) {
|
7048 | const threshold = typeof config2.axisThreshold === "object" ? config2.axisThreshold[getPointerType(event)] : config2.axisThreshold;
|
7049 | state.axis = selectAxis(state._movement, threshold);
|
7050 | }
|
7051 | state._blocked = (config2.lockDirection || !!config2.axis) && !state.axis || !!config2.axis && config2.axis !== state.axis;
|
7052 | }
|
7053 | restrictToAxis(v) {
|
7054 | if (this.config.axis || this.config.lockDirection) {
|
7055 | switch (this.state.axis) {
|
7056 | case "x":
|
7057 | v[1] = 0;
|
7058 | break;
|
7059 | case "y":
|
7060 | v[0] = 0;
|
7061 | break;
|
7062 | }
|
7063 | }
|
7064 | }
|
7065 | }
|
7066 | const identity = (v) => v;
|
7067 | const DEFAULT_RUBBERBAND = 0.15;
|
7068 | const commonConfigResolver = {
|
7069 | enabled(value = true) {
|
7070 | return value;
|
7071 | },
|
7072 | eventOptions(value, _k, config2) {
|
7073 | return _objectSpread2$1(_objectSpread2$1({}, config2.shared.eventOptions), value);
|
7074 | },
|
7075 | preventDefault(value = false) {
|
7076 | return value;
|
7077 | },
|
7078 | triggerAllEvents(value = false) {
|
7079 | return value;
|
7080 | },
|
7081 | rubberband(value = 0) {
|
7082 | switch (value) {
|
7083 | case true:
|
7084 | return [DEFAULT_RUBBERBAND, DEFAULT_RUBBERBAND];
|
7085 | case false:
|
7086 | return [0, 0];
|
7087 | default:
|
7088 | return V.toVector(value);
|
7089 | }
|
7090 | },
|
7091 | from(value) {
|
7092 | if (typeof value === "function")
|
7093 | return value;
|
7094 | if (value != null)
|
7095 | return V.toVector(value);
|
7096 | },
|
7097 | transform(value, _k, config2) {
|
7098 | const transform = value || config2.shared.transform;
|
7099 | this.hasCustomTransform = !!transform;
|
7100 | {
|
7101 | const originalTransform = transform || identity;
|
7102 | return (v) => {
|
7103 | const r = originalTransform(v);
|
7104 | if (!isFinite(r[0]) || !isFinite(r[1])) {
|
7105 | console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${r[0]},${[1]}]`);
|
7106 | }
|
7107 | return r;
|
7108 | };
|
7109 | }
|
7110 | },
|
7111 | threshold(value) {
|
7112 | return V.toVector(value, 0);
|
7113 | }
|
7114 | };
|
7115 | {
|
7116 | Object.assign(commonConfigResolver, {
|
7117 | domTarget(value) {
|
7118 | if (value !== void 0) {
|
7119 | throw Error(`[@use-gesture]: \`domTarget\` option has been renamed to \`target\`.`);
|
7120 | }
|
7121 | return NaN;
|
7122 | },
|
7123 | lockDirection(value) {
|
7124 | if (value !== void 0) {
|
7125 | throw Error(`[@use-gesture]: \`lockDirection\` option has been merged with \`axis\`. Use it as in \`{ axis: 'lock' }\``);
|
7126 | }
|
7127 | return NaN;
|
7128 | },
|
7129 | initial(value) {
|
7130 | if (value !== void 0) {
|
7131 | throw Error(`[@use-gesture]: \`initial\` option has been renamed to \`from\`.`);
|
7132 | }
|
7133 | return NaN;
|
7134 | }
|
7135 | });
|
7136 | }
|
7137 | const DEFAULT_AXIS_THRESHOLD = 0;
|
7138 | const coordinatesConfigResolver = _objectSpread2$1(_objectSpread2$1({}, commonConfigResolver), {}, {
|
7139 | axis(_v, _k, {
|
7140 | axis
|
7141 | }) {
|
7142 | this.lockDirection = axis === "lock";
|
7143 | if (!this.lockDirection)
|
7144 | return axis;
|
7145 | },
|
7146 | axisThreshold(value = DEFAULT_AXIS_THRESHOLD) {
|
7147 | return value;
|
7148 | },
|
7149 | bounds(value = {}) {
|
7150 | if (typeof value === "function") {
|
7151 | return (state) => coordinatesConfigResolver.bounds(value(state));
|
7152 | }
|
7153 | if ("current" in value) {
|
7154 | return () => value.current;
|
7155 | }
|
7156 | if (typeof HTMLElement === "function" && value instanceof HTMLElement) {
|
7157 | return value;
|
7158 | }
|
7159 | const {
|
7160 | left = -Infinity,
|
7161 | right = Infinity,
|
7162 | top = -Infinity,
|
7163 | bottom = Infinity
|
7164 | } = value;
|
7165 | return [[left, right], [top, bottom]];
|
7166 | }
|
7167 | });
|
7168 | const KEYS_DELTA_MAP = {
|
7169 | ArrowRight: (displacement, factor = 1) => [displacement * factor, 0],
|
7170 | ArrowLeft: (displacement, factor = 1) => [-1 * displacement * factor, 0],
|
7171 | ArrowUp: (displacement, factor = 1) => [0, -1 * displacement * factor],
|
7172 | ArrowDown: (displacement, factor = 1) => [0, displacement * factor]
|
7173 | };
|
7174 | class DragEngine extends CoordinatesEngine {
|
7175 | constructor(...args) {
|
7176 | super(...args);
|
7177 | _defineProperty$1(this, "ingKey", "dragging");
|
7178 | }
|
7179 | reset() {
|
7180 | super.reset();
|
7181 | const state = this.state;
|
7182 | state._pointerId = void 0;
|
7183 | state._pointerActive = false;
|
7184 | state._keyboardActive = false;
|
7185 | state._preventScroll = false;
|
7186 | state._delayed = false;
|
7187 | state.swipe = [0, 0];
|
7188 | state.tap = false;
|
7189 | state.canceled = false;
|
7190 | state.cancel = this.cancel.bind(this);
|
7191 | }
|
7192 | setup() {
|
7193 | const state = this.state;
|
7194 | if (state._bounds instanceof HTMLElement) {
|
7195 | const boundRect = state._bounds.getBoundingClientRect();
|
7196 | const targetRect = state.currentTarget.getBoundingClientRect();
|
7197 | const _bounds = {
|
7198 | left: boundRect.left - targetRect.left + state.offset[0],
|
7199 | right: boundRect.right - targetRect.right + state.offset[0],
|
7200 | top: boundRect.top - targetRect.top + state.offset[1],
|
7201 | bottom: boundRect.bottom - targetRect.bottom + state.offset[1]
|
7202 | };
|
7203 | state._bounds = coordinatesConfigResolver.bounds(_bounds);
|
7204 | }
|
7205 | }
|
7206 | cancel() {
|
7207 | const state = this.state;
|
7208 | if (state.canceled)
|
7209 | return;
|
7210 | state.canceled = true;
|
7211 | state._active = false;
|
7212 | setTimeout(() => {
|
7213 | this.compute();
|
7214 | this.emit();
|
7215 | }, 0);
|
7216 | }
|
7217 | setActive() {
|
7218 | this.state._active = this.state._pointerActive || this.state._keyboardActive;
|
7219 | }
|
7220 | clean() {
|
7221 | this.pointerClean();
|
7222 | this.state._pointerActive = false;
|
7223 | this.state._keyboardActive = false;
|
7224 | super.clean();
|
7225 | }
|
7226 | pointerDown(event) {
|
7227 | const config2 = this.config;
|
7228 | const state = this.state;
|
7229 | if (event.buttons != null && (Array.isArray(config2.pointerButtons) ? !config2.pointerButtons.includes(event.buttons) : config2.pointerButtons !== -1 && config2.pointerButtons !== event.buttons))
|
7230 | return;
|
7231 | const ctrlIds = this.ctrl.setEventIds(event);
|
7232 | if (config2.pointerCapture) {
|
7233 | event.target.setPointerCapture(event.pointerId);
|
7234 | }
|
7235 | if (ctrlIds && ctrlIds.size > 1 && state._pointerActive)
|
7236 | return;
|
7237 | this.start(event);
|
7238 | this.setupPointer(event);
|
7239 | state._pointerId = pointerId(event);
|
7240 | state._pointerActive = true;
|
7241 | this.computeValues(pointerValues(event));
|
7242 | this.computeInitial();
|
7243 | if (config2.preventScrollAxis && getPointerType(event) !== "mouse") {
|
7244 | state._active = false;
|
7245 | this.setupScrollPrevention(event);
|
7246 | } else if (config2.delay > 0) {
|
7247 | this.setupDelayTrigger(event);
|
7248 | if (config2.triggerAllEvents) {
|
7249 | this.compute(event);
|
7250 | this.emit();
|
7251 | }
|
7252 | } else {
|
7253 | this.startPointerDrag(event);
|
7254 | }
|
7255 | }
|
7256 | startPointerDrag(event) {
|
7257 | const state = this.state;
|
7258 | state._active = true;
|
7259 | state._preventScroll = true;
|
7260 | state._delayed = false;
|
7261 | this.compute(event);
|
7262 | this.emit();
|
7263 | }
|
7264 | pointerMove(event) {
|
7265 | const state = this.state;
|
7266 | const config2 = this.config;
|
7267 | if (!state._pointerActive)
|
7268 | return;
|
7269 | const id = pointerId(event);
|
7270 | if (state._pointerId !== void 0 && id !== state._pointerId)
|
7271 | return;
|
7272 | const _values = pointerValues(event);
|
7273 | if (document.pointerLockElement === event.target) {
|
7274 | state._delta = [event.movementX, event.movementY];
|
7275 | } else {
|
7276 | state._delta = V.sub(_values, state._values);
|
7277 | this.computeValues(_values);
|
7278 | }
|
7279 | V.addTo(state._movement, state._delta);
|
7280 | this.compute(event);
|
7281 | if (state._delayed && state.intentional) {
|
7282 | this.timeoutStore.remove("dragDelay");
|
7283 | state.active = false;
|
7284 | this.startPointerDrag(event);
|
7285 | return;
|
7286 | }
|
7287 | if (config2.preventScrollAxis && !state._preventScroll) {
|
7288 | if (state.axis) {
|
7289 | if (state.axis === config2.preventScrollAxis || config2.preventScrollAxis === "xy") {
|
7290 | state._active = false;
|
7291 | this.clean();
|
7292 | return;
|
7293 | } else {
|
7294 | this.timeoutStore.remove("startPointerDrag");
|
7295 | this.startPointerDrag(event);
|
7296 | return;
|
7297 | }
|
7298 | } else {
|
7299 | return;
|
7300 | }
|
7301 | }
|
7302 | this.emit();
|
7303 | }
|
7304 | pointerUp(event) {
|
7305 | this.ctrl.setEventIds(event);
|
7306 | try {
|
7307 | if (this.config.pointerCapture && event.target.hasPointerCapture(event.pointerId)) {
|
7308 | ;
|
7309 | event.target.releasePointerCapture(event.pointerId);
|
7310 | }
|
7311 | } catch (_unused) {
|
7312 | {
|
7313 | console.warn(`[@use-gesture]: If you see this message, it's likely that you're using an outdated version of \`@react-three/fiber\`.
|
7314 |
|
7315 | Please upgrade to the latest version.`);
|
7316 | }
|
7317 | }
|
7318 | const state = this.state;
|
7319 | const config2 = this.config;
|
7320 | if (!state._active || !state._pointerActive)
|
7321 | return;
|
7322 | const id = pointerId(event);
|
7323 | if (state._pointerId !== void 0 && id !== state._pointerId)
|
7324 | return;
|
7325 | this.state._pointerActive = false;
|
7326 | this.setActive();
|
7327 | this.compute(event);
|
7328 | const [dx, dy] = state._distance;
|
7329 | state.tap = dx <= config2.tapsThreshold && dy <= config2.tapsThreshold;
|
7330 | if (state.tap && config2.filterTaps) {
|
7331 | state._force = true;
|
7332 | } else {
|
7333 | const [_dx, _dy] = state._delta;
|
7334 | const [_mx, _my] = state._movement;
|
7335 | const [svx, svy] = config2.swipe.velocity;
|
7336 | const [sx, sy] = config2.swipe.distance;
|
7337 | const sdt = config2.swipe.duration;
|
7338 | if (state.elapsedTime < sdt) {
|
7339 | const _vx = Math.abs(_dx / state.timeDelta);
|
7340 | const _vy = Math.abs(_dy / state.timeDelta);
|
7341 | if (_vx > svx && Math.abs(_mx) > sx)
|
7342 | state.swipe[0] = Math.sign(_dx);
|
7343 | if (_vy > svy && Math.abs(_my) > sy)
|
7344 | state.swipe[1] = Math.sign(_dy);
|
7345 | }
|
7346 | }
|
7347 | this.emit();
|
7348 | }
|
7349 | pointerClick(event) {
|
7350 | if (!this.state.tap && event.detail > 0) {
|
7351 | event.preventDefault();
|
7352 | event.stopPropagation();
|
7353 | }
|
7354 | }
|
7355 | setupPointer(event) {
|
7356 | const config2 = this.config;
|
7357 | const device = config2.device;
|
7358 | {
|
7359 | try {
|
7360 | if (device === "pointer" && config2.preventScrollDelay === void 0) {
|
7361 | const currentTarget = "uv" in event ? event.sourceEvent.currentTarget : event.currentTarget;
|
7362 | const style = window.getComputedStyle(currentTarget);
|
7363 | if (style.touchAction === "auto") {
|
7364 | console.warn(`[@use-gesture]: The drag target has its \`touch-action\` style property set to \`auto\`. It is recommended to add \`touch-action: 'none'\` so that the drag gesture behaves correctly on touch-enabled devices. For more information read this: https://use-gesture.netlify.app/docs/extras/#touch-action.
|
7365 |
|
7366 | This message will only show in development mode. It won't appear in production. If this is intended, you can ignore it.`, currentTarget);
|
7367 | }
|
7368 | }
|
7369 | } catch (_unused2) {
|
7370 | }
|
7371 | }
|
7372 | if (config2.pointerLock) {
|
7373 | event.currentTarget.requestPointerLock();
|
7374 | }
|
7375 | if (!config2.pointerCapture) {
|
7376 | this.eventStore.add(this.sharedConfig.window, device, "change", this.pointerMove.bind(this));
|
7377 | this.eventStore.add(this.sharedConfig.window, device, "end", this.pointerUp.bind(this));
|
7378 | this.eventStore.add(this.sharedConfig.window, device, "cancel", this.pointerUp.bind(this));
|
7379 | }
|
7380 | }
|
7381 | pointerClean() {
|
7382 | if (this.config.pointerLock && document.pointerLockElement === this.state.currentTarget) {
|
7383 | document.exitPointerLock();
|
7384 | }
|
7385 | }
|
7386 | preventScroll(event) {
|
7387 | if (this.state._preventScroll && event.cancelable) {
|
7388 | event.preventDefault();
|
7389 | }
|
7390 | }
|
7391 | setupScrollPrevention(event) {
|
7392 | this.state._preventScroll = false;
|
7393 | persistEvent(event);
|
7394 | const remove = this.eventStore.add(this.sharedConfig.window, "touch", "change", this.preventScroll.bind(this), {
|
7395 | passive: false
|
7396 | });
|
7397 | this.eventStore.add(this.sharedConfig.window, "touch", "end", remove);
|
7398 | this.eventStore.add(this.sharedConfig.window, "touch", "cancel", remove);
|
7399 | this.timeoutStore.add("startPointerDrag", this.startPointerDrag.bind(this), this.config.preventScrollDelay, event);
|
7400 | }
|
7401 | setupDelayTrigger(event) {
|
7402 | this.state._delayed = true;
|
7403 | this.timeoutStore.add("dragDelay", () => {
|
7404 | this.state._step = [0, 0];
|
7405 | this.startPointerDrag(event);
|
7406 | }, this.config.delay);
|
7407 | }
|
7408 | keyDown(event) {
|
7409 | const deltaFn = KEYS_DELTA_MAP[event.key];
|
7410 | if (deltaFn) {
|
7411 | const state = this.state;
|
7412 | const factor = event.shiftKey ? 10 : event.altKey ? 0.1 : 1;
|
7413 | this.start(event);
|
7414 | state._delta = deltaFn(this.config.keyboardDisplacement, factor);
|
7415 | state._keyboardActive = true;
|
7416 | V.addTo(state._movement, state._delta);
|
7417 | this.compute(event);
|
7418 | this.emit();
|
7419 | }
|
7420 | }
|
7421 | keyUp(event) {
|
7422 | if (!(event.key in KEYS_DELTA_MAP))
|
7423 | return;
|
7424 | this.state._keyboardActive = false;
|
7425 | this.setActive();
|
7426 | this.compute(event);
|
7427 | this.emit();
|
7428 | }
|
7429 | bind(bindFunction) {
|
7430 | const device = this.config.device;
|
7431 | bindFunction(device, "start", this.pointerDown.bind(this));
|
7432 | if (this.config.pointerCapture) {
|
7433 | bindFunction(device, "change", this.pointerMove.bind(this));
|
7434 | bindFunction(device, "end", this.pointerUp.bind(this));
|
7435 | bindFunction(device, "cancel", this.pointerUp.bind(this));
|
7436 | bindFunction("lostPointerCapture", "", this.pointerUp.bind(this));
|
7437 | }
|
7438 | if (this.config.keys) {
|
7439 | bindFunction("key", "down", this.keyDown.bind(this));
|
7440 | bindFunction("key", "up", this.keyUp.bind(this));
|
7441 | }
|
7442 | if (this.config.filterTaps) {
|
7443 | bindFunction("click", "", this.pointerClick.bind(this), {
|
7444 | capture: true,
|
7445 | passive: false
|
7446 | });
|
7447 | }
|
7448 | }
|
7449 | }
|
7450 | function persistEvent(event) {
|
7451 | "persist" in event && typeof event.persist === "function" && event.persist();
|
7452 | }
|
7453 | const isBrowser = typeof window !== "undefined" && window.document && window.document.createElement;
|
7454 | function supportsTouchEvents() {
|
7455 | return isBrowser && "ontouchstart" in window;
|
7456 | }
|
7457 | function isTouchScreen() {
|
7458 | return supportsTouchEvents() || isBrowser && window.navigator.maxTouchPoints > 1;
|
7459 | }
|
7460 | function supportsPointerEvents() {
|
7461 | return isBrowser && "onpointerdown" in window;
|
7462 | }
|
7463 | function supportsPointerLock() {
|
7464 | return isBrowser && "exitPointerLock" in window.document;
|
7465 | }
|
7466 | function supportsGestureEvents() {
|
7467 | try {
|
7468 | return "constructor" in GestureEvent;
|
7469 | } catch (e2) {
|
7470 | return false;
|
7471 | }
|
7472 | }
|
7473 | const SUPPORT = {
|
7474 | isBrowser,
|
7475 | gesture: supportsGestureEvents(),
|
7476 | touch: supportsTouchEvents(),
|
7477 | touchscreen: isTouchScreen(),
|
7478 | pointer: supportsPointerEvents(),
|
7479 | pointerLock: supportsPointerLock()
|
7480 | };
|
7481 | const DEFAULT_PREVENT_SCROLL_DELAY = 250;
|
7482 | const DEFAULT_DRAG_DELAY = 180;
|
7483 | const DEFAULT_SWIPE_VELOCITY = 0.5;
|
7484 | const DEFAULT_SWIPE_DISTANCE = 50;
|
7485 | const DEFAULT_SWIPE_DURATION = 250;
|
7486 | const DEFAULT_KEYBOARD_DISPLACEMENT = 10;
|
7487 | const DEFAULT_DRAG_AXIS_THRESHOLD = {
|
7488 | mouse: 0,
|
7489 | touch: 0,
|
7490 | pen: 8
|
7491 | };
|
7492 | const dragConfigResolver = _objectSpread2$1(_objectSpread2$1({}, coordinatesConfigResolver), {}, {
|
7493 | device(_v, _k, {
|
7494 | pointer: {
|
7495 | touch = false,
|
7496 | lock = false,
|
7497 | mouse = false
|
7498 | } = {}
|
7499 | }) {
|
7500 | this.pointerLock = lock && SUPPORT.pointerLock;
|
7501 | if (SUPPORT.touch && touch)
|
7502 | return "touch";
|
7503 | if (this.pointerLock)
|
7504 | return "mouse";
|
7505 | if (SUPPORT.pointer && !mouse)
|
7506 | return "pointer";
|
7507 | if (SUPPORT.touch)
|
7508 | return "touch";
|
7509 | return "mouse";
|
7510 | },
|
7511 | preventScrollAxis(value, _k, {
|
7512 | preventScroll
|
7513 | }) {
|
7514 | this.preventScrollDelay = typeof preventScroll === "number" ? preventScroll : preventScroll || preventScroll === void 0 && value ? DEFAULT_PREVENT_SCROLL_DELAY : void 0;
|
7515 | if (!SUPPORT.touchscreen || preventScroll === false)
|
7516 | return void 0;
|
7517 | return value ? value : preventScroll !== void 0 ? "y" : void 0;
|
7518 | },
|
7519 | pointerCapture(_v, _k, {
|
7520 | pointer: {
|
7521 | capture = true,
|
7522 | buttons = 1,
|
7523 | keys = true
|
7524 | } = {}
|
7525 | }) {
|
7526 | this.pointerButtons = buttons;
|
7527 | this.keys = keys;
|
7528 | return !this.pointerLock && this.device === "pointer" && capture;
|
7529 | },
|
7530 | threshold(value, _k, {
|
7531 | filterTaps = false,
|
7532 | tapsThreshold = 3,
|
7533 | axis = void 0
|
7534 | }) {
|
7535 | const threshold = V.toVector(value, filterTaps ? tapsThreshold : axis ? 1 : 0);
|
7536 | this.filterTaps = filterTaps;
|
7537 | this.tapsThreshold = tapsThreshold;
|
7538 | return threshold;
|
7539 | },
|
7540 | swipe({
|
7541 | velocity = DEFAULT_SWIPE_VELOCITY,
|
7542 | distance = DEFAULT_SWIPE_DISTANCE,
|
7543 | duration = DEFAULT_SWIPE_DURATION
|
7544 | } = {}) {
|
7545 | return {
|
7546 | velocity: this.transform(V.toVector(velocity)),
|
7547 | distance: this.transform(V.toVector(distance)),
|
7548 | duration
|
7549 | };
|
7550 | },
|
7551 | delay(value = 0) {
|
7552 | switch (value) {
|
7553 | case true:
|
7554 | return DEFAULT_DRAG_DELAY;
|
7555 | case false:
|
7556 | return 0;
|
7557 | default:
|
7558 | return value;
|
7559 | }
|
7560 | },
|
7561 | axisThreshold(value) {
|
7562 | if (!value)
|
7563 | return DEFAULT_DRAG_AXIS_THRESHOLD;
|
7564 | return _objectSpread2$1(_objectSpread2$1({}, DEFAULT_DRAG_AXIS_THRESHOLD), value);
|
7565 | },
|
7566 | keyboardDisplacement(value = DEFAULT_KEYBOARD_DISPLACEMENT) {
|
7567 | return value;
|
7568 | }
|
7569 | });
|
7570 | {
|
7571 | Object.assign(dragConfigResolver, {
|
7572 | useTouch(value) {
|
7573 | if (value !== void 0) {
|
7574 | throw Error(`[@use-gesture]: \`useTouch\` option has been renamed to \`pointer.touch\`. Use it as in \`{ pointer: { touch: true } }\`.`);
|
7575 | }
|
7576 | return NaN;
|
7577 | },
|
7578 | experimental_preventWindowScrollY(value) {
|
7579 | if (value !== void 0) {
|
7580 | throw Error(`[@use-gesture]: \`experimental_preventWindowScrollY\` option has been renamed to \`preventScroll\`.`);
|
7581 | }
|
7582 | return NaN;
|
7583 | },
|
7584 | swipeVelocity(value) {
|
7585 | if (value !== void 0) {
|
7586 | throw Error(`[@use-gesture]: \`swipeVelocity\` option has been renamed to \`swipe.velocity\`. Use it as in \`{ swipe: { velocity: 0.5 } }\`.`);
|
7587 | }
|
7588 | return NaN;
|
7589 | },
|
7590 | swipeDistance(value) {
|
7591 | if (value !== void 0) {
|
7592 | throw Error(`[@use-gesture]: \`swipeDistance\` option has been renamed to \`swipe.distance\`. Use it as in \`{ swipe: { distance: 50 } }\`.`);
|
7593 | }
|
7594 | return NaN;
|
7595 | },
|
7596 | swipeDuration(value) {
|
7597 | if (value !== void 0) {
|
7598 | throw Error(`[@use-gesture]: \`swipeDuration\` option has been renamed to \`swipe.duration\`. Use it as in \`{ swipe: { duration: 250 } }\`.`);
|
7599 | }
|
7600 | return NaN;
|
7601 | }
|
7602 | });
|
7603 | }
|
7604 | function clampStateInternalMovementToBounds(state) {
|
7605 | const [ox, oy] = state.overflow;
|
7606 | const [dx, dy] = state._delta;
|
7607 | const [dirx, diry] = state._direction;
|
7608 | if (ox < 0 && dx > 0 && dirx < 0 || ox > 0 && dx < 0 && dirx > 0) {
|
7609 | state._movement[0] = state._movementBound[0];
|
7610 | }
|
7611 | if (oy < 0 && dy > 0 && diry < 0 || oy > 0 && dy < 0 && diry > 0) {
|
7612 | state._movement[1] = state._movementBound[1];
|
7613 | }
|
7614 | }
|
7615 | const SCALE_ANGLE_RATIO_INTENT_DEG = 30;
|
7616 | const PINCH_WHEEL_RATIO = 100;
|
7617 | class PinchEngine extends Engine {
|
7618 | constructor(...args) {
|
7619 | super(...args);
|
7620 | _defineProperty$1(this, "ingKey", "pinching");
|
7621 | _defineProperty$1(this, "aliasKey", "da");
|
7622 | }
|
7623 | init() {
|
7624 | this.state.offset = [1, 0];
|
7625 | this.state.lastOffset = [1, 0];
|
7626 | this.state._pointerEvents = new Map();
|
7627 | }
|
7628 | reset() {
|
7629 | super.reset();
|
7630 | const state = this.state;
|
7631 | state._touchIds = [];
|
7632 | state.canceled = false;
|
7633 | state.cancel = this.cancel.bind(this);
|
7634 | state.turns = 0;
|
7635 | }
|
7636 | computeOffset() {
|
7637 | const {
|
7638 | type,
|
7639 | movement,
|
7640 | lastOffset
|
7641 | } = this.state;
|
7642 | if (type === "wheel") {
|
7643 | this.state.offset = V.add(movement, lastOffset);
|
7644 | } else {
|
7645 | this.state.offset = [(1 + movement[0]) * lastOffset[0], movement[1] + lastOffset[1]];
|
7646 | }
|
7647 | }
|
7648 | computeMovement() {
|
7649 | const {
|
7650 | offset: offset2,
|
7651 | lastOffset
|
7652 | } = this.state;
|
7653 | this.state.movement = [offset2[0] / lastOffset[0], offset2[1] - lastOffset[1]];
|
7654 | }
|
7655 | axisIntent() {
|
7656 | const state = this.state;
|
7657 | const [_m0, _m1] = state._movement;
|
7658 | if (!state.axis) {
|
7659 | const axisMovementDifference = Math.abs(_m0) * SCALE_ANGLE_RATIO_INTENT_DEG - Math.abs(_m1);
|
7660 | if (axisMovementDifference < 0)
|
7661 | state.axis = "angle";
|
7662 | else if (axisMovementDifference > 0)
|
7663 | state.axis = "scale";
|
7664 | }
|
7665 | }
|
7666 | restrictToAxis(v) {
|
7667 | if (this.config.lockDirection) {
|
7668 | if (this.state.axis === "scale")
|
7669 | v[1] = 0;
|
7670 | else if (this.state.axis === "angle")
|
7671 | v[0] = 0;
|
7672 | }
|
7673 | }
|
7674 | cancel() {
|
7675 | const state = this.state;
|
7676 | if (state.canceled)
|
7677 | return;
|
7678 | setTimeout(() => {
|
7679 | state.canceled = true;
|
7680 | state._active = false;
|
7681 | this.compute();
|
7682 | this.emit();
|
7683 | }, 0);
|
7684 | }
|
7685 | touchStart(event) {
|
7686 | this.ctrl.setEventIds(event);
|
7687 | const state = this.state;
|
7688 | const ctrlTouchIds = this.ctrl.touchIds;
|
7689 | if (state._active) {
|
7690 | if (state._touchIds.every((id) => ctrlTouchIds.has(id)))
|
7691 | return;
|
7692 | }
|
7693 | if (ctrlTouchIds.size < 2)
|
7694 | return;
|
7695 | this.start(event);
|
7696 | state._touchIds = Array.from(ctrlTouchIds).slice(0, 2);
|
7697 | const payload = touchDistanceAngle(event, state._touchIds);
|
7698 | if (!payload)
|
7699 | return;
|
7700 | this.pinchStart(event, payload);
|
7701 | }
|
7702 | pointerStart(event) {
|
7703 | if (event.buttons != null && event.buttons % 2 !== 1)
|
7704 | return;
|
7705 | this.ctrl.setEventIds(event);
|
7706 | event.target.setPointerCapture(event.pointerId);
|
7707 | const state = this.state;
|
7708 | const _pointerEvents = state._pointerEvents;
|
7709 | const ctrlPointerIds = this.ctrl.pointerIds;
|
7710 | if (state._active) {
|
7711 | if (Array.from(_pointerEvents.keys()).every((id) => ctrlPointerIds.has(id)))
|
7712 | return;
|
7713 | }
|
7714 | if (_pointerEvents.size < 2) {
|
7715 | _pointerEvents.set(event.pointerId, event);
|
7716 | }
|
7717 | if (state._pointerEvents.size < 2)
|
7718 | return;
|
7719 | this.start(event);
|
7720 | const payload = distanceAngle(...Array.from(_pointerEvents.values()));
|
7721 | if (!payload)
|
7722 | return;
|
7723 | this.pinchStart(event, payload);
|
7724 | }
|
7725 | pinchStart(event, payload) {
|
7726 | const state = this.state;
|
7727 | state.origin = payload.origin;
|
7728 | this.computeValues([payload.distance, payload.angle]);
|
7729 | this.computeInitial();
|
7730 | this.compute(event);
|
7731 | this.emit();
|
7732 | }
|
7733 | touchMove(event) {
|
7734 | if (!this.state._active)
|
7735 | return;
|
7736 | const payload = touchDistanceAngle(event, this.state._touchIds);
|
7737 | if (!payload)
|
7738 | return;
|
7739 | this.pinchMove(event, payload);
|
7740 | }
|
7741 | pointerMove(event) {
|
7742 | const _pointerEvents = this.state._pointerEvents;
|
7743 | if (_pointerEvents.has(event.pointerId)) {
|
7744 | _pointerEvents.set(event.pointerId, event);
|
7745 | }
|
7746 | if (!this.state._active)
|
7747 | return;
|
7748 | const payload = distanceAngle(...Array.from(_pointerEvents.values()));
|
7749 | if (!payload)
|
7750 | return;
|
7751 | this.pinchMove(event, payload);
|
7752 | }
|
7753 | pinchMove(event, payload) {
|
7754 | const state = this.state;
|
7755 | const prev_a = state._values[1];
|
7756 | const delta_a = payload.angle - prev_a;
|
7757 | let delta_turns = 0;
|
7758 | if (Math.abs(delta_a) > 270)
|
7759 | delta_turns += Math.sign(delta_a);
|
7760 | this.computeValues([payload.distance, payload.angle - 360 * delta_turns]);
|
7761 | state.origin = payload.origin;
|
7762 | state.turns = delta_turns;
|
7763 | state._movement = [state._values[0] / state._initial[0] - 1, state._values[1] - state._initial[1]];
|
7764 | this.compute(event);
|
7765 | this.emit();
|
7766 | }
|
7767 | touchEnd(event) {
|
7768 | this.ctrl.setEventIds(event);
|
7769 | if (!this.state._active)
|
7770 | return;
|
7771 | if (this.state._touchIds.some((id) => !this.ctrl.touchIds.has(id))) {
|
7772 | this.state._active = false;
|
7773 | this.compute(event);
|
7774 | this.emit();
|
7775 | }
|
7776 | }
|
7777 | pointerEnd(event) {
|
7778 | const state = this.state;
|
7779 | this.ctrl.setEventIds(event);
|
7780 | try {
|
7781 | event.target.releasePointerCapture(event.pointerId);
|
7782 | } catch (_unused) {
|
7783 | }
|
7784 | if (state._pointerEvents.has(event.pointerId)) {
|
7785 | state._pointerEvents.delete(event.pointerId);
|
7786 | }
|
7787 | if (!state._active)
|
7788 | return;
|
7789 | if (state._pointerEvents.size < 2) {
|
7790 | state._active = false;
|
7791 | this.compute(event);
|
7792 | this.emit();
|
7793 | }
|
7794 | }
|
7795 | gestureStart(event) {
|
7796 | if (event.cancelable)
|
7797 | event.preventDefault();
|
7798 | const state = this.state;
|
7799 | if (state._active)
|
7800 | return;
|
7801 | this.start(event);
|
7802 | this.computeValues([event.scale, event.rotation]);
|
7803 | state.origin = [event.clientX, event.clientY];
|
7804 | this.compute(event);
|
7805 | this.emit();
|
7806 | }
|
7807 | gestureMove(event) {
|
7808 | if (event.cancelable)
|
7809 | event.preventDefault();
|
7810 | if (!this.state._active)
|
7811 | return;
|
7812 | const state = this.state;
|
7813 | this.computeValues([event.scale, event.rotation]);
|
7814 | state.origin = [event.clientX, event.clientY];
|
7815 | const _previousMovement = state._movement;
|
7816 | state._movement = [event.scale - 1, event.rotation];
|
7817 | state._delta = V.sub(state._movement, _previousMovement);
|
7818 | this.compute(event);
|
7819 | this.emit();
|
7820 | }
|
7821 | gestureEnd(event) {
|
7822 | if (!this.state._active)
|
7823 | return;
|
7824 | this.state._active = false;
|
7825 | this.compute(event);
|
7826 | this.emit();
|
7827 | }
|
7828 | wheel(event) {
|
7829 | const modifierKey = this.config.modifierKey;
|
7830 | if (modifierKey && (Array.isArray(modifierKey) ? !modifierKey.find((k) => event[k]) : !event[modifierKey]))
|
7831 | return;
|
7832 | if (!this.state._active)
|
7833 | this.wheelStart(event);
|
7834 | else
|
7835 | this.wheelChange(event);
|
7836 | this.timeoutStore.add("wheelEnd", this.wheelEnd.bind(this));
|
7837 | }
|
7838 | wheelStart(event) {
|
7839 | this.start(event);
|
7840 | this.wheelChange(event);
|
7841 | }
|
7842 | wheelChange(event) {
|
7843 | const isR3f = "uv" in event;
|
7844 | if (!isR3f) {
|
7845 | if (event.cancelable) {
|
7846 | event.preventDefault();
|
7847 | }
|
7848 | if (!event.defaultPrevented) {
|
7849 | console.warn(`[@use-gesture]: To properly support zoom on trackpads, try using the \`target\` option.
|
7850 |
|
7851 | This message will only appear in development mode.`);
|
7852 | }
|
7853 | }
|
7854 | const state = this.state;
|
7855 | state._delta = [-wheelValues(event)[1] / PINCH_WHEEL_RATIO * state.offset[0], 0];
|
7856 | V.addTo(state._movement, state._delta);
|
7857 | clampStateInternalMovementToBounds(state);
|
7858 | this.state.origin = [event.clientX, event.clientY];
|
7859 | this.compute(event);
|
7860 | this.emit();
|
7861 | }
|
7862 | wheelEnd() {
|
7863 | if (!this.state._active)
|
7864 | return;
|
7865 | this.state._active = false;
|
7866 | this.compute();
|
7867 | this.emit();
|
7868 | }
|
7869 | bind(bindFunction) {
|
7870 | const device = this.config.device;
|
7871 | if (!!device) {
|
7872 | bindFunction(device, "start", this[device + "Start"].bind(this));
|
7873 | bindFunction(device, "change", this[device + "Move"].bind(this));
|
7874 | bindFunction(device, "end", this[device + "End"].bind(this));
|
7875 | bindFunction(device, "cancel", this[device + "End"].bind(this));
|
7876 | bindFunction("lostPointerCapture", "", this[device + "End"].bind(this));
|
7877 | }
|
7878 | if (this.config.pinchOnWheel) {
|
7879 | bindFunction("wheel", "", this.wheel.bind(this), {
|
7880 | passive: false
|
7881 | });
|
7882 | }
|
7883 | }
|
7884 | }
|
7885 | const pinchConfigResolver = _objectSpread2$1(_objectSpread2$1({}, commonConfigResolver), {}, {
|
7886 | device(_v, _k, {
|
7887 | shared,
|
7888 | pointer: {
|
7889 | touch = false
|
7890 | } = {}
|
7891 | }) {
|
7892 | const sharedConfig = shared;
|
7893 | if (sharedConfig.target && !SUPPORT.touch && SUPPORT.gesture)
|
7894 | return "gesture";
|
7895 | if (SUPPORT.touch && touch)
|
7896 | return "touch";
|
7897 | if (SUPPORT.touchscreen) {
|
7898 | if (SUPPORT.pointer)
|
7899 | return "pointer";
|
7900 | if (SUPPORT.touch)
|
7901 | return "touch";
|
7902 | }
|
7903 | },
|
7904 | bounds(_v, _k, {
|
7905 | scaleBounds = {},
|
7906 | angleBounds = {}
|
7907 | }) {
|
7908 | const _scaleBounds = (state) => {
|
7909 | const D = assignDefault(call$2(scaleBounds, state), {
|
7910 | min: -Infinity,
|
7911 | max: Infinity
|
7912 | });
|
7913 | return [D.min, D.max];
|
7914 | };
|
7915 | const _angleBounds = (state) => {
|
7916 | const A = assignDefault(call$2(angleBounds, state), {
|
7917 | min: -Infinity,
|
7918 | max: Infinity
|
7919 | });
|
7920 | return [A.min, A.max];
|
7921 | };
|
7922 | if (typeof scaleBounds !== "function" && typeof angleBounds !== "function")
|
7923 | return [_scaleBounds(), _angleBounds()];
|
7924 | return (state) => [_scaleBounds(state), _angleBounds(state)];
|
7925 | },
|
7926 | threshold(value, _k, config2) {
|
7927 | this.lockDirection = config2.axis === "lock";
|
7928 | const threshold = V.toVector(value, this.lockDirection ? [0.1, 3] : 0);
|
7929 | return threshold;
|
7930 | },
|
7931 | modifierKey(value) {
|
7932 | if (value === void 0)
|
7933 | return "ctrlKey";
|
7934 | return value;
|
7935 | },
|
7936 | pinchOnWheel(value = true) {
|
7937 | return value;
|
7938 | }
|
7939 | });
|
7940 | _objectSpread2$1(_objectSpread2$1({}, coordinatesConfigResolver), {}, {
|
7941 | mouseOnly: (value = true) => value
|
7942 | });
|
7943 | class WheelEngine extends CoordinatesEngine {
|
7944 | constructor(...args) {
|
7945 | super(...args);
|
7946 | _defineProperty$1(this, "ingKey", "wheeling");
|
7947 | }
|
7948 | wheel(event) {
|
7949 | if (!this.state._active)
|
7950 | this.start(event);
|
7951 | this.wheelChange(event);
|
7952 | this.timeoutStore.add("wheelEnd", this.wheelEnd.bind(this));
|
7953 | }
|
7954 | wheelChange(event) {
|
7955 | const state = this.state;
|
7956 | state._delta = wheelValues(event);
|
7957 | V.addTo(state._movement, state._delta);
|
7958 | clampStateInternalMovementToBounds(state);
|
7959 | this.compute(event);
|
7960 | this.emit();
|
7961 | }
|
7962 | wheelEnd() {
|
7963 | if (!this.state._active)
|
7964 | return;
|
7965 | this.state._active = false;
|
7966 | this.compute();
|
7967 | this.emit();
|
7968 | }
|
7969 | bind(bindFunction) {
|
7970 | bindFunction("wheel", "", this.wheel.bind(this));
|
7971 | }
|
7972 | }
|
7973 | const wheelConfigResolver = coordinatesConfigResolver;
|
7974 | _objectSpread2$1(_objectSpread2$1({}, coordinatesConfigResolver), {}, {
|
7975 | mouseOnly: (value = true) => value
|
7976 | });
|
7977 | const EngineMap = new Map();
|
7978 | const ConfigResolverMap = new Map();
|
7979 | function registerAction(action) {
|
7980 | EngineMap.set(action.key, action.engine);
|
7981 | ConfigResolverMap.set(action.key, action.resolver);
|
7982 | }
|
7983 | const dragAction = {
|
7984 | key: "drag",
|
7985 | engine: DragEngine,
|
7986 | resolver: dragConfigResolver
|
7987 | };
|
7988 | const pinchAction = {
|
7989 | key: "pinch",
|
7990 | engine: PinchEngine,
|
7991 | resolver: pinchConfigResolver
|
7992 | };
|
7993 | const wheelAction = {
|
7994 | key: "wheel",
|
7995 | engine: WheelEngine,
|
7996 | resolver: wheelConfigResolver
|
7997 | };
|
7998 | function _objectWithoutPropertiesLoose$1(source, excluded) {
|
7999 | if (source == null)
|
8000 | return {};
|
8001 | var target = {};
|
8002 | var sourceKeys = Object.keys(source);
|
8003 | var key, i2;
|
8004 | for (i2 = 0; i2 < sourceKeys.length; i2++) {
|
8005 | key = sourceKeys[i2];
|
8006 | if (excluded.indexOf(key) >= 0)
|
8007 | continue;
|
8008 | target[key] = source[key];
|
8009 | }
|
8010 | return target;
|
8011 | }
|
8012 | function _objectWithoutProperties$1(source, excluded) {
|
8013 | if (source == null)
|
8014 | return {};
|
8015 | var target = _objectWithoutPropertiesLoose$1(source, excluded);
|
8016 | var key, i2;
|
8017 | if (Object.getOwnPropertySymbols) {
|
8018 | var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
8019 | for (i2 = 0; i2 < sourceSymbolKeys.length; i2++) {
|
8020 | key = sourceSymbolKeys[i2];
|
8021 | if (excluded.indexOf(key) >= 0)
|
8022 | continue;
|
8023 | if (!Object.prototype.propertyIsEnumerable.call(source, key))
|
8024 | continue;
|
8025 | target[key] = source[key];
|
8026 | }
|
8027 | }
|
8028 | return target;
|
8029 | }
|
8030 | const sharedConfigResolver = {
|
8031 | target(value) {
|
8032 | if (value) {
|
8033 | return () => "current" in value ? value.current : value;
|
8034 | }
|
8035 | return void 0;
|
8036 | },
|
8037 | enabled(value = true) {
|
8038 | return value;
|
8039 | },
|
8040 | window(value = SUPPORT.isBrowser ? window : void 0) {
|
8041 | return value;
|
8042 | },
|
8043 | eventOptions({
|
8044 | passive = true,
|
8045 | capture = false
|
8046 | } = {}) {
|
8047 | return {
|
8048 | passive,
|
8049 | capture
|
8050 | };
|
8051 | },
|
8052 | transform(value) {
|
8053 | return value;
|
8054 | }
|
8055 | };
|
8056 | const _excluded$3 = ["target", "eventOptions", "window", "enabled", "transform"];
|
8057 | function resolveWith(config2 = {}, resolvers) {
|
8058 | const result = {};
|
8059 | for (const [key, resolver] of Object.entries(resolvers)) {
|
8060 | switch (typeof resolver) {
|
8061 | case "function":
|
8062 | {
|
8063 | const r = resolver.call(result, config2[key], key, config2);
|
8064 | if (!Number.isNaN(r))
|
8065 | result[key] = r;
|
8066 | }
|
8067 | break;
|
8068 | case "object":
|
8069 | result[key] = resolveWith(config2[key], resolver);
|
8070 | break;
|
8071 | case "boolean":
|
8072 | if (resolver)
|
8073 | result[key] = config2[key];
|
8074 | break;
|
8075 | }
|
8076 | }
|
8077 | return result;
|
8078 | }
|
8079 | function parse(newConfig, gestureKey, _config = {}) {
|
8080 | const _ref = newConfig, {
|
8081 | target,
|
8082 | eventOptions,
|
8083 | window: window2,
|
8084 | enabled,
|
8085 | transform
|
8086 | } = _ref, rest = _objectWithoutProperties$1(_ref, _excluded$3);
|
8087 | _config.shared = resolveWith({
|
8088 | target,
|
8089 | eventOptions,
|
8090 | window: window2,
|
8091 | enabled,
|
8092 | transform
|
8093 | }, sharedConfigResolver);
|
8094 | if (gestureKey) {
|
8095 | const resolver = ConfigResolverMap.get(gestureKey);
|
8096 | _config[gestureKey] = resolveWith(_objectSpread2$1({
|
8097 | shared: _config.shared
|
8098 | }, rest), resolver);
|
8099 | } else {
|
8100 | for (const key in rest) {
|
8101 | const resolver = ConfigResolverMap.get(key);
|
8102 | if (resolver) {
|
8103 | _config[key] = resolveWith(_objectSpread2$1({
|
8104 | shared: _config.shared
|
8105 | }, rest[key]), resolver);
|
8106 | } else {
|
8107 | if (!["drag", "pinch", "scroll", "wheel", "move", "hover"].includes(key)) {
|
8108 | if (key === "domTarget") {
|
8109 | throw Error(`[@use-gesture]: \`domTarget\` option has been renamed to \`target\`.`);
|
8110 | }
|
8111 | console.warn(`[@use-gesture]: Unknown config key \`${key}\` was used. Please read the documentation for further information.`);
|
8112 | }
|
8113 | }
|
8114 | }
|
8115 | }
|
8116 | return _config;
|
8117 | }
|
8118 | class EventStore {
|
8119 | constructor(ctrl, gestureKey) {
|
8120 | _defineProperty$1(this, "_listeners", new Set());
|
8121 | this._ctrl = ctrl;
|
8122 | this._gestureKey = gestureKey;
|
8123 | }
|
8124 | add(element, device, action, handler, options) {
|
8125 | const listeners = this._listeners;
|
8126 | const type = toDomEventType(device, action);
|
8127 | const _options = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {};
|
8128 | const eventOptions = _objectSpread2$1(_objectSpread2$1({}, _options), options);
|
8129 | element.addEventListener(type, handler, eventOptions);
|
8130 | const remove = () => {
|
8131 | element.removeEventListener(type, handler, eventOptions);
|
8132 | listeners.delete(remove);
|
8133 | };
|
8134 | listeners.add(remove);
|
8135 | return remove;
|
8136 | }
|
8137 | clean() {
|
8138 | this._listeners.forEach((remove) => remove());
|
8139 | this._listeners.clear();
|
8140 | }
|
8141 | }
|
8142 | class TimeoutStore {
|
8143 | constructor() {
|
8144 | _defineProperty$1(this, "_timeouts", new Map());
|
8145 | }
|
8146 | add(key, callback, ms = 140, ...args) {
|
8147 | this.remove(key);
|
8148 | this._timeouts.set(key, window.setTimeout(callback, ms, ...args));
|
8149 | }
|
8150 | remove(key) {
|
8151 | const timeout = this._timeouts.get(key);
|
8152 | if (timeout)
|
8153 | window.clearTimeout(timeout);
|
8154 | }
|
8155 | clean() {
|
8156 | this._timeouts.forEach((timeout) => void window.clearTimeout(timeout));
|
8157 | this._timeouts.clear();
|
8158 | }
|
8159 | }
|
8160 | class Controller {
|
8161 | constructor(handlers) {
|
8162 | _defineProperty$1(this, "gestures", new Set());
|
8163 | _defineProperty$1(this, "_targetEventStore", new EventStore(this));
|
8164 | _defineProperty$1(this, "gestureEventStores", {});
|
8165 | _defineProperty$1(this, "gestureTimeoutStores", {});
|
8166 | _defineProperty$1(this, "handlers", {});
|
8167 | _defineProperty$1(this, "config", {});
|
8168 | _defineProperty$1(this, "pointerIds", new Set());
|
8169 | _defineProperty$1(this, "touchIds", new Set());
|
8170 | _defineProperty$1(this, "state", {
|
8171 | shared: {
|
8172 | shiftKey: false,
|
8173 | metaKey: false,
|
8174 | ctrlKey: false,
|
8175 | altKey: false
|
8176 | }
|
8177 | });
|
8178 | resolveGestures(this, handlers);
|
8179 | }
|
8180 | setEventIds(event) {
|
8181 | if (isTouch(event)) {
|
8182 | this.touchIds = new Set(touchIds(event));
|
8183 | return this.touchIds;
|
8184 | } else if ("pointerId" in event) {
|
8185 | if (event.type === "pointerup" || event.type === "pointercancel")
|
8186 | this.pointerIds.delete(event.pointerId);
|
8187 | else if (event.type === "pointerdown")
|
8188 | this.pointerIds.add(event.pointerId);
|
8189 | return this.pointerIds;
|
8190 | }
|
8191 | }
|
8192 | applyHandlers(handlers, nativeHandlers) {
|
8193 | this.handlers = handlers;
|
8194 | this.nativeHandlers = nativeHandlers;
|
8195 | }
|
8196 | applyConfig(config2, gestureKey) {
|
8197 | this.config = parse(config2, gestureKey, this.config);
|
8198 | }
|
8199 | clean() {
|
8200 | this._targetEventStore.clean();
|
8201 | for (const key of this.gestures) {
|
8202 | this.gestureEventStores[key].clean();
|
8203 | this.gestureTimeoutStores[key].clean();
|
8204 | }
|
8205 | }
|
8206 | effect() {
|
8207 | if (this.config.shared.target)
|
8208 | this.bind();
|
8209 | return () => this._targetEventStore.clean();
|
8210 | }
|
8211 | bind(...args) {
|
8212 | const sharedConfig = this.config.shared;
|
8213 | const props = {};
|
8214 | let target;
|
8215 | if (sharedConfig.target) {
|
8216 | target = sharedConfig.target();
|
8217 | if (!target)
|
8218 | return;
|
8219 | }
|
8220 | if (sharedConfig.enabled) {
|
8221 | for (const gestureKey of this.gestures) {
|
8222 | const gestureConfig = this.config[gestureKey];
|
8223 | const bindFunction = bindToProps(props, gestureConfig.eventOptions, !!target);
|
8224 | if (gestureConfig.enabled) {
|
8225 | const Engine2 = EngineMap.get(gestureKey);
|
8226 | new Engine2(this, args, gestureKey).bind(bindFunction);
|
8227 | }
|
8228 | }
|
8229 | const nativeBindFunction = bindToProps(props, sharedConfig.eventOptions, !!target);
|
8230 | for (const eventKey in this.nativeHandlers) {
|
8231 | nativeBindFunction(eventKey, "", (event) => this.nativeHandlers[eventKey](_objectSpread2$1(_objectSpread2$1({}, this.state.shared), {}, {
|
8232 | event,
|
8233 | args
|
8234 | })), void 0, true);
|
8235 | }
|
8236 | }
|
8237 | for (const handlerProp in props) {
|
8238 | props[handlerProp] = chain(...props[handlerProp]);
|
8239 | }
|
8240 | if (!target)
|
8241 | return props;
|
8242 | for (const handlerProp in props) {
|
8243 | const {
|
8244 | device,
|
8245 | capture,
|
8246 | passive
|
8247 | } = parseProp(handlerProp);
|
8248 | this._targetEventStore.add(target, device, "", props[handlerProp], {
|
8249 | capture,
|
8250 | passive
|
8251 | });
|
8252 | }
|
8253 | }
|
8254 | }
|
8255 | function setupGesture(ctrl, gestureKey) {
|
8256 | ctrl.gestures.add(gestureKey);
|
8257 | ctrl.gestureEventStores[gestureKey] = new EventStore(ctrl, gestureKey);
|
8258 | ctrl.gestureTimeoutStores[gestureKey] = new TimeoutStore();
|
8259 | }
|
8260 | function resolveGestures(ctrl, internalHandlers) {
|
8261 | if (internalHandlers.drag)
|
8262 | setupGesture(ctrl, "drag");
|
8263 | if (internalHandlers.wheel)
|
8264 | setupGesture(ctrl, "wheel");
|
8265 | if (internalHandlers.scroll)
|
8266 | setupGesture(ctrl, "scroll");
|
8267 | if (internalHandlers.move)
|
8268 | setupGesture(ctrl, "move");
|
8269 | if (internalHandlers.pinch)
|
8270 | setupGesture(ctrl, "pinch");
|
8271 | if (internalHandlers.hover)
|
8272 | setupGesture(ctrl, "hover");
|
8273 | }
|
8274 | const bindToProps = (props, eventOptions, withPassiveOption) => (device, action, handler, options = {}, isNative = false) => {
|
8275 | var _options$capture, _options$passive;
|
8276 | const capture = (_options$capture = options.capture) !== null && _options$capture !== void 0 ? _options$capture : eventOptions.capture;
|
8277 | const passive = (_options$passive = options.passive) !== null && _options$passive !== void 0 ? _options$passive : eventOptions.passive;
|
8278 | let handlerProp = isNative ? device : toHandlerProp(device, action, capture);
|
8279 | if (withPassiveOption && passive)
|
8280 | handlerProp += "Passive";
|
8281 | props[handlerProp] = props[handlerProp] || [];
|
8282 | props[handlerProp].push(handler);
|
8283 | };
|
8284 | const RE_NOT_NATIVE = /^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;
|
8285 | function sortHandlers(_handlers) {
|
8286 | const native = {};
|
8287 | const handlers = {};
|
8288 | const actions = new Set();
|
8289 | for (let key in _handlers) {
|
8290 | if (RE_NOT_NATIVE.test(key)) {
|
8291 | actions.add(RegExp.lastMatch);
|
8292 | handlers[key] = _handlers[key];
|
8293 | } else {
|
8294 | native[key] = _handlers[key];
|
8295 | }
|
8296 | }
|
8297 | return [handlers, native, actions];
|
8298 | }
|
8299 | function registerGesture(actions, handlers, handlerKey, key, internalHandlers, config2) {
|
8300 | if (!actions.has(handlerKey))
|
8301 | return;
|
8302 | if (!EngineMap.has(key)) {
|
8303 | {
|
8304 | console.warn(`[@use-gesture]: You've created a custom handler that that uses the \`${key}\` gesture but isn't properly configured.
|
8305 |
|
8306 | Please add \`${key}Action\` when creating your handler.`);
|
8307 | }
|
8308 | return;
|
8309 | }
|
8310 | const startKey = handlerKey + "Start";
|
8311 | const endKey = handlerKey + "End";
|
8312 | const fn = (state) => {
|
8313 | let memo = void 0;
|
8314 | if (state.first && startKey in handlers)
|
8315 | handlers[startKey](state);
|
8316 | if (handlerKey in handlers)
|
8317 | memo = handlers[handlerKey](state);
|
8318 | if (state.last && endKey in handlers)
|
8319 | handlers[endKey](state);
|
8320 | return memo;
|
8321 | };
|
8322 | internalHandlers[key] = fn;
|
8323 | config2[key] = config2[key] || {};
|
8324 | }
|
8325 | function parseMergedHandlers(mergedHandlers, mergedConfig) {
|
8326 | const [handlers, nativeHandlers, actions] = sortHandlers(mergedHandlers);
|
8327 | const internalHandlers = {};
|
8328 | registerGesture(actions, handlers, "onDrag", "drag", internalHandlers, mergedConfig);
|
8329 | registerGesture(actions, handlers, "onWheel", "wheel", internalHandlers, mergedConfig);
|
8330 | registerGesture(actions, handlers, "onScroll", "scroll", internalHandlers, mergedConfig);
|
8331 | registerGesture(actions, handlers, "onPinch", "pinch", internalHandlers, mergedConfig);
|
8332 | registerGesture(actions, handlers, "onMove", "move", internalHandlers, mergedConfig);
|
8333 | registerGesture(actions, handlers, "onHover", "hover", internalHandlers, mergedConfig);
|
8334 | return {
|
8335 | handlers: internalHandlers,
|
8336 | config: mergedConfig,
|
8337 | nativeHandlers
|
8338 | };
|
8339 | }
|
8340 | function useRecognizers(handlers, config2 = {}, gestureKey, nativeHandlers) {
|
8341 | const ctrl = React$1.useMemo(() => new Controller(handlers), []);
|
8342 | ctrl.applyHandlers(handlers, nativeHandlers);
|
8343 | ctrl.applyConfig(config2, gestureKey);
|
8344 | React$1.useEffect(ctrl.effect.bind(ctrl));
|
8345 | React$1.useEffect(() => {
|
8346 | return ctrl.clean.bind(ctrl);
|
8347 | }, []);
|
8348 | if (config2.target === void 0) {
|
8349 | return ctrl.bind.bind(ctrl);
|
8350 | }
|
8351 | return void 0;
|
8352 | }
|
8353 | function useDrag(handler, config2) {
|
8354 | registerAction(dragAction);
|
8355 | return useRecognizers({
|
8356 | drag: handler
|
8357 | }, config2 || {}, "drag");
|
8358 | }
|
8359 | function useWheel(handler, config2) {
|
8360 | registerAction(wheelAction);
|
8361 | return useRecognizers({
|
8362 | wheel: handler
|
8363 | }, config2 || {}, "wheel");
|
8364 | }
|
8365 | function createUseGesture(actions) {
|
8366 | actions.forEach(registerAction);
|
8367 | return function useGesture(_handlers, _config) {
|
8368 | const {
|
8369 | handlers,
|
8370 | nativeHandlers,
|
8371 | config: config2
|
8372 | } = parseMergedHandlers(_handlers, _config || {});
|
8373 | return useRecognizers(handlers, config2, void 0, nativeHandlers);
|
8374 | };
|
8375 | }
|
8376 | const classPrefix$1o = `adm-popup`;
|
8377 | const defaultProps$13 = Object.assign(Object.assign({}, defaultPopupBaseProps), {
|
8378 | closeOnSwipe: false,
|
8379 | position: "bottom"
|
8380 | });
|
8381 | const Popup = (p) => {
|
8382 | const {
|
8383 | locale,
|
8384 | popup: componentConfig = {}
|
8385 | } = useConfig();
|
8386 | const props = mergeProps(defaultProps$13, componentConfig, p);
|
8387 | const bodyCls = classNames(`${classPrefix$1o}-body`, props.bodyClassName, `${classPrefix$1o}-body-position-${props.position}`);
|
8388 | const [active, setActive] = React$1.useState(props.visible);
|
8389 | const ref = React$1.useRef(null);
|
8390 | useLockScroll(ref, props.disableBodyScroll && active ? "strict" : false);
|
8391 | useIsomorphicLayoutEffect$2(() => {
|
8392 | if (props.visible) {
|
8393 | setActive(true);
|
8394 | }
|
8395 | }, [props.visible]);
|
8396 | const unmountedRef = useUnmountedRef$1();
|
8397 | const {
|
8398 | percent
|
8399 | } = useSpring({
|
8400 | percent: props.visible ? 0 : 100,
|
8401 | config: {
|
8402 | precision: 0.1,
|
8403 | mass: 0.4,
|
8404 | tension: 300,
|
8405 | friction: 30
|
8406 | },
|
8407 | onRest: () => {
|
8408 | var _a, _b;
|
8409 | if (unmountedRef.current)
|
8410 | return;
|
8411 | setActive(props.visible);
|
8412 | if (props.visible) {
|
8413 | (_a = props.afterShow) === null || _a === void 0 ? void 0 : _a.call(props);
|
8414 | } else {
|
8415 | (_b = props.afterClose) === null || _b === void 0 ? void 0 : _b.call(props);
|
8416 | }
|
8417 | }
|
8418 | });
|
8419 | const bind = useDrag(({
|
8420 | swipe: [, swipeY]
|
8421 | }) => {
|
8422 | var _a;
|
8423 | if (!props.closeOnSwipe)
|
8424 | return;
|
8425 | if (swipeY === 1 && props.position === "bottom" || swipeY === -1 && props.position === "top") {
|
8426 | (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
8427 | }
|
8428 | }, {
|
8429 | axis: "y",
|
8430 | enabled: ["top", "bottom"].includes(props.position)
|
8431 | });
|
8432 | const maskVisible = useInnerVisible(active && props.visible);
|
8433 | const node = withStopPropagation(props.stopPropagation, withNativeProps(props, React$1.createElement("div", Object.assign({
|
8434 | className: classPrefix$1o,
|
8435 | onClick: props.onClick,
|
8436 | style: {
|
8437 | display: active ? void 0 : "none",
|
8438 | touchAction: ["top", "bottom"].includes(props.position) ? "none" : "auto"
|
8439 | }
|
8440 | }, bind()), props.mask && React$1.createElement(Mask, {
|
8441 | visible: maskVisible,
|
8442 | forceRender: props.forceRender,
|
8443 | destroyOnClose: props.destroyOnClose,
|
8444 | onMaskClick: (e2) => {
|
8445 | var _a, _b;
|
8446 | (_a = props.onMaskClick) === null || _a === void 0 ? void 0 : _a.call(props, e2);
|
8447 | if (props.closeOnMaskClick) {
|
8448 | (_b = props.onClose) === null || _b === void 0 ? void 0 : _b.call(props);
|
8449 | }
|
8450 | },
|
8451 | className: props.maskClassName,
|
8452 | style: props.maskStyle,
|
8453 | disableBodyScroll: false,
|
8454 | stopPropagation: props.stopPropagation
|
8455 | }), React$1.createElement(animated.div, {
|
8456 | className: bodyCls,
|
8457 | style: Object.assign(Object.assign({}, props.bodyStyle), {
|
8458 | pointerEvents: percent.to((v) => v === 0 ? "unset" : "none"),
|
8459 | transform: percent.to((v) => {
|
8460 | if (props.position === "bottom") {
|
8461 | return `translate(0, ${v}%)`;
|
8462 | }
|
8463 | if (props.position === "top") {
|
8464 | return `translate(0, -${v}%)`;
|
8465 | }
|
8466 | if (props.position === "left") {
|
8467 | return `translate(-${v}%, 0)`;
|
8468 | }
|
8469 | if (props.position === "right") {
|
8470 | return `translate(${v}%, 0)`;
|
8471 | }
|
8472 | return "none";
|
8473 | })
|
8474 | }),
|
8475 | ref
|
8476 | }, props.showCloseButton && React$1.createElement("a", {
|
8477 | className: classNames(`${classPrefix$1o}-close-icon`, "adm-plain-anchor"),
|
8478 | onClick: () => {
|
8479 | var _a;
|
8480 | (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
8481 | },
|
8482 | role: "button",
|
8483 | "aria-label": locale.common.close
|
8484 | }, props.closeIcon), props.children))));
|
8485 | return React$1.createElement(ShouldRender, {
|
8486 | active,
|
8487 | forceRender: props.forceRender,
|
8488 | destroyOnClose: props.destroyOnClose
|
8489 | }, renderToContainer(props.getContainer, node));
|
8490 | };
|
8491 | const classPrefix$1n = "adm-safe-area";
|
8492 | const SafeArea = (props) => {
|
8493 | return withNativeProps(props, React$1.createElement("div", {
|
8494 | className: classNames(classPrefix$1n, `${classPrefix$1n}-position-${props.position}`)
|
8495 | }));
|
8496 | };
|
8497 | const fullClone = Object.assign({}, ReactDOM__namespace);
|
8498 | const {
|
8499 | version,
|
8500 | render: reactRender,
|
8501 | unmountComponentAtNode
|
8502 | } = fullClone;
|
8503 | let createRoot;
|
8504 | try {
|
8505 | const mainVersion = Number((version || "").split(".")[0]);
|
8506 | if (mainVersion >= 18 && fullClone.createRoot) {
|
8507 | createRoot = fullClone.createRoot;
|
8508 | }
|
8509 | } catch (e2) {
|
8510 | }
|
8511 | function toggleWarning(skip) {
|
8512 | const {
|
8513 | __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
8514 | } = fullClone;
|
8515 | if (__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED && typeof __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED === "object") {
|
8516 | __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = skip;
|
8517 | }
|
8518 | }
|
8519 | const MARK = "__antd_mobile_root__";
|
8520 | function legacyRender(node, container) {
|
8521 | reactRender(node, container);
|
8522 | }
|
8523 | function concurrentRender(node, container) {
|
8524 | toggleWarning(true);
|
8525 | const root2 = container[MARK] || createRoot(container);
|
8526 | toggleWarning(false);
|
8527 | root2.render(node);
|
8528 | container[MARK] = root2;
|
8529 | }
|
8530 | function render(node, container) {
|
8531 | if (createRoot) {
|
8532 | concurrentRender(node, container);
|
8533 | return;
|
8534 | }
|
8535 | legacyRender(node, container);
|
8536 | }
|
8537 | function legacyUnmount(container) {
|
8538 | return unmountComponentAtNode(container);
|
8539 | }
|
8540 | function concurrentUnmount(container) {
|
8541 | return __awaiter(this, void 0, void 0, function* () {
|
8542 | return Promise.resolve().then(() => {
|
8543 | var _a;
|
8544 | (_a = container[MARK]) === null || _a === void 0 ? void 0 : _a.unmount();
|
8545 | delete container[MARK];
|
8546 | });
|
8547 | });
|
8548 | }
|
8549 | function unmount(container) {
|
8550 | if (createRoot) {
|
8551 | return concurrentUnmount(container);
|
8552 | }
|
8553 | return legacyUnmount(container);
|
8554 | }
|
8555 | function renderToBody(element) {
|
8556 | const container = document.createElement("div");
|
8557 | document.body.appendChild(container);
|
8558 | function unmount$1() {
|
8559 | const unmountResult = unmount(container);
|
8560 | if (unmountResult && container.parentNode) {
|
8561 | container.parentNode.removeChild(container);
|
8562 | }
|
8563 | }
|
8564 | render(element, container);
|
8565 | return unmount$1;
|
8566 | }
|
8567 | function renderImperatively(element) {
|
8568 | const Wrapper2 = React$1.forwardRef((_, ref) => {
|
8569 | const [visible, setVisible] = React$1.useState(false);
|
8570 | const closedRef = React$1.useRef(false);
|
8571 | const [elementToRender, setElementToRender] = React$1.useState(element);
|
8572 | const keyRef = React$1.useRef(0);
|
8573 | React$1.useEffect(() => {
|
8574 | if (!closedRef.current) {
|
8575 | setVisible(true);
|
8576 | } else {
|
8577 | afterClose();
|
8578 | }
|
8579 | }, []);
|
8580 | function onClose() {
|
8581 | var _a, _b;
|
8582 | closedRef.current = true;
|
8583 | setVisible(false);
|
8584 | (_b = (_a = elementToRender.props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
8585 | }
|
8586 | function afterClose() {
|
8587 | var _a, _b;
|
8588 | unmount2();
|
8589 | (_b = (_a = elementToRender.props).afterClose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
8590 | }
|
8591 | React$1.useImperativeHandle(ref, () => ({
|
8592 | close: onClose,
|
8593 | replace: (element2) => {
|
8594 | var _a, _b;
|
8595 | keyRef.current++;
|
8596 | (_b = (_a = elementToRender.props).afterClose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
8597 | setElementToRender(element2);
|
8598 | }
|
8599 | }));
|
8600 | return React$1.cloneElement(elementToRender, Object.assign(Object.assign({}, elementToRender.props), {
|
8601 | key: keyRef.current,
|
8602 | visible,
|
8603 | onClose,
|
8604 | afterClose
|
8605 | }));
|
8606 | });
|
8607 | const wrapperRef = React$1.createRef();
|
8608 | const unmount2 = renderToBody(React$1.createElement(Wrapper2, {
|
8609 | ref: wrapperRef
|
8610 | }));
|
8611 | return {
|
8612 | close: () => __awaiter(this, void 0, void 0, function* () {
|
8613 | var _a;
|
8614 | if (!wrapperRef.current) {
|
8615 | unmount2();
|
8616 | } else {
|
8617 | (_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.close();
|
8618 | }
|
8619 | }),
|
8620 | replace: (element2) => {
|
8621 | var _a;
|
8622 | (_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.replace(element2);
|
8623 | }
|
8624 | };
|
8625 | }
|
8626 | const classPrefix$1m = `adm-action-sheet`;
|
8627 | const defaultProps$12 = {
|
8628 | visible: false,
|
8629 | actions: [],
|
8630 | cancelText: "",
|
8631 | closeOnAction: false,
|
8632 | closeOnMaskClick: true,
|
8633 | safeArea: true,
|
8634 | destroyOnClose: false,
|
8635 | forceRender: false
|
8636 | };
|
8637 | const ActionSheet = (p) => {
|
8638 | const props = mergeProps(defaultProps$12, p);
|
8639 | const {
|
8640 | styles
|
8641 | } = props;
|
8642 | return React$1.createElement(Popup, {
|
8643 | visible: props.visible,
|
8644 | onMaskClick: () => {
|
8645 | var _a, _b;
|
8646 | (_a = props.onMaskClick) === null || _a === void 0 ? void 0 : _a.call(props);
|
8647 | if (props.closeOnMaskClick) {
|
8648 | (_b = props.onClose) === null || _b === void 0 ? void 0 : _b.call(props);
|
8649 | }
|
8650 | },
|
8651 | afterClose: props.afterClose,
|
8652 | className: classNames(`${classPrefix$1m}-popup`, props.popupClassName),
|
8653 | style: props.popupStyle,
|
8654 | getContainer: props.getContainer,
|
8655 | destroyOnClose: props.destroyOnClose,
|
8656 | forceRender: props.forceRender,
|
8657 | bodyStyle: styles === null || styles === void 0 ? void 0 : styles.body,
|
8658 | maskStyle: styles === null || styles === void 0 ? void 0 : styles.mask
|
8659 | }, withNativeProps(props, React$1.createElement("div", {
|
8660 | className: classPrefix$1m
|
8661 | }, props.extra && React$1.createElement("div", {
|
8662 | className: `${classPrefix$1m}-extra`
|
8663 | }, props.extra), React$1.createElement("div", {
|
8664 | className: `${classPrefix$1m}-button-list`
|
8665 | }, props.actions.map((action, index2) => React$1.createElement("div", {
|
8666 | key: action.key,
|
8667 | className: `${classPrefix$1m}-button-item-wrapper`
|
8668 | }, React$1.createElement("a", {
|
8669 | className: classNames("adm-plain-anchor", `${classPrefix$1m}-button-item`, {
|
8670 | [`${classPrefix$1m}-button-item-danger`]: action.danger,
|
8671 | [`${classPrefix$1m}-button-item-disabled`]: action.disabled,
|
8672 | [`${classPrefix$1m}-button-item-bold`]: action.bold
|
8673 | }),
|
8674 | onClick: () => {
|
8675 | var _a, _b, _c;
|
8676 | (_a = action.onClick) === null || _a === void 0 ? void 0 : _a.call(action);
|
8677 | (_b = props.onAction) === null || _b === void 0 ? void 0 : _b.call(props, action, index2);
|
8678 | if (props.closeOnAction) {
|
8679 | (_c = props.onClose) === null || _c === void 0 ? void 0 : _c.call(props);
|
8680 | }
|
8681 | },
|
8682 | role: "option",
|
8683 | "aria-disabled": action.disabled
|
8684 | }, React$1.createElement("div", {
|
8685 | className: `${classPrefix$1m}-button-item-name`
|
8686 | }, action.text), action.description && React$1.createElement("div", {
|
8687 | className: `${classPrefix$1m}-button-item-description`
|
8688 | }, action.description))))), props.cancelText && React$1.createElement("div", {
|
8689 | className: `${classPrefix$1m}-cancel`,
|
8690 | role: "option",
|
8691 | "aria-label": props.cancelText
|
8692 | }, React$1.createElement("div", {
|
8693 | className: `${classPrefix$1m}-button-item-wrapper`
|
8694 | }, React$1.createElement("a", {
|
8695 | className: classNames("adm-plain-anchor", `${classPrefix$1m}-button-item`),
|
8696 | onClick: props.onClose
|
8697 | }, React$1.createElement("div", {
|
8698 | className: `${classPrefix$1m}-button-item-name`
|
8699 | }, props.cancelText)))), props.safeArea && React$1.createElement(SafeArea, {
|
8700 | position: "bottom"
|
8701 | }))));
|
8702 | };
|
8703 | function showActionSheet(props) {
|
8704 | return renderImperatively(React$1.createElement(ActionSheet, Object.assign({}, props)));
|
8705 | }
|
8706 | const index$i = attachPropertiesToComponent(ActionSheet, {
|
8707 | show: showActionSheet
|
8708 | });
|
8709 | const classPrefix$1l = "adm-auto-center";
|
8710 | const AutoCenter = (props) => withNativeProps(props, React$1.createElement("div", {
|
8711 | className: classPrefix$1l
|
8712 | }, React$1.createElement("div", {
|
8713 | className: `${classPrefix$1l}-content`
|
8714 | }, props.children)));
|
8715 | const Fallback = React$1.memo(() => React$1.createElement("svg", {
|
8716 | className: "adm-avatar-fallback",
|
8717 | width: "88px",
|
8718 | height: "88px",
|
8719 | viewBox: "0 0 88 88",
|
8720 | version: "1.1"
|
8721 | }, React$1.createElement("title", null, "编组 3"), React$1.createElement("defs", null, React$1.createElement("polygon", {
|
8722 | id: "path-1",
|
8723 | points: "0 0 88 0 88 88 0 88"
|
8724 | })), React$1.createElement("g", {
|
8725 | id: "页面-1",
|
8726 | stroke: "none",
|
8727 | strokeWidth: "1",
|
8728 | fill: "none",
|
8729 | fillRule: "evenodd"
|
8730 | }, React$1.createElement("g", {
|
8731 | id: "语雀",
|
8732 | transform: "translate(-495.000000, -71.000000)"
|
8733 | }, React$1.createElement("g", {
|
8734 | id: "编组-3",
|
8735 | transform: "translate(495.000000, 71.000000)"
|
8736 | }, React$1.createElement("mask", {
|
8737 | id: "mask-2",
|
8738 | fill: "white"
|
8739 | }, React$1.createElement("use", {
|
8740 | xlinkHref: "#path-1"
|
8741 | })), React$1.createElement("use", {
|
8742 | id: "Mask",
|
8743 | fill: "#EEEEEE",
|
8744 | fillRule: "nonzero",
|
8745 | xlinkHref: "#path-1"
|
8746 | }), React$1.createElement("path", {
|
8747 | d: "M44.5707528,16 L43.4292117,16 L42.9575197,16.0086403 L42.9575195,16.0086403 C36.5215787,16.2615464 31.4341803,21.5678078 31.4344832,28.0273864 L31.4344832,34.7776551 L31.4495601,35.3716788 L31.4495593,35.3716628 C31.599687,38.5368723 32.9422041,41.5269327 35.2058513,43.7376716 L38.2147759,46.6775505 L38.4086219,46.8913989 C38.7747759,47.3385365 38.9750835,47.9001589 38.9750835,48.4833848 L38.9750835,48.8938006 L38.9556989,49.1897326 L38.9556989,49.1897325 C38.8577746,49.9812662 38.3754713,50.67284 37.667703,51.036605 L18.7375269,60.7440265 L18.4101421,60.9276334 L18.4101423,60.9276333 C16.9141658,61.8418636 16.0009389,63.4714674 16,65.2283758 L16,66.070809 L16.0129231,66.3948217 C16.1766149,68.4123376 17.860922,70 19.91569,70 L68.0843101,70 L68.08431,70 C70.2460467,70 71.9988087,68.243122 72,66.0751224 L72,65.2326893 C72,63.3382982 70.9446194,61.6037466 69.2624598,60.7440295 L50.3322837,51.036608 L50.3322835,51.0366079 C49.5291218,50.6249082 49.0240448,49.7962466 49.024903,48.8916436 L49.024903,48.4812278 C49.024903,47.8029608 49.3005955,47.1527756 49.7852106,46.6775603 L52.7941352,43.7376813 L52.7941354,43.7376811 C55.204308,41.3832325 56.5636029,38.151975 56.5633606,34.7776456 L56.5633606,28.0273769 L56.5633606,28.0273774 C56.5633606,21.3848531 51.1940878,16 44.5707524,16 L44.5707528,16 Z",
|
8748 | id: "形状",
|
8749 | fill: "#CCCCCC",
|
8750 | fillRule: "nonzero",
|
8751 | mask: "url(#mask-2)"
|
8752 | }))))));
|
8753 | var stagedComponents = {};
|
8754 | var __importDefault = commonjsGlobal && commonjsGlobal.__importDefault || function(mod) {
|
8755 | return mod && mod.__esModule ? mod : { "default": mod };
|
8756 | };
|
8757 | Object.defineProperty(stagedComponents, "__esModule", { value: true });
|
8758 | var staged_1 = stagedComponents.staged = void 0;
|
8759 | const react_1 = __importDefault(React$1);
|
8760 | function processNext(next) {
|
8761 | if (typeof next === "function") {
|
8762 | return react_1.default.createElement(Stage, { stage: next });
|
8763 | } else {
|
8764 | return next;
|
8765 | }
|
8766 | }
|
8767 | function Stage(props) {
|
8768 | const next = props.stage();
|
8769 | return processNext(next);
|
8770 | }
|
8771 | function staged(stage) {
|
8772 | return function Staged(props, ref) {
|
8773 | const next = stage(props, ref);
|
8774 | return processNext(next);
|
8775 | };
|
8776 | }
|
8777 | staged_1 = stagedComponents.staged = staged;
|
8778 | function toCSSLength(val) {
|
8779 | return typeof val === "number" ? `${val}px` : val;
|
8780 | }
|
8781 | const LazyDetector = (props) => {
|
8782 | const ref = React$1.useRef(null);
|
8783 | const [inViewport] = useInViewport(ref);
|
8784 | React$1.useEffect(() => {
|
8785 | if (inViewport) {
|
8786 | props.onActive();
|
8787 | }
|
8788 | }, [inViewport]);
|
8789 | return React$1.createElement("div", {
|
8790 | ref
|
8791 | });
|
8792 | };
|
8793 | const useIsomorphicUpdateLayoutEffect = createUpdateEffect(useIsomorphicLayoutEffect$2);
|
8794 | const ImageIcon = () => React$1.createElement("svg", {
|
8795 | viewBox: "0 0 48 48",
|
8796 | xmlns: "http://www.w3.org/2000/svg"
|
8797 | }, React$1.createElement("path", {
|
8798 | d: "M41.396 6.234c1.923 0 3.487 1.574 3.487 3.505v29.14c0 1.937-1.568 3.51-3.491 3.51H6.604c-1.923 0-3.487-1.573-3.487-3.51V9.745c0-1.936 1.564-3.51 3.487-3.51Zm0 2.847H6.604c-.355 0-.654.3-.654.658V34.9l5.989-8.707a2.373 2.373 0 0 1 1.801-1.005 2.405 2.405 0 0 1 1.933.752l4.182 4.525 7.58-11.005a2.374 2.374 0 0 1 1.96-1.01c.79 0 1.532.38 1.966 1.01L42.05 34.89V9.74a.664.664 0 0 0-.654-.658Zm-28.305 2.763a3.119 3.119 0 0 1 3.117 3.117 3.119 3.119 0 0 1-3.117 3.117 3.122 3.122 0 0 1-3.117-3.117 3.119 3.119 0 0 1 3.117-3.117Z",
|
8799 | fill: "#DBDBDB",
|
8800 | fillRule: "nonzero"
|
8801 | }));
|
8802 | const BrokenImageIcon = () => React$1.createElement("svg", {
|
8803 | viewBox: "0 0 48 48",
|
8804 | xmlns: "http://www.w3.org/2000/svg"
|
8805 | }, React$1.createElement("path", {
|
8806 | d: "M19.233 6.233 17.42 9.08l-10.817.001a.665.665 0 0 0-.647.562l-.007.096V34.9l5.989-8.707a2.373 2.373 0 0 1 1.801-1.005 2.415 2.415 0 0 1 1.807.625l.126.127 4.182 4.525 2.267-3.292 5.461 7.841-4.065 7.375H6.604c-1.86 0-3.382-1.47-3.482-3.317l-.005-.192V9.744c0-1.872 1.461-3.405 3.296-3.505l.19-.005h12.63Zm22.163 0c1.86 0 3.382 1.472 3.482 3.314l.005.192v29.14a3.507 3.507 0 0 1-3.3 3.505l-.191.006H27.789l3.63-6.587.06-.119a1.87 1.87 0 0 0-.163-1.853l-6.928-9.949 3.047-4.422a2.374 2.374 0 0 1 1.96-1.01 2.4 2.4 0 0 1 1.86.87l.106.14L42.05 34.89V9.74a.664.664 0 0 0-.654-.658H21.855l1.812-2.848h17.73Zm-28.305 5.611c.794 0 1.52.298 2.07.788l-.843 1.325-.067.114a1.87 1.87 0 0 0 .11 1.959l.848 1.217c-.556.515-1.3.83-2.118.83a3.122 3.122 0 0 1-3.117-3.116 3.119 3.119 0 0 1 3.117-3.117Z",
|
8807 | fill: "#DBDBDB",
|
8808 | fillRule: "nonzero"
|
8809 | }));
|
8810 | const classPrefix$1k = `adm-image`;
|
8811 | const defaultProps$11 = {
|
8812 | fit: "fill",
|
8813 | placeholder: React$1.createElement("div", {
|
8814 | className: `${classPrefix$1k}-tip`
|
8815 | }, React$1.createElement(ImageIcon, null)),
|
8816 | fallback: React$1.createElement("div", {
|
8817 | className: `${classPrefix$1k}-tip`
|
8818 | }, React$1.createElement(BrokenImageIcon, null)),
|
8819 | lazy: false,
|
8820 | draggable: false
|
8821 | };
|
8822 | const Image$1 = staged_1((p) => {
|
8823 | const props = mergeProps(defaultProps$11, p);
|
8824 | const [loaded, setLoaded] = React$1.useState(false);
|
8825 | const [failed, setFailed] = React$1.useState(false);
|
8826 | const ref = React$1.useRef(null);
|
8827 | const imgRef = React$1.useRef(null);
|
8828 | let src = props.src;
|
8829 | let srcSet = props.srcSet;
|
8830 | const [initialized, setInitialized] = React$1.useState(!props.lazy);
|
8831 | src = initialized ? props.src : void 0;
|
8832 | srcSet = initialized ? props.srcSet : void 0;
|
8833 | useIsomorphicUpdateLayoutEffect(() => {
|
8834 | setLoaded(false);
|
8835 | setFailed(false);
|
8836 | }, [src]);
|
8837 | React$1.useEffect(() => {
|
8838 | var _a;
|
8839 | if ((_a = imgRef.current) === null || _a === void 0 ? void 0 : _a.complete) {
|
8840 | setLoaded(true);
|
8841 | }
|
8842 | }, []);
|
8843 | function renderInner() {
|
8844 | if (failed) {
|
8845 | return React$1.createElement(React$1.Fragment, null, props.fallback);
|
8846 | }
|
8847 | const img = React$1.createElement("img", {
|
8848 | ref: imgRef,
|
8849 | id: props.id,
|
8850 | className: `${classPrefix$1k}-img`,
|
8851 | src,
|
8852 | alt: props.alt,
|
8853 | onClick: props.onClick,
|
8854 | onLoad: (e2) => {
|
8855 | var _a;
|
8856 | setLoaded(true);
|
8857 | (_a = props.onLoad) === null || _a === void 0 ? void 0 : _a.call(props, e2);
|
8858 | },
|
8859 | onError: (e2) => {
|
8860 | var _a;
|
8861 | setFailed(true);
|
8862 | (_a = props.onError) === null || _a === void 0 ? void 0 : _a.call(props, e2);
|
8863 | },
|
8864 | style: {
|
8865 | objectFit: props.fit,
|
8866 | display: loaded ? "block" : "none"
|
8867 | },
|
8868 | crossOrigin: props.crossOrigin,
|
8869 | decoding: props.decoding,
|
8870 | loading: props.loading,
|
8871 | referrerPolicy: props.referrerPolicy,
|
8872 | sizes: props.sizes,
|
8873 | srcSet,
|
8874 | useMap: props.useMap,
|
8875 | draggable: props.draggable
|
8876 | });
|
8877 | return React$1.createElement(React$1.Fragment, null, !loaded && props.placeholder, img);
|
8878 | }
|
8879 | const style = {};
|
8880 | if (props.width) {
|
8881 | style["--width"] = toCSSLength(props.width);
|
8882 | style["width"] = toCSSLength(props.width);
|
8883 | }
|
8884 | if (props.height) {
|
8885 | style["--height"] = toCSSLength(props.height);
|
8886 | style["height"] = toCSSLength(props.height);
|
8887 | }
|
8888 | return withNativeProps(props, React$1.createElement("div", {
|
8889 | ref,
|
8890 | className: classPrefix$1k,
|
8891 | style,
|
8892 | onClick: props.onContainerClick
|
8893 | }, props.lazy && !initialized && React$1.createElement(LazyDetector, {
|
8894 | onActive: () => {
|
8895 | setInitialized(true);
|
8896 | }
|
8897 | }), renderInner()));
|
8898 | });
|
8899 | const classPrefix$1j = "adm-avatar";
|
8900 | const defaultProps$10 = {
|
8901 | fallback: React$1.createElement(Fallback, null),
|
8902 | fit: "cover"
|
8903 | };
|
8904 | const Avatar = (p) => {
|
8905 | const props = mergeProps(defaultProps$10, p);
|
8906 | return withNativeProps(props, React$1.createElement(Image$1, {
|
8907 | className: classPrefix$1j,
|
8908 | src: props.src,
|
8909 | fallback: props.fallback,
|
8910 | placeholder: props.fallback,
|
8911 | alt: props.alt,
|
8912 | lazy: props.lazy,
|
8913 | fit: props.fit,
|
8914 | onClick: props.onClick,
|
8915 | onError: props.onError,
|
8916 | onLoad: props.onLoad
|
8917 | }));
|
8918 | };
|
8919 | const classPrefix$1i = `adm-badge`;
|
8920 | const dot = React$1.createElement(React$1.Fragment, null);
|
8921 | const Badge$1 = (props) => {
|
8922 | const {
|
8923 | content,
|
8924 | color,
|
8925 | children
|
8926 | } = props;
|
8927 | const isDot = content === dot;
|
8928 | const badgeClass = classNames(classPrefix$1i, {
|
8929 | [`${classPrefix$1i}-fixed`]: !!children,
|
8930 | [`${classPrefix$1i}-dot`]: isDot,
|
8931 | [`${classPrefix$1i}-bordered`]: props.bordered
|
8932 | });
|
8933 | const element = content || content === 0 ? withNativeProps(props, React$1.createElement("div", {
|
8934 | className: badgeClass,
|
8935 | style: {
|
8936 | "--color": color
|
8937 | }
|
8938 | }, !isDot && React$1.createElement("div", {
|
8939 | className: `${classPrefix$1i}-content`
|
8940 | }, content))) : null;
|
8941 | return children ? React$1.createElement("div", {
|
8942 | className: classNames(`${classPrefix$1i}-wrapper`, props.wrapperClassName),
|
8943 | style: props.wrapperStyle
|
8944 | }, children, element) : element;
|
8945 | };
|
8946 | const Badge = attachPropertiesToComponent(Badge$1, {
|
8947 | dot
|
8948 | });
|
8949 | const classPrefix$1h = `adm-dot-loading`;
|
8950 | const colorRecord$3 = {
|
8951 | default: "var(--adm-color-weak)",
|
8952 | primary: "var(--adm-color-primary)",
|
8953 | white: "var(--adm-color-white)"
|
8954 | };
|
8955 | const defaultProps$$ = {
|
8956 | color: "default"
|
8957 | };
|
8958 | const DotLoading = React$1.memo((p) => {
|
8959 | var _a;
|
8960 | const props = mergeProps(defaultProps$$, p);
|
8961 | return withNativeProps(props, React$1.createElement("div", {
|
8962 | style: {
|
8963 | color: (_a = colorRecord$3[props.color]) !== null && _a !== void 0 ? _a : props.color
|
8964 | },
|
8965 | className: classNames("adm-loading", classPrefix$1h)
|
8966 | }, React$1.createElement("svg", {
|
8967 | height: "1em",
|
8968 | viewBox: "0 0 100 40",
|
8969 | style: {
|
8970 | verticalAlign: "-0.125em"
|
8971 | }
|
8972 | }, React$1.createElement("g", {
|
8973 | stroke: "none",
|
8974 | strokeWidth: "1",
|
8975 | fill: "none",
|
8976 | fillRule: "evenodd"
|
8977 | }, React$1.createElement("g", {
|
8978 | transform: "translate(-100.000000, -71.000000)"
|
8979 | }, React$1.createElement("g", {
|
8980 | transform: "translate(95.000000, 71.000000)"
|
8981 | }, React$1.createElement("g", {
|
8982 | transform: "translate(5.000000, 0.000000)"
|
8983 | }, [0, 1, 2].map((i2) => React$1.createElement("rect", {
|
8984 | key: i2,
|
8985 | fill: "currentColor",
|
8986 | x: 20 + i2 * 26,
|
8987 | y: "16",
|
8988 | width: "8",
|
8989 | height: "8",
|
8990 | rx: "2"
|
8991 | }, React$1.createElement("animate", {
|
8992 | attributeName: "y",
|
8993 | from: "16",
|
8994 | to: "16",
|
8995 | dur: "2s",
|
8996 | begin: `${i2 * 0.2}s`,
|
8997 | repeatCount: "indefinite",
|
8998 | values: "16; 6; 26; 16; 16",
|
8999 | keyTimes: "0; 0.1; 0.3; 0.4; 1"
|
9000 | }))))))))));
|
9001 | });
|
9002 | function isPromise(obj) {
|
9003 | return !!obj && typeof obj === "object" && typeof obj.then === "function";
|
9004 | }
|
9005 | function isIOS() {
|
9006 | return canUseDom$1 ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
|
9007 | }
|
9008 | const classPrefix$1g = `adm-button`;
|
9009 | const defaultProps$_ = {
|
9010 | color: "default",
|
9011 | fill: "solid",
|
9012 | block: false,
|
9013 | loading: false,
|
9014 | loadingIcon: React$1.createElement(DotLoading, {
|
9015 | color: "currentColor"
|
9016 | }),
|
9017 | type: "button",
|
9018 | shape: "default",
|
9019 | size: "middle"
|
9020 | };
|
9021 | const Button = React$1.forwardRef((p, ref) => {
|
9022 | const props = mergeProps(defaultProps$_, p);
|
9023 | const [innerLoading, setInnerLoading] = React$1.useState(false);
|
9024 | const nativeButtonRef = React$1.useRef(null);
|
9025 | const loading = props.loading === "auto" ? innerLoading : props.loading;
|
9026 | const disabled = props.disabled || loading;
|
9027 | React$1.useImperativeHandle(ref, () => ({
|
9028 | get nativeElement() {
|
9029 | return nativeButtonRef.current;
|
9030 | }
|
9031 | }));
|
9032 | const handleClick = (e2) => __awaiter(void 0, void 0, void 0, function* () {
|
9033 | if (!props.onClick)
|
9034 | return;
|
9035 | const promise = props.onClick(e2);
|
9036 | if (isPromise(promise)) {
|
9037 | try {
|
9038 | setInnerLoading(true);
|
9039 | yield promise;
|
9040 | setInnerLoading(false);
|
9041 | } catch (e3) {
|
9042 | setInnerLoading(false);
|
9043 | throw e3;
|
9044 | }
|
9045 | }
|
9046 | });
|
9047 | return withNativeProps(props, React$1.createElement("button", {
|
9048 | ref: nativeButtonRef,
|
9049 | type: props.type,
|
9050 | onClick: handleClick,
|
9051 | className: classNames(classPrefix$1g, {
|
9052 | [`${classPrefix$1g}-${props.color}`]: props.color,
|
9053 | [`${classPrefix$1g}-block`]: props.block,
|
9054 | [`${classPrefix$1g}-disabled`]: disabled,
|
9055 | [`${classPrefix$1g}-fill-outline`]: props.fill === "outline",
|
9056 | [`${classPrefix$1g}-fill-none`]: props.fill === "none",
|
9057 | [`${classPrefix$1g}-mini`]: props.size === "mini",
|
9058 | [`${classPrefix$1g}-small`]: props.size === "small",
|
9059 | [`${classPrefix$1g}-large`]: props.size === "large",
|
9060 | [`${classPrefix$1g}-loading`]: loading
|
9061 | }, `${classPrefix$1g}-shape-${props.shape}`),
|
9062 | disabled,
|
9063 | onMouseDown: props.onMouseDown,
|
9064 | onMouseUp: props.onMouseUp,
|
9065 | onTouchStart: props.onTouchStart,
|
9066 | onTouchEnd: props.onTouchEnd
|
9067 | }, loading ? React$1.createElement("div", {
|
9068 | className: `${classPrefix$1g}-loading-wrapper`
|
9069 | }, props.loadingIcon, props.loadingText) : React$1.createElement("span", null, props.children)));
|
9070 | });
|
9071 | const ArrowLeft = () => {
|
9072 | return React$1.createElement("svg", {
|
9073 | height: "1em",
|
9074 | viewBox: "0 0 44 44"
|
9075 | }, React$1.createElement("g", {
|
9076 | stroke: "none",
|
9077 | strokeWidth: "1",
|
9078 | fill: "none",
|
9079 | fillRule: "evenodd"
|
9080 | }, React$1.createElement("g", {
|
9081 | transform: "translate(-100.000000, -22.000000)"
|
9082 | }, React$1.createElement("g", {
|
9083 | transform: "translate(100.000000, 22.000000)"
|
9084 | }, React$1.createElement("rect", {
|
9085 | x: "0",
|
9086 | y: "0",
|
9087 | width: "44",
|
9088 | height: "44"
|
9089 | }), React$1.createElement("g", {
|
9090 | transform: "translate(12.000000, 4.000000)",
|
9091 | fill: "currentColor",
|
9092 | fillRule: "nonzero"
|
9093 | }, React$1.createElement("path", {
|
9094 | d: "M19.4833058,2.71985611 L3.53051139,17.0699744 C3.0173831,17.5315665 2.97522952,18.3220903 3.43630803,18.8357433 L3.43630796,18.8357432 C3.46601289,18.8688164 3.49745845,18.9002801 3.53051133,18.9300007 L19.4833057,33.2801611 C20.1234001,33.8559077 20.1759552,34.8420707 19.6007967,35.4827774 C19.0256382,36.1235263 18.0404824,36.1761351 17.400388,35.6003885 L1.44759367,21.2502703 L1.4475933,21.25027 C1.33208743,21.1463692 1.22220259,21.036372 1.11840792,20.920748 C-0.49302969,19.1256817 -0.345639536,16.3628317 1.4475933,14.7497465 L17.4003877,0.399628282 C18.0404821,-0.176160428 19.0256378,-0.123509422 19.6007963,0.517239417 C20.1759548,1.1579461 20.1233997,2.14410915 19.4833053,2.7198557 L19.4833058,2.71985611 Z"
|
9095 | }))))));
|
9096 | };
|
9097 | const ArrowLeftDouble = () => {
|
9098 | return React$1.createElement("svg", {
|
9099 | height: "1em",
|
9100 | viewBox: "0 0 44 44"
|
9101 | }, React$1.createElement("g", {
|
9102 | stroke: "none",
|
9103 | strokeWidth: "1",
|
9104 | fill: "none",
|
9105 | fillRule: "evenodd"
|
9106 | }, React$1.createElement("g", {
|
9107 | transform: "translate(-24.000000, -22.000000)"
|
9108 | }, React$1.createElement("g", {
|
9109 | transform: "translate(24.000000, 22.000000)"
|
9110 | }, React$1.createElement("rect", {
|
9111 | x: "0",
|
9112 | y: "0",
|
9113 | width: "44",
|
9114 | height: "44"
|
9115 | }), React$1.createElement("g", {
|
9116 | transform: "translate(7.000000, 4.000000)",
|
9117 | fill: "currentColor",
|
9118 | fillRule: "nonzero"
|
9119 | }, React$1.createElement("path", {
|
9120 | d: "M19.4833058,2.71985611 L3.53051139,17.0699744 C3.0173831,17.5315665 2.97522952,18.3220903 3.43630803,18.8357433 L3.43630796,18.8357432 C3.46601289,18.8688164 3.49745845,18.9002801 3.53051133,18.9300007 L19.4833057,33.2801611 C20.1234001,33.8559077 20.1759552,34.8420707 19.6007967,35.4827774 C19.0256382,36.1235263 18.0404824,36.1761351 17.400388,35.6003885 L1.44759367,21.2502703 L1.4475933,21.25027 C1.33208743,21.1463692 1.22220259,21.036372 1.11840792,20.920748 C-0.49302969,19.1256817 -0.345639536,16.3628317 1.4475933,14.7497465 L17.4003877,0.399628282 C18.0404821,-0.176160428 19.0256378,-0.123509422 19.6007963,0.517239417 C20.1759548,1.1579461 20.1233997,2.14410915 19.4833053,2.7198557 L19.4833058,2.71985611 Z"
|
9121 | }), React$1.createElement("path", {
|
9122 | d: "M19.5305114,17.0699744 C19.0173831,17.5315665 18.9752295,18.3220903 19.436308,18.8357433 C19.4660129,18.8688164 19.4974585,18.9002801 19.5305113,18.9300007 L29.4833057,27.2801611 C30.1234001,27.8559077 30.1759552,28.8420707 29.6007967,29.4827774 C29.0256382,30.1235263 28.0404824,30.1761351 27.400388,29.6003885 L17.4475937,21.2502703 C17.3320874,21.1463692 17.2222026,21.036372 17.1184079,20.920748 C15.5069703,19.1256817 15.6543605,16.3628317 17.4475933,14.7497465 L27.4003877,6.39962828 C28.0404821,5.82383957 29.0256378,5.87649058 29.6007963,6.51723942 C30.1759548,7.1579461 30.1233997,8.14410915 29.4833053,8.7198557 L19.5305114,17.0699744 Z"
|
9123 | }))))));
|
9124 | };
|
9125 | var isoWeek$1 = { exports: {} };
|
9126 | (function(module2, exports3) {
|
9127 | !function(e2, t) {
|
9128 | module2.exports = t();
|
9129 | }(commonjsGlobal, function() {
|
9130 | var e2 = "day";
|
9131 | return function(t, i2, s) {
|
9132 | var a = function(t2) {
|
9133 | return t2.add(4 - t2.isoWeekday(), e2);
|
9134 | }, d = i2.prototype;
|
9135 | d.isoWeekYear = function() {
|
9136 | return a(this).year();
|
9137 | }, d.isoWeek = function(t2) {
|
9138 | if (!this.$utils().u(t2))
|
9139 | return this.add(7 * (t2 - this.isoWeek()), e2);
|
9140 | var i3, d2, n3, o, r = a(this), u = (i3 = this.isoWeekYear(), d2 = this.$u, n3 = (d2 ? s.utc : s)().year(i3).startOf("year"), o = 4 - n3.isoWeekday(), n3.isoWeekday() > 4 && (o += 7), n3.add(o, e2));
|
9141 | return r.diff(u, "week") + 1;
|
9142 | }, d.isoWeekday = function(e3) {
|
9143 | return this.$utils().u(e3) ? this.day() || 7 : this.day(this.day() % 7 ? e3 : e3 - 7);
|
9144 | };
|
9145 | var n2 = d.startOf;
|
9146 | d.startOf = function(e3, t2) {
|
9147 | var i3 = this.$utils(), s2 = !!i3.u(t2) || t2;
|
9148 | return "isoweek" === i3.p(e3) ? s2 ? this.date(this.date() - (this.isoWeekday() - 1)).startOf("day") : this.date(this.date() - 1 - (this.isoWeekday() - 1) + 7).endOf("day") : n2.bind(this)(e3, t2);
|
9149 | };
|
9150 | };
|
9151 | });
|
9152 | })(isoWeek$1);
|
9153 | var isoWeekExports = isoWeek$1.exports;
|
9154 | const isoWeek = getDefaultExportFromCjs(isoWeekExports);
|
9155 | function usePropsValue(options) {
|
9156 | const {
|
9157 | value,
|
9158 | defaultValue,
|
9159 | onChange
|
9160 | } = options;
|
9161 | const update2 = useUpdate$1();
|
9162 | const stateRef = React$1.useRef(value !== void 0 ? value : defaultValue);
|
9163 | if (value !== void 0) {
|
9164 | stateRef.current = value;
|
9165 | }
|
9166 | const setState = useMemoizedFn((v, forceTrigger = false) => {
|
9167 | const nextValue = typeof v === "function" ? v(stateRef.current) : v;
|
9168 | if (!forceTrigger && nextValue === stateRef.current)
|
9169 | return;
|
9170 | stateRef.current = nextValue;
|
9171 | update2();
|
9172 | return onChange === null || onChange === void 0 ? void 0 : onChange(nextValue);
|
9173 | });
|
9174 | return [stateRef.current, setState];
|
9175 | }
|
9176 | function replaceMessage$1(template, kv) {
|
9177 | return template.replace(/\$\{\w+\}/g, (str) => {
|
9178 | const key = str.slice(2, -1);
|
9179 | return kv[key];
|
9180 | });
|
9181 | }
|
9182 | function devWarning(component, message) {
|
9183 | {
|
9184 | console.warn(`[antd-mobile: ${component}] ${message}`);
|
9185 | }
|
9186 | }
|
9187 | function devError(component, message) {
|
9188 | {
|
9189 | console.error(`[antd-mobile: ${component}] ${message}`);
|
9190 | }
|
9191 | }
|
9192 | function convertValueToRange$1(selectionMode, value) {
|
9193 | if (selectionMode === void 0 || value === null)
|
9194 | return null;
|
9195 | if (Array.isArray(value)) {
|
9196 | return value;
|
9197 | }
|
9198 | return [value, value];
|
9199 | }
|
9200 | function convertPageToDayjs$1(page) {
|
9201 | return dayjs().year(page.year).month(page.month - 1).date(1);
|
9202 | }
|
9203 | dayjs.extend(isoWeek);
|
9204 | const classPrefix$1f = "adm-calendar";
|
9205 | const defaultProps$Z = {
|
9206 | weekStartsOn: "Sunday",
|
9207 | defaultValue: null,
|
9208 | allowClear: true,
|
9209 | prevMonthButton: React$1.createElement(ArrowLeft, null),
|
9210 | prevYearButton: React$1.createElement(ArrowLeftDouble, null),
|
9211 | nextMonthButton: React$1.createElement(ArrowLeft, null),
|
9212 | nextYearButton: React$1.createElement(ArrowLeftDouble, null)
|
9213 | };
|
9214 | const Calendar = React$1.forwardRef((p, ref) => {
|
9215 | const today = dayjs();
|
9216 | const props = mergeProps(defaultProps$Z, p);
|
9217 | const {
|
9218 | locale
|
9219 | } = useConfig();
|
9220 | const markItems = [...locale.Calendar.markItems];
|
9221 | if (props.weekStartsOn === "Sunday") {
|
9222 | const item = markItems.pop();
|
9223 | if (item)
|
9224 | markItems.unshift(item);
|
9225 | }
|
9226 | const [dateRange, setDateRange] = usePropsValue({
|
9227 | value: props.value === void 0 ? void 0 : convertValueToRange$1(props.selectionMode, props.value),
|
9228 | defaultValue: convertValueToRange$1(props.selectionMode, props.defaultValue),
|
9229 | onChange: (v) => {
|
9230 | var _a, _b;
|
9231 | if (props.selectionMode === "single") {
|
9232 | (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, v ? v[0] : null);
|
9233 | } else if (props.selectionMode === "range") {
|
9234 | (_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, v);
|
9235 | }
|
9236 | }
|
9237 | });
|
9238 | const [intermediate, setIntermediate] = React$1.useState(false);
|
9239 | const [current, setCurrent] = React$1.useState(() => dayjs(dateRange ? dateRange[0] : today).date(1));
|
9240 | useUpdateEffect(() => {
|
9241 | var _a;
|
9242 | (_a = props.onPageChange) === null || _a === void 0 ? void 0 : _a.call(props, current.year(), current.month() + 1);
|
9243 | }, [current]);
|
9244 | React$1.useImperativeHandle(ref, () => ({
|
9245 | jumpTo: (pageOrPageGenerator) => {
|
9246 | let page;
|
9247 | if (typeof pageOrPageGenerator === "function") {
|
9248 | page = pageOrPageGenerator({
|
9249 | year: current.year(),
|
9250 | month: current.month() + 1
|
9251 | });
|
9252 | } else {
|
9253 | page = pageOrPageGenerator;
|
9254 | }
|
9255 | setCurrent(convertPageToDayjs$1(page));
|
9256 | },
|
9257 | jumpToToday: () => {
|
9258 | setCurrent(dayjs().date(1));
|
9259 | }
|
9260 | }));
|
9261 | const handlePageChange = (action, num, type) => {
|
9262 | const nxtCurrent = current[action](num, type);
|
9263 | if (action === "subtract" && props.minPage) {
|
9264 | const minPage = convertPageToDayjs$1(props.minPage);
|
9265 | if (nxtCurrent.isBefore(minPage, type)) {
|
9266 | return;
|
9267 | }
|
9268 | }
|
9269 | if (action === "add" && props.maxPage) {
|
9270 | const maxPage = convertPageToDayjs$1(props.maxPage);
|
9271 | if (nxtCurrent.isAfter(maxPage, type)) {
|
9272 | return;
|
9273 | }
|
9274 | }
|
9275 | setCurrent(nxtCurrent);
|
9276 | };
|
9277 | const header = React$1.createElement("div", {
|
9278 | className: `${classPrefix$1f}-header`
|
9279 | }, React$1.createElement("a", {
|
9280 | className: `${classPrefix$1f}-arrow-button ${classPrefix$1f}-arrow-button-year`,
|
9281 | onClick: () => {
|
9282 | handlePageChange("subtract", 1, "year");
|
9283 | }
|
9284 | }, props.prevYearButton), React$1.createElement("a", {
|
9285 | className: `${classPrefix$1f}-arrow-button ${classPrefix$1f}-arrow-button-month`,
|
9286 | onClick: () => {
|
9287 | handlePageChange("subtract", 1, "month");
|
9288 | }
|
9289 | }, props.prevMonthButton), React$1.createElement("div", {
|
9290 | className: `${classPrefix$1f}-title`
|
9291 | }, replaceMessage$1(locale.Calendar.yearAndMonth, {
|
9292 | year: current.year().toString(),
|
9293 | month: (current.month() + 1).toString()
|
9294 | })), React$1.createElement("a", {
|
9295 | className: classNames(`${classPrefix$1f}-arrow-button`, `${classPrefix$1f}-arrow-button-right`, `${classPrefix$1f}-arrow-button-right-month`),
|
9296 | onClick: () => {
|
9297 | handlePageChange("add", 1, "month");
|
9298 | }
|
9299 | }, props.nextMonthButton), React$1.createElement("a", {
|
9300 | className: classNames(`${classPrefix$1f}-arrow-button`, `${classPrefix$1f}-arrow-button-right`, `${classPrefix$1f}-arrow-button-right-year`),
|
9301 | onClick: () => {
|
9302 | handlePageChange("add", 1, "year");
|
9303 | }
|
9304 | }, props.nextYearButton));
|
9305 | const maxDay = React$1.useMemo(() => props.max && dayjs(props.max), [props.max]);
|
9306 | const minDay = React$1.useMemo(() => props.min && dayjs(props.min), [props.min]);
|
9307 | function renderCells() {
|
9308 | var _a;
|
9309 | const cells = [];
|
9310 | let iterator = current.subtract(current.isoWeekday(), "day");
|
9311 | if (props.weekStartsOn === "Monday") {
|
9312 | iterator = iterator.add(1, "day");
|
9313 | }
|
9314 | while (cells.length < 6 * 7) {
|
9315 | const d = iterator;
|
9316 | let isSelect = false;
|
9317 | let isBegin = false;
|
9318 | let isEnd = false;
|
9319 | let isSelectRowBegin = false;
|
9320 | let isSelectRowEnd = false;
|
9321 | if (dateRange) {
|
9322 | const [begin, end] = dateRange;
|
9323 | isBegin = d.isSame(begin, "day");
|
9324 | isEnd = d.isSame(end, "day");
|
9325 | isSelect = isBegin || isEnd || d.isAfter(begin, "day") && d.isBefore(end, "day");
|
9326 | if (isSelect) {
|
9327 | isSelectRowBegin = (cells.length % 7 === 0 || d.isSame(d.startOf("month"), "day")) && !isBegin;
|
9328 | isSelectRowEnd = (cells.length % 7 === 6 || d.isSame(d.endOf("month"), "day")) && !isEnd;
|
9329 | }
|
9330 | }
|
9331 | const inThisMonth = d.month() === current.month();
|
9332 | const disabled = props.shouldDisableDate ? props.shouldDisableDate(d.toDate()) : maxDay && d.isAfter(maxDay, "day") || minDay && d.isBefore(minDay, "day");
|
9333 | cells.push(React$1.createElement("div", {
|
9334 | key: d.valueOf(),
|
9335 | className: classNames(`${classPrefix$1f}-cell`, (disabled || !inThisMonth) && `${classPrefix$1f}-cell-disabled`, inThisMonth && {
|
9336 | [`${classPrefix$1f}-cell-today`]: d.isSame(today, "day"),
|
9337 | [`${classPrefix$1f}-cell-selected`]: isSelect,
|
9338 | [`${classPrefix$1f}-cell-selected-begin`]: isBegin,
|
9339 | [`${classPrefix$1f}-cell-selected-end`]: isEnd,
|
9340 | [`${classPrefix$1f}-cell-selected-row-begin`]: isSelectRowBegin,
|
9341 | [`${classPrefix$1f}-cell-selected-row-end`]: isSelectRowEnd
|
9342 | }),
|
9343 | onClick: () => {
|
9344 | if (!props.selectionMode)
|
9345 | return;
|
9346 | if (disabled)
|
9347 | return;
|
9348 | const date = d.toDate();
|
9349 | if (!inThisMonth) {
|
9350 | setCurrent(d.clone().date(1));
|
9351 | }
|
9352 | function shouldClear() {
|
9353 | if (!props.allowClear)
|
9354 | return false;
|
9355 | if (!dateRange)
|
9356 | return false;
|
9357 | const [begin, end] = dateRange;
|
9358 | return d.isSame(begin, "date") && d.isSame(end, "day");
|
9359 | }
|
9360 | if (props.selectionMode === "single") {
|
9361 | if (props.allowClear && shouldClear()) {
|
9362 | setDateRange(null);
|
9363 | return;
|
9364 | }
|
9365 | setDateRange([date, date]);
|
9366 | } else if (props.selectionMode === "range") {
|
9367 | if (!dateRange) {
|
9368 | setDateRange([date, date]);
|
9369 | setIntermediate(true);
|
9370 | return;
|
9371 | }
|
9372 | if (shouldClear()) {
|
9373 | setDateRange(null);
|
9374 | setIntermediate(false);
|
9375 | return;
|
9376 | }
|
9377 | if (intermediate) {
|
9378 | const another = dateRange[0];
|
9379 | setDateRange(another > date ? [date, another] : [another, date]);
|
9380 | setIntermediate(false);
|
9381 | } else {
|
9382 | setDateRange([date, date]);
|
9383 | setIntermediate(true);
|
9384 | }
|
9385 | }
|
9386 | }
|
9387 | }, React$1.createElement("div", {
|
9388 | className: `${classPrefix$1f}-cell-top`
|
9389 | }, props.renderDate ? props.renderDate(d.toDate()) : d.date()), React$1.createElement("div", {
|
9390 | className: `${classPrefix$1f}-cell-bottom`
|
9391 | }, (_a = props.renderLabel) === null || _a === void 0 ? void 0 : _a.call(props, d.toDate()))));
|
9392 | iterator = iterator.add(1, "day");
|
9393 | }
|
9394 | return cells;
|
9395 | }
|
9396 | const body = React$1.createElement("div", {
|
9397 | className: `${classPrefix$1f}-cells`
|
9398 | }, renderCells());
|
9399 | const mark = React$1.createElement("div", {
|
9400 | className: `${classPrefix$1f}-mark`
|
9401 | }, markItems.map((item, index2) => React$1.createElement("div", {
|
9402 | key: index2,
|
9403 | className: `${classPrefix$1f}-mark-cell`
|
9404 | }, item)));
|
9405 | {
|
9406 | React$1.useEffect(() => {
|
9407 | devWarning("Calendar", "Calendar will be removed in the future, please use CalendarPickerView instead.");
|
9408 | }, []);
|
9409 | }
|
9410 | return withNativeProps(props, React$1.createElement("div", {
|
9411 | className: classPrefix$1f
|
9412 | }, header, mark, body));
|
9413 | });
|
9414 | var isSameOrBefore$1 = { exports: {} };
|
9415 | (function(module2, exports3) {
|
9416 | !function(e2, i2) {
|
9417 | module2.exports = i2();
|
9418 | }(commonjsGlobal, function() {
|
9419 | return function(e2, i2) {
|
9420 | i2.prototype.isSameOrBefore = function(e3, i3) {
|
9421 | return this.isSame(e3, i3) || this.isBefore(e3, i3);
|
9422 | };
|
9423 | };
|
9424 | });
|
9425 | })(isSameOrBefore$1);
|
9426 | var isSameOrBeforeExports = isSameOrBefore$1.exports;
|
9427 | const isSameOrBefore = getDefaultExportFromCjs(isSameOrBeforeExports);
|
9428 | function convertValueToRange(selectionMode, value) {
|
9429 | if (selectionMode === void 0 || value === null)
|
9430 | return null;
|
9431 | if (Array.isArray(value)) {
|
9432 | return value;
|
9433 | }
|
9434 | return [value, value];
|
9435 | }
|
9436 | function convertPageToDayjs(page) {
|
9437 | return dayjs().year(page.year).month(page.month - 1).date(1);
|
9438 | }
|
9439 | function useEvent(callback) {
|
9440 | var fnRef = React__namespace.useRef();
|
9441 | fnRef.current = callback;
|
9442 | var memoFn = React__namespace.useCallback(function() {
|
9443 | var _fnRef$current;
|
9444 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
9445 | args[_key] = arguments[_key];
|
9446 | }
|
9447 | return (_fnRef$current = fnRef.current) === null || _fnRef$current === void 0 ? void 0 : _fnRef$current.call.apply(_fnRef$current, [fnRef].concat(args));
|
9448 | }, []);
|
9449 | return memoFn;
|
9450 | }
|
9451 | function _arrayWithHoles(arr) {
|
9452 | if (Array.isArray(arr))
|
9453 | return arr;
|
9454 | }
|
9455 | function _iterableToArrayLimit(r, l) {
|
9456 | var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
9457 | if (null != t) {
|
9458 | var e2, n2, i2, u, a = [], f = true, o = false;
|
9459 | try {
|
9460 | if (i2 = (t = t.call(r)).next, 0 === l) {
|
9461 | if (Object(t) !== t)
|
9462 | return;
|
9463 | f = false;
|
9464 | } else
|
9465 | for (; !(f = (e2 = i2.call(t)).done) && (a.push(e2.value), a.length !== l); f = true)
|
9466 | ;
|
9467 | } catch (r2) {
|
9468 | o = true, n2 = r2;
|
9469 | } finally {
|
9470 | try {
|
9471 | if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u))
|
9472 | return;
|
9473 | } finally {
|
9474 | if (o)
|
9475 | throw n2;
|
9476 | }
|
9477 | }
|
9478 | return a;
|
9479 | }
|
9480 | }
|
9481 | function _arrayLikeToArray(arr, len) {
|
9482 | if (len == null || len > arr.length)
|
9483 | len = arr.length;
|
9484 | for (var i2 = 0, arr2 = new Array(len); i2 < len; i2++)
|
9485 | arr2[i2] = arr[i2];
|
9486 | return arr2;
|
9487 | }
|
9488 | function _unsupportedIterableToArray(o, minLen) {
|
9489 | if (!o)
|
9490 | return;
|
9491 | if (typeof o === "string")
|
9492 | return _arrayLikeToArray(o, minLen);
|
9493 | var n2 = Object.prototype.toString.call(o).slice(8, -1);
|
9494 | if (n2 === "Object" && o.constructor)
|
9495 | n2 = o.constructor.name;
|
9496 | if (n2 === "Map" || n2 === "Set")
|
9497 | return Array.from(o);
|
9498 | if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2))
|
9499 | return _arrayLikeToArray(o, minLen);
|
9500 | }
|
9501 | function _nonIterableRest() {
|
9502 | throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
9503 | }
|
9504 | function _slicedToArray(arr, i2) {
|
9505 | return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i2) || _unsupportedIterableToArray(arr, i2) || _nonIterableRest();
|
9506 | }
|
9507 | function canUseDom() {
|
9508 | return !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
9509 | }
|
9510 | var useInternalLayoutEffect = canUseDom() ? React__namespace.useLayoutEffect : React__namespace.useEffect;
|
9511 | var useLayoutEffect = function useLayoutEffect2(callback, deps) {
|
9512 | var firstMountRef = React__namespace.useRef(true);
|
9513 | useInternalLayoutEffect(function() {
|
9514 | return callback(firstMountRef.current);
|
9515 | }, deps);
|
9516 | useInternalLayoutEffect(function() {
|
9517 | firstMountRef.current = false;
|
9518 | return function() {
|
9519 | firstMountRef.current = true;
|
9520 | };
|
9521 | }, []);
|
9522 | };
|
9523 | var useLayoutUpdateEffect = function useLayoutUpdateEffect2(callback, deps) {
|
9524 | useLayoutEffect(function(firstMount) {
|
9525 | if (!firstMount) {
|
9526 | return callback();
|
9527 | }
|
9528 | }, deps);
|
9529 | };
|
9530 | function useSafeState(defaultValue) {
|
9531 | var destroyRef = React__namespace.useRef(false);
|
9532 | var _React$useState = React__namespace.useState(defaultValue), _React$useState2 = _slicedToArray(_React$useState, 2), value = _React$useState2[0], setValue2 = _React$useState2[1];
|
9533 | React__namespace.useEffect(function() {
|
9534 | destroyRef.current = false;
|
9535 | return function() {
|
9536 | destroyRef.current = true;
|
9537 | };
|
9538 | }, []);
|
9539 | function safeSetState(updater, ignoreDestroy) {
|
9540 | if (ignoreDestroy && destroyRef.current) {
|
9541 | return;
|
9542 | }
|
9543 | setValue2(updater);
|
9544 | }
|
9545 | return [value, safeSetState];
|
9546 | }
|
9547 | function hasValue(value) {
|
9548 | return value !== void 0;
|
9549 | }
|
9550 | function useMergedState(defaultStateValue, option) {
|
9551 | var _ref = option || {}, defaultValue = _ref.defaultValue, value = _ref.value, onChange = _ref.onChange, postState = _ref.postState;
|
9552 | var _useState = useSafeState(function() {
|
9553 | if (hasValue(value)) {
|
9554 | return value;
|
9555 | } else if (hasValue(defaultValue)) {
|
9556 | return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
9557 | } else {
|
9558 | return typeof defaultStateValue === "function" ? defaultStateValue() : defaultStateValue;
|
9559 | }
|
9560 | }), _useState2 = _slicedToArray(_useState, 2), innerValue = _useState2[0], setInnerValue = _useState2[1];
|
9561 | var mergedValue = value !== void 0 ? value : innerValue;
|
9562 | var postMergedValue = postState ? postState(mergedValue) : mergedValue;
|
9563 | var onChangeFn = useEvent(onChange);
|
9564 | var _useState3 = useSafeState([mergedValue]), _useState4 = _slicedToArray(_useState3, 2), prevValue = _useState4[0], setPrevValue = _useState4[1];
|
9565 | useLayoutUpdateEffect(function() {
|
9566 | var prev = prevValue[0];
|
9567 | if (innerValue !== prev) {
|
9568 | onChangeFn(innerValue, prev);
|
9569 | }
|
9570 | }, [prevValue]);
|
9571 | useLayoutUpdateEffect(function() {
|
9572 | if (!hasValue(value)) {
|
9573 | setInnerValue(value);
|
9574 | }
|
9575 | }, [value]);
|
9576 | var triggerChange = useEvent(function(updater, ignoreDestroy) {
|
9577 | setInnerValue(updater, ignoreDestroy);
|
9578 | setPrevValue([mergedValue], ignoreDestroy);
|
9579 | });
|
9580 | return [postMergedValue, triggerChange];
|
9581 | }
|
9582 | function _typeof$1(o) {
|
9583 | "@babel/helpers - typeof";
|
9584 | return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
9585 | return typeof o2;
|
9586 | } : function(o2) {
|
9587 | return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
9588 | }, _typeof$1(o);
|
9589 | }
|
9590 | var reactIs = { exports: {} };
|
9591 | var reactIs_development = {};
|
9592 | |
9593 |
|
9594 |
|
9595 |
|
9596 |
|
9597 |
|
9598 |
|
9599 |
|
9600 |
|
9601 | {
|
9602 | (function() {
|
9603 | var REACT_ELEMENT_TYPE2 = Symbol.for("react.element");
|
9604 | var REACT_PORTAL_TYPE = Symbol.for("react.portal");
|
9605 | var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
9606 | var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
|
9607 | var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
|
9608 | var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
|
9609 | var REACT_CONTEXT_TYPE = Symbol.for("react.context");
|
9610 | var REACT_SERVER_CONTEXT_TYPE = Symbol.for("react.server_context");
|
9611 | var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
|
9612 | var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
|
9613 | var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
|
9614 | var REACT_MEMO_TYPE = Symbol.for("react.memo");
|
9615 | var REACT_LAZY_TYPE = Symbol.for("react.lazy");
|
9616 | var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
|
9617 | var enableScopeAPI = false;
|
9618 | var enableCacheElement = false;
|
9619 | var enableTransitionTracing = false;
|
9620 | var enableLegacyHidden = false;
|
9621 | var enableDebugTracing = false;
|
9622 | var REACT_MODULE_REFERENCE;
|
9623 | {
|
9624 | REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
|
9625 | }
|
9626 | function isValidElementType(type) {
|
9627 | if (typeof type === "string" || typeof type === "function") {
|
9628 | return true;
|
9629 | }
|
9630 | if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) {
|
9631 | return true;
|
9632 | }
|
9633 | if (typeof type === "object" && type !== null) {
|
9634 | if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE ||
|
9635 |
|
9636 |
|
9637 |
|
9638 | type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== void 0) {
|
9639 | return true;
|
9640 | }
|
9641 | }
|
9642 | return false;
|
9643 | }
|
9644 | function typeOf(object) {
|
9645 | if (typeof object === "object" && object !== null) {
|
9646 | var $$typeof = object.$$typeof;
|
9647 | switch ($$typeof) {
|
9648 | case REACT_ELEMENT_TYPE2:
|
9649 | var type = object.type;
|
9650 | switch (type) {
|
9651 | case REACT_FRAGMENT_TYPE:
|
9652 | case REACT_PROFILER_TYPE:
|
9653 | case REACT_STRICT_MODE_TYPE:
|
9654 | case REACT_SUSPENSE_TYPE:
|
9655 | case REACT_SUSPENSE_LIST_TYPE:
|
9656 | return type;
|
9657 | default:
|
9658 | var $$typeofType = type && type.$$typeof;
|
9659 | switch ($$typeofType) {
|
9660 | case REACT_SERVER_CONTEXT_TYPE:
|
9661 | case REACT_CONTEXT_TYPE:
|
9662 | case REACT_FORWARD_REF_TYPE:
|
9663 | case REACT_LAZY_TYPE:
|
9664 | case REACT_MEMO_TYPE:
|
9665 | case REACT_PROVIDER_TYPE:
|
9666 | return $$typeofType;
|
9667 | default:
|
9668 | return $$typeof;
|
9669 | }
|
9670 | }
|
9671 | case REACT_PORTAL_TYPE:
|
9672 | return $$typeof;
|
9673 | }
|
9674 | }
|
9675 | return void 0;
|
9676 | }
|
9677 | var ContextConsumer = REACT_CONTEXT_TYPE;
|
9678 | var ContextProvider = REACT_PROVIDER_TYPE;
|
9679 | var Element2 = REACT_ELEMENT_TYPE2;
|
9680 | var ForwardRef = REACT_FORWARD_REF_TYPE;
|
9681 | var Fragment = REACT_FRAGMENT_TYPE;
|
9682 | var Lazy = REACT_LAZY_TYPE;
|
9683 | var Memo = REACT_MEMO_TYPE;
|
9684 | var Portal = REACT_PORTAL_TYPE;
|
9685 | var Profiler = REACT_PROFILER_TYPE;
|
9686 | var StrictMode = REACT_STRICT_MODE_TYPE;
|
9687 | var Suspense = REACT_SUSPENSE_TYPE;
|
9688 | var SuspenseList = REACT_SUSPENSE_LIST_TYPE;
|
9689 | var hasWarnedAboutDeprecatedIsAsyncMode = false;
|
9690 | var hasWarnedAboutDeprecatedIsConcurrentMode = false;
|
9691 | function isAsyncMode(object) {
|
9692 | {
|
9693 | if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
9694 | hasWarnedAboutDeprecatedIsAsyncMode = true;
|
9695 | console["warn"]("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.");
|
9696 | }
|
9697 | }
|
9698 | return false;
|
9699 | }
|
9700 | function isConcurrentMode(object) {
|
9701 | {
|
9702 | if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
|
9703 | hasWarnedAboutDeprecatedIsConcurrentMode = true;
|
9704 | console["warn"]("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.");
|
9705 | }
|
9706 | }
|
9707 | return false;
|
9708 | }
|
9709 | function isContextConsumer(object) {
|
9710 | return typeOf(object) === REACT_CONTEXT_TYPE;
|
9711 | }
|
9712 | function isContextProvider(object) {
|
9713 | return typeOf(object) === REACT_PROVIDER_TYPE;
|
9714 | }
|
9715 | function isElement2(object) {
|
9716 | return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE2;
|
9717 | }
|
9718 | function isForwardRef(object) {
|
9719 | return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
9720 | }
|
9721 | function isFragment(object) {
|
9722 | return typeOf(object) === REACT_FRAGMENT_TYPE;
|
9723 | }
|
9724 | function isLazy(object) {
|
9725 | return typeOf(object) === REACT_LAZY_TYPE;
|
9726 | }
|
9727 | function isMemo(object) {
|
9728 | return typeOf(object) === REACT_MEMO_TYPE;
|
9729 | }
|
9730 | function isPortal(object) {
|
9731 | return typeOf(object) === REACT_PORTAL_TYPE;
|
9732 | }
|
9733 | function isProfiler(object) {
|
9734 | return typeOf(object) === REACT_PROFILER_TYPE;
|
9735 | }
|
9736 | function isStrictMode(object) {
|
9737 | return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
9738 | }
|
9739 | function isSuspense(object) {
|
9740 | return typeOf(object) === REACT_SUSPENSE_TYPE;
|
9741 | }
|
9742 | function isSuspenseList(object) {
|
9743 | return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
|
9744 | }
|
9745 | reactIs_development.ContextConsumer = ContextConsumer;
|
9746 | reactIs_development.ContextProvider = ContextProvider;
|
9747 | reactIs_development.Element = Element2;
|
9748 | reactIs_development.ForwardRef = ForwardRef;
|
9749 | reactIs_development.Fragment = Fragment;
|
9750 | reactIs_development.Lazy = Lazy;
|
9751 | reactIs_development.Memo = Memo;
|
9752 | reactIs_development.Portal = Portal;
|
9753 | reactIs_development.Profiler = Profiler;
|
9754 | reactIs_development.StrictMode = StrictMode;
|
9755 | reactIs_development.Suspense = Suspense;
|
9756 | reactIs_development.SuspenseList = SuspenseList;
|
9757 | reactIs_development.isAsyncMode = isAsyncMode;
|
9758 | reactIs_development.isConcurrentMode = isConcurrentMode;
|
9759 | reactIs_development.isContextConsumer = isContextConsumer;
|
9760 | reactIs_development.isContextProvider = isContextProvider;
|
9761 | reactIs_development.isElement = isElement2;
|
9762 | reactIs_development.isForwardRef = isForwardRef;
|
9763 | reactIs_development.isFragment = isFragment;
|
9764 | reactIs_development.isLazy = isLazy;
|
9765 | reactIs_development.isMemo = isMemo;
|
9766 | reactIs_development.isPortal = isPortal;
|
9767 | reactIs_development.isProfiler = isProfiler;
|
9768 | reactIs_development.isStrictMode = isStrictMode;
|
9769 | reactIs_development.isSuspense = isSuspense;
|
9770 | reactIs_development.isSuspenseList = isSuspenseList;
|
9771 | reactIs_development.isValidElementType = isValidElementType;
|
9772 | reactIs_development.typeOf = typeOf;
|
9773 | })();
|
9774 | }
|
9775 | {
|
9776 | reactIs.exports = reactIs_development;
|
9777 | }
|
9778 | var reactIsExports = reactIs.exports;
|
9779 | function get(entity, path) {
|
9780 | var current = entity;
|
9781 | for (var i2 = 0; i2 < path.length; i2 += 1) {
|
9782 | if (current === null || current === void 0) {
|
9783 | return void 0;
|
9784 | }
|
9785 | current = current[path[i2]];
|
9786 | }
|
9787 | return current;
|
9788 | }
|
9789 | function _toPrimitive(input, hint) {
|
9790 | if (_typeof$1(input) !== "object" || input === null)
|
9791 | return input;
|
9792 | var prim = input[Symbol.toPrimitive];
|
9793 | if (prim !== void 0) {
|
9794 | var res = prim.call(input, hint || "default");
|
9795 | if (_typeof$1(res) !== "object")
|
9796 | return res;
|
9797 | throw new TypeError("@@toPrimitive must return a primitive value.");
|
9798 | }
|
9799 | return (hint === "string" ? String : Number)(input);
|
9800 | }
|
9801 | function _toPropertyKey(arg) {
|
9802 | var key = _toPrimitive(arg, "string");
|
9803 | return _typeof$1(key) === "symbol" ? key : String(key);
|
9804 | }
|
9805 | function _defineProperty(obj, key, value) {
|
9806 | key = _toPropertyKey(key);
|
9807 | if (key in obj) {
|
9808 | Object.defineProperty(obj, key, {
|
9809 | value,
|
9810 | enumerable: true,
|
9811 | configurable: true,
|
9812 | writable: true
|
9813 | });
|
9814 | } else {
|
9815 | obj[key] = value;
|
9816 | }
|
9817 | return obj;
|
9818 | }
|
9819 | function ownKeys(e2, r) {
|
9820 | var t = Object.keys(e2);
|
9821 | if (Object.getOwnPropertySymbols) {
|
9822 | var o = Object.getOwnPropertySymbols(e2);
|
9823 | r && (o = o.filter(function(r2) {
|
9824 | return Object.getOwnPropertyDescriptor(e2, r2).enumerable;
|
9825 | })), t.push.apply(t, o);
|
9826 | }
|
9827 | return t;
|
9828 | }
|
9829 | function _objectSpread2(e2) {
|
9830 | for (var r = 1; r < arguments.length; r++) {
|
9831 | var t = null != arguments[r] ? arguments[r] : {};
|
9832 | r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
9833 | _defineProperty(e2, r2, t[r2]);
|
9834 | }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
9835 | Object.defineProperty(e2, r2, Object.getOwnPropertyDescriptor(t, r2));
|
9836 | });
|
9837 | }
|
9838 | return e2;
|
9839 | }
|
9840 | function _arrayWithoutHoles(arr) {
|
9841 | if (Array.isArray(arr))
|
9842 | return _arrayLikeToArray(arr);
|
9843 | }
|
9844 | function _iterableToArray(iter) {
|
9845 | if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
9846 | return Array.from(iter);
|
9847 | }
|
9848 | function _nonIterableSpread() {
|
9849 | throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
9850 | }
|
9851 | function _toConsumableArray(arr) {
|
9852 | return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
9853 | }
|
9854 | function _toArray(arr) {
|
9855 | return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
|
9856 | }
|
9857 | function internalSet(entity, paths, value, removeIfUndefined) {
|
9858 | if (!paths.length) {
|
9859 | return value;
|
9860 | }
|
9861 | var _paths = _toArray(paths), path = _paths[0], restPath = _paths.slice(1);
|
9862 | var clone;
|
9863 | if (!entity && typeof path === "number") {
|
9864 | clone = [];
|
9865 | } else if (Array.isArray(entity)) {
|
9866 | clone = _toConsumableArray(entity);
|
9867 | } else {
|
9868 | clone = _objectSpread2({}, entity);
|
9869 | }
|
9870 | if (removeIfUndefined && value === void 0 && restPath.length === 1) {
|
9871 | delete clone[path][restPath[0]];
|
9872 | } else {
|
9873 | clone[path] = internalSet(clone[path], restPath, value, removeIfUndefined);
|
9874 | }
|
9875 | return clone;
|
9876 | }
|
9877 | function set(entity, paths, value) {
|
9878 | var removeIfUndefined = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false;
|
9879 | if (paths.length && removeIfUndefined && value === void 0 && !get(entity, paths.slice(0, -1))) {
|
9880 | return entity;
|
9881 | }
|
9882 | return internalSet(entity, paths, value, removeIfUndefined);
|
9883 | }
|
9884 | var warned$1 = {};
|
9885 | var preWarningFns$1 = [];
|
9886 | var preMessage$1 = function preMessage2(fn) {
|
9887 | preWarningFns$1.push(fn);
|
9888 | };
|
9889 | function warning$3(valid, message) {
|
9890 | if (!valid && console !== void 0) {
|
9891 | var finalMessage = preWarningFns$1.reduce(function(msg, preMessageFn) {
|
9892 | return preMessageFn(msg !== null && msg !== void 0 ? msg : "", "warning");
|
9893 | }, message);
|
9894 | if (finalMessage) {
|
9895 | console.error("Warning: ".concat(finalMessage));
|
9896 | }
|
9897 | }
|
9898 | }
|
9899 | function note$1(valid, message) {
|
9900 | if (!valid && console !== void 0) {
|
9901 | var finalMessage = preWarningFns$1.reduce(function(msg, preMessageFn) {
|
9902 | return preMessageFn(msg !== null && msg !== void 0 ? msg : "", "note");
|
9903 | }, message);
|
9904 | if (finalMessage) {
|
9905 | console.warn("Note: ".concat(finalMessage));
|
9906 | }
|
9907 | }
|
9908 | }
|
9909 | function resetWarned$1() {
|
9910 | warned$1 = {};
|
9911 | }
|
9912 | function call$1(method, valid, message) {
|
9913 | if (!valid && !warned$1[message]) {
|
9914 | method(false, message);
|
9915 | warned$1[message] = true;
|
9916 | }
|
9917 | }
|
9918 | function warningOnce$1(valid, message) {
|
9919 | call$1(warning$3, valid, message);
|
9920 | }
|
9921 | function noteOnce$1(valid, message) {
|
9922 | call$1(note$1, valid, message);
|
9923 | }
|
9924 | warningOnce$1.preMessage = preMessage$1;
|
9925 | warningOnce$1.resetWarned = resetWarned$1;
|
9926 | warningOnce$1.noteOnce = noteOnce$1;
|
9927 | function useSyncScroll(current, visible, bodyRef) {
|
9928 | const rafRef = React$1.useRef();
|
9929 | const clean = () => {
|
9930 | if (rafRef.current) {
|
9931 | cancelAnimationFrame(rafRef.current);
|
9932 | }
|
9933 | };
|
9934 | const scrollTo = useEvent((date) => {
|
9935 | clean();
|
9936 | rafRef.current = requestAnimationFrame(() => {
|
9937 | if (bodyRef.current) {
|
9938 | const yearMonth = date.format("YYYY-M");
|
9939 | const target = bodyRef.current.querySelector(`[data-year-month="${yearMonth}"]`);
|
9940 | if (target) {
|
9941 | target.scrollIntoView({
|
9942 | block: "start",
|
9943 | inline: "nearest"
|
9944 | });
|
9945 | }
|
9946 | }
|
9947 | });
|
9948 | });
|
9949 | React$1.useEffect(() => {
|
9950 | if (visible && current) {
|
9951 | scrollTo(current);
|
9952 | return clean;
|
9953 | }
|
9954 | }, [current, visible]);
|
9955 | return scrollTo;
|
9956 | }
|
9957 | dayjs.extend(isoWeek);
|
9958 | dayjs.extend(isSameOrBefore);
|
9959 | const classPrefix$1e = "adm-calendar-picker-view";
|
9960 | const Context$2 = React$1.createContext({
|
9961 | visible: false
|
9962 | });
|
9963 | const defaultProps$Y = {
|
9964 | weekStartsOn: "Sunday",
|
9965 | defaultValue: null,
|
9966 | allowClear: true,
|
9967 | usePopup: true,
|
9968 | selectionMode: "single"
|
9969 | };
|
9970 | const CalendarPickerView = React$1.forwardRef((p, ref) => {
|
9971 | var _a;
|
9972 | const bodyRef = React$1.useRef(null);
|
9973 | const today = dayjs();
|
9974 | const props = mergeProps(defaultProps$Y, p);
|
9975 | const {
|
9976 | locale
|
9977 | } = useConfig();
|
9978 | const markItems = [...locale.Calendar.markItems];
|
9979 | if (props.weekStartsOn === "Sunday") {
|
9980 | const item = markItems.pop();
|
9981 | if (item)
|
9982 | markItems.unshift(item);
|
9983 | }
|
9984 | const [dateRange, setDateRange] = usePropsValue({
|
9985 | value: props.value === void 0 ? void 0 : convertValueToRange(props.selectionMode, props.value),
|
9986 | defaultValue: convertValueToRange(props.selectionMode, props.defaultValue),
|
9987 | onChange: (v) => {
|
9988 | var _a2, _b;
|
9989 | if (props.selectionMode === "single") {
|
9990 | (_a2 = props.onChange) === null || _a2 === void 0 ? void 0 : _a2.call(props, v ? v[0] : null);
|
9991 | } else if (props.selectionMode === "range") {
|
9992 | (_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, v);
|
9993 | }
|
9994 | }
|
9995 | });
|
9996 | const [intermediate, setIntermediate] = React$1.useState(false);
|
9997 | const [current, setCurrent] = React$1.useState(() => dayjs(dateRange ? dateRange[0] : today).date(1));
|
9998 | const context = React$1.useContext(Context$2);
|
9999 | const scrollTo = useSyncScroll(current, context.visible, bodyRef);
|
10000 | const maxDay = React$1.useMemo(() => props.max ? dayjs(props.max) : current.add(6, "month"), [props.max, current]);
|
10001 | const minDay = React$1.useMemo(() => props.min ? dayjs(props.min) : current, [props.min, current]);
|
10002 | React$1.useImperativeHandle(ref, () => ({
|
10003 | jumpTo: (pageOrPageGenerator) => {
|
10004 | let page;
|
10005 | if (typeof pageOrPageGenerator === "function") {
|
10006 | page = pageOrPageGenerator({
|
10007 | year: current.year(),
|
10008 | month: current.month() + 1
|
10009 | });
|
10010 | } else {
|
10011 | page = pageOrPageGenerator;
|
10012 | }
|
10013 | const next = convertPageToDayjs(page);
|
10014 | setCurrent(next);
|
10015 | scrollTo(next);
|
10016 | },
|
10017 | jumpToToday: () => {
|
10018 | const next = dayjs().date(1);
|
10019 | setCurrent(next);
|
10020 | scrollTo(next);
|
10021 | },
|
10022 | getDateRange: () => dateRange
|
10023 | }));
|
10024 | const header = React$1.createElement("div", {
|
10025 | className: `${classPrefix$1e}-header`
|
10026 | }, React$1.createElement("div", {
|
10027 | className: `${classPrefix$1e}-title`
|
10028 | }, (_a = props.title) !== null && _a !== void 0 ? _a : locale.Calendar.title));
|
10029 | function renderBody() {
|
10030 | var _a2;
|
10031 | const cells = [];
|
10032 | let monthIterator = minDay;
|
10033 | while (monthIterator.isSameOrBefore(maxDay, "month")) {
|
10034 | const year = monthIterator.year();
|
10035 | const month = monthIterator.month() + 1;
|
10036 | const renderMap = {
|
10037 | year,
|
10038 | month
|
10039 | };
|
10040 | const yearMonth = `${year}-${month}`;
|
10041 | const presetEmptyCellCount = props.weekStartsOn === "Monday" ? monthIterator.date(1).isoWeekday() - 1 : monthIterator.date(1).isoWeekday();
|
10042 | const presetEmptyCells = presetEmptyCellCount == 7 ? null : Array(presetEmptyCellCount).fill(null).map((_, index2) => React$1.createElement("div", {
|
10043 | key: index2,
|
10044 | className: `${classPrefix$1e}-cell`
|
10045 | }));
|
10046 | cells.push(React$1.createElement("div", {
|
10047 | key: yearMonth,
|
10048 | "data-year-month": yearMonth
|
10049 | }, React$1.createElement("div", {
|
10050 | className: `${classPrefix$1e}-title`
|
10051 | }, (_a2 = locale.Calendar.yearAndMonth) === null || _a2 === void 0 ? void 0 : _a2.replace(/\${(.*?)}/g, (_, variable) => {
|
10052 | var _a3;
|
10053 | return (_a3 = renderMap[variable]) === null || _a3 === void 0 ? void 0 : _a3.toString();
|
10054 | })), React$1.createElement("div", {
|
10055 | className: `${classPrefix$1e}-cells`
|
10056 | }, presetEmptyCells, Array(monthIterator.daysInMonth()).fill(null).map((_, index2) => {
|
10057 | var _a3;
|
10058 | const d = monthIterator.date(index2 + 1);
|
10059 | let isSelect = false;
|
10060 | let isBegin = false;
|
10061 | let isEnd = false;
|
10062 | let isSelectRowBegin = false;
|
10063 | let isSelectRowEnd = false;
|
10064 | if (dateRange) {
|
10065 | const [begin, end] = dateRange;
|
10066 | isBegin = d.isSame(begin, "day");
|
10067 | isEnd = d.isSame(end, "day");
|
10068 | isSelect = isBegin || isEnd || d.isAfter(begin, "day") && d.isBefore(end, "day");
|
10069 | if (isSelect) {
|
10070 | isSelectRowBegin = (cells.length % 7 === 0 || d.isSame(d.startOf("month"), "day")) && !isBegin;
|
10071 | isSelectRowEnd = (cells.length % 7 === 6 || d.isSame(d.endOf("month"), "day")) && !isEnd;
|
10072 | }
|
10073 | }
|
10074 | const disabled = props.shouldDisableDate ? props.shouldDisableDate(d.toDate()) : maxDay && d.isAfter(maxDay, "day") || minDay && d.isBefore(minDay, "day");
|
10075 | const renderTop = () => {
|
10076 | var _a4;
|
10077 | const top = (_a4 = props.renderTop) === null || _a4 === void 0 ? void 0 : _a4.call(props, d.toDate());
|
10078 | if (top) {
|
10079 | return top;
|
10080 | }
|
10081 | if (props.selectionMode === "range") {
|
10082 | if (isBegin) {
|
10083 | return locale.Calendar.start;
|
10084 | }
|
10085 | if (isEnd) {
|
10086 | return locale.Calendar.end;
|
10087 | }
|
10088 | }
|
10089 | if (d.isSame(today, "day") && !isSelect) {
|
10090 | return locale.Calendar.today;
|
10091 | }
|
10092 | };
|
10093 | return React$1.createElement("div", {
|
10094 | key: d.valueOf(),
|
10095 | className: classNames(`${classPrefix$1e}-cell`, {
|
10096 | [`${classPrefix$1e}-cell-today`]: d.isSame(today, "day"),
|
10097 | [`${classPrefix$1e}-cell-selected`]: isSelect,
|
10098 | [`${classPrefix$1e}-cell-selected-begin`]: isBegin,
|
10099 | [`${classPrefix$1e}-cell-selected-end`]: isEnd,
|
10100 | [`${classPrefix$1e}-cell-selected-row-begin`]: isSelectRowBegin,
|
10101 | [`${classPrefix$1e}-cell-selected-row-end`]: isSelectRowEnd,
|
10102 | [`${classPrefix$1e}-cell-disabled`]: !!disabled
|
10103 | }),
|
10104 | onClick: () => {
|
10105 | if (!props.selectionMode)
|
10106 | return;
|
10107 | if (disabled)
|
10108 | return;
|
10109 | const date = d.toDate();
|
10110 | function shouldClear() {
|
10111 | if (!props.allowClear)
|
10112 | return false;
|
10113 | if (!dateRange)
|
10114 | return false;
|
10115 | const [begin, end] = dateRange;
|
10116 | return d.isSame(begin, "date") && d.isSame(end, "day");
|
10117 | }
|
10118 | if (props.selectionMode === "single") {
|
10119 | if (props.allowClear && shouldClear()) {
|
10120 | setDateRange(null);
|
10121 | return;
|
10122 | }
|
10123 | setDateRange([date, date]);
|
10124 | } else if (props.selectionMode === "range") {
|
10125 | if (!dateRange) {
|
10126 | setDateRange([date, date]);
|
10127 | setIntermediate(true);
|
10128 | return;
|
10129 | }
|
10130 | if (shouldClear()) {
|
10131 | setDateRange(null);
|
10132 | setIntermediate(false);
|
10133 | return;
|
10134 | }
|
10135 | if (intermediate) {
|
10136 | const another = dateRange[0];
|
10137 | setDateRange(another > date ? [date, another] : [another, date]);
|
10138 | setIntermediate(false);
|
10139 | } else {
|
10140 | setDateRange([date, date]);
|
10141 | setIntermediate(true);
|
10142 | }
|
10143 | }
|
10144 | }
|
10145 | }, React$1.createElement("div", {
|
10146 | className: `${classPrefix$1e}-cell-top`
|
10147 | }, renderTop()), React$1.createElement("div", {
|
10148 | className: `${classPrefix$1e}-cell-date`
|
10149 | }, props.renderDate ? props.renderDate(d.toDate()) : d.date()), React$1.createElement("div", {
|
10150 | className: `${classPrefix$1e}-cell-bottom`
|
10151 | }, (_a3 = props.renderBottom) === null || _a3 === void 0 ? void 0 : _a3.call(props, d.toDate())));
|
10152 | }))));
|
10153 | monthIterator = monthIterator.add(1, "month");
|
10154 | }
|
10155 | return cells;
|
10156 | }
|
10157 | const body = React$1.createElement("div", {
|
10158 | className: `${classPrefix$1e}-body`,
|
10159 | ref: bodyRef
|
10160 | }, renderBody());
|
10161 | const mark = React$1.createElement("div", {
|
10162 | className: `${classPrefix$1e}-mark`
|
10163 | }, markItems.map((item, index2) => React$1.createElement("div", {
|
10164 | key: index2,
|
10165 | className: `${classPrefix$1e}-mark-cell`
|
10166 | }, item)));
|
10167 | return withNativeProps(props, React$1.createElement("div", {
|
10168 | className: classPrefix$1e
|
10169 | }, header, mark, body));
|
10170 | });
|
10171 | const classPrefix$1d = `adm-divider`;
|
10172 | const defaultProps$X = {
|
10173 | contentPosition: "center",
|
10174 | direction: "horizontal"
|
10175 | };
|
10176 | const Divider = (p) => {
|
10177 | const props = mergeProps(defaultProps$X, p);
|
10178 | return withNativeProps(props, React$1.createElement("div", {
|
10179 | className: classNames(classPrefix$1d, `${classPrefix$1d}-${props.direction}`, `${classPrefix$1d}-${props.contentPosition}`)
|
10180 | }, props.children && React$1.createElement("div", {
|
10181 | className: `${classPrefix$1d}-content`
|
10182 | }, props.children)));
|
10183 | };
|
10184 | const classPrefix$1c = "adm-calendar-picker";
|
10185 | const defaultProps$W = {
|
10186 | weekStartsOn: "Sunday",
|
10187 | defaultValue: null,
|
10188 | allowClear: true,
|
10189 | usePopup: true,
|
10190 | selectionMode: "single"
|
10191 | };
|
10192 | const CalendarPicker = React$1.forwardRef((p, ref) => {
|
10193 | const props = mergeProps(defaultProps$W, p);
|
10194 | const {
|
10195 | locale
|
10196 | } = useConfig();
|
10197 | const calendarRef = ref !== null && ref !== void 0 ? ref : React$1.useRef(null);
|
10198 | const {
|
10199 | visible,
|
10200 | confirmText,
|
10201 | popupClassName,
|
10202 | popupStyle,
|
10203 | popupBodyStyle,
|
10204 | forceRender,
|
10205 | closeOnMaskClick,
|
10206 | onClose,
|
10207 | onConfirm,
|
10208 | onMaskClick,
|
10209 | getContainer
|
10210 | } = props, calendarViewProps = __rest(props, ["visible", "confirmText", "popupClassName", "popupStyle", "popupBodyStyle", "forceRender", "closeOnMaskClick", "onClose", "onConfirm", "onMaskClick", "getContainer"]);
|
10211 | const viewContext = React$1.useMemo(() => ({
|
10212 | visible: !!visible
|
10213 | }), [visible]);
|
10214 | const footer = React$1.createElement("div", {
|
10215 | className: `${classPrefix$1c}-footer`
|
10216 | }, React$1.createElement(Divider, null), React$1.createElement("div", {
|
10217 | className: `${classPrefix$1c}-footer-bottom`
|
10218 | }, React$1.createElement(Button, {
|
10219 | color: "primary",
|
10220 | onClick: () => {
|
10221 | var _a, _b, _c, _d;
|
10222 | const dateRange = (_b = (_a = calendarRef.current) === null || _a === void 0 ? void 0 : _a.getDateRange()) !== null && _b !== void 0 ? _b : null;
|
10223 | if (props.selectionMode === "single") {
|
10224 | (_c = props.onConfirm) === null || _c === void 0 ? void 0 : _c.call(props, dateRange ? dateRange[0] : null);
|
10225 | } else if (props.selectionMode === "range") {
|
10226 | (_d = props.onConfirm) === null || _d === void 0 ? void 0 : _d.call(props, dateRange);
|
10227 | }
|
10228 | onClose === null || onClose === void 0 ? void 0 : onClose();
|
10229 | }
|
10230 | }, confirmText !== null && confirmText !== void 0 ? confirmText : locale.Calendar.confirm)));
|
10231 | return withNativeProps(props, React$1.createElement("div", {
|
10232 | className: classPrefix$1c
|
10233 | }, React$1.createElement(Popup, {
|
10234 | visible,
|
10235 | className: classNames(`${classPrefix$1c}-popup`, popupClassName),
|
10236 | showCloseButton: true,
|
10237 | forceRender: ref ? true : forceRender,
|
10238 | style: popupStyle,
|
10239 | bodyStyle: Object.assign({
|
10240 | borderTopLeftRadius: "8px",
|
10241 | borderTopRightRadius: "8px",
|
10242 | minHeight: "80vh",
|
10243 | overflow: "auto"
|
10244 | }, popupBodyStyle),
|
10245 | onClose,
|
10246 | onMaskClick: () => {
|
10247 | onMaskClick === null || onMaskClick === void 0 ? void 0 : onMaskClick();
|
10248 | if (closeOnMaskClick) {
|
10249 | onClose === null || onClose === void 0 ? void 0 : onClose();
|
10250 | }
|
10251 | },
|
10252 | getContainer
|
10253 | }, React$1.createElement(Context$2.Provider, {
|
10254 | value: viewContext
|
10255 | }, React$1.createElement(CalendarPickerView, Object.assign({
|
10256 | ref: calendarRef
|
10257 | }, calendarViewProps))), footer)));
|
10258 | });
|
10259 | function useResizeEffect(effect, targetRef) {
|
10260 | const fn = useMemoizedFn(effect);
|
10261 | useIsomorphicLayoutEffect$2(() => {
|
10262 | const target = targetRef.current;
|
10263 | if (!target)
|
10264 | return;
|
10265 | if (window.ResizeObserver) {
|
10266 | let animationFrame;
|
10267 | const observer = new ResizeObserver(() => {
|
10268 | animationFrame = window.requestAnimationFrame(() => fn(target));
|
10269 | });
|
10270 | observer.observe(target);
|
10271 | return () => {
|
10272 | window.cancelAnimationFrame(animationFrame);
|
10273 | observer.disconnect();
|
10274 | };
|
10275 | } else {
|
10276 | fn(target);
|
10277 | }
|
10278 | }, [targetRef]);
|
10279 | }
|
10280 | function observe(element, options, callback) {
|
10281 | if (element && typeof MutationObserver !== "undefined") {
|
10282 | let observer = new MutationObserver(() => {
|
10283 | callback();
|
10284 | });
|
10285 | observer.observe(element, options);
|
10286 | return () => {
|
10287 | if (observer) {
|
10288 | observer.disconnect();
|
10289 | observer = null;
|
10290 | }
|
10291 | };
|
10292 | }
|
10293 | return () => {
|
10294 | };
|
10295 | }
|
10296 | function useMutationEffect(effect, targetRef, options) {
|
10297 | const fn = useMemoizedFn(effect);
|
10298 | React$1.useEffect(() => {
|
10299 | const cleanup = observe(targetRef.current, options, fn);
|
10300 | return cleanup;
|
10301 | }, [targetRef]);
|
10302 | }
|
10303 | function bound(position, min2, max2) {
|
10304 | let ret = position;
|
10305 | if (min2 !== void 0) {
|
10306 | ret = Math.max(position, min2);
|
10307 | }
|
10308 | if (max2 !== void 0) {
|
10309 | ret = Math.min(ret, max2);
|
10310 | }
|
10311 | return ret;
|
10312 | }
|
10313 | const useTabListScroll = (targetRef, activeIndex) => {
|
10314 | const [{
|
10315 | scrollLeft
|
10316 | }, api] = useSpring(() => ({
|
10317 | scrollLeft: 0,
|
10318 | config: {
|
10319 | tension: 300,
|
10320 | clamp: true
|
10321 | }
|
10322 | }));
|
10323 | function animate(immediate = false) {
|
10324 | const container = targetRef.current;
|
10325 | if (!container)
|
10326 | return;
|
10327 | if (activeIndex === void 0)
|
10328 | return;
|
10329 | const activeTabWrapper = container.children.item(activeIndex);
|
10330 | const activeTab = activeTabWrapper.children.item(0);
|
10331 | const activeTabLeft = activeTab.offsetLeft;
|
10332 | const activeTabWidth = activeTab.offsetWidth;
|
10333 | const containerWidth = container.offsetWidth;
|
10334 | const containerScrollWidth = container.scrollWidth;
|
10335 | const containerScrollLeft = container.scrollLeft;
|
10336 | const maxScrollDistance = containerScrollWidth - containerWidth;
|
10337 | if (maxScrollDistance <= 0)
|
10338 | return;
|
10339 | const nextScrollLeft = bound(activeTabLeft - (containerWidth - activeTabWidth) / 2, 0, containerScrollWidth - containerWidth);
|
10340 | api.start({
|
10341 | scrollLeft: nextScrollLeft,
|
10342 | from: {
|
10343 | scrollLeft: containerScrollLeft
|
10344 | },
|
10345 | immediate: immediate && !scrollLeft.isAnimating
|
10346 | });
|
10347 | }
|
10348 | useIsomorphicLayoutEffect$2(() => {
|
10349 | animate(true);
|
10350 | }, []);
|
10351 | useIsomorphicUpdateLayoutEffect(() => {
|
10352 | animate();
|
10353 | }, [activeIndex]);
|
10354 | useMutationEffect(() => {
|
10355 | animate(true);
|
10356 | }, targetRef, {
|
10357 | subtree: true,
|
10358 | childList: true,
|
10359 | characterData: true
|
10360 | });
|
10361 | return {
|
10362 | scrollLeft,
|
10363 | animate
|
10364 | };
|
10365 | };
|
10366 | const classPrefix$1b = `adm-scroll-mask`;
|
10367 | const ScrollMask = (props) => {
|
10368 | const maskRef = React$1.useRef(null);
|
10369 | const [{
|
10370 | leftMaskOpacity,
|
10371 | rightMaskOpacity
|
10372 | }, api] = useSpring(() => ({
|
10373 | leftMaskOpacity: 0,
|
10374 | rightMaskOpacity: 0,
|
10375 | config: {
|
10376 | clamp: true
|
10377 | }
|
10378 | }));
|
10379 | const {
|
10380 | run: updateMask
|
10381 | } = useThrottleFn((immediate = false) => {
|
10382 | const mask = maskRef.current;
|
10383 | if (!mask)
|
10384 | return;
|
10385 | const scrollEl = props.scrollTrackRef.current;
|
10386 | if (!scrollEl)
|
10387 | return;
|
10388 | const scrollLeft = scrollEl.scrollLeft;
|
10389 | const showLeftMask = scrollLeft > 0;
|
10390 | const showRightMask = scrollLeft + scrollEl.offsetWidth < scrollEl.scrollWidth;
|
10391 | api.start({
|
10392 | leftMaskOpacity: showLeftMask ? 1 : 0,
|
10393 | rightMaskOpacity: showRightMask ? 1 : 0,
|
10394 | immediate
|
10395 | });
|
10396 | }, {
|
10397 | wait: 100,
|
10398 | trailing: true,
|
10399 | leading: true
|
10400 | });
|
10401 | React$1.useEffect(() => {
|
10402 | updateMask(true);
|
10403 | }, []);
|
10404 | React$1.useEffect(() => {
|
10405 | const scrollEl = props.scrollTrackRef.current;
|
10406 | if (!scrollEl)
|
10407 | return;
|
10408 | scrollEl.addEventListener("scroll", updateMask);
|
10409 | return () => scrollEl.removeEventListener("scroll", updateMask);
|
10410 | }, []);
|
10411 | return React$1.createElement(React$1.Fragment, null, React$1.createElement(animated.div, {
|
10412 | ref: maskRef,
|
10413 | className: classNames(classPrefix$1b, `${classPrefix$1b}-left`),
|
10414 | style: {
|
10415 | opacity: leftMaskOpacity
|
10416 | }
|
10417 | }), React$1.createElement(animated.div, {
|
10418 | className: classNames(classPrefix$1b, `${classPrefix$1b}-right`),
|
10419 | style: {
|
10420 | opacity: rightMaskOpacity
|
10421 | }
|
10422 | }));
|
10423 | };
|
10424 | function traverseReactNode(children, fn) {
|
10425 | let i2 = 0;
|
10426 | function handle(target) {
|
10427 | React$1.Children.forEach(target, (child) => {
|
10428 | if (!reactIsExports.isFragment(child)) {
|
10429 | fn(child, i2);
|
10430 | i2 += 1;
|
10431 | } else {
|
10432 | handle(child.props.children);
|
10433 | }
|
10434 | });
|
10435 | }
|
10436 | handle(children);
|
10437 | }
|
10438 | const classPrefix$1a = `adm-capsule-tabs`;
|
10439 | const CapsuleTab = () => null;
|
10440 | const CapsuleTabs = (props) => {
|
10441 | var _a;
|
10442 | const tabListContainerRef = React$1.useRef(null);
|
10443 | const rootRef = React$1.useRef(null);
|
10444 | const keyToIndexRecord = {};
|
10445 | let firstActiveKey = null;
|
10446 | const panes = [];
|
10447 | traverseReactNode(props.children, (child, index2) => {
|
10448 | if (!React$1.isValidElement(child))
|
10449 | return;
|
10450 | const key = child.key;
|
10451 | if (typeof key !== "string")
|
10452 | return;
|
10453 | if (index2 === 0) {
|
10454 | firstActiveKey = key;
|
10455 | }
|
10456 | const length = panes.push(child);
|
10457 | keyToIndexRecord[key] = length - 1;
|
10458 | });
|
10459 | const [activeKey, setActiveKey] = usePropsValue({
|
10460 | value: props.activeKey,
|
10461 | defaultValue: (_a = props.defaultActiveKey) !== null && _a !== void 0 ? _a : firstActiveKey,
|
10462 | onChange: (v) => {
|
10463 | var _a2;
|
10464 | if (v === null)
|
10465 | return;
|
10466 | (_a2 = props.onChange) === null || _a2 === void 0 ? void 0 : _a2.call(props, v);
|
10467 | }
|
10468 | });
|
10469 | const {
|
10470 | scrollLeft,
|
10471 | animate
|
10472 | } = useTabListScroll(tabListContainerRef, keyToIndexRecord[activeKey]);
|
10473 | useResizeEffect(() => {
|
10474 | animate(true);
|
10475 | }, rootRef);
|
10476 | return withNativeProps(props, React$1.createElement("div", {
|
10477 | className: classPrefix$1a,
|
10478 | ref: rootRef
|
10479 | }, React$1.createElement("div", {
|
10480 | className: `${classPrefix$1a}-header`
|
10481 | }, React$1.createElement(ScrollMask, {
|
10482 | scrollTrackRef: tabListContainerRef
|
10483 | }), React$1.createElement(animated.div, {
|
10484 | className: `${classPrefix$1a}-tab-list`,
|
10485 | ref: tabListContainerRef,
|
10486 | scrollLeft
|
10487 | }, panes.map((pane) => withNativeProps(pane.props, React$1.createElement("div", {
|
10488 | key: pane.key,
|
10489 | className: `${classPrefix$1a}-tab-wrapper`
|
10490 | }, React$1.createElement("div", {
|
10491 | onClick: () => {
|
10492 | const {
|
10493 | key
|
10494 | } = pane;
|
10495 | if (pane.props.disabled)
|
10496 | return;
|
10497 | if (key === void 0 || key === null) {
|
10498 | return;
|
10499 | }
|
10500 | setActiveKey(key.toString());
|
10501 | },
|
10502 | className: classNames(`${classPrefix$1a}-tab`, {
|
10503 | [`${classPrefix$1a}-tab-active`]: pane.key === activeKey,
|
10504 | [`${classPrefix$1a}-tab-disabled`]: pane.props.disabled
|
10505 | })
|
10506 | }, pane.props.title)))))), panes.map((pane) => {
|
10507 | if (pane.props.children === void 0) {
|
10508 | return null;
|
10509 | }
|
10510 | const active = pane.key === activeKey;
|
10511 | return React$1.createElement(ShouldRender, {
|
10512 | key: pane.key,
|
10513 | active,
|
10514 | forceRender: pane.props.forceRender,
|
10515 | destroyOnClose: pane.props.destroyOnClose
|
10516 | }, React$1.createElement("div", {
|
10517 | className: `${classPrefix$1a}-content`,
|
10518 | style: {
|
10519 | display: active ? "block" : "none"
|
10520 | }
|
10521 | }, pane.props.children));
|
10522 | })));
|
10523 | };
|
10524 | const index$h = attachPropertiesToComponent(CapsuleTabs, {
|
10525 | Tab: CapsuleTab
|
10526 | });
|
10527 | const classPrefix$19 = `adm-card`;
|
10528 | const Card = (props) => {
|
10529 | const renderHeader = () => {
|
10530 | if (!(props.title || props.extra)) {
|
10531 | return null;
|
10532 | }
|
10533 | return React$1.createElement("div", {
|
10534 | className: classNames(`${classPrefix$19}-header`, props.headerClassName),
|
10535 | style: props.headerStyle,
|
10536 | onClick: props.onHeaderClick
|
10537 | }, React$1.createElement("div", {
|
10538 | className: `${classPrefix$19}-header-title`
|
10539 | }, props.title), props.extra);
|
10540 | };
|
10541 | const renderBody = () => {
|
10542 | if (!props.children) {
|
10543 | return null;
|
10544 | }
|
10545 | return React$1.createElement("div", {
|
10546 | className: classNames(`${classPrefix$19}-body`, props.bodyClassName),
|
10547 | style: props.bodyStyle,
|
10548 | onClick: props.onBodyClick
|
10549 | }, props.children);
|
10550 | };
|
10551 | return withNativeProps(props, React$1.createElement("div", {
|
10552 | className: classPrefix$19,
|
10553 | onClick: props.onClick
|
10554 | }, renderHeader(), renderBody()));
|
10555 | };
|
10556 | function rubberband(distance, dimension, constant) {
|
10557 | return distance * dimension * constant / (dimension + constant * distance);
|
10558 | }
|
10559 | function rubberbandIfOutOfBounds(position, min2, max2, dimension, constant = 0.15) {
|
10560 | if (constant === 0)
|
10561 | return bound(position, min2, max2);
|
10562 | if (position < min2)
|
10563 | return -rubberband(min2 - position, dimension, constant) + min2;
|
10564 | if (position > max2)
|
10565 | return +rubberband(position - max2, dimension, constant) + max2;
|
10566 | return position;
|
10567 | }
|
10568 | var hasElementType = typeof Element !== "undefined";
|
10569 | var hasMap = typeof Map === "function";
|
10570 | var hasSet = typeof Set === "function";
|
10571 | var hasArrayBuffer = typeof ArrayBuffer === "function" && !!ArrayBuffer.isView;
|
10572 | function equal(a, b) {
|
10573 | if (a === b)
|
10574 | return true;
|
10575 | if (a && b && typeof a == "object" && typeof b == "object") {
|
10576 | if (a.constructor !== b.constructor)
|
10577 | return false;
|
10578 | var length, i2, keys;
|
10579 | if (Array.isArray(a)) {
|
10580 | length = a.length;
|
10581 | if (length != b.length)
|
10582 | return false;
|
10583 | for (i2 = length; i2-- !== 0; )
|
10584 | if (!equal(a[i2], b[i2]))
|
10585 | return false;
|
10586 | return true;
|
10587 | }
|
10588 | var it;
|
10589 | if (hasMap && a instanceof Map && b instanceof Map) {
|
10590 | if (a.size !== b.size)
|
10591 | return false;
|
10592 | it = a.entries();
|
10593 | while (!(i2 = it.next()).done)
|
10594 | if (!b.has(i2.value[0]))
|
10595 | return false;
|
10596 | it = a.entries();
|
10597 | while (!(i2 = it.next()).done)
|
10598 | if (!equal(i2.value[1], b.get(i2.value[0])))
|
10599 | return false;
|
10600 | return true;
|
10601 | }
|
10602 | if (hasSet && a instanceof Set && b instanceof Set) {
|
10603 | if (a.size !== b.size)
|
10604 | return false;
|
10605 | it = a.entries();
|
10606 | while (!(i2 = it.next()).done)
|
10607 | if (!b.has(i2.value[0]))
|
10608 | return false;
|
10609 | return true;
|
10610 | }
|
10611 | if (hasArrayBuffer && ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
|
10612 | length = a.length;
|
10613 | if (length != b.length)
|
10614 | return false;
|
10615 | for (i2 = length; i2-- !== 0; )
|
10616 | if (a[i2] !== b[i2])
|
10617 | return false;
|
10618 | return true;
|
10619 | }
|
10620 | if (a.constructor === RegExp)
|
10621 | return a.source === b.source && a.flags === b.flags;
|
10622 | if (a.valueOf !== Object.prototype.valueOf && typeof a.valueOf === "function" && typeof b.valueOf === "function")
|
10623 | return a.valueOf() === b.valueOf();
|
10624 | if (a.toString !== Object.prototype.toString && typeof a.toString === "function" && typeof b.toString === "function")
|
10625 | return a.toString() === b.toString();
|
10626 | keys = Object.keys(a);
|
10627 | length = keys.length;
|
10628 | if (length !== Object.keys(b).length)
|
10629 | return false;
|
10630 | for (i2 = length; i2-- !== 0; )
|
10631 | if (!Object.prototype.hasOwnProperty.call(b, keys[i2]))
|
10632 | return false;
|
10633 | if (hasElementType && a instanceof Element)
|
10634 | return false;
|
10635 | for (i2 = length; i2-- !== 0; ) {
|
10636 | if ((keys[i2] === "_owner" || keys[i2] === "__v" || keys[i2] === "__o") && a.$$typeof) {
|
10637 | continue;
|
10638 | }
|
10639 | if (!equal(a[keys[i2]], b[keys[i2]]))
|
10640 | return false;
|
10641 | }
|
10642 | return true;
|
10643 | }
|
10644 | return a !== a && b !== b;
|
10645 | }
|
10646 | var reactFastCompare = function isEqual2(a, b) {
|
10647 | try {
|
10648 | return equal(a, b);
|
10649 | } catch (error) {
|
10650 | if ((error.message || "").match(/stack|recursion/i)) {
|
10651 | console.warn("react-fast-compare cannot handle circular refs");
|
10652 | return false;
|
10653 | }
|
10654 | throw error;
|
10655 | }
|
10656 | };
|
10657 | const isEqual = getDefaultExportFromCjs(reactFastCompare);
|
10658 | function measureCSSLength(raw) {
|
10659 | if (raw === null || raw === void 0 || raw === "") {
|
10660 | {
|
10661 | devError("Global", "Something went wrong when calculating CSS length. Please report an issue at https://github.com/ant-design/ant-design-mobile/issues/new/choose");
|
10662 | }
|
10663 | return 0;
|
10664 | }
|
10665 | const withUnit = raw.trim();
|
10666 | if (withUnit.endsWith("px")) {
|
10667 | return parseFloat(withUnit);
|
10668 | } else if (withUnit.endsWith("rem")) {
|
10669 | return parseFloat(withUnit) * parseFloat(window.getComputedStyle(document.documentElement).fontSize);
|
10670 | } else if (withUnit.endsWith("vw")) {
|
10671 | return parseFloat(withUnit) * window.innerWidth / 100;
|
10672 | } else {
|
10673 | {
|
10674 | devError("Global", `You are using a not supported CSS unit in \`${raw}\`. Only \`px\` \`rem\` and \`vw\` are supported.`);
|
10675 | }
|
10676 | return 0;
|
10677 | }
|
10678 | }
|
10679 | const classPrefix$18 = `adm-picker-view`;
|
10680 | const Wheel = React$1.memo((props) => {
|
10681 | const {
|
10682 | value,
|
10683 | column,
|
10684 | renderLabel
|
10685 | } = props;
|
10686 | function onSelect(val) {
|
10687 | props.onSelect(val, props.index);
|
10688 | }
|
10689 | const [{
|
10690 | y
|
10691 | }, api] = useSpring(() => ({
|
10692 | from: {
|
10693 | y: 0
|
10694 | },
|
10695 | config: {
|
10696 | tension: 400,
|
10697 | mass: 0.8
|
10698 | }
|
10699 | }));
|
10700 | const draggingRef = React$1.useRef(false);
|
10701 | const rootRef = React$1.useRef(null);
|
10702 | const itemHeightMeasureRef = React$1.useRef(null);
|
10703 | const itemHeight = React$1.useRef(34);
|
10704 | useIsomorphicLayoutEffect$2(() => {
|
10705 | const itemHeightMeasure = itemHeightMeasureRef.current;
|
10706 | if (!itemHeightMeasure)
|
10707 | return;
|
10708 | itemHeight.current = measureCSSLength(window.getComputedStyle(itemHeightMeasure).getPropertyValue("height"));
|
10709 | });
|
10710 | useIsomorphicLayoutEffect$2(() => {
|
10711 | if (draggingRef.current)
|
10712 | return;
|
10713 | if (value === null)
|
10714 | return;
|
10715 | const targetIndex = column.findIndex((item) => item.value === value);
|
10716 | if (targetIndex < 0)
|
10717 | return;
|
10718 | const finalPosition = targetIndex * -itemHeight.current;
|
10719 | api.start({
|
10720 | y: finalPosition,
|
10721 | immediate: y.goal !== finalPosition
|
10722 | });
|
10723 | }, [value, column]);
|
10724 | useIsomorphicLayoutEffect$2(() => {
|
10725 | if (column.length === 0) {
|
10726 | if (value !== null) {
|
10727 | onSelect(null);
|
10728 | }
|
10729 | } else {
|
10730 | if (!column.some((item) => item.value === value)) {
|
10731 | const firstItem = column[0];
|
10732 | onSelect(firstItem.value);
|
10733 | }
|
10734 | }
|
10735 | }, [column, value]);
|
10736 | function scrollSelect(index2) {
|
10737 | const finalPosition = index2 * -itemHeight.current;
|
10738 | api.start({
|
10739 | y: finalPosition
|
10740 | });
|
10741 | const item = column[index2];
|
10742 | if (!item)
|
10743 | return;
|
10744 | onSelect(item.value);
|
10745 | }
|
10746 | const handleGestureState = (state) => {
|
10747 | const {
|
10748 | direction: [, direction],
|
10749 | distance: [, distance],
|
10750 | velocity: [, velocity],
|
10751 | offset: [, offset2],
|
10752 | last
|
10753 | } = state;
|
10754 | return {
|
10755 | direction,
|
10756 | distance,
|
10757 | velocity,
|
10758 | offset: offset2,
|
10759 | last
|
10760 | };
|
10761 | };
|
10762 | const handleDrag = (state) => {
|
10763 | draggingRef.current = true;
|
10764 | const min2 = -((column.length - 1) * itemHeight.current);
|
10765 | const max2 = 0;
|
10766 | const {
|
10767 | direction,
|
10768 | last,
|
10769 | velocity,
|
10770 | offset: offset2
|
10771 | } = handleGestureState(state);
|
10772 | if (last) {
|
10773 | draggingRef.current = false;
|
10774 | const position = offset2 + velocity * direction * 50;
|
10775 | const boundNum = bound(position, min2, max2);
|
10776 | const targetIndex = -Math.round(boundNum / itemHeight.current);
|
10777 | scrollSelect(targetIndex);
|
10778 | } else {
|
10779 | const position = offset2;
|
10780 | api.start({
|
10781 | y: rubberbandIfOutOfBounds(position, min2, max2, itemHeight.current * 50, 0.2)
|
10782 | });
|
10783 | }
|
10784 | };
|
10785 | const handleWheel = (state) => {
|
10786 | draggingRef.current = true;
|
10787 | const min2 = -((column.length - 1) * itemHeight.current);
|
10788 | const max2 = 0;
|
10789 | const {
|
10790 | direction,
|
10791 | last,
|
10792 | velocity,
|
10793 | distance
|
10794 | } = handleGestureState(state);
|
10795 | const whellDir = -direction;
|
10796 | const scrollY = y.get();
|
10797 | if (last) {
|
10798 | draggingRef.current = false;
|
10799 | const speed = velocity * whellDir * 50;
|
10800 | const position = scrollY + distance * whellDir + speed;
|
10801 | const boundNum = bound(position, min2, max2);
|
10802 | const targetIndex = -Math.round(boundNum / itemHeight.current);
|
10803 | scrollSelect(targetIndex);
|
10804 | } else {
|
10805 | const position = scrollY + distance * whellDir;
|
10806 | api.start({
|
10807 | y: rubberbandIfOutOfBounds(position, min2, max2, itemHeight.current * 50, 0.2)
|
10808 | });
|
10809 | }
|
10810 | };
|
10811 | useDrag((state) => {
|
10812 | state.event.stopPropagation();
|
10813 | handleDrag(state);
|
10814 | }, {
|
10815 | axis: "y",
|
10816 | from: () => [0, y.get()],
|
10817 | filterTaps: true,
|
10818 | pointer: {
|
10819 | touch: true
|
10820 | },
|
10821 | target: rootRef
|
10822 | });
|
10823 | useWheel((state) => {
|
10824 | state.event.stopPropagation();
|
10825 | handleWheel(state);
|
10826 | }, {
|
10827 | target: props.mouseWheel ? rootRef : void 0,
|
10828 | axis: "y",
|
10829 | from: () => [0, y.get()],
|
10830 | preventDefault: true,
|
10831 | eventOptions: supportsPassive ? {
|
10832 | passive: false
|
10833 | } : void 0
|
10834 | });
|
10835 | let selectedIndex = null;
|
10836 | function renderAccessible() {
|
10837 | if (selectedIndex === null) {
|
10838 | return null;
|
10839 | }
|
10840 | const current = column[selectedIndex];
|
10841 | const previousIndex = selectedIndex - 1;
|
10842 | const nextIndex = selectedIndex + 1;
|
10843 | const previous = column[previousIndex];
|
10844 | const next = column[nextIndex];
|
10845 | return React$1.createElement("div", {
|
10846 | className: `${classPrefix$18}-column-accessible`
|
10847 | }, React$1.createElement("div", {
|
10848 | className: `${classPrefix$18}-column-accessible-current`,
|
10849 | role: "button",
|
10850 | "aria-label": current ? `当前选择的是:${current.label}` : "当前未选择"
|
10851 | }, "-"), React$1.createElement("div", {
|
10852 | className: `${classPrefix$18}-column-accessible-button`,
|
10853 | onClick: () => {
|
10854 | if (!previous)
|
10855 | return;
|
10856 | scrollSelect(previousIndex);
|
10857 | },
|
10858 | role: previous ? "button" : "text",
|
10859 | "aria-label": !previous ? "没有上一项" : `选择上一项:${previous.label}`
|
10860 | }, "-"), React$1.createElement("div", {
|
10861 | className: `${classPrefix$18}-column-accessible-button`,
|
10862 | onClick: () => {
|
10863 | if (!next)
|
10864 | return;
|
10865 | scrollSelect(nextIndex);
|
10866 | },
|
10867 | role: next ? "button" : "text",
|
10868 | "aria-label": !next ? "没有下一项" : `选择下一项:${next.label}`
|
10869 | }, "-"));
|
10870 | }
|
10871 | return React$1.createElement("div", {
|
10872 | className: `${classPrefix$18}-column`
|
10873 | }, React$1.createElement("div", {
|
10874 | className: `${classPrefix$18}-item-height-measure`,
|
10875 | ref: itemHeightMeasureRef
|
10876 | }), React$1.createElement(animated.div, {
|
10877 | ref: rootRef,
|
10878 | style: {
|
10879 | translateY: y
|
10880 | },
|
10881 | className: `${classPrefix$18}-column-wheel`,
|
10882 | "aria-hidden": true
|
10883 | }, column.map((item, index2) => {
|
10884 | var _a;
|
10885 | const selected = props.value === item.value;
|
10886 | if (selected)
|
10887 | selectedIndex = index2;
|
10888 | function handleClick() {
|
10889 | draggingRef.current = false;
|
10890 | scrollSelect(index2);
|
10891 | }
|
10892 | return React$1.createElement("div", {
|
10893 | key: (_a = item.key) !== null && _a !== void 0 ? _a : item.value,
|
10894 | "data-selected": selected,
|
10895 | className: classNames(`${classPrefix$18}-column-item`, {
|
10896 | [`${classPrefix$18}-column-item-active`]: selected
|
10897 | }),
|
10898 | onClick: handleClick,
|
10899 | "aria-hidden": !selected,
|
10900 | "aria-label": selected ? "active" : ""
|
10901 | }, React$1.createElement("div", {
|
10902 | className: `${classPrefix$18}-column-item-label`
|
10903 | }, renderLabel(item)));
|
10904 | })), renderAccessible());
|
10905 | }, (prev, next) => {
|
10906 | if (prev.index !== next.index)
|
10907 | return false;
|
10908 | if (prev.value !== next.value)
|
10909 | return false;
|
10910 | if (prev.onSelect !== next.onSelect)
|
10911 | return false;
|
10912 | if (prev.renderLabel !== next.renderLabel)
|
10913 | return false;
|
10914 | if (prev.mouseWheel !== next.mouseWheel)
|
10915 | return false;
|
10916 | if (!isEqual(prev.column, next.column))
|
10917 | return false;
|
10918 | return true;
|
10919 | });
|
10920 | Wheel.displayName = "Wheel";
|
10921 | function withCache(generate) {
|
10922 | let cache = null;
|
10923 | return () => {
|
10924 | if (cache === null) {
|
10925 | cache = generate();
|
10926 | }
|
10927 | return cache;
|
10928 | };
|
10929 | }
|
10930 | function generateColumnsExtend(rawColumns, val) {
|
10931 | const columns = withCache(() => {
|
10932 | const c = typeof rawColumns === "function" ? rawColumns(val) : rawColumns;
|
10933 | return c.map((column) => column.map((item) => typeof item === "string" ? {
|
10934 | label: item,
|
10935 | value: item
|
10936 | } : item));
|
10937 | });
|
10938 | const items = withCache(() => {
|
10939 | return val.map((v, index2) => {
|
10940 | var _a;
|
10941 | const column = columns()[index2];
|
10942 | if (!column)
|
10943 | return null;
|
10944 | return (_a = column.find((item) => item.value === v)) !== null && _a !== void 0 ? _a : null;
|
10945 | });
|
10946 | });
|
10947 | const extend = {
|
10948 | get columns() {
|
10949 | return columns();
|
10950 | },
|
10951 | get items() {
|
10952 | return items();
|
10953 | }
|
10954 | };
|
10955 | return extend;
|
10956 | }
|
10957 | function useColumnsExtend(rawColumns, value) {
|
10958 | return React$1.useMemo(() => generateColumnsExtend(rawColumns, value), [rawColumns, value]);
|
10959 | }
|
10960 | const defaultRenderLabel = (item) => item.label;
|
10961 | var shim = { exports: {} };
|
10962 | var useSyncExternalStoreShim_development = {};
|
10963 | |
10964 |
|
10965 |
|
10966 |
|
10967 |
|
10968 |
|
10969 |
|
10970 |
|
10971 |
|
10972 | {
|
10973 | (function() {
|
10974 | if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
|
10975 | __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
10976 | }
|
10977 | var React2 = React$1;
|
10978 | var ReactSharedInternals = React2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
10979 | function error(format2) {
|
10980 | {
|
10981 | {
|
10982 | for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
10983 | args[_key2 - 1] = arguments[_key2];
|
10984 | }
|
10985 | printWarning("error", format2, args);
|
10986 | }
|
10987 | }
|
10988 | }
|
10989 | function printWarning(level, format2, args) {
|
10990 | {
|
10991 | var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
10992 | var stack = ReactDebugCurrentFrame.getStackAddendum();
|
10993 | if (stack !== "") {
|
10994 | format2 += "%s";
|
10995 | args = args.concat([stack]);
|
10996 | }
|
10997 | var argsWithFormat = args.map(function(item) {
|
10998 | return String(item);
|
10999 | });
|
11000 | argsWithFormat.unshift("Warning: " + format2);
|
11001 | Function.prototype.apply.call(console[level], console, argsWithFormat);
|
11002 | }
|
11003 | }
|
11004 | function is2(x, y) {
|
11005 | return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
|
11006 | }
|
11007 | var objectIs = typeof Object.is === "function" ? Object.is : is2;
|
11008 | var useState = React2.useState, useEffect = React2.useEffect, useLayoutEffect2 = React2.useLayoutEffect, useDebugValue = React2.useDebugValue;
|
11009 | var didWarnOld18Alpha = false;
|
11010 | var didWarnUncachedGetSnapshot = false;
|
11011 | function useSyncExternalStore(subscribe2, getSnapshot, getServerSnapshot) {
|
11012 | {
|
11013 | if (!didWarnOld18Alpha) {
|
11014 | if (React2.startTransition !== void 0) {
|
11015 | didWarnOld18Alpha = true;
|
11016 | error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release.");
|
11017 | }
|
11018 | }
|
11019 | }
|
11020 | var value = getSnapshot();
|
11021 | {
|
11022 | if (!didWarnUncachedGetSnapshot) {
|
11023 | var cachedValue = getSnapshot();
|
11024 | if (!objectIs(value, cachedValue)) {
|
11025 | error("The result of getSnapshot should be cached to avoid an infinite loop");
|
11026 | didWarnUncachedGetSnapshot = true;
|
11027 | }
|
11028 | }
|
11029 | }
|
11030 | var _useState = useState({
|
11031 | inst: {
|
11032 | value,
|
11033 | getSnapshot
|
11034 | }
|
11035 | }), inst = _useState[0].inst, forceUpdate = _useState[1];
|
11036 | useLayoutEffect2(function() {
|
11037 | inst.value = value;
|
11038 | inst.getSnapshot = getSnapshot;
|
11039 | if (checkIfSnapshotChanged(inst)) {
|
11040 | forceUpdate({
|
11041 | inst
|
11042 | });
|
11043 | }
|
11044 | }, [subscribe2, value, getSnapshot]);
|
11045 | useEffect(function() {
|
11046 | if (checkIfSnapshotChanged(inst)) {
|
11047 | forceUpdate({
|
11048 | inst
|
11049 | });
|
11050 | }
|
11051 | var handleStoreChange = function() {
|
11052 | if (checkIfSnapshotChanged(inst)) {
|
11053 | forceUpdate({
|
11054 | inst
|
11055 | });
|
11056 | }
|
11057 | };
|
11058 | return subscribe2(handleStoreChange);
|
11059 | }, [subscribe2]);
|
11060 | useDebugValue(value);
|
11061 | return value;
|
11062 | }
|
11063 | function checkIfSnapshotChanged(inst) {
|
11064 | var latestGetSnapshot = inst.getSnapshot;
|
11065 | var prevValue = inst.value;
|
11066 | try {
|
11067 | var nextValue = latestGetSnapshot();
|
11068 | return !objectIs(prevValue, nextValue);
|
11069 | } catch (error2) {
|
11070 | return true;
|
11071 | }
|
11072 | }
|
11073 | function useSyncExternalStore$1(subscribe2, getSnapshot, getServerSnapshot) {
|
11074 | return getSnapshot();
|
11075 | }
|
11076 | var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
11077 | var isServerEnvironment = !canUseDOM;
|
11078 | var shim2 = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
|
11079 | var useSyncExternalStore$2 = React2.useSyncExternalStore !== void 0 ? React2.useSyncExternalStore : shim2;
|
11080 | useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2;
|
11081 | if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
|
11082 | __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
11083 | }
|
11084 | })();
|
11085 | }
|
11086 | {
|
11087 | shim.exports = useSyncExternalStoreShim_development;
|
11088 | }
|
11089 | var shimExports = shim.exports;
|
11090 | let reduced = false;
|
11091 | const subscribers = new Set();
|
11092 | function notify() {
|
11093 | subscribers.forEach((subscriber) => {
|
11094 | subscriber();
|
11095 | });
|
11096 | }
|
11097 | function reduceMotion() {
|
11098 | reduced = true;
|
11099 | notify();
|
11100 | globals.assign({
|
11101 | skipAnimation: true
|
11102 | });
|
11103 | }
|
11104 | function restoreMotion() {
|
11105 | reduced = false;
|
11106 | notify();
|
11107 | globals.assign({
|
11108 | skipAnimation: false
|
11109 | });
|
11110 | }
|
11111 | function isMotionReduced() {
|
11112 | return reduced;
|
11113 | }
|
11114 | function subscribe(onStoreChange) {
|
11115 | subscribers.add(onStoreChange);
|
11116 | return () => {
|
11117 | subscribers.delete(onStoreChange);
|
11118 | };
|
11119 | }
|
11120 | function useMotionReduced() {
|
11121 | return shimExports.useSyncExternalStore(subscribe, isMotionReduced, isMotionReduced);
|
11122 | }
|
11123 | const classPrefix$17 = "adm-spin-loading";
|
11124 | const colorRecord$2 = {
|
11125 | default: "var(--adm-color-weak)",
|
11126 | primary: "var(--adm-color-primary)",
|
11127 | white: "var(--adm-color-white)"
|
11128 | };
|
11129 | const defaultProps$V = {
|
11130 | color: "default"
|
11131 | };
|
11132 | const circumference = 15 * 3.14159265358979 * 2;
|
11133 | const SpinLoading = React$1.memo((p) => {
|
11134 | var _a;
|
11135 | const props = mergeProps(defaultProps$V, p);
|
11136 | const motionReduced = useMotionReduced();
|
11137 | const {
|
11138 | percent
|
11139 | } = useSpring({
|
11140 | cancel: motionReduced,
|
11141 | loop: {
|
11142 | reverse: true
|
11143 | },
|
11144 | from: {
|
11145 | percent: 80
|
11146 | },
|
11147 | to: {
|
11148 | percent: 30
|
11149 | },
|
11150 | config: {
|
11151 | duration: 1200
|
11152 | }
|
11153 | });
|
11154 | return withNativeProps(props, React$1.createElement(animated.div, {
|
11155 | className: classPrefix$17,
|
11156 | style: {
|
11157 | "--color": (_a = colorRecord$2[props.color]) !== null && _a !== void 0 ? _a : props.color,
|
11158 | "--percent": percent
|
11159 | }
|
11160 | }, React$1.createElement("svg", {
|
11161 | className: `${classPrefix$17}-svg`,
|
11162 | viewBox: "0 0 32 32"
|
11163 | }, React$1.createElement(animated.circle, {
|
11164 | className: `${classPrefix$17}-fill`,
|
11165 | fill: "transparent",
|
11166 | strokeWidth: "2",
|
11167 | strokeDasharray: circumference,
|
11168 | strokeDashoffset: percent,
|
11169 | strokeLinecap: "square",
|
11170 | r: 15,
|
11171 | cx: 16,
|
11172 | cy: 16
|
11173 | }))));
|
11174 | });
|
11175 | const classPrefix$16 = `adm-picker-view`;
|
11176 | const defaultProps$U = {
|
11177 | defaultValue: [],
|
11178 | renderLabel: defaultRenderLabel,
|
11179 | mouseWheel: false,
|
11180 | loadingContent: React$1.createElement("div", {
|
11181 | className: `${classPrefix$16}-loading-content`
|
11182 | }, React$1.createElement(SpinLoading, null))
|
11183 | };
|
11184 | const PickerView = React$1.memo((p) => {
|
11185 | const props = mergeProps(defaultProps$U, p);
|
11186 | const [innerValue, setInnerValue] = React$1.useState(props.value === void 0 ? props.defaultValue : props.value);
|
11187 | React$1.useEffect(() => {
|
11188 | if (props.value === void 0)
|
11189 | return;
|
11190 | if (props.value === innerValue)
|
11191 | return;
|
11192 | setInnerValue(props.value);
|
11193 | }, [props.value]);
|
11194 | React$1.useEffect(() => {
|
11195 | if (props.value === innerValue)
|
11196 | return;
|
11197 | const timeout = window.setTimeout(() => {
|
11198 | if (props.value !== void 0 && props.value !== innerValue) {
|
11199 | setInnerValue(props.value);
|
11200 | }
|
11201 | }, 1e3);
|
11202 | return () => {
|
11203 | window.clearTimeout(timeout);
|
11204 | };
|
11205 | }, [props.value, innerValue]);
|
11206 | const extend = useColumnsExtend(props.columns, innerValue);
|
11207 | const columns = extend.columns;
|
11208 | useDebounceEffect(() => {
|
11209 | var _a;
|
11210 | if (props.value === innerValue)
|
11211 | return;
|
11212 | (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, innerValue, extend);
|
11213 | }, [innerValue], {
|
11214 | wait: 0,
|
11215 | leading: false,
|
11216 | trailing: true
|
11217 | });
|
11218 | const handleSelect = React$1.useCallback((val, index2) => {
|
11219 | setInnerValue((prev) => {
|
11220 | const next = [...prev];
|
11221 | next[index2] = val;
|
11222 | return next;
|
11223 | });
|
11224 | }, []);
|
11225 | return withNativeProps(props, React$1.createElement("div", {
|
11226 | className: `${classPrefix$16}`
|
11227 | }, props.loading ? props.loadingContent : React$1.createElement(React$1.Fragment, null, columns.map((column, index2) => React$1.createElement(Wheel, {
|
11228 | key: index2,
|
11229 | index: index2,
|
11230 | column,
|
11231 | value: innerValue[index2],
|
11232 | onSelect: handleSelect,
|
11233 | renderLabel: props.renderLabel,
|
11234 | mouseWheel: props.mouseWheel
|
11235 | })), React$1.createElement("div", {
|
11236 | className: `${classPrefix$16}-mask`
|
11237 | }, React$1.createElement("div", {
|
11238 | className: `${classPrefix$16}-mask-top`
|
11239 | }), React$1.createElement("div", {
|
11240 | className: `${classPrefix$16}-mask-middle`
|
11241 | }), React$1.createElement("div", {
|
11242 | className: `${classPrefix$16}-mask-bottom`
|
11243 | })))));
|
11244 | });
|
11245 | PickerView.displayName = "PickerView";
|
11246 | const classPrefix$15 = `adm-picker`;
|
11247 | const defaultProps$T = {
|
11248 | defaultValue: [],
|
11249 | closeOnMaskClick: true,
|
11250 | renderLabel: defaultRenderLabel,
|
11251 | destroyOnClose: false,
|
11252 | forceRender: false
|
11253 | };
|
11254 | const Picker$1 = React$1.memo(React$1.forwardRef((p, ref) => {
|
11255 | var _a;
|
11256 | const {
|
11257 | locale
|
11258 | } = useConfig();
|
11259 | const props = mergeProps(defaultProps$T, {
|
11260 | confirmText: locale.common.confirm,
|
11261 | cancelText: locale.common.cancel
|
11262 | }, p);
|
11263 | const [visible, setVisible] = usePropsValue({
|
11264 | value: props.visible,
|
11265 | defaultValue: false,
|
11266 | onChange: (v) => {
|
11267 | var _a2;
|
11268 | if (v === false) {
|
11269 | (_a2 = props.onClose) === null || _a2 === void 0 ? void 0 : _a2.call(props);
|
11270 | }
|
11271 | }
|
11272 | });
|
11273 | const actions = {
|
11274 | toggle: () => {
|
11275 | setVisible((v) => !v);
|
11276 | },
|
11277 | open: () => {
|
11278 | setVisible(true);
|
11279 | },
|
11280 | close: () => {
|
11281 | setVisible(false);
|
11282 | }
|
11283 | };
|
11284 | React$1.useImperativeHandle(ref, () => actions);
|
11285 | const [value, setValue2] = usePropsValue(Object.assign(Object.assign({}, props), {
|
11286 | onChange: (val) => {
|
11287 | var _a2;
|
11288 | const extend2 = generateColumnsExtend(props.columns, val);
|
11289 | (_a2 = props.onConfirm) === null || _a2 === void 0 ? void 0 : _a2.call(props, val, extend2);
|
11290 | }
|
11291 | }));
|
11292 | const extend = useColumnsExtend(props.columns, value);
|
11293 | const [innerValue, setInnerValue] = React$1.useState(value);
|
11294 | React$1.useEffect(() => {
|
11295 | if (innerValue !== value) {
|
11296 | setInnerValue(value);
|
11297 | }
|
11298 | }, [visible]);
|
11299 | React$1.useEffect(() => {
|
11300 | if (!visible) {
|
11301 | setInnerValue(value);
|
11302 | }
|
11303 | }, [value]);
|
11304 | const onChange = useMemoizedFn((val, ext) => {
|
11305 | var _a2;
|
11306 | setInnerValue(val);
|
11307 | if (visible) {
|
11308 | (_a2 = props.onSelect) === null || _a2 === void 0 ? void 0 : _a2.call(props, val, ext);
|
11309 | }
|
11310 | });
|
11311 | const pickerElement = withNativeProps(props, React$1.createElement("div", {
|
11312 | className: classPrefix$15
|
11313 | }, React$1.createElement("div", {
|
11314 | className: `${classPrefix$15}-header`
|
11315 | }, React$1.createElement("a", {
|
11316 | role: "button",
|
11317 | className: `${classPrefix$15}-header-button`,
|
11318 | onClick: () => {
|
11319 | var _a2;
|
11320 | (_a2 = props.onCancel) === null || _a2 === void 0 ? void 0 : _a2.call(props);
|
11321 | setVisible(false);
|
11322 | }
|
11323 | }, props.cancelText), React$1.createElement("div", {
|
11324 | className: `${classPrefix$15}-header-title`
|
11325 | }, props.title), React$1.createElement("a", {
|
11326 | role: "button",
|
11327 | className: classNames(`${classPrefix$15}-header-button`, props.loading && `${classPrefix$15}-header-button-disabled`),
|
11328 | onClick: () => {
|
11329 | if (props.loading)
|
11330 | return;
|
11331 | setValue2(innerValue, true);
|
11332 | setVisible(false);
|
11333 | },
|
11334 | "aria-disabled": props.loading
|
11335 | }, props.confirmText)), React$1.createElement("div", {
|
11336 | className: `${classPrefix$15}-body`
|
11337 | }, React$1.createElement(PickerView, {
|
11338 | loading: props.loading,
|
11339 | loadingContent: props.loadingContent,
|
11340 | columns: props.columns,
|
11341 | renderLabel: props.renderLabel,
|
11342 | value: innerValue,
|
11343 | mouseWheel: props.mouseWheel,
|
11344 | onChange
|
11345 | }))));
|
11346 | const popupElement = React$1.createElement(Popup, {
|
11347 | style: props.popupStyle,
|
11348 | className: classNames(`${classPrefix$15}-popup`, props.popupClassName),
|
11349 | visible,
|
11350 | position: "bottom",
|
11351 | onMaskClick: () => {
|
11352 | var _a2;
|
11353 | if (!props.closeOnMaskClick)
|
11354 | return;
|
11355 | (_a2 = props.onCancel) === null || _a2 === void 0 ? void 0 : _a2.call(props);
|
11356 | setVisible(false);
|
11357 | },
|
11358 | getContainer: props.getContainer,
|
11359 | destroyOnClose: props.destroyOnClose,
|
11360 | afterShow: props.afterShow,
|
11361 | afterClose: props.afterClose,
|
11362 | onClick: props.onClick,
|
11363 | forceRender: props.forceRender,
|
11364 | stopPropagation: props.stopPropagation
|
11365 | }, pickerElement, React$1.createElement(SafeArea, {
|
11366 | position: "bottom"
|
11367 | }));
|
11368 | return React$1.createElement(React$1.Fragment, null, popupElement, (_a = props.children) === null || _a === void 0 ? void 0 : _a.call(props, extend.items, actions));
|
11369 | }));
|
11370 | Picker$1.displayName = "Picker";
|
11371 | function prompt$3(props) {
|
11372 | return new Promise((resolve) => {
|
11373 | const Wrapper2 = () => {
|
11374 | const [visible, setVisible] = React$1.useState(false);
|
11375 | React$1.useEffect(() => {
|
11376 | setVisible(true);
|
11377 | }, []);
|
11378 | return React$1.createElement(Picker$1, Object.assign({}, props, {
|
11379 | visible,
|
11380 | onConfirm: (val, extend) => {
|
11381 | var _a;
|
11382 | (_a = props.onConfirm) === null || _a === void 0 ? void 0 : _a.call(props, val, extend);
|
11383 | resolve(val);
|
11384 | },
|
11385 | onClose: () => {
|
11386 | var _a;
|
11387 | (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
11388 | setVisible(false);
|
11389 | resolve(null);
|
11390 | },
|
11391 | afterClose: () => {
|
11392 | var _a;
|
11393 | (_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
11394 | unmount2();
|
11395 | }
|
11396 | }));
|
11397 | };
|
11398 | const unmount2 = renderToBody(React$1.createElement(Wrapper2, null));
|
11399 | });
|
11400 | }
|
11401 | const Picker = attachPropertiesToComponent(Picker$1, {
|
11402 | prompt: prompt$3
|
11403 | });
|
11404 | function useColumnsFn(options) {
|
11405 | const depth = React$1.useMemo(() => {
|
11406 | let depth2 = 0;
|
11407 | function traverse(options2, currentDepth) {
|
11408 | if (currentDepth > depth2)
|
11409 | depth2 = currentDepth;
|
11410 | const nextDepth = currentDepth + 1;
|
11411 | options2.forEach((option) => {
|
11412 | if (option.children) {
|
11413 | traverse(option.children, nextDepth);
|
11414 | }
|
11415 | });
|
11416 | }
|
11417 | traverse(options, 1);
|
11418 | return depth2;
|
11419 | }, [options]);
|
11420 | return (selected) => {
|
11421 | const columns = [];
|
11422 | let currentOptions = options;
|
11423 | let i2 = 0;
|
11424 | while (true) {
|
11425 | columns.push(currentOptions.map((option) => ({
|
11426 | label: option.label,
|
11427 | value: option.value
|
11428 | })));
|
11429 | const x = selected[i2];
|
11430 | const targetOptions = currentOptions.find((option) => option.value === x);
|
11431 | if (!targetOptions || !targetOptions.children)
|
11432 | break;
|
11433 | currentOptions = targetOptions.children;
|
11434 | i2++;
|
11435 | }
|
11436 | while (i2 < depth - 1) {
|
11437 | columns.push([]);
|
11438 | i2++;
|
11439 | }
|
11440 | return columns;
|
11441 | };
|
11442 | }
|
11443 | const CascadePicker = React$1.forwardRef((props, ref) => {
|
11444 | const {
|
11445 | options
|
11446 | } = props, pickerProps = __rest(props, ["options"]);
|
11447 | const columnsFn = useColumnsFn(options);
|
11448 | return React$1.createElement(Picker, Object.assign({}, pickerProps, {
|
11449 | ref,
|
11450 | columns: columnsFn
|
11451 | }));
|
11452 | });
|
11453 | function prompt$2(props) {
|
11454 | return new Promise((resolve) => {
|
11455 | const Wrapper2 = () => {
|
11456 | const [visible, setVisible] = React$1.useState(false);
|
11457 | React$1.useEffect(() => {
|
11458 | setVisible(true);
|
11459 | }, []);
|
11460 | return React$1.createElement(CascadePicker, Object.assign({}, props, {
|
11461 | visible,
|
11462 | onConfirm: (val, extend) => {
|
11463 | var _a;
|
11464 | (_a = props.onConfirm) === null || _a === void 0 ? void 0 : _a.call(props, val, extend);
|
11465 | resolve(val);
|
11466 | },
|
11467 | onClose: () => {
|
11468 | var _a;
|
11469 | (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
11470 | setVisible(false);
|
11471 | resolve(null);
|
11472 | },
|
11473 | afterClose: () => {
|
11474 | var _a;
|
11475 | (_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
11476 | unmount2();
|
11477 | }
|
11478 | }));
|
11479 | };
|
11480 | const unmount2 = renderToBody(React$1.createElement(Wrapper2, null));
|
11481 | });
|
11482 | }
|
11483 | const index$g = attachPropertiesToComponent(CascadePicker, {
|
11484 | prompt: prompt$2
|
11485 | });
|
11486 | const CascadePickerView = (props) => {
|
11487 | const {
|
11488 | options
|
11489 | } = props, pickerProps = __rest(props, ["options"]);
|
11490 | const columnsFn = useColumnsFn(options);
|
11491 | return React$1.createElement(PickerView, Object.assign({}, pickerProps, {
|
11492 | columns: columnsFn
|
11493 | }));
|
11494 | };
|
11495 | const classPrefix$14 = `adm-tabs`;
|
11496 | const Tab = () => {
|
11497 | return null;
|
11498 | };
|
11499 | const defaultProps$S = {
|
11500 | activeLineMode: "auto",
|
11501 | stretch: true,
|
11502 | direction: "ltr"
|
11503 | };
|
11504 | const Tabs$1 = (p) => {
|
11505 | var _a;
|
11506 | const props = mergeProps(defaultProps$S, p);
|
11507 | const tabListContainerRef = React$1.useRef(null);
|
11508 | const activeLineRef = React$1.useRef(null);
|
11509 | const keyToIndexRecord = {};
|
11510 | let firstActiveKey = null;
|
11511 | const panes = [];
|
11512 | const isRTL2 = props.direction === "rtl";
|
11513 | traverseReactNode(props.children, (child, index2) => {
|
11514 | if (!React$1.isValidElement(child))
|
11515 | return;
|
11516 | const key = child.key;
|
11517 | if (typeof key !== "string")
|
11518 | return;
|
11519 | if (index2 === 0) {
|
11520 | firstActiveKey = key;
|
11521 | }
|
11522 | const length = panes.push(child);
|
11523 | keyToIndexRecord[key] = length - 1;
|
11524 | });
|
11525 | const [activeKey, setActiveKey] = usePropsValue({
|
11526 | value: props.activeKey,
|
11527 | defaultValue: (_a = props.defaultActiveKey) !== null && _a !== void 0 ? _a : firstActiveKey,
|
11528 | onChange: (v) => {
|
11529 | var _a2;
|
11530 | if (v === null)
|
11531 | return;
|
11532 | (_a2 = props.onChange) === null || _a2 === void 0 ? void 0 : _a2.call(props, v);
|
11533 | }
|
11534 | });
|
11535 | const [{
|
11536 | x,
|
11537 | width
|
11538 | }, inkApi] = useSpring(() => ({
|
11539 | x: 0,
|
11540 | width: 0,
|
11541 | config: {
|
11542 | tension: 300,
|
11543 | clamp: true
|
11544 | }
|
11545 | }));
|
11546 | const [{
|
11547 | scrollLeft
|
11548 | }, scrollApi] = useSpring(() => ({
|
11549 | scrollLeft: 0,
|
11550 | config: {
|
11551 | tension: 300,
|
11552 | clamp: true
|
11553 | }
|
11554 | }));
|
11555 | const [{
|
11556 | leftMaskOpacity,
|
11557 | rightMaskOpacity
|
11558 | }, maskApi] = useSpring(() => ({
|
11559 | leftMaskOpacity: 0,
|
11560 | rightMaskOpacity: 0,
|
11561 | config: {
|
11562 | clamp: true
|
11563 | }
|
11564 | }));
|
11565 | function animate(immediate = false, fromMutation = false) {
|
11566 | const container = tabListContainerRef.current;
|
11567 | if (!container)
|
11568 | return;
|
11569 | const activeIndex = keyToIndexRecord[activeKey];
|
11570 | if (activeIndex === void 0) {
|
11571 | inkApi.start({
|
11572 | x: 0,
|
11573 | width: 0,
|
11574 | immediate: true
|
11575 | });
|
11576 | return;
|
11577 | }
|
11578 | const activeLine = activeLineRef.current;
|
11579 | if (!activeLine)
|
11580 | return;
|
11581 | const activeTabWrapper = container.children.item(activeIndex + 1);
|
11582 | const activeTab = activeTabWrapper.children.item(0);
|
11583 | const activeTabLeft = activeTab.offsetLeft;
|
11584 | const activeTabWidth = activeTab.offsetWidth;
|
11585 | const activeTabWrapperLeft = activeTabWrapper.offsetLeft;
|
11586 | const activeTabWrapperWidth = activeTabWrapper.offsetWidth;
|
11587 | const containerWidth = container.offsetWidth;
|
11588 | const containerScrollWidth = container.scrollWidth;
|
11589 | const containerScrollLeft = container.scrollLeft;
|
11590 | const activeLineWidth = activeLine.offsetWidth;
|
11591 | let x2 = 0;
|
11592 | let width2 = 0;
|
11593 | if (props.activeLineMode === "auto") {
|
11594 | x2 = activeTabLeft;
|
11595 | width2 = activeTabWidth;
|
11596 | } else if (props.activeLineMode === "full") {
|
11597 | x2 = activeTabWrapperLeft;
|
11598 | width2 = activeTabWrapperWidth;
|
11599 | } else {
|
11600 | x2 = activeTabLeft + (activeTabWidth - activeLineWidth) / 2;
|
11601 | }
|
11602 | if (isRTL2) {
|
11603 | const w = ["auto", "full"].includes(props.activeLineMode) ? width2 : activeLineWidth;
|
11604 | x2 = -(containerWidth - x2 - w);
|
11605 | }
|
11606 | inkApi.start({
|
11607 | x: x2,
|
11608 | width: width2,
|
11609 | immediate
|
11610 | });
|
11611 | const maxScrollDistance = containerScrollWidth - containerWidth;
|
11612 | if (maxScrollDistance <= 0)
|
11613 | return;
|
11614 | let nextScrollLeft = 0;
|
11615 | if (isRTL2) {
|
11616 | nextScrollLeft = -bound(containerWidth / 2 - activeTabLeft + activeTabWidth / 2 - activeLineWidth, 0, maxScrollDistance);
|
11617 | } else {
|
11618 | nextScrollLeft = bound(activeTabLeft - (containerWidth - activeTabWidth) / 2, 0, maxScrollDistance);
|
11619 | }
|
11620 | if (!fromMutation || props.autoScroll !== false) {
|
11621 | scrollApi.start({
|
11622 | scrollLeft: nextScrollLeft,
|
11623 | from: {
|
11624 | scrollLeft: containerScrollLeft
|
11625 | },
|
11626 | immediate
|
11627 | });
|
11628 | }
|
11629 | }
|
11630 | useIsomorphicLayoutEffect$2(() => {
|
11631 | animate(!x.isAnimating);
|
11632 | }, []);
|
11633 | useIsomorphicUpdateLayoutEffect(() => {
|
11634 | animate();
|
11635 | }, [activeKey]);
|
11636 | useResizeEffect(() => {
|
11637 | animate(!x.isAnimating);
|
11638 | }, tabListContainerRef);
|
11639 | useMutationEffect(() => {
|
11640 | animate(!x.isAnimating, true);
|
11641 | }, tabListContainerRef, {
|
11642 | subtree: true,
|
11643 | childList: true,
|
11644 | characterData: true
|
11645 | });
|
11646 | const {
|
11647 | run: updateMask
|
11648 | } = useThrottleFn((immediate = false) => {
|
11649 | const container = tabListContainerRef.current;
|
11650 | if (!container)
|
11651 | return;
|
11652 | const scrollLeft2 = container.scrollLeft;
|
11653 | let showLeftMask = false;
|
11654 | let showRightMask = false;
|
11655 | if (isRTL2) {
|
11656 | showLeftMask = Math.round(-scrollLeft2) + container.offsetWidth < container.scrollWidth;
|
11657 | showRightMask = scrollLeft2 < 0;
|
11658 | } else {
|
11659 | showLeftMask = scrollLeft2 > 0;
|
11660 | showRightMask = scrollLeft2 + container.offsetWidth < container.scrollWidth;
|
11661 | }
|
11662 | maskApi.start({
|
11663 | leftMaskOpacity: showLeftMask ? 1 : 0,
|
11664 | rightMaskOpacity: showRightMask ? 1 : 0,
|
11665 | immediate
|
11666 | });
|
11667 | }, {
|
11668 | wait: 100,
|
11669 | trailing: true,
|
11670 | leading: true
|
11671 | });
|
11672 | useIsomorphicLayoutEffect$2(() => {
|
11673 | updateMask(true);
|
11674 | }, []);
|
11675 | return withNativeProps(props, React$1.createElement("div", {
|
11676 | className: classPrefix$14,
|
11677 | style: {
|
11678 | direction: props.direction
|
11679 | }
|
11680 | }, React$1.createElement("div", {
|
11681 | className: `${classPrefix$14}-header`
|
11682 | }, React$1.createElement(animated.div, {
|
11683 | className: classNames(`${classPrefix$14}-header-mask`, `${classPrefix$14}-header-mask-left`),
|
11684 | style: {
|
11685 | opacity: leftMaskOpacity
|
11686 | }
|
11687 | }), React$1.createElement(animated.div, {
|
11688 | className: classNames(`${classPrefix$14}-header-mask`, `${classPrefix$14}-header-mask-right`),
|
11689 | style: {
|
11690 | opacity: rightMaskOpacity
|
11691 | }
|
11692 | }), React$1.createElement(animated.div, {
|
11693 | className: `${classPrefix$14}-tab-list`,
|
11694 | ref: tabListContainerRef,
|
11695 | scrollLeft,
|
11696 | onScroll: updateMask,
|
11697 | role: "tablist"
|
11698 | }, React$1.createElement(animated.div, {
|
11699 | ref: activeLineRef,
|
11700 | className: `${classPrefix$14}-tab-line`,
|
11701 | style: {
|
11702 | width: props.activeLineMode === "fixed" ? "var(--fixed-active-line-width, 30px)" : width,
|
11703 | x
|
11704 | }
|
11705 | }), panes.map((pane) => withNativeProps(pane.props, React$1.createElement("div", {
|
11706 | key: pane.key,
|
11707 | className: classNames(`${classPrefix$14}-tab-wrapper`, {
|
11708 | [`${classPrefix$14}-tab-wrapper-stretch`]: props.stretch
|
11709 | })
|
11710 | }, React$1.createElement("div", {
|
11711 | onClick: () => {
|
11712 | const {
|
11713 | key
|
11714 | } = pane;
|
11715 | if (pane.props.disabled)
|
11716 | return;
|
11717 | if (key === void 0 || key === null) {
|
11718 | return;
|
11719 | }
|
11720 | setActiveKey(key.toString());
|
11721 | },
|
11722 | className: classNames(`${classPrefix$14}-tab`, {
|
11723 | [`${classPrefix$14}-tab-active`]: pane.key === activeKey,
|
11724 | [`${classPrefix$14}-tab-disabled`]: pane.props.disabled
|
11725 | }),
|
11726 | role: "tab",
|
11727 | "aria-selected": pane.key === activeKey
|
11728 | }, pane.props.title)))))), panes.map((pane) => {
|
11729 | if (pane.props.children === void 0) {
|
11730 | return null;
|
11731 | }
|
11732 | const active = pane.key === activeKey;
|
11733 | return React$1.createElement(ShouldRender, {
|
11734 | key: pane.key,
|
11735 | active,
|
11736 | forceRender: pane.props.forceRender,
|
11737 | destroyOnClose: pane.props.destroyOnClose
|
11738 | }, React$1.createElement("div", {
|
11739 | className: `${classPrefix$14}-content`,
|
11740 | style: {
|
11741 | display: active ? "block" : "none"
|
11742 | }
|
11743 | }, pane.props.children));
|
11744 | })));
|
11745 | };
|
11746 | const Tabs = attachPropertiesToComponent(Tabs$1, {
|
11747 | Tab
|
11748 | });
|
11749 | const classPrefix$13 = `adm-list`;
|
11750 | const defaultProps$R = {
|
11751 | mode: "default"
|
11752 | };
|
11753 | const List$2 = React$1.forwardRef((p, ref) => {
|
11754 | const props = mergeProps(defaultProps$R, p);
|
11755 | const nativeElementRef = React$1.useRef(null);
|
11756 | React$1.useImperativeHandle(ref, () => ({
|
11757 | get nativeElement() {
|
11758 | return nativeElementRef.current;
|
11759 | }
|
11760 | }));
|
11761 | return withNativeProps(props, React$1.createElement("div", {
|
11762 | className: classNames(classPrefix$13, `${classPrefix$13}-${props.mode}`),
|
11763 | ref: nativeElementRef
|
11764 | }, props.header && React$1.createElement("div", {
|
11765 | className: `${classPrefix$13}-header`
|
11766 | }, props.header), React$1.createElement("div", {
|
11767 | className: `${classPrefix$13}-body`
|
11768 | }, React$1.createElement("div", {
|
11769 | className: `${classPrefix$13}-body-inner`
|
11770 | }, props.children))));
|
11771 | });
|
11772 | function isNodeWithContent(node) {
|
11773 | return node !== void 0 && node !== null && node !== false;
|
11774 | }
|
11775 | const classPrefix$12 = `adm-list-item`;
|
11776 | const ListItem = (props) => {
|
11777 | var _a, _b;
|
11778 | const {
|
11779 | arrow: arrow2,
|
11780 | arrowIcon
|
11781 | } = props;
|
11782 | const {
|
11783 | list: componentConfig = {}
|
11784 | } = useConfig();
|
11785 | const clickable = (_a = props.clickable) !== null && _a !== void 0 ? _a : !!props.onClick;
|
11786 | const showArrow = (_b = arrow2 !== null && arrow2 !== void 0 ? arrow2 : arrowIcon) !== null && _b !== void 0 ? _b : clickable;
|
11787 | const mergedArrowIcon = mergeProp(componentConfig.arrowIcon, arrow2 !== true ? arrow2 : null, arrowIcon !== true ? arrowIcon : null);
|
11788 | const content = React$1.createElement("div", {
|
11789 | className: `${classPrefix$12}-content`
|
11790 | }, isNodeWithContent(props.prefix) && React$1.createElement("div", {
|
11791 | className: `${classPrefix$12}-content-prefix`
|
11792 | }, props.prefix), React$1.createElement("div", {
|
11793 | className: `${classPrefix$12}-content-main`
|
11794 | }, isNodeWithContent(props.title) && React$1.createElement("div", {
|
11795 | className: `${classPrefix$12}-title`
|
11796 | }, props.title), props.children, isNodeWithContent(props.description) && React$1.createElement("div", {
|
11797 | className: `${classPrefix$12}-description`
|
11798 | }, props.description)), isNodeWithContent(props.extra) && React$1.createElement("div", {
|
11799 | className: `${classPrefix$12}-content-extra`
|
11800 | }, props.extra), showArrow && React$1.createElement("div", {
|
11801 | className: `${classPrefix$12}-content-arrow`
|
11802 | }, mergedArrowIcon || React$1.createElement(RightOutline, null)));
|
11803 | return withNativeProps(props, React$1.createElement(clickable ? "a" : "div", {
|
11804 | className: classNames(`${classPrefix$12}`, clickable ? ["adm-plain-anchor"] : [], props.disabled && `${classPrefix$12}-disabled`),
|
11805 | onClick: props.disabled ? void 0 : props.onClick
|
11806 | }, content));
|
11807 | };
|
11808 | const List$1 = attachPropertiesToComponent(List$2, {
|
11809 | Item: ListItem
|
11810 | });
|
11811 | const CheckListContext = React$1.createContext(null);
|
11812 | const classPrefix$11 = "adm-check-list";
|
11813 | const defaultProps$Q = {
|
11814 | multiple: false,
|
11815 | defaultValue: [],
|
11816 | activeIcon: React$1.createElement(CheckOutline, null)
|
11817 | };
|
11818 | const CheckList$1 = (props) => {
|
11819 | const {
|
11820 | checkList: componentConfig = {}
|
11821 | } = useConfig();
|
11822 | const mergedProps = mergeProps(defaultProps$Q, componentConfig, props);
|
11823 | const [value, setValue2] = usePropsValue(mergedProps);
|
11824 | function check(val) {
|
11825 | if (mergedProps.multiple) {
|
11826 | setValue2([...value, val]);
|
11827 | } else {
|
11828 | setValue2([val]);
|
11829 | }
|
11830 | }
|
11831 | function uncheck(val) {
|
11832 | setValue2(value.filter((item) => item !== val));
|
11833 | }
|
11834 | const {
|
11835 | activeIcon,
|
11836 | extra,
|
11837 | disabled,
|
11838 | readOnly
|
11839 | } = mergedProps;
|
11840 | return React$1.createElement(CheckListContext.Provider, {
|
11841 | value: {
|
11842 | value,
|
11843 | check,
|
11844 | uncheck,
|
11845 | activeIcon,
|
11846 | extra,
|
11847 | disabled,
|
11848 | readOnly
|
11849 | }
|
11850 | }, withNativeProps(mergedProps, React$1.createElement(List$1, {
|
11851 | mode: mergedProps.mode,
|
11852 | className: classPrefix$11
|
11853 | }, mergedProps.children)));
|
11854 | };
|
11855 | const classPrefix$10 = `adm-check-list-item`;
|
11856 | const CheckListItem = (props) => {
|
11857 | const context = React$1.useContext(CheckListContext);
|
11858 | if (context === null) {
|
11859 | devWarning("CheckList.Item", "CheckList.Item can only be used inside CheckList.");
|
11860 | return null;
|
11861 | }
|
11862 | const active = context.value.includes(props.value);
|
11863 | const readOnly = props.readOnly || context.readOnly;
|
11864 | const defaultExtra = active ? context.activeIcon : null;
|
11865 | const renderExtra = context.extra ? context.extra(active) : defaultExtra;
|
11866 | const extra = React$1.createElement("div", {
|
11867 | className: `${classPrefix$10}-extra`
|
11868 | }, renderExtra);
|
11869 | return withNativeProps(props, React$1.createElement(List$1.Item, {
|
11870 | title: props.title,
|
11871 | className: classNames(classPrefix$10, readOnly && `${classPrefix$10}-readonly`, active && `${classPrefix$10}-active`),
|
11872 | description: props.description,
|
11873 | prefix: props.prefix,
|
11874 | onClick: (e2) => {
|
11875 | var _a;
|
11876 | if (readOnly)
|
11877 | return;
|
11878 | if (active) {
|
11879 | context.uncheck(props.value);
|
11880 | } else {
|
11881 | context.check(props.value);
|
11882 | }
|
11883 | (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, e2);
|
11884 | },
|
11885 | arrow: false,
|
11886 | clickable: !readOnly,
|
11887 | extra,
|
11888 | disabled: props.disabled || context.disabled
|
11889 | }, props.children));
|
11890 | };
|
11891 | const CheckList = attachPropertiesToComponent(CheckList$1, {
|
11892 | Item: CheckListItem
|
11893 | });
|
11894 | function $cf838c15c8b009ba$var$vrgs(f) {
|
11895 | var s = f + "", i2 = s.indexOf("...");
|
11896 | return i2 >= 0 && (i2 < s.indexOf(")") || s.indexOf("arguments") >= 0);
|
11897 | }
|
11898 | function $cf838c15c8b009ba$export$22f15dd4e5be7e52(fn, o) {
|
11899 | o || (o = {});
|
11900 | var vargs = o.vargs || $cf838c15c8b009ba$var$vrgs(fn), k = [], cache = new Map(), u, to2, d = function(key) {
|
11901 | return to2 = setTimeout(function() {
|
11902 | if (u) {
|
11903 | cache.delete(key);
|
11904 | return;
|
11905 | }
|
11906 | k.splice(key, 1);
|
11907 | }, o.maxAge);
|
11908 | }, c = o.maxAge > 0 && o.maxAge < Infinity ? d : 0, eq = o.equals ? o.equals : 0, maxargs = o.maxArgs, srlz = o.serializer, f;
|
11909 | if (fn.length === 1 && !o.equals && !vargs) {
|
11910 | f = function(a) {
|
11911 | if (srlz)
|
11912 | a = srlz(a);
|
11913 | var r;
|
11914 | return cache.get(a) || (!c || c(a), cache.set(a, r = fn.call(this, a)), r);
|
11915 | };
|
11916 | u = 1;
|
11917 | } else if (eq)
|
11918 | f = function() {
|
11919 | var l = maxargs || arguments.length, kl = k.length, i2 = -1;
|
11920 | while (++i2 < kl)
|
11921 | if (k[i2].length === l) {
|
11922 | var j = -1;
|
11923 | while (++j < l && eq(arguments[j], k[i2][j]))
|
11924 | ;
|
11925 | if (j === l)
|
11926 | return k[i2].val;
|
11927 | }
|
11928 | k[i2] = arguments;
|
11929 | return !c || c(i2), arguments.val = fn.apply(this, k[i2]);
|
11930 | };
|
11931 | else
|
11932 | f = function() {
|
11933 | var l = maxargs || arguments.length, kl = k.length, i2 = -1;
|
11934 | while (++i2 < kl)
|
11935 | if (k[i2].length === l) {
|
11936 | var j = -1;
|
11937 | while (++j < l && arguments[j] === k[i2][j])
|
11938 | ;
|
11939 | if (j === l)
|
11940 | return k[i2].val;
|
11941 | }
|
11942 | k[i2] = arguments;
|
11943 | return !c || c(i2), arguments.val = fn.apply(this, k[i2]);
|
11944 | };
|
11945 | f.clear = function() {
|
11946 | if (to2)
|
11947 | clearTimeout(to2);
|
11948 | cache.clear();
|
11949 | k = [];
|
11950 | };
|
11951 | f.keys = function() {
|
11952 | return u ? [
|
11953 | ...cache.keys()
|
11954 | ] : k.slice();
|
11955 | };
|
11956 | f.values = function() {
|
11957 | return u ? [
|
11958 | ...cache.values()
|
11959 | ] : k.map((args) => args.val);
|
11960 | };
|
11961 | return f;
|
11962 | }
|
11963 | function useCascaderValueExtend(options, fieldNames) {
|
11964 | const {
|
11965 | valueName,
|
11966 | childrenName
|
11967 | } = fieldNames;
|
11968 | const generateItems = React$1.useMemo(() => {
|
11969 | return $cf838c15c8b009ba$export$22f15dd4e5be7e52((val) => {
|
11970 | const ret = [];
|
11971 | let currentOptions = options;
|
11972 | for (const v of val) {
|
11973 | const target = currentOptions.find((option) => option[valueName] === v);
|
11974 | if (!target) {
|
11975 | break;
|
11976 | }
|
11977 | ret.push(target);
|
11978 | if (!target[childrenName])
|
11979 | break;
|
11980 | currentOptions = target[childrenName];
|
11981 | }
|
11982 | return ret;
|
11983 | }, {
|
11984 | equals: isEqual
|
11985 | });
|
11986 | }, [options]);
|
11987 | const generateIsLeaf = React$1.useMemo(() => {
|
11988 | return $cf838c15c8b009ba$export$22f15dd4e5be7e52((val) => {
|
11989 | const children = val.reduce((currentOptions, v) => {
|
11990 | var _a;
|
11991 | return ((_a = currentOptions.find((option) => option[valueName] === v)) === null || _a === void 0 ? void 0 : _a[childrenName]) || [];
|
11992 | }, options);
|
11993 | return children.length === 0;
|
11994 | }, {
|
11995 | equals: isEqual
|
11996 | });
|
11997 | }, [options]);
|
11998 | function generateValueExtend(val) {
|
11999 | return {
|
12000 | get items() {
|
12001 | return generateItems(val);
|
12002 | },
|
12003 | get isLeaf() {
|
12004 | return generateIsLeaf(val);
|
12005 | }
|
12006 | };
|
12007 | }
|
12008 | return generateValueExtend;
|
12009 | }
|
12010 | const optionSkeleton = [];
|
12011 | function generateIntArray(from, to2) {
|
12012 | const array = [];
|
12013 | for (let i2 = from; i2 <= to2; i2++) {
|
12014 | array.push(i2);
|
12015 | }
|
12016 | return array;
|
12017 | }
|
12018 | const classPrefix$$ = "adm-skeleton";
|
12019 | const Skeleton$1 = (props) => {
|
12020 | return withNativeProps(props, React$1.createElement("div", {
|
12021 | className: classNames(classPrefix$$, {
|
12022 | [`${classPrefix$$}-animated`]: props.animated
|
12023 | })
|
12024 | }));
|
12025 | };
|
12026 | const SkeletonTitle = (props) => {
|
12027 | return withNativeProps(props, React$1.createElement(Skeleton$1, {
|
12028 | animated: props.animated,
|
12029 | className: `${classPrefix$$}-title`
|
12030 | }));
|
12031 | };
|
12032 | const defaultSkeletonParagraphProps = {
|
12033 | lineCount: 3
|
12034 | };
|
12035 | const SkeletonParagraph = (p) => {
|
12036 | const props = mergeProps(defaultSkeletonParagraphProps, p);
|
12037 | const keys = generateIntArray(1, props.lineCount);
|
12038 | const node = React$1.createElement("div", {
|
12039 | className: `${classPrefix$$}-paragraph`
|
12040 | }, keys.map((key) => React$1.createElement(Skeleton$1, {
|
12041 | key,
|
12042 | animated: props.animated,
|
12043 | className: `${classPrefix$$}-paragraph-line`
|
12044 | })));
|
12045 | return withNativeProps(props, node);
|
12046 | };
|
12047 | const Skeleton = attachPropertiesToComponent(Skeleton$1, {
|
12048 | Title: SkeletonTitle,
|
12049 | Paragraph: SkeletonParagraph
|
12050 | });
|
12051 | const useFieldNames = (fieldNames = {}) => {
|
12052 | const fields = React$1.useMemo(() => {
|
12053 | const {
|
12054 | label = "label",
|
12055 | value = "value",
|
12056 | disabled = "disabled",
|
12057 | children = "children"
|
12058 | } = fieldNames;
|
12059 | return [label, value, children, disabled];
|
12060 | }, [JSON.stringify(fieldNames)]);
|
12061 | return fields;
|
12062 | };
|
12063 | const classPrefix$_ = `adm-cascader-view`;
|
12064 | const defaultProps$P = {
|
12065 | defaultValue: []
|
12066 | };
|
12067 | const CascaderView$1 = (p) => {
|
12068 | const props = mergeProps(defaultProps$P, p);
|
12069 | const {
|
12070 | locale
|
12071 | } = useConfig();
|
12072 | const [labelName, valueName, childrenName, disabledName] = useFieldNames(props.fieldNames);
|
12073 | const generateValueExtend = useCascaderValueExtend(props.options, {
|
12074 | valueName,
|
12075 | childrenName
|
12076 | });
|
12077 | const [value, setValue2] = usePropsValue(Object.assign(Object.assign({}, props), {
|
12078 | onChange: (val) => {
|
12079 | var _a;
|
12080 | (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, val, generateValueExtend(val));
|
12081 | }
|
12082 | }));
|
12083 | const [tabActiveIndex, setTabActiveIndex] = React$1.useState(0);
|
12084 | const levels = React$1.useMemo(() => {
|
12085 | const ret = [];
|
12086 | let currentOptions = props.options;
|
12087 | let reachedEnd = false;
|
12088 | for (const v of value) {
|
12089 | const target = currentOptions.find((option) => option[valueName] === v);
|
12090 | ret.push({
|
12091 | selected: target,
|
12092 | options: currentOptions
|
12093 | });
|
12094 | if (!target || !target[childrenName]) {
|
12095 | reachedEnd = true;
|
12096 | break;
|
12097 | }
|
12098 | currentOptions = target[childrenName];
|
12099 | }
|
12100 | if (!reachedEnd) {
|
12101 | ret.push({
|
12102 | selected: void 0,
|
12103 | options: currentOptions
|
12104 | });
|
12105 | }
|
12106 | return ret;
|
12107 | }, [value, props.options]);
|
12108 | useUpdateEffect(() => {
|
12109 | var _a;
|
12110 | (_a = props.onTabsChange) === null || _a === void 0 ? void 0 : _a.call(props, tabActiveIndex);
|
12111 | }, [tabActiveIndex]);
|
12112 | React$1.useEffect(() => {
|
12113 | setTabActiveIndex(levels.length - 1);
|
12114 | }, [value]);
|
12115 | React$1.useEffect(() => {
|
12116 | const max2 = levels.length - 1;
|
12117 | if (tabActiveIndex > max2) {
|
12118 | setTabActiveIndex(max2);
|
12119 | }
|
12120 | }, [tabActiveIndex, levels]);
|
12121 | const onItemSelect = (selectValue, depth) => {
|
12122 | const next = value.slice(0, depth);
|
12123 | if (selectValue !== void 0) {
|
12124 | next[depth] = selectValue;
|
12125 | }
|
12126 | setValue2(next);
|
12127 | };
|
12128 | const whetherLoading = (options) => props.loading || options === optionSkeleton;
|
12129 | const placeholder = props.placeholder || locale.Cascader.placeholder;
|
12130 | return withNativeProps(props, React$1.createElement("div", {
|
12131 | className: classPrefix$_
|
12132 | }, React$1.createElement(Tabs, {
|
12133 | activeKey: tabActiveIndex.toString(),
|
12134 | onChange: (key) => {
|
12135 | const activeIndex = parseInt(key);
|
12136 | setTabActiveIndex(activeIndex);
|
12137 | },
|
12138 | stretch: false,
|
12139 | className: `${classPrefix$_}-tabs`
|
12140 | }, levels.map((level, index2) => {
|
12141 | const selected = level.selected;
|
12142 | return React$1.createElement(Tabs.Tab, {
|
12143 | key: index2.toString(),
|
12144 | title: React$1.createElement("div", {
|
12145 | className: `${classPrefix$_}-header-title`
|
12146 | }, selected ? selected[labelName] : typeof placeholder === "function" ? placeholder(index2) : placeholder),
|
12147 | forceRender: true
|
12148 | }, React$1.createElement("div", {
|
12149 | className: `${classPrefix$_}-content`
|
12150 | }, whetherLoading(level.options) ? React$1.createElement("div", {
|
12151 | className: `${classPrefix$_}-skeleton`
|
12152 | }, React$1.createElement(Skeleton, {
|
12153 | className: `${classPrefix$_}-skeleton-line-1`,
|
12154 | animated: true
|
12155 | }), React$1.createElement(Skeleton, {
|
12156 | className: `${classPrefix$_}-skeleton-line-2`,
|
12157 | animated: true
|
12158 | }), React$1.createElement(Skeleton, {
|
12159 | className: `${classPrefix$_}-skeleton-line-3`,
|
12160 | animated: true
|
12161 | }), React$1.createElement(Skeleton, {
|
12162 | className: `${classPrefix$_}-skeleton-line-4`,
|
12163 | animated: true
|
12164 | })) : React$1.createElement(CheckList, {
|
12165 | value: [value[index2]],
|
12166 | onChange: (selectValue) => onItemSelect(selectValue[0], index2),
|
12167 | activeIcon: props.activeIcon
|
12168 | }, level.options.map((option) => {
|
12169 | const active = value[index2] === option[valueName];
|
12170 | return React$1.createElement(CheckList.Item, {
|
12171 | value: option[valueName],
|
12172 | key: option[valueName],
|
12173 | disabled: option[disabledName],
|
12174 | className: classNames(`${classPrefix$_}-item`, {
|
12175 | [`${classPrefix$_}-item-active`]: active
|
12176 | })
|
12177 | }, option[labelName]);
|
12178 | }))));
|
12179 | }))));
|
12180 | };
|
12181 | const CascaderView = attachPropertiesToComponent(CascaderView$1, {
|
12182 | optionSkeleton
|
12183 | });
|
12184 | const classPrefix$Z = `adm-cascader`;
|
12185 | const defaultProps$O = {
|
12186 | defaultValue: [],
|
12187 | destroyOnClose: true,
|
12188 | forceRender: false
|
12189 | };
|
12190 | const Cascader = React$1.forwardRef((p, ref) => {
|
12191 | var _a;
|
12192 | const {
|
12193 | locale
|
12194 | } = useConfig();
|
12195 | const props = mergeProps(defaultProps$O, {
|
12196 | confirmText: locale.common.confirm,
|
12197 | cancelText: locale.common.cancel,
|
12198 | placeholder: locale.Cascader.placeholder
|
12199 | }, p);
|
12200 | const [visible, setVisible] = usePropsValue({
|
12201 | value: props.visible,
|
12202 | defaultValue: false,
|
12203 | onChange: (v) => {
|
12204 | var _a2;
|
12205 | if (v === false) {
|
12206 | (_a2 = props.onClose) === null || _a2 === void 0 ? void 0 : _a2.call(props);
|
12207 | }
|
12208 | }
|
12209 | });
|
12210 | const actions = {
|
12211 | toggle: () => {
|
12212 | setVisible((v) => !v);
|
12213 | },
|
12214 | open: () => {
|
12215 | setVisible(true);
|
12216 | },
|
12217 | close: () => {
|
12218 | setVisible(false);
|
12219 | }
|
12220 | };
|
12221 | React$1.useImperativeHandle(ref, () => actions);
|
12222 | const [value, setValue2] = usePropsValue(Object.assign(Object.assign({}, props), {
|
12223 | onChange: (val) => {
|
12224 | var _a2;
|
12225 | (_a2 = props.onConfirm) === null || _a2 === void 0 ? void 0 : _a2.call(props, val, generateValueExtend(val));
|
12226 | }
|
12227 | }));
|
12228 | const [, valueName, childrenName] = useFieldNames(props.fieldNames);
|
12229 | const generateValueExtend = useCascaderValueExtend(props.options, {
|
12230 | valueName,
|
12231 | childrenName
|
12232 | });
|
12233 | const [innerValue, setInnerValue] = React$1.useState(value);
|
12234 | React$1.useEffect(() => {
|
12235 | if (!visible) {
|
12236 | setInnerValue(value);
|
12237 | }
|
12238 | }, [visible, value]);
|
12239 | const cascaderElement = withNativeProps(props, React$1.createElement("div", {
|
12240 | className: classPrefix$Z
|
12241 | }, React$1.createElement("div", {
|
12242 | className: `${classPrefix$Z}-header`
|
12243 | }, React$1.createElement("a", {
|
12244 | className: `${classPrefix$Z}-header-button`,
|
12245 | onClick: () => {
|
12246 | var _a2;
|
12247 | (_a2 = props.onCancel) === null || _a2 === void 0 ? void 0 : _a2.call(props);
|
12248 | setVisible(false);
|
12249 | }
|
12250 | }, props.cancelText), React$1.createElement("div", {
|
12251 | className: `${classPrefix$Z}-header-title`
|
12252 | }, props.title), React$1.createElement("a", {
|
12253 | className: `${classPrefix$Z}-header-button`,
|
12254 | onClick: () => {
|
12255 | setValue2(innerValue, true);
|
12256 | setVisible(false);
|
12257 | }
|
12258 | }, props.confirmText)), React$1.createElement("div", {
|
12259 | className: `${classPrefix$Z}-body`
|
12260 | }, React$1.createElement(CascaderView, Object.assign({}, props, {
|
12261 | value: innerValue,
|
12262 | onChange: (val, ext) => {
|
12263 | var _a2;
|
12264 | setInnerValue(val);
|
12265 | if (visible) {
|
12266 | (_a2 = props.onSelect) === null || _a2 === void 0 ? void 0 : _a2.call(props, val, ext);
|
12267 | }
|
12268 | }
|
12269 | })))));
|
12270 | const popupElement = React$1.createElement(Popup, {
|
12271 | visible,
|
12272 | position: "bottom",
|
12273 | onMaskClick: () => {
|
12274 | var _a2;
|
12275 | (_a2 = props.onCancel) === null || _a2 === void 0 ? void 0 : _a2.call(props);
|
12276 | setVisible(false);
|
12277 | },
|
12278 | getContainer: props.getContainer,
|
12279 | destroyOnClose: props.destroyOnClose,
|
12280 | forceRender: props.forceRender,
|
12281 | afterShow: props.afterShow,
|
12282 | afterClose: props.afterClose,
|
12283 | onClick: props.onClick,
|
12284 | stopPropagation: props.stopPropagation
|
12285 | }, cascaderElement);
|
12286 | return React$1.createElement(React$1.Fragment, null, popupElement, (_a = props.children) === null || _a === void 0 ? void 0 : _a.call(props, generateValueExtend(value).items, actions));
|
12287 | });
|
12288 | function prompt$1(props) {
|
12289 | return new Promise((resolve) => {
|
12290 | const Wrapper2 = () => {
|
12291 | const [visible, setVisible] = React$1.useState(false);
|
12292 | React$1.useEffect(() => {
|
12293 | setVisible(true);
|
12294 | }, []);
|
12295 | return React$1.createElement(Cascader, Object.assign({}, props, {
|
12296 | visible,
|
12297 | onConfirm: (val, extend) => {
|
12298 | var _a;
|
12299 | (_a = props.onConfirm) === null || _a === void 0 ? void 0 : _a.call(props, val, extend);
|
12300 | resolve(val);
|
12301 | },
|
12302 | onClose: () => {
|
12303 | var _a;
|
12304 | (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
12305 | setVisible(false);
|
12306 | resolve(null);
|
12307 | },
|
12308 | afterClose: () => {
|
12309 | var _a;
|
12310 | (_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
12311 | unmount2();
|
12312 | }
|
12313 | }));
|
12314 | };
|
12315 | const unmount2 = renderToBody(React$1.createElement(Wrapper2, null));
|
12316 | });
|
12317 | }
|
12318 | const index$f = attachPropertiesToComponent(Cascader, {
|
12319 | prompt: prompt$1,
|
12320 | optionSkeleton
|
12321 | });
|
12322 | const classPrefix$Y = "adm-center-popup";
|
12323 | const defaultProps$N = Object.assign(Object.assign({}, defaultPopupBaseProps), {
|
12324 | getContainer: null
|
12325 | });
|
12326 | const CenterPopup = (props) => {
|
12327 | const {
|
12328 | popup: componentConfig = {}
|
12329 | } = useConfig();
|
12330 | const mergedProps = mergeProps(defaultProps$N, componentConfig, props);
|
12331 | const unmountedRef = useUnmountedRef$1();
|
12332 | const style = useSpring({
|
12333 | scale: mergedProps.visible ? 1 : 0.8,
|
12334 | opacity: mergedProps.visible ? 1 : 0,
|
12335 | config: {
|
12336 | mass: 1.2,
|
12337 | tension: 200,
|
12338 | friction: 25,
|
12339 | clamp: true
|
12340 | },
|
12341 | onRest: () => {
|
12342 | var _a, _b;
|
12343 | if (unmountedRef.current)
|
12344 | return;
|
12345 | setActive(mergedProps.visible);
|
12346 | if (mergedProps.visible) {
|
12347 | (_a = mergedProps.afterShow) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
|
12348 | } else {
|
12349 | (_b = mergedProps.afterClose) === null || _b === void 0 ? void 0 : _b.call(mergedProps);
|
12350 | }
|
12351 | }
|
12352 | });
|
12353 | const [active, setActive] = React$1.useState(mergedProps.visible);
|
12354 | useIsomorphicLayoutEffect$2(() => {
|
12355 | if (mergedProps.visible) {
|
12356 | setActive(true);
|
12357 | }
|
12358 | }, [mergedProps.visible]);
|
12359 | const ref = React$1.useRef(null);
|
12360 | useLockScroll(ref, mergedProps.disableBodyScroll && active);
|
12361 | const maskVisible = useInnerVisible(active && mergedProps.visible);
|
12362 | const body = React$1.createElement("div", {
|
12363 | className: classNames(`${classPrefix$Y}-body`, mergedProps.bodyClassName),
|
12364 | style: mergedProps.bodyStyle
|
12365 | }, mergedProps.children);
|
12366 | const node = withStopPropagation(mergedProps.stopPropagation, withNativeProps(mergedProps, React$1.createElement("div", {
|
12367 | className: classPrefix$Y,
|
12368 | style: {
|
12369 | display: active ? void 0 : "none",
|
12370 | pointerEvents: active ? void 0 : "none"
|
12371 | }
|
12372 | }, mergedProps.mask && React$1.createElement(Mask, {
|
12373 | visible: maskVisible,
|
12374 | forceRender: mergedProps.forceRender,
|
12375 | destroyOnClose: mergedProps.destroyOnClose,
|
12376 | onMaskClick: (e2) => {
|
12377 | var _a, _b;
|
12378 | (_a = mergedProps.onMaskClick) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e2);
|
12379 | if (mergedProps.closeOnMaskClick) {
|
12380 | (_b = mergedProps.onClose) === null || _b === void 0 ? void 0 : _b.call(mergedProps);
|
12381 | }
|
12382 | },
|
12383 | style: mergedProps.maskStyle,
|
12384 | className: classNames(`${classPrefix$Y}-mask`, mergedProps.maskClassName),
|
12385 | disableBodyScroll: false,
|
12386 | stopPropagation: mergedProps.stopPropagation
|
12387 | }), React$1.createElement("div", {
|
12388 | className: `${classPrefix$Y}-wrap`,
|
12389 | role: mergedProps.role,
|
12390 | "aria-label": mergedProps["aria-label"]
|
12391 | }, React$1.createElement(animated.div, {
|
12392 | style: Object.assign(Object.assign({}, style), {
|
12393 | pointerEvents: style.opacity.to((v) => v === 1 ? "unset" : "none")
|
12394 | }),
|
12395 | ref
|
12396 | }, mergedProps.showCloseButton && React$1.createElement("a", {
|
12397 | className: classNames(`${classPrefix$Y}-close`, "adm-plain-anchor"),
|
12398 | onClick: () => {
|
12399 | var _a;
|
12400 | (_a = mergedProps.onClose) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
|
12401 | }
|
12402 | }, mergedProps.closeIcon), body)))));
|
12403 | return React$1.createElement(ShouldRender, {
|
12404 | active,
|
12405 | forceRender: mergedProps.forceRender,
|
12406 | destroyOnClose: mergedProps.destroyOnClose
|
12407 | }, renderToContainer(mergedProps.getContainer, node));
|
12408 | };
|
12409 | const CheckboxGroupContext = React$1.createContext(null);
|
12410 | const defaultProps$M = {
|
12411 | disabled: false,
|
12412 | defaultValue: []
|
12413 | };
|
12414 | const Group$1 = (p) => {
|
12415 | const props = mergeProps(defaultProps$M, p);
|
12416 | const [value, setValue2] = usePropsValue(props);
|
12417 | return React$1.createElement(
|
12418 | CheckboxGroupContext.Provider,
|
12419 | {
|
12420 |
|
12421 | value: {
|
12422 | value,
|
12423 | disabled: props.disabled,
|
12424 | check: (v) => {
|
12425 | setValue2([...value, v]);
|
12426 | },
|
12427 | uncheck: (v) => {
|
12428 | setValue2(value.filter((item) => item !== v));
|
12429 | }
|
12430 | }
|
12431 | },
|
12432 | props.children
|
12433 | );
|
12434 | };
|
12435 | const CheckIcon = React$1.memo((props) => {
|
12436 | return withNativeProps(props, React$1.createElement("svg", {
|
12437 | viewBox: "0 0 40 40"
|
12438 | }, React$1.createElement("path", {
|
12439 | d: "M31.5541766,15 L28.0892433,15 L28.0892434,15 C27.971052,15 27.8576674,15.044522 27.7740471,15.1239792 L18.2724722,24.1625319 L13.2248725,19.3630279 L13.2248725,19.3630279 C13.1417074,19.2834412 13.0287551,19.2384807 12.9107898,19.2380079 L9.44474455,19.2380079 L9.44474454,19.2380079 C9.19869815,19.2384085 8.99957935,19.4284738 9,19.66253 C9,19.7747587 9.04719253,19.8823283 9.13066188,19.9616418 L17.0907466,27.5338228 C17.4170809,27.8442545 17.8447695,28 18.2713393,28 L18.2980697,28 C18.7168464,27.993643 19.133396,27.8378975 19.4530492,27.5338228 L31.8693384,15.7236361 L31.8693384,15.7236361 C32.0434167,15.5582251 32.0435739,15.2898919 31.8696892,15.1242941 C31.7860402,15.0446329 31.6725052,15 31.5541421,15 L31.5541766,15 Z",
|
12440 | fill: "currentColor"
|
12441 | })));
|
12442 | });
|
12443 | const IndeterminateIcon = React$1.memo((props) => {
|
12444 | return withNativeProps(props, React$1.createElement("svg", {
|
12445 | viewBox: "0 0 40 40"
|
12446 | }, React$1.createElement("path", {
|
12447 | d: "M20,9 C26.0752953,9 31,13.9247047 31,20 C31,26.0752953 26.0752953,31 20,31 C13.9247047,31 9,26.0752953 9,20 C9,13.9247047 13.9247047,9 20,9 Z",
|
12448 | fill: "currentColor"
|
12449 | })));
|
12450 | });
|
12451 | const NativeInput = (props) => {
|
12452 | const inputRef = React$1.useRef(null);
|
12453 | const handleClick = useMemoizedFn((e2) => {
|
12454 | e2.stopPropagation();
|
12455 | e2.stopImmediatePropagation();
|
12456 | const latestChecked = e2.target.checked;
|
12457 | if (latestChecked === props.checked)
|
12458 | return;
|
12459 | props.onChange(latestChecked);
|
12460 | });
|
12461 | React$1.useEffect(() => {
|
12462 | if (props.disabled)
|
12463 | return;
|
12464 | if (!inputRef.current)
|
12465 | return;
|
12466 | const input = inputRef.current;
|
12467 | input.addEventListener("click", handleClick);
|
12468 | return () => {
|
12469 | input.removeEventListener("click", handleClick);
|
12470 | };
|
12471 | }, [props.disabled, props.onChange]);
|
12472 | return React$1.createElement("input", {
|
12473 | ref: inputRef,
|
12474 | type: props.type,
|
12475 | checked: props.checked,
|
12476 | onChange: () => {
|
12477 | },
|
12478 | disabled: props.disabled,
|
12479 | id: props.id
|
12480 | });
|
12481 | };
|
12482 | const classPrefix$X = `adm-checkbox`;
|
12483 | const defaultProps$L = {
|
12484 | defaultChecked: false,
|
12485 | indeterminate: false
|
12486 | };
|
12487 | const Checkbox$1 = React$1.forwardRef((p, ref) => {
|
12488 | const groupContext = React$1.useContext(CheckboxGroupContext);
|
12489 | const props = mergeProps(defaultProps$L, p);
|
12490 | let [checked, setChecked] = usePropsValue({
|
12491 | value: props.checked,
|
12492 | defaultValue: props.defaultChecked,
|
12493 | onChange: props.onChange
|
12494 | });
|
12495 | let disabled = props.disabled;
|
12496 | const {
|
12497 | value
|
12498 | } = props;
|
12499 | if (groupContext && value !== void 0) {
|
12500 | {
|
12501 | if (p.checked !== void 0) {
|
12502 | devWarning("Checkbox", "When used within `Checkbox.Group`, the `checked` prop of `Checkbox` will not work.");
|
12503 | }
|
12504 | if (p.defaultChecked !== void 0) {
|
12505 | devWarning("Checkbox", "When used within `Checkbox.Group`, the `defaultChecked` prop of `Checkbox` will not work.");
|
12506 | }
|
12507 | }
|
12508 | checked = groupContext.value.includes(value);
|
12509 | setChecked = (checked2) => {
|
12510 | var _a;
|
12511 | if (checked2) {
|
12512 | groupContext.check(value);
|
12513 | } else {
|
12514 | groupContext.uncheck(value);
|
12515 | }
|
12516 | (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, checked2);
|
12517 | };
|
12518 | disabled = disabled || groupContext.disabled;
|
12519 | }
|
12520 | React$1.useImperativeHandle(ref, () => ({
|
12521 | check: () => {
|
12522 | setChecked(true);
|
12523 | },
|
12524 | uncheck: () => {
|
12525 | setChecked(false);
|
12526 | },
|
12527 | toggle: () => {
|
12528 | setChecked(!checked);
|
12529 | }
|
12530 | }));
|
12531 | const renderIcon = () => {
|
12532 | if (props.icon) {
|
12533 | return React$1.createElement("div", {
|
12534 | className: `${classPrefix$X}-custom-icon`
|
12535 | }, props.icon(checked, props.indeterminate));
|
12536 | }
|
12537 | return React$1.createElement("div", {
|
12538 | className: `${classPrefix$X}-icon`
|
12539 | }, props.indeterminate ? React$1.createElement(IndeterminateIcon, null) : checked && React$1.createElement(CheckIcon, null));
|
12540 | };
|
12541 | return withNativeProps(props, React$1.createElement("label", {
|
12542 | onClick: props.onClick,
|
12543 | className: classNames(classPrefix$X, {
|
12544 | [`${classPrefix$X}-checked`]: checked && !props.indeterminate,
|
12545 | [`${classPrefix$X}-indeterminate`]: props.indeterminate,
|
12546 | [`${classPrefix$X}-disabled`]: disabled,
|
12547 | [`${classPrefix$X}-block`]: props.block
|
12548 | })
|
12549 | }, React$1.createElement(NativeInput, {
|
12550 | type: "checkbox",
|
12551 | checked,
|
12552 | onChange: setChecked,
|
12553 | disabled,
|
12554 | id: props.id
|
12555 | }), renderIcon(), props.children && React$1.createElement("div", {
|
12556 | className: `${classPrefix$X}-content`
|
12557 | }, props.children)));
|
12558 | });
|
12559 | const Checkbox = attachPropertiesToComponent(Checkbox$1, {
|
12560 | Group: Group$1
|
12561 | });
|
12562 | const classPrefix$W = `adm-collapse`;
|
12563 | const CollapsePanel = () => {
|
12564 | return null;
|
12565 | };
|
12566 | const CollapsePanelContent = (props) => {
|
12567 | const {
|
12568 | visible
|
12569 | } = props;
|
12570 | const innerRef = React$1.useRef(null);
|
12571 | const shouldRender = useShouldRender(visible, props.forceRender, props.destroyOnClose);
|
12572 | const [{
|
12573 | height
|
12574 | }, api] = useSpring(() => ({
|
12575 | from: {
|
12576 | height: 0
|
12577 | },
|
12578 | config: {
|
12579 | precision: 0.01,
|
12580 | mass: 1,
|
12581 | tension: 200,
|
12582 | friction: 25,
|
12583 | clamp: true
|
12584 | }
|
12585 | }));
|
12586 | useMount$1(() => {
|
12587 | if (!visible)
|
12588 | return;
|
12589 | const inner = innerRef.current;
|
12590 | if (!inner)
|
12591 | return;
|
12592 | api.start({
|
12593 | height: inner.offsetHeight,
|
12594 | immediate: true
|
12595 | });
|
12596 | });
|
12597 | useIsomorphicUpdateLayoutEffect(() => {
|
12598 | const inner = innerRef.current;
|
12599 | if (!inner)
|
12600 | return;
|
12601 | if (visible) {
|
12602 | let lastMotionId = 0;
|
12603 | let cancelObserve = () => {
|
12604 | };
|
12605 | const handleMotion = () => {
|
12606 | lastMotionId += 1;
|
12607 | const motionId = lastMotionId;
|
12608 | api.start({
|
12609 | height: inner.offsetHeight
|
12610 | })[0].then(() => {
|
12611 | if (motionId === lastMotionId) {
|
12612 | cancelObserve();
|
12613 | }
|
12614 | });
|
12615 | };
|
12616 | cancelObserve = observe(inner, {
|
12617 | childList: true,
|
12618 | subtree: true
|
12619 | }, handleMotion);
|
12620 | handleMotion();
|
12621 | return cancelObserve;
|
12622 | } else {
|
12623 | api.start({
|
12624 | height: inner.offsetHeight,
|
12625 | immediate: true
|
12626 | });
|
12627 | api.start({
|
12628 | height: 0
|
12629 | });
|
12630 | }
|
12631 | }, [visible]);
|
12632 | return React$1.createElement(animated.div, {
|
12633 | className: classNames(`${classPrefix$W}-panel-content`, {
|
12634 | [`${classPrefix$W}-panel-content-active`]: visible
|
12635 | }),
|
12636 | style: {
|
12637 | height: height.to((v) => {
|
12638 | if (height.idle && visible) {
|
12639 | return "auto";
|
12640 | } else {
|
12641 | return v;
|
12642 | }
|
12643 | })
|
12644 | }
|
12645 | }, React$1.createElement("div", {
|
12646 | className: `${classPrefix$W}-panel-content-inner`,
|
12647 | ref: innerRef
|
12648 | }, React$1.createElement(List$1.Item, null, shouldRender && props.children)));
|
12649 | };
|
12650 | const Collapse = (props) => {
|
12651 | const {
|
12652 | collapse: componentConfig = {}
|
12653 | } = useConfig();
|
12654 | const mergedProps = mergeProps(componentConfig, props);
|
12655 | const panels = [];
|
12656 | traverseReactNode(mergedProps.children, (child) => {
|
12657 | if (!React$1.isValidElement(child))
|
12658 | return;
|
12659 | const key = child.key;
|
12660 | if (typeof key !== "string")
|
12661 | return;
|
12662 | panels.push(child);
|
12663 | });
|
12664 | const handlePropsValue = () => {
|
12665 | var _a;
|
12666 | if (!mergedProps.accordion) {
|
12667 | return {
|
12668 | value: mergedProps.activeKey,
|
12669 | defaultValue: (_a = mergedProps.defaultActiveKey) !== null && _a !== void 0 ? _a : [],
|
12670 | onChange: mergedProps.onChange
|
12671 | };
|
12672 | }
|
12673 | const initValue = {
|
12674 | value: [],
|
12675 | defaultValue: [],
|
12676 | onChange: (v) => {
|
12677 | var _a2, _b;
|
12678 | (_a2 = mergedProps.onChange) === null || _a2 === void 0 ? void 0 : _a2.call(mergedProps, (_b = v[0]) !== null && _b !== void 0 ? _b : null);
|
12679 | }
|
12680 | };
|
12681 | if (mergedProps.activeKey === void 0) {
|
12682 | initValue.value = void 0;
|
12683 | } else if (mergedProps.activeKey !== null) {
|
12684 | initValue.value = [mergedProps.activeKey];
|
12685 | }
|
12686 | if (![null, void 0].includes(mergedProps.defaultActiveKey)) {
|
12687 | initValue.defaultValue = [mergedProps.defaultActiveKey];
|
12688 | }
|
12689 | return initValue;
|
12690 | };
|
12691 | const [activeKey, setActiveKey] = usePropsValue(handlePropsValue());
|
12692 | const activeKeyList = activeKey === null ? [] : Array.isArray(activeKey) ? activeKey : [activeKey];
|
12693 | return withNativeProps(mergedProps, React$1.createElement("div", {
|
12694 | className: classPrefix$W
|
12695 | }, React$1.createElement(List$1, null, panels.map((panel) => {
|
12696 | const key = panel.key;
|
12697 | const active = activeKeyList.includes(key);
|
12698 | function handleClick(event) {
|
12699 | var _a, _b;
|
12700 | if (mergedProps.accordion) {
|
12701 | if (active) {
|
12702 | setActiveKey([]);
|
12703 | } else {
|
12704 | setActiveKey([key]);
|
12705 | }
|
12706 | } else {
|
12707 | if (active) {
|
12708 | setActiveKey(activeKeyList.filter((v) => v !== key));
|
12709 | } else {
|
12710 | setActiveKey([...activeKeyList, key]);
|
12711 | }
|
12712 | }
|
12713 | (_b = (_a = panel.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
12714 | }
|
12715 | const arrow2 = mergeProp(React$1.createElement(DownOutline, null), mergedProps.arrow, mergedProps.arrowIcon, panel.props.arrow, panel.props.arrowIcon);
|
12716 | const arrowIcon = typeof arrow2 === "function" ? arrow2(active) : React$1.createElement("div", {
|
12717 | className: classNames(`${classPrefix$W}-arrow`, {
|
12718 | [`${classPrefix$W}-arrow-active`]: active
|
12719 | })
|
12720 | }, arrow2);
|
12721 | return React$1.createElement(React$1.Fragment, {
|
12722 | key
|
12723 | }, withNativeProps(panel.props, React$1.createElement(List$1.Item, {
|
12724 | className: `${classPrefix$W}-panel-header`,
|
12725 | onClick: handleClick,
|
12726 | disabled: panel.props.disabled,
|
12727 | arrowIcon
|
12728 | }, panel.props.title)), React$1.createElement(CollapsePanelContent, {
|
12729 | visible: active,
|
12730 | forceRender: !!panel.props.forceRender,
|
12731 | destroyOnClose: !!panel.props.destroyOnClose
|
12732 | }, panel.props.children));
|
12733 | }))));
|
12734 | };
|
12735 | const index$e = attachPropertiesToComponent(Collapse, {
|
12736 | Panel: CollapsePanel
|
12737 | });
|
12738 | var isoWeeksInYear$1 = { exports: {} };
|
12739 | (function(module2, exports3) {
|
12740 | !function(e2, n2) {
|
12741 | module2.exports = n2();
|
12742 | }(commonjsGlobal, function() {
|
12743 | return function(e2, n2) {
|
12744 | n2.prototype.isoWeeksInYear = function() {
|
12745 | var e3 = this.isLeapYear(), n3 = this.endOf("y").day();
|
12746 | return 4 === n3 || e3 && 5 === n3 ? 53 : 52;
|
12747 | };
|
12748 | };
|
12749 | });
|
12750 | })(isoWeeksInYear$1);
|
12751 | var isoWeeksInYearExports = isoWeeksInYear$1.exports;
|
12752 | const isoWeeksInYear = getDefaultExportFromCjs(isoWeeksInYearExports);
|
12753 | var isLeapYear$1 = { exports: {} };
|
12754 | (function(module2, exports3) {
|
12755 | !function(e2, t) {
|
12756 | module2.exports = t();
|
12757 | }(commonjsGlobal, function() {
|
12758 | return function(e2, t) {
|
12759 | t.prototype.isLeapYear = function() {
|
12760 | return this.$y % 4 == 0 && this.$y % 100 != 0 || this.$y % 400 == 0;
|
12761 | };
|
12762 | };
|
12763 | });
|
12764 | })(isLeapYear$1);
|
12765 | var isLeapYearExports = isLeapYear$1.exports;
|
12766 | const isLeapYear = getDefaultExportFromCjs(isLeapYearExports);
|
12767 | const TILL_NOW = "TILL_NOW";
|
12768 | dayjs.extend(isoWeek);
|
12769 | dayjs.extend(isoWeeksInYear);
|
12770 | dayjs.extend(isLeapYear);
|
12771 | const precisionRankRecord$1 = {
|
12772 | year: 0,
|
12773 | month: 1,
|
12774 | day: 2,
|
12775 | hour: 3,
|
12776 | minute: 4,
|
12777 | second: 5
|
12778 | };
|
12779 | function generateDatePickerColumns$2(selected, min2, max2, precision, renderLabel, filter, tillNow) {
|
12780 | const ret = [];
|
12781 | const minYear = min2.getFullYear();
|
12782 | const minMonth = min2.getMonth() + 1;
|
12783 | const minDay = min2.getDate();
|
12784 | const minHour = min2.getHours();
|
12785 | const minMinute = min2.getMinutes();
|
12786 | const minSecond = min2.getSeconds();
|
12787 | const maxYear = max2.getFullYear();
|
12788 | const maxMonth = max2.getMonth() + 1;
|
12789 | const maxDay = max2.getDate();
|
12790 | const maxHour = max2.getHours();
|
12791 | const maxMinute = max2.getMinutes();
|
12792 | const maxSecond = max2.getSeconds();
|
12793 | const rank = precisionRankRecord$1[precision];
|
12794 | const selectedYear = parseInt(selected[0]);
|
12795 | const firstDayInSelectedMonth = dayjs(convertStringArrayToDate$2([selected[0], selected[1], "1"]));
|
12796 | const selectedMonth = parseInt(selected[1]);
|
12797 | const selectedDay = parseInt(selected[2]);
|
12798 | const selectedHour = parseInt(selected[3]);
|
12799 | const selectedMinute = parseInt(selected[4]);
|
12800 | const isInMinYear = selectedYear === minYear;
|
12801 | const isInMaxYear = selectedYear === maxYear;
|
12802 | const isInMinMonth = isInMinYear && selectedMonth === minMonth;
|
12803 | const isInMaxMonth = isInMaxYear && selectedMonth === maxMonth;
|
12804 | const isInMinDay = isInMinMonth && selectedDay === minDay;
|
12805 | const isInMaxDay = isInMaxMonth && selectedDay === maxDay;
|
12806 | const isInMinHour = isInMinDay && selectedHour === minHour;
|
12807 | const isInMaxHour = isInMaxDay && selectedHour === maxHour;
|
12808 | const isInMinMinute = isInMinHour && selectedMinute === minMinute;
|
12809 | const isInMaxMinute = isInMaxHour && selectedMinute === maxMinute;
|
12810 | const generateColumn = (from, to2, precision2) => {
|
12811 | let column = [];
|
12812 | for (let i2 = from; i2 <= to2; i2++) {
|
12813 | column.push(i2);
|
12814 | }
|
12815 | const prefix2 = selected.slice(0, precisionRankRecord$1[precision2]);
|
12816 | const currentFilter = filter === null || filter === void 0 ? void 0 : filter[precision2];
|
12817 | if (currentFilter && typeof currentFilter === "function") {
|
12818 | column = column.filter((i2) => currentFilter(i2, {
|
12819 | get date() {
|
12820 | const stringArray = [...prefix2, i2.toString()];
|
12821 | return convertStringArrayToDate$2(stringArray);
|
12822 | }
|
12823 | }));
|
12824 | }
|
12825 | return column;
|
12826 | };
|
12827 | if (rank >= precisionRankRecord$1.year) {
|
12828 | const lower = minYear;
|
12829 | const upper = maxYear;
|
12830 | const years = generateColumn(lower, upper, "year");
|
12831 | ret.push(years.map((v) => ({
|
12832 | label: renderLabel("year", v),
|
12833 | value: v.toString()
|
12834 | })));
|
12835 | }
|
12836 | if (rank >= precisionRankRecord$1.month) {
|
12837 | const lower = isInMinYear ? minMonth : 1;
|
12838 | const upper = isInMaxYear ? maxMonth : 12;
|
12839 | const months = generateColumn(lower, upper, "month");
|
12840 | ret.push(months.map((v) => ({
|
12841 | label: renderLabel("month", v),
|
12842 | value: v.toString()
|
12843 | })));
|
12844 | }
|
12845 | if (rank >= precisionRankRecord$1.day) {
|
12846 | const lower = isInMinMonth ? minDay : 1;
|
12847 | const upper = isInMaxMonth ? maxDay : firstDayInSelectedMonth.daysInMonth();
|
12848 | const days = generateColumn(lower, upper, "day");
|
12849 | ret.push(days.map((v) => ({
|
12850 | label: renderLabel("day", v),
|
12851 | value: v.toString()
|
12852 | })));
|
12853 | }
|
12854 | if (rank >= precisionRankRecord$1.hour) {
|
12855 | const lower = isInMinDay ? minHour : 0;
|
12856 | const upper = isInMaxDay ? maxHour : 23;
|
12857 | const hours = generateColumn(lower, upper, "hour");
|
12858 | ret.push(hours.map((v) => ({
|
12859 | label: renderLabel("hour", v),
|
12860 | value: v.toString()
|
12861 | })));
|
12862 | }
|
12863 | if (rank >= precisionRankRecord$1.minute) {
|
12864 | const lower = isInMinHour ? minMinute : 0;
|
12865 | const upper = isInMaxHour ? maxMinute : 59;
|
12866 | const minutes = generateColumn(lower, upper, "minute");
|
12867 | ret.push(minutes.map((v) => ({
|
12868 | label: renderLabel("minute", v),
|
12869 | value: v.toString()
|
12870 | })));
|
12871 | }
|
12872 | if (rank >= precisionRankRecord$1.second) {
|
12873 | const lower = isInMinMinute ? minSecond : 0;
|
12874 | const upper = isInMaxMinute ? maxSecond : 59;
|
12875 | const seconds = generateColumn(lower, upper, "second");
|
12876 | ret.push(seconds.map((v) => ({
|
12877 | label: renderLabel("second", v),
|
12878 | value: v.toString()
|
12879 | })));
|
12880 | }
|
12881 | if (tillNow) {
|
12882 | ret[0].push({
|
12883 | label: renderLabel("now", null),
|
12884 | value: TILL_NOW
|
12885 | });
|
12886 | if (TILL_NOW === (selected === null || selected === void 0 ? void 0 : selected[0])) {
|
12887 | for (let i2 = 1; i2 < ret.length; i2 += 1) {
|
12888 | ret[i2] = [];
|
12889 | }
|
12890 | }
|
12891 | }
|
12892 | return ret;
|
12893 | }
|
12894 | function convertDateToStringArray$2(date) {
|
12895 | if (!date)
|
12896 | return [];
|
12897 | return [date.getFullYear().toString(), (date.getMonth() + 1).toString(), date.getDate().toString(), date.getHours().toString(), date.getMinutes().toString(), date.getSeconds().toString()];
|
12898 | }
|
12899 | function convertStringArrayToDate$2(value) {
|
12900 | var _a, _b, _c, _d, _e, _f;
|
12901 | const yearString = (_a = value[0]) !== null && _a !== void 0 ? _a : "1900";
|
12902 | const monthString = (_b = value[1]) !== null && _b !== void 0 ? _b : "1";
|
12903 | const dateString = (_c = value[2]) !== null && _c !== void 0 ? _c : "1";
|
12904 | const hourString = (_d = value[3]) !== null && _d !== void 0 ? _d : "0";
|
12905 | const minuteString = (_e = value[4]) !== null && _e !== void 0 ? _e : "0";
|
12906 | const secondString = (_f = value[5]) !== null && _f !== void 0 ? _f : "0";
|
12907 | return new Date(parseInt(yearString), parseInt(monthString) - 1, parseInt(dateString), parseInt(hourString), parseInt(minuteString), parseInt(secondString));
|
12908 | }
|
12909 | dayjs.extend(isoWeek);
|
12910 | dayjs.extend(isoWeeksInYear);
|
12911 | dayjs.extend(isLeapYear);
|
12912 | const precisionRankRecord = {
|
12913 | year: 0,
|
12914 | week: 1,
|
12915 | "week-day": 2
|
12916 | };
|
12917 | function generateDatePickerColumns$1(selected, min2, max2, precision, renderLabel, filter) {
|
12918 | const ret = [];
|
12919 | const minYear = min2.getFullYear();
|
12920 | const maxYear = max2.getFullYear();
|
12921 | const rank = precisionRankRecord[precision];
|
12922 | const selectedYear = parseInt(selected[0]);
|
12923 | const isInMinYear = selectedYear === minYear;
|
12924 | const isInMaxYear = selectedYear === maxYear;
|
12925 | const minDay = dayjs(min2);
|
12926 | const maxDay = dayjs(max2);
|
12927 | const minWeek = minDay.isoWeek();
|
12928 | const maxWeek = maxDay.isoWeek();
|
12929 | const minWeekday = minDay.isoWeekday();
|
12930 | const maxWeekday = maxDay.isoWeekday();
|
12931 | const selectedWeek = parseInt(selected[1]);
|
12932 | const isInMinWeek = isInMinYear && selectedWeek === minWeek;
|
12933 | const isInMaxWeek = isInMaxYear && selectedWeek === maxWeek;
|
12934 | const selectedYearWeeks = dayjs(`${selectedYear}-01-01`).isoWeeksInYear();
|
12935 | const generateColumn = (from, to2, precision2) => {
|
12936 | let column = [];
|
12937 | for (let i2 = from; i2 <= to2; i2++) {
|
12938 | column.push(i2);
|
12939 | }
|
12940 | const prefix2 = selected.slice(0, precisionRankRecord[precision2]);
|
12941 | const currentFilter = filter === null || filter === void 0 ? void 0 : filter[precision2];
|
12942 | if (currentFilter && typeof currentFilter === "function") {
|
12943 | column = column.filter((i2) => currentFilter(i2, {
|
12944 | get date() {
|
12945 | const stringArray = [...prefix2, i2.toString()];
|
12946 | return convertStringArrayToDate$1(stringArray);
|
12947 | }
|
12948 | }));
|
12949 | }
|
12950 | return column;
|
12951 | };
|
12952 | if (rank >= precisionRankRecord.year) {
|
12953 | const lower = minYear;
|
12954 | const upper = maxYear;
|
12955 | const years = generateColumn(lower, upper, "year");
|
12956 | ret.push(years.map((v) => ({
|
12957 | label: renderLabel("year", v),
|
12958 | value: v.toString()
|
12959 | })));
|
12960 | }
|
12961 | if (rank >= precisionRankRecord.week) {
|
12962 | const lower = isInMinYear ? minWeek : 1;
|
12963 | const upper = isInMaxYear ? maxWeek : selectedYearWeeks;
|
12964 | const weeks = generateColumn(lower, upper, "week");
|
12965 | ret.push(weeks.map((v) => ({
|
12966 | label: renderLabel("week", v),
|
12967 | value: v.toString()
|
12968 | })));
|
12969 | }
|
12970 | if (rank >= precisionRankRecord["week-day"]) {
|
12971 | const lower = isInMinWeek ? minWeekday : 1;
|
12972 | const upper = isInMaxWeek ? maxWeekday : 7;
|
12973 | const weeks = generateColumn(lower, upper, "week-day");
|
12974 | ret.push(weeks.map((v) => ({
|
12975 | label: renderLabel("week-day", v),
|
12976 | value: v.toString()
|
12977 | })));
|
12978 | }
|
12979 | return ret;
|
12980 | }
|
12981 | function convertDateToStringArray$1(date) {
|
12982 | if (!date)
|
12983 | return [];
|
12984 | const day = dayjs(date);
|
12985 | return [day.isoWeekYear().toString(), day.isoWeek().toString(), day.isoWeekday().toString()];
|
12986 | }
|
12987 | function convertStringArrayToDate$1(value) {
|
12988 | var _a, _b, _c;
|
12989 | const yearString = (_a = value[0]) !== null && _a !== void 0 ? _a : "1900";
|
12990 | const weekString = (_b = value[1]) !== null && _b !== void 0 ? _b : "1";
|
12991 | const weekdayString = (_c = value[2]) !== null && _c !== void 0 ? _c : "1";
|
12992 | const day = dayjs().year(parseInt(yearString)).isoWeek(parseInt(weekString)).isoWeekday(parseInt(weekdayString)).hour(0).minute(0).second(0);
|
12993 | return day.toDate();
|
12994 | }
|
12995 | const precisionLengthRecord = {
|
12996 | year: 1,
|
12997 | month: 2,
|
12998 | day: 3,
|
12999 | hour: 4,
|
13000 | minute: 5,
|
13001 | second: 6
|
13002 | };
|
13003 | const convertDateToStringArray = (date, precision) => {
|
13004 | if (precision.includes("week")) {
|
13005 | return convertDateToStringArray$1(date);
|
13006 | } else {
|
13007 | const datePrecision = precision;
|
13008 | const stringArray = convertDateToStringArray$2(date);
|
13009 | return stringArray.slice(0, precisionLengthRecord[datePrecision]);
|
13010 | }
|
13011 | };
|
13012 | const convertStringArrayToDate = (value, precision) => {
|
13013 | if ((value === null || value === void 0 ? void 0 : value[0]) === TILL_NOW) {
|
13014 | const now2 = new Date();
|
13015 | now2.tillNow = true;
|
13016 | return now2;
|
13017 | }
|
13018 | if (precision.includes("week")) {
|
13019 | return convertStringArrayToDate$1(value);
|
13020 | } else {
|
13021 | return convertStringArrayToDate$2(value);
|
13022 | }
|
13023 | };
|
13024 | const generateDatePickerColumns = (selected, min2, max2, precision, renderLabel, filter, tillNow) => {
|
13025 | if (precision.startsWith("week")) {
|
13026 | return generateDatePickerColumns$1(selected, min2, max2, precision, renderLabel, filter);
|
13027 | } else {
|
13028 | return generateDatePickerColumns$2(selected, min2, max2, precision, renderLabel, filter, tillNow);
|
13029 | }
|
13030 | };
|
13031 | function useRenderLabel(renderLabel) {
|
13032 | const {
|
13033 | locale
|
13034 | } = useConfig();
|
13035 | return React$1.useCallback((type, data) => {
|
13036 | if (renderLabel) {
|
13037 | return renderLabel(type, data);
|
13038 | }
|
13039 | switch (type) {
|
13040 | case "minute":
|
13041 | case "second":
|
13042 | case "hour":
|
13043 | return ("0" + data.toString()).slice(-2);
|
13044 | case "now":
|
13045 | return locale.DatePicker.tillNow;
|
13046 | default:
|
13047 | return data.toString();
|
13048 | }
|
13049 | }, [renderLabel]);
|
13050 | }
|
13051 | const thisYear$1 = ( new Date()).getFullYear();
|
13052 | const defaultProps$K = {
|
13053 | min: new Date(( new Date()).setFullYear(thisYear$1 - 10)),
|
13054 | max: new Date(( new Date()).setFullYear(thisYear$1 + 10)),
|
13055 | precision: "day",
|
13056 | defaultValue: null
|
13057 | };
|
13058 | const DatePicker = React$1.forwardRef((p, ref) => {
|
13059 | const props = mergeProps(defaultProps$K, p);
|
13060 | const {
|
13061 | renderLabel
|
13062 | } = props;
|
13063 | const [value, setValue2] = usePropsValue({
|
13064 | value: props.value,
|
13065 | defaultValue: props.defaultValue,
|
13066 | onChange: (v) => {
|
13067 | var _a;
|
13068 | if (v === null)
|
13069 | return;
|
13070 | (_a = props.onConfirm) === null || _a === void 0 ? void 0 : _a.call(props, v);
|
13071 | }
|
13072 | });
|
13073 | const now2 = React$1.useMemo(() => new Date(), []);
|
13074 | const mergedRenderLabel = useRenderLabel(renderLabel);
|
13075 | const pickerValue = React$1.useMemo(() => {
|
13076 | let date = value !== null && value !== void 0 ? value : now2;
|
13077 | if (date.tillNow) {
|
13078 | return [TILL_NOW];
|
13079 | }
|
13080 | date = new Date(bound(date.getTime(), props.min.getTime(), props.max.getTime()));
|
13081 | return convertDateToStringArray(date, props.precision);
|
13082 | }, [value, props.precision, props.min, props.max]);
|
13083 | const onConfirm = React$1.useCallback((val) => {
|
13084 | const date = convertStringArrayToDate(val, props.precision);
|
13085 | setValue2(date, true);
|
13086 | }, [setValue2, props.precision]);
|
13087 | const onSelect = useMemoizedFn((val) => {
|
13088 | var _a;
|
13089 | const date = convertStringArrayToDate(val, props.precision);
|
13090 | (_a = props.onSelect) === null || _a === void 0 ? void 0 : _a.call(props, date);
|
13091 | });
|
13092 | const columns = React$1.useCallback((selected) => generateDatePickerColumns(selected, props.min, props.max, props.precision, mergedRenderLabel, props.filter, props.tillNow), [props.min, props.max, props.precision, mergedRenderLabel, props.tillNow]);
|
13093 | return withNativeProps(props, React$1.createElement(Picker, {
|
13094 | ref,
|
13095 | columns,
|
13096 | value: pickerValue,
|
13097 | onCancel: props.onCancel,
|
13098 | onClose: props.onClose,
|
13099 | closeOnMaskClick: props.closeOnMaskClick,
|
13100 | visible: props.visible,
|
13101 | confirmText: props.confirmText,
|
13102 | cancelText: props.cancelText,
|
13103 | onConfirm,
|
13104 | onSelect,
|
13105 | getContainer: props.getContainer,
|
13106 | loading: props.loading,
|
13107 | loadingContent: props.loadingContent,
|
13108 | afterShow: props.afterShow,
|
13109 | afterClose: props.afterClose,
|
13110 | onClick: props.onClick,
|
13111 | title: props.title,
|
13112 | stopPropagation: props.stopPropagation,
|
13113 | mouseWheel: props.mouseWheel,
|
13114 | destroyOnClose: props.destroyOnClose,
|
13115 | forceRender: props.forceRender
|
13116 | }, (_, actions) => {
|
13117 | var _a;
|
13118 | return (_a = props.children) === null || _a === void 0 ? void 0 : _a.call(props, value, actions);
|
13119 | }));
|
13120 | });
|
13121 | function prompt(props) {
|
13122 | return new Promise((resolve) => {
|
13123 | const Wrapper2 = () => {
|
13124 | const [visible, setVisible] = React$1.useState(false);
|
13125 | React$1.useEffect(() => {
|
13126 | setVisible(true);
|
13127 | }, []);
|
13128 | return React$1.createElement(DatePicker, Object.assign({}, props, {
|
13129 | visible,
|
13130 | onConfirm: (val) => {
|
13131 | var _a;
|
13132 | (_a = props.onConfirm) === null || _a === void 0 ? void 0 : _a.call(props, val);
|
13133 | resolve(val);
|
13134 | },
|
13135 | onClose: () => {
|
13136 | var _a;
|
13137 | (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
13138 | setVisible(false);
|
13139 | resolve(null);
|
13140 | },
|
13141 | afterClose: () => {
|
13142 | var _a;
|
13143 | (_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
13144 | unmount2();
|
13145 | }
|
13146 | }));
|
13147 | };
|
13148 | const unmount2 = renderToBody(React$1.createElement(Wrapper2, null));
|
13149 | });
|
13150 | }
|
13151 | const index$d = attachPropertiesToComponent(DatePicker, {
|
13152 | prompt,
|
13153 | DATE_NOW: TILL_NOW
|
13154 | });
|
13155 | const thisYear = ( new Date()).getFullYear();
|
13156 | const defaultProps$J = {
|
13157 | min: new Date(( new Date()).setFullYear(thisYear - 10)),
|
13158 | max: new Date(( new Date()).setFullYear(thisYear + 10)),
|
13159 | precision: "day"
|
13160 | };
|
13161 | const DatePickerView = (p) => {
|
13162 | var _a;
|
13163 | const props = mergeProps(defaultProps$J, p);
|
13164 | const {
|
13165 | renderLabel
|
13166 | } = props;
|
13167 | const [value, setValue2] = usePropsValue({
|
13168 | value: props.value,
|
13169 | defaultValue: (_a = props.defaultValue) !== null && _a !== void 0 ? _a : null
|
13170 | });
|
13171 | const mergedRenderLabel = useRenderLabel(renderLabel);
|
13172 | const pickerValue = React$1.useMemo(() => {
|
13173 | if (value === null || value === void 0 ? void 0 : value.tillNow) {
|
13174 | return [TILL_NOW, null, null];
|
13175 | }
|
13176 | return convertDateToStringArray(value, props.precision);
|
13177 | }, [value, props.precision]);
|
13178 | const onChange = React$1.useCallback((val) => {
|
13179 | var _a2;
|
13180 | const date = convertStringArrayToDate(val, props.precision);
|
13181 | if (date) {
|
13182 | setValue2(date);
|
13183 | (_a2 = props.onChange) === null || _a2 === void 0 ? void 0 : _a2.call(props, date);
|
13184 | }
|
13185 | }, [props.onChange, props.precision]);
|
13186 | return withNativeProps(props, React$1.createElement(PickerView, {
|
13187 | columns: (selected) => generateDatePickerColumns(selected, props.min, props.max, props.precision, mergedRenderLabel, props.filter, props.tillNow),
|
13188 | loading: props.loading,
|
13189 | loadingContent: props.loadingContent,
|
13190 | value: pickerValue,
|
13191 | mouseWheel: props.mouseWheel,
|
13192 | onChange
|
13193 | }));
|
13194 | };
|
13195 | const DialogActionButton = (props) => {
|
13196 | const {
|
13197 | action
|
13198 | } = props;
|
13199 | return withNativeProps(props.action, React$1.createElement(Button, {
|
13200 | key: action.key,
|
13201 | onClick: props.onAction,
|
13202 | className: classNames("adm-dialog-button", {
|
13203 | "adm-dialog-button-bold": action.bold
|
13204 | }),
|
13205 | fill: "none",
|
13206 | shape: "rectangular",
|
13207 | block: true,
|
13208 | color: action.danger ? "danger" : "primary",
|
13209 | loading: "auto",
|
13210 | disabled: action.disabled
|
13211 | }, action.text));
|
13212 | };
|
13213 | const defaultProps$I = {
|
13214 | actions: [],
|
13215 | closeOnAction: false,
|
13216 | closeOnMaskClick: false,
|
13217 | getContainer: null
|
13218 | };
|
13219 | const Dialog = (p) => {
|
13220 | const props = mergeProps(defaultProps$I, p);
|
13221 | const element = React$1.createElement(React$1.Fragment, null, !!props.image && React$1.createElement("div", {
|
13222 | className: cls$1("image-container")
|
13223 | }, React$1.createElement(Image$1, {
|
13224 | src: props.image,
|
13225 | alt: "dialog header image",
|
13226 | width: "100%"
|
13227 | })), !!props.header && React$1.createElement("div", {
|
13228 | className: cls$1("header")
|
13229 | }, React$1.createElement(AutoCenter, null, props.header)), !!props.title && React$1.createElement("div", {
|
13230 | className: cls$1("title")
|
13231 | }, props.title), React$1.createElement("div", {
|
13232 | className: classNames(cls$1("content"), !props.content && cls$1("content-empty"))
|
13233 | }, typeof props.content === "string" ? React$1.createElement(AutoCenter, null, props.content) : props.content), React$1.createElement("div", {
|
13234 | className: cls$1("footer")
|
13235 | }, props.actions.map((row, index2) => {
|
13236 | const actions = Array.isArray(row) ? row : [row];
|
13237 | return React$1.createElement("div", {
|
13238 | className: cls$1("action-row"),
|
13239 | key: index2
|
13240 | }, actions.map((action, index3) => React$1.createElement(DialogActionButton, {
|
13241 | key: action.key,
|
13242 | action,
|
13243 | onAction: () => __awaiter(void 0, void 0, void 0, function* () {
|
13244 | var _a, _b, _c;
|
13245 | yield Promise.all([(_a = action.onClick) === null || _a === void 0 ? void 0 : _a.call(action), (_b = props.onAction) === null || _b === void 0 ? void 0 : _b.call(props, action, index3)]);
|
13246 | if (props.closeOnAction) {
|
13247 | (_c = props.onClose) === null || _c === void 0 ? void 0 : _c.call(props);
|
13248 | }
|
13249 | })
|
13250 | })));
|
13251 | })));
|
13252 | return React$1.createElement(CenterPopup, {
|
13253 | className: classNames(cls$1(), props.className),
|
13254 | style: props.style,
|
13255 | afterClose: props.afterClose,
|
13256 | afterShow: props.afterShow,
|
13257 | onMaskClick: props.closeOnMaskClick ? () => {
|
13258 | var _a;
|
13259 | (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
13260 | } : void 0,
|
13261 | visible: props.visible,
|
13262 | getContainer: props.getContainer,
|
13263 | bodyStyle: props.bodyStyle,
|
13264 | bodyClassName: classNames(cls$1("body"), props.image && cls$1("with-image"), props.bodyClassName),
|
13265 | maskStyle: props.maskStyle,
|
13266 | maskClassName: props.maskClassName,
|
13267 | stopPropagation: props.stopPropagation,
|
13268 | disableBodyScroll: props.disableBodyScroll,
|
13269 | destroyOnClose: props.destroyOnClose,
|
13270 | forceRender: props.forceRender,
|
13271 | role: "dialog",
|
13272 | "aria-label": props["aria-label"]
|
13273 | }, element);
|
13274 | };
|
13275 | function cls$1(name = "") {
|
13276 | return "adm-dialog" + (name && "-") + name;
|
13277 | }
|
13278 | const closeFnSet$1 = new Set();
|
13279 | function show$2(props) {
|
13280 | const handler = renderImperatively(React$1.createElement(Dialog, Object.assign({}, props, {
|
13281 | afterClose: () => {
|
13282 | var _a;
|
13283 | closeFnSet$1.delete(handler.close);
|
13284 | (_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
13285 | }
|
13286 | })));
|
13287 | closeFnSet$1.add(handler.close);
|
13288 | return handler;
|
13289 | }
|
13290 | function alert$1(p) {
|
13291 | const defaultProps2 = {
|
13292 | confirmText: getDefaultConfig().locale.Dialog.ok
|
13293 | };
|
13294 | const props = mergeProps(defaultProps2, p);
|
13295 | return new Promise((resolve) => {
|
13296 | show$2(Object.assign(Object.assign({}, props), {
|
13297 | closeOnAction: true,
|
13298 | actions: [{
|
13299 | key: "confirm",
|
13300 | text: props.confirmText
|
13301 | }],
|
13302 | onAction: props.onConfirm,
|
13303 | onClose: () => {
|
13304 | var _a;
|
13305 | (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
13306 | resolve();
|
13307 | }
|
13308 | }));
|
13309 | });
|
13310 | }
|
13311 | const defaultProps$H = {
|
13312 | confirmText: "确认",
|
13313 | cancelText: "取消"
|
13314 | };
|
13315 | function confirm$1(p) {
|
13316 | const {
|
13317 | locale
|
13318 | } = getDefaultConfig();
|
13319 | const props = mergeProps(defaultProps$H, {
|
13320 | confirmText: locale.common.confirm,
|
13321 | cancelText: locale.common.cancel
|
13322 | }, p);
|
13323 | return new Promise((resolve) => {
|
13324 | show$2(Object.assign(Object.assign({}, props), {
|
13325 | closeOnAction: true,
|
13326 | onClose: () => {
|
13327 | var _a;
|
13328 | (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
13329 | resolve(false);
|
13330 | },
|
13331 | actions: [[{
|
13332 | key: "cancel",
|
13333 | text: props.cancelText,
|
13334 | onClick: () => __awaiter(this, void 0, void 0, function* () {
|
13335 | var _a;
|
13336 | yield (_a = props.onCancel) === null || _a === void 0 ? void 0 : _a.call(props);
|
13337 | resolve(false);
|
13338 | })
|
13339 | }, {
|
13340 | key: "confirm",
|
13341 | text: props.confirmText,
|
13342 | bold: true,
|
13343 | onClick: () => __awaiter(this, void 0, void 0, function* () {
|
13344 | var _b;
|
13345 | yield (_b = props.onConfirm) === null || _b === void 0 ? void 0 : _b.call(props);
|
13346 | resolve(true);
|
13347 | })
|
13348 | }]]
|
13349 | }));
|
13350 | });
|
13351 | }
|
13352 | function clear$2() {
|
13353 | closeFnSet$1.forEach((close) => {
|
13354 | close();
|
13355 | });
|
13356 | }
|
13357 | const index$c = attachPropertiesToComponent(Dialog, {
|
13358 | show: show$2,
|
13359 | alert: alert$1,
|
13360 | confirm: confirm$1,
|
13361 | clear: clear$2
|
13362 | });
|
13363 | const IconContext = React$1.createContext(null);
|
13364 | const classPrefix$V = `adm-dropdown-item`;
|
13365 | const Item = (props) => {
|
13366 | const {
|
13367 | dropdown: componentConfig = {}
|
13368 | } = useConfig();
|
13369 | const mergedProps = mergeProps(componentConfig, props);
|
13370 | const {
|
13371 | active,
|
13372 | highlight,
|
13373 | onClick,
|
13374 | title
|
13375 | } = mergedProps;
|
13376 | const cls2 = classNames(classPrefix$V, {
|
13377 | [`${classPrefix$V}-active`]: active,
|
13378 | [`${classPrefix$V}-highlight`]: highlight !== null && highlight !== void 0 ? highlight : active
|
13379 | });
|
13380 | const contextArrowIcon = React$1.useContext(IconContext);
|
13381 | const mergedArrowIcon = mergeProp(React$1.createElement(DownFill, null), contextArrowIcon, mergedProps.arrow, mergedProps.arrowIcon);
|
13382 | return withNativeProps(props, React$1.createElement("div", {
|
13383 | className: cls2,
|
13384 | onClick
|
13385 | }, React$1.createElement("div", {
|
13386 | className: `${classPrefix$V}-title`
|
13387 | }, React$1.createElement("span", {
|
13388 | className: `${classPrefix$V}-title-text`
|
13389 | }, title), React$1.createElement("span", {
|
13390 | className: classNames(`${classPrefix$V}-title-arrow`, {
|
13391 | [`${classPrefix$V}-title-arrow-active`]: active
|
13392 | })
|
13393 | }, mergedArrowIcon))));
|
13394 | };
|
13395 | const Item$1 = Item;
|
13396 | const ItemChildrenWrap = (props) => {
|
13397 | const {
|
13398 | active = false
|
13399 | } = props;
|
13400 | const shouldRender = useShouldRender(active, props.forceRender, props.destroyOnClose);
|
13401 | const cls2 = classNames(`${classPrefix$V}-content`, {
|
13402 | [`${classPrefix$V}-content-hidden`]: !active
|
13403 | });
|
13404 | return shouldRender ? React$1.createElement("div", {
|
13405 | className: cls2,
|
13406 | onClick: props.onClick
|
13407 | }, props.children) : null;
|
13408 | };
|
13409 | const classPrefix$U = `adm-dropdown`;
|
13410 | const defaultProps$G = {
|
13411 | defaultActiveKey: null,
|
13412 | closeOnMaskClick: true,
|
13413 | closeOnClickAway: false,
|
13414 | getContainer: defaultPopupBaseProps["getContainer"]
|
13415 | };
|
13416 | const Dropdown = React$1.forwardRef((props, ref) => {
|
13417 | const {
|
13418 | dropdown: componentConfig = {}
|
13419 | } = useConfig();
|
13420 | const mergedProps = mergeProps(defaultProps$G, componentConfig, props);
|
13421 | const arrowIcon = mergeProp(componentConfig.arrowIcon, props.arrow, props.arrowIcon);
|
13422 | const [value, setValue2] = usePropsValue({
|
13423 | value: mergedProps.activeKey,
|
13424 | defaultValue: mergedProps.defaultActiveKey,
|
13425 | onChange: mergedProps.onChange
|
13426 | });
|
13427 | const navRef = React$1.useRef(null);
|
13428 | const contentRef = React$1.useRef(null);
|
13429 | useClickAway(() => {
|
13430 | if (!mergedProps.closeOnClickAway)
|
13431 | return;
|
13432 | setValue2(null);
|
13433 | }, [navRef, contentRef]);
|
13434 | const [top, setTop] = React$1.useState();
|
13435 | const containerRef = React$1.useRef(null);
|
13436 | React$1.useEffect(() => {
|
13437 | const container = containerRef.current;
|
13438 | if (!container)
|
13439 | return;
|
13440 | if (value) {
|
13441 | const rect = container.getBoundingClientRect();
|
13442 | setTop(rect.bottom);
|
13443 | }
|
13444 | }, [value]);
|
13445 | const changeActive = (key) => {
|
13446 | if (value === key) {
|
13447 | setValue2(null);
|
13448 | } else {
|
13449 | setValue2(key);
|
13450 | }
|
13451 | };
|
13452 | let popupForceRender = false;
|
13453 | const items = [];
|
13454 | const navs = React$1.Children.map(mergedProps.children, (child) => {
|
13455 | if (React$1.isValidElement(child)) {
|
13456 | const childProps = Object.assign(Object.assign({}, child.props), {
|
13457 | onClick: (event) => {
|
13458 | var _a, _b;
|
13459 | changeActive(child.key);
|
13460 | (_b = (_a = child.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
13461 | },
|
13462 | active: child.key === value
|
13463 | });
|
13464 | items.push(child);
|
13465 | if (child.props.forceRender)
|
13466 | popupForceRender = true;
|
13467 | return React$1.cloneElement(child, childProps);
|
13468 | } else {
|
13469 | return child;
|
13470 | }
|
13471 | });
|
13472 | React$1.useImperativeHandle(ref, () => ({
|
13473 | close: () => {
|
13474 | setValue2(null);
|
13475 | }
|
13476 | }), [setValue2]);
|
13477 | return withNativeProps(mergedProps, React$1.createElement("div", {
|
13478 | className: classNames(classPrefix$U, {
|
13479 | [`${classPrefix$U}-open`]: !!value
|
13480 | }),
|
13481 | ref: containerRef
|
13482 | }, React$1.createElement(IconContext.Provider, {
|
13483 | value: arrowIcon
|
13484 | }, React$1.createElement("div", {
|
13485 | className: `${classPrefix$U}-nav`,
|
13486 | ref: navRef
|
13487 | }, navs)), React$1.createElement(Popup, {
|
13488 | visible: !!value,
|
13489 | position: "top",
|
13490 | getContainer: mergedProps.getContainer,
|
13491 | className: `${classPrefix$U}-popup`,
|
13492 | maskClassName: `${classPrefix$U}-popup-mask`,
|
13493 | bodyClassName: `${classPrefix$U}-popup-body`,
|
13494 | style: {
|
13495 | top
|
13496 | },
|
13497 | forceRender: popupForceRender,
|
13498 | onMaskClick: mergedProps.closeOnMaskClick ? () => {
|
13499 | changeActive(null);
|
13500 | } : void 0
|
13501 | }, React$1.createElement("div", {
|
13502 | ref: contentRef
|
13503 | }, items.map((item) => {
|
13504 | const isActive = item.key === value;
|
13505 | return React$1.createElement(ItemChildrenWrap, {
|
13506 | key: item.key,
|
13507 | active: isActive,
|
13508 | forceRender: item.props.forceRender,
|
13509 | destroyOnClose: item.props.destroyOnClose
|
13510 | }, item.props.children);
|
13511 | })))));
|
13512 | });
|
13513 | const Dropdown$1 = Dropdown;
|
13514 | const index$b = attachPropertiesToComponent(Dropdown$1, {
|
13515 | Item: Item$1
|
13516 | });
|
13517 | var i;
|
13518 | !function(i2) {
|
13519 | i2[i2.HIGH_SURROGATE_START = 55296] = "HIGH_SURROGATE_START", i2[i2.HIGH_SURROGATE_END = 56319] = "HIGH_SURROGATE_END", i2[i2.LOW_SURROGATE_START = 56320] = "LOW_SURROGATE_START", i2[i2.REGIONAL_INDICATOR_START = 127462] = "REGIONAL_INDICATOR_START", i2[i2.REGIONAL_INDICATOR_END = 127487] = "REGIONAL_INDICATOR_END", i2[i2.FITZPATRICK_MODIFIER_START = 127995] = "FITZPATRICK_MODIFIER_START", i2[i2.FITZPATRICK_MODIFIER_END = 127999] = "FITZPATRICK_MODIFIER_END", i2[i2.VARIATION_MODIFIER_START = 65024] = "VARIATION_MODIFIER_START", i2[i2.VARIATION_MODIFIER_END = 65039] = "VARIATION_MODIFIER_END", i2[i2.DIACRITICAL_MARKS_START = 8400] = "DIACRITICAL_MARKS_START", i2[i2.DIACRITICAL_MARKS_END = 8447] = "DIACRITICAL_MARKS_END", i2[i2.SUBDIVISION_INDICATOR_START = 127988] = "SUBDIVISION_INDICATOR_START", i2[i2.TAGS_START = 917504] = "TAGS_START", i2[i2.TAGS_END = 917631] = "TAGS_END", i2[i2.ZWJ = 8205] = "ZWJ";
|
13520 | }(i || (i = {}));
|
13521 | const e = Object.freeze([776, 2359, 2367, 2984, 3007, 3021, 3633, 3635, 3648, 3657, 4352, 4449, 4520]);
|
13522 | var n;
|
13523 | function runes(i2) {
|
13524 | if ("string" != typeof i2)
|
13525 | throw new TypeError("string cannot be undefined or null");
|
13526 | const e2 = [];
|
13527 | let n2 = 0, t = 0;
|
13528 | for (; n2 < i2.length; )
|
13529 | t += nextUnits(n2 + t, i2), isGrapheme(i2[n2 + t]) && t++, isVariationSelector(i2[n2 + t]) && t++, isDiacriticalMark(i2[n2 + t]) && t++, isZeroWidthJoiner(i2[n2 + t]) ? t++ : (e2.push(i2.substring(n2, n2 + t)), n2 += t, t = 0);
|
13530 | return e2;
|
13531 | }
|
13532 | function nextUnits(i2, e2) {
|
13533 | const n2 = e2[i2];
|
13534 | if (!isFirstOfSurrogatePair(n2) || i2 === e2.length - 1)
|
13535 | return 1;
|
13536 | const t = n2 + e2[i2 + 1];
|
13537 | let r = e2.substring(i2 + 2, i2 + 5);
|
13538 | return isRegionalIndicator(t) && isRegionalIndicator(r) ? 4 : isSubdivisionFlag(t) && isSupplementarySpecialpurposePlane(r) ? e2.slice(i2).indexOf(String.fromCodePoint(917631)) + 2 : isFitzpatrickModifier(r) ? 4 : 2;
|
13539 | }
|
13540 | function isFirstOfSurrogatePair(i2) {
|
13541 | return i2 && betweenInclusive(i2[0].charCodeAt(0), 55296, 56319);
|
13542 | }
|
13543 | function isRegionalIndicator(i2) {
|
13544 | return betweenInclusive(codePointFromSurrogatePair(i2), 127462, 127487);
|
13545 | }
|
13546 | function isSubdivisionFlag(i2) {
|
13547 | return betweenInclusive(codePointFromSurrogatePair(i2), 127988, 127988);
|
13548 | }
|
13549 | function isFitzpatrickModifier(i2) {
|
13550 | return betweenInclusive(codePointFromSurrogatePair(i2), 127995, 127999);
|
13551 | }
|
13552 | function isVariationSelector(i2) {
|
13553 | return "string" == typeof i2 && betweenInclusive(i2.charCodeAt(0), 65024, 65039);
|
13554 | }
|
13555 | function isDiacriticalMark(i2) {
|
13556 | return "string" == typeof i2 && betweenInclusive(i2.charCodeAt(0), 8400, 8447);
|
13557 | }
|
13558 | function isSupplementarySpecialpurposePlane(i2) {
|
13559 | const e2 = i2.codePointAt(0);
|
13560 | return "string" == typeof i2 && "number" == typeof e2 && betweenInclusive(e2, 917504, 917631);
|
13561 | }
|
13562 | function isGrapheme(i2) {
|
13563 | return "string" == typeof i2 && e.includes(i2.charCodeAt(0));
|
13564 | }
|
13565 | function isZeroWidthJoiner(i2) {
|
13566 | return "string" == typeof i2 && 8205 === i2.charCodeAt(0);
|
13567 | }
|
13568 | function codePointFromSurrogatePair(i2) {
|
13569 | return (i2.charCodeAt(0) - 55296 << 10) + (i2.charCodeAt(1) - 56320) + 65536;
|
13570 | }
|
13571 | function betweenInclusive(i2, e2, n2) {
|
13572 | return i2 >= e2 && i2 <= n2;
|
13573 | }
|
13574 | !function(i2) {
|
13575 | i2[i2.unit_1 = 1] = "unit_1", i2[i2.unit_2 = 2] = "unit_2", i2[i2.unit_4 = 4] = "unit_4";
|
13576 | }(n || (n = {}));
|
13577 | const classPrefix$T = `adm-ellipsis`;
|
13578 | const defaultProps$F = {
|
13579 | direction: "end",
|
13580 | rows: 1,
|
13581 | expandText: "",
|
13582 | content: "",
|
13583 | collapseText: "",
|
13584 | stopPropagationForActionButtons: [],
|
13585 | onContentClick: () => {
|
13586 | },
|
13587 | defaultExpanded: false
|
13588 | };
|
13589 | const Ellipsis = (p) => {
|
13590 | const props = mergeProps(defaultProps$F, p);
|
13591 | const rootRef = React$1.useRef(null);
|
13592 | const expandElRef = React$1.useRef(null);
|
13593 | const collapseElRef = React$1.useRef(null);
|
13594 | const [ellipsised, setEllipsised] = React$1.useState({});
|
13595 | const [expanded, setExpanded] = React$1.useState(props.defaultExpanded);
|
13596 | const [exceeded, setExceeded] = React$1.useState(false);
|
13597 | const chars = React$1.useMemo(() => runes(props.content), [props.content]);
|
13598 | function getSubString(start2, end) {
|
13599 | return chars.slice(start2, end).join("");
|
13600 | }
|
13601 | function calcEllipsised() {
|
13602 | var _a, _b;
|
13603 | const root2 = rootRef.current;
|
13604 | if (!root2)
|
13605 | return;
|
13606 | const originDisplay = root2.style.display;
|
13607 | root2.style.display = "block";
|
13608 | const originStyle = window.getComputedStyle(root2);
|
13609 | const container = document.createElement("div");
|
13610 | const styleNames = Array.prototype.slice.apply(originStyle);
|
13611 | styleNames.forEach((name) => {
|
13612 | container.style.setProperty(name, originStyle.getPropertyValue(name));
|
13613 | });
|
13614 | root2.style.display = originDisplay;
|
13615 | container.style.height = "auto";
|
13616 | container.style.minHeight = "auto";
|
13617 | container.style.maxHeight = "auto";
|
13618 | container.style.textOverflow = "clip";
|
13619 | container.style.webkitLineClamp = "unset";
|
13620 | container.style.display = "block";
|
13621 | const lineHeight = pxToNumber(originStyle.lineHeight);
|
13622 | const maxHeight = Math.floor(lineHeight * (props.rows + 0.5) + pxToNumber(originStyle.paddingTop) + pxToNumber(originStyle.paddingBottom));
|
13623 | container.innerText = props.content;
|
13624 | document.body.appendChild(container);
|
13625 | if (container.offsetHeight <= maxHeight) {
|
13626 | setExceeded(false);
|
13627 | } else {
|
13628 | let check = function(left, right) {
|
13629 | if (right - left <= 1) {
|
13630 | if (props.direction === "end") {
|
13631 | return {
|
13632 | leading: getSubString(0, left) + "..."
|
13633 | };
|
13634 | } else {
|
13635 | return {
|
13636 | tailing: "..." + getSubString(right, end)
|
13637 | };
|
13638 | }
|
13639 | }
|
13640 | const middle2 = Math.round((left + right) / 2);
|
13641 | if (props.direction === "end") {
|
13642 | container.innerHTML = getSubString(0, middle2) + "..." + actionText;
|
13643 | } else {
|
13644 | container.innerHTML = actionText + "..." + getSubString(middle2, end);
|
13645 | }
|
13646 | if (container.offsetHeight <= maxHeight) {
|
13647 | if (props.direction === "end") {
|
13648 | return check(middle2, right);
|
13649 | } else {
|
13650 | return check(left, middle2);
|
13651 | }
|
13652 | } else {
|
13653 | if (props.direction === "end") {
|
13654 | return check(left, middle2);
|
13655 | } else {
|
13656 | return check(middle2, right);
|
13657 | }
|
13658 | }
|
13659 | }, checkMiddle = function(leftPart, rightPart) {
|
13660 | if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
|
13661 | return {
|
13662 | leading: getSubString(0, leftPart[0]) + "...",
|
13663 | tailing: "..." + getSubString(rightPart[1], end)
|
13664 | };
|
13665 | }
|
13666 | const leftPartMiddle = Math.floor((leftPart[0] + leftPart[1]) / 2);
|
13667 | const rightPartMiddle = Math.ceil((rightPart[0] + rightPart[1]) / 2);
|
13668 | container.innerHTML = getSubString(0, leftPartMiddle) + "..." + actionText + "..." + getSubString(rightPartMiddle, end);
|
13669 | if (container.offsetHeight <= maxHeight) {
|
13670 | return checkMiddle([leftPartMiddle, leftPart[1]], [rightPart[0], rightPartMiddle]);
|
13671 | } else {
|
13672 | return checkMiddle([leftPart[0], leftPartMiddle], [rightPartMiddle, rightPart[1]]);
|
13673 | }
|
13674 | };
|
13675 | setExceeded(true);
|
13676 | const end = props.content.length;
|
13677 | const collapseEl = typeof props.collapseText === "string" ? props.collapseText : (_a = collapseElRef.current) === null || _a === void 0 ? void 0 : _a.innerHTML;
|
13678 | const expandEl = typeof props.expandText === "string" ? props.expandText : (_b = expandElRef.current) === null || _b === void 0 ? void 0 : _b.innerHTML;
|
13679 | const actionText = expanded ? collapseEl : expandEl;
|
13680 | const middle = Math.floor((0 + end) / 2);
|
13681 | const ellipsised2 = props.direction === "middle" ? checkMiddle([0, middle], [middle, end]) : check(0, end);
|
13682 | setEllipsised(ellipsised2);
|
13683 | }
|
13684 | document.body.removeChild(container);
|
13685 | }
|
13686 | useResizeEffect(calcEllipsised, rootRef);
|
13687 | useIsomorphicLayoutEffect$2(() => {
|
13688 | calcEllipsised();
|
13689 | }, [props.content, props.direction, props.rows, props.expandText, props.collapseText]);
|
13690 | const expandActionElement = !!props.expandText && withStopPropagation(props.stopPropagationForActionButtons, React$1.createElement("a", {
|
13691 | ref: expandElRef,
|
13692 | onClick: () => {
|
13693 | setExpanded(true);
|
13694 | }
|
13695 | }, props.expandText));
|
13696 | const collapseActionElement = !!props.collapseText && withStopPropagation(props.stopPropagationForActionButtons, React$1.createElement("a", {
|
13697 | ref: collapseElRef,
|
13698 | onClick: () => {
|
13699 | setExpanded(false);
|
13700 | }
|
13701 | }, props.collapseText));
|
13702 | const renderContent = () => {
|
13703 | if (!exceeded)
|
13704 | return props.content;
|
13705 | if (expanded)
|
13706 | return React$1.createElement(React$1.Fragment, null, props.content, collapseActionElement);
|
13707 | return React$1.createElement(React$1.Fragment, null, ellipsised.leading, expandActionElement, ellipsised.tailing);
|
13708 | };
|
13709 | return withNativeProps(props, React$1.createElement("div", {
|
13710 | ref: rootRef,
|
13711 | className: classPrefix$T,
|
13712 | onClick: (e2) => {
|
13713 | if (e2.target === e2.currentTarget) {
|
13714 | props.onContentClick(e2);
|
13715 | }
|
13716 | }
|
13717 | }, renderContent()));
|
13718 | };
|
13719 | function pxToNumber(value) {
|
13720 | if (!value)
|
13721 | return 0;
|
13722 | const match = value.match(/^\d*(\.\d*)?/);
|
13723 | return match ? Number(match[0]) : 0;
|
13724 | }
|
13725 | const EmptyIcon = (props) => {
|
13726 | return withNativeProps(props, React$1.createElement("svg", {
|
13727 | viewBox: "0 0 64 41"
|
13728 | }, React$1.createElement("g", {
|
13729 | transform: "translate(0 1)",
|
13730 | fill: "none",
|
13731 | fillRule: "evenodd"
|
13732 | }, React$1.createElement("ellipse", {
|
13733 | fill: "#f5f5f5",
|
13734 | cx: "32",
|
13735 | cy: "33",
|
13736 | rx: "32",
|
13737 | ry: "7"
|
13738 | }), React$1.createElement("g", {
|
13739 | stroke: "#d9d9d9"
|
13740 | }, React$1.createElement("path", {
|
13741 | d: "M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"
|
13742 | }), React$1.createElement("path", {
|
13743 | d: "M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z",
|
13744 | fill: "#fafafa"
|
13745 | })))));
|
13746 | };
|
13747 | const classPrefix$S = `adm-empty`;
|
13748 | const Empty = (props) => {
|
13749 | function renderImageNode() {
|
13750 | const {
|
13751 | image
|
13752 | } = props;
|
13753 | if (image === void 0) {
|
13754 | return React$1.createElement(EmptyIcon, {
|
13755 | className: `${classPrefix$S}-image`,
|
13756 | style: props.imageStyle
|
13757 | });
|
13758 | }
|
13759 | if (typeof image === "string") {
|
13760 | return React$1.createElement("img", {
|
13761 | className: `${classPrefix$S}-image`,
|
13762 | style: props.imageStyle,
|
13763 | src: image,
|
13764 | alt: "empty"
|
13765 | });
|
13766 | }
|
13767 | return image;
|
13768 | }
|
13769 | return withNativeProps(props, React$1.createElement("div", {
|
13770 | className: classPrefix$S
|
13771 | }, React$1.createElement("div", {
|
13772 | className: `${classPrefix$S}-image-container`
|
13773 | }, renderImageNode()), props.description && React$1.createElement("div", {
|
13774 | className: classNames(`${classPrefix$S}-description`)
|
13775 | }, props.description)));
|
13776 | };
|
13777 | const classPrefix$R = `adm-error-block`;
|
13778 | const defaultProps$E = {
|
13779 | status: "default"
|
13780 | };
|
13781 | function createErrorBlock(imageRecord2) {
|
13782 | const ErrorBlock2 = (p) => {
|
13783 | var _a;
|
13784 | const props = mergeProps(defaultProps$E, p);
|
13785 | const {
|
13786 | locale
|
13787 | } = useConfig();
|
13788 | const contentPack = locale.ErrorBlock[props.status];
|
13789 | const desc = "description" in props ? props.description : contentPack.description;
|
13790 | const title = "title" in props ? props.title : contentPack.title;
|
13791 | const image = (_a = props.image) !== null && _a !== void 0 ? _a : imageRecord2[props.status];
|
13792 | const imageNode = typeof image === "string" ? React$1.createElement("img", {
|
13793 | src: image,
|
13794 | alt: "error block image"
|
13795 | }) : image;
|
13796 | return withNativeProps(props, React$1.createElement("div", {
|
13797 | className: classNames(classPrefix$R, {
|
13798 | [`${classPrefix$R}-full-page`]: props.fullPage
|
13799 | })
|
13800 | }, React$1.createElement("div", {
|
13801 | className: `${classPrefix$R}-image`
|
13802 | }, imageNode), React$1.createElement("div", {
|
13803 | className: `${classPrefix$R}-description`
|
13804 | }, ![void 0, null].includes(title) && React$1.createElement("div", {
|
13805 | className: `${classPrefix$R}-description-title`
|
13806 | }, title), ![void 0, null].includes(desc) && React$1.createElement("div", {
|
13807 | className: `${classPrefix$R}-description-subtitle`
|
13808 | }, desc)), props.children && React$1.createElement("div", {
|
13809 | className: `${classPrefix$R}-content`
|
13810 | }, props.children)));
|
13811 | };
|
13812 | return ErrorBlock2;
|
13813 | }
|
13814 | const defaultImage = React$1.createElement("svg", {
|
13815 | viewBox: "0 0 200 200",
|
13816 | xmlns: "http://www.w3.org/2000/svg",
|
13817 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
13818 | }, React$1.createElement("defs", null, React$1.createElement("linearGradient", {
|
13819 | x1: "50%",
|
13820 | y1: "-116.862%",
|
13821 | x2: "50%",
|
13822 | y2: "90.764%",
|
13823 | id: "error-block-image-default-a"
|
13824 | }, React$1.createElement("stop", {
|
13825 | stopColor: "#72A7FD",
|
13826 | stopOpacity: 0.207,
|
13827 | offset: "0%"
|
13828 | }), React$1.createElement("stop", {
|
13829 | stopColor: "#72A7FD",
|
13830 | stopOpacity: 0.115,
|
13831 | offset: "80.072%"
|
13832 | }), React$1.createElement("stop", {
|
13833 | stopColor: "#72A7FD",
|
13834 | stopOpacity: 0,
|
13835 | offset: "100%"
|
13836 | })), React$1.createElement("circle", {
|
13837 | id: "error-block-image-default-d",
|
13838 | cx: 18.823,
|
13839 | cy: 18.823,
|
13840 | r: 18.823
|
13841 | }), React$1.createElement("rect", {
|
13842 | id: "error-block-image-default-b",
|
13843 | x: 3.5,
|
13844 | y: 9,
|
13845 | width: 51.429,
|
13846 | height: 88,
|
13847 | rx: 4.571
|
13848 | })), React$1.createElement("g", {
|
13849 | fill: "none",
|
13850 | fillRule: "evenodd"
|
13851 | }, React$1.createElement("path", {
|
13852 | d: "M73.557.004c19.435-.311 38.696 17.016 51.523 35.287 8.708-10.822 17.127-16.233 25.255-16.233 13.333 0 28.35 14.274 45.053 42.822 1.769 3.024-3.582 7.435-16.054 13.231l-41.322 1.37c-7.343 5.872-31.225.626-69.152 1.234-27.79.445-45.759-1.234-53.908-5.037C3.2 71.143-1.625 68.686.48 65.308 27.371 22.12 51.73.353 73.557.003Zm93.098 49.53a1.125 1.125 0 0 0-.401.072l-.058.023-.07.03-.028.014-.02.01c-.03.015-.059.032-.088.049a2.543 2.543 0 0 0-.568.477l-.067.074c-1.686 1.931-2.904 7.062-2.904 8.985 0 2.283 1.719 4.153 3.898 4.314l.026.001v3.805c0 .39.25.705.56.705.31 0 .56-.316.56-.705l.001-3.88c1.92-.402 3.363-2.148 3.363-4.24 0-2.39-1.882-9.734-4.204-9.734Zm-100-5a1.125 1.125 0 0 0-.331.05l-.035.01-.035.012-.058.023-.07.03-.028.014-.02.01c-.03.015-.059.032-.088.049a2.543 2.543 0 0 0-.568.477l-.067.074c-1.686 1.931-2.904 7.062-2.904 8.985 0 2.212 1.613 4.036 3.695 4.294l.203.02.026.001v3.805c0 .39.25.705.56.705.282 0 .515-.26.555-.6l.006-.105v-3.88c1.92-.402 3.363-2.148 3.363-4.24 0-2.39-1.882-9.734-4.204-9.734ZM52.64 38.348l-.15.008-.149.023-.032.007-.032.008-.078.022-.045.015-.045.016-.06.023-.038.017-.038.017-.058.028-.022.011a2.201 2.201 0 0 0-.323.204l-.05.038-.05.04-.025.02-.025.021a3.742 3.742 0 0 0-.31.294l-.036.04c-.035.037-.07.076-.105.116-.01.012-.02.025-.031.036a3.275 3.275 0 0 0-.081.098l-.063.078c-2.031 2.583-3.48 8.692-3.48 11.027 0 2.636 1.846 4.832 4.292 5.323l.224.04-.064-.012.105.018.103.014v4.618c0 .47.299.85.667.85.337 0 .615-.32.659-.735l.006-.115v-4.618c.18-.023.355-.054.527-.094l.256-.067.196-.06c2.136-.706 3.68-2.75 3.68-5.162 0-2.996-2.383-12.207-5.325-12.207Z",
|
13853 | transform: "translate(2.286 22.286)",
|
13854 | fill: "url(#error-block-image-default-a)"
|
13855 | }), React$1.createElement("g", {
|
13856 | transform: "rotate(-90 102.429 55.357)"
|
13857 | }, React$1.createElement("path", {
|
13858 | d: "M6.857 0H52a6.857 6.857 0 0 1 6.857 6.857v92A6.857 6.857 0 0 1 52 105.714H6.857A6.857 6.857 0 0 1 0 98.857v-92A6.857 6.857 0 0 1 6.857 0Z",
|
13859 | fill: "#7EACFF"
|
13860 | }), React$1.createElement("mask", {
|
13861 | id: "error-block-image-default-c",
|
13862 | fill: "#fff"
|
13863 | }, React$1.createElement("use", {
|
13864 | xlinkHref: "#error-block-image-default-b"
|
13865 | })), React$1.createElement("use", {
|
13866 | fill: "#377EFF",
|
13867 | xlinkHref: "#error-block-image-default-b"
|
13868 | }), React$1.createElement("path", {
|
13869 | d: "M11.838 91.8a.64.64 0 0 1 .627.652.64.64 0 0 1-.627.652.64.64 0 0 1-.628-.652c0-.36.281-.651.628-.651Zm-2.858 0a.64.64 0 0 1 .628.652.64.64 0 0 1-.628.652.64.64 0 0 1-.627-.652c0-.36.281-.651.627-.651Zm2.16-2.305a.64.64 0 0 1 .628.652.64.64 0 0 1-.627.651.64.64 0 0 1-.627-.651c0-.36.28-.652.627-.652Zm-2.982-.04a.64.64 0 0 1 .627.651.64.64 0 0 1-.627.652.64.64 0 0 1-.627-.652c0-.36.28-.651.627-.651Zm5.268-.531a.64.64 0 0 1 .628.651.64.64 0 0 1-.628.652.64.64 0 0 1-.627-.652c0-.36.281-.651.627-.651Zm2.858-1.143a.64.64 0 0 1 .627.651.64.64 0 0 1-.627.652.64.64 0 0 1-.628-.652c0-.36.281-.651.628-.651Zm-6.37-.917c.209 0 .377.175.377.39a.384.384 0 0 1-.376.392.384.384 0 0 1-.376-.391c0-.216.168-.391.376-.391Zm3.512-.798.093.007a.644.644 0 0 1 .535.645.64.64 0 0 1-.628.652.64.64 0 0 1-.627-.652c0-.36.281-.652.627-.652Zm5.715 0a.64.64 0 0 1 .627.652.64.64 0 0 1-.627.652.64.64 0 0 1-.627-.652c0-.36.28-.652.627-.652Zm-11.429 0a.64.64 0 0 1 .627.652.64.64 0 0 1-.627.652.64.64 0 0 1-.627-.652c0-.36.28-.652.627-.652Zm-3.261.241c.208 0 .376.175.376.39a.384.384 0 0 1-.376.392.384.384 0 0 1-.377-.391c0-.216.169-.391.377-.391Zm11.833-.812a.64.64 0 0 1 .627.652.64.64 0 0 1-.627.651.64.64 0 0 1-.628-.651c0-.36.281-.652.628-.652Zm-4.851.399c.208 0 .376.175.376.39a.384.384 0 0 1-.376.392.384.384 0 0 1-.377-.391c0-.216.169-.391.377-.391Zm10.313-2.056a.64.64 0 0 1 .628.652.64.64 0 0 1-.628.651.64.64 0 0 1-.627-.651c0-.36.281-.652.627-.652Zm-2.354-.128a.64.64 0 0 1 .627.652.64.64 0 0 1-.627.652.64.64 0 0 1-.628-.652c0-.36.281-.652.628-.652Zm-13.798.311c.207 0 .376.175.376.391a.384.384 0 0 1-.376.391.384.384 0 0 1-.377-.39c0-.217.169-.392.377-.392Zm11.832-.812a.64.64 0 0 1 .628.652.64.64 0 0 1-.628.651.64.64 0 0 1-.627-.651c0-.36.281-.652.627-.652Zm-6.285 0a.64.64 0 0 1 .627.652.64.64 0 0 1-.627.651.64.64 0 0 1-.627-.651c0-.36.28-.652.627-.652Zm3.428 0a.64.64 0 0 1 .627.652.64.64 0 0 1-.627.651.64.64 0 0 1-.627-.651c0-.36.28-.652.627-.652Zm-6.118.24c.208 0 .376.176.376.392a.384.384 0 0 1-.376.39.384.384 0 0 1-.377-.39c0-.216.169-.391.377-.391Zm11.261-2.525a.64.64 0 0 1 .627.651.64.64 0 0 1-.627.652.64.64 0 0 1-.627-.652c0-.36.28-.651.627-.651Zm-3.557.484c.208 0 .376.175.376.391a.384.384 0 0 1-.376.391.384.384 0 0 1-.376-.391c0-.216.168-.391.376-.391Zm-2.478-.555a.64.64 0 0 1 .627.652.64.64 0 0 1-.627.652.64.64 0 0 1-.627-.652c0-.36.28-.652.627-.652Zm-3.512-.26c.208 0 .376.175.376.39a.384.384 0 0 1-.376.392.384.384 0 0 1-.376-.391c0-.216.168-.391.376-.391Zm-2.857 0c.208 0 .376.175.376.39a.384.384 0 0 1-.376.392.384.384 0 0 1-.376-.391c0-.216.168-.391.376-.391Zm-4.571 0c.207 0 .376.175.376.39a.384.384 0 0 1-.376.392.384.384 0 0 1-.377-.391c0-.216.169-.391.377-.391Zm14.898-1.835a.64.64 0 0 1 .628.652.64.64 0 0 1-.628.651.64.64 0 0 1-.627-.651c0-.36.281-.652.627-.652Zm-8.027-.245c.208 0 .377.175.377.39a.384.384 0 0 1-.377.392.384.384 0 0 1-.376-.391c0-.216.169-.391.376-.391Zm6.271-1.349c.208 0 .377.175.377.391a.384.384 0 0 1-.377.391.384.384 0 0 1-.376-.39c0-.217.169-.392.376-.392Zm-11.484-.481c.208 0 .376.175.376.39a.384.384 0 0 1-.376.392.384.384 0 0 1-.376-.391c0-.216.168-.391.376-.391Zm15.103-.972c.208 0 .376.175.376.391a.384.384 0 0 1-.376.391.384.384 0 0 1-.376-.39c0-.217.168-.392.376-.392Zm-9.333-1.404c.208 0 .376.175.376.39a.384.384 0 0 1-.376.392.384.384 0 0 1-.376-.391c0-.216.168-.391.376-.391Zm-6.819-.405c.208 0 .377.175.377.39a.384.384 0 0 1-.377.392.384.384 0 0 1-.376-.391c0-.216.168-.391.376-.391Z",
|
13870 | fill: "#003CFF",
|
13871 | fillRule: "nonzero",
|
13872 | mask: "url(#error-block-image-default-c)",
|
13873 | transform: "rotate(116 12.367 83.503)"
|
13874 | }), React$1.createElement("path", {
|
13875 | stroke: "#FFF",
|
13876 | strokeWidth: 0.75,
|
13877 | strokeLinecap: "round",
|
13878 | strokeLinejoin: "round",
|
13879 | d: "M36.774 5.474H21.523"
|
13880 | }), React$1.createElement("path", {
|
13881 | d: "m67.818 94.025-4.996 3.913m4.996 11.91-4.996-3.912m-1.142 9.145-1.143-6.288m10.71-6.768h-7.262",
|
13882 | stroke: "#4486FE",
|
13883 | strokeWidth: 0.75,
|
13884 | strokeLinecap: "round",
|
13885 | strokeLinejoin: "round"
|
13886 | })), React$1.createElement("circle", {
|
13887 | cx: 8.571,
|
13888 | cy: 8.571,
|
13889 | r: 8.571,
|
13890 | transform: "translate(22.857 142)",
|
13891 | fill: "#FFCD6B",
|
13892 | fillRule: "nonzero"
|
13893 | }), React$1.createElement("g", {
|
13894 | transform: "translate(132.857 124)"
|
13895 | }, React$1.createElement("mask", {
|
13896 | id: "error-block-image-default-e",
|
13897 | fill: "#fff"
|
13898 | }, React$1.createElement("use", {
|
13899 | xlinkHref: "#error-block-image-default-d"
|
13900 | })), React$1.createElement("use", {
|
13901 | fill: "#FBBE47",
|
13902 | fillRule: "nonzero",
|
13903 | xlinkHref: "#error-block-image-default-d"
|
13904 | }), React$1.createElement("circle", {
|
13905 | fill: "#FFCD6B",
|
13906 | fillRule: "nonzero",
|
13907 | mask: "url(#error-block-image-default-e)",
|
13908 | cx: 13.886,
|
13909 | cy: 15.12,
|
13910 | r: 18.823
|
13911 | }), React$1.createElement("circle", {
|
13912 | fill: "#FFB400",
|
13913 | fillRule: "nonzero",
|
13914 | mask: "url(#error-block-image-default-e)",
|
13915 | cx: 23.4,
|
13916 | cy: 29.057,
|
13917 | r: 1
|
13918 | }), React$1.createElement("circle", {
|
13919 | fill: "#FFB400",
|
13920 | fillRule: "nonzero",
|
13921 | mask: "url(#error-block-image-default-e)",
|
13922 | cx: 30.343,
|
13923 | cy: 29.829,
|
13924 | r: 1
|
13925 | }), React$1.createElement("circle", {
|
13926 | fill: "#FFB400",
|
13927 | fillRule: "nonzero",
|
13928 | mask: "url(#error-block-image-default-e)",
|
13929 | cx: 18.771,
|
13930 | cy: 32.657,
|
13931 | r: 1.286
|
13932 | }), React$1.createElement("circle", {
|
13933 | fill: "#FFB400",
|
13934 | fillRule: "nonzero",
|
13935 | mask: "url(#error-block-image-default-e)",
|
13936 | cx: 29.571,
|
13937 | cy: 25.971,
|
13938 | r: 1.286
|
13939 | }), React$1.createElement("circle", {
|
13940 | fill: "#FFB400",
|
13941 | fillRule: "nonzero",
|
13942 | mask: "url(#error-block-image-default-e)",
|
13943 | cx: 19.286,
|
13944 | cy: 7.971,
|
13945 | r: 1.286
|
13946 | }), React$1.createElement("circle", {
|
13947 | fill: "#FFB400",
|
13948 | fillRule: "nonzero",
|
13949 | mask: "url(#error-block-image-default-e)",
|
13950 | cx: 26.486,
|
13951 | cy: 5.914,
|
13952 | r: 1.286
|
13953 | }), React$1.createElement("circle", {
|
13954 | fill: "#FFB400",
|
13955 | fillRule: "nonzero",
|
13956 | mask: "url(#error-block-image-default-e)",
|
13957 | cx: 11.057,
|
13958 | cy: 6.943,
|
13959 | r: 1
|
13960 | }), React$1.createElement("circle", {
|
13961 | fill: "#FFB400",
|
13962 | fillRule: "nonzero",
|
13963 | mask: "url(#error-block-image-default-e)",
|
13964 | cx: 30.086,
|
13965 | cy: 15.686,
|
13966 | r: 1.286
|
13967 | }), React$1.createElement("circle", {
|
13968 | fill: "#FFB400",
|
13969 | fillRule: "nonzero",
|
13970 | mask: "url(#error-block-image-default-e)",
|
13971 | cx: 22.886,
|
13972 | cy: 14.657,
|
13973 | r: 1
|
13974 | })), React$1.createElement("path", {
|
13975 | d: "m87.429 135.123 6.591-9.378v-.08h-5.99v-2.559h10.038v1.787l-6.44 9.254v.082h6.56v2.557h-10.76v-1.663Zm12.185-5.889 4.948-7.047v-.056h-4.498v-1.917h7.536v1.34l-4.849 6.942v.059h4.923v1.92h-8.06v-1.24Zm10.345.702 3.708-5.274v-.045h-3.372v-1.437h5.648v1.003l-3.628 5.206v.045H116v1.438h-6.041v-.936Z",
|
13976 | fill: "#FFF",
|
13977 | fillRule: "nonzero"
|
13978 | })));
|
13979 | const disconnectedImage = React$1.createElement("svg", {
|
13980 | viewBox: "0 0 400 400",
|
13981 | xmlns: "http://www.w3.org/2000/svg",
|
13982 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
13983 | }, React$1.createElement("title", null, "@反馈/异常/网络服务异常"), React$1.createElement("defs", null, React$1.createElement("linearGradient", {
|
13984 | x1: "50%",
|
13985 | y1: "-116.862%",
|
13986 | x2: "50%",
|
13987 | y2: "90.764%",
|
13988 | id: "error-block-image-disconnected-c"
|
13989 | }, React$1.createElement("stop", {
|
13990 | stopColor: "#72A7FD",
|
13991 | stopOpacity: 0.207,
|
13992 | offset: "0%"
|
13993 | }), React$1.createElement("stop", {
|
13994 | stopColor: "#72A7FD",
|
13995 | stopOpacity: 0.115,
|
13996 | offset: "80.072%"
|
13997 | }), React$1.createElement("stop", {
|
13998 | stopColor: "#72A7FD",
|
13999 | stopOpacity: 0,
|
14000 | offset: "100%"
|
14001 | })), React$1.createElement("circle", {
|
14002 | id: "error-block-image-disconnected-d",
|
14003 | cx: 22.309,
|
14004 | cy: 22.309,
|
14005 | r: 22.309
|
14006 | }), React$1.createElement("path", {
|
14007 | id: "error-block-image-disconnected-a",
|
14008 | d: "M0 0h400v400H0z"
|
14009 | })), React$1.createElement("g", {
|
14010 | fill: "none",
|
14011 | fillRule: "evenodd"
|
14012 | }, React$1.createElement("mask", {
|
14013 | id: "error-block-image-disconnected-b",
|
14014 | fill: "#fff"
|
14015 | }, React$1.createElement("use", {
|
14016 | xlinkHref: "#error-block-image-disconnected-a"
|
14017 | })), React$1.createElement("g", {
|
14018 | mask: "url(#error-block-image-disconnected-b)",
|
14019 | fill: "url(#error-block-image-disconnected-c)"
|
14020 | }, React$1.createElement("path", {
|
14021 | d: "M151.686 45.58c38.869-.623 77.391 34.03 103.046 70.573 17.416-21.644 34.253-32.465 50.51-32.465 26.666 0 56.701 28.548 90.105 85.643 3.539 6.05-7.164 14.87-32.107 26.462l-82.643 2.741c-14.686 11.745-62.45 1.252-138.305 2.467-55.58.89-91.518-2.468-107.816-10.074-23.505-3.07-33.154-7.983-28.946-14.74C59.313 89.813 108.03 46.278 151.686 45.58Zm186.195 99.06-.127.003-.126.01a2.32 2.32 0 0 0-.465.103l-.032.01-.031.01a2.364 2.364 0 0 0-.181.071 2.52 2.52 0 0 0-.116.054l-.133.067-.042.024-.036.02a2.946 2.946 0 0 0-.133.08l-.048.03a3.052 3.052 0 0 0-.126.087l-.047.033a3.274 3.274 0 0 0-.128.097c-.01.008-.02.017-.031.024a4.906 4.906 0 0 0-.31.27l-.036.032a6.654 6.654 0 0 0-.46.484l-.045.05c-3.344 3.91-5.755 14.083-5.755 17.908 0 4.547 3.409 8.275 7.74 8.625l.108.008v7.608c0 .779.502 1.41 1.121 1.41.62 0 1.121-.632 1.121-1.41v-7.762c3.838-.802 6.727-4.293 6.727-8.48 0-4.778-3.765-19.467-8.409-19.467Zm-200-10-.127.003-.126.01a2.32 2.32 0 0 0-.368.073l-.049.014-.048.016-.032.01-.031.01a2.364 2.364 0 0 0-.181.071l-.058.026-.058.028-.133.067-.042.024-.036.02-.066.039-.067.041-.048.03a3.052 3.052 0 0 0-.126.087l-.047.033a3.274 3.274 0 0 0-.128.097c-.01.008-.02.017-.031.024l-.156.13-.154.14-.036.032a6.654 6.654 0 0 0-.46.484l-.045.05c-3.344 3.91-5.755 14.083-5.755 17.908 0 4.547 3.409 8.275 7.74 8.625l.054.004.054.004v7.608c0 .779.502 1.41 1.121 1.41.58 0 1.058-.556 1.115-1.266l.006-.144v-7.762c3.838-.802 6.727-4.293 6.727-8.48 0-4.778-3.765-19.467-8.409-19.467Zm-28.029-12.373-.107.002-.106.006a2.978 2.978 0 0 0-.551.095 3.444 3.444 0 0 0-.323.104 3.962 3.962 0 0 0-.61.297c-.076.045-.15.092-.226.141-4.964 3.312-8.728 18.445-8.728 23.77 0 5.434 3.922 9.935 9.04 10.726l.28.04v9.236c0 .886.532 1.614 1.21 1.692l.121.007.122-.007c.638-.074 1.147-.723 1.204-1.538l.006-.155v-9.235c5.254-.668 9.32-5.234 9.32-10.767 0-5.993-4.77-24.414-10.652-24.414Z"
|
14022 | })), React$1.createElement("g", {
|
14023 | mask: "url(#error-block-image-disconnected-b)"
|
14024 | }, React$1.createElement("g", {
|
14025 | transform: "translate(85.858 150.644)"
|
14026 | }, React$1.createElement("path", {
|
14027 | d: "M116.26 28.467c1.352 0 2.703.018 4.054.054 3.923.385 10.188 4.248 9.267 11.061-.878 6.496-5.836 9.089-8.962 9.529a130.762 130.762 0 0 0-4.36-.072c-28.567 0-60.654 10.149-96.22 30.676l-2.227 1.297c-.744.437-1.49.878-2.236 1.323-4.878 2.911-11.193 1.316-14.103-3.562C-1.438 73.894.157 67.58 5.035 64.67 45.34 40.62 82.4 28.467 116.26 28.467Zm22 11.63c1.03-5.942 6.376-8.618 11.084-8.08C172.14 36.91 194.83 46.86 217.37 61.794c4.735 3.138 6.03 9.52 2.893 14.255-3.138 4.736-9.52 6.031-14.256 2.893-20.111-13.325-40.075-22.165-59.935-26.584a9.974 9.974 0 0 0-.325-.088c-3.987-1.015-8.602-5.738-7.487-12.175ZM116.26 77.418c22.777 0 45.4 7.057 67.73 20.988 4.82 3.007 6.289 9.351 3.282 14.17-3.007 4.82-9.351 6.29-14.17 3.283-19.194-11.974-38.095-17.87-56.842-17.87s-37.648 5.896-56.842 17.87c-4.82 3.007-11.164 1.537-14.17-3.282-3.007-4.82-1.538-11.164 3.282-14.171 22.33-13.931 44.953-20.988 67.73-20.988ZM117.974 124.67c9.85 0 17.303 1.69 25.687 5.082l.82.337 2.9 1.231 3.008 1.252.77.305.107.04c5.326 1.976 8.042 7.895 6.066 13.221-1.976 5.326-7.895 8.042-13.221 6.067l-.713-.27-.726-.285-.763-.31-1.263-.527-2.944-1.26-1.125-.473c-6.393-2.648-11.433-3.838-18.603-3.838-8.223 0-16.532 2.126-25.028 6.475-5.056 2.588-11.254.587-13.842-4.47-2.589-5.056-.588-11.253 4.47-13.842 11.313-5.791 22.814-8.735 34.4-8.735ZM118.235 197.047c7.15 0 13.77-.897 19.841-2.721 5.44-1.635 8.526-7.37 6.892-12.81-1.635-5.44-7.37-8.526-12.81-6.892-4.072 1.224-8.707 1.851-13.923 1.851-4.36 0-8.79-1.045-13.373-3.21l-.626-.301c-5.095-2.512-11.262-.418-13.773 4.678-2.512 5.095-.418 11.261 4.678 13.773 7.559 3.727 15.288 5.632 23.094 5.632Z",
|
14028 | fill: "#377EFF",
|
14029 | fillRule: "nonzero"
|
14030 | }), React$1.createElement("path", {
|
14031 | d: "M198.35 62.413c2.755-4.967 9.016-6.76 13.984-4.004 13.068 7.25 19.124 18.535 17.615 30.952-1.157 9.515-6.83 18.757-14.096 24.352-13.364 10.29-34.915 9.401-49.363-1.91-4.472-3.502-5.26-9.967-1.758-14.44 3.436-4.388 9.724-5.229 14.185-1.952l.255.194c7.283 5.702 18.475 6.164 24.13 1.809 3.072-2.366 5.766-6.754 6.226-10.536.467-3.844-1.21-7.07-6.796-10.267l-.378-.213c-4.967-2.756-6.76-9.017-4.004-13.985ZM61.35 103.092c-2.84-4.92-9.13-6.607-14.05-3.768-20.662 11.922-21.772 35.751-6.018 51.69 13.752 13.914 33.192 13.447 50.507 1.158 4.633-3.288 5.723-9.708 2.436-14.34-3.288-4.633-9.709-5.724-14.341-2.436-9.763 6.928-18.07 7.128-23.97 1.158-6.761-6.84-6.498-14.501 1.35-19.225l.317-.187c4.92-2.84 6.608-9.13 3.769-14.05ZM129.103 135.702c1.688-5.424 7.454-8.453 12.878-6.764 14.776 4.599 23.437 13.727 25.259 25.58 1.316 8.561-1.228 17.533-5.58 24.052-3.132 4.688-7.388 8.287-12.504 11.112-3.03 1.673-5.75 2.811-9.37 4.066l-1.4.477c-5.387 1.806-11.217-1.097-13.022-6.484-1.805-5.386 1.098-11.216 6.484-13.02l1.09-.374c6.032-2.112 9.602-4.19 11.613-7.201 1.693-2.535 2.818-6.502 2.356-9.503-.564-3.673-3.432-6.696-11.04-9.063-5.424-1.689-8.452-7.454-6.764-12.878Z",
|
14032 | fill: "#377EFF",
|
14033 | fillRule: "nonzero"
|
14034 | }), React$1.createElement("path", {
|
14035 | d: "M148.072 181.58c3.718-7.98 4.172-14.9 1.36-20.76-2.81-5.86-6.236-9.096-10.275-9.707",
|
14036 | stroke: "#FFF",
|
14037 | strokeWidth: 0.571,
|
14038 | strokeLinecap: "round"
|
14039 | }), React$1.createElement("ellipse", {
|
14040 | fill: "#7EACFF",
|
14041 | transform: "rotate(10 147 41.933)",
|
14042 | cx: 147,
|
14043 | cy: 41.933,
|
14044 | rx: 9.143,
|
14045 | ry: 10.286
|
14046 | }), React$1.createElement("path", {
|
14047 | d: "M210.422 107.472c3.718-7.98 4.172-14.9 1.36-20.76-2.81-5.86-6.668-9.883-11.572-12.067M51.604 131.769c-3.15-6.8-3.537-12.694-1.161-17.685 2.376-4.99 5.57-8.136 9.583-9.438",
|
14048 | stroke: "#003CFF",
|
14049 | strokeWidth: 0.75,
|
14050 | strokeLinecap: "round",
|
14051 | strokeLinejoin: "round"
|
14052 | }), React$1.createElement("path", {
|
14053 | d: "M21.53 64.408c4.946-3.389 9.817-6.026 14.612-7.912",
|
14054 | stroke: "#FFF",
|
14055 | strokeWidth: 0.75,
|
14056 | strokeLinecap: "round",
|
14057 | strokeLinejoin: "round"
|
14058 | }), React$1.createElement("path", {
|
14059 | d: "m113.243 15.444 9.588 8.314M144.31 9.405l-5.775 11.3m18.389-1.246-11.907 4.643M127.64 5.66l2.77 14.255",
|
14060 | stroke: "#4486FE",
|
14061 | strokeWidth: 0.75,
|
14062 | strokeLinecap: "round",
|
14063 | strokeLinejoin: "round"
|
14064 | }))), React$1.createElement("g", {
|
14065 | mask: "url(#error-block-image-disconnected-b)"
|
14066 | }, React$1.createElement("g", {
|
14067 | transform: "translate(275.143 302.571)"
|
14068 | }, React$1.createElement("mask", {
|
14069 | id: "error-block-image-disconnected-e",
|
14070 | fill: "#fff"
|
14071 | }, React$1.createElement("use", {
|
14072 | xlinkHref: "#error-block-image-disconnected-d"
|
14073 | })), React$1.createElement("use", {
|
14074 | fill: "#FBBE47",
|
14075 | fillRule: "nonzero",
|
14076 | xlinkHref: "#error-block-image-disconnected-d"
|
14077 | }), React$1.createElement("circle", {
|
14078 | fill: "#FFCD6B",
|
14079 | fillRule: "nonzero",
|
14080 | mask: "url(#error-block-image-disconnected-e)",
|
14081 | cx: 16.457,
|
14082 | cy: 17.92,
|
14083 | r: 22.309
|
14084 | }), React$1.createElement("circle", {
|
14085 | fill: "#FFF",
|
14086 | fillRule: "nonzero",
|
14087 | mask: "url(#error-block-image-disconnected-e)",
|
14088 | cx: 14.263,
|
14089 | cy: 12.069,
|
14090 | r: 2.194
|
14091 | }))), React$1.createElement("g", {
|
14092 | mask: "url(#error-block-image-disconnected-b)",
|
14093 | fill: "#FBBE47",
|
14094 | fillRule: "nonzero"
|
14095 | }, React$1.createElement("circle", {
|
14096 | cx: 12,
|
14097 | cy: 12,
|
14098 | r: 12,
|
14099 | transform: "translate(84 297.714)"
|
14100 | }))));
|
14101 | const emptyImage = React$1.createElement("svg", {
|
14102 | viewBox: "0 0 400 400",
|
14103 | xmlns: "http://www.w3.org/2000/svg",
|
14104 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
14105 | }, React$1.createElement("defs", null, React$1.createElement("linearGradient", {
|
14106 | x1: "50%",
|
14107 | y1: "-116.862%",
|
14108 | x2: "50%",
|
14109 | y2: "90.764%",
|
14110 | id: "error-block-image-empty-a"
|
14111 | }, React$1.createElement("stop", {
|
14112 | stopColor: "#72A7FD",
|
14113 | stopOpacity: 0.207,
|
14114 | offset: "0%"
|
14115 | }), React$1.createElement("stop", {
|
14116 | stopColor: "#72A7FD",
|
14117 | stopOpacity: 0.115,
|
14118 | offset: "80.072%"
|
14119 | }), React$1.createElement("stop", {
|
14120 | stopColor: "#72A7FD",
|
14121 | stopOpacity: 0,
|
14122 | offset: "100%"
|
14123 | })), React$1.createElement("path", {
|
14124 | d: "M146.183 18.461c31.705 23.336 33.349 71.85 4.93 96.614-.252.22 6.172 5.602 13.577 11.414l.686.537.69.54.695.54.348.27.698.54a341.27 341.27 0 0 0 8.806 6.596c1.114.802 4.643-.853 10.587-4.965l-.532 12.218a1.2 1.2 0 0 1-.481.91l-10.868 8.111c-1.405 1.048-3.32 1.185-4.854.072l-35.578-25.834c-33.414 17.333-79.913 15-109.804-7-33.444-24.616-33.444-75.95 0-100.563 33.443-24.615 87.657-24.615 121.1 0Zm-60.469 7.653C51.63 26.114 24 44.534 24 67.257S51.63 108.4 85.714 108.4s61.715-18.42 61.715-41.143c0-22.722-27.63-41.143-61.715-41.143Z",
|
14125 | id: "error-block-image-empty-b"
|
14126 | })), React$1.createElement("g", {
|
14127 | fill: "none",
|
14128 | fillRule: "evenodd"
|
14129 | }, React$1.createElement("path", {
|
14130 | d: "M157.964 244.661H0L3.806 100.13a4.572 4.572 0 0 1 4.353-4.446l.217-.006h45.588V68.2a4.572 4.572 0 0 1 4.356-4.567l.216-.005h65.498l2.554-58.689a4.571 4.571 0 0 1 4.779-4.367l.214.015 87.79 8.222a4.572 4.572 0 0 1 4.126 4.133l.015.212 3.146 69.652L301.634 64.9a4.571 4.571 0 0 1 5.628 4.231l.005.215v43.955l56.162.001v130.264h-56.163v.001h-82.383v-.004h-66.919v1.098ZM89.503 160.03h-9.968v8.436h9.968v-8.436Zm0-14.507h-9.968v8.435h9.968v-8.435Zm197.985-5.15h-9.967v8.432h9.967v-8.431Zm-197.985-8.806h-9.968v8.436h9.968v-8.436Zm197.985-5.153h-9.967v8.432h9.967v-8.432Zm0-14.503h-9.967v8.432h9.967v-8.432Zm-84.643-.777h-30.8v8.436h30.8v-8.436Zm84.643-13.186h-9.967v8.436h9.967v-8.436Zm-84.643-3.29h-30.8v8.436h30.8v-8.436Zm0-15.912h-30.8v8.436h30.8v-8.436Z",
|
14131 | transform: "translate(18.286 50.286)",
|
14132 | fill: "url(#error-block-image-empty-a)"
|
14133 | }), React$1.createElement("g", {
|
14134 | transform: "translate(108.571 189.886)"
|
14135 | }, React$1.createElement("mask", {
|
14136 | id: "error-block-image-empty-c",
|
14137 | fill: "#fff"
|
14138 | }, React$1.createElement("use", {
|
14139 | xlinkHref: "#error-block-image-empty-b"
|
14140 | })), React$1.createElement("use", {
|
14141 | fill: "#377EFF",
|
14142 | xlinkHref: "#error-block-image-empty-b"
|
14143 | }), React$1.createElement("path", {
|
14144 | d: "M131.429 134.686a1.143 1.143 0 1 1 0 2.285 1.143 1.143 0 0 1 0-2.285Zm5.714 0a1.143 1.143 0 1 1 0 2.285 1.143 1.143 0 0 1 0-2.285ZM128 133.543a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-5.714 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm21.143-1.143a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm-9.143-1.143a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm12-1.143a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-6.857 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286ZM120 128.971a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm5.714 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm16-1.142.125.006a1.143 1.143 0 1 1-.125-.006Zm11.429 0a1.143 1.143 0 1 1 0 2.285 1.143 1.143 0 0 1 0-2.285Zm-22.857 0a1.143 1.143 0 1 1 0 2.285 1.143 1.143 0 0 1 0-2.285Zm17.143-1.143a1.143 1.143 0 1 1 0 2.285 1.143 1.143 0 0 1 0-2.285ZM136 125.543a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-13.143 1.143a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm4.572-1.143a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm18.857-2.286a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-16-1.143.124.007a1.143 1.143 0 1 1-.124-.007Zm11.428 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-22.857 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm36.572 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-5.715 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-37.143 1.143a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm13.715-1.143a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm9.714-1.143a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm18.286-3.428a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-11.429 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-28 1.143a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm5.714-1.143a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm17.715-1.143a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-5.715 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-6.857 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm17.143-4.571a1.143 1.143 0 1 1 0 2.285 1.143 1.143 0 0 1 0-2.285Zm-11.428 0a1.143 1.143 0 1 1 0 2.285 1.143 1.143 0 0 1 0-2.285Zm-5.143 1.142a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm-8-1.142a.571.571 0 1 1 0 1.142.571.571 0 0 1 0-1.142Zm-9.143 0a.571.571 0 1 1 0 1.142.571.571 0 0 1 0-1.142Zm30.286-3.429a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286ZM124 109.543a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm5.714 0a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm5.715-4.572a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm-22.858-1.142a.571.571 0 1 1 0 1.142.571.571 0 0 1 0-1.142Zm-11.428-3.429a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143ZM124 99.257a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143ZM49.143 55.829a1.143 1.143 0 1 1 0 2.285 1.143 1.143 0 0 1 0-2.285Zm5.714 0a1.143 1.143 0 1 1 0 2.285 1.143 1.143 0 0 1 0-2.285Zm-9.143-1.143a1.143 1.143 0 1 1 0 2.285 1.143 1.143 0 0 1 0-2.285Zm-5.714 0a1.143 1.143 0 1 1 0 2.285 1.143 1.143 0 0 1 0-2.285Zm21.143-1.143a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143ZM52 52.4a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm12-1.143a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-6.857 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-19.429-1.143a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm5.715 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm16-1.143.124.007a1.143 1.143 0 1 1-.124-.007Zm11.428 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-22.857 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm17.143-1.142a1.143 1.143 0 1 1 0 2.285 1.143 1.143 0 0 1 0-2.285Zm-11.429-1.143a1.143 1.143 0 1 1 0 2.285 1.143 1.143 0 0 1 0-2.285Zm-13.143 1.143a.571.571 0 1 1 0 1.142.571.571 0 0 1 0-1.142Zm4.572-1.143a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143ZM64 44.4a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-16-1.143.125.007a1.143 1.143 0 1 1-.125-.007Zm11.429 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-22.858 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm36.572 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-5.714 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286ZM30.286 44.4a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143ZM44 43.257a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm9.714-1.143a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286ZM72 38.686a1.143 1.143 0 1 1 0 2.285 1.143 1.143 0 0 1 0-2.285Zm-11.429 0a1.143 1.143 0 1 1 0 2.285 1.143 1.143 0 0 1 0-2.285Zm-28 1.143a.571.571 0 1 1 0 1.142.571.571 0 0 1 0-1.142Zm5.715-1.143a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143ZM56 37.543a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-5.714 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-6.857 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286ZM60.57 32.97a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-11.428 0a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286ZM44 34.114a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm-8-1.143a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm-9.143 0a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm30.286-3.428a1.143 1.143 0 1 1 0 2.286 1.143 1.143 0 0 1 0-2.286Zm-15.429 1.143a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm5.715 0a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm5.714-4.572a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm-22.857-1.143a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Zm-11.429-3.428a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143ZM41.714 20.4a.571.571 0 1 1 0 1.143.571.571 0 0 1 0-1.143Z",
|
14145 | fill: "#003CFF",
|
14146 | fillRule: "nonzero",
|
14147 | mask: "url(#error-block-image-empty-c)"
|
14148 | })), React$1.createElement("path", {
|
14149 | d: "M295.213 319.24c.744.546.745 1.433.002 1.98l-11.806 8.81c-1.069.799-3.326.474-4.853-.609l-35.622-25.241c-33.375 17.037-79.545 14.615-109.28-7.271-33.443-24.615-33.443-64.521 0-89.133 33.443-24.616 87.657-24.616 121.1 0 31.706 23.336 33.35 60.42 4.931 85.185-.543.473 35.528 26.278 35.528 26.278ZM148.06 220.015c-25.44 17.853-25.44 46.8 0 64.652 25.44 17.85 66.689 17.85 92.129 0 25.436-17.853 25.436-46.799 0-64.652-25.44-17.853-66.688-17.853-92.129 0Z",
|
14150 | fill: "#5D96FE"
|
14151 | }), React$1.createElement("path", {
|
14152 | d: "M123.514 233.021c2.185-5.241 5.67-9.735 10.453-13.482M264.967 271.54c-2.185 5.24-5.67 9.734-10.453 13.481",
|
14153 | stroke: "#FFF",
|
14154 | strokeWidth: 0.75,
|
14155 | strokeLinecap: "round",
|
14156 | strokeLinejoin: "round"
|
14157 | }), React$1.createElement("path", {
|
14158 | d: "M81.143 252.571c7.574 0 13.714 23.88 13.714 31.649 0 6.97-4.942 12.755-11.429 13.871v11.672c0 1.235-.767 2.237-1.713 2.237-.904 0-1.644-.912-1.71-2.07l-.005-.167v-11.526c-7.04-.595-12.571-6.644-12.571-14.017 0-7.024 5.02-27.222 11.581-31.027l.096-.053c.027-.016.055-.03.082-.045l.067-.035.066-.033.1-.05.094-.041a3.34 3.34 0 0 1 .224-.093l.11-.042.097-.032c.038-.013.077-.025.115-.036l.053-.016.053-.014a3.351 3.351 0 0 1 .23-.055l.085-.016a3.95 3.95 0 0 1 .441-.054l.11-.005.11-.002Z",
|
14159 | fill: "#FFCD6B",
|
14160 | fillRule: "nonzero"
|
14161 | }), React$1.createElement("g", {
|
14162 | transform: "translate(283.429 177.143)",
|
14163 | fillRule: "nonzero"
|
14164 | }, React$1.createElement("path", {
|
14165 | d: "M22.475.847c12.34 0 22.345 37.935 22.345 50.276 0 11.395-8.53 20.798-19.552 22.172v19.019c0 1.932-1.25 3.5-2.792 3.5-1.49 0-2.707-1.46-2.79-3.301l-.004-.2-.001-19.018C8.659 71.92.13 62.518.13 51.123.13 40.071 8.154 8.49 18.694 2.015l.054-.031a5.94 5.94 0 0 1 .214-.128l.088-.048c.213-.12.427-.228.642-.326l.135-.06.18-.075.135-.053a5.796 5.796 0 0 1 .464-.16 4.44 4.44 0 0 1 .33-.092l.124-.03a7.122 7.122 0 0 1 .31-.065l.018-.003a6.305 6.305 0 0 1 .756-.088l.165-.007.166-.002Z",
|
14166 | fill: "#FFCD6B"
|
14167 | }), React$1.createElement("path", {
|
14168 | d: "M22.475.847c12.34 0 22.345 37.935 22.345 50.276 0 11.395-8.53 20.798-19.552 22.172v19.019c0 1.932-1.25 3.5-2.792 3.5-1.543 0-2.794-1.566-2.794-3.5V73.295C8.659 71.921.13 62.518.13 51.123.13 38.783 10.134.847 22.475.847Z",
|
14169 | fill: "#FFCD6B"
|
14170 | }), React$1.createElement("circle", {
|
14171 | fill: "#FFB400",
|
14172 | cx: 26.4,
|
14173 | cy: 56.869,
|
14174 | r: 1.45
|
14175 | }), React$1.createElement("circle", {
|
14176 | fill: "#FFB400",
|
14177 | cx: 39.453,
|
14178 | cy: 58.319,
|
14179 | r: 1
|
14180 | }), React$1.createElement("circle", {
|
14181 | fill: "#FFB400",
|
14182 | cx: 17.698,
|
14183 | cy: 63.637,
|
14184 | r: 2.417
|
14185 | }), React$1.createElement("circle", {
|
14186 | fill: "#FFB400",
|
14187 | cx: 38.002,
|
14188 | cy: 51.068,
|
14189 | r: 2.417
|
14190 | }), React$1.createElement("circle", {
|
14191 | fill: "#FFB400",
|
14192 | cx: 18.665,
|
14193 | cy: 17.228,
|
14194 | r: 2.417
|
14195 | }), React$1.createElement("circle", {
|
14196 | fill: "#FFB400",
|
14197 | cx: 32.201,
|
14198 | cy: 13.36,
|
14199 | r: 2.417
|
14200 | }), React$1.createElement("circle", {
|
14201 | fill: "#FFB400",
|
14202 | cx: 26.83,
|
14203 | cy: 20.666,
|
14204 | r: 1.45
|
14205 | }), React$1.createElement("circle", {
|
14206 | fill: "#FFB400",
|
14207 | cx: 38.969,
|
14208 | cy: 31.731,
|
14209 | r: 2.417
|
14210 | }), React$1.createElement("circle", {
|
14211 | fill: "#FFB400",
|
14212 | cx: 25.433,
|
14213 | cy: 29.797,
|
14214 | r: 1.45
|
14215 | }), React$1.createElement("path", {
|
14216 | d: "M34.197 53.033c0 9.825-6.934 18.017-16.172 19.987a22.44 22.44 0 0 0 4.45.448c12.34 0 22.344-10.004 22.344-22.345C44.82 38.783 34.815.847 22.475.847c8.947 14.03 11.722 40.891 11.722 52.186Z",
|
14217 | fill: "#FBBE47"
|
14218 | }))));
|
14219 | const busyImage = React$1.createElement("svg", {
|
14220 | viewBox: "0 0 400 400",
|
14221 | xmlns: "http://www.w3.org/2000/svg",
|
14222 | xmlnsXlink: "http://www.w3.org/1999/xlink"
|
14223 | }, React$1.createElement("defs", null, React$1.createElement("linearGradient", {
|
14224 | x1: "50%",
|
14225 | y1: "-116.862%",
|
14226 | x2: "50%",
|
14227 | y2: "90.764%",
|
14228 | id: "error-block-image-busy-a"
|
14229 | }, React$1.createElement("stop", {
|
14230 | stopColor: "#72A7FD",
|
14231 | stopOpacity: 0.207,
|
14232 | offset: "0%"
|
14233 | }), React$1.createElement("stop", {
|
14234 | stopColor: "#72A7FD",
|
14235 | stopOpacity: 0.115,
|
14236 | offset: "80.072%"
|
14237 | }), React$1.createElement("stop", {
|
14238 | stopColor: "#72A7FD",
|
14239 | stopOpacity: 0,
|
14240 | offset: "100%"
|
14241 | })), React$1.createElement("circle", {
|
14242 | id: "error-block-image-busy-b",
|
14243 | cx: 34.857,
|
14244 | cy: 34.857,
|
14245 | r: 34.857
|
14246 | })), React$1.createElement("g", {
|
14247 | fill: "none",
|
14248 | fillRule: "evenodd"
|
14249 | }, React$1.createElement("path", {
|
14250 | d: "M157.964 243.667H0L3.806 99.134a4.572 4.572 0 0 1 4.353-4.446l.217-.005h45.588V67.205a4.572 4.572 0 0 1 4.356-4.566l.216-.005 65.498-.001 2.554-58.688a4.571 4.571 0 0 1 4.779-4.368l.214.015 87.79 8.222a4.572 4.572 0 0 1 4.126 4.133l.015.213 3.146 69.652 74.976-17.906a4.571 4.571 0 0 1 5.628 4.23l.005.216v43.955h56.162v130.265l-56.163-.001v.002h-82.383v-.004h-66.919v1.098Zm-68.461-84.631h-9.968v8.435h9.968v-8.435Zm0-14.508h-9.968v8.436h9.968v-8.436Zm197.985-5.149h-9.967v8.432h9.967v-8.432Zm-197.985-8.806h-9.968v8.436h9.968v-8.436Zm197.985-5.153h-9.967v8.432h9.967v-8.432Zm0-14.503h-9.967v8.432h9.967v-8.432Zm-84.643-.777h-30.8v8.436h30.8v-8.436Zm84.643-13.186h-9.967v8.435h9.967v-8.435Zm-84.643-3.29h-30.8v8.435h30.8v-8.435Zm0-15.912h-30.8v8.436h30.8v-8.436Z",
|
14251 | transform: "translate(18.286 51.286)",
|
14252 | fill: "url(#error-block-image-busy-a)"
|
14253 | }), React$1.createElement("path", {
|
14254 | d: "m250.934 176.555-101.963 1.038c-5.276.054-9.51 4.374-9.455 9.65.054 5.274 4.374 9.507 9.649 9.454l.958-.01c-.376 7.363 3.679 59.93 34.894 62.659 4.203.367 7.432.39 7.475 4.609.042 4.218-3.176 4.307-7.37 4.76-34.593 3.737-34.136 56.004-33.61 63.357l-.957.01c-5.276.053-9.51 4.373-9.455 9.649.053 5.275 4.374 9.508 9.649 9.454l101.963-1.039c5.275-.054 9.508-4.374 9.455-9.648-.055-5.276-4.374-9.51-9.65-9.455l-.958.01c.377-7.363-.729-59.672-34.894-62.66-4.202-.367-7.432-.39-7.474-4.608-.043-4.219 3.175-4.308 7.369-4.76 31.276-3.377 34.136-56.004 33.61-63.357l.958-.01c5.276-.053 9.508-4.373 9.455-9.649-.055-5.276-4.374-9.509-9.65-9.454Z",
|
14255 | fill: "#377EFF"
|
14256 | }), React$1.createElement("path", {
|
14257 | d: "M233.524 314.422c.108.684.772 1.148 1.483 1.035.711-.112 1.2-.758 1.091-1.443-.108-.684-.772-1.147-1.483-1.035-.711.113-1.2.759-1.091 1.443Zm-.894-5.644c.108.684.772 1.148 1.483 1.035.711-.112 1.2-.758 1.091-1.443-.108-.684-.772-1.147-1.483-1.035-.711.113-1.2.759-1.091 1.443Zm-.149 17.865c.108.684.773 1.147 1.483 1.035.711-.113 1.2-.759 1.091-1.443-.108-.684-.772-1.148-1.483-1.035-.71.112-1.2.758-1.09 1.443Zm-2.144-8.182c.109.684.773 1.148 1.484 1.035.71-.113 1.199-.759 1.09-1.443-.108-.684-.772-1.148-1.483-1.035-.71.113-1.2.759-1.09 1.443Zm-1.586-4.694c.108.684.772 1.148 1.483 1.035.711-.113 1.2-.759 1.091-1.443-.108-.684-.772-1.147-1.483-1.035-.711.113-1.2.759-1.091 1.443Zm-1.013-5.88c.109.685.773 1.148 1.484 1.036.71-.113 1.2-.759 1.09-1.443-.107-.684-.772-1.148-1.483-1.035-.71.113-1.199.759-1.09 1.443Zm.236 15.575c.108.685.772 1.148 1.483 1.035.71-.112 1.2-.758 1.09-1.442-.107-.685-.772-1.148-1.483-1.035-.71.112-1.199.758-1.09 1.442Zm-.4 4.494c.108.684.772 1.147 1.483 1.035.71-.113 1.2-.759 1.091-1.443-.108-.684-.773-1.148-1.483-1.035-.711.113-1.2.759-1.091 1.443Zm-3.88-8.601c.108.684.772 1.147 1.483 1.035.71-.113 1.199-.759 1.09-1.443-.108-.684-.772-1.148-1.483-1.035-.71.113-1.2.759-1.09 1.443Zm-.524-7.186c.065.41.463.688.89.62.426-.067.72-.454.654-.865-.065-.41-.463-.688-.89-.62-.426.067-.72.454-.654.865Zm-2.265-4.102c.109.684.773 1.148 1.484 1.035.71-.113 1.2-.759 1.09-1.443-.108-.684-.772-1.147-1.483-1.035-.71.113-1.199.759-1.09 1.443Zm-.545-6.518c.065.41.464.689.89.621.427-.067.72-.455.655-.865-.065-.41-.464-.689-.89-.621-.427.067-.72.455-.655.865Zm2.098 23.629c.109.684.773 1.147 1.484 1.035.71-.113 1.2-.759 1.09-1.443-.108-.684-.772-1.148-1.483-1.035-.71.112-1.199.758-1.09 1.443Zm-.756-9.65c.043.274.309.46.593.414a.512.512 0 0 0 .437-.577.512.512 0 0 0-.594-.414.512.512 0 0 0-.436.577Zm-.808 20.96c.109.684.773 1.147 1.484 1.034.71-.112 1.2-.758 1.09-1.442-.108-.685-.772-1.148-1.483-1.036-.71.113-1.199.759-1.09 1.443Zm-4.691-31.966c.065.41.463.689.89.621.426-.068.72-.455.654-.866-.065-.41-.463-.688-.89-.62-.426.067-.72.454-.654.865Zm2.098 23.628c.108.684.772 1.148 1.483 1.035.711-.112 1.2-.758 1.091-1.443-.108-.684-.772-1.147-1.483-1.035-.711.113-1.2.759-1.091 1.443Zm-1.967-12.416c.109.684.773 1.147 1.484 1.035.71-.113 1.199-.759 1.09-1.443-.108-.684-.772-1.148-1.483-1.035-.71.112-1.2.758-1.09 1.443Zm1.073 6.772c.108.685.772 1.148 1.483 1.035.711-.112 1.2-.758 1.091-1.442-.108-.685-.772-1.148-1.483-1.036-.711.113-1.2.759-1.091 1.443Zm-.009-3.131c.065.41.464.689.89.621.427-.068.72-.455.655-.866-.065-.41-.464-.688-.89-.62-.427.067-.72.454-.655.865Zm-1.43-9.03c.065.41.463.688.89.62.426-.067.72-.454.655-.865-.065-.41-.464-.689-.89-.62-.427.067-.72.454-.655.865ZM214.5 333.38c.108.685.772 1.148 1.483 1.036.711-.113 1.2-.759 1.091-1.443-.108-.684-.772-1.148-1.483-1.035-.711.112-1.2.758-1.091 1.442Zm-.156-7.178c.065.41.464.689.89.621.427-.067.72-.455.655-.865-.065-.41-.464-.689-.89-.621-.427.067-.72.455-.655.865Zm-1.871-4.72c.108.684.773 1.147 1.483 1.034.711-.112 1.2-.758 1.091-1.442-.108-.685-.772-1.148-1.483-1.035-.71.112-1.2.758-1.091 1.442Zm-1.614-6.857c.065.41.464.689.89.621.427-.068.72-.455.655-.866-.065-.41-.464-.688-.89-.62-.427.067-.72.454-.655.865Zm-.894-5.644c.065.41.464.689.89.621.427-.067.72-.455.655-.866-.065-.41-.463-.688-.89-.62-.427.067-.72.455-.655.865Zm-1.43-9.03c.065.41.464.688.89.62.427-.067.72-.454.655-.865-.065-.41-.464-.688-.89-.62-.427.067-.72.454-.655.865Zm-1.958 14.225c.065.41.463.689.89.62.426-.067.72-.454.654-.865-.065-.41-.463-.688-.89-.62-.426.067-.72.454-.654.865Zm-.703 12.81c.065.41.464.688.89.62.427-.067.72-.455.655-.865-.065-.41-.463-.689-.89-.621-.427.067-.72.455-.655.866Zm-4.543-22.536c.065.41.463.689.89.621.426-.067.72-.455.654-.865-.065-.41-.463-.689-.89-.621-.426.067-.72.455-.654.865Zm2.806 30.138c.065.41.463.689.89.621.426-.067.72-.455.654-.865-.065-.41-.463-.689-.89-.621-.426.067-.72.455-.654.865Zm-5.694-17.996c.065.41.463.688.89.62.426-.067.72-.455.654-.865-.065-.41-.463-.689-.89-.621-.426.067-.72.455-.654.866Zm-2.935-13.343c.066.41.464.688.89.62.427-.067.72-.454.655-.865-.065-.41-.463-.689-.89-.621-.426.068-.72.455-.655.866Z",
|
14258 | fill: "#003CFF",
|
14259 | fillRule: "nonzero"
|
14260 | }), React$1.createElement("path", {
|
14261 | d: "m250.934 176.555-101.963 1.038c-5.276.054-9.51 4.374-9.455 9.65.054 5.274 4.374 9.507 9.649 9.454l101.963-1.04c5.276-.052 9.508-4.372 9.455-9.648-.055-5.276-4.374-9.509-9.65-9.454ZM252.64 331.241l-101.964 1.038c-5.275.054-9.508 4.374-9.454 9.65.054 5.275 4.374 9.508 9.649 9.454l101.963-1.039c5.275-.053 9.507-4.373 9.454-9.649-.054-5.275-4.374-9.508-9.649-9.454Z",
|
14262 | fill: "#7EACFF"
|
14263 | }), React$1.createElement("path", {
|
14264 | stroke: "#003CFF",
|
14265 | strokeWidth: 0.75,
|
14266 | strokeLinecap: "round",
|
14267 | strokeLinejoin: "round",
|
14268 | d: "m196.824 197.298 52.216-.506M193.329 330.5h52.215"
|
14269 | }), React$1.createElement("path", {
|
14270 | d: "M167.367 228.041c-4.091-10.787-6.086-20.934-5.985-30.44",
|
14271 | stroke: "#FFF",
|
14272 | strokeWidth: 0.75,
|
14273 | strokeLinecap: "round",
|
14274 | strokeLinejoin: "round"
|
14275 | }), React$1.createElement("circle", {
|
14276 | cx: 14.857,
|
14277 | cy: 14.857,
|
14278 | r: 14.857,
|
14279 | transform: "translate(106.857 248.571)",
|
14280 | fill: "#FFCD6B",
|
14281 | fillRule: "nonzero"
|
14282 | }), React$1.createElement("g", {
|
14283 | transform: "translate(236.571 284.571)"
|
14284 | }, React$1.createElement("mask", {
|
14285 | id: "error-block-image-busy-c",
|
14286 | fill: "#fff"
|
14287 | }, React$1.createElement("use", {
|
14288 | xlinkHref: "#error-block-image-busy-b"
|
14289 | })), React$1.createElement("use", {
|
14290 | fill: "#FBBE47",
|
14291 | fillRule: "nonzero",
|
14292 | xlinkHref: "#error-block-image-busy-b"
|
14293 | }), React$1.createElement("circle", {
|
14294 | fill: "#FFCD6B",
|
14295 | fillRule: "nonzero",
|
14296 | mask: "url(#error-block-image-busy-c)",
|
14297 | cx: 25.714,
|
14298 | cy: 28,
|
14299 | r: 34.857
|
14300 | }), React$1.createElement("circle", {
|
14301 | fill: "#FFF",
|
14302 | fillRule: "nonzero",
|
14303 | mask: "url(#error-block-image-busy-c)",
|
14304 | cx: 22.286,
|
14305 | cy: 18.857,
|
14306 | r: 3.429
|
14307 | }))));
|
14308 | const imageRecord = {
|
14309 | "default": defaultImage,
|
14310 | "disconnected": disconnectedImage,
|
14311 | "empty": emptyImage,
|
14312 | "busy": busyImage
|
14313 | };
|
14314 | const ErrorBlock = createErrorBlock(imageRecord);
|
14315 | const classPrefix$Q = `adm-floating-bubble`;
|
14316 | const defaultProps$D = {
|
14317 | axis: "y",
|
14318 | defaultOffset: {
|
14319 | x: 0,
|
14320 | y: 0
|
14321 | }
|
14322 | };
|
14323 | const FloatingBubble = (p) => {
|
14324 | const props = mergeProps(defaultProps$D, p);
|
14325 | const boundaryRef = React$1.useRef(null);
|
14326 | const buttonRef = React$1.useRef(null);
|
14327 | const [innerValue, setInnerValue] = React$1.useState(props.offset === void 0 ? props.defaultOffset : props.offset);
|
14328 | React$1.useEffect(() => {
|
14329 | if (props.offset === void 0)
|
14330 | return;
|
14331 | api.start({
|
14332 | x: props.offset.x,
|
14333 | y: props.offset.y
|
14334 | });
|
14335 | }, [props.offset]);
|
14336 | const [{
|
14337 | x,
|
14338 | y,
|
14339 | opacity
|
14340 | }, api] = useSpring(() => ({
|
14341 | x: innerValue.x,
|
14342 | y: innerValue.y,
|
14343 | opacity: 1
|
14344 | }));
|
14345 | const bind = useDrag((state) => {
|
14346 | var _a;
|
14347 | let nextX = state.offset[0];
|
14348 | let nextY = state.offset[1];
|
14349 | if (state.last && props.magnetic) {
|
14350 | const boundary = boundaryRef.current;
|
14351 | const button = buttonRef.current;
|
14352 | if (!boundary || !button)
|
14353 | return;
|
14354 | const boundaryRect = boundary.getBoundingClientRect();
|
14355 | const buttonRect = button.getBoundingClientRect();
|
14356 | if (props.magnetic === "x") {
|
14357 | const compensation = x.goal - x.get();
|
14358 | const leftDistance = buttonRect.left + compensation - boundaryRect.left;
|
14359 | const rightDistance = boundaryRect.right - (buttonRect.right + compensation);
|
14360 | if (rightDistance <= leftDistance) {
|
14361 | nextX += rightDistance;
|
14362 | } else {
|
14363 | nextX -= leftDistance;
|
14364 | }
|
14365 | } else if (props.magnetic === "y") {
|
14366 | const compensation = y.goal - y.get();
|
14367 | const topDistance = buttonRect.top + compensation - boundaryRect.top;
|
14368 | const bottomDistance = boundaryRect.bottom - (buttonRect.bottom + compensation);
|
14369 | if (bottomDistance <= topDistance) {
|
14370 | nextY += bottomDistance;
|
14371 | } else {
|
14372 | nextY -= topDistance;
|
14373 | }
|
14374 | }
|
14375 | }
|
14376 | const nextOffest = {
|
14377 | x: nextX,
|
14378 | y: nextY
|
14379 | };
|
14380 | if (props.offset === void 0) {
|
14381 | api.start(nextOffest);
|
14382 | } else {
|
14383 | setInnerValue(nextOffest);
|
14384 | }
|
14385 | (_a = props.onOffsetChange) === null || _a === void 0 ? void 0 : _a.call(props, nextOffest);
|
14386 | api.start({
|
14387 | opacity: state.active ? 0.8 : 1
|
14388 | });
|
14389 | }, {
|
14390 | axis: props.axis === "xy" ? void 0 : props.axis,
|
14391 | pointer: {
|
14392 | touch: true
|
14393 | },
|
14394 |
|
14395 | filterTaps: true,
|
14396 |
|
14397 | bounds: boundaryRef,
|
14398 | from: () => [x.get(), y.get()]
|
14399 | });
|
14400 | return withNativeProps(props, React$1.createElement("div", {
|
14401 | className: classPrefix$Q
|
14402 | }, React$1.createElement("div", {
|
14403 | className: `${classPrefix$Q}-boundary-outer`
|
14404 | }, React$1.createElement("div", {
|
14405 | className: `${classPrefix$Q}-boundary`,
|
14406 | ref: boundaryRef
|
14407 | })), React$1.createElement(animated.div, Object.assign({}, bind(), {
|
14408 | style: {
|
14409 | opacity,
|
14410 | transform: to([x, y], (x2, y2) => `translate(${x2}px, ${y2}px)`)
|
14411 | },
|
14412 | onClick: props.onClick,
|
14413 | className: `${classPrefix$Q}-button`,
|
14414 | ref: buttonRef
|
14415 | }), props.children)));
|
14416 | };
|
14417 | function nearest(arr, target) {
|
14418 | return arr.reduce((pre, cur) => {
|
14419 | return Math.abs(pre - target) < Math.abs(cur - target) ? pre : cur;
|
14420 | });
|
14421 | }
|
14422 | const classPrefix$P = "adm-floating-panel";
|
14423 | const defaultProps$C = {
|
14424 | handleDraggingOfContent: true
|
14425 | };
|
14426 | const FloatingPanel = React$1.forwardRef((p, ref) => {
|
14427 | var _a, _b;
|
14428 | const props = mergeProps(defaultProps$C, p);
|
14429 | const {
|
14430 | anchors
|
14431 | } = props;
|
14432 | const maxHeight = (_a = anchors[anchors.length - 1]) !== null && _a !== void 0 ? _a : window.innerHeight;
|
14433 | const possibles = anchors.map((x) => -x);
|
14434 | const elementRef = React$1.useRef(null);
|
14435 | const headerRef = React$1.useRef(null);
|
14436 | const contentRef = React$1.useRef(null);
|
14437 | const [pulling, setPulling] = React$1.useState(false);
|
14438 | const pullingRef = React$1.useRef(false);
|
14439 | const bounds = {
|
14440 | top: possibles[possibles.length - 1],
|
14441 | bottom: possibles[0]
|
14442 | };
|
14443 | const onHeightChange = useMemoizedFn((_b = props.onHeightChange) !== null && _b !== void 0 ? _b : () => {
|
14444 | });
|
14445 | const [{
|
14446 | y
|
14447 | }, api] = useSpring(() => ({
|
14448 | y: bounds.bottom,
|
14449 | config: {
|
14450 | tension: 300
|
14451 | },
|
14452 | onChange: (result) => {
|
14453 | onHeightChange(-result.value.y, y.isAnimating);
|
14454 | }
|
14455 | }));
|
14456 | useDrag((state) => {
|
14457 | const [, offsetY] = state.offset;
|
14458 | if (state.first) {
|
14459 | const target = state.event.target;
|
14460 | const header = headerRef.current;
|
14461 | if (header === target || (header === null || header === void 0 ? void 0 : header.contains(target))) {
|
14462 | pullingRef.current = true;
|
14463 | } else {
|
14464 | if (!props.handleDraggingOfContent)
|
14465 | return;
|
14466 | const reachedTop = y.goal <= bounds.top;
|
14467 | const content = contentRef.current;
|
14468 | if (!content)
|
14469 | return;
|
14470 | if (reachedTop) {
|
14471 | if (content.scrollTop <= 0 && state.direction[1] > 0) {
|
14472 | pullingRef.current = true;
|
14473 | }
|
14474 | } else {
|
14475 | pullingRef.current = true;
|
14476 | }
|
14477 | }
|
14478 | }
|
14479 | setPulling(pullingRef.current);
|
14480 | if (!pullingRef.current)
|
14481 | return;
|
14482 | const {
|
14483 | event
|
14484 | } = state;
|
14485 | if (event.cancelable && supportsPassive) {
|
14486 | event.preventDefault();
|
14487 | }
|
14488 | event.stopPropagation();
|
14489 | let nextY = offsetY;
|
14490 | if (state.last) {
|
14491 | pullingRef.current = false;
|
14492 | setPulling(false);
|
14493 | nextY = nearest(possibles, offsetY);
|
14494 | }
|
14495 | api.start({
|
14496 | y: nextY
|
14497 | });
|
14498 | }, {
|
14499 | axis: "y",
|
14500 | bounds,
|
14501 | rubberband: true,
|
14502 | from: () => [0, y.get()],
|
14503 | pointer: {
|
14504 | touch: true
|
14505 | },
|
14506 | target: elementRef,
|
14507 | eventOptions: supportsPassive ? {
|
14508 | passive: false
|
14509 | } : void 0
|
14510 | });
|
14511 | React$1.useImperativeHandle(ref, () => ({
|
14512 | setHeight: (height, options) => {
|
14513 | api.start({
|
14514 | y: -height,
|
14515 | immediate: options === null || options === void 0 ? void 0 : options.immediate
|
14516 | });
|
14517 | }
|
14518 | }), [api]);
|
14519 | useLockScroll(elementRef, true);
|
14520 | return withNativeProps(props, React$1.createElement(animated.div, {
|
14521 | ref: elementRef,
|
14522 | className: classPrefix$P,
|
14523 | style: {
|
14524 | height: Math.round(maxHeight),
|
14525 | translateY: y.to((y2) => `calc(100% + (${Math.round(y2)}px))`)
|
14526 | }
|
14527 | }, React$1.createElement("div", {
|
14528 | className: `${classPrefix$P}-mask`,
|
14529 | style: {
|
14530 | display: pulling ? "block" : "none"
|
14531 | }
|
14532 | }), React$1.createElement("div", {
|
14533 | className: `${classPrefix$P}-header`,
|
14534 | ref: headerRef
|
14535 | }, React$1.createElement("div", {
|
14536 | className: `${classPrefix$P}-bar`
|
14537 | })), React$1.createElement("div", {
|
14538 | className: `${classPrefix$P}-content`,
|
14539 | ref: contentRef
|
14540 | }, props.children)));
|
14541 | });
|
14542 | function _extends$1() {
|
14543 | _extends$1 = Object.assign ? Object.assign.bind() : function(target) {
|
14544 | for (var i2 = 1; i2 < arguments.length; i2++) {
|
14545 | var source = arguments[i2];
|
14546 | for (var key in source) {
|
14547 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
14548 | target[key] = source[key];
|
14549 | }
|
14550 | }
|
14551 | }
|
14552 | return target;
|
14553 | };
|
14554 | return _extends$1.apply(this, arguments);
|
14555 | }
|
14556 | function _objectWithoutPropertiesLoose(source, excluded) {
|
14557 | if (source == null)
|
14558 | return {};
|
14559 | var target = {};
|
14560 | var sourceKeys = Object.keys(source);
|
14561 | var key, i2;
|
14562 | for (i2 = 0; i2 < sourceKeys.length; i2++) {
|
14563 | key = sourceKeys[i2];
|
14564 | if (excluded.indexOf(key) >= 0)
|
14565 | continue;
|
14566 | target[key] = source[key];
|
14567 | }
|
14568 | return target;
|
14569 | }
|
14570 | function _objectWithoutProperties(source, excluded) {
|
14571 | if (source == null)
|
14572 | return {};
|
14573 | var target = _objectWithoutPropertiesLoose(source, excluded);
|
14574 | var key, i2;
|
14575 | if (Object.getOwnPropertySymbols) {
|
14576 | var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
14577 | for (i2 = 0; i2 < sourceSymbolKeys.length; i2++) {
|
14578 | key = sourceSymbolKeys[i2];
|
14579 | if (excluded.indexOf(key) >= 0)
|
14580 | continue;
|
14581 | if (!Object.prototype.propertyIsEnumerable.call(source, key))
|
14582 | continue;
|
14583 | target[key] = source[key];
|
14584 | }
|
14585 | }
|
14586 | return target;
|
14587 | }
|
14588 | function _classCallCheck(instance, Constructor) {
|
14589 | if (!(instance instanceof Constructor)) {
|
14590 | throw new TypeError("Cannot call a class as a function");
|
14591 | }
|
14592 | }
|
14593 | function _defineProperties(target, props) {
|
14594 | for (var i2 = 0; i2 < props.length; i2++) {
|
14595 | var descriptor = props[i2];
|
14596 | descriptor.enumerable = descriptor.enumerable || false;
|
14597 | descriptor.configurable = true;
|
14598 | if ("value" in descriptor)
|
14599 | descriptor.writable = true;
|
14600 | Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
14601 | }
|
14602 | }
|
14603 | function _createClass(Constructor, protoProps, staticProps) {
|
14604 | if (protoProps)
|
14605 | _defineProperties(Constructor.prototype, protoProps);
|
14606 | if (staticProps)
|
14607 | _defineProperties(Constructor, staticProps);
|
14608 | Object.defineProperty(Constructor, "prototype", {
|
14609 | writable: false
|
14610 | });
|
14611 | return Constructor;
|
14612 | }
|
14613 | function _assertThisInitialized(self2) {
|
14614 | if (self2 === void 0) {
|
14615 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
14616 | }
|
14617 | return self2;
|
14618 | }
|
14619 | function _setPrototypeOf$1(o, p) {
|
14620 | _setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p2) {
|
14621 | o2.__proto__ = p2;
|
14622 | return o2;
|
14623 | };
|
14624 | return _setPrototypeOf$1(o, p);
|
14625 | }
|
14626 | function _inherits(subClass, superClass) {
|
14627 | if (typeof superClass !== "function" && superClass !== null) {
|
14628 | throw new TypeError("Super expression must either be null or a function");
|
14629 | }
|
14630 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
14631 | constructor: {
|
14632 | value: subClass,
|
14633 | writable: true,
|
14634 | configurable: true
|
14635 | }
|
14636 | });
|
14637 | Object.defineProperty(subClass, "prototype", {
|
14638 | writable: false
|
14639 | });
|
14640 | if (superClass)
|
14641 | _setPrototypeOf$1(subClass, superClass);
|
14642 | }
|
14643 | function _getPrototypeOf$1(o) {
|
14644 | _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o2) {
|
14645 | return o2.__proto__ || Object.getPrototypeOf(o2);
|
14646 | };
|
14647 | return _getPrototypeOf$1(o);
|
14648 | }
|
14649 | function _isNativeReflectConstruct$1() {
|
14650 | if (typeof Reflect === "undefined" || !Reflect.construct)
|
14651 | return false;
|
14652 | if (Reflect.construct.sham)
|
14653 | return false;
|
14654 | if (typeof Proxy === "function")
|
14655 | return true;
|
14656 | try {
|
14657 | Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
14658 | }));
|
14659 | return true;
|
14660 | } catch (e2) {
|
14661 | return false;
|
14662 | }
|
14663 | }
|
14664 | function _possibleConstructorReturn(self2, call2) {
|
14665 | if (call2 && (_typeof$1(call2) === "object" || typeof call2 === "function")) {
|
14666 | return call2;
|
14667 | } else if (call2 !== void 0) {
|
14668 | throw new TypeError("Derived constructors may only return object or undefined");
|
14669 | }
|
14670 | return _assertThisInitialized(self2);
|
14671 | }
|
14672 | function _createSuper(Derived) {
|
14673 | var hasNativeReflectConstruct = _isNativeReflectConstruct$1();
|
14674 | return function _createSuperInternal() {
|
14675 | var Super = _getPrototypeOf$1(Derived), result;
|
14676 | if (hasNativeReflectConstruct) {
|
14677 | var NewTarget = _getPrototypeOf$1(this).constructor;
|
14678 | result = Reflect.construct(Super, arguments, NewTarget);
|
14679 | } else {
|
14680 | result = Super.apply(this, arguments);
|
14681 | }
|
14682 | return _possibleConstructorReturn(this, result);
|
14683 | };
|
14684 | }
|
14685 | function toArray$2(children) {
|
14686 | var option = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
14687 | var ret = [];
|
14688 | React$1.Children.forEach(children, function(child) {
|
14689 | if ((child === void 0 || child === null) && !option.keepEmpty) {
|
14690 | return;
|
14691 | }
|
14692 | if (Array.isArray(child)) {
|
14693 | ret = ret.concat(toArray$2(child));
|
14694 | } else if (reactIsExports.isFragment(child) && child.props) {
|
14695 | ret = ret.concat(toArray$2(child.props.children, option));
|
14696 | } else {
|
14697 | ret.push(child);
|
14698 | }
|
14699 | });
|
14700 | return ret;
|
14701 | }
|
14702 | var HOOK_MARK$1 = "RC_FORM_INTERNAL_HOOKS";
|
14703 | var warningFunc$1 = function warningFunc2() {
|
14704 | warningOnce$1(false, "Can not find FormContext. Please make sure you wrap Field under Form.");
|
14705 | };
|
14706 | var Context$1 = React__namespace.createContext({
|
14707 | getFieldValue: warningFunc$1,
|
14708 | getFieldsValue: warningFunc$1,
|
14709 | getFieldError: warningFunc$1,
|
14710 | getFieldWarning: warningFunc$1,
|
14711 | getFieldsError: warningFunc$1,
|
14712 | isFieldsTouched: warningFunc$1,
|
14713 | isFieldTouched: warningFunc$1,
|
14714 | isFieldValidating: warningFunc$1,
|
14715 | isFieldsValidating: warningFunc$1,
|
14716 | resetFields: warningFunc$1,
|
14717 | setFields: warningFunc$1,
|
14718 | setFieldValue: warningFunc$1,
|
14719 | setFieldsValue: warningFunc$1,
|
14720 | validateFields: warningFunc$1,
|
14721 | submit: warningFunc$1,
|
14722 | getInternalHooks: function getInternalHooks() {
|
14723 | warningFunc$1();
|
14724 | return {
|
14725 | dispatch: warningFunc$1,
|
14726 | initEntityValue: warningFunc$1,
|
14727 | registerField: warningFunc$1,
|
14728 | useSubscribe: warningFunc$1,
|
14729 | setInitialValues: warningFunc$1,
|
14730 | destroyForm: warningFunc$1,
|
14731 | setCallbacks: warningFunc$1,
|
14732 | registerWatch: warningFunc$1,
|
14733 | getFields: warningFunc$1,
|
14734 | setValidateMessages: warningFunc$1,
|
14735 | setPreserve: warningFunc$1,
|
14736 | getInitialValue: warningFunc$1
|
14737 | };
|
14738 | }
|
14739 | });
|
14740 | function toArray$1(value) {
|
14741 | if (value === void 0 || value === null) {
|
14742 | return [];
|
14743 | }
|
14744 | return Array.isArray(value) ? value : [value];
|
14745 | }
|
14746 | function _regeneratorRuntime() {
|
14747 | _regeneratorRuntime = function _regeneratorRuntime2() {
|
14748 | return e2;
|
14749 | };
|
14750 | var t, e2 = {}, r = Object.prototype, n2 = r.hasOwnProperty, o = Object.defineProperty || function(t2, e3, r2) {
|
14751 | t2[e3] = r2.value;
|
14752 | }, i2 = "function" == typeof Symbol ? Symbol : {}, a = i2.iterator || "@@iterator", c = i2.asyncIterator || "@@asyncIterator", u = i2.toStringTag || "@@toStringTag";
|
14753 | function define2(t2, e3, r2) {
|
14754 | return Object.defineProperty(t2, e3, {
|
14755 | value: r2,
|
14756 | enumerable: true,
|
14757 | configurable: true,
|
14758 | writable: true
|
14759 | }), t2[e3];
|
14760 | }
|
14761 | try {
|
14762 | define2({}, "");
|
14763 | } catch (t2) {
|
14764 | define2 = function define3(t3, e3, r2) {
|
14765 | return t3[e3] = r2;
|
14766 | };
|
14767 | }
|
14768 | function wrap(t2, e3, r2, n3) {
|
14769 | var i3 = e3 && e3.prototype instanceof Generator ? e3 : Generator, a2 = Object.create(i3.prototype), c6 = new Context2(n3 || []);
|
14770 | return o(a2, "_invoke", {
|
14771 | value: makeInvokeMethod(t2, r2, c6)
|
14772 | }), a2;
|
14773 | }
|
14774 | function tryCatch(t2, e3, r2) {
|
14775 | try {
|
14776 | return {
|
14777 | type: "normal",
|
14778 | arg: t2.call(e3, r2)
|
14779 | };
|
14780 | } catch (t3) {
|
14781 | return {
|
14782 | type: "throw",
|
14783 | arg: t3
|
14784 | };
|
14785 | }
|
14786 | }
|
14787 | e2.wrap = wrap;
|
14788 | var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {};
|
14789 | function Generator() {
|
14790 | }
|
14791 | function GeneratorFunction() {
|
14792 | }
|
14793 | function GeneratorFunctionPrototype() {
|
14794 | }
|
14795 | var p = {};
|
14796 | define2(p, a, function() {
|
14797 | return this;
|
14798 | });
|
14799 | var d = Object.getPrototypeOf, v = d && d(d(values([])));
|
14800 | v && v !== r && n2.call(v, a) && (p = v);
|
14801 | var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
14802 | function defineIteratorMethods(t2) {
|
14803 | ["next", "throw", "return"].forEach(function(e3) {
|
14804 | define2(t2, e3, function(t3) {
|
14805 | return this._invoke(e3, t3);
|
14806 | });
|
14807 | });
|
14808 | }
|
14809 | function AsyncIterator(t2, e3) {
|
14810 | function invoke(r3, o2, i3, a2) {
|
14811 | var c6 = tryCatch(t2[r3], t2, o2);
|
14812 | if ("throw" !== c6.type) {
|
14813 | var u2 = c6.arg, h2 = u2.value;
|
14814 | return h2 && "object" == _typeof$1(h2) && n2.call(h2, "__await") ? e3.resolve(h2.__await).then(function(t3) {
|
14815 | invoke("next", t3, i3, a2);
|
14816 | }, function(t3) {
|
14817 | invoke("throw", t3, i3, a2);
|
14818 | }) : e3.resolve(h2).then(function(t3) {
|
14819 | u2.value = t3, i3(u2);
|
14820 | }, function(t3) {
|
14821 | return invoke("throw", t3, i3, a2);
|
14822 | });
|
14823 | }
|
14824 | a2(c6.arg);
|
14825 | }
|
14826 | var r2;
|
14827 | o(this, "_invoke", {
|
14828 | value: function value(t3, n3) {
|
14829 | function callInvokeWithMethodAndArg() {
|
14830 | return new e3(function(e4, r3) {
|
14831 | invoke(t3, n3, e4, r3);
|
14832 | });
|
14833 | }
|
14834 | return r2 = r2 ? r2.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
14835 | }
|
14836 | });
|
14837 | }
|
14838 | function makeInvokeMethod(e3, r2, n3) {
|
14839 | var o2 = h;
|
14840 | return function(i3, a2) {
|
14841 | if (o2 === f)
|
14842 | throw new Error("Generator is already running");
|
14843 | if (o2 === s) {
|
14844 | if ("throw" === i3)
|
14845 | throw a2;
|
14846 | return {
|
14847 | value: t,
|
14848 | done: true
|
14849 | };
|
14850 | }
|
14851 | for (n3.method = i3, n3.arg = a2; ; ) {
|
14852 | var c6 = n3.delegate;
|
14853 | if (c6) {
|
14854 | var u2 = maybeInvokeDelegate(c6, n3);
|
14855 | if (u2) {
|
14856 | if (u2 === y)
|
14857 | continue;
|
14858 | return u2;
|
14859 | }
|
14860 | }
|
14861 | if ("next" === n3.method)
|
14862 | n3.sent = n3._sent = n3.arg;
|
14863 | else if ("throw" === n3.method) {
|
14864 | if (o2 === h)
|
14865 | throw o2 = s, n3.arg;
|
14866 | n3.dispatchException(n3.arg);
|
14867 | } else
|
14868 | "return" === n3.method && n3.abrupt("return", n3.arg);
|
14869 | o2 = f;
|
14870 | var p2 = tryCatch(e3, r2, n3);
|
14871 | if ("normal" === p2.type) {
|
14872 | if (o2 = n3.done ? s : l, p2.arg === y)
|
14873 | continue;
|
14874 | return {
|
14875 | value: p2.arg,
|
14876 | done: n3.done
|
14877 | };
|
14878 | }
|
14879 | "throw" === p2.type && (o2 = s, n3.method = "throw", n3.arg = p2.arg);
|
14880 | }
|
14881 | };
|
14882 | }
|
14883 | function maybeInvokeDelegate(e3, r2) {
|
14884 | var n3 = r2.method, o2 = e3.iterator[n3];
|
14885 | if (o2 === t)
|
14886 | return r2.delegate = null, "throw" === n3 && e3.iterator["return"] && (r2.method = "return", r2.arg = t, maybeInvokeDelegate(e3, r2), "throw" === r2.method) || "return" !== n3 && (r2.method = "throw", r2.arg = new TypeError("The iterator does not provide a '" + n3 + "' method")), y;
|
14887 | var i3 = tryCatch(o2, e3.iterator, r2.arg);
|
14888 | if ("throw" === i3.type)
|
14889 | return r2.method = "throw", r2.arg = i3.arg, r2.delegate = null, y;
|
14890 | var a2 = i3.arg;
|
14891 | return a2 ? a2.done ? (r2[e3.resultName] = a2.value, r2.next = e3.nextLoc, "return" !== r2.method && (r2.method = "next", r2.arg = t), r2.delegate = null, y) : a2 : (r2.method = "throw", r2.arg = new TypeError("iterator result is not an object"), r2.delegate = null, y);
|
14892 | }
|
14893 | function pushTryEntry(t2) {
|
14894 | var e3 = {
|
14895 | tryLoc: t2[0]
|
14896 | };
|
14897 | 1 in t2 && (e3.catchLoc = t2[1]), 2 in t2 && (e3.finallyLoc = t2[2], e3.afterLoc = t2[3]), this.tryEntries.push(e3);
|
14898 | }
|
14899 | function resetTryEntry(t2) {
|
14900 | var e3 = t2.completion || {};
|
14901 | e3.type = "normal", delete e3.arg, t2.completion = e3;
|
14902 | }
|
14903 | function Context2(t2) {
|
14904 | this.tryEntries = [{
|
14905 | tryLoc: "root"
|
14906 | }], t2.forEach(pushTryEntry, this), this.reset(true);
|
14907 | }
|
14908 | function values(e3) {
|
14909 | if (e3 || "" === e3) {
|
14910 | var r2 = e3[a];
|
14911 | if (r2)
|
14912 | return r2.call(e3);
|
14913 | if ("function" == typeof e3.next)
|
14914 | return e3;
|
14915 | if (!isNaN(e3.length)) {
|
14916 | var o2 = -1, i3 = function next() {
|
14917 | for (; ++o2 < e3.length; )
|
14918 | if (n2.call(e3, o2))
|
14919 | return next.value = e3[o2], next.done = false, next;
|
14920 | return next.value = t, next.done = true, next;
|
14921 | };
|
14922 | return i3.next = i3;
|
14923 | }
|
14924 | }
|
14925 | throw new TypeError(_typeof$1(e3) + " is not iterable");
|
14926 | }
|
14927 | return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
14928 | value: GeneratorFunctionPrototype,
|
14929 | configurable: true
|
14930 | }), o(GeneratorFunctionPrototype, "constructor", {
|
14931 | value: GeneratorFunction,
|
14932 | configurable: true
|
14933 | }), GeneratorFunction.displayName = define2(GeneratorFunctionPrototype, u, "GeneratorFunction"), e2.isGeneratorFunction = function(t2) {
|
14934 | var e3 = "function" == typeof t2 && t2.constructor;
|
14935 | return !!e3 && (e3 === GeneratorFunction || "GeneratorFunction" === (e3.displayName || e3.name));
|
14936 | }, e2.mark = function(t2) {
|
14937 | return Object.setPrototypeOf ? Object.setPrototypeOf(t2, GeneratorFunctionPrototype) : (t2.__proto__ = GeneratorFunctionPrototype, define2(t2, u, "GeneratorFunction")), t2.prototype = Object.create(g), t2;
|
14938 | }, e2.awrap = function(t2) {
|
14939 | return {
|
14940 | __await: t2
|
14941 | };
|
14942 | }, defineIteratorMethods(AsyncIterator.prototype), define2(AsyncIterator.prototype, c, function() {
|
14943 | return this;
|
14944 | }), e2.AsyncIterator = AsyncIterator, e2.async = function(t2, r2, n3, o2, i3) {
|
14945 | void 0 === i3 && (i3 = Promise);
|
14946 | var a2 = new AsyncIterator(wrap(t2, r2, n3, o2), i3);
|
14947 | return e2.isGeneratorFunction(r2) ? a2 : a2.next().then(function(t3) {
|
14948 | return t3.done ? t3.value : a2.next();
|
14949 | });
|
14950 | }, defineIteratorMethods(g), define2(g, u, "Generator"), define2(g, a, function() {
|
14951 | return this;
|
14952 | }), define2(g, "toString", function() {
|
14953 | return "[object Generator]";
|
14954 | }), e2.keys = function(t2) {
|
14955 | var e3 = Object(t2), r2 = [];
|
14956 | for (var n3 in e3)
|
14957 | r2.push(n3);
|
14958 | return r2.reverse(), function next() {
|
14959 | for (; r2.length; ) {
|
14960 | var t3 = r2.pop();
|
14961 | if (t3 in e3)
|
14962 | return next.value = t3, next.done = false, next;
|
14963 | }
|
14964 | return next.done = true, next;
|
14965 | };
|
14966 | }, e2.values = values, Context2.prototype = {
|
14967 | constructor: Context2,
|
14968 | reset: function reset(e3) {
|
14969 | if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = false, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e3)
|
14970 | for (var r2 in this)
|
14971 | "t" === r2.charAt(0) && n2.call(this, r2) && !isNaN(+r2.slice(1)) && (this[r2] = t);
|
14972 | },
|
14973 | stop: function stop2() {
|
14974 | this.done = true;
|
14975 | var t2 = this.tryEntries[0].completion;
|
14976 | if ("throw" === t2.type)
|
14977 | throw t2.arg;
|
14978 | return this.rval;
|
14979 | },
|
14980 | dispatchException: function dispatchException(e3) {
|
14981 | if (this.done)
|
14982 | throw e3;
|
14983 | var r2 = this;
|
14984 | function handle(n3, o3) {
|
14985 | return a2.type = "throw", a2.arg = e3, r2.next = n3, o3 && (r2.method = "next", r2.arg = t), !!o3;
|
14986 | }
|
14987 | for (var o2 = this.tryEntries.length - 1; o2 >= 0; --o2) {
|
14988 | var i3 = this.tryEntries[o2], a2 = i3.completion;
|
14989 | if ("root" === i3.tryLoc)
|
14990 | return handle("end");
|
14991 | if (i3.tryLoc <= this.prev) {
|
14992 | var c6 = n2.call(i3, "catchLoc"), u2 = n2.call(i3, "finallyLoc");
|
14993 | if (c6 && u2) {
|
14994 | if (this.prev < i3.catchLoc)
|
14995 | return handle(i3.catchLoc, true);
|
14996 | if (this.prev < i3.finallyLoc)
|
14997 | return handle(i3.finallyLoc);
|
14998 | } else if (c6) {
|
14999 | if (this.prev < i3.catchLoc)
|
15000 | return handle(i3.catchLoc, true);
|
15001 | } else {
|
15002 | if (!u2)
|
15003 | throw new Error("try statement without catch or finally");
|
15004 | if (this.prev < i3.finallyLoc)
|
15005 | return handle(i3.finallyLoc);
|
15006 | }
|
15007 | }
|
15008 | }
|
15009 | },
|
15010 | abrupt: function abrupt(t2, e3) {
|
15011 | for (var r2 = this.tryEntries.length - 1; r2 >= 0; --r2) {
|
15012 | var o2 = this.tryEntries[r2];
|
15013 | if (o2.tryLoc <= this.prev && n2.call(o2, "finallyLoc") && this.prev < o2.finallyLoc) {
|
15014 | var i3 = o2;
|
15015 | break;
|
15016 | }
|
15017 | }
|
15018 | i3 && ("break" === t2 || "continue" === t2) && i3.tryLoc <= e3 && e3 <= i3.finallyLoc && (i3 = null);
|
15019 | var a2 = i3 ? i3.completion : {};
|
15020 | return a2.type = t2, a2.arg = e3, i3 ? (this.method = "next", this.next = i3.finallyLoc, y) : this.complete(a2);
|
15021 | },
|
15022 | complete: function complete(t2, e3) {
|
15023 | if ("throw" === t2.type)
|
15024 | throw t2.arg;
|
15025 | return "break" === t2.type || "continue" === t2.type ? this.next = t2.arg : "return" === t2.type ? (this.rval = this.arg = t2.arg, this.method = "return", this.next = "end") : "normal" === t2.type && e3 && (this.next = e3), y;
|
15026 | },
|
15027 | finish: function finish(t2) {
|
15028 | for (var e3 = this.tryEntries.length - 1; e3 >= 0; --e3) {
|
15029 | var r2 = this.tryEntries[e3];
|
15030 | if (r2.finallyLoc === t2)
|
15031 | return this.complete(r2.completion, r2.afterLoc), resetTryEntry(r2), y;
|
15032 | }
|
15033 | },
|
15034 | "catch": function _catch(t2) {
|
15035 | for (var e3 = this.tryEntries.length - 1; e3 >= 0; --e3) {
|
15036 | var r2 = this.tryEntries[e3];
|
15037 | if (r2.tryLoc === t2) {
|
15038 | var n3 = r2.completion;
|
15039 | if ("throw" === n3.type) {
|
15040 | var o2 = n3.arg;
|
15041 | resetTryEntry(r2);
|
15042 | }
|
15043 | return o2;
|
15044 | }
|
15045 | }
|
15046 | throw new Error("illegal catch attempt");
|
15047 | },
|
15048 | delegateYield: function delegateYield(e3, r2, n3) {
|
15049 | return this.delegate = {
|
15050 | iterator: values(e3),
|
15051 | resultName: r2,
|
15052 | nextLoc: n3
|
15053 | }, "next" === this.method && (this.arg = t), y;
|
15054 | }
|
15055 | }, e2;
|
15056 | }
|
15057 | function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
15058 | try {
|
15059 | var info = gen[key](arg);
|
15060 | var value = info.value;
|
15061 | } catch (error) {
|
15062 | reject(error);
|
15063 | return;
|
15064 | }
|
15065 | if (info.done) {
|
15066 | resolve(value);
|
15067 | } else {
|
15068 | Promise.resolve(value).then(_next, _throw);
|
15069 | }
|
15070 | }
|
15071 | function _asyncToGenerator(fn) {
|
15072 | return function() {
|
15073 | var self2 = this, args = arguments;
|
15074 | return new Promise(function(resolve, reject) {
|
15075 | var gen = fn.apply(self2, args);
|
15076 | function _next(value) {
|
15077 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
15078 | }
|
15079 | function _throw(err) {
|
15080 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
15081 | }
|
15082 | _next(void 0);
|
15083 | });
|
15084 | };
|
15085 | }
|
15086 | function _extends() {
|
15087 | _extends = Object.assign ? Object.assign.bind() : function(target) {
|
15088 | for (var i2 = 1; i2 < arguments.length; i2++) {
|
15089 | var source = arguments[i2];
|
15090 | for (var key in source) {
|
15091 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
15092 | target[key] = source[key];
|
15093 | }
|
15094 | }
|
15095 | }
|
15096 | return target;
|
15097 | };
|
15098 | return _extends.apply(this, arguments);
|
15099 | }
|
15100 | function _inheritsLoose(subClass, superClass) {
|
15101 | subClass.prototype = Object.create(superClass.prototype);
|
15102 | subClass.prototype.constructor = subClass;
|
15103 | _setPrototypeOf(subClass, superClass);
|
15104 | }
|
15105 | function _getPrototypeOf(o) {
|
15106 | _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o2) {
|
15107 | return o2.__proto__ || Object.getPrototypeOf(o2);
|
15108 | };
|
15109 | return _getPrototypeOf(o);
|
15110 | }
|
15111 | function _setPrototypeOf(o, p) {
|
15112 | _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p2) {
|
15113 | o2.__proto__ = p2;
|
15114 | return o2;
|
15115 | };
|
15116 | return _setPrototypeOf(o, p);
|
15117 | }
|
15118 | function _isNativeReflectConstruct() {
|
15119 | if (typeof Reflect === "undefined" || !Reflect.construct)
|
15120 | return false;
|
15121 | if (Reflect.construct.sham)
|
15122 | return false;
|
15123 | if (typeof Proxy === "function")
|
15124 | return true;
|
15125 | try {
|
15126 | Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
15127 | }));
|
15128 | return true;
|
15129 | } catch (e2) {
|
15130 | return false;
|
15131 | }
|
15132 | }
|
15133 | function _construct(Parent, args, Class) {
|
15134 | if (_isNativeReflectConstruct()) {
|
15135 | _construct = Reflect.construct.bind();
|
15136 | } else {
|
15137 | _construct = function _construct2(Parent2, args2, Class2) {
|
15138 | var a = [null];
|
15139 | a.push.apply(a, args2);
|
15140 | var Constructor = Function.bind.apply(Parent2, a);
|
15141 | var instance = new Constructor();
|
15142 | if (Class2)
|
15143 | _setPrototypeOf(instance, Class2.prototype);
|
15144 | return instance;
|
15145 | };
|
15146 | }
|
15147 | return _construct.apply(null, arguments);
|
15148 | }
|
15149 | function _isNativeFunction(fn) {
|
15150 | return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
15151 | }
|
15152 | function _wrapNativeSuper(Class) {
|
15153 | var _cache = typeof Map === "function" ? new Map() : void 0;
|
15154 | _wrapNativeSuper = function _wrapNativeSuper2(Class2) {
|
15155 | if (Class2 === null || !_isNativeFunction(Class2))
|
15156 | return Class2;
|
15157 | if (typeof Class2 !== "function") {
|
15158 | throw new TypeError("Super expression must either be null or a function");
|
15159 | }
|
15160 | if (typeof _cache !== "undefined") {
|
15161 | if (_cache.has(Class2))
|
15162 | return _cache.get(Class2);
|
15163 | _cache.set(Class2, Wrapper2);
|
15164 | }
|
15165 | function Wrapper2() {
|
15166 | return _construct(Class2, arguments, _getPrototypeOf(this).constructor);
|
15167 | }
|
15168 | Wrapper2.prototype = Object.create(Class2.prototype, {
|
15169 | constructor: {
|
15170 | value: Wrapper2,
|
15171 | enumerable: false,
|
15172 | writable: true,
|
15173 | configurable: true
|
15174 | }
|
15175 | });
|
15176 | return _setPrototypeOf(Wrapper2, Class2);
|
15177 | };
|
15178 | return _wrapNativeSuper(Class);
|
15179 | }
|
15180 | var formatRegExp = /%[sdj%]/g;
|
15181 | var warning$2 = function warning2() {
|
15182 | };
|
15183 | if (typeof process !== "undefined" && process.env && true && typeof window !== "undefined" && typeof document !== "undefined") {
|
15184 | warning$2 = function warning3(type4, errors) {
|
15185 | if (typeof console !== "undefined" && console.warn && typeof ASYNC_VALIDATOR_NO_WARNING === "undefined") {
|
15186 | if (errors.every(function(e2) {
|
15187 | return typeof e2 === "string";
|
15188 | })) {
|
15189 | console.warn(type4, errors);
|
15190 | }
|
15191 | }
|
15192 | };
|
15193 | }
|
15194 | function convertFieldsError(errors) {
|
15195 | if (!errors || !errors.length)
|
15196 | return null;
|
15197 | var fields = {};
|
15198 | errors.forEach(function(error) {
|
15199 | var field = error.field;
|
15200 | fields[field] = fields[field] || [];
|
15201 | fields[field].push(error);
|
15202 | });
|
15203 | return fields;
|
15204 | }
|
15205 | function format(template) {
|
15206 | for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
15207 | args[_key - 1] = arguments[_key];
|
15208 | }
|
15209 | var i2 = 0;
|
15210 | var len = args.length;
|
15211 | if (typeof template === "function") {
|
15212 | return template.apply(null, args);
|
15213 | }
|
15214 | if (typeof template === "string") {
|
15215 | var str = template.replace(formatRegExp, function(x) {
|
15216 | if (x === "%%") {
|
15217 | return "%";
|
15218 | }
|
15219 | if (i2 >= len) {
|
15220 | return x;
|
15221 | }
|
15222 | switch (x) {
|
15223 | case "%s":
|
15224 | return String(args[i2++]);
|
15225 | case "%d":
|
15226 | return Number(args[i2++]);
|
15227 | case "%j":
|
15228 | try {
|
15229 | return JSON.stringify(args[i2++]);
|
15230 | } catch (_) {
|
15231 | return "[Circular]";
|
15232 | }
|
15233 | break;
|
15234 | default:
|
15235 | return x;
|
15236 | }
|
15237 | });
|
15238 | return str;
|
15239 | }
|
15240 | return template;
|
15241 | }
|
15242 | function isNativeStringType(type4) {
|
15243 | return type4 === "string" || type4 === "url" || type4 === "hex" || type4 === "email" || type4 === "date" || type4 === "pattern";
|
15244 | }
|
15245 | function isEmptyValue(value, type4) {
|
15246 | if (value === void 0 || value === null) {
|
15247 | return true;
|
15248 | }
|
15249 | if (type4 === "array" && Array.isArray(value) && !value.length) {
|
15250 | return true;
|
15251 | }
|
15252 | if (isNativeStringType(type4) && typeof value === "string" && !value) {
|
15253 | return true;
|
15254 | }
|
15255 | return false;
|
15256 | }
|
15257 | function asyncParallelArray(arr, func, callback) {
|
15258 | var results = [];
|
15259 | var total = 0;
|
15260 | var arrLength = arr.length;
|
15261 | function count(errors) {
|
15262 | results.push.apply(results, errors || []);
|
15263 | total++;
|
15264 | if (total === arrLength) {
|
15265 | callback(results);
|
15266 | }
|
15267 | }
|
15268 | arr.forEach(function(a) {
|
15269 | func(a, count);
|
15270 | });
|
15271 | }
|
15272 | function asyncSerialArray(arr, func, callback) {
|
15273 | var index2 = 0;
|
15274 | var arrLength = arr.length;
|
15275 | function next(errors) {
|
15276 | if (errors && errors.length) {
|
15277 | callback(errors);
|
15278 | return;
|
15279 | }
|
15280 | var original = index2;
|
15281 | index2 = index2 + 1;
|
15282 | if (original < arrLength) {
|
15283 | func(arr[original], next);
|
15284 | } else {
|
15285 | callback([]);
|
15286 | }
|
15287 | }
|
15288 | next([]);
|
15289 | }
|
15290 | function flattenObjArr(objArr) {
|
15291 | var ret = [];
|
15292 | Object.keys(objArr).forEach(function(k) {
|
15293 | ret.push.apply(ret, objArr[k] || []);
|
15294 | });
|
15295 | return ret;
|
15296 | }
|
15297 | var AsyncValidationError = function(_Error) {
|
15298 | _inheritsLoose(AsyncValidationError2, _Error);
|
15299 | function AsyncValidationError2(errors, fields) {
|
15300 | var _this;
|
15301 | _this = _Error.call(this, "Async Validation Error") || this;
|
15302 | _this.errors = errors;
|
15303 | _this.fields = fields;
|
15304 | return _this;
|
15305 | }
|
15306 | return AsyncValidationError2;
|
15307 | }( _wrapNativeSuper(Error));
|
15308 | function asyncMap(objArr, option, func, callback, source) {
|
15309 | if (option.first) {
|
15310 | var _pending = new Promise(function(resolve, reject) {
|
15311 | var next = function next2(errors) {
|
15312 | callback(errors);
|
15313 | return errors.length ? reject(new AsyncValidationError(errors, convertFieldsError(errors))) : resolve(source);
|
15314 | };
|
15315 | var flattenArr = flattenObjArr(objArr);
|
15316 | asyncSerialArray(flattenArr, func, next);
|
15317 | });
|
15318 | _pending["catch"](function(e2) {
|
15319 | return e2;
|
15320 | });
|
15321 | return _pending;
|
15322 | }
|
15323 | var firstFields = option.firstFields === true ? Object.keys(objArr) : option.firstFields || [];
|
15324 | var objArrKeys = Object.keys(objArr);
|
15325 | var objArrLength = objArrKeys.length;
|
15326 | var total = 0;
|
15327 | var results = [];
|
15328 | var pending = new Promise(function(resolve, reject) {
|
15329 | var next = function next2(errors) {
|
15330 | results.push.apply(results, errors);
|
15331 | total++;
|
15332 | if (total === objArrLength) {
|
15333 | callback(results);
|
15334 | return results.length ? reject(new AsyncValidationError(results, convertFieldsError(results))) : resolve(source);
|
15335 | }
|
15336 | };
|
15337 | if (!objArrKeys.length) {
|
15338 | callback(results);
|
15339 | resolve(source);
|
15340 | }
|
15341 | objArrKeys.forEach(function(key) {
|
15342 | var arr = objArr[key];
|
15343 | if (firstFields.indexOf(key) !== -1) {
|
15344 | asyncSerialArray(arr, func, next);
|
15345 | } else {
|
15346 | asyncParallelArray(arr, func, next);
|
15347 | }
|
15348 | });
|
15349 | });
|
15350 | pending["catch"](function(e2) {
|
15351 | return e2;
|
15352 | });
|
15353 | return pending;
|
15354 | }
|
15355 | function isErrorObj(obj) {
|
15356 | return !!(obj && obj.message !== void 0);
|
15357 | }
|
15358 | function getValue$1(value, path) {
|
15359 | var v = value;
|
15360 | for (var i2 = 0; i2 < path.length; i2++) {
|
15361 | if (v == void 0) {
|
15362 | return v;
|
15363 | }
|
15364 | v = v[path[i2]];
|
15365 | }
|
15366 | return v;
|
15367 | }
|
15368 | function complementError(rule, source) {
|
15369 | return function(oe) {
|
15370 | var fieldValue;
|
15371 | if (rule.fullFields) {
|
15372 | fieldValue = getValue$1(source, rule.fullFields);
|
15373 | } else {
|
15374 | fieldValue = source[oe.field || rule.fullField];
|
15375 | }
|
15376 | if (isErrorObj(oe)) {
|
15377 | oe.field = oe.field || rule.fullField;
|
15378 | oe.fieldValue = fieldValue;
|
15379 | return oe;
|
15380 | }
|
15381 | return {
|
15382 | message: typeof oe === "function" ? oe() : oe,
|
15383 | fieldValue,
|
15384 | field: oe.field || rule.fullField
|
15385 | };
|
15386 | };
|
15387 | }
|
15388 | function deepMerge(target, source) {
|
15389 | if (source) {
|
15390 | for (var s in source) {
|
15391 | if (source.hasOwnProperty(s)) {
|
15392 | var value = source[s];
|
15393 | if (typeof value === "object" && typeof target[s] === "object") {
|
15394 | target[s] = _extends({}, target[s], value);
|
15395 | } else {
|
15396 | target[s] = value;
|
15397 | }
|
15398 | }
|
15399 | }
|
15400 | }
|
15401 | return target;
|
15402 | }
|
15403 | var required$1 = function required(rule, value, source, errors, options, type4) {
|
15404 | if (rule.required && (!source.hasOwnProperty(rule.field) || isEmptyValue(value, type4 || rule.type))) {
|
15405 | errors.push(format(options.messages.required, rule.fullField));
|
15406 | }
|
15407 | };
|
15408 | var whitespace = function whitespace2(rule, value, source, errors, options) {
|
15409 | if (/^\s+$/.test(value) || value === "") {
|
15410 | errors.push(format(options.messages.whitespace, rule.fullField));
|
15411 | }
|
15412 | };
|
15413 | var urlReg;
|
15414 | var getUrlRegex = function() {
|
15415 | if (urlReg) {
|
15416 | return urlReg;
|
15417 | }
|
15418 | var word = "[a-fA-F\\d:]";
|
15419 | var b = function b2(options) {
|
15420 | return options && options.includeBoundaries ? "(?:(?<=\\s|^)(?=" + word + ")|(?<=" + word + ")(?=\\s|$))" : "";
|
15421 | };
|
15422 | var v4 = "(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}";
|
15423 | var v6seg = "[a-fA-F\\d]{1,4}";
|
15424 | var v6 = ("\n(?:\n(?:" + v6seg + ":){7}(?:" + v6seg + "|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:" + v6seg + ":){6}(?:" + v4 + "|:" + v6seg + "|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:" + v6seg + ":){5}(?::" + v4 + "|(?::" + v6seg + "){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:" + v6seg + ":){4}(?:(?::" + v6seg + "){0,1}:" + v4 + "|(?::" + v6seg + "){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:" + v6seg + ":){3}(?:(?::" + v6seg + "){0,2}:" + v4 + "|(?::" + v6seg + "){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:" + v6seg + ":){2}(?:(?::" + v6seg + "){0,3}:" + v4 + "|(?::" + v6seg + "){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:" + v6seg + ":){1}(?:(?::" + v6seg + "){0,4}:" + v4 + "|(?::" + v6seg + "){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::" + v6seg + "){0,5}:" + v4 + "|(?::" + v6seg + "){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n").replace(/\s*\/\/.*$/gm, "").replace(/\n/g, "").trim();
|
15425 | var v46Exact = new RegExp("(?:^" + v4 + "$)|(?:^" + v6 + "$)");
|
15426 | var v4exact = new RegExp("^" + v4 + "$");
|
15427 | var v6exact = new RegExp("^" + v6 + "$");
|
15428 | var ip = function ip2(options) {
|
15429 | return options && options.exact ? v46Exact : new RegExp("(?:" + b(options) + v4 + b(options) + ")|(?:" + b(options) + v6 + b(options) + ")", "g");
|
15430 | };
|
15431 | ip.v4 = function(options) {
|
15432 | return options && options.exact ? v4exact : new RegExp("" + b(options) + v4 + b(options), "g");
|
15433 | };
|
15434 | ip.v6 = function(options) {
|
15435 | return options && options.exact ? v6exact : new RegExp("" + b(options) + v6 + b(options), "g");
|
15436 | };
|
15437 | var protocol = "(?:(?:[a-z]+:)?//)";
|
15438 | var auth = "(?:\\S+(?::\\S*)?@)?";
|
15439 | var ipv4 = ip.v4().source;
|
15440 | var ipv6 = ip.v6().source;
|
15441 | var host2 = "(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)";
|
15442 | var domain = "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*";
|
15443 | var tld = "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))";
|
15444 | var port = "(?::\\d{2,5})?";
|
15445 | var path = '(?:[/?#][^\\s"]*)?';
|
15446 | var regex = "(?:" + protocol + "|www\\.)" + auth + "(?:localhost|" + ipv4 + "|" + ipv6 + "|" + host2 + domain + tld + ")" + port + path;
|
15447 | urlReg = new RegExp("(?:^" + regex + "$)", "i");
|
15448 | return urlReg;
|
15449 | };
|
15450 | var pattern$2 = {
|
15451 |
|
15452 | email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,
|
15453 |
|
15454 |
|
15455 |
|
15456 |
|
15457 | hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i
|
15458 | };
|
15459 | var types = {
|
15460 | integer: function integer(value) {
|
15461 | return types.number(value) && parseInt(value, 10) === value;
|
15462 | },
|
15463 | "float": function float(value) {
|
15464 | return types.number(value) && !types.integer(value);
|
15465 | },
|
15466 | array: function array(value) {
|
15467 | return Array.isArray(value);
|
15468 | },
|
15469 | regexp: function regexp(value) {
|
15470 | if (value instanceof RegExp) {
|
15471 | return true;
|
15472 | }
|
15473 | try {
|
15474 | return !!new RegExp(value);
|
15475 | } catch (e2) {
|
15476 | return false;
|
15477 | }
|
15478 | },
|
15479 | date: function date(value) {
|
15480 | return typeof value.getTime === "function" && typeof value.getMonth === "function" && typeof value.getYear === "function" && !isNaN(value.getTime());
|
15481 | },
|
15482 | number: function number(value) {
|
15483 | if (isNaN(value)) {
|
15484 | return false;
|
15485 | }
|
15486 | return typeof value === "number";
|
15487 | },
|
15488 | object: function object(value) {
|
15489 | return typeof value === "object" && !types.array(value);
|
15490 | },
|
15491 | method: function method(value) {
|
15492 | return typeof value === "function";
|
15493 | },
|
15494 | email: function email(value) {
|
15495 | return typeof value === "string" && value.length <= 320 && !!value.match(pattern$2.email);
|
15496 | },
|
15497 | url: function url(value) {
|
15498 | return typeof value === "string" && value.length <= 2048 && !!value.match(getUrlRegex());
|
15499 | },
|
15500 | hex: function hex(value) {
|
15501 | return typeof value === "string" && !!value.match(pattern$2.hex);
|
15502 | }
|
15503 | };
|
15504 | var type$1 = function type(rule, value, source, errors, options) {
|
15505 | if (rule.required && value === void 0) {
|
15506 | required$1(rule, value, source, errors, options);
|
15507 | return;
|
15508 | }
|
15509 | var custom = ["integer", "float", "array", "regexp", "object", "method", "email", "number", "date", "url", "hex"];
|
15510 | var ruleType = rule.type;
|
15511 | if (custom.indexOf(ruleType) > -1) {
|
15512 | if (!types[ruleType](value)) {
|
15513 | errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
|
15514 | }
|
15515 | } else if (ruleType && typeof value !== rule.type) {
|
15516 | errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
|
15517 | }
|
15518 | };
|
15519 | var range = function range2(rule, value, source, errors, options) {
|
15520 | var len = typeof rule.len === "number";
|
15521 | var min2 = typeof rule.min === "number";
|
15522 | var max2 = typeof rule.max === "number";
|
15523 | var spRegexp = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
15524 | var val = value;
|
15525 | var key = null;
|
15526 | var num = typeof value === "number";
|
15527 | var str = typeof value === "string";
|
15528 | var arr = Array.isArray(value);
|
15529 | if (num) {
|
15530 | key = "number";
|
15531 | } else if (str) {
|
15532 | key = "string";
|
15533 | } else if (arr) {
|
15534 | key = "array";
|
15535 | }
|
15536 | if (!key) {
|
15537 | return false;
|
15538 | }
|
15539 | if (arr) {
|
15540 | val = value.length;
|
15541 | }
|
15542 | if (str) {
|
15543 | val = value.replace(spRegexp, "_").length;
|
15544 | }
|
15545 | if (len) {
|
15546 | if (val !== rule.len) {
|
15547 | errors.push(format(options.messages[key].len, rule.fullField, rule.len));
|
15548 | }
|
15549 | } else if (min2 && !max2 && val < rule.min) {
|
15550 | errors.push(format(options.messages[key].min, rule.fullField, rule.min));
|
15551 | } else if (max2 && !min2 && val > rule.max) {
|
15552 | errors.push(format(options.messages[key].max, rule.fullField, rule.max));
|
15553 | } else if (min2 && max2 && (val < rule.min || val > rule.max)) {
|
15554 | errors.push(format(options.messages[key].range, rule.fullField, rule.min, rule.max));
|
15555 | }
|
15556 | };
|
15557 | var ENUM$1 = "enum";
|
15558 | var enumerable$1 = function enumerable(rule, value, source, errors, options) {
|
15559 | rule[ENUM$1] = Array.isArray(rule[ENUM$1]) ? rule[ENUM$1] : [];
|
15560 | if (rule[ENUM$1].indexOf(value) === -1) {
|
15561 | errors.push(format(options.messages[ENUM$1], rule.fullField, rule[ENUM$1].join(", ")));
|
15562 | }
|
15563 | };
|
15564 | var pattern$1 = function pattern(rule, value, source, errors, options) {
|
15565 | if (rule.pattern) {
|
15566 | if (rule.pattern instanceof RegExp) {
|
15567 | rule.pattern.lastIndex = 0;
|
15568 | if (!rule.pattern.test(value)) {
|
15569 | errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
|
15570 | }
|
15571 | } else if (typeof rule.pattern === "string") {
|
15572 | var _pattern = new RegExp(rule.pattern);
|
15573 | if (!_pattern.test(value)) {
|
15574 | errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
|
15575 | }
|
15576 | }
|
15577 | }
|
15578 | };
|
15579 | var rules = {
|
15580 | required: required$1,
|
15581 | whitespace,
|
15582 | type: type$1,
|
15583 | range,
|
15584 | "enum": enumerable$1,
|
15585 | pattern: pattern$1
|
15586 | };
|
15587 | var string = function string2(rule, value, callback, source, options) {
|
15588 | var errors = [];
|
15589 | var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
15590 | if (validate) {
|
15591 | if (isEmptyValue(value, "string") && !rule.required) {
|
15592 | return callback();
|
15593 | }
|
15594 | rules.required(rule, value, source, errors, options, "string");
|
15595 | if (!isEmptyValue(value, "string")) {
|
15596 | rules.type(rule, value, source, errors, options);
|
15597 | rules.range(rule, value, source, errors, options);
|
15598 | rules.pattern(rule, value, source, errors, options);
|
15599 | if (rule.whitespace === true) {
|
15600 | rules.whitespace(rule, value, source, errors, options);
|
15601 | }
|
15602 | }
|
15603 | }
|
15604 | callback(errors);
|
15605 | };
|
15606 | var method2 = function method3(rule, value, callback, source, options) {
|
15607 | var errors = [];
|
15608 | var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
15609 | if (validate) {
|
15610 | if (isEmptyValue(value) && !rule.required) {
|
15611 | return callback();
|
15612 | }
|
15613 | rules.required(rule, value, source, errors, options);
|
15614 | if (value !== void 0) {
|
15615 | rules.type(rule, value, source, errors, options);
|
15616 | }
|
15617 | }
|
15618 | callback(errors);
|
15619 | };
|
15620 | var number2 = function number3(rule, value, callback, source, options) {
|
15621 | var errors = [];
|
15622 | var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
15623 | if (validate) {
|
15624 | if (value === "") {
|
15625 | value = void 0;
|
15626 | }
|
15627 | if (isEmptyValue(value) && !rule.required) {
|
15628 | return callback();
|
15629 | }
|
15630 | rules.required(rule, value, source, errors, options);
|
15631 | if (value !== void 0) {
|
15632 | rules.type(rule, value, source, errors, options);
|
15633 | rules.range(rule, value, source, errors, options);
|
15634 | }
|
15635 | }
|
15636 | callback(errors);
|
15637 | };
|
15638 | var _boolean = function _boolean2(rule, value, callback, source, options) {
|
15639 | var errors = [];
|
15640 | var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
15641 | if (validate) {
|
15642 | if (isEmptyValue(value) && !rule.required) {
|
15643 | return callback();
|
15644 | }
|
15645 | rules.required(rule, value, source, errors, options);
|
15646 | if (value !== void 0) {
|
15647 | rules.type(rule, value, source, errors, options);
|
15648 | }
|
15649 | }
|
15650 | callback(errors);
|
15651 | };
|
15652 | var regexp2 = function regexp3(rule, value, callback, source, options) {
|
15653 | var errors = [];
|
15654 | var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
15655 | if (validate) {
|
15656 | if (isEmptyValue(value) && !rule.required) {
|
15657 | return callback();
|
15658 | }
|
15659 | rules.required(rule, value, source, errors, options);
|
15660 | if (!isEmptyValue(value)) {
|
15661 | rules.type(rule, value, source, errors, options);
|
15662 | }
|
15663 | }
|
15664 | callback(errors);
|
15665 | };
|
15666 | var integer2 = function integer3(rule, value, callback, source, options) {
|
15667 | var errors = [];
|
15668 | var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
15669 | if (validate) {
|
15670 | if (isEmptyValue(value) && !rule.required) {
|
15671 | return callback();
|
15672 | }
|
15673 | rules.required(rule, value, source, errors, options);
|
15674 | if (value !== void 0) {
|
15675 | rules.type(rule, value, source, errors, options);
|
15676 | rules.range(rule, value, source, errors, options);
|
15677 | }
|
15678 | }
|
15679 | callback(errors);
|
15680 | };
|
15681 | var floatFn = function floatFn2(rule, value, callback, source, options) {
|
15682 | var errors = [];
|
15683 | var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
15684 | if (validate) {
|
15685 | if (isEmptyValue(value) && !rule.required) {
|
15686 | return callback();
|
15687 | }
|
15688 | rules.required(rule, value, source, errors, options);
|
15689 | if (value !== void 0) {
|
15690 | rules.type(rule, value, source, errors, options);
|
15691 | rules.range(rule, value, source, errors, options);
|
15692 | }
|
15693 | }
|
15694 | callback(errors);
|
15695 | };
|
15696 | var array2 = function array3(rule, value, callback, source, options) {
|
15697 | var errors = [];
|
15698 | var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
15699 | if (validate) {
|
15700 | if ((value === void 0 || value === null) && !rule.required) {
|
15701 | return callback();
|
15702 | }
|
15703 | rules.required(rule, value, source, errors, options, "array");
|
15704 | if (value !== void 0 && value !== null) {
|
15705 | rules.type(rule, value, source, errors, options);
|
15706 | rules.range(rule, value, source, errors, options);
|
15707 | }
|
15708 | }
|
15709 | callback(errors);
|
15710 | };
|
15711 | var object2 = function object3(rule, value, callback, source, options) {
|
15712 | var errors = [];
|
15713 | var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
15714 | if (validate) {
|
15715 | if (isEmptyValue(value) && !rule.required) {
|
15716 | return callback();
|
15717 | }
|
15718 | rules.required(rule, value, source, errors, options);
|
15719 | if (value !== void 0) {
|
15720 | rules.type(rule, value, source, errors, options);
|
15721 | }
|
15722 | }
|
15723 | callback(errors);
|
15724 | };
|
15725 | var ENUM = "enum";
|
15726 | var enumerable2 = function enumerable3(rule, value, callback, source, options) {
|
15727 | var errors = [];
|
15728 | var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
15729 | if (validate) {
|
15730 | if (isEmptyValue(value) && !rule.required) {
|
15731 | return callback();
|
15732 | }
|
15733 | rules.required(rule, value, source, errors, options);
|
15734 | if (value !== void 0) {
|
15735 | rules[ENUM](rule, value, source, errors, options);
|
15736 | }
|
15737 | }
|
15738 | callback(errors);
|
15739 | };
|
15740 | var pattern2 = function pattern3(rule, value, callback, source, options) {
|
15741 | var errors = [];
|
15742 | var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
15743 | if (validate) {
|
15744 | if (isEmptyValue(value, "string") && !rule.required) {
|
15745 | return callback();
|
15746 | }
|
15747 | rules.required(rule, value, source, errors, options);
|
15748 | if (!isEmptyValue(value, "string")) {
|
15749 | rules.pattern(rule, value, source, errors, options);
|
15750 | }
|
15751 | }
|
15752 | callback(errors);
|
15753 | };
|
15754 | var date2 = function date3(rule, value, callback, source, options) {
|
15755 | var errors = [];
|
15756 | var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
15757 | if (validate) {
|
15758 | if (isEmptyValue(value, "date") && !rule.required) {
|
15759 | return callback();
|
15760 | }
|
15761 | rules.required(rule, value, source, errors, options);
|
15762 | if (!isEmptyValue(value, "date")) {
|
15763 | var dateObject;
|
15764 | if (value instanceof Date) {
|
15765 | dateObject = value;
|
15766 | } else {
|
15767 | dateObject = new Date(value);
|
15768 | }
|
15769 | rules.type(rule, dateObject, source, errors, options);
|
15770 | if (dateObject) {
|
15771 | rules.range(rule, dateObject.getTime(), source, errors, options);
|
15772 | }
|
15773 | }
|
15774 | }
|
15775 | callback(errors);
|
15776 | };
|
15777 | var required2 = function required3(rule, value, callback, source, options) {
|
15778 | var errors = [];
|
15779 | var type4 = Array.isArray(value) ? "array" : typeof value;
|
15780 | rules.required(rule, value, source, errors, options, type4);
|
15781 | callback(errors);
|
15782 | };
|
15783 | var type2 = function type3(rule, value, callback, source, options) {
|
15784 | var ruleType = rule.type;
|
15785 | var errors = [];
|
15786 | var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
15787 | if (validate) {
|
15788 | if (isEmptyValue(value, ruleType) && !rule.required) {
|
15789 | return callback();
|
15790 | }
|
15791 | rules.required(rule, value, source, errors, options, ruleType);
|
15792 | if (!isEmptyValue(value, ruleType)) {
|
15793 | rules.type(rule, value, source, errors, options);
|
15794 | }
|
15795 | }
|
15796 | callback(errors);
|
15797 | };
|
15798 | var any = function any2(rule, value, callback, source, options) {
|
15799 | var errors = [];
|
15800 | var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
15801 | if (validate) {
|
15802 | if (isEmptyValue(value) && !rule.required) {
|
15803 | return callback();
|
15804 | }
|
15805 | rules.required(rule, value, source, errors, options);
|
15806 | }
|
15807 | callback(errors);
|
15808 | };
|
15809 | var validators = {
|
15810 | string,
|
15811 | method: method2,
|
15812 | number: number2,
|
15813 | "boolean": _boolean,
|
15814 | regexp: regexp2,
|
15815 | integer: integer2,
|
15816 | "float": floatFn,
|
15817 | array: array2,
|
15818 | object: object2,
|
15819 | "enum": enumerable2,
|
15820 | pattern: pattern2,
|
15821 | date: date2,
|
15822 | url: type2,
|
15823 | hex: type2,
|
15824 | email: type2,
|
15825 | required: required2,
|
15826 | any
|
15827 | };
|
15828 | function newMessages() {
|
15829 | return {
|
15830 | "default": "Validation error on field %s",
|
15831 | required: "%s is required",
|
15832 | "enum": "%s must be one of %s",
|
15833 | whitespace: "%s cannot be empty",
|
15834 | date: {
|
15835 | format: "%s date %s is invalid for format %s",
|
15836 | parse: "%s date could not be parsed, %s is invalid ",
|
15837 | invalid: "%s date %s is invalid"
|
15838 | },
|
15839 | types: {
|
15840 | string: "%s is not a %s",
|
15841 | method: "%s is not a %s (function)",
|
15842 | array: "%s is not an %s",
|
15843 | object: "%s is not an %s",
|
15844 | number: "%s is not a %s",
|
15845 | date: "%s is not a %s",
|
15846 | "boolean": "%s is not a %s",
|
15847 | integer: "%s is not an %s",
|
15848 | "float": "%s is not a %s",
|
15849 | regexp: "%s is not a valid %s",
|
15850 | email: "%s is not a valid %s",
|
15851 | url: "%s is not a valid %s",
|
15852 | hex: "%s is not a valid %s"
|
15853 | },
|
15854 | string: {
|
15855 | len: "%s must be exactly %s characters",
|
15856 | min: "%s must be at least %s characters",
|
15857 | max: "%s cannot be longer than %s characters",
|
15858 | range: "%s must be between %s and %s characters"
|
15859 | },
|
15860 | number: {
|
15861 | len: "%s must equal %s",
|
15862 | min: "%s cannot be less than %s",
|
15863 | max: "%s cannot be greater than %s",
|
15864 | range: "%s must be between %s and %s"
|
15865 | },
|
15866 | array: {
|
15867 | len: "%s must be exactly %s in length",
|
15868 | min: "%s cannot be less than %s in length",
|
15869 | max: "%s cannot be greater than %s in length",
|
15870 | range: "%s must be between %s and %s in length"
|
15871 | },
|
15872 | pattern: {
|
15873 | mismatch: "%s value %s does not match pattern %s"
|
15874 | },
|
15875 | clone: function clone() {
|
15876 | var cloned = JSON.parse(JSON.stringify(this));
|
15877 | cloned.clone = this.clone;
|
15878 | return cloned;
|
15879 | }
|
15880 | };
|
15881 | }
|
15882 | var messages = newMessages();
|
15883 | var Schema = function() {
|
15884 | function Schema2(descriptor) {
|
15885 | this.rules = null;
|
15886 | this._messages = messages;
|
15887 | this.define(descriptor);
|
15888 | }
|
15889 | var _proto = Schema2.prototype;
|
15890 | _proto.define = function define2(rules2) {
|
15891 | var _this = this;
|
15892 | if (!rules2) {
|
15893 | throw new Error("Cannot configure a schema with no rules");
|
15894 | }
|
15895 | if (typeof rules2 !== "object" || Array.isArray(rules2)) {
|
15896 | throw new Error("Rules must be an object");
|
15897 | }
|
15898 | this.rules = {};
|
15899 | Object.keys(rules2).forEach(function(name) {
|
15900 | var item = rules2[name];
|
15901 | _this.rules[name] = Array.isArray(item) ? item : [item];
|
15902 | });
|
15903 | };
|
15904 | _proto.messages = function messages2(_messages) {
|
15905 | if (_messages) {
|
15906 | this._messages = deepMerge(newMessages(), _messages);
|
15907 | }
|
15908 | return this._messages;
|
15909 | };
|
15910 | _proto.validate = function validate(source_, o, oc) {
|
15911 | var _this2 = this;
|
15912 | if (o === void 0) {
|
15913 | o = {};
|
15914 | }
|
15915 | if (oc === void 0) {
|
15916 | oc = function oc2() {
|
15917 | };
|
15918 | }
|
15919 | var source = source_;
|
15920 | var options = o;
|
15921 | var callback = oc;
|
15922 | if (typeof options === "function") {
|
15923 | callback = options;
|
15924 | options = {};
|
15925 | }
|
15926 | if (!this.rules || Object.keys(this.rules).length === 0) {
|
15927 | if (callback) {
|
15928 | callback(null, source);
|
15929 | }
|
15930 | return Promise.resolve(source);
|
15931 | }
|
15932 | function complete(results) {
|
15933 | var errors = [];
|
15934 | var fields = {};
|
15935 | function add(e2) {
|
15936 | if (Array.isArray(e2)) {
|
15937 | var _errors;
|
15938 | errors = (_errors = errors).concat.apply(_errors, e2);
|
15939 | } else {
|
15940 | errors.push(e2);
|
15941 | }
|
15942 | }
|
15943 | for (var i2 = 0; i2 < results.length; i2++) {
|
15944 | add(results[i2]);
|
15945 | }
|
15946 | if (!errors.length) {
|
15947 | callback(null, source);
|
15948 | } else {
|
15949 | fields = convertFieldsError(errors);
|
15950 | callback(errors, fields);
|
15951 | }
|
15952 | }
|
15953 | if (options.messages) {
|
15954 | var messages$1 = this.messages();
|
15955 | if (messages$1 === messages) {
|
15956 | messages$1 = newMessages();
|
15957 | }
|
15958 | deepMerge(messages$1, options.messages);
|
15959 | options.messages = messages$1;
|
15960 | } else {
|
15961 | options.messages = this.messages();
|
15962 | }
|
15963 | var series = {};
|
15964 | var keys = options.keys || Object.keys(this.rules);
|
15965 | keys.forEach(function(z) {
|
15966 | var arr = _this2.rules[z];
|
15967 | var value = source[z];
|
15968 | arr.forEach(function(r) {
|
15969 | var rule = r;
|
15970 | if (typeof rule.transform === "function") {
|
15971 | if (source === source_) {
|
15972 | source = _extends({}, source);
|
15973 | }
|
15974 | value = source[z] = rule.transform(value);
|
15975 | }
|
15976 | if (typeof rule === "function") {
|
15977 | rule = {
|
15978 | validator: rule
|
15979 | };
|
15980 | } else {
|
15981 | rule = _extends({}, rule);
|
15982 | }
|
15983 | rule.validator = _this2.getValidationMethod(rule);
|
15984 | if (!rule.validator) {
|
15985 | return;
|
15986 | }
|
15987 | rule.field = z;
|
15988 | rule.fullField = rule.fullField || z;
|
15989 | rule.type = _this2.getType(rule);
|
15990 | series[z] = series[z] || [];
|
15991 | series[z].push({
|
15992 | rule,
|
15993 | value,
|
15994 | source,
|
15995 | field: z
|
15996 | });
|
15997 | });
|
15998 | });
|
15999 | var errorFields = {};
|
16000 | return asyncMap(series, options, function(data, doIt) {
|
16001 | var rule = data.rule;
|
16002 | var deep = (rule.type === "object" || rule.type === "array") && (typeof rule.fields === "object" || typeof rule.defaultField === "object");
|
16003 | deep = deep && (rule.required || !rule.required && data.value);
|
16004 | rule.field = data.field;
|
16005 | function addFullField(key, schema) {
|
16006 | return _extends({}, schema, {
|
16007 | fullField: rule.fullField + "." + key,
|
16008 | fullFields: rule.fullFields ? [].concat(rule.fullFields, [key]) : [key]
|
16009 | });
|
16010 | }
|
16011 | function cb(e2) {
|
16012 | if (e2 === void 0) {
|
16013 | e2 = [];
|
16014 | }
|
16015 | var errorList = Array.isArray(e2) ? e2 : [e2];
|
16016 | if (!options.suppressWarning && errorList.length) {
|
16017 | Schema2.warning("async-validator:", errorList);
|
16018 | }
|
16019 | if (errorList.length && rule.message !== void 0) {
|
16020 | errorList = [].concat(rule.message);
|
16021 | }
|
16022 | var filledErrors = errorList.map(complementError(rule, source));
|
16023 | if (options.first && filledErrors.length) {
|
16024 | errorFields[rule.field] = 1;
|
16025 | return doIt(filledErrors);
|
16026 | }
|
16027 | if (!deep) {
|
16028 | doIt(filledErrors);
|
16029 | } else {
|
16030 | if (rule.required && !data.value) {
|
16031 | if (rule.message !== void 0) {
|
16032 | filledErrors = [].concat(rule.message).map(complementError(rule, source));
|
16033 | } else if (options.error) {
|
16034 | filledErrors = [options.error(rule, format(options.messages.required, rule.field))];
|
16035 | }
|
16036 | return doIt(filledErrors);
|
16037 | }
|
16038 | var fieldsSchema = {};
|
16039 | if (rule.defaultField) {
|
16040 | Object.keys(data.value).map(function(key) {
|
16041 | fieldsSchema[key] = rule.defaultField;
|
16042 | });
|
16043 | }
|
16044 | fieldsSchema = _extends({}, fieldsSchema, data.rule.fields);
|
16045 | var paredFieldsSchema = {};
|
16046 | Object.keys(fieldsSchema).forEach(function(field) {
|
16047 | var fieldSchema = fieldsSchema[field];
|
16048 | var fieldSchemaList = Array.isArray(fieldSchema) ? fieldSchema : [fieldSchema];
|
16049 | paredFieldsSchema[field] = fieldSchemaList.map(addFullField.bind(null, field));
|
16050 | });
|
16051 | var schema = new Schema2(paredFieldsSchema);
|
16052 | schema.messages(options.messages);
|
16053 | if (data.rule.options) {
|
16054 | data.rule.options.messages = options.messages;
|
16055 | data.rule.options.error = options.error;
|
16056 | }
|
16057 | schema.validate(data.value, data.rule.options || options, function(errs) {
|
16058 | var finalErrors = [];
|
16059 | if (filledErrors && filledErrors.length) {
|
16060 | finalErrors.push.apply(finalErrors, filledErrors);
|
16061 | }
|
16062 | if (errs && errs.length) {
|
16063 | finalErrors.push.apply(finalErrors, errs);
|
16064 | }
|
16065 | doIt(finalErrors.length ? finalErrors : null);
|
16066 | });
|
16067 | }
|
16068 | }
|
16069 | var res;
|
16070 | if (rule.asyncValidator) {
|
16071 | res = rule.asyncValidator(rule, data.value, cb, data.source, options);
|
16072 | } else if (rule.validator) {
|
16073 | try {
|
16074 | res = rule.validator(rule, data.value, cb, data.source, options);
|
16075 | } catch (error) {
|
16076 | console.error == null ? void 0 : console.error(error);
|
16077 | if (!options.suppressValidatorError) {
|
16078 | setTimeout(function() {
|
16079 | throw error;
|
16080 | }, 0);
|
16081 | }
|
16082 | cb(error.message);
|
16083 | }
|
16084 | if (res === true) {
|
16085 | cb();
|
16086 | } else if (res === false) {
|
16087 | cb(typeof rule.message === "function" ? rule.message(rule.fullField || rule.field) : rule.message || (rule.fullField || rule.field) + " fails");
|
16088 | } else if (res instanceof Array) {
|
16089 | cb(res);
|
16090 | } else if (res instanceof Error) {
|
16091 | cb(res.message);
|
16092 | }
|
16093 | }
|
16094 | if (res && res.then) {
|
16095 | res.then(function() {
|
16096 | return cb();
|
16097 | }, function(e2) {
|
16098 | return cb(e2);
|
16099 | });
|
16100 | }
|
16101 | }, function(results) {
|
16102 | complete(results);
|
16103 | }, source);
|
16104 | };
|
16105 | _proto.getType = function getType(rule) {
|
16106 | if (rule.type === void 0 && rule.pattern instanceof RegExp) {
|
16107 | rule.type = "pattern";
|
16108 | }
|
16109 | if (typeof rule.validator !== "function" && rule.type && !validators.hasOwnProperty(rule.type)) {
|
16110 | throw new Error(format("Unknown rule type %s", rule.type));
|
16111 | }
|
16112 | return rule.type || "string";
|
16113 | };
|
16114 | _proto.getValidationMethod = function getValidationMethod(rule) {
|
16115 | if (typeof rule.validator === "function") {
|
16116 | return rule.validator;
|
16117 | }
|
16118 | var keys = Object.keys(rule);
|
16119 | var messageIndex = keys.indexOf("message");
|
16120 | if (messageIndex !== -1) {
|
16121 | keys.splice(messageIndex, 1);
|
16122 | }
|
16123 | if (keys.length === 1 && keys[0] === "required") {
|
16124 | return validators.required;
|
16125 | }
|
16126 | return validators[this.getType(rule)] || void 0;
|
16127 | };
|
16128 | return Schema2;
|
16129 | }();
|
16130 | Schema.register = function register(type4, validator) {
|
16131 | if (typeof validator !== "function") {
|
16132 | throw new Error("Cannot register a validator by type, validator is not a function");
|
16133 | }
|
16134 | validators[type4] = validator;
|
16135 | };
|
16136 | Schema.warning = warning$2;
|
16137 | Schema.messages = messages;
|
16138 | Schema.validators = validators;
|
16139 | var typeTemplate = "'${name}' is not a valid ${type}";
|
16140 | var defaultValidateMessages = {
|
16141 | default: "Validation error on field '${name}'",
|
16142 | required: "'${name}' is required",
|
16143 | enum: "'${name}' must be one of [${enum}]",
|
16144 | whitespace: "'${name}' cannot be empty",
|
16145 | date: {
|
16146 | format: "'${name}' is invalid for format date",
|
16147 | parse: "'${name}' could not be parsed as date",
|
16148 | invalid: "'${name}' is invalid date"
|
16149 | },
|
16150 | types: {
|
16151 | string: typeTemplate,
|
16152 | method: typeTemplate,
|
16153 | array: typeTemplate,
|
16154 | object: typeTemplate,
|
16155 | number: typeTemplate,
|
16156 | date: typeTemplate,
|
16157 | boolean: typeTemplate,
|
16158 | integer: typeTemplate,
|
16159 | float: typeTemplate,
|
16160 | regexp: typeTemplate,
|
16161 | email: typeTemplate,
|
16162 | url: typeTemplate,
|
16163 | hex: typeTemplate
|
16164 | },
|
16165 | string: {
|
16166 | len: "'${name}' must be exactly ${len} characters",
|
16167 | min: "'${name}' must be at least ${min} characters",
|
16168 | max: "'${name}' cannot be longer than ${max} characters",
|
16169 | range: "'${name}' must be between ${min} and ${max} characters"
|
16170 | },
|
16171 | number: {
|
16172 | len: "'${name}' must equal ${len}",
|
16173 | min: "'${name}' cannot be less than ${min}",
|
16174 | max: "'${name}' cannot be greater than ${max}",
|
16175 | range: "'${name}' must be between ${min} and ${max}"
|
16176 | },
|
16177 | array: {
|
16178 | len: "'${name}' must be exactly ${len} in length",
|
16179 | min: "'${name}' cannot be less than ${min} in length",
|
16180 | max: "'${name}' cannot be greater than ${max} in length",
|
16181 | range: "'${name}' must be between ${min} and ${max} in length"
|
16182 | },
|
16183 | pattern: {
|
16184 | mismatch: "'${name}' does not match pattern ${pattern}"
|
16185 | }
|
16186 | };
|
16187 | function cloneDeep(val) {
|
16188 | if (Array.isArray(val)) {
|
16189 | return cloneArrayDeep(val);
|
16190 | } else if (_typeof$1(val) === "object" && val !== null) {
|
16191 | return cloneObjectDeep(val);
|
16192 | }
|
16193 | return val;
|
16194 | }
|
16195 | function cloneObjectDeep(val) {
|
16196 | if (Object.getPrototypeOf(val) === Object.prototype) {
|
16197 | var res = {};
|
16198 | for (var key in val) {
|
16199 | res[key] = cloneDeep(val[key]);
|
16200 | }
|
16201 | return res;
|
16202 | }
|
16203 | return val;
|
16204 | }
|
16205 | function cloneArrayDeep(val) {
|
16206 | return val.map(function(item) {
|
16207 | return cloneDeep(item);
|
16208 | });
|
16209 | }
|
16210 | function getNamePath(path) {
|
16211 | return toArray$1(path);
|
16212 | }
|
16213 | function getValue(store, namePath) {
|
16214 | var value = get(store, namePath);
|
16215 | return value;
|
16216 | }
|
16217 | function setValue(store, namePath, value) {
|
16218 | var removeIfUndefined = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false;
|
16219 | var newStore = set(store, namePath, value, removeIfUndefined);
|
16220 | return newStore;
|
16221 | }
|
16222 | function cloneByNamePathList(store, namePathList) {
|
16223 | var newStore = {};
|
16224 | namePathList.forEach(function(namePath) {
|
16225 | var value = getValue(store, namePath);
|
16226 | newStore = setValue(newStore, namePath, value);
|
16227 | });
|
16228 | return newStore;
|
16229 | }
|
16230 | function containsNamePath(namePathList, namePath) {
|
16231 | return namePathList && namePathList.some(function(path) {
|
16232 | return matchNamePath(path, namePath);
|
16233 | });
|
16234 | }
|
16235 | function isObject(obj) {
|
16236 | return _typeof$1(obj) === "object" && obj !== null && Object.getPrototypeOf(obj) === Object.prototype;
|
16237 | }
|
16238 | function internalSetValues(store, values) {
|
16239 | var newStore = Array.isArray(store) ? _toConsumableArray(store) : _objectSpread2({}, store);
|
16240 | if (!values) {
|
16241 | return newStore;
|
16242 | }
|
16243 | Object.keys(values).forEach(function(key) {
|
16244 | var prevValue = newStore[key];
|
16245 | var value = values[key];
|
16246 | var recursive = isObject(prevValue) && isObject(value);
|
16247 | newStore[key] = recursive ? internalSetValues(prevValue, value || {}) : cloneDeep(value);
|
16248 | });
|
16249 | return newStore;
|
16250 | }
|
16251 | function setValues(store) {
|
16252 | for (var _len = arguments.length, restValues = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
16253 | restValues[_key - 1] = arguments[_key];
|
16254 | }
|
16255 | return restValues.reduce(function(current, newStore) {
|
16256 | return internalSetValues(current, newStore);
|
16257 | }, store);
|
16258 | }
|
16259 | function matchNamePath(namePath, changedNamePath) {
|
16260 | if (!namePath || !changedNamePath || namePath.length !== changedNamePath.length) {
|
16261 | return false;
|
16262 | }
|
16263 | return namePath.every(function(nameUnit, i2) {
|
16264 | return changedNamePath[i2] === nameUnit;
|
16265 | });
|
16266 | }
|
16267 | function isSimilar(source, target) {
|
16268 | if (source === target) {
|
16269 | return true;
|
16270 | }
|
16271 | if (!source && target || source && !target) {
|
16272 | return false;
|
16273 | }
|
16274 | if (!source || !target || _typeof$1(source) !== "object" || _typeof$1(target) !== "object") {
|
16275 | return false;
|
16276 | }
|
16277 | var sourceKeys = Object.keys(source);
|
16278 | var targetKeys = Object.keys(target);
|
16279 | var keys = new Set([].concat(sourceKeys, targetKeys));
|
16280 | return _toConsumableArray(keys).every(function(key) {
|
16281 | var sourceValue = source[key];
|
16282 | var targetValue = target[key];
|
16283 | if (typeof sourceValue === "function" && typeof targetValue === "function") {
|
16284 | return true;
|
16285 | }
|
16286 | return sourceValue === targetValue;
|
16287 | });
|
16288 | }
|
16289 | function defaultGetValueFromEvent(valuePropName) {
|
16290 | var event = arguments.length <= 1 ? void 0 : arguments[1];
|
16291 | if (event && event.target && _typeof$1(event.target) === "object" && valuePropName in event.target) {
|
16292 | return event.target[valuePropName];
|
16293 | }
|
16294 | return event;
|
16295 | }
|
16296 | function move(array, moveIndex, toIndex) {
|
16297 | var length = array.length;
|
16298 | if (moveIndex < 0 || moveIndex >= length || toIndex < 0 || toIndex >= length) {
|
16299 | return array;
|
16300 | }
|
16301 | var item = array[moveIndex];
|
16302 | var diff = moveIndex - toIndex;
|
16303 | if (diff > 0) {
|
16304 | return [].concat(_toConsumableArray(array.slice(0, toIndex)), [item], _toConsumableArray(array.slice(toIndex, moveIndex)), _toConsumableArray(array.slice(moveIndex + 1, length)));
|
16305 | }
|
16306 | if (diff < 0) {
|
16307 | return [].concat(_toConsumableArray(array.slice(0, moveIndex)), _toConsumableArray(array.slice(moveIndex + 1, toIndex + 1)), [item], _toConsumableArray(array.slice(toIndex + 1, length)));
|
16308 | }
|
16309 | return array;
|
16310 | }
|
16311 | var AsyncValidator = Schema;
|
16312 | function replaceMessage(template, kv) {
|
16313 | return template.replace(/\$\{\w+\}/g, function(str) {
|
16314 | var key = str.slice(2, -1);
|
16315 | return kv[key];
|
16316 | });
|
16317 | }
|
16318 | var CODE_LOGIC_ERROR = "CODE_LOGIC_ERROR";
|
16319 | function validateRule(_x, _x2, _x3, _x4, _x5) {
|
16320 | return _validateRule.apply(this, arguments);
|
16321 | }
|
16322 | function _validateRule() {
|
16323 | _validateRule = _asyncToGenerator( _regeneratorRuntime().mark(function _callee2(name, value, rule, options, messageVariables) {
|
16324 | var cloneRule, originValidator, subRuleField, validator, messages2, result, subResults, kv, fillVariableResult;
|
16325 | return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
16326 | while (1)
|
16327 | switch (_context2.prev = _context2.next) {
|
16328 | case 0:
|
16329 | cloneRule = _objectSpread2({}, rule);
|
16330 | delete cloneRule.ruleIndex;
|
16331 | if (cloneRule.validator) {
|
16332 | originValidator = cloneRule.validator;
|
16333 | cloneRule.validator = function() {
|
16334 | try {
|
16335 | return originValidator.apply(void 0, arguments);
|
16336 | } catch (error) {
|
16337 | console.error(error);
|
16338 | return Promise.reject(CODE_LOGIC_ERROR);
|
16339 | }
|
16340 | };
|
16341 | }
|
16342 | subRuleField = null;
|
16343 | if (cloneRule && cloneRule.type === "array" && cloneRule.defaultField) {
|
16344 | subRuleField = cloneRule.defaultField;
|
16345 | delete cloneRule.defaultField;
|
16346 | }
|
16347 | validator = new AsyncValidator(_defineProperty({}, name, [cloneRule]));
|
16348 | messages2 = setValues({}, defaultValidateMessages, options.validateMessages);
|
16349 | validator.messages(messages2);
|
16350 | result = [];
|
16351 | _context2.prev = 9;
|
16352 | _context2.next = 12;
|
16353 | return Promise.resolve(validator.validate(_defineProperty({}, name, value), _objectSpread2({}, options)));
|
16354 | case 12:
|
16355 | _context2.next = 17;
|
16356 | break;
|
16357 | case 14:
|
16358 | _context2.prev = 14;
|
16359 | _context2.t0 = _context2["catch"](9);
|
16360 | if (_context2.t0.errors) {
|
16361 | result = _context2.t0.errors.map(function(_ref4, index2) {
|
16362 | var message = _ref4.message;
|
16363 | var mergedMessage = message === CODE_LOGIC_ERROR ? messages2.default : message;
|
16364 | return React__namespace.isValidElement(mergedMessage) ? (
|
16365 |
|
16366 | React__namespace.cloneElement(mergedMessage, {
|
16367 | key: "error_".concat(index2)
|
16368 | })
|
16369 | ) : mergedMessage;
|
16370 | });
|
16371 | }
|
16372 | case 17:
|
16373 | if (!(!result.length && subRuleField)) {
|
16374 | _context2.next = 22;
|
16375 | break;
|
16376 | }
|
16377 | _context2.next = 20;
|
16378 | return Promise.all(value.map(function(subValue, i2) {
|
16379 | return validateRule("".concat(name, ".").concat(i2), subValue, subRuleField, options, messageVariables);
|
16380 | }));
|
16381 | case 20:
|
16382 | subResults = _context2.sent;
|
16383 | return _context2.abrupt("return", subResults.reduce(function(prev, errors) {
|
16384 | return [].concat(_toConsumableArray(prev), _toConsumableArray(errors));
|
16385 | }, []));
|
16386 | case 22:
|
16387 | kv = _objectSpread2(_objectSpread2({}, rule), {}, {
|
16388 | name,
|
16389 | enum: (rule.enum || []).join(", ")
|
16390 | }, messageVariables);
|
16391 | fillVariableResult = result.map(function(error) {
|
16392 | if (typeof error === "string") {
|
16393 | return replaceMessage(error, kv);
|
16394 | }
|
16395 | return error;
|
16396 | });
|
16397 | return _context2.abrupt("return", fillVariableResult);
|
16398 | case 25:
|
16399 | case "end":
|
16400 | return _context2.stop();
|
16401 | }
|
16402 | }, _callee2, null, [[9, 14]]);
|
16403 | }));
|
16404 | return _validateRule.apply(this, arguments);
|
16405 | }
|
16406 | function validateRules(namePath, value, rules2, options, validateFirst, messageVariables) {
|
16407 | var name = namePath.join(".");
|
16408 | var filledRules = rules2.map(function(currentRule, ruleIndex) {
|
16409 | var originValidatorFunc = currentRule.validator;
|
16410 | var cloneRule = _objectSpread2(_objectSpread2({}, currentRule), {}, {
|
16411 | ruleIndex
|
16412 | });
|
16413 | if (originValidatorFunc) {
|
16414 | cloneRule.validator = function(rule, val, callback) {
|
16415 | var hasPromise = false;
|
16416 | var wrappedCallback = function wrappedCallback2() {
|
16417 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
16418 | args[_key] = arguments[_key];
|
16419 | }
|
16420 | Promise.resolve().then(function() {
|
16421 | warningOnce$1(!hasPromise, "Your validator function has already return a promise. `callback` will be ignored.");
|
16422 | if (!hasPromise) {
|
16423 | callback.apply(void 0, args);
|
16424 | }
|
16425 | });
|
16426 | };
|
16427 | var promise = originValidatorFunc(rule, val, wrappedCallback);
|
16428 | hasPromise = promise && typeof promise.then === "function" && typeof promise.catch === "function";
|
16429 | warningOnce$1(hasPromise, "`callback` is deprecated. Please return a promise instead.");
|
16430 | if (hasPromise) {
|
16431 | promise.then(function() {
|
16432 | callback();
|
16433 | }).catch(function(err) {
|
16434 | callback(err || " ");
|
16435 | });
|
16436 | }
|
16437 | };
|
16438 | }
|
16439 | return cloneRule;
|
16440 | }).sort(function(_ref, _ref2) {
|
16441 | var w1 = _ref.warningOnly, i1 = _ref.ruleIndex;
|
16442 | var w2 = _ref2.warningOnly, i2 = _ref2.ruleIndex;
|
16443 | if (!!w1 === !!w2) {
|
16444 | return i1 - i2;
|
16445 | }
|
16446 | if (w1) {
|
16447 | return 1;
|
16448 | }
|
16449 | return -1;
|
16450 | });
|
16451 | var summaryPromise;
|
16452 | if (validateFirst === true) {
|
16453 | summaryPromise = new Promise( function() {
|
16454 | var _ref3 = _asyncToGenerator( _regeneratorRuntime().mark(function _callee(resolve, reject) {
|
16455 | var i2, rule, errors;
|
16456 | return _regeneratorRuntime().wrap(function _callee$(_context) {
|
16457 | while (1)
|
16458 | switch (_context.prev = _context.next) {
|
16459 | case 0:
|
16460 | i2 = 0;
|
16461 | case 1:
|
16462 | if (!(i2 < filledRules.length)) {
|
16463 | _context.next = 12;
|
16464 | break;
|
16465 | }
|
16466 | rule = filledRules[i2];
|
16467 | _context.next = 5;
|
16468 | return validateRule(name, value, rule, options, messageVariables);
|
16469 | case 5:
|
16470 | errors = _context.sent;
|
16471 | if (!errors.length) {
|
16472 | _context.next = 9;
|
16473 | break;
|
16474 | }
|
16475 | reject([{
|
16476 | errors,
|
16477 | rule
|
16478 | }]);
|
16479 | return _context.abrupt("return");
|
16480 | case 9:
|
16481 | i2 += 1;
|
16482 | _context.next = 1;
|
16483 | break;
|
16484 | case 12:
|
16485 | resolve([]);
|
16486 | case 13:
|
16487 | case "end":
|
16488 | return _context.stop();
|
16489 | }
|
16490 | }, _callee);
|
16491 | }));
|
16492 | return function(_x6, _x7) {
|
16493 | return _ref3.apply(this, arguments);
|
16494 | };
|
16495 | }());
|
16496 | } else {
|
16497 | var rulePromises = filledRules.map(function(rule) {
|
16498 | return validateRule(name, value, rule, options, messageVariables).then(function(errors) {
|
16499 | return {
|
16500 | errors,
|
16501 | rule
|
16502 | };
|
16503 | });
|
16504 | });
|
16505 | summaryPromise = (validateFirst ? finishOnFirstFailed(rulePromises) : finishOnAllFailed(rulePromises)).then(function(errors) {
|
16506 | return Promise.reject(errors);
|
16507 | });
|
16508 | }
|
16509 | summaryPromise.catch(function(e2) {
|
16510 | return e2;
|
16511 | });
|
16512 | return summaryPromise;
|
16513 | }
|
16514 | function finishOnAllFailed(_x8) {
|
16515 | return _finishOnAllFailed.apply(this, arguments);
|
16516 | }
|
16517 | function _finishOnAllFailed() {
|
16518 | _finishOnAllFailed = _asyncToGenerator( _regeneratorRuntime().mark(function _callee3(rulePromises) {
|
16519 | return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
16520 | while (1)
|
16521 | switch (_context3.prev = _context3.next) {
|
16522 | case 0:
|
16523 | return _context3.abrupt("return", Promise.all(rulePromises).then(function(errorsList) {
|
16524 | var _ref5;
|
16525 | var errors = (_ref5 = []).concat.apply(_ref5, _toConsumableArray(errorsList));
|
16526 | return errors;
|
16527 | }));
|
16528 | case 1:
|
16529 | case "end":
|
16530 | return _context3.stop();
|
16531 | }
|
16532 | }, _callee3);
|
16533 | }));
|
16534 | return _finishOnAllFailed.apply(this, arguments);
|
16535 | }
|
16536 | function finishOnFirstFailed(_x9) {
|
16537 | return _finishOnFirstFailed.apply(this, arguments);
|
16538 | }
|
16539 | function _finishOnFirstFailed() {
|
16540 | _finishOnFirstFailed = _asyncToGenerator( _regeneratorRuntime().mark(function _callee4(rulePromises) {
|
16541 | var count;
|
16542 | return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
16543 | while (1)
|
16544 | switch (_context4.prev = _context4.next) {
|
16545 | case 0:
|
16546 | count = 0;
|
16547 | return _context4.abrupt("return", new Promise(function(resolve) {
|
16548 | rulePromises.forEach(function(promise) {
|
16549 | promise.then(function(ruleError) {
|
16550 | if (ruleError.errors.length) {
|
16551 | resolve([ruleError]);
|
16552 | }
|
16553 | count += 1;
|
16554 | if (count === rulePromises.length) {
|
16555 | resolve([]);
|
16556 | }
|
16557 | });
|
16558 | });
|
16559 | }));
|
16560 | case 2:
|
16561 | case "end":
|
16562 | return _context4.stop();
|
16563 | }
|
16564 | }, _callee4);
|
16565 | }));
|
16566 | return _finishOnFirstFailed.apply(this, arguments);
|
16567 | }
|
16568 | var _excluded$2 = ["name"];
|
16569 | var EMPTY_ERRORS = [];
|
16570 | function requireUpdate(shouldUpdate, prev, next, prevValue, nextValue, info) {
|
16571 | if (typeof shouldUpdate === "function") {
|
16572 | return shouldUpdate(prev, next, "source" in info ? {
|
16573 | source: info.source
|
16574 | } : {});
|
16575 | }
|
16576 | return prevValue !== nextValue;
|
16577 | }
|
16578 | var Field = function(_React$Component) {
|
16579 | _inherits(Field2, _React$Component);
|
16580 | var _super = _createSuper(Field2);
|
16581 | function Field2(props) {
|
16582 | var _this;
|
16583 | _classCallCheck(this, Field2);
|
16584 | _this = _super.call(this, props);
|
16585 | _this.state = {
|
16586 | resetCount: 0
|
16587 | };
|
16588 | _this.cancelRegisterFunc = null;
|
16589 | _this.mounted = false;
|
16590 | _this.touched = false;
|
16591 | _this.dirty = false;
|
16592 | _this.validatePromise = null;
|
16593 | _this.prevValidating = void 0;
|
16594 | _this.errors = EMPTY_ERRORS;
|
16595 | _this.warnings = EMPTY_ERRORS;
|
16596 | _this.cancelRegister = function() {
|
16597 | var _this$props = _this.props, preserve = _this$props.preserve, isListField = _this$props.isListField, name = _this$props.name;
|
16598 | if (_this.cancelRegisterFunc) {
|
16599 | _this.cancelRegisterFunc(isListField, preserve, getNamePath(name));
|
16600 | }
|
16601 | _this.cancelRegisterFunc = null;
|
16602 | };
|
16603 | _this.getNamePath = function() {
|
16604 | var _this$props2 = _this.props, name = _this$props2.name, fieldContext = _this$props2.fieldContext;
|
16605 | var _fieldContext$prefixN = fieldContext.prefixName, prefixName = _fieldContext$prefixN === void 0 ? [] : _fieldContext$prefixN;
|
16606 | return name !== void 0 ? [].concat(_toConsumableArray(prefixName), _toConsumableArray(name)) : [];
|
16607 | };
|
16608 | _this.getRules = function() {
|
16609 | var _this$props3 = _this.props, _this$props3$rules = _this$props3.rules, rules2 = _this$props3$rules === void 0 ? [] : _this$props3$rules, fieldContext = _this$props3.fieldContext;
|
16610 | return rules2.map(function(rule) {
|
16611 | if (typeof rule === "function") {
|
16612 | return rule(fieldContext);
|
16613 | }
|
16614 | return rule;
|
16615 | });
|
16616 | };
|
16617 | _this.refresh = function() {
|
16618 | if (!_this.mounted)
|
16619 | return;
|
16620 | _this.setState(function(_ref) {
|
16621 | var resetCount = _ref.resetCount;
|
16622 | return {
|
16623 | resetCount: resetCount + 1
|
16624 | };
|
16625 | });
|
16626 | };
|
16627 | _this.triggerMetaEvent = function(destroy) {
|
16628 | var onMetaChange = _this.props.onMetaChange;
|
16629 | onMetaChange === null || onMetaChange === void 0 ? void 0 : onMetaChange(_objectSpread2(_objectSpread2({}, _this.getMeta()), {}, {
|
16630 | destroy
|
16631 | }));
|
16632 | };
|
16633 | _this.onStoreChange = function(prevStore, namePathList, info) {
|
16634 | var _this$props4 = _this.props, shouldUpdate = _this$props4.shouldUpdate, _this$props4$dependen = _this$props4.dependencies, dependencies = _this$props4$dependen === void 0 ? [] : _this$props4$dependen, onReset = _this$props4.onReset;
|
16635 | var store = info.store;
|
16636 | var namePath = _this.getNamePath();
|
16637 | var prevValue = _this.getValue(prevStore);
|
16638 | var curValue = _this.getValue(store);
|
16639 | var namePathMatch = namePathList && containsNamePath(namePathList, namePath);
|
16640 | if (info.type === "valueUpdate" && info.source === "external" && prevValue !== curValue) {
|
16641 | _this.touched = true;
|
16642 | _this.dirty = true;
|
16643 | _this.validatePromise = null;
|
16644 | _this.errors = EMPTY_ERRORS;
|
16645 | _this.warnings = EMPTY_ERRORS;
|
16646 | _this.triggerMetaEvent();
|
16647 | }
|
16648 | switch (info.type) {
|
16649 | case "reset":
|
16650 | if (!namePathList || namePathMatch) {
|
16651 | _this.touched = false;
|
16652 | _this.dirty = false;
|
16653 | _this.validatePromise = null;
|
16654 | _this.errors = EMPTY_ERRORS;
|
16655 | _this.warnings = EMPTY_ERRORS;
|
16656 | _this.triggerMetaEvent();
|
16657 | onReset === null || onReset === void 0 ? void 0 : onReset();
|
16658 | _this.refresh();
|
16659 | return;
|
16660 | }
|
16661 | break;
|
16662 | case "remove": {
|
16663 | if (shouldUpdate) {
|
16664 | _this.reRender();
|
16665 | return;
|
16666 | }
|
16667 | break;
|
16668 | }
|
16669 | case "setField": {
|
16670 | if (namePathMatch) {
|
16671 | var data = info.data;
|
16672 | if ("touched" in data) {
|
16673 | _this.touched = data.touched;
|
16674 | }
|
16675 | if ("validating" in data && !("originRCField" in data)) {
|
16676 | _this.validatePromise = data.validating ? Promise.resolve([]) : null;
|
16677 | }
|
16678 | if ("errors" in data) {
|
16679 | _this.errors = data.errors || EMPTY_ERRORS;
|
16680 | }
|
16681 | if ("warnings" in data) {
|
16682 | _this.warnings = data.warnings || EMPTY_ERRORS;
|
16683 | }
|
16684 | _this.dirty = true;
|
16685 | _this.triggerMetaEvent();
|
16686 | _this.reRender();
|
16687 | return;
|
16688 | }
|
16689 | if (shouldUpdate && !namePath.length && requireUpdate(shouldUpdate, prevStore, store, prevValue, curValue, info)) {
|
16690 | _this.reRender();
|
16691 | return;
|
16692 | }
|
16693 | break;
|
16694 | }
|
16695 | case "dependenciesUpdate": {
|
16696 | var dependencyList = dependencies.map(getNamePath);
|
16697 | if (dependencyList.some(function(dependency) {
|
16698 | return containsNamePath(info.relatedFields, dependency);
|
16699 | })) {
|
16700 | _this.reRender();
|
16701 | return;
|
16702 | }
|
16703 | break;
|
16704 | }
|
16705 | default:
|
16706 | if (namePathMatch || (!dependencies.length || namePath.length || shouldUpdate) && requireUpdate(shouldUpdate, prevStore, store, prevValue, curValue, info)) {
|
16707 | _this.reRender();
|
16708 | return;
|
16709 | }
|
16710 | break;
|
16711 | }
|
16712 | if (shouldUpdate === true) {
|
16713 | _this.reRender();
|
16714 | }
|
16715 | };
|
16716 | _this.validateRules = function(options) {
|
16717 | var namePath = _this.getNamePath();
|
16718 | var currentValue = _this.getValue();
|
16719 | var rootPromise = Promise.resolve().then(function() {
|
16720 | if (!_this.mounted) {
|
16721 | return [];
|
16722 | }
|
16723 | var _this$props5 = _this.props, _this$props5$validate = _this$props5.validateFirst, validateFirst = _this$props5$validate === void 0 ? false : _this$props5$validate, messageVariables = _this$props5.messageVariables;
|
16724 | var _ref2 = options || {}, triggerName = _ref2.triggerName;
|
16725 | var filteredRules = _this.getRules();
|
16726 | if (triggerName) {
|
16727 | filteredRules = filteredRules.filter(function(rule) {
|
16728 | return rule;
|
16729 | }).filter(function(rule) {
|
16730 | var validateTrigger = rule.validateTrigger;
|
16731 | if (!validateTrigger) {
|
16732 | return true;
|
16733 | }
|
16734 | var triggerList = toArray$1(validateTrigger);
|
16735 | return triggerList.includes(triggerName);
|
16736 | });
|
16737 | }
|
16738 | var promise = validateRules(namePath, currentValue, filteredRules, options, validateFirst, messageVariables);
|
16739 | promise.catch(function(e2) {
|
16740 | return e2;
|
16741 | }).then(function() {
|
16742 | var ruleErrors = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : EMPTY_ERRORS;
|
16743 | if (_this.validatePromise === rootPromise) {
|
16744 | var _ruleErrors$forEach;
|
16745 | _this.validatePromise = null;
|
16746 | var nextErrors = [];
|
16747 | var nextWarnings = [];
|
16748 | (_ruleErrors$forEach = ruleErrors.forEach) === null || _ruleErrors$forEach === void 0 ? void 0 : _ruleErrors$forEach.call(ruleErrors, function(_ref3) {
|
16749 | var warningOnly = _ref3.rule.warningOnly, _ref3$errors = _ref3.errors, errors = _ref3$errors === void 0 ? EMPTY_ERRORS : _ref3$errors;
|
16750 | if (warningOnly) {
|
16751 | nextWarnings.push.apply(nextWarnings, _toConsumableArray(errors));
|
16752 | } else {
|
16753 | nextErrors.push.apply(nextErrors, _toConsumableArray(errors));
|
16754 | }
|
16755 | });
|
16756 | _this.errors = nextErrors;
|
16757 | _this.warnings = nextWarnings;
|
16758 | _this.triggerMetaEvent();
|
16759 | _this.reRender();
|
16760 | }
|
16761 | });
|
16762 | return promise;
|
16763 | });
|
16764 | _this.validatePromise = rootPromise;
|
16765 | _this.dirty = true;
|
16766 | _this.errors = EMPTY_ERRORS;
|
16767 | _this.warnings = EMPTY_ERRORS;
|
16768 | _this.triggerMetaEvent();
|
16769 | _this.reRender();
|
16770 | return rootPromise;
|
16771 | };
|
16772 | _this.isFieldValidating = function() {
|
16773 | return !!_this.validatePromise;
|
16774 | };
|
16775 | _this.isFieldTouched = function() {
|
16776 | return _this.touched;
|
16777 | };
|
16778 | _this.isFieldDirty = function() {
|
16779 | if (_this.dirty || _this.props.initialValue !== void 0) {
|
16780 | return true;
|
16781 | }
|
16782 | var fieldContext = _this.props.fieldContext;
|
16783 | var _fieldContext$getInte = fieldContext.getInternalHooks(HOOK_MARK$1), getInitialValue = _fieldContext$getInte.getInitialValue;
|
16784 | if (getInitialValue(_this.getNamePath()) !== void 0) {
|
16785 | return true;
|
16786 | }
|
16787 | return false;
|
16788 | };
|
16789 | _this.getErrors = function() {
|
16790 | return _this.errors;
|
16791 | };
|
16792 | _this.getWarnings = function() {
|
16793 | return _this.warnings;
|
16794 | };
|
16795 | _this.isListField = function() {
|
16796 | return _this.props.isListField;
|
16797 | };
|
16798 | _this.isList = function() {
|
16799 | return _this.props.isList;
|
16800 | };
|
16801 | _this.isPreserve = function() {
|
16802 | return _this.props.preserve;
|
16803 | };
|
16804 | _this.getMeta = function() {
|
16805 | _this.prevValidating = _this.isFieldValidating();
|
16806 | var meta = {
|
16807 | touched: _this.isFieldTouched(),
|
16808 | validating: _this.prevValidating,
|
16809 | errors: _this.errors,
|
16810 | warnings: _this.warnings,
|
16811 | name: _this.getNamePath()
|
16812 | };
|
16813 | return meta;
|
16814 | };
|
16815 | _this.getOnlyChild = function(children) {
|
16816 | if (typeof children === "function") {
|
16817 | var meta = _this.getMeta();
|
16818 | return _objectSpread2(_objectSpread2({}, _this.getOnlyChild(children(_this.getControlled(), meta, _this.props.fieldContext))), {}, {
|
16819 | isFunction: true
|
16820 | });
|
16821 | }
|
16822 | var childList = toArray$2(children);
|
16823 | if (childList.length !== 1 || ! React__namespace.isValidElement(childList[0])) {
|
16824 | return {
|
16825 | child: childList,
|
16826 | isFunction: false
|
16827 | };
|
16828 | }
|
16829 | return {
|
16830 | child: childList[0],
|
16831 | isFunction: false
|
16832 | };
|
16833 | };
|
16834 | _this.getValue = function(store) {
|
16835 | var getFieldsValue = _this.props.fieldContext.getFieldsValue;
|
16836 | var namePath = _this.getNamePath();
|
16837 | return getValue(store || getFieldsValue(true), namePath);
|
16838 | };
|
16839 | _this.getControlled = function() {
|
16840 | var childProps = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
16841 | var _this$props6 = _this.props, trigger = _this$props6.trigger, validateTrigger = _this$props6.validateTrigger, getValueFromEvent = _this$props6.getValueFromEvent, normalize2 = _this$props6.normalize, valuePropName = _this$props6.valuePropName, getValueProps = _this$props6.getValueProps, fieldContext = _this$props6.fieldContext;
|
16842 | var mergedValidateTrigger = validateTrigger !== void 0 ? validateTrigger : fieldContext.validateTrigger;
|
16843 | var namePath = _this.getNamePath();
|
16844 | var getInternalHooks2 = fieldContext.getInternalHooks, getFieldsValue = fieldContext.getFieldsValue;
|
16845 | var _getInternalHooks = getInternalHooks2(HOOK_MARK$1), dispatch = _getInternalHooks.dispatch;
|
16846 | var value = _this.getValue();
|
16847 | var mergedGetValueProps = getValueProps || function(val) {
|
16848 | return _defineProperty({}, valuePropName, val);
|
16849 | };
|
16850 | var originTriggerFunc = childProps[trigger];
|
16851 | var control = _objectSpread2(_objectSpread2({}, childProps), mergedGetValueProps(value));
|
16852 | control[trigger] = function() {
|
16853 | _this.touched = true;
|
16854 | _this.dirty = true;
|
16855 | _this.triggerMetaEvent();
|
16856 | var newValue;
|
16857 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
16858 | args[_key] = arguments[_key];
|
16859 | }
|
16860 | if (getValueFromEvent) {
|
16861 | newValue = getValueFromEvent.apply(void 0, args);
|
16862 | } else {
|
16863 | newValue = defaultGetValueFromEvent.apply(void 0, [valuePropName].concat(args));
|
16864 | }
|
16865 | if (normalize2) {
|
16866 | newValue = normalize2(newValue, value, getFieldsValue(true));
|
16867 | }
|
16868 | dispatch({
|
16869 | type: "updateValue",
|
16870 | namePath,
|
16871 | value: newValue
|
16872 | });
|
16873 | if (originTriggerFunc) {
|
16874 | originTriggerFunc.apply(void 0, args);
|
16875 | }
|
16876 | };
|
16877 | var validateTriggerList = toArray$1(mergedValidateTrigger || []);
|
16878 | validateTriggerList.forEach(function(triggerName) {
|
16879 | var originTrigger = control[triggerName];
|
16880 | control[triggerName] = function() {
|
16881 | if (originTrigger) {
|
16882 | originTrigger.apply(void 0, arguments);
|
16883 | }
|
16884 | var rules2 = _this.props.rules;
|
16885 | if (rules2 && rules2.length) {
|
16886 | dispatch({
|
16887 | type: "validateField",
|
16888 | namePath,
|
16889 | triggerName
|
16890 | });
|
16891 | }
|
16892 | };
|
16893 | });
|
16894 | return control;
|
16895 | };
|
16896 | if (props.fieldContext) {
|
16897 | var getInternalHooks = props.fieldContext.getInternalHooks;
|
16898 | var _getInternalHooks2 = getInternalHooks(HOOK_MARK$1), initEntityValue = _getInternalHooks2.initEntityValue;
|
16899 | initEntityValue(_assertThisInitialized(_this));
|
16900 | }
|
16901 | return _this;
|
16902 | }
|
16903 | _createClass(Field2, [{
|
16904 | key: "componentDidMount",
|
16905 | value: function componentDidMount() {
|
16906 | var _this$props7 = this.props, shouldUpdate = _this$props7.shouldUpdate, fieldContext = _this$props7.fieldContext;
|
16907 | this.mounted = true;
|
16908 | if (fieldContext) {
|
16909 | var getInternalHooks = fieldContext.getInternalHooks;
|
16910 | var _getInternalHooks3 = getInternalHooks(HOOK_MARK$1), registerField = _getInternalHooks3.registerField;
|
16911 | this.cancelRegisterFunc = registerField(this);
|
16912 | }
|
16913 | if (shouldUpdate === true) {
|
16914 | this.reRender();
|
16915 | }
|
16916 | }
|
16917 | }, {
|
16918 | key: "componentWillUnmount",
|
16919 | value: function componentWillUnmount() {
|
16920 | this.cancelRegister();
|
16921 | this.triggerMetaEvent(true);
|
16922 | this.mounted = false;
|
16923 | }
|
16924 | }, {
|
16925 | key: "reRender",
|
16926 | value: function reRender() {
|
16927 | if (!this.mounted)
|
16928 | return;
|
16929 | this.forceUpdate();
|
16930 | }
|
16931 | }, {
|
16932 | key: "render",
|
16933 | value: function render2() {
|
16934 | var resetCount = this.state.resetCount;
|
16935 | var children = this.props.children;
|
16936 | var _this$getOnlyChild = this.getOnlyChild(children), child = _this$getOnlyChild.child, isFunction2 = _this$getOnlyChild.isFunction;
|
16937 | var returnChildNode;
|
16938 | if (isFunction2) {
|
16939 | returnChildNode = child;
|
16940 | } else if ( React__namespace.isValidElement(child)) {
|
16941 | returnChildNode = React__namespace.cloneElement(child, this.getControlled(child.props));
|
16942 | } else {
|
16943 | warningOnce$1(!child, "`children` of Field is not validate ReactElement.");
|
16944 | returnChildNode = child;
|
16945 | }
|
16946 | return React__namespace.createElement(React__namespace.Fragment, {
|
16947 | key: resetCount
|
16948 | }, returnChildNode);
|
16949 | }
|
16950 | }]);
|
16951 | return Field2;
|
16952 | }(React__namespace.Component);
|
16953 | Field.contextType = Context$1;
|
16954 | Field.defaultProps = {
|
16955 | trigger: "onChange",
|
16956 | valuePropName: "value"
|
16957 | };
|
16958 | function WrapperField(_ref5) {
|
16959 | var name = _ref5.name, restProps = _objectWithoutProperties(_ref5, _excluded$2);
|
16960 | var fieldContext = React__namespace.useContext(Context$1);
|
16961 | var namePath = name !== void 0 ? getNamePath(name) : void 0;
|
16962 | var key = "keep";
|
16963 | if (!restProps.isListField) {
|
16964 | key = "_".concat((namePath || []).join("_"));
|
16965 | }
|
16966 | if (restProps.preserve === false && restProps.isListField && namePath.length <= 1) {
|
16967 | warningOnce$1(false, "`preserve` should not apply on Form.List fields.");
|
16968 | }
|
16969 | return React__namespace.createElement(Field, _extends$1({
|
16970 | key,
|
16971 | name: namePath
|
16972 | }, restProps, {
|
16973 | fieldContext
|
16974 | }));
|
16975 | }
|
16976 | var ListContext = React__namespace.createContext(null);
|
16977 | var List = function List2(_ref) {
|
16978 | var name = _ref.name, initialValue = _ref.initialValue, children = _ref.children, rules2 = _ref.rules, validateTrigger = _ref.validateTrigger;
|
16979 | var context = React__namespace.useContext(Context$1);
|
16980 | var keyRef = React__namespace.useRef({
|
16981 | keys: [],
|
16982 | id: 0
|
16983 | });
|
16984 | var keyManager = keyRef.current;
|
16985 | var prefixName = React__namespace.useMemo(function() {
|
16986 | var parentPrefixName = getNamePath(context.prefixName) || [];
|
16987 | return [].concat(_toConsumableArray(parentPrefixName), _toConsumableArray(getNamePath(name)));
|
16988 | }, [context.prefixName, name]);
|
16989 | var fieldContext = React__namespace.useMemo(function() {
|
16990 | return _objectSpread2(_objectSpread2({}, context), {}, {
|
16991 | prefixName
|
16992 | });
|
16993 | }, [context, prefixName]);
|
16994 | var listContext = React__namespace.useMemo(function() {
|
16995 | return {
|
16996 | getKey: function getKey(namePath) {
|
16997 | var len = prefixName.length;
|
16998 | var pathName = namePath[len];
|
16999 | return [keyManager.keys[pathName], namePath.slice(len + 1)];
|
17000 | }
|
17001 | };
|
17002 | }, [prefixName]);
|
17003 | if (typeof children !== "function") {
|
17004 | warningOnce$1(false, "Form.List only accepts function as children.");
|
17005 | return null;
|
17006 | }
|
17007 | var shouldUpdate = function shouldUpdate2(prevValue, nextValue, _ref2) {
|
17008 | var source = _ref2.source;
|
17009 | if (source === "internal") {
|
17010 | return false;
|
17011 | }
|
17012 | return prevValue !== nextValue;
|
17013 | };
|
17014 | return React__namespace.createElement(ListContext.Provider, {
|
17015 | value: listContext
|
17016 | }, React__namespace.createElement(Context$1.Provider, {
|
17017 | value: fieldContext
|
17018 | }, React__namespace.createElement(WrapperField, {
|
17019 | name: [],
|
17020 | shouldUpdate,
|
17021 | rules: rules2,
|
17022 | validateTrigger,
|
17023 | initialValue,
|
17024 | isList: true
|
17025 | }, function(_ref3, meta) {
|
17026 | var _ref3$value = _ref3.value, value = _ref3$value === void 0 ? [] : _ref3$value, onChange = _ref3.onChange;
|
17027 | var getFieldValue = context.getFieldValue;
|
17028 | var getNewValue = function getNewValue2() {
|
17029 | var values = getFieldValue(prefixName || []);
|
17030 | return values || [];
|
17031 | };
|
17032 | var operations = {
|
17033 | add: function add(defaultValue, index2) {
|
17034 | var newValue = getNewValue();
|
17035 | if (index2 >= 0 && index2 <= newValue.length) {
|
17036 | keyManager.keys = [].concat(_toConsumableArray(keyManager.keys.slice(0, index2)), [keyManager.id], _toConsumableArray(keyManager.keys.slice(index2)));
|
17037 | onChange([].concat(_toConsumableArray(newValue.slice(0, index2)), [defaultValue], _toConsumableArray(newValue.slice(index2))));
|
17038 | } else {
|
17039 | if (index2 < 0 || index2 > newValue.length) {
|
17040 | warningOnce$1(false, "The second parameter of the add function should be a valid positive number.");
|
17041 | }
|
17042 | keyManager.keys = [].concat(_toConsumableArray(keyManager.keys), [keyManager.id]);
|
17043 | onChange([].concat(_toConsumableArray(newValue), [defaultValue]));
|
17044 | }
|
17045 | keyManager.id += 1;
|
17046 | },
|
17047 | remove: function remove(index2) {
|
17048 | var newValue = getNewValue();
|
17049 | var indexSet = new Set(Array.isArray(index2) ? index2 : [index2]);
|
17050 | if (indexSet.size <= 0) {
|
17051 | return;
|
17052 | }
|
17053 | keyManager.keys = keyManager.keys.filter(function(_, keysIndex) {
|
17054 | return !indexSet.has(keysIndex);
|
17055 | });
|
17056 | onChange(newValue.filter(function(_, valueIndex) {
|
17057 | return !indexSet.has(valueIndex);
|
17058 | }));
|
17059 | },
|
17060 | move: function move$1(from, to2) {
|
17061 | if (from === to2) {
|
17062 | return;
|
17063 | }
|
17064 | var newValue = getNewValue();
|
17065 | if (from < 0 || from >= newValue.length || to2 < 0 || to2 >= newValue.length) {
|
17066 | return;
|
17067 | }
|
17068 | keyManager.keys = move(keyManager.keys, from, to2);
|
17069 | onChange(move(newValue, from, to2));
|
17070 | }
|
17071 | };
|
17072 | var listValue = value || [];
|
17073 | if (!Array.isArray(listValue)) {
|
17074 | listValue = [];
|
17075 | {
|
17076 | warningOnce$1(false, "Current value of '".concat(prefixName.join(" > "), "' is not an array type."));
|
17077 | }
|
17078 | }
|
17079 | return children(listValue.map(function(__, index2) {
|
17080 | var key = keyManager.keys[index2];
|
17081 | if (key === void 0) {
|
17082 | keyManager.keys[index2] = keyManager.id;
|
17083 | key = keyManager.keys[index2];
|
17084 | keyManager.id += 1;
|
17085 | }
|
17086 | return {
|
17087 | name: index2,
|
17088 | key,
|
17089 | isListField: true
|
17090 | };
|
17091 | }), operations, meta);
|
17092 | })));
|
17093 | };
|
17094 | function allPromiseFinish(promiseList) {
|
17095 | var hasError = false;
|
17096 | var count = promiseList.length;
|
17097 | var results = [];
|
17098 | if (!promiseList.length) {
|
17099 | return Promise.resolve([]);
|
17100 | }
|
17101 | return new Promise(function(resolve, reject) {
|
17102 | promiseList.forEach(function(promise, index2) {
|
17103 | promise.catch(function(e2) {
|
17104 | hasError = true;
|
17105 | return e2;
|
17106 | }).then(function(result) {
|
17107 | count -= 1;
|
17108 | results[index2] = result;
|
17109 | if (count > 0) {
|
17110 | return;
|
17111 | }
|
17112 | if (hasError) {
|
17113 | reject(results);
|
17114 | }
|
17115 | resolve(results);
|
17116 | });
|
17117 | });
|
17118 | });
|
17119 | }
|
17120 | var SPLIT = "__@field_split__";
|
17121 | function normalize(namePath) {
|
17122 | return namePath.map(function(cell) {
|
17123 | return "".concat(_typeof$1(cell), ":").concat(cell);
|
17124 | }).join(SPLIT);
|
17125 | }
|
17126 | var NameMap = function() {
|
17127 | function NameMap2() {
|
17128 | _classCallCheck(this, NameMap2);
|
17129 | this.kvs = new Map();
|
17130 | }
|
17131 | _createClass(NameMap2, [{
|
17132 | key: "set",
|
17133 | value: function set2(key, value) {
|
17134 | this.kvs.set(normalize(key), value);
|
17135 | }
|
17136 | }, {
|
17137 | key: "get",
|
17138 | value: function get2(key) {
|
17139 | return this.kvs.get(normalize(key));
|
17140 | }
|
17141 | }, {
|
17142 | key: "update",
|
17143 | value: function update2(key, updater) {
|
17144 | var origin = this.get(key);
|
17145 | var next = updater(origin);
|
17146 | if (!next) {
|
17147 | this.delete(key);
|
17148 | } else {
|
17149 | this.set(key, next);
|
17150 | }
|
17151 | }
|
17152 | }, {
|
17153 | key: "delete",
|
17154 | value: function _delete(key) {
|
17155 | this.kvs.delete(normalize(key));
|
17156 | }
|
17157 |
|
17158 | }, {
|
17159 | key: "map",
|
17160 | value: function map(callback) {
|
17161 | return _toConsumableArray(this.kvs.entries()).map(function(_ref) {
|
17162 | var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
|
17163 | var cells = key.split(SPLIT);
|
17164 | return callback({
|
17165 | key: cells.map(function(cell) {
|
17166 | var _cell$match = cell.match(/^([^:]*):(.*)$/), _cell$match2 = _slicedToArray(_cell$match, 3), type = _cell$match2[1], unit = _cell$match2[2];
|
17167 | return type === "number" ? Number(unit) : unit;
|
17168 | }),
|
17169 | value
|
17170 | });
|
17171 | });
|
17172 | }
|
17173 | }, {
|
17174 | key: "toJSON",
|
17175 | value: function toJSON() {
|
17176 | var json = {};
|
17177 | this.map(function(_ref3) {
|
17178 | var key = _ref3.key, value = _ref3.value;
|
17179 | json[key.join(".")] = value;
|
17180 | return null;
|
17181 | });
|
17182 | return json;
|
17183 | }
|
17184 | }]);
|
17185 | return NameMap2;
|
17186 | }();
|
17187 | var _excluded$1 = ["name", "errors"];
|
17188 | var FormStore = _createClass(function FormStore2(forceRootUpdate) {
|
17189 | var _this = this;
|
17190 | _classCallCheck(this, FormStore2);
|
17191 | this.formHooked = false;
|
17192 | this.forceRootUpdate = void 0;
|
17193 | this.subscribable = true;
|
17194 | this.store = {};
|
17195 | this.fieldEntities = [];
|
17196 | this.initialValues = {};
|
17197 | this.callbacks = {};
|
17198 | this.validateMessages = null;
|
17199 | this.preserve = null;
|
17200 | this.lastValidatePromise = null;
|
17201 | this.getForm = function() {
|
17202 | return {
|
17203 | getFieldValue: _this.getFieldValue,
|
17204 | getFieldsValue: _this.getFieldsValue,
|
17205 | getFieldError: _this.getFieldError,
|
17206 | getFieldWarning: _this.getFieldWarning,
|
17207 | getFieldsError: _this.getFieldsError,
|
17208 | isFieldsTouched: _this.isFieldsTouched,
|
17209 | isFieldTouched: _this.isFieldTouched,
|
17210 | isFieldValidating: _this.isFieldValidating,
|
17211 | isFieldsValidating: _this.isFieldsValidating,
|
17212 | resetFields: _this.resetFields,
|
17213 | setFields: _this.setFields,
|
17214 | setFieldValue: _this.setFieldValue,
|
17215 | setFieldsValue: _this.setFieldsValue,
|
17216 | validateFields: _this.validateFields,
|
17217 | submit: _this.submit,
|
17218 | _init: true,
|
17219 | getInternalHooks: _this.getInternalHooks
|
17220 | };
|
17221 | };
|
17222 | this.getInternalHooks = function(key) {
|
17223 | if (key === HOOK_MARK$1) {
|
17224 | _this.formHooked = true;
|
17225 | return {
|
17226 | dispatch: _this.dispatch,
|
17227 | initEntityValue: _this.initEntityValue,
|
17228 | registerField: _this.registerField,
|
17229 | useSubscribe: _this.useSubscribe,
|
17230 | setInitialValues: _this.setInitialValues,
|
17231 | destroyForm: _this.destroyForm,
|
17232 | setCallbacks: _this.setCallbacks,
|
17233 | setValidateMessages: _this.setValidateMessages,
|
17234 | getFields: _this.getFields,
|
17235 | setPreserve: _this.setPreserve,
|
17236 | getInitialValue: _this.getInitialValue,
|
17237 | registerWatch: _this.registerWatch
|
17238 | };
|
17239 | }
|
17240 | warningOnce$1(false, "`getInternalHooks` is internal usage. Should not call directly.");
|
17241 | return null;
|
17242 | };
|
17243 | this.useSubscribe = function(subscribable) {
|
17244 | _this.subscribable = subscribable;
|
17245 | };
|
17246 | this.prevWithoutPreserves = null;
|
17247 | this.setInitialValues = function(initialValues, init) {
|
17248 | _this.initialValues = initialValues || {};
|
17249 | if (init) {
|
17250 | var _this$prevWithoutPres;
|
17251 | var nextStore = setValues({}, initialValues, _this.store);
|
17252 | (_this$prevWithoutPres = _this.prevWithoutPreserves) === null || _this$prevWithoutPres === void 0 ? void 0 : _this$prevWithoutPres.map(function(_ref) {
|
17253 | var namePath = _ref.key;
|
17254 | nextStore = setValue(nextStore, namePath, getValue(initialValues, namePath));
|
17255 | });
|
17256 | _this.prevWithoutPreserves = null;
|
17257 | _this.updateStore(nextStore);
|
17258 | }
|
17259 | };
|
17260 | this.destroyForm = function() {
|
17261 | var prevWithoutPreserves = new NameMap();
|
17262 | _this.getFieldEntities(true).forEach(function(entity) {
|
17263 | if (!_this.isMergedPreserve(entity.isPreserve())) {
|
17264 | prevWithoutPreserves.set(entity.getNamePath(), true);
|
17265 | }
|
17266 | });
|
17267 | _this.prevWithoutPreserves = prevWithoutPreserves;
|
17268 | };
|
17269 | this.getInitialValue = function(namePath) {
|
17270 | var initValue = getValue(_this.initialValues, namePath);
|
17271 | return namePath.length ? cloneDeep(initValue) : initValue;
|
17272 | };
|
17273 | this.setCallbacks = function(callbacks) {
|
17274 | _this.callbacks = callbacks;
|
17275 | };
|
17276 | this.setValidateMessages = function(validateMessages) {
|
17277 | _this.validateMessages = validateMessages;
|
17278 | };
|
17279 | this.setPreserve = function(preserve) {
|
17280 | _this.preserve = preserve;
|
17281 | };
|
17282 | this.watchList = [];
|
17283 | this.registerWatch = function(callback) {
|
17284 | _this.watchList.push(callback);
|
17285 | return function() {
|
17286 | _this.watchList = _this.watchList.filter(function(fn) {
|
17287 | return fn !== callback;
|
17288 | });
|
17289 | };
|
17290 | };
|
17291 | this.notifyWatch = function() {
|
17292 | var namePath = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
|
17293 | if (_this.watchList.length) {
|
17294 | var values = _this.getFieldsValue();
|
17295 | _this.watchList.forEach(function(callback) {
|
17296 | callback(values, namePath);
|
17297 | });
|
17298 | }
|
17299 | };
|
17300 | this.timeoutId = null;
|
17301 | this.warningUnhooked = function() {
|
17302 | if (!_this.timeoutId && typeof window !== "undefined") {
|
17303 | _this.timeoutId = setTimeout(function() {
|
17304 | _this.timeoutId = null;
|
17305 | if (!_this.formHooked) {
|
17306 | warningOnce$1(false, "Instance created by `useForm` is not connected to any Form element. Forget to pass `form` prop?");
|
17307 | }
|
17308 | });
|
17309 | }
|
17310 | };
|
17311 | this.updateStore = function(nextStore) {
|
17312 | _this.store = nextStore;
|
17313 | };
|
17314 | this.getFieldEntities = function() {
|
17315 | var pure = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
17316 | if (!pure) {
|
17317 | return _this.fieldEntities;
|
17318 | }
|
17319 | return _this.fieldEntities.filter(function(field) {
|
17320 | return field.getNamePath().length;
|
17321 | });
|
17322 | };
|
17323 | this.getFieldsMap = function() {
|
17324 | var pure = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
17325 | var cache = new NameMap();
|
17326 | _this.getFieldEntities(pure).forEach(function(field) {
|
17327 | var namePath = field.getNamePath();
|
17328 | cache.set(namePath, field);
|
17329 | });
|
17330 | return cache;
|
17331 | };
|
17332 | this.getFieldEntitiesForNamePathList = function(nameList) {
|
17333 | if (!nameList) {
|
17334 | return _this.getFieldEntities(true);
|
17335 | }
|
17336 | var cache = _this.getFieldsMap(true);
|
17337 | return nameList.map(function(name) {
|
17338 | var namePath = getNamePath(name);
|
17339 | return cache.get(namePath) || {
|
17340 | INVALIDATE_NAME_PATH: getNamePath(name)
|
17341 | };
|
17342 | });
|
17343 | };
|
17344 | this.getFieldsValue = function(nameList, filterFunc) {
|
17345 | _this.warningUnhooked();
|
17346 | if (nameList === true && !filterFunc) {
|
17347 | return _this.store;
|
17348 | }
|
17349 | var fieldEntities = _this.getFieldEntitiesForNamePathList(Array.isArray(nameList) ? nameList : null);
|
17350 | var filteredNameList = [];
|
17351 | fieldEntities.forEach(function(entity) {
|
17352 | var _entity$isListField;
|
17353 | var namePath = "INVALIDATE_NAME_PATH" in entity ? entity.INVALIDATE_NAME_PATH : entity.getNamePath();
|
17354 | if (!nameList && ((_entity$isListField = entity.isListField) === null || _entity$isListField === void 0 ? void 0 : _entity$isListField.call(entity))) {
|
17355 | return;
|
17356 | }
|
17357 | if (!filterFunc) {
|
17358 | filteredNameList.push(namePath);
|
17359 | } else {
|
17360 | var meta = "getMeta" in entity ? entity.getMeta() : null;
|
17361 | if (filterFunc(meta)) {
|
17362 | filteredNameList.push(namePath);
|
17363 | }
|
17364 | }
|
17365 | });
|
17366 | return cloneByNamePathList(_this.store, filteredNameList.map(getNamePath));
|
17367 | };
|
17368 | this.getFieldValue = function(name) {
|
17369 | _this.warningUnhooked();
|
17370 | var namePath = getNamePath(name);
|
17371 | return getValue(_this.store, namePath);
|
17372 | };
|
17373 | this.getFieldsError = function(nameList) {
|
17374 | _this.warningUnhooked();
|
17375 | var fieldEntities = _this.getFieldEntitiesForNamePathList(nameList);
|
17376 | return fieldEntities.map(function(entity, index2) {
|
17377 | if (entity && !("INVALIDATE_NAME_PATH" in entity)) {
|
17378 | return {
|
17379 | name: entity.getNamePath(),
|
17380 | errors: entity.getErrors(),
|
17381 | warnings: entity.getWarnings()
|
17382 | };
|
17383 | }
|
17384 | return {
|
17385 | name: getNamePath(nameList[index2]),
|
17386 | errors: [],
|
17387 | warnings: []
|
17388 | };
|
17389 | });
|
17390 | };
|
17391 | this.getFieldError = function(name) {
|
17392 | _this.warningUnhooked();
|
17393 | var namePath = getNamePath(name);
|
17394 | var fieldError = _this.getFieldsError([namePath])[0];
|
17395 | return fieldError.errors;
|
17396 | };
|
17397 | this.getFieldWarning = function(name) {
|
17398 | _this.warningUnhooked();
|
17399 | var namePath = getNamePath(name);
|
17400 | var fieldError = _this.getFieldsError([namePath])[0];
|
17401 | return fieldError.warnings;
|
17402 | };
|
17403 | this.isFieldsTouched = function() {
|
17404 | _this.warningUnhooked();
|
17405 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
17406 | args[_key] = arguments[_key];
|
17407 | }
|
17408 | var arg0 = args[0], arg1 = args[1];
|
17409 | var namePathList;
|
17410 | var isAllFieldsTouched = false;
|
17411 | if (args.length === 0) {
|
17412 | namePathList = null;
|
17413 | } else if (args.length === 1) {
|
17414 | if (Array.isArray(arg0)) {
|
17415 | namePathList = arg0.map(getNamePath);
|
17416 | isAllFieldsTouched = false;
|
17417 | } else {
|
17418 | namePathList = null;
|
17419 | isAllFieldsTouched = arg0;
|
17420 | }
|
17421 | } else {
|
17422 | namePathList = arg0.map(getNamePath);
|
17423 | isAllFieldsTouched = arg1;
|
17424 | }
|
17425 | var fieldEntities = _this.getFieldEntities(true);
|
17426 | var isFieldTouched = function isFieldTouched2(field) {
|
17427 | return field.isFieldTouched();
|
17428 | };
|
17429 | if (!namePathList) {
|
17430 | return isAllFieldsTouched ? fieldEntities.every(isFieldTouched) : fieldEntities.some(isFieldTouched);
|
17431 | }
|
17432 | var map = new NameMap();
|
17433 | namePathList.forEach(function(shortNamePath) {
|
17434 | map.set(shortNamePath, []);
|
17435 | });
|
17436 | fieldEntities.forEach(function(field) {
|
17437 | var fieldNamePath = field.getNamePath();
|
17438 | namePathList.forEach(function(shortNamePath) {
|
17439 | if (shortNamePath.every(function(nameUnit, i2) {
|
17440 | return fieldNamePath[i2] === nameUnit;
|
17441 | })) {
|
17442 | map.update(shortNamePath, function(list) {
|
17443 | return [].concat(_toConsumableArray(list), [field]);
|
17444 | });
|
17445 | }
|
17446 | });
|
17447 | });
|
17448 | var isNamePathListTouched = function isNamePathListTouched2(entities) {
|
17449 | return entities.some(isFieldTouched);
|
17450 | };
|
17451 | var namePathListEntities = map.map(function(_ref2) {
|
17452 | var value = _ref2.value;
|
17453 | return value;
|
17454 | });
|
17455 | return isAllFieldsTouched ? namePathListEntities.every(isNamePathListTouched) : namePathListEntities.some(isNamePathListTouched);
|
17456 | };
|
17457 | this.isFieldTouched = function(name) {
|
17458 | _this.warningUnhooked();
|
17459 | return _this.isFieldsTouched([name]);
|
17460 | };
|
17461 | this.isFieldsValidating = function(nameList) {
|
17462 | _this.warningUnhooked();
|
17463 | var fieldEntities = _this.getFieldEntities();
|
17464 | if (!nameList) {
|
17465 | return fieldEntities.some(function(testField) {
|
17466 | return testField.isFieldValidating();
|
17467 | });
|
17468 | }
|
17469 | var namePathList = nameList.map(getNamePath);
|
17470 | return fieldEntities.some(function(testField) {
|
17471 | var fieldNamePath = testField.getNamePath();
|
17472 | return containsNamePath(namePathList, fieldNamePath) && testField.isFieldValidating();
|
17473 | });
|
17474 | };
|
17475 | this.isFieldValidating = function(name) {
|
17476 | _this.warningUnhooked();
|
17477 | return _this.isFieldsValidating([name]);
|
17478 | };
|
17479 | this.resetWithFieldInitialValue = function() {
|
17480 | var info = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
17481 | var cache = new NameMap();
|
17482 | var fieldEntities = _this.getFieldEntities(true);
|
17483 | fieldEntities.forEach(function(field) {
|
17484 | var initialValue = field.props.initialValue;
|
17485 | var namePath = field.getNamePath();
|
17486 | if (initialValue !== void 0) {
|
17487 | var records = cache.get(namePath) || new Set();
|
17488 | records.add({
|
17489 | entity: field,
|
17490 | value: initialValue
|
17491 | });
|
17492 | cache.set(namePath, records);
|
17493 | }
|
17494 | });
|
17495 | var resetWithFields = function resetWithFields2(entities) {
|
17496 | entities.forEach(function(field) {
|
17497 | var initialValue = field.props.initialValue;
|
17498 | if (initialValue !== void 0) {
|
17499 | var namePath = field.getNamePath();
|
17500 | var formInitialValue = _this.getInitialValue(namePath);
|
17501 | if (formInitialValue !== void 0) {
|
17502 | warningOnce$1(false, "Form already set 'initialValues' with path '".concat(namePath.join("."), "'. Field can not overwrite it."));
|
17503 | } else {
|
17504 | var records = cache.get(namePath);
|
17505 | if (records && records.size > 1) {
|
17506 | warningOnce$1(false, "Multiple Field with path '".concat(namePath.join("."), "' set 'initialValue'. Can not decide which one to pick."));
|
17507 | } else if (records) {
|
17508 | var originValue = _this.getFieldValue(namePath);
|
17509 | if (!info.skipExist || originValue === void 0) {
|
17510 | _this.updateStore(setValue(_this.store, namePath, _toConsumableArray(records)[0].value));
|
17511 | }
|
17512 | }
|
17513 | }
|
17514 | }
|
17515 | });
|
17516 | };
|
17517 | var requiredFieldEntities;
|
17518 | if (info.entities) {
|
17519 | requiredFieldEntities = info.entities;
|
17520 | } else if (info.namePathList) {
|
17521 | requiredFieldEntities = [];
|
17522 | info.namePathList.forEach(function(namePath) {
|
17523 | var records = cache.get(namePath);
|
17524 | if (records) {
|
17525 | var _requiredFieldEntitie;
|
17526 | (_requiredFieldEntitie = requiredFieldEntities).push.apply(_requiredFieldEntitie, _toConsumableArray(_toConsumableArray(records).map(function(r) {
|
17527 | return r.entity;
|
17528 | })));
|
17529 | }
|
17530 | });
|
17531 | } else {
|
17532 | requiredFieldEntities = fieldEntities;
|
17533 | }
|
17534 | resetWithFields(requiredFieldEntities);
|
17535 | };
|
17536 | this.resetFields = function(nameList) {
|
17537 | _this.warningUnhooked();
|
17538 | var prevStore = _this.store;
|
17539 | if (!nameList) {
|
17540 | _this.updateStore(setValues({}, _this.initialValues));
|
17541 | _this.resetWithFieldInitialValue();
|
17542 | _this.notifyObservers(prevStore, null, {
|
17543 | type: "reset"
|
17544 | });
|
17545 | _this.notifyWatch();
|
17546 | return;
|
17547 | }
|
17548 | var namePathList = nameList.map(getNamePath);
|
17549 | namePathList.forEach(function(namePath) {
|
17550 | var initialValue = _this.getInitialValue(namePath);
|
17551 | _this.updateStore(setValue(_this.store, namePath, initialValue));
|
17552 | });
|
17553 | _this.resetWithFieldInitialValue({
|
17554 | namePathList
|
17555 | });
|
17556 | _this.notifyObservers(prevStore, namePathList, {
|
17557 | type: "reset"
|
17558 | });
|
17559 | _this.notifyWatch(namePathList);
|
17560 | };
|
17561 | this.setFields = function(fields) {
|
17562 | _this.warningUnhooked();
|
17563 | var prevStore = _this.store;
|
17564 | var namePathList = [];
|
17565 | fields.forEach(function(fieldData) {
|
17566 | var name = fieldData.name;
|
17567 | fieldData.errors;
|
17568 | var data = _objectWithoutProperties(fieldData, _excluded$1);
|
17569 | var namePath = getNamePath(name);
|
17570 | namePathList.push(namePath);
|
17571 | if ("value" in data) {
|
17572 | _this.updateStore(setValue(_this.store, namePath, data.value));
|
17573 | }
|
17574 | _this.notifyObservers(prevStore, [namePath], {
|
17575 | type: "setField",
|
17576 | data: fieldData
|
17577 | });
|
17578 | });
|
17579 | _this.notifyWatch(namePathList);
|
17580 | };
|
17581 | this.getFields = function() {
|
17582 | var entities = _this.getFieldEntities(true);
|
17583 | var fields = entities.map(function(field) {
|
17584 | var namePath = field.getNamePath();
|
17585 | var meta = field.getMeta();
|
17586 | var fieldData = _objectSpread2(_objectSpread2({}, meta), {}, {
|
17587 | name: namePath,
|
17588 | value: _this.getFieldValue(namePath)
|
17589 | });
|
17590 | Object.defineProperty(fieldData, "originRCField", {
|
17591 | value: true
|
17592 | });
|
17593 | return fieldData;
|
17594 | });
|
17595 | return fields;
|
17596 | };
|
17597 | this.initEntityValue = function(entity) {
|
17598 | var initialValue = entity.props.initialValue;
|
17599 | if (initialValue !== void 0) {
|
17600 | var namePath = entity.getNamePath();
|
17601 | var prevValue = getValue(_this.store, namePath);
|
17602 | if (prevValue === void 0) {
|
17603 | _this.updateStore(setValue(_this.store, namePath, initialValue));
|
17604 | }
|
17605 | }
|
17606 | };
|
17607 | this.isMergedPreserve = function(fieldPreserve) {
|
17608 | var mergedPreserve = fieldPreserve !== void 0 ? fieldPreserve : _this.preserve;
|
17609 | return mergedPreserve !== null && mergedPreserve !== void 0 ? mergedPreserve : true;
|
17610 | };
|
17611 | this.registerField = function(entity) {
|
17612 | _this.fieldEntities.push(entity);
|
17613 | var namePath = entity.getNamePath();
|
17614 | _this.notifyWatch([namePath]);
|
17615 | if (entity.props.initialValue !== void 0) {
|
17616 | var prevStore = _this.store;
|
17617 | _this.resetWithFieldInitialValue({
|
17618 | entities: [entity],
|
17619 | skipExist: true
|
17620 | });
|
17621 | _this.notifyObservers(prevStore, [entity.getNamePath()], {
|
17622 | type: "valueUpdate",
|
17623 | source: "internal"
|
17624 | });
|
17625 | }
|
17626 | return function(isListField, preserve) {
|
17627 | var subNamePath = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
|
17628 | _this.fieldEntities = _this.fieldEntities.filter(function(item) {
|
17629 | return item !== entity;
|
17630 | });
|
17631 | if (!_this.isMergedPreserve(preserve) && (!isListField || subNamePath.length > 1)) {
|
17632 | var defaultValue = isListField ? void 0 : _this.getInitialValue(namePath);
|
17633 | if (namePath.length && _this.getFieldValue(namePath) !== defaultValue && _this.fieldEntities.every(function(field) {
|
17634 | return (
|
17635 |
|
17636 | !matchNamePath(field.getNamePath(), namePath)
|
17637 | );
|
17638 | })) {
|
17639 | var _prevStore = _this.store;
|
17640 | _this.updateStore(setValue(_prevStore, namePath, defaultValue, true));
|
17641 | _this.notifyObservers(_prevStore, [namePath], {
|
17642 | type: "remove"
|
17643 | });
|
17644 | _this.triggerDependenciesUpdate(_prevStore, namePath);
|
17645 | }
|
17646 | }
|
17647 | _this.notifyWatch([namePath]);
|
17648 | };
|
17649 | };
|
17650 | this.dispatch = function(action) {
|
17651 | switch (action.type) {
|
17652 | case "updateValue": {
|
17653 | var namePath = action.namePath, value = action.value;
|
17654 | _this.updateValue(namePath, value);
|
17655 | break;
|
17656 | }
|
17657 | case "validateField": {
|
17658 | var _namePath = action.namePath, triggerName = action.triggerName;
|
17659 | _this.validateFields([_namePath], {
|
17660 | triggerName
|
17661 | });
|
17662 | break;
|
17663 | }
|
17664 | }
|
17665 | };
|
17666 | this.notifyObservers = function(prevStore, namePathList, info) {
|
17667 | if (_this.subscribable) {
|
17668 | var mergedInfo = _objectSpread2(_objectSpread2({}, info), {}, {
|
17669 | store: _this.getFieldsValue(true)
|
17670 | });
|
17671 | _this.getFieldEntities().forEach(function(_ref3) {
|
17672 | var onStoreChange = _ref3.onStoreChange;
|
17673 | onStoreChange(prevStore, namePathList, mergedInfo);
|
17674 | });
|
17675 | } else {
|
17676 | _this.forceRootUpdate();
|
17677 | }
|
17678 | };
|
17679 | this.triggerDependenciesUpdate = function(prevStore, namePath) {
|
17680 | var childrenFields = _this.getDependencyChildrenFields(namePath);
|
17681 | if (childrenFields.length) {
|
17682 | _this.validateFields(childrenFields);
|
17683 | }
|
17684 | _this.notifyObservers(prevStore, childrenFields, {
|
17685 | type: "dependenciesUpdate",
|
17686 | relatedFields: [namePath].concat(_toConsumableArray(childrenFields))
|
17687 | });
|
17688 | return childrenFields;
|
17689 | };
|
17690 | this.updateValue = function(name, value) {
|
17691 | var namePath = getNamePath(name);
|
17692 | var prevStore = _this.store;
|
17693 | _this.updateStore(setValue(_this.store, namePath, value));
|
17694 | _this.notifyObservers(prevStore, [namePath], {
|
17695 | type: "valueUpdate",
|
17696 | source: "internal"
|
17697 | });
|
17698 | _this.notifyWatch([namePath]);
|
17699 | var childrenFields = _this.triggerDependenciesUpdate(prevStore, namePath);
|
17700 | var onValuesChange = _this.callbacks.onValuesChange;
|
17701 | if (onValuesChange) {
|
17702 | var changedValues = cloneByNamePathList(_this.store, [namePath]);
|
17703 | onValuesChange(changedValues, _this.getFieldsValue());
|
17704 | }
|
17705 | _this.triggerOnFieldsChange([namePath].concat(_toConsumableArray(childrenFields)));
|
17706 | };
|
17707 | this.setFieldsValue = function(store) {
|
17708 | _this.warningUnhooked();
|
17709 | var prevStore = _this.store;
|
17710 | if (store) {
|
17711 | var nextStore = setValues(_this.store, store);
|
17712 | _this.updateStore(nextStore);
|
17713 | }
|
17714 | _this.notifyObservers(prevStore, null, {
|
17715 | type: "valueUpdate",
|
17716 | source: "external"
|
17717 | });
|
17718 | _this.notifyWatch();
|
17719 | };
|
17720 | this.setFieldValue = function(name, value) {
|
17721 | _this.setFields([{
|
17722 | name,
|
17723 | value
|
17724 | }]);
|
17725 | };
|
17726 | this.getDependencyChildrenFields = function(rootNamePath) {
|
17727 | var children = new Set();
|
17728 | var childrenFields = [];
|
17729 | var dependencies2fields = new NameMap();
|
17730 | _this.getFieldEntities().forEach(function(field) {
|
17731 | var dependencies = field.props.dependencies;
|
17732 | (dependencies || []).forEach(function(dependency) {
|
17733 | var dependencyNamePath = getNamePath(dependency);
|
17734 | dependencies2fields.update(dependencyNamePath, function() {
|
17735 | var fields = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : new Set();
|
17736 | fields.add(field);
|
17737 | return fields;
|
17738 | });
|
17739 | });
|
17740 | });
|
17741 | var fillChildren = function fillChildren2(namePath) {
|
17742 | var fields = dependencies2fields.get(namePath) || new Set();
|
17743 | fields.forEach(function(field) {
|
17744 | if (!children.has(field)) {
|
17745 | children.add(field);
|
17746 | var fieldNamePath = field.getNamePath();
|
17747 | if (field.isFieldDirty() && fieldNamePath.length) {
|
17748 | childrenFields.push(fieldNamePath);
|
17749 | fillChildren2(fieldNamePath);
|
17750 | }
|
17751 | }
|
17752 | });
|
17753 | };
|
17754 | fillChildren(rootNamePath);
|
17755 | return childrenFields;
|
17756 | };
|
17757 | this.triggerOnFieldsChange = function(namePathList, filedErrors) {
|
17758 | var onFieldsChange = _this.callbacks.onFieldsChange;
|
17759 | if (onFieldsChange) {
|
17760 | var fields = _this.getFields();
|
17761 | if (filedErrors) {
|
17762 | var cache = new NameMap();
|
17763 | filedErrors.forEach(function(_ref4) {
|
17764 | var name = _ref4.name, errors = _ref4.errors;
|
17765 | cache.set(name, errors);
|
17766 | });
|
17767 | fields.forEach(function(field) {
|
17768 | field.errors = cache.get(field.name) || field.errors;
|
17769 | });
|
17770 | }
|
17771 | var changedFields = fields.filter(function(_ref5) {
|
17772 | var fieldName = _ref5.name;
|
17773 | return containsNamePath(namePathList, fieldName);
|
17774 | });
|
17775 | onFieldsChange(changedFields, fields);
|
17776 | }
|
17777 | };
|
17778 | this.validateFields = function(nameList, options) {
|
17779 | _this.warningUnhooked();
|
17780 | var provideNameList = !!nameList;
|
17781 | var namePathList = provideNameList ? nameList.map(getNamePath) : [];
|
17782 | var promiseList = [];
|
17783 | _this.getFieldEntities(true).forEach(function(field) {
|
17784 | if (!provideNameList) {
|
17785 | namePathList.push(field.getNamePath());
|
17786 | }
|
17787 | if ((options === null || options === void 0 ? void 0 : options.recursive) && provideNameList) {
|
17788 | var namePath = field.getNamePath();
|
17789 | if (
|
17790 |
|
17791 |
|
17792 | namePath.every(function(nameUnit, i2) {
|
17793 | return nameList[i2] === nameUnit || nameList[i2] === void 0;
|
17794 | })
|
17795 | ) {
|
17796 | namePathList.push(namePath);
|
17797 | }
|
17798 | }
|
17799 | if (!field.props.rules || !field.props.rules.length) {
|
17800 | return;
|
17801 | }
|
17802 | var fieldNamePath = field.getNamePath();
|
17803 | if (!provideNameList || containsNamePath(namePathList, fieldNamePath)) {
|
17804 | var promise = field.validateRules(_objectSpread2({
|
17805 | validateMessages: _objectSpread2(_objectSpread2({}, defaultValidateMessages), _this.validateMessages)
|
17806 | }, options));
|
17807 | promiseList.push(promise.then(function() {
|
17808 | return {
|
17809 | name: fieldNamePath,
|
17810 | errors: [],
|
17811 | warnings: []
|
17812 | };
|
17813 | }).catch(function(ruleErrors) {
|
17814 | var _ruleErrors$forEach;
|
17815 | var mergedErrors = [];
|
17816 | var mergedWarnings = [];
|
17817 | (_ruleErrors$forEach = ruleErrors.forEach) === null || _ruleErrors$forEach === void 0 ? void 0 : _ruleErrors$forEach.call(ruleErrors, function(_ref6) {
|
17818 | var warningOnly = _ref6.rule.warningOnly, errors = _ref6.errors;
|
17819 | if (warningOnly) {
|
17820 | mergedWarnings.push.apply(mergedWarnings, _toConsumableArray(errors));
|
17821 | } else {
|
17822 | mergedErrors.push.apply(mergedErrors, _toConsumableArray(errors));
|
17823 | }
|
17824 | });
|
17825 | if (mergedErrors.length) {
|
17826 | return Promise.reject({
|
17827 | name: fieldNamePath,
|
17828 | errors: mergedErrors,
|
17829 | warnings: mergedWarnings
|
17830 | });
|
17831 | }
|
17832 | return {
|
17833 | name: fieldNamePath,
|
17834 | errors: mergedErrors,
|
17835 | warnings: mergedWarnings
|
17836 | };
|
17837 | }));
|
17838 | }
|
17839 | });
|
17840 | var summaryPromise = allPromiseFinish(promiseList);
|
17841 | _this.lastValidatePromise = summaryPromise;
|
17842 | summaryPromise.catch(function(results) {
|
17843 | return results;
|
17844 | }).then(function(results) {
|
17845 | var resultNamePathList = results.map(function(_ref7) {
|
17846 | var name = _ref7.name;
|
17847 | return name;
|
17848 | });
|
17849 | _this.notifyObservers(_this.store, resultNamePathList, {
|
17850 | type: "validateFinish"
|
17851 | });
|
17852 | _this.triggerOnFieldsChange(resultNamePathList, results);
|
17853 | });
|
17854 | var returnPromise = summaryPromise.then(function() {
|
17855 | if (_this.lastValidatePromise === summaryPromise) {
|
17856 | return Promise.resolve(_this.getFieldsValue(namePathList));
|
17857 | }
|
17858 | return Promise.reject([]);
|
17859 | }).catch(function(results) {
|
17860 | var errorList = results.filter(function(result) {
|
17861 | return result && result.errors.length;
|
17862 | });
|
17863 | return Promise.reject({
|
17864 | values: _this.getFieldsValue(namePathList),
|
17865 | errorFields: errorList,
|
17866 | outOfDate: _this.lastValidatePromise !== summaryPromise
|
17867 | });
|
17868 | });
|
17869 | returnPromise.catch(function(e2) {
|
17870 | return e2;
|
17871 | });
|
17872 | return returnPromise;
|
17873 | };
|
17874 | this.submit = function() {
|
17875 | _this.warningUnhooked();
|
17876 | _this.validateFields().then(function(values) {
|
17877 | var onFinish = _this.callbacks.onFinish;
|
17878 | if (onFinish) {
|
17879 | try {
|
17880 | onFinish(values);
|
17881 | } catch (err) {
|
17882 | console.error(err);
|
17883 | }
|
17884 | }
|
17885 | }).catch(function(e2) {
|
17886 | var onFinishFailed = _this.callbacks.onFinishFailed;
|
17887 | if (onFinishFailed) {
|
17888 | onFinishFailed(e2);
|
17889 | }
|
17890 | });
|
17891 | };
|
17892 | this.forceRootUpdate = forceRootUpdate;
|
17893 | });
|
17894 | function useForm(form) {
|
17895 | var formRef = React__namespace.useRef();
|
17896 | var _React$useState = React__namespace.useState({}), _React$useState2 = _slicedToArray(_React$useState, 2), forceUpdate = _React$useState2[1];
|
17897 | if (!formRef.current) {
|
17898 | if (form) {
|
17899 | formRef.current = form;
|
17900 | } else {
|
17901 | var forceReRender = function forceReRender2() {
|
17902 | forceUpdate({});
|
17903 | };
|
17904 | var formStore = new FormStore(forceReRender);
|
17905 | formRef.current = formStore.getForm();
|
17906 | }
|
17907 | }
|
17908 | return [formRef.current];
|
17909 | }
|
17910 | var FormContext$1 = React__namespace.createContext({
|
17911 | triggerFormChange: function triggerFormChange() {
|
17912 | },
|
17913 | triggerFormFinish: function triggerFormFinish() {
|
17914 | },
|
17915 | registerForm: function registerForm() {
|
17916 | },
|
17917 | unregisterForm: function unregisterForm() {
|
17918 | }
|
17919 | });
|
17920 | var FormProvider = function FormProvider2(_ref) {
|
17921 | var validateMessages = _ref.validateMessages, onFormChange = _ref.onFormChange, onFormFinish = _ref.onFormFinish, children = _ref.children;
|
17922 | var formContext = React__namespace.useContext(FormContext$1);
|
17923 | var formsRef = React__namespace.useRef({});
|
17924 | return React__namespace.createElement(FormContext$1.Provider, {
|
17925 | value: _objectSpread2(_objectSpread2({}, formContext), {}, {
|
17926 | validateMessages: _objectSpread2(_objectSpread2({}, formContext.validateMessages), validateMessages),
|
17927 |
|
17928 |
|
17929 |
|
17930 | triggerFormChange: function triggerFormChange(name, changedFields) {
|
17931 | if (onFormChange) {
|
17932 | onFormChange(name, {
|
17933 | changedFields,
|
17934 | forms: formsRef.current
|
17935 | });
|
17936 | }
|
17937 | formContext.triggerFormChange(name, changedFields);
|
17938 | },
|
17939 | triggerFormFinish: function triggerFormFinish(name, values) {
|
17940 | if (onFormFinish) {
|
17941 | onFormFinish(name, {
|
17942 | values,
|
17943 | forms: formsRef.current
|
17944 | });
|
17945 | }
|
17946 | formContext.triggerFormFinish(name, values);
|
17947 | },
|
17948 | registerForm: function registerForm(name, form) {
|
17949 | if (name) {
|
17950 | formsRef.current = _objectSpread2(_objectSpread2({}, formsRef.current), {}, _defineProperty({}, name, form));
|
17951 | }
|
17952 | formContext.registerForm(name, form);
|
17953 | },
|
17954 | unregisterForm: function unregisterForm(name) {
|
17955 | var newForms = _objectSpread2({}, formsRef.current);
|
17956 | delete newForms[name];
|
17957 | formsRef.current = newForms;
|
17958 | formContext.unregisterForm(name);
|
17959 | }
|
17960 | })
|
17961 | }, children);
|
17962 | };
|
17963 | var _excluded = ["name", "initialValues", "fields", "form", "preserve", "children", "component", "validateMessages", "validateTrigger", "onValuesChange", "onFieldsChange", "onFinish", "onFinishFailed"];
|
17964 | var Form$1 = function Form2(_ref, ref) {
|
17965 | var name = _ref.name, initialValues = _ref.initialValues, fields = _ref.fields, form = _ref.form, preserve = _ref.preserve, children = _ref.children, _ref$component = _ref.component, Component = _ref$component === void 0 ? "form" : _ref$component, validateMessages = _ref.validateMessages, _ref$validateTrigger = _ref.validateTrigger, validateTrigger = _ref$validateTrigger === void 0 ? "onChange" : _ref$validateTrigger, onValuesChange = _ref.onValuesChange, _onFieldsChange = _ref.onFieldsChange, _onFinish = _ref.onFinish, onFinishFailed = _ref.onFinishFailed, restProps = _objectWithoutProperties(_ref, _excluded);
|
17966 | var formContext = React__namespace.useContext(FormContext$1);
|
17967 | var _useForm = useForm(form), _useForm2 = _slicedToArray(_useForm, 1), formInstance = _useForm2[0];
|
17968 | var _formInstance$getInte = formInstance.getInternalHooks(HOOK_MARK$1), useSubscribe = _formInstance$getInte.useSubscribe, setInitialValues = _formInstance$getInte.setInitialValues, setCallbacks = _formInstance$getInte.setCallbacks, setValidateMessages = _formInstance$getInte.setValidateMessages, setPreserve = _formInstance$getInte.setPreserve, destroyForm = _formInstance$getInte.destroyForm;
|
17969 | React__namespace.useImperativeHandle(ref, function() {
|
17970 | return formInstance;
|
17971 | });
|
17972 | React__namespace.useEffect(function() {
|
17973 | formContext.registerForm(name, formInstance);
|
17974 | return function() {
|
17975 | formContext.unregisterForm(name);
|
17976 | };
|
17977 | }, [formContext, formInstance, name]);
|
17978 | setValidateMessages(_objectSpread2(_objectSpread2({}, formContext.validateMessages), validateMessages));
|
17979 | setCallbacks({
|
17980 | onValuesChange,
|
17981 | onFieldsChange: function onFieldsChange(changedFields) {
|
17982 | formContext.triggerFormChange(name, changedFields);
|
17983 | if (_onFieldsChange) {
|
17984 | for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
17985 | rest[_key - 1] = arguments[_key];
|
17986 | }
|
17987 | _onFieldsChange.apply(void 0, [changedFields].concat(rest));
|
17988 | }
|
17989 | },
|
17990 | onFinish: function onFinish(values2) {
|
17991 | formContext.triggerFormFinish(name, values2);
|
17992 | if (_onFinish) {
|
17993 | _onFinish(values2);
|
17994 | }
|
17995 | },
|
17996 | onFinishFailed
|
17997 | });
|
17998 | setPreserve(preserve);
|
17999 | var mountRef = React__namespace.useRef(null);
|
18000 | setInitialValues(initialValues, !mountRef.current);
|
18001 | if (!mountRef.current) {
|
18002 | mountRef.current = true;
|
18003 | }
|
18004 | React__namespace.useEffect(
|
18005 | function() {
|
18006 | return destroyForm;
|
18007 | },
|
18008 |
|
18009 | []
|
18010 | );
|
18011 | var childrenNode;
|
18012 | var childrenRenderProps = typeof children === "function";
|
18013 | if (childrenRenderProps) {
|
18014 | var values = formInstance.getFieldsValue(true);
|
18015 | childrenNode = children(values, formInstance);
|
18016 | } else {
|
18017 | childrenNode = children;
|
18018 | }
|
18019 | useSubscribe(!childrenRenderProps);
|
18020 | var prevFieldsRef = React__namespace.useRef();
|
18021 | React__namespace.useEffect(function() {
|
18022 | if (!isSimilar(prevFieldsRef.current || [], fields || [])) {
|
18023 | formInstance.setFields(fields || []);
|
18024 | }
|
18025 | prevFieldsRef.current = fields;
|
18026 | }, [fields, formInstance]);
|
18027 | var formContextValue = React__namespace.useMemo(function() {
|
18028 | return _objectSpread2(_objectSpread2({}, formInstance), {}, {
|
18029 | validateTrigger
|
18030 | });
|
18031 | }, [formInstance, validateTrigger]);
|
18032 | var wrapperNode = React__namespace.createElement(Context$1.Provider, {
|
18033 | value: formContextValue
|
18034 | }, childrenNode);
|
18035 | if (Component === false) {
|
18036 | return wrapperNode;
|
18037 | }
|
18038 | return React__namespace.createElement(Component, _extends$1({}, restProps, {
|
18039 | onSubmit: function onSubmit(event) {
|
18040 | event.preventDefault();
|
18041 | event.stopPropagation();
|
18042 | formInstance.submit();
|
18043 | },
|
18044 | onReset: function onReset(event) {
|
18045 | var _restProps$onReset;
|
18046 | event.preventDefault();
|
18047 | formInstance.resetFields();
|
18048 | (_restProps$onReset = restProps.onReset) === null || _restProps$onReset === void 0 ? void 0 : _restProps$onReset.call(restProps, event);
|
18049 | }
|
18050 | }), wrapperNode);
|
18051 | };
|
18052 | function stringify(value) {
|
18053 | try {
|
18054 | return JSON.stringify(value);
|
18055 | } catch (err) {
|
18056 | return Math.random();
|
18057 | }
|
18058 | }
|
18059 | var useWatchWarning = function(namePath) {
|
18060 | var fullyStr = namePath.join("__RC_FIELD_FORM_SPLIT__");
|
18061 | var nameStrRef = React$1.useRef(fullyStr);
|
18062 | warningOnce$1(nameStrRef.current === fullyStr, "`useWatch` is not support dynamic `namePath`. Please provide static instead.");
|
18063 | };
|
18064 | function useWatch() {
|
18065 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
18066 | args[_key] = arguments[_key];
|
18067 | }
|
18068 | var _args$ = args[0], dependencies = _args$ === void 0 ? [] : _args$, form = args[1];
|
18069 | var _useState = React$1.useState(), _useState2 = _slicedToArray(_useState, 2), value = _useState2[0], setValue2 = _useState2[1];
|
18070 | var valueStr = React$1.useMemo(function() {
|
18071 | return stringify(value);
|
18072 | }, [value]);
|
18073 | var valueStrRef = React$1.useRef(valueStr);
|
18074 | valueStrRef.current = valueStr;
|
18075 | var fieldContext = React$1.useContext(Context$1);
|
18076 | var formInstance = form || fieldContext;
|
18077 | var isValidForm = formInstance && formInstance._init;
|
18078 | {
|
18079 | warningOnce$1(args.length === 2 ? form ? isValidForm : true : isValidForm, "useWatch requires a form instance since it can not auto detect from context.");
|
18080 | }
|
18081 | var namePath = getNamePath(dependencies);
|
18082 | var namePathRef = React$1.useRef(namePath);
|
18083 | namePathRef.current = namePath;
|
18084 | useWatchWarning(namePath);
|
18085 | React$1.useEffect(
|
18086 | function() {
|
18087 | if (!isValidForm) {
|
18088 | return;
|
18089 | }
|
18090 | var getFieldsValue = formInstance.getFieldsValue, getInternalHooks = formInstance.getInternalHooks;
|
18091 | var _getInternalHooks = getInternalHooks(HOOK_MARK$1), registerWatch = _getInternalHooks.registerWatch;
|
18092 | var cancelRegister = registerWatch(function(store) {
|
18093 | var newValue = getValue(store, namePathRef.current);
|
18094 | var nextValueStr = stringify(newValue);
|
18095 | if (valueStrRef.current !== nextValueStr) {
|
18096 | valueStrRef.current = nextValueStr;
|
18097 | setValue2(newValue);
|
18098 | }
|
18099 | });
|
18100 | var initialValue = getValue(getFieldsValue(), namePathRef.current);
|
18101 | setValue2(initialValue);
|
18102 | return cancelRegister;
|
18103 | },
|
18104 |
|
18105 |
|
18106 | [isValidForm]
|
18107 | );
|
18108 | return value;
|
18109 | }
|
18110 | var InternalForm = React__namespace.forwardRef(Form$1);
|
18111 | var RefForm = InternalForm;
|
18112 | RefForm.FormProvider = FormProvider;
|
18113 | RefForm.Field = WrapperField;
|
18114 | RefForm.List = List;
|
18115 | RefForm.useForm = useForm;
|
18116 | RefForm.useWatch = useWatch;
|
18117 | const defaultFormContext = {
|
18118 | name: void 0,
|
18119 | hasFeedback: true,
|
18120 | layout: "vertical",
|
18121 | requiredMarkStyle: "asterisk",
|
18122 | disabled: false
|
18123 | };
|
18124 | const FormContext = React$1.createContext(defaultFormContext);
|
18125 | const NoStyleItemContext = React$1.createContext(null);
|
18126 | const Header = () => null;
|
18127 | var isMergeableObject = function isMergeableObject2(value) {
|
18128 | return isNonNullObject(value) && !isSpecial(value);
|
18129 | };
|
18130 | function isNonNullObject(value) {
|
18131 | return !!value && typeof value === "object";
|
18132 | }
|
18133 | function isSpecial(value) {
|
18134 | var stringValue = Object.prototype.toString.call(value);
|
18135 | return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
|
18136 | }
|
18137 | var canUseSymbol = typeof Symbol === "function" && Symbol.for;
|
18138 | var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for("react.element") : 60103;
|
18139 | function isReactElement(value) {
|
18140 | return value.$$typeof === REACT_ELEMENT_TYPE;
|
18141 | }
|
18142 | function emptyTarget(val) {
|
18143 | return Array.isArray(val) ? [] : {};
|
18144 | }
|
18145 | function cloneUnlessOtherwiseSpecified(value, options) {
|
18146 | return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value;
|
18147 | }
|
18148 | function defaultArrayMerge(target, source, options) {
|
18149 | return target.concat(source).map(function(element) {
|
18150 | return cloneUnlessOtherwiseSpecified(element, options);
|
18151 | });
|
18152 | }
|
18153 | function getMergeFunction(key, options) {
|
18154 | if (!options.customMerge) {
|
18155 | return deepmerge;
|
18156 | }
|
18157 | var customMerge = options.customMerge(key);
|
18158 | return typeof customMerge === "function" ? customMerge : deepmerge;
|
18159 | }
|
18160 | function getEnumerableOwnPropertySymbols(target) {
|
18161 | return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
18162 | return Object.propertyIsEnumerable.call(target, symbol);
|
18163 | }) : [];
|
18164 | }
|
18165 | function getKeys(target) {
|
18166 | return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
|
18167 | }
|
18168 | function propertyIsOnObject(object, property) {
|
18169 | try {
|
18170 | return property in object;
|
18171 | } catch (_) {
|
18172 | return false;
|
18173 | }
|
18174 | }
|
18175 | function propertyIsUnsafe(target, key) {
|
18176 | return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
|
18177 | }
|
18178 | function mergeObject(target, source, options) {
|
18179 | var destination = {};
|
18180 | if (options.isMergeableObject(target)) {
|
18181 | getKeys(target).forEach(function(key) {
|
18182 | destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
|
18183 | });
|
18184 | }
|
18185 | getKeys(source).forEach(function(key) {
|
18186 | if (propertyIsUnsafe(target, key)) {
|
18187 | return;
|
18188 | }
|
18189 | if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
|
18190 | destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
|
18191 | } else {
|
18192 | destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
|
18193 | }
|
18194 | });
|
18195 | return destination;
|
18196 | }
|
18197 | function deepmerge(target, source, options) {
|
18198 | options = options || {};
|
18199 | options.arrayMerge = options.arrayMerge || defaultArrayMerge;
|
18200 | options.isMergeableObject = options.isMergeableObject || isMergeableObject;
|
18201 | options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
|
18202 | var sourceIsArray = Array.isArray(source);
|
18203 | var targetIsArray = Array.isArray(target);
|
18204 | var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
|
18205 | if (!sourceAndTargetTypesMatch) {
|
18206 | return cloneUnlessOtherwiseSpecified(source, options);
|
18207 | } else if (sourceIsArray) {
|
18208 | return options.arrayMerge(target, source, options);
|
18209 | } else {
|
18210 | return mergeObject(target, source, options);
|
18211 | }
|
18212 | }
|
18213 | deepmerge.all = function deepmergeAll(array, options) {
|
18214 | if (!Array.isArray(array)) {
|
18215 | throw new Error("first argument should be an array");
|
18216 | }
|
18217 | return array.reduce(function(prev, next) {
|
18218 | return deepmerge(prev, next, options);
|
18219 | }, {});
|
18220 | };
|
18221 | var deepmerge_1 = deepmerge;
|
18222 | var cjs = deepmerge_1;
|
18223 | const merge = getDefaultExportFromCjs(cjs);
|
18224 | const FormArray = (props) => {
|
18225 | return React$1.createElement(List, {
|
18226 | name: props.name,
|
18227 | initialValue: props.initialValue
|
18228 | }, (rcFields, operation) => {
|
18229 | const fields = rcFields.map((field) => ({
|
18230 | index: field.name,
|
18231 | key: field.key
|
18232 | }));
|
18233 | const children = props.children(fields, operation).map((child, index2) => {
|
18234 | var _a;
|
18235 | return React$1.createElement(List$1, {
|
18236 | key: fields[index2].key,
|
18237 | mode: "card",
|
18238 | header: (_a = props.renderHeader) === null || _a === void 0 ? void 0 : _a.call(props, fields[index2], operation)
|
18239 | }, child);
|
18240 | });
|
18241 | if (props.renderAdd) {
|
18242 | children.push(React$1.createElement(List$1, {
|
18243 | key: "add",
|
18244 | mode: "card"
|
18245 | }, React$1.createElement(List$1.Item, {
|
18246 | className: "adm-form-list-operation",
|
18247 | onClick: () => {
|
18248 | props.onAdd ? props.onAdd(operation) : operation.add();
|
18249 | },
|
18250 | arrow: false
|
18251 | }, props.renderAdd())));
|
18252 | }
|
18253 | return React$1.createElement(React$1.Fragment, null, children);
|
18254 | });
|
18255 | };
|
18256 | const classPrefix$O = "adm-form";
|
18257 | const defaultProps$B = defaultFormContext;
|
18258 | const Form = React$1.forwardRef((p, ref) => {
|
18259 | const props = mergeProps(defaultProps$B, p);
|
18260 | const {
|
18261 | className,
|
18262 | style,
|
18263 | hasFeedback,
|
18264 | children,
|
18265 | layout,
|
18266 | footer,
|
18267 | mode,
|
18268 | disabled,
|
18269 | requiredMarkStyle
|
18270 | } = props, formProps = __rest(props, ["className", "style", "hasFeedback", "children", "layout", "footer", "mode", "disabled", "requiredMarkStyle"]);
|
18271 | const {
|
18272 | locale
|
18273 | } = useConfig();
|
18274 | const validateMessages = React$1.useMemo(() => merge(locale.Form.defaultValidateMessages, formProps.validateMessages || {}), [locale.Form.defaultValidateMessages, formProps.validateMessages]);
|
18275 | const lists = [];
|
18276 | let currentHeader = null;
|
18277 | let items = [];
|
18278 | let count = 0;
|
18279 | function collect() {
|
18280 | if (items.length === 0)
|
18281 | return;
|
18282 | count += 1;
|
18283 | lists.push(React$1.createElement(List$1, {
|
18284 | header: currentHeader,
|
18285 | key: count,
|
18286 | mode
|
18287 | }, items));
|
18288 | items = [];
|
18289 | }
|
18290 | traverseReactNode(props.children, (child) => {
|
18291 | if (React$1.isValidElement(child)) {
|
18292 | if (child.type === Header) {
|
18293 | collect();
|
18294 | currentHeader = child.props.children;
|
18295 | return;
|
18296 | }
|
18297 | if (child.type === FormArray) {
|
18298 | collect();
|
18299 | lists.push(child);
|
18300 | return;
|
18301 | }
|
18302 | }
|
18303 | items.push(child);
|
18304 | });
|
18305 | collect();
|
18306 | return React$1.createElement(RefForm, Object.assign({
|
18307 | className: classNames(classPrefix$O, className),
|
18308 | style,
|
18309 | ref
|
18310 | }, formProps, {
|
18311 | validateMessages
|
18312 | }), React$1.createElement(FormContext.Provider, {
|
18313 | value: {
|
18314 | name: formProps.name,
|
18315 | hasFeedback,
|
18316 | layout,
|
18317 | requiredMarkStyle,
|
18318 | disabled
|
18319 | }
|
18320 | }, lists), footer && React$1.createElement("div", {
|
18321 | className: `${classPrefix$O}-footer`
|
18322 | }, footer));
|
18323 | });
|
18324 | var FieldContext = {};
|
18325 | var interopRequireWildcard = { exports: {} };
|
18326 | var _typeof = { exports: {} };
|
18327 | (function(module2) {
|
18328 | function _typeof2(o) {
|
18329 | "@babel/helpers - typeof";
|
18330 | return module2.exports = _typeof2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
18331 | return typeof o2;
|
18332 | } : function(o2) {
|
18333 | return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
18334 | }, module2.exports.__esModule = true, module2.exports["default"] = module2.exports, _typeof2(o);
|
18335 | }
|
18336 | module2.exports = _typeof2, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
|
18337 | })(_typeof);
|
18338 | var _typeofExports = _typeof.exports;
|
18339 | (function(module2) {
|
18340 | var _typeof2 = _typeofExports["default"];
|
18341 | function _getRequireWildcardCache(nodeInterop) {
|
18342 | if (typeof WeakMap !== "function")
|
18343 | return null;
|
18344 | var cacheBabelInterop = new WeakMap();
|
18345 | var cacheNodeInterop = new WeakMap();
|
18346 | return (_getRequireWildcardCache = function _getRequireWildcardCache2(nodeInterop2) {
|
18347 | return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
|
18348 | })(nodeInterop);
|
18349 | }
|
18350 | function _interopRequireWildcard2(obj, nodeInterop) {
|
18351 | if (!nodeInterop && obj && obj.__esModule) {
|
18352 | return obj;
|
18353 | }
|
18354 | if (obj === null || _typeof2(obj) !== "object" && typeof obj !== "function") {
|
18355 | return {
|
18356 | "default": obj
|
18357 | };
|
18358 | }
|
18359 | var cache = _getRequireWildcardCache(nodeInterop);
|
18360 | if (cache && cache.has(obj)) {
|
18361 | return cache.get(obj);
|
18362 | }
|
18363 | var newObj = {};
|
18364 | var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
18365 | for (var key in obj) {
|
18366 | if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
18367 | var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
18368 | if (desc && (desc.get || desc.set)) {
|
18369 | Object.defineProperty(newObj, key, desc);
|
18370 | } else {
|
18371 | newObj[key] = obj[key];
|
18372 | }
|
18373 | }
|
18374 | }
|
18375 | newObj["default"] = obj;
|
18376 | if (cache) {
|
18377 | cache.set(obj, newObj);
|
18378 | }
|
18379 | return newObj;
|
18380 | }
|
18381 | module2.exports = _interopRequireWildcard2, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
|
18382 | })(interopRequireWildcard);
|
18383 | var interopRequireWildcardExports = interopRequireWildcard.exports;
|
18384 | var interopRequireDefault = { exports: {} };
|
18385 | (function(module2) {
|
18386 | function _interopRequireDefault2(obj) {
|
18387 | return obj && obj.__esModule ? obj : {
|
18388 | "default": obj
|
18389 | };
|
18390 | }
|
18391 | module2.exports = _interopRequireDefault2, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
|
18392 | })(interopRequireDefault);
|
18393 | var interopRequireDefaultExports = interopRequireDefault.exports;
|
18394 | var warning$1 = {};
|
18395 | Object.defineProperty(warning$1, "__esModule", {
|
18396 | value: true
|
18397 | });
|
18398 | warning$1.call = call;
|
18399 | warning$1.default = void 0;
|
18400 | warning$1.note = note;
|
18401 | warning$1.noteOnce = noteOnce;
|
18402 | warning$1.preMessage = void 0;
|
18403 | warning$1.resetWarned = resetWarned;
|
18404 | warning$1.warning = warning;
|
18405 | warning$1.warningOnce = warningOnce;
|
18406 | var warned = {};
|
18407 | var preWarningFns = [];
|
18408 | var preMessage = warning$1.preMessage = function preMessage2(fn) {
|
18409 | preWarningFns.push(fn);
|
18410 | };
|
18411 | function warning(valid, message) {
|
18412 | if (!valid && console !== void 0) {
|
18413 | var finalMessage = preWarningFns.reduce(function(msg, preMessageFn) {
|
18414 | return preMessageFn(msg !== null && msg !== void 0 ? msg : "", "warning");
|
18415 | }, message);
|
18416 | if (finalMessage) {
|
18417 | console.error("Warning: ".concat(finalMessage));
|
18418 | }
|
18419 | }
|
18420 | }
|
18421 | function note(valid, message) {
|
18422 | if (!valid && console !== void 0) {
|
18423 | var finalMessage = preWarningFns.reduce(function(msg, preMessageFn) {
|
18424 | return preMessageFn(msg !== null && msg !== void 0 ? msg : "", "note");
|
18425 | }, message);
|
18426 | if (finalMessage) {
|
18427 | console.warn("Note: ".concat(finalMessage));
|
18428 | }
|
18429 | }
|
18430 | }
|
18431 | function resetWarned() {
|
18432 | warned = {};
|
18433 | }
|
18434 | function call(method, valid, message) {
|
18435 | if (!valid && !warned[message]) {
|
18436 | method(false, message);
|
18437 | warned[message] = true;
|
18438 | }
|
18439 | }
|
18440 | function warningOnce(valid, message) {
|
18441 | call(warning, valid, message);
|
18442 | }
|
18443 | function noteOnce(valid, message) {
|
18444 | call(note, valid, message);
|
18445 | }
|
18446 | warningOnce.preMessage = preMessage;
|
18447 | warningOnce.resetWarned = resetWarned;
|
18448 | warningOnce.noteOnce = noteOnce;
|
18449 | warning$1.default = warningOnce;
|
18450 | var _interopRequireWildcard = interopRequireWildcardExports.default;
|
18451 | var _interopRequireDefault = interopRequireDefaultExports.default;
|
18452 | Object.defineProperty(FieldContext, "__esModule", {
|
18453 | value: true
|
18454 | });
|
18455 | var default_1 = FieldContext.default = FieldContext.HOOK_MARK = void 0;
|
18456 | var _warning = _interopRequireDefault(warning$1);
|
18457 | var React = _interopRequireWildcard(React$1);
|
18458 | var HOOK_MARK = "RC_FORM_INTERNAL_HOOKS";
|
18459 | FieldContext.HOOK_MARK = HOOK_MARK;
|
18460 | var warningFunc = function warningFunc2() {
|
18461 | (0, _warning.default)(false, "Can not find FormContext. Please make sure you wrap Field under Form.");
|
18462 | };
|
18463 | var Context = React.createContext({
|
18464 | getFieldValue: warningFunc,
|
18465 | getFieldsValue: warningFunc,
|
18466 | getFieldError: warningFunc,
|
18467 | getFieldWarning: warningFunc,
|
18468 | getFieldsError: warningFunc,
|
18469 | isFieldsTouched: warningFunc,
|
18470 | isFieldTouched: warningFunc,
|
18471 | isFieldValidating: warningFunc,
|
18472 | isFieldsValidating: warningFunc,
|
18473 | resetFields: warningFunc,
|
18474 | setFields: warningFunc,
|
18475 | setFieldValue: warningFunc,
|
18476 | setFieldsValue: warningFunc,
|
18477 | validateFields: warningFunc,
|
18478 | submit: warningFunc,
|
18479 | getInternalHooks: function getInternalHooks() {
|
18480 | warningFunc();
|
18481 | return {
|
18482 | dispatch: warningFunc,
|
18483 | initEntityValue: warningFunc,
|
18484 | registerField: warningFunc,
|
18485 | useSubscribe: warningFunc,
|
18486 | setInitialValues: warningFunc,
|
18487 | destroyForm: warningFunc,
|
18488 | setCallbacks: warningFunc,
|
18489 | registerWatch: warningFunc,
|
18490 | getFields: warningFunc,
|
18491 | setValidateMessages: warningFunc,
|
18492 | setPreserve: warningFunc,
|
18493 | getInitialValue: warningFunc
|
18494 | };
|
18495 | }
|
18496 | });
|
18497 | var _default = Context;
|
18498 | default_1 = FieldContext.default = _default;
|
18499 | function undefinedFallback(...items) {
|
18500 | let i2;
|
18501 | for (i2 = 0; i2 < items.length; i2++) {
|
18502 | if (items[i2] !== void 0)
|
18503 | break;
|
18504 | }
|
18505 | return items[i2];
|
18506 | }
|
18507 | const Arrow = React$1.memo((props) => {
|
18508 | return withNativeProps(props, React$1.createElement("svg", {
|
18509 | viewBox: "0 0 30 16"
|
18510 | }, React$1.createElement("g", {
|
18511 | fill: "currentColor"
|
18512 | }, React$1.createElement("path", {
|
18513 | d: "M0,0 L30,0 L18.07289,14.312538 C16.65863,16.009645 14.13637,16.238942 12.43926,14.824685 C12.25341,14.669808 12.08199,14.49839 11.92711,14.312538 L0,0 L0,0 Z"
|
18514 | }))));
|
18515 | });
|
18516 | const sides = ["top", "right", "bottom", "left"];
|
18517 | const min = Math.min;
|
18518 | const max = Math.max;
|
18519 | const round = Math.round;
|
18520 | const floor = Math.floor;
|
18521 | const createCoords = (v) => ({
|
18522 | x: v,
|
18523 | y: v
|
18524 | });
|
18525 | const oppositeSideMap = {
|
18526 | left: "right",
|
18527 | right: "left",
|
18528 | bottom: "top",
|
18529 | top: "bottom"
|
18530 | };
|
18531 | const oppositeAlignmentMap = {
|
18532 | start: "end",
|
18533 | end: "start"
|
18534 | };
|
18535 | function clamp(start2, value, end) {
|
18536 | return max(start2, min(value, end));
|
18537 | }
|
18538 | function evaluate(value, param) {
|
18539 | return typeof value === "function" ? value(param) : value;
|
18540 | }
|
18541 | function getSide(placement) {
|
18542 | return placement.split("-")[0];
|
18543 | }
|
18544 | function getAlignment(placement) {
|
18545 | return placement.split("-")[1];
|
18546 | }
|
18547 | function getOppositeAxis(axis) {
|
18548 | return axis === "x" ? "y" : "x";
|
18549 | }
|
18550 | function getAxisLength(axis) {
|
18551 | return axis === "y" ? "height" : "width";
|
18552 | }
|
18553 | function getSideAxis(placement) {
|
18554 | return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
|
18555 | }
|
18556 | function getAlignmentAxis(placement) {
|
18557 | return getOppositeAxis(getSideAxis(placement));
|
18558 | }
|
18559 | function getAlignmentSides(placement, rects, rtl) {
|
18560 | if (rtl === void 0) {
|
18561 | rtl = false;
|
18562 | }
|
18563 | const alignment = getAlignment(placement);
|
18564 | const alignmentAxis = getAlignmentAxis(placement);
|
18565 | const length = getAxisLength(alignmentAxis);
|
18566 | let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
|
18567 | if (rects.reference[length] > rects.floating[length]) {
|
18568 | mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
18569 | }
|
18570 | return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
18571 | }
|
18572 | function getExpandedPlacements(placement) {
|
18573 | const oppositePlacement = getOppositePlacement(placement);
|
18574 | return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
18575 | }
|
18576 | function getOppositeAlignmentPlacement(placement) {
|
18577 | return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
|
18578 | }
|
18579 | function getSideList(side, isStart, rtl) {
|
18580 | const lr = ["left", "right"];
|
18581 | const rl = ["right", "left"];
|
18582 | const tb = ["top", "bottom"];
|
18583 | const bt = ["bottom", "top"];
|
18584 | switch (side) {
|
18585 | case "top":
|
18586 | case "bottom":
|
18587 | if (rtl)
|
18588 | return isStart ? rl : lr;
|
18589 | return isStart ? lr : rl;
|
18590 | case "left":
|
18591 | case "right":
|
18592 | return isStart ? tb : bt;
|
18593 | default:
|
18594 | return [];
|
18595 | }
|
18596 | }
|
18597 | function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
18598 | const alignment = getAlignment(placement);
|
18599 | let list = getSideList(getSide(placement), direction === "start", rtl);
|
18600 | if (alignment) {
|
18601 | list = list.map((side) => side + "-" + alignment);
|
18602 | if (flipAlignment) {
|
18603 | list = list.concat(list.map(getOppositeAlignmentPlacement));
|
18604 | }
|
18605 | }
|
18606 | return list;
|
18607 | }
|
18608 | function getOppositePlacement(placement) {
|
18609 | return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
|
18610 | }
|
18611 | function expandPaddingObject(padding) {
|
18612 | return {
|
18613 | top: 0,
|
18614 | right: 0,
|
18615 | bottom: 0,
|
18616 | left: 0,
|
18617 | ...padding
|
18618 | };
|
18619 | }
|
18620 | function getPaddingObject(padding) {
|
18621 | return typeof padding !== "number" ? expandPaddingObject(padding) : {
|
18622 | top: padding,
|
18623 | right: padding,
|
18624 | bottom: padding,
|
18625 | left: padding
|
18626 | };
|
18627 | }
|
18628 | function rectToClientRect(rect) {
|
18629 | return {
|
18630 | ...rect,
|
18631 | top: rect.y,
|
18632 | left: rect.x,
|
18633 | right: rect.x + rect.width,
|
18634 | bottom: rect.y + rect.height
|
18635 | };
|
18636 | }
|
18637 | function computeCoordsFromPlacement(_ref, placement, rtl) {
|
18638 | let {
|
18639 | reference,
|
18640 | floating
|
18641 | } = _ref;
|
18642 | const sideAxis = getSideAxis(placement);
|
18643 | const alignmentAxis = getAlignmentAxis(placement);
|
18644 | const alignLength = getAxisLength(alignmentAxis);
|
18645 | const side = getSide(placement);
|
18646 | const isVertical = sideAxis === "y";
|
18647 | const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
18648 | const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
18649 | const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
18650 | let coords;
|
18651 | switch (side) {
|
18652 | case "top":
|
18653 | coords = {
|
18654 | x: commonX,
|
18655 | y: reference.y - floating.height
|
18656 | };
|
18657 | break;
|
18658 | case "bottom":
|
18659 | coords = {
|
18660 | x: commonX,
|
18661 | y: reference.y + reference.height
|
18662 | };
|
18663 | break;
|
18664 | case "right":
|
18665 | coords = {
|
18666 | x: reference.x + reference.width,
|
18667 | y: commonY
|
18668 | };
|
18669 | break;
|
18670 | case "left":
|
18671 | coords = {
|
18672 | x: reference.x - floating.width,
|
18673 | y: commonY
|
18674 | };
|
18675 | break;
|
18676 | default:
|
18677 | coords = {
|
18678 | x: reference.x,
|
18679 | y: reference.y
|
18680 | };
|
18681 | }
|
18682 | switch (getAlignment(placement)) {
|
18683 | case "start":
|
18684 | coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
18685 | break;
|
18686 | case "end":
|
18687 | coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
18688 | break;
|
18689 | }
|
18690 | return coords;
|
18691 | }
|
18692 | const computePosition$1 = async (reference, floating, config2) => {
|
18693 | const {
|
18694 | placement = "bottom",
|
18695 | strategy = "absolute",
|
18696 | middleware = [],
|
18697 | platform: platform2
|
18698 | } = config2;
|
18699 | const validMiddleware = middleware.filter(Boolean);
|
18700 | const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
|
18701 | let rects = await platform2.getElementRects({
|
18702 | reference,
|
18703 | floating,
|
18704 | strategy
|
18705 | });
|
18706 | let {
|
18707 | x,
|
18708 | y
|
18709 | } = computeCoordsFromPlacement(rects, placement, rtl);
|
18710 | let statefulPlacement = placement;
|
18711 | let middlewareData = {};
|
18712 | let resetCount = 0;
|
18713 | for (let i2 = 0; i2 < validMiddleware.length; i2++) {
|
18714 | const {
|
18715 | name,
|
18716 | fn
|
18717 | } = validMiddleware[i2];
|
18718 | const {
|
18719 | x: nextX,
|
18720 | y: nextY,
|
18721 | data,
|
18722 | reset
|
18723 | } = await fn({
|
18724 | x,
|
18725 | y,
|
18726 | initialPlacement: placement,
|
18727 | placement: statefulPlacement,
|
18728 | strategy,
|
18729 | middlewareData,
|
18730 | rects,
|
18731 | platform: platform2,
|
18732 | elements: {
|
18733 | reference,
|
18734 | floating
|
18735 | }
|
18736 | });
|
18737 | x = nextX != null ? nextX : x;
|
18738 | y = nextY != null ? nextY : y;
|
18739 | middlewareData = {
|
18740 | ...middlewareData,
|
18741 | [name]: {
|
18742 | ...middlewareData[name],
|
18743 | ...data
|
18744 | }
|
18745 | };
|
18746 | if (reset && resetCount <= 50) {
|
18747 | resetCount++;
|
18748 | if (typeof reset === "object") {
|
18749 | if (reset.placement) {
|
18750 | statefulPlacement = reset.placement;
|
18751 | }
|
18752 | if (reset.rects) {
|
18753 | rects = reset.rects === true ? await platform2.getElementRects({
|
18754 | reference,
|
18755 | floating,
|
18756 | strategy
|
18757 | }) : reset.rects;
|
18758 | }
|
18759 | ({
|
18760 | x,
|
18761 | y
|
18762 | } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
18763 | }
|
18764 | i2 = -1;
|
18765 | continue;
|
18766 | }
|
18767 | }
|
18768 | return {
|
18769 | x,
|
18770 | y,
|
18771 | placement: statefulPlacement,
|
18772 | strategy,
|
18773 | middlewareData
|
18774 | };
|
18775 | };
|
18776 | async function detectOverflow(state, options) {
|
18777 | var _await$platform$isEle;
|
18778 | if (options === void 0) {
|
18779 | options = {};
|
18780 | }
|
18781 | const {
|
18782 | x,
|
18783 | y,
|
18784 | platform: platform2,
|
18785 | rects,
|
18786 | elements,
|
18787 | strategy
|
18788 | } = state;
|
18789 | const {
|
18790 | boundary = "clippingAncestors",
|
18791 | rootBoundary = "viewport",
|
18792 | elementContext = "floating",
|
18793 | altBoundary = false,
|
18794 | padding = 0
|
18795 | } = evaluate(options, state);
|
18796 | const paddingObject = getPaddingObject(padding);
|
18797 | const altContext = elementContext === "floating" ? "reference" : "floating";
|
18798 | const element = elements[altBoundary ? altContext : elementContext];
|
18799 | const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
|
18800 | element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
|
18801 | boundary,
|
18802 | rootBoundary,
|
18803 | strategy
|
18804 | }));
|
18805 | const rect = elementContext === "floating" ? {
|
18806 | ...rects.floating,
|
18807 | x,
|
18808 | y
|
18809 | } : rects.reference;
|
18810 | const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
|
18811 | const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
|
18812 | x: 1,
|
18813 | y: 1
|
18814 | } : {
|
18815 | x: 1,
|
18816 | y: 1
|
18817 | };
|
18818 | const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
|
18819 | rect,
|
18820 | offsetParent,
|
18821 | strategy
|
18822 | }) : rect);
|
18823 | return {
|
18824 | top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
18825 | bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
18826 | left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
18827 | right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
18828 | };
|
18829 | }
|
18830 | const arrow = (options) => ({
|
18831 | name: "arrow",
|
18832 | options,
|
18833 | async fn(state) {
|
18834 | const {
|
18835 | x,
|
18836 | y,
|
18837 | placement,
|
18838 | rects,
|
18839 | platform: platform2,
|
18840 | elements,
|
18841 | middlewareData
|
18842 | } = state;
|
18843 | const {
|
18844 | element,
|
18845 | padding = 0
|
18846 | } = evaluate(options, state) || {};
|
18847 | if (element == null) {
|
18848 | return {};
|
18849 | }
|
18850 | const paddingObject = getPaddingObject(padding);
|
18851 | const coords = {
|
18852 | x,
|
18853 | y
|
18854 | };
|
18855 | const axis = getAlignmentAxis(placement);
|
18856 | const length = getAxisLength(axis);
|
18857 | const arrowDimensions = await platform2.getDimensions(element);
|
18858 | const isYAxis = axis === "y";
|
18859 | const minProp = isYAxis ? "top" : "left";
|
18860 | const maxProp = isYAxis ? "bottom" : "right";
|
18861 | const clientProp = isYAxis ? "clientHeight" : "clientWidth";
|
18862 | const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
18863 | const startDiff = coords[axis] - rects.reference[axis];
|
18864 | const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element));
|
18865 | let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
18866 | if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) {
|
18867 | clientSize = elements.floating[clientProp] || rects.floating[length];
|
18868 | }
|
18869 | const centerToReference = endDiff / 2 - startDiff / 2;
|
18870 | const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
18871 | const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
18872 | const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
18873 | const min$1 = minPadding;
|
18874 | const max2 = clientSize - arrowDimensions[length] - maxPadding;
|
18875 | const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
18876 | const offset2 = clamp(min$1, center, max2);
|
18877 | const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center != offset2 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
18878 | const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0;
|
18879 | return {
|
18880 | [axis]: coords[axis] + alignmentOffset,
|
18881 | data: {
|
18882 | [axis]: offset2,
|
18883 | centerOffset: center - offset2 - alignmentOffset,
|
18884 | ...shouldAddOffset && {
|
18885 | alignmentOffset
|
18886 | }
|
18887 | },
|
18888 | reset: shouldAddOffset
|
18889 | };
|
18890 | }
|
18891 | });
|
18892 | const flip = function(options) {
|
18893 | if (options === void 0) {
|
18894 | options = {};
|
18895 | }
|
18896 | return {
|
18897 | name: "flip",
|
18898 | options,
|
18899 | async fn(state) {
|
18900 | var _middlewareData$arrow, _middlewareData$flip;
|
18901 | const {
|
18902 | placement,
|
18903 | middlewareData,
|
18904 | rects,
|
18905 | initialPlacement,
|
18906 | platform: platform2,
|
18907 | elements
|
18908 | } = state;
|
18909 | const {
|
18910 | mainAxis: checkMainAxis = true,
|
18911 | crossAxis: checkCrossAxis = true,
|
18912 | fallbackPlacements: specifiedFallbackPlacements,
|
18913 | fallbackStrategy = "bestFit",
|
18914 | fallbackAxisSideDirection = "none",
|
18915 | flipAlignment = true,
|
18916 | ...detectOverflowOptions
|
18917 | } = evaluate(options, state);
|
18918 | if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
18919 | return {};
|
18920 | }
|
18921 | const side = getSide(placement);
|
18922 | const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
18923 | const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
18924 | const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
18925 | if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== "none") {
|
18926 | fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
18927 | }
|
18928 | const placements = [initialPlacement, ...fallbackPlacements];
|
18929 | const overflow = await detectOverflow(state, detectOverflowOptions);
|
18930 | const overflows = [];
|
18931 | let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
18932 | if (checkMainAxis) {
|
18933 | overflows.push(overflow[side]);
|
18934 | }
|
18935 | if (checkCrossAxis) {
|
18936 | const sides2 = getAlignmentSides(placement, rects, rtl);
|
18937 | overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
|
18938 | }
|
18939 | overflowsData = [...overflowsData, {
|
18940 | placement,
|
18941 | overflows
|
18942 | }];
|
18943 | if (!overflows.every((side2) => side2 <= 0)) {
|
18944 | var _middlewareData$flip2, _overflowsData$filter;
|
18945 | const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
18946 | const nextPlacement = placements[nextIndex];
|
18947 | if (nextPlacement) {
|
18948 | return {
|
18949 | data: {
|
18950 | index: nextIndex,
|
18951 | overflows: overflowsData
|
18952 | },
|
18953 | reset: {
|
18954 | placement: nextPlacement
|
18955 | }
|
18956 | };
|
18957 | }
|
18958 | let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
18959 | if (!resetPlacement) {
|
18960 | switch (fallbackStrategy) {
|
18961 | case "bestFit": {
|
18962 | var _overflowsData$map$so;
|
18963 | const placement2 = (_overflowsData$map$so = overflowsData.map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
|
18964 | if (placement2) {
|
18965 | resetPlacement = placement2;
|
18966 | }
|
18967 | break;
|
18968 | }
|
18969 | case "initialPlacement":
|
18970 | resetPlacement = initialPlacement;
|
18971 | break;
|
18972 | }
|
18973 | }
|
18974 | if (placement !== resetPlacement) {
|
18975 | return {
|
18976 | reset: {
|
18977 | placement: resetPlacement
|
18978 | }
|
18979 | };
|
18980 | }
|
18981 | }
|
18982 | return {};
|
18983 | }
|
18984 | };
|
18985 | };
|
18986 | function getSideOffsets(overflow, rect) {
|
18987 | return {
|
18988 | top: overflow.top - rect.height,
|
18989 | right: overflow.right - rect.width,
|
18990 | bottom: overflow.bottom - rect.height,
|
18991 | left: overflow.left - rect.width
|
18992 | };
|
18993 | }
|
18994 | function isAnySideFullyClipped(overflow) {
|
18995 | return sides.some((side) => overflow[side] >= 0);
|
18996 | }
|
18997 | const hide = function(options) {
|
18998 | if (options === void 0) {
|
18999 | options = {};
|
19000 | }
|
19001 | return {
|
19002 | name: "hide",
|
19003 | options,
|
19004 | async fn(state) {
|
19005 | const {
|
19006 | rects
|
19007 | } = state;
|
19008 | const {
|
19009 | strategy = "referenceHidden",
|
19010 | ...detectOverflowOptions
|
19011 | } = evaluate(options, state);
|
19012 | switch (strategy) {
|
19013 | case "referenceHidden": {
|
19014 | const overflow = await detectOverflow(state, {
|
19015 | ...detectOverflowOptions,
|
19016 | elementContext: "reference"
|
19017 | });
|
19018 | const offsets = getSideOffsets(overflow, rects.reference);
|
19019 | return {
|
19020 | data: {
|
19021 | referenceHiddenOffsets: offsets,
|
19022 | referenceHidden: isAnySideFullyClipped(offsets)
|
19023 | }
|
19024 | };
|
19025 | }
|
19026 | case "escaped": {
|
19027 | const overflow = await detectOverflow(state, {
|
19028 | ...detectOverflowOptions,
|
19029 | altBoundary: true
|
19030 | });
|
19031 | const offsets = getSideOffsets(overflow, rects.floating);
|
19032 | return {
|
19033 | data: {
|
19034 | escapedOffsets: offsets,
|
19035 | escaped: isAnySideFullyClipped(offsets)
|
19036 | }
|
19037 | };
|
19038 | }
|
19039 | default: {
|
19040 | return {};
|
19041 | }
|
19042 | }
|
19043 | }
|
19044 | };
|
19045 | };
|
19046 | async function convertValueToCoords(state, options) {
|
19047 | const {
|
19048 | placement,
|
19049 | platform: platform2,
|
19050 | elements
|
19051 | } = state;
|
19052 | const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
19053 | const side = getSide(placement);
|
19054 | const alignment = getAlignment(placement);
|
19055 | const isVertical = getSideAxis(placement) === "y";
|
19056 | const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
|
19057 | const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
19058 | const rawValue = evaluate(options, state);
|
19059 | let {
|
19060 | mainAxis,
|
19061 | crossAxis,
|
19062 | alignmentAxis
|
19063 | } = typeof rawValue === "number" ? {
|
19064 | mainAxis: rawValue,
|
19065 | crossAxis: 0,
|
19066 | alignmentAxis: null
|
19067 | } : {
|
19068 | mainAxis: 0,
|
19069 | crossAxis: 0,
|
19070 | alignmentAxis: null,
|
19071 | ...rawValue
|
19072 | };
|
19073 | if (alignment && typeof alignmentAxis === "number") {
|
19074 | crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
19075 | }
|
19076 | return isVertical ? {
|
19077 | x: crossAxis * crossAxisMulti,
|
19078 | y: mainAxis * mainAxisMulti
|
19079 | } : {
|
19080 | x: mainAxis * mainAxisMulti,
|
19081 | y: crossAxis * crossAxisMulti
|
19082 | };
|
19083 | }
|
19084 | const offset = function(options) {
|
19085 | if (options === void 0) {
|
19086 | options = 0;
|
19087 | }
|
19088 | return {
|
19089 | name: "offset",
|
19090 | options,
|
19091 | async fn(state) {
|
19092 | const {
|
19093 | x,
|
19094 | y
|
19095 | } = state;
|
19096 | const diffCoords = await convertValueToCoords(state, options);
|
19097 | return {
|
19098 | x: x + diffCoords.x,
|
19099 | y: y + diffCoords.y,
|
19100 | data: diffCoords
|
19101 | };
|
19102 | }
|
19103 | };
|
19104 | };
|
19105 | const shift = function(options) {
|
19106 | if (options === void 0) {
|
19107 | options = {};
|
19108 | }
|
19109 | return {
|
19110 | name: "shift",
|
19111 | options,
|
19112 | async fn(state) {
|
19113 | const {
|
19114 | x,
|
19115 | y,
|
19116 | placement
|
19117 | } = state;
|
19118 | const {
|
19119 | mainAxis: checkMainAxis = true,
|
19120 | crossAxis: checkCrossAxis = false,
|
19121 | limiter = {
|
19122 | fn: (_ref) => {
|
19123 | let {
|
19124 | x: x2,
|
19125 | y: y2
|
19126 | } = _ref;
|
19127 | return {
|
19128 | x: x2,
|
19129 | y: y2
|
19130 | };
|
19131 | }
|
19132 | },
|
19133 | ...detectOverflowOptions
|
19134 | } = evaluate(options, state);
|
19135 | const coords = {
|
19136 | x,
|
19137 | y
|
19138 | };
|
19139 | const overflow = await detectOverflow(state, detectOverflowOptions);
|
19140 | const crossAxis = getSideAxis(getSide(placement));
|
19141 | const mainAxis = getOppositeAxis(crossAxis);
|
19142 | let mainAxisCoord = coords[mainAxis];
|
19143 | let crossAxisCoord = coords[crossAxis];
|
19144 | if (checkMainAxis) {
|
19145 | const minSide = mainAxis === "y" ? "top" : "left";
|
19146 | const maxSide = mainAxis === "y" ? "bottom" : "right";
|
19147 | const min2 = mainAxisCoord + overflow[minSide];
|
19148 | const max2 = mainAxisCoord - overflow[maxSide];
|
19149 | mainAxisCoord = clamp(min2, mainAxisCoord, max2);
|
19150 | }
|
19151 | if (checkCrossAxis) {
|
19152 | const minSide = crossAxis === "y" ? "top" : "left";
|
19153 | const maxSide = crossAxis === "y" ? "bottom" : "right";
|
19154 | const min2 = crossAxisCoord + overflow[minSide];
|
19155 | const max2 = crossAxisCoord - overflow[maxSide];
|
19156 | crossAxisCoord = clamp(min2, crossAxisCoord, max2);
|
19157 | }
|
19158 | const limitedCoords = limiter.fn({
|
19159 | ...state,
|
19160 | [mainAxis]: mainAxisCoord,
|
19161 | [crossAxis]: crossAxisCoord
|
19162 | });
|
19163 | return {
|
19164 | ...limitedCoords,
|
19165 | data: {
|
19166 | x: limitedCoords.x - x,
|
19167 | y: limitedCoords.y - y
|
19168 | }
|
19169 | };
|
19170 | }
|
19171 | };
|
19172 | };
|
19173 | const limitShift = function(options) {
|
19174 | if (options === void 0) {
|
19175 | options = {};
|
19176 | }
|
19177 | return {
|
19178 | options,
|
19179 | fn(state) {
|
19180 | const {
|
19181 | x,
|
19182 | y,
|
19183 | placement,
|
19184 | rects,
|
19185 | middlewareData
|
19186 | } = state;
|
19187 | const {
|
19188 | offset: offset2 = 0,
|
19189 | mainAxis: checkMainAxis = true,
|
19190 | crossAxis: checkCrossAxis = true
|
19191 | } = evaluate(options, state);
|
19192 | const coords = {
|
19193 | x,
|
19194 | y
|
19195 | };
|
19196 | const crossAxis = getSideAxis(placement);
|
19197 | const mainAxis = getOppositeAxis(crossAxis);
|
19198 | let mainAxisCoord = coords[mainAxis];
|
19199 | let crossAxisCoord = coords[crossAxis];
|
19200 | const rawOffset = evaluate(offset2, state);
|
19201 | const computedOffset = typeof rawOffset === "number" ? {
|
19202 | mainAxis: rawOffset,
|
19203 | crossAxis: 0
|
19204 | } : {
|
19205 | mainAxis: 0,
|
19206 | crossAxis: 0,
|
19207 | ...rawOffset
|
19208 | };
|
19209 | if (checkMainAxis) {
|
19210 | const len = mainAxis === "y" ? "height" : "width";
|
19211 | const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
|
19212 | const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
|
19213 | if (mainAxisCoord < limitMin) {
|
19214 | mainAxisCoord = limitMin;
|
19215 | } else if (mainAxisCoord > limitMax) {
|
19216 | mainAxisCoord = limitMax;
|
19217 | }
|
19218 | }
|
19219 | if (checkCrossAxis) {
|
19220 | var _middlewareData$offse, _middlewareData$offse2;
|
19221 | const len = mainAxis === "y" ? "width" : "height";
|
19222 | const isOriginSide = ["top", "left"].includes(getSide(placement));
|
19223 | const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
|
19224 | const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
|
19225 | if (crossAxisCoord < limitMin) {
|
19226 | crossAxisCoord = limitMin;
|
19227 | } else if (crossAxisCoord > limitMax) {
|
19228 | crossAxisCoord = limitMax;
|
19229 | }
|
19230 | }
|
19231 | return {
|
19232 | [mainAxis]: mainAxisCoord,
|
19233 | [crossAxis]: crossAxisCoord
|
19234 | };
|
19235 | }
|
19236 | };
|
19237 | };
|
19238 | function getNodeName(node) {
|
19239 | if (isNode(node)) {
|
19240 | return (node.nodeName || "").toLowerCase();
|
19241 | }
|
19242 | return "#document";
|
19243 | }
|
19244 | function getWindow(node) {
|
19245 | var _node$ownerDocument;
|
19246 | return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
19247 | }
|
19248 | function getDocumentElement(node) {
|
19249 | var _ref;
|
19250 | return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
19251 | }
|
19252 | function isNode(value) {
|
19253 | return value instanceof Node || value instanceof getWindow(value).Node;
|
19254 | }
|
19255 | function isElement(value) {
|
19256 | return value instanceof Element || value instanceof getWindow(value).Element;
|
19257 | }
|
19258 | function isHTMLElement(value) {
|
19259 | return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
19260 | }
|
19261 | function isShadowRoot(value) {
|
19262 | if (typeof ShadowRoot === "undefined") {
|
19263 | return false;
|
19264 | }
|
19265 | return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
19266 | }
|
19267 | function isOverflowElement(element) {
|
19268 | const {
|
19269 | overflow,
|
19270 | overflowX,
|
19271 | overflowY,
|
19272 | display
|
19273 | } = getComputedStyle(element);
|
19274 | return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
|
19275 | }
|
19276 | function isTableElement(element) {
|
19277 | return ["table", "td", "th"].includes(getNodeName(element));
|
19278 | }
|
19279 | function isContainingBlock(element) {
|
19280 | const webkit = isWebKit();
|
19281 | const css = getComputedStyle(element);
|
19282 | return css.transform !== "none" || css.perspective !== "none" || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
|
19283 | }
|
19284 | function getContainingBlock(element) {
|
19285 | let currentNode = getParentNode(element);
|
19286 | while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
19287 | if (isContainingBlock(currentNode)) {
|
19288 | return currentNode;
|
19289 | } else {
|
19290 | currentNode = getParentNode(currentNode);
|
19291 | }
|
19292 | }
|
19293 | return null;
|
19294 | }
|
19295 | function isWebKit() {
|
19296 | if (typeof CSS === "undefined" || !CSS.supports)
|
19297 | return false;
|
19298 | return CSS.supports("-webkit-backdrop-filter", "none");
|
19299 | }
|
19300 | function isLastTraversableNode(node) {
|
19301 | return ["html", "body", "#document"].includes(getNodeName(node));
|
19302 | }
|
19303 | function getComputedStyle(element) {
|
19304 | return getWindow(element).getComputedStyle(element);
|
19305 | }
|
19306 | function getNodeScroll(element) {
|
19307 | if (isElement(element)) {
|
19308 | return {
|
19309 | scrollLeft: element.scrollLeft,
|
19310 | scrollTop: element.scrollTop
|
19311 | };
|
19312 | }
|
19313 | return {
|
19314 | scrollLeft: element.pageXOffset,
|
19315 | scrollTop: element.pageYOffset
|
19316 | };
|
19317 | }
|
19318 | function getParentNode(node) {
|
19319 | if (getNodeName(node) === "html") {
|
19320 | return node;
|
19321 | }
|
19322 | const result = (
|
19323 |
|
19324 | node.assignedSlot ||
|
19325 | node.parentNode ||
|
19326 | isShadowRoot(node) && node.host ||
|
19327 | getDocumentElement(node)
|
19328 | );
|
19329 | return isShadowRoot(result) ? result.host : result;
|
19330 | }
|
19331 | function getNearestOverflowAncestor(node) {
|
19332 | const parentNode = getParentNode(node);
|
19333 | if (isLastTraversableNode(parentNode)) {
|
19334 | return node.ownerDocument ? node.ownerDocument.body : node.body;
|
19335 | }
|
19336 | if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
19337 | return parentNode;
|
19338 | }
|
19339 | return getNearestOverflowAncestor(parentNode);
|
19340 | }
|
19341 | function getOverflowAncestors(node, list, traverseIframes) {
|
19342 | var _node$ownerDocument2;
|
19343 | if (list === void 0) {
|
19344 | list = [];
|
19345 | }
|
19346 | if (traverseIframes === void 0) {
|
19347 | traverseIframes = true;
|
19348 | }
|
19349 | const scrollableAncestor = getNearestOverflowAncestor(node);
|
19350 | const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
19351 | const win = getWindow(scrollableAncestor);
|
19352 | if (isBody) {
|
19353 | return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
|
19354 | }
|
19355 | return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
19356 | }
|
19357 | function getCssDimensions(element) {
|
19358 | const css = getComputedStyle(element);
|
19359 | let width = parseFloat(css.width) || 0;
|
19360 | let height = parseFloat(css.height) || 0;
|
19361 | const hasOffset = isHTMLElement(element);
|
19362 | const offsetWidth = hasOffset ? element.offsetWidth : width;
|
19363 | const offsetHeight = hasOffset ? element.offsetHeight : height;
|
19364 | const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
19365 | if (shouldFallback) {
|
19366 | width = offsetWidth;
|
19367 | height = offsetHeight;
|
19368 | }
|
19369 | return {
|
19370 | width,
|
19371 | height,
|
19372 | $: shouldFallback
|
19373 | };
|
19374 | }
|
19375 | function unwrapElement(element) {
|
19376 | return !isElement(element) ? element.contextElement : element;
|
19377 | }
|
19378 | function getScale(element) {
|
19379 | const domElement = unwrapElement(element);
|
19380 | if (!isHTMLElement(domElement)) {
|
19381 | return createCoords(1);
|
19382 | }
|
19383 | const rect = domElement.getBoundingClientRect();
|
19384 | const {
|
19385 | width,
|
19386 | height,
|
19387 | $
|
19388 | } = getCssDimensions(domElement);
|
19389 | let x = ($ ? round(rect.width) : rect.width) / width;
|
19390 | let y = ($ ? round(rect.height) : rect.height) / height;
|
19391 | if (!x || !Number.isFinite(x)) {
|
19392 | x = 1;
|
19393 | }
|
19394 | if (!y || !Number.isFinite(y)) {
|
19395 | y = 1;
|
19396 | }
|
19397 | return {
|
19398 | x,
|
19399 | y
|
19400 | };
|
19401 | }
|
19402 | const noOffsets = createCoords(0);
|
19403 | function getVisualOffsets(element) {
|
19404 | const win = getWindow(element);
|
19405 | if (!isWebKit() || !win.visualViewport) {
|
19406 | return noOffsets;
|
19407 | }
|
19408 | return {
|
19409 | x: win.visualViewport.offsetLeft,
|
19410 | y: win.visualViewport.offsetTop
|
19411 | };
|
19412 | }
|
19413 | function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
19414 | if (isFixed === void 0) {
|
19415 | isFixed = false;
|
19416 | }
|
19417 | if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
19418 | return false;
|
19419 | }
|
19420 | return isFixed;
|
19421 | }
|
19422 | function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
19423 | if (includeScale === void 0) {
|
19424 | includeScale = false;
|
19425 | }
|
19426 | if (isFixedStrategy === void 0) {
|
19427 | isFixedStrategy = false;
|
19428 | }
|
19429 | const clientRect = element.getBoundingClientRect();
|
19430 | const domElement = unwrapElement(element);
|
19431 | let scale2 = createCoords(1);
|
19432 | if (includeScale) {
|
19433 | if (offsetParent) {
|
19434 | if (isElement(offsetParent)) {
|
19435 | scale2 = getScale(offsetParent);
|
19436 | }
|
19437 | } else {
|
19438 | scale2 = getScale(element);
|
19439 | }
|
19440 | }
|
19441 | const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
19442 | let x = (clientRect.left + visualOffsets.x) / scale2.x;
|
19443 | let y = (clientRect.top + visualOffsets.y) / scale2.y;
|
19444 | let width = clientRect.width / scale2.x;
|
19445 | let height = clientRect.height / scale2.y;
|
19446 | if (domElement) {
|
19447 | const win = getWindow(domElement);
|
19448 | const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
19449 | let currentIFrame = win.frameElement;
|
19450 | while (currentIFrame && offsetParent && offsetWin !== win) {
|
19451 | const iframeScale = getScale(currentIFrame);
|
19452 | const iframeRect = currentIFrame.getBoundingClientRect();
|
19453 | const css = getComputedStyle(currentIFrame);
|
19454 | const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
19455 | const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
19456 | x *= iframeScale.x;
|
19457 | y *= iframeScale.y;
|
19458 | width *= iframeScale.x;
|
19459 | height *= iframeScale.y;
|
19460 | x += left;
|
19461 | y += top;
|
19462 | currentIFrame = getWindow(currentIFrame).frameElement;
|
19463 | }
|
19464 | }
|
19465 | return rectToClientRect({
|
19466 | width,
|
19467 | height,
|
19468 | x,
|
19469 | y
|
19470 | });
|
19471 | }
|
19472 | function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
19473 | let {
|
19474 | rect,
|
19475 | offsetParent,
|
19476 | strategy
|
19477 | } = _ref;
|
19478 | const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
19479 | const documentElement = getDocumentElement(offsetParent);
|
19480 | if (offsetParent === documentElement) {
|
19481 | return rect;
|
19482 | }
|
19483 | let scroll = {
|
19484 | scrollLeft: 0,
|
19485 | scrollTop: 0
|
19486 | };
|
19487 | let scale2 = createCoords(1);
|
19488 | const offsets = createCoords(0);
|
19489 | if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
|
19490 | if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
19491 | scroll = getNodeScroll(offsetParent);
|
19492 | }
|
19493 | if (isHTMLElement(offsetParent)) {
|
19494 | const offsetRect = getBoundingClientRect(offsetParent);
|
19495 | scale2 = getScale(offsetParent);
|
19496 | offsets.x = offsetRect.x + offsetParent.clientLeft;
|
19497 | offsets.y = offsetRect.y + offsetParent.clientTop;
|
19498 | }
|
19499 | }
|
19500 | return {
|
19501 | width: rect.width * scale2.x,
|
19502 | height: rect.height * scale2.y,
|
19503 | x: rect.x * scale2.x - scroll.scrollLeft * scale2.x + offsets.x,
|
19504 | y: rect.y * scale2.y - scroll.scrollTop * scale2.y + offsets.y
|
19505 | };
|
19506 | }
|
19507 | function getClientRects(element) {
|
19508 | return Array.from(element.getClientRects());
|
19509 | }
|
19510 | function getWindowScrollBarX(element) {
|
19511 | return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
|
19512 | }
|
19513 | function getDocumentRect(element) {
|
19514 | const html = getDocumentElement(element);
|
19515 | const scroll = getNodeScroll(element);
|
19516 | const body = element.ownerDocument.body;
|
19517 | const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
19518 | const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
19519 | let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
19520 | const y = -scroll.scrollTop;
|
19521 | if (getComputedStyle(body).direction === "rtl") {
|
19522 | x += max(html.clientWidth, body.clientWidth) - width;
|
19523 | }
|
19524 | return {
|
19525 | width,
|
19526 | height,
|
19527 | x,
|
19528 | y
|
19529 | };
|
19530 | }
|
19531 | function getViewportRect(element, strategy) {
|
19532 | const win = getWindow(element);
|
19533 | const html = getDocumentElement(element);
|
19534 | const visualViewport = win.visualViewport;
|
19535 | let width = html.clientWidth;
|
19536 | let height = html.clientHeight;
|
19537 | let x = 0;
|
19538 | let y = 0;
|
19539 | if (visualViewport) {
|
19540 | width = visualViewport.width;
|
19541 | height = visualViewport.height;
|
19542 | const visualViewportBased = isWebKit();
|
19543 | if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
|
19544 | x = visualViewport.offsetLeft;
|
19545 | y = visualViewport.offsetTop;
|
19546 | }
|
19547 | }
|
19548 | return {
|
19549 | width,
|
19550 | height,
|
19551 | x,
|
19552 | y
|
19553 | };
|
19554 | }
|
19555 | function getInnerBoundingClientRect(element, strategy) {
|
19556 | const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
|
19557 | const top = clientRect.top + element.clientTop;
|
19558 | const left = clientRect.left + element.clientLeft;
|
19559 | const scale2 = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
19560 | const width = element.clientWidth * scale2.x;
|
19561 | const height = element.clientHeight * scale2.y;
|
19562 | const x = left * scale2.x;
|
19563 | const y = top * scale2.y;
|
19564 | return {
|
19565 | width,
|
19566 | height,
|
19567 | x,
|
19568 | y
|
19569 | };
|
19570 | }
|
19571 | function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
19572 | let rect;
|
19573 | if (clippingAncestor === "viewport") {
|
19574 | rect = getViewportRect(element, strategy);
|
19575 | } else if (clippingAncestor === "document") {
|
19576 | rect = getDocumentRect(getDocumentElement(element));
|
19577 | } else if (isElement(clippingAncestor)) {
|
19578 | rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
19579 | } else {
|
19580 | const visualOffsets = getVisualOffsets(element);
|
19581 | rect = {
|
19582 | ...clippingAncestor,
|
19583 | x: clippingAncestor.x - visualOffsets.x,
|
19584 | y: clippingAncestor.y - visualOffsets.y
|
19585 | };
|
19586 | }
|
19587 | return rectToClientRect(rect);
|
19588 | }
|
19589 | function hasFixedPositionAncestor(element, stopNode) {
|
19590 | const parentNode = getParentNode(element);
|
19591 | if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
19592 | return false;
|
19593 | }
|
19594 | return getComputedStyle(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
|
19595 | }
|
19596 | function getClippingElementAncestors(element, cache) {
|
19597 | const cachedResult = cache.get(element);
|
19598 | if (cachedResult) {
|
19599 | return cachedResult;
|
19600 | }
|
19601 | let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
|
19602 | let currentContainingBlockComputedStyle = null;
|
19603 | const elementIsFixed = getComputedStyle(element).position === "fixed";
|
19604 | let currentNode = elementIsFixed ? getParentNode(element) : element;
|
19605 | while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
19606 | const computedStyle = getComputedStyle(currentNode);
|
19607 | const currentNodeIsContaining = isContainingBlock(currentNode);
|
19608 | if (!currentNodeIsContaining && computedStyle.position === "fixed") {
|
19609 | currentContainingBlockComputedStyle = null;
|
19610 | }
|
19611 | const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
19612 | if (shouldDropCurrentNode) {
|
19613 | result = result.filter((ancestor) => ancestor !== currentNode);
|
19614 | } else {
|
19615 | currentContainingBlockComputedStyle = computedStyle;
|
19616 | }
|
19617 | currentNode = getParentNode(currentNode);
|
19618 | }
|
19619 | cache.set(element, result);
|
19620 | return result;
|
19621 | }
|
19622 | function getClippingRect(_ref) {
|
19623 | let {
|
19624 | element,
|
19625 | boundary,
|
19626 | rootBoundary,
|
19627 | strategy
|
19628 | } = _ref;
|
19629 | const elementClippingAncestors = boundary === "clippingAncestors" ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
19630 | const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
19631 | const firstClippingAncestor = clippingAncestors[0];
|
19632 | const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
19633 | const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
19634 | accRect.top = max(rect.top, accRect.top);
|
19635 | accRect.right = min(rect.right, accRect.right);
|
19636 | accRect.bottom = min(rect.bottom, accRect.bottom);
|
19637 | accRect.left = max(rect.left, accRect.left);
|
19638 | return accRect;
|
19639 | }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
19640 | return {
|
19641 | width: clippingRect.right - clippingRect.left,
|
19642 | height: clippingRect.bottom - clippingRect.top,
|
19643 | x: clippingRect.left,
|
19644 | y: clippingRect.top
|
19645 | };
|
19646 | }
|
19647 | function getDimensions(element) {
|
19648 | return getCssDimensions(element);
|
19649 | }
|
19650 | function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
19651 | const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
19652 | const documentElement = getDocumentElement(offsetParent);
|
19653 | const isFixed = strategy === "fixed";
|
19654 | const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
19655 | let scroll = {
|
19656 | scrollLeft: 0,
|
19657 | scrollTop: 0
|
19658 | };
|
19659 | const offsets = createCoords(0);
|
19660 | if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
19661 | if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
19662 | scroll = getNodeScroll(offsetParent);
|
19663 | }
|
19664 | if (isOffsetParentAnElement) {
|
19665 | const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
19666 | offsets.x = offsetRect.x + offsetParent.clientLeft;
|
19667 | offsets.y = offsetRect.y + offsetParent.clientTop;
|
19668 | } else if (documentElement) {
|
19669 | offsets.x = getWindowScrollBarX(documentElement);
|
19670 | }
|
19671 | }
|
19672 | return {
|
19673 | x: rect.left + scroll.scrollLeft - offsets.x,
|
19674 | y: rect.top + scroll.scrollTop - offsets.y,
|
19675 | width: rect.width,
|
19676 | height: rect.height
|
19677 | };
|
19678 | }
|
19679 | function getTrueOffsetParent(element, polyfill) {
|
19680 | if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") {
|
19681 | return null;
|
19682 | }
|
19683 | if (polyfill) {
|
19684 | return polyfill(element);
|
19685 | }
|
19686 | return element.offsetParent;
|
19687 | }
|
19688 | function getOffsetParent(element, polyfill) {
|
19689 | const window2 = getWindow(element);
|
19690 | if (!isHTMLElement(element)) {
|
19691 | return window2;
|
19692 | }
|
19693 | let offsetParent = getTrueOffsetParent(element, polyfill);
|
19694 | while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
|
19695 | offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
19696 | }
|
19697 | if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
|
19698 | return window2;
|
19699 | }
|
19700 | return offsetParent || getContainingBlock(element) || window2;
|
19701 | }
|
19702 | const getElementRects = async function(_ref) {
|
19703 | let {
|
19704 | reference,
|
19705 | floating,
|
19706 | strategy
|
19707 | } = _ref;
|
19708 | const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
19709 | const getDimensionsFn = this.getDimensions;
|
19710 | return {
|
19711 | reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
19712 | floating: {
|
19713 | x: 0,
|
19714 | y: 0,
|
19715 | ...await getDimensionsFn(floating)
|
19716 | }
|
19717 | };
|
19718 | };
|
19719 | function isRTL(element) {
|
19720 | return getComputedStyle(element).direction === "rtl";
|
19721 | }
|
19722 | const platform = {
|
19723 | convertOffsetParentRelativeRectToViewportRelativeRect,
|
19724 | getDocumentElement,
|
19725 | getClippingRect,
|
19726 | getOffsetParent,
|
19727 | getElementRects,
|
19728 | getClientRects,
|
19729 | getDimensions,
|
19730 | getScale,
|
19731 | isElement,
|
19732 | isRTL
|
19733 | };
|
19734 | function observeMove(element, onMove) {
|
19735 | let io = null;
|
19736 | let timeoutId;
|
19737 | const root2 = getDocumentElement(element);
|
19738 | function cleanup() {
|
19739 | clearTimeout(timeoutId);
|
19740 | io && io.disconnect();
|
19741 | io = null;
|
19742 | }
|
19743 | function refresh(skip, threshold) {
|
19744 | if (skip === void 0) {
|
19745 | skip = false;
|
19746 | }
|
19747 | if (threshold === void 0) {
|
19748 | threshold = 1;
|
19749 | }
|
19750 | cleanup();
|
19751 | const {
|
19752 | left,
|
19753 | top,
|
19754 | width,
|
19755 | height
|
19756 | } = element.getBoundingClientRect();
|
19757 | if (!skip) {
|
19758 | onMove();
|
19759 | }
|
19760 | if (!width || !height) {
|
19761 | return;
|
19762 | }
|
19763 | const insetTop = floor(top);
|
19764 | const insetRight = floor(root2.clientWidth - (left + width));
|
19765 | const insetBottom = floor(root2.clientHeight - (top + height));
|
19766 | const insetLeft = floor(left);
|
19767 | const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
19768 | const options = {
|
19769 | rootMargin,
|
19770 | threshold: max(0, min(1, threshold)) || 1
|
19771 | };
|
19772 | let isFirstUpdate = true;
|
19773 | function handleObserve(entries) {
|
19774 | const ratio = entries[0].intersectionRatio;
|
19775 | if (ratio !== threshold) {
|
19776 | if (!isFirstUpdate) {
|
19777 | return refresh();
|
19778 | }
|
19779 | if (!ratio) {
|
19780 | timeoutId = setTimeout(() => {
|
19781 | refresh(false, 1e-7);
|
19782 | }, 100);
|
19783 | } else {
|
19784 | refresh(false, ratio);
|
19785 | }
|
19786 | }
|
19787 | isFirstUpdate = false;
|
19788 | }
|
19789 | try {
|
19790 | io = new IntersectionObserver(handleObserve, {
|
19791 | ...options,
|
19792 |
|
19793 | root: root2.ownerDocument
|
19794 | });
|
19795 | } catch (e2) {
|
19796 | io = new IntersectionObserver(handleObserve, options);
|
19797 | }
|
19798 | io.observe(element);
|
19799 | }
|
19800 | refresh(true);
|
19801 | return cleanup;
|
19802 | }
|
19803 | function autoUpdate(reference, floating, update2, options) {
|
19804 | if (options === void 0) {
|
19805 | options = {};
|
19806 | }
|
19807 | const {
|
19808 | ancestorScroll = true,
|
19809 | ancestorResize = true,
|
19810 | elementResize = typeof ResizeObserver === "function",
|
19811 | layoutShift = typeof IntersectionObserver === "function",
|
19812 | animationFrame = false
|
19813 | } = options;
|
19814 | const referenceEl = unwrapElement(reference);
|
19815 | const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
|
19816 | ancestors.forEach((ancestor) => {
|
19817 | ancestorScroll && ancestor.addEventListener("scroll", update2, {
|
19818 | passive: true
|
19819 | });
|
19820 | ancestorResize && ancestor.addEventListener("resize", update2);
|
19821 | });
|
19822 | const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
|
19823 | let reobserveFrame = -1;
|
19824 | let resizeObserver = null;
|
19825 | if (elementResize) {
|
19826 | resizeObserver = new ResizeObserver((_ref) => {
|
19827 | let [firstEntry] = _ref;
|
19828 | if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
19829 | resizeObserver.unobserve(floating);
|
19830 | cancelAnimationFrame(reobserveFrame);
|
19831 | reobserveFrame = requestAnimationFrame(() => {
|
19832 | resizeObserver && resizeObserver.observe(floating);
|
19833 | });
|
19834 | }
|
19835 | update2();
|
19836 | });
|
19837 | if (referenceEl && !animationFrame) {
|
19838 | resizeObserver.observe(referenceEl);
|
19839 | }
|
19840 | resizeObserver.observe(floating);
|
19841 | }
|
19842 | let frameId;
|
19843 | let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
19844 | if (animationFrame) {
|
19845 | frameLoop2();
|
19846 | }
|
19847 | function frameLoop2() {
|
19848 | const nextRefRect = getBoundingClientRect(reference);
|
19849 | if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
|
19850 | update2();
|
19851 | }
|
19852 | prevRefRect = nextRefRect;
|
19853 | frameId = requestAnimationFrame(frameLoop2);
|
19854 | }
|
19855 | update2();
|
19856 | return () => {
|
19857 | ancestors.forEach((ancestor) => {
|
19858 | ancestorScroll && ancestor.removeEventListener("scroll", update2);
|
19859 | ancestorResize && ancestor.removeEventListener("resize", update2);
|
19860 | });
|
19861 | cleanupIo && cleanupIo();
|
19862 | resizeObserver && resizeObserver.disconnect();
|
19863 | resizeObserver = null;
|
19864 | if (animationFrame) {
|
19865 | cancelAnimationFrame(frameId);
|
19866 | }
|
19867 | };
|
19868 | }
|
19869 | const computePosition = (reference, floating, options) => {
|
19870 | const cache = new Map();
|
19871 | const mergedOptions = {
|
19872 | platform,
|
19873 | ...options
|
19874 | };
|
19875 | const platformWithCache = {
|
19876 | ...mergedOptions.platform,
|
19877 | _c: cache
|
19878 | };
|
19879 | return computePosition$1(reference, floating, {
|
19880 | ...mergedOptions,
|
19881 | platform: platformWithCache
|
19882 | });
|
19883 | };
|
19884 | class Wrapper extends React$1.Component {
|
19885 | constructor() {
|
19886 | super(...arguments);
|
19887 | this.element = null;
|
19888 | }
|
19889 | componentDidMount() {
|
19890 | this.componentDidUpdate();
|
19891 | }
|
19892 | componentDidUpdate() {
|
19893 | const node = ReactDOM.findDOMNode(this);
|
19894 | if (node instanceof Element) {
|
19895 | this.element = node;
|
19896 | } else {
|
19897 | this.element = null;
|
19898 | }
|
19899 | }
|
19900 | render() {
|
19901 | return React$1.Children.only(this.props.children);
|
19902 | }
|
19903 | }
|
19904 | const record = {
|
19905 | "topLeft": "top-start",
|
19906 | "topRight": "top-end",
|
19907 | "bottomLeft": "bottom-start",
|
19908 | "bottomRight": "bottom-end",
|
19909 | "leftTop": "left-start",
|
19910 | "leftBottom": "left-end",
|
19911 | "rightTop": "right-start",
|
19912 | "rightBottom": "right-end"
|
19913 | };
|
19914 | function normalizePlacement(placement) {
|
19915 | var _a;
|
19916 | return (_a = record[placement]) !== null && _a !== void 0 ? _a : placement;
|
19917 | }
|
19918 | let tenPxTester = null;
|
19919 | let tester = null;
|
19920 | if (canUseDom$1) {
|
19921 | tenPxTester = document.createElement("div");
|
19922 | tenPxTester.className = "adm-px-tester";
|
19923 | tenPxTester.style.setProperty("--size", "10");
|
19924 | document.body.appendChild(tenPxTester);
|
19925 | tester = document.createElement("div");
|
19926 | tester.className = "adm-px-tester";
|
19927 | document.body.appendChild(tester);
|
19928 | {
|
19929 | if (window.getComputedStyle(tester).position !== "fixed") {
|
19930 | devError("Global", "The px tester is not rendering properly. Please make sure you have imported `antd-mobile/es/global`.");
|
19931 | }
|
19932 | }
|
19933 | }
|
19934 | function convertPx(px) {
|
19935 | if (tenPxTester === null || tester === null)
|
19936 | return px;
|
19937 | if (tenPxTester.getBoundingClientRect().height === 10) {
|
19938 | return px;
|
19939 | }
|
19940 | tester.style.setProperty("--size", px.toString());
|
19941 | return tester.getBoundingClientRect().height;
|
19942 | }
|
19943 | const classPrefix$N = `adm-popover`;
|
19944 | const defaultProps$A = {
|
19945 | placement: "top",
|
19946 | defaultVisible: false,
|
19947 | stopPropagation: ["click"],
|
19948 | getContainer: () => document.body,
|
19949 | mode: "light"
|
19950 | };
|
19951 | const Popover$1 = React$1.forwardRef((p, ref) => {
|
19952 | const props = mergeProps(defaultProps$A, p);
|
19953 | const placement = normalizePlacement(props.placement);
|
19954 | const [visible, setVisible] = usePropsValue({
|
19955 | value: props.visible,
|
19956 | defaultValue: props.defaultVisible,
|
19957 | onChange: props.onVisibleChange
|
19958 | });
|
19959 | React$1.useImperativeHandle(ref, () => ({
|
19960 | show: () => setVisible(true),
|
19961 | hide: () => setVisible(false),
|
19962 | visible
|
19963 | }), [visible]);
|
19964 | const targetRef = React$1.useRef(null);
|
19965 | const floatingRef = React$1.useRef(null);
|
19966 | const arrowRef = React$1.useRef(null);
|
19967 | const floating = withStopPropagation(props.stopPropagation, withNativeProps(props, React$1.createElement("div", {
|
19968 | className: classNames(classPrefix$N, `${classPrefix$N}-${props.mode}`, {
|
19969 | [`${classPrefix$N}-hidden`]: !visible
|
19970 | }),
|
19971 | ref: floatingRef
|
19972 | }, React$1.createElement("div", {
|
19973 | className: `${classPrefix$N}-arrow`,
|
19974 | ref: arrowRef
|
19975 | }, React$1.createElement(Arrow, {
|
19976 | className: `${classPrefix$N}-arrow-icon`
|
19977 | })), React$1.createElement("div", {
|
19978 | className: `${classPrefix$N}-inner`
|
19979 | }, React$1.createElement("div", {
|
19980 | className: `${classPrefix$N}-inner-content`
|
19981 | }, props.content)))));
|
19982 | const [targetElement, setTargetElement] = React$1.useState(null);
|
19983 | function update2() {
|
19984 | var _a, _b, _c;
|
19985 | return __awaiter(this, void 0, void 0, function* () {
|
19986 | const target = (_b = (_a = targetRef.current) === null || _a === void 0 ? void 0 : _a.element) !== null && _b !== void 0 ? _b : null;
|
19987 | const floating2 = floatingRef.current;
|
19988 | const arrowElement = arrowRef.current;
|
19989 | setTargetElement(target);
|
19990 | if (!target || !floating2 || !arrowElement)
|
19991 | return;
|
19992 | const {
|
19993 | x,
|
19994 | y,
|
19995 | placement: realPlacement,
|
19996 | middlewareData
|
19997 | } = yield computePosition(target, floating2, {
|
19998 | placement,
|
19999 | middleware: [offset(convertPx(12)), shift({
|
20000 | padding: convertPx(4),
|
20001 | crossAxis: false,
|
20002 | limiter: limitShift()
|
20003 | }), flip(), hide(), arrow({
|
20004 | element: arrowElement,
|
20005 | padding: convertPx(12)
|
20006 | })]
|
20007 | });
|
20008 | Object.assign(floating2.style, {
|
20009 | left: `${x}px`,
|
20010 | top: `${y}px`
|
20011 | });
|
20012 | const side = realPlacement.split("-")[0];
|
20013 | const arrowSide = {
|
20014 | top: "bottom",
|
20015 | right: "left",
|
20016 | bottom: "top",
|
20017 | left: "right"
|
20018 | }[side];
|
20019 | const {
|
20020 | x: arrowX,
|
20021 | y: arrowY
|
20022 | } = (_c = middlewareData.arrow) !== null && _c !== void 0 ? _c : {};
|
20023 | Object.assign(arrowElement.style, {
|
20024 | left: arrowX != null ? `${arrowX}px` : "",
|
20025 | top: arrowY != null ? `${arrowY}px` : "",
|
20026 | right: "",
|
20027 | bottom: "",
|
20028 | [arrowSide]: "calc(var(--arrow-size) * -1)"
|
20029 | });
|
20030 | const arrowRotate = {
|
20031 | top: "0deg",
|
20032 | bottom: "180deg",
|
20033 | left: "270deg",
|
20034 | right: "90deg"
|
20035 | }[side];
|
20036 | arrowElement.style.setProperty("--arrow-icon-rotate", arrowRotate);
|
20037 | });
|
20038 | }
|
20039 | useIsomorphicLayoutEffect$2(() => {
|
20040 | update2();
|
20041 | });
|
20042 | React$1.useEffect(() => {
|
20043 | if (!targetElement)
|
20044 | return;
|
20045 | if (!props.trigger)
|
20046 | return;
|
20047 | function handleClick() {
|
20048 | setVisible((v) => !v);
|
20049 | }
|
20050 | targetElement.addEventListener("click", handleClick);
|
20051 | return () => {
|
20052 | targetElement.removeEventListener("click", handleClick);
|
20053 | };
|
20054 | }, [targetElement, props.trigger]);
|
20055 | React$1.useEffect(() => {
|
20056 | const floatingElement = floatingRef.current;
|
20057 | if (!targetElement || !floatingElement)
|
20058 | return;
|
20059 | return autoUpdate(targetElement, floatingElement, update2, {
|
20060 | elementResize: typeof ResizeObserver !== "undefined"
|
20061 | });
|
20062 | }, [targetElement]);
|
20063 | useClickAway(() => {
|
20064 | if (!props.trigger)
|
20065 | return;
|
20066 | setVisible(false);
|
20067 | }, [() => {
|
20068 | var _a;
|
20069 | return (_a = targetRef.current) === null || _a === void 0 ? void 0 : _a.element;
|
20070 | }, floatingRef], ["click", "touchmove"]);
|
20071 | const shouldRender = useShouldRender(visible, false, props.destroyOnHide);
|
20072 | return React$1.createElement(React$1.Fragment, null, React$1.createElement(Wrapper, {
|
20073 | ref: targetRef
|
20074 | }, props.children), shouldRender && renderToContainer(props.getContainer, floating));
|
20075 | });
|
20076 | const classPrefix$M = `adm-popover-menu`;
|
20077 | const PopoverMenu = React$1.forwardRef((props, ref) => {
|
20078 | const innerRef = React$1.useRef(null);
|
20079 | React$1.useImperativeHandle(ref, () => innerRef.current, []);
|
20080 | const onClick = React$1.useCallback((e2) => {
|
20081 | var _a;
|
20082 | const {
|
20083 | onAction
|
20084 | } = props;
|
20085 | if (onAction) {
|
20086 | onAction(e2);
|
20087 | }
|
20088 | (_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.hide();
|
20089 | }, [props.onAction]);
|
20090 | const overlay = React$1.useMemo(() => {
|
20091 | const whetherScroll = (props === null || props === void 0 ? void 0 : props.maxCount) && props.actions.length > (props === null || props === void 0 ? void 0 : props.maxCount);
|
20092 | const innerHeight = (props === null || props === void 0 ? void 0 : props.maxCount) && (props === null || props === void 0 ? void 0 : props.maxCount) * 48;
|
20093 | return React$1.createElement("div", {
|
20094 | className: `${classPrefix$M}-list`
|
20095 | }, React$1.createElement("div", {
|
20096 | className: classNames(`${classPrefix$M}-list-inner`, {
|
20097 | [`${classPrefix$M}-list-scroll`]: whetherScroll
|
20098 | }),
|
20099 | style: {
|
20100 | height: innerHeight
|
20101 | }
|
20102 | }, props.actions.map((action, index2) => {
|
20103 | var _a;
|
20104 | return React$1.createElement("a", {
|
20105 | key: (_a = action.key) !== null && _a !== void 0 ? _a : index2,
|
20106 | className: classNames(`${classPrefix$M}-item`, "adm-plain-anchor", {
|
20107 | [`${classPrefix$M}-item-disabled`]: action.disabled
|
20108 | }),
|
20109 | onClick: () => {
|
20110 | var _a2;
|
20111 | if (action.disabled)
|
20112 | return;
|
20113 | onClick(action);
|
20114 | (_a2 = action.onClick) === null || _a2 === void 0 ? void 0 : _a2.call(action);
|
20115 | }
|
20116 | }, action.icon && React$1.createElement("div", {
|
20117 | className: `${classPrefix$M}-item-icon`
|
20118 | }, action.icon), React$1.createElement("div", {
|
20119 | className: `${classPrefix$M}-item-text`
|
20120 | }, action.text));
|
20121 | })));
|
20122 | }, [props.actions, onClick]);
|
20123 | return React$1.createElement(Popover$1, Object.assign({
|
20124 | ref: innerRef
|
20125 | }, props, {
|
20126 | className: classNames(classPrefix$M, props.className),
|
20127 | content: overlay
|
20128 | }), props.children);
|
20129 | });
|
20130 | const Popover = attachPropertiesToComponent(Popover$1, {
|
20131 | Menu: PopoverMenu
|
20132 | });
|
20133 | function toArray(candidate) {
|
20134 | if (candidate === void 0 || candidate === false)
|
20135 | return [];
|
20136 | return Array.isArray(candidate) ? candidate : [candidate];
|
20137 | }
|
20138 | function shouldConstruct(Component) {
|
20139 | const prototype = Component.prototype;
|
20140 | return !!(prototype && prototype.isReactComponent);
|
20141 | }
|
20142 | function isSimpleFunctionComponent(type) {
|
20143 | return typeof type === "function" && !shouldConstruct(type) && type.defaultProps === void 0;
|
20144 | }
|
20145 | function isSafeSetRefComponent(component) {
|
20146 | if (reactIsExports.isFragment(component))
|
20147 | return false;
|
20148 | if (reactIsExports.isMemo(component))
|
20149 | return isSafeSetRefComponent(component.type);
|
20150 | return !isSimpleFunctionComponent(component.type);
|
20151 | }
|
20152 | const NAME_SPLIT = "__SPLIT__";
|
20153 | const classPrefix$L = `adm-form-item`;
|
20154 | const MemoInput = React$1.memo(({
|
20155 | children
|
20156 | }) => children, (prev, next) => prev.value === next.value && prev.update === next.update);
|
20157 | const FormItemLayout = (props) => {
|
20158 | var _a;
|
20159 | const {
|
20160 | locale,
|
20161 | form: componentConfig = {}
|
20162 | } = useConfig();
|
20163 | const {
|
20164 | style,
|
20165 | extra,
|
20166 | label,
|
20167 | help,
|
20168 | helpIcon,
|
20169 | required,
|
20170 | children,
|
20171 | htmlFor,
|
20172 | hidden,
|
20173 | arrow: arrow2,
|
20174 | arrowIcon,
|
20175 | childElementPosition = "normal"
|
20176 | } = mergeProps(componentConfig, props);
|
20177 | const context = React$1.useContext(FormContext);
|
20178 | const hasFeedback = props.hasFeedback !== void 0 ? props.hasFeedback : context.hasFeedback;
|
20179 | const layout = props.layout || context.layout;
|
20180 | const disabled = (_a = props.disabled) !== null && _a !== void 0 ? _a : context.disabled;
|
20181 | const requiredMark = (() => {
|
20182 | const {
|
20183 | requiredMarkStyle
|
20184 | } = context;
|
20185 | switch (requiredMarkStyle) {
|
20186 | case "asterisk":
|
20187 | return required && React$1.createElement("span", {
|
20188 | className: `${classPrefix$L}-required-asterisk`
|
20189 | }, "*");
|
20190 | case "text-required":
|
20191 | return required && React$1.createElement("span", {
|
20192 | className: `${classPrefix$L}-required-text`
|
20193 | }, "(", locale.Form.required, ")");
|
20194 | case "text-optional":
|
20195 | return !required && React$1.createElement("span", {
|
20196 | className: `${classPrefix$L}-required-text`
|
20197 | }, "(", locale.Form.optional, ")");
|
20198 | case "none":
|
20199 | return null;
|
20200 | default:
|
20201 | return null;
|
20202 | }
|
20203 | })();
|
20204 | const labelElement = !!label && React$1.createElement("label", {
|
20205 | className: `${classPrefix$L}-label`,
|
20206 | htmlFor
|
20207 | }, label, requiredMark, help && React$1.createElement(Popover, {
|
20208 | content: help,
|
20209 | mode: "dark",
|
20210 | trigger: "click"
|
20211 | }, React$1.createElement("span", {
|
20212 | className: `${classPrefix$L}-label-help`,
|
20213 | onClick: (e2) => {
|
20214 | e2.stopPropagation();
|
20215 | e2.preventDefault();
|
20216 | }
|
20217 | }, helpIcon || React$1.createElement(QuestionCircleOutline, null))));
|
20218 | const description = (!!props.description || hasFeedback) && React$1.createElement(React$1.Fragment, null, props.description, hasFeedback && React$1.createElement(React$1.Fragment, null, props.errors.map((error, index2) => React$1.createElement("div", {
|
20219 | key: `error-${index2}`,
|
20220 | className: `${classPrefix$L}-feedback-error`
|
20221 | }, error)), props.warnings.map((warning2, index2) => React$1.createElement("div", {
|
20222 | key: `warning-${index2}`,
|
20223 | className: `${classPrefix$L}-feedback-warning`
|
20224 | }, warning2))));
|
20225 | return withNativeProps(props, React$1.createElement(List$1.Item, {
|
20226 | style,
|
20227 | title: layout === "vertical" && labelElement,
|
20228 | prefix: layout === "horizontal" && labelElement,
|
20229 | extra,
|
20230 | description,
|
20231 | className: classNames(classPrefix$L, `${classPrefix$L}-${layout}`, {
|
20232 | [`${classPrefix$L}-hidden`]: hidden,
|
20233 | [`${classPrefix$L}-has-error`]: props.errors.length
|
20234 | }),
|
20235 | disabled,
|
20236 | onClick: props.onClick,
|
20237 | clickable: props.clickable,
|
20238 | arrowIcon: arrowIcon || arrow2
|
20239 | }, React$1.createElement("div", {
|
20240 | className: classNames(`${classPrefix$L}-child`, `${classPrefix$L}-child-position-${childElementPosition}`)
|
20241 | }, React$1.createElement("div", {
|
20242 | className: classNames(`${classPrefix$L}-child-inner`)
|
20243 | }, children))));
|
20244 | };
|
20245 | const FormItem = (props) => {
|
20246 | const {
|
20247 |
|
20248 | style,
|
20249 |
|
20250 | label,
|
20251 | help,
|
20252 | helpIcon,
|
20253 | extra,
|
20254 | hasFeedback,
|
20255 | name,
|
20256 | required,
|
20257 | noStyle,
|
20258 | hidden,
|
20259 | layout,
|
20260 | childElementPosition,
|
20261 | description,
|
20262 |
|
20263 | disabled,
|
20264 | rules: rules2,
|
20265 | children,
|
20266 | messageVariables,
|
20267 | trigger = "onChange",
|
20268 | validateTrigger = trigger,
|
20269 | onClick,
|
20270 | shouldUpdate,
|
20271 | dependencies,
|
20272 | clickable,
|
20273 | arrow: arrow2,
|
20274 | arrowIcon
|
20275 | } = props, fieldProps = __rest(props, ["style", "label", "help", "helpIcon", "extra", "hasFeedback", "name", "required", "noStyle", "hidden", "layout", "childElementPosition", "description", "disabled", "rules", "children", "messageVariables", "trigger", "validateTrigger", "onClick", "shouldUpdate", "dependencies", "clickable", "arrow", "arrowIcon"]);
|
20276 | const {
|
20277 | name: formName
|
20278 | } = React$1.useContext(FormContext);
|
20279 | const {
|
20280 | validateTrigger: contextValidateTrigger
|
20281 | } = React$1.useContext(default_1);
|
20282 | const mergedValidateTrigger = undefinedFallback(validateTrigger, contextValidateTrigger, trigger);
|
20283 | const widgetRef = React$1.useRef(null);
|
20284 | const updateRef2 = React$1.useRef(0);
|
20285 | updateRef2.current += 1;
|
20286 | const [subMetas, setSubMetas] = React$1.useState({});
|
20287 | const onSubMetaChange = React$1.useCallback((subMeta, namePath) => {
|
20288 | setSubMetas((prevSubMetas) => {
|
20289 | const nextSubMetas = Object.assign({}, prevSubMetas);
|
20290 | const nameKey = namePath.join(NAME_SPLIT);
|
20291 | if (subMeta.destroy) {
|
20292 | delete nextSubMetas[nameKey];
|
20293 | } else {
|
20294 | nextSubMetas[nameKey] = subMeta;
|
20295 | }
|
20296 | return nextSubMetas;
|
20297 | });
|
20298 | }, [setSubMetas]);
|
20299 | function renderLayout(baseChildren, fieldId, meta, isRequired) {
|
20300 | var _a, _b;
|
20301 | if (noStyle && !hidden) {
|
20302 | return baseChildren;
|
20303 | }
|
20304 | const curErrors = (_a = meta === null || meta === void 0 ? void 0 : meta.errors) !== null && _a !== void 0 ? _a : [];
|
20305 | const errors = Object.keys(subMetas).reduce((subErrors, key) => {
|
20306 | var _a2, _b2;
|
20307 | const errors2 = (_b2 = (_a2 = subMetas[key]) === null || _a2 === void 0 ? void 0 : _a2.errors) !== null && _b2 !== void 0 ? _b2 : [];
|
20308 | if (errors2.length) {
|
20309 | subErrors = [...subErrors, ...errors2];
|
20310 | }
|
20311 | return subErrors;
|
20312 | }, curErrors);
|
20313 | const curWarnings = (_b = meta === null || meta === void 0 ? void 0 : meta.warnings) !== null && _b !== void 0 ? _b : [];
|
20314 | const warnings = Object.keys(subMetas).reduce((subWarnings, key) => {
|
20315 | var _a2, _b2;
|
20316 | const warnings2 = (_b2 = (_a2 = subMetas[key]) === null || _a2 === void 0 ? void 0 : _a2.warnings) !== null && _b2 !== void 0 ? _b2 : [];
|
20317 | if (warnings2.length) {
|
20318 | subWarnings = [...subWarnings, ...warnings2];
|
20319 | }
|
20320 | return subWarnings;
|
20321 | }, curWarnings);
|
20322 | return withNativeProps(props, React$1.createElement(FormItemLayout, {
|
20323 | style,
|
20324 | label,
|
20325 | extra,
|
20326 | help,
|
20327 | helpIcon,
|
20328 | description,
|
20329 | required: isRequired,
|
20330 | disabled,
|
20331 | hasFeedback,
|
20332 | htmlFor: fieldId,
|
20333 | errors,
|
20334 | warnings,
|
20335 | onClick: onClick && ((e2) => onClick(e2, widgetRef)),
|
20336 | hidden,
|
20337 | layout,
|
20338 | childElementPosition,
|
20339 | clickable,
|
20340 | arrow: arrow2,
|
20341 | arrowIcon
|
20342 | }, React$1.createElement(NoStyleItemContext.Provider, {
|
20343 | value: onSubMetaChange
|
20344 | }, baseChildren)));
|
20345 | }
|
20346 | const isRenderProps = typeof children === "function";
|
20347 | if (!name && !isRenderProps && !props.dependencies) {
|
20348 | return renderLayout(children);
|
20349 | }
|
20350 | let Variables = {};
|
20351 | Variables.label = typeof label === "string" ? label : "";
|
20352 | if (messageVariables) {
|
20353 | Variables = Object.assign(Object.assign({}, Variables), messageVariables);
|
20354 | }
|
20355 | const notifyParentMetaChange = React$1.useContext(NoStyleItemContext);
|
20356 | const onMetaChange = (meta) => {
|
20357 | if (noStyle && notifyParentMetaChange) {
|
20358 | const namePath = meta.name;
|
20359 | notifyParentMetaChange(meta, namePath);
|
20360 | }
|
20361 | };
|
20362 | return React$1.createElement(WrapperField, Object.assign({}, fieldProps, {
|
20363 | name,
|
20364 | shouldUpdate,
|
20365 | dependencies,
|
20366 | rules: rules2,
|
20367 | trigger,
|
20368 | validateTrigger: mergedValidateTrigger,
|
20369 | onMetaChange,
|
20370 | messageVariables: Variables
|
20371 | }), (control, meta, context) => {
|
20372 | let childNode = null;
|
20373 | const isRequired = required !== void 0 ? required : rules2 && rules2.some((rule) => !!(rule && typeof rule === "object" && rule.required));
|
20374 | const nameList = toArray(name).length && meta ? meta.name : [];
|
20375 | const fieldId = (nameList.length > 0 && formName ? [formName, ...nameList] : nameList).join("_");
|
20376 | if (shouldUpdate && dependencies) {
|
20377 | devWarning("Form.Item", "`shouldUpdate` and `dependencies` shouldn't be used together.");
|
20378 | }
|
20379 | if (isRenderProps) {
|
20380 | if ((shouldUpdate || dependencies) && !name) {
|
20381 | childNode = children(context);
|
20382 | } else {
|
20383 | if (!(shouldUpdate || dependencies)) {
|
20384 | devWarning("Form.Item", "`children` of render props only work with `shouldUpdate` or `dependencies`.");
|
20385 | }
|
20386 | if (name) {
|
20387 | devWarning("Form.Item", "Do not use `name` with `children` of render props since it's not a field.");
|
20388 | }
|
20389 | }
|
20390 | } else if (dependencies && !name) {
|
20391 | devWarning("Form.Item", "Must set `name` or use render props when `dependencies` is set.");
|
20392 | } else if (React$1.isValidElement(children)) {
|
20393 | if (children.props.defaultValue) {
|
20394 | devWarning("Form.Item", "`defaultValue` will not work on controlled Field. You should use `initialValues` of Form instead.");
|
20395 | }
|
20396 | const childProps = Object.assign(Object.assign({}, children.props), control);
|
20397 | if (isSafeSetRefComponent(children)) {
|
20398 | childProps.ref = (instance) => {
|
20399 | const originRef = children.ref;
|
20400 | if (originRef) {
|
20401 | if (typeof originRef === "function") {
|
20402 | originRef(instance);
|
20403 | }
|
20404 | if ("current" in originRef) {
|
20405 | originRef.current = instance;
|
20406 | }
|
20407 | }
|
20408 | widgetRef.current = instance;
|
20409 | };
|
20410 | }
|
20411 | if (!childProps.id) {
|
20412 | childProps.id = fieldId;
|
20413 | }
|
20414 | const triggers = new Set([...toArray(trigger), ...toArray(mergedValidateTrigger)]);
|
20415 | triggers.forEach((eventName) => {
|
20416 | childProps[eventName] = (...args) => {
|
20417 | var _a, _b, _c;
|
20418 | (_a = control[eventName]) === null || _a === void 0 ? void 0 : _a.call(control, ...args);
|
20419 | (_c = (_b = children.props)[eventName]) === null || _c === void 0 ? void 0 : _c.call(_b, ...args);
|
20420 | };
|
20421 | });
|
20422 | childNode = React$1.createElement(MemoInput, {
|
20423 | value: control[props.valuePropName || "value"],
|
20424 | update: updateRef2.current
|
20425 | }, React$1.cloneElement(children, childProps));
|
20426 | } else {
|
20427 | if (name) {
|
20428 | devWarning("Form.Item", "`name` is only used for validate React element. If you are using Form.Item as layout display, please remove `name` instead.");
|
20429 | }
|
20430 | childNode = children;
|
20431 | }
|
20432 | return renderLayout(childNode, fieldId, meta, isRequired);
|
20433 | });
|
20434 | };
|
20435 | const FormSubscribe = (props) => {
|
20436 | const update2 = useUpdate$1();
|
20437 | const form = React$1.useContext(Context$1);
|
20438 | const value = form.getFieldsValue(props.to);
|
20439 | const childNode = React$1.useMemo(() => props.children(value, form), [JSON.stringify(value), props.children]);
|
20440 | return React$1.createElement(React$1.Fragment, null, childNode, props.to.map((namePath) => React$1.createElement(Watcher, {
|
20441 | key: namePath.toString(),
|
20442 | form,
|
20443 | namePath,
|
20444 | onChange: update2
|
20445 | })));
|
20446 | };
|
20447 | const Watcher = React$1.memo((props) => {
|
20448 | const value = useWatch(props.namePath, props.form);
|
20449 | useIsomorphicUpdateLayoutEffect(() => {
|
20450 | props.onChange();
|
20451 | }, [value]);
|
20452 | return null;
|
20453 | });
|
20454 | const index$a = attachPropertiesToComponent(Form, {
|
20455 | Item: FormItem,
|
20456 | Subscribe: FormSubscribe,
|
20457 | Header,
|
20458 | Array: FormArray,
|
20459 | useForm,
|
20460 | useWatch
|
20461 | });
|
20462 | const classPrefix$K = `adm-grid`;
|
20463 | const Grid$1 = (props) => {
|
20464 | const style = {
|
20465 | "--columns": props.columns.toString()
|
20466 | };
|
20467 | const {
|
20468 | gap
|
20469 | } = props;
|
20470 | if (gap !== void 0) {
|
20471 | if (Array.isArray(gap)) {
|
20472 | style["--gap-horizontal"] = toCSSLength(gap[0]);
|
20473 | style["--gap-vertical"] = toCSSLength(gap[1]);
|
20474 | } else {
|
20475 | style["--gap"] = toCSSLength(gap);
|
20476 | }
|
20477 | }
|
20478 | return withNativeProps(props, React$1.createElement("div", {
|
20479 | className: classPrefix$K,
|
20480 | style
|
20481 | }, props.children));
|
20482 | };
|
20483 | const GridItem = (p) => {
|
20484 | const props = mergeProps({
|
20485 | span: 1
|
20486 | }, p);
|
20487 | const itemStyle = {
|
20488 | "--item-span": props.span
|
20489 | };
|
20490 | return withNativeProps(props, React$1.createElement("div", {
|
20491 | className: `${classPrefix$K}-item`,
|
20492 | style: itemStyle,
|
20493 | onClick: props.onClick
|
20494 | }, props.children));
|
20495 | };
|
20496 | const Grid = attachPropertiesToComponent(Grid$1, {
|
20497 | Item: GridItem
|
20498 | });
|
20499 | const useDragAndPinch = createUseGesture([dragAction, pinchAction]);
|
20500 | const create = () => {
|
20501 | return [1, 0, 0, 1, 0, 0];
|
20502 | };
|
20503 | const getTranslateX = (m) => {
|
20504 | return m[4];
|
20505 | };
|
20506 | const getTranslateY = (m) => {
|
20507 | return m[5];
|
20508 | };
|
20509 | const getScaleX = (m) => {
|
20510 | return m[0];
|
20511 | };
|
20512 | const translate = (m, x, y) => {
|
20513 | return multiply([1, 0, 0, 1, x, y], m);
|
20514 | };
|
20515 | const scale = (m, scaleX, scaleY = scaleX) => {
|
20516 | return multiply([scaleX, 0, 0, scaleY, 0, 0], m);
|
20517 | };
|
20518 | const apply = (m, [ox, oy]) => {
|
20519 | return [m[0] * ox + m[2] * oy + m[4], m[1] * ox + m[3] * oy + m[5]];
|
20520 | };
|
20521 | const multiply = (m1, m2) => {
|
20522 | return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]];
|
20523 | };
|
20524 | const classPrefix$J = `adm-image-viewer`;
|
20525 | const Slide = (props) => {
|
20526 | const {
|
20527 | dragLockRef,
|
20528 | maxZoom
|
20529 | } = props;
|
20530 | const initialMartix = React$1.useRef([]);
|
20531 | const controlRef = React$1.useRef(null);
|
20532 | const imgRef = React$1.useRef(null);
|
20533 | const [{
|
20534 | matrix
|
20535 | }, api] = useSpring(() => ({
|
20536 | matrix: create(),
|
20537 | config: {
|
20538 | tension: 200
|
20539 | }
|
20540 | }));
|
20541 | const controlSize = useSize(controlRef);
|
20542 | const imgSize = useSize(imgRef);
|
20543 | const pinchLockRef = React$1.useRef(false);
|
20544 | const getMinAndMax = (nextMatrix) => {
|
20545 | if (!controlSize || !imgSize)
|
20546 | return {
|
20547 | x: {
|
20548 | position: 0,
|
20549 | minX: 0,
|
20550 | maxX: 0
|
20551 | },
|
20552 | y: {
|
20553 | position: 0,
|
20554 | minY: 0,
|
20555 | maxY: 0
|
20556 | }
|
20557 | };
|
20558 | const controlLeft = -controlSize.width / 2;
|
20559 | const controlTop = -controlSize.height / 2;
|
20560 | const imgLeft = -imgSize.width / 2;
|
20561 | const imgTop = -imgSize.height / 2;
|
20562 | const zoom = getScaleX(nextMatrix);
|
20563 | const scaledImgWidth = zoom * imgSize.width;
|
20564 | const scaledImgHeight = zoom * imgSize.height;
|
20565 | const minX = controlLeft - (scaledImgWidth - controlSize.width);
|
20566 | const maxX = controlLeft;
|
20567 | const minY = controlTop - (scaledImgHeight - controlSize.height);
|
20568 | const maxY = controlTop;
|
20569 | const [x, y] = apply(nextMatrix, [imgLeft, imgTop]);
|
20570 | return {
|
20571 | x: {
|
20572 | position: x,
|
20573 | minX,
|
20574 | maxX
|
20575 | },
|
20576 | y: {
|
20577 | position: y,
|
20578 | minY,
|
20579 | maxY
|
20580 | }
|
20581 | };
|
20582 | };
|
20583 | const getReachBound = (position, min2, max2, buffer = 0) => {
|
20584 | return [position <= min2 - buffer, position >= max2 + buffer];
|
20585 | };
|
20586 | const boundMatrix = (nextMatrix, type, last = false) => {
|
20587 | if (!controlSize || !imgSize)
|
20588 | return nextMatrix;
|
20589 | const zoom = getScaleX(nextMatrix);
|
20590 | const scaledImgWidth = zoom * imgSize.width;
|
20591 | const scaledImgHeight = zoom * imgSize.height;
|
20592 | const {
|
20593 | x: {
|
20594 | position: x,
|
20595 | minX,
|
20596 | maxX
|
20597 | },
|
20598 | y: {
|
20599 | position: y,
|
20600 | minY,
|
20601 | maxY
|
20602 | }
|
20603 | } = getMinAndMax(nextMatrix);
|
20604 | if (type === "translate") {
|
20605 | let boundedX = x;
|
20606 | let boundedY = y;
|
20607 | if (scaledImgWidth > controlSize.width) {
|
20608 | boundedX = last ? bound(x, minX, maxX) : rubberbandIfOutOfBounds(x, minX, maxX, zoom * 50);
|
20609 | } else {
|
20610 | boundedX = -scaledImgWidth / 2;
|
20611 | }
|
20612 | if (scaledImgHeight > controlSize.height) {
|
20613 | boundedY = last ? bound(y, minY, maxY) : rubberbandIfOutOfBounds(y, minY, maxY, zoom * 50);
|
20614 | } else {
|
20615 | boundedY = -scaledImgHeight / 2;
|
20616 | }
|
20617 | return translate(nextMatrix, boundedX - x, boundedY - y);
|
20618 | }
|
20619 | if (type === "scale" && last) {
|
20620 | const [boundedX, boundedY] = [scaledImgWidth > controlSize.width ? bound(x, minX, maxX) : -scaledImgWidth / 2, scaledImgHeight > controlSize.height ? bound(y, minY, maxY) : -scaledImgHeight / 2];
|
20621 | return translate(nextMatrix, boundedX - x, boundedY - y);
|
20622 | }
|
20623 | return nextMatrix;
|
20624 | };
|
20625 | useDragAndPinch({
|
20626 | onDrag: (state) => {
|
20627 | var _a;
|
20628 | if (state.first) {
|
20629 | const {
|
20630 | x: {
|
20631 | position: x,
|
20632 | minX,
|
20633 | maxX
|
20634 | }
|
20635 | } = getMinAndMax(matrix.get());
|
20636 | initialMartix.current = getReachBound(x, minX, maxX);
|
20637 | return;
|
20638 | }
|
20639 | if (state.pinching)
|
20640 | return state.cancel();
|
20641 | if (state.tap && state.elapsedTime > 0 && state.elapsedTime < 1e3) {
|
20642 | (_a = props.onTap) === null || _a === void 0 ? void 0 : _a.call(props);
|
20643 | return;
|
20644 | }
|
20645 | const currentZoom = getScaleX(matrix.get());
|
20646 | if (dragLockRef) {
|
20647 | dragLockRef.current = currentZoom !== 1;
|
20648 | }
|
20649 | if (!pinchLockRef.current && currentZoom <= 1) {
|
20650 | api.start({
|
20651 | matrix: create()
|
20652 | });
|
20653 | } else {
|
20654 | const currentMatrix = matrix.get();
|
20655 | const offset2 = [state.offset[0] - getTranslateX(currentMatrix), state.offset[1] - getTranslateY(currentMatrix)];
|
20656 | const nextMatrix = translate(currentMatrix, ...state.last ? [offset2[0] + state.velocity[0] * state.direction[0] * 200, offset2[1] + state.velocity[1] * state.direction[1] * 200] : offset2);
|
20657 | api.start({
|
20658 | matrix: boundMatrix(nextMatrix, "translate", state.last),
|
20659 | immediate: !state.last
|
20660 | });
|
20661 | const {
|
20662 | x: {
|
20663 | position: x,
|
20664 | minX,
|
20665 | maxX
|
20666 | }
|
20667 | } = getMinAndMax(nextMatrix);
|
20668 | if (state.last && initialMartix.current.some((i2) => i2) && getReachBound(x, minX, maxX).some((i2) => i2)) {
|
20669 | if (dragLockRef) {
|
20670 | dragLockRef.current = false;
|
20671 | }
|
20672 | api.start({
|
20673 | matrix: create()
|
20674 | });
|
20675 | }
|
20676 | }
|
20677 | },
|
20678 | onPinch: (state) => {
|
20679 | var _a;
|
20680 | pinchLockRef.current = !state.last;
|
20681 | const [d] = state.offset;
|
20682 | if (d < 0)
|
20683 | return;
|
20684 | let mergedMaxZoom;
|
20685 | if (maxZoom === "auto") {
|
20686 | mergedMaxZoom = controlSize && imgSize ? Math.max(controlSize.height / imgSize.height, controlSize.width / imgSize.width) : 1;
|
20687 | } else {
|
20688 | mergedMaxZoom = maxZoom;
|
20689 | }
|
20690 | const nextZoom = state.last ? bound(d, 1, mergedMaxZoom) : d;
|
20691 | (_a = props.onZoomChange) === null || _a === void 0 ? void 0 : _a.call(props, nextZoom);
|
20692 | if (state.last && nextZoom <= 1) {
|
20693 | api.start({
|
20694 | matrix: create()
|
20695 | });
|
20696 | if (dragLockRef) {
|
20697 | dragLockRef.current = false;
|
20698 | }
|
20699 | } else {
|
20700 | if (!controlSize)
|
20701 | return;
|
20702 | const currentMatrix = matrix.get();
|
20703 | const currentZoom = getScaleX(currentMatrix);
|
20704 | const originOffsetX = state.origin[0] - controlSize.width / 2;
|
20705 | const originOffsetY = state.origin[1] - controlSize.height / 2;
|
20706 | let nextMatrix = translate(currentMatrix, -originOffsetX, -originOffsetY);
|
20707 | nextMatrix = scale(nextMatrix, nextZoom / currentZoom);
|
20708 | nextMatrix = translate(nextMatrix, originOffsetX, originOffsetY);
|
20709 | api.start({
|
20710 | matrix: boundMatrix(nextMatrix, "scale", state.last),
|
20711 | immediate: !state.last
|
20712 | });
|
20713 | if (dragLockRef) {
|
20714 | dragLockRef.current = true;
|
20715 | }
|
20716 | }
|
20717 | }
|
20718 | }, {
|
20719 | target: controlRef,
|
20720 | drag: {
|
20721 | from: () => [getTranslateX(matrix.get()), getTranslateY(matrix.get())],
|
20722 | pointer: {
|
20723 | touch: true
|
20724 | }
|
20725 | },
|
20726 | pinch: {
|
20727 | from: () => [getScaleX(matrix.get()), 0],
|
20728 | pointer: {
|
20729 | touch: true
|
20730 | }
|
20731 | }
|
20732 | });
|
20733 | return React$1.createElement("div", {
|
20734 | className: `${classPrefix$J}-slide`
|
20735 | }, React$1.createElement("div", {
|
20736 | className: `${classPrefix$J}-control`,
|
20737 | ref: controlRef
|
20738 | }, React$1.createElement(animated.div, {
|
20739 | className: `${classPrefix$J}-image-wrapper`,
|
20740 | style: {
|
20741 | matrix
|
20742 | }
|
20743 | }, React$1.createElement("img", {
|
20744 | ref: imgRef,
|
20745 | src: props.image,
|
20746 | draggable: false,
|
20747 | alt: props.image
|
20748 | }))));
|
20749 | };
|
20750 | const classPrefix$I = `adm-image-viewer`;
|
20751 | const Slides = React$1.forwardRef((props, ref) => {
|
20752 | const slideWidth = window.innerWidth + convertPx(16);
|
20753 | const [{
|
20754 | x
|
20755 | }, api] = useSpring(() => ({
|
20756 | x: props.defaultIndex * slideWidth,
|
20757 | config: {
|
20758 | tension: 250,
|
20759 | clamp: true
|
20760 | }
|
20761 | }));
|
20762 | const count = props.images.length;
|
20763 | function swipeTo(index2, immediate = false) {
|
20764 | var _a;
|
20765 | const i2 = bound(index2, 0, count - 1);
|
20766 | (_a = props.onIndexChange) === null || _a === void 0 ? void 0 : _a.call(props, i2);
|
20767 | api.start({
|
20768 | x: i2 * slideWidth,
|
20769 | immediate
|
20770 | });
|
20771 | }
|
20772 | React$1.useImperativeHandle(ref, () => ({
|
20773 | swipeTo
|
20774 | }));
|
20775 | const dragLockRef = React$1.useRef(false);
|
20776 | const bind = useDrag((state) => {
|
20777 | if (dragLockRef.current)
|
20778 | return;
|
20779 | const [offsetX] = state.offset;
|
20780 | if (state.last) {
|
20781 | const minIndex = Math.floor(offsetX / slideWidth);
|
20782 | const maxIndex = minIndex + 1;
|
20783 | const velocityOffset = Math.min(state.velocity[0] * 2e3, slideWidth) * state.direction[0];
|
20784 | swipeTo(bound(Math.round((offsetX + velocityOffset) / slideWidth), minIndex, maxIndex));
|
20785 | } else {
|
20786 | api.start({
|
20787 | x: offsetX,
|
20788 | immediate: true
|
20789 | });
|
20790 | }
|
20791 | }, {
|
20792 | transform: ([x2, y]) => [-x2, y],
|
20793 | from: () => [x.get(), 0],
|
20794 | bounds: () => ({
|
20795 | left: 0,
|
20796 | right: (count - 1) * slideWidth
|
20797 | }),
|
20798 | rubberband: true,
|
20799 | axis: "x",
|
20800 | pointer: {
|
20801 | touch: true
|
20802 | }
|
20803 | });
|
20804 | return React$1.createElement("div", Object.assign({
|
20805 | className: `${classPrefix$I}-slides`
|
20806 | }, bind()), React$1.createElement(animated.div, {
|
20807 | className: `${classPrefix$I}-indicator`
|
20808 | }, x.to((v) => {
|
20809 | const index2 = bound(Math.round(v / slideWidth), 0, count - 1);
|
20810 | return `${index2 + 1} / ${count}`;
|
20811 | })), React$1.createElement(animated.div, {
|
20812 | className: `${classPrefix$I}-slides-inner`,
|
20813 | style: {
|
20814 | x: x.to((x2) => -x2)
|
20815 | }
|
20816 | }, props.images.map((image, index2) => React$1.createElement(Slide, {
|
20817 | key: index2,
|
20818 | image,
|
20819 | onTap: props.onTap,
|
20820 | maxZoom: props.maxZoom,
|
20821 | onZoomChange: (zoom) => {
|
20822 | if (zoom !== 1) {
|
20823 | const index3 = Math.round(x.get() / slideWidth);
|
20824 | api.start({
|
20825 | x: index3 * slideWidth
|
20826 | });
|
20827 | }
|
20828 | },
|
20829 | dragLockRef
|
20830 | }))));
|
20831 | });
|
20832 | const classPrefix$H = `adm-image-viewer`;
|
20833 | const defaultProps$z = {
|
20834 | maxZoom: 3,
|
20835 | getContainer: null,
|
20836 | visible: false
|
20837 | };
|
20838 | const ImageViewer$1 = (p) => {
|
20839 | var _a, _b, _c;
|
20840 | const props = mergeProps(defaultProps$z, p);
|
20841 | const node = React$1.createElement(Mask, {
|
20842 | visible: props.visible,
|
20843 | disableBodyScroll: false,
|
20844 | opacity: "thick",
|
20845 | afterClose: props.afterClose,
|
20846 | destroyOnClose: true,
|
20847 | className: (_a = props === null || props === void 0 ? void 0 : props.classNames) === null || _a === void 0 ? void 0 : _a.mask
|
20848 | }, React$1.createElement("div", {
|
20849 | className: classNames(`${classPrefix$H}-content`, (_b = props === null || props === void 0 ? void 0 : props.classNames) === null || _b === void 0 ? void 0 : _b.body)
|
20850 | }, props.image && React$1.createElement(Slide, {
|
20851 | image: props.image,
|
20852 | onTap: props.onClose,
|
20853 | maxZoom: props.maxZoom
|
20854 | })), props.image && React$1.createElement("div", {
|
20855 | className: `${classPrefix$H}-footer`
|
20856 | }, (_c = props.renderFooter) === null || _c === void 0 ? void 0 : _c.call(props, props.image), React$1.createElement(SafeArea, {
|
20857 | position: "bottom"
|
20858 | })));
|
20859 | return renderToContainer(props.getContainer, node);
|
20860 | };
|
20861 | const multiDefaultProps = Object.assign(Object.assign({}, defaultProps$z), {
|
20862 | defaultIndex: 0
|
20863 | });
|
20864 | const MultiImageViewer = React$1.forwardRef((p, ref) => {
|
20865 | var _a, _b, _c;
|
20866 | const props = mergeProps(multiDefaultProps, p);
|
20867 | const [index2, setIndex] = React$1.useState(props.defaultIndex);
|
20868 | const slidesRef = React$1.useRef(null);
|
20869 | React$1.useImperativeHandle(ref, () => ({
|
20870 | swipeTo: (index3, immediate) => {
|
20871 | var _a2;
|
20872 | setIndex(index3);
|
20873 | (_a2 = slidesRef.current) === null || _a2 === void 0 ? void 0 : _a2.swipeTo(index3, immediate);
|
20874 | }
|
20875 | }));
|
20876 | const onSlideChange = React$1.useCallback((newIndex) => {
|
20877 | var _a2;
|
20878 | if (newIndex === index2)
|
20879 | return;
|
20880 | setIndex(newIndex);
|
20881 | (_a2 = props.onIndexChange) === null || _a2 === void 0 ? void 0 : _a2.call(props, newIndex);
|
20882 | }, [props.onIndexChange, index2]);
|
20883 | const node = React$1.createElement(Mask, {
|
20884 | visible: props.visible,
|
20885 | disableBodyScroll: false,
|
20886 | opacity: "thick",
|
20887 | afterClose: props.afterClose,
|
20888 | destroyOnClose: true,
|
20889 | className: (_a = props === null || props === void 0 ? void 0 : props.classNames) === null || _a === void 0 ? void 0 : _a.mask
|
20890 | }, React$1.createElement("div", {
|
20891 | className: classNames(`${classPrefix$H}-content`, (_b = props === null || props === void 0 ? void 0 : props.classNames) === null || _b === void 0 ? void 0 : _b.body)
|
20892 | }, props.images && React$1.createElement(Slides, {
|
20893 | ref: slidesRef,
|
20894 | defaultIndex: index2,
|
20895 | onIndexChange: onSlideChange,
|
20896 | images: props.images,
|
20897 | onTap: props.onClose,
|
20898 | maxZoom: props.maxZoom
|
20899 | })), props.images && React$1.createElement("div", {
|
20900 | className: `${classPrefix$H}-footer`
|
20901 | }, (_c = props.renderFooter) === null || _c === void 0 ? void 0 : _c.call(props, props.images[index2], index2), React$1.createElement(SafeArea, {
|
20902 | position: "bottom"
|
20903 | })));
|
20904 | return renderToContainer(props.getContainer, node);
|
20905 | });
|
20906 | const handlerSet = new Set();
|
20907 | function showImageViewer(props) {
|
20908 | clearImageViewer();
|
20909 | const handler = renderImperatively(React$1.createElement(ImageViewer$1, Object.assign({}, props, {
|
20910 | afterClose: () => {
|
20911 | var _a;
|
20912 | handlerSet.delete(handler);
|
20913 | (_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
20914 | }
|
20915 | })));
|
20916 | handlerSet.add(handler);
|
20917 | return handler;
|
20918 | }
|
20919 | function showMultiImageViewer(props) {
|
20920 | clearImageViewer();
|
20921 | const handler = renderImperatively(React$1.createElement(MultiImageViewer, Object.assign({}, props, {
|
20922 | afterClose: () => {
|
20923 | var _a;
|
20924 | handlerSet.delete(handler);
|
20925 | (_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
20926 | }
|
20927 | })));
|
20928 | handlerSet.add(handler);
|
20929 | return handler;
|
20930 | }
|
20931 | function clearImageViewer() {
|
20932 | handlerSet.forEach((handler) => {
|
20933 | handler.close();
|
20934 | });
|
20935 | handlerSet.clear();
|
20936 | }
|
20937 | const Multi = attachPropertiesToComponent(MultiImageViewer, {
|
20938 | show: showMultiImageViewer
|
20939 | });
|
20940 | const ImageViewer = attachPropertiesToComponent(ImageViewer$1, {
|
20941 | Multi,
|
20942 | show: showImageViewer,
|
20943 | clear: clearImageViewer
|
20944 | });
|
20945 | const classPrefix$G = `adm-image-uploader`;
|
20946 | const PreviewItem = (props) => {
|
20947 | const {
|
20948 | locale
|
20949 | } = useConfig();
|
20950 | const {
|
20951 | url,
|
20952 | file,
|
20953 | deletable,
|
20954 | deleteIcon,
|
20955 | onDelete,
|
20956 | imageFit
|
20957 | } = props;
|
20958 | const src = React$1.useMemo(() => {
|
20959 | if (url) {
|
20960 | return url;
|
20961 | }
|
20962 | if (file) {
|
20963 | return URL.createObjectURL(file);
|
20964 | }
|
20965 | return "";
|
20966 | }, [url, file]);
|
20967 | React$1.useEffect(() => {
|
20968 | return () => {
|
20969 | if (file)
|
20970 | URL.revokeObjectURL(src);
|
20971 | };
|
20972 | }, [src, file]);
|
20973 | function renderLoading() {
|
20974 | return props.status === "pending" && React$1.createElement("div", {
|
20975 | className: `${classPrefix$G}-cell-mask`
|
20976 | }, React$1.createElement("span", {
|
20977 | className: `${classPrefix$G}-cell-loading`
|
20978 | }, React$1.createElement(SpinLoading, {
|
20979 | color: "white"
|
20980 | }), React$1.createElement("span", {
|
20981 | className: `${classPrefix$G}-cell-mask-message`
|
20982 | }, locale.ImageUploader.uploading)));
|
20983 | }
|
20984 | function renderDelete() {
|
20985 | return deletable && React$1.createElement("span", {
|
20986 | className: `${classPrefix$G}-cell-delete`,
|
20987 | onClick: onDelete
|
20988 | }, deleteIcon);
|
20989 | }
|
20990 | return React$1.createElement("div", {
|
20991 | className: classNames(`${classPrefix$G}-cell`, props.status === "fail" && `${classPrefix$G}-cell-fail`)
|
20992 | }, React$1.createElement(Image$1, {
|
20993 | className: `${classPrefix$G}-cell-image`,
|
20994 | src,
|
20995 | fit: imageFit,
|
20996 | onClick: props.onClick
|
20997 | }), renderLoading(), renderDelete());
|
20998 | };
|
20999 | const PreviewItem$1 = PreviewItem;
|
21000 | const classPrefix$F = `adm-space`;
|
21001 | const defaultProps$y = {
|
21002 | direction: "horizontal"
|
21003 | };
|
21004 | const Space = (p) => {
|
21005 | const props = mergeProps(defaultProps$y, p);
|
21006 | const {
|
21007 | direction,
|
21008 | onClick
|
21009 | } = props;
|
21010 | return withNativeProps(props, React$1.createElement("div", {
|
21011 | className: classNames(classPrefix$F, {
|
21012 | [`${classPrefix$F}-wrap`]: props.wrap,
|
21013 | [`${classPrefix$F}-block`]: props.block,
|
21014 | [`${classPrefix$F}-${direction}`]: true,
|
21015 | [`${classPrefix$F}-align-${props.align}`]: !!props.align,
|
21016 | [`${classPrefix$F}-justify-${props.justify}`]: !!props.justify
|
21017 | }),
|
21018 | onClick
|
21019 | }, React$1.Children.map(props.children, (child) => {
|
21020 | return child !== null && child !== void 0 && React$1.createElement("div", {
|
21021 | className: `${classPrefix$F}-item`
|
21022 | }, child);
|
21023 | })));
|
21024 | };
|
21025 | const classPrefix$E = `adm-image-uploader`;
|
21026 | const defaultProps$x = {
|
21027 | disableUpload: false,
|
21028 | deletable: true,
|
21029 | deleteIcon: React$1.createElement(CloseOutline, {
|
21030 | className: `${classPrefix$E}-cell-delete-icon`
|
21031 | }),
|
21032 | showUpload: true,
|
21033 | multiple: false,
|
21034 | maxCount: 0,
|
21035 | defaultValue: [],
|
21036 | accept: "image/*",
|
21037 | preview: true,
|
21038 | showFailed: true,
|
21039 | imageFit: "cover"
|
21040 | };
|
21041 | const ImageUploader = React$1.forwardRef((p, ref) => {
|
21042 | const {
|
21043 | locale
|
21044 | } = useConfig();
|
21045 | const props = mergeProps(defaultProps$x, p);
|
21046 | const {
|
21047 | columns
|
21048 | } = props;
|
21049 | const [value, setValue2] = usePropsValue(props);
|
21050 | const [tasks, setTasks] = React$1.useState([]);
|
21051 | const containerRef = React$1.useRef(null);
|
21052 | const containerSize = useSize(containerRef);
|
21053 | const gapMeasureRef = React$1.useRef(null);
|
21054 | const [cellSize, setCellSize] = React$1.useState(80);
|
21055 | const inputRef = React$1.useRef(null);
|
21056 | useIsomorphicLayoutEffect$2(() => {
|
21057 | const gapMeasure = gapMeasureRef.current;
|
21058 | if (columns && containerSize && gapMeasure) {
|
21059 | const width = containerSize.width;
|
21060 | const gap = measureCSSLength(window.getComputedStyle(gapMeasure).getPropertyValue("height"));
|
21061 | setCellSize((width - gap * (columns - 1)) / columns);
|
21062 | }
|
21063 | }, [containerSize === null || containerSize === void 0 ? void 0 : containerSize.width]);
|
21064 | const style = {
|
21065 | "--cell-size": cellSize + "px"
|
21066 | };
|
21067 | useIsomorphicLayoutEffect$2(() => {
|
21068 | setTasks((prev) => prev.filter((task) => {
|
21069 | if (task.url === void 0)
|
21070 | return true;
|
21071 | return !value.some((fileItem) => fileItem.url === task.url);
|
21072 | }));
|
21073 | }, [value]);
|
21074 | useIsomorphicLayoutEffect$2(() => {
|
21075 | var _a;
|
21076 | (_a = props.onUploadQueueChange) === null || _a === void 0 ? void 0 : _a.call(props, tasks.map((item) => ({
|
21077 | id: item.id,
|
21078 | status: item.status
|
21079 | })));
|
21080 | }, [tasks]);
|
21081 | const idCountRef = React$1.useRef(0);
|
21082 | const {
|
21083 | maxCount,
|
21084 | onPreview,
|
21085 | renderItem
|
21086 | } = props;
|
21087 | function processFile(file, fileList) {
|
21088 | return __awaiter(this, void 0, void 0, function* () {
|
21089 | const {
|
21090 | beforeUpload
|
21091 | } = props;
|
21092 | let transformedFile = file;
|
21093 | transformedFile = yield beforeUpload === null || beforeUpload === void 0 ? void 0 : beforeUpload(file, fileList);
|
21094 | return transformedFile;
|
21095 | });
|
21096 | }
|
21097 | function getFinalTasks(tasks2) {
|
21098 | return props.showFailed ? tasks2 : tasks2.filter((task) => task.status !== "fail");
|
21099 | }
|
21100 | function onChange(e2) {
|
21101 | var _a;
|
21102 | return __awaiter(this, void 0, void 0, function* () {
|
21103 | e2.persist();
|
21104 | const {
|
21105 | files: rawFiles
|
21106 | } = e2.target;
|
21107 | if (!rawFiles)
|
21108 | return;
|
21109 | let files = [].slice.call(rawFiles);
|
21110 | e2.target.value = "";
|
21111 | if (props.beforeUpload) {
|
21112 | const postFiles = files.map((file) => processFile(file, files));
|
21113 | yield Promise.all(postFiles).then((filesList) => {
|
21114 | files = filesList.filter(Boolean);
|
21115 | });
|
21116 | }
|
21117 | if (files.length === 0) {
|
21118 | return;
|
21119 | }
|
21120 | if (maxCount > 0) {
|
21121 | const exceed = value.length + files.length - maxCount;
|
21122 | if (exceed > 0) {
|
21123 | files = files.slice(0, files.length - exceed);
|
21124 | (_a = props.onCountExceed) === null || _a === void 0 ? void 0 : _a.call(props, exceed);
|
21125 | }
|
21126 | }
|
21127 | const newTasks = files.map((file) => ({
|
21128 | id: idCountRef.current++,
|
21129 | status: "pending",
|
21130 | file
|
21131 | }));
|
21132 | setTasks((prev) => [...getFinalTasks(prev), ...newTasks]);
|
21133 | const newVal = [];
|
21134 | yield Promise.all(newTasks.map((currentTask, index2) => __awaiter(this, void 0, void 0, function* () {
|
21135 | try {
|
21136 | const result = yield props.upload(currentTask.file);
|
21137 | newVal[index2] = result;
|
21138 | setTasks((prev) => {
|
21139 | return prev.map((task) => {
|
21140 | if (task.id === currentTask.id) {
|
21141 | return Object.assign(Object.assign({}, task), {
|
21142 | status: "success",
|
21143 | url: result.url
|
21144 | });
|
21145 | }
|
21146 | return task;
|
21147 | });
|
21148 | });
|
21149 | } catch (e3) {
|
21150 | setTasks((prev) => {
|
21151 | return prev.map((task) => {
|
21152 | if (task.id === currentTask.id) {
|
21153 | return Object.assign(Object.assign({}, task), {
|
21154 | status: "fail"
|
21155 | });
|
21156 | }
|
21157 | return task;
|
21158 | });
|
21159 | });
|
21160 | throw e3;
|
21161 | }
|
21162 | }))).catch((error) => console.error(error));
|
21163 | setValue2((prev) => prev.concat(newVal));
|
21164 | });
|
21165 | }
|
21166 | const imageViewerHandlerRef = React$1.useRef(null);
|
21167 | function previewImage(index2) {
|
21168 | imageViewerHandlerRef.current = ImageViewer.Multi.show({
|
21169 | images: value.map((fileItem) => fileItem.url),
|
21170 | defaultIndex: index2,
|
21171 | onClose: () => {
|
21172 | imageViewerHandlerRef.current = null;
|
21173 | }
|
21174 | });
|
21175 | }
|
21176 | useUnmount$1(() => {
|
21177 | var _a;
|
21178 | (_a = imageViewerHandlerRef.current) === null || _a === void 0 ? void 0 : _a.close();
|
21179 | });
|
21180 | const finalTasks = getFinalTasks(tasks);
|
21181 | const showUpload = props.showUpload && (maxCount === 0 || value.length + finalTasks.length < maxCount);
|
21182 | const renderImages = () => {
|
21183 | return value.map((fileItem, index2) => {
|
21184 | var _a, _b;
|
21185 | const originNode = React$1.createElement(PreviewItem$1, {
|
21186 | key: (_a = fileItem.key) !== null && _a !== void 0 ? _a : index2,
|
21187 | url: (_b = fileItem.thumbnailUrl) !== null && _b !== void 0 ? _b : fileItem.url,
|
21188 | deletable: props.deletable,
|
21189 | deleteIcon: props.deleteIcon,
|
21190 | imageFit: props.imageFit,
|
21191 | onClick: () => {
|
21192 | if (props.preview) {
|
21193 | previewImage(index2);
|
21194 | }
|
21195 | onPreview && onPreview(index2, fileItem);
|
21196 | },
|
21197 | onDelete: () => __awaiter(void 0, void 0, void 0, function* () {
|
21198 | var _c;
|
21199 | const canDelete = yield (_c = props.onDelete) === null || _c === void 0 ? void 0 : _c.call(props, fileItem);
|
21200 | if (canDelete === false)
|
21201 | return;
|
21202 | setValue2(value.filter((x, i2) => i2 !== index2));
|
21203 | })
|
21204 | });
|
21205 | return renderItem ? renderItem(originNode, fileItem, value) : originNode;
|
21206 | });
|
21207 | };
|
21208 | const contentNode = React$1.createElement(React$1.Fragment, null, renderImages(), tasks.map((task) => {
|
21209 | if (!props.showFailed && task.status === "fail") {
|
21210 | return null;
|
21211 | }
|
21212 | return React$1.createElement(PreviewItem$1, {
|
21213 | key: task.id,
|
21214 | file: task.file,
|
21215 | deletable: task.status !== "pending",
|
21216 | deleteIcon: props.deleteIcon,
|
21217 | status: task.status,
|
21218 | imageFit: props.imageFit,
|
21219 | onDelete: () => {
|
21220 | setTasks(tasks.filter((x) => x.id !== task.id));
|
21221 | }
|
21222 | });
|
21223 | }), React$1.createElement("div", {
|
21224 | className: `${classPrefix$E}-upload-button-wrap`,
|
21225 | style: showUpload ? void 0 : {
|
21226 | display: "none"
|
21227 | }
|
21228 | }, props.children || React$1.createElement("span", {
|
21229 | className: `${classPrefix$E}-cell ${classPrefix$E}-upload-button`,
|
21230 | role: "button",
|
21231 | "aria-label": locale.ImageUploader.upload
|
21232 | }, React$1.createElement("span", {
|
21233 | className: `${classPrefix$E}-upload-button-icon`
|
21234 | }, React$1.createElement(AddOutline, null))), !props.disableUpload && React$1.createElement("input", {
|
21235 | ref: inputRef,
|
21236 | capture: props.capture,
|
21237 | accept: props.accept,
|
21238 | multiple: props.multiple,
|
21239 | type: "file",
|
21240 | className: `${classPrefix$E}-input`,
|
21241 | onChange,
|
21242 | "aria-hidden": true
|
21243 | })));
|
21244 | React$1.useImperativeHandle(ref, () => ({
|
21245 | get nativeElement() {
|
21246 | return inputRef.current;
|
21247 | }
|
21248 | }));
|
21249 | return withNativeProps(props, React$1.createElement("div", {
|
21250 | className: classPrefix$E,
|
21251 | ref: containerRef
|
21252 | }, columns ? React$1.createElement(Grid, {
|
21253 | className: `${classPrefix$E}-grid`,
|
21254 | columns,
|
21255 | style
|
21256 | }, React$1.createElement("div", {
|
21257 | className: `${classPrefix$E}-gap-measure`,
|
21258 | ref: gapMeasureRef
|
21259 | }), contentNode.props.children) : React$1.createElement(Space, {
|
21260 | className: `${classPrefix$E}-space`,
|
21261 | wrap: true,
|
21262 | block: true
|
21263 | }, contentNode.props.children)));
|
21264 | });
|
21265 | const Panel = () => null;
|
21266 | const classPrefix$D = `adm-index-bar`;
|
21267 | const Sidebar = (props) => {
|
21268 | const [interacting, setInteracting] = React$1.useState(false);
|
21269 | return React$1.createElement("div", {
|
21270 | className: classNames(`${classPrefix$D}-sidebar`, {
|
21271 | [`${classPrefix$D}-sidebar-interacting`]: interacting
|
21272 | }),
|
21273 | onMouseDown: () => {
|
21274 | setInteracting(true);
|
21275 | },
|
21276 | onMouseUp: () => {
|
21277 | setInteracting(false);
|
21278 | },
|
21279 | onTouchStart: () => {
|
21280 | setInteracting(true);
|
21281 | },
|
21282 | onTouchEnd: () => {
|
21283 | setInteracting(false);
|
21284 | },
|
21285 | onTouchMove: (e2) => {
|
21286 | if (!interacting)
|
21287 | return;
|
21288 | const {
|
21289 | clientX,
|
21290 | clientY
|
21291 | } = e2.touches[0];
|
21292 | const target = document.elementFromPoint(clientX, clientY);
|
21293 | if (!target)
|
21294 | return;
|
21295 | const index2 = target.dataset["index"];
|
21296 | if (index2) {
|
21297 | props.onActive(index2);
|
21298 | }
|
21299 | }
|
21300 | }, props.indexItems.map(({
|
21301 | index: index2,
|
21302 | brief
|
21303 | }) => {
|
21304 | const active = index2 === props.activeIndex;
|
21305 | return React$1.createElement("div", {
|
21306 | className: `${classPrefix$D}-sidebar-row`,
|
21307 | onMouseDown: () => {
|
21308 | props.onActive(index2);
|
21309 | },
|
21310 | onTouchStart: () => {
|
21311 | props.onActive(index2);
|
21312 | },
|
21313 | onMouseEnter: () => {
|
21314 | if (interacting) {
|
21315 | props.onActive(index2);
|
21316 | }
|
21317 | },
|
21318 | "data-index": index2,
|
21319 | key: index2
|
21320 | }, interacting && active && React$1.createElement("div", {
|
21321 | className: `${classPrefix$D}-sidebar-bubble`
|
21322 | }, brief), React$1.createElement("div", {
|
21323 | className: classNames(`${classPrefix$D}-sidebar-item`, {
|
21324 | [`${classPrefix$D}-sidebar-item-active`]: active
|
21325 | }),
|
21326 | "data-index": index2
|
21327 | }, React$1.createElement("div", null, brief)));
|
21328 | }));
|
21329 | };
|
21330 | const classPrefix$C = `adm-index-bar`;
|
21331 | const defaultProps$w = {
|
21332 | sticky: true
|
21333 | };
|
21334 | const IndexBar = React$1.forwardRef((p, ref) => {
|
21335 | const props = mergeProps(defaultProps$w, p);
|
21336 | const titleHeight = convertPx(35);
|
21337 | const bodyRef = React$1.useRef(null);
|
21338 | const indexItems = [];
|
21339 | const panels = [];
|
21340 | traverseReactNode(props.children, (child) => {
|
21341 | var _a;
|
21342 | if (!React$1.isValidElement(child))
|
21343 | return;
|
21344 | if (child.type !== Panel) {
|
21345 | devWarning("IndexBar", "The children of `IndexBar` must be `IndexBar.Panel` components.");
|
21346 | return;
|
21347 | }
|
21348 | indexItems.push({
|
21349 | index: child.props.index,
|
21350 | brief: (_a = child.props.brief) !== null && _a !== void 0 ? _a : child.props.index.charAt(0)
|
21351 | });
|
21352 | panels.push(withNativeProps(child.props, React$1.createElement("div", {
|
21353 | key: child.props.index,
|
21354 | "data-index": child.props.index,
|
21355 | className: `${classPrefix$C}-anchor`
|
21356 | }, React$1.createElement("div", {
|
21357 | className: `${classPrefix$C}-anchor-title`
|
21358 | }, child.props.title || child.props.index), child.props.children)));
|
21359 | });
|
21360 | const [activeIndex, setActiveIndex] = React$1.useState(() => {
|
21361 | const firstItem = indexItems[0];
|
21362 | return firstItem ? firstItem.index : null;
|
21363 | });
|
21364 | React$1.useImperativeHandle(ref, () => ({
|
21365 | scrollTo
|
21366 | }));
|
21367 | function scrollTo(index2) {
|
21368 | var _a;
|
21369 | const body = bodyRef.current;
|
21370 | if (!body)
|
21371 | return;
|
21372 | const children = body.children;
|
21373 | for (let i2 = 0; i2 < children.length; i2++) {
|
21374 | const panel = children.item(i2);
|
21375 | if (!panel)
|
21376 | continue;
|
21377 | const panelIndex = panel.dataset["index"];
|
21378 | if (panelIndex === index2) {
|
21379 | body.scrollTop = panel.offsetTop;
|
21380 | setActiveIndex(index2);
|
21381 | activeIndex !== index2 && ((_a = props.onIndexChange) === null || _a === void 0 ? void 0 : _a.call(props, index2));
|
21382 | return;
|
21383 | }
|
21384 | }
|
21385 | }
|
21386 | const {
|
21387 | run: checkActiveIndex
|
21388 | } = useThrottleFn(() => {
|
21389 | var _a;
|
21390 | const body = bodyRef.current;
|
21391 | if (!body)
|
21392 | return;
|
21393 | const scrollTop = body.scrollTop;
|
21394 | const elements = body.getElementsByClassName(`${classPrefix$C}-anchor`);
|
21395 | for (let i2 = 0; i2 < elements.length; i2++) {
|
21396 | const panel = elements.item(i2);
|
21397 | if (!panel)
|
21398 | continue;
|
21399 | const panelIndex = panel.dataset["index"];
|
21400 | if (!panelIndex)
|
21401 | continue;
|
21402 | if (panel.offsetTop + panel.clientHeight - titleHeight > scrollTop) {
|
21403 | setActiveIndex(panelIndex);
|
21404 | activeIndex !== panelIndex && ((_a = props.onIndexChange) === null || _a === void 0 ? void 0 : _a.call(props, panelIndex));
|
21405 | return;
|
21406 | }
|
21407 | }
|
21408 | }, {
|
21409 | wait: 50,
|
21410 | trailing: true,
|
21411 | leading: true
|
21412 | });
|
21413 | return withNativeProps(props, React$1.createElement("div", {
|
21414 | className: classNames(`${classPrefix$C}`, {
|
21415 | [`${classPrefix$C}-sticky`]: props.sticky
|
21416 | })
|
21417 | }, React$1.createElement(Sidebar, {
|
21418 | indexItems,
|
21419 | activeIndex,
|
21420 | onActive: (index2) => {
|
21421 | scrollTo(index2);
|
21422 | }
|
21423 | }), React$1.createElement("div", {
|
21424 | className: `${classPrefix$C}-body`,
|
21425 | ref: bodyRef,
|
21426 | onScroll: checkActiveIndex
|
21427 | }, panels)));
|
21428 | });
|
21429 | const index$9 = attachPropertiesToComponent(IndexBar, {
|
21430 | Panel
|
21431 | });
|
21432 | function isWindow(element) {
|
21433 | return element === window;
|
21434 | }
|
21435 | const classPrefix$B = `adm-infinite-scroll`;
|
21436 | const defaultProps$v = {
|
21437 | threshold: 250,
|
21438 | children: (hasMore, failed, retry) => React$1.createElement(InfiniteScrollContent, {
|
21439 | hasMore,
|
21440 | failed,
|
21441 | retry
|
21442 | })
|
21443 | };
|
21444 | const InfiniteScroll = (p) => {
|
21445 | const props = mergeProps(defaultProps$v, p);
|
21446 | const [failed, setFailed] = React$1.useState(false);
|
21447 | const doLoadMore = useLockFn((isRetry) => __awaiter(void 0, void 0, void 0, function* () {
|
21448 | try {
|
21449 | yield props.loadMore(isRetry);
|
21450 | } catch (e2) {
|
21451 | setFailed(true);
|
21452 | throw e2;
|
21453 | }
|
21454 | }));
|
21455 | const elementRef = React$1.useRef(null);
|
21456 | const [flag, setFlag] = React$1.useState({});
|
21457 | const nextFlagRef = React$1.useRef(flag);
|
21458 | const [scrollParent, setScrollParent] = React$1.useState();
|
21459 | const {
|
21460 | run: check
|
21461 | } = useThrottleFn(() => __awaiter(void 0, void 0, void 0, function* () {
|
21462 | if (nextFlagRef.current !== flag)
|
21463 | return;
|
21464 | if (!props.hasMore)
|
21465 | return;
|
21466 | const element = elementRef.current;
|
21467 | if (!element)
|
21468 | return;
|
21469 | if (!element.offsetParent)
|
21470 | return;
|
21471 | const parent = getScrollParent(element);
|
21472 | setScrollParent(parent);
|
21473 | if (!parent)
|
21474 | return;
|
21475 | const rect = element.getBoundingClientRect();
|
21476 | const elementTop = rect.top;
|
21477 | const current = isWindow(parent) ? window.innerHeight : parent.getBoundingClientRect().bottom;
|
21478 | if (current >= elementTop - props.threshold) {
|
21479 | const nextFlag = {};
|
21480 | nextFlagRef.current = nextFlag;
|
21481 | try {
|
21482 | yield doLoadMore(false);
|
21483 | setFlag(nextFlag);
|
21484 | } catch (e2) {
|
21485 | }
|
21486 | }
|
21487 | }), {
|
21488 | wait: 100,
|
21489 | leading: true,
|
21490 | trailing: true
|
21491 | });
|
21492 | React$1.useEffect(() => {
|
21493 | check();
|
21494 | });
|
21495 | React$1.useEffect(() => {
|
21496 | const element = elementRef.current;
|
21497 | if (!element)
|
21498 | return;
|
21499 | if (!scrollParent)
|
21500 | return;
|
21501 | function onScroll() {
|
21502 | check();
|
21503 | }
|
21504 | scrollParent.addEventListener("scroll", onScroll);
|
21505 | return () => {
|
21506 | scrollParent.removeEventListener("scroll", onScroll);
|
21507 | };
|
21508 | }, [scrollParent]);
|
21509 | function retry() {
|
21510 | return __awaiter(this, void 0, void 0, function* () {
|
21511 | setFailed(false);
|
21512 | try {
|
21513 | yield doLoadMore(true);
|
21514 | setFlag(nextFlagRef.current);
|
21515 | } catch (e2) {
|
21516 | }
|
21517 | });
|
21518 | }
|
21519 | return withNativeProps(props, React$1.createElement("div", {
|
21520 | className: classPrefix$B,
|
21521 | ref: elementRef
|
21522 | }, typeof props.children === "function" ? props.children(props.hasMore, failed, retry) : props.children));
|
21523 | };
|
21524 | const InfiniteScrollContent = (props) => {
|
21525 | const {
|
21526 | locale
|
21527 | } = useConfig();
|
21528 | if (!props.hasMore) {
|
21529 | return React$1.createElement("span", null, locale.InfiniteScroll.noMore);
|
21530 | }
|
21531 | if (props.failed) {
|
21532 | return React$1.createElement("span", null, React$1.createElement("span", {
|
21533 | className: `${classPrefix$B}-failed-text`
|
21534 | }, locale.InfiniteScroll.failedToLoad), React$1.createElement("a", {
|
21535 | onClick: () => {
|
21536 | props.retry();
|
21537 | }
|
21538 | }, locale.InfiniteScroll.retry));
|
21539 | }
|
21540 | return React$1.createElement(React$1.Fragment, null, React$1.createElement("span", null, locale.common.loading), React$1.createElement(DotLoading, null));
|
21541 | };
|
21542 | function useInputHandleKeyDown({
|
21543 | onEnterPress,
|
21544 | onKeyDown,
|
21545 | nativeInputRef,
|
21546 | enterKeyHint
|
21547 | }) {
|
21548 | const handleKeydown = (e2) => {
|
21549 | if (onEnterPress && (e2.code === "Enter" || e2.keyCode === 13)) {
|
21550 | onEnterPress(e2);
|
21551 | }
|
21552 | onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e2);
|
21553 | };
|
21554 | useIsomorphicLayoutEffect$2(() => {
|
21555 | const ele = nativeInputRef.current;
|
21556 | if (!enterKeyHint || !ele)
|
21557 | return;
|
21558 | ele.setAttribute("enterkeyhint", enterKeyHint);
|
21559 | return () => {
|
21560 | ele.removeAttribute("enterkeyhint");
|
21561 | };
|
21562 | }, [enterKeyHint]);
|
21563 | return handleKeydown;
|
21564 | }
|
21565 | const classPrefix$A = `adm-input`;
|
21566 | const defaultProps$u = {
|
21567 | defaultValue: "",
|
21568 | clearIcon: React$1.createElement(CloseCircleFill, null),
|
21569 | onlyShowClearWhenFocus: true
|
21570 | };
|
21571 | const Input = React$1.forwardRef((props, ref) => {
|
21572 | const {
|
21573 | locale,
|
21574 | input: componentConfig = {}
|
21575 | } = useConfig();
|
21576 | const mergedProps = mergeProps(defaultProps$u, componentConfig, props);
|
21577 | const [value, setValue2] = usePropsValue(mergedProps);
|
21578 | const [hasFocus, setHasFocus] = React$1.useState(false);
|
21579 | const compositionStartRef = React$1.useRef(false);
|
21580 | const nativeInputRef = React$1.useRef(null);
|
21581 | const handleKeydown = useInputHandleKeyDown({
|
21582 | onEnterPress: mergedProps.onEnterPress,
|
21583 | onKeyDown: mergedProps.onKeyDown,
|
21584 | nativeInputRef,
|
21585 | enterKeyHint: mergedProps.enterKeyHint
|
21586 | });
|
21587 | React$1.useImperativeHandle(ref, () => ({
|
21588 | clear: () => {
|
21589 | setValue2("");
|
21590 | },
|
21591 | focus: () => {
|
21592 | var _a;
|
21593 | (_a = nativeInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
21594 | },
|
21595 | blur: () => {
|
21596 | var _a;
|
21597 | (_a = nativeInputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
21598 | },
|
21599 | get nativeElement() {
|
21600 | return nativeInputRef.current;
|
21601 | }
|
21602 | }));
|
21603 | function checkValue() {
|
21604 | let nextValue = value;
|
21605 | if (mergedProps.type === "number") {
|
21606 | const boundValue = nextValue && bound(parseFloat(nextValue), mergedProps.min, mergedProps.max).toString();
|
21607 | if (Number(nextValue) !== Number(boundValue)) {
|
21608 | nextValue = boundValue;
|
21609 | }
|
21610 | }
|
21611 | if (nextValue !== value) {
|
21612 | setValue2(nextValue);
|
21613 | }
|
21614 | }
|
21615 | const shouldShowClear = (() => {
|
21616 | if (!mergedProps.clearable || !value || mergedProps.readOnly)
|
21617 | return false;
|
21618 | if (mergedProps.onlyShowClearWhenFocus) {
|
21619 | return hasFocus;
|
21620 | } else {
|
21621 | return true;
|
21622 | }
|
21623 | })();
|
21624 | return withNativeProps(mergedProps, React$1.createElement("div", {
|
21625 | className: classNames(`${classPrefix$A}`, mergedProps.disabled && `${classPrefix$A}-disabled`)
|
21626 | }, React$1.createElement("input", {
|
21627 | ref: nativeInputRef,
|
21628 | className: `${classPrefix$A}-element`,
|
21629 | value,
|
21630 | onChange: (e2) => {
|
21631 | setValue2(e2.target.value);
|
21632 | },
|
21633 | onFocus: (e2) => {
|
21634 | var _a;
|
21635 | setHasFocus(true);
|
21636 | (_a = mergedProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e2);
|
21637 | },
|
21638 | onBlur: (e2) => {
|
21639 | var _a;
|
21640 | setHasFocus(false);
|
21641 | checkValue();
|
21642 | (_a = mergedProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e2);
|
21643 | },
|
21644 | id: mergedProps.id,
|
21645 | placeholder: mergedProps.placeholder,
|
21646 | disabled: mergedProps.disabled,
|
21647 | readOnly: mergedProps.readOnly,
|
21648 | maxLength: mergedProps.maxLength,
|
21649 | minLength: mergedProps.minLength,
|
21650 | max: mergedProps.max,
|
21651 | min: mergedProps.min,
|
21652 | autoComplete: mergedProps.autoComplete,
|
21653 | enterKeyHint: mergedProps.enterKeyHint,
|
21654 | autoFocus: mergedProps.autoFocus,
|
21655 | pattern: mergedProps.pattern,
|
21656 | inputMode: mergedProps.inputMode,
|
21657 | type: mergedProps.type,
|
21658 | name: mergedProps.name,
|
21659 | autoCapitalize: mergedProps.autoCapitalize,
|
21660 | autoCorrect: mergedProps.autoCorrect,
|
21661 | onKeyDown: handleKeydown,
|
21662 | onKeyUp: mergedProps.onKeyUp,
|
21663 | onCompositionStart: (e2) => {
|
21664 | var _a;
|
21665 | compositionStartRef.current = true;
|
21666 | (_a = mergedProps.onCompositionStart) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e2);
|
21667 | },
|
21668 | onCompositionEnd: (e2) => {
|
21669 | var _a;
|
21670 | compositionStartRef.current = false;
|
21671 | (_a = mergedProps.onCompositionEnd) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e2);
|
21672 | },
|
21673 | onClick: mergedProps.onClick,
|
21674 | step: mergedProps.step,
|
21675 | role: mergedProps.role,
|
21676 | "aria-valuenow": mergedProps["aria-valuenow"],
|
21677 | "aria-valuemax": mergedProps["aria-valuemax"],
|
21678 | "aria-valuemin": mergedProps["aria-valuemin"],
|
21679 | "aria-label": mergedProps["aria-label"]
|
21680 | }), shouldShowClear && React$1.createElement("div", {
|
21681 | className: `${classPrefix$A}-clear`,
|
21682 | onMouseDown: (e2) => {
|
21683 | e2.preventDefault();
|
21684 | },
|
21685 | onClick: () => {
|
21686 | var _a, _b;
|
21687 | setValue2("");
|
21688 | (_a = mergedProps.onClear) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
|
21689 | if (isIOS() && compositionStartRef.current) {
|
21690 | compositionStartRef.current = false;
|
21691 | (_b = nativeInputRef.current) === null || _b === void 0 ? void 0 : _b.blur();
|
21692 | }
|
21693 | },
|
21694 | "aria-label": locale.Input.clear
|
21695 | }, mergedProps.clearIcon)));
|
21696 | });
|
21697 | const classPrefix$z = `adm-jumbo-tabs`;
|
21698 | const JumboTab = () => {
|
21699 | return null;
|
21700 | };
|
21701 | const JumboTabs = (props) => {
|
21702 | var _a;
|
21703 | const tabListContainerRef = React$1.useRef(null);
|
21704 | const rootRef = React$1.useRef(null);
|
21705 | const keyToIndexRecord = {};
|
21706 | let firstActiveKey = null;
|
21707 | const panes = [];
|
21708 | traverseReactNode(props.children, (child, index2) => {
|
21709 | if (!React$1.isValidElement(child))
|
21710 | return;
|
21711 | const key = child.key;
|
21712 | if (typeof key !== "string")
|
21713 | return;
|
21714 | if (index2 === 0) {
|
21715 | firstActiveKey = key;
|
21716 | }
|
21717 | const length = panes.push(child);
|
21718 | keyToIndexRecord[key] = length - 1;
|
21719 | });
|
21720 | const [activeKey, setActiveKey] = usePropsValue({
|
21721 | value: props.activeKey,
|
21722 | defaultValue: (_a = props.defaultActiveKey) !== null && _a !== void 0 ? _a : firstActiveKey,
|
21723 | onChange: (v) => {
|
21724 | var _a2;
|
21725 | if (v === null)
|
21726 | return;
|
21727 | (_a2 = props.onChange) === null || _a2 === void 0 ? void 0 : _a2.call(props, v);
|
21728 | }
|
21729 | });
|
21730 | const {
|
21731 | scrollLeft,
|
21732 | animate
|
21733 | } = useTabListScroll(tabListContainerRef, keyToIndexRecord[activeKey]);
|
21734 | useResizeEffect(() => {
|
21735 | animate(true);
|
21736 | }, rootRef);
|
21737 | return withNativeProps(props, React$1.createElement("div", {
|
21738 | className: classPrefix$z,
|
21739 | ref: rootRef
|
21740 | }, React$1.createElement("div", {
|
21741 | className: `${classPrefix$z}-header`
|
21742 | }, React$1.createElement(ScrollMask, {
|
21743 | scrollTrackRef: tabListContainerRef
|
21744 | }), React$1.createElement(animated.div, {
|
21745 | className: `${classPrefix$z}-tab-list`,
|
21746 | ref: tabListContainerRef,
|
21747 | scrollLeft
|
21748 | }, panes.map((pane) => withNativeProps(pane.props, React$1.createElement("div", {
|
21749 | key: pane.key,
|
21750 | className: `${classPrefix$z}-tab-wrapper`
|
21751 | }, React$1.createElement("div", {
|
21752 | onClick: () => {
|
21753 | const {
|
21754 | key
|
21755 | } = pane;
|
21756 | if (pane.props.disabled)
|
21757 | return;
|
21758 | if (key === void 0 || key === null) {
|
21759 | return;
|
21760 | }
|
21761 | setActiveKey(key.toString());
|
21762 | },
|
21763 | className: classNames(`${classPrefix$z}-tab`, {
|
21764 | [`${classPrefix$z}-tab-active`]: pane.key === activeKey,
|
21765 | [`${classPrefix$z}-tab-disabled`]: pane.props.disabled
|
21766 | })
|
21767 | }, React$1.createElement("div", {
|
21768 | className: `${classPrefix$z}-tab-title`
|
21769 | }, pane.props.title), React$1.createElement("div", {
|
21770 | className: `${classPrefix$z}-tab-description`
|
21771 | }, pane.props.description))))))), panes.map((pane) => {
|
21772 | if (pane.props.children === void 0) {
|
21773 | return null;
|
21774 | }
|
21775 | const active = pane.key === activeKey;
|
21776 | return React$1.createElement(ShouldRender, {
|
21777 | key: pane.key,
|
21778 | active,
|
21779 | forceRender: pane.props.forceRender,
|
21780 | destroyOnClose: pane.props.destroyOnClose
|
21781 | }, React$1.createElement("div", {
|
21782 | className: `${classPrefix$z}-content`,
|
21783 | style: {
|
21784 | display: active ? "block" : "none"
|
21785 | }
|
21786 | }, pane.props.children));
|
21787 | })));
|
21788 | };
|
21789 | const index$8 = attachPropertiesToComponent(JumboTabs, {
|
21790 | Tab: JumboTab
|
21791 | });
|
21792 | const ModalActionButton = (props) => {
|
21793 | const {
|
21794 | action
|
21795 | } = props;
|
21796 | return withNativeProps(props.action, React$1.createElement(Button, {
|
21797 | key: action.key,
|
21798 | onClick: props.onAction,
|
21799 | className: classNames("adm-modal-button", {
|
21800 | "adm-modal-button-primary": props.action.primary
|
21801 | }),
|
21802 | fill: props.action.primary ? "solid" : "none",
|
21803 | size: props.action.primary ? "large" : "middle",
|
21804 | block: true,
|
21805 | color: action.danger ? "danger" : "primary",
|
21806 | loading: "auto",
|
21807 | disabled: action.disabled
|
21808 | }, action.text));
|
21809 | };
|
21810 | const defaultProps$t = {
|
21811 | actions: [],
|
21812 | closeOnAction: false,
|
21813 | closeOnMaskClick: false,
|
21814 | getContainer: null
|
21815 | };
|
21816 | const Modal = (p) => {
|
21817 | const props = mergeProps(defaultProps$t, p);
|
21818 | const element = React$1.createElement(React$1.Fragment, null, !!props.image && React$1.createElement("div", {
|
21819 | className: cls("image-container")
|
21820 | }, React$1.createElement(Image$1, {
|
21821 | src: props.image,
|
21822 | alt: "modal header image",
|
21823 | width: "100%"
|
21824 | })), !!props.header && React$1.createElement("div", {
|
21825 | className: cls("header")
|
21826 | }, React$1.createElement(AutoCenter, null, props.header)), !!props.title && React$1.createElement("div", {
|
21827 | className: cls("title")
|
21828 | }, props.title), React$1.createElement("div", {
|
21829 | className: cls("content")
|
21830 | }, typeof props.content === "string" ? React$1.createElement(AutoCenter, null, props.content) : props.content), React$1.createElement(Space, {
|
21831 | direction: "vertical",
|
21832 | block: true,
|
21833 | className: classNames(cls("footer"), props.actions.length === 0 && cls("footer-empty"))
|
21834 | }, props.actions.map((action, index2) => React$1.createElement(ModalActionButton, {
|
21835 | key: action.key,
|
21836 | action,
|
21837 | onAction: () => __awaiter(void 0, void 0, void 0, function* () {
|
21838 | var _a, _b, _c;
|
21839 | yield Promise.all([(_a = action.onClick) === null || _a === void 0 ? void 0 : _a.call(action), (_b = props.onAction) === null || _b === void 0 ? void 0 : _b.call(props, action, index2)]);
|
21840 | if (props.closeOnAction) {
|
21841 | (_c = props.onClose) === null || _c === void 0 ? void 0 : _c.call(props);
|
21842 | }
|
21843 | })
|
21844 | }))));
|
21845 | return React$1.createElement(CenterPopup, {
|
21846 | className: classNames(cls(), props.className),
|
21847 | style: props.style,
|
21848 | afterClose: props.afterClose,
|
21849 | afterShow: props.afterShow,
|
21850 | showCloseButton: props.showCloseButton,
|
21851 | closeOnMaskClick: props.closeOnMaskClick,
|
21852 | onClose: props.onClose,
|
21853 | visible: props.visible,
|
21854 | getContainer: props.getContainer,
|
21855 | bodyStyle: props.bodyStyle,
|
21856 | bodyClassName: classNames(cls("body"), props.image && cls("with-image"), props.bodyClassName),
|
21857 | maskStyle: props.maskStyle,
|
21858 | maskClassName: props.maskClassName,
|
21859 | stopPropagation: props.stopPropagation,
|
21860 | disableBodyScroll: props.disableBodyScroll,
|
21861 | destroyOnClose: props.destroyOnClose,
|
21862 | forceRender: props.forceRender
|
21863 | }, element);
|
21864 | };
|
21865 | function cls(name = "") {
|
21866 | return "adm-modal" + (name && "-") + name;
|
21867 | }
|
21868 | const closeFnSet = new Set();
|
21869 | function show$1(props) {
|
21870 | const handler = renderImperatively(React$1.createElement(Modal, Object.assign({}, props, {
|
21871 | afterClose: () => {
|
21872 | var _a;
|
21873 | closeFnSet.delete(handler.close);
|
21874 | (_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
21875 | }
|
21876 | })));
|
21877 | closeFnSet.add(handler.close);
|
21878 | return handler;
|
21879 | }
|
21880 | function alert(p) {
|
21881 | const defaultProps2 = {
|
21882 | confirmText: getDefaultConfig().locale.Modal.ok
|
21883 | };
|
21884 | const props = mergeProps(defaultProps2, p);
|
21885 | return new Promise((resolve) => {
|
21886 | show$1(Object.assign(Object.assign({}, props), {
|
21887 | closeOnAction: true,
|
21888 | actions: [{
|
21889 | key: "confirm",
|
21890 | text: props.confirmText,
|
21891 | primary: true
|
21892 | }],
|
21893 | onAction: props.onConfirm,
|
21894 | onClose: () => {
|
21895 | var _a;
|
21896 | (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
21897 | resolve();
|
21898 | }
|
21899 | }));
|
21900 | });
|
21901 | }
|
21902 | const defaultProps$s = {
|
21903 | confirmText: "确认",
|
21904 | cancelText: "取消"
|
21905 | };
|
21906 | function confirm(p) {
|
21907 | const {
|
21908 | locale
|
21909 | } = getDefaultConfig();
|
21910 | const props = mergeProps(defaultProps$s, {
|
21911 | confirmText: locale.common.confirm,
|
21912 | cancelText: locale.common.cancel
|
21913 | }, p);
|
21914 | return new Promise((resolve) => {
|
21915 | show$1(Object.assign(Object.assign({}, props), {
|
21916 | closeOnAction: true,
|
21917 | onClose: () => {
|
21918 | var _a;
|
21919 | (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
21920 | resolve(false);
|
21921 | },
|
21922 | actions: [{
|
21923 | key: "confirm",
|
21924 | text: props.confirmText,
|
21925 | primary: true,
|
21926 | onClick: () => __awaiter(this, void 0, void 0, function* () {
|
21927 | var _a;
|
21928 | yield (_a = props.onConfirm) === null || _a === void 0 ? void 0 : _a.call(props);
|
21929 | resolve(true);
|
21930 | })
|
21931 | }, {
|
21932 | key: "cancel",
|
21933 | text: props.cancelText,
|
21934 | onClick: () => __awaiter(this, void 0, void 0, function* () {
|
21935 | var _b;
|
21936 | yield (_b = props.onCancel) === null || _b === void 0 ? void 0 : _b.call(props);
|
21937 | resolve(false);
|
21938 | })
|
21939 | }]
|
21940 | }));
|
21941 | });
|
21942 | }
|
21943 | function clear$1() {
|
21944 | closeFnSet.forEach((close) => {
|
21945 | close();
|
21946 | });
|
21947 | }
|
21948 | const index$7 = attachPropertiesToComponent(Modal, {
|
21949 | show: show$1,
|
21950 | alert,
|
21951 | confirm,
|
21952 | clear: clear$1
|
21953 | });
|
21954 | const classPrefix$y = `adm-nav-bar`;
|
21955 | const defaultBackIcon = React$1.createElement(LeftOutline, null);
|
21956 | const NavBar = (props) => {
|
21957 | const {
|
21958 | navBar: componentConfig = {}
|
21959 | } = useConfig();
|
21960 | const mergedProps = mergeProps(componentConfig, props);
|
21961 | const {
|
21962 | back,
|
21963 | backIcon,
|
21964 | backArrow
|
21965 | } = mergedProps;
|
21966 | const mergedDefaultBackIcon = componentConfig.backIcon || defaultBackIcon;
|
21967 | const mergedBackIcon = mergeProp(defaultBackIcon, componentConfig.backIcon, backArrow === true ? mergedDefaultBackIcon : backArrow, backIcon === true ? mergedDefaultBackIcon : backIcon);
|
21968 | return withNativeProps(mergedProps, React$1.createElement("div", {
|
21969 | className: classNames(classPrefix$y)
|
21970 | }, React$1.createElement("div", {
|
21971 | className: `${classPrefix$y}-left`,
|
21972 | role: "button"
|
21973 | }, back !== null && React$1.createElement("div", {
|
21974 | className: `${classPrefix$y}-back`,
|
21975 | onClick: mergedProps.onBack
|
21976 | }, mergedBackIcon && React$1.createElement("span", {
|
21977 | className: `${classPrefix$y}-back-arrow`
|
21978 | }, mergedBackIcon), React$1.createElement("span", {
|
21979 | "aria-hidden": "true"
|
21980 | }, back)), mergedProps.left), React$1.createElement("div", {
|
21981 | className: `${classPrefix$y}-title`
|
21982 | }, mergedProps.children), React$1.createElement("div", {
|
21983 | className: `${classPrefix$y}-right`
|
21984 | }, mergedProps.right)));
|
21985 | };
|
21986 | const classPrefix$x = `adm-notice-bar`;
|
21987 | const defaultProps$r = {
|
21988 | color: "default",
|
21989 | delay: 2e3,
|
21990 | speed: 50,
|
21991 | icon: React$1.createElement(SoundOutline, null),
|
21992 | wrap: false
|
21993 | };
|
21994 | const NoticeBar = React$1.memo((props) => {
|
21995 | const {
|
21996 | noticeBar: componentConfig = {}
|
21997 | } = useConfig();
|
21998 | const mergedProps = mergeProps(defaultProps$r, componentConfig, props);
|
21999 | const closeIcon = mergeProp(React$1.createElement(CloseOutline, {
|
22000 | className: `${classPrefix$x}-close-icon`
|
22001 | }), componentConfig.closeIcon, props.closeIcon);
|
22002 | const containerRef = React$1.useRef(null);
|
22003 | const textRef = React$1.useRef(null);
|
22004 | const [visible, setVisible] = React$1.useState(true);
|
22005 | const speed = mergedProps.speed;
|
22006 | const delayLockRef = React$1.useRef(true);
|
22007 | const animatingRef = React$1.useRef(false);
|
22008 | function start2() {
|
22009 | if (delayLockRef.current || mergedProps.wrap)
|
22010 | return;
|
22011 | const container = containerRef.current;
|
22012 | const text = textRef.current;
|
22013 | if (!container || !text)
|
22014 | return;
|
22015 | if (container.offsetWidth >= text.offsetWidth) {
|
22016 | animatingRef.current = false;
|
22017 | text.style.removeProperty("transition-duration");
|
22018 | text.style.removeProperty("transform");
|
22019 | return;
|
22020 | }
|
22021 | if (animatingRef.current)
|
22022 | return;
|
22023 | const initial = !text.style.transform;
|
22024 | text.style.transitionDuration = "0s";
|
22025 | if (initial) {
|
22026 | text.style.transform = "translateX(0)";
|
22027 | } else {
|
22028 | text.style.transform = `translateX(${container.offsetWidth}px)`;
|
22029 | }
|
22030 | const distance = initial ? text.offsetWidth : container.offsetWidth + text.offsetWidth;
|
22031 | animatingRef.current = true;
|
22032 | text.style.transitionDuration = `${Math.round(distance / speed)}s`;
|
22033 | text.style.transform = `translateX(-${text.offsetWidth}px)`;
|
22034 | }
|
22035 | useTimeout$1(() => {
|
22036 | delayLockRef.current = false;
|
22037 | start2();
|
22038 | }, mergedProps.delay);
|
22039 | useResizeEffect(() => {
|
22040 | start2();
|
22041 | }, containerRef);
|
22042 | useMutationEffect(() => {
|
22043 | start2();
|
22044 | }, textRef, {
|
22045 | subtree: true,
|
22046 | childList: true,
|
22047 | characterData: true
|
22048 | });
|
22049 | if (!visible)
|
22050 | return null;
|
22051 | return withNativeProps(mergedProps, React$1.createElement("div", {
|
22052 | className: classNames(classPrefix$x, `${classPrefix$x}-${mergedProps.color}`, {
|
22053 | [`${classPrefix$x}-wrap`]: mergedProps.wrap
|
22054 | }),
|
22055 | onClick: mergedProps.onClick
|
22056 | }, mergedProps.icon && React$1.createElement("span", {
|
22057 | className: `${classPrefix$x}-left`
|
22058 | }, mergedProps.icon), React$1.createElement("span", {
|
22059 | ref: containerRef,
|
22060 | className: `${classPrefix$x}-content`
|
22061 | }, React$1.createElement("span", {
|
22062 | onTransitionEnd: () => {
|
22063 | animatingRef.current = false;
|
22064 | start2();
|
22065 | },
|
22066 | ref: textRef,
|
22067 | className: `${classPrefix$x}-content-inner`
|
22068 | }, mergedProps.content)), (mergedProps.closeable || mergedProps.extra) && React$1.createElement("span", {
|
22069 | className: `${classPrefix$x}-right`
|
22070 | }, mergedProps.extra, mergedProps.closeable && React$1.createElement("div", {
|
22071 | className: `${classPrefix$x}-close`,
|
22072 | onClick: () => {
|
22073 | var _a;
|
22074 | setVisible(false);
|
22075 | (_a = mergedProps.onClose) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
|
22076 | }
|
22077 | }, closeIcon))));
|
22078 | });
|
22079 | function shuffle(array) {
|
22080 | const result = [...array];
|
22081 | for (let i2 = result.length; i2 > 0; i2--) {
|
22082 | const j = Math.floor(Math.random() * i2);
|
22083 | [result[i2 - 1], result[j]] = [result[j], result[i2 - 1]];
|
22084 | }
|
22085 | return result;
|
22086 | }
|
22087 | const classPrefix$w = "adm-number-keyboard";
|
22088 | const defaultProps$q = {
|
22089 | defaultVisible: false,
|
22090 | randomOrder: false,
|
22091 | showCloseButton: true,
|
22092 | confirmText: null,
|
22093 | closeOnConfirm: true,
|
22094 | safeArea: true,
|
22095 | destroyOnClose: false,
|
22096 | forceRender: false
|
22097 | };
|
22098 | const NumberKeyboard = (p) => {
|
22099 | const props = mergeProps(defaultProps$q, p);
|
22100 | const {
|
22101 | visible,
|
22102 | title,
|
22103 | getContainer,
|
22104 | confirmText,
|
22105 | customKey,
|
22106 | randomOrder,
|
22107 | showCloseButton,
|
22108 | onInput
|
22109 | } = props;
|
22110 | const {
|
22111 | locale
|
22112 | } = useConfig();
|
22113 | const keyboardRef = React$1.useRef(null);
|
22114 | const keys = React$1.useMemo(() => {
|
22115 | const defaultKeys = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
|
22116 | const keyList = randomOrder ? shuffle(defaultKeys) : defaultKeys;
|
22117 | const customKeys = Array.isArray(customKey) ? customKey : [customKey];
|
22118 | keyList.push("0");
|
22119 | if (confirmText) {
|
22120 | if (customKeys.length === 2) {
|
22121 | keyList.splice(9, 0, customKeys.pop());
|
22122 | }
|
22123 | keyList.push(customKeys[0] || "");
|
22124 | } else {
|
22125 | keyList.splice(9, 0, customKeys[0] || "");
|
22126 | keyList.push(customKeys[1] || "BACKSPACE");
|
22127 | }
|
22128 | return keyList;
|
22129 | }, [customKey, confirmText, randomOrder, randomOrder && visible]);
|
22130 | const timeoutRef = React$1.useRef(-1);
|
22131 | const intervalRef = React$1.useRef(-1);
|
22132 | const onDelete = useMemoizedFn(() => {
|
22133 | var _a;
|
22134 | (_a = props.onDelete) === null || _a === void 0 ? void 0 : _a.call(props);
|
22135 | });
|
22136 | const startContinueClear = () => {
|
22137 | timeoutRef.current = window.setTimeout(() => {
|
22138 | onDelete();
|
22139 | intervalRef.current = window.setInterval(onDelete, 150);
|
22140 | }, 700);
|
22141 | };
|
22142 | const stopContinueClear = () => {
|
22143 | clearTimeout(timeoutRef.current);
|
22144 | clearInterval(intervalRef.current);
|
22145 | };
|
22146 | const onKeyPress = (e2, key) => {
|
22147 | var _a, _b;
|
22148 | e2.preventDefault();
|
22149 | switch (key) {
|
22150 | case "BACKSPACE":
|
22151 | onDelete === null || onDelete === void 0 ? void 0 : onDelete();
|
22152 | break;
|
22153 | case "OK":
|
22154 | (_a = props.onConfirm) === null || _a === void 0 ? void 0 : _a.call(props);
|
22155 | if (props.closeOnConfirm) {
|
22156 | (_b = props.onClose) === null || _b === void 0 ? void 0 : _b.call(props);
|
22157 | }
|
22158 | break;
|
22159 | default:
|
22160 | if (key !== "")
|
22161 | onInput === null || onInput === void 0 ? void 0 : onInput(key);
|
22162 | break;
|
22163 | }
|
22164 | };
|
22165 | const renderHeader = () => {
|
22166 | if (!showCloseButton && !title)
|
22167 | return null;
|
22168 | return React$1.createElement("div", {
|
22169 | className: classNames(`${classPrefix$w}-header`, {
|
22170 | [`${classPrefix$w}-header-with-title`]: !!title
|
22171 | })
|
22172 | }, !!title && React$1.createElement("div", {
|
22173 | className: `${classPrefix$w}-title`,
|
22174 | "aria-label": title
|
22175 | }, title), showCloseButton && React$1.createElement("span", {
|
22176 | className: `${classPrefix$w}-header-close-button`,
|
22177 | onClick: () => {
|
22178 | var _a;
|
22179 | (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
22180 | },
|
22181 | role: "button",
|
22182 | title: locale.common.close,
|
22183 | tabIndex: -1
|
22184 | }, React$1.createElement(DownOutline, null)));
|
22185 | };
|
22186 | const renderKey = (key, index2) => {
|
22187 | const isNumberKey = /^\d$/.test(key);
|
22188 | const className = classNames(`${classPrefix$w}-key`, {
|
22189 | [`${classPrefix$w}-key-number`]: isNumberKey,
|
22190 | [`${classPrefix$w}-key-sign`]: !isNumberKey && key,
|
22191 | [`${classPrefix$w}-key-mid`]: index2 === 9 && !!confirmText && keys.length < 12
|
22192 | });
|
22193 | const ariaProps = key ? {
|
22194 | role: "button",
|
22195 | title: key,
|
22196 | tabIndex: -1
|
22197 | } : void 0;
|
22198 | return React$1.createElement("div", Object.assign({
|
22199 | key,
|
22200 | className,
|
22201 | onTouchStart: () => {
|
22202 | stopContinueClear();
|
22203 | if (key === "BACKSPACE") {
|
22204 | startContinueClear();
|
22205 | }
|
22206 | },
|
22207 | onTouchEnd: (e2) => {
|
22208 | onKeyPress(e2, key);
|
22209 | if (key === "BACKSPACE") {
|
22210 | stopContinueClear();
|
22211 | }
|
22212 | }
|
22213 | }, ariaProps), key === "BACKSPACE" ? React$1.createElement(TextDeletionOutline, null) : key);
|
22214 | };
|
22215 | return React$1.createElement(Popup, {
|
22216 | visible,
|
22217 | getContainer,
|
22218 | mask: false,
|
22219 | afterClose: props.afterClose,
|
22220 | afterShow: props.afterShow,
|
22221 | className: `${classPrefix$w}-popup`,
|
22222 | stopPropagation: props.stopPropagation,
|
22223 | destroyOnClose: props.destroyOnClose,
|
22224 | forceRender: props.forceRender
|
22225 | }, withNativeProps(props, React$1.createElement("div", {
|
22226 | ref: keyboardRef,
|
22227 | className: classPrefix$w,
|
22228 | onMouseDown: (e2) => {
|
22229 | e2.preventDefault();
|
22230 | }
|
22231 | }, renderHeader(), React$1.createElement("div", {
|
22232 | className: `${classPrefix$w}-wrapper`
|
22233 | }, React$1.createElement("div", {
|
22234 | className: classNames(`${classPrefix$w}-main`, {
|
22235 | [`${classPrefix$w}-main-confirmed-style`]: !!confirmText
|
22236 | })
|
22237 | }, keys.map(renderKey)), !!confirmText && React$1.createElement("div", {
|
22238 | className: `${classPrefix$w}-confirm`
|
22239 | }, React$1.createElement("div", {
|
22240 | className: `${classPrefix$w}-key ${classPrefix$w}-key-extra ${classPrefix$w}-key-bs`,
|
22241 | onTouchStart: () => {
|
22242 | startContinueClear();
|
22243 | },
|
22244 | onTouchEnd: (e2) => {
|
22245 | onKeyPress(e2, "BACKSPACE");
|
22246 | stopContinueClear();
|
22247 | },
|
22248 | onContextMenu: (e2) => {
|
22249 | e2.preventDefault();
|
22250 | },
|
22251 | title: locale.Input.clear,
|
22252 | role: "button",
|
22253 | tabIndex: -1
|
22254 | }, React$1.createElement(TextDeletionOutline, null)), React$1.createElement("div", {
|
22255 | className: `${classPrefix$w}-key ${classPrefix$w}-key-extra ${classPrefix$w}-key-ok`,
|
22256 | onTouchEnd: (e2) => onKeyPress(e2, "OK"),
|
22257 | role: "button",
|
22258 | tabIndex: -1,
|
22259 | "aria-label": confirmText
|
22260 | }, confirmText))), props.safeArea && React$1.createElement("div", {
|
22261 | className: `${classPrefix$w}-footer`
|
22262 | }, React$1.createElement(SafeArea, {
|
22263 | position: "bottom"
|
22264 | })))));
|
22265 | };
|
22266 | const classPrefix$v = `adm-page-indicator`;
|
22267 | const defaultProps$p = {
|
22268 | color: "primary",
|
22269 | direction: "horizontal"
|
22270 | };
|
22271 | const PageIndicator = React$1.memo((p) => {
|
22272 | const props = mergeProps(defaultProps$p, p);
|
22273 | const dots = [];
|
22274 | for (let i2 = 0; i2 < props.total; i2++) {
|
22275 | dots.push(React$1.createElement("div", {
|
22276 | key: i2,
|
22277 | className: classNames(`${classPrefix$v}-dot`, {
|
22278 | [`${classPrefix$v}-dot-active`]: props.current === i2
|
22279 | })
|
22280 | }));
|
22281 | }
|
22282 | return withNativeProps(props, React$1.createElement("div", {
|
22283 | className: classNames(classPrefix$v, `${classPrefix$v}-${props.direction}`, `${classPrefix$v}-color-${props.color}`)
|
22284 | }, dots));
|
22285 | });
|
22286 | const classPrefix$u = "adm-passcode-input";
|
22287 | const defaultProps$o = {
|
22288 | defaultValue: "",
|
22289 | length: 6,
|
22290 | plain: false,
|
22291 | error: false,
|
22292 | seperated: false,
|
22293 | caret: true
|
22294 | };
|
22295 | const PasscodeInput = React$1.forwardRef((p, ref) => {
|
22296 | const props = mergeProps(defaultProps$o, p);
|
22297 | const cellLength = props.length > 0 && props.length < Infinity ? Math.floor(props.length) : defaultProps$o.length;
|
22298 | const {
|
22299 | locale
|
22300 | } = useConfig();
|
22301 | const [focused, setFocused] = React$1.useState(false);
|
22302 | const [value, setValue2] = usePropsValue(props);
|
22303 | const rootRef = React$1.useRef(null);
|
22304 | const nativeInputRef = React$1.useRef(null);
|
22305 | React$1.useEffect(() => {
|
22306 | var _a;
|
22307 | if (value.length >= cellLength) {
|
22308 | (_a = props.onFill) === null || _a === void 0 ? void 0 : _a.call(props, value);
|
22309 | }
|
22310 | }, [value, cellLength]);
|
22311 | const onFocus = () => {
|
22312 | var _a, _b;
|
22313 | if (!props.keyboard) {
|
22314 | (_a = nativeInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
22315 | }
|
22316 | setFocused(true);
|
22317 | (_b = props.onFocus) === null || _b === void 0 ? void 0 : _b.call(props);
|
22318 | };
|
22319 | React$1.useEffect(() => {
|
22320 | if (!focused)
|
22321 | return;
|
22322 | const timeout = window.setTimeout(() => {
|
22323 | var _a;
|
22324 | (_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({
|
22325 | block: "center",
|
22326 | inline: "center",
|
22327 | behavior: "smooth"
|
22328 | });
|
22329 | }, 100);
|
22330 | return () => {
|
22331 | window.clearTimeout(timeout);
|
22332 | };
|
22333 | }, [focused]);
|
22334 | const onBlur = () => {
|
22335 | var _a;
|
22336 | setFocused(false);
|
22337 | (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props);
|
22338 | };
|
22339 | React$1.useImperativeHandle(ref, () => ({
|
22340 | focus: () => {
|
22341 | var _a;
|
22342 | return (_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
22343 | },
|
22344 | blur: () => {
|
22345 | var _a, _b;
|
22346 | (_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
22347 | (_b = nativeInputRef.current) === null || _b === void 0 ? void 0 : _b.blur();
|
22348 | }
|
22349 | }));
|
22350 | const renderCells = () => {
|
22351 | const cells = [];
|
22352 | const chars = value.split("");
|
22353 | const caretIndex = chars.length;
|
22354 | const focusedIndex = bound(chars.length, 0, cellLength - 1);
|
22355 | for (let i2 = 0; i2 < cellLength; i2++) {
|
22356 | cells.push(React$1.createElement("div", {
|
22357 | className: classNames(`${classPrefix$u}-cell`, {
|
22358 | [`${classPrefix$u}-cell-caret`]: props.caret && caretIndex === i2 && focused,
|
22359 | [`${classPrefix$u}-cell-focused`]: focusedIndex === i2 && focused,
|
22360 | [`${classPrefix$u}-cell-dot`]: !props.plain && chars[i2]
|
22361 | }),
|
22362 | key: i2
|
22363 | }, chars[i2] && props.plain ? chars[i2] : ""));
|
22364 | }
|
22365 | return cells;
|
22366 | };
|
22367 | const cls2 = classNames(classPrefix$u, {
|
22368 | [`${classPrefix$u}-focused`]: focused,
|
22369 | [`${classPrefix$u}-error`]: props.error,
|
22370 | [`${classPrefix$u}-seperated`]: props.seperated
|
22371 | });
|
22372 | return React$1.createElement(React$1.Fragment, null, withNativeProps(props, React$1.createElement("div", {
|
22373 | ref: rootRef,
|
22374 | tabIndex: 0,
|
22375 | className: cls2,
|
22376 | onFocus,
|
22377 | onBlur,
|
22378 | role: "button",
|
22379 | "aria-label": locale.PasscodeInput.name
|
22380 | }, React$1.createElement("div", {
|
22381 | className: `${classPrefix$u}-cell-container`
|
22382 | }, renderCells()), React$1.createElement("input", {
|
22383 | ref: nativeInputRef,
|
22384 | className: `${classPrefix$u}-native-input`,
|
22385 | value,
|
22386 | type: "text",
|
22387 | pattern: "[0-9]*",
|
22388 | inputMode: "numeric",
|
22389 | onChange: (e2) => {
|
22390 | setValue2(e2.target.value.slice(0, props.length));
|
22391 | },
|
22392 | "aria-hidden": true
|
22393 | }))), props.keyboard && React$1.cloneElement(props.keyboard, {
|
22394 | visible: focused,
|
22395 | onInput: (v) => {
|
22396 | if (value.length < cellLength) {
|
22397 | setValue2((value + v).slice(0, props.length));
|
22398 | }
|
22399 | },
|
22400 | onDelete: () => {
|
22401 | setValue2(value.slice(0, -1));
|
22402 | },
|
22403 | onClose: () => {
|
22404 | var _a;
|
22405 | (_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
22406 | }
|
22407 | }));
|
22408 | });
|
22409 | const classPrefix$t = `adm-progress-bar`;
|
22410 | const defaultProps$n = {
|
22411 | percent: 0,
|
22412 | rounded: true,
|
22413 | text: false
|
22414 | };
|
22415 | const ProgressBar = (p) => {
|
22416 | const props = mergeProps(defaultProps$n, p);
|
22417 | const fillStyle = {
|
22418 | width: `${props.percent}%`
|
22419 | };
|
22420 | const textElement = function() {
|
22421 | if (props.text === true) {
|
22422 | return `${props.percent}%`;
|
22423 | }
|
22424 | if (typeof props.text === "function") {
|
22425 | return props.text(props.percent);
|
22426 | }
|
22427 | return props.text;
|
22428 | }();
|
22429 | return withNativeProps(props, React$1.createElement("div", {
|
22430 | className: classNames(classPrefix$t, props.rounded && `${classPrefix$t}-rounded`)
|
22431 | }, React$1.createElement("div", {
|
22432 | className: `${classPrefix$t}-trail`
|
22433 | }, React$1.createElement("div", {
|
22434 | className: `${classPrefix$t}-fill`,
|
22435 | style: fillStyle
|
22436 | })), isNodeWithContent(textElement) && React$1.createElement("div", {
|
22437 | className: `${classPrefix$t}-text`
|
22438 | }, textElement)));
|
22439 | };
|
22440 | const classPrefix$s = `adm-progress-circle`;
|
22441 | const ProgressCircle = (p) => {
|
22442 | const props = mergeProps({
|
22443 | percent: 0
|
22444 | }, p);
|
22445 | const style = {
|
22446 | "--percent": props.percent.toString()
|
22447 | };
|
22448 | return withNativeProps(props, React$1.createElement("div", {
|
22449 | className: `${classPrefix$s}`,
|
22450 | style
|
22451 | }, React$1.createElement("div", {
|
22452 | className: `${classPrefix$s}-content`
|
22453 | }, React$1.createElement("svg", {
|
22454 | className: `${classPrefix$s}-svg`
|
22455 | }, React$1.createElement("circle", {
|
22456 | className: `${classPrefix$s}-track`,
|
22457 | fill: "transparent"
|
22458 | }), React$1.createElement("circle", {
|
22459 | className: `${classPrefix$s}-fill`,
|
22460 | fill: "transparent"
|
22461 | })), React$1.createElement("div", {
|
22462 | className: `${classPrefix$s}-info`
|
22463 | }, props.children))));
|
22464 | };
|
22465 | const sleep = (time) => new Promise((resolve) => setTimeout(resolve, time));
|
22466 | const classPrefix$r = `adm-pull-to-refresh`;
|
22467 | const defaultProps$m = {
|
22468 | pullingText: "下拉刷新",
|
22469 | canReleaseText: "释放立即刷新",
|
22470 | refreshingText: "加载中...",
|
22471 | completeText: "刷新成功",
|
22472 | completeDelay: 500,
|
22473 | disabled: false,
|
22474 | onRefresh: () => {
|
22475 | }
|
22476 | };
|
22477 | const PullToRefresh = (p) => {
|
22478 | var _a, _b;
|
22479 | const {
|
22480 | locale
|
22481 | } = useConfig();
|
22482 | const props = mergeProps(defaultProps$m, {
|
22483 | refreshingText: `${locale.common.loading}...`,
|
22484 | pullingText: locale.PullToRefresh.pulling,
|
22485 | canReleaseText: locale.PullToRefresh.canRelease,
|
22486 | completeText: locale.PullToRefresh.complete
|
22487 | }, p);
|
22488 | const headHeight = (_a = props.headHeight) !== null && _a !== void 0 ? _a : convertPx(40);
|
22489 | const threshold = (_b = props.threshold) !== null && _b !== void 0 ? _b : convertPx(60);
|
22490 | const [status, setStatus] = React$1.useState("pulling");
|
22491 | const [springStyles, api] = useSpring(() => ({
|
22492 | from: {
|
22493 | height: 0
|
22494 | },
|
22495 | config: {
|
22496 | tension: 300,
|
22497 | friction: 30,
|
22498 | round: true,
|
22499 | clamp: true
|
22500 | }
|
22501 | }));
|
22502 | const elementRef = React$1.useRef(null);
|
22503 | const pullingRef = React$1.useRef(false);
|
22504 | React$1.useEffect(() => {
|
22505 | var _a2;
|
22506 | (_a2 = elementRef.current) === null || _a2 === void 0 ? void 0 : _a2.addEventListener("touchmove", () => {
|
22507 | });
|
22508 | }, []);
|
22509 | const reset = () => {
|
22510 | return new Promise((resolve) => {
|
22511 | api.start({
|
22512 | to: {
|
22513 | height: 0
|
22514 | },
|
22515 | onResolve() {
|
22516 | setStatus("pulling");
|
22517 | resolve();
|
22518 | }
|
22519 | });
|
22520 | });
|
22521 | };
|
22522 | function doRefresh() {
|
22523 | return __awaiter(this, void 0, void 0, function* () {
|
22524 | api.start({
|
22525 | height: headHeight
|
22526 | });
|
22527 | setStatus("refreshing");
|
22528 | try {
|
22529 | yield props.onRefresh();
|
22530 | setStatus("complete");
|
22531 | } catch (e2) {
|
22532 | reset();
|
22533 | throw e2;
|
22534 | }
|
22535 | if (props.completeDelay > 0) {
|
22536 | yield sleep(props.completeDelay);
|
22537 | }
|
22538 | reset();
|
22539 | });
|
22540 | }
|
22541 | useDrag((state) => {
|
22542 | if (status === "refreshing" || status === "complete")
|
22543 | return;
|
22544 | const {
|
22545 | event
|
22546 | } = state;
|
22547 | if (state.last) {
|
22548 | pullingRef.current = false;
|
22549 | if (status === "canRelease") {
|
22550 | doRefresh();
|
22551 | } else {
|
22552 | api.start({
|
22553 | height: 0
|
22554 | });
|
22555 | }
|
22556 | return;
|
22557 | }
|
22558 | const [, y] = state.movement;
|
22559 | const parsedY = Math.ceil(y);
|
22560 | if (state.first && parsedY > 0) {
|
22561 | let getScrollTop = function(element) {
|
22562 | return "scrollTop" in element ? element.scrollTop : element.scrollY;
|
22563 | };
|
22564 | const target = state.event.target;
|
22565 | if (!target || !(target instanceof Element))
|
22566 | return;
|
22567 | let scrollParent = getScrollParent(target);
|
22568 | while (true) {
|
22569 | if (!scrollParent)
|
22570 | return;
|
22571 | const scrollTop = getScrollTop(scrollParent);
|
22572 | if (scrollTop > 0) {
|
22573 | return;
|
22574 | }
|
22575 | if (scrollParent instanceof Window) {
|
22576 | break;
|
22577 | }
|
22578 | scrollParent = getScrollParent(scrollParent.parentNode);
|
22579 | }
|
22580 | pullingRef.current = true;
|
22581 | }
|
22582 | if (!pullingRef.current)
|
22583 | return;
|
22584 | if (event.cancelable) {
|
22585 | event.preventDefault();
|
22586 | }
|
22587 | event.stopPropagation();
|
22588 | const height = Math.max(rubberbandIfOutOfBounds(parsedY, 0, 0, headHeight * 5, 0.5), 0);
|
22589 | api.start({
|
22590 | height
|
22591 | });
|
22592 | setStatus(height > threshold ? "canRelease" : "pulling");
|
22593 | }, {
|
22594 | pointer: {
|
22595 | touch: true
|
22596 | },
|
22597 | axis: "y",
|
22598 | target: elementRef,
|
22599 | enabled: !props.disabled,
|
22600 | eventOptions: supportsPassive ? {
|
22601 | passive: false
|
22602 | } : void 0
|
22603 | });
|
22604 | const renderStatusText = () => {
|
22605 | var _a2;
|
22606 | if (props.renderText) {
|
22607 | return (_a2 = props.renderText) === null || _a2 === void 0 ? void 0 : _a2.call(props, status);
|
22608 | }
|
22609 | if (status === "pulling")
|
22610 | return props.pullingText;
|
22611 | if (status === "canRelease")
|
22612 | return props.canReleaseText;
|
22613 | if (status === "refreshing")
|
22614 | return props.refreshingText;
|
22615 | if (status === "complete")
|
22616 | return props.completeText;
|
22617 | };
|
22618 | return React$1.createElement(animated.div, {
|
22619 | ref: elementRef,
|
22620 | className: classPrefix$r
|
22621 | }, React$1.createElement(animated.div, {
|
22622 | style: springStyles,
|
22623 | className: `${classPrefix$r}-head`
|
22624 | }, React$1.createElement("div", {
|
22625 | className: `${classPrefix$r}-head-content`,
|
22626 | style: {
|
22627 | height: headHeight
|
22628 | }
|
22629 | }, renderStatusText())), React$1.createElement("div", {
|
22630 | className: `${classPrefix$r}-content`
|
22631 | }, props.children));
|
22632 | };
|
22633 | const RadioGroupContext = React$1.createContext(null);
|
22634 | const defaultProps$l = {
|
22635 | disabled: false,
|
22636 | defaultValue: null
|
22637 | };
|
22638 | const Group = (p) => {
|
22639 | const props = mergeProps(defaultProps$l, p);
|
22640 | const [value, setValue2] = usePropsValue({
|
22641 | value: props.value,
|
22642 | defaultValue: props.defaultValue,
|
22643 | onChange: (v) => {
|
22644 | var _a;
|
22645 | if (v === null)
|
22646 | return;
|
22647 | (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, v);
|
22648 | }
|
22649 | });
|
22650 | return React$1.createElement(
|
22651 | RadioGroupContext.Provider,
|
22652 | {
|
22653 |
|
22654 | value: {
|
22655 | value: value === null ? [] : [value],
|
22656 | check: (v) => {
|
22657 | setValue2(v);
|
22658 | },
|
22659 | uncheck: () => {
|
22660 | },
|
22661 | disabled: props.disabled
|
22662 | }
|
22663 | },
|
22664 | props.children
|
22665 | );
|
22666 | };
|
22667 | const classPrefix$q = `adm-radio`;
|
22668 | const defaultProps$k = {
|
22669 | defaultChecked: false
|
22670 | };
|
22671 | const Radio = (p) => {
|
22672 | const props = mergeProps(defaultProps$k, p);
|
22673 | const groupContext = React$1.useContext(RadioGroupContext);
|
22674 | let [checked, setChecked] = usePropsValue({
|
22675 | value: props.checked,
|
22676 | defaultValue: props.defaultChecked,
|
22677 | onChange: props.onChange
|
22678 | });
|
22679 | let disabled = props.disabled;
|
22680 | const {
|
22681 | value
|
22682 | } = props;
|
22683 | if (groupContext && value !== void 0) {
|
22684 | {
|
22685 | if (p.checked !== void 0) {
|
22686 | devWarning("Radio", "When used within `Radio.Group`, the `checked` prop of `Radio` will not work.");
|
22687 | }
|
22688 | if (p.defaultChecked !== void 0) {
|
22689 | devWarning("Radio", "When used within `Radio.Group`, the `defaultChecked` prop of `Radio` will not work.");
|
22690 | }
|
22691 | }
|
22692 | checked = groupContext.value.includes(value);
|
22693 | setChecked = (innerChecked) => {
|
22694 | var _a;
|
22695 | if (innerChecked) {
|
22696 | groupContext.check(value);
|
22697 | } else {
|
22698 | groupContext.uncheck(value);
|
22699 | }
|
22700 | (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, innerChecked);
|
22701 | };
|
22702 | disabled = disabled || groupContext.disabled;
|
22703 | }
|
22704 | const renderIcon = () => {
|
22705 | if (props.icon) {
|
22706 | return React$1.createElement("div", {
|
22707 | className: `${classPrefix$q}-custom-icon`
|
22708 | }, props.icon(checked));
|
22709 | }
|
22710 | return React$1.createElement("div", {
|
22711 | className: `${classPrefix$q}-icon`
|
22712 | }, checked && React$1.createElement(CheckIcon, null));
|
22713 | };
|
22714 | return withNativeProps(props, React$1.createElement("label", {
|
22715 | onClick: props.onClick,
|
22716 | className: classNames(classPrefix$q, {
|
22717 | [`${classPrefix$q}-checked`]: checked,
|
22718 | [`${classPrefix$q}-disabled`]: disabled,
|
22719 | [`${classPrefix$q}-block`]: props.block
|
22720 | })
|
22721 | }, React$1.createElement(NativeInput, {
|
22722 | type: "radio",
|
22723 | checked,
|
22724 | onChange: setChecked,
|
22725 | disabled,
|
22726 | id: props.id
|
22727 | }), renderIcon(), props.children && React$1.createElement("div", {
|
22728 | className: `${classPrefix$q}-content`
|
22729 | }, props.children)));
|
22730 | };
|
22731 | const index$6 = attachPropertiesToComponent(Radio, {
|
22732 | Group
|
22733 | });
|
22734 | const Star = () => {
|
22735 | return React$1.createElement("svg", {
|
22736 | viewBox: "0 0 42 40",
|
22737 | height: "1em",
|
22738 | xmlns: "http://www.w3.org/2000/svg",
|
22739 | style: {
|
22740 | verticalAlign: "-0.125em"
|
22741 | }
|
22742 | }, React$1.createElement("path", {
|
22743 | d: "m21 34-10.52 5.53a2 2 0 0 1-2.902-2.108l2.01-11.714-8.511-8.296a2 2 0 0 1 1.108-3.411l11.762-1.71 5.26-10.657a2 2 0 0 1 3.586 0l5.26 10.658L39.815 14a2 2 0 0 1 1.108 3.411l-8.51 8.296 2.009 11.714a2 2 0 0 1-2.902 2.109L21 34Z",
|
22744 | fill: "currentColor",
|
22745 | fillRule: "evenodd"
|
22746 | }));
|
22747 | };
|
22748 | const classPrefix$p = `adm-rate`;
|
22749 | const defaultProps$j = {
|
22750 | count: 5,
|
22751 | allowHalf: false,
|
22752 | character: React$1.createElement(Star, null),
|
22753 | defaultValue: 0,
|
22754 | readOnly: false,
|
22755 | allowClear: true
|
22756 | };
|
22757 | const Rate = (p) => {
|
22758 | const props = mergeProps(defaultProps$j, p);
|
22759 | const [value, setValue2] = usePropsValue(props);
|
22760 | const containerRef = React$1.useRef(null);
|
22761 | const starList = Array(props.count).fill(null);
|
22762 | function renderStar(v, half) {
|
22763 | return React$1.createElement("div", {
|
22764 | className: classNames(`${classPrefix$p}-star`, {
|
22765 | [`${classPrefix$p}-star-active`]: value >= v,
|
22766 | [`${classPrefix$p}-star-half`]: half,
|
22767 | [`${classPrefix$p}-star-readonly`]: props.readOnly
|
22768 | }),
|
22769 | role: "radio",
|
22770 | "aria-checked": value >= v,
|
22771 | "aria-label": "" + v
|
22772 | }, props.character);
|
22773 | }
|
22774 | const bind = useDrag((state) => {
|
22775 | if (props.readOnly)
|
22776 | return;
|
22777 | const {
|
22778 | xy: [clientX],
|
22779 | tap
|
22780 | } = state;
|
22781 | const container = containerRef.current;
|
22782 | if (!container)
|
22783 | return;
|
22784 | const rect = container.getBoundingClientRect();
|
22785 | const rawValue = (clientX - rect.left) / rect.width * props.count;
|
22786 | const ceiledValue = props.allowHalf ? Math.ceil(rawValue * 2) / 2 : Math.ceil(rawValue);
|
22787 | const boundValue = bound(ceiledValue, 0, props.count);
|
22788 | if (tap) {
|
22789 | if (props.allowClear && boundValue === value) {
|
22790 | setValue2(0);
|
22791 | return;
|
22792 | }
|
22793 | }
|
22794 | setValue2(boundValue);
|
22795 | }, {
|
22796 | axis: "x",
|
22797 | pointer: {
|
22798 | touch: true
|
22799 | },
|
22800 | filterTaps: true
|
22801 | });
|
22802 | return withNativeProps(props, React$1.createElement("div", Object.assign({
|
22803 | className: classNames(classPrefix$p, {
|
22804 | [`${classPrefix$p}-half`]: props.allowHalf
|
22805 | }),
|
22806 | role: "radiogroup",
|
22807 | "aria-readonly": props.readOnly,
|
22808 | ref: containerRef
|
22809 | }, bind()), starList.map((_, i2) => React$1.createElement("div", {
|
22810 | key: i2,
|
22811 | className: classNames(`${classPrefix$p}-box`)
|
22812 | }, props.allowHalf && renderStar(i2 + 0.5, true), renderStar(i2 + 1, false)))));
|
22813 | };
|
22814 | const useResultIcon = (status) => {
|
22815 | const {
|
22816 | result: componentConfig = {}
|
22817 | } = useConfig();
|
22818 | const {
|
22819 | successIcon = React$1.createElement(CheckCircleFill, null),
|
22820 | errorIcon = React$1.createElement(CloseCircleFill, null),
|
22821 | infoIcon = React$1.createElement(InformationCircleFill, null),
|
22822 | waitingIcon = React$1.createElement(ClockCircleFill, null),
|
22823 | warningIcon = React$1.createElement(ExclamationCircleFill, null)
|
22824 | } = componentConfig || {};
|
22825 | switch (status) {
|
22826 | case "success":
|
22827 | return successIcon;
|
22828 | case "error":
|
22829 | return errorIcon;
|
22830 | case "info":
|
22831 | return infoIcon;
|
22832 | case "waiting":
|
22833 | return waitingIcon;
|
22834 | case "warning":
|
22835 | return warningIcon;
|
22836 | default:
|
22837 | return null;
|
22838 | }
|
22839 | };
|
22840 | const classPrefix$o = `adm-result`;
|
22841 | const defaultProps$i = {
|
22842 | status: "info"
|
22843 | };
|
22844 | const Result = (p) => {
|
22845 | const props = mergeProps(defaultProps$i, p);
|
22846 | const {
|
22847 | status,
|
22848 | title,
|
22849 | description,
|
22850 | icon
|
22851 | } = props;
|
22852 | const fallbackIcon = useResultIcon(status);
|
22853 | if (!status)
|
22854 | return null;
|
22855 | return withNativeProps(props, React$1.createElement("div", {
|
22856 | className: classNames(classPrefix$o, `${classPrefix$o}-${status}`)
|
22857 | }, React$1.createElement("div", {
|
22858 | className: `${classPrefix$o}-icon`
|
22859 | }, icon || fallbackIcon), React$1.createElement("div", {
|
22860 | className: `${classPrefix$o}-title`
|
22861 | }, title), !!description && React$1.createElement("div", {
|
22862 | className: `${classPrefix$o}-description`
|
22863 | }, description)));
|
22864 | };
|
22865 | const classPrefix$n = `adm-result-page`;
|
22866 | const defaultProps$h = {
|
22867 | status: "info",
|
22868 | details: []
|
22869 | };
|
22870 | const ResultPage = (p) => {
|
22871 | const props = mergeProps(defaultProps$h, p);
|
22872 | const {
|
22873 | status,
|
22874 | title,
|
22875 | description,
|
22876 | details,
|
22877 | icon,
|
22878 | primaryButtonText,
|
22879 | secondaryButtonText,
|
22880 | onPrimaryButtonClick,
|
22881 | onSecondaryButtonClick
|
22882 | } = props;
|
22883 | const fallbackIcon = useResultIcon(status);
|
22884 | const [collapse, setCollapse] = React$1.useState(true);
|
22885 | const showSecondaryButton = isNodeWithContent(secondaryButtonText);
|
22886 | const showPrimaryButton = isNodeWithContent(primaryButtonText);
|
22887 | return withNativeProps(props, React$1.createElement("div", {
|
22888 | className: classPrefix$n
|
22889 | }, React$1.createElement("div", {
|
22890 | className: `${classPrefix$n}-header`
|
22891 | }, React$1.createElement("div", {
|
22892 | className: `${classPrefix$n}-icon`
|
22893 | }, icon || fallbackIcon), React$1.createElement("div", {
|
22894 | className: `${classPrefix$n}-title`
|
22895 | }, title), isNodeWithContent(description) ? React$1.createElement("div", {
|
22896 | className: `${classPrefix$n}-description`
|
22897 | }, description) : null, (details === null || details === void 0 ? void 0 : details.length) ? React$1.createElement("div", {
|
22898 | className: `${classPrefix$n}-details`
|
22899 | }, (collapse ? details.slice(0, 3) : details).map((detail, index2) => {
|
22900 | return React$1.createElement("div", {
|
22901 | className: classNames(`${classPrefix$n}-detail`, detail.bold && `${classPrefix$n}-detail-bold`),
|
22902 | key: index2
|
22903 | }, React$1.createElement("span", null, detail.label), React$1.createElement("span", null, detail.value));
|
22904 | }), details.length > 3 && React$1.createElement("div", {
|
22905 | onClick: () => setCollapse((prev) => !prev)
|
22906 | }, React$1.createElement("div", {
|
22907 | className: classNames(`${classPrefix$n}-collapse`, !collapse && `${classPrefix$n}-collapse-active`)
|
22908 | }))) : null, React$1.createElement("div", {
|
22909 | className: `${classPrefix$n}-bgWrapper`
|
22910 | }, React$1.createElement("div", {
|
22911 | className: `${classPrefix$n}-bg`
|
22912 | }))), React$1.createElement("div", {
|
22913 | className: `${classPrefix$n}-content`
|
22914 | }, props.children), (showPrimaryButton || showSecondaryButton) && React$1.createElement("div", {
|
22915 | className: `${classPrefix$n}-footer`
|
22916 | }, showSecondaryButton && React$1.createElement(Button, {
|
22917 | block: true,
|
22918 | color: "default",
|
22919 | fill: "solid",
|
22920 | size: "large",
|
22921 | onClick: onSecondaryButtonClick,
|
22922 | className: `${classPrefix$n}-footer-btn`
|
22923 | }, secondaryButtonText), showPrimaryButton && showSecondaryButton && React$1.createElement("div", {
|
22924 | className: `${classPrefix$n}-footer-space`
|
22925 | }), showPrimaryButton && React$1.createElement(Button, {
|
22926 | block: true,
|
22927 | color: "primary",
|
22928 | fill: "solid",
|
22929 | size: "large",
|
22930 | onClick: onPrimaryButtonClick,
|
22931 | className: `${classPrefix$n}-footer-btn`
|
22932 | }, primaryButtonText))));
|
22933 | };
|
22934 | const classPrefix$m = `adm-result-page-card`;
|
22935 | const ResultPageCard = (props) => {
|
22936 | return withNativeProps(props, React$1.createElement("div", {
|
22937 | className: classNames(`${classPrefix$m}`)
|
22938 | }, props.children));
|
22939 | };
|
22940 | const index$5 = attachPropertiesToComponent(ResultPage, {
|
22941 | Card: ResultPageCard
|
22942 | });
|
22943 | const classPrefix$l = `adm-search-bar`;
|
22944 | const defaultProps$g = {
|
22945 | clearable: true,
|
22946 | onlyShowClearWhenFocus: false,
|
22947 | showCancelButton: false,
|
22948 | defaultValue: "",
|
22949 | clearOnCancel: true
|
22950 | };
|
22951 | const SearchBar = React$1.forwardRef((props, ref) => {
|
22952 | const {
|
22953 | locale,
|
22954 | searchBar: componentConfig = {}
|
22955 | } = useConfig();
|
22956 | const mergedProps = mergeProps(defaultProps$g, componentConfig, {
|
22957 | cancelText: locale.common.cancel
|
22958 | }, props);
|
22959 | const searchIcon = mergeProp(React$1.createElement(SearchOutline, null), componentConfig.searchIcon, props.icon, props.searchIcon);
|
22960 | const [value, setValue2] = usePropsValue(mergedProps);
|
22961 | const [hasFocus, setHasFocus] = React$1.useState(false);
|
22962 | const inputRef = React$1.useRef(null);
|
22963 | const composingRef = React$1.useRef(false);
|
22964 | React$1.useImperativeHandle(ref, () => ({
|
22965 | clear: () => {
|
22966 | var _a;
|
22967 | return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.clear();
|
22968 | },
|
22969 | focus: () => {
|
22970 | var _a;
|
22971 | return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
22972 | },
|
22973 | blur: () => {
|
22974 | var _a;
|
22975 | return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
22976 | },
|
22977 | get nativeElement() {
|
22978 | var _a, _b;
|
22979 | return (_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.nativeElement) !== null && _b !== void 0 ? _b : null;
|
22980 | }
|
22981 | }));
|
22982 | const renderCancelButton = () => {
|
22983 | let isShowCancel;
|
22984 | if (typeof mergedProps.showCancelButton === "function") {
|
22985 | isShowCancel = mergedProps.showCancelButton(hasFocus, value);
|
22986 | } else {
|
22987 | isShowCancel = mergedProps.showCancelButton && hasFocus;
|
22988 | }
|
22989 | return isShowCancel && React$1.createElement("div", {
|
22990 | className: `${classPrefix$l}-suffix`
|
22991 | }, React$1.createElement(Button, {
|
22992 | fill: "none",
|
22993 | className: `${classPrefix$l}-cancel-button`,
|
22994 | onClick: () => {
|
22995 | var _a, _b, _c;
|
22996 | if (mergedProps.clearOnCancel) {
|
22997 | (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.clear();
|
22998 | }
|
22999 | (_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.blur();
|
23000 | (_c = mergedProps.onCancel) === null || _c === void 0 ? void 0 : _c.call(mergedProps);
|
23001 | },
|
23002 | onMouseDown: (e2) => {
|
23003 | e2.preventDefault();
|
23004 | }
|
23005 | }, mergedProps.cancelText));
|
23006 | };
|
23007 | return withNativeProps(mergedProps, React$1.createElement("div", {
|
23008 | className: classNames(classPrefix$l, {
|
23009 | [`${classPrefix$l}-active`]: hasFocus
|
23010 | })
|
23011 | }, React$1.createElement("div", {
|
23012 | className: `${classPrefix$l}-input-box`
|
23013 | }, searchIcon && React$1.createElement("div", {
|
23014 | className: `${classPrefix$l}-input-box-icon`
|
23015 | }, searchIcon), React$1.createElement(Input, {
|
23016 | ref: inputRef,
|
23017 | className: classNames(`${classPrefix$l}-input`, {
|
23018 | [`${classPrefix$l}-input-without-icon`]: !searchIcon
|
23019 | }),
|
23020 | value,
|
23021 | onChange: setValue2,
|
23022 | maxLength: mergedProps.maxLength,
|
23023 | placeholder: mergedProps.placeholder,
|
23024 | clearable: mergedProps.clearable,
|
23025 | onlyShowClearWhenFocus: mergedProps.onlyShowClearWhenFocus,
|
23026 | onFocus: (e2) => {
|
23027 | var _a;
|
23028 | setHasFocus(true);
|
23029 | (_a = mergedProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e2);
|
23030 | },
|
23031 | onBlur: (e2) => {
|
23032 | var _a;
|
23033 | setHasFocus(false);
|
23034 | (_a = mergedProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e2);
|
23035 | },
|
23036 | onClear: mergedProps.onClear,
|
23037 | type: "search",
|
23038 | enterKeyHint: "search",
|
23039 | onEnterPress: () => {
|
23040 | var _a, _b;
|
23041 | if (!composingRef.current) {
|
23042 | (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
23043 | (_b = mergedProps.onSearch) === null || _b === void 0 ? void 0 : _b.call(mergedProps, value);
|
23044 | }
|
23045 | },
|
23046 | "aria-label": locale.SearchBar.name,
|
23047 | onCompositionStart: (e2) => {
|
23048 | var _a;
|
23049 | composingRef.current = true;
|
23050 | (_a = mergedProps.onCompositionStart) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e2);
|
23051 | },
|
23052 | onCompositionEnd: (e2) => {
|
23053 | var _a;
|
23054 | composingRef.current = false;
|
23055 | (_a = mergedProps.onCompositionEnd) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e2);
|
23056 | }
|
23057 | })), renderCancelButton()));
|
23058 | });
|
23059 | const CheckMark = React$1.memo(() => {
|
23060 | return React$1.createElement("svg", {
|
23061 | width: "17px",
|
23062 | height: "13px",
|
23063 | viewBox: "0 0 17 13",
|
23064 | version: "1.1",
|
23065 | xmlns: "http://www.w3.org/2000/svg"
|
23066 | }, React$1.createElement("g", {
|
23067 | stroke: "none",
|
23068 | strokeWidth: "1",
|
23069 | fill: "none",
|
23070 | fillRule: "evenodd",
|
23071 | strokeLinecap: "round",
|
23072 | strokeLinejoin: "round"
|
23073 | }, React$1.createElement("g", {
|
23074 | transform: "translate(-2832.000000, -1103.000000)",
|
23075 | stroke: "#FFFFFF",
|
23076 | strokeWidth: "3"
|
23077 | }, React$1.createElement("g", {
|
23078 | transform: "translate(2610.000000, 955.000000)"
|
23079 | }, React$1.createElement("g", {
|
23080 | transform: "translate(24.000000, 91.000000)"
|
23081 | }, React$1.createElement("g", {
|
23082 | transform: "translate(179.177408, 36.687816)"
|
23083 | }, React$1.createElement("polyline", {
|
23084 | points: "34.2767388 22 24.797043 31.4796958 21 27.6826527"
|
23085 | })))))));
|
23086 | });
|
23087 | const classPrefix$k = `adm-selector`;
|
23088 | const defaultProps$f = {
|
23089 | multiple: false,
|
23090 | defaultValue: [],
|
23091 | showCheckMark: true
|
23092 | };
|
23093 | const Selector = (p) => {
|
23094 | const props = mergeProps(defaultProps$f, p);
|
23095 | const [labelName, valueName, , disabledName] = useFieldNames(props.fieldNames);
|
23096 | const [value, setValue2] = usePropsValue({
|
23097 | value: props.value,
|
23098 | defaultValue: props.defaultValue,
|
23099 | onChange: (val) => {
|
23100 | var _a;
|
23101 | const extend = {
|
23102 | get items() {
|
23103 | return props.options.filter((option) => val.includes(option[valueName]));
|
23104 | }
|
23105 | };
|
23106 | (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, val, extend);
|
23107 | }
|
23108 | });
|
23109 | const {
|
23110 | locale
|
23111 | } = useConfig();
|
23112 | const items = props.options.map((option) => {
|
23113 | const active = (value || []).includes(option[valueName]);
|
23114 | const disabled = option[disabledName] || props.disabled;
|
23115 | const itemCls = classNames(`${classPrefix$k}-item`, {
|
23116 | [`${classPrefix$k}-item-active`]: active && !props.multiple,
|
23117 | [`${classPrefix$k}-item-multiple-active`]: active && props.multiple,
|
23118 | [`${classPrefix$k}-item-disabled`]: disabled
|
23119 | });
|
23120 | return React$1.createElement("div", {
|
23121 | key: option[valueName],
|
23122 | className: itemCls,
|
23123 | onClick: () => {
|
23124 | if (disabled) {
|
23125 | return;
|
23126 | }
|
23127 | if (props.multiple) {
|
23128 | const val = active ? value.filter((v) => v !== option[valueName]) : [...value, option[valueName]];
|
23129 | setValue2(val);
|
23130 | } else {
|
23131 | const val = active ? [] : [option[valueName]];
|
23132 | setValue2(val);
|
23133 | }
|
23134 | },
|
23135 | role: "option",
|
23136 | "aria-selected": active && !props.multiple || active && props.multiple
|
23137 | }, option[labelName], option.description && React$1.createElement("div", {
|
23138 | className: `${classPrefix$k}-item-description`
|
23139 | }, option.description), active && props.showCheckMark && React$1.createElement("div", {
|
23140 | className: `${classPrefix$k}-check-mark-wrapper`
|
23141 | }, React$1.createElement(CheckMark, null)));
|
23142 | });
|
23143 | return withNativeProps(props, React$1.createElement("div", {
|
23144 | className: classPrefix$k,
|
23145 | role: "listbox",
|
23146 | "aria-label": locale.Selector.name
|
23147 | }, props.columns ? React$1.createElement(Grid, {
|
23148 | columns: props.columns
|
23149 | }, items) : React$1.createElement(Space, {
|
23150 | wrap: true
|
23151 | }, items)));
|
23152 | };
|
23153 | const Corner = React$1.memo((props) => withNativeProps(props, React$1.createElement("svg", {
|
23154 | viewBox: "0 0 30 30"
|
23155 | }, React$1.createElement("g", {
|
23156 | stroke: "none",
|
23157 | strokeWidth: "1",
|
23158 | fill: "none",
|
23159 | fillRule: "evenodd"
|
23160 | }, React$1.createElement("path", {
|
23161 | d: "M30,0 C13.4314575,3.04359188e-15 -2.02906125e-15,13.4314575 0,30 L0,30 L0,0 Z",
|
23162 | fill: "var(--adm-color-background)",
|
23163 | transform: "translate(15.000000, 15.000000) scale(-1, -1) translate(-15.000000, -15.000000) "
|
23164 | })))));
|
23165 | const classPrefix$j = `adm-side-bar`;
|
23166 | const SideBarItem = () => {
|
23167 | return null;
|
23168 | };
|
23169 | const SideBar = (props) => {
|
23170 | var _a;
|
23171 | let firstActiveKey = null;
|
23172 | const items = [];
|
23173 | traverseReactNode(props.children, (child, index2) => {
|
23174 | if (!React$1.isValidElement(child))
|
23175 | return;
|
23176 | const key = child.key;
|
23177 | if (typeof key !== "string")
|
23178 | return;
|
23179 | if (index2 === 0) {
|
23180 | firstActiveKey = key;
|
23181 | }
|
23182 | items.push(child);
|
23183 | });
|
23184 | const [activeKey, setActiveKey] = usePropsValue({
|
23185 | value: props.activeKey,
|
23186 | defaultValue: (_a = props.defaultActiveKey) !== null && _a !== void 0 ? _a : firstActiveKey,
|
23187 | onChange: (v) => {
|
23188 | var _a2;
|
23189 | if (v === null)
|
23190 | return;
|
23191 | (_a2 = props.onChange) === null || _a2 === void 0 ? void 0 : _a2.call(props, v);
|
23192 | }
|
23193 | });
|
23194 | const lastItem = items[items.length - 1];
|
23195 | const isLastItemActive = lastItem && lastItem.key === activeKey;
|
23196 | return withNativeProps(props, React$1.createElement("div", {
|
23197 | className: classPrefix$j
|
23198 | }, React$1.createElement("div", {
|
23199 | className: `${classPrefix$j}-items`
|
23200 | }, items.map((item, index2) => {
|
23201 | const active = item.key === activeKey;
|
23202 | const isActiveNextSibling = items[index2 - 1] && items[index2 - 1].key === activeKey;
|
23203 | const isActivePreviousSibling = items[index2 + 1] && items[index2 + 1].key === activeKey;
|
23204 | return withNativeProps(item.props, React$1.createElement("div", {
|
23205 | key: item.key,
|
23206 | onClick: () => {
|
23207 | const {
|
23208 | key
|
23209 | } = item;
|
23210 | if (key === void 0 || key === null || item.props.disabled)
|
23211 | return;
|
23212 | setActiveKey(key.toString());
|
23213 | },
|
23214 | className: classNames(`${classPrefix$j}-item`, {
|
23215 | [`${classPrefix$j}-item-active`]: active,
|
23216 | [`${classPrefix$j}-item-disabled`]: item.props.disabled
|
23217 | })
|
23218 | }, React$1.createElement(React$1.Fragment, null, isActiveNextSibling && React$1.createElement(Corner, {
|
23219 | className: `${classPrefix$j}-item-corner ${classPrefix$j}-item-corner-top`
|
23220 | }), isActivePreviousSibling && React$1.createElement(Corner, {
|
23221 | className: `${classPrefix$j}-item-corner ${classPrefix$j}-item-corner-bottom`
|
23222 | })), React$1.createElement(Badge, {
|
23223 | content: item.props.badge,
|
23224 | className: `${classPrefix$j}-badge`
|
23225 | }, React$1.createElement("div", {
|
23226 | className: `${classPrefix$j}-item-title`
|
23227 | }, active && React$1.createElement("div", {
|
23228 | className: `${classPrefix$j}-item-highlight`
|
23229 | }), item.props.title))));
|
23230 | })), React$1.createElement("div", {
|
23231 | className: classNames(`${classPrefix$j}-extra-space`, isLastItemActive && `${classPrefix$j}-item-active-next-sibling`)
|
23232 | }, isLastItemActive && React$1.createElement(Corner, {
|
23233 | className: `${classPrefix$j}-item-corner ${classPrefix$j}-item-corner-top`
|
23234 | }))));
|
23235 | };
|
23236 | const index$4 = attachPropertiesToComponent(SideBar, {
|
23237 | Item: SideBarItem
|
23238 | });
|
23239 | const classPrefix$i = `adm-slider`;
|
23240 | const Ticks = ({
|
23241 | points,
|
23242 | max: max2,
|
23243 | min: min2,
|
23244 | upperBound,
|
23245 | lowerBound
|
23246 | }) => {
|
23247 | const range2 = max2 - min2;
|
23248 | const elements = points.map((point) => {
|
23249 | const offset2 = `${Math.abs(point - min2) / range2 * 100}%`;
|
23250 | const isActived = point <= upperBound && point >= lowerBound;
|
23251 | const style = {
|
23252 | left: offset2
|
23253 | };
|
23254 | const pointClassName = classNames({
|
23255 | [`${classPrefix$i}-tick`]: true,
|
23256 | [`${classPrefix$i}-tick-active`]: isActived
|
23257 | });
|
23258 | return React$1.createElement("span", {
|
23259 | className: pointClassName,
|
23260 | style,
|
23261 | key: point
|
23262 | });
|
23263 | });
|
23264 | return React$1.createElement("div", {
|
23265 | className: `${classPrefix$i}-ticks`
|
23266 | }, elements);
|
23267 | };
|
23268 | const Ticks$1 = Ticks;
|
23269 | const classPrefix$h = `adm-slider-mark`;
|
23270 | const Marks = ({
|
23271 | marks,
|
23272 | upperBound,
|
23273 | lowerBound,
|
23274 | max: max2,
|
23275 | min: min2
|
23276 | }) => {
|
23277 | const marksKeys = Object.keys(marks);
|
23278 | const range2 = max2 - min2;
|
23279 | const elements = marksKeys.map(parseFloat).sort((a, b) => a - b).filter((point) => point >= min2 && point <= max2).map((point) => {
|
23280 | const markPoint = marks[point];
|
23281 | if (!markPoint && markPoint !== 0) {
|
23282 | return null;
|
23283 | }
|
23284 | const isActive = point <= upperBound && point >= lowerBound;
|
23285 | const markClassName = classNames({
|
23286 | [`${classPrefix$h}-text`]: true,
|
23287 | [`${classPrefix$h}-text-active`]: isActive
|
23288 | });
|
23289 | const style = {
|
23290 | left: `${(point - min2) / range2 * 100}%`
|
23291 | };
|
23292 | return React$1.createElement("span", {
|
23293 | className: markClassName,
|
23294 | style,
|
23295 | key: point
|
23296 | }, markPoint);
|
23297 | });
|
23298 | return React$1.createElement("div", {
|
23299 | className: classPrefix$h
|
23300 | }, elements);
|
23301 | };
|
23302 | const Marks$1 = Marks;
|
23303 | function supportBigInt() {
|
23304 | return typeof BigInt === "function";
|
23305 | }
|
23306 | function isEmpty(value) {
|
23307 | return !value && value !== 0 && !Number.isNaN(value) || !String(value).trim();
|
23308 | }
|
23309 | function trimNumber(numStr) {
|
23310 | var str = numStr.trim();
|
23311 | var negative = str.startsWith("-");
|
23312 | if (negative) {
|
23313 | str = str.slice(1);
|
23314 | }
|
23315 | str = str.replace(/(\.\d*[^0])0*$/, "$1").replace(/\.0*$/, "").replace(/^0+/, "");
|
23316 | if (str.startsWith(".")) {
|
23317 | str = "0".concat(str);
|
23318 | }
|
23319 | var trimStr = str || "0";
|
23320 | var splitNumber = trimStr.split(".");
|
23321 | var integerStr = splitNumber[0] || "0";
|
23322 | var decimalStr = splitNumber[1] || "0";
|
23323 | if (integerStr === "0" && decimalStr === "0") {
|
23324 | negative = false;
|
23325 | }
|
23326 | var negativeStr = negative ? "-" : "";
|
23327 | return {
|
23328 | negative,
|
23329 | negativeStr,
|
23330 | trimStr,
|
23331 | integerStr,
|
23332 | decimalStr,
|
23333 | fullStr: "".concat(negativeStr).concat(trimStr)
|
23334 | };
|
23335 | }
|
23336 | function isE(number) {
|
23337 | var str = String(number);
|
23338 | return !Number.isNaN(Number(str)) && str.includes("e");
|
23339 | }
|
23340 | function getNumberPrecision(number) {
|
23341 | var numStr = String(number);
|
23342 | if (isE(number)) {
|
23343 | var precision = Number(numStr.slice(numStr.indexOf("e-") + 2));
|
23344 | var decimalMatch = numStr.match(/\.(\d+)/);
|
23345 | if (decimalMatch !== null && decimalMatch !== void 0 && decimalMatch[1]) {
|
23346 | precision += decimalMatch[1].length;
|
23347 | }
|
23348 | return precision;
|
23349 | }
|
23350 | return numStr.includes(".") && validateNumber(numStr) ? numStr.length - numStr.indexOf(".") - 1 : 0;
|
23351 | }
|
23352 | function num2str(number) {
|
23353 | var numStr = String(number);
|
23354 | if (isE(number)) {
|
23355 | if (number > Number.MAX_SAFE_INTEGER) {
|
23356 | return String(supportBigInt() ? BigInt(number).toString() : Number.MAX_SAFE_INTEGER);
|
23357 | }
|
23358 | if (number < Number.MIN_SAFE_INTEGER) {
|
23359 | return String(supportBigInt() ? BigInt(number).toString() : Number.MIN_SAFE_INTEGER);
|
23360 | }
|
23361 | numStr = number.toFixed(getNumberPrecision(numStr));
|
23362 | }
|
23363 | return trimNumber(numStr).fullStr;
|
23364 | }
|
23365 | function validateNumber(num) {
|
23366 | if (typeof num === "number") {
|
23367 | return !Number.isNaN(num);
|
23368 | }
|
23369 | if (!num) {
|
23370 | return false;
|
23371 | }
|
23372 | return (
|
23373 |
|
23374 | /^\s*-?\d+(\.\d+)?\s*$/.test(num) ||
|
23375 | /^\s*-?\d+\.\s*$/.test(num) ||
|
23376 | /^\s*-?\.\d+\s*$/.test(num)
|
23377 | );
|
23378 | }
|
23379 | var BigIntDecimal = function() {
|
23380 | function BigIntDecimal2(value) {
|
23381 | _classCallCheck(this, BigIntDecimal2);
|
23382 | _defineProperty(this, "origin", "");
|
23383 | _defineProperty(this, "negative", void 0);
|
23384 | _defineProperty(this, "integer", void 0);
|
23385 | _defineProperty(this, "decimal", void 0);
|
23386 | _defineProperty(this, "decimalLen", void 0);
|
23387 | _defineProperty(this, "empty", void 0);
|
23388 | _defineProperty(this, "nan", void 0);
|
23389 | if (isEmpty(value)) {
|
23390 | this.empty = true;
|
23391 | return;
|
23392 | }
|
23393 | this.origin = String(value);
|
23394 | if (value === "-" || Number.isNaN(value)) {
|
23395 | this.nan = true;
|
23396 | return;
|
23397 | }
|
23398 | var mergedValue = value;
|
23399 | if (isE(mergedValue)) {
|
23400 | mergedValue = Number(mergedValue);
|
23401 | }
|
23402 | mergedValue = typeof mergedValue === "string" ? mergedValue : num2str(mergedValue);
|
23403 | if (validateNumber(mergedValue)) {
|
23404 | var trimRet = trimNumber(mergedValue);
|
23405 | this.negative = trimRet.negative;
|
23406 | var numbers = trimRet.trimStr.split(".");
|
23407 | this.integer = BigInt(numbers[0]);
|
23408 | var decimalStr = numbers[1] || "0";
|
23409 | this.decimal = BigInt(decimalStr);
|
23410 | this.decimalLen = decimalStr.length;
|
23411 | } else {
|
23412 | this.nan = true;
|
23413 | }
|
23414 | }
|
23415 | _createClass(BigIntDecimal2, [{
|
23416 | key: "getMark",
|
23417 | value: function getMark() {
|
23418 | return this.negative ? "-" : "";
|
23419 | }
|
23420 | }, {
|
23421 | key: "getIntegerStr",
|
23422 | value: function getIntegerStr() {
|
23423 | return this.integer.toString();
|
23424 | }
|
23425 | |
23426 |
|
23427 |
|
23428 | }, {
|
23429 | key: "getDecimalStr",
|
23430 | value: function getDecimalStr() {
|
23431 | return this.decimal.toString().padStart(this.decimalLen, "0");
|
23432 | }
|
23433 | |
23434 |
|
23435 |
|
23436 |
|
23437 | }, {
|
23438 | key: "alignDecimal",
|
23439 | value: function alignDecimal(decimalLength) {
|
23440 | var str = "".concat(this.getMark()).concat(this.getIntegerStr()).concat(this.getDecimalStr().padEnd(decimalLength, "0"));
|
23441 | return BigInt(str);
|
23442 | }
|
23443 | }, {
|
23444 | key: "negate",
|
23445 | value: function negate() {
|
23446 | var clone = new BigIntDecimal2(this.toString());
|
23447 | clone.negative = !clone.negative;
|
23448 | return clone;
|
23449 | }
|
23450 | }, {
|
23451 | key: "cal",
|
23452 | value: function cal(offset2, calculator, calDecimalLen) {
|
23453 | var maxDecimalLength = Math.max(this.getDecimalStr().length, offset2.getDecimalStr().length);
|
23454 | var myAlignedDecimal = this.alignDecimal(maxDecimalLength);
|
23455 | var offsetAlignedDecimal = offset2.alignDecimal(maxDecimalLength);
|
23456 | var valueStr = calculator(myAlignedDecimal, offsetAlignedDecimal).toString();
|
23457 | var nextDecimalLength = calDecimalLen(maxDecimalLength);
|
23458 | var _trimNumber = trimNumber(valueStr), negativeStr = _trimNumber.negativeStr, trimStr = _trimNumber.trimStr;
|
23459 | var hydrateValueStr = "".concat(negativeStr).concat(trimStr.padStart(nextDecimalLength + 1, "0"));
|
23460 | return new BigIntDecimal2("".concat(hydrateValueStr.slice(0, -nextDecimalLength), ".").concat(hydrateValueStr.slice(-nextDecimalLength)));
|
23461 | }
|
23462 | }, {
|
23463 | key: "add",
|
23464 | value: function add(value) {
|
23465 | if (this.isInvalidate()) {
|
23466 | return new BigIntDecimal2(value);
|
23467 | }
|
23468 | var offset2 = new BigIntDecimal2(value);
|
23469 | if (offset2.isInvalidate()) {
|
23470 | return this;
|
23471 | }
|
23472 | return this.cal(offset2, function(num1, num2) {
|
23473 | return num1 + num2;
|
23474 | }, function(len) {
|
23475 | return len;
|
23476 | });
|
23477 | }
|
23478 | }, {
|
23479 | key: "multi",
|
23480 | value: function multi(value) {
|
23481 | var target = new BigIntDecimal2(value);
|
23482 | if (this.isInvalidate() || target.isInvalidate()) {
|
23483 | return new BigIntDecimal2(NaN);
|
23484 | }
|
23485 | return this.cal(target, function(num1, num2) {
|
23486 | return num1 * num2;
|
23487 | }, function(len) {
|
23488 | return len * 2;
|
23489 | });
|
23490 | }
|
23491 | }, {
|
23492 | key: "isEmpty",
|
23493 | value: function isEmpty2() {
|
23494 | return this.empty;
|
23495 | }
|
23496 | }, {
|
23497 | key: "isNaN",
|
23498 | value: function isNaN2() {
|
23499 | return this.nan;
|
23500 | }
|
23501 | }, {
|
23502 | key: "isInvalidate",
|
23503 | value: function isInvalidate() {
|
23504 | return this.isEmpty() || this.isNaN();
|
23505 | }
|
23506 | }, {
|
23507 | key: "equals",
|
23508 | value: function equals(target) {
|
23509 | return this.toString() === (target === null || target === void 0 ? void 0 : target.toString());
|
23510 | }
|
23511 | }, {
|
23512 | key: "lessEquals",
|
23513 | value: function lessEquals(target) {
|
23514 | return this.add(target.negate().toString()).toNumber() <= 0;
|
23515 | }
|
23516 | }, {
|
23517 | key: "toNumber",
|
23518 | value: function toNumber2() {
|
23519 | if (this.isNaN()) {
|
23520 | return NaN;
|
23521 | }
|
23522 | return Number(this.toString());
|
23523 | }
|
23524 | }, {
|
23525 | key: "toString",
|
23526 | value: function toString() {
|
23527 | var safe = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
|
23528 | if (!safe) {
|
23529 | return this.origin;
|
23530 | }
|
23531 | if (this.isInvalidate()) {
|
23532 | return "";
|
23533 | }
|
23534 | return trimNumber("".concat(this.getMark()).concat(this.getIntegerStr(), ".").concat(this.getDecimalStr())).fullStr;
|
23535 | }
|
23536 | }]);
|
23537 | return BigIntDecimal2;
|
23538 | }();
|
23539 | var NumberDecimal = function() {
|
23540 | function NumberDecimal2(value) {
|
23541 | _classCallCheck(this, NumberDecimal2);
|
23542 | _defineProperty(this, "origin", "");
|
23543 | _defineProperty(this, "number", void 0);
|
23544 | _defineProperty(this, "empty", void 0);
|
23545 | if (isEmpty(value)) {
|
23546 | this.empty = true;
|
23547 | return;
|
23548 | }
|
23549 | this.origin = String(value);
|
23550 | this.number = Number(value);
|
23551 | }
|
23552 | _createClass(NumberDecimal2, [{
|
23553 | key: "negate",
|
23554 | value: function negate() {
|
23555 | return new NumberDecimal2(-this.toNumber());
|
23556 | }
|
23557 | }, {
|
23558 | key: "add",
|
23559 | value: function add(value) {
|
23560 | if (this.isInvalidate()) {
|
23561 | return new NumberDecimal2(value);
|
23562 | }
|
23563 | var target = Number(value);
|
23564 | if (Number.isNaN(target)) {
|
23565 | return this;
|
23566 | }
|
23567 | var number = this.number + target;
|
23568 | if (number > Number.MAX_SAFE_INTEGER) {
|
23569 | return new NumberDecimal2(Number.MAX_SAFE_INTEGER);
|
23570 | }
|
23571 | if (number < Number.MIN_SAFE_INTEGER) {
|
23572 | return new NumberDecimal2(Number.MIN_SAFE_INTEGER);
|
23573 | }
|
23574 | var maxPrecision = Math.max(getNumberPrecision(this.number), getNumberPrecision(target));
|
23575 | return new NumberDecimal2(number.toFixed(maxPrecision));
|
23576 | }
|
23577 | }, {
|
23578 | key: "multi",
|
23579 | value: function multi(value) {
|
23580 | var target = Number(value);
|
23581 | if (this.isInvalidate() || Number.isNaN(target)) {
|
23582 | return new NumberDecimal2(NaN);
|
23583 | }
|
23584 | var number = this.number * target;
|
23585 | if (number > Number.MAX_SAFE_INTEGER) {
|
23586 | return new NumberDecimal2(Number.MAX_SAFE_INTEGER);
|
23587 | }
|
23588 | if (number < Number.MIN_SAFE_INTEGER) {
|
23589 | return new NumberDecimal2(Number.MIN_SAFE_INTEGER);
|
23590 | }
|
23591 | var maxPrecision = Math.max(getNumberPrecision(this.number), getNumberPrecision(target));
|
23592 | return new NumberDecimal2(number.toFixed(maxPrecision));
|
23593 | }
|
23594 | }, {
|
23595 | key: "isEmpty",
|
23596 | value: function isEmpty2() {
|
23597 | return this.empty;
|
23598 | }
|
23599 | }, {
|
23600 | key: "isNaN",
|
23601 | value: function isNaN2() {
|
23602 | return Number.isNaN(this.number);
|
23603 | }
|
23604 | }, {
|
23605 | key: "isInvalidate",
|
23606 | value: function isInvalidate() {
|
23607 | return this.isEmpty() || this.isNaN();
|
23608 | }
|
23609 | }, {
|
23610 | key: "equals",
|
23611 | value: function equals(target) {
|
23612 | return this.toNumber() === (target === null || target === void 0 ? void 0 : target.toNumber());
|
23613 | }
|
23614 | }, {
|
23615 | key: "lessEquals",
|
23616 | value: function lessEquals(target) {
|
23617 | return this.add(target.negate().toString()).toNumber() <= 0;
|
23618 | }
|
23619 | }, {
|
23620 | key: "toNumber",
|
23621 | value: function toNumber2() {
|
23622 | return this.number;
|
23623 | }
|
23624 | }, {
|
23625 | key: "toString",
|
23626 | value: function toString() {
|
23627 | var safe = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
|
23628 | if (!safe) {
|
23629 | return this.origin;
|
23630 | }
|
23631 | if (this.isInvalidate()) {
|
23632 | return "";
|
23633 | }
|
23634 | return num2str(this.number);
|
23635 | }
|
23636 | }]);
|
23637 | return NumberDecimal2;
|
23638 | }();
|
23639 | function getMiniDecimal(value) {
|
23640 | if (supportBigInt()) {
|
23641 | return new BigIntDecimal(value);
|
23642 | }
|
23643 | return new NumberDecimal(value);
|
23644 | }
|
23645 | function toFixed(numStr, separatorStr, precision) {
|
23646 | var cutOnly = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false;
|
23647 | if (numStr === "") {
|
23648 | return "";
|
23649 | }
|
23650 | var _trimNumber = trimNumber(numStr), negativeStr = _trimNumber.negativeStr, integerStr = _trimNumber.integerStr, decimalStr = _trimNumber.decimalStr;
|
23651 | var precisionDecimalStr = "".concat(separatorStr).concat(decimalStr);
|
23652 | var numberWithoutDecimal = "".concat(negativeStr).concat(integerStr);
|
23653 | if (precision >= 0) {
|
23654 | var advancedNum = Number(decimalStr[precision]);
|
23655 | if (advancedNum >= 5 && !cutOnly) {
|
23656 | var advancedDecimal = getMiniDecimal(numStr).add("".concat(negativeStr, "0.").concat("0".repeat(precision)).concat(10 - advancedNum));
|
23657 | return toFixed(advancedDecimal.toString(), separatorStr, precision, cutOnly);
|
23658 | }
|
23659 | if (precision === 0) {
|
23660 | return numberWithoutDecimal;
|
23661 | }
|
23662 | return "".concat(numberWithoutDecimal).concat(separatorStr).concat(decimalStr.padEnd(precision, "0").slice(0, precision));
|
23663 | }
|
23664 | if (precisionDecimalStr === ".0") {
|
23665 | return numberWithoutDecimal;
|
23666 | }
|
23667 | return "".concat(numberWithoutDecimal).concat(precisionDecimalStr);
|
23668 | }
|
23669 | const ThumbIcon = (props) => {
|
23670 | return withNativeProps(props, React$1.createElement("svg", {
|
23671 | viewBox: "0 0 24 24",
|
23672 | xmlns: "http://www.w3.org/2000/svg"
|
23673 | }, React$1.createElement("g", {
|
23674 | fill: "currentColor",
|
23675 | fillRule: "evenodd"
|
23676 | }, React$1.createElement("rect", {
|
23677 | x: 10,
|
23678 | width: 4,
|
23679 | height: 24,
|
23680 | rx: 2
|
23681 | }), React$1.createElement("rect", {
|
23682 | y: 4,
|
23683 | width: 4,
|
23684 | height: 16,
|
23685 | rx: 2
|
23686 | }), React$1.createElement("rect", {
|
23687 | x: 20,
|
23688 | y: 4,
|
23689 | width: 4,
|
23690 | height: 16,
|
23691 | rx: 2
|
23692 | }))));
|
23693 | };
|
23694 | const classPrefix$g = `adm-slider`;
|
23695 | const Thumb = (props) => {
|
23696 | const {
|
23697 | value,
|
23698 | min: min2,
|
23699 | max: max2,
|
23700 | disabled,
|
23701 | icon,
|
23702 | residentPopover,
|
23703 | onDrag
|
23704 | } = props;
|
23705 | const prevValue = React$1.useRef(value);
|
23706 | const {
|
23707 | locale
|
23708 | } = useConfig();
|
23709 | const currentPosition = () => {
|
23710 | return {
|
23711 | left: `${(value - min2) / (max2 - min2) * 100}%`,
|
23712 | right: "auto"
|
23713 | };
|
23714 | };
|
23715 | const [dragging, setDragging] = React$1.useState(false);
|
23716 | const bind = useDrag((state) => {
|
23717 | var _a;
|
23718 | if (disabled)
|
23719 | return;
|
23720 | if (state.first) {
|
23721 | prevValue.current = value;
|
23722 | }
|
23723 | const x = state.xy[0] - state.initial[0];
|
23724 | const sliderOffsetWith = (_a = props.trackRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth;
|
23725 | if (!sliderOffsetWith)
|
23726 | return;
|
23727 | const diff = x / Math.ceil(sliderOffsetWith) * (max2 - min2);
|
23728 | onDrag(prevValue.current + diff, state.first, state.last);
|
23729 | setDragging(!state.last);
|
23730 | }, {
|
23731 | axis: "x",
|
23732 | pointer: {
|
23733 | touch: true
|
23734 | }
|
23735 | });
|
23736 | const renderPopoverContent = typeof props.popover === "function" ? props.popover : props.popover ? (value2) => value2.toString() : null;
|
23737 | const thumbElement = React$1.createElement("div", {
|
23738 | className: `${classPrefix$g}-thumb`
|
23739 | }, icon ? icon : React$1.createElement(ThumbIcon, {
|
23740 | className: `${classPrefix$g}-thumb-icon`
|
23741 | }));
|
23742 | return React$1.createElement("div", Object.assign({
|
23743 | className: `${classPrefix$g}-thumb-container`,
|
23744 | style: currentPosition()
|
23745 | }, bind(), {
|
23746 | role: "slider",
|
23747 | "aria-label": props["aria-label"] || locale.Slider.name,
|
23748 | "aria-valuemax": max2,
|
23749 | "aria-valuemin": min2,
|
23750 | "aria-valuenow": value,
|
23751 | "aria-disabled": disabled
|
23752 | }), renderPopoverContent ? React$1.createElement(Popover, {
|
23753 | content: renderPopoverContent(value),
|
23754 | placement: "top",
|
23755 | visible: residentPopover || dragging,
|
23756 | getContainer: null,
|
23757 | mode: "dark"
|
23758 | }, thumbElement) : thumbElement);
|
23759 | };
|
23760 | const Thumb$1 = Thumb;
|
23761 | const classPrefix$f = `adm-slider`;
|
23762 | const defaultProps$e = {
|
23763 | min: 0,
|
23764 | max: 100,
|
23765 | step: 1,
|
23766 | ticks: false,
|
23767 | range: false,
|
23768 | disabled: false,
|
23769 | popover: false,
|
23770 | residentPopover: false
|
23771 | };
|
23772 | const Slider = (p) => {
|
23773 | var _a;
|
23774 | const props = mergeProps(defaultProps$e, p);
|
23775 | const {
|
23776 | min: min2,
|
23777 | max: max2,
|
23778 | disabled,
|
23779 | marks,
|
23780 | ticks,
|
23781 | step,
|
23782 | icon
|
23783 | } = props;
|
23784 | function sortValue(val) {
|
23785 | return val.sort((a, b) => a - b);
|
23786 | }
|
23787 | function convertValue(value) {
|
23788 | return props.range ? value : [props.min, value];
|
23789 | }
|
23790 | function alignValue(value, decimalLen) {
|
23791 | const decimal = getMiniDecimal(value);
|
23792 | const fixedStr = toFixed(decimal.toString(), ".", decimalLen);
|
23793 | return getMiniDecimal(fixedStr).toNumber();
|
23794 | }
|
23795 | function reverseValue(value) {
|
23796 | const mergedDecimalLen = Math.max(getDecimalLen(step), getDecimalLen(value[0]), getDecimalLen(value[1]));
|
23797 | return props.range ? value.map((v) => alignValue(v, mergedDecimalLen)) : alignValue(value[1], mergedDecimalLen);
|
23798 | }
|
23799 | function getDecimalLen(n2) {
|
23800 | return (`${n2}`.split(".")[1] || "").length;
|
23801 | }
|
23802 | function onAfterChange(value) {
|
23803 | var _a2;
|
23804 | (_a2 = props.onAfterChange) === null || _a2 === void 0 ? void 0 : _a2.call(props, reverseValue(value));
|
23805 | }
|
23806 | let propsValue = props.value;
|
23807 | if (props.range && typeof props.value === "number") {
|
23808 | devWarning("Slider", "When `range` prop is enabled, the `value` prop should be an array, like: [0, 0]");
|
23809 | propsValue = [0, props.value];
|
23810 | }
|
23811 | const [rawValue, setRawValue] = usePropsValue({
|
23812 | value: propsValue,
|
23813 | defaultValue: (_a = props.defaultValue) !== null && _a !== void 0 ? _a : props.range ? [min2, min2] : min2,
|
23814 | onChange: props.onChange
|
23815 | });
|
23816 | const sliderValue = sortValue(convertValue(rawValue));
|
23817 | function setSliderValue(value) {
|
23818 | const next = sortValue(value);
|
23819 | const current = sliderValue;
|
23820 | if (next[0] === current[0] && next[1] === current[1])
|
23821 | return;
|
23822 | setRawValue(reverseValue(next));
|
23823 | }
|
23824 | const trackRef = React$1.useRef(null);
|
23825 | const fillSize = `${100 * (sliderValue[1] - sliderValue[0]) / (max2 - min2)}%`;
|
23826 | const fillStart = `${100 * (sliderValue[0] - min2) / (max2 - min2)}%`;
|
23827 | const pointList = React$1.useMemo(() => {
|
23828 | if (marks) {
|
23829 | return Object.keys(marks).map(parseFloat).sort((a, b) => a - b);
|
23830 | } else if (ticks) {
|
23831 | const points = [];
|
23832 | for (let i2 = getMiniDecimal(min2); i2.lessEquals(getMiniDecimal(max2)); i2 = i2.add(step)) {
|
23833 | points.push(i2.toNumber());
|
23834 | }
|
23835 | return points;
|
23836 | }
|
23837 | return [];
|
23838 | }, [marks, ticks, step, min2, max2]);
|
23839 | function getValueByPosition(position) {
|
23840 | const newPosition = position < min2 ? min2 : position > max2 ? max2 : position;
|
23841 | let value = min2;
|
23842 | if (pointList.length) {
|
23843 | value = nearest(pointList, newPosition);
|
23844 | } else {
|
23845 | const cell = Math.round((newPosition - min2) / step);
|
23846 | const nextVal = getMiniDecimal(cell).multi(step);
|
23847 | value = getMiniDecimal(min2).add(nextVal.toString()).toNumber();
|
23848 | }
|
23849 | return value;
|
23850 | }
|
23851 | const dragLockRef = React$1.useRef(0);
|
23852 | const onTrackClick = (event) => {
|
23853 | if (dragLockRef.current > 0)
|
23854 | return;
|
23855 | event.stopPropagation();
|
23856 | if (disabled)
|
23857 | return;
|
23858 | const track = trackRef.current;
|
23859 | if (!track)
|
23860 | return;
|
23861 | const sliderOffsetLeft = track.getBoundingClientRect().left;
|
23862 | const position = (event.clientX - sliderOffsetLeft) / Math.ceil(track.offsetWidth) * (max2 - min2) + min2;
|
23863 | const targetValue = getValueByPosition(position);
|
23864 | let nextSliderValue;
|
23865 | if (props.range) {
|
23866 | if (Math.abs(targetValue - sliderValue[0]) > Math.abs(targetValue - sliderValue[1])) {
|
23867 | nextSliderValue = [sliderValue[0], targetValue];
|
23868 | } else {
|
23869 | nextSliderValue = [targetValue, sliderValue[1]];
|
23870 | }
|
23871 | } else {
|
23872 | nextSliderValue = [props.min, targetValue];
|
23873 | }
|
23874 | setSliderValue(nextSliderValue);
|
23875 | onAfterChange(nextSliderValue);
|
23876 | };
|
23877 | const valueBeforeDragRef = React$1.useRef();
|
23878 | const renderThumb = (index2) => {
|
23879 | return React$1.createElement(Thumb$1, {
|
23880 | key: index2,
|
23881 | value: sliderValue[index2],
|
23882 | min: min2,
|
23883 | max: max2,
|
23884 | disabled,
|
23885 | trackRef,
|
23886 | icon,
|
23887 | popover: props.popover,
|
23888 | residentPopover: props.residentPopover,
|
23889 | onDrag: (position, first, last) => {
|
23890 | if (first) {
|
23891 | dragLockRef.current += 1;
|
23892 | valueBeforeDragRef.current = sliderValue;
|
23893 | }
|
23894 | const val = getValueByPosition(position);
|
23895 | const valueBeforeDrag = valueBeforeDragRef.current;
|
23896 | if (!valueBeforeDrag)
|
23897 | return;
|
23898 | const next = [...valueBeforeDrag];
|
23899 | next[index2] = val;
|
23900 | setSliderValue(next);
|
23901 | if (last) {
|
23902 | onAfterChange(next);
|
23903 | window.setTimeout(() => {
|
23904 | dragLockRef.current -= 1;
|
23905 | }, 100);
|
23906 | }
|
23907 | },
|
23908 | "aria-label": props["aria-label"]
|
23909 | });
|
23910 | };
|
23911 | return withNativeProps(props, React$1.createElement("div", {
|
23912 | className: classNames(classPrefix$f, {
|
23913 | [`${classPrefix$f}-disabled`]: disabled
|
23914 | })
|
23915 | }, React$1.createElement("div", {
|
23916 | className: `${classPrefix$f}-track-container`,
|
23917 | onClick: onTrackClick
|
23918 | }, React$1.createElement("div", {
|
23919 | className: `${classPrefix$f}-track`,
|
23920 | onClick: onTrackClick,
|
23921 | ref: trackRef
|
23922 | }, React$1.createElement("div", {
|
23923 | className: `${classPrefix$f}-fill`,
|
23924 | style: {
|
23925 | width: fillSize,
|
23926 | left: fillStart
|
23927 | }
|
23928 | }), props.ticks && React$1.createElement(Ticks$1, {
|
23929 | points: pointList,
|
23930 | min: min2,
|
23931 | max: max2,
|
23932 | lowerBound: sliderValue[0],
|
23933 | upperBound: sliderValue[1]
|
23934 | }), props.range && renderThumb(0), renderThumb(1))), marks && React$1.createElement(Marks$1, {
|
23935 | min: min2,
|
23936 | max: max2,
|
23937 | marks,
|
23938 | lowerBound: sliderValue[0],
|
23939 | upperBound: sliderValue[1]
|
23940 | })));
|
23941 | };
|
23942 | const classPrefix$e = `adm-stepper`;
|
23943 | const defaultProps$d = {
|
23944 | step: 1,
|
23945 | disabled: false,
|
23946 | allowEmpty: false
|
23947 | };
|
23948 | function InnerStepper(p, ref) {
|
23949 | const props = mergeProps(defaultProps$d, p);
|
23950 | const {
|
23951 | defaultValue = 0,
|
23952 | value,
|
23953 | onChange,
|
23954 | disabled,
|
23955 | step,
|
23956 | max: max2,
|
23957 | min: min2,
|
23958 | inputReadOnly,
|
23959 | digits,
|
23960 | stringMode,
|
23961 | formatter,
|
23962 | parser
|
23963 | } = props;
|
23964 | const {
|
23965 | locale
|
23966 | } = useConfig();
|
23967 | React$1.useImperativeHandle(ref, () => ({
|
23968 | focus: () => {
|
23969 | var _a;
|
23970 | (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
23971 | },
|
23972 | blur: () => {
|
23973 | var _a;
|
23974 | (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
23975 | },
|
23976 | get nativeElement() {
|
23977 | var _a, _b;
|
23978 | return (_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.nativeElement) !== null && _b !== void 0 ? _b : null;
|
23979 | }
|
23980 | }));
|
23981 | const fixedValue = (value2) => {
|
23982 | const fixedValue2 = digits !== void 0 ? toFixed(value2.toString(), ".", digits) : value2;
|
23983 | return fixedValue2.toString();
|
23984 | };
|
23985 | const getValueAsType = (value2) => stringMode ? value2.toString() : value2.toNumber();
|
23986 | const parseValue = (text) => {
|
23987 | if (text === "")
|
23988 | return null;
|
23989 | if (parser) {
|
23990 | return String(parser(text));
|
23991 | }
|
23992 | const decimal = getMiniDecimal(text);
|
23993 | return decimal.isInvalidate() ? null : decimal.toString();
|
23994 | };
|
23995 | const formatValue = (value2) => {
|
23996 | if (value2 === null)
|
23997 | return "";
|
23998 | return formatter ? formatter(value2) : fixedValue(value2);
|
23999 | };
|
24000 | const [mergedValue, setMergedValue] = useMergedState(defaultValue, {
|
24001 | value,
|
24002 | onChange: (nextValue) => {
|
24003 | onChange === null || onChange === void 0 ? void 0 : onChange(nextValue);
|
24004 | }
|
24005 | });
|
24006 | const [inputValue, setInputValue] = React$1.useState(() => formatValue(mergedValue));
|
24007 | function setValueWithCheck(nextValue) {
|
24008 | if (nextValue.isNaN())
|
24009 | return;
|
24010 | let target = nextValue;
|
24011 | if (min2 !== void 0) {
|
24012 | const minDecimal = getMiniDecimal(min2);
|
24013 | if (target.lessEquals(minDecimal)) {
|
24014 | target = minDecimal;
|
24015 | }
|
24016 | }
|
24017 | if (max2 !== void 0) {
|
24018 | const maxDecimal = getMiniDecimal(max2);
|
24019 | if (maxDecimal.lessEquals(target)) {
|
24020 | target = maxDecimal;
|
24021 | }
|
24022 | }
|
24023 | if (digits !== void 0) {
|
24024 | target = getMiniDecimal(fixedValue(getValueAsType(target)));
|
24025 | }
|
24026 | setMergedValue(getValueAsType(target));
|
24027 | }
|
24028 | const handleInputChange = (v) => {
|
24029 | setInputValue(v);
|
24030 | const valueStr = parseValue(v);
|
24031 | if (valueStr === null) {
|
24032 | if (props.allowEmpty) {
|
24033 | setMergedValue(null);
|
24034 | } else {
|
24035 | setMergedValue(defaultValue);
|
24036 | }
|
24037 | } else {
|
24038 | setValueWithCheck(getMiniDecimal(valueStr));
|
24039 | }
|
24040 | };
|
24041 | const [focused, setFocused] = React$1.useState(false);
|
24042 | const inputRef = React$1.useRef(null);
|
24043 | function triggerFocus(nextFocus) {
|
24044 | setFocused(nextFocus);
|
24045 | if (nextFocus) {
|
24046 | setInputValue(mergedValue !== null && mergedValue !== void 0 ? String(mergedValue) : "");
|
24047 | }
|
24048 | }
|
24049 | React$1.useEffect(() => {
|
24050 | var _a, _b, _c;
|
24051 | if (focused) {
|
24052 | (_c = (_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.nativeElement) === null || _b === void 0 ? void 0 : _b.select) === null || _c === void 0 ? void 0 : _c.call(_b);
|
24053 | }
|
24054 | }, [focused]);
|
24055 | React$1.useEffect(() => {
|
24056 | if (!focused) {
|
24057 | setInputValue(formatValue(mergedValue));
|
24058 | }
|
24059 | }, [focused, mergedValue, digits]);
|
24060 | const handleOffset = (positive) => {
|
24061 | let stepValue = getMiniDecimal(step);
|
24062 | if (!positive) {
|
24063 | stepValue = stepValue.negate();
|
24064 | }
|
24065 | setValueWithCheck(getMiniDecimal(mergedValue !== null && mergedValue !== void 0 ? mergedValue : 0).add(stepValue.toString()));
|
24066 | };
|
24067 | const handleMinus = () => {
|
24068 | handleOffset(false);
|
24069 | };
|
24070 | const handlePlus = () => {
|
24071 | handleOffset(true);
|
24072 | };
|
24073 | const minusDisabled = () => {
|
24074 | if (disabled)
|
24075 | return true;
|
24076 | if (mergedValue === null)
|
24077 | return false;
|
24078 | if (min2 !== void 0) {
|
24079 | return mergedValue <= min2;
|
24080 | }
|
24081 | return false;
|
24082 | };
|
24083 | const plusDisabled = () => {
|
24084 | if (disabled)
|
24085 | return true;
|
24086 | if (mergedValue === null)
|
24087 | return false;
|
24088 | if (max2 !== void 0) {
|
24089 | return mergedValue >= max2;
|
24090 | }
|
24091 | return false;
|
24092 | };
|
24093 | return withNativeProps(props, React$1.createElement("div", {
|
24094 | className: classNames(classPrefix$e, {
|
24095 | [`${classPrefix$e}-active`]: focused
|
24096 | })
|
24097 | }, React$1.createElement(Button, {
|
24098 | className: `${classPrefix$e}-minus`,
|
24099 | onClick: handleMinus,
|
24100 | disabled: minusDisabled(),
|
24101 | fill: "none",
|
24102 | shape: "rectangular",
|
24103 | color: "primary",
|
24104 | "aria-label": locale.Stepper.decrease
|
24105 | }, React$1.createElement(MinusOutline, null)), React$1.createElement("div", {
|
24106 | className: `${classPrefix$e}-middle`
|
24107 | }, React$1.createElement(Input, {
|
24108 | ref: inputRef,
|
24109 | className: `${classPrefix$e}-input`,
|
24110 | onFocus: (e2) => {
|
24111 | var _a;
|
24112 | triggerFocus(true);
|
24113 | (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, e2);
|
24114 | },
|
24115 | value: inputValue,
|
24116 | onChange: (val) => {
|
24117 | disabled || handleInputChange(val);
|
24118 | },
|
24119 | disabled,
|
24120 | onBlur: (e2) => {
|
24121 | var _a;
|
24122 | triggerFocus(false);
|
24123 | (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e2);
|
24124 | },
|
24125 | readOnly: inputReadOnly,
|
24126 | role: "spinbutton",
|
24127 | "aria-valuenow": Number(inputValue),
|
24128 | "aria-valuemax": Number(max2),
|
24129 | "aria-valuemin": Number(min2),
|
24130 | inputMode: "decimal"
|
24131 | })), React$1.createElement(Button, {
|
24132 | className: `${classPrefix$e}-plus`,
|
24133 | onClick: handlePlus,
|
24134 | disabled: plusDisabled(),
|
24135 | fill: "none",
|
24136 | shape: "rectangular",
|
24137 | color: "primary",
|
24138 | "aria-label": locale.Stepper.increase
|
24139 | }, React$1.createElement(AddOutline, null))));
|
24140 | }
|
24141 | const Stepper = React$1.forwardRef(InnerStepper);
|
24142 | const classPrefix$d = `adm-step`;
|
24143 | const Step = (props) => {
|
24144 | const {
|
24145 | title,
|
24146 | description,
|
24147 | icon,
|
24148 | status = "wait"
|
24149 | } = props;
|
24150 | return withNativeProps(props, React$1.createElement("div", {
|
24151 | className: classNames(`${classPrefix$d}`, `${classPrefix$d}-status-${status}`)
|
24152 | }, React$1.createElement("div", {
|
24153 | className: `${classPrefix$d}-indicator`
|
24154 | }, React$1.createElement("div", {
|
24155 | className: `${classPrefix$d}-icon-container`
|
24156 | }, icon)), React$1.createElement("div", {
|
24157 | className: `${classPrefix$d}-content`
|
24158 | }, React$1.createElement("div", {
|
24159 | className: `${classPrefix$d}-title`
|
24160 | }, title), !!description && React$1.createElement("div", {
|
24161 | className: `${classPrefix$d}-description`
|
24162 | }, description))));
|
24163 | };
|
24164 | const classPrefix$c = `adm-steps`;
|
24165 | const stepClassPrefix = `adm-step`;
|
24166 | const defaultIcon = React$1.createElement("span", {
|
24167 | className: `${stepClassPrefix}-icon-dot`
|
24168 | });
|
24169 | const defaultProps$c = {
|
24170 | current: 0,
|
24171 | direction: "horizontal"
|
24172 | };
|
24173 | const Steps = (p) => {
|
24174 | const props = mergeProps(defaultProps$c, p);
|
24175 | const {
|
24176 | direction,
|
24177 | current
|
24178 | } = props;
|
24179 | const classString = classNames(classPrefix$c, `${classPrefix$c}-${direction}`);
|
24180 | return withNativeProps(props, React$1.createElement("div", {
|
24181 | className: classString
|
24182 | }, React$1.Children.map(props.children, (child, index2) => {
|
24183 | var _a;
|
24184 | if (!React$1.isValidElement(child)) {
|
24185 | return child;
|
24186 | }
|
24187 | const childProps = child.props;
|
24188 | let status = childProps.status || "wait";
|
24189 | if (index2 < current) {
|
24190 | status = childProps.status || "finish";
|
24191 | } else if (index2 === current) {
|
24192 | status = childProps.status || "process";
|
24193 | }
|
24194 | const icon = (_a = childProps.icon) !== null && _a !== void 0 ? _a : defaultIcon;
|
24195 | return React$1.cloneElement(child, {
|
24196 | status,
|
24197 | icon
|
24198 | });
|
24199 | })));
|
24200 | };
|
24201 | const index$3 = attachPropertiesToComponent(Steps, {
|
24202 | Step
|
24203 | });
|
24204 | const classPrefix$b = `adm-swipe-action`;
|
24205 | const defaultProps$b = {
|
24206 | rightActions: [],
|
24207 | leftActions: [],
|
24208 | closeOnTouchOutside: true,
|
24209 | closeOnAction: true,
|
24210 | stopPropagation: []
|
24211 | };
|
24212 | const SwipeAction = React$1.forwardRef((p, ref) => {
|
24213 | const props = mergeProps(defaultProps$b, p);
|
24214 | const rootRef = React$1.useRef(null);
|
24215 | const leftRef = React$1.useRef(null);
|
24216 | const rightRef = React$1.useRef(null);
|
24217 | function getWidth(ref2) {
|
24218 | const element = ref2.current;
|
24219 | if (!element)
|
24220 | return 0;
|
24221 | return element.offsetWidth;
|
24222 | }
|
24223 | function getLeftWidth() {
|
24224 | return getWidth(leftRef);
|
24225 | }
|
24226 | function getRightWidth() {
|
24227 | return getWidth(rightRef);
|
24228 | }
|
24229 | const [{
|
24230 | x
|
24231 | }, api] = useSpring(() => ({
|
24232 | x: 0,
|
24233 | config: {
|
24234 | tension: 200,
|
24235 | friction: 30
|
24236 | }
|
24237 | }), []);
|
24238 | const draggingRef = React$1.useRef(false);
|
24239 | const dragCancelRef = React$1.useRef(null);
|
24240 | function forceCancelDrag() {
|
24241 | var _a;
|
24242 | (_a = dragCancelRef.current) === null || _a === void 0 ? void 0 : _a.call(dragCancelRef);
|
24243 | draggingRef.current = false;
|
24244 | }
|
24245 | const bind = useDrag((state) => {
|
24246 | var _a;
|
24247 | dragCancelRef.current = state.cancel;
|
24248 | if (!state.intentional)
|
24249 | return;
|
24250 | if (state.down) {
|
24251 | draggingRef.current = true;
|
24252 | }
|
24253 | if (!draggingRef.current)
|
24254 | return;
|
24255 | const [offsetX] = state.offset;
|
24256 | if (state.last) {
|
24257 | const leftWidth = getLeftWidth();
|
24258 | const rightWidth = getRightWidth();
|
24259 | let position = offsetX + state.velocity[0] * state.direction[0] * 50;
|
24260 | if (offsetX > 0) {
|
24261 | position = Math.max(0, position);
|
24262 | } else if (offsetX < 0) {
|
24263 | position = Math.min(0, position);
|
24264 | } else {
|
24265 | position = 0;
|
24266 | }
|
24267 | const targetX = nearest([-rightWidth, 0, leftWidth], position);
|
24268 | api.start({
|
24269 | x: targetX
|
24270 | });
|
24271 | if (targetX !== 0) {
|
24272 | (_a = p.onActionsReveal) === null || _a === void 0 ? void 0 : _a.call(p, targetX > 0 ? "left" : "right");
|
24273 | }
|
24274 | window.setTimeout(() => {
|
24275 | draggingRef.current = false;
|
24276 | });
|
24277 | } else {
|
24278 | api.start({
|
24279 | x: offsetX,
|
24280 | immediate: true
|
24281 | });
|
24282 | }
|
24283 | }, {
|
24284 | from: () => [x.get(), 0],
|
24285 | bounds: () => {
|
24286 | const leftWidth = getLeftWidth();
|
24287 | const rightWidth = getRightWidth();
|
24288 | return {
|
24289 | left: -rightWidth,
|
24290 | right: leftWidth
|
24291 | };
|
24292 | },
|
24293 | axis: "x",
|
24294 | preventScroll: true,
|
24295 | pointer: {
|
24296 | touch: true
|
24297 | },
|
24298 | triggerAllEvents: true
|
24299 | });
|
24300 | function close() {
|
24301 | api.start({
|
24302 | x: 0
|
24303 | });
|
24304 | forceCancelDrag();
|
24305 | }
|
24306 | React$1.useImperativeHandle(ref, () => ({
|
24307 | show: (side = "right") => {
|
24308 | var _a;
|
24309 | if (side === "right") {
|
24310 | api.start({
|
24311 | x: -getRightWidth()
|
24312 | });
|
24313 | } else if (side === "left") {
|
24314 | api.start({
|
24315 | x: getLeftWidth()
|
24316 | });
|
24317 | }
|
24318 | (_a = p.onActionsReveal) === null || _a === void 0 ? void 0 : _a.call(p, side);
|
24319 | },
|
24320 | close
|
24321 | }));
|
24322 | React$1.useEffect(() => {
|
24323 | if (!props.closeOnTouchOutside)
|
24324 | return;
|
24325 | function handle(e2) {
|
24326 | if (x.get() === 0) {
|
24327 | return;
|
24328 | }
|
24329 | const root2 = rootRef.current;
|
24330 | if (root2 && !root2.contains(e2.target)) {
|
24331 | close();
|
24332 | }
|
24333 | }
|
24334 | document.addEventListener("touchstart", handle);
|
24335 | return () => {
|
24336 | document.removeEventListener("touchstart", handle);
|
24337 | };
|
24338 | }, [props.closeOnTouchOutside]);
|
24339 | function renderAction(action) {
|
24340 | var _a, _b;
|
24341 | const color = (_a = action.color) !== null && _a !== void 0 ? _a : "light";
|
24342 | return React$1.createElement(Button, {
|
24343 | key: action.key,
|
24344 | className: `${classPrefix$b}-action-button`,
|
24345 | style: {
|
24346 | "--background-color": (_b = colorRecord$1[color]) !== null && _b !== void 0 ? _b : color
|
24347 | },
|
24348 | onClick: (e2) => {
|
24349 | var _a2, _b2;
|
24350 | if (props.closeOnAction) {
|
24351 | close();
|
24352 | }
|
24353 | (_a2 = action.onClick) === null || _a2 === void 0 ? void 0 : _a2.call(action, e2);
|
24354 | (_b2 = props.onAction) === null || _b2 === void 0 ? void 0 : _b2.call(props, action, e2);
|
24355 | }
|
24356 | }, action.text);
|
24357 | }
|
24358 | return withNativeProps(props, React$1.createElement("div", Object.assign({
|
24359 | className: classPrefix$b
|
24360 | }, bind(), {
|
24361 | ref: rootRef,
|
24362 | onClickCapture: (e2) => {
|
24363 | if (draggingRef.current) {
|
24364 | e2.stopPropagation();
|
24365 | e2.preventDefault();
|
24366 | }
|
24367 | }
|
24368 | }), React$1.createElement(animated.div, {
|
24369 | className: `${classPrefix$b}-track`,
|
24370 | style: {
|
24371 | x
|
24372 | }
|
24373 | }, withStopPropagation(props.stopPropagation, React$1.createElement("div", {
|
24374 | className: `${classPrefix$b}-actions ${classPrefix$b}-actions-left`,
|
24375 | ref: leftRef
|
24376 | }, props.leftActions.map(renderAction))), React$1.createElement("div", {
|
24377 | className: `${classPrefix$b}-content`,
|
24378 | onClickCapture: (e2) => {
|
24379 | if (x.goal !== 0) {
|
24380 | e2.preventDefault();
|
24381 | e2.stopPropagation();
|
24382 | close();
|
24383 | }
|
24384 | }
|
24385 | }, React$1.createElement(animated.div, {
|
24386 | style: {
|
24387 | pointerEvents: x.to((v) => v !== 0 && x.goal !== 0 ? "none" : "auto")
|
24388 | }
|
24389 | }, props.children)), withStopPropagation(props.stopPropagation, React$1.createElement("div", {
|
24390 | className: `${classPrefix$b}-actions ${classPrefix$b}-actions-right`,
|
24391 | ref: rightRef
|
24392 | }, props.rightActions.map(renderAction))))));
|
24393 | });
|
24394 | const colorRecord$1 = {
|
24395 | light: "var(--adm-color-light)",
|
24396 | weak: "var(--adm-color-weak)",
|
24397 | primary: "var(--adm-color-primary)",
|
24398 | success: "var(--adm-color-success)",
|
24399 | warning: "var(--adm-color-warning)",
|
24400 | danger: "var(--adm-color-danger)"
|
24401 | };
|
24402 | const SwiperItem = (props) => {
|
24403 | return withNativeProps(props, React$1.createElement("div", {
|
24404 | className: "adm-swiper-item",
|
24405 | onClick: props.onClick
|
24406 | }, props.children));
|
24407 | };
|
24408 | function useRefState(initialState) {
|
24409 | const [state, setState] = React$1.useState(initialState);
|
24410 | const ref = React$1.useRef(state);
|
24411 | React$1.useEffect(() => {
|
24412 | ref.current = state;
|
24413 | }, [state]);
|
24414 | return [state, setState, ref];
|
24415 | }
|
24416 | function mergeFuncProps(p1, p2) {
|
24417 | const p1Keys = Object.keys(p1);
|
24418 | const p2Keys = Object.keys(p2);
|
24419 | const keys = new Set([...p1Keys, ...p2Keys]);
|
24420 | const res = {};
|
24421 | keys.forEach((key) => {
|
24422 | const p1Value = p1[key];
|
24423 | const p2Value = p2[key];
|
24424 | if (typeof p1Value === "function" && typeof p2Value === "function") {
|
24425 | res[key] = function(...args) {
|
24426 | p1Value(...args);
|
24427 | p2Value(...args);
|
24428 | };
|
24429 | } else {
|
24430 | res[key] = p1Value || p2Value;
|
24431 | }
|
24432 | });
|
24433 | return res;
|
24434 | }
|
24435 | const classPrefix$a = `adm-swiper`;
|
24436 | const eventToPropRecord = {
|
24437 | "mousedown": "onMouseDown",
|
24438 | "mousemove": "onMouseMove",
|
24439 | "mouseup": "onMouseUp"
|
24440 | };
|
24441 | const defaultProps$a = {
|
24442 | defaultIndex: 0,
|
24443 | allowTouchMove: true,
|
24444 | autoplay: false,
|
24445 | autoplayInterval: 3e3,
|
24446 | loop: false,
|
24447 | direction: "horizontal",
|
24448 | slideSize: 100,
|
24449 | trackOffset: 0,
|
24450 | stuckAtBoundary: true,
|
24451 | rubberband: true,
|
24452 | stopPropagation: []
|
24453 | };
|
24454 | let currentUid;
|
24455 | const Swiper = React$1.forwardRef(staged_1((p, ref) => {
|
24456 | const props = mergeProps(defaultProps$a, p);
|
24457 | const {
|
24458 | direction,
|
24459 | total,
|
24460 | children,
|
24461 | indicator
|
24462 | } = props;
|
24463 | const [uid] = React$1.useState({});
|
24464 | const timeoutRef = React$1.useRef(null);
|
24465 | const isVertical = direction === "vertical";
|
24466 | const slideRatio = props.slideSize / 100;
|
24467 | const offsetRatio = props.trackOffset / 100;
|
24468 | const {
|
24469 | validChildren,
|
24470 | count,
|
24471 | renderChildren
|
24472 | } = React$1.useMemo(() => {
|
24473 | let count2 = 0;
|
24474 | let renderChildren2 = void 0;
|
24475 | let validChildren2 = void 0;
|
24476 | if (typeof children === "function") {
|
24477 | renderChildren2 = children;
|
24478 | } else {
|
24479 | validChildren2 = React$1.Children.map(children, (child) => {
|
24480 | if (!React$1.isValidElement(child))
|
24481 | return null;
|
24482 | if (child.type !== SwiperItem) {
|
24483 | devWarning("Swiper", "The children of `Swiper` must be `Swiper.Item` components.");
|
24484 | return null;
|
24485 | }
|
24486 | count2++;
|
24487 | return child;
|
24488 | });
|
24489 | }
|
24490 | return {
|
24491 | renderChildren: renderChildren2,
|
24492 | validChildren: validChildren2,
|
24493 | count: count2
|
24494 | };
|
24495 | }, [children]);
|
24496 | const mergedTotal = total !== null && total !== void 0 ? total : count;
|
24497 | if (mergedTotal === 0 || !validChildren && !renderChildren) {
|
24498 | devWarning("Swiper", "`Swiper` needs at least one child.");
|
24499 | return null;
|
24500 | }
|
24501 | return () => {
|
24502 | let loop2 = props.loop;
|
24503 | if (slideRatio * (mergedTotal - 1) < 1) {
|
24504 | loop2 = false;
|
24505 | }
|
24506 | const trackRef = React$1.useRef(null);
|
24507 | function getSlidePixels() {
|
24508 | const track = trackRef.current;
|
24509 | if (!track)
|
24510 | return 0;
|
24511 | const trackPixels = isVertical ? track.offsetHeight : track.offsetWidth;
|
24512 | return trackPixels * props.slideSize / 100;
|
24513 | }
|
24514 | const [current, setCurrent, getCurrent] = useGetState(props.defaultIndex);
|
24515 | const [dragging, setDragging, draggingRef] = useRefState(false);
|
24516 | function boundIndex(current2) {
|
24517 | let min2 = 0;
|
24518 | let max2 = mergedTotal - 1;
|
24519 | if (props.stuckAtBoundary) {
|
24520 | min2 += offsetRatio / slideRatio;
|
24521 | max2 -= (1 - slideRatio - offsetRatio) / slideRatio;
|
24522 | }
|
24523 | return bound(current2, min2, max2);
|
24524 | }
|
24525 | const [{
|
24526 | position
|
24527 | }, api] = useSpring(() => ({
|
24528 | position: boundIndex(current) * 100,
|
24529 | config: {
|
24530 | tension: 200,
|
24531 | friction: 30
|
24532 | },
|
24533 | onRest: () => {
|
24534 | if (draggingRef.current)
|
24535 | return;
|
24536 | if (!loop2)
|
24537 | return;
|
24538 | const rawX = position.get();
|
24539 | const totalWidth = 100 * mergedTotal;
|
24540 | const standardPosition = modulus(rawX, totalWidth);
|
24541 | if (standardPosition === rawX)
|
24542 | return;
|
24543 | api.start({
|
24544 | position: standardPosition,
|
24545 | immediate: true
|
24546 | });
|
24547 | }
|
24548 | }), [mergedTotal]);
|
24549 | const dragCancelRef = React$1.useRef(null);
|
24550 | function forceCancelDrag() {
|
24551 | var _a;
|
24552 | (_a = dragCancelRef.current) === null || _a === void 0 ? void 0 : _a.call(dragCancelRef);
|
24553 | draggingRef.current = false;
|
24554 | }
|
24555 | const bind = useDrag((state) => {
|
24556 | dragCancelRef.current = state.cancel;
|
24557 | if (!state.intentional)
|
24558 | return;
|
24559 | if (state.first && !currentUid) {
|
24560 | currentUid = uid;
|
24561 | }
|
24562 | if (currentUid !== uid)
|
24563 | return;
|
24564 | currentUid = state.last ? void 0 : uid;
|
24565 | const slidePixels = getSlidePixels();
|
24566 | if (!slidePixels)
|
24567 | return;
|
24568 | const paramIndex = isVertical ? 1 : 0;
|
24569 | const offset2 = state.offset[paramIndex];
|
24570 | const direction2 = state.direction[paramIndex];
|
24571 | const velocity = state.velocity[paramIndex];
|
24572 | setDragging(true);
|
24573 | if (!state.last) {
|
24574 | api.start({
|
24575 | position: offset2 * 100 / slidePixels,
|
24576 | immediate: true
|
24577 | });
|
24578 | } else {
|
24579 | const minIndex = Math.floor(offset2 / slidePixels);
|
24580 | const maxIndex = minIndex + 1;
|
24581 | const index2 = Math.round((offset2 + velocity * 2e3 * direction2) / slidePixels);
|
24582 | swipeTo(bound(index2, minIndex, maxIndex));
|
24583 | window.setTimeout(() => {
|
24584 | setDragging(false);
|
24585 | });
|
24586 | }
|
24587 | }, {
|
24588 | transform: ([x, y]) => [-x, -y],
|
24589 | from: () => {
|
24590 | const slidePixels = getSlidePixels();
|
24591 | return [position.get() / 100 * slidePixels, position.get() / 100 * slidePixels];
|
24592 | },
|
24593 | triggerAllEvents: true,
|
24594 | bounds: () => {
|
24595 | if (loop2)
|
24596 | return {};
|
24597 | const slidePixels = getSlidePixels();
|
24598 | const lowerBound = boundIndex(0) * slidePixels;
|
24599 | const upperBound = boundIndex(mergedTotal - 1) * slidePixels;
|
24600 | return isVertical ? {
|
24601 | top: lowerBound,
|
24602 | bottom: upperBound
|
24603 | } : {
|
24604 | left: lowerBound,
|
24605 | right: upperBound
|
24606 | };
|
24607 | },
|
24608 | rubberband: props.rubberband,
|
24609 | axis: isVertical ? "y" : "x",
|
24610 | preventScroll: !isVertical,
|
24611 | pointer: {
|
24612 | touch: true
|
24613 | }
|
24614 | });
|
24615 | function swipeTo(index2, immediate = false) {
|
24616 | var _a;
|
24617 | const roundedIndex = Math.round(index2);
|
24618 | const targetIndex = loop2 ? modulus(roundedIndex, mergedTotal) : bound(roundedIndex, 0, mergedTotal - 1);
|
24619 | if (targetIndex !== getCurrent()) {
|
24620 | (_a = props.onIndexChange) === null || _a === void 0 ? void 0 : _a.call(props, targetIndex);
|
24621 | }
|
24622 | setCurrent(targetIndex);
|
24623 | api.start({
|
24624 | position: (loop2 ? roundedIndex : boundIndex(roundedIndex)) * 100,
|
24625 | immediate
|
24626 | });
|
24627 | }
|
24628 | function swipeNext() {
|
24629 | swipeTo(Math.round(position.get() / 100) + 1);
|
24630 | }
|
24631 | function swipePrev() {
|
24632 | swipeTo(Math.round(position.get() / 100) - 1);
|
24633 | }
|
24634 | React$1.useImperativeHandle(ref, () => ({
|
24635 | swipeTo,
|
24636 | swipeNext,
|
24637 | swipePrev
|
24638 | }));
|
24639 | useIsomorphicLayoutEffect$2(() => {
|
24640 | const maxIndex = mergedTotal - 1;
|
24641 | if (current > maxIndex) {
|
24642 | swipeTo(maxIndex, true);
|
24643 | }
|
24644 | });
|
24645 | const {
|
24646 | autoplay,
|
24647 | autoplayInterval
|
24648 | } = props;
|
24649 | const runTimeSwiper = () => {
|
24650 | timeoutRef.current = window.setTimeout(() => {
|
24651 | if (autoplay === "reverse") {
|
24652 | swipePrev();
|
24653 | } else {
|
24654 | swipeNext();
|
24655 | }
|
24656 | runTimeSwiper();
|
24657 | }, autoplayInterval);
|
24658 | };
|
24659 | React$1.useEffect(() => {
|
24660 | if (!autoplay || dragging)
|
24661 | return;
|
24662 | runTimeSwiper();
|
24663 | return () => {
|
24664 | if (timeoutRef.current)
|
24665 | window.clearTimeout(timeoutRef.current);
|
24666 | };
|
24667 | }, [autoplay, autoplayInterval, dragging, mergedTotal]);
|
24668 | function renderItem(index2, child) {
|
24669 | let itemStyle = {};
|
24670 | if (loop2) {
|
24671 | itemStyle = {
|
24672 | [isVertical ? "y" : "x"]: position.to((position2) => {
|
24673 | let finalPosition = -position2 + index2 * 100;
|
24674 | const totalWidth = mergedTotal * 100;
|
24675 | const flagWidth = totalWidth / 2;
|
24676 | finalPosition = modulus(finalPosition + flagWidth, totalWidth) - flagWidth;
|
24677 | return `${finalPosition}%`;
|
24678 | }),
|
24679 | [isVertical ? "top" : "left"]: `-${index2 * 100}%`
|
24680 | };
|
24681 | }
|
24682 | return React$1.createElement(animated.div, {
|
24683 | className: classNames(`${classPrefix$a}-slide`, {
|
24684 | [`${classPrefix$a}-slide-active`]: current === index2
|
24685 | }),
|
24686 | style: itemStyle,
|
24687 | key: index2
|
24688 | }, child);
|
24689 | }
|
24690 | function renderItems() {
|
24691 | if (renderChildren && total) {
|
24692 | const offsetCount = 2;
|
24693 | const startIndex = Math.max(current - offsetCount, 0);
|
24694 | const endIndex = Math.min(current + offsetCount, total - 1);
|
24695 | const items = [];
|
24696 | for (let index2 = startIndex; index2 <= endIndex; index2 += 1) {
|
24697 | items.push(renderItem(index2, renderChildren(index2)));
|
24698 | }
|
24699 | return React$1.createElement(React$1.Fragment, null, React$1.createElement("div", {
|
24700 | className: `${classPrefix$a}-slide-placeholder`,
|
24701 | style: {
|
24702 | width: `${startIndex * 100}%`
|
24703 | }
|
24704 | }), items);
|
24705 | }
|
24706 | return React$1.Children.map(validChildren, (child, index2) => {
|
24707 | return renderItem(index2, child);
|
24708 | });
|
24709 | }
|
24710 | function renderTrackInner() {
|
24711 | if (loop2) {
|
24712 | return React$1.createElement("div", {
|
24713 | className: `${classPrefix$a}-track-inner`
|
24714 | }, renderItems());
|
24715 | } else {
|
24716 | return React$1.createElement(animated.div, {
|
24717 | className: `${classPrefix$a}-track-inner`,
|
24718 | style: {
|
24719 | [isVertical ? "y" : "x"]: position.to((position2) => `${-position2}%`)
|
24720 | }
|
24721 | }, renderItems());
|
24722 | }
|
24723 | }
|
24724 | const style = {
|
24725 | "--slide-size": `${props.slideSize}%`,
|
24726 | "--track-offset": `${props.trackOffset}%`
|
24727 | };
|
24728 | const dragProps = Object.assign({}, props.allowTouchMove ? bind() : {});
|
24729 | const stopPropagationProps = {};
|
24730 | for (const key of props.stopPropagation) {
|
24731 | const prop = eventToPropRecord[key];
|
24732 | stopPropagationProps[prop] = function(e2) {
|
24733 | e2.stopPropagation();
|
24734 | };
|
24735 | }
|
24736 | const mergedProps = mergeFuncProps(dragProps, stopPropagationProps);
|
24737 | let indicatorNode = null;
|
24738 | if (typeof indicator === "function") {
|
24739 | indicatorNode = indicator(mergedTotal, current);
|
24740 | } else if (indicator !== false) {
|
24741 | indicatorNode = React$1.createElement("div", {
|
24742 | className: `${classPrefix$a}-indicator`
|
24743 | }, React$1.createElement(PageIndicator, Object.assign({}, props.indicatorProps, {
|
24744 | total: mergedTotal,
|
24745 | current,
|
24746 | direction
|
24747 | })));
|
24748 | }
|
24749 | return withNativeProps(props, React$1.createElement("div", {
|
24750 | className: classNames(classPrefix$a, `${classPrefix$a}-${direction}`),
|
24751 | style
|
24752 | }, React$1.createElement("div", Object.assign({
|
24753 | ref: trackRef,
|
24754 | className: classNames(`${classPrefix$a}-track`, {
|
24755 | [`${classPrefix$a}-track-allow-touch-move`]: props.allowTouchMove
|
24756 | }),
|
24757 | onClickCapture: (e2) => {
|
24758 | if (draggingRef.current) {
|
24759 | e2.stopPropagation();
|
24760 | }
|
24761 | forceCancelDrag();
|
24762 | }
|
24763 | }, mergedProps), renderTrackInner()), indicatorNode));
|
24764 | };
|
24765 | }));
|
24766 | function modulus(value, division) {
|
24767 | const remainder = value % division;
|
24768 | return remainder < 0 ? remainder + division : remainder;
|
24769 | }
|
24770 | const index$2 = attachPropertiesToComponent(Swiper, {
|
24771 | Item: SwiperItem
|
24772 | });
|
24773 | const SpinIcon = React$1.memo((props) => {
|
24774 | return withNativeProps(props, React$1.createElement("svg", {
|
24775 | width: "28px",
|
24776 | height: "28px",
|
24777 | viewBox: "0 0 28 28"
|
24778 | }, React$1.createElement("g", {
|
24779 | stroke: "none",
|
24780 | strokeWidth: "1",
|
24781 | fill: "none",
|
24782 | fillRule: "evenodd"
|
24783 | }, React$1.createElement("g", {
|
24784 | transform: "translate(-137.000000, -840.000000)",
|
24785 | fill: "#1576FE"
|
24786 | }, React$1.createElement("g", {
|
24787 | transform: "translate(80.000000, 823.000000)"
|
24788 | }, React$1.createElement("g", {
|
24789 | transform: "translate(53.000000, 13.000000)"
|
24790 | }, React$1.createElement("path", {
|
24791 | d: "M17.9996753,31.5 C10.5556724,31.5 4.5,25.4443275 4.5,18.0003247 C4.5,10.5563219 10.5556724,4.5 17.9996753,4.5 C18.5355492,4.5 18.9702974,4.93474816 18.9702974,5.47062208 C18.9702974,6.006496 18.5355492,6.44124416 17.9996753,6.44124416 C11.6261524,6.44124416 6.44124416,11.6267709 6.44124416,18.0002938 C6.44124416,24.3738167 11.6261524,29.5587249 17.9996753,29.5587249 C24.3731982,29.5587249 29.5587249,24.3738167 29.5587249,18.0002938 C29.5587249,14.7964616 28.2778291,11.8169616 25.9523687,9.61220279 C25.5637302,9.24317094 25.5473089,8.62893223 25.9157222,8.23967523 C26.2841356,7.84976878 26.8989928,7.83461537 27.2882498,8.20302872 C30.0042351,10.7787368 31.5,14.2580826 31.5,18.0002938 C31.5,25.4443275 25.4436781,31.5 17.9996753,31.5 Z"
|
24792 | })))))));
|
24793 | });
|
24794 | const classPrefix$9 = `adm-switch`;
|
24795 | const defaultProps$9 = {
|
24796 | defaultChecked: false
|
24797 | };
|
24798 | const Switch = (p) => {
|
24799 | const props = mergeProps(defaultProps$9, p);
|
24800 | const disabled = props.disabled || props.loading || false;
|
24801 | const [changing, setChanging] = React$1.useState(false);
|
24802 | const {
|
24803 | locale
|
24804 | } = useConfig();
|
24805 | const [checked, setChecked] = usePropsValue({
|
24806 | value: props.checked,
|
24807 | defaultValue: props.defaultChecked,
|
24808 | onChange: props.onChange
|
24809 | });
|
24810 | function onClick() {
|
24811 | return __awaiter(this, void 0, void 0, function* () {
|
24812 | if (disabled || props.loading || changing) {
|
24813 | return;
|
24814 | }
|
24815 | const nextChecked = !checked;
|
24816 | if (props.beforeChange) {
|
24817 | setChanging(true);
|
24818 | try {
|
24819 | yield props.beforeChange(nextChecked);
|
24820 | setChanging(false);
|
24821 | } catch (e2) {
|
24822 | setChanging(false);
|
24823 | throw e2;
|
24824 | }
|
24825 | }
|
24826 | const result = setChecked(nextChecked);
|
24827 | if (isPromise(result)) {
|
24828 | setChanging(true);
|
24829 | try {
|
24830 | yield result;
|
24831 | setChanging(false);
|
24832 | } catch (e2) {
|
24833 | setChanging(false);
|
24834 | throw e2;
|
24835 | }
|
24836 | }
|
24837 | });
|
24838 | }
|
24839 | return withNativeProps(props, React$1.createElement("div", {
|
24840 | onClick,
|
24841 | className: classNames(classPrefix$9, {
|
24842 | [`${classPrefix$9}-checked`]: checked,
|
24843 | [`${classPrefix$9}-disabled`]: disabled || changing
|
24844 | }),
|
24845 | role: "switch",
|
24846 | "aria-label": locale.Switch.name,
|
24847 | "aria-checked": checked,
|
24848 | "aria-disabled": disabled
|
24849 | }, React$1.createElement("div", {
|
24850 | className: `${classPrefix$9}-checkbox`
|
24851 | }, React$1.createElement("div", {
|
24852 | className: `${classPrefix$9}-handle`
|
24853 | }, (props.loading || changing) && React$1.createElement(SpinIcon, {
|
24854 | className: `${classPrefix$9}-spin-icon`
|
24855 | })), React$1.createElement("div", {
|
24856 | className: `${classPrefix$9}-inner`
|
24857 | }, checked ? props.checkedText : props.uncheckedText))));
|
24858 | };
|
24859 | const TabBarItem = () => {
|
24860 | return null;
|
24861 | };
|
24862 | const classPrefix$8 = `adm-tab-bar`;
|
24863 | const defaultProps$8 = {
|
24864 | safeArea: false
|
24865 | };
|
24866 | const TabBar = (p) => {
|
24867 | var _a;
|
24868 | const props = mergeProps(defaultProps$8, p);
|
24869 | let firstActiveKey = null;
|
24870 | const items = [];
|
24871 | traverseReactNode(props.children, (child, index2) => {
|
24872 | if (!React$1.isValidElement(child))
|
24873 | return;
|
24874 | const key = child.key;
|
24875 | if (typeof key !== "string")
|
24876 | return;
|
24877 | if (index2 === 0) {
|
24878 | firstActiveKey = key;
|
24879 | }
|
24880 | items.push(child);
|
24881 | });
|
24882 | const [activeKey, setActiveKey] = usePropsValue({
|
24883 | value: props.activeKey,
|
24884 | defaultValue: (_a = props.defaultActiveKey) !== null && _a !== void 0 ? _a : firstActiveKey,
|
24885 | onChange: (v) => {
|
24886 | var _a2;
|
24887 | if (v === null)
|
24888 | return;
|
24889 | (_a2 = props.onChange) === null || _a2 === void 0 ? void 0 : _a2.call(props, v);
|
24890 | }
|
24891 | });
|
24892 | return withNativeProps(props, React$1.createElement("div", {
|
24893 | className: classPrefix$8
|
24894 | }, React$1.createElement("div", {
|
24895 | className: `${classPrefix$8}-wrap`
|
24896 | }, items.map((item) => {
|
24897 | const active = item.key === activeKey;
|
24898 | function renderContent() {
|
24899 | const iconElement = item.props.icon && React$1.createElement("div", {
|
24900 | className: `${classPrefix$8}-item-icon`
|
24901 | }, typeof item.props.icon === "function" ? item.props.icon(active) : item.props.icon);
|
24902 | const titleElement = item.props.title && React$1.createElement("div", {
|
24903 | className: classNames(`${classPrefix$8}-item-title`, Boolean(iconElement) && `${classPrefix$8}-item-title-with-icon`)
|
24904 | }, typeof item.props.title === "function" ? item.props.title(active) : item.props.title);
|
24905 | if (iconElement) {
|
24906 | return React$1.createElement(React$1.Fragment, null, React$1.createElement(Badge, {
|
24907 | content: item.props.badge,
|
24908 | className: `${classPrefix$8}-icon-badge`
|
24909 | }, iconElement), titleElement);
|
24910 | } else if (titleElement) {
|
24911 | return React$1.createElement(Badge, {
|
24912 | content: item.props.badge,
|
24913 | className: `${classPrefix$8}-title-badge`
|
24914 | }, titleElement);
|
24915 | }
|
24916 | return null;
|
24917 | }
|
24918 | return withNativeProps(item.props, React$1.createElement("div", {
|
24919 | key: item.key,
|
24920 | onClick: () => {
|
24921 | const {
|
24922 | key
|
24923 | } = item;
|
24924 | if (key === void 0 || key === null)
|
24925 | return;
|
24926 | setActiveKey(key.toString());
|
24927 | },
|
24928 | className: classNames(`${classPrefix$8}-item`, {
|
24929 | [`${classPrefix$8}-item-active`]: active
|
24930 | })
|
24931 | }, renderContent()));
|
24932 | })), props.safeArea && React$1.createElement(SafeArea, {
|
24933 | position: "bottom"
|
24934 | })));
|
24935 | };
|
24936 | const index$1 = attachPropertiesToComponent(TabBar, {
|
24937 | Item: TabBarItem
|
24938 | });
|
24939 | const classPrefix$7 = `adm-tag`;
|
24940 | const colorRecord = {
|
24941 | default: "var(--adm-color-text-secondary, #666666)",
|
24942 | primary: "var(--adm-color-primary, #1677ff)",
|
24943 | success: "var(--adm-color-success, #00b578)",
|
24944 | warning: "var(--adm-color-warning, #ff8f1f)",
|
24945 | danger: "var(--adm-color-danger, #ff3141)"
|
24946 | };
|
24947 | const defaultProps$7 = {
|
24948 | color: "default",
|
24949 | fill: "solid",
|
24950 | round: false
|
24951 | };
|
24952 | const Tag = (p) => {
|
24953 | var _a;
|
24954 | const props = mergeProps(defaultProps$7, p);
|
24955 | const color = (_a = colorRecord[props.color]) !== null && _a !== void 0 ? _a : props.color;
|
24956 | const style = {
|
24957 | "--border-color": color,
|
24958 | "--text-color": props.fill === "outline" ? color : "#ffffff",
|
24959 | "--background-color": props.fill === "outline" ? "transparent" : color
|
24960 | };
|
24961 | return withNativeProps(props, React$1.createElement("span", {
|
24962 | style,
|
24963 | onClick: props.onClick,
|
24964 | className: classNames(classPrefix$7, {
|
24965 | [`${classPrefix$7}-round`]: props.round
|
24966 | })
|
24967 | }, props.children));
|
24968 | };
|
24969 | const classPrefix$6 = "adm-text-area";
|
24970 | const defaultProps$6 = {
|
24971 | rows: 2,
|
24972 | showCount: false,
|
24973 | autoSize: false,
|
24974 | defaultValue: ""
|
24975 | };
|
24976 | const TextArea = React$1.forwardRef((p, ref) => {
|
24977 | const props = mergeProps(defaultProps$6, p);
|
24978 | const {
|
24979 | autoSize,
|
24980 | showCount,
|
24981 | maxLength
|
24982 | } = props;
|
24983 | const [value, setValue2] = usePropsValue(Object.assign(Object.assign({}, props), {
|
24984 | value: props.value === null ? "" : props.value
|
24985 | }));
|
24986 | if (props.value === null) {
|
24987 | devError("TextArea", "`value` prop on `TextArea` should not be `null`. Consider using an empty string to clear the component.");
|
24988 | }
|
24989 | const nativeTextAreaRef = React$1.useRef(null);
|
24990 | const heightRef = React$1.useRef("auto");
|
24991 | const hiddenTextAreaRef = React$1.useRef(null);
|
24992 | const handleKeydown = useInputHandleKeyDown({
|
24993 | onEnterPress: props.onEnterPress,
|
24994 | onKeyDown: props.onKeyDown,
|
24995 | nativeInputRef: nativeTextAreaRef,
|
24996 | enterKeyHint: props.enterKeyHint
|
24997 | });
|
24998 | React$1.useImperativeHandle(ref, () => ({
|
24999 | clear: () => {
|
25000 | setValue2("");
|
25001 | },
|
25002 | focus: () => {
|
25003 | var _a;
|
25004 | (_a = nativeTextAreaRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
25005 | },
|
25006 | blur: () => {
|
25007 | var _a;
|
25008 | (_a = nativeTextAreaRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
25009 | },
|
25010 | get nativeElement() {
|
25011 | return nativeTextAreaRef.current;
|
25012 | }
|
25013 | }));
|
25014 | useIsomorphicLayoutEffect$2(() => {
|
25015 | if (!autoSize)
|
25016 | return;
|
25017 | const textArea = nativeTextAreaRef.current;
|
25018 | const hiddenTextArea = hiddenTextAreaRef.current;
|
25019 | if (!textArea)
|
25020 | return;
|
25021 | textArea.style.height = heightRef.current;
|
25022 | if (!hiddenTextArea)
|
25023 | return;
|
25024 | let height = hiddenTextArea.scrollHeight;
|
25025 | if (typeof autoSize === "object") {
|
25026 | const computedStyle = window.getComputedStyle(textArea);
|
25027 | const lineHeight = parseFloat(computedStyle.lineHeight);
|
25028 | if (autoSize.minRows) {
|
25029 | height = Math.max(height, autoSize.minRows * lineHeight);
|
25030 | }
|
25031 | if (autoSize.maxRows) {
|
25032 | height = Math.min(height, autoSize.maxRows * lineHeight);
|
25033 | }
|
25034 | }
|
25035 | heightRef.current = `${height}px`;
|
25036 | textArea.style.height = `${height}px`;
|
25037 | }, [value, autoSize]);
|
25038 | const compositingRef = React$1.useRef(false);
|
25039 | let count;
|
25040 | const valueLength = runes(value).length;
|
25041 | if (typeof showCount === "function") {
|
25042 | count = showCount(valueLength, maxLength);
|
25043 | } else if (showCount) {
|
25044 | count = React$1.createElement("div", {
|
25045 | className: `${classPrefix$6}-count`
|
25046 | }, maxLength === void 0 ? valueLength : valueLength + "/" + maxLength);
|
25047 | }
|
25048 | let rows = props.rows;
|
25049 | if (typeof autoSize === "object") {
|
25050 | if (autoSize.maxRows && rows > autoSize.maxRows) {
|
25051 | rows = autoSize.maxRows;
|
25052 | }
|
25053 | if (autoSize.minRows && rows < autoSize.minRows) {
|
25054 | rows = autoSize.minRows;
|
25055 | }
|
25056 | }
|
25057 | return withNativeProps(props, React$1.createElement("div", {
|
25058 | className: classPrefix$6
|
25059 | }, React$1.createElement("textarea", {
|
25060 | ref: nativeTextAreaRef,
|
25061 | className: `${classPrefix$6}-element`,
|
25062 | rows,
|
25063 | value,
|
25064 | placeholder: props.placeholder,
|
25065 | onChange: (e2) => {
|
25066 | let v = e2.target.value;
|
25067 | if (maxLength && !compositingRef.current) {
|
25068 | v = runes(v).slice(0, maxLength).join("");
|
25069 | }
|
25070 | setValue2(v);
|
25071 | },
|
25072 | id: props.id,
|
25073 | onCompositionStart: (e2) => {
|
25074 | var _a;
|
25075 | compositingRef.current = true;
|
25076 | (_a = props.onCompositionStart) === null || _a === void 0 ? void 0 : _a.call(props, e2);
|
25077 | },
|
25078 | onCompositionEnd: (e2) => {
|
25079 | var _a;
|
25080 | compositingRef.current = false;
|
25081 | if (maxLength) {
|
25082 | const v = e2.target.value;
|
25083 | setValue2(runes(v).slice(0, maxLength).join(""));
|
25084 | }
|
25085 | (_a = props.onCompositionEnd) === null || _a === void 0 ? void 0 : _a.call(props, e2);
|
25086 | },
|
25087 | autoComplete: props.autoComplete,
|
25088 | autoFocus: props.autoFocus,
|
25089 | disabled: props.disabled,
|
25090 | readOnly: props.readOnly,
|
25091 | name: props.name,
|
25092 | onFocus: props.onFocus,
|
25093 | onBlur: props.onBlur,
|
25094 | onClick: props.onClick,
|
25095 | onKeyDown: handleKeydown
|
25096 | }), count, autoSize && React$1.createElement("textarea", {
|
25097 | ref: hiddenTextAreaRef,
|
25098 | className: `${classPrefix$6}-element ${classPrefix$6}-element-hidden`,
|
25099 | value,
|
25100 | rows,
|
25101 | "aria-hidden": true,
|
25102 | readOnly: true
|
25103 | })));
|
25104 | });
|
25105 | TextArea.defaultProps = defaultProps$6;
|
25106 | const classPrefix$5 = `adm-toast`;
|
25107 | const defaultProps$5 = {
|
25108 | maskClickable: true,
|
25109 | stopPropagation: ["click"]
|
25110 | };
|
25111 | const InternalToast = (p) => {
|
25112 | const props = mergeProps(defaultProps$5, p);
|
25113 | const {
|
25114 | maskClickable,
|
25115 | content,
|
25116 | icon,
|
25117 | position
|
25118 | } = props;
|
25119 | const iconElement = React$1.useMemo(() => {
|
25120 | if (icon === null || icon === void 0)
|
25121 | return null;
|
25122 | switch (icon) {
|
25123 | case "success":
|
25124 | return React$1.createElement(CheckOutline, {
|
25125 | className: `${classPrefix$5}-icon-success`
|
25126 | });
|
25127 | case "fail":
|
25128 | return React$1.createElement(CloseOutline, {
|
25129 | className: `${classPrefix$5}-icon-fail`
|
25130 | });
|
25131 | case "loading":
|
25132 | return React$1.createElement(SpinLoading, {
|
25133 | color: "white",
|
25134 | className: `${classPrefix$5}-loading`
|
25135 | });
|
25136 | default:
|
25137 | return icon;
|
25138 | }
|
25139 | }, [icon]);
|
25140 | const top = React$1.useMemo(() => {
|
25141 | switch (position) {
|
25142 | case "top":
|
25143 | return "20%";
|
25144 | case "bottom":
|
25145 | return "80%";
|
25146 | default:
|
25147 | return "50%";
|
25148 | }
|
25149 | }, [position]);
|
25150 | return React$1.createElement(Mask, {
|
25151 | visible: props.visible,
|
25152 | destroyOnClose: true,
|
25153 | opacity: 0,
|
25154 | disableBodyScroll: !maskClickable,
|
25155 | getContainer: props.getContainer,
|
25156 | afterClose: props.afterClose,
|
25157 | style: Object.assign({
|
25158 | pointerEvents: maskClickable ? "none" : "auto"
|
25159 | }, props.maskStyle),
|
25160 | className: classNames(`${classPrefix$5}-mask`, props.maskClassName),
|
25161 | stopPropagation: props.stopPropagation
|
25162 | }, React$1.createElement("div", {
|
25163 | className: classNames(`${classPrefix$5}-wrap`)
|
25164 | }, React$1.createElement("div", {
|
25165 | style: {
|
25166 | top
|
25167 | },
|
25168 | className: classNames(`${classPrefix$5}-main`, icon ? `${classPrefix$5}-main-icon` : `${classPrefix$5}-main-text`)
|
25169 | }, iconElement && React$1.createElement("div", {
|
25170 | className: `${classPrefix$5}-icon`
|
25171 | }, iconElement), React$1.createElement(AutoCenter, null, content))));
|
25172 | };
|
25173 | let currentHandler = null;
|
25174 | let currentTimeout = null;
|
25175 | const defaultProps$4 = {
|
25176 | duration: 2e3,
|
25177 | position: "center",
|
25178 | maskClickable: true
|
25179 | };
|
25180 | const ToastInner = (props) => React$1.createElement(InternalToast, Object.assign({}, props));
|
25181 | function show(p) {
|
25182 | const props = mergeProps(defaultProps$4, typeof p === "string" ? {
|
25183 | content: p
|
25184 | } : p);
|
25185 | const element = React$1.createElement(ToastInner, Object.assign({}, props, {
|
25186 | onClose: () => {
|
25187 | currentHandler = null;
|
25188 | }
|
25189 | }));
|
25190 | if (currentHandler) {
|
25191 | currentHandler.replace(element);
|
25192 | } else {
|
25193 | currentHandler = renderImperatively(element);
|
25194 | }
|
25195 | if (currentTimeout) {
|
25196 | window.clearTimeout(currentTimeout);
|
25197 | }
|
25198 | if (props.duration !== 0) {
|
25199 | currentTimeout = window.setTimeout(() => {
|
25200 | clear();
|
25201 | }, props.duration);
|
25202 | }
|
25203 | return currentHandler;
|
25204 | }
|
25205 | function clear() {
|
25206 | currentHandler === null || currentHandler === void 0 ? void 0 : currentHandler.close();
|
25207 | currentHandler = null;
|
25208 | }
|
25209 | function config(val) {
|
25210 | if (val.duration !== void 0) {
|
25211 | defaultProps$4.duration = val.duration;
|
25212 | }
|
25213 | if (val.position !== void 0) {
|
25214 | defaultProps$4.position = val.position;
|
25215 | }
|
25216 | if (val.maskClickable !== void 0) {
|
25217 | defaultProps$4.maskClickable = val.maskClickable;
|
25218 | }
|
25219 | }
|
25220 | const Toast = {
|
25221 | show,
|
25222 | clear,
|
25223 | config
|
25224 | };
|
25225 | const Toast$1 = Toast;
|
25226 | function getTreeDeep(treeData, childrenName = "children") {
|
25227 | const walker = (tree) => {
|
25228 | let deep = 0;
|
25229 | tree.forEach((item) => {
|
25230 | if (item[childrenName]) {
|
25231 | deep = Math.max(deep, walker(item[childrenName]) + 1);
|
25232 | } else {
|
25233 | deep = Math.max(deep, 1);
|
25234 | }
|
25235 | });
|
25236 | return deep;
|
25237 | };
|
25238 | return walker(treeData);
|
25239 | }
|
25240 | const classPrefix$4 = `adm-tree-select`;
|
25241 | const defaultProps$3 = {
|
25242 | options: [],
|
25243 | fieldNames: {},
|
25244 | defaultValue: []
|
25245 | };
|
25246 | const TreeSelect = (p) => {
|
25247 | const props = mergeProps(defaultProps$3, p);
|
25248 | const [labelName, valueName, childrenName] = useFieldNames(props.fieldNames);
|
25249 | const [value, setValue2] = usePropsValue({
|
25250 | value: props.value,
|
25251 | defaultValue: props.defaultValue
|
25252 | });
|
25253 | const [deep, optionsMap, optionsParentMap] = React$1.useMemo(() => {
|
25254 | const deep2 = getTreeDeep(props.options, childrenName);
|
25255 | const optionsMap2 = new Map();
|
25256 | const optionsParentMap2 = new Map();
|
25257 | function traverse(current, children) {
|
25258 | children.forEach((item) => {
|
25259 | optionsParentMap2.set(item[valueName], current);
|
25260 | optionsMap2.set(item[valueName], item);
|
25261 | if (item[childrenName]) {
|
25262 | traverse(item, item[childrenName]);
|
25263 | }
|
25264 | });
|
25265 | }
|
25266 | traverse(void 0, props.options);
|
25267 | return [deep2, optionsMap2, optionsParentMap2];
|
25268 | }, [props.options]);
|
25269 | const onItemSelect = (node) => {
|
25270 | var _a;
|
25271 | const parentNodes = [];
|
25272 | let current = node;
|
25273 | while (current) {
|
25274 | parentNodes.push(current);
|
25275 | const next = optionsParentMap.get(current[valueName]);
|
25276 | current = next;
|
25277 | }
|
25278 | const values = parentNodes.reverse().map((i2) => i2[valueName]);
|
25279 | setValue2(values);
|
25280 | (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, values, {
|
25281 | options: parentNodes
|
25282 | });
|
25283 | };
|
25284 | const renderItems = (columnOptions = [], index2) => {
|
25285 | return columnOptions.map((item) => {
|
25286 | const isActive = item[valueName] === value[index2];
|
25287 | return React$1.createElement("div", {
|
25288 | key: item[valueName],
|
25289 | className: classNames(`${classPrefix$4}-item`, {
|
25290 | [`${classPrefix$4}-item-active`]: isActive
|
25291 | }),
|
25292 | onClick: () => {
|
25293 | if (!isActive) {
|
25294 | onItemSelect(item);
|
25295 | }
|
25296 | }
|
25297 | }, item[labelName]);
|
25298 | });
|
25299 | };
|
25300 | const renderColumns = () => {
|
25301 | var _a;
|
25302 | const columns = [];
|
25303 | for (let i2 = 0; i2 < deep; i2++) {
|
25304 | let width = `${100 / deep}%`;
|
25305 | if (deep === 2 && i2 === 0) {
|
25306 | width = `33.33%`;
|
25307 | }
|
25308 | if (deep === 2 && i2 === 1) {
|
25309 | width = `66.67%`;
|
25310 | }
|
25311 | const column = React$1.createElement("div", {
|
25312 | key: i2,
|
25313 | className: classNames(`${classPrefix$4}-column`),
|
25314 | style: {
|
25315 | width
|
25316 | }
|
25317 | }, renderItems(i2 === 0 ? props.options : (_a = optionsMap.get(value[i2 - 1])) === null || _a === void 0 ? void 0 : _a[childrenName], i2));
|
25318 | columns.push(column);
|
25319 | }
|
25320 | return columns;
|
25321 | };
|
25322 | return withNativeProps(props, React$1.createElement("div", {
|
25323 | className: classPrefix$4
|
25324 | }, renderColumns()));
|
25325 | };
|
25326 | const classPrefix$3 = `adm-tree-select-multiple`;
|
25327 | const Multiple = (p) => {
|
25328 | const props = mergeProps({
|
25329 | options: [],
|
25330 | fieldNames: {},
|
25331 | allSelectText: [],
|
25332 | defaultExpandKeys: [],
|
25333 | defaultValue: []
|
25334 | }, p);
|
25335 | React$1.useEffect(() => {
|
25336 | devWarning("TreeSelect", "TreeSelect.Multiple has been deprecated.");
|
25337 | }, []);
|
25338 | const [labelName, valueName, childrenName] = useFieldNames(props.fieldNames);
|
25339 | const [expandKeys, setExpandKeys] = usePropsValue({
|
25340 | value: props.expandKeys,
|
25341 | defaultValue: props.defaultExpandKeys
|
25342 | });
|
25343 | const [value, setValue2] = usePropsValue({
|
25344 | value: props.value,
|
25345 | defaultValue: props.defaultValue
|
25346 | });
|
25347 | const getLeafKeys = (option) => {
|
25348 | const keys = [];
|
25349 | const walker = (op) => {
|
25350 | var _a;
|
25351 | if (!op) {
|
25352 | return;
|
25353 | }
|
25354 | if ((_a = op[childrenName]) === null || _a === void 0 ? void 0 : _a.length) {
|
25355 | op[childrenName].forEach((i2) => walker(i2));
|
25356 | } else {
|
25357 | keys.push(op[valueName]);
|
25358 | }
|
25359 | };
|
25360 | walker(option);
|
25361 | return keys;
|
25362 | };
|
25363 | const [deep, optionsMap, optionsParentMap] = React$1.useMemo(() => {
|
25364 | const deep2 = getTreeDeep(props.options, childrenName);
|
25365 | const optionsMap2 = new Map();
|
25366 | const optionsParentMap2 = new Map();
|
25367 | function traverse(current, children) {
|
25368 | children.forEach((item) => {
|
25369 | optionsParentMap2.set(item[valueName], current);
|
25370 | optionsMap2.set(item[valueName], item);
|
25371 | if (item[childrenName]) {
|
25372 | traverse(item, item[childrenName]);
|
25373 | }
|
25374 | });
|
25375 | }
|
25376 | traverse(void 0, props.options);
|
25377 | return [deep2, optionsMap2, optionsParentMap2];
|
25378 | }, [props.options]);
|
25379 | const allSelectedLeafKeys = React$1.useMemo(() => {
|
25380 | let leafKeys = [];
|
25381 | value.forEach((v) => {
|
25382 | const option = optionsMap.get(v);
|
25383 | leafKeys = leafKeys.concat(getLeafKeys(option));
|
25384 | });
|
25385 | return leafKeys;
|
25386 | }, [value, optionsMap]);
|
25387 | const dotMap = React$1.useMemo(() => {
|
25388 | const map = new Map();
|
25389 | const walker = (key) => {
|
25390 | const parentOption = optionsParentMap.get(key);
|
25391 | if (!parentOption) {
|
25392 | return;
|
25393 | }
|
25394 | map.set(parentOption[valueName], true);
|
25395 | walker(parentOption[valueName]);
|
25396 | };
|
25397 | allSelectedLeafKeys.forEach((key) => {
|
25398 | map.set(key, true);
|
25399 | walker(key);
|
25400 | });
|
25401 | return map;
|
25402 | }, [optionsParentMap, value]);
|
25403 | const onChange = (targetKeys) => {
|
25404 | var _a;
|
25405 | let groupKeys = [...targetKeys];
|
25406 | let unusedKeys = [];
|
25407 | const walker = (keys) => {
|
25408 | keys.forEach((key) => {
|
25409 | var _a2;
|
25410 | if (unusedKeys.includes(key)) {
|
25411 | return;
|
25412 | }
|
25413 | const parent = optionsParentMap.get(key);
|
25414 | if (!parent) {
|
25415 | return;
|
25416 | }
|
25417 | const childrenKeys = ((_a2 = parent[childrenName]) === null || _a2 === void 0 ? void 0 : _a2.map((i2) => i2[valueName])) || [];
|
25418 | if (childrenKeys.every((i2) => groupKeys.includes(i2))) {
|
25419 | groupKeys.push(parent[valueName]);
|
25420 | unusedKeys = unusedKeys.concat(childrenKeys);
|
25421 | }
|
25422 | });
|
25423 | };
|
25424 | for (let i2 = 0; i2 < deep; i2++) {
|
25425 | walker(groupKeys);
|
25426 | }
|
25427 | groupKeys = groupKeys.filter((i2) => !unusedKeys.includes(i2));
|
25428 | const groupOptions = groupKeys.map((i2) => optionsMap.get(i2));
|
25429 | setValue2(groupKeys);
|
25430 | (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, groupKeys, groupOptions);
|
25431 | };
|
25432 | const onItemSelect = (option) => {
|
25433 | var _a;
|
25434 | const parentNodes = [];
|
25435 | let current = option;
|
25436 | while (current) {
|
25437 | parentNodes.unshift(current);
|
25438 | const next = optionsParentMap.get(current[valueName]);
|
25439 | current = next;
|
25440 | }
|
25441 | const keys = parentNodes.map((i2) => i2[valueName]);
|
25442 | setExpandKeys(keys);
|
25443 | (_a = props.onExpand) === null || _a === void 0 ? void 0 : _a.call(props, keys, parentNodes);
|
25444 | };
|
25445 | const renderSelectAllItem = (columnOptions, index2) => {
|
25446 | var _a;
|
25447 | const text = (_a = props.selectAllText) === null || _a === void 0 ? void 0 : _a[index2];
|
25448 | if (!text) {
|
25449 | return;
|
25450 | }
|
25451 | let currentLeafKeys = [];
|
25452 | columnOptions.forEach((option) => {
|
25453 | currentLeafKeys = currentLeafKeys.concat(getLeafKeys(option));
|
25454 | });
|
25455 | const allSelected = currentLeafKeys.every((i2) => allSelectedLeafKeys.includes(i2));
|
25456 | return React$1.createElement("div", {
|
25457 | onClick: () => {
|
25458 | if (allSelected) {
|
25459 | onChange(allSelectedLeafKeys.filter((i2) => !currentLeafKeys.includes(i2)));
|
25460 | } else {
|
25461 | onChange(allSelectedLeafKeys.concat(currentLeafKeys));
|
25462 | }
|
25463 | },
|
25464 | className: `${classPrefix$3}-item`
|
25465 | }, text);
|
25466 | };
|
25467 | const renderSelectAllLeafItem = (columnOptions, index2) => {
|
25468 | var _a;
|
25469 | const text = (_a = props.selectAllText) === null || _a === void 0 ? void 0 : _a[index2];
|
25470 | if (!text) {
|
25471 | return;
|
25472 | }
|
25473 | const currentLeafKeys = columnOptions.map((i2) => i2[valueName]);
|
25474 | const allSelected = currentLeafKeys.every((i2) => allSelectedLeafKeys.includes(i2));
|
25475 | const halfSelected = allSelected ? false : currentLeafKeys.some((i2) => allSelectedLeafKeys.includes(i2));
|
25476 | return React$1.createElement("div", {
|
25477 | onClick: () => {
|
25478 | if (allSelected) {
|
25479 | onChange(allSelectedLeafKeys.filter((i2) => !currentLeafKeys.includes(i2)));
|
25480 | } else {
|
25481 | onChange(allSelectedLeafKeys.concat(currentLeafKeys));
|
25482 | }
|
25483 | },
|
25484 | className: classNames(`${classPrefix$3}-item`, `${classPrefix$3}-item-leaf`)
|
25485 | }, React$1.createElement(Checkbox, {
|
25486 | className: `${classPrefix$3}-item-checkbox`,
|
25487 | checked: allSelected,
|
25488 | indeterminate: halfSelected
|
25489 | }), text);
|
25490 | };
|
25491 | const renderItem = (option) => {
|
25492 | const isExpand = expandKeys.includes(option[valueName]);
|
25493 | return React$1.createElement("div", {
|
25494 | key: option[valueName],
|
25495 | onClick: () => {
|
25496 | if (!isExpand) {
|
25497 | onItemSelect(option);
|
25498 | }
|
25499 | },
|
25500 | className: classNames(`${classPrefix$3}-item`, {
|
25501 | [`${classPrefix$3}-item-expand`]: isExpand
|
25502 | })
|
25503 | }, option[labelName], !!dotMap.get(option[valueName]) && React$1.createElement("div", {
|
25504 | className: `${classPrefix$3}-dot`
|
25505 | }));
|
25506 | };
|
25507 | const renderLeafItem = (option) => {
|
25508 | const isSelected = allSelectedLeafKeys.includes(option[valueName]);
|
25509 | return React$1.createElement("div", {
|
25510 | key: option[valueName],
|
25511 | onClick: () => {
|
25512 | if (isSelected) {
|
25513 | onChange(allSelectedLeafKeys.filter((val) => val !== option[valueName]));
|
25514 | } else {
|
25515 | onChange([...allSelectedLeafKeys, option[valueName]]);
|
25516 | }
|
25517 | },
|
25518 | className: classNames(`${classPrefix$3}-item`, `${classPrefix$3}-item-leaf`)
|
25519 | }, React$1.createElement(Checkbox, {
|
25520 | className: `${classPrefix$3}-item-checkbox`,
|
25521 | checked: isSelected
|
25522 | }), option[labelName]);
|
25523 | };
|
25524 | const renderItems = (columnOptions = [], index2) => {
|
25525 | if (columnOptions.length === 0) {
|
25526 | return;
|
25527 | }
|
25528 | const isLeaf = deep === index2 + 1;
|
25529 | if (isLeaf) {
|
25530 | return React$1.createElement(React$1.Fragment, null, renderSelectAllLeafItem(columnOptions, index2), columnOptions.map((option) => renderLeafItem(option)));
|
25531 | }
|
25532 | return React$1.createElement(React$1.Fragment, null, renderSelectAllItem(columnOptions, index2), columnOptions.map((option) => renderItem(option)));
|
25533 | };
|
25534 | const renderColumns = () => {
|
25535 | var _a;
|
25536 | const columns = [];
|
25537 | for (let i2 = 0; i2 < deep; i2++) {
|
25538 | let width = `${100 / deep}%`;
|
25539 | if (deep === 2 && i2 === 0) {
|
25540 | width = `33.33%`;
|
25541 | }
|
25542 | if (deep === 2 && i2 === 1) {
|
25543 | width = `66.67%`;
|
25544 | }
|
25545 | const column = React$1.createElement("div", {
|
25546 | key: i2,
|
25547 | className: classNames(`${classPrefix$3}-column`),
|
25548 | style: {
|
25549 | width
|
25550 | }
|
25551 | }, renderItems(i2 === 0 ? props.options : (_a = optionsMap.get(expandKeys[i2 - 1])) === null || _a === void 0 ? void 0 : _a[childrenName], i2));
|
25552 | columns.push(column);
|
25553 | }
|
25554 | return columns;
|
25555 | };
|
25556 | return withNativeProps(props, React$1.createElement("div", {
|
25557 | className: classPrefix$3
|
25558 | }, renderColumns()));
|
25559 | };
|
25560 | const index = attachPropertiesToComponent(TreeSelect, {
|
25561 | Multiple
|
25562 | });
|
25563 | const classPrefix$2 = "adm-virtual-input";
|
25564 | const defaultProps$2 = {
|
25565 | defaultValue: ""
|
25566 | };
|
25567 | const VirtualInput = React$1.forwardRef((props, ref) => {
|
25568 | const {
|
25569 | locale,
|
25570 | input: componentConfig = {}
|
25571 | } = useConfig();
|
25572 | const mergedProps = mergeProps(defaultProps$2, componentConfig, props);
|
25573 | const [value, setValue2] = usePropsValue(mergedProps);
|
25574 | const rootRef = React$1.useRef(null);
|
25575 | const contentRef = React$1.useRef(null);
|
25576 | const [hasFocus, setHasFocus] = React$1.useState(false);
|
25577 | const clearIcon = mergeProp(React$1.createElement(CloseCircleFill, null), componentConfig.clearIcon, props.clearIcon);
|
25578 | function scrollToEnd() {
|
25579 | const root2 = rootRef.current;
|
25580 | if (!root2)
|
25581 | return;
|
25582 | if (document.activeElement !== root2) {
|
25583 | return;
|
25584 | }
|
25585 | const content = contentRef.current;
|
25586 | if (!content)
|
25587 | return;
|
25588 | content.scrollLeft = content.clientWidth;
|
25589 | }
|
25590 | useIsomorphicLayoutEffect$2(() => {
|
25591 | scrollToEnd();
|
25592 | }, [value]);
|
25593 | React$1.useEffect(() => {
|
25594 | if (hasFocus) {
|
25595 | scrollToEnd();
|
25596 | }
|
25597 | }, [hasFocus]);
|
25598 | React$1.useImperativeHandle(ref, () => ({
|
25599 | focus: () => {
|
25600 | var _a;
|
25601 | (_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
25602 | },
|
25603 | blur: () => {
|
25604 | var _a;
|
25605 | (_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
25606 | }
|
25607 | }));
|
25608 | function onFocus() {
|
25609 | var _a;
|
25610 | setHasFocus(true);
|
25611 | (_a = mergedProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
|
25612 | }
|
25613 | function onBlur() {
|
25614 | var _a;
|
25615 | setHasFocus(false);
|
25616 | (_a = mergedProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
|
25617 | }
|
25618 | const keyboard = mergedProps.keyboard;
|
25619 | const keyboardElement = keyboard && React$1.cloneElement(keyboard, {
|
25620 | onInput: (v) => {
|
25621 | var _a, _b;
|
25622 | setValue2(value + v);
|
25623 | (_b = (_a = keyboard.props).onInput) === null || _b === void 0 ? void 0 : _b.call(_a, v);
|
25624 | },
|
25625 | onDelete: () => {
|
25626 | var _a, _b;
|
25627 | setValue2(value.slice(0, -1));
|
25628 | (_b = (_a = keyboard.props).onDelete) === null || _b === void 0 ? void 0 : _b.call(_a);
|
25629 | },
|
25630 | visible: hasFocus,
|
25631 | onClose: () => {
|
25632 | var _a, _b, _c, _d;
|
25633 | const activeElement = document.activeElement;
|
25634 | if (activeElement && ((_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.contains(activeElement))) {
|
25635 | activeElement.blur();
|
25636 | } else {
|
25637 | (_b = rootRef.current) === null || _b === void 0 ? void 0 : _b.blur();
|
25638 | }
|
25639 | (_d = (_c = keyboard.props).onClose) === null || _d === void 0 ? void 0 : _d.call(_c);
|
25640 | },
|
25641 | getContainer: null
|
25642 | });
|
25643 | return withNativeProps(mergedProps, React$1.createElement("div", {
|
25644 | ref: rootRef,
|
25645 | className: classNames(classPrefix$2, {
|
25646 | [`${classPrefix$2}-disabled`]: mergedProps.disabled
|
25647 | }),
|
25648 | tabIndex: mergedProps.disabled ? void 0 : 0,
|
25649 | role: "textbox",
|
25650 | onFocus,
|
25651 | onBlur,
|
25652 | onClick: mergedProps.onClick
|
25653 | }, React$1.createElement("div", {
|
25654 | className: `${classPrefix$2}-content`,
|
25655 | ref: contentRef,
|
25656 | "aria-disabled": mergedProps.disabled,
|
25657 | "aria-label": mergedProps.placeholder
|
25658 | }, value, React$1.createElement("div", {
|
25659 | className: `${classPrefix$2}-caret-container`
|
25660 | }, hasFocus && React$1.createElement("div", {
|
25661 | className: `${classPrefix$2}-caret`
|
25662 | }))), mergedProps.clearable && !!value && hasFocus && React$1.createElement("div", {
|
25663 | className: `${classPrefix$2}-clear`,
|
25664 | onClick: (e2) => {
|
25665 | var _a;
|
25666 | e2.stopPropagation();
|
25667 | setValue2("");
|
25668 | (_a = mergedProps.onClear) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
|
25669 | },
|
25670 | role: "button",
|
25671 | "aria-label": locale.Input.clear
|
25672 | }, clearIcon), [void 0, null, ""].includes(value) && React$1.createElement("div", {
|
25673 | className: `${classPrefix$2}-placeholder`
|
25674 | }, mergedProps.placeholder), keyboardElement));
|
25675 | });
|
25676 | const classPrefix$1 = `adm-water-mark`;
|
25677 | const defaultProps$1 = {
|
25678 | fullPage: true
|
25679 | };
|
25680 | const WaterMark = (p) => {
|
25681 | const props = mergeProps(defaultProps$1, p);
|
25682 | const {
|
25683 | zIndex,
|
25684 | gapX = 24,
|
25685 | gapY = 48,
|
25686 | width = 120,
|
25687 | height = 64,
|
25688 | rotate = -22,
|
25689 | image,
|
25690 | imageWidth = 120,
|
25691 | imageHeight = 64,
|
25692 | content,
|
25693 | fontStyle = "normal",
|
25694 | fontWeight = "normal",
|
25695 | fontColor = "rgba(0,0,0,.15)",
|
25696 | fontSize = 14,
|
25697 | fontFamily = "sans-serif"
|
25698 | } = props;
|
25699 | const [base64Url, setBase64Url] = React$1.useState("");
|
25700 | React$1.useEffect(() => {
|
25701 | const canvas = document.createElement("canvas");
|
25702 | const ratio = window.devicePixelRatio;
|
25703 | const ctx2 = canvas.getContext("2d");
|
25704 | const canvasWidth = `${(gapX + width) * ratio}px`;
|
25705 | const canvasHeight = `${(gapY + height) * ratio}px`;
|
25706 | const markWidth = width * ratio;
|
25707 | const markHeight = height * ratio;
|
25708 | canvas.setAttribute("width", canvasWidth);
|
25709 | canvas.setAttribute("height", canvasHeight);
|
25710 | if (ctx2) {
|
25711 | if (image) {
|
25712 | ctx2.translate(markWidth / 2, markHeight / 2);
|
25713 | ctx2.rotate(Math.PI / 180 * Number(rotate));
|
25714 | const img = new Image();
|
25715 | img.crossOrigin = "anonymous";
|
25716 | img.referrerPolicy = "no-referrer";
|
25717 | img.onload = () => {
|
25718 | ctx2.drawImage(img, -imageWidth * ratio / 2, -imageHeight * ratio / 2, imageWidth * ratio, imageHeight * ratio);
|
25719 | ctx2.restore();
|
25720 | setBase64Url(canvas.toDataURL());
|
25721 | };
|
25722 | img.src = image;
|
25723 | } else if (content) {
|
25724 | ctx2.textBaseline = "middle";
|
25725 | ctx2.textAlign = "center";
|
25726 | ctx2.translate(markWidth / 2, markHeight / 2);
|
25727 | ctx2.rotate(Math.PI / 180 * Number(rotate));
|
25728 | const markSize = Number(fontSize) * ratio;
|
25729 | ctx2.font = `${fontStyle} normal ${fontWeight} ${markSize}px/${markHeight}px ${fontFamily}`;
|
25730 | ctx2.fillStyle = fontColor;
|
25731 | if (Array.isArray(content)) {
|
25732 | content.forEach((item, index2) => ctx2.fillText(item, 0, index2 * markSize));
|
25733 | } else {
|
25734 | ctx2.fillText(content, 0, 0);
|
25735 | }
|
25736 | ctx2.restore();
|
25737 | setBase64Url(canvas.toDataURL());
|
25738 | }
|
25739 | } else {
|
25740 | throw new Error("Canvas is not supported in the current environment");
|
25741 | }
|
25742 | }, [gapX, gapY, rotate, fontStyle, fontWeight, width, height, fontFamily, fontColor, image, content, fontSize]);
|
25743 | return withNativeProps(props, React$1.createElement("div", {
|
25744 | className: classNames(classPrefix$1, {
|
25745 | [`${classPrefix$1}-full-page`]: props.fullPage
|
25746 | }),
|
25747 | style: {
|
25748 | zIndex,
|
25749 | backgroundSize: `${gapX + width}px`,
|
25750 |
|
25751 | backgroundImage: base64Url === "" ? void 0 : `url('${base64Url}')`
|
25752 | }
|
25753 | }));
|
25754 | };
|
25755 | const classPrefix = `adm-footer`;
|
25756 | const defaultProps = {
|
25757 | label: "",
|
25758 | links: [],
|
25759 | content: "",
|
25760 | chips: []
|
25761 | };
|
25762 | const Footer = (p) => {
|
25763 | const props = mergeProps(defaultProps, p);
|
25764 | const {
|
25765 | label,
|
25766 | links,
|
25767 | content,
|
25768 | chips,
|
25769 | onChipClick,
|
25770 | onLinkClick
|
25771 | } = props;
|
25772 | const clickChipItem = (item, index2) => {
|
25773 | if ((chips === null || chips === void 0 ? void 0 : chips.length) && item.type === "link") {
|
25774 | onChipClick === null || onChipClick === void 0 ? void 0 : onChipClick(item, index2);
|
25775 | }
|
25776 | };
|
25777 | const clickLinkItem = (item, index2, e2) => {
|
25778 | if (onLinkClick) {
|
25779 | e2.preventDefault();
|
25780 | onLinkClick(item, index2);
|
25781 | }
|
25782 | };
|
25783 | return withNativeProps(props, React$1.createElement("div", {
|
25784 | className: classNames(classPrefix)
|
25785 | }, label && React$1.createElement("div", {
|
25786 | className: `${classPrefix}-label`
|
25787 | }, React$1.createElement(Divider, null, label)), !!(links === null || links === void 0 ? void 0 : links.length) && React$1.createElement("div", {
|
25788 | className: `${classPrefix}-links`
|
25789 | }, links.map((link, index2) => React$1.createElement(React$1.Fragment, {
|
25790 | key: index2
|
25791 | }, React$1.createElement("a", {
|
25792 | href: link.href,
|
25793 | rel: "noopener noreferrer",
|
25794 | onClick: (event) => clickLinkItem(link, index2, event)
|
25795 | }, link.text), index2 !== links.length - 1 && React$1.createElement(Divider, {
|
25796 | direction: "vertical"
|
25797 | })))), content && React$1.createElement("div", {
|
25798 | className: `${classPrefix}-content`
|
25799 | }, content), chips && chips.length > 0 && React$1.createElement("div", {
|
25800 | className: `${classPrefix}-chips`
|
25801 | }, chips.map((chip, index2) => React$1.createElement("div", {
|
25802 | key: index2,
|
25803 | onClick: () => clickChipItem(chip, index2),
|
25804 | className: classNames(`${classPrefix}-chip`, {
|
25805 | [`${classPrefix}-chip-link`]: chip.type === "link"
|
25806 | })
|
25807 | }, chip.text)))));
|
25808 | };
|
25809 | exports2.ActionSheet = index$i;
|
25810 | exports2.AutoCenter = AutoCenter;
|
25811 | exports2.Avatar = Avatar;
|
25812 | exports2.Badge = Badge;
|
25813 | exports2.Button = Button;
|
25814 | exports2.Calendar = Calendar;
|
25815 | exports2.CalendarPicker = CalendarPicker;
|
25816 | exports2.CalendarPickerView = CalendarPickerView;
|
25817 | exports2.CapsuleTabs = index$h;
|
25818 | exports2.Card = Card;
|
25819 | exports2.CascadePicker = index$g;
|
25820 | exports2.CascadePickerView = CascadePickerView;
|
25821 | exports2.Cascader = index$f;
|
25822 | exports2.CascaderView = CascaderView;
|
25823 | exports2.CenterPopup = CenterPopup;
|
25824 | exports2.CheckList = CheckList;
|
25825 | exports2.Checkbox = Checkbox;
|
25826 | exports2.Collapse = index$e;
|
25827 | exports2.ConfigProvider = ConfigProvider;
|
25828 | exports2.DatePicker = index$d;
|
25829 | exports2.DatePickerView = DatePickerView;
|
25830 | exports2.Dialog = index$c;
|
25831 | exports2.Divider = Divider;
|
25832 | exports2.DotLoading = DotLoading;
|
25833 | exports2.Dropdown = index$b;
|
25834 | exports2.Ellipsis = Ellipsis;
|
25835 | exports2.Empty = Empty;
|
25836 | exports2.ErrorBlock = ErrorBlock;
|
25837 | exports2.FloatingBubble = FloatingBubble;
|
25838 | exports2.FloatingPanel = FloatingPanel;
|
25839 | exports2.Footer = Footer;
|
25840 | exports2.Form = index$a;
|
25841 | exports2.Grid = Grid;
|
25842 | exports2.Image = Image$1;
|
25843 | exports2.ImageUploader = ImageUploader;
|
25844 | exports2.ImageViewer = ImageViewer;
|
25845 | exports2.IndexBar = index$9;
|
25846 | exports2.InfiniteScroll = InfiniteScroll;
|
25847 | exports2.Input = Input;
|
25848 | exports2.JumboTabs = index$8;
|
25849 | exports2.List = List$1;
|
25850 | exports2.Loading = DotLoading;
|
25851 | exports2.Mask = Mask;
|
25852 | exports2.Modal = index$7;
|
25853 | exports2.NavBar = NavBar;
|
25854 | exports2.NoticeBar = NoticeBar;
|
25855 | exports2.NumberKeyboard = NumberKeyboard;
|
25856 | exports2.PageIndicator = PageIndicator;
|
25857 | exports2.PasscodeInput = PasscodeInput;
|
25858 | exports2.Picker = Picker;
|
25859 | exports2.PickerView = PickerView;
|
25860 | exports2.Popover = Popover;
|
25861 | exports2.Popup = Popup;
|
25862 | exports2.ProgressBar = ProgressBar;
|
25863 | exports2.ProgressCircle = ProgressCircle;
|
25864 | exports2.PullToRefresh = PullToRefresh;
|
25865 | exports2.Radio = index$6;
|
25866 | exports2.Rate = Rate;
|
25867 | exports2.Result = Result;
|
25868 | exports2.ResultPage = index$5;
|
25869 | exports2.SafeArea = SafeArea;
|
25870 | exports2.ScrollMask = ScrollMask;
|
25871 | exports2.SearchBar = SearchBar;
|
25872 | exports2.Selector = Selector;
|
25873 | exports2.SideBar = index$4;
|
25874 | exports2.Skeleton = Skeleton;
|
25875 | exports2.Slider = Slider;
|
25876 | exports2.Space = Space;
|
25877 | exports2.SpinLoading = SpinLoading;
|
25878 | exports2.Stepper = Stepper;
|
25879 | exports2.Steps = index$3;
|
25880 | exports2.SwipeAction = SwipeAction;
|
25881 | exports2.Swiper = index$2;
|
25882 | exports2.Switch = Switch;
|
25883 | exports2.TabBar = index$1;
|
25884 | exports2.Tabs = Tabs;
|
25885 | exports2.Tag = Tag;
|
25886 | exports2.TextArea = TextArea;
|
25887 | exports2.Toast = Toast$1;
|
25888 | exports2.TreeSelect = index;
|
25889 | exports2.VirtualInput = VirtualInput;
|
25890 | exports2.WaterMark = WaterMark;
|
25891 | exports2.createErrorBlock = createErrorBlock;
|
25892 | exports2.reduceMotion = reduceMotion;
|
25893 | exports2.restoreMotion = restoreMotion;
|
25894 | exports2.setDefaultConfig = setDefaultConfig;
|
25895 | exports2.useConfig = useConfig;
|
25896 | Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
25897 | });
|