bootstrap-rn 0.3.1 → 0.3.2
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 +82 -62
- package/src/theme/utilities.js +4 -4
|
@@ -1,247 +1,247 @@
|
|
|
1
|
-
import React, { useContext, useState } from 'react';
|
|
2
|
-
import { Platform } from 'react-native';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import StyleSheet from '../../style/StyleSheet';
|
|
5
|
-
import css from '../../style/css';
|
|
6
|
-
import { getStyles, each } from '../../utils';
|
|
7
|
-
import useMedia from '../../hooks/useMedia';
|
|
8
|
-
import useStyle from '../../hooks/useStyle';
|
|
9
|
-
import useModifier from '../../hooks/useModifier';
|
|
10
|
-
import { FORM_VALIDATION_STATES } from '../../theme/proxies';
|
|
11
|
-
import { escapeSvg } from '../../theme/functions';
|
|
12
|
-
import FormCheckContext from './FormCheckContext';
|
|
13
|
-
import FormCheckInputWeb from './internals/FormCheckInputWeb';
|
|
14
|
-
import FormCheckInputNative from './internals/FormCheckInputNative';
|
|
15
|
-
|
|
16
|
-
/* eslint-disable react/no-unused-prop-types */
|
|
17
|
-
const propTypes = {
|
|
18
|
-
type: PropTypes.oneOf(['checkbox', 'radio', 'switch']).isRequired,
|
|
19
|
-
value: PropTypes.bool.isRequired,
|
|
20
|
-
onFocus: PropTypes.func,
|
|
21
|
-
onBlur: PropTypes.func,
|
|
22
|
-
disabled: PropTypes.bool,
|
|
23
|
-
valid: PropTypes.bool,
|
|
24
|
-
invalid: PropTypes.bool,
|
|
25
|
-
useNativeComponent: PropTypes.bool,
|
|
26
|
-
// eslint-disable-next-line react/forbid-prop-types
|
|
27
|
-
style: PropTypes.any,
|
|
28
|
-
// eslint-disable-next-line react/forbid-prop-types
|
|
29
|
-
};
|
|
30
|
-
/* eslint-enable */
|
|
31
|
-
|
|
32
|
-
const styles = StyleSheet.create({
|
|
33
|
-
'.form-check .form-check-input': css`
|
|
34
|
-
$height: $line-height-base * 1rem;
|
|
35
|
-
$margin-top-double: $height - $form-check-input-width;
|
|
36
|
-
|
|
37
|
-
// float: left;
|
|
38
|
-
// margin-left: $form-check-padding-start * -1;
|
|
39
|
-
margin-top: $margin-top-double * 0.5; // added for bootstrap-rn
|
|
40
|
-
margin-right: $form-check-padding-start - $form-check-input-width; // added for bootstrap-rn
|
|
41
|
-
`,
|
|
42
|
-
'.form-check-reverse .form-check-input': css`
|
|
43
|
-
// float: right;
|
|
44
|
-
// margin-right: $form-check-padding-start * -1;
|
|
45
|
-
margin-right: 0; // added for bootstrap-rn
|
|
46
|
-
// margin-left: 0;
|
|
47
|
-
margin-left: $form-check-padding-start - $form-check-input-width; // added for bootstrap-rn
|
|
48
|
-
`,
|
|
49
|
-
'.form-check-input': css`
|
|
50
|
-
width: $form-check-input-width;
|
|
51
|
-
height: $form-check-input-width;
|
|
52
|
-
// margin-top: ($line-height-base - $form-check-input-width) * 0.5; // line-height minus check height
|
|
53
|
-
|
|
54
|
-
background-color: $form-check-input-bg;
|
|
55
|
-
background-repeat: no-repeat;
|
|
56
|
-
background-position: center;
|
|
57
|
-
background-size: contain;
|
|
58
|
-
border: $form-check-input-border;
|
|
59
|
-
@include platform(web) {
|
|
60
|
-
appearance: none;
|
|
61
|
-
user-select: none; // added for bootstrap-rn
|
|
62
|
-
color-adjust: exact; // Keep themed appearance for print
|
|
63
|
-
}
|
|
64
|
-
// @include transition($form-check-transition);
|
|
65
|
-
|
|
66
|
-
&:active {
|
|
67
|
-
// filter: $form-check-input-active-filter;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
&:focus {
|
|
71
|
-
border-color: $form-check-input-focus-border;
|
|
72
|
-
@include platform(web) {
|
|
73
|
-
outline-width: 0; // outline: 0;
|
|
74
|
-
box-shadow: $form-check-input-focus-box-shadow;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
`,
|
|
78
|
-
'.form-check-input[type="checkbox"]': css`
|
|
79
|
-
border-radius: $form-check-input-border-radius;
|
|
80
|
-
`,
|
|
81
|
-
'.form-check-input[type="radio"]': css`
|
|
82
|
-
border-radius: $form-check-radio-border-radius;
|
|
83
|
-
`,
|
|
84
|
-
'.form-check-input:checked': css`
|
|
85
|
-
background-color: $form-check-input-checked-bg-color;
|
|
86
|
-
border-color: $form-check-input-checked-border-color;
|
|
87
|
-
`,
|
|
88
|
-
'.form-check-input[type="checkbox"]:checked': css`
|
|
89
|
-
// @if $enable-gradients {
|
|
90
|
-
// background-image: escape-svg($form-check-input-checked-bg-image), var(--#{$variable-prefix}gradient);
|
|
91
|
-
// } @else {
|
|
92
|
-
background-image: ${(t) =>
|
|
93
|
-
escapeSvg(t['form-check-input-checked-bg-image'])};
|
|
94
|
-
// }
|
|
95
|
-
`,
|
|
96
|
-
'.form-check-input[type="radio"]:checked': css`
|
|
97
|
-
// @if $enable-gradients {
|
|
98
|
-
// background-image: escape-svg($form-check-radio-checked-bg-image), var(--#{$variable-prefix}gradient);
|
|
99
|
-
// } @else {
|
|
100
|
-
background-image: ${(t) =>
|
|
101
|
-
escapeSvg(t['form-check-radio-checked-bg-image'])};
|
|
102
|
-
// }
|
|
103
|
-
`,
|
|
104
|
-
'.form-check-input:disabled': css`
|
|
105
|
-
@include platform(web) {
|
|
106
|
-
pointer-events: none;
|
|
107
|
-
filter: none;
|
|
108
|
-
}
|
|
109
|
-
opacity: $form-check-label-disabled-opacity;
|
|
110
|
-
`,
|
|
111
|
-
...each(FORM_VALIDATION_STATES, (state, data) => ({
|
|
112
|
-
[`.form-check-input:${state}`]: css`
|
|
113
|
-
border-color: ${(t) => data(t).color};
|
|
114
|
-
|
|
115
|
-
&:focus {
|
|
116
|
-
border-color: ${(t) => data(t).color}; // added for bootstrap-rn
|
|
117
|
-
@include platform(web) {
|
|
118
|
-
box-shadow: 0 0 $input-btn-focus-blur $input-focus-width
|
|
119
|
-
rgba(${(t) => data(t).color}, $input-btn-focus-color-opacity);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
`,
|
|
123
|
-
[`.form-check-input:${state}:checked`]: css`
|
|
124
|
-
background-color: ${(t) => data(t).color};
|
|
125
|
-
`,
|
|
126
|
-
})),
|
|
127
|
-
'.form-switch.form-check .form-check-input': css`
|
|
128
|
-
// float: left;
|
|
129
|
-
// margin-left: $form-switch-padding-start * -1;
|
|
130
|
-
margin-right: $form-switch-padding-start - $form-switch-width; // added for bootstrap-rn
|
|
131
|
-
`,
|
|
132
|
-
'.form-switch.form-check-reverse .form-check-input': css`
|
|
133
|
-
// margin-right: $form-switch-padding-start * -1;
|
|
134
|
-
margin-right: 0; // added for bootstrap-rn
|
|
135
|
-
// margin-left: 0;
|
|
136
|
-
margin-left: $form-switch-padding-start - $form-switch-width; // added for bootstrap-rn
|
|
137
|
-
`,
|
|
138
|
-
'.form-switch .form-check-input': css`
|
|
139
|
-
width: $form-switch-width;
|
|
140
|
-
background-image: ${(t) => escapeSvg(t['form-switch-bg-image'])};
|
|
141
|
-
background-position: left center;
|
|
142
|
-
border-radius: $form-switch-border-radius;
|
|
143
|
-
// @include transition($form-switch-transition);
|
|
144
|
-
|
|
145
|
-
&:focus {
|
|
146
|
-
background-image: ${(t) => escapeSvg(t['form-switch-focus-bg-image'])};
|
|
147
|
-
}
|
|
148
|
-
`,
|
|
149
|
-
'.form-switch .form-check-input:checked': css`
|
|
150
|
-
background-position: $form-switch-checked-bg-position;
|
|
151
|
-
|
|
152
|
-
// @if $enable-gradients {
|
|
153
|
-
// background-image: escape-svg($form-switch-checked-bg-image), var(--#{$prefix}gradient);
|
|
154
|
-
// } @else {
|
|
155
|
-
background-image: ${(t) => escapeSvg(t['form-switch-checked-bg-image'])};
|
|
156
|
-
// }
|
|
157
|
-
|
|
158
|
-
&:focus {
|
|
159
|
-
background-image: ${(t) =>
|
|
160
|
-
escapeSvg(t['form-switch-checked-bg-image'])}; // added for bootstrap-rn
|
|
161
|
-
}
|
|
162
|
-
`,
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
const FormCheckInput = React.forwardRef((props, ref) => {
|
|
166
|
-
const [modifierProps, modifierRef] = useModifier('useFormField', props, ref);
|
|
167
|
-
|
|
168
|
-
const context = useContext(FormCheckContext);
|
|
169
|
-
|
|
170
|
-
const {
|
|
171
|
-
type,
|
|
172
|
-
value,
|
|
173
|
-
onFocus = () => {},
|
|
174
|
-
onBlur = () => {},
|
|
175
|
-
disabled = context ? context.disabled : false,
|
|
176
|
-
valid = context ? context.valid : false,
|
|
177
|
-
invalid = context ? context.invalid : false,
|
|
178
|
-
useNativeComponent = false,
|
|
179
|
-
autoFocus = false,
|
|
180
|
-
style,
|
|
181
|
-
...elementProps
|
|
182
|
-
} = modifierProps;
|
|
183
|
-
|
|
184
|
-
const media = useMedia();
|
|
185
|
-
const [focused, setFocused] = useState(autoFocus);
|
|
186
|
-
|
|
187
|
-
const classes = getStyles(styles, [
|
|
188
|
-
context && '.form-check .form-check-input',
|
|
189
|
-
context?.reverse && '.form-check-reverse .form-check-input',
|
|
190
|
-
'.form-check-input',
|
|
191
|
-
type === 'checkbox' && '.form-check-input[type="checkbox"]',
|
|
192
|
-
type === 'radio' && '.form-check-input[type="radio"]',
|
|
193
|
-
value && '.form-check-input:checked',
|
|
194
|
-
type === 'checkbox' &&
|
|
195
|
-
value &&
|
|
196
|
-
'.form-check-input[type="checkbox"]:checked',
|
|
197
|
-
type === 'radio' && value && '.form-check-input[type="radio"]:checked',
|
|
198
|
-
disabled && '.form-check-input:disabled',
|
|
199
|
-
// validation
|
|
200
|
-
valid && '.form-check-input:valid',
|
|
201
|
-
valid && value && '.form-check-input:valid:checked',
|
|
202
|
-
invalid && '.form-check-input:invalid',
|
|
203
|
-
invalid && value && '.form-check-input:invalid:checked',
|
|
204
|
-
// switch
|
|
205
|
-
context && type === 'switch' && '.form-switch.form-check .form-check-input',
|
|
206
|
-
context?.reverse &&
|
|
207
|
-
type === 'switch' &&
|
|
208
|
-
'.form-switch.form-check-reverse .form-check-input',
|
|
209
|
-
type === 'switch' && '.form-switch .form-check-input',
|
|
210
|
-
type === 'switch' && value && '.form-switch .form-check-input:checked',
|
|
211
|
-
]);
|
|
212
|
-
|
|
213
|
-
const resolveStyle = useStyle([classes, style]);
|
|
214
|
-
|
|
215
|
-
const BaseFormCheckInput =
|
|
216
|
-
Platform.OS === 'web' && !useNativeComponent
|
|
217
|
-
? FormCheckInputWeb
|
|
218
|
-
: FormCheckInputNative;
|
|
219
|
-
|
|
220
|
-
return (
|
|
221
|
-
<BaseFormCheckInput
|
|
222
|
-
{...elementProps}
|
|
223
|
-
ref={modifierRef}
|
|
224
|
-
type={type}
|
|
225
|
-
value={value}
|
|
226
|
-
onFocus={() => {
|
|
227
|
-
setFocused(true);
|
|
228
|
-
onFocus();
|
|
229
|
-
}}
|
|
230
|
-
onBlur={() => {
|
|
231
|
-
setFocused(false);
|
|
232
|
-
onBlur();
|
|
233
|
-
}}
|
|
234
|
-
disabled={disabled}
|
|
235
|
-
autoFocus={autoFocus}
|
|
236
|
-
style={resolveStyle({
|
|
237
|
-
media,
|
|
238
|
-
interaction: { focus: focused, focusVisible: focused },
|
|
239
|
-
})}
|
|
240
|
-
/>
|
|
241
|
-
);
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
FormCheckInput.displayName = 'FormCheckInput';
|
|
245
|
-
FormCheckInput.propTypes = propTypes;
|
|
246
|
-
|
|
247
|
-
export default FormCheckInput;
|
|
1
|
+
import React, { useContext, useState } from 'react';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import StyleSheet from '../../style/StyleSheet';
|
|
5
|
+
import css from '../../style/css';
|
|
6
|
+
import { getStyles, each } from '../../utils';
|
|
7
|
+
import useMedia from '../../hooks/useMedia';
|
|
8
|
+
import useStyle from '../../hooks/useStyle';
|
|
9
|
+
import useModifier from '../../hooks/useModifier';
|
|
10
|
+
import { FORM_VALIDATION_STATES } from '../../theme/proxies';
|
|
11
|
+
import { escapeSvg } from '../../theme/functions';
|
|
12
|
+
import FormCheckContext from './FormCheckContext';
|
|
13
|
+
import FormCheckInputWeb from './internals/FormCheckInputWeb';
|
|
14
|
+
import FormCheckInputNative from './internals/FormCheckInputNative';
|
|
15
|
+
|
|
16
|
+
/* eslint-disable react/no-unused-prop-types */
|
|
17
|
+
const propTypes = {
|
|
18
|
+
type: PropTypes.oneOf(['checkbox', 'radio', 'switch']).isRequired,
|
|
19
|
+
value: PropTypes.bool.isRequired,
|
|
20
|
+
onFocus: PropTypes.func,
|
|
21
|
+
onBlur: PropTypes.func,
|
|
22
|
+
disabled: PropTypes.bool,
|
|
23
|
+
valid: PropTypes.bool,
|
|
24
|
+
invalid: PropTypes.bool,
|
|
25
|
+
useNativeComponent: PropTypes.bool,
|
|
26
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
27
|
+
style: PropTypes.any,
|
|
28
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
29
|
+
};
|
|
30
|
+
/* eslint-enable */
|
|
31
|
+
|
|
32
|
+
const styles = StyleSheet.create({
|
|
33
|
+
'.form-check .form-check-input': css`
|
|
34
|
+
$height: $line-height-base * 1rem;
|
|
35
|
+
$margin-top-double: $height - $form-check-input-width;
|
|
36
|
+
|
|
37
|
+
// float: left;
|
|
38
|
+
// margin-left: $form-check-padding-start * -1;
|
|
39
|
+
margin-top: $margin-top-double * 0.5; // added for bootstrap-rn
|
|
40
|
+
margin-right: $form-check-padding-start - $form-check-input-width; // added for bootstrap-rn
|
|
41
|
+
`,
|
|
42
|
+
'.form-check-reverse .form-check-input': css`
|
|
43
|
+
// float: right;
|
|
44
|
+
// margin-right: $form-check-padding-start * -1;
|
|
45
|
+
margin-right: 0; // added for bootstrap-rn
|
|
46
|
+
// margin-left: 0;
|
|
47
|
+
margin-left: $form-check-padding-start - $form-check-input-width; // added for bootstrap-rn
|
|
48
|
+
`,
|
|
49
|
+
'.form-check-input': css`
|
|
50
|
+
width: $form-check-input-width;
|
|
51
|
+
height: $form-check-input-width;
|
|
52
|
+
// margin-top: ($line-height-base - $form-check-input-width) * 0.5; // line-height minus check height
|
|
53
|
+
vertical-align: top;
|
|
54
|
+
background-color: $form-check-input-bg;
|
|
55
|
+
background-repeat: no-repeat;
|
|
56
|
+
background-position: center;
|
|
57
|
+
background-size: contain;
|
|
58
|
+
border: $form-check-input-border;
|
|
59
|
+
@include platform(web) {
|
|
60
|
+
appearance: none;
|
|
61
|
+
user-select: none; // added for bootstrap-rn
|
|
62
|
+
color-adjust: exact; // Keep themed appearance for print
|
|
63
|
+
}
|
|
64
|
+
// @include transition($form-check-transition);
|
|
65
|
+
|
|
66
|
+
&:active {
|
|
67
|
+
// filter: $form-check-input-active-filter;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&:focus {
|
|
71
|
+
border-color: $form-check-input-focus-border;
|
|
72
|
+
@include platform(web) {
|
|
73
|
+
outline-width: 0; // outline: 0;
|
|
74
|
+
box-shadow: $form-check-input-focus-box-shadow;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
`,
|
|
78
|
+
'.form-check-input[type="checkbox"]': css`
|
|
79
|
+
border-radius: $form-check-input-border-radius;
|
|
80
|
+
`,
|
|
81
|
+
'.form-check-input[type="radio"]': css`
|
|
82
|
+
border-radius: $form-check-radio-border-radius;
|
|
83
|
+
`,
|
|
84
|
+
'.form-check-input:checked': css`
|
|
85
|
+
background-color: $form-check-input-checked-bg-color;
|
|
86
|
+
border-color: $form-check-input-checked-border-color;
|
|
87
|
+
`,
|
|
88
|
+
'.form-check-input[type="checkbox"]:checked': css`
|
|
89
|
+
// @if $enable-gradients {
|
|
90
|
+
// background-image: escape-svg($form-check-input-checked-bg-image), var(--#{$variable-prefix}gradient);
|
|
91
|
+
// } @else {
|
|
92
|
+
background-image: ${(t) =>
|
|
93
|
+
escapeSvg(t['form-check-input-checked-bg-image'])};
|
|
94
|
+
// }
|
|
95
|
+
`,
|
|
96
|
+
'.form-check-input[type="radio"]:checked': css`
|
|
97
|
+
// @if $enable-gradients {
|
|
98
|
+
// background-image: escape-svg($form-check-radio-checked-bg-image), var(--#{$variable-prefix}gradient);
|
|
99
|
+
// } @else {
|
|
100
|
+
background-image: ${(t) =>
|
|
101
|
+
escapeSvg(t['form-check-radio-checked-bg-image'])};
|
|
102
|
+
// }
|
|
103
|
+
`,
|
|
104
|
+
'.form-check-input:disabled': css`
|
|
105
|
+
@include platform(web) {
|
|
106
|
+
pointer-events: none;
|
|
107
|
+
filter: none;
|
|
108
|
+
}
|
|
109
|
+
opacity: $form-check-label-disabled-opacity;
|
|
110
|
+
`,
|
|
111
|
+
...each(FORM_VALIDATION_STATES, (state, data) => ({
|
|
112
|
+
[`.form-check-input:${state}`]: css`
|
|
113
|
+
border-color: ${(t) => data(t).color};
|
|
114
|
+
|
|
115
|
+
&:focus {
|
|
116
|
+
border-color: ${(t) => data(t).color}; // added for bootstrap-rn
|
|
117
|
+
@include platform(web) {
|
|
118
|
+
box-shadow: 0 0 $input-btn-focus-blur $input-focus-width
|
|
119
|
+
rgba(${(t) => data(t).color}, $input-btn-focus-color-opacity);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
`,
|
|
123
|
+
[`.form-check-input:${state}:checked`]: css`
|
|
124
|
+
background-color: ${(t) => data(t).color};
|
|
125
|
+
`,
|
|
126
|
+
})),
|
|
127
|
+
'.form-switch.form-check .form-check-input': css`
|
|
128
|
+
// float: left;
|
|
129
|
+
// margin-left: $form-switch-padding-start * -1;
|
|
130
|
+
margin-right: $form-switch-padding-start - $form-switch-width; // added for bootstrap-rn
|
|
131
|
+
`,
|
|
132
|
+
'.form-switch.form-check-reverse .form-check-input': css`
|
|
133
|
+
// margin-right: $form-switch-padding-start * -1;
|
|
134
|
+
margin-right: 0; // added for bootstrap-rn
|
|
135
|
+
// margin-left: 0;
|
|
136
|
+
margin-left: $form-switch-padding-start - $form-switch-width; // added for bootstrap-rn
|
|
137
|
+
`,
|
|
138
|
+
'.form-switch .form-check-input': css`
|
|
139
|
+
width: $form-switch-width;
|
|
140
|
+
background-image: ${(t) => escapeSvg(t['form-switch-bg-image'])};
|
|
141
|
+
background-position: left center;
|
|
142
|
+
border-radius: $form-switch-border-radius;
|
|
143
|
+
// @include transition($form-switch-transition);
|
|
144
|
+
|
|
145
|
+
&:focus {
|
|
146
|
+
background-image: ${(t) => escapeSvg(t['form-switch-focus-bg-image'])};
|
|
147
|
+
}
|
|
148
|
+
`,
|
|
149
|
+
'.form-switch .form-check-input:checked': css`
|
|
150
|
+
background-position: $form-switch-checked-bg-position;
|
|
151
|
+
|
|
152
|
+
// @if $enable-gradients {
|
|
153
|
+
// background-image: escape-svg($form-switch-checked-bg-image), var(--#{$prefix}gradient);
|
|
154
|
+
// } @else {
|
|
155
|
+
background-image: ${(t) => escapeSvg(t['form-switch-checked-bg-image'])};
|
|
156
|
+
// }
|
|
157
|
+
|
|
158
|
+
&:focus {
|
|
159
|
+
background-image: ${(t) =>
|
|
160
|
+
escapeSvg(t['form-switch-checked-bg-image'])}; // added for bootstrap-rn
|
|
161
|
+
}
|
|
162
|
+
`,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const FormCheckInput = React.forwardRef((props, ref) => {
|
|
166
|
+
const [modifierProps, modifierRef] = useModifier('useFormField', props, ref);
|
|
167
|
+
|
|
168
|
+
const context = useContext(FormCheckContext);
|
|
169
|
+
|
|
170
|
+
const {
|
|
171
|
+
type,
|
|
172
|
+
value,
|
|
173
|
+
onFocus = () => {},
|
|
174
|
+
onBlur = () => {},
|
|
175
|
+
disabled = context ? context.disabled : false,
|
|
176
|
+
valid = context ? context.valid : false,
|
|
177
|
+
invalid = context ? context.invalid : false,
|
|
178
|
+
useNativeComponent = false,
|
|
179
|
+
autoFocus = false,
|
|
180
|
+
style,
|
|
181
|
+
...elementProps
|
|
182
|
+
} = modifierProps;
|
|
183
|
+
|
|
184
|
+
const media = useMedia();
|
|
185
|
+
const [focused, setFocused] = useState(autoFocus);
|
|
186
|
+
|
|
187
|
+
const classes = getStyles(styles, [
|
|
188
|
+
context && '.form-check .form-check-input',
|
|
189
|
+
context?.reverse && '.form-check-reverse .form-check-input',
|
|
190
|
+
'.form-check-input',
|
|
191
|
+
type === 'checkbox' && '.form-check-input[type="checkbox"]',
|
|
192
|
+
type === 'radio' && '.form-check-input[type="radio"]',
|
|
193
|
+
value && '.form-check-input:checked',
|
|
194
|
+
type === 'checkbox' &&
|
|
195
|
+
value &&
|
|
196
|
+
'.form-check-input[type="checkbox"]:checked',
|
|
197
|
+
type === 'radio' && value && '.form-check-input[type="radio"]:checked',
|
|
198
|
+
disabled && '.form-check-input:disabled',
|
|
199
|
+
// validation
|
|
200
|
+
valid && '.form-check-input:valid',
|
|
201
|
+
valid && value && '.form-check-input:valid:checked',
|
|
202
|
+
invalid && '.form-check-input:invalid',
|
|
203
|
+
invalid && value && '.form-check-input:invalid:checked',
|
|
204
|
+
// switch
|
|
205
|
+
context && type === 'switch' && '.form-switch.form-check .form-check-input',
|
|
206
|
+
context?.reverse &&
|
|
207
|
+
type === 'switch' &&
|
|
208
|
+
'.form-switch.form-check-reverse .form-check-input',
|
|
209
|
+
type === 'switch' && '.form-switch .form-check-input',
|
|
210
|
+
type === 'switch' && value && '.form-switch .form-check-input:checked',
|
|
211
|
+
]);
|
|
212
|
+
|
|
213
|
+
const resolveStyle = useStyle([classes, style]);
|
|
214
|
+
|
|
215
|
+
const BaseFormCheckInput =
|
|
216
|
+
Platform.OS === 'web' && !useNativeComponent
|
|
217
|
+
? FormCheckInputWeb
|
|
218
|
+
: FormCheckInputNative;
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
<BaseFormCheckInput
|
|
222
|
+
{...elementProps}
|
|
223
|
+
ref={modifierRef}
|
|
224
|
+
type={type}
|
|
225
|
+
value={value}
|
|
226
|
+
onFocus={() => {
|
|
227
|
+
setFocused(true);
|
|
228
|
+
onFocus();
|
|
229
|
+
}}
|
|
230
|
+
onBlur={() => {
|
|
231
|
+
setFocused(false);
|
|
232
|
+
onBlur();
|
|
233
|
+
}}
|
|
234
|
+
disabled={disabled}
|
|
235
|
+
autoFocus={autoFocus}
|
|
236
|
+
style={resolveStyle({
|
|
237
|
+
media,
|
|
238
|
+
interaction: { focus: focused, focusVisible: focused },
|
|
239
|
+
})}
|
|
240
|
+
/>
|
|
241
|
+
);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
FormCheckInput.displayName = 'FormCheckInput';
|
|
245
|
+
FormCheckInput.propTypes = propTypes;
|
|
246
|
+
|
|
247
|
+
export default FormCheckInput;
|
|
@@ -43,7 +43,7 @@ export const styles = StyleSheet.create({
|
|
|
43
43
|
border-bottom-right-radius: $list-group-border-radius;
|
|
44
44
|
`,
|
|
45
45
|
'.list-group-item.disabled': css`
|
|
46
|
-
|
|
46
|
+
pointer-events: none;
|
|
47
47
|
background-color: $list-group-disabled-bg;
|
|
48
48
|
`,
|
|
49
49
|
'.list-group-item.disabled --text': css`
|