@fluentui/react-switch 9.1.7 → 9.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +65 -5
- package/CHANGELOG.md +29 -6
- package/lib/components/Switch/useSwitch.js +6 -0
- package/lib/components/Switch/useSwitch.js.map +1 -1
- package/lib-commonjs/components/Switch/useSwitch.js +6 -0
- package/lib-commonjs/components/Switch/useSwitch.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,67 @@
|
|
2
2
|
"name": "@fluentui/react-switch",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Wed, 12 Apr 2023 09:28:17 GMT",
|
6
|
+
"tag": "@fluentui/react-switch_v9.1.9",
|
7
|
+
"version": "9.1.9",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"author": "beachball",
|
12
|
+
"package": "@fluentui/react-switch",
|
13
|
+
"comment": "Bump @fluentui/react-field to v9.0.0-beta.2",
|
14
|
+
"commit": "b48890859f5ce28fe12fd40f6bda26ed486c5e47"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"author": "beachball",
|
18
|
+
"package": "@fluentui/react-switch",
|
19
|
+
"comment": "Bump @fluentui/react-label to v9.1.8",
|
20
|
+
"commit": "b48890859f5ce28fe12fd40f6bda26ed486c5e47"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"author": "beachball",
|
24
|
+
"package": "@fluentui/react-switch",
|
25
|
+
"comment": "Bump @fluentui/react-tabster to v9.6.4",
|
26
|
+
"commit": "b48890859f5ce28fe12fd40f6bda26ed486c5e47"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"author": "beachball",
|
30
|
+
"package": "@fluentui/react-switch",
|
31
|
+
"comment": "Bump @fluentui/react-utilities to v9.7.4",
|
32
|
+
"commit": "b48890859f5ce28fe12fd40f6bda26ed486c5e47"
|
33
|
+
}
|
34
|
+
]
|
35
|
+
}
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"date": "Fri, 07 Apr 2023 00:01:44 GMT",
|
39
|
+
"tag": "@fluentui/react-switch_v9.1.8",
|
40
|
+
"version": "9.1.8",
|
41
|
+
"comments": {
|
42
|
+
"patch": [
|
43
|
+
{
|
44
|
+
"author": "behowell@microsoft.com",
|
45
|
+
"package": "@fluentui/react-switch",
|
46
|
+
"commit": "5a8d7a29645b3b500eb7145d2e42ac34fcafc4c6",
|
47
|
+
"comment": "chore: Hook up FieldContext for use inside a Field"
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"author": "behowell@microsoft.com",
|
51
|
+
"package": "@fluentui/react-switch",
|
52
|
+
"commit": "eee5716e76dc6a5bef9316546a352694bbe5750a",
|
53
|
+
"comment": "chore: Update package version of react-field"
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"author": "beachball",
|
57
|
+
"package": "@fluentui/react-switch",
|
58
|
+
"comment": "Bump @fluentui/react-field to v9.0.0-beta.1",
|
59
|
+
"commit": "7a46cab3d31a233b89b7188e994b24712af5393c"
|
60
|
+
}
|
61
|
+
]
|
62
|
+
}
|
63
|
+
},
|
64
|
+
{
|
65
|
+
"date": "Tue, 04 Apr 2023 18:44:50 GMT",
|
6
66
|
"tag": "@fluentui/react-switch_v9.1.7",
|
7
67
|
"version": "9.1.7",
|
8
68
|
"comments": {
|
@@ -11,25 +71,25 @@
|
|
11
71
|
"author": "beachball",
|
12
72
|
"package": "@fluentui/react-switch",
|
13
73
|
"comment": "Bump @fluentui/react-field to v9.0.0-alpha.29",
|
14
|
-
"commit": "
|
74
|
+
"commit": "6778d76bbbad7e1975c151c797f28c2708cde2ce"
|
15
75
|
},
|
16
76
|
{
|
17
77
|
"author": "beachball",
|
18
78
|
"package": "@fluentui/react-switch",
|
19
79
|
"comment": "Bump @fluentui/react-label to v9.1.7",
|
20
|
-
"commit": "
|
80
|
+
"commit": "6778d76bbbad7e1975c151c797f28c2708cde2ce"
|
21
81
|
},
|
22
82
|
{
|
23
83
|
"author": "beachball",
|
24
84
|
"package": "@fluentui/react-switch",
|
25
85
|
"comment": "Bump @fluentui/react-tabster to v9.6.3",
|
26
|
-
"commit": "
|
86
|
+
"commit": "6778d76bbbad7e1975c151c797f28c2708cde2ce"
|
27
87
|
},
|
28
88
|
{
|
29
89
|
"author": "beachball",
|
30
90
|
"package": "@fluentui/react-switch",
|
31
91
|
"comment": "Bump @fluentui/react-utilities to v9.7.3",
|
32
|
-
"commit": "
|
92
|
+
"commit": "6778d76bbbad7e1975c151c797f28c2708cde2ce"
|
33
93
|
}
|
34
94
|
]
|
35
95
|
}
|
package/CHANGELOG.md
CHANGED
@@ -1,20 +1,43 @@
|
|
1
1
|
# Change Log - @fluentui/react-switch
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Wed, 12 Apr 2023 09:28:17 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.1.9](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.1.9)
|
8
|
+
|
9
|
+
Wed, 12 Apr 2023 09:28:17 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.1.8..@fluentui/react-switch_v9.1.9)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- Bump @fluentui/react-field to v9.0.0-beta.2 ([commit](https://github.com/microsoft/fluentui/commit/b48890859f5ce28fe12fd40f6bda26ed486c5e47) by beachball)
|
15
|
+
- Bump @fluentui/react-label to v9.1.8 ([commit](https://github.com/microsoft/fluentui/commit/b48890859f5ce28fe12fd40f6bda26ed486c5e47) by beachball)
|
16
|
+
- Bump @fluentui/react-tabster to v9.6.4 ([commit](https://github.com/microsoft/fluentui/commit/b48890859f5ce28fe12fd40f6bda26ed486c5e47) by beachball)
|
17
|
+
- Bump @fluentui/react-utilities to v9.7.4 ([commit](https://github.com/microsoft/fluentui/commit/b48890859f5ce28fe12fd40f6bda26ed486c5e47) by beachball)
|
18
|
+
|
19
|
+
## [9.1.8](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.1.8)
|
20
|
+
|
21
|
+
Fri, 07 Apr 2023 00:01:44 GMT
|
22
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.1.7..@fluentui/react-switch_v9.1.8)
|
23
|
+
|
24
|
+
### Patches
|
25
|
+
|
26
|
+
- chore: Hook up FieldContext for use inside a Field ([PR #27399](https://github.com/microsoft/fluentui/pull/27399) by behowell@microsoft.com)
|
27
|
+
- chore: Update package version of react-field ([PR #27458](https://github.com/microsoft/fluentui/pull/27458) by behowell@microsoft.com)
|
28
|
+
- Bump @fluentui/react-field to v9.0.0-beta.1 ([PR #27420](https://github.com/microsoft/fluentui/pull/27420) by beachball)
|
29
|
+
|
7
30
|
## [9.1.7](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.1.7)
|
8
31
|
|
9
|
-
Tue, 04 Apr 2023 18:
|
32
|
+
Tue, 04 Apr 2023 18:44:50 GMT
|
10
33
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.1.5..@fluentui/react-switch_v9.1.7)
|
11
34
|
|
12
35
|
### Patches
|
13
36
|
|
14
|
-
- Bump @fluentui/react-field to v9.0.0-alpha.29 ([PR #
|
15
|
-
- Bump @fluentui/react-label to v9.1.7 ([PR #
|
16
|
-
- Bump @fluentui/react-tabster to v9.6.3 ([PR #
|
17
|
-
- Bump @fluentui/react-utilities to v9.7.3 ([PR #
|
37
|
+
- Bump @fluentui/react-field to v9.0.0-alpha.29 ([PR #27434](https://github.com/microsoft/fluentui/pull/27434) by beachball)
|
38
|
+
- Bump @fluentui/react-label to v9.1.7 ([PR #27434](https://github.com/microsoft/fluentui/pull/27434) by beachball)
|
39
|
+
- Bump @fluentui/react-tabster to v9.6.3 ([PR #27434](https://github.com/microsoft/fluentui/pull/27434) by beachball)
|
40
|
+
- Bump @fluentui/react-utilities to v9.7.3 ([PR #27434](https://github.com/microsoft/fluentui/pull/27434) by beachball)
|
18
41
|
|
19
42
|
## [9.1.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.1.5)
|
20
43
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
+
import { useFieldControlProps_unstable } from '@fluentui/react-field';
|
2
3
|
import { CircleFilled } from '@fluentui/react-icons';
|
3
4
|
import { Label } from '@fluentui/react-label';
|
4
5
|
import { useFocusWithin } from '@fluentui/react-tabster';
|
@@ -13,6 +14,11 @@ import { getPartitionedNativeProps, mergeCallbacks, resolveShorthand, useId } fr
|
|
13
14
|
* @param ref - reference to `<input>` element of Switch
|
14
15
|
*/
|
15
16
|
export const useSwitch_unstable = (props, ref) => {
|
17
|
+
// Merge props from surrounding <Field>, if any
|
18
|
+
props = useFieldControlProps_unstable(props, {
|
19
|
+
supportsLabelFor: true,
|
20
|
+
supportsRequired: true
|
21
|
+
});
|
16
22
|
const {
|
17
23
|
checked,
|
18
24
|
defaultChecked,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","CircleFilled","Label","useFocusWithin","getPartitionedNativeProps","mergeCallbacks","resolveShorthand","useId","useSwitch_unstable","props","ref","checked","defaultChecked","disabled","labelPosition","onChange","required","nativeProps","primarySlotTagName","excludedPropNames","id","primary","root","defaultProps","indicator","children","createElement","input","role","type","ev","currentTarget","label","htmlFor","size","components"],"sources":["../../../src/components/Switch/useSwitch.tsx"],"sourcesContent":["import * as React from 'react';\nimport { CircleFilled } from '@fluentui/react-icons';\nimport { Label } from '@fluentui/react-label';\nimport { useFocusWithin } from '@fluentui/react-tabster';\nimport { getPartitionedNativeProps, mergeCallbacks, resolveShorthand, useId } from '@fluentui/react-utilities';\nimport type { SwitchProps, SwitchState } from './Switch.types';\n\n/**\n * Create the state required to render Switch.\n *\n * The returned state can be modified with hooks such as useSwitchStyles_unstable,\n * before being passed to renderSwitch_unstable.\n *\n * @param props - props from this instance of Switch\n * @param ref - reference to `<input>` element of Switch\n */\nexport const useSwitch_unstable = (props: SwitchProps, ref: React.Ref<HTMLInputElement>): SwitchState => {\n const { checked, defaultChecked, disabled, labelPosition = 'after', onChange, required } = props;\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'onChange'],\n });\n\n const id = useId('switch-', nativeProps.primary.id);\n\n const root = resolveShorthand(props.root, {\n defaultProps: { ref: useFocusWithin<HTMLDivElement>(), ...nativeProps.root },\n required: true,\n });\n\n const indicator = resolveShorthand(props.indicator, {\n defaultProps: {\n 'aria-hidden': true,\n children: <CircleFilled />,\n },\n required: true,\n });\n\n const input = resolveShorthand(props.input, {\n defaultProps: {\n checked,\n defaultChecked,\n id,\n ref,\n role: 'switch',\n type: 'checkbox',\n ...nativeProps.primary,\n },\n required: true,\n });\n input.onChange = mergeCallbacks(input.onChange, ev => onChange?.(ev, { checked: ev.currentTarget.checked }));\n\n const label = resolveShorthand(props.label, {\n defaultProps: {\n disabled,\n htmlFor: id,\n required,\n size: 'medium',\n },\n });\n\n return {\n labelPosition,\n\n //Slots definition\n components: {\n root: 'div',\n indicator: 'div',\n input: 'input',\n label: Label,\n },\n\n root,\n indicator,\n input,\n label,\n };\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,YAAY,QAAQ;AAC7B,SAASC,KAAK,QAAQ;AACtB,SAASC,cAAc,QAAQ;AAC/B,SAASC,yBAAyB,EAAEC,cAAc,EAAEC,gBAAgB,EAAEC,KAAK,QAAQ;AAGnF;;;;;;;;;AASA,OAAO,MAAMC,kBAAA,GAAqBA,CAACC,KAAA,EAAoBC,GAAA,KAAkD;EACvG,MAAM;IAAEC,OAAA;IAASC,cAAA;IAAgBC,QAAA;IAAUC,aAAA,GAAgB;IAASC,QAAA;IAAUC;EAAQ,CAAE,
|
1
|
+
{"version":3,"names":["React","useFieldControlProps_unstable","CircleFilled","Label","useFocusWithin","getPartitionedNativeProps","mergeCallbacks","resolveShorthand","useId","useSwitch_unstable","props","ref","supportsLabelFor","supportsRequired","checked","defaultChecked","disabled","labelPosition","onChange","required","nativeProps","primarySlotTagName","excludedPropNames","id","primary","root","defaultProps","indicator","children","createElement","input","role","type","ev","currentTarget","label","htmlFor","size","components"],"sources":["../../../src/components/Switch/useSwitch.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { CircleFilled } from '@fluentui/react-icons';\nimport { Label } from '@fluentui/react-label';\nimport { useFocusWithin } from '@fluentui/react-tabster';\nimport { getPartitionedNativeProps, mergeCallbacks, resolveShorthand, useId } from '@fluentui/react-utilities';\nimport type { SwitchProps, SwitchState } from './Switch.types';\n\n/**\n * Create the state required to render Switch.\n *\n * The returned state can be modified with hooks such as useSwitchStyles_unstable,\n * before being passed to renderSwitch_unstable.\n *\n * @param props - props from this instance of Switch\n * @param ref - reference to `<input>` element of Switch\n */\nexport const useSwitch_unstable = (props: SwitchProps, ref: React.Ref<HTMLInputElement>): SwitchState => {\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, { supportsLabelFor: true, supportsRequired: true });\n\n const { checked, defaultChecked, disabled, labelPosition = 'after', onChange, required } = props;\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'onChange'],\n });\n\n const id = useId('switch-', nativeProps.primary.id);\n\n const root = resolveShorthand(props.root, {\n defaultProps: { ref: useFocusWithin<HTMLDivElement>(), ...nativeProps.root },\n required: true,\n });\n\n const indicator = resolveShorthand(props.indicator, {\n defaultProps: {\n 'aria-hidden': true,\n children: <CircleFilled />,\n },\n required: true,\n });\n\n const input = resolveShorthand(props.input, {\n defaultProps: {\n checked,\n defaultChecked,\n id,\n ref,\n role: 'switch',\n type: 'checkbox',\n ...nativeProps.primary,\n },\n required: true,\n });\n input.onChange = mergeCallbacks(input.onChange, ev => onChange?.(ev, { checked: ev.currentTarget.checked }));\n\n const label = resolveShorthand(props.label, {\n defaultProps: {\n disabled,\n htmlFor: id,\n required,\n size: 'medium',\n },\n });\n\n return {\n labelPosition,\n\n //Slots definition\n components: {\n root: 'div',\n indicator: 'div',\n input: 'input',\n label: Label,\n },\n\n root,\n indicator,\n input,\n label,\n };\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,6BAA6B,QAAQ;AAC9C,SAASC,YAAY,QAAQ;AAC7B,SAASC,KAAK,QAAQ;AACtB,SAASC,cAAc,QAAQ;AAC/B,SAASC,yBAAyB,EAAEC,cAAc,EAAEC,gBAAgB,EAAEC,KAAK,QAAQ;AAGnF;;;;;;;;;AASA,OAAO,MAAMC,kBAAA,GAAqBA,CAACC,KAAA,EAAoBC,GAAA,KAAkD;EACvG;EACAD,KAAA,GAAQT,6BAAA,CAA8BS,KAAA,EAAO;IAAEE,gBAAA,EAAkB,IAAI;IAAEC,gBAAA,EAAkB;EAAK;EAE9F,MAAM;IAAEC,OAAA;IAASC,cAAA;IAAgBC,QAAA;IAAUC,aAAA,GAAgB;IAASC,QAAA;IAAUC;EAAQ,CAAE,GAAGT,KAAA;EAE3F,MAAMU,WAAA,GAAcf,yBAAA,CAA0B;IAC5CK,KAAA;IACAW,kBAAA,EAAoB;IACpBC,iBAAA,EAAmB,CAAC,WAAW,kBAAkB;EACnD;EAEA,MAAMC,EAAA,GAAKf,KAAA,CAAM,WAAWY,WAAA,CAAYI,OAAO,CAACD,EAAE;EAElD,MAAME,IAAA,GAAOlB,gBAAA,CAAiBG,KAAA,CAAMe,IAAI,EAAE;IACxCC,YAAA,EAAc;MAAEf,GAAA,EAAKP,cAAA;MAAkC,GAAGgB,WAAA,CAAYK;IAAK;IAC3EN,QAAA,EAAU;EACZ;EAEA,MAAMQ,SAAA,GAAYpB,gBAAA,CAAiBG,KAAA,CAAMiB,SAAS,EAAE;IAClDD,YAAA,EAAc;MACZ,eAAe,IAAI;MACnBE,QAAA,eAAU5B,KAAA,CAAA6B,aAAA,CAAC3B,YAAA;IACb;IACAiB,QAAA,EAAU;EACZ;EAEA,MAAMW,KAAA,GAAQvB,gBAAA,CAAiBG,KAAA,CAAMoB,KAAK,EAAE;IAC1CJ,YAAA,EAAc;MACZZ,OAAA;MACAC,cAAA;MACAQ,EAAA;MACAZ,GAAA;MACAoB,IAAA,EAAM;MACNC,IAAA,EAAM;MACN,GAAGZ,WAAA,CAAYI;IACjB;IACAL,QAAA,EAAU;EACZ;EACAW,KAAA,CAAMZ,QAAQ,GAAGZ,cAAA,CAAewB,KAAA,CAAMZ,QAAQ,EAAEe,EAAA;IAAM,OAAAf,QAAA,aAAAA,QAAA,uBAAAA,QAAA,CAAWe,EAAA,EAAI;MAAEnB,OAAA,EAASmB,EAAA,CAAGC,aAAa,CAACpB;IAAQ;;EAEzG,MAAMqB,KAAA,GAAQ5B,gBAAA,CAAiBG,KAAA,CAAMyB,KAAK,EAAE;IAC1CT,YAAA,EAAc;MACZV,QAAA;MACAoB,OAAA,EAASb,EAAA;MACTJ,QAAA;MACAkB,IAAA,EAAM;IACR;EACF;EAEA,OAAO;IACLpB,aAAA;IAEA;IACAqB,UAAA,EAAY;MACVb,IAAA,EAAM;MACNE,SAAA,EAAW;MACXG,KAAA,EAAO;MACPK,KAAA,EAAOhC;IACT;IAEAsB,IAAA;IACAE,SAAA;IACAG,KAAA;IACAK;EACF;AACF"}
|
@@ -8,11 +8,17 @@ Object.defineProperty(exports, "useSwitch_unstable", {
|
|
8
8
|
});
|
9
9
|
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
10
|
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
11
|
+
const _reactField = require("@fluentui/react-field");
|
11
12
|
const _reactIcons = require("@fluentui/react-icons");
|
12
13
|
const _reactLabel = require("@fluentui/react-label");
|
13
14
|
const _reactTabster = require("@fluentui/react-tabster");
|
14
15
|
const _reactUtilities = require("@fluentui/react-utilities");
|
15
16
|
const useSwitch_unstable = (props, ref)=>{
|
17
|
+
// Merge props from surrounding <Field>, if any
|
18
|
+
props = (0, _reactField.useFieldControlProps_unstable)(props, {
|
19
|
+
supportsLabelFor: true,
|
20
|
+
supportsRequired: true
|
21
|
+
});
|
16
22
|
const { checked , defaultChecked , disabled , labelPosition ='after' , onChange , required } = props;
|
17
23
|
const nativeProps = (0, _reactUtilities.getPartitionedNativeProps)({
|
18
24
|
props,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Switch/useSwitch.js"],"sourcesContent":["import * as React from 'react';\nimport { CircleFilled } from '@fluentui/react-icons';\nimport { Label } from '@fluentui/react-label';\nimport { useFocusWithin } from '@fluentui/react-tabster';\nimport { getPartitionedNativeProps, mergeCallbacks, resolveShorthand, useId } from '@fluentui/react-utilities';\n/**\n * Create the state required to render Switch.\n *\n * The returned state can be modified with hooks such as useSwitchStyles_unstable,\n * before being passed to renderSwitch_unstable.\n *\n * @param props - props from this instance of Switch\n * @param ref - reference to `<input>` element of Switch\n */\nexport const useSwitch_unstable = (props, ref) => {\n const {\n checked,\n defaultChecked,\n disabled,\n labelPosition = 'after',\n onChange,\n required\n } = props;\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'onChange']\n });\n const id = useId('switch-', nativeProps.primary.id);\n const root = resolveShorthand(props.root, {\n defaultProps: {\n ref: useFocusWithin(),\n ...nativeProps.root\n },\n required: true\n });\n const indicator = resolveShorthand(props.indicator, {\n defaultProps: {\n 'aria-hidden': true,\n children: /*#__PURE__*/React.createElement(CircleFilled, null)\n },\n required: true\n });\n const input = resolveShorthand(props.input, {\n defaultProps: {\n checked,\n defaultChecked,\n id,\n ref,\n role: 'switch',\n type: 'checkbox',\n ...nativeProps.primary\n },\n required: true\n });\n input.onChange = mergeCallbacks(input.onChange, ev => {\n return onChange === null || onChange === void 0 ? void 0 : onChange(ev, {\n checked: ev.currentTarget.checked\n });\n });\n const label = resolveShorthand(props.label, {\n defaultProps: {\n disabled,\n htmlFor: id,\n required,\n size: 'medium'\n }\n });\n return {\n labelPosition,\n //Slots definition\n components: {\n root: 'div',\n indicator: 'div',\n input: 'input',\n label: Label\n },\n root,\n indicator,\n input,\n label\n };\n};\n//# sourceMappingURL=useSwitch.js.map"],"names":["useSwitch_unstable","props","ref","checked","defaultChecked","disabled","labelPosition","onChange","required","nativeProps","getPartitionedNativeProps","primarySlotTagName","excludedPropNames","id","useId","primary","root","resolveShorthand","defaultProps","useFocusWithin","indicator","children","React","createElement","CircleFilled","input","role","type","mergeCallbacks","ev","currentTarget","label","htmlFor","size","components","Label"],"mappings":";;;;+
|
1
|
+
{"version":3,"sources":["../../../lib/components/Switch/useSwitch.js"],"sourcesContent":["import * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { CircleFilled } from '@fluentui/react-icons';\nimport { Label } from '@fluentui/react-label';\nimport { useFocusWithin } from '@fluentui/react-tabster';\nimport { getPartitionedNativeProps, mergeCallbacks, resolveShorthand, useId } from '@fluentui/react-utilities';\n/**\n * Create the state required to render Switch.\n *\n * The returned state can be modified with hooks such as useSwitchStyles_unstable,\n * before being passed to renderSwitch_unstable.\n *\n * @param props - props from this instance of Switch\n * @param ref - reference to `<input>` element of Switch\n */\nexport const useSwitch_unstable = (props, ref) => {\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, {\n supportsLabelFor: true,\n supportsRequired: true\n });\n const {\n checked,\n defaultChecked,\n disabled,\n labelPosition = 'after',\n onChange,\n required\n } = props;\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'onChange']\n });\n const id = useId('switch-', nativeProps.primary.id);\n const root = resolveShorthand(props.root, {\n defaultProps: {\n ref: useFocusWithin(),\n ...nativeProps.root\n },\n required: true\n });\n const indicator = resolveShorthand(props.indicator, {\n defaultProps: {\n 'aria-hidden': true,\n children: /*#__PURE__*/React.createElement(CircleFilled, null)\n },\n required: true\n });\n const input = resolveShorthand(props.input, {\n defaultProps: {\n checked,\n defaultChecked,\n id,\n ref,\n role: 'switch',\n type: 'checkbox',\n ...nativeProps.primary\n },\n required: true\n });\n input.onChange = mergeCallbacks(input.onChange, ev => {\n return onChange === null || onChange === void 0 ? void 0 : onChange(ev, {\n checked: ev.currentTarget.checked\n });\n });\n const label = resolveShorthand(props.label, {\n defaultProps: {\n disabled,\n htmlFor: id,\n required,\n size: 'medium'\n }\n });\n return {\n labelPosition,\n //Slots definition\n components: {\n root: 'div',\n indicator: 'div',\n input: 'input',\n label: Label\n },\n root,\n indicator,\n input,\n label\n };\n};\n//# sourceMappingURL=useSwitch.js.map"],"names":["useSwitch_unstable","props","ref","useFieldControlProps_unstable","supportsLabelFor","supportsRequired","checked","defaultChecked","disabled","labelPosition","onChange","required","nativeProps","getPartitionedNativeProps","primarySlotTagName","excludedPropNames","id","useId","primary","root","resolveShorthand","defaultProps","useFocusWithin","indicator","children","React","createElement","CircleFilled","input","role","type","mergeCallbacks","ev","currentTarget","label","htmlFor","size","components","Label"],"mappings":";;;;+BAeaA;;aAAAA;;;6DAfU;4BACuB;4BACjB;4BACP;8BACS;gCACoD;AAU5E,MAAMA,qBAAqB,CAACC,OAAOC,MAAQ;IAChD,+CAA+C;IAC/CD,QAAQE,IAAAA,yCAA6B,EAACF,OAAO;QAC3CG,kBAAkB,IAAI;QACtBC,kBAAkB,IAAI;IACxB;IACA,MAAM,EACJC,QAAO,EACPC,eAAc,EACdC,SAAQ,EACRC,eAAgB,QAAO,EACvBC,SAAQ,EACRC,SAAQ,EACT,GAAGV;IACJ,MAAMW,cAAcC,IAAAA,yCAAyB,EAAC;QAC5CZ;QACAa,oBAAoB;QACpBC,mBAAmB;YAAC;YAAW;YAAkB;SAAW;IAC9D;IACA,MAAMC,KAAKC,IAAAA,qBAAK,EAAC,WAAWL,YAAYM,OAAO,CAACF,EAAE;IAClD,MAAMG,OAAOC,IAAAA,gCAAgB,EAACnB,MAAMkB,IAAI,EAAE;QACxCE,cAAc;YACZnB,KAAKoB,IAAAA,4BAAc;YACnB,GAAGV,YAAYO,IAAI;QACrB;QACAR,UAAU,IAAI;IAChB;IACA,MAAMY,YAAYH,IAAAA,gCAAgB,EAACnB,MAAMsB,SAAS,EAAE;QAClDF,cAAc;YACZ,eAAe,IAAI;YACnBG,UAAU,WAAW,GAAEC,OAAMC,aAAa,CAACC,wBAAY,EAAE,IAAI;QAC/D;QACAhB,UAAU,IAAI;IAChB;IACA,MAAMiB,QAAQR,IAAAA,gCAAgB,EAACnB,MAAM2B,KAAK,EAAE;QAC1CP,cAAc;YACZf;YACAC;YACAS;YACAd;YACA2B,MAAM;YACNC,MAAM;YACN,GAAGlB,YAAYM,OAAO;QACxB;QACAP,UAAU,IAAI;IAChB;IACAiB,MAAMlB,QAAQ,GAAGqB,IAAAA,8BAAc,EAACH,MAAMlB,QAAQ,EAAEsB,CAAAA,KAAM;QACpD,OAAOtB,aAAa,IAAI,IAAIA,aAAa,KAAK,IAAI,KAAK,IAAIA,SAASsB,IAAI;YACtE1B,SAAS0B,GAAGC,aAAa,CAAC3B,OAAO;QACnC,EAAE;IACJ;IACA,MAAM4B,QAAQd,IAAAA,gCAAgB,EAACnB,MAAMiC,KAAK,EAAE;QAC1Cb,cAAc;YACZb;YACA2B,SAASnB;YACTL;YACAyB,MAAM;QACR;IACF;IACA,OAAO;QACL3B;QACA,kBAAkB;QAClB4B,YAAY;YACVlB,MAAM;YACNI,WAAW;YACXK,OAAO;YACPM,OAAOI,iBAAK;QACd;QACAnB;QACAI;QACAK;QACAM;IACF;AACF,GACA,qCAAqC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-switch",
|
3
|
-
"version": "9.1.
|
3
|
+
"version": "9.1.9",
|
4
4
|
"description": "Fluent UI React Switch component.",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -32,13 +32,13 @@
|
|
32
32
|
"@fluentui/scripts-tasks": "*"
|
33
33
|
},
|
34
34
|
"dependencies": {
|
35
|
-
"@fluentui/react-field": "9.0.0-
|
35
|
+
"@fluentui/react-field": "9.0.0-beta.2",
|
36
36
|
"@fluentui/react-icons": "^2.0.196",
|
37
|
-
"@fluentui/react-label": "^9.1.
|
37
|
+
"@fluentui/react-label": "^9.1.8",
|
38
38
|
"@fluentui/react-shared-contexts": "^9.3.3",
|
39
|
-
"@fluentui/react-tabster": "^9.6.
|
39
|
+
"@fluentui/react-tabster": "^9.6.4",
|
40
40
|
"@fluentui/react-theme": "^9.1.7",
|
41
|
-
"@fluentui/react-utilities": "^9.7.
|
41
|
+
"@fluentui/react-utilities": "^9.7.4",
|
42
42
|
"@griffel/react": "^1.5.2",
|
43
43
|
"@swc/helpers": "^0.4.14"
|
44
44
|
},
|