@ovotech/element-native 4.0.2-canary-242da35-253 → 4.0.2-canary-e8705c2-255
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/dist/components/ActionCard/ActionCard.js +6 -1
- package/dist/components/FilterSection/FilterSection.d.ts +498 -0
- package/dist/components/FilterSection/FilterSection.js +95 -0
- package/dist/components/FilterSection/components/FilterButton.d.ts +9 -0
- package/dist/components/FilterSection/components/FilterButton.js +93 -0
- package/dist/components/FilterSection/constants.d.ts +28 -0
- package/dist/components/FilterSection/constants.js +2 -0
- package/dist/components/FilterSection/index.d.ts +2 -0
- package/dist/components/FilterSection/index.js +5 -0
- package/dist/esm/components/ActionCard/ActionCard.js +6 -1
- package/dist/esm/components/FilterSection/FilterSection.js +65 -0
- package/dist/esm/components/FilterSection/components/FilterButton.js +66 -0
- package/dist/esm/components/FilterSection/constants.js +1 -0
- package/dist/esm/components/FilterSection/index.js +2 -0
- package/package.json +2 -2
|
@@ -50,6 +50,11 @@ var StyledP = (0, styled_native_1.default)(P_1.P)(function (_a) {
|
|
|
50
50
|
var ActionCard = function (_a) {
|
|
51
51
|
var onPressCloseButton = _a.onPressCloseButton, onPressActionButton = _a.onPressActionButton, onPressIndicator = _a.onPressIndicator, onMount = _a.onMount, body = _a.body, title = _a.title, buttonTitle = _a.buttonTitle, ctaVariant = _a.ctaVariant, image = _a.image, testID = _a.testID, _b = _a.accessibilityLabel, accessibilityLabel = _b === void 0 ? 'image' : _b, _c = _a.inverted, inverted = _c === void 0 ? false : _c, _d = _a.inline, inline = _d === void 0 ? false : _d;
|
|
52
52
|
var _e = (0, react_1.useContext)(styled_native_1.ThemeContext), core = _e.core, semantic = _e.semantic;
|
|
53
|
+
var hasSingleAction = (onPressActionButton && !onPressIndicator && !onPressCloseButton) ||
|
|
54
|
+
(onPressIndicator && !onPressActionButton && !onPressCloseButton);
|
|
55
|
+
var cardAction = hasSingleAction
|
|
56
|
+
? onPressActionButton || onPressIndicator
|
|
57
|
+
: null;
|
|
53
58
|
(0, react_1.useEffect)(function () {
|
|
54
59
|
if (onMount) {
|
|
55
60
|
onMount();
|
|
@@ -58,7 +63,7 @@ var ActionCard = function (_a) {
|
|
|
58
63
|
var Heading = inline ? __1.Heading3 : __1.Heading2;
|
|
59
64
|
var cardPadding = core.space[inline ? 4 : 6];
|
|
60
65
|
var negativeMarginAdjustment = -cardPadding;
|
|
61
|
-
return ((0, jsx_runtime_1.jsx)(StyledCard, { onPress:
|
|
66
|
+
return ((0, jsx_runtime_1.jsx)(StyledCard, { onPress: cardAction, inline: inline, inverted: inverted, reducedBottomPadding: Boolean(buttonTitle && !ctaVariant), testID: "".concat(testID, "-card"), children: (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: { flexDirection: 'row' }, children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { style: { flex: 1 }, children: (0, jsx_runtime_1.jsxs)(__1.Stack, { spaceBetween: 2, children: [(0, jsx_runtime_1.jsx)(Heading, { style: {
|
|
62
67
|
color: inverted
|
|
63
68
|
? semantic.inverted.message.link
|
|
64
69
|
: semantic.message.branded,
|
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { Filters } from './constants';
|
|
3
|
+
type FilterSectionProps<T extends keyof Filters> = {
|
|
4
|
+
filterTitle: string;
|
|
5
|
+
localFilter: Filters[T][number];
|
|
6
|
+
setLocalFilter: Dispatch<SetStateAction<Filters[T][number]>>;
|
|
7
|
+
filters: Filters[T];
|
|
8
|
+
multipleRows?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const FilterSection: <T extends keyof Filters>({ filterTitle, localFilter, setLocalFilter, filters, multipleRows, }: FilterSectionProps<T>) => JSX.Element;
|
|
11
|
+
export declare const BlackHeading4: import("styled-components").StyledComponent<({ accessibilityRole, ...rest }: import("react").PropsWithChildren<import("react-native").TextProps & {
|
|
12
|
+
inverted?: boolean | undefined;
|
|
13
|
+
}>) => JSX.Element, {
|
|
14
|
+
core: {
|
|
15
|
+
color: {
|
|
16
|
+
brand: {
|
|
17
|
+
midnight: string;
|
|
18
|
+
midnightTint: string;
|
|
19
|
+
forest: string;
|
|
20
|
+
forestTint: string;
|
|
21
|
+
ovo: string;
|
|
22
|
+
ovoTint: string;
|
|
23
|
+
leaf: string;
|
|
24
|
+
leafTint: string;
|
|
25
|
+
energised: string;
|
|
26
|
+
energisedTint: string;
|
|
27
|
+
offwhite: string;
|
|
28
|
+
white: string;
|
|
29
|
+
black: string;
|
|
30
|
+
};
|
|
31
|
+
neutral: {
|
|
32
|
+
darkest: string;
|
|
33
|
+
darker: string;
|
|
34
|
+
dark: string;
|
|
35
|
+
base: string;
|
|
36
|
+
light: string;
|
|
37
|
+
lighter: string;
|
|
38
|
+
lightest: string;
|
|
39
|
+
};
|
|
40
|
+
red: {
|
|
41
|
+
darkest: string;
|
|
42
|
+
darker: string;
|
|
43
|
+
dark: string;
|
|
44
|
+
base: string;
|
|
45
|
+
light: string;
|
|
46
|
+
lighter: string;
|
|
47
|
+
lightest: string;
|
|
48
|
+
};
|
|
49
|
+
orange: {
|
|
50
|
+
darkest: string;
|
|
51
|
+
darker: string;
|
|
52
|
+
dark: string;
|
|
53
|
+
base: string;
|
|
54
|
+
light: string;
|
|
55
|
+
lighter: string;
|
|
56
|
+
lightest: string;
|
|
57
|
+
};
|
|
58
|
+
yellow: {
|
|
59
|
+
darkest: string;
|
|
60
|
+
darker: string;
|
|
61
|
+
dark: string;
|
|
62
|
+
base: string;
|
|
63
|
+
light: string;
|
|
64
|
+
lighter: string;
|
|
65
|
+
lightest: string;
|
|
66
|
+
};
|
|
67
|
+
green: {
|
|
68
|
+
darkest: string;
|
|
69
|
+
darker: string;
|
|
70
|
+
dark: string;
|
|
71
|
+
base: string;
|
|
72
|
+
light: string;
|
|
73
|
+
lighter: string;
|
|
74
|
+
lightest: string;
|
|
75
|
+
};
|
|
76
|
+
blue: {
|
|
77
|
+
darkest: string;
|
|
78
|
+
darker: string;
|
|
79
|
+
dark: string;
|
|
80
|
+
base: string;
|
|
81
|
+
light: string;
|
|
82
|
+
lighter: string;
|
|
83
|
+
lightest: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
fontFamily: {
|
|
87
|
+
mono: {
|
|
88
|
+
native: string;
|
|
89
|
+
web: string;
|
|
90
|
+
};
|
|
91
|
+
heading: {
|
|
92
|
+
native: string;
|
|
93
|
+
web: string;
|
|
94
|
+
};
|
|
95
|
+
body: {
|
|
96
|
+
native: string;
|
|
97
|
+
web: string;
|
|
98
|
+
};
|
|
99
|
+
bodyBold: {
|
|
100
|
+
native: string;
|
|
101
|
+
web: string;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
fontWeight: {
|
|
105
|
+
book: number;
|
|
106
|
+
bold: number;
|
|
107
|
+
black: number;
|
|
108
|
+
};
|
|
109
|
+
fontSize: {
|
|
110
|
+
heading1: {
|
|
111
|
+
small: number;
|
|
112
|
+
large: number;
|
|
113
|
+
};
|
|
114
|
+
heading2: {
|
|
115
|
+
small: number;
|
|
116
|
+
large: number;
|
|
117
|
+
};
|
|
118
|
+
heading3: {
|
|
119
|
+
small: number;
|
|
120
|
+
large: number;
|
|
121
|
+
};
|
|
122
|
+
heading4: {
|
|
123
|
+
small: number;
|
|
124
|
+
large: number;
|
|
125
|
+
};
|
|
126
|
+
lead: {
|
|
127
|
+
small: number;
|
|
128
|
+
large: number;
|
|
129
|
+
};
|
|
130
|
+
body: {
|
|
131
|
+
small: number;
|
|
132
|
+
large: number;
|
|
133
|
+
};
|
|
134
|
+
small: {
|
|
135
|
+
small: number;
|
|
136
|
+
large: number;
|
|
137
|
+
};
|
|
138
|
+
label: {
|
|
139
|
+
small: number;
|
|
140
|
+
large: number;
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
letterSpacing: {
|
|
144
|
+
base: number;
|
|
145
|
+
compressed: number;
|
|
146
|
+
extraCompressed: number;
|
|
147
|
+
};
|
|
148
|
+
lineHeight: {
|
|
149
|
+
heading1: {
|
|
150
|
+
small: number;
|
|
151
|
+
large: number;
|
|
152
|
+
};
|
|
153
|
+
heading2: {
|
|
154
|
+
small: number;
|
|
155
|
+
large: number;
|
|
156
|
+
};
|
|
157
|
+
heading3: {
|
|
158
|
+
small: number;
|
|
159
|
+
large: number;
|
|
160
|
+
};
|
|
161
|
+
heading4: {
|
|
162
|
+
small: number;
|
|
163
|
+
large: number;
|
|
164
|
+
};
|
|
165
|
+
lead: {
|
|
166
|
+
small: number;
|
|
167
|
+
large: number;
|
|
168
|
+
};
|
|
169
|
+
body: {
|
|
170
|
+
small: number;
|
|
171
|
+
large: number;
|
|
172
|
+
};
|
|
173
|
+
small: {
|
|
174
|
+
small: number;
|
|
175
|
+
large: number;
|
|
176
|
+
};
|
|
177
|
+
label: {
|
|
178
|
+
small: number;
|
|
179
|
+
large: number;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
borderWidth: {
|
|
183
|
+
small: number;
|
|
184
|
+
medium: number;
|
|
185
|
+
large: number;
|
|
186
|
+
};
|
|
187
|
+
breakpoint: {
|
|
188
|
+
small: number;
|
|
189
|
+
medium: number;
|
|
190
|
+
large: number;
|
|
191
|
+
};
|
|
192
|
+
mediaQuery: {
|
|
193
|
+
small: number;
|
|
194
|
+
medium: number;
|
|
195
|
+
large: number;
|
|
196
|
+
};
|
|
197
|
+
customMediaQuery: {
|
|
198
|
+
'small-and-up': number;
|
|
199
|
+
'medium-and-up': number;
|
|
200
|
+
'large-and-up': number;
|
|
201
|
+
};
|
|
202
|
+
opacity: {
|
|
203
|
+
solid: number;
|
|
204
|
+
translucent: number;
|
|
205
|
+
transparent: number;
|
|
206
|
+
};
|
|
207
|
+
radius: {
|
|
208
|
+
small: number;
|
|
209
|
+
medium: number;
|
|
210
|
+
large: number;
|
|
211
|
+
max: number;
|
|
212
|
+
};
|
|
213
|
+
space: {
|
|
214
|
+
'0': number;
|
|
215
|
+
'1': number;
|
|
216
|
+
'2': number;
|
|
217
|
+
'3': number;
|
|
218
|
+
'4': number;
|
|
219
|
+
'5': number;
|
|
220
|
+
'6': number;
|
|
221
|
+
'7': number;
|
|
222
|
+
'8': number;
|
|
223
|
+
'9': number;
|
|
224
|
+
'10': number;
|
|
225
|
+
'11': number;
|
|
226
|
+
'12': number;
|
|
227
|
+
'13': number;
|
|
228
|
+
'14': number;
|
|
229
|
+
'15': number;
|
|
230
|
+
};
|
|
231
|
+
transition: {
|
|
232
|
+
slow: number;
|
|
233
|
+
medium: number;
|
|
234
|
+
fast: number;
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
semantic: {
|
|
238
|
+
border: {
|
|
239
|
+
graphic: string;
|
|
240
|
+
differentiated: string;
|
|
241
|
+
functional: string;
|
|
242
|
+
};
|
|
243
|
+
branded: {
|
|
244
|
+
surface: string;
|
|
245
|
+
message: string;
|
|
246
|
+
heading: string;
|
|
247
|
+
};
|
|
248
|
+
neutral: {
|
|
249
|
+
surface: string;
|
|
250
|
+
message: string;
|
|
251
|
+
surfaceEmphasis: string;
|
|
252
|
+
messageOnEmphasis: string;
|
|
253
|
+
border: string;
|
|
254
|
+
};
|
|
255
|
+
success: {
|
|
256
|
+
surface: string;
|
|
257
|
+
message: string;
|
|
258
|
+
surfaceEmphasis: string;
|
|
259
|
+
messageOnEmphasis: string;
|
|
260
|
+
border: string;
|
|
261
|
+
};
|
|
262
|
+
warning: {
|
|
263
|
+
surface: string;
|
|
264
|
+
message: string;
|
|
265
|
+
surfaceEmphasis: string;
|
|
266
|
+
messageOnEmphasis: string;
|
|
267
|
+
border: string;
|
|
268
|
+
};
|
|
269
|
+
error: {
|
|
270
|
+
surface: string;
|
|
271
|
+
message: string;
|
|
272
|
+
surfaceEmphasis: string;
|
|
273
|
+
messageOnEmphasis: string;
|
|
274
|
+
border: string;
|
|
275
|
+
};
|
|
276
|
+
info: {
|
|
277
|
+
surface: string;
|
|
278
|
+
message: string;
|
|
279
|
+
surfaceEmphasis: string;
|
|
280
|
+
messageOnEmphasis: string;
|
|
281
|
+
border: string;
|
|
282
|
+
};
|
|
283
|
+
data: {
|
|
284
|
+
branded: {
|
|
285
|
+
'1': string;
|
|
286
|
+
'2': string;
|
|
287
|
+
'3': string;
|
|
288
|
+
'4': string;
|
|
289
|
+
};
|
|
290
|
+
electric: {
|
|
291
|
+
'1': string;
|
|
292
|
+
'2': string;
|
|
293
|
+
'3': string;
|
|
294
|
+
'4': string;
|
|
295
|
+
};
|
|
296
|
+
gas: {
|
|
297
|
+
'1': string;
|
|
298
|
+
'2': string;
|
|
299
|
+
'3': string;
|
|
300
|
+
'4': string;
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
focus: {
|
|
304
|
+
outline: string;
|
|
305
|
+
hover: string;
|
|
306
|
+
surface: string;
|
|
307
|
+
};
|
|
308
|
+
inverted: {
|
|
309
|
+
surface: string;
|
|
310
|
+
surfaceAlt: string;
|
|
311
|
+
border: string;
|
|
312
|
+
borderAlt: string;
|
|
313
|
+
message: {
|
|
314
|
+
branded: string;
|
|
315
|
+
base: string;
|
|
316
|
+
secondary: string;
|
|
317
|
+
link: string;
|
|
318
|
+
};
|
|
319
|
+
};
|
|
320
|
+
message: {
|
|
321
|
+
base: string;
|
|
322
|
+
secondary: string;
|
|
323
|
+
link: string;
|
|
324
|
+
error: string;
|
|
325
|
+
branded: string;
|
|
326
|
+
};
|
|
327
|
+
surface: {
|
|
328
|
+
base: string;
|
|
329
|
+
cutout: string;
|
|
330
|
+
elevated: string;
|
|
331
|
+
};
|
|
332
|
+
};
|
|
333
|
+
component: {
|
|
334
|
+
badge: {
|
|
335
|
+
variants: {
|
|
336
|
+
neutral: {
|
|
337
|
+
background: string;
|
|
338
|
+
foreground: string;
|
|
339
|
+
};
|
|
340
|
+
red: {
|
|
341
|
+
background: string;
|
|
342
|
+
foreground: string;
|
|
343
|
+
};
|
|
344
|
+
orange: {
|
|
345
|
+
background: string;
|
|
346
|
+
foreground: string;
|
|
347
|
+
};
|
|
348
|
+
yellow: {
|
|
349
|
+
background: string;
|
|
350
|
+
foreground: string;
|
|
351
|
+
};
|
|
352
|
+
green: {
|
|
353
|
+
background: string;
|
|
354
|
+
foreground: string;
|
|
355
|
+
};
|
|
356
|
+
blue: {
|
|
357
|
+
background: string;
|
|
358
|
+
foreground: string;
|
|
359
|
+
};
|
|
360
|
+
};
|
|
361
|
+
};
|
|
362
|
+
cta: {
|
|
363
|
+
primary: {
|
|
364
|
+
message: string;
|
|
365
|
+
surface: string;
|
|
366
|
+
messageHover: string;
|
|
367
|
+
surfaceHover: string;
|
|
368
|
+
messageFocused: string;
|
|
369
|
+
surfaceFocused: string;
|
|
370
|
+
outlineFocused: string;
|
|
371
|
+
backgroundFocused: string;
|
|
372
|
+
messageInverted: string;
|
|
373
|
+
surfaceInverted: string;
|
|
374
|
+
};
|
|
375
|
+
secondary: {
|
|
376
|
+
message: string;
|
|
377
|
+
surface: string;
|
|
378
|
+
messageHover: string;
|
|
379
|
+
surfaceHover: string;
|
|
380
|
+
messageFocused: string;
|
|
381
|
+
surfaceFocused: string;
|
|
382
|
+
outlineFocused: string;
|
|
383
|
+
backgroundFocused: string;
|
|
384
|
+
messageInverted: string;
|
|
385
|
+
surfaceInverted: string;
|
|
386
|
+
};
|
|
387
|
+
destructive: {
|
|
388
|
+
message: string;
|
|
389
|
+
surface: string;
|
|
390
|
+
messageHover: string;
|
|
391
|
+
surfaceHover: string;
|
|
392
|
+
messageFocused: string;
|
|
393
|
+
surfaceFocused: string;
|
|
394
|
+
outlineFocused: string;
|
|
395
|
+
backgroundFocused: string;
|
|
396
|
+
messageInverted: string;
|
|
397
|
+
surfaceInverted: string;
|
|
398
|
+
};
|
|
399
|
+
};
|
|
400
|
+
heading1: {
|
|
401
|
+
fontFamily: string;
|
|
402
|
+
fontWeight: number;
|
|
403
|
+
lineHeight: {
|
|
404
|
+
small: number;
|
|
405
|
+
large: number;
|
|
406
|
+
};
|
|
407
|
+
fontSize: {
|
|
408
|
+
small: number;
|
|
409
|
+
large: number;
|
|
410
|
+
};
|
|
411
|
+
};
|
|
412
|
+
heading2: {
|
|
413
|
+
fontFamily: string;
|
|
414
|
+
fontWeight: number;
|
|
415
|
+
lineHeight: {
|
|
416
|
+
small: number;
|
|
417
|
+
large: number;
|
|
418
|
+
};
|
|
419
|
+
fontSize: {
|
|
420
|
+
small: number;
|
|
421
|
+
large: number;
|
|
422
|
+
};
|
|
423
|
+
};
|
|
424
|
+
heading3: {
|
|
425
|
+
fontFamily: string;
|
|
426
|
+
fontWeight: number;
|
|
427
|
+
lineHeight: {
|
|
428
|
+
small: number;
|
|
429
|
+
large: number;
|
|
430
|
+
};
|
|
431
|
+
fontSize: {
|
|
432
|
+
small: number;
|
|
433
|
+
large: number;
|
|
434
|
+
};
|
|
435
|
+
};
|
|
436
|
+
heading4: {
|
|
437
|
+
fontFamily: string;
|
|
438
|
+
fontWeight: number;
|
|
439
|
+
lineHeight: {
|
|
440
|
+
small: number;
|
|
441
|
+
large: number;
|
|
442
|
+
};
|
|
443
|
+
fontSize: {
|
|
444
|
+
small: number;
|
|
445
|
+
large: number;
|
|
446
|
+
};
|
|
447
|
+
};
|
|
448
|
+
lead: {
|
|
449
|
+
fontFamily: string;
|
|
450
|
+
fontWeight: number;
|
|
451
|
+
lineHeight: {
|
|
452
|
+
small: number;
|
|
453
|
+
large: number;
|
|
454
|
+
};
|
|
455
|
+
fontSize: {
|
|
456
|
+
small: number;
|
|
457
|
+
large: number;
|
|
458
|
+
};
|
|
459
|
+
};
|
|
460
|
+
body: {
|
|
461
|
+
fontFamily: string;
|
|
462
|
+
fontWeight: number;
|
|
463
|
+
lineHeight: {
|
|
464
|
+
small: number;
|
|
465
|
+
large: number;
|
|
466
|
+
};
|
|
467
|
+
fontSize: {
|
|
468
|
+
small: number;
|
|
469
|
+
large: number;
|
|
470
|
+
};
|
|
471
|
+
};
|
|
472
|
+
small: {
|
|
473
|
+
fontFamily: string;
|
|
474
|
+
fontWeight: number;
|
|
475
|
+
lineHeight: {
|
|
476
|
+
small: number;
|
|
477
|
+
large: number;
|
|
478
|
+
};
|
|
479
|
+
fontSize: {
|
|
480
|
+
small: number;
|
|
481
|
+
large: number;
|
|
482
|
+
};
|
|
483
|
+
};
|
|
484
|
+
label: {
|
|
485
|
+
fontFamily: string;
|
|
486
|
+
fontWeight: number;
|
|
487
|
+
lineHeight: {
|
|
488
|
+
small: number;
|
|
489
|
+
large: number;
|
|
490
|
+
};
|
|
491
|
+
fontSize: {
|
|
492
|
+
small: number;
|
|
493
|
+
large: number;
|
|
494
|
+
};
|
|
495
|
+
};
|
|
496
|
+
};
|
|
497
|
+
}, {}, never>;
|
|
498
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
+
if (mod && mod.__esModule) return mod;
|
|
24
|
+
var result = {};
|
|
25
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
+
__setModuleDefault(result, mod);
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
30
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.BlackHeading4 = exports.FilterSection = void 0;
|
|
34
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
35
|
+
var react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
|
|
36
|
+
var styled_native_1 = __importDefault(require("../../styled.native"));
|
|
37
|
+
var Heading4_1 = require("../Heading4");
|
|
38
|
+
var FilterButton_1 = require("./components/FilterButton");
|
|
39
|
+
var springSettings = {
|
|
40
|
+
damping: 15,
|
|
41
|
+
};
|
|
42
|
+
var FilterSection = function (_a) {
|
|
43
|
+
var filterTitle = _a.filterTitle, localFilter = _a.localFilter, setLocalFilter = _a.setLocalFilter, filters = _a.filters, multipleRows = _a.multipleRows;
|
|
44
|
+
var animatedX = (0, react_native_reanimated_1.useSharedValue)(0);
|
|
45
|
+
var animatedY = (0, react_native_reanimated_1.useSharedValue)(0);
|
|
46
|
+
var animatedWidth = (0, react_native_reanimated_1.useSharedValue)(0);
|
|
47
|
+
var animatedHeight = (0, react_native_reanimated_1.useSharedValue)(0);
|
|
48
|
+
var animatedBackgroundStyle = (0, react_native_reanimated_1.useAnimatedStyle)(function () {
|
|
49
|
+
return {
|
|
50
|
+
transform: [
|
|
51
|
+
{ translateX: animatedX.value },
|
|
52
|
+
{ translateY: animatedY.value },
|
|
53
|
+
],
|
|
54
|
+
width: animatedWidth.value,
|
|
55
|
+
height: animatedHeight.value,
|
|
56
|
+
position: 'absolute',
|
|
57
|
+
borderRadius: 22,
|
|
58
|
+
backgroundColor: '#0a9828',
|
|
59
|
+
};
|
|
60
|
+
}, [animatedX, animatedY, animatedWidth, animatedHeight]);
|
|
61
|
+
return ((0, jsx_runtime_1.jsxs)(SectionContainer, { children: [(0, jsx_runtime_1.jsx)(exports.BlackHeading4, { children: filterTitle }), (0, jsx_runtime_1.jsxs)(FilterSelectorContainer, { children: [(0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: animatedBackgroundStyle }), filters.map(function (filter) { return ((0, jsx_runtime_1.jsx)(FilterButton_1.FilterButton, { isSelected: localFilter.key === filter.key, label: filter.label, onPress: function (x, y, width) {
|
|
62
|
+
setLocalFilter(filter);
|
|
63
|
+
animatedX.value = (0, react_native_reanimated_1.withSpring)(x, springSettings);
|
|
64
|
+
animatedY.value = (0, react_native_reanimated_1.withSpring)(y, springSettings);
|
|
65
|
+
animatedWidth.value = (0, react_native_reanimated_1.withSpring)(width, springSettings);
|
|
66
|
+
}, onLayout: function (width, height, x, y) {
|
|
67
|
+
if (localFilter.key === filter.key) {
|
|
68
|
+
animatedX.value = x;
|
|
69
|
+
// (adrian.pop) - I couldn't figure out how to make the positioning work once the
|
|
70
|
+
// choices go on the second row. The only way I could get it to work
|
|
71
|
+
// was to hardcode the denominator to 3 for the single row ones
|
|
72
|
+
// and 1.1 for the multiple row ones.
|
|
73
|
+
animatedY.value = y - height / (multipleRows ? 1.1 : 3);
|
|
74
|
+
animatedWidth.value = width;
|
|
75
|
+
animatedHeight.value = height;
|
|
76
|
+
}
|
|
77
|
+
}, multipleRows: multipleRows }, filter.key)); })] })] }));
|
|
78
|
+
};
|
|
79
|
+
exports.FilterSection = FilterSection;
|
|
80
|
+
var SectionContainer = styled_native_1.default.View(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n gap: ", "px;\n align-items: flex-start;\n"], ["\n gap: ", "px;\n align-items: flex-start;\n"])), function (_a) {
|
|
81
|
+
var theme = _a.theme;
|
|
82
|
+
return theme.core.space[2];
|
|
83
|
+
});
|
|
84
|
+
var FilterSelectorContainer = styled_native_1.default.View(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background-color: ", ";\n padding: ", "px;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-wrap: wrap;\n gap: ", "px;\n border-radius: 22px;\n width: 100%;\n"], ["\n background-color: ", ";\n padding: ", "px;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-wrap: wrap;\n gap: ", "px;\n border-radius: 22px;\n width: 100%;\n"])), function (_a) {
|
|
85
|
+
var theme = _a.theme;
|
|
86
|
+
return theme.core.color.neutral.lighter;
|
|
87
|
+
}, function (_a) {
|
|
88
|
+
var theme = _a.theme;
|
|
89
|
+
return theme.core.space[2];
|
|
90
|
+
}, function (_a) {
|
|
91
|
+
var theme = _a.theme;
|
|
92
|
+
return theme.core.space[1];
|
|
93
|
+
});
|
|
94
|
+
exports.BlackHeading4 = (0, styled_native_1.default)(Heading4_1.Heading4)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n color: black;\n"], ["\n color: black;\n"])));
|
|
95
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type FilterButtonProps = {
|
|
2
|
+
onPress: (x: number, y: number, width: number) => void;
|
|
3
|
+
onLayout: (width: number, height: number, x: number, y: number) => void;
|
|
4
|
+
isSelected: boolean;
|
|
5
|
+
label: string;
|
|
6
|
+
multipleRows?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const FilterButton: ({ onPress, onLayout, isSelected, label, multipleRows, }: FilterButtonProps) => JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
+
if (mod && mod.__esModule) return mod;
|
|
24
|
+
var result = {};
|
|
25
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
+
__setModuleDefault(result, mod);
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.FilterButton = void 0;
|
|
31
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
32
|
+
var react_1 = require("react");
|
|
33
|
+
var react_native_1 = require("react-native");
|
|
34
|
+
var react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
|
|
35
|
+
var styled_native_1 = __importStar(require("../../../styled.native"));
|
|
36
|
+
var P_1 = require("../../P");
|
|
37
|
+
var AnimatedP = react_native_reanimated_1.default.createAnimatedComponent(P_1.P);
|
|
38
|
+
var FilterButton = function (_a) {
|
|
39
|
+
var onPress = _a.onPress, onLayout = _a.onLayout, isSelected = _a.isSelected, label = _a.label, multipleRows = _a.multipleRows;
|
|
40
|
+
var xRef = (0, react_1.useRef)(0);
|
|
41
|
+
var yRef = (0, react_1.useRef)(0);
|
|
42
|
+
var widthRef = (0, react_1.useRef)(0);
|
|
43
|
+
var heightRef = (0, react_1.useRef)(0);
|
|
44
|
+
var fontWeightAnim = (0, react_native_reanimated_1.useSharedValue)(isSelected ? 1 : 0);
|
|
45
|
+
var animatedStyleNormal = (0, react_native_reanimated_1.useAnimatedStyle)(function () {
|
|
46
|
+
return {
|
|
47
|
+
opacity: 1 - fontWeightAnim.value,
|
|
48
|
+
position: 'absolute',
|
|
49
|
+
};
|
|
50
|
+
}, [fontWeightAnim]);
|
|
51
|
+
var animatedStyleBold = (0, react_native_reanimated_1.useAnimatedStyle)(function () {
|
|
52
|
+
return {
|
|
53
|
+
opacity: fontWeightAnim.value,
|
|
54
|
+
position: 'absolute',
|
|
55
|
+
};
|
|
56
|
+
}, [fontWeightAnim]);
|
|
57
|
+
(0, react_1.useEffect)(function () {
|
|
58
|
+
fontWeightAnim.value = (0, react_native_reanimated_1.withTiming)(isSelected ? 1 : 0);
|
|
59
|
+
}, [fontWeightAnim, isSelected]);
|
|
60
|
+
var handleLayout = function (event) {
|
|
61
|
+
var _a = event.nativeEvent.layout, width = _a.width, height = _a.height, x = _a.x, y = _a.y;
|
|
62
|
+
xRef.current = x;
|
|
63
|
+
yRef.current = y;
|
|
64
|
+
widthRef.current = width;
|
|
65
|
+
heightRef.current = height;
|
|
66
|
+
onLayout(width, height, x, y);
|
|
67
|
+
};
|
|
68
|
+
var handlePress = function () {
|
|
69
|
+
onPress(xRef.current,
|
|
70
|
+
// (adrian.pop) - I couldn't figure out how to make the positioning work once the
|
|
71
|
+
// choices go on the second row. The only way I could get it to work
|
|
72
|
+
// was to hardcode the denominator to 3 for the single row ones
|
|
73
|
+
// and 1.1 for the multiple row ones.
|
|
74
|
+
yRef.current - heightRef.current / (multipleRows ? 1.1 : 3), widthRef.current);
|
|
75
|
+
};
|
|
76
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { onLayout: handleLayout, onPress: handlePress, accessibilityRole: "checkbox", accessibilityState: { selected: isSelected }, children: (0, jsx_runtime_1.jsxs)(SFilterSelector, { "$isSelected": isSelected, children: [(0, jsx_runtime_1.jsx)(SFilterText, { style: {
|
|
77
|
+
opacity: 0,
|
|
78
|
+
fontWeight: '900',
|
|
79
|
+
}, "$isSelected": false, children: label }), (0, jsx_runtime_1.jsx)(SFilterText, { style: animatedStyleNormal, "$isSelected": false, numberOfLines: 1, adjustsFontSizeToFit: true, children: label }), (0, jsx_runtime_1.jsx)(SFilterText, { style: animatedStyleBold, "$isSelected": true, numberOfLines: 1, adjustsFontSizeToFit: true, children: label })] }) }));
|
|
80
|
+
};
|
|
81
|
+
exports.FilterButton = FilterButton;
|
|
82
|
+
var SFilterSelector = styled_native_1.default.View(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 0 ", "px;\n border-radius: ", "px;\n align-items: center;\n justify-content: center;\n"], ["\n padding: 0 ", "px;\n border-radius: ", "px;\n align-items: center;\n justify-content: center;\n"])), function (_a) {
|
|
83
|
+
var theme = _a.theme;
|
|
84
|
+
return theme.core.space[4];
|
|
85
|
+
}, function (_a) {
|
|
86
|
+
var theme = _a.theme;
|
|
87
|
+
return theme.core.radius.large;
|
|
88
|
+
});
|
|
89
|
+
var SFilterText = (0, styled_native_1.default)(AnimatedP)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (_a) {
|
|
90
|
+
var $isSelected = _a.$isSelected, theme = _a.theme;
|
|
91
|
+
return $isSelected && (0, styled_native_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n color: ", ";\n font-weight: ", ";\n "], ["\n color: ", ";\n font-weight: ", ";\n "])), theme.core.color.brand.white, theme.core.fontWeight.bold);
|
|
92
|
+
});
|
|
93
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type EnergyUseFilters = 'electricity' | 'gas' | 'combined';
|
|
2
|
+
export type PeriodFilters = 'week' | 'month' | 'year';
|
|
3
|
+
export type MeasurementFilters = 'consumption' | 'cost';
|
|
4
|
+
export type ComparisonFilters = 'similar' | 'previous' | 'none';
|
|
5
|
+
export type MeasurementUnit = '£' | 'kWh';
|
|
6
|
+
export type Filters = {
|
|
7
|
+
ENERGY_USE: {
|
|
8
|
+
key: EnergyUseFilters;
|
|
9
|
+
label: string;
|
|
10
|
+
mainScreenLabel?: string;
|
|
11
|
+
}[];
|
|
12
|
+
PERIOD: {
|
|
13
|
+
key: PeriodFilters;
|
|
14
|
+
label: string;
|
|
15
|
+
mainScreenLabel?: string;
|
|
16
|
+
}[];
|
|
17
|
+
MEASUREMENT: {
|
|
18
|
+
key: MeasurementFilters;
|
|
19
|
+
label: string;
|
|
20
|
+
mainScreenLabel?: string;
|
|
21
|
+
unit: MeasurementUnit;
|
|
22
|
+
}[];
|
|
23
|
+
COMPARISON: {
|
|
24
|
+
key: ComparisonFilters;
|
|
25
|
+
label: string;
|
|
26
|
+
mainScreenLabel?: string;
|
|
27
|
+
}[];
|
|
28
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FilterSelect = void 0;
|
|
4
|
+
var FilterSelect_1 = require("../FilterSelect");
|
|
5
|
+
Object.defineProperty(exports, "FilterSelect", { enumerable: true, get: function () { return FilterSelect_1.FilterSelect; } });
|
|
@@ -21,6 +21,11 @@ var StyledP = styled(P)(function (_a) {
|
|
|
21
21
|
export var ActionCard = function (_a) {
|
|
22
22
|
var onPressCloseButton = _a.onPressCloseButton, onPressActionButton = _a.onPressActionButton, onPressIndicator = _a.onPressIndicator, onMount = _a.onMount, body = _a.body, title = _a.title, buttonTitle = _a.buttonTitle, ctaVariant = _a.ctaVariant, image = _a.image, testID = _a.testID, _b = _a.accessibilityLabel, accessibilityLabel = _b === void 0 ? 'image' : _b, _c = _a.inverted, inverted = _c === void 0 ? false : _c, _d = _a.inline, inline = _d === void 0 ? false : _d;
|
|
23
23
|
var _e = useContext(ThemeContext), core = _e.core, semantic = _e.semantic;
|
|
24
|
+
var hasSingleAction = (onPressActionButton && !onPressIndicator && !onPressCloseButton) ||
|
|
25
|
+
(onPressIndicator && !onPressActionButton && !onPressCloseButton);
|
|
26
|
+
var cardAction = hasSingleAction
|
|
27
|
+
? onPressActionButton || onPressIndicator
|
|
28
|
+
: null;
|
|
24
29
|
useEffect(function () {
|
|
25
30
|
if (onMount) {
|
|
26
31
|
onMount();
|
|
@@ -29,7 +34,7 @@ export var ActionCard = function (_a) {
|
|
|
29
34
|
var Heading = inline ? Heading3 : Heading2;
|
|
30
35
|
var cardPadding = core.space[inline ? 4 : 6];
|
|
31
36
|
var negativeMarginAdjustment = -cardPadding;
|
|
32
|
-
return (_jsx(StyledCard, { onPress:
|
|
37
|
+
return (_jsx(StyledCard, { onPress: cardAction, inline: inline, inverted: inverted, reducedBottomPadding: Boolean(buttonTitle && !ctaVariant), testID: "".concat(testID, "-card"), children: _jsxs(View, { style: { flexDirection: 'row' }, children: [_jsx(View, { style: { flex: 1 }, children: _jsxs(Stack, { spaceBetween: 2, children: [_jsx(Heading, { style: {
|
|
33
38
|
color: inverted
|
|
34
39
|
? semantic.inverted.message.link
|
|
35
40
|
: semantic.message.branded,
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
import Animated, { useAnimatedStyle, useSharedValue, withSpring, } from 'react-native-reanimated';
|
|
7
|
+
import styled from '../../styled.native';
|
|
8
|
+
import { Heading4 } from '../Heading4';
|
|
9
|
+
import { FilterButton } from './components/FilterButton';
|
|
10
|
+
var springSettings = {
|
|
11
|
+
damping: 15,
|
|
12
|
+
};
|
|
13
|
+
export var FilterSection = function (_a) {
|
|
14
|
+
var filterTitle = _a.filterTitle, localFilter = _a.localFilter, setLocalFilter = _a.setLocalFilter, filters = _a.filters, multipleRows = _a.multipleRows;
|
|
15
|
+
var animatedX = useSharedValue(0);
|
|
16
|
+
var animatedY = useSharedValue(0);
|
|
17
|
+
var animatedWidth = useSharedValue(0);
|
|
18
|
+
var animatedHeight = useSharedValue(0);
|
|
19
|
+
var animatedBackgroundStyle = useAnimatedStyle(function () {
|
|
20
|
+
return {
|
|
21
|
+
transform: [
|
|
22
|
+
{ translateX: animatedX.value },
|
|
23
|
+
{ translateY: animatedY.value },
|
|
24
|
+
],
|
|
25
|
+
width: animatedWidth.value,
|
|
26
|
+
height: animatedHeight.value,
|
|
27
|
+
position: 'absolute',
|
|
28
|
+
borderRadius: 22,
|
|
29
|
+
backgroundColor: '#0a9828',
|
|
30
|
+
};
|
|
31
|
+
}, [animatedX, animatedY, animatedWidth, animatedHeight]);
|
|
32
|
+
return (_jsxs(SectionContainer, { children: [_jsx(BlackHeading4, { children: filterTitle }), _jsxs(FilterSelectorContainer, { children: [_jsx(Animated.View, { style: animatedBackgroundStyle }), filters.map(function (filter) { return (_jsx(FilterButton, { isSelected: localFilter.key === filter.key, label: filter.label, onPress: function (x, y, width) {
|
|
33
|
+
setLocalFilter(filter);
|
|
34
|
+
animatedX.value = withSpring(x, springSettings);
|
|
35
|
+
animatedY.value = withSpring(y, springSettings);
|
|
36
|
+
animatedWidth.value = withSpring(width, springSettings);
|
|
37
|
+
}, onLayout: function (width, height, x, y) {
|
|
38
|
+
if (localFilter.key === filter.key) {
|
|
39
|
+
animatedX.value = x;
|
|
40
|
+
// (adrian.pop) - I couldn't figure out how to make the positioning work once the
|
|
41
|
+
// choices go on the second row. The only way I could get it to work
|
|
42
|
+
// was to hardcode the denominator to 3 for the single row ones
|
|
43
|
+
// and 1.1 for the multiple row ones.
|
|
44
|
+
animatedY.value = y - height / (multipleRows ? 1.1 : 3);
|
|
45
|
+
animatedWidth.value = width;
|
|
46
|
+
animatedHeight.value = height;
|
|
47
|
+
}
|
|
48
|
+
}, multipleRows: multipleRows }, filter.key)); })] })] }));
|
|
49
|
+
};
|
|
50
|
+
var SectionContainer = styled.View(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n gap: ", "px;\n align-items: flex-start;\n"], ["\n gap: ", "px;\n align-items: flex-start;\n"])), function (_a) {
|
|
51
|
+
var theme = _a.theme;
|
|
52
|
+
return theme.core.space[2];
|
|
53
|
+
});
|
|
54
|
+
var FilterSelectorContainer = styled.View(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background-color: ", ";\n padding: ", "px;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-wrap: wrap;\n gap: ", "px;\n border-radius: 22px;\n width: 100%;\n"], ["\n background-color: ", ";\n padding: ", "px;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-wrap: wrap;\n gap: ", "px;\n border-radius: 22px;\n width: 100%;\n"])), function (_a) {
|
|
55
|
+
var theme = _a.theme;
|
|
56
|
+
return theme.core.color.neutral.lighter;
|
|
57
|
+
}, function (_a) {
|
|
58
|
+
var theme = _a.theme;
|
|
59
|
+
return theme.core.space[2];
|
|
60
|
+
}, function (_a) {
|
|
61
|
+
var theme = _a.theme;
|
|
62
|
+
return theme.core.space[1];
|
|
63
|
+
});
|
|
64
|
+
export var BlackHeading4 = styled(Heading4)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n color: black;\n"], ["\n color: black;\n"])));
|
|
65
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useEffect, useRef } from 'react';
|
|
7
|
+
import { Pressable } from 'react-native';
|
|
8
|
+
import Animated, { useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated';
|
|
9
|
+
import styled, { css } from '../../../styled.native';
|
|
10
|
+
import { P } from '../../P';
|
|
11
|
+
var AnimatedP = Animated.createAnimatedComponent(P);
|
|
12
|
+
export var FilterButton = function (_a) {
|
|
13
|
+
var onPress = _a.onPress, onLayout = _a.onLayout, isSelected = _a.isSelected, label = _a.label, multipleRows = _a.multipleRows;
|
|
14
|
+
var xRef = useRef(0);
|
|
15
|
+
var yRef = useRef(0);
|
|
16
|
+
var widthRef = useRef(0);
|
|
17
|
+
var heightRef = useRef(0);
|
|
18
|
+
var fontWeightAnim = useSharedValue(isSelected ? 1 : 0);
|
|
19
|
+
var animatedStyleNormal = useAnimatedStyle(function () {
|
|
20
|
+
return {
|
|
21
|
+
opacity: 1 - fontWeightAnim.value,
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
};
|
|
24
|
+
}, [fontWeightAnim]);
|
|
25
|
+
var animatedStyleBold = useAnimatedStyle(function () {
|
|
26
|
+
return {
|
|
27
|
+
opacity: fontWeightAnim.value,
|
|
28
|
+
position: 'absolute',
|
|
29
|
+
};
|
|
30
|
+
}, [fontWeightAnim]);
|
|
31
|
+
useEffect(function () {
|
|
32
|
+
fontWeightAnim.value = withTiming(isSelected ? 1 : 0);
|
|
33
|
+
}, [fontWeightAnim, isSelected]);
|
|
34
|
+
var handleLayout = function (event) {
|
|
35
|
+
var _a = event.nativeEvent.layout, width = _a.width, height = _a.height, x = _a.x, y = _a.y;
|
|
36
|
+
xRef.current = x;
|
|
37
|
+
yRef.current = y;
|
|
38
|
+
widthRef.current = width;
|
|
39
|
+
heightRef.current = height;
|
|
40
|
+
onLayout(width, height, x, y);
|
|
41
|
+
};
|
|
42
|
+
var handlePress = function () {
|
|
43
|
+
onPress(xRef.current,
|
|
44
|
+
// (adrian.pop) - I couldn't figure out how to make the positioning work once the
|
|
45
|
+
// choices go on the second row. The only way I could get it to work
|
|
46
|
+
// was to hardcode the denominator to 3 for the single row ones
|
|
47
|
+
// and 1.1 for the multiple row ones.
|
|
48
|
+
yRef.current - heightRef.current / (multipleRows ? 1.1 : 3), widthRef.current);
|
|
49
|
+
};
|
|
50
|
+
return (_jsx(Pressable, { onLayout: handleLayout, onPress: handlePress, accessibilityRole: "checkbox", accessibilityState: { selected: isSelected }, children: _jsxs(SFilterSelector, { "$isSelected": isSelected, children: [_jsx(SFilterText, { style: {
|
|
51
|
+
opacity: 0,
|
|
52
|
+
fontWeight: '900',
|
|
53
|
+
}, "$isSelected": false, children: label }), _jsx(SFilterText, { style: animatedStyleNormal, "$isSelected": false, numberOfLines: 1, adjustsFontSizeToFit: true, children: label }), _jsx(SFilterText, { style: animatedStyleBold, "$isSelected": true, numberOfLines: 1, adjustsFontSizeToFit: true, children: label })] }) }));
|
|
54
|
+
};
|
|
55
|
+
var SFilterSelector = styled.View(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 0 ", "px;\n border-radius: ", "px;\n align-items: center;\n justify-content: center;\n"], ["\n padding: 0 ", "px;\n border-radius: ", "px;\n align-items: center;\n justify-content: center;\n"])), function (_a) {
|
|
56
|
+
var theme = _a.theme;
|
|
57
|
+
return theme.core.space[4];
|
|
58
|
+
}, function (_a) {
|
|
59
|
+
var theme = _a.theme;
|
|
60
|
+
return theme.core.radius.large;
|
|
61
|
+
});
|
|
62
|
+
var SFilterText = styled(AnimatedP)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (_a) {
|
|
63
|
+
var $isSelected = _a.$isSelected, theme = _a.theme;
|
|
64
|
+
return $isSelected && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n color: ", ";\n font-weight: ", ";\n "], ["\n color: ", ";\n font-weight: ", ";\n "])), theme.core.color.brand.white, theme.core.fontWeight.bold);
|
|
65
|
+
});
|
|
66
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ovotech/element-native",
|
|
3
|
-
"version": "4.0.2-canary-
|
|
3
|
+
"version": "4.0.2-canary-e8705c2-255",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@backpackapp-io/react-native-toast": "^0.10.0",
|
|
17
|
-
"@ovotech/element-core": "3.0.1-canary-
|
|
17
|
+
"@ovotech/element-core": "3.0.1-canary-e8705c2-255",
|
|
18
18
|
"deepmerge": "^4.2.2",
|
|
19
19
|
"lodash.groupby": "^4.6.0",
|
|
20
20
|
"react-native-reanimated-carousel": "^3.5.1"
|