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.
- package/dist/{index.d.ts → cjs/index.d.ts} +9 -17
- package/dist/cjs/index.js +462 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/esm/index.d.ts +269 -0
- package/dist/esm/index.js +869 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +7 -5
- package/src/index.tsx +4 -149
- package/dist/index.js +0 -816
- package/dist/index.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ButtonHTMLAttributes, CSSProperties, FC, HTMLAttributes, InputHTMLAttributes, ReactNode } from "react";
|
|
2
2
|
import type { ScrollbarOptions } from "smooth-scrollbar/interfaces";
|
|
3
3
|
export type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
|
|
4
4
|
export interface InputFileDataTypes {
|
|
@@ -40,12 +40,12 @@ export type InputFileProps = ({
|
|
|
40
40
|
}) & Omit<InputHTMLAttributes<HTMLInputElement>, "onChange" | "multiple" | "type">;
|
|
41
41
|
export declare function getFileData<T extends InputFileDataType>(file: File, type: T): Promise<InputFileDataTypes[T]>;
|
|
42
42
|
/** 专用与读取文件的组件 */
|
|
43
|
-
export declare const InputFile:
|
|
43
|
+
export declare const InputFile: import("react").ForwardRefExoticComponent<InputFileProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
44
44
|
export interface ImportExcelProps extends Omit<InputFileProps, "multiple" | "onChange" | "accept" | "type"> {
|
|
45
45
|
onChange?: (data: Record<string, string>[]) => void;
|
|
46
46
|
}
|
|
47
47
|
/** 专门用于读取 excel 的组件 */
|
|
48
|
-
export declare const ImportExcel:
|
|
48
|
+
export declare const ImportExcel: import("react").ForwardRefExoticComponent<ImportExcelProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
49
49
|
/** 手动导出 excel */
|
|
50
50
|
export declare function exportExcel(data: Record<string, string>[], name: string): void;
|
|
51
51
|
export interface ExportExcelProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
@@ -53,7 +53,7 @@ export interface ExportExcelProps extends ButtonHTMLAttributes<HTMLButtonElement
|
|
|
53
53
|
fileName: string;
|
|
54
54
|
}
|
|
55
55
|
/** 导出 excel 的 button 组件 */
|
|
56
|
-
export declare const ExportExcel:
|
|
56
|
+
export declare const ExportExcel: import("react").ForwardRefExoticComponent<ExportExcelProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
57
57
|
export interface TransitionBoxProps extends HTMLAttributes<HTMLDivElement> {
|
|
58
58
|
containerClassName?: string;
|
|
59
59
|
containerStyle?: CSSProperties;
|
|
@@ -168,7 +168,7 @@ export interface FlowProps<T> extends Omit<HTMLAttributes<HTMLDivElement>, "chil
|
|
|
168
168
|
export declare function getGapRange(gap?: undefined | number | null | (number | null)[]): [number, number | null];
|
|
169
169
|
export declare function getGapCountAndSize(width: number, itemWidth: number, minGap: number, maxGap: number | null): [number, number];
|
|
170
170
|
/** 自适应浮动组件 */
|
|
171
|
-
export declare function Flow<T>(props: FlowProps<T>):
|
|
171
|
+
export declare function Flow<T>(props: FlowProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
172
172
|
export interface TrapeziumProps extends HTMLAttributes<HTMLDivElement> {
|
|
173
173
|
top: number;
|
|
174
174
|
bottom: number;
|
|
@@ -176,7 +176,7 @@ export interface TrapeziumProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
176
176
|
borderRadius: number;
|
|
177
177
|
}
|
|
178
178
|
/** 梯形组件 */
|
|
179
|
-
export declare const Trapezium:
|
|
179
|
+
export declare const Trapezium: import("react").ForwardRefExoticComponent<TrapeziumProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
180
180
|
export interface LoopSwiperProps<T> {
|
|
181
181
|
/** 源数据 */
|
|
182
182
|
data: T[];
|
|
@@ -205,7 +205,7 @@ export interface LoopSwiperItem {
|
|
|
205
205
|
offset: number;
|
|
206
206
|
}
|
|
207
207
|
/** 循环播放组件 */
|
|
208
|
-
export declare function LoopSwiper<T>(props: LoopSwiperProps<T>):
|
|
208
|
+
export declare function LoopSwiper<T>(props: LoopSwiperProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
209
209
|
export interface SectionRingProps extends HTMLAttributes<HTMLDivElement> {
|
|
210
210
|
outerRadius: number;
|
|
211
211
|
innerRadius: number;
|
|
@@ -225,7 +225,7 @@ export interface TransitionNumIns {
|
|
|
225
225
|
get(): number;
|
|
226
226
|
}
|
|
227
227
|
/** 渐变数字组件 */
|
|
228
|
-
export declare const TransitionNum:
|
|
228
|
+
export declare const TransitionNum: import("react").ForwardRefExoticComponent<TransitionNumProps & import("react").RefAttributes<TransitionNumIns>>;
|
|
229
229
|
export interface CircleTextProps extends Omit<HTMLAttributes<HTMLSpanElement>, "children"> {
|
|
230
230
|
/** 每一个方块的宽度 */
|
|
231
231
|
width: number;
|
|
@@ -266,12 +266,4 @@ export interface ScrollProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
266
266
|
* 滚动条组件
|
|
267
267
|
* @description 注意 children 不是直接渲染在组件上的,而是渲染在内部的容器上
|
|
268
268
|
*/
|
|
269
|
-
export declare const Scroll:
|
|
270
|
-
export declare const X: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
271
|
-
export declare const Y: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
272
|
-
export declare const Auto: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
273
|
-
export declare const None: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
274
|
-
export declare const XAuto: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
275
|
-
export declare const YAuto: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
276
|
-
export declare const XNone: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
277
|
-
export declare const YNone: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
269
|
+
export declare const Scroll: import("react").ForwardRefExoticComponent<ScrollProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/index.tsx
|
|
30
|
+
var src_exports = {};
|
|
31
|
+
__export(src_exports, {
|
|
32
|
+
CircleText: () => CircleText,
|
|
33
|
+
ExportExcel: () => ExportExcel,
|
|
34
|
+
Flow: () => Flow,
|
|
35
|
+
ImportExcel: () => ImportExcel,
|
|
36
|
+
InputFile: () => InputFile,
|
|
37
|
+
LoopSwiper: () => LoopSwiper,
|
|
38
|
+
Ring: () => Ring,
|
|
39
|
+
Scroll: () => Scroll,
|
|
40
|
+
SeaRadar: () => SeaRadar,
|
|
41
|
+
SectionRing: () => SectionRing,
|
|
42
|
+
TransitionBox: () => TransitionBox,
|
|
43
|
+
TransitionNum: () => TransitionNum,
|
|
44
|
+
Trapezium: () => Trapezium,
|
|
45
|
+
exportExcel: () => exportExcel,
|
|
46
|
+
getFileData: () => getFileData,
|
|
47
|
+
getGapCountAndSize: () => getGapCountAndSize,
|
|
48
|
+
getGapRange: () => getGapRange
|
|
49
|
+
});
|
|
50
|
+
module.exports = __toCommonJS(src_exports);
|
|
51
|
+
var import_css = require("@emotion/css");
|
|
52
|
+
var import_clsx = __toESM(require("clsx"));
|
|
53
|
+
var import_deepsea_tools = require("deepsea-tools");
|
|
54
|
+
var import_react = require("react");
|
|
55
|
+
var import_smooth_scrollbar = __toESM(require("smooth-scrollbar"));
|
|
56
|
+
var import_xlsx = require("xlsx");
|
|
57
|
+
async function getFileData(file, type) {
|
|
58
|
+
const fileReader = new FileReader();
|
|
59
|
+
switch (type) {
|
|
60
|
+
case "arrayBuffer":
|
|
61
|
+
fileReader.readAsArrayBuffer(file);
|
|
62
|
+
break;
|
|
63
|
+
case "binary":
|
|
64
|
+
fileReader.readAsBinaryString(file);
|
|
65
|
+
break;
|
|
66
|
+
case "base64":
|
|
67
|
+
fileReader.readAsDataURL(file);
|
|
68
|
+
break;
|
|
69
|
+
case "text":
|
|
70
|
+
fileReader.readAsText(file);
|
|
71
|
+
break;
|
|
72
|
+
default:
|
|
73
|
+
return file;
|
|
74
|
+
}
|
|
75
|
+
return new Promise((resolve) => {
|
|
76
|
+
fileReader.addEventListener("load", () => {
|
|
77
|
+
resolve(fileReader.result);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
var InputFile = (0, import_react.forwardRef)((props, ref) => {
|
|
82
|
+
const { multiple = false, type = "file", onChange, disabled: inputDisabled, ...others } = props;
|
|
83
|
+
const [disabled, setDisabled] = (0, import_react.useState)(false);
|
|
84
|
+
async function onInputChange(e) {
|
|
85
|
+
const input = e.target;
|
|
86
|
+
const { files } = input;
|
|
87
|
+
if (!files || files.length === 0)
|
|
88
|
+
return;
|
|
89
|
+
setDisabled(true);
|
|
90
|
+
try {
|
|
91
|
+
if (multiple) {
|
|
92
|
+
const result = [];
|
|
93
|
+
for (const file of Array.from(files)) {
|
|
94
|
+
result.push({
|
|
95
|
+
result: await getFileData(file, type),
|
|
96
|
+
file
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
onChange == null ? void 0 : onChange(result);
|
|
100
|
+
} else {
|
|
101
|
+
onChange == null ? void 0 : onChange({
|
|
102
|
+
result: await getFileData(files[0], type),
|
|
103
|
+
file: files[0]
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
setDisabled(false);
|
|
107
|
+
input.value = "";
|
|
108
|
+
} catch (error) {
|
|
109
|
+
setDisabled(false);
|
|
110
|
+
input.value = "";
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return /* @__PURE__ */ React.createElement("input", { disabled: disabled && inputDisabled, ref, type: "file", multiple, onChange: onInputChange, ...others });
|
|
115
|
+
});
|
|
116
|
+
var ImportExcel = (0, import_react.forwardRef)((props, ref) => {
|
|
117
|
+
const { onChange, ...others } = props;
|
|
118
|
+
function onInputChange(data) {
|
|
119
|
+
const wb = (0, import_xlsx.read)(data.result);
|
|
120
|
+
const result = import_xlsx.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
|
|
121
|
+
if (typeof result === "object") {
|
|
122
|
+
const $ = result.map((it) => {
|
|
123
|
+
const _ = {};
|
|
124
|
+
Object.keys(it).filter((key) => key !== "__rowNum__").forEach((key) => _[key] = String(it[key]));
|
|
125
|
+
return _;
|
|
126
|
+
});
|
|
127
|
+
onChange == null ? void 0 : onChange($);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return /* @__PURE__ */ React.createElement(InputFile, { ref, accept: ".xlsx", type: "arrayBuffer", onChange: onInputChange, ...others });
|
|
131
|
+
});
|
|
132
|
+
function exportExcel(data, name) {
|
|
133
|
+
const workSheet = import_xlsx.utils.json_to_sheet(data);
|
|
134
|
+
const workBook = import_xlsx.utils.book_new();
|
|
135
|
+
import_xlsx.utils.book_append_sheet(workBook, workSheet);
|
|
136
|
+
(0, import_xlsx.writeFile)(workBook, `${name}${name.endsWith(".xlsx") ? "" : ".xlsx"}`);
|
|
137
|
+
}
|
|
138
|
+
var ExportExcel = (0, import_react.forwardRef)((props, ref) => {
|
|
139
|
+
const { data, fileName, onClick, ...others } = props;
|
|
140
|
+
function onButtonClick(e) {
|
|
141
|
+
exportExcel(data, fileName);
|
|
142
|
+
onClick == null ? void 0 : onClick(e);
|
|
143
|
+
}
|
|
144
|
+
return /* @__PURE__ */ React.createElement("button", { ref, onClick: onButtonClick, ...others });
|
|
145
|
+
});
|
|
146
|
+
var TransitionBox = (props) => {
|
|
147
|
+
const { style, containerClassName, containerStyle, children, vertical = true, horizontal = true, time = 3e3, ...others } = props;
|
|
148
|
+
const box = (0, import_react.useRef)(null);
|
|
149
|
+
const [width, setWidth] = (0, import_react.useState)(0);
|
|
150
|
+
const [height, setHeight] = (0, import_react.useState)(0);
|
|
151
|
+
const [count, setCount] = (0, import_react.useState)(0);
|
|
152
|
+
(0, import_react.useEffect)(() => {
|
|
153
|
+
const observer = new ResizeObserver((entries) => {
|
|
154
|
+
const { width: currentWidth, height: currentHeight } = entries[0].contentRect;
|
|
155
|
+
setWidth(currentWidth);
|
|
156
|
+
setHeight(currentHeight);
|
|
157
|
+
});
|
|
158
|
+
observer.observe(box.current);
|
|
159
|
+
return () => {
|
|
160
|
+
observer.disconnect();
|
|
161
|
+
};
|
|
162
|
+
}, []);
|
|
163
|
+
(0, import_react.useEffect)(() => {
|
|
164
|
+
setCount((count2) => Math.min(count2 + 1, 3));
|
|
165
|
+
}, [width, height]);
|
|
166
|
+
const outerStyle = { transitionProperty: count === 3 ? [horizontal && "width", vertical && "height"].filter(Boolean).join(", ") : void 0, transitionDuration: count === 3 ? `${time}ms` : void 0, width, height, overflow: "hidden", position: "relative", ...style };
|
|
167
|
+
return /* @__PURE__ */ React.createElement("div", { style: outerStyle, ...others }, /* @__PURE__ */ React.createElement("div", { className: containerClassName, style: { position: "absolute", ...containerStyle }, ref: box }, children));
|
|
168
|
+
};
|
|
169
|
+
var SeaRadar = (props) => {
|
|
170
|
+
const { unitRadius = 50, circleCount = 4, circleWidth = 1, circleColor, directionCount = 36, directionWidth = 1, directionColor, backgroundColor, scanColor, scanAngle = Math.PI / 6, period = 8, targets, showGraduationLine, showGraduationText, showCircle, showDirection } = props;
|
|
171
|
+
const style = { "--unit-radius": `${unitRadius}px`, "--circle-count": circleCount, "--circle-width": `${circleWidth}px`, "--circle-color": circleColor, "--direction-count": directionCount, "--direction-width": `${directionWidth}px`, "--direction-color": directionColor, "--background-color": backgroundColor, "--scan-color": scanColor, "--period": `${period}s` };
|
|
172
|
+
return /* @__PURE__ */ React.createElement("div", { className: "sea-radar-wrapper", style }, Array(180).fill(0).map((_, index) => /* @__PURE__ */ React.createElement("div", { className: "sea-radar-little-graduation", style: { transform: `rotateZ(${2 * index}deg)`, display: showGraduationLine ? "block" : "none" } })), Array(36).fill(0).map((_, index) => /* @__PURE__ */ React.createElement("div", { className: "sea-radar-graduation", style: { transform: `rotateZ(${10 * index}deg)`, display: showGraduationLine ? "block" : "none" } }, /* @__PURE__ */ React.createElement("span", { className: "sea-radar-graduation-text", style: { display: showGraduationText ? "block" : "none" } }, String(index * 10).padStart(3, "0")))), /* @__PURE__ */ React.createElement("div", { className: "sea-radar" }, /* @__PURE__ */ React.createElement("div", { className: "sea-radar-scan", style: { height: `${unitRadius * circleCount * Math.tan(scanAngle)}px`, clipPath: `polygon(0 0, 0 100%, 100% 100%)` } }), showCircle && Array(circleCount).fill(0).map((_, index) => /* @__PURE__ */ React.createElement("div", { className: "sea-radar-circle", style: { width: `${unitRadius * 2 * (index + 1)}px`, height: `${unitRadius * 2 * (index + 1)}px` } })), showDirection && Array(directionCount).fill(0).map((_, index) => /* @__PURE__ */ React.createElement("div", { className: "sea-radar-direction", style: { transform: `rotateZ(${360 / directionCount * index}deg)` } })), targets == null ? void 0 : targets.map((it) => /* @__PURE__ */ React.createElement("div", { className: "sea-radar-target", style: { left: `${unitRadius * circleCount + it.radius * Math.cos(it.angle)}px`, bottom: `${unitRadius * circleCount + it.radius * Math.sin(it.angle)}px` } }, it.element))));
|
|
173
|
+
};
|
|
174
|
+
var Ring = (props) => {
|
|
175
|
+
const { outerWidth, innerWidth, style, ...leftProps } = props;
|
|
176
|
+
const outerRadius = outerWidth / 2;
|
|
177
|
+
const innerRadius = innerWidth / 2;
|
|
178
|
+
return /* @__PURE__ */ React.createElement("div", { style: { ...style, width: `${outerWidth}px`, height: `${outerWidth}px`, clipPath: `path("M0,${outerRadius} a${outerRadius},${outerRadius},0,1,0,${outerWidth},0 a${outerRadius},${outerRadius},0,1,0,-${outerWidth},0 l${outerRadius - innerRadius},0 a${innerRadius},${innerRadius},0,0,1,${innerRadius * 2},0 a${innerRadius},${innerRadius},0,0,1,-${innerRadius * 2},0 Z")` }, ...leftProps });
|
|
179
|
+
};
|
|
180
|
+
function getGapRange(gap) {
|
|
181
|
+
if (typeof gap === "number")
|
|
182
|
+
return [gap, gap];
|
|
183
|
+
if (Array.isArray(gap))
|
|
184
|
+
return [gap[0] || 0, gap[1]];
|
|
185
|
+
return [0, null];
|
|
186
|
+
}
|
|
187
|
+
function getGapCountAndSize(width, itemWidth, minGap, maxGap) {
|
|
188
|
+
const count = Math.floor((width + minGap) / (itemWidth + minGap)) || 1;
|
|
189
|
+
if (count === 1)
|
|
190
|
+
return [count, 0];
|
|
191
|
+
const averageGap = (width - itemWidth * count) / (count - 1);
|
|
192
|
+
if (averageGap < minGap)
|
|
193
|
+
return [count, minGap];
|
|
194
|
+
if (maxGap !== null && averageGap > maxGap)
|
|
195
|
+
return [count, maxGap];
|
|
196
|
+
return [count, averageGap];
|
|
197
|
+
}
|
|
198
|
+
function Flow(props) {
|
|
199
|
+
const { itemWidth, itemHeight, columnGap, rowGap = 0, maxRows, data, render, keyExactor, className, style, containerClassName, containerStyle, throttle, transitionDuration, onSizeChange, ...others } = props;
|
|
200
|
+
const [minColumnGap, maxColumnGap] = getGapRange(columnGap);
|
|
201
|
+
const [width, setWidth] = (0, import_react.useState)(0);
|
|
202
|
+
const [columnCount, setColumnCount] = (0, import_react.useState)(1);
|
|
203
|
+
const [columnGapSize, setColumnGapSize] = (0, import_react.useState)(minColumnGap);
|
|
204
|
+
const [showItems, setShowItems] = (0, import_react.useState)(false);
|
|
205
|
+
const ele = (0, import_react.useRef)(null);
|
|
206
|
+
const contentRows = Math.ceil(data.length / columnCount);
|
|
207
|
+
const contentShownRows = typeof maxRows === "number" ? Math.min(contentRows, maxRows) : contentRows;
|
|
208
|
+
const height = contentShownRows > 0 ? contentShownRows * (itemHeight + rowGap) - rowGap : 0;
|
|
209
|
+
function getPosition(index) {
|
|
210
|
+
const y = Math.floor(index / columnCount);
|
|
211
|
+
const x = index - y * columnCount;
|
|
212
|
+
return {
|
|
213
|
+
left: x * (itemWidth + columnGapSize),
|
|
214
|
+
top: y * (itemHeight + rowGap)
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function getHidden(index) {
|
|
218
|
+
if (typeof maxRows !== "number")
|
|
219
|
+
return false;
|
|
220
|
+
return index >= maxRows * columnCount;
|
|
221
|
+
}
|
|
222
|
+
(0, import_react.useEffect)(() => {
|
|
223
|
+
let timeout;
|
|
224
|
+
const observer = new ResizeObserver((entries) => {
|
|
225
|
+
clearTimeout(timeout);
|
|
226
|
+
function task() {
|
|
227
|
+
const { inlineSize: width2 } = entries[0].borderBoxSize[0];
|
|
228
|
+
const [newColumnCount, newColumnGapSize] = getGapCountAndSize(width2, itemWidth, minColumnGap, maxColumnGap);
|
|
229
|
+
setShowItems(true);
|
|
230
|
+
setWidth(width2);
|
|
231
|
+
setColumnCount(newColumnCount);
|
|
232
|
+
setColumnGapSize(newColumnGapSize);
|
|
233
|
+
}
|
|
234
|
+
if (throttle === null) {
|
|
235
|
+
task();
|
|
236
|
+
} else {
|
|
237
|
+
timeout = window.setTimeout(task, throttle || 200);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
observer.observe(ele.current);
|
|
241
|
+
return () => {
|
|
242
|
+
observer.disconnect();
|
|
243
|
+
};
|
|
244
|
+
}, [itemWidth, throttle, columnGap]);
|
|
245
|
+
(0, import_react.useEffect)(() => {
|
|
246
|
+
onSizeChange == null ? void 0 : onSizeChange({ width, height, itemWidth, itemHeight, columnGap: columnGapSize, columnCount, rowGap, rowCount: contentShownRows, overflow: data.length > contentShownRows * columnCount, itemCount: data.length, maxRows: maxRows ?? null });
|
|
247
|
+
}, [width, height, columnGapSize, columnCount, rowGap, contentShownRows, data.length, itemWidth, itemHeight, maxRows]);
|
|
248
|
+
return /* @__PURE__ */ React.createElement("div", { ref: ele, className, style: { position: "relative", boxSizing: "border-box", height, ...style }, ...others }, showItems && data.map((it, idx) => /* @__PURE__ */ React.createElement(
|
|
249
|
+
"div",
|
|
250
|
+
{
|
|
251
|
+
key: (keyExactor == null ? void 0 : keyExactor(it, idx)) || idx,
|
|
252
|
+
className: containerClassName,
|
|
253
|
+
style: {
|
|
254
|
+
position: "absolute",
|
|
255
|
+
width: itemWidth,
|
|
256
|
+
height: itemHeight,
|
|
257
|
+
transition: transitionDuration !== null ? `all ${transitionDuration ?? 400}ms` : void 0,
|
|
258
|
+
...getPosition(idx)
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
/* @__PURE__ */ React.createElement("div", { style: { width: itemWidth, height: itemHeight, display: maxRows && idx >= maxRows * columnCount ? "none" : "block", ...containerStyle } }, render(it, idx, getHidden(idx)))
|
|
262
|
+
)));
|
|
263
|
+
}
|
|
264
|
+
var Trapezium = (0, import_react.forwardRef)((props, ref) => {
|
|
265
|
+
const { top, bottom, height, borderRadius, style, ...other } = props;
|
|
266
|
+
const diff = (bottom - top) / 2;
|
|
267
|
+
const a = Math.atan(height / diff) / 2;
|
|
268
|
+
const b = borderRadius / Math.tan(a);
|
|
269
|
+
const c = b * Math.cos(a * 2);
|
|
270
|
+
const d = b * Math.sin(a * 2);
|
|
271
|
+
const e = Math.PI / 2 - a;
|
|
272
|
+
const f = borderRadius / Math.tan(e);
|
|
273
|
+
const g = f * Math.cos(a * 2);
|
|
274
|
+
const h = f * Math.sin(a * 2);
|
|
275
|
+
return /* @__PURE__ */ React.createElement("div", { ref, style: { width: bottom, height, clipPath: `path("M ${diff + f} ${0} A ${borderRadius} ${borderRadius} 0 0 0 ${diff - g} ${h} L ${c} ${height - d} A ${borderRadius} ${borderRadius} 0 0 0 ${b} ${height} L ${bottom - b} ${height} A ${borderRadius} ${borderRadius} 0 0 0 ${bottom - c} ${height - d} L ${top + diff + g} ${h} A ${borderRadius} ${borderRadius} 0 0 0 ${top + diff - f} ${0} Z")`, ...style }, ...other });
|
|
276
|
+
});
|
|
277
|
+
function LoopSwiper(props) {
|
|
278
|
+
const { data, render, keyExactor, size, gap = 0, start = 0, speed, paused = false, className = "", direction = "x" } = props;
|
|
279
|
+
if (!(size > 0 && (speed > 0 || speed < 0))) {
|
|
280
|
+
throw new RangeError("size 必须是正数,speed 必须非0");
|
|
281
|
+
}
|
|
282
|
+
const keys = data.map((it, idx, arr) => keyExactor ? keyExactor(it, idx, arr) : String(idx));
|
|
283
|
+
const keysRef = (0, import_react.useRef)(keys);
|
|
284
|
+
const cache = (0, import_react.useRef)({ size, gap, speed, keys, paused, className, direction });
|
|
285
|
+
cache.current = { size, gap, speed, keys, paused, className, direction };
|
|
286
|
+
const eles = (0, import_react.useRef)(keys.map((key, idx) => ({ key, dom: null, offset: idx * (size + gap) + start })));
|
|
287
|
+
if (keysRef.current.length !== keys.length || keysRef.current.some((it, idx) => it !== keys[idx])) {
|
|
288
|
+
keysRef.current = keys;
|
|
289
|
+
eles.current = keys.map((key, idx) => ({ key, dom: null, offset: idx * (size + gap) + start }));
|
|
290
|
+
}
|
|
291
|
+
function setStyles() {
|
|
292
|
+
const { size: size2, speed: speed2, className: className2, direction: direction2 } = cache.current;
|
|
293
|
+
eles.current.forEach((it) => {
|
|
294
|
+
it.dom.className = className2;
|
|
295
|
+
it.dom.style.setProperty("position", `absolute`);
|
|
296
|
+
it.dom.style.setProperty("width", `${size2}px`);
|
|
297
|
+
direction2 === "x" && speed2 < 0 ? it.dom.style.setProperty("right", `0`) : it.dom.style.setProperty("left", `0`);
|
|
298
|
+
direction2 === "y" && speed2 < 0 ? it.dom.style.setProperty("bottom", `0`) : it.dom.style.setProperty("top", `0`);
|
|
299
|
+
it.dom.style.setProperty("transform", `translate${direction2.toUpperCase()}(${it.offset * (speed2 > 0 ? 1 : -1)}px)`);
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
(0, import_react.useEffect)(() => {
|
|
303
|
+
setStyles();
|
|
304
|
+
}, []);
|
|
305
|
+
(0, import_react.useEffect)(() => {
|
|
306
|
+
const stop = (0, import_deepsea_tools.setFrameInterval)(() => {
|
|
307
|
+
const { size: size2, gap: gap2, speed: speed2, keys: keys2, paused: paused2 } = cache.current;
|
|
308
|
+
if (paused2)
|
|
309
|
+
return;
|
|
310
|
+
eles.current.length = keys2.length;
|
|
311
|
+
let minIndex = 0;
|
|
312
|
+
eles.current.forEach((it, idx) => {
|
|
313
|
+
if (it.offset < eles.current[minIndex].offset) {
|
|
314
|
+
minIndex = idx;
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
const minOffset = eles.current[minIndex].offset;
|
|
318
|
+
eles.current.forEach((it, idx) => {
|
|
319
|
+
let index = idx;
|
|
320
|
+
if (idx < minIndex)
|
|
321
|
+
index = eles.current.length + idx;
|
|
322
|
+
it.offset = minOffset + (index - minIndex) * (size2 + gap2);
|
|
323
|
+
let newOffset = it.offset - Math.abs(speed2);
|
|
324
|
+
if (newOffset + size2 + gap2 <= 0) {
|
|
325
|
+
newOffset += eles.current.length * (size2 + gap2);
|
|
326
|
+
}
|
|
327
|
+
it.offset = newOffset;
|
|
328
|
+
});
|
|
329
|
+
setStyles();
|
|
330
|
+
}, 1);
|
|
331
|
+
return stop;
|
|
332
|
+
}, []);
|
|
333
|
+
function ref(dom, index) {
|
|
334
|
+
if (!eles.current[index])
|
|
335
|
+
return;
|
|
336
|
+
eles.current[index].dom = dom;
|
|
337
|
+
}
|
|
338
|
+
return /* @__PURE__ */ React.createElement(import_react.Fragment, null, data.map((it, idx, arr) => /* @__PURE__ */ React.createElement("div", { key: keys[idx], ref: (dom) => ref(dom, idx) }, render(it, idx, arr))));
|
|
339
|
+
}
|
|
340
|
+
var SectionRing = (props) => {
|
|
341
|
+
const { outerRadius: o, innerRadius: i, count: c, angel: a, style, ...others } = props;
|
|
342
|
+
const s = Math.PI * 2 / c - a;
|
|
343
|
+
function arc(radius, startAngle, endAngle, options = {}) {
|
|
344
|
+
return (0, import_deepsea_tools.drawArc)(o, o, radius, startAngle, endAngle, options);
|
|
345
|
+
}
|
|
346
|
+
return /* @__PURE__ */ React.createElement(
|
|
347
|
+
"div",
|
|
348
|
+
{
|
|
349
|
+
style: {
|
|
350
|
+
...style,
|
|
351
|
+
width: o * 2,
|
|
352
|
+
height: o * 2,
|
|
353
|
+
clipPath: `path("${Array(c).fill(0).map((it, idx) => `${arc(o, idx * (a + s), idx * (a + s) + a)} ${arc(i, idx * (a + s) + a, idx * (a + s), { line: true, anticlockwise: true })}`).join(" ")} Z")`
|
|
354
|
+
},
|
|
355
|
+
...others
|
|
356
|
+
}
|
|
357
|
+
);
|
|
358
|
+
};
|
|
359
|
+
var TransitionNum = (0, import_react.forwardRef)((props, ref) => {
|
|
360
|
+
const { children: num, period, numToStr, ...others } = props;
|
|
361
|
+
if (!Number.isInteger(num) || !Number.isInteger(period) || period <= 0) {
|
|
362
|
+
throw new RangeError("目标数字必须是整数,周期必须是正整数");
|
|
363
|
+
}
|
|
364
|
+
const ele = (0, import_react.useRef)(null);
|
|
365
|
+
const cache = (0, import_react.useRef)({ num, period, numToStr, show: num });
|
|
366
|
+
cache.current = { ...cache.current, num, period, numToStr };
|
|
367
|
+
(0, import_react.useImperativeHandle)(ref, () => ({ get: () => cache.current.show }), []);
|
|
368
|
+
(0, import_react.useEffect)(() => {
|
|
369
|
+
const { num: num2, period: period2, show, numToStr: numToStr2 } = cache.current;
|
|
370
|
+
ele.current.innerText = (numToStr2 || String)(show);
|
|
371
|
+
if (num2 === show)
|
|
372
|
+
return;
|
|
373
|
+
const div = ele.current;
|
|
374
|
+
const speed = (num2 - show) / period2;
|
|
375
|
+
const cancel = (0, import_deepsea_tools.setFrameInterval)(() => {
|
|
376
|
+
const { num: num3, numToStr: numToStr3 } = cache.current;
|
|
377
|
+
cache.current.show += speed;
|
|
378
|
+
if (speed > 0 && cache.current.show > num3 || speed < 0 && cache.current.show < num3) {
|
|
379
|
+
cancel();
|
|
380
|
+
cache.current.show = num3;
|
|
381
|
+
}
|
|
382
|
+
div.innerText = (numToStr3 || String)(speed > 0 ? Math.floor(cache.current.show) : Math.ceil(cache.current.show));
|
|
383
|
+
}, 1);
|
|
384
|
+
return cancel;
|
|
385
|
+
}, [num]);
|
|
386
|
+
return /* @__PURE__ */ React.createElement("div", { ref: ele, ...others });
|
|
387
|
+
});
|
|
388
|
+
var CircleText = (props) => {
|
|
389
|
+
const { width, height, radius, startAngel = 0, gapAngel = 0, align = "center", style, direction = "outer", reverse = false, separator, children, ...others } = props;
|
|
390
|
+
const unitAngle = Math.atan(width / 2 / radius) * 2;
|
|
391
|
+
const totalAngle = (unitAngle + gapAngel) * children.length - gapAngel;
|
|
392
|
+
const offsetAngle = align === "left" ? 0 : align === "right" ? totalAngle : totalAngle / 2;
|
|
393
|
+
function getTransform(idx) {
|
|
394
|
+
const angle = startAngel - idx * (unitAngle + gapAngel) + offsetAngle - unitAngle / 2;
|
|
395
|
+
const x = (radius + height / 2) * Math.cos(angle) - width / 2;
|
|
396
|
+
const y = (radius + height / 2) * Math.sin(angle) * -1 - height / 2;
|
|
397
|
+
const z = Math.PI / 2 - angle + (direction === "inner" ? Math.PI : 0);
|
|
398
|
+
return `translateX(${x}px) translateY(${y}px) rotateZ(${z / Math.PI * 180}deg)`;
|
|
399
|
+
}
|
|
400
|
+
const words = typeof separator === "function" ? separator(children) : children.split(separator ?? "");
|
|
401
|
+
if (reverse)
|
|
402
|
+
words.reverse();
|
|
403
|
+
return /* @__PURE__ */ React.createElement(import_react.Fragment, null, words.map((w, idx) => /* @__PURE__ */ React.createElement("span", { key: idx, style: { position: "absolute", ...style, transform: getTransform(idx), textAlign: "center", width, lineHeight: `${height}px`, height }, ...others }, w)));
|
|
404
|
+
};
|
|
405
|
+
var Scroll = (0, import_react.forwardRef)((props, ref) => {
|
|
406
|
+
const { children, containerClassName, containerStyle, options, className, ...others } = props;
|
|
407
|
+
const { thumbWidth, ...scrollbarOptions } = options || {};
|
|
408
|
+
const id = (0, import_react.useId)();
|
|
409
|
+
(0, import_react.useEffect)(() => {
|
|
410
|
+
import_smooth_scrollbar.default.init(document.querySelector(`[data-scroll-id="${id}"]`), scrollbarOptions);
|
|
411
|
+
}, []);
|
|
412
|
+
return /* @__PURE__ */ React.createElement(
|
|
413
|
+
"div",
|
|
414
|
+
{
|
|
415
|
+
ref,
|
|
416
|
+
className: (0, import_clsx.default)(
|
|
417
|
+
!!thumbWidth && import_css.css`
|
|
418
|
+
.scrollbar-track.scrollbar-track-x {
|
|
419
|
+
height: ${thumbWidth}px;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
.scrollbar-thumb.scrollbar-thumb-x {
|
|
423
|
+
height: ${thumbWidth}px;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
.scrollbar-track.scrollbar-track-y {
|
|
427
|
+
width: ${thumbWidth}px;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
.scrollbar-thumb.scrollbar-thumb-y {
|
|
431
|
+
width: ${thumbWidth}px;
|
|
432
|
+
}
|
|
433
|
+
`,
|
|
434
|
+
className
|
|
435
|
+
),
|
|
436
|
+
"data-scroll-id": id,
|
|
437
|
+
...others
|
|
438
|
+
},
|
|
439
|
+
/* @__PURE__ */ React.createElement("div", { className: containerClassName, style: containerStyle }, children)
|
|
440
|
+
);
|
|
441
|
+
});
|
|
442
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
443
|
+
0 && (module.exports = {
|
|
444
|
+
CircleText,
|
|
445
|
+
ExportExcel,
|
|
446
|
+
Flow,
|
|
447
|
+
ImportExcel,
|
|
448
|
+
InputFile,
|
|
449
|
+
LoopSwiper,
|
|
450
|
+
Ring,
|
|
451
|
+
Scroll,
|
|
452
|
+
SeaRadar,
|
|
453
|
+
SectionRing,
|
|
454
|
+
TransitionBox,
|
|
455
|
+
TransitionNum,
|
|
456
|
+
Trapezium,
|
|
457
|
+
exportExcel,
|
|
458
|
+
getFileData,
|
|
459
|
+
getGapCountAndSize,
|
|
460
|
+
getGapRange
|
|
461
|
+
});
|
|
462
|
+
//# sourceMappingURL=index.js.map
|