@@ -4,7 +4,7 @@ import {StyleSheet, Animated, Easing, StyleProp, ViewStyle, AccessibilityProps}
4
4
import { BorderRadiuses , Colors , Dividers , Spacings } from '../../style' ;
5
5
import { createShimmerPlaceholder , LinearGradientPackage } from 'optionalDeps' ;
6
6
import View from '../view' ;
7
- import { Constants , asBaseComponent } from '../../commons/new' ;
7
+ import { Constants , asBaseComponent , BaseComponentInjectedProps , MarginModifiers } from '../../commons/new' ;
8
8
import { extractAccessibilityProps } from '../../commons/modifiers' ;
9
9
10
10
const LinearGradient = LinearGradientPackage ?. default ;
@@ -53,7 +53,7 @@ export interface SkeletonListProps {
53
53
renderEndContent ?: ( ) => React . ReactElement | undefined ;
54
54
}
55
55
56
- export interface SkeletonViewProps extends AccessibilityProps {
56
+ export interface SkeletonViewProps extends AccessibilityProps , MarginModifiers {
57
57
/**
58
58
* The content has been loaded, start fading out the skeleton and fading in the content
59
59
*/
@@ -157,7 +157,10 @@ interface SkeletonState {
157
157
* @image : https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/Skeleton/Skeleton.gif?raw=true
158
158
* @notes : View requires installing the 'react-native-shimmer-placeholder' and 'react-native-linear-gradient' library
159
159
*/
160
- class SkeletonView extends Component < SkeletonViewProps , SkeletonState > {
160
+
161
+ type InternalSkeletonViewProps = SkeletonViewProps & BaseComponentInjectedProps ;
162
+
163
+ class SkeletonView extends Component < InternalSkeletonViewProps , SkeletonState > {
161
164
static defaultProps = {
162
165
size : Size . SMALL ,
163
166
// listProps: {size: Size.SMALL}, TODO: once size is deprecated remove it and add this
@@ -170,7 +173,7 @@ class SkeletonView extends Component<SkeletonViewProps, SkeletonState> {
170
173
171
174
fadeInAnimation ?: Animated . CompositeAnimation ;
172
175
173
- constructor ( props : SkeletonViewProps ) {
176
+ constructor ( props : InternalSkeletonViewProps ) {
174
177
super ( props ) ;
175
178
176
179
this . state = {
@@ -193,7 +196,7 @@ class SkeletonView extends Component<SkeletonViewProps, SkeletonState> {
193
196
}
194
197
}
195
198
196
- componentDidUpdate ( prevProps : SkeletonViewProps ) {
199
+ componentDidUpdate ( prevProps : InternalSkeletonViewProps ) {
197
200
if ( this . props . showContent && ! prevProps . showContent ) {
198
201
this . fadeInAnimation ?. stop ( ) ;
199
202
this . fade ( false , this . showChildren ) ;
@@ -407,22 +410,66 @@ class SkeletonView extends Component<SkeletonViewProps, SkeletonState> {
407
410
return null ;
408
411
}
409
412
410
- const { times, timesKey, renderContent, testID} = this . props ;
413
+ const {
414
+ times,
415
+ timesKey,
416
+ renderContent,
417
+ showContent,
418
+ customValue,
419
+ contentData,
420
+ template,
421
+ listProps,
422
+ size,
423
+ contentType,
424
+ hideSeparator,
425
+ showLastSeparator,
426
+ height,
427
+ width,
428
+ borderRadius,
429
+ circle,
430
+ style,
431
+ testID,
432
+ ...others
433
+ } = this . props ;
434
+
435
+ const passedProps = {
436
+ showContent,
437
+ renderContent,
438
+ customValue,
439
+ contentData,
440
+ template,
441
+ listProps,
442
+ size,
443
+ contentType,
444
+ hideSeparator,
445
+ showLastSeparator,
446
+ height,
447
+ width,
448
+ borderRadius,
449
+ circle,
450
+ style,
451
+ testID
452
+ } ;
411
453
412
454
if ( times ) {
413
- return _ . times ( times , index => {
414
- const key = timesKey ? `${ timesKey } -${ index } ` : `${ index } ` ;
415
- return (
416
- < SkeletonView
417
- { ...this . props }
418
- key = { key }
419
- testID = { `${ testID } -${ index } ` }
420
- renderContent = { index === 0 ? renderContent : this . renderNothing }
421
- hideSeparator = { this . hideSeparator || ( ! this . showLastSeparator && index === times - 1 ) }
422
- times = { undefined }
423
- />
424
- ) ;
425
- } ) ;
455
+ return (
456
+ < View { ...others } >
457
+ { _ . times ( times , index => {
458
+ const key = timesKey ? `${ timesKey } -${ index } ` : `${ index } ` ;
459
+ return (
460
+ < SkeletonView
461
+ modifiers = { { } }
462
+ { ...passedProps }
463
+ key = { key }
464
+ testID = { `${ testID } -${ index } ` }
465
+ renderContent = { index === 0 ? renderContent : this . renderNothing }
466
+ hideSeparator = { this . hideSeparator || ( ! this . showLastSeparator && index === times - 1 ) }
467
+ times = { undefined }
468
+ />
469
+ ) ;
470
+ } ) }
471
+ </ View >
472
+ ) ;
426
473
} else {
427
474
return this . renderSkeleton ( ) ;
428
475
}
0 commit comments