rn-css 1.8.5 → 1.8.7

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.
@@ -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: Part | ((props: Props) => Part)): (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<Props>)[]) => React.ForwardRefExoticComponent<React.PropsWithoutRef<Exclude<Props, Part> & Partial<Part>> & React.RefAttributes<React.ComponentType<Props>>>;
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<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: Partial<S_1 & FlatListProps<any>> | ((props: S_1 & FlatListProps<any>) => Partial<S_1 & FlatListProps<any>>)): (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S_1 & FlatListProps<any>>)[]) => <Props>(componentProps: S_1 & OptionalProps & FlatListProps<Props>) => JSX.Element;
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: Partial<S_1 & SectionListProps<any, import("react-native").DefaultSectionT>> | ((props: S_1 & SectionListProps<any, import("react-native").DefaultSectionT>) => Partial<S_1 & 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;
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: Partial<S_1 & VirtualizedListProps<any>> | ((props: S_1 & VirtualizedListProps<any>) => Partial<S_1 & VirtualizedListProps<any>>)): (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S_1 & VirtualizedListProps<any>>)[]) => <Props>(componentProps: S_1 & OptionalProps & VirtualizedListProps<Props>) => JSX.Element;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rn-css",
3
- "version": "1.8.5",
3
+ "version": "1.8.7",
4
4
  "scripts": {
5
5
  "test": "jest",
6
6
  "prepare": "tsc",
@@ -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>, >(opts: Part | ((props: Props) => Part)) => (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<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, Part> & Partial<Part>>((props, ref) => {
153
+ const ForwardRefComponent = React.forwardRef<React.ComponentType<Props & Part>, Props & Part>((props, ref) => {
154
154
  const attrs = (opts instanceof Function) ? opts(props) : opts
155
- return <ComponentWithAttrs ref={ref} {...(props as Props)} {...attrs} />
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: Partial<S & FlatListProps<any>> | ((props: S & FlatListProps<any>) => Partial<S & FlatListProps<any>>)) => (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S & FlatListProps<any>>)[]) => <Props, >(componentProps: S & OptionalProps & FlatListProps<Props>) => invoke(styled<ViewStyle, FlatListProps<Props>>(FlatList).attrs<S>(opts as S)(chunks, ...functs as (Primitive | Functs<FlatListProps<Props>>)[]), componentProps as any)
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: Partial<S & SectionListProps<any>> | ((props: S & SectionListProps<any>) => Partial<S & 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 as S)(chunks, ...functs as (Primitive | Functs<SectionListProps<Props>>)[]), componentProps as any)
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: Partial<S & VirtualizedListProps<any>> | ((props: S & VirtualizedListProps<any>) => Partial<S & 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 as S)(chunks, ...functs as (Primitive | Functs<VirtualizedListProps<Props>>)[]), componentProps as any)
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} />