@@ -74,6 +74,21 @@ export interface CheckboxOption<T = any> {
74
74
readOnly? : boolean ;
75
75
onChange? : (checked : boolean , e : React .ChangeEvent <HTMLInputElement >) => void ;
76
76
}
77
+
78
+
79
+ export interface RenderProps <T = any > {
80
+ value: T | undefined ;
81
+ onChange: (value : T ) => void ;
82
+ }
83
+ export interface CheckboxOption <T = any > {
84
+ value: T ;
85
+ label: React .ReactNode ;
86
+ style? : React .CSSProperties ;
87
+ className? : string ;
88
+ disabled? : boolean ;
89
+ readOnly? : boolean ;
90
+ onChange? : (checked : boolean , e : React .ChangeEvent <HTMLInputElement >) => void ;
91
+ }
77
92
export interface CheckboxGroupProps <T = any > extends Omit <React .HTMLAttributes <HTMLDivElement >, " defaultValue" | " onChange" | " defaultChecked" > {
78
93
prefixCls? : string ;
79
94
name? : string ;
@@ -82,6 +97,7 @@ export interface CheckboxGroupProps<T = any> extends Omit<React.HTMLAttributes<H
82
97
disabled? : boolean ;
83
98
readOnly? : boolean ;
84
99
options? : T extends string | number ? (string | number )[] : CheckboxOption <T >[];
100
+ render? : (props : RenderProps ) => React .ReactNode ;
85
101
onChange? : (checkedValue : T []) => void ;
86
102
}
87
103
export interface CheckboxGroupState <T = any > {
@@ -106,19 +122,9 @@ export declare class CheckboxGroup<T = any> extends React.Component<CheckboxGrou
106
122
};
107
123
getOptions(): CheckboxOption <any >[];
108
124
toggleChange: (option : CheckboxOption ) => void ;
125
+ handleChange: (value : T []) => void ;
109
126
render(): JSX .Element ;
110
127
}
111
-
112
- export interface CheckboxGroupContextValue {
113
- toggleChange: (option : {
114
- value: any ;
115
- label: React .ReactNode ;
116
- }) => void ;
117
- value: any ;
118
- name: string | undefined ;
119
- disabled: boolean ;
120
- readOnly: boolean ;
121
- }
122
128
```
123
129
124
130
@@ -127,142 +133,143 @@ export interface CheckboxGroupContextValue {
127
133
``` css
128
134
/* RWCheckbox 基础样式 */
129
135
.rw-checkbox {
130
- position : relative ;
131
- display : inline-block ;
132
- vertical-align : middle ;
133
- outline : none ;
134
- margin : 0 ;
135
- padding : 0 ;
136
- box-sizing : border-box ;
137
- flex : none ;
136
+ position : relative ;
137
+ display : inline-block ;
138
+ vertical-align : middle ;
139
+ outline : none ;
140
+ margin : 0 ;
141
+ padding : 0 ;
142
+ box-sizing : border-box ;
143
+ flex : none ;
138
144
}
139
145
140
146
.rw-checkbox-input {
141
- width : 100% ;
142
- height : 100% ;
143
- position : absolute ;
144
- top : 0 ;
145
- bottom : 0 ;
146
- left : 0 ;
147
- right : 0 ;
148
- z-index : 1 ;
149
- cursor : pointer ;
150
- opacity : 0 ;
151
- padding : 0 ;
152
- margin : 0 ;
153
- box-sizing : border-box ;
147
+ width : 100% ;
148
+ height : 100% ;
149
+ position : absolute ;
150
+ top : 0 ;
151
+ bottom : 0 ;
152
+ left : 0 ;
153
+ right : 0 ;
154
+ z-index : 1 ;
155
+ cursor : pointer ;
156
+ opacity : 0 ;
157
+ padding : 0 ;
158
+ margin : 0 ;
159
+ box-sizing : border-box ;
154
160
}
155
161
156
162
.rw-checkbox-inner {
157
- position : relative ;
158
- top : 0 ;
159
- left : 0 ;
160
- display : block ;
161
- width : 16px ;
162
- height : 16px ;
163
- border : 1px solid #d9d9d9 ;
164
- border-radius : 2px ;
165
- box-sizing : border-box ;
163
+ position : relative ;
164
+ top : 0 ;
165
+ left : 0 ;
166
+ display : block ;
167
+ width : 16px ;
168
+ height : 16px ;
169
+ border : 1px solid #d9d9d9 ;
170
+ border-radius : 2px ;
171
+ box-sizing : border-box ;
166
172
}
167
173
168
174
.rw-checkbox-input :focus + .rw-checkbox-inner ,
169
175
.rw-checkbox :hover .rw-checkbox-inner {
170
- border-color : #1890ff ;
176
+ border-color : #1890ff ;
171
177
}
172
178
173
179
.rw-checkbox-disabled .rw-checkbox-input ,
174
180
.rw-checkbox-disabled {
175
- cursor : not-allowed ;
181
+ cursor : not-allowed ;
176
182
}
177
183
178
184
.rw-checkbox-disabled :hover .rw-checkbox-inner ,
179
185
.rw-checkbox-disabled :active .rw-checkbox-inner ,
180
186
.rw-checkbox-disabled .rw-checkbox-inner {
181
- background-color : #f5f5f5 ;
182
- border-color : #d9d9d9 !important ;
187
+ background-color : #f5f5f5 !important ;
188
+ border-color : #d9d9d9 !important ;
183
189
}
184
190
185
191
/* RWCheckbox 选中样式 */
186
192
.rw-checkbox-checked .rw-checkbox-inner {
187
- background : #1890ff ;
188
- border-color : #1890ff ;
193
+ background : #1890ff ;
194
+ border-color : #1890ff ;
189
195
}
190
196
191
197
.rw-checkbox-inner :after {
192
- box-sizing : border-box ;
193
- position : absolute ;
194
- top : 45% ;
195
- left : 22% ;
196
- display : table ;
197
- width : 6px ;
198
- height : 9px ;
199
- border : 2px solid #fff ;
200
- border-top : 0 ;
201
- border-left : 0 ;
202
- transform : rotate (45deg ) scale (0 ) translate (-50% , -50% );
203
- opacity : 0 ;
204
- content : " " ;
198
+ box-sizing : border-box ;
199
+ position : absolute ;
200
+ top : 45% ;
201
+ left : 22% ;
202
+ display : table ;
203
+ width : 6px ;
204
+ height : 9px ;
205
+ border : 2px solid #fff ;
206
+ border-top : 0 ;
207
+ border-left : 0 ;
208
+ transform : rotate (45deg ) scale (0 ) translate (-50% , -50% );
209
+ opacity : 0 ;
210
+ content : " " ;
205
211
}
206
212
207
213
.rw-checkbox-checked .rw-checkbox-inner :after {
208
- opacity : 1 ;
209
- transform : rotate (45deg ) scale (1 ) translate (-50% , -50% );
210
- }
211
-
212
- .rw-checkbox-disabled .rw-checkbox-inner {
213
- background : #f5f5f5 ;
214
- border-color : #d9d9d9 ;
214
+ opacity : 1 ;
215
+ transform : rotate (45deg ) scale (1 ) translate (-50% , -50% );
215
216
}
216
217
217
218
.rw-checkbox-disabled .rw-checkbox-inner :after {
218
- border-color : #d9d9d9 ;
219
+ border-color : #d9d9d9 ;
219
220
}
220
221
221
222
/* RWCheckbox半选状态 */
222
223
.rw-checkbox-indeterminate :not (.rw-checkbox-disabled ) .rw-checkbox-inner {
223
- border-color : #1890ff ;
224
+ border-color : #1890ff ;
224
225
}
225
226
.rw-checkbox-indeterminate .rw-checkbox-inner :after {
226
- top : 50% ;
227
- left : 50% ;
228
- width : 8px ;
229
- height : 8px ;
230
- background-color : #1890ff ;
231
- border : 0 ;
232
- border-radius : 1px ;
233
- transform : translate (-4px , -4px ) scale (1 );
234
- opacity : 1 ;
235
- content : " " ;
227
+ top : 50% ;
228
+ left : 50% ;
229
+ width : 8px ;
230
+ height : 8px ;
231
+ background-color : #1890ff ;
232
+ border : 0 ;
233
+ border-radius : 1px ;
234
+ transform : translate (-4px , -4px ) scale (1 );
235
+ opacity : 1 ;
236
+ content : " " ;
236
237
}
237
238
238
239
.rw-checkbox-indeterminate.rw-checkbox-disabled .rw-checkbox-inner :after {
239
- background : #d9d9d9 ;
240
+ background : #d9d9d9 ;
240
241
}
241
242
242
243
/* Checkbox */
243
244
.rw-checkbox-wrapper {
244
- display : inline-flex ;
245
- cursor : pointer ;
246
- vertical-align : middle ;
247
- outline : none ;
248
- align-items : center ;
245
+ display : inline-flex ;
246
+ cursor : pointer ;
247
+ vertical-align : middle ;
248
+ outline : none ;
249
+ align-items : center ;
250
+ flex : 1 ;
249
251
}
250
252
251
253
.rw-checkbox-wrapper :hover .rw-checkbox-inner {
252
- border-color : #1890ff ;
254
+ border-color : #1890ff ;
253
255
}
254
256
255
257
.rw-checkbox-label {
256
- flex : 1 ;
257
- padding : 0 8px ;
258
- overflow : hidden ;
259
- text-overflow : ellipsis ;
260
- white-space : nowrap ;
258
+ flex : 1 ;
259
+ padding : 0 8px ;
260
+ overflow : hidden ;
261
+ text-overflow : ellipsis ;
262
+ white-space : nowrap ;
261
263
}
262
264
263
265
.rw-checkbox-wrapper-disabled .rw-checkbox-label {
264
- color : rgba (0 , 0 , 0 , 0.25 );
265
- cursor : not-allowed ;
266
+ color : rgba (0 , 0 , 0 , 0.25 );
267
+ cursor : not-allowed ;
268
+ }
269
+
270
+ /* CheckboxGroup */
271
+ .rw-checkbox-group {
272
+ display : inline-flex ;
266
273
}
267
274
268
275
0 commit comments