@workday/canvas-kit-react 7.0.6 → 7.0.7
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/checkbox/lib/Checkbox.tsx +106 -54
- package/dist/commonjs/checkbox/lib/Checkbox.d.ts +4 -0
- package/dist/commonjs/checkbox/lib/Checkbox.d.ts.map +1 -1
- package/dist/commonjs/checkbox/lib/Checkbox.js +65 -34
- package/dist/commonjs/radio/lib/Radio.d.ts +1 -0
- package/dist/commonjs/radio/lib/Radio.d.ts.map +1 -1
- package/dist/commonjs/radio/lib/Radio.js +74 -26
- package/dist/es6/checkbox/lib/Checkbox.d.ts +4 -0
- package/dist/es6/checkbox/lib/Checkbox.d.ts.map +1 -1
- package/dist/es6/checkbox/lib/Checkbox.js +65 -34
- package/dist/es6/radio/lib/Radio.d.ts +1 -0
- package/dist/es6/radio/lib/Radio.d.ts.map +1 -1
- package/dist/es6/radio/lib/Radio.js +74 -26
- package/package.json +5 -5
- package/radio/lib/Radio.tsx +98 -29
|
@@ -58,6 +58,10 @@ export interface CheckboxProps extends Themeable {
|
|
|
58
58
|
* @default false
|
|
59
59
|
*/
|
|
60
60
|
indeterminate?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The variant for the checkbox
|
|
63
|
+
*/
|
|
64
|
+
variant?: 'inverse' | undefined;
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
const checkboxHeight = 18;
|
|
@@ -87,16 +91,20 @@ const CheckboxInputWrapper = styled('div')<Pick<CheckboxProps, 'disabled'>>({
|
|
|
87
91
|
alignSelf: 'flex-start',
|
|
88
92
|
});
|
|
89
93
|
|
|
90
|
-
const CheckboxRipple = styled('span')<Pick<CheckboxProps, 'disabled'>>(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
94
|
+
const CheckboxRipple = styled('span')<Pick<CheckboxProps, 'disabled' | 'variant'>>(
|
|
95
|
+
{
|
|
96
|
+
borderRadius: borderRadius.circle,
|
|
97
|
+
boxShadow: `0 0 0 0 ${colors.soap200}`,
|
|
98
|
+
height: checkboxHeight,
|
|
99
|
+
transition: 'box-shadow 150ms ease-out',
|
|
100
|
+
width: checkboxWidth,
|
|
101
|
+
position: 'absolute',
|
|
102
|
+
pointerEvents: 'none', // This is a decorative element we don't want it to block clicks to input
|
|
103
|
+
},
|
|
104
|
+
({variant}) => ({
|
|
105
|
+
opacity: variant === 'inverse' ? '0.4' : '1',
|
|
106
|
+
})
|
|
107
|
+
);
|
|
100
108
|
|
|
101
109
|
/**
|
|
102
110
|
* Note: `~ div:first-of-type` refers to `CheckboxBackground`
|
|
@@ -112,6 +120,7 @@ const CheckboxInput = styled('input')<CheckboxProps & StyledType>(
|
|
|
112
120
|
},
|
|
113
121
|
},
|
|
114
122
|
},
|
|
123
|
+
variant,
|
|
115
124
|
}) => ({
|
|
116
125
|
borderRadius: borderRadius.s,
|
|
117
126
|
width: checkboxTapArea,
|
|
@@ -129,20 +138,21 @@ const CheckboxInput = styled('input')<CheckboxProps & StyledType>(
|
|
|
129
138
|
// States
|
|
130
139
|
'&:not(:checked):not(:disabled):not(:focus):hover, &:not(:checked):not(:disabled):active': {
|
|
131
140
|
'~ div:first-of-type': {
|
|
132
|
-
borderColor: inputColors.hoverBorder,
|
|
141
|
+
borderColor: variant === 'inverse' ? colors.soap300 : inputColors.hoverBorder,
|
|
133
142
|
},
|
|
134
143
|
},
|
|
135
144
|
'&:checked ~ div:first-of-type': {
|
|
136
|
-
borderColor: themePrimary.main,
|
|
137
|
-
backgroundColor: themePrimary.main,
|
|
145
|
+
borderColor: variant === 'inverse' ? colors.soap300 : themePrimary.main,
|
|
146
|
+
backgroundColor: variant === 'inverse' ? colors.frenchVanilla100 : themePrimary.main,
|
|
138
147
|
},
|
|
139
148
|
'&:disabled ~ div:first-of-type': {
|
|
140
149
|
borderColor: inputColors.disabled.border,
|
|
141
|
-
backgroundColor: inputColors.disabled.background,
|
|
150
|
+
backgroundColor: variant === 'inverse' ? colors.soap300 : inputColors.disabled.background,
|
|
151
|
+
opacity: variant === 'inverse' ? '.4' : '1',
|
|
142
152
|
},
|
|
143
153
|
'&:disabled:checked ~ div:first-of-type': {
|
|
144
|
-
borderColor: themePrimary.light,
|
|
145
|
-
backgroundColor: themePrimary.light,
|
|
154
|
+
borderColor: variant === 'inverse' ? colors.soap300 : themePrimary.light,
|
|
155
|
+
backgroundColor: variant === 'inverse' ? colors.soap300 : themePrimary.light,
|
|
146
156
|
},
|
|
147
157
|
|
|
148
158
|
// Focus
|
|
@@ -150,30 +160,48 @@ const CheckboxInput = styled('input')<CheckboxProps & StyledType>(
|
|
|
150
160
|
outline: 'none',
|
|
151
161
|
},
|
|
152
162
|
'&:focus ~ div:first-of-type': {
|
|
153
|
-
borderColor: themePrimary.main,
|
|
163
|
+
borderColor: variant === 'inverse' ? colors.blackPepper400 : themePrimary.main,
|
|
154
164
|
borderWidth: '2px',
|
|
155
165
|
boxShadow: 'none',
|
|
166
|
+
...focusRing({
|
|
167
|
+
width: variant === 'inverse' ? 2 : 0,
|
|
168
|
+
separation: 0,
|
|
169
|
+
animate: false,
|
|
170
|
+
innerColor: variant === 'inverse' ? colors.blackPepper400 : undefined,
|
|
171
|
+
outerColor: variant === 'inverse' ? colors.frenchVanilla100 : undefined,
|
|
172
|
+
}),
|
|
156
173
|
},
|
|
157
174
|
'&:checked:focus ~ div:first-of-type': {
|
|
158
|
-
...focusRing({
|
|
175
|
+
...focusRing({
|
|
176
|
+
width: 2,
|
|
177
|
+
separation: 2,
|
|
178
|
+
animate: false,
|
|
179
|
+
innerColor: variant === 'inverse' ? colors.blackPepper400 : undefined,
|
|
180
|
+
outerColor: variant === 'inverse' ? colors.frenchVanilla100 : themeFocusOutline,
|
|
181
|
+
}),
|
|
182
|
+
borderColor: variant === 'inverse' ? colors.frenchVanilla100 : themePrimary.main,
|
|
183
|
+
borderWidth: '2px',
|
|
159
184
|
'& span': {
|
|
160
185
|
marginLeft: '-7px',
|
|
161
186
|
},
|
|
162
187
|
},
|
|
163
188
|
...mouseFocusBehavior({
|
|
164
189
|
'&:focus ~ div:first-of-type': {
|
|
165
|
-
border:
|
|
190
|
+
border:
|
|
191
|
+
variant === 'inverse'
|
|
192
|
+
? `1px solid ${colors.soap300}`
|
|
193
|
+
: `1px solid ${inputColors.hoverBorder}`,
|
|
166
194
|
boxShadow: 'none',
|
|
167
195
|
'& span': {
|
|
168
196
|
marginLeft: '-6px',
|
|
169
197
|
},
|
|
170
198
|
},
|
|
171
199
|
'&:checked ~ div:first-of-type': {
|
|
172
|
-
borderColor: themePrimary.main,
|
|
200
|
+
borderColor: variant === 'inverse' ? colors.soap300 : themePrimary.main,
|
|
173
201
|
},
|
|
174
202
|
'&:disabled:checked ~ div:first-of-type': {
|
|
175
203
|
borderColor: themePrimary.light,
|
|
176
|
-
backgroundColor: themePrimary.light,
|
|
204
|
+
backgroundColor: variant === 'inverse' ? colors.soap300 : themePrimary.light,
|
|
177
205
|
},
|
|
178
206
|
}),
|
|
179
207
|
}),
|
|
@@ -182,7 +210,7 @@ const CheckboxInput = styled('input')<CheckboxProps & StyledType>(
|
|
|
182
210
|
boxShadow: disabled ? undefined : `0 0 0 ${rippleRadius}px ${colors.soap200}`,
|
|
183
211
|
},
|
|
184
212
|
}),
|
|
185
|
-
({theme, error}) => {
|
|
213
|
+
({theme, error, variant}) => {
|
|
186
214
|
const errorColors = getErrorColors(error, theme);
|
|
187
215
|
|
|
188
216
|
if (errorColors.outer === errorColors.inner) {
|
|
@@ -191,24 +219,24 @@ const CheckboxInput = styled('input')<CheckboxProps & StyledType>(
|
|
|
191
219
|
|
|
192
220
|
const errorStyles = {
|
|
193
221
|
'& ~ div:first-of-type': {
|
|
194
|
-
border:
|
|
222
|
+
border:
|
|
223
|
+
variant === 'inverse' ? `1px solid ${colors.soap300}` : `1px solid ${errorColors.inner}`,
|
|
195
224
|
boxShadow: `0 0 0 1px ${errorColors.inner}, 0 0 0 2px ${errorColors.outer}`,
|
|
196
225
|
},
|
|
197
226
|
'&:not(:checked):not(:disabled):not(:focus):hover, &:not(:checked):not(:disabled):active': {
|
|
198
227
|
'~ div:first-of-type': {
|
|
199
|
-
borderColor: errorColors.inner,
|
|
228
|
+
borderColor: variant === 'inverse' ? `1px solid ${colors.soap300}` : errorColors.inner,
|
|
200
229
|
},
|
|
201
230
|
},
|
|
202
231
|
'&:checked ~ div:first-of-type': {
|
|
203
|
-
borderColor: theme.canvas.palette.primary.main,
|
|
232
|
+
borderColor: variant === 'inverse' ? colors.soap300 : theme.canvas.palette.primary.main,
|
|
204
233
|
boxShadow: `
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
234
|
+
0 0 0 2px ${colors.frenchVanilla100},
|
|
235
|
+
0 0 0 4px ${errorColors.inner},
|
|
236
|
+
0 0 0 5px ${errorColors.outer}`,
|
|
208
237
|
},
|
|
209
238
|
};
|
|
210
239
|
return {
|
|
211
|
-
...errorStyles,
|
|
212
240
|
// Error rings take precedence over focus
|
|
213
241
|
...mouseFocusBehavior({
|
|
214
242
|
...errorStyles,
|
|
@@ -217,25 +245,30 @@ const CheckboxInput = styled('input')<CheckboxProps & StyledType>(
|
|
|
217
245
|
boxShadow: `0 0 0 1px ${errorColors.inner}, 0 0 0 2px ${errorColors.outer}`,
|
|
218
246
|
},
|
|
219
247
|
}),
|
|
248
|
+
...errorStyles,
|
|
220
249
|
};
|
|
221
250
|
}
|
|
222
251
|
);
|
|
223
252
|
|
|
224
|
-
const CheckboxBackground = styled('div')<CheckboxProps>(
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
253
|
+
const CheckboxBackground = styled('div')<CheckboxProps>(
|
|
254
|
+
{
|
|
255
|
+
alignItems: 'center',
|
|
256
|
+
backgroundColor: colors.frenchVanilla100,
|
|
257
|
+
borderRadius: borderRadius.s,
|
|
258
|
+
boxSizing: 'border-box',
|
|
259
|
+
display: 'flex',
|
|
260
|
+
height: checkboxHeight,
|
|
261
|
+
justifyContent: 'center',
|
|
262
|
+
padding: '0px 2px',
|
|
263
|
+
pointerEvents: 'none',
|
|
264
|
+
position: 'absolute',
|
|
265
|
+
transition: 'border 200ms ease, background 200ms',
|
|
266
|
+
width: checkboxWidth,
|
|
267
|
+
},
|
|
268
|
+
({variant}) => ({
|
|
269
|
+
border: `1px solid ${variant === 'inverse' ? colors.soap300 : inputColors.border}`,
|
|
270
|
+
})
|
|
271
|
+
);
|
|
239
272
|
|
|
240
273
|
const CheckboxCheck = styled('div')<Pick<CheckboxProps, 'checked'>>(
|
|
241
274
|
{
|
|
@@ -261,22 +294,32 @@ const CheckboxCheck = styled('div')<Pick<CheckboxProps, 'checked'>>(
|
|
|
261
294
|
})
|
|
262
295
|
);
|
|
263
296
|
|
|
264
|
-
const IndeterminateBox = styled('div')(
|
|
297
|
+
const IndeterminateBox = styled('div')<CheckboxProps>(
|
|
265
298
|
{
|
|
266
299
|
width: '10px',
|
|
267
300
|
height: '2px',
|
|
268
301
|
},
|
|
269
|
-
({theme}) => ({
|
|
270
|
-
backgroundColor:
|
|
302
|
+
({theme, variant}) => ({
|
|
303
|
+
backgroundColor:
|
|
304
|
+
variant === 'inverse'
|
|
305
|
+
? theme.canvas.palette.primary.main
|
|
306
|
+
: theme.canvas.palette.primary.contrast,
|
|
271
307
|
})
|
|
272
308
|
);
|
|
273
309
|
|
|
274
|
-
const CheckboxLabel = styled('label')<{disabled?: boolean}>(
|
|
310
|
+
const CheckboxLabel = styled('label')<{disabled?: boolean; variant?: string}>(
|
|
275
311
|
{
|
|
276
312
|
...canvas.type.levels.subtext.large,
|
|
277
313
|
paddingLeft: checkboxLabelDistance,
|
|
278
314
|
},
|
|
279
|
-
({
|
|
315
|
+
({variant}) => (variant === 'inverse' ? {color: colors.frenchVanilla100} : undefined),
|
|
316
|
+
({disabled, variant}) =>
|
|
317
|
+
disabled
|
|
318
|
+
? {
|
|
319
|
+
color: variant === 'inverse' ? colors.frenchVanilla100 : inputColors.disabled.text,
|
|
320
|
+
opacity: variant === 'inverse' ? '.4' : '1',
|
|
321
|
+
}
|
|
322
|
+
: {cursor: 'pointer'}
|
|
280
323
|
);
|
|
281
324
|
|
|
282
325
|
export const Checkbox = createComponent('input')({
|
|
@@ -294,6 +337,7 @@ export const Checkbox = createComponent('input')({
|
|
|
294
337
|
value,
|
|
295
338
|
error,
|
|
296
339
|
indeterminate,
|
|
340
|
+
variant,
|
|
297
341
|
...elemProps
|
|
298
342
|
}: CheckboxProps,
|
|
299
343
|
ref,
|
|
@@ -313,22 +357,30 @@ export const Checkbox = createComponent('input')({
|
|
|
313
357
|
type="checkbox"
|
|
314
358
|
value={value}
|
|
315
359
|
error={error}
|
|
360
|
+
variant={variant}
|
|
316
361
|
aria-checked={indeterminate ? 'mixed' : checked}
|
|
317
362
|
{...elemProps}
|
|
318
363
|
/>
|
|
319
|
-
<CheckboxRipple />
|
|
320
|
-
<CheckboxBackground checked={checked} disabled={disabled}>
|
|
364
|
+
<CheckboxRipple variant={variant} />
|
|
365
|
+
<CheckboxBackground variant={variant} checked={checked} disabled={disabled}>
|
|
321
366
|
<CheckboxCheck checked={checked}>
|
|
322
367
|
{indeterminate ? (
|
|
323
|
-
<IndeterminateBox />
|
|
368
|
+
<IndeterminateBox variant={variant} />
|
|
324
369
|
) : (
|
|
325
|
-
<SystemIcon
|
|
370
|
+
<SystemIcon
|
|
371
|
+
icon={checkSmallIcon}
|
|
372
|
+
color={
|
|
373
|
+
variant === 'inverse'
|
|
374
|
+
? theme.canvas.palette.primary.main
|
|
375
|
+
: theme.canvas.palette.primary.contrast
|
|
376
|
+
}
|
|
377
|
+
/>
|
|
326
378
|
)}
|
|
327
379
|
</CheckboxCheck>
|
|
328
380
|
</CheckboxBackground>
|
|
329
381
|
</CheckboxInputWrapper>
|
|
330
382
|
{label && (
|
|
331
|
-
<CheckboxLabel htmlFor={inputId} disabled={disabled}>
|
|
383
|
+
<CheckboxLabel variant={variant} htmlFor={inputId} disabled={disabled}>
|
|
332
384
|
{label}
|
|
333
385
|
</CheckboxLabel>
|
|
334
386
|
)}
|
|
@@ -38,6 +38,10 @@ export interface CheckboxProps extends Themeable {
|
|
|
38
38
|
* @default false
|
|
39
39
|
*/
|
|
40
40
|
indeterminate?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* The variant for the checkbox
|
|
43
|
+
*/
|
|
44
|
+
variant?: 'inverse' | undefined;
|
|
41
45
|
}
|
|
42
46
|
export declare const Checkbox: import("../../common").ElementComponent<"input", CheckboxProps> & {
|
|
43
47
|
ErrorType: typeof ErrorType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../../checkbox/lib/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAGL,SAAS,EAOT,SAAS,EACV,MAAM,kCAAkC,CAAC;AAU1C,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAC5D;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../../checkbox/lib/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAGL,SAAS,EAOT,SAAS,EACV,MAAM,kCAAkC,CAAC;AAU1C,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAC5D;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACjC;AAoQD,eAAO,MAAM,QAAQ;;CAoEnB,CAAC;AAEH,eAAe,QAAQ,CAAC"}
|
|
@@ -79,55 +79,70 @@ var CheckboxRipple = common_1.styled('span')({
|
|
|
79
79
|
width: checkboxWidth,
|
|
80
80
|
position: 'absolute',
|
|
81
81
|
pointerEvents: 'none',
|
|
82
|
-
|
|
82
|
+
}, function (_a) {
|
|
83
|
+
var variant = _a.variant;
|
|
84
|
+
return ({
|
|
85
|
+
opacity: variant === 'inverse' ? '0.4' : '1',
|
|
86
|
+
});
|
|
83
87
|
});
|
|
84
88
|
/**
|
|
85
89
|
* Note: `~ div:first-of-type` refers to `CheckboxBackground`
|
|
86
90
|
* and was easier to use than a component selector in this case.
|
|
87
91
|
*/
|
|
88
92
|
var CheckboxInput = common_1.styled('input')(function (_a) {
|
|
89
|
-
var _b = _a.theme.canvas.palette, themePrimary = _b.primary, themeFocusOutline = _b.common.focusOutline;
|
|
93
|
+
var _b = _a.theme.canvas.palette, themePrimary = _b.primary, themeFocusOutline = _b.common.focusOutline, variant = _a.variant;
|
|
90
94
|
return (__assign({ borderRadius: tokens_1.borderRadius.s, width: checkboxTapArea, height: checkboxTapArea, margin: 0, marginTop: '-3px', marginLeft: '-3px', position: 'absolute', opacity: 0, '&:not(:disabled)': {
|
|
91
95
|
cursor: 'pointer',
|
|
92
96
|
},
|
|
93
97
|
// States
|
|
94
98
|
'&:not(:checked):not(:disabled):not(:focus):hover, &:not(:checked):not(:disabled):active': {
|
|
95
99
|
'~ div:first-of-type': {
|
|
96
|
-
borderColor: tokens_1.inputColors.hoverBorder,
|
|
100
|
+
borderColor: variant === 'inverse' ? tokens_1.colors.soap300 : tokens_1.inputColors.hoverBorder,
|
|
97
101
|
},
|
|
98
102
|
}, '&:checked ~ div:first-of-type': {
|
|
99
|
-
borderColor: themePrimary.main,
|
|
100
|
-
backgroundColor: themePrimary.main,
|
|
103
|
+
borderColor: variant === 'inverse' ? tokens_1.colors.soap300 : themePrimary.main,
|
|
104
|
+
backgroundColor: variant === 'inverse' ? tokens_1.colors.frenchVanilla100 : themePrimary.main,
|
|
101
105
|
}, '&:disabled ~ div:first-of-type': {
|
|
102
106
|
borderColor: tokens_1.inputColors.disabled.border,
|
|
103
|
-
backgroundColor: tokens_1.inputColors.disabled.background,
|
|
107
|
+
backgroundColor: variant === 'inverse' ? tokens_1.colors.soap300 : tokens_1.inputColors.disabled.background,
|
|
108
|
+
opacity: variant === 'inverse' ? '.4' : '1',
|
|
104
109
|
}, '&:disabled:checked ~ div:first-of-type': {
|
|
105
|
-
borderColor: themePrimary.light,
|
|
106
|
-
backgroundColor: themePrimary.light,
|
|
110
|
+
borderColor: variant === 'inverse' ? tokens_1.colors.soap300 : themePrimary.light,
|
|
111
|
+
backgroundColor: variant === 'inverse' ? tokens_1.colors.soap300 : themePrimary.light,
|
|
107
112
|
},
|
|
108
113
|
// Focus
|
|
109
114
|
'&:focus, &:active': {
|
|
110
115
|
outline: 'none',
|
|
111
|
-
}, '&:focus ~ div:first-of-type': {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
+
}, '&:focus ~ div:first-of-type': __assign({ borderColor: variant === 'inverse' ? tokens_1.colors.blackPepper400 : themePrimary.main, borderWidth: '2px', boxShadow: 'none' }, common_1.focusRing({
|
|
117
|
+
width: variant === 'inverse' ? 2 : 0,
|
|
118
|
+
separation: 0,
|
|
119
|
+
animate: false,
|
|
120
|
+
innerColor: variant === 'inverse' ? tokens_1.colors.blackPepper400 : undefined,
|
|
121
|
+
outerColor: variant === 'inverse' ? tokens_1.colors.frenchVanilla100 : undefined,
|
|
122
|
+
})), '&:checked:focus ~ div:first-of-type': __assign(__assign({}, common_1.focusRing({
|
|
123
|
+
width: 2,
|
|
124
|
+
separation: 2,
|
|
125
|
+
animate: false,
|
|
126
|
+
innerColor: variant === 'inverse' ? tokens_1.colors.blackPepper400 : undefined,
|
|
127
|
+
outerColor: variant === 'inverse' ? tokens_1.colors.frenchVanilla100 : themeFocusOutline,
|
|
128
|
+
})), { borderColor: variant === 'inverse' ? tokens_1.colors.frenchVanilla100 : themePrimary.main, borderWidth: '2px', '& span': {
|
|
116
129
|
marginLeft: '-7px',
|
|
117
130
|
} }) }, common_1.mouseFocusBehavior({
|
|
118
131
|
'&:focus ~ div:first-of-type': {
|
|
119
|
-
border:
|
|
132
|
+
border: variant === 'inverse'
|
|
133
|
+
? "1px solid " + tokens_1.colors.soap300
|
|
134
|
+
: "1px solid " + tokens_1.inputColors.hoverBorder,
|
|
120
135
|
boxShadow: 'none',
|
|
121
136
|
'& span': {
|
|
122
137
|
marginLeft: '-6px',
|
|
123
138
|
},
|
|
124
139
|
},
|
|
125
140
|
'&:checked ~ div:first-of-type': {
|
|
126
|
-
borderColor: themePrimary.main,
|
|
141
|
+
borderColor: variant === 'inverse' ? tokens_1.colors.soap300 : themePrimary.main,
|
|
127
142
|
},
|
|
128
143
|
'&:disabled:checked ~ div:first-of-type': {
|
|
129
144
|
borderColor: themePrimary.light,
|
|
130
|
-
backgroundColor: themePrimary.light,
|
|
145
|
+
backgroundColor: variant === 'inverse' ? tokens_1.colors.soap300 : themePrimary.light,
|
|
131
146
|
},
|
|
132
147
|
})));
|
|
133
148
|
}, function (_a) {
|
|
@@ -138,36 +153,35 @@ var CheckboxInput = common_1.styled('input')(function (_a) {
|
|
|
138
153
|
},
|
|
139
154
|
});
|
|
140
155
|
}, function (_a) {
|
|
141
|
-
var theme = _a.theme, error = _a.error;
|
|
156
|
+
var theme = _a.theme, error = _a.error, variant = _a.variant;
|
|
142
157
|
var errorColors = common_1.getErrorColors(error, theme);
|
|
143
158
|
if (errorColors.outer === errorColors.inner) {
|
|
144
159
|
errorColors.outer = 'transparent';
|
|
145
160
|
}
|
|
146
161
|
var errorStyles = {
|
|
147
162
|
'& ~ div:first-of-type': {
|
|
148
|
-
border: "1px solid " + errorColors.inner,
|
|
163
|
+
border: variant === 'inverse' ? "1px solid " + tokens_1.colors.soap300 : "1px solid " + errorColors.inner,
|
|
149
164
|
boxShadow: "0 0 0 1px " + errorColors.inner + ", 0 0 0 2px " + errorColors.outer,
|
|
150
165
|
},
|
|
151
166
|
'&:not(:checked):not(:disabled):not(:focus):hover, &:not(:checked):not(:disabled):active': {
|
|
152
167
|
'~ div:first-of-type': {
|
|
153
|
-
borderColor: errorColors.inner,
|
|
168
|
+
borderColor: variant === 'inverse' ? "1px solid " + tokens_1.colors.soap300 : errorColors.inner,
|
|
154
169
|
},
|
|
155
170
|
},
|
|
156
171
|
'&:checked ~ div:first-of-type': {
|
|
157
|
-
borderColor: theme.canvas.palette.primary.main,
|
|
158
|
-
boxShadow: "\n
|
|
172
|
+
borderColor: variant === 'inverse' ? tokens_1.colors.soap300 : theme.canvas.palette.primary.main,
|
|
173
|
+
boxShadow: "\n 0 0 0 2px " + tokens_1.colors.frenchVanilla100 + ",\n 0 0 0 4px " + errorColors.inner + ",\n 0 0 0 5px " + errorColors.outer,
|
|
159
174
|
},
|
|
160
175
|
};
|
|
161
|
-
return __assign(__assign({},
|
|
176
|
+
return __assign(__assign({}, common_1.mouseFocusBehavior(__assign(__assign({}, errorStyles), { '&:not(:checked):focus ~ div:first-of-type': {
|
|
162
177
|
border: "1px solid " + errorColors.inner,
|
|
163
178
|
boxShadow: "0 0 0 1px " + errorColors.inner + ", 0 0 0 2px " + errorColors.outer,
|
|
164
|
-
} })));
|
|
179
|
+
} }))), errorStyles);
|
|
165
180
|
});
|
|
166
181
|
var CheckboxBackground = common_1.styled('div')({
|
|
167
182
|
alignItems: 'center',
|
|
168
183
|
backgroundColor: tokens_1.colors.frenchVanilla100,
|
|
169
184
|
borderRadius: tokens_1.borderRadius.s,
|
|
170
|
-
border: '1px solid ' + tokens_1.inputColors.border,
|
|
171
185
|
boxSizing: 'border-box',
|
|
172
186
|
display: 'flex',
|
|
173
187
|
height: checkboxHeight,
|
|
@@ -177,6 +191,11 @@ var CheckboxBackground = common_1.styled('div')({
|
|
|
177
191
|
position: 'absolute',
|
|
178
192
|
transition: 'border 200ms ease, background 200ms',
|
|
179
193
|
width: checkboxWidth,
|
|
194
|
+
}, function (_a) {
|
|
195
|
+
var variant = _a.variant;
|
|
196
|
+
return ({
|
|
197
|
+
border: "1px solid " + (variant === 'inverse' ? tokens_1.colors.soap300 : tokens_1.inputColors.border),
|
|
198
|
+
});
|
|
180
199
|
});
|
|
181
200
|
var CheckboxCheck = common_1.styled('div')({
|
|
182
201
|
display: 'flex',
|
|
@@ -205,14 +224,24 @@ var IndeterminateBox = common_1.styled('div')({
|
|
|
205
224
|
width: '10px',
|
|
206
225
|
height: '2px',
|
|
207
226
|
}, function (_a) {
|
|
208
|
-
var theme = _a.theme;
|
|
227
|
+
var theme = _a.theme, variant = _a.variant;
|
|
209
228
|
return ({
|
|
210
|
-
backgroundColor:
|
|
229
|
+
backgroundColor: variant === 'inverse'
|
|
230
|
+
? theme.canvas.palette.primary.main
|
|
231
|
+
: theme.canvas.palette.primary.contrast,
|
|
211
232
|
});
|
|
212
233
|
});
|
|
213
234
|
var CheckboxLabel = common_1.styled('label')(__assign(__assign({}, tokens_1.default.type.levels.subtext.large), { paddingLeft: checkboxLabelDistance }), function (_a) {
|
|
214
|
-
var
|
|
215
|
-
return (
|
|
235
|
+
var variant = _a.variant;
|
|
236
|
+
return (variant === 'inverse' ? { color: tokens_1.colors.frenchVanilla100 } : undefined);
|
|
237
|
+
}, function (_a) {
|
|
238
|
+
var disabled = _a.disabled, variant = _a.variant;
|
|
239
|
+
return disabled
|
|
240
|
+
? {
|
|
241
|
+
color: variant === 'inverse' ? tokens_1.colors.frenchVanilla100 : tokens_1.inputColors.disabled.text,
|
|
242
|
+
opacity: variant === 'inverse' ? '.4' : '1',
|
|
243
|
+
}
|
|
244
|
+
: { cursor: 'pointer' };
|
|
216
245
|
});
|
|
217
246
|
exports.Checkbox = common_1.createComponent('input')({
|
|
218
247
|
displayName: 'Checkbox',
|
|
@@ -223,15 +252,17 @@ exports.Checkbox = common_1.createComponent('input')({
|
|
|
223
252
|
_d = _a.theme,
|
|
224
253
|
// TODO: Fix useTheme and make it a real hook
|
|
225
254
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
226
|
-
theme = _d === void 0 ? common_1.useTheme() : _d, id = _a.id, disabled = _a.disabled, onChange = _a.onChange, value = _a.value, error = _a.error, indeterminate = _a.indeterminate, elemProps = __rest(_a, ["checked", "label", "theme", "id", "disabled", "onChange", "value", "error", "indeterminate"]);
|
|
255
|
+
theme = _d === void 0 ? common_1.useTheme() : _d, id = _a.id, disabled = _a.disabled, onChange = _a.onChange, value = _a.value, error = _a.error, indeterminate = _a.indeterminate, variant = _a.variant, elemProps = __rest(_a, ["checked", "label", "theme", "id", "disabled", "onChange", "value", "error", "indeterminate", "variant"]);
|
|
227
256
|
var inputId = common_1.useUniqueId(id);
|
|
228
257
|
return (React.createElement(CheckboxContainer, null,
|
|
229
258
|
React.createElement(CheckboxInputWrapper, { disabled: disabled },
|
|
230
|
-
React.createElement(CheckboxInput, __assign({ as: Element, checked: checked, disabled: disabled, id: inputId, ref: ref, onChange: onChange, type: "checkbox", value: value, error: error, "aria-checked": indeterminate ? 'mixed' : checked }, elemProps)),
|
|
231
|
-
React.createElement(CheckboxRipple,
|
|
232
|
-
React.createElement(CheckboxBackground, { checked: checked, disabled: disabled },
|
|
233
|
-
React.createElement(CheckboxCheck, { checked: checked }, indeterminate ? (React.createElement(IndeterminateBox,
|
|
234
|
-
|
|
259
|
+
React.createElement(CheckboxInput, __assign({ as: Element, checked: checked, disabled: disabled, id: inputId, ref: ref, onChange: onChange, type: "checkbox", value: value, error: error, variant: variant, "aria-checked": indeterminate ? 'mixed' : checked }, elemProps)),
|
|
260
|
+
React.createElement(CheckboxRipple, { variant: variant }),
|
|
261
|
+
React.createElement(CheckboxBackground, { variant: variant, checked: checked, disabled: disabled },
|
|
262
|
+
React.createElement(CheckboxCheck, { checked: checked }, indeterminate ? (React.createElement(IndeterminateBox, { variant: variant })) : (React.createElement(icon_1.SystemIcon, { icon: canvas_system_icons_web_1.checkSmallIcon, color: variant === 'inverse'
|
|
263
|
+
? theme.canvas.palette.primary.main
|
|
264
|
+
: theme.canvas.palette.primary.contrast }))))),
|
|
265
|
+
label && (React.createElement(CheckboxLabel, { variant: variant, htmlFor: inputId, disabled: disabled }, label))));
|
|
235
266
|
},
|
|
236
267
|
subComponents: {
|
|
237
268
|
ErrorType: common_1.ErrorType,
|
|
@@ -33,6 +33,7 @@ export interface RadioProps extends Themeable {
|
|
|
33
33
|
* The value of the Radio button.
|
|
34
34
|
*/
|
|
35
35
|
value?: string;
|
|
36
|
+
variant?: 'inverse' | undefined;
|
|
36
37
|
}
|
|
37
38
|
export declare const Radio: import("../../common").ElementComponent<"input", RadioProps>;
|
|
38
39
|
export default Radio;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.d.ts","sourceRoot":"","sources":["../../../../radio/lib/Radio.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAML,SAAS,EAEV,MAAM,kCAAkC,CAAC;AAQ1C,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAC5D;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"Radio.d.ts","sourceRoot":"","sources":["../../../../radio/lib/Radio.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAML,SAAS,EAEV,MAAM,kCAAkC,CAAC;AAQ1C,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAC5D;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACjC;AAkPD,eAAO,MAAM,KAAK,8DAgDhB,CAAC;AAEH,eAAe,KAAK,CAAC"}
|