@hero-design/rn-work-uikit 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import Select from '..';
3
+ import renderWithTheme from '../../../../testUtils/renderWithTheme';
4
+ import { noop } from '../../../utils/functions';
5
+
6
+ const options = [
7
+ { text: 'Monday', value: 'mon' },
8
+ { text: 'Tuesday', value: 'tue' },
9
+ { text: 'Wednesday', value: 'wed' },
10
+ { text: 'Thursday', value: 'thu' },
11
+ { text: 'Friday', value: 'fri' },
12
+ { text: 'Saturday', value: 'sat' },
13
+ { text: 'Sunday', value: 'sun', disabled: true },
14
+ ];
15
+
16
+ describe('Select', () => {
17
+ it('renders correctly (snapshot)', () => {
18
+ const { toJSON } = renderWithTheme(
19
+ <Select
20
+ value="mon"
21
+ onConfirm={noop}
22
+ options={options}
23
+ label="Select Label"
24
+ />
25
+ );
26
+ expect(toJSON()).toMatchSnapshot();
27
+ });
28
+ });
29
+
30
+ describe('MultiSelect', () => {
31
+ it('renders correctly (snapshot)', () => {
32
+ const { toJSON } = renderWithTheme(
33
+ <Select.Multi
34
+ value={['tue', 'wed']}
35
+ onConfirm={noop}
36
+ options={options}
37
+ label="Select Label"
38
+ footerLabel="Confirm"
39
+ />
40
+ );
41
+ expect(toJSON()).toMatchSnapshot();
42
+ });
43
+ });
@@ -91,7 +91,6 @@ exports[`TextInputGroup should render: xxx 1`] = `
91
91
  {
92
92
  "alignItems": "center",
93
93
  "backgroundColor": "transparent",
94
- "flex": 1,
95
94
  "flexDirection": "row",
96
95
  },
97
96
  ],
@@ -344,7 +343,6 @@ exports[`TextInputGroup should render: xxx 1`] = `
344
343
  {
345
344
  "alignItems": "center",
346
345
  "backgroundColor": "transparent",
347
- "flex": 1,
348
346
  "flexDirection": "row",
349
347
  },
350
348
  ],
@@ -706,7 +704,6 @@ exports[`TextInputGroup should render: xxx 1`] = `
706
704
  {
707
705
  "alignItems": "center",
708
706
  "backgroundColor": "transparent",
709
- "flex": 1,
710
707
  "flexDirection": "row",
711
708
  },
712
709
  ],
@@ -42,7 +42,6 @@ const StyledFloatingLabelContainer = styled(Animated.View)<{
42
42
  themeVariant: Variant;
43
43
  }>(({ themeVariant }) => ({
44
44
  flexDirection: 'row',
45
- flex: 1,
46
45
  alignItems: themeVariant === 'text' ? 'center' : 'flex-start',
47
46
  backgroundColor: 'transparent',
48
47
  }));
@@ -75,7 +75,6 @@ exports[`TextInput when user applies custom styling should respect user-provided
75
75
  {
76
76
  "alignItems": "center",
77
77
  "backgroundColor": "transparent",
78
- "flex": 1,
79
78
  "flexDirection": "row",
80
79
  },
81
80
  ],
@@ -432,7 +431,6 @@ exports[`TextInput when user chooses textarea variant should provide multiline t
432
431
  {
433
432
  "alignItems": "flex-start",
434
433
  "backgroundColor": "transparent",
435
- "flex": 1,
436
434
  "flexDirection": "row",
437
435
  },
438
436
  ],
@@ -712,7 +710,6 @@ exports[`TextInput when user encounters a disabled field should display content
712
710
  {
713
711
  "alignItems": "center",
714
712
  "backgroundColor": "transparent",
715
- "flex": 1,
716
713
  "flexDirection": "row",
717
714
  },
718
715
  ],
@@ -991,7 +988,6 @@ exports[`TextInput when user encounters a read-only field should display content
991
988
  {
992
989
  "alignItems": "center",
993
990
  "backgroundColor": "transparent",
994
- "flex": 1,
995
991
  "flexDirection": "row",
996
992
  },
997
993
  ],
@@ -1354,7 +1350,6 @@ exports[`TextInput when user has entered text should show the input content and
1354
1350
  {
1355
1351
  "alignItems": "center",
1356
1352
  "backgroundColor": "transparent",
1357
- "flex": 1,
1358
1353
  "flexDirection": "row",
1359
1354
  },
1360
1355
  ],
@@ -1717,7 +1712,6 @@ exports[`TextInput when user interacts with placeholder text starting from empty
1717
1712
  {
1718
1713
  "alignItems": "center",
1719
1714
  "backgroundColor": "transparent",
1720
- "flex": 1,
1721
1715
  "flexDirection": "row",
1722
1716
  },
1723
1717
  ],
@@ -2037,7 +2031,6 @@ exports[`TextInput when user needs programmatic control should provide ref metho
2037
2031
  {
2038
2032
  "alignItems": "center",
2039
2033
  "backgroundColor": "transparent",
2040
- "flex": 1,
2041
2034
  "flexDirection": "row",
2042
2035
  },
2043
2036
  ],
@@ -2316,7 +2309,6 @@ exports[`TextInput when user provides default values starting with pre-filled co
2316
2309
  {
2317
2310
  "alignItems": "center",
2318
2311
  "backgroundColor": "transparent",
2319
- "flex": 1,
2320
2312
  "flexDirection": "row",
2321
2313
  },
2322
2314
  ],
@@ -2672,7 +2664,6 @@ exports[`TextInput when user provides default values when both default and contr
2672
2664
  {
2673
2665
  "alignItems": "center",
2674
2666
  "backgroundColor": "transparent",
2675
- "flex": 1,
2676
2667
  "flexDirection": "row",
2677
2668
  },
2678
2669
  ],
@@ -3029,7 +3020,6 @@ exports[`TextInput when user sees a loading state should show loading indicator
3029
3020
  {
3030
3021
  "alignItems": "center",
3031
3022
  "backgroundColor": "transparent",
3032
- "flex": 1,
3033
3023
  "flexDirection": "row",
3034
3024
  },
3035
3025
  ],
@@ -3411,7 +3401,6 @@ exports[`TextInput when user sees a required field should indicate the field is
3411
3401
  {
3412
3402
  "alignItems": "center",
3413
3403
  "backgroundColor": "transparent",
3414
- "flex": 1,
3415
3404
  "flexDirection": "row",
3416
3405
  },
3417
3406
  ],
@@ -3744,7 +3733,6 @@ exports[`TextInput when user sees a textarea with character count should display
3744
3733
  {
3745
3734
  "alignItems": "flex-start",
3746
3735
  "backgroundColor": "transparent",
3747
- "flex": 1,
3748
3736
  "flexDirection": "row",
3749
3737
  },
3750
3738
  ],
@@ -4144,7 +4132,6 @@ exports[`TextInput when user sees a textarea with character count should hide ch
4144
4132
  {
4145
4133
  "alignItems": "flex-start",
4146
4134
  "backgroundColor": "transparent",
4147
- "flex": 1,
4148
4135
  "flexDirection": "row",
4149
4136
  },
4150
4137
  ],
@@ -4511,7 +4498,6 @@ exports[`TextInput when user sees an empty input field should display label and
4511
4498
  {
4512
4499
  "alignItems": "center",
4513
4500
  "backgroundColor": "transparent",
4514
- "flex": 1,
4515
4501
  "flexDirection": "row",
4516
4502
  },
4517
4503
  ],
@@ -4873,7 +4859,6 @@ exports[`TextInput when user sees an error state should display error message to
4873
4859
  {
4874
4860
  "alignItems": "center",
4875
4861
  "backgroundColor": "transparent",
4876
- "flex": 1,
4877
4862
  "flexDirection": "row",
4878
4863
  },
4879
4864
  ],
@@ -5251,7 +5236,6 @@ exports[`TextInput when user sees helper text should display guidance text to as
5251
5236
  {
5252
5237
  "alignItems": "center",
5253
5238
  "backgroundColor": "transparent",
5254
- "flex": 1,
5255
5239
  "flexDirection": "row",
5256
5240
  },
5257
5241
  ],
@@ -5571,7 +5555,6 @@ exports[`TextInput when user sees input with custom prefix and suffix elements s
5571
5555
  {
5572
5556
  "alignItems": "center",
5573
5557
  "backgroundColor": "transparent",
5574
- "flex": 1,
5575
5558
  "flexDirection": "row",
5576
5559
  },
5577
5560
  ],
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { Platform } from 'react-native';
3
+ import TimePicker from '..';
4
+ import renderWithTheme from '../../../../testUtils/renderWithTheme';
5
+
6
+ describe('TimePicker', () => {
7
+ it('renders TimePickerIOS when OS is iOS', () => {
8
+ Platform.OS = 'ios';
9
+ const { getByTestId } = renderWithTheme(
10
+ <TimePicker
11
+ label="Start time"
12
+ value={new Date('December 17, 1995 03:24:00')}
13
+ confirmLabel="Confirm"
14
+ onChange={jest.fn()}
15
+ />
16
+ );
17
+
18
+ expect(getByTestId('timePickerInputIOS')).toBeDefined();
19
+ });
20
+
21
+ it('renders TimePickerAndroid when OS is android', () => {
22
+ Platform.OS = 'android';
23
+ const { getByTestId } = renderWithTheme(
24
+ <TimePicker
25
+ label="Start time"
26
+ value={new Date('December 17, 1995 03:24:00')}
27
+ confirmLabel="Confirm"
28
+ onChange={jest.fn()}
29
+ />
30
+ );
31
+
32
+ expect(getByTestId('timePickerInputAndroid')).toBeDefined();
33
+ });
34
+ });
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import {
3
+ TimePicker as InternalTimePicker,
4
+ TimePickerProps,
5
+ } from '@hero-design/rn';
6
+ import TextInput from '../TextInput';
7
+
8
+ const TimePicker = (props: TimePickerProps) => {
9
+ return <InternalTimePicker {...props} TextInputComponent={TextInput} />;
10
+ };
11
+
12
+ export default TimePicker;
package/src/index.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  // Re-export everything from @hero-design/rn except theme exports we want to override
2
2
  import TextInput from './components/TextInput';
3
3
  import Select from './components/Select';
4
+ import DatePicker from './components/DatePicker';
5
+ import TimePicker from './components/TimePicker';
4
6
 
5
7
  export * from '@hero-design/rn';
6
8
 
@@ -15,4 +17,4 @@ export {
15
17
  } from './theme';
16
18
 
17
19
  export { default as theme } from './theme';
18
- export { TextInput, Select };
20
+ export { TextInput, Select, DatePicker, TimePicker };
@@ -0,0 +1,2 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
2
+ export const noop = (): void => {};