@sunggang/ui-lib 0.4.30 → 0.4.31
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/Accordion.cjs.d.ts +1 -0
- package/Accordion.cjs.default.js +1 -0
- package/Accordion.cjs.js +223 -0
- package/Accordion.cjs.mjs +2 -0
- package/Accordion.esm.d.ts +1 -0
- package/Accordion.esm.js +216 -0
- package/Carousel.cjs.d.ts +1 -0
- package/Carousel.cjs.default.js +1 -0
- package/Carousel.cjs.js +177 -0
- package/Carousel.cjs.mjs +2 -0
- package/Carousel.esm.d.ts +1 -0
- package/Carousel.esm.js +153 -0
- package/DataTable.cjs.js +4 -3
- package/DataTable.esm.js +2 -1
- package/Skeleton.cjs.d.ts +1 -0
- package/Skeleton.cjs.default.js +1 -0
- package/Skeleton.cjs.js +169 -0
- package/Skeleton.cjs.mjs +2 -0
- package/Skeleton.esm.d.ts +1 -0
- package/Skeleton.esm.js +162 -0
- package/accordion.cjs2.js +161 -0
- package/accordion.esm2.js +135 -0
- package/button.cjs.js +175 -0
- package/button.esm.js +152 -0
- package/carousel.cjs2.js +342 -0
- package/carousel.esm2.js +313 -0
- package/index.cjs.css +311 -0
- package/index.cjs.js +23 -7
- package/index.esm.css +311 -0
- package/index.esm.js +8 -2
- package/input.cjs.js +0 -149
- package/input.esm.js +2 -149
- package/package.json +18 -1
- package/skeleton.cjs2.js +70 -0
- package/skeleton.esm2.js +68 -0
- package/src/Accordion.d.ts +1 -0
- package/src/Carousel.d.ts +1 -0
- package/src/Skeleton.d.ts +1 -0
- package/src/components/ui/accordion.d.ts +7 -0
- package/src/components/ui/carousel.d.ts +18 -0
- package/src/components/ui/skeleton.d.ts +2 -0
- package/src/index.d.ts +3 -0
- package/src/lib/Accordion/index.d.ts +79 -0
- package/src/lib/Carousel/index.d.ts +35 -0
- package/src/lib/Skeleton/index.d.ts +55 -0
package/Carousel.esm.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { C as Carousel, a as CarouselContent, b as CarouselItem, c as CarouselPrevious, d as CarouselNext } from './carousel.esm2.js';
|
|
4
|
+
import { c as cn } from './utils.esm.js';
|
|
5
|
+
import 'embla-carousel-react';
|
|
6
|
+
import 'lucide-react';
|
|
7
|
+
import './button.esm.js';
|
|
8
|
+
import '@radix-ui/react-slot';
|
|
9
|
+
import 'class-variance-authority';
|
|
10
|
+
import 'clsx';
|
|
11
|
+
import 'tailwind-merge';
|
|
12
|
+
|
|
13
|
+
function _array_like_to_array(arr, len) {
|
|
14
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
15
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
16
|
+
return arr2;
|
|
17
|
+
}
|
|
18
|
+
function _array_with_holes(arr) {
|
|
19
|
+
if (Array.isArray(arr)) return arr;
|
|
20
|
+
}
|
|
21
|
+
function _iterable_to_array_limit(arr, i) {
|
|
22
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
23
|
+
if (_i == null) return;
|
|
24
|
+
var _arr = [];
|
|
25
|
+
var _n = true;
|
|
26
|
+
var _d = false;
|
|
27
|
+
var _s, _e;
|
|
28
|
+
try {
|
|
29
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
30
|
+
_arr.push(_s.value);
|
|
31
|
+
if (i && _arr.length === i) break;
|
|
32
|
+
}
|
|
33
|
+
} catch (err) {
|
|
34
|
+
_d = true;
|
|
35
|
+
_e = err;
|
|
36
|
+
} finally{
|
|
37
|
+
try {
|
|
38
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
39
|
+
} finally{
|
|
40
|
+
if (_d) throw _e;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return _arr;
|
|
44
|
+
}
|
|
45
|
+
function _non_iterable_rest() {
|
|
46
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
47
|
+
}
|
|
48
|
+
function _sliced_to_array(arr, i) {
|
|
49
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
50
|
+
}
|
|
51
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
52
|
+
if (!o) return;
|
|
53
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
54
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
55
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
56
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
57
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
58
|
+
}
|
|
59
|
+
var BaseCarousel = function(param) {
|
|
60
|
+
var items = param.items, _param_showNavigation = param.showNavigation, showNavigation = _param_showNavigation === void 0 ? true : _param_showNavigation, _param_showIndicators = param.showIndicators, showIndicators = _param_showIndicators === void 0 ? true : _param_showIndicators, autoPlay = param.autoPlay, _param_orientation = param.orientation, orientation = _param_orientation === void 0 ? "horizontal" : _param_orientation, _param_itemsPerView = param.itemsPerView, itemsPerView = _param_itemsPerView === void 0 ? 1 : _param_itemsPerView, _param_gap = param.gap, gap = _param_gap === void 0 ? "1rem" : _param_gap, className = param.className, itemClassName = param.itemClassName, navigationClassName = param.navigationClassName, indicatorClassName = param.indicatorClassName, onSlideChange = param.onSlideChange, onReady = param.onReady;
|
|
61
|
+
var _React_useState = _sliced_to_array(React.useState(), 2), api = _React_useState[0], setApi = _React_useState[1];
|
|
62
|
+
var _React_useState1 = _sliced_to_array(React.useState(0), 2), current = _React_useState1[0], setCurrent = _React_useState1[1];
|
|
63
|
+
var _React_useState2 = _sliced_to_array(React.useState(0), 2), count = _React_useState2[0], setCount = _React_useState2[1];
|
|
64
|
+
React.useEffect(function() {
|
|
65
|
+
if (!api) return;
|
|
66
|
+
setCount(api.scrollSnapList().length);
|
|
67
|
+
setCurrent(api.selectedScrollSnap() + 1);
|
|
68
|
+
api.on("select", function() {
|
|
69
|
+
var selectedIndex = api.selectedScrollSnap();
|
|
70
|
+
setCurrent(selectedIndex + 1);
|
|
71
|
+
onSlideChange === null || onSlideChange === void 0 ? void 0 : onSlideChange(selectedIndex);
|
|
72
|
+
});
|
|
73
|
+
onReady === null || onReady === void 0 ? void 0 : onReady(api);
|
|
74
|
+
}, [
|
|
75
|
+
api,
|
|
76
|
+
onSlideChange,
|
|
77
|
+
onReady
|
|
78
|
+
]);
|
|
79
|
+
React.useEffect(function() {
|
|
80
|
+
if (!api || !autoPlay) return;
|
|
81
|
+
var interval = setInterval(function() {
|
|
82
|
+
if (api.canScrollNext()) {
|
|
83
|
+
api.scrollNext();
|
|
84
|
+
} else {
|
|
85
|
+
api.scrollTo(0);
|
|
86
|
+
}
|
|
87
|
+
}, autoPlay);
|
|
88
|
+
return function() {
|
|
89
|
+
return clearInterval(interval);
|
|
90
|
+
};
|
|
91
|
+
}, [
|
|
92
|
+
api,
|
|
93
|
+
autoPlay
|
|
94
|
+
]);
|
|
95
|
+
var basisClass = itemsPerView === 1 ? "basis-full" : itemsPerView === 2 ? "basis-1/2" : itemsPerView === 3 ? "basis-1/3" : itemsPerView === 4 ? "basis-1/4" : "basis-1/".concat(itemsPerView);
|
|
96
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
97
|
+
className: cn("relative w-full", className),
|
|
98
|
+
children: [
|
|
99
|
+
/*#__PURE__*/ jsxs(Carousel, {
|
|
100
|
+
setApi: setApi,
|
|
101
|
+
orientation: orientation,
|
|
102
|
+
opts: {
|
|
103
|
+
align: "start",
|
|
104
|
+
loop: true
|
|
105
|
+
},
|
|
106
|
+
className: "w-full",
|
|
107
|
+
children: [
|
|
108
|
+
/*#__PURE__*/ jsx(CarouselContent, {
|
|
109
|
+
className: cn("-ml-1", orientation === "vertical" && "-mt-1 flex-col"),
|
|
110
|
+
style: {
|
|
111
|
+
gap: gap
|
|
112
|
+
},
|
|
113
|
+
children: items.map(function(item, index) {
|
|
114
|
+
return /*#__PURE__*/ jsx(CarouselItem, {
|
|
115
|
+
className: cn("pl-1", basisClass, orientation === "vertical" && "pt-1", itemClassName),
|
|
116
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
117
|
+
className: "p-1",
|
|
118
|
+
children: item.content
|
|
119
|
+
})
|
|
120
|
+
}, item.id);
|
|
121
|
+
})
|
|
122
|
+
}),
|
|
123
|
+
showNavigation && /*#__PURE__*/ jsxs(Fragment, {
|
|
124
|
+
children: [
|
|
125
|
+
/*#__PURE__*/ jsx(CarouselPrevious, {
|
|
126
|
+
className: cn(navigationClassName)
|
|
127
|
+
}),
|
|
128
|
+
/*#__PURE__*/ jsx(CarouselNext, {
|
|
129
|
+
className: cn(navigationClassName)
|
|
130
|
+
})
|
|
131
|
+
]
|
|
132
|
+
})
|
|
133
|
+
]
|
|
134
|
+
}),
|
|
135
|
+
showIndicators && /*#__PURE__*/ jsx("div", {
|
|
136
|
+
className: "flex justify-center mt-4 space-x-2",
|
|
137
|
+
children: Array.from({
|
|
138
|
+
length: count
|
|
139
|
+
}, function(_, index) {
|
|
140
|
+
return /*#__PURE__*/ jsx("button", {
|
|
141
|
+
className: cn("h-2 w-2 rounded-full transition-all", current === index + 1 ? "bg-primary scale-125" : "bg-primary/30 hover:bg-primary/60", indicatorClassName),
|
|
142
|
+
onClick: function() {
|
|
143
|
+
return api === null || api === void 0 ? void 0 : api.scrollTo(index);
|
|
144
|
+
},
|
|
145
|
+
"aria-label": "前往第 ".concat(index + 1, " 張投影片")
|
|
146
|
+
}, index);
|
|
147
|
+
})
|
|
148
|
+
})
|
|
149
|
+
]
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export { BaseCarousel };
|
package/DataTable.cjs.js
CHANGED
|
@@ -6,10 +6,11 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var reactTable = require('@tanstack/react-table');
|
|
8
8
|
var lucideReact = require('lucide-react');
|
|
9
|
-
var
|
|
9
|
+
var button = require('./button.cjs.js');
|
|
10
10
|
var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
|
|
11
11
|
var reactIcons = require('@radix-ui/react-icons');
|
|
12
12
|
var utils = require('./utils.cjs.js');
|
|
13
|
+
var input = require('./input.cjs.js');
|
|
13
14
|
require('@radix-ui/react-slot');
|
|
14
15
|
require('class-variance-authority');
|
|
15
16
|
require('clsx');
|
|
@@ -579,7 +580,7 @@ var DataTable = function(param) {
|
|
|
579
580
|
children: [
|
|
580
581
|
/*#__PURE__*/ jsxRuntime.jsx(DropdownMenuTrigger, {
|
|
581
582
|
asChild: true,
|
|
582
|
-
children: /*#__PURE__*/ jsxRuntime.jsxs(
|
|
583
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(button.Button, {
|
|
583
584
|
variant: "outline",
|
|
584
585
|
className: "ml-auto",
|
|
585
586
|
children: [
|
|
@@ -883,7 +884,7 @@ var BaseTable = function(param) {
|
|
|
883
884
|
children: [
|
|
884
885
|
/*#__PURE__*/ jsxRuntime.jsx(DropdownMenuTrigger, {
|
|
885
886
|
asChild: true,
|
|
886
|
-
children: /*#__PURE__*/ jsxRuntime.jsxs(
|
|
887
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(button.Button, {
|
|
887
888
|
variant: "outline",
|
|
888
889
|
className: "ml-auto",
|
|
889
890
|
children: [
|
package/DataTable.esm.js
CHANGED
|
@@ -3,10 +3,11 @@ import * as React from 'react';
|
|
|
3
3
|
import { useState, useEffect } from 'react';
|
|
4
4
|
import { useReactTable, getCoreRowModel, getPaginationRowModel, getSortedRowModel, getFilteredRowModel, flexRender } from '@tanstack/react-table';
|
|
5
5
|
import { ChevronDown } from 'lucide-react';
|
|
6
|
-
import {
|
|
6
|
+
import { B as Button } from './button.esm.js';
|
|
7
7
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
8
8
|
import { ChevronRightIcon, CheckIcon, DotFilledIcon } from '@radix-ui/react-icons';
|
|
9
9
|
import { c as cn } from './utils.esm.js';
|
|
10
|
+
import { I as Input } from './input.esm.js';
|
|
10
11
|
import '@radix-ui/react-slot';
|
|
11
12
|
import 'class-variance-authority';
|
|
12
13
|
import 'clsx';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/Skeleton";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./Skeleton.cjs.js').default;
|
package/Skeleton.cjs.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
require('react');
|
|
7
|
+
var skeleton = require('./skeleton.cjs2.js');
|
|
8
|
+
var utils = require('./utils.cjs.js');
|
|
9
|
+
require('clsx');
|
|
10
|
+
require('tailwind-merge');
|
|
11
|
+
|
|
12
|
+
var BaseSkeleton = function(param) {
|
|
13
|
+
var _param_variant = param.variant, variant = _param_variant === void 0 ? "default" : _param_variant, width = param.width, height = param.height, _param_animate = param.animate, animate = _param_animate === void 0 ? true : _param_animate, className = param.className, _param_count = param.count, count = _param_count === void 0 ? 1 : _param_count, _param_spacing = param.spacing, spacing = _param_spacing === void 0 ? "0.5rem" : _param_spacing;
|
|
14
|
+
var getVariantStyles = function() {
|
|
15
|
+
switch(variant){
|
|
16
|
+
case "text":
|
|
17
|
+
return "h-4 w-full rounded-sm";
|
|
18
|
+
case "circular":
|
|
19
|
+
return "rounded-full aspect-square";
|
|
20
|
+
case "rectangular":
|
|
21
|
+
return "rounded-sm";
|
|
22
|
+
default:
|
|
23
|
+
return "rounded-md";
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var skeletonStyle = {
|
|
27
|
+
width: typeof width === "number" ? "".concat(width, "px") : width,
|
|
28
|
+
height: typeof height === "number" ? "".concat(height, "px") : height
|
|
29
|
+
};
|
|
30
|
+
var skeletonClasses = utils.cn(getVariantStyles(), !animate && "animate-none", className);
|
|
31
|
+
if (count === 1) {
|
|
32
|
+
return /*#__PURE__*/ jsxRuntime.jsx(skeleton.Skeleton, {
|
|
33
|
+
className: skeletonClasses,
|
|
34
|
+
style: skeletonStyle
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
38
|
+
className: "space-y-2",
|
|
39
|
+
style: {
|
|
40
|
+
gap: spacing
|
|
41
|
+
},
|
|
42
|
+
children: Array.from({
|
|
43
|
+
length: count
|
|
44
|
+
}, function(_, index) {
|
|
45
|
+
return /*#__PURE__*/ jsxRuntime.jsx(skeleton.Skeleton, {
|
|
46
|
+
className: skeletonClasses,
|
|
47
|
+
style: skeletonStyle
|
|
48
|
+
}, index);
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
var AvatarSkeleton = function(param) {
|
|
53
|
+
var _param_size = param.size, size = _param_size === void 0 ? "md" : _param_size, _param_showText = param.showText, showText = _param_showText === void 0 ? true : _param_showText, _param_textLines = param.textLines, textLines = _param_textLines === void 0 ? 2 : _param_textLines, className = param.className;
|
|
54
|
+
var sizeClasses = {
|
|
55
|
+
sm: "h-8 w-8",
|
|
56
|
+
md: "h-12 w-12",
|
|
57
|
+
lg: "h-16 w-16",
|
|
58
|
+
xl: "h-20 w-20"
|
|
59
|
+
};
|
|
60
|
+
return /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
61
|
+
className: utils.cn("flex items-center space-x-4", className),
|
|
62
|
+
children: [
|
|
63
|
+
/*#__PURE__*/ jsxRuntime.jsx(skeleton.Skeleton, {
|
|
64
|
+
className: utils.cn("rounded-full", sizeClasses[size])
|
|
65
|
+
}),
|
|
66
|
+
showText && /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
67
|
+
className: "space-y-2 flex-1",
|
|
68
|
+
children: Array.from({
|
|
69
|
+
length: textLines
|
|
70
|
+
}, function(_, index) {
|
|
71
|
+
return /*#__PURE__*/ jsxRuntime.jsx(skeleton.Skeleton, {
|
|
72
|
+
className: utils.cn("h-4 rounded", index === textLines - 1 ? "w-3/4" : "w-full")
|
|
73
|
+
}, index);
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
]
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
var CardSkeleton = function(param) {
|
|
80
|
+
var _param_showImage = param.showImage, showImage = _param_showImage === void 0 ? true : _param_showImage, _param_imageHeight = param.imageHeight, imageHeight = _param_imageHeight === void 0 ? "200px" : _param_imageHeight, _param_titleLines = param.titleLines, titleLines = _param_titleLines === void 0 ? 1 : _param_titleLines, _param_contentLines = param.contentLines, contentLines = _param_contentLines === void 0 ? 3 : _param_contentLines, _param_showActions = param.showActions, showActions = _param_showActions === void 0 ? true : _param_showActions, className = param.className;
|
|
81
|
+
return /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
82
|
+
className: utils.cn("border rounded-lg p-4 space-y-4", className),
|
|
83
|
+
children: [
|
|
84
|
+
showImage && /*#__PURE__*/ jsxRuntime.jsx(skeleton.Skeleton, {
|
|
85
|
+
className: "w-full rounded-md",
|
|
86
|
+
style: {
|
|
87
|
+
height: imageHeight
|
|
88
|
+
}
|
|
89
|
+
}),
|
|
90
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
91
|
+
className: "space-y-2",
|
|
92
|
+
children: Array.from({
|
|
93
|
+
length: titleLines
|
|
94
|
+
}, function(_, index) {
|
|
95
|
+
return /*#__PURE__*/ jsxRuntime.jsx(skeleton.Skeleton, {
|
|
96
|
+
className: "h-6 w-3/4 rounded"
|
|
97
|
+
}, "title-".concat(index));
|
|
98
|
+
})
|
|
99
|
+
}),
|
|
100
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
101
|
+
className: "space-y-2",
|
|
102
|
+
children: Array.from({
|
|
103
|
+
length: contentLines
|
|
104
|
+
}, function(_, index) {
|
|
105
|
+
return /*#__PURE__*/ jsxRuntime.jsx(skeleton.Skeleton, {
|
|
106
|
+
className: utils.cn("h-4 rounded", index === contentLines - 1 ? "w-2/3" : "w-full")
|
|
107
|
+
}, "content-".concat(index));
|
|
108
|
+
})
|
|
109
|
+
}),
|
|
110
|
+
showActions && /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
111
|
+
className: "flex space-x-2 pt-2",
|
|
112
|
+
children: [
|
|
113
|
+
/*#__PURE__*/ jsxRuntime.jsx(skeleton.Skeleton, {
|
|
114
|
+
className: "h-9 w-20 rounded"
|
|
115
|
+
}),
|
|
116
|
+
/*#__PURE__*/ jsxRuntime.jsx(skeleton.Skeleton, {
|
|
117
|
+
className: "h-9 w-16 rounded"
|
|
118
|
+
})
|
|
119
|
+
]
|
|
120
|
+
})
|
|
121
|
+
]
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
var TableSkeleton = function(param) {
|
|
125
|
+
var _param_rows = param.rows, rows = _param_rows === void 0 ? 5 : _param_rows, _param_columns = param.columns, columns = _param_columns === void 0 ? 4 : _param_columns, _param_showHeader = param.showHeader, showHeader = _param_showHeader === void 0 ? true : _param_showHeader, className = param.className;
|
|
126
|
+
return /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
127
|
+
className: utils.cn("w-full", className),
|
|
128
|
+
children: [
|
|
129
|
+
showHeader && /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
130
|
+
className: "grid gap-4 pb-4 border-b",
|
|
131
|
+
style: {
|
|
132
|
+
gridTemplateColumns: "repeat(".concat(columns, ", 1fr)")
|
|
133
|
+
},
|
|
134
|
+
children: Array.from({
|
|
135
|
+
length: columns
|
|
136
|
+
}, function(_, index) {
|
|
137
|
+
return /*#__PURE__*/ jsxRuntime.jsx(skeleton.Skeleton, {
|
|
138
|
+
className: "h-6 rounded"
|
|
139
|
+
}, "header-".concat(index));
|
|
140
|
+
})
|
|
141
|
+
}),
|
|
142
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
143
|
+
className: "space-y-3 pt-4",
|
|
144
|
+
children: Array.from({
|
|
145
|
+
length: rows
|
|
146
|
+
}, function(_, rowIndex) {
|
|
147
|
+
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
148
|
+
className: "grid gap-4",
|
|
149
|
+
style: {
|
|
150
|
+
gridTemplateColumns: "repeat(".concat(columns, ", 1fr)")
|
|
151
|
+
},
|
|
152
|
+
children: Array.from({
|
|
153
|
+
length: columns
|
|
154
|
+
}, function(_, colIndex) {
|
|
155
|
+
return /*#__PURE__*/ jsxRuntime.jsx(skeleton.Skeleton, {
|
|
156
|
+
className: "h-4 rounded"
|
|
157
|
+
}, "cell-".concat(rowIndex, "-").concat(colIndex));
|
|
158
|
+
})
|
|
159
|
+
}, "row-".concat(rowIndex));
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
]
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
exports.AvatarSkeleton = AvatarSkeleton;
|
|
167
|
+
exports.BaseSkeleton = BaseSkeleton;
|
|
168
|
+
exports.CardSkeleton = CardSkeleton;
|
|
169
|
+
exports.TableSkeleton = TableSkeleton;
|
package/Skeleton.cjs.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/Skeleton";
|
package/Skeleton.esm.js
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import 'react';
|
|
3
|
+
import { S as Skeleton } from './skeleton.esm2.js';
|
|
4
|
+
import { c as cn } from './utils.esm.js';
|
|
5
|
+
import 'clsx';
|
|
6
|
+
import 'tailwind-merge';
|
|
7
|
+
|
|
8
|
+
var BaseSkeleton = function(param) {
|
|
9
|
+
var _param_variant = param.variant, variant = _param_variant === void 0 ? "default" : _param_variant, width = param.width, height = param.height, _param_animate = param.animate, animate = _param_animate === void 0 ? true : _param_animate, className = param.className, _param_count = param.count, count = _param_count === void 0 ? 1 : _param_count, _param_spacing = param.spacing, spacing = _param_spacing === void 0 ? "0.5rem" : _param_spacing;
|
|
10
|
+
var getVariantStyles = function() {
|
|
11
|
+
switch(variant){
|
|
12
|
+
case "text":
|
|
13
|
+
return "h-4 w-full rounded-sm";
|
|
14
|
+
case "circular":
|
|
15
|
+
return "rounded-full aspect-square";
|
|
16
|
+
case "rectangular":
|
|
17
|
+
return "rounded-sm";
|
|
18
|
+
default:
|
|
19
|
+
return "rounded-md";
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var skeletonStyle = {
|
|
23
|
+
width: typeof width === "number" ? "".concat(width, "px") : width,
|
|
24
|
+
height: typeof height === "number" ? "".concat(height, "px") : height
|
|
25
|
+
};
|
|
26
|
+
var skeletonClasses = cn(getVariantStyles(), !animate && "animate-none", className);
|
|
27
|
+
if (count === 1) {
|
|
28
|
+
return /*#__PURE__*/ jsx(Skeleton, {
|
|
29
|
+
className: skeletonClasses,
|
|
30
|
+
style: skeletonStyle
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return /*#__PURE__*/ jsx("div", {
|
|
34
|
+
className: "space-y-2",
|
|
35
|
+
style: {
|
|
36
|
+
gap: spacing
|
|
37
|
+
},
|
|
38
|
+
children: Array.from({
|
|
39
|
+
length: count
|
|
40
|
+
}, function(_, index) {
|
|
41
|
+
return /*#__PURE__*/ jsx(Skeleton, {
|
|
42
|
+
className: skeletonClasses,
|
|
43
|
+
style: skeletonStyle
|
|
44
|
+
}, index);
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
var AvatarSkeleton = function(param) {
|
|
49
|
+
var _param_size = param.size, size = _param_size === void 0 ? "md" : _param_size, _param_showText = param.showText, showText = _param_showText === void 0 ? true : _param_showText, _param_textLines = param.textLines, textLines = _param_textLines === void 0 ? 2 : _param_textLines, className = param.className;
|
|
50
|
+
var sizeClasses = {
|
|
51
|
+
sm: "h-8 w-8",
|
|
52
|
+
md: "h-12 w-12",
|
|
53
|
+
lg: "h-16 w-16",
|
|
54
|
+
xl: "h-20 w-20"
|
|
55
|
+
};
|
|
56
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
57
|
+
className: cn("flex items-center space-x-4", className),
|
|
58
|
+
children: [
|
|
59
|
+
/*#__PURE__*/ jsx(Skeleton, {
|
|
60
|
+
className: cn("rounded-full", sizeClasses[size])
|
|
61
|
+
}),
|
|
62
|
+
showText && /*#__PURE__*/ jsx("div", {
|
|
63
|
+
className: "space-y-2 flex-1",
|
|
64
|
+
children: Array.from({
|
|
65
|
+
length: textLines
|
|
66
|
+
}, function(_, index) {
|
|
67
|
+
return /*#__PURE__*/ jsx(Skeleton, {
|
|
68
|
+
className: cn("h-4 rounded", index === textLines - 1 ? "w-3/4" : "w-full")
|
|
69
|
+
}, index);
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
var CardSkeleton = function(param) {
|
|
76
|
+
var _param_showImage = param.showImage, showImage = _param_showImage === void 0 ? true : _param_showImage, _param_imageHeight = param.imageHeight, imageHeight = _param_imageHeight === void 0 ? "200px" : _param_imageHeight, _param_titleLines = param.titleLines, titleLines = _param_titleLines === void 0 ? 1 : _param_titleLines, _param_contentLines = param.contentLines, contentLines = _param_contentLines === void 0 ? 3 : _param_contentLines, _param_showActions = param.showActions, showActions = _param_showActions === void 0 ? true : _param_showActions, className = param.className;
|
|
77
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
78
|
+
className: cn("border rounded-lg p-4 space-y-4", className),
|
|
79
|
+
children: [
|
|
80
|
+
showImage && /*#__PURE__*/ jsx(Skeleton, {
|
|
81
|
+
className: "w-full rounded-md",
|
|
82
|
+
style: {
|
|
83
|
+
height: imageHeight
|
|
84
|
+
}
|
|
85
|
+
}),
|
|
86
|
+
/*#__PURE__*/ jsx("div", {
|
|
87
|
+
className: "space-y-2",
|
|
88
|
+
children: Array.from({
|
|
89
|
+
length: titleLines
|
|
90
|
+
}, function(_, index) {
|
|
91
|
+
return /*#__PURE__*/ jsx(Skeleton, {
|
|
92
|
+
className: "h-6 w-3/4 rounded"
|
|
93
|
+
}, "title-".concat(index));
|
|
94
|
+
})
|
|
95
|
+
}),
|
|
96
|
+
/*#__PURE__*/ jsx("div", {
|
|
97
|
+
className: "space-y-2",
|
|
98
|
+
children: Array.from({
|
|
99
|
+
length: contentLines
|
|
100
|
+
}, function(_, index) {
|
|
101
|
+
return /*#__PURE__*/ jsx(Skeleton, {
|
|
102
|
+
className: cn("h-4 rounded", index === contentLines - 1 ? "w-2/3" : "w-full")
|
|
103
|
+
}, "content-".concat(index));
|
|
104
|
+
})
|
|
105
|
+
}),
|
|
106
|
+
showActions && /*#__PURE__*/ jsxs("div", {
|
|
107
|
+
className: "flex space-x-2 pt-2",
|
|
108
|
+
children: [
|
|
109
|
+
/*#__PURE__*/ jsx(Skeleton, {
|
|
110
|
+
className: "h-9 w-20 rounded"
|
|
111
|
+
}),
|
|
112
|
+
/*#__PURE__*/ jsx(Skeleton, {
|
|
113
|
+
className: "h-9 w-16 rounded"
|
|
114
|
+
})
|
|
115
|
+
]
|
|
116
|
+
})
|
|
117
|
+
]
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
var TableSkeleton = function(param) {
|
|
121
|
+
var _param_rows = param.rows, rows = _param_rows === void 0 ? 5 : _param_rows, _param_columns = param.columns, columns = _param_columns === void 0 ? 4 : _param_columns, _param_showHeader = param.showHeader, showHeader = _param_showHeader === void 0 ? true : _param_showHeader, className = param.className;
|
|
122
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
123
|
+
className: cn("w-full", className),
|
|
124
|
+
children: [
|
|
125
|
+
showHeader && /*#__PURE__*/ jsx("div", {
|
|
126
|
+
className: "grid gap-4 pb-4 border-b",
|
|
127
|
+
style: {
|
|
128
|
+
gridTemplateColumns: "repeat(".concat(columns, ", 1fr)")
|
|
129
|
+
},
|
|
130
|
+
children: Array.from({
|
|
131
|
+
length: columns
|
|
132
|
+
}, function(_, index) {
|
|
133
|
+
return /*#__PURE__*/ jsx(Skeleton, {
|
|
134
|
+
className: "h-6 rounded"
|
|
135
|
+
}, "header-".concat(index));
|
|
136
|
+
})
|
|
137
|
+
}),
|
|
138
|
+
/*#__PURE__*/ jsx("div", {
|
|
139
|
+
className: "space-y-3 pt-4",
|
|
140
|
+
children: Array.from({
|
|
141
|
+
length: rows
|
|
142
|
+
}, function(_, rowIndex) {
|
|
143
|
+
return /*#__PURE__*/ jsx("div", {
|
|
144
|
+
className: "grid gap-4",
|
|
145
|
+
style: {
|
|
146
|
+
gridTemplateColumns: "repeat(".concat(columns, ", 1fr)")
|
|
147
|
+
},
|
|
148
|
+
children: Array.from({
|
|
149
|
+
length: columns
|
|
150
|
+
}, function(_, colIndex) {
|
|
151
|
+
return /*#__PURE__*/ jsx(Skeleton, {
|
|
152
|
+
className: "h-4 rounded"
|
|
153
|
+
}, "cell-".concat(rowIndex, "-").concat(colIndex));
|
|
154
|
+
})
|
|
155
|
+
}, "row-".concat(rowIndex));
|
|
156
|
+
})
|
|
157
|
+
})
|
|
158
|
+
]
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export { AvatarSkeleton, BaseSkeleton, CardSkeleton, TableSkeleton };
|