@hero-design/rn 8.74.0 → 8.75.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/assets/fonts/hero-icons-mobile.ttf +0 -0
  3. package/es/index.js +800 -529
  4. package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
  5. package/lib/index.js +800 -528
  6. package/package.json +4 -4
  7. package/src/components/BottomSheet/__tests__/index.spec.tsx +17 -153
  8. package/src/components/BottomSheet/index.tsx +14 -13
  9. package/src/components/Collapse/__tests__/index.spec.tsx +2 -5
  10. package/src/components/FloatingIsland/StyledFloatingIsland.tsx +32 -0
  11. package/src/components/FloatingIsland/__tests__/__snapshots__/index.spec.tsx.snap +561 -0
  12. package/src/components/FloatingIsland/__tests__/index.spec.tsx +67 -0
  13. package/src/components/FloatingIsland/index.tsx +94 -0
  14. package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
  15. package/src/components/Icon/IconList.ts +4 -0
  16. package/src/components/Toolbar/StyledToolbar.tsx +50 -1
  17. package/src/components/Toolbar/ToolbarMessage.tsx +169 -0
  18. package/src/components/Toolbar/__tests__/ToolbarMessage.spec.tsx +161 -0
  19. package/src/components/Toolbar/__tests__/__snapshots__/ToolbarMessage.spec.tsx.snap +382 -0
  20. package/src/components/Toolbar/index.tsx +2 -0
  21. package/src/index.ts +2 -0
  22. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +46 -0
  23. package/src/theme/components/floatingIsland.ts +31 -0
  24. package/src/theme/components/toolbar.ts +19 -1
  25. package/src/theme/getTheme.ts +3 -0
  26. package/stats/8.74.1/rn-stats.html +4842 -0
  27. package/stats/8.75.0/rn-stats.html +4844 -0
  28. package/types/components/CompoundSearch/CompoundSearchHandler.d.ts +31 -0
  29. package/types/components/CompoundSearch/CompoundSearchTextInput.d.ts +60 -0
  30. package/types/components/CompoundSearch/StyledCompoundSearch.d.ts +40 -0
  31. package/types/components/CompoundSearch/index.d.ts +8 -0
  32. package/types/components/CompoundSearch/utils.d.ts +8 -0
  33. package/types/components/FloatingIsland/SingleLine/StyledSingleLine.d.ts +15 -0
  34. package/types/components/FloatingIsland/SingleLine/index.d.ts +24 -0
  35. package/types/components/FloatingIsland/StyledFloatingIsland.d.ts +19 -0
  36. package/types/components/FloatingIsland/index.d.ts +23 -0
  37. package/types/components/Icon/IconList.d.ts +1 -1
  38. package/types/components/Icon/index.d.ts +1 -1
  39. package/types/components/Icon/utils.d.ts +1 -1
  40. package/types/components/Search/utils.d.ts +2 -2
  41. package/types/components/TextInput/index.d.ts +3 -3
  42. package/types/components/Toolbar/StyledToolbar.d.ts +33 -2
  43. package/types/components/Toolbar/ToolbarMessage.d.ts +59 -0
  44. package/types/components/Toolbar/index.d.ts +1 -0
  45. package/types/index.d.ts +2 -1
  46. package/types/theme/components/compoundSearch.d.ts +36 -0
  47. package/types/theme/components/floatingIsland.d.ts +32 -0
  48. package/types/theme/components/toolbar.d.ts +16 -0
  49. package/types/theme/getTheme.d.ts +2 -0
  50. package/.turbo/turbo-build.log +0 -8
  51. package/src/components/BottomSheet/__tests__/__snapshots__/index.spec.tsx.snap +0 -751
@@ -0,0 +1,561 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`FloatingIsland renders correctly 1`] = `
4
+ <View
5
+ style={
6
+ {
7
+ "flex": 1,
8
+ }
9
+ }
10
+ >
11
+ <View
12
+ accessibilityState={
13
+ {
14
+ "busy": undefined,
15
+ "checked": undefined,
16
+ "disabled": true,
17
+ "expanded": undefined,
18
+ "selected": undefined,
19
+ }
20
+ }
21
+ accessibilityValue={
22
+ {
23
+ "max": undefined,
24
+ "min": undefined,
25
+ "now": undefined,
26
+ "text": undefined,
27
+ }
28
+ }
29
+ accessible={true}
30
+ collapsable={false}
31
+ focusable={false}
32
+ onClick={[Function]}
33
+ onLayout={[Function]}
34
+ onResponderGrant={[Function]}
35
+ onResponderMove={[Function]}
36
+ onResponderRelease={[Function]}
37
+ onResponderTerminate={[Function]}
38
+ onResponderTerminationRequest={[Function]}
39
+ onStartShouldSetResponder={[Function]}
40
+ style={
41
+ {
42
+ "alignItems": "center",
43
+ "alignSelf": "flex-start",
44
+ "backgroundColor": "#ffffff",
45
+ "borderRadius": 999,
46
+ "elevation": 3,
47
+ "flexDirection": "row",
48
+ "justifyContent": "center",
49
+ "left": "50%",
50
+ "opacity": 1,
51
+ "padding": 8,
52
+ "position": "absolute",
53
+ "shadowColor": "#001f23",
54
+ "shadowOffset": {
55
+ "height": 2,
56
+ "width": 0,
57
+ },
58
+ "shadowOpacity": 0.12,
59
+ "shadowRadius": 4,
60
+ "top": 12,
61
+ "zIndex": 9999,
62
+ }
63
+ }
64
+ >
65
+ <Text
66
+ allowFontScaling={false}
67
+ style={
68
+ [
69
+ {
70
+ "color": "#001f23",
71
+ "fontFamily": "BeVietnamPro-Regular",
72
+ "fontSize": 16,
73
+ "letterSpacing": 0.48,
74
+ "lineHeight": 24,
75
+ },
76
+ undefined,
77
+ ]
78
+ }
79
+ themeIntent="body"
80
+ themeTypeface="neutral"
81
+ themeVariant="regular"
82
+ >
83
+ Content
84
+ </Text>
85
+ </View>
86
+ <View
87
+ pointerEvents="box-none"
88
+ position="bottom"
89
+ style={
90
+ [
91
+ {
92
+ "bottom": 0,
93
+ "elevation": 9999,
94
+ "flexDirection": "column-reverse",
95
+ "left": 0,
96
+ "paddingHorizontal": 24,
97
+ "paddingVertical": 16,
98
+ "position": "absolute",
99
+ "right": 0,
100
+ "top": 0,
101
+ },
102
+ undefined,
103
+ ]
104
+ }
105
+ />
106
+ </View>
107
+ `;
108
+
109
+ exports[`FloatingIsland renders icons as prefix and suffix correctly 1`] = `
110
+ <View
111
+ style={
112
+ {
113
+ "flex": 1,
114
+ }
115
+ }
116
+ >
117
+ <View
118
+ accessibilityState={
119
+ {
120
+ "busy": undefined,
121
+ "checked": undefined,
122
+ "disabled": true,
123
+ "expanded": undefined,
124
+ "selected": undefined,
125
+ }
126
+ }
127
+ accessibilityValue={
128
+ {
129
+ "max": undefined,
130
+ "min": undefined,
131
+ "now": undefined,
132
+ "text": undefined,
133
+ }
134
+ }
135
+ accessible={true}
136
+ collapsable={false}
137
+ focusable={false}
138
+ onClick={[Function]}
139
+ onLayout={[Function]}
140
+ onResponderGrant={[Function]}
141
+ onResponderMove={[Function]}
142
+ onResponderRelease={[Function]}
143
+ onResponderTerminate={[Function]}
144
+ onResponderTerminationRequest={[Function]}
145
+ onStartShouldSetResponder={[Function]}
146
+ style={
147
+ {
148
+ "alignItems": "center",
149
+ "alignSelf": "flex-start",
150
+ "backgroundColor": "#ffffff",
151
+ "borderRadius": 999,
152
+ "elevation": 3,
153
+ "flexDirection": "row",
154
+ "justifyContent": "center",
155
+ "left": "50%",
156
+ "opacity": 1,
157
+ "padding": 8,
158
+ "position": "absolute",
159
+ "shadowColor": "#001f23",
160
+ "shadowOffset": {
161
+ "height": 2,
162
+ "width": 0,
163
+ },
164
+ "shadowOpacity": 0.12,
165
+ "shadowRadius": 4,
166
+ "top": 12,
167
+ "zIndex": 9999,
168
+ }
169
+ }
170
+ >
171
+ <View
172
+ style={
173
+ [
174
+ {},
175
+ [
176
+ {
177
+ "marginRight": 8,
178
+ },
179
+ undefined,
180
+ ],
181
+ ]
182
+ }
183
+ >
184
+ <HeroIcon
185
+ name="calendar"
186
+ style={
187
+ [
188
+ {
189
+ "color": "#001f23",
190
+ "fontSize": 20,
191
+ },
192
+ [
193
+ {
194
+ "padding": 12,
195
+ },
196
+ undefined,
197
+ ],
198
+ ]
199
+ }
200
+ testID="floating-island-prefix-icon"
201
+ themeIntent="text"
202
+ themeSize="small"
203
+ />
204
+ </View>
205
+ <Text
206
+ allowFontScaling={false}
207
+ style={
208
+ [
209
+ {
210
+ "color": "#001f23",
211
+ "fontFamily": "BeVietnamPro-Regular",
212
+ "fontSize": 16,
213
+ "letterSpacing": 0.48,
214
+ "lineHeight": 24,
215
+ },
216
+ undefined,
217
+ ]
218
+ }
219
+ themeIntent="body"
220
+ themeTypeface="neutral"
221
+ themeVariant="regular"
222
+ >
223
+ Content
224
+ </Text>
225
+ <View
226
+ style={
227
+ [
228
+ {},
229
+ [
230
+ {
231
+ "marginLeft": 16,
232
+ },
233
+ undefined,
234
+ ],
235
+ ]
236
+ }
237
+ >
238
+ <HeroIcon
239
+ name="cancel"
240
+ style={
241
+ [
242
+ {
243
+ "color": "#001f23",
244
+ "fontSize": 20,
245
+ },
246
+ [
247
+ {
248
+ "padding": 12,
249
+ },
250
+ undefined,
251
+ ],
252
+ ]
253
+ }
254
+ testID="floating-island-suffix-icon"
255
+ themeIntent="text"
256
+ themeSize="small"
257
+ />
258
+ </View>
259
+ </View>
260
+ <View
261
+ pointerEvents="box-none"
262
+ position="bottom"
263
+ style={
264
+ [
265
+ {
266
+ "bottom": 0,
267
+ "elevation": 9999,
268
+ "flexDirection": "column-reverse",
269
+ "left": 0,
270
+ "paddingHorizontal": 24,
271
+ "paddingVertical": 16,
272
+ "position": "absolute",
273
+ "right": 0,
274
+ "top": 0,
275
+ },
276
+ undefined,
277
+ ]
278
+ }
279
+ />
280
+ </View>
281
+ `;
282
+
283
+ exports[`FloatingIsland renders prefix correctly 1`] = `
284
+ <View
285
+ style={
286
+ {
287
+ "flex": 1,
288
+ }
289
+ }
290
+ >
291
+ <View
292
+ accessibilityState={
293
+ {
294
+ "busy": undefined,
295
+ "checked": undefined,
296
+ "disabled": true,
297
+ "expanded": undefined,
298
+ "selected": undefined,
299
+ }
300
+ }
301
+ accessibilityValue={
302
+ {
303
+ "max": undefined,
304
+ "min": undefined,
305
+ "now": undefined,
306
+ "text": undefined,
307
+ }
308
+ }
309
+ accessible={true}
310
+ collapsable={false}
311
+ focusable={false}
312
+ onClick={[Function]}
313
+ onLayout={[Function]}
314
+ onResponderGrant={[Function]}
315
+ onResponderMove={[Function]}
316
+ onResponderRelease={[Function]}
317
+ onResponderTerminate={[Function]}
318
+ onResponderTerminationRequest={[Function]}
319
+ onStartShouldSetResponder={[Function]}
320
+ style={
321
+ {
322
+ "alignItems": "center",
323
+ "alignSelf": "flex-start",
324
+ "backgroundColor": "#ffffff",
325
+ "borderRadius": 999,
326
+ "elevation": 3,
327
+ "flexDirection": "row",
328
+ "justifyContent": "center",
329
+ "left": "50%",
330
+ "opacity": 1,
331
+ "padding": 8,
332
+ "position": "absolute",
333
+ "shadowColor": "#001f23",
334
+ "shadowOffset": {
335
+ "height": 2,
336
+ "width": 0,
337
+ },
338
+ "shadowOpacity": 0.12,
339
+ "shadowRadius": 4,
340
+ "top": 12,
341
+ "zIndex": 9999,
342
+ }
343
+ }
344
+ >
345
+ <View
346
+ style={
347
+ [
348
+ {},
349
+ [
350
+ {
351
+ "marginRight": 8,
352
+ },
353
+ undefined,
354
+ ],
355
+ ]
356
+ }
357
+ >
358
+ <Text
359
+ allowFontScaling={false}
360
+ style={
361
+ [
362
+ {
363
+ "color": "#001f23",
364
+ "fontFamily": "BeVietnamPro-Regular",
365
+ "fontSize": 16,
366
+ "letterSpacing": 0.48,
367
+ "lineHeight": 24,
368
+ },
369
+ undefined,
370
+ ]
371
+ }
372
+ themeIntent="body"
373
+ themeTypeface="neutral"
374
+ themeVariant="regular"
375
+ >
376
+ Prefix
377
+ </Text>
378
+ </View>
379
+ <Text
380
+ allowFontScaling={false}
381
+ style={
382
+ [
383
+ {
384
+ "color": "#001f23",
385
+ "fontFamily": "BeVietnamPro-Regular",
386
+ "fontSize": 16,
387
+ "letterSpacing": 0.48,
388
+ "lineHeight": 24,
389
+ },
390
+ undefined,
391
+ ]
392
+ }
393
+ themeIntent="body"
394
+ themeTypeface="neutral"
395
+ themeVariant="regular"
396
+ >
397
+ Content
398
+ </Text>
399
+ </View>
400
+ <View
401
+ pointerEvents="box-none"
402
+ position="bottom"
403
+ style={
404
+ [
405
+ {
406
+ "bottom": 0,
407
+ "elevation": 9999,
408
+ "flexDirection": "column-reverse",
409
+ "left": 0,
410
+ "paddingHorizontal": 24,
411
+ "paddingVertical": 16,
412
+ "position": "absolute",
413
+ "right": 0,
414
+ "top": 0,
415
+ },
416
+ undefined,
417
+ ]
418
+ }
419
+ />
420
+ </View>
421
+ `;
422
+
423
+ exports[`FloatingIsland renders suffix correctly 1`] = `
424
+ <View
425
+ style={
426
+ {
427
+ "flex": 1,
428
+ }
429
+ }
430
+ >
431
+ <View
432
+ accessibilityState={
433
+ {
434
+ "busy": undefined,
435
+ "checked": undefined,
436
+ "disabled": true,
437
+ "expanded": undefined,
438
+ "selected": undefined,
439
+ }
440
+ }
441
+ accessibilityValue={
442
+ {
443
+ "max": undefined,
444
+ "min": undefined,
445
+ "now": undefined,
446
+ "text": undefined,
447
+ }
448
+ }
449
+ accessible={true}
450
+ collapsable={false}
451
+ focusable={false}
452
+ onClick={[Function]}
453
+ onLayout={[Function]}
454
+ onResponderGrant={[Function]}
455
+ onResponderMove={[Function]}
456
+ onResponderRelease={[Function]}
457
+ onResponderTerminate={[Function]}
458
+ onResponderTerminationRequest={[Function]}
459
+ onStartShouldSetResponder={[Function]}
460
+ style={
461
+ {
462
+ "alignItems": "center",
463
+ "alignSelf": "flex-start",
464
+ "backgroundColor": "#ffffff",
465
+ "borderRadius": 999,
466
+ "elevation": 3,
467
+ "flexDirection": "row",
468
+ "justifyContent": "center",
469
+ "left": "50%",
470
+ "opacity": 1,
471
+ "padding": 8,
472
+ "position": "absolute",
473
+ "shadowColor": "#001f23",
474
+ "shadowOffset": {
475
+ "height": 2,
476
+ "width": 0,
477
+ },
478
+ "shadowOpacity": 0.12,
479
+ "shadowRadius": 4,
480
+ "top": 12,
481
+ "zIndex": 9999,
482
+ }
483
+ }
484
+ >
485
+ <Text
486
+ allowFontScaling={false}
487
+ style={
488
+ [
489
+ {
490
+ "color": "#001f23",
491
+ "fontFamily": "BeVietnamPro-Regular",
492
+ "fontSize": 16,
493
+ "letterSpacing": 0.48,
494
+ "lineHeight": 24,
495
+ },
496
+ undefined,
497
+ ]
498
+ }
499
+ themeIntent="body"
500
+ themeTypeface="neutral"
501
+ themeVariant="regular"
502
+ >
503
+ Content
504
+ </Text>
505
+ <View
506
+ style={
507
+ [
508
+ {},
509
+ [
510
+ {
511
+ "marginLeft": 16,
512
+ },
513
+ undefined,
514
+ ],
515
+ ]
516
+ }
517
+ >
518
+ <Text
519
+ allowFontScaling={false}
520
+ style={
521
+ [
522
+ {
523
+ "color": "#001f23",
524
+ "fontFamily": "BeVietnamPro-Regular",
525
+ "fontSize": 16,
526
+ "letterSpacing": 0.48,
527
+ "lineHeight": 24,
528
+ },
529
+ undefined,
530
+ ]
531
+ }
532
+ themeIntent="body"
533
+ themeTypeface="neutral"
534
+ themeVariant="regular"
535
+ >
536
+ Suffix
537
+ </Text>
538
+ </View>
539
+ </View>
540
+ <View
541
+ pointerEvents="box-none"
542
+ position="bottom"
543
+ style={
544
+ [
545
+ {
546
+ "bottom": 0,
547
+ "elevation": 9999,
548
+ "flexDirection": "column-reverse",
549
+ "left": 0,
550
+ "paddingHorizontal": 24,
551
+ "paddingVertical": 16,
552
+ "position": "absolute",
553
+ "right": 0,
554
+ "top": 0,
555
+ },
556
+ undefined,
557
+ ]
558
+ }
559
+ />
560
+ </View>
561
+ `;
@@ -0,0 +1,67 @@
1
+ import { fireEvent } from '@testing-library/react-native';
2
+ import React from 'react';
3
+ import FloatingIsland from '..';
4
+ import renderWithTheme from '../../../testHelpers/renderWithTheme';
5
+ import Typography from '../../Typography';
6
+
7
+ const Content = () => <Typography.Body>Content</Typography.Body>;
8
+
9
+ describe('FloatingIsland', () => {
10
+ it('renders correctly', () => {
11
+ const { toJSON, getByText } = renderWithTheme(
12
+ <FloatingIsland>
13
+ <Content />
14
+ </FloatingIsland>
15
+ );
16
+
17
+ expect(toJSON()).toMatchSnapshot();
18
+ expect(getByText('Content')).toBeDefined();
19
+ });
20
+
21
+ it('calls onPress correctly', () => {
22
+ const onPress = jest.fn();
23
+ const { getByText } = renderWithTheme(
24
+ <FloatingIsland onPress={onPress}>
25
+ <Content />
26
+ </FloatingIsland>
27
+ );
28
+
29
+ fireEvent.press(getByText('Content'));
30
+
31
+ expect(onPress).toHaveBeenCalled();
32
+ });
33
+
34
+ it('renders icons as prefix and suffix correctly', () => {
35
+ const { toJSON, getByTestId } = renderWithTheme(
36
+ <FloatingIsland prefix="calendar" suffix="cancel">
37
+ <Content />
38
+ </FloatingIsland>
39
+ );
40
+
41
+ expect(toJSON()).toMatchSnapshot();
42
+ expect(getByTestId('floating-island-prefix-icon')).toBeDefined();
43
+ expect(getByTestId('floating-island-suffix-icon')).toBeDefined();
44
+ });
45
+
46
+ it('renders prefix correctly', () => {
47
+ const { toJSON, getByText } = renderWithTheme(
48
+ <FloatingIsland prefix={<Typography.Body>Prefix</Typography.Body>}>
49
+ <Content />
50
+ </FloatingIsland>
51
+ );
52
+
53
+ expect(toJSON()).toMatchSnapshot();
54
+ expect(getByText('Prefix')).toBeDefined();
55
+ });
56
+
57
+ it('renders suffix correctly', () => {
58
+ const { toJSON, getByText } = renderWithTheme(
59
+ <FloatingIsland suffix={<Typography.Body>Suffix</Typography.Body>}>
60
+ <Content />
61
+ </FloatingIsland>
62
+ );
63
+
64
+ expect(toJSON()).toMatchSnapshot();
65
+ expect(getByText('Content')).toBeDefined();
66
+ });
67
+ });
@@ -0,0 +1,94 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { LayoutChangeEvent, ViewProps } from 'react-native';
3
+ import {
4
+ StyledWrapper,
5
+ StyledPrefixWrapper,
6
+ StyledSuffixWrapper,
7
+ StyledIcon,
8
+ } from './StyledFloatingIsland';
9
+ import { IconName } from '../Icon';
10
+
11
+ export interface FloatingIslandProps extends ViewProps {
12
+ /**
13
+ * Callback that is called when the floating island is pressed.
14
+ */
15
+ onPress?: () => void;
16
+ /**
17
+ * Children of the floating island.
18
+ */
19
+ children: ReactNode;
20
+ /**
21
+ * Prefix element that is displayed before the children.
22
+ */
23
+ prefix?: IconName | ReactNode;
24
+ /**
25
+ * Suffix element that is displayed after the children.
26
+ */
27
+ suffix?: IconName | ReactNode;
28
+ }
29
+
30
+ const getPrefixOrSuffix = ({
31
+ element,
32
+ isPrefix = true,
33
+ }: {
34
+ element: IconName | ReactNode;
35
+ isPrefix: boolean;
36
+ }) => {
37
+ const Wrapper = isPrefix ? StyledPrefixWrapper : StyledSuffixWrapper;
38
+ if (typeof element === 'string') {
39
+ return (
40
+ <Wrapper>
41
+ <StyledIcon
42
+ testID={`floating-island-${isPrefix ? 'prefix' : 'suffix'}-icon`}
43
+ size="small"
44
+ icon={element as IconName}
45
+ />
46
+ </Wrapper>
47
+ );
48
+ }
49
+
50
+ return <Wrapper>{element}</Wrapper>;
51
+ };
52
+
53
+ const FloatingIsland = ({
54
+ onPress,
55
+ onLayout,
56
+ style,
57
+ children,
58
+ prefix,
59
+ suffix,
60
+ ...props
61
+ }: FloatingIslandProps) => {
62
+ const [width, setWidth] = React.useState(0);
63
+
64
+ const onWrapperLayout = (event: LayoutChangeEvent) => {
65
+ setWidth(event.nativeEvent.layout.width);
66
+
67
+ onLayout?.(event);
68
+ };
69
+
70
+ return (
71
+ <StyledWrapper
72
+ {...props}
73
+ onLayout={onWrapperLayout}
74
+ disabled={!onPress}
75
+ onPress={onPress}
76
+ style={[
77
+ style,
78
+ width > 0
79
+ ? {
80
+ transform: [{ translateX: -width / 2 }],
81
+ }
82
+ : undefined,
83
+ ]}
84
+ >
85
+ {prefix && getPrefixOrSuffix({ element: prefix, isPrefix: true })}
86
+
87
+ {children}
88
+
89
+ {suffix && getPrefixOrSuffix({ element: suffix, isPrefix: false })}
90
+ </StyledWrapper>
91
+ );
92
+ };
93
+
94
+ export default FloatingIsland;