@evlop/native-components 1.0.253 → 1.0.255
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 +456 -0
- package/dist/cjs/src/Actionable.d.ts +1 -1
- package/dist/cjs/src/Actionable.d.ts.map +1 -1
- package/dist/cjs/src/Actionable.js +2 -163
- package/dist/cjs/src/Actionable.js.map +1 -1
- package/dist/cjs/src/Button.d.ts +3 -0
- package/dist/cjs/src/Button.d.ts.map +1 -1
- package/dist/cjs/src/Button.js +35 -26
- package/dist/cjs/src/Button.js.map +1 -1
- package/dist/cjs/src/hooks/index.d.ts +2 -0
- package/dist/cjs/src/hooks/index.d.ts.map +1 -0
- package/dist/cjs/src/hooks/index.js +18 -0
- package/dist/cjs/src/hooks/index.js.map +1 -0
- package/dist/cjs/src/hooks/useAnimatedPress.d.ts +56 -0
- package/dist/cjs/src/hooks/useAnimatedPress.d.ts.map +1 -0
- package/dist/cjs/src/hooks/useAnimatedPress.js +168 -0
- package/dist/cjs/src/hooks/useAnimatedPress.js.map +1 -0
- package/dist/cjs/src/utils/index.d.ts +1 -0
- package/dist/cjs/src/utils/index.d.ts.map +1 -1
- package/dist/cjs/src/utils/index.js +1 -0
- package/dist/cjs/src/utils/index.js.map +1 -1
- package/dist/cjs/src/utils/pushNotification.d.ts +13 -0
- package/dist/cjs/src/utils/pushNotification.d.ts.map +1 -0
- package/dist/cjs/src/utils/pushNotification.js +21 -0
- package/dist/cjs/src/utils/pushNotification.js.map +1 -0
- package/dist/cjs/src/utils/pushNotification.native.d.ts +19 -0
- package/dist/cjs/src/utils/pushNotification.native.d.ts.map +1 -0
- package/dist/cjs/src/utils/pushNotification.native.js +113 -0
- package/dist/cjs/src/utils/pushNotification.native.js.map +1 -0
- package/dist/types/main.ai.d.ts +3 -1
- package/dist/types/src/Actionable.d.ts +1 -1
- package/dist/types/src/Actionable.d.ts.map +1 -1
- package/dist/types/src/Button.d.ts +3 -0
- package/dist/types/src/Button.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useAnimatedPress.d.ts +56 -0
- package/dist/types/src/hooks/useAnimatedPress.d.ts.map +1 -0
- package/dist/types/src/utils/index.d.ts +1 -0
- package/dist/types/src/utils/index.d.ts.map +1 -1
- package/dist/types/src/utils/pushNotification.d.ts +13 -0
- package/dist/types/src/utils/pushNotification.d.ts.map +1 -0
- package/dist/types/src/utils/pushNotification.native.d.ts +19 -0
- package/dist/types/src/utils/pushNotification.native.d.ts.map +1 -0
- package/package.json +3 -1
package/README.md
ADDED
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
# Native Components
|
|
2
|
+
|
|
3
|
+
A collection of React Native components with styled-system integration for building beautiful, consistent UI. These components are designed for use with AI-powered code generation tools.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @evlop/native-components
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Box, Flexbox, Text, Icon, Button, Actionable, Image, ImageBackground, Swiper, triggerHapticFeedback } from 'types-for-ai';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Components & Use Cases
|
|
20
|
+
|
|
21
|
+
### 📦 Box
|
|
22
|
+
|
|
23
|
+
A styled `View` component with support for layout, spacing, borders, colors, and positioning.
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
// Basic container
|
|
27
|
+
<Box padding={16} backgroundColor="white" borderRadius={8}>
|
|
28
|
+
<Text>Content</Text>
|
|
29
|
+
</Box>
|
|
30
|
+
|
|
31
|
+
// Card with shadow effect
|
|
32
|
+
<Box
|
|
33
|
+
margin={16}
|
|
34
|
+
padding={20}
|
|
35
|
+
backgroundColor="white"
|
|
36
|
+
borderRadius={12}
|
|
37
|
+
borderWidth={1}
|
|
38
|
+
borderColor="gray-200"
|
|
39
|
+
>
|
|
40
|
+
<Text>Card Content</Text>
|
|
41
|
+
</Box>
|
|
42
|
+
|
|
43
|
+
// Absolute positioned overlay
|
|
44
|
+
<Box position="absolute" top={0} left={0} right={0} bottom={0} opacity={0.5} backgroundColor="black" />
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Props:** All React Native `ViewProps` + `flexbox`, `border`, `layout`, `color`, `background`, `space`, `opacity`, `position`
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
### 🧩 Flexbox
|
|
52
|
+
|
|
53
|
+
A flexbox container with default `flexDirection: 'row'` and gap support.
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
// Horizontal row with items
|
|
57
|
+
<Flexbox flexDirection="row" justifyContent="space-between" alignItems="center" gap={12}>
|
|
58
|
+
<Icon icon="home" />
|
|
59
|
+
<Text>Home</Text>
|
|
60
|
+
</Flexbox>
|
|
61
|
+
|
|
62
|
+
// Vertical stack
|
|
63
|
+
<Flexbox flexDirection="column" gap={8} padding={16}>
|
|
64
|
+
<Text>Item 1</Text>
|
|
65
|
+
<Text>Item 2</Text>
|
|
66
|
+
<Text>Item 3</Text>
|
|
67
|
+
</Flexbox>
|
|
68
|
+
|
|
69
|
+
// Grid-like layout
|
|
70
|
+
<Flexbox flexWrap="wrap" gap={16} rowGap={8} columnGap={12}>
|
|
71
|
+
{items.map(item => <Box key={item.id} width="48%">{item.name}</Box>)}
|
|
72
|
+
</Flexbox>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Props:** All `Box` props + `gap`, `rowGap`, `columnGap`
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
### ✏️ Text
|
|
80
|
+
|
|
81
|
+
A styled text component with typography support, theme variants, and template rendering.
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
// Basic text
|
|
85
|
+
<Text color="gray-900" fontSize={16}>Hello World</Text>
|
|
86
|
+
|
|
87
|
+
// Styled heading
|
|
88
|
+
<Text fontWeight="Bold" fontSize={24} color="primary">
|
|
89
|
+
Welcome Back!
|
|
90
|
+
</Text>
|
|
91
|
+
|
|
92
|
+
// Using theme variants
|
|
93
|
+
<Text variant="heading">Heading Text</Text>
|
|
94
|
+
<Text variant="body">Body text content</Text>
|
|
95
|
+
|
|
96
|
+
// Font scaling (relative to base font size)
|
|
97
|
+
<Text fontScale={1.5}>Larger Text</Text>
|
|
98
|
+
|
|
99
|
+
// Dynamic template content (supports handlebars)
|
|
100
|
+
<Text content="Hello, {{user.name}}!" />
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Props:** `color`, `fontSize`, `fontWeight`, `fontScale`, `textAlign`, `variant`, `content` + standard `TextProps`
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
### 🎨 Icon
|
|
108
|
+
|
|
109
|
+
Display icons from various icon libraries with RTL support.
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
// Basic icon
|
|
113
|
+
<Icon icon="home" size={24} color="primary" />
|
|
114
|
+
|
|
115
|
+
// Different sizes
|
|
116
|
+
<Icon icon="settings" size={32} color="gray-600" />
|
|
117
|
+
|
|
118
|
+
// With press handler
|
|
119
|
+
<Icon icon="close" onPress={() => navigation.goBack()} />
|
|
120
|
+
|
|
121
|
+
// RTL flip support (for directional icons like arrows)
|
|
122
|
+
<Icon icon="arrow-right" flipOnRTL />
|
|
123
|
+
|
|
124
|
+
// Supported icon libraries:
|
|
125
|
+
// - material-icons
|
|
126
|
+
// - material-community-icons
|
|
127
|
+
// - font-awesome-6
|
|
128
|
+
// - ionicons
|
|
129
|
+
// - simple-line-icons
|
|
130
|
+
// - evilicons
|
|
131
|
+
// - octicons
|
|
132
|
+
// - svg (custom SVG URLs)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Props:** `icon`, `size`, `color`, `flipOnRTL`, `onPress`
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
### 🔘 Button
|
|
140
|
+
|
|
141
|
+
A styled button with multiple variants, sizes, loading states, and icon support.
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
// Filled button (default)
|
|
145
|
+
<Button label="Get Started" color="primary" action={myAction} />
|
|
146
|
+
|
|
147
|
+
// Outlined button
|
|
148
|
+
<Button label="Learn More" variant="outlined" color="secondary" />
|
|
149
|
+
|
|
150
|
+
// Ghost button (no background)
|
|
151
|
+
<Button label="Cancel" variant="ghost" color="gray-600" />
|
|
152
|
+
|
|
153
|
+
// Dim outlined (subtle border)
|
|
154
|
+
<Button label="Optional" variant="dim-outlined" color="primary" />
|
|
155
|
+
|
|
156
|
+
// Dim filled outlined (subtle background + border)
|
|
157
|
+
<Button label="Soft CTA" variant="dim-filled-outlined" color="primary" />
|
|
158
|
+
|
|
159
|
+
// With icon
|
|
160
|
+
<Button label="Add Item" icon="plus" iconPosition="left" color="primary" />
|
|
161
|
+
<Button label="Next" icon="arrow-right" iconPosition="right" />
|
|
162
|
+
|
|
163
|
+
// Different sizes
|
|
164
|
+
<Button label="Small" size="sm" />
|
|
165
|
+
<Button label="Medium" size="md" />
|
|
166
|
+
<Button label="Large" size="lg" />
|
|
167
|
+
<Button label="Extra Large" size="xl" />
|
|
168
|
+
<Button label="2X Large" size="2xl" />
|
|
169
|
+
|
|
170
|
+
// Loading state
|
|
171
|
+
<Button label="Submitting..." loading={true} />
|
|
172
|
+
|
|
173
|
+
// Disabled state
|
|
174
|
+
<Button label="Unavailable" disabled={true} />
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Variants:** `filled`, `outlined`, `dim-outlined`, `dim-filled-outlined`, `ghost`
|
|
178
|
+
**Sizes:** `sm`, `md`, `lg`, `xl`, `2xl`
|
|
179
|
+
**Props:** `label`, `variant`, `size`, `color`, `textColor`, `icon`, `iconPosition`, `loading`, `disabled`, `action`
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
### 👆 Actionable
|
|
184
|
+
|
|
185
|
+
A pressable wrapper with press effects and haptic feedback support.
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
// Basic actionable area
|
|
189
|
+
<Actionable action={navigateAction}>
|
|
190
|
+
<Text>Tap me</Text>
|
|
191
|
+
</Actionable>
|
|
192
|
+
|
|
193
|
+
// With scale press effect
|
|
194
|
+
<Actionable action={myAction} pressEffect="scale">
|
|
195
|
+
<Box padding={16}><Text>Press to scale</Text></Box>
|
|
196
|
+
</Actionable>
|
|
197
|
+
|
|
198
|
+
// With opacity press effect
|
|
199
|
+
<Actionable pressEffect="opacity" action={myAction}>
|
|
200
|
+
<Image src="card-image.jpg" />
|
|
201
|
+
</Actionable>
|
|
202
|
+
|
|
203
|
+
// With haptic feedback
|
|
204
|
+
<Actionable action={myAction} hapticFeedback="impactMedium">
|
|
205
|
+
<Text>Haptic button</Text>
|
|
206
|
+
</Actionable>
|
|
207
|
+
|
|
208
|
+
// Combined effects
|
|
209
|
+
<Actionable
|
|
210
|
+
action={addToCartAction}
|
|
211
|
+
pressEffect="bounce"
|
|
212
|
+
hapticFeedback="impactLight"
|
|
213
|
+
>
|
|
214
|
+
<Box backgroundColor="primary" padding={12} borderRadius={8}>
|
|
215
|
+
<Text color="white">Add to Cart</Text>
|
|
216
|
+
</Box>
|
|
217
|
+
</Actionable>
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**Press Effects:**
|
|
221
|
+
- `none` - No visual effect
|
|
222
|
+
- `opacity` - Fades on press
|
|
223
|
+
- `scale` - Shrinks slightly on press
|
|
224
|
+
- `scale-opacity` - Combines scale and opacity
|
|
225
|
+
- `bounce` - Bouncy spring effect
|
|
226
|
+
- `tilt-left` / `tilt-right` - Tilts on press
|
|
227
|
+
- `pulse` - Pulsing animation
|
|
228
|
+
- `jelly` - Elastic jelly effect
|
|
229
|
+
- `rubberBand` - Rubber band stretch effect
|
|
230
|
+
- `glow` - Glowing highlight effect
|
|
231
|
+
- `press-in` - 3D press-in effect
|
|
232
|
+
- `swing` - Swinging rotation
|
|
233
|
+
|
|
234
|
+
**Haptic Types:** `impactLight`, `impactMedium`, `impactHeavy`, `rigid`, `soft`, `notificationSuccess`, `notificationWarning`, `notificationError`
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
### 🖼️ Image
|
|
239
|
+
|
|
240
|
+
A styled image component with preset sizes and template URL support.
|
|
241
|
+
|
|
242
|
+
```tsx
|
|
243
|
+
// Basic image
|
|
244
|
+
<Image src="https://example.com/image.jpg" />
|
|
245
|
+
|
|
246
|
+
// Using preset sizes
|
|
247
|
+
<Image src="product.jpg" size="md" />
|
|
248
|
+
<Image src="avatar.jpg" size="xs" />
|
|
249
|
+
<Image src="banner.jpg" size="fluid" />
|
|
250
|
+
|
|
251
|
+
// Custom dimensions
|
|
252
|
+
<Image src="photo.jpg" width={200} height={150} />
|
|
253
|
+
|
|
254
|
+
// With aspect ratio
|
|
255
|
+
<Image src="video-thumb.jpg" aspectRatio={16/9} />
|
|
256
|
+
|
|
257
|
+
// Resize modes
|
|
258
|
+
<Image src="cover.jpg" resizeMode="cover" />
|
|
259
|
+
<Image src="contain.jpg" resizeMode="contain" />
|
|
260
|
+
|
|
261
|
+
// With placeholder fallback
|
|
262
|
+
<Image src="{{product.image}}" placeholder="default-product.jpg" />
|
|
263
|
+
|
|
264
|
+
// Dynamic URL with template
|
|
265
|
+
<Image src="{{baseUrl}}/images/{{product.id}}.jpg" />
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**Preset Sizes:** `3xs` (15px), `2xs` (35px), `xs` (50px), `sm` (75px), `md` (150px), `lg` (275px), `xl` (300px), `2xl` (400px), `3xl` (480px), `fluid` (100%)
|
|
269
|
+
|
|
270
|
+
**Props:** `src`, `placeholder`, `size`, `width`, `height`, `aspectRatio`, `resizeMode`
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
### 🖼️ ImageBackground
|
|
275
|
+
|
|
276
|
+
An image that can contain child elements, perfect for hero sections and cards.
|
|
277
|
+
|
|
278
|
+
```tsx
|
|
279
|
+
// Hero section
|
|
280
|
+
<ImageBackground
|
|
281
|
+
src="hero-bg.jpg"
|
|
282
|
+
height={300}
|
|
283
|
+
justifyContent="center"
|
|
284
|
+
alignItems="center"
|
|
285
|
+
>
|
|
286
|
+
<Text color="white" fontSize={32} fontWeight="Bold">
|
|
287
|
+
Welcome
|
|
288
|
+
</Text>
|
|
289
|
+
</ImageBackground>
|
|
290
|
+
|
|
291
|
+
// Card with background
|
|
292
|
+
<ImageBackground
|
|
293
|
+
src="{{product.coverImage}}"
|
|
294
|
+
aspectRatio={16/9}
|
|
295
|
+
borderRadius={12}
|
|
296
|
+
overflow="hidden"
|
|
297
|
+
>
|
|
298
|
+
<Box position="absolute" bottom={0} left={0} right={0} padding={16} backgroundColor="rgba(0,0,0,0.5)">
|
|
299
|
+
<Text color="white">Product Name</Text>
|
|
300
|
+
</Box>
|
|
301
|
+
</ImageBackground>
|
|
302
|
+
|
|
303
|
+
// With template URL and placeholder
|
|
304
|
+
<ImageBackground
|
|
305
|
+
src="{{user.coverPhoto}}"
|
|
306
|
+
placeholder="default-cover.jpg"
|
|
307
|
+
height={200}
|
|
308
|
+
>
|
|
309
|
+
{children}
|
|
310
|
+
</ImageBackground>
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
**Props:** `src`, `placeholder`, all `Box` layout/styling props
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
### 🎠 Swiper
|
|
318
|
+
|
|
319
|
+
A horizontal carousel/slider with multiple pagination styles and autoplay support.
|
|
320
|
+
|
|
321
|
+
```tsx
|
|
322
|
+
// Basic swiper
|
|
323
|
+
<Swiper
|
|
324
|
+
data={slides}
|
|
325
|
+
renderItem={({ item }) => (
|
|
326
|
+
<Image src={item.image} width="100%" aspectRatio={16/9} />
|
|
327
|
+
)}
|
|
328
|
+
/>
|
|
329
|
+
|
|
330
|
+
// With autoplay
|
|
331
|
+
<Swiper
|
|
332
|
+
data={banners}
|
|
333
|
+
autoplay
|
|
334
|
+
autoplayInterval={3000}
|
|
335
|
+
renderItem={({ item }) => <BannerCard banner={item} />}
|
|
336
|
+
/>
|
|
337
|
+
|
|
338
|
+
// Different pagination styles
|
|
339
|
+
<Swiper data={items} paginationType="dot" />
|
|
340
|
+
<Swiper data={items} paginationType="dash" />
|
|
341
|
+
<Swiper data={items} paginationType="line" />
|
|
342
|
+
<Swiper data={items} paginationType="number" />
|
|
343
|
+
|
|
344
|
+
// Custom item width
|
|
345
|
+
<Swiper
|
|
346
|
+
data={cards}
|
|
347
|
+
itemWidth={280}
|
|
348
|
+
renderItem={({ item }) => <ProductCard product={item} />}
|
|
349
|
+
/>
|
|
350
|
+
|
|
351
|
+
// With index change callback
|
|
352
|
+
<Swiper
|
|
353
|
+
data={onboardingScreens}
|
|
354
|
+
onIndexChange={(index) => setCurrentStep(index)}
|
|
355
|
+
renderItem={({ item }) => <OnboardingSlide {...item} />}
|
|
356
|
+
/>
|
|
357
|
+
|
|
358
|
+
// Using ref for programmatic control
|
|
359
|
+
const swiperRef = useRef();
|
|
360
|
+
<Swiper ref={swiperRef} data={items} />
|
|
361
|
+
<Button label="Next" action={() => swiperRef.current.scrollToIndex(2)} />
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
**Pagination Types:** `dash`, `dot`, `line`, `number`
|
|
365
|
+
**Props:** `data`, `renderItem`, `autoplay`, `autoplayInterval`, `paginationType`, `paginationStyle`, `itemWidth`, `onIndexChange`
|
|
366
|
+
|
|
367
|
+
---
|
|
368
|
+
|
|
369
|
+
### 📳 triggerHapticFeedback
|
|
370
|
+
|
|
371
|
+
A utility function to trigger haptic feedback on supported devices.
|
|
372
|
+
|
|
373
|
+
```tsx
|
|
374
|
+
import { triggerHapticFeedback } from 'types-for-ai';
|
|
375
|
+
|
|
376
|
+
// On button press
|
|
377
|
+
const handlePress = () => {
|
|
378
|
+
triggerHapticFeedback('impactMedium');
|
|
379
|
+
// ... do something
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
// Success notification
|
|
383
|
+
const onSuccess = () => {
|
|
384
|
+
triggerHapticFeedback('notificationSuccess');
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
// Error feedback
|
|
388
|
+
const onError = () => {
|
|
389
|
+
triggerHapticFeedback('notificationError');
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
// Light tap feedback
|
|
393
|
+
triggerHapticFeedback('impactLight');
|
|
394
|
+
|
|
395
|
+
// Heavy impact
|
|
396
|
+
triggerHapticFeedback('impactHeavy');
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
**Haptic Types:**
|
|
400
|
+
- `impactLight` - Light tap
|
|
401
|
+
- `impactMedium` - Medium tap
|
|
402
|
+
- `impactHeavy` - Heavy tap
|
|
403
|
+
- `rigid` - Rigid impact
|
|
404
|
+
- `soft` - Soft impact
|
|
405
|
+
- `notificationSuccess` - Success notification pattern
|
|
406
|
+
- `notificationWarning` - Warning notification pattern
|
|
407
|
+
- `notificationError` - Error notification pattern
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
## Styled System Props Reference
|
|
412
|
+
|
|
413
|
+
All components support [styled-system](https://styled-system.com/) props:
|
|
414
|
+
|
|
415
|
+
| Category | Props |
|
|
416
|
+
|----------|-------|
|
|
417
|
+
| **Space** | `margin`, `marginTop`, `marginRight`, `marginBottom`, `marginLeft`, `padding`, `paddingTop`, `paddingRight`, `paddingBottom`, `paddingLeft`, `m`, `mt`, `mr`, `mb`, `ml`, `p`, `pt`, `pr`, `pb`, `pl` |
|
|
418
|
+
| **Layout** | `width`, `height`, `minWidth`, `maxWidth`, `minHeight`, `maxHeight`, `overflow` |
|
|
419
|
+
| **Flexbox** | `flex`, `flexDirection`, `flexWrap`, `justifyContent`, `alignItems`, `alignSelf` |
|
|
420
|
+
| **Border** | `border`, `borderWidth`, `borderColor`, `borderRadius`, `borderTop`, `borderRight`, `borderBottom`, `borderLeft` |
|
|
421
|
+
| **Color** | `color`, `backgroundColor`, `bg`, `opacity` |
|
|
422
|
+
| **Position** | `position`, `top`, `right`, `bottom`, `left`, `zIndex` |
|
|
423
|
+
| **Typography** | `fontSize`, `fontWeight`, `textAlign`, `lineHeight`, `fontFamily` |
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## Theme Integration
|
|
428
|
+
|
|
429
|
+
Components automatically use theme values from your styled-components `ThemeProvider`:
|
|
430
|
+
|
|
431
|
+
```tsx
|
|
432
|
+
const theme = {
|
|
433
|
+
colors: {
|
|
434
|
+
primary: '#6366f1',
|
|
435
|
+
secondary: '#8b5cf6',
|
|
436
|
+
'gray-100': '#f3f4f6',
|
|
437
|
+
'gray-900': '#111827',
|
|
438
|
+
},
|
|
439
|
+
space: [0, 4, 8, 16, 24, 32, 48, 64],
|
|
440
|
+
fontWeights: {
|
|
441
|
+
Regular: '400',
|
|
442
|
+
Medium: '500',
|
|
443
|
+
Bold: '700',
|
|
444
|
+
},
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
<ThemeProvider theme={theme}>
|
|
448
|
+
<App />
|
|
449
|
+
</ThemeProvider>
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
---
|
|
453
|
+
|
|
454
|
+
## License
|
|
455
|
+
|
|
456
|
+
MIT
|
|
@@ -2,7 +2,7 @@ import { Action } from '@evlop/commons';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { PressableProps } from 'react-native';
|
|
4
4
|
import { HapticType } from './utils/haptic';
|
|
5
|
-
|
|
5
|
+
import { EffectType } from './hooks/useAnimatedPress';
|
|
6
6
|
export interface BaseActionableProps extends PressableProps {
|
|
7
7
|
pressEffect?: EffectType;
|
|
8
8
|
hapticFeedback?: HapticType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Actionable.d.ts","sourceRoot":"","sources":["../../../src/Actionable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA2B,MAAM,gBAAgB,CAAC;AACjE,OAAO,
|
|
1
|
+
{"version":3,"file":"Actionable.d.ts","sourceRoot":"","sources":["../../../src/Actionable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA2B,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAsB,MAAM,OAAO,CAAC;AAC3C,OAAO,EAA8C,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,EAAE,UAAU,EAAyB,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAoB,MAAM,0BAA0B,CAAC;AAIxE,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACvD,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,cAAc,CAAC,EAAE,UAAU,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAWD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC,mBAAmB,CAsBnE,CAAA;;;;;;;;;;AAED,wBAImB"}
|
|
@@ -42,176 +42,15 @@ const commons_1 = require("@evlop/commons");
|
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
43
|
const react_native_1 = require("react-native");
|
|
44
44
|
const haptic_1 = require("./utils/haptic");
|
|
45
|
+
const useAnimatedPress_1 = require("./hooks/useAnimatedPress");
|
|
45
46
|
const native_1 = __importDefault(require("styled-components/native"));
|
|
46
47
|
const styled_system_1 = require("styled-system");
|
|
47
48
|
const AnimatedPressable = react_native_1.Animated.createAnimatedComponent(react_native_1.Pressable);
|
|
48
49
|
const StyledPressable = (0, native_1.default)(AnimatedPressable)(styled_system_1.border, styled_system_1.background, styled_system_1.layout, styled_system_1.space);
|
|
49
|
-
// Hook to create animated press effect
|
|
50
|
-
const useAnimatedPress = (effect) => {
|
|
51
|
-
return (0, react_1.useMemo)(() => {
|
|
52
|
-
if (effect === 'none') {
|
|
53
|
-
return {};
|
|
54
|
-
}
|
|
55
|
-
const animatedValue = new react_native_1.Animated.Value(1);
|
|
56
|
-
const handlePressIn = () => {
|
|
57
|
-
react_native_1.Animated.spring(animatedValue, {
|
|
58
|
-
toValue: 0,
|
|
59
|
-
useNativeDriver: true,
|
|
60
|
-
speed: 50,
|
|
61
|
-
bounciness: 4,
|
|
62
|
-
}).start();
|
|
63
|
-
};
|
|
64
|
-
const handlePressOut = () => {
|
|
65
|
-
react_native_1.Animated.spring(animatedValue, {
|
|
66
|
-
toValue: 1,
|
|
67
|
-
useNativeDriver: true,
|
|
68
|
-
speed: 20,
|
|
69
|
-
bounciness: 6,
|
|
70
|
-
}).start();
|
|
71
|
-
};
|
|
72
|
-
const getAnimatedStyle = () => {
|
|
73
|
-
switch (effect) {
|
|
74
|
-
case 'shrink':
|
|
75
|
-
return {
|
|
76
|
-
transform: [{
|
|
77
|
-
scale: animatedValue.interpolate({
|
|
78
|
-
inputRange: [0, 1],
|
|
79
|
-
outputRange: [0.95, 1],
|
|
80
|
-
}),
|
|
81
|
-
}],
|
|
82
|
-
};
|
|
83
|
-
case 'dim':
|
|
84
|
-
return {
|
|
85
|
-
opacity: animatedValue.interpolate({
|
|
86
|
-
inputRange: [0, 1],
|
|
87
|
-
outputRange: [0.7, 1],
|
|
88
|
-
}),
|
|
89
|
-
};
|
|
90
|
-
case 'shrink-dim':
|
|
91
|
-
return {
|
|
92
|
-
transform: [{
|
|
93
|
-
scale: animatedValue.interpolate({
|
|
94
|
-
inputRange: [0, 1],
|
|
95
|
-
outputRange: [0.95, 1],
|
|
96
|
-
}),
|
|
97
|
-
}],
|
|
98
|
-
opacity: animatedValue.interpolate({
|
|
99
|
-
inputRange: [0, 1],
|
|
100
|
-
outputRange: [0.7, 1],
|
|
101
|
-
}),
|
|
102
|
-
};
|
|
103
|
-
case 'push-down':
|
|
104
|
-
return {
|
|
105
|
-
transform: [
|
|
106
|
-
{
|
|
107
|
-
scale: animatedValue.interpolate({
|
|
108
|
-
inputRange: [0, 1],
|
|
109
|
-
outputRange: [0.97, 1],
|
|
110
|
-
}),
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
translateY: animatedValue.interpolate({
|
|
114
|
-
inputRange: [0, 1],
|
|
115
|
-
outputRange: [2, 0],
|
|
116
|
-
}),
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
};
|
|
120
|
-
case 'gentle-shrink':
|
|
121
|
-
return {
|
|
122
|
-
transform: [{
|
|
123
|
-
scale: animatedValue.interpolate({
|
|
124
|
-
inputRange: [0, 1],
|
|
125
|
-
outputRange: [0.98, 1],
|
|
126
|
-
}),
|
|
127
|
-
}],
|
|
128
|
-
};
|
|
129
|
-
case 'tilt':
|
|
130
|
-
return {
|
|
131
|
-
transform: [
|
|
132
|
-
{
|
|
133
|
-
scale: animatedValue.interpolate({
|
|
134
|
-
inputRange: [0, 1],
|
|
135
|
-
outputRange: [0.97, 1],
|
|
136
|
-
}),
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
rotateZ: animatedValue.interpolate({
|
|
140
|
-
inputRange: [0, 1],
|
|
141
|
-
outputRange: ['-2deg', '0deg'],
|
|
142
|
-
}),
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
perspective: animatedValue.interpolate({
|
|
146
|
-
inputRange: [0, 1],
|
|
147
|
-
outputRange: [800, 1000],
|
|
148
|
-
}),
|
|
149
|
-
},
|
|
150
|
-
],
|
|
151
|
-
};
|
|
152
|
-
case 'bounce':
|
|
153
|
-
return {
|
|
154
|
-
transform: [{
|
|
155
|
-
scale: animatedValue.interpolate({
|
|
156
|
-
inputRange: [0, 0.5, 1],
|
|
157
|
-
outputRange: [0.9, 0.95, 1],
|
|
158
|
-
}),
|
|
159
|
-
}],
|
|
160
|
-
};
|
|
161
|
-
case 'squeeze':
|
|
162
|
-
return {
|
|
163
|
-
transform: [
|
|
164
|
-
{
|
|
165
|
-
scaleX: animatedValue.interpolate({
|
|
166
|
-
inputRange: [0, 1],
|
|
167
|
-
outputRange: [0.92, 1],
|
|
168
|
-
}),
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
scaleY: animatedValue.interpolate({
|
|
172
|
-
inputRange: [0, 1],
|
|
173
|
-
outputRange: [1.04, 1],
|
|
174
|
-
}),
|
|
175
|
-
},
|
|
176
|
-
],
|
|
177
|
-
};
|
|
178
|
-
case 'pop':
|
|
179
|
-
return {
|
|
180
|
-
transform: [{
|
|
181
|
-
scale: animatedValue.interpolate({
|
|
182
|
-
inputRange: [0, 1],
|
|
183
|
-
outputRange: [1.05, 1],
|
|
184
|
-
}),
|
|
185
|
-
}],
|
|
186
|
-
};
|
|
187
|
-
case 'wobble':
|
|
188
|
-
return {
|
|
189
|
-
transform: [
|
|
190
|
-
{
|
|
191
|
-
scale: animatedValue.interpolate({
|
|
192
|
-
inputRange: [0, 1],
|
|
193
|
-
outputRange: [0.97, 1],
|
|
194
|
-
}),
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
rotateZ: animatedValue.interpolate({
|
|
198
|
-
inputRange: [0, 0.25, 0.5, 0.75, 1],
|
|
199
|
-
outputRange: ['0deg', '-1deg', '1deg', '-0.5deg', '0deg'],
|
|
200
|
-
}),
|
|
201
|
-
},
|
|
202
|
-
],
|
|
203
|
-
};
|
|
204
|
-
default:
|
|
205
|
-
return {};
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
return { handlePressIn, handlePressOut, animatedStyle: getAnimatedStyle() };
|
|
209
|
-
}, [effect]);
|
|
210
|
-
};
|
|
211
50
|
const BaseActionable = (_a) => {
|
|
212
51
|
var { action, pressEffect = 'none', hapticFeedback: hapticFeedbackType, style } = _a, props = __rest(_a, ["action", "pressEffect", "hapticFeedback", "style"]);
|
|
213
52
|
const onPress = (0, commons_1.useAction)(action);
|
|
214
|
-
const { handlePressIn, handlePressOut, animatedStyle } = useAnimatedPress(pressEffect);
|
|
53
|
+
const { handlePressIn, handlePressOut, animatedStyle } = (0, useAnimatedPress_1.useAnimatedPress)(pressEffect);
|
|
215
54
|
const handlePress = (0, react_1.useCallback)((event) => {
|
|
216
55
|
if (hapticFeedbackType) {
|
|
217
56
|
(0, haptic_1.triggerHapticFeedback)(hapticFeedbackType);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Actionable.js","sourceRoot":"","sources":["../../../src/Actionable.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAiE;AACjE,+
|
|
1
|
+
{"version":3,"file":"Actionable.js","sourceRoot":"","sources":["../../../src/Actionable.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAiE;AACjE,+CAA2C;AAC3C,+CAA0F;AAC1F,2CAAmE;AACnE,+DAAwE;AACxE,sEAA8C;AAC9C,iDAAkE;AASlE,MAAM,iBAAiB,GAAG,uBAAQ,CAAC,uBAAuB,CAAC,wBAAS,CAAC,CAAC;AAEtE,MAAM,eAAe,GAAG,IAAA,gBAAM,EAAC,iBAAiB,CAAC,CAC7C,sBAAM,EACN,0BAAU,EACV,sBAAM,EACN,qBAAK,CACR,CAAA;AAEM,MAAM,cAAc,GAA6C,CAAC,EAAqF,EAAE,EAAE;QAAzF,EAAE,MAAM,EAAE,WAAW,GAAG,MAAM,EAAE,cAAc,EAAE,kBAAkB,EAAE,KAAK,OAAY,EAAP,KAAK,cAAnF,oDAAqF,CAAF;IACxJ,MAAM,OAAO,GAAG,IAAA,mBAAS,EAAC,MAAM,CAAC,CAAC;IAClC,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,IAAA,mCAAgB,EAAC,WAAW,CAAC,CAAC;IAEvF,MAAM,WAAW,GAAG,IAAA,mBAAW,EAAC,CAAC,KAA4B,EAAE,EAAE;QAC7D,IAAI,kBAAkB,EAAE;YACpB,IAAA,8BAAqB,EAAC,kBAAkB,CAAC,CAAC;SAC7C;QACD,YAAY,CAAC,GAAG,EAAE;YACd,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,KAAK,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;IACP,CAAC,EAAE,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC,CAAC;IAElC,OAAO,CACH,8BAAC,eAAe,kBACZ,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EACzC,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,cAAc,EAC1B,KAAK,EAAE,CAAC,aAAa,EAAE,KAAK,CAAQ,IAChC,KAAK,EACX,CACL,CAAC;AACN,CAAC,CAAA;AAtBY,QAAA,cAAc,kBAsB1B;AAED,kBAAe,IAAA,sBAAY,EAAC;IACxB,IAAI,EAAE,YAAY;IAClB,oBAAoB,EAAE,EAAE;IACxB,YAAY,EAAE,EAAE;CACnB,CAAC,CAAC,sBAAc,CAAC,CAAC"}
|
package/dist/cjs/src/Button.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Action, Color, IconIdentifier, Theme } from '@evlop/commons';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { TextStyle, ViewProps } from 'react-native';
|
|
4
4
|
import { BackgroundColorProps, BorderProps, FontSizeProps, FontWeightProps, LayoutProps, SpaceProps } from 'styled-system';
|
|
5
|
+
import { EffectType } from './hooks/useAnimatedPress';
|
|
5
6
|
declare type ButtonSize = 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
6
7
|
export interface BaseButtonProps extends ViewProps, FontWeightProps<Theme>, FontSizeProps<Theme>, LayoutProps<Theme>, SpaceProps<Theme>, BackgroundColorProps<Theme>, BorderProps<Theme> {
|
|
7
8
|
disabled?: boolean;
|
|
@@ -15,6 +16,8 @@ export interface BaseButtonProps extends ViewProps, FontWeightProps<Theme>, Font
|
|
|
15
16
|
action?: Action;
|
|
16
17
|
icon?: IconIdentifier;
|
|
17
18
|
iconPosition?: 'left' | 'right';
|
|
19
|
+
iconSize?: number;
|
|
20
|
+
pressEffect?: EffectType;
|
|
18
21
|
}
|
|
19
22
|
export declare const BaseButton: React.FC<BaseButtonProps>;
|
|
20
23
|
declare const ButtonWithSettings: (props: BaseButtonProps & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAgC,MAAM,gBAAgB,CAAC;AAEpG,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAgC,MAAM,gBAAgB,CAAC;AAEpG,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAA0C,SAAS,EAAQ,SAAS,EAAE,MAAM,cAAc,CAAC;AAElG,OAAO,EAAmB,oBAAoB,EAAU,WAAW,EAAE,aAAa,EAAE,eAAe,EAAU,WAAW,EAAS,UAAU,EAAuB,MAAM,eAAe,CAAC;AAIxL,OAAO,EAAE,UAAU,EAAoB,MAAM,0BAA0B,CAAC;AAQxE,aAAK,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAEpD,MAAM,WAAW,eAAgB,SAAQ,SAAS,EAAE,eAAe,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,oBAAoB,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC;IACtL,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,cAAc,GAAG,qBAAqB,GAAG,OAAO,CAAC;IACnF,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,UAAU,CAAC;CAC1B;AAyHD,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAiEhD,CAAC;AAEF,QAAA,MAAM,kBAAkB;;;;;;;;uBAIV,CAAC;AAEf,eAAe,kBAAkB,CAAC"}
|