cpk-ui 0.5.4 → 0.7.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 (136) hide show
  1. package/README.md +80 -147
  2. package/components/modals/AlertDialog/AlertDialog.d.ts.map +1 -1
  3. package/components/modals/AlertDialog/AlertDialog.js +14 -7
  4. package/components/modals/Snackbar/Snackbar.d.ts.map +1 -1
  5. package/components/modals/Snackbar/Snackbar.js +20 -17
  6. package/components/uis/Accordion/AccordionItem.d.ts.map +1 -1
  7. package/components/uis/Accordion/AccordionItem.js +41 -17
  8. package/components/uis/Button/Button.d.ts +2 -1
  9. package/components/uis/Button/Button.d.ts.map +1 -1
  10. package/components/uis/Button/Button.js +11 -11
  11. package/components/uis/Card/Card.d.ts +2 -1
  12. package/components/uis/Card/Card.d.ts.map +1 -1
  13. package/components/uis/Card/Card.js +12 -3
  14. package/components/uis/Checkbox/Checkbox.d.ts +2 -1
  15. package/components/uis/Checkbox/Checkbox.d.ts.map +1 -1
  16. package/components/uis/Checkbox/Checkbox.js +2 -2
  17. package/components/uis/CustomPressable/CustomPressable.d.ts.map +1 -1
  18. package/components/uis/CustomPressable/CustomPressable.js +6 -6
  19. package/components/uis/EditText/EditText.d.ts +1 -0
  20. package/components/uis/EditText/EditText.d.ts.map +1 -1
  21. package/components/uis/EditText/EditText.js +18 -13
  22. package/components/uis/Fab/Fab.d.ts +2 -2
  23. package/components/uis/Fab/Fab.d.ts.map +1 -1
  24. package/components/uis/Fab/Fab.js +22 -4
  25. package/components/uis/Icon/Icon.d.ts.map +1 -1
  26. package/components/uis/Icon/Icon.js +6 -3
  27. package/components/uis/IconButton/IconButton.d.ts +2 -1
  28. package/components/uis/IconButton/IconButton.d.ts.map +1 -1
  29. package/components/uis/IconButton/IconButton.js +44 -42
  30. package/components/uis/LoadingIndicator/LoadingIndicator.d.ts +2 -1
  31. package/components/uis/LoadingIndicator/LoadingIndicator.d.ts.map +1 -1
  32. package/components/uis/LoadingIndicator/LoadingIndicator.js +4 -4
  33. package/components/uis/RadioGroup/RadioButton.d.ts +2 -1
  34. package/components/uis/RadioGroup/RadioButton.d.ts.map +1 -1
  35. package/components/uis/RadioGroup/RadioButton.js +2 -2
  36. package/components/uis/RadioGroup/RadioGroup.d.ts.map +1 -1
  37. package/components/uis/RadioGroup/RadioGroup.js +16 -3
  38. package/components/uis/Rating/Rating.d.ts.map +1 -1
  39. package/components/uis/Rating/Rating.js +23 -19
  40. package/components/uis/SegmentedControl/SegmentedControl.d.ts.map +1 -1
  41. package/components/uis/SegmentedControl/SegmentedControl.js +1 -1
  42. package/components/uis/StatusbarBrightness/StatusBarBrightness.d.ts +2 -2
  43. package/components/uis/StatusbarBrightness/StatusBarBrightness.d.ts.map +1 -1
  44. package/components/uis/StatusbarBrightness/StatusBarBrightness.js +1 -1
  45. package/components/uis/SwitchToggle/SwitchToggle.d.ts +2 -1
  46. package/components/uis/SwitchToggle/SwitchToggle.d.ts.map +1 -1
  47. package/components/uis/SwitchToggle/SwitchToggle.js +2 -2
  48. package/hooks/useHoverState.d.ts +8 -0
  49. package/hooks/useHoverState.d.ts.map +1 -0
  50. package/hooks/useHoverState.js +16 -0
  51. package/package.json +18 -6
  52. package/providers/ThemeProvider.d.ts.map +1 -1
  53. package/providers/ThemeProvider.js +0 -1
  54. package/providers/index.d.ts.map +1 -1
  55. package/providers/index.js +3 -2
  56. package/components/uis/Icon/selection.json +0 -1
  57. package/src/components/common/ErrorBoundary/ErrorBoundary.tsx +0 -75
  58. package/src/components/modals/AlertDialog/AlertDialog.stories.tsx +0 -216
  59. package/src/components/modals/AlertDialog/AlertDialog.test.tsx +0 -251
  60. package/src/components/modals/AlertDialog/AlertDialog.tsx +0 -356
  61. package/src/components/modals/Snackbar/Snackbar.stories.tsx +0 -182
  62. package/src/components/modals/Snackbar/Snackbar.test.tsx +0 -319
  63. package/src/components/modals/Snackbar/Snackbar.tsx +0 -260
  64. package/src/components/modals/Snackbar/const.ts +0 -4
  65. package/src/components/uis/Accordion/Accordion.stories.tsx +0 -167
  66. package/src/components/uis/Accordion/Accordion.test.tsx +0 -272
  67. package/src/components/uis/Accordion/Accordion.tsx +0 -109
  68. package/src/components/uis/Accordion/AccordionItem.tsx +0 -306
  69. package/src/components/uis/Button/Button.stories.tsx +0 -218
  70. package/src/components/uis/Button/Button.test.tsx +0 -620
  71. package/src/components/uis/Button/Button.tsx +0 -436
  72. package/src/components/uis/Card/Card.test.tsx +0 -146
  73. package/src/components/uis/Card/Card.tsx +0 -102
  74. package/src/components/uis/Checkbox/Checkbox.stories.tsx +0 -216
  75. package/src/components/uis/Checkbox/Checkbox.test.tsx +0 -173
  76. package/src/components/uis/Checkbox/Checkbox.tsx +0 -220
  77. package/src/components/uis/CustomPressable/CustomPressable.tsx +0 -48
  78. package/src/components/uis/EditText/EditText.stories.tsx +0 -124
  79. package/src/components/uis/EditText/EditText.test.tsx +0 -477
  80. package/src/components/uis/EditText/EditText.tsx +0 -590
  81. package/src/components/uis/Fab/Fab.stories.tsx +0 -133
  82. package/src/components/uis/Fab/Fab.test.tsx +0 -110
  83. package/src/components/uis/Fab/Fab.tsx +0 -168
  84. package/src/components/uis/Hr/Hr.test.tsx +0 -26
  85. package/src/components/uis/Hr/Hr.tsx +0 -19
  86. package/src/components/uis/Icon/Icon.stories.tsx +0 -98
  87. package/src/components/uis/Icon/Icon.test.tsx +0 -49
  88. package/src/components/uis/Icon/Icon.tsx +0 -3819
  89. package/src/components/uis/IconButton/IconButton.test.tsx +0 -165
  90. package/src/components/uis/IconButton/IconButton.tsx +0 -275
  91. package/src/components/uis/LoadingIndicator/LoadingIndicator.tsx +0 -126
  92. package/src/components/uis/LoadingIndicator/LodingIndicator.stories.tsx +0 -81
  93. package/src/components/uis/PinchZoom/PinchZoom.stories.tsx +0 -266
  94. package/src/components/uis/PinchZoom/PinchZoom.test.tsx +0 -113
  95. package/src/components/uis/PinchZoom/PinchZoom.tsx +0 -424
  96. package/src/components/uis/RadioGroup/RadioButton.tsx +0 -188
  97. package/src/components/uis/RadioGroup/RadioGroup.stories.tsx +0 -188
  98. package/src/components/uis/RadioGroup/RadioGroup.test.tsx +0 -287
  99. package/src/components/uis/RadioGroup/RadioGroup.tsx +0 -109
  100. package/src/components/uis/Rating/Rating.test.tsx +0 -98
  101. package/src/components/uis/Rating/Rating.tsx +0 -200
  102. package/src/components/uis/SegmentedControl/SegmentedControl.stories.tsx +0 -546
  103. package/src/components/uis/SegmentedControl/SegmentedControl.test.tsx +0 -274
  104. package/src/components/uis/SegmentedControl/SegmentedControl.tsx +0 -229
  105. package/src/components/uis/StatusbarBrightness/StatusBarBrightness.test.tsx +0 -41
  106. package/src/components/uis/StatusbarBrightness/StatusBarBrightness.tsx +0 -26
  107. package/src/components/uis/Styled/StyledComponents.tsx +0 -217
  108. package/src/components/uis/SwitchToggle/SwitchToggle.stories.tsx +0 -75
  109. package/src/components/uis/SwitchToggle/SwitchToggle.test.tsx +0 -105
  110. package/src/components/uis/SwitchToggle/SwitchToggle.tsx +0 -305
  111. package/src/components/uis/Typography/Typography.stories.tsx +0 -149
  112. package/src/components/uis/Typography/Typography.test.tsx +0 -58
  113. package/src/components/uis/Typography/Typography.tsx +0 -386
  114. package/src/hooks/index.ts +0 -2
  115. package/src/hooks/useAnimations.ts +0 -71
  116. package/src/hooks/useDebouncedColorScheme.tsx +0 -30
  117. package/src/hooks/useOptimizedStyles.ts +0 -22
  118. package/src/hooks/usePerformance.ts +0 -93
  119. package/src/index.tsx +0 -38
  120. package/src/providers/ThemeProvider.tsx +0 -177
  121. package/src/providers/index.tsx +0 -130
  122. package/src/test/testUtils.tsx +0 -101
  123. package/src/types/common.ts +0 -77
  124. package/src/types/index.ts +0 -1
  125. package/src/types/kstyled.d.ts +0 -6
  126. package/src/utils/accessibility.ts +0 -110
  127. package/src/utils/colors.ts +0 -151
  128. package/src/utils/createCtx.tsx +0 -26
  129. package/src/utils/guards.ts +0 -93
  130. package/src/utils/index.ts +0 -2
  131. package/src/utils/performanceTest.ts +0 -174
  132. package/src/utils/platform.ts +0 -69
  133. package/src/utils/theme.ts +0 -38
  134. package/test/testUtils.d.ts +0 -113
  135. package/test/testUtils.d.ts.map +0 -1
  136. package/test/testUtils.js +0 -65
@@ -1,274 +0,0 @@
1
- import * as React from 'react';
2
- import {type ReactElement} from 'react';
3
- import {View, Text} from 'react-native';
4
- import type {RenderAPI} from '@testing-library/react-native';
5
- import {fireEvent, render, waitFor} from '@testing-library/react-native';
6
-
7
- import {createComponent, createTestProps} from '../../../../test/testUtils';
8
- import {type SegmentedControlColorType, SegmentedControl} from './SegmentedControl';
9
- import {Typography} from '../Typography/Typography';
10
-
11
- let props: any;
12
- let component: ReactElement;
13
- let testingLib: RenderAPI;
14
-
15
- const values = [
16
- {value: 'day', text: 'Day'},
17
- {value: 'week', text: 'Week'},
18
- {value: 'month', text: 'Month'},
19
- ];
20
-
21
- describe('[SegmentedControl] render', () => {
22
- it('should render without crashing', async () => {
23
- props = createTestProps({
24
- selectedValue: 'day',
25
- onValueChange: (value: string | number) => (props.selectedValue = value),
26
- });
27
-
28
- component = createComponent(
29
- <View>
30
- <SegmentedControl
31
- values={values}
32
- onValueChange={props.onValueChange}
33
- selectedValue={props.selectedValue}
34
- />
35
- </View>,
36
- );
37
-
38
- testingLib = render(component);
39
-
40
- const baseElement = await waitFor(() => testingLib.toJSON());
41
- expect(baseElement).toBeTruthy();
42
- });
43
-
44
- it('should trigger `onValueChange` and change `selectedValue` props', () => {
45
- props = createTestProps({
46
- selectedValue: 'day',
47
- onValueChange: (value: string | number) => (props.selectedValue = value),
48
- });
49
-
50
- component = createComponent(
51
- <View>
52
- <SegmentedControl
53
- values={values}
54
- onValueChange={props.onValueChange}
55
- selectedValue={props.selectedValue}
56
- />
57
- </View>,
58
- );
59
-
60
- testingLib = render(component);
61
-
62
- const secondOption = testingLib.getByTestId('segment-1');
63
- expect(props.selectedValue).toEqual('day');
64
-
65
- fireEvent.press(secondOption);
66
- expect(props.selectedValue).toEqual('week');
67
- });
68
-
69
- it('should not trigger `onValueChange` when disabled', () => {
70
- props = createTestProps({
71
- selectedValue: 'day',
72
- onValueChange: jest.fn(),
73
- });
74
-
75
- component = createComponent(
76
- <View>
77
- <SegmentedControl
78
- values={values}
79
- disabled={true}
80
- onValueChange={props.onValueChange}
81
- selectedValue={props.selectedValue}
82
- />
83
- </View>,
84
- );
85
-
86
- testingLib = render(component);
87
-
88
- const secondOption = testingLib.getByTestId('segment-1');
89
- fireEvent.press(secondOption);
90
-
91
- expect(props.onValueChange).not.toHaveBeenCalled();
92
- });
93
- });
94
-
95
- describe('[SegmentedControl] colors', () => {
96
- const colors = [
97
- 'primary',
98
- 'secondary',
99
- 'success',
100
- 'info',
101
- 'warning',
102
- 'danger',
103
- 'light',
104
- ];
105
-
106
- it('should render all colors', async () => {
107
- component = createComponent(
108
- <View>
109
- {colors.map((color) => {
110
- return (
111
- <View key={color} style={{marginTop: 24}}>
112
- <SegmentedControl
113
- color={color as SegmentedControlColorType}
114
- values={values}
115
- selectedValue="day"
116
- />
117
- </View>
118
- );
119
- })}
120
- </View>,
121
- );
122
-
123
- testingLib = render(component);
124
-
125
- const baseElement = await waitFor(() => testingLib.toJSON());
126
- expect(baseElement).toBeTruthy();
127
- });
128
- });
129
-
130
- describe('[SegmentedControl] sizes', () => {
131
- it('should render with small size', async () => {
132
- component = createComponent(
133
- <SegmentedControl
134
- values={values}
135
- selectedValue="day"
136
- size="small"
137
- />,
138
- );
139
-
140
- testingLib = render(component);
141
-
142
- const baseElement = await waitFor(() => testingLib.toJSON());
143
- expect(baseElement).toBeTruthy();
144
- });
145
-
146
- it('should render with medium size', async () => {
147
- component = createComponent(
148
- <SegmentedControl
149
- values={values}
150
- selectedValue="day"
151
- size="medium"
152
- />,
153
- );
154
-
155
- testingLib = render(component);
156
-
157
- const baseElement = await waitFor(() => testingLib.toJSON());
158
- expect(baseElement).toBeTruthy();
159
- });
160
-
161
- it('should render with large size', async () => {
162
- component = createComponent(
163
- <SegmentedControl
164
- values={values}
165
- selectedValue="day"
166
- size="large"
167
- />,
168
- );
169
-
170
- testingLib = render(component);
171
-
172
- const baseElement = await waitFor(() => testingLib.toJSON());
173
- expect(baseElement).toBeTruthy();
174
- });
175
-
176
- it('should render with custom numeric size', async () => {
177
- component = createComponent(
178
- <SegmentedControl
179
- values={values}
180
- selectedValue="day"
181
- size={28}
182
- />,
183
- );
184
-
185
- testingLib = render(component);
186
-
187
- const baseElement = await waitFor(() => testingLib.toJSON());
188
- expect(baseElement).toBeTruthy();
189
- });
190
- });
191
-
192
- describe('[SegmentedControl] with different data lengths', () => {
193
- it('should render with 2 segments', async () => {
194
- const twoSegments = [
195
- {value: 'first', text: 'First'},
196
- {value: 'second', text: 'Second'},
197
- ];
198
- component = createComponent(
199
- <SegmentedControl
200
- values={twoSegments}
201
- selectedValue="first"
202
- />,
203
- );
204
-
205
- testingLib = render(component);
206
-
207
- const baseElement = await waitFor(() => testingLib.toJSON());
208
- expect(baseElement).toBeTruthy();
209
- expect(testingLib.getByTestId('segment-0')).toBeTruthy();
210
- expect(testingLib.getByTestId('segment-1')).toBeTruthy();
211
- });
212
-
213
- it('should render with 4 segments', async () => {
214
- const fourSegments = [
215
- {value: 1, text: 'One'},
216
- {value: 2, text: 'Two'},
217
- {value: 3, text: 'Three'},
218
- {value: 4, text: 'Four'},
219
- ];
220
- component = createComponent(
221
- <SegmentedControl
222
- values={fourSegments}
223
- selectedValue={1}
224
- />,
225
- );
226
-
227
- testingLib = render(component);
228
-
229
- const baseElement = await waitFor(() => testingLib.toJSON());
230
- expect(baseElement).toBeTruthy();
231
- expect(testingLib.getByTestId('segment-0')).toBeTruthy();
232
- expect(testingLib.getByTestId('segment-1')).toBeTruthy();
233
- expect(testingLib.getByTestId('segment-2')).toBeTruthy();
234
- expect(testingLib.getByTestId('segment-3')).toBeTruthy();
235
- });
236
- });
237
-
238
- describe('[SegmentedControl] custom borderRadius', () => {
239
- it('should render with custom border radius', async () => {
240
- component = createComponent(
241
- <SegmentedControl
242
- borderRadius={16}
243
- values={values}
244
- selectedValue="day"
245
- />,
246
- );
247
-
248
- testingLib = render(component);
249
-
250
- const baseElement = await waitFor(() => testingLib.toJSON());
251
- expect(baseElement).toBeTruthy();
252
- });
253
- });
254
-
255
- describe('[SegmentedControl] with ReactElement text', () => {
256
- it('should render with React elements as text', async () => {
257
- const valuesWithElements = [
258
- {value: 'grid', text: <View><Text>Grid</Text></View>},
259
- {value: 'list', text: <View><Text>List</Text></View>},
260
- ];
261
-
262
- component = createComponent(
263
- <SegmentedControl
264
- values={valuesWithElements}
265
- selectedValue="grid"
266
- />,
267
- );
268
-
269
- testingLib = render(component);
270
-
271
- const baseElement = await waitFor(() => testingLib.toJSON());
272
- expect(baseElement).toBeTruthy();
273
- });
274
- });
@@ -1,229 +0,0 @@
1
- import React, {useCallback, useMemo, type ReactElement} from 'react';
2
- import type {StyleProp, TextStyle, ViewStyle} from 'react-native';
3
- import {TouchableOpacity} from 'react-native';
4
- import {styled, css} from 'kstyled';
5
-
6
- import {useTheme} from '../../../providers/ThemeProvider';
7
- import {Typography} from '../Typography/Typography';
8
- import type {CpkTheme} from '../../../utils/theme';
9
-
10
- export type SegmentedControlSizeType = 'small' | 'medium' | 'large' | number;
11
- export type SegmentedControlColorType =
12
- | 'primary'
13
- | 'secondary'
14
- | 'success'
15
- | 'danger'
16
- | 'warning'
17
- | 'info'
18
- | 'light';
19
-
20
- export type SegmentedControlItem = {
21
- value: string | number;
22
- text: string | ReactElement;
23
- };
24
-
25
- type Styles = {
26
- container?: StyleProp<ViewStyle>;
27
- segment?: StyleProp<ViewStyle>;
28
- selectedSegment?: StyleProp<ViewStyle>;
29
- text?: StyleProp<TextStyle>;
30
- selectedText?: StyleProp<TextStyle>;
31
- };
32
-
33
- export type SegmentedControlProps = {
34
- testID?: string;
35
- values: SegmentedControlItem[];
36
- selectedValue: string | number;
37
- onValueChange?: (value: string | number) => void;
38
- color?: SegmentedControlColorType;
39
- size?: SegmentedControlSizeType;
40
- disabled?: boolean;
41
- style?: StyleProp<ViewStyle>;
42
- styles?: Styles;
43
- borderRadius?: number;
44
- };
45
-
46
- const Container = styled.View`
47
- overflow: hidden;
48
- `;
49
-
50
- // Calculate styles based on theme and props
51
- const calculateStyles = ({
52
- theme,
53
- color,
54
- size,
55
- borderRadius,
56
- styles,
57
- }: {
58
- theme: CpkTheme;
59
- color: SegmentedControlColorType;
60
- size: SegmentedControlSizeType;
61
- borderRadius: number;
62
- styles?: Styles;
63
- }) => {
64
- const padding =
65
- typeof size === 'number'
66
- ? `${size * 0.4}px ${size * 0.8}px`
67
- : size === 'large'
68
- ? '12px 16px'
69
- : size === 'medium'
70
- ? '8px 12px'
71
- : size === 'small'
72
- ? '6px 8px'
73
- : '8px 12px';
74
-
75
- return {
76
- wrapper: [
77
- css`
78
- flex-direction: row;
79
- background-color: ${theme.bg.paper};
80
- border-top-color: ${theme.bg.disabled};
81
- border-bottom-color: ${theme.bg.disabled};
82
- border-left-color: ${theme.bg.disabled};
83
- border-right-color: ${theme.bg.disabled};
84
- border-width: 1px;
85
- border-radius: ${borderRadius}px;
86
- `,
87
- ],
88
- container: styles?.container,
89
- segment: [
90
- css`
91
- flex: 1;
92
- align-items: center;
93
- justify-content: center;
94
- padding: ${padding};
95
- background-color: transparent;
96
- `,
97
- styles?.segment,
98
- ],
99
- selectedSegment: [
100
- css`
101
- background-color: ${theme.button[color].bg};
102
- `,
103
- styles?.selectedSegment,
104
- ],
105
- text: [
106
- css`
107
- color: ${theme.text.basic};
108
- `,
109
- styles?.text,
110
- ],
111
- selectedText: [
112
- css`
113
- color: ${theme.button[color].text};
114
- font-weight: 600;
115
- `,
116
- styles?.selectedText,
117
- ],
118
- };
119
- };
120
-
121
- function SegmentedControlContainer({
122
- testID,
123
- values,
124
- selectedValue,
125
- onValueChange,
126
- color = 'primary',
127
- size = 'medium',
128
- disabled = false,
129
- style,
130
- styles,
131
- borderRadius = 8,
132
- }: SegmentedControlProps): ReactElement {
133
- const {theme} = useTheme();
134
-
135
- // Memoize styles calculation
136
- const compositeStyles = useMemo(
137
- () =>
138
- calculateStyles({
139
- theme,
140
- color,
141
- size,
142
- borderRadius,
143
- styles,
144
- }),
145
- [theme, color, size, borderRadius, styles],
146
- );
147
-
148
- // Memoize segment press handler
149
- const handlePress = useCallback(
150
- (value: string | number) => {
151
- if (!disabled) {
152
- onValueChange?.(value);
153
- }
154
- },
155
- [disabled, onValueChange],
156
- );
157
-
158
- // Memoize segments rendering
159
- const segments = useMemo(
160
- () => {
161
- const cornerRadius = Math.max(borderRadius - 1, 0);
162
-
163
- return values.map((item: SegmentedControlItem, index: number) => {
164
- const isSelected = selectedValue === item.value;
165
- const isFirst = index === 0;
166
- const isLast = index === values.length - 1;
167
-
168
- return (
169
- <TouchableOpacity
170
- key={`segment-${index}`}
171
- testID={`segment-${index}`}
172
- activeOpacity={0.7}
173
- disabled={disabled}
174
- onPress={() => handlePress(item.value)}
175
- style={[
176
- compositeStyles.segment,
177
- isSelected && compositeStyles.selectedSegment,
178
- {
179
- borderTopLeftRadius: isFirst ? cornerRadius : 0,
180
- borderBottomLeftRadius: isFirst ? cornerRadius : 0,
181
- borderTopRightRadius: isLast ? cornerRadius : 0,
182
- borderBottomRightRadius: isLast ? cornerRadius : 0,
183
- borderRightWidth: isLast ? 0 : 1,
184
- borderRightColor: theme.bg.disabled,
185
- },
186
- ]}
187
- >
188
- {typeof item.text === 'string' ? (
189
- <Typography.Body2
190
- style={[
191
- compositeStyles.text,
192
- isSelected && compositeStyles.selectedText,
193
- ]}
194
- >
195
- {item.text}
196
- </Typography.Body2>
197
- ) : (
198
- item.text
199
- )}
200
- </TouchableOpacity>
201
- );
202
- });
203
- },
204
- [
205
- values,
206
- selectedValue,
207
- disabled,
208
- handlePress,
209
- compositeStyles,
210
- borderRadius,
211
- theme.bg.disabled,
212
- ],
213
- );
214
-
215
- return (
216
- <Container style={style} testID={testID}>
217
- <Container style={[compositeStyles.wrapper, compositeStyles.container]}>
218
- {segments}
219
- </Container>
220
- </Container>
221
- );
222
- }
223
-
224
- // Export memoized component for better performance
225
- export const SegmentedControl = React.memo(
226
- SegmentedControlContainer,
227
- );
228
-
229
- export default SegmentedControl;
@@ -1,41 +0,0 @@
1
- import React, {type ReactElement} from 'react';
2
- import {View} from 'react-native';
3
- import type {RenderAPI} from '@testing-library/react-native';
4
- import {render} from '@testing-library/react-native';
5
-
6
- import {createComponent} from '../../../../test/testUtils';
7
- import StatusBarBrightness from './StatusBarBrightness';
8
- import {ThemeProvider} from '../../../providers/ThemeProvider';
9
-
10
- let testingLib: RenderAPI;
11
-
12
- const Component = (): ReactElement =>
13
- createComponent(
14
- <View>
15
- <StatusBarBrightness />
16
- </View>,
17
- );
18
-
19
- describe('[StatusBarBrightness]', () => {
20
- it('should render without crashing', () => {
21
- testingLib = render(Component());
22
-
23
- const json = testingLib.toJSON();
24
-
25
- expect(json).toBeTruthy();
26
- });
27
-
28
- it('should render [dark] mode', () => {
29
- testingLib = render(
30
- <ThemeProvider initialThemeType="dark">
31
- <View>
32
- <StatusBarBrightness />
33
- </View>
34
- </ThemeProvider>,
35
- );
36
-
37
- const json = testingLib.toJSON();
38
-
39
- expect(json).toBeTruthy();
40
- });
41
- });
@@ -1,26 +0,0 @@
1
- import React, {useMemo, type ReactElement} from 'react';
2
- import type {StatusBarStyle} from 'react-native';
3
- import {StatusBar} from 'react-native';
4
- import {useTheme} from '../../../providers/ThemeProvider';
5
-
6
- type StatusBarBrightnessProps = {
7
- type?: StatusBarStyle;
8
- };
9
-
10
- function StatusBarBrightness({type}: StatusBarBrightnessProps): ReactElement {
11
- const {themeType} = useTheme();
12
-
13
- // Memoize status bar color calculation
14
- const statusColor: StatusBarStyle = useMemo(() => {
15
- return type
16
- ? type
17
- : themeType === 'light'
18
- ? 'dark-content'
19
- : 'light-content';
20
- }, [type, themeType]);
21
-
22
- return <StatusBar barStyle={statusColor} />;
23
- }
24
-
25
- // Export memoized component for better performance
26
- export default React.memo(StatusBarBrightness) as typeof StatusBarBrightness;