@prototyp/skeletor 1.0.8 → 1.0.10
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 +166 -15
- package/lib/module/components/Block/Block.js +21 -30
- package/lib/module/components/Block/Block.js.map +1 -1
- package/lib/module/components/InputFocusScrollView/InputFocusScrollView.js +16 -15
- package/lib/module/components/InputFocusScrollView/InputFocusScrollView.js.map +1 -1
- package/lib/module/components/Screen/Screen.js +13 -14
- package/lib/module/components/Screen/Screen.js.map +1 -1
- package/lib/module/components/SkeletorProvider/SkeletorContext.js.map +1 -1
- package/lib/module/components/SkeletorProvider/SkeletorProvider.js +4 -5
- package/lib/module/components/SkeletorProvider/SkeletorProvider.js.map +1 -1
- package/lib/module/components/SkeletorProvider/index.js +1 -1
- package/lib/module/components/SkeletorProvider/index.js.map +1 -1
- package/lib/module/components/Text/Text.js +25 -26
- package/lib/module/components/Text/Text.js.map +1 -1
- package/lib/module/components/index.js +3 -3
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/package.json +3 -0
- package/lib/module/hooks/index.js +2 -2
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/package.json +3 -0
- package/lib/module/hooks/skeleform/package.json +1 -1
- package/lib/module/hooks/skeleform/src/index.js +43 -14
- package/lib/module/hooks/skeleform/src/index.js.map +1 -1
- package/lib/module/hooks/skeleform/yarn.lock +50 -2967
- package/lib/module/hooks/useAndroidBackHandler.js +1 -1
- package/lib/module/hooks/useAndroidBackHandler.js.map +1 -1
- package/lib/module/hooks/useAnimation.js.map +1 -1
- package/lib/module/hooks/useAnimationTimeline.js +6 -7
- package/lib/module/hooks/useAnimationTimeline.js.map +1 -1
- package/lib/module/hooks/useAppState.js +6 -7
- package/lib/module/hooks/useAppState.js.map +1 -1
- package/lib/module/hooks/useSkeletor.js.map +1 -1
- package/lib/module/models/Animation.js +2 -0
- package/lib/module/models/Animation.js.map +1 -0
- package/lib/module/models/Flex.js +2 -0
- package/lib/module/models/Flex.js.map +1 -0
- package/lib/module/models/Position.js +2 -0
- package/lib/module/models/Position.js.map +1 -0
- package/lib/module/models/index.js +3 -0
- package/lib/module/models/index.js.map +1 -1
- package/lib/module/models/package.json +3 -0
- package/lib/module/utils/animations.js +204 -0
- package/lib/module/utils/animations.js.map +1 -0
- package/lib/module/utils/extractAlignmentProperties.js +3 -4
- package/lib/module/utils/extractAlignmentProperties.js.map +1 -1
- package/lib/module/utils/extractAnimationProperties.js +46 -0
- package/lib/module/utils/extractAnimationProperties.js.map +1 -0
- package/lib/module/utils/extractFlexProperties.js +24 -0
- package/lib/module/utils/extractFlexProperties.js.map +1 -0
- package/lib/module/utils/extractPositionProperties.js +20 -0
- package/lib/module/utils/extractPositionProperties.js.map +1 -0
- package/lib/module/utils/extractSizeProperties.js +0 -1
- package/lib/module/utils/extractSizeProperties.js.map +1 -1
- package/lib/module/utils/index.js +4 -0
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/package.json +3 -0
- package/lib/typescript/components/Block/Block.d.ts +8 -9
- package/lib/typescript/components/Block/Block.d.ts.map +1 -1
- package/lib/typescript/components/InputFocusScrollView/InputFocusScrollView.d.ts.map +1 -1
- package/lib/typescript/components/Screen/Screen.d.ts.map +1 -1
- package/lib/typescript/components/SkeletorProvider/SkeletorContext.d.ts.map +1 -1
- package/lib/typescript/components/SkeletorProvider/SkeletorProvider.d.ts.map +1 -1
- package/lib/typescript/components/SkeletorProvider/index.d.ts +1 -1
- package/lib/typescript/components/SkeletorProvider/index.d.ts.map +1 -1
- package/lib/typescript/components/Text/Text.d.ts +2 -2
- package/lib/typescript/components/Text/Text.d.ts.map +1 -1
- package/lib/typescript/components/index.d.ts +3 -3
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/hooks/index.d.ts +2 -2
- package/lib/typescript/hooks/index.d.ts.map +1 -1
- package/lib/typescript/hooks/skeleform/src/index.d.ts +3 -5
- package/lib/typescript/hooks/skeleform/src/index.d.ts.map +1 -1
- package/lib/typescript/hooks/useAnimation.d.ts +8 -8
- package/lib/typescript/hooks/useAnimation.d.ts.map +1 -1
- package/lib/typescript/hooks/useAnimationTimeline.d.ts +2 -2
- package/lib/typescript/hooks/useAnimationTimeline.d.ts.map +1 -1
- package/lib/typescript/hooks/useSkeletor.d.ts.map +1 -1
- package/lib/typescript/models/Alignment.d.ts +0 -1
- package/lib/typescript/models/Alignment.d.ts.map +1 -1
- package/lib/typescript/models/Animation.d.ts +30 -0
- package/lib/typescript/models/Animation.d.ts.map +1 -0
- package/lib/typescript/models/Border.d.ts +7 -14
- package/lib/typescript/models/Border.d.ts.map +1 -1
- package/lib/typescript/models/Flex.d.ts +15 -0
- package/lib/typescript/models/Flex.d.ts.map +1 -0
- package/lib/typescript/models/Position.d.ts +20 -0
- package/lib/typescript/models/Position.d.ts.map +1 -0
- package/lib/typescript/models/Size.d.ts +0 -1
- package/lib/typescript/models/Size.d.ts.map +1 -1
- package/lib/typescript/models/Spacing.d.ts +12 -19
- package/lib/typescript/models/Spacing.d.ts.map +1 -1
- package/lib/typescript/models/index.d.ts +3 -0
- package/lib/typescript/models/index.d.ts.map +1 -1
- package/lib/typescript/utils/animations.d.ts +21 -0
- package/lib/typescript/utils/animations.d.ts.map +1 -0
- package/lib/typescript/utils/extractAlignmentProperties.d.ts +9 -1
- package/lib/typescript/utils/extractAlignmentProperties.d.ts.map +1 -1
- package/lib/typescript/utils/extractAnimationProperties.d.ts +104 -0
- package/lib/typescript/utils/extractAnimationProperties.d.ts.map +1 -0
- package/lib/typescript/utils/extractFlexProperties.d.ts +3 -0
- package/lib/typescript/utils/extractFlexProperties.d.ts.map +1 -0
- package/lib/typescript/utils/extractPositionProperties.d.ts +13 -0
- package/lib/typescript/utils/extractPositionProperties.d.ts.map +1 -0
- package/lib/typescript/utils/extractSizeProperties.d.ts.map +1 -1
- package/lib/typescript/utils/index.d.ts +4 -0
- package/lib/typescript/utils/index.d.ts.map +1 -1
- package/package.json +15 -4
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ Use this as the top-level wrapper for every screen you navigate to. Is not inten
|
|
|
64
64
|
|
|
65
65
|
#### Props
|
|
66
66
|
|
|
67
|
-
```
|
|
67
|
+
```javascript
|
|
68
68
|
/** Pass a specific background view (gradients, animated backgrounds etc) OR just a background color value. Custom components should be 100% height and width to span the full screen area. */
|
|
69
69
|
background?: JSX.Element | string;
|
|
70
70
|
hideTopSafeArea?: boolean;
|
|
@@ -80,7 +80,7 @@ isLandscape?: boolean;
|
|
|
80
80
|
|
|
81
81
|
#### Usage
|
|
82
82
|
|
|
83
|
-
```
|
|
83
|
+
```javascript
|
|
84
84
|
function Component: React.FC = () => {
|
|
85
85
|
return <Screen background={<GradientBackground />} statusBarType="dark-content">
|
|
86
86
|
...
|
|
@@ -96,7 +96,7 @@ Will detect configured Font type, built with the ability to easily customize the
|
|
|
96
96
|
|
|
97
97
|
#### Props
|
|
98
98
|
|
|
99
|
-
```
|
|
99
|
+
```javascript
|
|
100
100
|
/** Inferred from @types/Font.d.ts */
|
|
101
101
|
font?: Font;
|
|
102
102
|
/** Either define [fontSize, lineHeight] or just one size applied to both fontSize and lineHeight */
|
|
@@ -106,13 +106,14 @@ letterSpacing?: TextStyle["letterSpacing"];
|
|
|
106
106
|
color?: string;
|
|
107
107
|
textAlign?: TextStyle["textAlign"];
|
|
108
108
|
opacity?: TextStyle["opacity"];
|
|
109
|
+
animations?: Partial<ViewStyle>;
|
|
109
110
|
```
|
|
110
111
|
|
|
111
112
|
#### Usage
|
|
112
113
|
|
|
113
114
|
To use the `Text` component, simply import it and pass in the desired props.
|
|
114
115
|
|
|
115
|
-
```
|
|
116
|
+
```javascript
|
|
116
117
|
import { Text } from "./Text";
|
|
117
118
|
|
|
118
119
|
function MyComponent() {
|
|
@@ -132,15 +133,42 @@ This is a flexible and customizable React Native component that can be used as e
|
|
|
132
133
|
|
|
133
134
|
#### Props
|
|
134
135
|
|
|
135
|
-
```
|
|
136
|
+
```javascript
|
|
136
137
|
/** Determine if Block is scrollable or not. If scrollable, extends ScrollView props. */
|
|
137
138
|
scrollable?: boolean;
|
|
139
|
+
animations?: Partial<ViewStyle>;
|
|
140
|
+
/** Whether the element is absolutely positioned. */
|
|
141
|
+
absolute?: boolean;
|
|
142
|
+
zIndex?: number;
|
|
143
|
+
overflow?: ViewStyle["overflow"];
|
|
144
|
+
/** Offsets to use in combination with position. Can be defined as [top, left?, bottom?, right?] or as an object **/
|
|
145
|
+
offsets?:
|
|
146
|
+
| [ViewStyle["top"]]
|
|
147
|
+
| [ViewStyle["top"], ViewStyle["left"]]
|
|
148
|
+
| [ViewStyle["top"], ViewStyle["left"], ViewStyle["bottom"]]
|
|
149
|
+
| [ViewStyle["top"], ViewStyle["left"], ViewStyle["bottom"], ViewStyle["right"]]
|
|
150
|
+
| {
|
|
151
|
+
top?: ViewStyle["top"];
|
|
152
|
+
bottom?: ViewStyle["bottom"];
|
|
153
|
+
left?: ViewStyle["left"];
|
|
154
|
+
right?: ViewStyle["right"];
|
|
155
|
+
};
|
|
138
156
|
align?: ViewStyle["alignItems"];
|
|
139
157
|
alignSelf?: ViewStyle["alignSelf"];
|
|
140
158
|
justify?: ViewStyle["justifyContent"];
|
|
141
159
|
flexDirection?: ViewStyle["flexDirection"];
|
|
142
|
-
|
|
143
|
-
|
|
160
|
+
flex?:
|
|
161
|
+
| number
|
|
162
|
+
| {
|
|
163
|
+
columnGap?: ViewStyle["columnGap"],
|
|
164
|
+
flex?: ViewStyle["flex"],
|
|
165
|
+
flexBasis?: ViewStyle["flexBasis"],
|
|
166
|
+
flexGrow?: ViewStyle["flexGrow"],
|
|
167
|
+
flexShrink?: ViewStyle["flexShrink"],
|
|
168
|
+
flexWrap?: ViewStyle["flexWrap"],
|
|
169
|
+
gap?: ViewStyle["gap"],
|
|
170
|
+
rowGap?: ViewStyle["rowGap"]
|
|
171
|
+
};
|
|
144
172
|
width?: number | string;
|
|
145
173
|
height?: number | string;
|
|
146
174
|
minHeight?: number | string;
|
|
@@ -176,7 +204,7 @@ border?: {
|
|
|
176
204
|
borderTopLeftRadius?: number;
|
|
177
205
|
borderTopRightRadius?: number;
|
|
178
206
|
borderBottomLeftRadius?: number;
|
|
179
|
-
|
|
207
|
+
... // all other border-related properties
|
|
180
208
|
};
|
|
181
209
|
|
|
182
210
|
```
|
|
@@ -185,7 +213,7 @@ border?: {
|
|
|
185
213
|
|
|
186
214
|
Use cases are many, but simple. This component is intended to be used as a building block for your layout. One example is:
|
|
187
215
|
|
|
188
|
-
```
|
|
216
|
+
```javascript
|
|
189
217
|
<Block
|
|
190
218
|
maxHeight="75%"
|
|
191
219
|
flexDirection="row"
|
|
@@ -206,7 +234,7 @@ This scroll view will automatically scroll to an active input field rendered ins
|
|
|
206
234
|
|
|
207
235
|
#### Props
|
|
208
236
|
|
|
209
|
-
```
|
|
237
|
+
```javascript
|
|
210
238
|
/** Decimal value of screen height percentage the input will be positioned at. */
|
|
211
239
|
/** Defaults to 0.3, just above the keyboard. */
|
|
212
240
|
focusPositionOffset?: number;
|
|
@@ -216,7 +244,7 @@ height?: "full" | "auto";
|
|
|
216
244
|
|
|
217
245
|
#### Usage
|
|
218
246
|
|
|
219
|
-
```
|
|
247
|
+
```javascript
|
|
220
248
|
<InputFocusScrollView focusPositionOffset={0.1}>
|
|
221
249
|
{(onInputFocus) => (
|
|
222
250
|
...
|
|
@@ -238,13 +266,134 @@ height?: "full" | "auto";
|
|
|
238
266
|
</InputFocusScrollView>
|
|
239
267
|
```
|
|
240
268
|
|
|
269
|
+
## Animations (>=v1.0.10)
|
|
270
|
+
|
|
271
|
+
New utilities have been created to reduce boilerplate when using animations Animated from react-native. The previous hook-based approach is still available.
|
|
272
|
+
|
|
273
|
+
### Overview
|
|
274
|
+
|
|
275
|
+
The concept behind this approach is to:
|
|
276
|
+
|
|
277
|
+
1. Define element animations and how they are triggered via `animateParallel`, `animateSequence` or `animateStagger`.
|
|
278
|
+
2. Place compiled element animations on an animation timeline OR trigger element animations separately.
|
|
279
|
+
|
|
280
|
+
### Defining element animations using animateParallel, animateStagger, animateSequence
|
|
281
|
+
|
|
282
|
+
Use these methods to construct <b>element</b> animations in a super simple way. Create these animations outside the component body to avoid unnecessary re-renders and other lifecycle related issues. All animations are done via native driver, <i>except if the animation loops to avoid issues with the animation itself.</i>
|
|
283
|
+
|
|
284
|
+
`animateParallel` will animate all of the defined element styles in parallel (meaning they will all start animating at the same time). In the example below, this means that opacity, translateY and translateX will all start animating at once. Additional configuration is possible as a second parameter, where you can define the animation `duration`, `loop` and `easing`. The default configuration is `{ duration: 800, easing: Easing.ease(Easing.quad) }`.
|
|
285
|
+
|
|
286
|
+
Usage
|
|
287
|
+
|
|
288
|
+
```javascript
|
|
289
|
+
const element1 = animateParallel({
|
|
290
|
+
opacity: [0, 1],
|
|
291
|
+
translateX: [20, 0],
|
|
292
|
+
translateY: [20, 0],
|
|
293
|
+
});
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
`animateSequence` will animate all of the defined element styles in sequence (meaning every property will start animating only when the previous property has finished animating). In the example below, that means that opacity, translateY and translateX will animate in sequence as they are defined - opacity first, translateX second, translateY last. Additional configuration is possible as a second parameter, where you can define the animation `duration`, `loop` and `easing`. The default configuration is `{ duration: 800, easing: Easing.ease(Easing.quad) }`.
|
|
297
|
+
|
|
298
|
+
Usage
|
|
299
|
+
|
|
300
|
+
```javascript
|
|
301
|
+
const element1 = animateSequence({
|
|
302
|
+
opacity: [0, 1],
|
|
303
|
+
translateX: [20, 0],
|
|
304
|
+
translateY: [20, 0],
|
|
305
|
+
});
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
`animateStagger` will animate all of the defined elements in the order they are defined at a staggered pace defined in the configuration object (meaning every property will start animating after an X amount of miliseconds between animation starts, in the order they are defined in). In the example below, that means that opacity, translateY and translateX will animate in sequence with a 400ms delay between them. Additional configuration is possible as a second parameter, where you can define the animation `duration`, `stagger`, `loop` and `easing`. The default configuration is `{ duration: 800, stagger: 400, easing: Easing.ease(Easing.quad) }`.
|
|
309
|
+
|
|
310
|
+
Usage
|
|
311
|
+
|
|
312
|
+
```javascript
|
|
313
|
+
const element1 = animateStagger({
|
|
314
|
+
opacity: [0, 1],
|
|
315
|
+
translateX: [20, 0],
|
|
316
|
+
translateY: [20, 0],
|
|
317
|
+
});
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### Defining element animation timeline
|
|
321
|
+
|
|
322
|
+
Once defined, the animations can be layed out on a timeline using the `createAnimationTimeline` function. The return value of the `createAnimationTimeline` is an `Animated.CompositeAnimation` wrapping all defined animations on the timeline, giving you a single start/stop function to trigger all animations wrapped in the timeline.
|
|
323
|
+
|
|
324
|
+
The configuration object is of type `{ [ms: number]: ElementAnimation<K>[]; }`, with the key of the object representing the point-in-time in ms when the associated animation array will trigger. In the following example, this means that, once started, at 0ms (without delay) the `element1` animation set will start, and at 2000ms the `element2` animation will start.
|
|
325
|
+
|
|
326
|
+
### Everything combined
|
|
327
|
+
|
|
328
|
+
Usage
|
|
329
|
+
|
|
330
|
+
```javascript
|
|
331
|
+
const element1 = animateParallel({ opacity: [0, 1] }, { duration: 400 });
|
|
332
|
+
const element2 = animateStagger(
|
|
333
|
+
{
|
|
334
|
+
opacity: [0, 1],
|
|
335
|
+
translateX: [20, 0],
|
|
336
|
+
translateY: [20, 0],
|
|
337
|
+
},
|
|
338
|
+
{ stagger: 1200, duration: 800 },
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
const timeline = createAnimationTimeline({
|
|
342
|
+
0: [element1],
|
|
343
|
+
2000: [element2],
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
export const Component: React.FC = () => {
|
|
347
|
+
...
|
|
348
|
+
useEffect(() => {
|
|
349
|
+
if(startAnimation) {
|
|
350
|
+
timeline.start();
|
|
351
|
+
} else {
|
|
352
|
+
timeline.reset();
|
|
353
|
+
}
|
|
354
|
+
}, [startAnimation])
|
|
355
|
+
|
|
356
|
+
return <Block animations={element1.animations}>...</Block>
|
|
357
|
+
}
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### Reversing element animations.
|
|
361
|
+
|
|
362
|
+
Instead of just reseting the animation, which does not play the animation back in reverse, the utility also exposes a `reverse` function which will animate the element back to it's initial values.
|
|
363
|
+
Instead of `element.reset()`, use `element.reverse()`. This can also be used on timelines.
|
|
364
|
+
|
|
365
|
+
Usage
|
|
366
|
+
|
|
367
|
+
```javascript
|
|
368
|
+
const element = animateStagger(
|
|
369
|
+
{
|
|
370
|
+
opacity: [0, 1],
|
|
371
|
+
translateX: [20, 0],
|
|
372
|
+
translateY: [20, 0],
|
|
373
|
+
},
|
|
374
|
+
{ stagger: 1200, duration: 800 },
|
|
375
|
+
);
|
|
376
|
+
|
|
377
|
+
...
|
|
378
|
+
|
|
379
|
+
useEffect(() => {
|
|
380
|
+
if (startAnimation) {
|
|
381
|
+
element.start();
|
|
382
|
+
} else {
|
|
383
|
+
element.reverse();
|
|
384
|
+
}
|
|
385
|
+
}, [startAnimation]);
|
|
386
|
+
```
|
|
387
|
+
|
|
241
388
|
## Hooks
|
|
242
389
|
|
|
243
390
|
### useForm & useFormUtils
|
|
244
391
|
|
|
245
392
|
Read documentation about useForm here: https://github.com/prototypdigital/skeleform
|
|
246
393
|
|
|
247
|
-
### useAnimation & useAnimationTimeline
|
|
394
|
+
### LEGACY: useAnimation & useAnimationTimeline
|
|
395
|
+
|
|
396
|
+
This approach is not going to be maintained anymore starting from version 1.0.10. New utilities have been created that are more performant and more flexible, but the following hooks will still be available for the foreseeable future. For more information on the new approach, see <b>Animations</b> above.
|
|
248
397
|
|
|
249
398
|
---
|
|
250
399
|
|
|
@@ -256,7 +405,7 @@ Read documentation about useForm here: https://github.com/prototypdigital/skelef
|
|
|
256
405
|
|
|
257
406
|
```javascript
|
|
258
407
|
const inputs = useAnimation(...);
|
|
259
|
-
const
|
|
408
|
+
const heading = useAnimation(
|
|
260
409
|
{opacity: [0, 1], translateY: [20, 0]},
|
|
261
410
|
{duration: 400},
|
|
262
411
|
);
|
|
@@ -272,8 +421,10 @@ useAnimTimeline({
|
|
|
272
421
|
|
|
273
422
|
...
|
|
274
423
|
|
|
275
|
-
//
|
|
276
|
-
|
|
424
|
+
// Animations can be passed directly into the Block component without any particular modification
|
|
425
|
+
<Block animations={heading.animations}>...</Block>
|
|
426
|
+
|
|
427
|
+
// If not using Block, transformations (scale, rotate, translate) cannot be applied outside the transform style - translateY has to be passed in through the transform style prop.
|
|
277
428
|
<Animated.View
|
|
278
429
|
style={{
|
|
279
430
|
...heading.animations,
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
import React, { useMemo } from "react";
|
|
3
|
-
import { ScrollView, StyleSheet
|
|
4
|
-
import { extractAlignmentProperties, extractSizeProperties } from "../../utils";
|
|
5
|
-
const BlockElement =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} = _ref;
|
|
3
|
+
import { Animated, ScrollView, StyleSheet } from "react-native";
|
|
4
|
+
import { extractAlignmentProperties, extractAnimationProperties, extractFlexProperties, extractPositionProperties, extractSizeProperties } from "../../utils";
|
|
5
|
+
const BlockElement = ({
|
|
6
|
+
children,
|
|
7
|
+
...props
|
|
8
|
+
}) => {
|
|
10
9
|
const {
|
|
11
10
|
border,
|
|
12
11
|
paddings,
|
|
@@ -14,34 +13,26 @@ const BlockElement = _ref => {
|
|
|
14
13
|
background,
|
|
15
14
|
style,
|
|
16
15
|
overflow,
|
|
16
|
+
animations,
|
|
17
17
|
...view
|
|
18
18
|
} = props;
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} = extractAlignmentProperties(props);
|
|
19
|
+
const animationProps = useMemo(() => extractAnimationProperties(animations), [animations]);
|
|
20
|
+
const flexProps = useMemo(() => extractFlexProperties(props), [props]);
|
|
21
|
+
const sizeProps = useMemo(() => extractSizeProperties(props), [props]);
|
|
22
|
+
const positionProps = useMemo(() => extractPositionProperties(props), [props]);
|
|
23
|
+
const alignmentProps = useMemo(() => extractAlignmentProperties(props), [props]);
|
|
25
24
|
const styles = useMemo(() => StyleSheet.flatten([{
|
|
26
|
-
...margins,
|
|
27
|
-
...paddings,
|
|
28
|
-
...alignment,
|
|
29
|
-
...size,
|
|
30
|
-
...border,
|
|
31
|
-
alignItems,
|
|
32
|
-
justifyContent,
|
|
33
25
|
backgroundColor: background,
|
|
34
26
|
overflow
|
|
35
|
-
}, style]), [
|
|
36
|
-
return /*#__PURE__*/React.createElement(View, _extends({}, view, {
|
|
37
|
-
style: styles
|
|
27
|
+
}, alignmentProps, margins, paddings, border, flexProps, sizeProps, positionProps, style]), [alignmentProps, sizeProps, background, style, overflow, margins, paddings, positionProps, flexProps, border]);
|
|
28
|
+
return /*#__PURE__*/React.createElement(Animated.View, _extends({}, view, {
|
|
29
|
+
style: [styles, animationProps]
|
|
38
30
|
}), children);
|
|
39
31
|
};
|
|
40
|
-
export const Block =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
} = _ref2;
|
|
32
|
+
export const Block = ({
|
|
33
|
+
children,
|
|
34
|
+
...props
|
|
35
|
+
}) => {
|
|
45
36
|
const {
|
|
46
37
|
scrollable,
|
|
47
38
|
...rest
|
|
@@ -61,10 +52,10 @@ export const Block = _ref2 => {
|
|
|
61
52
|
keyboardShouldPersistTaps: "handled",
|
|
62
53
|
showsHorizontalScrollIndicator: showsHorizontalScrollIndicator,
|
|
63
54
|
showsVerticalScrollIndicator: showsVerticalScrollIndicator,
|
|
64
|
-
contentContainerStyle: {
|
|
55
|
+
contentContainerStyle: [{
|
|
65
56
|
flexGrow: 1,
|
|
66
57
|
backgroundColor: rest.background
|
|
67
|
-
},
|
|
58
|
+
}],
|
|
68
59
|
bounces: bounces
|
|
69
60
|
}, element());
|
|
70
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useMemo","ScrollView","StyleSheet","
|
|
1
|
+
{"version":3,"names":["React","useMemo","Animated","ScrollView","StyleSheet","extractAlignmentProperties","extractAnimationProperties","extractFlexProperties","extractPositionProperties","extractSizeProperties","BlockElement","children","props","border","paddings","margins","background","style","overflow","animations","view","animationProps","flexProps","sizeProps","positionProps","alignmentProps","styles","flatten","backgroundColor","createElement","View","_extends","Block","scrollable","rest","element","horizontal","showsHorizontalScrollIndicator","showsVerticalScrollIndicator","bounces","keyboardShouldPersistTaps","contentContainerStyle","flexGrow"],"sourceRoot":"../../src","sources":["Block.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAuBC,OAAO,QAAQ,OAAO;AACzD,SACEC,QAAQ,EACRC,UAAU,EAGVC,UAAU,QAGL,cAAc;AAWrB,SACEC,0BAA0B,EAC1BC,0BAA0B,EAC1BC,qBAAqB,EACrBC,yBAAyB,EACzBC,qBAAqB,QAChB,aAAa;AA+BpB,MAAMC,YAA4D,GAAGA,CAAC;EACpEC,QAAQ;EACR,GAAGC;AACL,CAAC,KAAK;EACJ,MAAM;IACJC,MAAM;IACNC,QAAQ;IACRC,OAAO;IACPC,UAAU;IACVC,KAAK;IACLC,QAAQ;IACRC,UAAU;IACV,GAAGC;EACL,CAAC,GAAGR,KAAK;EAET,MAAMS,cAAc,GAAGpB,OAAO,CAC5B,MAAMK,0BAA0B,CAACa,UAAU,CAAC,EAC5C,CAACA,UAAU,CACb,CAAC;EACD,MAAMG,SAAS,GAAGrB,OAAO,CAAC,MAAMM,qBAAqB,CAACK,KAAK,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EACtE,MAAMW,SAAS,GAAGtB,OAAO,CAAC,MAAMQ,qBAAqB,CAACG,KAAK,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EACtE,MAAMY,aAAa,GAAGvB,OAAO,CAC3B,MAAMO,yBAAyB,CAACI,KAAK,CAAC,EACtC,CAACA,KAAK,CACR,CAAC;EACD,MAAMa,cAAc,GAAGxB,OAAO,CAC5B,MAAMI,0BAA0B,CAACO,KAAK,CAAC,EACvC,CAACA,KAAK,CACR,CAAC;EAED,MAAMc,MAAM,GAAGzB,OAAO,CACpB,MACEG,UAAU,CAACuB,OAAO,CAAC,CACjB;IACEC,eAAe,EAAEZ,UAAU;IAC3BE;EACF,CAAC,EACDO,cAAc,EACdV,OAAO,EACPD,QAAQ,EACRD,MAAM,EACNS,SAAS,EACTC,SAAS,EACTC,aAAa,EACbP,KAAK,CACN,CAAC,EACJ,CACEQ,cAAc,EACdF,SAAS,EACTP,UAAU,EACVC,KAAK,EACLC,QAAQ,EACRH,OAAO,EACPD,QAAQ,EACRU,aAAa,EACbF,SAAS,EACTT,MAAM,CAEV,CAAC;EAED,oBACEb,KAAA,CAAA6B,aAAA,CAAC3B,QAAQ,CAAC4B,IAAI,EAAAC,QAAA,KAAKX,IAAI;IAAEH,KAAK,EAAE,CAACS,MAAM,EAAEL,cAAc;EAAE,IACtDV,QACY,CAAC;AAEpB,CAAC;AAYD,OAAO,MAAMqB,KAA8C,GAAGA,CAAC;EAC7DrB,QAAQ;EACR,GAAGC;AACL,CAAC,KAAK;EACJ,MAAM;IAAEqB,UAAU;IAAE,GAAGC;EAAK,CAAC,GAAGtB,KAAK;EACrC,MAAMuB,OAAO,GAAGA,CAAA,kBAAMnC,KAAA,CAAA6B,aAAA,CAACnB,YAAY,EAAKwB,IAAI,EAAGvB,QAAuB,CAAC;EAEvE,IAAI,CAACsB,UAAU,EAAE;IACf,OAAOE,OAAO,CAAC,CAAC;EAClB;EAEA,MAAM;IACJC,UAAU;IACVC,8BAA8B;IAC9BC,4BAA4B;IAC5BC;EACF,CAAC,GAAG3B,KAAK;EAET,oBACEZ,KAAA,CAAA6B,aAAA,CAAC1B,UAAU;IACTiC,UAAU,EAAEA,UAAW;IACvBI,yBAAyB,EAAC,SAAS;IACnCH,8BAA8B,EAAEA,8BAA+B;IAC/DC,4BAA4B,EAAEA,4BAA6B;IAC3DG,qBAAqB,EAAE,CACrB;MAAEC,QAAQ,EAAE,CAAC;MAAEd,eAAe,EAAEM,IAAI,CAAClB;IAAW,CAAC,CACjD;IACFuB,OAAO,EAAEA;EAAQ,GAEhBJ,OAAO,CAAC,CACC,CAAC;AAEjB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
import React, { useRef, useState } from "react";
|
|
3
|
-
import { Platform, ScrollView, StyleSheet
|
|
3
|
+
import { Dimensions, Platform, ScrollView, StyleSheet } from "react-native";
|
|
4
4
|
/**
|
|
5
5
|
* This scroll view will automatically scroll to an active input field rendered within it, provided you attach the onInputFocus callback to the input onFocus prop.
|
|
6
6
|
*
|
|
@@ -8,24 +8,25 @@ import { Platform, ScrollView, StyleSheet, Dimensions } from "react-native";
|
|
|
8
8
|
* @example <InputFocusScrollView>{(onInputFocus) => <TextInput onFocus={onInputFocus} ... />}</InputFocusScrollView>
|
|
9
9
|
* NOTE: This works on iOS only, Android does this by default with @param android:windowSoftInputMode
|
|
10
10
|
*/
|
|
11
|
-
export const InputFocusScrollView =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
} = _ref;
|
|
11
|
+
export const InputFocusScrollView = ({
|
|
12
|
+
children,
|
|
13
|
+
style,
|
|
14
|
+
contentContainerStyle,
|
|
15
|
+
height = "full",
|
|
16
|
+
focusPositionOffset = 0.3,
|
|
17
|
+
margins,
|
|
18
|
+
paddings,
|
|
19
|
+
...rest
|
|
20
|
+
}) => {
|
|
22
21
|
const screenHeight = useRef(Dimensions.get("screen").height).current;
|
|
23
22
|
const ref = useRef(null);
|
|
24
23
|
/** Cached scroll position to keep focus on input if layout shifts. */
|
|
25
24
|
const [scrollPosition, setScrollPosition] = useState(null);
|
|
26
25
|
const [scrollTarget, setScrollTarget] = useState(null);
|
|
27
26
|
function onInputFocus(e) {
|
|
28
|
-
if (Platform.OS !== "ios" || !scrollTarget)
|
|
27
|
+
if (Platform.OS !== "ios" || !scrollTarget) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
29
30
|
e.currentTarget.measureLayout(scrollTarget, (nope, top, nuuh, elementHeight) => {
|
|
30
31
|
var _ref$current;
|
|
31
32
|
let scrollY = top - elementHeight;
|
|
@@ -36,7 +37,7 @@ export const InputFocusScrollView = _ref => {
|
|
|
36
37
|
// Cache scroll position for layout shift cases
|
|
37
38
|
setScrollPosition(scrollY);
|
|
38
39
|
// Scroll to input position
|
|
39
|
-
(_ref$current = ref.current) === null || _ref$current === void 0
|
|
40
|
+
(_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.scrollTo({
|
|
40
41
|
y: scrollY
|
|
41
42
|
});
|
|
42
43
|
}, () => console.error("failed to measure layout"));
|
|
@@ -48,7 +49,7 @@ export const InputFocusScrollView = _ref => {
|
|
|
48
49
|
if (Platform.OS !== "ios" || !scrollPosition) {
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
|
-
(_ref$current2 = ref.current) === null || _ref$current2 === void 0
|
|
52
|
+
(_ref$current2 = ref.current) === null || _ref$current2 === void 0 || _ref$current2.scrollTo({
|
|
52
53
|
y: scrollPosition,
|
|
53
54
|
animated: false
|
|
54
55
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useRef","useState","Platform","ScrollView","StyleSheet","
|
|
1
|
+
{"version":3,"names":["React","useRef","useState","Dimensions","Platform","ScrollView","StyleSheet","InputFocusScrollView","children","style","contentContainerStyle","height","focusPositionOffset","margins","paddings","rest","screenHeight","get","current","ref","scrollPosition","setScrollPosition","scrollTarget","setScrollTarget","onInputFocus","e","OS","currentTarget","measureLayout","nope","top","nuuh","elementHeight","_ref$current","scrollY","undefined","scrollTo","y","console","error","onContentSizeChange","_ref$current2","animated","containerStyles","flatten","styles","contentStyles","content","createElement","_extends","scrollToOverflowEnabled","scrollEventThrottle","onLayout","showsVerticalScrollIndicator","showsHorizontalScrollIndicator","create","full","auto","flexGrow","paddingBottom"],"sourceRoot":"../../src","sources":["InputFocusScrollView.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC/C,SACEC,UAAU,EAEVC,QAAQ,EACRC,UAAU,EAEVC,UAAU,QAGL,cAAc;AAerB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAyD,GAAGA,CAAC;EACxEC,QAAQ;EACRC,KAAK;EACLC,qBAAqB;EACrBC,MAAM,GAAG,MAAM;EACfC,mBAAmB,GAAG,GAAG;EACzBC,OAAO;EACPC,QAAQ;EACR,GAAGC;AACL,CAAC,KAAK;EACJ,MAAMC,YAAY,GAAGf,MAAM,CAACE,UAAU,CAACc,GAAG,CAAC,QAAQ,CAAC,CAACN,MAAM,CAAC,CAACO,OAAO;EACpE,MAAMC,GAAG,GAAGlB,MAAM,CAAa,IAAI,CAAC;EACpC;EACA,MAAM,CAACmB,cAAc,EAAEC,iBAAiB,CAAC,GAAGnB,QAAQ,CAAgB,IAAI,CAAC;EACzE,MAAM,CAACoB,YAAY,EAAEC,eAAe,CAAC,GAAGrB,QAAQ,CAAgB,IAAI,CAAC;EAErE,SAASsB,YAAYA,CAACC,CAAgD,EAAE;IACtE,IAAIrB,QAAQ,CAACsB,EAAE,KAAK,KAAK,IAAI,CAACJ,YAAY,EAAE;MAC1C;IACF;IAECG,CAAC,CAACE,aAAa,CAA0BC,aAAa,CACrDN,YAAY,EACZ,CAACO,IAAI,EAAEC,GAAG,EAAEC,IAAI,EAAEC,aAAa,KAAK;MAAA,IAAAC,YAAA;MAClC,IAAIC,OAAO,GAAGJ,GAAG,GAAGE,aAAa;MACjC,IAAIpB,mBAAmB,KAAKuB,SAAS,EAAE;QACrCD,OAAO,GAAGA,OAAO,GAAGlB,YAAY,GAAGJ,mBAAmB;MACxD;;MAEA;MACAS,iBAAiB,CAACa,OAAO,CAAC;MAC1B;MACA,CAAAD,YAAA,GAAAd,GAAG,CAACD,OAAO,cAAAe,YAAA,eAAXA,YAAA,CAAaG,QAAQ,CAAC;QAAEC,CAAC,EAAEH;MAAQ,CAAC,CAAC;IACvC,CAAC,EACD,MAAMI,OAAO,CAACC,KAAK,CAAC,0BAA0B,CAChD,CAAC;EACH;;EAEA;EACA,SAASC,mBAAmBA,CAAA,EAAG;IAAA,IAAAC,aAAA;IAC7B,IAAIrC,QAAQ,CAACsB,EAAE,KAAK,KAAK,IAAI,CAACN,cAAc,EAAE;MAC5C;IACF;IACA,CAAAqB,aAAA,GAAAtB,GAAG,CAACD,OAAO,cAAAuB,aAAA,eAAXA,aAAA,CAAaL,QAAQ,CAAC;MAAEC,CAAC,EAAEjB,cAAc;MAAEsB,QAAQ,EAAE;IAAM,CAAC,CAAC;IAC7DrB,iBAAiB,CAAC,IAAI,CAAC;EACzB;EAEA,MAAMsB,eAAe,GAAGrC,UAAU,CAACsC,OAAO,CAAC,CAACC,MAAM,CAAClC,MAAM,CAAC,EAAEE,OAAO,EAAEJ,KAAK,CAAC,CAAC;EAE5E,MAAMqC,aAAa,GAAGxC,UAAU,CAACsC,OAAO,CAAC,CACvCC,MAAM,CAACE,OAAO,EACd;IAAE,GAAGjC;EAAS,CAAC,EACfJ,qBAAqB,CACtB,CAAC;EAEF,oBACEV,KAAA,CAAAgD,aAAA,CAAC3C,UAAU,EAAA4C,QAAA;IACT9B,GAAG,EAAEA,GAAI;IACT+B,uBAAuB;IACvBC,mBAAmB,EAAE,EAAG;IACxBC,QAAQ,EAAE3B,CAAC,IAAIF,eAAe,CAACE,CAAC,CAACE,aAAa,CAAE;IAChDa,mBAAmB,EAAEA,mBAAoB;IACzCa,4BAA4B,EAAE,KAAM;IACpCC,8BAA8B,EAAE,KAAM;IACtC7C,KAAK,EAAEkC,eAAgB;IACvBjC,qBAAqB,EAAEoC;EAAc,GACjC/B,IAAI,GAEPP,QAAQ,CAACgB,YAAY,CACZ,CAAC;AAEjB,CAAC;AAED,MAAMqB,MAAM,GAAGvC,UAAU,CAACiD,MAAM,CAAC;EAC/BC,IAAI,EAAE;IAAE7C,MAAM,EAAE;EAAO,CAAC;EACxB8C,IAAI,EAAE;IAAE9C,MAAM,EAAE;EAAO,CAAC;EACxBoC,OAAO,EAAE;IACPW,QAAQ,EAAE,CAAC;IACXC,aAAa,EAAE;EACjB;AACF,CAAC,CAAC"}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
import React from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { Dimensions, Platform, SafeAreaView, StatusBar, StyleSheet, View } from "react-native";
|
|
4
4
|
import { useSkeletor } from "../../hooks";
|
|
5
5
|
import { Block } from "../Block";
|
|
6
|
-
export const Screen =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} = _ref;
|
|
6
|
+
export const Screen = ({
|
|
7
|
+
background,
|
|
8
|
+
children,
|
|
9
|
+
hideBottomSafeArea,
|
|
10
|
+
hideTopSafeArea,
|
|
11
|
+
bottomSafeAreaColor,
|
|
12
|
+
topSafeAreaColor,
|
|
13
|
+
style,
|
|
14
|
+
statusBarType,
|
|
15
|
+
isLandscape,
|
|
16
|
+
...rest
|
|
17
|
+
}) => {
|
|
19
18
|
const {
|
|
20
19
|
defaultStatusBarType
|
|
21
20
|
} = useSkeletor();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","
|
|
1
|
+
{"version":3,"names":["React","Dimensions","Platform","SafeAreaView","StatusBar","StyleSheet","View","useSkeletor","Block","Screen","background","children","hideBottomSafeArea","hideTopSafeArea","bottomSafeAreaColor","topSafeAreaColor","style","statusBarType","isLandscape","rest","defaultStatusBarType","createElement","Fragment","styles","container","backgroundColor","translucent","barStyle","_extends","paddings","paddingTop","OS","currentHeight","flex","create","position","height","get","width"],"sourceRoot":"../../src","sources":["Screen.tsx"],"mappings":";AAAA,OAAOA,KAAK,MAA6B,OAAO;AAChD,SACEC,UAAU,EACVC,QAAQ,EACRC,YAAY,EACZC,SAAS,EACTC,UAAU,EACVC,IAAI,QAEC,cAAc;AAErB,SAASC,WAAW,QAAQ,aAAa;AACzC,SAASC,KAAK,QAAQ,UAAU;AAehC,OAAO,MAAMC,MAAgD,GAAGA,CAAC;EAC/DC,UAAU;EACVC,QAAQ;EACRC,kBAAkB;EAClBC,eAAe;EACfC,mBAAmB;EACnBC,gBAAgB;EAChBC,KAAK;EACLC,aAAa;EACbC,WAAW;EACX,GAAGC;AACL,CAAC,KAAK;EACJ,MAAM;IAAEC;EAAqB,CAAC,GAAGb,WAAW,CAAC,CAAC;EAE9C,oBACEP,KAAA,CAAAqB,aAAA,CAAArB,KAAA,CAAAsB,QAAA,QACGZ,UAAU,KACR,OAAOA,UAAU,KAAK,QAAQ,gBAC7BV,KAAA,CAAAqB,aAAA,CAACf,IAAI;IAACU,KAAK,EAAE,CAACO,MAAM,CAACC,SAAS,EAAE;MAAEC,eAAe,EAAEf;IAAW,CAAC;EAAE,CAAE,CAAC,gBAEpEV,KAAA,CAAAqB,aAAA,CAACf,IAAI;IAACU,KAAK,EAAEO,MAAM,CAACC;EAAU,GAAEd,UAAiB,CAClD,CAAC,EAEH,CAACG,eAAe,iBACfb,KAAA,CAAAqB,aAAA,CAAClB,YAAY;IAACa,KAAK,EAAE;MAAES,eAAe,EAAEV;IAAiB;EAAE,CAAE,CAC9D,eAEDf,KAAA,CAAAqB,aAAA,CAACjB,SAAS;IACRsB,WAAW;IACXD,eAAe,EAAC,aAAa;IAC7BE,QAAQ,EAAEV,aAAa,IAAIG;EAAqB,CACjD,CAAC,eAEFpB,KAAA,CAAAqB,aAAA,CAACb,KAAK,EAAAoB,QAAA;IACJC,QAAQ,EAAE;MACRC,UAAU,EACR5B,QAAQ,CAAC6B,EAAE,KAAK,SAAS,IAAI,CAACb,WAAW,GACrCd,SAAS,CAAC4B,aAAa,IAAI,EAAE,GAC7B;IACR,CAAE;IACFC,IAAI,EAAE,CAAE;IACRjB,KAAK,EAAEA;EAAM,GACTG,IAAI,GAEPR,QACI,CAAC,EAEP,CAACC,kBAAkB,iBAClBZ,KAAA,CAAAqB,aAAA,CAAClB,YAAY;IACXa,KAAK,EAAE;MACLS,eAAe,EAAEX;IACnB;EAAE,CACH,CAEH,CAAC;AAEP,CAAC;AAED,MAAMS,MAAM,GAAGlB,UAAU,CAAC6B,MAAM,CAAC;EAC/BV,SAAS,EAAE;IACTW,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAEnC,UAAU,CAACoC,GAAG,CAAC,QAAQ,CAAC,CAACD,MAAM;IACvCE,KAAK,EAAErC,UAAU,CAACoC,GAAG,CAAC,QAAQ,CAAC,CAACC;EAClC;AACF,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","SkeletorDefaults","defaultFont","undefined","defaultFontSize","defaultStatusBarType","defaultTextColor","SkeletorContext","createContext"],"sourceRoot":"../../src","sources":["SkeletorContext.ts"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;
|
|
1
|
+
{"version":3,"names":["React","SkeletorDefaults","defaultFont","undefined","defaultFontSize","defaultStatusBarType","defaultTextColor","SkeletorContext","createContext"],"sourceRoot":"../../src","sources":["SkeletorContext.ts"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAIzB,OAAO,MAAMC,gBAAgC,GAAG;EAC9CC,WAAW,EAAEC,SAAS;EACtBC,eAAe,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;EACzBC,oBAAoB,EAAE,cAAc;EACpCC,gBAAgB,EAAE;AACpB,CAAC;AAED,OAAO,MAAMC,eAAe,gBAC1BP,KAAK,CAACQ,aAAa,CAAiBP,gBAAgB,CAAC"}
|
|
@@ -2,11 +2,10 @@ import React from "react";
|
|
|
2
2
|
import { SkeletorContext, SkeletorDefaults } from "./SkeletorContext";
|
|
3
3
|
/** Create a Font.d.ts type in your typescript types directory and define fonts as follows:
|
|
4
4
|
* @example type Font = "Helvetica" | "Montserrat" ... */
|
|
5
|
-
export const SkeletorProvider =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} = _ref;
|
|
5
|
+
export const SkeletorProvider = ({
|
|
6
|
+
children,
|
|
7
|
+
...config
|
|
8
|
+
}) => {
|
|
10
9
|
return /*#__PURE__*/React.createElement(SkeletorContext.Provider, {
|
|
11
10
|
value: {
|
|
12
11
|
...SkeletorDefaults,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","SkeletorContext","SkeletorDefaults","SkeletorProvider","children","config"],"sourceRoot":"../../src","sources":["SkeletorProvider.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAA6B,OAAO;
|
|
1
|
+
{"version":3,"names":["React","SkeletorContext","SkeletorDefaults","SkeletorProvider","children","config","createElement","Provider","value"],"sourceRoot":"../../src","sources":["SkeletorProvider.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAA6B,OAAO;AAGhD,SAASC,eAAe,EAAEC,gBAAgB,QAAQ,mBAAmB;AAIrE;AACA;AACA,OAAO,MAAMC,gBAAoD,GAAGA,CAAC;EACnEC,QAAQ;EACR,GAAGC;AACL,CAAC,KAAK;EACJ,oBACEL,KAAA,CAAAM,aAAA,CAACL,eAAe,CAACM,QAAQ;IAACC,KAAK,EAAE;MAAE,GAAGN,gBAAgB;MAAE,GAAGG;IAAO;EAAE,GACjED,QACuB,CAAC;AAE/B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,cAAc,mBAAmB;AACjC,cAAc,oBAAoB"}
|
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
import React, { useMemo } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import { extractSizeProperties } from "../../utils";
|
|
3
|
+
import { Animated, StyleSheet } from "react-native";
|
|
5
4
|
import { useSkeletor } from "../../hooks";
|
|
5
|
+
import { extractAnimationProperties, extractFlexProperties, extractPositionProperties, extractSizeProperties } from "../../utils";
|
|
6
6
|
/** Create a Font.d.ts type in your typescript types directory and define fonts as follows:
|
|
7
7
|
* @example type Font = "Helvetica" | "Montserrat" ... */
|
|
8
|
-
export const Text =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
export const Text = ({
|
|
9
|
+
font,
|
|
10
|
+
size,
|
|
11
|
+
textTransform,
|
|
12
|
+
letterSpacing,
|
|
13
|
+
color,
|
|
14
|
+
style,
|
|
15
|
+
children,
|
|
16
|
+
textAlign,
|
|
17
|
+
opacity,
|
|
18
|
+
margins,
|
|
19
|
+
paddings,
|
|
20
|
+
animations,
|
|
21
|
+
...props
|
|
22
|
+
}) => {
|
|
23
23
|
const {
|
|
24
24
|
defaultFont,
|
|
25
25
|
defaultFontSize,
|
|
26
26
|
defaultTextColor
|
|
27
27
|
} = useSkeletor();
|
|
28
|
-
const
|
|
28
|
+
const animationProps = useMemo(() => extractAnimationProperties(animations), [animations]);
|
|
29
|
+
const positionProps = useMemo(() => extractPositionProperties(props), [props]);
|
|
30
|
+
const flexProps = useMemo(() => extractFlexProperties(props), [props]);
|
|
31
|
+
const sizeProps = useMemo(() => extractSizeProperties(props), [props]);
|
|
29
32
|
const textSize = useMemo(() => {
|
|
30
33
|
function mapper(value) {
|
|
31
34
|
if (Array.isArray(value)) {
|
|
@@ -45,18 +48,14 @@ export const Text = _ref => {
|
|
|
45
48
|
}, [size, defaultFontSize]);
|
|
46
49
|
const styles = useMemo(() => StyleSheet.flatten([{
|
|
47
50
|
color: color || defaultTextColor,
|
|
48
|
-
...textSize,
|
|
49
51
|
fontFamily: font || defaultFont,
|
|
50
52
|
opacity,
|
|
51
53
|
textAlign,
|
|
52
54
|
textTransform,
|
|
53
|
-
letterSpacing
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}, style]), [color, font, opacity, textAlign, textTransform, textSize, margins, paddings, style]);
|
|
58
|
-
return /*#__PURE__*/React.createElement(RNText, _extends({
|
|
59
|
-
style: styles,
|
|
55
|
+
letterSpacing
|
|
56
|
+
}, textSize, margins, paddings, sizeProps, flexProps, positionProps, style]), [color, font, opacity, textAlign, textTransform, textSize, margins, paddings, style, positionProps, sizeProps, flexProps, defaultTextColor, defaultFont, letterSpacing]);
|
|
57
|
+
return /*#__PURE__*/React.createElement(Animated.Text, _extends({
|
|
58
|
+
style: [styles, animationProps],
|
|
60
59
|
allowFontScaling: false,
|
|
61
60
|
maxFontSizeMultiplier: 1
|
|
62
61
|
}, props), children);
|