@zentauri-ui/zentauri-components 0.0.84 → 0.0.91
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 +47 -29
- package/dist/ui/accordion.cjs +311 -0
- package/dist/ui/accordion.cjs.map +1 -0
- package/dist/ui/accordion.d.cts +70 -0
- package/dist/ui/accordion.d.ts +70 -0
- package/dist/ui/accordion.js +286 -0
- package/dist/ui/accordion.js.map +1 -0
- package/dist/ui/alert.cjs +257 -0
- package/dist/ui/alert.cjs.map +1 -0
- package/dist/ui/alert.d.cts +66 -0
- package/dist/ui/alert.d.ts +66 -0
- package/dist/ui/alert.js +224 -0
- package/dist/ui/alert.js.map +1 -0
- package/dist/ui/badge.cjs +192 -0
- package/dist/ui/badge.cjs.map +1 -0
- package/dist/ui/badge.d.cts +37 -0
- package/dist/ui/badge.d.ts +37 -0
- package/dist/ui/badge.js +165 -0
- package/dist/ui/badge.js.map +1 -0
- package/dist/ui/buttons.cjs +202 -0
- package/dist/ui/buttons.cjs.map +1 -0
- package/dist/ui/buttons.d.cts +27 -0
- package/dist/ui/buttons.d.ts +27 -0
- package/dist/ui/buttons.js +176 -0
- package/dist/ui/buttons.js.map +1 -0
- package/dist/ui/card.cjs +293 -0
- package/dist/ui/card.cjs.map +1 -0
- package/dist/ui/card.d.cts +77 -0
- package/dist/ui/card.d.ts +77 -0
- package/dist/ui/card.js +258 -0
- package/dist/ui/card.js.map +1 -0
- package/dist/ui/divider.cjs +229 -0
- package/dist/ui/divider.cjs.map +1 -0
- package/dist/ui/divider.d.cts +39 -0
- package/dist/ui/divider.d.ts +39 -0
- package/dist/ui/divider.js +200 -0
- package/dist/ui/divider.js.map +1 -0
- package/dist/ui/drawer.cjs +408 -0
- package/dist/ui/drawer.cjs.map +1 -0
- package/dist/ui/drawer.d.cts +81 -0
- package/dist/ui/drawer.d.ts +81 -0
- package/dist/ui/drawer.js +383 -0
- package/dist/ui/drawer.js.map +1 -0
- package/dist/ui/dropdown.cjs +302 -0
- package/dist/ui/dropdown.cjs.map +1 -0
- package/dist/ui/dropdown.d.cts +50 -0
- package/dist/ui/dropdown.d.ts +50 -0
- package/dist/ui/dropdown.js +278 -0
- package/dist/ui/dropdown.js.map +1 -0
- package/dist/ui/empty-state.cjs +186 -0
- package/dist/ui/empty-state.cjs.map +1 -0
- package/dist/ui/empty-state.d.cts +55 -0
- package/dist/ui/empty-state.d.ts +55 -0
- package/dist/ui/empty-state.js +154 -0
- package/dist/ui/empty-state.js.map +1 -0
- package/dist/ui/index.d.cts +27 -1164
- package/dist/ui/index.d.ts +27 -1164
- package/dist/ui/inputs.cjs +458 -0
- package/dist/ui/inputs.cjs.map +1 -0
- package/dist/ui/inputs.d.cts +35 -0
- package/dist/ui/inputs.d.ts +35 -0
- package/dist/ui/inputs.js +432 -0
- package/dist/ui/inputs.js.map +1 -0
- package/dist/ui/modal.cjs +406 -0
- package/dist/ui/modal.cjs.map +1 -0
- package/dist/ui/modal.d.cts +84 -0
- package/dist/ui/modal.d.ts +84 -0
- package/dist/ui/modal.js +384 -0
- package/dist/ui/modal.js.map +1 -0
- package/dist/ui/pagination.cjs +523 -0
- package/dist/ui/pagination.cjs.map +1 -0
- package/dist/ui/pagination.d.cts +114 -0
- package/dist/ui/pagination.d.ts +114 -0
- package/dist/ui/pagination.js +494 -0
- package/dist/ui/pagination.js.map +1 -0
- package/dist/ui/progress.cjs +268 -0
- package/dist/ui/progress.cjs.map +1 -0
- package/dist/ui/progress.d.cts +61 -0
- package/dist/ui/progress.d.ts +61 -0
- package/dist/ui/progress.js +237 -0
- package/dist/ui/progress.js.map +1 -0
- package/dist/ui/select.cjs +360 -0
- package/dist/ui/select.cjs.map +1 -0
- package/dist/ui/select.d.cts +73 -0
- package/dist/ui/select.d.ts +73 -0
- package/dist/ui/select.js +327 -0
- package/dist/ui/select.js.map +1 -0
- package/dist/ui/skeleton.cjs +576 -0
- package/dist/ui/skeleton.cjs.map +1 -0
- package/dist/ui/skeleton.d.cts +90 -0
- package/dist/ui/skeleton.d.ts +90 -0
- package/dist/ui/skeleton.js +544 -0
- package/dist/ui/skeleton.js.map +1 -0
- package/dist/ui/spinner.cjs +219 -0
- package/dist/ui/spinner.cjs.map +1 -0
- package/dist/ui/spinner.d.cts +27 -0
- package/dist/ui/spinner.d.ts +27 -0
- package/dist/ui/spinner.js +193 -0
- package/dist/ui/spinner.js.map +1 -0
- package/dist/ui/table.cjs +328 -0
- package/dist/ui/table.cjs.map +1 -0
- package/dist/ui/table.d.cts +81 -0
- package/dist/ui/table.d.ts +81 -0
- package/dist/ui/table.js +293 -0
- package/dist/ui/table.js.map +1 -0
- package/dist/ui/tabs.cjs +300 -0
- package/dist/ui/tabs.cjs.map +1 -0
- package/dist/ui/tabs.d.cts +58 -0
- package/dist/ui/tabs.d.ts +58 -0
- package/dist/ui/tabs.js +274 -0
- package/dist/ui/tabs.js.map +1 -0
- package/dist/ui/toast.cjs +285 -0
- package/dist/ui/toast.cjs.map +1 -0
- package/dist/ui/toast.d.cts +86 -0
- package/dist/ui/toast.d.ts +86 -0
- package/dist/ui/toast.js +258 -0
- package/dist/ui/toast.js.map +1 -0
- package/dist/ui/toggle.cjs +185 -0
- package/dist/ui/toggle.cjs.map +1 -0
- package/dist/ui/toggle.d.cts +37 -0
- package/dist/ui/toggle.d.ts +37 -0
- package/dist/ui/toggle.js +158 -0
- package/dist/ui/toggle.js.map +1 -0
- package/dist/ui/tooltip.cjs +242 -0
- package/dist/ui/tooltip.cjs.map +1 -0
- package/dist/ui/tooltip.d.cts +46 -0
- package/dist/ui/tooltip.d.ts +46 -0
- package/dist/ui/tooltip.js +214 -0
- package/dist/ui/tooltip.js.map +1 -0
- package/dist/variants-1Bx3BEeS.d.cts +8 -0
- package/dist/variants-1Bx3BEeS.d.ts +8 -0
- package/package.json +7 -1
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/ui/progress/index.ts
|
|
21
|
+
var progress_exports = {};
|
|
22
|
+
__export(progress_exports, {
|
|
23
|
+
Progress: () => Progress,
|
|
24
|
+
ProgressBar: () => ProgressBar,
|
|
25
|
+
ProgressLabel: () => ProgressLabel,
|
|
26
|
+
ProgressValue: () => ProgressValue,
|
|
27
|
+
progressAnimationPresets: () => progressAnimationPresets,
|
|
28
|
+
progressBarVariants: () => progressBarVariants,
|
|
29
|
+
progressTrackVariants: () => progressTrackVariants,
|
|
30
|
+
progressVariants: () => progressVariants
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(progress_exports);
|
|
33
|
+
|
|
34
|
+
// src/ui/progress/progress.tsx
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
var import_framer_motion = require("framer-motion");
|
|
37
|
+
|
|
38
|
+
// src/lib/utils.ts
|
|
39
|
+
var import_clsx = require("clsx");
|
|
40
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
41
|
+
function cn(...inputs) {
|
|
42
|
+
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/ui/progress/animations.ts
|
|
46
|
+
var progressAnimationPresets = {
|
|
47
|
+
none: {},
|
|
48
|
+
shimmer: {
|
|
49
|
+
animate: { backgroundPosition: ["0% 0%", "100% 0%"] },
|
|
50
|
+
transition: { repeat: Infinity, duration: 1.2, ease: "linear" }
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/ui/progress/variants.ts
|
|
55
|
+
var import_class_variance_authority = require("class-variance-authority");
|
|
56
|
+
var progressVariants = (0, import_class_variance_authority.cva)("w-full text-slate-50", {
|
|
57
|
+
variants: {
|
|
58
|
+
appearance: {
|
|
59
|
+
default: "[--progress-fill:theme(colors.slate.50)]",
|
|
60
|
+
secondary: "[--progress-fill:theme(colors.slate.300)]",
|
|
61
|
+
destructive: "[--progress-fill:theme(colors.rose.400)]",
|
|
62
|
+
emerald: "[--progress-fill:theme(colors.emerald.400)]",
|
|
63
|
+
indigo: "[--progress-fill:theme(colors.indigo.400)]",
|
|
64
|
+
purple: "[--progress-fill:theme(colors.purple.400)]",
|
|
65
|
+
pink: "[--progress-fill:theme(colors.pink.400)]",
|
|
66
|
+
rose: "[--progress-fill:theme(colors.rose.400)]",
|
|
67
|
+
sky: "[--progress-fill:theme(colors.sky.400)]",
|
|
68
|
+
teal: "[--progress-fill:theme(colors.teal.400)]",
|
|
69
|
+
yellow: "[--progress-fill:theme(colors.yellow.400)]",
|
|
70
|
+
orange: "[--progress-fill:theme(colors.orange.400)]",
|
|
71
|
+
outline: "[--progress-fill:theme(colors.cyan.300)]",
|
|
72
|
+
ghost: "[--progress-fill:theme(colors.slate.200)]",
|
|
73
|
+
glass: "[--progress-fill:theme(colors.white)]",
|
|
74
|
+
"gradient-blue": "[--progress-fill:linear-gradient(90deg,theme(colors.blue.500),theme(colors.purple.500))]",
|
|
75
|
+
"gradient-green": "[--progress-fill:linear-gradient(90deg,theme(colors.green.500),theme(colors.lime.500))]",
|
|
76
|
+
"gradient-red": "[--progress-fill:linear-gradient(90deg,theme(colors.red.500),theme(colors.pink.500))]",
|
|
77
|
+
"gradient-yellow": "[--progress-fill:linear-gradient(90deg,theme(colors.yellow.500),theme(colors.orange.500))]",
|
|
78
|
+
"gradient-purple": "[--progress-fill:linear-gradient(90deg,theme(colors.purple.500),theme(colors.pink.500))]",
|
|
79
|
+
"gradient-teal": "[--progress-fill:linear-gradient(90deg,theme(colors.teal.500),theme(colors.cyan.500))]",
|
|
80
|
+
"gradient-indigo": "[--progress-fill:linear-gradient(90deg,theme(colors.indigo.500),theme(colors.purple.500))]",
|
|
81
|
+
"gradient-pink": "[--progress-fill:linear-gradient(90deg,theme(colors.pink.500),theme(colors.rose.500))]",
|
|
82
|
+
"gradient-orange": "[--progress-fill:linear-gradient(90deg,theme(colors.orange.500),theme(colors.red.500))]"
|
|
83
|
+
},
|
|
84
|
+
size: {
|
|
85
|
+
xs: "text-[0.65rem]",
|
|
86
|
+
sm: "text-xs",
|
|
87
|
+
md: "text-sm",
|
|
88
|
+
lg: "text-base",
|
|
89
|
+
xl: "text-lg"
|
|
90
|
+
},
|
|
91
|
+
shape: {
|
|
92
|
+
flat: "rounded-none",
|
|
93
|
+
rounded: "rounded-md",
|
|
94
|
+
pill: "rounded-full"
|
|
95
|
+
},
|
|
96
|
+
striped: {
|
|
97
|
+
true: "",
|
|
98
|
+
false: ""
|
|
99
|
+
},
|
|
100
|
+
animated: {
|
|
101
|
+
true: "",
|
|
102
|
+
false: ""
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
defaultVariants: {
|
|
106
|
+
appearance: "default",
|
|
107
|
+
size: "md",
|
|
108
|
+
shape: "rounded",
|
|
109
|
+
striped: false,
|
|
110
|
+
animated: false
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
var progressTrackVariants = (0, import_class_variance_authority.cva)("relative w-full overflow-hidden bg-white/10", {
|
|
114
|
+
variants: {
|
|
115
|
+
size: {
|
|
116
|
+
xs: "h-1",
|
|
117
|
+
sm: "h-1.5",
|
|
118
|
+
md: "h-2",
|
|
119
|
+
lg: "h-3",
|
|
120
|
+
xl: "h-4"
|
|
121
|
+
},
|
|
122
|
+
shape: {
|
|
123
|
+
flat: "rounded-none",
|
|
124
|
+
rounded: "rounded-md",
|
|
125
|
+
pill: "rounded-full"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
defaultVariants: {
|
|
129
|
+
size: "md",
|
|
130
|
+
shape: "rounded"
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
var progressBarVariants = (0, import_class_variance_authority.cva)(
|
|
134
|
+
"h-full w-full origin-left rounded-[inherit]",
|
|
135
|
+
{
|
|
136
|
+
variants: {
|
|
137
|
+
striped: {
|
|
138
|
+
true: "bg-[repeating-linear-gradient(135deg,rgba(255,255,255,0.18)_0,rgba(255,255,255,0.18)_10px,transparent_10px,transparent_20px)]",
|
|
139
|
+
false: "[background:var(--progress-fill)]"
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
defaultVariants: { striped: false }
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
// src/ui/progress/progress.tsx
|
|
147
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
148
|
+
var ProgressContext = (0, import_react.createContext)(null);
|
|
149
|
+
function useProgressContext(component) {
|
|
150
|
+
const ctx = (0, import_react.useContext)(ProgressContext);
|
|
151
|
+
if (!ctx) {
|
|
152
|
+
throw new Error(`${component} must be used within <Progress>`);
|
|
153
|
+
}
|
|
154
|
+
return ctx;
|
|
155
|
+
}
|
|
156
|
+
function clamp(value, min, max) {
|
|
157
|
+
return Math.min(max, Math.max(min, value));
|
|
158
|
+
}
|
|
159
|
+
function Progress(props) {
|
|
160
|
+
const {
|
|
161
|
+
className,
|
|
162
|
+
appearance = "default",
|
|
163
|
+
size = "md",
|
|
164
|
+
shape = "rounded",
|
|
165
|
+
striped = false,
|
|
166
|
+
animated = false,
|
|
167
|
+
animation = "none",
|
|
168
|
+
value = 0,
|
|
169
|
+
min = 0,
|
|
170
|
+
max = 100,
|
|
171
|
+
label,
|
|
172
|
+
children,
|
|
173
|
+
ref,
|
|
174
|
+
...rest
|
|
175
|
+
} = props;
|
|
176
|
+
const motionProps = progressAnimationPresets[animation];
|
|
177
|
+
const clamped = clamp(value, min, max);
|
|
178
|
+
const percent = max === min ? 0 : (clamped - min) / (max - min) * 100;
|
|
179
|
+
const ctx = (0, import_react.useMemo)(
|
|
180
|
+
() => ({
|
|
181
|
+
value: clamped,
|
|
182
|
+
min,
|
|
183
|
+
max,
|
|
184
|
+
size: size ?? "md",
|
|
185
|
+
shape: shape ?? "rounded",
|
|
186
|
+
striped: Boolean(striped),
|
|
187
|
+
animated: Boolean(animated),
|
|
188
|
+
appearance: appearance ?? "default"
|
|
189
|
+
}),
|
|
190
|
+
[animated, appearance, clamped, max, min, shape, size, striped]
|
|
191
|
+
);
|
|
192
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProgressContext.Provider, { value: ctx, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
193
|
+
import_framer_motion.motion.div,
|
|
194
|
+
{
|
|
195
|
+
ref,
|
|
196
|
+
"data-slot": "progress",
|
|
197
|
+
role: "progressbar",
|
|
198
|
+
"aria-valuemin": min,
|
|
199
|
+
"aria-valuemax": max,
|
|
200
|
+
"aria-valuenow": clamped,
|
|
201
|
+
"aria-label": label,
|
|
202
|
+
className: cn(
|
|
203
|
+
progressVariants({ appearance, size, shape, striped, animated }),
|
|
204
|
+
className
|
|
205
|
+
),
|
|
206
|
+
initial: false,
|
|
207
|
+
...motionProps,
|
|
208
|
+
...rest,
|
|
209
|
+
children: children ?? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProgressBar, { style: { transform: `scaleX(${percent / 100})` } }) })
|
|
210
|
+
}
|
|
211
|
+
) });
|
|
212
|
+
}
|
|
213
|
+
Progress.displayName = "Progress";
|
|
214
|
+
function ProgressBar({
|
|
215
|
+
className,
|
|
216
|
+
style,
|
|
217
|
+
ref,
|
|
218
|
+
...rest
|
|
219
|
+
}) {
|
|
220
|
+
const { size, shape, striped, animated } = useProgressContext("ProgressBar");
|
|
221
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
222
|
+
"div",
|
|
223
|
+
{
|
|
224
|
+
"data-slot": "progress-track",
|
|
225
|
+
className: cn(progressTrackVariants({ size, shape }), "text-current"),
|
|
226
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
227
|
+
import_framer_motion.motion.div,
|
|
228
|
+
{
|
|
229
|
+
ref,
|
|
230
|
+
"data-slot": "progress-bar",
|
|
231
|
+
className: cn(progressBarVariants({ striped }), className),
|
|
232
|
+
style: {
|
|
233
|
+
transformOrigin: "left center",
|
|
234
|
+
...style
|
|
235
|
+
},
|
|
236
|
+
animate: animated ? { x: ["-30%", "0%"], opacity: [0.85, 1] } : void 0,
|
|
237
|
+
transition: animated ? { repeat: Infinity, duration: 1.1, ease: "easeInOut" } : void 0,
|
|
238
|
+
...rest
|
|
239
|
+
}
|
|
240
|
+
)
|
|
241
|
+
}
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
ProgressBar.displayName = "ProgressBar";
|
|
245
|
+
function ProgressLabel({ className, children }) {
|
|
246
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-slot": "progress-label", className: cn("mb-2 font-medium text-slate-200", className), children });
|
|
247
|
+
}
|
|
248
|
+
ProgressLabel.displayName = "ProgressLabel";
|
|
249
|
+
function ProgressValue({ className, children }) {
|
|
250
|
+
const { value, min, max } = useProgressContext("ProgressValue");
|
|
251
|
+
const range = max - min;
|
|
252
|
+
const pct = range === 0 ? 0 : Math.round((value - min) / range * 100);
|
|
253
|
+
const content = children ?? `${pct}%`;
|
|
254
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-slot": "progress-value", className: cn("mt-2 text-right text-slate-400", className), children: content });
|
|
255
|
+
}
|
|
256
|
+
ProgressValue.displayName = "ProgressValue";
|
|
257
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
258
|
+
0 && (module.exports = {
|
|
259
|
+
Progress,
|
|
260
|
+
ProgressBar,
|
|
261
|
+
ProgressLabel,
|
|
262
|
+
ProgressValue,
|
|
263
|
+
progressAnimationPresets,
|
|
264
|
+
progressBarVariants,
|
|
265
|
+
progressTrackVariants,
|
|
266
|
+
progressVariants
|
|
267
|
+
});
|
|
268
|
+
//# sourceMappingURL=progress.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/progress/index.ts","../../src/ui/progress/progress.tsx","../../src/lib/utils.ts","../../src/ui/progress/animations.ts","../../src/ui/progress/variants.ts"],"sourcesContent":["export { Progress, ProgressBar, ProgressLabel, ProgressValue } from \"./progress\";\nexport type { ProgressAnimation, ProgressProps, ProgressSectionProps } from \"./types\";\nexport { progressAnimationPresets } from \"./animations\";\nexport { progressVariants, progressTrackVariants, progressBarVariants } from \"./variants\";\n","\"use client\";\n\nimport { createContext, useContext, useMemo } from \"react\";\nimport { motion } from \"framer-motion\";\n\nimport { cn } from \"../../lib/utils\";\n\nimport { progressAnimationPresets } from \"./animations\";\nimport type { ProgressProps, ProgressSectionProps } from \"./types\";\nimport {\n progressBarVariants,\n progressTrackVariants,\n progressVariants,\n} from \"./variants\";\n\ntype ProgressCtx = {\n value: number;\n min: number;\n max: number;\n size: NonNullable<ProgressProps[\"size\"]>;\n shape: NonNullable<ProgressProps[\"shape\"]>;\n striped: boolean;\n animated: boolean;\n appearance: NonNullable<ProgressProps[\"appearance\"]>;\n};\n\nconst ProgressContext = createContext<ProgressCtx | null>(null);\n\nfunction useProgressContext(component: string): ProgressCtx {\n const ctx = useContext(ProgressContext);\n if (!ctx) {\n throw new Error(`${component} must be used within <Progress>`);\n }\n return ctx;\n}\n\nfunction clamp(value: number, min: number, max: number) {\n return Math.min(max, Math.max(min, value));\n}\n\nexport function Progress(props: ProgressProps) {\n const {\n className,\n appearance = \"default\",\n size = \"md\",\n shape = \"rounded\",\n striped = false,\n animated = false,\n animation = \"none\",\n value = 0,\n min = 0,\n max = 100,\n label,\n children,\n ref,\n ...rest\n } = props;\n const motionProps = progressAnimationPresets[animation];\n const clamped = clamp(value, min, max);\n const percent = max === min ? 0 : ((clamped - min) / (max - min)) * 100;\n\n const ctx = useMemo(\n () => ({\n value: clamped,\n min,\n max,\n size: size ?? \"md\",\n shape: shape ?? \"rounded\",\n striped: Boolean(striped),\n animated: Boolean(animated),\n appearance: appearance ?? \"default\",\n }),\n [animated, appearance, clamped, max, min, shape, size, striped],\n );\n\n return (\n <ProgressContext.Provider value={ctx}>\n <motion.div\n ref={ref}\n data-slot=\"progress\"\n role=\"progressbar\"\n aria-valuemin={min}\n aria-valuemax={max}\n aria-valuenow={clamped}\n aria-label={label}\n className={cn(\n progressVariants({ appearance, size, shape, striped, animated }),\n className,\n )}\n initial={false}\n {...motionProps}\n {...rest}\n >\n {children ?? (\n <>\n <ProgressBar style={{ transform: `scaleX(${percent / 100})` }} />\n </>\n )}\n </motion.div>\n </ProgressContext.Provider>\n );\n}\n\nProgress.displayName = \"Progress\";\n\nexport function ProgressBar({\n className,\n style,\n ref,\n ...rest\n}: ProgressSectionProps & { style?: React.CSSProperties; ref?: React.Ref<HTMLDivElement> }) {\n const { size, shape, striped, animated } = useProgressContext(\"ProgressBar\");\n\n return (\n <div\n data-slot=\"progress-track\"\n className={cn(progressTrackVariants({ size, shape }), \"text-current\")}\n >\n <motion.div\n ref={ref}\n data-slot=\"progress-bar\"\n className={cn(progressBarVariants({ striped }), className)}\n style={{\n transformOrigin: \"left center\",\n ...style,\n }}\n animate={\n animated\n ? { x: [\"-30%\", \"0%\"], opacity: [0.85, 1] }\n : undefined\n }\n transition={\n animated\n ? { repeat: Infinity, duration: 1.1, ease: \"easeInOut\" }\n : undefined\n }\n {...rest}\n />\n </div>\n );\n}\n\nProgressBar.displayName = \"ProgressBar\";\n\nexport function ProgressLabel({ className, children }: ProgressSectionProps) {\n return (\n <div data-slot=\"progress-label\" className={cn(\"mb-2 font-medium text-slate-200\", className)}>\n {children}\n </div>\n );\n}\n\nProgressLabel.displayName = \"ProgressLabel\";\n\nexport function ProgressValue({ className, children }: ProgressSectionProps) {\n const { value, min, max } = useProgressContext(\"ProgressValue\");\n const range = max - min;\n const pct = range === 0 ? 0 : Math.round(((value - min) / range) * 100);\n const content = children ?? `${pct}%`;\n return (\n <div data-slot=\"progress-value\" className={cn(\"mt-2 text-right text-slate-400\", className)}>\n {content}\n </div>\n );\n}\n\nProgressValue.displayName = \"ProgressValue\";\n","import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}","import type { HTMLMotionProps } from \"framer-motion\";\n\nimport type { ProgressAnimation } from \"./types\";\n\ntype ProgressPresetMotionProps = Pick<\n HTMLMotionProps<\"div\">,\n \"transition\" | \"animate\"\n>;\n\nexport type ProgressAnimationPresets = Record<\n ProgressAnimation,\n ProgressPresetMotionProps\n>;\n\nexport const progressAnimationPresets: ProgressAnimationPresets = {\n none: {},\n shimmer: {\n animate: { backgroundPosition: [\"0% 0%\", \"100% 0%\"] },\n transition: { repeat: Infinity, duration: 1.2, ease: \"linear\" },\n },\n};\n","import { cva } from \"class-variance-authority\";\n\nexport const progressVariants = cva(\"w-full text-slate-50\", {\n variants: {\n appearance: {\n default: \"[--progress-fill:theme(colors.slate.50)]\",\n secondary: \"[--progress-fill:theme(colors.slate.300)]\",\n destructive: \"[--progress-fill:theme(colors.rose.400)]\",\n emerald: \"[--progress-fill:theme(colors.emerald.400)]\",\n indigo: \"[--progress-fill:theme(colors.indigo.400)]\",\n purple: \"[--progress-fill:theme(colors.purple.400)]\",\n pink: \"[--progress-fill:theme(colors.pink.400)]\",\n rose: \"[--progress-fill:theme(colors.rose.400)]\",\n sky: \"[--progress-fill:theme(colors.sky.400)]\",\n teal: \"[--progress-fill:theme(colors.teal.400)]\",\n yellow: \"[--progress-fill:theme(colors.yellow.400)]\",\n orange: \"[--progress-fill:theme(colors.orange.400)]\",\n outline: \"[--progress-fill:theme(colors.cyan.300)]\",\n ghost: \"[--progress-fill:theme(colors.slate.200)]\",\n glass: \"[--progress-fill:theme(colors.white)]\",\n \"gradient-blue\":\n \"[--progress-fill:linear-gradient(90deg,theme(colors.blue.500),theme(colors.purple.500))]\",\n \"gradient-green\":\n \"[--progress-fill:linear-gradient(90deg,theme(colors.green.500),theme(colors.lime.500))]\",\n \"gradient-red\":\n \"[--progress-fill:linear-gradient(90deg,theme(colors.red.500),theme(colors.pink.500))]\",\n \"gradient-yellow\":\n \"[--progress-fill:linear-gradient(90deg,theme(colors.yellow.500),theme(colors.orange.500))]\",\n \"gradient-purple\":\n \"[--progress-fill:linear-gradient(90deg,theme(colors.purple.500),theme(colors.pink.500))]\",\n \"gradient-teal\":\n \"[--progress-fill:linear-gradient(90deg,theme(colors.teal.500),theme(colors.cyan.500))]\",\n \"gradient-indigo\":\n \"[--progress-fill:linear-gradient(90deg,theme(colors.indigo.500),theme(colors.purple.500))]\",\n \"gradient-pink\":\n \"[--progress-fill:linear-gradient(90deg,theme(colors.pink.500),theme(colors.rose.500))]\",\n \"gradient-orange\":\n \"[--progress-fill:linear-gradient(90deg,theme(colors.orange.500),theme(colors.red.500))]\",\n },\n size: {\n xs: \"text-[0.65rem]\",\n sm: \"text-xs\",\n md: \"text-sm\",\n lg: \"text-base\",\n xl: \"text-lg\",\n },\n shape: {\n flat: \"rounded-none\",\n rounded: \"rounded-md\",\n pill: \"rounded-full\",\n },\n striped: {\n true: \"\",\n false: \"\",\n },\n animated: {\n true: \"\",\n false: \"\",\n },\n },\n defaultVariants: {\n appearance: \"default\",\n size: \"md\",\n shape: \"rounded\",\n striped: false,\n animated: false,\n },\n});\n\nexport const progressTrackVariants = cva(\"relative w-full overflow-hidden bg-white/10\", {\n variants: {\n size: {\n xs: \"h-1\",\n sm: \"h-1.5\",\n md: \"h-2\",\n lg: \"h-3\",\n xl: \"h-4\",\n },\n shape: {\n flat: \"rounded-none\",\n rounded: \"rounded-md\",\n pill: \"rounded-full\",\n },\n },\n defaultVariants: {\n size: \"md\",\n shape: \"rounded\",\n },\n});\n\nexport const progressBarVariants = cva(\n \"h-full w-full origin-left rounded-[inherit]\",\n {\n variants: {\n striped: {\n true: \"bg-[repeating-linear-gradient(135deg,rgba(255,255,255,0.18)_0,rgba(255,255,255,0.18)_10px,transparent_10px,transparent_20px)]\",\n false: \"[background:var(--progress-fill)]\",\n },\n },\n defaultVariants: { striped: false },\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,mBAAmD;AACnD,2BAAuB;;;ACHvB,kBAAsC;AACtC,4BAAwB;AAEjB,SAAS,MAAM,QAAsB;AAC1C,aAAO,mCAAQ,kBAAK,MAAM,CAAC;AAC7B;;;ACSO,IAAM,2BAAqD;AAAA,EAChE,MAAM,CAAC;AAAA,EACP,SAAS;AAAA,IACP,SAAS,EAAE,oBAAoB,CAAC,SAAS,SAAS,EAAE;AAAA,IACpD,YAAY,EAAE,QAAQ,UAAU,UAAU,KAAK,MAAM,SAAS;AAAA,EAChE;AACF;;;ACpBA,sCAAoB;AAEb,IAAM,uBAAmB,qCAAI,wBAAwB;AAAA,EAC1D,UAAU;AAAA,IACR,YAAY;AAAA,MACV,SAAS;AAAA,MACT,WAAW;AAAA,MACX,aAAa;AAAA,MACb,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,MAAM;AAAA,MACN,KAAK;AAAA,MACL,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,QAAQ;AA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M,UAAU,IAAI,IAAI,KAAK,OAAQ,QAAQ,OAAO,QAAS,GAAG;AACtE,QAAM,UAAU,YAAY,GAAG,GAAG;AAClC,SACE,4CAAC,SAAI,aAAU,kBAAiB,WAAW,GAAG,kCAAkC,SAAS,GACtF,mBACH;AAEJ;AAEA,cAAc,cAAc;","names":[]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { HTMLMotionProps } from 'framer-motion';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
|
+
|
|
7
|
+
declare const progressVariants: (props?: ({
|
|
8
|
+
appearance?: "default" | "outline" | "ghost" | "sky" | "rose" | "purple" | "pink" | "orange" | "yellow" | "teal" | "indigo" | "emerald" | "gradient-blue" | "gradient-green" | "gradient-red" | "gradient-yellow" | "gradient-purple" | "gradient-teal" | "gradient-indigo" | "gradient-pink" | "gradient-orange" | "secondary" | "destructive" | "glass" | null | undefined;
|
|
9
|
+
size?: "sm" | "md" | "lg" | "xl" | "xs" | null | undefined;
|
|
10
|
+
shape?: "flat" | "pill" | "rounded" | null | undefined;
|
|
11
|
+
striped?: boolean | null | undefined;
|
|
12
|
+
animated?: boolean | null | undefined;
|
|
13
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
14
|
+
declare const progressTrackVariants: (props?: ({
|
|
15
|
+
size?: "sm" | "md" | "lg" | "xl" | "xs" | null | undefined;
|
|
16
|
+
shape?: "flat" | "pill" | "rounded" | null | undefined;
|
|
17
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
18
|
+
declare const progressBarVariants: (props?: ({
|
|
19
|
+
striped?: boolean | null | undefined;
|
|
20
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
21
|
+
|
|
22
|
+
type ProgressAnimation = "none" | "shimmer";
|
|
23
|
+
type ProgressVariantProps = VariantProps<typeof progressVariants>;
|
|
24
|
+
type ProgressProps = ProgressVariantProps & Omit<HTMLMotionProps<"div">, "children"> & {
|
|
25
|
+
value?: number;
|
|
26
|
+
min?: number;
|
|
27
|
+
max?: number;
|
|
28
|
+
animation?: ProgressAnimation;
|
|
29
|
+
label?: string;
|
|
30
|
+
children?: ReactNode;
|
|
31
|
+
};
|
|
32
|
+
type ProgressSectionProps = {
|
|
33
|
+
className?: string;
|
|
34
|
+
children?: ReactNode;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
declare function Progress(props: ProgressProps): react_jsx_runtime.JSX.Element;
|
|
38
|
+
declare namespace Progress {
|
|
39
|
+
var displayName: string;
|
|
40
|
+
}
|
|
41
|
+
declare function ProgressBar({ className, style, ref, ...rest }: ProgressSectionProps & {
|
|
42
|
+
style?: React.CSSProperties;
|
|
43
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
44
|
+
}): react_jsx_runtime.JSX.Element;
|
|
45
|
+
declare namespace ProgressBar {
|
|
46
|
+
var displayName: string;
|
|
47
|
+
}
|
|
48
|
+
declare function ProgressLabel({ className, children }: ProgressSectionProps): react_jsx_runtime.JSX.Element;
|
|
49
|
+
declare namespace ProgressLabel {
|
|
50
|
+
var displayName: string;
|
|
51
|
+
}
|
|
52
|
+
declare function ProgressValue({ className, children }: ProgressSectionProps): react_jsx_runtime.JSX.Element;
|
|
53
|
+
declare namespace ProgressValue {
|
|
54
|
+
var displayName: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type ProgressPresetMotionProps = Pick<HTMLMotionProps<"div">, "transition" | "animate">;
|
|
58
|
+
type ProgressAnimationPresets = Record<ProgressAnimation, ProgressPresetMotionProps>;
|
|
59
|
+
declare const progressAnimationPresets: ProgressAnimationPresets;
|
|
60
|
+
|
|
61
|
+
export { Progress, type ProgressAnimation, ProgressBar, ProgressLabel, type ProgressProps, type ProgressSectionProps, ProgressValue, progressAnimationPresets, progressBarVariants, progressTrackVariants, progressVariants };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { HTMLMotionProps } from 'framer-motion';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
|
+
|
|
7
|
+
declare const progressVariants: (props?: ({
|
|
8
|
+
appearance?: "default" | "outline" | "ghost" | "sky" | "rose" | "purple" | "pink" | "orange" | "yellow" | "teal" | "indigo" | "emerald" | "gradient-blue" | "gradient-green" | "gradient-red" | "gradient-yellow" | "gradient-purple" | "gradient-teal" | "gradient-indigo" | "gradient-pink" | "gradient-orange" | "secondary" | "destructive" | "glass" | null | undefined;
|
|
9
|
+
size?: "sm" | "md" | "lg" | "xl" | "xs" | null | undefined;
|
|
10
|
+
shape?: "flat" | "pill" | "rounded" | null | undefined;
|
|
11
|
+
striped?: boolean | null | undefined;
|
|
12
|
+
animated?: boolean | null | undefined;
|
|
13
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
14
|
+
declare const progressTrackVariants: (props?: ({
|
|
15
|
+
size?: "sm" | "md" | "lg" | "xl" | "xs" | null | undefined;
|
|
16
|
+
shape?: "flat" | "pill" | "rounded" | null | undefined;
|
|
17
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
18
|
+
declare const progressBarVariants: (props?: ({
|
|
19
|
+
striped?: boolean | null | undefined;
|
|
20
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
21
|
+
|
|
22
|
+
type ProgressAnimation = "none" | "shimmer";
|
|
23
|
+
type ProgressVariantProps = VariantProps<typeof progressVariants>;
|
|
24
|
+
type ProgressProps = ProgressVariantProps & Omit<HTMLMotionProps<"div">, "children"> & {
|
|
25
|
+
value?: number;
|
|
26
|
+
min?: number;
|
|
27
|
+
max?: number;
|
|
28
|
+
animation?: ProgressAnimation;
|
|
29
|
+
label?: string;
|
|
30
|
+
children?: ReactNode;
|
|
31
|
+
};
|
|
32
|
+
type ProgressSectionProps = {
|
|
33
|
+
className?: string;
|
|
34
|
+
children?: ReactNode;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
declare function Progress(props: ProgressProps): react_jsx_runtime.JSX.Element;
|
|
38
|
+
declare namespace Progress {
|
|
39
|
+
var displayName: string;
|
|
40
|
+
}
|
|
41
|
+
declare function ProgressBar({ className, style, ref, ...rest }: ProgressSectionProps & {
|
|
42
|
+
style?: React.CSSProperties;
|
|
43
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
44
|
+
}): react_jsx_runtime.JSX.Element;
|
|
45
|
+
declare namespace ProgressBar {
|
|
46
|
+
var displayName: string;
|
|
47
|
+
}
|
|
48
|
+
declare function ProgressLabel({ className, children }: ProgressSectionProps): react_jsx_runtime.JSX.Element;
|
|
49
|
+
declare namespace ProgressLabel {
|
|
50
|
+
var displayName: string;
|
|
51
|
+
}
|
|
52
|
+
declare function ProgressValue({ className, children }: ProgressSectionProps): react_jsx_runtime.JSX.Element;
|
|
53
|
+
declare namespace ProgressValue {
|
|
54
|
+
var displayName: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type ProgressPresetMotionProps = Pick<HTMLMotionProps<"div">, "transition" | "animate">;
|
|
58
|
+
type ProgressAnimationPresets = Record<ProgressAnimation, ProgressPresetMotionProps>;
|
|
59
|
+
declare const progressAnimationPresets: ProgressAnimationPresets;
|
|
60
|
+
|
|
61
|
+
export { Progress, type ProgressAnimation, ProgressBar, ProgressLabel, type ProgressProps, type ProgressSectionProps, ProgressValue, progressAnimationPresets, progressBarVariants, progressTrackVariants, progressVariants };
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
// src/ui/progress/progress.tsx
|
|
5
|
+
import { createContext, useContext, useMemo } from "react";
|
|
6
|
+
import { motion } from "framer-motion";
|
|
7
|
+
|
|
8
|
+
// src/lib/utils.ts
|
|
9
|
+
import { clsx } from "clsx";
|
|
10
|
+
import { twMerge } from "tailwind-merge";
|
|
11
|
+
function cn(...inputs) {
|
|
12
|
+
return twMerge(clsx(inputs));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// src/ui/progress/animations.ts
|
|
16
|
+
var progressAnimationPresets = {
|
|
17
|
+
none: {},
|
|
18
|
+
shimmer: {
|
|
19
|
+
animate: { backgroundPosition: ["0% 0%", "100% 0%"] },
|
|
20
|
+
transition: { repeat: Infinity, duration: 1.2, ease: "linear" }
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// src/ui/progress/variants.ts
|
|
25
|
+
import { cva } from "class-variance-authority";
|
|
26
|
+
var progressVariants = cva("w-full text-slate-50", {
|
|
27
|
+
variants: {
|
|
28
|
+
appearance: {
|
|
29
|
+
default: "[--progress-fill:theme(colors.slate.50)]",
|
|
30
|
+
secondary: "[--progress-fill:theme(colors.slate.300)]",
|
|
31
|
+
destructive: "[--progress-fill:theme(colors.rose.400)]",
|
|
32
|
+
emerald: "[--progress-fill:theme(colors.emerald.400)]",
|
|
33
|
+
indigo: "[--progress-fill:theme(colors.indigo.400)]",
|
|
34
|
+
purple: "[--progress-fill:theme(colors.purple.400)]",
|
|
35
|
+
pink: "[--progress-fill:theme(colors.pink.400)]",
|
|
36
|
+
rose: "[--progress-fill:theme(colors.rose.400)]",
|
|
37
|
+
sky: "[--progress-fill:theme(colors.sky.400)]",
|
|
38
|
+
teal: "[--progress-fill:theme(colors.teal.400)]",
|
|
39
|
+
yellow: "[--progress-fill:theme(colors.yellow.400)]",
|
|
40
|
+
orange: "[--progress-fill:theme(colors.orange.400)]",
|
|
41
|
+
outline: "[--progress-fill:theme(colors.cyan.300)]",
|
|
42
|
+
ghost: "[--progress-fill:theme(colors.slate.200)]",
|
|
43
|
+
glass: "[--progress-fill:theme(colors.white)]",
|
|
44
|
+
"gradient-blue": "[--progress-fill:linear-gradient(90deg,theme(colors.blue.500),theme(colors.purple.500))]",
|
|
45
|
+
"gradient-green": "[--progress-fill:linear-gradient(90deg,theme(colors.green.500),theme(colors.lime.500))]",
|
|
46
|
+
"gradient-red": "[--progress-fill:linear-gradient(90deg,theme(colors.red.500),theme(colors.pink.500))]",
|
|
47
|
+
"gradient-yellow": "[--progress-fill:linear-gradient(90deg,theme(colors.yellow.500),theme(colors.orange.500))]",
|
|
48
|
+
"gradient-purple": "[--progress-fill:linear-gradient(90deg,theme(colors.purple.500),theme(colors.pink.500))]",
|
|
49
|
+
"gradient-teal": "[--progress-fill:linear-gradient(90deg,theme(colors.teal.500),theme(colors.cyan.500))]",
|
|
50
|
+
"gradient-indigo": "[--progress-fill:linear-gradient(90deg,theme(colors.indigo.500),theme(colors.purple.500))]",
|
|
51
|
+
"gradient-pink": "[--progress-fill:linear-gradient(90deg,theme(colors.pink.500),theme(colors.rose.500))]",
|
|
52
|
+
"gradient-orange": "[--progress-fill:linear-gradient(90deg,theme(colors.orange.500),theme(colors.red.500))]"
|
|
53
|
+
},
|
|
54
|
+
size: {
|
|
55
|
+
xs: "text-[0.65rem]",
|
|
56
|
+
sm: "text-xs",
|
|
57
|
+
md: "text-sm",
|
|
58
|
+
lg: "text-base",
|
|
59
|
+
xl: "text-lg"
|
|
60
|
+
},
|
|
61
|
+
shape: {
|
|
62
|
+
flat: "rounded-none",
|
|
63
|
+
rounded: "rounded-md",
|
|
64
|
+
pill: "rounded-full"
|
|
65
|
+
},
|
|
66
|
+
striped: {
|
|
67
|
+
true: "",
|
|
68
|
+
false: ""
|
|
69
|
+
},
|
|
70
|
+
animated: {
|
|
71
|
+
true: "",
|
|
72
|
+
false: ""
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
defaultVariants: {
|
|
76
|
+
appearance: "default",
|
|
77
|
+
size: "md",
|
|
78
|
+
shape: "rounded",
|
|
79
|
+
striped: false,
|
|
80
|
+
animated: false
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
var progressTrackVariants = cva("relative w-full overflow-hidden bg-white/10", {
|
|
84
|
+
variants: {
|
|
85
|
+
size: {
|
|
86
|
+
xs: "h-1",
|
|
87
|
+
sm: "h-1.5",
|
|
88
|
+
md: "h-2",
|
|
89
|
+
lg: "h-3",
|
|
90
|
+
xl: "h-4"
|
|
91
|
+
},
|
|
92
|
+
shape: {
|
|
93
|
+
flat: "rounded-none",
|
|
94
|
+
rounded: "rounded-md",
|
|
95
|
+
pill: "rounded-full"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
defaultVariants: {
|
|
99
|
+
size: "md",
|
|
100
|
+
shape: "rounded"
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
var progressBarVariants = cva(
|
|
104
|
+
"h-full w-full origin-left rounded-[inherit]",
|
|
105
|
+
{
|
|
106
|
+
variants: {
|
|
107
|
+
striped: {
|
|
108
|
+
true: "bg-[repeating-linear-gradient(135deg,rgba(255,255,255,0.18)_0,rgba(255,255,255,0.18)_10px,transparent_10px,transparent_20px)]",
|
|
109
|
+
false: "[background:var(--progress-fill)]"
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
defaultVariants: { striped: false }
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
// src/ui/progress/progress.tsx
|
|
117
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
118
|
+
var ProgressContext = createContext(null);
|
|
119
|
+
function useProgressContext(component) {
|
|
120
|
+
const ctx = useContext(ProgressContext);
|
|
121
|
+
if (!ctx) {
|
|
122
|
+
throw new Error(`${component} must be used within <Progress>`);
|
|
123
|
+
}
|
|
124
|
+
return ctx;
|
|
125
|
+
}
|
|
126
|
+
function clamp(value, min, max) {
|
|
127
|
+
return Math.min(max, Math.max(min, value));
|
|
128
|
+
}
|
|
129
|
+
function Progress(props) {
|
|
130
|
+
const {
|
|
131
|
+
className,
|
|
132
|
+
appearance = "default",
|
|
133
|
+
size = "md",
|
|
134
|
+
shape = "rounded",
|
|
135
|
+
striped = false,
|
|
136
|
+
animated = false,
|
|
137
|
+
animation = "none",
|
|
138
|
+
value = 0,
|
|
139
|
+
min = 0,
|
|
140
|
+
max = 100,
|
|
141
|
+
label,
|
|
142
|
+
children,
|
|
143
|
+
ref,
|
|
144
|
+
...rest
|
|
145
|
+
} = props;
|
|
146
|
+
const motionProps = progressAnimationPresets[animation];
|
|
147
|
+
const clamped = clamp(value, min, max);
|
|
148
|
+
const percent = max === min ? 0 : (clamped - min) / (max - min) * 100;
|
|
149
|
+
const ctx = useMemo(
|
|
150
|
+
() => ({
|
|
151
|
+
value: clamped,
|
|
152
|
+
min,
|
|
153
|
+
max,
|
|
154
|
+
size: size ?? "md",
|
|
155
|
+
shape: shape ?? "rounded",
|
|
156
|
+
striped: Boolean(striped),
|
|
157
|
+
animated: Boolean(animated),
|
|
158
|
+
appearance: appearance ?? "default"
|
|
159
|
+
}),
|
|
160
|
+
[animated, appearance, clamped, max, min, shape, size, striped]
|
|
161
|
+
);
|
|
162
|
+
return /* @__PURE__ */ jsx(ProgressContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(
|
|
163
|
+
motion.div,
|
|
164
|
+
{
|
|
165
|
+
ref,
|
|
166
|
+
"data-slot": "progress",
|
|
167
|
+
role: "progressbar",
|
|
168
|
+
"aria-valuemin": min,
|
|
169
|
+
"aria-valuemax": max,
|
|
170
|
+
"aria-valuenow": clamped,
|
|
171
|
+
"aria-label": label,
|
|
172
|
+
className: cn(
|
|
173
|
+
progressVariants({ appearance, size, shape, striped, animated }),
|
|
174
|
+
className
|
|
175
|
+
),
|
|
176
|
+
initial: false,
|
|
177
|
+
...motionProps,
|
|
178
|
+
...rest,
|
|
179
|
+
children: children ?? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ProgressBar, { style: { transform: `scaleX(${percent / 100})` } }) })
|
|
180
|
+
}
|
|
181
|
+
) });
|
|
182
|
+
}
|
|
183
|
+
Progress.displayName = "Progress";
|
|
184
|
+
function ProgressBar({
|
|
185
|
+
className,
|
|
186
|
+
style,
|
|
187
|
+
ref,
|
|
188
|
+
...rest
|
|
189
|
+
}) {
|
|
190
|
+
const { size, shape, striped, animated } = useProgressContext("ProgressBar");
|
|
191
|
+
return /* @__PURE__ */ jsx(
|
|
192
|
+
"div",
|
|
193
|
+
{
|
|
194
|
+
"data-slot": "progress-track",
|
|
195
|
+
className: cn(progressTrackVariants({ size, shape }), "text-current"),
|
|
196
|
+
children: /* @__PURE__ */ jsx(
|
|
197
|
+
motion.div,
|
|
198
|
+
{
|
|
199
|
+
ref,
|
|
200
|
+
"data-slot": "progress-bar",
|
|
201
|
+
className: cn(progressBarVariants({ striped }), className),
|
|
202
|
+
style: {
|
|
203
|
+
transformOrigin: "left center",
|
|
204
|
+
...style
|
|
205
|
+
},
|
|
206
|
+
animate: animated ? { x: ["-30%", "0%"], opacity: [0.85, 1] } : void 0,
|
|
207
|
+
transition: animated ? { repeat: Infinity, duration: 1.1, ease: "easeInOut" } : void 0,
|
|
208
|
+
...rest
|
|
209
|
+
}
|
|
210
|
+
)
|
|
211
|
+
}
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
ProgressBar.displayName = "ProgressBar";
|
|
215
|
+
function ProgressLabel({ className, children }) {
|
|
216
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "progress-label", className: cn("mb-2 font-medium text-slate-200", className), children });
|
|
217
|
+
}
|
|
218
|
+
ProgressLabel.displayName = "ProgressLabel";
|
|
219
|
+
function ProgressValue({ className, children }) {
|
|
220
|
+
const { value, min, max } = useProgressContext("ProgressValue");
|
|
221
|
+
const range = max - min;
|
|
222
|
+
const pct = range === 0 ? 0 : Math.round((value - min) / range * 100);
|
|
223
|
+
const content = children ?? `${pct}%`;
|
|
224
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "progress-value", className: cn("mt-2 text-right text-slate-400", className), children: content });
|
|
225
|
+
}
|
|
226
|
+
ProgressValue.displayName = "ProgressValue";
|
|
227
|
+
export {
|
|
228
|
+
Progress,
|
|
229
|
+
ProgressBar,
|
|
230
|
+
ProgressLabel,
|
|
231
|
+
ProgressValue,
|
|
232
|
+
progressAnimationPresets,
|
|
233
|
+
progressBarVariants,
|
|
234
|
+
progressTrackVariants,
|
|
235
|
+
progressVariants
|
|
236
|
+
};
|
|
237
|
+
//# sourceMappingURL=progress.js.map
|