@fluentui/react-checkbox 9.0.19 → 9.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +57 -1
- package/CHANGELOG.md +23 -2
- package/dist/index.d.ts +1 -1
- package/lib/components/Checkbox/Checkbox.types.js.map +1 -1
- package/lib/components/Checkbox/useCheckbox.js +2 -1
- package/lib/components/Checkbox/useCheckbox.js.map +1 -1
- package/lib/components/Checkbox/useCheckboxStyles.js +81 -6
- package/lib/components/Checkbox/useCheckboxStyles.js.map +1 -1
- package/lib-amd/components/Checkbox/Checkbox.types.js.map +1 -1
- package/lib-amd/components/Checkbox/useCheckbox.js +4 -3
- package/lib-amd/components/Checkbox/useCheckbox.js.map +1 -1
- package/lib-amd/components/Checkbox/useCheckboxStyles.js +60 -97
- package/lib-amd/components/Checkbox/useCheckboxStyles.js.map +1 -1
- package/lib-commonjs/components/Checkbox/useCheckbox.js +2 -1
- package/lib-commonjs/components/Checkbox/useCheckbox.js.map +1 -1
- package/lib-commonjs/components/Checkbox/useCheckboxStyles.js +81 -6
- package/lib-commonjs/components/Checkbox/useCheckboxStyles.js.map +1 -1
- package/package.json +6 -5
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,63 @@
|
|
|
2
2
|
"name": "@fluentui/react-checkbox",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Wed, 18 Jan 2023 16:30:58 GMT",
|
|
6
|
+
"tag": "@fluentui/react-checkbox_v9.0.21",
|
|
7
|
+
"version": "9.0.21",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "beachball",
|
|
12
|
+
"package": "@fluentui/react-checkbox",
|
|
13
|
+
"comment": "Bump @fluentui/react-tabster to v9.4.0",
|
|
14
|
+
"commit": "13cf1d07a6df4617106c731ba0379b6102a08104"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Mon, 16 Jan 2023 08:38:56 GMT",
|
|
21
|
+
"tag": "@fluentui/react-checkbox_v9.0.20",
|
|
22
|
+
"version": "9.0.20",
|
|
23
|
+
"comments": {
|
|
24
|
+
"none": [
|
|
25
|
+
{
|
|
26
|
+
"author": "martinhochel@microsoft.com",
|
|
27
|
+
"package": "@fluentui/react-checkbox",
|
|
28
|
+
"commit": "64bb45980d68de1219c6b36a7db5363f0a9cff9f",
|
|
29
|
+
"comment": "chore: migrate to packaged scripts"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"patch": [
|
|
33
|
+
{
|
|
34
|
+
"author": "behowell@microsoft.com",
|
|
35
|
+
"package": "@fluentui/react-checkbox",
|
|
36
|
+
"commit": "0a301bd88ae273175661eda0eae8a0e9e48d62ec",
|
|
37
|
+
"comment": "chore: Simplify Checkbox style selectors using component checked/disabled state"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"author": "beachball",
|
|
41
|
+
"package": "@fluentui/react-checkbox",
|
|
42
|
+
"comment": "Bump @fluentui/react-field to v9.0.0-alpha.15",
|
|
43
|
+
"commit": "a870d8360e47f3ea03358c4e75e89e08a74845d7"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"author": "beachball",
|
|
47
|
+
"package": "@fluentui/react-checkbox",
|
|
48
|
+
"comment": "Bump @fluentui/react-label to v9.0.17",
|
|
49
|
+
"commit": "a870d8360e47f3ea03358c4e75e89e08a74845d7"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"author": "beachball",
|
|
53
|
+
"package": "@fluentui/react-checkbox",
|
|
54
|
+
"comment": "Bump @fluentui/react-tabster to v9.3.7",
|
|
55
|
+
"commit": "a870d8360e47f3ea03358c4e75e89e08a74845d7"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"date": "Mon, 09 Jan 2023 21:51:23 GMT",
|
|
6
62
|
"tag": "@fluentui/react-checkbox_v9.0.19",
|
|
7
63
|
"version": "9.0.19",
|
|
8
64
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,33 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-checkbox
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 18 Jan 2023 16:30:58 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.0.21](https://github.com/microsoft/fluentui/tree/@fluentui/react-checkbox_v9.0.21)
|
|
8
|
+
|
|
9
|
+
Wed, 18 Jan 2023 16:30:58 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-checkbox_v9.0.20..@fluentui/react-checkbox_v9.0.21)
|
|
11
|
+
|
|
12
|
+
### Patches
|
|
13
|
+
|
|
14
|
+
- Bump @fluentui/react-tabster to v9.4.0 ([PR #26377](https://github.com/microsoft/fluentui/pull/26377) by beachball)
|
|
15
|
+
|
|
16
|
+
## [9.0.20](https://github.com/microsoft/fluentui/tree/@fluentui/react-checkbox_v9.0.20)
|
|
17
|
+
|
|
18
|
+
Mon, 16 Jan 2023 08:38:56 GMT
|
|
19
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-checkbox_v9.0.19..@fluentui/react-checkbox_v9.0.20)
|
|
20
|
+
|
|
21
|
+
### Patches
|
|
22
|
+
|
|
23
|
+
- chore: Simplify Checkbox style selectors using component checked/disabled state ([PR #26247](https://github.com/microsoft/fluentui/pull/26247) by behowell@microsoft.com)
|
|
24
|
+
- Bump @fluentui/react-field to v9.0.0-alpha.15 ([commit](https://github.com/microsoft/fluentui/commit/a870d8360e47f3ea03358c4e75e89e08a74845d7) by beachball)
|
|
25
|
+
- Bump @fluentui/react-label to v9.0.17 ([commit](https://github.com/microsoft/fluentui/commit/a870d8360e47f3ea03358c4e75e89e08a74845d7) by beachball)
|
|
26
|
+
- Bump @fluentui/react-tabster to v9.3.7 ([commit](https://github.com/microsoft/fluentui/commit/a870d8360e47f3ea03358c4e75e89e08a74845d7) by beachball)
|
|
27
|
+
|
|
7
28
|
## [9.0.19](https://github.com/microsoft/fluentui/tree/@fluentui/react-checkbox_v9.0.19)
|
|
8
29
|
|
|
9
|
-
Mon, 09 Jan 2023 21:
|
|
30
|
+
Mon, 09 Jan 2023 21:51:23 GMT
|
|
10
31
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-checkbox_v9.0.18..@fluentui/react-checkbox_v9.0.19)
|
|
11
32
|
|
|
12
33
|
### Patches
|
package/dist/index.d.ts
CHANGED
|
@@ -115,7 +115,7 @@ export declare type CheckboxSlots = {
|
|
|
115
115
|
/**
|
|
116
116
|
* State used in rendering Checkbox
|
|
117
117
|
*/
|
|
118
|
-
export declare type CheckboxState = ComponentState<CheckboxSlots> & Required<Pick<CheckboxProps, 'checked' | 'labelPosition' | 'shape' | 'size'>>;
|
|
118
|
+
export declare type CheckboxState = ComponentState<CheckboxSlots> & Required<Pick<CheckboxProps, 'checked' | 'disabled' | 'labelPosition' | 'shape' | 'size'>>;
|
|
119
119
|
|
|
120
120
|
export declare const renderCheckbox_unstable: (state: CheckboxState) => JSX.Element;
|
|
121
121
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.types.js","sourceRoot":"../src/","sources":["packages/react-components/react-checkbox/src/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\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 'checked' | 'defaultChecked' | 'onChange' | 'size'\n> & {\n /**\n * The controlled value for the checkbox.\n *\n * @default false\n */\n checked?: 'mixed' | boolean;\n\n /**\n * Checkboxes don't support children. To add a label, use the `label` prop.\n */\n children?: never;\n\n /**\n * Whether the checkbox should be rendered as checked by default.\n */\n defaultChecked?: 'mixed' | boolean;\n\n /**\n * The position of the label relative to the checkbox indicator.\n *\n * @default after\n */\n labelPosition?: 'before' | 'after';\n\n /**\n * Callback to be called when the checked state value changes.\n */\n onChange?: (ev: React.ChangeEvent<HTMLInputElement>, data: CheckboxOnChangeData) => void;\n\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 * @default square\n */\n shape?: 'square' | 'circular';\n\n /**\n * The size of the checkbox indicator.\n *\n * @default medium\n */\n size?: 'medium' | 'large';\n};\n\n/**\n * Data for the onChange event for checkbox.\n */\nexport interface CheckboxOnChangeData {\n checked: 'mixed' | boolean;\n}\n\n/**\n * State used in rendering Checkbox\n */\nexport type CheckboxState = ComponentState<CheckboxSlots> &\n Required<Pick<CheckboxProps, 'checked' | 'labelPosition' | 'shape' | 'size'>>;\n"]}
|
|
1
|
+
{"version":3,"file":"Checkbox.types.js","sourceRoot":"../src/","sources":["packages/react-components/react-checkbox/src/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\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 'checked' | 'defaultChecked' | 'onChange' | 'size'\n> & {\n /**\n * The controlled value for the checkbox.\n *\n * @default false\n */\n checked?: 'mixed' | boolean;\n\n /**\n * Checkboxes don't support children. To add a label, use the `label` prop.\n */\n children?: never;\n\n /**\n * Whether the checkbox should be rendered as checked by default.\n */\n defaultChecked?: 'mixed' | boolean;\n\n /**\n * The position of the label relative to the checkbox indicator.\n *\n * @default after\n */\n labelPosition?: 'before' | 'after';\n\n /**\n * Callback to be called when the checked state value changes.\n */\n onChange?: (ev: React.ChangeEvent<HTMLInputElement>, data: CheckboxOnChangeData) => void;\n\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 * @default square\n */\n shape?: 'square' | 'circular';\n\n /**\n * The size of the checkbox indicator.\n *\n * @default medium\n */\n size?: 'medium' | 'large';\n};\n\n/**\n * Data for the onChange event for checkbox.\n */\nexport interface CheckboxOnChangeData {\n checked: 'mixed' | boolean;\n}\n\n/**\n * State used in rendering Checkbox\n */\nexport type CheckboxState = ComponentState<CheckboxSlots> &\n Required<Pick<CheckboxProps, 'checked' | 'disabled' | 'labelPosition' | 'shape' | 'size'>>;\n"]}
|
|
@@ -14,7 +14,7 @@ import { useFocusWithin } from '@fluentui/react-tabster';
|
|
|
14
14
|
*/
|
|
15
15
|
export const useCheckbox_unstable = (props, ref) => {
|
|
16
16
|
const {
|
|
17
|
-
disabled,
|
|
17
|
+
disabled = false,
|
|
18
18
|
required,
|
|
19
19
|
shape = 'square',
|
|
20
20
|
size = 'medium',
|
|
@@ -46,6 +46,7 @@ export const useCheckbox_unstable = (props, ref) => {
|
|
|
46
46
|
const state = {
|
|
47
47
|
shape,
|
|
48
48
|
checked,
|
|
49
|
+
disabled,
|
|
49
50
|
size,
|
|
50
51
|
labelPosition,
|
|
51
52
|
components: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SACEC,yBAAyB,EACzBC,gBAAgB,EAChBC,oBAAoB,EACpBC,gBAAgB,EAChBC,KAAK,EACLC,yBAAyB,EACzBC,aAAa,QACR,2BAA2B;AAElC,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,cAAc,EACdC,cAAc,EACdC,YAAY,QACP,uBAAuB;AAC9B,SAASC,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,cAAc,QAAQ,yBAAyB;AAExD;;;;;;;;;AASA,OAAO,MAAMC,oBAAoB,GAAG,CAACC,KAAoB,EAAEC,GAAgC,KAAmB;EAC5G,MAAM;IAAEC,QAAQ;IAAEC,QAAQ;IAAEC,KAAK,GAAG,QAAQ;IAAEC,IAAI,GAAG,QAAQ;IAAEC,aAAa,GAAG,OAAO;IAAEC;EAAQ,CAAE,GAAGP,KAAK;
|
|
1
|
+
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SACEC,yBAAyB,EACzBC,gBAAgB,EAChBC,oBAAoB,EACpBC,gBAAgB,EAChBC,KAAK,EACLC,yBAAyB,EACzBC,aAAa,QACR,2BAA2B;AAElC,SACEC,iB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AAGuB,EAAE,EAAE;MAAEtB,OAAO,EAAEuB;IAAG,CAAE,CAAC;IAChCtB,UAAU,CAACsB,GAAG,CAAC;EACjB,CAAC,CAAC;EAEF;EACA;EACA,MAAMG,QAAQ,GAAG3C,aAAa,CAACqB,KAAK,CAACW,KAAK,CAACtB,GAAG,CAAC;EAC/CW,KAAK,CAACW,KAAK,CAACtB,GAAG,GAAGiC,QAAQ;EAE1B;EACA;EACA5C,yBAAyB,CAAC,MAAK;IAC7B,IAAI4C,QAAQ,CAACC,OAAO,EAAE;MACpBD,QAAQ,CAACC,OAAO,CAACF,aAAa,GAAGhB,KAAK;;EAE1C,CAAC,EAAE,CAACiB,QAAQ,EAAEjB,KAAK,CAAC,CAAC;EAErB,OAAOL,KAAK;AACd,CAAC","names":["React","getPartitionedNativeProps","resolveShorthand","useControllableState","useEventCallback","useId","useIsomorphicLayoutEffect","useMergedRefs","Checkmark12Filled","Checkmark16Filled","Square12Filled","Square16Filled","CircleFilled","Label","useFocusWithin","useCheckbox_unstable","props","ref","disabled","required","shape","size","labelPosition","onChange","checked","setChecked","defaultState","defaultChecked","state","initialState","nativeProps","primarySlotTagName","excludedPropNames","mixed","id","primary","checkmarkIcon","components","root","input","indicator","label","defaultProps","type","htmlFor","children","ev","val","currentTarget","indeterminate","inputRef","current"],"sourceRoot":"../src/","sources":["packages/react-components/react-checkbox/src/components/Checkbox/useCheckbox.tsx"],"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';\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 { disabled = false, 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 if (checked) {\n checkmarkIcon = size === 'large' ? <Checkmark16Filled /> : <Checkmark12Filled />;\n }\n\n const state: CheckboxState = {\n shape,\n checked,\n disabled,\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: {\n ref: useFocusWithin<HTMLSpanElement>(),\n ...nativeProps.root,\n },\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"]}
|
|
@@ -10,8 +10,79 @@ export const checkboxClassNames = {
|
|
|
10
10
|
// The indicator size is used by the indicator and label styles
|
|
11
11
|
const indicatorSizeMedium = '16px';
|
|
12
12
|
const indicatorSizeLarge = '20px';
|
|
13
|
-
const useRootBaseClassName = /*#__PURE__*/__resetStyles("
|
|
14
|
-
const
|
|
13
|
+
const useRootBaseClassName = /*#__PURE__*/__resetStyles("ripp6we", "r1b86e4p", [".ripp6we{position:relative;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;cursor:pointer;color:var(--colorNeutralForeground3);}", ".ripp6we:focus{outline-style:none;}", ".ripp6we:focus-visible{outline-style:none;}", ".ripp6we[data-fui-focus-within]:focus-within{border-top-color:transparent;border-right-color:transparent;border-bottom-color:transparent;border-left-color:transparent;}", ".ripp6we[data-fui-focus-within]:focus-within::after{content:\"\";position:absolute;pointer-events:none;z-index:1;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-width:2px;border-right-width:2px;border-bottom-width:2px;border-left-width:2px;border-bottom-right-radius:var(--borderRadiusMedium);border-bottom-left-radius:var(--borderRadiusMedium);border-top-right-radius:var(--borderRadiusMedium);border-top-left-radius:var(--borderRadiusMedium);border-top-color:var(--colorStrokeFocus2);border-right-color:var(--colorStrokeFocus2);border-bottom-color:var(--colorStrokeFocus2);border-left-color:var(--colorStrokeFocus2);top:-2px;bottom:-2px;left:-2px;right:-2px;}", ".r1b86e4p{position:relative;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;cursor:pointer;color:var(--colorNeutralForeground3);}", ".r1b86e4p:focus{outline-style:none;}", ".r1b86e4p:focus-visible{outline-style:none;}", ".r1b86e4p[data-fui-focus-within]:focus-within{border-top-color:transparent;border-left-color:transparent;border-bottom-color:transparent;border-right-color:transparent;}", ".r1b86e4p[data-fui-focus-within]:focus-within::after{content:\"\";position:absolute;pointer-events:none;z-index:1;border-top-style:solid;border-left-style:solid;border-bottom-style:solid;border-right-style:solid;border-top-width:2px;border-left-width:2px;border-bottom-width:2px;border-right-width:2px;border-bottom-left-radius:var(--borderRadiusMedium);border-bottom-right-radius:var(--borderRadiusMedium);border-top-left-radius:var(--borderRadiusMedium);border-top-right-radius:var(--borderRadiusMedium);border-top-color:var(--colorStrokeFocus2);border-left-color:var(--colorStrokeFocus2);border-bottom-color:var(--colorStrokeFocus2);border-right-color:var(--colorStrokeFocus2);top:-2px;bottom:-2px;right:-2px;left:-2px;}"]);
|
|
14
|
+
const useRootStyles = /*#__PURE__*/__styles({
|
|
15
|
+
unchecked: {
|
|
16
|
+
Bi91k9c: "f3p8bqa",
|
|
17
|
+
ns3gzv: "ffqb913",
|
|
18
|
+
n5iecx: ["f42z0vd", "f1j37kh1"],
|
|
19
|
+
Bq2lx2j: "f10v6cc1",
|
|
20
|
+
Bv7p3up: ["f1j37kh1", "f42z0vd"],
|
|
21
|
+
lj723h: "f1r2dosr",
|
|
22
|
+
B6u2zzw: "f1oarbgq",
|
|
23
|
+
Be5wueo: ["fo8gord", "f18ci1af"],
|
|
24
|
+
Cgwcxn: "fviagcr",
|
|
25
|
+
Btnvhkj: ["f18ci1af", "fo8gord"]
|
|
26
|
+
},
|
|
27
|
+
checked: {
|
|
28
|
+
sj55zd: "f19n0e5",
|
|
29
|
+
Bvs3sgl: "f5opsb9",
|
|
30
|
+
opw9sb: "fpaw01r",
|
|
31
|
+
C5wppx: "f1gqj827",
|
|
32
|
+
B32epof: ["fub94a2", "f13mj44e"],
|
|
33
|
+
Bphahg7: "f1qq5vh1",
|
|
34
|
+
Jctw66: ["f13mj44e", "fub94a2"],
|
|
35
|
+
Bq0zqd5: "f5x9vvn",
|
|
36
|
+
ns3gzv: "fub8hyy",
|
|
37
|
+
n5iecx: ["fffzknn", "f172bh4s"],
|
|
38
|
+
Bq2lx2j: "f6tipb1",
|
|
39
|
+
Bv7p3up: ["f172bh4s", "fffzknn"],
|
|
40
|
+
Bgesukf: "f8adco2",
|
|
41
|
+
B6u2zzw: "f1lepnt8",
|
|
42
|
+
Be5wueo: ["f80ygm0", "frrkusm"],
|
|
43
|
+
Cgwcxn: "f1gg953z",
|
|
44
|
+
Btnvhkj: ["frrkusm", "f80ygm0"]
|
|
45
|
+
},
|
|
46
|
+
mixed: {
|
|
47
|
+
sj55zd: "f19n0e5",
|
|
48
|
+
C5wppx: "f12fgbth",
|
|
49
|
+
B32epof: ["f171e6fm", "fttsnhr"],
|
|
50
|
+
Bphahg7: "f1fyk1ks",
|
|
51
|
+
Jctw66: ["fttsnhr", "f171e6fm"],
|
|
52
|
+
opw9sb: "fvvg2h8",
|
|
53
|
+
ns3gzv: "f1nlwys0",
|
|
54
|
+
n5iecx: ["f1bhstg2", "f6tsdgz"],
|
|
55
|
+
Bq2lx2j: "fqxbw9v",
|
|
56
|
+
Bv7p3up: ["f6tsdgz", "f1bhstg2"],
|
|
57
|
+
cc1l3s: "f1r38qqt",
|
|
58
|
+
B6u2zzw: "f12q3i2l",
|
|
59
|
+
Be5wueo: ["f9g1hxu", "f1o4ic5t"],
|
|
60
|
+
Cgwcxn: "f1c3thm1",
|
|
61
|
+
Btnvhkj: ["f1o4ic5t", "f9g1hxu"],
|
|
62
|
+
km5s60: "ffd07pq"
|
|
63
|
+
},
|
|
64
|
+
disabled: {
|
|
65
|
+
Bceei9c: "f158kwzp",
|
|
66
|
+
sj55zd: "f1s2aq7o",
|
|
67
|
+
C5wppx: "fgiuqeu",
|
|
68
|
+
B32epof: ["f1q4sfkt", "f71co73"],
|
|
69
|
+
Bphahg7: "f1u7lsiy",
|
|
70
|
+
Jctw66: ["f71co73", "f1q4sfkt"],
|
|
71
|
+
opw9sb: "f3vxa14",
|
|
72
|
+
Bbusuzp: "f1dcs8yz",
|
|
73
|
+
B7bxudy: "f1lmtjkn"
|
|
74
|
+
}
|
|
75
|
+
}, {
|
|
76
|
+
h: [".f3p8bqa:hover{color:var(--colorNeutralForeground2);}", ".ffqb913:hover>.fui-Checkbox__indicator{border-top-color:var(--colorNeutralStrokeAccessibleHover);}", ".f42z0vd:hover>.fui-Checkbox__indicator{border-right-color:var(--colorNeutralStrokeAccessibleHover);}", ".f1j37kh1:hover>.fui-Checkbox__indicator{border-left-color:var(--colorNeutralStrokeAccessibleHover);}", ".f10v6cc1:hover>.fui-Checkbox__indicator{border-bottom-color:var(--colorNeutralStrokeAccessibleHover);}", ".f5x9vvn:hover>.fui-Checkbox__indicator{background-color:var(--colorCompoundBrandBackgroundHover);}", ".fub8hyy:hover>.fui-Checkbox__indicator{border-top-color:var(--colorCompoundBrandBackgroundHover);}", ".fffzknn:hover>.fui-Checkbox__indicator{border-right-color:var(--colorCompoundBrandBackgroundHover);}", ".f172bh4s:hover>.fui-Checkbox__indicator{border-left-color:var(--colorCompoundBrandBackgroundHover);}", ".f6tipb1:hover>.fui-Checkbox__indicator{border-bottom-color:var(--colorCompoundBrandBackgroundHover);}", ".f1nlwys0:hover>.fui-Checkbox__indicator{border-top-color:var(--colorCompoundBrandStrokeHover);}", ".f1bhstg2:hover>.fui-Checkbox__indicator{border-right-color:var(--colorCompoundBrandStrokeHover);}", ".f6tsdgz:hover>.fui-Checkbox__indicator{border-left-color:var(--colorCompoundBrandStrokeHover);}", ".fqxbw9v:hover>.fui-Checkbox__indicator{border-bottom-color:var(--colorCompoundBrandStrokeHover);}", ".f1r38qqt:hover>.fui-Checkbox__indicator{color:var(--colorCompoundBrandForeground1Hover);}"],
|
|
77
|
+
a: [".f1r2dosr:active{color:var(--colorNeutralForeground1);}", ".f1oarbgq:active>.fui-Checkbox__indicator{border-top-color:var(--colorNeutralStrokeAccessiblePressed);}", ".fo8gord:active>.fui-Checkbox__indicator{border-right-color:var(--colorNeutralStrokeAccessiblePressed);}", ".f18ci1af:active>.fui-Checkbox__indicator{border-left-color:var(--colorNeutralStrokeAccessiblePressed);}", ".fviagcr:active>.fui-Checkbox__indicator{border-bottom-color:var(--colorNeutralStrokeAccessiblePressed);}", ".f8adco2:active>.fui-Checkbox__indicator{background-color:var(--colorCompoundBrandBackgroundPressed);}", ".f1lepnt8:active>.fui-Checkbox__indicator{border-top-color:var(--colorCompoundBrandBackgroundPressed);}", ".f80ygm0:active>.fui-Checkbox__indicator{border-right-color:var(--colorCompoundBrandBackgroundPressed);}", ".frrkusm:active>.fui-Checkbox__indicator{border-left-color:var(--colorCompoundBrandBackgroundPressed);}", ".f1gg953z:active>.fui-Checkbox__indicator{border-bottom-color:var(--colorCompoundBrandBackgroundPressed);}", ".f12q3i2l:active>.fui-Checkbox__indicator{border-top-color:var(--colorCompoundBrandStrokePressed);}", ".f9g1hxu:active>.fui-Checkbox__indicator{border-right-color:var(--colorCompoundBrandStrokePressed);}", ".f1o4ic5t:active>.fui-Checkbox__indicator{border-left-color:var(--colorCompoundBrandStrokePressed);}", ".f1c3thm1:active>.fui-Checkbox__indicator{border-bottom-color:var(--colorCompoundBrandStrokePressed);}", ".ffd07pq:active>.fui-Checkbox__indicator{color:var(--colorCompoundBrandForeground1Pressed);}"],
|
|
78
|
+
d: [".f19n0e5{color:var(--colorNeutralForeground1);}", ".f5opsb9>.fui-Checkbox__indicator{background-color:var(--colorCompoundBrandBackground);}", ".fpaw01r>.fui-Checkbox__indicator{color:var(--colorNeutralForegroundInverted);}", ".f1gqj827>.fui-Checkbox__indicator{border-top-color:var(--colorCompoundBrandBackground);}", ".fub94a2>.fui-Checkbox__indicator{border-right-color:var(--colorCompoundBrandBackground);}", ".f13mj44e>.fui-Checkbox__indicator{border-left-color:var(--colorCompoundBrandBackground);}", ".f1qq5vh1>.fui-Checkbox__indicator{border-bottom-color:var(--colorCompoundBrandBackground);}", ".f12fgbth>.fui-Checkbox__indicator{border-top-color:var(--colorCompoundBrandStroke);}", ".f171e6fm>.fui-Checkbox__indicator{border-right-color:var(--colorCompoundBrandStroke);}", ".fttsnhr>.fui-Checkbox__indicator{border-left-color:var(--colorCompoundBrandStroke);}", ".f1fyk1ks>.fui-Checkbox__indicator{border-bottom-color:var(--colorCompoundBrandStroke);}", ".fvvg2h8>.fui-Checkbox__indicator{color:var(--colorCompoundBrandForeground1);}", ".f158kwzp{cursor:default;}", ".f1s2aq7o{color:var(--colorNeutralForegroundDisabled);}", ".fgiuqeu>.fui-Checkbox__indicator{border-top-color:var(--colorNeutralStrokeDisabled);}", ".f1q4sfkt>.fui-Checkbox__indicator{border-right-color:var(--colorNeutralStrokeDisabled);}", ".f71co73>.fui-Checkbox__indicator{border-left-color:var(--colorNeutralStrokeDisabled);}", ".f1u7lsiy>.fui-Checkbox__indicator{border-bottom-color:var(--colorNeutralStrokeDisabled);}", ".f3vxa14>.fui-Checkbox__indicator{color:var(--colorNeutralForegroundDisabled);}"],
|
|
79
|
+
m: [["@media (forced-colors: active){.f1dcs8yz{color:GrayText;}}", {
|
|
80
|
+
m: "(forced-colors: active)"
|
|
81
|
+
}], ["@media (forced-colors: active){.f1lmtjkn>.fui-Checkbox__indicator{color:GrayText;}}", {
|
|
82
|
+
m: "(forced-colors: active)"
|
|
83
|
+
}]]
|
|
84
|
+
});
|
|
85
|
+
const useInputBaseClassName = /*#__PURE__*/__resetStyles("ruo9svu", null, [".ruo9svu{box-sizing:border-box;cursor:inherit;height:100%;margin:0;opacity:0;position:absolute;top:0;width:calc(16px + 2 * var(--spacingHorizontalS));}"]);
|
|
15
86
|
const useInputStyles = /*#__PURE__*/__styles({
|
|
16
87
|
before: {
|
|
17
88
|
j35jbq: ["f1e31b4d", "f1vgc2s3"]
|
|
@@ -25,7 +96,7 @@ const useInputStyles = /*#__PURE__*/__styles({
|
|
|
25
96
|
}, {
|
|
26
97
|
d: [".f1e31b4d{right:0;}", ".f1vgc2s3{left:0;}", ".f1mq5jt6{width:calc(20px + 2 * var(--spacingHorizontalS));}"]
|
|
27
98
|
});
|
|
28
|
-
const useIndicatorBaseClassName = /*#__PURE__*/__resetStyles("
|
|
99
|
+
const useIndicatorBaseClassName = /*#__PURE__*/__resetStyles("rrh91wr", null, [".rrh91wr{-webkit-align-self:flex-start;-ms-flex-item-align:flex-start;align-self:flex-start;box-sizing:border-box;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;overflow:hidden;border:var(--strokeWidthThin) solid var(--colorNeutralStrokeAccessible);border-radius:var(--borderRadiusSmall);margin:var(--spacingVerticalS) var(--spacingHorizontalS);fill:currentColor;pointer-events:none;font-size:12px;height:16px;width:16px;}"]);
|
|
29
100
|
const useIndicatorStyles = /*#__PURE__*/__styles({
|
|
30
101
|
large: {
|
|
31
102
|
Be2twd7: "f4ybsrx",
|
|
@@ -45,7 +116,8 @@ const useIndicatorStyles = /*#__PURE__*/__styles({
|
|
|
45
116
|
const useLabelStyles = /*#__PURE__*/__styles({
|
|
46
117
|
base: {
|
|
47
118
|
qb2dma: "f7nlbp4",
|
|
48
|
-
|
|
119
|
+
sj55zd: "f1ym3bx4",
|
|
120
|
+
Bceei9c: "fpo1scq",
|
|
49
121
|
z8tnut: "f1kwiid1",
|
|
50
122
|
z189sj: ["f1vdfbxk", "f1f5gg8d"],
|
|
51
123
|
Byoj8tv: "f5b47ha",
|
|
@@ -66,19 +138,22 @@ const useLabelStyles = /*#__PURE__*/__styles({
|
|
|
66
138
|
jrapky: "f49ad5g"
|
|
67
139
|
}
|
|
68
140
|
}, {
|
|
69
|
-
d: [".f7nlbp4{-webkit-align-self:center;-ms-flex-item-align:center;align-self:center;}", ".
|
|
141
|
+
d: [".f7nlbp4{-webkit-align-self:center;-ms-flex-item-align:center;align-self:center;}", ".f1ym3bx4{color:inherit;}", ".fpo1scq{cursor:inherit;}", ".f1kwiid1{padding-top:var(--spacingVerticalS);}", ".f1vdfbxk{padding-right:var(--spacingHorizontalS);}", ".f1f5gg8d{padding-left:var(--spacingHorizontalS);}", ".f5b47ha{padding-bottom:var(--spacingVerticalS);}", ".f7x41pl{padding-right:var(--spacingHorizontalXS);}", ".fruq291{padding-left:var(--spacingHorizontalXS);}", ".fjzwpt6{margin-top:calc((16px - var(--lineHeightBase300)) / 2);}", ".fh6j2fo{margin-bottom:calc((16px - var(--lineHeightBase300)) / 2);}", ".f1xlvstr{margin-top:calc((20px - var(--lineHeightBase300)) / 2);}", ".f49ad5g{margin-bottom:calc((20px - var(--lineHeightBase300)) / 2);}"]
|
|
70
142
|
});
|
|
71
143
|
/**
|
|
72
144
|
* Apply styling to the Checkbox slots based on the state
|
|
73
145
|
*/
|
|
74
146
|
export const useCheckboxStyles_unstable = state => {
|
|
75
147
|
const {
|
|
148
|
+
checked,
|
|
149
|
+
disabled,
|
|
76
150
|
labelPosition,
|
|
77
151
|
shape,
|
|
78
152
|
size
|
|
79
153
|
} = state;
|
|
80
154
|
const rootBaseClassName = useRootBaseClassName();
|
|
81
|
-
|
|
155
|
+
const rootStyles = useRootStyles();
|
|
156
|
+
state.root.className = mergeClasses(checkboxClassNames.root, rootBaseClassName, disabled ? rootStyles.disabled : checked === 'mixed' ? rootStyles.mixed : checked ? rootStyles.checked : rootStyles.unchecked, state.root.className);
|
|
82
157
|
const inputBaseClassName = useInputBaseClassName();
|
|
83
158
|
const inputStyles = useInputStyles();
|
|
84
159
|
state.input.className = mergeClasses(checkboxClassNames.input, inputBaseClassName, size === 'large' && inputStyles.large, inputStyles[labelPosition], state.input.className);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":"AAAA,kCAAsCA,YAAY,EAAEC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cAAc,EAAE;EACpCK,KAAK,CAACX,KAAK,CAACgB,SAAS,GAAGvB,YAAY,CAClCI,kBAAkB,CAACG,KAAK,EACxBiB,kBAAkB,EAClBH,IAAI,KAAK,OAAO,IAAII,WAAW,CAACC,KAAK,EACrCD,WAAW,CAACN,aAAa,CAAC,EAC1BD,KAAK,CAACX,KAAK,CAACgB,SAAS,CACtB;EAED,MAAMI,sBAAsB,GAAGb,yBAAyB,EAAE;EAC1D,MAAMc,eAAe,GAAGb,kBAAkB,EAAE;EAC5C,IAAIG,KAAK,CAACV,SAAS,EAAE;IACnBU,KAAK,CAACV,SAAS,CAACe,SAAS,GAAGvB,YAAY,CACtCI,kBAAkB,CAACI,SAAS,EAC5BmB,sBAAsB,EACtBN,IAAI,KAAK,OAAO,IAAIO,eAAe,CAACF,KAAK,EACzCN,KAAK,KAAK,UAAU,IAAIQ,eAAe,CAACC,QAAQ,EAChDX,KAAK,CAACV,SAAS,CAACe,SAAS,CAC1B;;EAGH,MAAMO,WAAW,GAAGd,cAAc,EAAE;EACpC,IAAIE,KAAK,CAACZ,KAAK,EAAE;IACfY,KAAK,CAACZ,KAAK,CAACiB,SAAS,GAAGvB,YAAY,CAClCI,kBAAkB,CAACE,KAAK,EACxBwB,WAAW,CAACC,IAAI,EAChBD,WAAW,CAACT,IAAI,CAAC,EACjBS,WAAW,CAACX,aAAa,CAAC,EAC1BD,KAAK,CAACZ,KAAK,CAACiB,SAAS,CACtB;;EAGH,OAAOL,KAAK;AACd,CAAC","names":["mergeClasses","shorthands","createFocusOutlineStyle","tokens","checkboxClassNames","root","label","input","indicator","indicatorSizeMedium","indicatorSizeLarge","useRootBaseClassName","useInputBaseClassName","useInputStyles","useIndicatorBaseClassName","useIndicatorStyles","useLabelStyles","useCheckboxStyles_unstable","state","labelPosition","shape","size","rootBaseClassName","className","inputBaseClassName","inputStyles","large","indicatorBaseClassName","indicatorStyles","circular","labelStyles","base"],"sourceRoot":"../src/","sources":["packages/react-components/react-checkbox/src/components/Checkbox/useCheckboxStyles.ts"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { createFocusOutlineStyle } from '@fluentui/react-tabster';\nimport { tokens } from '@fluentui/react-theme';\nimport { CheckboxSlots, CheckboxState } from './Checkbox.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const checkboxClassNames: SlotClassNames<CheckboxSlots> = {\n root: 'fui-Checkbox',\n label: 'fui-Checkbox__label',\n input: 'fui-Checkbox__input',\n indicator: 'fui-Checkbox__indicator',\n};\n\n// The indicator size is used by the indicator and label styles\nconst indicatorSizeMedium = '16px';\nconst indicatorSizeLarge = '20px';\n\nconst useRootBaseClassName = makeResetStyles({\n position: 'relative',\n display: 'inline-flex',\n ...createFocusOutlineStyle({ style: {}, selector: 'focus-within' }),\n});\n\nconst useInputBaseClassName = makeResetStyles({\n boxSizing: 'border-box',\n cursor: 'pointer',\n height: '100%',\n margin: 0,\n opacity: 0,\n position: 'absolute',\n top: 0,\n // Calculate the width of the hidden input by taking into account the size of the indicator + the padding around it.\n // This is done so that clicking on that \"empty space\" still toggles the checkbox.\n width: `calc(${indicatorSizeMedium} + 2 * ${tokens.spacingHorizontalS})`,\n\n // Colors for the unchecked state\n ':enabled:not(:checked):not(:indeterminate)': {\n [`& ~ .${checkboxClassNames.label}`]: {\n color: tokens.colorNeutralForeground3,\n },\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorNeutralStrokeAccessible,\n },\n\n ':hover': {\n [`& ~ .${checkboxClassNames.label}`]: {\n color: tokens.colorNeutralForeground2,\n },\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorNeutralStrokeAccessibleHover,\n },\n },\n\n ':active:hover': {\n [`& ~ .${checkboxClassNames.label}`]: {\n color: tokens.colorNeutralForeground1,\n },\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorNeutralStrokeAccessiblePressed,\n },\n },\n },\n\n // Colors for the checked state\n ':enabled:checked:not(:indeterminate)': {\n [`& ~ .${checkboxClassNames.label}`]: {\n color: tokens.colorNeutralForeground1,\n },\n [`& ~ .${checkboxClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackground,\n color: tokens.colorNeutralForegroundInverted,\n borderColor: tokens.colorCompoundBrandBackground,\n },\n\n ':hover': {\n [`& ~ .${checkboxClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundHover,\n borderColor: tokens.colorCompoundBrandBackgroundHover,\n },\n },\n\n ':active:hover': {\n [`& ~ .${checkboxClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundPressed,\n borderColor: tokens.colorCompoundBrandBackgroundPressed,\n },\n },\n },\n\n // Colors for the mixed state\n ':enabled:indeterminate': {\n [`& ~ .${checkboxClassNames.label}`]: {\n color: tokens.colorNeutralForeground1,\n },\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorCompoundBrandStroke,\n color: tokens.colorCompoundBrandForeground1,\n },\n\n ':hover': {\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorCompoundBrandStrokeHover,\n color: tokens.colorCompoundBrandForeground1Hover,\n },\n },\n\n ':active:hover': {\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorCompoundBrandStrokePressed,\n color: tokens.colorCompoundBrandForeground1Pressed,\n },\n },\n },\n\n ':disabled': {\n cursor: 'default',\n\n [`& ~ .${checkboxClassNames.label}`]: {\n cursor: 'default',\n color: tokens.colorNeutralForegroundDisabled,\n '@media (forced-colors: active)': {\n color: 'GrayText',\n },\n },\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorNeutralStrokeDisabled,\n color: tokens.colorNeutralForegroundDisabled,\n '@media (forced-colors: active)': {\n color: 'GrayText',\n },\n },\n [`& ~ .${checkboxClassNames.indicator} svg`]: {\n '@media (forced-colors: active)': {\n color: 'GrayText',\n },\n },\n },\n});\n\nconst useInputStyles = makeStyles({\n before: {\n right: 0,\n },\n after: {\n left: 0,\n },\n\n large: {\n width: `calc(${indicatorSizeLarge} + 2 * ${tokens.spacingHorizontalS})`,\n },\n});\n\nconst useIndicatorBaseClassName = makeResetStyles({\n alignSelf: 'flex-start',\n boxSizing: 'border-box',\n flexShrink: 0,\n\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n overflow: 'hidden',\n\n border: tokens.strokeWidthThin + ' solid',\n borderRadius: tokens.borderRadiusSmall,\n margin: tokens.spacingVerticalS + ' ' + tokens.spacingHorizontalS,\n fill: 'currentColor',\n pointerEvents: 'none',\n\n fontSize: '12px',\n height: indicatorSizeMedium,\n width: indicatorSizeMedium,\n});\n\nconst useIndicatorStyles = makeStyles({\n large: {\n fontSize: '16px',\n height: indicatorSizeLarge,\n width: indicatorSizeLarge,\n },\n\n circular: {\n ...shorthands.borderRadius(tokens.borderRadiusCircular),\n },\n});\n\n// Can't use makeResetStyles here because Label is a component that may itself use makeResetStyles.\nconst useLabelStyles = makeStyles({\n base: {\n alignSelf: 'center',\n cursor: 'pointer',\n ...shorthands.padding(tokens.spacingVerticalS, tokens.spacingHorizontalS),\n },\n\n before: {\n paddingRight: tokens.spacingHorizontalXS,\n },\n after: {\n paddingLeft: tokens.spacingHorizontalXS,\n },\n\n // Use a (negative) margin to account for the difference between the indicator's height and the label's line height.\n // This prevents the label from expanding the height of the checkbox, but preserves line height if the label wraps.\n medium: {\n marginTop: `calc((${indicatorSizeMedium} - ${tokens.lineHeightBase300}) / 2)`,\n marginBottom: `calc((${indicatorSizeMedium} - ${tokens.lineHeightBase300}) / 2)`,\n },\n large: {\n marginTop: `calc((${indicatorSizeLarge} - ${tokens.lineHeightBase300}) / 2)`,\n marginBottom: `calc((${indicatorSizeLarge} - ${tokens.lineHeightBase300}) / 2)`,\n },\n});\n\n/**\n * Apply styling to the Checkbox slots based on the state\n */\nexport const useCheckboxStyles_unstable = (state: CheckboxState): CheckboxState => {\n const { labelPosition, shape, size } = state;\n\n const rootBaseClassName = useRootBaseClassName();\n state.root.className = mergeClasses(checkboxClassNames.root, rootBaseClassName, state.root.className);\n\n const inputBaseClassName = useInputBaseClassName();\n const inputStyles = useInputStyles();\n state.input.className = mergeClasses(\n checkboxClassNames.input,\n inputBaseClassName,\n size === 'large' && inputStyles.large,\n inputStyles[labelPosition],\n state.input.className,\n );\n\n const indicatorBaseClassName = useIndicatorBaseClassName();\n const indicatorStyles = useIndicatorStyles();\n if (state.indicator) {\n state.indicator.className = mergeClasses(\n checkboxClassNames.indicator,\n indicatorBaseClassName,\n size === 'large' && indicatorStyles.large,\n shape === 'circular' && indicatorStyles.circular,\n state.indicator.className,\n );\n }\n\n const labelStyles = useLabelStyles();\n if (state.label) {\n state.label.className = mergeClasses(\n checkboxClassNames.label,\n labelStyles.base,\n labelStyles[size],\n labelStyles[labelPosition],\n state.label.className,\n );\n }\n\n return state;\n};\n"]}
|
|
1
|
+
{"version":3,"mappings":"AAAA,kCAAsCA,YAAY,EAAEC,UAAU,QAAQ,gBAAgB;AACtF,SAASC,uBAAuB,QAAQ,yBAAyB;AACjE,SAASC,MAAM,QAAQ,uBAAuB;AAI9C,OAAO,MAAMC,kBAAkB,GAAkC;EAC/DC,IAAI,EAAE,cAAc;EACpBC,KAAK,EAAE,qBAAqB;EAC5BC,KAAK,EAAE,qBAAqB;EAC5BC,SAAS,EAAE;CACZ;AAED;AACA,MAAMC,mBAAmB,GAAG,MAAM;AAClC,MAAMC,kBAAkB,GAAG,MAAM;AAEjC,MAAMC,oBAAoB,gBAAG,+0EAM3B;AAEF,MAAMC,aAAa,gBAAG;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA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ACrB;EAED,MAAMG,kBAAkB,GAAGjB,qBAAqB,EAAE;EAClD,MAAMkB,WAAW,GAAGjB,cAAc,EAAE;EACpCK,KAAK,CAACZ,KAAK,CAACoB,SAAS,GAAG3B,YAAY,CAClCI,kBAAkB,CAACG,KAAK,EACxBuB,kBAAkB,EAClBN,IAAI,KAAK,OAAO,IAAIO,WAAW,CAACC,KAAK,EACrCD,WAAW,CAACT,aAAa,CAAC,EAC1BH,KAAK,CAACZ,KAAK,CAACoB,SAAS,CACtB;EAED,MAAMM,sBAAsB,GAAGlB,yBAAyB,EAAE;EAC1D,MAAMmB,eAAe,GAAGlB,kBAAkB,EAAE;EAC5C,IAAIG,KAAK,CAACX,SAAS,EAAE;IACnBW,KAAK,CAACX,SAAS,CAACmB,SAAS,GAAG3B,YAAY,CACtCI,kBAAkB,CAACI,SAAS,EAC5ByB,sBAAsB,EACtBT,IAAI,KAAK,OAAO,IAAIU,eAAe,CAACF,KAAK,EACzCT,KAAK,KAAK,UAAU,IAAIW,eAAe,CAACC,QAAQ,EAChDhB,KAAK,CAACX,SAAS,CAACmB,SAAS,CAC1B;;EAGH,MAAMS,WAAW,GAAGnB,cAAc,EAAE;EACpC,IAAIE,KAAK,CAACb,KAAK,EAAE;IACfa,KAAK,CAACb,KAAK,CAACqB,SAAS,GAAG3B,YAAY,CAClCI,kBAAkB,CAACE,KAAK,EACxB8B,WAAW,CAACC,IAAI,EAChBD,WAAW,CAACZ,IAAI,CAAC,EACjBY,WAAW,CAACd,aAAa,CAAC,EAC1BH,KAAK,CAACb,KAAK,CAACqB,SAAS,CACtB;;EAGH,OAAOR,KAAK;AACd,CAAC","names":["mergeClasses","shorthands","createFocusOutlineStyle","tokens","checkboxClassNames","root","label","input","indicator","indicatorSizeMedium","indicatorSizeLarge","useRootBaseClassName","useRootStyles","useInputBaseClassName","useInputStyles","useIndicatorBaseClassName","useIndicatorStyles","useLabelStyles","useCheckboxStyles_unstable","state","checked","disabled","labelPosition","shape","size","rootBaseClassName","rootStyles","className","mixed","unchecked","inputBaseClassName","inputStyles","large","indicatorBaseClassName","indicatorStyles","circular","labelStyles","base"],"sourceRoot":"../src/","sources":["packages/react-components/react-checkbox/src/components/Checkbox/useCheckboxStyles.ts"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { createFocusOutlineStyle } from '@fluentui/react-tabster';\nimport { tokens } from '@fluentui/react-theme';\nimport { CheckboxSlots, CheckboxState } from './Checkbox.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const checkboxClassNames: SlotClassNames<CheckboxSlots> = {\n root: 'fui-Checkbox',\n label: 'fui-Checkbox__label',\n input: 'fui-Checkbox__input',\n indicator: 'fui-Checkbox__indicator',\n};\n\n// The indicator size is used by the indicator and label styles\nconst indicatorSizeMedium = '16px';\nconst indicatorSizeLarge = '20px';\n\nconst useRootBaseClassName = makeResetStyles({\n position: 'relative',\n display: 'inline-flex',\n cursor: 'pointer',\n color: tokens.colorNeutralForeground3,\n ...createFocusOutlineStyle({ style: {}, selector: 'focus-within' }),\n});\n\nconst useRootStyles = makeStyles({\n unchecked: {\n ':hover': {\n color: tokens.colorNeutralForeground2,\n [`> .${checkboxClassNames.indicator}`]: {\n ...shorthands.borderColor(tokens.colorNeutralStrokeAccessibleHover),\n },\n },\n\n ':active': {\n color: tokens.colorNeutralForeground1,\n [`> .${checkboxClassNames.indicator}`]: {\n ...shorthands.borderColor(tokens.colorNeutralStrokeAccessiblePressed),\n },\n },\n },\n\n checked: {\n color: tokens.colorNeutralForeground1,\n\n [`> .${checkboxClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackground,\n color: tokens.colorNeutralForegroundInverted,\n ...shorthands.borderColor(tokens.colorCompoundBrandBackground),\n },\n\n ':hover': {\n [`> .${checkboxClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundHover,\n ...shorthands.borderColor(tokens.colorCompoundBrandBackgroundHover),\n },\n },\n\n ':active': {\n [`> .${checkboxClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundPressed,\n ...shorthands.borderColor(tokens.colorCompoundBrandBackgroundPressed),\n },\n },\n },\n\n mixed: {\n color: tokens.colorNeutralForeground1,\n\n [`> .${checkboxClassNames.indicator}`]: {\n ...shorthands.borderColor(tokens.colorCompoundBrandStroke),\n color: tokens.colorCompoundBrandForeground1,\n },\n\n ':hover': {\n [`> .${checkboxClassNames.indicator}`]: {\n ...shorthands.borderColor(tokens.colorCompoundBrandStrokeHover),\n color: tokens.colorCompoundBrandForeground1Hover,\n },\n },\n\n ':active': {\n [`> .${checkboxClassNames.indicator}`]: {\n ...shorthands.borderColor(tokens.colorCompoundBrandStrokePressed),\n color: tokens.colorCompoundBrandForeground1Pressed,\n },\n },\n },\n\n disabled: {\n cursor: 'default',\n\n color: tokens.colorNeutralForegroundDisabled,\n\n [`> .${checkboxClassNames.indicator}`]: {\n ...shorthands.borderColor(tokens.colorNeutralStrokeDisabled),\n color: tokens.colorNeutralForegroundDisabled,\n },\n\n '@media (forced-colors: active)': {\n color: 'GrayText',\n [`> .${checkboxClassNames.indicator}`]: {\n color: 'GrayText',\n },\n },\n },\n});\n\nconst useInputBaseClassName = makeResetStyles({\n boxSizing: 'border-box',\n cursor: 'inherit',\n height: '100%',\n margin: 0,\n opacity: 0,\n position: 'absolute',\n top: 0,\n // Calculate the width of the hidden input by taking into account the size of the indicator + the padding around it.\n // This is done so that clicking on that \"empty space\" still toggles the checkbox.\n width: `calc(${indicatorSizeMedium} + 2 * ${tokens.spacingHorizontalS})`,\n});\n\nconst useInputStyles = makeStyles({\n before: {\n right: 0,\n },\n after: {\n left: 0,\n },\n\n large: {\n width: `calc(${indicatorSizeLarge} + 2 * ${tokens.spacingHorizontalS})`,\n },\n});\n\nconst useIndicatorBaseClassName = makeResetStyles({\n alignSelf: 'flex-start',\n boxSizing: 'border-box',\n flexShrink: 0,\n\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n overflow: 'hidden',\n\n border: tokens.strokeWidthThin + ' solid ' + tokens.colorNeutralStrokeAccessible,\n borderRadius: tokens.borderRadiusSmall,\n margin: tokens.spacingVerticalS + ' ' + tokens.spacingHorizontalS,\n fill: 'currentColor',\n pointerEvents: 'none',\n\n fontSize: '12px',\n height: indicatorSizeMedium,\n width: indicatorSizeMedium,\n});\n\nconst useIndicatorStyles = makeStyles({\n large: {\n fontSize: '16px',\n height: indicatorSizeLarge,\n width: indicatorSizeLarge,\n },\n\n circular: {\n ...shorthands.borderRadius(tokens.borderRadiusCircular),\n },\n});\n\n// Can't use makeResetStyles here because Label is a component that may itself use makeResetStyles.\nconst useLabelStyles = makeStyles({\n base: {\n alignSelf: 'center',\n color: 'inherit',\n cursor: 'inherit',\n ...shorthands.padding(tokens.spacingVerticalS, tokens.spacingHorizontalS),\n },\n\n before: {\n paddingRight: tokens.spacingHorizontalXS,\n },\n after: {\n paddingLeft: tokens.spacingHorizontalXS,\n },\n\n // Use a (negative) margin to account for the difference between the indicator's height and the label's line height.\n // This prevents the label from expanding the height of the checkbox, but preserves line height if the label wraps.\n medium: {\n marginTop: `calc((${indicatorSizeMedium} - ${tokens.lineHeightBase300}) / 2)`,\n marginBottom: `calc((${indicatorSizeMedium} - ${tokens.lineHeightBase300}) / 2)`,\n },\n large: {\n marginTop: `calc((${indicatorSizeLarge} - ${tokens.lineHeightBase300}) / 2)`,\n marginBottom: `calc((${indicatorSizeLarge} - ${tokens.lineHeightBase300}) / 2)`,\n },\n});\n\n/**\n * Apply styling to the Checkbox slots based on the state\n */\nexport const useCheckboxStyles_unstable = (state: CheckboxState): CheckboxState => {\n const { checked, disabled, labelPosition, shape, size } = state;\n\n const rootBaseClassName = useRootBaseClassName();\n const rootStyles = useRootStyles();\n state.root.className = mergeClasses(\n checkboxClassNames.root,\n rootBaseClassName,\n disabled\n ? rootStyles.disabled\n : checked === 'mixed'\n ? rootStyles.mixed\n : checked\n ? rootStyles.checked\n : rootStyles.unchecked,\n state.root.className,\n );\n\n const inputBaseClassName = useInputBaseClassName();\n const inputStyles = useInputStyles();\n state.input.className = mergeClasses(\n checkboxClassNames.input,\n inputBaseClassName,\n size === 'large' && inputStyles.large,\n inputStyles[labelPosition],\n state.input.className,\n );\n\n const indicatorBaseClassName = useIndicatorBaseClassName();\n const indicatorStyles = useIndicatorStyles();\n if (state.indicator) {\n state.indicator.className = mergeClasses(\n checkboxClassNames.indicator,\n indicatorBaseClassName,\n size === 'large' && indicatorStyles.large,\n shape === 'circular' && indicatorStyles.circular,\n state.indicator.className,\n );\n }\n\n const labelStyles = useLabelStyles();\n if (state.label) {\n state.label.className = mergeClasses(\n checkboxClassNames.label,\n labelStyles.base,\n labelStyles[size],\n labelStyles[labelPosition],\n state.label.className,\n );\n }\n\n return state;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-checkbox/src/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\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 'checked' | 'defaultChecked' | 'onChange' | 'size'\n> & {\n /**\n * The controlled value for the checkbox.\n *\n * @default false\n */\n checked?: 'mixed' | boolean;\n\n /**\n * Checkboxes don't support children. To add a label, use the `label` prop.\n */\n children?: never;\n\n /**\n * Whether the checkbox should be rendered as checked by default.\n */\n defaultChecked?: 'mixed' | boolean;\n\n /**\n * The position of the label relative to the checkbox indicator.\n *\n * @default after\n */\n labelPosition?: 'before' | 'after';\n\n /**\n * Callback to be called when the checked state value changes.\n */\n onChange?: (ev: React.ChangeEvent<HTMLInputElement>, data: CheckboxOnChangeData) => void;\n\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 * @default square\n */\n shape?: 'square' | 'circular';\n\n /**\n * The size of the checkbox indicator.\n *\n * @default medium\n */\n size?: 'medium' | 'large';\n};\n\n/**\n * Data for the onChange event for checkbox.\n */\nexport interface CheckboxOnChangeData {\n checked: 'mixed' | boolean;\n}\n\n/**\n * State used in rendering Checkbox\n */\nexport type CheckboxState = ComponentState<CheckboxSlots> &\n Required<Pick<CheckboxProps, 'checked' | 'labelPosition' | 'shape' | 'size'>>;\n"]}
|
|
1
|
+
{"version":3,"file":"Checkbox.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-checkbox/src/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\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 'checked' | 'defaultChecked' | 'onChange' | 'size'\n> & {\n /**\n * The controlled value for the checkbox.\n *\n * @default false\n */\n checked?: 'mixed' | boolean;\n\n /**\n * Checkboxes don't support children. To add a label, use the `label` prop.\n */\n children?: never;\n\n /**\n * Whether the checkbox should be rendered as checked by default.\n */\n defaultChecked?: 'mixed' | boolean;\n\n /**\n * The position of the label relative to the checkbox indicator.\n *\n * @default after\n */\n labelPosition?: 'before' | 'after';\n\n /**\n * Callback to be called when the checked state value changes.\n */\n onChange?: (ev: React.ChangeEvent<HTMLInputElement>, data: CheckboxOnChangeData) => void;\n\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 * @default square\n */\n shape?: 'square' | 'circular';\n\n /**\n * The size of the checkbox indicator.\n *\n * @default medium\n */\n size?: 'medium' | 'large';\n};\n\n/**\n * Data for the onChange event for checkbox.\n */\nexport interface CheckboxOnChangeData {\n checked: 'mixed' | boolean;\n}\n\n/**\n * State used in rendering Checkbox\n */\nexport type CheckboxState = ComponentState<CheckboxSlots> &\n Required<Pick<CheckboxProps, 'checked' | 'disabled' | 'labelPosition' | 'shape' | 'size'>>;\n"]}
|
|
@@ -12,12 +12,12 @@ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "@f
|
|
|
12
12
|
* @param ref - reference to `<input>` element of Checkbox
|
|
13
13
|
*/
|
|
14
14
|
var useCheckbox_unstable = function (props, ref) {
|
|
15
|
-
var
|
|
16
|
-
var
|
|
15
|
+
var _a = props.disabled, disabled = _a === void 0 ? false : _a, required = props.required, _b = props.shape, shape = _b === void 0 ? 'square' : _b, _c = props.size, size = _c === void 0 ? 'medium' : _c, _d = props.labelPosition, labelPosition = _d === void 0 ? 'after' : _d, onChange = props.onChange;
|
|
16
|
+
var _e = react_utilities_1.useControllableState({
|
|
17
17
|
defaultState: props.defaultChecked,
|
|
18
18
|
state: props.checked,
|
|
19
19
|
initialState: false,
|
|
20
|
-
}), checked =
|
|
20
|
+
}), checked = _e[0], setChecked = _e[1];
|
|
21
21
|
var nativeProps = react_utilities_1.getPartitionedNativeProps({
|
|
22
22
|
props: props,
|
|
23
23
|
primarySlotTagName: 'input',
|
|
@@ -40,6 +40,7 @@ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "@f
|
|
|
40
40
|
var state = {
|
|
41
41
|
shape: shape,
|
|
42
42
|
checked: checked,
|
|
43
|
+
disabled: disabled,
|
|
43
44
|
size: size,
|
|
44
45
|
labelPosition: labelPosition,
|
|
45
46
|
components: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCheckbox.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-checkbox/src/components/Checkbox/useCheckbox.tsx"],"names":[],"mappings":";;;;IAqBA;;;;;;;;OAQG;IACI,IAAM,oBAAoB,GAAG,UAAC,KAAoB,EAAE,GAAgC;QACjF,IAAA,QAAQ,
|
|
1
|
+
{"version":3,"file":"useCheckbox.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-checkbox/src/components/Checkbox/useCheckbox.tsx"],"names":[],"mappings":";;;;IAqBA;;;;;;;;OAQG;IACI,IAAM,oBAAoB,GAAG,UAAC,KAAoB,EAAE,GAAgC;QACjF,IAAA,KAAqG,KAAK,SAA1F,EAAhB,QAAQ,mBAAG,KAAK,KAAA,EAAE,QAAQ,GAA2E,KAAK,SAAhF,EAAE,KAAyE,KAAK,MAA9D,EAAhB,KAAK,mBAAG,QAAQ,KAAA,EAAE,KAAuD,KAAK,KAA7C,EAAf,IAAI,mBAAG,QAAQ,KAAA,EAAE,KAAsC,KAAK,cAApB,EAAvB,aAAa,mBAAG,OAAO,KAAA,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CAAC,CAAC;QAChD,KAAK,CAAC,KAAK,CAAC,GAAG,GAAG,QAAQ,CAAC;QAE3B,kGAAkG;QAClG,4FAA4F;QAC5F,2CAAyB,CAAC;YACxB,IAAI,QAAQ,CAAC,OAAO,EAAE;gBACpB,QAAQ,CAAC,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC;aACxC;QACH,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;QAEtB,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAhGW,QAAA,oBAAoB,wBAgG/B","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';\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 { disabled = false, 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 if (checked) {\n checkmarkIcon = size === 'large' ? <Checkmark16Filled /> : <Checkmark12Filled />;\n }\n\n const state: CheckboxState = {\n shape,\n checked,\n disabled,\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: {\n ref: useFocusWithin<HTMLSpanElement>(),\n ...nativeProps.root,\n },\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"]}
|
|
@@ -12,111 +12,67 @@ define(["require", "exports", "tslib", "@griffel/react", "@fluentui/react-tabste
|
|
|
12
12
|
// The indicator size is used by the indicator and label styles
|
|
13
13
|
var indicatorSizeMedium = '16px';
|
|
14
14
|
var indicatorSizeLarge = '20px';
|
|
15
|
-
var useRootBaseClassName = react_1.makeResetStyles(tslib_1.__assign({ position: 'relative', display: 'inline-flex' }, react_tabster_1.createFocusOutlineStyle({ style: {}, selector: 'focus-within' })));
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
margin: 0,
|
|
21
|
-
opacity: 0,
|
|
22
|
-
position: 'absolute',
|
|
23
|
-
top: 0,
|
|
24
|
-
// Calculate the width of the hidden input by taking into account the size of the indicator + the padding around it.
|
|
25
|
-
// This is done so that clicking on that "empty space" still toggles the checkbox.
|
|
26
|
-
width: "calc(" + indicatorSizeMedium + " + 2 * " + react_theme_1.tokens.spacingHorizontalS + ")",
|
|
27
|
-
// Colors for the unchecked state
|
|
28
|
-
':enabled:not(:checked):not(:indeterminate)': (_a = {},
|
|
29
|
-
_a["& ~ ." + exports.checkboxClassNames.label] = {
|
|
30
|
-
color: react_theme_1.tokens.colorNeutralForeground3,
|
|
31
|
-
},
|
|
32
|
-
_a["& ~ ." + exports.checkboxClassNames.indicator] = {
|
|
33
|
-
borderColor: react_theme_1.tokens.colorNeutralStrokeAccessible,
|
|
34
|
-
},
|
|
35
|
-
_a[':hover'] = (_b = {},
|
|
36
|
-
_b["& ~ ." + exports.checkboxClassNames.label] = {
|
|
37
|
-
color: react_theme_1.tokens.colorNeutralForeground2,
|
|
15
|
+
var useRootBaseClassName = react_1.makeResetStyles(tslib_1.__assign({ position: 'relative', display: 'inline-flex', cursor: 'pointer', color: react_theme_1.tokens.colorNeutralForeground3 }, react_tabster_1.createFocusOutlineStyle({ style: {}, selector: 'focus-within' })));
|
|
16
|
+
var useRootStyles = react_1.makeStyles({
|
|
17
|
+
unchecked: {
|
|
18
|
+
':hover': (_a = {
|
|
19
|
+
color: react_theme_1.tokens.colorNeutralForeground2
|
|
38
20
|
},
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
_a["> ." + exports.checkboxClassNames.indicator] = tslib_1.__assign({}, react_1.shorthands.borderColor(react_theme_1.tokens.colorNeutralStrokeAccessibleHover)),
|
|
22
|
+
_a),
|
|
23
|
+
':active': (_b = {
|
|
24
|
+
color: react_theme_1.tokens.colorNeutralForeground1
|
|
41
25
|
},
|
|
26
|
+
_b["> ." + exports.checkboxClassNames.indicator] = tslib_1.__assign({}, react_1.shorthands.borderColor(react_theme_1.tokens.colorNeutralStrokeAccessiblePressed)),
|
|
42
27
|
_b),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
_c["& ~ ." + exports.checkboxClassNames.indicator] = {
|
|
48
|
-
borderColor: react_theme_1.tokens.colorNeutralStrokeAccessiblePressed,
|
|
49
|
-
},
|
|
50
|
-
_c),
|
|
51
|
-
_a),
|
|
52
|
-
// Colors for the checked state
|
|
53
|
-
':enabled:checked:not(:indeterminate)': (_d = {},
|
|
54
|
-
_d["& ~ ." + exports.checkboxClassNames.label] = {
|
|
55
|
-
color: react_theme_1.tokens.colorNeutralForeground1,
|
|
56
|
-
},
|
|
57
|
-
_d["& ~ ." + exports.checkboxClassNames.indicator] = {
|
|
58
|
-
backgroundColor: react_theme_1.tokens.colorCompoundBrandBackground,
|
|
59
|
-
color: react_theme_1.tokens.colorNeutralForegroundInverted,
|
|
60
|
-
borderColor: react_theme_1.tokens.colorCompoundBrandBackground,
|
|
28
|
+
},
|
|
29
|
+
checked: (_c = {
|
|
30
|
+
color: react_theme_1.tokens.colorNeutralForeground1
|
|
61
31
|
},
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
32
|
+
_c["> ." + exports.checkboxClassNames.indicator] = tslib_1.__assign({ backgroundColor: react_theme_1.tokens.colorCompoundBrandBackground, color: react_theme_1.tokens.colorNeutralForegroundInverted }, react_1.shorthands.borderColor(react_theme_1.tokens.colorCompoundBrandBackground)),
|
|
33
|
+
_c[':hover'] = (_d = {},
|
|
34
|
+
_d["> ." + exports.checkboxClassNames.indicator] = tslib_1.__assign({ backgroundColor: react_theme_1.tokens.colorCompoundBrandBackgroundHover }, react_1.shorthands.borderColor(react_theme_1.tokens.colorCompoundBrandBackgroundHover)),
|
|
35
|
+
_d),
|
|
36
|
+
_c[':active'] = (_e = {},
|
|
37
|
+
_e["> ." + exports.checkboxClassNames.indicator] = tslib_1.__assign({ backgroundColor: react_theme_1.tokens.colorCompoundBrandBackgroundPressed }, react_1.shorthands.borderColor(react_theme_1.tokens.colorCompoundBrandBackgroundPressed)),
|
|
67
38
|
_e),
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
borderColor: react_theme_1.tokens.colorCompoundBrandBackgroundPressed,
|
|
72
|
-
},
|
|
73
|
-
_f),
|
|
74
|
-
_d),
|
|
75
|
-
// Colors for the mixed state
|
|
76
|
-
':enabled:indeterminate': (_g = {},
|
|
77
|
-
_g["& ~ ." + exports.checkboxClassNames.label] = {
|
|
78
|
-
color: react_theme_1.tokens.colorNeutralForeground1,
|
|
79
|
-
},
|
|
80
|
-
_g["& ~ ." + exports.checkboxClassNames.indicator] = {
|
|
81
|
-
borderColor: react_theme_1.tokens.colorCompoundBrandStroke,
|
|
82
|
-
color: react_theme_1.tokens.colorCompoundBrandForeground1,
|
|
39
|
+
_c),
|
|
40
|
+
mixed: (_f = {
|
|
41
|
+
color: react_theme_1.tokens.colorNeutralForeground1
|
|
83
42
|
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
43
|
+
_f["> ." + exports.checkboxClassNames.indicator] = tslib_1.__assign(tslib_1.__assign({}, react_1.shorthands.borderColor(react_theme_1.tokens.colorCompoundBrandStroke)), { color: react_theme_1.tokens.colorCompoundBrandForeground1 }),
|
|
44
|
+
_f[':hover'] = (_g = {},
|
|
45
|
+
_g["> ." + exports.checkboxClassNames.indicator] = tslib_1.__assign(tslib_1.__assign({}, react_1.shorthands.borderColor(react_theme_1.tokens.colorCompoundBrandStrokeHover)), { color: react_theme_1.tokens.colorCompoundBrandForeground1Hover }),
|
|
46
|
+
_g),
|
|
47
|
+
_f[':active'] = (_h = {},
|
|
48
|
+
_h["> ." + exports.checkboxClassNames.indicator] = tslib_1.__assign(tslib_1.__assign({}, react_1.shorthands.borderColor(react_theme_1.tokens.colorCompoundBrandStrokePressed)), { color: react_theme_1.tokens.colorCompoundBrandForeground1Pressed }),
|
|
89
49
|
_h),
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
borderColor: react_theme_1.tokens.colorCompoundBrandStrokePressed,
|
|
93
|
-
color: react_theme_1.tokens.colorCompoundBrandForeground1Pressed,
|
|
94
|
-
},
|
|
95
|
-
_j),
|
|
96
|
-
_g),
|
|
97
|
-
':disabled': (_k = {
|
|
98
|
-
cursor: 'default'
|
|
99
|
-
},
|
|
100
|
-
_k["& ~ ." + exports.checkboxClassNames.label] = {
|
|
50
|
+
_f),
|
|
51
|
+
disabled: (_j = {
|
|
101
52
|
cursor: 'default',
|
|
102
|
-
color: react_theme_1.tokens.colorNeutralForegroundDisabled
|
|
103
|
-
'@media (forced-colors: active)': {
|
|
104
|
-
color: 'GrayText',
|
|
105
|
-
},
|
|
53
|
+
color: react_theme_1.tokens.colorNeutralForegroundDisabled
|
|
106
54
|
},
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
'@media (forced-colors: active)': {
|
|
111
|
-
color: 'GrayText',
|
|
55
|
+
_j["> ." + exports.checkboxClassNames.indicator] = tslib_1.__assign(tslib_1.__assign({}, react_1.shorthands.borderColor(react_theme_1.tokens.colorNeutralStrokeDisabled)), { color: react_theme_1.tokens.colorNeutralForegroundDisabled }),
|
|
56
|
+
_j['@media (forced-colors: active)'] = (_k = {
|
|
57
|
+
color: 'GrayText'
|
|
112
58
|
},
|
|
113
|
-
|
|
114
|
-
_k["& ~ ." + exports.checkboxClassNames.indicator + " svg"] = {
|
|
115
|
-
'@media (forced-colors: active)': {
|
|
59
|
+
_k["> ." + exports.checkboxClassNames.indicator] = {
|
|
116
60
|
color: 'GrayText',
|
|
117
61
|
},
|
|
118
|
-
|
|
119
|
-
|
|
62
|
+
_k),
|
|
63
|
+
_j),
|
|
64
|
+
});
|
|
65
|
+
var useInputBaseClassName = react_1.makeResetStyles({
|
|
66
|
+
boxSizing: 'border-box',
|
|
67
|
+
cursor: 'inherit',
|
|
68
|
+
height: '100%',
|
|
69
|
+
margin: 0,
|
|
70
|
+
opacity: 0,
|
|
71
|
+
position: 'absolute',
|
|
72
|
+
top: 0,
|
|
73
|
+
// Calculate the width of the hidden input by taking into account the size of the indicator + the padding around it.
|
|
74
|
+
// This is done so that clicking on that "empty space" still toggles the checkbox.
|
|
75
|
+
width: "calc(" + indicatorSizeMedium + " + 2 * " + react_theme_1.tokens.spacingHorizontalS + ")",
|
|
120
76
|
});
|
|
121
77
|
var useInputStyles = react_1.makeStyles({
|
|
122
78
|
before: {
|
|
@@ -137,7 +93,7 @@ define(["require", "exports", "tslib", "@griffel/react", "@fluentui/react-tabste
|
|
|
137
93
|
alignItems: 'center',
|
|
138
94
|
justifyContent: 'center',
|
|
139
95
|
overflow: 'hidden',
|
|
140
|
-
border: react_theme_1.tokens.strokeWidthThin + ' solid',
|
|
96
|
+
border: react_theme_1.tokens.strokeWidthThin + ' solid ' + react_theme_1.tokens.colorNeutralStrokeAccessible,
|
|
141
97
|
borderRadius: react_theme_1.tokens.borderRadiusSmall,
|
|
142
98
|
margin: react_theme_1.tokens.spacingVerticalS + ' ' + react_theme_1.tokens.spacingHorizontalS,
|
|
143
99
|
fill: 'currentColor',
|
|
@@ -156,7 +112,7 @@ define(["require", "exports", "tslib", "@griffel/react", "@fluentui/react-tabste
|
|
|
156
112
|
});
|
|
157
113
|
// Can't use makeResetStyles here because Label is a component that may itself use makeResetStyles.
|
|
158
114
|
var useLabelStyles = react_1.makeStyles({
|
|
159
|
-
base: tslib_1.__assign({ alignSelf: 'center', cursor: '
|
|
115
|
+
base: tslib_1.__assign({ alignSelf: 'center', color: 'inherit', cursor: 'inherit' }, react_1.shorthands.padding(react_theme_1.tokens.spacingVerticalS, react_theme_1.tokens.spacingHorizontalS)),
|
|
160
116
|
before: {
|
|
161
117
|
paddingRight: react_theme_1.tokens.spacingHorizontalXS,
|
|
162
118
|
},
|
|
@@ -178,9 +134,16 @@ define(["require", "exports", "tslib", "@griffel/react", "@fluentui/react-tabste
|
|
|
178
134
|
* Apply styling to the Checkbox slots based on the state
|
|
179
135
|
*/
|
|
180
136
|
var useCheckboxStyles_unstable = function (state) {
|
|
181
|
-
var labelPosition = state.labelPosition, shape = state.shape, size = state.size;
|
|
137
|
+
var checked = state.checked, disabled = state.disabled, labelPosition = state.labelPosition, shape = state.shape, size = state.size;
|
|
182
138
|
var rootBaseClassName = useRootBaseClassName();
|
|
183
|
-
|
|
139
|
+
var rootStyles = useRootStyles();
|
|
140
|
+
state.root.className = react_1.mergeClasses(exports.checkboxClassNames.root, rootBaseClassName, disabled
|
|
141
|
+
? rootStyles.disabled
|
|
142
|
+
: checked === 'mixed'
|
|
143
|
+
? rootStyles.mixed
|
|
144
|
+
: checked
|
|
145
|
+
? rootStyles.checked
|
|
146
|
+
: rootStyles.unchecked, state.root.className);
|
|
184
147
|
var inputBaseClassName = useInputBaseClassName();
|
|
185
148
|
var inputStyles = useInputStyles();
|
|
186
149
|
state.input.className = react_1.mergeClasses(exports.checkboxClassNames.input, inputBaseClassName, size === 'large' && inputStyles.large, inputStyles[labelPosition], state.input.className);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCheckboxStyles.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-checkbox/src/components/Checkbox/useCheckboxStyles.ts"],"names":[],"mappings":";;;;;IAMa,QAAA,kBAAkB,GAAkC;QAC/D,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,qBAAqB;QAC5B,KAAK,EAAE,qBAAqB;QAC5B,SAAS,EAAE,yBAAyB;KACrC,CAAC;IAEF,+DAA+D;IAC/D,IAAM,mBAAmB,GAAG,MAAM,CAAC;IACnC,IAAM,kBAAkB,GAAG,MAAM,CAAC;IAElC,IAAM,oBAAoB,GAAG,uBAAe,oBAC1C,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AS,GAAG,oBAAY,CAClC,0BAAkB,CAAC,KAAK,EACxB,kBAAkB,EAClB,IAAI,KAAK,OAAO,IAAI,WAAW,CAAC,KAAK,EACrC,WAAW,CAAC,aAAa,CAAC,EAC1B,KAAK,CAAC,KAAK,CAAC,SAAS,CACtB,CAAC;QAEF,IAAM,sBAAsB,GAAG,yBAAyB,EAAE,CAAC;QAC3D,IAAM,eAAe,GAAG,kBAAkB,EAAE,CAAC;QAC7C,IAAI,KAAK,CAAC,SAAS,EAAE;YACnB,KAAK,CAAC,SAAS,CAAC,SAAS,GAAG,oBAAY,CACtC,0BAAkB,CAAC,SAAS,EAC5B,sBAAsB,EACtB,IAAI,KAAK,OAAO,IAAI,eAAe,CAAC,KAAK,EACzC,KAAK,KAAK,UAAU,IAAI,eAAe,CAAC,QAAQ,EAChD,KAAK,CAAC,SAAS,CAAC,SAAS,CAC1B,CAAC;SACH;QAED,IAAM,WAAW,GAAG,cAAc,EAAE,CAAC;QACrC,IAAI,KAAK,CAAC,KAAK,EAAE;YACf,KAAK,CAAC,KAAK,CAAC,SAAS,GAAG,oBAAY,CAClC,0BAAkB,CAAC,KAAK,EACxB,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC,IAAI,CAAC,EACjB,WAAW,CAAC,aAAa,CAAC,EAC1B,KAAK,CAAC,KAAK,CAAC,SAAS,CACtB,CAAC;SACH;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAxCW,QAAA,0BAA0B,8BAwCrC","sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { createFocusOutlineStyle } from '@fluentui/react-tabster';\nimport { tokens } from '@fluentui/react-theme';\nimport { CheckboxSlots, CheckboxState } from './Checkbox.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const checkboxClassNames: SlotClassNames<CheckboxSlots> = {\n root: 'fui-Checkbox',\n label: 'fui-Checkbox__label',\n input: 'fui-Checkbox__input',\n indicator: 'fui-Checkbox__indicator',\n};\n\n// The indicator size is used by the indicator and label styles\nconst indicatorSizeMedium = '16px';\nconst indicatorSizeLarge = '20px';\n\nconst useRootBaseClassName = makeResetStyles({\n position: 'relative',\n display: 'inline-flex',\n ...createFocusOutlineStyle({ style: {}, selector: 'focus-within' }),\n});\n\nconst useInputBaseClassName = makeResetStyles({\n boxSizing: 'border-box',\n cursor: 'pointer',\n height: '100%',\n margin: 0,\n opacity: 0,\n position: 'absolute',\n top: 0,\n // Calculate the width of the hidden input by taking into account the size of the indicator + the padding around it.\n // This is done so that clicking on that \"empty space\" still toggles the checkbox.\n width: `calc(${indicatorSizeMedium} + 2 * ${tokens.spacingHorizontalS})`,\n\n // Colors for the unchecked state\n ':enabled:not(:checked):not(:indeterminate)': {\n [`& ~ .${checkboxClassNames.label}`]: {\n color: tokens.colorNeutralForeground3,\n },\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorNeutralStrokeAccessible,\n },\n\n ':hover': {\n [`& ~ .${checkboxClassNames.label}`]: {\n color: tokens.colorNeutralForeground2,\n },\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorNeutralStrokeAccessibleHover,\n },\n },\n\n ':active:hover': {\n [`& ~ .${checkboxClassNames.label}`]: {\n color: tokens.colorNeutralForeground1,\n },\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorNeutralStrokeAccessiblePressed,\n },\n },\n },\n\n // Colors for the checked state\n ':enabled:checked:not(:indeterminate)': {\n [`& ~ .${checkboxClassNames.label}`]: {\n color: tokens.colorNeutralForeground1,\n },\n [`& ~ .${checkboxClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackground,\n color: tokens.colorNeutralForegroundInverted,\n borderColor: tokens.colorCompoundBrandBackground,\n },\n\n ':hover': {\n [`& ~ .${checkboxClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundHover,\n borderColor: tokens.colorCompoundBrandBackgroundHover,\n },\n },\n\n ':active:hover': {\n [`& ~ .${checkboxClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundPressed,\n borderColor: tokens.colorCompoundBrandBackgroundPressed,\n },\n },\n },\n\n // Colors for the mixed state\n ':enabled:indeterminate': {\n [`& ~ .${checkboxClassNames.label}`]: {\n color: tokens.colorNeutralForeground1,\n },\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorCompoundBrandStroke,\n color: tokens.colorCompoundBrandForeground1,\n },\n\n ':hover': {\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorCompoundBrandStrokeHover,\n color: tokens.colorCompoundBrandForeground1Hover,\n },\n },\n\n ':active:hover': {\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorCompoundBrandStrokePressed,\n color: tokens.colorCompoundBrandForeground1Pressed,\n },\n },\n },\n\n ':disabled': {\n cursor: 'default',\n\n [`& ~ .${checkboxClassNames.label}`]: {\n cursor: 'default',\n color: tokens.colorNeutralForegroundDisabled,\n '@media (forced-colors: active)': {\n color: 'GrayText',\n },\n },\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorNeutralStrokeDisabled,\n color: tokens.colorNeutralForegroundDisabled,\n '@media (forced-colors: active)': {\n color: 'GrayText',\n },\n },\n [`& ~ .${checkboxClassNames.indicator} svg`]: {\n '@media (forced-colors: active)': {\n color: 'GrayText',\n },\n },\n },\n});\n\nconst useInputStyles = makeStyles({\n before: {\n right: 0,\n },\n after: {\n left: 0,\n },\n\n large: {\n width: `calc(${indicatorSizeLarge} + 2 * ${tokens.spacingHorizontalS})`,\n },\n});\n\nconst useIndicatorBaseClassName = makeResetStyles({\n alignSelf: 'flex-start',\n boxSizing: 'border-box',\n flexShrink: 0,\n\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n overflow: 'hidden',\n\n border: tokens.strokeWidthThin + ' solid',\n borderRadius: tokens.borderRadiusSmall,\n margin: tokens.spacingVerticalS + ' ' + tokens.spacingHorizontalS,\n fill: 'currentColor',\n pointerEvents: 'none',\n\n fontSize: '12px',\n height: indicatorSizeMedium,\n width: indicatorSizeMedium,\n});\n\nconst useIndicatorStyles = makeStyles({\n large: {\n fontSize: '16px',\n height: indicatorSizeLarge,\n width: indicatorSizeLarge,\n },\n\n circular: {\n ...shorthands.borderRadius(tokens.borderRadiusCircular),\n },\n});\n\n// Can't use makeResetStyles here because Label is a component that may itself use makeResetStyles.\nconst useLabelStyles = makeStyles({\n base: {\n alignSelf: 'center',\n cursor: 'pointer',\n ...shorthands.padding(tokens.spacingVerticalS, tokens.spacingHorizontalS),\n },\n\n before: {\n paddingRight: tokens.spacingHorizontalXS,\n },\n after: {\n paddingLeft: tokens.spacingHorizontalXS,\n },\n\n // Use a (negative) margin to account for the difference between the indicator's height and the label's line height.\n // This prevents the label from expanding the height of the checkbox, but preserves line height if the label wraps.\n medium: {\n marginTop: `calc((${indicatorSizeMedium} - ${tokens.lineHeightBase300}) / 2)`,\n marginBottom: `calc((${indicatorSizeMedium} - ${tokens.lineHeightBase300}) / 2)`,\n },\n large: {\n marginTop: `calc((${indicatorSizeLarge} - ${tokens.lineHeightBase300}) / 2)`,\n marginBottom: `calc((${indicatorSizeLarge} - ${tokens.lineHeightBase300}) / 2)`,\n },\n});\n\n/**\n * Apply styling to the Checkbox slots based on the state\n */\nexport const useCheckboxStyles_unstable = (state: CheckboxState): CheckboxState => {\n const { labelPosition, shape, size } = state;\n\n const rootBaseClassName = useRootBaseClassName();\n state.root.className = mergeClasses(checkboxClassNames.root, rootBaseClassName, state.root.className);\n\n const inputBaseClassName = useInputBaseClassName();\n const inputStyles = useInputStyles();\n state.input.className = mergeClasses(\n checkboxClassNames.input,\n inputBaseClassName,\n size === 'large' && inputStyles.large,\n inputStyles[labelPosition],\n state.input.className,\n );\n\n const indicatorBaseClassName = useIndicatorBaseClassName();\n const indicatorStyles = useIndicatorStyles();\n if (state.indicator) {\n state.indicator.className = mergeClasses(\n checkboxClassNames.indicator,\n indicatorBaseClassName,\n size === 'large' && indicatorStyles.large,\n shape === 'circular' && indicatorStyles.circular,\n state.indicator.className,\n );\n }\n\n const labelStyles = useLabelStyles();\n if (state.label) {\n state.label.className = mergeClasses(\n checkboxClassNames.label,\n labelStyles.base,\n labelStyles[size],\n labelStyles[labelPosition],\n state.label.className,\n );\n }\n\n return state;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"useCheckboxStyles.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-checkbox/src/components/Checkbox/useCheckboxStyles.ts"],"names":[],"mappings":";;;;;IAMa,QAAA,kBAAkB,GAAkC;QAC/D,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,qBAAqB;QAC5B,KAAK,EAAE,qBAAqB;QAC5B,SAAS,EAAE,yBAAyB;KACrC,CAAC;IAEF,+DAA+D;IAC/D,IAAM,mBAAmB,GAAG,MAAM,CAAC;IACnC,IAAM,kBAAkB,GAAG,MAAM,CAAC;IAElC,IAAM,oBAAoB,GAAG,uBAAe,oBAC1C,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,oBAAM,CAAC,uBAAuB,IAClC,uCAAuB,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC,EACnE,CAAC;IAEH,IAAM,aAAa,GAAG,kBAAU,CAAC;QAC/B,SAAS,EAAE;YACT,QAAQ;oBACN,KAAK,EAAE,oBAAM,CAAC,uBAAuB;;gBACrC,GAAC,QAAM,0BAAkB,CAAC,SAAW,yBAChC,kBAAU,CAAC,WAAW,CAAC,oBAAM,CAAC,iCAAiC,CAAC,CACpE;mBACF;YAED,SAAS;oBACP,KAAK,EAAE,oBAAM,CAAC,uBAAuB;;gBACrC,GAAC,QAAM,0BAAkB,CAAC,SAAW,yBAChC,kBAAU,CAAC,WAAW,CAAC,oBAAM,CAAC,mCAAmC,CAAC,CACtE;mBACF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ACrC,IAAI,KAAK,CAAC,KAAK,EAAE;YACf,KAAK,CAAC,KAAK,CAAC,SAAS,GAAG,oBAAY,CAClC,0BAAkB,CAAC,KAAK,EACxB,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC,IAAI,CAAC,EACjB,WAAW,CAAC,aAAa,CAAC,EAC1B,KAAK,CAAC,KAAK,CAAC,SAAS,CACtB,CAAC;SACH;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IApDW,QAAA,0BAA0B,8BAoDrC","sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { createFocusOutlineStyle } from '@fluentui/react-tabster';\nimport { tokens } from '@fluentui/react-theme';\nimport { CheckboxSlots, CheckboxState } from './Checkbox.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const checkboxClassNames: SlotClassNames<CheckboxSlots> = {\n root: 'fui-Checkbox',\n label: 'fui-Checkbox__label',\n input: 'fui-Checkbox__input',\n indicator: 'fui-Checkbox__indicator',\n};\n\n// The indicator size is used by the indicator and label styles\nconst indicatorSizeMedium = '16px';\nconst indicatorSizeLarge = '20px';\n\nconst useRootBaseClassName = makeResetStyles({\n position: 'relative',\n display: 'inline-flex',\n cursor: 'pointer',\n color: tokens.colorNeutralForeground3,\n ...createFocusOutlineStyle({ style: {}, selector: 'focus-within' }),\n});\n\nconst useRootStyles = makeStyles({\n unchecked: {\n ':hover': {\n color: tokens.colorNeutralForeground2,\n [`> .${checkboxClassNames.indicator}`]: {\n ...shorthands.borderColor(tokens.colorNeutralStrokeAccessibleHover),\n },\n },\n\n ':active': {\n color: tokens.colorNeutralForeground1,\n [`> .${checkboxClassNames.indicator}`]: {\n ...shorthands.borderColor(tokens.colorNeutralStrokeAccessiblePressed),\n },\n },\n },\n\n checked: {\n color: tokens.colorNeutralForeground1,\n\n [`> .${checkboxClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackground,\n color: tokens.colorNeutralForegroundInverted,\n ...shorthands.borderColor(tokens.colorCompoundBrandBackground),\n },\n\n ':hover': {\n [`> .${checkboxClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundHover,\n ...shorthands.borderColor(tokens.colorCompoundBrandBackgroundHover),\n },\n },\n\n ':active': {\n [`> .${checkboxClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundPressed,\n ...shorthands.borderColor(tokens.colorCompoundBrandBackgroundPressed),\n },\n },\n },\n\n mixed: {\n color: tokens.colorNeutralForeground1,\n\n [`> .${checkboxClassNames.indicator}`]: {\n ...shorthands.borderColor(tokens.colorCompoundBrandStroke),\n color: tokens.colorCompoundBrandForeground1,\n },\n\n ':hover': {\n [`> .${checkboxClassNames.indicator}`]: {\n ...shorthands.borderColor(tokens.colorCompoundBrandStrokeHover),\n color: tokens.colorCompoundBrandForeground1Hover,\n },\n },\n\n ':active': {\n [`> .${checkboxClassNames.indicator}`]: {\n ...shorthands.borderColor(tokens.colorCompoundBrandStrokePressed),\n color: tokens.colorCompoundBrandForeground1Pressed,\n },\n },\n },\n\n disabled: {\n cursor: 'default',\n\n color: tokens.colorNeutralForegroundDisabled,\n\n [`> .${checkboxClassNames.indicator}`]: {\n ...shorthands.borderColor(tokens.colorNeutralStrokeDisabled),\n color: tokens.colorNeutralForegroundDisabled,\n },\n\n '@media (forced-colors: active)': {\n color: 'GrayText',\n [`> .${checkboxClassNames.indicator}`]: {\n color: 'GrayText',\n },\n },\n },\n});\n\nconst useInputBaseClassName = makeResetStyles({\n boxSizing: 'border-box',\n cursor: 'inherit',\n height: '100%',\n margin: 0,\n opacity: 0,\n position: 'absolute',\n top: 0,\n // Calculate the width of the hidden input by taking into account the size of the indicator + the padding around it.\n // This is done so that clicking on that \"empty space\" still toggles the checkbox.\n width: `calc(${indicatorSizeMedium} + 2 * ${tokens.spacingHorizontalS})`,\n});\n\nconst useInputStyles = makeStyles({\n before: {\n right: 0,\n },\n after: {\n left: 0,\n },\n\n large: {\n width: `calc(${indicatorSizeLarge} + 2 * ${tokens.spacingHorizontalS})`,\n },\n});\n\nconst useIndicatorBaseClassName = makeResetStyles({\n alignSelf: 'flex-start',\n boxSizing: 'border-box',\n flexShrink: 0,\n\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n overflow: 'hidden',\n\n border: tokens.strokeWidthThin + ' solid ' + tokens.colorNeutralStrokeAccessible,\n borderRadius: tokens.borderRadiusSmall,\n margin: tokens.spacingVerticalS + ' ' + tokens.spacingHorizontalS,\n fill: 'currentColor',\n pointerEvents: 'none',\n\n fontSize: '12px',\n height: indicatorSizeMedium,\n width: indicatorSizeMedium,\n});\n\nconst useIndicatorStyles = makeStyles({\n large: {\n fontSize: '16px',\n height: indicatorSizeLarge,\n width: indicatorSizeLarge,\n },\n\n circular: {\n ...shorthands.borderRadius(tokens.borderRadiusCircular),\n },\n});\n\n// Can't use makeResetStyles here because Label is a component that may itself use makeResetStyles.\nconst useLabelStyles = makeStyles({\n base: {\n alignSelf: 'center',\n color: 'inherit',\n cursor: 'inherit',\n ...shorthands.padding(tokens.spacingVerticalS, tokens.spacingHorizontalS),\n },\n\n before: {\n paddingRight: tokens.spacingHorizontalXS,\n },\n after: {\n paddingLeft: tokens.spacingHorizontalXS,\n },\n\n // Use a (negative) margin to account for the difference between the indicator's height and the label's line height.\n // This prevents the label from expanding the height of the checkbox, but preserves line height if the label wraps.\n medium: {\n marginTop: `calc((${indicatorSizeMedium} - ${tokens.lineHeightBase300}) / 2)`,\n marginBottom: `calc((${indicatorSizeMedium} - ${tokens.lineHeightBase300}) / 2)`,\n },\n large: {\n marginTop: `calc((${indicatorSizeLarge} - ${tokens.lineHeightBase300}) / 2)`,\n marginBottom: `calc((${indicatorSizeLarge} - ${tokens.lineHeightBase300}) / 2)`,\n },\n});\n\n/**\n * Apply styling to the Checkbox slots based on the state\n */\nexport const useCheckboxStyles_unstable = (state: CheckboxState): CheckboxState => {\n const { checked, disabled, labelPosition, shape, size } = state;\n\n const rootBaseClassName = useRootBaseClassName();\n const rootStyles = useRootStyles();\n state.root.className = mergeClasses(\n checkboxClassNames.root,\n rootBaseClassName,\n disabled\n ? rootStyles.disabled\n : checked === 'mixed'\n ? rootStyles.mixed\n : checked\n ? rootStyles.checked\n : rootStyles.unchecked,\n state.root.className,\n );\n\n const inputBaseClassName = useInputBaseClassName();\n const inputStyles = useInputStyles();\n state.input.className = mergeClasses(\n checkboxClassNames.input,\n inputBaseClassName,\n size === 'large' && inputStyles.large,\n inputStyles[labelPosition],\n state.input.className,\n );\n\n const indicatorBaseClassName = useIndicatorBaseClassName();\n const indicatorStyles = useIndicatorStyles();\n if (state.indicator) {\n state.indicator.className = mergeClasses(\n checkboxClassNames.indicator,\n indicatorBaseClassName,\n size === 'large' && indicatorStyles.large,\n shape === 'circular' && indicatorStyles.circular,\n state.indicator.className,\n );\n }\n\n const labelStyles = useLabelStyles();\n if (state.label) {\n state.label.className = mergeClasses(\n checkboxClassNames.label,\n labelStyles.base,\n labelStyles[size],\n labelStyles[labelPosition],\n state.label.className,\n );\n }\n\n return state;\n};\n"]}
|
|
@@ -20,7 +20,7 @@ const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
|
|
|
20
20
|
*/
|
|
21
21
|
const useCheckbox_unstable = (props, ref) => {
|
|
22
22
|
const {
|
|
23
|
-
disabled,
|
|
23
|
+
disabled = false,
|
|
24
24
|
required,
|
|
25
25
|
shape = 'square',
|
|
26
26
|
size = 'medium',
|
|
@@ -52,6 +52,7 @@ const useCheckbox_unstable = (props, ref) => {
|
|
|
52
52
|
const state = {
|
|
53
53
|
shape,
|
|
54
54
|
checked,
|
|
55
|
+
disabled,
|
|
55
56
|
size,
|
|
56
57
|
labelPosition,
|
|
57
58
|
components: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":";;;;;;AAAA;AACA;AAUA;AAOA;AACA;AAEA;;;;;;;;;AASO,MAAMA,oBAAoB,GAAG,CAACC,KAAoB,EAAEC,GAAgC,KA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AACE,aAAa,CAAC7B,OAAO;IAC/ED,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAG4B,EAAE,EAAE;MAAE3B,OAAO,EAAE4B;IAAG,CAAE,CAAC;IAChC3B,UAAU,CAAC2B,GAAG,CAAC;EACjB,CAAC,CAAC;EAEF;EACA;EACA,MAAMG,QAAQ,GAAG7B,+BAAa,CAACG,KAAK,CAACa,KAAK,CAACzB,GAAG,CAAC;EAC/CY,KAAK,CAACa,KAAK,CAACzB,GAAG,GAAGsC,QAAQ;EAE1B;EACA;EACA7B,2CAAyB,CAAC,MAAK;IAC7B,IAAI6B,QAAQ,CAACC,OAAO,EAAE;MACpBD,QAAQ,CAACC,OAAO,CAACF,aAAa,GAAGpB,KAAK;;EAE1C,CAAC,EAAE,CAACqB,QAAQ,EAAErB,KAAK,CAAC,CAAC;EAErB,OAAOL,KAAK;AACd,CAAC;AAhGY4B,4BAAoB","names":["useCheckbox_unstable","props","ref","disabled","required","shape","size","labelPosition","onChange","checked","setChecked","react_utilities_1","defaultState","defaultChecked","state","initialState","nativeProps","primarySlotTagName","excludedPropNames","mixed","id","primary","checkmarkIcon","React","react_icons_1","components","root","input","indicator","label","react_label_1","defaultProps","react_tabster_1","type","htmlFor","children","ev","val","currentTarget","indeterminate","inputRef","current","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-checkbox/src/components/Checkbox/useCheckbox.tsx"],"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';\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 { disabled = false, 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 if (checked) {\n checkmarkIcon = size === 'large' ? <Checkmark16Filled /> : <Checkmark12Filled />;\n }\n\n const state: CheckboxState = {\n shape,\n checked,\n disabled,\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: {\n ref: useFocusWithin<HTMLSpanElement>(),\n ...nativeProps.root,\n },\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"]}
|
|
@@ -16,8 +16,79 @@ exports.checkboxClassNames = {
|
|
|
16
16
|
// The indicator size is used by the indicator and label styles
|
|
17
17
|
const indicatorSizeMedium = '16px';
|
|
18
18
|
const indicatorSizeLarge = '20px';
|
|
19
|
-
const useRootBaseClassName = /*#__PURE__*/react_1.__resetStyles("
|
|
20
|
-
const
|
|
19
|
+
const useRootBaseClassName = /*#__PURE__*/react_1.__resetStyles("ripp6we", "r1b86e4p", [".ripp6we{position:relative;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;cursor:pointer;color:var(--colorNeutralForeground3);}", ".ripp6we:focus{outline-style:none;}", ".ripp6we:focus-visible{outline-style:none;}", ".ripp6we[data-fui-focus-within]:focus-within{border-top-color:transparent;border-right-color:transparent;border-bottom-color:transparent;border-left-color:transparent;}", ".ripp6we[data-fui-focus-within]:focus-within::after{content:\"\";position:absolute;pointer-events:none;z-index:1;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-width:2px;border-right-width:2px;border-bottom-width:2px;border-left-width:2px;border-bottom-right-radius:var(--borderRadiusMedium);border-bottom-left-radius:var(--borderRadiusMedium);border-top-right-radius:var(--borderRadiusMedium);border-top-left-radius:var(--borderRadiusMedium);border-top-color:var(--colorStrokeFocus2);border-right-color:var(--colorStrokeFocus2);border-bottom-color:var(--colorStrokeFocus2);border-left-color:var(--colorStrokeFocus2);top:-2px;bottom:-2px;left:-2px;right:-2px;}", ".r1b86e4p{position:relative;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;cursor:pointer;color:var(--colorNeutralForeground3);}", ".r1b86e4p:focus{outline-style:none;}", ".r1b86e4p:focus-visible{outline-style:none;}", ".r1b86e4p[data-fui-focus-within]:focus-within{border-top-color:transparent;border-left-color:transparent;border-bottom-color:transparent;border-right-color:transparent;}", ".r1b86e4p[data-fui-focus-within]:focus-within::after{content:\"\";position:absolute;pointer-events:none;z-index:1;border-top-style:solid;border-left-style:solid;border-bottom-style:solid;border-right-style:solid;border-top-width:2px;border-left-width:2px;border-bottom-width:2px;border-right-width:2px;border-bottom-left-radius:var(--borderRadiusMedium);border-bottom-right-radius:var(--borderRadiusMedium);border-top-left-radius:var(--borderRadiusMedium);border-top-right-radius:var(--borderRadiusMedium);border-top-color:var(--colorStrokeFocus2);border-left-color:var(--colorStrokeFocus2);border-bottom-color:var(--colorStrokeFocus2);border-right-color:var(--colorStrokeFocus2);top:-2px;bottom:-2px;right:-2px;left:-2px;}"]);
|
|
20
|
+
const useRootStyles = /*#__PURE__*/react_1.__styles({
|
|
21
|
+
unchecked: {
|
|
22
|
+
Bi91k9c: "f3p8bqa",
|
|
23
|
+
ns3gzv: "ffqb913",
|
|
24
|
+
n5iecx: ["f42z0vd", "f1j37kh1"],
|
|
25
|
+
Bq2lx2j: "f10v6cc1",
|
|
26
|
+
Bv7p3up: ["f1j37kh1", "f42z0vd"],
|
|
27
|
+
lj723h: "f1r2dosr",
|
|
28
|
+
B6u2zzw: "f1oarbgq",
|
|
29
|
+
Be5wueo: ["fo8gord", "f18ci1af"],
|
|
30
|
+
Cgwcxn: "fviagcr",
|
|
31
|
+
Btnvhkj: ["f18ci1af", "fo8gord"]
|
|
32
|
+
},
|
|
33
|
+
checked: {
|
|
34
|
+
sj55zd: "f19n0e5",
|
|
35
|
+
Bvs3sgl: "f5opsb9",
|
|
36
|
+
opw9sb: "fpaw01r",
|
|
37
|
+
C5wppx: "f1gqj827",
|
|
38
|
+
B32epof: ["fub94a2", "f13mj44e"],
|
|
39
|
+
Bphahg7: "f1qq5vh1",
|
|
40
|
+
Jctw66: ["f13mj44e", "fub94a2"],
|
|
41
|
+
Bq0zqd5: "f5x9vvn",
|
|
42
|
+
ns3gzv: "fub8hyy",
|
|
43
|
+
n5iecx: ["fffzknn", "f172bh4s"],
|
|
44
|
+
Bq2lx2j: "f6tipb1",
|
|
45
|
+
Bv7p3up: ["f172bh4s", "fffzknn"],
|
|
46
|
+
Bgesukf: "f8adco2",
|
|
47
|
+
B6u2zzw: "f1lepnt8",
|
|
48
|
+
Be5wueo: ["f80ygm0", "frrkusm"],
|
|
49
|
+
Cgwcxn: "f1gg953z",
|
|
50
|
+
Btnvhkj: ["frrkusm", "f80ygm0"]
|
|
51
|
+
},
|
|
52
|
+
mixed: {
|
|
53
|
+
sj55zd: "f19n0e5",
|
|
54
|
+
C5wppx: "f12fgbth",
|
|
55
|
+
B32epof: ["f171e6fm", "fttsnhr"],
|
|
56
|
+
Bphahg7: "f1fyk1ks",
|
|
57
|
+
Jctw66: ["fttsnhr", "f171e6fm"],
|
|
58
|
+
opw9sb: "fvvg2h8",
|
|
59
|
+
ns3gzv: "f1nlwys0",
|
|
60
|
+
n5iecx: ["f1bhstg2", "f6tsdgz"],
|
|
61
|
+
Bq2lx2j: "fqxbw9v",
|
|
62
|
+
Bv7p3up: ["f6tsdgz", "f1bhstg2"],
|
|
63
|
+
cc1l3s: "f1r38qqt",
|
|
64
|
+
B6u2zzw: "f12q3i2l",
|
|
65
|
+
Be5wueo: ["f9g1hxu", "f1o4ic5t"],
|
|
66
|
+
Cgwcxn: "f1c3thm1",
|
|
67
|
+
Btnvhkj: ["f1o4ic5t", "f9g1hxu"],
|
|
68
|
+
km5s60: "ffd07pq"
|
|
69
|
+
},
|
|
70
|
+
disabled: {
|
|
71
|
+
Bceei9c: "f158kwzp",
|
|
72
|
+
sj55zd: "f1s2aq7o",
|
|
73
|
+
C5wppx: "fgiuqeu",
|
|
74
|
+
B32epof: ["f1q4sfkt", "f71co73"],
|
|
75
|
+
Bphahg7: "f1u7lsiy",
|
|
76
|
+
Jctw66: ["f71co73", "f1q4sfkt"],
|
|
77
|
+
opw9sb: "f3vxa14",
|
|
78
|
+
Bbusuzp: "f1dcs8yz",
|
|
79
|
+
B7bxudy: "f1lmtjkn"
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
h: [".f3p8bqa:hover{color:var(--colorNeutralForeground2);}", ".ffqb913:hover>.fui-Checkbox__indicator{border-top-color:var(--colorNeutralStrokeAccessibleHover);}", ".f42z0vd:hover>.fui-Checkbox__indicator{border-right-color:var(--colorNeutralStrokeAccessibleHover);}", ".f1j37kh1:hover>.fui-Checkbox__indicator{border-left-color:var(--colorNeutralStrokeAccessibleHover);}", ".f10v6cc1:hover>.fui-Checkbox__indicator{border-bottom-color:var(--colorNeutralStrokeAccessibleHover);}", ".f5x9vvn:hover>.fui-Checkbox__indicator{background-color:var(--colorCompoundBrandBackgroundHover);}", ".fub8hyy:hover>.fui-Checkbox__indicator{border-top-color:var(--colorCompoundBrandBackgroundHover);}", ".fffzknn:hover>.fui-Checkbox__indicator{border-right-color:var(--colorCompoundBrandBackgroundHover);}", ".f172bh4s:hover>.fui-Checkbox__indicator{border-left-color:var(--colorCompoundBrandBackgroundHover);}", ".f6tipb1:hover>.fui-Checkbox__indicator{border-bottom-color:var(--colorCompoundBrandBackgroundHover);}", ".f1nlwys0:hover>.fui-Checkbox__indicator{border-top-color:var(--colorCompoundBrandStrokeHover);}", ".f1bhstg2:hover>.fui-Checkbox__indicator{border-right-color:var(--colorCompoundBrandStrokeHover);}", ".f6tsdgz:hover>.fui-Checkbox__indicator{border-left-color:var(--colorCompoundBrandStrokeHover);}", ".fqxbw9v:hover>.fui-Checkbox__indicator{border-bottom-color:var(--colorCompoundBrandStrokeHover);}", ".f1r38qqt:hover>.fui-Checkbox__indicator{color:var(--colorCompoundBrandForeground1Hover);}"],
|
|
83
|
+
a: [".f1r2dosr:active{color:var(--colorNeutralForeground1);}", ".f1oarbgq:active>.fui-Checkbox__indicator{border-top-color:var(--colorNeutralStrokeAccessiblePressed);}", ".fo8gord:active>.fui-Checkbox__indicator{border-right-color:var(--colorNeutralStrokeAccessiblePressed);}", ".f18ci1af:active>.fui-Checkbox__indicator{border-left-color:var(--colorNeutralStrokeAccessiblePressed);}", ".fviagcr:active>.fui-Checkbox__indicator{border-bottom-color:var(--colorNeutralStrokeAccessiblePressed);}", ".f8adco2:active>.fui-Checkbox__indicator{background-color:var(--colorCompoundBrandBackgroundPressed);}", ".f1lepnt8:active>.fui-Checkbox__indicator{border-top-color:var(--colorCompoundBrandBackgroundPressed);}", ".f80ygm0:active>.fui-Checkbox__indicator{border-right-color:var(--colorCompoundBrandBackgroundPressed);}", ".frrkusm:active>.fui-Checkbox__indicator{border-left-color:var(--colorCompoundBrandBackgroundPressed);}", ".f1gg953z:active>.fui-Checkbox__indicator{border-bottom-color:var(--colorCompoundBrandBackgroundPressed);}", ".f12q3i2l:active>.fui-Checkbox__indicator{border-top-color:var(--colorCompoundBrandStrokePressed);}", ".f9g1hxu:active>.fui-Checkbox__indicator{border-right-color:var(--colorCompoundBrandStrokePressed);}", ".f1o4ic5t:active>.fui-Checkbox__indicator{border-left-color:var(--colorCompoundBrandStrokePressed);}", ".f1c3thm1:active>.fui-Checkbox__indicator{border-bottom-color:var(--colorCompoundBrandStrokePressed);}", ".ffd07pq:active>.fui-Checkbox__indicator{color:var(--colorCompoundBrandForeground1Pressed);}"],
|
|
84
|
+
d: [".f19n0e5{color:var(--colorNeutralForeground1);}", ".f5opsb9>.fui-Checkbox__indicator{background-color:var(--colorCompoundBrandBackground);}", ".fpaw01r>.fui-Checkbox__indicator{color:var(--colorNeutralForegroundInverted);}", ".f1gqj827>.fui-Checkbox__indicator{border-top-color:var(--colorCompoundBrandBackground);}", ".fub94a2>.fui-Checkbox__indicator{border-right-color:var(--colorCompoundBrandBackground);}", ".f13mj44e>.fui-Checkbox__indicator{border-left-color:var(--colorCompoundBrandBackground);}", ".f1qq5vh1>.fui-Checkbox__indicator{border-bottom-color:var(--colorCompoundBrandBackground);}", ".f12fgbth>.fui-Checkbox__indicator{border-top-color:var(--colorCompoundBrandStroke);}", ".f171e6fm>.fui-Checkbox__indicator{border-right-color:var(--colorCompoundBrandStroke);}", ".fttsnhr>.fui-Checkbox__indicator{border-left-color:var(--colorCompoundBrandStroke);}", ".f1fyk1ks>.fui-Checkbox__indicator{border-bottom-color:var(--colorCompoundBrandStroke);}", ".fvvg2h8>.fui-Checkbox__indicator{color:var(--colorCompoundBrandForeground1);}", ".f158kwzp{cursor:default;}", ".f1s2aq7o{color:var(--colorNeutralForegroundDisabled);}", ".fgiuqeu>.fui-Checkbox__indicator{border-top-color:var(--colorNeutralStrokeDisabled);}", ".f1q4sfkt>.fui-Checkbox__indicator{border-right-color:var(--colorNeutralStrokeDisabled);}", ".f71co73>.fui-Checkbox__indicator{border-left-color:var(--colorNeutralStrokeDisabled);}", ".f1u7lsiy>.fui-Checkbox__indicator{border-bottom-color:var(--colorNeutralStrokeDisabled);}", ".f3vxa14>.fui-Checkbox__indicator{color:var(--colorNeutralForegroundDisabled);}"],
|
|
85
|
+
m: [["@media (forced-colors: active){.f1dcs8yz{color:GrayText;}}", {
|
|
86
|
+
m: "(forced-colors: active)"
|
|
87
|
+
}], ["@media (forced-colors: active){.f1lmtjkn>.fui-Checkbox__indicator{color:GrayText;}}", {
|
|
88
|
+
m: "(forced-colors: active)"
|
|
89
|
+
}]]
|
|
90
|
+
});
|
|
91
|
+
const useInputBaseClassName = /*#__PURE__*/react_1.__resetStyles("ruo9svu", null, [".ruo9svu{box-sizing:border-box;cursor:inherit;height:100%;margin:0;opacity:0;position:absolute;top:0;width:calc(16px + 2 * var(--spacingHorizontalS));}"]);
|
|
21
92
|
const useInputStyles = /*#__PURE__*/react_1.__styles({
|
|
22
93
|
before: {
|
|
23
94
|
j35jbq: ["f1e31b4d", "f1vgc2s3"]
|
|
@@ -31,7 +102,7 @@ const useInputStyles = /*#__PURE__*/react_1.__styles({
|
|
|
31
102
|
}, {
|
|
32
103
|
d: [".f1e31b4d{right:0;}", ".f1vgc2s3{left:0;}", ".f1mq5jt6{width:calc(20px + 2 * var(--spacingHorizontalS));}"]
|
|
33
104
|
});
|
|
34
|
-
const useIndicatorBaseClassName = /*#__PURE__*/react_1.__resetStyles("
|
|
105
|
+
const useIndicatorBaseClassName = /*#__PURE__*/react_1.__resetStyles("rrh91wr", null, [".rrh91wr{-webkit-align-self:flex-start;-ms-flex-item-align:flex-start;align-self:flex-start;box-sizing:border-box;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;overflow:hidden;border:var(--strokeWidthThin) solid var(--colorNeutralStrokeAccessible);border-radius:var(--borderRadiusSmall);margin:var(--spacingVerticalS) var(--spacingHorizontalS);fill:currentColor;pointer-events:none;font-size:12px;height:16px;width:16px;}"]);
|
|
35
106
|
const useIndicatorStyles = /*#__PURE__*/react_1.__styles({
|
|
36
107
|
large: {
|
|
37
108
|
Be2twd7: "f4ybsrx",
|
|
@@ -51,7 +122,8 @@ const useIndicatorStyles = /*#__PURE__*/react_1.__styles({
|
|
|
51
122
|
const useLabelStyles = /*#__PURE__*/react_1.__styles({
|
|
52
123
|
base: {
|
|
53
124
|
qb2dma: "f7nlbp4",
|
|
54
|
-
|
|
125
|
+
sj55zd: "f1ym3bx4",
|
|
126
|
+
Bceei9c: "fpo1scq",
|
|
55
127
|
z8tnut: "f1kwiid1",
|
|
56
128
|
z189sj: ["f1vdfbxk", "f1f5gg8d"],
|
|
57
129
|
Byoj8tv: "f5b47ha",
|
|
@@ -72,19 +144,22 @@ const useLabelStyles = /*#__PURE__*/react_1.__styles({
|
|
|
72
144
|
jrapky: "f49ad5g"
|
|
73
145
|
}
|
|
74
146
|
}, {
|
|
75
|
-
d: [".f7nlbp4{-webkit-align-self:center;-ms-flex-item-align:center;align-self:center;}", ".
|
|
147
|
+
d: [".f7nlbp4{-webkit-align-self:center;-ms-flex-item-align:center;align-self:center;}", ".f1ym3bx4{color:inherit;}", ".fpo1scq{cursor:inherit;}", ".f1kwiid1{padding-top:var(--spacingVerticalS);}", ".f1vdfbxk{padding-right:var(--spacingHorizontalS);}", ".f1f5gg8d{padding-left:var(--spacingHorizontalS);}", ".f5b47ha{padding-bottom:var(--spacingVerticalS);}", ".f7x41pl{padding-right:var(--spacingHorizontalXS);}", ".fruq291{padding-left:var(--spacingHorizontalXS);}", ".fjzwpt6{margin-top:calc((16px - var(--lineHeightBase300)) / 2);}", ".fh6j2fo{margin-bottom:calc((16px - var(--lineHeightBase300)) / 2);}", ".f1xlvstr{margin-top:calc((20px - var(--lineHeightBase300)) / 2);}", ".f49ad5g{margin-bottom:calc((20px - var(--lineHeightBase300)) / 2);}"]
|
|
76
148
|
});
|
|
77
149
|
/**
|
|
78
150
|
* Apply styling to the Checkbox slots based on the state
|
|
79
151
|
*/
|
|
80
152
|
const useCheckboxStyles_unstable = state => {
|
|
81
153
|
const {
|
|
154
|
+
checked,
|
|
155
|
+
disabled,
|
|
82
156
|
labelPosition,
|
|
83
157
|
shape,
|
|
84
158
|
size
|
|
85
159
|
} = state;
|
|
86
160
|
const rootBaseClassName = useRootBaseClassName();
|
|
87
|
-
|
|
161
|
+
const rootStyles = useRootStyles();
|
|
162
|
+
state.root.className = react_1.mergeClasses(exports.checkboxClassNames.root, rootBaseClassName, disabled ? rootStyles.disabled : checked === 'mixed' ? rootStyles.mixed : checked ? rootStyles.checked : rootStyles.unchecked, state.root.className);
|
|
88
163
|
const inputBaseClassName = useInputBaseClassName();
|
|
89
164
|
const inputStyles = useInputStyles();
|
|
90
165
|
state.input.className = react_1.mergeClasses(exports.checkboxClassNames.input, inputBaseClassName, size === 'large' && inputStyles.large, inputStyles[labelPosition], state.input.className);
|
|
@@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,cAAc,EAAE;EACpCK,KAAK,CAACZ,KAAK,CAACiB,SAAS,GAAGZ,oBAAY,CAClCR,0BAAkB,CAACG,KAAK,EACxBkB,kBAAkB,EAClBH,IAAI,KAAK,OAAO,IAAII,WAAW,CAACC,KAAK,EACrCD,WAAW,CAACN,aAAa,CAAC,EAC1BD,KAAK,CAACZ,KAAK,CAACiB,SAAS,CACtB;EAED,MAAMI,sBAAsB,GAAGb,yBAAyB,EAAE;EAC1D,MAAMc,eAAe,GAAGb,kBAAkB,EAAE;EAC5C,IAAIG,KAAK,CAACX,SAAS,EAAE;IACnBW,KAAK,CAACX,SAAS,CAACgB,SAAS,GAAGZ,oBAAY,CACtCR,0BAAkB,CAACI,SAAS,EAC5BoB,sBAAsB,EACtBN,IAAI,KAAK,OAAO,IAAIO,eAAe,CAACF,KAAK,EACzCN,KAAK,KAAK,UAAU,IAAIQ,eAAe,CAACC,QAAQ,EAChDX,KAAK,CAACX,SAAS,CAACgB,SAAS,CAC1B;;EAGH,MAAMO,WAAW,GAAGd,cAAc,EAAE;EACpC,IAAIE,KAAK,CAACb,KAAK,EAAE;IACfa,KAAK,CAACb,KAAK,CAACkB,SAAS,GAAGZ,oBAAY,CAClCR,0BAAkB,CAACE,KAAK,EACxByB,WAAW,CAACC,IAAI,EAChBD,WAAW,CAACT,IAAI,CAAC,EACjBS,WAAW,CAACX,aAAa,CAAC,EAC1BD,KAAK,CAACb,KAAK,CAACkB,SAAS,CACtB;;EAGH,OAAOL,KAAK;AACd,CAAC;AAxCYf,kCAA0B","names":["exports","root","label","input","indicator","indicatorSizeMedium","indicatorSizeLarge","useRootBaseClassName","react_1","useInputBaseClassName","useInputStyles","useIndicatorBaseClassName","useIndicatorStyles","useLabelStyles","useCheckboxStyles_unstable","state","labelPosition","shape","size","rootBaseClassName","className","inputBaseClassName","inputStyles","large","indicatorBaseClassName","indicatorStyles","circular","labelStyles","base"],"sourceRoot":"../src/","sources":["packages/react-components/react-checkbox/src/components/Checkbox/useCheckboxStyles.ts"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { createFocusOutlineStyle } from '@fluentui/react-tabster';\nimport { tokens } from '@fluentui/react-theme';\nimport { CheckboxSlots, CheckboxState } from './Checkbox.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const checkboxClassNames: SlotClassNames<CheckboxSlots> = {\n root: 'fui-Checkbox',\n label: 'fui-Checkbox__label',\n input: 'fui-Checkbox__input',\n indicator: 'fui-Checkbox__indicator',\n};\n\n// The indicator size is used by the indicator and label styles\nconst indicatorSizeMedium = '16px';\nconst indicatorSizeLarge = '20px';\n\nconst useRootBaseClassName = makeResetStyles({\n position: 'relative',\n display: 'inline-flex',\n ...createFocusOutlineStyle({ style: {}, selector: 'focus-within' }),\n});\n\nconst useInputBaseClassName = makeResetStyles({\n boxSizing: 'border-box',\n cursor: 'pointer',\n height: '100%',\n margin: 0,\n opacity: 0,\n position: 'absolute',\n top: 0,\n // Calculate the width of the hidden input by taking into account the size of the indicator + the padding around it.\n // This is done so that clicking on that \"empty space\" still toggles the checkbox.\n width: `calc(${indicatorSizeMedium} + 2 * ${tokens.spacingHorizontalS})`,\n\n // Colors for the unchecked state\n ':enabled:not(:checked):not(:indeterminate)': {\n [`& ~ .${checkboxClassNames.label}`]: {\n color: tokens.colorNeutralForeground3,\n },\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorNeutralStrokeAccessible,\n },\n\n ':hover': {\n [`& ~ .${checkboxClassNames.label}`]: {\n color: tokens.colorNeutralForeground2,\n },\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorNeutralStrokeAccessibleHover,\n },\n },\n\n ':active:hover': {\n [`& ~ .${checkboxClassNames.label}`]: {\n color: tokens.colorNeutralForeground1,\n },\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorNeutralStrokeAccessiblePressed,\n },\n },\n },\n\n // Colors for the checked state\n ':enabled:checked:not(:indeterminate)': {\n [`& ~ .${checkboxClassNames.label}`]: {\n color: tokens.colorNeutralForeground1,\n },\n [`& ~ .${checkboxClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackground,\n color: tokens.colorNeutralForegroundInverted,\n borderColor: tokens.colorCompoundBrandBackground,\n },\n\n ':hover': {\n [`& ~ .${checkboxClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundHover,\n borderColor: tokens.colorCompoundBrandBackgroundHover,\n },\n },\n\n ':active:hover': {\n [`& ~ .${checkboxClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundPressed,\n borderColor: tokens.colorCompoundBrandBackgroundPressed,\n },\n },\n },\n\n // Colors for the mixed state\n ':enabled:indeterminate': {\n [`& ~ .${checkboxClassNames.label}`]: {\n color: tokens.colorNeutralForeground1,\n },\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorCompoundBrandStroke,\n color: tokens.colorCompoundBrandForeground1,\n },\n\n ':hover': {\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorCompoundBrandStrokeHover,\n color: tokens.colorCompoundBrandForeground1Hover,\n },\n },\n\n ':active:hover': {\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorCompoundBrandStrokePressed,\n color: tokens.colorCompoundBrandForeground1Pressed,\n },\n },\n },\n\n ':disabled': {\n cursor: 'default',\n\n [`& ~ .${checkboxClassNames.label}`]: {\n cursor: 'default',\n color: tokens.colorNeutralForegroundDisabled,\n '@media (forced-colors: active)': {\n color: 'GrayText',\n },\n },\n [`& ~ .${checkboxClassNames.indicator}`]: {\n borderColor: tokens.colorNeutralStrokeDisabled,\n color: tokens.colorNeutralForegroundDisabled,\n '@media (forced-colors: active)': {\n color: 'GrayText',\n },\n },\n [`& ~ .${checkboxClassNames.indicator} svg`]: {\n '@media (forced-colors: active)': {\n color: 'GrayText',\n },\n },\n },\n});\n\nconst useInputStyles = makeStyles({\n before: {\n right: 0,\n },\n after: {\n left: 0,\n },\n\n large: {\n width: `calc(${indicatorSizeLarge} + 2 * ${tokens.spacingHorizontalS})`,\n },\n});\n\nconst useIndicatorBaseClassName = makeResetStyles({\n alignSelf: 'flex-start',\n boxSizing: 'border-box',\n flexShrink: 0,\n\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n overflow: 'hidden',\n\n border: tokens.strokeWidthThin + ' solid',\n borderRadius: tokens.borderRadiusSmall,\n margin: tokens.spacingVerticalS + ' ' + tokens.spacingHorizontalS,\n fill: 'currentColor',\n pointerEvents: 'none',\n\n fontSize: '12px',\n height: indicatorSizeMedium,\n width: indicatorSizeMedium,\n});\n\nconst useIndicatorStyles = makeStyles({\n large: {\n fontSize: '16px',\n height: indicatorSizeLarge,\n width: indicatorSizeLarge,\n },\n\n circular: {\n ...shorthands.borderRadius(tokens.borderRadiusCircular),\n },\n});\n\n// Can't use makeResetStyles here because Label is a component that may itself use makeResetStyles.\nconst useLabelStyles = makeStyles({\n base: {\n alignSelf: 'center',\n cursor: 'pointer',\n ...shorthands.padding(tokens.spacingVerticalS, tokens.spacingHorizontalS),\n },\n\n before: {\n paddingRight: tokens.spacingHorizontalXS,\n },\n after: {\n paddingLeft: tokens.spacingHorizontalXS,\n },\n\n // Use a (negative) margin to account for the difference between the indicator's height and the label's line height.\n // This prevents the label from expanding the height of the checkbox, but preserves line height if the label wraps.\n medium: {\n marginTop: `calc((${indicatorSizeMedium} - ${tokens.lineHeightBase300}) / 2)`,\n marginBottom: `calc((${indicatorSizeMedium} - ${tokens.lineHeightBase300}) / 2)`,\n },\n large: {\n marginTop: `calc((${indicatorSizeLarge} - ${tokens.lineHeightBase300}) / 2)`,\n marginBottom: `calc((${indicatorSizeLarge} - ${tokens.lineHeightBase300}) / 2)`,\n },\n});\n\n/**\n * Apply styling to the Checkbox slots based on the state\n */\nexport const useCheckboxStyles_unstable = (state: CheckboxState): CheckboxState => {\n const { labelPosition, shape, size } = state;\n\n const rootBaseClassName = useRootBaseClassName();\n state.root.className = mergeClasses(checkboxClassNames.root, rootBaseClassName, state.root.className);\n\n const inputBaseClassName = useInputBaseClassName();\n const inputStyles = useInputStyles();\n state.input.className = mergeClasses(\n checkboxClassNames.input,\n inputBaseClassName,\n size === 'large' && inputStyles.large,\n inputStyles[labelPosition],\n state.input.className,\n );\n\n const indicatorBaseClassName = useIndicatorBaseClassName();\n const indicatorStyles = useIndicatorStyles();\n if (state.indicator) {\n state.indicator.className = mergeClasses(\n checkboxClassNames.indicator,\n indicatorBaseClassName,\n size === 'large' && indicatorStyles.large,\n shape === 'circular' && indicatorStyles.circular,\n state.indicator.className,\n );\n }\n\n const labelStyles = useLabelStyles();\n if (state.label) {\n state.label.className = mergeClasses(\n checkboxClassNames.label,\n labelStyles.base,\n labelStyles[size],\n labelStyles[labelPosition],\n state.label.className,\n );\n }\n\n return state;\n};\n"]}
|
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AAIaA,0BAAkB,GAAkC;EAC/DC,IAAI,EAAE,cAAc;EACpBC,KAAK,EAAE,qBAAqB;EAC5BC,KAAK,EAAE,qBAAqB;EAC5BC,SAAS,EAAE;CACZ;AAED;AACA,MAAMC,mBAAmB,GAAG,MAAM;AAClC,MAAMC,kBAAkB,GAAG,MAAM;AAEjC,MAAMC,oBAAoB,gBAAGC,qBAAe,k0EAM1C;AAEF,MAAMC,aAAa,gBAAGD,gBAAU;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA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AAGjB,cAAc,EAAE;EACpCK,KAAK,CAACb,KAAK,CAACqB,SAAS,GAAGhB,oBAAY,CAClCR,0BAAkB,CAACG,KAAK,EACxBwB,kBAAkB,EAClBN,IAAI,KAAK,OAAO,IAAIO,WAAW,CAACC,KAAK,EACrCD,WAAW,CAACT,aAAa,CAAC,EAC1BH,KAAK,CAACb,KAAK,CAACqB,SAAS,CACtB;EAED,MAAMM,sBAAsB,GAAGlB,yBAAyB,EAAE;EAC1D,MAAMmB,eAAe,GAAGlB,kBAAkB,EAAE;EAC5C,IAAIG,KAAK,CAACZ,SAAS,EAAE;IACnBY,KAAK,CAACZ,SAAS,CAACoB,SAAS,GAAGhB,oBAAY,CACtCR,0BAAkB,CAACI,SAAS,EAC5B0B,sBAAsB,EACtBT,IAAI,KAAK,OAAO,IAAIU,eAAe,CAACF,KAAK,EACzCT,KAAK,KAAK,UAAU,IAAIW,eAAe,CAACC,QAAQ,EAChDhB,KAAK,CAACZ,SAAS,CAACoB,SAAS,CAC1B;;EAGH,MAAMS,WAAW,GAAGnB,cAAc,EAAE;EACpC,IAAIE,KAAK,CAACd,KAAK,EAAE;IACfc,KAAK,CAACd,KAAK,CAACsB,SAAS,GAAGhB,oBAAY,CAClCR,0BAAkB,CAACE,KAAK,EACxB+B,WAAW,CAACC,IAAI,EAChBD,WAAW,CAACZ,IAAI,CAAC,EACjBY,WAAW,CAACd,aAAa,CAAC,EAC1BH,KAAK,CAACd,KAAK,CAACsB,SAAS,CACtB;;EAGH,OAAOR,KAAK;AACd,CAAC;AApDYhB,kCAA0B","names":["exports","root","label","input","indicator","indicatorSizeMedium","indicatorSizeLarge","useRootBaseClassName","react_1","useRootStyles","useInputBaseClassName","useInputStyles","useIndicatorBaseClassName","useIndicatorStyles","useLabelStyles","useCheckboxStyles_unstable","state","checked","disabled","labelPosition","shape","size","rootBaseClassName","rootStyles","className","mixed","unchecked","inputBaseClassName","inputStyles","large","indicatorBaseClassName","indicatorStyles","circular","labelStyles","base"],"sourceRoot":"../src/","sources":["packages/react-components/react-checkbox/src/components/Checkbox/useCheckboxStyles.ts"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { createFocusOutlineStyle } from '@fluentui/react-tabster';\nimport { tokens } from '@fluentui/react-theme';\nimport { CheckboxSlots, CheckboxState } from './Checkbox.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const checkboxClassNames: SlotClassNames<CheckboxSlots> = {\n root: 'fui-Checkbox',\n label: 'fui-Checkbox__label',\n input: 'fui-Checkbox__input',\n indicator: 'fui-Checkbox__indicator',\n};\n\n// The indicator size is used by the indicator and label styles\nconst indicatorSizeMedium = '16px';\nconst indicatorSizeLarge = '20px';\n\nconst useRootBaseClassName = makeResetStyles({\n position: 'relative',\n display: 'inline-flex',\n cursor: 'pointer',\n color: tokens.colorNeutralForeground3,\n ...createFocusOutlineStyle({ style: {}, selector: 'focus-within' }),\n});\n\nconst useRootStyles = makeStyles({\n unchecked: {\n ':hover': {\n color: tokens.colorNeutralForeground2,\n [`> .${checkboxClassNames.indicator}`]: {\n ...shorthands.borderColor(tokens.colorNeutralStrokeAccessibleHover),\n },\n },\n\n ':active': {\n color: tokens.colorNeutralForeground1,\n [`> .${checkboxClassNames.indicator}`]: {\n ...shorthands.borderColor(tokens.colorNeutralStrokeAccessiblePressed),\n },\n },\n },\n\n checked: {\n color: tokens.colorNeutralForeground1,\n\n [`> .${checkboxClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackground,\n color: tokens.colorNeutralForegroundInverted,\n ...shorthands.borderColor(tokens.colorCompoundBrandBackground),\n },\n\n ':hover': {\n [`> .${checkboxClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundHover,\n ...shorthands.borderColor(tokens.colorCompoundBrandBackgroundHover),\n },\n },\n\n ':active': {\n [`> .${checkboxClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundPressed,\n ...shorthands.borderColor(tokens.colorCompoundBrandBackgroundPressed),\n },\n },\n },\n\n mixed: {\n color: tokens.colorNeutralForeground1,\n\n [`> .${checkboxClassNames.indicator}`]: {\n ...shorthands.borderColor(tokens.colorCompoundBrandStroke),\n color: tokens.colorCompoundBrandForeground1,\n },\n\n ':hover': {\n [`> .${checkboxClassNames.indicator}`]: {\n ...shorthands.borderColor(tokens.colorCompoundBrandStrokeHover),\n color: tokens.colorCompoundBrandForeground1Hover,\n },\n },\n\n ':active': {\n [`> .${checkboxClassNames.indicator}`]: {\n ...shorthands.borderColor(tokens.colorCompoundBrandStrokePressed),\n color: tokens.colorCompoundBrandForeground1Pressed,\n },\n },\n },\n\n disabled: {\n cursor: 'default',\n\n color: tokens.colorNeutralForegroundDisabled,\n\n [`> .${checkboxClassNames.indicator}`]: {\n ...shorthands.borderColor(tokens.colorNeutralStrokeDisabled),\n color: tokens.colorNeutralForegroundDisabled,\n },\n\n '@media (forced-colors: active)': {\n color: 'GrayText',\n [`> .${checkboxClassNames.indicator}`]: {\n color: 'GrayText',\n },\n },\n },\n});\n\nconst useInputBaseClassName = makeResetStyles({\n boxSizing: 'border-box',\n cursor: 'inherit',\n height: '100%',\n margin: 0,\n opacity: 0,\n position: 'absolute',\n top: 0,\n // Calculate the width of the hidden input by taking into account the size of the indicator + the padding around it.\n // This is done so that clicking on that \"empty space\" still toggles the checkbox.\n width: `calc(${indicatorSizeMedium} + 2 * ${tokens.spacingHorizontalS})`,\n});\n\nconst useInputStyles = makeStyles({\n before: {\n right: 0,\n },\n after: {\n left: 0,\n },\n\n large: {\n width: `calc(${indicatorSizeLarge} + 2 * ${tokens.spacingHorizontalS})`,\n },\n});\n\nconst useIndicatorBaseClassName = makeResetStyles({\n alignSelf: 'flex-start',\n boxSizing: 'border-box',\n flexShrink: 0,\n\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n overflow: 'hidden',\n\n border: tokens.strokeWidthThin + ' solid ' + tokens.colorNeutralStrokeAccessible,\n borderRadius: tokens.borderRadiusSmall,\n margin: tokens.spacingVerticalS + ' ' + tokens.spacingHorizontalS,\n fill: 'currentColor',\n pointerEvents: 'none',\n\n fontSize: '12px',\n height: indicatorSizeMedium,\n width: indicatorSizeMedium,\n});\n\nconst useIndicatorStyles = makeStyles({\n large: {\n fontSize: '16px',\n height: indicatorSizeLarge,\n width: indicatorSizeLarge,\n },\n\n circular: {\n ...shorthands.borderRadius(tokens.borderRadiusCircular),\n },\n});\n\n// Can't use makeResetStyles here because Label is a component that may itself use makeResetStyles.\nconst useLabelStyles = makeStyles({\n base: {\n alignSelf: 'center',\n color: 'inherit',\n cursor: 'inherit',\n ...shorthands.padding(tokens.spacingVerticalS, tokens.spacingHorizontalS),\n },\n\n before: {\n paddingRight: tokens.spacingHorizontalXS,\n },\n after: {\n paddingLeft: tokens.spacingHorizontalXS,\n },\n\n // Use a (negative) margin to account for the difference between the indicator's height and the label's line height.\n // This prevents the label from expanding the height of the checkbox, but preserves line height if the label wraps.\n medium: {\n marginTop: `calc((${indicatorSizeMedium} - ${tokens.lineHeightBase300}) / 2)`,\n marginBottom: `calc((${indicatorSizeMedium} - ${tokens.lineHeightBase300}) / 2)`,\n },\n large: {\n marginTop: `calc((${indicatorSizeLarge} - ${tokens.lineHeightBase300}) / 2)`,\n marginBottom: `calc((${indicatorSizeLarge} - ${tokens.lineHeightBase300}) / 2)`,\n },\n});\n\n/**\n * Apply styling to the Checkbox slots based on the state\n */\nexport const useCheckboxStyles_unstable = (state: CheckboxState): CheckboxState => {\n const { checked, disabled, labelPosition, shape, size } = state;\n\n const rootBaseClassName = useRootBaseClassName();\n const rootStyles = useRootStyles();\n state.root.className = mergeClasses(\n checkboxClassNames.root,\n rootBaseClassName,\n disabled\n ? rootStyles.disabled\n : checked === 'mixed'\n ? rootStyles.mixed\n : checked\n ? rootStyles.checked\n : rootStyles.unchecked,\n state.root.className,\n );\n\n const inputBaseClassName = useInputBaseClassName();\n const inputStyles = useInputStyles();\n state.input.className = mergeClasses(\n checkboxClassNames.input,\n inputBaseClassName,\n size === 'large' && inputStyles.large,\n inputStyles[labelPosition],\n state.input.className,\n );\n\n const indicatorBaseClassName = useIndicatorBaseClassName();\n const indicatorStyles = useIndicatorStyles();\n if (state.indicator) {\n state.indicator.className = mergeClasses(\n checkboxClassNames.indicator,\n indicatorBaseClassName,\n size === 'large' && indicatorStyles.large,\n shape === 'circular' && indicatorStyles.circular,\n state.indicator.className,\n );\n }\n\n const labelStyles = useLabelStyles();\n if (state.label) {\n state.label.className = mergeClasses(\n checkboxClassNames.label,\n labelStyles.base,\n labelStyles[size],\n labelStyles[labelPosition],\n state.label.className,\n );\n }\n\n return state;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/react-checkbox",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.21",
|
|
4
4
|
"description": "Fluent UI checkbox component",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -28,13 +28,14 @@
|
|
|
28
28
|
"@fluentui/eslint-plugin": "*",
|
|
29
29
|
"@fluentui/react-conformance": "*",
|
|
30
30
|
"@fluentui/react-conformance-griffel": "9.0.0-beta.19",
|
|
31
|
-
"@fluentui/scripts": "*"
|
|
31
|
+
"@fluentui/scripts-api-extractor": "*",
|
|
32
|
+
"@fluentui/scripts-tasks": "*"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"@fluentui/react-field": "9.0.0-alpha.
|
|
35
|
+
"@fluentui/react-field": "9.0.0-alpha.15",
|
|
35
36
|
"@fluentui/react-icons": "^2.0.175",
|
|
36
|
-
"@fluentui/react-label": "^9.0.
|
|
37
|
-
"@fluentui/react-tabster": "^9.
|
|
37
|
+
"@fluentui/react-label": "^9.0.17",
|
|
38
|
+
"@fluentui/react-tabster": "^9.4.0",
|
|
38
39
|
"@fluentui/react-theme": "^9.1.5",
|
|
39
40
|
"@fluentui/react-utilities": "^9.4.0",
|
|
40
41
|
"@griffel/react": "^1.5.2",
|