eglador-ui-react 0.1.0-alpha.2 → 0.1.0-alpha.3
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 +3 -1
- package/dist/index.d.mts +29 -1
- package/dist/index.d.ts +29 -1
- package/dist/index.js +230 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +228 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ Add the following to your global stylesheet (e.g. `app/globals.css`) so Tailwind
|
|
|
24
24
|
## Usage
|
|
25
25
|
|
|
26
26
|
```tsx
|
|
27
|
-
import { Button, ButtonGroup } from "eglador-ui-react";
|
|
27
|
+
import { Button, ButtonGroup, Checkbox, CheckboxGroup } from "eglador-ui-react";
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
## Components
|
|
@@ -33,6 +33,8 @@ import { Button, ButtonGroup } from "eglador-ui-react";
|
|
|
33
33
|
|-----------|-----------|
|
|
34
34
|
| **Button** | `variant`, `color`, `size`, `shape`, `soft`, `icon`, `iconRight`, `loading`, `active`, `disabled`, `className` |
|
|
35
35
|
| **ButtonGroup** | `variant`, `className`, `children` |
|
|
36
|
+
| **Checkbox** | `variant`, `color`, `size`, `checked`, `onChange`, `indeterminate`, `label`, `description`, `disabled`, `name`, `value`, `className` |
|
|
37
|
+
| **CheckboxGroup** | `variant`, `className`, `children` |
|
|
36
38
|
|
|
37
39
|
## Development
|
|
38
40
|
|
package/dist/index.d.mts
CHANGED
|
@@ -28,6 +28,34 @@ interface ButtonGroupProps {
|
|
|
28
28
|
}
|
|
29
29
|
declare function ButtonGroup({ variant, className, children, }: ButtonGroupProps): react_jsx_runtime.JSX.Element;
|
|
30
30
|
|
|
31
|
+
type CheckboxSize = "xs" | "sm" | "md";
|
|
32
|
+
type CheckboxColor = "default" | "black" | "primary" | "danger" | "success" | "warning" | "info";
|
|
33
|
+
type CheckboxVariant = "default" | "card" | "list";
|
|
34
|
+
interface CheckboxProps {
|
|
35
|
+
variant?: CheckboxVariant;
|
|
36
|
+
checked?: boolean;
|
|
37
|
+
onChange?: (checked: boolean) => void;
|
|
38
|
+
indeterminate?: boolean;
|
|
39
|
+
size?: CheckboxSize;
|
|
40
|
+
color?: CheckboxColor;
|
|
41
|
+
label?: React.ReactNode;
|
|
42
|
+
description?: React.ReactNode;
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
className?: string;
|
|
45
|
+
name?: string;
|
|
46
|
+
value?: string;
|
|
47
|
+
id?: string;
|
|
48
|
+
}
|
|
49
|
+
declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
|
|
50
|
+
|
|
51
|
+
type CheckboxGroupVariant = "bordered" | "segmented";
|
|
52
|
+
interface CheckboxGroupProps {
|
|
53
|
+
variant?: CheckboxGroupVariant;
|
|
54
|
+
className?: string;
|
|
55
|
+
children: React.ReactNode;
|
|
56
|
+
}
|
|
57
|
+
declare function CheckboxGroup({ variant, className, children, }: CheckboxGroupProps): react_jsx_runtime.JSX.Element;
|
|
58
|
+
|
|
31
59
|
declare function cn(...inputs: ClassValue[]): string;
|
|
32
60
|
|
|
33
|
-
export { Button, type ButtonColor, ButtonGroup, type ButtonGroupProps, type ButtonGroupVariant, type ButtonProps, type ButtonShape, type ButtonSize, type ButtonVariant, cn };
|
|
61
|
+
export { Button, type ButtonColor, ButtonGroup, type ButtonGroupProps, type ButtonGroupVariant, type ButtonProps, type ButtonShape, type ButtonSize, type ButtonVariant, Checkbox, type CheckboxColor, CheckboxGroup, type CheckboxGroupProps, type CheckboxGroupVariant, type CheckboxProps, type CheckboxSize, type CheckboxVariant, cn };
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,34 @@ interface ButtonGroupProps {
|
|
|
28
28
|
}
|
|
29
29
|
declare function ButtonGroup({ variant, className, children, }: ButtonGroupProps): react_jsx_runtime.JSX.Element;
|
|
30
30
|
|
|
31
|
+
type CheckboxSize = "xs" | "sm" | "md";
|
|
32
|
+
type CheckboxColor = "default" | "black" | "primary" | "danger" | "success" | "warning" | "info";
|
|
33
|
+
type CheckboxVariant = "default" | "card" | "list";
|
|
34
|
+
interface CheckboxProps {
|
|
35
|
+
variant?: CheckboxVariant;
|
|
36
|
+
checked?: boolean;
|
|
37
|
+
onChange?: (checked: boolean) => void;
|
|
38
|
+
indeterminate?: boolean;
|
|
39
|
+
size?: CheckboxSize;
|
|
40
|
+
color?: CheckboxColor;
|
|
41
|
+
label?: React.ReactNode;
|
|
42
|
+
description?: React.ReactNode;
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
className?: string;
|
|
45
|
+
name?: string;
|
|
46
|
+
value?: string;
|
|
47
|
+
id?: string;
|
|
48
|
+
}
|
|
49
|
+
declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
|
|
50
|
+
|
|
51
|
+
type CheckboxGroupVariant = "bordered" | "segmented";
|
|
52
|
+
interface CheckboxGroupProps {
|
|
53
|
+
variant?: CheckboxGroupVariant;
|
|
54
|
+
className?: string;
|
|
55
|
+
children: React.ReactNode;
|
|
56
|
+
}
|
|
57
|
+
declare function CheckboxGroup({ variant, className, children, }: CheckboxGroupProps): react_jsx_runtime.JSX.Element;
|
|
58
|
+
|
|
31
59
|
declare function cn(...inputs: ClassValue[]): string;
|
|
32
60
|
|
|
33
|
-
export { Button, type ButtonColor, ButtonGroup, type ButtonGroupProps, type ButtonGroupVariant, type ButtonProps, type ButtonShape, type ButtonSize, type ButtonVariant, cn };
|
|
61
|
+
export { Button, type ButtonColor, ButtonGroup, type ButtonGroupProps, type ButtonGroupVariant, type ButtonProps, type ButtonShape, type ButtonSize, type ButtonVariant, Checkbox, type CheckboxColor, CheckboxGroup, type CheckboxGroupProps, type CheckboxGroupVariant, type CheckboxProps, type CheckboxSize, type CheckboxVariant, cn };
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,8 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
Button: () => Button,
|
|
34
34
|
ButtonGroup: () => ButtonGroup,
|
|
35
|
+
Checkbox: () => Checkbox,
|
|
36
|
+
CheckboxGroup: () => CheckboxGroup,
|
|
35
37
|
cn: () => cn
|
|
36
38
|
});
|
|
37
39
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -3429,10 +3431,238 @@ function ButtonGroup({
|
|
|
3429
3431
|
}
|
|
3430
3432
|
);
|
|
3431
3433
|
}
|
|
3434
|
+
|
|
3435
|
+
// src/components/checkbox/checkbox.tsx
|
|
3436
|
+
var React3 = __toESM(require("react"));
|
|
3437
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
3438
|
+
function CheckIcon({ className, strokeWidth }) {
|
|
3439
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M20 6 9 17l-5-5" }) });
|
|
3440
|
+
}
|
|
3441
|
+
function MinusIcon({ className, strokeWidth }) {
|
|
3442
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M5 12h14" }) });
|
|
3443
|
+
}
|
|
3444
|
+
var SIZES2 = {
|
|
3445
|
+
xs: {
|
|
3446
|
+
box: "size-3.5",
|
|
3447
|
+
iconSize: "size-2.5",
|
|
3448
|
+
iconStroke: 3,
|
|
3449
|
+
labelFont: "text-xs",
|
|
3450
|
+
descFont: "text-[10px]",
|
|
3451
|
+
gap: "gap-1.5",
|
|
3452
|
+
cardPadding: "p-2"
|
|
3453
|
+
},
|
|
3454
|
+
sm: {
|
|
3455
|
+
box: "size-4",
|
|
3456
|
+
iconSize: "size-3",
|
|
3457
|
+
iconStroke: 3,
|
|
3458
|
+
labelFont: "text-sm",
|
|
3459
|
+
descFont: "text-xs",
|
|
3460
|
+
gap: "gap-2",
|
|
3461
|
+
cardPadding: "p-2.5"
|
|
3462
|
+
},
|
|
3463
|
+
md: {
|
|
3464
|
+
box: "size-5",
|
|
3465
|
+
iconSize: "size-3.5",
|
|
3466
|
+
iconStroke: 2.5,
|
|
3467
|
+
labelFont: "text-base",
|
|
3468
|
+
descFont: "text-sm",
|
|
3469
|
+
gap: "gap-2.5",
|
|
3470
|
+
cardPadding: "p-3"
|
|
3471
|
+
}
|
|
3472
|
+
};
|
|
3473
|
+
var COLORS2 = {
|
|
3474
|
+
default: {
|
|
3475
|
+
checked: "bg-zinc-900 border-zinc-900",
|
|
3476
|
+
hover: "group-hover/cb:border-zinc-400"
|
|
3477
|
+
},
|
|
3478
|
+
black: {
|
|
3479
|
+
checked: "bg-zinc-900 border-zinc-900",
|
|
3480
|
+
hover: "group-hover/cb:border-zinc-400"
|
|
3481
|
+
},
|
|
3482
|
+
primary: {
|
|
3483
|
+
checked: "bg-blue-600 border-blue-600",
|
|
3484
|
+
hover: "group-hover/cb:border-blue-300"
|
|
3485
|
+
},
|
|
3486
|
+
danger: {
|
|
3487
|
+
checked: "bg-red-500 border-red-500",
|
|
3488
|
+
hover: "group-hover/cb:border-red-300"
|
|
3489
|
+
},
|
|
3490
|
+
success: {
|
|
3491
|
+
checked: "bg-green-500 border-green-500",
|
|
3492
|
+
hover: "group-hover/cb:border-green-300"
|
|
3493
|
+
},
|
|
3494
|
+
warning: {
|
|
3495
|
+
checked: "bg-yellow-500 border-yellow-500",
|
|
3496
|
+
hover: "group-hover/cb:border-yellow-300"
|
|
3497
|
+
},
|
|
3498
|
+
info: {
|
|
3499
|
+
checked: "bg-indigo-500 border-indigo-500",
|
|
3500
|
+
hover: "group-hover/cb:border-indigo-300"
|
|
3501
|
+
}
|
|
3502
|
+
};
|
|
3503
|
+
var CARD_COLORS = {
|
|
3504
|
+
default: {
|
|
3505
|
+
checked: "bg-zinc-50 border-zinc-300 text-zinc-800",
|
|
3506
|
+
unchecked: "bg-white border-zinc-200 text-zinc-600 hover:bg-zinc-50 hover:border-zinc-300"
|
|
3507
|
+
},
|
|
3508
|
+
black: {
|
|
3509
|
+
checked: "bg-zinc-100 border-zinc-300 text-zinc-900",
|
|
3510
|
+
unchecked: "bg-white border-zinc-200 text-zinc-600 hover:bg-zinc-50 hover:border-zinc-300"
|
|
3511
|
+
},
|
|
3512
|
+
primary: {
|
|
3513
|
+
checked: "bg-blue-50/50 border-blue-200 text-blue-700",
|
|
3514
|
+
unchecked: "bg-white border-zinc-200 text-zinc-600 hover:bg-zinc-50 hover:border-zinc-300"
|
|
3515
|
+
},
|
|
3516
|
+
danger: {
|
|
3517
|
+
checked: "bg-red-50/50 border-red-200 text-red-700",
|
|
3518
|
+
unchecked: "bg-white border-zinc-200 text-zinc-600 hover:bg-zinc-50 hover:border-zinc-300"
|
|
3519
|
+
},
|
|
3520
|
+
success: {
|
|
3521
|
+
checked: "bg-green-50/50 border-green-200 text-green-700",
|
|
3522
|
+
unchecked: "bg-white border-zinc-200 text-zinc-600 hover:bg-zinc-50 hover:border-zinc-300"
|
|
3523
|
+
},
|
|
3524
|
+
warning: {
|
|
3525
|
+
checked: "bg-yellow-50/50 border-yellow-200 text-yellow-700",
|
|
3526
|
+
unchecked: "bg-white border-zinc-200 text-zinc-600 hover:bg-zinc-50 hover:border-zinc-300"
|
|
3527
|
+
},
|
|
3528
|
+
info: {
|
|
3529
|
+
checked: "bg-indigo-50/50 border-indigo-200 text-indigo-700",
|
|
3530
|
+
unchecked: "bg-white border-zinc-200 text-zinc-600 hover:bg-zinc-50 hover:border-zinc-300"
|
|
3531
|
+
}
|
|
3532
|
+
};
|
|
3533
|
+
var Checkbox = React3.forwardRef(
|
|
3534
|
+
({
|
|
3535
|
+
variant = "default",
|
|
3536
|
+
checked = false,
|
|
3537
|
+
onChange,
|
|
3538
|
+
indeterminate = false,
|
|
3539
|
+
size = "sm",
|
|
3540
|
+
color = "default",
|
|
3541
|
+
label,
|
|
3542
|
+
description,
|
|
3543
|
+
disabled = false,
|
|
3544
|
+
className,
|
|
3545
|
+
name,
|
|
3546
|
+
value,
|
|
3547
|
+
id: idProp
|
|
3548
|
+
}, ref) => {
|
|
3549
|
+
const autoId = React3.useId();
|
|
3550
|
+
const id = idProp || autoId;
|
|
3551
|
+
const s = SIZES2[size];
|
|
3552
|
+
const c = COLORS2[color];
|
|
3553
|
+
const isActive = checked || indeterminate;
|
|
3554
|
+
const handleChange = () => {
|
|
3555
|
+
if (disabled) return;
|
|
3556
|
+
onChange?.(!checked);
|
|
3557
|
+
};
|
|
3558
|
+
const variantClasses = (() => {
|
|
3559
|
+
switch (variant) {
|
|
3560
|
+
case "card": {
|
|
3561
|
+
const cc = CARD_COLORS[color];
|
|
3562
|
+
return cn(
|
|
3563
|
+
"rounded-xl border font-medium transition-colors",
|
|
3564
|
+
s.cardPadding,
|
|
3565
|
+
isActive ? cc.checked : cc.unchecked
|
|
3566
|
+
);
|
|
3567
|
+
}
|
|
3568
|
+
case "list":
|
|
3569
|
+
return "p-2 rounded-lg hover:bg-zinc-50 transition-colors";
|
|
3570
|
+
default:
|
|
3571
|
+
return "";
|
|
3572
|
+
}
|
|
3573
|
+
})();
|
|
3574
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
3575
|
+
"label",
|
|
3576
|
+
{
|
|
3577
|
+
htmlFor: id,
|
|
3578
|
+
className: cn(
|
|
3579
|
+
"group/cb inline-flex items-start select-none",
|
|
3580
|
+
s.gap,
|
|
3581
|
+
disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer",
|
|
3582
|
+
variantClasses,
|
|
3583
|
+
className
|
|
3584
|
+
),
|
|
3585
|
+
children: [
|
|
3586
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
3587
|
+
"input",
|
|
3588
|
+
{
|
|
3589
|
+
ref,
|
|
3590
|
+
id,
|
|
3591
|
+
type: "checkbox",
|
|
3592
|
+
className: "sr-only",
|
|
3593
|
+
checked,
|
|
3594
|
+
onChange: handleChange,
|
|
3595
|
+
disabled,
|
|
3596
|
+
name,
|
|
3597
|
+
value
|
|
3598
|
+
}
|
|
3599
|
+
),
|
|
3600
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
3601
|
+
"div",
|
|
3602
|
+
{
|
|
3603
|
+
className: cn(
|
|
3604
|
+
"shrink-0 flex items-center justify-center rounded transition-all duration-150 mt-0.5",
|
|
3605
|
+
s.box,
|
|
3606
|
+
isActive ? cn(c.checked, "text-white") : cn("border border-zinc-300 bg-white", !disabled && c.hover)
|
|
3607
|
+
),
|
|
3608
|
+
children: [
|
|
3609
|
+
checked && !indeterminate && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CheckIcon, { className: s.iconSize, strokeWidth: s.iconStroke }),
|
|
3610
|
+
indeterminate && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MinusIcon, { className: s.iconSize, strokeWidth: s.iconStroke })
|
|
3611
|
+
]
|
|
3612
|
+
}
|
|
3613
|
+
),
|
|
3614
|
+
(label || description) && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex flex-col min-w-0", children: [
|
|
3615
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: cn("font-medium", s.labelFont, variant === "default" && "text-zinc-700"), children: label }),
|
|
3616
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: cn("text-zinc-400 mt-0.5", s.descFont), children: description })
|
|
3617
|
+
] })
|
|
3618
|
+
]
|
|
3619
|
+
}
|
|
3620
|
+
);
|
|
3621
|
+
}
|
|
3622
|
+
);
|
|
3623
|
+
Checkbox.displayName = "Checkbox";
|
|
3624
|
+
|
|
3625
|
+
// src/components/checkbox-group/checkbox-group.tsx
|
|
3626
|
+
var React4 = __toESM(require("react"));
|
|
3627
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
3628
|
+
function CheckboxGroup({
|
|
3629
|
+
variant = "bordered",
|
|
3630
|
+
className,
|
|
3631
|
+
children
|
|
3632
|
+
}) {
|
|
3633
|
+
const items = React4.Children.toArray(children).filter(React4.isValidElement);
|
|
3634
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3635
|
+
"div",
|
|
3636
|
+
{
|
|
3637
|
+
className: cn(
|
|
3638
|
+
"inline-flex items-center rounded-lg",
|
|
3639
|
+
variant === "bordered" ? "bg-white border border-zinc-200" : "bg-zinc-100 p-1 gap-px",
|
|
3640
|
+
className
|
|
3641
|
+
),
|
|
3642
|
+
children: items.map((child, index) => {
|
|
3643
|
+
const childProps = child.props;
|
|
3644
|
+
const isChecked = !!childProps.checked;
|
|
3645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(React4.Fragment, { children: [
|
|
3646
|
+
React4.cloneElement(child, {
|
|
3647
|
+
className: cn(
|
|
3648
|
+
childProps.className,
|
|
3649
|
+
"border-0",
|
|
3650
|
+
variant === "segmented" && !isChecked && "bg-transparent hover:bg-white/80",
|
|
3651
|
+
variant === "segmented" && isChecked && "bg-white shadow-sm text-zinc-900"
|
|
3652
|
+
)
|
|
3653
|
+
}),
|
|
3654
|
+
variant === "bordered" && index < items.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "w-px self-stretch my-2 bg-zinc-200 shrink-0" })
|
|
3655
|
+
] }, index);
|
|
3656
|
+
})
|
|
3657
|
+
}
|
|
3658
|
+
);
|
|
3659
|
+
}
|
|
3432
3660
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3433
3661
|
0 && (module.exports = {
|
|
3434
3662
|
Button,
|
|
3435
3663
|
ButtonGroup,
|
|
3664
|
+
Checkbox,
|
|
3665
|
+
CheckboxGroup,
|
|
3436
3666
|
cn
|
|
3437
3667
|
});
|
|
3438
3668
|
//# sourceMappingURL=index.js.map
|