moldekit-react 0.0.6 → 0.0.7
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/dist/components/MkAlert/MkAlert.d.ts +1 -1
- package/dist/components/MkAlert/MkAlert.props.d.ts +3 -0
- package/dist/components/MkBarChart/MkBarChart.d.ts +1 -1
- package/dist/components/MkBarChart/MkBarChart.props.d.ts +5 -0
- package/dist/components/MkBarHistoryChart/MkBarHistoryChart.d.ts +1 -1
- package/dist/components/MkBarHistoryChart/MkBarHistoryChart.props.d.ts +5 -0
- package/dist/components/MkCheckbox/MkCheckbox.d.ts +1 -1
- package/dist/components/MkCheckbox/MkCheckbox.props.d.ts +3 -1
- package/dist/components/MkDonutChart/MkDonutChart.d.ts +1 -1
- package/dist/components/MkDonutChart/MkDonutChart.props.d.ts +8 -0
- package/dist/components/MkRadioButton/MkRadioButton.d.ts +1 -1
- package/dist/components/MkRadioButton/MkRadioButton.props.d.ts +5 -1
- package/dist/components/MkStackedBarChart/MkStackedBarChart.d.ts +1 -1
- package/dist/components/MkStackedBarChart/MkStackedBarChart.props.d.ts +5 -0
- package/dist/components/MkTag/MkTag.d.ts +2 -2
- package/dist/components/MkTag/MkTag.props.d.ts +5 -0
- package/dist/index.cjs +499 -120
- package/dist/index.js +500 -121
- package/dist/style.css +236 -0
- package/package.json +5 -1
package/dist/index.cjs
CHANGED
|
@@ -3,111 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
const react = require('react');
|
|
7
|
-
const dynamic = require('lucide-react/dynamic');
|
|
8
6
|
const lucideReact = require('lucide-react');
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className });
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function MkBottomSheet({
|
|
15
|
-
open = false,
|
|
16
|
-
onClose,
|
|
17
|
-
children,
|
|
18
|
-
height = "md",
|
|
19
|
-
className = ""
|
|
20
|
-
}) {
|
|
21
|
-
const [isOpen, setIsOpen] = react.useState(open);
|
|
22
|
-
const [isMounted, setIsMounted] = react.useState(open);
|
|
23
|
-
const timeoutRef = react.useRef(null);
|
|
24
|
-
const isInitialMount = react.useRef(true);
|
|
25
|
-
react.useEffect(() => {
|
|
26
|
-
if (open) {
|
|
27
|
-
if (timeoutRef.current) {
|
|
28
|
-
clearTimeout(timeoutRef.current);
|
|
29
|
-
timeoutRef.current = null;
|
|
30
|
-
}
|
|
31
|
-
setIsMounted(true);
|
|
32
|
-
if (isInitialMount.current) {
|
|
33
|
-
setIsOpen(true);
|
|
34
|
-
isInitialMount.current = false;
|
|
35
|
-
} else {
|
|
36
|
-
requestAnimationFrame(() => {
|
|
37
|
-
setIsOpen(true);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
isInitialMount.current = false;
|
|
42
|
-
setIsOpen(false);
|
|
43
|
-
timeoutRef.current = setTimeout(() => {
|
|
44
|
-
setIsMounted(false);
|
|
45
|
-
}, 300);
|
|
46
|
-
}
|
|
47
|
-
return () => {
|
|
48
|
-
if (timeoutRef.current) {
|
|
49
|
-
clearTimeout(timeoutRef.current);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}, [open]);
|
|
53
|
-
const heightClasses = {
|
|
54
|
-
sm: "max-h-[30vh]",
|
|
55
|
-
md: "max-h-[60vh]",
|
|
56
|
-
lg: "max-h-[85vh]",
|
|
57
|
-
full: "h-screen max-h-screen"
|
|
58
|
-
};
|
|
59
|
-
const backdropStyles = "fixed inset-0 z-40 backdrop-blur-sm transition-opacity duration-200";
|
|
60
|
-
const backdropOpcatityAnimation = isOpen ? "opacity-100" : "opacity-0";
|
|
61
|
-
const sheetStyles = [
|
|
62
|
-
"fixed bottom-0 left-0 right-0 z-50",
|
|
63
|
-
"w-full bg-[var(--surface-level1)]",
|
|
64
|
-
"border-t border-[var(--border-default)] rounded-t-[20px] shadow-2xl",
|
|
65
|
-
"transition-transform duration-300 ease-out"
|
|
66
|
-
].join(" ");
|
|
67
|
-
const sheetTranslateAnimation = isOpen ? "translate-y-0" : "translate-y-full";
|
|
68
|
-
const handleBackdropClick = (e) => {
|
|
69
|
-
if (e.target === e.currentTarget) {
|
|
70
|
-
onClose?.();
|
|
71
|
-
setIsOpen(false);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
const handleKeyDown = (e) => {
|
|
75
|
-
if (e.key === "Escape") {
|
|
76
|
-
onClose?.();
|
|
77
|
-
setIsOpen(false);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
if (!isMounted) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
84
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
85
|
-
"div",
|
|
86
|
-
{
|
|
87
|
-
className: `${backdropStyles} ${backdropOpcatityAnimation}`,
|
|
88
|
-
onClick: handleBackdropClick
|
|
89
|
-
}
|
|
90
|
-
),
|
|
91
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
92
|
-
"div",
|
|
93
|
-
{
|
|
94
|
-
className: `${sheetStyles}
|
|
95
|
-
${heightClasses[height]}
|
|
96
|
-
${sheetTranslateAnimation}
|
|
97
|
-
${className}
|
|
98
|
-
`,
|
|
99
|
-
role: "dialog",
|
|
100
|
-
"aria-modal": "true",
|
|
101
|
-
onKeyDown: handleKeyDown,
|
|
102
|
-
tabIndex: -1,
|
|
103
|
-
children: [
|
|
104
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 pt-6 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-8 h-1.5 bg-neutral-300 rounded-full" }) }),
|
|
105
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6 pb-12 max-h-full overflow-y-auto", children })
|
|
106
|
-
]
|
|
107
|
-
}
|
|
108
|
-
)
|
|
109
|
-
] });
|
|
110
|
-
}
|
|
7
|
+
const dynamic = require('lucide-react/dynamic');
|
|
8
|
+
const react = require('react');
|
|
111
9
|
|
|
112
10
|
function MkButton({
|
|
113
11
|
variant = "filled",
|
|
@@ -282,12 +180,191 @@ function MkButton({
|
|
|
282
180
|
);
|
|
283
181
|
}
|
|
284
182
|
|
|
285
|
-
function
|
|
286
|
-
|
|
183
|
+
function MkAlert({
|
|
184
|
+
label,
|
|
185
|
+
state = "info",
|
|
186
|
+
position = "top-right",
|
|
187
|
+
className
|
|
188
|
+
}) {
|
|
189
|
+
const positionStyles = {
|
|
190
|
+
"top-right": "top-4 right-4",
|
|
191
|
+
"top-center": "top-4 left-1/2 -translate-x-1/2",
|
|
192
|
+
"bottom-center": "bottom-4 left-1/2 -translate-x-1/2"
|
|
193
|
+
};
|
|
194
|
+
const baseStyles = [
|
|
195
|
+
"absolute z-[60]",
|
|
196
|
+
positionStyles[position],
|
|
197
|
+
"p-[20px] w-[380px]",
|
|
198
|
+
"bg-neutral-50 border-1 border-neutral-200 rounded-[12px]",
|
|
199
|
+
"flex flex-row items-center justify-between"
|
|
200
|
+
].join(" ");
|
|
201
|
+
const labelStyles = "mk-caption inline-block align-middle pl-3.5 leading-none";
|
|
202
|
+
const stateStyle = {
|
|
203
|
+
info: "text-info-900"
|
|
204
|
+
};
|
|
205
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${baseStyles} ${className}`, children: [
|
|
206
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "inline-block align-middle", children: [
|
|
207
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
208
|
+
lucideReact.InfoIcon,
|
|
209
|
+
{
|
|
210
|
+
className: "inline-block align-middle",
|
|
211
|
+
color: "var(--color-info-700)"
|
|
212
|
+
}
|
|
213
|
+
),
|
|
214
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: `${labelStyles} ${stateStyle[state]}`, children: label })
|
|
215
|
+
] }),
|
|
216
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
217
|
+
MkButton,
|
|
218
|
+
{
|
|
219
|
+
color: "neutral",
|
|
220
|
+
iconOnly: true,
|
|
221
|
+
iconName: "x",
|
|
222
|
+
variant: "transparent"
|
|
223
|
+
}
|
|
224
|
+
)
|
|
225
|
+
] });
|
|
287
226
|
}
|
|
288
227
|
|
|
289
|
-
function
|
|
290
|
-
|
|
228
|
+
function MkBottomSheet({
|
|
229
|
+
open = false,
|
|
230
|
+
onClose,
|
|
231
|
+
children,
|
|
232
|
+
height = "md",
|
|
233
|
+
className = ""
|
|
234
|
+
}) {
|
|
235
|
+
const [isOpen, setIsOpen] = react.useState(open);
|
|
236
|
+
const [isMounted, setIsMounted] = react.useState(open);
|
|
237
|
+
const timeoutRef = react.useRef(null);
|
|
238
|
+
const isInitialMount = react.useRef(true);
|
|
239
|
+
react.useEffect(() => {
|
|
240
|
+
if (open) {
|
|
241
|
+
if (timeoutRef.current) {
|
|
242
|
+
clearTimeout(timeoutRef.current);
|
|
243
|
+
timeoutRef.current = null;
|
|
244
|
+
}
|
|
245
|
+
setIsMounted(true);
|
|
246
|
+
if (isInitialMount.current) {
|
|
247
|
+
setIsOpen(true);
|
|
248
|
+
isInitialMount.current = false;
|
|
249
|
+
} else {
|
|
250
|
+
requestAnimationFrame(() => {
|
|
251
|
+
setIsOpen(true);
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
} else {
|
|
255
|
+
isInitialMount.current = false;
|
|
256
|
+
setIsOpen(false);
|
|
257
|
+
timeoutRef.current = setTimeout(() => {
|
|
258
|
+
setIsMounted(false);
|
|
259
|
+
}, 300);
|
|
260
|
+
}
|
|
261
|
+
return () => {
|
|
262
|
+
if (timeoutRef.current) {
|
|
263
|
+
clearTimeout(timeoutRef.current);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}, [open]);
|
|
267
|
+
const heightClasses = {
|
|
268
|
+
sm: "max-h-[30vh]",
|
|
269
|
+
md: "max-h-[60vh]",
|
|
270
|
+
lg: "max-h-[85vh]",
|
|
271
|
+
full: "h-screen max-h-screen"
|
|
272
|
+
};
|
|
273
|
+
const backdropStyles = "fixed inset-0 z-40 backdrop-blur-sm transition-opacity duration-200";
|
|
274
|
+
const backdropOpcatityAnimation = isOpen ? "opacity-100" : "opacity-0";
|
|
275
|
+
const sheetStyles = [
|
|
276
|
+
"fixed bottom-0 left-0 right-0 z-50",
|
|
277
|
+
"w-full bg-[var(--surface-level1)]",
|
|
278
|
+
"border-t border-[var(--border-default)] rounded-t-[20px] shadow-2xl",
|
|
279
|
+
"transition-transform duration-300 ease-out"
|
|
280
|
+
].join(" ");
|
|
281
|
+
const sheetTranslateAnimation = isOpen ? "translate-y-0" : "translate-y-full";
|
|
282
|
+
const handleBackdropClick = (e) => {
|
|
283
|
+
if (e.target === e.currentTarget) {
|
|
284
|
+
onClose?.();
|
|
285
|
+
setIsOpen(false);
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
const handleKeyDown = (e) => {
|
|
289
|
+
if (e.key === "Escape") {
|
|
290
|
+
onClose?.();
|
|
291
|
+
setIsOpen(false);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
if (!isMounted) {
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
298
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
299
|
+
"div",
|
|
300
|
+
{
|
|
301
|
+
className: `${backdropStyles} ${backdropOpcatityAnimation}`,
|
|
302
|
+
onClick: handleBackdropClick
|
|
303
|
+
}
|
|
304
|
+
),
|
|
305
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
306
|
+
"div",
|
|
307
|
+
{
|
|
308
|
+
className: `${sheetStyles}
|
|
309
|
+
${heightClasses[height]}
|
|
310
|
+
${sheetTranslateAnimation}
|
|
311
|
+
${className}
|
|
312
|
+
`,
|
|
313
|
+
role: "dialog",
|
|
314
|
+
"aria-modal": "true",
|
|
315
|
+
onKeyDown: handleKeyDown,
|
|
316
|
+
tabIndex: -1,
|
|
317
|
+
children: [
|
|
318
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 pt-6 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-8 h-1.5 bg-neutral-300 rounded-full" }) }),
|
|
319
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6 pb-12 max-h-full overflow-y-auto", children })
|
|
320
|
+
]
|
|
321
|
+
}
|
|
322
|
+
)
|
|
323
|
+
] });
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function MkBarChart({ data, className }) {
|
|
327
|
+
const baseStyles = "flex flex-row flex-wrap justify-between p-1 w-full max-w-4xl";
|
|
328
|
+
const barContainerStyles = "flex flex-col items-center gap-2 w-12";
|
|
329
|
+
const barStyles = "w-[25px] rounded-[5px] shadow-sm absolute bottom-0 left-0";
|
|
330
|
+
const bgBarStyles = "w-[25px] h-32 rounded-[5px] relative";
|
|
331
|
+
const batColorStyles = {
|
|
332
|
+
faded: "bg-neutral-200",
|
|
333
|
+
regular: "bg-primary-500",
|
|
334
|
+
"no-data": "bg-primary-400"
|
|
335
|
+
};
|
|
336
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${baseStyles} ${className}`, children: data.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: barContainerStyles, children: [
|
|
337
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: bgBarStyles, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
338
|
+
"div",
|
|
339
|
+
{
|
|
340
|
+
className: `${barStyles} ${batColorStyles[item.type ? item.type : "regular"]}`,
|
|
341
|
+
style: { height: `${item.value}%` }
|
|
342
|
+
}
|
|
343
|
+
) }),
|
|
344
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "mk-label text-xs font-medium text-neutral-700 text-center min-w-[40px]", children: item.label })
|
|
345
|
+
] }, index)) });
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function MkBarHistoryChart({ data, className }) {
|
|
349
|
+
const baseStyles = "flex flex-row flex-wrap justify-between p-1 w-full max-w-4xl";
|
|
350
|
+
const barContainerStyles = "flex flex-col items-center gap-2 w-12";
|
|
351
|
+
const barStyles = "w-[10px] rounded-full shadow-sm absolute bottom-0 left-0";
|
|
352
|
+
const bgBarStyles = "w-[10px] h-32 bg-neutral-200 rounded-full relative";
|
|
353
|
+
const batColorStyles = {
|
|
354
|
+
faded: "bg-primary-200",
|
|
355
|
+
regular: "bg-primary-500",
|
|
356
|
+
"no-data": "bg-primary-400"
|
|
357
|
+
};
|
|
358
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${baseStyles} ${className}`, children: data.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: barContainerStyles, children: [
|
|
359
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: bgBarStyles, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
360
|
+
"div",
|
|
361
|
+
{
|
|
362
|
+
className: `${barStyles} ${batColorStyles[item.type ? item.type : "regular"]}`,
|
|
363
|
+
style: { height: `${item.value}%` }
|
|
364
|
+
}
|
|
365
|
+
) }),
|
|
366
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "mk-label text-xs font-medium text-neutral-700 text-center min-w-[40px]", children: item.label })
|
|
367
|
+
] }, index)) });
|
|
291
368
|
}
|
|
292
369
|
|
|
293
370
|
function MkCard({ className = "", noPadding = false, children }) {
|
|
@@ -306,8 +383,90 @@ function MkCard({ className = "", noPadding = false, children }) {
|
|
|
306
383
|
return /* @__PURE__ */ jsxRuntime.jsx("section", { className: `${baseStyles} ${className}`, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${contentStyles} ${paddingStyle}`, children }) });
|
|
307
384
|
}
|
|
308
385
|
|
|
309
|
-
function MkCheckbox({
|
|
310
|
-
|
|
386
|
+
function MkCheckbox({
|
|
387
|
+
label,
|
|
388
|
+
size = "md",
|
|
389
|
+
className = "",
|
|
390
|
+
checked,
|
|
391
|
+
disabled,
|
|
392
|
+
id,
|
|
393
|
+
onChange,
|
|
394
|
+
...props
|
|
395
|
+
}) {
|
|
396
|
+
const generatedId = react.useId();
|
|
397
|
+
const checkboxId = id || generatedId;
|
|
398
|
+
const [isChecked, setIsChecked] = react.useState(checked ?? false);
|
|
399
|
+
react.useEffect(() => {
|
|
400
|
+
if (checked !== void 0) {
|
|
401
|
+
setIsChecked(checked);
|
|
402
|
+
}
|
|
403
|
+
}, [checked]);
|
|
404
|
+
const handleChange = (event) => {
|
|
405
|
+
const newChecked = event.target.checked;
|
|
406
|
+
setIsChecked(newChecked);
|
|
407
|
+
onChange?.(event);
|
|
408
|
+
};
|
|
409
|
+
const baseStyle = [
|
|
410
|
+
"appearance-none cursor-pointer",
|
|
411
|
+
"bg-neutral-50 rounded-[7px] border-2 border-neutral-300",
|
|
412
|
+
"transition-all duration-300",
|
|
413
|
+
"disabled:cursor-not-allowed disabled:bg-neutral-100 disabled:border-neutral-200",
|
|
414
|
+
"enabled:focus:border-primary-300 enabled:focus:outline-none enabled:focus:ring-0",
|
|
415
|
+
"enabled:hover:shadow-[0_0_4px_var(--color-primary-400)] enabled:hover:border-primary-300",
|
|
416
|
+
"checked:bg-neutral-600 checked:border-primary-600",
|
|
417
|
+
"checked:enabled:hover:bg-primary-700 checked:enabled:hover:border-primary-700",
|
|
418
|
+
"checked:enabled:hover:shadow-[0_0_4px_var(--color-primary-500)]",
|
|
419
|
+
"disabled:checked:bg-neutral-400 disabled:checked:border-neutral-400",
|
|
420
|
+
"relative flex items-center justify-center"
|
|
421
|
+
].join(" ");
|
|
422
|
+
const sizeStyles = {
|
|
423
|
+
sm: "w-4 h-4",
|
|
424
|
+
md: "w-5 h-5",
|
|
425
|
+
lg: "w-6 h-6"
|
|
426
|
+
};
|
|
427
|
+
const iconSizes = {
|
|
428
|
+
sm: 12,
|
|
429
|
+
md: 14,
|
|
430
|
+
lg: 16
|
|
431
|
+
};
|
|
432
|
+
const labelSizeStyles = {
|
|
433
|
+
sm: "text-sm",
|
|
434
|
+
md: "text-md",
|
|
435
|
+
lg: "text-lg"
|
|
436
|
+
};
|
|
437
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex items-center gap-2 ${className}`, children: [
|
|
438
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
439
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
440
|
+
"input",
|
|
441
|
+
{
|
|
442
|
+
type: "checkbox",
|
|
443
|
+
id: checkboxId,
|
|
444
|
+
className: `${baseStyle} ${sizeStyles[size]}`,
|
|
445
|
+
checked: isChecked,
|
|
446
|
+
disabled,
|
|
447
|
+
onChange: handleChange,
|
|
448
|
+
...props
|
|
449
|
+
}
|
|
450
|
+
),
|
|
451
|
+
isChecked && /* @__PURE__ */ jsxRuntime.jsx(
|
|
452
|
+
lucideReact.Check,
|
|
453
|
+
{
|
|
454
|
+
className: "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 pointer-events-none text-white z-10",
|
|
455
|
+
size: iconSizes[size],
|
|
456
|
+
strokeWidth: 3,
|
|
457
|
+
"aria-hidden": "true"
|
|
458
|
+
}
|
|
459
|
+
)
|
|
460
|
+
] }),
|
|
461
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(
|
|
462
|
+
"label",
|
|
463
|
+
{
|
|
464
|
+
htmlFor: checkboxId,
|
|
465
|
+
className: `${labelSizeStyles[size]} text-neutral-800 cursor-pointer select-none ${disabled ? "cursor-not-allowed text-neutral-600" : ""}`,
|
|
466
|
+
children: label
|
|
467
|
+
}
|
|
468
|
+
)
|
|
469
|
+
] });
|
|
311
470
|
}
|
|
312
471
|
|
|
313
472
|
function MkComboBox({
|
|
@@ -502,16 +661,69 @@ function MkDetailedList({ className, data }) {
|
|
|
502
661
|
) }, index)) });
|
|
503
662
|
}
|
|
504
663
|
|
|
505
|
-
function MkDonutChart({
|
|
506
|
-
|
|
664
|
+
function MkDonutChart({
|
|
665
|
+
data,
|
|
666
|
+
className,
|
|
667
|
+
sizePx = 160,
|
|
668
|
+
thicknessPx = 24,
|
|
669
|
+
centerLabel,
|
|
670
|
+
centerValue
|
|
671
|
+
}) {
|
|
672
|
+
const baseStyles = "flex items-center justify-center";
|
|
673
|
+
const wrapperStyles = "relative";
|
|
674
|
+
const total = data.reduce((sum, d) => sum + Math.max(0, d.value), 0);
|
|
675
|
+
const segmentColorByIndex = [
|
|
676
|
+
"var(--color-primary-500)",
|
|
677
|
+
"var(--color-primary-400)",
|
|
678
|
+
"var(--color-primary-300)",
|
|
679
|
+
"var(--color-primary-200)",
|
|
680
|
+
"var(--color-primary-100)"
|
|
681
|
+
];
|
|
682
|
+
const ringBackground = total > 0 ? (() => {
|
|
683
|
+
let acc = 0;
|
|
684
|
+
const stops = data.map((d, i) => {
|
|
685
|
+
const v = Math.max(0, d.value);
|
|
686
|
+
const start = acc;
|
|
687
|
+
acc += v / total * 100;
|
|
688
|
+
const color = segmentColorByIndex[i % segmentColorByIndex.length];
|
|
689
|
+
return `${color} ${start}% ${acc}%`;
|
|
690
|
+
});
|
|
691
|
+
return `conic-gradient(${stops.join(", ")})`;
|
|
692
|
+
})() : "conic-gradient(var(--color-neutral-200) 0% 100%)";
|
|
693
|
+
const sizeStyle = { width: sizePx, height: sizePx };
|
|
694
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${baseStyles} ${className ?? ""}`, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperStyles, style: sizeStyle, children: [
|
|
695
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
696
|
+
"div",
|
|
697
|
+
{
|
|
698
|
+
className: "rounded-full",
|
|
699
|
+
style: {
|
|
700
|
+
...sizeStyle,
|
|
701
|
+
background: ringBackground
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
),
|
|
705
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
706
|
+
"div",
|
|
707
|
+
{
|
|
708
|
+
className: "absolute rounded-full bg-white flex flex-col items-center justify-center text-center",
|
|
709
|
+
style: {
|
|
710
|
+
inset: thicknessPx
|
|
711
|
+
},
|
|
712
|
+
children: [
|
|
713
|
+
centerValue ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mk-label text-lg font-semibold text-neutral-900", children: centerValue }) : null,
|
|
714
|
+
centerLabel ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mk-label text-xs font-medium text-neutral-600", children: centerLabel }) : null
|
|
715
|
+
]
|
|
716
|
+
}
|
|
717
|
+
)
|
|
718
|
+
] }) });
|
|
507
719
|
}
|
|
508
720
|
|
|
509
721
|
function MkHeader({ title, subtitle, className, children }) {
|
|
510
722
|
const baseStyle = ["flex items-center justify-between", "py-1"].join(" ");
|
|
511
723
|
return /* @__PURE__ */ jsxRuntime.jsxs("header", { className: `${baseStyle} ${className}`, children: [
|
|
512
724
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
513
|
-
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "mk-title", children: title }),
|
|
514
|
-
subtitle ? /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "mk-subtitle", children: subtitle }) : null
|
|
725
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "mk-header-title", children: title }),
|
|
726
|
+
subtitle ? /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "mk-header-subtitle", children: subtitle }) : null
|
|
515
727
|
] }),
|
|
516
728
|
children ? /* @__PURE__ */ jsxRuntime.jsx("div", { children }) : null
|
|
517
729
|
] });
|
|
@@ -785,8 +997,102 @@ function MkProgressBar({ percentage }) {
|
|
|
785
997
|
) });
|
|
786
998
|
}
|
|
787
999
|
|
|
788
|
-
function MkRadioButton({
|
|
789
|
-
|
|
1000
|
+
function MkRadioButton({
|
|
1001
|
+
label,
|
|
1002
|
+
value,
|
|
1003
|
+
name,
|
|
1004
|
+
size = "md",
|
|
1005
|
+
className = "",
|
|
1006
|
+
checked,
|
|
1007
|
+
disabled,
|
|
1008
|
+
id,
|
|
1009
|
+
onChange,
|
|
1010
|
+
...props
|
|
1011
|
+
}) {
|
|
1012
|
+
const generatedId = react.useId();
|
|
1013
|
+
const checkboxId = id || generatedId;
|
|
1014
|
+
const [isChecked, setIsChecked] = react.useState(checked ?? false);
|
|
1015
|
+
react.useEffect(() => {
|
|
1016
|
+
if (checked !== void 0) {
|
|
1017
|
+
setIsChecked(checked);
|
|
1018
|
+
}
|
|
1019
|
+
}, [checked]);
|
|
1020
|
+
const handleChange = (event) => {
|
|
1021
|
+
const newChecked = event.target.checked;
|
|
1022
|
+
setIsChecked(newChecked);
|
|
1023
|
+
onChange?.(event);
|
|
1024
|
+
};
|
|
1025
|
+
const baseStyle = [
|
|
1026
|
+
"appearance-none cursor-pointer",
|
|
1027
|
+
"bg-neutral-50 rounded-full border-2 border-neutral-300",
|
|
1028
|
+
"transition-all duration-300",
|
|
1029
|
+
"disabled:cursor-not-allowed disabled:bg-neutral-100 disabled:border-neutral-300",
|
|
1030
|
+
"enabled:focus:border-primary-300 enabled:focus:outline-none enabled:focus:ring-0",
|
|
1031
|
+
"enabled:hover:shadow-[0_0_4px_var(--color-primary-400)] enabled:hover:border-primary-300",
|
|
1032
|
+
"checked:bg-neutral-50 checked:border-primary-300",
|
|
1033
|
+
"checked:enabled:hover:bg-primary-100 checked:enabled:hover:border-primary-300",
|
|
1034
|
+
"checked:enabled:hover:shadow-[0_0_4px_var(--color-primary-500)]",
|
|
1035
|
+
"disabled:checked:bg-neutral-100 disabled:checked:border-neutral-400",
|
|
1036
|
+
"relative flex items-center justify-center"
|
|
1037
|
+
].join(" ");
|
|
1038
|
+
const sizeStyles = {
|
|
1039
|
+
sm: "w-5 h-5",
|
|
1040
|
+
md: "w-6 h-6",
|
|
1041
|
+
lg: "w-7 h-7"
|
|
1042
|
+
};
|
|
1043
|
+
const iconSizes = {
|
|
1044
|
+
sm: 50,
|
|
1045
|
+
md: 70,
|
|
1046
|
+
lg: 90
|
|
1047
|
+
};
|
|
1048
|
+
const labelSizeStyles = {
|
|
1049
|
+
sm: "text-sm",
|
|
1050
|
+
md: "text-md",
|
|
1051
|
+
lg: "text-lg"
|
|
1052
|
+
};
|
|
1053
|
+
const iconStyle = [
|
|
1054
|
+
"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 pointer-events-none z-10",
|
|
1055
|
+
disabled === true ? "text-[var(--color-neutral-400)]" : "text-[var(--color-primary-300)]"
|
|
1056
|
+
].join(" ");
|
|
1057
|
+
const labelStyle = [
|
|
1058
|
+
"text-neutral-800 cursor-pointer select-none",
|
|
1059
|
+
disabled === true ? "cursor-not-allowed text-neutral-600" : ""
|
|
1060
|
+
].join(" ");
|
|
1061
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex items-center gap-2 ${className}`, children: [
|
|
1062
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
1063
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1064
|
+
"input",
|
|
1065
|
+
{
|
|
1066
|
+
type: "radio",
|
|
1067
|
+
name,
|
|
1068
|
+
value,
|
|
1069
|
+
id: checkboxId,
|
|
1070
|
+
className: `${baseStyle} ${sizeStyles[size]}`,
|
|
1071
|
+
checked: isChecked,
|
|
1072
|
+
disabled,
|
|
1073
|
+
onChange: handleChange,
|
|
1074
|
+
...props
|
|
1075
|
+
}
|
|
1076
|
+
),
|
|
1077
|
+
isChecked && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1078
|
+
lucideReact.DotIcon,
|
|
1079
|
+
{
|
|
1080
|
+
className: iconStyle,
|
|
1081
|
+
size: iconSizes[size],
|
|
1082
|
+
strokeWidth: 3,
|
|
1083
|
+
"aria-hidden": "true"
|
|
1084
|
+
}
|
|
1085
|
+
)
|
|
1086
|
+
] }),
|
|
1087
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1088
|
+
"label",
|
|
1089
|
+
{
|
|
1090
|
+
htmlFor: checkboxId,
|
|
1091
|
+
className: `${labelStyle} ${labelSizeStyles[size]}`,
|
|
1092
|
+
children: label
|
|
1093
|
+
}
|
|
1094
|
+
)
|
|
1095
|
+
] });
|
|
790
1096
|
}
|
|
791
1097
|
|
|
792
1098
|
function MkSectionHeader({ title, className, children }) {
|
|
@@ -797,8 +1103,56 @@ function MkSectionHeader({ title, className, children }) {
|
|
|
797
1103
|
] });
|
|
798
1104
|
}
|
|
799
1105
|
|
|
800
|
-
function MkStackedBarChart({ className }) {
|
|
801
|
-
|
|
1106
|
+
function MkStackedBarChart({ data, className }) {
|
|
1107
|
+
const baseStyles = "flex flex-row flex-wrap justify-between p-1 w-full max-w-4xl";
|
|
1108
|
+
const barContainerStyles = "flex flex-col items-center gap-2 w-12";
|
|
1109
|
+
const bgBarStyles = "w-[25px] h-32 relative overflow-hidden flex items-end";
|
|
1110
|
+
const segmentBaseStyles = "w-full";
|
|
1111
|
+
const segmentColorByIndex = [
|
|
1112
|
+
"bg-primary-500",
|
|
1113
|
+
"bg-primary-400",
|
|
1114
|
+
"bg-neutral-300",
|
|
1115
|
+
"bg-neutral-500"
|
|
1116
|
+
];
|
|
1117
|
+
const barOpacityByType = {
|
|
1118
|
+
faded: "opacity-50",
|
|
1119
|
+
regular: "opacity-100",
|
|
1120
|
+
"no-data": "opacity-70"
|
|
1121
|
+
};
|
|
1122
|
+
const labelStyles = "mk-label text-xs font-medium text-neutral-700 text-center min-w-[40px]";
|
|
1123
|
+
const totals = data.map((item) => item.values.reduce((sum, v) => sum + v, 0));
|
|
1124
|
+
const maxTotal = Math.max(...totals, 1);
|
|
1125
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${baseStyles} ${className ?? ""}`, children: data.map((item, index) => {
|
|
1126
|
+
const total = totals[index] || 0;
|
|
1127
|
+
const barHeightPercent = total / maxTotal * 100;
|
|
1128
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: barContainerStyles, children: [
|
|
1129
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: bgBarStyles, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1130
|
+
"div",
|
|
1131
|
+
{
|
|
1132
|
+
className: `w-full flex flex-col justify-end rounded-[5px] ${barOpacityByType[item.type]}`,
|
|
1133
|
+
style: { height: `${barHeightPercent}%` },
|
|
1134
|
+
children: item.values.map((value, i) => {
|
|
1135
|
+
const segmentHeightPercent = total > 0 ? value / total * 100 : 0;
|
|
1136
|
+
const isFirst = i === 0;
|
|
1137
|
+
const isLast = i === item.values.length - 1;
|
|
1138
|
+
const radiusClass = [
|
|
1139
|
+
isFirst ? "rounded-t-[5px]" : "",
|
|
1140
|
+
isLast ? "rounded-b-[5px]" : ""
|
|
1141
|
+
].join(" ");
|
|
1142
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1143
|
+
"div",
|
|
1144
|
+
{
|
|
1145
|
+
className: `${segmentBaseStyles} ${segmentColorByIndex[i % segmentColorByIndex.length]} ${radiusClass}`,
|
|
1146
|
+
style: { height: `${segmentHeightPercent}%` }
|
|
1147
|
+
},
|
|
1148
|
+
i
|
|
1149
|
+
);
|
|
1150
|
+
})
|
|
1151
|
+
}
|
|
1152
|
+
) }),
|
|
1153
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: labelStyles, children: item.label })
|
|
1154
|
+
] }, index);
|
|
1155
|
+
}) });
|
|
802
1156
|
}
|
|
803
1157
|
|
|
804
1158
|
function MkStepper({ steps, currentStep }) {
|
|
@@ -858,8 +1212,33 @@ function MkTab({ data, onTabSelect, selectedTab }) {
|
|
|
858
1212
|
)) });
|
|
859
1213
|
}
|
|
860
1214
|
|
|
861
|
-
function MkTag({ className }) {
|
|
862
|
-
|
|
1215
|
+
function MkTag({ data, onRemove, className }) {
|
|
1216
|
+
const baseStyle = "w-full p-[2px] flex flex-row gap-1";
|
|
1217
|
+
const tagStyle = [
|
|
1218
|
+
"flex items-center justify-center",
|
|
1219
|
+
"px-[10px] py-[5px] rounded-[5px] flex-1 sm:flex-none gap-2",
|
|
1220
|
+
"cursor-pointer transition-all duration-300",
|
|
1221
|
+
"bg-[var(--surface-level1)] hover:bg-neutral-200",
|
|
1222
|
+
"border border-[var(--border-default)]"
|
|
1223
|
+
].join(" ");
|
|
1224
|
+
const handleRemove = (id) => (e) => {
|
|
1225
|
+
e.stopPropagation();
|
|
1226
|
+
if (onRemove) {
|
|
1227
|
+
onRemove(id);
|
|
1228
|
+
}
|
|
1229
|
+
};
|
|
1230
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${baseStyle} ${className}`, children: data.map((tag) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${tagStyle}`, children: [
|
|
1231
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "mk-label", children: tag.label }),
|
|
1232
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1233
|
+
MkButton,
|
|
1234
|
+
{
|
|
1235
|
+
iconOnly: true,
|
|
1236
|
+
iconName: "x",
|
|
1237
|
+
variant: "transparent",
|
|
1238
|
+
onClick: handleRemove(tag.id)
|
|
1239
|
+
}
|
|
1240
|
+
)
|
|
1241
|
+
] })) });
|
|
863
1242
|
}
|
|
864
1243
|
|
|
865
1244
|
function MkTextInput({
|