deepsea-components 1.3.3 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,869 @@
1
+ var _templateObject;
2
+ var _excluded = ["multiple", "type", "onChange", "disabled"],
3
+ _excluded2 = ["onChange"],
4
+ _excluded3 = ["data", "fileName", "onClick"],
5
+ _excluded4 = ["style", "containerClassName", "containerStyle", "children", "vertical", "horizontal", "time"],
6
+ _excluded5 = ["outerWidth", "innerWidth", "style"],
7
+ _excluded6 = ["itemWidth", "itemHeight", "columnGap", "rowGap", "maxRows", "data", "render", "keyExactor", "className", "style", "containerClassName", "containerStyle", "throttle", "transitionDuration", "onSizeChange"],
8
+ _excluded7 = ["top", "bottom", "height", "borderRadius", "style"],
9
+ _excluded8 = ["outerRadius", "innerRadius", "count", "angel", "style"],
10
+ _excluded9 = ["children", "period", "numToStr"],
11
+ _excluded10 = ["width", "height", "radius", "startAngel", "gapAngel", "align", "style", "direction", "reverse", "separator", "children"],
12
+ _excluded11 = ["children", "containerClassName", "containerStyle", "options", "className"],
13
+ _excluded12 = ["thumbWidth"];
14
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
15
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
16
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
17
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
19
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
20
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
21
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
22
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
23
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
24
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
25
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
26
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
27
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
28
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
29
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
30
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
31
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
32
+ import { css } from "@emotion/css";
33
+ import clsx from "clsx";
34
+ import { drawArc, setFrameInterval } from "deepsea-tools";
35
+ import { Fragment, forwardRef, useEffect, useId, useImperativeHandle, useRef, useState } from "react";
36
+ import SmoothScrollBar from "smooth-scrollbar";
37
+ import { read, utils, writeFile } from "xlsx";
38
+ import { jsx as _jsx } from "react/jsx-runtime";
39
+ import { jsxs as _jsxs } from "react/jsx-runtime";
40
+ export function getFileData(_x, _x2) {
41
+ return _getFileData.apply(this, arguments);
42
+ }
43
+
44
+ /** 专用与读取文件的组件 */
45
+ function _getFileData() {
46
+ _getFileData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(file, type) {
47
+ var fileReader;
48
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
49
+ while (1) switch (_context2.prev = _context2.next) {
50
+ case 0:
51
+ fileReader = new FileReader();
52
+ _context2.t0 = type;
53
+ _context2.next = _context2.t0 === "arrayBuffer" ? 4 : _context2.t0 === "binary" ? 6 : _context2.t0 === "base64" ? 8 : _context2.t0 === "text" ? 10 : 12;
54
+ break;
55
+ case 4:
56
+ fileReader.readAsArrayBuffer(file);
57
+ return _context2.abrupt("break", 13);
58
+ case 6:
59
+ fileReader.readAsBinaryString(file);
60
+ return _context2.abrupt("break", 13);
61
+ case 8:
62
+ fileReader.readAsDataURL(file);
63
+ return _context2.abrupt("break", 13);
64
+ case 10:
65
+ fileReader.readAsText(file);
66
+ return _context2.abrupt("break", 13);
67
+ case 12:
68
+ return _context2.abrupt("return", file);
69
+ case 13:
70
+ return _context2.abrupt("return", new Promise(function (resolve) {
71
+ fileReader.addEventListener("load", function () {
72
+ resolve(fileReader.result);
73
+ });
74
+ }));
75
+ case 14:
76
+ case "end":
77
+ return _context2.stop();
78
+ }
79
+ }, _callee2);
80
+ }));
81
+ return _getFileData.apply(this, arguments);
82
+ }
83
+ export var InputFile = /*#__PURE__*/forwardRef(function (props, ref) {
84
+ var _props$multiple = props.multiple,
85
+ multiple = _props$multiple === void 0 ? false : _props$multiple,
86
+ _props$type = props.type,
87
+ type = _props$type === void 0 ? "file" : _props$type,
88
+ onChange = props.onChange,
89
+ inputDisabled = props.disabled,
90
+ others = _objectWithoutProperties(props, _excluded);
91
+ var _useState = useState(false),
92
+ _useState2 = _slicedToArray(_useState, 2),
93
+ disabled = _useState2[0],
94
+ setDisabled = _useState2[1];
95
+ function onInputChange(_x3) {
96
+ return _onInputChange.apply(this, arguments);
97
+ }
98
+ function _onInputChange() {
99
+ _onInputChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
100
+ var input, files, result, _i, _Array$from, file;
101
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
102
+ while (1) switch (_context.prev = _context.next) {
103
+ case 0:
104
+ input = e.target;
105
+ files = input.files;
106
+ if (!(!files || files.length === 0)) {
107
+ _context.next = 4;
108
+ break;
109
+ }
110
+ return _context.abrupt("return");
111
+ case 4:
112
+ setDisabled(true);
113
+ _context.prev = 5;
114
+ if (!multiple) {
115
+ _context.next = 24;
116
+ break;
117
+ }
118
+ result = [];
119
+ _i = 0, _Array$from = Array.from(files);
120
+ case 9:
121
+ if (!(_i < _Array$from.length)) {
122
+ _context.next = 21;
123
+ break;
124
+ }
125
+ file = _Array$from[_i];
126
+ _context.t0 = result;
127
+ _context.next = 14;
128
+ return getFileData(file, type);
129
+ case 14:
130
+ _context.t1 = _context.sent;
131
+ _context.t2 = file;
132
+ _context.t3 = {
133
+ result: _context.t1,
134
+ file: _context.t2
135
+ };
136
+ _context.t0.push.call(_context.t0, _context.t3);
137
+ case 18:
138
+ _i++;
139
+ _context.next = 9;
140
+ break;
141
+ case 21:
142
+ onChange === null || onChange === void 0 || onChange(result);
143
+ _context.next = 33;
144
+ break;
145
+ case 24:
146
+ _context.t4 = onChange === null || onChange === void 0;
147
+ if (_context.t4) {
148
+ _context.next = 33;
149
+ break;
150
+ }
151
+ _context.t5 = onChange;
152
+ _context.next = 29;
153
+ return getFileData(files[0], type);
154
+ case 29:
155
+ _context.t6 = _context.sent;
156
+ _context.t7 = files[0];
157
+ _context.t8 = {
158
+ result: _context.t6,
159
+ file: _context.t7
160
+ };
161
+ (0, _context.t5)(_context.t8);
162
+ case 33:
163
+ setDisabled(false);
164
+ input.value = "";
165
+ _context.next = 42;
166
+ break;
167
+ case 37:
168
+ _context.prev = 37;
169
+ _context.t9 = _context["catch"](5);
170
+ setDisabled(false);
171
+ input.value = "";
172
+ throw _context.t9;
173
+ case 42:
174
+ case "end":
175
+ return _context.stop();
176
+ }
177
+ }, _callee, null, [[5, 37]]);
178
+ }));
179
+ return _onInputChange.apply(this, arguments);
180
+ }
181
+ return /*#__PURE__*/_jsx("input", _objectSpread({
182
+ disabled: disabled && inputDisabled,
183
+ ref: ref,
184
+ type: "file",
185
+ multiple: multiple,
186
+ onChange: onInputChange
187
+ }, others));
188
+ });
189
+ /** 专门用于读取 excel 的组件 */
190
+ export var ImportExcel = /*#__PURE__*/forwardRef(function (props, ref) {
191
+ var onChange = props.onChange,
192
+ others = _objectWithoutProperties(props, _excluded2);
193
+ function onInputChange(data) {
194
+ var wb = read(data.result);
195
+ var result = utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
196
+ if (_typeof(result) === "object") {
197
+ var $ = result.map(function (it) {
198
+ var _ = {};
199
+ Object.keys(it).filter(function (key) {
200
+ return key !== "__rowNum__";
201
+ }).forEach(function (key) {
202
+ return _[key] = String(it[key]);
203
+ });
204
+ return _;
205
+ });
206
+ onChange === null || onChange === void 0 || onChange($);
207
+ }
208
+ }
209
+ return /*#__PURE__*/_jsx(InputFile, _objectSpread({
210
+ ref: ref,
211
+ accept: ".xlsx",
212
+ type: "arrayBuffer",
213
+ onChange: onInputChange
214
+ }, others));
215
+ });
216
+
217
+ /** 手动导出 excel */
218
+ export function exportExcel(data, name) {
219
+ var workSheet = utils.json_to_sheet(data);
220
+ var workBook = utils.book_new();
221
+ utils.book_append_sheet(workBook, workSheet);
222
+ writeFile(workBook, "".concat(name).concat(name.endsWith(".xlsx") ? "" : ".xlsx"));
223
+ }
224
+ /** 导出 excel 的 button 组件 */
225
+ export var ExportExcel = /*#__PURE__*/forwardRef(function (props, ref) {
226
+ var data = props.data,
227
+ fileName = props.fileName,
228
+ onClick = props.onClick,
229
+ others = _objectWithoutProperties(props, _excluded3);
230
+ function onButtonClick(e) {
231
+ exportExcel(data, fileName);
232
+ onClick === null || onClick === void 0 || onClick(e);
233
+ }
234
+ return /*#__PURE__*/_jsx("button", _objectSpread({
235
+ ref: ref,
236
+ onClick: onButtonClick
237
+ }, others));
238
+ });
239
+ /** 尺寸渐变的组件 */
240
+ export var TransitionBox = function TransitionBox(props) {
241
+ var style = props.style,
242
+ containerClassName = props.containerClassName,
243
+ containerStyle = props.containerStyle,
244
+ children = props.children,
245
+ _props$vertical = props.vertical,
246
+ vertical = _props$vertical === void 0 ? true : _props$vertical,
247
+ _props$horizontal = props.horizontal,
248
+ horizontal = _props$horizontal === void 0 ? true : _props$horizontal,
249
+ _props$time = props.time,
250
+ time = _props$time === void 0 ? 3000 : _props$time,
251
+ others = _objectWithoutProperties(props, _excluded4);
252
+ var box = useRef(null);
253
+ var _useState3 = useState(0),
254
+ _useState4 = _slicedToArray(_useState3, 2),
255
+ width = _useState4[0],
256
+ setWidth = _useState4[1];
257
+ var _useState5 = useState(0),
258
+ _useState6 = _slicedToArray(_useState5, 2),
259
+ height = _useState6[0],
260
+ setHeight = _useState6[1];
261
+ var _useState7 = useState(0),
262
+ _useState8 = _slicedToArray(_useState7, 2),
263
+ count = _useState8[0],
264
+ setCount = _useState8[1];
265
+ useEffect(function () {
266
+ var observer = new ResizeObserver(function (entries) {
267
+ var _entries$0$contentRec = entries[0].contentRect,
268
+ currentWidth = _entries$0$contentRec.width,
269
+ currentHeight = _entries$0$contentRec.height;
270
+ setWidth(currentWidth);
271
+ setHeight(currentHeight);
272
+ });
273
+ observer.observe(box.current);
274
+ return function () {
275
+ observer.disconnect();
276
+ };
277
+ }, []);
278
+ useEffect(function () {
279
+ setCount(function (count) {
280
+ return Math.min(count + 1, 3);
281
+ });
282
+ }, [width, height]);
283
+ var outerStyle = _objectSpread({
284
+ transitionProperty: count === 3 ? [horizontal && "width", vertical && "height"].filter(Boolean).join(", ") : undefined,
285
+ transitionDuration: count === 3 ? "".concat(time, "ms") : undefined,
286
+ width: width,
287
+ height: height,
288
+ overflow: "hidden",
289
+ position: "relative"
290
+ }, style);
291
+ return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
292
+ style: outerStyle
293
+ }, others), {}, {
294
+ children: /*#__PURE__*/_jsx("div", {
295
+ className: containerClassName,
296
+ style: _objectSpread({
297
+ position: "absolute"
298
+ }, containerStyle),
299
+ ref: box,
300
+ children: children
301
+ })
302
+ }));
303
+ };
304
+ /** 雷达组件 */
305
+ export var SeaRadar = function SeaRadar(props) {
306
+ var _props$unitRadius = props.unitRadius,
307
+ unitRadius = _props$unitRadius === void 0 ? 50 : _props$unitRadius,
308
+ _props$circleCount = props.circleCount,
309
+ circleCount = _props$circleCount === void 0 ? 4 : _props$circleCount,
310
+ _props$circleWidth = props.circleWidth,
311
+ circleWidth = _props$circleWidth === void 0 ? 1 : _props$circleWidth,
312
+ circleColor = props.circleColor,
313
+ _props$directionCount = props.directionCount,
314
+ directionCount = _props$directionCount === void 0 ? 36 : _props$directionCount,
315
+ _props$directionWidth = props.directionWidth,
316
+ directionWidth = _props$directionWidth === void 0 ? 1 : _props$directionWidth,
317
+ directionColor = props.directionColor,
318
+ backgroundColor = props.backgroundColor,
319
+ scanColor = props.scanColor,
320
+ _props$scanAngle = props.scanAngle,
321
+ scanAngle = _props$scanAngle === void 0 ? Math.PI / 6 : _props$scanAngle,
322
+ _props$period = props.period,
323
+ period = _props$period === void 0 ? 8 : _props$period,
324
+ targets = props.targets,
325
+ showGraduationLine = props.showGraduationLine,
326
+ showGraduationText = props.showGraduationText,
327
+ showCircle = props.showCircle,
328
+ showDirection = props.showDirection;
329
+ var style = {
330
+ "--unit-radius": "".concat(unitRadius, "px"),
331
+ "--circle-count": circleCount,
332
+ "--circle-width": "".concat(circleWidth, "px"),
333
+ "--circle-color": circleColor,
334
+ "--direction-count": directionCount,
335
+ "--direction-width": "".concat(directionWidth, "px"),
336
+ "--direction-color": directionColor,
337
+ "--background-color": backgroundColor,
338
+ "--scan-color": scanColor,
339
+ "--period": "".concat(period, "s")
340
+ };
341
+ return /*#__PURE__*/_jsxs("div", {
342
+ className: "sea-radar-wrapper",
343
+ style: style,
344
+ children: [Array(180).fill(0).map(function (_, index) {
345
+ return /*#__PURE__*/_jsx("div", {
346
+ className: "sea-radar-little-graduation",
347
+ style: {
348
+ transform: "rotateZ(".concat(2 * index, "deg)"),
349
+ display: showGraduationLine ? "block" : "none"
350
+ }
351
+ });
352
+ }), Array(36).fill(0).map(function (_, index) {
353
+ return /*#__PURE__*/_jsx("div", {
354
+ className: "sea-radar-graduation",
355
+ style: {
356
+ transform: "rotateZ(".concat(10 * index, "deg)"),
357
+ display: showGraduationLine ? "block" : "none"
358
+ },
359
+ children: /*#__PURE__*/_jsx("span", {
360
+ className: "sea-radar-graduation-text",
361
+ style: {
362
+ display: showGraduationText ? "block" : "none"
363
+ },
364
+ children: String(index * 10).padStart(3, "0")
365
+ })
366
+ });
367
+ }), /*#__PURE__*/_jsxs("div", {
368
+ className: "sea-radar",
369
+ children: [/*#__PURE__*/_jsx("div", {
370
+ className: "sea-radar-scan",
371
+ style: {
372
+ height: "".concat(unitRadius * circleCount * Math.tan(scanAngle), "px"),
373
+ clipPath: "polygon(0 0, 0 100%, 100% 100%)"
374
+ }
375
+ }), showCircle && Array(circleCount).fill(0).map(function (_, index) {
376
+ return /*#__PURE__*/_jsx("div", {
377
+ className: "sea-radar-circle",
378
+ style: {
379
+ width: "".concat(unitRadius * 2 * (index + 1), "px"),
380
+ height: "".concat(unitRadius * 2 * (index + 1), "px")
381
+ }
382
+ });
383
+ }), showDirection && Array(directionCount).fill(0).map(function (_, index) {
384
+ return /*#__PURE__*/_jsx("div", {
385
+ className: "sea-radar-direction",
386
+ style: {
387
+ transform: "rotateZ(".concat(360 / directionCount * index, "deg)")
388
+ }
389
+ });
390
+ }), targets === null || targets === void 0 ? void 0 : targets.map(function (it) {
391
+ return /*#__PURE__*/_jsx("div", {
392
+ className: "sea-radar-target",
393
+ style: {
394
+ left: "".concat(unitRadius * circleCount + it.radius * Math.cos(it.angle), "px"),
395
+ bottom: "".concat(unitRadius * circleCount + it.radius * Math.sin(it.angle), "px")
396
+ },
397
+ children: it.element
398
+ });
399
+ })]
400
+ })]
401
+ });
402
+ };
403
+ /** 忘了什么组件 */
404
+ export var Ring = function Ring(props) {
405
+ var outerWidth = props.outerWidth,
406
+ innerWidth = props.innerWidth,
407
+ style = props.style,
408
+ leftProps = _objectWithoutProperties(props, _excluded5);
409
+ var outerRadius = outerWidth / 2;
410
+ var innerRadius = innerWidth / 2;
411
+ return /*#__PURE__*/_jsx("div", _objectSpread({
412
+ style: _objectSpread(_objectSpread({}, style), {}, {
413
+ width: "".concat(outerWidth, "px"),
414
+ height: "".concat(outerWidth, "px"),
415
+ clipPath: "path(\"M0,".concat(outerRadius, " a").concat(outerRadius, ",").concat(outerRadius, ",0,1,0,").concat(outerWidth, ",0 a").concat(outerRadius, ",").concat(outerRadius, ",0,1,0,-").concat(outerWidth, ",0 l").concat(outerRadius - innerRadius, ",0 a").concat(innerRadius, ",").concat(innerRadius, ",0,0,1,").concat(innerRadius * 2, ",0 a").concat(innerRadius, ",").concat(innerRadius, ",0,0,1,-").concat(innerRadius * 2, ",0 Z\")")
416
+ })
417
+ }, leftProps));
418
+ };
419
+ export function getGapRange(gap) {
420
+ if (typeof gap === "number") return [gap, gap];
421
+ if (Array.isArray(gap)) return [gap[0] || 0, gap[1]];
422
+ return [0, null];
423
+ }
424
+ export function getGapCountAndSize(width, itemWidth, minGap, maxGap) {
425
+ var count = Math.floor((width + minGap) / (itemWidth + minGap)) || 1;
426
+ if (count === 1) return [count, 0];
427
+ var averageGap = (width - itemWidth * count) / (count - 1);
428
+ if (averageGap < minGap) return [count, minGap];
429
+ if (maxGap !== null && averageGap > maxGap) return [count, maxGap];
430
+ return [count, averageGap];
431
+ }
432
+
433
+ /** 自适应浮动组件 */
434
+ export function Flow(props) {
435
+ var itemWidth = props.itemWidth,
436
+ itemHeight = props.itemHeight,
437
+ columnGap = props.columnGap,
438
+ _props$rowGap = props.rowGap,
439
+ rowGap = _props$rowGap === void 0 ? 0 : _props$rowGap,
440
+ maxRows = props.maxRows,
441
+ data = props.data,
442
+ render = props.render,
443
+ keyExactor = props.keyExactor,
444
+ className = props.className,
445
+ style = props.style,
446
+ containerClassName = props.containerClassName,
447
+ containerStyle = props.containerStyle,
448
+ throttle = props.throttle,
449
+ transitionDuration = props.transitionDuration,
450
+ onSizeChange = props.onSizeChange,
451
+ others = _objectWithoutProperties(props, _excluded6);
452
+ var _getGapRange = getGapRange(columnGap),
453
+ _getGapRange2 = _slicedToArray(_getGapRange, 2),
454
+ minColumnGap = _getGapRange2[0],
455
+ maxColumnGap = _getGapRange2[1];
456
+ var _useState9 = useState(0),
457
+ _useState10 = _slicedToArray(_useState9, 2),
458
+ width = _useState10[0],
459
+ setWidth = _useState10[1];
460
+ var _useState11 = useState(1),
461
+ _useState12 = _slicedToArray(_useState11, 2),
462
+ columnCount = _useState12[0],
463
+ setColumnCount = _useState12[1];
464
+ var _useState13 = useState(minColumnGap),
465
+ _useState14 = _slicedToArray(_useState13, 2),
466
+ columnGapSize = _useState14[0],
467
+ setColumnGapSize = _useState14[1];
468
+ var _useState15 = useState(false),
469
+ _useState16 = _slicedToArray(_useState15, 2),
470
+ showItems = _useState16[0],
471
+ setShowItems = _useState16[1];
472
+ var ele = useRef(null);
473
+ var contentRows = Math.ceil(data.length / columnCount);
474
+ var contentShownRows = typeof maxRows === "number" ? Math.min(contentRows, maxRows) : contentRows;
475
+ var height = contentShownRows > 0 ? contentShownRows * (itemHeight + rowGap) - rowGap : 0;
476
+ function getPosition(index) {
477
+ var y = Math.floor(index / columnCount);
478
+ var x = index - y * columnCount;
479
+ return {
480
+ left: x * (itemWidth + columnGapSize),
481
+ top: y * (itemHeight + rowGap)
482
+ };
483
+ }
484
+ function getHidden(index) {
485
+ if (typeof maxRows !== "number") return false;
486
+ return index >= maxRows * columnCount;
487
+ }
488
+ useEffect(function () {
489
+ var timeout;
490
+ var observer = new ResizeObserver(function (entries) {
491
+ clearTimeout(timeout);
492
+ function task() {
493
+ var width = entries[0].borderBoxSize[0].inlineSize;
494
+ var _getGapCountAndSize = getGapCountAndSize(width, itemWidth, minColumnGap, maxColumnGap),
495
+ _getGapCountAndSize2 = _slicedToArray(_getGapCountAndSize, 2),
496
+ newColumnCount = _getGapCountAndSize2[0],
497
+ newColumnGapSize = _getGapCountAndSize2[1];
498
+ setShowItems(true);
499
+ setWidth(width);
500
+ setColumnCount(newColumnCount);
501
+ setColumnGapSize(newColumnGapSize);
502
+ }
503
+ if (throttle === null) {
504
+ task();
505
+ } else {
506
+ timeout = window.setTimeout(task, throttle || 200);
507
+ }
508
+ });
509
+ observer.observe(ele.current);
510
+ return function () {
511
+ observer.disconnect();
512
+ };
513
+ }, [itemWidth, throttle, columnGap]);
514
+ useEffect(function () {
515
+ onSizeChange === null || onSizeChange === void 0 || onSizeChange({
516
+ width: width,
517
+ height: height,
518
+ itemWidth: itemWidth,
519
+ itemHeight: itemHeight,
520
+ columnGap: columnGapSize,
521
+ columnCount: columnCount,
522
+ rowGap: rowGap,
523
+ rowCount: contentShownRows,
524
+ overflow: data.length > contentShownRows * columnCount,
525
+ itemCount: data.length,
526
+ maxRows: maxRows !== null && maxRows !== void 0 ? maxRows : null
527
+ });
528
+ }, [width, height, columnGapSize, columnCount, rowGap, contentShownRows, data.length, itemWidth, itemHeight, maxRows]);
529
+ return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
530
+ ref: ele,
531
+ className: className,
532
+ style: _objectSpread({
533
+ position: "relative",
534
+ boxSizing: "border-box",
535
+ height: height
536
+ }, style)
537
+ }, others), {}, {
538
+ children: showItems && data.map(function (it, idx) {
539
+ return /*#__PURE__*/_jsx("div", {
540
+ className: containerClassName,
541
+ style: _objectSpread({
542
+ position: "absolute",
543
+ width: itemWidth,
544
+ height: itemHeight,
545
+ transition: transitionDuration !== null ? "all ".concat(transitionDuration !== null && transitionDuration !== void 0 ? transitionDuration : 400, "ms") : undefined
546
+ }, getPosition(idx)),
547
+ children: /*#__PURE__*/_jsx("div", {
548
+ style: _objectSpread({
549
+ width: itemWidth,
550
+ height: itemHeight,
551
+ display: maxRows && idx >= maxRows * columnCount ? "none" : "block"
552
+ }, containerStyle),
553
+ children: render(it, idx, getHidden(idx))
554
+ })
555
+ }, (keyExactor === null || keyExactor === void 0 ? void 0 : keyExactor(it, idx)) || idx);
556
+ })
557
+ }));
558
+ }
559
+ /** 梯形组件 */
560
+ export var Trapezium = /*#__PURE__*/forwardRef(function (props, ref) {
561
+ var top = props.top,
562
+ bottom = props.bottom,
563
+ height = props.height,
564
+ borderRadius = props.borderRadius,
565
+ style = props.style,
566
+ other = _objectWithoutProperties(props, _excluded7);
567
+ var diff = (bottom - top) / 2;
568
+ var a = Math.atan(height / diff) / 2;
569
+ var b = borderRadius / Math.tan(a);
570
+ var c = b * Math.cos(a * 2);
571
+ var d = b * Math.sin(a * 2);
572
+ var e = Math.PI / 2 - a;
573
+ var f = borderRadius / Math.tan(e);
574
+ var g = f * Math.cos(a * 2);
575
+ var h = f * Math.sin(a * 2);
576
+ return /*#__PURE__*/_jsx("div", _objectSpread({
577
+ ref: ref,
578
+ style: _objectSpread({
579
+ width: bottom,
580
+ height: height,
581
+ clipPath: "path(\"M ".concat(diff + f, " ", 0, " A ").concat(borderRadius, " ").concat(borderRadius, " 0 0 0 ").concat(diff - g, " ").concat(h, " L ").concat(c, " ").concat(height - d, " A ").concat(borderRadius, " ").concat(borderRadius, " 0 0 0 ").concat(b, " ").concat(height, " L ").concat(bottom - b, " ").concat(height, " A ").concat(borderRadius, " ").concat(borderRadius, " 0 0 0 ").concat(bottom - c, " ").concat(height - d, " L ").concat(top + diff + g, " ").concat(h, " A ").concat(borderRadius, " ").concat(borderRadius, " 0 0 0 ").concat(top + diff - f, " ", 0, " Z\")")
582
+ }, style)
583
+ }, other));
584
+ });
585
+ /** 循环播放组件 */
586
+ export function LoopSwiper(props) {
587
+ var data = props.data,
588
+ render = props.render,
589
+ keyExactor = props.keyExactor,
590
+ size = props.size,
591
+ _props$gap = props.gap,
592
+ gap = _props$gap === void 0 ? 0 : _props$gap,
593
+ _props$start = props.start,
594
+ start = _props$start === void 0 ? 0 : _props$start,
595
+ speed = props.speed,
596
+ _props$paused = props.paused,
597
+ paused = _props$paused === void 0 ? false : _props$paused,
598
+ _props$className = props.className,
599
+ className = _props$className === void 0 ? "" : _props$className,
600
+ _props$direction = props.direction,
601
+ direction = _props$direction === void 0 ? "x" : _props$direction;
602
+ if (!(size > 0 && (speed > 0 || speed < 0))) {
603
+ throw new RangeError("size 必须是正数,speed 必须非0");
604
+ }
605
+ var keys = data.map(function (it, idx, arr) {
606
+ return keyExactor ? keyExactor(it, idx, arr) : String(idx);
607
+ });
608
+ var keysRef = useRef(keys);
609
+ var cache = useRef({
610
+ size: size,
611
+ gap: gap,
612
+ speed: speed,
613
+ keys: keys,
614
+ paused: paused,
615
+ className: className,
616
+ direction: direction
617
+ });
618
+ cache.current = {
619
+ size: size,
620
+ gap: gap,
621
+ speed: speed,
622
+ keys: keys,
623
+ paused: paused,
624
+ className: className,
625
+ direction: direction
626
+ };
627
+ var eles = useRef(keys.map(function (key, idx) {
628
+ return {
629
+ key: key,
630
+ dom: null,
631
+ offset: idx * (size + gap) + start
632
+ };
633
+ }));
634
+ if (keysRef.current.length !== keys.length || keysRef.current.some(function (it, idx) {
635
+ return it !== keys[idx];
636
+ })) {
637
+ keysRef.current = keys;
638
+ eles.current = keys.map(function (key, idx) {
639
+ return {
640
+ key: key,
641
+ dom: null,
642
+ offset: idx * (size + gap) + start
643
+ };
644
+ });
645
+ }
646
+ function setStyles() {
647
+ var _cache$current = cache.current,
648
+ size = _cache$current.size,
649
+ speed = _cache$current.speed,
650
+ className = _cache$current.className,
651
+ direction = _cache$current.direction;
652
+ eles.current.forEach(function (it) {
653
+ it.dom.className = className;
654
+ it.dom.style.setProperty("position", "absolute");
655
+ it.dom.style.setProperty("width", "".concat(size, "px"));
656
+ direction === "x" && speed < 0 ? it.dom.style.setProperty("right", "0") : it.dom.style.setProperty("left", "0");
657
+ direction === "y" && speed < 0 ? it.dom.style.setProperty("bottom", "0") : it.dom.style.setProperty("top", "0");
658
+ it.dom.style.setProperty("transform", "translate".concat(direction.toUpperCase(), "(").concat(it.offset * (speed > 0 ? 1 : -1), "px)"));
659
+ });
660
+ }
661
+ useEffect(function () {
662
+ setStyles();
663
+ }, []);
664
+ useEffect(function () {
665
+ var stop = setFrameInterval(function () {
666
+ var _cache$current2 = cache.current,
667
+ size = _cache$current2.size,
668
+ gap = _cache$current2.gap,
669
+ speed = _cache$current2.speed,
670
+ keys = _cache$current2.keys,
671
+ paused = _cache$current2.paused;
672
+ if (paused) return;
673
+ eles.current.length = keys.length;
674
+ var minIndex = 0;
675
+ eles.current.forEach(function (it, idx) {
676
+ if (it.offset < eles.current[minIndex].offset) {
677
+ minIndex = idx;
678
+ }
679
+ });
680
+ var minOffset = eles.current[minIndex].offset;
681
+ eles.current.forEach(function (it, idx) {
682
+ var index = idx;
683
+ if (idx < minIndex) index = eles.current.length + idx;
684
+ it.offset = minOffset + (index - minIndex) * (size + gap);
685
+ var newOffset = it.offset - Math.abs(speed);
686
+ if (newOffset + size + gap <= 0) {
687
+ newOffset += eles.current.length * (size + gap);
688
+ }
689
+ it.offset = newOffset;
690
+ });
691
+ setStyles();
692
+ }, 1);
693
+ return stop;
694
+ }, []);
695
+ function _ref(dom, index) {
696
+ if (!eles.current[index]) return;
697
+ eles.current[index].dom = dom;
698
+ }
699
+ return /*#__PURE__*/_jsx(Fragment, {
700
+ children: data.map(function (it, idx, arr) {
701
+ return /*#__PURE__*/_jsx("div", {
702
+ ref: function ref(dom) {
703
+ return _ref(dom, idx);
704
+ },
705
+ children: render(it, idx, arr)
706
+ }, keys[idx]);
707
+ })
708
+ });
709
+ }
710
+ export var SectionRing = function SectionRing(props) {
711
+ var o = props.outerRadius,
712
+ i = props.innerRadius,
713
+ c = props.count,
714
+ a = props.angel,
715
+ style = props.style,
716
+ others = _objectWithoutProperties(props, _excluded8);
717
+ var s = Math.PI * 2 / c - a;
718
+ function arc(radius, startAngle, endAngle) {
719
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
720
+ return drawArc(o, o, radius, startAngle, endAngle, options);
721
+ }
722
+ return /*#__PURE__*/_jsx("div", _objectSpread({
723
+ style: _objectSpread(_objectSpread({}, style), {}, {
724
+ width: o * 2,
725
+ height: o * 2,
726
+ clipPath: "path(\"".concat(Array(c).fill(0).map(function (it, idx) {
727
+ return "".concat(arc(o, idx * (a + s), idx * (a + s) + a), " ").concat(arc(i, idx * (a + s) + a, idx * (a + s), {
728
+ line: true,
729
+ anticlockwise: true
730
+ }));
731
+ }).join(" "), " Z\")")
732
+ })
733
+ }, others));
734
+ };
735
+ /** 渐变数字组件 */
736
+ export var TransitionNum = /*#__PURE__*/forwardRef(function (props, ref) {
737
+ var num = props.children,
738
+ period = props.period,
739
+ numToStr = props.numToStr,
740
+ others = _objectWithoutProperties(props, _excluded9);
741
+ if (!Number.isInteger(num) || !Number.isInteger(period) || period <= 0) {
742
+ throw new RangeError("目标数字必须是整数,周期必须是正整数");
743
+ }
744
+ var ele = useRef(null);
745
+ var cache = useRef({
746
+ num: num,
747
+ period: period,
748
+ numToStr: numToStr,
749
+ show: num
750
+ });
751
+ cache.current = _objectSpread(_objectSpread({}, cache.current), {}, {
752
+ num: num,
753
+ period: period,
754
+ numToStr: numToStr
755
+ });
756
+ useImperativeHandle(ref, function () {
757
+ return {
758
+ get: function get() {
759
+ return cache.current.show;
760
+ }
761
+ };
762
+ }, []);
763
+ useEffect(function () {
764
+ var _cache$current3 = cache.current,
765
+ num = _cache$current3.num,
766
+ period = _cache$current3.period,
767
+ show = _cache$current3.show,
768
+ numToStr = _cache$current3.numToStr;
769
+ ele.current.innerText = (numToStr || String)(show);
770
+ if (num === show) return;
771
+ var div = ele.current;
772
+ var speed = (num - show) / period;
773
+ var cancel = setFrameInterval(function () {
774
+ var _cache$current4 = cache.current,
775
+ num = _cache$current4.num,
776
+ numToStr = _cache$current4.numToStr;
777
+ cache.current.show += speed;
778
+ if (speed > 0 && cache.current.show > num || speed < 0 && cache.current.show < num) {
779
+ cancel();
780
+ cache.current.show = num;
781
+ }
782
+ div.innerText = (numToStr || String)(speed > 0 ? Math.floor(cache.current.show) : Math.ceil(cache.current.show));
783
+ }, 1);
784
+ return cancel;
785
+ }, [num]);
786
+ return /*#__PURE__*/_jsx("div", _objectSpread({
787
+ ref: ele
788
+ }, others));
789
+ });
790
+ /** 环形文字 */
791
+ export var CircleText = function CircleText(props) {
792
+ var width = props.width,
793
+ height = props.height,
794
+ radius = props.radius,
795
+ _props$startAngel = props.startAngel,
796
+ startAngel = _props$startAngel === void 0 ? 0 : _props$startAngel,
797
+ _props$gapAngel = props.gapAngel,
798
+ gapAngel = _props$gapAngel === void 0 ? 0 : _props$gapAngel,
799
+ _props$align = props.align,
800
+ align = _props$align === void 0 ? "center" : _props$align,
801
+ style = props.style,
802
+ _props$direction2 = props.direction,
803
+ direction = _props$direction2 === void 0 ? "outer" : _props$direction2,
804
+ _props$reverse = props.reverse,
805
+ reverse = _props$reverse === void 0 ? false : _props$reverse,
806
+ separator = props.separator,
807
+ children = props.children,
808
+ others = _objectWithoutProperties(props, _excluded10);
809
+ var unitAngle = Math.atan(width / 2 / radius) * 2;
810
+ var totalAngle = (unitAngle + gapAngel) * children.length - gapAngel;
811
+ var offsetAngle = align === "left" ? 0 : align === "right" ? totalAngle : totalAngle / 2;
812
+ function getTransform(idx) {
813
+ var angle = startAngel - idx * (unitAngle + gapAngel) + offsetAngle - unitAngle / 2;
814
+ var x = (radius + height / 2) * Math.cos(angle) - width / 2;
815
+ var y = (radius + height / 2) * Math.sin(angle) * -1 - height / 2;
816
+ var z = Math.PI / 2 - angle + (direction === "inner" ? Math.PI : 0);
817
+ return "translateX(".concat(x, "px) translateY(").concat(y, "px) rotateZ(").concat(z / Math.PI * 180, "deg)");
818
+ }
819
+ var words = typeof separator === "function" ? separator(children) : children.split(separator !== null && separator !== void 0 ? separator : "");
820
+ if (reverse) words.reverse();
821
+ return /*#__PURE__*/_jsx(Fragment, {
822
+ children: words.map(function (w, idx) {
823
+ return /*#__PURE__*/_jsx("span", _objectSpread(_objectSpread({
824
+ style: _objectSpread(_objectSpread({
825
+ position: "absolute"
826
+ }, style), {}, {
827
+ transform: getTransform(idx),
828
+ textAlign: "center",
829
+ width: width,
830
+ lineHeight: "".concat(height, "px"),
831
+ height: height
832
+ })
833
+ }, others), {}, {
834
+ children: w
835
+ }), idx);
836
+ })
837
+ });
838
+ };
839
+ /**
840
+ * 滚动条组件
841
+ * @description 注意 children 不是直接渲染在组件上的,而是渲染在内部的容器上
842
+ */
843
+ export var Scroll = /*#__PURE__*/forwardRef(function (props, ref) {
844
+ var children = props.children,
845
+ containerClassName = props.containerClassName,
846
+ containerStyle = props.containerStyle,
847
+ options = props.options,
848
+ className = props.className,
849
+ others = _objectWithoutProperties(props, _excluded11);
850
+ var _ref2 = options || {},
851
+ thumbWidth = _ref2.thumbWidth,
852
+ scrollbarOptions = _objectWithoutProperties(_ref2, _excluded12);
853
+ var id = useId();
854
+ useEffect(function () {
855
+ SmoothScrollBar.init(document.querySelector("[data-scroll-id=\"".concat(id, "\"]")), scrollbarOptions);
856
+ }, []);
857
+ return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
858
+ ref: ref,
859
+ className: clsx(!!thumbWidth && css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .scrollbar-track.scrollbar-track-x {\n height: ", "px;\n }\n\n .scrollbar-thumb.scrollbar-thumb-x {\n height: ", "px;\n }\n\n .scrollbar-track.scrollbar-track-y {\n width: ", "px;\n }\n\n .scrollbar-thumb.scrollbar-thumb-y {\n width: ", "px;\n }\n "])), thumbWidth, thumbWidth, thumbWidth, thumbWidth), className),
860
+ "data-scroll-id": id
861
+ }, others), {}, {
862
+ children: /*#__PURE__*/_jsx("div", {
863
+ className: containerClassName,
864
+ style: containerStyle,
865
+ children: children
866
+ })
867
+ }));
868
+ });
869
+ //# sourceMappingURL=index.js.map