uilib-native 5.0.0 → 5.1.0-snapshot.7630

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 (70) hide show
  1. package/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m +5 -5
  2. package/package.json +4 -5
  3. package/components/DynamicFonts/FontDownloader.d.ts +0 -41
  4. package/components/DynamicFonts/FontDownloader.js +0 -140
  5. package/components/DynamicFonts/FontLoader.d.ts +0 -35
  6. package/components/DynamicFonts/FontLoader.js +0 -89
  7. package/components/DynamicFonts/NoPermissionsAcquirer.d.ts +0 -3
  8. package/components/DynamicFonts/NoPermissionsAcquirer.js +0 -5
  9. package/components/DynamicFonts/PermissionsAcquirer.android.d.ts +0 -13
  10. package/components/DynamicFonts/PermissionsAcquirer.android.js +0 -42
  11. package/components/DynamicFonts/PermissionsAcquirer.ios.d.ts +0 -2
  12. package/components/DynamicFonts/PermissionsAcquirer.ios.js +0 -2
  13. package/components/DynamicFonts/PermissionsAcquirer.web.d.ts +0 -2
  14. package/components/DynamicFonts/PermissionsAcquirer.web.js +0 -2
  15. package/components/DynamicFonts/RNFSPackage.d.ts +0 -2
  16. package/components/DynamicFonts/RNFSPackage.js +0 -5
  17. package/components/DynamicFonts/index.d.ts +0 -61
  18. package/components/DynamicFonts/index.js +0 -154
  19. package/components/HighlighterOverlayView/index.d.ts +0 -34
  20. package/components/HighlighterOverlayView/index.js +0 -49
  21. package/components/HighlighterOverlayView/index.web.d.ts +0 -34
  22. package/components/HighlighterOverlayView/index.web.js +0 -15
  23. package/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.android.d.ts +0 -10
  24. package/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.android.js +0 -51
  25. package/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.ios.d.ts +0 -19
  26. package/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.ios.js +0 -62
  27. package/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardViewBase.d.ts +0 -27
  28. package/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardViewBase.js +0 -67
  29. package/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/index.d.ts +0 -4
  30. package/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/index.js +0 -10
  31. package/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/index.web.d.ts +0 -3
  32. package/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/index.web.js +0 -6
  33. package/components/Keyboard/KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.d.ts +0 -10
  34. package/components/Keyboard/KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.js +0 -33
  35. package/components/Keyboard/KeyboardAccessoryView/KeyboardRegistry/index.d.ts +0 -71
  36. package/components/Keyboard/KeyboardAccessoryView/KeyboardRegistry/index.js +0 -135
  37. package/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.d.ts +0 -26
  38. package/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.js +0 -91
  39. package/components/Keyboard/KeyboardAccessoryView/TextInputKeyboardManager/TextInputKeyboardManager.android.d.ts +0 -4
  40. package/components/Keyboard/KeyboardAccessoryView/TextInputKeyboardManager/TextInputKeyboardManager.android.js +0 -9
  41. package/components/Keyboard/KeyboardAccessoryView/TextInputKeyboardManager/TextInputKeyboardManager.ios.d.ts +0 -10
  42. package/components/Keyboard/KeyboardAccessoryView/TextInputKeyboardManager/TextInputKeyboardManager.ios.js +0 -64
  43. package/components/Keyboard/KeyboardAccessoryView/TextInputKeyboardManager/index.d.ts +0 -4
  44. package/components/Keyboard/KeyboardAccessoryView/TextInputKeyboardManager/index.js +0 -6
  45. package/components/Keyboard/KeyboardAccessoryView/index.d.ts +0 -84
  46. package/components/Keyboard/KeyboardAccessoryView/index.js +0 -161
  47. package/components/Keyboard/KeyboardAwareInsetsView/index.d.ts +0 -16
  48. package/components/Keyboard/KeyboardAwareInsetsView/index.js +0 -31
  49. package/components/Keyboard/KeyboardTrackingView/KeyboardTrackingView.android.d.ts +0 -12
  50. package/components/Keyboard/KeyboardTrackingView/KeyboardTrackingView.android.js +0 -17
  51. package/components/Keyboard/KeyboardTrackingView/KeyboardTrackingView.ios.d.ts +0 -21
  52. package/components/Keyboard/KeyboardTrackingView/KeyboardTrackingView.ios.js +0 -35
  53. package/components/Keyboard/KeyboardTrackingView/index.d.ts +0 -81
  54. package/components/Keyboard/KeyboardTrackingView/index.js +0 -22
  55. package/components/Keyboard/KeyboardTrackingView/index.web.d.ts +0 -6
  56. package/components/Keyboard/KeyboardTrackingView/index.web.js +0 -7
  57. package/components/Keyboard/index.d.ts +0 -40
  58. package/components/Keyboard/index.js +0 -13
  59. package/components/SafeArea/SafeAreaInsetsManager.d.ts +0 -34
  60. package/components/SafeArea/SafeAreaInsetsManager.js +0 -128
  61. package/components/SafeArea/SafeAreaSpacerView.d.ts +0 -10
  62. package/components/SafeArea/SafeAreaSpacerView.js +0 -68
  63. package/components/SafeArea/SafeAreaSpacerView.web.d.ts +0 -10
  64. package/components/SafeArea/SafeAreaSpacerView.web.js +0 -9
  65. package/components/SafeArea/index.d.ts +0 -10
  66. package/components/SafeArea/index.js +0 -11
  67. package/components/index.d.ts +0 -6
  68. package/components/index.js +0 -6
  69. package/specs/HighlighterViewNativeComponent.d.ts +0 -61
  70. package/specs/KeyboardTrackingViewNativeComponent.d.ts +0 -58
@@ -1,34 +0,0 @@
1
- import React from 'react';
2
- import { ViewStyle } from 'react-native';
3
- type HighlightFrameType = {
4
- x: number;
5
- y: number;
6
- width: number;
7
- height: number;
8
- };
9
- type HighlightViewTagParams = {
10
- padding: number | ViewStyle['padding'];
11
- offset: Pick<HighlightFrameType, 'x' | 'y'>;
12
- };
13
- export type HighlighterOverlayViewProps = {
14
- visible: boolean;
15
- overlayColor?: string;
16
- borderRadius?: number;
17
- strokeColor?: string;
18
- strokeWidth?: number;
19
- onRequestClose?: () => void;
20
- highlightFrame?: HighlightFrameType;
21
- style?: ViewStyle;
22
- highlightViewTag?: number;
23
- children?: JSX.Element[] | JSX.Element;
24
- highlightViewTagParams?: HighlightViewTagParams;
25
- minimumRectSize?: Pick<HighlightFrameType, 'width' | 'height'>;
26
- innerPadding?: number;
27
- accessible?: boolean;
28
- testID?: string;
29
- };
30
- declare const HighlighterOverlayView: {
31
- (props: HighlighterOverlayViewProps): React.JSX.Element;
32
- displayName: string;
33
- };
34
- export default HighlighterOverlayView;
@@ -1,49 +0,0 @@
1
- import React from 'react';
2
- import { processColor, StyleSheet, Modal } from 'react-native';
3
- // Import the Codegen specification for New Architecture
4
- import HighlighterViewNativeComponent from "../../specs/HighlighterViewNativeComponent";
5
- const DefaultOverlayColor = 'rgba(0, 0, 0, 0.5)';
6
- const HighlighterOverlayView = props => {
7
- const {
8
- overlayColor,
9
- borderRadius,
10
- strokeColor,
11
- strokeWidth,
12
- visible,
13
- onRequestClose,
14
- highlightFrame,
15
- style,
16
- children,
17
- highlightViewTag,
18
- highlightViewTagParams,
19
- minimumRectSize,
20
- innerPadding
21
- } = props;
22
-
23
- // Process colors for New Architecture Codegen component
24
- const overlayColorToUse = processColor(overlayColor || DefaultOverlayColor);
25
- const strokeColorToUse = strokeColor ? processColor(strokeColor) : undefined;
26
-
27
- // Convert highlightViewTagParams to match native Codegen spec
28
- let nativeHighlightViewTagParams;
29
- if (highlightViewTagParams) {
30
- const padding = typeof highlightViewTagParams.padding === 'number' ? highlightViewTagParams.padding : 0;
31
- nativeHighlightViewTagParams = {
32
- paddingLeft: padding,
33
- paddingTop: padding,
34
- paddingRight: padding,
35
- paddingBottom: padding,
36
- offsetX: highlightViewTagParams.offset?.x || 0,
37
- offsetY: highlightViewTagParams.offset?.y || 0
38
- };
39
- }
40
- return <Modal visible={!!visible} animationType={'fade'} transparent onRequestClose={() => onRequestClose?.()}>
41
- <HighlighterViewNativeComponent highlightFrame={highlightFrame} style={[style, {
42
- ...StyleSheet.absoluteFillObject,
43
- backgroundColor: 'transparent'
44
- }]} overlayColor={overlayColorToUse} borderRadius={borderRadius} strokeColor={strokeColorToUse} strokeWidth={strokeWidth} highlightViewTag={highlightViewTag} highlightViewTagParams={nativeHighlightViewTagParams} minimumRectSize={minimumRectSize} innerPadding={innerPadding} testID={props.testID} accessible={props.accessible} />
45
- {children}
46
- </Modal>;
47
- };
48
- HighlighterOverlayView.displayName = 'IGNORE';
49
- export default HighlighterOverlayView;
@@ -1,34 +0,0 @@
1
- import React from 'react';
2
- import { ViewStyle } from 'react-native';
3
- type HighlightFrameType = {
4
- x: number;
5
- y: number;
6
- width: number;
7
- height: number;
8
- };
9
- type HighlightViewTagParams = {
10
- padding: number | ViewStyle['padding'];
11
- offset: Pick<HighlightFrameType, 'x' | 'y'>;
12
- };
13
- export type HighlighterOverlayViewProps = {
14
- visible: boolean;
15
- overlayColor?: string;
16
- borderRadius?: number;
17
- strokeColor?: string;
18
- strokeWidth?: number;
19
- onRequestClose?: () => void;
20
- highlightFrame?: HighlightFrameType;
21
- style?: ViewStyle;
22
- highlightViewTag?: number;
23
- children?: JSX.Element[] | JSX.Element;
24
- highlightViewTagParams?: HighlightViewTagParams;
25
- minimumRectSize?: Pick<HighlightFrameType, 'width' | 'height'>;
26
- innerPadding?: number;
27
- accessible?: boolean;
28
- testID?: string;
29
- };
30
- declare const HighlighterOverlayView: {
31
- (props: HighlighterOverlayViewProps): React.JSX.Element;
32
- displayName: string;
33
- };
34
- export default HighlighterOverlayView;
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
- import { Modal } from 'react-native';
3
- const HighlighterOverlayView = props => {
4
- const {
5
- visible,
6
- onRequestClose,
7
- children
8
- } = props;
9
- return <Modal visible={!!visible} animationType={'fade'} transparent onRequestClose={() => onRequestClose?.()}>
10
-
11
- {children}
12
- </Modal>;
13
- };
14
- HighlighterOverlayView.displayName = 'IGNORE';
15
- export default HighlighterOverlayView;
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- import CustomKeyboardViewBase, { CustomKeyboardViewBaseProps } from './CustomKeyboardViewBase';
3
- export default class CustomKeyboardView extends CustomKeyboardViewBase<CustomKeyboardViewBaseProps> {
4
- static displayName: string;
5
- componentDidUpdate(prevProps: CustomKeyboardViewBaseProps): Promise<void>;
6
- getStyle: () => {
7
- height: number | undefined;
8
- };
9
- render(): React.JSX.Element | null;
10
- }
@@ -1,51 +0,0 @@
1
- import React from 'react';
2
- import { Keyboard, View } from 'react-native';
3
- import KeyboardRegistry from "../KeyboardRegistry";
4
- import CustomKeyboardViewBase from "./CustomKeyboardViewBase";
5
- export default class CustomKeyboardView extends CustomKeyboardViewBase {
6
- static displayName = 'IGNORE';
7
- async componentDidUpdate(prevProps) {
8
- const {
9
- component,
10
- inputRef,
11
- shouldFocus,
12
- onKeyboardDismiss
13
- } = this.props;
14
- if (prevProps.component !== component) {
15
- if (!component) {
16
- if (shouldFocus) {
17
- if (inputRef?.current) {
18
- inputRef.current.focus?.();
19
- } else {
20
- inputRef?.focus?.();
21
- }
22
- }
23
- } else {
24
- Keyboard.dismiss();
25
- }
26
- onKeyboardDismiss?.();
27
- }
28
- super.componentDidUpdate(prevProps);
29
- }
30
- getStyle = () => {
31
- const {
32
- keyboardHeight
33
- } = this.props;
34
- return {
35
- height: keyboardHeight
36
- };
37
- };
38
- render() {
39
- const {
40
- component,
41
- initialProps
42
- } = this.props;
43
- const KeyboardComponent = component && KeyboardRegistry.getKeyboard(component);
44
- if (!KeyboardComponent) {
45
- return null;
46
- }
47
- return <View style={this.getStyle()}>
48
- <KeyboardComponent {...initialProps} />
49
- </View>;
50
- }
51
- }
@@ -1,19 +0,0 @@
1
- import CustomKeyboardViewBase, { CustomKeyboardViewBaseProps } from './CustomKeyboardViewBase';
2
- export type CustomKeyboardViewProps = CustomKeyboardViewBaseProps & {
3
- /**
4
- * The reference to the actual text input (or the keyboard may not reset when instructed to, etc.)
5
- */
6
- inputRef?: any;
7
- useSafeArea?: boolean;
8
- };
9
- export default class CustomKeyboardView extends CustomKeyboardViewBase<CustomKeyboardViewProps> {
10
- static displayName: string;
11
- static defaultProps: {
12
- initialProps: {};
13
- useSafeArea: boolean;
14
- };
15
- constructor(props: CustomKeyboardViewProps);
16
- componentWillUnmount(): void;
17
- componentDidUpdate(prevProps: CustomKeyboardViewProps): void;
18
- render(): null;
19
- }
@@ -1,62 +0,0 @@
1
- import TextInputKeyboardManager from "../TextInputKeyboardManager/TextInputKeyboardManager.ios";
2
- import KeyboardRegistry from "../KeyboardRegistry";
3
- import CustomKeyboardViewBase from "./CustomKeyboardViewBase";
4
- export default class CustomKeyboardView extends CustomKeyboardViewBase {
5
- static displayName = 'IGNORE';
6
- static defaultProps = {
7
- initialProps: {},
8
- useSafeArea: true
9
- };
10
- constructor(props) {
11
- super(props);
12
- const {
13
- component
14
- } = props;
15
- if (component) {
16
- this.registeredRequestShowKeyboard = false;
17
- }
18
- KeyboardRegistry.addListener('onToggleExpandedKeyboard', args => {
19
- const {
20
- inputRef,
21
- initialProps
22
- } = this.props;
23
- if (inputRef) {
24
- if (this.keyboardExpandedToggle[args.keyboardId] === undefined) {
25
- this.keyboardExpandedToggle[args.keyboardId] = false;
26
- }
27
- this.keyboardExpandedToggle[args.keyboardId] = !this.keyboardExpandedToggle[args.keyboardId];
28
- TextInputKeyboardManager.toggleExpandKeyboard(inputRef, this.keyboardExpandedToggle[args.keyboardId], initialProps.expandWithLayoutAnimation);
29
- }
30
- });
31
- }
32
- componentWillUnmount() {
33
- KeyboardRegistry.removeListeners('onToggleExpandedKeyboard');
34
- super.componentWillUnmount();
35
- }
36
- componentDidUpdate(prevProps) {
37
- const {
38
- inputRef: nextInputRef,
39
- component: nextComponent,
40
- initialProps: nextInitialProps,
41
- useSafeArea
42
- } = this.props;
43
- const {
44
- component
45
- } = prevProps;
46
- if (nextInputRef && nextComponent !== component) {
47
- if (nextComponent) {
48
- TextInputKeyboardManager.setInputComponent(nextInputRef, {
49
- component: nextComponent,
50
- initialProps: nextInitialProps,
51
- useSafeArea
52
- });
53
- } else {
54
- TextInputKeyboardManager.removeInputComponent(nextInputRef);
55
- }
56
- }
57
- super.componentDidUpdate(prevProps);
58
- }
59
- render() {
60
- return null;
61
- }
62
- }
@@ -1,27 +0,0 @@
1
- import React, { Component } from 'react';
2
- import { EventSubscription } from 'react-native';
3
- export type CustomKeyboardViewBaseProps = {
4
- inputRef?: any;
5
- initialProps?: any;
6
- keyboardHeight?: number;
7
- onKeyboardDismiss?: () => void;
8
- shouldFocus?: boolean;
9
- component?: string;
10
- onItemSelected?: (component?: string, args?: any) => void;
11
- onRequestShowKeyboard?: (keyboardId: string) => void;
12
- children?: React.ReactChild | React.ReactChild[];
13
- };
14
- export default class CustomKeyboardViewBase<T extends CustomKeyboardViewBaseProps> extends Component<T> {
15
- static defaultProps: {
16
- initialProps: {};
17
- };
18
- registeredRequestShowKeyboard: boolean;
19
- keyboardExpandedToggle: any;
20
- keyboardEventListeners: EventSubscription[];
21
- constructor(props: T);
22
- shouldComponentUpdate(nextProps: T): boolean;
23
- componentWillUnmount(): void;
24
- addOnItemSelectListener(onItemSelected: CustomKeyboardViewBaseProps['onItemSelected'], component: CustomKeyboardViewBaseProps['component']): void;
25
- componentDidUpdate(prevProps: T): void;
26
- registerListener(props: T, nextProps: T): void;
27
- }
@@ -1,67 +0,0 @@
1
- import { Component } from 'react';
2
- import KeyboardRegistry from "../KeyboardRegistry";
3
- export default class CustomKeyboardViewBase extends Component {
4
- static defaultProps = {
5
- initialProps: {}
6
- };
7
- registeredRequestShowKeyboard = false;
8
- keyboardEventListeners = [];
9
- constructor(props) {
10
- super(props);
11
- const {
12
- component,
13
- onItemSelected
14
- } = props;
15
- if (component) {
16
- this.addOnItemSelectListener(onItemSelected, component);
17
- }
18
- this.keyboardExpandedToggle = {};
19
- }
20
- shouldComponentUpdate(nextProps) {
21
- return nextProps.component !== this.props.component;
22
- }
23
- componentWillUnmount() {
24
- const {
25
- component
26
- } = this.props;
27
- KeyboardRegistry.removeListeners('onRequestShowKeyboard');
28
- if (this.keyboardEventListeners) {
29
- this.keyboardEventListeners.forEach(eventListener => eventListener.remove());
30
- }
31
- if (component) {
32
- KeyboardRegistry.removeListeners(`${component}.onItemSelected`);
33
- }
34
- }
35
- addOnItemSelectListener(onItemSelected, component) {
36
- if (onItemSelected) {
37
- KeyboardRegistry.addListener(`${component}.onItemSelected`, args => {
38
- onItemSelected(component, args);
39
- });
40
- }
41
- }
42
- componentDidUpdate(prevProps) {
43
- const {
44
- onRequestShowKeyboard
45
- } = this.props;
46
- if (onRequestShowKeyboard && !this.registeredRequestShowKeyboard) {
47
- this.registeredRequestShowKeyboard = true;
48
- KeyboardRegistry.addListener('onRequestShowKeyboard', args => {
49
- onRequestShowKeyboard(args.keyboardId);
50
- });
51
- }
52
- this.registerListener(prevProps, this.props);
53
- }
54
- registerListener(props, nextProps) {
55
- const {
56
- component,
57
- onItemSelected
58
- } = nextProps;
59
- if (component && props.component !== component) {
60
- if (props.component) {
61
- KeyboardRegistry.removeListeners(`${props.component}.onItemSelected`);
62
- }
63
- KeyboardRegistry.removeListeners(`${component}.onItemSelected`);
64
- this.addOnItemSelectListener(onItemSelected, component);
65
- }
66
- }
67
- }
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import { CustomKeyboardViewProps } from './CustomKeyboardView.ios';
3
- declare const CustomKeyboardView: (props: CustomKeyboardViewProps) => React.JSX.Element;
4
- export default CustomKeyboardView;
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- import { Platform } from 'react-native';
3
- import { default as CustomKeyboardViewIOS } from "./CustomKeyboardView.ios";
4
- import { default as CustomKeyboardViewAndroid } from "./CustomKeyboardView.android";
5
- const IsAndroid = Platform.OS === 'android';
6
- const CustomKeyboardView = props => {
7
- const Container = IsAndroid ? CustomKeyboardViewAndroid : CustomKeyboardViewIOS;
8
- return <Container {...props} />;
9
- };
10
- export default CustomKeyboardView;
@@ -1,3 +0,0 @@
1
- import 'react';
2
- declare const CustomKeyboardView: () => null;
3
- export default CustomKeyboardView;
@@ -1,6 +0,0 @@
1
- import 'react';
2
- console.log('keyboard is not supported on web');
3
- const CustomKeyboardView = () => {
4
- return null;
5
- };
6
- export default CustomKeyboardView;
@@ -1,10 +0,0 @@
1
- export default class EventEmitterManager {
2
- handlerCallbacks: {
3
- [key: string]: Function[];
4
- };
5
- constructor();
6
- listenOn(eventName: string, handlerCallback: Function): void;
7
- emitEvent(eventName: string, params?: {}): void;
8
- removeListeners(eventName: string): void;
9
- removeListener(eventName: string, listener: Function): void;
10
- }
@@ -1,33 +0,0 @@
1
- import _indexOf from "lodash/indexOf";
2
- export default class EventEmitterManager {
3
- handlerCallbacks = {};
4
- constructor() {
5
- this.handlerCallbacks = {};
6
- }
7
- listenOn(eventName, handlerCallback) {
8
- if (!this.handlerCallbacks[eventName]) {
9
- this.handlerCallbacks[eventName] = [];
10
- }
11
- if (_indexOf(this.handlerCallbacks[eventName], handlerCallback) === -1) {
12
- this.handlerCallbacks[eventName].push(handlerCallback);
13
- }
14
- }
15
- emitEvent(eventName, params = {}) {
16
- if (this.handlerCallbacks[eventName]) {
17
- this.handlerCallbacks[eventName].forEach(callback => callback(params));
18
- }
19
- }
20
- removeListeners(eventName) {
21
- delete this.handlerCallbacks[eventName];
22
- }
23
- removeListener(eventName, listener) {
24
- const handlers = this.handlerCallbacks[eventName];
25
- if (handlers) {
26
- handlers.forEach((handler, index) => {
27
- if (handler === listener) {
28
- handlers.splice(index, 1);
29
- }
30
- });
31
- }
32
- }
33
- }
@@ -1,71 +0,0 @@
1
- import EventEmitterManager from './EventEmitterManager';
2
- /**
3
- * @description: used for registering keyboards and performing certain actions on the keyboards.
4
- * @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/nativeComponentScreens/keyboardAccessory/demoKeyboards.js
5
- */
6
- export default class KeyboardRegistry {
7
- static displayName: string;
8
- static registeredKeyboards: {
9
- [key: string]: any;
10
- };
11
- static eventEmitter: EventEmitterManager;
12
- /**
13
- * Register a new keyboard.
14
- * componentID (string) - the ID of the keyboard.
15
- * generator (function) - a function for the creation of the keyboard.
16
- * params (object) - to be returned when using other methods (i.e. getKeyboards and getAllKeyboards).
17
- */
18
- static registerKeyboard: (componentID: string, generator: Function, params?: {}) => void;
19
- /**
20
- * Get a specific keyboard
21
- * componentID (string) - the ID of the keyboard.
22
- */
23
- static getKeyboard: (componentID: string) => any;
24
- /**
25
- * Get keyboards by IDs
26
- * componentIDs (string[]) - the ID of the keyboard.
27
- */
28
- static getKeyboards: (componentIDs?: never[]) => any[];
29
- /**
30
- * Get all keyboards
31
- */
32
- static getAllKeyboards: () => any[];
33
- /**
34
- * Add a listener for a callback.
35
- * globalID (string) - ID that includes the componentID and the event name
36
- * (i.e. if componentID='kb1' globalID='kb1.onItemSelected')
37
- * callback (function) - the callback to be called when the said event happens
38
- */
39
- static addListener: (globalID: string, callback: Function) => void;
40
- /**
41
- * Notify that an event has occurred.
42
- * globalID (string) - ID that includes the componentID and the event name
43
- * (i.e. if componentID='kb1' globalID='kb1.onItemSelected')
44
- * args (object) - data to be sent to the listener.
45
- */
46
- static notifyListeners: (globalID: string, args: any) => void;
47
- /**
48
- * Remove a listener for a callback.
49
- * globalID (string) - ID that includes the componentID and the event name
50
- * (i.e. if componentID='kb1' globalID='kb1.onItemSelected')
51
- */
52
- static removeListeners: (globalID: string) => void;
53
- /**
54
- * Default event to be used for when an item on the keyboard has been pressed.
55
- * componentID (string) - the ID of the keyboard.
56
- * args (object) - data to be sent to the listener.
57
- */
58
- static onItemSelected: (componentID: string, args: any) => void;
59
- /**
60
- * Request to show the keyboard
61
- * componentID (string) - the ID of the keyboard.
62
- */
63
- static requestShowKeyboard: (componentID: string) => void;
64
- /**
65
- * @deprecated
66
- * iOS only (experimental)
67
- * Call to make the keyboard full screen
68
- * componentID (string) - the ID of the keyboard.
69
- */
70
- static toggleExpandedKeyboard: (componentID: string) => void;
71
- }
@@ -1,135 +0,0 @@
1
- import _intersection from "lodash/intersection";
2
- import _isFunction from "lodash/isFunction";
3
- import { AppRegistry } from 'react-native';
4
- import EventEmitterManager from "./EventEmitterManager";
5
-
6
- /*
7
- * Tech debt: how to deal with multiple registries in the app?
8
- */
9
-
10
- const getKeyboardsWithIDs = keyboardIDs => {
11
- return keyboardIDs.map(keyboardId => {
12
- return {
13
- id: keyboardId,
14
- ...KeyboardRegistry.registeredKeyboards[keyboardId].params
15
- };
16
- });
17
- };
18
-
19
- /**
20
- * @description: used for registering keyboards and performing certain actions on the keyboards.
21
- * @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/nativeComponentScreens/keyboardAccessory/demoKeyboards.js
22
- */
23
- export default class KeyboardRegistry {
24
- static displayName = 'KeyboardRegistry';
25
- static registeredKeyboards = {};
26
- static eventEmitter = new EventEmitterManager();
27
-
28
- /**
29
- * Register a new keyboard.
30
- * componentID (string) - the ID of the keyboard.
31
- * generator (function) - a function for the creation of the keyboard.
32
- * params (object) - to be returned when using other methods (i.e. getKeyboards and getAllKeyboards).
33
- */
34
- static registerKeyboard = (componentID, generator, params = {}) => {
35
- if (!_isFunction(generator)) {
36
- console.error(`KeyboardRegistry.registerKeyboard: ${componentID} you must register a generator function`);
37
- return;
38
- }
39
- KeyboardRegistry.registeredKeyboards[componentID] = {
40
- generator,
41
- params,
42
- componentID
43
- };
44
- AppRegistry.registerComponent(componentID, generator);
45
- };
46
-
47
- /**
48
- * Get a specific keyboard
49
- * componentID (string) - the ID of the keyboard.
50
- */
51
- static getKeyboard = componentID => {
52
- const res = KeyboardRegistry.registeredKeyboards[componentID];
53
- if (!res || !res.generator) {
54
- console.error(`KeyboardRegistry.getKeyboard: ${componentID} used but not yet registered`);
55
- return undefined;
56
- }
57
- return res.generator();
58
- };
59
-
60
- /**
61
- * Get keyboards by IDs
62
- * componentIDs (string[]) - the ID of the keyboard.
63
- */
64
- static getKeyboards = (componentIDs = []) => {
65
- const validKeyboardIDs = _intersection(componentIDs, Object.keys(KeyboardRegistry.registeredKeyboards));
66
- return getKeyboardsWithIDs(validKeyboardIDs);
67
- };
68
-
69
- /**
70
- * Get all keyboards
71
- */
72
- static getAllKeyboards = () => {
73
- return getKeyboardsWithIDs(Object.keys(KeyboardRegistry.registeredKeyboards));
74
- };
75
-
76
- /**
77
- * Add a listener for a callback.
78
- * globalID (string) - ID that includes the componentID and the event name
79
- * (i.e. if componentID='kb1' globalID='kb1.onItemSelected')
80
- * callback (function) - the callback to be called when the said event happens
81
- */
82
- static addListener = (globalID, callback) => {
83
- KeyboardRegistry.eventEmitter.listenOn(globalID, callback);
84
- };
85
-
86
- /**
87
- * Notify that an event has occurred.
88
- * globalID (string) - ID that includes the componentID and the event name
89
- * (i.e. if componentID='kb1' globalID='kb1.onItemSelected')
90
- * args (object) - data to be sent to the listener.
91
- */
92
- static notifyListeners = (globalID, args) => {
93
- KeyboardRegistry.eventEmitter.emitEvent(globalID, args);
94
- };
95
-
96
- /**
97
- * Remove a listener for a callback.
98
- * globalID (string) - ID that includes the componentID and the event name
99
- * (i.e. if componentID='kb1' globalID='kb1.onItemSelected')
100
- */
101
- static removeListeners = globalID => {
102
- KeyboardRegistry.eventEmitter.removeListeners(globalID);
103
- };
104
-
105
- /**
106
- * Default event to be used for when an item on the keyboard has been pressed.
107
- * componentID (string) - the ID of the keyboard.
108
- * args (object) - data to be sent to the listener.
109
- */
110
- static onItemSelected = (componentID, args) => {
111
- KeyboardRegistry.notifyListeners(`${componentID}.onItemSelected`, args);
112
- };
113
-
114
- /**
115
- * Request to show the keyboard
116
- * componentID (string) - the ID of the keyboard.
117
- */
118
- static requestShowKeyboard = componentID => {
119
- KeyboardRegistry.notifyListeners('onRequestShowKeyboard', {
120
- keyboardId: componentID
121
- });
122
- };
123
-
124
- /**
125
- * @deprecated
126
- * iOS only (experimental)
127
- * Call to make the keyboard full screen
128
- * componentID (string) - the ID of the keyboard.
129
- */
130
- static toggleExpandedKeyboard = componentID => {
131
- KeyboardRegistry.notifyListeners('onToggleExpandedKeyboard', {
132
- keyboardId: componentID
133
- });
134
- };
135
- }