@xaui/hybrid 0.0.2
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/README.md +16 -0
- package/dist/button/index.cjs +692 -0
- package/dist/button/index.d.cts +65 -0
- package/dist/button/index.d.ts +65 -0
- package/dist/button/index.js +261 -0
- package/dist/chunk-4GTYR4N2.js +86 -0
- package/dist/chunk-57VNE2OC.js +390 -0
- package/dist/core/index.cjs +125 -0
- package/dist/core/index.d.cts +20 -0
- package/dist/core/index.d.ts +20 -0
- package/dist/core/index.js +12 -0
- package/dist/index.cjs +18 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +0 -0
- package/dist/indicator/index.cjs +440 -0
- package/dist/indicator/index.d.cts +51 -0
- package/dist/indicator/index.d.ts +51 -0
- package/dist/indicator/index.js +7 -0
- package/dist/progress/index.cjs +292 -0
- package/dist/progress/index.d.cts +51 -0
- package/dist/progress/index.d.ts +51 -0
- package/dist/progress/index.js +241 -0
- package/dist/theme-qvIXI4kF.d.cts +3 -0
- package/dist/theme-qvIXI4kF.d.ts +3 -0
- package/package.json +85 -0
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# @xaui/hybrid
|
|
2
|
+
|
|
3
|
+
The documentation for `@xaui/hybrid` is not ready yet (“no doc yet”). In the meantime, explore the source under `packages/hybrid/src` to inspect the React/ReactDOM components, the `useXUITheme` hooks, and the `framer-motion`/`tailwindcss` integrations.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @xaui/hybrid
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Peer dependencies
|
|
12
|
+
|
|
13
|
+
- `react` ^18 || ^19
|
|
14
|
+
- `react-dom` ^18 || ^19
|
|
15
|
+
- `framer-motion` ^11
|
|
16
|
+
- `tailwindcss` ^4
|
|
@@ -0,0 +1,692 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/components/button/index.ts
|
|
31
|
+
var button_exports = {};
|
|
32
|
+
__export(button_exports, {
|
|
33
|
+
Button: () => Button
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(button_exports);
|
|
36
|
+
|
|
37
|
+
// src/components/button/button.tsx
|
|
38
|
+
var import_react5 = require("react");
|
|
39
|
+
var import_framer_motion3 = require("framer-motion");
|
|
40
|
+
|
|
41
|
+
// src/components/indicator/circular-activity-indicator.tsx
|
|
42
|
+
var import_react3 = require("react");
|
|
43
|
+
var import_framer_motion = require("framer-motion");
|
|
44
|
+
|
|
45
|
+
// src/core/theme-context.tsx
|
|
46
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
47
|
+
|
|
48
|
+
// src/core/theme-hooks.ts
|
|
49
|
+
var import_react = require("react");
|
|
50
|
+
function useXUITheme() {
|
|
51
|
+
const theme = (0, import_react.useContext)(XUIThemeContext);
|
|
52
|
+
if (!theme) {
|
|
53
|
+
throw new Error("useXUITheme must be used within XUIProvider");
|
|
54
|
+
}
|
|
55
|
+
return theme;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/core/theme-context.tsx
|
|
59
|
+
var import_theme = require("@xaui/core/theme");
|
|
60
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
61
|
+
var XUIThemeContext = (0, import_react2.createContext)(null);
|
|
62
|
+
|
|
63
|
+
// src/components/indicator/indicator.style.ts
|
|
64
|
+
var import_tailwind_variants = require("tailwind-variants");
|
|
65
|
+
var indicatorStyles = (0, import_tailwind_variants.tv)({
|
|
66
|
+
slots: {
|
|
67
|
+
base: "relative flex items-center justify-center overflow-hidden",
|
|
68
|
+
track: "overflow-hidden",
|
|
69
|
+
indicator: ""
|
|
70
|
+
},
|
|
71
|
+
variants: {
|
|
72
|
+
variant: {
|
|
73
|
+
linear: {
|
|
74
|
+
base: "w-full block",
|
|
75
|
+
track: "relative w-full h-full overflow-hidden",
|
|
76
|
+
indicator: "absolute top-0 bottom-0 left-0 transition-all"
|
|
77
|
+
},
|
|
78
|
+
circular: {
|
|
79
|
+
base: "inline-flex shrink-0",
|
|
80
|
+
track: "fill-none w-auto h-auto",
|
|
81
|
+
indicator: "fill-none w-auto h-auto"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
defaultVariants: {
|
|
86
|
+
variant: "linear"
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// src/components/indicator/circular-activity-indicator.tsx
|
|
91
|
+
var import_core2 = require("@xaui/core");
|
|
92
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
93
|
+
var DURATION = 1.5;
|
|
94
|
+
var EASING = [0.4, 0, 0.7, 1];
|
|
95
|
+
var bezierEasing = (t) => {
|
|
96
|
+
const [x1, y1, x2, y2] = EASING;
|
|
97
|
+
const cx = 3 * x1;
|
|
98
|
+
const bx = 3 * (x2 - x1) - cx;
|
|
99
|
+
const ax = 1 - cx - bx;
|
|
100
|
+
const cy = 3 * y1;
|
|
101
|
+
const by = 3 * (y2 - y1) - cy;
|
|
102
|
+
const ay = 1 - cy - by;
|
|
103
|
+
const sampleCurveX = (u2) => ((ax * u2 + bx) * u2 + cx) * u2;
|
|
104
|
+
const sampleCurveY = (u2) => ((ay * u2 + by) * u2 + cy) * u2;
|
|
105
|
+
let u = t;
|
|
106
|
+
for (let i = 0; i < 8; i++) {
|
|
107
|
+
const x = sampleCurveX(u) - t;
|
|
108
|
+
if (Math.abs(x) < 1e-3) break;
|
|
109
|
+
const slope = 3 * ax * u * u + 2 * bx * u + cx;
|
|
110
|
+
if (Math.abs(slope) < 1e-6) break;
|
|
111
|
+
u -= x / slope;
|
|
112
|
+
}
|
|
113
|
+
return sampleCurveY(u);
|
|
114
|
+
};
|
|
115
|
+
var generateKeyframes = (index, frames) => {
|
|
116
|
+
const rotationValue = index ? 360 - 15 : -(180 - 15);
|
|
117
|
+
const direction = index ? -1 : 1;
|
|
118
|
+
return Array.from({ length: frames }, (_, frameIndex) => {
|
|
119
|
+
let progress = 2 * frameIndex / (frames - 1);
|
|
120
|
+
if (progress > 1) progress = 2 - progress;
|
|
121
|
+
return direction * (180 - 30) * bezierEasing(progress) + rotationValue;
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
var CircularActivityIndicator = ({
|
|
125
|
+
size = 40,
|
|
126
|
+
themeColor = "primary",
|
|
127
|
+
color,
|
|
128
|
+
backgroundColor,
|
|
129
|
+
disableAnimation = false,
|
|
130
|
+
showTrack = true,
|
|
131
|
+
className
|
|
132
|
+
}) => {
|
|
133
|
+
const { base } = indicatorStyles({ variant: "circular" });
|
|
134
|
+
const theme = useXUITheme();
|
|
135
|
+
const safeThemeColor = (0, import_core2.getSafeThemeColor)(themeColor);
|
|
136
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
137
|
+
const resolvedColor = color ?? colorScheme.main;
|
|
138
|
+
const resolvedBackground = showTrack ? backgroundColor ?? colorScheme.background : "transparent";
|
|
139
|
+
const strokeWidth = size * 0.1;
|
|
140
|
+
const frames = Math.round(60 * DURATION);
|
|
141
|
+
const times = (0, import_react3.useMemo)(
|
|
142
|
+
() => Array.from({ length: frames }, (_, i) => i / (frames - 1)),
|
|
143
|
+
[frames]
|
|
144
|
+
);
|
|
145
|
+
const outerStart = 0 + 30 + 15;
|
|
146
|
+
const outerEnd = 2 * 360 + 30 + 15;
|
|
147
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
148
|
+
"div",
|
|
149
|
+
{
|
|
150
|
+
className: base({ className }),
|
|
151
|
+
style: { width: size, height: size, position: "relative" },
|
|
152
|
+
children: [
|
|
153
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
154
|
+
"div",
|
|
155
|
+
{
|
|
156
|
+
style: {
|
|
157
|
+
width: size,
|
|
158
|
+
height: size,
|
|
159
|
+
borderRadius: size / 2,
|
|
160
|
+
borderWidth: strokeWidth,
|
|
161
|
+
borderStyle: "solid",
|
|
162
|
+
borderColor: resolvedBackground,
|
|
163
|
+
boxSizing: "border-box"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
),
|
|
167
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
168
|
+
"div",
|
|
169
|
+
{
|
|
170
|
+
style: {
|
|
171
|
+
width: size,
|
|
172
|
+
height: size,
|
|
173
|
+
position: "absolute",
|
|
174
|
+
top: 0,
|
|
175
|
+
left: 0
|
|
176
|
+
},
|
|
177
|
+
children: [0, 1].map((index) => {
|
|
178
|
+
const keyframes = generateKeyframes(index, frames);
|
|
179
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
180
|
+
"div",
|
|
181
|
+
{
|
|
182
|
+
style: {
|
|
183
|
+
position: "absolute",
|
|
184
|
+
width: size,
|
|
185
|
+
height: size
|
|
186
|
+
},
|
|
187
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
188
|
+
import_framer_motion.motion.div,
|
|
189
|
+
{
|
|
190
|
+
style: {
|
|
191
|
+
width: size,
|
|
192
|
+
height: size,
|
|
193
|
+
transformOrigin: "50% 50%"
|
|
194
|
+
},
|
|
195
|
+
initial: { rotate: outerStart },
|
|
196
|
+
animate: disableAnimation ? { rotate: outerStart } : { rotate: outerEnd },
|
|
197
|
+
transition: disableAnimation ? { duration: 0 } : {
|
|
198
|
+
type: "tween",
|
|
199
|
+
duration: DURATION,
|
|
200
|
+
ease: "linear",
|
|
201
|
+
repeat: Infinity,
|
|
202
|
+
repeatType: "loop",
|
|
203
|
+
repeatDelay: 0
|
|
204
|
+
},
|
|
205
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
206
|
+
"div",
|
|
207
|
+
{
|
|
208
|
+
style: {
|
|
209
|
+
width: size,
|
|
210
|
+
height: size / 2,
|
|
211
|
+
overflow: "hidden",
|
|
212
|
+
position: "absolute",
|
|
213
|
+
...index ? { top: size / 2 } : {}
|
|
214
|
+
},
|
|
215
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
216
|
+
import_framer_motion.motion.div,
|
|
217
|
+
{
|
|
218
|
+
style: {
|
|
219
|
+
width: size,
|
|
220
|
+
height: size,
|
|
221
|
+
transformOrigin: "50% 50%"
|
|
222
|
+
},
|
|
223
|
+
initial: {
|
|
224
|
+
y: index ? -size / 2 : 0,
|
|
225
|
+
rotate: keyframes[0]
|
|
226
|
+
},
|
|
227
|
+
animate: disableAnimation ? { y: index ? -size / 2 : 0, rotate: keyframes[0] } : { y: index ? -size / 2 : 0, rotate: keyframes },
|
|
228
|
+
transition: disableAnimation ? { duration: 0 } : {
|
|
229
|
+
type: "tween",
|
|
230
|
+
duration: DURATION,
|
|
231
|
+
ease: "linear",
|
|
232
|
+
repeat: Infinity,
|
|
233
|
+
repeatType: "loop",
|
|
234
|
+
repeatDelay: 0,
|
|
235
|
+
times
|
|
236
|
+
},
|
|
237
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
238
|
+
"div",
|
|
239
|
+
{
|
|
240
|
+
style: {
|
|
241
|
+
width: size,
|
|
242
|
+
height: size / 2,
|
|
243
|
+
overflow: "hidden"
|
|
244
|
+
},
|
|
245
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
246
|
+
"div",
|
|
247
|
+
{
|
|
248
|
+
style: {
|
|
249
|
+
width: size,
|
|
250
|
+
height: size,
|
|
251
|
+
borderColor: resolvedColor,
|
|
252
|
+
borderWidth: strokeWidth,
|
|
253
|
+
borderStyle: "solid",
|
|
254
|
+
borderRadius: size / 2,
|
|
255
|
+
boxSizing: "border-box"
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
}
|
|
260
|
+
)
|
|
261
|
+
}
|
|
262
|
+
)
|
|
263
|
+
}
|
|
264
|
+
)
|
|
265
|
+
}
|
|
266
|
+
)
|
|
267
|
+
},
|
|
268
|
+
index
|
|
269
|
+
);
|
|
270
|
+
})
|
|
271
|
+
}
|
|
272
|
+
)
|
|
273
|
+
]
|
|
274
|
+
}
|
|
275
|
+
);
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
// src/components/indicator/linear-activity-indicator.tsx
|
|
279
|
+
var import_framer_motion2 = require("framer-motion");
|
|
280
|
+
var import_core4 = require("@xaui/core");
|
|
281
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
282
|
+
var DURATION_SECONDS = 2;
|
|
283
|
+
var PRIMARY_TRANSLATE_OFFSET = 1.45167;
|
|
284
|
+
var SECONDARY_TRANSLATE_OFFSET = 0.548889;
|
|
285
|
+
var toPercent = (value, offset) => `${(value - offset) * 100}%`;
|
|
286
|
+
var buildTimes = (durations) => {
|
|
287
|
+
const total = durations.reduce((sum, duration) => sum + duration, 0);
|
|
288
|
+
let acc = 0;
|
|
289
|
+
const intermediateTimes = durations.slice(0, -1).map((duration) => {
|
|
290
|
+
acc += duration;
|
|
291
|
+
return acc / total;
|
|
292
|
+
});
|
|
293
|
+
return [0, ...intermediateTimes, 1];
|
|
294
|
+
};
|
|
295
|
+
var primaryTranslateKeyframes = [0, 0, 0.836714, 2.00611].map(
|
|
296
|
+
(value) => toPercent(value, PRIMARY_TRANSLATE_OFFSET)
|
|
297
|
+
);
|
|
298
|
+
var primaryTranslateTimes = buildTimes([400, 783, 817]);
|
|
299
|
+
var primaryTranslateEase = [
|
|
300
|
+
"linear",
|
|
301
|
+
[0.5, 0, 0.701732, 0.495819],
|
|
302
|
+
[0.302435, 0.381352, 0.55, 0.956352]
|
|
303
|
+
];
|
|
304
|
+
var primaryScaleKeyframes = [0.08, 0.08, 0.661479, 0.08];
|
|
305
|
+
var primaryScaleTimes = buildTimes([733, 650, 617]);
|
|
306
|
+
var primaryScaleEase = [
|
|
307
|
+
"linear",
|
|
308
|
+
[0.334731, 0.12482, 0.785844, 1],
|
|
309
|
+
[0.06, 0.11, 0.6, 1]
|
|
310
|
+
];
|
|
311
|
+
var secondaryTranslateKeyframes = [0, 0.376519, 0.843862, 1.60278].map(
|
|
312
|
+
(value) => toPercent(value, SECONDARY_TRANSLATE_OFFSET)
|
|
313
|
+
);
|
|
314
|
+
var secondaryTranslateTimes = buildTimes([500, 467, 1033]);
|
|
315
|
+
var secondaryTranslateEase = [
|
|
316
|
+
[0.15, 0, 0.515058, 0.409685],
|
|
317
|
+
[0.31033, 0.284058, 0.8, 0.733712],
|
|
318
|
+
[0.4, 0.627035, 0.6, 0.902026]
|
|
319
|
+
];
|
|
320
|
+
var secondaryScaleKeyframes = [0.08, 0.457104, 0.72796, 0.08];
|
|
321
|
+
var secondaryScaleTimes = buildTimes([383, 500, 1117]);
|
|
322
|
+
var secondaryScaleEase = [
|
|
323
|
+
[0.205028, 0.057051, 0.57661, 0.453971],
|
|
324
|
+
[0.152313, 0.196432, 0.648374, 1.00432],
|
|
325
|
+
[0.257759, -3163e-6, 0.211762, 1.38179]
|
|
326
|
+
];
|
|
327
|
+
var LinearActivityIndicator = ({
|
|
328
|
+
size = 4,
|
|
329
|
+
themeColor = "primary",
|
|
330
|
+
color,
|
|
331
|
+
backgroundColor,
|
|
332
|
+
disableAnimation = false,
|
|
333
|
+
borderRadius = 0,
|
|
334
|
+
showTrack = true,
|
|
335
|
+
className
|
|
336
|
+
}) => {
|
|
337
|
+
const { base, track } = indicatorStyles({ variant: "linear" });
|
|
338
|
+
const theme = useXUITheme();
|
|
339
|
+
const safeThemeColor = (0, import_core4.getSafeThemeColor)(themeColor);
|
|
340
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
341
|
+
const mainColor = color ?? colorScheme.main;
|
|
342
|
+
const trackColor = showTrack ? backgroundColor ?? colorScheme.background : "transparent";
|
|
343
|
+
const radius = Math.max(0, borderRadius);
|
|
344
|
+
const primaryAnimate = disableAnimation ? { x: primaryTranslateKeyframes[0], scaleX: primaryScaleKeyframes[0] } : { x: primaryTranslateKeyframes, scaleX: primaryScaleKeyframes };
|
|
345
|
+
const secondaryAnimate = disableAnimation ? { x: secondaryTranslateKeyframes[0], scaleX: secondaryScaleKeyframes[0] } : { x: secondaryTranslateKeyframes, scaleX: secondaryScaleKeyframes };
|
|
346
|
+
const primaryTransition = disableAnimation ? { x: { duration: 0 }, scaleX: { duration: 0 } } : {
|
|
347
|
+
x: {
|
|
348
|
+
duration: DURATION_SECONDS,
|
|
349
|
+
ease: primaryTranslateEase,
|
|
350
|
+
times: primaryTranslateTimes,
|
|
351
|
+
repeat: Infinity,
|
|
352
|
+
repeatType: "loop"
|
|
353
|
+
},
|
|
354
|
+
scaleX: {
|
|
355
|
+
duration: DURATION_SECONDS,
|
|
356
|
+
ease: primaryScaleEase,
|
|
357
|
+
times: primaryScaleTimes,
|
|
358
|
+
repeat: Infinity,
|
|
359
|
+
repeatType: "loop"
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
const secondaryTransition = disableAnimation ? { x: { duration: 0 }, scaleX: { duration: 0 } } : {
|
|
363
|
+
x: {
|
|
364
|
+
duration: DURATION_SECONDS,
|
|
365
|
+
ease: secondaryTranslateEase,
|
|
366
|
+
times: secondaryTranslateTimes,
|
|
367
|
+
repeat: Infinity,
|
|
368
|
+
repeatType: "loop"
|
|
369
|
+
},
|
|
370
|
+
scaleX: {
|
|
371
|
+
duration: DURATION_SECONDS,
|
|
372
|
+
ease: secondaryScaleEase,
|
|
373
|
+
times: secondaryScaleTimes,
|
|
374
|
+
repeat: Infinity,
|
|
375
|
+
repeatType: "loop"
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: base({ className }), style: { height: size }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
379
|
+
"div",
|
|
380
|
+
{
|
|
381
|
+
className: track(),
|
|
382
|
+
style: {
|
|
383
|
+
position: "relative",
|
|
384
|
+
height: size,
|
|
385
|
+
backgroundColor: trackColor,
|
|
386
|
+
borderRadius: radius,
|
|
387
|
+
overflow: "hidden"
|
|
388
|
+
},
|
|
389
|
+
children: [
|
|
390
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
391
|
+
import_framer_motion2.motion.div,
|
|
392
|
+
{
|
|
393
|
+
initial: { x: primaryTranslateKeyframes[0], scaleX: primaryScaleKeyframes[0] },
|
|
394
|
+
animate: primaryAnimate,
|
|
395
|
+
transition: primaryTransition,
|
|
396
|
+
style: {
|
|
397
|
+
position: "absolute",
|
|
398
|
+
inset: 0,
|
|
399
|
+
width: "100%",
|
|
400
|
+
height: size,
|
|
401
|
+
backgroundColor: mainColor,
|
|
402
|
+
borderRadius: radius,
|
|
403
|
+
transformOrigin: "50% 50%"
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
),
|
|
407
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
408
|
+
import_framer_motion2.motion.div,
|
|
409
|
+
{
|
|
410
|
+
initial: {
|
|
411
|
+
x: secondaryTranslateKeyframes[0],
|
|
412
|
+
scaleX: secondaryScaleKeyframes[0]
|
|
413
|
+
},
|
|
414
|
+
animate: secondaryAnimate,
|
|
415
|
+
transition: secondaryTransition,
|
|
416
|
+
style: {
|
|
417
|
+
position: "absolute",
|
|
418
|
+
inset: 0,
|
|
419
|
+
width: "100%",
|
|
420
|
+
height: size,
|
|
421
|
+
backgroundColor: mainColor,
|
|
422
|
+
borderRadius: radius,
|
|
423
|
+
transformOrigin: "50% 50%"
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
)
|
|
427
|
+
]
|
|
428
|
+
}
|
|
429
|
+
) });
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
// src/components/indicator/indicator.tsx
|
|
433
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
434
|
+
var ActivityIndicator = (props) => {
|
|
435
|
+
const { variant = "circular", ...rest } = props;
|
|
436
|
+
if (variant === "circular") {
|
|
437
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { role: "progressbar", "aria-label": "Loading", className: "inline-flex", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CircularActivityIndicator, { ...rest }) });
|
|
438
|
+
}
|
|
439
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { role: "progressbar", "aria-label": "Loading", className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LinearActivityIndicator, { ...rest }) });
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
// src/components/button/button.style.ts
|
|
443
|
+
var import_tailwind_variants2 = require("tailwind-variants");
|
|
444
|
+
var buttonStyles = (0, import_tailwind_variants2.tv)({
|
|
445
|
+
slots: {
|
|
446
|
+
base: [
|
|
447
|
+
"inline-flex",
|
|
448
|
+
"items-center",
|
|
449
|
+
"justify-center",
|
|
450
|
+
"gap-2",
|
|
451
|
+
"overflow-hidden",
|
|
452
|
+
"font-medium",
|
|
453
|
+
"text-center",
|
|
454
|
+
"outline-none",
|
|
455
|
+
"cursor-pointer",
|
|
456
|
+
"select-none",
|
|
457
|
+
"transition-all",
|
|
458
|
+
"subpixel-antialiased",
|
|
459
|
+
"tap-highlight-transparent",
|
|
460
|
+
"transform-gpu"
|
|
461
|
+
]
|
|
462
|
+
},
|
|
463
|
+
variants: {
|
|
464
|
+
fullWidth: {
|
|
465
|
+
true: {
|
|
466
|
+
base: "w-full"
|
|
467
|
+
},
|
|
468
|
+
false: {
|
|
469
|
+
base: "inline-flex"
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
isDisabled: {
|
|
473
|
+
true: {
|
|
474
|
+
base: "opacity-50 cursor-not-allowed"
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
defaultVariants: {
|
|
479
|
+
fullWidth: false
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
// src/components/button/button.hook.ts
|
|
484
|
+
var import_react4 = require("react");
|
|
485
|
+
var useButtonStyles = (themeColor, variant, size, radius) => {
|
|
486
|
+
const theme = useXUITheme();
|
|
487
|
+
const colorScheme = theme.colors[themeColor];
|
|
488
|
+
const sizeStyles = (0, import_react4.useMemo)(() => {
|
|
489
|
+
const sizes = {
|
|
490
|
+
xs: {
|
|
491
|
+
paddingLeft: `${theme.spacing.sm}px`,
|
|
492
|
+
paddingRight: `${theme.spacing.sm}px`,
|
|
493
|
+
paddingTop: `${theme.spacing.xs}px`,
|
|
494
|
+
paddingBottom: `${theme.spacing.xs}px`,
|
|
495
|
+
minHeight: "28px",
|
|
496
|
+
fontSize: `${theme.fontSizes.xs}px`,
|
|
497
|
+
lineHeight: "1"
|
|
498
|
+
},
|
|
499
|
+
sm: {
|
|
500
|
+
paddingLeft: `${theme.spacing.md}px`,
|
|
501
|
+
paddingRight: `${theme.spacing.md}px`,
|
|
502
|
+
paddingTop: `${theme.spacing.xs}px`,
|
|
503
|
+
paddingBottom: `${theme.spacing.xs}px`,
|
|
504
|
+
minHeight: "32px",
|
|
505
|
+
fontSize: `${theme.fontSizes.sm}px`,
|
|
506
|
+
lineHeight: "1"
|
|
507
|
+
},
|
|
508
|
+
md: {
|
|
509
|
+
paddingLeft: `${theme.spacing.md}px`,
|
|
510
|
+
paddingRight: `${theme.spacing.md}px`,
|
|
511
|
+
paddingTop: `${theme.spacing.sm}px`,
|
|
512
|
+
paddingBottom: `${theme.spacing.sm}px`,
|
|
513
|
+
minHeight: "40px",
|
|
514
|
+
fontSize: `${theme.fontSizes.md}px`,
|
|
515
|
+
lineHeight: "1"
|
|
516
|
+
},
|
|
517
|
+
lg: {
|
|
518
|
+
paddingLeft: `${theme.spacing.lg}px`,
|
|
519
|
+
paddingRight: `${theme.spacing.lg}px`,
|
|
520
|
+
paddingTop: `${theme.spacing.md}px`,
|
|
521
|
+
paddingBottom: `${theme.spacing.md}px`,
|
|
522
|
+
minHeight: "48px",
|
|
523
|
+
fontSize: `${theme.fontSizes.lg}px`,
|
|
524
|
+
lineHeight: "1"
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
return sizes[size];
|
|
528
|
+
}, [size, theme]);
|
|
529
|
+
const radiusStyles = (0, import_react4.useMemo)(() => {
|
|
530
|
+
const radii = {
|
|
531
|
+
none: theme.borderRadius.none,
|
|
532
|
+
sm: theme.borderRadius.sm,
|
|
533
|
+
md: theme.borderRadius.md,
|
|
534
|
+
lg: theme.borderRadius.lg,
|
|
535
|
+
full: theme.borderRadius.full
|
|
536
|
+
};
|
|
537
|
+
return { borderRadius: `${radii[radius]}px` };
|
|
538
|
+
}, [radius, theme]);
|
|
539
|
+
const variantStyles = (0, import_react4.useMemo)(() => {
|
|
540
|
+
const styles = {
|
|
541
|
+
solid: {
|
|
542
|
+
backgroundColor: colorScheme.main,
|
|
543
|
+
borderWidth: "0",
|
|
544
|
+
color: colorScheme.foreground
|
|
545
|
+
},
|
|
546
|
+
outlined: {
|
|
547
|
+
backgroundColor: "transparent",
|
|
548
|
+
borderWidth: `${theme.borderWidth.md}px`,
|
|
549
|
+
borderStyle: "solid",
|
|
550
|
+
borderColor: colorScheme.main,
|
|
551
|
+
color: colorScheme.main
|
|
552
|
+
},
|
|
553
|
+
flat: {
|
|
554
|
+
backgroundColor: colorScheme.background,
|
|
555
|
+
borderWidth: "0",
|
|
556
|
+
color: colorScheme.main
|
|
557
|
+
},
|
|
558
|
+
light: {
|
|
559
|
+
backgroundColor: "transparent",
|
|
560
|
+
borderWidth: "0",
|
|
561
|
+
color: colorScheme.main
|
|
562
|
+
},
|
|
563
|
+
elevated: {
|
|
564
|
+
backgroundColor: colorScheme.main,
|
|
565
|
+
borderWidth: "0",
|
|
566
|
+
color: colorScheme.foreground,
|
|
567
|
+
boxShadow: typeof theme.shadows.md === "string" ? theme.shadows.md : "0 2px 4px rgba(0,0,0,0.1)"
|
|
568
|
+
},
|
|
569
|
+
faded: {
|
|
570
|
+
backgroundColor: `${colorScheme.background}90`,
|
|
571
|
+
borderWidth: `${theme.borderWidth.md}px`,
|
|
572
|
+
borderStyle: "solid",
|
|
573
|
+
borderColor: colorScheme.main,
|
|
574
|
+
color: colorScheme.main
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
return styles[variant];
|
|
578
|
+
}, [variant, colorScheme, theme]);
|
|
579
|
+
const textColor = (0, import_react4.useMemo)(() => {
|
|
580
|
+
if (variant === "solid" || variant === "elevated") {
|
|
581
|
+
return colorScheme.foreground;
|
|
582
|
+
}
|
|
583
|
+
return colorScheme.main;
|
|
584
|
+
}, [variant, colorScheme]);
|
|
585
|
+
const spinnerSize = (0, import_react4.useMemo)(() => {
|
|
586
|
+
const sizes = {
|
|
587
|
+
xs: 14,
|
|
588
|
+
sm: 16,
|
|
589
|
+
md: 18,
|
|
590
|
+
lg: 20
|
|
591
|
+
};
|
|
592
|
+
return sizes[size];
|
|
593
|
+
}, [size]);
|
|
594
|
+
return {
|
|
595
|
+
sizeStyles,
|
|
596
|
+
radiusStyles,
|
|
597
|
+
variantStyles,
|
|
598
|
+
textColor,
|
|
599
|
+
spinnerSize
|
|
600
|
+
};
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
// src/components/button/button.tsx
|
|
604
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
605
|
+
var Button = ({
|
|
606
|
+
children,
|
|
607
|
+
themeColor = "default",
|
|
608
|
+
variant = "solid",
|
|
609
|
+
size = "md",
|
|
610
|
+
radius = "md",
|
|
611
|
+
startContent,
|
|
612
|
+
endContent,
|
|
613
|
+
spinnerPlacement = "start",
|
|
614
|
+
fullWidth = false,
|
|
615
|
+
isDisabled = false,
|
|
616
|
+
isLoading = false,
|
|
617
|
+
className,
|
|
618
|
+
style: userStyle,
|
|
619
|
+
onMouseLeave,
|
|
620
|
+
onMouseDown,
|
|
621
|
+
onMouseUp,
|
|
622
|
+
...restProps
|
|
623
|
+
}) => {
|
|
624
|
+
const [isPressed, setIsPressed] = (0, import_react5.useState)(false);
|
|
625
|
+
const { base } = buttonStyles({ fullWidth, isDisabled });
|
|
626
|
+
const { sizeStyles, radiusStyles, variantStyles, textColor, spinnerSize } = useButtonStyles(themeColor, variant, size, radius);
|
|
627
|
+
const handleMouseDown = (event) => {
|
|
628
|
+
if (!isDisabled && !isLoading) {
|
|
629
|
+
setIsPressed(true);
|
|
630
|
+
}
|
|
631
|
+
onMouseDown?.(event);
|
|
632
|
+
};
|
|
633
|
+
const handleMouseUp = (event) => {
|
|
634
|
+
if (!isDisabled && !isLoading) {
|
|
635
|
+
setIsPressed(false);
|
|
636
|
+
}
|
|
637
|
+
onMouseUp?.(event);
|
|
638
|
+
};
|
|
639
|
+
const handleMouseLeave = (event) => {
|
|
640
|
+
if (!isDisabled && !isLoading) {
|
|
641
|
+
setIsPressed(false);
|
|
642
|
+
}
|
|
643
|
+
onMouseLeave?.(event);
|
|
644
|
+
};
|
|
645
|
+
const spinnerElement = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
646
|
+
ActivityIndicator,
|
|
647
|
+
{
|
|
648
|
+
variant: "circular",
|
|
649
|
+
showTrack: false,
|
|
650
|
+
themeColor: variant === "solid" || variant === "elevated" ? void 0 : themeColor,
|
|
651
|
+
color: variant === "solid" || variant === "elevated" ? textColor : void 0,
|
|
652
|
+
size: spinnerSize
|
|
653
|
+
}
|
|
654
|
+
);
|
|
655
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
656
|
+
import_framer_motion3.motion.button,
|
|
657
|
+
{
|
|
658
|
+
type: "button",
|
|
659
|
+
className: base({ className }),
|
|
660
|
+
disabled: isDisabled || isLoading,
|
|
661
|
+
onMouseLeave: handleMouseLeave,
|
|
662
|
+
onMouseDown: handleMouseDown,
|
|
663
|
+
onMouseUp: handleMouseUp,
|
|
664
|
+
...restProps,
|
|
665
|
+
style: {
|
|
666
|
+
...sizeStyles,
|
|
667
|
+
...radiusStyles,
|
|
668
|
+
...variantStyles,
|
|
669
|
+
...userStyle
|
|
670
|
+
},
|
|
671
|
+
animate: {
|
|
672
|
+
scale: isPressed ? 0.95 : 1,
|
|
673
|
+
opacity: isPressed ? 0.8 : 1
|
|
674
|
+
},
|
|
675
|
+
transition: {
|
|
676
|
+
duration: 0.1,
|
|
677
|
+
ease: "easeInOut"
|
|
678
|
+
},
|
|
679
|
+
children: [
|
|
680
|
+
startContent,
|
|
681
|
+
isLoading && spinnerPlacement === "start" && spinnerElement,
|
|
682
|
+
children,
|
|
683
|
+
isLoading && spinnerPlacement === "end" && spinnerElement,
|
|
684
|
+
endContent
|
|
685
|
+
]
|
|
686
|
+
}
|
|
687
|
+
);
|
|
688
|
+
};
|
|
689
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
690
|
+
0 && (module.exports = {
|
|
691
|
+
Button
|
|
692
|
+
});
|