@hero-design/rn-work-uikit 1.9.4 → 1.9.6
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/CHANGELOG.md +18 -0
- package/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/es/index.js +69810 -0
- package/lib/index.js +809 -440
- package/package.json +5 -5
- package/src/components/RichTextEditor/MentionList.tsx +2 -1
- package/testUtils/renderWithTheme.tsx +2 -2
- package/types/index.d.ts +525 -0
- package/src/__tests__/index-export.spec.ts +0 -64
- package/src/__tests__/index.spec.tsx +0 -14
- package/src/components/DatePicker/__tests__/__snapshots__/index.spec.tsx.snap +0 -1649
- package/src/components/DatePicker/__tests__/index.spec.tsx +0 -56
- package/src/components/FormGroup/__tests__/__snapshots__/index.spec.tsx.snap +0 -908
- package/src/components/FormGroup/__tests__/index.spec.tsx +0 -319
- package/src/components/FormGroup/__tests__/utils.spec.ts +0 -73
- package/src/components/RichTextEditor/__tests__/EditorToolbar.spec.tsx +0 -154
- package/src/components/RichTextEditor/__tests__/MentionList.spec.tsx +0 -105
- package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +0 -81
- package/src/components/RichTextEditor/__tests__/RichTextEditorInput.spec.tsx +0 -174
- package/src/components/RichTextEditor/__tests__/__snapshots__/EditorToolbar.spec.tsx.snap +0 -407
- package/src/components/RichTextEditor/__tests__/__snapshots__/MentionList.spec.tsx.snap +0 -13
- package/src/components/Select/__tests__/__snapshots__/index.spec.tsx.snap +0 -1324
- package/src/components/Select/__tests__/index.spec.tsx +0 -43
- package/src/components/TextInput/__tests__/ErrorOrHelpText.spec.tsx +0 -20
- package/src/components/TextInput/__tests__/FloatingLabel.spec.tsx +0 -193
- package/src/components/TextInput/__tests__/InputComponent.spec.tsx +0 -41
- package/src/components/TextInput/__tests__/InputRow.spec.tsx +0 -233
- package/src/components/TextInput/__tests__/MaxLengthMessage.spec.tsx +0 -17
- package/src/components/TextInput/__tests__/PrefixComponent.spec.tsx +0 -14
- package/src/components/TextInput/__tests__/StyledTextInput.spec.tsx +0 -114
- package/src/components/TextInput/__tests__/SuffixComponent.spec.tsx +0 -20
- package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +0 -583
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +0 -5835
- package/src/components/TextInput/__tests__/getState.spec.tsx +0 -89
- package/src/components/TextInput/__tests__/index.spec.tsx +0 -679
- package/src/components/TimePicker/__tests__/index.spec.tsx +0 -34
- package/src/theme/__tests__/ThemeProvider.spec.tsx +0 -32
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +0 -2042
- package/src/theme/__tests__/index.spec.ts +0 -7
- package/src/utils/__tests__/helpers.spec.ts +0 -92
- package/stats/1.3.0/rn-work-uikit-stats.html +0 -4842
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn-work-uikit",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"type-check": "tsc --noEmit",
|
|
12
12
|
"test": "jest --runInBand",
|
|
13
13
|
"test:watch": "jest --runInBand --watch",
|
|
14
|
-
"test:ci": "jest --c=jest-ci.config.js --i --logHeapUsage --coverage
|
|
14
|
+
"test:ci": "jest --c=jest-ci.config.js --i --logHeapUsage --coverage",
|
|
15
15
|
"build:js": "rollup -c",
|
|
16
16
|
"build:types": "rollup -c rollup.config.mjs --configPlugin dts",
|
|
17
17
|
"build": "yarn build:js && yarn build:types",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@emotion/native": "^11.9.3",
|
|
24
24
|
"@emotion/react": "^11.9.3",
|
|
25
|
-
"@hero-design/rn": "^8.
|
|
25
|
+
"@hero-design/rn": "^8.115.1",
|
|
26
26
|
"hero-editor": "^1.17.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@rollup/plugin-replace": "^6.0.1",
|
|
67
67
|
"@rollup/plugin-typescript": "^12.1.1",
|
|
68
68
|
"@testing-library/jest-native": "^5.4.2",
|
|
69
|
-
"@testing-library/react-native": "^
|
|
69
|
+
"@testing-library/react-native": "^13.0.0",
|
|
70
70
|
"@types/jest": "^29.5.3",
|
|
71
71
|
"@types/react": "^18.2.0",
|
|
72
72
|
"@types/react-native-vector-icons": "^6.4.10",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"react-native-svg": "15.8.0",
|
|
92
92
|
"react-native-vector-icons": "^9.1.0",
|
|
93
93
|
"react-native-webview": "^13.16.0",
|
|
94
|
-
"react-test-renderer": "18.
|
|
94
|
+
"react-test-renderer": "18.3.1",
|
|
95
95
|
"rollup": "^4.24.3",
|
|
96
96
|
"rollup-plugin-copy": "^3.5.0",
|
|
97
97
|
"rollup-plugin-delete": "^3.0.1",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
1
2
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
3
|
import { View } from 'react-native';
|
|
3
4
|
import { useTheme } from '../../theme';
|
|
@@ -26,7 +27,7 @@ export interface MentionListProps<TMetaData = unknown> {
|
|
|
26
27
|
name: string,
|
|
27
28
|
options?: OnSelectOptionsType<TMetaData>
|
|
28
29
|
) => void
|
|
29
|
-
) =>
|
|
30
|
+
) => ReactElement;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
const MentionList = <TMetaData,>({
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
2
|
import { render } from '@testing-library/react-native'; // eslint-disable-line import/no-extraneous-dependencies
|
|
3
3
|
import type { RenderOptions } from '@testing-library/react-native';
|
|
4
4
|
import { getTheme, ThemeProvider } from '../src';
|
|
5
5
|
|
|
6
6
|
const theme = getTheme();
|
|
7
7
|
|
|
8
|
-
const renderWithTheme = (ui:
|
|
8
|
+
const renderWithTheme = (ui: ReactElement, options?: RenderOptions) => {
|
|
9
9
|
return render(<ThemeProvider theme={theme}>{ui}</ThemeProvider>, options);
|
|
10
10
|
};
|
|
11
11
|
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
import React$1, { ReactNode, Ref, ReactElement, PropsWithChildren } from 'react';
|
|
2
|
+
import { TextInput as TextInput$1, TextInputProps as TextInputProps$1, StyleProp, ViewStyle, TextStyle, NativeSyntheticEvent, TextInputFocusEventData, ViewProps } from 'react-native';
|
|
3
|
+
import { IconName, SelectOptionType, SingleSelectProps, MultiSelectProps, DatePickerProps, TimePickerProps, Theme as Theme$1, Scale, SystemPalette } from '@hero-design/rn';
|
|
4
|
+
export * from '@hero-design/rn';
|
|
5
|
+
|
|
6
|
+
type TextInputHandles = Pick<TextInput$1, 'focus' | 'clear' | 'blur' | 'isFocused' | 'setNativeProps'>;
|
|
7
|
+
type TextInputVariant = 'text' | 'textarea';
|
|
8
|
+
type NativeTextInputProps = Omit<TextInputProps$1, 'onFocus' | 'onBlur'> & {
|
|
9
|
+
onFocus?: (event?: NativeSyntheticEvent<TextInputFocusEventData>) => void | undefined;
|
|
10
|
+
onBlur?: (event?: NativeSyntheticEvent<TextInputFocusEventData>) => void | undefined;
|
|
11
|
+
};
|
|
12
|
+
interface TextInputRef {
|
|
13
|
+
focus: () => void;
|
|
14
|
+
blur: () => void;
|
|
15
|
+
clear: () => void;
|
|
16
|
+
isFocused: () => boolean;
|
|
17
|
+
setNativeProps?: (props: TextInputProps$1) => void;
|
|
18
|
+
}
|
|
19
|
+
type TextInputProps = NativeTextInputProps & {
|
|
20
|
+
/**
|
|
21
|
+
* Field label.
|
|
22
|
+
*/
|
|
23
|
+
label?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Name of Icon or ReactElement to render on the left side of the input, before the user's cursor.
|
|
26
|
+
*/
|
|
27
|
+
prefix?: IconName | React.ReactElement;
|
|
28
|
+
/**
|
|
29
|
+
* Name of Icon or ReactElement to render on the right side of the input.
|
|
30
|
+
*/
|
|
31
|
+
suffix?: IconName | React.ReactElement;
|
|
32
|
+
/**
|
|
33
|
+
* Additional wrapper style.
|
|
34
|
+
*/
|
|
35
|
+
style?: StyleProp<ViewStyle>;
|
|
36
|
+
/**
|
|
37
|
+
* Input text style.
|
|
38
|
+
*/
|
|
39
|
+
textStyle?: StyleProp<TextStyle>;
|
|
40
|
+
/**
|
|
41
|
+
* Testing id of the component.
|
|
42
|
+
*/
|
|
43
|
+
testID?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Accessibility label for the input (Android).
|
|
46
|
+
*/
|
|
47
|
+
accessibilityLabelledBy?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Error message to display.
|
|
50
|
+
*/
|
|
51
|
+
error?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Whether the input is required. When false, "(Optional)" will be appended to the label.
|
|
54
|
+
*/
|
|
55
|
+
required?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Placeholder text to display.
|
|
58
|
+
* */
|
|
59
|
+
placeholder?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Whether the input is editable.
|
|
62
|
+
* */
|
|
63
|
+
editable?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the input is disabled.
|
|
66
|
+
*/
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Whether the input is loading.
|
|
70
|
+
*/
|
|
71
|
+
loading?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* The max length of the input.
|
|
74
|
+
* If the max length is set, the input will display the current length and the max length.
|
|
75
|
+
* */
|
|
76
|
+
maxLength?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Whether to hide the character count.
|
|
79
|
+
* */
|
|
80
|
+
hideCharacterCount?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* The helper text to display.
|
|
83
|
+
*/
|
|
84
|
+
helpText?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Customise input value renderer
|
|
87
|
+
*/
|
|
88
|
+
renderInputValue?: (inputProps: NativeTextInputProps, ref?: React.ForwardedRef<TextInputRef>) => React.ReactNode;
|
|
89
|
+
/**
|
|
90
|
+
* Component ref.
|
|
91
|
+
*/
|
|
92
|
+
ref?: React.Ref<TextInputHandles>;
|
|
93
|
+
/**
|
|
94
|
+
* Component variant.
|
|
95
|
+
*/
|
|
96
|
+
variant?: TextInputVariant;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
declare const TextInput: React$1.ForwardRefExoticComponent<Omit<TextInputProps, "ref"> & React$1.RefAttributes<TextInputHandles>>;
|
|
100
|
+
|
|
101
|
+
declare const _default$2: (<V, T extends SelectOptionType<V> = SelectOptionType<V>>(props: SingleSelectProps<V, T>) => React$1.JSX.Element) & {
|
|
102
|
+
Multi: <V, T extends SelectOptionType<V> = SelectOptionType<V>>(props: MultiSelectProps<V, T>) => React$1.JSX.Element;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
interface DatePickerDialogProps {
|
|
106
|
+
/**
|
|
107
|
+
* The value of the date picker.
|
|
108
|
+
*/
|
|
109
|
+
value?: Date;
|
|
110
|
+
/**
|
|
111
|
+
* The minimum date of the date picker.
|
|
112
|
+
*/
|
|
113
|
+
minDate?: Date;
|
|
114
|
+
/**
|
|
115
|
+
* The maximum date of the date picker.
|
|
116
|
+
*/
|
|
117
|
+
maxDate?: Date;
|
|
118
|
+
/**
|
|
119
|
+
* The function to call when the date is changed.
|
|
120
|
+
*/
|
|
121
|
+
onChange: (date: Date) => void;
|
|
122
|
+
/**
|
|
123
|
+
* The test ID of the date picker.
|
|
124
|
+
*/
|
|
125
|
+
testID?: string;
|
|
126
|
+
/**
|
|
127
|
+
* Whether the dialog is open
|
|
128
|
+
*/
|
|
129
|
+
open: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* The function to call when the dialog is closed.
|
|
132
|
+
*/
|
|
133
|
+
onClose: () => void;
|
|
134
|
+
/**
|
|
135
|
+
* The variant of the date picker.
|
|
136
|
+
*/
|
|
137
|
+
variant?: 'default' | 'month-year';
|
|
138
|
+
/**
|
|
139
|
+
* [iOS only] The label of the DatePicker bottom sheet.
|
|
140
|
+
*/
|
|
141
|
+
label: string;
|
|
142
|
+
/**
|
|
143
|
+
* [iOS only] The confirm label of the date picker bottom sheet.
|
|
144
|
+
*/
|
|
145
|
+
confirmLabel: string;
|
|
146
|
+
/**
|
|
147
|
+
* [iOS only] The supported orientations of the date picker.
|
|
148
|
+
*/
|
|
149
|
+
supportedOrientations?: ('portrait' | 'landscape')[];
|
|
150
|
+
/**
|
|
151
|
+
* [iOS only] The locale of the date picker.
|
|
152
|
+
*/
|
|
153
|
+
locale?: string;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
declare const _default$1: ((props: DatePickerProps) => React$1.JSX.Element) & {
|
|
157
|
+
Dialog: ({ ...props }: DatePickerDialogProps) => React$1.JSX.Element;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
declare const TimePicker: (props: TimePickerProps) => React$1.JSX.Element;
|
|
161
|
+
|
|
162
|
+
interface FormGroupProps extends ViewProps {
|
|
163
|
+
/**
|
|
164
|
+
* The children of the FormGroup. In order for the group styling to work,
|
|
165
|
+
* they must be either HD form components (TextInput, Select, Pickers,...) or enhanced HD input components
|
|
166
|
+
* that supports the corresponding interface.
|
|
167
|
+
*
|
|
168
|
+
* Example:
|
|
169
|
+
* const EnhancedTextInput = (props: TextInputProps) => {
|
|
170
|
+
* return <TextInput {...props} />;
|
|
171
|
+
* };
|
|
172
|
+
*
|
|
173
|
+
* <FormGroup>
|
|
174
|
+
* <Select ... />
|
|
175
|
+
* <EnhancedTextInput ... />
|
|
176
|
+
* </FormGroup>
|
|
177
|
+
*/
|
|
178
|
+
children: ReactNode;
|
|
179
|
+
/**
|
|
180
|
+
* The style of the FormGroup.
|
|
181
|
+
*/
|
|
182
|
+
style?: StyleProp<ViewStyle>;
|
|
183
|
+
/**
|
|
184
|
+
* The testID of the FormGroup.
|
|
185
|
+
*/
|
|
186
|
+
testID?: string;
|
|
187
|
+
}
|
|
188
|
+
declare const FormGroup: ({ children, style, testID, ...props }: FormGroupProps) => React$1.JSX.Element;
|
|
189
|
+
|
|
190
|
+
type ToolbarButtonName = 'bold' | 'italic' | 'underline' | 'bulletedList' | 'numberedList' | 'headingOne' | 'headingTwo' | '|';
|
|
191
|
+
type TextUnit = 'character' | 'word' | 'line' | 'block';
|
|
192
|
+
interface RichTextEditorRef$1 {
|
|
193
|
+
requestBlur: VoidFunction;
|
|
194
|
+
insertNodes: (nodes: Record<string, unknown>[]) => void;
|
|
195
|
+
deleteBackward: (unit?: TextUnit) => void;
|
|
196
|
+
setReadOnly: (readOnly: boolean) => void;
|
|
197
|
+
}
|
|
198
|
+
type EditorValue = {
|
|
199
|
+
type: string;
|
|
200
|
+
children: unknown;
|
|
201
|
+
}[];
|
|
202
|
+
interface RichTextEditorProps {
|
|
203
|
+
/**
|
|
204
|
+
* If true, the editor will be focused when the user enters the screen
|
|
205
|
+
*/
|
|
206
|
+
autoFocus?: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Error message
|
|
209
|
+
*/
|
|
210
|
+
error?: string;
|
|
211
|
+
/**
|
|
212
|
+
* Field value
|
|
213
|
+
*/
|
|
214
|
+
value?: EditorValue;
|
|
215
|
+
/**
|
|
216
|
+
* Unique name used to communicate with webview
|
|
217
|
+
*/
|
|
218
|
+
name: string;
|
|
219
|
+
/**
|
|
220
|
+
* Callback function called when the field value changed
|
|
221
|
+
*/
|
|
222
|
+
onChange: (data: EditorValue) => void;
|
|
223
|
+
/**
|
|
224
|
+
* Callback function called when the cursor position changed
|
|
225
|
+
*/
|
|
226
|
+
onCursorChange?: (params: {
|
|
227
|
+
position: {
|
|
228
|
+
top: number;
|
|
229
|
+
};
|
|
230
|
+
}) => void;
|
|
231
|
+
/**
|
|
232
|
+
* Field placeholder
|
|
233
|
+
*/
|
|
234
|
+
placeholder?: string;
|
|
235
|
+
/**
|
|
236
|
+
* Additional styles
|
|
237
|
+
*/
|
|
238
|
+
style?: StyleProp<ViewStyle>;
|
|
239
|
+
/**
|
|
240
|
+
* Field label
|
|
241
|
+
*/
|
|
242
|
+
label: string;
|
|
243
|
+
/**
|
|
244
|
+
* Field helper text
|
|
245
|
+
*/
|
|
246
|
+
helpText?: string;
|
|
247
|
+
/**
|
|
248
|
+
* Whether the input is required, if true, an asterisk will be appended to the label.
|
|
249
|
+
* */
|
|
250
|
+
required?: boolean;
|
|
251
|
+
/**
|
|
252
|
+
* Testing ID of the component
|
|
253
|
+
*/
|
|
254
|
+
testID?: string;
|
|
255
|
+
/**
|
|
256
|
+
* Imperative ref to expose the component method
|
|
257
|
+
*/
|
|
258
|
+
forwardedRef?: Ref<RichTextEditorRef$1>;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
interface OnSelectOptionsType<TMetaData> {
|
|
262
|
+
highlighted: boolean;
|
|
263
|
+
meta?: TMetaData;
|
|
264
|
+
}
|
|
265
|
+
interface MentionListProps<TMetaData = unknown> {
|
|
266
|
+
/**
|
|
267
|
+
* Unique name used to communicate with webview, should be the same with the RichTextEditor component it used with
|
|
268
|
+
*/
|
|
269
|
+
name: string;
|
|
270
|
+
/**
|
|
271
|
+
* Function used to render mention options
|
|
272
|
+
*/
|
|
273
|
+
render: (searchText: string, onSelect: (id: string, name: string, options?: OnSelectOptionsType<TMetaData>) => void) => ReactElement;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
interface EditorToolbarProps {
|
|
277
|
+
/**
|
|
278
|
+
* List of buttons to display in toolbar
|
|
279
|
+
*/
|
|
280
|
+
buttons?: ToolbarButtonName[];
|
|
281
|
+
/**
|
|
282
|
+
* Unique name used to communicate with webview, should be the same with the RichTextEditor component it used with
|
|
283
|
+
*/
|
|
284
|
+
name: string;
|
|
285
|
+
/**
|
|
286
|
+
* Testing ID of the component
|
|
287
|
+
*/
|
|
288
|
+
testID?: string;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
interface RichTextEditorRef {
|
|
292
|
+
requestBlur: VoidFunction;
|
|
293
|
+
insertNodes: (nodes: Record<string, unknown>[]) => void;
|
|
294
|
+
deleteBackward: (unit?: TextUnit) => void;
|
|
295
|
+
setReadOnly: (readOnly: boolean) => void;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
declare enum ToolbarEvents {
|
|
299
|
+
Bold = "bold",
|
|
300
|
+
Italic = "italic",
|
|
301
|
+
Underline = "underline",
|
|
302
|
+
BulletedList = "bulleted-list",
|
|
303
|
+
NumberedList = "numbered-list",
|
|
304
|
+
HeadingOne = "heading-one",
|
|
305
|
+
HeadingTwo = "heading-two",
|
|
306
|
+
AddLink = "add-link",
|
|
307
|
+
ApplyLink = "link"
|
|
308
|
+
}
|
|
309
|
+
declare enum EditorEvents {
|
|
310
|
+
EditorFocus = "editor-focus",
|
|
311
|
+
EditorBlur = "editor-blur",
|
|
312
|
+
EditorChange = "editor-change",
|
|
313
|
+
UpsertLink = "request-upsert-link"
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
declare const _default: React$1.ForwardRefExoticComponent<Omit<RichTextEditorProps, "forwardedRef"> & React$1.RefAttributes<RichTextEditorRef>> & {
|
|
317
|
+
Toolbar: ({ name, buttons, testID, }: EditorToolbarProps) => React$1.JSX.Element | null;
|
|
318
|
+
MentionList: <TMetaData>({ name: eventPrefix, render, }: MentionListProps<TMetaData>) => React$1.JSX.Element | null;
|
|
319
|
+
EditorEvents: typeof EditorEvents;
|
|
320
|
+
ToolbarEvents: typeof ToolbarEvents;
|
|
321
|
+
useRichTextEditorEvents: (editorName: string) => {
|
|
322
|
+
emitEvent: <TEventName extends ToolbarEvents>({ type, data, }: {
|
|
323
|
+
type: TEventName;
|
|
324
|
+
data: TEventName extends keyof {
|
|
325
|
+
"request-upsert-link": {
|
|
326
|
+
text: string;
|
|
327
|
+
url: string;
|
|
328
|
+
};
|
|
329
|
+
"editor-change": {
|
|
330
|
+
value: string;
|
|
331
|
+
toolbarState: Record<string, boolean>;
|
|
332
|
+
};
|
|
333
|
+
link: {
|
|
334
|
+
text: string;
|
|
335
|
+
url: string;
|
|
336
|
+
};
|
|
337
|
+
} ? {
|
|
338
|
+
"request-upsert-link": {
|
|
339
|
+
text: string;
|
|
340
|
+
url: string;
|
|
341
|
+
};
|
|
342
|
+
"editor-change": {
|
|
343
|
+
value: string;
|
|
344
|
+
toolbarState: Record<string, boolean>;
|
|
345
|
+
};
|
|
346
|
+
link: {
|
|
347
|
+
text: string;
|
|
348
|
+
url: string;
|
|
349
|
+
};
|
|
350
|
+
}[TEventName] : unknown;
|
|
351
|
+
}) => void;
|
|
352
|
+
subscribeToEvents: <TEventName extends EditorEvents | ToolbarEvents>(eventName: TEventName, onEvent: (data: TEventName extends keyof {
|
|
353
|
+
"request-upsert-link": {
|
|
354
|
+
text: string;
|
|
355
|
+
url: string;
|
|
356
|
+
};
|
|
357
|
+
"editor-change": {
|
|
358
|
+
value: string;
|
|
359
|
+
toolbarState: Record<string, boolean>;
|
|
360
|
+
};
|
|
361
|
+
link: {
|
|
362
|
+
text: string;
|
|
363
|
+
url: string;
|
|
364
|
+
};
|
|
365
|
+
} ? {
|
|
366
|
+
"request-upsert-link": {
|
|
367
|
+
text: string;
|
|
368
|
+
url: string;
|
|
369
|
+
};
|
|
370
|
+
"editor-change": {
|
|
371
|
+
value: string;
|
|
372
|
+
toolbarState: Record<string, boolean>;
|
|
373
|
+
};
|
|
374
|
+
link: {
|
|
375
|
+
text: string;
|
|
376
|
+
url: string;
|
|
377
|
+
};
|
|
378
|
+
}[TEventName] : void) => void) => () => void;
|
|
379
|
+
};
|
|
380
|
+
Base: React$1.ForwardRefExoticComponent<{
|
|
381
|
+
value: EditorValue;
|
|
382
|
+
name: string;
|
|
383
|
+
autoFocus: boolean;
|
|
384
|
+
placeholder: string;
|
|
385
|
+
onChange: (data: EditorValue) => void;
|
|
386
|
+
onCursorChange?: (params: {
|
|
387
|
+
position: {
|
|
388
|
+
top: number;
|
|
389
|
+
};
|
|
390
|
+
}) => void;
|
|
391
|
+
forwardedRef?: React$1.Ref<RichTextEditorRef$1>;
|
|
392
|
+
onFocus?: () => void;
|
|
393
|
+
onBlur?: () => void;
|
|
394
|
+
} & React$1.RefAttributes<TextInputRef>>;
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
declare const getTextInputTheme: (theme: Theme$1) => {
|
|
398
|
+
colors: {
|
|
399
|
+
borders: {
|
|
400
|
+
default: string;
|
|
401
|
+
error: string;
|
|
402
|
+
disabled: string;
|
|
403
|
+
readonly: string;
|
|
404
|
+
filled: string;
|
|
405
|
+
focused: string;
|
|
406
|
+
};
|
|
407
|
+
labels: {
|
|
408
|
+
default: string;
|
|
409
|
+
error: string;
|
|
410
|
+
disabled: string;
|
|
411
|
+
readonly: string;
|
|
412
|
+
filled: string;
|
|
413
|
+
focused: string;
|
|
414
|
+
};
|
|
415
|
+
maxLengthLabels: {
|
|
416
|
+
default: string;
|
|
417
|
+
error: string;
|
|
418
|
+
disabled: string;
|
|
419
|
+
readonly: string;
|
|
420
|
+
filled: string;
|
|
421
|
+
focused: string;
|
|
422
|
+
};
|
|
423
|
+
labelBackground: string;
|
|
424
|
+
containerBackground: string;
|
|
425
|
+
asterisks: {
|
|
426
|
+
default: string;
|
|
427
|
+
error: string;
|
|
428
|
+
disabled: string;
|
|
429
|
+
readonly: string;
|
|
430
|
+
filled: string;
|
|
431
|
+
};
|
|
432
|
+
error: string;
|
|
433
|
+
text: string;
|
|
434
|
+
labelsInsideTextInput: {
|
|
435
|
+
default: string;
|
|
436
|
+
error: string;
|
|
437
|
+
disabled: string;
|
|
438
|
+
readonly: string;
|
|
439
|
+
filled: string;
|
|
440
|
+
};
|
|
441
|
+
placeholder: {
|
|
442
|
+
default: string;
|
|
443
|
+
error: string;
|
|
444
|
+
disabled: string;
|
|
445
|
+
readonly: string;
|
|
446
|
+
filled: string;
|
|
447
|
+
};
|
|
448
|
+
};
|
|
449
|
+
space: {
|
|
450
|
+
inputWrapperMarginVertical: number;
|
|
451
|
+
prefixAndInputContainerGap: number;
|
|
452
|
+
containerPadding: number;
|
|
453
|
+
labelLeft: number;
|
|
454
|
+
labelTop: number;
|
|
455
|
+
labelPaddingBottom: number;
|
|
456
|
+
labelHorizontalPadding: number;
|
|
457
|
+
inputHorizontalMargin: number;
|
|
458
|
+
errorContainerMarginRight: number;
|
|
459
|
+
errorAndHelpTextContainerMarginTop: number;
|
|
460
|
+
errorMarginLeft: number;
|
|
461
|
+
errorAndHelpTextContainerHorizontalPadding: number;
|
|
462
|
+
containerMarginTop: number;
|
|
463
|
+
labelInsideTextInputMarginTop: number;
|
|
464
|
+
errorAndHelpTextContainerPaddingTop: number;
|
|
465
|
+
};
|
|
466
|
+
fonts: {
|
|
467
|
+
text: string;
|
|
468
|
+
};
|
|
469
|
+
fontSizes: {
|
|
470
|
+
text: number;
|
|
471
|
+
labelInsideTextInput: number;
|
|
472
|
+
error: number;
|
|
473
|
+
maxLength: number;
|
|
474
|
+
asteriskLabel: number;
|
|
475
|
+
topLabel: number;
|
|
476
|
+
};
|
|
477
|
+
borderWidths: {
|
|
478
|
+
container: {
|
|
479
|
+
normal: number;
|
|
480
|
+
focused: number;
|
|
481
|
+
};
|
|
482
|
+
};
|
|
483
|
+
radii: {
|
|
484
|
+
container: number;
|
|
485
|
+
};
|
|
486
|
+
sizes: {
|
|
487
|
+
containerMinHeight: number;
|
|
488
|
+
errorAndHelpTextContainerHeight: number;
|
|
489
|
+
textInputMinHeight: number;
|
|
490
|
+
textareaHeight: number;
|
|
491
|
+
textInputMaxHeight: number;
|
|
492
|
+
};
|
|
493
|
+
lineHeights: {
|
|
494
|
+
topLabel: number;
|
|
495
|
+
};
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
type Theme = Theme$1 & {
|
|
499
|
+
__hd__: Theme$1['__hd__'] & {
|
|
500
|
+
textInput: ReturnType<typeof getTextInputTheme>;
|
|
501
|
+
};
|
|
502
|
+
};
|
|
503
|
+
declare const getTheme: (scale?: Scale, systemPalette?: SystemPalette) => Theme;
|
|
504
|
+
|
|
505
|
+
interface ThemeProviderProps {
|
|
506
|
+
theme: Partial<Theme> | ((outerTheme: Theme) => Theme);
|
|
507
|
+
children: React$1.ReactNode;
|
|
508
|
+
}
|
|
509
|
+
interface ThemeProviderType {
|
|
510
|
+
(props: ThemeProviderProps): React$1.ReactElement;
|
|
511
|
+
}
|
|
512
|
+
declare const WorkThemeProvider: ThemeProviderType;
|
|
513
|
+
declare const useWorkTheme: () => Theme;
|
|
514
|
+
|
|
515
|
+
type ThemeName = 'swag' | 'swagDark' | 'swagLight' | 'work' | 'jobs' | 'wallet' | 'eBens' | 'ehWorkDark' | 'ehWork' | 'ehJobs';
|
|
516
|
+
declare const WorkThemeSwitcher: ({ name, children, }: {
|
|
517
|
+
name?: ThemeName;
|
|
518
|
+
children: React$1.ReactNode;
|
|
519
|
+
}) => React$1.JSX.Element;
|
|
520
|
+
declare const withWorkTheme: <P extends Record<string, unknown>>(C: React$1.ComponentType<P>, themeName: ThemeName) => (props: PropsWithChildren<P>) => React$1.JSX.Element;
|
|
521
|
+
|
|
522
|
+
declare const defaultTheme: Theme;
|
|
523
|
+
|
|
524
|
+
export { _default$1 as DatePicker, FormGroup, _default as RichTextEditor, _default$2 as Select, TextInput, WorkThemeProvider as ThemeProvider, WorkThemeSwitcher as ThemeSwitcher, TimePicker, getTheme, defaultTheme as theme, useWorkTheme as useTheme, withWorkTheme as withTheme };
|
|
525
|
+
export type { Theme };
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import * as Base from '@hero-design/rn';
|
|
2
|
-
import * as HD from '../index';
|
|
3
|
-
import TextInput from '../components/TextInput';
|
|
4
|
-
import Select from '../components/Select';
|
|
5
|
-
import DatePicker from '../components/DatePicker';
|
|
6
|
-
import TimePicker from '../components/TimePicker';
|
|
7
|
-
import { getTheme, theme } from '../index';
|
|
8
|
-
|
|
9
|
-
describe('index.ts exports', () => {
|
|
10
|
-
it('TextInput, Select, DatePicker, TimePicker should be custom rn-work-uikit versions', () => {
|
|
11
|
-
// Check that the exported components are not the same as the base ones
|
|
12
|
-
expect(HD.TextInput).not.toBe(Base.TextInput);
|
|
13
|
-
expect(HD.Select).not.toBe(Base.Select);
|
|
14
|
-
expect(HD.DatePicker).not.toBe(Base.DatePicker);
|
|
15
|
-
expect(HD.TimePicker).not.toBe(Base.TimePicker);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('TextInput, Select, DatePicker, TimePicker should use the custom TextInput', () => {
|
|
19
|
-
// For TextInput, it's a direct export
|
|
20
|
-
expect(HD.TextInput).toBe(TextInput);
|
|
21
|
-
// For Select, DatePicker, TimePicker, check that they use the custom TextInput
|
|
22
|
-
// We can check the displayName or inspect the rendered output
|
|
23
|
-
// For DatePicker and TimePicker, check the TextInputComponent prop
|
|
24
|
-
// (We can't fully render without React Native, but we can check the implementation)
|
|
25
|
-
// These checks are mostly structural
|
|
26
|
-
expect(Select).toBe(HD.Select);
|
|
27
|
-
expect(DatePicker).toBe(HD.DatePicker);
|
|
28
|
-
expect(TimePicker).toBe(HD.TimePicker);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
describe('Theme Export Override', () => {
|
|
33
|
-
it('should export work-specific theme with overridden textInput from index', () => {
|
|
34
|
-
// Check a few key values from the textInput override
|
|
35
|
-
expect(theme.__hd__.textInput.sizes.containerMinHeight).toBe(
|
|
36
|
-
54.92307692307692
|
|
37
|
-
);
|
|
38
|
-
expect(theme.__hd__.textInput.sizes.errorAndHelpTextContainerHeight).toBe(
|
|
39
|
-
0
|
|
40
|
-
);
|
|
41
|
-
expect(theme.__hd__.textInput.space.prefixAndInputContainerGap).toBe(
|
|
42
|
-
3.9230769230769234
|
|
43
|
-
);
|
|
44
|
-
// Check that borderWidths.container.normal is overridden
|
|
45
|
-
expect(theme.__hd__.textInput.borderWidths.container.normal).toBe(2);
|
|
46
|
-
// Check that colors.borders.default is overridden
|
|
47
|
-
expect(theme.__hd__.textInput.colors.borders.default).toBe('#e8e9ea');
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('should export work-specific getTheme function with overridden textInput', () => {
|
|
51
|
-
const workTheme = getTheme();
|
|
52
|
-
expect(workTheme.__hd__.textInput.sizes.containerMinHeight).toBe(
|
|
53
|
-
54.92307692307692
|
|
54
|
-
);
|
|
55
|
-
expect(
|
|
56
|
-
workTheme.__hd__.textInput.sizes.errorAndHelpTextContainerHeight
|
|
57
|
-
).toBe(0);
|
|
58
|
-
expect(workTheme.__hd__.textInput.space.prefixAndInputContainerGap).toBe(
|
|
59
|
-
3.9230769230769234
|
|
60
|
-
);
|
|
61
|
-
expect(workTheme.__hd__.textInput.borderWidths.container.normal).toBe(2);
|
|
62
|
-
expect(workTheme.__hd__.textInput.colors.borders.default).toBe('#e8e9ea');
|
|
63
|
-
});
|
|
64
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
describe('Export Completeness', () => {
|
|
2
|
-
it('should include all exports from @hero-design/rn', () => {
|
|
3
|
-
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
4
|
-
const baseRN = require('@hero-design/rn');
|
|
5
|
-
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
6
|
-
const workUIKit = require('../index');
|
|
7
|
-
|
|
8
|
-
const baseExports = Object.keys(baseRN);
|
|
9
|
-
|
|
10
|
-
baseExports.forEach((exportName) => {
|
|
11
|
-
expect(workUIKit).toHaveProperty(exportName);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
});
|