@aristobyte-ui/switch 2.5.1 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -0
- package/package.json +5 -5
- package/es/src/main/components/Switch/Switch.scss +0 -486
- package/es/src/main/components/Switch/index.d.ts +0 -33
- package/es/src/main/components/Switch/index.d.ts.map +0 -1
- package/es/src/main/components/Switch/index.js +0 -45
- package/es/src/main/components/index.d.ts +0 -2
- package/es/src/main/components/index.d.ts.map +0 -1
- package/es/src/main/components/index.js +0 -1
- package/es/src/main/index.d.ts +0 -2
- package/es/src/main/index.d.ts.map +0 -1
- package/es/src/main/index.js +0 -1
- package/lib/src/main/components/Switch/Switch.scss +0 -486
- package/lib/src/main/components/Switch/index.d.ts +0 -33
- package/lib/src/main/components/Switch/index.d.ts.map +0 -1
- package/lib/src/main/components/Switch/index.js +0 -82
- package/lib/src/main/components/index.d.ts +0 -2
- package/lib/src/main/components/index.d.ts.map +0 -1
- package/lib/src/main/components/index.js +0 -17
- package/lib/src/main/index.d.ts +0 -2
- package/lib/src/main/index.d.ts.map +0 -1
- package/lib/src/main/index.js +0 -17
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# `@aristobyte-ui/switch`
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://img.shields.io/badge/TypeScript-5.8-blue?style=for-the-badge&logo=typescript&logoColor=white" alt="TypeScript" />
|
|
5
|
+
<img src="https://img.shields.io/badge/Build-Turbo-green?style=for-the-badge&logo=turbo&logoColor=white" alt="TurboRepo" />
|
|
6
|
+
<img src="https://img.shields.io/badge/Lint-Strict-red?style=for-the-badge&logo=eslint&logoColor=white" alt="ESLint" />
|
|
7
|
+
<img src="https://img.shields.io/badge/License-MIT-black?style=for-the-badge&logo=open-source-initiative&logoColor=white" alt="License" />
|
|
8
|
+
<img src="https://img.shields.io/badge/AristoByte-UI-purple?style=for-the-badge&logo=react&logoColor=white" alt="AristoByte UI" />
|
|
9
|
+
<img src="https://img.shields.io/badge/Node-20.17.0+-339933?style=for-the-badge&logo=node.js&logoColor=white" alt="Node.js >=20.17.0" />
|
|
10
|
+
<img src="https://img.shields.io/badge/Yarn-1.22+-2C8EBB?style=for-the-badge&logo=yarn&logoColor=white" alt="Yarn >=1.22" />
|
|
11
|
+
<img src="https://img.shields.io/badge/NPM-10.8+-CB3837?style=for-the-badge&logo=npm&logoColor=white" alt="NPM >=10.8" />
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
A highly flexible and type-safe Switch component for React with multiple sizes, variants, and label alignment options.
|
|
15
|
+
|
|
16
|
+
## 📦 Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Install via Yarn
|
|
20
|
+
yarn add -D @aristobyte-ui/switch
|
|
21
|
+
|
|
22
|
+
# Or via npm
|
|
23
|
+
npm install -D @aristobyte-ui/switch
|
|
24
|
+
|
|
25
|
+
# Or via pnpm
|
|
26
|
+
pnpm add -D @aristobyte-ui/switch
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 🛠 Usage
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { Switch } from "@aristobyte-ui/switch";
|
|
33
|
+
|
|
34
|
+
export const Demo = () => (
|
|
35
|
+
<Switch
|
|
36
|
+
label="Enable notifications"
|
|
37
|
+
alignLabel="horizontal"
|
|
38
|
+
switchSize="md"
|
|
39
|
+
variant="primary"
|
|
40
|
+
checked={true}
|
|
41
|
+
onChange={() => console.log("Toggled!")}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## 📂 Presets Available
|
|
47
|
+
|
|
48
|
+
**alignLabel**: `"horizontal"` | `"vertical"` (default: `"vertical"`)
|
|
49
|
+
|
|
50
|
+
**switchSize**: `"xsm"` | `"sm"` | `"md"` | `"lg"` | `"xlg"` (default: `"md"`)
|
|
51
|
+
|
|
52
|
+
**variant**: `"default"` | `"primary"` | `"secondary"` | `"success"` | `"error"` | `"warning"` (default: `"default"`)
|
|
53
|
+
|
|
54
|
+
**trackIcon** & **thumbIcon**: Optional React components for custom icons
|
|
55
|
+
|
|
56
|
+
**disabled**: Boolean flag to disable switch
|
|
57
|
+
|
|
58
|
+
## 🔧 Example in a Package
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
<Switch
|
|
62
|
+
label="Dark Mode"
|
|
63
|
+
switchSize="lg"
|
|
64
|
+
variant="secondary"
|
|
65
|
+
trackIcon={{ checked: CheckIcon, unchecked: CloseIcon }}
|
|
66
|
+
thumbIcon={StarIcon}
|
|
67
|
+
checked={false}
|
|
68
|
+
/>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## 📊 Why This Matters
|
|
72
|
+
|
|
73
|
+
- **Performance-first:** Lightweight CSS transitions ensure smooth toggling with zero layout thrashing.
|
|
74
|
+
- **Fully typed:** TypeScript-first API for predictable integration and IDE autocomplete.
|
|
75
|
+
- **AristoByteUI ready:** Integrates seamlessly with design tokens and SCSS modules.
|
|
76
|
+
- **Flexible:** Supports multiple sizes, label alignments, variants, and custom icons.
|
|
77
|
+
|
|
78
|
+
## 🏆 Philosophy
|
|
79
|
+
|
|
80
|
+
- **Modular architecture:** Switch component is fully composable.
|
|
81
|
+
- **Declarative styling:** SCSS modules keep styles maintainable and scoped.
|
|
82
|
+
- **Strict typing & runtime flexibility:** Props fully typed while allowing runtime overrides.
|
|
83
|
+
- **Developer experience optimized:** Easy to use with predictable behavior and minimal boilerplate.
|
|
84
|
+
|
|
85
|
+
## 📜 License
|
|
86
|
+
|
|
87
|
+
[MIT](./LICENSE) © AristoByte
|
|
88
|
+
|
|
89
|
+
## 🛡 Shields Showcase
|
|
90
|
+
|
|
91
|
+
<p align="center">
|
|
92
|
+
<img src="https://img.shields.io/badge/Consistency-100%25-green?style=for-the-badge&logo=typescript" />
|
|
93
|
+
<img src="https://img.shields.io/badge/Maintained-Active-brightgreen?style=for-the-badge&logo=github" />
|
|
94
|
+
<img src="https://img.shields.io/badge/Strictness-High-critical?style=for-the-badge&logo=eslint" />
|
|
95
|
+
<img src="https://img.shields.io/badge/Declarations-Enabled-blue?style=for-the-badge&logo=typescript" />
|
|
96
|
+
<img src="https://img.shields.io/badge/Monorepo-Turbo-green?style=for-the-badge&logo=monorepo" />
|
|
97
|
+
<img src="https://img.shields.io/badge/Interop-ESM%2FCJS-orange?style=for-the-badge&logo=javascript" />
|
|
98
|
+
</p>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aristobyte-ui/switch",
|
|
3
3
|
"description": "A fully typed, customizable Switch/toggle component for React with multiple sizes, variants, label alignments, and optional icons. Built to integrate seamlessly with AristoByteUI design tokens and SCSS modules.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.6.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
7
7
|
"author": "AristoByte <info@aristobyte.com>",
|
|
@@ -39,15 +39,15 @@
|
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"main": "lib/
|
|
43
|
-
"module": "es/
|
|
44
|
-
"types": "es/
|
|
42
|
+
"main": "lib/index.js",
|
|
43
|
+
"module": "es/index.js",
|
|
44
|
+
"types": "es/index.d.ts",
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"react": "^19.1.0",
|
|
47
47
|
"react-dom": "^19.1.0",
|
|
48
48
|
"sass": "^1.97.3"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@aristobyte-ui/utils": "2.
|
|
51
|
+
"@aristobyte-ui/utils": "^2.6.1"
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -1,486 +0,0 @@
|
|
|
1
|
-
@use '@aristobyte-ui/utils/styles' as *;
|
|
2
|
-
|
|
3
|
-
.switch {
|
|
4
|
-
align-items: center;
|
|
5
|
-
cursor: pointer;
|
|
6
|
-
display: flex;
|
|
7
|
-
gap: 10px;
|
|
8
|
-
max-width: max-content;
|
|
9
|
-
user-select: none;
|
|
10
|
-
position: relative;
|
|
11
|
-
|
|
12
|
-
&-align-label {
|
|
13
|
-
&--horizontal {
|
|
14
|
-
flex-direction: row;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
&--vertical {
|
|
18
|
-
flex-direction: column;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
&--disabled {
|
|
23
|
-
opacity: 0.5;
|
|
24
|
-
cursor: not-allowed;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
&-size {
|
|
28
|
-
&--xsm {
|
|
29
|
-
.switch {
|
|
30
|
-
&__track {
|
|
31
|
-
height: 1rem;
|
|
32
|
-
width: 1.8rem;
|
|
33
|
-
|
|
34
|
-
&-icon {
|
|
35
|
-
height: calc(0.8rem - 0.16rem * 2);
|
|
36
|
-
width: calc(0.8rem - 0.16rem * 2);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
&__thumb {
|
|
41
|
-
border-radius: calc(0.8rem / 2);
|
|
42
|
-
height: 0.8rem;
|
|
43
|
-
left: 0.16rem;
|
|
44
|
-
width: 0.8rem;
|
|
45
|
-
|
|
46
|
-
&-icon {
|
|
47
|
-
height: 0.6rem;
|
|
48
|
-
width: 0.6rem;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
&__label {
|
|
53
|
-
color: $white;
|
|
54
|
-
font-size: 0.625rem; // 10px
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
input {
|
|
59
|
-
+ .switch__track .switch__track-icon {
|
|
60
|
-
&--checked {
|
|
61
|
-
left: -2rem;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
&--unchecked {
|
|
65
|
-
right: 0.18rem;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
&:checked + .switch__track {
|
|
70
|
-
.switch__track-icon {
|
|
71
|
-
&--checked {
|
|
72
|
-
left: 0.18rem;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
&--unchecked {
|
|
76
|
-
right: -2rem;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.switch__thumb {
|
|
81
|
-
transform: translate(calc(1.8rem - 0.8rem - 0.16rem * 2), -50%);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
&:active {
|
|
86
|
-
+ .switch__track .switch__thumb {
|
|
87
|
-
width: 1rem;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
&:checked + .switch__track .switch__thumb {
|
|
91
|
-
transform: translate(calc(0.8rem / 2 + 0.08rem), -50%);
|
|
92
|
-
width: 1rem;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
&--sm {
|
|
99
|
-
.switch {
|
|
100
|
-
&__track {
|
|
101
|
-
height: 1.4rem;
|
|
102
|
-
width: 2.6rem;
|
|
103
|
-
|
|
104
|
-
&-icon {
|
|
105
|
-
height: calc(1.2rem - 0.2rem * 2);
|
|
106
|
-
width: calc(1.2rem - 0.2rem * 2);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
&__thumb {
|
|
111
|
-
border-radius: calc(1rem / 2);
|
|
112
|
-
height: 1rem;
|
|
113
|
-
left: 0.2rem;
|
|
114
|
-
width: 1rem;
|
|
115
|
-
|
|
116
|
-
&-icon {
|
|
117
|
-
height: 0.8rem;
|
|
118
|
-
width: 0.8rem;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
&__label {
|
|
123
|
-
color: $white;
|
|
124
|
-
font-size: 0.75rem; // 12px
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
input {
|
|
129
|
-
+ .switch__track .switch__track-icon {
|
|
130
|
-
&--checked {
|
|
131
|
-
left: -2rem;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
&--unchecked {
|
|
135
|
-
right: 0.24rem;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
&:checked + .switch__track {
|
|
140
|
-
.switch__track-icon {
|
|
141
|
-
&--checked {
|
|
142
|
-
left: 0.24rem;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
&--unchecked {
|
|
146
|
-
right: -2rem;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.switch__thumb {
|
|
151
|
-
transform: translate(calc(2.6rem - 1rem - 0.2rem * 2), -50%);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
&:active {
|
|
156
|
-
+ .switch__track .switch__thumb {
|
|
157
|
-
width: 1.3rem;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
&:checked + .switch__track .switch__thumb {
|
|
161
|
-
transform: translate(calc(1.3rem / 2 + 0.25rem), -50%);
|
|
162
|
-
width: 1.3rem;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
&--md {
|
|
169
|
-
.switch {
|
|
170
|
-
&__track {
|
|
171
|
-
height: 1.6rem;
|
|
172
|
-
width: 3rem;
|
|
173
|
-
|
|
174
|
-
&-icon {
|
|
175
|
-
height: calc(1.4rem - 0.2rem * 2);
|
|
176
|
-
width: calc(1.4rem - 0.2rem * 2);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
&__thumb {
|
|
181
|
-
border-radius: calc(1.2rem / 2);
|
|
182
|
-
height: 1.2rem;
|
|
183
|
-
left: 0.2rem;
|
|
184
|
-
width: 1.2rem;
|
|
185
|
-
|
|
186
|
-
&-icon {
|
|
187
|
-
height: 0.9rem;
|
|
188
|
-
width: 0.9rem;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
&__label {
|
|
193
|
-
color: $white;
|
|
194
|
-
font-size: 0.875rem; // 14px
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
input {
|
|
199
|
-
+ .switch__track .switch__track-icon {
|
|
200
|
-
&--checked {
|
|
201
|
-
left: -2rem;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
&--unchecked {
|
|
205
|
-
right: 0.3rem;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
&:checked + .switch__track {
|
|
210
|
-
.switch__track-icon {
|
|
211
|
-
&--checked {
|
|
212
|
-
left: 0.3rem;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
&--unchecked {
|
|
216
|
-
right: -2rem;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.switch__thumb {
|
|
221
|
-
transform: translate(calc(3rem - 1.2rem - 0.2rem * 2), -50%);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
&:active {
|
|
225
|
-
+ .switch__track .switch__thumb {
|
|
226
|
-
width: 1.5rem;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
&:checked + .switch__track .switch__thumb {
|
|
230
|
-
transform: translate(calc(1.5rem / 2 + 0.3rem), -50%);
|
|
231
|
-
width: 1.5rem;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
&--lg {
|
|
238
|
-
.switch {
|
|
239
|
-
&__track {
|
|
240
|
-
height: 1.8rem;
|
|
241
|
-
width: 3.4rem;
|
|
242
|
-
|
|
243
|
-
&-icon {
|
|
244
|
-
height: calc(1.6rem - 0.3rem * 2);
|
|
245
|
-
width: calc(1.6rem - 0.3rem * 2);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
&__thumb {
|
|
250
|
-
border-radius: calc(1.4rem / 2);
|
|
251
|
-
height: 1.4rem;
|
|
252
|
-
left: 0.3rem;
|
|
253
|
-
width: 1.4rem;
|
|
254
|
-
|
|
255
|
-
&-icon {
|
|
256
|
-
height: 1rem;
|
|
257
|
-
width: 1rem;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
&__label {
|
|
262
|
-
color: $white;
|
|
263
|
-
font-size: 1rem; // 16px
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
input {
|
|
268
|
-
+ .switch__track .switch__track-icon {
|
|
269
|
-
&--checked {
|
|
270
|
-
left: -2rem;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
&--unchecked {
|
|
274
|
-
right: 0.34rem;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
&:checked + .switch__track {
|
|
279
|
-
.switch__track-icon {
|
|
280
|
-
&--checked {
|
|
281
|
-
left: 0.34rem;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
&--unchecked {
|
|
285
|
-
right: -2rem;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
.switch__thumb {
|
|
290
|
-
transform: translate(calc(3.4rem - 1.4rem - 0.3rem * 2 + 0.05rem), -50%);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
&:active {
|
|
295
|
-
+ .switch__track .switch__thumb {
|
|
296
|
-
width: 1.8rem;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
&:checked + .switch__track .switch__thumb {
|
|
300
|
-
transform: translate(calc(1.8rem / 2 + 0.2rem - 0.05rem), -50%);
|
|
301
|
-
width: 1.8rem;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
&--xlg {
|
|
308
|
-
.switch {
|
|
309
|
-
&__track {
|
|
310
|
-
height: 2rem;
|
|
311
|
-
width: 3.8rem;
|
|
312
|
-
|
|
313
|
-
&-icon {
|
|
314
|
-
height: calc(1.8rem - 0.3rem * 2);
|
|
315
|
-
width: calc(1.8rem - 0.3rem * 2);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
&__thumb {
|
|
320
|
-
border-radius: calc(1.6rem / 2);
|
|
321
|
-
height: 1.6rem;
|
|
322
|
-
left: 0.3rem;
|
|
323
|
-
width: 1.6rem;
|
|
324
|
-
|
|
325
|
-
&-icon {
|
|
326
|
-
height: 1.2rem;
|
|
327
|
-
width: 1.2rem;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
&__label {
|
|
332
|
-
color: $white;
|
|
333
|
-
font-size: 1.125rem; // 18px
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
input {
|
|
338
|
-
+ .switch__track .switch__track-icon {
|
|
339
|
-
&--checked {
|
|
340
|
-
left: -2rem;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
&--unchecked {
|
|
344
|
-
right: 0.38rem;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
&:checked + .switch__track {
|
|
349
|
-
.switch__track-icon {
|
|
350
|
-
&--checked {
|
|
351
|
-
left: 0.38rem;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
&--unchecked {
|
|
355
|
-
right: -2rem;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
.switch__thumb {
|
|
360
|
-
transform: translate(calc(3.8rem - 1.6rem - 0.3rem * 2), -50%);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
&:active {
|
|
365
|
-
+ .switch__track .switch__thumb {
|
|
366
|
-
width: 2rem;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
&:checked + .switch__track .switch__thumb {
|
|
370
|
-
transform: translate(calc(2rem / 2 + 0.22rem), -50%);
|
|
371
|
-
width: 2rem;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
&-variant--default input:checked + &__track {
|
|
379
|
-
background-color: $grey-500;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
&-variant--primary input:checked + &__track {
|
|
383
|
-
background-color: $color-primary;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
&-variant--secondary input:checked + &__track {
|
|
387
|
-
background-color: $color-secondary;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
&-variant--success input:checked + &__track {
|
|
391
|
-
background-color: $color-success;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
&-variant--error input:checked + &__track {
|
|
395
|
-
background-color: $color-error;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
&-variant--warning input:checked + &__track {
|
|
399
|
-
background-color: $color-warning;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
input {
|
|
403
|
-
display: none;
|
|
404
|
-
|
|
405
|
-
+ .switch__track .switch__track-icon {
|
|
406
|
-
&--checked {
|
|
407
|
-
opacity: 0;
|
|
408
|
-
transform: translate(0, -50%) scale(0.55);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
&--unchecked {
|
|
412
|
-
opacity: 1;
|
|
413
|
-
transform: translate(0, -50%) scale(1);
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
&:checked {
|
|
418
|
-
+ .switch__track .switch__track-icon {
|
|
419
|
-
&--checked {
|
|
420
|
-
opacity: 1;
|
|
421
|
-
transform: translate(0, -50%) scale(1);
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
&--unchecked {
|
|
425
|
-
opacity: 0;
|
|
426
|
-
transform: translate(0, -50%) scale(0.55);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
&__track {
|
|
433
|
-
position: relative;
|
|
434
|
-
background-color: $grey-700;
|
|
435
|
-
border-radius: 999px;
|
|
436
|
-
overflow: hidden;
|
|
437
|
-
position: relative;
|
|
438
|
-
transition: background-color 0.3s ease;
|
|
439
|
-
|
|
440
|
-
&-icon {
|
|
441
|
-
align-items: center;
|
|
442
|
-
display: flex;
|
|
443
|
-
justify-content: center;
|
|
444
|
-
position: absolute;
|
|
445
|
-
top: 50%;
|
|
446
|
-
transition:
|
|
447
|
-
transform 120ms ease-out,
|
|
448
|
-
left 200ms ease-out,
|
|
449
|
-
right 200ms ease-out,
|
|
450
|
-
opacity 100ms ease-out;
|
|
451
|
-
z-index: 0;
|
|
452
|
-
|
|
453
|
-
svg {
|
|
454
|
-
height: 100%;
|
|
455
|
-
width: 100%;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
&__thumb {
|
|
461
|
-
align-items: center;
|
|
462
|
-
background-color: white;
|
|
463
|
-
display: flex;
|
|
464
|
-
justify-content: center;
|
|
465
|
-
position: absolute;
|
|
466
|
-
top: 50%;
|
|
467
|
-
transform: translate(0, -50%);
|
|
468
|
-
transition: all 200ms ease-out;
|
|
469
|
-
z-index: 1;
|
|
470
|
-
|
|
471
|
-
&-icon {
|
|
472
|
-
align-items: center;
|
|
473
|
-
display: flex;
|
|
474
|
-
justify-content: center;
|
|
475
|
-
|
|
476
|
-
svg {
|
|
477
|
-
height: 100%;
|
|
478
|
-
width: 100%;
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
&__label {
|
|
484
|
-
color: $white;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { type IconPropsType } from '@aristobyte-ui/utils';
|
|
3
|
-
import './Switch.scss';
|
|
4
|
-
export interface ISwitch {
|
|
5
|
-
onChange?: () => void;
|
|
6
|
-
label?: string;
|
|
7
|
-
alignLabel?: 'horizontal' | 'vertical';
|
|
8
|
-
switchSize?: 'xsm' | 'sm' | 'md' | 'lg' | 'xlg';
|
|
9
|
-
variant?: 'default' | 'primary' | 'secondary' | 'success' | 'error' | 'warning';
|
|
10
|
-
trackIcon?: {
|
|
11
|
-
checked?: {
|
|
12
|
-
component: (props: IconPropsType) => React.JSX.Element;
|
|
13
|
-
size?: number;
|
|
14
|
-
color?: string;
|
|
15
|
-
};
|
|
16
|
-
unchecked?: {
|
|
17
|
-
component: (props: IconPropsType) => React.JSX.Element;
|
|
18
|
-
size?: number;
|
|
19
|
-
color?: string;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
thumbIcon?: {
|
|
23
|
-
component: (props: IconPropsType) => React.JSX.Element;
|
|
24
|
-
size?: number;
|
|
25
|
-
color?: string;
|
|
26
|
-
};
|
|
27
|
-
checked?: boolean;
|
|
28
|
-
disabled?: boolean;
|
|
29
|
-
className?: string;
|
|
30
|
-
style?: React.CSSProperties;
|
|
31
|
-
}
|
|
32
|
-
export declare const Switch: React.FC<ISwitch>;
|
|
33
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/switch/src/main/components/Switch/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,eAAe,CAAC;AAEvB,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACvC,UAAU,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;IAChD,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IAChF,SAAS,CAAC,EAAE;QACV,OAAO,CAAC,EAAE;YACR,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;YACvD,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,KAAK,CAAC,EAAE,MAAM,CAAC;SAChB,CAAC;QACF,SAAS,CAAC,EAAE;YACV,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;YACvD,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,KAAK,CAAC,EAAE,MAAM,CAAC;SAChB,CAAC;KACH,CAAC;IACF,SAAS,CAAC,EAAE;QACV,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;QACvD,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAGD,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,OAAO,CA4DpC,CAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
import * as React from 'react';
|
|
19
|
-
import './Switch.scss';
|
|
20
|
-
export var Switch = function (_a) {
|
|
21
|
-
var onChange = _a.onChange, label = _a.label, _b = _a.alignLabel, alignLabel = _b === void 0 ? 'vertical' : _b, checked = _a.checked, _c = _a.switchSize, switchSize = _c === void 0 ? 'md' : _c, _d = _a.variant, variant = _d === void 0 ? 'default' : _d, _e = _a.disabled, disabled = _e === void 0 ? false : _e, trackIcon = _a.trackIcon, thumbIcon = _a.thumbIcon, _f = _a.className, className = _f === void 0 ? '' : _f, _g = _a.style, style = _g === void 0 ? {} : _g;
|
|
22
|
-
var id = React.useId();
|
|
23
|
-
var _h = __read(React.useState(!!checked), 2), isChecked = _h[0], setIsChecked = _h[1];
|
|
24
|
-
var handleChange = function () {
|
|
25
|
-
setIsChecked(function (prev) { return !prev; });
|
|
26
|
-
if (onChange)
|
|
27
|
-
onChange();
|
|
28
|
-
};
|
|
29
|
-
return (React.createElement("label", { htmlFor: id, className: "switch ".concat("switch-size--".concat(switchSize), " ").concat("switch-variant--".concat(variant), " ").concat("switch-align-label--".concat(alignLabel), " ").concat(disabled ? 'switch--disabled' : '', " ").concat(className), style: style },
|
|
30
|
-
React.createElement("input", { id: id, type: "checkbox", disabled: disabled, checked: isChecked, onChange: handleChange }),
|
|
31
|
-
React.createElement("span", { className: "switch__track" },
|
|
32
|
-
trackIcon && trackIcon.checked && (React.createElement("span", { className: "switch__track-icon ".concat('switch__track-icon--checked') }, trackIcon.checked.component({
|
|
33
|
-
size: trackIcon.checked.size,
|
|
34
|
-
color: trackIcon.checked.color,
|
|
35
|
-
}))),
|
|
36
|
-
React.createElement("span", { className: 'switch__thumb' }, thumbIcon && (React.createElement("span", { className: 'switch__thumb-icon' }, thumbIcon.component({
|
|
37
|
-
size: thumbIcon.size,
|
|
38
|
-
color: thumbIcon.color,
|
|
39
|
-
})))),
|
|
40
|
-
trackIcon && trackIcon.unchecked && (React.createElement("span", { className: "".concat('switch__track-icon', " ").concat('switch__track-icon--unchecked') }, trackIcon.unchecked.component({
|
|
41
|
-
size: trackIcon.unchecked.size,
|
|
42
|
-
color: trackIcon.unchecked.color,
|
|
43
|
-
})))),
|
|
44
|
-
label && React.createElement("span", { className: 'switch__label' }, label)));
|
|
45
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/switch/src/main/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Switch';
|
package/es/src/main/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/switch/src/main/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
package/es/src/main/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './components';
|
|
@@ -1,486 +0,0 @@
|
|
|
1
|
-
@use '@aristobyte-ui/utils/styles' as *;
|
|
2
|
-
|
|
3
|
-
.switch {
|
|
4
|
-
align-items: center;
|
|
5
|
-
cursor: pointer;
|
|
6
|
-
display: flex;
|
|
7
|
-
gap: 10px;
|
|
8
|
-
max-width: max-content;
|
|
9
|
-
user-select: none;
|
|
10
|
-
position: relative;
|
|
11
|
-
|
|
12
|
-
&-align-label {
|
|
13
|
-
&--horizontal {
|
|
14
|
-
flex-direction: row;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
&--vertical {
|
|
18
|
-
flex-direction: column;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
&--disabled {
|
|
23
|
-
opacity: 0.5;
|
|
24
|
-
cursor: not-allowed;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
&-size {
|
|
28
|
-
&--xsm {
|
|
29
|
-
.switch {
|
|
30
|
-
&__track {
|
|
31
|
-
height: 1rem;
|
|
32
|
-
width: 1.8rem;
|
|
33
|
-
|
|
34
|
-
&-icon {
|
|
35
|
-
height: calc(0.8rem - 0.16rem * 2);
|
|
36
|
-
width: calc(0.8rem - 0.16rem * 2);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
&__thumb {
|
|
41
|
-
border-radius: calc(0.8rem / 2);
|
|
42
|
-
height: 0.8rem;
|
|
43
|
-
left: 0.16rem;
|
|
44
|
-
width: 0.8rem;
|
|
45
|
-
|
|
46
|
-
&-icon {
|
|
47
|
-
height: 0.6rem;
|
|
48
|
-
width: 0.6rem;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
&__label {
|
|
53
|
-
color: $white;
|
|
54
|
-
font-size: 0.625rem; // 10px
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
input {
|
|
59
|
-
+ .switch__track .switch__track-icon {
|
|
60
|
-
&--checked {
|
|
61
|
-
left: -2rem;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
&--unchecked {
|
|
65
|
-
right: 0.18rem;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
&:checked + .switch__track {
|
|
70
|
-
.switch__track-icon {
|
|
71
|
-
&--checked {
|
|
72
|
-
left: 0.18rem;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
&--unchecked {
|
|
76
|
-
right: -2rem;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.switch__thumb {
|
|
81
|
-
transform: translate(calc(1.8rem - 0.8rem - 0.16rem * 2), -50%);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
&:active {
|
|
86
|
-
+ .switch__track .switch__thumb {
|
|
87
|
-
width: 1rem;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
&:checked + .switch__track .switch__thumb {
|
|
91
|
-
transform: translate(calc(0.8rem / 2 + 0.08rem), -50%);
|
|
92
|
-
width: 1rem;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
&--sm {
|
|
99
|
-
.switch {
|
|
100
|
-
&__track {
|
|
101
|
-
height: 1.4rem;
|
|
102
|
-
width: 2.6rem;
|
|
103
|
-
|
|
104
|
-
&-icon {
|
|
105
|
-
height: calc(1.2rem - 0.2rem * 2);
|
|
106
|
-
width: calc(1.2rem - 0.2rem * 2);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
&__thumb {
|
|
111
|
-
border-radius: calc(1rem / 2);
|
|
112
|
-
height: 1rem;
|
|
113
|
-
left: 0.2rem;
|
|
114
|
-
width: 1rem;
|
|
115
|
-
|
|
116
|
-
&-icon {
|
|
117
|
-
height: 0.8rem;
|
|
118
|
-
width: 0.8rem;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
&__label {
|
|
123
|
-
color: $white;
|
|
124
|
-
font-size: 0.75rem; // 12px
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
input {
|
|
129
|
-
+ .switch__track .switch__track-icon {
|
|
130
|
-
&--checked {
|
|
131
|
-
left: -2rem;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
&--unchecked {
|
|
135
|
-
right: 0.24rem;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
&:checked + .switch__track {
|
|
140
|
-
.switch__track-icon {
|
|
141
|
-
&--checked {
|
|
142
|
-
left: 0.24rem;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
&--unchecked {
|
|
146
|
-
right: -2rem;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.switch__thumb {
|
|
151
|
-
transform: translate(calc(2.6rem - 1rem - 0.2rem * 2), -50%);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
&:active {
|
|
156
|
-
+ .switch__track .switch__thumb {
|
|
157
|
-
width: 1.3rem;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
&:checked + .switch__track .switch__thumb {
|
|
161
|
-
transform: translate(calc(1.3rem / 2 + 0.25rem), -50%);
|
|
162
|
-
width: 1.3rem;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
&--md {
|
|
169
|
-
.switch {
|
|
170
|
-
&__track {
|
|
171
|
-
height: 1.6rem;
|
|
172
|
-
width: 3rem;
|
|
173
|
-
|
|
174
|
-
&-icon {
|
|
175
|
-
height: calc(1.4rem - 0.2rem * 2);
|
|
176
|
-
width: calc(1.4rem - 0.2rem * 2);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
&__thumb {
|
|
181
|
-
border-radius: calc(1.2rem / 2);
|
|
182
|
-
height: 1.2rem;
|
|
183
|
-
left: 0.2rem;
|
|
184
|
-
width: 1.2rem;
|
|
185
|
-
|
|
186
|
-
&-icon {
|
|
187
|
-
height: 0.9rem;
|
|
188
|
-
width: 0.9rem;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
&__label {
|
|
193
|
-
color: $white;
|
|
194
|
-
font-size: 0.875rem; // 14px
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
input {
|
|
199
|
-
+ .switch__track .switch__track-icon {
|
|
200
|
-
&--checked {
|
|
201
|
-
left: -2rem;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
&--unchecked {
|
|
205
|
-
right: 0.3rem;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
&:checked + .switch__track {
|
|
210
|
-
.switch__track-icon {
|
|
211
|
-
&--checked {
|
|
212
|
-
left: 0.3rem;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
&--unchecked {
|
|
216
|
-
right: -2rem;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.switch__thumb {
|
|
221
|
-
transform: translate(calc(3rem - 1.2rem - 0.2rem * 2), -50%);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
&:active {
|
|
225
|
-
+ .switch__track .switch__thumb {
|
|
226
|
-
width: 1.5rem;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
&:checked + .switch__track .switch__thumb {
|
|
230
|
-
transform: translate(calc(1.5rem / 2 + 0.3rem), -50%);
|
|
231
|
-
width: 1.5rem;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
&--lg {
|
|
238
|
-
.switch {
|
|
239
|
-
&__track {
|
|
240
|
-
height: 1.8rem;
|
|
241
|
-
width: 3.4rem;
|
|
242
|
-
|
|
243
|
-
&-icon {
|
|
244
|
-
height: calc(1.6rem - 0.3rem * 2);
|
|
245
|
-
width: calc(1.6rem - 0.3rem * 2);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
&__thumb {
|
|
250
|
-
border-radius: calc(1.4rem / 2);
|
|
251
|
-
height: 1.4rem;
|
|
252
|
-
left: 0.3rem;
|
|
253
|
-
width: 1.4rem;
|
|
254
|
-
|
|
255
|
-
&-icon {
|
|
256
|
-
height: 1rem;
|
|
257
|
-
width: 1rem;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
&__label {
|
|
262
|
-
color: $white;
|
|
263
|
-
font-size: 1rem; // 16px
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
input {
|
|
268
|
-
+ .switch__track .switch__track-icon {
|
|
269
|
-
&--checked {
|
|
270
|
-
left: -2rem;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
&--unchecked {
|
|
274
|
-
right: 0.34rem;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
&:checked + .switch__track {
|
|
279
|
-
.switch__track-icon {
|
|
280
|
-
&--checked {
|
|
281
|
-
left: 0.34rem;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
&--unchecked {
|
|
285
|
-
right: -2rem;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
.switch__thumb {
|
|
290
|
-
transform: translate(calc(3.4rem - 1.4rem - 0.3rem * 2 + 0.05rem), -50%);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
&:active {
|
|
295
|
-
+ .switch__track .switch__thumb {
|
|
296
|
-
width: 1.8rem;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
&:checked + .switch__track .switch__thumb {
|
|
300
|
-
transform: translate(calc(1.8rem / 2 + 0.2rem - 0.05rem), -50%);
|
|
301
|
-
width: 1.8rem;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
&--xlg {
|
|
308
|
-
.switch {
|
|
309
|
-
&__track {
|
|
310
|
-
height: 2rem;
|
|
311
|
-
width: 3.8rem;
|
|
312
|
-
|
|
313
|
-
&-icon {
|
|
314
|
-
height: calc(1.8rem - 0.3rem * 2);
|
|
315
|
-
width: calc(1.8rem - 0.3rem * 2);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
&__thumb {
|
|
320
|
-
border-radius: calc(1.6rem / 2);
|
|
321
|
-
height: 1.6rem;
|
|
322
|
-
left: 0.3rem;
|
|
323
|
-
width: 1.6rem;
|
|
324
|
-
|
|
325
|
-
&-icon {
|
|
326
|
-
height: 1.2rem;
|
|
327
|
-
width: 1.2rem;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
&__label {
|
|
332
|
-
color: $white;
|
|
333
|
-
font-size: 1.125rem; // 18px
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
input {
|
|
338
|
-
+ .switch__track .switch__track-icon {
|
|
339
|
-
&--checked {
|
|
340
|
-
left: -2rem;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
&--unchecked {
|
|
344
|
-
right: 0.38rem;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
&:checked + .switch__track {
|
|
349
|
-
.switch__track-icon {
|
|
350
|
-
&--checked {
|
|
351
|
-
left: 0.38rem;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
&--unchecked {
|
|
355
|
-
right: -2rem;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
.switch__thumb {
|
|
360
|
-
transform: translate(calc(3.8rem - 1.6rem - 0.3rem * 2), -50%);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
&:active {
|
|
365
|
-
+ .switch__track .switch__thumb {
|
|
366
|
-
width: 2rem;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
&:checked + .switch__track .switch__thumb {
|
|
370
|
-
transform: translate(calc(2rem / 2 + 0.22rem), -50%);
|
|
371
|
-
width: 2rem;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
&-variant--default input:checked + &__track {
|
|
379
|
-
background-color: $grey-500;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
&-variant--primary input:checked + &__track {
|
|
383
|
-
background-color: $color-primary;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
&-variant--secondary input:checked + &__track {
|
|
387
|
-
background-color: $color-secondary;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
&-variant--success input:checked + &__track {
|
|
391
|
-
background-color: $color-success;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
&-variant--error input:checked + &__track {
|
|
395
|
-
background-color: $color-error;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
&-variant--warning input:checked + &__track {
|
|
399
|
-
background-color: $color-warning;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
input {
|
|
403
|
-
display: none;
|
|
404
|
-
|
|
405
|
-
+ .switch__track .switch__track-icon {
|
|
406
|
-
&--checked {
|
|
407
|
-
opacity: 0;
|
|
408
|
-
transform: translate(0, -50%) scale(0.55);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
&--unchecked {
|
|
412
|
-
opacity: 1;
|
|
413
|
-
transform: translate(0, -50%) scale(1);
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
&:checked {
|
|
418
|
-
+ .switch__track .switch__track-icon {
|
|
419
|
-
&--checked {
|
|
420
|
-
opacity: 1;
|
|
421
|
-
transform: translate(0, -50%) scale(1);
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
&--unchecked {
|
|
425
|
-
opacity: 0;
|
|
426
|
-
transform: translate(0, -50%) scale(0.55);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
&__track {
|
|
433
|
-
position: relative;
|
|
434
|
-
background-color: $grey-700;
|
|
435
|
-
border-radius: 999px;
|
|
436
|
-
overflow: hidden;
|
|
437
|
-
position: relative;
|
|
438
|
-
transition: background-color 0.3s ease;
|
|
439
|
-
|
|
440
|
-
&-icon {
|
|
441
|
-
align-items: center;
|
|
442
|
-
display: flex;
|
|
443
|
-
justify-content: center;
|
|
444
|
-
position: absolute;
|
|
445
|
-
top: 50%;
|
|
446
|
-
transition:
|
|
447
|
-
transform 120ms ease-out,
|
|
448
|
-
left 200ms ease-out,
|
|
449
|
-
right 200ms ease-out,
|
|
450
|
-
opacity 100ms ease-out;
|
|
451
|
-
z-index: 0;
|
|
452
|
-
|
|
453
|
-
svg {
|
|
454
|
-
height: 100%;
|
|
455
|
-
width: 100%;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
&__thumb {
|
|
461
|
-
align-items: center;
|
|
462
|
-
background-color: white;
|
|
463
|
-
display: flex;
|
|
464
|
-
justify-content: center;
|
|
465
|
-
position: absolute;
|
|
466
|
-
top: 50%;
|
|
467
|
-
transform: translate(0, -50%);
|
|
468
|
-
transition: all 200ms ease-out;
|
|
469
|
-
z-index: 1;
|
|
470
|
-
|
|
471
|
-
&-icon {
|
|
472
|
-
align-items: center;
|
|
473
|
-
display: flex;
|
|
474
|
-
justify-content: center;
|
|
475
|
-
|
|
476
|
-
svg {
|
|
477
|
-
height: 100%;
|
|
478
|
-
width: 100%;
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
&__label {
|
|
484
|
-
color: $white;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { type IconPropsType } from '@aristobyte-ui/utils';
|
|
3
|
-
import './Switch.scss';
|
|
4
|
-
export interface ISwitch {
|
|
5
|
-
onChange?: () => void;
|
|
6
|
-
label?: string;
|
|
7
|
-
alignLabel?: 'horizontal' | 'vertical';
|
|
8
|
-
switchSize?: 'xsm' | 'sm' | 'md' | 'lg' | 'xlg';
|
|
9
|
-
variant?: 'default' | 'primary' | 'secondary' | 'success' | 'error' | 'warning';
|
|
10
|
-
trackIcon?: {
|
|
11
|
-
checked?: {
|
|
12
|
-
component: (props: IconPropsType) => React.JSX.Element;
|
|
13
|
-
size?: number;
|
|
14
|
-
color?: string;
|
|
15
|
-
};
|
|
16
|
-
unchecked?: {
|
|
17
|
-
component: (props: IconPropsType) => React.JSX.Element;
|
|
18
|
-
size?: number;
|
|
19
|
-
color?: string;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
thumbIcon?: {
|
|
23
|
-
component: (props: IconPropsType) => React.JSX.Element;
|
|
24
|
-
size?: number;
|
|
25
|
-
color?: string;
|
|
26
|
-
};
|
|
27
|
-
checked?: boolean;
|
|
28
|
-
disabled?: boolean;
|
|
29
|
-
className?: string;
|
|
30
|
-
style?: React.CSSProperties;
|
|
31
|
-
}
|
|
32
|
-
export declare const Switch: React.FC<ISwitch>;
|
|
33
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/switch/src/main/components/Switch/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,eAAe,CAAC;AAEvB,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACvC,UAAU,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;IAChD,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IAChF,SAAS,CAAC,EAAE;QACV,OAAO,CAAC,EAAE;YACR,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;YACvD,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,KAAK,CAAC,EAAE,MAAM,CAAC;SAChB,CAAC;QACF,SAAS,CAAC,EAAE;YACV,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;YACvD,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,KAAK,CAAC,EAAE,MAAM,CAAC;SAChB,CAAC;KACH,CAAC;IACF,SAAS,CAAC,EAAE;QACV,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;QACvD,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAGD,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,OAAO,CA4DpC,CAAC"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
'use client';
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
-
var ownKeys = function(o) {
|
|
21
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
-
var ar = [];
|
|
23
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
-
return ar;
|
|
25
|
-
};
|
|
26
|
-
return ownKeys(o);
|
|
27
|
-
};
|
|
28
|
-
return function (mod) {
|
|
29
|
-
if (mod && mod.__esModule) return mod;
|
|
30
|
-
var result = {};
|
|
31
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
-
__setModuleDefault(result, mod);
|
|
33
|
-
return result;
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
37
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
38
|
-
if (!m) return o;
|
|
39
|
-
var i = m.call(o), r, ar = [], e;
|
|
40
|
-
try {
|
|
41
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
42
|
-
}
|
|
43
|
-
catch (error) { e = { error: error }; }
|
|
44
|
-
finally {
|
|
45
|
-
try {
|
|
46
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
47
|
-
}
|
|
48
|
-
finally { if (e) throw e.error; }
|
|
49
|
-
}
|
|
50
|
-
return ar;
|
|
51
|
-
};
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.Switch = void 0;
|
|
54
|
-
var React = __importStar(require("react"));
|
|
55
|
-
require("./Switch.scss");
|
|
56
|
-
var Switch = function (_a) {
|
|
57
|
-
var onChange = _a.onChange, label = _a.label, _b = _a.alignLabel, alignLabel = _b === void 0 ? 'vertical' : _b, checked = _a.checked, _c = _a.switchSize, switchSize = _c === void 0 ? 'md' : _c, _d = _a.variant, variant = _d === void 0 ? 'default' : _d, _e = _a.disabled, disabled = _e === void 0 ? false : _e, trackIcon = _a.trackIcon, thumbIcon = _a.thumbIcon, _f = _a.className, className = _f === void 0 ? '' : _f, _g = _a.style, style = _g === void 0 ? {} : _g;
|
|
58
|
-
var id = React.useId();
|
|
59
|
-
var _h = __read(React.useState(!!checked), 2), isChecked = _h[0], setIsChecked = _h[1];
|
|
60
|
-
var handleChange = function () {
|
|
61
|
-
setIsChecked(function (prev) { return !prev; });
|
|
62
|
-
if (onChange)
|
|
63
|
-
onChange();
|
|
64
|
-
};
|
|
65
|
-
return (React.createElement("label", { htmlFor: id, className: "switch ".concat("switch-size--".concat(switchSize), " ").concat("switch-variant--".concat(variant), " ").concat("switch-align-label--".concat(alignLabel), " ").concat(disabled ? 'switch--disabled' : '', " ").concat(className), style: style },
|
|
66
|
-
React.createElement("input", { id: id, type: "checkbox", disabled: disabled, checked: isChecked, onChange: handleChange }),
|
|
67
|
-
React.createElement("span", { className: "switch__track" },
|
|
68
|
-
trackIcon && trackIcon.checked && (React.createElement("span", { className: "switch__track-icon ".concat('switch__track-icon--checked') }, trackIcon.checked.component({
|
|
69
|
-
size: trackIcon.checked.size,
|
|
70
|
-
color: trackIcon.checked.color,
|
|
71
|
-
}))),
|
|
72
|
-
React.createElement("span", { className: 'switch__thumb' }, thumbIcon && (React.createElement("span", { className: 'switch__thumb-icon' }, thumbIcon.component({
|
|
73
|
-
size: thumbIcon.size,
|
|
74
|
-
color: thumbIcon.color,
|
|
75
|
-
})))),
|
|
76
|
-
trackIcon && trackIcon.unchecked && (React.createElement("span", { className: "".concat('switch__track-icon', " ").concat('switch__track-icon--unchecked') }, trackIcon.unchecked.component({
|
|
77
|
-
size: trackIcon.unchecked.size,
|
|
78
|
-
color: trackIcon.unchecked.color,
|
|
79
|
-
})))),
|
|
80
|
-
label && React.createElement("span", { className: 'switch__label' }, label)));
|
|
81
|
-
};
|
|
82
|
-
exports.Switch = Switch;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/switch/src/main/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./Switch"), exports);
|
package/lib/src/main/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/switch/src/main/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
package/lib/src/main/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./components"), exports);
|