rn-css 1.8.7 → 1.8.9

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, 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>>>;
29
+ attrs<Part, Result extends Partial<Props & Part> = Partial<Props & Part>>(opts: Partial<Props & Part> | ((props: Props & Part) => Partial<Props & Part>)): (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<Part & Props>)[]) => React.ForwardRefExoticComponent<React.PropsWithoutRef<Result> & React.RefAttributes<any>>;
30
30
  };
31
31
  export default styled;
32
32
  export declare const styledFlatList: {
33
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;
34
+ attrs<S_1>(opts: Partial<S_1 & FlatListProps<any> & OptionalProps> | ((props: S_1 & FlatListProps<any> & OptionalProps) => Partial<S_1 & OptionalProps & FlatListProps<any>>)): (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S_1 & FlatListProps<any>>)[]) => <Props>(componentProps: Partial<S_1 & OptionalProps & FlatListProps<Props>>) => JSX.Element;
35
35
  };
36
36
  export declare const styledSectionList: {
37
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;
38
+ attrs<S_1>(opts: Partial<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: Partial<S_1 & OptionalProps & SectionListProps<Props, import("react-native").DefaultSectionT>>) => JSX.Element;
39
39
  };
40
40
  export declare const styledVirtualizedList: {
41
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;
42
+ attrs<S_1>(opts: Partial<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: Partial<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.7",
3
+ "version": "1.8.9",
4
4
  "scripts": {
5
5
  "test": "jest",
6
6
  "prepare": "tsc",
@@ -60,7 +60,7 @@ function removeStyle (hash: string) {
60
60
  }
61
61
  const styled = <StyleType, InitialProps extends { style?: StyleProp<StyleType> }, Props extends InitialProps & OptionalProps = InitialProps & OptionalProps>(Component: React.ComponentType<InitialProps>) => {
62
62
  const styledComponent = <S, >(chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S & Props>)[]) => {
63
- const ForwardRefComponent = React.forwardRef<React.ComponentType<S & Props>, S & Props>((props: S & Props, ref) => {
63
+ const ForwardRefComponent = React.forwardRef<any, S & Props>((props: S & Props, ref) => {
64
64
  const rem = React.useContext(RemContext)
65
65
  const shared = React.useContext(SharedValue)
66
66
  // Build the css string with the context
@@ -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, Result extends Partial<Part & Props> = Partial<Part & Props>>(opts: Result | ((props: Part & Props) => Result)) => (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<Part & Props>)[]) => {
151
+ styledComponent.attrs = <Part, Result extends Partial<Props & Part> = Partial<Props & Part>>(opts: Partial<Props & Part> | ((props: Props & Part) => Partial<Props & Part>)) => (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<Part & Props>)[]) => {
152
152
  const ComponentWithAttrs = styledComponent(chunks, ...functs)
153
- const ForwardRefComponent = React.forwardRef<React.ComponentType<Props & Part>, Props & Part>((props, ref) => {
154
- const attrs = (opts instanceof Function) ? opts(props) : opts
155
- return <ComponentWithAttrs ref={ref} {...props} {...attrs} />
153
+ const ForwardRefComponent = React.forwardRef<any, Result>((props, ref) => {
154
+ const attrs = (opts instanceof Function) ? opts(props as unknown as Props & Part) : opts
155
+ return <ComponentWithAttrs ref={ref} {...(props as unknown as Props & Part)} {...attrs} />
156
156
  })
157
157
  // TODO : Find a way to remove from the Props the properties affected by opts
158
158
  return ForwardRefComponent
@@ -164,11 +164,11 @@ const styled = <StyleType, InitialProps extends { style?: StyleProp<StyleType> }
164
164
  export default styled
165
165
 
166
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)
167
+ styledFlatList.attrs = <S, >(opts: Partial<S & FlatListProps<any> & OptionalProps> | ((props: S & FlatListProps<any> & OptionalProps) => Partial<S & OptionalProps & FlatListProps<any>>)) => (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S & FlatListProps<any>>)[]) => <Props, >(componentProps: Partial<S & OptionalProps & FlatListProps<Props>>) => invoke(styled<ViewStyle, FlatListProps<Props>>(FlatList).attrs<S>(opts as any)(chunks, ...functs), componentProps as any)
168
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)
169
+ styledSectionList.attrs = <S, >(opts: Partial<S & SectionListProps<any> & OptionalProps> | ((props: S & SectionListProps<any> & OptionalProps) => Partial<S & OptionalProps & SectionListProps<any>>)) => (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S & SectionListProps<any>>)[]) => <Props, >(componentProps: Partial<S & OptionalProps & SectionListProps<Props>>) => invoke(styled<ViewStyle, SectionListProps<Props>>(SectionList).attrs<S>(opts as any)(chunks, ...functs), componentProps as any)
170
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)
171
+ styledVirtualizedList.attrs = <S, >(opts: Partial<S & VirtualizedListProps<any> & OptionalProps> | ((props: S & VirtualizedListProps<any> & OptionalProps) => Partial<S & OptionalProps & VirtualizedListProps<any>>)) => (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S & VirtualizedListProps<any>>)[]) => <Props, >(componentProps: Partial<S & OptionalProps & VirtualizedListProps<Props>>) => invoke(styled<ViewStyle, VirtualizedListProps<Props>>(VirtualizedList).attrs<S>(opts as any)(chunks, ...functs), componentProps as any)
172
172
 
173
173
  function invoke<T> (Component: React.ComponentType<T>, props: T) {
174
174
  return <Component {...props} />