@hero-design/rn 7.20.0 → 7.21.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 (106) hide show
  1. package/.eslintrc.json +1 -0
  2. package/.turbo/turbo-build.log +2 -2
  3. package/es/index.js +410 -285
  4. package/lib/index.js +410 -282
  5. package/package.json +4 -2
  6. package/rollup.config.js +1 -0
  7. package/src/components/BottomSheet/index.tsx +6 -1
  8. package/src/components/Checkbox/__tests__/__snapshots__/StyledCheckbox.spec.tsx.snap +4 -4
  9. package/src/components/Checkbox/__tests__/__snapshots__/index.spec.tsx.snap +13 -13
  10. package/src/components/Empty/StyledEmpty.tsx +1 -9
  11. package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +58 -5
  12. package/src/components/Empty/__tests__/index.spec.tsx +13 -0
  13. package/src/components/Empty/index.tsx +38 -18
  14. package/src/components/Image/__tests__/__snapshots__/index.spec.tsx.snap +81 -0
  15. package/src/components/Image/__tests__/index.spec.tsx +29 -0
  16. package/src/components/Image/index.tsx +46 -0
  17. package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +5 -5
  18. package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +60 -60
  19. package/src/components/RichTextEditor/EditorToolbar.tsx +19 -18
  20. package/src/components/RichTextEditor/RichTextEditor.tsx +7 -2
  21. package/src/components/RichTextEditor/StyledRichTextEditor.ts +0 -2
  22. package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +7 -4
  23. package/src/components/RichTextEditor/__tests__/__snapshots__/EditorToolbar.spec.tsx.snap +2 -2
  24. package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +4 -12
  25. package/src/components/RichTextEditor/constants.ts +0 -11
  26. package/src/components/RichTextEditor/index.tsx +0 -3
  27. package/src/components/RichTextEditor/types.ts +9 -0
  28. package/src/components/Select/MultiSelect/OptionList.tsx +4 -6
  29. package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +21 -0
  30. package/src/components/Select/MultiSelect/index.tsx +33 -3
  31. package/src/components/Select/SingleSelect/OptionList.tsx +4 -5
  32. package/src/components/Select/SingleSelect/__tests__/index.spec.tsx +16 -0
  33. package/src/components/Select/SingleSelect/index.tsx +34 -4
  34. package/src/components/Select/StyledOptionList.tsx +3 -9
  35. package/src/components/Slider/__tests__/__snapshots__/index.spec.tsx.snap +43 -0
  36. package/src/components/Slider/__tests__/index.spec.tsx +33 -0
  37. package/src/components/Slider/index.tsx +89 -0
  38. package/src/components/Switch/StyledSwitch.tsx +4 -4
  39. package/src/components/Switch/__tests__/__snapshots__/StyledSwitch.spec.tsx.snap +10 -10
  40. package/src/components/Switch/__tests__/__snapshots__/index.spec.tsx.snap +8 -8
  41. package/src/components/Switch/index.tsx +5 -4
  42. package/src/components/TextInput/index.tsx +43 -37
  43. package/src/index.ts +4 -0
  44. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +56 -11
  45. package/src/theme/components/alert.ts +1 -2
  46. package/src/theme/components/avatar.ts +8 -8
  47. package/src/theme/components/badge.ts +4 -4
  48. package/src/theme/components/bottomNavigation.ts +1 -1
  49. package/src/theme/components/bottomSheet.ts +2 -3
  50. package/src/theme/components/calendar.ts +9 -7
  51. package/src/theme/components/card.ts +1 -1
  52. package/src/theme/components/checkbox.ts +2 -5
  53. package/src/theme/components/datePicker.ts +3 -3
  54. package/src/theme/components/drawer.ts +2 -3
  55. package/src/theme/components/empty.ts +3 -8
  56. package/src/theme/components/fab.ts +2 -2
  57. package/src/theme/components/image.ts +12 -0
  58. package/src/theme/components/pinInput.ts +3 -3
  59. package/src/theme/components/progress.ts +2 -3
  60. package/src/theme/components/radio.ts +7 -3
  61. package/src/theme/components/richTextEditor.ts +4 -4
  62. package/src/theme/components/slider.ts +13 -0
  63. package/src/theme/components/switch.ts +16 -1
  64. package/src/theme/components/tabs.ts +1 -1
  65. package/src/theme/components/timePicker.ts +3 -3
  66. package/src/theme/components/toast.ts +1 -2
  67. package/src/theme/getTheme.ts +9 -2
  68. package/src/theme/global/colors/swag.ts +2 -0
  69. package/src/theme/global/colors/types.ts +2 -0
  70. package/src/theme/global/index.ts +3 -0
  71. package/src/theme/global/scale.ts +3 -0
  72. package/src/theme/global/sizes.ts +29 -0
  73. package/src/types.ts +0 -2
  74. package/testUtils/setup.tsx +14 -0
  75. package/types/components/BottomSheet/index.d.ts +5 -1
  76. package/types/components/Empty/StyledEmpty.d.ts +1 -7
  77. package/types/components/Empty/index.d.ts +8 -2
  78. package/types/components/Image/__tests__/index.spec.d.ts +1 -0
  79. package/types/components/Image/index.d.ts +17 -0
  80. package/types/components/RichTextEditor/EditorToolbar.d.ts +1 -1
  81. package/types/components/RichTextEditor/RichTextEditor.d.ts +4 -0
  82. package/types/components/RichTextEditor/constants.d.ts +0 -10
  83. package/types/components/RichTextEditor/index.d.ts +0 -2
  84. package/types/components/RichTextEditor/types.d.ts +1 -0
  85. package/types/components/Select/MultiSelect/OptionList.d.ts +5 -2
  86. package/types/components/Select/MultiSelect/index.d.ts +7 -1
  87. package/types/components/Select/SingleSelect/OptionList.d.ts +5 -2
  88. package/types/components/Select/SingleSelect/index.d.ts +8 -2
  89. package/types/components/Select/StyledOptionList.d.ts +4 -3
  90. package/types/components/Select/index.d.ts +1 -1
  91. package/types/components/Slider/__tests__/index.spec.d.ts +1 -0
  92. package/types/components/Slider/index.d.ts +52 -0
  93. package/types/components/TextInput/index.d.ts +2 -1
  94. package/types/index.d.ts +3 -1
  95. package/types/theme/components/datePicker.d.ts +2 -1
  96. package/types/theme/components/empty.d.ts +2 -5
  97. package/types/theme/components/image.d.ts +8 -0
  98. package/types/theme/components/slider.d.ts +9 -0
  99. package/types/theme/components/switch.d.ts +14 -1
  100. package/types/theme/components/timePicker.d.ts +2 -1
  101. package/types/theme/getTheme.d.ts +4 -0
  102. package/types/theme/global/colors/types.d.ts +2 -0
  103. package/types/theme/global/index.d.ts +3 -0
  104. package/types/theme/global/scale.d.ts +1 -0
  105. package/types/theme/global/sizes.d.ts +14 -0
  106. package/types/types.d.ts +1 -2
@@ -96,9 +96,9 @@ exports[`Progress.Circle renders correctly 1`] = `
96
96
  style={
97
97
  Array [
98
98
  Object {
99
- "height": 76,
99
+ "height": 72,
100
100
  "overflow": "hidden",
101
- "width": 38,
101
+ "width": 36,
102
102
  },
103
103
  undefined,
104
104
  ]
@@ -110,8 +110,8 @@ exports[`Progress.Circle renders correctly 1`] = `
110
110
  Object {
111
111
  "backgroundColor": "#8505a2",
112
112
  "borderRadius": 999,
113
- "height": 76,
114
- "width": 76,
113
+ "height": 72,
114
+ "width": 72,
115
115
  },
116
116
  undefined,
117
117
  ]
@@ -131,13 +131,13 @@ exports[`Progress.Circle renders correctly 1`] = `
131
131
  "top": 0,
132
132
  "transform": Array [
133
133
  Object {
134
- "translateX": 19,
134
+ "translateX": 18,
135
135
  },
136
136
  Object {
137
137
  "rotate": "0deg",
138
138
  },
139
139
  Object {
140
- "translateX": -19,
140
+ "translateX": -18,
141
141
  },
142
142
  ],
143
143
  }
@@ -147,9 +147,9 @@ exports[`Progress.Circle renders correctly 1`] = `
147
147
  style={
148
148
  Array [
149
149
  Object {
150
- "height": 76,
150
+ "height": 72,
151
151
  "overflow": "hidden",
152
- "width": 38,
152
+ "width": 36,
153
153
  },
154
154
  undefined,
155
155
  ]
@@ -161,8 +161,8 @@ exports[`Progress.Circle renders correctly 1`] = `
161
161
  Object {
162
162
  "backgroundColor": "#e8e9ea",
163
163
  "borderRadius": 999,
164
- "height": 76,
165
- "width": 76,
164
+ "height": 72,
165
+ "width": 72,
166
166
  },
167
167
  undefined,
168
168
  ]
@@ -188,9 +188,9 @@ exports[`Progress.Circle renders correctly 1`] = `
188
188
  style={
189
189
  Array [
190
190
  Object {
191
- "height": 76,
191
+ "height": 72,
192
192
  "overflow": "hidden",
193
- "width": 38,
193
+ "width": 36,
194
194
  },
195
195
  undefined,
196
196
  ]
@@ -202,8 +202,8 @@ exports[`Progress.Circle renders correctly 1`] = `
202
202
  Object {
203
203
  "backgroundColor": "#8505a2",
204
204
  "borderRadius": 999,
205
- "height": 76,
206
- "width": 76,
205
+ "height": 72,
206
+ "width": 72,
207
207
  },
208
208
  undefined,
209
209
  ]
@@ -224,13 +224,13 @@ exports[`Progress.Circle renders correctly 1`] = `
224
224
  "top": 0,
225
225
  "transform": Array [
226
226
  Object {
227
- "translateX": 19,
227
+ "translateX": 18,
228
228
  },
229
229
  Object {
230
230
  "rotate": "0deg",
231
231
  },
232
232
  Object {
233
- "translateX": -19,
233
+ "translateX": -18,
234
234
  },
235
235
  ],
236
236
  }
@@ -240,9 +240,9 @@ exports[`Progress.Circle renders correctly 1`] = `
240
240
  style={
241
241
  Array [
242
242
  Object {
243
- "height": 76,
243
+ "height": 72,
244
244
  "overflow": "hidden",
245
- "width": 38,
245
+ "width": 36,
246
246
  },
247
247
  undefined,
248
248
  ]
@@ -254,8 +254,8 @@ exports[`Progress.Circle renders correctly 1`] = `
254
254
  Object {
255
255
  "backgroundColor": "#e8e9ea",
256
256
  "borderRadius": 999,
257
- "height": 76,
258
- "width": 76,
257
+ "height": 72,
258
+ "width": 72,
259
259
  },
260
260
  undefined,
261
261
  ]
@@ -270,11 +270,11 @@ exports[`Progress.Circle renders correctly 1`] = `
270
270
  Object {
271
271
  "backgroundColor": "#8505a2",
272
272
  "borderRadius": 999,
273
- "height": 5.7,
274
- "left": 35.15,
273
+ "height": 5.3999999999999995,
274
+ "left": 33.3,
275
275
  "position": "absolute",
276
276
  "top": 0,
277
- "width": 5.7,
277
+ "width": 5.3999999999999995,
278
278
  "zIndex": 2,
279
279
  },
280
280
  undefined,
@@ -307,11 +307,11 @@ exports[`Progress.Circle renders correctly 1`] = `
307
307
  Object {
308
308
  "backgroundColor": "#8505a2",
309
309
  "borderRadius": 999,
310
- "height": 5.7,
311
- "left": 35.15,
310
+ "height": 5.3999999999999995,
311
+ "left": 33.3,
312
312
  "position": "absolute",
313
313
  "top": 0,
314
- "width": 5.7,
314
+ "width": 5.3999999999999995,
315
315
  "zIndex": 2,
316
316
  },
317
317
  undefined,
@@ -327,12 +327,12 @@ exports[`Progress.Circle renders correctly 1`] = `
327
327
  "alignItems": "center",
328
328
  "backgroundColor": "#ffffff",
329
329
  "borderRadius": 999,
330
- "height": 64.6,
330
+ "height": 61.199999999999996,
331
331
  "justifyContent": "center",
332
- "left": 5.7,
332
+ "left": 5.3999999999999995,
333
333
  "position": "absolute",
334
- "top": 5.7,
335
- "width": 64.6,
334
+ "top": 5.3999999999999995,
335
+ "width": 61.199999999999996,
336
336
  "zIndex": 3,
337
337
  },
338
338
  undefined,
@@ -383,9 +383,9 @@ exports[`Progress.Circle renders correctly with intent 1`] = `
383
383
  style={
384
384
  Array [
385
385
  Object {
386
- "height": 76,
386
+ "height": 72,
387
387
  "overflow": "hidden",
388
- "width": 38,
388
+ "width": 36,
389
389
  },
390
390
  undefined,
391
391
  ]
@@ -397,8 +397,8 @@ exports[`Progress.Circle renders correctly with intent 1`] = `
397
397
  Object {
398
398
  "backgroundColor": "#5ace7d",
399
399
  "borderRadius": 999,
400
- "height": 76,
401
- "width": 76,
400
+ "height": 72,
401
+ "width": 72,
402
402
  },
403
403
  undefined,
404
404
  ]
@@ -418,13 +418,13 @@ exports[`Progress.Circle renders correctly with intent 1`] = `
418
418
  "top": 0,
419
419
  "transform": Array [
420
420
  Object {
421
- "translateX": 19,
421
+ "translateX": 18,
422
422
  },
423
423
  Object {
424
424
  "rotate": "0deg",
425
425
  },
426
426
  Object {
427
- "translateX": -19,
427
+ "translateX": -18,
428
428
  },
429
429
  ],
430
430
  }
@@ -434,9 +434,9 @@ exports[`Progress.Circle renders correctly with intent 1`] = `
434
434
  style={
435
435
  Array [
436
436
  Object {
437
- "height": 76,
437
+ "height": 72,
438
438
  "overflow": "hidden",
439
- "width": 38,
439
+ "width": 36,
440
440
  },
441
441
  undefined,
442
442
  ]
@@ -448,8 +448,8 @@ exports[`Progress.Circle renders correctly with intent 1`] = `
448
448
  Object {
449
449
  "backgroundColor": "#e8e9ea",
450
450
  "borderRadius": 999,
451
- "height": 76,
452
- "width": 76,
451
+ "height": 72,
452
+ "width": 72,
453
453
  },
454
454
  undefined,
455
455
  ]
@@ -475,9 +475,9 @@ exports[`Progress.Circle renders correctly with intent 1`] = `
475
475
  style={
476
476
  Array [
477
477
  Object {
478
- "height": 76,
478
+ "height": 72,
479
479
  "overflow": "hidden",
480
- "width": 38,
480
+ "width": 36,
481
481
  },
482
482
  undefined,
483
483
  ]
@@ -489,8 +489,8 @@ exports[`Progress.Circle renders correctly with intent 1`] = `
489
489
  Object {
490
490
  "backgroundColor": "#5ace7d",
491
491
  "borderRadius": 999,
492
- "height": 76,
493
- "width": 76,
492
+ "height": 72,
493
+ "width": 72,
494
494
  },
495
495
  undefined,
496
496
  ]
@@ -511,13 +511,13 @@ exports[`Progress.Circle renders correctly with intent 1`] = `
511
511
  "top": 0,
512
512
  "transform": Array [
513
513
  Object {
514
- "translateX": 19,
514
+ "translateX": 18,
515
515
  },
516
516
  Object {
517
517
  "rotate": "0deg",
518
518
  },
519
519
  Object {
520
- "translateX": -19,
520
+ "translateX": -18,
521
521
  },
522
522
  ],
523
523
  }
@@ -527,9 +527,9 @@ exports[`Progress.Circle renders correctly with intent 1`] = `
527
527
  style={
528
528
  Array [
529
529
  Object {
530
- "height": 76,
530
+ "height": 72,
531
531
  "overflow": "hidden",
532
- "width": 38,
532
+ "width": 36,
533
533
  },
534
534
  undefined,
535
535
  ]
@@ -541,8 +541,8 @@ exports[`Progress.Circle renders correctly with intent 1`] = `
541
541
  Object {
542
542
  "backgroundColor": "#e8e9ea",
543
543
  "borderRadius": 999,
544
- "height": 76,
545
- "width": 76,
544
+ "height": 72,
545
+ "width": 72,
546
546
  },
547
547
  undefined,
548
548
  ]
@@ -557,11 +557,11 @@ exports[`Progress.Circle renders correctly with intent 1`] = `
557
557
  Object {
558
558
  "backgroundColor": "#5ace7d",
559
559
  "borderRadius": 999,
560
- "height": 5.7,
561
- "left": 35.15,
560
+ "height": 5.3999999999999995,
561
+ "left": 33.3,
562
562
  "position": "absolute",
563
563
  "top": 0,
564
- "width": 5.7,
564
+ "width": 5.3999999999999995,
565
565
  "zIndex": 2,
566
566
  },
567
567
  undefined,
@@ -594,11 +594,11 @@ exports[`Progress.Circle renders correctly with intent 1`] = `
594
594
  Object {
595
595
  "backgroundColor": "#5ace7d",
596
596
  "borderRadius": 999,
597
- "height": 5.7,
598
- "left": 35.15,
597
+ "height": 5.3999999999999995,
598
+ "left": 33.3,
599
599
  "position": "absolute",
600
600
  "top": 0,
601
- "width": 5.7,
601
+ "width": 5.3999999999999995,
602
602
  "zIndex": 2,
603
603
  },
604
604
  undefined,
@@ -614,12 +614,12 @@ exports[`Progress.Circle renders correctly with intent 1`] = `
614
614
  "alignItems": "center",
615
615
  "backgroundColor": "#ffffff",
616
616
  "borderRadius": 999,
617
- "height": 64.6,
617
+ "height": 61.199999999999996,
618
618
  "justifyContent": "center",
619
- "left": 5.7,
619
+ "left": 5.3999999999999995,
620
620
  "position": "absolute",
621
- "top": 5.7,
622
- "width": 64.6,
621
+ "top": 5.3999999999999995,
622
+ "width": 61.199999999999996,
623
623
  "zIndex": 3,
624
624
  },
625
625
  undefined,
@@ -1,13 +1,14 @@
1
1
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
2
2
  import type { ComponentType } from 'react';
3
3
  import Icon from '../Icon';
4
- import { ToolbarButtonName, ToolbarEvents } from './constants';
4
+ import { ToolbarEvents } from './constants';
5
5
  import { emitter } from './EditorEvent';
6
6
  import {
7
7
  StyledSeparator,
8
8
  StyledToolbar,
9
9
  StyledToolbarButton,
10
10
  } from './StyledToolbar';
11
+ import { ToolbarButtonName } from './types';
11
12
  import * as Events from './utils/events';
12
13
  import type { IconProps } from '../Icon';
13
14
 
@@ -35,34 +36,34 @@ interface ButtonConfig {
35
36
  }
36
37
 
37
38
  const buttonConfigs: Partial<Record<ToolbarButtonName, ButtonConfig>> = {
38
- [ToolbarButtonName.Bold]: {
39
+ bold: {
39
40
  icon: 'format-bold',
40
41
  eventName: ToolbarEvents.Bold,
41
42
  },
42
- [ToolbarButtonName.Italic]: {
43
+ italic: {
43
44
  icon: 'format-italic',
44
45
  eventName: ToolbarEvents.Italic,
45
46
  },
46
- [ToolbarButtonName.Underline]: {
47
+ underline: {
47
48
  icon: 'format-underlined',
48
49
  eventName: ToolbarEvents.Underline,
49
50
  },
50
- [ToolbarButtonName.BulletedList]: {
51
+ bulletedList: {
51
52
  icon: 'format-list-bulleted',
52
53
  eventName: ToolbarEvents.BulletedList,
53
54
  standalone: true,
54
55
  },
55
- [ToolbarButtonName.NumberedList]: {
56
+ numberedList: {
56
57
  icon: 'format-list-numbered',
57
58
  eventName: ToolbarEvents.NumberedList,
58
59
  standalone: true,
59
60
  },
60
- [ToolbarButtonName.HeadingOne]: {
61
+ headingOne: {
61
62
  icon: 'format-heading1',
62
63
  eventName: ToolbarEvents.HeadingOne,
63
64
  standalone: true,
64
65
  },
65
- [ToolbarButtonName.HeadingTwo]: {
66
+ headingTwo: {
66
67
  icon: 'format-heading2',
67
68
  eventName: ToolbarEvents.HeadingTwo,
68
69
  standalone: true,
@@ -70,15 +71,15 @@ const buttonConfigs: Partial<Record<ToolbarButtonName, ButtonConfig>> = {
70
71
  };
71
72
 
72
73
  const defaultButtons: ToolbarButtonName[] = [
73
- ToolbarButtonName.Bold,
74
- ToolbarButtonName.Italic,
75
- ToolbarButtonName.Underline,
76
- ToolbarButtonName.Seperator,
77
- ToolbarButtonName.BulletedList,
78
- ToolbarButtonName.NumberedList,
79
- ToolbarButtonName.Seperator,
80
- ToolbarButtonName.HeadingOne,
81
- ToolbarButtonName.HeadingTwo,
74
+ 'bold',
75
+ 'italic',
76
+ 'underline',
77
+ '|',
78
+ 'bulletedList',
79
+ 'numberedList',
80
+ '|',
81
+ 'headingOne',
82
+ 'headingTwo',
82
83
  ];
83
84
 
84
85
  export interface EditorToolbarProps {
@@ -180,7 +181,7 @@ const EditorToolbar = ({
180
181
  const toolbarButtons = useMemo(
181
182
  () =>
182
183
  toolbarButtonArray.map(button => {
183
- if (button.buttonName === ToolbarButtonName.Seperator) {
184
+ if (button.buttonName === '|') {
184
185
  return <StyledSeparator key={button.id} />;
185
186
  }
186
187
  const config = buttonConfigs[button.buttonName];
@@ -51,6 +51,10 @@ export type EditorValue = {
51
51
  }[];
52
52
 
53
53
  export interface RichTextEditorProps {
54
+ /**
55
+ * If true, the editor will be focused when the user enters the screen
56
+ */
57
+ autoFocus?: boolean;
54
58
  /**
55
59
  * Error message
56
60
  */
@@ -110,6 +114,7 @@ const defaultValue: EditorValue = [
110
114
  ];
111
115
 
112
116
  const RichTextEditor: ComponentType<RichTextEditorProps> = ({
117
+ autoFocus = true,
113
118
  name,
114
119
  placeholder = '',
115
120
  onChange = noop,
@@ -191,7 +196,7 @@ const RichTextEditor: ComponentType<RichTextEditorProps> = ({
191
196
  placeholder: "${placeholder}",
192
197
  initialValue: ${initialValueString},
193
198
  isAndroid: ${isAndroid ? 'true' : 'false'},
194
- autoFocus: true,
199
+ autoFocus: ${autoFocus},
195
200
  style: {
196
201
  padding: '0 !important',
197
202
  fontSize: ${theme.__hd__.richTextEditor.fontSizes.editor}
@@ -305,7 +310,7 @@ const RichTextEditor: ComponentType<RichTextEditorProps> = ({
305
310
  );
306
311
 
307
312
  return (
308
- <StyledContainer style={style} testID={testID}>
313
+ <StyledContainer testID={testID}>
309
314
  <StyledTextInputContainer>
310
315
  <StyledBorderBackDrop themeVariant={variant} />
311
316
  {(isFocused || (label && !isEmptyValue)) && (
@@ -14,7 +14,5 @@ export const StyledWebView = styled(WebView)<{
14
14
  backgroundColor: 'transparent',
15
15
  textAlignVertical: 'center',
16
16
  fontSize: theme.__hd__.textInput.fontSizes.text,
17
- alignSelf: 'stretch',
18
- flexGrow: 2,
19
17
  marginHorizontal: theme.__hd__.textInput.space.inputHorizontalMargin,
20
18
  }));
@@ -94,10 +94,13 @@ describe('RichTextEditor', () => {
94
94
  Events.on(EditorEventEmitter, 'rich-text-editor/editor-focus', () => {
95
95
  emittedEvents.push('called');
96
96
  });
97
- onMessageOfLatestRendering({
98
- nativeEvent: {
99
- data: '{"type": "@hero-editor/webview/editor-focus", "data" : {}}',
100
- },
97
+
98
+ act(() => {
99
+ onMessageOfLatestRendering({
100
+ nativeEvent: {
101
+ data: '{"type": "@hero-editor/webview/editor-focus", "data" : {}}',
102
+ },
103
+ });
101
104
  });
102
105
  expect(emittedEvents).toMatchObject(['called']);
103
106
  });
@@ -143,7 +143,7 @@ exports[`EditorToolbar when the editor is focused should render toolbar 1`] = `
143
143
  "flexDirection": "row",
144
144
  "height": 16,
145
145
  "marginHorizontal": 8,
146
- "width": 1,
146
+ "width": 2,
147
147
  },
148
148
  undefined,
149
149
  ]
@@ -236,7 +236,7 @@ exports[`EditorToolbar when the editor is focused should render toolbar 1`] = `
236
236
  "flexDirection": "row",
237
237
  "height": 16,
238
238
  "marginHorizontal": 8,
239
- "width": 1,
239
+ "width": 2,
240
240
  },
241
241
  undefined,
242
242
  ]
@@ -8,9 +8,7 @@ exports[`RichTextEditor onMessage recevied event editor-layout should update hei
8
8
  "marginVertical": 8,
9
9
  "width": "100%",
10
10
  },
11
- Object {
12
- "backgroundColor": "yellow",
13
- },
11
+ undefined,
14
12
  ]
15
13
  }
16
14
  >
@@ -163,13 +161,11 @@ exports[`RichTextEditor onMessage recevied event editor-layout should update hei
163
161
  style={
164
162
  Array [
165
163
  Object {
166
- "alignSelf": "stretch",
167
164
  "backgroundColor": "transparent",
168
- "flexGrow": 2,
169
165
  "fontSize": 14,
170
166
  "height": 480,
171
167
  "marginHorizontal": 8,
172
- "minHeight": 21,
168
+ "minHeight": 24,
173
169
  "textAlignVertical": "center",
174
170
  },
175
171
  Object {
@@ -272,9 +268,7 @@ exports[`RichTextEditor should render correctly 1`] = `
272
268
  "marginVertical": 8,
273
269
  "width": "100%",
274
270
  },
275
- Object {
276
- "backgroundColor": "yellow",
277
- },
271
+ undefined,
278
272
  ]
279
273
  }
280
274
  >
@@ -426,13 +420,11 @@ exports[`RichTextEditor should render correctly 1`] = `
426
420
  style={
427
421
  Array [
428
422
  Object {
429
- "alignSelf": "stretch",
430
423
  "backgroundColor": "transparent",
431
- "flexGrow": 2,
432
424
  "fontSize": 14,
433
425
  "height": undefined,
434
426
  "marginHorizontal": 8,
435
- "minHeight": 21,
427
+ "minHeight": 24,
436
428
  "textAlignVertical": "center",
437
429
  },
438
430
  Object {
@@ -7,14 +7,3 @@ export enum ToolbarEvents {
7
7
  HeadingOne = 'heading-one',
8
8
  HeadingTwo = 'heading-two',
9
9
  }
10
-
11
- export enum ToolbarButtonName {
12
- Bold = 'bold',
13
- Italic = 'italic',
14
- Underline = 'underline',
15
- BulletedList = 'bulletedList',
16
- NumberedList = 'numberedList',
17
- HeadingOne = 'headingOne',
18
- HeadingTwo = 'headingTwo',
19
- Seperator = '|',
20
- }
@@ -1,4 +1,3 @@
1
- import { ToolbarButtonName } from './constants';
2
1
  import Toolbar from './EditorToolbar';
3
2
  import MentionList from './MentionList';
4
3
  import RichTextEditor from './RichTextEditor';
@@ -6,8 +5,6 @@ import type { RichTextEditorProps, RichTextEditorRef } from './RichTextEditor';
6
5
 
7
6
  export type { RichTextEditorProps, RichTextEditorRef };
8
7
 
9
- export { ToolbarButtonName };
10
-
11
8
  export default Object.assign(RichTextEditor, {
12
9
  MentionList,
13
10
  Toolbar,
@@ -0,0 +1,9 @@
1
+ export type ToolbarButtonName =
2
+ | 'bold'
3
+ | 'italic'
4
+ | 'underline'
5
+ | 'bulletedList'
6
+ | 'numberedList'
7
+ | 'headingOne'
8
+ | 'headingTwo'
9
+ | '|';
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- import type { SectionListRenderItemInfo } from 'react-native';
3
- import { getScrollParams } from '../helpers';
2
+ import type { SectionListRenderItemInfo, SectionList } from 'react-native';
4
3
  import StyledOptionList from '../StyledOptionList';
5
4
  import Option from './Option';
6
5
  import type { MultiSelectProps } from '.';
@@ -17,6 +16,7 @@ type OptionListProps<V, T extends OptionType<V>> = Pick<
17
16
  > & {
18
17
  onPress: (value: V[]) => void;
19
18
  sections: SectionData<V, T>[];
19
+ sectionListRef?: React.RefObject<SectionList<T, SectionType>>;
20
20
  };
21
21
 
22
22
  const OptionList = <V, T extends OptionType<V>>({
@@ -28,10 +28,8 @@ const OptionList = <V, T extends OptionType<V>>({
28
28
  sections,
29
29
  renderOption,
30
30
  value,
31
+ sectionListRef,
31
32
  }: OptionListProps<V, T>) => {
32
- const firstValue = value?.[0];
33
- const scrollParams = getScrollParams(firstValue, sections);
34
-
35
33
  const renderItem = (info: SectionListRenderItemInfo<T, SectionType>) => {
36
34
  const { item } = info;
37
35
  const selected = value.includes(info.item.value);
@@ -63,7 +61,7 @@ const OptionList = <V, T extends OptionType<V>>({
63
61
  onQueryChange={onQueryChange}
64
62
  sections={sections}
65
63
  renderItem={renderItem}
66
- scrollParams={scrollParams}
64
+ sectionListRef={sectionListRef}
67
65
  />
68
66
  );
69
67
  };
@@ -174,6 +174,27 @@ describe('rendering', () => {
174
174
  expect(getByText('Josh')).toBeTruthy();
175
175
  expect(getByText('Junior Developer')).toBeTruthy();
176
176
  });
177
+
178
+ it('allows custom selected value', () => {
179
+ const { getByText } = renderWithTheme(
180
+ <MultiSelect<string, CustomOptionType>
181
+ label="Choose collaborators"
182
+ footerLabel="Confirm"
183
+ options={collaboratorSections}
184
+ value={['daniel', 'daemon']}
185
+ onConfirm={jest.fn()}
186
+ renderSelectedValue={(selectedValue, _inputProps) => (
187
+ <>
188
+ {selectedValue.map(value => (
189
+ <Typography.Text>Custom {value}</Typography.Text>
190
+ ))}
191
+ </>
192
+ )}
193
+ />
194
+ );
195
+ expect(getByText('Custom daniel')).toBeTruthy();
196
+ expect(getByText('Custom daemon')).toBeTruthy();
197
+ });
177
198
  });
178
199
 
179
200
  describe('behavior', () => {