@fluentui/react-switch 9.1.3 → 9.1.5
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
@@ -1,211 +0,0 @@
|
|
1
|
-
define(["require", "exports", "tslib", "@fluentui/react-tabster", "@fluentui/react-theme", "@griffel/react"], function (require, exports, tslib_1, react_tabster_1, react_theme_1, react_1) {
|
2
|
-
"use strict";
|
3
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
5
|
-
exports.useSwitchStyles_unstable = exports.switchClassName = exports.switchClassNames = void 0;
|
6
|
-
exports.switchClassNames = {
|
7
|
-
root: 'fui-Switch',
|
8
|
-
indicator: 'fui-Switch__indicator',
|
9
|
-
input: 'fui-Switch__input',
|
10
|
-
label: 'fui-Switch__label',
|
11
|
-
};
|
12
|
-
/**
|
13
|
-
* @deprecated Use `switchClassNames.root` instead.
|
14
|
-
*/
|
15
|
-
exports.switchClassName = exports.switchClassNames.root;
|
16
|
-
// Thumb and track sizes used by the component.
|
17
|
-
var spaceBetweenThumbAndTrack = 2;
|
18
|
-
var trackHeight = 20;
|
19
|
-
var trackWidth = 40;
|
20
|
-
var thumbSize = trackHeight - spaceBetweenThumbAndTrack;
|
21
|
-
var useRootBaseClassName = react_1.makeResetStyles(tslib_1.__assign({ alignItems: 'flex-start', boxSizing: 'border-box', display: 'inline-flex', position: 'relative' }, react_tabster_1.createFocusOutlineStyle({ style: {}, selector: 'focus-within' })));
|
22
|
-
var useRootStyles = react_1.makeStyles({
|
23
|
-
vertical: {
|
24
|
-
flexDirection: 'column',
|
25
|
-
},
|
26
|
-
});
|
27
|
-
var useIndicatorBaseClassName = react_1.makeResetStyles({
|
28
|
-
borderRadius: react_theme_1.tokens.borderRadiusCircular,
|
29
|
-
border: '1px solid',
|
30
|
-
lineHeight: 0,
|
31
|
-
boxSizing: 'border-box',
|
32
|
-
fill: 'currentColor',
|
33
|
-
flexShrink: 0,
|
34
|
-
fontSize: thumbSize + "px",
|
35
|
-
height: trackHeight + "px",
|
36
|
-
margin: react_theme_1.tokens.spacingVerticalS + ' ' + react_theme_1.tokens.spacingHorizontalS,
|
37
|
-
pointerEvents: 'none',
|
38
|
-
transitionDuration: react_theme_1.tokens.durationNormal,
|
39
|
-
transitionTimingFunction: react_theme_1.tokens.curveEasyEase,
|
40
|
-
transitionProperty: 'background, border, color',
|
41
|
-
width: trackWidth + "px",
|
42
|
-
'@media screen and (prefers-reduced-motion: reduce)': {
|
43
|
-
transitionDuration: '0.01ms',
|
44
|
-
},
|
45
|
-
'> *': {
|
46
|
-
transitionDuration: react_theme_1.tokens.durationNormal,
|
47
|
-
transitionTimingFunction: react_theme_1.tokens.curveEasyEase,
|
48
|
-
transitionProperty: 'transform',
|
49
|
-
'@media screen and (prefers-reduced-motion: reduce)': {
|
50
|
-
transitionDuration: '0.01ms',
|
51
|
-
},
|
52
|
-
},
|
53
|
-
});
|
54
|
-
var useIndicatorStyles = react_1.makeStyles({
|
55
|
-
labelAbove: {
|
56
|
-
marginTop: 0,
|
57
|
-
},
|
58
|
-
});
|
59
|
-
var useInputBaseClassName = react_1.makeResetStyles({
|
60
|
-
boxSizing: 'border-box',
|
61
|
-
cursor: 'pointer',
|
62
|
-
height: '100%',
|
63
|
-
margin: 0,
|
64
|
-
opacity: 0,
|
65
|
-
position: 'absolute',
|
66
|
-
// Calculate the width of the hidden input by taking into account the size of the indicator + the padding around it.
|
67
|
-
// This is done so that clicking on that "empty space" still toggles the switch.
|
68
|
-
width: "calc(" + trackWidth + "px + 2 * " + react_theme_1.tokens.spacingHorizontalS + ")",
|
69
|
-
// Checked (both enabled and disabled)
|
70
|
-
':checked': (_a = {},
|
71
|
-
_a["& ~ ." + exports.switchClassNames.indicator] = {
|
72
|
-
'> *': {
|
73
|
-
transform: "translateX(" + (trackWidth - thumbSize - spaceBetweenThumbAndTrack) + "px)",
|
74
|
-
},
|
75
|
-
},
|
76
|
-
_a),
|
77
|
-
// Disabled (both checked and unchecked)
|
78
|
-
':disabled': (_b = {
|
79
|
-
cursor: 'default'
|
80
|
-
},
|
81
|
-
_b["& ~ ." + exports.switchClassNames.indicator] = {
|
82
|
-
color: react_theme_1.tokens.colorNeutralForegroundDisabled,
|
83
|
-
},
|
84
|
-
_b["& ~ ." + exports.switchClassNames.label] = {
|
85
|
-
cursor: 'default',
|
86
|
-
color: react_theme_1.tokens.colorNeutralForegroundDisabled,
|
87
|
-
},
|
88
|
-
_b),
|
89
|
-
// Enabled and unchecked
|
90
|
-
':enabled:not(:checked)': (_c = {},
|
91
|
-
_c["& ~ ." + exports.switchClassNames.indicator] = {
|
92
|
-
color: react_theme_1.tokens.colorNeutralStrokeAccessible,
|
93
|
-
borderColor: react_theme_1.tokens.colorNeutralStrokeAccessible,
|
94
|
-
},
|
95
|
-
_c["& ~ ." + exports.switchClassNames.label] = {
|
96
|
-
color: react_theme_1.tokens.colorNeutralForeground1,
|
97
|
-
},
|
98
|
-
_c[':hover'] = (_d = {},
|
99
|
-
_d["& ~ ." + exports.switchClassNames.indicator] = {
|
100
|
-
color: react_theme_1.tokens.colorNeutralStrokeAccessibleHover,
|
101
|
-
borderColor: react_theme_1.tokens.colorNeutralStrokeAccessibleHover,
|
102
|
-
},
|
103
|
-
_d),
|
104
|
-
_c[':hover:active'] = (_e = {},
|
105
|
-
_e["& ~ ." + exports.switchClassNames.indicator] = {
|
106
|
-
color: react_theme_1.tokens.colorNeutralStrokeAccessiblePressed,
|
107
|
-
borderColor: react_theme_1.tokens.colorNeutralStrokeAccessiblePressed,
|
108
|
-
},
|
109
|
-
_e),
|
110
|
-
_c),
|
111
|
-
// Enabled and checked
|
112
|
-
':enabled:checked': (_f = {},
|
113
|
-
_f["& ~ ." + exports.switchClassNames.indicator] = {
|
114
|
-
backgroundColor: react_theme_1.tokens.colorCompoundBrandBackground,
|
115
|
-
color: react_theme_1.tokens.colorNeutralForegroundInverted,
|
116
|
-
borderColor: react_theme_1.tokens.colorTransparentStroke,
|
117
|
-
},
|
118
|
-
_f[':hover'] = (_g = {},
|
119
|
-
_g["& ~ ." + exports.switchClassNames.indicator] = {
|
120
|
-
backgroundColor: react_theme_1.tokens.colorCompoundBrandBackgroundHover,
|
121
|
-
borderColor: react_theme_1.tokens.colorTransparentStrokeInteractive,
|
122
|
-
},
|
123
|
-
_g),
|
124
|
-
_f[':hover:active'] = (_h = {},
|
125
|
-
_h["& ~ ." + exports.switchClassNames.indicator] = {
|
126
|
-
backgroundColor: react_theme_1.tokens.colorCompoundBrandBackgroundPressed,
|
127
|
-
borderColor: react_theme_1.tokens.colorTransparentStrokeInteractive,
|
128
|
-
},
|
129
|
-
_h),
|
130
|
-
_f),
|
131
|
-
// Disabled and unchecked
|
132
|
-
':disabled:not(:checked)': (_j = {},
|
133
|
-
_j["& ~ ." + exports.switchClassNames.indicator] = {
|
134
|
-
borderColor: react_theme_1.tokens.colorNeutralStrokeDisabled,
|
135
|
-
},
|
136
|
-
_j),
|
137
|
-
// Disabled and checked
|
138
|
-
':disabled:checked': (_k = {},
|
139
|
-
_k["& ~ ." + exports.switchClassNames.indicator] = {
|
140
|
-
backgroundColor: react_theme_1.tokens.colorNeutralBackgroundDisabled,
|
141
|
-
borderColor: react_theme_1.tokens.colorTransparentStrokeDisabled,
|
142
|
-
},
|
143
|
-
_k),
|
144
|
-
'@media (forced-colors: active)': {
|
145
|
-
':disabled': (_l = {},
|
146
|
-
_l["& ~ ." + exports.switchClassNames.indicator] = {
|
147
|
-
color: 'GrayText',
|
148
|
-
borderColor: 'GrayText',
|
149
|
-
},
|
150
|
-
_l["& ~ ." + exports.switchClassNames.label] = {
|
151
|
-
color: 'GrayText',
|
152
|
-
},
|
153
|
-
_l),
|
154
|
-
},
|
155
|
-
});
|
156
|
-
var useInputStyles = react_1.makeStyles({
|
157
|
-
before: {
|
158
|
-
right: 0,
|
159
|
-
top: 0,
|
160
|
-
},
|
161
|
-
after: {
|
162
|
-
left: 0,
|
163
|
-
top: 0,
|
164
|
-
},
|
165
|
-
above: {
|
166
|
-
bottom: 0,
|
167
|
-
height: "calc(" + trackHeight + "px + " + react_theme_1.tokens.spacingVerticalS + ")",
|
168
|
-
width: '100%',
|
169
|
-
},
|
170
|
-
});
|
171
|
-
// Can't use makeResetStyles here because Label is a component that may itself use makeResetStyles.
|
172
|
-
var useLabelStyles = react_1.makeStyles({
|
173
|
-
base: tslib_1.__assign({ cursor: 'pointer',
|
174
|
-
// Use a (negative) margin to account for the difference between the track's height and the label's line height.
|
175
|
-
// This prevents the label from expanding the height of the switch, but preserves line height if the label wraps.
|
176
|
-
marginBottom: "calc((" + trackHeight + "px - " + react_theme_1.tokens.lineHeightBase300 + ") / 2)", marginTop: "calc((" + trackHeight + "px - " + react_theme_1.tokens.lineHeightBase300 + ") / 2)" }, react_1.shorthands.padding(react_theme_1.tokens.spacingVerticalS, react_theme_1.tokens.spacingHorizontalS)),
|
177
|
-
above: {
|
178
|
-
paddingTop: react_theme_1.tokens.spacingVerticalXS,
|
179
|
-
paddingBottom: react_theme_1.tokens.spacingVerticalXS,
|
180
|
-
width: '100%',
|
181
|
-
},
|
182
|
-
after: {
|
183
|
-
paddingLeft: react_theme_1.tokens.spacingHorizontalXS,
|
184
|
-
},
|
185
|
-
before: {
|
186
|
-
paddingRight: react_theme_1.tokens.spacingHorizontalXS,
|
187
|
-
},
|
188
|
-
});
|
189
|
-
/**
|
190
|
-
* Apply styling to the Switch slots based on the state
|
191
|
-
*/
|
192
|
-
var useSwitchStyles_unstable = function (state) {
|
193
|
-
var rootBaseClassName = useRootBaseClassName();
|
194
|
-
var rootStyles = useRootStyles();
|
195
|
-
var indicatorBaseClassName = useIndicatorBaseClassName();
|
196
|
-
var indicatorStyles = useIndicatorStyles();
|
197
|
-
var inputBaseClassName = useInputBaseClassName();
|
198
|
-
var inputStyles = useInputStyles();
|
199
|
-
var labelStyles = useLabelStyles();
|
200
|
-
var label = state.label, labelPosition = state.labelPosition;
|
201
|
-
state.root.className = react_1.mergeClasses(exports.switchClassNames.root, rootBaseClassName, labelPosition === 'above' && rootStyles.vertical, state.root.className);
|
202
|
-
state.indicator.className = react_1.mergeClasses(exports.switchClassNames.indicator, indicatorBaseClassName, label && labelPosition === 'above' && indicatorStyles.labelAbove, state.indicator.className);
|
203
|
-
state.input.className = react_1.mergeClasses(exports.switchClassNames.input, inputBaseClassName, label && inputStyles[labelPosition], state.input.className);
|
204
|
-
if (state.label) {
|
205
|
-
state.label.className = react_1.mergeClasses(exports.switchClassNames.label, labelStyles.base, labelStyles[labelPosition], state.label.className);
|
206
|
-
}
|
207
|
-
return state;
|
208
|
-
};
|
209
|
-
exports.useSwitchStyles_unstable = useSwitchStyles_unstable;
|
210
|
-
});
|
211
|
-
//# sourceMappingURL=useSwitchStyles.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useSwitchStyles.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-switch/src/components/Switch/useSwitchStyles.ts"],"names":[],"mappings":";;;;;IAMa,QAAA,gBAAgB,GAAgC;QAC3D,IAAI,EAAE,YAAY;QAClB,SAAS,EAAE,uBAAuB;QAClC,KAAK,EAAE,mBAAmB;QAC1B,KAAK,EAAE,mBAAmB;KAC3B,CAAC;IAEF;;OAEG;IACU,QAAA,eAAe,GAAG,wBAAgB,CAAC,IAAI,CAAC;IAErD,+CAA+C;IAC/C,IAAM,yBAAyB,GAAG,CAAC,CAAC;IACpC,IAAM,WAAW,GAAG,EAAE,CAAC;IACvB,IAAM,UAAU,GAAG,EAAE,CAAC;IACtB,IAAM,SAAS,GAAG,WAAW,GAAG,yBAAyB,CAAC;IAE1D,IAAM,oBAAoB,GAAG,uBAAe,oBAC1C,UAAU,EAAE,YAAY,EACxB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,UAAU,IAEjB,uCAAuB,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC,EACnE,CAAC;IAEH,IAAM,aAAa,GAAG,kBAAU,CAAC;QAC/B,QAAQ,EAAE;YACR,aAAa,EAAE,QAAQ;SACxB;KACF,CAAC,CAAC;IAEH,IAAM,yBAAyB,GAAG,uBAAe,CAAC;QAChD,YAAY,EAAE,oBAAM,CAAC,oBAAoB;QACzC,MAAM,EAAE,WAAW;QACnB,UAAU,EAAE,CAAC;QACb,SAAS,EAAE,YAAY;QACvB,IAAI,EAAE,cAAc;QACpB,UAAU,EAAE,CAAC;QACb,QAAQ,EAAK,SAAS,OAAI;QAC1B,MAAM,EAAK,WAAW,OAAI;QAC1B,MAAM,EAAE,oBAAM,CAAC,gBAAgB,GAAG,GAAG,GAAG,o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C,KAAK,EACtB,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC,aAAa,CAAC,EAC1B,KAAK,CAAC,KAAK,CAAC,SAAS,CACtB,CAAC;SACH;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IA1CW,QAAA,wBAAwB,4BA0CnC","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"]}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
define(["require", "exports", "@fluentui/react-field", "../../Switch"], function (require, exports, react_field_1, Switch_1) {
|
2
|
-
"use strict";
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.SwitchField = exports.switchFieldClassNames = void 0;
|
5
|
-
/** @deprecated Use Field with Switch: `<Field><Switch /></Field>` */
|
6
|
-
exports.switchFieldClassNames = react_field_1.getDeprecatedFieldClassNames(Switch_1.switchClassNames.root);
|
7
|
-
/** @deprecated Use Field with Switch: `<Field><Switch /></Field>` */
|
8
|
-
exports.SwitchField = react_field_1.makeDeprecatedField(Switch_1.Switch);
|
9
|
-
});
|
10
|
-
//# sourceMappingURL=SwitchField.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"SwitchField.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-switch/src/components/SwitchField/SwitchField.tsx"],"names":[],"mappings":";;;;IAOA,qEAAqE;IACxD,QAAA,qBAAqB,GAAG,0CAA4B,CAAC,yBAAgB,CAAC,IAAI,CAAC,CAAC;IACzF,qEAAqE;IACxD,QAAA,WAAW,GAA0C,iCAAmB,CAAC,eAAM,CAAC,CAAC","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"]}
|
@@ -1,6 +0,0 @@
|
|
1
|
-
define(["require", "exports", "tslib", "./SwitchField"], function (require, exports, tslib_1, SwitchField_1) {
|
2
|
-
"use strict";
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
tslib_1.__exportStar(SwitchField_1, exports);
|
5
|
-
});
|
6
|
-
//# sourceMappingURL=index.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-switch/src/components/SwitchField/index.ts"],"names":[],"mappings":";;;IAAA,6CAA8B","sourcesContent":["export * from './SwitchField';\n"]}
|
package/lib-amd/index.js
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
define(["require", "exports", "./Switch", "./SwitchField"], function (require, exports, Switch_1, SwitchField_1) {
|
2
|
-
"use strict";
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.switchFieldClassNames = exports.SwitchField_unstable = exports.useSwitch_unstable = exports.useSwitchStyles_unstable = exports.switchClassNames = exports.switchClassName = exports.renderSwitch_unstable = exports.Switch = void 0;
|
5
|
-
Object.defineProperty(exports, "Switch", { enumerable: true, get: function () { return Switch_1.Switch; } });
|
6
|
-
Object.defineProperty(exports, "renderSwitch_unstable", { enumerable: true, get: function () { return Switch_1.renderSwitch_unstable; } });
|
7
|
-
// eslint-disable-next-line deprecation/deprecation
|
8
|
-
Object.defineProperty(exports, "switchClassName", { enumerable: true, get: function () { return Switch_1.switchClassName; } });
|
9
|
-
Object.defineProperty(exports, "switchClassNames", { enumerable: true, get: function () { return Switch_1.switchClassNames; } });
|
10
|
-
Object.defineProperty(exports, "useSwitchStyles_unstable", { enumerable: true, get: function () { return Switch_1.useSwitchStyles_unstable; } });
|
11
|
-
Object.defineProperty(exports, "useSwitch_unstable", { enumerable: true, get: function () { return Switch_1.useSwitch_unstable; } });
|
12
|
-
Object.defineProperty(exports, "SwitchField_unstable", { enumerable: true, get: function () { return SwitchField_1.SwitchField; } });
|
13
|
-
Object.defineProperty(exports, "switchFieldClassNames", { enumerable: true, get: function () { return SwitchField_1.switchFieldClassNames; } });
|
14
|
-
});
|
15
|
-
//# sourceMappingURL=index.js.map
|
package/lib-amd/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-switch/src/index.ts"],"names":[],"mappings":";;;;IACE,gGAAA,MAAM,OAAA;IACN,+GAAA,qBAAqB,OAAA;IACrB,mDAAmD;IACnD,yGAAA,eAAe,OAAA;IACf,0GAAA,gBAAgB,OAAA;IAChB,kHAAA,wBAAwB,OAAA;IACxB,4GAAA,kBAAkB,OAAA;IAKX,mHAAA,WAAW,OAAwB;IAAE,oHAAA,qBAAqB,OAAA","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"]}
|