@fluentui/react-switch 9.1.4 → 9.1.6
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/.swcrc +30 -0
- package/CHANGELOG.json +109 -1
- package/CHANGELOG.md +33 -2
- package/lib/Switch.js.map +1 -1
- package/lib/SwitchField.js.map +1 -1
- package/lib/components/Switch/Switch.js.map +1 -1
- package/lib/components/Switch/Switch.types.js +1 -1
- package/lib/components/Switch/Switch.types.js.map +1 -1
- package/lib/components/Switch/index.js.map +1 -1
- package/lib/components/Switch/renderSwitch.js +1 -11
- package/lib/components/Switch/renderSwitch.js.map +1 -1
- package/lib/components/Switch/useSwitch.js +5 -3
- package/lib/components/Switch/useSwitch.js.map +1 -1
- package/lib/components/Switch/useSwitchStyles.js +1 -1
- package/lib/components/Switch/useSwitchStyles.js.map +1 -1
- package/lib/components/SwitchField/SwitchField.js +1 -2
- package/lib/components/SwitchField/SwitchField.js.map +1 -1
- package/lib/components/SwitchField/index.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/Switch.js +5 -4
- package/lib-commonjs/Switch.js.map +1 -1
- package/lib-commonjs/SwitchField.js +5 -4
- package/lib-commonjs/SwitchField.js.map +1 -1
- package/lib-commonjs/components/Switch/Switch.js +19 -20
- package/lib-commonjs/components/Switch/Switch.js.map +1 -1
- package/lib-commonjs/components/Switch/Switch.types.js +5 -2
- package/lib-commonjs/components/Switch/Switch.types.js.map +1 -1
- package/lib-commonjs/components/Switch/index.js +9 -8
- package/lib-commonjs/components/Switch/index.js.map +1 -1
- package/lib-commonjs/components/Switch/renderSwitch.js +14 -29
- package/lib-commonjs/components/Switch/renderSwitch.js.map +1 -1
- package/lib-commonjs/components/Switch/useSwitch.js +78 -85
- package/lib-commonjs/components/Switch/useSwitch.js.map +1 -1
- package/lib-commonjs/components/Switch/useSwitchStyles.js +176 -89
- package/lib-commonjs/components/Switch/useSwitchStyles.js.map +1 -1
- package/lib-commonjs/components/SwitchField/SwitchField.js +17 -11
- package/lib-commonjs/components/SwitchField/SwitchField.js.map +1 -1
- package/lib-commonjs/components/SwitchField/index.js +5 -4
- package/lib-commonjs/components/SwitchField/index.js.map +1 -1
- package/lib-commonjs/index.js +23 -56
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +12 -11
- package/lib-amd/Switch.js +0 -6
- package/lib-amd/Switch.js.map +0 -1
- package/lib-amd/SwitchField.js +0 -6
- package/lib-amd/SwitchField.js.map +0 -1
- package/lib-amd/components/Switch/Switch.js +0 -17
- package/lib-amd/components/Switch/Switch.js.map +0 -1
- package/lib-amd/components/Switch/Switch.types.js +0 -5
- package/lib-amd/components/Switch/Switch.types.js.map +0 -1
- package/lib-amd/components/Switch/index.js +0 -10
- package/lib-amd/components/Switch/index.js.map +0 -1
- package/lib-amd/components/Switch/renderSwitch.js +0 -19
- package/lib-amd/components/Switch/renderSwitch.js.map +0 -1
- package/lib-amd/components/Switch/useSwitch.js +0 -63
- package/lib-amd/components/Switch/useSwitch.js.map +0 -1
- package/lib-amd/components/Switch/useSwitchStyles.js +0 -211
- package/lib-amd/components/Switch/useSwitchStyles.js.map +0 -1
- package/lib-amd/components/SwitchField/SwitchField.js +0 -10
- package/lib-amd/components/SwitchField/SwitchField.js.map +0 -1
- package/lib-amd/components/SwitchField/index.js +0 -6
- package/lib-amd/components/SwitchField/index.js.map +0 -1
- package/lib-amd/index.js +0 -15
- package/lib-amd/index.js.map +0 -1
package/.swcrc
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://json.schemastore.org/swcrc",
|
3
|
+
"exclude": [
|
4
|
+
"/testing",
|
5
|
+
"/**/*.cy.ts",
|
6
|
+
"/**/*.cy.tsx",
|
7
|
+
"/**/*.spec.ts",
|
8
|
+
"/**/*.spec.tsx",
|
9
|
+
"/**/*.test.ts",
|
10
|
+
"/**/*.test.tsx"
|
11
|
+
],
|
12
|
+
"jsc": {
|
13
|
+
"parser": {
|
14
|
+
"syntax": "typescript",
|
15
|
+
"tsx": true,
|
16
|
+
"decorators": false,
|
17
|
+
"dynamicImport": false
|
18
|
+
},
|
19
|
+
"externalHelpers": true,
|
20
|
+
"transform": {
|
21
|
+
"react": {
|
22
|
+
"runtime": "classic",
|
23
|
+
"useSpread": true
|
24
|
+
}
|
25
|
+
},
|
26
|
+
"target": "es2019"
|
27
|
+
},
|
28
|
+
"minify": false,
|
29
|
+
"sourceMaps": true
|
30
|
+
}
|
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,115 @@
|
|
2
2
|
"name": "@fluentui/react-switch",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "Thu,
|
5
|
+
"date": "Thu, 23 Mar 2023 12:28:45 GMT",
|
6
|
+
"tag": "@fluentui/react-switch_v9.1.6",
|
7
|
+
"version": "9.1.6",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"author": "beachball",
|
12
|
+
"package": "@fluentui/react-switch",
|
13
|
+
"comment": "Bump @fluentui/react-field to v9.0.0-alpha.28",
|
14
|
+
"commit": "be0ca69899300abe3c8478c435e0f6837138479b"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"author": "beachball",
|
18
|
+
"package": "@fluentui/react-switch",
|
19
|
+
"comment": "Bump @fluentui/react-label to v9.1.6",
|
20
|
+
"commit": "be0ca69899300abe3c8478c435e0f6837138479b"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"author": "beachball",
|
24
|
+
"package": "@fluentui/react-switch",
|
25
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.3.3",
|
26
|
+
"commit": "be0ca69899300abe3c8478c435e0f6837138479b"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"author": "beachball",
|
30
|
+
"package": "@fluentui/react-switch",
|
31
|
+
"comment": "Bump @fluentui/react-tabster to v9.6.2",
|
32
|
+
"commit": "be0ca69899300abe3c8478c435e0f6837138479b"
|
33
|
+
}
|
34
|
+
]
|
35
|
+
}
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"date": "Tue, 21 Mar 2023 21:23:05 GMT",
|
39
|
+
"tag": "@fluentui/react-switch_v9.1.5",
|
40
|
+
"version": "9.1.5",
|
41
|
+
"comments": {
|
42
|
+
"patch": [
|
43
|
+
{
|
44
|
+
"author": "tristan.watanabe@gmail.com",
|
45
|
+
"package": "@fluentui/react-switch",
|
46
|
+
"commit": "ead1c6d4c2ac3f3596b62b8cbc07b0a03041f11f",
|
47
|
+
"comment": "fix: add node field to package.json exports map."
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"author": "lingfangao@hotmail.com",
|
51
|
+
"package": "@fluentui/react-switch",
|
52
|
+
"commit": "1a45088ee3492f352e23748539bf207af57f99a8",
|
53
|
+
"comment": "fix: Make checked switch more visible in high contrast mode"
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"author": "makotom@microsoft.com",
|
57
|
+
"package": "@fluentui/react-switch",
|
58
|
+
"commit": "7fde5c94869ff9841b142b7ff1d0a3df0ab58f74",
|
59
|
+
"comment": "chore: Bumping version of @fluentui/react-icons to ^2.0.196."
|
60
|
+
},
|
61
|
+
{
|
62
|
+
"author": "tristan.watanabe@gmail.com",
|
63
|
+
"package": "@fluentui/react-switch",
|
64
|
+
"commit": "2fac1a139149bd13b76b1306207bc988dca9c72c",
|
65
|
+
"comment": "chore: migrate to swc transpilation approach."
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"author": "beachball",
|
69
|
+
"package": "@fluentui/react-switch",
|
70
|
+
"comment": "Bump @fluentui/react-field to v9.0.0-alpha.27",
|
71
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
72
|
+
},
|
73
|
+
{
|
74
|
+
"author": "beachball",
|
75
|
+
"package": "@fluentui/react-switch",
|
76
|
+
"comment": "Bump @fluentui/react-label to v9.1.5",
|
77
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
78
|
+
},
|
79
|
+
{
|
80
|
+
"author": "beachball",
|
81
|
+
"package": "@fluentui/react-switch",
|
82
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.3.2",
|
83
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
84
|
+
},
|
85
|
+
{
|
86
|
+
"author": "beachball",
|
87
|
+
"package": "@fluentui/react-switch",
|
88
|
+
"comment": "Bump @fluentui/react-tabster to v9.6.1",
|
89
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
90
|
+
},
|
91
|
+
{
|
92
|
+
"author": "beachball",
|
93
|
+
"package": "@fluentui/react-switch",
|
94
|
+
"comment": "Bump @fluentui/react-theme to v9.1.7",
|
95
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
96
|
+
},
|
97
|
+
{
|
98
|
+
"author": "beachball",
|
99
|
+
"package": "@fluentui/react-switch",
|
100
|
+
"comment": "Bump @fluentui/react-utilities to v9.7.2",
|
101
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
102
|
+
},
|
103
|
+
{
|
104
|
+
"author": "beachball",
|
105
|
+
"package": "@fluentui/react-switch",
|
106
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.20",
|
107
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
108
|
+
}
|
109
|
+
]
|
110
|
+
}
|
111
|
+
},
|
112
|
+
{
|
113
|
+
"date": "Thu, 16 Mar 2023 14:36:59 GMT",
|
6
114
|
"tag": "@fluentui/react-switch_v9.1.4",
|
7
115
|
"version": "9.1.4",
|
8
116
|
"comments": {
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,43 @@
|
|
1
1
|
# Change Log - @fluentui/react-switch
|
2
2
|
|
3
|
-
This log was last generated on Thu,
|
3
|
+
This log was last generated on Thu, 23 Mar 2023 12:28:45 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.1.6](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.1.6)
|
8
|
+
|
9
|
+
Thu, 23 Mar 2023 12:28:45 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.1.5..@fluentui/react-switch_v9.1.6)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- Bump @fluentui/react-field to v9.0.0-alpha.28 ([PR #27286](https://github.com/microsoft/fluentui/pull/27286) by beachball)
|
15
|
+
- Bump @fluentui/react-label to v9.1.6 ([PR #27286](https://github.com/microsoft/fluentui/pull/27286) by beachball)
|
16
|
+
- Bump @fluentui/react-shared-contexts to v9.3.3 ([PR #27286](https://github.com/microsoft/fluentui/pull/27286) by beachball)
|
17
|
+
- Bump @fluentui/react-tabster to v9.6.2 ([PR #27286](https://github.com/microsoft/fluentui/pull/27286) by beachball)
|
18
|
+
|
19
|
+
## [9.1.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.1.5)
|
20
|
+
|
21
|
+
Tue, 21 Mar 2023 21:23:05 GMT
|
22
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.1.4..@fluentui/react-switch_v9.1.5)
|
23
|
+
|
24
|
+
### Patches
|
25
|
+
|
26
|
+
- fix: add node field to package.json exports map. ([PR #27154](https://github.com/microsoft/fluentui/pull/27154) by tristan.watanabe@gmail.com)
|
27
|
+
- fix: Make checked switch more visible in high contrast mode ([PR #27257](https://github.com/microsoft/fluentui/pull/27257) by lingfangao@hotmail.com)
|
28
|
+
- chore: Bumping version of @fluentui/react-icons to ^2.0.196. ([PR #27100](https://github.com/microsoft/fluentui/pull/27100) by makotom@microsoft.com)
|
29
|
+
- chore: migrate to swc transpilation approach. ([PR #27250](https://github.com/microsoft/fluentui/pull/27250) by tristan.watanabe@gmail.com)
|
30
|
+
- Bump @fluentui/react-field to v9.0.0-alpha.27 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
31
|
+
- Bump @fluentui/react-label to v9.1.5 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
32
|
+
- Bump @fluentui/react-shared-contexts to v9.3.2 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
33
|
+
- Bump @fluentui/react-tabster to v9.6.1 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
34
|
+
- Bump @fluentui/react-theme to v9.1.7 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
35
|
+
- Bump @fluentui/react-utilities to v9.7.2 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
36
|
+
- Bump @fluentui/react-conformance-griffel to v9.0.0-beta.20 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
37
|
+
|
7
38
|
## [9.1.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.1.4)
|
8
39
|
|
9
|
-
Thu, 16 Mar 2023 14:
|
40
|
+
Thu, 16 Mar 2023 14:36:59 GMT
|
10
41
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.1.3..@fluentui/react-switch_v9.1.4)
|
11
42
|
|
12
43
|
### Patches
|
package/lib/Switch.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":[],"sources":["../src/Switch.ts"],"sourcesContent":["export * from './components/Switch/index';\n"],"mappings":"AAAA,cAAc"}
|
package/lib/SwitchField.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":[],"sources":["../src/SwitchField.ts"],"sourcesContent":["export * from './components/SwitchField/index';\n"],"mappings":"AAAA,cAAc"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","useSwitch_unstable","renderSwitch_unstable","useSwitchStyles_unstable","useCustomStyleHooks_unstable","Switch","forwardRef","props","ref","state","useCustomStyles","displayName"],"sources":["
|
1
|
+
{"version":3,"names":["React","useSwitch_unstable","renderSwitch_unstable","useSwitchStyles_unstable","useCustomStyleHooks_unstable","Switch","forwardRef","props","ref","state","useCustomStyles","displayName"],"sources":["../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useSwitch_unstable } from './useSwitch';\nimport { renderSwitch_unstable } from './renderSwitch';\nimport { useSwitchStyles_unstable } from './useSwitchStyles';\nimport type { SwitchProps } from './Switch.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useCustomStyleHooks_unstable } from '@fluentui/react-shared-contexts';\n\n/**\n * Switches enable users to trigger an option on or off through pressing the component.\n */\nexport const Switch: ForwardRefComponent<SwitchProps> = React.forwardRef((props, ref) => {\n const state = useSwitch_unstable(props, ref);\n\n useSwitchStyles_unstable(state);\n\n const { useSwitchStyles_unstable: useCustomStyles } = useCustomStyleHooks_unstable();\n useCustomStyles(state);\n\n return renderSwitch_unstable(state);\n});\n\nSwitch.displayName = 'Switch';\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,kBAAkB,QAAQ;AACnC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,wBAAwB,QAAQ;AAGzC,SAASC,4BAA4B,QAAQ;AAE7C;;;AAGA,OAAO,MAAMC,MAAA,gBAA2CL,KAAA,CAAMM,UAAU,CAAC,CAACC,KAAA,EAAOC,GAAA,KAAQ;EACvF,MAAMC,KAAA,GAAQR,kBAAA,CAAmBM,KAAA,EAAOC,GAAA;EAExCL,wBAAA,CAAyBM,KAAA;EAEzB,MAAM;IAAEN,wBAAA,EAA0BO;EAAe,CAAE,GAAGN,4BAAA;EACtDM,eAAA,CAAgBD,KAAA;EAEhB,OAAOP,qBAAA,CAAsBO,KAAA;AAC/B;AAEAJ,MAAA,CAAOM,WAAW,GAAG"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
|
1
|
+
import * as React from 'react';
|
2
2
|
//# sourceMappingURL=Switch.types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["React"],"sources":["../../../src/components/Switch/Switch.types.ts"],"sourcesContent":["import * as React from 'react';\nimport { Label } from '@fluentui/react-label';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type SwitchSlots = {\n /**\n * The root element of the Switch.\n *\n * The root slot receives the `className` and `style` specified directly on the `<Switch>` tag.\n * All other native props will be applied to the primary slot: `input`.\n */\n root: NonNullable<Slot<'div'>>;\n\n /**\n * The track and the thumb sliding over it indicating the on and off status of the Switch.\n */\n indicator: NonNullable<Slot<'div'>>;\n\n /**\n * Hidden input that handles the Switch's functionality.\n *\n * This is the PRIMARY slot: all native properties specified directly on the `<Switch>` tag will be applied to this\n * slot, except `className` and `style`, which remain on the root slot.\n */\n input: NonNullable<Slot<'input'>>;\n\n /**\n * The Switch's label.\n */\n label?: Slot<typeof Label>;\n};\n\nexport type SwitchOnChangeData = {\n checked: boolean;\n};\n\n/**\n * Switch Props\n */\nexport type SwitchProps = Omit<\n ComponentProps<Partial<SwitchSlots>, 'input'>,\n 'checked' | 'defaultChecked' | 'onChange'\n> & {\n /**\n * Defines the controlled checked state of the Switch.\n * If passed, Switch ignores the `defaultChecked` property.\n * This should only be used if the checked state is to be controlled at a higher level and there is a plan to pass the\n * correct value based on handling `onChange` events and re-rendering.\n *\n * @default false\n */\n checked?: boolean;\n\n /**\n * Defines whether the Switch is initially in a checked state or not when rendered.\n *\n * @default false\n */\n defaultChecked?: boolean;\n\n /**\n * The position of the label relative to the Switch.\n *\n * @default after\n */\n labelPosition?: 'above' | 'after' | 'before';\n\n /**\n * Callback to be called when the checked state value changes.\n */\n onChange?: (ev: React.ChangeEvent<HTMLInputElement>, data: SwitchOnChangeData) => void;\n};\n\n/**\n * State used in rendering Switch\n */\nexport type SwitchState = ComponentState<SwitchSlots> & Required<Pick<SwitchProps, 'labelPosition'>>;\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/components/Switch/index.ts"],"sourcesContent":["export * from './Switch';\nexport * from './Switch.types';\nexport * from './renderSwitch';\nexport * from './useSwitch';\nexport * from './useSwitchStyles';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc"}
|
@@ -11,16 +11,6 @@ export const renderSwitch_unstable = state => {
|
|
11
11
|
const {
|
12
12
|
labelPosition
|
13
13
|
} = state;
|
14
|
-
return /*#__PURE__*/React.createElement(slots.root,
|
15
|
-
...slotProps.root
|
16
|
-
}, /*#__PURE__*/React.createElement(slots.input, {
|
17
|
-
...slotProps.input
|
18
|
-
}), labelPosition !== 'after' && slots.label && /*#__PURE__*/React.createElement(slots.label, {
|
19
|
-
...slotProps.label
|
20
|
-
}), /*#__PURE__*/React.createElement(slots.indicator, {
|
21
|
-
...slotProps.indicator
|
22
|
-
}), labelPosition === 'after' && slots.label && /*#__PURE__*/React.createElement(slots.label, {
|
23
|
-
...slotProps.label
|
24
|
-
}));
|
14
|
+
return /*#__PURE__*/React.createElement(slots.root, slotProps.root, /*#__PURE__*/React.createElement(slots.input, slotProps.input), labelPosition !== 'after' && slots.label && /*#__PURE__*/React.createElement(slots.label, slotProps.label), /*#__PURE__*/React.createElement(slots.indicator, slotProps.indicator), labelPosition === 'after' && slots.label && /*#__PURE__*/React.createElement(slots.label, slotProps.label));
|
25
15
|
};
|
26
16
|
//# sourceMappingURL=renderSwitch.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","getSlots","renderSwitch_unstable","state","slots","slotProps","labelPosition","createElement","root","input","label","indicator"],"sources":["
|
1
|
+
{"version":3,"names":["React","getSlots","renderSwitch_unstable","state","slots","slotProps","labelPosition","createElement","root","input","label","indicator"],"sources":["../../../src/components/Switch/renderSwitch.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { SwitchState, SwitchSlots } from './Switch.types';\n\n/**\n * Render a Switch component by passing the state defined props to the appropriate slots.\n */\nexport const renderSwitch_unstable = (state: SwitchState) => {\n const { slots, slotProps } = getSlots<SwitchSlots>(state);\n const { labelPosition } = state;\n\n return (\n <slots.root {...slotProps.root}>\n <slots.input {...slotProps.input} />\n {labelPosition !== 'after' && slots.label && <slots.label {...slotProps.label} />}\n <slots.indicator {...slotProps.indicator} />\n {labelPosition === 'after' && slots.label && <slots.label {...slotProps.label} />}\n </slots.root>\n );\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,QAAQ,QAAQ;AAGzB;;;AAGA,OAAO,MAAMC,qBAAA,GAAyBC,KAAA,IAAuB;EAC3D,MAAM;IAAEC,KAAA;IAAOC;EAAS,CAAE,GAAGJ,QAAA,CAAsBE,KAAA;EACnD,MAAM;IAAEG;EAAa,CAAE,GAAGH,KAAA;EAE1B,oBACEH,KAAA,CAAAO,aAAA,CAACH,KAAA,CAAMI,IAAI,EAAKH,SAAA,CAAUG,IAAI,eAC5BR,KAAA,CAAAO,aAAA,CAACH,KAAA,CAAMK,KAAK,EAAKJ,SAAA,CAAUI,KAAK,GAC/BH,aAAA,KAAkB,WAAWF,KAAA,CAAMM,KAAK,iBAAIV,KAAA,CAAAO,aAAA,CAACH,KAAA,CAAMM,KAAK,EAAKL,SAAA,CAAUK,KAAK,gBAC7EV,KAAA,CAAAO,aAAA,CAACH,KAAA,CAAMO,SAAS,EAAKN,SAAA,CAAUM,SAAS,GACvCL,aAAA,KAAkB,WAAWF,KAAA,CAAMM,KAAK,iBAAIV,KAAA,CAAAO,aAAA,CAACH,KAAA,CAAMM,KAAK,EAAKL,SAAA,CAAUK,KAAK;AAGnF"}
|
@@ -53,9 +53,11 @@ export const useSwitch_unstable = (props, ref) => {
|
|
53
53
|
},
|
54
54
|
required: true
|
55
55
|
});
|
56
|
-
input.onChange = mergeCallbacks(input.onChange, ev =>
|
57
|
-
|
58
|
-
|
56
|
+
input.onChange = mergeCallbacks(input.onChange, ev => {
|
57
|
+
return onChange === null || onChange === void 0 ? void 0 : onChange(ev, {
|
58
|
+
checked: ev.currentTarget.checked
|
59
|
+
});
|
60
|
+
});
|
59
61
|
const label = resolveShorthand(props.label, {
|
60
62
|
defaultProps: {
|
61
63
|
disabled,
|
@@ -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":["
|
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"}
|
@@ -32,7 +32,7 @@ const useIndicatorStyles = /*#__PURE__*/__styles({
|
|
32
32
|
}, {
|
33
33
|
d: [".f1hu3pq6{margin-top:0;}"]
|
34
34
|
});
|
35
|
-
const useInputBaseClassName = /*#__PURE__*/__resetStyles("
|
35
|
+
const useInputBaseClassName = /*#__PURE__*/__resetStyles("rw4brat", "r1f4bxyr", [".rw4brat{box-sizing:border-box;cursor:pointer;height:100%;margin:0;opacity:0;position:absolute;width:calc(40px + 2 * var(--spacingHorizontalS));}", ".rw4brat:checked~.fui-Switch__indicator>*{-webkit-transform:translateX(20px);-moz-transform:translateX(20px);-ms-transform:translateX(20px);transform:translateX(20px);}", ".rw4brat:disabled{cursor:default;}", ".rw4brat:disabled~.fui-Switch__indicator{color:var(--colorNeutralForegroundDisabled);}", ".rw4brat:disabled~.fui-Switch__label{cursor:default;color:var(--colorNeutralForegroundDisabled);}", ".rw4brat:enabled:not(:checked)~.fui-Switch__indicator{color:var(--colorNeutralStrokeAccessible);border-color:var(--colorNeutralStrokeAccessible);}", ".rw4brat:enabled:not(:checked)~.fui-Switch__label{color:var(--colorNeutralForeground1);}", ".rw4brat:enabled:not(:checked):hover~.fui-Switch__indicator{color:var(--colorNeutralStrokeAccessibleHover);border-color:var(--colorNeutralStrokeAccessibleHover);}", ".rw4brat:enabled:not(:checked):hover:active~.fui-Switch__indicator{color:var(--colorNeutralStrokeAccessiblePressed);border-color:var(--colorNeutralStrokeAccessiblePressed);}", ".rw4brat:enabled:checked~.fui-Switch__indicator{background-color:var(--colorCompoundBrandBackground);color:var(--colorNeutralForegroundInverted);border-color:var(--colorTransparentStroke);}", ".rw4brat:enabled:checked:hover~.fui-Switch__indicator{background-color:var(--colorCompoundBrandBackgroundHover);border-color:var(--colorTransparentStrokeInteractive);}", ".rw4brat:enabled:checked:hover:active~.fui-Switch__indicator{background-color:var(--colorCompoundBrandBackgroundPressed);border-color:var(--colorTransparentStrokeInteractive);}", ".rw4brat:disabled:not(:checked)~.fui-Switch__indicator{border-color:var(--colorNeutralStrokeDisabled);}", ".rw4brat:disabled:checked~.fui-Switch__indicator{background-color:var(--colorNeutralBackgroundDisabled);border-color:var(--colorTransparentStrokeDisabled);}", "@media (forced-colors: active){.rw4brat:disabled~.fui-Switch__indicator{color:GrayText;border-color:GrayText;}.rw4brat:disabled~.fui-Switch__label{color:GrayText;}.rw4brat:enabled:checked:hover~.fui-Switch__indicator{background-color:Highlight;color:Canvas;}.rw4brat:enabled:checked~.fui-Switch__indicator{background-color:Highlight;color:Canvas;}}", ".r1f4bxyr{box-sizing:border-box;cursor:pointer;height:100%;margin:0;opacity:0;position:absolute;width:calc(40px + 2 * var(--spacingHorizontalS));}", ".r1f4bxyr:checked~.fui-Switch__indicator>*{-webkit-transform:translateX(-20px);-moz-transform:translateX(-20px);-ms-transform:translateX(-20px);transform:translateX(-20px);}", ".r1f4bxyr:disabled{cursor:default;}", ".r1f4bxyr:disabled~.fui-Switch__indicator{color:var(--colorNeutralForegroundDisabled);}", ".r1f4bxyr:disabled~.fui-Switch__label{cursor:default;color:var(--colorNeutralForegroundDisabled);}", ".r1f4bxyr:enabled:not(:checked)~.fui-Switch__indicator{color:var(--colorNeutralStrokeAccessible);border-color:var(--colorNeutralStrokeAccessible);}", ".r1f4bxyr:enabled:not(:checked)~.fui-Switch__label{color:var(--colorNeutralForeground1);}", ".r1f4bxyr:enabled:not(:checked):hover~.fui-Switch__indicator{color:var(--colorNeutralStrokeAccessibleHover);border-color:var(--colorNeutralStrokeAccessibleHover);}", ".r1f4bxyr:enabled:not(:checked):hover:active~.fui-Switch__indicator{color:var(--colorNeutralStrokeAccessiblePressed);border-color:var(--colorNeutralStrokeAccessiblePressed);}", ".r1f4bxyr:enabled:checked~.fui-Switch__indicator{background-color:var(--colorCompoundBrandBackground);color:var(--colorNeutralForegroundInverted);border-color:var(--colorTransparentStroke);}", ".r1f4bxyr:enabled:checked:hover~.fui-Switch__indicator{background-color:var(--colorCompoundBrandBackgroundHover);border-color:var(--colorTransparentStrokeInteractive);}", ".r1f4bxyr:enabled:checked:hover:active~.fui-Switch__indicator{background-color:var(--colorCompoundBrandBackgroundPressed);border-color:var(--colorTransparentStrokeInteractive);}", ".r1f4bxyr:disabled:not(:checked)~.fui-Switch__indicator{border-color:var(--colorNeutralStrokeDisabled);}", ".r1f4bxyr:disabled:checked~.fui-Switch__indicator{background-color:var(--colorNeutralBackgroundDisabled);border-color:var(--colorTransparentStrokeDisabled);}", "@media (forced-colors: active){.r1f4bxyr:disabled~.fui-Switch__indicator{color:GrayText;border-color:GrayText;}.r1f4bxyr:disabled~.fui-Switch__label{color:GrayText;}.r1f4bxyr:enabled:checked:hover~.fui-Switch__indicator{background-color:Highlight;color:Canvas;}.r1f4bxyr:enabled:checked~.fui-Switch__indicator{background-color:Highlight;color:Canvas;}}"]);
|
36
36
|
const useInputStyles = /*#__PURE__*/__styles({
|
37
37
|
before: {
|
38
38
|
j35jbq: ["f1e31b4d", "f1vgc2s3"],
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createFocusOutlineStyle","tokens","__resetStyles","__styles","mergeClasses","shorthands","switchClassNames","root","indicator","input","label","switchClassName","spaceBetweenThumbAndTrack","trackHeight","trackWidth","thumbSize","useRootBaseClassName","useRootStyles","vertical","Beiy3e4","d","useIndicatorBaseClassName","useIndicatorStyles","labelAbove","B6of3ja","useInputBaseClassName","useInputStyles","before","j35jbq","Bhzewxz","after","oyh7mz","above","B5kzvoi","Bqenvij","a9b677","useLabelStyles","base","Bceei9c","jrapky","z8tnut","z189sj","Byoj8tv","uwmqm3","useSwitchStyles_unstable","state","rootBaseClassName","rootStyles","indicatorBaseClassName","indicatorStyles","inputBaseClassName","inputStyles","labelStyles","labelPosition","className"],"sources":["../src/packages/react-components/react-switch/src/components/Switch/useSwitchStyles.ts"],"sourcesContent":["import { createFocusOutlineStyle } from '@fluentui/react-tabster';\nimport { tokens } from '@fluentui/react-theme';\nimport { makeResetStyles, makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport type { SwitchSlots, SwitchState } from './Switch.types';\n\nexport const switchClassNames: SlotClassNames<SwitchSlots> = {\n root: 'fui-Switch',\n indicator: 'fui-Switch__indicator',\n input: 'fui-Switch__input',\n label: 'fui-Switch__label',\n};\n\n/**\n * @deprecated Use `switchClassNames.root` instead.\n */\nexport const switchClassName = switchClassNames.root;\n\n// Thumb and track sizes used by the component.\nconst spaceBetweenThumbAndTrack = 2;\nconst trackHeight = 20;\nconst trackWidth = 40;\nconst thumbSize = trackHeight - spaceBetweenThumbAndTrack;\n\nconst useRootBaseClassName = makeResetStyles({\n alignItems: 'flex-start',\n boxSizing: 'border-box',\n display: 'inline-flex',\n position: 'relative',\n\n ...createFocusOutlineStyle({ style: {}, selector: 'focus-within' }),\n});\n\nconst useRootStyles = makeStyles({\n vertical: {\n flexDirection: 'column',\n },\n});\n\nconst useIndicatorBaseClassName = makeResetStyles({\n borderRadius: tokens.borderRadiusCircular,\n border: '1px solid',\n lineHeight: 0,\n boxSizing: 'border-box',\n fill: 'currentColor',\n flexShrink: 0,\n fontSize: `${thumbSize}px`,\n height: `${trackHeight}px`,\n margin: tokens.spacingVerticalS + ' ' + tokens.spacingHorizontalS,\n pointerEvents: 'none',\n transitionDuration: tokens.durationNormal,\n transitionTimingFunction: tokens.curveEasyEase,\n transitionProperty: 'background, border, color',\n width: `${trackWidth}px`,\n\n '@media screen and (prefers-reduced-motion: reduce)': {\n transitionDuration: '0.01ms',\n },\n\n '> *': {\n transitionDuration: tokens.durationNormal,\n transitionTimingFunction: tokens.curveEasyEase,\n transitionProperty: 'transform',\n\n '@media screen and (prefers-reduced-motion: reduce)': {\n transitionDuration: '0.01ms',\n },\n },\n});\n\nconst useIndicatorStyles = makeStyles({\n labelAbove: {\n marginTop: 0,\n },\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\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 switch.\n width: `calc(${trackWidth}px + 2 * ${tokens.spacingHorizontalS})`,\n\n // Checked (both enabled and disabled)\n ':checked': {\n [`& ~ .${switchClassNames.indicator}`]: {\n '> *': {\n transform: `translateX(${trackWidth - thumbSize - spaceBetweenThumbAndTrack}px)`,\n },\n },\n },\n\n // Disabled (both checked and unchecked)\n ':disabled': {\n cursor: 'default',\n\n [`& ~ .${switchClassNames.indicator}`]: {\n color: tokens.colorNeutralForegroundDisabled,\n },\n\n [`& ~ .${switchClassNames.label}`]: {\n cursor: 'default',\n color: tokens.colorNeutralForegroundDisabled,\n },\n },\n\n // Enabled and unchecked\n ':enabled:not(:checked)': {\n [`& ~ .${switchClassNames.indicator}`]: {\n color: tokens.colorNeutralStrokeAccessible,\n borderColor: tokens.colorNeutralStrokeAccessible,\n },\n\n [`& ~ .${switchClassNames.label}`]: {\n color: tokens.colorNeutralForeground1,\n },\n\n ':hover': {\n [`& ~ .${switchClassNames.indicator}`]: {\n color: tokens.colorNeutralStrokeAccessibleHover,\n borderColor: tokens.colorNeutralStrokeAccessibleHover,\n },\n },\n\n ':hover:active': {\n [`& ~ .${switchClassNames.indicator}`]: {\n color: tokens.colorNeutralStrokeAccessiblePressed,\n borderColor: tokens.colorNeutralStrokeAccessiblePressed,\n },\n },\n },\n\n // Enabled and checked\n ':enabled:checked': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackground,\n color: tokens.colorNeutralForegroundInverted,\n borderColor: tokens.colorTransparentStroke,\n },\n\n ':hover': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundHover,\n borderColor: tokens.colorTransparentStrokeInteractive,\n },\n },\n\n ':hover:active': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundPressed,\n borderColor: tokens.colorTransparentStrokeInteractive,\n },\n },\n },\n\n // Disabled and unchecked\n ':disabled:not(:checked)': {\n [`& ~ .${switchClassNames.indicator}`]: {\n borderColor: tokens.colorNeutralStrokeDisabled,\n },\n },\n\n // Disabled and checked\n ':disabled:checked': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorNeutralBackgroundDisabled,\n borderColor: tokens.colorTransparentStrokeDisabled,\n },\n },\n\n '@media (forced-colors: active)': {\n ':disabled': {\n [`& ~ .${switchClassNames.indicator}`]: {\n color: 'GrayText',\n borderColor: 'GrayText',\n },\n\n [`& ~ .${switchClassNames.label}`]: {\n color: 'GrayText',\n },\n },\n },\n});\n\nconst useInputStyles = makeStyles({\n before: {\n right: 0,\n top: 0,\n },\n after: {\n left: 0,\n top: 0,\n },\n above: {\n bottom: 0,\n height: `calc(${trackHeight}px + ${tokens.spacingVerticalS})`,\n width: '100%',\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 cursor: 'pointer',\n\n // Use a (negative) margin to account for the difference between the track's height and the label's line height.\n // This prevents the label from expanding the height of the switch, but preserves line height if the label wraps.\n marginBottom: `calc((${trackHeight}px - ${tokens.lineHeightBase300}) / 2)`,\n marginTop: `calc((${trackHeight}px - ${tokens.lineHeightBase300}) / 2)`,\n\n ...shorthands.padding(tokens.spacingVerticalS, tokens.spacingHorizontalS),\n },\n above: {\n paddingTop: tokens.spacingVerticalXS,\n paddingBottom: tokens.spacingVerticalXS,\n width: '100%',\n },\n after: {\n paddingLeft: tokens.spacingHorizontalXS,\n },\n before: {\n paddingRight: tokens.spacingHorizontalXS,\n },\n});\n\n/**\n * Apply styling to the Switch slots based on the state\n */\nexport const useSwitchStyles_unstable = (state: SwitchState): SwitchState => {\n const rootBaseClassName = useRootBaseClassName();\n const rootStyles = useRootStyles();\n const indicatorBaseClassName = useIndicatorBaseClassName();\n const indicatorStyles = useIndicatorStyles();\n const inputBaseClassName = useInputBaseClassName();\n const inputStyles = useInputStyles();\n const labelStyles = useLabelStyles();\n\n const { label, labelPosition } = state;\n\n state.root.className = mergeClasses(\n switchClassNames.root,\n rootBaseClassName,\n labelPosition === 'above' && rootStyles.vertical,\n state.root.className,\n );\n\n state.indicator.className = mergeClasses(\n switchClassNames.indicator,\n indicatorBaseClassName,\n label && labelPosition === 'above' && indicatorStyles.labelAbove,\n state.indicator.className,\n );\n\n state.input.className = mergeClasses(\n switchClassNames.input,\n inputBaseClassName,\n label && inputStyles[labelPosition],\n state.input.className,\n );\n\n if (state.label) {\n state.label.className = mergeClasses(\n switchClassNames.label,\n labelStyles.base,\n labelStyles[labelPosition],\n state.label.className,\n );\n }\n\n return state;\n};\n"],"mappings":"AAAA,SAASA,uBAAuB,QAAQ,yBAAyB;AACjE,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAAAC,aAAA,EAAAC,QAAA,EAAsCC,YAAY,EAAEC,UAAU,QAAQ,gBAAgB;AAItF,OAAO,MAAMC,gBAAgB,GAAgC;EAC3DC,IAAI,EAAE,YAAY;EAClBC,SAAS,EAAE,uBAAuB;EAClCC,KAAK,EAAE,mBAAmB;EAC1BC,KAAK,EAAE;CACR;AAED;;;AAGA,OAAO,MAAMC,eAAe,GAAGL,gBAAgB,CAACC,IAAI;AAEpD;AACA,MAAMK,yBAAyB,GAAG,CAAC;AACnC,MAAMC,WAAW,GAAG,EAAE;AACtB,MAAMC,UAAU,GAAG,EAAE;AACrB,MAAMC,SAAS,GAAGF,WAAW,GAAGD,yBAAyB;AAEzD,MAAMI,oBAAoB,gBAAGd,aAAA,g+EAO3B;AAEF,MAAMe,aAAa,gBAAGd,QAAA;EAAAe,QAAA;IAAAC,OAAA;EAAA;AAAA;EAAAC,CAAA;AAAA,EAIpB;AAEF,MAAMC,yBAAyB,gBAAGnB,aAAA,4wBA6BhC;AAEF,MAAMoB,kBAAkB,gBAAGnB,QAAA;EAAAoB,UAAA;IAAAC,OAAA;EAAA;AAAA;EAAAJ,CAAA;AAAA,EAIzB;AAEF,MAAMK,qBAAqB,gBAAGvB,aAAA,gqIA+G5B;AAEF,MAAMwB,cAAc,gBAAGvB,QAAA;EAAAwB,MAAA;IAAAC,MAAA;IAAAC,OAAA;EAAA;EAAAC,KAAA;IAAAC,MAAA;IAAAF,OAAA;EAAA;EAAAG,KAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;AAAA;EAAAf,CAAA;AAAA,EAcrB;AAEF;AACA,MAAMgB,cAAc,gBAAGjC,QAAA;EAAAkC,IAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAf,OAAA;IAAAgB,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;EAAAX,KAAA;IAAAQ,MAAA;IAAAE,OAAA;IAAAP,MAAA;EAAA;EAAAL,KAAA;IAAAa,MAAA;EAAA;EAAAhB,MAAA;IAAAc,MAAA;EAAA;AAAA;EAAArB,CAAA;AAAA,EAsBrB;AAEF;;;AAGA,OAAO,MAAMwB,wBAAwB,GAAIC,KAAkB,IAAiB;EAC1E,MAAMC,iBAAiB,GAAG9B,oBAAoB,EAAE;EAChD,MAAM+B,UAAU,GAAG9B,aAAa,EAAE;EAClC,MAAM+B,sBAAsB,GAAG3B,yBAAyB,EAAE;EAC1D,MAAM4B,eAAe,GAAG3B,kBAAkB,EAAE;EAC5C,MAAM4B,kBAAkB,GAAGzB,qBAAqB,EAAE;EAClD,MAAM0B,WAAW,GAAGzB,cAAc,EAAE;EACpC,MAAM0B,WAAW,GAAGhB,cAAc,EAAE;EAEpC,MAAM;IAAE1B,KAAK;IAAE2C;EAAa,CAAE,GAAGR,KAAK;EAEtCA,KAAK,CAACtC,IAAI,CAAC+C,SAAS,GAAGlD,YAAY,CACjCE,gBAAgB,CAACC,IAAI,EACrBuC,iBAAiB,EACjBO,aAAa,KAAK,OAAO,IAAIN,UAAU,CAAC7B,QAAQ,EAChD2B,KAAK,CAACtC,IAAI,CAAC+C,SAAS,CACrB;EAEDT,KAAK,CAACrC,SAAS,CAAC8C,SAAS,GAAGlD,YAAY,CACtCE,gBAAgB,CAACE,SAAS,EAC1BwC,sBAAsB,EACtBtC,KAAK,IAAI2C,aAAa,KAAK,OAAO,IAAIJ,eAAe,CAAC1B,UAAU,EAChEsB,KAAK,CAACrC,SAAS,CAAC8C,SAAS,CAC1B;EAEDT,KAAK,CAACpC,KAAK,CAAC6C,SAAS,GAAGlD,YAAY,CAClCE,gBAAgB,CAACG,KAAK,EACtByC,kBAAkB,EAClBxC,KAAK,IAAIyC,WAAW,CAACE,aAAa,CAAC,EACnCR,KAAK,CAACpC,KAAK,CAAC6C,SAAS,CACtB;EAED,IAAIT,KAAK,CAACnC,KAAK,EAAE;IACfmC,KAAK,CAACnC,KAAK,CAAC4C,SAAS,GAAGlD,YAAY,CAClCE,gBAAgB,CAACI,KAAK,EACtB0C,WAAW,CAACf,IAAI,EAChBe,WAAW,CAACC,aAAa,CAAC,EAC1BR,KAAK,CAACnC,KAAK,CAAC4C,SAAS,CACtB;;EAGH,OAAOT,KAAK;AACd,CAAC"}
|
1
|
+
{"version":3,"names":["createFocusOutlineStyle","tokens","__resetStyles","__styles","mergeClasses","shorthands","switchClassNames","root","indicator","input","label","switchClassName","spaceBetweenThumbAndTrack","trackHeight","trackWidth","thumbSize","useRootBaseClassName","useRootStyles","vertical","Beiy3e4","d","useIndicatorBaseClassName","useIndicatorStyles","labelAbove","B6of3ja","useInputBaseClassName","useInputStyles","before","j35jbq","Bhzewxz","after","oyh7mz","above","B5kzvoi","Bqenvij","a9b677","useLabelStyles","base","Bceei9c","jrapky","z8tnut","z189sj","Byoj8tv","uwmqm3","useSwitchStyles_unstable","state","rootBaseClassName","rootStyles","indicatorBaseClassName","indicatorStyles","inputBaseClassName","inputStyles","labelStyles","labelPosition","className"],"sources":["../../../src/components/Switch/useSwitchStyles.ts"],"sourcesContent":["import { createFocusOutlineStyle } from '@fluentui/react-tabster';\nimport { tokens } from '@fluentui/react-theme';\nimport { makeResetStyles, makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport type { SwitchSlots, SwitchState } from './Switch.types';\n\nexport const switchClassNames: SlotClassNames<SwitchSlots> = {\n root: 'fui-Switch',\n indicator: 'fui-Switch__indicator',\n input: 'fui-Switch__input',\n label: 'fui-Switch__label',\n};\n\n/**\n * @deprecated Use `switchClassNames.root` instead.\n */\nexport const switchClassName = switchClassNames.root;\n\n// Thumb and track sizes used by the component.\nconst spaceBetweenThumbAndTrack = 2;\nconst trackHeight = 20;\nconst trackWidth = 40;\nconst thumbSize = trackHeight - spaceBetweenThumbAndTrack;\n\nconst useRootBaseClassName = makeResetStyles({\n alignItems: 'flex-start',\n boxSizing: 'border-box',\n display: 'inline-flex',\n position: 'relative',\n\n ...createFocusOutlineStyle({ style: {}, selector: 'focus-within' }),\n});\n\nconst useRootStyles = makeStyles({\n vertical: {\n flexDirection: 'column',\n },\n});\n\nconst useIndicatorBaseClassName = makeResetStyles({\n borderRadius: tokens.borderRadiusCircular,\n border: '1px solid',\n lineHeight: 0,\n boxSizing: 'border-box',\n fill: 'currentColor',\n flexShrink: 0,\n fontSize: `${thumbSize}px`,\n height: `${trackHeight}px`,\n margin: tokens.spacingVerticalS + ' ' + tokens.spacingHorizontalS,\n pointerEvents: 'none',\n transitionDuration: tokens.durationNormal,\n transitionTimingFunction: tokens.curveEasyEase,\n transitionProperty: 'background, border, color',\n width: `${trackWidth}px`,\n\n '@media screen and (prefers-reduced-motion: reduce)': {\n transitionDuration: '0.01ms',\n },\n\n '> *': {\n transitionDuration: tokens.durationNormal,\n transitionTimingFunction: tokens.curveEasyEase,\n transitionProperty: 'transform',\n\n '@media screen and (prefers-reduced-motion: reduce)': {\n transitionDuration: '0.01ms',\n },\n },\n});\n\nconst useIndicatorStyles = makeStyles({\n labelAbove: {\n marginTop: 0,\n },\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\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 switch.\n width: `calc(${trackWidth}px + 2 * ${tokens.spacingHorizontalS})`,\n\n // Checked (both enabled and disabled)\n ':checked': {\n [`& ~ .${switchClassNames.indicator}`]: {\n '> *': {\n transform: `translateX(${trackWidth - thumbSize - spaceBetweenThumbAndTrack}px)`,\n },\n },\n },\n\n // Disabled (both checked and unchecked)\n ':disabled': {\n cursor: 'default',\n\n [`& ~ .${switchClassNames.indicator}`]: {\n color: tokens.colorNeutralForegroundDisabled,\n },\n\n [`& ~ .${switchClassNames.label}`]: {\n cursor: 'default',\n color: tokens.colorNeutralForegroundDisabled,\n },\n },\n\n // Enabled and unchecked\n ':enabled:not(:checked)': {\n [`& ~ .${switchClassNames.indicator}`]: {\n color: tokens.colorNeutralStrokeAccessible,\n borderColor: tokens.colorNeutralStrokeAccessible,\n },\n\n [`& ~ .${switchClassNames.label}`]: {\n color: tokens.colorNeutralForeground1,\n },\n\n ':hover': {\n [`& ~ .${switchClassNames.indicator}`]: {\n color: tokens.colorNeutralStrokeAccessibleHover,\n borderColor: tokens.colorNeutralStrokeAccessibleHover,\n },\n },\n\n ':hover:active': {\n [`& ~ .${switchClassNames.indicator}`]: {\n color: tokens.colorNeutralStrokeAccessiblePressed,\n borderColor: tokens.colorNeutralStrokeAccessiblePressed,\n },\n },\n },\n\n // Enabled and checked\n ':enabled:checked': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackground,\n color: tokens.colorNeutralForegroundInverted,\n borderColor: tokens.colorTransparentStroke,\n },\n\n ':hover': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundHover,\n borderColor: tokens.colorTransparentStrokeInteractive,\n },\n },\n\n ':hover:active': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundPressed,\n borderColor: tokens.colorTransparentStrokeInteractive,\n },\n },\n },\n\n // Disabled and unchecked\n ':disabled:not(:checked)': {\n [`& ~ .${switchClassNames.indicator}`]: {\n borderColor: tokens.colorNeutralStrokeDisabled,\n },\n },\n\n // Disabled and checked\n ':disabled:checked': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorNeutralBackgroundDisabled,\n borderColor: tokens.colorTransparentStrokeDisabled,\n },\n },\n\n '@media (forced-colors: active)': {\n ':disabled': {\n [`& ~ .${switchClassNames.indicator}`]: {\n color: 'GrayText',\n borderColor: 'GrayText',\n },\n\n [`& ~ .${switchClassNames.label}`]: {\n color: 'GrayText',\n },\n },\n\n ':enabled:checked': {\n ':hover': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: 'Highlight',\n color: 'Canvas',\n },\n },\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: 'Highlight',\n color: 'Canvas',\n },\n },\n },\n});\n\nconst useInputStyles = makeStyles({\n before: {\n right: 0,\n top: 0,\n },\n after: {\n left: 0,\n top: 0,\n },\n above: {\n bottom: 0,\n height: `calc(${trackHeight}px + ${tokens.spacingVerticalS})`,\n width: '100%',\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 cursor: 'pointer',\n\n // Use a (negative) margin to account for the difference between the track's height and the label's line height.\n // This prevents the label from expanding the height of the switch, but preserves line height if the label wraps.\n marginBottom: `calc((${trackHeight}px - ${tokens.lineHeightBase300}) / 2)`,\n marginTop: `calc((${trackHeight}px - ${tokens.lineHeightBase300}) / 2)`,\n\n ...shorthands.padding(tokens.spacingVerticalS, tokens.spacingHorizontalS),\n },\n above: {\n paddingTop: tokens.spacingVerticalXS,\n paddingBottom: tokens.spacingVerticalXS,\n width: '100%',\n },\n after: {\n paddingLeft: tokens.spacingHorizontalXS,\n },\n before: {\n paddingRight: tokens.spacingHorizontalXS,\n },\n});\n\n/**\n * Apply styling to the Switch slots based on the state\n */\nexport const useSwitchStyles_unstable = (state: SwitchState): SwitchState => {\n const rootBaseClassName = useRootBaseClassName();\n const rootStyles = useRootStyles();\n const indicatorBaseClassName = useIndicatorBaseClassName();\n const indicatorStyles = useIndicatorStyles();\n const inputBaseClassName = useInputBaseClassName();\n const inputStyles = useInputStyles();\n const labelStyles = useLabelStyles();\n\n const { label, labelPosition } = state;\n\n state.root.className = mergeClasses(\n switchClassNames.root,\n rootBaseClassName,\n labelPosition === 'above' && rootStyles.vertical,\n state.root.className,\n );\n\n state.indicator.className = mergeClasses(\n switchClassNames.indicator,\n indicatorBaseClassName,\n label && labelPosition === 'above' && indicatorStyles.labelAbove,\n state.indicator.className,\n );\n\n state.input.className = mergeClasses(\n switchClassNames.input,\n inputBaseClassName,\n label && inputStyles[labelPosition],\n state.input.className,\n );\n\n if (state.label) {\n state.label.className = mergeClasses(\n switchClassNames.label,\n labelStyles.base,\n labelStyles[labelPosition],\n state.label.className,\n );\n }\n\n return state;\n};\n"],"mappings":"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"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
/* eslint-disable deprecation/deprecation */
|
2
|
-
import { getDeprecatedFieldClassNames, makeDeprecatedField } from '@fluentui/react-field';
|
1
|
+
/* eslint-disable deprecation/deprecation */import { getDeprecatedFieldClassNames, makeDeprecatedField } from '@fluentui/react-field';
|
3
2
|
import { Switch, switchClassNames } from '../../Switch';
|
4
3
|
/** @deprecated Use Field with Switch: `<Field><Switch /></Field>` */
|
5
4
|
export const switchFieldClassNames = /*#__PURE__*/getDeprecatedFieldClassNames(switchClassNames.root);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["getDeprecatedFieldClassNames","makeDeprecatedField","Switch","switchClassNames","switchFieldClassNames","root","SwitchField"],"sources":["
|
1
|
+
{"version":3,"names":["getDeprecatedFieldClassNames","makeDeprecatedField","Switch","switchClassNames","switchFieldClassNames","root","SwitchField"],"sources":["../../../src/components/SwitchField/SwitchField.tsx"],"sourcesContent":["/* eslint-disable deprecation/deprecation */\nimport { DeprecatedFieldProps, getDeprecatedFieldClassNames, makeDeprecatedField } from '@fluentui/react-field';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { Switch, switchClassNames, SwitchProps } from '../../Switch';\n\n/** @deprecated Use Field with Switch: `<Field><Switch /></Field>` */\nexport type SwitchFieldProps = DeprecatedFieldProps<SwitchProps>;\n/** @deprecated Use Field with Switch: `<Field><Switch /></Field>` */\nexport const switchFieldClassNames = getDeprecatedFieldClassNames(switchClassNames.root);\n/** @deprecated Use Field with Switch: `<Field><Switch /></Field>` */\nexport const SwitchField: ForwardRefComponent<SwitchFieldProps> = makeDeprecatedField(Switch);\n"],"mappings":"AAAA,4CACA,SAA+BA,4BAA4B,EAAEC,mBAAmB,QAAQ;AAExF,SAASC,MAAM,EAAEC,gBAAgB,QAAqB;AAItD;AACA,OAAO,MAAMC,qBAAA,gBAAwBJ,4BAAA,CAA6BG,gBAAA,CAAiBE,IAAI;AACvF;AACA,OAAO,MAAMC,WAAA,gBAAqDL,mBAAA,CAAoBC,MAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/components/SwitchField/index.ts"],"sourcesContent":["export * from './SwitchField';\n"],"mappings":"AAAA,cAAc"}
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Switch","renderSwitch_unstable","switchClassName","switchClassNames","useSwitchStyles_unstable","useSwitch_unstable","SwitchField","SwitchField_unstable","switchFieldClassNames"],"sources":["../src/
|
1
|
+
{"version":3,"names":["Switch","renderSwitch_unstable","switchClassName","switchClassNames","useSwitchStyles_unstable","useSwitch_unstable","SwitchField","SwitchField_unstable","switchFieldClassNames"],"sources":["../src/index.ts"],"sourcesContent":["export {\n Switch,\n renderSwitch_unstable,\n // eslint-disable-next-line deprecation/deprecation\n switchClassName,\n switchClassNames,\n useSwitchStyles_unstable,\n useSwitch_unstable,\n} from './Switch';\nexport type { SwitchOnChangeData, SwitchProps, SwitchSlots, SwitchState } from './Switch';\n\n// eslint-disable-next-line deprecation/deprecation\nexport { SwitchField as SwitchField_unstable, switchFieldClassNames } from './SwitchField';\n// eslint-disable-next-line deprecation/deprecation\nexport type { SwitchFieldProps as SwitchFieldProps_unstable } from './SwitchField';\n"],"mappings":"AAAA,SACEA,MAAM,EACNC,qBAAqB;AACrB;AACAC,eAAe,EACfC,gBAAgB,EAChBC,wBAAwB,EACxBC,kBAAkB,QACb;AAGP;AACA,SAASC,WAAA,IAAeC,oBAAoB,EAAEC,qBAAqB,QAAQ"}
|
package/lib-commonjs/Switch.js
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
5
4
|
});
|
6
|
-
const
|
7
|
-
|
5
|
+
const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
|
6
|
+
_exportStar(require("./components/Switch/index"), exports);
|
7
|
+
//# sourceMappingURL=Switch.js.map
|
8
|
+
|
8
9
|
//# sourceMappingURL=Switch.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../lib/Switch.js"],"sourcesContent":["export * from './components/Switch/index';\n//# sourceMappingURL=Switch.js.map"],"names":[],"mappings":";;;;;oBAAc;CACd,kCAAkC"}
|
@@ -1,8 +1,9 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
5
4
|
});
|
6
|
-
const
|
7
|
-
|
5
|
+
const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
|
6
|
+
_exportStar(require("./components/SwitchField/index"), exports);
|
7
|
+
//# sourceMappingURL=SwitchField.js.map
|
8
|
+
|
8
9
|
//# sourceMappingURL=SwitchField.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../lib/SwitchField.js"],"sourcesContent":["export * from './components/SwitchField/index';\n//# sourceMappingURL=SwitchField.js.map"],"names":[],"mappings":";;;;;oBAAc;CACd,uCAAuC"}
|
@@ -1,25 +1,24 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "Switch", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>Switch
|
5
8
|
});
|
6
|
-
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
10
|
-
const
|
11
|
-
const
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
const {
|
19
|
-
useSwitchStyles_unstable: useCustomStyles
|
20
|
-
} = react_shared_contexts_1.useCustomStyleHooks_unstable();
|
21
|
-
useCustomStyles(state);
|
22
|
-
return renderSwitch_1.renderSwitch_unstable(state);
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
11
|
+
const _useSwitch = require("./useSwitch");
|
12
|
+
const _renderSwitch = require("./renderSwitch");
|
13
|
+
const _useSwitchStyles = require("./useSwitchStyles");
|
14
|
+
const _reactSharedContexts = require("@fluentui/react-shared-contexts");
|
15
|
+
const Switch = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
|
16
|
+
const state = (0, _useSwitch.useSwitch_unstable)(props, ref);
|
17
|
+
(0, _useSwitchStyles.useSwitchStyles_unstable)(state);
|
18
|
+
const { useSwitchStyles_unstable: useCustomStyles } = (0, _reactSharedContexts.useCustomStyleHooks_unstable)();
|
19
|
+
useCustomStyles(state);
|
20
|
+
return (0, _renderSwitch.renderSwitch_unstable)(state);
|
23
21
|
});
|
24
|
-
|
22
|
+
Switch.displayName = 'Switch'; //# sourceMappingURL=Switch.js.map
|
23
|
+
|
25
24
|
//# sourceMappingURL=Switch.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../../lib/components/Switch/Switch.js"],"sourcesContent":["import * as React from 'react';\nimport { useSwitch_unstable } from './useSwitch';\nimport { renderSwitch_unstable } from './renderSwitch';\nimport { useSwitchStyles_unstable } from './useSwitchStyles';\nimport { useCustomStyleHooks_unstable } from '@fluentui/react-shared-contexts';\n/**\n * Switches enable users to trigger an option on or off through pressing the component.\n */\nexport const Switch = /*#__PURE__*/React.forwardRef((props, ref) => {\n const state = useSwitch_unstable(props, ref);\n useSwitchStyles_unstable(state);\n const {\n useSwitchStyles_unstable: useCustomStyles\n } = useCustomStyleHooks_unstable();\n useCustomStyles(state);\n return renderSwitch_unstable(state);\n});\nSwitch.displayName = 'Switch';\n//# sourceMappingURL=Switch.js.map"],"names":["Switch","React","forwardRef","props","ref","state","useSwitch_unstable","useSwitchStyles_unstable","useCustomStyles","useCustomStyleHooks_unstable","renderSwitch_unstable","displayName"],"mappings":";;;;+BAQaA;;aAAAA;;;6DARU;2BACY;8BACG;iCACG;qCACI;AAItC,MAAMA,SAAS,WAAW,GAAEC,OAAMC,UAAU,CAAC,CAACC,OAAOC,MAAQ;IAClE,MAAMC,QAAQC,IAAAA,6BAAkB,EAACH,OAAOC;IACxCG,IAAAA,yCAAwB,EAACF;IACzB,MAAM,EACJE,0BAA0BC,gBAAe,EAC1C,GAAGC,IAAAA,iDAA4B;IAChCD,gBAAgBH;IAChB,OAAOK,IAAAA,mCAAqB,EAACL;AAC/B;AACAL,OAAOW,WAAW,GAAG,UACrB,kCAAkC"}
|
@@ -1,6 +1,9 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
5
4
|
});
|
5
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
6
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
7
|
+
//# sourceMappingURL=Switch.types.js.map
|
8
|
+
|
6
9
|
//# sourceMappingURL=Switch.types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../../lib/components/Switch/Switch.types.js"],"sourcesContent":["import * as React from 'react';\n//# sourceMappingURL=Switch.types.js.map"],"names":[],"mappings":";;;;;6DAAuB;CACvB,wCAAwC"}
|