asterui 0.12.24 → 0.12.25
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/Card.d.ts +24 -7
- package/dist/components/Tag.d.ts +8 -4
- package/dist/components/TreeSelect.d.ts +35 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +43 -42
- package/dist/index11.js +55 -55
- package/dist/index11.js.map +1 -1
- package/dist/index13.js +39 -39
- package/dist/index13.js.map +1 -1
- package/dist/index14.js +192 -107
- package/dist/index14.js.map +1 -1
- package/dist/index15.js +1 -1
- package/dist/index15.js.map +1 -1
- package/dist/index30.js +9 -8
- package/dist/index30.js.map +1 -1
- package/dist/index35.js +35 -36
- package/dist/index35.js.map +1 -1
- package/dist/index43.js +19 -20
- package/dist/index43.js.map +1 -1
- package/dist/index44.js +6 -7
- package/dist/index44.js.map +1 -1
- package/dist/index5.js +9 -9
- package/dist/index5.js.map +1 -1
- package/dist/index61.js +7 -7
- package/dist/index61.js.map +1 -1
- package/dist/index62.js +10 -10
- package/dist/index62.js.map +1 -1
- package/dist/index85.js +126 -92
- package/dist/index85.js.map +1 -1
- package/dist/index92.js +1 -1
- package/dist/index92.js.map +1 -1
- package/dist/index94.js +478 -385
- package/dist/index94.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
export type CardSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
3
|
+
export type CardVariant = 'default' | 'border' | 'dash' | 'borderless';
|
|
4
|
+
export interface CardTabItem {
|
|
5
|
+
key: string;
|
|
6
|
+
label: React.ReactNode;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
}
|
|
2
9
|
export interface CardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
3
10
|
children?: React.ReactNode;
|
|
4
11
|
title?: React.ReactNode;
|
|
@@ -6,8 +13,13 @@ export interface CardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 't
|
|
|
6
13
|
extra?: React.ReactNode;
|
|
7
14
|
cover?: React.ReactNode;
|
|
8
15
|
actions?: React.ReactNode;
|
|
9
|
-
size?:
|
|
16
|
+
size?: CardSize;
|
|
17
|
+
/** @deprecated Use variant instead */
|
|
10
18
|
bordered?: boolean;
|
|
19
|
+
/** Card style variant */
|
|
20
|
+
variant?: CardVariant;
|
|
21
|
+
/** Inner card style (nested cards) */
|
|
22
|
+
type?: 'inner';
|
|
11
23
|
side?: boolean;
|
|
12
24
|
imageFull?: boolean;
|
|
13
25
|
actionsJustify?: 'start' | 'center' | 'end';
|
|
@@ -15,6 +27,12 @@ export interface CardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 't
|
|
|
15
27
|
hoverable?: boolean;
|
|
16
28
|
avatar?: React.ReactNode;
|
|
17
29
|
description?: React.ReactNode;
|
|
30
|
+
tabList?: CardTabItem[];
|
|
31
|
+
activeTabKey?: string;
|
|
32
|
+
defaultActiveTabKey?: string;
|
|
33
|
+
onTabChange?: (key: string) => void;
|
|
34
|
+
tabBarExtraContent?: React.ReactNode;
|
|
35
|
+
'data-testid'?: string;
|
|
18
36
|
}
|
|
19
37
|
export interface CardMetaProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
20
38
|
/** Avatar or icon element */
|
|
@@ -23,16 +41,15 @@ export interface CardMetaProps extends Omit<React.HTMLAttributes<HTMLDivElement>
|
|
|
23
41
|
title?: React.ReactNode;
|
|
24
42
|
/** Description content */
|
|
25
43
|
description?: React.ReactNode;
|
|
44
|
+
'data-testid'?: string;
|
|
26
45
|
}
|
|
27
46
|
export interface CardGridProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
28
47
|
children: React.ReactNode;
|
|
29
48
|
hoverable?: boolean;
|
|
49
|
+
'data-testid'?: string;
|
|
30
50
|
}
|
|
31
|
-
declare
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export declare const Card: typeof CardRoot & {
|
|
35
|
-
Grid: typeof CardGrid;
|
|
36
|
-
Meta: typeof CardMeta;
|
|
51
|
+
export declare const Card: React.ForwardRefExoticComponent<CardProps & React.RefAttributes<HTMLDivElement>> & {
|
|
52
|
+
Grid: React.ForwardRefExoticComponent<CardGridProps & React.RefAttributes<HTMLDivElement>>;
|
|
53
|
+
Meta: React.ForwardRefExoticComponent<CardMetaProps & React.RefAttributes<HTMLDivElement>>;
|
|
37
54
|
};
|
|
38
55
|
export default Card;
|
package/dist/components/Tag.d.ts
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
export type TagSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
3
|
+
export type TagColor = 'primary' | 'secondary' | 'accent' | 'neutral' | 'info' | 'success' | 'warning' | 'error' | 'ghost';
|
|
2
4
|
export interface TagProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'color'> {
|
|
3
5
|
closable?: boolean;
|
|
4
6
|
closeIcon?: React.ReactNode;
|
|
5
7
|
onClose?: () => void;
|
|
6
|
-
color?: string;
|
|
8
|
+
color?: TagColor | string;
|
|
7
9
|
icon?: React.ReactNode;
|
|
8
|
-
size?:
|
|
10
|
+
size?: TagSize;
|
|
9
11
|
children?: React.ReactNode;
|
|
12
|
+
'data-testid'?: string;
|
|
10
13
|
}
|
|
11
14
|
export interface CheckableTagProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'onChange'> {
|
|
12
15
|
checked?: boolean;
|
|
13
16
|
onChange?: (checked: boolean) => void;
|
|
14
17
|
icon?: React.ReactNode;
|
|
15
18
|
children?: React.ReactNode;
|
|
19
|
+
'data-testid'?: string;
|
|
16
20
|
}
|
|
17
|
-
export declare const Tag: React.
|
|
18
|
-
export declare const CheckableTag: React.
|
|
21
|
+
export declare const Tag: React.ForwardRefExoticComponent<TagProps & React.RefAttributes<HTMLSpanElement>>;
|
|
22
|
+
export declare const CheckableTag: React.ForwardRefExoticComponent<CheckableTagProps & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { TreeDataNode } from './Tree';
|
|
3
3
|
export type TreeSelectSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
4
|
-
export type TreeSelectColor = 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error';
|
|
4
|
+
export type TreeSelectColor = 'primary' | 'secondary' | 'accent' | 'neutral' | 'info' | 'success' | 'warning' | 'error';
|
|
5
5
|
export type TreeSelectStatus = 'error' | 'warning';
|
|
6
|
+
export type TreeSelectVariant = 'outlined' | 'filled' | 'borderless';
|
|
6
7
|
export type ShowCheckedStrategy = 'SHOW_ALL' | 'SHOW_PARENT' | 'SHOW_CHILD';
|
|
7
8
|
export interface TreeSelectFieldNames {
|
|
8
9
|
label?: string;
|
|
9
10
|
value?: string;
|
|
10
11
|
children?: string;
|
|
11
12
|
}
|
|
13
|
+
/** Value type when labelInValue is true */
|
|
14
|
+
export interface LabeledValue {
|
|
15
|
+
value: string;
|
|
16
|
+
label: React.ReactNode;
|
|
17
|
+
}
|
|
12
18
|
export interface TreeSelectProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {
|
|
13
19
|
treeData: TreeDataNode[];
|
|
14
|
-
value?: string | string[];
|
|
15
|
-
defaultValue?: string | string[];
|
|
16
|
-
onChange?: (value: string | string[], labels: React.ReactNode[]
|
|
20
|
+
value?: string | string[] | LabeledValue | LabeledValue[];
|
|
21
|
+
defaultValue?: string | string[] | LabeledValue | LabeledValue[];
|
|
22
|
+
onChange?: (value: string | string[] | LabeledValue | LabeledValue[], labels: React.ReactNode[], extra?: {
|
|
23
|
+
triggerValue: string;
|
|
24
|
+
triggerNode: TreeDataNode;
|
|
25
|
+
}) => void;
|
|
17
26
|
multiple?: boolean;
|
|
18
27
|
treeCheckable?: boolean;
|
|
19
28
|
treeCheckStrictly?: boolean;
|
|
@@ -32,10 +41,26 @@ export interface TreeSelectProps extends Omit<React.HTMLAttributes<HTMLDivElemen
|
|
|
32
41
|
size?: TreeSelectSize;
|
|
33
42
|
color?: TreeSelectColor;
|
|
34
43
|
status?: TreeSelectStatus;
|
|
44
|
+
/** Visual variant style */
|
|
45
|
+
variant?: TreeSelectVariant;
|
|
46
|
+
/** Ghost style with no background */
|
|
47
|
+
ghost?: boolean;
|
|
48
|
+
/** Maximum number of tags to show (multiple/treeCheckable mode) */
|
|
35
49
|
maxTagCount?: number | 'responsive';
|
|
36
50
|
maxTagPlaceholder?: React.ReactNode | ((omittedValues: string[]) => React.ReactNode);
|
|
51
|
+
/** Maximum number of selections allowed */
|
|
52
|
+
maxCount?: number;
|
|
53
|
+
/** Return object with value and label instead of just value */
|
|
37
54
|
labelInValue?: boolean;
|
|
55
|
+
/** Custom tag render function */
|
|
56
|
+
tagRender?: (props: {
|
|
57
|
+
label: React.ReactNode;
|
|
58
|
+
value: string;
|
|
59
|
+
closable: boolean;
|
|
60
|
+
onClose: () => void;
|
|
61
|
+
}) => React.ReactNode;
|
|
38
62
|
treeLine?: boolean;
|
|
63
|
+
/** Show tree node icon */
|
|
39
64
|
treeIcon?: boolean;
|
|
40
65
|
loadData?: (node: TreeDataNode) => Promise<void>;
|
|
41
66
|
fieldNames?: TreeSelectFieldNames;
|
|
@@ -51,3 +76,9 @@ export interface TreeSelectProps extends Omit<React.HTMLAttributes<HTMLDivElemen
|
|
|
51
76
|
'data-testid'?: string;
|
|
52
77
|
}
|
|
53
78
|
export declare const TreeSelect: React.ForwardRefExoticComponent<TreeSelectProps & React.RefAttributes<HTMLDivElement>>;
|
|
79
|
+
export declare const TreeSelectComponent: React.ForwardRefExoticComponent<TreeSelectProps & React.RefAttributes<HTMLDivElement>> & {
|
|
80
|
+
SHOW_ALL: "SHOW_ALL";
|
|
81
|
+
SHOW_PARENT: "SHOW_PARENT";
|
|
82
|
+
SHOW_CHILD: "SHOW_CHILD";
|
|
83
|
+
};
|
|
84
|
+
export { TreeSelectComponent as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export type { ChatProps } from './components/Chat';
|
|
|
23
23
|
export { ColorPicker } from './components/ColorPicker';
|
|
24
24
|
export type { ColorPickerProps } from './components/ColorPicker';
|
|
25
25
|
export { Card } from './components/Card';
|
|
26
|
-
export type { CardProps, CardGridProps } from './components/Card';
|
|
26
|
+
export type { CardProps, CardGridProps, CardMetaProps, CardSize, CardVariant, CardTabItem } from './components/Card';
|
|
27
27
|
export { Cascader } from './components/Cascader';
|
|
28
28
|
export type { CascaderProps, CascaderOption } from './components/Cascader';
|
|
29
29
|
export { Chart } from './components/Chart';
|
|
@@ -165,7 +165,7 @@ export type { TextareaProps } from './components/Textarea';
|
|
|
165
165
|
export { TextRotate } from './components/TextRotate';
|
|
166
166
|
export type { TextRotateProps, TextRotateDuration } from './components/TextRotate';
|
|
167
167
|
export { Tag, CheckableTag } from './components/Tag';
|
|
168
|
-
export type { TagProps, CheckableTagProps } from './components/Tag';
|
|
168
|
+
export type { TagProps, CheckableTagProps, TagSize, TagColor } from './components/Tag';
|
|
169
169
|
export { ThemeController } from './components/ThemeController';
|
|
170
170
|
export type { ThemeControllerSwapProps, ThemeControllerDropdownProps, ThemeControllerToggleProps } from './components/ThemeController';
|
|
171
171
|
export { TimePicker } from './components/TimePicker';
|
|
@@ -182,8 +182,8 @@ export { Transfer } from './components/Transfer';
|
|
|
182
182
|
export type { TransferProps, TransferItem } from './components/Transfer';
|
|
183
183
|
export { Tree } from './components/Tree';
|
|
184
184
|
export type { TreeProps, TreeDataNode } from './components/Tree';
|
|
185
|
-
export { TreeSelect } from './components/TreeSelect';
|
|
186
|
-
export type { TreeSelectProps, TreeSelectSize, TreeSelectColor, TreeSelectStatus, TreeSelectFieldNames, ShowCheckedStrategy, } from './components/TreeSelect';
|
|
185
|
+
export { TreeSelect, TreeSelectComponent } from './components/TreeSelect';
|
|
186
|
+
export type { TreeSelectProps, TreeSelectSize, TreeSelectColor, TreeSelectStatus, TreeSelectVariant, TreeSelectFieldNames, ShowCheckedStrategy, LabeledValue, } from './components/TreeSelect';
|
|
187
187
|
export { Typography } from './components/Typography';
|
|
188
188
|
export type { TypographyProps, TitleProps, ParagraphProps, TextProps, TypographyLinkProps, TypographySize, TitleLevel, } from './components/Typography';
|
|
189
189
|
export { Upload } from './components/Upload';
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Avatar as n, AvatarGroup as s } from "./index6.js";
|
|
|
6
6
|
import { Badge as l } from "./index7.js";
|
|
7
7
|
import { Breadcrumb as c } from "./index8.js";
|
|
8
8
|
import { Button as T } from "./index9.js";
|
|
9
|
-
import { CopyButton as
|
|
9
|
+
import { CopyButton as S } from "./index10.js";
|
|
10
10
|
import { Checkbox as b } from "./index11.js";
|
|
11
11
|
import { Chat as y } from "./index12.js";
|
|
12
12
|
import { ColorPicker as h } from "./index13.js";
|
|
@@ -32,7 +32,7 @@ import { Flex as io } from "./index32.js";
|
|
|
32
32
|
import { FloatButton as so } from "./index33.js";
|
|
33
33
|
import { Footer as lo } from "./index34.js";
|
|
34
34
|
import { Form as Co, useFormInstance as To } from "./index35.js";
|
|
35
|
-
import { Col as
|
|
35
|
+
import { Col as So, Grid as Po, Row as bo } from "./index36.js";
|
|
36
36
|
import { Hero as yo } from "./index37.js";
|
|
37
37
|
import { HoverGallery as ho } from "./index38.js";
|
|
38
38
|
import { Image as vo } from "./index39.js";
|
|
@@ -58,7 +58,7 @@ import { Modal as ur } from "./index58.js";
|
|
|
58
58
|
import { Navbar as dr } from "./index59.js";
|
|
59
59
|
import { notification as Cr } from "./index60.js";
|
|
60
60
|
import { OTPInput as gr } from "./index61.js";
|
|
61
|
-
import { Pagination as
|
|
61
|
+
import { Pagination as Pr } from "./index62.js";
|
|
62
62
|
import { PageLayout as kr } from "./index63.js";
|
|
63
63
|
import { Popconfirm as Dr } from "./index64.js";
|
|
64
64
|
import { Popover as wr } from "./index65.js";
|
|
@@ -84,28 +84,28 @@ import { TextRotate as ne } from "./index84.js";
|
|
|
84
84
|
import { CheckableTag as ue, Tag as le } from "./index85.js";
|
|
85
85
|
import { ThemeController as ce } from "./index86.js";
|
|
86
86
|
import { TimePicker as Te } from "./index87.js";
|
|
87
|
-
import { Timeline as
|
|
87
|
+
import { Timeline as Se } from "./index88.js";
|
|
88
88
|
import { Toggle as be } from "./index89.js";
|
|
89
89
|
import { Tour as ye } from "./index90.js";
|
|
90
90
|
import { Tooltip as he } from "./index91.js";
|
|
91
91
|
import { Transfer as ve } from "./index92.js";
|
|
92
92
|
import { Tree as Re } from "./index93.js";
|
|
93
|
-
import { TreeSelect as Ie } from "./index94.js";
|
|
94
|
-
import { Typography as
|
|
95
|
-
import { Upload as
|
|
96
|
-
import { VirtualList as
|
|
97
|
-
import { Watermark as
|
|
98
|
-
import { Hide as
|
|
99
|
-
import { useBreakpoint as
|
|
100
|
-
import { useDisclosure as
|
|
101
|
-
import { useClipboard as
|
|
102
|
-
import { useLocalStorage as
|
|
103
|
-
import { useDebounce as
|
|
104
|
-
import { useClickOutside as
|
|
105
|
-
import { usePrevious as
|
|
106
|
-
import { useHover as
|
|
107
|
-
import { useKeyPress as
|
|
108
|
-
import { useWindowSize as
|
|
93
|
+
import { TreeSelect as Ie, TreeSelectComponent as Ae } from "./index94.js";
|
|
94
|
+
import { Typography as Me } from "./index95.js";
|
|
95
|
+
import { Upload as Ge } from "./index96.js";
|
|
96
|
+
import { VirtualList as We } from "./index97.js";
|
|
97
|
+
import { Watermark as Oe } from "./index98.js";
|
|
98
|
+
import { Hide as Ee, Show as Je } from "./index99.js";
|
|
99
|
+
import { useBreakpoint as Ue } from "./index100.js";
|
|
100
|
+
import { useDisclosure as je } from "./index101.js";
|
|
101
|
+
import { useClipboard as Xe } from "./index102.js";
|
|
102
|
+
import { useLocalStorage as Ze } from "./index103.js";
|
|
103
|
+
import { useDebounce as $e } from "./index104.js";
|
|
104
|
+
import { useClickOutside as rt } from "./index105.js";
|
|
105
|
+
import { usePrevious as tt } from "./index106.js";
|
|
106
|
+
import { useHover as mt } from "./index107.js";
|
|
107
|
+
import { useKeyPress as xt, useKeyPressCallback as at } from "./index108.js";
|
|
108
|
+
import { useWindowSize as nt } from "./index109.js";
|
|
109
109
|
export {
|
|
110
110
|
e as Affix,
|
|
111
111
|
f as Alert,
|
|
@@ -125,12 +125,12 @@ export {
|
|
|
125
125
|
ue as CheckableTag,
|
|
126
126
|
b as Checkbox,
|
|
127
127
|
fr as Code,
|
|
128
|
-
|
|
128
|
+
So as Col,
|
|
129
129
|
H as Collapse,
|
|
130
130
|
h as ColorPicker,
|
|
131
131
|
K as Container,
|
|
132
132
|
N as ContextMenu,
|
|
133
|
-
|
|
133
|
+
S as CopyButton,
|
|
134
134
|
z as Countdown,
|
|
135
135
|
J as DatePicker,
|
|
136
136
|
U as Descriptions,
|
|
@@ -147,9 +147,9 @@ export {
|
|
|
147
147
|
so as FloatButton,
|
|
148
148
|
lo as Footer,
|
|
149
149
|
Co as Form,
|
|
150
|
-
|
|
150
|
+
Po as Grid,
|
|
151
151
|
yo as Hero,
|
|
152
|
-
|
|
152
|
+
Ee as Hide,
|
|
153
153
|
ho as HoverGallery,
|
|
154
154
|
vo as Image,
|
|
155
155
|
Ro as Indicator,
|
|
@@ -168,7 +168,7 @@ export {
|
|
|
168
168
|
dr as Navbar,
|
|
169
169
|
gr as OTPInput,
|
|
170
170
|
kr as PageLayout,
|
|
171
|
-
|
|
171
|
+
Pr as Pagination,
|
|
172
172
|
ar as Phone,
|
|
173
173
|
Dr as Popconfirm,
|
|
174
174
|
wr as Popover,
|
|
@@ -182,7 +182,7 @@ export {
|
|
|
182
182
|
bo as Row,
|
|
183
183
|
Qr as Segmented,
|
|
184
184
|
Er as Select,
|
|
185
|
-
|
|
185
|
+
Je as Show,
|
|
186
186
|
ro as SidebarDrawer,
|
|
187
187
|
Vr as Skeleton,
|
|
188
188
|
qr as Space,
|
|
@@ -197,31 +197,32 @@ export {
|
|
|
197
197
|
ae as Textarea,
|
|
198
198
|
ce as ThemeController,
|
|
199
199
|
Te as TimePicker,
|
|
200
|
-
|
|
200
|
+
Se as Timeline,
|
|
201
201
|
be as Toggle,
|
|
202
202
|
he as Tooltip,
|
|
203
203
|
ye as Tour,
|
|
204
204
|
ve as Transfer,
|
|
205
205
|
Re as Tree,
|
|
206
206
|
Ie as TreeSelect,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
Ae as TreeSelectComponent,
|
|
208
|
+
Me as Typography,
|
|
209
|
+
Ge as Upload,
|
|
210
|
+
We as VirtualList,
|
|
211
|
+
Oe as Watermark,
|
|
211
212
|
nr as Window,
|
|
212
213
|
Cr as notification,
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
214
|
+
Ue as useBreakpoint,
|
|
215
|
+
rt as useClickOutside,
|
|
216
|
+
Xe as useClipboard,
|
|
217
|
+
$e as useDebounce,
|
|
218
|
+
je as useDisclosure,
|
|
218
219
|
To as useFormInstance,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
220
|
+
mt as useHover,
|
|
221
|
+
xt as useKeyPress,
|
|
222
|
+
at as useKeyPressCallback,
|
|
223
|
+
Ze as useLocalStorage,
|
|
224
|
+
tt as usePrevious,
|
|
224
225
|
Qo as useSiderContext,
|
|
225
|
-
|
|
226
|
+
nt as useWindowSize
|
|
226
227
|
};
|
|
227
228
|
//# sourceMappingURL=index.js.map
|
package/dist/index11.js
CHANGED
|
@@ -2,49 +2,49 @@ import { jsxs as p, jsx as c } from "react/jsx-runtime";
|
|
|
2
2
|
import R, { forwardRef as G, useContext as $, createContext as B } from "react";
|
|
3
3
|
const y = B(null);
|
|
4
4
|
function I({
|
|
5
|
-
children:
|
|
6
|
-
value:
|
|
7
|
-
defaultValue:
|
|
5
|
+
children: x,
|
|
6
|
+
value: r,
|
|
7
|
+
defaultValue: b,
|
|
8
8
|
onChange: d,
|
|
9
|
-
disabled:
|
|
9
|
+
disabled: a = !1,
|
|
10
10
|
options: h,
|
|
11
|
-
direction:
|
|
11
|
+
direction: s = "vertical",
|
|
12
12
|
className: u = ""
|
|
13
13
|
}) {
|
|
14
|
-
const [C, g] = R.useState(
|
|
15
|
-
value:
|
|
14
|
+
const [C, g] = R.useState(b || []), l = r !== void 0 ? r : C, t = {
|
|
15
|
+
value: l,
|
|
16
16
|
onChange: (i, e) => {
|
|
17
|
-
const k = e ? [...
|
|
18
|
-
|
|
17
|
+
const k = e ? [...l, i] : l.filter((f) => f !== i);
|
|
18
|
+
r === void 0 && g(k), d?.(k);
|
|
19
19
|
},
|
|
20
|
-
disabled:
|
|
20
|
+
disabled: a
|
|
21
21
|
};
|
|
22
22
|
if (h) {
|
|
23
|
-
const i =
|
|
24
|
-
return /* @__PURE__ */ c(y.Provider, { value: t, children: /* @__PURE__ */ c("div", { className: `${i} ${u}`.trim(), children: h.map((e) => typeof e == "string" || typeof e == "number" ? /* @__PURE__ */ p("label", { className: "
|
|
23
|
+
const i = s === "horizontal" ? "flex flex-row flex-wrap gap-4" : "flex flex-col";
|
|
24
|
+
return /* @__PURE__ */ c(y.Provider, { value: t, children: /* @__PURE__ */ c("div", { className: `${i} ${u}`.trim(), children: h.map((e) => typeof e == "string" || typeof e == "number" ? /* @__PURE__ */ p("label", { className: "flex items-center cursor-pointer gap-2", children: [
|
|
25
25
|
/* @__PURE__ */ c(m, { value: e }),
|
|
26
|
-
/* @__PURE__ */ c("span", {
|
|
27
|
-
] }, e) : /* @__PURE__ */ p("label", { className: "
|
|
26
|
+
/* @__PURE__ */ c("span", { children: e })
|
|
27
|
+
] }, e) : /* @__PURE__ */ p("label", { className: "flex items-center cursor-pointer gap-2", children: [
|
|
28
28
|
/* @__PURE__ */ c(m, { value: e.value, disabled: e.disabled }),
|
|
29
|
-
/* @__PURE__ */ c("span", {
|
|
29
|
+
/* @__PURE__ */ c("span", { children: e.label })
|
|
30
30
|
] }, e.value)) }) });
|
|
31
31
|
}
|
|
32
|
-
return /* @__PURE__ */ c(y.Provider, { value: t, children: /* @__PURE__ */ c("div", { className: u, children:
|
|
32
|
+
return /* @__PURE__ */ c(y.Provider, { value: t, children: /* @__PURE__ */ c("div", { className: u, children: x }) });
|
|
33
33
|
}
|
|
34
34
|
const m = G(
|
|
35
35
|
({
|
|
36
|
-
children:
|
|
37
|
-
size:
|
|
38
|
-
color:
|
|
36
|
+
children: x,
|
|
37
|
+
size: r,
|
|
38
|
+
color: b,
|
|
39
39
|
indeterminate: d = !1,
|
|
40
|
-
swap:
|
|
40
|
+
swap: a,
|
|
41
41
|
className: h = "",
|
|
42
|
-
value:
|
|
42
|
+
value: s,
|
|
43
43
|
checked: u,
|
|
44
44
|
onChange: C,
|
|
45
45
|
disabled: g,
|
|
46
|
-
...
|
|
47
|
-
},
|
|
46
|
+
...l
|
|
47
|
+
}, o) => {
|
|
48
48
|
const t = $(y), i = {
|
|
49
49
|
xs: "checkbox-xs",
|
|
50
50
|
sm: "checkbox-sm",
|
|
@@ -62,58 +62,58 @@ const m = G(
|
|
|
62
62
|
error: "checkbox-error"
|
|
63
63
|
}, k = [
|
|
64
64
|
"checkbox",
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
].filter(Boolean).join(" "),
|
|
68
|
-
t &&
|
|
65
|
+
r && i[r],
|
|
66
|
+
b && e[b]
|
|
67
|
+
].filter(Boolean).join(" "), f = t && s !== void 0 && (typeof s == "string" || typeof s == "number") ? t.value?.includes(s) ?? !1 : u, v = t?.disabled || g, w = (n) => {
|
|
68
|
+
t && s !== void 0 && (typeof s == "string" || typeof s == "number") && t.onChange?.(s, n.target.checked), C?.(n);
|
|
69
69
|
}, V = R.useCallback(
|
|
70
|
-
(
|
|
71
|
-
|
|
70
|
+
(n) => {
|
|
71
|
+
n && (n.indeterminate = d), typeof o == "function" ? o(n) : o && (o.current = n);
|
|
72
72
|
},
|
|
73
|
-
[d,
|
|
74
|
-
),
|
|
75
|
-
if (
|
|
76
|
-
const
|
|
73
|
+
[d, o]
|
|
74
|
+
), N = d ? "indeterminate" : f ? "checked" : "unchecked";
|
|
75
|
+
if (a) {
|
|
76
|
+
const n = [
|
|
77
77
|
"swap",
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
a.effect === "rotate" && "swap-rotate",
|
|
79
|
+
a.effect === "flip" && "swap-flip",
|
|
80
80
|
h
|
|
81
81
|
].filter(Boolean).join(" ");
|
|
82
|
-
return /* @__PURE__ */ p("label", { className:
|
|
82
|
+
return /* @__PURE__ */ p("label", { className: n, children: [
|
|
83
83
|
/* @__PURE__ */ c(
|
|
84
84
|
"input",
|
|
85
85
|
{
|
|
86
|
-
ref:
|
|
86
|
+
ref: o,
|
|
87
87
|
type: "checkbox",
|
|
88
|
-
checked:
|
|
89
|
-
onChange:
|
|
90
|
-
disabled:
|
|
91
|
-
"data-state":
|
|
92
|
-
...
|
|
88
|
+
checked: f,
|
|
89
|
+
onChange: w,
|
|
90
|
+
disabled: v,
|
|
91
|
+
"data-state": N,
|
|
92
|
+
...l
|
|
93
93
|
}
|
|
94
94
|
),
|
|
95
|
-
/* @__PURE__ */ c("div", { className: "swap-on", children:
|
|
96
|
-
/* @__PURE__ */ c("div", { className: "swap-off", children:
|
|
95
|
+
/* @__PURE__ */ c("div", { className: "swap-on", children: a.on }),
|
|
96
|
+
/* @__PURE__ */ c("div", { className: "swap-off", children: a.off })
|
|
97
97
|
] });
|
|
98
98
|
}
|
|
99
|
-
const
|
|
99
|
+
const j = /* @__PURE__ */ c(
|
|
100
100
|
"input",
|
|
101
101
|
{
|
|
102
102
|
ref: V,
|
|
103
103
|
type: "checkbox",
|
|
104
104
|
className: k,
|
|
105
|
-
value:
|
|
106
|
-
checked:
|
|
107
|
-
onChange:
|
|
108
|
-
disabled:
|
|
109
|
-
"data-state":
|
|
110
|
-
...
|
|
105
|
+
value: s,
|
|
106
|
+
checked: f,
|
|
107
|
+
onChange: w,
|
|
108
|
+
disabled: v,
|
|
109
|
+
"data-state": N,
|
|
110
|
+
...l
|
|
111
111
|
}
|
|
112
112
|
);
|
|
113
|
-
return
|
|
114
|
-
|
|
115
|
-
/* @__PURE__ */ c("span", {
|
|
116
|
-
] }) :
|
|
113
|
+
return x ? /* @__PURE__ */ p("label", { className: `flex items-center cursor-pointer gap-2 ${h}`, children: [
|
|
114
|
+
j,
|
|
115
|
+
/* @__PURE__ */ c("span", { children: x })
|
|
116
|
+
] }) : j;
|
|
117
117
|
}
|
|
118
118
|
);
|
|
119
119
|
m.displayName = "Checkbox";
|
package/dist/index11.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index11.js","sources":["../src/components/Checkbox.tsx"],"sourcesContent":["import React, { forwardRef, createContext, useContext } from 'react'\n\nexport interface CheckboxSwapConfig {\n /** Content shown when checked */\n on: React.ReactNode\n /** Content shown when unchecked */\n off: React.ReactNode\n /** Animation effect for the swap transition */\n effect?: 'rotate' | 'flip'\n}\n\nexport interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'type'> {\n children?: React.ReactNode\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n color?: 'primary' | 'secondary' | 'accent' | 'neutral' | 'success' | 'warning' | 'info' | 'error'\n indeterminate?: boolean\n /** Swap mode: toggle between two visual states instead of showing a checkbox */\n swap?: CheckboxSwapConfig\n className?: string\n}\n\nexport interface CheckboxOptionType {\n label: React.ReactNode\n value: string | number\n disabled?: boolean\n}\n\nexport interface CheckboxGroupProps {\n children?: React.ReactNode\n value?: (string | number)[]\n defaultValue?: (string | number)[]\n onChange?: (values: (string | number)[]) => void\n disabled?: boolean\n options?: (string | number | CheckboxOptionType)[]\n /** Layout direction for options */\n direction?: 'horizontal' | 'vertical'\n className?: string\n}\n\ninterface CheckboxGroupContextValue {\n value?: (string | number)[]\n onChange?: (checkedValue: string | number, checked: boolean) => void\n disabled?: boolean\n}\n\nconst CheckboxGroupContext = createContext<CheckboxGroupContextValue | null>(null)\n\nfunction CheckboxGroup({\n children,\n value,\n defaultValue,\n onChange,\n disabled = false,\n options,\n direction = 'vertical',\n className = ''\n}: CheckboxGroupProps) {\n const [internalValue, setInternalValue] = React.useState<(string | number)[]>(defaultValue || [])\n const currentValue = value !== undefined ? value : internalValue\n\n const handleChange = (checkedValue: string | number, checked: boolean) => {\n const newValue = checked\n ? [...currentValue, checkedValue]\n : currentValue.filter((v) => v !== checkedValue)\n\n if (value === undefined) {\n setInternalValue(newValue)\n }\n onChange?.(newValue)\n }\n\n const contextValue: CheckboxGroupContextValue = {\n value: currentValue,\n onChange: handleChange,\n disabled,\n }\n\n // If options are provided, render checkboxes automatically\n if (options) {\n const directionClasses = direction === 'horizontal' ? 'flex flex-row flex-wrap gap-4' : 'flex flex-col'\n return (\n <CheckboxGroupContext.Provider value={contextValue}>\n <div className={`${directionClasses} ${className}`.trim()}>\n {options.map((option) => {\n if (typeof option === 'string' || typeof option === 'number') {\n return (\n <label key={option} className=\"label cursor-pointer justify-start gap-2\">\n <CheckboxRoot value={option} />\n <span className=\"label-text\">{option}</span>\n </label>\n )\n } else {\n return (\n <label key={option.value} className=\"label cursor-pointer justify-start gap-2\">\n <CheckboxRoot value={option.value} disabled={option.disabled} />\n <span className=\"label-text\">{option.label}</span>\n </label>\n )\n }\n })}\n </div>\n </CheckboxGroupContext.Provider>\n )\n }\n\n return (\n <CheckboxGroupContext.Provider value={contextValue}>\n <div className={className}>{children}</div>\n </CheckboxGroupContext.Provider>\n )\n}\n\nconst CheckboxRoot = forwardRef<HTMLInputElement, CheckboxProps>(\n (\n {\n children,\n size,\n color,\n indeterminate = false,\n swap,\n className = '',\n value,\n checked,\n onChange,\n disabled: disabledProp,\n ...props\n },\n ref\n ) => {\n const groupContext = useContext(CheckboxGroupContext)\n\n const sizeClasses = {\n xs: 'checkbox-xs',\n sm: 'checkbox-sm',\n md: 'checkbox-md',\n lg: 'checkbox-lg',\n xl: 'checkbox-xl',\n }\n\n const colorClasses = {\n primary: 'checkbox-primary',\n secondary: 'checkbox-secondary',\n accent: 'checkbox-accent',\n neutral: 'checkbox-neutral',\n success: 'checkbox-success',\n warning: 'checkbox-warning',\n info: 'checkbox-info',\n error: 'checkbox-error',\n }\n\n const checkboxClasses = [\n 'checkbox',\n size && sizeClasses[size],\n color && colorClasses[color],\n ]\n .filter(Boolean)\n .join(' ')\n\n // If in a group, use group's value to determine checked state\n const isChecked = groupContext && value !== undefined && (typeof value === 'string' || typeof value === 'number')\n ? groupContext.value?.includes(value) ?? false\n : checked\n\n const isDisabled = groupContext?.disabled || disabledProp\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (groupContext && value !== undefined && (typeof value === 'string' || typeof value === 'number')) {\n groupContext.onChange?.(value, e.target.checked)\n }\n onChange?.(e)\n }\n\n // Handle indeterminate state\n const checkboxRef = React.useCallback(\n (node: HTMLInputElement | null) => {\n if (node) {\n node.indeterminate = indeterminate\n }\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref) {\n ref.current = node\n }\n },\n [indeterminate, ref]\n )\n\n const dataState = indeterminate ? 'indeterminate' : isChecked ? 'checked' : 'unchecked'\n\n // Swap mode: render as a swap toggle instead of checkbox\n if (swap) {\n const swapClasses = [\n 'swap',\n swap.effect === 'rotate' && 'swap-rotate',\n swap.effect === 'flip' && 'swap-flip',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n return (\n <label className={swapClasses}>\n <input\n ref={ref}\n type=\"checkbox\"\n checked={isChecked}\n onChange={handleChange}\n disabled={isDisabled}\n data-state={dataState}\n {...props}\n />\n <div className=\"swap-on\">{swap.on}</div>\n <div className=\"swap-off\">{swap.off}</div>\n </label>\n )\n }\n\n const checkboxInput = (\n <input\n ref={checkboxRef}\n type=\"checkbox\"\n className={checkboxClasses}\n value={value}\n checked={isChecked}\n onChange={handleChange}\n disabled={isDisabled}\n data-state={dataState}\n {...props}\n />\n )\n\n // If children provided, wrap in label\n if (children) {\n return (\n <label className={`label cursor-pointer justify-start gap-2 ${className}`}>\n {checkboxInput}\n <span className=\"label-text\">{children}</span>\n </label>\n )\n }\n\n return checkboxInput\n }\n)\n\nCheckboxRoot.displayName = 'Checkbox'\n\nexport const Checkbox = Object.assign(CheckboxRoot, {\n Group: CheckboxGroup,\n})\n"],"names":["CheckboxGroupContext","createContext","CheckboxGroup","children","value","defaultValue","onChange","disabled","options","direction","className","internalValue","setInternalValue","React","currentValue","contextValue","checkedValue","checked","newValue","v","directionClasses","option","jsxs","jsx","CheckboxRoot","forwardRef","size","color","indeterminate","swap","disabledProp","props","ref","groupContext","useContext","sizeClasses","colorClasses","checkboxClasses","isChecked","isDisabled","handleChange","e","checkboxRef","node","dataState","swapClasses","checkboxInput","Checkbox"],"mappings":";;AA6CA,MAAMA,IAAuBC,EAAgD,IAAI;AAEjF,SAASC,EAAc;AAAA,EACrB,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,SAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,WAAAC,IAAY;AACd,GAAuB;AACrB,QAAM,CAACC,GAAeC,CAAgB,IAAIC,EAAM,SAA8BR,KAAgB,EAAE,GAC1FS,IAAeV,MAAU,SAAYA,IAAQO,GAa7CI,IAA0C;AAAA,IAC9C,OAAOD;AAAA,IACP,UAbmB,CAACE,GAA+BC,MAAqB;AACxE,YAAMC,IAAWD,IACb,CAAC,GAAGH,GAAcE,CAAY,IAC9BF,EAAa,OAAO,CAACK,MAAMA,MAAMH,CAAY;AAEjD,MAAIZ,MAAU,UACZQ,EAAiBM,CAAQ,GAE3BZ,IAAWY,CAAQ;AAAA,IACrB;AAAA,IAKE,UAAAX;AAAA,EAAA;AAIF,MAAIC,GAAS;AACX,UAAMY,IAAmBX,MAAc,eAAe,kCAAkC;AACxF,6BACGT,EAAqB,UAArB,EAA8B,OAAOe,GACpC,4BAAC,OAAA,EAAI,WAAW,GAAGK,CAAgB,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QAEN,gBAAAR,EAAC,OAAA,EAAI,WAAU,WAAW,YAAK,IAAG;AAAA,QAClC,gBAAAA,EAAC,OAAA,EAAI,WAAU,YAAY,YAAK,IAAA,CAAI;AAAA,MAAA,GACtC;AAAA,IAEJ;AAEA,UAAMuB,IACJ,gBAAAvB;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAKmB;AAAA,QACL,MAAK;AAAA,QACL,WAAWL;AAAA,QACX,OAAAjC;AAAA,QACA,SAASkC;AAAA,QACT,UAAUE;AAAA,QACV,UAAUD;AAAA,QACV,cAAYK;AAAA,QACX,GAAGb;AAAA,MAAA;AAAA,IAAA;AAKR,WAAI5B,IAEA,gBAAAmB,EAAC,SAAA,EAAM,WAAW,4CAA4CZ,CAAS,IACpE,UAAA;AAAA,MAAAoC;AAAA,MACD,gBAAAvB,EAAC,QAAA,EAAK,WAAU,cAAc,UAAApB,EAAA,CAAS;AAAA,IAAA,GACzC,IAIG2C;AAAA,EACT;AACF;AAEAtB,EAAa,cAAc;AAEpB,MAAMuB,IAAW,OAAO,OAAOvB,GAAc;AAAA,EAClD,OAAOtB;AACT,CAAC;"}
|
|
1
|
+
{"version":3,"file":"index11.js","sources":["../src/components/Checkbox.tsx"],"sourcesContent":["import React, { forwardRef, createContext, useContext } from 'react'\n\nexport interface CheckboxSwapConfig {\n /** Content shown when checked */\n on: React.ReactNode\n /** Content shown when unchecked */\n off: React.ReactNode\n /** Animation effect for the swap transition */\n effect?: 'rotate' | 'flip'\n}\n\nexport interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'type'> {\n children?: React.ReactNode\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n color?: 'primary' | 'secondary' | 'accent' | 'neutral' | 'success' | 'warning' | 'info' | 'error'\n indeterminate?: boolean\n /** Swap mode: toggle between two visual states instead of showing a checkbox */\n swap?: CheckboxSwapConfig\n className?: string\n}\n\nexport interface CheckboxOptionType {\n label: React.ReactNode\n value: string | number\n disabled?: boolean\n}\n\nexport interface CheckboxGroupProps {\n children?: React.ReactNode\n value?: (string | number)[]\n defaultValue?: (string | number)[]\n onChange?: (values: (string | number)[]) => void\n disabled?: boolean\n options?: (string | number | CheckboxOptionType)[]\n /** Layout direction for options */\n direction?: 'horizontal' | 'vertical'\n className?: string\n}\n\ninterface CheckboxGroupContextValue {\n value?: (string | number)[]\n onChange?: (checkedValue: string | number, checked: boolean) => void\n disabled?: boolean\n}\n\nconst CheckboxGroupContext = createContext<CheckboxGroupContextValue | null>(null)\n\nfunction CheckboxGroup({\n children,\n value,\n defaultValue,\n onChange,\n disabled = false,\n options,\n direction = 'vertical',\n className = ''\n}: CheckboxGroupProps) {\n const [internalValue, setInternalValue] = React.useState<(string | number)[]>(defaultValue || [])\n const currentValue = value !== undefined ? value : internalValue\n\n const handleChange = (checkedValue: string | number, checked: boolean) => {\n const newValue = checked\n ? [...currentValue, checkedValue]\n : currentValue.filter((v) => v !== checkedValue)\n\n if (value === undefined) {\n setInternalValue(newValue)\n }\n onChange?.(newValue)\n }\n\n const contextValue: CheckboxGroupContextValue = {\n value: currentValue,\n onChange: handleChange,\n disabled,\n }\n\n // If options are provided, render checkboxes automatically\n if (options) {\n const directionClasses = direction === 'horizontal' ? 'flex flex-row flex-wrap gap-4' : 'flex flex-col'\n return (\n <CheckboxGroupContext.Provider value={contextValue}>\n <div className={`${directionClasses} ${className}`.trim()}>\n {options.map((option) => {\n if (typeof option === 'string' || typeof option === 'number') {\n return (\n <label key={option} className=\"flex items-center cursor-pointer gap-2\">\n <CheckboxRoot value={option} />\n <span>{option}</span>\n </label>\n )\n } else {\n return (\n <label key={option.value} className=\"flex items-center cursor-pointer gap-2\">\n <CheckboxRoot value={option.value} disabled={option.disabled} />\n <span>{option.label}</span>\n </label>\n )\n }\n })}\n </div>\n </CheckboxGroupContext.Provider>\n )\n }\n\n return (\n <CheckboxGroupContext.Provider value={contextValue}>\n <div className={className}>{children}</div>\n </CheckboxGroupContext.Provider>\n )\n}\n\nconst CheckboxRoot = forwardRef<HTMLInputElement, CheckboxProps>(\n (\n {\n children,\n size,\n color,\n indeterminate = false,\n swap,\n className = '',\n value,\n checked,\n onChange,\n disabled: disabledProp,\n ...props\n },\n ref\n ) => {\n const groupContext = useContext(CheckboxGroupContext)\n\n const sizeClasses = {\n xs: 'checkbox-xs',\n sm: 'checkbox-sm',\n md: 'checkbox-md',\n lg: 'checkbox-lg',\n xl: 'checkbox-xl',\n }\n\n const colorClasses = {\n primary: 'checkbox-primary',\n secondary: 'checkbox-secondary',\n accent: 'checkbox-accent',\n neutral: 'checkbox-neutral',\n success: 'checkbox-success',\n warning: 'checkbox-warning',\n info: 'checkbox-info',\n error: 'checkbox-error',\n }\n\n const checkboxClasses = [\n 'checkbox',\n size && sizeClasses[size],\n color && colorClasses[color],\n ]\n .filter(Boolean)\n .join(' ')\n\n // If in a group, use group's value to determine checked state\n const isChecked = groupContext && value !== undefined && (typeof value === 'string' || typeof value === 'number')\n ? groupContext.value?.includes(value) ?? false\n : checked\n\n const isDisabled = groupContext?.disabled || disabledProp\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (groupContext && value !== undefined && (typeof value === 'string' || typeof value === 'number')) {\n groupContext.onChange?.(value, e.target.checked)\n }\n onChange?.(e)\n }\n\n // Handle indeterminate state\n const checkboxRef = React.useCallback(\n (node: HTMLInputElement | null) => {\n if (node) {\n node.indeterminate = indeterminate\n }\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref) {\n ref.current = node\n }\n },\n [indeterminate, ref]\n )\n\n const dataState = indeterminate ? 'indeterminate' : isChecked ? 'checked' : 'unchecked'\n\n // Swap mode: render as a swap toggle instead of checkbox\n if (swap) {\n const swapClasses = [\n 'swap',\n swap.effect === 'rotate' && 'swap-rotate',\n swap.effect === 'flip' && 'swap-flip',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n return (\n <label className={swapClasses}>\n <input\n ref={ref}\n type=\"checkbox\"\n checked={isChecked}\n onChange={handleChange}\n disabled={isDisabled}\n data-state={dataState}\n {...props}\n />\n <div className=\"swap-on\">{swap.on}</div>\n <div className=\"swap-off\">{swap.off}</div>\n </label>\n )\n }\n\n const checkboxInput = (\n <input\n ref={checkboxRef}\n type=\"checkbox\"\n className={checkboxClasses}\n value={value}\n checked={isChecked}\n onChange={handleChange}\n disabled={isDisabled}\n data-state={dataState}\n {...props}\n />\n )\n\n // If children provided, wrap in label\n if (children) {\n return (\n <label className={`flex items-center cursor-pointer gap-2 ${className}`}>\n {checkboxInput}\n <span>{children}</span>\n </label>\n )\n }\n\n return checkboxInput\n }\n)\n\nCheckboxRoot.displayName = 'Checkbox'\n\nexport const Checkbox = Object.assign(CheckboxRoot, {\n Group: CheckboxGroup,\n})\n"],"names":["CheckboxGroupContext","createContext","CheckboxGroup","children","value","defaultValue","onChange","disabled","options","direction","className","internalValue","setInternalValue","React","currentValue","contextValue","checkedValue","checked","newValue","v","directionClasses","option","jsxs","jsx","CheckboxRoot","forwardRef","size","color","indeterminate","swap","disabledProp","props","ref","groupContext","useContext","sizeClasses","colorClasses","checkboxClasses","isChecked","isDisabled","handleChange","e","checkboxRef","node","dataState","swapClasses","checkboxInput","Checkbox"],"mappings":";;AA6CA,MAAMA,IAAuBC,EAAgD,IAAI;AAEjF,SAASC,EAAc;AAAA,EACrB,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,SAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,WAAAC,IAAY;AACd,GAAuB;AACrB,QAAM,CAACC,GAAeC,CAAgB,IAAIC,EAAM,SAA8BR,KAAgB,EAAE,GAC1FS,IAAeV,MAAU,SAAYA,IAAQO,GAa7CI,IAA0C;AAAA,IAC9C,OAAOD;AAAA,IACP,UAbmB,CAACE,GAA+BC,MAAqB;AACxE,YAAMC,IAAWD,IACb,CAAC,GAAGH,GAAcE,CAAY,IAC9BF,EAAa,OA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