@telus-uds/components-base 1.8.2 → 1.8.5
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 +33 -2
- package/component-docs.json +36 -1
- package/lib/ActivityIndicator/Spinner.js +7 -7
- package/lib/ActivityIndicator/Spinner.native.js +2 -2
- package/lib/Button/ButtonBase.js +2 -2
- package/lib/Button/ButtonGroup.js +1 -1
- package/lib/Checkbox/Checkbox.js +5 -3
- package/lib/Checkbox/CheckboxGroup.js +2 -2
- package/lib/Divider/Divider.js +2 -2
- package/lib/ExpandCollapse/Panel.js +2 -17
- package/lib/FlexGrid/Col/Col.js +1 -1
- package/lib/Icon/Icon.js +1 -1
- package/lib/Link/InlinePressable.js +5 -1
- package/lib/Link/LinkBase.js +5 -2
- package/lib/List/List.js +12 -7
- package/lib/List/ListItem.js +4 -5
- package/lib/Modal/Modal.js +2 -1
- package/lib/Pagination/PageButton.js +2 -2
- package/lib/Pagination/Pagination.js +5 -3
- package/lib/Pagination/usePagination.js +2 -2
- package/lib/Progress/ProgressBar.js +3 -3
- package/lib/Progress/ProgressBarBackground.js +3 -3
- 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/Search/Search.js +1 -1
- 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 +3 -1
- package/lib/StackView/getStackedContent.js +2 -2
- package/lib/Tabs/Tabs.js +28 -3
- package/lib/Tabs/TabsItem.js +5 -6
- package/lib/Tags/Tags.js +1 -1
- package/lib/ThemeProvider/utils/styles.js +2 -2
- package/lib/ThemeProvider/utils/theme-tokens.js +7 -9
- package/lib/ToggleSwitch/ToggleSwitch.js +1 -1
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +1 -1
- package/lib/Tooltip/Backdrop.js +2 -10
- package/lib/utils/animation/useVerticalExpandAnimation.js +40 -14
- package/lib/utils/children.js +2 -2
- package/lib/utils/input.js +6 -12
- 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/useSpacingScale.js +3 -1
- package/lib/utils/useUniqueId.js +1 -1
- package/lib-module/A11yInfoProvider/index.js +63 -0
- package/lib-module/A11yText/index.js +56 -0
- package/lib-module/ActivityIndicator/Spinner.js +77 -0
- package/lib-module/ActivityIndicator/Spinner.native.js +144 -0
- package/lib-module/ActivityIndicator/index.js +41 -0
- package/lib-module/ActivityIndicator/shared.js +12 -0
- package/lib-module/BaseProvider/index.js +29 -0
- package/lib-module/Box/Box.js +244 -0
- package/lib-module/Box/index.js +2 -0
- package/lib-module/Button/Button.js +26 -0
- package/lib-module/Button/ButtonBase.js +271 -0
- package/lib-module/Button/ButtonGroup.js +247 -0
- package/lib-module/Button/ButtonLink.js +40 -0
- package/lib-module/Button/index.js +4 -0
- package/lib-module/Button/propTypes.js +36 -0
- package/lib-module/Card/Card.js +84 -0
- package/lib-module/Card/CardBase.js +66 -0
- package/lib-module/Card/PressableCardBase.js +114 -0
- package/lib-module/Card/index.js +4 -0
- package/lib-module/Checkbox/Checkbox.js +348 -0
- package/lib-module/Checkbox/CheckboxGroup.js +233 -0
- package/lib-module/Checkbox/CheckboxInput.js +60 -0
- package/lib-module/Checkbox/CheckboxInput.native.js +6 -0
- package/lib-module/Checkbox/index.js +3 -0
- package/lib-module/Divider/Divider.js +124 -0
- package/lib-module/Divider/index.js +2 -0
- package/lib-module/ExpandCollapse/Accordion.js +15 -0
- package/lib-module/ExpandCollapse/Control.js +136 -0
- package/lib-module/ExpandCollapse/ExpandCollapse.js +95 -0
- package/lib-module/ExpandCollapse/Panel.js +151 -0
- package/lib-module/ExpandCollapse/index.js +7 -0
- package/lib-module/Feedback/Feedback.js +157 -0
- package/lib-module/Feedback/index.js +2 -0
- package/lib-module/Fieldset/Fieldset.js +153 -0
- package/lib-module/Fieldset/FieldsetContainer.js +32 -0
- package/lib-module/Fieldset/FieldsetContainer.native.js +23 -0
- package/lib-module/Fieldset/Legend.js +24 -0
- package/lib-module/Fieldset/Legend.native.js +31 -0
- package/lib-module/Fieldset/cssReset.js +14 -0
- package/lib-module/Fieldset/index.js +2 -0
- package/lib-module/FlexGrid/Col/Col.js +276 -0
- package/lib-module/FlexGrid/Col/index.js +2 -0
- package/lib-module/FlexGrid/FlexGrid.js +148 -0
- package/lib-module/FlexGrid/Row/Row.js +184 -0
- package/lib-module/FlexGrid/Row/index.js +2 -0
- package/lib-module/FlexGrid/helpers/index.js +18 -0
- package/lib-module/FlexGrid/index.js +2 -0
- package/lib-module/FlexGrid/providers/GutterContext.js +3 -0
- package/lib-module/HorizontalScroll/HorizontalScroll.js +175 -0
- package/lib-module/HorizontalScroll/HorizontalScrollButton.js +81 -0
- package/lib-module/HorizontalScroll/ScrollViewEnd.js +48 -0
- package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +27 -0
- package/lib-module/HorizontalScroll/dictionary.js +11 -0
- package/lib-module/HorizontalScroll/index.js +11 -0
- package/lib-module/HorizontalScroll/itemPositions.js +112 -0
- package/lib-module/Icon/Icon.js +62 -0
- package/lib-module/Icon/IconText.js +83 -0
- package/lib-module/Icon/index.js +4 -0
- package/lib-module/IconButton/IconButton.js +122 -0
- package/lib-module/IconButton/index.js +2 -0
- package/lib-module/InputLabel/InputLabel.js +148 -0
- package/lib-module/InputLabel/LabelContent.js +27 -0
- package/lib-module/InputLabel/LabelContent.native.js +19 -0
- package/lib-module/InputLabel/index.js +2 -0
- package/lib-module/InputSupports/InputSupports.js +96 -0
- package/lib-module/InputSupports/index.js +2 -0
- package/lib-module/InputSupports/useInputSupports.js +32 -0
- package/lib-module/Link/ChevronLink.js +52 -0
- package/lib-module/Link/InlinePressable.js +44 -0
- package/lib-module/Link/InlinePressable.native.js +89 -0
- package/lib-module/Link/Link.js +28 -0
- package/lib-module/Link/LinkBase.js +243 -0
- package/lib-module/Link/TextButton.js +35 -0
- package/lib-module/Link/index.js +5 -0
- package/lib-module/List/List.js +62 -0
- package/lib-module/List/ListItem.js +248 -0
- package/lib-module/List/index.js +5 -0
- package/lib-module/Modal/Modal.js +222 -0
- package/lib-module/Modal/dictionary.js +9 -0
- package/lib-module/Modal/index.js +2 -0
- package/lib-module/Notification/Notification.js +209 -0
- package/lib-module/Notification/dictionary.js +8 -0
- package/lib-module/Notification/index.js +2 -0
- package/lib-module/Pagination/PageButton.js +66 -0
- package/lib-module/Pagination/Pagination.js +153 -0
- package/lib-module/Pagination/SideButton.js +106 -0
- package/lib-module/Pagination/dictionary.js +18 -0
- package/lib-module/Pagination/index.js +2 -0
- package/lib-module/Pagination/usePagination.js +73 -0
- package/lib-module/Progress/Progress.js +89 -0
- package/lib-module/Progress/ProgressBar.js +138 -0
- package/lib-module/Progress/ProgressBarBackground.js +42 -0
- package/lib-module/Progress/index.js +4 -0
- package/lib-module/Radio/Radio.js +285 -0
- package/lib-module/Radio/RadioButton.js +138 -0
- package/lib-module/Radio/RadioGroup.js +243 -0
- package/lib-module/Radio/RadioInput.js +62 -0
- package/lib-module/Radio/RadioInput.native.js +6 -0
- package/lib-module/Radio/index.js +3 -0
- package/lib-module/RadioCard/RadioCard.js +219 -0
- package/lib-module/RadioCard/RadioCardGroup.js +250 -0
- package/lib-module/RadioCard/index.js +3 -0
- package/lib-module/Search/Search.js +261 -0
- package/lib-module/Search/dictionary.js +12 -0
- package/lib-module/Search/index.js +2 -0
- package/lib-module/Select/Group.js +21 -0
- package/lib-module/Select/Group.native.js +15 -0
- package/lib-module/Select/Item.js +20 -0
- package/lib-module/Select/Item.native.js +3 -0
- package/lib-module/Select/Picker.js +68 -0
- package/lib-module/Select/Picker.native.js +120 -0
- package/lib-module/Select/Select.js +337 -0
- package/lib-module/Select/index.js +6 -0
- package/lib-module/SideNav/Item.js +145 -0
- package/lib-module/SideNav/ItemContent.js +48 -0
- package/lib-module/SideNav/ItemsGroup.js +117 -0
- package/lib-module/SideNav/SideNav.js +136 -0
- package/lib-module/SideNav/index.js +1 -0
- package/lib-module/Skeleton/Skeleton.js +179 -0
- package/lib-module/Skeleton/index.js +2 -0
- package/lib-module/Skeleton/skeleton.constant.js +3 -0
- package/lib-module/Skeleton/skeletonWebAnimation.js +18 -0
- package/lib-module/Skeleton/useSkeletonNativeAnimation.js +24 -0
- package/lib-module/Spacer/Spacer.js +98 -0
- package/lib-module/Spacer/index.js +2 -0
- package/lib-module/StackView/StackView.js +125 -0
- package/lib-module/StackView/StackWrap.js +50 -0
- package/lib-module/StackView/StackWrap.native.js +3 -0
- package/lib-module/StackView/StackWrapBox.js +115 -0
- package/lib-module/StackView/StackWrapGap.js +59 -0
- package/lib-module/StackView/common.js +35 -0
- package/lib-module/StackView/getStackedContent.js +124 -0
- package/lib-module/StackView/index.js +5 -0
- package/lib-module/StepTracker/Step.js +248 -0
- package/lib-module/StepTracker/StepTracker.js +185 -0
- package/lib-module/StepTracker/dictionary.js +10 -0
- package/lib-module/StepTracker/index.js +2 -0
- package/lib-module/Tabs/Tabs.js +143 -0
- package/lib-module/Tabs/TabsItem.js +224 -0
- package/lib-module/Tabs/index.js +2 -0
- package/lib-module/Tags/Tags.js +251 -0
- package/lib-module/Tags/index.js +2 -0
- package/lib-module/TextInput/TextArea.js +94 -0
- package/lib-module/TextInput/TextInput.js +72 -0
- package/lib-module/TextInput/TextInputBase.js +245 -0
- package/lib-module/TextInput/index.js +3 -0
- package/lib-module/TextInput/propTypes.js +37 -0
- package/lib-module/ThemeProvider/ThemeProvider.js +36 -0
- package/lib-module/ThemeProvider/index.js +6 -0
- package/lib-module/ThemeProvider/useSetTheme.js +25 -0
- package/lib-module/ThemeProvider/useTheme.js +14 -0
- package/lib-module/ThemeProvider/useThemeTokens.js +110 -0
- package/lib-module/ThemeProvider/utils/index.js +2 -0
- package/lib-module/ThemeProvider/utils/styles.js +181 -0
- package/lib-module/ThemeProvider/utils/theme-tokens.js +163 -0
- package/lib-module/ToggleSwitch/ToggleSwitch.js +250 -0
- package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +220 -0
- package/lib-module/ToggleSwitch/index.js +3 -0
- package/lib-module/Tooltip/Backdrop.js +45 -0
- package/lib-module/Tooltip/Backdrop.native.js +44 -0
- package/lib-module/Tooltip/Tooltip.js +348 -0
- package/lib-module/Tooltip/dictionary.js +8 -0
- package/lib-module/Tooltip/getTooltipPosition.js +175 -0
- package/lib-module/Tooltip/index.js +2 -0
- package/lib-module/TooltipButton/TooltipButton.js +78 -0
- package/lib-module/TooltipButton/index.js +2 -0
- package/lib-module/Typography/Typography.js +124 -0
- package/lib-module/Typography/index.js +2 -0
- package/lib-module/ViewportProvider/ViewportProvider.js +29 -0
- package/lib-module/ViewportProvider/index.js +3 -0
- package/lib-module/ViewportProvider/useViewport.js +3 -0
- package/lib-module/ViewportProvider/useViewportListener.js +46 -0
- package/lib-module/index.js +48 -0
- package/lib-module/utils/a11y/index.js +2 -0
- package/lib-module/utils/a11y/semantics.js +157 -0
- package/lib-module/utils/a11y/textSize.js +36 -0
- package/lib-module/utils/animation/index.js +2 -0
- package/lib-module/utils/animation/useVerticalExpandAnimation.js +88 -0
- package/lib-module/utils/children.js +119 -0
- package/lib-module/utils/containUniqueFields.js +26 -0
- package/lib-module/utils/index.js +16 -0
- package/lib-module/utils/info/index.js +7 -0
- package/lib-module/utils/info/platform/index.js +11 -0
- package/lib-module/utils/info/platform/platform.android.js +1 -0
- package/lib-module/utils/info/platform/platform.ios.js +1 -0
- package/lib-module/utils/info/platform/platform.js +1 -0
- package/lib-module/utils/info/platform/platform.native.js +4 -0
- package/lib-module/utils/info/versions.js +5 -0
- package/lib-module/utils/input.js +179 -0
- package/lib-module/utils/pressability.js +111 -0
- package/lib-module/utils/props/a11yProps.js +140 -0
- package/lib-module/utils/props/clickProps.js +26 -0
- package/lib-module/utils/props/componentPropType.js +63 -0
- package/lib-module/utils/props/copyPropTypes.js +2 -0
- package/lib-module/utils/props/getPropSelector.js +9 -0
- package/lib-module/utils/props/handlerProps.js +65 -0
- package/lib-module/utils/props/hrefAttrsProp.js +33 -0
- package/lib-module/utils/props/index.js +19 -0
- package/lib-module/utils/props/inputSupportsProps.js +62 -0
- package/lib-module/utils/props/linkProps.js +44 -0
- package/lib-module/utils/props/paddingProp.js +9 -0
- package/lib-module/utils/props/pressProps.js +42 -0
- package/lib-module/utils/props/rectProp.js +9 -0
- package/lib-module/utils/props/responsiveProps.js +30 -0
- package/lib-module/utils/props/selectSystemProps.js +24 -0
- package/lib-module/utils/props/spacingProps.js +56 -0
- package/lib-module/utils/props/textInputProps.js +194 -0
- package/lib-module/utils/props/textProps.js +59 -0
- package/lib-module/utils/props/tokens.js +133 -0
- package/lib-module/utils/props/variantProp.js +18 -0
- package/lib-module/utils/props/viewProps.js +22 -0
- package/lib-module/utils/ssr.js +38 -0
- package/lib-module/utils/useCopy.js +44 -0
- package/lib-module/utils/useHash.js +45 -0
- package/lib-module/utils/useHash.native.js +7 -0
- package/lib-module/utils/useResponsiveProp.js +47 -0
- package/lib-module/utils/useSpacingScale.js +125 -0
- package/lib-module/utils/useUniqueId.js +13 -0
- package/lib-module/utils/withLinkRouter.js +83 -0
- package/package.json +3 -2
- package/src/Checkbox/Checkbox.jsx +3 -1
- package/src/ExpandCollapse/Panel.jsx +2 -19
- package/src/Link/InlinePressable.jsx +5 -2
- package/src/Link/LinkBase.jsx +4 -1
- package/src/List/List.jsx +34 -19
- package/src/List/ListItem.jsx +12 -2
- package/src/Modal/Modal.jsx +2 -1
- package/src/Tabs/Tabs.jsx +24 -2
- package/src/Tabs/TabsItem.jsx +6 -5
- package/src/utils/animation/useVerticalExpandAnimation.js +47 -13
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import View from "react-native-web/dist/exports/View";
|
|
3
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { useThemeTokens, useThemeTokensCallback } from '../ThemeProvider';
|
|
6
|
+
import { a11yProps, getTokensPropType, selectSystemProps, selectTokens, useInputValue, useSpacingScale, textInputHandlerProps, textInputProps, variantProp, viewProps } from '../utils';
|
|
7
|
+
import TextInputBase from '../TextInput/TextInputBase';
|
|
8
|
+
import ButtonBase from '../Button/ButtonBase';
|
|
9
|
+
import StackView from '../StackView';
|
|
10
|
+
import useCopy from '../utils/useCopy';
|
|
11
|
+
import dictionary from './dictionary';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
const [selectContainerProps, selectedContainerPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
15
|
+
const [selectInputProps, selectedInputPropTypes] = selectSystemProps([textInputHandlerProps, textInputProps]);
|
|
16
|
+
|
|
17
|
+
const selectInputTokens = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
searchTokens,
|
|
20
|
+
buttonTokens,
|
|
21
|
+
buttonsGapSize
|
|
22
|
+
} = _ref;
|
|
23
|
+
const {
|
|
24
|
+
paddingRight: inputPaddingRight,
|
|
25
|
+
clearButtonIcon,
|
|
26
|
+
submitButtonIcon
|
|
27
|
+
} = searchTokens;
|
|
28
|
+
const {
|
|
29
|
+
paddingLeft = 0,
|
|
30
|
+
paddingRight = 0,
|
|
31
|
+
iconSize = 0
|
|
32
|
+
} = buttonTokens;
|
|
33
|
+
const buttonWidth = paddingLeft + paddingRight + iconSize;
|
|
34
|
+
const paddingWithButtons = inputPaddingRight + (submitButtonIcon ? buttonWidth : 0) + (clearButtonIcon ? buttonsGapSize + buttonWidth : 0);
|
|
35
|
+
return { ...selectTokens('TextInput', searchTokens),
|
|
36
|
+
paddingRight: paddingWithButtons
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const selectButtonTokens = tokens => selectTokens('Button', tokens);
|
|
41
|
+
|
|
42
|
+
const selectIconsContainerStyle = _ref2 => {
|
|
43
|
+
let {
|
|
44
|
+
paddingRight
|
|
45
|
+
} = _ref2;
|
|
46
|
+
return {
|
|
47
|
+
paddingRight
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const selectIconTokens = _ref3 => {
|
|
52
|
+
let {
|
|
53
|
+
iconSize,
|
|
54
|
+
iconColor
|
|
55
|
+
} = _ref3;
|
|
56
|
+
return {
|
|
57
|
+
color: iconColor,
|
|
58
|
+
size: iconSize
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* The `Search` component is a combination of a `TextInput` and 2 different kinds of custom buttons.
|
|
63
|
+
* Use `Search` to feature autocomplete interactions.
|
|
64
|
+
*
|
|
65
|
+
* This component includes a clear button, which will appear as text is entered and pressing it will
|
|
66
|
+
* cause the input's internal state value to be set to an empty string.
|
|
67
|
+
*
|
|
68
|
+
* This component may only be used as uncontrolled, as the search value is managed within an internal state.
|
|
69
|
+
* You can use the `onChange` prop to react to value changes and the `onSubmit` prop to react on search submission.
|
|
70
|
+
*
|
|
71
|
+
* Use the following props to supply additional accessibility labels for the input - `accessibilityLabel`,
|
|
72
|
+
* clear button - `clearButtonAccessibilityLabel`, and submit button - `submitButtonAccessibilityLabel`.
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
const Search = /*#__PURE__*/forwardRef((_ref4, ref) => {
|
|
77
|
+
let {
|
|
78
|
+
initialValue,
|
|
79
|
+
value,
|
|
80
|
+
placeholder,
|
|
81
|
+
inactive,
|
|
82
|
+
onChange,
|
|
83
|
+
onSubmit,
|
|
84
|
+
onClear,
|
|
85
|
+
onFocus,
|
|
86
|
+
accessibilityLabel,
|
|
87
|
+
copy = 'en',
|
|
88
|
+
tokens,
|
|
89
|
+
variant,
|
|
90
|
+
...rest
|
|
91
|
+
} = _ref4;
|
|
92
|
+
const {
|
|
93
|
+
currentValue = '',
|
|
94
|
+
setValue
|
|
95
|
+
} = useInputValue({
|
|
96
|
+
value,
|
|
97
|
+
initialValue,
|
|
98
|
+
onChange
|
|
99
|
+
});
|
|
100
|
+
const themeTokens = useThemeTokens('Search', tokens, variant);
|
|
101
|
+
const buttonTokens = useThemeTokens('SearchButton', tokens, variant);
|
|
102
|
+
const getThemeTokens = useThemeTokensCallback('Search', tokens, variant);
|
|
103
|
+
const getButtonTokens = useThemeTokensCallback('SearchButton', tokens, variant); // TODO: support overriding the a11y props using a custom dictionary
|
|
104
|
+
|
|
105
|
+
const getCopy = useCopy({
|
|
106
|
+
dictionary,
|
|
107
|
+
copy
|
|
108
|
+
});
|
|
109
|
+
const {
|
|
110
|
+
placeholderColor,
|
|
111
|
+
buttonsGap,
|
|
112
|
+
clearButtonIcon: ClearButtonIcon,
|
|
113
|
+
submitButtonIcon: SubmitButtonIcon
|
|
114
|
+
} = themeTokens; // get the actual gap value for the current viewport
|
|
115
|
+
|
|
116
|
+
const buttonsGapSize = useSpacingScale(buttonsGap);
|
|
117
|
+
|
|
118
|
+
const handleSubmit = event => {
|
|
119
|
+
if (onSubmit !== undefined) {
|
|
120
|
+
onSubmit(currentValue, event);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const handleClear = event => {
|
|
125
|
+
setValue('', event);
|
|
126
|
+
if (onClear !== undefined) onClear('', event);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const handleFocus = event => {
|
|
130
|
+
if (onFocus !== undefined) onFocus(event);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const isEmpty = currentValue === ''; // Accessibility label should always be present and correctly localised
|
|
134
|
+
|
|
135
|
+
const a11yLabelText = accessibilityLabel || getCopy('accessibilityLabel'); // Placeholder is optional and may be unset by passing an empty string
|
|
136
|
+
|
|
137
|
+
const placeholderText = placeholder !== null && placeholder !== void 0 ? placeholder : a11yLabelText;
|
|
138
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
139
|
+
style: staticStyles.container,
|
|
140
|
+
...selectContainerProps(rest),
|
|
141
|
+
children: [/*#__PURE__*/_jsx(TextInputBase, { ...selectInputProps(rest),
|
|
142
|
+
ref: ref,
|
|
143
|
+
tokens: appearances => selectInputTokens({
|
|
144
|
+
searchTokens: getThemeTokens(appearances),
|
|
145
|
+
buttonTokens,
|
|
146
|
+
buttonsGapSize,
|
|
147
|
+
isEmpty
|
|
148
|
+
}),
|
|
149
|
+
placeholder: placeholderText,
|
|
150
|
+
placeholderTextColor: placeholderColor,
|
|
151
|
+
inactive: inactive,
|
|
152
|
+
enablesReturnKeyAutomatically: true,
|
|
153
|
+
returnKeyType: "search",
|
|
154
|
+
value: currentValue,
|
|
155
|
+
onChange: setValue,
|
|
156
|
+
onSubmitEditing: handleSubmit,
|
|
157
|
+
onFocus: handleFocus,
|
|
158
|
+
accessibilityLabel: a11yLabelText
|
|
159
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
160
|
+
style: [staticStyles.iconsContainer, selectIconsContainerStyle(themeTokens)],
|
|
161
|
+
children: /*#__PURE__*/_jsxs(StackView, {
|
|
162
|
+
direction: "row",
|
|
163
|
+
space: buttonsGap,
|
|
164
|
+
children: [ClearButtonIcon && !isEmpty && /*#__PURE__*/_jsx(ButtonBase, {
|
|
165
|
+
onPress: handleClear,
|
|
166
|
+
inactive: inactive,
|
|
167
|
+
accessibilityRole: "button",
|
|
168
|
+
accessibilityLabel: getCopy('clearButtonAccessibilityLabel'),
|
|
169
|
+
tokens: appearances => selectButtonTokens(getButtonTokens(appearances)),
|
|
170
|
+
children: buttonState => /*#__PURE__*/_jsx(ClearButtonIcon, { ...selectIconTokens(getButtonTokens(buttonState))
|
|
171
|
+
})
|
|
172
|
+
}), SubmitButtonIcon && /*#__PURE__*/_jsx(ButtonBase, {
|
|
173
|
+
onPress: handleSubmit,
|
|
174
|
+
inactive: inactive,
|
|
175
|
+
accessibilityRole: "button",
|
|
176
|
+
accessibilityLabel: getCopy('submitButtonAccessibilityLabel'),
|
|
177
|
+
tokens: buttonState => selectButtonTokens(getButtonTokens({ ...buttonState,
|
|
178
|
+
priority: 'high'
|
|
179
|
+
})),
|
|
180
|
+
children: buttonState => /*#__PURE__*/_jsx(SubmitButtonIcon, { ...selectIconTokens(getButtonTokens({ ...buttonState,
|
|
181
|
+
priority: 'high'
|
|
182
|
+
}))
|
|
183
|
+
})
|
|
184
|
+
})]
|
|
185
|
+
})
|
|
186
|
+
})]
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
Search.displayName = 'Search';
|
|
190
|
+
Search.propTypes = { ...selectedContainerPropTypes,
|
|
191
|
+
...selectedInputPropTypes,
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Use this to set the initial value of the search input.
|
|
195
|
+
* Updating `initialValue` will **not** update the actual value.
|
|
196
|
+
*/
|
|
197
|
+
initialValue: PropTypes.string,
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Label rendered in the search input when it has no value.
|
|
201
|
+
*/
|
|
202
|
+
placeholder: PropTypes.string,
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Disables all user interactions with the search input.
|
|
206
|
+
*/
|
|
207
|
+
inactive: PropTypes.bool,
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Use to react upon search input's value changes.
|
|
211
|
+
* Will receive the searched value as an argument.
|
|
212
|
+
*/
|
|
213
|
+
onChange: PropTypes.func,
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Triggered when the search input is submitted,
|
|
217
|
+
* either by pressing the submit button, "Enter" key on web,
|
|
218
|
+
* or "Search" key in a mobile keyboard.
|
|
219
|
+
*/
|
|
220
|
+
onSubmit: PropTypes.func,
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Triggered when the clear button is pressed.
|
|
224
|
+
*/
|
|
225
|
+
onClear: PropTypes.func,
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Triggered when the search input is focused.
|
|
229
|
+
*/
|
|
230
|
+
onFocus: PropTypes.func,
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
*
|
|
234
|
+
* Use to provide an accessible label for the input (visually hidden).
|
|
235
|
+
*/
|
|
236
|
+
accessibilityLabel: PropTypes.string,
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Select English or French copy for the accessible labels.
|
|
240
|
+
* You may also pass in a custom dictionary object.
|
|
241
|
+
*/
|
|
242
|
+
copy: PropTypes.oneOfType([PropTypes.oneOf(['en', 'fr']), PropTypes.shape({
|
|
243
|
+
accessibilityLabel: PropTypes.string,
|
|
244
|
+
clearButtonAccessibilityLabel: PropTypes.string,
|
|
245
|
+
submitButtonAccessibilityLabel: PropTypes.string
|
|
246
|
+
})]),
|
|
247
|
+
tokens: getTokensPropType('Search'),
|
|
248
|
+
variant: variantProp.propType
|
|
249
|
+
};
|
|
250
|
+
export default Search;
|
|
251
|
+
const staticStyles = StyleSheet.create({
|
|
252
|
+
container: {// No styles needed here except the View defaults (position: relative etc)
|
|
253
|
+
},
|
|
254
|
+
iconsContainer: {
|
|
255
|
+
position: 'absolute',
|
|
256
|
+
right: 0,
|
|
257
|
+
top: 0,
|
|
258
|
+
bottom: 0,
|
|
259
|
+
justifyContent: 'center'
|
|
260
|
+
}
|
|
261
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
en: {
|
|
3
|
+
accessibilityLabel: 'Search',
|
|
4
|
+
clearButtonAccessibilityLabel: 'Clear',
|
|
5
|
+
submitButtonAccessibilityLabel: 'Search'
|
|
6
|
+
},
|
|
7
|
+
fr: {
|
|
8
|
+
accessibilityLabel: 'Chercher',
|
|
9
|
+
clearButtonAccessibilityLabel: 'Effacer',
|
|
10
|
+
submitButtonAccessibilityLabel: 'Chercher'
|
|
11
|
+
}
|
|
12
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { componentPropType } from '../utils';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
const Group = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
children,
|
|
9
|
+
label
|
|
10
|
+
} = _ref;
|
|
11
|
+
return /*#__PURE__*/_jsx("optgroup", {
|
|
12
|
+
label: label,
|
|
13
|
+
children: children
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default Group;
|
|
18
|
+
Group.propTypes = {
|
|
19
|
+
children: componentPropType('Item'),
|
|
20
|
+
label: PropTypes.string.isRequired
|
|
21
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import { componentPropType } from '../utils';
|
|
3
|
+
|
|
4
|
+
const Group = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
children
|
|
7
|
+
} = _ref;
|
|
8
|
+
return children;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default Group;
|
|
12
|
+
Group.propTypes = {
|
|
13
|
+
children: componentPropType('Item'),
|
|
14
|
+
label: PropTypes.string.isRequired
|
|
15
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
const Item = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
value
|
|
9
|
+
} = _ref;
|
|
10
|
+
return /*#__PURE__*/_jsx("option", {
|
|
11
|
+
value: value,
|
|
12
|
+
children: children
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default Item;
|
|
17
|
+
Item.propTypes = {
|
|
18
|
+
children: PropTypes.string.isRequired,
|
|
19
|
+
value: PropTypes.string.isRequired
|
|
20
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { componentPropType } from '../utils';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
const Picker = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
7
|
+
let {
|
|
8
|
+
value,
|
|
9
|
+
onChange,
|
|
10
|
+
onFocus,
|
|
11
|
+
onBlur,
|
|
12
|
+
onMouseOver,
|
|
13
|
+
onMouseOut,
|
|
14
|
+
style,
|
|
15
|
+
inactive,
|
|
16
|
+
children,
|
|
17
|
+
placeholder,
|
|
18
|
+
nativeID,
|
|
19
|
+
testID,
|
|
20
|
+
...rest
|
|
21
|
+
} = _ref;
|
|
22
|
+
const {
|
|
23
|
+
accessibilityLabel,
|
|
24
|
+
accessibilityDescribedBy,
|
|
25
|
+
accessibilityInvalid
|
|
26
|
+
} = rest;
|
|
27
|
+
return /*#__PURE__*/_jsxs("select", {
|
|
28
|
+
ref: ref,
|
|
29
|
+
style: style,
|
|
30
|
+
onMouseOver: onMouseOver,
|
|
31
|
+
onMouseOut: onMouseOut,
|
|
32
|
+
onFocus: onFocus,
|
|
33
|
+
onBlur: onBlur,
|
|
34
|
+
disabled: inactive,
|
|
35
|
+
value: value || (placeholder !== undefined ? placeholder.value : undefined),
|
|
36
|
+
onChange: event => onChange(event.target.value, event),
|
|
37
|
+
id: nativeID,
|
|
38
|
+
"aria-label": accessibilityLabel,
|
|
39
|
+
"aria-describedby": accessibilityDescribedBy,
|
|
40
|
+
"aria-invalid": accessibilityInvalid,
|
|
41
|
+
"data-testid": testID,
|
|
42
|
+
children: [placeholder !== undefined && /*#__PURE__*/_jsx("option", {
|
|
43
|
+
value: placeholder.value,
|
|
44
|
+
disabled: true,
|
|
45
|
+
hidden: true,
|
|
46
|
+
children: placeholder.label
|
|
47
|
+
}), children]
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
Picker.displayName = 'Picker';
|
|
51
|
+
export default Picker;
|
|
52
|
+
Picker.propTypes = {
|
|
53
|
+
value: PropTypes.string,
|
|
54
|
+
onChange: PropTypes.func,
|
|
55
|
+
onFocus: PropTypes.func,
|
|
56
|
+
onBlur: PropTypes.func,
|
|
57
|
+
onMouseOver: PropTypes.func,
|
|
58
|
+
onMouseOut: PropTypes.func,
|
|
59
|
+
style: PropTypes.object,
|
|
60
|
+
inactive: PropTypes.bool,
|
|
61
|
+
children: componentPropType(['Item', 'Group']),
|
|
62
|
+
placeholder: PropTypes.shape({
|
|
63
|
+
value: PropTypes.string,
|
|
64
|
+
label: PropTypes.string
|
|
65
|
+
}),
|
|
66
|
+
nativeID: PropTypes.string,
|
|
67
|
+
testID: PropTypes.string
|
|
68
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import React, { forwardRef, Children } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import View from "react-native-web/dist/exports/View";
|
|
4
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
5
|
+
import NativePicker from 'react-native-picker-select';
|
|
6
|
+
import { a11yProps, componentPropType } from '../utils';
|
|
7
|
+
import Group from './Group'; // styling of the native input is very limited, most of the styles have to be applied to an additional View
|
|
8
|
+
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
|
|
12
|
+
const selectAndroidInputStyles = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
height = 0,
|
|
15
|
+
paddingBottom = 0,
|
|
16
|
+
paddingTop = 0,
|
|
17
|
+
borderWidth = 0,
|
|
18
|
+
color
|
|
19
|
+
} = _ref;
|
|
20
|
+
return {
|
|
21
|
+
height: height - paddingTop - paddingBottom - 2 * borderWidth,
|
|
22
|
+
color
|
|
23
|
+
};
|
|
24
|
+
}; // the native input has a side padding of 8px, which can't be adjusted, so we have to account for that in the container
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const selectAndroidContainerStyles = _ref2 => {
|
|
28
|
+
let {
|
|
29
|
+
paddingLeft = 0,
|
|
30
|
+
paddingRight = 0,
|
|
31
|
+
...rest
|
|
32
|
+
} = _ref2;
|
|
33
|
+
return {
|
|
34
|
+
paddingLeft: paddingLeft > 8 ? paddingLeft - 8 : 0,
|
|
35
|
+
paddingRight: paddingRight > 8 ? paddingRight - 8 : 0,
|
|
36
|
+
...rest
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const Picker = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
41
|
+
let {
|
|
42
|
+
value,
|
|
43
|
+
onChange,
|
|
44
|
+
onFocus,
|
|
45
|
+
onBlur,
|
|
46
|
+
style,
|
|
47
|
+
inactive,
|
|
48
|
+
children,
|
|
49
|
+
placeholder,
|
|
50
|
+
...rest
|
|
51
|
+
} = _ref3;
|
|
52
|
+
// ungroup items, since there's no way to support groups on native
|
|
53
|
+
const flatChildren = Children.toArray(children).flatMap(child => {
|
|
54
|
+
if (child.type === Group) {
|
|
55
|
+
return child.props.children;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return child;
|
|
59
|
+
});
|
|
60
|
+
const items = flatChildren.map(_ref4 => {
|
|
61
|
+
let {
|
|
62
|
+
props
|
|
63
|
+
} = _ref4;
|
|
64
|
+
return {
|
|
65
|
+
label: props.children,
|
|
66
|
+
value: props.value
|
|
67
|
+
};
|
|
68
|
+
}); // Unlike other input components, react-native-picker-select doesn't pass an event to its change fn.
|
|
69
|
+
|
|
70
|
+
const handleChange = (newValue, index) => {
|
|
71
|
+
if (onChange) onChange(newValue, {
|
|
72
|
+
// TODO: see if it's possible to pass a real React SyntheticEvent here. For now, just pass an
|
|
73
|
+
// object with a shape where if an onChange deconstructs `event.nativeEvent`, it won't crash.
|
|
74
|
+
nativeEvent: {
|
|
75
|
+
index,
|
|
76
|
+
value: newValue
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const picker = /*#__PURE__*/_jsx(NativePicker, {
|
|
82
|
+
pickerProps: {
|
|
83
|
+
ref
|
|
84
|
+
},
|
|
85
|
+
touchableWrapperProps: a11yProps.select(rest),
|
|
86
|
+
onOpen: onFocus,
|
|
87
|
+
onClose: onBlur,
|
|
88
|
+
disabled: inactive,
|
|
89
|
+
items: items,
|
|
90
|
+
value: value,
|
|
91
|
+
onValueChange: handleChange,
|
|
92
|
+
style: {
|
|
93
|
+
inputIOS: style,
|
|
94
|
+
inputAndroid: selectAndroidInputStyles(style)
|
|
95
|
+
},
|
|
96
|
+
placeholder: placeholder !== undefined ? placeholder : {}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
100
|
+
children: Platform.OS === 'android' ? /*#__PURE__*/_jsx(View, {
|
|
101
|
+
style: selectAndroidContainerStyles(style),
|
|
102
|
+
children: picker
|
|
103
|
+
}) : picker
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
Picker.displayName = 'Picker';
|
|
107
|
+
export default Picker;
|
|
108
|
+
Picker.propTypes = {
|
|
109
|
+
value: PropTypes.string,
|
|
110
|
+
onChange: PropTypes.func,
|
|
111
|
+
onFocus: PropTypes.func,
|
|
112
|
+
onBlur: PropTypes.func,
|
|
113
|
+
style: PropTypes.object,
|
|
114
|
+
inactive: PropTypes.bool,
|
|
115
|
+
children: componentPropType(['Item', 'Group']),
|
|
116
|
+
placeholder: PropTypes.shape({
|
|
117
|
+
value: PropTypes.string,
|
|
118
|
+
label: PropTypes.string
|
|
119
|
+
})
|
|
120
|
+
};
|