@jobber/components-native 0.30.0 → 0.32.0
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/README.md +3 -0
- package/dist/src/InputNumber/InputNumber.js +82 -0
- package/dist/src/InputNumber/index.js +1 -0
- package/dist/src/InputNumber/messages.js +8 -0
- package/dist/src/Select/Select.js +79 -0
- package/dist/src/Select/Select.style.js +45 -0
- package/dist/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.js +30 -0
- package/dist/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.js +16 -0
- package/dist/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.style.js +29 -0
- package/dist/src/Select/components/SelectDefaultPicker/index.js +1 -0
- package/dist/src/Select/components/SelectDefaultPicker/messages.js +8 -0
- package/dist/src/Select/components/SelectIOSPicker/SelectIOSPicker.js +2 -0
- package/dist/src/Select/components/SelectIOSPicker/index.js +1 -0
- package/dist/src/Select/components/SelectInternalPicker/SelectInternalPicker.js +14 -0
- package/dist/src/Select/components/SelectInternalPicker/index.js +1 -0
- package/dist/src/Select/components/SelectInternalPicker/utils.js +13 -0
- package/dist/src/Select/components/SelectPressable/SelectPressable.js +15 -0
- package/dist/src/Select/components/SelectPressable/SelectPressable.style.js +7 -0
- package/dist/src/Select/components/SelectPressable/index.js +1 -0
- package/dist/src/Select/index.js +1 -0
- package/dist/src/Select/messages.js +13 -0
- package/dist/src/Select/types.js +1 -0
- package/dist/src/index.js +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/InputNumber/InputNumber.d.ts +20 -0
- package/dist/types/src/InputNumber/index.d.ts +2 -0
- package/dist/types/src/InputNumber/messages.d.ts +7 -0
- package/dist/types/src/Select/Select.d.ts +69 -0
- package/dist/types/src/Select/Select.style.d.ts +56 -0
- package/dist/types/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.d.ts +5 -0
- package/dist/types/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.d.ts +5 -0
- package/dist/types/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.style.d.ts +30 -0
- package/dist/types/src/Select/components/SelectDefaultPicker/index.d.ts +1 -0
- package/dist/types/src/Select/components/SelectDefaultPicker/messages.d.ts +7 -0
- package/dist/types/src/Select/components/SelectIOSPicker/SelectIOSPicker.d.ts +10 -0
- package/dist/types/src/Select/components/SelectIOSPicker/index.d.ts +1 -0
- package/dist/types/src/Select/components/SelectInternalPicker/SelectInternalPicker.d.ts +3 -0
- package/dist/types/src/Select/components/SelectInternalPicker/index.d.ts +1 -0
- package/dist/types/src/Select/components/SelectInternalPicker/utils.d.ts +3 -0
- package/dist/types/src/Select/components/SelectPressable/SelectPressable.d.ts +11 -0
- package/dist/types/src/Select/components/SelectPressable/SelectPressable.style.d.ts +5 -0
- package/dist/types/src/Select/components/SelectPressable/index.d.ts +1 -0
- package/dist/types/src/Select/index.d.ts +1 -0
- package/dist/types/src/Select/messages.d.ts +12 -0
- package/dist/types/src/Select/types.d.ts +38 -0
- package/dist/types/src/index.d.ts +2 -0
- package/ios/ComponentsNative-Bridging-Header.h +2 -0
- package/ios/ComponentsNative.xcodeproj/project.pbxproj +303 -0
- package/ios/Picker/ATLFallBackPickerView.swift +13 -0
- package/ios/Picker/ATLPickerOption.swift +44 -0
- package/ios/Picker/ATLPickerView.swift +61 -0
- package/ios/Picker/RCTATLPickerManager.m +26 -0
- package/ios/Picker/RCTATLPickerManager.swift +25 -0
- package/jobber-components-native.podspec +35 -0
- package/package.json +19 -3
- package/src/InputNumber/InputNumber.test.tsx +323 -0
- package/src/InputNumber/InputNumber.tsx +126 -0
- package/src/InputNumber/index.ts +2 -0
- package/src/InputNumber/messages.ts +10 -0
- package/src/Select/Select.style.ts +51 -0
- package/src/Select/Select.test.tsx +323 -0
- package/src/Select/Select.tsx +240 -0
- package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.tsx +64 -0
- package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.style.ts +30 -0
- package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.test.tsx +76 -0
- package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.tsx +45 -0
- package/src/Select/components/SelectDefaultPicker/index.ts +1 -0
- package/src/Select/components/SelectDefaultPicker/messages.ts +9 -0
- package/src/Select/components/SelectIOSPicker/SelectIOSPicker.tsx +16 -0
- package/src/Select/components/SelectIOSPicker/index.ts +1 -0
- package/src/Select/components/SelectInternalPicker/SelectInternalPicker.test.tsx +100 -0
- package/src/Select/components/SelectInternalPicker/SelectInternalPicker.tsx +33 -0
- package/src/Select/components/SelectInternalPicker/index.ts +1 -0
- package/src/Select/components/SelectInternalPicker/utils.ts +20 -0
- package/src/Select/components/SelectPressable/SelectPressable.style.ts +8 -0
- package/src/Select/components/SelectPressable/SelectPressable.tsx +32 -0
- package/src/Select/components/SelectPressable/index.ts +1 -0
- package/src/Select/index.ts +1 -0
- package/src/Select/messages.ts +14 -0
- package/src/Select/types.ts +46 -0
- package/src/index.ts +2 -0
package/README.md
CHANGED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, { forwardRef, useState } from "react";
|
|
2
|
+
import { Platform } from "react-native";
|
|
3
|
+
import { useIntl } from "react-intl";
|
|
4
|
+
import flow from "lodash/flow";
|
|
5
|
+
import identity from "lodash/identity";
|
|
6
|
+
import { messages } from "./messages";
|
|
7
|
+
import { InputText } from "../InputText";
|
|
8
|
+
const NUMBER_VALIDATION_REGEX = /^[-+]?(([0-9]*\.[0-9]+)|([0-9]+)|([0-9]+(\.?[0-9]+)?e[-+]?[0-9]+))$/;
|
|
9
|
+
export const InputNumber = forwardRef(InputNumberInternal);
|
|
10
|
+
function InputNumberInternal(props, ref) {
|
|
11
|
+
var _a, _b, _c, _d;
|
|
12
|
+
const getKeyboard = () => {
|
|
13
|
+
var _a;
|
|
14
|
+
if (Platform.OS === "ios") {
|
|
15
|
+
//since we are checking for which keyboard to use here here, just implement default keyboard here instead of in params
|
|
16
|
+
return (_a = props.keyboard) !== null && _a !== void 0 ? _a : "numbers-and-punctuation";
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return "numeric";
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const { formatMessage } = useIntl();
|
|
23
|
+
const handleChange = (newValue) => {
|
|
24
|
+
var _a;
|
|
25
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, newValue);
|
|
26
|
+
};
|
|
27
|
+
const { inputTransform: convertToString, outputTransform: convertToNumber } = useNumberTransform(props.value);
|
|
28
|
+
return (React.createElement(InputText, Object.assign({}, props, { keyboard: getKeyboard(), transform: {
|
|
29
|
+
input: flow(convertToString, ((_a = props.transform) === null || _a === void 0 ? void 0 : _a.input) || identity),
|
|
30
|
+
output: flow(convertToNumber, ((_b = props.transform) === null || _b === void 0 ? void 0 : _b.output) || identity),
|
|
31
|
+
}, ref: ref, value: (_c = props.value) === null || _c === void 0 ? void 0 : _c.toString(), defaultValue: (_d = props.defaultValue) === null || _d === void 0 ? void 0 : _d.toString(), onChangeText: handleChange, validations: Object.assign({ pattern: {
|
|
32
|
+
value: NUMBER_VALIDATION_REGEX,
|
|
33
|
+
message: formatMessage(messages.notANumberError),
|
|
34
|
+
} }, props.validations) })));
|
|
35
|
+
}
|
|
36
|
+
function hasPeriodAtEnd(value) {
|
|
37
|
+
// matches patterns like ".", "0.", "12.", "+1.", and "-0."
|
|
38
|
+
return !!(value === null || value === void 0 ? void 0 : value.match(/^[-+]?[0-9]*\.$/));
|
|
39
|
+
}
|
|
40
|
+
function hasScientificNotationAtEnd(value) {
|
|
41
|
+
// matches patterns like "1e", "+2e", "1.2e" and "-3e"
|
|
42
|
+
return !!(value === null || value === void 0 ? void 0 : value.match(/^[-+]?[0-9]+(\.?[0-9]+)?e$/));
|
|
43
|
+
}
|
|
44
|
+
function hasPlusMinusAtEnd(value) {
|
|
45
|
+
// matches "+" and "-"
|
|
46
|
+
return !!(value === null || value === void 0 ? void 0 : value.match(/^[-+]+$/));
|
|
47
|
+
}
|
|
48
|
+
function hasZeroDecimalAtEnd(value) {
|
|
49
|
+
// matches patterns like "0.0", "+0.00000", "-3.00000", "2.100", ".0", and ".00000"
|
|
50
|
+
return !!(value === null || value === void 0 ? void 0 : value.match(/^[-+]?[0-9]*\.[0-9]*0+$/));
|
|
51
|
+
}
|
|
52
|
+
export function shouldShowUserValue(value) {
|
|
53
|
+
const specialCasesFn = [
|
|
54
|
+
hasPeriodAtEnd,
|
|
55
|
+
hasScientificNotationAtEnd,
|
|
56
|
+
hasPlusMinusAtEnd,
|
|
57
|
+
hasZeroDecimalAtEnd,
|
|
58
|
+
];
|
|
59
|
+
const isSpecial = (v) => specialCasesFn.reduce((acc, fn) => acc || fn(v), false);
|
|
60
|
+
return isSpecial(value);
|
|
61
|
+
}
|
|
62
|
+
export function useNumberTransform(controlledValue) {
|
|
63
|
+
const [typedValue, setTypedValue] = useState((controlledValue === null || controlledValue === void 0 ? void 0 : controlledValue.toString()) || "");
|
|
64
|
+
const convertToNumber = (newValue) => {
|
|
65
|
+
var _a;
|
|
66
|
+
setTypedValue(newValue);
|
|
67
|
+
if ((_a = newValue === null || newValue === void 0 ? void 0 : newValue.match) === null || _a === void 0 ? void 0 : _a.call(newValue, NUMBER_VALIDATION_REGEX)) {
|
|
68
|
+
return parseFloat(newValue);
|
|
69
|
+
}
|
|
70
|
+
return newValue;
|
|
71
|
+
};
|
|
72
|
+
const convertToString = (internalValue) => {
|
|
73
|
+
if (shouldShowUserValue(typedValue)) {
|
|
74
|
+
return typedValue;
|
|
75
|
+
}
|
|
76
|
+
return (internalValue === null || internalValue === void 0 ? void 0 : internalValue.toString()) || undefined;
|
|
77
|
+
};
|
|
78
|
+
return {
|
|
79
|
+
inputTransform: convertToString,
|
|
80
|
+
outputTransform: convertToNumber,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InputNumber } from "./InputNumber";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defineMessages } from "react-intl";
|
|
2
|
+
export const messages = defineMessages({
|
|
3
|
+
notANumberError: {
|
|
4
|
+
id: "notANumberError",
|
|
5
|
+
defaultMessage: "Enter a number",
|
|
6
|
+
description: "Error message shown when a non-numeric value is typed in number input",
|
|
7
|
+
},
|
|
8
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { useIntl } from "react-intl";
|
|
4
|
+
import { styles } from "./Select.style";
|
|
5
|
+
import { SelectInternalPicker } from "./components/SelectInternalPicker";
|
|
6
|
+
import { messages } from "./messages";
|
|
7
|
+
import { InputFieldWrapper } from "../InputFieldWrapper";
|
|
8
|
+
import { Icon } from "../Icon";
|
|
9
|
+
import { Text } from "../Text";
|
|
10
|
+
import { useFormController } from "../hooks";
|
|
11
|
+
export function Select({ value, defaultValue, onChange, children, placeholder, label, assistiveText, disabled, invalid, validations, accessibilityLabel, name, }) {
|
|
12
|
+
const { field, error } = useFormController({
|
|
13
|
+
name,
|
|
14
|
+
validations,
|
|
15
|
+
value: value !== null && value !== void 0 ? value : defaultValue,
|
|
16
|
+
});
|
|
17
|
+
const { formatMessage } = useIntl();
|
|
18
|
+
const internalValue = value !== null && value !== void 0 ? value : field.value;
|
|
19
|
+
const textVariation = getTextVariation({
|
|
20
|
+
disabled,
|
|
21
|
+
invalid: invalid || !!error,
|
|
22
|
+
});
|
|
23
|
+
const valueTextVariation = disabled ? "disabled" : undefined;
|
|
24
|
+
const hasValue = internalValue && (internalValue === null || internalValue === void 0 ? void 0 : internalValue.length) > 0;
|
|
25
|
+
return (React.createElement(InputFieldWrapper, { error: error, invalid: invalid || !!error, hasValue: hasValue, styleOverride: {
|
|
26
|
+
container: { borderBottomWidth: undefined },
|
|
27
|
+
} },
|
|
28
|
+
React.createElement(View, { testID: "ATL-Select", accessible: true, accessibilityLabel: getA11yLabel(), accessibilityValue: { text: getValue() }, accessibilityHint: formatMessage(messages.a11yHint), accessibilityRole: "button", accessibilityState: { disabled: disabled } },
|
|
29
|
+
React.createElement(SelectInternalPicker, { disabled: disabled, options: getOptions(), onChange: handleChange },
|
|
30
|
+
React.createElement(View, { style: [styles.container, (invalid || !!error) && styles.invalid] },
|
|
31
|
+
label && (React.createElement(Text, { level: "textSupporting", variation: textVariation, hideFromScreenReader: true }, label)),
|
|
32
|
+
React.createElement(View, { style: styles.input },
|
|
33
|
+
React.createElement(View, { style: styles.value },
|
|
34
|
+
React.createElement(Text, { variation: disabled ? "disabled" : "base", hideFromScreenReader: true }, getValue())),
|
|
35
|
+
React.createElement(View, { style: styles.icon },
|
|
36
|
+
React.createElement(Icon, { name: "arrowDown", color: valueTextVariation }))))),
|
|
37
|
+
assistiveText && (React.createElement(Text, { level: "textSupporting", variation: textVariation, hideFromScreenReader: true }, assistiveText)))));
|
|
38
|
+
function getA11yLabel() {
|
|
39
|
+
let text = [accessibilityLabel || label, assistiveText];
|
|
40
|
+
text = text.filter(Boolean);
|
|
41
|
+
return text.join(", ");
|
|
42
|
+
}
|
|
43
|
+
function handleChange(val) {
|
|
44
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(val);
|
|
45
|
+
// need this onBlur for validations to occur
|
|
46
|
+
field.onBlur();
|
|
47
|
+
field.onChange(val);
|
|
48
|
+
}
|
|
49
|
+
function getOptions() {
|
|
50
|
+
const options = children.map(({ props }) => ({
|
|
51
|
+
label: props.children,
|
|
52
|
+
value: props.value,
|
|
53
|
+
isActive: props.value === internalValue,
|
|
54
|
+
}));
|
|
55
|
+
if (!internalValue || placeholder) {
|
|
56
|
+
options.unshift({
|
|
57
|
+
label: placeholder || formatMessage(messages.emptyValue),
|
|
58
|
+
value: "",
|
|
59
|
+
isActive: !internalValue,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return options;
|
|
63
|
+
}
|
|
64
|
+
function getValue() {
|
|
65
|
+
const options = getOptions();
|
|
66
|
+
const activeValue = options.find(option => option.isActive);
|
|
67
|
+
return ((activeValue === null || activeValue === void 0 ? void 0 : activeValue.label) || placeholder || formatMessage(messages.emptyValue));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function getTextVariation({ invalid, disabled, }) {
|
|
71
|
+
if (invalid)
|
|
72
|
+
return "error";
|
|
73
|
+
if (disabled)
|
|
74
|
+
return "disabled";
|
|
75
|
+
return "subdued";
|
|
76
|
+
}
|
|
77
|
+
export function Option({ children }) {
|
|
78
|
+
return React.createElement(React.Fragment, null, children);
|
|
79
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { commonInputStyles } from "../InputFieldWrapper";
|
|
3
|
+
import { tokens } from "../utils/design";
|
|
4
|
+
export const styles = StyleSheet.create({
|
|
5
|
+
container: StyleSheet.flatten([
|
|
6
|
+
commonInputStyles.container,
|
|
7
|
+
{
|
|
8
|
+
flexDirection: "column",
|
|
9
|
+
justifyContent: "flex-end",
|
|
10
|
+
minHeight: tokens["space-largest"] + tokens["border-base"],
|
|
11
|
+
},
|
|
12
|
+
]),
|
|
13
|
+
input: StyleSheet.flatten([
|
|
14
|
+
commonInputStyles.input,
|
|
15
|
+
{
|
|
16
|
+
flexDirection: "row",
|
|
17
|
+
flexGrow: 0,
|
|
18
|
+
paddingBottom: tokens["space-smaller"],
|
|
19
|
+
minHeight: 0,
|
|
20
|
+
minWidth: "100%",
|
|
21
|
+
},
|
|
22
|
+
]),
|
|
23
|
+
value: {
|
|
24
|
+
flexGrow: 1,
|
|
25
|
+
flexShrink: 1,
|
|
26
|
+
},
|
|
27
|
+
icon: {
|
|
28
|
+
flexGrow: 0,
|
|
29
|
+
flexShrink: 0,
|
|
30
|
+
},
|
|
31
|
+
invalid: {
|
|
32
|
+
color: tokens["color-critical"],
|
|
33
|
+
borderColor: tokens["color-critical"],
|
|
34
|
+
},
|
|
35
|
+
errorMessageWrapperIcon: {
|
|
36
|
+
flex: 0,
|
|
37
|
+
flexBasis: "auto",
|
|
38
|
+
paddingTop: tokens["space-minuscule"],
|
|
39
|
+
paddingRight: tokens["space-smaller"],
|
|
40
|
+
},
|
|
41
|
+
messageWrapper: {
|
|
42
|
+
paddingTop: tokens["space-smaller"],
|
|
43
|
+
flexDirection: "row",
|
|
44
|
+
},
|
|
45
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
// Need to use iOS style button
|
|
4
|
+
Button, Modal, TouchableOpacity, View, } from "react-native";
|
|
5
|
+
import { Picker } from "@react-native-picker/picker";
|
|
6
|
+
import { SafeAreaView } from "react-native-safe-area-context";
|
|
7
|
+
import { useIntl } from "react-intl";
|
|
8
|
+
import { styles } from "./SelectDefaultPicker.style";
|
|
9
|
+
import { messages } from "./messages";
|
|
10
|
+
import { SelectPressable } from "../SelectPressable/SelectPressable";
|
|
11
|
+
export function SelectDefaultPicker({ children, options, onChange, }) {
|
|
12
|
+
const [show, setShow] = useState(false);
|
|
13
|
+
const { formatMessage } = useIntl();
|
|
14
|
+
const selectedLanguage = options.find(option => option.isActive);
|
|
15
|
+
return (React.createElement(React.Fragment, null,
|
|
16
|
+
React.createElement(SelectPressable, { onPress: showPicker }, children),
|
|
17
|
+
React.createElement(Modal, { visible: show, transparent: true, animationType: "slide", onRequestClose: hidePicker },
|
|
18
|
+
React.createElement(TouchableOpacity, { style: styles.overlay, onPress: hidePicker }),
|
|
19
|
+
React.createElement(View, { style: styles.actionBar },
|
|
20
|
+
React.createElement(Button, { title: formatMessage(messages.done), onPress: hidePicker })),
|
|
21
|
+
React.createElement(View, { style: styles.pickerContainer, testID: "select-wheel-picker" },
|
|
22
|
+
React.createElement(SafeAreaView, { edges: ["bottom"] },
|
|
23
|
+
React.createElement(Picker, { selectedValue: selectedLanguage === null || selectedLanguage === void 0 ? void 0 : selectedLanguage.value, onValueChange: onChange }, options.map(({ label, value }, i) => (React.createElement(Picker.Item, { key: i, label: label, value: value })))))))));
|
|
24
|
+
function showPicker() {
|
|
25
|
+
setShow(true);
|
|
26
|
+
}
|
|
27
|
+
function hidePicker() {
|
|
28
|
+
setShow(false);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { useRef } from "react";
|
|
2
|
+
import { Picker } from "@react-native-picker/picker";
|
|
3
|
+
import { styles } from "./SelectDefaultPicker.style";
|
|
4
|
+
import { SelectPressable } from "../SelectPressable";
|
|
5
|
+
import { tokens } from "../../../utils/design";
|
|
6
|
+
export function SelectDefaultPicker({ children, options, disabled, onChange, }) {
|
|
7
|
+
var _a;
|
|
8
|
+
const selectedItem = options.find(option => option.isActive);
|
|
9
|
+
const pickerRef = useRef(null);
|
|
10
|
+
return (React.createElement(SelectPressable, { onPress: (_a = pickerRef.current) === null || _a === void 0 ? void 0 : _a.focus },
|
|
11
|
+
children,
|
|
12
|
+
React.createElement(Picker, { ref: pickerRef, selectedValue: selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value, onValueChange: onChange, mode: "dropdown", enabled: !disabled, style: styles.androidPickerContainer }, options.map(({ label, value, isActive }, i) => (React.createElement(Picker.Item, { key: i, label: label, value: value, color: isSelected(isActive) }))))));
|
|
13
|
+
function isSelected(isActive) {
|
|
14
|
+
return isActive ? tokens["color-interactive"] : tokens["color-text"];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
export const styles = StyleSheet.create({
|
|
3
|
+
overlay: { flex: 1 },
|
|
4
|
+
actionBar: {
|
|
5
|
+
flexDirection: "row",
|
|
6
|
+
height: 45,
|
|
7
|
+
justifyContent: "flex-end",
|
|
8
|
+
alignItems: "center",
|
|
9
|
+
paddingHorizontal: 10,
|
|
10
|
+
backgroundColor: "#f8f8f8",
|
|
11
|
+
borderTopWidth: 1,
|
|
12
|
+
borderTopColor: "#dedede",
|
|
13
|
+
zIndex: 2,
|
|
14
|
+
},
|
|
15
|
+
pickerContainer: {
|
|
16
|
+
justifyContent: "center",
|
|
17
|
+
backgroundColor: "#d0d4da",
|
|
18
|
+
},
|
|
19
|
+
androidPickerContainer: {
|
|
20
|
+
position: "absolute",
|
|
21
|
+
top: 0,
|
|
22
|
+
left: 0,
|
|
23
|
+
width: "100%",
|
|
24
|
+
height: "100%",
|
|
25
|
+
color: "transparent",
|
|
26
|
+
backgroundColor: "transparent",
|
|
27
|
+
opacity: 0,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SelectDefaultPicker";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SelectIOSPicker";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { handlePress, isIOS14AndUp } from "./utils";
|
|
3
|
+
import { SelectIOSPicker } from "../SelectIOSPicker";
|
|
4
|
+
import { SelectPressable } from "../SelectPressable";
|
|
5
|
+
import { SelectDefaultPicker } from "../SelectDefaultPicker";
|
|
6
|
+
export function SelectInternalPicker({ children, options, disabled, onChange, }) {
|
|
7
|
+
if (disabled)
|
|
8
|
+
return React.createElement(React.Fragment, null, children);
|
|
9
|
+
if (isIOS14AndUp()) {
|
|
10
|
+
return (React.createElement(SelectPressable, null,
|
|
11
|
+
React.createElement(SelectIOSPicker, { options: options, onOptionPress: handlePress(onChange) }, children)));
|
|
12
|
+
}
|
|
13
|
+
return (React.createElement(SelectDefaultPicker, { options: options, onChange: onChange }, children));
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SelectInternalPicker";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Platform } from "react-native";
|
|
2
|
+
export function handlePress(onChange) {
|
|
3
|
+
return ({ nativeEvent: { event } }) => {
|
|
4
|
+
return onChange(event);
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export function isIOS14AndUp() {
|
|
8
|
+
if (Platform.OS === "ios") {
|
|
9
|
+
const majorVersionIOS = parseInt(Platform.Version, 10);
|
|
10
|
+
return majorVersionIOS >= 14;
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Keyboard, Pressable } from "react-native";
|
|
3
|
+
import { styles } from "./SelectPressable.style";
|
|
4
|
+
import { useIsScreenReaderEnabled } from "../../../hooks";
|
|
5
|
+
/**
|
|
6
|
+
* Switches between Pressable with pressed styling and a fragment when a
|
|
7
|
+
* screen-reader is being used to avoid screen-readers from ignoring the press
|
|
8
|
+
* on the MenuView
|
|
9
|
+
*/
|
|
10
|
+
export function SelectPressable({ children, onPress, }) {
|
|
11
|
+
const isScreenReaderEnabled = useIsScreenReaderEnabled();
|
|
12
|
+
if (isScreenReaderEnabled)
|
|
13
|
+
return React.createElement(React.Fragment, null, children);
|
|
14
|
+
return (React.createElement(Pressable, { style: ({ pressed }) => [pressed && styles.pressed], onPressIn: Keyboard.dismiss, onPress: onPress }, children));
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SelectPressable";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Select, Option } from "./Select";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineMessages } from "react-intl";
|
|
2
|
+
export const messages = defineMessages({
|
|
3
|
+
a11yHint: {
|
|
4
|
+
id: "a11yHint",
|
|
5
|
+
defaultMessage: "Select to open the picker",
|
|
6
|
+
description: "Accessibility hint on how to interact with the select",
|
|
7
|
+
},
|
|
8
|
+
emptyValue: {
|
|
9
|
+
id: "emptyValue",
|
|
10
|
+
defaultMessage: "Select an option",
|
|
11
|
+
description: "Accessibility hint on how to interact with the select",
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/src/index.js
CHANGED
|
@@ -17,12 +17,14 @@ export * from "./Heading";
|
|
|
17
17
|
export * from "./Icon";
|
|
18
18
|
export * from "./IconButton";
|
|
19
19
|
export * from "./InputFieldWrapper";
|
|
20
|
+
export * from "./InputNumber";
|
|
20
21
|
export * from "./InputPassword";
|
|
21
22
|
export * from "./InputPressable";
|
|
22
23
|
export * from "./InputSearch";
|
|
23
24
|
export * from "./InputText";
|
|
24
25
|
export * from "./TextList";
|
|
25
26
|
export * from "./ProgressBar";
|
|
27
|
+
export * from "./Select";
|
|
26
28
|
export * from "./StatusLabel";
|
|
27
29
|
export * from "./Switch";
|
|
28
30
|
export * from "./Text";
|