rn-css 1.11.10 → 1.12.0
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/convertUnits.js
CHANGED
|
@@ -17,7 +17,7 @@ function convertValue(key, value, units) {
|
|
|
17
17
|
return 0;
|
|
18
18
|
}
|
|
19
19
|
// colors should be left untouched
|
|
20
|
-
if (value.startsWith('#'))
|
|
20
|
+
if (value.startsWith('#') || value.startsWith('linear-gradient'))
|
|
21
21
|
return value;
|
|
22
22
|
// Percentage values need to rely on an other unit as reference
|
|
23
23
|
const finalUnits = { ...units };
|
package/dist/cssToRN/convert.js
CHANGED
|
@@ -136,7 +136,9 @@ function placeContent(value) {
|
|
|
136
136
|
exports.placeContent = placeContent;
|
|
137
137
|
function background(value) {
|
|
138
138
|
const values = value.match(/(linear-gradient\(|url\().*?\)|[^\s]+/mg) || [];
|
|
139
|
-
const backgroundColor = values.reverse().find(isColor) ||
|
|
139
|
+
const backgroundColor = values.reverse().find(isColor) ||
|
|
140
|
+
(values[0]?.startsWith('linear-gradient') && values[0].split(',').map(val => val.trim()).find(isColor)) ||
|
|
141
|
+
'transparent';
|
|
140
142
|
// We support everything on web
|
|
141
143
|
return react_native_1.Platform.OS === 'web' ? { backgroundColor, background: value } : { backgroundColor };
|
|
142
144
|
}
|
package/dist/styleComponent.js
CHANGED
|
@@ -26,7 +26,7 @@ function buildCSSString(chunks, functs, props, shared) {
|
|
|
26
26
|
.map((chunk, i) => ([chunk, (functs[i] instanceof Function) ? functs[i]({ shared, theme: shared, ...props }) : functs[i]]))
|
|
27
27
|
.flat()
|
|
28
28
|
// Convert the objects to string if the result is not a primitive
|
|
29
|
-
.map(chunk => typeof chunk === 'object' ? (0, rnToCss_1.default)(chunk) : chunk)
|
|
29
|
+
.map(chunk => chunk && typeof chunk === 'object' ? (0, rnToCss_1.default)(chunk) : chunk)
|
|
30
30
|
.join('');
|
|
31
31
|
if (props.rnCSS)
|
|
32
32
|
computedString += props.rnCSS.replace(/=/gm, ':') + ';';
|
|
@@ -158,8 +158,9 @@ const styled = (Component) => {
|
|
|
158
158
|
const ComponentWithAttrs = styledComponent(chunks, ...functs);
|
|
159
159
|
// We need to limit the props control to only Result https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABBATgUwIZTQUQB7ZgAmaRAwnALYAOAPAAopzUDOAfABQU0BciH1Jqz6NmLAJSIAvG0QYwAT0kBvAFCJkCFlET5CJYt2rT+gsSKETpstRo3ooIFEiMDL49YgC+nvWmL+5FTUAHRYUCgsJrQASmgsIAA2OmgEgVH0GCiwGIkMlmyc4ZF8cQnJkjKItnYQWjqMaHVgwDAA5k5YpEYmbua6eBCJICT5YgA0iGVJUGyVNp52iA5OLsEcyiFbZqyTW2FQESxeHks+SyvOiI3NrR0oXUE0nufLaI5XfgGGwao+qqBILAEIgen1hNVENhtHxtCgYGA2pNtApEmhYREEW1vCpPJckDsWH9VM1tNd0Ld2j0pMh0F0viQntQuMFxAcjhsofEoHwAORwADWvJxqhuCDurmUiBRaL50KgwpOQA
|
|
160
160
|
const ForwardRefComponent = react_1.default.forwardRef((props, ref) => {
|
|
161
|
-
const
|
|
162
|
-
|
|
161
|
+
const castProps = props;
|
|
162
|
+
const attrs = (opts instanceof Function) ? opts(castProps) : opts;
|
|
163
|
+
return react_1.default.createElement(ComponentWithAttrs, { ref: ref, ...attrs, ...castProps });
|
|
163
164
|
});
|
|
164
165
|
// TODO : Find a way to remove from the Props the properties affected by opts
|
|
165
166
|
return ForwardRefComponent;
|
package/package.json
CHANGED
package/src/convertUnits.ts
CHANGED
|
@@ -16,7 +16,7 @@ export function convertValue (key: keyof PartialStyle | keyof Transform, value:
|
|
|
16
16
|
return 0
|
|
17
17
|
}
|
|
18
18
|
// colors should be left untouched
|
|
19
|
-
if (value.startsWith('#')) return value
|
|
19
|
+
if (value.startsWith('#') || value.startsWith('linear-gradient')) return value
|
|
20
20
|
|
|
21
21
|
// Percentage values need to rely on an other unit as reference
|
|
22
22
|
const finalUnits = { ...units }
|
package/src/cssToRN/convert.ts
CHANGED
|
@@ -119,7 +119,9 @@ export function placeContent (value: string) {
|
|
|
119
119
|
|
|
120
120
|
export function background (value: string) {
|
|
121
121
|
const values = value.match(/(linear-gradient\(|url\().*?\)|[^\s]+/mg) || []
|
|
122
|
-
const backgroundColor = values.reverse().find(isColor) ||
|
|
122
|
+
const backgroundColor = values.reverse().find(isColor) ||
|
|
123
|
+
(values[0]?.startsWith('linear-gradient') && values[0].split(',').map(val => val.trim()).find(isColor)) ||
|
|
124
|
+
'transparent'
|
|
123
125
|
// We support everything on web
|
|
124
126
|
return Platform.OS === 'web' ? { backgroundColor, background: value } : { backgroundColor }
|
|
125
127
|
}
|
package/src/styleComponent.tsx
CHANGED
|
@@ -44,7 +44,7 @@ function buildCSSString<T extends { rnCSS?: string }> (chunks: TemplateStringsAr
|
|
|
44
44
|
.map((chunk, i) => ([chunk, (functs[i] instanceof Function) ? (functs[i] as Functs<T>)({ shared, theme: (shared as DefaultTheme), ...props }) : functs[i]]))
|
|
45
45
|
.flat()
|
|
46
46
|
// Convert the objects to string if the result is not a primitive
|
|
47
|
-
.map(chunk => typeof chunk === 'object' ? rnToCSS(chunk as Partial<CompleteStyle>) : chunk)
|
|
47
|
+
.map(chunk => chunk && typeof chunk === 'object' ? rnToCSS(chunk as Partial<CompleteStyle>) : chunk)
|
|
48
48
|
.join('')
|
|
49
49
|
if (props.rnCSS) computedString += props.rnCSS.replace(/=/gm, ':') + ';'
|
|
50
50
|
return computedString
|
|
@@ -187,8 +187,9 @@ const styled = <StyleType, InitialProps extends { style?: StyleProp<StyleType> }
|
|
|
187
187
|
const ComponentWithAttrs = styledComponent(chunks, ...functs)
|
|
188
188
|
// We need to limit the props control to only Result https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABBATgUwIZTQUQB7ZgAmaRAwnALYAOAPAAopzUDOAfABQU0BciH1Jqz6NmLAJSIAvG0QYwAT0kBvAFCJkCFlET5CJYt2rT+gsSKETpstRo3ooIFEiMDL49YgC+nvWmL+5FTUAHRYUCgsJrQASmgsIAA2OmgEgVH0GCiwGIkMlmyc4ZF8cQnJkjKItnYQWjqMaHVgwDAA5k5YpEYmbua6eBCJICT5YgA0iGVJUGyVNp52iA5OLsEcyiFbZqyTW2FQESxeHks+SyvOiI3NrR0oXUE0nufLaI5XfgGGwao+qqBILAEIgen1hNVENhtHxtCgYGA2pNtApEmhYREEW1vCpPJckDsWH9VM1tNd0Ld2j0pMh0F0viQntQuMFxAcjhsofEoHwAORwADWvJxqhuCDurmUiBRaL50KgwpOQA
|
|
189
189
|
const ForwardRefComponent = React.forwardRef<any, Omit<Props, keyof Result> & Part & Partial<Pick<Props, Extract<keyof Props, keyof Result>>>>((props, ref) => {
|
|
190
|
-
const
|
|
191
|
-
|
|
190
|
+
const castProps = props as unknown as Props & Part
|
|
191
|
+
const attrs = (opts instanceof Function) ? opts(castProps) : opts
|
|
192
|
+
return <ComponentWithAttrs ref={ref} {...attrs} {...castProps} />
|
|
192
193
|
})
|
|
193
194
|
// TODO : Find a way to remove from the Props the properties affected by opts
|
|
194
195
|
return ForwardRefComponent
|
|
@@ -206,6 +207,6 @@ styledSectionList.attrs = <S, Result extends Partial<S & SectionListProps<any> &
|
|
|
206
207
|
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)
|
|
207
208
|
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)
|
|
208
209
|
|
|
209
|
-
function invoke<T> (Component: React.ComponentType<T>, props: T) {
|
|
210
|
+
function invoke<T extends object> (Component: React.ComponentType<T>, props: T) {
|
|
210
211
|
return <Component {...props} />
|
|
211
212
|
}
|