@fluentui/react-checkbox 9.0.0-beta.5 → 9.0.0-beta.9

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.
Files changed (55) hide show
  1. package/CHANGELOG.json +240 -7
  2. package/CHANGELOG.md +62 -8
  3. package/Spec.md +25 -115
  4. package/dist/react-checkbox.d.ts +40 -31
  5. package/lib/Checkbox.js.map +1 -1
  6. package/lib/components/Checkbox/Checkbox.d.ts +2 -1
  7. package/lib/components/Checkbox/Checkbox.js +10 -8
  8. package/lib/components/Checkbox/Checkbox.js.map +1 -1
  9. package/lib/components/Checkbox/Checkbox.types.d.ts +34 -24
  10. package/lib/components/Checkbox/Checkbox.types.js.map +1 -1
  11. package/lib/components/Checkbox/index.js.map +1 -1
  12. package/lib/components/Checkbox/renderCheckbox.d.ts +1 -1
  13. package/lib/components/Checkbox/renderCheckbox.js +11 -8
  14. package/lib/components/Checkbox/renderCheckbox.js.map +1 -1
  15. package/lib/components/Checkbox/useCheckbox.d.ts +3 -3
  16. package/lib/components/Checkbox/useCheckbox.js +98 -75
  17. package/lib/components/Checkbox/useCheckbox.js.map +1 -1
  18. package/lib/components/Checkbox/useCheckboxStyles.d.ts +1 -1
  19. package/lib/components/Checkbox/useCheckboxStyles.js +199 -160
  20. package/lib/components/Checkbox/useCheckboxStyles.js.map +1 -1
  21. package/lib/index.js.map +1 -1
  22. package/lib-commonjs/Checkbox.js +7 -2
  23. package/lib-commonjs/Checkbox.js.map +1 -1
  24. package/lib-commonjs/components/Checkbox/Checkbox.d.ts +2 -1
  25. package/lib-commonjs/components/Checkbox/Checkbox.js +20 -10
  26. package/lib-commonjs/components/Checkbox/Checkbox.js.map +1 -1
  27. package/lib-commonjs/components/Checkbox/Checkbox.types.d.ts +34 -24
  28. package/lib-commonjs/components/Checkbox/Checkbox.types.js +4 -1
  29. package/lib-commonjs/components/Checkbox/Checkbox.types.js.map +1 -1
  30. package/lib-commonjs/components/Checkbox/index.js +11 -2
  31. package/lib-commonjs/components/Checkbox/index.js.map +1 -1
  32. package/lib-commonjs/components/Checkbox/renderCheckbox.d.ts +1 -1
  33. package/lib-commonjs/components/Checkbox/renderCheckbox.js +23 -13
  34. package/lib-commonjs/components/Checkbox/renderCheckbox.js.map +1 -1
  35. package/lib-commonjs/components/Checkbox/useCheckbox.d.ts +3 -3
  36. package/lib-commonjs/components/Checkbox/useCheckbox.js +112 -80
  37. package/lib-commonjs/components/Checkbox/useCheckbox.js.map +1 -1
  38. package/lib-commonjs/components/Checkbox/useCheckboxStyles.d.ts +1 -1
  39. package/lib-commonjs/components/Checkbox/useCheckboxStyles.js +211 -164
  40. package/lib-commonjs/components/Checkbox/useCheckboxStyles.js.map +1 -1
  41. package/lib-commonjs/index.js +7 -2
  42. package/lib-commonjs/index.js.map +1 -1
  43. package/package.json +12 -10
  44. package/lib/common/isConformant.d.ts +0 -4
  45. package/lib/common/isConformant.js +0 -12
  46. package/lib/common/isConformant.js.map +0 -1
  47. package/lib/components/Checkbox/DefaultIcons.d.ts +0 -4
  48. package/lib/components/Checkbox/DefaultIcons.js +0 -10
  49. package/lib/components/Checkbox/DefaultIcons.js.map +0 -1
  50. package/lib-commonjs/common/isConformant.d.ts +0 -4
  51. package/lib-commonjs/common/isConformant.js +0 -16
  52. package/lib-commonjs/common/isConformant.js.map +0 -1
  53. package/lib-commonjs/components/Checkbox/DefaultIcons.d.ts +0 -4
  54. package/lib-commonjs/components/Checkbox/DefaultIcons.js +0 -17
  55. package/lib-commonjs/components/Checkbox/DefaultIcons.js.map +0 -1
@@ -1,43 +1,46 @@
1
1
  import { ComponentProps } from '@fluentui/react-utilities';
2
2
  import { ComponentState } from '@fluentui/react-utilities';
3
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';
4
+ import { Label } from '@fluentui/react-label';
7
5
  import * as React_2 from 'react';
6
+ import { Slot } from '@fluentui/react-utilities';
8
7
 
9
8
  /**
10
- * A Checkbox component provides a way to represent options that can be selected
9
+ * Checkboxes give people a way to select one or more items from a group,
10
+ * or switch between two mutually exclusive options (checked or unchecked).
11
11
  */
12
12
  export declare const Checkbox: ForwardRefComponent<CheckboxProps>;
13
13
 
14
14
  export declare const checkboxClassName = "fui-Checkbox";
15
15
 
16
- export declare interface CheckboxCommons {
16
+ declare interface CheckboxCommons {
17
17
  /**
18
- * A checkbox can be rendered with a circular shape.
18
+ * The shape of the checkbox indicator.
19
+ *
20
+ * The `circular` variant is only recommended to be used in a tasks-style UI (checklist),
21
+ * since it otherwise could be confused for a `RadioItem`.
22
+ *
23
+ * @defaultvalue square
19
24
  */
20
- circular: boolean | undefined;
25
+ shape: 'square' | 'circular';
21
26
  /**
22
- * A checkbox's state can be controlled.
27
+ * The controlled value for the checkbox.
28
+ *
23
29
  * @defaultvalue false
24
30
  */
25
31
  checked: 'mixed' | boolean;
26
32
  /**
27
- * Checkbox supports two different checkbox sizes.
28
- * @defaultvalue 'medium'
33
+ * The size of the checkbox indicator.
34
+ *
35
+ * @defaultvalue medium
29
36
  */
30
37
  size: 'medium' | 'large';
31
38
  /**
32
- * Determines whether the label should be positioned before or after the checkbox.
33
- * @defaultvalue 'after'
39
+ * The position of the label relative to the checkbox indicator.
40
+ *
41
+ * @defaultvalue after
34
42
  */
35
43
  labelPosition: 'before' | 'after';
36
- /**
37
- * Field required to pass className to container instead of input
38
- * this will be solved by https://github.com/microsoft/fluentui/pull/18983
39
- */
40
- containerClassName?: string;
41
44
  }
42
45
 
43
46
  /**
@@ -50,7 +53,11 @@ export declare interface CheckboxOnChangeData {
50
53
  /**
51
54
  * Checkbox Props
52
55
  */
53
- export declare type CheckboxProps = Omit<ComponentProps<CheckboxSlots, 'input'>, 'size' | 'checked' | 'defaultChecked'> & Partial<CheckboxCommons> & {
56
+ export declare type CheckboxProps = Omit<ComponentProps<Partial<CheckboxSlots>, 'input'>, 'size' | 'checked' | 'defaultChecked' | 'onChange'> & Partial<CheckboxCommons> & {
57
+ /**
58
+ * Checkboxes don't support children. To add a label, use the `label` prop.
59
+ */
60
+ children?: never;
54
61
  /**
55
62
  * Callback to be called when the checked state value changes.
56
63
  */
@@ -63,48 +70,50 @@ export declare type CheckboxProps = Omit<ComponentProps<CheckboxSlots, 'input'>,
63
70
 
64
71
  export declare type CheckboxSlots = {
65
72
  /**
66
- * The root element of the checkbox is its `<label>`.
73
+ * The root element of the Checkbox.
67
74
  *
68
75
  * The root slot receives the `className` and `style` specified directly on the `<Checkbox>`.
69
76
  * All other native props will be applied to the primary slot: `input`
70
77
  */
71
- root: ObjectShorthandProps<LabelProps> | IntrinsicShorthandProps<'span'>;
78
+ root: NonNullable<Slot<'span'>>;
79
+ /**
80
+ * The Checkbox's label.
81
+ */
82
+ label?: Slot<typeof Label>;
72
83
  /**
73
84
  * Hidden input that handles the checkbox's functionality.
74
85
  *
75
86
  * This is the PRIMARY slot: all native properties specified directly on `<Checkbox>` will be applied to this slot,
76
87
  * except `className` and `style`, which remain on the root slot.
77
88
  */
78
- input: IntrinsicShorthandProps<'input'>;
89
+ input: NonNullable<Slot<'input'>>;
79
90
  /**
80
- * Renders the checkbox, with the checkmark icon as its child when checked.
91
+ * The checkbox, with the checkmark icon as its child when checked.
81
92
  */
82
- indicator: IntrinsicShorthandProps<'div'>;
93
+ indicator: Slot<'div'>;
83
94
  };
84
95
 
85
96
  /**
86
97
  * State used in rendering Checkbox
87
98
  */
88
- export declare type CheckboxState = ComponentState<CheckboxSlots> & CheckboxCommons & {
89
- hasLabel: boolean;
90
- };
99
+ export declare type CheckboxState = ComponentState<CheckboxSlots> & CheckboxCommons;
91
100
 
92
- export declare const renderCheckbox: (state: CheckboxState) => JSX.Element;
101
+ export declare const renderCheckbox_unstable: (state: CheckboxState) => JSX.Element;
93
102
 
94
103
  /**
95
104
  * Create the state required to render Checkbox.
96
105
  *
97
- * The returned state can be modified with hooks such as useCheckboxStyles,
98
- * before being passed to renderCheckbox.
106
+ * The returned state can be modified with hooks such as useCheckboxStyles_unstable,
107
+ * before being passed to renderCheckbox_unstable.
99
108
  *
100
109
  * @param props - props from this instance of Checkbox
101
110
  * @param ref - reference to `<input>` element of Checkbox
102
111
  */
103
- export declare const useCheckbox: (props: CheckboxProps, ref: React_2.Ref<HTMLInputElement>) => CheckboxState;
112
+ export declare const useCheckbox_unstable: (props: CheckboxProps, ref: React_2.Ref<HTMLInputElement>) => CheckboxState;
104
113
 
105
114
  /**
106
115
  * Apply styling to the Checkbox slots based on the state
107
116
  */
108
- export declare const useCheckboxStyles: (state: CheckboxState) => CheckboxState;
117
+ export declare const useCheckboxStyles_unstable: (state: CheckboxState) => CheckboxState;
109
118
 
110
119
  export { }
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../src/Checkbox.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"Checkbox.js","sourceRoot":"../src/","sources":["Checkbox.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC","sourcesContent":["export * from './components/Checkbox/index';\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { CheckboxProps } from './Checkbox.types';
2
2
  import type { ForwardRefComponent } from '@fluentui/react-utilities';
3
3
  /**
4
- * A Checkbox component provides a way to represent options that can be selected
4
+ * Checkboxes give people a way to select one or more items from a group,
5
+ * or switch between two mutually exclusive options (checked or unchecked).
5
6
  */
6
7
  export declare const Checkbox: ForwardRefComponent<CheckboxProps>;
@@ -1,14 +1,16 @@
1
1
  import * as React from 'react';
2
- import { useCheckbox } from './useCheckbox';
3
- import { renderCheckbox } from './renderCheckbox';
4
- import { useCheckboxStyles } from './useCheckboxStyles';
2
+ import { useCheckbox_unstable } from './useCheckbox';
3
+ import { renderCheckbox_unstable } from './renderCheckbox';
4
+ import { useCheckboxStyles_unstable } from './useCheckboxStyles';
5
5
  /**
6
- * A Checkbox component provides a way to represent options that can be selected
6
+ * Checkboxes give people a way to select one or more items from a group,
7
+ * or switch between two mutually exclusive options (checked or unchecked).
7
8
  */
8
- export const Checkbox = React.forwardRef((props, ref) => {
9
- const state = useCheckbox(props, ref);
10
- useCheckboxStyles(state);
11
- return renderCheckbox(state);
9
+
10
+ export const Checkbox = /*#__PURE__*/React.forwardRef((props, ref) => {
11
+ const state = useCheckbox_unstable(props, ref);
12
+ useCheckboxStyles_unstable(state);
13
+ return renderCheckbox_unstable(state);
12
14
  });
13
15
  Checkbox.displayName = 'Checkbox';
14
16
  //# sourceMappingURL=Checkbox.js.map
@@ -1 +1 @@
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,MAAM,QAAQ,GAAuC,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IAC1F,MAAM,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
+ {"version":3,"sources":["components/Checkbox/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,oBAAT,QAAqC,eAArC;AACA,SAAS,uBAAT,QAAwC,kBAAxC;AACA,SAAS,0BAAT,QAA2C,qBAA3C;AAIA;;;AAGG;;AACH,OAAO,MAAM,QAAQ,gBAAuC,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;AAC1F,QAAM,KAAK,GAAG,oBAAoB,CAAC,KAAD,EAAQ,GAAR,CAAlC;AAEA,EAAA,0BAA0B,CAAC,KAAD,CAA1B;AACA,SAAO,uBAAuB,CAAC,KAAD,CAA9B;AACD,CAL2D,CAArD;AAOP,QAAQ,CAAC,WAAT,GAAuB,UAAvB","sourcesContent":["import * as React from 'react';\nimport { useCheckbox_unstable } from './useCheckbox';\nimport { renderCheckbox_unstable } from './renderCheckbox';\nimport { useCheckboxStyles_unstable } from './useCheckboxStyles';\nimport type { CheckboxProps } from './Checkbox.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * Checkboxes give people a way to select one or more items from a group,\n * or switch between two mutually exclusive options (checked or unchecked).\n */\nexport const Checkbox: ForwardRefComponent<CheckboxProps> = React.forwardRef((props, ref) => {\n const state = useCheckbox_unstable(props, ref);\n\n useCheckboxStyles_unstable(state);\n return renderCheckbox_unstable(state);\n});\n\nCheckbox.displayName = 'Checkbox';\n"],"sourceRoot":"../src/"}
@@ -1,31 +1,34 @@
1
1
  import * as React from 'react';
2
- import { ComponentProps, ComponentState, IntrinsicShorthandProps, ObjectShorthandProps } from '@fluentui/react-utilities';
3
- import { LabelProps } from '@fluentui/react-label';
4
- export interface CheckboxCommons {
2
+ import { Label } from '@fluentui/react-label';
3
+ import { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';
4
+ interface CheckboxCommons {
5
5
  /**
6
- * A checkbox can be rendered with a circular shape.
6
+ * The shape of the checkbox indicator.
7
+ *
8
+ * The `circular` variant is only recommended to be used in a tasks-style UI (checklist),
9
+ * since it otherwise could be confused for a `RadioItem`.
10
+ *
11
+ * @defaultvalue square
7
12
  */
8
- circular: boolean | undefined;
13
+ shape: 'square' | 'circular';
9
14
  /**
10
- * A checkbox's state can be controlled.
15
+ * The controlled value for the checkbox.
16
+ *
11
17
  * @defaultvalue false
12
18
  */
13
19
  checked: 'mixed' | boolean;
14
20
  /**
15
- * Checkbox supports two different checkbox sizes.
16
- * @defaultvalue 'medium'
21
+ * The size of the checkbox indicator.
22
+ *
23
+ * @defaultvalue medium
17
24
  */
18
25
  size: 'medium' | 'large';
19
26
  /**
20
- * Determines whether the label should be positioned before or after the checkbox.
21
- * @defaultvalue 'after'
27
+ * The position of the label relative to the checkbox indicator.
28
+ *
29
+ * @defaultvalue after
22
30
  */
23
31
  labelPosition: 'before' | 'after';
24
- /**
25
- * Field required to pass className to container instead of input
26
- * this will be solved by https://github.com/microsoft/fluentui/pull/18983
27
- */
28
- containerClassName?: string;
29
32
  }
30
33
  /**
31
34
  * Data for the onChange event for checkbox.
@@ -35,28 +38,36 @@ export interface CheckboxOnChangeData {
35
38
  }
36
39
  export declare type CheckboxSlots = {
37
40
  /**
38
- * The root element of the checkbox is its `<label>`.
41
+ * The root element of the Checkbox.
39
42
  *
40
43
  * The root slot receives the `className` and `style` specified directly on the `<Checkbox>`.
41
44
  * All other native props will be applied to the primary slot: `input`
42
45
  */
43
- root: ObjectShorthandProps<LabelProps> | IntrinsicShorthandProps<'span'>;
46
+ root: NonNullable<Slot<'span'>>;
47
+ /**
48
+ * The Checkbox's label.
49
+ */
50
+ label?: Slot<typeof Label>;
44
51
  /**
45
52
  * Hidden input that handles the checkbox's functionality.
46
53
  *
47
54
  * This is the PRIMARY slot: all native properties specified directly on `<Checkbox>` will be applied to this slot,
48
55
  * except `className` and `style`, which remain on the root slot.
49
56
  */
50
- input: IntrinsicShorthandProps<'input'>;
57
+ input: NonNullable<Slot<'input'>>;
51
58
  /**
52
- * Renders the checkbox, with the checkmark icon as its child when checked.
59
+ * The checkbox, with the checkmark icon as its child when checked.
53
60
  */
54
- indicator: IntrinsicShorthandProps<'div'>;
61
+ indicator: Slot<'div'>;
55
62
  };
56
63
  /**
57
64
  * Checkbox Props
58
65
  */
59
- export declare type CheckboxProps = Omit<ComponentProps<CheckboxSlots, 'input'>, 'size' | 'checked' | 'defaultChecked'> & Partial<CheckboxCommons> & {
66
+ export declare type CheckboxProps = Omit<ComponentProps<Partial<CheckboxSlots>, 'input'>, 'size' | 'checked' | 'defaultChecked' | 'onChange'> & Partial<CheckboxCommons> & {
67
+ /**
68
+ * Checkboxes don't support children. To add a label, use the `label` prop.
69
+ */
70
+ children?: never;
60
71
  /**
61
72
  * Callback to be called when the checked state value changes.
62
73
  */
@@ -69,6 +80,5 @@ export declare type CheckboxProps = Omit<ComponentProps<CheckboxSlots, 'input'>,
69
80
  /**
70
81
  * State used in rendering Checkbox
71
82
  */
72
- export declare type CheckboxState = ComponentState<CheckboxSlots> & CheckboxCommons & {
73
- hasLabel: boolean;
74
- };
83
+ export declare type CheckboxState = ComponentState<CheckboxSlots> & CheckboxCommons;
84
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.types.js","sourceRoot":"","sources":["../../../src/components/Checkbox/Checkbox.types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"Checkbox.types.js","sourceRoot":"../src/","sources":["components/Checkbox/Checkbox.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { Label } from '@fluentui/react-label';\nimport { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\ninterface CheckboxCommons {\n /**\n * The shape of the checkbox indicator.\n *\n * The `circular` variant is only recommended to be used in a tasks-style UI (checklist),\n * since it otherwise could be confused for a `RadioItem`.\n *\n * @defaultvalue square\n */\n shape: 'square' | 'circular';\n\n /**\n * The controlled value for the checkbox.\n *\n * @defaultvalue false\n */\n checked: 'mixed' | boolean;\n\n /**\n * The size of the checkbox indicator.\n *\n * @defaultvalue medium\n */\n size: 'medium' | 'large';\n\n /**\n * The position of the label relative to the checkbox indicator.\n *\n * @defaultvalue after\n */\n labelPosition: 'before' | 'after';\n}\n\n/**\n * Data for the onChange event for checkbox.\n */\nexport interface CheckboxOnChangeData {\n checked: 'mixed' | boolean;\n}\n\nexport type CheckboxSlots = {\n /**\n * The root element of the Checkbox.\n *\n * The root slot receives the `className` and `style` specified directly on the `<Checkbox>`.\n * All other native props will be applied to the primary slot: `input`\n */\n root: NonNullable<Slot<'span'>>;\n\n /**\n * The Checkbox's label.\n */\n label?: Slot<typeof Label>;\n\n /**\n * Hidden input that handles the checkbox's functionality.\n *\n * This is the PRIMARY slot: all native properties specified directly on `<Checkbox>` will be applied to this slot,\n * except `className` and `style`, which remain on the root slot.\n */\n input: NonNullable<Slot<'input'>>;\n\n /**\n * The checkbox, with the checkmark icon as its child when checked.\n */\n indicator: Slot<'div'>;\n};\n\n/**\n * Checkbox Props\n */\nexport type CheckboxProps = Omit<\n ComponentProps<Partial<CheckboxSlots>, 'input'>,\n 'size' | 'checked' | 'defaultChecked' | 'onChange'\n> &\n Partial<CheckboxCommons> & {\n /**\n * Checkboxes don't support children. To add a label, use the `label` prop.\n */\n children?: never;\n\n /**\n * Callback to be called when the checked state value changes.\n */\n onChange?: (ev: React.FormEvent<HTMLInputElement>, data: CheckboxOnChangeData) => void;\n\n /**\n * Whether the checkbox should be rendered as checked by default.\n */\n defaultChecked?: 'mixed' | boolean;\n };\n\n/**\n * State used in rendering Checkbox\n */\nexport type CheckboxState = ComponentState<CheckboxSlots> & CheckboxCommons;\n"]}
@@ -1 +1 @@
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
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["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","sourcesContent":["export * from './Checkbox';\nexport * from './Checkbox.types';\nexport * from './renderCheckbox';\nexport * from './useCheckbox';\nexport * from './useCheckboxStyles';\n"]}
@@ -1,2 +1,2 @@
1
1
  import { CheckboxState } from './Checkbox.types';
2
- export declare const renderCheckbox: (state: CheckboxState) => JSX.Element;
2
+ export declare const renderCheckbox_unstable: (state: CheckboxState) => JSX.Element;
@@ -1,12 +1,15 @@
1
1
  import * as React from 'react';
2
2
  import { getSlots } from '@fluentui/react-utilities';
3
- export const renderCheckbox = (state) => {
4
- const { slots, slotProps } = getSlots(state, ['root', 'indicator', 'input']);
5
- return (React.createElement(slots.root, Object.assign({}, slotProps.root),
6
- state.labelPosition === 'before' && slotProps.root.children,
7
- React.createElement("div", { className: state.containerClassName },
8
- React.createElement(slots.indicator, Object.assign({}, slotProps.indicator)),
9
- React.createElement(slots.input, Object.assign({}, slotProps.input))),
10
- state.labelPosition === 'after' && slotProps.root.children));
3
+ export const renderCheckbox_unstable = state => {
4
+ const {
5
+ slots,
6
+ slotProps
7
+ } = getSlots(state);
8
+ return /*#__PURE__*/React.createElement(slots.root, { ...slotProps.root
9
+ }, /*#__PURE__*/React.createElement(slots.input, { ...slotProps.input
10
+ }), state.labelPosition === 'before' && slots.label && /*#__PURE__*/React.createElement(slots.label, { ...slotProps.label
11
+ }), /*#__PURE__*/React.createElement(slots.indicator, { ...slotProps.indicator
12
+ }), state.labelPosition === 'after' && slots.label && /*#__PURE__*/React.createElement(slots.label, { ...slotProps.label
13
+ }));
11
14
  };
12
15
  //# sourceMappingURL=renderCheckbox.js.map
@@ -1 +1 @@
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;AAGrD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAoB,EAAE,EAAE;IACrD,MAAM,EAAE,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,CAAC;AAAf,GAAhB,CAHF,EAIG,KAAK,CAAC,aAAN,KAAwB,OAAxB,IAAmC,KAAK,CAAC,KAAzC,iBAAkD,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;AAAf,GAAZ,CAJrD,CADF;AAQD,CAXM","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { CheckboxState, CheckboxSlots } from './Checkbox.types';\n\nexport const renderCheckbox_unstable = (state: CheckboxState) => {\n const { slots, slotProps } = getSlots<CheckboxSlots>(state);\n\n return (\n <slots.root {...slotProps.root}>\n <slots.input {...slotProps.input} />\n {state.labelPosition === 'before' && slots.label && <slots.label {...slotProps.label} />}\n <slots.indicator {...slotProps.indicator} />\n {state.labelPosition === 'after' && slots.label && <slots.label {...slotProps.label} />}\n </slots.root>\n );\n};\n"],"sourceRoot":"../src/"}
@@ -3,10 +3,10 @@ import { CheckboxProps, CheckboxState } from './Checkbox.types';
3
3
  /**
4
4
  * Create the state required to render Checkbox.
5
5
  *
6
- * The returned state can be modified with hooks such as useCheckboxStyles,
7
- * before being passed to renderCheckbox.
6
+ * The returned state can be modified with hooks such as useCheckboxStyles_unstable,
7
+ * before being passed to renderCheckbox_unstable.
8
8
  *
9
9
  * @param props - props from this instance of Checkbox
10
10
  * @param ref - reference to `<input>` element of Checkbox
11
11
  */
12
- export declare const useCheckbox: (props: CheckboxProps, ref: React.Ref<HTMLInputElement>) => CheckboxState;
12
+ export declare const useCheckbox_unstable: (props: CheckboxProps, ref: React.Ref<HTMLInputElement>) => CheckboxState;
@@ -1,88 +1,111 @@
1
1
  import * as React from 'react';
2
- import { getPartitionedNativeProps, resolveShorthand, useControllableState, useEventCallback, useId, useIsomorphicLayoutEffect, useMergedRefs, } from '@fluentui/react-utilities';
3
- import { Mixed12Regular, Mixed16Regular, Checkmark12Regular, Checkmark16Regular } from './DefaultIcons';
2
+ import { getPartitionedNativeProps, resolveShorthand, useControllableState, useEventCallback, useId, useIsomorphicLayoutEffect, useMergedRefs } from '@fluentui/react-utilities';
3
+ import { Checkmark12Filled, Checkmark16Filled, Square12Filled, Square16Filled, CircleFilled } from '@fluentui/react-icons';
4
4
  import { Label } from '@fluentui/react-label';
5
5
  /**
6
6
  * Create the state required to render Checkbox.
7
7
  *
8
- * The returned state can be modified with hooks such as useCheckboxStyles,
9
- * before being passed to renderCheckbox.
8
+ * The returned state can be modified with hooks such as useCheckboxStyles_unstable,
9
+ * before being passed to renderCheckbox_unstable.
10
10
  *
11
11
  * @param props - props from this instance of Checkbox
12
12
  * @param ref - reference to `<input>` element of Checkbox
13
13
  */
14
- export const useCheckbox = (props, ref) => {
15
- const { circular, size = 'medium', labelPosition = 'after' } = props;
16
- const [checked, setChecked] = useControllableState({
17
- defaultState: props.defaultChecked,
18
- state: props.checked,
19
- initialState: false,
20
- });
21
- const nativeProps = getPartitionedNativeProps({
22
- props,
23
- primarySlotTagName: 'input',
24
- excludedPropNames: ['checked', 'defaultChecked', 'children'],
25
- });
26
- const state = {
27
- circular,
28
- checked,
29
- size,
30
- labelPosition,
31
- hasLabel: !!props.children,
32
- components: {
33
- root: props.children !== undefined ? Label : 'span',
34
- indicator: 'div',
35
- input: 'input',
36
- },
37
- root: resolveShorthand(props.root, {
38
- required: true,
39
- defaultProps: {
40
- children: props.children,
41
- ...nativeProps.root,
42
- },
43
- }),
44
- input: resolveShorthand(props.input, {
45
- required: true,
46
- defaultProps: {
47
- type: 'checkbox',
48
- id: useId('checkbox-', nativeProps.primary.id),
49
- ref,
50
- checked: checked === true,
51
- ...nativeProps.primary,
52
- },
53
- }),
54
- indicator: resolveShorthand(props.indicator, {
55
- required: true,
56
- }),
57
- };
58
- // Add the default checkmark icon if none was provided
59
- if (!state.indicator.children) {
60
- if (state.size === 'medium') {
61
- state.indicator.children = checked === 'mixed' ? React.createElement(Mixed12Regular, null) : React.createElement(Checkmark12Regular, null);
62
- }
63
- else {
64
- state.indicator.children = checked === 'mixed' ? React.createElement(Mixed16Regular, null) : React.createElement(Checkmark16Regular, null);
65
- }
14
+
15
+ export const useCheckbox_unstable = (props, ref) => {
16
+ const {
17
+ disabled,
18
+ required,
19
+ shape = 'square',
20
+ size = 'medium',
21
+ labelPosition = 'after',
22
+ onChange
23
+ } = props;
24
+ const [checked, setChecked] = useControllableState({
25
+ defaultState: props.defaultChecked,
26
+ state: props.checked,
27
+ initialState: false
28
+ });
29
+ const nativeProps = getPartitionedNativeProps({
30
+ props,
31
+ primarySlotTagName: 'input',
32
+ excludedPropNames: ['checked', 'defaultChecked', 'size', 'onChange']
33
+ });
34
+ const mixed = checked === 'mixed';
35
+ const id = useId('checkbox-', nativeProps.primary.id);
36
+ let checkmarkIcon;
37
+
38
+ if (mixed) {
39
+ if (shape === 'circular') {
40
+ checkmarkIcon = /*#__PURE__*/React.createElement(CircleFilled, null);
41
+ } else {
42
+ checkmarkIcon = size === 'large' ? /*#__PURE__*/React.createElement(Square16Filled, null) : /*#__PURE__*/React.createElement(Square12Filled, null);
66
43
  }
67
- const onChange = state.input.onChange;
68
- state.input.onChange = useEventCallback(ev => {
69
- ev.stopPropagation();
70
- const val = ev.currentTarget.indeterminate ? 'mixed' : ev.currentTarget.checked;
71
- onChange === null || onChange === void 0 ? void 0 : onChange(ev, { checked: val });
72
- setChecked(val);
44
+ } else {
45
+ checkmarkIcon = size === 'large' ? /*#__PURE__*/React.createElement(Checkmark16Filled, null) : /*#__PURE__*/React.createElement(Checkmark12Filled, null);
46
+ }
47
+
48
+ const state = {
49
+ shape,
50
+ checked,
51
+ size,
52
+ labelPosition,
53
+ components: {
54
+ root: 'span',
55
+ input: 'input',
56
+ indicator: 'div',
57
+ label: Label
58
+ },
59
+ root: resolveShorthand(props.root, {
60
+ required: true,
61
+ defaultProps: nativeProps.root
62
+ }),
63
+ input: resolveShorthand(props.input, {
64
+ required: true,
65
+ defaultProps: {
66
+ type: 'checkbox',
67
+ id,
68
+ ref,
69
+ checked: checked === true,
70
+ ...nativeProps.primary
71
+ }
72
+ }),
73
+ label: resolveShorthand(props.label, {
74
+ required: false,
75
+ defaultProps: {
76
+ htmlFor: id,
77
+ disabled,
78
+ required,
79
+ size: 'medium' // Even if the checkbox itself is large
80
+
81
+ }
82
+ }),
83
+ indicator: resolveShorthand(props.indicator, {
84
+ required: true,
85
+ defaultProps: {
86
+ 'aria-hidden': true,
87
+ children: checkmarkIcon
88
+ }
89
+ })
90
+ };
91
+ state.input.onChange = useEventCallback(ev => {
92
+ const val = ev.currentTarget.indeterminate ? 'mixed' : ev.currentTarget.checked;
93
+ onChange === null || onChange === void 0 ? void 0 : onChange(ev, {
94
+ checked: val
73
95
  });
74
- // Create a ref object for the input element so we can use it to set the indeterminate prop.
75
- // Use useMergedRefs, since the ref might be undefined or a function-ref (no .current)
76
- const inputRef = useMergedRefs(state.input.ref);
77
- state.input.ref = inputRef;
78
- // Set the <input> element's checked and indeterminate properties based on our tri-state property.
79
- // Since indeterminate can only be set via javascript, it has to be done in a layout effect.
80
- const indeterminate = checked === 'mixed';
81
- useIsomorphicLayoutEffect(() => {
82
- if (inputRef.current) {
83
- inputRef.current.indeterminate = indeterminate;
84
- }
85
- }, [inputRef, indeterminate]);
86
- return state;
96
+ setChecked(val);
97
+ }); // Create a ref object for the input element so we can use it to set the indeterminate prop.
98
+ // Use useMergedRefs, since the ref might be undefined or a function-ref (no .current)
99
+
100
+ const inputRef = useMergedRefs(state.input.ref);
101
+ state.input.ref = inputRef; // Set the <input> element's checked and indeterminate properties based on our tri-state property.
102
+ // Since indeterminate can only be set via javascript, it has to be done in a layout effect.
103
+
104
+ useIsomorphicLayoutEffect(() => {
105
+ if (inputRef.current) {
106
+ inputRef.current.indeterminate = mixed;
107
+ }
108
+ }, [inputRef, mixed]);
109
+ return state;
87
110
  };
88
111
  //# sourceMappingURL=useCheckbox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCheckbox.js","sourceRoot":"","sources":["../../../src/components/Checkbox/useCheckbox.tsx"],"names":[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,CAAG,EAAH,EAAO;AAAE,MAAA,OAAO,EAAE;AAAX,KAAP,CAAR;AACA,IAAA,UAAU,CAAC,GAAD,CAAV;AACD,GAJsC,CAAvC,CAxE4G,CA8E5G;AACA;;AACA,QAAM,QAAQ,GAAG,aAAa,CAAC,KAAK,CAAC,KAAN,CAAY,GAAb,CAA9B;AACA,EAAA,KAAK,CAAC,KAAN,CAAY,GAAZ,GAAkB,QAAlB,CAjF4G,CAmF5G;AACA;;AACA,EAAA,yBAAyB,CAAC,MAAK;AAC7B,QAAI,QAAQ,CAAC,OAAb,EAAsB;AACpB,MAAA,QAAQ,CAAC,OAAT,CAAiB,aAAjB,GAAiC,KAAjC;AACD;AACF,GAJwB,EAItB,CAAC,QAAD,EAAW,KAAX,CAJsB,CAAzB;AAMA,SAAO,KAAP;AACD,CA5FM","sourcesContent":["import * as React from 'react';\nimport {\n getPartitionedNativeProps,\n resolveShorthand,\n useControllableState,\n useEventCallback,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n} from '@fluentui/react-utilities';\nimport { CheckboxProps, CheckboxState } from './Checkbox.types';\nimport {\n Checkmark12Filled,\n Checkmark16Filled,\n Square12Filled,\n Square16Filled,\n CircleFilled,\n} from '@fluentui/react-icons';\nimport { Label } from '@fluentui/react-label';\n\n/**\n * Create the state required to render Checkbox.\n *\n * The returned state can be modified with hooks such as useCheckboxStyles_unstable,\n * before being passed to renderCheckbox_unstable.\n *\n * @param props - props from this instance of Checkbox\n * @param ref - reference to `<input>` element of Checkbox\n */\nexport const useCheckbox_unstable = (props: CheckboxProps, ref: React.Ref<HTMLInputElement>): CheckboxState => {\n const { disabled, required, shape = 'square', size = 'medium', labelPosition = 'after', onChange } = props;\n\n const [checked, setChecked] = useControllableState({\n defaultState: props.defaultChecked,\n state: props.checked,\n initialState: false,\n });\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'size', 'onChange'],\n });\n\n const mixed = checked === 'mixed';\n const id = useId('checkbox-', nativeProps.primary.id);\n\n let checkmarkIcon;\n if (mixed) {\n if (shape === 'circular') {\n checkmarkIcon = <CircleFilled />;\n } else {\n checkmarkIcon = size === 'large' ? <Square16Filled /> : <Square12Filled />;\n }\n } else {\n checkmarkIcon = size === 'large' ? <Checkmark16Filled /> : <Checkmark12Filled />;\n }\n\n const state: CheckboxState = {\n shape,\n checked,\n size,\n labelPosition,\n components: {\n root: 'span',\n input: 'input',\n indicator: 'div',\n label: Label,\n },\n root: resolveShorthand(props.root, {\n required: true,\n defaultProps: nativeProps.root,\n }),\n input: resolveShorthand(props.input, {\n required: true,\n defaultProps: {\n type: 'checkbox',\n id,\n ref,\n checked: checked === true,\n ...nativeProps.primary,\n },\n }),\n label: resolveShorthand(props.label, {\n required: false,\n defaultProps: {\n htmlFor: id,\n disabled,\n required,\n size: 'medium', // Even if the checkbox itself is large\n },\n }),\n indicator: resolveShorthand(props.indicator, {\n required: true,\n defaultProps: {\n 'aria-hidden': true,\n children: checkmarkIcon,\n },\n }),\n };\n\n state.input.onChange = useEventCallback(ev => {\n const val = ev.currentTarget.indeterminate ? 'mixed' : ev.currentTarget.checked;\n onChange?.(ev, { checked: val });\n setChecked(val);\n });\n\n // Create a ref object for the input element so we can use it to set the indeterminate prop.\n // Use useMergedRefs, since the ref might be undefined or a function-ref (no .current)\n const inputRef = useMergedRefs(state.input.ref);\n state.input.ref = inputRef;\n\n // Set the <input> element's checked and indeterminate properties based on our tri-state property.\n // Since indeterminate can only be set via javascript, it has to be done in a layout effect.\n useIsomorphicLayoutEffect(() => {\n if (inputRef.current) {\n inputRef.current.indeterminate = mixed;\n }\n }, [inputRef, mixed]);\n\n return state;\n};\n"],"sourceRoot":"../src/"}
@@ -3,4 +3,4 @@ export declare const checkboxClassName = "fui-Checkbox";
3
3
  /**
4
4
  * Apply styling to the Checkbox slots based on the state
5
5
  */
6
- export declare const useCheckboxStyles: (state: CheckboxState) => CheckboxState;
6
+ export declare const useCheckboxStyles_unstable: (state: CheckboxState) => CheckboxState;