@fluentui/react-switch 9.0.0-alpha.8 → 9.0.0-nightly.25435def33.0
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 +648 -1
- package/CHANGELOG.md +180 -2
- package/dist/react-switch.d.ts +7 -2
- package/lib/components/Switch/Switch.d.ts +2 -2
- package/lib/components/Switch/Switch.js.map +1 -1
- package/lib/components/Switch/Switch.types.d.ts +5 -1
- package/lib/components/Switch/renderSwitch.js +1 -1
- package/lib/components/Switch/renderSwitch.js.map +1 -1
- package/lib/components/Switch/useSwitch.js +6 -1
- package/lib/components/Switch/useSwitch.js.map +1 -1
- package/lib/components/Switch/useSwitchState.js +124 -19
- package/lib/components/Switch/useSwitchState.js.map +1 -1
- package/lib/components/Switch/useSwitchStyles.js +186 -95
- package/lib/components/Switch/useSwitchStyles.js.map +1 -1
- package/lib-commonjs/components/Switch/Switch.d.ts +2 -2
- package/lib-commonjs/components/Switch/Switch.js.map +1 -1
- package/lib-commonjs/components/Switch/Switch.types.d.ts +5 -1
- package/lib-commonjs/components/Switch/renderSwitch.js +1 -1
- package/lib-commonjs/components/Switch/renderSwitch.js.map +1 -1
- package/lib-commonjs/components/Switch/useSwitch.js +6 -1
- package/lib-commonjs/components/Switch/useSwitch.js.map +1 -1
- package/lib-commonjs/components/Switch/useSwitchState.js +123 -18
- package/lib-commonjs/components/Switch/useSwitchState.js.map +1 -1
- package/lib-commonjs/components/Switch/useSwitchStyles.js +185 -94
- package/lib-commonjs/components/Switch/useSwitchStyles.js.map +1 -1
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,190 @@
|
|
1
1
|
# Change Log - @fluentui/react-switch
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Thu, 21 Oct 2021 09:18:06 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.0.0-nightly.25435def33.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.0.0-nightly.25435def33.0)
|
8
|
+
|
9
|
+
Thu, 21 Oct 2021 09:18:06 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.0.0-beta.2..@fluentui/react-switch_v9.0.0-nightly.25435def33.0)
|
11
|
+
|
12
|
+
### Changes
|
13
|
+
|
14
|
+
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/fb58116bf4cb0469b316999385bdbc960b02d2a3) by email not defined)
|
15
|
+
- Changing the Switch's onKeyDown event to onKeyUp. ([commit](https://github.com/microsoft/fluentui/commit/fb58116bf4cb0469b316999385bdbc960b02d2a3) by czearing@outlook.com)
|
16
|
+
- added styling of documentation ([commit](https://github.com/microsoft/fluentui/commit/fb58116bf4cb0469b316999385bdbc960b02d2a3) by peter@draxler.ml)
|
17
|
+
- Bump @fluentui/react-make-styles to v9.0.0-nightly.25435def33.0 ([commit](https://github.com/microsoft/fluentui/commit/fb58116bf4cb0469b316999385bdbc960b02d2a3) by beachball)
|
18
|
+
- Bump @fluentui/react-shared-contexts to v9.0.0-nightly.25435def33.0 ([commit](https://github.com/microsoft/fluentui/commit/fb58116bf4cb0469b316999385bdbc960b02d2a3) by beachball)
|
19
|
+
- Bump @fluentui/react-tabster to v9.0.0-nightly.25435def33.0 ([commit](https://github.com/microsoft/fluentui/commit/fb58116bf4cb0469b316999385bdbc960b02d2a3) by beachball)
|
20
|
+
- Bump @fluentui/react-utilities to v9.0.0-nightly.25435def33.0 ([commit](https://github.com/microsoft/fluentui/commit/fb58116bf4cb0469b316999385bdbc960b02d2a3) by beachball)
|
21
|
+
- Bump @fluentui/babel-make-styles to v9.0.0-nightly.25435def33.0 ([commit](https://github.com/microsoft/fluentui/commit/fb58116bf4cb0469b316999385bdbc960b02d2a3) by beachball)
|
22
|
+
- Bump @fluentui/jest-serializer-make-styles to v9.0.0-nightly.25435def33.0 ([commit](https://github.com/microsoft/fluentui/commit/fb58116bf4cb0469b316999385bdbc960b02d2a3) by beachball)
|
23
|
+
- Bump @fluentui/react-conformance-make-styles to v9.0.0-nightly.25435def33.0 ([commit](https://github.com/microsoft/fluentui/commit/fb58116bf4cb0469b316999385bdbc960b02d2a3) by beachball)
|
24
|
+
- Bump @fluentui/react-label to v9.0.0-nightly.25435def33.0 ([commit](https://github.com/microsoft/fluentui/commit/fb58116bf4cb0469b316999385bdbc960b02d2a3) by beachball)
|
25
|
+
- Bump @fluentui/react-provider to v9.0.0-nightly.25435def33.0 ([commit](https://github.com/microsoft/fluentui/commit/fb58116bf4cb0469b316999385bdbc960b02d2a3) by beachball)
|
26
|
+
- Bump @fluentui/react-theme to v9.0.0-nightly.25435def33.0 ([commit](https://github.com/microsoft/fluentui/commit/fb58116bf4cb0469b316999385bdbc960b02d2a3) by beachball)
|
27
|
+
|
28
|
+
## [9.0.0-beta.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.0.0-beta.2)
|
29
|
+
|
30
|
+
Tue, 12 Oct 2021 19:45:58 GMT
|
31
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.0.0-beta.1..@fluentui/react-switch_v9.0.0-beta.2)
|
32
|
+
|
33
|
+
### Changes
|
34
|
+
|
35
|
+
- Bump @fluentui/react-tabster to v9.0.0-beta.2 ([PR #20132](https://github.com/microsoft/fluentui/pull/20132) by beachball)
|
36
|
+
- Bump @fluentui/react-provider to v9.0.0-beta.2 ([PR #20132](https://github.com/microsoft/fluentui/pull/20132) by beachball)
|
37
|
+
|
38
|
+
## [9.0.0-beta.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.0.0-beta.1)
|
39
|
+
|
40
|
+
Wed, 06 Oct 2021 10:37:22 GMT
|
41
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.0.0-alpha.17..@fluentui/react-switch_v9.0.0-beta.1)
|
42
|
+
|
43
|
+
### Changes
|
44
|
+
|
45
|
+
- Bump all v9 components to beta prerelease tag ([PR #20106](https://github.com/microsoft/fluentui/pull/20106) by lingfangao@hotmail.com)
|
46
|
+
- Bump @fluentui/react-make-styles to v9.0.0-beta.1 ([PR #20106](https://github.com/microsoft/fluentui/pull/20106) by beachball)
|
47
|
+
- Bump @fluentui/react-shared-contexts to v9.0.0-beta.1 ([PR #20106](https://github.com/microsoft/fluentui/pull/20106) by beachball)
|
48
|
+
- Bump @fluentui/react-tabster to v9.0.0-beta.1 ([PR #20106](https://github.com/microsoft/fluentui/pull/20106) by beachball)
|
49
|
+
- Bump @fluentui/react-utilities to v9.0.0-beta.1 ([PR #20106](https://github.com/microsoft/fluentui/pull/20106) by beachball)
|
50
|
+
- Bump @fluentui/babel-make-styles to v9.0.0-beta.1 ([PR #20106](https://github.com/microsoft/fluentui/pull/20106) by beachball)
|
51
|
+
- Bump @fluentui/jest-serializer-make-styles to v9.0.0-beta.1 ([PR #20106](https://github.com/microsoft/fluentui/pull/20106) by beachball)
|
52
|
+
- Bump @fluentui/react-conformance-make-styles to v9.0.0-beta.1 ([PR #20106](https://github.com/microsoft/fluentui/pull/20106) by beachball)
|
53
|
+
- Bump @fluentui/react-label to v9.0.0-beta.1 ([PR #20106](https://github.com/microsoft/fluentui/pull/20106) by beachball)
|
54
|
+
- Bump @fluentui/react-provider to v9.0.0-beta.1 ([PR #20106](https://github.com/microsoft/fluentui/pull/20106) by beachball)
|
55
|
+
- Bump @fluentui/react-theme to v9.0.0-beta.1 ([PR #20106](https://github.com/microsoft/fluentui/pull/20106) by beachball)
|
56
|
+
|
57
|
+
## [9.0.0-alpha.17](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.0.0-alpha.17)
|
58
|
+
|
59
|
+
Tue, 05 Oct 2021 12:47:58 GMT
|
60
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.0.0-alpha.16..@fluentui/react-switch_v9.0.0-alpha.17)
|
61
|
+
|
62
|
+
### Changes
|
63
|
+
|
64
|
+
- Bump @fluentui/react-make-styles to v9.0.0-alpha.78 ([PR #20108](https://github.com/microsoft/fluentui/pull/20108) by beachball)
|
65
|
+
- Bump @fluentui/react-tabster to v9.0.0-alpha.73 ([PR #20108](https://github.com/microsoft/fluentui/pull/20108) by beachball)
|
66
|
+
- Bump @fluentui/babel-make-styles to v9.0.0-alpha.60 ([PR #20108](https://github.com/microsoft/fluentui/pull/20108) by beachball)
|
67
|
+
- Bump @fluentui/jest-serializer-make-styles to v9.0.0-alpha.53 ([PR #20108](https://github.com/microsoft/fluentui/pull/20108) by beachball)
|
68
|
+
- Bump @fluentui/react-conformance-make-styles to v9.0.0-alpha.22 ([PR #20108](https://github.com/microsoft/fluentui/pull/20108) by beachball)
|
69
|
+
- Bump @fluentui/react-label to v9.0.0-alpha.51 ([PR #20108](https://github.com/microsoft/fluentui/pull/20108) by beachball)
|
70
|
+
- Bump @fluentui/react-provider to v9.0.0-alpha.90 ([PR #20108](https://github.com/microsoft/fluentui/pull/20108) by beachball)
|
71
|
+
|
72
|
+
## [9.0.0-alpha.16](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.0.0-alpha.16)
|
73
|
+
|
74
|
+
Tue, 05 Oct 2021 09:28:07 GMT
|
75
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.0.0-alpha.15..@fluentui/react-switch_v9.0.0-alpha.16)
|
76
|
+
|
77
|
+
### Changes
|
78
|
+
|
79
|
+
- Adds ForwardRefComponent to react-switch components declaration ([PR #20081](https://github.com/microsoft/fluentui/pull/20081) by bsunderhus@microsoft.com)
|
80
|
+
- Bump @fluentui/react-make-styles to v9.0.0-alpha.77 ([PR #20081](https://github.com/microsoft/fluentui/pull/20081) by beachball)
|
81
|
+
- Bump @fluentui/react-tabster to v9.0.0-alpha.72 ([PR #20081](https://github.com/microsoft/fluentui/pull/20081) by beachball)
|
82
|
+
- Bump @fluentui/react-utilities to v9.0.0-alpha.56 ([PR #20081](https://github.com/microsoft/fluentui/pull/20081) by beachball)
|
83
|
+
- Bump @fluentui/babel-make-styles to v9.0.0-alpha.59 ([PR #20081](https://github.com/microsoft/fluentui/pull/20081) by beachball)
|
84
|
+
- Bump @fluentui/jest-serializer-make-styles to v9.0.0-alpha.52 ([PR #20081](https://github.com/microsoft/fluentui/pull/20081) by beachball)
|
85
|
+
- Bump @fluentui/react-conformance-make-styles to v9.0.0-alpha.21 ([PR #20081](https://github.com/microsoft/fluentui/pull/20081) by beachball)
|
86
|
+
- Bump @fluentui/react-label to v9.0.0-alpha.50 ([PR #20081](https://github.com/microsoft/fluentui/pull/20081) by beachball)
|
87
|
+
- Bump @fluentui/react-provider to v9.0.0-alpha.89 ([PR #20081](https://github.com/microsoft/fluentui/pull/20081) by beachball)
|
88
|
+
|
89
|
+
## [9.0.0-alpha.15](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.0.0-alpha.15)
|
90
|
+
|
91
|
+
Fri, 01 Oct 2021 14:13:08 GMT
|
92
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.0.0-alpha.13..@fluentui/react-switch_v9.0.0-alpha.15)
|
93
|
+
|
94
|
+
### Changes
|
95
|
+
|
96
|
+
- Bump v9 prerelease versions to rerelease ([PR #20069](https://github.com/microsoft/fluentui/pull/20069) by lingfangao@hotmail.com)
|
97
|
+
- Bump @fluentui/react-make-styles to v9.0.0-alpha.76 ([PR #20069](https://github.com/microsoft/fluentui/pull/20069) by beachball)
|
98
|
+
- Bump @fluentui/react-shared-contexts to v9.0.0-alpha.28 ([PR #20069](https://github.com/microsoft/fluentui/pull/20069) by beachball)
|
99
|
+
- Bump @fluentui/react-tabster to v9.0.0-alpha.71 ([PR #20069](https://github.com/microsoft/fluentui/pull/20069) by beachball)
|
100
|
+
- Bump @fluentui/react-utilities to v9.0.0-alpha.55 ([PR #20069](https://github.com/microsoft/fluentui/pull/20069) by beachball)
|
101
|
+
- Bump @fluentui/babel-make-styles to v9.0.0-alpha.58 ([PR #20069](https://github.com/microsoft/fluentui/pull/20069) by beachball)
|
102
|
+
- Bump @fluentui/jest-serializer-make-styles to v9.0.0-alpha.51 ([PR #20069](https://github.com/microsoft/fluentui/pull/20069) by beachball)
|
103
|
+
- Bump @fluentui/react-conformance-make-styles to v9.0.0-alpha.20 ([PR #20069](https://github.com/microsoft/fluentui/pull/20069) by beachball)
|
104
|
+
- Bump @fluentui/react-label to v9.0.0-alpha.49 ([PR #20069](https://github.com/microsoft/fluentui/pull/20069) by beachball)
|
105
|
+
- Bump @fluentui/react-provider to v9.0.0-alpha.88 ([PR #20069](https://github.com/microsoft/fluentui/pull/20069) by beachball)
|
106
|
+
- Bump @fluentui/react-theme to v9.0.0-alpha.26 ([PR #20069](https://github.com/microsoft/fluentui/pull/20069) by beachball)
|
107
|
+
|
108
|
+
## [9.0.0-alpha.13](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.0.0-alpha.13)
|
109
|
+
|
110
|
+
Fri, 01 Oct 2021 09:44:56 GMT
|
111
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.0.0-alpha.12..@fluentui/react-switch_v9.0.0-alpha.13)
|
112
|
+
|
113
|
+
### Changes
|
114
|
+
|
115
|
+
- Use new default pseudo element focus outline style ([PR #19990](https://github.com/microsoft/fluentui/pull/19990) by lingfangao@hotmail.com)
|
116
|
+
- Bump @fluentui/react-tabster to v9.0.0-alpha.69 ([PR #19990](https://github.com/microsoft/fluentui/pull/19990) by beachball)
|
117
|
+
- Bump @fluentui/react-provider to v9.0.0-alpha.86 ([PR #19990](https://github.com/microsoft/fluentui/pull/19990) by beachball)
|
118
|
+
|
119
|
+
## [9.0.0-alpha.12](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.0.0-alpha.12)
|
120
|
+
|
121
|
+
Wed, 29 Sep 2021 08:06:11 GMT
|
122
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.0.0-alpha.11..@fluentui/react-switch_v9.0.0-alpha.12)
|
123
|
+
|
124
|
+
### Changes
|
125
|
+
|
126
|
+
- Bump @fluentui/react-make-styles to v9.0.0-alpha.74 ([PR #19660](https://github.com/microsoft/fluentui/pull/19660) by beachball)
|
127
|
+
- Bump @fluentui/react-shared-contexts to v9.0.0-alpha.26 ([PR #19660](https://github.com/microsoft/fluentui/pull/19660) by beachball)
|
128
|
+
- Bump @fluentui/react-tabster to v9.0.0-alpha.68 ([PR #19660](https://github.com/microsoft/fluentui/pull/19660) by beachball)
|
129
|
+
- Bump @fluentui/babel-make-styles to v9.0.0-alpha.56 ([PR #19660](https://github.com/microsoft/fluentui/pull/19660) by beachball)
|
130
|
+
- Bump @fluentui/jest-serializer-make-styles to v9.0.0-alpha.49 ([PR #19660](https://github.com/microsoft/fluentui/pull/19660) by beachball)
|
131
|
+
- Bump @fluentui/react-conformance-make-styles to v9.0.0-alpha.18 ([PR #19660](https://github.com/microsoft/fluentui/pull/19660) by beachball)
|
132
|
+
- Bump @fluentui/react-label to v9.0.0-alpha.47 ([PR #19660](https://github.com/microsoft/fluentui/pull/19660) by beachball)
|
133
|
+
- Bump @fluentui/react-provider to v9.0.0-alpha.85 ([PR #19660](https://github.com/microsoft/fluentui/pull/19660) by beachball)
|
134
|
+
- Bump @fluentui/react-theme to v9.0.0-alpha.24 ([PR #19660](https://github.com/microsoft/fluentui/pull/19660) by beachball)
|
135
|
+
|
136
|
+
## [9.0.0-alpha.11](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.0.0-alpha.11)
|
137
|
+
|
138
|
+
Mon, 27 Sep 2021 08:06:00 GMT
|
139
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.0.0-alpha.10..@fluentui/react-switch_v9.0.0-alpha.11)
|
140
|
+
|
141
|
+
### Changes
|
142
|
+
|
143
|
+
- Bump @fluentui/react-make-styles to v9.0.0-alpha.73 ([PR #19981](https://github.com/microsoft/fluentui/pull/19981) by beachball)
|
144
|
+
- Bump @fluentui/react-tabster to v9.0.0-alpha.67 ([PR #19981](https://github.com/microsoft/fluentui/pull/19981) by beachball)
|
145
|
+
- Bump @fluentui/react-utilities to v9.0.0-alpha.53 ([PR #19981](https://github.com/microsoft/fluentui/pull/19981) by beachball)
|
146
|
+
- Bump @fluentui/babel-make-styles to v9.0.0-alpha.55 ([PR #19981](https://github.com/microsoft/fluentui/pull/19981) by beachball)
|
147
|
+
- Bump @fluentui/jest-serializer-make-styles to v9.0.0-alpha.48 ([PR #19981](https://github.com/microsoft/fluentui/pull/19981) by beachball)
|
148
|
+
- Bump @fluentui/react-conformance-make-styles to v9.0.0-alpha.17 ([PR #19981](https://github.com/microsoft/fluentui/pull/19981) by beachball)
|
149
|
+
- Bump @fluentui/react-label to v9.0.0-alpha.46 ([PR #19981](https://github.com/microsoft/fluentui/pull/19981) by beachball)
|
150
|
+
- Bump @fluentui/react-provider to v9.0.0-alpha.84 ([PR #19981](https://github.com/microsoft/fluentui/pull/19981) by beachball)
|
151
|
+
|
152
|
+
## [9.0.0-alpha.10](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.0.0-alpha.10)
|
153
|
+
|
154
|
+
Fri, 24 Sep 2021 09:17:17 GMT
|
155
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.0.0-alpha.9..@fluentui/react-switch_v9.0.0-alpha.10)
|
156
|
+
|
157
|
+
### Changes
|
158
|
+
|
159
|
+
- Bump @fluentui/react-make-styles to v9.0.0-alpha.72 ([PR #19950](https://github.com/microsoft/fluentui/pull/19950) by beachball)
|
160
|
+
- Bump @fluentui/react-tabster to v9.0.0-alpha.66 ([PR #19950](https://github.com/microsoft/fluentui/pull/19950) by beachball)
|
161
|
+
- Bump @fluentui/react-utilities to v9.0.0-alpha.52 ([PR #19950](https://github.com/microsoft/fluentui/pull/19950) by beachball)
|
162
|
+
- Bump @fluentui/babel-make-styles to v9.0.0-alpha.54 ([PR #19950](https://github.com/microsoft/fluentui/pull/19950) by beachball)
|
163
|
+
- Bump @fluentui/jest-serializer-make-styles to v9.0.0-alpha.47 ([PR #19950](https://github.com/microsoft/fluentui/pull/19950) by beachball)
|
164
|
+
- Bump @fluentui/react-conformance-make-styles to v9.0.0-alpha.16 ([PR #19950](https://github.com/microsoft/fluentui/pull/19950) by beachball)
|
165
|
+
- Bump @fluentui/react-label to v9.0.0-alpha.45 ([PR #19950](https://github.com/microsoft/fluentui/pull/19950) by beachball)
|
166
|
+
- Bump @fluentui/react-provider to v9.0.0-alpha.83 ([PR #19950](https://github.com/microsoft/fluentui/pull/19950) by beachball)
|
167
|
+
|
168
|
+
## [9.0.0-alpha.9](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.0.0-alpha.9)
|
169
|
+
|
170
|
+
Thu, 23 Sep 2021 08:21:34 GMT
|
171
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.0.0-alpha.8..@fluentui/react-switch_v9.0.0-alpha.9)
|
172
|
+
|
173
|
+
### Changes
|
174
|
+
|
175
|
+
- Adding dragging to the Switch component. ([commit](https://github.com/microsoft/fluentui/commit/95682da34c48813f7658032ae490d21d2f363b90) by czearing@outlook.com)
|
176
|
+
- Bump @fluentui/react-make-styles to v9.0.0-alpha.71 ([commit](https://github.com/microsoft/fluentui/commit/95682da34c48813f7658032ae490d21d2f363b90) by beachball)
|
177
|
+
- Bump @fluentui/react-tabster to v9.0.0-alpha.65 ([commit](https://github.com/microsoft/fluentui/commit/95682da34c48813f7658032ae490d21d2f363b90) by beachball)
|
178
|
+
- Bump @fluentui/react-utilities to v9.0.0-alpha.51 ([commit](https://github.com/microsoft/fluentui/commit/95682da34c48813f7658032ae490d21d2f363b90) by beachball)
|
179
|
+
- Bump @fluentui/babel-make-styles to v9.0.0-alpha.53 ([commit](https://github.com/microsoft/fluentui/commit/95682da34c48813f7658032ae490d21d2f363b90) by beachball)
|
180
|
+
- Bump @fluentui/jest-serializer-make-styles to v9.0.0-alpha.46 ([commit](https://github.com/microsoft/fluentui/commit/95682da34c48813f7658032ae490d21d2f363b90) by beachball)
|
181
|
+
- Bump @fluentui/react-conformance-make-styles to v9.0.0-alpha.15 ([commit](https://github.com/microsoft/fluentui/commit/95682da34c48813f7658032ae490d21d2f363b90) by beachball)
|
182
|
+
- Bump @fluentui/react-label to v9.0.0-alpha.44 ([commit](https://github.com/microsoft/fluentui/commit/95682da34c48813f7658032ae490d21d2f363b90) by beachball)
|
183
|
+
- Bump @fluentui/react-provider to v9.0.0-alpha.82 ([commit](https://github.com/microsoft/fluentui/commit/95682da34c48813f7658032ae490d21d2f363b90) by beachball)
|
184
|
+
|
7
185
|
## [9.0.0-alpha.8](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.0.0-alpha.8)
|
8
186
|
|
9
|
-
Wed, 22 Sep 2021 10:
|
187
|
+
Wed, 22 Sep 2021 10:10:07 GMT
|
10
188
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.0.0-alpha.7..@fluentui/react-switch_v9.0.0-alpha.8)
|
11
189
|
|
12
190
|
### Changes
|
package/dist/react-switch.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { ComponentProps } from '@fluentui/react-utilities';
|
2
2
|
import type { ComponentState } from '@fluentui/react-utilities';
|
3
|
+
import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
3
4
|
import type { IntrinsicShorthandProps } from '@fluentui/react-utilities';
|
4
5
|
import * as React_2 from 'react';
|
5
6
|
|
@@ -11,7 +12,7 @@ export declare const renderSwitch: (state: SwitchState) => JSX.Element;
|
|
11
12
|
/**
|
12
13
|
* The Switch control enables users to trigger an option on or off through pressing on the component.
|
13
14
|
*/
|
14
|
-
export declare const Switch:
|
15
|
+
export declare const Switch: ForwardRefComponent<SwitchProps>;
|
15
16
|
|
16
17
|
export declare interface SwitchCommons {
|
17
18
|
/**
|
@@ -35,7 +36,7 @@ export declare interface SwitchCommons {
|
|
35
36
|
/**
|
36
37
|
* Callback to be called when the `checked` value changes.
|
37
38
|
*/
|
38
|
-
onChange?: (ev: React_2.
|
39
|
+
onChange?: (ev: React_2.PointerEvent<HTMLDivElement> | React_2.KeyboardEvent<HTMLDivElement>, data: {
|
39
40
|
checked: boolean;
|
40
41
|
}) => void;
|
41
42
|
}
|
@@ -69,6 +70,10 @@ export declare type SwitchSlots = {
|
|
69
70
|
* The hidden input that handles the Switch's internal functionality.
|
70
71
|
*/
|
71
72
|
input: IntrinsicShorthandProps<'input'>;
|
73
|
+
/**
|
74
|
+
* The area in which the Switch's rail allows for the thumb to be dragged.
|
75
|
+
*/
|
76
|
+
activeRail: IntrinsicShorthandProps<'div'>;
|
72
77
|
};
|
73
78
|
|
74
79
|
export declare interface SwitchState extends ComponentState<SwitchSlots>, SwitchCommons {
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import * as React from 'react';
|
2
1
|
import type { SwitchProps } from './Switch.types';
|
2
|
+
import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
3
3
|
/**
|
4
4
|
* The Switch control enables users to trigger an option on or off through pressing on the component.
|
5
5
|
*/
|
6
|
-
export declare const Switch:
|
6
|
+
export declare const Switch: ForwardRefComponent<SwitchProps>;
|
@@ -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;
|
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,IAAM,MAAM,gBAAqC,KAAK,CAAC,UAAN,CAAiB,UAAC,KAAD,EAAQ,GAAR,EAAW;AAClF,MAAM,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":""}
|
@@ -21,6 +21,10 @@ export declare type SwitchSlots = {
|
|
21
21
|
* The hidden input that handles the Switch's internal functionality.
|
22
22
|
*/
|
23
23
|
input: IntrinsicShorthandProps<'input'>;
|
24
|
+
/**
|
25
|
+
* The area in which the Switch's rail allows for the thumb to be dragged.
|
26
|
+
*/
|
27
|
+
activeRail: IntrinsicShorthandProps<'div'>;
|
24
28
|
};
|
25
29
|
export interface SwitchCommons {
|
26
30
|
/**
|
@@ -44,7 +48,7 @@ export interface SwitchCommons {
|
|
44
48
|
/**
|
45
49
|
* Callback to be called when the `checked` value changes.
|
46
50
|
*/
|
47
|
-
onChange?: (ev: React.
|
51
|
+
onChange?: (ev: React.PointerEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>, data: {
|
48
52
|
checked: boolean;
|
49
53
|
}) => void;
|
50
54
|
}
|
@@ -11,6 +11,6 @@ export var renderSwitch = function (state) {
|
|
11
11
|
slots = _a.slots,
|
12
12
|
slotProps = _a.slotProps;
|
13
13
|
|
14
|
-
return /*#__PURE__*/React.createElement(slots.root, __assign({}, slotProps.root), /*#__PURE__*/React.createElement(slots.track, __assign({}, slotProps.track)), /*#__PURE__*/React.createElement(slots.thumbWrapper, __assign({}, slotProps.thumbWrapper), /*#__PURE__*/React.createElement(slots.thumb, __assign({}, slotProps.thumb))), /*#__PURE__*/React.createElement(slots.input, __assign({}, slotProps.input)));
|
14
|
+
return /*#__PURE__*/React.createElement(slots.root, __assign({}, slotProps.root), /*#__PURE__*/React.createElement(slots.track, __assign({}, slotProps.track)), /*#__PURE__*/React.createElement(slots.thumbWrapper, __assign({}, slotProps.thumbWrapper), /*#__PURE__*/React.createElement(slots.thumb, __assign({}, slotProps.thumb))), /*#__PURE__*/React.createElement(slots.input, __assign({}, slotProps.input)), /*#__PURE__*/React.createElement(slots.activeRail, __assign({}, slotProps.activeRail)));
|
15
15
|
};
|
16
16
|
//# sourceMappingURL=renderSwitch.js.map
|
@@ -1 +1 @@
|
|
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,IAAM,YAAY,GAAG,UAAC,KAAD,EAAmB;AACvC,MAAA,EAAA,GAAuB,QAAQ,CAAc,KAAd,EAAqB,oBAArB,CAA/B;AAAA,MAAE,KAAK,GAAA,EAAA,CAAA,KAAP;AAAA,MAAS,SAAS,GAAA,EAAA,CAAA,SAAlB;;AAEN,sBACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,QAAA,CAAA,EAAA,EAAK,SAAS,CAAC,IAAf,CAAX,eACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,QAAA,CAAA,EAAA,EAAK,SAAS,CAAC,KAAf,CAAZ,CADF,eAEE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,YAAP,EAAmB,QAAA,CAAA,EAAA,EAAK,SAAS,CAAC,YAAf,CAAnB,eACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,QAAA,CAAA,EAAA,EAAK,SAAS,CAAC,KAAf,CAAZ,CADF,CAFF,eAKE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,QAAA,CAAA,EAAA,EAAK,SAAS,CAAC,KAAf,CAAZ,CALF,CADF;
|
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,IAAM,YAAY,GAAG,UAAC,KAAD,EAAmB;AACvC,MAAA,EAAA,GAAuB,QAAQ,CAAc,KAAd,EAAqB,oBAArB,CAA/B;AAAA,MAAE,KAAK,GAAA,EAAA,CAAA,KAAP;AAAA,MAAS,SAAS,GAAA,EAAA,CAAA,SAAlB;;AAEN,sBACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,QAAA,CAAA,EAAA,EAAK,SAAS,CAAC,IAAf,CAAX,eACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,QAAA,CAAA,EAAA,EAAK,SAAS,CAAC,KAAf,CAAZ,CADF,eAEE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,YAAP,EAAmB,QAAA,CAAA,EAAA,EAAK,SAAS,CAAC,YAAf,CAAnB,eACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,QAAA,CAAA,EAAA,EAAK,SAAS,CAAC,KAAf,CAAZ,CADF,CAFF,eAKE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,QAAA,CAAA,EAAA,EAAK,SAAS,CAAC,KAAf,CAAZ,CALF,eAME,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,UAAP,EAAiB,QAAA,CAAA,EAAA,EAAK,SAAS,CAAC,UAAf,CAAjB,CANF,CADF;AAUD,CAbM","sourceRoot":""}
|
@@ -5,7 +5,7 @@ import { useSwitchState } from './useSwitchState';
|
|
5
5
|
* Array of all shorthand properties listed in SwitchSlots
|
6
6
|
*/
|
7
7
|
|
8
|
-
export var switchShorthandProps = ['root', 'track', 'thumbWrapper', 'thumb', 'input'];
|
8
|
+
export var switchShorthandProps = ['root', 'track', 'thumbWrapper', 'thumb', 'activeRail', 'input'];
|
9
9
|
/**
|
10
10
|
* Given user props, returns state and render function for a Switch.
|
11
11
|
*/
|
@@ -14,6 +14,7 @@ export var useSwitch = function (props, ref) {
|
|
14
14
|
var track = props.track,
|
15
15
|
thumbWrapper = props.thumbWrapper,
|
16
16
|
thumb = props.thumb,
|
17
|
+
activeRail = props.activeRail,
|
17
18
|
input = props.input,
|
18
19
|
defaultChecked = props.defaultChecked,
|
19
20
|
checked = props.checked,
|
@@ -34,6 +35,7 @@ export var useSwitch = function (props, ref) {
|
|
34
35
|
track: 'div',
|
35
36
|
thumbWrapper: 'div',
|
36
37
|
thumb: 'div',
|
38
|
+
activeRail: 'div',
|
37
39
|
input: 'input'
|
38
40
|
},
|
39
41
|
track: resolveShorthand(track, {
|
@@ -45,6 +47,9 @@ export var useSwitch = function (props, ref) {
|
|
45
47
|
thumb: resolveShorthand(thumb, {
|
46
48
|
required: true
|
47
49
|
}),
|
50
|
+
activeRail: resolveShorthand(activeRail, {
|
51
|
+
required: true
|
52
|
+
}),
|
48
53
|
input: resolveShorthand(input, {
|
49
54
|
required: true,
|
50
55
|
defaultProps: {
|
@@ -1 +1 @@
|
|
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,IAAM,oBAAoB,GAA0B,
|
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,IAAM,oBAAoB,GAA0B,CACzD,MADyD,EAEzD,OAFyD,EAGzD,cAHyD,EAIzD,OAJyD,EAKzD,YALyD,EAMzD,OANyD,CAApD;AASP;;AAEG;;AACH,OAAO,IAAM,SAAS,GAA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,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":""}
|
@@ -1,6 +1,15 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import { useControllableState, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';
|
3
|
-
import { useFluent } from '@fluentui/react-shared-contexts';
|
2
|
+
import { clamp, useBoolean, useControllableState, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';
|
3
|
+
import { useFluent } from '@fluentui/react-shared-contexts'; // TODO: This should be replaced with a useEvent hook
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
5
|
+
|
6
|
+
var on = function (element, eventName, callback) {
|
7
|
+
element.addEventListener(eventName, callback);
|
8
|
+
return function () {
|
9
|
+
return element.removeEventListener(eventName, callback);
|
10
|
+
};
|
11
|
+
};
|
12
|
+
|
4
13
|
export var useSwitchState = function (state) {
|
5
14
|
var _a = state.defaultChecked,
|
6
15
|
defaultChecked = _a === void 0 ? false : _a,
|
@@ -8,40 +17,136 @@ export var useSwitchState = function (state) {
|
|
8
17
|
_b = state.disabled,
|
9
18
|
disabled = _b === void 0 ? false : _b,
|
10
19
|
onChange = state.onChange;
|
20
|
+
var _c = state.root,
|
21
|
+
onPointerDownCallback = _c.onPointerDown,
|
22
|
+
onKeyUpCallback = _c.onKeyUp;
|
11
23
|
var dir = useFluent().dir;
|
12
24
|
var inputRef = useMergedRefs(state.input.ref);
|
25
|
+
var railRef = React.useRef(null);
|
26
|
+
var internalState = React.useRef({
|
27
|
+
internalValue: checked ? checked : defaultChecked,
|
28
|
+
thumbIsDragging: false,
|
29
|
+
disposables: []
|
30
|
+
});
|
13
31
|
|
14
|
-
var
|
32
|
+
var _d = useControllableState({
|
15
33
|
defaultState: defaultChecked,
|
16
34
|
state: checked,
|
17
35
|
initialState: false
|
18
36
|
}),
|
19
|
-
|
20
|
-
|
37
|
+
currentValue = _d[0],
|
38
|
+
setCurrentValue = _d[1];
|
39
|
+
|
40
|
+
var _e = useBoolean(true),
|
41
|
+
thumbAnimation = _e[0],
|
42
|
+
_f = _e[1],
|
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];
|
21
49
|
|
22
|
-
var setChecked =
|
50
|
+
var setChecked = useEventCallback(function (ev, incomingValue) {
|
51
|
+
ev.stopPropagation();
|
52
|
+
ev.preventDefault();
|
53
|
+
internalState.current.internalValue = incomingValue;
|
23
54
|
onChange === null || onChange === void 0 ? void 0 : onChange(ev, {
|
24
55
|
checked: incomingValue
|
25
56
|
});
|
26
|
-
|
27
|
-
|
28
|
-
var userOnChange = state.input.onChange;
|
29
|
-
var onInputChange = useEventCallback(function (ev) {
|
30
|
-
ev.stopPropagation();
|
31
|
-
userOnChange === null || userOnChange === void 0 ? void 0 : userOnChange(ev);
|
32
|
-
setChecked(ev, ev.currentTarget.checked);
|
57
|
+
setCurrentValue(incomingValue);
|
58
|
+
setRenderedPosition(undefined);
|
33
59
|
});
|
60
|
+
var calculatePosition = React.useCallback(function (ev) {
|
61
|
+
var _a;
|
62
|
+
|
63
|
+
var currentBounds = (_a = railRef === null || railRef === void 0 ? void 0 : railRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
64
|
+
var railWidth = currentBounds.width;
|
65
|
+
var railPosition = dir === 'rtl' ? currentBounds.right : currentBounds.left;
|
66
|
+
var distance = dir === 'rtl' ? railPosition - ev.clientX : ev.clientX - railPosition;
|
67
|
+
return clamp(distance / railWidth * 100, 0, 100);
|
68
|
+
}, [dir]);
|
69
|
+
var onPointerMove = React.useCallback(function (ev) {
|
70
|
+
var incomingPosition = calculatePosition(ev);
|
71
|
+
internalState.current.thumbIsDragging = true;
|
72
|
+
hideThumbAnimation();
|
73
|
+
setRenderedPosition(incomingPosition); // If the Switch reaches a new position of 0% or 100%, update the state and fire change.
|
74
|
+
|
75
|
+
if (incomingPosition === 100 && internalState.current.internalValue !== true) {
|
76
|
+
setChecked(ev, true);
|
77
|
+
} else if (incomingPosition === 0 && internalState.current.internalValue !== false) {
|
78
|
+
setChecked(ev, false);
|
79
|
+
}
|
80
|
+
}, [calculatePosition, hideThumbAnimation, setChecked]);
|
81
|
+
var onPointerUp = React.useCallback(function (ev) {
|
82
|
+
internalState.current.disposables.forEach(function (dispose) {
|
83
|
+
return dispose();
|
84
|
+
});
|
85
|
+
internalState.current.disposables = [];
|
86
|
+
inputRef.current.focus();
|
87
|
+
|
88
|
+
if (internalState.current.thumbIsDragging) {
|
89
|
+
var roundedPosition = Math.round(calculatePosition(ev) / 100) * 100;
|
90
|
+
showThumbAnimation();
|
91
|
+
|
92
|
+
if (roundedPosition === 100) {
|
93
|
+
setChecked(ev, true);
|
94
|
+
} else if (roundedPosition === 0) {
|
95
|
+
setChecked(ev, false);
|
96
|
+
}
|
97
|
+
} else {
|
98
|
+
setChecked(ev, !internalState.current.internalValue);
|
99
|
+
}
|
100
|
+
}, [calculatePosition, inputRef, setChecked, showThumbAnimation]);
|
101
|
+
var onPointerDown = React.useCallback(function (ev) {
|
102
|
+
var _a;
|
103
|
+
|
104
|
+
var pointerId = ev.pointerId;
|
105
|
+
var target = ev.target;
|
106
|
+
onPointerDownCallback === null || onPointerDownCallback === void 0 ? void 0 : onPointerDownCallback(ev);
|
107
|
+
showThumbAnimation();
|
108
|
+
(_a = target.setPointerCapture) === null || _a === void 0 ? void 0 : _a.call(target, pointerId);
|
109
|
+
internalState.current.thumbIsDragging = false;
|
110
|
+
internalState.current.disposables.push(on(target, 'pointermove', onPointerMove), on(target, 'pointerup', onPointerUp), function () {
|
111
|
+
var _a;
|
112
|
+
|
113
|
+
(_a = target.releasePointerCapture) === null || _a === void 0 ? void 0 : _a.call(target, pointerId);
|
114
|
+
});
|
115
|
+
}, [onPointerDownCallback, onPointerMove, onPointerUp, showThumbAnimation]);
|
116
|
+
var onKeyUp = React.useCallback(function (ev) {
|
117
|
+
onKeyUpCallback === null || onKeyUpCallback === void 0 ? void 0 : onKeyUpCallback(ev);
|
118
|
+
|
119
|
+
if (ev.key === ' ') {
|
120
|
+
setChecked(ev, !internalState.current.internalValue);
|
121
|
+
}
|
122
|
+
}, [onKeyUpCallback, setChecked]);
|
123
|
+
var currentPosition = renderedPosition !== undefined ? renderedPosition : currentValue ? 100 : 0;
|
124
|
+
var rootStyles = {
|
125
|
+
'--switch-checked-opacity': currentPosition / 100,
|
126
|
+
'--switch-unchecked-opacity': (100 - currentPosition) / 100
|
127
|
+
};
|
34
128
|
var thumbWrapperStyles = {
|
35
|
-
transform: dir === 'rtl' ?
|
36
|
-
|
129
|
+
transform: "translate(" + (dir === 'rtl' ? -currentPosition : currentPosition) + "%)",
|
130
|
+
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
|
+
}; // Root Props
|
132
|
+
|
133
|
+
state.root.style = rootStyles;
|
134
|
+
|
135
|
+
if (!disabled) {
|
136
|
+
state.root.onPointerDown = onPointerDown;
|
137
|
+
state.root.onKeyUp = onKeyUp;
|
138
|
+
} // Input Props
|
37
139
|
|
38
|
-
|
39
|
-
state.input.checked =
|
140
|
+
|
141
|
+
state.input.checked = currentValue;
|
40
142
|
state.input.disabled = disabled;
|
41
143
|
state.input.ref = inputRef;
|
42
|
-
state.input.
|
144
|
+
state.input.readOnly = true;
|
145
|
+
state.input.role = 'switch'; // Thumb Container Props
|
146
|
+
|
147
|
+
state.thumbWrapper.style = thumbWrapperStyles; // Active Rail Props
|
43
148
|
|
44
|
-
state.
|
149
|
+
state.activeRail.ref = railRef;
|
45
150
|
return state;
|
46
151
|
};
|
47
152
|
//# sourceMappingURL=useSwitchState.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Switch/useSwitchState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,
|
1
|
+
{"version":3,"sources":["../../../src/components/Switch/useSwitchState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,KAAT,EAAgB,UAAhB,EAA4B,oBAA5B,EAAkD,gBAAlD,EAAoE,aAApE,QAAyF,2BAAzF;AACA,SAAS,SAAT,QAA0B,iCAA1B,C,CAoBA;AACA;;AACA,IAAM,EAAE,GAAG,UAAC,OAAD,EAAmB,SAAnB,EAAsC,QAAtC,EAAiE;AAC1E,EAAA,OAAO,CAAC,gBAAR,CAAyB,SAAzB,EAAoC,QAApC;AACA,SAAO,YAAA;AAAM,WAAA,OAAO,CAAC,mBAAR,CAA4B,SAA5B,EAAA,QAAA,CAAA;AAAgD,GAA7D;AACD,CAHD;;AAKA,OAAO,IAAM,cAAc,GAAG,UAAC,KAAD,EAAmB;AACvC,MAAA,EAAA,GAAgE,KAAK,CAA/C,cAAtB;AAAA,MAAA,cAAc,GAAA,EAAA,KAAA,KAAA,CAAA,GAAG,KAAH,GAAQ,EAAtB;AAAA,MAAwB,OAAO,GAAiC,KAAK,CAAtC,OAA/B;AAAA,MAAiC,EAAA,GAA+B,KAAK,CAApB,QAAjD;AAAA,MAAiC,QAAQ,GAAA,EAAA,KAAA,KAAA,CAAA,GAA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