@rescui/checkbox 0.11.0 → 0.11.1-RUI-296-Build-docs-md-files-for-each-docs-section-b138dd5bf.19
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/lib/checkbox.d.ts +43 -43
- package/lib/index.css +69 -69
- package/lib/index.d.ts +13 -14
- package/lib/index.js +2 -2
- package/lib/parts/checkbox-control-inner.d.ts +36 -36
- package/lib/parts/checkbox-control.d.ts +4 -4
- package/lib/parts/checkbox-list.d.ts +28 -28
- package/lib/parts/checkbox-list.p.module.css.js +13 -13
- package/lib/parts/checkbox-manager.d.ts +15 -15
- package/lib/parts/checkbox.p.module.css.js +22 -22
- package/lib/parts/group-context.d.ts +17 -17
- package/lib/parts/marks.d.ts +9 -9
- package/lib/parts/use-backward-compatible-id.d.ts +4 -4
- package/llm/components/checkbox.md +437 -0
- package/llm/index.md +2 -0
- package/package.json +10 -9
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Theme } from '@rescui/ui-contexts';
|
|
3
|
-
import CSS from 'csstype';
|
|
4
|
-
export
|
|
5
|
-
className?: string;
|
|
6
|
-
id?: string;
|
|
7
|
-
style?: CSS.Properties;
|
|
8
|
-
mode?: 'classic' | 'rock';
|
|
9
|
-
size?: 's' | 'm' | 'l';
|
|
10
|
-
onChange?: (val: string[]) => void;
|
|
11
|
-
value?: string[];
|
|
12
|
-
defaultValue?: string[];
|
|
13
|
-
label?: React.ReactNode;
|
|
14
|
-
note?: React.ReactNode;
|
|
15
|
-
/** Error flag or message */
|
|
16
|
-
error?: React.ReactNode;
|
|
17
|
-
/**
|
|
18
|
-
* If `true`, there will be reserved a space for a 1-line error message. Subsequent lines will be placed below normally.
|
|
19
|
-
* If `false`, there will be no reservation.
|
|
20
|
-
*/
|
|
21
|
-
reserveErrorLine?: boolean;
|
|
22
|
-
boldLabel?: boolean;
|
|
23
|
-
theme?: Theme;
|
|
24
|
-
disabled?: boolean;
|
|
25
|
-
children?: React.ReactNode;
|
|
26
|
-
};
|
|
27
|
-
declare const CheckboxList: React.FC<CheckboxListProps>;
|
|
28
|
-
export default CheckboxList;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Theme } from '@rescui/ui-contexts';
|
|
3
|
+
import CSS from 'csstype';
|
|
4
|
+
export type CheckboxListProps = {
|
|
5
|
+
className?: string;
|
|
6
|
+
id?: string;
|
|
7
|
+
style?: CSS.Properties;
|
|
8
|
+
mode?: 'classic' | 'rock';
|
|
9
|
+
size?: 's' | 'm' | 'l';
|
|
10
|
+
onChange?: (val: string[]) => void;
|
|
11
|
+
value?: string[];
|
|
12
|
+
defaultValue?: string[];
|
|
13
|
+
label?: React.ReactNode;
|
|
14
|
+
note?: React.ReactNode;
|
|
15
|
+
/** Error flag or message */
|
|
16
|
+
error?: React.ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* If `true`, there will be reserved a space for a 1-line error message. Subsequent lines will be placed below normally.
|
|
19
|
+
* If `false`, there will be no reservation.
|
|
20
|
+
*/
|
|
21
|
+
reserveErrorLine?: boolean;
|
|
22
|
+
boldLabel?: boolean;
|
|
23
|
+
theme?: Theme;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
children?: React.ReactNode;
|
|
26
|
+
};
|
|
27
|
+
declare const CheckboxList: React.FC<CheckboxListProps>;
|
|
28
|
+
export default CheckboxList;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"themeLight": "
|
|
3
|
-
"themeDark": "
|
|
4
|
-
"container": "
|
|
5
|
-
"sizeS": "
|
|
6
|
-
"sizeM": "
|
|
7
|
-
"sizeL": "
|
|
8
|
-
"inner": "
|
|
9
|
-
"label": "
|
|
10
|
-
"disabled": "
|
|
11
|
-
"footer": "
|
|
12
|
-
"errorMessage": "
|
|
13
|
-
"error": "
|
|
14
|
-
"note": "
|
|
2
|
+
"themeLight": "_themeLight_6v3o7_6",
|
|
3
|
+
"themeDark": "_themeDark_6v3o7_9",
|
|
4
|
+
"container": "_container_6v3o7_13",
|
|
5
|
+
"sizeS": "_sizeS_6v3o7_18",
|
|
6
|
+
"sizeM": "_sizeM_6v3o7_21",
|
|
7
|
+
"sizeL": "_sizeL_6v3o7_24",
|
|
8
|
+
"inner": "_inner_6v3o7_28",
|
|
9
|
+
"label": "_label_6v3o7_32",
|
|
10
|
+
"disabled": "_disabled_6v3o7_39",
|
|
11
|
+
"footer": "_footer_6v3o7_44",
|
|
12
|
+
"errorMessage": "_errorMessage_6v3o7_49",
|
|
13
|
+
"error": "_error_6v3o7_49",
|
|
14
|
+
"note": "_note_6v3o7_58"
|
|
15
15
|
};
|
|
16
16
|
export { styles as default };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Theme } from '@rescui/ui-contexts';
|
|
3
|
-
export
|
|
4
|
-
onChange: (val: string[]) => void;
|
|
5
|
-
value: string[];
|
|
6
|
-
defaultValue: string[];
|
|
7
|
-
isError?: boolean;
|
|
8
|
-
theme: Theme;
|
|
9
|
-
size: 's' | 'm' | 'l';
|
|
10
|
-
mode: 'classic' | 'rock';
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
children?: React.ReactNode;
|
|
13
|
-
};
|
|
14
|
-
declare const CheckboxManager: React.FC<CheckboxManagerProps>;
|
|
15
|
-
export default CheckboxManager;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Theme } from '@rescui/ui-contexts';
|
|
3
|
+
export type CheckboxManagerProps = {
|
|
4
|
+
onChange: (val: string[]) => void;
|
|
5
|
+
value: string[];
|
|
6
|
+
defaultValue: string[];
|
|
7
|
+
isError?: boolean;
|
|
8
|
+
theme: Theme;
|
|
9
|
+
size: 's' | 'm' | 'l';
|
|
10
|
+
mode: 'classic' | 'rock';
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
};
|
|
14
|
+
declare const CheckboxManager: React.FC<CheckboxManagerProps>;
|
|
15
|
+
export default CheckboxManager;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"themeLight": "
|
|
3
|
-
"themeDark": "
|
|
4
|
-
"checkboxSizeS": "
|
|
5
|
-
"checkboxSizeM": "
|
|
6
|
-
"checkboxSizeL": "
|
|
7
|
-
"sizeS": "
|
|
8
|
-
"sizeM": "
|
|
9
|
-
"sizeL": "
|
|
10
|
-
"classic": "
|
|
11
|
-
"rock": "
|
|
12
|
-
"checkbox": "
|
|
13
|
-
"input": "
|
|
14
|
-
"icon": "
|
|
15
|
-
"enabled": "
|
|
16
|
-
"indeterminate": "
|
|
17
|
-
"disabled": "
|
|
18
|
-
"error": "
|
|
19
|
-
"checkmark": "
|
|
20
|
-
"markS": "
|
|
21
|
-
"markM": "
|
|
22
|
-
"markL": "
|
|
23
|
-
"errorMessage": "
|
|
2
|
+
"themeLight": "_themeLight_a1kdxa_8",
|
|
3
|
+
"themeDark": "_themeDark_a1kdxa_11",
|
|
4
|
+
"checkboxSizeS": "_checkboxSizeS_a1kdxa_15",
|
|
5
|
+
"checkboxSizeM": "_checkboxSizeM_a1kdxa_18",
|
|
6
|
+
"checkboxSizeL": "_checkboxSizeL_a1kdxa_21",
|
|
7
|
+
"sizeS": "_sizeS_a1kdxa_25",
|
|
8
|
+
"sizeM": "_sizeM_a1kdxa_28",
|
|
9
|
+
"sizeL": "_sizeL_a1kdxa_31",
|
|
10
|
+
"classic": "_classic_a1kdxa_35",
|
|
11
|
+
"rock": "_rock_a1kdxa_38",
|
|
12
|
+
"checkbox": "_checkbox_a1kdxa_15",
|
|
13
|
+
"input": "_input_a1kdxa_65",
|
|
14
|
+
"icon": "_icon_a1kdxa_76",
|
|
15
|
+
"enabled": "_enabled_a1kdxa_93",
|
|
16
|
+
"indeterminate": "_indeterminate_a1kdxa_97",
|
|
17
|
+
"disabled": "_disabled_a1kdxa_105",
|
|
18
|
+
"error": "_error_a1kdxa_134",
|
|
19
|
+
"checkmark": "_checkmark_a1kdxa_161",
|
|
20
|
+
"markS": "_markS_a1kdxa_186",
|
|
21
|
+
"markM": "_markM_a1kdxa_189",
|
|
22
|
+
"markL": "_markL_a1kdxa_192",
|
|
23
|
+
"errorMessage": "_errorMessage_a1kdxa_196"
|
|
24
24
|
};
|
|
25
25
|
export { styles as default };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Theme } from '@rescui/ui-contexts';
|
|
3
|
-
import { CheckboxSize } from './checkbox-control-inner';
|
|
4
|
-
export
|
|
5
|
-
value: string[];
|
|
6
|
-
addToValue?: (val: string) => void;
|
|
7
|
-
removeFromValue?: (val: string) => void;
|
|
8
|
-
inGroup: boolean;
|
|
9
|
-
handleCheckboxChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
10
|
-
isError?: boolean;
|
|
11
|
-
errorId?: string;
|
|
12
|
-
theme?: Theme;
|
|
13
|
-
size?: CheckboxSize;
|
|
14
|
-
mode?: 'classic' | 'rock';
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
};
|
|
17
|
-
export declare const GroupContext: React.Context<GroupContextValue>;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Theme } from '@rescui/ui-contexts';
|
|
3
|
+
import { CheckboxSize } from './checkbox-control-inner';
|
|
4
|
+
export type GroupContextValue = {
|
|
5
|
+
value: string[];
|
|
6
|
+
addToValue?: (val: string) => void;
|
|
7
|
+
removeFromValue?: (val: string) => void;
|
|
8
|
+
inGroup: boolean;
|
|
9
|
+
handleCheckboxChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
10
|
+
isError?: boolean;
|
|
11
|
+
errorId?: string;
|
|
12
|
+
theme?: Theme;
|
|
13
|
+
size?: CheckboxSize;
|
|
14
|
+
mode?: 'classic' | 'rock';
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare const GroupContext: React.Context<GroupContextValue>;
|
package/lib/parts/marks.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export
|
|
3
|
-
className?: string;
|
|
4
|
-
'data-test'?: string;
|
|
5
|
-
};
|
|
6
|
-
export declare const MarkS: React.FC<MarkProps>;
|
|
7
|
-
export declare const MarkM: React.FC<MarkProps>;
|
|
8
|
-
export declare const MarkL: React.FC<MarkProps>;
|
|
9
|
-
export declare const Mark: React.FC<MarkProps>;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type MarkProps = {
|
|
3
|
+
className?: string;
|
|
4
|
+
'data-test'?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const MarkS: React.FC<MarkProps>;
|
|
7
|
+
export declare const MarkM: React.FC<MarkProps>;
|
|
8
|
+
export declare const MarkL: React.FC<MarkProps>;
|
|
9
|
+
export declare const Mark: React.FC<MarkProps>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const useBackwardCompatibleId: {
|
|
2
|
-
(): string | number;
|
|
3
|
-
counter: number;
|
|
4
|
-
};
|
|
1
|
+
export declare const useBackwardCompatibleId: {
|
|
2
|
+
(): string | number;
|
|
3
|
+
counter: number;
|
|
4
|
+
};
|
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
# Checkbox
|
|
2
|
+
|
|
3
|
+
Checkboxes allow users to select one or more items from a set of options.
|
|
4
|
+
|
|
5
|
+
## CheckboxList
|
|
6
|
+
|
|
7
|
+
### Features showcase
|
|
8
|
+
|
|
9
|
+
### CheckboxList
|
|
10
|
+
|
|
11
|
+
Is a special component to quickly retrieve array of selected values:
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { useState } from 'react';
|
|
15
|
+
import { Checkbox, CheckboxList } from '@rescui/checkbox';
|
|
16
|
+
|
|
17
|
+
const Demo = () => {
|
|
18
|
+
const [groupValue, setGroupValue] = useState(['item2']);
|
|
19
|
+
return (
|
|
20
|
+
<>
|
|
21
|
+
<CheckboxList value={groupValue} onChange={setGroupValue}>
|
|
22
|
+
<Checkbox value="item1">
|
|
23
|
+
I'm not ready to pay for it, and my trial has ended
|
|
24
|
+
</Checkbox>
|
|
25
|
+
<Checkbox value="item2">
|
|
26
|
+
Just changing PC / job / client machine
|
|
27
|
+
</Checkbox>
|
|
28
|
+
<Checkbox value="item3">
|
|
29
|
+
Reinstalling / upgrading / upgrading Rider
|
|
30
|
+
</Checkbox>
|
|
31
|
+
<Checkbox value="item4">
|
|
32
|
+
The reason has nothing to do with the product
|
|
33
|
+
</Checkbox>
|
|
34
|
+
</CheckboxList>
|
|
35
|
+
|
|
36
|
+
<p>{JSON.stringify(groupValue)}</p>
|
|
37
|
+
</>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
render(<Demo />);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
#### With default value
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
import { Checkbox, CheckboxList } from '@rescui/checkbox';
|
|
48
|
+
|
|
49
|
+
const Demo = () => {
|
|
50
|
+
return (
|
|
51
|
+
<CheckboxList defaultValue={['item3', 'item1']}>
|
|
52
|
+
<Checkbox value="item1">
|
|
53
|
+
I'm not ready to pay for it, and my trial has ended
|
|
54
|
+
</Checkbox>
|
|
55
|
+
<Checkbox value="item2">Just changing PC / job / client machine</Checkbox>
|
|
56
|
+
<Checkbox value="item3">
|
|
57
|
+
Reinstalling / upgrading / upgrading Rider
|
|
58
|
+
</Checkbox>
|
|
59
|
+
<Checkbox value="item4">
|
|
60
|
+
The reason has nothing to do with the product
|
|
61
|
+
</Checkbox>
|
|
62
|
+
</CheckboxList>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
render(<Demo />);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### With a custom list
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import { CheckboxControl, CheckboxManager } from '@rescui/checkbox';
|
|
73
|
+
|
|
74
|
+
<CheckboxManager>
|
|
75
|
+
<p>
|
|
76
|
+
<label style={{ display: 'flex', alignItems: 'center' }}>
|
|
77
|
+
<span className="rs-text-2" style={{ marginRight: 8 }}>
|
|
78
|
+
custom description 1:
|
|
79
|
+
</span>
|
|
80
|
+
<CheckboxControl notUseLabelTag value="1" />
|
|
81
|
+
</label>
|
|
82
|
+
</p>
|
|
83
|
+
<p>
|
|
84
|
+
<label style={{ display: 'flex', alignItems: 'center' }}>
|
|
85
|
+
<span className="rs-text-2" style={{ marginRight: 8 }}>
|
|
86
|
+
custom description 2:
|
|
87
|
+
</span>
|
|
88
|
+
<CheckboxControl notUseLabelTag value="2" />
|
|
89
|
+
</label>
|
|
90
|
+
</p>
|
|
91
|
+
</CheckboxManager>;
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### Conditional Input
|
|
95
|
+
|
|
96
|
+
CSS variable `--rs-out-checkbox-list-left-offset` is used to indent nested `CheckboxList`. It is available only inside `CheckboxList` component.
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
import { useState } from 'react';
|
|
100
|
+
import { Checkbox, CheckboxList } from '@rescui/checkbox';
|
|
101
|
+
import { Input } from '@rescui/input';
|
|
102
|
+
|
|
103
|
+
const Demo = () => {
|
|
104
|
+
const [groupValue, setGroupValue] = useState(['other']);
|
|
105
|
+
const [otherValue, setOtherValue] = useState('');
|
|
106
|
+
return (
|
|
107
|
+
<CheckboxList
|
|
108
|
+
value={groupValue}
|
|
109
|
+
onChange={setGroupValue}
|
|
110
|
+
style={{ maxWidth: 400 }}
|
|
111
|
+
label="Are you using Rider under license?"
|
|
112
|
+
>
|
|
113
|
+
<Checkbox value="yes">Yes, I have a Rider license</Checkbox>
|
|
114
|
+
<Checkbox value="other">Other</Checkbox>
|
|
115
|
+
{groupValue.includes('other') && (
|
|
116
|
+
<Input
|
|
117
|
+
style={{
|
|
118
|
+
marginLeft: 'var(--rs-out-checkbox-list-left-offset)'
|
|
119
|
+
}}
|
|
120
|
+
placeholder="Please enter your reason"
|
|
121
|
+
value={otherValue}
|
|
122
|
+
onChange={e => setOtherValue(e.target.value)}
|
|
123
|
+
/>
|
|
124
|
+
)}
|
|
125
|
+
</CheckboxList>
|
|
126
|
+
);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
render(<Demo />);
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### Nested CheckboxList
|
|
133
|
+
|
|
134
|
+
CSS variable `--rs-out-checkbox-list-left-offset` is used to indent nested `CheckboxList`. It is available only inside `CheckboxList` component.
|
|
135
|
+
|
|
136
|
+
This demo also shows a complex state management to sync nested `CheckboxList` with the outer `CheckboxList`.
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
import { useState } from 'react';
|
|
140
|
+
import { Checkbox, CheckboxList } from '@rescui/checkbox';
|
|
141
|
+
|
|
142
|
+
const INNER_VALUES = ['item1', 'item2'];
|
|
143
|
+
const INNER_LIST_VALUE = 'no';
|
|
144
|
+
|
|
145
|
+
const Demo = () => {
|
|
146
|
+
const [outerValue, setOuterValue] = useState([]);
|
|
147
|
+
const [innerValue, setInnerValue] = useState([INNER_VALUES[1]]);
|
|
148
|
+
|
|
149
|
+
const handleOuterChange = newOuterValue => {
|
|
150
|
+
setOuterValue(newOuterValue);
|
|
151
|
+
|
|
152
|
+
const isInnerOptionChecked = value => value.includes(INNER_LIST_VALUE);
|
|
153
|
+
|
|
154
|
+
if (
|
|
155
|
+
isInnerOptionChecked(newOuterValue) &&
|
|
156
|
+
!isInnerOptionChecked(outerValue)
|
|
157
|
+
) {
|
|
158
|
+
// When "no" is checked, check all nested items
|
|
159
|
+
setInnerValue(INNER_VALUES);
|
|
160
|
+
} else if (
|
|
161
|
+
!isInnerOptionChecked(newOuterValue) &&
|
|
162
|
+
isInnerOptionChecked(outerValue)
|
|
163
|
+
) {
|
|
164
|
+
// When "no" is unchecked, uncheck all nested items
|
|
165
|
+
setInnerValue([]);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const handleInnerChange = newInnerValue => {
|
|
170
|
+
setInnerValue(newInnerValue);
|
|
171
|
+
|
|
172
|
+
const outerValueWithoutInnerOption = outerValue.filter(
|
|
173
|
+
v => v !== INNER_LIST_VALUE
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
if (newInnerValue.length < INNER_VALUES.length) {
|
|
177
|
+
// If any nested items are unchecked, uncheck "no"
|
|
178
|
+
setOuterValue(outerValueWithoutInnerOption);
|
|
179
|
+
} else {
|
|
180
|
+
// Otherwise, check "no"
|
|
181
|
+
setOuterValue([...outerValueWithoutInnerOption, INNER_LIST_VALUE]);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<CheckboxList
|
|
187
|
+
value={outerValue}
|
|
188
|
+
onChange={handleOuterChange}
|
|
189
|
+
label="Are you using Rider under license?"
|
|
190
|
+
>
|
|
191
|
+
<Checkbox value="yes">Yes, I have a Rider license</Checkbox>
|
|
192
|
+
<Checkbox value={INNER_LIST_VALUE} indeterminate={innerValue.length > 0}>
|
|
193
|
+
No, I'm still on my 30-day trial
|
|
194
|
+
</Checkbox>
|
|
195
|
+
<CheckboxList
|
|
196
|
+
value={innerValue}
|
|
197
|
+
onChange={handleInnerChange}
|
|
198
|
+
style={{
|
|
199
|
+
marginLeft: 'var(--rs-out-checkbox-list-left-offset)'
|
|
200
|
+
}}
|
|
201
|
+
>
|
|
202
|
+
<Checkbox value={INNER_VALUES[0]}>
|
|
203
|
+
I'm not ready to pay for it, and my trial has ended
|
|
204
|
+
</Checkbox>
|
|
205
|
+
<Checkbox value={INNER_VALUES[1]}>
|
|
206
|
+
The reason has nothing to do with the product
|
|
207
|
+
</Checkbox>
|
|
208
|
+
</CheckboxList>
|
|
209
|
+
</CheckboxList>
|
|
210
|
+
);
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
render(<Demo />);
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Usage
|
|
217
|
+
|
|
218
|
+
### Features showcase
|
|
219
|
+
|
|
220
|
+
### Controlled checkbox
|
|
221
|
+
|
|
222
|
+
```tsx
|
|
223
|
+
import { Checkbox } from '@rescui/checkbox';
|
|
224
|
+
import { useState } from 'react';
|
|
225
|
+
|
|
226
|
+
const Demo = () => {
|
|
227
|
+
const [checked, setChecked] = useState(false);
|
|
228
|
+
return (
|
|
229
|
+
<>
|
|
230
|
+
<Checkbox checked={checked} onChange={e => setChecked(e.target.checked)}>
|
|
231
|
+
Checkbox
|
|
232
|
+
</Checkbox>
|
|
233
|
+
<div>Checkbox {checked ? 'checked' : 'unchecked'}</div>
|
|
234
|
+
</>
|
|
235
|
+
);
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
render(<Demo />);
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
#### With `label` on the outside
|
|
242
|
+
|
|
243
|
+
```tsx
|
|
244
|
+
import { CheckboxControl } from '@rescui/checkbox';
|
|
245
|
+
|
|
246
|
+
<label style={{ display: 'flex', alignItems: 'center' }}>
|
|
247
|
+
<span className="rs-text-2" style={{ marginRight: 8 }}>
|
|
248
|
+
custom description:
|
|
249
|
+
</span>
|
|
250
|
+
<CheckboxControl notUseLabelTag value="item" />
|
|
251
|
+
</label>;
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## CSS Mixins API
|
|
255
|
+
|
|
256
|
+
#### `CheckboxList` mixins
|
|
257
|
+
|
|
258
|
+
| Mixin name | Details |
|
|
259
|
+
| --- | --- |
|
|
260
|
+
| `rs-checkbox-list-size-s` | prop: `size`<br><br>value: `"s"` |
|
|
261
|
+
| `rs-checkbox-list-size-m` | prop: `size`<br><br>value: `"m"` |
|
|
262
|
+
| `rs-checkbox-list-size-l` | prop: `size`<br><br>value: `"l"` |
|
|
263
|
+
| `rs-checkbox-list-mode-classic` | prop: `mode`<br><br>value: `"classic"` |
|
|
264
|
+
| `rs-checkbox-list-mode-rock` | prop: `mode`<br><br>value: `"rock"` |
|
|
265
|
+
|
|
266
|
+
##### Demo
|
|
267
|
+
|
|
268
|
+
Instead of separate classes, it may be a single class with `@media` queries inside:
|
|
269
|
+
|
|
270
|
+
```tsx
|
|
271
|
+
import { Checkbox, CheckboxList } from '@rescui/checkbox';
|
|
272
|
+
import { useState } from 'react';
|
|
273
|
+
|
|
274
|
+
const MyCheckboxList = ({ className }) => {
|
|
275
|
+
const [groupValue, setGroupValue] = useState(['item2']);
|
|
276
|
+
return (
|
|
277
|
+
<div style={{ padding: 12, backgroundColor: 'var(--rs-color-black-t5)' }}>
|
|
278
|
+
<CheckboxList
|
|
279
|
+
value={groupValue}
|
|
280
|
+
onChange={setGroupValue}
|
|
281
|
+
className={className}
|
|
282
|
+
>
|
|
283
|
+
<Checkbox value="item1">Option 1</Checkbox>
|
|
284
|
+
<Checkbox value="item2">Option 2</Checkbox>
|
|
285
|
+
</CheckboxList>
|
|
286
|
+
</div>
|
|
287
|
+
);
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
render(
|
|
291
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 24 }}>
|
|
292
|
+
<div>
|
|
293
|
+
<p>Default:</p>
|
|
294
|
+
<MyCheckboxList />
|
|
295
|
+
</div>
|
|
296
|
+
<div>
|
|
297
|
+
<p>Var1:</p>
|
|
298
|
+
<MyCheckboxList className={`my-checkbox-list-var-1`} />
|
|
299
|
+
</div>
|
|
300
|
+
<div>
|
|
301
|
+
<p>Var1 & Var2 combined:</p>
|
|
302
|
+
<MyCheckboxList
|
|
303
|
+
className={`my-checkbox-list-var-1 my-checkbox-list-var-2`}
|
|
304
|
+
/>
|
|
305
|
+
</div>
|
|
306
|
+
</div>
|
|
307
|
+
);
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
```postcss
|
|
311
|
+
@import '@rescui/checkbox/lib/public-api.p.css';
|
|
312
|
+
|
|
313
|
+
.my-checkbox-list-var-1 {
|
|
314
|
+
@mixin rs-checkbox-list-size-l;
|
|
315
|
+
@mixin rs-checkbox-list-mode-rock;
|
|
316
|
+
}
|
|
317
|
+
.my-checkbox-list-var-2 {
|
|
318
|
+
@mixin rs-checkbox-list-size-s;
|
|
319
|
+
@mixin rs-checkbox-list-mode-classic;
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
#### `Checkbox` mixins
|
|
324
|
+
|
|
325
|
+
| Mixin name | Details |
|
|
326
|
+
| --- | --- |
|
|
327
|
+
| `rs-checkbox-size-s` | prop: `size`<br><br>value: `"s"` |
|
|
328
|
+
| `rs-checkbox-size-m` | prop: `size`<br><br>value: `"m"` |
|
|
329
|
+
| `rs-checkbox-size-l` | prop: `size`<br><br>value: `"l"` |
|
|
330
|
+
| `rs-checkbox-mode-classic` | prop: `mode`<br><br>value: `"classic"` |
|
|
331
|
+
| `rs-checkbox-mode-rock` | prop: `mode`<br><br>value: `"rock"` |
|
|
332
|
+
|
|
333
|
+
##### Demo
|
|
334
|
+
|
|
335
|
+
Instead of separate classes, it may be a single class with `@media` queries inside:
|
|
336
|
+
|
|
337
|
+
```tsx
|
|
338
|
+
import { Checkbox } from '@rescui/checkbox';
|
|
339
|
+
|
|
340
|
+
const MyCheckbox = ({ className }) => {
|
|
341
|
+
return (
|
|
342
|
+
<div style={{ padding: 12, backgroundColor: 'var(--rs-color-black-t5)' }}>
|
|
343
|
+
<Checkbox className={className} defaultChecked>
|
|
344
|
+
Option
|
|
345
|
+
</Checkbox>
|
|
346
|
+
</div>
|
|
347
|
+
);
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
render(
|
|
351
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 24 }}>
|
|
352
|
+
<div>
|
|
353
|
+
<p>Default:</p>
|
|
354
|
+
<MyCheckbox />
|
|
355
|
+
</div>
|
|
356
|
+
<div>
|
|
357
|
+
<p>Var1:</p>
|
|
358
|
+
<MyCheckbox className={`my-checkbox-var-1`} />
|
|
359
|
+
</div>
|
|
360
|
+
<div>
|
|
361
|
+
<p>Var1 & Var2 combined:</p>
|
|
362
|
+
<MyCheckbox className={`my-checkbox-var-1 my-checkbox-var-2`} />
|
|
363
|
+
</div>
|
|
364
|
+
</div>
|
|
365
|
+
);
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
```postcss attached
|
|
369
|
+
@import '@rescui/checkbox/lib/public-api.p.css';
|
|
370
|
+
|
|
371
|
+
.my-checkbox-var-1 {
|
|
372
|
+
@mixin rs-checkbox-size-l;
|
|
373
|
+
@mixin rs-checkbox-mode-rock;
|
|
374
|
+
}
|
|
375
|
+
.my-checkbox-var-2 {
|
|
376
|
+
@mixin rs-checkbox-size-s;
|
|
377
|
+
@mixin rs-checkbox-mode-classic;
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
#### `CheckboxControl` mixins
|
|
382
|
+
|
|
383
|
+
| Mixin name | Details |
|
|
384
|
+
| --- | --- |
|
|
385
|
+
| `rs-checkbox-control-size-s` | prop: `size`<br><br>value: `"s"` |
|
|
386
|
+
| `rs-checkbox-control-size-m` | prop: `size`<br><br>value: `"m"` |
|
|
387
|
+
| `rs-checkbox-control-size-l` | prop: `size`<br><br>value: `"l"` |
|
|
388
|
+
| `rs-checkbox-control-mode-classic` | prop: `mode`<br><br>value: `"classic"` |
|
|
389
|
+
| `rs-checkbox-control-mode-rock` | prop: `mode`<br><br>value: `"rock"` |
|
|
390
|
+
|
|
391
|
+
##### Demo
|
|
392
|
+
|
|
393
|
+
Instead of separate classes, it may be a single class with `@media` queries inside:
|
|
394
|
+
|
|
395
|
+
```tsx
|
|
396
|
+
import { CheckboxControl } from '@rescui/checkbox';
|
|
397
|
+
|
|
398
|
+
const MyCheckboxControl = ({ className }) => {
|
|
399
|
+
return (
|
|
400
|
+
<div style={{ padding: 12, backgroundColor: 'var(--rs-color-black-t5)' }}>
|
|
401
|
+
<CheckboxControl className={className} defaultChecked />
|
|
402
|
+
</div>
|
|
403
|
+
);
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
render(
|
|
407
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 24 }}>
|
|
408
|
+
<div>
|
|
409
|
+
<p>Default:</p>
|
|
410
|
+
<MyCheckboxControl />
|
|
411
|
+
</div>
|
|
412
|
+
<div>
|
|
413
|
+
<p>Var1:</p>
|
|
414
|
+
<MyCheckboxControl className={`my-checkbox-control-var-1`} />
|
|
415
|
+
</div>
|
|
416
|
+
<div>
|
|
417
|
+
<p>Var1 & Var2 combined:</p>
|
|
418
|
+
<MyCheckboxControl
|
|
419
|
+
className={`my-checkbox-control-var-1 my-checkbox-control-var-2`}
|
|
420
|
+
/>
|
|
421
|
+
</div>
|
|
422
|
+
</div>
|
|
423
|
+
);
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
```postcss
|
|
427
|
+
@import '@rescui/checkbox/lib/public-api.p.css';
|
|
428
|
+
|
|
429
|
+
.my-checkbox-control-var-1 {
|
|
430
|
+
@mixin rs-checkbox-control-size-l;
|
|
431
|
+
@mixin rs-checkbox-control-mode-rock;
|
|
432
|
+
}
|
|
433
|
+
.my-checkbox-control-var-2 {
|
|
434
|
+
@mixin rs-checkbox-control-size-s;
|
|
435
|
+
@mixin rs-checkbox-control-mode-classic;
|
|
436
|
+
}
|
|
437
|
+
```
|
package/llm/index.md
ADDED