@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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
|
|
3
|
+
export const styles = StyleSheet.create({
|
|
4
|
+
overlay: { flex: 1 },
|
|
5
|
+
actionBar: {
|
|
6
|
+
flexDirection: "row",
|
|
7
|
+
height: 45,
|
|
8
|
+
justifyContent: "flex-end",
|
|
9
|
+
alignItems: "center",
|
|
10
|
+
paddingHorizontal: 10,
|
|
11
|
+
backgroundColor: "#f8f8f8",
|
|
12
|
+
borderTopWidth: 1,
|
|
13
|
+
borderTopColor: "#dedede",
|
|
14
|
+
zIndex: 2,
|
|
15
|
+
},
|
|
16
|
+
pickerContainer: {
|
|
17
|
+
justifyContent: "center",
|
|
18
|
+
backgroundColor: "#d0d4da",
|
|
19
|
+
},
|
|
20
|
+
androidPickerContainer: {
|
|
21
|
+
position: "absolute",
|
|
22
|
+
top: 0,
|
|
23
|
+
left: 0,
|
|
24
|
+
width: "100%",
|
|
25
|
+
height: "100%",
|
|
26
|
+
color: "transparent",
|
|
27
|
+
backgroundColor: "transparent",
|
|
28
|
+
opacity: 0,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { cleanup, fireEvent, render } from "@testing-library/react-native";
|
|
3
|
+
import { AccessibilityInfo, View } from "react-native";
|
|
4
|
+
import { SelectDefaultPicker } from "./SelectDefaultPicker";
|
|
5
|
+
import { messages } from "./messages";
|
|
6
|
+
import { Text } from "../../../Text";
|
|
7
|
+
|
|
8
|
+
const A11yInfoSpy = jest.spyOn(AccessibilityInfo, "isScreenReaderEnabled");
|
|
9
|
+
const handleChange = jest.fn();
|
|
10
|
+
|
|
11
|
+
function MockPicker() {
|
|
12
|
+
return React.createElement("MockPicker");
|
|
13
|
+
}
|
|
14
|
+
const MockPickerItem = () => <></>;
|
|
15
|
+
jest.mock("@react-native-picker/picker", () => ({ Picker: MockPicker }));
|
|
16
|
+
MockPicker.Item = MockPickerItem;
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
A11yInfoSpy.mockImplementation(() => Promise.resolve(false));
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
afterEach(() => {
|
|
23
|
+
cleanup();
|
|
24
|
+
jest.resetAllMocks();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const childText = "Click me";
|
|
28
|
+
function setup() {
|
|
29
|
+
return render(
|
|
30
|
+
<View testID="SelectDefaultPicker">
|
|
31
|
+
<SelectDefaultPicker
|
|
32
|
+
onChange={handleChange}
|
|
33
|
+
options={[
|
|
34
|
+
{ value: "1", label: "First option" },
|
|
35
|
+
{ value: "2", label: "Second option" },
|
|
36
|
+
]}
|
|
37
|
+
>
|
|
38
|
+
<Text>{childText}</Text>
|
|
39
|
+
</SelectDefaultPicker>
|
|
40
|
+
</View>,
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
describe("SelectDefaultPicker", () => {
|
|
45
|
+
it("opens the picker", () => {
|
|
46
|
+
const screen = setup();
|
|
47
|
+
|
|
48
|
+
fireEvent.press(screen.getByText(childText));
|
|
49
|
+
expect(
|
|
50
|
+
screen.getByTestId("SelectDefaultPicker").findByType(MockPicker),
|
|
51
|
+
).toBeDefined();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("closes the picker", () => {
|
|
55
|
+
const screen = setup();
|
|
56
|
+
|
|
57
|
+
fireEvent.press(screen.getByText(childText));
|
|
58
|
+
fireEvent.press(screen.getByText(messages.done.defaultMessage));
|
|
59
|
+
expect(
|
|
60
|
+
screen.getByTestId("SelectDefaultPicker").findAllByType(MockPicker),
|
|
61
|
+
).toEqual([]);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("fires the onChange", () => {
|
|
65
|
+
const screen = setup();
|
|
66
|
+
|
|
67
|
+
fireEvent.press(screen.getByText(childText));
|
|
68
|
+
const menu = screen
|
|
69
|
+
.getByTestId("SelectDefaultPicker")
|
|
70
|
+
.findByType(MockPicker);
|
|
71
|
+
|
|
72
|
+
expect(menu).toBeDefined();
|
|
73
|
+
fireEvent(menu, "onValueChange", "2");
|
|
74
|
+
expect(handleChange).toHaveBeenCalledWith("2");
|
|
75
|
+
});
|
|
76
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { useRef } from "react";
|
|
2
|
+
import { Picker } from "@react-native-picker/picker";
|
|
3
|
+
import { styles } from "./SelectDefaultPicker.style";
|
|
4
|
+
import { SelectInternalPickerProps } from "../../types";
|
|
5
|
+
import { SelectPressable } from "../SelectPressable";
|
|
6
|
+
import { tokens } from "../../../utils/design";
|
|
7
|
+
|
|
8
|
+
type SelectDefaultPickerProps = SelectInternalPickerProps;
|
|
9
|
+
|
|
10
|
+
export function SelectDefaultPicker({
|
|
11
|
+
children,
|
|
12
|
+
options,
|
|
13
|
+
disabled,
|
|
14
|
+
onChange,
|
|
15
|
+
}: SelectDefaultPickerProps): JSX.Element {
|
|
16
|
+
const selectedItem = options.find(option => option.isActive);
|
|
17
|
+
const pickerRef = useRef<Picker<string>>(null);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<SelectPressable onPress={pickerRef.current?.focus}>
|
|
21
|
+
{children}
|
|
22
|
+
<Picker
|
|
23
|
+
ref={pickerRef}
|
|
24
|
+
selectedValue={selectedItem?.value}
|
|
25
|
+
onValueChange={onChange}
|
|
26
|
+
mode="dropdown"
|
|
27
|
+
enabled={!disabled}
|
|
28
|
+
style={styles.androidPickerContainer}
|
|
29
|
+
>
|
|
30
|
+
{options.map(({ label, value, isActive }, i) => (
|
|
31
|
+
<Picker.Item
|
|
32
|
+
key={i}
|
|
33
|
+
label={label}
|
|
34
|
+
value={value}
|
|
35
|
+
color={isSelected(isActive)}
|
|
36
|
+
/>
|
|
37
|
+
))}
|
|
38
|
+
</Picker>
|
|
39
|
+
</SelectPressable>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
function isSelected(isActive: boolean | undefined): string {
|
|
43
|
+
return isActive ? tokens["color-interactive"] : tokens["color-text"];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SelectDefaultPicker";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HostComponent, requireNativeComponent } from "react-native";
|
|
2
|
+
import {
|
|
3
|
+
SelectInternalPickerProps,
|
|
4
|
+
SelectOnOptionPressEvent,
|
|
5
|
+
} from "../../types";
|
|
6
|
+
|
|
7
|
+
interface NativeSelectIOSPickerProps
|
|
8
|
+
extends Pick<SelectInternalPickerProps, "options" | "children"> {
|
|
9
|
+
/**
|
|
10
|
+
* Callback when one of the option is pressed
|
|
11
|
+
*/
|
|
12
|
+
readonly onOptionPress: (event: SelectOnOptionPressEvent) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const SelectIOSPicker: HostComponent<NativeSelectIOSPickerProps> =
|
|
16
|
+
requireNativeComponent?.<NativeSelectIOSPickerProps>("RCTATLPicker");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SelectIOSPicker";
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React, { ElementType } from "react";
|
|
2
|
+
import { cleanup, fireEvent, render } from "@testing-library/react-native";
|
|
3
|
+
import { View } from "react-native";
|
|
4
|
+
import { SelectInternalPicker } from ".";
|
|
5
|
+
import { SelectInternalPickerProps } from "../../types";
|
|
6
|
+
import { Text } from "../../../Text";
|
|
7
|
+
|
|
8
|
+
let Platform: { OS: "ios" | "android"; Version: string | number };
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
Platform = require("react-native").Platform;
|
|
11
|
+
Object.defineProperty(Platform, "Version", { get: () => undefined });
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
function MockPicker() {
|
|
15
|
+
return React.createElement("MockPicker");
|
|
16
|
+
}
|
|
17
|
+
const MockPickerItem = () => <></>;
|
|
18
|
+
jest.mock("@react-native-picker/picker", () => ({ Picker: MockPicker }));
|
|
19
|
+
MockPicker.Item = MockPickerItem;
|
|
20
|
+
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
cleanup();
|
|
23
|
+
jest.resetAllMocks();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const RCTPicker = "RCTATLPicker" as ElementType;
|
|
27
|
+
const childText = "Click me";
|
|
28
|
+
const handleChange = jest.fn();
|
|
29
|
+
|
|
30
|
+
function setup(props?: Partial<SelectInternalPickerProps>) {
|
|
31
|
+
return render(
|
|
32
|
+
<View testID="SelectInternalPicker">
|
|
33
|
+
<SelectInternalPicker
|
|
34
|
+
onChange={handleChange}
|
|
35
|
+
disabled={props?.disabled}
|
|
36
|
+
options={[
|
|
37
|
+
{ value: "1", label: "First option" },
|
|
38
|
+
{ value: "2", label: "Second option" },
|
|
39
|
+
]}
|
|
40
|
+
>
|
|
41
|
+
<Text>{childText}</Text>
|
|
42
|
+
</SelectInternalPicker>
|
|
43
|
+
</View>,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
describe("SelectInternalPicker", () => {
|
|
48
|
+
it("fires the onChange", () => {
|
|
49
|
+
const screen = setup();
|
|
50
|
+
fireEvent.press(screen.getByText(childText));
|
|
51
|
+
const menu = screen
|
|
52
|
+
.getByTestId("SelectInternalPicker")
|
|
53
|
+
.findByType(MockPicker);
|
|
54
|
+
|
|
55
|
+
expect(menu).toBeDefined();
|
|
56
|
+
fireEvent(menu, "onChange", "1");
|
|
57
|
+
expect(handleChange).toHaveBeenCalledWith("1");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe("iOS 13 and below fallback", () => {
|
|
61
|
+
it("renders the iOS 14 native menu picker", () => {
|
|
62
|
+
Platform.OS = "ios";
|
|
63
|
+
Object.defineProperty(Platform, "Version", { get: () => "14.1" });
|
|
64
|
+
|
|
65
|
+
const screen = setup();
|
|
66
|
+
|
|
67
|
+
const menu = screen
|
|
68
|
+
.getByTestId("SelectInternalPicker")
|
|
69
|
+
.findByType(RCTPicker);
|
|
70
|
+
|
|
71
|
+
expect(menu).toBeDefined();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it.each<[typeof Platform.OS, typeof Platform.Version]>([
|
|
75
|
+
["ios", "13.1"],
|
|
76
|
+
["android", 100],
|
|
77
|
+
])("renders the menu picker on %s", (os, version) => {
|
|
78
|
+
Platform.OS = os;
|
|
79
|
+
Object.defineProperty(Platform, "Version", { get: () => version });
|
|
80
|
+
const screen = setup();
|
|
81
|
+
|
|
82
|
+
fireEvent.press(screen.getByText(childText));
|
|
83
|
+
expect(
|
|
84
|
+
screen.getByTestId("SelectInternalPicker").findByType(MockPicker),
|
|
85
|
+
).toBeDefined();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe("Disabled", () => {
|
|
90
|
+
it("should not render the picker", () => {
|
|
91
|
+
const screen = setup({ disabled: true });
|
|
92
|
+
|
|
93
|
+
const menu = screen
|
|
94
|
+
.getByTestId("SelectInternalPicker")
|
|
95
|
+
.findAllByType(RCTPicker);
|
|
96
|
+
|
|
97
|
+
expect(menu).toEqual([]);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { handlePress, isIOS14AndUp } from "./utils";
|
|
3
|
+
import { SelectInternalPickerProps } from "../../types";
|
|
4
|
+
import { SelectIOSPicker } from "../SelectIOSPicker";
|
|
5
|
+
import { SelectPressable } from "../SelectPressable";
|
|
6
|
+
import { SelectDefaultPicker } from "../SelectDefaultPicker";
|
|
7
|
+
|
|
8
|
+
export function SelectInternalPicker({
|
|
9
|
+
children,
|
|
10
|
+
options,
|
|
11
|
+
disabled,
|
|
12
|
+
onChange,
|
|
13
|
+
}: SelectInternalPickerProps): JSX.Element {
|
|
14
|
+
if (disabled) return <>{children}</>;
|
|
15
|
+
if (isIOS14AndUp()) {
|
|
16
|
+
return (
|
|
17
|
+
<SelectPressable>
|
|
18
|
+
<SelectIOSPicker
|
|
19
|
+
options={options}
|
|
20
|
+
onOptionPress={handlePress(onChange)}
|
|
21
|
+
>
|
|
22
|
+
{children}
|
|
23
|
+
</SelectIOSPicker>
|
|
24
|
+
</SelectPressable>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<SelectDefaultPicker options={options} onChange={onChange}>
|
|
30
|
+
{children}
|
|
31
|
+
</SelectDefaultPicker>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SelectInternalPicker";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Platform } from "react-native";
|
|
2
|
+
import {
|
|
3
|
+
SelectInternalPickerProps,
|
|
4
|
+
SelectOnOptionPressEvent,
|
|
5
|
+
} from "../../types";
|
|
6
|
+
|
|
7
|
+
export function handlePress(onChange: SelectInternalPickerProps["onChange"]) {
|
|
8
|
+
return ({ nativeEvent: { event } }: SelectOnOptionPressEvent): void => {
|
|
9
|
+
return onChange(event);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function isIOS14AndUp(): boolean {
|
|
14
|
+
if (Platform.OS === "ios") {
|
|
15
|
+
const majorVersionIOS = parseInt(Platform.Version, 10);
|
|
16
|
+
return majorVersionIOS >= 14;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Keyboard, Pressable, PressableProps } from "react-native";
|
|
3
|
+
import { styles } from "./SelectPressable.style";
|
|
4
|
+
import { SelectInternalPickerProps } from "../../types";
|
|
5
|
+
import { useIsScreenReaderEnabled } from "../../../hooks";
|
|
6
|
+
|
|
7
|
+
type SelectPressableProps = Pick<SelectInternalPickerProps, "children"> &
|
|
8
|
+
Pick<PressableProps, "onPress">;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Switches between Pressable with pressed styling and a fragment when a
|
|
12
|
+
* screen-reader is being used to avoid screen-readers from ignoring the press
|
|
13
|
+
* on the MenuView
|
|
14
|
+
*/
|
|
15
|
+
export function SelectPressable({
|
|
16
|
+
children,
|
|
17
|
+
onPress,
|
|
18
|
+
}: SelectPressableProps): JSX.Element {
|
|
19
|
+
const isScreenReaderEnabled = useIsScreenReaderEnabled();
|
|
20
|
+
|
|
21
|
+
if (isScreenReaderEnabled) return <>{children}</>;
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<Pressable
|
|
25
|
+
style={({ pressed }) => [pressed && styles.pressed]}
|
|
26
|
+
onPressIn={Keyboard.dismiss}
|
|
27
|
+
onPress={onPress}
|
|
28
|
+
>
|
|
29
|
+
{children}
|
|
30
|
+
</Pressable>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SelectPressable";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Select, Option, SelectOption, SelectProps } from "./Select";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineMessages } from "react-intl";
|
|
2
|
+
|
|
3
|
+
export const messages = defineMessages({
|
|
4
|
+
a11yHint: {
|
|
5
|
+
id: "a11yHint",
|
|
6
|
+
defaultMessage: "Select to open the picker",
|
|
7
|
+
description: "Accessibility hint on how to interact with the select",
|
|
8
|
+
},
|
|
9
|
+
emptyValue: {
|
|
10
|
+
id: "emptyValue",
|
|
11
|
+
defaultMessage: "Select an option",
|
|
12
|
+
description: "Accessibility hint on how to interact with the select",
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export interface SelectInternalPickerProps {
|
|
4
|
+
/**
|
|
5
|
+
* Tapping the children opens the picker
|
|
6
|
+
*/
|
|
7
|
+
readonly children: ReactNode;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The list of options that user can choose from
|
|
11
|
+
*/
|
|
12
|
+
readonly options: SelectInternalPickerOption[];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Prevents the menu from opening
|
|
16
|
+
*/
|
|
17
|
+
readonly disabled?: boolean;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Callback to fire when an option is pressed
|
|
21
|
+
*/
|
|
22
|
+
readonly onChange: (value: string) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface SelectInternalPickerOption {
|
|
26
|
+
/**
|
|
27
|
+
* The value that gets returned whenever the option is selected
|
|
28
|
+
*/
|
|
29
|
+
readonly value: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* What the user chooses on the UI
|
|
33
|
+
*/
|
|
34
|
+
readonly label: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Determines if the option is selected or not
|
|
38
|
+
*/
|
|
39
|
+
readonly isActive?: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface SelectOnOptionPressEvent {
|
|
43
|
+
readonly nativeEvent: {
|
|
44
|
+
readonly event: string;
|
|
45
|
+
};
|
|
46
|
+
}
|
package/src/index.ts
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";
|