@fluentui/react-switch 0.0.0-nightly-20230404-0419.1 → 0.0.0-nightly-20230405-0421.1

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 CHANGED
@@ -2,9 +2,9 @@
2
2
  "name": "@fluentui/react-switch",
3
3
  "entries": [
4
4
  {
5
- "date": "Tue, 04 Apr 2023 04:25:10 GMT",
6
- "tag": "@fluentui/react-switch_v0.0.0-nightly-20230404-0419.1",
7
- "version": "0.0.0-nightly-20230404-0419.1",
5
+ "date": "Wed, 05 Apr 2023 04:27:43 GMT",
6
+ "tag": "@fluentui/react-switch_v0.0.0-nightly-20230405-0421.1",
7
+ "version": "0.0.0-nightly-20230405-0421.1",
8
8
  "comments": {
9
9
  "prerelease": [
10
10
  {
@@ -16,44 +16,77 @@
16
16
  {
17
17
  "author": "beachball",
18
18
  "package": "@fluentui/react-switch",
19
- "comment": "Bump @fluentui/react-field to v0.0.0-nightly-20230404-0419.1",
20
- "commit": "75e35c8f53b490d241fffe70f831b72eaa66a5ab"
19
+ "comment": "Bump @fluentui/react-field to v0.0.0-nightly-20230405-0421.1",
20
+ "commit": "b363f61416aba5861d265582db62040b5dced850"
21
21
  },
22
22
  {
23
23
  "author": "beachball",
24
24
  "package": "@fluentui/react-switch",
25
- "comment": "Bump @fluentui/react-label to v0.0.0-nightly-20230404-0419.1",
26
- "commit": "75e35c8f53b490d241fffe70f831b72eaa66a5ab"
25
+ "comment": "Bump @fluentui/react-label to v0.0.0-nightly-20230405-0421.1",
26
+ "commit": "b363f61416aba5861d265582db62040b5dced850"
27
27
  },
28
28
  {
29
29
  "author": "beachball",
30
30
  "package": "@fluentui/react-switch",
31
- "comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20230404-0419.1",
32
- "commit": "75e35c8f53b490d241fffe70f831b72eaa66a5ab"
31
+ "comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20230405-0421.1",
32
+ "commit": "b363f61416aba5861d265582db62040b5dced850"
33
33
  },
34
34
  {
35
35
  "author": "beachball",
36
36
  "package": "@fluentui/react-switch",
37
- "comment": "Bump @fluentui/react-tabster to v0.0.0-nightly-20230404-0419.1",
38
- "commit": "75e35c8f53b490d241fffe70f831b72eaa66a5ab"
37
+ "comment": "Bump @fluentui/react-tabster to v0.0.0-nightly-20230405-0421.1",
38
+ "commit": "b363f61416aba5861d265582db62040b5dced850"
39
39
  },
40
40
  {
41
41
  "author": "beachball",
42
42
  "package": "@fluentui/react-switch",
43
- "comment": "Bump @fluentui/react-theme to v0.0.0-nightly-20230404-0419.1",
44
- "commit": "75e35c8f53b490d241fffe70f831b72eaa66a5ab"
43
+ "comment": "Bump @fluentui/react-theme to v0.0.0-nightly-20230405-0421.1",
44
+ "commit": "b363f61416aba5861d265582db62040b5dced850"
45
45
  },
46
46
  {
47
47
  "author": "beachball",
48
48
  "package": "@fluentui/react-switch",
49
- "comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20230404-0419.1",
50
- "commit": "75e35c8f53b490d241fffe70f831b72eaa66a5ab"
49
+ "comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20230405-0421.1",
50
+ "commit": "b363f61416aba5861d265582db62040b5dced850"
51
51
  },
52
52
  {
53
53
  "author": "beachball",
54
54
  "package": "@fluentui/react-switch",
55
- "comment": "Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20230404-0419.1",
56
- "commit": "75e35c8f53b490d241fffe70f831b72eaa66a5ab"
55
+ "comment": "Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20230405-0421.1",
56
+ "commit": "b363f61416aba5861d265582db62040b5dced850"
57
+ }
58
+ ]
59
+ }
60
+ },
61
+ {
62
+ "date": "Tue, 04 Apr 2023 18:44:50 GMT",
63
+ "tag": "@fluentui/react-switch_v9.1.7",
64
+ "version": "9.1.7",
65
+ "comments": {
66
+ "patch": [
67
+ {
68
+ "author": "beachball",
69
+ "package": "@fluentui/react-switch",
70
+ "comment": "Bump @fluentui/react-field to v9.0.0-alpha.29",
71
+ "commit": "6778d76bbbad7e1975c151c797f28c2708cde2ce"
72
+ },
73
+ {
74
+ "author": "beachball",
75
+ "package": "@fluentui/react-switch",
76
+ "comment": "Bump @fluentui/react-label to v9.1.7",
77
+ "commit": "6778d76bbbad7e1975c151c797f28c2708cde2ce"
78
+ },
79
+ {
80
+ "author": "beachball",
81
+ "package": "@fluentui/react-switch",
82
+ "comment": "Bump @fluentui/react-tabster to v9.6.3",
83
+ "commit": "6778d76bbbad7e1975c151c797f28c2708cde2ce"
84
+ },
85
+ {
86
+ "author": "beachball",
87
+ "package": "@fluentui/react-switch",
88
+ "comment": "Bump @fluentui/react-utilities to v9.7.3",
89
+ "commit": "6778d76bbbad7e1975c151c797f28c2708cde2ce"
57
90
  }
58
91
  ]
59
92
  }
package/CHANGELOG.md CHANGED
@@ -1,24 +1,36 @@
1
1
  # Change Log - @fluentui/react-switch
2
2
 
3
- This log was last generated on Tue, 04 Apr 2023 04:25:10 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 05 Apr 2023 04:27:43 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## [0.0.0-nightly-20230404-0419.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v0.0.0-nightly-20230404-0419.1)
7
+ ## [0.0.0-nightly-20230405-0421.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v0.0.0-nightly-20230405-0421.1)
8
8
 
9
- Tue, 04 Apr 2023 04:25:10 GMT
10
- [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.1.5..@fluentui/react-switch_v0.0.0-nightly-20230404-0419.1)
9
+ Wed, 05 Apr 2023 04:27:43 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.1.7..@fluentui/react-switch_v0.0.0-nightly-20230405-0421.1)
11
11
 
12
12
  ### Changes
13
13
 
14
14
  - Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
15
- - Bump @fluentui/react-field to v0.0.0-nightly-20230404-0419.1 ([commit](https://github.com/microsoft/fluentui/commit/75e35c8f53b490d241fffe70f831b72eaa66a5ab) by beachball)
16
- - Bump @fluentui/react-label to v0.0.0-nightly-20230404-0419.1 ([commit](https://github.com/microsoft/fluentui/commit/75e35c8f53b490d241fffe70f831b72eaa66a5ab) by beachball)
17
- - Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20230404-0419.1 ([commit](https://github.com/microsoft/fluentui/commit/75e35c8f53b490d241fffe70f831b72eaa66a5ab) by beachball)
18
- - Bump @fluentui/react-tabster to v0.0.0-nightly-20230404-0419.1 ([commit](https://github.com/microsoft/fluentui/commit/75e35c8f53b490d241fffe70f831b72eaa66a5ab) by beachball)
19
- - Bump @fluentui/react-theme to v0.0.0-nightly-20230404-0419.1 ([commit](https://github.com/microsoft/fluentui/commit/75e35c8f53b490d241fffe70f831b72eaa66a5ab) by beachball)
20
- - Bump @fluentui/react-utilities to v0.0.0-nightly-20230404-0419.1 ([commit](https://github.com/microsoft/fluentui/commit/75e35c8f53b490d241fffe70f831b72eaa66a5ab) by beachball)
21
- - Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20230404-0419.1 ([commit](https://github.com/microsoft/fluentui/commit/75e35c8f53b490d241fffe70f831b72eaa66a5ab) by beachball)
15
+ - Bump @fluentui/react-field to v0.0.0-nightly-20230405-0421.1 ([commit](https://github.com/microsoft/fluentui/commit/b363f61416aba5861d265582db62040b5dced850) by beachball)
16
+ - Bump @fluentui/react-label to v0.0.0-nightly-20230405-0421.1 ([commit](https://github.com/microsoft/fluentui/commit/b363f61416aba5861d265582db62040b5dced850) by beachball)
17
+ - Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20230405-0421.1 ([commit](https://github.com/microsoft/fluentui/commit/b363f61416aba5861d265582db62040b5dced850) by beachball)
18
+ - Bump @fluentui/react-tabster to v0.0.0-nightly-20230405-0421.1 ([commit](https://github.com/microsoft/fluentui/commit/b363f61416aba5861d265582db62040b5dced850) by beachball)
19
+ - Bump @fluentui/react-theme to v0.0.0-nightly-20230405-0421.1 ([commit](https://github.com/microsoft/fluentui/commit/b363f61416aba5861d265582db62040b5dced850) by beachball)
20
+ - Bump @fluentui/react-utilities to v0.0.0-nightly-20230405-0421.1 ([commit](https://github.com/microsoft/fluentui/commit/b363f61416aba5861d265582db62040b5dced850) by beachball)
21
+ - Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20230405-0421.1 ([commit](https://github.com/microsoft/fluentui/commit/b363f61416aba5861d265582db62040b5dced850) by beachball)
22
+
23
+ ## [9.1.7](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.1.7)
24
+
25
+ Tue, 04 Apr 2023 18:44:50 GMT
26
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.1.5..@fluentui/react-switch_v9.1.7)
27
+
28
+ ### Patches
29
+
30
+ - Bump @fluentui/react-field to v9.0.0-alpha.29 ([PR #27434](https://github.com/microsoft/fluentui/pull/27434) by beachball)
31
+ - Bump @fluentui/react-label to v9.1.7 ([PR #27434](https://github.com/microsoft/fluentui/pull/27434) by beachball)
32
+ - Bump @fluentui/react-tabster to v9.6.3 ([PR #27434](https://github.com/microsoft/fluentui/pull/27434) by beachball)
33
+ - Bump @fluentui/react-utilities to v9.7.3 ([PR #27434](https://github.com/microsoft/fluentui/pull/27434) by beachball)
22
34
 
23
35
  ## [9.1.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.1.5)
24
36
 
@@ -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,GAAGP,KAAA;EAE3F,MAAMQ,WAAA,GAAcb,yBAAA,CAA0B;IAC5CK,KAAA;IACAS,kBAAA,EAAoB;IACpBC,iBAAA,EAAmB,CAAC,WAAW,kBAAkB;EACnD;EAEA,MAAMC,EAAA,GAAKb,KAAA,CAAM,WAAWU,WAAA,CAAYI,OAAO,CAACD,EAAE;EAElD,MAAME,IAAA,GAAOhB,gBAAA,CAAiBG,KAAA,CAAMa,IAAI,EAAE;IACxCC,YAAA,EAAc;MAAEb,GAAA,EAAKP,cAAA;MAAkC,GAAGc,WAAA,CAAYK;IAAK;IAC3EN,QAAA,EAAU;EACZ;EAEA,MAAMQ,SAAA,GAAYlB,gBAAA,CAAiBG,KAAA,CAAMe,SAAS,EAAE;IAClDD,YAAA,EAAc;MACZ,eAAe,IAAI;MACnBE,QAAA,eAAUzB,KAAA,CAAA0B,aAAA,CAACzB,YAAA;IACb;IACAe,QAAA,EAAU;EACZ;EAEA,MAAMW,KAAA,GAAQrB,gBAAA,CAAiBG,KAAA,CAAMkB,KAAK,EAAE;IAC1CJ,YAAA,EAAc;MACZZ,OAAA;MACAC,cAAA;MACAQ,EAAA;MACAV,GAAA;MACAkB,IAAA,EAAM;MACNC,IAAA,EAAM;MACN,GAAGZ,WAAA,CAAYI;IACjB;IACAL,QAAA,EAAU;EACZ;EACAW,KAAA,CAAMZ,QAAQ,GAAGV,cAAA,CAAesB,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,GAAQ1B,gBAAA,CAAiBG,KAAA,CAAMuB,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,EAAO9B;IACT;IAEAoB,IAAA;IACAE,SAAA;IACAG,KAAA;IACAK;EACF;AACF"}
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,KA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,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","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AAM8B,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"}
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": "0.0.0-nightly-20230404-0419.1",
3
+ "version": "0.0.0-nightly-20230405-0421.1",
4
4
  "description": "Fluent UI React Switch component.",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -27,18 +27,18 @@
27
27
  "devDependencies": {
28
28
  "@fluentui/eslint-plugin": "*",
29
29
  "@fluentui/react-conformance": "*",
30
- "@fluentui/react-conformance-griffel": "0.0.0-nightly-20230404-0419.1",
30
+ "@fluentui/react-conformance-griffel": "0.0.0-nightly-20230405-0421.1",
31
31
  "@fluentui/scripts-api-extractor": "*",
32
32
  "@fluentui/scripts-tasks": "*"
33
33
  },
34
34
  "dependencies": {
35
- "@fluentui/react-field": "0.0.0-nightly-20230404-0419.1",
35
+ "@fluentui/react-field": "0.0.0-nightly-20230405-0421.1",
36
36
  "@fluentui/react-icons": "^2.0.196",
37
- "@fluentui/react-label": "0.0.0-nightly-20230404-0419.1",
38
- "@fluentui/react-shared-contexts": "0.0.0-nightly-20230404-0419.1",
39
- "@fluentui/react-tabster": "0.0.0-nightly-20230404-0419.1",
40
- "@fluentui/react-theme": "0.0.0-nightly-20230404-0419.1",
41
- "@fluentui/react-utilities": "0.0.0-nightly-20230404-0419.1",
37
+ "@fluentui/react-label": "0.0.0-nightly-20230405-0421.1",
38
+ "@fluentui/react-shared-contexts": "0.0.0-nightly-20230405-0421.1",
39
+ "@fluentui/react-tabster": "0.0.0-nightly-20230405-0421.1",
40
+ "@fluentui/react-theme": "0.0.0-nightly-20230405-0421.1",
41
+ "@fluentui/react-utilities": "0.0.0-nightly-20230405-0421.1",
42
42
  "@griffel/react": "^1.5.2",
43
43
  "@swc/helpers": "^0.4.14"
44
44
  },