@fluentui/react-switch 0.0.0-nightly-20220302-0405.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.
Files changed (57) hide show
  1. package/CHANGELOG.json +1477 -0
  2. package/CHANGELOG.md +442 -0
  3. package/LICENSE +15 -0
  4. package/MIGRATION.md +28 -0
  5. package/README.md +32 -0
  6. package/Spec.md +134 -0
  7. package/dist/react-switch.d.ts +106 -0
  8. package/lib/Switch.d.ts +1 -0
  9. package/lib/Switch.js +2 -0
  10. package/lib/Switch.js.map +1 -0
  11. package/lib/components/Switch/Switch.d.ts +6 -0
  12. package/lib/components/Switch/Switch.js +15 -0
  13. package/lib/components/Switch/Switch.js.map +1 -0
  14. package/lib/components/Switch/Switch.types.d.ts +65 -0
  15. package/lib/components/Switch/Switch.types.js +2 -0
  16. package/lib/components/Switch/Switch.types.js.map +1 -0
  17. package/lib/components/Switch/index.d.ts +5 -0
  18. package/lib/components/Switch/index.js +6 -0
  19. package/lib/components/Switch/index.js.map +1 -0
  20. package/lib/components/Switch/renderSwitch.d.ts +5 -0
  21. package/lib/components/Switch/renderSwitch.js +22 -0
  22. package/lib/components/Switch/renderSwitch.js.map +1 -0
  23. package/lib/components/Switch/useSwitch.d.ts +12 -0
  24. package/lib/components/Switch/useSwitch.js +79 -0
  25. package/lib/components/Switch/useSwitch.js.map +1 -0
  26. package/lib/components/Switch/useSwitchStyles.d.ts +9 -0
  27. package/lib/components/Switch/useSwitchStyles.js +194 -0
  28. package/lib/components/Switch/useSwitchStyles.js.map +1 -0
  29. package/lib/index.d.ts +2 -0
  30. package/lib/index.js +2 -0
  31. package/lib/index.js.map +1 -0
  32. package/lib/tsdoc-metadata.json +11 -0
  33. package/lib-commonjs/Switch.d.ts +1 -0
  34. package/lib-commonjs/Switch.js +10 -0
  35. package/lib-commonjs/Switch.js.map +1 -0
  36. package/lib-commonjs/components/Switch/Switch.d.ts +6 -0
  37. package/lib-commonjs/components/Switch/Switch.js +26 -0
  38. package/lib-commonjs/components/Switch/Switch.js.map +1 -0
  39. package/lib-commonjs/components/Switch/Switch.types.d.ts +65 -0
  40. package/lib-commonjs/components/Switch/Switch.types.js +6 -0
  41. package/lib-commonjs/components/Switch/Switch.types.js.map +1 -0
  42. package/lib-commonjs/components/Switch/index.d.ts +5 -0
  43. package/lib-commonjs/components/Switch/index.js +18 -0
  44. package/lib-commonjs/components/Switch/index.js.map +1 -0
  45. package/lib-commonjs/components/Switch/renderSwitch.d.ts +5 -0
  46. package/lib-commonjs/components/Switch/renderSwitch.js +33 -0
  47. package/lib-commonjs/components/Switch/renderSwitch.js.map +1 -0
  48. package/lib-commonjs/components/Switch/useSwitch.d.ts +12 -0
  49. package/lib-commonjs/components/Switch/useSwitch.js +92 -0
  50. package/lib-commonjs/components/Switch/useSwitch.js.map +1 -0
  51. package/lib-commonjs/components/Switch/useSwitchStyles.d.ts +9 -0
  52. package/lib-commonjs/components/Switch/useSwitchStyles.js +206 -0
  53. package/lib-commonjs/components/Switch/useSwitchStyles.js.map +1 -0
  54. package/lib-commonjs/index.d.ts +2 -0
  55. package/lib-commonjs/index.js +10 -0
  56. package/lib-commonjs/index.js.map +1 -0
  57. package/package.json +66 -0
@@ -0,0 +1,194 @@
1
+ import { createFocusOutlineStyle } from '@fluentui/react-tabster';
2
+ import { tokens } from '@fluentui/react-theme';
3
+ import { __styles, mergeClasses, shorthands } from '@griffel/react';
4
+ export const switchClassNames = {
5
+ root: 'fui-Switch',
6
+ indicator: 'fui-Switch__indicator',
7
+ input: 'fui-Switch__input',
8
+ label: 'fui-Switch__label'
9
+ }; // TODO temporary export to pass conformance test.
10
+
11
+ export const switchClassName = switchClassNames.root; // TODO replace these spacing constants with theme values once they're on the theme.
12
+
13
+ const spacingXS = 4;
14
+ const spacingS = 8;
15
+ const spacingM = 12; // Thumb and track sizes used by the component.
16
+
17
+ const spaceBetweenThumbAndTrack = 2;
18
+ const thumbSize = 14;
19
+ const trackHeight = 20;
20
+ const trackWidth = 40;
21
+
22
+ const useRootStyles = /*#__PURE__*/__styles({
23
+ "base": {
24
+ "B7ck84d": "f1ewtqcl",
25
+ "i8kkvl": "f4akndk",
26
+ "mc9l5x": "ftuwxu6",
27
+ "z8tnut": "fp9bwmr",
28
+ "z189sj": ["f19lj068", "f177v4lu"],
29
+ "Byoj8tv": "f150uoa4",
30
+ "uwmqm3": ["f177v4lu", "f19lj068"],
31
+ "qhf8xq": "f10pi13n",
32
+ "B486eqv": "f2hkw1w",
33
+ "c2y4jd": "fsofd9k",
34
+ "B8vm7ur": "f12sql3b",
35
+ "f4hv8x": "f1i4q40k",
36
+ "Gpan81": "fcrbge9",
37
+ "z7afg": "ft464mn",
38
+ "rsjj6t": "fskqmiq",
39
+ "Bqsd8kq": "f2gy8jn",
40
+ "sfhsbh": "f1pke3uf",
41
+ "Bugh3ej": "f18xdlq9",
42
+ "hpanx6": "f1114nks",
43
+ "Bjkpy09": "f1unftzx",
44
+ "Jxg1p8": "f8rjbh6",
45
+ "Bc94xmo": ["fxfgh6q", "f8l10fm"],
46
+ "Bj23z95": ["f8l10fm", "fxfgh6q"]
47
+ },
48
+ "above": {
49
+ "Beiy3e4": "f1vx9l62",
50
+ "z8tnut": "f10ra9hq",
51
+ "Belr9w4": "f1ma2n7n"
52
+ },
53
+ "after": {
54
+ "Bt984gj": "f6jr5hl",
55
+ "i8kkvl": "f4akndk",
56
+ "Beiy3e4": "f1063pyq"
57
+ },
58
+ "before": {
59
+ "Bt984gj": "f6jr5hl",
60
+ "i8kkvl": "f4akndk",
61
+ "Beiy3e4": "f1063pyq"
62
+ }
63
+ }, {
64
+ "d": [".f1ewtqcl{box-sizing:border-box;}", ".f4akndk{-webkit-column-gap:12px;column-gap:12px;}", ".ftuwxu6{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;}", ".fp9bwmr{padding-top:8px;}", ".f19lj068{padding-right:8px;}", ".f177v4lu{padding-left:8px;}", ".f150uoa4{padding-bottom:8px;}", ".f10pi13n{position:relative;}", "[data-keyboard-nav] .fsofd9k:focus-within{border-color:transparent;}", "[data-keyboard-nav] .f12sql3b:focus-within:after{content:\"\";}", "[data-keyboard-nav] .f1i4q40k:focus-within:after{position:absolute;}", "[data-keyboard-nav] .fcrbge9:focus-within:after{pointer-events:none;}", "[data-keyboard-nav] .ft464mn:focus-within:after{box-sizing:outline-box;}", "[data-keyboard-nav] .fskqmiq:focus-within:after{z-index:1;}", "[data-keyboard-nav] .f2gy8jn:focus-within:after{border-style:solid;}", "[data-keyboard-nav] .f1pke3uf:focus-within:after{border-width:2px;}", "[data-keyboard-nav] .f18xdlq9:focus-within:after{border-radius:var(--borderRadiusMedium);}", "[data-keyboard-nav] .f1114nks:focus-within:after{border-color:var(--colorStrokeFocus2);}", "[data-keyboard-nav] .f1unftzx:focus-within:after{top:-2px;}", "[data-keyboard-nav] .f8rjbh6:focus-within:after{bottom:-2px;}", "[data-keyboard-nav] .fxfgh6q:focus-within:after{left:-2px;}", "[data-keyboard-nav] .f8l10fm:focus-within:after{right:-2px;}", ".f1vx9l62{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}", ".f10ra9hq{padding-top:4px;}", ".f1ma2n7n{row-gap:4px;}", ".f6jr5hl{-webkit-align-items:flex-start;-webkit-box-align:flex-start;-ms-flex-align:flex-start;align-items:flex-start;}", ".f1063pyq{-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;}"],
65
+ "i": [".f2hkw1w:focus-visible{outline-style:none;}"]
66
+ });
67
+
68
+ const useIndicatorStyles = /*#__PURE__*/__styles({
69
+ "base": {
70
+ "Bbmb7ep": ["f8fbkgy", "f1nfllo7"],
71
+ "Beyfa6y": ["f1nfllo7", "f8fbkgy"],
72
+ "B7oj6ja": ["f1djnp8u", "f1s8kh49"],
73
+ "Btl43ni": ["f1s8kh49", "f1djnp8u"],
74
+ "icvyot": "fzkkow9",
75
+ "vrafjx": ["fcdblym", "fjik90z"],
76
+ "oivjwe": "fg706s2",
77
+ "wvpqe5": ["fjik90z", "fcdblym"],
78
+ "B4j52fo": "f5ogflp",
79
+ "Bekrc4i": ["f1hqa2wf", "finvdd3"],
80
+ "Bn0qgzm": "f1f09k3d",
81
+ "ibv6hh": ["finvdd3", "f1hqa2wf"],
82
+ "B7ck84d": "f1ewtqcl",
83
+ "Bkfmm31": "f1w9h62z",
84
+ "Bnnss6s": "fi64zpg",
85
+ "Be2twd7": "f4ybsrx",
86
+ "Bqenvij": "fjamq6b",
87
+ "Bkecrkj": "f1aehjj5",
88
+ "B3o57yi": "f1bnoopa",
89
+ "Bkqvd7p": "f1e1a42z",
90
+ "Bmy1vo4": "fo99fu7",
91
+ "a9b677": "feqmc2u",
92
+ "Hkqiji": "f1wkgtgk",
93
+ "Bgrs90m": "f17f8g0y",
94
+ "B0zx559": "f1uwej41"
95
+ }
96
+ }, {
97
+ "d": [".f8fbkgy{border-bottom-right-radius:var(--borderRadiusCircular);}", ".f1nfllo7{border-bottom-left-radius:var(--borderRadiusCircular);}", ".f1djnp8u{border-top-right-radius:var(--borderRadiusCircular);}", ".f1s8kh49{border-top-left-radius:var(--borderRadiusCircular);}", ".fzkkow9{border-top-style:solid;}", ".fcdblym{border-right-style:solid;}", ".fjik90z{border-left-style:solid;}", ".fg706s2{border-bottom-style:solid;}", ".f5ogflp{border-top-width:1px;}", ".f1hqa2wf{border-right-width:1px;}", ".finvdd3{border-left-width:1px;}", ".f1f09k3d{border-bottom-width:1px;}", ".f1ewtqcl{box-sizing:border-box;}", ".f1w9h62z{fill:currentColor;}", ".fi64zpg{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;}", ".f4ybsrx{font-size:16px;}", ".fjamq6b{height:20px;}", ".f1aehjj5{pointer-events:none;}", ".f1bnoopa{transition-duration:200ms;}", ".f1e1a42z{transition-timing-function:cubic-bezier(0.33, 0, 0.67, 1);}", ".fo99fu7{transition-property:background,border,color;}", ".feqmc2u{width:40px;}", ".f1wkgtgk>*{transition-duration:200ms;}", ".f17f8g0y>*{transition-timing-function:cubic-bezier(0.33, 0, 0.67, 1);}", ".f1uwej41>*{transition-property:transform;}"]
98
+ });
99
+
100
+ const useInputStyles = /*#__PURE__*/__styles({
101
+ "base": {
102
+ "B7ck84d": "f1ewtqcl",
103
+ "Bceei9c": "f1k6fduh",
104
+ "Bqenvij": "f1l02sjl",
105
+ "oyh7mz": ["f1vgc2s3", "f1e31b4d"],
106
+ "B6of3ja": "f1hu3pq6",
107
+ "t21cq0": ["f11qmguv", "f1tyq0we"],
108
+ "jrapky": "f19f4twv",
109
+ "Frg6f3": ["f1tyq0we", "f11qmguv"],
110
+ "abs64n": "fk73vx1",
111
+ "qhf8xq": "f1euv43f",
112
+ "Bhzewxz": "f15twtuk",
113
+ "a9b677": "fly5x3f",
114
+ "fv8x6k": ["f1owqbgs", "f1a7g3i4"],
115
+ "ezr58z": "fvxnmui",
116
+ "Blezdol": "f1cxq9o1",
117
+ "B8f96ig": "f1ks1zsm",
118
+ "po7uxr": "fiqfi0i",
119
+ "inq7wv": "f9aagkg",
120
+ "Cdugon": ["fgv8l18", "f1p3jmxb"],
121
+ "ptsei1": "f11yi64e",
122
+ "bl04ud": ["f1p3jmxb", "fgv8l18"],
123
+ "Bu7dm46": "fthrly9",
124
+ "Gwwlnz": "fhdp2ht",
125
+ "wb1her": "f1rzj6jj",
126
+ "Bmieemq": ["f1jywl1l", "f13d626x"],
127
+ "Bdgjgzg": "f1ivtmze",
128
+ "B05cvx7": ["f13d626x", "f1jywl1l"],
129
+ "Bx4eqiv": "f1uvnr57",
130
+ "xhnoxe": "frhcydi",
131
+ "Hnmc4c": ["f1pvt3n7", "f14i0clv"],
132
+ "By8gkvz": "fq9gcw4",
133
+ "lekrm4": ["f14i0clv", "f1pvt3n7"],
134
+ "Bei91sp": "fft44l1",
135
+ "Bksztz9": "fwlrvmy",
136
+ "h3gz1v": "f1c4gun2",
137
+ "Cw6427": ["flhgtcm", "fx1zdd8"],
138
+ "Bpbd9g9": "fayrp2e",
139
+ "ssulyh": ["fx1zdd8", "flhgtcm"],
140
+ "vq7rp1": "f1vk2knj",
141
+ "ynrfiu": "firogjh",
142
+ "Bf5tpyt": ["f1crd6p1", "for8100"],
143
+ "Brhic7g": "f1v5j4zb",
144
+ "Cqvc5u": ["for8100", "f1crd6p1"],
145
+ "B4e80u0": "f1rt7qcq",
146
+ "Bwj41i9": "fxvotg6",
147
+ "B2iiaa1": ["fk9ur30", "f3u5smv"],
148
+ "Bejmxmv": "fdtj07x",
149
+ "rqauf5": ["f3u5smv", "fk9ur30"],
150
+ "wo5z87": "fv5mb1o",
151
+ "B50joxe": ["f1i2l8ou", "fxj1kmv"],
152
+ "Bmuizf1": "fku528b",
153
+ "f4urji": ["fxj1kmv", "f1i2l8ou"],
154
+ "Bxiq1ly": "fabcpc0",
155
+ "vbmdq8": "f17xwy6w",
156
+ "u4vbwo": ["fipwscc", "fab39iv"],
157
+ "Bfjga03": "f1th5z1l",
158
+ "F0s3py": ["fab39iv", "fipwscc"]
159
+ }
160
+ }, {
161
+ "d": [".f1ewtqcl{box-sizing:border-box;}", ".f1k6fduh{cursor:pointer;}", ".f1l02sjl{height:100%;}", ".f1vgc2s3{left:0;}", ".f1e31b4d{right:0;}", ".f1hu3pq6{margin-top:0;}", ".f11qmguv{margin-right:0;}", ".f1tyq0we{margin-left:0;}", ".f19f4twv{margin-bottom:0;}", ".fk73vx1{opacity:0;}", ".f1euv43f{position:absolute;}", ".f15twtuk{top:0;}", ".fly5x3f{width:100%;}", ".f1owqbgs:checked~.fui-Switch__indicator>*{-webkit-transform:translateX(22px);-moz-transform:translateX(22px);-ms-transform:translateX(22px);transform:translateX(22px);}", ".f1a7g3i4:checked~.fui-Switch__indicator>*{-webkit-transform:translateX(-22px);-moz-transform:translateX(-22px);-ms-transform:translateX(-22px);transform:translateX(-22px);}", ".fvxnmui:disabled{cursor:default;}", ".f1cxq9o1:disabled~.fui-Switch__indicator{color:var(--colorNeutralForegroundDisabled);}", ".f1ks1zsm:disabled~.fui-Switch__label{color:var(--colorNeutralForegroundDisabled);}", ".fiqfi0i:enabled:not(:checked)~.fui-Switch__indicator{color:var(--colorNeutralStrokeAccessible);}", ".f9aagkg:enabled:not(:checked)~.fui-Switch__indicator{border-top-color:var(--colorNeutralStrokeAccessible);}", ".fgv8l18:enabled:not(:checked)~.fui-Switch__indicator{border-right-color:var(--colorNeutralStrokeAccessible);}", ".f1p3jmxb:enabled:not(:checked)~.fui-Switch__indicator{border-left-color:var(--colorNeutralStrokeAccessible);}", ".f11yi64e:enabled:not(:checked)~.fui-Switch__indicator{border-bottom-color:var(--colorNeutralStrokeAccessible);}", ".fthrly9:enabled:not(:checked)~.fui-Switch__label{color:var(--colorNeutralForeground1);}", ".fhdp2ht:enabled:not(:checked):hover~.fui-Switch__indicator{color:var(--colorNeutralStrokeAccessibleHover);}", ".f1rzj6jj:enabled:not(:checked):hover~.fui-Switch__indicator{border-top-color:var(--colorNeutralStrokeAccessibleHover);}", ".f1jywl1l:enabled:not(:checked):hover~.fui-Switch__indicator{border-right-color:var(--colorNeutralStrokeAccessibleHover);}", ".f13d626x:enabled:not(:checked):hover~.fui-Switch__indicator{border-left-color:var(--colorNeutralStrokeAccessibleHover);}", ".f1ivtmze:enabled:not(:checked):hover~.fui-Switch__indicator{border-bottom-color:var(--colorNeutralStrokeAccessibleHover);}", ".f1uvnr57:enabled:not(:checked):hover:active~.fui-Switch__indicator{color:var(--colorNeutralStrokeAccessiblePressed);}", ".frhcydi:enabled:not(:checked):hover:active~.fui-Switch__indicator{border-top-color:var(--colorNeutralStrokeAccessiblePressed);}", ".f1pvt3n7:enabled:not(:checked):hover:active~.fui-Switch__indicator{border-right-color:var(--colorNeutralStrokeAccessiblePressed);}", ".f14i0clv:enabled:not(:checked):hover:active~.fui-Switch__indicator{border-left-color:var(--colorNeutralStrokeAccessiblePressed);}", ".fq9gcw4:enabled:not(:checked):hover:active~.fui-Switch__indicator{border-bottom-color:var(--colorNeutralStrokeAccessiblePressed);}", ".fft44l1:enabled:checked~.fui-Switch__indicator{background-color:var(--colorBrandBackground);}", ".fwlrvmy:enabled:checked~.fui-Switch__indicator{color:var(--colorNeutralForegroundOnBrand);}", ".f1c4gun2:enabled:checked~.fui-Switch__indicator{border-top-color:var(--colorTransparentStroke);}", ".flhgtcm:enabled:checked~.fui-Switch__indicator{border-right-color:var(--colorTransparentStroke);}", ".fx1zdd8:enabled:checked~.fui-Switch__indicator{border-left-color:var(--colorTransparentStroke);}", ".fayrp2e:enabled:checked~.fui-Switch__indicator{border-bottom-color:var(--colorTransparentStroke);}", ".f1vk2knj:enabled:checked:hover~.fui-Switch__indicator{background-color:var(--colorBrandBackgroundHover);}", ".firogjh:enabled:checked:hover~.fui-Switch__indicator{border-top-color:var(--colorTransparentStrokeInteractive);}", ".f1crd6p1:enabled:checked:hover~.fui-Switch__indicator{border-right-color:var(--colorTransparentStrokeInteractive);}", ".for8100:enabled:checked:hover~.fui-Switch__indicator{border-left-color:var(--colorTransparentStrokeInteractive);}", ".f1v5j4zb:enabled:checked:hover~.fui-Switch__indicator{border-bottom-color:var(--colorTransparentStrokeInteractive);}", ".f1rt7qcq:enabled:checked:hover:active~.fui-Switch__indicator{background-color:var(--colorBrandBackgroundPressed);}", ".fxvotg6:enabled:checked:hover:active~.fui-Switch__indicator{border-top-color:var(--colorTransparentStrokeInteractive);}", ".fk9ur30:enabled:checked:hover:active~.fui-Switch__indicator{border-right-color:var(--colorTransparentStrokeInteractive);}", ".f3u5smv:enabled:checked:hover:active~.fui-Switch__indicator{border-left-color:var(--colorTransparentStrokeInteractive);}", ".fdtj07x:enabled:checked:hover:active~.fui-Switch__indicator{border-bottom-color:var(--colorTransparentStrokeInteractive);}", ".fv5mb1o:disabled:not(:checked)~.fui-Switch__indicator{border-top-color:var(--colorNeutralStrokeDisabled);}", ".f1i2l8ou:disabled:not(:checked)~.fui-Switch__indicator{border-right-color:var(--colorNeutralStrokeDisabled);}", ".fxj1kmv:disabled:not(:checked)~.fui-Switch__indicator{border-left-color:var(--colorNeutralStrokeDisabled);}", ".fku528b:disabled:not(:checked)~.fui-Switch__indicator{border-bottom-color:var(--colorNeutralStrokeDisabled);}", ".fabcpc0:disabled:checked~.fui-Switch__indicator{background-color:var(--colorNeutralBackgroundDisabled);}", ".f17xwy6w:disabled:checked~.fui-Switch__indicator{border-top-color:var(--colorTransparentStrokeDisabled);}", ".fipwscc:disabled:checked~.fui-Switch__indicator{border-right-color:var(--colorTransparentStrokeDisabled);}", ".fab39iv:disabled:checked~.fui-Switch__indicator{border-left-color:var(--colorTransparentStrokeDisabled);}", ".f1th5z1l:disabled:checked~.fui-Switch__indicator{border-bottom-color:var(--colorTransparentStrokeDisabled);}"]
162
+ });
163
+
164
+ const useLabelStyles = /*#__PURE__*/__styles({
165
+ "base": {
166
+ "famaaq": "f1xqy1su"
167
+ }
168
+ }, {
169
+ "d": [".f1xqy1su{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}"]
170
+ });
171
+ /**
172
+ * Apply styling to the Switch slots based on the state
173
+ */
174
+
175
+
176
+ export const useSwitchStyles_unstable = state => {
177
+ const rootStyles = useRootStyles();
178
+ const indicatorStyles = useIndicatorStyles();
179
+ const inputStyles = useInputStyles();
180
+ const labelStyles = useLabelStyles();
181
+ const {
182
+ labelPosition
183
+ } = state;
184
+ state.root.className = mergeClasses(switchClassNames.root, rootStyles.base, rootStyles[labelPosition], state.root.className);
185
+ state.indicator.className = mergeClasses(switchClassNames.indicator, indicatorStyles.base, state.indicator.className);
186
+ state.input.className = mergeClasses(switchClassNames.input, inputStyles.base, state.input.className);
187
+
188
+ if (state.label) {
189
+ state.label.className = mergeClasses(switchClassNames.label, labelStyles.base, state.label.className);
190
+ }
191
+
192
+ return state;
193
+ };
194
+ //# sourceMappingURL=useSwitchStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/Switch/useSwitchStyles.ts"],"names":[],"mappings":"AAAA,SAAS,uBAAT,QAAwC,yBAAxC;A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D,CAApC;AACD;;AAED,SAAO,KAAP;AACD,CAxBM","sourcesContent":["import { createFocusOutlineStyle } from '@fluentui/react-tabster';\nimport { tokens } from '@fluentui/react-theme';\nimport { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport type { SwitchSlots, SwitchState } from './Switch.types';\n\nexport const switchClassNames: {\n [SlotName in keyof SwitchSlots]-?: string;\n} = {\n root: 'fui-Switch',\n indicator: 'fui-Switch__indicator',\n input: 'fui-Switch__input',\n label: 'fui-Switch__label',\n};\n\n// TODO temporary export to pass conformance test.\nexport const switchClassName = switchClassNames.root;\n\n// TODO replace these spacing constants with theme values once they're on the theme.\nconst spacingXS = 4;\nconst spacingS = 8;\nconst spacingM = 12;\n\n// Thumb and track sizes used by the component.\nconst spaceBetweenThumbAndTrack = 2;\nconst thumbSize = 14;\nconst trackHeight = 20;\nconst trackWidth = 40;\n\nconst useRootStyles = makeStyles({\n base: {\n boxSizing: 'border-box',\n columnGap: `${spacingM}px`,\n display: 'inline-flex',\n ...shorthands.padding(`${spacingS}px`),\n position: 'relative',\n\n ...createFocusOutlineStyle({ style: {}, selector: 'focus-within' }),\n },\n\n // Label position variations\n above: {\n flexDirection: 'column',\n paddingTop: `${spacingXS}px`,\n rowGap: `${spacingXS}px`,\n },\n after: {\n alignItems: 'flex-start',\n columnGap: `${spacingM}px`,\n flexDirection: 'row',\n },\n before: {\n alignItems: 'flex-start',\n columnGap: `${spacingM}px`,\n flexDirection: 'row',\n },\n});\n\nconst useIndicatorStyles = makeStyles({\n base: {\n ...shorthands.borderRadius(tokens.borderRadiusCircular),\n ...shorthands.borderStyle('solid'),\n ...shorthands.borderWidth('1px'),\n boxSizing: 'border-box',\n fill: 'currentColor',\n flexShrink: 0,\n fontSize: `${thumbSize + spaceBetweenThumbAndTrack}px`,\n height: `${trackHeight}px`,\n pointerEvents: 'none',\n transitionDuration: '200ms',\n transitionTimingFunction: 'cubic-bezier(0.33, 0, 0.67, 1)',\n transitionProperty: 'background, border, color',\n width: `${trackWidth}px`,\n\n '> *': {\n transitionDuration: '200ms',\n transitionTimingFunction: 'cubic-bezier(0.33, 0, 0.67, 1)',\n transitionProperty: 'transform',\n },\n },\n});\n\nconst useInputStyles = makeStyles({\n base: {\n boxSizing: 'border-box',\n cursor: 'pointer',\n height: '100%',\n left: 0,\n ...shorthands.margin(0),\n opacity: 0,\n position: 'absolute',\n top: 0,\n width: '100%',\n\n // Checked (both enabled and disabled)\n ':checked': {\n [`& ~ .${switchClassNames.indicator}`]: {\n '> *': {\n transform: `translateX(${trackWidth - thumbSize - spaceBetweenThumbAndTrack * 2}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 color: tokens.colorNeutralForegroundDisabled,\n },\n },\n\n // Enabled and unchecked\n ':enabled:not(:checked)': {\n [`& ~ .${switchClassNames.indicator}`]: {\n color: tokens.colorNeutralStrokeAccessible,\n ...shorthands.borderColor(tokens.colorNeutralStrokeAccessible),\n },\n\n [`& ~ .${switchClassNames.label}`]: {\n color: tokens.colorNeutralForeground1,\n },\n\n ':hover': {\n [`& ~ .${switchClassNames.indicator}`]: {\n color: tokens.colorNeutralStrokeAccessibleHover,\n ...shorthands.borderColor(tokens.colorNeutralStrokeAccessibleHover),\n },\n },\n\n ':hover:active': {\n [`& ~ .${switchClassNames.indicator}`]: {\n color: tokens.colorNeutralStrokeAccessiblePressed,\n ...shorthands.borderColor(tokens.colorNeutralStrokeAccessiblePressed),\n },\n },\n },\n\n // Enabled and checked\n ':enabled:checked': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorBrandBackground,\n color: tokens.colorNeutralForegroundOnBrand,\n ...shorthands.borderColor(tokens.colorTransparentStroke),\n },\n\n ':hover': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorBrandBackgroundHover,\n ...shorthands.borderColor(tokens.colorTransparentStrokeInteractive),\n },\n },\n\n ':hover:active': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorBrandBackgroundPressed,\n ...shorthands.borderColor(tokens.colorTransparentStrokeInteractive),\n },\n },\n },\n\n // Disabled and unchecked\n ':disabled:not(:checked)': {\n [`& ~ .${switchClassNames.indicator}`]: {\n ...shorthands.borderColor(tokens.colorNeutralStrokeDisabled),\n },\n },\n\n // Disabled and checked\n ':disabled:checked': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorNeutralBackgroundDisabled,\n ...shorthands.borderColor(tokens.colorTransparentStrokeDisabled),\n },\n },\n },\n});\n\nconst useLabelStyles = makeStyles({\n base: {\n userSelect: 'none',\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 rootStyles = useRootStyles();\n const indicatorStyles = useIndicatorStyles();\n const inputStyles = useInputStyles();\n const labelStyles = useLabelStyles();\n\n const { labelPosition } = state;\n\n state.root.className = mergeClasses(\n switchClassNames.root,\n rootStyles.base,\n rootStyles[labelPosition],\n state.root.className,\n );\n\n state.indicator.className = mergeClasses(switchClassNames.indicator, indicatorStyles.base, state.indicator.className);\n\n state.input.className = mergeClasses(switchClassNames.input, inputStyles.base, state.input.className);\n\n if (state.label) {\n state.label.className = mergeClasses(switchClassNames.label, labelStyles.base, state.label.className);\n }\n\n return state;\n};\n"],"sourceRoot":"../src/"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ export * from './Switch';
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './Switch';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC","sourcesContent":["export {};\nexport * from './Switch';\n"]}
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.18.1"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1 @@
1
+ export * from './components/Switch/index';
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ const tslib_1 = /*#__PURE__*/require("tslib");
8
+
9
+ tslib_1.__exportStar(require("./components/Switch/index"), exports);
10
+ //# sourceMappingURL=Switch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["Switch.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,2BAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './components/Switch/index';\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,6 @@
1
+ import type { SwitchProps } from './Switch.types';
2
+ import type { ForwardRefComponent } from '@fluentui/react-utilities';
3
+ /**
4
+ * Switches enable users to trigger an option on or off through pressing the component.
5
+ */
6
+ export declare const Switch: ForwardRefComponent<SwitchProps>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Switch = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const useSwitch_1 = /*#__PURE__*/require("./useSwitch");
11
+
12
+ const renderSwitch_1 = /*#__PURE__*/require("./renderSwitch");
13
+
14
+ const useSwitchStyles_1 = /*#__PURE__*/require("./useSwitchStyles");
15
+ /**
16
+ * Switches enable users to trigger an option on or off through pressing the component.
17
+ */
18
+
19
+
20
+ exports.Switch = /*#__PURE__*/React.forwardRef((props, ref) => {
21
+ const state = useSwitch_1.useSwitch_unstable(props, ref);
22
+ useSwitchStyles_1.useSwitchStyles_unstable(state);
23
+ return renderSwitch_1.renderSwitch_unstable(state);
24
+ });
25
+ exports.Switch.displayName = 'Switch';
26
+ //# sourceMappingURL=Switch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/Switch/Switch.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,mBAAA,CAAA;AAIA;;AAEG;;;AACU,OAAA,CAAA,MAAA,gBAA2C,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;AACtF,QAAM,KAAK,GAAG,WAAA,CAAA,kBAAA,CAAmB,KAAnB,EAA0B,GAA1B,CAAd;AAEA,EAAA,iBAAA,CAAA,wBAAA,CAAyB,KAAzB;AAEA,SAAO,cAAA,CAAA,qBAAA,CAAsB,KAAtB,CAAP;AACD,CANuD,CAA3C;AAQb,OAAA,CAAA,MAAA,CAAO,WAAP,GAAqB,QAArB","sourcesContent":["import * as React from 'react';\nimport { useSwitch_unstable } from './useSwitch';\nimport { renderSwitch_unstable } from './renderSwitch';\nimport { useSwitchStyles_unstable } from './useSwitchStyles';\nimport type { SwitchProps } from './Switch.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * Switches enable users to trigger an option on or off through pressing the component.\n */\nexport const Switch: ForwardRefComponent<SwitchProps> = React.forwardRef((props, ref) => {\n const state = useSwitch_unstable(props, ref);\n\n useSwitchStyles_unstable(state);\n\n return renderSwitch_unstable(state);\n});\n\nSwitch.displayName = 'Switch';\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,65 @@
1
+ import * as React from 'react';
2
+ import { Label } from '@fluentui/react-label';
3
+ import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';
4
+ export declare type SwitchSlots = {
5
+ /**
6
+ * The root element of the Switch.
7
+ *
8
+ * The root slot receives the `className` and `style` specified directly on the `<Switch>` tag.
9
+ * All other native props will be applied to the primary slot: `input`.
10
+ */
11
+ root: NonNullable<Slot<'div'>>;
12
+ /**
13
+ * The track and the thumb sliding over it indicating the on and off status of the Switch.
14
+ */
15
+ indicator: NonNullable<Slot<'div'>>;
16
+ /**
17
+ * Hidden input that handles the Switch's functionality.
18
+ *
19
+ * This is the PRIMARY slot: all native properties specified directly on the `<Switch>` tag will be applied to this
20
+ * slot, except `className` and `style`, which remain on the root slot.
21
+ */
22
+ input: NonNullable<Slot<'input'>>;
23
+ /**
24
+ * The Switch's label.
25
+ */
26
+ label?: Slot<typeof Label>;
27
+ };
28
+ declare type SwitchCommons = {
29
+ /**
30
+ * Defines the controlled checked state of the Switch.
31
+ * If passed, Switch ignores the `defaultChecked` property.
32
+ * This should only be used if the checked state is to be controlled at a higher level and there is a plan to pass the
33
+ * correct value based on handling `onChange` events and re-rendering.
34
+ * @default false
35
+ */
36
+ checked?: boolean;
37
+ /**
38
+ * The position of the label relative to the Switch.
39
+ *
40
+ * @default after
41
+ */
42
+ labelPosition: 'above' | 'after' | 'before';
43
+ };
44
+ export declare type SwitchOnChangeData = {
45
+ checked: boolean;
46
+ };
47
+ /**
48
+ * Switch Props
49
+ */
50
+ export declare type SwitchProps = Omit<ComponentProps<Partial<SwitchSlots>, 'input'>, 'onChange'> & Partial<SwitchCommons> & {
51
+ /**
52
+ * Defines whether the Switch is initially in a checked state or not when rendered.
53
+ * @default false
54
+ */
55
+ defaultChecked?: boolean;
56
+ /**
57
+ * Callback to be called when the checked state value changes.
58
+ */
59
+ onChange?: (ev: React.ChangeEvent<HTMLInputElement>, data: SwitchOnChangeData) => void;
60
+ };
61
+ /**
62
+ * State used in rendering Switch
63
+ */
64
+ export declare type SwitchState = ComponentState<SwitchSlots> & SwitchCommons;
65
+ export {};
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=Switch.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
@@ -0,0 +1,5 @@
1
+ export * from './Switch';
2
+ export * from './Switch.types';
3
+ export * from './renderSwitch';
4
+ export * from './useSwitch';
5
+ export * from './useSwitchStyles';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ const tslib_1 = /*#__PURE__*/require("tslib");
8
+
9
+ tslib_1.__exportStar(require("./Switch"), exports);
10
+
11
+ tslib_1.__exportStar(require("./Switch.types"), exports);
12
+
13
+ tslib_1.__exportStar(require("./renderSwitch"), exports);
14
+
15
+ tslib_1.__exportStar(require("./useSwitch"), exports);
16
+
17
+ tslib_1.__exportStar(require("./useSwitchStyles"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/Switch/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,UAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,aAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './Switch';\nexport * from './Switch.types';\nexport * from './renderSwitch';\nexport * from './useSwitch';\nexport * from './useSwitchStyles';\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,5 @@
1
+ import type { SwitchState } from './Switch.types';
2
+ /**
3
+ * Render a Switch component by passing the state defined props to the appropriate slots.
4
+ */
5
+ export declare const renderSwitch_unstable: (state: SwitchState) => JSX.Element;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.renderSwitch_unstable = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
+ /**
12
+ * Render a Switch component by passing the state defined props to the appropriate slots.
13
+ */
14
+
15
+
16
+ const renderSwitch_unstable = state => {
17
+ const {
18
+ slots,
19
+ slotProps
20
+ } = react_utilities_1.getSlots(state);
21
+ const {
22
+ labelPosition
23
+ } = state;
24
+ return React.createElement(slots.root, { ...slotProps.root
25
+ }, React.createElement(slots.input, { ...slotProps.input
26
+ }), labelPosition !== 'after' && slots.label && React.createElement(slots.label, { ...slotProps.label
27
+ }), React.createElement(slots.indicator, { ...slotProps.indicator
28
+ }), labelPosition === 'after' && slots.label && React.createElement(slots.label, { ...slotProps.label
29
+ }));
30
+ };
31
+
32
+ exports.renderSwitch_unstable = renderSwitch_unstable;
33
+ //# sourceMappingURL=renderSwitch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/Switch/renderSwitch.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,qBAAqB,GAAI,KAAD,IAAuB;AAC1D,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,iBAAA,CAAA,QAAA,CAAsB,KAAtB,CAA7B;AACA,QAAM;AAAE,IAAA;AAAF,MAAoB,KAA1B;AAEA,SACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;AAAf,GAAX,EACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;AAAf,GAAZ,CADF,EAEG,aAAa,KAAK,OAAlB,IAA6B,KAAK,CAAC,KAAnC,IAA4C,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;AAAf,GAAZ,CAF/C,EAGE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,SAAP,EAAgB,EAAA,GAAK,SAAS,CAAC;AAAf,GAAhB,CAHF,EAIG,aAAa,KAAK,OAAlB,IAA6B,KAAK,CAAC,KAAnC,IAA4C,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;AAAf,GAAZ,CAJ/C,CADF;AAQD,CAZM;;AAAM,OAAA,CAAA,qBAAA,GAAqB,qBAArB","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { SwitchState, SwitchSlots } from './Switch.types';\n\n/**\n * Render a Switch component by passing the state defined props to the appropriate slots.\n */\nexport const renderSwitch_unstable = (state: SwitchState) => {\n const { slots, slotProps } = getSlots<SwitchSlots>(state);\n const { labelPosition } = state;\n\n return (\n <slots.root {...slotProps.root}>\n <slots.input {...slotProps.input} />\n {labelPosition !== 'after' && slots.label && <slots.label {...slotProps.label} />}\n <slots.indicator {...slotProps.indicator} />\n {labelPosition === 'after' && slots.label && <slots.label {...slotProps.label} />}\n </slots.root>\n );\n};\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import type { SwitchProps, SwitchState } from './Switch.types';
3
+ /**
4
+ * Create the state required to render Switch.
5
+ *
6
+ * The returned state can be modified with hooks such as useSwitchStyles_unstable,
7
+ * before being passed to renderSwitch_unstable.
8
+ *
9
+ * @param props - props from this instance of Switch
10
+ * @param ref - reference to `<input>` element of Switch
11
+ */
12
+ export declare const useSwitch_unstable: (props: SwitchProps, ref: React.Ref<HTMLInputElement>) => SwitchState;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useSwitch_unstable = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const react_icons_1 = /*#__PURE__*/require("@fluentui/react-icons");
11
+
12
+ const react_label_1 = /*#__PURE__*/require("@fluentui/react-label");
13
+
14
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
15
+ /**
16
+ * Create the state required to render Switch.
17
+ *
18
+ * The returned state can be modified with hooks such as useSwitchStyles_unstable,
19
+ * before being passed to renderSwitch_unstable.
20
+ *
21
+ * @param props - props from this instance of Switch
22
+ * @param ref - reference to `<input>` element of Switch
23
+ */
24
+
25
+
26
+ const useSwitch_unstable = (props, ref) => {
27
+ const {
28
+ checked,
29
+ defaultChecked,
30
+ disabled,
31
+ labelPosition = 'after',
32
+ onChange,
33
+ required
34
+ } = props;
35
+ const nativeProps = react_utilities_1.getPartitionedNativeProps({
36
+ props,
37
+ primarySlotTagName: 'input',
38
+ excludedPropNames: ['checked', 'defaultChecked', 'onChange']
39
+ });
40
+ const id = react_utilities_1.useId('switch-', nativeProps.primary.id);
41
+ const root = react_utilities_1.resolveShorthand(props.root, {
42
+ defaultProps: nativeProps.root,
43
+ required: true
44
+ });
45
+ const indicator = react_utilities_1.resolveShorthand(props.indicator, {
46
+ defaultProps: {
47
+ 'aria-hidden': true,
48
+ children: React.createElement(react_icons_1.CircleFilled, null)
49
+ },
50
+ required: true
51
+ });
52
+ const input = react_utilities_1.resolveShorthand(props.input, {
53
+ defaultProps: {
54
+ checked,
55
+ defaultChecked,
56
+ id,
57
+ ref,
58
+ role: 'switch',
59
+ type: 'checkbox',
60
+ ...nativeProps.primary
61
+ },
62
+ required: true
63
+ });
64
+ input.onChange = react_utilities_1.useMergedEventCallbacks(input.onChange, ev => onChange === null || onChange === void 0 ? void 0 : onChange(ev, {
65
+ checked: ev.currentTarget.checked
66
+ }));
67
+ const label = react_utilities_1.resolveShorthand(props.label, {
68
+ defaultProps: {
69
+ disabled,
70
+ htmlFor: id,
71
+ required,
72
+ size: 'medium'
73
+ }
74
+ });
75
+ return {
76
+ labelPosition,
77
+ //Slots definition
78
+ components: {
79
+ root: 'div',
80
+ indicator: 'div',
81
+ input: 'input',
82
+ label: react_label_1.Label
83
+ },
84
+ root,
85
+ indicator,
86
+ input,
87
+ label
88
+ };
89
+ };
90
+
91
+ exports.useSwitch_unstable = useSwitch_unstable;
92
+ //# sourceMappingURL=useSwitch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/Switch/useSwitch.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,aAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;;AACA,MAAA,aAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;;;;;;;AAQG;;;AACI,MAAM,kBAAkB,GAAG,CAAC,KAAD,EAAqB,GAArB,KAAsE;AACtG,QAAM;AAAE,IAAA,OAAF;AAAW,IAAA,cAAX;AAA2B,IAAA,QAA3B;AAAqC,IAAA,aAAa,GAAG,OAArD;AAA8D,IAAA,QAA9D;AAAwE,IAAA;AAAxE,MAAqF,KAA3F;AAEA,QAAM,WAAW,GAAG,iBAAA,CAAA,yBAAA,CAA0B;AAC5C,IAAA,KAD4C;AAE5C,IAAA,kBAAkB,EAAE,OAFwB;AAG5C,IAAA,iBAAiB,EAAE,CAAC,SAAD,EAAY,gBAAZ,EAA8B,UAA9B;AAHyB,GAA1B,CAApB;AAMA,QAAM,EAAE,GAAG,iBAAA,CAAA,KAAA,CAAM,SAAN,EAAiB,WAAW,CAAC,OAAZ,CAAoB,EAArC,CAAX;AAEA,QAAM,IAAI,GAAG,iBAAA,CAAA,gBAAA,CAAiB,KAAK,CAAC,IAAvB,EAA6B;AACxC,IAAA,YAAY,EAAE,WAAW,CAAC,IADc;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S,EAAE,KAFD;AAGV,MAAA,KAAK,EAAE,OAHG;AAIV,MAAA,KAAK,EAAE,aAAA,CAAA;AAJG,KAJP;AAWL,IAAA,IAXK;AAYL,IAAA,SAZK;AAaL,IAAA,KAbK;AAcL,IAAA;AAdK,GAAP;AAgBD,CA/DM;;AAAM,OAAA,CAAA,kBAAA,GAAkB,kBAAlB","sourcesContent":["import * as React from 'react';\nimport { CircleFilled } from '@fluentui/react-icons';\nimport { Label } from '@fluentui/react-label';\nimport { getPartitionedNativeProps, resolveShorthand, useId, useMergedEventCallbacks } from '@fluentui/react-utilities';\nimport type { SwitchProps, SwitchState } from './Switch.types';\n\n/**\n * Create the state required to render Switch.\n *\n * The returned state can be modified with hooks such as useSwitchStyles_unstable,\n * before being passed to renderSwitch_unstable.\n *\n * @param props - props from this instance of Switch\n * @param ref - reference to `<input>` element of Switch\n */\nexport const useSwitch_unstable = (props: SwitchProps, ref: React.Ref<HTMLInputElement>): SwitchState => {\n const { checked, defaultChecked, disabled, labelPosition = 'after', onChange, required } = props;\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'onChange'],\n });\n\n const id = useId('switch-', nativeProps.primary.id);\n\n const root = resolveShorthand(props.root, {\n defaultProps: nativeProps.root,\n required: true,\n });\n\n const indicator = resolveShorthand(props.indicator, {\n defaultProps: {\n 'aria-hidden': true,\n children: <CircleFilled />,\n },\n required: true,\n });\n\n const input = resolveShorthand(props.input, {\n defaultProps: {\n checked,\n defaultChecked,\n id,\n ref,\n role: 'switch',\n type: 'checkbox',\n ...nativeProps.primary,\n },\n required: true,\n });\n input.onChange = useMergedEventCallbacks(input.onChange, ev => onChange?.(ev, { checked: ev.currentTarget.checked }));\n\n const label = resolveShorthand(props.label, {\n defaultProps: {\n disabled,\n htmlFor: id,\n required,\n size: 'medium',\n },\n });\n\n return {\n labelPosition,\n\n //Slots definition\n components: {\n root: 'div',\n indicator: 'div',\n input: 'input',\n label: Label,\n },\n\n root,\n indicator,\n input,\n label,\n };\n};\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,9 @@
1
+ import type { SwitchSlots, SwitchState } from './Switch.types';
2
+ export declare const switchClassNames: {
3
+ [SlotName in keyof SwitchSlots]-?: string;
4
+ };
5
+ export declare const switchClassName: string;
6
+ /**
7
+ * Apply styling to the Switch slots based on the state
8
+ */
9
+ export declare const useSwitchStyles_unstable: (state: SwitchState) => SwitchState;