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.
Files changed (71) hide show
  1. package/lib/commonjs/Provider.js +3 -0
  2. package/lib/commonjs/Provider.js.map +1 -1
  3. package/lib/commonjs/components/Caret.js +1 -1
  4. package/lib/commonjs/components/badge/Badge.js +1 -1
  5. package/lib/commonjs/components/buttons/Button.js +3 -3
  6. package/lib/commonjs/components/close/CloseButton.js +2 -2
  7. package/lib/commonjs/components/dropdown/DropdownItem.js +1 -1
  8. package/lib/commonjs/components/dropdown/useToggleDropdown.js +1 -0
  9. package/lib/commonjs/components/dropdown/useToggleDropdown.js.map +1 -1
  10. package/lib/commonjs/components/forms/FormCheckInput.js +1 -1
  11. package/lib/commonjs/components/list-group/ListGroupItem.js +1 -1
  12. package/lib/commonjs/components/modal/Modal.js +3 -8
  13. package/lib/commonjs/components/modal/Modal.js.map +1 -1
  14. package/lib/commonjs/components/modal/useModal.js +13 -1
  15. package/lib/commonjs/components/modal/useModal.js.map +1 -1
  16. package/lib/commonjs/components/navbar/NavbarToggler.js +1 -1
  17. package/lib/commonjs/components/offcanvas/Offcanvas.js +1 -6
  18. package/lib/commonjs/components/offcanvas/Offcanvas.js.map +1 -1
  19. package/lib/commonjs/components/offcanvas/useOffcanvas.js +13 -1
  20. package/lib/commonjs/components/offcanvas/useOffcanvas.js.map +1 -1
  21. package/lib/commonjs/components/toasts/Toast.js +1 -1
  22. package/lib/commonjs/components/toasts/ToastContainer.js +1 -1
  23. package/lib/commonjs/hooks/useScrollbarEffects.js +48 -41
  24. package/lib/commonjs/hooks/useScrollbarEffects.js.map +1 -1
  25. package/lib/commonjs/theme/utilities.js +8 -8
  26. package/lib/commonjs/theme/utilities.js.map +1 -1
  27. package/lib/module/Provider.js +3 -0
  28. package/lib/module/Provider.js.map +1 -1
  29. package/lib/module/components/Caret.js +1 -1
  30. package/lib/module/components/badge/Badge.js +1 -1
  31. package/lib/module/components/buttons/Button.js +3 -3
  32. package/lib/module/components/close/CloseButton.js +2 -2
  33. package/lib/module/components/dropdown/DropdownItem.js +1 -1
  34. package/lib/module/components/dropdown/useToggleDropdown.js +1 -0
  35. package/lib/module/components/dropdown/useToggleDropdown.js.map +1 -1
  36. package/lib/module/components/forms/FormCheckInput.js +1 -1
  37. package/lib/module/components/list-group/ListGroupItem.js +1 -1
  38. package/lib/module/components/modal/Modal.js +3 -8
  39. package/lib/module/components/modal/Modal.js.map +1 -1
  40. package/lib/module/components/modal/useModal.js +13 -2
  41. package/lib/module/components/modal/useModal.js.map +1 -1
  42. package/lib/module/components/navbar/NavbarToggler.js +1 -1
  43. package/lib/module/components/offcanvas/Offcanvas.js +1 -6
  44. package/lib/module/components/offcanvas/Offcanvas.js.map +1 -1
  45. package/lib/module/components/offcanvas/useOffcanvas.js +13 -2
  46. package/lib/module/components/offcanvas/useOffcanvas.js.map +1 -1
  47. package/lib/module/components/toasts/Toast.js +1 -1
  48. package/lib/module/components/toasts/ToastContainer.js +1 -1
  49. package/lib/module/hooks/useScrollbarEffects.js +49 -41
  50. package/lib/module/hooks/useScrollbarEffects.js.map +1 -1
  51. package/lib/module/theme/utilities.js +8 -8
  52. package/lib/module/theme/utilities.js.map +1 -1
  53. package/package.json +69 -69
  54. package/src/Provider.js +63 -59
  55. package/src/components/Caret.js +127 -127
  56. package/src/components/badge/Badge.js +52 -52
  57. package/src/components/buttons/Button.js +381 -381
  58. package/src/components/close/CloseButton.js +146 -146
  59. package/src/components/dropdown/DropdownItem.js +151 -151
  60. package/src/components/dropdown/useToggleDropdown.js +1 -0
  61. package/src/components/forms/FormCheckInput.js +247 -247
  62. package/src/components/list-group/ListGroupItem.js +1 -1
  63. package/src/components/modal/Modal.js +235 -241
  64. package/src/components/modal/useModal.js +25 -10
  65. package/src/components/navbar/NavbarToggler.js +132 -132
  66. package/src/components/offcanvas/Offcanvas.js +252 -258
  67. package/src/components/offcanvas/useOffcanvas.js +20 -5
  68. package/src/components/toasts/Toast.js +1 -1
  69. package/src/components/toasts/ToastContainer.js +43 -43
  70. package/src/hooks/useScrollbarEffects.js +82 -62
  71. package/src/theme/utilities.js +4 -4
@@ -1,381 +1,381 @@
1
- import React, { useContext } from 'react';
2
- import PropTypes from 'prop-types';
3
- import invariant from 'tiny-invariant';
4
- import StyleSheet from '../../style/StyleSheet';
5
- import css from '../../style/css';
6
- import Pressable from '../Pressable';
7
- import { getStyles, each } from '../../utils';
8
- import { THEME_COLORS } from '../../theme/proxies';
9
- import { shadeColor, colorContrast } from '../../theme/functions';
10
- import ButtonGroupContext from '../button-group/ButtonGroupContext';
11
- import useToggleButton from './useToggleButton';
12
- import ListContext from '../helpers/ListContext';
13
-
14
- const propTypes = {
15
- children: PropTypes.node.isRequired,
16
- color: PropTypes.oneOf([...Object.keys(THEME_COLORS), 'link']),
17
- size: PropTypes.oneOf(['lg', 'sm']),
18
- outline: PropTypes.bool,
19
- active: PropTypes.bool,
20
- disabled: PropTypes.bool,
21
- // eslint-disable-next-line react/forbid-prop-types
22
- style: PropTypes.any,
23
- // eslint-disable-next-line react/forbid-prop-types
24
- activeStyle: PropTypes.any,
25
- // eslint-disable-next-line react/forbid-prop-types
26
- textStyle: PropTypes.any,
27
- // eslint-disable-next-line react/forbid-prop-types
28
- activeTextStyle: PropTypes.any,
29
- };
30
-
31
- const styles = StyleSheet.create({
32
- '.btn': css`
33
- flex-direction: row; // added for bootstrap-rn
34
- justify-content: center; // added for bootstrap-rn
35
- // display: inline-block;
36
- @include platform(web) {
37
- // cursor: if($enable-button-pointers, pointer, null);
38
- user-select: none;
39
- }
40
- background-color: transparent;
41
- border: $btn-border-width solid transparent;
42
- padding: $btn-padding-y $btn-padding-x;
43
- // Manually declare to provide an override to the browser default
44
- border-radius: $btn-border-radius;
45
- // @include transition($btn-transition);
46
-
47
- &:focus-visible {
48
- // outline: 0;
49
- // box-shadow: $btn-focus-box-shadow;
50
- }
51
-
52
- &:active {
53
- // @include box-shadow($btn-active-box-shadow);
54
-
55
- &:focus-visible {
56
- // @include box-shadow($btn-focus-box-shadow, $btn-active-box-shadow);
57
- }
58
- }
59
- `,
60
- '.btn --text': css`
61
- font-family: $btn-font-family;
62
- font-weight: $btn-font-weight;
63
- line-height: $btn-font-size * $btn-line-height;
64
- color: $body-color;
65
- text-align: center;
66
- text-decoration: none; // if($link-decoration == none, null, none);
67
- white-space: $btn-white-space;
68
- // vertical-align: middle;
69
- font-size: $btn-font-size;
70
-
71
- &:hover {
72
- color: $body-color;
73
- text-decoration: none; // if($link-decoration == none, null, none);
74
- }
75
- `,
76
- '.btn.disabled': css`
77
- // pointer-events: none;
78
- opacity: $btn-disabled-opacity;
79
- // @include box-shadow(none);
80
- `,
81
- ...each(THEME_COLORS, (color, value) => ({
82
- [`.btn-${color}`]: css`
83
- background-color: ${value};
84
- border-color: ${value};
85
- // @include box-shadow($btn-box-shadow);
86
-
87
- &:hover {
88
- background-color: ${shadeColor(
89
- value,
90
- (t) => t['btn-hover-bg-shade-amount'],
91
- )};
92
- border-color: ${shadeColor(
93
- value,
94
- (t) => t['btn-hover-border-shade-amount'],
95
- )};
96
- }
97
-
98
- &:focus-visible {
99
- background-color: ${shadeColor(
100
- value,
101
- (t) => t['btn-hover-bg-shade-amount'],
102
- )};
103
- border-color: ${shadeColor(
104
- value,
105
- (t) => t['btn-hover-border-shade-amount'],
106
- )};
107
- /* @if $enable-shadows {
108
- @include box-shadow($btn-box-shadow, 0 0 0 $btn-focus-width rgba(mix($color, $border, 15%), .5));
109
- } @else {
110
- // Avoid using mixin so we can pass custom focus shadow properly
111
- box-shadow: 0 0 0 $btn-focus-width rgba(mix($color, $border, 15%), .5);
112
- } */
113
- }
114
-
115
- &:active {
116
- background-color: ${shadeColor(
117
- value,
118
- (t) => t['btn-active-bg-shade-amount'],
119
- )};
120
- // Remove CSS gradients if they're enabled
121
- // background-image: if($enable-gradients, none, null);
122
- border-color: ${shadeColor(
123
- value,
124
- (t) => t['btn-active-border-shade-amount'],
125
- )};
126
- }
127
- `,
128
- [`.btn-${color} --text`]: css`
129
- color: ${colorContrast(value)};
130
-
131
- &:hover {
132
- color: ${colorContrast(value)};
133
- }
134
-
135
- &:focus-visible {
136
- color: ${colorContrast(value)};
137
- }
138
-
139
- &:active {
140
- color: ${colorContrast(value)};
141
- }
142
- `,
143
- [`.btn-${color}.active`]: css`
144
- background-color: ${shadeColor(
145
- value,
146
- (t) => t['btn-active-bg-shade-amount'],
147
- )};
148
- // Remove CSS gradients if they're enabled
149
- // background-image: if($enable-gradients, none, null);
150
- border-color: ${shadeColor(
151
- value,
152
- (t) => t['btn-active-border-shade-amount'],
153
- )};
154
- `,
155
- [`.btn-${color}.active --text`]: css`
156
- color: ${colorContrast(value)};
157
- `,
158
- [`.btn-${color}.disabled`]: css`
159
- $disabled-background: ${value};
160
- $disabled-border: ${value};
161
-
162
- background-color: $disabled-background;
163
- // Remove CSS gradients if they're enabled
164
- // background-image: if($enable-gradients, none, null);
165
- border-color: $disabled-border;
166
- `,
167
- [`.btn-${color}.disabled --text`]: css`
168
- $disabled-color: ${colorContrast(value)};
169
-
170
- color: $disabled-color;
171
- `,
172
- [`.btn-outline-${color}`]: css`
173
- border-color: ${value};
174
-
175
- &:hover {
176
- background-color: ${value};
177
- border-color: ${value};
178
- }
179
-
180
- &:focus-visible {
181
- // box-shadow: 0 0 0 $btn-focus-width rgba($color, .5);
182
- }
183
-
184
- &:active {
185
- background-color: ${value};
186
- border-color: ${value};
187
-
188
- /* &:focus {
189
- @if $enable-shadows {
190
- @include box-shadow(
191
- $btn-active-box-shadow,
192
- 0 0 0 $btn-focus-width rgba($color, 0.5)
193
- );
194
- } @else {
195
- // Avoid using mixin so we can pass custom focus shadow properly
196
- box-shadow: 0 0 0 $btn-focus-width rgba($color, 0.5);
197
- }
198
- } */
199
- }
200
- `,
201
- [`.btn-outline-${color} --text`]: css`
202
- color: ${value};
203
-
204
- &:hover {
205
- color: ${colorContrast(value)};
206
- }
207
-
208
- &:active {
209
- color: ${colorContrast(value)};
210
- }
211
- `,
212
- [`.btn-outline-${color}.disabled`]: css`
213
- background-color: transparent;
214
- `,
215
- [`.btn-outline-${color}.disabled --text`]: css`
216
- color: ${value};
217
- `,
218
- })),
219
- '.btn-link --text': css`
220
- font-weight: $font-weight-normal;
221
- color: $btn-link-color;
222
- text-decoration-color: $btn-link-color; // added for bootstrap-rn
223
- text-decoration-line: $link-decoration;
224
-
225
- &:hover {
226
- color: $btn-link-hover-color;
227
- text-decoration-color: $btn-link-hover-color; // added for bootstrap-rn
228
- text-decoration-line: $link-hover-decoration;
229
- }
230
-
231
- &:focus-visible {
232
- text-decoration-line: $link-hover-decoration;
233
- }
234
-
235
- // No need for an active state here
236
- `,
237
- '.btn-link.disabled --text': css`
238
- color: $btn-link-disabled-color;
239
- `,
240
- '.btn-lg': css`
241
- padding: $btn-padding-y-lg $btn-padding-x-lg;
242
- // Manually declare to provide an override to the browser default
243
- border-radius: $btn-border-radius-lg;
244
- `,
245
- '.btn-lg --text': css`
246
- line-height: $btn-font-size-lg * $btn-line-height;
247
- font-size: $btn-font-size-lg;
248
- `,
249
- '.btn-sm': css`
250
- padding: $btn-padding-y-sm $btn-padding-x-sm;
251
- // Manually declare to provide an override to the browser default
252
- border-radius: $btn-border-radius-sm;
253
- `,
254
- '.btn-sm --text': css`
255
- line-height: $btn-font-size-sm * $btn-line-height;
256
- font-size: $btn-font-size-sm;
257
- `,
258
- '.btn-group > .btn': css`
259
- position: relative;
260
- // flex: 1 1 auto;
261
-
262
- &:hover {
263
- z-index: 1;
264
- }
265
- &:focus-visible {
266
- z-index: 1;
267
- }
268
- &:active {
269
- z-index: 1;
270
- }
271
- `,
272
- '.btn-group > .btn.active': css`
273
- z-index: 2; // 1;
274
- `,
275
- '.btn-group > .btn:not(:first-child)': css`
276
- margin-left: -$btn-border-width;
277
- border-top-left-radius: 0;
278
- border-bottom-left-radius: 0;
279
- `,
280
- '.btn-group > .btn:not(:last-child)': css`
281
- border-top-right-radius: 0;
282
- border-bottom-right-radius: 0;
283
- `,
284
- });
285
-
286
- const getVariant = (color, outline) => {
287
- if (color === 'link') {
288
- return null;
289
- }
290
-
291
- if (outline) {
292
- return `.btn-outline-${color}`;
293
- }
294
-
295
- return `.btn-${color}`;
296
- };
297
-
298
- const hasSize = (size, group, value) => {
299
- if (size !== undefined || !group) {
300
- return size === value;
301
- }
302
-
303
- return group.size === value;
304
- };
305
-
306
- const Button = React.forwardRef((props, ref) => {
307
- const {
308
- children,
309
- color = 'primary',
310
- size,
311
- outline = false,
312
- active = false,
313
- disabled = false,
314
- style,
315
- activeStyle,
316
- textStyle,
317
- activeTextStyle,
318
- ...elementProps
319
- } = props;
320
-
321
- invariant(
322
- color !== 'link' || !outline,
323
- 'Button link variant is only available as non outline style.',
324
- );
325
-
326
- const listItem = useContext(ListContext);
327
- const group = useContext(ButtonGroupContext);
328
-
329
- const classes = getStyles(styles, [
330
- '.btn',
331
- getVariant(color, outline),
332
- disabled && '.btn.disabled',
333
- disabled && `${getVariant(color, outline)}.disabled`,
334
- hasSize(size, group, 'lg') && '.btn-lg',
335
- hasSize(size, group, 'sm') && '.btn-sm',
336
- group && '.btn-group > .btn',
337
- group && active && '.btn-group > .btn.active',
338
- group && !listItem.first && '.btn-group > .btn:not(:first-child)',
339
- group && !listItem.last && '.btn-group > .btn:not(:last-child)',
340
- ]);
341
-
342
- const activeClasses = getStyles(styles, [
343
- `${getVariant(color, outline)}.active`,
344
- ]);
345
-
346
- const textClasses = getStyles(styles, [
347
- '.btn --text',
348
- `${getVariant(color, outline)} --text`,
349
- color === 'link' && '.btn-link --text',
350
- disabled && `${getVariant(color, outline)}.disabled --text`,
351
- disabled && color === 'link' && '.btn-link.disabled --text',
352
- hasSize(size, group, 'lg') && '.btn-lg --text',
353
- hasSize(size, group, 'sm') && '.btn-sm --text',
354
- ]);
355
-
356
- const activeTextClasses = getStyles(styles, [
357
- `${getVariant(color, outline)}.active --text`,
358
- ]);
359
-
360
- return (
361
- <Pressable
362
- {...elementProps}
363
- ref={ref}
364
- active={active}
365
- disabled={disabled}
366
- style={[...classes, style]}
367
- activeStyle={[...activeClasses, activeStyle]}
368
- textStyle={[...textClasses, textStyle]}
369
- activeTextStyle={[...activeTextClasses, activeTextStyle]}
370
- >
371
- {children}
372
- </Pressable>
373
- );
374
- });
375
-
376
- Button.displayName = 'Button';
377
- Button.propTypes = propTypes;
378
-
379
- Button.useToggle = useToggleButton;
380
-
381
- export default Button;
1
+ import React, { useContext } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import invariant from 'tiny-invariant';
4
+ import StyleSheet from '../../style/StyleSheet';
5
+ import css from '../../style/css';
6
+ import Pressable from '../Pressable';
7
+ import { getStyles, each } from '../../utils';
8
+ import { THEME_COLORS } from '../../theme/proxies';
9
+ import { shadeColor, colorContrast } from '../../theme/functions';
10
+ import ButtonGroupContext from '../button-group/ButtonGroupContext';
11
+ import useToggleButton from './useToggleButton';
12
+ import ListContext from '../helpers/ListContext';
13
+
14
+ const propTypes = {
15
+ children: PropTypes.node.isRequired,
16
+ color: PropTypes.oneOf([...Object.keys(THEME_COLORS), 'link']),
17
+ size: PropTypes.oneOf(['lg', 'sm']),
18
+ outline: PropTypes.bool,
19
+ active: PropTypes.bool,
20
+ disabled: PropTypes.bool,
21
+ // eslint-disable-next-line react/forbid-prop-types
22
+ style: PropTypes.any,
23
+ // eslint-disable-next-line react/forbid-prop-types
24
+ activeStyle: PropTypes.any,
25
+ // eslint-disable-next-line react/forbid-prop-types
26
+ textStyle: PropTypes.any,
27
+ // eslint-disable-next-line react/forbid-prop-types
28
+ activeTextStyle: PropTypes.any,
29
+ };
30
+
31
+ const styles = StyleSheet.create({
32
+ '.btn': css`
33
+ flex-direction: row; // added for bootstrap-rn
34
+ justify-content: center; // added for bootstrap-rn
35
+ // display: inline-block;
36
+ @include platform(web) {
37
+ // cursor: if($enable-button-pointers, pointer, null);
38
+ }
39
+ user-select: none;
40
+ background-color: transparent;
41
+ border: $btn-border-width solid transparent;
42
+ padding: $btn-padding-y $btn-padding-x;
43
+ // Manually declare to provide an override to the browser default
44
+ border-radius: $btn-border-radius;
45
+ // @include transition($btn-transition);
46
+
47
+ &:focus-visible {
48
+ // outline: 0;
49
+ // box-shadow: $btn-focus-box-shadow;
50
+ }
51
+
52
+ &:active {
53
+ // @include box-shadow($btn-active-box-shadow);
54
+
55
+ &:focus-visible {
56
+ // @include box-shadow($btn-focus-box-shadow, $btn-active-box-shadow);
57
+ }
58
+ }
59
+ `,
60
+ '.btn --text': css`
61
+ font-family: $btn-font-family;
62
+ font-weight: $btn-font-weight;
63
+ line-height: $btn-font-size * $btn-line-height;
64
+ color: $body-color;
65
+ text-align: center;
66
+ text-decoration: none; // if($link-decoration == none, null, none);
67
+ white-space: $btn-white-space;
68
+ vertical-align: middle;
69
+ font-size: $btn-font-size;
70
+
71
+ &:hover {
72
+ color: $body-color;
73
+ text-decoration: none; // if($link-decoration == none, null, none);
74
+ }
75
+ `,
76
+ '.btn.disabled': css`
77
+ pointer-events: none;
78
+ opacity: $btn-disabled-opacity;
79
+ // @include box-shadow(none);
80
+ `,
81
+ ...each(THEME_COLORS, (color, value) => ({
82
+ [`.btn-${color}`]: css`
83
+ background-color: ${value};
84
+ border-color: ${value};
85
+ // @include box-shadow($btn-box-shadow);
86
+
87
+ &:hover {
88
+ background-color: ${shadeColor(
89
+ value,
90
+ (t) => t['btn-hover-bg-shade-amount'],
91
+ )};
92
+ border-color: ${shadeColor(
93
+ value,
94
+ (t) => t['btn-hover-border-shade-amount'],
95
+ )};
96
+ }
97
+
98
+ &:focus-visible {
99
+ background-color: ${shadeColor(
100
+ value,
101
+ (t) => t['btn-hover-bg-shade-amount'],
102
+ )};
103
+ border-color: ${shadeColor(
104
+ value,
105
+ (t) => t['btn-hover-border-shade-amount'],
106
+ )};
107
+ /* @if $enable-shadows {
108
+ @include box-shadow($btn-box-shadow, 0 0 0 $btn-focus-width rgba(mix($color, $border, 15%), .5));
109
+ } @else {
110
+ // Avoid using mixin so we can pass custom focus shadow properly
111
+ box-shadow: 0 0 0 $btn-focus-width rgba(mix($color, $border, 15%), .5);
112
+ } */
113
+ }
114
+
115
+ &:active {
116
+ background-color: ${shadeColor(
117
+ value,
118
+ (t) => t['btn-active-bg-shade-amount'],
119
+ )};
120
+ // Remove CSS gradients if they're enabled
121
+ // background-image: if($enable-gradients, none, null);
122
+ border-color: ${shadeColor(
123
+ value,
124
+ (t) => t['btn-active-border-shade-amount'],
125
+ )};
126
+ }
127
+ `,
128
+ [`.btn-${color} --text`]: css`
129
+ color: ${colorContrast(value)};
130
+
131
+ &:hover {
132
+ color: ${colorContrast(value)};
133
+ }
134
+
135
+ &:focus-visible {
136
+ color: ${colorContrast(value)};
137
+ }
138
+
139
+ &:active {
140
+ color: ${colorContrast(value)};
141
+ }
142
+ `,
143
+ [`.btn-${color}.active`]: css`
144
+ background-color: ${shadeColor(
145
+ value,
146
+ (t) => t['btn-active-bg-shade-amount'],
147
+ )};
148
+ // Remove CSS gradients if they're enabled
149
+ // background-image: if($enable-gradients, none, null);
150
+ border-color: ${shadeColor(
151
+ value,
152
+ (t) => t['btn-active-border-shade-amount'],
153
+ )};
154
+ `,
155
+ [`.btn-${color}.active --text`]: css`
156
+ color: ${colorContrast(value)};
157
+ `,
158
+ [`.btn-${color}.disabled`]: css`
159
+ $disabled-background: ${value};
160
+ $disabled-border: ${value};
161
+
162
+ background-color: $disabled-background;
163
+ // Remove CSS gradients if they're enabled
164
+ // background-image: if($enable-gradients, none, null);
165
+ border-color: $disabled-border;
166
+ `,
167
+ [`.btn-${color}.disabled --text`]: css`
168
+ $disabled-color: ${colorContrast(value)};
169
+
170
+ color: $disabled-color;
171
+ `,
172
+ [`.btn-outline-${color}`]: css`
173
+ border-color: ${value};
174
+
175
+ &:hover {
176
+ background-color: ${value};
177
+ border-color: ${value};
178
+ }
179
+
180
+ &:focus-visible {
181
+ // box-shadow: 0 0 0 $btn-focus-width rgba($color, .5);
182
+ }
183
+
184
+ &:active {
185
+ background-color: ${value};
186
+ border-color: ${value};
187
+
188
+ /* &:focus {
189
+ @if $enable-shadows {
190
+ @include box-shadow(
191
+ $btn-active-box-shadow,
192
+ 0 0 0 $btn-focus-width rgba($color, 0.5)
193
+ );
194
+ } @else {
195
+ // Avoid using mixin so we can pass custom focus shadow properly
196
+ box-shadow: 0 0 0 $btn-focus-width rgba($color, 0.5);
197
+ }
198
+ } */
199
+ }
200
+ `,
201
+ [`.btn-outline-${color} --text`]: css`
202
+ color: ${value};
203
+
204
+ &:hover {
205
+ color: ${colorContrast(value)};
206
+ }
207
+
208
+ &:active {
209
+ color: ${colorContrast(value)};
210
+ }
211
+ `,
212
+ [`.btn-outline-${color}.disabled`]: css`
213
+ background-color: transparent;
214
+ `,
215
+ [`.btn-outline-${color}.disabled --text`]: css`
216
+ color: ${value};
217
+ `,
218
+ })),
219
+ '.btn-link --text': css`
220
+ font-weight: $font-weight-normal;
221
+ color: $btn-link-color;
222
+ text-decoration-color: $btn-link-color; // added for bootstrap-rn
223
+ text-decoration-line: $link-decoration;
224
+
225
+ &:hover {
226
+ color: $btn-link-hover-color;
227
+ text-decoration-color: $btn-link-hover-color; // added for bootstrap-rn
228
+ text-decoration-line: $link-hover-decoration;
229
+ }
230
+
231
+ &:focus-visible {
232
+ text-decoration-line: $link-hover-decoration;
233
+ }
234
+
235
+ // No need for an active state here
236
+ `,
237
+ '.btn-link.disabled --text': css`
238
+ color: $btn-link-disabled-color;
239
+ `,
240
+ '.btn-lg': css`
241
+ padding: $btn-padding-y-lg $btn-padding-x-lg;
242
+ // Manually declare to provide an override to the browser default
243
+ border-radius: $btn-border-radius-lg;
244
+ `,
245
+ '.btn-lg --text': css`
246
+ line-height: $btn-font-size-lg * $btn-line-height;
247
+ font-size: $btn-font-size-lg;
248
+ `,
249
+ '.btn-sm': css`
250
+ padding: $btn-padding-y-sm $btn-padding-x-sm;
251
+ // Manually declare to provide an override to the browser default
252
+ border-radius: $btn-border-radius-sm;
253
+ `,
254
+ '.btn-sm --text': css`
255
+ line-height: $btn-font-size-sm * $btn-line-height;
256
+ font-size: $btn-font-size-sm;
257
+ `,
258
+ '.btn-group > .btn': css`
259
+ position: relative;
260
+ // flex: 1 1 auto;
261
+
262
+ &:hover {
263
+ z-index: 1;
264
+ }
265
+ &:focus-visible {
266
+ z-index: 1;
267
+ }
268
+ &:active {
269
+ z-index: 1;
270
+ }
271
+ `,
272
+ '.btn-group > .btn.active': css`
273
+ z-index: 2; // 1;
274
+ `,
275
+ '.btn-group > .btn:not(:first-child)': css`
276
+ margin-left: -$btn-border-width;
277
+ border-top-left-radius: 0;
278
+ border-bottom-left-radius: 0;
279
+ `,
280
+ '.btn-group > .btn:not(:last-child)': css`
281
+ border-top-right-radius: 0;
282
+ border-bottom-right-radius: 0;
283
+ `,
284
+ });
285
+
286
+ const getVariant = (color, outline) => {
287
+ if (color === 'link') {
288
+ return null;
289
+ }
290
+
291
+ if (outline) {
292
+ return `.btn-outline-${color}`;
293
+ }
294
+
295
+ return `.btn-${color}`;
296
+ };
297
+
298
+ const hasSize = (size, group, value) => {
299
+ if (size !== undefined || !group) {
300
+ return size === value;
301
+ }
302
+
303
+ return group.size === value;
304
+ };
305
+
306
+ const Button = React.forwardRef((props, ref) => {
307
+ const {
308
+ children,
309
+ color = 'primary',
310
+ size,
311
+ outline = false,
312
+ active = false,
313
+ disabled = false,
314
+ style,
315
+ activeStyle,
316
+ textStyle,
317
+ activeTextStyle,
318
+ ...elementProps
319
+ } = props;
320
+
321
+ invariant(
322
+ color !== 'link' || !outline,
323
+ 'Button link variant is only available as non outline style.',
324
+ );
325
+
326
+ const listItem = useContext(ListContext);
327
+ const group = useContext(ButtonGroupContext);
328
+
329
+ const classes = getStyles(styles, [
330
+ '.btn',
331
+ getVariant(color, outline),
332
+ disabled && '.btn.disabled',
333
+ disabled && `${getVariant(color, outline)}.disabled`,
334
+ hasSize(size, group, 'lg') && '.btn-lg',
335
+ hasSize(size, group, 'sm') && '.btn-sm',
336
+ group && '.btn-group > .btn',
337
+ group && active && '.btn-group > .btn.active',
338
+ group && !listItem.first && '.btn-group > .btn:not(:first-child)',
339
+ group && !listItem.last && '.btn-group > .btn:not(:last-child)',
340
+ ]);
341
+
342
+ const activeClasses = getStyles(styles, [
343
+ `${getVariant(color, outline)}.active`,
344
+ ]);
345
+
346
+ const textClasses = getStyles(styles, [
347
+ '.btn --text',
348
+ `${getVariant(color, outline)} --text`,
349
+ color === 'link' && '.btn-link --text',
350
+ disabled && `${getVariant(color, outline)}.disabled --text`,
351
+ disabled && color === 'link' && '.btn-link.disabled --text',
352
+ hasSize(size, group, 'lg') && '.btn-lg --text',
353
+ hasSize(size, group, 'sm') && '.btn-sm --text',
354
+ ]);
355
+
356
+ const activeTextClasses = getStyles(styles, [
357
+ `${getVariant(color, outline)}.active --text`,
358
+ ]);
359
+
360
+ return (
361
+ <Pressable
362
+ {...elementProps}
363
+ ref={ref}
364
+ active={active}
365
+ disabled={disabled}
366
+ style={[...classes, style]}
367
+ activeStyle={[...activeClasses, activeStyle]}
368
+ textStyle={[...textClasses, textStyle]}
369
+ activeTextStyle={[...activeTextClasses, activeTextStyle]}
370
+ >
371
+ {children}
372
+ </Pressable>
373
+ );
374
+ });
375
+
376
+ Button.displayName = 'Button';
377
+ Button.propTypes = propTypes;
378
+
379
+ Button.useToggle = useToggleButton;
380
+
381
+ export default Button;