@fluentui/react-switch 0.0.0-nightly0e0cf06c3420211029.1 → 0.0.0-nightly554221a5aa20211202.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 +136 -24
- package/CHANGELOG.md +43 -15
- package/Spec.md +4 -4
- package/dist/react-switch.d.ts +2 -0
- package/lib/components/Switch/Switch.js +2 -2
- package/lib/components/Switch/Switch.js.map +1 -1
- package/lib/components/Switch/renderSwitch.js +6 -7
- package/lib/components/Switch/renderSwitch.js.map +1 -1
- package/lib/components/Switch/useSwitch.js +22 -21
- package/lib/components/Switch/useSwitch.js.map +1 -1
- package/lib/components/Switch/useSwitchState.js +48 -56
- package/lib/components/Switch/useSwitchState.js.map +1 -1
- package/lib/components/Switch/useSwitchStyles.d.ts +1 -0
- package/lib/components/Switch/useSwitchStyles.js +30 -29
- package/lib/components/Switch/useSwitchStyles.js.map +1 -1
- package/lib-commonjs/Switch.js +1 -1
- package/lib-commonjs/components/Switch/Switch.js +6 -6
- package/lib-commonjs/components/Switch/Switch.js.map +1 -1
- package/lib-commonjs/components/Switch/index.js +1 -1
- package/lib-commonjs/components/Switch/renderSwitch.js +9 -11
- package/lib-commonjs/components/Switch/renderSwitch.js.map +1 -1
- package/lib-commonjs/components/Switch/useSwitch.js +23 -23
- package/lib-commonjs/components/Switch/useSwitch.js.map +1 -1
- package/lib-commonjs/components/Switch/useSwitchState.js +51 -59
- package/lib-commonjs/components/Switch/useSwitchState.js.map +1 -1
- package/lib-commonjs/components/Switch/useSwitchStyles.d.ts +1 -0
- package/lib-commonjs/components/Switch/useSwitchStyles.js +33 -32
- package/lib-commonjs/components/Switch/useSwitchStyles.js.map +1 -1
- package/lib-commonjs/index.js +1 -1
- package/package.json +12 -15
- package/lib/common/isConformant.d.ts +0 -4
- package/lib/common/isConformant.js +0 -12
- package/lib/common/isConformant.js.map +0 -1
- package/lib-commonjs/common/isConformant.d.ts +0 -4
- package/lib-commonjs/common/isConformant.js +0 -23
- package/lib-commonjs/common/isConformant.js.map +0 -1
package/CHANGELOG.json
CHANGED
@@ -2,76 +2,188 @@
|
|
2
2
|
"name": "@fluentui/react-switch",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
6
|
-
"tag": "@fluentui/react-switch_v0.0.0-
|
7
|
-
"version": "0.0.0-
|
5
|
+
"date": "Thu, 02 Dec 2021 04:16:17 GMT",
|
6
|
+
"tag": "@fluentui/react-switch_v0.0.0-nightly554221a5aa20211202.1",
|
7
|
+
"version": "0.0.0-nightly554221a5aa20211202.1",
|
8
8
|
"comments": {
|
9
9
|
"prerelease": [
|
10
10
|
{
|
11
11
|
"author": "email not defined",
|
12
12
|
"package": "@fluentui/react-switch",
|
13
|
-
"commit": "
|
13
|
+
"commit": "09da80c5c669ccd56bbfd16c53fd632f4579aa3b",
|
14
14
|
"comment": "Release nightly v9"
|
15
15
|
},
|
16
16
|
{
|
17
17
|
"author": "beachball",
|
18
18
|
"package": "@fluentui/react-switch",
|
19
|
-
"comment": "Bump @fluentui/react-make-styles to v0.0.0-
|
20
|
-
"commit": "
|
19
|
+
"comment": "Bump @fluentui/react-make-styles to v0.0.0-nightly554221a5aa20211202.1",
|
20
|
+
"commit": "09da80c5c669ccd56bbfd16c53fd632f4579aa3b"
|
21
21
|
},
|
22
22
|
{
|
23
23
|
"author": "beachball",
|
24
24
|
"package": "@fluentui/react-switch",
|
25
|
-
"comment": "Bump @fluentui/react-shared-contexts to v0.0.0-
|
26
|
-
"commit": "
|
25
|
+
"comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly554221a5aa20211202.1",
|
26
|
+
"commit": "09da80c5c669ccd56bbfd16c53fd632f4579aa3b"
|
27
27
|
},
|
28
28
|
{
|
29
29
|
"author": "beachball",
|
30
30
|
"package": "@fluentui/react-switch",
|
31
|
-
"comment": "Bump @fluentui/react-tabster to v0.0.0-
|
32
|
-
"commit": "
|
31
|
+
"comment": "Bump @fluentui/react-tabster to v0.0.0-nightly554221a5aa20211202.1",
|
32
|
+
"commit": "09da80c5c669ccd56bbfd16c53fd632f4579aa3b"
|
33
33
|
},
|
34
34
|
{
|
35
35
|
"author": "beachball",
|
36
36
|
"package": "@fluentui/react-switch",
|
37
|
-
"comment": "Bump @fluentui/react-utilities to v0.0.0-
|
38
|
-
"commit": "
|
37
|
+
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly554221a5aa20211202.1",
|
38
|
+
"commit": "09da80c5c669ccd56bbfd16c53fd632f4579aa3b"
|
39
39
|
},
|
40
40
|
{
|
41
41
|
"author": "beachball",
|
42
42
|
"package": "@fluentui/react-switch",
|
43
|
-
"comment": "Bump @fluentui/babel-make-styles to v0.0.0-
|
44
|
-
"commit": "
|
43
|
+
"comment": "Bump @fluentui/babel-make-styles to v0.0.0-nightly554221a5aa20211202.1",
|
44
|
+
"commit": "09da80c5c669ccd56bbfd16c53fd632f4579aa3b"
|
45
45
|
},
|
46
46
|
{
|
47
47
|
"author": "beachball",
|
48
48
|
"package": "@fluentui/react-switch",
|
49
|
-
"comment": "Bump @fluentui/jest-serializer-make-styles to v0.0.0-
|
50
|
-
"commit": "
|
49
|
+
"comment": "Bump @fluentui/jest-serializer-make-styles to v0.0.0-nightly554221a5aa20211202.1",
|
50
|
+
"commit": "09da80c5c669ccd56bbfd16c53fd632f4579aa3b"
|
51
51
|
},
|
52
52
|
{
|
53
53
|
"author": "beachball",
|
54
54
|
"package": "@fluentui/react-switch",
|
55
|
-
"comment": "Bump @fluentui/react-conformance-make-styles to v0.0.0-
|
56
|
-
"commit": "
|
55
|
+
"comment": "Bump @fluentui/react-conformance-make-styles to v0.0.0-nightly554221a5aa20211202.1",
|
56
|
+
"commit": "09da80c5c669ccd56bbfd16c53fd632f4579aa3b"
|
57
|
+
}
|
58
|
+
],
|
59
|
+
"none": [
|
60
|
+
{
|
61
|
+
"author": "andredias@microsoft.com",
|
62
|
+
"package": "@fluentui/react-switch",
|
63
|
+
"commit": "bf950e951b102fd8be046993dbb604073fc4ea9e",
|
64
|
+
"comment": "Migrate package to use solution tsconfigs"
|
65
|
+
}
|
66
|
+
]
|
67
|
+
}
|
68
|
+
},
|
69
|
+
{
|
70
|
+
"date": "Thu, 25 Nov 2021 08:34:17 GMT",
|
71
|
+
"tag": "@fluentui/react-switch_v9.0.0-beta.5",
|
72
|
+
"version": "9.0.0-beta.5",
|
73
|
+
"comments": {
|
74
|
+
"prerelease": [
|
75
|
+
{
|
76
|
+
"author": "beachball",
|
77
|
+
"package": "@fluentui/react-switch",
|
78
|
+
"comment": "Bump @fluentui/react-make-styles to v9.0.0-beta.4",
|
79
|
+
"commit": "48d236ac53a4950fabc3ddd52f91dac93ca0195b"
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"author": "beachball",
|
83
|
+
"package": "@fluentui/react-switch",
|
84
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.0.0-beta.4",
|
85
|
+
"commit": "48d236ac53a4950fabc3ddd52f91dac93ca0195b"
|
86
|
+
},
|
87
|
+
{
|
88
|
+
"author": "beachball",
|
89
|
+
"package": "@fluentui/react-switch",
|
90
|
+
"comment": "Bump @fluentui/react-tabster to v9.0.0-beta.5",
|
91
|
+
"commit": "48d236ac53a4950fabc3ddd52f91dac93ca0195b"
|
92
|
+
},
|
93
|
+
{
|
94
|
+
"author": "beachball",
|
95
|
+
"package": "@fluentui/react-switch",
|
96
|
+
"comment": "Bump @fluentui/react-utilities to v9.0.0-beta.4",
|
97
|
+
"commit": "48d236ac53a4950fabc3ddd52f91dac93ca0195b"
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"author": "beachball",
|
101
|
+
"package": "@fluentui/react-switch",
|
102
|
+
"comment": "Bump @fluentui/babel-make-styles to v9.0.0-beta.4",
|
103
|
+
"commit": "48d236ac53a4950fabc3ddd52f91dac93ca0195b"
|
104
|
+
},
|
105
|
+
{
|
106
|
+
"author": "beachball",
|
107
|
+
"package": "@fluentui/react-switch",
|
108
|
+
"comment": "Bump @fluentui/jest-serializer-make-styles to v9.0.0-beta.4",
|
109
|
+
"commit": "48d236ac53a4950fabc3ddd52f91dac93ca0195b"
|
110
|
+
},
|
111
|
+
{
|
112
|
+
"author": "beachball",
|
113
|
+
"package": "@fluentui/react-switch",
|
114
|
+
"comment": "Bump @fluentui/react-conformance-make-styles to v9.0.0-beta.4",
|
115
|
+
"commit": "48d236ac53a4950fabc3ddd52f91dac93ca0195b"
|
116
|
+
}
|
117
|
+
]
|
118
|
+
}
|
119
|
+
},
|
120
|
+
{
|
121
|
+
"date": "Fri, 12 Nov 2021 13:25:33 GMT",
|
122
|
+
"tag": "@fluentui/react-switch_v9.0.0-beta.4",
|
123
|
+
"version": "9.0.0-beta.4",
|
124
|
+
"comments": {
|
125
|
+
"none": [
|
126
|
+
{
|
127
|
+
"author": "olfedias@microsoft.com",
|
128
|
+
"package": "@fluentui/react-switch",
|
129
|
+
"commit": "9e6977945782df1cc997c92804a1b214cc4e4f43",
|
130
|
+
"comment": "do not use other packages in devDependencies"
|
131
|
+
},
|
132
|
+
{
|
133
|
+
"author": "lingfangao@hotmail.com",
|
134
|
+
"package": "@fluentui/react-switch",
|
135
|
+
"commit": "00f70581480b536e723fb69edf0ae617beac4807",
|
136
|
+
"comment": "Remove beta release tag"
|
137
|
+
}
|
138
|
+
],
|
139
|
+
"prerelease": [
|
140
|
+
{
|
141
|
+
"author": "olfedias@microsoft.com",
|
142
|
+
"package": "@fluentui/react-switch",
|
143
|
+
"commit": "9186578324773f95f4d61be3d70e67752159d843",
|
144
|
+
"comment": "export static classes for components"
|
145
|
+
},
|
146
|
+
{
|
147
|
+
"author": "beachball",
|
148
|
+
"package": "@fluentui/react-switch",
|
149
|
+
"comment": "Bump @fluentui/react-make-styles to v9.0.0-beta.3",
|
150
|
+
"commit": "742342e52c65066f779232e4e1302fedf0dd460d"
|
151
|
+
},
|
152
|
+
{
|
153
|
+
"author": "beachball",
|
154
|
+
"package": "@fluentui/react-switch",
|
155
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.0.0-beta.3",
|
156
|
+
"commit": "742342e52c65066f779232e4e1302fedf0dd460d"
|
157
|
+
},
|
158
|
+
{
|
159
|
+
"author": "beachball",
|
160
|
+
"package": "@fluentui/react-switch",
|
161
|
+
"comment": "Bump @fluentui/react-tabster to v9.0.0-beta.4",
|
162
|
+
"commit": "742342e52c65066f779232e4e1302fedf0dd460d"
|
163
|
+
},
|
164
|
+
{
|
165
|
+
"author": "beachball",
|
166
|
+
"package": "@fluentui/react-switch",
|
167
|
+
"comment": "Bump @fluentui/react-utilities to v9.0.0-beta.3",
|
168
|
+
"commit": "742342e52c65066f779232e4e1302fedf0dd460d"
|
57
169
|
},
|
58
170
|
{
|
59
171
|
"author": "beachball",
|
60
172
|
"package": "@fluentui/react-switch",
|
61
|
-
"comment": "Bump @fluentui/
|
62
|
-
"commit": "
|
173
|
+
"comment": "Bump @fluentui/babel-make-styles to v9.0.0-beta.3",
|
174
|
+
"commit": "742342e52c65066f779232e4e1302fedf0dd460d"
|
63
175
|
},
|
64
176
|
{
|
65
177
|
"author": "beachball",
|
66
178
|
"package": "@fluentui/react-switch",
|
67
|
-
"comment": "Bump @fluentui/
|
68
|
-
"commit": "
|
179
|
+
"comment": "Bump @fluentui/jest-serializer-make-styles to v9.0.0-beta.3",
|
180
|
+
"commit": "742342e52c65066f779232e4e1302fedf0dd460d"
|
69
181
|
},
|
70
182
|
{
|
71
183
|
"author": "beachball",
|
72
184
|
"package": "@fluentui/react-switch",
|
73
|
-
"comment": "Bump @fluentui/react-
|
74
|
-
"commit": "
|
185
|
+
"comment": "Bump @fluentui/react-conformance-make-styles to v9.0.0-beta.3",
|
186
|
+
"commit": "742342e52c65066f779232e4e1302fedf0dd460d"
|
75
187
|
}
|
76
188
|
]
|
77
189
|
}
|
package/CHANGELOG.md
CHANGED
@@ -1,27 +1,55 @@
|
|
1
1
|
# Change Log - @fluentui/react-switch
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Thu, 02 Dec 2021 04:16:17 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
-
## [0.0.0-
|
7
|
+
## [0.0.0-nightly554221a5aa20211202.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v0.0.0-nightly554221a5aa20211202.1)
|
8
8
|
|
9
|
-
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.0.0-beta.
|
9
|
+
Thu, 02 Dec 2021 04:16:17 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.0.0-beta.5..@fluentui/react-switch_v0.0.0-nightly554221a5aa20211202.1)
|
11
11
|
|
12
12
|
### Changes
|
13
13
|
|
14
|
-
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/
|
15
|
-
- Bump @fluentui/react-make-styles to v0.0.0-
|
16
|
-
- Bump @fluentui/react-shared-contexts to v0.0.0-
|
17
|
-
- Bump @fluentui/react-tabster to v0.0.0-
|
18
|
-
- Bump @fluentui/react-utilities to v0.0.0-
|
19
|
-
- Bump @fluentui/babel-make-styles to v0.0.0-
|
20
|
-
- Bump @fluentui/jest-serializer-make-styles to v0.0.0-
|
21
|
-
- Bump @fluentui/react-conformance-make-styles to v0.0.0-
|
22
|
-
|
23
|
-
|
24
|
-
|
14
|
+
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/09da80c5c669ccd56bbfd16c53fd632f4579aa3b) by email not defined)
|
15
|
+
- Bump @fluentui/react-make-styles to v0.0.0-nightly554221a5aa20211202.1 ([commit](https://github.com/microsoft/fluentui/commit/09da80c5c669ccd56bbfd16c53fd632f4579aa3b) by beachball)
|
16
|
+
- Bump @fluentui/react-shared-contexts to v0.0.0-nightly554221a5aa20211202.1 ([commit](https://github.com/microsoft/fluentui/commit/09da80c5c669ccd56bbfd16c53fd632f4579aa3b) by beachball)
|
17
|
+
- Bump @fluentui/react-tabster to v0.0.0-nightly554221a5aa20211202.1 ([commit](https://github.com/microsoft/fluentui/commit/09da80c5c669ccd56bbfd16c53fd632f4579aa3b) by beachball)
|
18
|
+
- Bump @fluentui/react-utilities to v0.0.0-nightly554221a5aa20211202.1 ([commit](https://github.com/microsoft/fluentui/commit/09da80c5c669ccd56bbfd16c53fd632f4579aa3b) by beachball)
|
19
|
+
- Bump @fluentui/babel-make-styles to v0.0.0-nightly554221a5aa20211202.1 ([commit](https://github.com/microsoft/fluentui/commit/09da80c5c669ccd56bbfd16c53fd632f4579aa3b) by beachball)
|
20
|
+
- Bump @fluentui/jest-serializer-make-styles to v0.0.0-nightly554221a5aa20211202.1 ([commit](https://github.com/microsoft/fluentui/commit/09da80c5c669ccd56bbfd16c53fd632f4579aa3b) by beachball)
|
21
|
+
- Bump @fluentui/react-conformance-make-styles to v0.0.0-nightly554221a5aa20211202.1 ([commit](https://github.com/microsoft/fluentui/commit/09da80c5c669ccd56bbfd16c53fd632f4579aa3b) by beachball)
|
22
|
+
|
23
|
+
## [9.0.0-beta.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.0.0-beta.5)
|
24
|
+
|
25
|
+
Thu, 25 Nov 2021 08:34:17 GMT
|
26
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.0.0-beta.4..@fluentui/react-switch_v9.0.0-beta.5)
|
27
|
+
|
28
|
+
### Changes
|
29
|
+
|
30
|
+
- Bump @fluentui/react-make-styles to v9.0.0-beta.4 ([PR #20762](https://github.com/microsoft/fluentui/pull/20762) by beachball)
|
31
|
+
- Bump @fluentui/react-shared-contexts to v9.0.0-beta.4 ([PR #20762](https://github.com/microsoft/fluentui/pull/20762) by beachball)
|
32
|
+
- Bump @fluentui/react-tabster to v9.0.0-beta.5 ([PR #20762](https://github.com/microsoft/fluentui/pull/20762) by beachball)
|
33
|
+
- Bump @fluentui/react-utilities to v9.0.0-beta.4 ([PR #20762](https://github.com/microsoft/fluentui/pull/20762) by beachball)
|
34
|
+
- Bump @fluentui/babel-make-styles to v9.0.0-beta.4 ([PR #20762](https://github.com/microsoft/fluentui/pull/20762) by beachball)
|
35
|
+
- Bump @fluentui/jest-serializer-make-styles to v9.0.0-beta.4 ([PR #20762](https://github.com/microsoft/fluentui/pull/20762) by beachball)
|
36
|
+
- Bump @fluentui/react-conformance-make-styles to v9.0.0-beta.4 ([PR #20762](https://github.com/microsoft/fluentui/pull/20762) by beachball)
|
37
|
+
|
38
|
+
## [9.0.0-beta.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.0.0-beta.4)
|
39
|
+
|
40
|
+
Fri, 12 Nov 2021 13:25:33 GMT
|
41
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.0.0-beta.3..@fluentui/react-switch_v9.0.0-beta.4)
|
42
|
+
|
43
|
+
### Changes
|
44
|
+
|
45
|
+
- export static classes for components ([PR #20456](https://github.com/microsoft/fluentui/pull/20456) by olfedias@microsoft.com)
|
46
|
+
- Bump @fluentui/react-make-styles to v9.0.0-beta.3 ([PR #20583](https://github.com/microsoft/fluentui/pull/20583) by beachball)
|
47
|
+
- Bump @fluentui/react-shared-contexts to v9.0.0-beta.3 ([PR #20583](https://github.com/microsoft/fluentui/pull/20583) by beachball)
|
48
|
+
- Bump @fluentui/react-tabster to v9.0.0-beta.4 ([PR #20583](https://github.com/microsoft/fluentui/pull/20583) by beachball)
|
49
|
+
- Bump @fluentui/react-utilities to v9.0.0-beta.3 ([PR #20583](https://github.com/microsoft/fluentui/pull/20583) by beachball)
|
50
|
+
- Bump @fluentui/babel-make-styles to v9.0.0-beta.3 ([PR #20583](https://github.com/microsoft/fluentui/pull/20583) by beachball)
|
51
|
+
- Bump @fluentui/jest-serializer-make-styles to v9.0.0-beta.3 ([PR #20583](https://github.com/microsoft/fluentui/pull/20583) by beachball)
|
52
|
+
- Bump @fluentui/react-conformance-make-styles to v9.0.0-beta.3 ([PR #20583](https://github.com/microsoft/fluentui/pull/20583) by beachball)
|
25
53
|
|
26
54
|
## [9.0.0-beta.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.0.0-beta.3)
|
27
55
|
|
package/Spec.md
CHANGED
@@ -86,10 +86,10 @@ Amongst other major component libraries (`Material UI`, `Ant Design`, `Evergreen
|
|
86
86
|
- _**DOM**_
|
87
87
|
|
88
88
|
```jsx=
|
89
|
-
<div className="
|
90
|
-
<div className="
|
91
|
-
<div className="
|
92
|
-
<div className="
|
89
|
+
<div className="fui-Switch">
|
90
|
+
<div className="fui-Switch-track" />
|
91
|
+
<div className="fui-Switch-thumbWrapper">
|
92
|
+
<div className="fui-Switch-thumb" />
|
93
93
|
</div>
|
94
94
|
<input type="checkbox" />
|
95
95
|
</div>;
|
package/dist/react-switch.d.ts
CHANGED
@@ -14,6 +14,8 @@ export declare const renderSwitch: (state: SwitchState) => JSX.Element;
|
|
14
14
|
*/
|
15
15
|
export declare const Switch: ForwardRefComponent<SwitchProps>;
|
16
16
|
|
17
|
+
export declare const switchClassName = "fui-Switch";
|
18
|
+
|
17
19
|
export declare interface SwitchCommons {
|
18
20
|
/**
|
19
21
|
* The starting value for a uncontrolled Switch. If `true` then the Switch will be enabled.
|
@@ -6,8 +6,8 @@ import { useSwitchStyles } from './useSwitchStyles';
|
|
6
6
|
* The Switch control enables users to trigger an option on or off through pressing on the component.
|
7
7
|
*/
|
8
8
|
|
9
|
-
export
|
10
|
-
|
9
|
+
export const Switch = /*#__PURE__*/React.forwardRef((props, ref) => {
|
10
|
+
const state = useSwitch(props, ref);
|
11
11
|
useSwitchStyles(state);
|
12
12
|
return renderSwitch(state);
|
13
13
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Switch/Switch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,SAAT,QAA0B,aAA1B;AACA,SAAS,YAAT,QAA6B,gBAA7B;AACA,SAAS,eAAT,QAAgC,mBAAhC;AAIA;;AAEG;;AACH,OAAO,
|
1
|
+
{"version":3,"sources":["../../../src/components/Switch/Switch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,SAAT,QAA0B,aAA1B;AACA,SAAS,YAAT,QAA6B,gBAA7B;AACA,SAAS,eAAT,QAAgC,mBAAhC;AAIA;;AAEG;;AACH,OAAO,MAAM,MAAM,gBAAqC,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;AACtF,QAAM,KAAK,GAAG,SAAS,CAAC,KAAD,EAAQ,GAAR,CAAvB;AAEA,EAAA,eAAe,CAAC,KAAD,CAAf;AAEA,SAAO,YAAY,CAAC,KAAD,CAAnB;AACD,CANuD,CAAjD;AAQP,MAAM,CAAC,WAAP,GAAqB,QAArB","sourceRoot":""}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { __assign } from "tslib";
|
2
1
|
import * as React from 'react';
|
3
2
|
import { getSlots } from '@fluentui/react-utilities';
|
4
3
|
import { switchShorthandProps } from './useSwitch';
|
@@ -6,11 +5,11 @@ import { switchShorthandProps } from './useSwitch';
|
|
6
5
|
* Render the final JSX of Switch
|
7
6
|
*/
|
8
7
|
|
9
|
-
export
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
return /*#__PURE__*/React.createElement(slots.root,
|
8
|
+
export const renderSwitch = state => {
|
9
|
+
const {
|
10
|
+
slots,
|
11
|
+
slotProps
|
12
|
+
} = getSlots(state, switchShorthandProps);
|
13
|
+
return /*#__PURE__*/React.createElement(slots.root, Object.assign({}, slotProps.root), /*#__PURE__*/React.createElement(slots.track, Object.assign({}, slotProps.track)), /*#__PURE__*/React.createElement(slots.thumbWrapper, Object.assign({}, slotProps.thumbWrapper), /*#__PURE__*/React.createElement(slots.thumb, Object.assign({}, slotProps.thumb))), /*#__PURE__*/React.createElement(slots.input, Object.assign({}, slotProps.input)), /*#__PURE__*/React.createElement(slots.activeRail, Object.assign({}, slotProps.activeRail)));
|
15
14
|
};
|
16
15
|
//# sourceMappingURL=renderSwitch.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Switch/renderSwitch.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/components/Switch/renderSwitch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AACA,SAAS,oBAAT,QAAqC,aAArC;AAGA;;AAEG;;AACH,OAAO,MAAM,YAAY,GAAI,KAAD,IAAuB;AACjD,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,QAAQ,CAAc,KAAd,EAAqB,oBAArB,CAArC;AAEA,sBACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,MAAA,CAAA,MAAA,CAAA,EAAA,EAAK,SAAS,CAAC,IAAf,CAAX,eACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,MAAA,CAAA,MAAA,CAAA,EAAA,EAAK,SAAS,CAAC,KAAf,CAAZ,CADF,eAEE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,YAAP,EAAmB,MAAA,CAAA,MAAA,CAAA,EAAA,EAAK,SAAS,CAAC,YAAf,CAAnB,eACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,MAAA,CAAA,MAAA,CAAA,EAAA,EAAK,SAAS,CAAC,KAAf,CAAZ,CADF,CAFF,eAKE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,MAAA,CAAA,MAAA,CAAA,EAAA,EAAK,SAAS,CAAC,KAAf,CAAZ,CALF,eAME,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,UAAP,EAAiB,MAAA,CAAA,MAAA,CAAA,EAAA,EAAK,SAAS,CAAC,UAAf,CAAjB,CANF,CADF;AAUD,CAbM","sourceRoot":""}
|
@@ -1,35 +1,36 @@
|
|
1
|
-
import { __assign } from "tslib";
|
2
1
|
import { getNativeElementProps, resolveShorthand, useId } from '@fluentui/react-utilities';
|
3
2
|
import { useSwitchState } from './useSwitchState';
|
4
3
|
/**
|
5
4
|
* Array of all shorthand properties listed in SwitchSlots
|
6
5
|
*/
|
7
6
|
|
8
|
-
export
|
7
|
+
export const switchShorthandProps = ['root', 'track', 'thumbWrapper', 'thumb', 'activeRail', 'input'];
|
9
8
|
/**
|
10
9
|
* Given user props, returns state and render function for a Switch.
|
11
10
|
*/
|
12
11
|
|
13
|
-
export
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
12
|
+
export const useSwitch = (props, ref) => {
|
13
|
+
const {
|
14
|
+
track,
|
15
|
+
thumbWrapper,
|
16
|
+
thumb,
|
17
|
+
activeRail,
|
18
|
+
input,
|
19
|
+
defaultChecked,
|
20
|
+
checked,
|
21
|
+
disabled,
|
22
|
+
onChange
|
23
|
+
} = props;
|
24
|
+
const state = {
|
25
|
+
defaultChecked,
|
26
|
+
checked,
|
27
|
+
disabled,
|
28
|
+
onChange,
|
29
|
+
root: getNativeElementProps('span', {
|
30
|
+
ref,
|
31
|
+
...props,
|
31
32
|
id: useId('switch-', props.id)
|
32
|
-
})
|
33
|
+
}),
|
33
34
|
components: {
|
34
35
|
root: 'div',
|
35
36
|
track: 'div',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Switch/useSwitch.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/components/Switch/useSwitch.ts"],"names":[],"mappings":"AACA,SAAS,qBAAT,EAAgC,gBAAhC,EAAkD,KAAlD,QAA+D,2BAA/D;AACA,SAAS,cAAT,QAA+B,kBAA/B;AAGA;;AAEG;;AACH,OAAO,MAAM,oBAAoB,GAA0B,CACzD,MADyD,EAEzD,OAFyD,EAGzD,cAHyD,EAIzD,OAJyD,EAKzD,YALyD,EAMzD,OANyD,CAApD;AASP;;AAEG;;AACH,OAAO,MAAM,SAAS,GAAG,CAAC,KAAD,EAAqB,GAArB,KAAiE;AACxF,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA,YAAT;AAAuB,IAAA,KAAvB;AAA8B,IAAA,UAA9B;AAA0C,IAAA,KAA1C;AAAiD,IAAA,cAAjD;AAAiE,IAAA,OAAjE;AAA0E,IAAA,QAA1E;AAAoF,IAAA;AAApF,MAAiG,KAAvG;AACA,QAAM,KAAK,GAAgB;AACzB,IAAA,cADyB;AAEzB,IAAA,OAFyB;AAGzB,IAAA,QAHyB;AAIzB,IAAA,QAJyB;AAKzB,IAAA,IAAI,EAAE,qBAAqB,CAAC,MAAD,EAAS;AAClC,MAAA,GADkC;AAElC,SAAG,KAF+B;AAGlC,MAAA,EAAE,EAAE,KAAK,CAAC,SAAD,EAAY,KAAK,CAAC,EAAlB;AAHyB,KAAT,CALF;AAUzB,IAAA,UAAU,EAAE;AACV,MAAA,IAAI,EAAE,KADI;AAEV,MAAA,KAAK,EAAE,KAFG;AAGV,MAAA,YAAY,EAAE,KAHJ;AAIV,MAAA,KAAK,EAAE,KAJG;AAKV,MAAA,UAAU,EAAE,KALF;AAMV,MAAA,KAAK,EAAE;AANG,KAVa;AAkBzB,IAAA,KAAK,EAAE,gBAAgB,CAAC,KAAD,EAAQ;AAAE,MAAA,QAAQ,EAAE;AAAZ,KAAR,CAlBE;AAmBzB,IAAA,YAAY,EAAE,gBAAgB,CAAC,YAAD,EAAe;AAAE,MAAA,QAAQ,EAAE;AAAZ,KAAf,CAnBL;AAoBzB,IAAA,KAAK,EAAE,gBAAgB,CAAC,KAAD,EAAQ;AAAE,MAAA,QAAQ,EAAE;AAAZ,KAAR,CApBE;AAqBzB,IAAA,UAAU,EAAE,gBAAgB,CAAC,UAAD,EAAa;AAAE,MAAA,QAAQ,EAAE;AAAZ,KAAb,CArBH;AAsBzB,IAAA,KAAK,EAAE,gBAAgB,CAAC,KAAD,EAAQ;AAC7B,MAAA,QAAQ,EAAE,IADmB;AAE7B,MAAA,YAAY,EAAE;AACZ,QAAA,IAAI,EAAE;AADM;AAFe,KAAR;AAtBE,GAA3B;AA8BA,EAAA,cAAc,CAAC,KAAD,CAAd;AAEA,SAAO,KAAP;AACD,CAnCM","sourceRoot":""}
|
@@ -3,51 +3,43 @@ import { clamp, useBoolean, useControllableState, useEventCallback, useMergedRef
|
|
3
3
|
import { useFluent } from '@fluentui/react-shared-contexts'; // TODO: This should be replaced with a useEvent hook
|
4
4
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
5
5
|
|
6
|
-
|
6
|
+
const on = (element, eventName, callback) => {
|
7
7
|
element.addEventListener(eventName, callback);
|
8
|
-
return
|
9
|
-
return element.removeEventListener(eventName, callback);
|
10
|
-
};
|
8
|
+
return () => element.removeEventListener(eventName, callback);
|
11
9
|
};
|
12
10
|
|
13
|
-
export
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
11
|
+
export const useSwitchState = state => {
|
12
|
+
const {
|
13
|
+
defaultChecked = false,
|
14
|
+
checked,
|
15
|
+
disabled = false,
|
16
|
+
onChange
|
17
|
+
} = state;
|
18
|
+
const {
|
19
|
+
onPointerDown: onPointerDownCallback,
|
20
|
+
onKeyUp: onKeyUpCallback
|
21
|
+
} = state.root;
|
22
|
+
const {
|
23
|
+
dir
|
24
|
+
} = useFluent();
|
25
|
+
const inputRef = useMergedRefs(state.input.ref);
|
26
|
+
const railRef = React.useRef(null);
|
27
|
+
const internalState = React.useRef({
|
27
28
|
internalValue: checked ? checked : defaultChecked,
|
28
29
|
thumbIsDragging: false,
|
29
30
|
disposables: []
|
30
31
|
});
|
31
|
-
|
32
|
-
var _d = useControllableState({
|
32
|
+
const [currentValue, setCurrentValue] = useControllableState({
|
33
33
|
defaultState: defaultChecked,
|
34
34
|
state: checked,
|
35
35
|
initialState: false
|
36
|
-
})
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
showThumbAnimation = _f.setTrue,
|
44
|
-
hideThumbAnimation = _f.setFalse;
|
45
|
-
|
46
|
-
var _g = React.useState(currentValue === true ? 100 : 0),
|
47
|
-
renderedPosition = _g[0],
|
48
|
-
setRenderedPosition = _g[1];
|
49
|
-
|
50
|
-
var setChecked = useEventCallback(function (ev, incomingValue) {
|
36
|
+
});
|
37
|
+
const [thumbAnimation, {
|
38
|
+
setTrue: showThumbAnimation,
|
39
|
+
setFalse: hideThumbAnimation
|
40
|
+
}] = useBoolean(true);
|
41
|
+
const [renderedPosition, setRenderedPosition] = React.useState(currentValue === true ? 100 : 0);
|
42
|
+
const setChecked = useEventCallback((ev, incomingValue) => {
|
51
43
|
ev.stopPropagation();
|
52
44
|
ev.preventDefault();
|
53
45
|
internalState.current.internalValue = incomingValue;
|
@@ -57,17 +49,17 @@ export var useSwitchState = function (state) {
|
|
57
49
|
setCurrentValue(incomingValue);
|
58
50
|
setRenderedPosition(undefined);
|
59
51
|
});
|
60
|
-
|
52
|
+
const calculatePosition = React.useCallback(ev => {
|
61
53
|
var _a;
|
62
54
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
55
|
+
const currentBounds = (_a = railRef === null || railRef === void 0 ? void 0 : railRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
56
|
+
const railWidth = currentBounds.width;
|
57
|
+
const railPosition = dir === 'rtl' ? currentBounds.right : currentBounds.left;
|
58
|
+
const distance = dir === 'rtl' ? railPosition - ev.clientX : ev.clientX - railPosition;
|
67
59
|
return clamp(distance / railWidth * 100, 0, 100);
|
68
60
|
}, [dir]);
|
69
|
-
|
70
|
-
|
61
|
+
const onPointerMove = React.useCallback(ev => {
|
62
|
+
const incomingPosition = calculatePosition(ev);
|
71
63
|
internalState.current.thumbIsDragging = true;
|
72
64
|
hideThumbAnimation();
|
73
65
|
setRenderedPosition(incomingPosition); // If the Switch reaches a new position of 0% or 100%, update the state and fire change.
|
@@ -78,15 +70,13 @@ export var useSwitchState = function (state) {
|
|
78
70
|
setChecked(ev, false);
|
79
71
|
}
|
80
72
|
}, [calculatePosition, hideThumbAnimation, setChecked]);
|
81
|
-
|
82
|
-
internalState.current.disposables.forEach(
|
83
|
-
return dispose();
|
84
|
-
});
|
73
|
+
const onPointerUp = React.useCallback(ev => {
|
74
|
+
internalState.current.disposables.forEach(dispose => dispose());
|
85
75
|
internalState.current.disposables = [];
|
86
76
|
inputRef.current.focus();
|
87
77
|
|
88
78
|
if (internalState.current.thumbIsDragging) {
|
89
|
-
|
79
|
+
const roundedPosition = Math.round(calculatePosition(ev) / 100) * 100;
|
90
80
|
showThumbAnimation();
|
91
81
|
|
92
82
|
if (roundedPosition === 100) {
|
@@ -98,35 +88,37 @@ export var useSwitchState = function (state) {
|
|
98
88
|
setChecked(ev, !internalState.current.internalValue);
|
99
89
|
}
|
100
90
|
}, [calculatePosition, inputRef, setChecked, showThumbAnimation]);
|
101
|
-
|
91
|
+
const onPointerDown = React.useCallback(ev => {
|
102
92
|
var _a;
|
103
93
|
|
104
|
-
|
105
|
-
|
94
|
+
const {
|
95
|
+
pointerId
|
96
|
+
} = ev;
|
97
|
+
const target = ev.target;
|
106
98
|
onPointerDownCallback === null || onPointerDownCallback === void 0 ? void 0 : onPointerDownCallback(ev);
|
107
99
|
showThumbAnimation();
|
108
100
|
(_a = target.setPointerCapture) === null || _a === void 0 ? void 0 : _a.call(target, pointerId);
|
109
101
|
internalState.current.thumbIsDragging = false;
|
110
|
-
internalState.current.disposables.push(on(target, 'pointermove', onPointerMove), on(target, 'pointerup', onPointerUp),
|
102
|
+
internalState.current.disposables.push(on(target, 'pointermove', onPointerMove), on(target, 'pointerup', onPointerUp), () => {
|
111
103
|
var _a;
|
112
104
|
|
113
105
|
(_a = target.releasePointerCapture) === null || _a === void 0 ? void 0 : _a.call(target, pointerId);
|
114
106
|
});
|
115
107
|
}, [onPointerDownCallback, onPointerMove, onPointerUp, showThumbAnimation]);
|
116
|
-
|
108
|
+
const onKeyUp = React.useCallback(ev => {
|
117
109
|
onKeyUpCallback === null || onKeyUpCallback === void 0 ? void 0 : onKeyUpCallback(ev);
|
118
110
|
|
119
111
|
if (ev.key === ' ') {
|
120
112
|
setChecked(ev, !internalState.current.internalValue);
|
121
113
|
}
|
122
114
|
}, [onKeyUpCallback, setChecked]);
|
123
|
-
|
124
|
-
|
115
|
+
const currentPosition = renderedPosition !== undefined ? renderedPosition : currentValue ? 100 : 0;
|
116
|
+
const rootStyles = {
|
125
117
|
'--switch-checked-opacity': currentPosition / 100,
|
126
118
|
'--switch-unchecked-opacity': (100 - currentPosition) / 100
|
127
119
|
};
|
128
|
-
|
129
|
-
transform:
|
120
|
+
const thumbWrapperStyles = {
|
121
|
+
transform: `translate(${dir === 'rtl' ? -currentPosition : currentPosition}%)`,
|
130
122
|
transition: thumbAnimation ? 'transform .1s cubic-bezier(0.33, 0.0, 0.67, 1), opacity .1s cubic-bezier(0.33, 0.0, 0.67, 1)' : 'none'
|
131
123
|
}; // Root Props
|
132
124
|
|