@hero-design/rn-work-uikit 1.9.5 → 1.10.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 (45) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +219 -63
  3. package/assets/fonts/hero-icons-mobile.ttf +0 -0
  4. package/es/index.js +55337 -0
  5. package/lib/index.js +7173 -21259
  6. package/package.json +22 -22
  7. package/src/components/FormGroup/index.tsx +21 -10
  8. package/src/components/FormGroup/utils.ts +3 -3
  9. package/src/components/TextInput/InputRow.tsx +3 -6
  10. package/src/components/TextInput/index.tsx +4 -4
  11. package/src/components/TextInput/types.ts +4 -8
  12. package/types/index.d.ts +525 -0
  13. package/src/__tests__/index-export.spec.ts +0 -64
  14. package/src/__tests__/index.spec.tsx +0 -14
  15. package/src/components/DatePicker/__tests__/__snapshots__/index.spec.tsx.snap +0 -1649
  16. package/src/components/DatePicker/__tests__/index.spec.tsx +0 -56
  17. package/src/components/FormGroup/__tests__/__snapshots__/index.spec.tsx.snap +0 -908
  18. package/src/components/FormGroup/__tests__/index.spec.tsx +0 -319
  19. package/src/components/FormGroup/__tests__/utils.spec.ts +0 -73
  20. package/src/components/RichTextEditor/__tests__/EditorToolbar.spec.tsx +0 -154
  21. package/src/components/RichTextEditor/__tests__/MentionList.spec.tsx +0 -105
  22. package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +0 -81
  23. package/src/components/RichTextEditor/__tests__/RichTextEditorInput.spec.tsx +0 -174
  24. package/src/components/RichTextEditor/__tests__/__snapshots__/EditorToolbar.spec.tsx.snap +0 -407
  25. package/src/components/RichTextEditor/__tests__/__snapshots__/MentionList.spec.tsx.snap +0 -13
  26. package/src/components/Select/__tests__/__snapshots__/index.spec.tsx.snap +0 -1324
  27. package/src/components/Select/__tests__/index.spec.tsx +0 -43
  28. package/src/components/TextInput/__tests__/ErrorOrHelpText.spec.tsx +0 -20
  29. package/src/components/TextInput/__tests__/FloatingLabel.spec.tsx +0 -190
  30. package/src/components/TextInput/__tests__/InputComponent.spec.tsx +0 -41
  31. package/src/components/TextInput/__tests__/InputRow.spec.tsx +0 -233
  32. package/src/components/TextInput/__tests__/MaxLengthMessage.spec.tsx +0 -17
  33. package/src/components/TextInput/__tests__/PrefixComponent.spec.tsx +0 -14
  34. package/src/components/TextInput/__tests__/StyledTextInput.spec.tsx +0 -114
  35. package/src/components/TextInput/__tests__/SuffixComponent.spec.tsx +0 -20
  36. package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +0 -583
  37. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +0 -5835
  38. package/src/components/TextInput/__tests__/getState.spec.tsx +0 -89
  39. package/src/components/TextInput/__tests__/index.spec.tsx +0 -679
  40. package/src/components/TimePicker/__tests__/index.spec.tsx +0 -34
  41. package/src/theme/__tests__/ThemeProvider.spec.tsx +0 -32
  42. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +0 -2042
  43. package/src/theme/__tests__/index.spec.ts +0 -7
  44. package/src/utils/__tests__/helpers.spec.ts +0 -92
  45. package/stats/1.3.0/rn-work-uikit-stats.html +0 -4842
@@ -1,81 +0,0 @@
1
- import React from 'react';
2
- import RichTextEditor from '../RichTextEditor';
3
- import renderWithTheme from '../../../../testUtils/renderWithTheme';
4
-
5
- const initialValue = [
6
- { type: 'paragraph', children: [{ text: 'Hello world' }] },
7
- ];
8
-
9
- describe('RichTextEditor zIndex', () => {
10
- it('applies correct zIndex logic when groupStyleEnabled is true', () => {
11
- const { getByTestId } = renderWithTheme(
12
- <RichTextEditor
13
- label="Test Editor"
14
- value={initialValue}
15
- onChange={jest.fn()}
16
- name="test-editor"
17
- testID="rich-text-editor"
18
- groupStyleEnabled
19
- />
20
- );
21
-
22
- const container = getByTestId('rich-text-editor');
23
-
24
- // Initially should have zIndex 0 (normal state)
25
- expect(container.props.style.flat()).toEqual(
26
- expect.arrayContaining([
27
- expect.objectContaining({
28
- zIndex: 0,
29
- }),
30
- ])
31
- );
32
- });
33
-
34
- it('applies correct zIndex when has error', () => {
35
- const { getByTestId } = renderWithTheme(
36
- <RichTextEditor
37
- label="Test Editor"
38
- value={initialValue}
39
- onChange={jest.fn()}
40
- name="test-editor"
41
- testID="rich-text-editor"
42
- error="This is an error"
43
- groupStyleEnabled
44
- />
45
- );
46
-
47
- const container = getByTestId('rich-text-editor');
48
-
49
- // Should have zIndex 1 when has error (medium priority)
50
- expect(container.props.style.flat()).toEqual(
51
- expect.arrayContaining([
52
- expect.objectContaining({
53
- zIndex: 1,
54
- }),
55
- ])
56
- );
57
- });
58
-
59
- it('does not apply zIndex when groupStyleEnabled is false', () => {
60
- const { getByTestId } = renderWithTheme(
61
- <RichTextEditor
62
- label="Test Editor"
63
- value={initialValue}
64
- onChange={jest.fn()}
65
- name="test-editor"
66
- testID="rich-text-editor"
67
- groupStyleEnabled={false}
68
- error="This is an error"
69
- />
70
- );
71
-
72
- const container = getByTestId('rich-text-editor');
73
-
74
- // Should not have zIndex applied when groupStyleEnabled is false
75
- const containerStyle = container.props.style.flat();
76
- const hasZIndex = containerStyle.some(
77
- (style: Record<string, unknown>) => style && style.zIndex !== undefined
78
- );
79
- expect(hasZIndex).toBe(false);
80
- });
81
- });
@@ -1,174 +0,0 @@
1
- import React from 'react';
2
- import { fireEvent } from '@testing-library/react-native';
3
- import RichTextEditorInput from '../RichTextEditorInput';
4
- import { emitter } from '../EditorEvent';
5
- import * as Events from '../utils/events';
6
- import renderWithTheme from '../../../../testUtils/renderWithTheme';
7
-
8
- // Mock minimal EditorValue type for test
9
- const initialValue = [
10
- { type: 'paragraph', children: [{ text: 'Hello world' }] },
11
- ];
12
-
13
- describe('RichTextEditorInput', () => {
14
- it('renders a WebView with correct initial html', () => {
15
- const { getByTestId } = renderWithTheme(
16
- <RichTextEditorInput
17
- value={initialValue}
18
- name="test-editor"
19
- autoFocus={false}
20
- placeholder="Type something..."
21
- onChange={jest.fn()}
22
- />
23
- );
24
-
25
- const webview = getByTestId('webview');
26
- expect(webview).toBeTruthy();
27
- expect(webview.props.source.html).toContain(
28
- 'placeholder: "Type something..."'
29
- );
30
- expect(webview.props.source.html).toContain(JSON.stringify(initialValue));
31
- });
32
-
33
- it('handles editor-change event from webview', () => {
34
- const onChange = jest.fn();
35
- const { getByTestId } = renderWithTheme(
36
- <RichTextEditorInput
37
- value={initialValue}
38
- name="test-editor"
39
- autoFocus={false}
40
- placeholder="Type here..."
41
- onChange={onChange}
42
- />
43
- );
44
-
45
- const webview = getByTestId('webview');
46
- const newValue = [{ type: 'paragraph', children: [{ text: 'Changed' }] }];
47
- fireEvent(webview, 'message', {
48
- nativeEvent: {
49
- data: JSON.stringify({
50
- type: '@hero-editor/webview/editor-change',
51
- data: { value: newValue },
52
- }),
53
- },
54
- });
55
-
56
- expect(onChange).toHaveBeenCalledWith(newValue);
57
- });
58
-
59
- it('handles editor-focus and editor-blur events from webview', () => {
60
- const onFocus = jest.fn();
61
- const onBlur = jest.fn();
62
- const { getByTestId } = renderWithTheme(
63
- <RichTextEditorInput
64
- value={initialValue}
65
- name="test-editor"
66
- autoFocus={false}
67
- placeholder="Type here..."
68
- onChange={jest.fn()}
69
- onFocus={onFocus}
70
- onBlur={onBlur}
71
- />
72
- );
73
-
74
- const webview = getByTestId('webview');
75
-
76
- // Spy on emitter
77
- const spy = jest.spyOn(Events, 'emit');
78
-
79
- // Simulate focus
80
- fireEvent(webview, 'message', {
81
- nativeEvent: {
82
- data: JSON.stringify({
83
- type: '@hero-editor/webview/editor-focus',
84
- }),
85
- },
86
- });
87
- expect(spy).toHaveBeenCalledWith(
88
- emitter,
89
- 'test-editor/editor-focus',
90
- undefined
91
- );
92
-
93
- // Simulate blur
94
- fireEvent(webview, 'message', {
95
- nativeEvent: {
96
- data: JSON.stringify({
97
- type: '@hero-editor/webview/editor-blur',
98
- }),
99
- },
100
- });
101
- expect(spy).toHaveBeenCalledWith(
102
- emitter,
103
- 'test-editor/editor-blur',
104
- undefined
105
- );
106
-
107
- spy.mockRestore();
108
- });
109
-
110
- it('handles cursor-change event from webview', () => {
111
- const onCursorChange = jest.fn();
112
- const { getByTestId } = renderWithTheme(
113
- <RichTextEditorInput
114
- value={initialValue}
115
- name="test-editor"
116
- autoFocus={false}
117
- placeholder="Type here..."
118
- onChange={jest.fn()}
119
- onCursorChange={onCursorChange}
120
- />
121
- );
122
-
123
- const webview = getByTestId('webview');
124
- const cursorData = { position: { top: 10 } };
125
- fireEvent(webview, 'message', {
126
- nativeEvent: {
127
- data: JSON.stringify({
128
- type: '@hero-editor/webview/cursor-change',
129
- data: cursorData,
130
- }),
131
- },
132
- });
133
-
134
- expect(onCursorChange).toHaveBeenCalledWith(cursorData);
135
- });
136
-
137
- it('handles request-upsert-link event from webview', () => {
138
- const { getByTestId } = renderWithTheme(
139
- <RichTextEditorInput
140
- value={initialValue}
141
- name="test-editor"
142
- autoFocus={false}
143
- placeholder="Type here..."
144
- onChange={jest.fn()}
145
- />
146
- );
147
-
148
- const webview = getByTestId('webview');
149
- // Spy on emitter
150
- const spy = jest.spyOn(Events, 'emit');
151
-
152
- fireEvent(webview, 'message', {
153
- nativeEvent: {
154
- data: JSON.stringify({
155
- type: '@hero-editor/webview/request-upsert-link',
156
- data: {
157
- text: 'Test',
158
- url: 'https://test.com',
159
- },
160
- }),
161
- },
162
- });
163
- expect(spy).toHaveBeenCalledWith(
164
- emitter,
165
- 'test-editor/request-upsert-link',
166
- {
167
- text: 'Test',
168
- url: 'https://test.com',
169
- }
170
- );
171
-
172
- spy.mockRestore();
173
- });
174
- });
@@ -1,407 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`EditorToolbar when the editor is focused should render toolbar 1`] = `
4
- <View
5
- style={
6
- [
7
- [
8
- {
9
- "alignItems": "center",
10
- "backgroundColor": "#f6f6f7",
11
- "borderTopColor": "#e8e9ea",
12
- "borderTopWidth": undefined,
13
- "flexDirection": "row",
14
- "paddingHorizontal": 7.846153846153847,
15
- },
16
- ],
17
- undefined,
18
- ]
19
- }
20
- testID="toolbar"
21
- >
22
- <TouchableOpacity
23
- onPress={[Function]}
24
- style={
25
- [
26
- [
27
- {
28
- "alignItems": "center",
29
- "backgroundColor": undefined,
30
- "height": 47.07692307692308,
31
- "justifyContent": "center",
32
- "width": 47.07692307692308,
33
- },
34
- ],
35
- undefined,
36
- ]
37
- }
38
- testID="format-bold"
39
- >
40
- <Text
41
- allowFontScaling={false}
42
- selectable={false}
43
- style={
44
- [
45
- {
46
- "color": undefined,
47
- "fontSize": 12,
48
- },
49
- [
50
- [
51
- {
52
- "color": "#001f23",
53
- "fontSize": 19.615384615384613,
54
- },
55
- ],
56
- undefined,
57
- ],
58
- {
59
- "fontFamily": "hero-icons-mobile",
60
- "fontStyle": "normal",
61
- "fontWeight": "normal",
62
- },
63
- {},
64
- ]
65
- }
66
- themeIntent="text"
67
- themeSize="small"
68
- >
69
-
70
- </Text>
71
- </TouchableOpacity>
72
- <TouchableOpacity
73
- onPress={[Function]}
74
- style={
75
- [
76
- [
77
- {
78
- "alignItems": "center",
79
- "backgroundColor": undefined,
80
- "height": 47.07692307692308,
81
- "justifyContent": "center",
82
- "width": 47.07692307692308,
83
- },
84
- ],
85
- undefined,
86
- ]
87
- }
88
- testID="format-italic"
89
- >
90
- <Text
91
- allowFontScaling={false}
92
- selectable={false}
93
- style={
94
- [
95
- {
96
- "color": undefined,
97
- "fontSize": 12,
98
- },
99
- [
100
- [
101
- {
102
- "color": "#001f23",
103
- "fontSize": 19.615384615384613,
104
- },
105
- ],
106
- undefined,
107
- ],
108
- {
109
- "fontFamily": "hero-icons-mobile",
110
- "fontStyle": "normal",
111
- "fontWeight": "normal",
112
- },
113
- {},
114
- ]
115
- }
116
- themeIntent="text"
117
- themeSize="small"
118
- >
119
-
120
- </Text>
121
- </TouchableOpacity>
122
- <TouchableOpacity
123
- onPress={[Function]}
124
- style={
125
- [
126
- [
127
- {
128
- "alignItems": "center",
129
- "backgroundColor": undefined,
130
- "height": 47.07692307692308,
131
- "justifyContent": "center",
132
- "width": 47.07692307692308,
133
- },
134
- ],
135
- undefined,
136
- ]
137
- }
138
- testID="format-underlined"
139
- >
140
- <Text
141
- allowFontScaling={false}
142
- selectable={false}
143
- style={
144
- [
145
- {
146
- "color": undefined,
147
- "fontSize": 12,
148
- },
149
- [
150
- [
151
- {
152
- "color": "#001f23",
153
- "fontSize": 19.615384615384613,
154
- },
155
- ],
156
- undefined,
157
- ],
158
- {
159
- "fontFamily": "hero-icons-mobile",
160
- "fontStyle": "normal",
161
- "fontWeight": "normal",
162
- },
163
- {},
164
- ]
165
- }
166
- themeIntent="text"
167
- themeSize="small"
168
- >
169
-
170
- </Text>
171
- </TouchableOpacity>
172
- <View
173
- style={
174
- [
175
- [
176
- {
177
- "alignItems": "center",
178
- "backgroundColor": "#e8e9ea",
179
- "flexDirection": "row",
180
- "height": 15.692307692307693,
181
- "marginHorizontal": 7.846153846153847,
182
- "width": 1.9615384615384617,
183
- },
184
- ],
185
- undefined,
186
- ]
187
- }
188
- />
189
- <TouchableOpacity
190
- onPress={[Function]}
191
- style={
192
- [
193
- [
194
- {
195
- "alignItems": "center",
196
- "backgroundColor": undefined,
197
- "height": 47.07692307692308,
198
- "justifyContent": "center",
199
- "width": 47.07692307692308,
200
- },
201
- ],
202
- undefined,
203
- ]
204
- }
205
- testID="format-list-bulleted"
206
- >
207
- <Text
208
- allowFontScaling={false}
209
- selectable={false}
210
- style={
211
- [
212
- {
213
- "color": undefined,
214
- "fontSize": 12,
215
- },
216
- [
217
- [
218
- {
219
- "color": "#001f23",
220
- "fontSize": 19.615384615384613,
221
- },
222
- ],
223
- undefined,
224
- ],
225
- {
226
- "fontFamily": "hero-icons-mobile",
227
- "fontStyle": "normal",
228
- "fontWeight": "normal",
229
- },
230
- {},
231
- ]
232
- }
233
- themeIntent="text"
234
- themeSize="small"
235
- >
236
-
237
- </Text>
238
- </TouchableOpacity>
239
- <TouchableOpacity
240
- onPress={[Function]}
241
- style={
242
- [
243
- [
244
- {
245
- "alignItems": "center",
246
- "backgroundColor": undefined,
247
- "height": 47.07692307692308,
248
- "justifyContent": "center",
249
- "width": 47.07692307692308,
250
- },
251
- ],
252
- undefined,
253
- ]
254
- }
255
- testID="format-list-numbered"
256
- >
257
- <Text
258
- allowFontScaling={false}
259
- selectable={false}
260
- style={
261
- [
262
- {
263
- "color": undefined,
264
- "fontSize": 12,
265
- },
266
- [
267
- [
268
- {
269
- "color": "#001f23",
270
- "fontSize": 19.615384615384613,
271
- },
272
- ],
273
- undefined,
274
- ],
275
- {
276
- "fontFamily": "hero-icons-mobile",
277
- "fontStyle": "normal",
278
- "fontWeight": "normal",
279
- },
280
- {},
281
- ]
282
- }
283
- themeIntent="text"
284
- themeSize="small"
285
- >
286
-
287
- </Text>
288
- </TouchableOpacity>
289
- <View
290
- style={
291
- [
292
- [
293
- {
294
- "alignItems": "center",
295
- "backgroundColor": "#e8e9ea",
296
- "flexDirection": "row",
297
- "height": 15.692307692307693,
298
- "marginHorizontal": 7.846153846153847,
299
- "width": 1.9615384615384617,
300
- },
301
- ],
302
- undefined,
303
- ]
304
- }
305
- />
306
- <TouchableOpacity
307
- onPress={[Function]}
308
- style={
309
- [
310
- [
311
- {
312
- "alignItems": "center",
313
- "backgroundColor": undefined,
314
- "height": 47.07692307692308,
315
- "justifyContent": "center",
316
- "width": 47.07692307692308,
317
- },
318
- ],
319
- undefined,
320
- ]
321
- }
322
- testID="format-heading1"
323
- >
324
- <Text
325
- allowFontScaling={false}
326
- selectable={false}
327
- style={
328
- [
329
- {
330
- "color": undefined,
331
- "fontSize": 12,
332
- },
333
- [
334
- [
335
- {
336
- "color": "#001f23",
337
- "fontSize": 19.615384615384613,
338
- },
339
- ],
340
- undefined,
341
- ],
342
- {
343
- "fontFamily": "hero-icons-mobile",
344
- "fontStyle": "normal",
345
- "fontWeight": "normal",
346
- },
347
- {},
348
- ]
349
- }
350
- themeIntent="text"
351
- themeSize="small"
352
- >
353
-
354
- </Text>
355
- </TouchableOpacity>
356
- <TouchableOpacity
357
- onPress={[Function]}
358
- style={
359
- [
360
- [
361
- {
362
- "alignItems": "center",
363
- "backgroundColor": undefined,
364
- "height": 47.07692307692308,
365
- "justifyContent": "center",
366
- "width": 47.07692307692308,
367
- },
368
- ],
369
- undefined,
370
- ]
371
- }
372
- testID="format-heading2"
373
- >
374
- <Text
375
- allowFontScaling={false}
376
- selectable={false}
377
- style={
378
- [
379
- {
380
- "color": undefined,
381
- "fontSize": 12,
382
- },
383
- [
384
- [
385
- {
386
- "color": "#001f23",
387
- "fontSize": 19.615384615384613,
388
- },
389
- ],
390
- undefined,
391
- ],
392
- {
393
- "fontFamily": "hero-icons-mobile",
394
- "fontStyle": "normal",
395
- "fontWeight": "normal",
396
- },
397
- {},
398
- ]
399
- }
400
- themeIntent="text"
401
- themeSize="small"
402
- >
403
-
404
- </Text>
405
- </TouchableOpacity>
406
- </View>
407
- `;
@@ -1,13 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`MentionList when search string is not empty should render mention list showing filtered results 1`] = `
4
- <View>
5
- <View>
6
- <Text
7
- onPress={[Function]}
8
- >
9
- Hieu Pham
10
- </Text>
11
- </View>
12
- </View>
13
- `;