@fluentui/react-checkbox 9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0 → 9.75.2-experimental.css-modules.20261113-ba13c87438.0

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.md CHANGED
@@ -1,23 +1,23 @@
1
1
  # Change Log - @fluentui/react-checkbox
2
2
 
3
- <!-- This log was last generated on Tue, 03 Nov 2026 14:03:11 GMT and should not be manually modified. -->
3
+ <!-- This log was last generated on Fri, 13 Nov 2026 20:37:11 GMT and should not be manually modified. -->
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## [9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-checkbox_v9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0)
7
+ ## [9.75.2-experimental.css-modules.20261113-ba13c87438.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-checkbox_v9.75.2-experimental.css-modules.20261113-ba13c87438.0)
8
8
 
9
- Tue, 03 Nov 2026 14:03:11 GMT
9
+ Fri, 13 Nov 2026 20:37:11 GMT
10
10
 
11
11
  ### Changes
12
12
 
13
- - Release 9.75.1-experimental.css-modules.20261103-d6c85ee2a9 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by 257645319+office-ogx-auth-helper[bot]@users.noreply.github.com)
14
- - Bump @fluentui/react-field to v9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
15
- - Bump @fluentui/react-jsx-runtime to v9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
16
- - Bump @fluentui/react-label to v9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
17
- - Bump @fluentui/react-shared-contexts to v9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
18
- - Bump @fluentui/react-tabster to v9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
19
- - Bump @fluentui/react-theme to v9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
20
- - Bump @fluentui/react-utilities to v9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
13
+ - Release 9.75.2-experimental.css-modules.20261113-ba13c87438 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by 257645319+office-ogx-auth-helper[bot]@users.noreply.github.com)
14
+ - Bump @fluentui/react-field to v9.75.2-experimental.css-modules.20261113-ba13c87438.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
15
+ - Bump @fluentui/react-jsx-runtime to v9.75.2-experimental.css-modules.20261113-ba13c87438.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
16
+ - Bump @fluentui/react-label to v9.75.2-experimental.css-modules.20261113-ba13c87438.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
17
+ - Bump @fluentui/react-shared-contexts to v9.75.2-experimental.css-modules.20261113-ba13c87438.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
18
+ - Bump @fluentui/react-tabster to v9.75.2-experimental.css-modules.20261113-ba13c87438.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
19
+ - Bump @fluentui/react-theme to v9.75.2-experimental.css-modules.20261113-ba13c87438.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
20
+ - Bump @fluentui/react-utilities to v9.75.2-experimental.css-modules.20261113-ba13c87438.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
21
21
 
22
22
  ## [9.6.6](https://github.com/microsoft/fluentui/tree/@fluentui/react-checkbox_v9.6.6)
23
23
 
package/README.md CHANGED
@@ -30,16 +30,16 @@ Alternatively, run Storybook locally with:
30
30
 
31
31
  ### Specification
32
32
 
33
- See [Spec.md](./Spec.md).
33
+ See [Spec.md](./docs/Spec.md).
34
34
 
35
35
  ### Migration Guide
36
36
 
37
- If you're upgrading to Fluent UI v9 see [MIGRATION.md](./MIGRATION.md) for guidance on updating to the latest Checkbox implementation.
37
+ If you're upgrading to Fluent UI v9 see [MIGRATION.md](./docs/MIGRATION.md) for guidance on updating to the latest Checkbox implementation.
38
38
 
39
39
  ## Opt-in CSS Modules styles
40
40
 
41
41
  The `use*Styles.styles.css` modules beside the existing Griffel hooks provide opt-in,
42
- layered CSS alternatives with the same exports. Configure the bundler to replace
42
+ CSS alternatives with the same exports. Configure the bundler to replace
43
43
  `.styles` with `.styles.css.ts` for source imports and `.styles.js` with
44
44
  `.styles.css.js` for built imports. Load CSS Modules as default class-name maps and
45
45
  retain the package CSS assets. Default component imports still use Griffel.
@@ -47,4 +47,4 @@ Composed components require their own style alternatives; this does not remove
47
47
  all reachable Griffel dependencies. Browser, forced-colors, RTL, and visual-regression
48
48
  parity must be validated before switching defaults.
49
49
 
50
- Select the CSS Modules alternative for the composed `Label` as well; mixing a layered parent with an unlayered Griffel child can change the label cascade.
50
+ Select the CSS Modules alternative for the composed `Label` as well; mixing a CSS Modules parent with a Griffel child makes the label cascade depend on style insertion order.
package/dist/index.d.cts CHANGED
@@ -116,7 +116,7 @@ export declare const useCheckbox_unstable: (props: CheckboxProps, ref: React_2.R
116
116
 
117
117
  /**
118
118
  * Base hook for Checkbox component, which manages state related to checked state, ARIA attributes,
119
- * focus management, and slot structure without design props.
119
+ * and slot structure without design props or focus management.
120
120
  *
121
121
  * @param props - props from this instance of Checkbox
122
122
  * @param ref - reference to `<input>` element of Checkbox
package/dist/index.d.ts CHANGED
@@ -116,7 +116,7 @@ export declare const useCheckbox_unstable: (props: CheckboxProps, ref: React_2.R
116
116
 
117
117
  /**
118
118
  * Base hook for Checkbox component, which manages state related to checked state, ARIA attributes,
119
- * focus management, and slot structure without design props.
119
+ * and slot structure without design props or focus management.
120
120
  *
121
121
  * @param props - props from this instance of Checkbox
122
122
  * @param ref - reference to `<input>` element of Checkbox
@@ -1,179 +1,178 @@
1
- @layer fluent {
2
- .root {
3
- position: relative;
4
- display: inline-flex;
5
- cursor: pointer;
6
- max-width: fit-content;
7
- vertical-align: middle;
8
- color: var(--colorNeutralForeground3);
9
- &:focus {
10
- outline-style: none;
1
+ /* @griffel-buckets reset: .root, .input, .indicator */
2
+ .root {
3
+ position: relative;
4
+ display: inline-flex;
5
+ cursor: pointer;
6
+ max-width: fit-content;
7
+ vertical-align: middle;
8
+ color: var(--colorNeutralForeground3);
9
+ &:focus {
10
+ outline-style: none;
11
+ }
12
+
13
+ &:focus-visible {
14
+ outline-style: none;
15
+ }
16
+
17
+ &[data-fui-focus-within]:focus-within {
18
+ border-top-color: transparent;
19
+ border-inline-end-color: transparent;
20
+ border-bottom-color: transparent;
21
+ border-inline-start-color: transparent;
22
+ &::after {
23
+ content: '';
24
+ position: absolute;
25
+ pointer-events: none;
26
+ z-index: 1;
27
+ border: var(--strokeWidthThick) solid var(--colorStrokeFocus2);
28
+ border-radius: var(--borderRadiusMedium);
29
+ top: calc(var(--strokeWidthThick) * -1);
30
+ inset-inline-end: calc(var(--strokeWidthThick) * -1);
31
+ bottom: calc(var(--strokeWidthThick) * -1);
32
+ inset-inline-start: calc(var(--strokeWidthThick) * -1);
11
33
  }
12
34
 
13
- &:focus-visible {
14
- outline-style: none;
15
- }
16
-
17
- &[data-fui-focus-within]:focus-within {
18
- border-top-color: transparent;
19
- border-right-color: transparent;
20
- border-bottom-color: transparent;
21
- border-left-color: transparent;
35
+ @media (forced-colors: active) {
22
36
  &::after {
23
- content: '';
24
- position: absolute;
25
- pointer-events: none;
26
- z-index: 1;
27
- border: var(--strokeWidthThick) solid var(--colorStrokeFocus2);
28
- border-radius: var(--borderRadiusMedium);
29
- top: calc(var(--strokeWidthThick) * -1);
30
- inset-inline-end: calc(var(--strokeWidthThick) * -1);
31
- bottom: calc(var(--strokeWidthThick) * -1);
32
- inset-inline-start: calc(var(--strokeWidthThick) * -1);
33
- }
34
-
35
- @media (forced-colors: active) {
36
- &::after {
37
- border-top-color: Highlight;
38
- border-right-color: Highlight;
39
- border-bottom-color: Highlight;
40
- border-left-color: Highlight;
41
- }
37
+ border-top-color: Highlight;
38
+ border-inline-end-color: Highlight;
39
+ border-bottom-color: Highlight;
40
+ border-inline-start-color: Highlight;
42
41
  }
43
42
  }
44
43
  }
44
+ }
45
45
 
46
- .root:where(.unchecked:not(.disabled)) {
47
- &:hover {
48
- color: var(--colorNeutralForeground2);
49
- --fui-Checkbox__indicator--borderColor: var(--colorNeutralStrokeAccessibleHover);
50
- }
51
-
52
- &:active {
53
- color: var(--colorNeutralForeground1);
54
- --fui-Checkbox__indicator--borderColor: var(--colorNeutralStrokeAccessiblePressed);
55
- }
46
+ .root:where(.unchecked:not(.disabled)) {
47
+ &:hover {
48
+ color: var(--colorNeutralForeground2);
49
+ --fui-Checkbox__indicator--borderColor: var(--colorNeutralStrokeAccessibleHover);
56
50
  }
57
51
 
58
- .root:where(.checked:not(.disabled)) {
52
+ &:active {
59
53
  color: var(--colorNeutralForeground1);
60
- --fui-Checkbox__indicator--backgroundColor: var(--colorCompoundBrandBackground);
61
- --fui-Checkbox__indicator--color: var(--colorNeutralForegroundInverted);
62
- --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandBackground);
63
- &:hover {
64
- --fui-Checkbox__indicator--backgroundColor: var(--colorCompoundBrandBackgroundHover);
65
- --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandBackgroundHover);
66
- }
67
-
68
- &:active {
69
- --fui-Checkbox__indicator--backgroundColor: var(--colorCompoundBrandBackgroundPressed);
70
- --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandBackgroundPressed);
71
- }
54
+ --fui-Checkbox__indicator--borderColor: var(--colorNeutralStrokeAccessiblePressed);
72
55
  }
56
+ }
73
57
 
74
- .root:where(.mixed:not(.disabled)) {
75
- color: var(--colorNeutralForeground1);
76
- --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandStroke);
77
- --fui-Checkbox__indicator--color: var(--colorCompoundBrandForeground1);
78
- &:hover {
79
- --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandStrokeHover);
80
- --fui-Checkbox__indicator--color: var(--colorCompoundBrandForeground1Hover);
81
- }
82
-
83
- &:active {
84
- --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandStrokePressed);
85
- --fui-Checkbox__indicator--color: var(--colorCompoundBrandForeground1Pressed);
86
- }
58
+ .root:where(.checked:not(.disabled)) {
59
+ color: var(--colorNeutralForeground1);
60
+ --fui-Checkbox__indicator--backgroundColor: var(--colorCompoundBrandBackground);
61
+ --fui-Checkbox__indicator--color: var(--colorNeutralForegroundInverted);
62
+ --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandBackground);
63
+ &:hover {
64
+ --fui-Checkbox__indicator--backgroundColor: var(--colorCompoundBrandBackgroundHover);
65
+ --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandBackgroundHover);
87
66
  }
88
67
 
89
- .root:where(.disabled) {
90
- cursor: default;
91
- color: var(--colorNeutralForegroundDisabled);
92
- --fui-Checkbox__indicator--borderColor: var(--colorNeutralStrokeDisabled);
93
- --fui-Checkbox__indicator--color: var(--colorNeutralForegroundDisabled);
94
- @media (forced-colors: active) {
95
- color: GrayText;
96
- --fui-Checkbox__indicator--color: GrayText;
97
- }
68
+ &:active {
69
+ --fui-Checkbox__indicator--backgroundColor: var(--colorCompoundBrandBackgroundPressed);
70
+ --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandBackgroundPressed);
98
71
  }
72
+ }
99
73
 
100
- .input {
101
- box-sizing: border-box;
102
- cursor: inherit;
103
- height: 100%;
104
- margin: 0;
105
- opacity: 0;
106
- position: absolute;
107
- top: 0;
108
- width: calc(var(--spacingHorizontalL) + 2 * var(--spacingHorizontalS));
74
+ .root:where(.mixed:not(.disabled)) {
75
+ color: var(--colorNeutralForeground1);
76
+ --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandStroke);
77
+ --fui-Checkbox__indicator--color: var(--colorCompoundBrandForeground1);
78
+ &:hover {
79
+ --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandStrokeHover);
80
+ --fui-Checkbox__indicator--color: var(--colorCompoundBrandForeground1Hover);
109
81
  }
110
82
 
111
- :where(.before) > .input {
112
- inset-inline-end: 0;
83
+ &:active {
84
+ --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandStrokePressed);
85
+ --fui-Checkbox__indicator--color: var(--colorCompoundBrandForeground1Pressed);
113
86
  }
87
+ }
114
88
 
115
- :where(.after) > .input {
116
- inset-inline-start: 0;
89
+ .root:where(.disabled) {
90
+ cursor: default;
91
+ color: var(--colorNeutralForegroundDisabled);
92
+ --fui-Checkbox__indicator--borderColor: var(--colorNeutralStrokeDisabled);
93
+ --fui-Checkbox__indicator--color: var(--colorNeutralForegroundDisabled);
94
+ @media (forced-colors: active) {
95
+ color: GrayText;
96
+ --fui-Checkbox__indicator--color: GrayText;
117
97
  }
98
+ }
118
99
 
119
- :where(.large) > .input {
120
- width: calc(var(--spacingHorizontalXL) + 2 * var(--spacingHorizontalS));
121
- }
100
+ .input {
101
+ box-sizing: border-box;
102
+ cursor: inherit;
103
+ height: 100%;
104
+ margin: 0;
105
+ opacity: 0;
106
+ position: absolute;
107
+ top: 0;
108
+ width: calc(var(--spacingHorizontalL) + 2 * var(--spacingHorizontalS));
109
+ }
122
110
 
123
- .indicator {
124
- align-self: flex-start;
125
- box-sizing: border-box;
126
- flex-shrink: 0;
127
- display: flex;
128
- align-items: center;
129
- justify-content: center;
130
- overflow: hidden;
131
- color: var(--fui-Checkbox__indicator--color);
132
- background-color: var(--fui-Checkbox__indicator--backgroundColor);
133
- border-color: var(--fui-Checkbox__indicator--borderColor, var(--colorNeutralStrokeAccessible));
134
- border-style: solid;
135
- border-width: var(--strokeWidthThin);
136
- border-radius: var(--borderRadiusSmall);
137
- margin: var(--spacingVerticalS) var(--spacingHorizontalS);
138
- fill: currentColor;
139
- pointer-events: none;
140
- font-size: var(--fontSizeBase200);
141
- height: var(--spacingHorizontalL);
142
- width: var(--spacingHorizontalL);
143
- }
111
+ :where(.before) > .input {
112
+ inset-inline-end: 0;
113
+ }
144
114
 
145
- :where(.large) > .indicator {
146
- font-size: var(--fontSizeBase400);
147
- height: var(--spacingHorizontalXL);
148
- width: var(--spacingHorizontalXL);
149
- }
115
+ :where(.after) > .input {
116
+ inset-inline-start: 0;
117
+ }
150
118
 
151
- :where(.circular) > .indicator {
152
- border-radius: var(--borderRadiusCircular);
153
- }
119
+ :where(.large) > .input {
120
+ width: calc(var(--spacingHorizontalXL) + 2 * var(--spacingHorizontalS));
121
+ }
154
122
 
155
- .label {
156
- align-self: center;
157
- color: inherit;
158
- cursor: inherit;
159
- padding: var(--spacingVerticalS) var(--spacingHorizontalS);
160
- }
123
+ .indicator {
124
+ align-self: flex-start;
125
+ box-sizing: border-box;
126
+ flex-shrink: 0;
127
+ display: flex;
128
+ align-items: center;
129
+ justify-content: center;
130
+ overflow: hidden;
131
+ color: var(--fui-Checkbox__indicator--color);
132
+ background-color: var(--fui-Checkbox__indicator--backgroundColor);
133
+ border-color: var(--fui-Checkbox__indicator--borderColor, var(--colorNeutralStrokeAccessible));
134
+ border-style: solid;
135
+ border-width: var(--strokeWidthThin);
136
+ border-radius: var(--borderRadiusSmall);
137
+ margin: var(--spacingVerticalS) var(--spacingHorizontalS);
138
+ fill: currentColor;
139
+ pointer-events: none;
140
+ font-size: var(--fontSizeBase200);
141
+ height: var(--spacingHorizontalL);
142
+ width: var(--spacingHorizontalL);
143
+ }
161
144
 
162
- :where(.before) > .label {
163
- padding-inline-end: var(--spacingHorizontalXS);
164
- }
145
+ :where(.large) > .indicator {
146
+ font-size: var(--fontSizeBase400);
147
+ height: var(--spacingHorizontalXL);
148
+ width: var(--spacingHorizontalXL);
149
+ }
165
150
 
166
- :where(.after) > .label {
167
- padding-inline-start: var(--spacingHorizontalXS);
168
- }
151
+ :where(.circular) > .indicator {
152
+ border-radius: var(--borderRadiusCircular);
153
+ }
169
154
 
170
- :where(.medium) > .label {
171
- margin-top: calc((var(--spacingHorizontalL) - var(--lineHeightBase300)) / 2);
172
- margin-bottom: calc((var(--spacingHorizontalL) - var(--lineHeightBase300)) / 2);
173
- }
155
+ .label {
156
+ align-self: center;
157
+ color: inherit;
158
+ cursor: inherit;
159
+ padding: var(--spacingVerticalS) var(--spacingHorizontalS);
160
+ }
174
161
 
175
- :where(.large) > .label {
176
- margin-top: calc((var(--spacingHorizontalXL) - var(--lineHeightBase300)) / 2);
177
- margin-bottom: calc((var(--spacingHorizontalXL) - var(--lineHeightBase300)) / 2);
178
- }
162
+ :where(.before) > .label {
163
+ padding-inline-end: var(--spacingHorizontalXS);
164
+ }
165
+
166
+ :where(.after) > .label {
167
+ padding-inline-start: var(--spacingHorizontalXS);
168
+ }
169
+
170
+ :where(.medium) > .label {
171
+ margin-top: calc((var(--spacingHorizontalL) - var(--lineHeightBase300)) / 2);
172
+ margin-bottom: calc((var(--spacingHorizontalL) - var(--lineHeightBase300)) / 2);
173
+ }
174
+
175
+ :where(.large) > .label {
176
+ margin-top: calc((var(--spacingHorizontalXL) - var(--lineHeightBase300)) / 2);
177
+ margin-bottom: calc((var(--spacingHorizontalXL) - var(--lineHeightBase300)) / 2);
179
178
  }
@@ -16,6 +16,10 @@ import { useFocusWithin } from "@fluentui/react-tabster";
16
16
  */ export const useCheckbox_unstable = (props, ref)=>{
17
17
  const { shape = 'square', size = 'medium', ...checkboxProps } = props;
18
18
  const state = useCheckboxBase_unstable(checkboxProps, ref);
19
+ // Focus-within ref drives the styled focus outline; applied here rather than in the base hook
20
+ // so the base hook does not depend on react-tabster (keyborg).
21
+ // eslint-disable-next-line react-hooks/immutability
22
+ state.root.ref = useMergedRefs(state.root.ref, useFocusWithin());
19
23
  // Override indicator children with size+shape-appropriate icon
20
24
  const mixed = state.checked === 'mixed';
21
25
  let checkmarkIcon;
@@ -52,7 +56,7 @@ import { useFocusWithin } from "@fluentui/react-tabster";
52
56
  };
53
57
  /**
54
58
  * Base hook for Checkbox component, which manages state related to checked state, ARIA attributes,
55
- * focus management, and slot structure without design props.
59
+ * and slot structure without design props or focus management.
56
60
  *
57
61
  * @param props - props from this instance of Checkbox
58
62
  * @param ref - reference to `<input>` element of Checkbox
@@ -91,10 +95,7 @@ import { useFocusWithin } from "@fluentui/react-tabster";
91
95
  label: 'label'
92
96
  },
93
97
  root: slot.always(props.root, {
94
- defaultProps: {
95
- ref: useFocusWithin(),
96
- ...nativeProps.root
97
- },
98
+ defaultProps: nativeProps.root,
98
99
  elementType: 'span'
99
100
  }),
100
101
  input: slot.always(props.input, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Checkbox/useCheckbox.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport {\n getPartitionedNativeProps,\n useControllableState,\n mergeCallbacks,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n slot,\n} from '@fluentui/react-utilities';\nimport type { CheckboxBaseProps, CheckboxBaseState, 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';\nimport { useFocusWithin } from '@fluentui/react-tabster';\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 { shape = 'square', size = 'medium', ...checkboxProps } = props;\n\n const state = useCheckboxBase_unstable(checkboxProps, ref);\n\n // Override indicator children with size+shape-appropriate icon\n const mixed = state.checked === 'mixed';\n let checkmarkIcon;\n if (mixed) {\n if (shape === 'circular') {\n checkmarkIcon = <CircleFilled />;\n } else {\n checkmarkIcon = size === 'large' ? <Square16Filled /> : <Square12Filled />;\n }\n } else if (state.checked) {\n checkmarkIcon = size === 'large' ? <Checkmark16Filled /> : <Checkmark12Filled />;\n }\n\n if (state.indicator) {\n state.indicator.children ??= checkmarkIcon;\n }\n\n return {\n shape,\n size,\n ...state,\n components: {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ...state.components,\n label: Label,\n },\n label: slot.optional(props.label, {\n defaultProps: {\n ...state.label,\n size: 'medium',\n },\n elementType: Label,\n }),\n };\n};\n\n/**\n * Base hook for Checkbox component, which manages state related to checked state, ARIA attributes,\n * focus management, and slot structure without design props.\n *\n * @param props - props from this instance of Checkbox\n * @param ref - reference to `<input>` element of Checkbox\n */\nexport const useCheckboxBase_unstable = (\n props: CheckboxBaseProps,\n ref: React.Ref<HTMLInputElement>,\n): CheckboxBaseState => {\n 'use no memo'; // justified: compiler would optimize useCheckboxBase_unstable — manual opt-out to preserve runtime behavior\n\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, { supportsLabelFor: true, supportsRequired: true });\n\n const { disabled = false, required, 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', 'onChange'],\n });\n\n const mixed = checked === 'mixed';\n const id = useId('checkbox-', nativeProps.primary.id);\n\n const state: CheckboxBaseState = {\n checked,\n disabled,\n labelPosition,\n components: {\n root: 'span',\n input: 'input',\n indicator: 'div',\n label: 'label',\n },\n root: slot.always(props.root, {\n defaultProps: {\n ref: useFocusWithin<HTMLSpanElement>(),\n ...nativeProps.root,\n },\n elementType: 'span',\n }),\n input: slot.always(props.input, {\n defaultProps: {\n type: 'checkbox',\n id,\n ref,\n checked: checked === true,\n ...nativeProps.primary,\n },\n elementType: 'input',\n }),\n label: slot.optional(props.label, {\n defaultProps: {\n htmlFor: id,\n disabled,\n required,\n },\n elementType: 'label',\n }),\n indicator: slot.optional(props.indicator, {\n renderByDefault: true,\n defaultProps: {\n 'aria-hidden': true,\n },\n elementType: 'div',\n }),\n };\n\n state.input.onChange = mergeCallbacks(state.input.onChange, 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"],"names":["React","useFieldControlProps_unstable","getPartitionedNativeProps","useControllableState","mergeCallbacks","useId","useIsomorphicLayoutEffect","useMergedRefs","slot","Checkmark12Filled","Checkmark16Filled","Square12Filled","Square16Filled","CircleFilled","Label","useFocusWithin","useCheckbox_unstable","props","ref","shape","size","checkboxProps","state","useCheckboxBase_unstable","mixed","checked","checkmarkIcon","indicator","children","components","label","optional","defaultProps","elementType","supportsLabelFor","supportsRequired","disabled","required","labelPosition","onChange","setChecked","defaultState","defaultChecked","initialState","nativeProps","primarySlotTagName","excludedPropNames","id","primary","root","input","always","type","htmlFor","renderByDefault","ev","val","currentTarget","indeterminate","inputRef","current"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,6BAA6B,QAAQ,wBAAwB;AACtE,SACEC,yBAAyB,EACzBC,oBAAoB,EACpBC,cAAc,EACdC,KAAK,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AAEgB,CAAAA;QAC1D,MAAMC,MAAMD,GAAGE,aAAa,CAACC,aAAa,GAAG,UAAUH,GAAGE,aAAa,CAAChC,OAAO;QAC/Ec,qBAAAA,+BAAAA,SAAWgB,IAAI;YAAE9B,SAAS+B;QAAI;QAC9BhB,WAAWgB;IACb;IAEA,4FAA4F;IAC5F,sFAAsF;IACtF,MAAMG,WAAWpD,cAAce,MAAM4B,KAAK,CAAChC,GAAG;IAC9CI,MAAM4B,KAAK,CAAChC,GAAG,GAAGyC;IAElB,kGAAkG;IAClG,4FAA4F;IAC5FrD,0BAA0B;QACxB,IAAIqD,SAASC,OAAO,EAAE;YACpBD,SAASC,OAAO,CAACF,aAAa,GAAGlC;QACnC;IACF,GAAG;QAACmC;QAAUnC;KAAM;IAEpB,OAAOF;AACT,EAAE"}
1
+ {"version":3,"sources":["../../../src/components/Checkbox/useCheckbox.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport {\n getPartitionedNativeProps,\n useControllableState,\n mergeCallbacks,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n slot,\n} from '@fluentui/react-utilities';\nimport type { CheckboxBaseProps, CheckboxBaseState, 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';\nimport { useFocusWithin } from '@fluentui/react-tabster';\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 { shape = 'square', size = 'medium', ...checkboxProps } = props;\n\n const state = useCheckboxBase_unstable(checkboxProps, ref);\n\n // Focus-within ref drives the styled focus outline; applied here rather than in the base hook\n // so the base hook does not depend on react-tabster (keyborg).\n // eslint-disable-next-line react-hooks/immutability\n state.root.ref = useMergedRefs(state.root.ref, useFocusWithin<HTMLSpanElement>());\n\n // Override indicator children with size+shape-appropriate icon\n const mixed = state.checked === 'mixed';\n let checkmarkIcon;\n if (mixed) {\n if (shape === 'circular') {\n checkmarkIcon = <CircleFilled />;\n } else {\n checkmarkIcon = size === 'large' ? <Square16Filled /> : <Square12Filled />;\n }\n } else if (state.checked) {\n checkmarkIcon = size === 'large' ? <Checkmark16Filled /> : <Checkmark12Filled />;\n }\n\n if (state.indicator) {\n state.indicator.children ??= checkmarkIcon;\n }\n\n return {\n shape,\n size,\n ...state,\n components: {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ...state.components,\n label: Label,\n },\n label: slot.optional(props.label, {\n defaultProps: {\n ...state.label,\n size: 'medium',\n },\n elementType: Label,\n }),\n };\n};\n\n/**\n * Base hook for Checkbox component, which manages state related to checked state, ARIA attributes,\n * and slot structure without design props or focus management.\n *\n * @param props - props from this instance of Checkbox\n * @param ref - reference to `<input>` element of Checkbox\n */\nexport const useCheckboxBase_unstable = (\n props: CheckboxBaseProps,\n ref: React.Ref<HTMLInputElement>,\n): CheckboxBaseState => {\n 'use no memo'; // justified: compiler would optimize useCheckboxBase_unstable — manual opt-out to preserve runtime behavior\n\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, { supportsLabelFor: true, supportsRequired: true });\n\n const { disabled = false, required, 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', 'onChange'],\n });\n\n const mixed = checked === 'mixed';\n const id = useId('checkbox-', nativeProps.primary.id);\n\n const state: CheckboxBaseState = {\n checked,\n disabled,\n labelPosition,\n components: {\n root: 'span',\n input: 'input',\n indicator: 'div',\n label: 'label',\n },\n root: slot.always(props.root, {\n defaultProps: nativeProps.root,\n elementType: 'span',\n }),\n input: slot.always(props.input, {\n defaultProps: {\n type: 'checkbox',\n id,\n ref,\n checked: checked === true,\n ...nativeProps.primary,\n },\n elementType: 'input',\n }),\n label: slot.optional(props.label, {\n defaultProps: {\n htmlFor: id,\n disabled,\n required,\n },\n elementType: 'label',\n }),\n indicator: slot.optional(props.indicator, {\n renderByDefault: true,\n defaultProps: {\n 'aria-hidden': true,\n },\n elementType: 'div',\n }),\n };\n\n state.input.onChange = mergeCallbacks(state.input.onChange, 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"],"names":["React","useFieldControlProps_unstable","getPartitionedNativeProps","useControllableState","mergeCallbacks","useId","useIsomorphicLayoutEffect","useMergedRefs","slot","Checkmark12Filled","Checkmark16Filled","Square12Filled","Square16Filled","CircleFilled","Label","useFocusWithin","useCheckbox_unstable","props","ref","shape","size","checkboxProps","state","useCheckboxBase_unstable","root","mixed","checked","checkmarkIcon","indicator","children","components","label","optional","defaultProps","elementType","supportsLabelFor","supportsRequired","disabled","required","labelPosition","onChange","setChecked","defaultState","defaultChecked","initialState","nativeProps","primarySlotTagName","excludedPropNames","id","primary","input","always","type","htmlFor","renderByDefault","ev","val","currentTarget","indeterminate","inputRef","current"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,6BAA6B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MW,SAAS,EAAE;YACxC0B,iBAAiB;YACjBrB,cAAc;gBACZ,eAAe;YACjB;YACAC,aAAa;QACf;IACF;IAEAZ,MAAM4B,KAAK,CAACV,QAAQ,GAAGpC,eAAekB,MAAM4B,KAAK,CAACV,QAAQ,EAAEe,CAAAA;QAC1D,MAAMC,MAAMD,GAAGE,aAAa,CAACC,aAAa,GAAG,UAAUH,GAAGE,aAAa,CAAC/B,OAAO;QAC/Ec,qBAAAA,+BAAAA,SAAWe,IAAI;YAAE7B,SAAS8B;QAAI;QAC9Bf,WAAWe;IACb;IAEA,4FAA4F;IAC5F,sFAAsF;IACtF,MAAMG,WAAWpD,cAAce,MAAM4B,KAAK,CAAChC,GAAG;IAC9CI,MAAM4B,KAAK,CAAChC,GAAG,GAAGyC;IAElB,kGAAkG;IAClG,4FAA4F;IAC5FrD,0BAA0B;QACxB,IAAIqD,SAASC,OAAO,EAAE;YACpBD,SAASC,OAAO,CAACF,aAAa,GAAGjC;QACnC;IACF,GAAG;QAACkC;QAAUlC;KAAM;IAEpB,OAAOH;AACT,EAAE"}
@@ -1,179 +1,178 @@
1
- @layer fluent {
2
- .root {
3
- position: relative;
4
- display: inline-flex;
5
- cursor: pointer;
6
- max-width: fit-content;
7
- vertical-align: middle;
8
- color: var(--colorNeutralForeground3);
9
- &:focus {
10
- outline-style: none;
1
+ /* @griffel-buckets reset: .root, .input, .indicator */
2
+ .root {
3
+ position: relative;
4
+ display: inline-flex;
5
+ cursor: pointer;
6
+ max-width: fit-content;
7
+ vertical-align: middle;
8
+ color: var(--colorNeutralForeground3);
9
+ &:focus {
10
+ outline-style: none;
11
+ }
12
+
13
+ &:focus-visible {
14
+ outline-style: none;
15
+ }
16
+
17
+ &[data-fui-focus-within]:focus-within {
18
+ border-top-color: transparent;
19
+ border-inline-end-color: transparent;
20
+ border-bottom-color: transparent;
21
+ border-inline-start-color: transparent;
22
+ &::after {
23
+ content: '';
24
+ position: absolute;
25
+ pointer-events: none;
26
+ z-index: 1;
27
+ border: var(--strokeWidthThick) solid var(--colorStrokeFocus2);
28
+ border-radius: var(--borderRadiusMedium);
29
+ top: calc(var(--strokeWidthThick) * -1);
30
+ inset-inline-end: calc(var(--strokeWidthThick) * -1);
31
+ bottom: calc(var(--strokeWidthThick) * -1);
32
+ inset-inline-start: calc(var(--strokeWidthThick) * -1);
11
33
  }
12
34
 
13
- &:focus-visible {
14
- outline-style: none;
15
- }
16
-
17
- &[data-fui-focus-within]:focus-within {
18
- border-top-color: transparent;
19
- border-right-color: transparent;
20
- border-bottom-color: transparent;
21
- border-left-color: transparent;
35
+ @media (forced-colors: active) {
22
36
  &::after {
23
- content: '';
24
- position: absolute;
25
- pointer-events: none;
26
- z-index: 1;
27
- border: var(--strokeWidthThick) solid var(--colorStrokeFocus2);
28
- border-radius: var(--borderRadiusMedium);
29
- top: calc(var(--strokeWidthThick) * -1);
30
- inset-inline-end: calc(var(--strokeWidthThick) * -1);
31
- bottom: calc(var(--strokeWidthThick) * -1);
32
- inset-inline-start: calc(var(--strokeWidthThick) * -1);
33
- }
34
-
35
- @media (forced-colors: active) {
36
- &::after {
37
- border-top-color: Highlight;
38
- border-right-color: Highlight;
39
- border-bottom-color: Highlight;
40
- border-left-color: Highlight;
41
- }
37
+ border-top-color: Highlight;
38
+ border-inline-end-color: Highlight;
39
+ border-bottom-color: Highlight;
40
+ border-inline-start-color: Highlight;
42
41
  }
43
42
  }
44
43
  }
44
+ }
45
45
 
46
- .root:where(.unchecked:not(.disabled)) {
47
- &:hover {
48
- color: var(--colorNeutralForeground2);
49
- --fui-Checkbox__indicator--borderColor: var(--colorNeutralStrokeAccessibleHover);
50
- }
51
-
52
- &:active {
53
- color: var(--colorNeutralForeground1);
54
- --fui-Checkbox__indicator--borderColor: var(--colorNeutralStrokeAccessiblePressed);
55
- }
46
+ .root:where(.unchecked:not(.disabled)) {
47
+ &:hover {
48
+ color: var(--colorNeutralForeground2);
49
+ --fui-Checkbox__indicator--borderColor: var(--colorNeutralStrokeAccessibleHover);
56
50
  }
57
51
 
58
- .root:where(.checked:not(.disabled)) {
52
+ &:active {
59
53
  color: var(--colorNeutralForeground1);
60
- --fui-Checkbox__indicator--backgroundColor: var(--colorCompoundBrandBackground);
61
- --fui-Checkbox__indicator--color: var(--colorNeutralForegroundInverted);
62
- --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandBackground);
63
- &:hover {
64
- --fui-Checkbox__indicator--backgroundColor: var(--colorCompoundBrandBackgroundHover);
65
- --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandBackgroundHover);
66
- }
67
-
68
- &:active {
69
- --fui-Checkbox__indicator--backgroundColor: var(--colorCompoundBrandBackgroundPressed);
70
- --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandBackgroundPressed);
71
- }
54
+ --fui-Checkbox__indicator--borderColor: var(--colorNeutralStrokeAccessiblePressed);
72
55
  }
56
+ }
73
57
 
74
- .root:where(.mixed:not(.disabled)) {
75
- color: var(--colorNeutralForeground1);
76
- --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandStroke);
77
- --fui-Checkbox__indicator--color: var(--colorCompoundBrandForeground1);
78
- &:hover {
79
- --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandStrokeHover);
80
- --fui-Checkbox__indicator--color: var(--colorCompoundBrandForeground1Hover);
81
- }
82
-
83
- &:active {
84
- --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandStrokePressed);
85
- --fui-Checkbox__indicator--color: var(--colorCompoundBrandForeground1Pressed);
86
- }
58
+ .root:where(.checked:not(.disabled)) {
59
+ color: var(--colorNeutralForeground1);
60
+ --fui-Checkbox__indicator--backgroundColor: var(--colorCompoundBrandBackground);
61
+ --fui-Checkbox__indicator--color: var(--colorNeutralForegroundInverted);
62
+ --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandBackground);
63
+ &:hover {
64
+ --fui-Checkbox__indicator--backgroundColor: var(--colorCompoundBrandBackgroundHover);
65
+ --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandBackgroundHover);
87
66
  }
88
67
 
89
- .root:where(.disabled) {
90
- cursor: default;
91
- color: var(--colorNeutralForegroundDisabled);
92
- --fui-Checkbox__indicator--borderColor: var(--colorNeutralStrokeDisabled);
93
- --fui-Checkbox__indicator--color: var(--colorNeutralForegroundDisabled);
94
- @media (forced-colors: active) {
95
- color: GrayText;
96
- --fui-Checkbox__indicator--color: GrayText;
97
- }
68
+ &:active {
69
+ --fui-Checkbox__indicator--backgroundColor: var(--colorCompoundBrandBackgroundPressed);
70
+ --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandBackgroundPressed);
98
71
  }
72
+ }
99
73
 
100
- .input {
101
- box-sizing: border-box;
102
- cursor: inherit;
103
- height: 100%;
104
- margin: 0;
105
- opacity: 0;
106
- position: absolute;
107
- top: 0;
108
- width: calc(var(--spacingHorizontalL) + 2 * var(--spacingHorizontalS));
74
+ .root:where(.mixed:not(.disabled)) {
75
+ color: var(--colorNeutralForeground1);
76
+ --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandStroke);
77
+ --fui-Checkbox__indicator--color: var(--colorCompoundBrandForeground1);
78
+ &:hover {
79
+ --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandStrokeHover);
80
+ --fui-Checkbox__indicator--color: var(--colorCompoundBrandForeground1Hover);
109
81
  }
110
82
 
111
- :where(.before) > .input {
112
- inset-inline-end: 0;
83
+ &:active {
84
+ --fui-Checkbox__indicator--borderColor: var(--colorCompoundBrandStrokePressed);
85
+ --fui-Checkbox__indicator--color: var(--colorCompoundBrandForeground1Pressed);
113
86
  }
87
+ }
114
88
 
115
- :where(.after) > .input {
116
- inset-inline-start: 0;
89
+ .root:where(.disabled) {
90
+ cursor: default;
91
+ color: var(--colorNeutralForegroundDisabled);
92
+ --fui-Checkbox__indicator--borderColor: var(--colorNeutralStrokeDisabled);
93
+ --fui-Checkbox__indicator--color: var(--colorNeutralForegroundDisabled);
94
+ @media (forced-colors: active) {
95
+ color: GrayText;
96
+ --fui-Checkbox__indicator--color: GrayText;
117
97
  }
98
+ }
118
99
 
119
- :where(.large) > .input {
120
- width: calc(var(--spacingHorizontalXL) + 2 * var(--spacingHorizontalS));
121
- }
100
+ .input {
101
+ box-sizing: border-box;
102
+ cursor: inherit;
103
+ height: 100%;
104
+ margin: 0;
105
+ opacity: 0;
106
+ position: absolute;
107
+ top: 0;
108
+ width: calc(var(--spacingHorizontalL) + 2 * var(--spacingHorizontalS));
109
+ }
122
110
 
123
- .indicator {
124
- align-self: flex-start;
125
- box-sizing: border-box;
126
- flex-shrink: 0;
127
- display: flex;
128
- align-items: center;
129
- justify-content: center;
130
- overflow: hidden;
131
- color: var(--fui-Checkbox__indicator--color);
132
- background-color: var(--fui-Checkbox__indicator--backgroundColor);
133
- border-color: var(--fui-Checkbox__indicator--borderColor, var(--colorNeutralStrokeAccessible));
134
- border-style: solid;
135
- border-width: var(--strokeWidthThin);
136
- border-radius: var(--borderRadiusSmall);
137
- margin: var(--spacingVerticalS) var(--spacingHorizontalS);
138
- fill: currentColor;
139
- pointer-events: none;
140
- font-size: var(--fontSizeBase200);
141
- height: var(--spacingHorizontalL);
142
- width: var(--spacingHorizontalL);
143
- }
111
+ :where(.before) > .input {
112
+ inset-inline-end: 0;
113
+ }
144
114
 
145
- :where(.large) > .indicator {
146
- font-size: var(--fontSizeBase400);
147
- height: var(--spacingHorizontalXL);
148
- width: var(--spacingHorizontalXL);
149
- }
115
+ :where(.after) > .input {
116
+ inset-inline-start: 0;
117
+ }
150
118
 
151
- :where(.circular) > .indicator {
152
- border-radius: var(--borderRadiusCircular);
153
- }
119
+ :where(.large) > .input {
120
+ width: calc(var(--spacingHorizontalXL) + 2 * var(--spacingHorizontalS));
121
+ }
154
122
 
155
- .label {
156
- align-self: center;
157
- color: inherit;
158
- cursor: inherit;
159
- padding: var(--spacingVerticalS) var(--spacingHorizontalS);
160
- }
123
+ .indicator {
124
+ align-self: flex-start;
125
+ box-sizing: border-box;
126
+ flex-shrink: 0;
127
+ display: flex;
128
+ align-items: center;
129
+ justify-content: center;
130
+ overflow: hidden;
131
+ color: var(--fui-Checkbox__indicator--color);
132
+ background-color: var(--fui-Checkbox__indicator--backgroundColor);
133
+ border-color: var(--fui-Checkbox__indicator--borderColor, var(--colorNeutralStrokeAccessible));
134
+ border-style: solid;
135
+ border-width: var(--strokeWidthThin);
136
+ border-radius: var(--borderRadiusSmall);
137
+ margin: var(--spacingVerticalS) var(--spacingHorizontalS);
138
+ fill: currentColor;
139
+ pointer-events: none;
140
+ font-size: var(--fontSizeBase200);
141
+ height: var(--spacingHorizontalL);
142
+ width: var(--spacingHorizontalL);
143
+ }
161
144
 
162
- :where(.before) > .label {
163
- padding-inline-end: var(--spacingHorizontalXS);
164
- }
145
+ :where(.large) > .indicator {
146
+ font-size: var(--fontSizeBase400);
147
+ height: var(--spacingHorizontalXL);
148
+ width: var(--spacingHorizontalXL);
149
+ }
165
150
 
166
- :where(.after) > .label {
167
- padding-inline-start: var(--spacingHorizontalXS);
168
- }
151
+ :where(.circular) > .indicator {
152
+ border-radius: var(--borderRadiusCircular);
153
+ }
169
154
 
170
- :where(.medium) > .label {
171
- margin-top: calc((var(--spacingHorizontalL) - var(--lineHeightBase300)) / 2);
172
- margin-bottom: calc((var(--spacingHorizontalL) - var(--lineHeightBase300)) / 2);
173
- }
155
+ .label {
156
+ align-self: center;
157
+ color: inherit;
158
+ cursor: inherit;
159
+ padding: var(--spacingVerticalS) var(--spacingHorizontalS);
160
+ }
174
161
 
175
- :where(.large) > .label {
176
- margin-top: calc((var(--spacingHorizontalXL) - var(--lineHeightBase300)) / 2);
177
- margin-bottom: calc((var(--spacingHorizontalXL) - var(--lineHeightBase300)) / 2);
178
- }
162
+ :where(.before) > .label {
163
+ padding-inline-end: var(--spacingHorizontalXS);
164
+ }
165
+
166
+ :where(.after) > .label {
167
+ padding-inline-start: var(--spacingHorizontalXS);
168
+ }
169
+
170
+ :where(.medium) > .label {
171
+ margin-top: calc((var(--spacingHorizontalL) - var(--lineHeightBase300)) / 2);
172
+ margin-bottom: calc((var(--spacingHorizontalL) - var(--lineHeightBase300)) / 2);
173
+ }
174
+
175
+ :where(.large) > .label {
176
+ margin-top: calc((var(--spacingHorizontalXL) - var(--lineHeightBase300)) / 2);
177
+ margin-bottom: calc((var(--spacingHorizontalXL) - var(--lineHeightBase300)) / 2);
179
178
  }
@@ -27,6 +27,10 @@ const _reacttabster = require("@fluentui/react-tabster");
27
27
  const useCheckbox_unstable = (props, ref)=>{
28
28
  const { shape = 'square', size = 'medium', ...checkboxProps } = props;
29
29
  const state = useCheckboxBase_unstable(checkboxProps, ref);
30
+ // Focus-within ref drives the styled focus outline; applied here rather than in the base hook
31
+ // so the base hook does not depend on react-tabster (keyborg).
32
+ // eslint-disable-next-line react-hooks/immutability
33
+ state.root.ref = (0, _reactutilities.useMergedRefs)(state.root.ref, (0, _reacttabster.useFocusWithin)());
30
34
  // Override indicator children with size+shape-appropriate icon
31
35
  const mixed = state.checked === 'mixed';
32
36
  let checkmarkIcon;
@@ -96,10 +100,7 @@ const useCheckboxBase_unstable = (props, ref)=>{
96
100
  label: 'label'
97
101
  },
98
102
  root: _reactutilities.slot.always(props.root, {
99
- defaultProps: {
100
- ref: (0, _reacttabster.useFocusWithin)(),
101
- ...nativeProps.root
102
- },
103
+ defaultProps: nativeProps.root,
103
104
  elementType: 'span'
104
105
  }),
105
106
  input: _reactutilities.slot.always(props.input, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Checkbox/useCheckbox.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport {\n getPartitionedNativeProps,\n useControllableState,\n mergeCallbacks,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n slot,\n} from '@fluentui/react-utilities';\nimport type { CheckboxBaseProps, CheckboxBaseState, 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';\nimport { useFocusWithin } from '@fluentui/react-tabster';\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 { shape = 'square', size = 'medium', ...checkboxProps } = props;\n\n const state = useCheckboxBase_unstable(checkboxProps, ref);\n\n // Override indicator children with size+shape-appropriate icon\n const mixed = state.checked === 'mixed';\n let checkmarkIcon;\n if (mixed) {\n if (shape === 'circular') {\n checkmarkIcon = <CircleFilled />;\n } else {\n checkmarkIcon = size === 'large' ? <Square16Filled /> : <Square12Filled />;\n }\n } else if (state.checked) {\n checkmarkIcon = size === 'large' ? <Checkmark16Filled /> : <Checkmark12Filled />;\n }\n\n if (state.indicator) {\n state.indicator.children ??= checkmarkIcon;\n }\n\n return {\n shape,\n size,\n ...state,\n components: {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ...state.components,\n label: Label,\n },\n label: slot.optional(props.label, {\n defaultProps: {\n ...state.label,\n size: 'medium',\n },\n elementType: Label,\n }),\n };\n};\n\n/**\n * Base hook for Checkbox component, which manages state related to checked state, ARIA attributes,\n * focus management, and slot structure without design props.\n *\n * @param props - props from this instance of Checkbox\n * @param ref - reference to `<input>` element of Checkbox\n */\nexport const useCheckboxBase_unstable = (\n props: CheckboxBaseProps,\n ref: React.Ref<HTMLInputElement>,\n): CheckboxBaseState => {\n 'use no memo'; // justified: compiler would optimize useCheckboxBase_unstable — manual opt-out to preserve runtime behavior\n\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, { supportsLabelFor: true, supportsRequired: true });\n\n const { disabled = false, required, 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', 'onChange'],\n });\n\n const mixed = checked === 'mixed';\n const id = useId('checkbox-', nativeProps.primary.id);\n\n const state: CheckboxBaseState = {\n checked,\n disabled,\n labelPosition,\n components: {\n root: 'span',\n input: 'input',\n indicator: 'div',\n label: 'label',\n },\n root: slot.always(props.root, {\n defaultProps: {\n ref: useFocusWithin<HTMLSpanElement>(),\n ...nativeProps.root,\n },\n elementType: 'span',\n }),\n input: slot.always(props.input, {\n defaultProps: {\n type: 'checkbox',\n id,\n ref,\n checked: checked === true,\n ...nativeProps.primary,\n },\n elementType: 'input',\n }),\n label: slot.optional(props.label, {\n defaultProps: {\n htmlFor: id,\n disabled,\n required,\n },\n elementType: 'label',\n }),\n indicator: slot.optional(props.indicator, {\n renderByDefault: true,\n defaultProps: {\n 'aria-hidden': true,\n },\n elementType: 'div',\n }),\n };\n\n state.input.onChange = mergeCallbacks(state.input.onChange, 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"],"names":["React","useFieldControlProps_unstable","getPartitionedNativeProps","useControllableState","mergeCallbacks","useId","useIsomorphicLayoutEffect","useMergedRefs","slot","Checkmark12Filled","Checkmark16Filled","Square12Filled","Square16Filled","CircleFilled","Label","useFocusWithin","useCheckbox_unstable","props","ref","shape","size","checkboxProps","state","useCheckboxBase_unstable","mixed","checked","checkmarkIcon","indicator","children","components","label","optional","defaultProps","elementType","supportsLabelFor","supportsRequired","disabled","required","labelPosition","onChange","setChecked","defaultState","defaultChecked","initialState","nativeProps","primarySlotTagName","excludedPropNames","id","primary","root","input","always","type","htmlFor","renderByDefault","ev","val","currentTarget","indeterminate","inputRef","current"],"mappings":"AAAA;;;;;;;;;;;;QAiFauB;;;QAhDAP;;;;;iEA/BU,QAAQ;4BACe,wBAAwB;gCAS/D,4BAA4B;4BAQ5B,wBAAwB;4BACT,wBAAwB;8BACf,0BAA0B;AAWlD,6BAA6B,CAACC,OAAsBC;IACzD,MAAM,EAAEC,QAAQ,QAAQ,EAAEC,OAAO,QAAQ,EAAE,GAAGC,eAAe,GAAGJ;IAEhE,MAAMK,QAAQC,yBAAyBF,eAAeH;IAEtD,+DAA+D;IAC/D,MAAMM,QAAQF,MAAMG,OAAO,KAAK;IAChC,IAAIC;IACJ,IAAIF,OAAO;QACT,IAAIL,UAAU,YAAY;YACxBO,gBAAAA,WAAAA,GAAgB,OAAA,aAAA,CAACb,wBAAAA,EAAAA;QACnB,OAAO;YACLa,gBAAgBN,SAAS,UAAA,WAAA,GAAU,OAAA,aAAA,CAACR,0BAAAA,EAAAA,QAAAA,WAAAA,GAAoB,OAAA,aAAA,CAACD,0BAAAA,EAAAA;QAC3D;IACF,OAAO,IAAIW,MAAMG,OAAO,EAAE;QACxBC,gBAAgBN,SAAS,UAAA,WAAA,GAAU,OAAA,aAAA,CAACV,6BAAAA,EAAAA,QAAAA,WAAAA,GAAuB,OAAA,aAAA,CAACD,6BAAAA,EAAAA;IAC9D;IAEA,IAAIa,MAAMK,SAAS,EAAE;YACnBL,kBAAAA;SAAAA,YAAAA,CAAAA,mBAAAA,MAAMK,SAAAA,AAAS,EAACC,QAAAA,AAAQ,MAAA,QAAxBN,cAAAA,KAAAA,IAAAA,YAAAA,iBAAgBM,QAAQ,GAAKF;IAC/B;IAEA,OAAO;QACLP;QACAC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7B;gBACAO,SAASA,YAAY;gBACrB,GAAGmB,YAAYI,OAAO;YACxB;YACAf,aAAa;QACf;QACAH,OAAOtB,oBAAAA,CAAKuB,QAAQ,CAACd,MAAMa,KAAK,EAAE;YAChCE,cAAc;gBACZqB,SAASN;gBACTX;gBACAC;YACF;YACAJ,aAAa;QACf;QACAN,WAAWnB,oBAAAA,CAAKuB,QAAQ,CAACd,MAAMU,SAAS,EAAE;YACxC2B,iBAAiB;YACjBtB,cAAc;gBACZ,eAAe;YACjB;YACAC,aAAa;QACf;IACF;IAEAX,MAAM4B,KAAK,CAACX,QAAQ,OAAGnC,8BAAAA,EAAekB,MAAM4B,KAAK,CAACX,QAAQ,EAAEgB,CAAAA;QAC1D,MAAMC,MAAMD,GAAGE,aAAa,CAACC,aAAa,GAAG,UAAUH,GAAGE,aAAa,CAAChC,OAAO;QAC/Ec,aAAAA,QAAAA,aAAAA,KAAAA,IAAAA,KAAAA,IAAAA,SAAWgB,IAAI;YAAE9B,SAAS+B;QAAI;QAC9BhB,WAAWgB;IACb;IAEA,4FAA4F;IAC5F,sFAAsF;IACtF,MAAMG,eAAWpD,6BAAAA,EAAce,MAAM4B,KAAK,CAAChC,GAAG;IAC9CI,MAAM4B,KAAK,CAAChC,GAAG,GAAGyC;IAElB,kGAAkG;IAClG,4FAA4F;QAC5FrD,yCAAAA,EAA0B;QACxB,IAAIqD,SAASC,OAAO,EAAE;YACpBD,SAASC,OAAO,CAACF,aAAa,GAAGlC;QACnC;IACF,GAAG;QAACmC;QAAUnC;KAAM;IAEpB,OAAOF;AACT,EAAE"}
1
+ {"version":3,"sources":["../../../src/components/Checkbox/useCheckbox.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport {\n getPartitionedNativeProps,\n useControllableState,\n mergeCallbacks,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n slot,\n} from '@fluentui/react-utilities';\nimport type { CheckboxBaseProps, CheckboxBaseState, 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';\nimport { useFocusWithin } from '@fluentui/react-tabster';\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 { shape = 'square', size = 'medium', ...checkboxProps } = props;\n\n const state = useCheckboxBase_unstable(checkboxProps, ref);\n\n // Focus-within ref drives the styled focus outline; applied here rather than in the base hook\n // so the base hook does not depend on react-tabster (keyborg).\n // eslint-disable-next-line react-hooks/immutability\n state.root.ref = useMergedRefs(state.root.ref, useFocusWithin<HTMLSpanElement>());\n\n // Override indicator children with size+shape-appropriate icon\n const mixed = state.checked === 'mixed';\n let checkmarkIcon;\n if (mixed) {\n if (shape === 'circular') {\n checkmarkIcon = <CircleFilled />;\n } else {\n checkmarkIcon = size === 'large' ? <Square16Filled /> : <Square12Filled />;\n }\n } else if (state.checked) {\n checkmarkIcon = size === 'large' ? <Checkmark16Filled /> : <Checkmark12Filled />;\n }\n\n if (state.indicator) {\n state.indicator.children ??= checkmarkIcon;\n }\n\n return {\n shape,\n size,\n ...state,\n components: {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ...state.components,\n label: Label,\n },\n label: slot.optional(props.label, {\n defaultProps: {\n ...state.label,\n size: 'medium',\n },\n elementType: Label,\n }),\n };\n};\n\n/**\n * Base hook for Checkbox component, which manages state related to checked state, ARIA attributes,\n * and slot structure without design props or focus management.\n *\n * @param props - props from this instance of Checkbox\n * @param ref - reference to `<input>` element of Checkbox\n */\nexport const useCheckboxBase_unstable = (\n props: CheckboxBaseProps,\n ref: React.Ref<HTMLInputElement>,\n): CheckboxBaseState => {\n 'use no memo'; // justified: compiler would optimize useCheckboxBase_unstable — manual opt-out to preserve runtime behavior\n\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, { supportsLabelFor: true, supportsRequired: true });\n\n const { disabled = false, required, 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', 'onChange'],\n });\n\n const mixed = checked === 'mixed';\n const id = useId('checkbox-', nativeProps.primary.id);\n\n const state: CheckboxBaseState = {\n checked,\n disabled,\n labelPosition,\n components: {\n root: 'span',\n input: 'input',\n indicator: 'div',\n label: 'label',\n },\n root: slot.always(props.root, {\n defaultProps: nativeProps.root,\n elementType: 'span',\n }),\n input: slot.always(props.input, {\n defaultProps: {\n type: 'checkbox',\n id,\n ref,\n checked: checked === true,\n ...nativeProps.primary,\n },\n elementType: 'input',\n }),\n label: slot.optional(props.label, {\n defaultProps: {\n htmlFor: id,\n disabled,\n required,\n },\n elementType: 'label',\n }),\n indicator: slot.optional(props.indicator, {\n renderByDefault: true,\n defaultProps: {\n 'aria-hidden': true,\n },\n elementType: 'div',\n }),\n };\n\n state.input.onChange = mergeCallbacks(state.input.onChange, 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"],"names":["React","useFieldControlProps_unstable","getPartitionedNativeProps","useControllableState","mergeCallbacks","useId","useIsomorphicLayoutEffect","useMergedRefs","slot","Checkmark12Filled","Checkmark16Filled","Square12Filled","Square16Filled","CircleFilled","Label","useFocusWithin","useCheckbox_unstable","props","ref","shape","size","checkboxProps","state","useCheckboxBase_unstable","root","mixed","checked","checkmarkIcon","indicator","children","components","label","optional","defaultProps","elementType","supportsLabelFor","supportsRequired","disabled","required","labelPosition","onChange","setChecked","defaultState","defaultChecked","initialState","nativeProps","primarySlotTagName","excludedPropNames","id","primary","input","always","type","htmlFor","renderByDefault","ev","val","currentTarget","indeterminate","inputRef","current"],"mappings":"AAAA;;;;;;;;;;;;QAsFauB;;;QArDAP;;;;;iEA/BU,QAAQ;4BACe,wBAAwB;gCAS/D,4BAA4B;4BAQ5B,wBAAwB;4BACT,wBAAwB;8BACf,0BAA0B;AAWlD,6BAA6B,CAACC,OAAsBC;IACzD,MAAM,EAAEC,QAAQ,QAAQ,EAAEC,OAAO,QAAQ,EAAE,GAAGC,eAAe,GAAGJ;IAEhE,MAAMK,QAAQC,yBAAyBF,eAAeH;IAEtD,8FAA8F;IAC9F,+DAA+D;IAC/D,oDAAoD;IACpDI,MAAME,IAAI,CAACN,GAAG,OAAGX,6BAAAA,EAAce,MAAME,IAAI,CAACN,GAAG,MAAEH,4BAAAA;IAE/C,+DAA+D;IAC/D,MAAMU,QAAQH,MAAMI,OAAO,KAAK;IAChC,IAAIC;IACJ,IAAIF,OAAO;QACT,IAAIN,UAAU,YAAY;YACxBQ,gBAAAA,WAAAA,GAAgB,OAAA,aAAA,CAACd,wBAAAA,EAAAA;QACnB,OAAO;YACLc,gBAAgBP,SAAS,UAAA,WAAA,GAAU,OAAA,aAAA,CAACR,0BAAAA,EAAAA,QAAAA,WAAAA,GAAoB,OAAA,aAAA,CAACD,0BAAAA,EAAAA;QAC3D;IACF,OAAO,IAAIW,MAAMI,OAAO,EAAE;QACxBC,gBAAgBP,SA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lC;KAAM;IAEpB,OAAOH;AACT,EAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-checkbox",
3
- "version": "9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0",
3
+ "version": "9.75.2-experimental.css-modules.20261113-ba13c87438.0",
4
4
  "description": "Fluent UI checkbox component",
5
5
  "main": "lib-commonjs/index.cjs",
6
6
  "module": "lib/index.js",
@@ -14,14 +14,14 @@
14
14
  },
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
- "@fluentui/react-field": "9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0",
17
+ "@fluentui/react-field": "9.75.2-experimental.css-modules.20261113-ba13c87438.0",
18
18
  "@fluentui/react-icons": "^2.0.245",
19
- "@fluentui/react-jsx-runtime": "9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0",
20
- "@fluentui/react-label": "9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0",
21
- "@fluentui/react-shared-contexts": "9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0",
22
- "@fluentui/react-tabster": "9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0",
23
- "@fluentui/react-theme": "9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0",
24
- "@fluentui/react-utilities": "9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0",
19
+ "@fluentui/react-jsx-runtime": "9.75.2-experimental.css-modules.20261113-ba13c87438.0",
20
+ "@fluentui/react-label": "9.75.2-experimental.css-modules.20261113-ba13c87438.0",
21
+ "@fluentui/react-shared-contexts": "9.75.2-experimental.css-modules.20261113-ba13c87438.0",
22
+ "@fluentui/react-tabster": "9.75.2-experimental.css-modules.20261113-ba13c87438.0",
23
+ "@fluentui/react-theme": "9.75.2-experimental.css-modules.20261113-ba13c87438.0",
24
+ "@fluentui/react-utilities": "9.75.2-experimental.css-modules.20261113-ba13c87438.0",
25
25
  "@griffel/react": "^1.5.32",
26
26
  "@swc/helpers": "^0.5.1",
27
27
  "clsx": "^2.1.1"