bootstrap-rn 0.3.1 → 0.3.3
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/Provider.js +3 -0
- package/lib/commonjs/Provider.js.map +1 -1
- package/lib/commonjs/components/Caret.js +1 -1
- package/lib/commonjs/components/badge/Badge.js +1 -1
- package/lib/commonjs/components/buttons/Button.js +3 -3
- package/lib/commonjs/components/close/CloseButton.js +2 -2
- package/lib/commonjs/components/dropdown/DropdownItem.js +1 -1
- package/lib/commonjs/components/dropdown/useToggleDropdown.js +1 -0
- package/lib/commonjs/components/dropdown/useToggleDropdown.js.map +1 -1
- package/lib/commonjs/components/forms/FormCheckInput.js +1 -1
- package/lib/commonjs/components/list-group/ListGroupItem.js +1 -1
- package/lib/commonjs/components/modal/Modal.js +3 -8
- package/lib/commonjs/components/modal/Modal.js.map +1 -1
- package/lib/commonjs/components/modal/useModal.js +13 -1
- package/lib/commonjs/components/modal/useModal.js.map +1 -1
- package/lib/commonjs/components/navbar/NavbarToggler.js +1 -1
- package/lib/commonjs/components/offcanvas/Offcanvas.js +1 -6
- package/lib/commonjs/components/offcanvas/Offcanvas.js.map +1 -1
- package/lib/commonjs/components/offcanvas/useOffcanvas.js +13 -1
- package/lib/commonjs/components/offcanvas/useOffcanvas.js.map +1 -1
- package/lib/commonjs/components/toasts/Toast.js +1 -1
- package/lib/commonjs/components/toasts/ToastContainer.js +1 -1
- package/lib/commonjs/hooks/useScrollbarEffects.js +48 -41
- package/lib/commonjs/hooks/useScrollbarEffects.js.map +1 -1
- package/lib/commonjs/theme/utilities.js +8 -8
- package/lib/commonjs/theme/utilities.js.map +1 -1
- package/lib/module/Provider.js +3 -0
- package/lib/module/Provider.js.map +1 -1
- package/lib/module/components/Caret.js +1 -1
- package/lib/module/components/badge/Badge.js +1 -1
- package/lib/module/components/buttons/Button.js +3 -3
- package/lib/module/components/close/CloseButton.js +2 -2
- package/lib/module/components/dropdown/DropdownItem.js +1 -1
- package/lib/module/components/dropdown/useToggleDropdown.js +1 -0
- package/lib/module/components/dropdown/useToggleDropdown.js.map +1 -1
- package/lib/module/components/forms/FormCheckInput.js +1 -1
- package/lib/module/components/list-group/ListGroupItem.js +1 -1
- package/lib/module/components/modal/Modal.js +3 -8
- package/lib/module/components/modal/Modal.js.map +1 -1
- package/lib/module/components/modal/useModal.js +13 -2
- package/lib/module/components/modal/useModal.js.map +1 -1
- package/lib/module/components/navbar/NavbarToggler.js +1 -1
- package/lib/module/components/offcanvas/Offcanvas.js +1 -6
- package/lib/module/components/offcanvas/Offcanvas.js.map +1 -1
- package/lib/module/components/offcanvas/useOffcanvas.js +13 -2
- package/lib/module/components/offcanvas/useOffcanvas.js.map +1 -1
- package/lib/module/components/toasts/Toast.js +1 -1
- package/lib/module/components/toasts/ToastContainer.js +1 -1
- package/lib/module/hooks/useScrollbarEffects.js +49 -41
- package/lib/module/hooks/useScrollbarEffects.js.map +1 -1
- package/lib/module/theme/utilities.js +8 -8
- package/lib/module/theme/utilities.js.map +1 -1
- package/package.json +69 -69
- package/src/Provider.js +63 -59
- package/src/components/Caret.js +127 -127
- package/src/components/badge/Badge.js +52 -52
- package/src/components/buttons/Button.js +381 -381
- package/src/components/close/CloseButton.js +146 -146
- package/src/components/dropdown/DropdownItem.js +151 -151
- package/src/components/dropdown/useToggleDropdown.js +1 -0
- package/src/components/forms/FormCheckInput.js +247 -247
- package/src/components/list-group/ListGroupItem.js +1 -1
- package/src/components/modal/Modal.js +235 -241
- package/src/components/modal/useModal.js +25 -10
- package/src/components/navbar/NavbarToggler.js +132 -132
- package/src/components/offcanvas/Offcanvas.js +252 -258
- package/src/components/offcanvas/useOffcanvas.js +20 -5
- package/src/components/toasts/Toast.js +1 -1
- package/src/components/toasts/ToastContainer.js +43 -43
- package/src/hooks/useScrollbarEffects.js +61 -41
- package/src/theme/utilities.js +4 -4
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import css from '../../style/css';
|
|
4
|
-
import { getStyles } from '../../utils';
|
|
5
|
-
import StyleSheet from '../../style/StyleSheet';
|
|
6
|
-
import Pressable from '../Pressable';
|
|
7
|
-
import ModalContext from '../modal/ModalContext';
|
|
8
|
-
import OffcanvasContext from '../offcanvas/OffcanvasContext';
|
|
9
|
-
import useMedia from '../../hooks/useMedia';
|
|
10
|
-
import useStyle from '../../hooks/useStyle';
|
|
11
|
-
import useInteractionState from '../../hooks/useInteractionState';
|
|
12
|
-
import useBackground from '../../hooks/useBackground';
|
|
13
|
-
import { escapeSvg } from '../../theme/functions';
|
|
14
|
-
|
|
15
|
-
const propTypes = {
|
|
16
|
-
children: PropTypes.node,
|
|
17
|
-
disabled: PropTypes.bool,
|
|
18
|
-
// eslint-disable-next-line react/forbid-prop-types
|
|
19
|
-
style: PropTypes.any,
|
|
20
|
-
// eslint-disable-next-line react/forbid-prop-types
|
|
21
|
-
textStyle: PropTypes.any,
|
|
22
|
-
// eslint-disable-next-line react/forbid-prop-types
|
|
23
|
-
styleName: PropTypes.any,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const styles = StyleSheet.create({
|
|
27
|
-
'.btn-close': css`
|
|
28
|
-
// Workaround for missing box-sizing in react native.
|
|
29
|
-
$additional-width: $btn-close-padding-x * 2;
|
|
30
|
-
$additional-height: $btn-close-padding-y * 2;
|
|
31
|
-
|
|
32
|
-
// box-sizing: content-box;
|
|
33
|
-
width: $btn-close-width + $additional-width;
|
|
34
|
-
height: $btn-close-height + $additional-height;
|
|
35
|
-
padding: $btn-close-padding-y $btn-close-padding-x;
|
|
36
|
-
background-color: transparent; // include transparent for button elements
|
|
37
|
-
background-image: ${(t) => escapeSvg(t['btn-close-bg'])};
|
|
38
|
-
background-position: center;
|
|
39
|
-
background-size: $btn-close-width auto;
|
|
40
|
-
background-repeat: no-repeat;
|
|
41
|
-
border-width: 0; // for button elements
|
|
42
|
-
// @include border-radius();
|
|
43
|
-
opacity: $btn-close-opacity;
|
|
44
|
-
|
|
45
|
-
&:hover {
|
|
46
|
-
opacity: $btn-close-hover-opacity;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
&:focus {
|
|
50
|
-
// outline: 0;
|
|
51
|
-
// box-shadow: $btn-close-focus-shadow;
|
|
52
|
-
opacity: $btn-close-focus-opacity;
|
|
53
|
-
}
|
|
54
|
-
`,
|
|
55
|
-
'.btn-close --text': css`
|
|
56
|
-
color: $btn-close-color;
|
|
57
|
-
|
|
58
|
-
// Override <a>'s hover style
|
|
59
|
-
&:hover {
|
|
60
|
-
color: $btn-close-color;
|
|
61
|
-
text-decoration: none;
|
|
62
|
-
}
|
|
63
|
-
`,
|
|
64
|
-
'.btn-close.disabled': css`
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
opacity: $btn-close-disabled-opacity;
|
|
68
|
-
`,
|
|
69
|
-
// Modal styles
|
|
70
|
-
'.modal-header .btn-close': css`
|
|
71
|
-
padding: $modal-header-padding-y * 0.5 $modal-header-padding-x * 0.5;
|
|
72
|
-
margin: -0.5 * $modal-header-padding-y -0.5 * $modal-header-padding-x -0.5 *
|
|
73
|
-
$modal-header-padding-y auto;
|
|
74
|
-
|
|
75
|
-
// Workaround for missing box-sizing in react native.
|
|
76
|
-
width: $btn-close-width + $modal-header-padding-x;
|
|
77
|
-
height: $btn-close-height + $modal-header-padding-y;
|
|
78
|
-
`,
|
|
79
|
-
// Offcanvas styles
|
|
80
|
-
'.offcanvas-header .btn-close': css`
|
|
81
|
-
padding: $offcanvas-padding-y * 0.5 $offcanvas-padding-x * 0.5;
|
|
82
|
-
margin-top: -0.5 * $offcanvas-padding-y;
|
|
83
|
-
margin-right: -0.5 * $offcanvas-padding-x;
|
|
84
|
-
margin-bottom: -0.5 * $offcanvas-padding-y;
|
|
85
|
-
|
|
86
|
-
// Workaround for missing box-sizing in react native.
|
|
87
|
-
width: $btn-close-width + $offcanvas-padding-x;
|
|
88
|
-
height: $btn-close-height + $offcanvas-padding-y;
|
|
89
|
-
`,
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
const CloseButton = React.forwardRef((props, ref) => {
|
|
93
|
-
const {
|
|
94
|
-
children,
|
|
95
|
-
disabled = false,
|
|
96
|
-
style,
|
|
97
|
-
textStyle,
|
|
98
|
-
styleName,
|
|
99
|
-
...elementProps
|
|
100
|
-
} = props;
|
|
101
|
-
|
|
102
|
-
const media = useMedia();
|
|
103
|
-
|
|
104
|
-
const modal = useContext(ModalContext);
|
|
105
|
-
const offcanvas = useContext(OffcanvasContext);
|
|
106
|
-
|
|
107
|
-
const classes = getStyles(styles, [
|
|
108
|
-
'.btn-close',
|
|
109
|
-
disabled && '.btn-close.disabled',
|
|
110
|
-
// Modal styles
|
|
111
|
-
modal && '.modal-header .btn-close',
|
|
112
|
-
// Offcanvas styles
|
|
113
|
-
offcanvas && '.offcanvas-header .btn-close',
|
|
114
|
-
]);
|
|
115
|
-
const textClasses = getStyles(styles, ['.btn-close --text']);
|
|
116
|
-
|
|
117
|
-
const resolveStyle = useStyle([classes, style], styleName);
|
|
118
|
-
|
|
119
|
-
const { interaction, interactionProps } = useInteractionState(elementProps);
|
|
120
|
-
|
|
121
|
-
const background = useBackground(
|
|
122
|
-
resolveStyle({
|
|
123
|
-
media,
|
|
124
|
-
interaction,
|
|
125
|
-
}),
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
return (
|
|
129
|
-
<Pressable
|
|
130
|
-
{...elementProps}
|
|
131
|
-
{...interactionProps}
|
|
132
|
-
component={Pressable}
|
|
133
|
-
ref={ref}
|
|
134
|
-
disabled={disabled}
|
|
135
|
-
style={background.style}
|
|
136
|
-
textStyle={[textClasses, textStyle]}
|
|
137
|
-
>
|
|
138
|
-
{background.element}
|
|
139
|
-
</Pressable>
|
|
140
|
-
);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
CloseButton.displayName = 'CloseButton';
|
|
144
|
-
CloseButton.propTypes = propTypes;
|
|
145
|
-
|
|
146
|
-
export default CloseButton;
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import css from '../../style/css';
|
|
4
|
+
import { getStyles } from '../../utils';
|
|
5
|
+
import StyleSheet from '../../style/StyleSheet';
|
|
6
|
+
import Pressable from '../Pressable';
|
|
7
|
+
import ModalContext from '../modal/ModalContext';
|
|
8
|
+
import OffcanvasContext from '../offcanvas/OffcanvasContext';
|
|
9
|
+
import useMedia from '../../hooks/useMedia';
|
|
10
|
+
import useStyle from '../../hooks/useStyle';
|
|
11
|
+
import useInteractionState from '../../hooks/useInteractionState';
|
|
12
|
+
import useBackground from '../../hooks/useBackground';
|
|
13
|
+
import { escapeSvg } from '../../theme/functions';
|
|
14
|
+
|
|
15
|
+
const propTypes = {
|
|
16
|
+
children: PropTypes.node,
|
|
17
|
+
disabled: PropTypes.bool,
|
|
18
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
19
|
+
style: PropTypes.any,
|
|
20
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
21
|
+
textStyle: PropTypes.any,
|
|
22
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
23
|
+
styleName: PropTypes.any,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const styles = StyleSheet.create({
|
|
27
|
+
'.btn-close': css`
|
|
28
|
+
// Workaround for missing box-sizing in react native.
|
|
29
|
+
$additional-width: $btn-close-padding-x * 2;
|
|
30
|
+
$additional-height: $btn-close-padding-y * 2;
|
|
31
|
+
|
|
32
|
+
// box-sizing: content-box;
|
|
33
|
+
width: $btn-close-width + $additional-width;
|
|
34
|
+
height: $btn-close-height + $additional-height;
|
|
35
|
+
padding: $btn-close-padding-y $btn-close-padding-x;
|
|
36
|
+
background-color: transparent; // include transparent for button elements
|
|
37
|
+
background-image: ${(t) => escapeSvg(t['btn-close-bg'])};
|
|
38
|
+
background-position: center;
|
|
39
|
+
background-size: $btn-close-width auto;
|
|
40
|
+
background-repeat: no-repeat;
|
|
41
|
+
border-width: 0; // for button elements
|
|
42
|
+
// @include border-radius();
|
|
43
|
+
opacity: $btn-close-opacity;
|
|
44
|
+
|
|
45
|
+
&:hover {
|
|
46
|
+
opacity: $btn-close-hover-opacity;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&:focus {
|
|
50
|
+
// outline: 0;
|
|
51
|
+
// box-shadow: $btn-close-focus-shadow;
|
|
52
|
+
opacity: $btn-close-focus-opacity;
|
|
53
|
+
}
|
|
54
|
+
`,
|
|
55
|
+
'.btn-close --text': css`
|
|
56
|
+
color: $btn-close-color;
|
|
57
|
+
|
|
58
|
+
// Override <a>'s hover style
|
|
59
|
+
&:hover {
|
|
60
|
+
color: $btn-close-color;
|
|
61
|
+
text-decoration: none;
|
|
62
|
+
}
|
|
63
|
+
`,
|
|
64
|
+
'.btn-close.disabled': css`
|
|
65
|
+
pointer-events: none;
|
|
66
|
+
user-select: none;
|
|
67
|
+
opacity: $btn-close-disabled-opacity;
|
|
68
|
+
`,
|
|
69
|
+
// Modal styles
|
|
70
|
+
'.modal-header .btn-close': css`
|
|
71
|
+
padding: $modal-header-padding-y * 0.5 $modal-header-padding-x * 0.5;
|
|
72
|
+
margin: -0.5 * $modal-header-padding-y -0.5 * $modal-header-padding-x -0.5 *
|
|
73
|
+
$modal-header-padding-y auto;
|
|
74
|
+
|
|
75
|
+
// Workaround for missing box-sizing in react native.
|
|
76
|
+
width: $btn-close-width + $modal-header-padding-x;
|
|
77
|
+
height: $btn-close-height + $modal-header-padding-y;
|
|
78
|
+
`,
|
|
79
|
+
// Offcanvas styles
|
|
80
|
+
'.offcanvas-header .btn-close': css`
|
|
81
|
+
padding: $offcanvas-padding-y * 0.5 $offcanvas-padding-x * 0.5;
|
|
82
|
+
margin-top: -0.5 * $offcanvas-padding-y;
|
|
83
|
+
margin-right: -0.5 * $offcanvas-padding-x;
|
|
84
|
+
margin-bottom: -0.5 * $offcanvas-padding-y;
|
|
85
|
+
|
|
86
|
+
// Workaround for missing box-sizing in react native.
|
|
87
|
+
width: $btn-close-width + $offcanvas-padding-x;
|
|
88
|
+
height: $btn-close-height + $offcanvas-padding-y;
|
|
89
|
+
`,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const CloseButton = React.forwardRef((props, ref) => {
|
|
93
|
+
const {
|
|
94
|
+
children,
|
|
95
|
+
disabled = false,
|
|
96
|
+
style,
|
|
97
|
+
textStyle,
|
|
98
|
+
styleName,
|
|
99
|
+
...elementProps
|
|
100
|
+
} = props;
|
|
101
|
+
|
|
102
|
+
const media = useMedia();
|
|
103
|
+
|
|
104
|
+
const modal = useContext(ModalContext);
|
|
105
|
+
const offcanvas = useContext(OffcanvasContext);
|
|
106
|
+
|
|
107
|
+
const classes = getStyles(styles, [
|
|
108
|
+
'.btn-close',
|
|
109
|
+
disabled && '.btn-close.disabled',
|
|
110
|
+
// Modal styles
|
|
111
|
+
modal && '.modal-header .btn-close',
|
|
112
|
+
// Offcanvas styles
|
|
113
|
+
offcanvas && '.offcanvas-header .btn-close',
|
|
114
|
+
]);
|
|
115
|
+
const textClasses = getStyles(styles, ['.btn-close --text']);
|
|
116
|
+
|
|
117
|
+
const resolveStyle = useStyle([classes, style], styleName);
|
|
118
|
+
|
|
119
|
+
const { interaction, interactionProps } = useInteractionState(elementProps);
|
|
120
|
+
|
|
121
|
+
const background = useBackground(
|
|
122
|
+
resolveStyle({
|
|
123
|
+
media,
|
|
124
|
+
interaction,
|
|
125
|
+
}),
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<Pressable
|
|
130
|
+
{...elementProps}
|
|
131
|
+
{...interactionProps}
|
|
132
|
+
component={Pressable}
|
|
133
|
+
ref={ref}
|
|
134
|
+
disabled={disabled}
|
|
135
|
+
style={background.style}
|
|
136
|
+
textStyle={[textClasses, textStyle]}
|
|
137
|
+
>
|
|
138
|
+
{background.element}
|
|
139
|
+
</Pressable>
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
CloseButton.displayName = 'CloseButton';
|
|
144
|
+
CloseButton.propTypes = propTypes;
|
|
145
|
+
|
|
146
|
+
export default CloseButton;
|
|
@@ -1,151 +1,151 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import StyleSheet from '../../style/StyleSheet';
|
|
4
|
-
import { getStyles } from '../../utils';
|
|
5
|
-
import useForcedContext from '../../hooks/useForcedContext';
|
|
6
|
-
import css from '../../style/css';
|
|
7
|
-
import Pressable from '../Pressable';
|
|
8
|
-
import DropdownContext from './DropdownContext';
|
|
9
|
-
|
|
10
|
-
const propTypes = {
|
|
11
|
-
children: PropTypes.node.isRequired,
|
|
12
|
-
onPress: PropTypes.func,
|
|
13
|
-
active: PropTypes.bool,
|
|
14
|
-
disabled: PropTypes.bool,
|
|
15
|
-
// eslint-disable-next-line react/forbid-prop-types
|
|
16
|
-
style: PropTypes.any,
|
|
17
|
-
// eslint-disable-next-line react/forbid-prop-types
|
|
18
|
-
textStyle: PropTypes.any,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const styles = StyleSheet.create({
|
|
22
|
-
'.dropdown-item': css`
|
|
23
|
-
width: 100%;
|
|
24
|
-
padding: $dropdown-item-padding-y $dropdown-item-padding-x;
|
|
25
|
-
// clear: both;
|
|
26
|
-
background-color: transparent;
|
|
27
|
-
border: 0;
|
|
28
|
-
|
|
29
|
-
&:hover {
|
|
30
|
-
// @include gradient-bg($dropdown-link-hover-bg);
|
|
31
|
-
background-color: $dropdown-link-hover-bg;
|
|
32
|
-
}
|
|
33
|
-
&:focus {
|
|
34
|
-
// @include gradient-bg($dropdown-link-hover-bg);
|
|
35
|
-
background-color: $dropdown-link-hover-bg;
|
|
36
|
-
}
|
|
37
|
-
`,
|
|
38
|
-
'.dropdown-item --text': css`
|
|
39
|
-
font-weight: $font-weight-normal;
|
|
40
|
-
color: $dropdown-link-color;
|
|
41
|
-
// text-align: inherit;
|
|
42
|
-
text-decoration: none; // if($link-decoration == none, null, none);
|
|
43
|
-
// white-space: nowrap;
|
|
44
|
-
|
|
45
|
-
&:hover {
|
|
46
|
-
color: $dropdown-link-hover-color;
|
|
47
|
-
text-decoration: none; // if($link-hover-decoration == underline, none, null);
|
|
48
|
-
}
|
|
49
|
-
&:focus {
|
|
50
|
-
color: $dropdown-link-hover-color;
|
|
51
|
-
text-decoration: none; // if($link-hover-decoration == underline, none, null);
|
|
52
|
-
}
|
|
53
|
-
`,
|
|
54
|
-
'.dropdown-item.active': css`
|
|
55
|
-
// @include gradient-bg($dropdown-link-active-bg);
|
|
56
|
-
background-color: $dropdown-link-active-bg;
|
|
57
|
-
|
|
58
|
-
&:hover {
|
|
59
|
-
background-color: $dropdown-link-active-bg;
|
|
60
|
-
}
|
|
61
|
-
&:focus {
|
|
62
|
-
background-color: $dropdown-link-active-bg;
|
|
63
|
-
}
|
|
64
|
-
`,
|
|
65
|
-
'.dropdown-item.active --text': css`
|
|
66
|
-
color: $dropdown-link-active-color;
|
|
67
|
-
text-decoration: none;
|
|
68
|
-
|
|
69
|
-
&:hover {
|
|
70
|
-
color: $dropdown-link-active-color;
|
|
71
|
-
}
|
|
72
|
-
&:focus {
|
|
73
|
-
color: $dropdown-link-active-color;
|
|
74
|
-
}
|
|
75
|
-
`,
|
|
76
|
-
|
|
77
|
-
'.dropdown-item.disabled': css`
|
|
78
|
-
|
|
79
|
-
background-color: transparent;
|
|
80
|
-
// Remove CSS gradients if they're enabled
|
|
81
|
-
// background-image: if($enable-gradients, none, null);
|
|
82
|
-
|
|
83
|
-
&:hover {
|
|
84
|
-
background-color: transparent;
|
|
85
|
-
}
|
|
86
|
-
&:focus {
|
|
87
|
-
background-color: transparent;
|
|
88
|
-
}
|
|
89
|
-
`,
|
|
90
|
-
'.dropdown-item.disabled --text': css`
|
|
91
|
-
color: $dropdown-link-disabled-color;
|
|
92
|
-
|
|
93
|
-
&:hover {
|
|
94
|
-
color: $dropdown-link-disabled-color;
|
|
95
|
-
}
|
|
96
|
-
&:focus {
|
|
97
|
-
color: $dropdown-link-disabled-color;
|
|
98
|
-
}
|
|
99
|
-
`,
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
const DropdownItem = (props) => {
|
|
103
|
-
const {
|
|
104
|
-
children,
|
|
105
|
-
onPress: handlePress,
|
|
106
|
-
active = false,
|
|
107
|
-
disabled = false,
|
|
108
|
-
style,
|
|
109
|
-
textStyle,
|
|
110
|
-
...elementProps
|
|
111
|
-
} = props;
|
|
112
|
-
|
|
113
|
-
const dropdown = useForcedContext(DropdownContext);
|
|
114
|
-
|
|
115
|
-
const classes = getStyles(styles, [
|
|
116
|
-
'.dropdown-item',
|
|
117
|
-
active && '.dropdown-item.active',
|
|
118
|
-
disabled && '.dropdown-item.disabled',
|
|
119
|
-
]);
|
|
120
|
-
|
|
121
|
-
const textClasses = getStyles(styles, [
|
|
122
|
-
'.dropdown-item --text',
|
|
123
|
-
active && '.dropdown-item.active --text',
|
|
124
|
-
disabled && '.dropdown-item.disabled --text',
|
|
125
|
-
]);
|
|
126
|
-
|
|
127
|
-
return (
|
|
128
|
-
<Pressable
|
|
129
|
-
{...elementProps}
|
|
130
|
-
onPress={(event) => {
|
|
131
|
-
if (handlePress) handlePress(event);
|
|
132
|
-
|
|
133
|
-
if (event.defaultPrevented) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
dropdown.setVisible(false);
|
|
138
|
-
}}
|
|
139
|
-
disabled={disabled}
|
|
140
|
-
style={[classes, style]}
|
|
141
|
-
textStyle={[textClasses, textStyle]}
|
|
142
|
-
>
|
|
143
|
-
{children}
|
|
144
|
-
</Pressable>
|
|
145
|
-
);
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
DropdownItem.displayName = 'DropdownItem';
|
|
149
|
-
DropdownItem.propTypes = propTypes;
|
|
150
|
-
|
|
151
|
-
export default DropdownItem;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import StyleSheet from '../../style/StyleSheet';
|
|
4
|
+
import { getStyles } from '../../utils';
|
|
5
|
+
import useForcedContext from '../../hooks/useForcedContext';
|
|
6
|
+
import css from '../../style/css';
|
|
7
|
+
import Pressable from '../Pressable';
|
|
8
|
+
import DropdownContext from './DropdownContext';
|
|
9
|
+
|
|
10
|
+
const propTypes = {
|
|
11
|
+
children: PropTypes.node.isRequired,
|
|
12
|
+
onPress: PropTypes.func,
|
|
13
|
+
active: PropTypes.bool,
|
|
14
|
+
disabled: PropTypes.bool,
|
|
15
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
16
|
+
style: PropTypes.any,
|
|
17
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
18
|
+
textStyle: PropTypes.any,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const styles = StyleSheet.create({
|
|
22
|
+
'.dropdown-item': css`
|
|
23
|
+
width: 100%;
|
|
24
|
+
padding: $dropdown-item-padding-y $dropdown-item-padding-x;
|
|
25
|
+
// clear: both;
|
|
26
|
+
background-color: transparent;
|
|
27
|
+
border: 0;
|
|
28
|
+
|
|
29
|
+
&:hover {
|
|
30
|
+
// @include gradient-bg($dropdown-link-hover-bg);
|
|
31
|
+
background-color: $dropdown-link-hover-bg;
|
|
32
|
+
}
|
|
33
|
+
&:focus {
|
|
34
|
+
// @include gradient-bg($dropdown-link-hover-bg);
|
|
35
|
+
background-color: $dropdown-link-hover-bg;
|
|
36
|
+
}
|
|
37
|
+
`,
|
|
38
|
+
'.dropdown-item --text': css`
|
|
39
|
+
font-weight: $font-weight-normal;
|
|
40
|
+
color: $dropdown-link-color;
|
|
41
|
+
// text-align: inherit;
|
|
42
|
+
text-decoration: none; // if($link-decoration == none, null, none);
|
|
43
|
+
// white-space: nowrap;
|
|
44
|
+
|
|
45
|
+
&:hover {
|
|
46
|
+
color: $dropdown-link-hover-color;
|
|
47
|
+
text-decoration: none; // if($link-hover-decoration == underline, none, null);
|
|
48
|
+
}
|
|
49
|
+
&:focus {
|
|
50
|
+
color: $dropdown-link-hover-color;
|
|
51
|
+
text-decoration: none; // if($link-hover-decoration == underline, none, null);
|
|
52
|
+
}
|
|
53
|
+
`,
|
|
54
|
+
'.dropdown-item.active': css`
|
|
55
|
+
// @include gradient-bg($dropdown-link-active-bg);
|
|
56
|
+
background-color: $dropdown-link-active-bg;
|
|
57
|
+
|
|
58
|
+
&:hover {
|
|
59
|
+
background-color: $dropdown-link-active-bg;
|
|
60
|
+
}
|
|
61
|
+
&:focus {
|
|
62
|
+
background-color: $dropdown-link-active-bg;
|
|
63
|
+
}
|
|
64
|
+
`,
|
|
65
|
+
'.dropdown-item.active --text': css`
|
|
66
|
+
color: $dropdown-link-active-color;
|
|
67
|
+
text-decoration: none;
|
|
68
|
+
|
|
69
|
+
&:hover {
|
|
70
|
+
color: $dropdown-link-active-color;
|
|
71
|
+
}
|
|
72
|
+
&:focus {
|
|
73
|
+
color: $dropdown-link-active-color;
|
|
74
|
+
}
|
|
75
|
+
`,
|
|
76
|
+
|
|
77
|
+
'.dropdown-item.disabled': css`
|
|
78
|
+
pointer-events: none;
|
|
79
|
+
background-color: transparent;
|
|
80
|
+
// Remove CSS gradients if they're enabled
|
|
81
|
+
// background-image: if($enable-gradients, none, null);
|
|
82
|
+
|
|
83
|
+
&:hover {
|
|
84
|
+
background-color: transparent;
|
|
85
|
+
}
|
|
86
|
+
&:focus {
|
|
87
|
+
background-color: transparent;
|
|
88
|
+
}
|
|
89
|
+
`,
|
|
90
|
+
'.dropdown-item.disabled --text': css`
|
|
91
|
+
color: $dropdown-link-disabled-color;
|
|
92
|
+
|
|
93
|
+
&:hover {
|
|
94
|
+
color: $dropdown-link-disabled-color;
|
|
95
|
+
}
|
|
96
|
+
&:focus {
|
|
97
|
+
color: $dropdown-link-disabled-color;
|
|
98
|
+
}
|
|
99
|
+
`,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const DropdownItem = (props) => {
|
|
103
|
+
const {
|
|
104
|
+
children,
|
|
105
|
+
onPress: handlePress,
|
|
106
|
+
active = false,
|
|
107
|
+
disabled = false,
|
|
108
|
+
style,
|
|
109
|
+
textStyle,
|
|
110
|
+
...elementProps
|
|
111
|
+
} = props;
|
|
112
|
+
|
|
113
|
+
const dropdown = useForcedContext(DropdownContext);
|
|
114
|
+
|
|
115
|
+
const classes = getStyles(styles, [
|
|
116
|
+
'.dropdown-item',
|
|
117
|
+
active && '.dropdown-item.active',
|
|
118
|
+
disabled && '.dropdown-item.disabled',
|
|
119
|
+
]);
|
|
120
|
+
|
|
121
|
+
const textClasses = getStyles(styles, [
|
|
122
|
+
'.dropdown-item --text',
|
|
123
|
+
active && '.dropdown-item.active --text',
|
|
124
|
+
disabled && '.dropdown-item.disabled --text',
|
|
125
|
+
]);
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<Pressable
|
|
129
|
+
{...elementProps}
|
|
130
|
+
onPress={(event) => {
|
|
131
|
+
if (handlePress) handlePress(event);
|
|
132
|
+
|
|
133
|
+
if (event.defaultPrevented) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
dropdown.setVisible(false);
|
|
138
|
+
}}
|
|
139
|
+
disabled={disabled}
|
|
140
|
+
style={[classes, style]}
|
|
141
|
+
textStyle={[textClasses, textStyle]}
|
|
142
|
+
>
|
|
143
|
+
{children}
|
|
144
|
+
</Pressable>
|
|
145
|
+
);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
DropdownItem.displayName = 'DropdownItem';
|
|
149
|
+
DropdownItem.propTypes = propTypes;
|
|
150
|
+
|
|
151
|
+
export default DropdownItem;
|