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