@hero-design/rn 7.21.0 → 7.22.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 (58) hide show
  1. package/.eslintrc.js +11 -0
  2. package/.turbo/turbo-build.log +9 -9
  3. package/babel.config.js +1 -1
  4. package/es/index.js +357 -247
  5. package/lib/index.js +361 -251
  6. package/package.json +7 -15
  7. package/src/components/BottomNavigation/__tests__/index.spec.tsx +1 -1
  8. package/src/components/BottomNavigation/index.tsx +3 -3
  9. package/src/components/Box/helpers.ts +1 -1
  10. package/src/components/Calendar/index.tsx +9 -9
  11. package/src/components/Collapse/index.tsx +1 -1
  12. package/src/components/Drawer/DragableDrawer/helpers.ts +7 -3
  13. package/src/components/FAB/ActionGroup/index.tsx +1 -1
  14. package/src/components/Icon/HeroIcon/selection.json +7029 -1
  15. package/src/components/PinInput/index.tsx +1 -1
  16. package/src/components/RichTextEditor/EditorToolbar.tsx +3 -3
  17. package/src/components/RichTextEditor/RichTextEditor.tsx +5 -5
  18. package/src/components/RichTextEditor/__tests__/EditorToolbar.spec.tsx +2 -2
  19. package/src/components/RichTextEditor/__tests__/MentionList.spec.tsx +1 -1
  20. package/src/components/Select/MultiSelect/OptionList.tsx +1 -1
  21. package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +1 -1
  22. package/src/components/Select/MultiSelect/index.tsx +3 -3
  23. package/src/components/Select/SingleSelect/index.tsx +3 -3
  24. package/src/components/Select/helpers.tsx +4 -4
  25. package/src/components/Slider/index.tsx +1 -1
  26. package/src/components/Switch/SelectorSwitch/Option.tsx +67 -0
  27. package/src/components/Switch/SelectorSwitch/StyledSelectorSwitch.tsx +25 -0
  28. package/src/components/Switch/SelectorSwitch/__tests__/Option.spec.tsx +61 -0
  29. package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/Option.spec.tsx.snap +195 -0
  30. package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/index.spec.tsx.snap +121 -0
  31. package/src/components/Switch/SelectorSwitch/__tests__/index.spec.tsx +62 -0
  32. package/src/components/Switch/SelectorSwitch/index.tsx +60 -0
  33. package/src/components/Switch/index.tsx +4 -1
  34. package/src/components/Tabs/ScrollableTabs.tsx +12 -5
  35. package/src/components/Tabs/__tests__/ScrollableTabs.spec.tsx +1 -1
  36. package/src/components/Tabs/__tests__/index.spec.tsx +1 -1
  37. package/src/components/Tabs/index.tsx +13 -6
  38. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +3 -1
  39. package/src/components/TextInput/__tests__/index.spec.tsx +114 -112
  40. package/src/components/TextInput/index.tsx +29 -30
  41. package/src/components/Toast/ToastContainer.tsx +6 -6
  42. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +14 -12
  43. package/src/theme/components/switch.ts +14 -18
  44. package/testUtils/setup.tsx +1 -1
  45. package/tsconfig.json +1 -1
  46. package/types/components/Slider/index.d.ts +1 -1
  47. package/types/components/Switch/SelectorSwitch/Option.d.ts +10 -0
  48. package/types/components/Switch/SelectorSwitch/StyledSelectorSwitch.d.ts +19 -0
  49. package/types/components/Switch/SelectorSwitch/__tests__/Option.spec.d.ts +1 -0
  50. package/types/components/Switch/SelectorSwitch/__tests__/index.spec.d.ts +1 -0
  51. package/types/components/Switch/SelectorSwitch/index.d.ts +37 -0
  52. package/types/components/Switch/index.d.ts +5 -3
  53. package/types/components/Tabs/ScrollableTabs.d.ts +1 -1
  54. package/types/components/Tabs/index.d.ts +2 -2
  55. package/types/components/TextInput/index.d.ts +4 -4
  56. package/types/theme/components/switch.d.ts +14 -12
  57. package/.eslintrc.json +0 -62
  58. package/.prettierrc.json +0 -8
@@ -1,20 +1,21 @@
1
- import { fireEvent, within } from '@testing-library/react-native';
2
- import React from 'react';
3
- import renderWithTheme from '../../../testHelpers/renderWithTheme';
4
- import Icon from '../../Icon';
5
- import TextInput, { getVariant } from '../index';
6
-
7
- describe('getVariant', () => {
1
+ import { fireEvent, within } from "@testing-library/react-native";
2
+ import React from "react";
3
+ import { theme } from "../../..";
4
+ import renderWithTheme from "../../../testHelpers/renderWithTheme";
5
+ import Icon from "../../Icon";
6
+ import TextInput, { getVariant } from "../index";
7
+
8
+ describe("getVariant", () => {
8
9
  it.each`
9
10
  disabled | error | editable | loading | isFocused | isEmptyValue | expected
10
- ${false} | ${undefined} | ${true} | ${false} | ${false} | ${true} | ${'default'}
11
- ${false} | ${undefined} | ${true} | ${false} | ${false} | ${false} | ${'filled'}
12
- ${false} | ${undefined} | ${true} | ${false} | ${true} | ${true} | ${'focused'}
13
- ${false} | ${undefined} | ${false} | ${true} | ${true} | ${true} | ${'readonly'}
14
- ${false} | ${'This field is required'} | ${false} | ${false} | ${true} | ${true} | ${'error'}
15
- ${true} | ${'This field is required'} | ${false} | ${false} | ${true} | ${true} | ${'disabled'}
11
+ ${false} | ${undefined} | ${true} | ${false} | ${false} | ${true} | ${"default"}
12
+ ${false} | ${undefined} | ${true} | ${false} | ${false} | ${false} | ${"filled"}
13
+ ${false} | ${undefined} | ${true} | ${false} | ${true} | ${true} | ${"focused"}
14
+ ${false} | ${undefined} | ${false} | ${true} | ${true} | ${true} | ${"readonly"}
15
+ ${false} | ${"This field is required"} | ${false} | ${false} | ${true} | ${true} | ${"error"}
16
+ ${true} | ${"This field is required"} | ${false} | ${false} | ${true} | ${true} | ${"disabled"}
16
17
  `(
17
- 'should return the correct variant when disabled $disabled, errorMessage $errorMessage, editable $false, isFocused $isFocused, isEmptyValue $isEmptyValue',
18
+ "should return the correct variant when disabled $disabled, errorMessage $errorMessage, editable $false, isFocused $isFocused, isEmptyValue $isEmptyValue",
18
19
  ({
19
20
  disabled,
20
21
  error,
@@ -38,38 +39,39 @@ describe('getVariant', () => {
38
39
  );
39
40
  });
40
41
 
41
- describe('TextInput', () => {
42
- describe('idle', () => {
43
- it('renders correctly', () => {
42
+ describe("TextInput", () => {
43
+ describe("idle", () => {
44
+ it("renders correctly", () => {
44
45
  const { getByTestId, toJSON } = renderWithTheme(
45
46
  <TextInput
46
47
  label="Amount (AUD)"
47
48
  prefix="dollar-sign"
48
49
  suffix="arrow-down"
49
50
  testID="idle-text-input"
51
+ style={{ borderColor: theme.colors.danger }}
50
52
  />
51
53
  );
52
54
 
53
55
  expect(toJSON()).toMatchSnapshot();
54
- expect(getByTestId('idle-text-input')).toBeTruthy();
56
+ expect(getByTestId("idle-text-input")).toBeTruthy();
55
57
  expect(
56
- within(getByTestId('idle-text-input')).queryAllByTestId('text-input')
58
+ within(getByTestId("idle-text-input")).queryAllByTestId("text-input")
57
59
  ).toHaveLength(1);
58
60
  expect(
59
- within(getByTestId('idle-text-input')).queryAllByText('Amount (AUD)')
61
+ within(getByTestId("idle-text-input")).queryAllByText("Amount (AUD)")
60
62
  ).toHaveLength(1);
61
63
  expect(
62
- within(getByTestId('idle-text-input')).queryAllByTestId('input-label')
64
+ within(getByTestId("idle-text-input")).queryAllByTestId("input-label")
63
65
  ).toHaveLength(1);
64
66
  expect(
65
- within(getByTestId('idle-text-input')).queryAllByTestId('input-prefix')
67
+ within(getByTestId("idle-text-input")).queryAllByTestId("input-prefix")
66
68
  ).toHaveLength(1);
67
69
  expect(
68
- within(getByTestId('idle-text-input')).queryAllByTestId('input-suffix')
70
+ within(getByTestId("idle-text-input")).queryAllByTestId("input-suffix")
69
71
  ).toHaveLength(1);
70
72
  });
71
73
 
72
- it('should not render input-label if label is empty', () => {
74
+ it("should not render input-label if label is empty", () => {
73
75
  const { getByTestId } = renderWithTheme(
74
76
  <TextInput
75
77
  prefix="dollar-sign"
@@ -78,13 +80,13 @@ describe('TextInput', () => {
78
80
  />
79
81
  );
80
82
 
81
- expect(getByTestId('idle-text-input')).toBeTruthy();
83
+ expect(getByTestId("idle-text-input")).toBeTruthy();
82
84
  expect(
83
- within(getByTestId('idle-text-input')).queryAllByTestId('input-label')
85
+ within(getByTestId("idle-text-input")).queryAllByTestId("input-label")
84
86
  ).toHaveLength(0);
85
87
  });
86
88
 
87
- it('onChangeText, onBlur, onFocus', () => {
89
+ it("onChangeText, onBlur, onFocus", () => {
88
90
  const onChangeText = jest.fn();
89
91
  const onBlur = jest.fn();
90
92
  const onFocus = jest.fn();
@@ -100,23 +102,23 @@ describe('TextInput', () => {
100
102
  />
101
103
  );
102
104
 
103
- const testInput = within(getByTestId('idle-text-input')).getByTestId(
104
- 'text-input'
105
+ const testInput = within(getByTestId("idle-text-input")).getByTestId(
106
+ "text-input"
105
107
  );
106
108
 
107
- fireEvent.changeText(testInput, 'Thong Quach');
108
- expect(onChangeText).toHaveBeenCalledWith('Thong Quach');
109
+ fireEvent.changeText(testInput, "Thong Quach");
110
+ expect(onChangeText).toHaveBeenCalledWith("Thong Quach");
109
111
 
110
- fireEvent(testInput, 'blur');
112
+ fireEvent(testInput, "blur");
111
113
  expect(onBlur).toHaveBeenCalledTimes(1);
112
114
 
113
- fireEvent(testInput, 'focus');
115
+ fireEvent(testInput, "focus");
114
116
  expect(onFocus).toHaveBeenCalledTimes(1);
115
117
  });
116
118
  });
117
119
 
118
- describe('idle with suffix and prefix are React Element', () => {
119
- it('renders correctly', () => {
120
+ describe("idle with suffix and prefix are React Element", () => {
121
+ it("renders correctly", () => {
120
122
  const { toJSON, queryAllByTestId, queryAllByText } = renderWithTheme(
121
123
  <TextInput
122
124
  label="Amount (AUD)"
@@ -127,16 +129,16 @@ describe('TextInput', () => {
127
129
  );
128
130
 
129
131
  expect(toJSON()).toMatchSnapshot();
130
- expect(queryAllByText('Amount (AUD)')).toHaveLength(1);
131
- expect(queryAllByText('*')).toHaveLength(1);
132
- expect(queryAllByTestId('input-label')).toHaveLength(1);
133
- expect(queryAllByTestId('prefix-element')).toHaveLength(1);
134
- expect(queryAllByTestId('suffix-element')).toHaveLength(1);
135
- expect(queryAllByTestId('text-input')).toHaveLength(1);
132
+ expect(queryAllByText("Amount (AUD)")).toHaveLength(1);
133
+ expect(queryAllByText("*")).toHaveLength(1);
134
+ expect(queryAllByTestId("input-label")).toHaveLength(1);
135
+ expect(queryAllByTestId("prefix-element")).toHaveLength(1);
136
+ expect(queryAllByTestId("suffix-element")).toHaveLength(1);
137
+ expect(queryAllByTestId("text-input")).toHaveLength(1);
136
138
  });
137
139
  });
138
- describe('required', () => {
139
- it('renders correctly', () => {
140
+ describe("required", () => {
141
+ it("renders correctly", () => {
140
142
  const { toJSON, queryAllByTestId, queryAllByText } = renderWithTheme(
141
143
  <TextInput
142
144
  label="Amount (AUD)"
@@ -147,17 +149,17 @@ describe('TextInput', () => {
147
149
  );
148
150
 
149
151
  expect(toJSON()).toMatchSnapshot();
150
- expect(queryAllByText('Amount (AUD)')).toHaveLength(1);
151
- expect(queryAllByText('*')).toHaveLength(1);
152
- expect(queryAllByTestId('input-label')).toHaveLength(1);
153
- expect(queryAllByTestId('input-prefix')).toHaveLength(1);
154
- expect(queryAllByTestId('input-suffix')).toHaveLength(1);
155
- expect(queryAllByTestId('text-input')).toHaveLength(1);
152
+ expect(queryAllByText("Amount (AUD)")).toHaveLength(1);
153
+ expect(queryAllByText("*")).toHaveLength(1);
154
+ expect(queryAllByTestId("input-label")).toHaveLength(1);
155
+ expect(queryAllByTestId("input-prefix")).toHaveLength(1);
156
+ expect(queryAllByTestId("input-suffix")).toHaveLength(1);
157
+ expect(queryAllByTestId("text-input")).toHaveLength(1);
156
158
  });
157
159
  });
158
160
 
159
- describe('filled', () => {
160
- it('renders correctly', () => {
161
+ describe("filled", () => {
162
+ it("renders correctly", () => {
161
163
  const {
162
164
  toJSON,
163
165
  queryAllByTestId,
@@ -173,17 +175,17 @@ describe('TextInput', () => {
173
175
  );
174
176
 
175
177
  expect(toJSON()).toMatchSnapshot();
176
- expect(queryAllByText('Amount (AUD)')).toHaveLength(1);
177
- expect(queryAllByDisplayValue('100')).toHaveLength(1);
178
- expect(queryAllByTestId('input-label')).toHaveLength(1);
179
- expect(queryAllByTestId('input-prefix')).toHaveLength(1);
180
- expect(queryAllByTestId('input-suffix')).toHaveLength(1);
181
- expect(queryAllByTestId('text-input')).toHaveLength(1);
178
+ expect(queryAllByText("Amount (AUD)")).toHaveLength(1);
179
+ expect(queryAllByDisplayValue("100")).toHaveLength(1);
180
+ expect(queryAllByTestId("input-label")).toHaveLength(1);
181
+ expect(queryAllByTestId("input-prefix")).toHaveLength(1);
182
+ expect(queryAllByTestId("input-suffix")).toHaveLength(1);
183
+ expect(queryAllByTestId("text-input")).toHaveLength(1);
182
184
  });
183
185
  });
184
186
 
185
- describe('readonly', () => {
186
- it('renders correctly', () => {
187
+ describe("readonly", () => {
188
+ it("renders correctly", () => {
187
189
  const onChangeText = jest.fn();
188
190
  const {
189
191
  toJSON,
@@ -204,31 +206,31 @@ describe('TextInput', () => {
204
206
  );
205
207
 
206
208
  expect(toJSON()).toMatchSnapshot();
207
- expect(queryAllByText('Amount (AUD)')).toHaveLength(1);
208
- expect(queryAllByDisplayValue('100')).toHaveLength(1);
209
- expect(queryAllByTestId('input-label')).toHaveLength(1);
210
- expect(queryAllByTestId('input-prefix')).toHaveLength(1);
211
- expect(queryAllByTestId('input-suffix')).toHaveLength(1);
212
- expect(queryAllByTestId('text-input')).toHaveLength(1);
213
-
214
- expect(getByTestId('text-input')).not.toHaveProp('editable', 'false');
209
+ expect(queryAllByText("Amount (AUD)")).toHaveLength(1);
210
+ expect(queryAllByDisplayValue("100")).toHaveLength(1);
211
+ expect(queryAllByTestId("input-label")).toHaveLength(1);
212
+ expect(queryAllByTestId("input-prefix")).toHaveLength(1);
213
+ expect(queryAllByTestId("input-suffix")).toHaveLength(1);
214
+ expect(queryAllByTestId("text-input")).toHaveLength(1);
215
+
216
+ expect(getByTestId("text-input")).not.toHaveProp("editable", "false");
215
217
  });
216
218
  });
217
219
 
218
- describe('loading', () => {
219
- it('renders correctly', () => {
220
+ describe("loading", () => {
221
+ it("renders correctly", () => {
220
222
  const { toJSON, queryAllByTestId, getByTestId } = renderWithTheme(
221
223
  <TextInput suffix="arrow-down" loading />
222
224
  );
223
225
 
224
226
  expect(toJSON()).toMatchSnapshot();
225
- expect(queryAllByTestId('text-input')).toHaveLength(1);
226
- expect(getByTestId('input-suffix')).toHaveProp('name', 'loading');
227
+ expect(queryAllByTestId("text-input")).toHaveLength(1);
228
+ expect(getByTestId("input-suffix")).toHaveProp("name", "loading");
227
229
  });
228
230
  });
229
231
 
230
- describe('max length', () => {
231
- it('renders correctly', () => {
232
+ describe("max length", () => {
233
+ it("renders correctly", () => {
232
234
  const {
233
235
  toJSON,
234
236
  queryAllByTestId,
@@ -247,18 +249,18 @@ describe('TextInput', () => {
247
249
  );
248
250
 
249
251
  expect(toJSON()).toMatchSnapshot();
250
- expect(queryAllByText('Shout out')).toHaveLength(1);
251
- expect(queryAllByDisplayValue('shout out Tung Van')).toHaveLength(1);
252
- expect(queryAllByText('18/255')).toHaveLength(1);
253
- expect(queryAllByTestId('input-label')).toHaveLength(1);
254
- expect(queryAllByTestId('text-input')).toHaveLength(1);
252
+ expect(queryAllByText("Shout out")).toHaveLength(1);
253
+ expect(queryAllByDisplayValue("shout out Tung Van")).toHaveLength(1);
254
+ expect(queryAllByText("18/255")).toHaveLength(1);
255
+ expect(queryAllByTestId("input-label")).toHaveLength(1);
256
+ expect(queryAllByTestId("text-input")).toHaveLength(1);
255
257
 
256
- expect(getByTestId('text-input')).not.toHaveProp('multiline', 'true');
258
+ expect(getByTestId("text-input")).not.toHaveProp("multiline", "true");
257
259
  });
258
260
  });
259
261
 
260
- describe('disabled', () => {
261
- it('renders correctly', () => {
262
+ describe("disabled", () => {
263
+ it("renders correctly", () => {
262
264
  const { toJSON, queryAllByTestId, queryAllByText, getByTestId } =
263
265
  renderWithTheme(
264
266
  <TextInput
@@ -271,17 +273,17 @@ describe('TextInput', () => {
271
273
  );
272
274
 
273
275
  expect(toJSON()).toMatchSnapshot();
274
- expect(queryAllByText('Amount (AUD)')).toHaveLength(1);
275
- expect(queryAllByTestId('input-label')).toHaveLength(1);
276
- expect(queryAllByTestId('text-input')).toHaveLength(1);
277
- expect(getByTestId('disabled-text-input')).toBeDisabled();
276
+ expect(queryAllByText("Amount (AUD)")).toHaveLength(1);
277
+ expect(queryAllByTestId("input-label")).toHaveLength(1);
278
+ expect(queryAllByTestId("text-input")).toHaveLength(1);
279
+ expect(getByTestId("disabled-text-input")).toBeDisabled();
278
280
 
279
- expect(getByTestId('text-input')).not.toHaveProp('multiline', 'true');
281
+ expect(getByTestId("text-input")).not.toHaveProp("multiline", "true");
280
282
  });
281
283
  });
282
284
 
283
- describe('error', () => {
284
- it('renders correctly', () => {
285
+ describe("error", () => {
286
+ it("renders correctly", () => {
285
287
  const { toJSON, queryAllByText } = renderWithTheme(
286
288
  <TextInput
287
289
  label="Amount (AUD)"
@@ -292,12 +294,12 @@ describe('TextInput', () => {
292
294
  );
293
295
 
294
296
  expect(toJSON()).toMatchSnapshot();
295
- expect(queryAllByText('Amount (AUD)')).toHaveLength(1);
296
- expect(queryAllByText('This field is required')).toHaveLength(1);
297
+ expect(queryAllByText("Amount (AUD)")).toHaveLength(1);
298
+ expect(queryAllByText("This field is required")).toHaveLength(1);
297
299
  });
298
300
  });
299
- describe('helper text', () => {
300
- it('renders correctly', () => {
301
+ describe("helper text", () => {
302
+ it("renders correctly", () => {
301
303
  const { toJSON, queryAllByText } = renderWithTheme(
302
304
  <TextInput
303
305
  label="Amount (AUD)"
@@ -308,14 +310,14 @@ describe('TextInput', () => {
308
310
  );
309
311
 
310
312
  expect(toJSON()).toMatchSnapshot();
311
- expect(queryAllByText('Amount (AUD)')).toHaveLength(1);
312
- expect(queryAllByText('This is helper text')).toHaveLength(1);
313
+ expect(queryAllByText("Amount (AUD)")).toHaveLength(1);
314
+ expect(queryAllByText("This is helper text")).toHaveLength(1);
313
315
  });
314
316
  });
315
317
 
316
- describe('placeholder', () => {
317
- describe('TextInput is idle', () => {
318
- it('renders correctly', () => {
318
+ describe("placeholder", () => {
319
+ describe("TextInput is idle", () => {
320
+ it("renders correctly", () => {
319
321
  const wrapper = renderWithTheme(
320
322
  <TextInput
321
323
  label="Amount (AUD)"
@@ -327,20 +329,20 @@ describe('TextInput', () => {
327
329
  );
328
330
 
329
331
  expect(wrapper.toJSON()).toMatchSnapshot();
330
- expect(wrapper.queryByPlaceholderText('Enter Amount')).toBeFalsy();
332
+ expect(wrapper.queryByPlaceholderText("Enter Amount")).toBeFalsy();
331
333
 
332
- fireEvent(wrapper.getByTestId('text-input'), 'focus');
333
- expect(wrapper.queryByPlaceholderText('Enter Amount')).toBeTruthy();
334
+ fireEvent(wrapper.getByTestId("text-input"), "focus");
335
+ expect(wrapper.queryByPlaceholderText("Enter Amount")).toBeTruthy();
334
336
 
335
- fireEvent(wrapper.getByTestId('text-input'), 'blur');
336
- expect(wrapper.queryByPlaceholderText('Enter Amount')).toBeFalsy();
337
+ fireEvent(wrapper.getByTestId("text-input"), "blur");
338
+ expect(wrapper.queryByPlaceholderText("Enter Amount")).toBeFalsy();
337
339
  });
338
340
  });
339
341
  });
340
342
 
341
- describe('defaultValue', () => {
342
- describe('TextInput is idle', () => {
343
- it('renders correctly', () => {
343
+ describe("defaultValue", () => {
344
+ describe("TextInput is idle", () => {
345
+ it("renders correctly", () => {
344
346
  const wrapper = renderWithTheme(
345
347
  <TextInput
346
348
  label="Amount (AUD)"
@@ -354,13 +356,13 @@ describe('TextInput', () => {
354
356
  );
355
357
 
356
358
  expect(wrapper.toJSON()).toMatchSnapshot();
357
- expect(wrapper.queryByDisplayValue('1000')).toBeTruthy();
358
- expect(wrapper.queryByText('4/255')).toBeTruthy();
359
+ expect(wrapper.queryByDisplayValue("1000")).toBeTruthy();
360
+ expect(wrapper.queryByText("4/255")).toBeTruthy();
359
361
  });
360
362
  });
361
363
 
362
- describe('default Value and Value', () => {
363
- it('renders correctly with 2000', () => {
364
+ describe("default Value and Value", () => {
365
+ it("renders correctly with 2000", () => {
364
366
  const wrapper = renderWithTheme(
365
367
  <TextInput
366
368
  label="Amount (AUD)"
@@ -375,9 +377,9 @@ describe('TextInput', () => {
375
377
  );
376
378
 
377
379
  expect(wrapper.toJSON()).toMatchSnapshot();
378
- expect(wrapper.queryByDisplayValue('2000')).toBeTruthy();
379
- expect(wrapper.queryByDisplayValue('1000')).toBeFalsy();
380
- expect(wrapper.queryByText('4/255')).toBeTruthy();
380
+ expect(wrapper.queryByDisplayValue("2000")).toBeTruthy();
381
+ expect(wrapper.queryByDisplayValue("1000")).toBeFalsy();
382
+ expect(wrapper.queryByText("4/255")).toBeTruthy();
381
383
  });
382
384
  });
383
385
  });
@@ -1,11 +1,11 @@
1
- import React from 'react';
2
- import { StyleSheet } from 'react-native';
1
+ import React from "react";
2
+ import { StyleSheet } from "react-native";
3
3
  import type {
4
4
  TextInputProps as NativeTextInputProps,
5
5
  StyleProp,
6
6
  ViewStyle,
7
7
  TextStyle,
8
- } from 'react-native';
8
+ } from "react-native";
9
9
  import {
10
10
  StyledTextInputContainer,
11
11
  StyledLabel,
@@ -24,11 +24,11 @@ import {
24
24
  StyledErrorAndHelpTextContainer,
25
25
  StyledBorderBackDrop,
26
26
  StyledErrorAndMaxLengthContainer,
27
- } from './StyledTextInput';
28
- import Icon from '../Icon';
29
- import { useTheme } from '../../theme';
30
- import type { Variant } from './StyledTextInput';
31
- import type { IconName } from '../Icon';
27
+ } from "./StyledTextInput";
28
+ import Icon from "../Icon";
29
+ import { useTheme } from "../../theme";
30
+ import type { Variant } from "./StyledTextInput";
31
+ import type { IconName } from "../Icon";
32
32
 
33
33
  export interface TextInputProps extends NativeTextInputProps {
34
34
  /**
@@ -114,21 +114,21 @@ export const getVariant = ({
114
114
  isEmptyValue?: boolean;
115
115
  }): Variant => {
116
116
  if (disabled) {
117
- return 'disabled';
117
+ return "disabled";
118
118
  }
119
119
  if (error) {
120
- return 'error';
120
+ return "error";
121
121
  }
122
122
  if (!editable || loading) {
123
- return 'readonly';
123
+ return "readonly";
124
124
  }
125
125
  if (isFocused) {
126
- return 'focused';
126
+ return "focused";
127
127
  }
128
128
  if (!isEmptyValue) {
129
- return 'filled';
129
+ return "filled";
130
130
  }
131
- return 'default';
131
+ return "default";
132
132
  };
133
133
 
134
134
  const TextInput = ({
@@ -151,9 +151,9 @@ const TextInput = ({
151
151
  renderInputValue,
152
152
  ...nativeProps
153
153
  }: TextInputProps): JSX.Element => {
154
- const displayText = (value !== undefined ? value : defaultValue) ?? '';
154
+ const displayText = (value !== undefined ? value : defaultValue) ?? "";
155
155
  const isEmptyValue = displayText.length === 0;
156
- const actualSuffix = loading ? 'loading' : suffix;
156
+ const actualSuffix = loading ? "loading" : suffix;
157
157
 
158
158
  const [isFocused, setIsFocused] = React.useState(false);
159
159
 
@@ -175,41 +175,40 @@ const TextInput = ({
175
175
  { color: theme.__hd__.textInput.colors.text },
176
176
  textStyle,
177
177
  ]),
178
- testID: 'text-input',
178
+ testID: "text-input",
179
179
  accessibilityState: {
180
- disabled: variant === 'disabled' || variant === 'readonly',
180
+ disabled: variant === "disabled" || variant === "readonly",
181
181
  },
182
182
  // @ts-ignore
183
183
  accessibilityLabelledBy,
184
184
  ...nativeProps,
185
- onFocus: event => {
185
+ onFocus: (event) => {
186
186
  setIsFocused(true);
187
187
  nativeProps.onFocus?.(event);
188
188
  },
189
- onBlur: event => {
189
+ onBlur: (event) => {
190
190
  setIsFocused(false);
191
191
  nativeProps.onBlur?.(event);
192
192
  },
193
193
  editable,
194
194
  maxLength,
195
195
  value,
196
- onChangeText: text => {
196
+ onChangeText: (text) => {
197
197
  nativeProps.onChangeText?.(text);
198
198
  },
199
199
  defaultValue,
200
- placeholder: variant === 'focused' ? nativeProps.placeholder : undefined,
200
+ placeholder: variant === "focused" ? nativeProps.placeholder : undefined,
201
201
  };
202
202
 
203
203
  return (
204
204
  <StyledContainer
205
- style={style}
206
205
  pointerEvents={
207
- variant === 'disabled' || variant === 'readonly' ? 'none' : 'auto'
206
+ variant === "disabled" || variant === "readonly" ? "none" : "auto"
208
207
  }
209
208
  testID={testID}
210
209
  >
211
210
  <StyledTextInputContainer>
212
- <StyledBorderBackDrop themeVariant={variant} />
211
+ <StyledBorderBackDrop themeVariant={variant} style={style} />
213
212
  {(isFocused || (label && !isEmptyValue)) && (
214
213
  <StyledLabelContainer pointerEvents="none">
215
214
  {required && (
@@ -229,9 +228,9 @@ const TextInput = ({
229
228
  )}
230
229
  </StyledLabelContainer>
231
230
  )}
232
- {typeof prefix === 'string' ? (
231
+ {typeof prefix === "string" ? (
233
232
  <Icon
234
- intent={variant === 'disabled' ? 'disabled-text' : 'text'}
233
+ intent={variant === "disabled" ? "disabled-text" : "text"}
235
234
  testID="input-prefix"
236
235
  icon={prefix}
237
236
  size="xsmall"
@@ -265,12 +264,12 @@ const TextInput = ({
265
264
  <StyledTextInput {...nativeInputProps} />
266
265
  )}
267
266
  </StyledTextInputAndLabelContainer>
268
- {typeof actualSuffix === 'string' ? (
267
+ {typeof actualSuffix === "string" ? (
269
268
  <Icon
270
- intent={variant === 'disabled' ? 'disabled-text' : 'text'}
269
+ intent={variant === "disabled" ? "disabled-text" : "text"}
271
270
  testID="input-suffix"
272
271
  icon={actualSuffix}
273
- spin={actualSuffix === 'loading'}
272
+ spin={actualSuffix === "loading"}
274
273
  size="xsmall"
275
274
  />
276
275
  ) : (
@@ -28,7 +28,7 @@ const SingleToastDisplay = ({
28
28
  key={toast.id}
29
29
  style={{ marginBottom: theme.space.small }}
30
30
  onDismiss={() => {
31
- setToastList(state => state.filter(item => item.id !== toast.id));
31
+ setToastList((state) => state.filter((item) => item.id !== toast.id));
32
32
  toast.props.onDismiss?.();
33
33
  }}
34
34
  />
@@ -43,17 +43,17 @@ const ToastContainer = React.forwardRef<
43
43
  const [toastList, setToastList] = useState<ToastItemProps[]>([]);
44
44
 
45
45
  useImperativeHandle(ref, () => ({
46
- show: props => {
46
+ show: (props) => {
47
47
  const item = {
48
48
  id: generateID(),
49
49
  props,
50
50
  };
51
51
 
52
- setToastList(state => [item, ...state]);
52
+ setToastList((state) => [item, ...state]);
53
53
  return item.id;
54
54
  },
55
- hide: id => {
56
- setToastList(state => state.filter(item => item.id !== id));
55
+ hide: (id) => {
56
+ setToastList((state) => state.filter((item) => item.id !== id));
57
57
  },
58
58
  clearAll: () => {
59
59
  setToastList([]);
@@ -75,7 +75,7 @@ const ToastContainer = React.forwardRef<
75
75
  key={id}
76
76
  style={{ marginBottom: theme.space.small }}
77
77
  onDismiss={() => {
78
- setToastList(state => state.filter(item => item.id !== id));
78
+ setToastList((state) => state.filter((item) => item.id !== id));
79
79
  props.onDismiss?.();
80
80
  }}
81
81
  />
@@ -621,20 +621,26 @@ Object {
621
621
  "disabled-unchecked": "#ccced1",
622
622
  "unchecked": "#808f91",
623
623
  },
624
+ "selector": Object {
625
+ "background": "#f6f6f7",
626
+ "textBackground": "#401960",
627
+ },
624
628
  "thumb": "#ffffff",
625
629
  },
626
- "heights": Object {
627
- "medium": 28.799999999999997,
628
- "small": 24,
629
- },
630
630
  "radii": Object {
631
631
  "rounded": 999,
632
+ "selector": Object {
633
+ "default": 999,
634
+ },
632
635
  },
633
636
  "sizes": Object {
634
637
  "heights": Object {
635
638
  "medium": 32,
636
639
  "small": 24,
637
640
  },
641
+ "selector": Object {
642
+ "height": 56,
643
+ },
638
644
  "thumbs": Object {
639
645
  "medium": 24,
640
646
  "small": 16,
@@ -646,16 +652,12 @@ Object {
646
652
  },
647
653
  "spaces": Object {
648
654
  "medium": 4,
655
+ "selector": Object {
656
+ "iconPadding": 16,
657
+ "wrapperPadding": 4,
658
+ },
649
659
  "small": 4,
650
660
  },
651
- "thumbSizes": Object {
652
- "medium": 20.8,
653
- "small": 16,
654
- },
655
- "widths": Object {
656
- "medium": 56,
657
- "small": 48,
658
- },
659
661
  },
660
662
  "tabs": Object {
661
663
  "borderWidths": Object {