@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
package/dist/react-checkbox.d.ts
CHANGED
|
@@ -1,46 +1,107 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ComponentProps } from '@fluentui/react-utilities';
|
|
2
|
+
import { ComponentState } from '@fluentui/react-utilities';
|
|
3
|
+
import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
|
4
|
+
import { IntrinsicShorthandProps } from '@fluentui/react-utilities';
|
|
5
|
+
import { LabelProps } from '@fluentui/react-label';
|
|
6
|
+
import { ObjectShorthandProps } from '@fluentui/react-utilities';
|
|
3
7
|
import * as React_2 from 'react';
|
|
4
8
|
|
|
5
9
|
/**
|
|
6
10
|
* A Checkbox component provides a way to represent options that can be selected
|
|
7
11
|
*/
|
|
8
|
-
export declare const Checkbox:
|
|
12
|
+
export declare const Checkbox: ForwardRefComponent<CheckboxProps>;
|
|
9
13
|
|
|
10
14
|
/**
|
|
11
|
-
*
|
|
15
|
+
* TODO:
|
|
16
|
+
* - Remove as from Omit. Currently it's needed since checkbox Commons shouldn't have as.
|
|
17
|
+
* - Instead of extending LabelProps, extend LabelCommons once it's added.
|
|
12
18
|
*/
|
|
13
|
-
export declare
|
|
19
|
+
export declare interface CheckboxCommons {
|
|
20
|
+
/**
|
|
21
|
+
* A checkbox can be rendered with a circular shape.
|
|
22
|
+
*/
|
|
23
|
+
circular: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* ID of the root element that wraps the checkbox and label.
|
|
26
|
+
*/
|
|
27
|
+
rootId: string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* A checkbox's state can be controlled.
|
|
30
|
+
* @defaultvalue false
|
|
31
|
+
*/
|
|
32
|
+
checked: 'mixed' | boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Checkbox supports two different checkbox sizes.
|
|
35
|
+
* @defaultvalue 'medium'
|
|
36
|
+
*/
|
|
37
|
+
size: 'medium' | 'large';
|
|
38
|
+
/**
|
|
39
|
+
* Determines whether the label should be positioned before or after the checkbox.
|
|
40
|
+
* @defaultvalue 'after'
|
|
41
|
+
*/
|
|
42
|
+
labelPosition: 'before' | 'after';
|
|
43
|
+
/**
|
|
44
|
+
* Field required to pass className to container instead of input
|
|
45
|
+
* this will be solved by https://github.com/microsoft/fluentui/pull/18983
|
|
46
|
+
*/
|
|
47
|
+
containerClassName?: string;
|
|
48
|
+
}
|
|
14
49
|
|
|
15
50
|
/**
|
|
16
|
-
*
|
|
51
|
+
* Data for the onChange event for checkbox.
|
|
17
52
|
*/
|
|
18
|
-
export declare interface
|
|
53
|
+
export declare interface CheckboxOnChangeData {
|
|
54
|
+
checked: 'mixed' | boolean;
|
|
19
55
|
}
|
|
20
56
|
|
|
21
57
|
/**
|
|
22
|
-
*
|
|
58
|
+
* Checkbox Props
|
|
23
59
|
*/
|
|
24
|
-
export declare type
|
|
60
|
+
export declare type CheckboxProps = Omit<ComponentProps<CheckboxSlots>, 'defaultChecked'> & Partial<CheckboxCommons> & {
|
|
61
|
+
/**
|
|
62
|
+
* ID of the native element that represents the checkbox.
|
|
63
|
+
*/
|
|
64
|
+
id?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Callback to be called when the checked state value changes.
|
|
67
|
+
*/
|
|
68
|
+
onChange?: (ev: React_2.FormEvent<HTMLInputElement>, data: CheckboxOnChangeData) => void;
|
|
69
|
+
/**
|
|
70
|
+
* Whether the checkbox should be rendered as checked by default.
|
|
71
|
+
*/
|
|
72
|
+
defaultChecked?: 'mixed' | boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Required state of the checkbox.
|
|
75
|
+
*/
|
|
76
|
+
required?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Disabled
|
|
79
|
+
*/
|
|
80
|
+
disabled?: boolean;
|
|
81
|
+
};
|
|
25
82
|
|
|
26
83
|
/**
|
|
27
|
-
* Array of all shorthand properties listed
|
|
84
|
+
* Array of all shorthand properties listed as the keys of CheckboxSlots
|
|
28
85
|
*/
|
|
29
|
-
export declare const checkboxShorthandProps:
|
|
86
|
+
export declare const checkboxShorthandProps: Array<keyof CheckboxSlots>;
|
|
30
87
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*/
|
|
34
|
-
export declare interface CheckboxState extends ComponentStateCompat<CheckboxProps, CheckboxShorthandProps, CheckboxDefaultedProps> {
|
|
88
|
+
export declare type CheckboxSlots = {
|
|
89
|
+
root: ObjectShorthandProps<LabelProps> | IntrinsicShorthandProps<'span'>;
|
|
35
90
|
/**
|
|
36
|
-
*
|
|
91
|
+
* Hidden input that handles the checkbox's functionality.
|
|
37
92
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
93
|
+
input: IntrinsicShorthandProps<'input'>;
|
|
94
|
+
/**
|
|
95
|
+
* Renders the checkbox, with the checkmark icon as its child when checked.
|
|
96
|
+
*/
|
|
97
|
+
indicator: IntrinsicShorthandProps<'div'>;
|
|
98
|
+
};
|
|
40
99
|
|
|
41
100
|
/**
|
|
42
|
-
*
|
|
101
|
+
* State used in rendering Checkbox
|
|
43
102
|
*/
|
|
103
|
+
export declare type CheckboxState = ComponentState<CheckboxSlots> & CheckboxCommons;
|
|
104
|
+
|
|
44
105
|
export declare const renderCheckbox: (state: CheckboxState) => JSX.Element;
|
|
45
106
|
|
|
46
107
|
/**
|
|
@@ -51,9 +112,8 @@ export declare const renderCheckbox: (state: CheckboxState) => JSX.Element;
|
|
|
51
112
|
*
|
|
52
113
|
* @param props - props from this instance of Checkbox
|
|
53
114
|
* @param ref - reference to root HTMLElement of Checkbox
|
|
54
|
-
* @param defaultProps - (optional) default prop values provided by the implementing type
|
|
55
115
|
*/
|
|
56
|
-
export declare const useCheckbox: (props: CheckboxProps, ref: React_2.Ref<HTMLElement
|
|
116
|
+
export declare const useCheckbox: (props: CheckboxProps, ref: React_2.Ref<HTMLElement>) => CheckboxState;
|
|
57
117
|
|
|
58
118
|
/**
|
|
59
119
|
* Apply styling to the Checkbox slots based on the state
|
package/lib/Checkbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sourceRoot":"
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../src/Checkbox.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { isConformant as baseIsConformant } from '@fluentui/react-conformance';
|
|
2
|
+
import makeStylesTests from '@fluentui/react-conformance-make-styles';
|
|
2
3
|
export function isConformant(testInfo) {
|
|
3
4
|
var defaultOptions = {
|
|
4
5
|
asPropHandlesRef: true,
|
|
5
6
|
componentPath: module.parent.filename.replace('.test', ''),
|
|
7
|
+
extraTests: makeStylesTests,
|
|
8
|
+
skipAsPropTests: true,
|
|
6
9
|
};
|
|
7
10
|
baseIsConformant(defaultOptions, testInfo);
|
|
8
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isConformant.js","sourceRoot":"
|
|
1
|
+
{"version":3,"file":"isConformant.js","sourceRoot":"","sources":["../../src/common/isConformant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAmC,MAAM,6BAA6B,CAAC;AAChH,OAAO,eAAe,MAAM,yCAAyC,CAAC;AAEtE,MAAM,UAAU,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,eAAqC;QACjD,eAAe,EAAE,IAAI;KACtB,CAAC;IAEF,gBAAgB,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -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,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAIxD;;GAEG;AACH,MAAM,CAAC,IAAM,QAAQ,GAAuC,KAAK,CAAC,UAAU,CAAC,UAAC,KAAK,EAAE,GAAG;IACtF,IAAM,KAAK,GAAG,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAEtC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACzB,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC;AAEH,QAAQ,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,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export 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" },
|
|
3
|
+
React.createElement("rect", { width: "8", height: "8", x: "2", y: "2" }))); };
|
|
4
|
+
export 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" },
|
|
5
|
+
React.createElement("rect", { width: "10", height: "10", x: "3", y: "3" }))); };
|
|
6
|
+
export var Checkmark12Regular = function () { return (React.createElement("svg", { width: "12", height: "12", viewBox: "0 0 12 12", xmlns: "http://www.w3.org/2000/svg" },
|
|
7
|
+
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" }))); };
|
|
8
|
+
export var Checkmark16Regular = function () { return (React.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", xmlns: "http://www.w3.org/2000/svg" },
|
|
9
|
+
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" }))); };
|
|
10
|
+
//# sourceMappingURL=DefaultIcons.js.map
|
|
@@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,CAIvC,CAAC"}
|
|
@@ -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,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { getSlots } from '@fluentui/react-utilities';
|
|
4
4
|
import { checkboxShorthandProps } from './useCheckbox';
|
|
5
|
-
/**
|
|
6
|
-
* Render the final JSX of Checkbox
|
|
7
|
-
*/
|
|
8
5
|
export var renderCheckbox = function (state) {
|
|
9
|
-
var _a =
|
|
10
|
-
return (React.createElement(slots.root, __assign({}, slotProps.root),
|
|
6
|
+
var _a = getSlots(state, checkboxShorthandProps), slots = _a.slots, slotProps = _a.slotProps;
|
|
7
|
+
return (React.createElement(slots.root, __assign({}, slotProps.root),
|
|
8
|
+
state.labelPosition === 'before' && slotProps.root.children,
|
|
9
|
+
React.createElement("div", { className: state.containerClassName },
|
|
10
|
+
React.createElement(slots.indicator, __assign({}, slotProps.indicator)),
|
|
11
|
+
React.createElement(slots.input, __assign({}, slotProps.input))),
|
|
12
|
+
state.labelPosition === 'after' && slotProps.root.children));
|
|
11
13
|
};
|
|
12
14
|
//# 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,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEvD,MAAM,CAAC,IAAM,cAAc,GAAG,UAAC,KAAoB;IAC3C,IAAA,KAAuB,QAAQ,CAAgB,KAAK,EAAE,sBAAsB,CAAC,EAA3E,KAAK,WAAA,EAAE,SAAS,eAA2D,CAAC;IAEpF,OAAO,CACL,oBAAC,KAAK,CAAC,IAAI,eAAK,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,eAAK,SAAS,CAAC,SAAS,EAAI;YAC5C,oBAAC,KAAK,CAAC,KAAK,eAAK,SAAS,CAAC,KAAK,EAAI,CAChC;QACL,KAAK,CAAC,aAAa,KAAK,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,QAAQ,CAChD,CACd,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -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,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { getNativeElementProps, resolveShorthand, useControllableState, useId, useIsomorphicLayoutEffect, useMergedRefs, useEventCallback, } from '@fluentui/react-utilities';
|
|
4
|
+
import { Mixed12Regular, Mixed16Regular, Checkmark12Regular, Checkmark16Regular } from './DefaultIcons';
|
|
5
|
+
import { Label } from '@fluentui/react-label';
|
|
2
6
|
/**
|
|
3
|
-
* Array of all shorthand properties listed
|
|
7
|
+
* Array of all shorthand properties listed as the keys of CheckboxSlots
|
|
4
8
|
*/
|
|
5
|
-
export var checkboxShorthandProps = [
|
|
6
|
-
/* TODO add shorthand property names */
|
|
7
|
-
];
|
|
8
|
-
var mergeProps = makeMergeProps({ deepMerge: checkboxShorthandProps });
|
|
9
|
+
export var checkboxShorthandProps = ['root', 'indicator', 'input'];
|
|
9
10
|
/**
|
|
10
11
|
* Create the state required to render Checkbox.
|
|
11
12
|
*
|
|
@@ -14,12 +15,66 @@ var mergeProps = makeMergeProps({ deepMerge: checkboxShorthandProps });
|
|
|
14
15
|
*
|
|
15
16
|
* @param props - props from this instance of Checkbox
|
|
16
17
|
* @param ref - reference to root HTMLElement of Checkbox
|
|
17
|
-
* @param defaultProps - (optional) default prop values provided by the implementing type
|
|
18
18
|
*/
|
|
19
|
-
export var useCheckbox = function (props, ref
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
export var useCheckbox = function (props, ref) {
|
|
20
|
+
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;
|
|
21
|
+
var _d = useControllableState({
|
|
22
|
+
defaultState: props.defaultChecked,
|
|
23
|
+
state: props.checked,
|
|
24
|
+
initialState: false,
|
|
25
|
+
}), checked = _d[0], setChecked = _d[1];
|
|
26
|
+
var inputInternalRef = React.useRef(null);
|
|
27
|
+
var inputShorthand = resolveShorthand(props.input, {
|
|
28
|
+
required: true,
|
|
29
|
+
defaultProps: {
|
|
30
|
+
disabled: disabled,
|
|
31
|
+
type: 'checkbox',
|
|
32
|
+
required: required,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
var state = {
|
|
36
|
+
circular: circular,
|
|
37
|
+
checked: checked,
|
|
38
|
+
size: 'medium',
|
|
39
|
+
labelPosition: 'after',
|
|
40
|
+
rootId: rootId,
|
|
41
|
+
components: {
|
|
42
|
+
root: props.children !== undefined ? Label : 'span',
|
|
43
|
+
indicator: 'div',
|
|
44
|
+
input: 'input',
|
|
45
|
+
},
|
|
46
|
+
input: __assign(__assign({}, inputShorthand), { ref: useMergedRefs(inputShorthand.ref, inputInternalRef) }),
|
|
47
|
+
indicator: resolveShorthand(props.indicator, {
|
|
48
|
+
required: true,
|
|
49
|
+
}),
|
|
50
|
+
root: getNativeElementProps('div', __assign({ ref: ref }, props)),
|
|
51
|
+
};
|
|
52
|
+
state.input.checked = checked === true;
|
|
53
|
+
state.checked = checked ? checked : false;
|
|
54
|
+
if (state.indicator && !state.indicator.children) {
|
|
55
|
+
if (state.size === 'medium') {
|
|
56
|
+
state.indicator.children = checked === 'mixed' ? React.createElement(Mixed12Regular, null) : React.createElement(Checkmark12Regular, null);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
state.indicator.children = checked === 'mixed' ? React.createElement(Mixed16Regular, null) : React.createElement(Checkmark16Regular, null);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
var inputOnChange = state.input.onChange;
|
|
63
|
+
state.input.onChange = useEventCallback(function (ev) {
|
|
64
|
+
ev.stopPropagation();
|
|
65
|
+
inputOnChange === null || inputOnChange === void 0 ? void 0 : inputOnChange(ev);
|
|
66
|
+
var val = ev.currentTarget.indeterminate ? 'mixed' : ev.currentTarget.checked;
|
|
67
|
+
userOnChange === null || userOnChange === void 0 ? void 0 : userOnChange(ev, { checked: val });
|
|
68
|
+
setChecked(val);
|
|
69
|
+
});
|
|
70
|
+
state.input.id = useId('checkbox-', id);
|
|
71
|
+
state.root.id = state.rootId;
|
|
72
|
+
var isMixed = checked === 'mixed';
|
|
73
|
+
useIsomorphicLayoutEffect(function () {
|
|
74
|
+
if (inputInternalRef.current) {
|
|
75
|
+
inputInternalRef.current.indeterminate = isMixed;
|
|
76
|
+
}
|
|
77
|
+
}, [isMixed]);
|
|
23
78
|
return state;
|
|
24
79
|
};
|
|
25
80
|
//# sourceMappingURL=useCheckbox.js.map
|
|
@@ -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,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,EACL,yBAAyB,EACzB,aAAa,EACb,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACxG,OAAO,EAAE,KAAK,EAAc,MAAM,uBAAuB,CAAC;AAE1D;;GAEG;AACH,MAAM,CAAC,IAAM,sBAAsB,GAA+B,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAEjG;;;;;;;;GAQG;AACH,MAAM,CAAC,IAAM,WAAW,GAAG,UAAC,KAAoB,EAAE,GAA2B;IACnE,IAAA,KAA6F,KAAK,SAAlF,EAAhB,QAAQ,mBAAG,KAAK,KAAA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