rn-css 1.8.5 → 1.8.6
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/dist/index.d.ts +441 -111
- package/dist/styleComponent.d.ts +7 -7
- package/package.json +1 -1
- package/src/styleComponent.tsx +9 -9
package/dist/styleComponent.d.ts
CHANGED
|
@@ -26,18 +26,18 @@ declare const styled: <StyleType, InitialProps extends {
|
|
|
26
26
|
<S>(chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S & Props>)[]): React.ForwardRefExoticComponent<Props & S & {
|
|
27
27
|
ref?: React.Ref<any> | undefined;
|
|
28
28
|
}>;
|
|
29
|
-
attrs<Part extends Partial<Props>>(opts:
|
|
29
|
+
attrs<Part, Result extends Partial<Part & Props> = Partial<Part & Props>>(opts: Result | ((props: Part & Props) => Result)): (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<Part & Props>)[]) => React.ForwardRefExoticComponent<React.PropsWithoutRef<Exclude<Props & Part, Result> & Partial<Props & Part>> & React.RefAttributes<React.ComponentType<Props & Part>>>;
|
|
30
30
|
};
|
|
31
31
|
export default styled;
|
|
32
32
|
export declare const styledFlatList: {
|
|
33
|
-
<S>(chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S>)[]): <Type>(props: S & OptionalProps & FlatListProps<Type>) => JSX.Element;
|
|
34
|
-
attrs<S_1>(opts:
|
|
33
|
+
<S>(chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S & FlatListProps<any> & OptionalProps>)[]): <Type>(props: S & OptionalProps & FlatListProps<Type>) => JSX.Element;
|
|
34
|
+
attrs<S_1>(opts: (S_1 & FlatListProps<any> & OptionalProps) | ((props: S_1 & FlatListProps<any> & OptionalProps) => Partial<S_1 & OptionalProps & FlatListProps<any>>)): (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S_1 & OptionalProps & FlatListProps<any>>)[]) => <Props>(componentProps: S_1 & OptionalProps & FlatListProps<Props>) => JSX.Element;
|
|
35
35
|
};
|
|
36
36
|
export declare const styledSectionList: {
|
|
37
|
-
<S>(chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S>)[]): <Type>(props: S & OptionalProps & SectionListProps<Type, import("react-native").DefaultSectionT>) => JSX.Element;
|
|
38
|
-
attrs<S_1>(opts:
|
|
37
|
+
<S>(chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S & SectionListProps<any, import("react-native").DefaultSectionT> & OptionalProps>)[]): <Type>(props: S & OptionalProps & SectionListProps<Type, import("react-native").DefaultSectionT>) => JSX.Element;
|
|
38
|
+
attrs<S_1>(opts: (S_1 & SectionListProps<any, import("react-native").DefaultSectionT> & OptionalProps) | ((props: S_1 & SectionListProps<any, import("react-native").DefaultSectionT> & OptionalProps) => Partial<S_1 & OptionalProps & SectionListProps<any, import("react-native").DefaultSectionT>>)): (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S_1 & SectionListProps<any, import("react-native").DefaultSectionT>>)[]) => <Props>(componentProps: S_1 & OptionalProps & SectionListProps<Props, import("react-native").DefaultSectionT>) => JSX.Element;
|
|
39
39
|
};
|
|
40
40
|
export declare const styledVirtualizedList: {
|
|
41
|
-
<S>(chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S>)[]): <Type>(props: S & OptionalProps & VirtualizedListProps<Type>) => JSX.Element;
|
|
42
|
-
attrs<S_1>(opts:
|
|
41
|
+
<S>(chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S & VirtualizedListProps<any> & OptionalProps>)[]): <Type>(props: S & OptionalProps & VirtualizedListProps<Type>) => JSX.Element;
|
|
42
|
+
attrs<S_1>(opts: (S_1 & VirtualizedListProps<any> & OptionalProps) | ((props: S_1 & VirtualizedListProps<any> & OptionalProps) => Partial<S_1 & OptionalProps & VirtualizedListProps<any>>)): (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S_1 & VirtualizedListProps<any>>)[]) => <Props>(componentProps: S_1 & OptionalProps & VirtualizedListProps<Props>) => JSX.Element;
|
|
43
43
|
};
|
package/package.json
CHANGED
package/src/styleComponent.tsx
CHANGED
|
@@ -148,11 +148,11 @@ const styled = <StyleType, InitialProps extends { style?: StyleProp<StyleType> }
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
// provide styled(Comp).attrs({} | () => {}) feature
|
|
151
|
-
styledComponent.attrs = <Part extends Partial<Props
|
|
151
|
+
styledComponent.attrs = <Part, Result extends Partial<Part & Props> = Partial<Part & Props>>(opts: Result | ((props: Part & Props) => Result)) => (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<Part & Props>)[]) => {
|
|
152
152
|
const ComponentWithAttrs = styledComponent(chunks, ...functs)
|
|
153
|
-
const ForwardRefComponent = React.forwardRef<React.ComponentType<Props>, Exclude<Props,
|
|
153
|
+
const ForwardRefComponent = React.forwardRef<React.ComponentType<Props & Part>, Exclude<Props & Part, Result> & Partial<Props & Part>>((props, ref) => {
|
|
154
154
|
const attrs = (opts instanceof Function) ? opts(props) : opts
|
|
155
|
-
return <ComponentWithAttrs ref={ref} {...
|
|
155
|
+
return <ComponentWithAttrs ref={ref} {...props} {...attrs} />
|
|
156
156
|
})
|
|
157
157
|
// TODO : Find a way to remove from the Props the properties affected by opts
|
|
158
158
|
return ForwardRefComponent
|
|
@@ -163,12 +163,12 @@ const styled = <StyleType, InitialProps extends { style?: StyleProp<StyleType> }
|
|
|
163
163
|
|
|
164
164
|
export default styled
|
|
165
165
|
|
|
166
|
-
export const styledFlatList = <S, >(chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S>)[]) => <Type, >(props: S & OptionalProps & FlatListProps<Type>) => invoke(styled<ViewStyle, FlatListProps<Type>>(FlatList)(chunks, ...functs), props)
|
|
167
|
-
styledFlatList.attrs = <S, >(opts:
|
|
168
|
-
export const styledSectionList = <S, >(chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S>)[]) => <Type, >(props: S & OptionalProps & SectionListProps<Type>) => invoke(styled<ViewStyle, SectionListProps<Type>>(SectionList)(chunks, ...functs), props)
|
|
169
|
-
styledSectionList.attrs = <S, >(opts:
|
|
170
|
-
export const styledVirtualizedList = <S, >(chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S>)[]) => <Type, >(props: S & OptionalProps & VirtualizedListProps<Type>) => invoke(styled<ViewStyle, VirtualizedListProps<Type>>(VirtualizedList)(chunks, ...functs), props)
|
|
171
|
-
styledVirtualizedList.attrs = <S, >(opts:
|
|
166
|
+
export const styledFlatList = <S, >(chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S & FlatListProps<any> & OptionalProps>)[]) => <Type, >(props: S & OptionalProps & FlatListProps<Type>) => invoke(styled<ViewStyle, FlatListProps<Type>>(FlatList)(chunks, ...functs), props)
|
|
167
|
+
styledFlatList.attrs = <S, >(opts: S & FlatListProps<any> & OptionalProps | ((props: S & FlatListProps<any> & OptionalProps) => Partial<S & OptionalProps & FlatListProps<any>>)) => (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S & OptionalProps & FlatListProps<any>>)[]) => <Props, >(componentProps: S & OptionalProps & FlatListProps<Props>) => invoke(styled<ViewStyle, FlatListProps<Props>>(FlatList).attrs<S>(opts)(chunks, ...functs), componentProps as any)
|
|
168
|
+
export const styledSectionList = <S, >(chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S & SectionListProps<any> & OptionalProps>)[]) => <Type, >(props: S & OptionalProps & SectionListProps<Type>) => invoke(styled<ViewStyle, SectionListProps<Type>>(SectionList)(chunks, ...functs), props)
|
|
169
|
+
styledSectionList.attrs = <S, >(opts: S & SectionListProps<any> & OptionalProps | ((props: S & SectionListProps<any> & OptionalProps) => Partial<S & OptionalProps & SectionListProps<any>>)) => (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S & SectionListProps<any>>)[]) => <Props, >(componentProps: S & OptionalProps & SectionListProps<Props>) => invoke(styled<ViewStyle, SectionListProps<Props>>(SectionList).attrs<S>(opts)(chunks, ...functs), componentProps as any)
|
|
170
|
+
export const styledVirtualizedList = <S, >(chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S & VirtualizedListProps<any> & OptionalProps>)[]) => <Type, >(props: S & OptionalProps & VirtualizedListProps<Type>) => invoke(styled<ViewStyle, VirtualizedListProps<Type>>(VirtualizedList)(chunks, ...functs), props)
|
|
171
|
+
styledVirtualizedList.attrs = <S, >(opts: S & VirtualizedListProps<any> & OptionalProps | ((props: S & VirtualizedListProps<any> & OptionalProps) => Partial<S & OptionalProps & VirtualizedListProps<any>>)) => (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S & VirtualizedListProps<any>>)[]) => <Props, >(componentProps: S & OptionalProps & VirtualizedListProps<Props>) => invoke(styled<ViewStyle, VirtualizedListProps<Props>>(VirtualizedList).attrs<S>(opts)(chunks, ...functs), componentProps as any)
|
|
172
172
|
|
|
173
173
|
function invoke<T> (Component: React.ComponentType<T>, props: T) {
|
|
174
174
|
return <Component {...props} />
|