bootstrap-rn 0.4.10 → 0.4.12
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/module/components/close/CloseButton.js +1 -1
- package/lib/module/components/close/CloseButton.js.map +1 -1
- package/lib/module/components/collapse/Collapse.js +1 -0
- package/lib/module/components/collapse/Collapse.js.map +1 -1
- package/lib/module/components/forms/FormCheckInput.js +1 -5
- package/lib/module/components/forms/FormCheckInput.js.map +1 -1
- package/lib/module/components/forms/Picker.js +24 -35
- package/lib/module/components/forms/Picker.js.map +1 -1
- package/lib/module/components/forms/PickerItem.js +1 -9
- package/lib/module/components/forms/PickerItem.js.map +1 -1
- package/lib/module/components/forms/Radio.js +1 -0
- package/lib/module/components/forms/Radio.js.map +1 -1
- package/lib/module/components/forms/internals/{FormCheckInputNative.js → FormCheckInput.js} +4 -4
- package/lib/module/components/forms/internals/FormCheckInput.js.map +1 -0
- package/lib/module/components/forms/internals/{FormCheckInputWeb.js → FormCheckInput.web.js} +4 -4
- package/lib/module/components/forms/internals/FormCheckInput.web.js.map +1 -0
- package/lib/module/components/forms/internals/{PickerNative.js → Picker.js} +4 -4
- package/lib/module/components/forms/internals/Picker.js.map +1 -0
- package/lib/module/components/forms/internals/{PickerWeb.js → Picker.web.js} +4 -4
- package/lib/module/components/forms/internals/Picker.web.js.map +1 -0
- package/lib/module/components/forms/internals/{PickerNativeItem.js → PickerItem.js} +3 -3
- package/lib/module/components/forms/internals/PickerItem.js.map +1 -0
- package/lib/module/components/forms/internals/{PickerWebItem.js → PickerItem.web.js} +3 -3
- package/lib/module/components/forms/internals/PickerItem.web.js.map +1 -0
- package/lib/module/components/helpers/Portal.js +20 -1
- package/lib/module/components/helpers/Portal.js.map +1 -1
- package/lib/module/components/helpers/Portal.web.js +10 -2
- package/lib/module/components/helpers/Portal.web.js.map +1 -1
- package/lib/module/components/helpers/PortalHost.web.js +4 -1
- package/lib/module/components/helpers/PortalHost.web.js.map +1 -1
- package/lib/module/components/list-group/ListGroup.js +1 -0
- package/lib/module/components/list-group/ListGroup.js.map +1 -1
- package/lib/module/components/navbar/NavbarToggler.js +1 -1
- package/lib/module/components/navbar/NavbarToggler.js.map +1 -1
- package/lib/module/components/popover/Popover.js +1 -0
- package/lib/module/components/popover/Popover.js.map +1 -1
- package/lib/module/components/progress/Progress.js +1 -0
- package/lib/module/components/progress/Progress.js.map +1 -1
- package/lib/module/components/tooltip/Tooltip.js +1 -0
- package/lib/module/components/tooltip/Tooltip.js.map +1 -1
- package/lib/module/components/type/Paragraph.js +2 -2
- package/lib/module/components/type/Paragraph.js.map +1 -1
- package/lib/module/hooks/useBackground.js +167 -4
- package/lib/module/hooks/useBackground.js.map +1 -1
- package/lib/module/hooks/{useBackgroundWeb.js → useBackground.web.js} +2 -2
- package/lib/module/hooks/useBackground.web.js.map +1 -0
- package/lib/module/hooks/useOverlay.web.js +6 -1
- package/lib/module/hooks/useOverlay.web.js.map +1 -1
- package/lib/module/hooks/usePortalRegistry.js +26 -0
- package/lib/module/hooks/usePortalRegistry.js.map +1 -0
- package/lib/typescript/components/collapse/Collapse.d.ts +5 -0
- package/lib/typescript/components/collapse/Collapse.d.ts.map +1 -1
- package/lib/typescript/components/forms/FormCheckInput.d.ts +0 -1
- package/lib/typescript/components/forms/FormCheckInput.d.ts.map +1 -1
- package/lib/typescript/components/forms/Picker.d.ts +0 -1
- package/lib/typescript/components/forms/Picker.d.ts.map +1 -1
- package/lib/typescript/components/forms/PickerItem.d.ts.map +1 -1
- package/lib/typescript/components/forms/Radio.d.ts +5 -0
- package/lib/typescript/components/forms/Radio.d.ts.map +1 -1
- package/lib/typescript/components/forms/internals/FormCheckInput.d.ts +10 -0
- package/lib/typescript/components/forms/internals/FormCheckInput.d.ts.map +1 -0
- package/lib/typescript/components/forms/internals/FormCheckInput.web.d.ts +10 -0
- package/lib/typescript/components/forms/internals/FormCheckInput.web.d.ts.map +1 -0
- package/lib/typescript/components/forms/internals/Picker.d.ts +10 -0
- package/lib/typescript/components/forms/internals/Picker.d.ts.map +1 -0
- package/lib/typescript/components/forms/internals/Picker.web.d.ts +10 -0
- package/lib/typescript/components/forms/internals/Picker.web.d.ts.map +1 -0
- package/lib/typescript/components/forms/internals/PickerItem.d.ts +10 -0
- package/lib/typescript/components/forms/internals/PickerItem.d.ts.map +1 -0
- package/lib/typescript/components/forms/internals/PickerItem.web.d.ts +10 -0
- package/lib/typescript/components/forms/internals/PickerItem.web.d.ts.map +1 -0
- package/lib/typescript/components/helpers/Portal.d.ts +2 -1
- package/lib/typescript/components/helpers/Portal.d.ts.map +1 -1
- package/lib/typescript/components/helpers/Portal.web.d.ts +2 -1
- package/lib/typescript/components/helpers/Portal.web.d.ts.map +1 -1
- package/lib/typescript/components/list-group/ListGroup.d.ts +3 -0
- package/lib/typescript/components/list-group/ListGroup.d.ts.map +1 -1
- package/lib/typescript/components/list-group/ListGroupContext.d.ts +2 -2
- package/lib/typescript/components/list-group/ListGroupContext.d.ts.map +1 -1
- package/lib/typescript/components/popover/Popover.d.ts +4 -0
- package/lib/typescript/components/popover/Popover.d.ts.map +1 -1
- package/lib/typescript/components/progress/Progress.d.ts +4 -0
- package/lib/typescript/components/progress/Progress.d.ts.map +1 -1
- package/lib/typescript/components/tooltip/Tooltip.d.ts +4 -0
- package/lib/typescript/components/tooltip/Tooltip.d.ts.map +1 -1
- package/lib/typescript/components/type/Paragraph.d.ts +2 -2
- package/lib/typescript/components/type/Paragraph.d.ts.map +1 -1
- package/lib/typescript/hooks/useBackground.d.ts +8 -4
- package/lib/typescript/hooks/useBackground.d.ts.map +1 -1
- package/lib/typescript/hooks/useBackground.web.d.ts +6 -0
- package/lib/typescript/hooks/useBackground.web.d.ts.map +1 -0
- package/lib/typescript/hooks/useOverlay.web.d.ts +5 -2
- package/lib/typescript/hooks/useOverlay.web.d.ts.map +1 -1
- package/lib/typescript/hooks/usePortalRegistry.d.ts +2 -0
- package/lib/typescript/hooks/usePortalRegistry.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/buttons/Button.tsx +380 -380
- package/src/components/collapse/Collapse.tsx +1 -0
- package/src/components/forms/FormCheckInput.tsx +1 -10
- package/src/components/forms/Input.tsx +219 -219
- package/src/components/forms/Picker.tsx +24 -40
- package/src/components/forms/PickerItem.tsx +1 -12
- package/src/components/forms/Radio.tsx +1 -0
- package/src/components/forms/RadioContext.ts +13 -13
- package/src/components/forms/internals/{FormCheckInputNative.tsx → FormCheckInput.tsx} +4 -4
- package/src/components/forms/internals/{FormCheckInputWeb.tsx → FormCheckInput.web.tsx} +4 -4
- package/src/components/forms/internals/{PickerNative.tsx → Picker.tsx} +3 -5
- package/src/components/forms/internals/{PickerWeb.tsx → Picker.web.tsx} +3 -3
- package/src/components/forms/internals/{PickerNativeItem.tsx → PickerItem.tsx} +3 -5
- package/src/components/forms/internals/{PickerWebItem.tsx → PickerItem.web.tsx} +3 -5
- package/src/components/forms/internals/PickerNativeContext.ts +14 -14
- package/src/components/helpers/Portal.tsx +16 -2
- package/src/components/helpers/Portal.web.tsx +16 -4
- package/src/components/helpers/PortalHost.web.tsx +1 -1
- package/src/components/list-group/ListGroup.tsx +1 -0
- package/src/components/list-group/ListGroupContext.ts +11 -11
- package/src/components/popover/Popover.tsx +1 -0
- package/src/components/popover/PopoverContext.ts +13 -13
- package/src/components/progress/Progress.tsx +1 -0
- package/src/components/tooltip/Tooltip.tsx +1 -0
- package/src/components/tooltip/TooltipContext.ts +13 -13
- package/src/components/type/Paragraph.tsx +2 -2
- package/src/hooks/useBackground.tsx +203 -4
- package/src/hooks/{useBackgroundWeb.tsx → useBackground.web.tsx} +1 -1
- package/src/hooks/useOverlay.web.ts +20 -3
- package/src/hooks/usePortalRegistry.ts +36 -0
- package/lib/module/components/forms/PickerContext.js +0 -7
- package/lib/module/components/forms/PickerContext.js.map +0 -1
- package/lib/module/components/forms/internals/FormCheckInputNative.js.map +0 -1
- package/lib/module/components/forms/internals/FormCheckInputWeb.js.map +0 -1
- package/lib/module/components/forms/internals/PickerNative.js.map +0 -1
- package/lib/module/components/forms/internals/PickerNativeItem.js.map +0 -1
- package/lib/module/components/forms/internals/PickerWeb.js.map +0 -1
- package/lib/module/components/forms/internals/PickerWebItem.js.map +0 -1
- package/lib/module/hooks/useBackgroundNative.js +0 -170
- package/lib/module/hooks/useBackgroundNative.js.map +0 -1
- package/lib/module/hooks/useBackgroundWeb.js.map +0 -1
- package/lib/typescript/components/forms/PickerContext.d.ts +0 -7
- package/lib/typescript/components/forms/PickerContext.d.ts.map +0 -1
- package/lib/typescript/components/forms/internals/FormCheckInputNative.d.ts +0 -10
- package/lib/typescript/components/forms/internals/FormCheckInputNative.d.ts.map +0 -1
- package/lib/typescript/components/forms/internals/FormCheckInputWeb.d.ts +0 -10
- package/lib/typescript/components/forms/internals/FormCheckInputWeb.d.ts.map +0 -1
- package/lib/typescript/components/forms/internals/PickerNative.d.ts +0 -10
- package/lib/typescript/components/forms/internals/PickerNative.d.ts.map +0 -1
- package/lib/typescript/components/forms/internals/PickerNativeItem.d.ts +0 -10
- package/lib/typescript/components/forms/internals/PickerNativeItem.d.ts.map +0 -1
- package/lib/typescript/components/forms/internals/PickerWeb.d.ts +0 -10
- package/lib/typescript/components/forms/internals/PickerWeb.d.ts.map +0 -1
- package/lib/typescript/components/forms/internals/PickerWebItem.d.ts +0 -10
- package/lib/typescript/components/forms/internals/PickerWebItem.d.ts.map +0 -1
- package/lib/typescript/hooks/useBackgroundNative.d.ts +0 -9
- package/lib/typescript/hooks/useBackgroundNative.d.ts.map +0 -1
- package/lib/typescript/hooks/useBackgroundWeb.d.ts +0 -6
- package/lib/typescript/hooks/useBackgroundWeb.d.ts.map +0 -1
- package/src/components/forms/PickerContext.ts +0 -11
- package/src/hooks/useBackgroundNative.tsx +0 -204
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { useContext, useState } from 'react';
|
|
2
|
-
import { Platform } from 'react-native';
|
|
3
2
|
import StyleSheet from '../../style/StyleSheet';
|
|
4
3
|
import css from '../../style/css';
|
|
5
4
|
import { getStyles, each } from '../../utils';
|
|
@@ -10,8 +9,7 @@ import useModifier from '../../hooks/useModifier';
|
|
|
10
9
|
import { FORM_VALIDATION_STATES } from '../../theme/proxies';
|
|
11
10
|
import { escapeSvg } from '../../theme/functions';
|
|
12
11
|
import FormCheckContext from './FormCheckContext';
|
|
13
|
-
import
|
|
14
|
-
import FormCheckInputNative from './internals/FormCheckInputNative';
|
|
12
|
+
import BaseFormCheckInput from './internals/FormCheckInput';
|
|
15
13
|
import type {
|
|
16
14
|
ExtendedViewStyle,
|
|
17
15
|
FormValidationState,
|
|
@@ -29,7 +27,6 @@ export interface FormCheckInputProps extends UseFormFieldProps {
|
|
|
29
27
|
disabled?: boolean;
|
|
30
28
|
valid?: boolean;
|
|
31
29
|
invalid?: boolean;
|
|
32
|
-
useNativeComponent?: boolean;
|
|
33
30
|
autoFocus?: boolean;
|
|
34
31
|
hitSlop?: number;
|
|
35
32
|
style?: StyleProp<ExtendedViewStyle>;
|
|
@@ -192,7 +189,6 @@ function FormCheckInput(
|
|
|
192
189
|
disabled = context ? context.disabled : false,
|
|
193
190
|
valid = context ? context.valid : false,
|
|
194
191
|
invalid = context ? context.invalid : false,
|
|
195
|
-
useNativeComponent = false,
|
|
196
192
|
autoFocus = false,
|
|
197
193
|
style,
|
|
198
194
|
...elementProps
|
|
@@ -229,11 +225,6 @@ function FormCheckInput(
|
|
|
229
225
|
|
|
230
226
|
const resolveStyle = useStyle([classes, style]);
|
|
231
227
|
|
|
232
|
-
const BaseFormCheckInput =
|
|
233
|
-
Platform.OS === 'web' && !useNativeComponent
|
|
234
|
-
? FormCheckInputWeb
|
|
235
|
-
: FormCheckInputNative;
|
|
236
|
-
|
|
237
228
|
return (
|
|
238
229
|
<BaseFormCheckInput
|
|
239
230
|
{...elementProps}
|
|
@@ -1,219 +1,219 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import StyleSheet from '../../style/StyleSheet';
|
|
3
|
-
import css from '../../style/css';
|
|
4
|
-
import TextInput, { TextInputProps, TextInputRef } from '../TextInput';
|
|
5
|
-
import { getStyles, each } from '../../utils';
|
|
6
|
-
import useModifier from '../../hooks/useModifier';
|
|
7
|
-
import { FORM_VALIDATION_STATES } from '../../theme/proxies';
|
|
8
|
-
import type {
|
|
9
|
-
FormValidationState,
|
|
10
|
-
ThemeVariables,
|
|
11
|
-
UseFormFieldProps,
|
|
12
|
-
} from '../../types';
|
|
13
|
-
|
|
14
|
-
export interface InputProps extends UseFormFieldProps, TextInputProps {
|
|
15
|
-
size?: 'sm' | 'lg';
|
|
16
|
-
placeholderTextColor?: string;
|
|
17
|
-
multiline?: boolean;
|
|
18
|
-
disabled?: boolean;
|
|
19
|
-
valid?: boolean;
|
|
20
|
-
invalid?: boolean;
|
|
21
|
-
readOnly?: boolean;
|
|
22
|
-
selectTextOnFocus?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Known issues:
|
|
26
|
-
//
|
|
27
|
-
// line-height (iOS)
|
|
28
|
-
// If a line height is defined on iOS the text will be displayed on the bottom
|
|
29
|
-
// of the line. As a workaround the line height is only defined for multi line
|
|
30
|
-
// inputs.
|
|
31
|
-
//
|
|
32
|
-
// multi line height (iOS)
|
|
33
|
-
// A multi line input on iOS has only the height of a single line input. As a
|
|
34
|
-
// workaround we added a height of $input-height-sm + 8rem for multi line
|
|
35
|
-
// inputs on iOS.
|
|
36
|
-
//
|
|
37
|
-
// single line height (Android)
|
|
38
|
-
// If no height is defined, Android sets a text line height of 28px auto-
|
|
39
|
-
// matically, which leads to a larger height than min height for the default
|
|
40
|
-
// and sm size. As a workaround we set a height for single line inputs.
|
|
41
|
-
const styles = StyleSheet.create({
|
|
42
|
-
'.form-control': css`
|
|
43
|
-
// display: block;
|
|
44
|
-
width: 100%;
|
|
45
|
-
min-height: $input-height; // added for bootstrap-rn
|
|
46
|
-
padding: $input-padding-y $input-padding-x;
|
|
47
|
-
font-family: $input-font-family;
|
|
48
|
-
font-size: $input-font-size;
|
|
49
|
-
font-weight: $input-font-weight;
|
|
50
|
-
@include platform(web) {
|
|
51
|
-
line-height: $input-font-size * $input-line-height;
|
|
52
|
-
}
|
|
53
|
-
color: $input-color;
|
|
54
|
-
background-color: $input-bg;
|
|
55
|
-
// background-clip: padding-box;
|
|
56
|
-
border: $input-border-width solid $input-border-color;
|
|
57
|
-
@include platform(web) {
|
|
58
|
-
appearance: none; // Fix appearance for date inputs in Safari
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Note: This has no effect on <select>s in some browsers, due to the limited stylability of "<select>"s in CSS.
|
|
62
|
-
border-radius: $input-border-radius;
|
|
63
|
-
|
|
64
|
-
// @include box-shadow($input-box-shadow);
|
|
65
|
-
// @include transition($input-transition);
|
|
66
|
-
|
|
67
|
-
// Customize the ":focus" state to imitate native WebKit styles.
|
|
68
|
-
&:focus {
|
|
69
|
-
color: $input-focus-color;
|
|
70
|
-
background-color: $input-focus-bg;
|
|
71
|
-
border-color: $input-focus-border-color;
|
|
72
|
-
@include platform(web) {
|
|
73
|
-
outline-style: none; // outline: 0;
|
|
74
|
-
// @if $enable-shadows {
|
|
75
|
-
// @include box-shadow($input-box-shadow, $input-focus-box-shadow);
|
|
76
|
-
// } @else {
|
|
77
|
-
// // Avoid using mixin so we can pass custom focus shadow properly
|
|
78
|
-
box-shadow: $input-focus-box-shadow;
|
|
79
|
-
// }
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
`,
|
|
83
|
-
'.form-control.disabled': css`
|
|
84
|
-
background-color: $input-disabled-bg;
|
|
85
|
-
border-color: $input-disabled-border-color;
|
|
86
|
-
// iOS fix for unreadable disabled content; see https://github.com/twbs/bootstrap/issues/11655.
|
|
87
|
-
opacity: 1;
|
|
88
|
-
`,
|
|
89
|
-
'.form-control-sm': css`
|
|
90
|
-
min-height: $input-height-sm;
|
|
91
|
-
padding: $input-padding-y-sm $input-padding-x-sm;
|
|
92
|
-
font-size: $input-font-size-sm;
|
|
93
|
-
@include platform(web) {
|
|
94
|
-
line-height: $input-font-size-sm * $line-height-base; // added for bootstrap-rn
|
|
95
|
-
}
|
|
96
|
-
border-radius: $input-border-radius-sm;
|
|
97
|
-
`,
|
|
98
|
-
'.form-control-lg': css`
|
|
99
|
-
min-height: $input-height-lg;
|
|
100
|
-
padding: $input-padding-y-lg $input-padding-x-lg;
|
|
101
|
-
font-size: $input-font-size-lg;
|
|
102
|
-
@include platform(web) {
|
|
103
|
-
line-height: $input-font-size-lg * $line-height-base; // added for bootstrap-rn
|
|
104
|
-
}
|
|
105
|
-
border-radius: $input-border-radius-lg;
|
|
106
|
-
`,
|
|
107
|
-
'.form-control:not(textarea)': css`
|
|
108
|
-
@include platform(android) {
|
|
109
|
-
height: $input-height; // added for bootstrap-rn
|
|
110
|
-
}
|
|
111
|
-
`,
|
|
112
|
-
'.form-control-sm:not(textarea)': css`
|
|
113
|
-
@include platform(android) {
|
|
114
|
-
height: $input-height-sm; // added for bootstrap-rn
|
|
115
|
-
}
|
|
116
|
-
`,
|
|
117
|
-
'.form-control-lg:not(textarea)': css`
|
|
118
|
-
@include platform(android) {
|
|
119
|
-
height: $input-height-lg; // added for bootstrap-rn
|
|
120
|
-
}
|
|
121
|
-
`,
|
|
122
|
-
'textarea.form-control': css`
|
|
123
|
-
vertical-align: top; // added for bootstrap-rn
|
|
124
|
-
min-height: $input-height;
|
|
125
|
-
|
|
126
|
-
@include platform(ios) {
|
|
127
|
-
min-height: $input-height-sm + 8rem; // added for bootstrap-rn
|
|
128
|
-
}
|
|
129
|
-
@include platform(native) {
|
|
130
|
-
line-height: $input-font-size * $input-line-height; // added for bootstrap-rn
|
|
131
|
-
}
|
|
132
|
-
`,
|
|
133
|
-
'textarea.form-control-sm': css`
|
|
134
|
-
min-height: $input-height-sm;
|
|
135
|
-
|
|
136
|
-
@include platform(ios) {
|
|
137
|
-
// TODO: Adjust ios height to sm size
|
|
138
|
-
min-height: $input-height-sm + 8rem; // added for bootstrap-rn
|
|
139
|
-
}
|
|
140
|
-
@include platform(native) {
|
|
141
|
-
line-height: $input-font-size-sm * $line-height-base; // added for bootstrap-rn
|
|
142
|
-
}
|
|
143
|
-
`,
|
|
144
|
-
'textarea.form-control-lg': css`
|
|
145
|
-
min-height: $input-height-lg;
|
|
146
|
-
|
|
147
|
-
@include platform(ios) {
|
|
148
|
-
// TODO: Adjust ios height to lg size
|
|
149
|
-
min-height: $input-height-sm + 8rem; // added for bootstrap-rn
|
|
150
|
-
}
|
|
151
|
-
@include platform(native) {
|
|
152
|
-
line-height: $input-font-size-sm * $line-height-base; // added for bootstrap-rn
|
|
153
|
-
}
|
|
154
|
-
`,
|
|
155
|
-
...each(FORM_VALIDATION_STATES, (state, data: FormValidationState) => ({
|
|
156
|
-
[`.form-control:${state}`]: css`
|
|
157
|
-
border-color: ${(t: ThemeVariables) => data(t).color};
|
|
158
|
-
|
|
159
|
-
&:focus {
|
|
160
|
-
border-color: ${(t: ThemeVariables) => data(t).color};
|
|
161
|
-
@include platform(web) {
|
|
162
|
-
box-shadow: 0 0 $input-btn-focus-blur $input-focus-width
|
|
163
|
-
rgba(
|
|
164
|
-
${(t: ThemeVariables) => data(t).color},
|
|
165
|
-
$input-btn-focus-color-opacity
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
`,
|
|
170
|
-
})),
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
function Input(props: InputProps & React.RefAttributes<TextInputRef>) {
|
|
174
|
-
const modifierProps = useModifier('useFormField', props);
|
|
175
|
-
|
|
176
|
-
const {
|
|
177
|
-
ref,
|
|
178
|
-
size,
|
|
179
|
-
placeholderTextColor = StyleSheet.value('input-placeholder-color'),
|
|
180
|
-
multiline = false,
|
|
181
|
-
disabled = false,
|
|
182
|
-
valid = false,
|
|
183
|
-
invalid = false,
|
|
184
|
-
readOnly = false,
|
|
185
|
-
selectTextOnFocus = false,
|
|
186
|
-
style,
|
|
187
|
-
...elementProps
|
|
188
|
-
} = modifierProps;
|
|
189
|
-
|
|
190
|
-
const classes = getStyles(styles, [
|
|
191
|
-
'.form-control',
|
|
192
|
-
disabled && '.form-control.disabled',
|
|
193
|
-
size === 'sm' && '.form-control-sm',
|
|
194
|
-
size === 'lg' && '.form-control-lg',
|
|
195
|
-
!multiline && '.form-control:not(textarea)',
|
|
196
|
-
!multiline && size === 'sm' && '.form-control-sm:not(textarea)',
|
|
197
|
-
!multiline && size === 'lg' && '.form-control-lg:not(textarea)',
|
|
198
|
-
multiline && 'textarea.form-control',
|
|
199
|
-
multiline && size === 'sm' && 'textarea.form-control-sm',
|
|
200
|
-
multiline && size === 'lg' && 'textarea.form-control-lg',
|
|
201
|
-
valid && '.form-control:valid',
|
|
202
|
-
invalid && '.form-control:invalid',
|
|
203
|
-
]);
|
|
204
|
-
|
|
205
|
-
return (
|
|
206
|
-
<TextInput
|
|
207
|
-
{...elementProps}
|
|
208
|
-
ref={ref}
|
|
209
|
-
placeholderTextColor={placeholderTextColor}
|
|
210
|
-
multiline={multiline}
|
|
211
|
-
disabled={disabled}
|
|
212
|
-
readOnly={disabled ? true : readOnly}
|
|
213
|
-
selectTextOnFocus={disabled ? false : selectTextOnFocus}
|
|
214
|
-
style={[classes, style]}
|
|
215
|
-
/>
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
export default Input;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import StyleSheet from '../../style/StyleSheet';
|
|
3
|
+
import css from '../../style/css';
|
|
4
|
+
import TextInput, { TextInputProps, TextInputRef } from '../TextInput';
|
|
5
|
+
import { getStyles, each } from '../../utils';
|
|
6
|
+
import useModifier from '../../hooks/useModifier';
|
|
7
|
+
import { FORM_VALIDATION_STATES } from '../../theme/proxies';
|
|
8
|
+
import type {
|
|
9
|
+
FormValidationState,
|
|
10
|
+
ThemeVariables,
|
|
11
|
+
UseFormFieldProps,
|
|
12
|
+
} from '../../types';
|
|
13
|
+
|
|
14
|
+
export interface InputProps extends UseFormFieldProps, TextInputProps {
|
|
15
|
+
size?: 'sm' | 'lg';
|
|
16
|
+
placeholderTextColor?: string;
|
|
17
|
+
multiline?: boolean;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
valid?: boolean;
|
|
20
|
+
invalid?: boolean;
|
|
21
|
+
readOnly?: boolean;
|
|
22
|
+
selectTextOnFocus?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Known issues:
|
|
26
|
+
//
|
|
27
|
+
// line-height (iOS)
|
|
28
|
+
// If a line height is defined on iOS the text will be displayed on the bottom
|
|
29
|
+
// of the line. As a workaround the line height is only defined for multi line
|
|
30
|
+
// inputs.
|
|
31
|
+
//
|
|
32
|
+
// multi line height (iOS)
|
|
33
|
+
// A multi line input on iOS has only the height of a single line input. As a
|
|
34
|
+
// workaround we added a height of $input-height-sm + 8rem for multi line
|
|
35
|
+
// inputs on iOS.
|
|
36
|
+
//
|
|
37
|
+
// single line height (Android)
|
|
38
|
+
// If no height is defined, Android sets a text line height of 28px auto-
|
|
39
|
+
// matically, which leads to a larger height than min height for the default
|
|
40
|
+
// and sm size. As a workaround we set a height for single line inputs.
|
|
41
|
+
const styles = StyleSheet.create({
|
|
42
|
+
'.form-control': css`
|
|
43
|
+
// display: block;
|
|
44
|
+
width: 100%;
|
|
45
|
+
min-height: $input-height; // added for bootstrap-rn
|
|
46
|
+
padding: $input-padding-y $input-padding-x;
|
|
47
|
+
font-family: $input-font-family;
|
|
48
|
+
font-size: $input-font-size;
|
|
49
|
+
font-weight: $input-font-weight;
|
|
50
|
+
@include platform(web) {
|
|
51
|
+
line-height: $input-font-size * $input-line-height;
|
|
52
|
+
}
|
|
53
|
+
color: $input-color;
|
|
54
|
+
background-color: $input-bg;
|
|
55
|
+
// background-clip: padding-box;
|
|
56
|
+
border: $input-border-width solid $input-border-color;
|
|
57
|
+
@include platform(web) {
|
|
58
|
+
appearance: none; // Fix appearance for date inputs in Safari
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Note: This has no effect on <select>s in some browsers, due to the limited stylability of "<select>"s in CSS.
|
|
62
|
+
border-radius: $input-border-radius;
|
|
63
|
+
|
|
64
|
+
// @include box-shadow($input-box-shadow);
|
|
65
|
+
// @include transition($input-transition);
|
|
66
|
+
|
|
67
|
+
// Customize the ":focus" state to imitate native WebKit styles.
|
|
68
|
+
&:focus {
|
|
69
|
+
color: $input-focus-color;
|
|
70
|
+
background-color: $input-focus-bg;
|
|
71
|
+
border-color: $input-focus-border-color;
|
|
72
|
+
@include platform(web) {
|
|
73
|
+
outline-style: none; // outline: 0;
|
|
74
|
+
// @if $enable-shadows {
|
|
75
|
+
// @include box-shadow($input-box-shadow, $input-focus-box-shadow);
|
|
76
|
+
// } @else {
|
|
77
|
+
// // Avoid using mixin so we can pass custom focus shadow properly
|
|
78
|
+
box-shadow: $input-focus-box-shadow;
|
|
79
|
+
// }
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
`,
|
|
83
|
+
'.form-control.disabled': css`
|
|
84
|
+
background-color: $input-disabled-bg;
|
|
85
|
+
border-color: $input-disabled-border-color;
|
|
86
|
+
// iOS fix for unreadable disabled content; see https://github.com/twbs/bootstrap/issues/11655.
|
|
87
|
+
opacity: 1;
|
|
88
|
+
`,
|
|
89
|
+
'.form-control-sm': css`
|
|
90
|
+
min-height: $input-height-sm;
|
|
91
|
+
padding: $input-padding-y-sm $input-padding-x-sm;
|
|
92
|
+
font-size: $input-font-size-sm;
|
|
93
|
+
@include platform(web) {
|
|
94
|
+
line-height: $input-font-size-sm * $line-height-base; // added for bootstrap-rn
|
|
95
|
+
}
|
|
96
|
+
border-radius: $input-border-radius-sm;
|
|
97
|
+
`,
|
|
98
|
+
'.form-control-lg': css`
|
|
99
|
+
min-height: $input-height-lg;
|
|
100
|
+
padding: $input-padding-y-lg $input-padding-x-lg;
|
|
101
|
+
font-size: $input-font-size-lg;
|
|
102
|
+
@include platform(web) {
|
|
103
|
+
line-height: $input-font-size-lg * $line-height-base; // added for bootstrap-rn
|
|
104
|
+
}
|
|
105
|
+
border-radius: $input-border-radius-lg;
|
|
106
|
+
`,
|
|
107
|
+
'.form-control:not(textarea)': css`
|
|
108
|
+
@include platform(android) {
|
|
109
|
+
height: $input-height; // added for bootstrap-rn
|
|
110
|
+
}
|
|
111
|
+
`,
|
|
112
|
+
'.form-control-sm:not(textarea)': css`
|
|
113
|
+
@include platform(android) {
|
|
114
|
+
height: $input-height-sm; // added for bootstrap-rn
|
|
115
|
+
}
|
|
116
|
+
`,
|
|
117
|
+
'.form-control-lg:not(textarea)': css`
|
|
118
|
+
@include platform(android) {
|
|
119
|
+
height: $input-height-lg; // added for bootstrap-rn
|
|
120
|
+
}
|
|
121
|
+
`,
|
|
122
|
+
'textarea.form-control': css`
|
|
123
|
+
vertical-align: top; // added for bootstrap-rn
|
|
124
|
+
min-height: $input-height;
|
|
125
|
+
|
|
126
|
+
@include platform(ios) {
|
|
127
|
+
min-height: $input-height-sm + 8rem; // added for bootstrap-rn
|
|
128
|
+
}
|
|
129
|
+
@include platform(native) {
|
|
130
|
+
line-height: $input-font-size * $input-line-height; // added for bootstrap-rn
|
|
131
|
+
}
|
|
132
|
+
`,
|
|
133
|
+
'textarea.form-control-sm': css`
|
|
134
|
+
min-height: $input-height-sm;
|
|
135
|
+
|
|
136
|
+
@include platform(ios) {
|
|
137
|
+
// TODO: Adjust ios height to sm size
|
|
138
|
+
min-height: $input-height-sm + 8rem; // added for bootstrap-rn
|
|
139
|
+
}
|
|
140
|
+
@include platform(native) {
|
|
141
|
+
line-height: $input-font-size-sm * $line-height-base; // added for bootstrap-rn
|
|
142
|
+
}
|
|
143
|
+
`,
|
|
144
|
+
'textarea.form-control-lg': css`
|
|
145
|
+
min-height: $input-height-lg;
|
|
146
|
+
|
|
147
|
+
@include platform(ios) {
|
|
148
|
+
// TODO: Adjust ios height to lg size
|
|
149
|
+
min-height: $input-height-sm + 8rem; // added for bootstrap-rn
|
|
150
|
+
}
|
|
151
|
+
@include platform(native) {
|
|
152
|
+
line-height: $input-font-size-sm * $line-height-base; // added for bootstrap-rn
|
|
153
|
+
}
|
|
154
|
+
`,
|
|
155
|
+
...each(FORM_VALIDATION_STATES, (state, data: FormValidationState) => ({
|
|
156
|
+
[`.form-control:${state}`]: css`
|
|
157
|
+
border-color: ${(t: ThemeVariables) => data(t).color};
|
|
158
|
+
|
|
159
|
+
&:focus {
|
|
160
|
+
border-color: ${(t: ThemeVariables) => data(t).color};
|
|
161
|
+
@include platform(web) {
|
|
162
|
+
box-shadow: 0 0 $input-btn-focus-blur $input-focus-width
|
|
163
|
+
rgba(
|
|
164
|
+
${(t: ThemeVariables) => data(t).color},
|
|
165
|
+
$input-btn-focus-color-opacity
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
`,
|
|
170
|
+
})),
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
function Input(props: InputProps & React.RefAttributes<TextInputRef>) {
|
|
174
|
+
const modifierProps = useModifier('useFormField', props);
|
|
175
|
+
|
|
176
|
+
const {
|
|
177
|
+
ref,
|
|
178
|
+
size,
|
|
179
|
+
placeholderTextColor = StyleSheet.value('input-placeholder-color'),
|
|
180
|
+
multiline = false,
|
|
181
|
+
disabled = false,
|
|
182
|
+
valid = false,
|
|
183
|
+
invalid = false,
|
|
184
|
+
readOnly = false,
|
|
185
|
+
selectTextOnFocus = false,
|
|
186
|
+
style,
|
|
187
|
+
...elementProps
|
|
188
|
+
} = modifierProps;
|
|
189
|
+
|
|
190
|
+
const classes = getStyles(styles, [
|
|
191
|
+
'.form-control',
|
|
192
|
+
disabled && '.form-control.disabled',
|
|
193
|
+
size === 'sm' && '.form-control-sm',
|
|
194
|
+
size === 'lg' && '.form-control-lg',
|
|
195
|
+
!multiline && '.form-control:not(textarea)',
|
|
196
|
+
!multiline && size === 'sm' && '.form-control-sm:not(textarea)',
|
|
197
|
+
!multiline && size === 'lg' && '.form-control-lg:not(textarea)',
|
|
198
|
+
multiline && 'textarea.form-control',
|
|
199
|
+
multiline && size === 'sm' && 'textarea.form-control-sm',
|
|
200
|
+
multiline && size === 'lg' && 'textarea.form-control-lg',
|
|
201
|
+
valid && '.form-control:valid',
|
|
202
|
+
invalid && '.form-control:invalid',
|
|
203
|
+
]);
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<TextInput
|
|
207
|
+
{...elementProps}
|
|
208
|
+
ref={ref}
|
|
209
|
+
placeholderTextColor={placeholderTextColor}
|
|
210
|
+
multiline={multiline}
|
|
211
|
+
disabled={disabled}
|
|
212
|
+
readOnly={disabled ? true : readOnly}
|
|
213
|
+
selectTextOnFocus={disabled ? false : selectTextOnFocus}
|
|
214
|
+
style={[classes, style]}
|
|
215
|
+
/>
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export default Input;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { useState
|
|
2
|
-
import {
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { NativeSyntheticEvent, TargetedEvent } from 'react-native';
|
|
3
3
|
import StyleSheet from '../../style/StyleSheet';
|
|
4
4
|
import css from '../../style/css';
|
|
5
5
|
import useMedia from '../../hooks/useMedia';
|
|
@@ -8,10 +8,8 @@ import { FORM_VALIDATION_STATES } from '../../theme/proxies';
|
|
|
8
8
|
import { escapeSvg } from '../../theme/functions';
|
|
9
9
|
import useStyle from '../../hooks/useStyle';
|
|
10
10
|
import useModifier from '../../hooks/useModifier';
|
|
11
|
-
import
|
|
12
|
-
import PickerNative from './internals/PickerNative';
|
|
11
|
+
import BasePicker from './internals/Picker';
|
|
13
12
|
import PickerItem, { PickerItemProps } from './PickerItem';
|
|
14
|
-
import PickerContext from './PickerContext';
|
|
15
13
|
import type {
|
|
16
14
|
FormValidationState,
|
|
17
15
|
ThemeVariables,
|
|
@@ -40,7 +38,6 @@ export interface PickerProps extends UseFormFieldProps, PressableProps {
|
|
|
40
38
|
disabled?: boolean;
|
|
41
39
|
valid?: boolean;
|
|
42
40
|
invalid?: boolean;
|
|
43
|
-
useNativeComponent?: boolean;
|
|
44
41
|
autoFocus?: boolean;
|
|
45
42
|
MenuComponent?: React.FC<MenuComponentProps>;
|
|
46
43
|
}
|
|
@@ -128,7 +125,6 @@ function Picker(props: PickerProps & React.RefAttributes<PressableRef>) {
|
|
|
128
125
|
disabled = false,
|
|
129
126
|
valid = false,
|
|
130
127
|
invalid = false,
|
|
131
|
-
useNativeComponent = false,
|
|
132
128
|
autoFocus = false,
|
|
133
129
|
style,
|
|
134
130
|
styleName,
|
|
@@ -150,40 +146,28 @@ function Picker(props: PickerProps & React.RefAttributes<PressableRef>) {
|
|
|
150
146
|
|
|
151
147
|
const resolveStyle = useStyle([classes, style], styleName);
|
|
152
148
|
|
|
153
|
-
const BasePicker =
|
|
154
|
-
Platform.OS === 'web' && !useNativeComponent ? PickerWeb : PickerNative;
|
|
155
|
-
|
|
156
|
-
const contextValue = useMemo(
|
|
157
|
-
() => ({
|
|
158
|
-
useNativeComponent,
|
|
159
|
-
}),
|
|
160
|
-
[useNativeComponent],
|
|
161
|
-
);
|
|
162
|
-
|
|
163
149
|
return (
|
|
164
|
-
<
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
</BasePicker>
|
|
186
|
-
</PickerContext.Provider>
|
|
150
|
+
<BasePicker
|
|
151
|
+
{...elementProps}
|
|
152
|
+
ref={ref}
|
|
153
|
+
placeholderTextColor={placeholderTextColor}
|
|
154
|
+
onFocus={(event: NativeSyntheticEvent<TargetedEvent>) => {
|
|
155
|
+
setFocused(true);
|
|
156
|
+
onFocus(event);
|
|
157
|
+
}}
|
|
158
|
+
onBlur={(event: NativeSyntheticEvent<TargetedEvent>) => {
|
|
159
|
+
setFocused(false);
|
|
160
|
+
onBlur(event);
|
|
161
|
+
}}
|
|
162
|
+
disabled={disabled}
|
|
163
|
+
autoFocus={autoFocus}
|
|
164
|
+
style={resolveStyle({
|
|
165
|
+
media,
|
|
166
|
+
interaction: { focus: focused, focusVisible: focused },
|
|
167
|
+
})}
|
|
168
|
+
>
|
|
169
|
+
{children}
|
|
170
|
+
</BasePicker>
|
|
187
171
|
);
|
|
188
172
|
}
|
|
189
173
|
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import PickerContext from './PickerContext';
|
|
4
|
-
import useForcedContext from '../../hooks/useForcedContext';
|
|
5
|
-
import PickerWebItem from './internals/PickerWebItem';
|
|
6
|
-
import PickerNativeItem from './internals/PickerNativeItem';
|
|
2
|
+
import BasePickerItem from './internals/PickerItem';
|
|
7
3
|
import type { ViewProps, ViewRef } from '../View';
|
|
8
4
|
|
|
9
5
|
export interface PickerItemProps extends ViewProps {
|
|
@@ -15,13 +11,6 @@ export interface PickerItemProps extends ViewProps {
|
|
|
15
11
|
function PickerItem(props: PickerItemProps & React.RefAttributes<ViewRef>) {
|
|
16
12
|
const { ref, label, value, disabled = false } = props;
|
|
17
13
|
|
|
18
|
-
const { useNativeComponent } = useForcedContext(PickerContext);
|
|
19
|
-
|
|
20
|
-
const BasePickerItem =
|
|
21
|
-
Platform.OS === 'web' && !useNativeComponent
|
|
22
|
-
? PickerWebItem
|
|
23
|
-
: PickerNativeItem;
|
|
24
|
-
|
|
25
14
|
return (
|
|
26
15
|
<BasePickerItem ref={ref} label={label} value={value} disabled={disabled} />
|
|
27
16
|
);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
type RadioContextType = {
|
|
4
|
-
selectedValue?: boolean | number | string | object | null | undefined;
|
|
5
|
-
onValueChange: (value: boolean | number | string | object | null) => void;
|
|
6
|
-
disabled: boolean;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const RadioContext = React.createContext<RadioContextType | null>(null);
|
|
10
|
-
|
|
11
|
-
RadioContext.displayName = 'RadioContext';
|
|
12
|
-
|
|
13
|
-
export default RadioContext;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
type RadioContextType = {
|
|
4
|
+
selectedValue?: boolean | number | string | object | null | undefined;
|
|
5
|
+
onValueChange: (value: boolean | number | string | object | null) => void;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const RadioContext = React.createContext<RadioContextType | null>(null);
|
|
10
|
+
|
|
11
|
+
RadioContext.displayName = 'RadioContext';
|
|
12
|
+
|
|
13
|
+
export default RadioContext;
|
|
@@ -4,12 +4,12 @@ import Pressable, { PressableRef } from '../../Pressable';
|
|
|
4
4
|
import useBackground from '../../../hooks/useBackground';
|
|
5
5
|
import type { FormCheckInputProps } from '../FormCheckInput';
|
|
6
6
|
|
|
7
|
-
export interface
|
|
7
|
+
export interface BaseFormCheckInputProps extends FormCheckInputProps {
|
|
8
8
|
style: ViewStyle[];
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
function
|
|
12
|
-
props:
|
|
11
|
+
function FormCheckInput(
|
|
12
|
+
props: BaseFormCheckInputProps & React.RefAttributes<PressableRef>,
|
|
13
13
|
) {
|
|
14
14
|
const {
|
|
15
15
|
ref,
|
|
@@ -46,4 +46,4 @@ function FormCheckInputNative(
|
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export default
|
|
49
|
+
export default FormCheckInput;
|