rn-inputforge 0.1.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/LICENSE +21 -0
- package/README.md +273 -0
- package/lib/commonjs/components/ChatInput/ChatInput.js +170 -0
- package/lib/commonjs/components/ChatInput/ChatInput.js.map +1 -0
- package/lib/commonjs/components/ChatInput/index.js +13 -0
- package/lib/commonjs/components/ChatInput/index.js.map +1 -0
- package/lib/commonjs/components/ChatInput/types.js +6 -0
- package/lib/commonjs/components/ChatInput/types.js.map +1 -0
- package/lib/commonjs/components/DescriptionField/DescriptionField.js +40 -0
- package/lib/commonjs/components/DescriptionField/DescriptionField.js.map +1 -0
- package/lib/commonjs/components/DescriptionField/index.js +13 -0
- package/lib/commonjs/components/DescriptionField/index.js.map +1 -0
- package/lib/commonjs/components/FieldFlowInput/FieldFlowInput.js +207 -0
- package/lib/commonjs/components/FieldFlowInput/FieldFlowInput.js.map +1 -0
- package/lib/commonjs/components/FieldFlowInput/index.js +13 -0
- package/lib/commonjs/components/FieldFlowInput/index.js.map +1 -0
- package/lib/commonjs/components/FieldFlowInput/styles.js +99 -0
- package/lib/commonjs/components/FieldFlowInput/styles.js.map +1 -0
- package/lib/commonjs/components/FieldFlowInput/types.js +6 -0
- package/lib/commonjs/components/FieldFlowInput/types.js.map +1 -0
- package/lib/commonjs/components/KeyboardAwareFormWrapper/KeyboardAwareFormWrapper.js +44 -0
- package/lib/commonjs/components/KeyboardAwareFormWrapper/KeyboardAwareFormWrapper.js.map +1 -0
- package/lib/commonjs/components/KeyboardAwareFormWrapper/index.js +13 -0
- package/lib/commonjs/components/KeyboardAwareFormWrapper/index.js.map +1 -0
- package/lib/commonjs/hooks/index.js +27 -0
- package/lib/commonjs/hooks/index.js.map +1 -0
- package/lib/commonjs/hooks/useFieldFlowForm.js +108 -0
- package/lib/commonjs/hooks/useFieldFlowForm.js.map +1 -0
- package/lib/commonjs/hooks/useFieldState.js +27 -0
- package/lib/commonjs/hooks/useFieldState.js.map +1 -0
- package/lib/commonjs/hooks/useKeyboardManager.js +68 -0
- package/lib/commonjs/hooks/useKeyboardManager.js.map +1 -0
- package/lib/commonjs/icons/Icon.js +388 -0
- package/lib/commonjs/icons/Icon.js.map +1 -0
- package/lib/commonjs/icons/index.js +13 -0
- package/lib/commonjs/icons/index.js.map +1 -0
- package/lib/commonjs/index.js +158 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/theme/ThemeProvider.js +48 -0
- package/lib/commonjs/theme/ThemeProvider.js.map +1 -0
- package/lib/commonjs/theme/defaultTheme.js +62 -0
- package/lib/commonjs/theme/defaultTheme.js.map +1 -0
- package/lib/commonjs/theme/index.js +38 -0
- package/lib/commonjs/theme/index.js.map +1 -0
- package/lib/commonjs/types/index.js +6 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/utils/formatters.js +25 -0
- package/lib/commonjs/utils/formatters.js.map +1 -0
- package/lib/commonjs/utils/keyboardTypes.js +103 -0
- package/lib/commonjs/utils/keyboardTypes.js.map +1 -0
- package/lib/commonjs/validation/index.js +80 -0
- package/lib/commonjs/validation/index.js.map +1 -0
- package/lib/commonjs/validation/useValidation.js +34 -0
- package/lib/commonjs/validation/useValidation.js.map +1 -0
- package/lib/commonjs/validation/validators.js +118 -0
- package/lib/commonjs/validation/validators.js.map +1 -0
- package/lib/module/components/ChatInput/ChatInput.js +165 -0
- package/lib/module/components/ChatInput/ChatInput.js.map +1 -0
- package/lib/module/components/ChatInput/index.js +4 -0
- package/lib/module/components/ChatInput/index.js.map +1 -0
- package/lib/module/components/ChatInput/types.js +4 -0
- package/lib/module/components/ChatInput/types.js.map +1 -0
- package/lib/module/components/DescriptionField/DescriptionField.js +35 -0
- package/lib/module/components/DescriptionField/DescriptionField.js.map +1 -0
- package/lib/module/components/DescriptionField/index.js +4 -0
- package/lib/module/components/DescriptionField/index.js.map +1 -0
- package/lib/module/components/FieldFlowInput/FieldFlowInput.js +202 -0
- package/lib/module/components/FieldFlowInput/FieldFlowInput.js.map +1 -0
- package/lib/module/components/FieldFlowInput/index.js +4 -0
- package/lib/module/components/FieldFlowInput/index.js.map +1 -0
- package/lib/module/components/FieldFlowInput/styles.js +92 -0
- package/lib/module/components/FieldFlowInput/styles.js.map +1 -0
- package/lib/module/components/FieldFlowInput/types.js +4 -0
- package/lib/module/components/FieldFlowInput/types.js.map +1 -0
- package/lib/module/components/KeyboardAwareFormWrapper/KeyboardAwareFormWrapper.js +39 -0
- package/lib/module/components/KeyboardAwareFormWrapper/KeyboardAwareFormWrapper.js.map +1 -0
- package/lib/module/components/KeyboardAwareFormWrapper/index.js +4 -0
- package/lib/module/components/KeyboardAwareFormWrapper/index.js.map +1 -0
- package/lib/module/hooks/index.js +6 -0
- package/lib/module/hooks/index.js.map +1 -0
- package/lib/module/hooks/useFieldFlowForm.js +104 -0
- package/lib/module/hooks/useFieldFlowForm.js.map +1 -0
- package/lib/module/hooks/useFieldState.js +23 -0
- package/lib/module/hooks/useFieldState.js.map +1 -0
- package/lib/module/hooks/useKeyboardManager.js +64 -0
- package/lib/module/hooks/useKeyboardManager.js.map +1 -0
- package/lib/module/icons/Icon.js +383 -0
- package/lib/module/icons/Icon.js.map +1 -0
- package/lib/module/icons/index.js +4 -0
- package/lib/module/icons/index.js.map +1 -0
- package/lib/module/index.js +18 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/theme/ThemeProvider.js +42 -0
- package/lib/module/theme/ThemeProvider.js.map +1 -0
- package/lib/module/theme/defaultTheme.js +58 -0
- package/lib/module/theme/defaultTheme.js.map +1 -0
- package/lib/module/theme/index.js +5 -0
- package/lib/module/theme/index.js.map +1 -0
- package/lib/module/types/index.js +4 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/utils/formatters.js +19 -0
- package/lib/module/utils/formatters.js.map +1 -0
- package/lib/module/utils/keyboardTypes.js +98 -0
- package/lib/module/utils/keyboardTypes.js.map +1 -0
- package/lib/module/validation/index.js +5 -0
- package/lib/module/validation/index.js.map +1 -0
- package/lib/module/validation/useValidation.js +30 -0
- package/lib/module/validation/useValidation.js.map +1 -0
- package/lib/module/validation/validators.js +103 -0
- package/lib/module/validation/validators.js.map +1 -0
- package/lib/typescript/components/ChatInput/ChatInput.d.ts +10 -0
- package/lib/typescript/components/ChatInput/ChatInput.d.ts.map +1 -0
- package/lib/typescript/components/ChatInput/index.d.ts +3 -0
- package/lib/typescript/components/ChatInput/index.d.ts.map +1 -0
- package/lib/typescript/components/ChatInput/types.d.ts +30 -0
- package/lib/typescript/components/ChatInput/types.d.ts.map +1 -0
- package/lib/typescript/components/DescriptionField/DescriptionField.d.ts +16 -0
- package/lib/typescript/components/DescriptionField/DescriptionField.d.ts.map +1 -0
- package/lib/typescript/components/DescriptionField/index.d.ts +3 -0
- package/lib/typescript/components/DescriptionField/index.d.ts.map +1 -0
- package/lib/typescript/components/FieldFlowInput/FieldFlowInput.d.ts +5 -0
- package/lib/typescript/components/FieldFlowInput/FieldFlowInput.d.ts.map +1 -0
- package/lib/typescript/components/FieldFlowInput/index.d.ts +3 -0
- package/lib/typescript/components/FieldFlowInput/index.d.ts.map +1 -0
- package/lib/typescript/components/FieldFlowInput/styles.d.ts +71 -0
- package/lib/typescript/components/FieldFlowInput/styles.d.ts.map +1 -0
- package/lib/typescript/components/FieldFlowInput/types.d.ts +50 -0
- package/lib/typescript/components/FieldFlowInput/types.d.ts.map +1 -0
- package/lib/typescript/components/KeyboardAwareFormWrapper/KeyboardAwareFormWrapper.d.ts +17 -0
- package/lib/typescript/components/KeyboardAwareFormWrapper/KeyboardAwareFormWrapper.d.ts.map +1 -0
- package/lib/typescript/components/KeyboardAwareFormWrapper/index.d.ts +3 -0
- package/lib/typescript/components/KeyboardAwareFormWrapper/index.d.ts.map +1 -0
- package/lib/typescript/hooks/index.d.ts +7 -0
- package/lib/typescript/hooks/index.d.ts.map +1 -0
- package/lib/typescript/hooks/useFieldFlowForm.d.ts +31 -0
- package/lib/typescript/hooks/useFieldFlowForm.d.ts.map +1 -0
- package/lib/typescript/hooks/useFieldState.d.ts +12 -0
- package/lib/typescript/hooks/useFieldState.d.ts.map +1 -0
- package/lib/typescript/hooks/useKeyboardManager.d.ts +35 -0
- package/lib/typescript/hooks/useKeyboardManager.d.ts.map +1 -0
- package/lib/typescript/icons/Icon.d.ts +17 -0
- package/lib/typescript/icons/Icon.d.ts.map +1 -0
- package/lib/typescript/icons/index.d.ts +3 -0
- package/lib/typescript/icons/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +18 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/theme/ThemeProvider.d.ts +16 -0
- package/lib/typescript/theme/ThemeProvider.d.ts.map +1 -0
- package/lib/typescript/theme/defaultTheme.d.ts +4 -0
- package/lib/typescript/theme/defaultTheme.d.ts.map +1 -0
- package/lib/typescript/theme/index.d.ts +4 -0
- package/lib/typescript/theme/index.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +79 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/lib/typescript/utils/formatters.d.ts +5 -0
- package/lib/typescript/utils/formatters.d.ts.map +1 -0
- package/lib/typescript/utils/keyboardTypes.d.ts +18 -0
- package/lib/typescript/utils/keyboardTypes.d.ts.map +1 -0
- package/lib/typescript/validation/index.d.ts +4 -0
- package/lib/typescript/validation/index.d.ts.map +1 -0
- package/lib/typescript/validation/useValidation.d.ts +14 -0
- package/lib/typescript/validation/useValidation.d.ts.map +1 -0
- package/lib/typescript/validation/validators.d.ts +17 -0
- package/lib/typescript/validation/validators.d.ts.map +1 -0
- package/package.json +80 -0
- package/src/components/ChatInput/ChatInput.tsx +178 -0
- package/src/components/ChatInput/index.ts +2 -0
- package/src/components/ChatInput/types.ts +35 -0
- package/src/components/DescriptionField/DescriptionField.tsx +39 -0
- package/src/components/DescriptionField/index.ts +2 -0
- package/src/components/FieldFlowInput/FieldFlowInput.tsx +240 -0
- package/src/components/FieldFlowInput/index.ts +2 -0
- package/src/components/FieldFlowInput/styles.ts +94 -0
- package/src/components/FieldFlowInput/types.ts +55 -0
- package/src/components/KeyboardAwareFormWrapper/KeyboardAwareFormWrapper.tsx +45 -0
- package/src/components/KeyboardAwareFormWrapper/index.ts +2 -0
- package/src/hooks/index.ts +12 -0
- package/src/hooks/useFieldFlowForm.ts +133 -0
- package/src/hooks/useFieldState.ts +31 -0
- package/src/hooks/useKeyboardManager.ts +105 -0
- package/src/icons/Icon.tsx +338 -0
- package/src/icons/index.ts +2 -0
- package/src/index.ts +63 -0
- package/src/theme/ThemeProvider.tsx +49 -0
- package/src/theme/defaultTheme.ts +58 -0
- package/src/theme/index.ts +3 -0
- package/src/types/index.ts +98 -0
- package/src/utils/formatters.ts +18 -0
- package/src/utils/keyboardTypes.ts +85 -0
- package/src/validation/index.ts +15 -0
- package/src/validation/useValidation.ts +37 -0
- package/src/validation/validators.ts +93 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Your Name
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# rn-inputforge
|
|
2
|
+
|
|
3
|
+
A production-ready, highly customizable input field system for **bare React Native CLI** apps — text, email, number, phone, password, search, description, and chat inputs, with built-in validation, theming, icons, and keyboard-aware form navigation. Pure JS/TS, no native modules, so there's nothing to link.
|
|
4
|
+
|
|
5
|
+
Works identically whether your project uses **npm** or **yarn**.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Pick whichever your project already uses — the package itself doesn't care.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# npm
|
|
15
|
+
npm install rn-inputforge
|
|
16
|
+
|
|
17
|
+
# yarn
|
|
18
|
+
yarn add rn-inputforge
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
That's it — this is a pure JavaScript/TypeScript package (no native code), so on a bare React Native CLI project there is **no pod install step and no manual linking** required. If you're on iOS and your project's Podfile does a full `pod install` on every dependency change anyway, running it won't hurt, it's just not required for this package.
|
|
22
|
+
|
|
23
|
+
### Requirements
|
|
24
|
+
|
|
25
|
+
- `react` >= 18 (tested against 19.2.x)
|
|
26
|
+
- `react-native` >= 0.73 (tested against 0.86.x)
|
|
27
|
+
- TypeScript is optional but recommended (type defs are bundled)
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Quick start
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { FieldFlowInput } from 'rn-inputforge';
|
|
35
|
+
|
|
36
|
+
function LoginForm() {
|
|
37
|
+
const [email, setEmail] = useState('');
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<FieldFlowInput
|
|
41
|
+
type="email"
|
|
42
|
+
label="Email address"
|
|
43
|
+
placeholder="you@example.com"
|
|
44
|
+
value={email}
|
|
45
|
+
onChangeText={setEmail}
|
|
46
|
+
required
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Setting `type="email"` automatically wires up the email keyboard, disables autocorrect/autocapitalize, and applies email-format validation on blur — no extra config needed. Same idea for `number`, `decimal`, `phone`, `password`, and `search`.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Field types
|
|
57
|
+
|
|
58
|
+
| `type` | Keyboard | Notes |
|
|
59
|
+
|---------------|---------------------|-------|
|
|
60
|
+
| `text` | default | sentence auto-capitalize |
|
|
61
|
+
| `email` | email-address | auto validates email format |
|
|
62
|
+
| `number` | numeric / number-pad| strips non-digits as you type |
|
|
63
|
+
| `decimal` | decimal-pad | allows a single `.` |
|
|
64
|
+
| `phone` | phone-pad | strips invalid phone characters |
|
|
65
|
+
| `password` | default, masked | built-in show/hide toggle |
|
|
66
|
+
| `search` | default | search icon + clear button by default |
|
|
67
|
+
| `multiline` | default, multi-line | free-form multi-line text |
|
|
68
|
+
| `description` | default, multi-line | used internally by `DescriptionField` |
|
|
69
|
+
| `chat` | default | used internally by `ChatInput` |
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Validation
|
|
74
|
+
|
|
75
|
+
Rules are declarative and reusable across the whole library:
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
<FieldFlowInput
|
|
79
|
+
type="email"
|
|
80
|
+
label="Email"
|
|
81
|
+
value={email}
|
|
82
|
+
onChangeText={setEmail}
|
|
83
|
+
rules={{ required: 'Email is required', email: true }}
|
|
84
|
+
validateOnChange
|
|
85
|
+
/>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Available rule keys: `required`, `minLength`, `maxLength`, `pattern` (RegExp), `email`, `number`, and `custom` (one or more `(value: string) => { valid: boolean; message?: string }` functions).
|
|
89
|
+
|
|
90
|
+
For a whole form at once, use `useFieldFlowForm`:
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
import { useFieldFlowForm, FieldFlowInput } from 'rn-inputforge';
|
|
94
|
+
|
|
95
|
+
const form = useFieldFlowForm({
|
|
96
|
+
initialValues: { name: '', email: '' },
|
|
97
|
+
rules: {
|
|
98
|
+
name: { required: true, minLength: 2 },
|
|
99
|
+
email: { required: true, email: true },
|
|
100
|
+
},
|
|
101
|
+
onSubmit: async values => {
|
|
102
|
+
await api.createAccount(values);
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
<FieldFlowInput
|
|
107
|
+
label="Name"
|
|
108
|
+
value={form.values.name}
|
|
109
|
+
onChangeText={form.handleChange('name')}
|
|
110
|
+
onBlur={form.handleBlur('name')}
|
|
111
|
+
errorText={form.touched.name ? form.errors.name : undefined}
|
|
112
|
+
/>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`form.submit()` validates every field and only calls `onSubmit` if everything passes.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Keyboard & form navigation
|
|
120
|
+
|
|
121
|
+
`useKeyboardManager` handles "Next" → focus the next field, "Done" → submit, and keeps the focused field scrolled above the keyboard:
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
const keyboardManager = useKeyboardManager({
|
|
125
|
+
order: ['name', 'email', 'password'],
|
|
126
|
+
onSubmit: form.submit,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
<KeyboardAwareFormWrapper keyboardManager={keyboardManager}>
|
|
130
|
+
<FieldFlowInput
|
|
131
|
+
ref={r => keyboardManager.registerField('name', { current: r })}
|
|
132
|
+
returnKeyType={keyboardManager.getReturnKeyType('name')}
|
|
133
|
+
onSubmitEditing={() => keyboardManager.focusNext('name')}
|
|
134
|
+
/* ...value, onChangeText, etc. */
|
|
135
|
+
/>
|
|
136
|
+
{/* ...more fields */}
|
|
137
|
+
</KeyboardAwareFormWrapper>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
See `example/App.tsx` for a complete multi-field form wired end to end.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Description fields
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
import { DescriptionField } from 'rn-inputforge';
|
|
148
|
+
|
|
149
|
+
<DescriptionField
|
|
150
|
+
label="Bio"
|
|
151
|
+
placeholder="Tell us about yourself..."
|
|
152
|
+
value={bio}
|
|
153
|
+
onChangeText={setBio}
|
|
154
|
+
maxLength={240}
|
|
155
|
+
minHeight={80}
|
|
156
|
+
maxHeight={200}
|
|
157
|
+
/>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Grows automatically as the user types, shows a live character counter, and supports every validation/theming prop `FieldFlowInput` does.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Chat input
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
import { ChatInput } from 'rn-inputforge';
|
|
168
|
+
|
|
169
|
+
<ChatInput
|
|
170
|
+
value={message}
|
|
171
|
+
onChangeText={setMessage}
|
|
172
|
+
onSend={text => sendMessage(text)}
|
|
173
|
+
attachmentActions={['camera', 'gallery', 'document', 'location']}
|
|
174
|
+
onAttachmentPress={action => handleAttachment(action)}
|
|
175
|
+
customActions={[{ id: 'gif', icon: 'image', onPress: openGifPicker }]}
|
|
176
|
+
placeholder="Type a message..."
|
|
177
|
+
/>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Handles expandable height, keyboard-avoiding behavior, and a send button that's only active once there's text to send. Attachment buttons are opt-in per screen — pass only the ones your chat needs.
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Icons
|
|
185
|
+
|
|
186
|
+
FieldFlow ships a small, dependency-free icon set (`eye`, `eyeOff`, `clear`, `check`, `alert`, `search`, `send`, `camera`, `image`, `paperclip`, `mic`, `mapPin`, `spinner`) so you don't need to install `react-native-svg` or a vector-icon library just to use text fields with icons:
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
<FieldFlowInput leftIcon="search" rightIcon={<MyCustomIcon />} />
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Any prop that accepts an icon also accepts a raw `ReactNode`, so you can swap in your own icon library (e.g. `react-native-vector-icons`, `lucide-react-native`) at any time without changing anything else.
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Theming
|
|
197
|
+
|
|
198
|
+
Wrap your app (or just a screen) in `FieldFlowThemeProvider` and override only what you need — everything else falls back to the default theme:
|
|
199
|
+
|
|
200
|
+
```tsx
|
|
201
|
+
import { FieldFlowThemeProvider } from 'rn-inputforge';
|
|
202
|
+
|
|
203
|
+
<FieldFlowThemeProvider
|
|
204
|
+
theme={{
|
|
205
|
+
colors: { borderFocused: '#7C3AED', labelFocused: '#7C3AED' },
|
|
206
|
+
spacing: { borderRadius: 14 },
|
|
207
|
+
}}
|
|
208
|
+
>
|
|
209
|
+
<App />
|
|
210
|
+
</FieldFlowThemeProvider>
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
You can also pass a one-off `theme` prop directly to any single field to override it locally, or use the bundled `darkTheme` as a starting point for dark mode.
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## Project structure
|
|
218
|
+
|
|
219
|
+
```
|
|
220
|
+
rn-inputforge/
|
|
221
|
+
├── src/
|
|
222
|
+
│ ├── components/
|
|
223
|
+
│ │ ├── FieldFlowInput/ core input (all field types, icons, states)
|
|
224
|
+
│ │ ├── DescriptionField/ auto-growing multiline field
|
|
225
|
+
│ │ ├── ChatInput/ chat composer + attachment toolbar
|
|
226
|
+
│ │ └── KeyboardAwareFormWrapper/
|
|
227
|
+
│ ├── hooks/ useFieldFlowForm, useKeyboardManager, useFieldState
|
|
228
|
+
│ ├── theme/ ThemeProvider + default/dark themes
|
|
229
|
+
│ ├── validation/ validators + useValidation
|
|
230
|
+
│ ├── icons/ dependency-free icon set
|
|
231
|
+
│ ├── utils/ keyboard-type resolution, formatters
|
|
232
|
+
│ └── index.ts public API
|
|
233
|
+
├── example/App.tsx full usage reference (form + chat screen)
|
|
234
|
+
├── package.json
|
|
235
|
+
└── tsconfig*.json
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Building the library locally
|
|
241
|
+
|
|
242
|
+
The package is set up with [`react-native-builder-bob`](https://github.com/callstack/react-native-builder-bob) to produce CommonJS, ES module, and TypeScript declaration output — the standard setup for RN libraries, and it works the same regardless of whether the consuming app uses npm or Yarn.
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
# with yarn
|
|
246
|
+
yarn install
|
|
247
|
+
yarn build
|
|
248
|
+
|
|
249
|
+
# with npm
|
|
250
|
+
npm install
|
|
251
|
+
npm run build
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
This produces:
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
lib/commonjs/ -> require()-style output
|
|
258
|
+
lib/module/ -> ES module output (used by Metro when bundling)
|
|
259
|
+
lib/typescript/ -> .d.ts declaration files
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Publishing
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
npm version patch # or minor / major
|
|
266
|
+
npm publish # or: yarn publish
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Both package managers read the same `package.json`, so there's nothing extra to configure to support either one.
|
|
270
|
+
|
|
271
|
+
## License
|
|
272
|
+
|
|
273
|
+
MIT
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ChatInput = ChatInput;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _ThemeProvider = require("../../theme/ThemeProvider");
|
|
10
|
+
var _defaultTheme = require("../../theme/defaultTheme");
|
|
11
|
+
var _Icon = require("../../icons/Icon");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
|
+
const ACTION_ICON = {
|
|
15
|
+
camera: 'camera',
|
|
16
|
+
gallery: 'image',
|
|
17
|
+
document: 'paperclip',
|
|
18
|
+
location: 'mapPin',
|
|
19
|
+
voice: 'mic'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A ready-to-drop-in chat composer for messaging screens: expandable input,
|
|
24
|
+
* a configurable row of attachment buttons (camera / gallery / document /
|
|
25
|
+
* location / voice, plus your own custom actions), and a send button that
|
|
26
|
+
* only lights up once there's something to send.
|
|
27
|
+
*/
|
|
28
|
+
function ChatInput({
|
|
29
|
+
value,
|
|
30
|
+
defaultValue,
|
|
31
|
+
onChangeText,
|
|
32
|
+
onSend,
|
|
33
|
+
placeholder = 'Message',
|
|
34
|
+
attachmentActions = [],
|
|
35
|
+
onAttachmentPress,
|
|
36
|
+
customActions = [],
|
|
37
|
+
disabled,
|
|
38
|
+
loading,
|
|
39
|
+
maxLength,
|
|
40
|
+
minHeight = 40,
|
|
41
|
+
maxHeight = 140,
|
|
42
|
+
theme: themeOverride,
|
|
43
|
+
testID
|
|
44
|
+
}) {
|
|
45
|
+
const contextTheme = (0, _ThemeProvider.useFieldFlowTheme)();
|
|
46
|
+
const theme = (0, _react.useMemo)(() => themeOverride ? (0, _ThemeProvider.mergeDeep)(contextTheme ?? _defaultTheme.defaultTheme, themeOverride) : contextTheme ?? _defaultTheme.defaultTheme, [contextTheme, themeOverride]);
|
|
47
|
+
const isControlled = value !== undefined;
|
|
48
|
+
const [internalValue, setInternalValue] = (0, _react.useState)(defaultValue ?? '');
|
|
49
|
+
const currentValue = isControlled ? value ?? '' : internalValue;
|
|
50
|
+
const [height, setHeight] = (0, _react.useState)(minHeight);
|
|
51
|
+
const inputRef = (0, _react.useRef)(null);
|
|
52
|
+
const handleChangeText = next => {
|
|
53
|
+
if (!isControlled) setInternalValue(next);
|
|
54
|
+
onChangeText?.(next);
|
|
55
|
+
};
|
|
56
|
+
const handleContentSizeChange = e => {
|
|
57
|
+
setHeight(Math.min(maxHeight, Math.max(minHeight, e.nativeEvent.contentSize.height)));
|
|
58
|
+
};
|
|
59
|
+
const handleSend = () => {
|
|
60
|
+
const trimmed = currentValue.trim();
|
|
61
|
+
if (!trimmed || disabled || loading) return;
|
|
62
|
+
onSend(trimmed);
|
|
63
|
+
if (!isControlled) setInternalValue('');
|
|
64
|
+
inputRef.current?.clear();
|
|
65
|
+
};
|
|
66
|
+
const canSend = currentValue.trim().length > 0 && !disabled && !loading;
|
|
67
|
+
const styles = (0, _react.useMemo)(() => createStyles(theme), [theme]);
|
|
68
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.KeyboardAvoidingView, {
|
|
69
|
+
behavior: _reactNative.Platform.OS === 'ios' ? 'padding' : undefined,
|
|
70
|
+
testID: testID,
|
|
71
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
72
|
+
style: styles.container,
|
|
73
|
+
children: [attachmentActions.length > 0 || customActions.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
74
|
+
style: styles.toolbar,
|
|
75
|
+
children: [attachmentActions.map(action => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
76
|
+
onPress: () => onAttachmentPress?.(action),
|
|
77
|
+
style: styles.toolbarButton,
|
|
78
|
+
hitSlop: 8,
|
|
79
|
+
disabled: disabled,
|
|
80
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.FieldFlowIcon, {
|
|
81
|
+
name: ACTION_ICON[action],
|
|
82
|
+
color: theme.colors.icon,
|
|
83
|
+
size: 20
|
|
84
|
+
})
|
|
85
|
+
}, action)), customActions.map(action => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
86
|
+
onPress: action.onPress,
|
|
87
|
+
style: styles.toolbarButton,
|
|
88
|
+
hitSlop: 8,
|
|
89
|
+
children: typeof action.icon === 'string' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.FieldFlowIcon, {
|
|
90
|
+
name: action.icon,
|
|
91
|
+
color: theme.colors.icon,
|
|
92
|
+
size: 20
|
|
93
|
+
}) : action.icon
|
|
94
|
+
}, action.id))]
|
|
95
|
+
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
96
|
+
style: styles.inputRow,
|
|
97
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TextInput, {
|
|
98
|
+
ref: inputRef,
|
|
99
|
+
value: currentValue,
|
|
100
|
+
onChangeText: handleChangeText,
|
|
101
|
+
onContentSizeChange: handleContentSizeChange,
|
|
102
|
+
placeholder: placeholder,
|
|
103
|
+
placeholderTextColor: theme.colors.placeholder,
|
|
104
|
+
multiline: true,
|
|
105
|
+
maxLength: maxLength,
|
|
106
|
+
editable: !disabled && !loading,
|
|
107
|
+
style: [styles.input, {
|
|
108
|
+
height
|
|
109
|
+
}]
|
|
110
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
111
|
+
onPress: handleSend,
|
|
112
|
+
disabled: !canSend,
|
|
113
|
+
style: [styles.sendButton, {
|
|
114
|
+
opacity: canSend ? 1 : 0.4
|
|
115
|
+
}],
|
|
116
|
+
hitSlop: 8,
|
|
117
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.FieldFlowIcon, {
|
|
118
|
+
name: loading ? 'spinner' : 'send',
|
|
119
|
+
color: "#FFFFFF",
|
|
120
|
+
size: 16
|
|
121
|
+
})
|
|
122
|
+
})]
|
|
123
|
+
})]
|
|
124
|
+
})
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function createStyles(theme) {
|
|
128
|
+
return _reactNative.StyleSheet.create({
|
|
129
|
+
container: {
|
|
130
|
+
backgroundColor: theme.colors.background,
|
|
131
|
+
borderTopWidth: theme.spacing.borderWidth,
|
|
132
|
+
borderTopColor: theme.colors.border,
|
|
133
|
+
paddingHorizontal: theme.spacing.paddingHorizontal,
|
|
134
|
+
paddingVertical: theme.spacing.gap
|
|
135
|
+
},
|
|
136
|
+
toolbar: {
|
|
137
|
+
flexDirection: 'row',
|
|
138
|
+
marginBottom: theme.spacing.gap
|
|
139
|
+
},
|
|
140
|
+
toolbarButton: {
|
|
141
|
+
marginRight: theme.spacing.gap * 2,
|
|
142
|
+
alignItems: 'center',
|
|
143
|
+
justifyContent: 'center'
|
|
144
|
+
},
|
|
145
|
+
inputRow: {
|
|
146
|
+
flexDirection: 'row',
|
|
147
|
+
alignItems: 'flex-end'
|
|
148
|
+
},
|
|
149
|
+
input: {
|
|
150
|
+
flex: 1,
|
|
151
|
+
fontSize: theme.typography.fontSize,
|
|
152
|
+
color: theme.colors.text,
|
|
153
|
+
backgroundColor: theme.colors.backgroundDisabled,
|
|
154
|
+
borderRadius: theme.spacing.borderRadius * 1.6,
|
|
155
|
+
paddingHorizontal: theme.spacing.paddingHorizontal,
|
|
156
|
+
paddingVertical: theme.spacing.paddingVertical * 0.7,
|
|
157
|
+
textAlignVertical: 'top'
|
|
158
|
+
},
|
|
159
|
+
sendButton: {
|
|
160
|
+
width: 34,
|
|
161
|
+
height: 34,
|
|
162
|
+
borderRadius: 17,
|
|
163
|
+
backgroundColor: theme.colors.borderFocused,
|
|
164
|
+
alignItems: 'center',
|
|
165
|
+
justifyContent: 'center',
|
|
166
|
+
marginLeft: theme.spacing.gap
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=ChatInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_ThemeProvider","_defaultTheme","_Icon","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ACTION_ICON","camera","gallery","document","location","voice","ChatInput","value","defaultValue","onChangeText","onSend","placeholder","attachmentActions","onAttachmentPress","customActions","disabled","loading","maxLength","minHeight","maxHeight","theme","themeOverride","testID","contextTheme","useFieldFlowTheme","useMemo","mergeDeep","defaultTheme","isControlled","undefined","internalValue","setInternalValue","useState","currentValue","height","setHeight","inputRef","useRef","handleChangeText","next","handleContentSizeChange","Math","min","max","nativeEvent","contentSize","handleSend","trimmed","trim","current","clear","canSend","length","styles","createStyles","jsx","KeyboardAvoidingView","behavior","Platform","OS","children","jsxs","View","style","container","toolbar","map","action","Pressable","onPress","toolbarButton","hitSlop","FieldFlowIcon","name","color","colors","icon","size","id","inputRow","TextInput","ref","onContentSizeChange","placeholderTextColor","multiline","editable","input","sendButton","opacity","StyleSheet","create","backgroundColor","background","borderTopWidth","spacing","borderWidth","borderTopColor","border","paddingHorizontal","paddingVertical","gap","flexDirection","marginBottom","marginRight","alignItems","justifyContent","flex","fontSize","typography","text","backgroundDisabled","borderRadius","textAlignVertical","width","borderFocused","marginLeft"],"sourceRoot":"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(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ChatInput", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ChatInput.ChatInput;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _ChatInput = require("./ChatInput");
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_ChatInput","require"],"sourceRoot":"../../../../src","sources":["components/ChatInput/index.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/ChatInput/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DescriptionField = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _FieldFlowInput = require("../FieldFlowInput/FieldFlowInput");
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
11
|
+
/**
|
|
12
|
+
* A dedicated multi-line field for comments, notes, descriptions, and feedback.
|
|
13
|
+
* Grows automatically as the user types, up to `maxHeight`, and supports the
|
|
14
|
+
* same character-limit / validation / theming props as FieldFlowInput.
|
|
15
|
+
*/
|
|
16
|
+
const DescriptionField = exports.DescriptionField = /*#__PURE__*/(0, _react.forwardRef)(function DescriptionField({
|
|
17
|
+
minHeight = 80,
|
|
18
|
+
maxHeight = 200,
|
|
19
|
+
inputStyle,
|
|
20
|
+
showCharacterCount = true,
|
|
21
|
+
...rest
|
|
22
|
+
}, ref) {
|
|
23
|
+
const [height, setHeight] = (0, _react.useState)(minHeight);
|
|
24
|
+
const handleContentSizeChange = e => {
|
|
25
|
+
const next = Math.min(maxHeight, Math.max(minHeight, e.nativeEvent.contentSize.height));
|
|
26
|
+
setHeight(next);
|
|
27
|
+
};
|
|
28
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_FieldFlowInput.FieldFlowInput, {
|
|
29
|
+
ref: ref,
|
|
30
|
+
type: "description",
|
|
31
|
+
showCharacterCount: showCharacterCount,
|
|
32
|
+
inputStyle: {
|
|
33
|
+
height,
|
|
34
|
+
...inputStyle
|
|
35
|
+
},
|
|
36
|
+
onContentSizeChange: handleContentSizeChange,
|
|
37
|
+
...rest
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=DescriptionField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_FieldFlowInput","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DescriptionField","exports","forwardRef","minHeight","maxHeight","inputStyle","showCharacterCount","rest","ref","height","setHeight","useState","handleContentSizeChange","next","Math","min","max","nativeEvent","contentSize","jsx","FieldFlowInput","type","onContentSizeChange"],"sourceRoot":"../../../../src","sources":["components/DescriptionField/DescriptionField.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,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,GAAGC;AAAK,CAAC,EACnFC,GAAG,EACH;EACA,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAG,IAAAC,eAAQ,EAACR,SAAS,CAAC;EAE/C,MAAMS,uBAAuB,GAAI/B,CAA4D,IAAK;IAChG,MAAMgC,IAAI,GAAGC,IAAI,CAACC,GAAG,CAACX,SAAS,EAAEU,IAAI,CAACE,GAAG,CAACb,SAAS,EAAEtB,CAAC,CAACoC,WAAW,CAACC,WAAW,CAACT,MAAM,CAAC,CAAC;IACvFC,SAAS,CAACG,IAAI,CAAC;EACjB,CAAC;EAED,oBACE,IAAAjC,WAAA,CAAAuC,GAAA,EAACxC,eAAA,CAAAyC,cAAc;IACbZ,GAAG,EAAEA,GAAI;IACTa,IAAI,EAAC,aAAa;IAClBf,kBAAkB,EAAEA,kBAAmB;IACvCD,UAAU,EAAE;MAAEI,MAAM;MAAE,GAAGJ;IAAW,CAAE;IACtCiB,mBAAmB,EAAEV,uBAAwB;IAAA,GACzCL;EAAI,CACT,CAAC;AAEN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "DescriptionField", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _DescriptionField.DescriptionField;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _DescriptionField = require("./DescriptionField");
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_DescriptionField","require"],"sourceRoot":"../../../../src","sources":["components/DescriptionField/index.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA","ignoreList":[]}
|