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