@ovotech/element-native 3.5.0-canary-8dee962-166 → 3.5.0-canary-e225e8b-167

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.
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ import { TouchableOpacity, TouchableOpacityProps } from 'react-native';
3
+ export declare type HorizontalPosition = 'left' | 'right';
4
+ export declare const Toggle: import("react").ForwardRefExoticComponent<Omit<TouchableOpacityProps, "children"> & {
5
+ label?: string | ReactNode;
6
+ checked?: boolean | undefined;
7
+ hint?: ReactNode;
8
+ labelPosition?: HorizontalPosition | undefined;
9
+ onChange?: (() => void) | undefined;
10
+ } & import("react").RefAttributes<TouchableOpacity>>;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.Toggle = void 0;
26
+ var jsx_runtime_1 = require("react/jsx-runtime");
27
+ var react_1 = require("react");
28
+ var react_native_1 = require("react-native");
29
+ var native_1 = require("styled-components/native");
30
+ var HintText_1 = require("../HintText/HintText");
31
+ var LabelText_1 = require("../LabelText");
32
+ var styles_1 = require("./styles");
33
+ var Input = function (_a) {
34
+ var checked = _a.checked, labelPosition = _a.labelPosition, testID = _a.testID, rest = __rest(_a, ["checked", "labelPosition", "testID"]);
35
+ var core = (0, react_1.useContext)(native_1.ThemeContext).core;
36
+ var leftVal = (0, react_1.useRef)(new react_native_1.Animated.Value(checked ? parseInt(core.space[6]) : parseInt(core.space[1]))).current;
37
+ (0, react_1.useEffect)(function () {
38
+ react_native_1.Animated.timing(leftVal, {
39
+ toValue: checked ? parseInt(core.space[6]) : parseInt(core.space[1]),
40
+ duration: 150,
41
+ useNativeDriver: true,
42
+ }).start();
43
+ }, [checked]);
44
+ return ((0, jsx_runtime_1.jsx)(styles_1.StyledToggleInputWrapper, __assign({ labelPosition: labelPosition }, rest, { children: (0, jsx_runtime_1.jsx)(styles_1.StyledToggleInput, __assign({ checked: checked, testID: testID }, { children: (0, jsx_runtime_1.jsx)(styles_1.StyledToggleDot, { style: {
45
+ transform: [{ translateX: leftVal }],
46
+ }, checked: checked }) })) })));
47
+ };
48
+ exports.Toggle = (0, react_1.forwardRef)(function (_a, ref) {
49
+ var label = _a.label, hint = _a.hint, _b = _a.checked, checked = _b === void 0 ? false : _b,
50
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
51
+ _c = _a.activeOpacity,
52
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
53
+ activeOpacity = _c === void 0 ? 0.8 : _c, testID = _a.testID, _d = _a.labelPosition, labelPosition = _d === void 0 ? 'left' : _d, rest = __rest(_a, ["label", "hint", "checked", "activeOpacity", "testID", "labelPosition"]);
54
+ var hasLabel = label !== undefined;
55
+ return ((0, jsx_runtime_1.jsxs)(styles_1.StyledWrapper, __assign({ ref: ref, accessibilityRole: "checkbox", activeOpacity: activeOpacity, accessibilityState: { checked: checked }, hitSlop: 10, hasLabel: hasLabel, labelPosition: labelPosition }, rest, { children: [hasLabel ? ((0, jsx_runtime_1.jsxs)(react_native_1.View, __assign({ style: { flexShrink: 1 } }, { children: [(0, jsx_runtime_1.jsx)(LabelText_1.LabelText, { children: label }), hint ? (0, jsx_runtime_1.jsx)(HintText_1.HintText, { children: hint }) : null] }))) : null, (0, jsx_runtime_1.jsx)(Input, { checked: checked, testID: testID, labelPosition: hasLabel ? labelPosition : undefined })] })));
56
+ });
@@ -0,0 +1 @@
1
+ export { Toggle } from './Toggle';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Toggle = void 0;
4
+ var Toggle_1 = require("./Toggle");
5
+ Object.defineProperty(exports, "Toggle", { enumerable: true, get: function () { return Toggle_1.Toggle; } });
@@ -0,0 +1,939 @@
1
+ import { Animated } from 'react-native';
2
+ import { HorizontalPosition } from './Toggle';
3
+ export declare const StyledWrapper: import("styled-components").StyledComponent<typeof import("react-native").TouchableOpacity, {
4
+ core: {
5
+ radius: Record<"small" | "medium" | "large" | "max", string>;
6
+ borderWidth: Record<"small" | "medium" | "large", string>;
7
+ breakpoint: Record<"small" | "medium" | "large", string | number>;
8
+ mediaQuery: Record<"small" | "medium" | "large", string>;
9
+ space: Record<0 | 2 | 1 | 3 | 4 | 5 | 10 | 6 | 7 | 8 | 9 | 11 | 12 | 13 | 14 | 15, string>;
10
+ transition: Record<"medium" | "slow" | "fast", string>;
11
+ opacity: Record<"solid" | "transparent" | "translucent", string | number>;
12
+ color: Record<"neutral" | "red" | "orange" | "yellow" | "green" | "blue", {
13
+ lightest: string;
14
+ lighter: string;
15
+ light: string;
16
+ base: string;
17
+ dark: string;
18
+ darker: string;
19
+ darkest: string;
20
+ }> & {
21
+ brand: Record<string, string>;
22
+ };
23
+ fontFamily: Record<"body" | "mono" | "heading" | "bodyBold", {
24
+ native: string;
25
+ web: string;
26
+ }>;
27
+ fontWeight: Record<"bold" | "book" | "black", string | number>;
28
+ fontSize: Record<"small" | "body" | "label" | "heading1" | "heading2" | "heading3" | "heading4" | "lead", {
29
+ small: string | number;
30
+ large: string | number;
31
+ }>;
32
+ lineHeight: Record<"small" | "body" | "label" | "heading1" | "heading2" | "heading3" | "heading4" | "lead", {
33
+ small: string | number;
34
+ large: string | number;
35
+ }>;
36
+ letterSpacing: Record<"base" | "compressed" | "extraCompressed", number>;
37
+ };
38
+ semantic: {
39
+ surface: Record<"base" | "cutout" | "elevated", string>;
40
+ message: Record<"base" | "link" | "secondary" | "error" | "branded", string>;
41
+ border: Record<"graphic" | "differentiated" | "functional", string>;
42
+ focus: Record<"surface" | "outline" | "hover", string>;
43
+ inverted: Record<"surface" | "border", string> & {
44
+ message: Record<"base" | "link" | "secondary" | "branded", string>;
45
+ };
46
+ success: {
47
+ border: string;
48
+ surface: string;
49
+ surfaceEmphasis: string;
50
+ message: string;
51
+ messageOnEmphasis: string;
52
+ };
53
+ warning: {
54
+ border: string;
55
+ surface: string;
56
+ surfaceEmphasis: string;
57
+ message: string;
58
+ messageOnEmphasis: string;
59
+ };
60
+ error: {
61
+ border: string;
62
+ surface: string;
63
+ surfaceEmphasis: string;
64
+ message: string;
65
+ messageOnEmphasis: string;
66
+ };
67
+ info: {
68
+ border: string;
69
+ surface: string;
70
+ surfaceEmphasis: string;
71
+ message: string;
72
+ messageOnEmphasis: string;
73
+ };
74
+ data: Record<"branded" | "gas" | "electric", Record<2 | 1 | 3 | 4, string>>;
75
+ };
76
+ component: {
77
+ heading1: {
78
+ fontFamily: string;
79
+ fontWeight: string | number;
80
+ fontSize: {
81
+ small: string | number;
82
+ large: string | number;
83
+ };
84
+ lineHeight: {
85
+ small: string | number;
86
+ large: string | number;
87
+ };
88
+ };
89
+ heading2: {
90
+ fontFamily: string;
91
+ fontWeight: string | number;
92
+ fontSize: {
93
+ small: string | number;
94
+ large: string | number;
95
+ };
96
+ lineHeight: {
97
+ small: string | number;
98
+ large: string | number;
99
+ };
100
+ };
101
+ heading3: {
102
+ fontFamily: string;
103
+ fontWeight: string | number;
104
+ fontSize: {
105
+ small: string | number;
106
+ large: string | number;
107
+ };
108
+ lineHeight: {
109
+ small: string | number;
110
+ large: string | number;
111
+ };
112
+ };
113
+ heading4: {
114
+ fontFamily: string;
115
+ fontWeight: string | number;
116
+ fontSize: {
117
+ small: string | number;
118
+ large: string | number;
119
+ };
120
+ lineHeight: {
121
+ small: string | number;
122
+ large: string | number;
123
+ };
124
+ };
125
+ lead: {
126
+ fontFamily: string;
127
+ fontWeight: string | number;
128
+ fontSize: {
129
+ small: string | number;
130
+ large: string | number;
131
+ };
132
+ lineHeight: {
133
+ small: string | number;
134
+ large: string | number;
135
+ };
136
+ };
137
+ body: {
138
+ fontFamily: string;
139
+ fontWeight: string | number;
140
+ fontSize: {
141
+ small: string | number;
142
+ large: string | number;
143
+ };
144
+ lineHeight: {
145
+ small: string | number;
146
+ large: string | number;
147
+ };
148
+ };
149
+ small: {
150
+ fontFamily: string;
151
+ fontWeight: string | number;
152
+ fontSize: {
153
+ small: string | number;
154
+ large: string | number;
155
+ };
156
+ lineHeight: {
157
+ small: string | number;
158
+ large: string | number;
159
+ };
160
+ };
161
+ label: {
162
+ fontFamily: string;
163
+ fontWeight: string | number;
164
+ fontSize: {
165
+ small: string | number;
166
+ large: string | number;
167
+ };
168
+ lineHeight: {
169
+ small: string | number;
170
+ large: string | number;
171
+ };
172
+ };
173
+ cta: {
174
+ primary: {
175
+ message: string;
176
+ surface: string;
177
+ messageHover: string;
178
+ surfaceHover: string;
179
+ messageFocused: string;
180
+ surfaceFocused: string;
181
+ outlineFocused: string;
182
+ backgroundFocused: string;
183
+ };
184
+ secondary: {
185
+ message: string;
186
+ surface: string;
187
+ messageHover: string;
188
+ surfaceHover: string;
189
+ messageFocused: string;
190
+ surfaceFocused: string;
191
+ outlineFocused: string;
192
+ backgroundFocused: string;
193
+ };
194
+ destructive: {
195
+ message: string;
196
+ surface: string;
197
+ messageHover: string;
198
+ surfaceHover: string;
199
+ messageFocused: string;
200
+ surfaceFocused: string;
201
+ outlineFocused: string;
202
+ backgroundFocused: string;
203
+ };
204
+ };
205
+ badge: {
206
+ variants: {
207
+ neutral: {
208
+ foreground: string;
209
+ background: string;
210
+ };
211
+ red: {
212
+ foreground: string;
213
+ background: string;
214
+ };
215
+ orange: {
216
+ foreground: string;
217
+ background: string;
218
+ };
219
+ yellow: {
220
+ foreground: string;
221
+ background: string;
222
+ };
223
+ green: {
224
+ foreground: string;
225
+ background: string;
226
+ };
227
+ blue: {
228
+ foreground: string;
229
+ background: string;
230
+ };
231
+ };
232
+ };
233
+ };
234
+ }, {
235
+ hasLabel?: boolean | undefined;
236
+ labelPosition?: HorizontalPosition | undefined;
237
+ }, never>;
238
+ export declare const StyledToggleInputWrapper: import("styled-components").StyledComponent<typeof import("react-native").View, {
239
+ core: {
240
+ radius: Record<"small" | "medium" | "large" | "max", string>;
241
+ borderWidth: Record<"small" | "medium" | "large", string>;
242
+ breakpoint: Record<"small" | "medium" | "large", string | number>;
243
+ mediaQuery: Record<"small" | "medium" | "large", string>;
244
+ space: Record<0 | 2 | 1 | 3 | 4 | 5 | 10 | 6 | 7 | 8 | 9 | 11 | 12 | 13 | 14 | 15, string>;
245
+ transition: Record<"medium" | "slow" | "fast", string>;
246
+ opacity: Record<"solid" | "transparent" | "translucent", string | number>;
247
+ color: Record<"neutral" | "red" | "orange" | "yellow" | "green" | "blue", {
248
+ lightest: string;
249
+ lighter: string;
250
+ light: string;
251
+ base: string;
252
+ dark: string;
253
+ darker: string;
254
+ darkest: string;
255
+ }> & {
256
+ brand: Record<string, string>;
257
+ };
258
+ fontFamily: Record<"body" | "mono" | "heading" | "bodyBold", {
259
+ native: string;
260
+ web: string;
261
+ }>;
262
+ fontWeight: Record<"bold" | "book" | "black", string | number>;
263
+ fontSize: Record<"small" | "body" | "label" | "heading1" | "heading2" | "heading3" | "heading4" | "lead", {
264
+ small: string | number;
265
+ large: string | number;
266
+ }>;
267
+ lineHeight: Record<"small" | "body" | "label" | "heading1" | "heading2" | "heading3" | "heading4" | "lead", {
268
+ small: string | number;
269
+ large: string | number;
270
+ }>;
271
+ letterSpacing: Record<"base" | "compressed" | "extraCompressed", number>;
272
+ };
273
+ semantic: {
274
+ surface: Record<"base" | "cutout" | "elevated", string>;
275
+ message: Record<"base" | "link" | "secondary" | "error" | "branded", string>;
276
+ border: Record<"graphic" | "differentiated" | "functional", string>;
277
+ focus: Record<"surface" | "outline" | "hover", string>;
278
+ inverted: Record<"surface" | "border", string> & {
279
+ message: Record<"base" | "link" | "secondary" | "branded", string>;
280
+ };
281
+ success: {
282
+ border: string;
283
+ surface: string;
284
+ surfaceEmphasis: string;
285
+ message: string;
286
+ messageOnEmphasis: string;
287
+ };
288
+ warning: {
289
+ border: string;
290
+ surface: string;
291
+ surfaceEmphasis: string;
292
+ message: string;
293
+ messageOnEmphasis: string;
294
+ };
295
+ error: {
296
+ border: string;
297
+ surface: string;
298
+ surfaceEmphasis: string;
299
+ message: string;
300
+ messageOnEmphasis: string;
301
+ };
302
+ info: {
303
+ border: string;
304
+ surface: string;
305
+ surfaceEmphasis: string;
306
+ message: string;
307
+ messageOnEmphasis: string;
308
+ };
309
+ data: Record<"branded" | "gas" | "electric", Record<2 | 1 | 3 | 4, string>>;
310
+ };
311
+ component: {
312
+ heading1: {
313
+ fontFamily: string;
314
+ fontWeight: string | number;
315
+ fontSize: {
316
+ small: string | number;
317
+ large: string | number;
318
+ };
319
+ lineHeight: {
320
+ small: string | number;
321
+ large: string | number;
322
+ };
323
+ };
324
+ heading2: {
325
+ fontFamily: string;
326
+ fontWeight: string | number;
327
+ fontSize: {
328
+ small: string | number;
329
+ large: string | number;
330
+ };
331
+ lineHeight: {
332
+ small: string | number;
333
+ large: string | number;
334
+ };
335
+ };
336
+ heading3: {
337
+ fontFamily: string;
338
+ fontWeight: string | number;
339
+ fontSize: {
340
+ small: string | number;
341
+ large: string | number;
342
+ };
343
+ lineHeight: {
344
+ small: string | number;
345
+ large: string | number;
346
+ };
347
+ };
348
+ heading4: {
349
+ fontFamily: string;
350
+ fontWeight: string | number;
351
+ fontSize: {
352
+ small: string | number;
353
+ large: string | number;
354
+ };
355
+ lineHeight: {
356
+ small: string | number;
357
+ large: string | number;
358
+ };
359
+ };
360
+ lead: {
361
+ fontFamily: string;
362
+ fontWeight: string | number;
363
+ fontSize: {
364
+ small: string | number;
365
+ large: string | number;
366
+ };
367
+ lineHeight: {
368
+ small: string | number;
369
+ large: string | number;
370
+ };
371
+ };
372
+ body: {
373
+ fontFamily: string;
374
+ fontWeight: string | number;
375
+ fontSize: {
376
+ small: string | number;
377
+ large: string | number;
378
+ };
379
+ lineHeight: {
380
+ small: string | number;
381
+ large: string | number;
382
+ };
383
+ };
384
+ small: {
385
+ fontFamily: string;
386
+ fontWeight: string | number;
387
+ fontSize: {
388
+ small: string | number;
389
+ large: string | number;
390
+ };
391
+ lineHeight: {
392
+ small: string | number;
393
+ large: string | number;
394
+ };
395
+ };
396
+ label: {
397
+ fontFamily: string;
398
+ fontWeight: string | number;
399
+ fontSize: {
400
+ small: string | number;
401
+ large: string | number;
402
+ };
403
+ lineHeight: {
404
+ small: string | number;
405
+ large: string | number;
406
+ };
407
+ };
408
+ cta: {
409
+ primary: {
410
+ message: string;
411
+ surface: string;
412
+ messageHover: string;
413
+ surfaceHover: string;
414
+ messageFocused: string;
415
+ surfaceFocused: string;
416
+ outlineFocused: string;
417
+ backgroundFocused: string;
418
+ };
419
+ secondary: {
420
+ message: string;
421
+ surface: string;
422
+ messageHover: string;
423
+ surfaceHover: string;
424
+ messageFocused: string;
425
+ surfaceFocused: string;
426
+ outlineFocused: string;
427
+ backgroundFocused: string;
428
+ };
429
+ destructive: {
430
+ message: string;
431
+ surface: string;
432
+ messageHover: string;
433
+ surfaceHover: string;
434
+ messageFocused: string;
435
+ surfaceFocused: string;
436
+ outlineFocused: string;
437
+ backgroundFocused: string;
438
+ };
439
+ };
440
+ badge: {
441
+ variants: {
442
+ neutral: {
443
+ foreground: string;
444
+ background: string;
445
+ };
446
+ red: {
447
+ foreground: string;
448
+ background: string;
449
+ };
450
+ orange: {
451
+ foreground: string;
452
+ background: string;
453
+ };
454
+ yellow: {
455
+ foreground: string;
456
+ background: string;
457
+ };
458
+ green: {
459
+ foreground: string;
460
+ background: string;
461
+ };
462
+ blue: {
463
+ foreground: string;
464
+ background: string;
465
+ };
466
+ };
467
+ };
468
+ };
469
+ }, {
470
+ labelPosition?: HorizontalPosition | undefined;
471
+ }, never>;
472
+ export declare const StyledToggleInput: import("styled-components").StyledComponent<typeof import("react-native").View, {
473
+ core: {
474
+ radius: Record<"small" | "medium" | "large" | "max", string>;
475
+ borderWidth: Record<"small" | "medium" | "large", string>;
476
+ breakpoint: Record<"small" | "medium" | "large", string | number>;
477
+ mediaQuery: Record<"small" | "medium" | "large", string>;
478
+ space: Record<0 | 2 | 1 | 3 | 4 | 5 | 10 | 6 | 7 | 8 | 9 | 11 | 12 | 13 | 14 | 15, string>;
479
+ transition: Record<"medium" | "slow" | "fast", string>;
480
+ opacity: Record<"solid" | "transparent" | "translucent", string | number>;
481
+ color: Record<"neutral" | "red" | "orange" | "yellow" | "green" | "blue", {
482
+ lightest: string;
483
+ lighter: string;
484
+ light: string;
485
+ base: string;
486
+ dark: string;
487
+ darker: string;
488
+ darkest: string;
489
+ }> & {
490
+ brand: Record<string, string>;
491
+ };
492
+ fontFamily: Record<"body" | "mono" | "heading" | "bodyBold", {
493
+ native: string;
494
+ web: string;
495
+ }>;
496
+ fontWeight: Record<"bold" | "book" | "black", string | number>;
497
+ fontSize: Record<"small" | "body" | "label" | "heading1" | "heading2" | "heading3" | "heading4" | "lead", {
498
+ small: string | number;
499
+ large: string | number;
500
+ }>;
501
+ lineHeight: Record<"small" | "body" | "label" | "heading1" | "heading2" | "heading3" | "heading4" | "lead", {
502
+ small: string | number;
503
+ large: string | number;
504
+ }>;
505
+ letterSpacing: Record<"base" | "compressed" | "extraCompressed", number>;
506
+ };
507
+ semantic: {
508
+ surface: Record<"base" | "cutout" | "elevated", string>;
509
+ message: Record<"base" | "link" | "secondary" | "error" | "branded", string>;
510
+ border: Record<"graphic" | "differentiated" | "functional", string>;
511
+ focus: Record<"surface" | "outline" | "hover", string>;
512
+ inverted: Record<"surface" | "border", string> & {
513
+ message: Record<"base" | "link" | "secondary" | "branded", string>;
514
+ };
515
+ success: {
516
+ border: string;
517
+ surface: string;
518
+ surfaceEmphasis: string;
519
+ message: string;
520
+ messageOnEmphasis: string;
521
+ };
522
+ warning: {
523
+ border: string;
524
+ surface: string;
525
+ surfaceEmphasis: string;
526
+ message: string;
527
+ messageOnEmphasis: string;
528
+ };
529
+ error: {
530
+ border: string;
531
+ surface: string;
532
+ surfaceEmphasis: string;
533
+ message: string;
534
+ messageOnEmphasis: string;
535
+ };
536
+ info: {
537
+ border: string;
538
+ surface: string;
539
+ surfaceEmphasis: string;
540
+ message: string;
541
+ messageOnEmphasis: string;
542
+ };
543
+ data: Record<"branded" | "gas" | "electric", Record<2 | 1 | 3 | 4, string>>;
544
+ };
545
+ component: {
546
+ heading1: {
547
+ fontFamily: string;
548
+ fontWeight: string | number;
549
+ fontSize: {
550
+ small: string | number;
551
+ large: string | number;
552
+ };
553
+ lineHeight: {
554
+ small: string | number;
555
+ large: string | number;
556
+ };
557
+ };
558
+ heading2: {
559
+ fontFamily: string;
560
+ fontWeight: string | number;
561
+ fontSize: {
562
+ small: string | number;
563
+ large: string | number;
564
+ };
565
+ lineHeight: {
566
+ small: string | number;
567
+ large: string | number;
568
+ };
569
+ };
570
+ heading3: {
571
+ fontFamily: string;
572
+ fontWeight: string | number;
573
+ fontSize: {
574
+ small: string | number;
575
+ large: string | number;
576
+ };
577
+ lineHeight: {
578
+ small: string | number;
579
+ large: string | number;
580
+ };
581
+ };
582
+ heading4: {
583
+ fontFamily: string;
584
+ fontWeight: string | number;
585
+ fontSize: {
586
+ small: string | number;
587
+ large: string | number;
588
+ };
589
+ lineHeight: {
590
+ small: string | number;
591
+ large: string | number;
592
+ };
593
+ };
594
+ lead: {
595
+ fontFamily: string;
596
+ fontWeight: string | number;
597
+ fontSize: {
598
+ small: string | number;
599
+ large: string | number;
600
+ };
601
+ lineHeight: {
602
+ small: string | number;
603
+ large: string | number;
604
+ };
605
+ };
606
+ body: {
607
+ fontFamily: string;
608
+ fontWeight: string | number;
609
+ fontSize: {
610
+ small: string | number;
611
+ large: string | number;
612
+ };
613
+ lineHeight: {
614
+ small: string | number;
615
+ large: string | number;
616
+ };
617
+ };
618
+ small: {
619
+ fontFamily: string;
620
+ fontWeight: string | number;
621
+ fontSize: {
622
+ small: string | number;
623
+ large: string | number;
624
+ };
625
+ lineHeight: {
626
+ small: string | number;
627
+ large: string | number;
628
+ };
629
+ };
630
+ label: {
631
+ fontFamily: string;
632
+ fontWeight: string | number;
633
+ fontSize: {
634
+ small: string | number;
635
+ large: string | number;
636
+ };
637
+ lineHeight: {
638
+ small: string | number;
639
+ large: string | number;
640
+ };
641
+ };
642
+ cta: {
643
+ primary: {
644
+ message: string;
645
+ surface: string;
646
+ messageHover: string;
647
+ surfaceHover: string;
648
+ messageFocused: string;
649
+ surfaceFocused: string;
650
+ outlineFocused: string;
651
+ backgroundFocused: string;
652
+ };
653
+ secondary: {
654
+ message: string;
655
+ surface: string;
656
+ messageHover: string;
657
+ surfaceHover: string;
658
+ messageFocused: string;
659
+ surfaceFocused: string;
660
+ outlineFocused: string;
661
+ backgroundFocused: string;
662
+ };
663
+ destructive: {
664
+ message: string;
665
+ surface: string;
666
+ messageHover: string;
667
+ surfaceHover: string;
668
+ messageFocused: string;
669
+ surfaceFocused: string;
670
+ outlineFocused: string;
671
+ backgroundFocused: string;
672
+ };
673
+ };
674
+ badge: {
675
+ variants: {
676
+ neutral: {
677
+ foreground: string;
678
+ background: string;
679
+ };
680
+ red: {
681
+ foreground: string;
682
+ background: string;
683
+ };
684
+ orange: {
685
+ foreground: string;
686
+ background: string;
687
+ };
688
+ yellow: {
689
+ foreground: string;
690
+ background: string;
691
+ };
692
+ green: {
693
+ foreground: string;
694
+ background: string;
695
+ };
696
+ blue: {
697
+ foreground: string;
698
+ background: string;
699
+ };
700
+ };
701
+ };
702
+ };
703
+ }, {
704
+ checked?: boolean | undefined;
705
+ }, never>;
706
+ export declare const StyledToggleDot: import("styled-components").StyledComponent<Animated.AnimatedComponent<typeof import("react-native/types").View>, {
707
+ core: {
708
+ radius: Record<"small" | "medium" | "large" | "max", string>;
709
+ borderWidth: Record<"small" | "medium" | "large", string>;
710
+ breakpoint: Record<"small" | "medium" | "large", string | number>;
711
+ mediaQuery: Record<"small" | "medium" | "large", string>;
712
+ space: Record<0 | 2 | 1 | 3 | 4 | 5 | 10 | 6 | 7 | 8 | 9 | 11 | 12 | 13 | 14 | 15, string>;
713
+ transition: Record<"medium" | "slow" | "fast", string>;
714
+ opacity: Record<"solid" | "transparent" | "translucent", string | number>;
715
+ color: Record<"neutral" | "red" | "orange" | "yellow" | "green" | "blue", {
716
+ lightest: string;
717
+ lighter: string;
718
+ light: string;
719
+ base: string;
720
+ dark: string;
721
+ darker: string;
722
+ darkest: string;
723
+ }> & {
724
+ brand: Record<string, string>;
725
+ };
726
+ fontFamily: Record<"body" | "mono" | "heading" | "bodyBold", {
727
+ native: string;
728
+ web: string;
729
+ }>;
730
+ fontWeight: Record<"bold" | "book" | "black", string | number>;
731
+ fontSize: Record<"small" | "body" | "label" | "heading1" | "heading2" | "heading3" | "heading4" | "lead", {
732
+ small: string | number;
733
+ large: string | number;
734
+ }>;
735
+ lineHeight: Record<"small" | "body" | "label" | "heading1" | "heading2" | "heading3" | "heading4" | "lead", {
736
+ small: string | number;
737
+ large: string | number;
738
+ }>;
739
+ letterSpacing: Record<"base" | "compressed" | "extraCompressed", number>;
740
+ };
741
+ semantic: {
742
+ surface: Record<"base" | "cutout" | "elevated", string>;
743
+ message: Record<"base" | "link" | "secondary" | "error" | "branded", string>;
744
+ border: Record<"graphic" | "differentiated" | "functional", string>;
745
+ focus: Record<"surface" | "outline" | "hover", string>;
746
+ inverted: Record<"surface" | "border", string> & {
747
+ message: Record<"base" | "link" | "secondary" | "branded", string>;
748
+ };
749
+ success: {
750
+ border: string;
751
+ surface: string;
752
+ surfaceEmphasis: string;
753
+ message: string;
754
+ messageOnEmphasis: string;
755
+ };
756
+ warning: {
757
+ border: string;
758
+ surface: string;
759
+ surfaceEmphasis: string;
760
+ message: string;
761
+ messageOnEmphasis: string;
762
+ };
763
+ error: {
764
+ border: string;
765
+ surface: string;
766
+ surfaceEmphasis: string;
767
+ message: string;
768
+ messageOnEmphasis: string;
769
+ };
770
+ info: {
771
+ border: string;
772
+ surface: string;
773
+ surfaceEmphasis: string;
774
+ message: string;
775
+ messageOnEmphasis: string;
776
+ };
777
+ data: Record<"branded" | "gas" | "electric", Record<2 | 1 | 3 | 4, string>>;
778
+ };
779
+ component: {
780
+ heading1: {
781
+ fontFamily: string;
782
+ fontWeight: string | number;
783
+ fontSize: {
784
+ small: string | number;
785
+ large: string | number;
786
+ };
787
+ lineHeight: {
788
+ small: string | number;
789
+ large: string | number;
790
+ };
791
+ };
792
+ heading2: {
793
+ fontFamily: string;
794
+ fontWeight: string | number;
795
+ fontSize: {
796
+ small: string | number;
797
+ large: string | number;
798
+ };
799
+ lineHeight: {
800
+ small: string | number;
801
+ large: string | number;
802
+ };
803
+ };
804
+ heading3: {
805
+ fontFamily: string;
806
+ fontWeight: string | number;
807
+ fontSize: {
808
+ small: string | number;
809
+ large: string | number;
810
+ };
811
+ lineHeight: {
812
+ small: string | number;
813
+ large: string | number;
814
+ };
815
+ };
816
+ heading4: {
817
+ fontFamily: string;
818
+ fontWeight: string | number;
819
+ fontSize: {
820
+ small: string | number;
821
+ large: string | number;
822
+ };
823
+ lineHeight: {
824
+ small: string | number;
825
+ large: string | number;
826
+ };
827
+ };
828
+ lead: {
829
+ fontFamily: string;
830
+ fontWeight: string | number;
831
+ fontSize: {
832
+ small: string | number;
833
+ large: string | number;
834
+ };
835
+ lineHeight: {
836
+ small: string | number;
837
+ large: string | number;
838
+ };
839
+ };
840
+ body: {
841
+ fontFamily: string;
842
+ fontWeight: string | number;
843
+ fontSize: {
844
+ small: string | number;
845
+ large: string | number;
846
+ };
847
+ lineHeight: {
848
+ small: string | number;
849
+ large: string | number;
850
+ };
851
+ };
852
+ small: {
853
+ fontFamily: string;
854
+ fontWeight: string | number;
855
+ fontSize: {
856
+ small: string | number;
857
+ large: string | number;
858
+ };
859
+ lineHeight: {
860
+ small: string | number;
861
+ large: string | number;
862
+ };
863
+ };
864
+ label: {
865
+ fontFamily: string;
866
+ fontWeight: string | number;
867
+ fontSize: {
868
+ small: string | number;
869
+ large: string | number;
870
+ };
871
+ lineHeight: {
872
+ small: string | number;
873
+ large: string | number;
874
+ };
875
+ };
876
+ cta: {
877
+ primary: {
878
+ message: string;
879
+ surface: string;
880
+ messageHover: string;
881
+ surfaceHover: string;
882
+ messageFocused: string;
883
+ surfaceFocused: string;
884
+ outlineFocused: string;
885
+ backgroundFocused: string;
886
+ };
887
+ secondary: {
888
+ message: string;
889
+ surface: string;
890
+ messageHover: string;
891
+ surfaceHover: string;
892
+ messageFocused: string;
893
+ surfaceFocused: string;
894
+ outlineFocused: string;
895
+ backgroundFocused: string;
896
+ };
897
+ destructive: {
898
+ message: string;
899
+ surface: string;
900
+ messageHover: string;
901
+ surfaceHover: string;
902
+ messageFocused: string;
903
+ surfaceFocused: string;
904
+ outlineFocused: string;
905
+ backgroundFocused: string;
906
+ };
907
+ };
908
+ badge: {
909
+ variants: {
910
+ neutral: {
911
+ foreground: string;
912
+ background: string;
913
+ };
914
+ red: {
915
+ foreground: string;
916
+ background: string;
917
+ };
918
+ orange: {
919
+ foreground: string;
920
+ background: string;
921
+ };
922
+ yellow: {
923
+ foreground: string;
924
+ background: string;
925
+ };
926
+ green: {
927
+ foreground: string;
928
+ background: string;
929
+ };
930
+ blue: {
931
+ foreground: string;
932
+ background: string;
933
+ };
934
+ };
935
+ };
936
+ };
937
+ }, {
938
+ checked?: boolean | undefined;
939
+ }, never>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.StyledToggleDot = exports.StyledToggleInput = exports.StyledToggleInputWrapper = exports.StyledWrapper = void 0;
7
+ var react_native_1 = require("react-native");
8
+ var styled_native_1 = __importDefault(require("../../styled.native"));
9
+ exports.StyledWrapper = styled_native_1.default.TouchableOpacity(function (_a) {
10
+ var core = _a.theme.core, hasLabel = _a.hasLabel, labelPosition = _a.labelPosition;
11
+ return "\n width: ".concat(hasLabel ? '100%' : core.space[11], ";\n display: flex;\n flex-direction: row").concat(labelPosition === 'left' ? '' : '-reverse', ";\n justify-content: space-between;\n position: relative;\n ");
12
+ });
13
+ exports.StyledToggleInputWrapper = styled_native_1.default.View(function (_a) {
14
+ var core = _a.theme.core, labelPosition = _a.labelPosition;
15
+ return "\n width: ".concat(core.space[11], ";\n height: ").concat(core.space[6], ";\n ").concat(labelPosition
16
+ ? labelPosition === 'left'
17
+ ? 'margin-left: 10px;'
18
+ : 'margin-right: 10px;'
19
+ : null, "\n ");
20
+ });
21
+ exports.StyledToggleInput = styled_native_1.default.View(function (_a) {
22
+ var core = _a.theme.core, checked = _a.checked;
23
+ return "\n width: ".concat(core.space[11], ";\n height: ").concat(core.space[6], ";\n justify-content: center;\n border-radius: ").concat(core.radius.large, ";\n background: ").concat(checked ? core.color.brand.ovo : core.color.neutral.lighter, ";\n ");
24
+ });
25
+ exports.StyledToggleDot = (0, styled_native_1.default)(react_native_1.Animated.View)(function (_a) {
26
+ var core = _a.theme.core, checked = _a.checked;
27
+ return "\n position: absolute;\n width: ".concat(core.space[4], ";\n height: ").concat(core.space[4], ";\n border-radius: ").concat(core.space[4], ";\n background-color: ").concat(checked ? core.color.brand.white : core.color.neutral.dark, ";\n");
28
+ });
@@ -53,5 +53,6 @@ export * from './TextareaField';
53
53
  export * from './TextareaInput';
54
54
  export * from './TextField';
55
55
  export * from './TextGroup';
56
- export * from './TextLink';
57
56
  export * from './TextInput';
57
+ export * from './TextLink';
58
+ export * from './Toggle';
@@ -69,5 +69,6 @@ __exportStar(require("./TextareaField"), exports);
69
69
  __exportStar(require("./TextareaInput"), exports);
70
70
  __exportStar(require("./TextField"), exports);
71
71
  __exportStar(require("./TextGroup"), exports);
72
- __exportStar(require("./TextLink"), exports);
73
72
  __exportStar(require("./TextInput"), exports);
73
+ __exportStar(require("./TextLink"), exports);
74
+ __exportStar(require("./Toggle"), exports);
@@ -0,0 +1,53 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
+ import { forwardRef, useContext, useEffect, useRef } from 'react';
25
+ import { Animated, View, } from 'react-native';
26
+ import { ThemeContext } from 'styled-components/native';
27
+ import { HintText } from '../HintText/HintText';
28
+ import { LabelText } from '../LabelText';
29
+ import { StyledToggleDot, StyledToggleInputWrapper, StyledToggleInput, StyledWrapper, } from './styles';
30
+ var Input = function (_a) {
31
+ var checked = _a.checked, labelPosition = _a.labelPosition, testID = _a.testID, rest = __rest(_a, ["checked", "labelPosition", "testID"]);
32
+ var core = useContext(ThemeContext).core;
33
+ var leftVal = useRef(new Animated.Value(checked ? parseInt(core.space[6]) : parseInt(core.space[1]))).current;
34
+ useEffect(function () {
35
+ Animated.timing(leftVal, {
36
+ toValue: checked ? parseInt(core.space[6]) : parseInt(core.space[1]),
37
+ duration: 150,
38
+ useNativeDriver: true,
39
+ }).start();
40
+ }, [checked]);
41
+ return (_jsx(StyledToggleInputWrapper, __assign({ labelPosition: labelPosition }, rest, { children: _jsx(StyledToggleInput, __assign({ checked: checked, testID: testID }, { children: _jsx(StyledToggleDot, { style: {
42
+ transform: [{ translateX: leftVal }],
43
+ }, checked: checked }) })) })));
44
+ };
45
+ export var Toggle = forwardRef(function (_a, ref) {
46
+ var label = _a.label, hint = _a.hint, _b = _a.checked, checked = _b === void 0 ? false : _b,
47
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
48
+ _c = _a.activeOpacity,
49
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
50
+ activeOpacity = _c === void 0 ? 0.8 : _c, testID = _a.testID, _d = _a.labelPosition, labelPosition = _d === void 0 ? 'left' : _d, rest = __rest(_a, ["label", "hint", "checked", "activeOpacity", "testID", "labelPosition"]);
51
+ var hasLabel = label !== undefined;
52
+ return (_jsxs(StyledWrapper, __assign({ ref: ref, accessibilityRole: "checkbox", activeOpacity: activeOpacity, accessibilityState: { checked: checked }, hitSlop: 10, hasLabel: hasLabel, labelPosition: labelPosition }, rest, { children: [hasLabel ? (_jsxs(View, __assign({ style: { flexShrink: 1 } }, { children: [_jsx(LabelText, { children: label }), hint ? _jsx(HintText, { children: hint }) : null] }))) : null, _jsx(Input, { checked: checked, testID: testID, labelPosition: hasLabel ? labelPosition : undefined })] })));
53
+ });
@@ -0,0 +1 @@
1
+ export { Toggle } from './Toggle';
@@ -0,0 +1,22 @@
1
+ import { Animated } from 'react-native';
2
+ import styled from '../../styled.native';
3
+ export var StyledWrapper = styled.TouchableOpacity(function (_a) {
4
+ var core = _a.theme.core, hasLabel = _a.hasLabel, labelPosition = _a.labelPosition;
5
+ return "\n width: ".concat(hasLabel ? '100%' : core.space[11], ";\n display: flex;\n flex-direction: row").concat(labelPosition === 'left' ? '' : '-reverse', ";\n justify-content: space-between;\n position: relative;\n ");
6
+ });
7
+ export var StyledToggleInputWrapper = styled.View(function (_a) {
8
+ var core = _a.theme.core, labelPosition = _a.labelPosition;
9
+ return "\n width: ".concat(core.space[11], ";\n height: ").concat(core.space[6], ";\n ").concat(labelPosition
10
+ ? labelPosition === 'left'
11
+ ? 'margin-left: 10px;'
12
+ : 'margin-right: 10px;'
13
+ : null, "\n ");
14
+ });
15
+ export var StyledToggleInput = styled.View(function (_a) {
16
+ var core = _a.theme.core, checked = _a.checked;
17
+ return "\n width: ".concat(core.space[11], ";\n height: ").concat(core.space[6], ";\n justify-content: center;\n border-radius: ").concat(core.radius.large, ";\n background: ").concat(checked ? core.color.brand.ovo : core.color.neutral.lighter, ";\n ");
18
+ });
19
+ export var StyledToggleDot = styled(Animated.View)(function (_a) {
20
+ var core = _a.theme.core, checked = _a.checked;
21
+ return "\n position: absolute;\n width: ".concat(core.space[4], ";\n height: ").concat(core.space[4], ";\n border-radius: ").concat(core.space[4], ";\n background-color: ").concat(checked ? core.color.brand.white : core.color.neutral.dark, ";\n");
22
+ });
@@ -53,5 +53,6 @@ export * from './TextareaField';
53
53
  export * from './TextareaInput';
54
54
  export * from './TextField';
55
55
  export * from './TextGroup';
56
- export * from './TextLink';
57
56
  export * from './TextInput';
57
+ export * from './TextLink';
58
+ export * from './Toggle';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ovotech/element-native",
3
- "version": "3.5.0-canary-8dee962-166",
3
+ "version": "3.5.0-canary-e225e8b-167",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "url": "@ovotech/element"
14
14
  },
15
15
  "dependencies": {
16
- "@ovotech/element-core": "^2.2.0-canary-8dee962-166",
16
+ "@ovotech/element-core": "^2.2.0-canary-e225e8b-167",
17
17
  "deepmerge": "^4.2.2",
18
18
  "lodash.groupby": "^4.6.0"
19
19
  },