rn-css 1.8.8 → 1.8.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.
@@ -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<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>>;
29
+ attrs<Part, Result extends Partial<Props & Part> = Partial<Props & Part>>(opts: Result | ((props: Props & Part) => Result)): (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<Props & Part>)[]) => React.ForwardRefExoticComponent<React.PropsWithoutRef<Omit<Props, keyof Result> & Part & Partial<Props>> & 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: 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;
34
+ attrs<S_1, Result extends Partial<S_1 & FlatListProps<any> & OptionalProps> = {}>(opts: Result | ((props: S_1 & OptionalProps & FlatListProps<any>) => Result)): (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S_1>)[]) => <Props>(componentProps: Omit<FlatListProps<Props> & OptionalProps, keyof Result> & S_1 & Partial<Result>) => 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: 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;
38
+ attrs<S_1, Result extends Partial<S_1 & SectionListProps<any, import("react-native").DefaultSectionT> & OptionalProps> = {}>(opts: Result | ((props: S_1 & OptionalProps & SectionListProps<any, import("react-native").DefaultSectionT>) => Result)): (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S_1>)[]) => <Props>(componentProps: Omit<SectionListProps<Props, import("react-native").DefaultSectionT> & OptionalProps, keyof Result> & S_1 & Partial<Result>) => 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: 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;
42
+ attrs<S_1, Result extends Partial<S_1 & VirtualizedListProps<any> & OptionalProps> = {}>(opts: Result | ((props: S_1 & OptionalProps & VirtualizedListProps<any>) => Result)): (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S_1>)[]) => <Props>(componentProps: Omit<VirtualizedListProps<Props> & OptionalProps, keyof Result> & S_1 & Partial<Result>) => JSX.Element;
43
43
  };
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.styledVirtualizedList = exports.styledSectionList = exports.styledFlatList = exports.SharedValue = exports.FontSizeContext = exports.RemContext = exports.defaultUnits = void 0;
7
+ /* eslint-disable @typescript-eslint/ban-types */
7
8
  /* eslint-disable react/prop-types */
8
9
  /* eslint-disable react/display-name */
9
10
  const react_1 = __importDefault(require("react"));
@@ -129,9 +130,9 @@ const styled = (Component) => {
129
130
  return ForwardRefComponent;
130
131
  };
131
132
  // provide styled(Comp).attrs({} | () => {}) feature
132
- // eslint-disable-next-line @typescript-eslint/ban-types
133
133
  styledComponent.attrs = (opts) => (chunks, ...functs) => {
134
134
  const ComponentWithAttrs = styledComponent(chunks, ...functs);
135
+ // We need to limit the props control to only Result https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABBATgUwIZTQUQB7ZgAmaRAwnALYAOAPAAopzUDOAfABQU0BciH1Jqz6NmLAJSIAvG0QYwAT0kBvAFCJkCFlET5CJYt2rT+gsSKETpstRo3ooIFEiMDL49YgC+nvWmL+5FTUAHRYUCgsJrQASmgsIAA2OmgEgVH0GCiwGIkMlmyc4ZF8cQnJkjKItnYQWjqMaHVgwDAA5k5YpEYmbua6eBCJICT5YgA0iGVJUGyVNp52iA5OLsEcyiFbZqyTW2FQESxeHks+SyvOiI3NrR0oXUE0nufLaI5XfgGGwao+qqBILAEIgen1hNVENhtHxtCgYGA2pNtApEmhYREEW1vCpPJckDsWH9VM1tNd0Ld2j0pMh0F0viQntQuMFxAcjhsofEoHwAORwADWvJxqhuCDurmUiBRaL50KgwpOQA
135
136
  const ForwardRefComponent = react_1.default.forwardRef((props, ref) => {
136
137
  const attrs = (opts instanceof Function) ? opts(props) : opts;
137
138
  return react_1.default.createElement(ComponentWithAttrs, { ref: ref, ...props, ...attrs });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rn-css",
3
- "version": "1.8.8",
3
+ "version": "1.8.10",
4
4
  "scripts": {
5
5
  "test": "jest",
6
6
  "prepare": "tsc",
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/ban-types */
1
2
  /* eslint-disable react/prop-types */
2
3
  /* eslint-disable react/display-name */
3
4
  import React, { MouseEvent } from 'react'
@@ -148,12 +149,12 @@ const styled = <StyleType, InitialProps extends { style?: StyleProp<StyleType> }
148
149
  }
149
150
 
150
151
  // provide styled(Comp).attrs({} | () => {}) feature
151
- // eslint-disable-next-line @typescript-eslint/ban-types
152
- styledComponent.attrs = <Part, Result extends Partial<Props & Part> = {}>(opts: Partial<Props & Part> | ((props: Props & Part) => Partial<Props & Part>)) => (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<Part & Props>)[]) => {
152
+ styledComponent.attrs = <Part, Result extends Partial<Props & Part> = Partial<Props & Part>>(opts: Result | ((props: Props & Part) => Result)) => (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<Props & Part>)[]) => {
153
153
  const ComponentWithAttrs = styledComponent(chunks, ...functs)
154
- const ForwardRefComponent = React.forwardRef<any, Result>((props, ref) => {
155
- const attrs = (opts instanceof Function) ? opts(props as unknown as Props & Part) : opts
156
- return <ComponentWithAttrs ref={ref} {...(props as unknown as Props & Part)} {...attrs} />
154
+ // We need to limit the props control to only Result https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABBATgUwIZTQUQB7ZgAmaRAwnALYAOAPAAopzUDOAfABQU0BciH1Jqz6NmLAJSIAvG0QYwAT0kBvAFCJkCFlET5CJYt2rT+gsSKETpstRo3ooIFEiMDL49YgC+nvWmL+5FTUAHRYUCgsJrQASmgsIAA2OmgEgVH0GCiwGIkMlmyc4ZF8cQnJkjKItnYQWjqMaHVgwDAA5k5YpEYmbua6eBCJICT5YgA0iGVJUGyVNp52iA5OLsEcyiFbZqyTW2FQESxeHks+SyvOiI3NrR0oXUE0nufLaI5XfgGGwao+qqBILAEIgen1hNVENhtHxtCgYGA2pNtApEmhYREEW1vCpPJckDsWH9VM1tNd0Ld2j0pMh0F0viQntQuMFxAcjhsofEoHwAORwADWvJxqhuCDurmUiBRaL50KgwpOQA
155
+ const ForwardRefComponent = React.forwardRef<any, Omit<Props, keyof Result> & Part & Partial<Props>>((props, ref) => {
156
+ const attrs = (opts instanceof Function) ? opts(props as Props & Part) : opts
157
+ return <ComponentWithAttrs ref={ref} {...(props as Props & Part)} {...attrs} />
157
158
  })
158
159
  // TODO : Find a way to remove from the Props the properties affected by opts
159
160
  return ForwardRefComponent
@@ -165,11 +166,11 @@ const styled = <StyleType, InitialProps extends { style?: StyleProp<StyleType> }
165
166
  export default styled
166
167
 
167
168
  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)
168
- 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)
169
+ styledFlatList.attrs = <S, Result extends Partial<S & FlatListProps<any> & OptionalProps> = {} > (opts: Result | ((props: S & OptionalProps & FlatListProps<any>) => Result)) => (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S>)[]) => <Props, >(componentProps: Omit<FlatListProps<Props> & OptionalProps, keyof Result> & S & Partial<Result>) => invoke(styled<ViewStyle, FlatListProps<Props>>(FlatList).attrs<S>(opts)(chunks, ...functs), componentProps as any)
169
170
  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)
170
- 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)
171
+ styledSectionList.attrs = <S, Result extends Partial<S & SectionListProps<any> & OptionalProps> = {} >(opts: Result | ((props: S & OptionalProps & SectionListProps<any>) => Result)) => (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S>)[]) => <Props, >(componentProps: Omit<SectionListProps<Props> & OptionalProps, keyof Result> & S & Partial<Result>) => invoke(styled<ViewStyle, SectionListProps<Props>>(SectionList).attrs<S>(opts)(chunks, ...functs), componentProps as any)
171
172
  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)
172
- 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)
173
+ styledVirtualizedList.attrs = <S, Result extends Partial<S & VirtualizedListProps<any> & OptionalProps> = {} >(opts: Result | ((props: S & OptionalProps & VirtualizedListProps<any>) => Result)) => (chunks: TemplateStringsArray, ...functs: (Primitive | Functs<S>)[]) => <Props, >(componentProps: Omit<VirtualizedListProps<Props> & OptionalProps, keyof Result> & S & Partial<Result>) => invoke(styled<ViewStyle, VirtualizedListProps<Props>>(VirtualizedList).attrs<S>(opts)(chunks, ...functs), componentProps as any)
173
174
 
174
175
  function invoke<T> (Component: React.ComponentType<T>, props: T) {
175
176
  return <Component {...props} />