@aiready/components 0.14.5 → 0.14.6
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/checkbox.js +3 -1
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/separator.js +1 -0
- package/dist/components/separator.js.map +1 -1
- package/dist/components/switch.js +64 -42
- package/dist/components/switch.js.map +1 -1
- package/dist/index.js +68 -43
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/checkbox.tsx +3 -1
- package/src/components/separator.tsx +1 -0
- package/src/components/switch.tsx +62 -41
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiready/components",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.6",
|
|
4
4
|
"description": "Unified shared components library (UI, charts, hooks, utilities) for AIReady",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"framer-motion": "^12.35.0",
|
|
129
129
|
"lucide-react": "^0.577.0",
|
|
130
130
|
"tailwind-merge": "^3.0.0",
|
|
131
|
-
"@aiready/core": "0.24.
|
|
131
|
+
"@aiready/core": "0.24.7"
|
|
132
132
|
},
|
|
133
133
|
"devDependencies": {
|
|
134
134
|
"@testing-library/jest-dom": "^6.6.5",
|
|
@@ -18,8 +18,10 @@ const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
|
|
|
18
18
|
type="checkbox"
|
|
19
19
|
id={checkboxId}
|
|
20
20
|
ref={ref}
|
|
21
|
+
role="checkbox"
|
|
22
|
+
aria-checked={props.checked ? 'true' : 'false'}
|
|
21
23
|
className={cn(
|
|
22
|
-
'h-4 w-4 rounded border-gray-300 text-primary focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
|
|
24
|
+
'peer h-4 w-4 rounded border-gray-300 text-primary focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
|
|
23
25
|
className
|
|
24
26
|
)}
|
|
25
27
|
{...props}
|
|
@@ -15,6 +15,7 @@ const Separator = React.forwardRef<HTMLDivElement, SeparatorProps>(
|
|
|
15
15
|
ref={ref}
|
|
16
16
|
role={decorative ? 'none' : 'separator'}
|
|
17
17
|
aria-orientation={orientation}
|
|
18
|
+
data-orientation={orientation}
|
|
18
19
|
className={cn(
|
|
19
20
|
'shrink-0 bg-border',
|
|
20
21
|
orientation === 'horizontal' ? 'h-[1px] w-full' : 'h-full w-[1px]',
|
|
@@ -9,49 +9,70 @@ export interface SwitchProps extends Omit<
|
|
|
9
9
|
onCheckedChange?: (checked: boolean) => void;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
const Switch = React.forwardRef<HTMLInputElement, SwitchProps>(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
const Switch = React.forwardRef<HTMLInputElement, SwitchProps>((props, ref) => {
|
|
13
|
+
const {
|
|
14
|
+
className,
|
|
15
|
+
label,
|
|
16
|
+
id,
|
|
17
|
+
checked,
|
|
18
|
+
onCheckedChange,
|
|
19
|
+
onChange,
|
|
20
|
+
disabled,
|
|
21
|
+
...restProps
|
|
22
|
+
} = props;
|
|
23
|
+
const switchId = id || React.useId();
|
|
24
|
+
const isChecked = checked ?? false;
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
onCheckedChange?.(e.target.checked);
|
|
22
|
-
};
|
|
26
|
+
// Destructure restProps to omit attributes that cause React warnings/errors on buttons
|
|
27
|
+
const { type: _type, ...buttonProps } = restProps as any;
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
)
|
|
29
|
+
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
30
|
+
onChange?.(e);
|
|
31
|
+
onCheckedChange?.(e.target.checked);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div className="flex items-center">
|
|
36
|
+
<label
|
|
37
|
+
htmlFor={switchId}
|
|
38
|
+
className="relative inline-flex cursor-pointer items-center"
|
|
39
|
+
>
|
|
40
|
+
<input
|
|
41
|
+
type="checkbox"
|
|
42
|
+
id={switchId}
|
|
43
|
+
ref={ref}
|
|
44
|
+
checked={isChecked}
|
|
45
|
+
onChange={handleChange}
|
|
46
|
+
className="peer sr-only"
|
|
47
|
+
disabled={disabled}
|
|
48
|
+
/>
|
|
49
|
+
<button
|
|
50
|
+
type="button"
|
|
51
|
+
role="switch"
|
|
52
|
+
aria-checked={isChecked}
|
|
53
|
+
disabled={disabled}
|
|
54
|
+
className={cn(
|
|
55
|
+
'peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input',
|
|
56
|
+
'bg-gray-200 after:absolute after:left-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:border after:border-gray-300 after:bg-white after:transition-all after:content-[""] peer-checked:bg-primary peer-checked:after:translate-x-full peer-checked:after:border-white peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-ring peer-focus:ring-offset-2 peer-disabled:cursor-not-allowed peer-disabled:opacity-50',
|
|
57
|
+
className
|
|
58
|
+
)}
|
|
59
|
+
onClick={() => {
|
|
60
|
+
if (!disabled) {
|
|
61
|
+
const newChecked = !isChecked;
|
|
62
|
+
onCheckedChange?.(newChecked);
|
|
63
|
+
}
|
|
64
|
+
}}
|
|
65
|
+
{...buttonProps}
|
|
66
|
+
/>
|
|
67
|
+
</label>
|
|
68
|
+
{label && (
|
|
69
|
+
<span className="ml-3 text-sm font-medium text-foreground">
|
|
70
|
+
{label}
|
|
71
|
+
</span>
|
|
72
|
+
)}
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
});
|
|
55
76
|
Switch.displayName = 'Switch';
|
|
56
77
|
|
|
57
78
|
export { Switch };
|