deepsea-components 1.3.0 → 1.3.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/package.json +3 -2
- package/src/index.tsx +943 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deepsea-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "格数科技自用组件库",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"files": [
|
|
23
23
|
"dist",
|
|
24
|
-
"compiled"
|
|
24
|
+
"compiled",
|
|
25
|
+
"src"
|
|
25
26
|
],
|
|
26
27
|
"publishConfig": {
|
|
27
28
|
"access": "public"
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,943 @@
|
|
|
1
|
+
import { css } from "@emotion/css"
|
|
2
|
+
import clsx from "clsx"
|
|
3
|
+
import { DrawArcOptions, drawArc, setFrameInterval } from "deepsea-tools"
|
|
4
|
+
import React, { ButtonHTMLAttributes, CSSProperties, ChangeEvent, FC, Fragment, HTMLAttributes, InputHTMLAttributes, MouseEvent as ReactMouseEvent, ReactNode, forwardRef, useEffect, useId, useImperativeHandle, useRef, useState } from "react"
|
|
5
|
+
import SmoothScrollBar from "smooth-scrollbar"
|
|
6
|
+
import type { ScrollbarOptions } from "smooth-scrollbar/interfaces"
|
|
7
|
+
import { read, utils, writeFile } from "xlsx"
|
|
8
|
+
|
|
9
|
+
export type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false
|
|
10
|
+
|
|
11
|
+
export interface InputFileDataTypes {
|
|
12
|
+
base64: string
|
|
13
|
+
text: string
|
|
14
|
+
arrayBuffer: ArrayBuffer
|
|
15
|
+
binary: string
|
|
16
|
+
file: File
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type InputFileDataType = keyof InputFileDataTypes
|
|
20
|
+
|
|
21
|
+
export interface InputFileData<T> {
|
|
22
|
+
result: T
|
|
23
|
+
file: File
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type InputFileProps = (
|
|
27
|
+
| {
|
|
28
|
+
multiple?: false
|
|
29
|
+
type: "base64" | "text" | "binary"
|
|
30
|
+
onChange?: (data: InputFileData<string>) => void
|
|
31
|
+
}
|
|
32
|
+
| {
|
|
33
|
+
multiple?: false
|
|
34
|
+
type: "arrayBuffer"
|
|
35
|
+
onChange?: (data: InputFileData<ArrayBuffer>) => void
|
|
36
|
+
}
|
|
37
|
+
| {
|
|
38
|
+
multiple?: false
|
|
39
|
+
type?: "file"
|
|
40
|
+
onChange?: (data: InputFileData<File>) => void
|
|
41
|
+
}
|
|
42
|
+
| {
|
|
43
|
+
multiple: true
|
|
44
|
+
type: "base64" | "text" | "binary"
|
|
45
|
+
onChange?: (data: InputFileData<string>[]) => void
|
|
46
|
+
}
|
|
47
|
+
| {
|
|
48
|
+
multiple: true
|
|
49
|
+
type: "arrayBuffer"
|
|
50
|
+
onChange?: (data: InputFileData<ArrayBuffer>[]) => void
|
|
51
|
+
}
|
|
52
|
+
| {
|
|
53
|
+
multiple: true
|
|
54
|
+
type?: "file"
|
|
55
|
+
onChange?: (data: InputFileData<File>[]) => void
|
|
56
|
+
}
|
|
57
|
+
) &
|
|
58
|
+
Omit<InputHTMLAttributes<HTMLInputElement>, "onChange" | "multiple" | "type">
|
|
59
|
+
|
|
60
|
+
export async function getFileData<T extends InputFileDataType>(file: File, type: T): Promise<InputFileDataTypes[T]> {
|
|
61
|
+
const fileReader = new FileReader()
|
|
62
|
+
switch (type) {
|
|
63
|
+
case "arrayBuffer":
|
|
64
|
+
fileReader.readAsArrayBuffer(file)
|
|
65
|
+
break
|
|
66
|
+
case "binary":
|
|
67
|
+
fileReader.readAsBinaryString(file)
|
|
68
|
+
break
|
|
69
|
+
case "base64":
|
|
70
|
+
fileReader.readAsDataURL(file)
|
|
71
|
+
break
|
|
72
|
+
case "text":
|
|
73
|
+
fileReader.readAsText(file)
|
|
74
|
+
break
|
|
75
|
+
default:
|
|
76
|
+
return file as any
|
|
77
|
+
}
|
|
78
|
+
return new Promise(resolve => {
|
|
79
|
+
fileReader.addEventListener("load", () => {
|
|
80
|
+
resolve(fileReader.result as any)
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** 专用与读取文件的组件 */
|
|
86
|
+
export const InputFile = forwardRef<HTMLInputElement, InputFileProps>((props, ref) => {
|
|
87
|
+
const { multiple = false, type = "file", onChange, disabled: inputDisabled, ...others } = props
|
|
88
|
+
const [disabled, setDisabled] = useState(false)
|
|
89
|
+
|
|
90
|
+
async function onInputChange(e: ChangeEvent<HTMLInputElement>) {
|
|
91
|
+
const input = e.target
|
|
92
|
+
const { files } = input
|
|
93
|
+
if (!files || files.length === 0) return
|
|
94
|
+
setDisabled(true)
|
|
95
|
+
try {
|
|
96
|
+
if (multiple) {
|
|
97
|
+
const result: any[] = []
|
|
98
|
+
for (const file of files) {
|
|
99
|
+
result.push({
|
|
100
|
+
result: await getFileData(file, type),
|
|
101
|
+
file
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
onChange?.(result as any)
|
|
105
|
+
} else {
|
|
106
|
+
onChange?.({
|
|
107
|
+
result: await getFileData(files[0], type),
|
|
108
|
+
file: files[0]
|
|
109
|
+
} as any)
|
|
110
|
+
}
|
|
111
|
+
setDisabled(false)
|
|
112
|
+
input.value = ""
|
|
113
|
+
} catch (error) {
|
|
114
|
+
setDisabled(false)
|
|
115
|
+
input.value = ""
|
|
116
|
+
throw error
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return <input disabled={disabled && inputDisabled} ref={ref} type="file" multiple={multiple} onChange={onInputChange} {...others} />
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
export interface ImportExcelProps extends Omit<InputFileProps, "multiple" | "onChange" | "accept" | "type"> {
|
|
124
|
+
onChange?: (data: Record<string, string>[]) => void
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** 专门用于读取 excel 的组件 */
|
|
128
|
+
export const ImportExcel = forwardRef<HTMLInputElement, ImportExcelProps>((props, ref) => {
|
|
129
|
+
const { onChange, ...others } = props
|
|
130
|
+
|
|
131
|
+
function onInputChange(data: InputFileData<ArrayBuffer>) {
|
|
132
|
+
const wb = read(data.result)
|
|
133
|
+
const result = utils.sheet_to_json<any>(wb.Sheets[wb.SheetNames[0]])
|
|
134
|
+
if (typeof result === "object") {
|
|
135
|
+
const $ = result.map(it => {
|
|
136
|
+
const _: Record<string, string> = {}
|
|
137
|
+
Object.keys(it)
|
|
138
|
+
.filter(key => key !== "__rowNum__")
|
|
139
|
+
.forEach(key => (_[key] = String(it[key])))
|
|
140
|
+
return _
|
|
141
|
+
})
|
|
142
|
+
onChange?.($)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return <InputFile ref={ref} accept=".xlsx" type="arrayBuffer" onChange={onInputChange} {...others} />
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
/** 手动导出 excel */
|
|
150
|
+
export function exportExcel(data: Record<string, string>[], name: string) {
|
|
151
|
+
const workSheet = utils.json_to_sheet(data)
|
|
152
|
+
const workBook = utils.book_new()
|
|
153
|
+
utils.book_append_sheet(workBook, workSheet)
|
|
154
|
+
writeFile(workBook, `${name}${name.endsWith(".xlsx") ? "" : ".xlsx"}`)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface ExportExcelProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
158
|
+
data: Record<string, string>[]
|
|
159
|
+
fileName: string
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** 导出 excel 的 button 组件 */
|
|
163
|
+
export const ExportExcel = forwardRef<HTMLButtonElement, ExportExcelProps>((props, ref) => {
|
|
164
|
+
const { data, fileName, onClick, ...others } = props
|
|
165
|
+
|
|
166
|
+
function onButtonClick(e: ReactMouseEvent<HTMLButtonElement, MouseEvent>) {
|
|
167
|
+
exportExcel(data, fileName)
|
|
168
|
+
onClick?.(e)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return <button ref={ref} onClick={onButtonClick} {...others} />
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
export interface TransitionBoxProps extends HTMLAttributes<HTMLDivElement> {
|
|
175
|
+
containerClassName?: string
|
|
176
|
+
containerStyle?: CSSProperties
|
|
177
|
+
vertical?: boolean
|
|
178
|
+
horizontal?: boolean
|
|
179
|
+
time?: number
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** 尺寸渐变的组件 */
|
|
183
|
+
export const TransitionBox: FC<TransitionBoxProps> = props => {
|
|
184
|
+
const { style, containerClassName, containerStyle, children, vertical = true, horizontal = true, time = 3000, ...others } = props
|
|
185
|
+
const box = useRef<HTMLDivElement>(null)
|
|
186
|
+
const [width, setWidth] = useState(0)
|
|
187
|
+
const [height, setHeight] = useState(0)
|
|
188
|
+
const [count, setCount] = useState(0)
|
|
189
|
+
|
|
190
|
+
useEffect(() => {
|
|
191
|
+
const observer = new ResizeObserver(entries => {
|
|
192
|
+
const { width: currentWidth, height: currentHeight } = entries[0].contentRect
|
|
193
|
+
setWidth(currentWidth)
|
|
194
|
+
setHeight(currentHeight)
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
observer.observe(box.current!)
|
|
198
|
+
|
|
199
|
+
return () => {
|
|
200
|
+
observer.disconnect()
|
|
201
|
+
}
|
|
202
|
+
}, [])
|
|
203
|
+
|
|
204
|
+
useEffect(() => {
|
|
205
|
+
setCount(count => Math.min(count + 1, 3))
|
|
206
|
+
}, [width, height])
|
|
207
|
+
|
|
208
|
+
const outerStyle: CSSProperties = { transitionProperty: count === 3 ? [horizontal && "width", vertical && "height"].filter(Boolean).join(", ") : undefined, transitionDuration: count === 3 ? `${time}ms` : undefined, width, height, overflow: "hidden", position: "relative", ...style }
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<div style={outerStyle} {...others}>
|
|
212
|
+
<div className={containerClassName} style={{ position: "absolute", ...containerStyle }} ref={box}>
|
|
213
|
+
{children}
|
|
214
|
+
</div>
|
|
215
|
+
</div>
|
|
216
|
+
)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface SeaRadarTarget {
|
|
220
|
+
/** 半径 */
|
|
221
|
+
radius: number
|
|
222
|
+
/** 弧度 */
|
|
223
|
+
angle: number
|
|
224
|
+
/** 元素 */
|
|
225
|
+
element: ReactNode
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export interface SeaRadarProps {
|
|
229
|
+
/** 最小圆的半径 */
|
|
230
|
+
unitRadius?: number
|
|
231
|
+
/** 一共的全数 */
|
|
232
|
+
circleCount?: number
|
|
233
|
+
/** 角度分成多少份 */
|
|
234
|
+
directionCount?: number
|
|
235
|
+
/** 圈的宽度 */
|
|
236
|
+
circleWidth?: number
|
|
237
|
+
/** 圈的颜色 */
|
|
238
|
+
circleColor: string
|
|
239
|
+
/** 角度的宽度 */
|
|
240
|
+
directionWidth?: number
|
|
241
|
+
/** 角度颜色 */
|
|
242
|
+
directionColor: string
|
|
243
|
+
/** 背景色 */
|
|
244
|
+
backgroundColor: string
|
|
245
|
+
/** 扫描的颜色 */
|
|
246
|
+
scanColor: string
|
|
247
|
+
/** 扫描的弧度 */
|
|
248
|
+
scanAngle?: number
|
|
249
|
+
/** 扫描一周的时间,单位秒 */
|
|
250
|
+
period?: number
|
|
251
|
+
/** 目标列表 */
|
|
252
|
+
targets?: SeaRadarTarget[]
|
|
253
|
+
/** 展示圈 */
|
|
254
|
+
showCircle?: boolean
|
|
255
|
+
/** 展示方位 */
|
|
256
|
+
showDirection?: boolean
|
|
257
|
+
/** 展示刻度线 */
|
|
258
|
+
showGraduationLine?: boolean
|
|
259
|
+
/** 展示刻度文字 */
|
|
260
|
+
showGraduationText?: boolean
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** 雷达组件 */
|
|
264
|
+
export const SeaRadar: FC<SeaRadarProps> = props => {
|
|
265
|
+
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
|
|
266
|
+
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` } as CSSProperties
|
|
267
|
+
return (
|
|
268
|
+
<div className="sea-radar-wrapper" style={style}>
|
|
269
|
+
{Array(180)
|
|
270
|
+
.fill(0)
|
|
271
|
+
.map((_, index) => (
|
|
272
|
+
<div className="sea-radar-little-graduation" style={{ transform: `rotateZ(${2 * index}deg)`, display: showGraduationLine ? "block" : "none" }}></div>
|
|
273
|
+
))}
|
|
274
|
+
{Array(36)
|
|
275
|
+
.fill(0)
|
|
276
|
+
.map((_, index) => (
|
|
277
|
+
<div className="sea-radar-graduation" style={{ transform: `rotateZ(${10 * index}deg)`, display: showGraduationLine ? "block" : "none" }}>
|
|
278
|
+
<span className="sea-radar-graduation-text" style={{ display: showGraduationText ? "block" : "none" }}>
|
|
279
|
+
{String(index * 10).padStart(3, "0")}
|
|
280
|
+
</span>
|
|
281
|
+
</div>
|
|
282
|
+
))}
|
|
283
|
+
<div className="sea-radar">
|
|
284
|
+
<div className="sea-radar-scan" style={{ height: `${unitRadius * circleCount * Math.tan(scanAngle)}px`, clipPath: `polygon(0 0, 0 100%, 100% 100%)` }}></div>
|
|
285
|
+
{showCircle &&
|
|
286
|
+
Array(circleCount)
|
|
287
|
+
.fill(0)
|
|
288
|
+
.map((_, index) => <div className="sea-radar-circle" style={{ width: `${unitRadius * 2 * (index + 1)}px`, height: `${unitRadius * 2 * (index + 1)}px` }}></div>)}
|
|
289
|
+
{showDirection &&
|
|
290
|
+
Array(directionCount)
|
|
291
|
+
.fill(0)
|
|
292
|
+
.map((_, index) => <div className="sea-radar-direction" style={{ transform: `rotateZ(${(360 / directionCount) * index}deg)` }}></div>)}
|
|
293
|
+
{targets?.map(it => (
|
|
294
|
+
<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` }}>
|
|
295
|
+
{it.element}
|
|
296
|
+
</div>
|
|
297
|
+
))}
|
|
298
|
+
</div>
|
|
299
|
+
</div>
|
|
300
|
+
)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export interface RingProps extends HTMLAttributes<HTMLDivElement> {
|
|
304
|
+
outerWidth: number
|
|
305
|
+
innerWidth: number
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** 忘了什么组件 */
|
|
309
|
+
export const Ring: FC<RingProps> = props => {
|
|
310
|
+
const { outerWidth, innerWidth, style, ...leftProps } = props
|
|
311
|
+
|
|
312
|
+
const outerRadius = outerWidth / 2
|
|
313
|
+
|
|
314
|
+
const innerRadius = innerWidth / 2
|
|
315
|
+
|
|
316
|
+
return <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} />
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export interface FlowSizeData {
|
|
320
|
+
/** 容器宽度 */
|
|
321
|
+
width: number
|
|
322
|
+
/** 容器高度 */
|
|
323
|
+
height: number
|
|
324
|
+
/** 元素宽度 */
|
|
325
|
+
itemWidth: number
|
|
326
|
+
/** 元素高度 */
|
|
327
|
+
itemHeight: number
|
|
328
|
+
/** 列间距 */
|
|
329
|
+
columnGap: number
|
|
330
|
+
/** 列数 */
|
|
331
|
+
columnCount: number
|
|
332
|
+
/** 行间距 */
|
|
333
|
+
rowGap: number
|
|
334
|
+
/** 行数 */
|
|
335
|
+
rowCount: number
|
|
336
|
+
/** 元素格数 */
|
|
337
|
+
itemCount: number
|
|
338
|
+
/** 最大行数 */
|
|
339
|
+
maxRows: number | null
|
|
340
|
+
/** 是否有元素被隐藏 */
|
|
341
|
+
overflow: boolean
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export interface FlowProps<T> extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
|
|
345
|
+
/** 元素宽度 */
|
|
346
|
+
itemWidth: number
|
|
347
|
+
/** 元素高度 */
|
|
348
|
+
itemHeight: number
|
|
349
|
+
/** 列间距 */
|
|
350
|
+
columnGap?: number | null | (number | null)[]
|
|
351
|
+
/** 行间距 */
|
|
352
|
+
rowGap?: number
|
|
353
|
+
/** 最大行数 */
|
|
354
|
+
maxRows?: number | null
|
|
355
|
+
/** 源数据 */
|
|
356
|
+
data: T[]
|
|
357
|
+
/** 渲染 */
|
|
358
|
+
render: (item: T, index: number, hidden: boolean) => ReactNode
|
|
359
|
+
/** key释放器,默认为 index */
|
|
360
|
+
keyExactor?: (item: T, index: number) => string | number
|
|
361
|
+
/** 容器类名 */
|
|
362
|
+
containerClassName?: string
|
|
363
|
+
/** 容器样式 */
|
|
364
|
+
containerStyle?: CSSProperties
|
|
365
|
+
/** 节流时间,单位毫秒,默认200ms,传入 null 不节流 */
|
|
366
|
+
throttle?: number | null
|
|
367
|
+
/** 动画时间,单位毫秒,默认400ms,传入 null 不展示动画 */
|
|
368
|
+
transitionDuration?: number | null
|
|
369
|
+
/** 变化的回调函数 */
|
|
370
|
+
onSizeChange?: (sizeData: FlowSizeData) => void
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export function getGapRange(gap?: undefined | number | null | (number | null)[]): [number, number | null] {
|
|
374
|
+
if (typeof gap === "number") return [gap, gap]
|
|
375
|
+
if (Array.isArray(gap)) return [gap[0] || 0, gap[1]]
|
|
376
|
+
return [0, null]
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
export function getGapCountAndSize(width: number, itemWidth: number, minGap: number, maxGap: number | null): [number, number] {
|
|
380
|
+
const count = Math.floor((width + minGap) / (itemWidth + minGap)) || 1
|
|
381
|
+
if (count === 1) return [count, 0]
|
|
382
|
+
const averageGap = (width - itemWidth * count) / (count - 1)
|
|
383
|
+
if (averageGap < minGap) return [count, minGap]
|
|
384
|
+
if (maxGap !== null && averageGap > maxGap) return [count, maxGap]
|
|
385
|
+
return [count, averageGap]
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** 自适应浮动组件 */
|
|
389
|
+
export function Flow<T>(props: FlowProps<T>) {
|
|
390
|
+
const { itemWidth, itemHeight, columnGap, rowGap = 0, maxRows, data, render, keyExactor, className, style, containerClassName, containerStyle, throttle, transitionDuration, onSizeChange, ...others } = props
|
|
391
|
+
const [minColumnGap, maxColumnGap] = getGapRange(columnGap)
|
|
392
|
+
const [width, setWidth] = useState(0)
|
|
393
|
+
const [columnCount, setColumnCount] = useState(1)
|
|
394
|
+
const [columnGapSize, setColumnGapSize] = useState(minColumnGap)
|
|
395
|
+
const [showItems, setShowItems] = useState(false)
|
|
396
|
+
const ele = useRef<HTMLDivElement>(null)
|
|
397
|
+
const contentRows = Math.ceil(data.length / columnCount)
|
|
398
|
+
const contentShownRows = typeof maxRows === "number" ? Math.min(contentRows, maxRows) : contentRows
|
|
399
|
+
const height = contentShownRows > 0 ? contentShownRows * (itemHeight + rowGap) - rowGap : 0
|
|
400
|
+
|
|
401
|
+
interface Position {
|
|
402
|
+
left: number
|
|
403
|
+
top: number
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function getPosition(index: number): Position {
|
|
407
|
+
const y = Math.floor(index / columnCount)
|
|
408
|
+
const x = index - y * columnCount
|
|
409
|
+
return {
|
|
410
|
+
left: x * (itemWidth + columnGapSize),
|
|
411
|
+
top: y * (itemHeight + rowGap)
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function getHidden(index: number) {
|
|
416
|
+
if (typeof maxRows !== "number") return false
|
|
417
|
+
return index >= maxRows * columnCount
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
useEffect(() => {
|
|
421
|
+
let timeout: number
|
|
422
|
+
const observer = new ResizeObserver(entries => {
|
|
423
|
+
clearTimeout(timeout)
|
|
424
|
+
function task() {
|
|
425
|
+
const { inlineSize: width } = entries[0].borderBoxSize[0]
|
|
426
|
+
const [newColumnCount, newColumnGapSize] = getGapCountAndSize(width, itemWidth, minColumnGap, maxColumnGap)
|
|
427
|
+
setShowItems(true)
|
|
428
|
+
setWidth(width)
|
|
429
|
+
setColumnCount(newColumnCount)
|
|
430
|
+
setColumnGapSize(newColumnGapSize)
|
|
431
|
+
}
|
|
432
|
+
if (throttle === null) {
|
|
433
|
+
task()
|
|
434
|
+
} else {
|
|
435
|
+
timeout = window.setTimeout(task, throttle || 200)
|
|
436
|
+
}
|
|
437
|
+
})
|
|
438
|
+
observer.observe(ele.current!)
|
|
439
|
+
|
|
440
|
+
return () => {
|
|
441
|
+
observer.disconnect()
|
|
442
|
+
}
|
|
443
|
+
}, [itemWidth, throttle, columnGap])
|
|
444
|
+
|
|
445
|
+
useEffect(() => {
|
|
446
|
+
onSizeChange?.({ width, height, itemWidth, itemHeight, columnGap: columnGapSize, columnCount, rowGap, rowCount: contentShownRows, overflow: data.length > contentShownRows * columnCount, itemCount: data.length, maxRows: maxRows ?? null })
|
|
447
|
+
}, [width, height, columnGapSize, columnCount, rowGap, contentShownRows, data.length, itemWidth, itemHeight, maxRows])
|
|
448
|
+
|
|
449
|
+
return (
|
|
450
|
+
<div ref={ele} className={className} style={{ position: "relative", boxSizing: "border-box", height, ...style }} {...others}>
|
|
451
|
+
{showItems &&
|
|
452
|
+
data.map((it, idx) => (
|
|
453
|
+
<div
|
|
454
|
+
key={keyExactor?.(it, idx) || idx}
|
|
455
|
+
className={containerClassName}
|
|
456
|
+
style={{
|
|
457
|
+
position: "absolute",
|
|
458
|
+
width: itemWidth,
|
|
459
|
+
height: itemHeight,
|
|
460
|
+
transition: transitionDuration !== null ? `all ${transitionDuration ?? 400}ms` : undefined,
|
|
461
|
+
...getPosition(idx)
|
|
462
|
+
}}
|
|
463
|
+
>
|
|
464
|
+
<div style={{ width: itemWidth, height: itemHeight, display: maxRows && idx >= maxRows * columnCount ? "none" : "block", ...containerStyle }}>{render(it, idx, getHidden(idx))}</div>
|
|
465
|
+
</div>
|
|
466
|
+
))}
|
|
467
|
+
</div>
|
|
468
|
+
)
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export interface TrapeziumProps extends HTMLAttributes<HTMLDivElement> {
|
|
472
|
+
top: number
|
|
473
|
+
bottom: number
|
|
474
|
+
height: number
|
|
475
|
+
borderRadius: number
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/** 梯形组件 */
|
|
479
|
+
export const Trapezium = forwardRef<HTMLDivElement, TrapeziumProps>((props, ref) => {
|
|
480
|
+
const { top, bottom, height, borderRadius, style, ...other } = props
|
|
481
|
+
|
|
482
|
+
const diff = (bottom - top) / 2
|
|
483
|
+
|
|
484
|
+
const a = Math.atan(height / diff) / 2
|
|
485
|
+
|
|
486
|
+
const b = borderRadius / Math.tan(a)
|
|
487
|
+
|
|
488
|
+
const c = b * Math.cos(a * 2)
|
|
489
|
+
|
|
490
|
+
const d = b * Math.sin(a * 2)
|
|
491
|
+
|
|
492
|
+
const e = Math.PI / 2 - a
|
|
493
|
+
|
|
494
|
+
const f = borderRadius / Math.tan(e)
|
|
495
|
+
|
|
496
|
+
const g = f * Math.cos(a * 2)
|
|
497
|
+
|
|
498
|
+
const h = f * Math.sin(a * 2)
|
|
499
|
+
|
|
500
|
+
return <div ref={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} />
|
|
501
|
+
})
|
|
502
|
+
|
|
503
|
+
export interface LoopSwiperProps<T> {
|
|
504
|
+
/** 源数据 */
|
|
505
|
+
data: T[]
|
|
506
|
+
/** 渲染函数 */
|
|
507
|
+
render: (item: T, index: number, array: T[]) => ReactNode
|
|
508
|
+
/** 每个元素的key */
|
|
509
|
+
keyExactor?: (item: T, index: number, array: T[]) => string
|
|
510
|
+
/** 水平方向是宽度,垂直方向是高度 */
|
|
511
|
+
size: number
|
|
512
|
+
/** 元素之间间隔 */
|
|
513
|
+
gap?: number
|
|
514
|
+
/** 起始位置 */
|
|
515
|
+
start?: number
|
|
516
|
+
/** 速度,水平方向正数为向左,水平方向负数为向右,垂直方向正数为向上,水平方向负数为向下 */
|
|
517
|
+
speed: number
|
|
518
|
+
/** 是否暂停播放 */
|
|
519
|
+
paused?: boolean
|
|
520
|
+
/** 容器的类名 */
|
|
521
|
+
className?: string
|
|
522
|
+
/** x 水平方向,y 垂直方向 */
|
|
523
|
+
direction?: "x" | "y"
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
export interface LoopSwiperItem {
|
|
527
|
+
key: string
|
|
528
|
+
dom: HTMLDivElement | null
|
|
529
|
+
offset: number
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/** 循环播放组件 */
|
|
533
|
+
export function LoopSwiper<T>(props: LoopSwiperProps<T>) {
|
|
534
|
+
const { data, render, keyExactor, size, gap = 0, start = 0, speed, paused = false, className = "", direction = "x" } = props
|
|
535
|
+
if (!(size > 0 && (speed > 0 || speed < 0))) {
|
|
536
|
+
throw new RangeError("size 必须是正数,speed 必须非0")
|
|
537
|
+
}
|
|
538
|
+
const keys = data.map((it, idx, arr) => (keyExactor ? keyExactor(it, idx, arr) : String(idx)))
|
|
539
|
+
const keysRef = useRef(keys)
|
|
540
|
+
const cache = useRef({ size, gap, speed, keys, paused, className, direction })
|
|
541
|
+
cache.current = { size, gap, speed, keys, paused, className, direction }
|
|
542
|
+
const eles = useRef<LoopSwiperItem[]>(keys.map((key, idx) => ({ key, dom: null, offset: idx * (size + gap) + start })))
|
|
543
|
+
|
|
544
|
+
if (keysRef.current.length !== keys.length || keysRef.current.some((it, idx) => it !== keys[idx])) {
|
|
545
|
+
keysRef.current = keys
|
|
546
|
+
eles.current = keys.map((key, idx) => ({ key, dom: null, offset: idx * (size + gap) + start }))
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function setStyles() {
|
|
550
|
+
const { size, speed, className, direction } = cache.current
|
|
551
|
+
eles.current.forEach(it => {
|
|
552
|
+
it.dom!.className = className
|
|
553
|
+
it.dom!.style.setProperty("position", `absolute`)
|
|
554
|
+
it.dom!.style.setProperty("width", `${size}px`)
|
|
555
|
+
direction === "x" && speed < 0 ? it.dom!.style.setProperty("right", `0`) : it.dom!.style.setProperty("left", `0`)
|
|
556
|
+
direction === "y" && speed < 0 ? it.dom!.style.setProperty("bottom", `0`) : it.dom!.style.setProperty("top", `0`)
|
|
557
|
+
it.dom!.style.setProperty("transform", `translate${direction.toUpperCase()}(${it.offset * (speed > 0 ? 1 : -1)}px)`)
|
|
558
|
+
})
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
useEffect(() => {
|
|
562
|
+
setStyles()
|
|
563
|
+
}, [])
|
|
564
|
+
|
|
565
|
+
useEffect(() => {
|
|
566
|
+
const stop = setFrameInterval(() => {
|
|
567
|
+
const { size, gap, speed, keys, paused } = cache.current
|
|
568
|
+
if (paused) return
|
|
569
|
+
eles.current.length = keys.length
|
|
570
|
+
let minIndex = 0
|
|
571
|
+
eles.current.forEach((it, idx) => {
|
|
572
|
+
if (it.offset < eles.current[minIndex].offset) {
|
|
573
|
+
minIndex = idx
|
|
574
|
+
}
|
|
575
|
+
})
|
|
576
|
+
const minOffset = eles.current[minIndex].offset
|
|
577
|
+
eles.current.forEach((it, idx) => {
|
|
578
|
+
let index = idx
|
|
579
|
+
if (idx < minIndex) index = eles.current.length + idx
|
|
580
|
+
it.offset = minOffset + (index - minIndex) * (size + gap)
|
|
581
|
+
let newOffset = it.offset - Math.abs(speed)
|
|
582
|
+
if (newOffset + size + gap <= 0) {
|
|
583
|
+
newOffset += eles.current.length * (size + gap)
|
|
584
|
+
}
|
|
585
|
+
it.offset = newOffset
|
|
586
|
+
})
|
|
587
|
+
setStyles()
|
|
588
|
+
}, 1)
|
|
589
|
+
|
|
590
|
+
return stop
|
|
591
|
+
}, [])
|
|
592
|
+
|
|
593
|
+
function ref(dom: HTMLDivElement | null, index: number) {
|
|
594
|
+
if (!eles.current[index]) return
|
|
595
|
+
eles.current[index].dom = dom
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
return (
|
|
599
|
+
<Fragment>
|
|
600
|
+
{data.map((it, idx, arr) => (
|
|
601
|
+
<div key={keys[idx]} ref={dom => ref(dom, idx)}>
|
|
602
|
+
{render(it, idx, arr)}
|
|
603
|
+
</div>
|
|
604
|
+
))}
|
|
605
|
+
</Fragment>
|
|
606
|
+
)
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
export interface SectionRingProps extends HTMLAttributes<HTMLDivElement> {
|
|
610
|
+
outerRadius: number
|
|
611
|
+
innerRadius: number
|
|
612
|
+
count: number
|
|
613
|
+
angel: number
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
export const SectionRing: FC<SectionRingProps> = props => {
|
|
617
|
+
const { outerRadius: o, innerRadius: i, count: c, angel: a, style, ...others } = props
|
|
618
|
+
|
|
619
|
+
const s = (Math.PI * 2) / c - a
|
|
620
|
+
|
|
621
|
+
function arc(radius: number, startAngle: number, endAngle: number, options: DrawArcOptions = {}) {
|
|
622
|
+
return drawArc(o, o, radius, startAngle, endAngle, options)
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
return (
|
|
626
|
+
<div
|
|
627
|
+
style={{
|
|
628
|
+
...style,
|
|
629
|
+
width: o * 2,
|
|
630
|
+
height: o * 2,
|
|
631
|
+
clipPath: `path("${Array(c)
|
|
632
|
+
.fill(0)
|
|
633
|
+
.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 })}`)
|
|
634
|
+
.join(" ")} Z")`
|
|
635
|
+
}}
|
|
636
|
+
{...others}
|
|
637
|
+
/>
|
|
638
|
+
)
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
export interface TransitionNumProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
|
|
642
|
+
/** 当前数字 */
|
|
643
|
+
children: number
|
|
644
|
+
/** 变换周期,单位帧 */
|
|
645
|
+
period: number
|
|
646
|
+
/** 数字转换为字符串的方法 */
|
|
647
|
+
numToStr?: (num: number) => string
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
export interface TransitionNumIns {
|
|
651
|
+
get(): number
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/** 渐变数字组件 */
|
|
655
|
+
export const TransitionNum = forwardRef<TransitionNumIns, TransitionNumProps>((props, ref) => {
|
|
656
|
+
const { children: num, period, numToStr, ...others } = props
|
|
657
|
+
if (!Number.isInteger(num) || !Number.isInteger(period) || period <= 0) {
|
|
658
|
+
throw new RangeError("目标数字必须是整数,周期必须是正整数")
|
|
659
|
+
}
|
|
660
|
+
const ele = useRef<HTMLDivElement>(null)
|
|
661
|
+
const cache = useRef({ num, period, numToStr, show: num })
|
|
662
|
+
cache.current = { ...cache.current, num, period, numToStr }
|
|
663
|
+
|
|
664
|
+
useImperativeHandle(ref, () => ({ get: () => cache.current.show }), [])
|
|
665
|
+
|
|
666
|
+
useEffect(() => {
|
|
667
|
+
const { num, period, show, numToStr } = cache.current
|
|
668
|
+
ele.current!.innerText = (numToStr || String)(show)
|
|
669
|
+
if (num === show) return
|
|
670
|
+
const div = ele.current!
|
|
671
|
+
const speed = (num - show) / period
|
|
672
|
+
const cancel = setFrameInterval(() => {
|
|
673
|
+
const { num, numToStr } = cache.current
|
|
674
|
+
cache.current.show += speed
|
|
675
|
+
if ((speed > 0 && cache.current.show > num) || (speed < 0 && cache.current.show < num)) {
|
|
676
|
+
cancel()
|
|
677
|
+
cache.current.show = num
|
|
678
|
+
}
|
|
679
|
+
div.innerText = (numToStr || String)(speed > 0 ? Math.floor(cache.current.show) : Math.ceil(cache.current.show))
|
|
680
|
+
}, 1)
|
|
681
|
+
|
|
682
|
+
return cancel
|
|
683
|
+
}, [num])
|
|
684
|
+
|
|
685
|
+
return <div ref={ele} {...others} />
|
|
686
|
+
})
|
|
687
|
+
|
|
688
|
+
export interface CircleTextProps extends Omit<HTMLAttributes<HTMLSpanElement>, "children"> {
|
|
689
|
+
/** 每一个方块的宽度 */
|
|
690
|
+
width: number
|
|
691
|
+
/** 每一个方块的高度 */
|
|
692
|
+
height: number
|
|
693
|
+
/** 圆弧的半径,不包含方块的高度 */
|
|
694
|
+
radius: number
|
|
695
|
+
/** 开始旋转的弧度,逆时针增加,0 为 x 轴方向 */
|
|
696
|
+
startAngel?: number
|
|
697
|
+
/** 每一个方块之间间隔的弧度 */
|
|
698
|
+
gapAngel?: number
|
|
699
|
+
/** 文字对齐的方式,默认居中 */
|
|
700
|
+
align?: "left" | "center" | "right"
|
|
701
|
+
/** 文字朝向圆心还是外侧,默认外侧 */
|
|
702
|
+
direction?: "inner" | "outer"
|
|
703
|
+
/** 是否反转文字顺序 */
|
|
704
|
+
reverse?: boolean
|
|
705
|
+
/** 分割文字的方法 */
|
|
706
|
+
separator?: string | RegExp | ((text: string) => string[])
|
|
707
|
+
/** 显示的文字 */
|
|
708
|
+
children: string
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/** 环形文字 */
|
|
712
|
+
export const CircleText: FC<CircleTextProps> = props => {
|
|
713
|
+
const { width, height, radius, startAngel = 0, gapAngel = 0, align = "center", style, direction = "outer", reverse = false, separator, children, ...others } = props
|
|
714
|
+
const unitAngle = Math.atan(width / 2 / radius) * 2
|
|
715
|
+
const totalAngle = (unitAngle + gapAngel) * children.length - gapAngel
|
|
716
|
+
const offsetAngle = align === "left" ? 0 : align === "right" ? totalAngle : totalAngle / 2
|
|
717
|
+
|
|
718
|
+
function getTransform(idx: number) {
|
|
719
|
+
const angle = startAngel - idx * (unitAngle + gapAngel) + offsetAngle - unitAngle / 2
|
|
720
|
+
const x = (radius + height / 2) * Math.cos(angle) - width / 2
|
|
721
|
+
const y = (radius + height / 2) * Math.sin(angle) * -1 - height / 2
|
|
722
|
+
const z = Math.PI / 2 - angle + (direction === "inner" ? Math.PI : 0)
|
|
723
|
+
return `translateX(${x}px) translateY(${y}px) rotateZ(${(z / Math.PI) * 180}deg)`
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
const words = typeof separator === "function" ? separator(children) : children.split(separator ?? "")
|
|
727
|
+
|
|
728
|
+
if (reverse) words.reverse()
|
|
729
|
+
|
|
730
|
+
return (
|
|
731
|
+
<Fragment>
|
|
732
|
+
{words.map((w, idx) => (
|
|
733
|
+
<span key={idx} style={{ position: "absolute", ...style, transform: getTransform(idx), textAlign: "center", width, lineHeight: `${height}px`, height: height }} {...others}>
|
|
734
|
+
{w}
|
|
735
|
+
</span>
|
|
736
|
+
))}
|
|
737
|
+
</Fragment>
|
|
738
|
+
)
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
export interface ScrollOptions extends Partial<ScrollbarOptions> {
|
|
742
|
+
/** 滑块宽度 */
|
|
743
|
+
thumbWidth?: number
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
export interface ScrollProps extends HTMLAttributes<HTMLDivElement> {
|
|
747
|
+
/** 滚动的配置 */
|
|
748
|
+
options?: ScrollOptions
|
|
749
|
+
/** 容器宽度 */
|
|
750
|
+
containerClassName?: string
|
|
751
|
+
/** 容器样式 */
|
|
752
|
+
containerStyle?: CSSProperties
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* 滚动条组件
|
|
757
|
+
* @description 注意 children 不是直接渲染在组件上的,而是渲染在内部的容器上
|
|
758
|
+
*/
|
|
759
|
+
export const Scroll = forwardRef<HTMLDivElement, ScrollProps>((props, ref) => {
|
|
760
|
+
const { children, containerClassName, containerStyle, options, className, ...others } = props
|
|
761
|
+
const { thumbWidth, ...scrollbarOptions } = options || {}
|
|
762
|
+
const id = useId()
|
|
763
|
+
|
|
764
|
+
useEffect(() => {
|
|
765
|
+
SmoothScrollBar.init(document.querySelector(`[data-scroll-id="${id}"]`)!, scrollbarOptions)
|
|
766
|
+
}, [])
|
|
767
|
+
|
|
768
|
+
return (
|
|
769
|
+
<div
|
|
770
|
+
ref={ref}
|
|
771
|
+
className={clsx(
|
|
772
|
+
!!thumbWidth &&
|
|
773
|
+
css`
|
|
774
|
+
.scrollbar-track.scrollbar-track-x {
|
|
775
|
+
height: ${thumbWidth}px;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
.scrollbar-thumb.scrollbar-thumb-x {
|
|
779
|
+
height: ${thumbWidth}px;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
.scrollbar-track.scrollbar-track-y {
|
|
783
|
+
width: ${thumbWidth}px;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
.scrollbar-thumb.scrollbar-thumb-y {
|
|
787
|
+
width: ${thumbWidth}px;
|
|
788
|
+
}
|
|
789
|
+
`,
|
|
790
|
+
className
|
|
791
|
+
)}
|
|
792
|
+
data-scroll-id={id}
|
|
793
|
+
{...others}
|
|
794
|
+
>
|
|
795
|
+
<div className={containerClassName} style={containerStyle}>
|
|
796
|
+
{children}
|
|
797
|
+
</div>
|
|
798
|
+
</div>
|
|
799
|
+
)
|
|
800
|
+
})
|
|
801
|
+
|
|
802
|
+
export const X = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>((props, ref) => {
|
|
803
|
+
const { className, ...others } = props
|
|
804
|
+
|
|
805
|
+
return (
|
|
806
|
+
<div
|
|
807
|
+
ref={ref}
|
|
808
|
+
className={clsx(
|
|
809
|
+
css`
|
|
810
|
+
display: flex;
|
|
811
|
+
`,
|
|
812
|
+
className
|
|
813
|
+
)}
|
|
814
|
+
{...others}
|
|
815
|
+
/>
|
|
816
|
+
)
|
|
817
|
+
})
|
|
818
|
+
|
|
819
|
+
export const Y = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>((props, ref) => {
|
|
820
|
+
const { className, ...others } = props
|
|
821
|
+
|
|
822
|
+
return (
|
|
823
|
+
<div
|
|
824
|
+
ref={ref}
|
|
825
|
+
className={clsx(
|
|
826
|
+
css`
|
|
827
|
+
display: flex;
|
|
828
|
+
flex-direction: column;
|
|
829
|
+
`,
|
|
830
|
+
className
|
|
831
|
+
)}
|
|
832
|
+
{...others}
|
|
833
|
+
/>
|
|
834
|
+
)
|
|
835
|
+
})
|
|
836
|
+
|
|
837
|
+
export const Auto = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>((props, ref) => {
|
|
838
|
+
const { className, ...others } = props
|
|
839
|
+
|
|
840
|
+
return (
|
|
841
|
+
<div
|
|
842
|
+
ref={ref}
|
|
843
|
+
className={clsx(
|
|
844
|
+
css`
|
|
845
|
+
flex: auto;
|
|
846
|
+
`,
|
|
847
|
+
className
|
|
848
|
+
)}
|
|
849
|
+
{...others}
|
|
850
|
+
/>
|
|
851
|
+
)
|
|
852
|
+
})
|
|
853
|
+
|
|
854
|
+
export const None = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>((props, ref) => {
|
|
855
|
+
const { className, ...others } = props
|
|
856
|
+
|
|
857
|
+
return (
|
|
858
|
+
<div
|
|
859
|
+
ref={ref}
|
|
860
|
+
className={clsx(
|
|
861
|
+
css`
|
|
862
|
+
flex: none;
|
|
863
|
+
`,
|
|
864
|
+
className
|
|
865
|
+
)}
|
|
866
|
+
{...others}
|
|
867
|
+
/>
|
|
868
|
+
)
|
|
869
|
+
})
|
|
870
|
+
|
|
871
|
+
export const XAuto = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>((props, ref) => {
|
|
872
|
+
const { className, ...others } = props
|
|
873
|
+
|
|
874
|
+
return (
|
|
875
|
+
<div
|
|
876
|
+
ref={ref}
|
|
877
|
+
className={clsx(
|
|
878
|
+
css`
|
|
879
|
+
display: flex;
|
|
880
|
+
flex: auto;
|
|
881
|
+
`,
|
|
882
|
+
className
|
|
883
|
+
)}
|
|
884
|
+
{...others}
|
|
885
|
+
/>
|
|
886
|
+
)
|
|
887
|
+
})
|
|
888
|
+
|
|
889
|
+
export const YAuto = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>((props, ref) => {
|
|
890
|
+
const { className, ...others } = props
|
|
891
|
+
|
|
892
|
+
return (
|
|
893
|
+
<div
|
|
894
|
+
ref={ref}
|
|
895
|
+
className={clsx(
|
|
896
|
+
css`
|
|
897
|
+
display: flex;
|
|
898
|
+
flex-direction: column;
|
|
899
|
+
flex: auto;
|
|
900
|
+
`,
|
|
901
|
+
className
|
|
902
|
+
)}
|
|
903
|
+
{...others}
|
|
904
|
+
/>
|
|
905
|
+
)
|
|
906
|
+
})
|
|
907
|
+
|
|
908
|
+
export const XNone = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>((props, ref) => {
|
|
909
|
+
const { className, ...others } = props
|
|
910
|
+
|
|
911
|
+
return (
|
|
912
|
+
<div
|
|
913
|
+
ref={ref}
|
|
914
|
+
className={clsx(
|
|
915
|
+
css`
|
|
916
|
+
display: flex;
|
|
917
|
+
flex: none;
|
|
918
|
+
`,
|
|
919
|
+
className
|
|
920
|
+
)}
|
|
921
|
+
{...others}
|
|
922
|
+
/>
|
|
923
|
+
)
|
|
924
|
+
})
|
|
925
|
+
|
|
926
|
+
export const YNone = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>((props, ref) => {
|
|
927
|
+
const { className, ...others } = props
|
|
928
|
+
|
|
929
|
+
return (
|
|
930
|
+
<div
|
|
931
|
+
ref={ref}
|
|
932
|
+
className={clsx(
|
|
933
|
+
css`
|
|
934
|
+
display: flex;
|
|
935
|
+
flex-direction: column;
|
|
936
|
+
flex: none;
|
|
937
|
+
`,
|
|
938
|
+
className
|
|
939
|
+
)}
|
|
940
|
+
{...others}
|
|
941
|
+
/>
|
|
942
|
+
)
|
|
943
|
+
})
|