@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.
Files changed (60) hide show
  1. package/.storybook/vitest.setup.ts +35 -3
  2. package/.turbo/turbo-build.log +5 -4
  3. package/CHANGELOG.md +15 -0
  4. package/build/components/Button/ButtonRoot.js +8 -0
  5. package/build/components/Carousel/Carousel.js +6 -1
  6. package/build/components/DatePicker/TimePicker.d.ts +3 -0
  7. package/build/components/DatePicker/TimePicker.js +84 -0
  8. package/build/components/DatePicker/time-picker/animated-math.d.ts +4 -0
  9. package/build/components/DatePicker/time-picker/animated-math.js +19 -0
  10. package/build/components/DatePicker/time-picker/period-native.d.ts +6 -0
  11. package/build/components/DatePicker/time-picker/period-native.js +17 -0
  12. package/build/components/DatePicker/time-picker/period-picker.d.ts +6 -0
  13. package/build/components/DatePicker/time-picker/period-picker.js +10 -0
  14. package/build/components/DatePicker/time-picker/period-web.d.ts +6 -0
  15. package/build/components/DatePicker/time-picker/period-web.js +21 -0
  16. package/build/components/DatePicker/time-picker/wheel-native.d.ts +8 -0
  17. package/build/components/DatePicker/time-picker/wheel-native.js +19 -0
  18. package/build/components/DatePicker/time-picker/wheel-picker/index.d.ts +2 -0
  19. package/build/components/DatePicker/time-picker/wheel-picker/index.js +2 -0
  20. package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.d.ts +16 -0
  21. package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.js +97 -0
  22. package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.d.ts +21 -0
  23. package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.js +88 -0
  24. package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.d.ts +23 -0
  25. package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.js +21 -0
  26. package/build/components/DatePicker/time-picker/wheel-web.d.ts +8 -0
  27. package/build/components/DatePicker/time-picker/wheel-web.js +146 -0
  28. package/build/components/DatePicker/time-picker/wheel.d.ts +8 -0
  29. package/build/components/DatePicker/time-picker/wheel.js +10 -0
  30. package/build/components/List/List.js +2 -2
  31. package/build/components/Modal/Modal.js +16 -11
  32. package/build/components/SegmentedControl/SegmentedControl.js +4 -1
  33. package/build/components/SegmentedControl/SegmentedControlOption.js +4 -1
  34. package/build/components/TimePicker/TimePickerWheel.js +9 -1
  35. package/build/components/Toast/Toast.context.js +1 -1
  36. package/build/components/VerificationInput/VerificationInput.js +11 -22
  37. package/build/components/VerificationInput/VerificationInput.utils.d.ts +8 -0
  38. package/build/components/VerificationInput/VerificationInput.utils.js +17 -0
  39. package/build/components/VerificationInput/VerificationInput.utils.test.d.ts +1 -0
  40. package/build/components/VerificationInput/VerificationInput.utils.test.js +36 -0
  41. package/docs/changelog.mdx +113 -0
  42. package/package.json +5 -4
  43. package/src/components/Button/Button.stories.tsx +43 -7
  44. package/src/components/Button/ButtonRoot.tsx +8 -0
  45. package/src/components/Carousel/Carousel.tsx +6 -2
  46. package/src/components/IconContainer/IconContainer.stories.tsx +35 -30
  47. package/src/components/List/List.tsx +5 -4
  48. package/src/components/Modal/Modal.tsx +31 -16
  49. package/src/components/SegmentedControl/SegmentedControl.tsx +4 -1
  50. package/src/components/SegmentedControl/SegmentedControlOption.tsx +5 -4
  51. package/src/components/TimePicker/TimePickerWheel.tsx +11 -4
  52. package/src/components/Toast/Toast.context.tsx +1 -1
  53. package/src/components/VerificationInput/VerificationInput.stories.tsx +33 -0
  54. package/src/components/VerificationInput/VerificationInput.tsx +18 -29
  55. package/src/components/VerificationInput/VerificationInput.utils.test.ts +48 -0
  56. package/src/components/VerificationInput/VerificationInput.utils.ts +32 -0
  57. package/tsconfig.eslint.json +2 -1
  58. package/vitest.config.js +11 -13
  59. package/vitest.unit.config.ts +9 -0
  60. 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
+ };
@@ -5,7 +5,8 @@
5
5
  "./src/**/*.stories.tsx",
6
6
  "./src/**/*.figma.tsx",
7
7
  "./.storybook/**/*",
8
- "./docs/**/*"
8
+ "./docs/**/*",
9
+ "./vitest.unit.config.ts"
9
10
  ],
10
11
  "exclude": [
11
12
  "node_modules"
package/vitest.config.js CHANGED
@@ -1,35 +1,33 @@
1
- import path from "node:path";
2
- import { fileURLToPath } from "node:url";
1
+ import path from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
3
 
4
- import { defineConfig } from "vitest/config";
4
+ import { defineConfig } from 'vitest/config';
5
5
 
6
- import { storybookTest } from "@storybook/addon-vitest/vitest-plugin";
6
+ import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
7
7
 
8
8
  const dirname =
9
- typeof __dirname !== "undefined"
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
- workspace: [
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, ".storybook") }),
20
+ storybookTest({ configDir: path.join(dirname, '.storybook') }),
23
21
  ],
24
22
  test: {
25
- name: "storybook",
23
+ name: 'storybook',
26
24
  browser: {
27
25
  enabled: true,
28
26
  headless: true,
29
- provider: "playwright",
30
- instances: [{ browser: "chromium" }],
27
+ provider: 'playwright',
28
+ instances: [{ browser: 'chromium' }],
31
29
  },
32
- setupFiles: [".storybook/vitest.setup.js"],
30
+ setupFiles: ['.storybook/vitest.setup.ts'],
33
31
  },
34
32
  },
35
33
  ],
@@ -0,0 +1,9 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ include: ['src/**/*.test.ts', 'src/**/*.test.tsx'],
6
+ exclude: ['src/**/*.stories.ts', 'src/**/*.stories.tsx'],
7
+ environment: 'node',
8
+ },
9
+ });
@@ -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%