@luxfi/ui 6.1.3 → 7.1.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/accordion.cjs +213 -0
- package/dist/accordion.d.cts +74 -0
- package/dist/accordion.d.ts +74 -0
- package/dist/accordion.js +186 -0
- package/dist/alert.cjs +430 -0
- package/dist/alert.d.cts +30 -0
- package/dist/alert.d.ts +30 -0
- package/dist/alert.js +408 -0
- package/dist/avatar.cjs +149 -0
- package/dist/avatar.d.cts +25 -0
- package/dist/avatar.d.ts +25 -0
- package/dist/avatar.js +125 -0
- package/dist/badge.cjs +452 -0
- package/dist/badge.d.cts +19 -0
- package/dist/badge.d.ts +19 -0
- package/dist/badge.js +431 -0
- package/dist/bank.cjs +272 -0
- package/dist/bank.d.cts +76 -0
- package/dist/bank.d.ts +76 -0
- package/dist/bank.js +258 -0
- package/dist/button.cjs +578 -0
- package/dist/button.d.cts +55 -0
- package/dist/button.d.ts +55 -0
- package/dist/button.js +553 -0
- package/dist/checkbox.cjs +265 -0
- package/dist/checkbox.d.cts +31 -0
- package/dist/checkbox.d.ts +31 -0
- package/dist/checkbox.js +241 -0
- package/dist/close-button.cjs +92 -0
- package/dist/close-button.d.cts +9 -0
- package/dist/close-button.d.ts +9 -0
- package/dist/close-button.js +70 -0
- package/dist/collapsible.cjs +555 -0
- package/dist/collapsible.d.cts +23 -0
- package/dist/collapsible.d.ts +23 -0
- package/dist/collapsible.js +532 -0
- package/dist/color-mode.cjs +96 -0
- package/dist/color-mode.d.cts +25 -0
- package/dist/color-mode.d.ts +25 -0
- package/dist/color-mode.js +72 -0
- package/dist/dialog.cjs +295 -0
- package/dist/dialog.d.cts +65 -0
- package/dist/dialog.d.ts +65 -0
- package/dist/dialog.js +263 -0
- package/dist/drawer.cjs +231 -0
- package/dist/drawer.d.cts +36 -0
- package/dist/drawer.d.ts +36 -0
- package/dist/drawer.js +199 -0
- package/dist/empty-state.cjs +93 -0
- package/dist/empty-state.d.cts +13 -0
- package/dist/empty-state.d.ts +13 -0
- package/dist/empty-state.js +71 -0
- package/dist/expiration-selector.cjs +138 -0
- package/dist/expiration-selector.d.cts +16 -0
- package/dist/expiration-selector.d.ts +16 -0
- package/dist/expiration-selector.js +116 -0
- package/dist/field.cjs +183 -0
- package/dist/field.d.cts +24 -0
- package/dist/field.d.ts +24 -0
- package/dist/field.js +160 -0
- package/dist/greeks-display.cjs +114 -0
- package/dist/greeks-display.d.cts +14 -0
- package/dist/greeks-display.d.ts +14 -0
- package/dist/greeks-display.js +92 -0
- package/dist/heading.cjs +41 -0
- package/dist/heading.d.cts +10 -0
- package/dist/heading.d.ts +10 -0
- package/dist/heading.js +35 -0
- package/dist/icon-button.cjs +367 -0
- package/dist/icon-button.d.cts +33 -0
- package/dist/icon-button.d.ts +33 -0
- package/dist/icon-button.js +345 -0
- package/dist/image.cjs +425 -0
- package/dist/image.d.cts +57 -0
- package/dist/image.d.ts +57 -0
- package/dist/image.js +404 -0
- package/dist/index.cjs +7220 -0
- package/dist/index.d.cts +55 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +7043 -0
- package/dist/input-group.cjs +155 -0
- package/dist/input-group.d.cts +17 -0
- package/dist/input-group.d.ts +17 -0
- package/dist/input-group.js +133 -0
- package/dist/input.cjs +65 -0
- package/dist/input.d.cts +11 -0
- package/dist/input.d.ts +11 -0
- package/dist/input.js +59 -0
- package/dist/link.cjs +483 -0
- package/dist/link.d.cts +37 -0
- package/dist/link.d.ts +37 -0
- package/dist/link.js +459 -0
- package/dist/menu.cjs +305 -0
- package/dist/menu.d.cts +84 -0
- package/dist/menu.d.ts +84 -0
- package/dist/menu.js +269 -0
- package/dist/option-chain.cjs +221 -0
- package/dist/option-chain.d.cts +37 -0
- package/dist/option-chain.d.ts +37 -0
- package/dist/option-chain.js +199 -0
- package/dist/option-position.cjs +164 -0
- package/dist/option-position.d.cts +29 -0
- package/dist/option-position.d.ts +29 -0
- package/dist/option-position.js +142 -0
- package/dist/pin-input.cjs +182 -0
- package/dist/pin-input.d.cts +25 -0
- package/dist/pin-input.d.ts +25 -0
- package/dist/pin-input.js +160 -0
- package/dist/pnl-diagram.cjs +453 -0
- package/dist/pnl-diagram.d.cts +11 -0
- package/dist/pnl-diagram.d.ts +11 -0
- package/dist/pnl-diagram.js +431 -0
- package/dist/popover.cjs +342 -0
- package/dist/popover.d.cts +73 -0
- package/dist/popover.d.ts +73 -0
- package/dist/popover.js +310 -0
- package/dist/progress-circle.cjs +152 -0
- package/dist/progress-circle.d.cts +47 -0
- package/dist/progress-circle.d.ts +47 -0
- package/dist/progress-circle.js +128 -0
- package/dist/progress.cjs +117 -0
- package/dist/progress.d.cts +28 -0
- package/dist/progress.d.ts +28 -0
- package/dist/progress.js +94 -0
- package/dist/provider.cjs +62 -0
- package/dist/provider.d.cts +7 -0
- package/dist/provider.d.ts +7 -0
- package/dist/provider.js +40 -0
- package/dist/radio.cjs +177 -0
- package/dist/radio.d.cts +53 -0
- package/dist/radio.d.ts +53 -0
- package/dist/radio.js +153 -0
- package/dist/rating.cjs +80 -0
- package/dist/rating.d.cts +14 -0
- package/dist/rating.d.ts +14 -0
- package/dist/rating.js +58 -0
- package/dist/select.cjs +644 -0
- package/dist/select.d.cts +130 -0
- package/dist/select.d.ts +130 -0
- package/dist/select.js +610 -0
- package/dist/separator.cjs +57 -0
- package/dist/separator.d.cts +13 -0
- package/dist/separator.d.ts +13 -0
- package/dist/separator.js +51 -0
- package/dist/skeleton.cjs +223 -0
- package/dist/skeleton.d.cts +60 -0
- package/dist/skeleton.d.ts +60 -0
- package/dist/skeleton.js +199 -0
- package/dist/slider.cjs +138 -0
- package/dist/slider.d.cts +24 -0
- package/dist/slider.d.ts +24 -0
- package/dist/slider.js +115 -0
- package/dist/strategy-builder.cjs +373 -0
- package/dist/strategy-builder.d.cts +26 -0
- package/dist/strategy-builder.d.ts +26 -0
- package/dist/strategy-builder.js +351 -0
- package/dist/switch.cjs +163 -0
- package/dist/switch.d.cts +27 -0
- package/dist/switch.d.ts +27 -0
- package/dist/switch.js +140 -0
- package/dist/table.cjs +897 -0
- package/dist/table.d.cts +107 -0
- package/dist/table.d.ts +107 -0
- package/dist/table.js +866 -0
- package/dist/tabs.cjs +240 -0
- package/dist/tabs.d.cts +78 -0
- package/dist/tabs.d.ts +78 -0
- package/dist/tabs.js +213 -0
- package/dist/tag.cjs +529 -0
- package/dist/tag.d.cts +21 -0
- package/dist/tag.d.ts +21 -0
- package/dist/tag.js +507 -0
- package/dist/textarea.cjs +65 -0
- package/dist/textarea.d.cts +11 -0
- package/dist/textarea.d.ts +11 -0
- package/dist/textarea.js +59 -0
- package/dist/toaster.cjs +99 -0
- package/dist/toaster.d.cts +29 -0
- package/dist/toaster.d.ts +29 -0
- package/dist/toaster.js +96 -0
- package/dist/tooltip.cjs +172 -0
- package/dist/tooltip.d.cts +38 -0
- package/dist/tooltip.d.ts +38 -0
- package/dist/tooltip.js +150 -0
- package/dist/utils.cjs +11 -0
- package/dist/utils.d.cts +5 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +9 -0
- package/package.json +284 -89
- package/src/accordion.tsx +285 -0
- package/src/alert.tsx +221 -0
- package/src/avatar.tsx +174 -0
- package/src/badge.tsx +147 -0
- package/src/bank.tsx +325 -0
- package/src/button.tsx +477 -0
- package/src/checkbox.tsx +307 -0
- package/src/close-button.tsx +77 -0
- package/src/collapsible.tsx +126 -0
- package/src/color-mode.tsx +125 -0
- package/src/dialog.tsx +346 -0
- package/src/drawer.tsx +186 -0
- package/src/empty-state.tsx +97 -0
- package/src/expiration-selector.tsx +163 -0
- package/src/field.tsx +202 -0
- package/src/greeks-display.tsx +138 -0
- package/src/heading.tsx +44 -0
- package/src/icon-button.tsx +217 -0
- package/src/image.tsx +280 -0
- package/src/index.ts +267 -138
- package/src/input-group.tsx +159 -0
- package/src/input.tsx +60 -0
- package/src/link.tsx +326 -0
- package/src/menu.tsx +471 -0
- package/src/option-chain.tsx +261 -0
- package/src/option-position.tsx +200 -0
- package/src/pin-input.tsx +187 -0
- package/src/pnl-diagram.tsx +458 -0
- package/src/popover.tsx +386 -0
- package/src/progress-circle.tsx +180 -0
- package/src/progress.tsx +109 -0
- package/src/provider.tsx +12 -0
- package/src/radio.tsx +175 -0
- package/src/rating.tsx +79 -0
- package/src/select.tsx +696 -0
- package/src/separator.tsx +59 -0
- package/src/skeleton.tsx +254 -0
- package/src/slider.tsx +152 -0
- package/src/strategy-builder.tsx +466 -0
- package/src/switch.tsx +158 -0
- package/src/table.tsx +621 -0
- package/src/tabs.tsx +354 -0
- package/src/tag.tsx +159 -0
- package/src/textarea.tsx +60 -0
- package/src/toaster.tsx +117 -0
- package/src/tokens.css +438 -0
- package/src/tooltip.tsx +191 -0
- package/src/utils/cn.ts +7 -0
- package/src/utils.ts +6 -0
- package/tokens.css +438 -0
- package/LICENSE +0 -122
- package/README.md +0 -109
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import { twMerge } from 'tailwind-merge';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
// src/separator.tsx
|
|
8
|
+
function cn(...inputs) {
|
|
9
|
+
return twMerge(clsx(inputs));
|
|
10
|
+
}
|
|
11
|
+
var VARIANT_CLASSES = {
|
|
12
|
+
solid: "border-solid",
|
|
13
|
+
dashed: "border-dashed",
|
|
14
|
+
dotted: "border-dotted"
|
|
15
|
+
};
|
|
16
|
+
var HORIZONTAL_SIZE_CLASSES = {
|
|
17
|
+
xs: "border-t-[0.5px]",
|
|
18
|
+
sm: "border-t",
|
|
19
|
+
md: "border-t-2",
|
|
20
|
+
lg: "border-t-[3px]"
|
|
21
|
+
};
|
|
22
|
+
var VERTICAL_SIZE_CLASSES = {
|
|
23
|
+
xs: "border-l-[0.5px]",
|
|
24
|
+
sm: "border-l",
|
|
25
|
+
md: "border-l-2",
|
|
26
|
+
lg: "border-l-[3px]"
|
|
27
|
+
};
|
|
28
|
+
var Separator = React.forwardRef(
|
|
29
|
+
function Separator2({ orientation = "horizontal", variant = "solid", size = "sm", className, ...rest }, ref) {
|
|
30
|
+
const isVertical = orientation === "vertical";
|
|
31
|
+
return /* @__PURE__ */ jsx(
|
|
32
|
+
"hr",
|
|
33
|
+
{
|
|
34
|
+
ref,
|
|
35
|
+
role: "separator",
|
|
36
|
+
"aria-orientation": orientation,
|
|
37
|
+
className: cn(
|
|
38
|
+
"border-[var(--color-border-divider)]",
|
|
39
|
+
"border-0",
|
|
40
|
+
VARIANT_CLASSES[variant],
|
|
41
|
+
isVertical ? VERTICAL_SIZE_CLASSES[size] : HORIZONTAL_SIZE_CLASSES[size],
|
|
42
|
+
isVertical ? "self-stretch h-auto w-0" : "w-full",
|
|
43
|
+
className
|
|
44
|
+
),
|
|
45
|
+
...rest
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
export { Separator };
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var clsx = require('clsx');
|
|
6
|
+
var tailwindMerge = require('tailwind-merge');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return e[k]; }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
n.default = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
28
|
+
|
|
29
|
+
// src/skeleton.tsx
|
|
30
|
+
function cn(...inputs) {
|
|
31
|
+
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
32
|
+
}
|
|
33
|
+
var SHIM_PROPS = [
|
|
34
|
+
"w",
|
|
35
|
+
"h",
|
|
36
|
+
"minW",
|
|
37
|
+
"maxW",
|
|
38
|
+
"display",
|
|
39
|
+
"flexGrow",
|
|
40
|
+
"flexShrink",
|
|
41
|
+
"flexBasis",
|
|
42
|
+
"fontWeight",
|
|
43
|
+
"textStyle",
|
|
44
|
+
"borderRadius",
|
|
45
|
+
"alignSelf",
|
|
46
|
+
"alignItems",
|
|
47
|
+
"justifyContent",
|
|
48
|
+
"color",
|
|
49
|
+
"mt",
|
|
50
|
+
"mb",
|
|
51
|
+
"ml",
|
|
52
|
+
"mr",
|
|
53
|
+
"height",
|
|
54
|
+
"overflow",
|
|
55
|
+
"whiteSpace",
|
|
56
|
+
"textOverflow",
|
|
57
|
+
"textTransform",
|
|
58
|
+
"gap",
|
|
59
|
+
"gridTemplateColumns",
|
|
60
|
+
"minWidth",
|
|
61
|
+
"boxSize",
|
|
62
|
+
"py",
|
|
63
|
+
"px",
|
|
64
|
+
"p",
|
|
65
|
+
"hideBelow",
|
|
66
|
+
"fontSize",
|
|
67
|
+
"flexWrap",
|
|
68
|
+
"wordBreak",
|
|
69
|
+
"lineHeight",
|
|
70
|
+
"marginRight",
|
|
71
|
+
"position",
|
|
72
|
+
"background"
|
|
73
|
+
];
|
|
74
|
+
var S = 4;
|
|
75
|
+
function dim(v) {
|
|
76
|
+
if (v == null) return void 0;
|
|
77
|
+
if (typeof v === "number") return `${v * S}px`;
|
|
78
|
+
if (typeof v === "string") return v;
|
|
79
|
+
if (typeof v === "object") {
|
|
80
|
+
const o = v;
|
|
81
|
+
return o.base ?? o.lg ?? o.xl ?? Object.values(o)[0];
|
|
82
|
+
}
|
|
83
|
+
return void 0;
|
|
84
|
+
}
|
|
85
|
+
function sp(v) {
|
|
86
|
+
if (v === void 0) return void 0;
|
|
87
|
+
return typeof v === "number" ? `${v * S}px` : v;
|
|
88
|
+
}
|
|
89
|
+
function shimToStyle(props) {
|
|
90
|
+
const s = {};
|
|
91
|
+
if (props.w !== void 0) s.width = dim(props.w);
|
|
92
|
+
if (props.h !== void 0) s.height = dim(props.h);
|
|
93
|
+
if (props.minW !== void 0) s.minWidth = dim(props.minW);
|
|
94
|
+
if (props.maxW !== void 0) s.maxWidth = dim(props.maxW);
|
|
95
|
+
if (props.display !== void 0) s.display = props.display;
|
|
96
|
+
if (props.flexGrow !== void 0) s.flexGrow = props.flexGrow;
|
|
97
|
+
if (props.flexShrink !== void 0) s.flexShrink = props.flexShrink;
|
|
98
|
+
if (props.flexBasis !== void 0) s.flexBasis = props.flexBasis;
|
|
99
|
+
if (props.fontWeight !== void 0) s.fontWeight = props.fontWeight;
|
|
100
|
+
if (props.borderRadius !== void 0) s.borderRadius = props.borderRadius;
|
|
101
|
+
if (props.alignSelf !== void 0) s.alignSelf = props.alignSelf;
|
|
102
|
+
if (props.alignItems !== void 0) s.alignItems = props.alignItems;
|
|
103
|
+
if (props.justifyContent !== void 0) s.justifyContent = props.justifyContent;
|
|
104
|
+
if (props.color !== void 0) s.color = props.color;
|
|
105
|
+
if (props.mt !== void 0) s.marginTop = sp(props.mt);
|
|
106
|
+
if (props.mb !== void 0) s.marginBottom = sp(props.mb);
|
|
107
|
+
if (props.ml !== void 0) s.marginLeft = sp(props.ml);
|
|
108
|
+
if (props.mr !== void 0) s.marginRight = sp(props.mr);
|
|
109
|
+
if (props.height !== void 0) s.height = props.height;
|
|
110
|
+
if (props.overflow !== void 0) s.overflow = props.overflow;
|
|
111
|
+
if (props.whiteSpace !== void 0) s.whiteSpace = props.whiteSpace;
|
|
112
|
+
if (props.textOverflow !== void 0) s.textOverflow = props.textOverflow;
|
|
113
|
+
if (props.textTransform !== void 0) s.textTransform = props.textTransform;
|
|
114
|
+
if (props.gap !== void 0) s.gap = sp(props.gap);
|
|
115
|
+
if (props.gridTemplateColumns !== void 0) s.gridTemplateColumns = props.gridTemplateColumns;
|
|
116
|
+
if (props.minWidth !== void 0) s.minWidth = props.minWidth;
|
|
117
|
+
if (props.boxSize !== void 0) {
|
|
118
|
+
const v = typeof props.boxSize === "number" ? `${props.boxSize * S}px` : props.boxSize;
|
|
119
|
+
s.width = v;
|
|
120
|
+
s.height = v;
|
|
121
|
+
}
|
|
122
|
+
if (props.py !== void 0) {
|
|
123
|
+
const v = sp(props.py);
|
|
124
|
+
s.paddingTop = v;
|
|
125
|
+
s.paddingBottom = v;
|
|
126
|
+
}
|
|
127
|
+
if (props.px !== void 0) {
|
|
128
|
+
const v = sp(props.px);
|
|
129
|
+
s.paddingLeft = v;
|
|
130
|
+
s.paddingRight = v;
|
|
131
|
+
}
|
|
132
|
+
if (props.p !== void 0) s.padding = sp(props.p);
|
|
133
|
+
if (props.fontSize !== void 0) s.fontSize = props.fontSize;
|
|
134
|
+
if (props.flexWrap !== void 0) s.flexWrap = props.flexWrap;
|
|
135
|
+
if (props.wordBreak !== void 0) s.wordBreak = props.wordBreak;
|
|
136
|
+
if (props.lineHeight !== void 0) s.lineHeight = props.lineHeight;
|
|
137
|
+
if (props.marginRight !== void 0) s.marginRight = props.marginRight;
|
|
138
|
+
if (props.position !== void 0) s.position = props.position;
|
|
139
|
+
if (props.background !== void 0) s.background = props.background;
|
|
140
|
+
return s;
|
|
141
|
+
}
|
|
142
|
+
function stripShims(props) {
|
|
143
|
+
const out = { ...props };
|
|
144
|
+
for (const k of SHIM_PROPS) delete out[k];
|
|
145
|
+
return out;
|
|
146
|
+
}
|
|
147
|
+
var SKELETON_CLASSES = [
|
|
148
|
+
"animate-skeleton-shimmer rounded-sm",
|
|
149
|
+
"bg-[linear-gradient(90deg,var(--color-skeleton-start)_0%,var(--color-skeleton-end)_50%,var(--color-skeleton-start)_100%)]",
|
|
150
|
+
"bg-[length:200%_100%]"
|
|
151
|
+
].join(" ");
|
|
152
|
+
var HIDE_BELOW_MAP = { lg: "lg:hidden", md: "md:hidden", sm: "sm:hidden" };
|
|
153
|
+
var Skeleton = React__namespace.forwardRef(
|
|
154
|
+
function Skeleton2(props, ref) {
|
|
155
|
+
const { loading = false, asChild, className, children, style: styleProp, as: Component = "div", ...allRest } = props;
|
|
156
|
+
const shimStyle = shimToStyle(props);
|
|
157
|
+
const mergedStyle = Object.keys(shimStyle).length > 0 || styleProp ? { ...shimStyle, ...styleProp } : void 0;
|
|
158
|
+
const hideBelowClass = props.hideBelow ? HIDE_BELOW_MAP[props.hideBelow] : void 0;
|
|
159
|
+
const cls = hideBelowClass ? cn(className, hideBelowClass) : className;
|
|
160
|
+
const htmlRest = stripShims(allRest);
|
|
161
|
+
if (!loading) {
|
|
162
|
+
if (asChild && React__namespace.isValidElement(children)) return children;
|
|
163
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ref, className: cls, style: mergedStyle, ...htmlRest, children });
|
|
164
|
+
}
|
|
165
|
+
if (asChild && React__namespace.isValidElement(children)) {
|
|
166
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
167
|
+
Component,
|
|
168
|
+
{
|
|
169
|
+
ref,
|
|
170
|
+
"data-loading": true,
|
|
171
|
+
className: cn(SKELETON_CLASSES, "text-transparent [&_*]:invisible", cls),
|
|
172
|
+
style: mergedStyle,
|
|
173
|
+
...htmlRest,
|
|
174
|
+
children
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
179
|
+
Component,
|
|
180
|
+
{
|
|
181
|
+
ref,
|
|
182
|
+
"data-loading": true,
|
|
183
|
+
className: cn(SKELETON_CLASSES, children ? "text-transparent [&_*]:invisible" : "min-h-5", cls),
|
|
184
|
+
style: mergedStyle,
|
|
185
|
+
...htmlRest,
|
|
186
|
+
children
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
var SkeletonCircle = React__namespace.forwardRef(
|
|
192
|
+
function SkeletonCircle2(props, ref) {
|
|
193
|
+
const { size = 40, loading = true, className, ...rest } = props;
|
|
194
|
+
const dimension = typeof size === "number" ? `${size}px` : size;
|
|
195
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
196
|
+
Skeleton,
|
|
197
|
+
{
|
|
198
|
+
ref,
|
|
199
|
+
loading,
|
|
200
|
+
className: cn("rounded-full shrink-0", className),
|
|
201
|
+
style: { width: dimension, height: dimension, ...rest.style },
|
|
202
|
+
...rest
|
|
203
|
+
}
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
var SkeletonText = React__namespace.forwardRef(
|
|
208
|
+
function SkeletonText2(props, ref) {
|
|
209
|
+
const { noOfLines = 3, loading = true, className, ...rest } = props;
|
|
210
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("flex w-full flex-col gap-2", className), ...rest, children: Array.from({ length: noOfLines }).map((_, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
211
|
+
Skeleton,
|
|
212
|
+
{
|
|
213
|
+
loading,
|
|
214
|
+
className: cn("h-4", index === noOfLines - 1 && "max-w-[80%]")
|
|
215
|
+
},
|
|
216
|
+
index
|
|
217
|
+
)) });
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
exports.Skeleton = Skeleton;
|
|
222
|
+
exports.SkeletonCircle = SkeletonCircle;
|
|
223
|
+
exports.SkeletonText = SkeletonText;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface SkeletonProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'> {
|
|
4
|
+
readonly loading: boolean | undefined;
|
|
5
|
+
/** When true, the Skeleton wraps its single child element instead of adding a wrapper div. */
|
|
6
|
+
readonly asChild?: boolean;
|
|
7
|
+
readonly w?: any;
|
|
8
|
+
readonly h?: any;
|
|
9
|
+
readonly minW?: any;
|
|
10
|
+
readonly maxW?: any;
|
|
11
|
+
readonly display?: string;
|
|
12
|
+
readonly flexGrow?: number;
|
|
13
|
+
readonly flexShrink?: number;
|
|
14
|
+
readonly flexBasis?: string;
|
|
15
|
+
readonly fontWeight?: number | string;
|
|
16
|
+
readonly textStyle?: string;
|
|
17
|
+
readonly borderRadius?: string;
|
|
18
|
+
readonly alignSelf?: string;
|
|
19
|
+
readonly alignItems?: string;
|
|
20
|
+
readonly justifyContent?: string;
|
|
21
|
+
readonly color?: string;
|
|
22
|
+
readonly mt?: number | string;
|
|
23
|
+
readonly mb?: number | string;
|
|
24
|
+
readonly ml?: number | string;
|
|
25
|
+
readonly mr?: number | string;
|
|
26
|
+
readonly height?: string;
|
|
27
|
+
readonly overflow?: string;
|
|
28
|
+
readonly whiteSpace?: string;
|
|
29
|
+
readonly textOverflow?: string;
|
|
30
|
+
readonly textTransform?: string;
|
|
31
|
+
readonly gap?: number | string;
|
|
32
|
+
readonly gridTemplateColumns?: string;
|
|
33
|
+
readonly minWidth?: string;
|
|
34
|
+
readonly boxSize?: number | string;
|
|
35
|
+
readonly py?: number | string;
|
|
36
|
+
readonly px?: number | string;
|
|
37
|
+
readonly p?: number | string;
|
|
38
|
+
readonly hideBelow?: string;
|
|
39
|
+
readonly as?: React.ElementType;
|
|
40
|
+
readonly fontSize?: string;
|
|
41
|
+
readonly flexWrap?: React.CSSProperties['flexWrap'];
|
|
42
|
+
readonly wordBreak?: React.CSSProperties['wordBreak'];
|
|
43
|
+
readonly lineHeight?: string;
|
|
44
|
+
readonly marginRight?: string;
|
|
45
|
+
readonly position?: React.CSSProperties['position'];
|
|
46
|
+
readonly background?: string;
|
|
47
|
+
}
|
|
48
|
+
declare const Skeleton: React.ForwardRefExoticComponent<SkeletonProps & React.RefAttributes<HTMLDivElement>>;
|
|
49
|
+
interface SkeletonCircleProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
50
|
+
readonly size?: string | number;
|
|
51
|
+
readonly loading?: boolean;
|
|
52
|
+
}
|
|
53
|
+
declare const SkeletonCircle: React.ForwardRefExoticComponent<SkeletonCircleProps & React.RefAttributes<HTMLDivElement>>;
|
|
54
|
+
interface SkeletonTextProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
55
|
+
readonly noOfLines?: number;
|
|
56
|
+
readonly loading?: boolean;
|
|
57
|
+
}
|
|
58
|
+
declare const SkeletonText: React.ForwardRefExoticComponent<SkeletonTextProps & React.RefAttributes<HTMLDivElement>>;
|
|
59
|
+
|
|
60
|
+
export { Skeleton, SkeletonCircle, type SkeletonCircleProps, type SkeletonProps, SkeletonText, type SkeletonTextProps };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface SkeletonProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'> {
|
|
4
|
+
readonly loading: boolean | undefined;
|
|
5
|
+
/** When true, the Skeleton wraps its single child element instead of adding a wrapper div. */
|
|
6
|
+
readonly asChild?: boolean;
|
|
7
|
+
readonly w?: any;
|
|
8
|
+
readonly h?: any;
|
|
9
|
+
readonly minW?: any;
|
|
10
|
+
readonly maxW?: any;
|
|
11
|
+
readonly display?: string;
|
|
12
|
+
readonly flexGrow?: number;
|
|
13
|
+
readonly flexShrink?: number;
|
|
14
|
+
readonly flexBasis?: string;
|
|
15
|
+
readonly fontWeight?: number | string;
|
|
16
|
+
readonly textStyle?: string;
|
|
17
|
+
readonly borderRadius?: string;
|
|
18
|
+
readonly alignSelf?: string;
|
|
19
|
+
readonly alignItems?: string;
|
|
20
|
+
readonly justifyContent?: string;
|
|
21
|
+
readonly color?: string;
|
|
22
|
+
readonly mt?: number | string;
|
|
23
|
+
readonly mb?: number | string;
|
|
24
|
+
readonly ml?: number | string;
|
|
25
|
+
readonly mr?: number | string;
|
|
26
|
+
readonly height?: string;
|
|
27
|
+
readonly overflow?: string;
|
|
28
|
+
readonly whiteSpace?: string;
|
|
29
|
+
readonly textOverflow?: string;
|
|
30
|
+
readonly textTransform?: string;
|
|
31
|
+
readonly gap?: number | string;
|
|
32
|
+
readonly gridTemplateColumns?: string;
|
|
33
|
+
readonly minWidth?: string;
|
|
34
|
+
readonly boxSize?: number | string;
|
|
35
|
+
readonly py?: number | string;
|
|
36
|
+
readonly px?: number | string;
|
|
37
|
+
readonly p?: number | string;
|
|
38
|
+
readonly hideBelow?: string;
|
|
39
|
+
readonly as?: React.ElementType;
|
|
40
|
+
readonly fontSize?: string;
|
|
41
|
+
readonly flexWrap?: React.CSSProperties['flexWrap'];
|
|
42
|
+
readonly wordBreak?: React.CSSProperties['wordBreak'];
|
|
43
|
+
readonly lineHeight?: string;
|
|
44
|
+
readonly marginRight?: string;
|
|
45
|
+
readonly position?: React.CSSProperties['position'];
|
|
46
|
+
readonly background?: string;
|
|
47
|
+
}
|
|
48
|
+
declare const Skeleton: React.ForwardRefExoticComponent<SkeletonProps & React.RefAttributes<HTMLDivElement>>;
|
|
49
|
+
interface SkeletonCircleProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
50
|
+
readonly size?: string | number;
|
|
51
|
+
readonly loading?: boolean;
|
|
52
|
+
}
|
|
53
|
+
declare const SkeletonCircle: React.ForwardRefExoticComponent<SkeletonCircleProps & React.RefAttributes<HTMLDivElement>>;
|
|
54
|
+
interface SkeletonTextProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
55
|
+
readonly noOfLines?: number;
|
|
56
|
+
readonly loading?: boolean;
|
|
57
|
+
}
|
|
58
|
+
declare const SkeletonText: React.ForwardRefExoticComponent<SkeletonTextProps & React.RefAttributes<HTMLDivElement>>;
|
|
59
|
+
|
|
60
|
+
export { Skeleton, SkeletonCircle, type SkeletonCircleProps, type SkeletonProps, SkeletonText, type SkeletonTextProps };
|
package/dist/skeleton.js
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import { twMerge } from 'tailwind-merge';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
// src/skeleton.tsx
|
|
8
|
+
function cn(...inputs) {
|
|
9
|
+
return twMerge(clsx(inputs));
|
|
10
|
+
}
|
|
11
|
+
var SHIM_PROPS = [
|
|
12
|
+
"w",
|
|
13
|
+
"h",
|
|
14
|
+
"minW",
|
|
15
|
+
"maxW",
|
|
16
|
+
"display",
|
|
17
|
+
"flexGrow",
|
|
18
|
+
"flexShrink",
|
|
19
|
+
"flexBasis",
|
|
20
|
+
"fontWeight",
|
|
21
|
+
"textStyle",
|
|
22
|
+
"borderRadius",
|
|
23
|
+
"alignSelf",
|
|
24
|
+
"alignItems",
|
|
25
|
+
"justifyContent",
|
|
26
|
+
"color",
|
|
27
|
+
"mt",
|
|
28
|
+
"mb",
|
|
29
|
+
"ml",
|
|
30
|
+
"mr",
|
|
31
|
+
"height",
|
|
32
|
+
"overflow",
|
|
33
|
+
"whiteSpace",
|
|
34
|
+
"textOverflow",
|
|
35
|
+
"textTransform",
|
|
36
|
+
"gap",
|
|
37
|
+
"gridTemplateColumns",
|
|
38
|
+
"minWidth",
|
|
39
|
+
"boxSize",
|
|
40
|
+
"py",
|
|
41
|
+
"px",
|
|
42
|
+
"p",
|
|
43
|
+
"hideBelow",
|
|
44
|
+
"fontSize",
|
|
45
|
+
"flexWrap",
|
|
46
|
+
"wordBreak",
|
|
47
|
+
"lineHeight",
|
|
48
|
+
"marginRight",
|
|
49
|
+
"position",
|
|
50
|
+
"background"
|
|
51
|
+
];
|
|
52
|
+
var S = 4;
|
|
53
|
+
function dim(v) {
|
|
54
|
+
if (v == null) return void 0;
|
|
55
|
+
if (typeof v === "number") return `${v * S}px`;
|
|
56
|
+
if (typeof v === "string") return v;
|
|
57
|
+
if (typeof v === "object") {
|
|
58
|
+
const o = v;
|
|
59
|
+
return o.base ?? o.lg ?? o.xl ?? Object.values(o)[0];
|
|
60
|
+
}
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
function sp(v) {
|
|
64
|
+
if (v === void 0) return void 0;
|
|
65
|
+
return typeof v === "number" ? `${v * S}px` : v;
|
|
66
|
+
}
|
|
67
|
+
function shimToStyle(props) {
|
|
68
|
+
const s = {};
|
|
69
|
+
if (props.w !== void 0) s.width = dim(props.w);
|
|
70
|
+
if (props.h !== void 0) s.height = dim(props.h);
|
|
71
|
+
if (props.minW !== void 0) s.minWidth = dim(props.minW);
|
|
72
|
+
if (props.maxW !== void 0) s.maxWidth = dim(props.maxW);
|
|
73
|
+
if (props.display !== void 0) s.display = props.display;
|
|
74
|
+
if (props.flexGrow !== void 0) s.flexGrow = props.flexGrow;
|
|
75
|
+
if (props.flexShrink !== void 0) s.flexShrink = props.flexShrink;
|
|
76
|
+
if (props.flexBasis !== void 0) s.flexBasis = props.flexBasis;
|
|
77
|
+
if (props.fontWeight !== void 0) s.fontWeight = props.fontWeight;
|
|
78
|
+
if (props.borderRadius !== void 0) s.borderRadius = props.borderRadius;
|
|
79
|
+
if (props.alignSelf !== void 0) s.alignSelf = props.alignSelf;
|
|
80
|
+
if (props.alignItems !== void 0) s.alignItems = props.alignItems;
|
|
81
|
+
if (props.justifyContent !== void 0) s.justifyContent = props.justifyContent;
|
|
82
|
+
if (props.color !== void 0) s.color = props.color;
|
|
83
|
+
if (props.mt !== void 0) s.marginTop = sp(props.mt);
|
|
84
|
+
if (props.mb !== void 0) s.marginBottom = sp(props.mb);
|
|
85
|
+
if (props.ml !== void 0) s.marginLeft = sp(props.ml);
|
|
86
|
+
if (props.mr !== void 0) s.marginRight = sp(props.mr);
|
|
87
|
+
if (props.height !== void 0) s.height = props.height;
|
|
88
|
+
if (props.overflow !== void 0) s.overflow = props.overflow;
|
|
89
|
+
if (props.whiteSpace !== void 0) s.whiteSpace = props.whiteSpace;
|
|
90
|
+
if (props.textOverflow !== void 0) s.textOverflow = props.textOverflow;
|
|
91
|
+
if (props.textTransform !== void 0) s.textTransform = props.textTransform;
|
|
92
|
+
if (props.gap !== void 0) s.gap = sp(props.gap);
|
|
93
|
+
if (props.gridTemplateColumns !== void 0) s.gridTemplateColumns = props.gridTemplateColumns;
|
|
94
|
+
if (props.minWidth !== void 0) s.minWidth = props.minWidth;
|
|
95
|
+
if (props.boxSize !== void 0) {
|
|
96
|
+
const v = typeof props.boxSize === "number" ? `${props.boxSize * S}px` : props.boxSize;
|
|
97
|
+
s.width = v;
|
|
98
|
+
s.height = v;
|
|
99
|
+
}
|
|
100
|
+
if (props.py !== void 0) {
|
|
101
|
+
const v = sp(props.py);
|
|
102
|
+
s.paddingTop = v;
|
|
103
|
+
s.paddingBottom = v;
|
|
104
|
+
}
|
|
105
|
+
if (props.px !== void 0) {
|
|
106
|
+
const v = sp(props.px);
|
|
107
|
+
s.paddingLeft = v;
|
|
108
|
+
s.paddingRight = v;
|
|
109
|
+
}
|
|
110
|
+
if (props.p !== void 0) s.padding = sp(props.p);
|
|
111
|
+
if (props.fontSize !== void 0) s.fontSize = props.fontSize;
|
|
112
|
+
if (props.flexWrap !== void 0) s.flexWrap = props.flexWrap;
|
|
113
|
+
if (props.wordBreak !== void 0) s.wordBreak = props.wordBreak;
|
|
114
|
+
if (props.lineHeight !== void 0) s.lineHeight = props.lineHeight;
|
|
115
|
+
if (props.marginRight !== void 0) s.marginRight = props.marginRight;
|
|
116
|
+
if (props.position !== void 0) s.position = props.position;
|
|
117
|
+
if (props.background !== void 0) s.background = props.background;
|
|
118
|
+
return s;
|
|
119
|
+
}
|
|
120
|
+
function stripShims(props) {
|
|
121
|
+
const out = { ...props };
|
|
122
|
+
for (const k of SHIM_PROPS) delete out[k];
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
var SKELETON_CLASSES = [
|
|
126
|
+
"animate-skeleton-shimmer rounded-sm",
|
|
127
|
+
"bg-[linear-gradient(90deg,var(--color-skeleton-start)_0%,var(--color-skeleton-end)_50%,var(--color-skeleton-start)_100%)]",
|
|
128
|
+
"bg-[length:200%_100%]"
|
|
129
|
+
].join(" ");
|
|
130
|
+
var HIDE_BELOW_MAP = { lg: "lg:hidden", md: "md:hidden", sm: "sm:hidden" };
|
|
131
|
+
var Skeleton = React.forwardRef(
|
|
132
|
+
function Skeleton2(props, ref) {
|
|
133
|
+
const { loading = false, asChild, className, children, style: styleProp, as: Component = "div", ...allRest } = props;
|
|
134
|
+
const shimStyle = shimToStyle(props);
|
|
135
|
+
const mergedStyle = Object.keys(shimStyle).length > 0 || styleProp ? { ...shimStyle, ...styleProp } : void 0;
|
|
136
|
+
const hideBelowClass = props.hideBelow ? HIDE_BELOW_MAP[props.hideBelow] : void 0;
|
|
137
|
+
const cls = hideBelowClass ? cn(className, hideBelowClass) : className;
|
|
138
|
+
const htmlRest = stripShims(allRest);
|
|
139
|
+
if (!loading) {
|
|
140
|
+
if (asChild && React.isValidElement(children)) return children;
|
|
141
|
+
return /* @__PURE__ */ jsx(Component, { ref, className: cls, style: mergedStyle, ...htmlRest, children });
|
|
142
|
+
}
|
|
143
|
+
if (asChild && React.isValidElement(children)) {
|
|
144
|
+
return /* @__PURE__ */ jsx(
|
|
145
|
+
Component,
|
|
146
|
+
{
|
|
147
|
+
ref,
|
|
148
|
+
"data-loading": true,
|
|
149
|
+
className: cn(SKELETON_CLASSES, "text-transparent [&_*]:invisible", cls),
|
|
150
|
+
style: mergedStyle,
|
|
151
|
+
...htmlRest,
|
|
152
|
+
children
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
return /* @__PURE__ */ jsx(
|
|
157
|
+
Component,
|
|
158
|
+
{
|
|
159
|
+
ref,
|
|
160
|
+
"data-loading": true,
|
|
161
|
+
className: cn(SKELETON_CLASSES, children ? "text-transparent [&_*]:invisible" : "min-h-5", cls),
|
|
162
|
+
style: mergedStyle,
|
|
163
|
+
...htmlRest,
|
|
164
|
+
children
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
var SkeletonCircle = React.forwardRef(
|
|
170
|
+
function SkeletonCircle2(props, ref) {
|
|
171
|
+
const { size = 40, loading = true, className, ...rest } = props;
|
|
172
|
+
const dimension = typeof size === "number" ? `${size}px` : size;
|
|
173
|
+
return /* @__PURE__ */ jsx(
|
|
174
|
+
Skeleton,
|
|
175
|
+
{
|
|
176
|
+
ref,
|
|
177
|
+
loading,
|
|
178
|
+
className: cn("rounded-full shrink-0", className),
|
|
179
|
+
style: { width: dimension, height: dimension, ...rest.style },
|
|
180
|
+
...rest
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
var SkeletonText = React.forwardRef(
|
|
186
|
+
function SkeletonText2(props, ref) {
|
|
187
|
+
const { noOfLines = 3, loading = true, className, ...rest } = props;
|
|
188
|
+
return /* @__PURE__ */ jsx("div", { ref, className: cn("flex w-full flex-col gap-2", className), ...rest, children: Array.from({ length: noOfLines }).map((_, index) => /* @__PURE__ */ jsx(
|
|
189
|
+
Skeleton,
|
|
190
|
+
{
|
|
191
|
+
loading,
|
|
192
|
+
className: cn("h-4", index === noOfLines - 1 && "max-w-[80%]")
|
|
193
|
+
},
|
|
194
|
+
index
|
|
195
|
+
)) });
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
export { Skeleton, SkeletonCircle, SkeletonText };
|