@utilitywarehouse/hearth-react-native 0.27.1 → 0.27.2-testid-fix-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.
- package/.storybook/vitest.setup.ts +35 -3
- package/.turbo/turbo-build.log +5 -4
- package/CHANGELOG.md +15 -0
- package/build/components/Button/ButtonRoot.js +8 -0
- package/build/components/Carousel/Carousel.js +6 -1
- package/build/components/DatePicker/TimePicker.d.ts +3 -0
- package/build/components/DatePicker/TimePicker.js +84 -0
- package/build/components/DatePicker/time-picker/animated-math.d.ts +4 -0
- package/build/components/DatePicker/time-picker/animated-math.js +19 -0
- package/build/components/DatePicker/time-picker/period-native.d.ts +6 -0
- package/build/components/DatePicker/time-picker/period-native.js +17 -0
- package/build/components/DatePicker/time-picker/period-picker.d.ts +6 -0
- package/build/components/DatePicker/time-picker/period-picker.js +10 -0
- package/build/components/DatePicker/time-picker/period-web.d.ts +6 -0
- package/build/components/DatePicker/time-picker/period-web.js +21 -0
- package/build/components/DatePicker/time-picker/wheel-native.d.ts +8 -0
- package/build/components/DatePicker/time-picker/wheel-native.js +19 -0
- package/build/components/DatePicker/time-picker/wheel-picker/index.d.ts +2 -0
- package/build/components/DatePicker/time-picker/wheel-picker/index.js +2 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.d.ts +16 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.js +97 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.d.ts +21 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.js +88 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.d.ts +23 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.js +21 -0
- package/build/components/DatePicker/time-picker/wheel-web.d.ts +8 -0
- package/build/components/DatePicker/time-picker/wheel-web.js +146 -0
- package/build/components/DatePicker/time-picker/wheel.d.ts +8 -0
- package/build/components/DatePicker/time-picker/wheel.js +10 -0
- package/build/components/List/List.js +2 -2
- package/build/components/Modal/Modal.js +16 -11
- package/build/components/SegmentedControl/SegmentedControl.js +4 -1
- package/build/components/SegmentedControl/SegmentedControlOption.js +4 -1
- package/build/components/TimePicker/TimePickerWheel.js +9 -1
- package/build/components/Toast/Toast.context.js +1 -1
- package/build/components/VerificationInput/VerificationInput.js +11 -22
- package/build/components/VerificationInput/VerificationInput.utils.d.ts +8 -0
- package/build/components/VerificationInput/VerificationInput.utils.js +17 -0
- package/build/components/VerificationInput/VerificationInput.utils.test.d.ts +1 -0
- package/build/components/VerificationInput/VerificationInput.utils.test.js +36 -0
- package/docs/changelog.mdx +113 -0
- package/package.json +5 -4
- package/src/components/Button/Button.stories.tsx +43 -7
- package/src/components/Button/ButtonRoot.tsx +8 -0
- package/src/components/Carousel/Carousel.tsx +6 -2
- package/src/components/IconContainer/IconContainer.stories.tsx +35 -30
- package/src/components/List/List.tsx +5 -4
- package/src/components/Modal/Modal.tsx +31 -16
- package/src/components/SegmentedControl/SegmentedControl.tsx +4 -1
- package/src/components/SegmentedControl/SegmentedControlOption.tsx +5 -4
- package/src/components/TimePicker/TimePickerWheel.tsx +11 -4
- package/src/components/Toast/Toast.context.tsx +1 -1
- package/src/components/VerificationInput/VerificationInput.stories.tsx +33 -0
- package/src/components/VerificationInput/VerificationInput.tsx +18 -29
- package/src/components/VerificationInput/VerificationInput.utils.test.ts +48 -0
- package/src/components/VerificationInput/VerificationInput.utils.ts +32 -0
- package/tsconfig.eslint.json +2 -1
- package/vitest.config.js +11 -13
- package/vitest.unit.config.ts +9 -0
- package/.turbo/turbo-lint.log +0 -72
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { findDiffIndex, getNextIndexFromValueChange } from './VerificationInput.utils';
|
|
3
|
+
|
|
4
|
+
describe('findDiffIndex', () => {
|
|
5
|
+
it('returns first differing index', () => {
|
|
6
|
+
expect(findDiffIndex('12', '19')).toBe(1);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('returns previous length when next appends', () => {
|
|
10
|
+
expect(findDiffIndex('12', '123')).toBe(2);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('returns next length when next shortens with same prefix', () => {
|
|
14
|
+
expect(findDiffIndex('123', '12')).toBe(2);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('getNextIndexFromValueChange', () => {
|
|
19
|
+
it('moves to the slot after the one that changed when inserting in an empty later slot', () => {
|
|
20
|
+
expect(
|
|
21
|
+
getNextIndexFromValueChange({
|
|
22
|
+
prevValue: '12',
|
|
23
|
+
nextValue: '123',
|
|
24
|
+
length: 6,
|
|
25
|
+
})
|
|
26
|
+
).toBe(3);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('caps at length when value becomes full', () => {
|
|
30
|
+
expect(
|
|
31
|
+
getNextIndexFromValueChange({
|
|
32
|
+
prevValue: '12345',
|
|
33
|
+
nextValue: '123456',
|
|
34
|
+
length: 6,
|
|
35
|
+
})
|
|
36
|
+
).toBe(6);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('stays at edited index for deletions', () => {
|
|
40
|
+
expect(
|
|
41
|
+
getNextIndexFromValueChange({
|
|
42
|
+
prevValue: '123',
|
|
43
|
+
nextValue: '12',
|
|
44
|
+
length: 6,
|
|
45
|
+
})
|
|
46
|
+
).toBe(2);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
interface GetNextIndexFromValueChangeOptions {
|
|
2
|
+
prevValue: string;
|
|
3
|
+
nextValue: string;
|
|
4
|
+
length: number;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const findDiffIndex = (prevValue: string, nextValue: string): number => {
|
|
8
|
+
const minLength = Math.min(prevValue.length, nextValue.length);
|
|
9
|
+
|
|
10
|
+
for (let i = 0; i < minLength; i += 1) {
|
|
11
|
+
if (prevValue[i] !== nextValue[i]) {
|
|
12
|
+
return i;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return minLength;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const getNextIndexFromValueChange = ({
|
|
20
|
+
prevValue,
|
|
21
|
+
nextValue,
|
|
22
|
+
length,
|
|
23
|
+
}: GetNextIndexFromValueChangeOptions): number => {
|
|
24
|
+
const diff = nextValue.length - prevValue.length;
|
|
25
|
+
const editedIndex = findDiffIndex(prevValue, nextValue);
|
|
26
|
+
|
|
27
|
+
if (diff >= 0) {
|
|
28
|
+
return Math.min(editedIndex + 1, length);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return Math.max(editedIndex, 0);
|
|
32
|
+
};
|
package/tsconfig.eslint.json
CHANGED
package/vitest.config.js
CHANGED
|
@@ -1,35 +1,33 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import { fileURLToPath } from
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
3
|
|
|
4
|
-
import { defineConfig } from
|
|
4
|
+
import { defineConfig } from 'vitest/config';
|
|
5
5
|
|
|
6
|
-
import { storybookTest } from
|
|
6
|
+
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
|
|
7
7
|
|
|
8
8
|
const dirname =
|
|
9
|
-
typeof __dirname !==
|
|
10
|
-
? __dirname
|
|
11
|
-
: path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url));
|
|
12
10
|
|
|
13
11
|
// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon
|
|
14
12
|
export default defineConfig({
|
|
15
13
|
test: {
|
|
16
|
-
|
|
14
|
+
projects: [
|
|
17
15
|
{
|
|
18
16
|
extends: true,
|
|
19
17
|
plugins: [
|
|
20
18
|
// The plugin will run tests for the stories defined in your Storybook config
|
|
21
19
|
// See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
|
|
22
|
-
storybookTest({ configDir: path.join(dirname,
|
|
20
|
+
storybookTest({ configDir: path.join(dirname, '.storybook') }),
|
|
23
21
|
],
|
|
24
22
|
test: {
|
|
25
|
-
name:
|
|
23
|
+
name: 'storybook',
|
|
26
24
|
browser: {
|
|
27
25
|
enabled: true,
|
|
28
26
|
headless: true,
|
|
29
|
-
provider:
|
|
30
|
-
instances: [{ browser:
|
|
27
|
+
provider: 'playwright',
|
|
28
|
+
instances: [{ browser: 'chromium' }],
|
|
31
29
|
},
|
|
32
|
-
setupFiles: [
|
|
30
|
+
setupFiles: ['.storybook/vitest.setup.ts'],
|
|
33
31
|
},
|
|
34
32
|
},
|
|
35
33
|
],
|
package/.turbo/turbo-lint.log
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @utilitywarehouse/hearth-react-native@0.27.1 lint /home/runner/work/hearth/hearth/packages/react-native
|
|
3
|
-
> TIMING=1 eslint .
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/home/runner/work/hearth/hearth/packages/react-native/src/components/Carousel/Carousel.context.tsx
|
|
7
|
-
6:14 warning Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components react-refresh/only-export-components
|
|
8
|
-
|
|
9
|
-
/home/runner/work/hearth/hearth/packages/react-native/src/components/Carousel/Carousel.tsx
|
|
10
|
-
146:6 warning React Hook useMemo has a missing dependency: 'hasCarouselControlsInTree'. Either include it or remove the dependency array react-hooks/exhaustive-deps
|
|
11
|
-
|
|
12
|
-
/home/runner/work/hearth/hearth/packages/react-native/src/components/DatePicker/DatePicker.tsx
|
|
13
|
-
109:6 warning React Hook useCallback has an unnecessary dependency: 'modalRef.current'. Either exclude it or remove the dependency array. Mutable values like 'modalRef.current' aren't valid dependencies because mutating them doesn't re-render the component react-hooks/exhaustive-deps
|
|
14
|
-
259:6 warning React Hook useEffect has a missing dependency: 'initialState'. Either include it or remove the dependency array react-hooks/exhaustive-deps
|
|
15
|
-
346:6 warning React Hook useEffect has a missing dependency: 'onChange'. Either include it or remove the dependency array react-hooks/exhaustive-deps
|
|
16
|
-
468:5 warning React Hook useCallback has a missing dependency: 'onChange'. Either include it or remove the dependency array react-hooks/exhaustive-deps
|
|
17
|
-
536:6 warning React Hook useEffect has a missing dependency: 'onSelectMonth'. Either include it or remove the dependency array react-hooks/exhaustive-deps
|
|
18
|
-
542:6 warning React Hook useEffect has a missing dependency: 'onSelectYear'. Either include it or remove the dependency array react-hooks/exhaustive-deps
|
|
19
|
-
|
|
20
|
-
/home/runner/work/hearth/hearth/packages/react-native/src/components/DatePicker/DatePickerDay.tsx
|
|
21
|
-
76:6 warning React Hook useMemo has an unnecessary dependency: 'styles.rangeRoot'. Either exclude it or remove the dependency array. Outer scope values like 'styles.rangeRoot' aren't valid dependencies because mutating them doesn't re-render the component react-hooks/exhaustive-deps
|
|
22
|
-
84:6 warning React Hook useMemo has a missing dependency: 'isSelected'. Either include it or remove the dependency array react-hooks/exhaustive-deps
|
|
23
|
-
|
|
24
|
-
/home/runner/work/hearth/hearth/packages/react-native/src/components/DatePicker/DatePickerDays.tsx
|
|
25
|
-
179:6 warning React Hook useMemo has unnecessary dependencies: 'month' and 'year'. Either exclude them or remove the dependency array react-hooks/exhaustive-deps
|
|
26
|
-
|
|
27
|
-
/home/runner/work/hearth/hearth/packages/react-native/src/components/DatePicker/DatePickerYears.tsx
|
|
28
|
-
52:6 warning React Hook useCallback has a missing dependency: 'containerHeight'. Either include it or remove the dependency array. Outer scope values like 'styles' aren't valid dependencies because mutating them doesn't re-render the component react-hooks/exhaustive-deps
|
|
29
|
-
|
|
30
|
-
/home/runner/work/hearth/hearth/packages/react-native/src/components/Input/Input.tsx
|
|
31
|
-
78:8 warning React Hook useEffect has a missing dependency: 'formFieldContext'. Either include it or remove the dependency array react-hooks/exhaustive-deps
|
|
32
|
-
|
|
33
|
-
/home/runner/work/hearth/hearth/packages/react-native/src/components/Modal/Modal.tsx
|
|
34
|
-
86:6 warning React Hook useCallback has an unnecessary dependency: 'Platform.OS'. Either exclude it or remove the dependency array. Outer scope values like 'Platform.OS' aren't valid dependencies because mutating them doesn't re-render the component react-hooks/exhaustive-deps
|
|
35
|
-
313:5 warning React Hook useCallback has a missing dependency: 'footer'. Either include it or remove the dependency array react-hooks/exhaustive-deps
|
|
36
|
-
|
|
37
|
-
/home/runner/work/hearth/hearth/packages/react-native/src/components/Modal/Modal.web.tsx
|
|
38
|
-
66:6 warning React Hook useCallback has an unnecessary dependency: 'Platform.OS'. Either exclude it or remove the dependency array. Outer scope values like 'Platform.OS' aren't valid dependencies because mutating them doesn't re-render the component react-hooks/exhaustive-deps
|
|
39
|
-
|
|
40
|
-
/home/runner/work/hearth/hearth/packages/react-native/src/components/PillGroup/PillGroup.tsx
|
|
41
|
-
17:9 warning The 'normalizedValue' conditional could make the dependencies of useMemo Hook (at line 33) change on every render. Move it inside the useMemo callback. Alternatively, wrap the initialization of 'normalizedValue' in its own useMemo() Hook react-hooks/exhaustive-deps
|
|
42
|
-
|
|
43
|
-
/home/runner/work/hearth/hearth/packages/react-native/src/components/Tabs/Tabs.tsx
|
|
44
|
-
53:6 warning React Hook useEffect has a missing dependency: 'tabValues'. Either include it or remove the dependency array react-hooks/exhaustive-deps
|
|
45
|
-
53:7 warning React Hook useEffect has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked react-hooks/exhaustive-deps
|
|
46
|
-
104:5 warning React Hook useMemo has an unnecessary dependency: 'tabValues'. Either exclude it or remove the dependency array react-hooks/exhaustive-deps
|
|
47
|
-
127:62 warning React Hook useEffect has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked react-hooks/exhaustive-deps
|
|
48
|
-
|
|
49
|
-
/home/runner/work/hearth/hearth/packages/react-native/src/components/Textarea/Textarea.tsx
|
|
50
|
-
45:6 warning React Hook useEffect has a missing dependency: 'formFieldContext'. Either include it or remove the dependency array react-hooks/exhaustive-deps
|
|
51
|
-
|
|
52
|
-
/home/runner/work/hearth/hearth/packages/react-native/src/components/Toast/Toast.context.tsx
|
|
53
|
-
14:14 warning Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components react-refresh/only-export-components
|
|
54
|
-
106:14 warning Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components react-refresh/only-export-components
|
|
55
|
-
|
|
56
|
-
/home/runner/work/hearth/hearth/packages/react-native/src/components/VerificationInput/VerificationInput.tsx
|
|
57
|
-
174:7 warning React Hook useImperativeHandle has a missing dependency: 'updateValue'. Either include it or remove the dependency array react-hooks/exhaustive-deps
|
|
58
|
-
|
|
59
|
-
✖ 25 problems (0 errors, 25 warnings)
|
|
60
|
-
|
|
61
|
-
Rule | Time (ms) | Relative
|
|
62
|
-
:-----------------------------------------|----------:|--------:
|
|
63
|
-
@typescript-eslint/no-unused-vars | 1499.293 | 61.6%
|
|
64
|
-
react-hooks/exhaustive-deps | 127.430 | 5.2%
|
|
65
|
-
react-hooks/rules-of-hooks | 84.158 | 3.5%
|
|
66
|
-
no-global-assign | 65.981 | 2.7%
|
|
67
|
-
no-unexpected-multiline | 44.926 | 1.8%
|
|
68
|
-
@typescript-eslint/ban-ts-comment | 39.212 | 1.6%
|
|
69
|
-
@typescript-eslint/triple-slash-reference | 36.913 | 1.5%
|
|
70
|
-
no-misleading-character-class | 36.268 | 1.5%
|
|
71
|
-
no-useless-escape | 28.431 | 1.2%
|
|
72
|
-
@typescript-eslint/no-unused-expressions | 25.564 | 1.1%
|