deepsea-components 1.3.3 → 2.0.0

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.js DELETED
@@ -1,816 +0,0 @@
1
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
- import { css } from "@emotion/css";
3
- import clsx from "clsx";
4
- import { drawArc, setFrameInterval } from "deepsea-tools";
5
- import React, { Fragment, forwardRef, useEffect, useId, useImperativeHandle, useRef, useState } from "react";
6
- import SmoothScrollBar from "smooth-scrollbar";
7
- import { read, utils, writeFile } from "xlsx";
8
- export async function getFileData(file, type) {
9
- const fileReader = new FileReader();
10
- switch (type) {
11
- case "arrayBuffer":
12
- fileReader.readAsArrayBuffer(file);
13
- break;
14
- case "binary":
15
- fileReader.readAsBinaryString(file);
16
- break;
17
- case "base64":
18
- fileReader.readAsDataURL(file);
19
- break;
20
- case "text":
21
- fileReader.readAsText(file);
22
- break;
23
- default:
24
- return file;
25
- }
26
- return new Promise(resolve => {
27
- fileReader.addEventListener("load", () => {
28
- resolve(fileReader.result);
29
- });
30
- });
31
- }
32
-
33
- /** 专用与读取文件的组件 */
34
- export const InputFile = /*#__PURE__*/forwardRef((props, ref) => {
35
- const {
36
- multiple = false,
37
- type = "file",
38
- onChange,
39
- disabled: inputDisabled,
40
- ...others
41
- } = props;
42
- const [disabled, setDisabled] = useState(false);
43
- async function onInputChange(e) {
44
- const input = e.target;
45
- const {
46
- files
47
- } = input;
48
- if (!files || files.length === 0) return;
49
- setDisabled(true);
50
- try {
51
- if (multiple) {
52
- const result = [];
53
- for (const file of files) {
54
- result.push({
55
- result: await getFileData(file, type),
56
- file
57
- });
58
- }
59
- onChange?.(result);
60
- } else {
61
- onChange?.({
62
- result: await getFileData(files[0], type),
63
- file: files[0]
64
- });
65
- }
66
- setDisabled(false);
67
- input.value = "";
68
- } catch (error) {
69
- setDisabled(false);
70
- input.value = "";
71
- throw error;
72
- }
73
- }
74
- return /*#__PURE__*/React.createElement("input", _extends({
75
- disabled: disabled && inputDisabled,
76
- ref: ref,
77
- type: "file",
78
- multiple: multiple,
79
- onChange: onInputChange
80
- }, others));
81
- });
82
- /** 专门用于读取 excel 的组件 */
83
- export const ImportExcel = /*#__PURE__*/forwardRef((props, ref) => {
84
- const {
85
- onChange,
86
- ...others
87
- } = props;
88
- function onInputChange(data) {
89
- const wb = read(data.result);
90
- const result = utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
91
- if (typeof result === "object") {
92
- const $ = result.map(it => {
93
- const _ = {};
94
- Object.keys(it).filter(key => key !== "__rowNum__").forEach(key => _[key] = String(it[key]));
95
- return _;
96
- });
97
- onChange?.($);
98
- }
99
- }
100
- return /*#__PURE__*/React.createElement(InputFile, _extends({
101
- ref: ref,
102
- accept: ".xlsx",
103
- type: "arrayBuffer",
104
- onChange: onInputChange
105
- }, others));
106
- });
107
-
108
- /** 手动导出 excel */
109
- export function exportExcel(data, name) {
110
- const workSheet = utils.json_to_sheet(data);
111
- const workBook = utils.book_new();
112
- utils.book_append_sheet(workBook, workSheet);
113
- writeFile(workBook, `${name}${name.endsWith(".xlsx") ? "" : ".xlsx"}`);
114
- }
115
- /** 导出 excel 的 button 组件 */
116
- export const ExportExcel = /*#__PURE__*/forwardRef((props, ref) => {
117
- const {
118
- data,
119
- fileName,
120
- onClick,
121
- ...others
122
- } = props;
123
- function onButtonClick(e) {
124
- exportExcel(data, fileName);
125
- onClick?.(e);
126
- }
127
- return /*#__PURE__*/React.createElement("button", _extends({
128
- ref: ref,
129
- onClick: onButtonClick
130
- }, others));
131
- });
132
- /** 尺寸渐变的组件 */
133
- export const TransitionBox = props => {
134
- const {
135
- style,
136
- containerClassName,
137
- containerStyle,
138
- children,
139
- vertical = true,
140
- horizontal = true,
141
- time = 3000,
142
- ...others
143
- } = props;
144
- const box = useRef(null);
145
- const [width, setWidth] = useState(0);
146
- const [height, setHeight] = useState(0);
147
- const [count, setCount] = useState(0);
148
- useEffect(() => {
149
- const observer = new ResizeObserver(entries => {
150
- const {
151
- width: currentWidth,
152
- height: currentHeight
153
- } = entries[0].contentRect;
154
- setWidth(currentWidth);
155
- setHeight(currentHeight);
156
- });
157
- observer.observe(box.current);
158
- return () => {
159
- observer.disconnect();
160
- };
161
- }, []);
162
- useEffect(() => {
163
- setCount(count => Math.min(count + 1, 3));
164
- }, [width, height]);
165
- const outerStyle = {
166
- transitionProperty: count === 3 ? [horizontal && "width", vertical && "height"].filter(Boolean).join(", ") : undefined,
167
- transitionDuration: count === 3 ? `${time}ms` : undefined,
168
- width,
169
- height,
170
- overflow: "hidden",
171
- position: "relative",
172
- ...style
173
- };
174
- return /*#__PURE__*/React.createElement("div", _extends({
175
- style: outerStyle
176
- }, others), /*#__PURE__*/React.createElement("div", {
177
- className: containerClassName,
178
- style: {
179
- position: "absolute",
180
- ...containerStyle
181
- },
182
- ref: box
183
- }, children));
184
- };
185
- /** 雷达组件 */
186
- export const SeaRadar = props => {
187
- const {
188
- unitRadius = 50,
189
- circleCount = 4,
190
- circleWidth = 1,
191
- circleColor,
192
- directionCount = 36,
193
- directionWidth = 1,
194
- directionColor,
195
- backgroundColor,
196
- scanColor,
197
- scanAngle = Math.PI / 6,
198
- period = 8,
199
- targets,
200
- showGraduationLine,
201
- showGraduationText,
202
- showCircle,
203
- showDirection
204
- } = props;
205
- const style = {
206
- "--unit-radius": `${unitRadius}px`,
207
- "--circle-count": circleCount,
208
- "--circle-width": `${circleWidth}px`,
209
- "--circle-color": circleColor,
210
- "--direction-count": directionCount,
211
- "--direction-width": `${directionWidth}px`,
212
- "--direction-color": directionColor,
213
- "--background-color": backgroundColor,
214
- "--scan-color": scanColor,
215
- "--period": `${period}s`
216
- };
217
- return /*#__PURE__*/React.createElement("div", {
218
- className: "sea-radar-wrapper",
219
- style: style
220
- }, Array(180).fill(0).map((_, index) => /*#__PURE__*/React.createElement("div", {
221
- className: "sea-radar-little-graduation",
222
- style: {
223
- transform: `rotateZ(${2 * index}deg)`,
224
- display: showGraduationLine ? "block" : "none"
225
- }
226
- })), Array(36).fill(0).map((_, index) => /*#__PURE__*/React.createElement("div", {
227
- className: "sea-radar-graduation",
228
- style: {
229
- transform: `rotateZ(${10 * index}deg)`,
230
- display: showGraduationLine ? "block" : "none"
231
- }
232
- }, /*#__PURE__*/React.createElement("span", {
233
- className: "sea-radar-graduation-text",
234
- style: {
235
- display: showGraduationText ? "block" : "none"
236
- }
237
- }, String(index * 10).padStart(3, "0")))), /*#__PURE__*/React.createElement("div", {
238
- className: "sea-radar"
239
- }, /*#__PURE__*/React.createElement("div", {
240
- className: "sea-radar-scan",
241
- style: {
242
- height: `${unitRadius * circleCount * Math.tan(scanAngle)}px`,
243
- clipPath: `polygon(0 0, 0 100%, 100% 100%)`
244
- }
245
- }), showCircle && Array(circleCount).fill(0).map((_, index) => /*#__PURE__*/React.createElement("div", {
246
- className: "sea-radar-circle",
247
- style: {
248
- width: `${unitRadius * 2 * (index + 1)}px`,
249
- height: `${unitRadius * 2 * (index + 1)}px`
250
- }
251
- })), showDirection && Array(directionCount).fill(0).map((_, index) => /*#__PURE__*/React.createElement("div", {
252
- className: "sea-radar-direction",
253
- style: {
254
- transform: `rotateZ(${360 / directionCount * index}deg)`
255
- }
256
- })), targets?.map(it => /*#__PURE__*/React.createElement("div", {
257
- className: "sea-radar-target",
258
- style: {
259
- left: `${unitRadius * circleCount + it.radius * Math.cos(it.angle)}px`,
260
- bottom: `${unitRadius * circleCount + it.radius * Math.sin(it.angle)}px`
261
- }
262
- }, it.element))));
263
- };
264
- /** 忘了什么组件 */
265
- export const Ring = props => {
266
- const {
267
- outerWidth,
268
- innerWidth,
269
- style,
270
- ...leftProps
271
- } = props;
272
- const outerRadius = outerWidth / 2;
273
- const innerRadius = innerWidth / 2;
274
- return /*#__PURE__*/React.createElement("div", _extends({
275
- style: {
276
- ...style,
277
- width: `${outerWidth}px`,
278
- height: `${outerWidth}px`,
279
- 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")`
280
- }
281
- }, leftProps));
282
- };
283
- export function getGapRange(gap) {
284
- if (typeof gap === "number") return [gap, gap];
285
- if (Array.isArray(gap)) return [gap[0] || 0, gap[1]];
286
- return [0, null];
287
- }
288
- export function getGapCountAndSize(width, itemWidth, minGap, maxGap) {
289
- const count = Math.floor((width + minGap) / (itemWidth + minGap)) || 1;
290
- if (count === 1) return [count, 0];
291
- const averageGap = (width - itemWidth * count) / (count - 1);
292
- if (averageGap < minGap) return [count, minGap];
293
- if (maxGap !== null && averageGap > maxGap) return [count, maxGap];
294
- return [count, averageGap];
295
- }
296
-
297
- /** 自适应浮动组件 */
298
- export function Flow(props) {
299
- const {
300
- itemWidth,
301
- itemHeight,
302
- columnGap,
303
- rowGap = 0,
304
- maxRows,
305
- data,
306
- render,
307
- keyExactor,
308
- className,
309
- style,
310
- containerClassName,
311
- containerStyle,
312
- throttle,
313
- transitionDuration,
314
- onSizeChange,
315
- ...others
316
- } = props;
317
- const [minColumnGap, maxColumnGap] = getGapRange(columnGap);
318
- const [width, setWidth] = useState(0);
319
- const [columnCount, setColumnCount] = useState(1);
320
- const [columnGapSize, setColumnGapSize] = useState(minColumnGap);
321
- const [showItems, setShowItems] = useState(false);
322
- const ele = useRef(null);
323
- const contentRows = Math.ceil(data.length / columnCount);
324
- const contentShownRows = typeof maxRows === "number" ? Math.min(contentRows, maxRows) : contentRows;
325
- const height = contentShownRows > 0 ? contentShownRows * (itemHeight + rowGap) - rowGap : 0;
326
- function getPosition(index) {
327
- const y = Math.floor(index / columnCount);
328
- const x = index - y * columnCount;
329
- return {
330
- left: x * (itemWidth + columnGapSize),
331
- top: y * (itemHeight + rowGap)
332
- };
333
- }
334
- function getHidden(index) {
335
- if (typeof maxRows !== "number") return false;
336
- return index >= maxRows * columnCount;
337
- }
338
- useEffect(() => {
339
- let timeout;
340
- const observer = new ResizeObserver(entries => {
341
- clearTimeout(timeout);
342
- function task() {
343
- const {
344
- inlineSize: width
345
- } = entries[0].borderBoxSize[0];
346
- const [newColumnCount, newColumnGapSize] = getGapCountAndSize(width, itemWidth, minColumnGap, maxColumnGap);
347
- setShowItems(true);
348
- setWidth(width);
349
- setColumnCount(newColumnCount);
350
- setColumnGapSize(newColumnGapSize);
351
- }
352
- if (throttle === null) {
353
- task();
354
- } else {
355
- timeout = window.setTimeout(task, throttle || 200);
356
- }
357
- });
358
- observer.observe(ele.current);
359
- return () => {
360
- observer.disconnect();
361
- };
362
- }, [itemWidth, throttle, columnGap]);
363
- useEffect(() => {
364
- onSizeChange?.({
365
- width,
366
- height,
367
- itemWidth,
368
- itemHeight,
369
- columnGap: columnGapSize,
370
- columnCount,
371
- rowGap,
372
- rowCount: contentShownRows,
373
- overflow: data.length > contentShownRows * columnCount,
374
- itemCount: data.length,
375
- maxRows: maxRows ?? null
376
- });
377
- }, [width, height, columnGapSize, columnCount, rowGap, contentShownRows, data.length, itemWidth, itemHeight, maxRows]);
378
- return /*#__PURE__*/React.createElement("div", _extends({
379
- ref: ele,
380
- className: className,
381
- style: {
382
- position: "relative",
383
- boxSizing: "border-box",
384
- height,
385
- ...style
386
- }
387
- }, others), showItems && data.map((it, idx) => /*#__PURE__*/React.createElement("div", {
388
- key: keyExactor?.(it, idx) || idx,
389
- className: containerClassName,
390
- style: {
391
- position: "absolute",
392
- width: itemWidth,
393
- height: itemHeight,
394
- transition: transitionDuration !== null ? `all ${transitionDuration ?? 400}ms` : undefined,
395
- ...getPosition(idx)
396
- }
397
- }, /*#__PURE__*/React.createElement("div", {
398
- style: {
399
- width: itemWidth,
400
- height: itemHeight,
401
- display: maxRows && idx >= maxRows * columnCount ? "none" : "block",
402
- ...containerStyle
403
- }
404
- }, render(it, idx, getHidden(idx))))));
405
- }
406
- /** 梯形组件 */
407
- export const Trapezium = /*#__PURE__*/forwardRef((props, ref) => {
408
- const {
409
- top,
410
- bottom,
411
- height,
412
- borderRadius,
413
- style,
414
- ...other
415
- } = props;
416
- const diff = (bottom - top) / 2;
417
- const a = Math.atan(height / diff) / 2;
418
- const b = borderRadius / Math.tan(a);
419
- const c = b * Math.cos(a * 2);
420
- const d = b * Math.sin(a * 2);
421
- const e = Math.PI / 2 - a;
422
- const f = borderRadius / Math.tan(e);
423
- const g = f * Math.cos(a * 2);
424
- const h = f * Math.sin(a * 2);
425
- return /*#__PURE__*/React.createElement("div", _extends({
426
- ref: ref,
427
- style: {
428
- width: bottom,
429
- height,
430
- 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")`,
431
- ...style
432
- }
433
- }, other));
434
- });
435
- /** 循环播放组件 */
436
- export function LoopSwiper(props) {
437
- const {
438
- data,
439
- render,
440
- keyExactor,
441
- size,
442
- gap = 0,
443
- start = 0,
444
- speed,
445
- paused = false,
446
- className = "",
447
- direction = "x"
448
- } = props;
449
- if (!(size > 0 && (speed > 0 || speed < 0))) {
450
- throw new RangeError("size 必须是正数,speed 必须非0");
451
- }
452
- const keys = data.map((it, idx, arr) => keyExactor ? keyExactor(it, idx, arr) : String(idx));
453
- const keysRef = useRef(keys);
454
- const cache = useRef({
455
- size,
456
- gap,
457
- speed,
458
- keys,
459
- paused,
460
- className,
461
- direction
462
- });
463
- cache.current = {
464
- size,
465
- gap,
466
- speed,
467
- keys,
468
- paused,
469
- className,
470
- direction
471
- };
472
- const eles = useRef(keys.map((key, idx) => ({
473
- key,
474
- dom: null,
475
- offset: idx * (size + gap) + start
476
- })));
477
- if (keysRef.current.length !== keys.length || keysRef.current.some((it, idx) => it !== keys[idx])) {
478
- keysRef.current = keys;
479
- eles.current = keys.map((key, idx) => ({
480
- key,
481
- dom: null,
482
- offset: idx * (size + gap) + start
483
- }));
484
- }
485
- function setStyles() {
486
- const {
487
- size,
488
- speed,
489
- className,
490
- direction
491
- } = cache.current;
492
- eles.current.forEach(it => {
493
- it.dom.className = className;
494
- it.dom.style.setProperty("position", `absolute`);
495
- it.dom.style.setProperty("width", `${size}px`);
496
- direction === "x" && speed < 0 ? it.dom.style.setProperty("right", `0`) : it.dom.style.setProperty("left", `0`);
497
- direction === "y" && speed < 0 ? it.dom.style.setProperty("bottom", `0`) : it.dom.style.setProperty("top", `0`);
498
- it.dom.style.setProperty("transform", `translate${direction.toUpperCase()}(${it.offset * (speed > 0 ? 1 : -1)}px)`);
499
- });
500
- }
501
- useEffect(() => {
502
- setStyles();
503
- }, []);
504
- useEffect(() => {
505
- const stop = setFrameInterval(() => {
506
- const {
507
- size,
508
- gap,
509
- speed,
510
- keys,
511
- paused
512
- } = cache.current;
513
- if (paused) return;
514
- eles.current.length = keys.length;
515
- let minIndex = 0;
516
- eles.current.forEach((it, idx) => {
517
- if (it.offset < eles.current[minIndex].offset) {
518
- minIndex = idx;
519
- }
520
- });
521
- const minOffset = eles.current[minIndex].offset;
522
- eles.current.forEach((it, idx) => {
523
- let index = idx;
524
- if (idx < minIndex) index = eles.current.length + idx;
525
- it.offset = minOffset + (index - minIndex) * (size + gap);
526
- let newOffset = it.offset - Math.abs(speed);
527
- if (newOffset + size + gap <= 0) {
528
- newOffset += eles.current.length * (size + gap);
529
- }
530
- it.offset = newOffset;
531
- });
532
- setStyles();
533
- }, 1);
534
- return stop;
535
- }, []);
536
- function ref(dom, index) {
537
- if (!eles.current[index]) return;
538
- eles.current[index].dom = dom;
539
- }
540
- return /*#__PURE__*/React.createElement(Fragment, null, data.map((it, idx, arr) => /*#__PURE__*/React.createElement("div", {
541
- key: keys[idx],
542
- ref: dom => ref(dom, idx)
543
- }, render(it, idx, arr))));
544
- }
545
- export const SectionRing = props => {
546
- const {
547
- outerRadius: o,
548
- innerRadius: i,
549
- count: c,
550
- angel: a,
551
- style,
552
- ...others
553
- } = props;
554
- const s = Math.PI * 2 / c - a;
555
- function arc(radius, startAngle, endAngle, options = {}) {
556
- return drawArc(o, o, radius, startAngle, endAngle, options);
557
- }
558
- return /*#__PURE__*/React.createElement("div", _extends({
559
- style: {
560
- ...style,
561
- width: o * 2,
562
- height: o * 2,
563
- 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), {
564
- line: true,
565
- anticlockwise: true
566
- })}`).join(" ")} Z")`
567
- }
568
- }, others));
569
- };
570
- /** 渐变数字组件 */
571
- export const TransitionNum = /*#__PURE__*/forwardRef((props, ref) => {
572
- const {
573
- children: num,
574
- period,
575
- numToStr,
576
- ...others
577
- } = props;
578
- if (!Number.isInteger(num) || !Number.isInteger(period) || period <= 0) {
579
- throw new RangeError("目标数字必须是整数,周期必须是正整数");
580
- }
581
- const ele = useRef(null);
582
- const cache = useRef({
583
- num,
584
- period,
585
- numToStr,
586
- show: num
587
- });
588
- cache.current = {
589
- ...cache.current,
590
- num,
591
- period,
592
- numToStr
593
- };
594
- useImperativeHandle(ref, () => ({
595
- get: () => cache.current.show
596
- }), []);
597
- useEffect(() => {
598
- const {
599
- num,
600
- period,
601
- show,
602
- numToStr
603
- } = cache.current;
604
- ele.current.innerText = (numToStr || String)(show);
605
- if (num === show) return;
606
- const div = ele.current;
607
- const speed = (num - show) / period;
608
- const cancel = setFrameInterval(() => {
609
- const {
610
- num,
611
- numToStr
612
- } = cache.current;
613
- cache.current.show += speed;
614
- if (speed > 0 && cache.current.show > num || speed < 0 && cache.current.show < num) {
615
- cancel();
616
- cache.current.show = num;
617
- }
618
- div.innerText = (numToStr || String)(speed > 0 ? Math.floor(cache.current.show) : Math.ceil(cache.current.show));
619
- }, 1);
620
- return cancel;
621
- }, [num]);
622
- return /*#__PURE__*/React.createElement("div", _extends({
623
- ref: ele
624
- }, others));
625
- });
626
- /** 环形文字 */
627
- export const CircleText = props => {
628
- const {
629
- width,
630
- height,
631
- radius,
632
- startAngel = 0,
633
- gapAngel = 0,
634
- align = "center",
635
- style,
636
- direction = "outer",
637
- reverse = false,
638
- separator,
639
- children,
640
- ...others
641
- } = props;
642
- const unitAngle = Math.atan(width / 2 / radius) * 2;
643
- const totalAngle = (unitAngle + gapAngel) * children.length - gapAngel;
644
- const offsetAngle = align === "left" ? 0 : align === "right" ? totalAngle : totalAngle / 2;
645
- function getTransform(idx) {
646
- const angle = startAngel - idx * (unitAngle + gapAngel) + offsetAngle - unitAngle / 2;
647
- const x = (radius + height / 2) * Math.cos(angle) - width / 2;
648
- const y = (radius + height / 2) * Math.sin(angle) * -1 - height / 2;
649
- const z = Math.PI / 2 - angle + (direction === "inner" ? Math.PI : 0);
650
- return `translateX(${x}px) translateY(${y}px) rotateZ(${z / Math.PI * 180}deg)`;
651
- }
652
- const words = typeof separator === "function" ? separator(children) : children.split(separator ?? "");
653
- if (reverse) words.reverse();
654
- return /*#__PURE__*/React.createElement(Fragment, null, words.map((w, idx) => /*#__PURE__*/React.createElement("span", _extends({
655
- key: idx,
656
- style: {
657
- position: "absolute",
658
- ...style,
659
- transform: getTransform(idx),
660
- textAlign: "center",
661
- width,
662
- lineHeight: `${height}px`,
663
- height: height
664
- }
665
- }, others), w)));
666
- };
667
- /**
668
- * 滚动条组件
669
- * @description 注意 children 不是直接渲染在组件上的,而是渲染在内部的容器上
670
- */
671
- export const Scroll = /*#__PURE__*/forwardRef((props, ref) => {
672
- const {
673
- children,
674
- containerClassName,
675
- containerStyle,
676
- options,
677
- className,
678
- ...others
679
- } = props;
680
- const {
681
- thumbWidth,
682
- ...scrollbarOptions
683
- } = options || {};
684
- const id = useId();
685
- useEffect(() => {
686
- SmoothScrollBar.init(document.querySelector(`[data-scroll-id="${id}"]`), scrollbarOptions);
687
- }, []);
688
- return /*#__PURE__*/React.createElement("div", _extends({
689
- ref: ref,
690
- className: clsx(!!thumbWidth && css`
691
- .scrollbar-track.scrollbar-track-x {
692
- height: ${thumbWidth}px;
693
- }
694
-
695
- .scrollbar-thumb.scrollbar-thumb-x {
696
- height: ${thumbWidth}px;
697
- }
698
-
699
- .scrollbar-track.scrollbar-track-y {
700
- width: ${thumbWidth}px;
701
- }
702
-
703
- .scrollbar-thumb.scrollbar-thumb-y {
704
- width: ${thumbWidth}px;
705
- }
706
- `, className),
707
- "data-scroll-id": id
708
- }, others), /*#__PURE__*/React.createElement("div", {
709
- className: containerClassName,
710
- style: containerStyle
711
- }, children));
712
- });
713
- export const X = /*#__PURE__*/forwardRef((props, ref) => {
714
- const {
715
- className,
716
- ...others
717
- } = props;
718
- return /*#__PURE__*/React.createElement("div", _extends({
719
- ref: ref,
720
- className: clsx(css`
721
- display: flex;
722
- `, className)
723
- }, others));
724
- });
725
- export const Y = /*#__PURE__*/forwardRef((props, ref) => {
726
- const {
727
- className,
728
- ...others
729
- } = props;
730
- return /*#__PURE__*/React.createElement("div", _extends({
731
- ref: ref,
732
- className: clsx(css`
733
- display: flex;
734
- flex-direction: column;
735
- `, className)
736
- }, others));
737
- });
738
- export const Auto = /*#__PURE__*/forwardRef((props, ref) => {
739
- const {
740
- className,
741
- ...others
742
- } = props;
743
- return /*#__PURE__*/React.createElement("div", _extends({
744
- ref: ref,
745
- className: clsx(css`
746
- flex: auto;
747
- `, className)
748
- }, others));
749
- });
750
- export const None = /*#__PURE__*/forwardRef((props, ref) => {
751
- const {
752
- className,
753
- ...others
754
- } = props;
755
- return /*#__PURE__*/React.createElement("div", _extends({
756
- ref: ref,
757
- className: clsx(css`
758
- flex: none;
759
- `, className)
760
- }, others));
761
- });
762
- export const XAuto = /*#__PURE__*/forwardRef((props, ref) => {
763
- const {
764
- className,
765
- ...others
766
- } = props;
767
- return /*#__PURE__*/React.createElement("div", _extends({
768
- ref: ref,
769
- className: clsx(css`
770
- display: flex;
771
- flex: auto;
772
- `, className)
773
- }, others));
774
- });
775
- export const YAuto = /*#__PURE__*/forwardRef((props, ref) => {
776
- const {
777
- className,
778
- ...others
779
- } = props;
780
- return /*#__PURE__*/React.createElement("div", _extends({
781
- ref: ref,
782
- className: clsx(css`
783
- display: flex;
784
- flex-direction: column;
785
- flex: auto;
786
- `, className)
787
- }, others));
788
- });
789
- export const XNone = /*#__PURE__*/forwardRef((props, ref) => {
790
- const {
791
- className,
792
- ...others
793
- } = props;
794
- return /*#__PURE__*/React.createElement("div", _extends({
795
- ref: ref,
796
- className: clsx(css`
797
- display: flex;
798
- flex: none;
799
- `, className)
800
- }, others));
801
- });
802
- export const YNone = /*#__PURE__*/forwardRef((props, ref) => {
803
- const {
804
- className,
805
- ...others
806
- } = props;
807
- return /*#__PURE__*/React.createElement("div", _extends({
808
- ref: ref,
809
- className: clsx(css`
810
- display: flex;
811
- flex-direction: column;
812
- flex: none;
813
- `, className)
814
- }, others));
815
- });
816
- //# sourceMappingURL=index.js.map