bootstrap-rn 0.4.10 → 0.4.11
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/FormCheckInput.js +1 -5
- package/lib/module/components/forms/FormCheckInput.js.map +1 -1
- package/lib/module/components/forms/Picker.js +24 -35
- package/lib/module/components/forms/Picker.js.map +1 -1
- package/lib/module/components/forms/PickerItem.js +1 -9
- package/lib/module/components/forms/PickerItem.js.map +1 -1
- package/lib/module/components/forms/internals/{FormCheckInputNative.js → FormCheckInput.js} +4 -4
- package/lib/module/components/forms/internals/FormCheckInput.js.map +1 -0
- package/lib/module/components/forms/internals/{FormCheckInputWeb.js → FormCheckInput.web.js} +4 -4
- package/lib/module/components/forms/internals/FormCheckInput.web.js.map +1 -0
- package/lib/module/components/forms/internals/{PickerNative.js → Picker.js} +4 -4
- package/lib/module/components/forms/internals/Picker.js.map +1 -0
- package/lib/module/components/forms/internals/{PickerWeb.js → Picker.web.js} +4 -4
- package/lib/module/components/forms/internals/Picker.web.js.map +1 -0
- package/lib/module/components/forms/internals/{PickerNativeItem.js → PickerItem.js} +3 -3
- package/lib/module/components/forms/internals/PickerItem.js.map +1 -0
- package/lib/module/components/forms/internals/{PickerWebItem.js → PickerItem.web.js} +3 -3
- package/lib/module/components/forms/internals/PickerItem.web.js.map +1 -0
- 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 +167 -4
- package/lib/module/hooks/useBackground.js.map +1 -1
- package/lib/module/hooks/{useBackgroundWeb.js → useBackground.web.js} +2 -2
- package/lib/module/hooks/useBackground.web.js.map +1 -0
- package/lib/module/hooks/useOverlay.web.js +6 -1
- package/lib/module/hooks/useOverlay.web.js.map +1 -1
- package/lib/typescript/components/forms/FormCheckInput.d.ts +0 -1
- package/lib/typescript/components/forms/FormCheckInput.d.ts.map +1 -1
- package/lib/typescript/components/forms/Picker.d.ts +0 -1
- package/lib/typescript/components/forms/Picker.d.ts.map +1 -1
- package/lib/typescript/components/forms/PickerItem.d.ts.map +1 -1
- package/lib/typescript/components/forms/internals/FormCheckInput.d.ts +10 -0
- package/lib/typescript/components/forms/internals/FormCheckInput.d.ts.map +1 -0
- package/lib/typescript/components/forms/internals/FormCheckInput.web.d.ts +10 -0
- package/lib/typescript/components/forms/internals/FormCheckInput.web.d.ts.map +1 -0
- package/lib/typescript/components/forms/internals/Picker.d.ts +10 -0
- package/lib/typescript/components/forms/internals/Picker.d.ts.map +1 -0
- package/lib/typescript/components/forms/internals/Picker.web.d.ts +10 -0
- package/lib/typescript/components/forms/internals/Picker.web.d.ts.map +1 -0
- package/lib/typescript/components/forms/internals/PickerItem.d.ts +10 -0
- package/lib/typescript/components/forms/internals/PickerItem.d.ts.map +1 -0
- package/lib/typescript/components/forms/internals/PickerItem.web.d.ts +10 -0
- package/lib/typescript/components/forms/internals/PickerItem.web.d.ts.map +1 -0
- package/lib/typescript/hooks/useBackground.d.ts +8 -4
- package/lib/typescript/hooks/useBackground.d.ts.map +1 -1
- package/lib/typescript/hooks/useBackground.web.d.ts +6 -0
- package/lib/typescript/hooks/useBackground.web.d.ts.map +1 -0
- package/lib/typescript/hooks/useOverlay.web.d.ts +5 -2
- package/lib/typescript/hooks/useOverlay.web.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/forms/FormCheckInput.tsx +1 -10
- package/src/components/forms/Picker.tsx +24 -40
- package/src/components/forms/PickerItem.tsx +1 -12
- package/src/components/forms/internals/{FormCheckInputNative.tsx → FormCheckInput.tsx} +4 -4
- package/src/components/forms/internals/{FormCheckInputWeb.tsx → FormCheckInput.web.tsx} +4 -4
- package/src/components/forms/internals/{PickerNative.tsx → Picker.tsx} +3 -5
- package/src/components/forms/internals/{PickerWeb.tsx → Picker.web.tsx} +3 -3
- package/src/components/forms/internals/{PickerNativeItem.tsx → PickerItem.tsx} +3 -5
- package/src/components/forms/internals/{PickerWebItem.tsx → PickerItem.web.tsx} +3 -5
- package/src/hooks/useBackground.tsx +203 -4
- package/src/hooks/{useBackgroundWeb.tsx → useBackground.web.tsx} +1 -1
- package/src/hooks/useOverlay.web.ts +20 -3
- package/lib/module/components/forms/PickerContext.js +0 -7
- package/lib/module/components/forms/PickerContext.js.map +0 -1
- package/lib/module/components/forms/internals/FormCheckInputNative.js.map +0 -1
- package/lib/module/components/forms/internals/FormCheckInputWeb.js.map +0 -1
- package/lib/module/components/forms/internals/PickerNative.js.map +0 -1
- package/lib/module/components/forms/internals/PickerNativeItem.js.map +0 -1
- package/lib/module/components/forms/internals/PickerWeb.js.map +0 -1
- package/lib/module/components/forms/internals/PickerWebItem.js.map +0 -1
- package/lib/module/hooks/useBackgroundNative.js +0 -170
- package/lib/module/hooks/useBackgroundNative.js.map +0 -1
- package/lib/module/hooks/useBackgroundWeb.js.map +0 -1
- package/lib/typescript/components/forms/PickerContext.d.ts +0 -7
- package/lib/typescript/components/forms/PickerContext.d.ts.map +0 -1
- package/lib/typescript/components/forms/internals/FormCheckInputNative.d.ts +0 -10
- package/lib/typescript/components/forms/internals/FormCheckInputNative.d.ts.map +0 -1
- package/lib/typescript/components/forms/internals/FormCheckInputWeb.d.ts +0 -10
- package/lib/typescript/components/forms/internals/FormCheckInputWeb.d.ts.map +0 -1
- package/lib/typescript/components/forms/internals/PickerNative.d.ts +0 -10
- package/lib/typescript/components/forms/internals/PickerNative.d.ts.map +0 -1
- package/lib/typescript/components/forms/internals/PickerNativeItem.d.ts +0 -10
- package/lib/typescript/components/forms/internals/PickerNativeItem.d.ts.map +0 -1
- package/lib/typescript/components/forms/internals/PickerWeb.d.ts +0 -10
- package/lib/typescript/components/forms/internals/PickerWeb.d.ts.map +0 -1
- package/lib/typescript/components/forms/internals/PickerWebItem.d.ts +0 -10
- package/lib/typescript/components/forms/internals/PickerWebItem.d.ts.map +0 -1
- package/lib/typescript/hooks/useBackgroundNative.d.ts +0 -9
- package/lib/typescript/hooks/useBackgroundNative.d.ts.map +0 -1
- package/lib/typescript/hooks/useBackgroundWeb.d.ts +0 -6
- package/lib/typescript/hooks/useBackgroundWeb.d.ts.map +0 -1
- package/src/components/forms/PickerContext.ts +0 -11
- package/src/hooks/useBackgroundNative.tsx +0 -204
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { I18nManager, StyleSheet, View } from 'react-native';
|
|
3
|
-
import { SvgXml } from 'react-native-svg';
|
|
4
|
-
import type { BaseStyle } from '../types';
|
|
5
|
-
|
|
6
|
-
type Position = 'center' | 'left' | 'right' | 'top' | 'bottom';
|
|
7
|
-
|
|
8
|
-
type BackgroundSize = 'cover' | 'contain' | { width: number; height: number };
|
|
9
|
-
|
|
10
|
-
type BackgroundResult = {
|
|
11
|
-
containerStyle: BaseStyle;
|
|
12
|
-
objectStyle: BaseStyle;
|
|
13
|
-
xml: string | null;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const styles = StyleSheet.create({
|
|
17
|
-
container: { overflow: 'hidden' },
|
|
18
|
-
object: { aspectRatio: 1 },
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const horizontalPositions = {
|
|
22
|
-
left: (offset: number = 0) => ({
|
|
23
|
-
alignItems: I18nManager.isRTL ? 'flex-end' : 'flex-start',
|
|
24
|
-
paddingLeft: offset,
|
|
25
|
-
}),
|
|
26
|
-
right: (offset: number = 0) => ({
|
|
27
|
-
alignItems: I18nManager.isRTL ? 'flex-start' : 'flex-end',
|
|
28
|
-
paddingRight: offset,
|
|
29
|
-
}),
|
|
30
|
-
center: (offset?: number) => {
|
|
31
|
-
if (offset !== undefined) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
alignItems: 'center',
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
top: undefined,
|
|
40
|
-
bottom: undefined,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const verticalPositions = {
|
|
44
|
-
top: (offset: number = 0) => ({
|
|
45
|
-
justifyContent: 'flex-start',
|
|
46
|
-
paddingTop: offset,
|
|
47
|
-
}),
|
|
48
|
-
bottom: (offset: number = 0) => ({
|
|
49
|
-
justifyContent: 'flex-end',
|
|
50
|
-
paddingBottom: offset,
|
|
51
|
-
}),
|
|
52
|
-
center: (offset?: number) => {
|
|
53
|
-
if (offset !== undefined) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
justifyContent: 'center',
|
|
59
|
-
};
|
|
60
|
-
},
|
|
61
|
-
left: undefined,
|
|
62
|
-
right: undefined,
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const getXml = (value: string) => {
|
|
66
|
-
const match = value.match(/^url\("data:image\/svg\+xml,(.*?)"\)$/);
|
|
67
|
-
|
|
68
|
-
if (!match) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return decodeURIComponent(match[1]);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const transforms = {
|
|
76
|
-
backgroundSize(value: BackgroundSize) {
|
|
77
|
-
if (value === 'cover') {
|
|
78
|
-
return {
|
|
79
|
-
width: '100%',
|
|
80
|
-
// TODO: Support cover for views with height > width.
|
|
81
|
-
// height: '100%',
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (value === 'contain') {
|
|
86
|
-
return {
|
|
87
|
-
width: '100%',
|
|
88
|
-
height: '100%',
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const { width, height = width } = value;
|
|
93
|
-
|
|
94
|
-
return {
|
|
95
|
-
width,
|
|
96
|
-
height,
|
|
97
|
-
};
|
|
98
|
-
},
|
|
99
|
-
backgroundPosition(value: Position) {
|
|
100
|
-
if (value === 'center') {
|
|
101
|
-
return {
|
|
102
|
-
alignItems: 'center',
|
|
103
|
-
justifyContent: 'center',
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const horizontalPosition = horizontalPositions[value];
|
|
108
|
-
|
|
109
|
-
if (horizontalPosition !== undefined) {
|
|
110
|
-
return {
|
|
111
|
-
...horizontalPosition(),
|
|
112
|
-
justifyContent: 'center',
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const verticalPosition = verticalPositions[value];
|
|
117
|
-
|
|
118
|
-
if (verticalPosition) {
|
|
119
|
-
return {
|
|
120
|
-
alignItems: 'center',
|
|
121
|
-
...verticalPosition(),
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return null;
|
|
126
|
-
},
|
|
127
|
-
backgroundPositionX(
|
|
128
|
-
value: Position | { position: Position; offset: number },
|
|
129
|
-
) {
|
|
130
|
-
const { position = 'left', offset } =
|
|
131
|
-
typeof value === 'object'
|
|
132
|
-
? value
|
|
133
|
-
: { position: value, offset: undefined };
|
|
134
|
-
|
|
135
|
-
const horizontalPosition = horizontalPositions[position];
|
|
136
|
-
|
|
137
|
-
if (!horizontalPosition) {
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return horizontalPosition(offset);
|
|
142
|
-
},
|
|
143
|
-
backgroundPositionY(
|
|
144
|
-
value: Position | { position: Position; offset: number },
|
|
145
|
-
) {
|
|
146
|
-
const { position = 'top', offset } =
|
|
147
|
-
typeof value === 'object'
|
|
148
|
-
? value
|
|
149
|
-
: { position: value, offset: undefined };
|
|
150
|
-
|
|
151
|
-
const verticalPosition = verticalPositions[position];
|
|
152
|
-
|
|
153
|
-
if (!verticalPosition) {
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return verticalPosition(offset);
|
|
158
|
-
},
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
export default function useBackgroundNative(style: BaseStyle[]) {
|
|
162
|
-
const flattenedStyle = StyleSheet.flatten(style);
|
|
163
|
-
|
|
164
|
-
const background: BackgroundResult = {
|
|
165
|
-
containerStyle: {},
|
|
166
|
-
objectStyle: {},
|
|
167
|
-
xml: null,
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
Object.entries(flattenedStyle).forEach(([key, value]) => {
|
|
171
|
-
if (!value) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (key === 'backgroundImage') {
|
|
176
|
-
background.xml = getXml(value);
|
|
177
|
-
} else if (key === 'backgroundSize') {
|
|
178
|
-
Object.assign(background.objectStyle, transforms[key](value));
|
|
179
|
-
} else if (
|
|
180
|
-
key === 'backgroundPosition' ||
|
|
181
|
-
key === 'backgroundPositionX' ||
|
|
182
|
-
key === 'backgroundPositionY'
|
|
183
|
-
) {
|
|
184
|
-
Object.assign(background.containerStyle, transforms[key](value));
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
return {
|
|
189
|
-
style: flattenedStyle,
|
|
190
|
-
element: (
|
|
191
|
-
<View
|
|
192
|
-
style={[
|
|
193
|
-
StyleSheet.absoluteFill,
|
|
194
|
-
styles.container,
|
|
195
|
-
background.containerStyle,
|
|
196
|
-
]}
|
|
197
|
-
>
|
|
198
|
-
<View style={[styles.object, background.objectStyle]}>
|
|
199
|
-
{background.xml && <SvgXml xml={background.xml} />}
|
|
200
|
-
</View>
|
|
201
|
-
</View>
|
|
202
|
-
),
|
|
203
|
-
};
|
|
204
|
-
}
|