@luxfi/ui 7.0.0 → 7.2.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.
Files changed (70) hide show
  1. package/dist/alert.cjs +184 -335
  2. package/dist/alert.js +184 -335
  3. package/dist/badge.cjs +162 -321
  4. package/dist/badge.d.cts +3 -7
  5. package/dist/badge.d.ts +3 -7
  6. package/dist/badge.js +162 -320
  7. package/dist/bank.d.cts +1 -1
  8. package/dist/bank.d.ts +1 -1
  9. package/dist/button.cjs +373 -484
  10. package/dist/button.d.cts +10 -7
  11. package/dist/button.d.ts +10 -7
  12. package/dist/button.js +373 -484
  13. package/dist/close-button.cjs +37 -18
  14. package/dist/close-button.d.cts +1 -1
  15. package/dist/close-button.d.ts +1 -1
  16. package/dist/close-button.js +37 -18
  17. package/dist/collapsible.cjs +125 -272
  18. package/dist/collapsible.js +125 -272
  19. package/dist/dialog.cjs +60 -44
  20. package/dist/dialog.d.cts +7 -8
  21. package/dist/dialog.d.ts +7 -8
  22. package/dist/dialog.js +60 -43
  23. package/dist/drawer.cjs +37 -13
  24. package/dist/drawer.js +37 -13
  25. package/dist/heading.cjs +3 -8
  26. package/dist/heading.js +3 -8
  27. package/dist/icon-button.cjs +213 -337
  28. package/dist/icon-button.d.cts +4 -4
  29. package/dist/icon-button.d.ts +4 -4
  30. package/dist/icon-button.js +213 -338
  31. package/dist/image.cjs +125 -272
  32. package/dist/image.js +125 -272
  33. package/dist/index.cjs +695 -858
  34. package/dist/index.d.cts +0 -3
  35. package/dist/index.d.ts +0 -3
  36. package/dist/index.js +695 -856
  37. package/dist/input.cjs +25 -36
  38. package/dist/input.js +25 -36
  39. package/dist/link.cjs +125 -272
  40. package/dist/link.js +125 -272
  41. package/dist/popover.cjs +55 -40
  42. package/dist/popover.js +55 -39
  43. package/dist/select.cjs +125 -272
  44. package/dist/select.js +125 -272
  45. package/dist/skeleton.cjs +125 -272
  46. package/dist/skeleton.js +125 -272
  47. package/dist/table.cjs +127 -274
  48. package/dist/table.js +127 -274
  49. package/dist/tag.cjs +199 -341
  50. package/dist/tag.js +199 -340
  51. package/dist/textarea.cjs +25 -36
  52. package/dist/textarea.js +25 -36
  53. package/dist/tooltip.cjs +22 -21
  54. package/dist/tooltip.d.cts +2 -3
  55. package/dist/tooltip.d.ts +2 -3
  56. package/dist/tooltip.js +22 -20
  57. package/package.json +9 -8
  58. package/src/alert.tsx +23 -51
  59. package/src/badge.tsx +20 -31
  60. package/src/button.tsx +304 -238
  61. package/src/close-button.tsx +48 -22
  62. package/src/dialog.tsx +37 -47
  63. package/src/heading.tsx +8 -19
  64. package/src/icon-button.tsx +129 -104
  65. package/src/input.tsx +27 -36
  66. package/src/popover.tsx +30 -44
  67. package/src/skeleton.tsx +96 -144
  68. package/src/tag.tsx +17 -35
  69. package/src/textarea.tsx +27 -36
  70. package/src/tooltip.tsx +54 -47
package/dist/table.js CHANGED
@@ -10,272 +10,137 @@ import { jsx, jsxs } from 'react/jsx-runtime';
10
10
  function cn(...inputs) {
11
11
  return twMerge(clsx(inputs));
12
12
  }
13
- var SPACING_SCALE = 4;
14
- function toStylePx(value) {
15
- if (value === void 0) return void 0;
16
- if (typeof value === "string") return value;
17
- return `${value * SPACING_SCALE}px`;
13
+ var SHIM_PROPS = [
14
+ "w",
15
+ "h",
16
+ "minW",
17
+ "maxW",
18
+ "display",
19
+ "flexGrow",
20
+ "flexShrink",
21
+ "flexBasis",
22
+ "fontWeight",
23
+ "textStyle",
24
+ "borderRadius",
25
+ "alignSelf",
26
+ "alignItems",
27
+ "justifyContent",
28
+ "color",
29
+ "mt",
30
+ "mb",
31
+ "ml",
32
+ "mr",
33
+ "height",
34
+ "overflow",
35
+ "whiteSpace",
36
+ "textOverflow",
37
+ "textTransform",
38
+ "gap",
39
+ "gridTemplateColumns",
40
+ "minWidth",
41
+ "boxSize",
42
+ "py",
43
+ "px",
44
+ "p",
45
+ "hideBelow",
46
+ "fontSize",
47
+ "flexWrap",
48
+ "wordBreak",
49
+ "lineHeight",
50
+ "marginRight",
51
+ "position",
52
+ "background"
53
+ ];
54
+ var S = 4;
55
+ function dim(v) {
56
+ if (v == null) return void 0;
57
+ if (typeof v === "number") return `${v * S}px`;
58
+ if (typeof v === "string") return v;
59
+ if (typeof v === "object") {
60
+ const o = v;
61
+ return o.base ?? o.lg ?? o.xl ?? Object.values(o)[0];
62
+ }
63
+ return void 0;
18
64
  }
19
- function extractSkeletonStyleProps(props) {
20
- const style = {};
21
- const rest = {};
22
- function resolveDimension(value) {
23
- if (value === void 0 || value === null) return void 0;
24
- if (typeof value === "number") return `${value * SPACING_SCALE}px`;
25
- if (typeof value === "string") return value;
26
- if (typeof value === "object") {
27
- const obj = value;
28
- return obj.base ?? obj.lg ?? obj.xl ?? Object.values(obj)[0];
29
- }
30
- return void 0;
65
+ function sp(v) {
66
+ if (v === void 0) return void 0;
67
+ return typeof v === "number" ? `${v * S}px` : v;
68
+ }
69
+ function shimToStyle(props) {
70
+ const s = {};
71
+ if (props.w !== void 0) s.width = dim(props.w);
72
+ if (props.h !== void 0) s.height = dim(props.h);
73
+ if (props.minW !== void 0) s.minWidth = dim(props.minW);
74
+ if (props.maxW !== void 0) s.maxWidth = dim(props.maxW);
75
+ if (props.display !== void 0) s.display = props.display;
76
+ if (props.flexGrow !== void 0) s.flexGrow = props.flexGrow;
77
+ if (props.flexShrink !== void 0) s.flexShrink = props.flexShrink;
78
+ if (props.flexBasis !== void 0) s.flexBasis = props.flexBasis;
79
+ if (props.fontWeight !== void 0) s.fontWeight = props.fontWeight;
80
+ if (props.borderRadius !== void 0) s.borderRadius = props.borderRadius;
81
+ if (props.alignSelf !== void 0) s.alignSelf = props.alignSelf;
82
+ if (props.alignItems !== void 0) s.alignItems = props.alignItems;
83
+ if (props.justifyContent !== void 0) s.justifyContent = props.justifyContent;
84
+ if (props.color !== void 0) s.color = props.color;
85
+ if (props.mt !== void 0) s.marginTop = sp(props.mt);
86
+ if (props.mb !== void 0) s.marginBottom = sp(props.mb);
87
+ if (props.ml !== void 0) s.marginLeft = sp(props.ml);
88
+ if (props.mr !== void 0) s.marginRight = sp(props.mr);
89
+ if (props.height !== void 0) s.height = props.height;
90
+ if (props.overflow !== void 0) s.overflow = props.overflow;
91
+ if (props.whiteSpace !== void 0) s.whiteSpace = props.whiteSpace;
92
+ if (props.textOverflow !== void 0) s.textOverflow = props.textOverflow;
93
+ if (props.textTransform !== void 0) s.textTransform = props.textTransform;
94
+ if (props.gap !== void 0) s.gap = sp(props.gap);
95
+ if (props.gridTemplateColumns !== void 0) s.gridTemplateColumns = props.gridTemplateColumns;
96
+ if (props.minWidth !== void 0) s.minWidth = props.minWidth;
97
+ if (props.boxSize !== void 0) {
98
+ const v = typeof props.boxSize === "number" ? `${props.boxSize * S}px` : props.boxSize;
99
+ s.width = v;
100
+ s.height = v;
31
101
  }
32
- for (const [key, value] of Object.entries(props)) {
33
- if (value === void 0) continue;
34
- switch (key) {
35
- case "w": {
36
- const v = resolveDimension(value);
37
- if (v) style.width = v;
38
- break;
39
- }
40
- case "h": {
41
- const v = resolveDimension(value);
42
- if (v) style.height = v;
43
- break;
44
- }
45
- case "minW": {
46
- const v = resolveDimension(value);
47
- if (v) style.minWidth = v;
48
- break;
49
- }
50
- case "maxW": {
51
- const v = resolveDimension(value);
52
- if (v) style.maxWidth = v;
53
- break;
54
- }
55
- case "height":
56
- style.height = value;
57
- break;
58
- case "display":
59
- style.display = value;
60
- break;
61
- case "flexGrow":
62
- style.flexGrow = value;
63
- break;
64
- case "flexShrink":
65
- style.flexShrink = value;
66
- break;
67
- case "flexBasis":
68
- style.flexBasis = value;
69
- break;
70
- case "fontWeight":
71
- style.fontWeight = value;
72
- break;
73
- case "borderRadius":
74
- style.borderRadius = value;
75
- break;
76
- case "alignSelf":
77
- style.alignSelf = value;
78
- break;
79
- case "alignItems":
80
- style.alignItems = value;
81
- break;
82
- case "justifyContent":
83
- style.justifyContent = value;
84
- break;
85
- case "color":
86
- style.color = value;
87
- break;
88
- case "mt":
89
- style.marginTop = toStylePx(value);
90
- break;
91
- case "mb":
92
- style.marginBottom = toStylePx(value);
93
- break;
94
- case "ml":
95
- style.marginLeft = toStylePx(value);
96
- break;
97
- case "mr":
98
- style.marginRight = toStylePx(value);
99
- break;
100
- case "overflow":
101
- style.overflow = value;
102
- break;
103
- case "whiteSpace":
104
- style.whiteSpace = value;
105
- break;
106
- case "textOverflow":
107
- style.textOverflow = value;
108
- break;
109
- case "textTransform":
110
- style.textTransform = value;
111
- break;
112
- case "gap":
113
- style.gap = typeof value === "number" ? `${value * SPACING_SCALE}px` : value;
114
- break;
115
- case "gridTemplateColumns":
116
- style.gridTemplateColumns = value;
117
- break;
118
- case "minWidth":
119
- style.minWidth = value;
120
- break;
121
- case "boxSize": {
122
- const s = typeof value === "number" ? `${value * SPACING_SCALE}px` : value;
123
- style.width = s;
124
- style.height = s;
125
- break;
126
- }
127
- case "py": {
128
- const v = toStylePx(value);
129
- style.paddingTop = v;
130
- style.paddingBottom = v;
131
- break;
132
- }
133
- case "px": {
134
- const v = toStylePx(value);
135
- style.paddingLeft = v;
136
- style.paddingRight = v;
137
- break;
138
- }
139
- case "p": {
140
- const v = toStylePx(value);
141
- style.padding = v;
142
- break;
143
- }
144
- case "hideBelow":
145
- break;
146
- // handled via className
147
- case "textStyle":
148
- break;
149
- // drop textStyle, not directly applicable
150
- case "fontSize":
151
- style.fontSize = value;
152
- break;
153
- case "flexWrap":
154
- style.flexWrap = value;
155
- break;
156
- case "wordBreak":
157
- style.wordBreak = value;
158
- break;
159
- case "lineHeight":
160
- style.lineHeight = value;
161
- break;
162
- case "marginRight":
163
- style.marginRight = value;
164
- break;
165
- case "position":
166
- style.position = value;
167
- break;
168
- case "background":
169
- style.background = value;
170
- break;
171
- default:
172
- rest[key] = value;
173
- break;
174
- }
102
+ if (props.py !== void 0) {
103
+ const v = sp(props.py);
104
+ s.paddingTop = v;
105
+ s.paddingBottom = v;
175
106
  }
176
- return { style, rest };
107
+ if (props.px !== void 0) {
108
+ const v = sp(props.px);
109
+ s.paddingLeft = v;
110
+ s.paddingRight = v;
111
+ }
112
+ if (props.p !== void 0) s.padding = sp(props.p);
113
+ if (props.fontSize !== void 0) s.fontSize = props.fontSize;
114
+ if (props.flexWrap !== void 0) s.flexWrap = props.flexWrap;
115
+ if (props.wordBreak !== void 0) s.wordBreak = props.wordBreak;
116
+ if (props.lineHeight !== void 0) s.lineHeight = props.lineHeight;
117
+ if (props.marginRight !== void 0) s.marginRight = props.marginRight;
118
+ if (props.position !== void 0) s.position = props.position;
119
+ if (props.background !== void 0) s.background = props.background;
120
+ return s;
177
121
  }
122
+ function stripShims(props) {
123
+ const out = { ...props };
124
+ for (const k of SHIM_PROPS) delete out[k];
125
+ return out;
126
+ }
127
+ var SKELETON_CLASSES = [
128
+ "animate-skeleton-shimmer rounded-sm",
129
+ "bg-[linear-gradient(90deg,var(--color-skeleton-start)_0%,var(--color-skeleton-end)_50%,var(--color-skeleton-start)_100%)]",
130
+ "bg-[length:200%_100%]"
131
+ ].join(" ");
132
+ var HIDE_BELOW_MAP = { lg: "lg:hidden", md: "md:hidden", sm: "sm:hidden" };
178
133
  var Skeleton = React3.forwardRef(
179
134
  function Skeleton2(props, ref) {
180
- const {
181
- loading = false,
182
- asChild,
183
- className,
184
- children,
185
- style: styleProp,
186
- // Destructure style-prop shims so they don't leak into DOM
187
- w: _w,
188
- h: _h,
189
- minW: _minW,
190
- maxW: _maxW,
191
- display: _display,
192
- flexGrow: _flexGrow,
193
- flexShrink: _flexShrink,
194
- flexBasis: _flexBasis,
195
- fontWeight: _fontWeight,
196
- textStyle: _textStyle,
197
- borderRadius: _borderRadius,
198
- alignSelf: _alignSelf,
199
- alignItems: _alignItems,
200
- justifyContent: _justifyContent,
201
- color: _color,
202
- mt: _mt,
203
- mb: _mb,
204
- ml: _ml,
205
- mr: _mr,
206
- height: _height,
207
- overflow: _overflow,
208
- whiteSpace: _whiteSpace,
209
- textOverflow: _textOverflow,
210
- textTransform: _textTransform,
211
- gap: _gap,
212
- gridTemplateColumns: _gridTemplateColumns,
213
- minWidth: _minWidth,
214
- boxSize: _boxSize,
215
- py: _py,
216
- px: _px,
217
- p: _p,
218
- hideBelow: _hideBelow,
219
- fontSize: _fontSize,
220
- flexWrap: _flexWrap,
221
- wordBreak: _wordBreak,
222
- lineHeight: _lineHeight,
223
- marginRight: _marginRight,
224
- position: _position,
225
- background: _background,
226
- as: Component = "div",
227
- ...htmlRest
228
- } = props;
229
- const { style: shimStyle } = extractSkeletonStyleProps({
230
- w: _w,
231
- h: _h,
232
- minW: _minW,
233
- maxW: _maxW,
234
- display: _display,
235
- flexGrow: _flexGrow,
236
- flexShrink: _flexShrink,
237
- flexBasis: _flexBasis,
238
- fontWeight: _fontWeight,
239
- textStyle: _textStyle,
240
- borderRadius: _borderRadius,
241
- alignSelf: _alignSelf,
242
- alignItems: _alignItems,
243
- justifyContent: _justifyContent,
244
- color: _color,
245
- mt: _mt,
246
- mb: _mb,
247
- ml: _ml,
248
- mr: _mr,
249
- height: _height,
250
- overflow: _overflow,
251
- whiteSpace: _whiteSpace,
252
- textOverflow: _textOverflow,
253
- textTransform: _textTransform,
254
- gap: _gap,
255
- gridTemplateColumns: _gridTemplateColumns,
256
- minWidth: _minWidth,
257
- boxSize: _boxSize,
258
- py: _py,
259
- px: _px,
260
- p: _p,
261
- hideBelow: _hideBelow,
262
- fontSize: _fontSize,
263
- flexWrap: _flexWrap,
264
- wordBreak: _wordBreak,
265
- lineHeight: _lineHeight,
266
- marginRight: _marginRight,
267
- position: _position,
268
- background: _background
269
- });
135
+ const { loading = false, asChild, className, children, style: styleProp, as: Component = "div", ...allRest } = props;
136
+ const shimStyle = shimToStyle(props);
270
137
  const mergedStyle = Object.keys(shimStyle).length > 0 || styleProp ? { ...shimStyle, ...styleProp } : void 0;
271
- const HIDE_BELOW_MAP = { lg: "lg:hidden", md: "md:hidden", sm: "sm:hidden" };
272
- const hideBelowClass = _hideBelow ? HIDE_BELOW_MAP[_hideBelow] : void 0;
273
- const finalClassName = hideBelowClass ? cn(className, hideBelowClass) : className;
138
+ const hideBelowClass = props.hideBelow ? HIDE_BELOW_MAP[props.hideBelow] : void 0;
139
+ const cls = hideBelowClass ? cn(className, hideBelowClass) : className;
140
+ const htmlRest = stripShims(allRest);
274
141
  if (!loading) {
275
- if (asChild && React3.isValidElement(children)) {
276
- return children;
277
- }
278
- return /* @__PURE__ */ jsx(Component, { ref, className: finalClassName, style: mergedStyle, ...htmlRest, children });
142
+ if (asChild && React3.isValidElement(children)) return children;
143
+ return /* @__PURE__ */ jsx(Component, { ref, className: cls, style: mergedStyle, ...htmlRest, children });
279
144
  }
280
145
  if (asChild && React3.isValidElement(children)) {
281
146
  return /* @__PURE__ */ jsx(
@@ -283,13 +148,7 @@ var Skeleton = React3.forwardRef(
283
148
  {
284
149
  ref,
285
150
  "data-loading": true,
286
- className: cn(
287
- "animate-skeleton-shimmer rounded-sm",
288
- "bg-[linear-gradient(90deg,var(--color-skeleton-start)_0%,var(--color-skeleton-end)_50%,var(--color-skeleton-start)_100%)]",
289
- "bg-[length:200%_100%]",
290
- "text-transparent [&_*]:invisible",
291
- finalClassName
292
- ),
151
+ className: cn(SKELETON_CLASSES, "text-transparent [&_*]:invisible", cls),
293
152
  style: mergedStyle,
294
153
  ...htmlRest,
295
154
  children
@@ -301,13 +160,7 @@ var Skeleton = React3.forwardRef(
301
160
  {
302
161
  ref,
303
162
  "data-loading": true,
304
- className: cn(
305
- "animate-skeleton-shimmer rounded-sm",
306
- "bg-[linear-gradient(90deg,var(--color-skeleton-start)_0%,var(--color-skeleton-end)_50%,var(--color-skeleton-start)_100%)]",
307
- "bg-[length:200%_100%]",
308
- children ? "text-transparent [&_*]:invisible" : "min-h-5",
309
- finalClassName
310
- ),
163
+ className: cn(SKELETON_CLASSES, children ? "text-transparent [&_*]:invisible" : "min-h-5", cls),
311
164
  style: mergedStyle,
312
165
  ...htmlRest,
313
166
  children
@@ -604,11 +457,11 @@ React3__default.forwardRef(
604
457
  }
605
458
  );
606
459
  var ArrowIcon2 = ({ className }) => /* @__PURE__ */ jsx("svg", { className, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { d: "M5 12h14M12 5l7 7-7 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) });
607
- var SPACING_SCALE2 = 4;
460
+ var SPACING_SCALE = 4;
608
461
  function toPixels(value) {
609
462
  if (value === void 0) return void 0;
610
463
  if (typeof value === "string") return value;
611
- return `${value * SPACING_SCALE2}px`;
464
+ return `${value * SPACING_SCALE}px`;
612
465
  }
613
466
  function extractStyles(props) {
614
467
  const style = {};