@navegarti/rn-design-system 0.7.7 โ 0.7.9
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/README.md +719 -14
- package/lib/module/components/Input/styles.js +3 -2
- package/lib/module/components.js +1 -1
- package/lib/module/index.js +10 -2
- package/lib/typescript/src/components/Button/index.d.ts +1 -0
- package/lib/typescript/src/components/Carousel/index.d.ts +1 -0
- package/lib/typescript/src/components/FAB/index.d.ts +1 -0
- package/lib/typescript/src/components.d.ts +5 -1
- package/lib/typescript/src/index.d.ts +14 -2
- package/package.json +38 -9
- package/src/api/axios-adapter.ts +272 -0
- package/src/api/errors.ts +113 -0
- package/src/api/index.ts +27 -0
- package/src/api/retry-strategy.ts +86 -0
- package/src/api/stores/auth-store.ts +26 -0
- package/src/api/types.ts +91 -0
- package/src/api.tsx +17 -0
- package/src/components/Button/index.tsx +37 -0
- package/src/components/Button/styles.ts +28 -0
- package/src/components/Carousel/components/dot.tsx +43 -0
- package/src/components/Carousel/components/footer.tsx +21 -0
- package/src/components/Carousel/components/list.tsx +81 -0
- package/src/components/Carousel/components/pagination.tsx +16 -0
- package/src/components/Carousel/components/see-all-button.tsx +25 -0
- package/src/components/Carousel/context.tsx +19 -0
- package/src/components/Carousel/index.tsx +193 -0
- package/src/components/Carousel/styles.ts +8 -0
- package/src/components/Carousel/types.ts +45 -0
- package/src/components/Checkbox/index.tsx +42 -0
- package/src/components/Checkbox/styles.ts +7 -0
- package/src/components/FAB/components/extended-fab.tsx +17 -0
- package/src/components/FAB/index.tsx +24 -0
- package/src/components/FAB/styles.ts +61 -0
- package/src/components/FAB/utils.ts +45 -0
- package/src/components/Flex/index.tsx +1 -0
- package/src/components/Flex/styles.ts +47 -0
- package/src/components/FormLabel/index.tsx +6 -0
- package/src/components/FormLabel/styles.ts +8 -0
- package/src/components/Icon/index.tsx +14 -0
- package/src/components/Input/components/input-control.tsx +20 -0
- package/src/components/Input/components/input-error.tsx +14 -0
- package/src/components/Input/components/input-field.tsx +55 -0
- package/src/components/Input/components/input-icon.tsx +7 -0
- package/src/components/Input/components/input-password-toggle.tsx +19 -0
- package/src/components/Input/components/input-root.tsx +55 -0
- package/src/components/Input/context.tsx +26 -0
- package/src/components/Input/index.tsx +17 -0
- package/src/components/Input/styles.ts +46 -0
- package/src/components/Input/utils.ts +27 -0
- package/src/components/Margin/index.tsx +1 -0
- package/src/components/Margin/styles.ts +23 -0
- package/src/components/OTPInput/index.tsx +116 -0
- package/src/components/OTPInput/styles.ts +23 -0
- package/src/components/OTPInput/utils.ts +31 -0
- package/src/components/Padding/index.tsx +1 -0
- package/src/components/Padding/styles.ts +23 -0
- package/src/components/Radio/components/radio-item.tsx +53 -0
- package/src/components/Radio/context.tsx +10 -0
- package/src/components/Radio/index.tsx +32 -0
- package/src/components/Radio/styles.ts +38 -0
- package/src/components/Radio/utils.ts +19 -0
- package/src/components/Select/components/error-icon.tsx +3 -0
- package/src/components/Select/components/select-error.tsx +14 -0
- package/src/components/Select/components/select-field.tsx +72 -0
- package/src/components/Select/context.tsx +17 -0
- package/src/components/Select/index.tsx +24 -0
- package/src/components/Select/styles.ts +15 -0
- package/src/components/Skeleton/index.tsx +60 -0
- package/src/components/Switch/index.tsx +61 -0
- package/src/components/Switch/styles.ts +32 -0
- package/src/components/Switch/utils.ts +15 -0
- package/src/components/Text/index.tsx +2 -0
- package/src/components/Text/styles.ts +44 -0
- package/src/components.tsx +26 -0
- package/src/form.tsx +7 -0
- package/src/formValidators/ZodTypeValidator.ts +58 -0
- package/src/formValidators/index.ts +8 -0
- package/src/formValidators/types.ts +21 -0
- package/src/hooks/useAppIsActive.ts +28 -0
- package/src/hooks/useAppSecurity.tsx +35 -0
- package/src/hooks/useNetworkStatus.ts +75 -0
- package/src/hooks/useStatusBar.ts +34 -0
- package/src/hooks.tsx +9 -0
- package/src/index.tsx +76 -0
- package/src/libs/tanstack-form.tsx +3 -0
- package/src/utils/camelCase.ts +6 -0
- package/src/utils/camelCaseJSONKeys.ts +31 -0
- package/src/utils/capitalizeWord.ts +4 -0
- package/src/utils/createLinkingPhoneNumberString.ts +13 -0
- package/src/utils/dateFormatters.ts +48 -0
- package/src/utils/debounce.ts +15 -0
- package/src/utils/deepLinkParser.ts +88 -0
- package/src/utils/getAge.ts +12 -0
- package/src/utils/getOnlyNumbers.ts +1 -0
- package/src/utils/isArray.ts +4 -0
- package/src/utils/isObject.ts +4 -0
- package/src/utils/masks.ts +3 -0
- package/src/utils/priceFormatter.ts +11 -0
- package/src/utils/removeTextAccents.ts +4 -0
- package/src/utils/shadowStyledIos.ts +6 -0
- package/src/utils/sortBy.ts +21 -0
- package/src/utils/uniqBy.ts +20 -0
- package/src/utils/userFullnameInitialsExtractor.ts +23 -0
- package/src/utils.tsx +23 -0
- package/lib/module/lucide-icons.d.js +0 -2
package/README.md
CHANGED
|
@@ -1,37 +1,742 @@
|
|
|
1
1
|
# @navegarti/rn-design-system
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A comprehensive React Native design system with reusable components, utilities, hooks, and API integration tools for building scalable mobile applications.
|
|
4
4
|
|
|
5
|
-
## Installation
|
|
5
|
+
## ๐ฆ Installation
|
|
6
6
|
|
|
7
|
+
### Using Yarn
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
yarn add @navegarti/rn-design-system
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Using npm
|
|
7
14
|
|
|
8
15
|
```sh
|
|
9
16
|
npm install @navegarti/rn-design-system
|
|
10
17
|
```
|
|
11
18
|
|
|
19
|
+
### Prerequisites
|
|
20
|
+
|
|
21
|
+
Ensure your project has the required peer dependencies:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
yarn add react react-native react-native-svg @emotion/react @emotion/native
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## ๐ Quick Start
|
|
28
|
+
|
|
29
|
+
### Basic Import
|
|
30
|
+
|
|
31
|
+
Import components from the main entry point:
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { Button, Input, Text, Flex, Padding } from '@navegarti/rn-design-system';
|
|
35
|
+
import { View } from 'react-native';
|
|
36
|
+
|
|
37
|
+
export default function App() {
|
|
38
|
+
return (
|
|
39
|
+
<Padding padding={16}>
|
|
40
|
+
<Flex>
|
|
41
|
+
<Text.Title>Welcome to Design System</Text.Title>
|
|
42
|
+
<Button.Rounded onPress={() => console.log('Pressed')}>
|
|
43
|
+
<Button.Text>Press Me</Button.Text>
|
|
44
|
+
</Button.Rounded>
|
|
45
|
+
</Flex>
|
|
46
|
+
</Padding>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Specific Entry Points
|
|
52
|
+
|
|
53
|
+
Import from specialized sub-packages for tree-shaking:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
// Components only
|
|
57
|
+
import { Button, Input, Select } from '@navegarti/rn-design-system/components';
|
|
58
|
+
|
|
59
|
+
// Utilities
|
|
60
|
+
import { priceFormatter, getAge, camelCase } from '@navegarti/rn-design-system/utils';
|
|
61
|
+
|
|
62
|
+
// Hooks
|
|
63
|
+
import { useNetworkStatus, useAppIsActive } from '@navegarti/rn-design-system/hooks';
|
|
64
|
+
|
|
65
|
+
// API layer
|
|
66
|
+
import { AxiosAdapter, apiRequest } from '@navegarti/rn-design-system/api';
|
|
67
|
+
|
|
68
|
+
// Form utilities
|
|
69
|
+
import { formValidators, tanstackForm } from '@navegarti/rn-design-system/form';
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## ๐จ Components
|
|
75
|
+
|
|
76
|
+
### Form Components
|
|
77
|
+
|
|
78
|
+
#### Input
|
|
79
|
+
Customizable text input for user data entry:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { Input } from '@navegarti/rn-design-system';
|
|
83
|
+
import { useState } from 'react';
|
|
84
|
+
|
|
85
|
+
export function LoginForm() {
|
|
86
|
+
const [email, setEmail] = useState('');
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<Input.Default
|
|
90
|
+
placeholder="Enter your email"
|
|
91
|
+
value={email}
|
|
92
|
+
onChangeText={setEmail}
|
|
93
|
+
keyboardType="email-address"
|
|
94
|
+
/>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### Select
|
|
100
|
+
Dropdown menu for selecting from multiple options:
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
import { Select } from '@navegarti/rn-design-system';
|
|
104
|
+
import { useState } from 'react';
|
|
105
|
+
|
|
106
|
+
export function CountrySelector() {
|
|
107
|
+
const [country, setCountry] = useState('');
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<Select
|
|
111
|
+
placeholder="Select a country"
|
|
112
|
+
value={country}
|
|
113
|
+
onValueChange={setCountry}
|
|
114
|
+
items={[
|
|
115
|
+
{ label: 'Brazil', value: 'BR' },
|
|
116
|
+
{ label: 'USA', value: 'US' },
|
|
117
|
+
{ label: 'Canada', value: 'CA' },
|
|
118
|
+
]}
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### Checkbox
|
|
125
|
+
Binary choice selection:
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import { Checkbox, Text } from '@navegarti/rn-design-system';
|
|
129
|
+
import { useState } from 'react';
|
|
130
|
+
|
|
131
|
+
export function TermsAcceptance() {
|
|
132
|
+
const [agreed, setAgreed] = useState(false);
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<>
|
|
136
|
+
<Checkbox
|
|
137
|
+
value={agreed}
|
|
138
|
+
onValueChange={setAgreed}
|
|
139
|
+
/>
|
|
140
|
+
<Text>I agree to the terms and conditions</Text>
|
|
141
|
+
</>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### Radio
|
|
147
|
+
Single selection from multiple options:
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import { Radio, Text } from '@navegarti/rn-design-system';
|
|
151
|
+
import { useState } from 'react';
|
|
152
|
+
|
|
153
|
+
export function PaymentMethod() {
|
|
154
|
+
const [method, setMethod] = useState('credit-card');
|
|
155
|
+
|
|
156
|
+
return (
|
|
157
|
+
<>
|
|
158
|
+
<Radio
|
|
159
|
+
value="credit-card"
|
|
160
|
+
selected={method === 'credit-card'}
|
|
161
|
+
onPress={() => setMethod('credit-card')}
|
|
162
|
+
/>
|
|
163
|
+
<Text>Credit Card</Text>
|
|
164
|
+
|
|
165
|
+
<Radio
|
|
166
|
+
value="debit-card"
|
|
167
|
+
selected={method === 'debit-card'}
|
|
168
|
+
onPress={() => setMethod('debit-card')}
|
|
169
|
+
/>
|
|
170
|
+
<Text>Debit Card</Text>
|
|
171
|
+
</>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
#### OTPInput
|
|
177
|
+
One-Time Password input for authentication:
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
import { OTPInput } from '@navegarti/rn-design-system';
|
|
181
|
+
import { useState } from 'react';
|
|
182
|
+
|
|
183
|
+
export function TwoFactorAuth() {
|
|
184
|
+
const [otp, setOtp] = useState('');
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<OTPInput
|
|
188
|
+
value={otp}
|
|
189
|
+
onChangeText={setOtp}
|
|
190
|
+
length={6}
|
|
191
|
+
/>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
#### Switch
|
|
197
|
+
Toggle boolean values:
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
import { Switch, Text, Flex } from '@navegarti/rn-design-system';
|
|
201
|
+
import { useState } from 'react';
|
|
202
|
+
|
|
203
|
+
export function DarkModeToggle() {
|
|
204
|
+
const [darkMode, setDarkMode] = useState(false);
|
|
205
|
+
|
|
206
|
+
return (
|
|
207
|
+
<Flex direction="row" align="center">
|
|
208
|
+
<Text>Dark Mode</Text>
|
|
209
|
+
<Switch
|
|
210
|
+
value={darkMode}
|
|
211
|
+
onValueChange={setDarkMode}
|
|
212
|
+
/>
|
|
213
|
+
</Flex>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Action Components
|
|
219
|
+
|
|
220
|
+
#### Button
|
|
221
|
+
Highly customizable button component with multiple variants:
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
import { Button } from '@navegarti/rn-design-system';
|
|
225
|
+
|
|
226
|
+
export function ButtonVariants() {
|
|
227
|
+
return (
|
|
228
|
+
<>
|
|
229
|
+
{/* Default button */}
|
|
230
|
+
<Button onPress={() => {}}>
|
|
231
|
+
<Button.Text>Default</Button.Text>
|
|
232
|
+
</Button>
|
|
233
|
+
|
|
234
|
+
{/* Rounded button */}
|
|
235
|
+
<Button.Rounded onPress={() => {}}>
|
|
236
|
+
<Button.Text>Rounded</Button.Text>
|
|
237
|
+
</Button.Rounded>
|
|
238
|
+
|
|
239
|
+
{/* Pill-shaped button */}
|
|
240
|
+
<Button.Pill onPress={() => {}}>
|
|
241
|
+
<Button.Text>Pill</Button.Text>
|
|
242
|
+
</Button.Pill>
|
|
243
|
+
|
|
244
|
+
{/* Outline button */}
|
|
245
|
+
<Button.Outline onPress={() => {}}>
|
|
246
|
+
<Button.Text>Outline</Button.Text>
|
|
247
|
+
</Button.Outline>
|
|
248
|
+
|
|
249
|
+
{/* Square button */}
|
|
250
|
+
<Button.Square onPress={() => {}}>
|
|
251
|
+
<Button.Text>Square</Button.Text>
|
|
252
|
+
</Button.Square>
|
|
253
|
+
</>
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
#### FAB
|
|
259
|
+
Floating Action Button for primary actions:
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
import { FAB } from '@navegarti/rn-design-system';
|
|
263
|
+
|
|
264
|
+
export function CreateFunction() {
|
|
265
|
+
return (
|
|
266
|
+
<FAB
|
|
267
|
+
onPress={() => console.log('Create new item')}
|
|
268
|
+
icon={{ name: 'plus' }}
|
|
269
|
+
/>
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Display Components
|
|
275
|
+
|
|
276
|
+
#### Text
|
|
277
|
+
Typography component with predefined styles:
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
import { Text } from '@navegarti/rn-design-system';
|
|
281
|
+
|
|
282
|
+
export function Typography() {
|
|
283
|
+
return (
|
|
284
|
+
<>
|
|
285
|
+
<Text.Title>Page Title</Text.Title>
|
|
286
|
+
<Text.Subtitle>Subtitle</Text.Subtitle>
|
|
287
|
+
<Text.Body>Regular body text</Text.Body>
|
|
288
|
+
<Text.Caption>Small caption text</Text.Caption>
|
|
289
|
+
</>
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
#### Skeleton
|
|
295
|
+
Loading placeholder for content:
|
|
296
|
+
|
|
297
|
+
```typescript
|
|
298
|
+
import { Skeleton, Flex } from '@navegarti/rn-design-system';
|
|
299
|
+
|
|
300
|
+
export function LoadingPlaceholder() {
|
|
301
|
+
return (
|
|
302
|
+
<Flex gap={8}>
|
|
303
|
+
<Skeleton width="100%" height={20} />
|
|
304
|
+
<Skeleton width="100%" height={40} />
|
|
305
|
+
<Skeleton width="80%" height={20} />
|
|
306
|
+
</Flex>
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
#### Carousel
|
|
312
|
+
Image carousel/gallery component:
|
|
313
|
+
|
|
314
|
+
```typescript
|
|
315
|
+
import { Carousel } from '@navegarti/rn-design-system';
|
|
316
|
+
|
|
317
|
+
export function ImageGallery() {
|
|
318
|
+
const images = [
|
|
319
|
+
{ uri: 'https://example.com/image1.jpg' },
|
|
320
|
+
{ uri: 'https://example.com/image2.jpg' },
|
|
321
|
+
{ uri: 'https://example.com/image3.jpg' },
|
|
322
|
+
];
|
|
323
|
+
|
|
324
|
+
return <Carousel items={images} />;
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Layout Components
|
|
329
|
+
|
|
330
|
+
#### Flex
|
|
331
|
+
Flexible layout using Flexbox:
|
|
332
|
+
|
|
333
|
+
```typescript
|
|
334
|
+
import { Flex, Text, Button } from '@navegarti/rn-design-system';
|
|
335
|
+
|
|
336
|
+
export function FlexLayout() {
|
|
337
|
+
return (
|
|
338
|
+
<Flex
|
|
339
|
+
direction="column"
|
|
340
|
+
justify="space-between"
|
|
341
|
+
align="center"
|
|
342
|
+
gap={16}
|
|
343
|
+
>
|
|
344
|
+
<Text>Flexible Layout</Text>
|
|
345
|
+
<Button><Button.Text>Action</Button.Text></Button>
|
|
346
|
+
</Flex>
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
#### Padding
|
|
352
|
+
Add internal spacing:
|
|
353
|
+
|
|
354
|
+
```typescript
|
|
355
|
+
import { Padding, Text } from '@navegarti/rn-design-system';
|
|
356
|
+
|
|
357
|
+
export function PaddedContent() {
|
|
358
|
+
return (
|
|
359
|
+
<Padding padding={16}>
|
|
360
|
+
<Text>Content with padding</Text>
|
|
361
|
+
</Padding>
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
#### Margin
|
|
367
|
+
Add external spacing:
|
|
368
|
+
|
|
369
|
+
```typescript
|
|
370
|
+
import { Margin, Text } from '@navegarti/rn-design-system';
|
|
371
|
+
|
|
372
|
+
export function MarginalContent() {
|
|
373
|
+
return (
|
|
374
|
+
<Margin margin={16}>
|
|
375
|
+
<Text>Content with margin</Text>
|
|
376
|
+
</Margin>
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
#### FormLabel
|
|
382
|
+
Label for form inputs:
|
|
383
|
+
|
|
384
|
+
```typescript
|
|
385
|
+
import { FormLabel, Input } from '@navegarti/rn-design-system';
|
|
386
|
+
|
|
387
|
+
export function LabeledInput() {
|
|
388
|
+
return (
|
|
389
|
+
<>
|
|
390
|
+
<FormLabel label="Email Address" />
|
|
391
|
+
<Input.Default placeholder="Enter email" />
|
|
392
|
+
</>
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
---
|
|
398
|
+
|
|
399
|
+
## ๐ช Hooks
|
|
400
|
+
|
|
401
|
+
### useNetworkStatus
|
|
402
|
+
Monitor device network connectivity:
|
|
403
|
+
|
|
404
|
+
```typescript
|
|
405
|
+
import { useNetworkStatus } from '@navegarti/rn-design-system/hooks';
|
|
406
|
+
import { Text } from 'react-native';
|
|
407
|
+
|
|
408
|
+
export function NetworkMonitor() {
|
|
409
|
+
const { isConnected } = useNetworkStatus();
|
|
410
|
+
|
|
411
|
+
return <Text>{isConnected ? 'Online' : 'Offline'}</Text>;
|
|
412
|
+
}
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
### useAppIsActive
|
|
416
|
+
Detect when app comes to foreground/background:
|
|
417
|
+
|
|
418
|
+
```typescript
|
|
419
|
+
import { useAppIsActive } from '@navegarti/rn-design-system/hooks';
|
|
420
|
+
|
|
421
|
+
export function AppLifecycleMonitor() {
|
|
422
|
+
const isActive = useAppIsActive();
|
|
423
|
+
|
|
424
|
+
React.useEffect(() => {
|
|
425
|
+
if (isActive) {
|
|
426
|
+
console.log('App is active');
|
|
427
|
+
}
|
|
428
|
+
}, [isActive]);
|
|
429
|
+
|
|
430
|
+
return null;
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### useAppSecurity
|
|
435
|
+
Check device security status:
|
|
436
|
+
|
|
437
|
+
```typescript
|
|
438
|
+
import { useAppSecurity } from '@navegarti/rn-design-system/hooks';
|
|
439
|
+
|
|
440
|
+
export function SecurityChecker() {
|
|
441
|
+
const { isDeviceSecure } = useAppSecurity();
|
|
442
|
+
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
### useStatusBar
|
|
448
|
+
Control status bar appearance:
|
|
449
|
+
|
|
450
|
+
```typescript
|
|
451
|
+
import { useStatusBar } from '@navegarti/rn-design-system/hooks';
|
|
452
|
+
|
|
453
|
+
export function MyScreen() {
|
|
454
|
+
useStatusBar({ barStyle: 'dark-content' });
|
|
455
|
+
|
|
456
|
+
return null;
|
|
457
|
+
}
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
---
|
|
461
|
+
|
|
462
|
+
## ๐ง Utilities
|
|
463
|
+
|
|
464
|
+
### Text Formatting
|
|
465
|
+
|
|
466
|
+
```typescript
|
|
467
|
+
import {
|
|
468
|
+
priceFormatter,
|
|
469
|
+
capitalizeWord,
|
|
470
|
+
removeTextAccents,
|
|
471
|
+
userFullnameInitialsExtractor,
|
|
472
|
+
} from '@navegarti/rn-design-system/utils';
|
|
473
|
+
|
|
474
|
+
// Price formatting
|
|
475
|
+
const price = priceFormatter(1299.50); // R$ 1.299,50
|
|
476
|
+
|
|
477
|
+
// Capitalize
|
|
478
|
+
const capitalized = capitalizeWord('hello'); // Hello
|
|
479
|
+
|
|
480
|
+
// Remove accents
|
|
481
|
+
const clean = removeTextAccents('Sรฃo Paulo'); // Sao Paulo
|
|
482
|
+
|
|
483
|
+
// Extract initials
|
|
484
|
+
const initials = userFullnameInitialsExtractor('John Doe'); // JD
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
### Data Manipulation
|
|
488
|
+
|
|
489
|
+
```typescript
|
|
490
|
+
import {
|
|
491
|
+
camelCase,
|
|
492
|
+
camelCaseJSONKeys,
|
|
493
|
+
sortBy,
|
|
494
|
+
uniqBy,
|
|
495
|
+
getAge,
|
|
496
|
+
getOnlyNumbers,
|
|
497
|
+
isArray,
|
|
498
|
+
isObject,
|
|
499
|
+
} from '@navegarti/rn-design-system/utils';
|
|
500
|
+
|
|
501
|
+
// Camel case conversion
|
|
502
|
+
const camel = camelCase('hello-world'); // helloWorld
|
|
503
|
+
|
|
504
|
+
// Sort array of objects
|
|
505
|
+
const users = [{ name: 'Bob' }, { name: 'Alice' }];
|
|
506
|
+
const sorted = sortBy(users, 'name'); // Alphabetical order
|
|
507
|
+
|
|
508
|
+
// Get unique items
|
|
509
|
+
const unique = uniqBy(users, 'name');
|
|
510
|
+
|
|
511
|
+
// Age calculation
|
|
512
|
+
const age = getAge('1990-01-01');
|
|
513
|
+
|
|
514
|
+
// Extract numbers
|
|
515
|
+
const numbers = getOnlyNumbers('(11) 9999-8888'); // 119999888
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
### Date Formatting
|
|
12
519
|
|
|
13
|
-
|
|
520
|
+
```typescript
|
|
521
|
+
import {
|
|
522
|
+
formatDate,
|
|
523
|
+
formatTime,
|
|
524
|
+
formatDateTime,
|
|
525
|
+
} from '@navegarti/rn-design-system/utils';
|
|
14
526
|
|
|
527
|
+
const date = new Date();
|
|
528
|
+
const formatted = formatDate(date); // DD/MM/YYYY
|
|
529
|
+
const time = formatTime(date); // HH:MM:SS
|
|
530
|
+
const combined = formatDateTime(date); // DD/MM/YYYY HH:MM:SS
|
|
531
|
+
```
|
|
15
532
|
|
|
16
|
-
|
|
17
|
-
import { multiply } from '@navegarti/rn-design-system';
|
|
533
|
+
### Input Masks
|
|
18
534
|
|
|
19
|
-
|
|
535
|
+
```typescript
|
|
536
|
+
import { Masks } from '@navegarti/rn-design-system/utils';
|
|
20
537
|
|
|
21
|
-
|
|
538
|
+
// CPF mask
|
|
539
|
+
const cpfMask = Masks.cpf('12345678901'); // 123.456.789-01
|
|
540
|
+
|
|
541
|
+
// Phone mask
|
|
542
|
+
const phoneMask = Masks.phone('1199998888'); // (11) 99999-888
|
|
543
|
+
|
|
544
|
+
// Currency mask
|
|
545
|
+
const currencyMask = Masks.currency('1299'); // R$ 12,99
|
|
22
546
|
```
|
|
23
547
|
|
|
548
|
+
---
|
|
24
549
|
|
|
25
|
-
##
|
|
550
|
+
## ๐ก API Integration
|
|
26
551
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
552
|
+
### Basic Setup
|
|
553
|
+
|
|
554
|
+
```typescript
|
|
555
|
+
import { AxiosAdapter } from '@navegarti/rn-design-system/api';
|
|
556
|
+
|
|
557
|
+
const api = new AxiosAdapter({
|
|
558
|
+
baseURL: 'https://api.example.com',
|
|
559
|
+
timeout: 10000,
|
|
560
|
+
retryAttempts: 3,
|
|
561
|
+
});
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
### Making Requests
|
|
565
|
+
|
|
566
|
+
```typescript
|
|
567
|
+
// GET request
|
|
568
|
+
const posts = await api.get<Post[]>('/posts');
|
|
569
|
+
if (posts.success && posts.data) {
|
|
570
|
+
console.log('Posts:', posts.data);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// POST request
|
|
574
|
+
const newPost: Post = { title: 'New Post', body: 'Content' };
|
|
575
|
+
const response = await api.post('/posts', newPost);
|
|
576
|
+
|
|
577
|
+
// PUT request
|
|
578
|
+
const updated = await api.put('/posts/1', { title: 'Updated' });
|
|
579
|
+
|
|
580
|
+
// DELETE request
|
|
581
|
+
const deleted = await api.delete('/posts/1');
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
### Error Handling
|
|
585
|
+
|
|
586
|
+
```typescript
|
|
587
|
+
const response = await api.get('/posts');
|
|
588
|
+
|
|
589
|
+
if (!response.success) {
|
|
590
|
+
switch (response.statusCode) {
|
|
591
|
+
case 401:
|
|
592
|
+
console.log('Unauthorized');
|
|
593
|
+
break;
|
|
594
|
+
case 404:
|
|
595
|
+
console.log('Not found');
|
|
596
|
+
break;
|
|
597
|
+
case 500:
|
|
598
|
+
console.log('Server error');
|
|
599
|
+
break;
|
|
600
|
+
default:
|
|
601
|
+
console.log('Error:', response.error);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
```
|
|
30
605
|
|
|
31
|
-
|
|
606
|
+
### Authentication
|
|
32
607
|
|
|
33
|
-
|
|
608
|
+
```typescript
|
|
609
|
+
import { apiRequest } from '@navegarti/rn-design-system/api';
|
|
610
|
+
|
|
611
|
+
// Add token
|
|
612
|
+
apiRequest.addToken('your-jwt-token');
|
|
613
|
+
|
|
614
|
+
// Make authenticated request
|
|
615
|
+
const profile = await apiRequest.get('/profile');
|
|
616
|
+
|
|
617
|
+
// Remove token when logging out
|
|
618
|
+
apiRequest.removeToken();
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
---
|
|
622
|
+
|
|
623
|
+
## ๐ Form Validation
|
|
624
|
+
|
|
625
|
+
### Using Zod Validators
|
|
626
|
+
|
|
627
|
+
```typescript
|
|
628
|
+
import { formValidators } from '@navegarti/rn-design-system/form';
|
|
629
|
+
|
|
630
|
+
const emailValidator = formValidators.email;
|
|
631
|
+
const passwordValidator = formValidators.password;
|
|
632
|
+
|
|
633
|
+
const email = 'user@example.com';
|
|
634
|
+
const result = emailValidator.safeParse(email);
|
|
635
|
+
|
|
636
|
+
if (result.success) {
|
|
637
|
+
console.log('Valid email');
|
|
638
|
+
} else {
|
|
639
|
+
console.log('Invalid email:', result.error.errors);
|
|
640
|
+
}
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
### TanStack Form Integration
|
|
644
|
+
|
|
645
|
+
```typescript
|
|
646
|
+
import { tanstackForm } from '@navegarti/rn-design-system/form';
|
|
647
|
+
import { useForm } from '@tanstack/react-form';
|
|
648
|
+
|
|
649
|
+
const form = useForm({
|
|
650
|
+
defaultValues: {
|
|
651
|
+
firstName: '',
|
|
652
|
+
lastName: '',
|
|
653
|
+
},
|
|
654
|
+
onSubmit: async (values) => {
|
|
655
|
+
console.log('Form submitted:', values);
|
|
656
|
+
},
|
|
657
|
+
});
|
|
658
|
+
```
|
|
659
|
+
|
|
660
|
+
---
|
|
661
|
+
|
|
662
|
+
## ๐ Examples
|
|
663
|
+
|
|
664
|
+
For interactive examples, check out the [example](./example) folder:
|
|
665
|
+
|
|
666
|
+
```bash
|
|
667
|
+
# Navigate to example
|
|
668
|
+
cd example
|
|
669
|
+
|
|
670
|
+
# Install dependencies
|
|
671
|
+
yarn install
|
|
672
|
+
|
|
673
|
+
# Run on iOS
|
|
674
|
+
yarn ios
|
|
675
|
+
|
|
676
|
+
# Run on Android
|
|
677
|
+
yarn android
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
Available examples:
|
|
681
|
+
- **api-examples.tsx**: Complete API integration patterns
|
|
682
|
+
- **API-EXAMPLES-README.md**: Detailed API documentation
|
|
683
|
+
|
|
684
|
+
---
|
|
685
|
+
|
|
686
|
+
## ๐งช Testing
|
|
687
|
+
|
|
688
|
+
Run unit tests:
|
|
689
|
+
|
|
690
|
+
```bash
|
|
691
|
+
yarn test
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
---
|
|
695
|
+
|
|
696
|
+
## ๐ Documentation
|
|
697
|
+
|
|
698
|
+
- [API Examples](./example/API-EXAMPLES-README.md) - Detailed API usage
|
|
699
|
+
|
|
700
|
+
---
|
|
701
|
+
|
|
702
|
+
## ๐ Security
|
|
703
|
+
|
|
704
|
+
For security-related hooks and utilities, ensure your app requires:
|
|
705
|
+
- Permission checks via `react-native-permissions`
|
|
706
|
+
|
|
707
|
+
---
|
|
708
|
+
|
|
709
|
+
## ๐ ๏ธ Troubleshooting
|
|
710
|
+
|
|
711
|
+
### Module Not Found
|
|
712
|
+
|
|
713
|
+
```bash
|
|
714
|
+
# Clean install
|
|
715
|
+
yarn clean
|
|
716
|
+
yarn install
|
|
717
|
+
yarn prepare
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
### TypeScript Errors
|
|
721
|
+
|
|
722
|
+
Ensure `tsconfig.json` includes:
|
|
723
|
+
```json
|
|
724
|
+
{
|
|
725
|
+
"compilerOptions": {
|
|
726
|
+
"moduleResolution": "node",
|
|
727
|
+
"skipLibCheck": true,
|
|
728
|
+
"esModuleInterop": true
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
```
|
|
732
|
+
|
|
733
|
+
### Peer Dependency Issues
|
|
734
|
+
|
|
735
|
+
Install missing dependencies:
|
|
736
|
+
```bash
|
|
737
|
+
yarn add react react-native react-native-svg @emotion/react @emotion/native
|
|
738
|
+
```
|
|
34
739
|
|
|
35
740
|
---
|
|
36
741
|
|
|
37
|
-
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
|
742
|
+
Made with โค๏ธ by Navegar Team | Built with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|