@draftbit/core 50.1.1-1cea51.2 → 50.1.1-eb22bb.2
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/lib/commonjs/components/Button.js +1 -1
- package/lib/commonjs/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.js +1 -1
- package/lib/commonjs/components/MediaPlayer/MediaPlayerCommon.js +1 -1
- package/lib/commonjs/components/MediaPlayer/VideoPlayer/VideoPlayer.js +1 -1
- package/lib/commonjs/components/Picker/PickerCommon.js +1 -1
- package/lib/commonjs/components/Picker/dropdown/DropDownModalPicker.js +1 -0
- package/lib/commonjs/components/Picker/dropdown/DropDownPicker.js +1 -1
- package/lib/commonjs/components/Picker/index.js +1 -1
- package/lib/typescript/src/components/Button.js +4 -3
- package/lib/typescript/src/components/Button.js.map +1 -1
- package/lib/typescript/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.js +3 -25
- package/lib/typescript/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.js.map +1 -1
- package/lib/typescript/src/components/MediaPlayer/MediaPlayerCommon.d.ts +6 -0
- package/lib/typescript/src/components/MediaPlayer/MediaPlayerCommon.js +43 -0
- package/lib/typescript/src/components/MediaPlayer/MediaPlayerCommon.js.map +1 -1
- package/lib/typescript/src/components/MediaPlayer/VideoPlayer/VideoPlayer.js +11 -3
- package/lib/typescript/src/components/MediaPlayer/VideoPlayer/VideoPlayer.js.map +1 -1
- package/lib/typescript/src/components/Picker/PickerCommon.d.ts +4 -1
- package/lib/typescript/src/components/Picker/PickerCommon.js +11 -0
- package/lib/typescript/src/components/Picker/PickerCommon.js.map +1 -1
- package/lib/typescript/src/components/Picker/{modal/ModalPicker.d.ts → dropdown/DropDownModalPicker.d.ts} +3 -3
- package/lib/typescript/src/components/Picker/dropdown/DropDownModalPicker.js +70 -0
- package/lib/typescript/src/components/Picker/dropdown/DropDownModalPicker.js.map +1 -0
- package/lib/typescript/src/components/Picker/dropdown/DropDownPicker.js +3 -9
- package/lib/typescript/src/components/Picker/dropdown/DropDownPicker.js.map +1 -1
- package/lib/typescript/src/components/Picker/index.d.ts +3 -3
- package/lib/typescript/src/components/Picker/index.js +4 -4
- package/lib/typescript/src/components/Picker/index.js.map +1 -1
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -4
- package/src/components/Button.js +4 -3
- package/src/components/Button.js.map +1 -1
- package/src/components/Button.tsx +14 -2
- package/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.js +3 -25
- package/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.js.map +1 -1
- package/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.tsx +8 -31
- package/src/components/MediaPlayer/MediaPlayerCommon.js +43 -0
- package/src/components/MediaPlayer/MediaPlayerCommon.js.map +1 -1
- package/src/components/MediaPlayer/MediaPlayerCommon.ts +56 -0
- package/src/components/MediaPlayer/VideoPlayer/VideoPlayer.js +11 -3
- package/src/components/MediaPlayer/VideoPlayer/VideoPlayer.js.map +1 -1
- package/src/components/MediaPlayer/VideoPlayer/VideoPlayer.tsx +18 -1
- package/src/components/Picker/PickerCommon.js +11 -0
- package/src/components/Picker/PickerCommon.js.map +1 -1
- package/src/components/Picker/PickerCommon.ts +19 -1
- package/src/components/Picker/dropdown/DropDownModalPicker.js +70 -0
- package/src/components/Picker/dropdown/DropDownModalPicker.js.map +1 -0
- package/src/components/Picker/dropdown/DropDownModalPicker.tsx +155 -0
- package/src/components/Picker/dropdown/DropDownPicker.js +3 -9
- package/src/components/Picker/dropdown/DropDownPicker.js.map +1 -1
- package/src/components/Picker/dropdown/DropDownPicker.tsx +3 -16
- package/src/components/Picker/index.js +4 -4
- package/src/components/Picker/index.js.map +1 -1
- package/src/components/Picker/index.tsx +7 -7
- package/lib/commonjs/components/Picker/modal/ModalPicker.js +0 -1
- package/lib/typescript/src/components/Picker/modal/ModalPicker.js +0 -88
- package/lib/typescript/src/components/Picker/modal/ModalPicker.js.map +0 -1
- package/src/components/Picker/modal/ModalPicker.js +0 -88
- package/src/components/Picker/modal/ModalPicker.js.map +0 -1
- package/src/components/Picker/modal/ModalPicker.tsx +0 -179
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { View, Text, Keyboard } from "react-native";
|
|
3
|
-
import {
|
|
4
|
-
extractStyles,
|
|
5
|
-
flattenReactFragments,
|
|
6
|
-
useDeepCompareMemo,
|
|
7
|
-
} from "../../../utilities";
|
|
8
|
-
import {
|
|
9
|
-
CommonDropDownPickerProps,
|
|
10
|
-
ModalPickerProps,
|
|
11
|
-
SinglePickerProps,
|
|
12
|
-
normalizeToPickerOptions,
|
|
13
|
-
} from "../PickerCommon";
|
|
14
|
-
import PickerInputContainer from "../PickerInputContainer";
|
|
15
|
-
import ModalPickerComponent from "react-native-select-dropdown";
|
|
16
|
-
import { withTheme } from "../../../theming";
|
|
17
|
-
import PickerItem, { PickerItemProps } from "../dropdown/PickerItem";
|
|
18
|
-
import { useOnUpdate } from "../../../hooks";
|
|
19
|
-
|
|
20
|
-
const ModalPicker: React.FC<
|
|
21
|
-
React.PropsWithChildren<
|
|
22
|
-
CommonDropDownPickerProps & SinglePickerProps & ModalPickerProps
|
|
23
|
-
>
|
|
24
|
-
> = ({
|
|
25
|
-
theme,
|
|
26
|
-
options: optionsProp = [],
|
|
27
|
-
onValueChange,
|
|
28
|
-
Icon,
|
|
29
|
-
placeholder,
|
|
30
|
-
value,
|
|
31
|
-
autoDismissKeyboard = true,
|
|
32
|
-
selectedIconName = "Feather/check",
|
|
33
|
-
selectedIconColor = theme.colors.strong,
|
|
34
|
-
selectedIconSize = 20,
|
|
35
|
-
dropDownBackgroundColor = theme.colors.background,
|
|
36
|
-
dropDownBorderColor = theme.colors.divider,
|
|
37
|
-
dropDownTextColor = theme.colors.strong,
|
|
38
|
-
dropDownBorderWidth = 1,
|
|
39
|
-
dropDownBorderRadius = 8,
|
|
40
|
-
children: childrenProp,
|
|
41
|
-
disabled,
|
|
42
|
-
dropdownOverlayColor,
|
|
43
|
-
...rest
|
|
44
|
-
}) => {
|
|
45
|
-
const dropdownRef = React.useRef();
|
|
46
|
-
|
|
47
|
-
const [pickerVisible, setPickerVisible] = React.useState(false);
|
|
48
|
-
const [internalValue, setInternalValue] = React.useState<
|
|
49
|
-
string | number | (string | number)[] | undefined
|
|
50
|
-
>(value);
|
|
51
|
-
|
|
52
|
-
const isMultiSelect = Array.isArray(value);
|
|
53
|
-
|
|
54
|
-
const pickerItemProps: PickerItemProps = React.useMemo(() => {
|
|
55
|
-
const children = flattenReactFragments(
|
|
56
|
-
React.Children.toArray(childrenProp) as React.ReactElement[]
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
// Only the props of the first PickerItem are used, any others are ignored
|
|
60
|
-
const firstPickerItem = children.find((child) => child.type === PickerItem);
|
|
61
|
-
|
|
62
|
-
return firstPickerItem?.props || {};
|
|
63
|
-
}, [childrenProp]);
|
|
64
|
-
|
|
65
|
-
const { viewStyles: pickerItemViewStyles, textStyles: pickerItemTextStyles } =
|
|
66
|
-
extractStyles(pickerItemProps.style);
|
|
67
|
-
|
|
68
|
-
const options = useDeepCompareMemo(
|
|
69
|
-
() =>
|
|
70
|
-
normalizeToPickerOptions(optionsProp).map((option) => ({
|
|
71
|
-
label: option.label.toString(),
|
|
72
|
-
value: option.value,
|
|
73
|
-
})),
|
|
74
|
-
[optionsProp]
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
useOnUpdate(() => {
|
|
78
|
-
onValueChange?.(
|
|
79
|
-
(isMultiSelect ? internalValue ?? [] : internalValue ?? "") as any // cannot determine if multiselect or not on compile time
|
|
80
|
-
);
|
|
81
|
-
// onValueChange excluded to prevent running on every re-render when using an anoymous function, which is the common case
|
|
82
|
-
}, [internalValue]);
|
|
83
|
-
|
|
84
|
-
React.useEffect(() => {
|
|
85
|
-
if (pickerVisible && autoDismissKeyboard) {
|
|
86
|
-
Keyboard.dismiss();
|
|
87
|
-
}
|
|
88
|
-
}, [pickerVisible, autoDismissKeyboard]);
|
|
89
|
-
|
|
90
|
-
React.useEffect(() => {
|
|
91
|
-
if (disabled) {
|
|
92
|
-
setPickerVisible(false);
|
|
93
|
-
}
|
|
94
|
-
}, [disabled]);
|
|
95
|
-
|
|
96
|
-
const defaultValue = options.find((item) => item.value === value);
|
|
97
|
-
|
|
98
|
-
return (
|
|
99
|
-
<PickerInputContainer
|
|
100
|
-
testID="dropdown-picker"
|
|
101
|
-
Icon={Icon}
|
|
102
|
-
placeholder={placeholder}
|
|
103
|
-
selectedValue={value}
|
|
104
|
-
options={options}
|
|
105
|
-
onPress={() => {
|
|
106
|
-
setPickerVisible(!pickerVisible);
|
|
107
|
-
// @ts-ignore
|
|
108
|
-
dropdownRef.current.openDropdown();
|
|
109
|
-
}}
|
|
110
|
-
zIndex={pickerVisible ? 100 : undefined} // Guarantees drop down is rendered above all sibling components
|
|
111
|
-
disabled={disabled}
|
|
112
|
-
{...rest}
|
|
113
|
-
>
|
|
114
|
-
<ModalPickerComponent
|
|
115
|
-
// @ts-ignore
|
|
116
|
-
ref={dropdownRef}
|
|
117
|
-
data={options}
|
|
118
|
-
defaultValue={defaultValue}
|
|
119
|
-
onSelect={(selectedItem, index) => {
|
|
120
|
-
console.log(selectedItem, index);
|
|
121
|
-
setInternalValue(selectedItem.value);
|
|
122
|
-
}}
|
|
123
|
-
renderButton={() => {
|
|
124
|
-
return <View />;
|
|
125
|
-
}}
|
|
126
|
-
renderItem={(item, _index, isSelected) => {
|
|
127
|
-
const selectedBackgroundColor = isSelected
|
|
128
|
-
? pickerItemProps.selectedBackgroundColor
|
|
129
|
-
: pickerItemViewStyles.backgroundColor;
|
|
130
|
-
const selectedTextColor = isSelected
|
|
131
|
-
? pickerItemProps.selectedTextColor || dropDownTextColor
|
|
132
|
-
: dropDownTextColor;
|
|
133
|
-
const selectedTextSize = isSelected
|
|
134
|
-
? pickerItemProps.selectedTextSize || 14
|
|
135
|
-
: 14;
|
|
136
|
-
const iconColor = isSelected ? selectedIconColor : "transparent";
|
|
137
|
-
|
|
138
|
-
return (
|
|
139
|
-
<View
|
|
140
|
-
style={{
|
|
141
|
-
padding: 10,
|
|
142
|
-
flexDirection: "row",
|
|
143
|
-
alignItems: "center",
|
|
144
|
-
backgroundColor: selectedBackgroundColor,
|
|
145
|
-
}}
|
|
146
|
-
>
|
|
147
|
-
<Text
|
|
148
|
-
style={{
|
|
149
|
-
color: selectedTextColor,
|
|
150
|
-
fontSize: selectedTextSize,
|
|
151
|
-
flex: 1,
|
|
152
|
-
...pickerItemTextStyles,
|
|
153
|
-
}}
|
|
154
|
-
>
|
|
155
|
-
{item.label}
|
|
156
|
-
</Text>
|
|
157
|
-
<Icon
|
|
158
|
-
name={selectedIconName}
|
|
159
|
-
size={selectedIconSize}
|
|
160
|
-
color={iconColor}
|
|
161
|
-
/>
|
|
162
|
-
</View>
|
|
163
|
-
);
|
|
164
|
-
}}
|
|
165
|
-
showsVerticalScrollIndicator={false}
|
|
166
|
-
dropdownOverlayColor={dropdownOverlayColor}
|
|
167
|
-
dropdownStyle={{
|
|
168
|
-
borderColor: dropDownBorderColor,
|
|
169
|
-
borderWidth: dropDownBorderWidth,
|
|
170
|
-
borderRadius: dropDownBorderRadius,
|
|
171
|
-
backgroundColor: dropDownBackgroundColor,
|
|
172
|
-
}}
|
|
173
|
-
disableAutoScroll={true}
|
|
174
|
-
/>
|
|
175
|
-
</PickerInputContainer>
|
|
176
|
-
);
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
export default withTheme(ModalPicker);
|