@hero-design/rn-work-uikit 1.1.0 → 1.2.0-alpha.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 (49) hide show
  1. package/.cursorrules +57 -0
  2. package/CHANGELOG.md +16 -0
  3. package/DEVELOPMENT.md +118 -0
  4. package/assets/fonts/BeVietnamPro-Bold.ttf +0 -0
  5. package/assets/fonts/BeVietnamPro-Light.ttf +0 -0
  6. package/assets/fonts/BeVietnamPro-Regular.ttf +0 -0
  7. package/assets/fonts/BeVietnamPro-SemiBold.ttf +0 -0
  8. package/assets/fonts/Saiga-Light.otf +0 -0
  9. package/assets/fonts/Saiga-Medium.otf +0 -0
  10. package/assets/fonts/Saiga-Regular.otf +0 -0
  11. package/assets/fonts/hero-icons-mobile.ttf +0 -0
  12. package/eslint.config.js +20 -0
  13. package/lib/index.js +871 -5
  14. package/package.json +4 -1
  15. package/rollup.config.mjs +2 -2
  16. package/src/__tests__/__snapshots__/index.spec.tsx.snap +90 -115
  17. package/src/__tests__/theme-export-override.spec.ts +6 -0
  18. package/src/components/TextInput/ErrorOrHelpText.tsx +58 -0
  19. package/src/components/TextInput/FloatingLabel.tsx +120 -0
  20. package/src/components/TextInput/InputComponent.tsx +61 -0
  21. package/src/components/TextInput/InputRow.tsx +103 -0
  22. package/src/components/TextInput/MaxLengthMessage.tsx +66 -0
  23. package/src/components/TextInput/PrefixComponent.tsx +77 -0
  24. package/src/components/TextInput/StyledTextInput.tsx +134 -0
  25. package/src/components/TextInput/SuffixComponent.tsx +73 -0
  26. package/src/components/TextInput/__tests__/ErrorOrHelpText.spec.tsx +20 -0
  27. package/src/components/TextInput/__tests__/FloatingLabel.spec.tsx +203 -0
  28. package/src/components/TextInput/__tests__/InputComponent.spec.tsx +39 -0
  29. package/src/components/TextInput/__tests__/InputRow.spec.tsx +275 -0
  30. package/src/components/TextInput/__tests__/MaxLengthMessage.spec.tsx +17 -0
  31. package/src/components/TextInput/__tests__/PrefixComponent.spec.tsx +14 -0
  32. package/src/components/TextInput/__tests__/StyledTextInput.spec.tsx +114 -0
  33. package/src/components/TextInput/__tests__/SuffixComponent.spec.tsx +20 -0
  34. package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +571 -0
  35. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +5671 -0
  36. package/src/components/TextInput/__tests__/getState.spec.tsx +89 -0
  37. package/src/components/TextInput/__tests__/index.spec.tsx +699 -0
  38. package/src/components/TextInput/constants.ts +1 -0
  39. package/src/components/TextInput/index.tsx +327 -0
  40. package/src/components/TextInput/types.ts +95 -0
  41. package/src/emotion.d.ts +15 -0
  42. package/src/index.ts +3 -0
  43. package/src/jest.d.ts +24 -0
  44. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +15 -8
  45. package/src/theme/components/textInput.ts +33 -0
  46. package/src/utils/__tests__/helpers.spec.ts +92 -0
  47. package/src/utils/helpers.ts +113 -0
  48. package/testUtils/renderWithTheme.tsx +6 -3
  49. package/stats/1.1.0/rn-work-uikit-stats.html +0 -4842
@@ -0,0 +1,89 @@
1
+ import { getState } from '../index';
2
+
3
+ describe('getState', () => {
4
+ it.each`
5
+ disabled | error | editable | loading | isEmptyValue | expected
6
+ ${false} | ${undefined} | ${true} | ${false} | ${true} | ${'default'}
7
+ ${false} | ${undefined} | ${true} | ${false} | ${false} | ${'filled'}
8
+ ${false} | ${undefined} | ${false} | ${true} | ${true} | ${'readonly'}
9
+ ${false} | ${undefined} | ${false} | ${true} | ${false} | ${'readonly'}
10
+ ${false} | ${undefined} | ${true} | ${true} | ${true} | ${'readonly'}
11
+ ${false} | ${'This field is required'} | ${false} | ${false} | ${true} | ${'error'}
12
+ ${false} | ${'This field is required'} | ${false} | ${false} | ${false} | ${'error'}
13
+ ${false} | ${'This field is required'} | ${true} | ${false} | ${false} | ${'error'}
14
+ ${true} | ${'This field is required'} | ${false} | ${false} | ${true} | ${'disabled'}
15
+ ${true} | ${'This field is required'} | ${false} | ${false} | ${false} | ${'disabled'}
16
+ ${true} | ${undefined} | ${true} | ${false} | ${true} | ${'disabled'}
17
+ ${true} | ${undefined} | ${true} | ${false} | ${false} | ${'disabled'}
18
+ `(
19
+ 'should return "$expected" when disabled: $disabled, error: $error, editable: $editable, loading: $loading, isEmptyValue: $isEmptyValue',
20
+ ({ disabled, error, editable, loading, isEmptyValue, expected }) => {
21
+ expect(
22
+ getState({
23
+ disabled,
24
+ error,
25
+ editable,
26
+ loading,
27
+ isEmptyValue,
28
+ })
29
+ ).toBe(expected);
30
+ }
31
+ );
32
+
33
+ it('should prioritize states in correct order', () => {
34
+ // Disabled takes highest priority
35
+ expect(
36
+ getState({
37
+ disabled: true,
38
+ error: 'Some error',
39
+ editable: false,
40
+ loading: true,
41
+ isEmptyValue: false,
42
+ })
43
+ ).toBe('disabled');
44
+
45
+ // Error takes priority over readonly and filled
46
+ expect(
47
+ getState({
48
+ disabled: false,
49
+ error: 'Some error',
50
+ editable: false,
51
+ loading: false,
52
+ isEmptyValue: false,
53
+ })
54
+ ).toBe('error');
55
+
56
+ // Readonly takes priority over filled
57
+ expect(
58
+ getState({
59
+ disabled: false,
60
+ error: undefined,
61
+ editable: false,
62
+ loading: false,
63
+ isEmptyValue: false,
64
+ })
65
+ ).toBe('readonly');
66
+
67
+ // Filled takes priority over default
68
+ expect(
69
+ getState({
70
+ disabled: false,
71
+ error: undefined,
72
+ editable: true,
73
+ loading: false,
74
+ isEmptyValue: false,
75
+ })
76
+ ).toBe('filled');
77
+
78
+ // Default is the fallback
79
+ expect(
80
+ getState({
81
+ disabled: false,
82
+ error: undefined,
83
+ editable: true,
84
+ loading: false,
85
+ isEmptyValue: true,
86
+ })
87
+ ).toBe('default');
88
+ });
89
+ });