@hero-design/rn-work-uikit 1.3.0 → 1.4.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.
- package/CHANGELOG.md +23 -0
- package/lib/index.js +48742 -29649
- package/package.json +5 -4
- package/src/__tests__/index-export.spec.ts +64 -0
- package/src/components/DatePicker/__tests__/__snapshots__/index.spec.tsx.snap +1602 -0
- package/src/components/DatePicker/__tests__/index.spec.tsx +56 -0
- package/src/components/DatePicker/index.tsx +12 -0
- package/src/components/FormGroup/__tests__/__snapshots__/index.spec.tsx.snap +880 -0
- package/src/components/FormGroup/__tests__/index.spec.tsx +179 -0
- package/src/components/FormGroup/__tests__/utils.spec.ts +73 -0
- package/src/components/FormGroup/index.tsx +97 -0
- package/src/components/FormGroup/utils.ts +67 -0
- package/src/components/RichTextEditor/EditorEvent.ts +7 -0
- package/src/components/RichTextEditor/EditorToolbar.tsx +216 -0
- package/src/components/RichTextEditor/MentionList.tsx +99 -0
- package/src/components/RichTextEditor/RichTextEditor.tsx +88 -0
- package/src/components/RichTextEditor/RichTextEditorInput.tsx +286 -0
- package/src/components/RichTextEditor/StyledRichTextEditor.tsx +18 -0
- package/src/components/RichTextEditor/StyledToolbar.ts +32 -0
- package/src/components/RichTextEditor/__mocks__/hero-editor.js +3 -0
- package/src/components/RichTextEditor/__mocks__/heroEditorApp.ts +2 -0
- package/src/components/RichTextEditor/__tests__/EditorToolbar.spec.tsx +144 -0
- package/src/components/RichTextEditor/__tests__/MentionList.spec.tsx +105 -0
- package/src/components/RichTextEditor/__tests__/RichTextEditorInput.spec.tsx +136 -0
- package/src/components/RichTextEditor/__tests__/__snapshots__/EditorToolbar.spec.tsx.snap +414 -0
- package/src/components/RichTextEditor/__tests__/__snapshots__/MentionList.spec.tsx.snap +13 -0
- package/src/components/RichTextEditor/constants.ts +9 -0
- package/src/{hero-editor.d.ts → components/RichTextEditor/hero-editor.d.ts} +6 -0
- package/src/components/RichTextEditor/heroEditorApp.ts +3 -0
- package/src/components/RichTextEditor/index.tsx +20 -0
- package/src/components/RichTextEditor/types.ts +87 -0
- package/src/components/RichTextEditor/utils/events.ts +31 -0
- package/src/components/RichTextEditor/utils/rnWebView.tsx +30 -0
- package/src/components/Select/__tests__/__snapshots__/index.spec.tsx.snap +1293 -0
- package/src/components/Select/__tests__/index.spec.tsx +43 -0
- package/src/components/TextInput/Group/__tests__/__snapshots__/index.spec.tsx.snap +0 -3
- package/src/components/TextInput/InputComponent.tsx +59 -18
- package/src/components/TextInput/InputRow.tsx +13 -7
- package/src/components/TextInput/StyledTextInput.tsx +0 -1
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +0 -17
- package/src/components/TextInput/index.tsx +20 -11
- package/src/components/TextInput/types.ts +29 -4
- package/src/components/TimePicker/__tests__/index.spec.tsx +34 -0
- package/src/components/TimePicker/index.tsx +12 -0
- package/src/index.ts +4 -1
- package/src/utils/functions.ts +2 -0
- package/stats/1.3.0/rn-work-uikit-stats.html +1 -1
- package/stats/1.4.0/rn-work-uikit-stats.html +4844 -0
- package/src/__tests__/theme-export-override.spec.ts +0 -96
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { Ref } from 'react';
|
|
4
|
+
import type { TextInputProps } from '../TextInput';
|
|
5
|
+
|
|
6
|
+
export type ToolbarButtonName =
|
|
7
|
+
| 'bold'
|
|
8
|
+
| 'italic'
|
|
9
|
+
| 'underline'
|
|
10
|
+
| 'bulletedList'
|
|
11
|
+
| 'numberedList'
|
|
12
|
+
| 'headingOne'
|
|
13
|
+
| 'headingTwo'
|
|
14
|
+
| '|';
|
|
15
|
+
|
|
16
|
+
export type TextUnit = 'character' | 'word' | 'line' | 'block';
|
|
17
|
+
|
|
18
|
+
export interface RichTextEditorRef {
|
|
19
|
+
requestBlur: VoidFunction;
|
|
20
|
+
insertNodes: (nodes: Record<string, unknown>[]) => void;
|
|
21
|
+
deleteBackward: (unit?: TextUnit) => void;
|
|
22
|
+
setReadOnly: (readOnly: boolean) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type EditorValue = {
|
|
26
|
+
type: string;
|
|
27
|
+
children: unknown;
|
|
28
|
+
}[];
|
|
29
|
+
|
|
30
|
+
export interface RichTextEditorProps {
|
|
31
|
+
/**
|
|
32
|
+
* If true, the editor will be focused when the user enters the screen
|
|
33
|
+
*/
|
|
34
|
+
autoFocus?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Error message
|
|
37
|
+
*/
|
|
38
|
+
error?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Field value
|
|
41
|
+
*/
|
|
42
|
+
value?: EditorValue;
|
|
43
|
+
/**
|
|
44
|
+
* Unique name used to communicate with webview
|
|
45
|
+
*/
|
|
46
|
+
name: string;
|
|
47
|
+
/**
|
|
48
|
+
* Callback function called when the field value changed
|
|
49
|
+
*/
|
|
50
|
+
onChange: (data: EditorValue) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Callback function called when the cursor position changed
|
|
53
|
+
*/
|
|
54
|
+
onCursorChange?: (params: { position: { top: number } }) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Field placeholder
|
|
57
|
+
*/
|
|
58
|
+
placeholder?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Additional styles
|
|
61
|
+
*/
|
|
62
|
+
style?: StyleProp<ViewStyle>;
|
|
63
|
+
/**
|
|
64
|
+
* Field label
|
|
65
|
+
*/
|
|
66
|
+
label: string;
|
|
67
|
+
/**
|
|
68
|
+
* Field helper text
|
|
69
|
+
*/
|
|
70
|
+
helpText?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Whether the input is required, if true, an asterisk will be appended to the label.
|
|
73
|
+
* */
|
|
74
|
+
required?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Testing ID of the component
|
|
77
|
+
*/
|
|
78
|
+
testID?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Imperative ref to expose the component method
|
|
81
|
+
*/
|
|
82
|
+
forwardedRef?: Ref<RichTextEditorRef>;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface InternalRichTextEditorProps extends RichTextEditorProps {
|
|
86
|
+
TextInputComponent?: React.ComponentType<TextInputProps>;
|
|
87
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
|
|
3
|
+
export interface Listener<T> {
|
|
4
|
+
(data: T): void;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const off = <T>(
|
|
8
|
+
emitter: EventEmitter,
|
|
9
|
+
eventName: string,
|
|
10
|
+
listener: Listener<T>
|
|
11
|
+
) => {
|
|
12
|
+
emitter.off(eventName, listener);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const emit = <T>(emitter: EventEmitter, eventName: string, data: T) =>
|
|
16
|
+
emitter.emit(eventName, data);
|
|
17
|
+
|
|
18
|
+
export const setMaxListeners = (emitter: EventEmitter, n: number) => {
|
|
19
|
+
emitter.setMaxListeners(n);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const on = <T>(
|
|
23
|
+
emitter: EventEmitter,
|
|
24
|
+
eventName: string,
|
|
25
|
+
listener: Listener<T>
|
|
26
|
+
) => {
|
|
27
|
+
emitter.on(eventName, listener);
|
|
28
|
+
return () => {
|
|
29
|
+
emitter.off(eventName, listener);
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import WebView from 'react-native-webview';
|
|
2
|
+
|
|
3
|
+
export const requestBlurEditor = (element: WebView): void => {
|
|
4
|
+
element.injectJavaScript(
|
|
5
|
+
'\n window.document.activeElement && window.document.activeElement.blur();\n '
|
|
6
|
+
);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const requestFocusEditor = (element: WebView): void => {
|
|
10
|
+
element.injectJavaScript(
|
|
11
|
+
`
|
|
12
|
+
\n
|
|
13
|
+
var el = window.document.querySelector('[role="textbox"]');
|
|
14
|
+
if (el) el.focus();
|
|
15
|
+
\n
|
|
16
|
+
`
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export interface WebViewEventMessage {
|
|
21
|
+
type: string;
|
|
22
|
+
data: unknown;
|
|
23
|
+
}
|
|
24
|
+
export const postMessage = (
|
|
25
|
+
element: WebView,
|
|
26
|
+
message: WebViewEventMessage
|
|
27
|
+
): void => {
|
|
28
|
+
const messageString = JSON.stringify(message);
|
|
29
|
+
element.injectJavaScript(`window.postMessage(${messageString}, '*');`);
|
|
30
|
+
};
|