bootstrap-rn 0.3.4 → 0.3.5
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/commonjs/components/Image.js.map +1 -1
- package/lib/commonjs/components/ImageBackground.js.map +1 -1
- package/lib/commonjs/components/Text.js.map +1 -1
- package/lib/commonjs/components/dropdown/DropdownMenu.js.map +1 -1
- package/lib/commonjs/components/modal/ModalContext.js.map +1 -1
- package/lib/commonjs/components/nav/Nav.js.map +1 -1
- package/lib/commonjs/components/nav/NavContext.js.map +1 -1
- package/lib/commonjs/components/nav/TabContext.js.map +1 -1
- package/lib/commonjs/components/navbar/NavbarContext.js.map +1 -1
- package/lib/commonjs/components/offcanvas/OffcanvasContext.js.map +1 -1
- package/lib/commonjs/components/popover/injectPopover.js.map +1 -1
- package/lib/commonjs/components/toasts/ToastContainer.js +3 -1
- package/lib/commonjs/components/toasts/ToastContainer.js.map +1 -1
- package/lib/commonjs/components/tooltip/injectTooltip.js +0 -3
- package/lib/commonjs/components/tooltip/injectTooltip.js.map +1 -1
- package/lib/commonjs/index.d.ts +47 -8
- package/lib/commonjs/index.js +0 -56
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/style/StyleSheet.js +4 -2
- package/lib/commonjs/style/StyleSheet.js.map +1 -1
- package/lib/commonjs/types.d.ts +6 -3
- package/lib/module/components/Image.js.map +1 -1
- package/lib/module/components/ImageBackground.js.map +1 -1
- package/lib/module/components/Text.js.map +1 -1
- package/lib/module/components/dropdown/DropdownMenu.js.map +1 -1
- package/lib/module/components/modal/ModalContext.js.map +1 -1
- package/lib/module/components/nav/Nav.js.map +1 -1
- package/lib/module/components/nav/NavContext.js.map +1 -1
- package/lib/module/components/nav/TabContext.js.map +1 -1
- package/lib/module/components/navbar/NavbarContext.js.map +1 -1
- package/lib/module/components/offcanvas/OffcanvasContext.js.map +1 -1
- package/lib/module/components/popover/injectPopover.js.map +1 -1
- package/lib/module/components/toasts/ToastContainer.js +3 -1
- package/lib/module/components/toasts/ToastContainer.js.map +1 -1
- package/lib/module/components/tooltip/injectTooltip.js +0 -3
- package/lib/module/components/tooltip/injectTooltip.js.map +1 -1
- package/lib/module/index.d.ts +47 -8
- package/lib/module/index.js +0 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/style/StyleSheet.js +4 -2
- package/lib/module/style/StyleSheet.js.map +1 -1
- package/lib/module/types.d.ts +6 -3
- package/lib/types/components/Image.d.ts.map +1 -1
- package/lib/types/components/ImageBackground.d.ts.map +1 -1
- package/lib/types/components/Text.d.ts +1 -1
- package/lib/types/components/Text.d.ts.map +1 -1
- package/lib/types/components/dropdown/Dropdown.d.ts +2 -11
- package/lib/types/components/dropdown/Dropdown.d.ts.map +1 -1
- package/lib/types/components/dropdown/DropdownContext.d.ts +2 -2
- package/lib/types/components/dropdown/DropdownContext.d.ts.map +1 -1
- package/lib/types/components/dropdown/DropdownMenu.d.ts +2 -2
- package/lib/types/components/dropdown/DropdownMenu.d.ts.map +1 -1
- package/lib/types/components/dropdown/DropdownToggle.d.ts +2 -2
- package/lib/types/components/dropdown/DropdownToggle.d.ts.map +1 -1
- package/lib/types/components/list-group/ListGroup.d.ts +1 -1
- package/lib/types/components/list-group/ListGroupItem.d.ts +13 -1
- package/lib/types/components/list-group/ListGroupItem.d.ts.map +1 -1
- package/lib/types/components/list-group/ListGroupItemAction.d.ts +2 -2
- package/lib/types/components/list-group/ListGroupItemAction.d.ts.map +1 -1
- package/lib/types/components/modal/Modal.d.ts +1 -3
- package/lib/types/components/modal/Modal.d.ts.map +1 -1
- package/lib/types/components/modal/ModalContext.d.ts +3 -3
- package/lib/types/components/modal/ModalContext.d.ts.map +1 -1
- package/lib/types/components/nav/Nav.d.ts +1 -3
- package/lib/types/components/nav/Nav.d.ts.map +1 -1
- package/lib/types/components/nav/NavContext.d.ts +3 -3
- package/lib/types/components/nav/NavContext.d.ts.map +1 -1
- package/lib/types/components/nav/Tab.d.ts +1 -1
- package/lib/types/components/nav/TabContext.d.ts +3 -3
- package/lib/types/components/nav/TabContext.d.ts.map +1 -1
- package/lib/types/components/navbar/Navbar.d.ts +1 -1
- package/lib/types/components/navbar/NavbarBrand.d.ts +2 -2
- package/lib/types/components/navbar/NavbarBrand.d.ts.map +1 -1
- package/lib/types/components/navbar/NavbarContext.d.ts +2 -2
- package/lib/types/components/navbar/NavbarContext.d.ts.map +1 -1
- package/lib/types/components/offcanvas/Offcanvas.d.ts +1 -3
- package/lib/types/components/offcanvas/Offcanvas.d.ts.map +1 -1
- package/lib/types/components/offcanvas/OffcanvasContext.d.ts +2 -2
- package/lib/types/components/offcanvas/OffcanvasContext.d.ts.map +1 -1
- package/lib/types/components/popover/injectPopover.d.ts +9 -12
- package/lib/types/components/popover/injectPopover.d.ts.map +1 -1
- package/lib/types/components/toasts/ToastContainer.d.ts +4 -2
- package/lib/types/components/toasts/ToastContainer.d.ts.map +1 -1
- package/lib/types/components/tooltip/injectTooltip.d.ts +8 -11
- package/lib/types/components/tooltip/injectTooltip.d.ts.map +1 -1
- package/lib/types/hooks/useBackground.native.d.ts +3 -1
- package/lib/types/hooks/useBackground.native.d.ts.map +1 -1
- package/lib/types/index.d.ts +47 -8
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/style/StyleSheet.d.ts +2 -3
- package/lib/types/style/StyleSheet.d.ts.map +1 -1
- package/lib/types/style/createStyle.d.ts +3 -1
- package/lib/types/style/createStyle.d.ts.map +1 -1
- package/lib/types/style/css.d.ts +3 -1
- package/lib/types/style/css.d.ts.map +1 -1
- package/lib/types/theme/variables.d.ts +3 -1
- package/lib/types/theme/variables.d.ts.map +1 -1
- package/lib/types/types.d.ts +6 -3
- package/lib/types/types.d.ts.map +1 -1
- package/package.json +80 -80
- package/src/components/Image.tsx +31 -27
- package/src/components/ImageBackground.tsx +48 -46
- package/src/components/Text.tsx +119 -117
- package/src/components/dropdown/DropdownContext.ts +2 -2
- package/src/components/dropdown/DropdownMenu.tsx +127 -125
- package/src/components/dropdown/DropdownToggle.ts +2 -2
- package/src/components/list-group/ListGroupItemAction.tsx +2 -2
- package/src/components/modal/ModalContext.ts +3 -3
- package/src/components/nav/Nav.tsx +4 -4
- package/src/components/nav/NavContext.ts +3 -3
- package/src/components/nav/TabContext.ts +3 -3
- package/src/components/navbar/NavbarBrand.tsx +2 -2
- package/src/components/navbar/NavbarContext.ts +2 -2
- package/src/components/offcanvas/OffcanvasContext.ts +4 -2
- package/src/components/popover/injectPopover.tsx +97 -98
- package/src/components/toasts/ToastContainer.tsx +41 -39
- package/src/components/tooltip/injectTooltip.tsx +93 -96
- package/src/index.ts +242 -211
- package/src/style/StyleSheet.ts +149 -138
- package/src/types.ts +168 -162
package/src/style/StyleSheet.ts
CHANGED
|
@@ -1,138 +1,149 @@
|
|
|
1
|
-
import { StyleSheet as BaseStyleSheet } from 'react-native';
|
|
2
|
-
import type { ExtendedStyle, BaseStyle, ThemeVariables } from '../types';
|
|
3
|
-
|
|
4
|
-
type
|
|
5
|
-
string
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
1
|
+
import { StyleSheet as BaseStyleSheet } from 'react-native';
|
|
2
|
+
import type { ExtendedStyle, BaseStyle, ThemeVariables } from '../types';
|
|
3
|
+
|
|
4
|
+
type StyleSourceEntry =
|
|
5
|
+
| ((theme: object, key: string) => ExtendedStyle)
|
|
6
|
+
| ExtendedStyle;
|
|
7
|
+
|
|
8
|
+
type NamedExtendedStyles<T extends string> = {
|
|
9
|
+
[K in T]: ExtendedStyle;
|
|
10
|
+
};
|
|
11
|
+
type NamedStyles<T extends string> = {
|
|
12
|
+
[K in T]: BaseStyle;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type StyleSheetDefinition<T extends string> = {
|
|
16
|
+
source: {
|
|
17
|
+
[K in T]: StyleSourceEntry;
|
|
18
|
+
};
|
|
19
|
+
cache: Record<string, NamedExtendedStyles<T>>;
|
|
20
|
+
active: NamedExtendedStyles<T>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
let activeKey: string | null = null;
|
|
24
|
+
|
|
25
|
+
const themes: Record<string, ThemeVariables> = {};
|
|
26
|
+
const sheets: StyleSheetDefinition<string>[] = [];
|
|
27
|
+
|
|
28
|
+
const createSheet = <T extends string>(
|
|
29
|
+
sheet: StyleSheetDefinition<T>,
|
|
30
|
+
): NamedExtendedStyles<T> => {
|
|
31
|
+
if (!activeKey) {
|
|
32
|
+
throw new Error('No active theme key.');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const theme = themes[activeKey];
|
|
36
|
+
|
|
37
|
+
const statelessSource: Partial<NamedStyles<T>> = {};
|
|
38
|
+
const statefulSource: Partial<NamedExtendedStyles<T>> = {};
|
|
39
|
+
|
|
40
|
+
// Apply theme to themeable styles.
|
|
41
|
+
Object.entries(sheet.source).forEach(([key, style]) => {
|
|
42
|
+
// Resolve theme.
|
|
43
|
+
const value = typeof style === 'function' ? style(theme, activeKey) : style;
|
|
44
|
+
|
|
45
|
+
if (typeof value === 'function') {
|
|
46
|
+
statefulSource[key as T] = value;
|
|
47
|
+
} else {
|
|
48
|
+
statelessSource[key as T] = value as BaseStyle;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Wrap stateful and stateless in a proxy, so that we can update the styles on theme change.
|
|
53
|
+
// For using Object.assign below we need some additional methods on the proxy that are mentioned here:
|
|
54
|
+
// https://stackoverflow.com/questions/43185453/object-assign-and-proxies
|
|
55
|
+
return new Proxy(
|
|
56
|
+
{
|
|
57
|
+
keys: Object.keys(sheet.source),
|
|
58
|
+
stateless: BaseStyleSheet.create(statelessSource as NamedStyles<string>),
|
|
59
|
+
stateful: statefulSource,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
get(target, prop: T) {
|
|
63
|
+
return target.stateless[prop] || target.stateful[prop] || undefined;
|
|
64
|
+
},
|
|
65
|
+
ownKeys: (target) => target.keys,
|
|
66
|
+
getOwnPropertyDescriptor(target, name: string) {
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
68
|
+
const proxy = this;
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
get value() {
|
|
72
|
+
return proxy.get(target, name);
|
|
73
|
+
},
|
|
74
|
+
configurable: true,
|
|
75
|
+
enumerable: true,
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
has: (target, name: string) => target.keys.indexOf(name) >= 0,
|
|
79
|
+
},
|
|
80
|
+
) as NamedExtendedStyles<T>;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const { absoluteFill, absoluteFillObject, hairlineWidth } = BaseStyleSheet;
|
|
84
|
+
|
|
85
|
+
const StyleSheet = {
|
|
86
|
+
create<T extends string>(source: { [K in T]: StyleSourceEntry }): {
|
|
87
|
+
[K in T]: ExtendedStyle;
|
|
88
|
+
} {
|
|
89
|
+
// Create sheet object.
|
|
90
|
+
const sheet: StyleSheetDefinition<T> = {
|
|
91
|
+
source,
|
|
92
|
+
cache: {},
|
|
93
|
+
// @ts-expect-error Placeholder until build method is called.
|
|
94
|
+
active: {},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// If initialized, set active sheet based by active theme.
|
|
98
|
+
if (activeKey !== null) {
|
|
99
|
+
sheet.cache[activeKey] = createSheet(sheet);
|
|
100
|
+
sheet.active = sheet.cache[activeKey];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
sheets.push(sheet);
|
|
104
|
+
|
|
105
|
+
return sheet.active;
|
|
106
|
+
},
|
|
107
|
+
build(theme: ThemeVariables, key: string = 'default') {
|
|
108
|
+
if (!themes[key]) {
|
|
109
|
+
themes[key] = theme;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// If theme is already set, we don't need to do anything.
|
|
113
|
+
if (key === activeKey) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Set new theme active.
|
|
118
|
+
activeKey = key;
|
|
119
|
+
|
|
120
|
+
// Update style sheets.
|
|
121
|
+
sheets.forEach((_, i) => {
|
|
122
|
+
// If there is no result for the active theme, we'll create a themed
|
|
123
|
+
// style sheet.
|
|
124
|
+
if (!sheets[i].cache[key]) {
|
|
125
|
+
sheets[i].cache[key] = createSheet(sheets[i]);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Assign active object, which is also returned from the create
|
|
129
|
+
// function, so style changes will be applied on next rerender in
|
|
130
|
+
// the components as well.
|
|
131
|
+
Object.assign(sheets[i].active, sheets[i].cache[key]);
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
value(key: keyof ThemeVariables) {
|
|
135
|
+
if (activeKey === null) {
|
|
136
|
+
throw new Error('Use of StyleSheet.value() before initializing.');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const theme = themes[activeKey];
|
|
140
|
+
|
|
141
|
+
return theme[key];
|
|
142
|
+
},
|
|
143
|
+
// Add default styles from StyleSheet
|
|
144
|
+
absoluteFill,
|
|
145
|
+
absoluteFillObject,
|
|
146
|
+
hairlineWidth,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export default StyleSheet;
|
package/src/types.ts
CHANGED
|
@@ -1,162 +1,168 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ViewStyle as BaseViewStyle,
|
|
3
|
-
ImageStyle as
|
|
4
|
-
TextStyle as BaseTextStyle,
|
|
5
|
-
GestureResponderEvent,
|
|
6
|
-
Role,
|
|
7
|
-
NativeSyntheticEvent,
|
|
8
|
-
TextInputKeyPressEventData,
|
|
9
|
-
} from 'react-native';
|
|
10
|
-
import type { Placement, Axis, PlacementAxis } from '@react-types/overlays';
|
|
11
|
-
import { BOOTSTRAP_RN_STYLE } from './style/createStyle';
|
|
12
|
-
|
|
13
|
-
// Media
|
|
14
|
-
|
|
15
|
-
export type Viewport = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
|
16
|
-
|
|
17
|
-
export type MediaHandler = {
|
|
18
|
-
up: (point: Viewport) => boolean;
|
|
19
|
-
down: (point: Viewport) => boolean;
|
|
20
|
-
only: (point: Viewport) => boolean;
|
|
21
|
-
between: (lower: Viewport, upper: Viewport) => boolean;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// Styles
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
60
|
-
export type
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
export type
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
export type
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
| '
|
|
106
|
-
| '
|
|
107
|
-
| '
|
|
108
|
-
| '
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
| '
|
|
114
|
-
| '
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
1
|
+
import {
|
|
2
|
+
ViewStyle as BaseViewStyle,
|
|
3
|
+
ImageStyle as TempImageStyle,
|
|
4
|
+
TextStyle as BaseTextStyle,
|
|
5
|
+
GestureResponderEvent,
|
|
6
|
+
Role,
|
|
7
|
+
NativeSyntheticEvent,
|
|
8
|
+
TextInputKeyPressEventData,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import type { Placement, Axis, PlacementAxis } from '@react-types/overlays';
|
|
11
|
+
import { BOOTSTRAP_RN_STYLE } from './style/createStyle';
|
|
12
|
+
|
|
13
|
+
// Media
|
|
14
|
+
|
|
15
|
+
export type Viewport = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
|
16
|
+
|
|
17
|
+
export type MediaHandler = {
|
|
18
|
+
up: (point: Viewport) => boolean;
|
|
19
|
+
down: (point: Viewport) => boolean;
|
|
20
|
+
only: (point: Viewport) => boolean;
|
|
21
|
+
between: (lower: Viewport, upper: Viewport) => boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Styles
|
|
25
|
+
|
|
26
|
+
// Workaround: Add scroll to possible overflow values of ImageStyle to resolve conflict between
|
|
27
|
+
// ImageStyle and ViewStyle.
|
|
28
|
+
type BaseImageStyle = Omit<TempImageStyle, 'overflow'> & {
|
|
29
|
+
overflow?: 'visible' | 'hidden' | 'scroll';
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type BaseStyle = BaseViewStyle | BaseImageStyle | BaseTextStyle;
|
|
33
|
+
|
|
34
|
+
export type InteractionState = {
|
|
35
|
+
interaction?: {
|
|
36
|
+
hover?: boolean;
|
|
37
|
+
focus: boolean;
|
|
38
|
+
focusVisible: boolean;
|
|
39
|
+
active?: boolean;
|
|
40
|
+
};
|
|
41
|
+
media: MediaHandler;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Ref: https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/StyleSheet/StyleSheet.d.ts
|
|
45
|
+
type Falsy = undefined | null | undefined | false | '';
|
|
46
|
+
interface RecursiveArray<T>
|
|
47
|
+
extends Array<T | ReadonlyArray<T> | RecursiveArray<T>> {}
|
|
48
|
+
type RegisteredStyle<T> = number & { __registeredStyleBrand: T };
|
|
49
|
+
|
|
50
|
+
export type SpecialInteractionStyle<T> = {
|
|
51
|
+
(state: InteractionState): [T[], T[]];
|
|
52
|
+
$$typeof: typeof BOOTSTRAP_RN_STYLE;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type ExtendedStyleType<T> =
|
|
56
|
+
| T
|
|
57
|
+
| SpecialInteractionStyle<T>
|
|
58
|
+
| ((state: InteractionState) => T);
|
|
59
|
+
|
|
60
|
+
export type StyleProp<T> =
|
|
61
|
+
| ExtendedStyleType<T>
|
|
62
|
+
| RegisteredStyle<T>
|
|
63
|
+
| RecursiveArray<ExtendedStyleType<T> | RegisteredStyle<T> | Falsy>
|
|
64
|
+
| Falsy;
|
|
65
|
+
|
|
66
|
+
export type ExtendedViewStyle = ExtendedStyleType<BaseViewStyle>;
|
|
67
|
+
|
|
68
|
+
export type ExtendedImageStyle = ExtendedStyleType<BaseImageStyle>;
|
|
69
|
+
|
|
70
|
+
export type ExtendedTextStyle = ExtendedStyleType<BaseTextStyle>;
|
|
71
|
+
|
|
72
|
+
export type ExtendedStyle =
|
|
73
|
+
| ExtendedViewStyle
|
|
74
|
+
| ExtendedImageStyle
|
|
75
|
+
| ExtendedTextStyle;
|
|
76
|
+
|
|
77
|
+
export type StyleName = string;
|
|
78
|
+
|
|
79
|
+
// Theme
|
|
80
|
+
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
82
|
+
export type StyleValue = any;
|
|
83
|
+
|
|
84
|
+
export type ThemeVariables = {
|
|
85
|
+
[key: string]: StyleValue;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export type StyleUtility = {
|
|
89
|
+
responsive?: boolean;
|
|
90
|
+
print?: boolean;
|
|
91
|
+
rfs?: boolean;
|
|
92
|
+
property: string;
|
|
93
|
+
class?: string;
|
|
94
|
+
values: Record<string, string | ((t: ThemeVariables) => StyleValue)>;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export type FormValidationState = (t: ThemeVariables) => {
|
|
98
|
+
color: string;
|
|
99
|
+
icon: string;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// Overlay
|
|
103
|
+
|
|
104
|
+
export type Trigger =
|
|
105
|
+
| 'press'
|
|
106
|
+
| 'hover'
|
|
107
|
+
| 'focus'
|
|
108
|
+
| 'manual'
|
|
109
|
+
| 'press hover'
|
|
110
|
+
| 'hover press'
|
|
111
|
+
| 'hover focus'
|
|
112
|
+
| 'focus hover'
|
|
113
|
+
| 'press focus'
|
|
114
|
+
| 'focus press';
|
|
115
|
+
|
|
116
|
+
export { Placement, Axis, PlacementAxis };
|
|
117
|
+
|
|
118
|
+
export type TransformedPlacementAxis =
|
|
119
|
+
| 'top'
|
|
120
|
+
| 'bottom'
|
|
121
|
+
| 'end'
|
|
122
|
+
| 'start'
|
|
123
|
+
| 'center';
|
|
124
|
+
|
|
125
|
+
// Modifiers
|
|
126
|
+
|
|
127
|
+
// TODO: Modifiers can have different props based on the implementation. It would be better to define modifiers on the application.
|
|
128
|
+
|
|
129
|
+
type To =
|
|
130
|
+
| string
|
|
131
|
+
| Partial<{
|
|
132
|
+
pathname: string;
|
|
133
|
+
search: string;
|
|
134
|
+
hash: string;
|
|
135
|
+
}>;
|
|
136
|
+
|
|
137
|
+
type External =
|
|
138
|
+
| boolean
|
|
139
|
+
| Partial<{
|
|
140
|
+
download: boolean;
|
|
141
|
+
target: string;
|
|
142
|
+
rel: string;
|
|
143
|
+
}>;
|
|
144
|
+
|
|
145
|
+
export type UseTabbableProps = {
|
|
146
|
+
to?: To;
|
|
147
|
+
external?: External;
|
|
148
|
+
end?: boolean;
|
|
149
|
+
caseSensitive?: boolean;
|
|
150
|
+
active?: boolean;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export type UseActionableProps = {
|
|
154
|
+
to?: To;
|
|
155
|
+
external?: External;
|
|
156
|
+
relative?: 'path' | 'route';
|
|
157
|
+
replace?: boolean;
|
|
158
|
+
preventScrollReset?: boolean;
|
|
159
|
+
reloadDocument?: boolean;
|
|
160
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
161
|
+
state?: any;
|
|
162
|
+
onPress?: null | ((event: GestureResponderEvent) => void);
|
|
163
|
+
role?: Role;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export type UseFormFieldProps = {
|
|
167
|
+
onKeyPress?: (e: NativeSyntheticEvent<TextInputKeyPressEventData>) => void;
|
|
168
|
+
};
|