bootstrap-rn 0.3.4 → 0.3.6
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/forms/RadioGroup.js.map +1 -1
- package/lib/commonjs/components/forms/internals/PickerNative.js.map +1 -1
- package/lib/commonjs/components/modal/Modal.js +1 -1
- package/lib/commonjs/components/modal/Modal.js.map +1 -1
- package/lib/commonjs/components/modal/ModalBody.js +1 -1
- package/lib/commonjs/components/modal/ModalBody.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/OffcanvasBody.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/style/makeUtilities.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/forms/RadioGroup.js.map +1 -1
- package/lib/module/components/forms/internals/PickerNative.js.map +1 -1
- package/lib/module/components/modal/Modal.js +1 -1
- package/lib/module/components/modal/Modal.js.map +1 -1
- package/lib/module/components/modal/ModalBody.js +1 -1
- package/lib/module/components/modal/ModalBody.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/OffcanvasBody.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/style/makeUtilities.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/forms/Picker.d.ts +4 -4
- package/lib/types/components/forms/Picker.d.ts.map +1 -1
- package/lib/types/components/forms/PickerItem.d.ts +1 -1
- package/lib/types/components/forms/PickerItem.d.ts.map +1 -1
- package/lib/types/components/forms/Radio.d.ts +1 -1
- package/lib/types/components/forms/Radio.d.ts.map +1 -1
- package/lib/types/components/forms/RadioContext.d.ts +2 -2
- package/lib/types/components/forms/RadioContext.d.ts.map +1 -1
- package/lib/types/components/forms/RadioGroup.d.ts +2 -2
- package/lib/types/components/forms/RadioGroup.d.ts.map +1 -1
- package/lib/types/components/forms/internals/PickerNative.d.ts.map +1 -1
- package/lib/types/components/forms/internals/PickerNativeContext.d.ts +2 -2
- package/lib/types/components/forms/internals/PickerNativeContext.d.ts.map +1 -1
- package/lib/types/components/forms/internals/PickerNativeItem.d.ts +1 -1
- package/lib/types/components/forms/internals/PickerNativeItem.d.ts.map +1 -1
- package/lib/types/components/forms/internals/PickerWebItem.d.ts +1 -1
- package/lib/types/components/forms/internals/PickerWebItem.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 +4 -7
- package/lib/types/components/modal/Modal.d.ts.map +1 -1
- package/lib/types/components/modal/ModalBody.d.ts +3 -6
- package/lib/types/components/modal/ModalBody.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/OffcanvasBody.d.ts +3 -4
- package/lib/types/components/offcanvas/OffcanvasBody.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/style/makeUtilities.d.ts +6 -2
- package/lib/types/style/makeUtilities.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/forms/Picker.tsx +191 -191
- package/src/components/forms/PickerItem.tsx +32 -32
- package/src/components/forms/Radio.tsx +37 -37
- package/src/components/forms/RadioContext.ts +13 -13
- package/src/components/forms/RadioGroup.tsx +42 -40
- package/src/components/forms/internals/PickerNative.tsx +193 -195
- package/src/components/forms/internals/PickerNativeContext.ts +14 -14
- package/src/components/forms/internals/PickerNativeItem.tsx +59 -59
- package/src/components/forms/internals/PickerWebItem.tsx +36 -36
- package/src/components/list-group/ListGroupItemAction.tsx +2 -2
- package/src/components/modal/Modal.tsx +234 -233
- package/src/components/modal/ModalBody.tsx +52 -56
- 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/OffcanvasBody.tsx +64 -66
- 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/style/makeUtilities.ts +79 -76
- package/src/types.ts +168 -162
package/src/components/Text.tsx
CHANGED
|
@@ -1,117 +1,119 @@
|
|
|
1
|
-
import React, { useContext, useMemo } from 'react';
|
|
2
|
-
import { Text as BaseText, TextProps as BaseTextProps } from 'react-native';
|
|
3
|
-
import StyleSheet from '../style/StyleSheet';
|
|
4
|
-
import css from '../style/css';
|
|
5
|
-
import useMedia from '../hooks/useMedia';
|
|
6
|
-
import TextStyleContext from '../style/TextStyleContext';
|
|
7
|
-
import { getStyles } from '../utils';
|
|
8
|
-
import { THEME_COLORS } from '../theme/proxies';
|
|
9
|
-
import useStyle from '../hooks/useStyle';
|
|
10
|
-
import type { ExtendedTextStyle, StyleProp, StyleName } from '../types';
|
|
11
|
-
|
|
12
|
-
export type TextRef = BaseText;
|
|
13
|
-
|
|
14
|
-
type ThemeColors =
|
|
15
|
-
| keyof typeof THEME_COLORS
|
|
16
|
-
| '
|
|
17
|
-
| '
|
|
18
|
-
| 'white
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
font-
|
|
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
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
style,
|
|
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
|
-
|
|
1
|
+
import React, { useContext, useMemo } from 'react';
|
|
2
|
+
import { Text as BaseText, TextProps as BaseTextProps } from 'react-native';
|
|
3
|
+
import StyleSheet from '../style/StyleSheet';
|
|
4
|
+
import css from '../style/css';
|
|
5
|
+
import useMedia from '../hooks/useMedia';
|
|
6
|
+
import TextStyleContext from '../style/TextStyleContext';
|
|
7
|
+
import { getStyles } from '../utils';
|
|
8
|
+
import { THEME_COLORS } from '../theme/proxies';
|
|
9
|
+
import useStyle from '../hooks/useStyle';
|
|
10
|
+
import type { ExtendedTextStyle, StyleProp, StyleName } from '../types';
|
|
11
|
+
|
|
12
|
+
export type TextRef = BaseText;
|
|
13
|
+
|
|
14
|
+
type ThemeColors =
|
|
15
|
+
| keyof typeof THEME_COLORS
|
|
16
|
+
| 'body'
|
|
17
|
+
| 'muted'
|
|
18
|
+
| 'white'
|
|
19
|
+
| 'black-50'
|
|
20
|
+
| 'white-50';
|
|
21
|
+
|
|
22
|
+
export interface TextProps extends Omit<BaseTextProps, 'style'> {
|
|
23
|
+
color?: ThemeColors;
|
|
24
|
+
small?: boolean;
|
|
25
|
+
mark?: boolean;
|
|
26
|
+
bold?: boolean;
|
|
27
|
+
italic?: boolean;
|
|
28
|
+
style?: StyleProp<ExtendedTextStyle>;
|
|
29
|
+
styleName?: StyleName;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const styles = StyleSheet.create({
|
|
33
|
+
text: css`
|
|
34
|
+
font-family: $font-family-base;
|
|
35
|
+
font-size: $font-size-base;
|
|
36
|
+
font-weight: $font-weight-base;
|
|
37
|
+
line-height: $font-size-base * $line-height-base;
|
|
38
|
+
`,
|
|
39
|
+
strong: css`
|
|
40
|
+
font-weight: $font-weight-bolder;
|
|
41
|
+
`,
|
|
42
|
+
italic: css`
|
|
43
|
+
font-style: italic;
|
|
44
|
+
`,
|
|
45
|
+
small: css`
|
|
46
|
+
font-size: $small-font-size;
|
|
47
|
+
line-height: $small-font-size * $line-height-base;
|
|
48
|
+
`,
|
|
49
|
+
mark: css`
|
|
50
|
+
padding: $mark-padding;
|
|
51
|
+
background-color: $mark-bg;
|
|
52
|
+
`,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const getStyleName = (styleName?: StyleName, color?: ThemeColors) => {
|
|
56
|
+
if (!color) {
|
|
57
|
+
return styleName;
|
|
58
|
+
}
|
|
59
|
+
return styleName ? `text-${color} ${styleName}` : `text-${color}`;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const Text = React.forwardRef<TextRef, TextProps>((props, ref) => {
|
|
63
|
+
const {
|
|
64
|
+
color, // will be deprecated soon
|
|
65
|
+
bold = false,
|
|
66
|
+
italic = false,
|
|
67
|
+
mark = false,
|
|
68
|
+
small = false,
|
|
69
|
+
style,
|
|
70
|
+
styleName,
|
|
71
|
+
...elementProps
|
|
72
|
+
} = props;
|
|
73
|
+
|
|
74
|
+
const media = useMedia();
|
|
75
|
+
const context = useContext(TextStyleContext);
|
|
76
|
+
|
|
77
|
+
const classes = getStyles(styles, [
|
|
78
|
+
bold && 'strong',
|
|
79
|
+
italic && 'italic',
|
|
80
|
+
small && 'small',
|
|
81
|
+
mark && 'mark',
|
|
82
|
+
]);
|
|
83
|
+
|
|
84
|
+
const resolveStyle = useStyle(
|
|
85
|
+
[
|
|
86
|
+
(!context || !context.hasTextAncestor) && styles.text,
|
|
87
|
+
context && context.style,
|
|
88
|
+
classes,
|
|
89
|
+
style,
|
|
90
|
+
],
|
|
91
|
+
getStyleName(styleName, color),
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const contextValue = useMemo(
|
|
95
|
+
() => ({
|
|
96
|
+
style: null,
|
|
97
|
+
hasTextAncestor: true,
|
|
98
|
+
}),
|
|
99
|
+
[],
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const element = (
|
|
103
|
+
<BaseText {...elementProps} ref={ref} style={resolveStyle({ media })} />
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
if (context && context.hasTextAncestor && !context.style) {
|
|
107
|
+
return element;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<TextStyleContext.Provider value={contextValue}>
|
|
112
|
+
{element}
|
|
113
|
+
</TextStyleContext.Provider>
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
Text.displayName = 'Text';
|
|
118
|
+
|
|
119
|
+
export default Text;
|
|
@@ -3,7 +3,7 @@ import type { ViewRef } from '../View';
|
|
|
3
3
|
|
|
4
4
|
export type DropdownDirection = 'up' | 'down' | 'start' | 'end';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
export interface DropdownContextProps {
|
|
7
7
|
identifier: string;
|
|
8
8
|
visible: boolean;
|
|
9
9
|
setVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
|
@@ -12,7 +12,7 @@ type DropdownContextProps = {
|
|
|
12
12
|
center: boolean;
|
|
13
13
|
display: string;
|
|
14
14
|
autoClose: string | boolean;
|
|
15
|
-
}
|
|
15
|
+
}
|
|
16
16
|
|
|
17
17
|
const DropdownContext = createContext<DropdownContextProps | null>(null);
|
|
18
18
|
|
|
@@ -18,7 +18,7 @@ import type { MediaHandler, Placement } from '../../types';
|
|
|
18
18
|
|
|
19
19
|
type AlignmentBreakpoints = boolean | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
|
20
20
|
|
|
21
|
-
export interface
|
|
21
|
+
export interface DropdownMenuProps extends ViewProps {
|
|
22
22
|
start?: AlignmentBreakpoints;
|
|
23
23
|
right?: AlignmentBreakpoints;
|
|
24
24
|
end?: AlignmentBreakpoints;
|
|
@@ -137,145 +137,147 @@ const transformPlacement = (
|
|
|
137
137
|
return `${direction} top`;
|
|
138
138
|
};
|
|
139
139
|
|
|
140
|
-
const DropdownMenu = React.forwardRef<ViewRef,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
140
|
+
const DropdownMenu = React.forwardRef<ViewRef, DropdownMenuProps>(
|
|
141
|
+
(props, ref) => {
|
|
142
|
+
const {
|
|
143
|
+
children,
|
|
144
|
+
start = true,
|
|
145
|
+
right,
|
|
146
|
+
end = false,
|
|
147
|
+
style,
|
|
148
|
+
textStyle,
|
|
149
|
+
...elementProps
|
|
150
|
+
} = props;
|
|
150
151
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const navbar = useContext(NavbarContext);
|
|
157
|
-
const media = useMedia();
|
|
158
|
-
const dialogRef = useRef(null);
|
|
152
|
+
if (right !== undefined) {
|
|
153
|
+
// eslint-disable-next-line no-console
|
|
154
|
+
console.warn('Prop "right" is deprecated, please use "end" instead.');
|
|
155
|
+
}
|
|
159
156
|
|
|
160
|
-
|
|
157
|
+
const navbar = useContext(NavbarContext);
|
|
158
|
+
const media = useMedia();
|
|
159
|
+
const dialogRef = useRef(null);
|
|
161
160
|
|
|
162
|
-
|
|
163
|
-
identifier,
|
|
164
|
-
toggleRef,
|
|
165
|
-
visible,
|
|
166
|
-
setVisible,
|
|
167
|
-
direction,
|
|
168
|
-
display,
|
|
169
|
-
autoClose,
|
|
170
|
-
} = dropdown;
|
|
161
|
+
const dropdown = useForcedContext(DropdownContext);
|
|
171
162
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
163
|
+
const {
|
|
164
|
+
identifier,
|
|
165
|
+
toggleRef,
|
|
166
|
+
visible,
|
|
167
|
+
setVisible,
|
|
168
|
+
direction,
|
|
169
|
+
display,
|
|
170
|
+
autoClose,
|
|
171
|
+
} = dropdown;
|
|
175
172
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
!(navbar.expand && (navbar.expand === true || media.up(navbar.expand)));
|
|
180
|
-
const hasStaticStyle = isStatic && !isCollapsedNavbar;
|
|
173
|
+
if (!visible) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
181
176
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
hasStaticStyle &&
|
|
187
|
-
start &&
|
|
188
|
-
`.dropdown-menu${
|
|
189
|
-
start === true ? '' : `-${start}`
|
|
190
|
-
}-start[data-bs-popper]`,
|
|
191
|
-
hasStaticStyle &&
|
|
192
|
-
end &&
|
|
193
|
-
`.dropdown-menu${end === true ? '' : `-${end}`}-end[data-bs-popper]`,
|
|
194
|
-
hasStaticStyle &&
|
|
195
|
-
direction === 'up' &&
|
|
196
|
-
'.dropup .dropdown-menu[data-bs-popper]',
|
|
197
|
-
hasStaticStyle &&
|
|
198
|
-
direction === 'end' &&
|
|
199
|
-
'.dropend .dropdown-menu[data-bs-popper]',
|
|
200
|
-
hasStaticStyle &&
|
|
201
|
-
direction === 'start' &&
|
|
202
|
-
'.dropstart .dropdown-menu[data-bs-popper]',
|
|
203
|
-
// Navbar styles
|
|
204
|
-
navbar && '.navbar-nav .dropdown-menu',
|
|
205
|
-
navbar &&
|
|
206
|
-
navbar.expand &&
|
|
207
|
-
`.navbar-expand${
|
|
208
|
-
navbar.expand === true ? '' : `-${navbar.expand}`
|
|
209
|
-
} .navbar-nav .dropdown-menu`,
|
|
210
|
-
]);
|
|
211
|
-
const textClasses = getStyles(styles, ['.dropdown-menu --text']);
|
|
177
|
+
const isStatic = Platform.OS === 'web' && display === 'static';
|
|
178
|
+
const isCollapsedNavbar =
|
|
179
|
+
navbar &&
|
|
180
|
+
!(navbar.expand && (navbar.expand === true || media.up(navbar.expand)));
|
|
181
|
+
const hasStaticStyle = isStatic && !isCollapsedNavbar;
|
|
212
182
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
183
|
+
const classes = getStyles(styles, [
|
|
184
|
+
'.dropdown-menu',
|
|
185
|
+
// Non-Popper styles
|
|
186
|
+
hasStaticStyle && '.dropdown-menu[data-bs-popper]',
|
|
187
|
+
hasStaticStyle &&
|
|
188
|
+
start &&
|
|
189
|
+
`.dropdown-menu${
|
|
190
|
+
start === true ? '' : `-${start}`
|
|
191
|
+
}-start[data-bs-popper]`,
|
|
192
|
+
hasStaticStyle &&
|
|
193
|
+
end &&
|
|
194
|
+
`.dropdown-menu${end === true ? '' : `-${end}`}-end[data-bs-popper]`,
|
|
195
|
+
hasStaticStyle &&
|
|
196
|
+
direction === 'up' &&
|
|
197
|
+
'.dropup .dropdown-menu[data-bs-popper]',
|
|
198
|
+
hasStaticStyle &&
|
|
199
|
+
direction === 'end' &&
|
|
200
|
+
'.dropend .dropdown-menu[data-bs-popper]',
|
|
201
|
+
hasStaticStyle &&
|
|
202
|
+
direction === 'start' &&
|
|
203
|
+
'.dropstart .dropdown-menu[data-bs-popper]',
|
|
204
|
+
// Navbar styles
|
|
205
|
+
navbar && '.navbar-nav .dropdown-menu',
|
|
206
|
+
navbar &&
|
|
207
|
+
navbar.expand &&
|
|
208
|
+
`.navbar-expand${
|
|
209
|
+
navbar.expand === true ? '' : `-${navbar.expand}`
|
|
210
|
+
} .navbar-nav .dropdown-menu`,
|
|
211
|
+
]);
|
|
212
|
+
const textClasses = getStyles(styles, ['.dropdown-menu --text']);
|
|
238
213
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
targetRef={toggleRef}
|
|
244
|
-
offset={normalizeNumber(StyleSheet.value('dropdown-spacer'))}
|
|
245
|
-
visible={visible}
|
|
246
|
-
>
|
|
247
|
-
{(overlay, overlayRef) => (
|
|
248
|
-
<>
|
|
214
|
+
if (isStatic || isCollapsedNavbar) {
|
|
215
|
+
return (
|
|
216
|
+
<>
|
|
217
|
+
{!isCollapsedNavbar && (
|
|
249
218
|
<BackdropHandler
|
|
250
219
|
toggleRef={toggleRef}
|
|
251
|
-
dialogRef={
|
|
220
|
+
dialogRef={dialogRef}
|
|
252
221
|
onClose={() => {
|
|
253
222
|
setVisible(false);
|
|
254
223
|
}}
|
|
255
224
|
autoClose={autoClose}
|
|
256
225
|
/>
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
226
|
+
)}
|
|
227
|
+
<View
|
|
228
|
+
{...elementProps}
|
|
229
|
+
ref={concatRefs(dialogRef, ref)}
|
|
230
|
+
aria-labelledby={identifier}
|
|
231
|
+
style={[classes, style]}
|
|
232
|
+
textStyle={[textClasses, textStyle]}
|
|
233
|
+
>
|
|
234
|
+
{children}
|
|
235
|
+
</View>
|
|
236
|
+
</>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return (
|
|
241
|
+
<OverlayContainer>
|
|
242
|
+
<Overlay
|
|
243
|
+
placement={transformPlacement(media, direction, start, end)}
|
|
244
|
+
targetRef={toggleRef}
|
|
245
|
+
offset={normalizeNumber(StyleSheet.value('dropdown-spacer'))}
|
|
246
|
+
visible={visible}
|
|
247
|
+
>
|
|
248
|
+
{(overlay, overlayRef) => (
|
|
249
|
+
<>
|
|
250
|
+
<BackdropHandler
|
|
251
|
+
toggleRef={toggleRef}
|
|
252
|
+
dialogRef={overlayRef}
|
|
253
|
+
onClose={() => {
|
|
254
|
+
setVisible(false);
|
|
255
|
+
}}
|
|
256
|
+
autoClose={autoClose}
|
|
257
|
+
/>
|
|
258
|
+
<View
|
|
259
|
+
{...elementProps}
|
|
260
|
+
ref={concatRefs(overlayRef, ref)}
|
|
261
|
+
aria-labelledby={identifier}
|
|
262
|
+
style={[
|
|
263
|
+
classes,
|
|
264
|
+
overlay.overlayProps.style,
|
|
265
|
+
{ maxHeight: 'auto', opacity: overlay.rendered ? 1 : 0 },
|
|
266
|
+
style,
|
|
267
|
+
]}
|
|
268
|
+
textStyle={[textClasses, textStyle]}
|
|
269
|
+
>
|
|
270
|
+
<DropdownContext.Provider value={dropdown}>
|
|
271
|
+
{children}
|
|
272
|
+
</DropdownContext.Provider>
|
|
273
|
+
</View>
|
|
274
|
+
</>
|
|
275
|
+
)}
|
|
276
|
+
</Overlay>
|
|
277
|
+
</OverlayContainer>
|
|
278
|
+
);
|
|
279
|
+
},
|
|
280
|
+
);
|
|
279
281
|
|
|
280
282
|
DropdownMenu.displayName = 'DropdownMenu';
|
|
281
283
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import useToggleDropdown, { UseToggleDropdownProps } from './useToggleDropdown';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export interface DropdownToggleProps {
|
|
5
5
|
children: (args: UseToggleDropdownProps) => React.ReactNode;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
7
|
|
|
8
8
|
function DropdownToggle(props: DropdownToggleProps) {
|
|
9
9
|
const { children } = props;
|