@prototyp/skeletor 1.0.2
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/.eslintrc.json +19 -0
- package/.github/CODEOWNERS +2 -0
- package/.gitignore +5 -0
- package/README.md +418 -0
- package/lib/module/components/Block/Block.js +71 -0
- package/lib/module/components/Block/Block.js.map +1 -0
- package/lib/module/components/Block/index.js +2 -0
- package/lib/module/components/Block/index.js.map +1 -0
- package/lib/module/components/InputFocusScrollView/InputFocusScrollView.js +93 -0
- package/lib/module/components/InputFocusScrollView/InputFocusScrollView.js.map +1 -0
- package/lib/module/components/InputFocusScrollView/index.js +2 -0
- package/lib/module/components/InputFocusScrollView/index.js.map +1 -0
- package/lib/module/components/Screen/Screen.js +55 -0
- package/lib/module/components/Screen/Screen.js.map +1 -0
- package/lib/module/components/Screen/index.js +2 -0
- package/lib/module/components/Screen/index.js.map +1 -0
- package/lib/module/components/SkeletorProvider/SkeletorContext.js +9 -0
- package/lib/module/components/SkeletorProvider/SkeletorContext.js.map +1 -0
- package/lib/module/components/SkeletorProvider/SkeletorProvider.js +17 -0
- package/lib/module/components/SkeletorProvider/SkeletorProvider.js.map +1 -0
- package/lib/module/components/SkeletorProvider/index.js +3 -0
- package/lib/module/components/SkeletorProvider/index.js.map +1 -0
- package/lib/module/components/Text/Text.js +64 -0
- package/lib/module/components/Text/Text.js.map +1 -0
- package/lib/module/components/Text/index.js +2 -0
- package/lib/module/components/Text/index.js.map +1 -0
- package/lib/module/components/index.js +6 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/hooks/index.js +7 -0
- package/lib/module/hooks/index.js.map +1 -0
- package/lib/module/hooks/useAndroidBackHandler.js +24 -0
- package/lib/module/hooks/useAndroidBackHandler.js.map +1 -0
- package/lib/module/hooks/useAnimation.js +33 -0
- package/lib/module/hooks/useAnimation.js.map +1 -0
- package/lib/module/hooks/useAnimationTimeline.js +97 -0
- package/lib/module/hooks/useAnimationTimeline.js.map +1 -0
- package/lib/module/hooks/useAppState.js +21 -0
- package/lib/module/hooks/useAppState.js.map +1 -0
- package/lib/module/hooks/useForm.js +159 -0
- package/lib/module/hooks/useForm.js.map +1 -0
- package/lib/module/hooks/useSkeletor.js +6 -0
- package/lib/module/hooks/useSkeletor.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/models/Alignment.js +2 -0
- package/lib/module/models/Alignment.js.map +1 -0
- package/lib/module/models/Border.js +2 -0
- package/lib/module/models/Border.js.map +1 -0
- package/lib/module/models/Size.js +2 -0
- package/lib/module/models/Size.js.map +1 -0
- package/lib/module/models/SkeletorConfig.js +2 -0
- package/lib/module/models/SkeletorConfig.js.map +1 -0
- package/lib/module/models/Spacing.js +2 -0
- package/lib/module/models/Spacing.js.map +1 -0
- package/lib/module/models/index.js +6 -0
- package/lib/module/models/index.js.map +1 -0
- package/lib/module/types/Font.d.js +2 -0
- package/lib/module/types/Font.d.js.map +1 -0
- package/lib/module/utils/extractAlignmentProperties.js +10 -0
- package/lib/module/utils/extractAlignmentProperties.js.map +1 -0
- package/lib/module/utils/extractSizeProperties.js +12 -0
- package/lib/module/utils/extractSizeProperties.js.map +1 -0
- package/lib/module/utils/index.js +3 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/typescript/lib/module/components/Block/Block.d.ts +4 -0
- package/lib/typescript/lib/module/components/Block/Block.d.ts.map +1 -0
- package/lib/typescript/lib/module/components/Block/index.d.ts +2 -0
- package/lib/typescript/lib/module/components/Block/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/components/InputFocusScrollView/InputFocusScrollView.d.ts +4 -0
- package/lib/typescript/lib/module/components/InputFocusScrollView/InputFocusScrollView.d.ts.map +1 -0
- package/lib/typescript/lib/module/components/InputFocusScrollView/index.d.ts +2 -0
- package/lib/typescript/lib/module/components/InputFocusScrollView/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/components/Screen/Screen.d.ts +5 -0
- package/lib/typescript/lib/module/components/Screen/Screen.d.ts.map +1 -0
- package/lib/typescript/lib/module/components/Screen/index.d.ts +2 -0
- package/lib/typescript/lib/module/components/Screen/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/components/SkeletorProvider/SkeletorContext.d.ts +14 -0
- package/lib/typescript/lib/module/components/SkeletorProvider/SkeletorContext.d.ts.map +1 -0
- package/lib/typescript/lib/module/components/SkeletorProvider/SkeletorProvider.d.ts +8 -0
- package/lib/typescript/lib/module/components/SkeletorProvider/SkeletorProvider.d.ts.map +1 -0
- package/lib/typescript/lib/module/components/SkeletorProvider/index.d.ts +3 -0
- package/lib/typescript/lib/module/components/SkeletorProvider/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/components/Text/Text.d.ts +4 -0
- package/lib/typescript/lib/module/components/Text/Text.d.ts.map +1 -0
- package/lib/typescript/lib/module/components/Text/index.d.ts +2 -0
- package/lib/typescript/lib/module/components/Text/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/components/index.d.ts +6 -0
- package/lib/typescript/lib/module/components/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/hooks/index.d.ts +7 -0
- package/lib/typescript/lib/module/hooks/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/hooks/useAndroidBackHandler.d.ts +2 -0
- package/lib/typescript/lib/module/hooks/useAndroidBackHandler.d.ts.map +1 -0
- package/lib/typescript/lib/module/hooks/useAnimation.d.ts +9 -0
- package/lib/typescript/lib/module/hooks/useAnimation.d.ts.map +1 -0
- package/lib/typescript/lib/module/hooks/useAnimationTimeline.d.ts +10 -0
- package/lib/typescript/lib/module/hooks/useAnimationTimeline.d.ts.map +1 -0
- package/lib/typescript/lib/module/hooks/useAppState.d.ts +2 -0
- package/lib/typescript/lib/module/hooks/useAppState.d.ts.map +1 -0
- package/lib/typescript/lib/module/hooks/useForm.d.ts +33 -0
- package/lib/typescript/lib/module/hooks/useForm.d.ts.map +1 -0
- package/lib/typescript/lib/module/hooks/useSkeletor.d.ts +7 -0
- package/lib/typescript/lib/module/hooks/useSkeletor.d.ts.map +1 -0
- package/lib/typescript/lib/module/index.d.ts +5 -0
- package/lib/typescript/lib/module/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/models/Alignment.d.ts +2 -0
- package/lib/typescript/lib/module/models/Alignment.d.ts.map +1 -0
- package/lib/typescript/lib/module/models/Border.d.ts +1 -0
- package/lib/typescript/lib/module/models/Border.d.ts.map +1 -0
- package/lib/typescript/lib/module/models/Size.d.ts +1 -0
- package/lib/typescript/lib/module/models/Size.d.ts.map +1 -0
- package/lib/typescript/lib/module/models/SkeletorConfig.d.ts +1 -0
- package/lib/typescript/lib/module/models/SkeletorConfig.d.ts.map +1 -0
- package/lib/typescript/lib/module/models/Spacing.d.ts +1 -0
- package/lib/typescript/lib/module/models/Spacing.d.ts.map +1 -0
- package/lib/typescript/lib/module/models/index.d.ts +2 -0
- package/lib/typescript/lib/module/models/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/types/Font.d.d.ts +1 -0
- package/lib/typescript/lib/module/types/Font.d.d.ts.map +1 -0
- package/lib/typescript/lib/module/utils/extractAlignmentProperties.d.ts +8 -0
- package/lib/typescript/lib/module/utils/extractAlignmentProperties.d.ts.map +1 -0
- package/lib/typescript/lib/module/utils/extractSizeProperties.d.ts +10 -0
- package/lib/typescript/lib/module/utils/extractSizeProperties.d.ts.map +1 -0
- package/lib/typescript/lib/module/utils/index.d.ts +3 -0
- package/lib/typescript/lib/module/utils/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Block/Block.d.ts +23 -0
- package/lib/typescript/src/components/Block/Block.d.ts.map +1 -0
- package/lib/typescript/src/components/Block/index.d.ts +2 -0
- package/lib/typescript/src/components/Block/index.d.ts.map +1 -0
- package/lib/typescript/src/components/InputFocusScrollView/InputFocusScrollView.d.ts +18 -0
- package/lib/typescript/src/components/InputFocusScrollView/InputFocusScrollView.d.ts.map +1 -0
- package/lib/typescript/src/components/InputFocusScrollView/index.d.ts +2 -0
- package/lib/typescript/src/components/InputFocusScrollView/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Screen/Screen.d.ts +16 -0
- package/lib/typescript/src/components/Screen/Screen.d.ts.map +1 -0
- package/lib/typescript/src/components/Screen/index.d.ts +2 -0
- package/lib/typescript/src/components/Screen/index.d.ts.map +1 -0
- package/lib/typescript/src/components/SkeletorProvider/SkeletorContext.d.ts +5 -0
- package/lib/typescript/src/components/SkeletorProvider/SkeletorContext.d.ts.map +1 -0
- package/lib/typescript/src/components/SkeletorProvider/SkeletorProvider.d.ts +8 -0
- package/lib/typescript/src/components/SkeletorProvider/SkeletorProvider.d.ts.map +1 -0
- package/lib/typescript/src/components/SkeletorProvider/index.d.ts +3 -0
- package/lib/typescript/src/components/SkeletorProvider/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Text/Text.d.ts +21 -0
- package/lib/typescript/src/components/Text/Text.d.ts.map +1 -0
- package/lib/typescript/src/components/Text/index.d.ts +2 -0
- package/lib/typescript/src/components/Text/index.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +6 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/index.d.ts +7 -0
- package/lib/typescript/src/hooks/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useAndroidBackHandler.d.ts +16 -0
- package/lib/typescript/src/hooks/useAndroidBackHandler.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useAnimation.d.ts +20 -0
- package/lib/typescript/src/hooks/useAnimation.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useAnimationTimeline.d.ts +30 -0
- package/lib/typescript/src/hooks/useAnimationTimeline.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useAppState.d.ts +7 -0
- package/lib/typescript/src/hooks/useAppState.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useForm.d.ts +52 -0
- package/lib/typescript/src/hooks/useForm.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useSkeletor.d.ts +3 -0
- package/lib/typescript/src/hooks/useSkeletor.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +5 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/models/Alignment.d.ts +9 -0
- package/lib/typescript/src/models/Alignment.d.ts.map +1 -0
- package/lib/typescript/src/models/Border.d.ts +16 -0
- package/lib/typescript/src/models/Border.d.ts.map +1 -0
- package/lib/typescript/src/models/Size.d.ts +10 -0
- package/lib/typescript/src/models/Size.d.ts.map +1 -0
- package/lib/typescript/src/models/SkeletorConfig.d.ts +7 -0
- package/lib/typescript/src/models/SkeletorConfig.d.ts.map +1 -0
- package/lib/typescript/src/models/Spacing.d.ts +21 -0
- package/lib/typescript/src/models/Spacing.d.ts.map +1 -0
- package/lib/typescript/src/models/index.d.ts +6 -0
- package/lib/typescript/src/models/index.d.ts.map +1 -0
- package/lib/typescript/src/utils/extractAlignmentProperties.d.ts +3 -0
- package/lib/typescript/src/utils/extractAlignmentProperties.d.ts.map +1 -0
- package/lib/typescript/src/utils/extractSizeProperties.d.ts +3 -0
- package/lib/typescript/src/utils/extractSizeProperties.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +3 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -0
- package/package.json +63 -0
- package/prototyp-skeletor-v1.0.0.tgz +0 -0
- package/src/components/Block/Block.tsx +106 -0
- package/src/components/Block/index.ts +1 -0
- package/src/components/InputFocusScrollView/InputFocusScrollView.tsx +120 -0
- package/src/components/InputFocusScrollView/index.ts +1 -0
- package/src/components/Screen/Screen.tsx +91 -0
- package/src/components/Screen/index.ts +1 -0
- package/src/components/SkeletorProvider/SkeletorContext.ts +12 -0
- package/src/components/SkeletorProvider/SkeletorProvider.tsx +18 -0
- package/src/components/SkeletorProvider/index.ts +2 -0
- package/src/components/Text/Text.tsx +99 -0
- package/src/components/Text/index.ts +1 -0
- package/src/components/index.ts +5 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/useAndroidBackHandler.ts +45 -0
- package/src/hooks/useAnimation.ts +62 -0
- package/src/hooks/useAnimationTimeline.ts +139 -0
- package/src/hooks/useAppState.ts +26 -0
- package/src/hooks/useForm.ts +190 -0
- package/src/hooks/useSkeletor.ts +7 -0
- package/src/index.ts +4 -0
- package/src/models/Alignment.ts +9 -0
- package/src/models/Border.ts +15 -0
- package/src/models/Size.ts +9 -0
- package/src/models/SkeletorConfig.ts +6 -0
- package/src/models/Spacing.ts +20 -0
- package/src/models/index.ts +5 -0
- package/src/types/Font.d.ts +1 -0
- package/src/utils/extractAlignmentProperties.ts +13 -0
- package/src/utils/extractSizeProperties.ts +13 -0
- package/src/utils/index.ts +2 -0
- package/tsconfig.json +16 -0
- package/yarn.lock +6080 -0
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@react-native-community",
|
|
3
|
+
"parser": "@typescript-eslint/parser",
|
|
4
|
+
"plugins": ["@typescript-eslint", "import", "prettier"],
|
|
5
|
+
"rules": {
|
|
6
|
+
"quotes": ["error", "double", { "avoidEscape": true }],
|
|
7
|
+
"react-hooks/exhaustive-deps": "off"
|
|
8
|
+
},
|
|
9
|
+
"overrides": [
|
|
10
|
+
{
|
|
11
|
+
"files": ["*.ts", "*.tsx"],
|
|
12
|
+
"rules": {
|
|
13
|
+
"@typescript-eslint/no-shadow": ["error"],
|
|
14
|
+
"no-shadow": "off",
|
|
15
|
+
"no-undef": "off"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
package/.gitignore
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
### Welcome to Skeletor
|
|
2
|
+
|
|
3
|
+
#### Our small in-house react-native toolkit to make your life easier
|
|
4
|
+
|
|
5
|
+
## Project setup
|
|
6
|
+
|
|
7
|
+
Since this is supposed to be as configurable as possible while still maintaining some form and structure with how things should be done, you'll have to set up a couple things first.
|
|
8
|
+
|
|
9
|
+
### Initialize Skeletor
|
|
10
|
+
|
|
11
|
+
Add the SkeletorProvider component as the (or one of) top wrapper of your application. Example:
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
/// index.js
|
|
15
|
+
const App = () => {
|
|
16
|
+
return (
|
|
17
|
+
<SkeletorProvider>
|
|
18
|
+
<StoreProvider>
|
|
19
|
+
<RootNavigator />
|
|
20
|
+
</StoreProvider>
|
|
21
|
+
</SkeletorProvider>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Configure the SkeletorProvider properties with whatever you desire. Here is the list of all configurable properties for the SkeletorProvider component:
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
type SkeletorConfig = {
|
|
30
|
+
defaultFont: Font,
|
|
31
|
+
defaultFontSize: number,
|
|
32
|
+
defaultStatusBarType: "dark-content" | "light-content" | "default",
|
|
33
|
+
};
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
For Skeletor to detect the fonts you have added, you will have to create a type defintion file to override the existing Font type like in the following example:
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
/// @types/Font.d.ts
|
|
40
|
+
type Font = "Helvetica" | "Roboto" | "San Francisco";
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Then you can configure the `defaultFont` property as follows:
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
<SkeletorProvider defaultFont="Arial">...</SkeletorProvider>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
To get access to the skeletor styles in other components, you can use the provided `useSkeletor` hook that will return the entire Skeletor configuration object. For instance:
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
const skeletor = useSkeletor();
|
|
53
|
+
return <SomeComponent style={{ fontFamily: skeletor.defaultFont }} />;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Components
|
|
57
|
+
|
|
58
|
+
### Screen
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
Use this as the top-level wrapper for every screen you navigate to. Is not intended as a wrapper for other components, as you may deduce from the name.
|
|
63
|
+
|
|
64
|
+
#### Props
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
/** Pass a specific background view (gradients, animated backgrounds etc) OR just a background color value. Custom components should be 100% height and width to span the full screen area. */
|
|
68
|
+
background?: JSX.Element | string;
|
|
69
|
+
hideTopSafeArea?: boolean;
|
|
70
|
+
hideBottomSafeArea?: boolean;
|
|
71
|
+
/** Set bottom safe area background color */
|
|
72
|
+
bottomSafeAreaColor?: string;
|
|
73
|
+
/** Set top safe area background color */
|
|
74
|
+
topSafeAreaColor?: string;
|
|
75
|
+
/** Set device status bar color type. */
|
|
76
|
+
statusBarType?: "default" | "light-content" | "dark-content";
|
|
77
|
+
isLandscape?: boolean;
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### Usage
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
function Component: React.FC = () => {
|
|
84
|
+
return <Screen background={<GradientBackground />} statusBarType="dark-content">
|
|
85
|
+
...
|
|
86
|
+
</Screen>
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Text
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
Will detect configured Font type, built with the ability to easily customize the font in use, font size, line height, letter spacing and other quick-access props so you do not have to create separate styles. <b>Hint:</b> Wrap `Text` components into `Block` components so they wrap correctly within a layout.
|
|
95
|
+
|
|
96
|
+
#### Props
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
/** Inferred from @types/Font.d.ts */
|
|
100
|
+
font?: Font;
|
|
101
|
+
/** Either define [fontSize, lineHeight] or just one size applied to both fontSize and lineHeight */
|
|
102
|
+
size?: [number, number] | number;
|
|
103
|
+
textTransform?: TextStyle["textTransform"];
|
|
104
|
+
letterSpacing?: TextStyle["letterSpacing"];
|
|
105
|
+
color?: string;
|
|
106
|
+
textAlign?: TextStyle["textAlign"];
|
|
107
|
+
opacity?: TextStyle["opacity"];
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### Usage
|
|
111
|
+
|
|
112
|
+
To use the `Text` component, simply import it and pass in the desired props.
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
import { Text } from "./Text";
|
|
116
|
+
|
|
117
|
+
function MyComponent() {
|
|
118
|
+
return (
|
|
119
|
+
<Text font="Arial" size={[14, 18]} color="#333" textAlign="center">
|
|
120
|
+
Hello World!
|
|
121
|
+
</Text>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Block
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
This is a flexible and customizable React Native component that can be used as either a `View` or a `ScrollView`. The `Block` component allows you to add paddings, margins, sizes, alignments, and borders to your layout. Extends `ScrollViewProps` or `ViewProps` depending on the value of the `scrollable` prop.
|
|
131
|
+
|
|
132
|
+
#### Props
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
/** Determine if Block is scrollable or not. If scrollable, extends ScrollView props. */
|
|
136
|
+
scrollable?: boolean;
|
|
137
|
+
align?: ViewStyle["alignItems"];
|
|
138
|
+
alignSelf?: ViewStyle["alignSelf"];
|
|
139
|
+
justify?: ViewStyle["justifyContent"];
|
|
140
|
+
flexDirection?: ViewStyle["flexDirection"];
|
|
141
|
+
flexWrap?: ViewStyle["flexWrap"];
|
|
142
|
+
flex?: number;
|
|
143
|
+
width?: number | string;
|
|
144
|
+
height?: number | string;
|
|
145
|
+
minHeight?: number | string;
|
|
146
|
+
minWidth?: number | string;
|
|
147
|
+
maxHeight?: number | string;
|
|
148
|
+
maxWidth?: number | string;
|
|
149
|
+
margins?: {
|
|
150
|
+
marginTop?: number | string;
|
|
151
|
+
marginBottom?: number | string;
|
|
152
|
+
marginLeft?: number | string;
|
|
153
|
+
marginRight?: number | string;
|
|
154
|
+
marginHorizontal?: number | string;
|
|
155
|
+
marginVertical?: number | string;
|
|
156
|
+
margin?: number | string;
|
|
157
|
+
};
|
|
158
|
+
paddings?: {
|
|
159
|
+
paddingTop?: number | string;
|
|
160
|
+
paddingBottom?: number | string;
|
|
161
|
+
paddingLeft?: number | string;
|
|
162
|
+
paddingRight?: number | string;
|
|
163
|
+
paddingHorizontal?: number | string;
|
|
164
|
+
paddingVertical?: number | string;
|
|
165
|
+
padding?: number | string;
|
|
166
|
+
};
|
|
167
|
+
border?: {
|
|
168
|
+
borderWidth?: number;
|
|
169
|
+
borderTopWidth?: number;
|
|
170
|
+
borderBottomWidth?: number;
|
|
171
|
+
borderLeftWidth?: number;
|
|
172
|
+
borderRightWidth?: number;
|
|
173
|
+
borderColor?: string;
|
|
174
|
+
borderRadius?: number;
|
|
175
|
+
borderTopLeftRadius?: number;
|
|
176
|
+
borderTopRightRadius?: number;
|
|
177
|
+
borderBottomLeftRadius?: number;
|
|
178
|
+
borderBottomRightRadius?: number;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
#### Usage
|
|
184
|
+
|
|
185
|
+
Use cases are many, but simple. This component is intended to be used as a building block for your layout. One example is:
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
<Block
|
|
189
|
+
maxHeight="75%"
|
|
190
|
+
flexDirection="row"
|
|
191
|
+
align="flex-start"
|
|
192
|
+
justify="space-between"
|
|
193
|
+
>
|
|
194
|
+
... ...
|
|
195
|
+
</Block>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### InputFocusScrollView - iOS ONLY
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
This scroll view will automatically scroll to an active input field rendered inside it, provided you attach the `onInputFocus` callback to the input `onFocus` prop. This is a lambda component, returning a callback which you attach to input fields rendered within it.
|
|
203
|
+
|
|
204
|
+
<b>NOTE</b> — This works on iOS only, Android does this by default with `android:windowSoftInputMode`
|
|
205
|
+
|
|
206
|
+
#### Props
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
/** Decimal value of screen height percentage the input will be positioned at. */
|
|
210
|
+
/** Defaults to 0.3, just above the keyboard. */
|
|
211
|
+
focusPositionOffset?: number;
|
|
212
|
+
/** Is the scrollview 100% in height or automatic. Defaults to auto. */
|
|
213
|
+
height?: "full" | "auto";
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
#### Usage
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
<InputFocusScrollView focusPositionOffset={0.1}>
|
|
220
|
+
{(onInputFocus) => (
|
|
221
|
+
...
|
|
222
|
+
<Input
|
|
223
|
+
keyboardType="email-address"
|
|
224
|
+
returnKeyType="next"
|
|
225
|
+
placeholder="Your e-mail address"
|
|
226
|
+
label="E-mail Address"
|
|
227
|
+
emptyMessage="You must enter an e-mail."
|
|
228
|
+
errorMessage="E-mail is invalid."
|
|
229
|
+
value={state.email}
|
|
230
|
+
valid={validation.email}
|
|
231
|
+
onFocus={onInputFocus}
|
|
232
|
+
onChangeText={(text) => update("email", text)}
|
|
233
|
+
onSubmitEditing={() => passwordRef.current?.focus()}
|
|
234
|
+
/>
|
|
235
|
+
...
|
|
236
|
+
)}
|
|
237
|
+
</InputFocusScrollView>
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Hooks
|
|
241
|
+
|
|
242
|
+
### useForm & useFormUtils
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
Handle form value updates and validation with `useForm`. Full TypeScript support, ability to configure optional parameters, custom validation rules.
|
|
247
|
+
|
|
248
|
+
Flexible in its function, supports multiple validation approaches through callbacks:
|
|
249
|
+
|
|
250
|
+
1. For on-change validation, use `update("prop", value, true)`
|
|
251
|
+
2. To trigger standalone validation, use `validate("prop")`
|
|
252
|
+
3. Validate entire form with `validateForm()`
|
|
253
|
+
|
|
254
|
+
#### Example 1: Simple use case with standalone validation on blur:
|
|
255
|
+
|
|
256
|
+
```javascript
|
|
257
|
+
const {state, validation, update, validate} = useForm({email: "", password: "");
|
|
258
|
+
|
|
259
|
+
...
|
|
260
|
+
<Input
|
|
261
|
+
keyboardType="email-address"
|
|
262
|
+
returnKeyType="next"
|
|
263
|
+
label="E-mail Address"
|
|
264
|
+
errorMessage="Email is not valid."
|
|
265
|
+
emptyMessage="Email is a required field."
|
|
266
|
+
placeholder="What's your email address?"
|
|
267
|
+
value={state.email}
|
|
268
|
+
textContentType="emailAddress"
|
|
269
|
+
valid={validation.email}
|
|
270
|
+
onChangeText={(text) => update("email", text)}
|
|
271
|
+
onBlur={() => validate("email")}
|
|
272
|
+
/>
|
|
273
|
+
...
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
#### Example 2: Simple use case with on-change validation:
|
|
277
|
+
|
|
278
|
+
```javascript
|
|
279
|
+
// See example 1
|
|
280
|
+
...
|
|
281
|
+
onChangeText={(text) => update("email", text, true)}
|
|
282
|
+
...
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
#### Example 3: Simple use case with on-submit validation:
|
|
286
|
+
|
|
287
|
+
```javascript
|
|
288
|
+
// See example 1
|
|
289
|
+
|
|
290
|
+
function submit() {
|
|
291
|
+
if(!validateForm()) {
|
|
292
|
+
// Throw invalid error
|
|
293
|
+
// validation object will be populated
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
...
|
|
298
|
+
<Input
|
|
299
|
+
keyboardType="email-address"
|
|
300
|
+
returnKeyType="next"
|
|
301
|
+
label="E-mail Address"
|
|
302
|
+
errorMessage="Email is not valid."
|
|
303
|
+
emptyMessage="Email is a required field."
|
|
304
|
+
placeholder="What's your email address?"
|
|
305
|
+
value={state.email}
|
|
306
|
+
textContentType="emailAddress"
|
|
307
|
+
valid={validation.email}
|
|
308
|
+
onChangeText={(text) => update("email", text)}
|
|
309
|
+
/>
|
|
310
|
+
<Button onPress={submit}>Submit</Button>
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
#### Example 4: Form configuration
|
|
314
|
+
|
|
315
|
+
```javascript
|
|
316
|
+
const { state, validation, update, validate } = useForm(
|
|
317
|
+
{ firstName: "", middleName: "", lastName: ""},
|
|
318
|
+
{
|
|
319
|
+
// If left empty, validation.middleName will be true
|
|
320
|
+
optional: ["middleName"],
|
|
321
|
+
// validation.lastName is invalid if lastName is <3 characters long
|
|
322
|
+
// state can be used to compare with other values (ie repeat password)
|
|
323
|
+
rules: { lastName: (value, state) => value.length >= 3,
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
#### Example 5: useFormUtils
|
|
328
|
+
|
|
329
|
+
Utility functions to help with standalone state validation, such as when re-validating a list of form values in a parent components.
|
|
330
|
+
|
|
331
|
+
```javascript
|
|
332
|
+
const { stateValidation } = useFormUtils<Person>();
|
|
333
|
+
|
|
334
|
+
function validatePeople() {
|
|
335
|
+
return people.every(person => stateValidation(person).valid);
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
Other utilities: `doesValueExist`, `validateByRule`, `isOptional`, `fieldValidation`, `stateValidation`. Some are meant for internal `useForm` usage, such as `fieldValidation` and `validateByRule`, but are not unusable.
|
|
340
|
+
|
|
341
|
+
### useAnimation & useAnimationTimeline
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
`useAnimation` helps you quickly create simple animations and transitions using the default react-native animation toolkit. You can define as many animations as possible for a single element with a single invocation of the hook.
|
|
346
|
+
|
|
347
|
+
`useAnimationTimeline` is used to lay the defined animations out on a timeline and configure when and how each animation is triggered. Available methods are `stagger`, `parallel`, `sequence`, `delay`.
|
|
348
|
+
|
|
349
|
+
#### Usage
|
|
350
|
+
|
|
351
|
+
```javascript
|
|
352
|
+
const inputs = useAnimation(...);
|
|
353
|
+
const heading = useAnimation(
|
|
354
|
+
{opacity: [0, 1], translateY: [20, 0]},
|
|
355
|
+
{duration: 400},
|
|
356
|
+
);
|
|
357
|
+
|
|
358
|
+
// Use this hook to lay the animations out in a specific schedule/timeline.
|
|
359
|
+
useAnimTimeline({
|
|
360
|
+
stagger: {
|
|
361
|
+
elements: [heading, inputs],
|
|
362
|
+
stagger: 200,
|
|
363
|
+
start: true,
|
|
364
|
+
},
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
...
|
|
368
|
+
|
|
369
|
+
// Transformations cannot be applied outside the transform style.
|
|
370
|
+
// so translateY has to be passed in through the transform style prop.
|
|
371
|
+
<Animated.View
|
|
372
|
+
style={{
|
|
373
|
+
...heading.animations,
|
|
374
|
+
transform: [{translateY: heading.animations.translateY}],
|
|
375
|
+
}}
|
|
376
|
+
>
|
|
377
|
+
...
|
|
378
|
+
</Animated.View>
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### useAndroidBackHandler
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
Handle how the android back button behaves through enabling / disabling the button or passing in a completely custom callback. External `enabled` control in order to be able to mount / unmount the back handler event based on outside integrations, such as checking if the current screen is focused or not with `react-navigation`. Will always be cleared on unmount.
|
|
386
|
+
|
|
387
|
+
#### Usage
|
|
388
|
+
|
|
389
|
+
```javascript
|
|
390
|
+
const Component: React.FC = () => {
|
|
391
|
+
useAndroidBackHandler({
|
|
392
|
+
handlePress: () => setOpenCancelModal(true),
|
|
393
|
+
enabled: !openCancelModal && isFocused,
|
|
394
|
+
});
|
|
395
|
+
...
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### useAppState
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
Handle what happens when the application changes state between background and foreground. <b>Note:</b> Background states cannot be processed on Android, only foreground.
|
|
404
|
+
|
|
405
|
+
#### Usage
|
|
406
|
+
|
|
407
|
+
```javascript
|
|
408
|
+
useAppState({ onForeground: () => Alert.alert("Foreground") });
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
## Contributions
|
|
412
|
+
|
|
413
|
+
Suggestions and requests welcome, contributions appreciated but will be reviewed.
|
|
414
|
+
|
|
415
|
+
## Disclaimer
|
|
416
|
+
|
|
417
|
+
Parts of this readme file were generated with ChatGPT.
|
|
418
|
+
Thank you for making documentation easy for a lazy programmer.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
import React, { useMemo } from "react";
|
|
3
|
+
import { ScrollView, StyleSheet, View } from "react-native";
|
|
4
|
+
import { extractAlignmentProperties, extractSizeProperties } from "../../utils";
|
|
5
|
+
const BlockElement = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
...props
|
|
9
|
+
} = _ref;
|
|
10
|
+
const {
|
|
11
|
+
border,
|
|
12
|
+
paddings,
|
|
13
|
+
margins,
|
|
14
|
+
background,
|
|
15
|
+
style,
|
|
16
|
+
overflow,
|
|
17
|
+
...view
|
|
18
|
+
} = props;
|
|
19
|
+
const size = extractSizeProperties(props);
|
|
20
|
+
const {
|
|
21
|
+
align: alignItems,
|
|
22
|
+
justify: justifyContent,
|
|
23
|
+
...alignment
|
|
24
|
+
} = extractAlignmentProperties(props);
|
|
25
|
+
const styles = useMemo(() => StyleSheet.flatten([{
|
|
26
|
+
...margins,
|
|
27
|
+
...paddings,
|
|
28
|
+
...alignment,
|
|
29
|
+
...size,
|
|
30
|
+
...border,
|
|
31
|
+
alignItems,
|
|
32
|
+
justifyContent,
|
|
33
|
+
backgroundColor: background,
|
|
34
|
+
overflow
|
|
35
|
+
}, style]), [alignment, size, background, style, overflow, margins, paddings]);
|
|
36
|
+
return /*#__PURE__*/React.createElement(View, _extends({}, view, {
|
|
37
|
+
style: styles
|
|
38
|
+
}), children);
|
|
39
|
+
};
|
|
40
|
+
export const Block = _ref2 => {
|
|
41
|
+
let {
|
|
42
|
+
children,
|
|
43
|
+
...props
|
|
44
|
+
} = _ref2;
|
|
45
|
+
const {
|
|
46
|
+
scrollable,
|
|
47
|
+
...rest
|
|
48
|
+
} = props;
|
|
49
|
+
const element = () => /*#__PURE__*/React.createElement(BlockElement, rest, children);
|
|
50
|
+
if (!scrollable) {
|
|
51
|
+
return element();
|
|
52
|
+
}
|
|
53
|
+
const {
|
|
54
|
+
horizontal,
|
|
55
|
+
showsHorizontalScrollIndicator,
|
|
56
|
+
showsVerticalScrollIndicator,
|
|
57
|
+
bounces
|
|
58
|
+
} = props;
|
|
59
|
+
return /*#__PURE__*/React.createElement(ScrollView, {
|
|
60
|
+
horizontal: horizontal,
|
|
61
|
+
keyboardShouldPersistTaps: "handled",
|
|
62
|
+
showsHorizontalScrollIndicator: showsHorizontalScrollIndicator,
|
|
63
|
+
showsVerticalScrollIndicator: showsVerticalScrollIndicator,
|
|
64
|
+
contentContainerStyle: {
|
|
65
|
+
flexGrow: 1,
|
|
66
|
+
backgroundColor: rest.background
|
|
67
|
+
},
|
|
68
|
+
bounces: bounces
|
|
69
|
+
}, element());
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=Block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useMemo","ScrollView","StyleSheet","View","extractAlignmentProperties","extractSizeProperties","BlockElement","children","props","border","paddings","margins","background","style","overflow","view","size","align","alignItems","justify","justifyContent","alignment","styles","flatten","backgroundColor","Block","scrollable","rest","element","horizontal","showsHorizontalScrollIndicator","showsVerticalScrollIndicator","bounces","flexGrow"],"sourceRoot":"../../src","sources":["Block.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAuBC,OAAO,QAAQ,OAAO;AACzD,SACEC,UAAU,EAEVC,UAAU,EACVC,IAAI,QAGC,cAAc;AAErB,SAASC,0BAA0B,EAAEC,qBAAqB,QAAQ,aAAa;AAsB/E,MAAMC,YAA4D,GAAG,QAG/D;EAAA,IAHgE;IACpEC,QAAQ;IACR,GAAGC;EACL,CAAC;EACC,MAAM;IAAEC,M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IACnC,8BAA8B,EAAEC,8BAA+B;IAC/D,4BAA4B,EAAEC,4BAA6B;IAC3D,qBAAqB,EAAE;MAAEE,QAAQ,EAAE,CAAC;MAAET,eAAe,EAAEG,IAAI,CAACf;IAAW,CAAE;IACzE,OAAO,EAAEoB;EAAQ,GAEhBJ,OAAO,EAAE,CACC;AAEjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,cAAc,SAAS"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
import React, { useRef, useState } from "react";
|
|
3
|
+
import { Platform, ScrollView, StyleSheet, Dimensions } from "react-native";
|
|
4
|
+
/**
|
|
5
|
+
* This scroll view will automatically scroll to an active input field rendered within it, provided you attach the onInputFocus callback to the input onFocus prop.
|
|
6
|
+
*
|
|
7
|
+
* The return value is a lambda component, returning a callback which you attach to input fields rendered within it.
|
|
8
|
+
* @example <InputFocusScrollView>{(onInputFocus) => <TextInput onFocus={onInputFocus} ... />}</InputFocusScrollView>
|
|
9
|
+
* NOTE: This works on iOS only, Android does this by default with @param android:windowSoftInputMode
|
|
10
|
+
*/
|
|
11
|
+
export const InputFocusScrollView = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
children,
|
|
14
|
+
style,
|
|
15
|
+
contentContainerStyle,
|
|
16
|
+
height = "full",
|
|
17
|
+
focusPositionOffset = 0.3,
|
|
18
|
+
margins,
|
|
19
|
+
paddings,
|
|
20
|
+
...rest
|
|
21
|
+
} = _ref;
|
|
22
|
+
const screenHeight = useRef(Dimensions.get("screen").height).current;
|
|
23
|
+
const ref = useRef(null);
|
|
24
|
+
const [scrollTarget, setScrollTarget] = useState();
|
|
25
|
+
/** Cached scroll position to keep focus on input if layout shifts. */
|
|
26
|
+
const [scrollPosition, setScrollPosition] = useState();
|
|
27
|
+
function onInputFocus(e) {
|
|
28
|
+
if (Platform.OS !== "ios" || !scrollTarget) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
e.currentTarget.measureLayout(scrollTarget, (nope, top, nuuh, elementHeight) => {
|
|
32
|
+
var _ref$current;
|
|
33
|
+
let scrollY = top - elementHeight;
|
|
34
|
+
if (focusPositionOffset !== undefined) {
|
|
35
|
+
scrollY = scrollY - screenHeight * focusPositionOffset;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Cache scroll position for layout shift cases
|
|
39
|
+
setScrollPosition(scrollY);
|
|
40
|
+
// Scroll to input position
|
|
41
|
+
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.scrollTo({
|
|
42
|
+
y: scrollY
|
|
43
|
+
});
|
|
44
|
+
}, () => console.error("failed to measure layout"));
|
|
45
|
+
}
|
|
46
|
+
function onScrollViewLayout(e) {
|
|
47
|
+
if (Platform.OS !== "ios") {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
setScrollTarget(e.nativeEvent.target);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Handle layout shifts by programmatically scrolling to the same input position without animation. */
|
|
54
|
+
function onContentSizeChange() {
|
|
55
|
+
var _ref$current2;
|
|
56
|
+
if (Platform.OS !== "ios" || !scrollPosition) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
(_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.scrollTo({
|
|
60
|
+
y: scrollPosition,
|
|
61
|
+
animated: false
|
|
62
|
+
});
|
|
63
|
+
setScrollPosition(undefined);
|
|
64
|
+
}
|
|
65
|
+
const containerStyles = StyleSheet.flatten([styles[height], margins, style]);
|
|
66
|
+
const contentStyles = StyleSheet.flatten([styles.content, {
|
|
67
|
+
...paddings
|
|
68
|
+
}, contentContainerStyle]);
|
|
69
|
+
return /*#__PURE__*/React.createElement(ScrollView, _extends({
|
|
70
|
+
ref: ref,
|
|
71
|
+
scrollToOverflowEnabled: true,
|
|
72
|
+
scrollEventThrottle: 16,
|
|
73
|
+
onLayout: onScrollViewLayout,
|
|
74
|
+
onContentSizeChange: onContentSizeChange,
|
|
75
|
+
showsVerticalScrollIndicator: false,
|
|
76
|
+
showsHorizontalScrollIndicator: false,
|
|
77
|
+
style: containerStyles,
|
|
78
|
+
contentContainerStyle: contentStyles
|
|
79
|
+
}, rest), children(onInputFocus));
|
|
80
|
+
};
|
|
81
|
+
const styles = StyleSheet.create({
|
|
82
|
+
full: {
|
|
83
|
+
height: "100%"
|
|
84
|
+
},
|
|
85
|
+
auto: {
|
|
86
|
+
height: "auto"
|
|
87
|
+
},
|
|
88
|
+
content: {
|
|
89
|
+
flexGrow: 1,
|
|
90
|
+
paddingBottom: 30
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=InputFocusScrollView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useRef","useState","Platform","ScrollView","StyleSheet","Dimensions","InputFocusScrollView","children","style","contentContainerStyle","height","focusPositionOffset","margins","paddings","rest","screenHeight","get","current","ref","scrollTarget","setScrollTarget","scrollPosition","setScrollPosition","onInputFocus","e","OS","currentTarget","measureLayout","nope","top","nuuh","elementHeight","scrollY","undefined","scrollTo","y","console","error","onScrollViewLayout","nativeEvent","target","onContentSizeChange","animated","containerStyles","flatten","styles","contentStyles","content","create","full","auto","flexGrow","paddingBottom"],"sourceRoot":"../../src","sources":["InputFocusScrollView.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAuBC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAClE,SACEC,QAAQ,EAGRC,UAAU,EAEVC,UAAU,EAEVC,UAAU,QACL,cAAc;AAcrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OA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