bootstrap-rn 0.4.2 → 0.4.4
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/lib/module/components/close/CloseButton.js +1 -1
- package/lib/module/components/close/CloseButton.js.map +1 -1
- package/lib/module/components/forms/internals/FormCheckInputNative.js +1 -1
- package/lib/module/components/forms/internals/FormCheckInputNative.js.map +1 -1
- package/lib/module/components/forms/internals/FormCheckInputWeb.js +4 -2
- package/lib/module/components/forms/internals/FormCheckInputWeb.js.map +1 -1
- package/lib/module/components/forms/internals/PickerNative.js +1 -1
- package/lib/module/components/forms/internals/PickerNative.js.map +1 -1
- package/lib/module/components/forms/internals/PickerWeb.js +5 -2
- package/lib/module/components/forms/internals/PickerWeb.js.map +1 -1
- package/lib/module/components/helpers/BackdropHandler.js +3 -3
- package/lib/module/components/helpers/BackdropHandler.js.map +1 -1
- package/lib/module/components/navbar/NavbarToggler.js +1 -1
- package/lib/module/components/navbar/NavbarToggler.js.map +1 -1
- package/lib/module/hooks/useBackground.js +4 -78
- package/lib/module/hooks/useBackground.js.map +1 -1
- package/lib/module/hooks/{useBackground.native.js → useBackgroundNative.js} +2 -2
- package/lib/module/hooks/useBackgroundNative.js.map +1 -0
- package/lib/module/hooks/useBackgroundWeb.js +81 -0
- package/lib/module/hooks/useBackgroundWeb.js.map +1 -0
- package/lib/module/hooks/useScrollbarEffects.js +2 -2
- package/lib/module/hooks/useScrollbarEffects.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/theme/variables.js +91 -91
- package/lib/module/theme/variables.js.map +1 -1
- package/lib/typescript/components/Pressable.d.ts.map +1 -1
- package/lib/typescript/components/forms/internals/FormCheckInputWeb.d.ts.map +1 -1
- package/lib/typescript/components/forms/internals/PickerNative.d.ts.map +1 -1
- package/lib/typescript/components/forms/internals/PickerWeb.d.ts.map +1 -1
- package/lib/typescript/hooks/useBackground.d.ts +4 -5
- package/lib/typescript/hooks/useBackground.d.ts.map +1 -1
- package/lib/typescript/hooks/{useBackground.native.d.ts → useBackgroundNative.d.ts} +2 -2
- package/lib/typescript/hooks/useBackgroundNative.d.ts.map +1 -0
- package/lib/typescript/hooks/useBackgroundWeb.d.ts +6 -0
- package/lib/typescript/hooks/useBackgroundWeb.d.ts.map +1 -0
- package/lib/typescript/hooks/useStyle.d.ts.map +1 -1
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/theme/functions.d.ts.map +1 -1
- package/lib/typescript/theme/variables.d.ts.map +1 -1
- package/package.json +85 -84
- package/src/components/forms/internals/FormCheckInputWeb.tsx +79 -78
- package/src/components/forms/internals/PickerNative.tsx +3 -2
- package/src/components/forms/internals/PickerWeb.tsx +85 -78
- package/src/components/helpers/BackdropHandler.tsx +3 -3
- package/src/hooks/useBackground.tsx +4 -122
- package/src/hooks/{useBackground.native.tsx → useBackgroundNative.tsx} +1 -1
- package/src/hooks/useBackgroundWeb.tsx +123 -0
- package/src/hooks/useScrollbarEffects.ts +2 -2
- package/src/style/transform/index.ts +245 -245
- package/src/theme/variables.ts +1420 -1414
- package/lib/module/hooks/useBackground.native.js.map +0 -1
- package/lib/typescript/hooks/useBackground.native.d.ts.map +0 -1
|
@@ -1,245 +1,245 @@
|
|
|
1
|
-
import { Platform } from 'react-native';
|
|
2
|
-
import { getPropertyName, getStylesForProperty } from 'css-to-react-native';
|
|
3
|
-
import rem from './rem';
|
|
4
|
-
import formula from './formula';
|
|
5
|
-
import rgba from './rgba';
|
|
6
|
-
import backgroundSize from './properties/backgroundSize';
|
|
7
|
-
import backgroundPosition from './properties/backgroundPosition';
|
|
8
|
-
import backgroundPositionX from './properties/backgroundPositionX';
|
|
9
|
-
import backgroundPositionY from './properties/backgroundPositionY';
|
|
10
|
-
import type { BaseStyle } from '../../types';
|
|
11
|
-
|
|
12
|
-
type Value = string | ((v: object, k: string | undefined) => string);
|
|
13
|
-
|
|
14
|
-
export type SelectorStyleScope = {
|
|
15
|
-
type: 'selector';
|
|
16
|
-
name: 'hover' | 'focus' | 'focus-visible' | 'active';
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type MixinStyleScope = {
|
|
20
|
-
type: 'mixin';
|
|
21
|
-
name:
|
|
22
|
-
| 'media-breakpoint-between'
|
|
23
|
-
| 'media-breakpoint-down'
|
|
24
|
-
| 'media-breakpoint-only'
|
|
25
|
-
| 'media-breakpoint-up'
|
|
26
|
-
| 'platform';
|
|
27
|
-
args: string[];
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export type StyleScope = SelectorStyleScope | MixinStyleScope;
|
|
31
|
-
|
|
32
|
-
export type RootNode = {
|
|
33
|
-
type: 'root';
|
|
34
|
-
// eslint-disable-next-line no-use-before-define
|
|
35
|
-
children: Node[];
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export type VariableNode = { type: 'variable'; name: string; value: Value[] };
|
|
39
|
-
|
|
40
|
-
export type DeclarationNode = {
|
|
41
|
-
type: 'declaration';
|
|
42
|
-
name: string;
|
|
43
|
-
value: Value[];
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export type BlockNode = {
|
|
47
|
-
type: 'block';
|
|
48
|
-
scopes: StyleScope[];
|
|
49
|
-
// eslint-disable-next-line no-use-before-define
|
|
50
|
-
children: Node[];
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export type Node = RootNode | VariableNode | DeclarationNode | BlockNode;
|
|
54
|
-
|
|
55
|
-
export type StyleDefinition = {
|
|
56
|
-
scopes: StyleScope[];
|
|
57
|
-
declarations: BaseStyle;
|
|
58
|
-
variables: Record<string, string>;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
type Options = {
|
|
62
|
-
key?: string;
|
|
63
|
-
preferTheme?: boolean;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const urlRE = /^url\(.*?\)$/g;
|
|
67
|
-
|
|
68
|
-
const applyVariables = (
|
|
69
|
-
variables: Record<string, string>,
|
|
70
|
-
key: string | undefined,
|
|
71
|
-
value: Value,
|
|
72
|
-
) => (typeof value === 'function' ? value(variables, key) : value);
|
|
73
|
-
|
|
74
|
-
const applyTransforms = (result: string) => {
|
|
75
|
-
// Do not transform values that belong to an url().
|
|
76
|
-
if (result.match(urlRE)) {
|
|
77
|
-
return result;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return rgba(formula(rem(result)));
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const resolveValue = (
|
|
84
|
-
value: Value[],
|
|
85
|
-
definition: StyleDefinition,
|
|
86
|
-
theme: object,
|
|
87
|
-
options: Options,
|
|
88
|
-
) => {
|
|
89
|
-
const variables = options.preferTheme
|
|
90
|
-
? { ...definition.variables, ...theme }
|
|
91
|
-
: { ...theme, ...definition.variables };
|
|
92
|
-
|
|
93
|
-
// If there is only one part, we allow other results than strings as well.
|
|
94
|
-
if (value.length === 1) {
|
|
95
|
-
const result = applyVariables(variables, options.key, value[0]);
|
|
96
|
-
|
|
97
|
-
return typeof result === 'string' ? applyTransforms(result) : result;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const stringifiedResult = value.reduce(
|
|
101
|
-
(previous, current) =>
|
|
102
|
-
`${previous}${applyVariables(variables, options.key, current)}`,
|
|
103
|
-
'',
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
return applyTransforms(stringifiedResult as string);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export default function transform(
|
|
110
|
-
children: Node[],
|
|
111
|
-
theme: object,
|
|
112
|
-
options: Options = {},
|
|
113
|
-
scopes: StyleScope[] = [],
|
|
114
|
-
variables: Record<string, string> = {},
|
|
115
|
-
) {
|
|
116
|
-
let definitions: StyleDefinition[] = [
|
|
117
|
-
{
|
|
118
|
-
scopes,
|
|
119
|
-
declarations: {},
|
|
120
|
-
variables: { ...variables },
|
|
121
|
-
},
|
|
122
|
-
];
|
|
123
|
-
|
|
124
|
-
children.forEach((child) => {
|
|
125
|
-
if (child.type === 'variable' || child.type === 'declaration') {
|
|
126
|
-
// Transform value to react native compatible value.
|
|
127
|
-
const value = resolveValue(child.value, definitions[0], theme, options);
|
|
128
|
-
|
|
129
|
-
if (child.type === 'variable') {
|
|
130
|
-
definitions[0].variables[child.name] = value;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// Only add value if value is not null.
|
|
134
|
-
if (child.type === 'declaration' && value !== 'null') {
|
|
135
|
-
if (child.name === 'box-shadow') {
|
|
136
|
-
if (Platform.OS === 'web') {
|
|
137
|
-
Object.assign(definitions[0].declarations, {
|
|
138
|
-
boxShadow: value,
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
} else if (child.name === 'margin-vertical') {
|
|
142
|
-
Object.assign(definitions[0].declarations, {
|
|
143
|
-
...getStylesForProperty('marginTop', value),
|
|
144
|
-
...getStylesForProperty('marginBottom', value),
|
|
145
|
-
});
|
|
146
|
-
} else if (child.name === 'margin-horizontal') {
|
|
147
|
-
// Among other things workaround for react-native issue #350
|
|
148
|
-
// https://github.com/facebook/react-native/issues/350#issuecomment-375238958
|
|
149
|
-
Object.assign(definitions[0].declarations, {
|
|
150
|
-
...getStylesForProperty('marginLeft', value),
|
|
151
|
-
...getStylesForProperty('marginRight', value),
|
|
152
|
-
});
|
|
153
|
-
} else if (child.name === 'padding-vertical') {
|
|
154
|
-
Object.assign(definitions[0].declarations, {
|
|
155
|
-
...getStylesForProperty('paddingTop', value),
|
|
156
|
-
...getStylesForProperty('paddingBottom', value),
|
|
157
|
-
});
|
|
158
|
-
} else if (child.name === 'padding-horizontal') {
|
|
159
|
-
Object.assign(definitions[0].declarations, {
|
|
160
|
-
...getStylesForProperty('paddingLeft', value),
|
|
161
|
-
...getStylesForProperty('paddingRight', value),
|
|
162
|
-
});
|
|
163
|
-
} else if (child.name === 'background-size') {
|
|
164
|
-
Object.assign(definitions[0].declarations, backgroundSize(value));
|
|
165
|
-
} else if (child.name === 'background-position') {
|
|
166
|
-
Object.assign(definitions[0].declarations, backgroundPosition(value));
|
|
167
|
-
} else if (child.name === 'background-position-x') {
|
|
168
|
-
Object.assign(
|
|
169
|
-
definitions[0].declarations,
|
|
170
|
-
backgroundPositionX(value),
|
|
171
|
-
);
|
|
172
|
-
} else if (child.name === 'background-position-y') {
|
|
173
|
-
Object.assign(
|
|
174
|
-
definitions[0].declarations,
|
|
175
|
-
backgroundPositionY(value),
|
|
176
|
-
);
|
|
177
|
-
} else if (
|
|
178
|
-
child.name === 'border-color' &&
|
|
179
|
-
value.split(' ').length === 1
|
|
180
|
-
) {
|
|
181
|
-
// Workaround for react-native issue #19981
|
|
182
|
-
// https://github.com/facebook/react-native/issues/19981
|
|
183
|
-
Object.assign(definitions[0].declarations, {
|
|
184
|
-
borderColor: value,
|
|
185
|
-
});
|
|
186
|
-
} else {
|
|
187
|
-
const style = getStylesForProperty(
|
|
188
|
-
getPropertyName(child.name),
|
|
189
|
-
value,
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
// Workaround for react-native issue #47235
|
|
193
|
-
// https://github.com/facebook/react-native/issues/47235
|
|
194
|
-
if (Platform.OS === 'ios') {
|
|
195
|
-
if (style.borderTopLeftRadius) {
|
|
196
|
-
style.borderTopLeftRadius = Math.round(
|
|
197
|
-
style.borderTopLeftRadius as number,
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
if (style.borderTopRightRadius) {
|
|
201
|
-
style.borderTopRightRadius = Math.round(
|
|
202
|
-
style.borderTopRightRadius as number,
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
if (style.borderBottomRightRadius) {
|
|
206
|
-
style.borderBottomRightRadius = Math.round(
|
|
207
|
-
style.borderBottomRightRadius as number,
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
if (style.borderBottomLeftRadius) {
|
|
211
|
-
style.borderBottomLeftRadius = Math.round(
|
|
212
|
-
style.borderBottomLeftRadius as number,
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// TODO: Pre-process css-to-react-native transformation, so that we only
|
|
218
|
-
// need to insert theme variables here.
|
|
219
|
-
Object.assign(definitions[0].declarations, style);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (child.type === 'block') {
|
|
225
|
-
definitions = definitions.concat(
|
|
226
|
-
transform(
|
|
227
|
-
child.children,
|
|
228
|
-
theme,
|
|
229
|
-
options,
|
|
230
|
-
// Add child scopes to current scopes.
|
|
231
|
-
[...scopes, ...child.scopes],
|
|
232
|
-
// Pass down variables, so that we can extend them.
|
|
233
|
-
definitions[0].variables,
|
|
234
|
-
),
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
// Filter empty definitions and return.
|
|
240
|
-
return definitions.filter(
|
|
241
|
-
(definition) =>
|
|
242
|
-
Object.keys(definition.declarations).length > 0 ||
|
|
243
|
-
Object.keys(definition.variables).length > 0,
|
|
244
|
-
);
|
|
245
|
-
}
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { getPropertyName, getStylesForProperty } from 'css-to-react-native';
|
|
3
|
+
import rem from './rem';
|
|
4
|
+
import formula from './formula';
|
|
5
|
+
import rgba from './rgba';
|
|
6
|
+
import backgroundSize from './properties/backgroundSize';
|
|
7
|
+
import backgroundPosition from './properties/backgroundPosition';
|
|
8
|
+
import backgroundPositionX from './properties/backgroundPositionX';
|
|
9
|
+
import backgroundPositionY from './properties/backgroundPositionY';
|
|
10
|
+
import type { BaseStyle } from '../../types';
|
|
11
|
+
|
|
12
|
+
type Value = string | ((v: object, k: string | undefined) => string);
|
|
13
|
+
|
|
14
|
+
export type SelectorStyleScope = {
|
|
15
|
+
type: 'selector';
|
|
16
|
+
name: 'hover' | 'focus' | 'focus-visible' | 'active';
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type MixinStyleScope = {
|
|
20
|
+
type: 'mixin';
|
|
21
|
+
name:
|
|
22
|
+
| 'media-breakpoint-between'
|
|
23
|
+
| 'media-breakpoint-down'
|
|
24
|
+
| 'media-breakpoint-only'
|
|
25
|
+
| 'media-breakpoint-up'
|
|
26
|
+
| 'platform';
|
|
27
|
+
args: string[];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type StyleScope = SelectorStyleScope | MixinStyleScope;
|
|
31
|
+
|
|
32
|
+
export type RootNode = {
|
|
33
|
+
type: 'root';
|
|
34
|
+
// eslint-disable-next-line no-use-before-define
|
|
35
|
+
children: Node[];
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type VariableNode = { type: 'variable'; name: string; value: Value[] };
|
|
39
|
+
|
|
40
|
+
export type DeclarationNode = {
|
|
41
|
+
type: 'declaration';
|
|
42
|
+
name: string;
|
|
43
|
+
value: Value[];
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type BlockNode = {
|
|
47
|
+
type: 'block';
|
|
48
|
+
scopes: StyleScope[];
|
|
49
|
+
// eslint-disable-next-line no-use-before-define
|
|
50
|
+
children: Node[];
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type Node = RootNode | VariableNode | DeclarationNode | BlockNode;
|
|
54
|
+
|
|
55
|
+
export type StyleDefinition = {
|
|
56
|
+
scopes: StyleScope[];
|
|
57
|
+
declarations: BaseStyle;
|
|
58
|
+
variables: Record<string, string>;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
type Options = {
|
|
62
|
+
key?: string;
|
|
63
|
+
preferTheme?: boolean;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const urlRE = /^url\(.*?\)$/g;
|
|
67
|
+
|
|
68
|
+
const applyVariables = (
|
|
69
|
+
variables: Record<string, string>,
|
|
70
|
+
key: string | undefined,
|
|
71
|
+
value: Value,
|
|
72
|
+
) => (typeof value === 'function' ? value(variables, key) : value);
|
|
73
|
+
|
|
74
|
+
const applyTransforms = (result: string) => {
|
|
75
|
+
// Do not transform values that belong to an url().
|
|
76
|
+
if (result.match(urlRE)) {
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return rgba(formula(rem(result)));
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const resolveValue = (
|
|
84
|
+
value: Value[],
|
|
85
|
+
definition: StyleDefinition,
|
|
86
|
+
theme: object,
|
|
87
|
+
options: Options,
|
|
88
|
+
) => {
|
|
89
|
+
const variables = options.preferTheme
|
|
90
|
+
? { ...definition.variables, ...theme }
|
|
91
|
+
: { ...theme, ...definition.variables };
|
|
92
|
+
|
|
93
|
+
// If there is only one part, we allow other results than strings as well.
|
|
94
|
+
if (value.length === 1) {
|
|
95
|
+
const result = applyVariables(variables, options.key, value[0]);
|
|
96
|
+
|
|
97
|
+
return typeof result === 'string' ? applyTransforms(result) : result;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const stringifiedResult = value.reduce(
|
|
101
|
+
(previous, current) =>
|
|
102
|
+
`${previous}${applyVariables(variables, options.key, current)}`,
|
|
103
|
+
'',
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
return applyTransforms(stringifiedResult as string);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export default function transform(
|
|
110
|
+
children: Node[],
|
|
111
|
+
theme: object,
|
|
112
|
+
options: Options = {},
|
|
113
|
+
scopes: StyleScope[] = [],
|
|
114
|
+
variables: Record<string, string> = {},
|
|
115
|
+
) {
|
|
116
|
+
let definitions: StyleDefinition[] = [
|
|
117
|
+
{
|
|
118
|
+
scopes,
|
|
119
|
+
declarations: {},
|
|
120
|
+
variables: { ...variables },
|
|
121
|
+
},
|
|
122
|
+
];
|
|
123
|
+
|
|
124
|
+
children.forEach((child) => {
|
|
125
|
+
if (child.type === 'variable' || child.type === 'declaration') {
|
|
126
|
+
// Transform value to react native compatible value.
|
|
127
|
+
const value = resolveValue(child.value, definitions[0], theme, options);
|
|
128
|
+
|
|
129
|
+
if (child.type === 'variable') {
|
|
130
|
+
definitions[0].variables[child.name] = value;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Only add value if value is not null.
|
|
134
|
+
if (child.type === 'declaration' && value !== 'null') {
|
|
135
|
+
if (child.name === 'box-shadow') {
|
|
136
|
+
if (Platform.OS === 'web') {
|
|
137
|
+
Object.assign(definitions[0].declarations, {
|
|
138
|
+
boxShadow: value,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
} else if (child.name === 'margin-vertical') {
|
|
142
|
+
Object.assign(definitions[0].declarations, {
|
|
143
|
+
...getStylesForProperty('marginTop', value),
|
|
144
|
+
...getStylesForProperty('marginBottom', value),
|
|
145
|
+
});
|
|
146
|
+
} else if (child.name === 'margin-horizontal') {
|
|
147
|
+
// Among other things workaround for react-native issue #350
|
|
148
|
+
// https://github.com/facebook/react-native/issues/350#issuecomment-375238958
|
|
149
|
+
Object.assign(definitions[0].declarations, {
|
|
150
|
+
...getStylesForProperty('marginLeft', value),
|
|
151
|
+
...getStylesForProperty('marginRight', value),
|
|
152
|
+
});
|
|
153
|
+
} else if (child.name === 'padding-vertical') {
|
|
154
|
+
Object.assign(definitions[0].declarations, {
|
|
155
|
+
...getStylesForProperty('paddingTop', value),
|
|
156
|
+
...getStylesForProperty('paddingBottom', value),
|
|
157
|
+
});
|
|
158
|
+
} else if (child.name === 'padding-horizontal') {
|
|
159
|
+
Object.assign(definitions[0].declarations, {
|
|
160
|
+
...getStylesForProperty('paddingLeft', value),
|
|
161
|
+
...getStylesForProperty('paddingRight', value),
|
|
162
|
+
});
|
|
163
|
+
} else if (child.name === 'background-size') {
|
|
164
|
+
Object.assign(definitions[0].declarations, backgroundSize(value));
|
|
165
|
+
} else if (child.name === 'background-position') {
|
|
166
|
+
Object.assign(definitions[0].declarations, backgroundPosition(value));
|
|
167
|
+
} else if (child.name === 'background-position-x') {
|
|
168
|
+
Object.assign(
|
|
169
|
+
definitions[0].declarations,
|
|
170
|
+
backgroundPositionX(value),
|
|
171
|
+
);
|
|
172
|
+
} else if (child.name === 'background-position-y') {
|
|
173
|
+
Object.assign(
|
|
174
|
+
definitions[0].declarations,
|
|
175
|
+
backgroundPositionY(value),
|
|
176
|
+
);
|
|
177
|
+
} else if (
|
|
178
|
+
child.name === 'border-color' &&
|
|
179
|
+
value.split(' ').length === 1
|
|
180
|
+
) {
|
|
181
|
+
// Workaround for react-native issue #19981
|
|
182
|
+
// https://github.com/facebook/react-native/issues/19981
|
|
183
|
+
Object.assign(definitions[0].declarations, {
|
|
184
|
+
borderColor: value,
|
|
185
|
+
});
|
|
186
|
+
} else {
|
|
187
|
+
const style = getStylesForProperty(
|
|
188
|
+
getPropertyName(child.name),
|
|
189
|
+
value,
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
// Workaround for react-native issue #47235
|
|
193
|
+
// https://github.com/facebook/react-native/issues/47235
|
|
194
|
+
if (Platform.OS === 'ios') {
|
|
195
|
+
if (style.borderTopLeftRadius) {
|
|
196
|
+
style.borderTopLeftRadius = Math.round(
|
|
197
|
+
style.borderTopLeftRadius as number,
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
if (style.borderTopRightRadius) {
|
|
201
|
+
style.borderTopRightRadius = Math.round(
|
|
202
|
+
style.borderTopRightRadius as number,
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
if (style.borderBottomRightRadius) {
|
|
206
|
+
style.borderBottomRightRadius = Math.round(
|
|
207
|
+
style.borderBottomRightRadius as number,
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
if (style.borderBottomLeftRadius) {
|
|
211
|
+
style.borderBottomLeftRadius = Math.round(
|
|
212
|
+
style.borderBottomLeftRadius as number,
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// TODO: Pre-process css-to-react-native transformation, so that we only
|
|
218
|
+
// need to insert theme variables here.
|
|
219
|
+
Object.assign(definitions[0].declarations, style);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (child.type === 'block') {
|
|
225
|
+
definitions = definitions.concat(
|
|
226
|
+
transform(
|
|
227
|
+
child.children,
|
|
228
|
+
theme,
|
|
229
|
+
options,
|
|
230
|
+
// Add child scopes to current scopes.
|
|
231
|
+
[...scopes, ...child.scopes],
|
|
232
|
+
// Pass down variables, so that we can extend them.
|
|
233
|
+
definitions[0].variables,
|
|
234
|
+
),
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
// Filter empty definitions and return.
|
|
240
|
+
return definitions.filter(
|
|
241
|
+
(definition) =>
|
|
242
|
+
Object.keys(definition.declarations).length > 0 ||
|
|
243
|
+
Object.keys(definition.variables).length > 0,
|
|
244
|
+
);
|
|
245
|
+
}
|