@momo-kits/foundation 0.75.1-beta.9 → 0.75.2-beta.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 (112) hide show
  1. package/Application/BottomTab/BottomTabBar.tsx +478 -0
  2. package/Application/BottomTab/index.tsx +134 -0
  3. package/Application/Components.tsx +552 -0
  4. package/Application/ModalScreen.tsx +244 -0
  5. package/Application/Navigation.ts +50 -0
  6. package/Application/NavigationContainer.tsx +128 -0
  7. package/Application/Navigator.ts +151 -0
  8. package/Application/StackScreen.tsx +146 -0
  9. package/Application/index.ts +37 -0
  10. package/{Navigation → Application}/types.ts +96 -27
  11. package/Application/utils.tsx +175 -0
  12. package/Assets/DotAnimation.json +256 -0
  13. package/Assets/SpinnerAnimation.json +1027 -0
  14. package/Assets/icon.json +89 -5
  15. package/Assets/icon_bank.json +506 -0
  16. package/Assets/language.json +202 -0
  17. package/Badge/Badge.tsx +56 -0
  18. package/Badge/BadgeDot.tsx +11 -0
  19. package/Badge/BadgeRibbon.tsx +125 -0
  20. package/Badge/Shape.tsx +29 -0
  21. package/Badge/index.tsx +7 -0
  22. package/Badge/styles.ts +58 -0
  23. package/Badge/types.ts +63 -0
  24. package/Button/index.tsx +90 -39
  25. package/Button/styles.ts +19 -0
  26. package/CheckBox/index.tsx +58 -43
  27. package/CheckBox/styles.ts +1 -1
  28. package/CheckBox/types.ts +6 -4
  29. package/Consts/colors+spacing+radius.ts +18 -0
  30. package/Consts/styles.ts +0 -26
  31. package/Consts/theme.ts +5 -1
  32. package/Divider/index.tsx +3 -1
  33. package/Icon/index.tsx +14 -10
  34. package/Icon/types.ts +4 -3
  35. package/IconButton/index.tsx +24 -15
  36. package/Image/index.tsx +63 -45
  37. package/Image/styles.ts +1 -9
  38. package/Image/types.ts +5 -1
  39. package/Input/Input.tsx +227 -115
  40. package/Input/InputDropDown.tsx +132 -0
  41. package/Input/InputMoney.tsx +174 -110
  42. package/Input/InputOTP.tsx +257 -0
  43. package/Input/InputSearch.tsx +160 -130
  44. package/Input/InputTextArea.tsx +149 -121
  45. package/Input/common.tsx +43 -18
  46. package/Input/index.tsx +205 -17
  47. package/Input/styles.ts +44 -7
  48. package/Input/utils.ts +2 -2
  49. package/Layout/Card.tsx +76 -37
  50. package/Layout/FloatingButton.tsx +128 -0
  51. package/Layout/GridSystem.tsx +35 -23
  52. package/Layout/Item.tsx +29 -33
  53. package/Layout/ItemList.tsx +55 -0
  54. package/Layout/ItemSectionList.tsx +39 -0
  55. package/Layout/Screen.tsx +378 -0
  56. package/Layout/Section.tsx +73 -35
  57. package/Layout/index.ts +13 -3
  58. package/Layout/styles.ts +101 -0
  59. package/Layout/types.ts +1 -37
  60. package/Layout/utils.ts +38 -43
  61. package/Loader/DotLoader.tsx +37 -0
  62. package/Loader/Loader.tsx +13 -0
  63. package/Loader/ProgressBar.tsx +44 -0
  64. package/Loader/Spinner.tsx +29 -0
  65. package/Loader/index.tsx +4 -0
  66. package/Loader/styles.ts +10 -0
  67. package/Loader/types.ts +35 -0
  68. package/Loader/utils.ts +25 -0
  69. package/Pagination/Dot.tsx +1 -1
  70. package/Pagination/PaginationDot.tsx +8 -3
  71. package/Pagination/PaginationNumber.tsx +8 -7
  72. package/Pagination/PaginationScroll.tsx +1 -1
  73. package/Pagination/PaginationWhiteDot.tsx +8 -5
  74. package/Pagination/styles.ts +3 -0
  75. package/Pagination/types.ts +2 -0
  76. package/Popup/PopupNotify.tsx +102 -44
  77. package/Popup/PopupPromotion.tsx +63 -22
  78. package/Popup/types.ts +15 -4
  79. package/Radio/index.tsx +35 -21
  80. package/Radio/types.ts +7 -5
  81. package/Skeleton/index.tsx +1 -1
  82. package/Skeleton/types.ts +3 -0
  83. package/Switch/index.tsx +35 -24
  84. package/Switch/types.ts +5 -3
  85. package/Tag/index.tsx +1 -1
  86. package/Text/index.tsx +32 -26
  87. package/Text/styles.ts +38 -0
  88. package/Text/types.ts +25 -13
  89. package/Text/utils.ts +14 -0
  90. package/Title/index.tsx +186 -0
  91. package/Title/styles.ts +79 -0
  92. package/Title/types.ts +20 -0
  93. package/code-scanner.js +143 -0
  94. package/index.ts +17 -3
  95. package/migrate_typo.js +56 -0
  96. package/package.json +44 -39
  97. package/publish.sh +2 -5
  98. package/tsconfig.json +24 -0
  99. package/verify.js +47 -0
  100. package/Assets/header-background.png +0 -0
  101. package/Layout/ScreenContainer.tsx +0 -121
  102. package/Navigation/BottomTab.tsx +0 -39
  103. package/Navigation/Components.tsx +0 -365
  104. package/Navigation/ModalScreen.tsx +0 -226
  105. package/Navigation/Navigation.ts +0 -44
  106. package/Navigation/NavigationButton.tsx +0 -54
  107. package/Navigation/NavigationContainer.tsx +0 -77
  108. package/Navigation/Navigator.ts +0 -82
  109. package/Navigation/Observer.ts +0 -79
  110. package/Navigation/StackScreen.tsx +0 -27
  111. package/Navigation/index.ts +0 -14
  112. package/Navigation/utils.tsx +0 -137
@@ -1,77 +0,0 @@
1
- import React, {createContext, useEffect, useRef} from 'react';
2
- import {BottomSheetModalProvider} from '@gorhom/bottom-sheet';
3
- import {SafeAreaProvider} from 'react-native-safe-area-context';
4
- import {
5
- NavigationContainer as ReactNavigationContainer,
6
- NavigationContainerRef,
7
- } from '@react-navigation/native';
8
- import {createStackNavigator} from '@react-navigation/stack';
9
- import StackScreen from './StackScreen';
10
- import ModalScreen from './ModalScreen';
11
- import Navigator from './Navigator';
12
- import {getDialogOptions, getModalOptions, getStackOptions} from './utils';
13
- import {GridSystem} from '../Layout';
14
- import {defaultContext, GRIDVIEW} from '../Consts';
15
- import {NavigationContainerProps} from './types';
16
-
17
- const Stack = createStackNavigator();
18
-
19
- const ApplicationContext = createContext(defaultContext);
20
- const NavigationContainer: React.FC<NavigationContainerProps> = ({
21
- screen,
22
- theme,
23
- options,
24
- maxApi,
25
- }) => {
26
- const navigationRef = React.useRef<NavigationContainerRef>(null);
27
- const navigator = useRef(new Navigator(navigationRef));
28
- navigator.current.maxApi = maxApi;
29
-
30
- return (
31
- <SafeAreaProvider>
32
- <BottomSheetModalProvider>
33
- <ApplicationContext.Provider
34
- value={{theme, navigator: navigator.current}}>
35
- <ReactNavigationContainer
36
- theme={{
37
- ...theme,
38
- colors: {
39
- ...theme.colors,
40
- background: theme.colors.background.default,
41
- card: theme.colors.background.surface,
42
- text: theme.colors.text.default,
43
- border: theme.colors.border.default,
44
- notification: theme.colors.error.primary,
45
- },
46
- }}
47
- ref={navigator.current?.ref}
48
- independent={true}>
49
- <Stack.Navigator initialRouteName="Stack" headerMode="screen">
50
- <Stack.Screen
51
- name="Stack"
52
- component={StackScreen}
53
- initialParams={{screen}}
54
- options={{...getStackOptions(theme), ...options}}
55
- />
56
- <Stack.Screen
57
- name="Dialog"
58
- component={StackScreen}
59
- options={getDialogOptions(theme)}
60
- initialParams={{screen}}
61
- />
62
- <Stack.Screen
63
- name="Modal"
64
- component={ModalScreen}
65
- options={getModalOptions()}
66
- initialParams={{screen}}
67
- />
68
- </Stack.Navigator>
69
- </ReactNavigationContainer>
70
- </ApplicationContext.Provider>
71
- </BottomSheetModalProvider>
72
- {GRIDVIEW && <GridSystem />}
73
- </SafeAreaProvider>
74
- );
75
- };
76
-
77
- export {ApplicationContext, NavigationContainer};
@@ -1,82 +0,0 @@
1
- import {StackActions} from '@react-navigation/native';
2
- import {
3
- BottomSheetParams,
4
- HeaderToolkitProps,
5
- ModalParams,
6
- ScreenParams,
7
- } from './types';
8
-
9
- class Navigator {
10
- ref?: any;
11
- toolkitConfig?: HeaderToolkitProps;
12
- maxApi?: any;
13
-
14
- constructor(navigation: any) {
15
- this.ref = navigation;
16
- }
17
-
18
- push = (params: ScreenParams) => {
19
- this.ref.current.dispatch(StackActions.push('Stack', params));
20
- };
21
-
22
- replace = (params: ScreenParams) => {
23
- this.ref.current.dispatch(StackActions.replace('Stack', params));
24
- };
25
-
26
- pop = (count?: number) => {
27
- this.ref.current.dispatch(StackActions.pop(count ?? 1));
28
- };
29
-
30
- present = (params: ScreenParams) => {
31
- this.ref.current.dispatch(StackActions.push('Dialog', params));
32
- };
33
-
34
- showModal = (params: ModalParams) => {
35
- this.ref.current.dispatch(StackActions.push('Modal', params));
36
- };
37
-
38
- showBottomSheet = (params: BottomSheetParams) => {
39
- this.ref.current.dispatch(
40
- StackActions.push('Modal', {
41
- ...params,
42
- isBottomSheet: true,
43
- }),
44
- );
45
- };
46
-
47
- popToTop = () => {
48
- this.ref.current.dispatch(StackActions.popToTop());
49
- };
50
-
51
- requestApi = (func: any, args: any = [], callback: any) => {
52
- if (this.maxApi) {
53
- this.maxApi[func]?.(...args, callback);
54
- } else {
55
- const instance: any = global;
56
- instance?.miniAppApi?.dispatch?.(func, ...args, callback);
57
- }
58
- };
59
- getToolkit = async (): Promise<HeaderToolkitProps | undefined> => {
60
- return new Promise(resolve => {
61
- if (this.toolkitConfig) {
62
- resolve(this.toolkitConfig);
63
- return;
64
- }
65
- this.requestApi('getToolkit', [undefined], (result: boolean) => {
66
- if (result) {
67
- this.requestApi('getToolkitConfig', [undefined], (config: any) => {
68
- this.toolkitConfig = {
69
- ...config?.utilityToolConfig,
70
- appCode: config?.appCode,
71
- };
72
- resolve(this.toolkitConfig);
73
- });
74
- } else {
75
- resolve(undefined);
76
- }
77
- });
78
- });
79
- };
80
- }
81
-
82
- export default Navigator;
@@ -1,79 +0,0 @@
1
- class Subject {
2
- private observers: any[];
3
- constructor() {
4
- this.observers = [];
5
- }
6
-
7
- attach(observer: any) {
8
- observer && this.observers.push(observer);
9
- }
10
-
11
- detach(observer: any) {
12
- this.observers = this.observers.filter(item => item !== observer);
13
- }
14
-
15
- notify(newState: any) {
16
- this.observers.forEach(observer => {
17
- if (typeof observer === 'function') {
18
- observer(newState);
19
- } else {
20
- observer.updateData && observer.updateData(newState);
21
- }
22
- });
23
- }
24
- }
25
-
26
- class ObserverInstance {
27
- private readonly props: any;
28
- constructor(props: any) {
29
- this.props = props;
30
- }
31
-
32
- remove() {
33
- const {detach, observer} = this.props;
34
- detach && detach(observer);
35
- }
36
- }
37
-
38
- export default class Observer {
39
- static SCHEMA = 'Observer';
40
-
41
- static instances: any = {};
42
- private schema: any;
43
- private subject: Subject;
44
- private data: null;
45
- private loaded: boolean;
46
-
47
- constructor(props: any) {
48
- this.schema = props.schema;
49
- this.subject = new Subject();
50
- this.data = null;
51
- this.loaded = false;
52
- this.initilize();
53
- }
54
-
55
- static getInstance(schema: string, Class = Observer) {
56
- schema = schema || Class.SCHEMA;
57
- let instance = Observer.instances[schema];
58
- if (!instance) {
59
- instance = new Class({schema});
60
- Observer.instances[schema] = instance;
61
- }
62
- return instance;
63
- }
64
-
65
- initilize = () => {};
66
-
67
- notify = (state: any) => {
68
- this.subject.notify(state);
69
- };
70
-
71
- attach = (observer: any) => {
72
- this.subject.attach(observer);
73
- return new ObserverInstance({observer, detach: this.detach});
74
- };
75
-
76
- detach = (observer: any) => {
77
- this.subject.detach(observer);
78
- };
79
- }
@@ -1,27 +0,0 @@
1
- import React, {useContext, useEffect} from 'react';
2
- import {ScreenParams} from './types';
3
- import Navigation from './Navigation';
4
- import {ApplicationContext} from './NavigationContainer';
5
-
6
- const StackScreen: React.FC<any> = props => {
7
- const {route, navigation} = props;
8
- const {screen: Component, options}: ScreenParams = route.params;
9
- const {theme, navigator} = useContext(ApplicationContext);
10
-
11
- const params = {
12
- ...route.params,
13
- navigation: new Navigation(navigation, theme),
14
- };
15
-
16
- delete params.screen;
17
-
18
- useEffect(() => {
19
- if (options) {
20
- params.navigation.setOptions(options);
21
- }
22
- }, [options]);
23
-
24
- return <Component {...params} />;
25
- };
26
-
27
- export default StackScreen;
@@ -1,14 +0,0 @@
1
- import {NavigationContainer, ApplicationContext} from './NavigationContainer';
2
- import ScreenContainer from '../Layout/ScreenContainer';
3
- import NavigationButton from './NavigationButton';
4
- import {HeaderRightAction} from './Components';
5
- import BottomTab from './BottomTab';
6
-
7
- export {
8
- NavigationContainer,
9
- ApplicationContext,
10
- ScreenContainer,
11
- NavigationButton,
12
- HeaderRightAction,
13
- BottomTab,
14
- };
@@ -1,137 +0,0 @@
1
- import React from 'react';
2
- import {
3
- StackNavigationOptions,
4
- TransitionPresets,
5
- } from '@react-navigation/stack';
6
- import {
7
- HeaderBackground,
8
- HeaderCustom,
9
- HeaderLeft,
10
- HeaderTitle,
11
- HeaderToolkitAction,
12
- } from './Components';
13
- import {NavigationOptions, Theme} from './types';
14
- import {Colors} from '../Consts';
15
-
16
- const getTintColor = (theme: Theme): any => {
17
- if (theme.assets?.headerBackground) {
18
- return {
19
- headerTintColor: Colors.black_01,
20
- };
21
- }
22
- return {
23
- headerTintColor: theme.colors.text.default,
24
- };
25
- };
26
-
27
- const getStackOptions = (theme: Theme): StackNavigationOptions => {
28
- return {
29
- headerTitleAlign: 'center',
30
- headerTitle: HeaderTitle,
31
- headerBackground: HeaderBackground,
32
- headerLeft: (props: any) => <HeaderLeft {...props} />,
33
- headerRight: (props: any) => <HeaderToolkitAction {...props} />,
34
- ...getTintColor(theme),
35
- };
36
- };
37
-
38
- const getDialogOptions = (theme: Theme): StackNavigationOptions => {
39
- return {
40
- headerTitleAlign: 'center',
41
- headerTitle: HeaderTitle,
42
- headerLeft: (props: any) => <HeaderLeft {...props} />,
43
- headerBackground: HeaderBackground,
44
- ...getTintColor(theme),
45
- ...TransitionPresets.ModalTransition,
46
- };
47
- };
48
-
49
- const getModalOptions = (): StackNavigationOptions => {
50
- return {
51
- headerShown: false,
52
- headerBackground: undefined,
53
- cardStyle: {backgroundColor: 'transparent'},
54
- cardOverlayEnabled: true,
55
- animationEnabled: false,
56
- cardStyleInterpolator: ({current: {progress}}) => ({
57
- cardStyle: {
58
- opacity: progress.interpolate({
59
- inputRange: [0, 0.5, 0.9, 1],
60
- outputRange: [0, 0.25, 0.7, 1],
61
- }),
62
- },
63
- overlayStyle: {
64
- opacity: progress.interpolate({
65
- inputRange: [0, 0.5, 0.9, 1],
66
- outputRange: [0, 0.2, 0.4, 0.6],
67
- extrapolate: 'clamp',
68
- }),
69
- },
70
- }),
71
- };
72
- };
73
-
74
- const getOptions = (params: NavigationOptions, theme: Theme) => {
75
- let backgroundProps = {};
76
- let titleProps = {};
77
- let options = {};
78
-
79
- if (params.preventBack) {
80
- options = {
81
- ...options,
82
- headerLeft: (props: any) => (
83
- <HeaderLeft {...props} preventBack={params.preventBack} />
84
- ),
85
- };
86
- }
87
- if (params.surface == true) {
88
- options = {
89
- ...options,
90
- ...getTintColor({
91
- ...theme,
92
- assets: {...theme.assets, headerBackground: undefined},
93
- }),
94
- };
95
- backgroundProps = {
96
- ...backgroundProps,
97
- image: null,
98
- backgroundColor: theme.colors.background.surface,
99
- };
100
- } else {
101
- backgroundProps = {};
102
- options = {...options, ...getTintColor(theme)};
103
- }
104
-
105
- if (params.animatedValue) {
106
- backgroundProps = {...backgroundProps, animatedValue: params.animatedValue};
107
- titleProps = {...titleProps, animatedValue: params.animatedValue};
108
- options = {...options, headerTransparent: true};
109
- } else {
110
- options = {...options, headerTransparent: false};
111
- }
112
-
113
- if (params.customTitle) {
114
- options = {
115
- ...options,
116
- headerTitleAlign: 'left',
117
- headerTitle: (props: any) => {
118
- return <HeaderCustom {...params.customTitle} {...props} />;
119
- },
120
- };
121
- } else {
122
- options = {
123
- ...options,
124
- headerTitle: (props: any) => {
125
- return <HeaderTitle {...titleProps} {...props} />;
126
- },
127
- };
128
- }
129
-
130
- return {
131
- ...params,
132
- ...options,
133
- headerBackground: () => <HeaderBackground {...backgroundProps} />,
134
- };
135
- };
136
-
137
- export {getStackOptions, getDialogOptions, getModalOptions, getOptions};