@jobber/components-native 0.26.0 → 0.26.1-pre.10
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/android/build.gradle +77 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/jobber/componentsnative/ComponentsNativeModule.java +32 -0
- package/android/src/main/java/com/jobber/componentsnative/ComponentsNativePackage.java +28 -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 +16 -0
- package/dist/src/Select/messages.js +13 -0
- package/dist/src/Select/types.js +1 -0
- package/dist/src/index.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- 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 +2 -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 +1 -0
- package/ios/ComponentsNative-Bridging-Header.h +2 -0
- package/ios/ComponentsNative.m +14 -0
- package/ios/ComponentsNative.swift +8 -0
- package/ios/ComponentsNative.xcodeproj/project.pbxproj +309 -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 +24 -3
- 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 +23 -0
- package/src/Select/messages.ts +14 -0
- package/src/Select/types.ts +46 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
mavenCentral()
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
dependencies {
|
|
8
|
+
classpath "com.android.tools.build:gradle:7.2.1"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
def isNewArchitectureEnabled() {
|
|
13
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
apply plugin: "com.android.library"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
|
|
20
|
+
|
|
21
|
+
if (isNewArchitectureEnabled()) {
|
|
22
|
+
apply plugin: "com.facebook.react"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
def getExtOrDefault(name) {
|
|
26
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["ComponentsNative_" + name]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
def getExtOrIntegerDefault(name) {
|
|
30
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ComponentsNative_" + name]).toInteger()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
android {
|
|
34
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
35
|
+
|
|
36
|
+
defaultConfig {
|
|
37
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
38
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
39
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
40
|
+
}
|
|
41
|
+
buildTypes {
|
|
42
|
+
release {
|
|
43
|
+
minifyEnabled false
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
lintOptions {
|
|
48
|
+
disable "GradleCompatible"
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
compileOptions {
|
|
52
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
53
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
repositories {
|
|
59
|
+
mavenCentral()
|
|
60
|
+
google()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
dependencies {
|
|
65
|
+
// For < 0.71, this will be from the local maven repo
|
|
66
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
67
|
+
//noinspection GradleDynamicVersion
|
|
68
|
+
implementation "com.facebook.react:react-native:+"
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (isNewArchitectureEnabled()) {
|
|
72
|
+
react {
|
|
73
|
+
jsRootDir = file("../src/")
|
|
74
|
+
libraryName = "ComponentsNative"
|
|
75
|
+
codegenJavaPackageName = "com.jobber.componentsnative"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
package com.jobber.componentsnative;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.Promise;
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
8
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
9
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
10
|
+
|
|
11
|
+
@ReactModule(name = ComponentsNativeModule.NAME)
|
|
12
|
+
public class ComponentsNativeModule extends ReactContextBaseJavaModule {
|
|
13
|
+
public static final String NAME = "ComponentsNative";
|
|
14
|
+
|
|
15
|
+
public ComponentsNativeModule(ReactApplicationContext reactContext) {
|
|
16
|
+
super(reactContext);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Override
|
|
20
|
+
@NonNull
|
|
21
|
+
public String getName() {
|
|
22
|
+
return NAME;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// Example method
|
|
27
|
+
// See https://reactnative.dev/docs/native-modules-android
|
|
28
|
+
@ReactMethod
|
|
29
|
+
public void multiply(double a, double b, Promise promise) {
|
|
30
|
+
promise.resolve(a * b);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package com.jobber.componentsnative;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.ReactPackage;
|
|
6
|
+
import com.facebook.react.bridge.NativeModule;
|
|
7
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
9
|
+
|
|
10
|
+
import java.util.ArrayList;
|
|
11
|
+
import java.util.Collections;
|
|
12
|
+
import java.util.List;
|
|
13
|
+
|
|
14
|
+
public class ComponentsNativePackage implements ReactPackage {
|
|
15
|
+
@NonNull
|
|
16
|
+
@Override
|
|
17
|
+
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
|
|
18
|
+
List<NativeModule> modules = new ArrayList<>();
|
|
19
|
+
modules.add(new ComponentsNativeModule(reactContext));
|
|
20
|
+
return modules;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@NonNull
|
|
24
|
+
@Override
|
|
25
|
+
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
26
|
+
return Collections.emptyList();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -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,16 @@
|
|
|
1
|
+
export { Select, Option } from "./Select";
|
|
2
|
+
import { NativeModules, Platform } from "react-native";
|
|
3
|
+
const LINKING_ERROR = `The package '@jobber/components-native' doesn't seem to be linked. Make sure: \n\n` +
|
|
4
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: "" }) +
|
|
5
|
+
"- You rebuilt the app after installing the package\n" +
|
|
6
|
+
"- You are not using Expo Go\n";
|
|
7
|
+
const ComponentsNative = NativeModules.ComponentsNative
|
|
8
|
+
? NativeModules.ComponentsNative
|
|
9
|
+
: new Proxy({}, {
|
|
10
|
+
get() {
|
|
11
|
+
throw new Error(LINKING_ERROR);
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
export function multiply(a, b) {
|
|
15
|
+
return ComponentsNative.multiply(a, b);
|
|
16
|
+
}
|
|
@@ -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