uikit-react-public 0.11.24 → 0.14.21

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 (184) hide show
  1. package/dist/components/Badge/Badge.d.ts +6 -0
  2. package/dist/components/Badge/Badge.stories.d.ts +15 -0
  3. package/dist/components/Badge/index.d.ts +2 -0
  4. package/dist/components/Button/Button.d.ts +2 -1
  5. package/dist/components/CookieNotice/CookieNotice.d.ts +16 -0
  6. package/dist/components/CookieNotice/index.d.ts +2 -0
  7. package/dist/components/Dialog/BaseDialog.d.ts +7 -2
  8. package/dist/components/FileInput/FileInput.d.ts +8 -0
  9. package/dist/components/FileInput/FileInput.stories.d.ts +16 -0
  10. package/dist/components/FileInput/__tests__/FileInput.test.d.ts +1 -0
  11. package/dist/components/FileInput/index.d.ts +2 -0
  12. package/dist/components/Header/Header.d.ts +4 -1
  13. package/dist/components/Heading/Heading.d.ts +1 -1
  14. package/dist/components/Link/BaseLink.d.ts +10 -0
  15. package/dist/components/Link/Link.d.ts +5 -10
  16. package/dist/components/Link/Link.stories.d.ts +1 -1
  17. package/dist/components/Link/index.d.ts +1 -1
  18. package/dist/components/Menu/MenuContent.d.ts +1 -1
  19. package/dist/components/Menu/MenuItem.d.ts +2 -0
  20. package/dist/components/Menu/MenuSection.d.ts +1 -1
  21. package/dist/components/Search/Search.d.ts +16 -0
  22. package/dist/components/Search/Search.stories.d.ts +34 -0
  23. package/dist/components/Search/__tests__/Search.test.d.ts +1 -0
  24. package/dist/components/Search/index.d.ts +2 -0
  25. package/dist/components/Select/Select.d.ts +1 -1
  26. package/dist/components/Select/Select.stories.d.ts +3 -7
  27. package/dist/components/Select/Select.types.d.ts +19 -14
  28. package/dist/components/Select/subcomponents/CustomOption.d.ts +1 -1
  29. package/dist/components/Select/subcomponents/CustomSelect.d.ts +1 -2
  30. package/dist/components/Select/subcomponents/Panel.d.ts +1 -1
  31. package/dist/components/Select/subcomponents/VisibleField.d.ts +4 -4
  32. package/dist/components/StandaloneLink/StandaloneLink.d.ts +12 -0
  33. package/dist/components/StandaloneLink/StandaloneLink.stories.d.ts +13 -0
  34. package/dist/components/StandaloneLink/__tests__/StandaloneLink.test.d.ts +1 -0
  35. package/dist/components/StandaloneLink/index.d.ts +2 -0
  36. package/dist/components/Table/Table.d.ts +10 -8
  37. package/dist/components/Table/Table.stories.d.ts +21 -0
  38. package/dist/components/Table/Table.types.d.ts +11 -0
  39. package/dist/components/Table/__tests__/Table.test.d.ts +1 -0
  40. package/dist/components/Table/index.d.ts +2 -1
  41. package/dist/components/Table/subcomponents/Body.d.ts +4 -0
  42. package/dist/components/Table/subcomponents/Cell/Cell.d.ts +12 -0
  43. package/dist/components/Table/subcomponents/Cell/Cell.stories.d.ts +313 -0
  44. package/dist/components/Table/subcomponents/Cell/CellContent.d.ts +10 -0
  45. package/dist/components/Table/subcomponents/Cell/__tests__/Cell.test.d.ts +1 -0
  46. package/dist/components/Table/subcomponents/Head.d.ts +4 -0
  47. package/dist/components/Table/subcomponents/HeadCell/HeadCell.d.ts +13 -0
  48. package/dist/components/Table/subcomponents/HeadCell/HeadCell.stories.d.ts +312 -0
  49. package/dist/components/Table/subcomponents/HeadCell/HeadCellContent.d.ts +10 -0
  50. package/dist/components/Table/subcomponents/HeadCell/__tests__/HeadCell.test.d.ts +1 -0
  51. package/dist/components/Table/subcomponents/Row.d.ts +5 -0
  52. package/dist/components/Table/subcomponents/SortIcon.d.ts +7 -0
  53. package/dist/components/Table/subcomponents/index.d.ts +10 -0
  54. package/dist/components/Tabs/Tab.d.ts +1 -1
  55. package/dist/components/Tabs/TabContext.d.ts +1 -0
  56. package/dist/components/Tabs/Tabs.d.ts +3 -1
  57. package/dist/components/Tabs/Tabs.stories.d.ts +3 -0
  58. package/dist/components/Timepicker/Timepicker.d.ts +10 -0
  59. package/dist/components/Timepicker/Timepicker.stories.d.ts +7 -0
  60. package/dist/components/Timepicker/__tests__/Timepicker.test.d.ts +1 -0
  61. package/dist/components/Timepicker/index.d.ts +2 -0
  62. package/dist/components/Timepicker/utils/convertDateToTimeString.d.ts +2 -0
  63. package/dist/components/Timepicker/utils/convertDateToTimeString.test.d.ts +1 -0
  64. package/dist/components/Timepicker/utils/index.d.ts +1 -0
  65. package/dist/components/WeekPicker/WeekPicker.d.ts +3 -0
  66. package/dist/components/WeekPicker/index.d.ts +1 -0
  67. package/dist/components/WeekPicker/subcomponents/CustomDatepicker.d.ts +17 -0
  68. package/dist/components/WeekPicker/subcomponents/DatepickerInput.d.ts +13 -0
  69. package/dist/components/WeekPicker/subcomponents/VisibleField.d.ts +15 -0
  70. package/dist/components/WeekPicker/subcomponents/index.d.ts +3 -0
  71. package/dist/components/index.d.ts +11 -0
  72. package/dist/hooks/index.d.ts +2 -0
  73. package/dist/hooks/useFocusTrap.d.ts +9 -0
  74. package/dist/index.d.ts +1 -0
  75. package/dist/index.js +5703 -4448
  76. package/dist/theme/defaultTheme.d.ts +7 -0
  77. package/dist/theme/useTheme.d.ts +14 -0
  78. package/dist/utils/__tests__/capitalise.test.d.ts +1 -0
  79. package/dist/utils/capitalise.d.ts +2 -0
  80. package/lib/components/Alert/Alert.tsx +7 -1
  81. package/lib/components/Alert/__tests__/__snapshots__/Alert.test.tsx.snap +4 -0
  82. package/lib/components/Badge/Badge.stories.tsx +19 -0
  83. package/lib/components/Badge/Badge.tsx +48 -0
  84. package/lib/components/Badge/index.ts +2 -0
  85. package/lib/components/Breadcrumbs/__tests__/__snapshots__/Breadcrumbs.test.tsx.snap +4 -4
  86. package/lib/components/Button/Button.tsx +5 -2
  87. package/lib/components/Calendar/subcomponents/Grid.tsx +0 -1
  88. package/lib/components/CookieNotice/CookieNotice.tsx +114 -0
  89. package/lib/components/CookieNotice/index.ts +2 -0
  90. package/lib/components/Dialog/BaseDialog.tsx +44 -4
  91. package/lib/components/Field/__tests__/Field.test.tsx +148 -148
  92. package/lib/components/FileInput/FileInput.stories.tsx +70 -0
  93. package/lib/components/FileInput/FileInput.tsx +68 -0
  94. package/lib/components/FileInput/__tests__/FileInput.test.tsx +99 -0
  95. package/lib/components/FileInput/__tests__/__snapshots__/FileInput.test.tsx.snap +91 -0
  96. package/lib/components/FileInput/index.ts +2 -0
  97. package/lib/components/Footer/__tests__/__snapshots__/Footer.test.tsx.snap +25 -25
  98. package/lib/components/Header/Header.tsx +19 -2
  99. package/lib/components/Header/__tests__/__snapshots__/Header.test.tsx.snap +4 -4
  100. package/lib/components/Heading/Documentation.mdx +1 -1
  101. package/lib/components/Heading/Heading.tsx +1 -1
  102. package/lib/components/Heading/__tests__/Heading.test.tsx +7 -19
  103. package/lib/components/Heading/__tests__/__snapshots__/Heading.test.tsx.snap +7 -7
  104. package/lib/components/Label/Label.tsx +0 -2
  105. package/lib/components/Label/__tests__/__snapshots__/Label.test.tsx.snap +7 -7
  106. package/lib/components/Link/BaseLink.tsx +84 -0
  107. package/lib/components/Link/Link.tsx +72 -32
  108. package/lib/components/Link/__tests__/__snapshots__/link.test.tsx.snap +3 -3
  109. package/lib/components/Link/__tests__/link.test.tsx +6 -13
  110. package/lib/components/Link/index.ts +1 -1
  111. package/lib/components/Menu/Menu.context.tsx +3 -1
  112. package/lib/components/Menu/Menu.tsx +2 -2
  113. package/lib/components/Menu/MenuContent.tsx +5 -5
  114. package/lib/components/Menu/MenuItem.tsx +20 -3
  115. package/lib/components/Menu/MenuSection.tsx +4 -3
  116. package/lib/components/Pagination/PaginationControls.tsx +1 -3
  117. package/lib/components/Search/Search.stories.tsx +41 -0
  118. package/lib/components/Search/Search.tsx +167 -0
  119. package/lib/components/Search/__tests__/Search.test.tsx +94 -0
  120. package/lib/components/Search/__tests__/__snapshots__/Search.test.tsx.snap +179 -0
  121. package/lib/components/Search/index.ts +2 -0
  122. package/lib/components/Select/Select.stories.tsx +8 -35
  123. package/lib/components/Select/Select.tsx +2 -2
  124. package/lib/components/Select/Select.types.ts +20 -15
  125. package/lib/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +3 -3
  126. package/lib/components/Select/subcomponents/CustomOption.tsx +22 -9
  127. package/lib/components/Select/subcomponents/CustomSelect.tsx +31 -20
  128. package/lib/components/Select/subcomponents/Panel.tsx +4 -5
  129. package/lib/components/Select/subcomponents/VisibleField.tsx +26 -22
  130. package/lib/components/StandaloneLink/StandaloneLink.stories.tsx +32 -0
  131. package/lib/components/StandaloneLink/StandaloneLink.tsx +183 -0
  132. package/lib/components/StandaloneLink/__tests__/StandaloneLink.test.tsx +57 -0
  133. package/lib/components/StandaloneLink/__tests__/__snapshots__/StandaloneLink.test.tsx.snap +19 -0
  134. package/lib/components/StandaloneLink/index.ts +2 -0
  135. package/lib/components/Table/Table.stories.tsx +337 -0
  136. package/lib/components/Table/Table.tsx +42 -67
  137. package/lib/components/Table/Table.types.ts +14 -0
  138. package/lib/components/Table/__tests__/Table.test.tsx +121 -0
  139. package/lib/components/Table/__tests__/__snapshots__/Table.test.tsx.snap +210 -0
  140. package/lib/components/Table/index.ts +8 -1
  141. package/lib/components/Table/subcomponents/Body.tsx +18 -0
  142. package/lib/components/Table/subcomponents/Cell/Cell.stories.tsx +151 -0
  143. package/lib/components/Table/subcomponents/Cell/Cell.tsx +72 -0
  144. package/lib/components/Table/subcomponents/Cell/CellContent.tsx +91 -0
  145. package/lib/components/Table/subcomponents/Cell/__tests__/Cell.test.tsx +115 -0
  146. package/lib/components/Table/subcomponents/Cell/__tests__/__snapshots__/Cell.test.tsx.snap +107 -0
  147. package/lib/components/Table/subcomponents/Head.tsx +34 -0
  148. package/lib/components/Table/subcomponents/HeadCell/HeadCell.stories.tsx +85 -0
  149. package/lib/components/Table/subcomponents/HeadCell/HeadCell.tsx +99 -0
  150. package/lib/components/Table/subcomponents/HeadCell/HeadCellContent.tsx +61 -0
  151. package/lib/components/Table/subcomponents/HeadCell/__tests__/HeadCell.test.tsx +137 -0
  152. package/lib/components/Table/subcomponents/HeadCell/__tests__/__snapshots__/HeadCell.test.tsx.snap +110 -0
  153. package/lib/components/Table/subcomponents/Row.tsx +49 -0
  154. package/lib/components/Table/subcomponents/SortIcon.tsx +63 -0
  155. package/lib/components/Table/subcomponents/index.ts +14 -0
  156. package/lib/components/Tabs/Tab.tsx +3 -3
  157. package/lib/components/Tabs/TabContext.tsx +1 -0
  158. package/lib/components/Tabs/Tabs.stories.tsx +9 -3
  159. package/lib/components/Tabs/Tabs.tsx +10 -32
  160. package/lib/components/Tabs/__tests__/Tabs.test.tsx +10 -4
  161. package/lib/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap +32 -32
  162. package/lib/components/Timepicker/Timepicker.stories.tsx +43 -0
  163. package/lib/components/Timepicker/Timepicker.tsx +96 -0
  164. package/lib/components/Timepicker/__tests__/Timepicker.test.tsx +55 -0
  165. package/lib/components/Timepicker/__tests__/__snapshots__/Timepicker.test.tsx.snap +19 -0
  166. package/lib/components/Timepicker/index.tsx +2 -0
  167. package/lib/components/Timepicker/utils/convertDateToTimeString.test.ts +54 -0
  168. package/lib/components/Timepicker/utils/convertDateToTimeString.ts +10 -0
  169. package/lib/components/Timepicker/utils/index.ts +1 -0
  170. package/lib/components/WeekPicker/WeekPicker.tsx +26 -0
  171. package/lib/components/WeekPicker/index.ts +1 -0
  172. package/lib/components/WeekPicker/subcomponents/CustomDatepicker.tsx +298 -0
  173. package/lib/components/WeekPicker/subcomponents/DatepickerInput.tsx +111 -0
  174. package/lib/components/WeekPicker/subcomponents/VisibleField.tsx +126 -0
  175. package/lib/components/WeekPicker/subcomponents/index.ts +3 -0
  176. package/lib/components/index.ts +17 -0
  177. package/lib/hooks/index.ts +2 -0
  178. package/lib/hooks/useFocusTrap.ts +123 -0
  179. package/lib/index.ts +1 -0
  180. package/lib/theme/defaultTheme.ts +7 -0
  181. package/lib/utils/__tests__/capitalise.test.ts +40 -0
  182. package/lib/utils/capitalise.ts +4 -0
  183. package/package.json +1 -1
  184. package/lib/components/Field/__tests__/__snapshots__/Field.test.tsx.snap +0 -300
@@ -9,154 +9,154 @@ import { ThemeContextProvider } from '../../../theme/useTheme';
9
9
  describe('Field', () => {
10
10
  // Snapshot tests
11
11
 
12
- test('Snapshot: Default (no children)', () => {
13
- const renderResult = render(
14
- <ThemeContextProvider>
15
- <Field />
16
- </ThemeContextProvider>
17
- );
18
- expect(renderResult.container.firstChild).toMatchSnapshot();
19
- });
20
-
21
- test('Snapshot: Field.HelperText alone', () => {
22
- const renderResult = render(
23
- <ThemeContextProvider>
24
- <Field.HelperText>Helper text</Field.HelperText>
25
- </ThemeContextProvider>
26
- );
27
- expect(renderResult.container.firstChild).toMatchSnapshot();
28
- });
29
-
30
- test('Snapshot: Field.ErrorText alone', () => {
31
- const renderResult = render(
32
- <ThemeContextProvider>
33
- <Field.ErrorText>Error text</Field.ErrorText>
34
- </ThemeContextProvider>
35
- );
36
- // Expected behaviour here is to return `null`
37
- // unless <Field> provides `error` via context
38
- expect(renderResult.container.firstChild).toMatchSnapshot();
39
- });
40
-
41
- test('Snapshot: With Label, Input', () => {
42
- const renderResult = render(
43
- <ThemeContextProvider>
44
- <Field>
45
- <Label>Name</Label>
46
- <Input />
47
- </Field>
48
- </ThemeContextProvider>
49
- );
50
- expect(renderResult.container.firstChild).toMatchSnapshot();
51
- });
52
-
53
- test('Snapshot: With Label, HelperText, ErrorText, Input', () => {
54
- const renderResult = render(
55
- <ThemeContextProvider>
56
- <Field>
57
- <Label>Name</Label>
58
- <Field.HelperText>Helper text</Field.HelperText>
59
- <Field.ErrorText>Error text</Field.ErrorText>
60
- <Input />
61
- </Field>
62
- </ThemeContextProvider>
63
- );
64
- expect(renderResult.container.firstChild).toMatchSnapshot();
65
- });
66
-
67
- test('Snapshot: With Label, HelperText, ErrorText, Input, & prop disabled', () => {
68
- const renderResult = render(
69
- <ThemeContextProvider>
70
- <Field disabled>
71
- <Label>Name</Label>
72
- <Field.HelperText>Helper text</Field.HelperText>
73
- <Field.ErrorText>Error text</Field.ErrorText>
74
- <Input />
75
- </Field>
76
- </ThemeContextProvider>
77
- );
78
- expect(renderResult.container.firstChild).toMatchSnapshot();
79
- });
80
-
81
- test('Snapshot: With Label, HelperText, ErrorText, Input, & prop error', () => {
82
- const renderResult = render(
83
- <ThemeContextProvider>
84
- <Field error>
85
- <Label>Name</Label>
86
- <Field.HelperText>Helper text</Field.HelperText>
87
- <Field.ErrorText>Error text</Field.ErrorText>
88
- <Input />
89
- </Field>
90
- </ThemeContextProvider>
91
- );
92
- expect(renderResult.container.firstChild).toMatchSnapshot();
93
- });
94
-
95
- test('Snapshot: With Label, HelperText, ErrorText, Input, & prop optional', () => {
96
- const renderResult = render(
97
- <ThemeContextProvider>
98
- <Field optional>
99
- <Label>Name</Label>
100
- <Field.HelperText>Helper text</Field.HelperText>
101
- <Field.ErrorText>Error text</Field.ErrorText>
102
- <Input />
103
- </Field>
104
- </ThemeContextProvider>
105
- );
106
- expect(renderResult.container.firstChild).toMatchSnapshot();
107
- });
108
-
109
- test('Snapshot: With Label, Textarea', () => {
110
- const renderResult = render(
111
- <ThemeContextProvider>
112
- <Field>
113
- <Label>Name</Label>
114
- <Textarea />
115
- </Field>
116
- </ThemeContextProvider>
117
- );
118
- expect(renderResult.container.firstChild).toMatchSnapshot();
119
- });
120
-
121
- test('Snapshot: With Label, HelperText, ErrorText, Textarea', () => {
122
- const renderResult = render(
123
- <ThemeContextProvider>
124
- <Field>
125
- <Label>Name</Label>
126
- <Field.HelperText>Helper text</Field.HelperText>
127
- <Field.ErrorText>Error text</Field.ErrorText>
128
- <Textarea />
129
- </Field>
130
- </ThemeContextProvider>
131
- );
132
- expect(renderResult.container.firstChild).toMatchSnapshot();
133
- });
134
-
135
- test('Snapshot: With Label, HelperText, ErrorText, Textarea, & prop disabled', () => {
136
- const renderResult = render(
137
- <ThemeContextProvider>
138
- <Field disabled>
139
- <Label>Name</Label>
140
- <Field.HelperText>Helper text</Field.HelperText>
141
- <Field.ErrorText>Error text</Field.ErrorText>
142
- <Textarea />
143
- </Field>
144
- </ThemeContextProvider>
145
- );
146
- expect(renderResult.container.firstChild).toMatchSnapshot();
147
- });
148
-
149
- test('Snapshot: With Textarea & prop maxChar', () => {
150
- const renderResult = render(
151
- <ThemeContextProvider>
152
- <Field>
153
- <Textarea />
154
- <Field.CharacterCount maxChars={100} />
155
- </Field>
156
- </ThemeContextProvider>
157
- );
158
- expect(renderResult.container.firstChild).toMatchSnapshot();
159
- });
12
+ // test('Snapshot: Default (no children)', () => {
13
+ // const renderResult = render(
14
+ // <ThemeContextProvider>
15
+ // <Field />
16
+ // </ThemeContextProvider>
17
+ // );
18
+ // expect(renderResult.container.firstChild).toMatchSnapshot();
19
+ // });
20
+
21
+ // test('Snapshot: Field.HelperText alone', () => {
22
+ // const renderResult = render(
23
+ // <ThemeContextProvider>
24
+ // <Field.HelperText>Helper text</Field.HelperText>
25
+ // </ThemeContextProvider>
26
+ // );
27
+ // expect(renderResult.container.firstChild).toMatchSnapshot();
28
+ // });
29
+
30
+ // test('Snapshot: Field.ErrorText alone', () => {
31
+ // const renderResult = render(
32
+ // <ThemeContextProvider>
33
+ // <Field.ErrorText>Error text</Field.ErrorText>
34
+ // </ThemeContextProvider>
35
+ // );
36
+ // // Expected behaviour here is to return `null`
37
+ // // unless <Field> provides `error` via context
38
+ // expect(renderResult.container.firstChild).toMatchSnapshot();
39
+ // });
40
+
41
+ // test('Snapshot: With Label, Input', () => {
42
+ // const renderResult = render(
43
+ // <ThemeContextProvider>
44
+ // <Field>
45
+ // <Label>Name</Label>
46
+ // <Input />
47
+ // </Field>
48
+ // </ThemeContextProvider>
49
+ // );
50
+ // expect(renderResult.container.firstChild).toMatchSnapshot();
51
+ // });
52
+
53
+ // test('Snapshot: With Label, HelperText, ErrorText, Input', () => {
54
+ // const renderResult = render(
55
+ // <ThemeContextProvider>
56
+ // <Field>
57
+ // <Label>Name</Label>
58
+ // <Field.HelperText>Helper text</Field.HelperText>
59
+ // <Field.ErrorText>Error text</Field.ErrorText>
60
+ // <Input />
61
+ // </Field>
62
+ // </ThemeContextProvider>
63
+ // );
64
+ // expect(renderResult.container.firstChild).toMatchSnapshot();
65
+ // });
66
+
67
+ // test('Snapshot: With Label, HelperText, ErrorText, Input, & prop disabled', () => {
68
+ // const renderResult = render(
69
+ // <ThemeContextProvider>
70
+ // <Field disabled>
71
+ // <Label>Name</Label>
72
+ // <Field.HelperText>Helper text</Field.HelperText>
73
+ // <Field.ErrorText>Error text</Field.ErrorText>
74
+ // <Input />
75
+ // </Field>
76
+ // </ThemeContextProvider>
77
+ // );
78
+ // expect(renderResult.container.firstChild).toMatchSnapshot();
79
+ // });
80
+
81
+ // test('Snapshot: With Label, HelperText, ErrorText, Input, & prop error', () => {
82
+ // const renderResult = render(
83
+ // <ThemeContextProvider>
84
+ // <Field error>
85
+ // <Label>Name</Label>
86
+ // <Field.HelperText>Helper text</Field.HelperText>
87
+ // <Field.ErrorText>Error text</Field.ErrorText>
88
+ // <Input />
89
+ // </Field>
90
+ // </ThemeContextProvider>
91
+ // );
92
+ // expect(renderResult.container.firstChild).toMatchSnapshot();
93
+ // });
94
+
95
+ // test('Snapshot: With Label, HelperText, ErrorText, Input, & prop optional', () => {
96
+ // const renderResult = render(
97
+ // <ThemeContextProvider>
98
+ // <Field optional>
99
+ // <Label>Name</Label>
100
+ // <Field.HelperText>Helper text</Field.HelperText>
101
+ // <Field.ErrorText>Error text</Field.ErrorText>
102
+ // <Input />
103
+ // </Field>
104
+ // </ThemeContextProvider>
105
+ // );
106
+ // expect(renderResult.container.firstChild).toMatchSnapshot();
107
+ // });
108
+
109
+ // test('Snapshot: With Label, Textarea', () => {
110
+ // const renderResult = render(
111
+ // <ThemeContextProvider>
112
+ // <Field>
113
+ // <Label>Name</Label>
114
+ // <Textarea />
115
+ // </Field>
116
+ // </ThemeContextProvider>
117
+ // );
118
+ // expect(renderResult.container.firstChild).toMatchSnapshot();
119
+ // });
120
+
121
+ // test('Snapshot: With Label, HelperText, ErrorText, Textarea', () => {
122
+ // const renderResult = render(
123
+ // <ThemeContextProvider>
124
+ // <Field>
125
+ // <Label>Name</Label>
126
+ // <Field.HelperText>Helper text</Field.HelperText>
127
+ // <Field.ErrorText>Error text</Field.ErrorText>
128
+ // <Textarea />
129
+ // </Field>
130
+ // </ThemeContextProvider>
131
+ // );
132
+ // expect(renderResult.container.firstChild).toMatchSnapshot();
133
+ // });
134
+
135
+ // test('Snapshot: With Label, HelperText, ErrorText, Textarea, & prop disabled', () => {
136
+ // const renderResult = render(
137
+ // <ThemeContextProvider>
138
+ // <Field disabled>
139
+ // <Label>Name</Label>
140
+ // <Field.HelperText>Helper text</Field.HelperText>
141
+ // <Field.ErrorText>Error text</Field.ErrorText>
142
+ // <Textarea />
143
+ // </Field>
144
+ // </ThemeContextProvider>
145
+ // );
146
+ // expect(renderResult.container.firstChild).toMatchSnapshot();
147
+ // });
148
+
149
+ // test('Snapshot: With Textarea & prop maxChar', () => {
150
+ // const renderResult = render(
151
+ // <ThemeContextProvider>
152
+ // <Field>
153
+ // <Textarea />
154
+ // <Field.CharacterCount maxChars={100} />
155
+ // </Field>
156
+ // </ThemeContextProvider>
157
+ // );
158
+ // expect(renderResult.container.firstChild).toMatchSnapshot();
159
+ // });
160
160
 
161
161
  // Interation tests
162
162
 
@@ -0,0 +1,70 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import FileInput from './FileInput';
3
+
4
+ const meta = {
5
+ title: 'Components/WorkInProgress/FileInput',
6
+ component: FileInput,
7
+ parameters: {
8
+ layout: 'centered',
9
+ },
10
+ tags: ['autodocs'],
11
+ } satisfies Meta<typeof FileInput>;
12
+
13
+ export default meta;
14
+ type Story = StoryObj<typeof meta>;
15
+
16
+ export const Default: Story = {
17
+ args: {
18
+ children: 'Upload file or images',
19
+ testId: 'file-input-default',
20
+ },
21
+ };
22
+
23
+ export const WithCustomClass: Story = {
24
+ args: {
25
+ children: 'Custom Styled File Input',
26
+ className: 'custom-class',
27
+ testId: 'file-input-custom',
28
+ },
29
+ };
30
+
31
+ export const MultipleFiles: Story = {
32
+ args: {
33
+ children: 'Upload multiple files',
34
+ testId: 'file-input-multiple',
35
+ multiple: true,
36
+ },
37
+ };
38
+
39
+ export const NoChildren: Story = {
40
+ args: {
41
+ testId: 'file-input-no-children',
42
+ },
43
+ };
44
+
45
+ export const WithDecorator: Story = {
46
+ name: 'FileInput with decorator',
47
+ args: {
48
+ children: 'FileInput with a decorator',
49
+ testId: 'file-input-decorator',
50
+ },
51
+ decorators: [
52
+ (Story) => (
53
+ <div>
54
+ <div
55
+ style={{
56
+ height: '16px',
57
+ backgroundColor: '#0d68cf',
58
+ }}
59
+ />
60
+ <Story />
61
+ <div
62
+ style={{
63
+ height: '16px',
64
+ backgroundColor: '#0d68cf',
65
+ }}
66
+ />
67
+ </div>
68
+ ),
69
+ ],
70
+ };
@@ -0,0 +1,68 @@
1
+ import { css, cx } from '@emotion/css';
2
+ import { useTheme } from '../../theme';
3
+ import { InputHTMLAttributes } from 'react';
4
+ import { Icon } from '..';
5
+ import { useRef } from 'react';
6
+
7
+ export const NAME = 'ucl-uikit-fileinput';
8
+
9
+ export interface FileInputProps extends InputHTMLAttributes<HTMLInputElement> {
10
+ testId?: string;
11
+ labelId?: string;
12
+ }
13
+
14
+ const FileInput = ({
15
+ testId = NAME,
16
+ children,
17
+ labelId = '1',
18
+ ...props
19
+ }: FileInputProps) => {
20
+ const [theme] = useTheme();
21
+ const fileInputRef = useRef<HTMLInputElement>(null);
22
+
23
+ const baseStyle = css`
24
+ font-size: ${theme.font.size.f16};
25
+ font-family: ${theme.font.family.primary};
26
+ color: ${theme.color.link.default};
27
+ `;
28
+
29
+ const hiddenInputContainerStyle = css`
30
+ opacity: 0;
31
+ width: 0;
32
+ height: 0;
33
+ position: absolute;
34
+ `;
35
+
36
+ const labelStyle = css`
37
+ display: inline-flex;
38
+ text-decoration: underline;
39
+ gap: 6px;
40
+ font-weight: 700;
41
+ margin-top: 3px;
42
+ cursor: pointer;
43
+ `;
44
+
45
+ const style = cx(NAME, baseStyle, props.className);
46
+
47
+ return (
48
+ <div className={style}>
49
+ <label
50
+ htmlFor={`file-input-${labelId}`}
51
+ className={labelStyle}
52
+ >
53
+ <Icon.Upload />
54
+ {children}
55
+ </label>
56
+ <input
57
+ ref={fileInputRef}
58
+ type='file'
59
+ data-testid={testId}
60
+ className={hiddenInputContainerStyle}
61
+ id={`file-input-${labelId}`}
62
+ {...props}
63
+ />
64
+ </div>
65
+ );
66
+ };
67
+
68
+ export default FileInput;
@@ -0,0 +1,99 @@
1
+ import { describe, expect, test } from 'vitest';
2
+ import { render, screen } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+ import FileInput from '../';
5
+ import { ThemeContextProvider } from '../../../theme/useTheme';
6
+
7
+ describe('Input', () => {
8
+ // Snapshot tests
9
+
10
+ test('snapshot: no props', () => {
11
+ const renderResult = render(
12
+ <ThemeContextProvider>
13
+ <FileInput>Upload File</FileInput>
14
+ </ThemeContextProvider>
15
+ );
16
+ expect(renderResult.container.firstChild).toMatchSnapshot();
17
+ });
18
+
19
+ test('snapshot: value prop', () => {
20
+ const renderResult = render(
21
+ <ThemeContextProvider>
22
+ <FileInput testId='test123'>Upload File/Image</FileInput>
23
+ </ThemeContextProvider>
24
+ );
25
+ expect(renderResult.container.firstChild).toMatchSnapshot();
26
+ });
27
+
28
+ test('test ID: default', () => {
29
+ render(
30
+ <ThemeContextProvider>
31
+ <FileInput>Upload File/Image</FileInput>
32
+ </ThemeContextProvider>
33
+ );
34
+ const fileInput = screen.getByTestId('ucl-uikit-fileinput');
35
+ expect(fileInput).toBeDefined();
36
+ });
37
+
38
+ test('test ID: default with mutliple attribute', () => {
39
+ render(
40
+ <ThemeContextProvider>
41
+ <FileInput multiple={true}>Upload File/Image</FileInput>
42
+ </ThemeContextProvider>
43
+ );
44
+ const fileInput = screen.getByTestId('ucl-uikit-fileinput');
45
+ expect(fileInput).toBeDefined();
46
+ });
47
+
48
+ test('test ID: custom', () => {
49
+ render(
50
+ <ThemeContextProvider>
51
+ <FileInput testId='custom-test-id'>Upload File/Image</FileInput>
52
+ </ThemeContextProvider>
53
+ );
54
+ const fileInput = screen.getByTestId('custom-test-id');
55
+ expect(fileInput).toBeDefined();
56
+ });
57
+
58
+ test('snapshot: id prop', () => {
59
+ render(
60
+ <ThemeContextProvider>
61
+ <FileInput id='custom-id'>Upload File/Image</FileInput>
62
+ </ThemeContextProvider>
63
+ );
64
+ const fileInput = screen.getByTestId('ucl-uikit-fileinput');
65
+ expect(fileInput.id).toBe('custom-id');
66
+ });
67
+
68
+ test('updates file list on file selection', async () => {
69
+ const user = userEvent.setup();
70
+ render(
71
+ <ThemeContextProvider>
72
+ <FileInput>Upload File</FileInput>
73
+ </ThemeContextProvider>
74
+ );
75
+
76
+ const fileInput = screen.getByTestId(
77
+ 'ucl-uikit-fileinput'
78
+ ) as HTMLInputElement;
79
+ const file = new File(['file content'], 'example.txt', {
80
+ type: 'text/plain',
81
+ });
82
+
83
+ await user.upload(fileInput, file);
84
+
85
+ expect(fileInput.files).toHaveLength(1);
86
+ expect(fileInput.files?.[0].name).toBe('example.txt');
87
+ });
88
+
89
+ test('applies custom className', () => {
90
+ render(
91
+ <ThemeContextProvider>
92
+ <FileInput className='custom-class'>Upload File</FileInput>
93
+ </ThemeContextProvider>
94
+ );
95
+
96
+ const fileInput = screen.getByTestId('ucl-uikit-fileinput');
97
+ expect(fileInput).toHaveClass('custom-class');
98
+ });
99
+ });
@@ -0,0 +1,91 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`Input > snapshot: no props 1`] = `
4
+ <div
5
+ class="ucl-uikit-fileinput css-r56yy"
6
+ >
7
+ <label
8
+ class="css-1lc9iag"
9
+ for="file-input-1"
10
+ >
11
+ <svg
12
+ class="ucl-uikit-icon css-148hpxb"
13
+ data-testid="ucl-uikit-icon"
14
+ fill="none"
15
+ height="24"
16
+ stroke="currentColor"
17
+ stroke-linecap="round"
18
+ stroke-linejoin="round"
19
+ stroke-width="2"
20
+ viewBox="0 0 24 24"
21
+ width="24"
22
+ xmlns="http://www.w3.org/2000/svg"
23
+ >
24
+ <path
25
+ d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"
26
+ />
27
+ <polyline
28
+ points="17 8 12 3 7 8"
29
+ />
30
+ <line
31
+ x1="12"
32
+ x2="12"
33
+ y1="3"
34
+ y2="15"
35
+ />
36
+ </svg>
37
+ Upload File
38
+ </label>
39
+ <input
40
+ class="css-1w0w0g6"
41
+ data-testid="ucl-uikit-fileinput"
42
+ id="file-input-1"
43
+ type="file"
44
+ />
45
+ </div>
46
+ `;
47
+
48
+ exports[`Input > snapshot: value prop 1`] = `
49
+ <div
50
+ class="ucl-uikit-fileinput css-r56yy"
51
+ >
52
+ <label
53
+ class="css-1lc9iag"
54
+ for="file-input-1"
55
+ >
56
+ <svg
57
+ class="ucl-uikit-icon css-148hpxb"
58
+ data-testid="ucl-uikit-icon"
59
+ fill="none"
60
+ height="24"
61
+ stroke="currentColor"
62
+ stroke-linecap="round"
63
+ stroke-linejoin="round"
64
+ stroke-width="2"
65
+ viewBox="0 0 24 24"
66
+ width="24"
67
+ xmlns="http://www.w3.org/2000/svg"
68
+ >
69
+ <path
70
+ d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"
71
+ />
72
+ <polyline
73
+ points="17 8 12 3 7 8"
74
+ />
75
+ <line
76
+ x1="12"
77
+ x2="12"
78
+ y1="3"
79
+ y2="15"
80
+ />
81
+ </svg>
82
+ Upload File/Image
83
+ </label>
84
+ <input
85
+ class="css-1w0w0g6"
86
+ data-testid="test123"
87
+ id="file-input-1"
88
+ type="file"
89
+ />
90
+ </div>
91
+ `;
@@ -0,0 +1,2 @@
1
+ export { default } from './FileInput';
2
+ export type { FileInputProps } from './FileInput';