@fluentui/react-checkbox 9.0.0-alpha.7 → 9.0.0-beta.2
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/CHANGELOG.json +1224 -1
- package/CHANGELOG.md +450 -2
- package/Spec.md +30 -34
- package/dist/react-checkbox.d.ts +81 -21
- package/lib/Checkbox.js.map +1 -1
- package/lib/common/isConformant.js +3 -0
- package/lib/common/isConformant.js.map +1 -1
- package/lib/components/Checkbox/Checkbox.d.ts +3 -3
- package/lib/components/Checkbox/Checkbox.js.map +1 -1
- package/lib/components/Checkbox/Checkbox.types.d.ts +73 -13
- package/lib/components/Checkbox/Checkbox.types.js.map +1 -1
- package/lib/components/Checkbox/DefaultIcons.d.ts +4 -0
- package/lib/components/Checkbox/DefaultIcons.js +10 -0
- package/lib/components/Checkbox/DefaultIcons.js.map +1 -0
- package/lib/components/Checkbox/index.js.map +1 -1
- package/lib/components/Checkbox/renderCheckbox.d.ts +0 -3
- package/lib/components/Checkbox/renderCheckbox.js +8 -6
- package/lib/components/Checkbox/renderCheckbox.js.map +1 -1
- package/lib/components/Checkbox/useCheckbox.d.ts +4 -5
- package/lib/components/Checkbox/useCheckbox.js +66 -11
- package/lib/components/Checkbox/useCheckbox.js.map +1 -1
- package/lib/components/Checkbox/useCheckboxStyles.js +156 -4
- package/lib/components/Checkbox/useCheckboxStyles.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib-commonjs/Checkbox.js.map +1 -1
- package/lib-commonjs/common/isConformant.js +3 -0
- package/lib-commonjs/common/isConformant.js.map +1 -1
- package/lib-commonjs/components/Checkbox/Checkbox.d.ts +3 -3
- package/lib-commonjs/components/Checkbox/Checkbox.js.map +1 -1
- package/lib-commonjs/components/Checkbox/Checkbox.types.d.ts +73 -13
- package/lib-commonjs/components/Checkbox/Checkbox.types.js.map +1 -1
- package/lib-commonjs/components/Checkbox/DefaultIcons.d.ts +4 -0
- package/lib-commonjs/components/Checkbox/DefaultIcons.js +17 -0
- package/lib-commonjs/components/Checkbox/DefaultIcons.js.map +1 -0
- package/lib-commonjs/components/Checkbox/index.js.map +1 -1
- package/lib-commonjs/components/Checkbox/renderCheckbox.d.ts +0 -3
- package/lib-commonjs/components/Checkbox/renderCheckbox.js +7 -5
- package/lib-commonjs/components/Checkbox/renderCheckbox.js.map +1 -1
- package/lib-commonjs/components/Checkbox/useCheckbox.d.ts +4 -5
- package/lib-commonjs/components/Checkbox/useCheckbox.js +65 -10
- package/lib-commonjs/components/Checkbox/useCheckbox.js.map +1 -1
- package/lib-commonjs/components/Checkbox/useCheckboxStyles.js +156 -4
- package/lib-commonjs/components/Checkbox/useCheckboxStyles.js.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +15 -11
- package/config/api-extractor.json +0 -3
- package/config/tests.js +0 -7
- package/etc/react-checkbox.api.md +0 -44
- package/just.config.ts +0 -3
- package/lib-amd/Checkbox.d.ts +0 -1
- package/lib-amd/Checkbox.js +0 -6
- package/lib-amd/Checkbox.js.map +0 -1
- package/lib-amd/common/isConformant.d.ts +0 -4
- package/lib-amd/common/isConformant.js +0 -14
- package/lib-amd/common/isConformant.js.map +0 -1
- package/lib-amd/components/Checkbox/Checkbox.d.ts +0 -6
- package/lib-amd/components/Checkbox/Checkbox.js +0 -15
- package/lib-amd/components/Checkbox/Checkbox.js.map +0 -1
- package/lib-amd/components/Checkbox/Checkbox.types.d.ts +0 -24
- package/lib-amd/components/Checkbox/Checkbox.types.js +0 -5
- package/lib-amd/components/Checkbox/Checkbox.types.js.map +0 -1
- package/lib-amd/components/Checkbox/index.d.ts +0 -5
- package/lib-amd/components/Checkbox/index.js +0 -10
- package/lib-amd/components/Checkbox/index.js.map +0 -1
- package/lib-amd/components/Checkbox/renderCheckbox.d.ts +0 -5
- package/lib-amd/components/Checkbox/renderCheckbox.js +0 -14
- package/lib-amd/components/Checkbox/renderCheckbox.js.map +0 -1
- package/lib-amd/components/Checkbox/useCheckbox.d.ts +0 -17
- package/lib-amd/components/Checkbox/useCheckbox.js +0 -30
- package/lib-amd/components/Checkbox/useCheckbox.js.map +0 -1
- package/lib-amd/components/Checkbox/useCheckboxStyles.d.ts +0 -5
- package/lib-amd/components/Checkbox/useCheckboxStyles.js +0 -25
- package/lib-amd/components/Checkbox/useCheckboxStyles.js.map +0 -1
- package/lib-amd/index.d.ts +0 -1
- package/lib-amd/index.js +0 -6
- package/lib-amd/index.js.map +0 -1
- package/src/components/Checkbox/Checkbox.types.ts +0 -34
|
@@ -1,20 +1,172 @@
|
|
|
1
1
|
import { makeStyles, mergeClasses } from '@fluentui/react-make-styles';
|
|
2
|
+
import { createFocusOutlineStyle } from '@fluentui/react-tabster';
|
|
2
3
|
/**
|
|
3
4
|
* Styles for the root slot
|
|
4
5
|
*/
|
|
5
6
|
var useStyles = makeStyles({
|
|
6
7
|
root: function (theme) { return ({
|
|
7
|
-
|
|
8
|
+
display: 'inline-flex',
|
|
9
|
+
position: 'relative',
|
|
10
|
+
alignSelf: 'flex-start',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
padding: '4px',
|
|
13
|
+
userSelect: 'none',
|
|
14
|
+
cursor: 'pointer',
|
|
15
|
+
}); },
|
|
16
|
+
disabled: function (theme) { return ({
|
|
17
|
+
color: theme.colorNeutralForegroundDisabled,
|
|
18
|
+
cursor: 'default',
|
|
19
|
+
'& .ms-checkbox-indicator': {
|
|
20
|
+
borderColor: theme.colorNeutralStrokeDisabled,
|
|
21
|
+
color: theme.colorNeutralForegroundDisabled,
|
|
22
|
+
backgroundColor: theme.colorNeutralBackground1,
|
|
23
|
+
},
|
|
24
|
+
':hover': {
|
|
25
|
+
'& .ms-checkbox-indicator': {
|
|
26
|
+
borderColor: theme.colorNeutralStrokeDisabled,
|
|
27
|
+
color: theme.colorNeutralForegroundDisabled,
|
|
28
|
+
backgroundColor: theme.colorNeutralBackground1,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
':active': {
|
|
32
|
+
'& .ms-checkbox-indicator': {
|
|
33
|
+
borderColor: theme.colorNeutralStrokeDisabled,
|
|
34
|
+
color: theme.colorNeutralForegroundDisabled,
|
|
35
|
+
backgroundColor: theme.colorNeutralBackground1,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
}); },
|
|
39
|
+
unchecked: function (theme) { return ({
|
|
40
|
+
color: theme.colorNeutralForeground3,
|
|
41
|
+
'& .ms-checkbox-indicator': {
|
|
42
|
+
borderColor: theme.colorNeutralStrokeAccessible,
|
|
43
|
+
'& > *': {
|
|
44
|
+
opacity: 0,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
':hover': {
|
|
48
|
+
color: theme.colorNeutralForeground2,
|
|
49
|
+
'& .ms-checkbox-indicator': {
|
|
50
|
+
borderColor: theme.colorNeutralStrokeAccessibleHover,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
':active': {
|
|
54
|
+
color: theme.colorNeutralForeground1,
|
|
55
|
+
'& .ms-checkbox-indicator': {
|
|
56
|
+
borderColor: theme.colorNeutralStrokeAccessiblePressed,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
}); },
|
|
60
|
+
checked: function (theme) { return ({
|
|
61
|
+
color: theme.colorNeutralForeground1,
|
|
62
|
+
// TODO: neutralForegroundInverted change to NeutralForegroundOnBrand once it's added
|
|
63
|
+
'& .ms-checkbox-indicator': {
|
|
64
|
+
backgroundColor: theme.colorCompoundBrandBackground,
|
|
65
|
+
color: theme.colorNeutralForegroundInverted,
|
|
66
|
+
borderColor: theme.colorBrandBackground,
|
|
67
|
+
},
|
|
68
|
+
':active': {
|
|
69
|
+
'& .ms-checkbox-indicator': {
|
|
70
|
+
backgroundColor: theme.colorCompoundBrandBackgroundPressed,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
':hover': {
|
|
74
|
+
'& .ms-checkbox-indicator': {
|
|
75
|
+
backgroundColor: theme.colorCompoundBrandBackgroundHover,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
}); },
|
|
79
|
+
mixed: function (theme) { return ({
|
|
80
|
+
color: theme.colorNeutralForeground1,
|
|
81
|
+
'& .ms-checkbox-indicator': {
|
|
82
|
+
borderColor: theme.colorCompoundBrandStroke,
|
|
83
|
+
color: theme.colorCompoundBrandForeground1,
|
|
84
|
+
},
|
|
85
|
+
':active': {
|
|
86
|
+
'& .ms-checkbox-indicator': {
|
|
87
|
+
borderColor: theme.colorCompoundBrandStrokePressed,
|
|
88
|
+
color: theme.colorCompoundBrandForeground1Pressed,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
':hover': {
|
|
92
|
+
'& .ms-checkbox-indicator': {
|
|
93
|
+
borderColor: theme.colorCompoundBrandStrokeHover,
|
|
94
|
+
color: theme.colorCompoundBrandForeground1Hover,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
}); },
|
|
98
|
+
focusIndicator: function (theme) {
|
|
99
|
+
return createFocusOutlineStyle(theme, { style: { outlineOffset: '2px' }, selector: 'focus-within' });
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
var useContainerStyles = makeStyles({
|
|
103
|
+
container: {
|
|
104
|
+
position: 'relative',
|
|
105
|
+
display: 'flex',
|
|
106
|
+
alignItems: 'center',
|
|
107
|
+
justifyContent: 'center',
|
|
108
|
+
},
|
|
109
|
+
medium: {
|
|
110
|
+
width: '16px',
|
|
111
|
+
height: '16px',
|
|
112
|
+
},
|
|
113
|
+
large: {
|
|
114
|
+
width: '20px',
|
|
115
|
+
height: '20px',
|
|
116
|
+
},
|
|
117
|
+
// TODO: change marginLeft to Spacing horizontal M once it's added
|
|
118
|
+
before: function (theme) { return ({
|
|
119
|
+
marginLeft: '12px',
|
|
120
|
+
}); },
|
|
121
|
+
// TODO: change marginRight to Spacing horizontal M once it's added
|
|
122
|
+
after: function (theme) { return ({
|
|
123
|
+
marginRight: '12px',
|
|
124
|
+
}); },
|
|
125
|
+
});
|
|
126
|
+
var useInputStyles = makeStyles({
|
|
127
|
+
input: {
|
|
128
|
+
opacity: 0,
|
|
129
|
+
position: 'absolute',
|
|
130
|
+
margin: 0,
|
|
131
|
+
padding: 0,
|
|
132
|
+
cursor: 'pointer',
|
|
133
|
+
},
|
|
134
|
+
disabled: {
|
|
135
|
+
cursor: 'not-allowed',
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
var useIndicatorStyles = makeStyles({
|
|
139
|
+
box: function (theme) { return ({
|
|
140
|
+
width: '100%',
|
|
141
|
+
height: '100%',
|
|
142
|
+
fill: 'currentColor',
|
|
143
|
+
overflow: 'hidden',
|
|
144
|
+
display: 'flex',
|
|
145
|
+
alignItems: 'center',
|
|
146
|
+
justifyContent: 'center',
|
|
147
|
+
position: 'absolute',
|
|
148
|
+
boxSizing: 'border-box',
|
|
149
|
+
borderStyle: 'solid',
|
|
150
|
+
borderRadius: theme.borderRadiusSmall,
|
|
151
|
+
borderWidth: theme.strokeWidthThin,
|
|
152
|
+
}); },
|
|
153
|
+
circular: function (theme) { return ({
|
|
154
|
+
borderRadius: theme.borderRadiusCircular,
|
|
8
155
|
}); },
|
|
9
156
|
});
|
|
10
157
|
/**
|
|
11
158
|
* Apply styling to the Checkbox slots based on the state
|
|
12
159
|
*/
|
|
13
160
|
export var useCheckboxStyles = function (state) {
|
|
161
|
+
var checkedState = state.checked === 'mixed' ? 'mixed' : state.checked ? 'checked' : 'unchecked';
|
|
162
|
+
var indicatorStyles = useIndicatorStyles();
|
|
163
|
+
var inputStyles = useInputStyles();
|
|
164
|
+
var containerStyles = useContainerStyles();
|
|
14
165
|
var styles = useStyles();
|
|
15
|
-
state.className = mergeClasses(styles.root, state.className);
|
|
16
|
-
|
|
17
|
-
|
|
166
|
+
state.root.className = mergeClasses(styles.root, styles.focusIndicator, styles[checkedState], state.input.disabled && styles.disabled, state.root.className);
|
|
167
|
+
state.input.className = mergeClasses(containerStyles[state.size], inputStyles.input, state.input.disabled && inputStyles.disabled, state.input.className);
|
|
168
|
+
state.containerClassName = mergeClasses(containerStyles.container, containerStyles[state.size], !!state.root.children && containerStyles[state.labelPosition]);
|
|
169
|
+
state.indicator.className = mergeClasses(indicatorStyles.box, containerStyles[state.size], state.circular && indicatorStyles.circular, 'ms-checkbox-indicator', state.indicator.className);
|
|
18
170
|
return state;
|
|
19
171
|
};
|
|
20
172
|
//# sourceMappingURL=useCheckboxStyles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCheckboxStyles.js","sourceRoot":"
|
|
1
|
+
{"version":3,"file":"useCheckboxStyles.js","sourceRoot":"","sources":["../../../src/components/Checkbox/useCheckboxStyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAGlE;;GAEG;AACH,IAAM,SAAS,GAAG,UAAU,CAAC;IAC3B,IAAI,EAAE,UAAA,KAAK,IAAI,OAAA,CAAC;QACd,OAAO,EAAE,aAAa;QACtB,QAAQ,EAAE,UAAU;QACpB,SAAS,EAAE,YAAY;QACvB,UAAU,EAAE,QAAQ;QACpB,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,MAAM;QAClB,MAAM,EAAE,SAAS;KAClB,CAAC,EARa,CAQb;IAEF,QAAQ,EAAE,UAAA,KAAK,IAAI,OAAA,CAAC;QAClB,KAAK,EAAE,KAAK,CAAC,8BAA8B;QAC3C,MAAM,EAAE,SAAS;QAEjB,0BAA0B,EAAE;YAC1B,WAAW,EAAE,KAAK,CAAC,0BAA0B;YAC7C,KAAK,EAAE,KAAK,CAAC,8BAA8B;YAC3C,eAAe,EAAE,KAAK,CAAC,uBAAuB;SAC/C;QAED,QAAQ,EAAE;YACR,0BAA0B,EAAE;gBAC1B,WAAW,EAAE,KAAK,CAAC,0BAA0B;gBAC7C,KAAK,EAAE,KAAK,CAAC,8BAA8B;gBAC3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AAY,CAAC,EACpB,KAAK,CAAC,KAAK,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,EACvC,KAAK,CAAC,IAAI,CAAC,SAAS,CACrB,CAAC;IAEF,KAAK,CAAC,KAAK,CAAC,SAAS,GAAG,YAAY,CAClC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAC3B,WAAW,CAAC,KAAK,EACjB,KAAK,CAAC,KAAK,CAAC,QAAQ,IAAI,WAAW,CAAC,QAAQ,EAC5C,KAAK,CAAC,KAAK,CAAC,SAAS,CACtB,CAAC;IAEF,KAAK,CAAC,kBAAkB,GAAG,YAAY,CACrC,eAAe,CAAC,SAAS,EACzB,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAC3B,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,IAAI,eAAe,CAAC,KAAK,CAAC,aAAa,CAAC,CAC9D,CAAC;IACF,KAAK,CAAC,SAAS,CAAC,SAAS,GAAG,YAAY,CACtC,eAAe,CAAC,GAAG,EACnB,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAC3B,KAAK,CAAC,QAAQ,IAAI,eAAe,CAAC,QAAQ,EAC1C,uBAAuB,EACvB,KAAK,CAAC,SAAS,CAAC,SAAS,CAC1B,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
package/lib/tsdoc-metadata.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sourceRoot":"
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../src/Checkbox.ts"],"names":[],"mappings":";;;AAAA,sEAA4C"}
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isConformant = void 0;
|
|
4
4
|
var react_conformance_1 = require("@fluentui/react-conformance");
|
|
5
|
+
var react_conformance_make_styles_1 = require("@fluentui/react-conformance-make-styles");
|
|
5
6
|
function isConformant(testInfo) {
|
|
6
7
|
var defaultOptions = {
|
|
7
8
|
asPropHandlesRef: true,
|
|
8
9
|
componentPath: module.parent.filename.replace('.test', ''),
|
|
10
|
+
extraTests: react_conformance_make_styles_1.default,
|
|
11
|
+
skipAsPropTests: true,
|
|
9
12
|
};
|
|
10
13
|
react_conformance_1.isConformant(defaultOptions, testInfo);
|
|
11
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isConformant.js","sourceRoot":"
|
|
1
|
+
{"version":3,"file":"isConformant.js","sourceRoot":"","sources":["../../src/common/isConformant.ts"],"names":[],"mappings":";;;AAAA,iEAAgH;AAChH,yFAAsE;AAEtE,SAAgB,YAAY,CAC1B,QAAyF;IAEzF,IAAM,cAAc,GAAyC;QAC3D,gBAAgB,EAAE,IAAI;QACtB,aAAa,EAAE,MAAO,CAAC,MAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QAC5D,UAAU,EAAE,uCAAqC;QACjD,eAAe,EAAE,IAAI;KACtB,CAAC;IAEF,gCAAgB,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;AAC7C,CAAC;AAXD,oCAWC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import type { CheckboxProps } from './Checkbox.types';
|
|
2
|
+
import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
|
3
3
|
/**
|
|
4
4
|
* A Checkbox component provides a way to represent options that can be selected
|
|
5
5
|
*/
|
|
6
|
-
export declare const Checkbox:
|
|
6
|
+
export declare const Checkbox: ForwardRefComponent<CheckboxProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sourceRoot":"
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../src/components/Checkbox/Checkbox.tsx"],"names":[],"mappings":";;;AAAA,6BAA+B;AAC/B,6CAA4C;AAC5C,mDAAkD;AAClD,yDAAwD;AAIxD;;GAEG;AACU,QAAA,QAAQ,GAAuC,KAAK,CAAC,UAAU,CAAC,UAAC,KAAK,EAAE,GAAG;IACtF,IAAM,KAAK,GAAG,yBAAW,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAEtC,qCAAiB,CAAC,KAAK,CAAC,CAAC;IACzB,OAAO,+BAAc,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC;AAEH,gBAAQ,CAAC,WAAW,GAAG,UAAU,CAAC"}
|
|
@@ -1,24 +1,84 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ComponentProps, ComponentState, IntrinsicShorthandProps, ObjectShorthandProps } from '@fluentui/react-utilities';
|
|
3
|
+
import { LabelProps } from '@fluentui/react-label';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* TODO:
|
|
6
|
+
* - Remove as from Omit. Currently it's needed since checkbox Commons shouldn't have as.
|
|
7
|
+
* - Instead of extending LabelProps, extend LabelCommons once it's added.
|
|
5
8
|
*/
|
|
6
|
-
export interface
|
|
9
|
+
export interface CheckboxCommons {
|
|
10
|
+
/**
|
|
11
|
+
* A checkbox can be rendered with a circular shape.
|
|
12
|
+
*/
|
|
13
|
+
circular: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* ID of the root element that wraps the checkbox and label.
|
|
16
|
+
*/
|
|
17
|
+
rootId: string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* A checkbox's state can be controlled.
|
|
20
|
+
* @defaultvalue false
|
|
21
|
+
*/
|
|
22
|
+
checked: 'mixed' | boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Checkbox supports two different checkbox sizes.
|
|
25
|
+
* @defaultvalue 'medium'
|
|
26
|
+
*/
|
|
27
|
+
size: 'medium' | 'large';
|
|
28
|
+
/**
|
|
29
|
+
* Determines whether the label should be positioned before or after the checkbox.
|
|
30
|
+
* @defaultvalue 'after'
|
|
31
|
+
*/
|
|
32
|
+
labelPosition: 'before' | 'after';
|
|
33
|
+
/**
|
|
34
|
+
* Field required to pass className to container instead of input
|
|
35
|
+
* this will be solved by https://github.com/microsoft/fluentui/pull/18983
|
|
36
|
+
*/
|
|
37
|
+
containerClassName?: string;
|
|
7
38
|
}
|
|
8
39
|
/**
|
|
9
|
-
*
|
|
40
|
+
* Data for the onChange event for checkbox.
|
|
10
41
|
*/
|
|
11
|
-
export
|
|
42
|
+
export interface CheckboxOnChangeData {
|
|
43
|
+
checked: 'mixed' | boolean;
|
|
44
|
+
}
|
|
45
|
+
export declare type CheckboxSlots = {
|
|
46
|
+
root: ObjectShorthandProps<LabelProps> | IntrinsicShorthandProps<'span'>;
|
|
47
|
+
/**
|
|
48
|
+
* Hidden input that handles the checkbox's functionality.
|
|
49
|
+
*/
|
|
50
|
+
input: IntrinsicShorthandProps<'input'>;
|
|
51
|
+
/**
|
|
52
|
+
* Renders the checkbox, with the checkmark icon as its child when checked.
|
|
53
|
+
*/
|
|
54
|
+
indicator: IntrinsicShorthandProps<'div'>;
|
|
55
|
+
};
|
|
12
56
|
/**
|
|
13
|
-
*
|
|
57
|
+
* Checkbox Props
|
|
14
58
|
*/
|
|
15
|
-
export declare type
|
|
59
|
+
export declare type CheckboxProps = Omit<ComponentProps<CheckboxSlots>, 'defaultChecked'> & Partial<CheckboxCommons> & {
|
|
60
|
+
/**
|
|
61
|
+
* ID of the native element that represents the checkbox.
|
|
62
|
+
*/
|
|
63
|
+
id?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Callback to be called when the checked state value changes.
|
|
66
|
+
*/
|
|
67
|
+
onChange?: (ev: React.FormEvent<HTMLInputElement>, data: CheckboxOnChangeData) => void;
|
|
68
|
+
/**
|
|
69
|
+
* Whether the checkbox should be rendered as checked by default.
|
|
70
|
+
*/
|
|
71
|
+
defaultChecked?: 'mixed' | boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Required state of the checkbox.
|
|
74
|
+
*/
|
|
75
|
+
required?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Disabled
|
|
78
|
+
*/
|
|
79
|
+
disabled?: boolean;
|
|
80
|
+
};
|
|
16
81
|
/**
|
|
17
82
|
* State used in rendering Checkbox
|
|
18
83
|
*/
|
|
19
|
-
export
|
|
20
|
-
/**
|
|
21
|
-
* Ref to the root element
|
|
22
|
-
*/
|
|
23
|
-
ref: React.Ref<HTMLElement>;
|
|
24
|
-
}
|
|
84
|
+
export declare type CheckboxState = ComponentState<CheckboxSlots> & CheckboxCommons;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.types.js","sourceRoot":"
|
|
1
|
+
{"version":3,"file":"Checkbox.types.js","sourceRoot":"","sources":["../../../src/components/Checkbox/Checkbox.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Checkmark16Regular = exports.Checkmark12Regular = exports.Mixed16Regular = exports.Mixed12Regular = void 0;
|
|
4
|
+
var React = require("react");
|
|
5
|
+
var Mixed12Regular = function () { return (React.createElement("svg", { width: "12", height: "12", viewBox: "0 0 12 12", xmlns: "http://www.w3.org/2000/svg", focusable: "false" },
|
|
6
|
+
React.createElement("rect", { width: "8", height: "8", x: "2", y: "2" }))); };
|
|
7
|
+
exports.Mixed12Regular = Mixed12Regular;
|
|
8
|
+
var Mixed16Regular = function () { return (React.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", xmlns: "http://www.w3.org/2000/svg", focusable: "false" },
|
|
9
|
+
React.createElement("rect", { width: "10", height: "10", x: "3", y: "3" }))); };
|
|
10
|
+
exports.Mixed16Regular = Mixed16Regular;
|
|
11
|
+
var Checkmark12Regular = function () { return (React.createElement("svg", { width: "12", height: "12", viewBox: "0 0 12 12", xmlns: "http://www.w3.org/2000/svg" },
|
|
12
|
+
React.createElement("path", { d: "M9.85355 3.14645C10.0488 3.34171 10.0488 3.65829 9.85355 3.85355L5.35355 8.35355C5.15829 8.54882 4.84171 8.54882 4.64645 8.35355L2.64645 6.35355C2.45118 6.15829 2.45118 5.84171 2.64645 5.64645C2.84171 5.45118 3.15829 5.45118 3.35355 5.64645L5 7.29289L9.14645 3.14645C9.34171 2.95118 9.65829 2.95118 9.85355 3.14645Z" }))); };
|
|
13
|
+
exports.Checkmark12Regular = Checkmark12Regular;
|
|
14
|
+
var Checkmark16Regular = function () { return (React.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", xmlns: "http://www.w3.org/2000/svg" },
|
|
15
|
+
React.createElement("path", { d: "M13.8639 3.65609C14.0533 3.85704 14.0439 4.17348 13.8429 4.36288L5.91309 11.8368C5.67573 12.0605 5.30311 12.0536 5.07417 11.8213L2.39384 9.10093C2.20003 8.90422 2.20237 8.58765 2.39907 8.39384C2.59578 8.20003 2.91235 8.20237 3.10616 8.39908L5.51192 10.8407L13.1571 3.63517C13.358 3.44577 13.6745 3.45513 13.8639 3.65609Z" }))); };
|
|
16
|
+
exports.Checkmark16Regular = Checkmark16Regular;
|
|
17
|
+
//# sourceMappingURL=DefaultIcons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultIcons.js","sourceRoot":"","sources":["../../../src/components/Checkbox/DefaultIcons.tsx"],"names":[],"mappings":";;;AAAA,6BAA+B;AAExB,IAAM,cAAc,GAAG,cAAM,OAAA,CAClC,6BAAK,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,WAAW,EAAC,KAAK,EAAC,4BAA4B,EAAC,SAAS,EAAC,OAAO;IAClG,8BAAM,KAAK,EAAC,GAAG,EAAC,MAAM,EAAC,GAAG,EAAC,CAAC,EAAC,GAAG,EAAC,CAAC,EAAC,GAAG,GAAG,CACrC,CACP,EAJmC,CAInC,CAAC;AAJW,QAAA,cAAc,kBAIzB;AAEK,IAAM,cAAc,GAAG,cAAM,OAAA,CAClC,6BAAK,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,WAAW,EAAC,KAAK,EAAC,4BAA4B,EAAC,SAAS,EAAC,OAAO;IAClG,8BAAM,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,CAAC,EAAC,GAAG,EAAC,CAAC,EAAC,GAAG,GAAG,CACvC,CACP,EAJmC,CAInC,CAAC;AAJW,QAAA,cAAc,kBAIzB;AAEK,IAAM,kBAAkB,GAAG,cAAM,OAAA,CACtC,6BAAK,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,WAAW,EAAC,KAAK,EAAC,4BAA4B;IAChF,8BAAM,CAAC,EAAC,6TAA6T,GAAG,CACpU,CACP,EAJuC,CAIvC,CAAC;AAJW,QAAA,kBAAkB,sBAI7B;AAEK,IAAM,kBAAkB,GAAG,cAAM,OAAA,CACtC,6BAAK,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,WAAW,EAAC,KAAK,EAAC,4BAA4B;IAChF,8BAAM,CAAC,EAAC,kUAAkU,GAAG,CACzU,CACP,EAJuC,CAIvC,CAAC;AAJW,QAAA,kBAAkB,sBAI7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Checkbox/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,2DAAiC;AACjC,2DAAiC;AACjC,wDAA8B;AAC9B,8DAAoC"}
|
|
@@ -5,12 +5,14 @@ var tslib_1 = require("tslib");
|
|
|
5
5
|
var React = require("react");
|
|
6
6
|
var react_utilities_1 = require("@fluentui/react-utilities");
|
|
7
7
|
var useCheckbox_1 = require("./useCheckbox");
|
|
8
|
-
/**
|
|
9
|
-
* Render the final JSX of Checkbox
|
|
10
|
-
*/
|
|
11
8
|
var renderCheckbox = function (state) {
|
|
12
|
-
var _a = react_utilities_1.
|
|
13
|
-
return (React.createElement(slots.root, tslib_1.__assign({}, slotProps.root),
|
|
9
|
+
var _a = react_utilities_1.getSlots(state, useCheckbox_1.checkboxShorthandProps), slots = _a.slots, slotProps = _a.slotProps;
|
|
10
|
+
return (React.createElement(slots.root, tslib_1.__assign({}, slotProps.root),
|
|
11
|
+
state.labelPosition === 'before' && slotProps.root.children,
|
|
12
|
+
React.createElement("div", { className: state.containerClassName },
|
|
13
|
+
React.createElement(slots.indicator, tslib_1.__assign({}, slotProps.indicator)),
|
|
14
|
+
React.createElement(slots.input, tslib_1.__assign({}, slotProps.input))),
|
|
15
|
+
state.labelPosition === 'after' && slotProps.root.children));
|
|
14
16
|
};
|
|
15
17
|
exports.renderCheckbox = renderCheckbox;
|
|
16
18
|
//# sourceMappingURL=renderCheckbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderCheckbox.js","sourceRoot":"
|
|
1
|
+
{"version":3,"file":"renderCheckbox.js","sourceRoot":"","sources":["../../../src/components/Checkbox/renderCheckbox.tsx"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAC/B,6DAAqD;AAErD,6CAAuD;AAEhD,IAAM,cAAc,GAAG,UAAC,KAAoB;IAC3C,IAAA,KAAuB,0BAAQ,CAAgB,KAAK,EAAE,oCAAsB,CAAC,EAA3E,KAAK,WAAA,EAAE,SAAS,eAA2D,CAAC;IAEpF,OAAO,CACL,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI;QAC3B,KAAK,CAAC,aAAa,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,QAAQ;QAC5D,6BAAK,SAAS,EAAE,KAAK,CAAC,kBAAkB;YACtC,oBAAC,KAAK,CAAC,SAAS,uBAAK,SAAS,CAAC,SAAS,EAAI;YAC5C,oBAAC,KAAK,CAAC,KAAK,uBAAK,SAAS,CAAC,KAAK,EAAI,CAChC;QACL,KAAK,CAAC,aAAa,KAAK,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,QAAQ,CAChD,CACd,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,cAAc,kBAazB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { CheckboxProps,
|
|
2
|
+
import { CheckboxProps, CheckboxSlots, CheckboxState } from './Checkbox.types';
|
|
3
3
|
/**
|
|
4
|
-
* Array of all shorthand properties listed
|
|
4
|
+
* Array of all shorthand properties listed as the keys of CheckboxSlots
|
|
5
5
|
*/
|
|
6
|
-
export declare const checkboxShorthandProps:
|
|
6
|
+
export declare const checkboxShorthandProps: Array<keyof CheckboxSlots>;
|
|
7
7
|
/**
|
|
8
8
|
* Create the state required to render Checkbox.
|
|
9
9
|
*
|
|
@@ -12,6 +12,5 @@ export declare const checkboxShorthandProps: CheckboxShorthandProps[];
|
|
|
12
12
|
*
|
|
13
13
|
* @param props - props from this instance of Checkbox
|
|
14
14
|
* @param ref - reference to root HTMLElement of Checkbox
|
|
15
|
-
* @param defaultProps - (optional) default prop values provided by the implementing type
|
|
16
15
|
*/
|
|
17
|
-
export declare const useCheckbox: (props: CheckboxProps, ref: React.Ref<HTMLElement
|
|
16
|
+
export declare const useCheckbox: (props: CheckboxProps, ref: React.Ref<HTMLElement>) => CheckboxState;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useCheckbox = exports.checkboxShorthandProps = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var React = require("react");
|
|
4
6
|
var react_utilities_1 = require("@fluentui/react-utilities");
|
|
7
|
+
var DefaultIcons_1 = require("./DefaultIcons");
|
|
8
|
+
var react_label_1 = require("@fluentui/react-label");
|
|
5
9
|
/**
|
|
6
|
-
* Array of all shorthand properties listed
|
|
10
|
+
* Array of all shorthand properties listed as the keys of CheckboxSlots
|
|
7
11
|
*/
|
|
8
|
-
exports.checkboxShorthandProps = [
|
|
9
|
-
/* TODO add shorthand property names */
|
|
10
|
-
];
|
|
11
|
-
var mergeProps = react_utilities_1.makeMergeProps({ deepMerge: exports.checkboxShorthandProps });
|
|
12
|
+
exports.checkboxShorthandProps = ['root', 'indicator', 'input'];
|
|
12
13
|
/**
|
|
13
14
|
* Create the state required to render Checkbox.
|
|
14
15
|
*
|
|
@@ -17,12 +18,66 @@ var mergeProps = react_utilities_1.makeMergeProps({ deepMerge: exports.checkboxS
|
|
|
17
18
|
*
|
|
18
19
|
* @param props - props from this instance of Checkbox
|
|
19
20
|
* @param ref - reference to root HTMLElement of Checkbox
|
|
20
|
-
* @param defaultProps - (optional) default prop values provided by the implementing type
|
|
21
21
|
*/
|
|
22
|
-
var useCheckbox = function (props, ref
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
var useCheckbox = function (props, ref) {
|
|
23
|
+
var _a = props.disabled, disabled = _a === void 0 ? false : _a, _b = props.circular, circular = _b === void 0 ? false : _b, _c = props.required, required = _c === void 0 ? false : _c, id = props.id, rootId = props.rootId, userOnChange = props.onChange;
|
|
24
|
+
var _d = react_utilities_1.useControllableState({
|
|
25
|
+
defaultState: props.defaultChecked,
|
|
26
|
+
state: props.checked,
|
|
27
|
+
initialState: false,
|
|
28
|
+
}), checked = _d[0], setChecked = _d[1];
|
|
29
|
+
var inputInternalRef = React.useRef(null);
|
|
30
|
+
var inputShorthand = react_utilities_1.resolveShorthand(props.input, {
|
|
31
|
+
required: true,
|
|
32
|
+
defaultProps: {
|
|
33
|
+
disabled: disabled,
|
|
34
|
+
type: 'checkbox',
|
|
35
|
+
required: required,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
var state = {
|
|
39
|
+
circular: circular,
|
|
40
|
+
checked: checked,
|
|
41
|
+
size: 'medium',
|
|
42
|
+
labelPosition: 'after',
|
|
43
|
+
rootId: rootId,
|
|
44
|
+
components: {
|
|
45
|
+
root: props.children !== undefined ? react_label_1.Label : 'span',
|
|
46
|
+
indicator: 'div',
|
|
47
|
+
input: 'input',
|
|
48
|
+
},
|
|
49
|
+
input: tslib_1.__assign(tslib_1.__assign({}, inputShorthand), { ref: react_utilities_1.useMergedRefs(inputShorthand.ref, inputInternalRef) }),
|
|
50
|
+
indicator: react_utilities_1.resolveShorthand(props.indicator, {
|
|
51
|
+
required: true,
|
|
52
|
+
}),
|
|
53
|
+
root: react_utilities_1.getNativeElementProps('div', tslib_1.__assign({ ref: ref }, props)),
|
|
54
|
+
};
|
|
55
|
+
state.input.checked = checked === true;
|
|
56
|
+
state.checked = checked ? checked : false;
|
|
57
|
+
if (state.indicator && !state.indicator.children) {
|
|
58
|
+
if (state.size === 'medium') {
|
|
59
|
+
state.indicator.children = checked === 'mixed' ? React.createElement(DefaultIcons_1.Mixed12Regular, null) : React.createElement(DefaultIcons_1.Checkmark12Regular, null);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
state.indicator.children = checked === 'mixed' ? React.createElement(DefaultIcons_1.Mixed16Regular, null) : React.createElement(DefaultIcons_1.Checkmark16Regular, null);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
var inputOnChange = state.input.onChange;
|
|
66
|
+
state.input.onChange = react_utilities_1.useEventCallback(function (ev) {
|
|
67
|
+
ev.stopPropagation();
|
|
68
|
+
inputOnChange === null || inputOnChange === void 0 ? void 0 : inputOnChange(ev);
|
|
69
|
+
var val = ev.currentTarget.indeterminate ? 'mixed' : ev.currentTarget.checked;
|
|
70
|
+
userOnChange === null || userOnChange === void 0 ? void 0 : userOnChange(ev, { checked: val });
|
|
71
|
+
setChecked(val);
|
|
72
|
+
});
|
|
73
|
+
state.input.id = react_utilities_1.useId('checkbox-', id);
|
|
74
|
+
state.root.id = state.rootId;
|
|
75
|
+
var isMixed = checked === 'mixed';
|
|
76
|
+
react_utilities_1.useIsomorphicLayoutEffect(function () {
|
|
77
|
+
if (inputInternalRef.current) {
|
|
78
|
+
inputInternalRef.current.indeterminate = isMixed;
|
|
79
|
+
}
|
|
80
|
+
}, [isMixed]);
|
|
26
81
|
return state;
|
|
27
82
|
};
|
|
28
83
|
exports.useCheckbox = useCheckbox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCheckbox.js","sourceRoot":"
|
|
1
|
+
{"version":3,"file":"useCheckbox.js","sourceRoot":"","sources":["../../../src/components/Checkbox/useCheckbox.tsx"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAC/B,6DAQmC;AAEnC,+CAAwG;AACxG,qDAA0D;AAE1D;;GAEG;AACU,QAAA,sBAAsB,GAA+B,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAEjG;;;;;;;;GAQG;AACI,IAAM,WAAW,GAAG,UAAC,KAAoB,EAAE,GAA2B;IACnE,IAAA,KAA6F,KAAK,SAAlF,EAAhB,QAAQ,mBAAG,KAAK,KAAA,EAAE,KAA2E,KAAK,SAAhE,EAAhB,QAAQ,mBAAG,KAAK,KAAA,EAAE,KAAyD,KAAK,SAA9C,EAAhB,QAAQ,mBAAG,KAAK,KAAA,EAAE,EAAE,GAAqC,KAAK,GAA1C,EAAE,MAAM,GAA6B,KAAK,OAAlC,EAAY,YAAY,GAAK,KAAK,SAAV,CAAW;IACrG,IAAA,KAAwB,sCAAoB,CAAC;QACjD,YAAY,EAAE,KAAK,CAAC,cAAc;QAClC,KAAK,EAAE,KAAK,CAAC,OAAO;QACpB,YAAY,EAAE,KAAK;KACpB,CAAC,EAJK,OAAO,QAAA,EAAE,UAAU,QAIxB,CAAC;IAEH,IAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,CAAmB,IAAI,CAAC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