@telus-uds/components-base 1.18.1 → 1.19.1
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/CHANGELOG.md +22 -2
- package/component-docs.json +111 -16
- package/jest.config-android.js +17 -0
- package/jest.config-ios.js +18 -0
- package/jest.config-web.js +31 -0
- package/lib/ActivityIndicator/Spinner.js +7 -7
- package/lib/ActivityIndicator/Spinner.native.js +2 -2
- package/lib/BaseProvider/HydrationContext.js +1 -1
- package/lib/BaseProvider/TamaguiProvider.js +30 -0
- package/lib/Button/ButtonBase.js +8 -4
- package/lib/Button/ButtonDropdown.js +207 -0
- package/lib/Button/ButtonGroup.js +1 -1
- package/lib/Carousel/Carousel.js +31 -5
- package/lib/Carousel/CarouselContext.js +1 -1
- package/lib/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +1 -1
- package/lib/Carousel/CarouselTabs/CarouselTabsPanel.js +1 -10
- package/lib/Carousel/CarouselThumbnail.js +2 -2
- package/lib/Checkbox/Checkbox.js +1 -1
- package/lib/Checkbox/CheckboxGroup.js +2 -2
- package/lib/Divider/Divider.js +2 -2
- package/lib/FlexGrid/Col/Col.js +1 -1
- package/lib/Icon/Icon.js +1 -1
- package/lib/MultiSelectFilter/ModalOverlay.js +136 -0
- package/lib/MultiSelectFilter/MultiSelectFilter.js +314 -0
- package/lib/MultiSelectFilter/dictionary.js +19 -0
- package/lib/MultiSelectFilter/index.js +13 -0
- package/lib/Pagination/PageButton.js +2 -2
- package/lib/Pagination/Pagination.js +3 -5
- package/lib/Pagination/SideButton.js +6 -4
- package/lib/Pagination/usePagination.js +2 -2
- package/lib/Progress/ProgressBar.js +3 -3
- package/lib/Progress/ProgressBarBackground.js +3 -3
- package/lib/QuickLinksFeature/QuickLinksFeature.js +91 -0
- package/lib/QuickLinksFeature/QuickLinksFeatureItem.js +157 -0
- package/lib/QuickLinksFeature/index.js +16 -0
- package/lib/Radio/Radio.js +2 -2
- package/lib/Radio/RadioGroup.js +2 -2
- package/lib/RadioCard/RadioCard.js +1 -1
- package/lib/RadioCard/RadioCardGroup.js +2 -2
- package/lib/Responsive/Responsive.js +58 -0
- package/lib/Responsive/index.js +13 -0
- package/lib/Search/Search.js +30 -63
- package/lib/Select/constants.js +15 -0
- package/lib/SideNav/SideNav.js +2 -2
- package/lib/Skeleton/Skeleton.js +1 -1
- package/lib/Skeleton/skeletonWebAnimation.js +1 -1
- package/lib/StackView/StackWrap.js +1 -3
- package/lib/StackView/getStackedContent.js +2 -2
- package/lib/Tabs/Tabs.js +2 -4
- package/lib/Tags/Tags.js +11 -5
- package/lib/TextInput/TextInputBase.js +53 -19
- package/lib/TextInput/dictionary.js +19 -0
- package/lib/ThemeProvider/utils/styles.js +3 -3
- package/lib/ThemeProvider/utils/theme-tokens.js +9 -7
- package/lib/Timeline/Timeline.js +1 -1
- package/lib/ToggleSwitch/ToggleSwitch.js +1 -1
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +1 -1
- package/lib/Tooltip/Backdrop.js +10 -2
- package/lib/Tooltip/Tooltip.native.js +357 -0
- package/lib/Tooltip/shared.js +39 -0
- package/lib/Validator/Validator.js +271 -0
- package/lib/Validator/index.js +13 -0
- package/lib/index.js +9 -0
- package/lib/utils/BaseView/BaseView.js +64 -0
- package/lib/utils/BaseView/BaseView.native.js +16 -0
- package/lib/utils/BaseView/index.js +13 -0
- package/lib/utils/animation/useVerticalExpandAnimation.js +1 -1
- package/lib/utils/children.js +2 -2
- package/lib/utils/floating-ui/index.js +43 -0
- package/lib/utils/floating-ui/index.native.js +43 -0
- package/lib/utils/input.js +12 -6
- package/lib/utils/props/componentPropType.js +3 -3
- package/lib/utils/props/selectSystemProps.js +2 -2
- package/lib/utils/props/tokens.js +2 -2
- package/lib/utils/useOverlaidPosition.js +243 -0
- package/lib/utils/useSpacingScale.js +1 -3
- package/lib/utils/useUniqueId.js +1 -1
- package/lib-module/ActivityIndicator/Spinner.js +7 -7
- package/lib-module/ActivityIndicator/Spinner.native.js +2 -2
- package/lib-module/BaseProvider/HydrationContext.js +1 -1
- package/lib-module/BaseProvider/TamaguiProvider.js +22 -0
- package/lib-module/Button/ButtonBase.js +8 -4
- package/lib-module/Button/ButtonDropdown.js +181 -0
- package/lib-module/Button/ButtonGroup.js +1 -1
- package/lib-module/Carousel/Carousel.js +31 -5
- package/lib-module/Carousel/CarouselContext.js +1 -1
- package/lib-module/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +1 -1
- package/lib-module/Carousel/CarouselTabs/CarouselTabsPanel.js +1 -10
- package/lib-module/Carousel/CarouselThumbnail.js +2 -2
- package/lib-module/Checkbox/Checkbox.js +1 -1
- package/lib-module/Checkbox/CheckboxGroup.js +2 -2
- package/lib-module/Divider/Divider.js +2 -2
- package/lib-module/FlexGrid/Col/Col.js +1 -1
- package/lib-module/Icon/Icon.js +1 -1
- package/lib-module/MultiSelectFilter/ModalOverlay.js +112 -0
- package/lib-module/MultiSelectFilter/MultiSelectFilter.js +286 -0
- package/lib-module/MultiSelectFilter/dictionary.js +12 -0
- package/lib-module/MultiSelectFilter/index.js +2 -0
- package/lib-module/Pagination/PageButton.js +2 -2
- package/lib-module/Pagination/Pagination.js +3 -5
- package/lib-module/Pagination/SideButton.js +6 -4
- package/lib-module/Pagination/usePagination.js +2 -2
- package/lib-module/Progress/ProgressBar.js +3 -3
- package/lib-module/Progress/ProgressBarBackground.js +3 -3
- package/lib-module/QuickLinksFeature/QuickLinksFeature.js +69 -0
- package/lib-module/QuickLinksFeature/QuickLinksFeatureItem.js +130 -0
- package/lib-module/QuickLinksFeature/index.js +4 -0
- package/lib-module/Radio/Radio.js +2 -2
- package/lib-module/Radio/RadioGroup.js +2 -2
- package/lib-module/RadioCard/RadioCard.js +1 -1
- package/lib-module/RadioCard/RadioCardGroup.js +2 -2
- package/lib-module/Responsive/Responsive.js +45 -0
- package/lib-module/Responsive/index.js +2 -0
- package/lib-module/Search/Search.js +30 -61
- package/lib-module/Select/constants.js +5 -0
- package/lib-module/SideNav/SideNav.js +2 -2
- package/lib-module/Skeleton/Skeleton.js +1 -1
- package/lib-module/Skeleton/skeletonWebAnimation.js +1 -1
- package/lib-module/StackView/StackWrap.js +1 -3
- package/lib-module/StackView/getStackedContent.js +2 -2
- package/lib-module/Tabs/Tabs.js +2 -4
- package/lib-module/Tags/Tags.js +11 -5
- package/lib-module/TextInput/TextInputBase.js +52 -19
- package/lib-module/TextInput/dictionary.js +12 -0
- package/lib-module/ThemeProvider/utils/styles.js +3 -3
- package/lib-module/ThemeProvider/utils/theme-tokens.js +9 -7
- package/lib-module/Timeline/Timeline.js +1 -1
- package/lib-module/ToggleSwitch/ToggleSwitch.js +1 -1
- package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +1 -1
- package/lib-module/Tooltip/Backdrop.js +10 -2
- package/lib-module/Tooltip/Tooltip.native.js +326 -0
- package/lib-module/Tooltip/shared.js +27 -0
- package/lib-module/Validator/Validator.js +245 -0
- package/lib-module/Validator/index.js +2 -0
- package/lib-module/index.js +1 -0
- package/lib-module/utils/BaseView/BaseView.js +43 -0
- package/lib-module/utils/BaseView/BaseView.native.js +6 -0
- package/lib-module/utils/BaseView/index.js +2 -0
- package/lib-module/utils/animation/useVerticalExpandAnimation.js +1 -1
- package/lib-module/utils/children.js +2 -2
- package/lib-module/utils/floating-ui/index.js +1 -0
- package/lib-module/utils/floating-ui/index.native.js +1 -0
- package/lib-module/utils/input.js +12 -6
- package/lib-module/utils/props/componentPropType.js +3 -3
- package/lib-module/utils/props/selectSystemProps.js +2 -2
- package/lib-module/utils/props/tokens.js +2 -2
- package/lib-module/utils/useOverlaidPosition.js +232 -0
- package/lib-module/utils/useSpacingScale.js +1 -3
- package/lib-module/utils/useUniqueId.js +1 -1
- package/package.json +7 -4
- package/src/Button/ButtonBase.jsx +4 -2
- package/src/Carousel/Carousel.jsx +42 -10
- package/src/Carousel/CarouselTabs/CarouselTabsPanel.jsx +0 -10
- package/src/Pagination/SideButton.jsx +5 -5
- package/src/Responsive/Responsive.jsx +33 -0
- package/src/Responsive/index.js +3 -0
- package/src/Search/Search.jsx +17 -32
- package/src/Tags/Tags.jsx +46 -33
- package/src/TextInput/TextInputBase.jsx +46 -16
- package/src/index.js +1 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import { viewports } from '@telus-uds/system-constants'
|
|
4
|
+
import { useResponsiveProp } from '../utils'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Responsive conditionally renders children based on whether the viewport matches the provided
|
|
8
|
+
* min and max viewports.
|
|
9
|
+
*
|
|
10
|
+
* In SSR, like other viewport utilities, it treats the viewport as `xs` both in SSR itself and
|
|
11
|
+
* during first hydration on the client side; then if the viewport is not `xs`, it re-renders
|
|
12
|
+
* after hydration. This may cause a layout shift on devices other than the narrowest.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const Responsive = ({ min = 'xs', max, children }) => {
|
|
16
|
+
// Start returning children at the 'min' viewport or greater
|
|
17
|
+
const byViewports = { [min]: children }
|
|
18
|
+
if (max && max !== 'xl') {
|
|
19
|
+
// Stop returning children at the viewport one above 'max' or greater
|
|
20
|
+
const maxIndex = viewports.keys.indexOf(max)
|
|
21
|
+
const maxPlusOne = maxIndex >= 0 ? viewports.keys[maxIndex + 1] : null
|
|
22
|
+
if (maxPlusOne) byViewports[maxPlusOne] = null
|
|
23
|
+
}
|
|
24
|
+
return <>{useResponsiveProp(byViewports, null)}</>
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
Responsive.propTypes = {
|
|
28
|
+
min: PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),
|
|
29
|
+
max: PropTypes.oneOf(['sm', 'md', 'lg', 'xl']),
|
|
30
|
+
children: PropTypes.node.isRequired
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default Responsive
|
package/src/Search/Search.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react'
|
|
2
|
-
import { View
|
|
2
|
+
import { View } from 'react-native'
|
|
3
3
|
|
|
4
4
|
import PropTypes from 'prop-types'
|
|
5
5
|
import { useThemeTokens, useThemeTokensCallback } from '../ThemeProvider'
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
} from '../utils'
|
|
18
18
|
import TextInputBase from '../TextInput/TextInputBase'
|
|
19
19
|
import ButtonBase from '../Button/ButtonBase'
|
|
20
|
-
import StackView from '../StackView'
|
|
21
20
|
import useCopy from '../utils/useCopy'
|
|
22
21
|
import dictionary from './dictionary'
|
|
23
22
|
|
|
@@ -42,7 +41,6 @@ const selectInputTokens = ({ searchTokens, buttonTokens, buttonsGapSize }) => {
|
|
|
42
41
|
}
|
|
43
42
|
const selectButtonTokens = (tokens) => selectTokens('Button', tokens)
|
|
44
43
|
|
|
45
|
-
const selectIconsContainerStyle = ({ paddingRight }) => ({ paddingRight })
|
|
46
44
|
const selectIconTokens = ({ iconSize, iconColor }) => ({ color: iconColor, size: iconSize })
|
|
47
45
|
|
|
48
46
|
/**
|
|
@@ -126,7 +124,7 @@ const Search = forwardRef(
|
|
|
126
124
|
const { nativeID, testID, ...containerProps } = selectContainerProps(rest)
|
|
127
125
|
|
|
128
126
|
return (
|
|
129
|
-
<View
|
|
127
|
+
<View {...containerProps}>
|
|
130
128
|
<TextInputBase
|
|
131
129
|
nativeID={nativeID}
|
|
132
130
|
testID={testID}
|
|
@@ -150,28 +148,28 @@ const Search = forwardRef(
|
|
|
150
148
|
onSubmitEditing={handleSubmit}
|
|
151
149
|
onFocus={handleFocus}
|
|
152
150
|
accessibilityLabel={a11yLabelText}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
<StackView direction="row" space={buttonsGap}>
|
|
156
|
-
{ClearButtonIcon && !isEmpty && (
|
|
151
|
+
buttons={[
|
|
152
|
+
ClearButtonIcon && !isEmpty && (
|
|
157
153
|
<ButtonBase
|
|
158
|
-
onPress={handleClear}
|
|
159
|
-
inactive={inactive}
|
|
160
|
-
accessibilityRole="button"
|
|
161
154
|
accessibilityLabel={getCopy('clearButtonAccessibilityLabel')}
|
|
155
|
+
accessibilityRole="button"
|
|
156
|
+
inactive={inactive}
|
|
157
|
+
key="clear"
|
|
158
|
+
onPress={handleClear}
|
|
162
159
|
tokens={(appearances) => selectButtonTokens(getButtonTokens(appearances))}
|
|
163
160
|
>
|
|
164
161
|
{(buttonState) => (
|
|
165
162
|
<ClearButtonIcon {...selectIconTokens(getButtonTokens(buttonState))} />
|
|
166
163
|
)}
|
|
167
164
|
</ButtonBase>
|
|
168
|
-
)
|
|
169
|
-
|
|
165
|
+
),
|
|
166
|
+
SubmitButtonIcon && (
|
|
170
167
|
<ButtonBase
|
|
171
|
-
onPress={handleSubmit}
|
|
172
|
-
inactive={inactive}
|
|
173
|
-
accessibilityRole="button"
|
|
174
168
|
accessibilityLabel={getCopy('submitButtonAccessibilityLabel')}
|
|
169
|
+
accessibilityRole="button"
|
|
170
|
+
inactive={inactive}
|
|
171
|
+
key="submit"
|
|
172
|
+
onPress={handleSubmit}
|
|
175
173
|
tokens={(buttonState) =>
|
|
176
174
|
selectButtonTokens(getButtonTokens({ ...buttonState, priority: 'high' }))
|
|
177
175
|
}
|
|
@@ -182,9 +180,9 @@ const Search = forwardRef(
|
|
|
182
180
|
/>
|
|
183
181
|
)}
|
|
184
182
|
</ButtonBase>
|
|
185
|
-
)
|
|
186
|
-
|
|
187
|
-
|
|
183
|
+
)
|
|
184
|
+
]}
|
|
185
|
+
/>
|
|
188
186
|
</View>
|
|
189
187
|
)
|
|
190
188
|
}
|
|
@@ -248,16 +246,3 @@ Search.propTypes = {
|
|
|
248
246
|
}
|
|
249
247
|
|
|
250
248
|
export default Search
|
|
251
|
-
|
|
252
|
-
const staticStyles = StyleSheet.create({
|
|
253
|
-
container: {
|
|
254
|
-
// No styles needed here except the View defaults (position: relative etc)
|
|
255
|
-
},
|
|
256
|
-
iconsContainer: {
|
|
257
|
-
position: 'absolute',
|
|
258
|
-
right: 0,
|
|
259
|
-
top: 0,
|
|
260
|
-
bottom: 0,
|
|
261
|
-
justifyContent: 'center'
|
|
262
|
-
}
|
|
263
|
-
})
|
package/src/Tags/Tags.jsx
CHANGED
|
@@ -30,39 +30,49 @@ const [selectItemProps, selectedItemPropTypes] = selectSystemProps([
|
|
|
30
30
|
viewProps
|
|
31
31
|
])
|
|
32
32
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
iconPosition,
|
|
48
|
-
iconSpace,
|
|
49
|
-
iconWrapperStyle: {
|
|
50
|
-
backgroundColor: iconBackground,
|
|
51
|
-
borderRadius: iconBorderRadius,
|
|
52
|
-
alignSelf: iconAlignSelf,
|
|
53
|
-
padding: iconPadding,
|
|
54
|
-
...Platform.select({
|
|
55
|
-
// TODO: https://github.com/telus/universal-design-system/issues/487
|
|
56
|
-
web: { transition: 'color 200ms, background 200ms' }
|
|
57
|
-
})
|
|
33
|
+
const separateIconTextTokens = (
|
|
34
|
+
{
|
|
35
|
+
icon,
|
|
36
|
+
iconPosition,
|
|
37
|
+
iconSpace,
|
|
38
|
+
iconSize,
|
|
39
|
+
iconColor,
|
|
40
|
+
iconBackground,
|
|
41
|
+
iconBorderRadius,
|
|
42
|
+
iconAlignSelf,
|
|
43
|
+
iconPadding,
|
|
44
|
+
iconTranslateX,
|
|
45
|
+
iconTranslateY,
|
|
46
|
+
...rest
|
|
58
47
|
},
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
48
|
+
returnRest
|
|
49
|
+
) =>
|
|
50
|
+
returnRest
|
|
51
|
+
? rest
|
|
52
|
+
: {
|
|
53
|
+
icon,
|
|
54
|
+
iconPosition,
|
|
55
|
+
iconSpace,
|
|
56
|
+
iconWrapperStyle: {
|
|
57
|
+
backgroundColor: iconBackground,
|
|
58
|
+
borderRadius: iconBorderRadius,
|
|
59
|
+
alignSelf: iconAlignSelf,
|
|
60
|
+
padding: iconPadding,
|
|
61
|
+
...Platform.select({
|
|
62
|
+
// TODO: https://github.com/telus/universal-design-system/issues/487
|
|
63
|
+
web: { transition: 'color 200ms, background 200ms' }
|
|
64
|
+
})
|
|
65
|
+
},
|
|
66
|
+
iconTokens: {
|
|
67
|
+
size: iconSize,
|
|
68
|
+
color: iconColor,
|
|
69
|
+
translateX: iconTranslateX,
|
|
70
|
+
translateY: iconTranslateY
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const selectIconTextTokens = (tokens) => separateIconTextTokens(tokens, false)
|
|
75
|
+
const selectNonIconTextTokens = (tokens) => separateIconTextTokens(tokens, true)
|
|
66
76
|
|
|
67
77
|
const Tags = forwardRef(
|
|
68
78
|
(
|
|
@@ -87,7 +97,10 @@ const Tags = forwardRef(
|
|
|
87
97
|
const { direction, space } = themeTokens
|
|
88
98
|
|
|
89
99
|
const getItemTokens = useThemeTokensCallback('TagsItem', tokens, variant)
|
|
90
|
-
|
|
100
|
+
|
|
101
|
+
const getButtonTokens = (buttonState) =>
|
|
102
|
+
// Remove icon-text-related tokens, since we want to handle them ourselves, not use ButtonBase's handling
|
|
103
|
+
selectTokens('Button', selectNonIconTextTokens(getItemTokens(buttonState)))
|
|
91
104
|
|
|
92
105
|
const { currentValues, toggleOneValue } = useMultipleInputValues({
|
|
93
106
|
initialValues,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { forwardRef, useEffect, useState } from 'react'
|
|
2
|
-
import { Platform, StyleSheet, TextInput as NativeTextInput, View } from 'react-native'
|
|
3
|
-
|
|
4
2
|
import PropTypes from 'prop-types'
|
|
3
|
+
import { Platform, StyleSheet, TextInput as NativeTextInput, View } from 'react-native'
|
|
5
4
|
import { applyTextStyles, useTheme, useThemeTokens, applyOuterBorder } from '../ThemeProvider'
|
|
5
|
+
import StackView from '../StackView'
|
|
6
6
|
import {
|
|
7
7
|
a11yProps,
|
|
8
8
|
getTokensPropType,
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
textInputHandlerProps,
|
|
11
11
|
textInputProps,
|
|
12
12
|
useInputValue,
|
|
13
|
+
useSpacingScale,
|
|
13
14
|
variantProp,
|
|
14
15
|
viewProps
|
|
15
16
|
} from '../utils'
|
|
@@ -116,27 +117,35 @@ const selectIconTokens = ({ iconSize, iconColor }) => ({
|
|
|
116
117
|
color: iconColor
|
|
117
118
|
})
|
|
118
119
|
|
|
119
|
-
const selectIconContainerStyles = (
|
|
120
|
-
paddingRight,
|
|
120
|
+
const selectIconContainerStyles = (
|
|
121
|
+
{ buttonSize, buttonsGapSize, paddingRight, paddingBottom },
|
|
122
|
+
buttonCount
|
|
123
|
+
) => ({
|
|
124
|
+
paddingRight: paddingRight + buttonCount * (buttonSize + buttonsGapSize),
|
|
121
125
|
paddingBottom
|
|
122
126
|
})
|
|
123
127
|
|
|
128
|
+
const selectButtonsContainerStyle = ({ buttonsPaddingRight }) => ({
|
|
129
|
+
paddingRight: buttonsPaddingRight
|
|
130
|
+
})
|
|
131
|
+
|
|
124
132
|
const TextInputBase = forwardRef(
|
|
125
133
|
(
|
|
126
134
|
{
|
|
127
|
-
|
|
135
|
+
buttons = [],
|
|
128
136
|
height,
|
|
129
|
-
initialValue,
|
|
130
137
|
inactive,
|
|
131
|
-
|
|
138
|
+
initialValue,
|
|
139
|
+
onBlur,
|
|
132
140
|
onChange,
|
|
133
141
|
onChangeText,
|
|
134
142
|
onFocus,
|
|
135
|
-
onBlur,
|
|
136
|
-
onMouseOver,
|
|
137
143
|
onMouseOut,
|
|
144
|
+
onMouseOver,
|
|
138
145
|
pattern,
|
|
146
|
+
readOnly,
|
|
139
147
|
tokens,
|
|
148
|
+
value,
|
|
140
149
|
variant = {},
|
|
141
150
|
...rest
|
|
142
151
|
},
|
|
@@ -188,7 +197,7 @@ const TextInputBase = forwardRef(
|
|
|
188
197
|
|
|
189
198
|
const themeTokens = useThemeTokens('TextInput', tokens, variant, states)
|
|
190
199
|
|
|
191
|
-
const { icon: IconComponent } = themeTokens
|
|
200
|
+
const { icon: IconComponent, buttonsGap } = themeTokens
|
|
192
201
|
|
|
193
202
|
const inputProps = {
|
|
194
203
|
...selectProps(rest),
|
|
@@ -204,6 +213,9 @@ const TextInputBase = forwardRef(
|
|
|
204
213
|
value: isControlled ? currentValue : undefined
|
|
205
214
|
}
|
|
206
215
|
|
|
216
|
+
// Get the actual gap value for the current viewport
|
|
217
|
+
const buttonsGapSize = useSpacingScale(buttonsGap)
|
|
218
|
+
|
|
207
219
|
const { themeOptions } = useTheme()
|
|
208
220
|
const nativeInputStyle = selectInputStyles({ ...themeTokens, height }, themeOptions, inactive)
|
|
209
221
|
|
|
@@ -213,11 +225,21 @@ const TextInputBase = forwardRef(
|
|
|
213
225
|
{IconComponent && (
|
|
214
226
|
<View
|
|
215
227
|
pointerEvents="none" // avoid hijacking input press events
|
|
216
|
-
style={[
|
|
228
|
+
style={[
|
|
229
|
+
staticStyles.iconContainer,
|
|
230
|
+
selectIconContainerStyles({ ...themeTokens, buttonsGapSize }, buttons?.length)
|
|
231
|
+
]}
|
|
217
232
|
>
|
|
218
233
|
<IconComponent {...selectIconTokens(themeTokens)} />
|
|
219
234
|
</View>
|
|
220
235
|
)}
|
|
236
|
+
{buttons?.length > 0 && (
|
|
237
|
+
<View style={[staticStyles.buttonsContainer, selectButtonsContainerStyle(themeTokens)]}>
|
|
238
|
+
<StackView direction="row" space={buttonsGap}>
|
|
239
|
+
{buttons}
|
|
240
|
+
</StackView>
|
|
241
|
+
</View>
|
|
242
|
+
)}
|
|
221
243
|
</View>
|
|
222
244
|
)
|
|
223
245
|
}
|
|
@@ -226,24 +248,32 @@ TextInputBase.displayName = 'TextInputBase'
|
|
|
226
248
|
|
|
227
249
|
TextInputBase.propTypes = {
|
|
228
250
|
...selectedSystemPropTypes,
|
|
229
|
-
|
|
251
|
+
buttons: PropTypes.arrayOf(PropTypes.node),
|
|
230
252
|
height: PropTypes.number,
|
|
231
|
-
initialValue: PropTypes.string,
|
|
232
253
|
inactive: PropTypes.bool,
|
|
233
|
-
|
|
254
|
+
initialValue: PropTypes.string,
|
|
255
|
+
onBlur: PropTypes.func,
|
|
234
256
|
onChange: PropTypes.func,
|
|
235
257
|
onChangeText: PropTypes.func,
|
|
236
258
|
onFocus: PropTypes.func,
|
|
237
|
-
onBlur: PropTypes.func,
|
|
238
|
-
onMouseOver: PropTypes.func,
|
|
239
259
|
onMouseOut: PropTypes.func,
|
|
260
|
+
onMouseOver: PropTypes.func,
|
|
261
|
+
readOnly: PropTypes.bool,
|
|
240
262
|
tokens: getTokensPropType('TextInput', 'TextArea'),
|
|
263
|
+
value: PropTypes.string,
|
|
241
264
|
variant: variantProp.propType
|
|
242
265
|
}
|
|
243
266
|
|
|
244
267
|
export default TextInputBase
|
|
245
268
|
|
|
246
269
|
const staticStyles = StyleSheet.create({
|
|
270
|
+
buttonsContainer: {
|
|
271
|
+
position: 'absolute',
|
|
272
|
+
right: 0,
|
|
273
|
+
top: 0,
|
|
274
|
+
bottom: 0,
|
|
275
|
+
justifyContent: 'center'
|
|
276
|
+
},
|
|
247
277
|
iconContainer: {
|
|
248
278
|
position: 'absolute',
|
|
249
279
|
right: 0,
|
package/src/index.js
CHANGED
|
@@ -29,6 +29,7 @@ export { default as Radio } from './Radio'
|
|
|
29
29
|
export * from './Radio'
|
|
30
30
|
export { default as RadioCard } from './RadioCard'
|
|
31
31
|
export * from './RadioCard'
|
|
32
|
+
export { default as Responsive } from './Responsive'
|
|
32
33
|
export { default as Search } from './Search'
|
|
33
34
|
export { default as Select } from './Select'
|
|
34
35
|
export { default as SideNav } from './SideNav'
|