@draftbit/core 53.0.4 → 53.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftbit/core",
3
- "version": "53.0.4",
3
+ "version": "53.0.5",
4
4
  "description": "Core (non-native) Components",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "types": "lib/typescript/src/index.d.ts",
@@ -40,7 +40,7 @@
40
40
  "homepage": "https://github.com/draftbit/react-native-jigsaw#readme",
41
41
  "dependencies": {
42
42
  "@draftbit/react-theme-provider": "^2.1.1",
43
- "@draftbit/theme": "53.0.4",
43
+ "@draftbit/theme": "53.0.5",
44
44
  "@emotion/react": "^11.13.5",
45
45
  "@emotion/styled": "^11.13.5",
46
46
  "@expo/vector-icons": "^14.1.0",
@@ -119,5 +119,5 @@
119
119
  ],
120
120
  "testEnvironment": "node"
121
121
  },
122
- "gitHead": "9ede62f7ca2d3a092316652617b881a2260c3af7"
122
+ "gitHead": "1f4640f93a896cb9bbc03facbe3f27ebd845a521"
123
123
  }
@@ -0,0 +1,77 @@
1
+ import * as React from "react";
2
+ import { StyleSheet, Keyboard } from "react-native";
3
+ import { SafeAreaView } from "react-native-safe-area-context";
4
+ import { Picker as NativePickerComponent } from "@react-native-picker/picker";
5
+ import Portal from "../Portal/Portal";
6
+ import { Button } from "../Button";
7
+ import { useDeepCompareMemo } from "../../utilities";
8
+ import { normalizeToPickerOptions, } from "./PickerCommon";
9
+ import PickerInputContainer from "./PickerInputContainer";
10
+ import { withTheme } from "@draftbit/theme";
11
+ const PortalPickerContent = ({ value, options, placeholder, onValueChange, onClose, Icon, theme, autoDismissKeyboard = true, }) => {
12
+ const pickerRef = React.useRef(null);
13
+ // Manage value state inside the Portal to avoid stale state issues across the Portal boundary
14
+ const [internalValue, setInternalValue] = React.useState(value);
15
+ React.useEffect(() => {
16
+ setInternalValue(value);
17
+ }, [value]);
18
+ React.useEffect(() => {
19
+ if (autoDismissKeyboard) {
20
+ Keyboard.dismiss();
21
+ }
22
+ }, [autoDismissKeyboard]);
23
+ return (React.createElement(SafeAreaView, { style: [
24
+ styles.iosPickerContent,
25
+ { backgroundColor: theme.colors.background.base },
26
+ ] },
27
+ React.createElement(Button, { Icon: Icon, onPress: onClose, style: [styles.iosButton, { color: theme.colors.branding.primary }], title: "Close" }),
28
+ React.createElement(NativePickerComponent, { ref: pickerRef, testID: "native-picker-component", selectedValue: internalValue, onValueChange: (newValue) => {
29
+ setInternalValue(newValue);
30
+ if (newValue !== placeholder) {
31
+ onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue);
32
+ }
33
+ else if (newValue === placeholder) {
34
+ onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange("");
35
+ }
36
+ }, style: [
37
+ styles.iosNativePicker,
38
+ { backgroundColor: theme.colors.background.base },
39
+ ], onBlur: onClose }, options.map((option) => (React.createElement(NativePickerComponent.Item, { testID: "native-picker-item", label: option.label.toString(), value: option.value, key: option.value, color: theme.colors.text.strong }))))));
40
+ };
41
+ const NativePicker = ({ options: optionsProp = [], onValueChange, Icon, placeholder, value, autoDismissKeyboard = true, theme, disabled, ...rest }) => {
42
+ const [pickerVisible, setPickerVisible] = React.useState(false);
43
+ const options = useDeepCompareMemo(() => {
44
+ const normalizedOptions = normalizeToPickerOptions(optionsProp);
45
+ // Underlying Picker component defaults selection to first element when value is not provided (or undefined)
46
+ // Placholder must be the 1st option in order to allow selection of the 'actual' 1st option
47
+ if (placeholder) {
48
+ return [{ label: placeholder, value: placeholder }, ...normalizedOptions];
49
+ }
50
+ else {
51
+ return normalizedOptions;
52
+ }
53
+ }, [placeholder, optionsProp]);
54
+ // When no placeholder is provided then first item should be marked selected to reflect underlying Picker internal state
55
+ if (!placeholder && options.length && !value && value !== options[0].value) {
56
+ onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(options[0].value);
57
+ }
58
+ return (React.createElement(PickerInputContainer, { testID: "native-picker", Icon: Icon, placeholder: placeholder, selectedValue: value, options: options, onPress: () => setPickerVisible(!pickerVisible), disabled: disabled, ...rest }, pickerVisible && !disabled && (React.createElement(Portal, null,
59
+ React.createElement(PortalPickerContent, { value: value, options: options, placeholder: placeholder, onValueChange: onValueChange, onClose: () => setPickerVisible(false), Icon: Icon, theme: theme, autoDismissKeyboard: autoDismissKeyboard })))));
60
+ };
61
+ const styles = StyleSheet.create({
62
+ iosNativePicker: {
63
+ backgroundColor: "white",
64
+ },
65
+ iosPickerContent: {
66
+ width: "100%",
67
+ position: "absolute",
68
+ bottom: 0,
69
+ backgroundColor: "white",
70
+ },
71
+ iosButton: {
72
+ backgroundColor: "transparent",
73
+ borderWidth: 0,
74
+ },
75
+ });
76
+ export default withTheme(NativePicker);
77
+ //# sourceMappingURL=NativePicker.ios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativePicker.ios.js","sourceRoot":"","sources":["NativePicker.ios.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,MAAM,IAAI,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAGL,wBAAwB,GAEzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAa,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAkBvD,MAAM,mBAAmB,GAAuC,CAAC,EAC/D,KAAK,EACL,OAAO,EACP,WAAW,EACX,aAAa,EACb,OAAO,EACP,IAAI,EACJ,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ACf;CACF,CAAC,CAAC;AAEH,eAAe,SAAS,CAAC,YAAY,CAAC,CAAC"}
@@ -0,0 +1,180 @@
1
+ import * as React from "react";
2
+ import { StyleSheet, Keyboard } from "react-native";
3
+ import { SafeAreaView } from "react-native-safe-area-context";
4
+ import { Picker as NativePickerComponent } from "@react-native-picker/picker";
5
+ import Portal from "../Portal/Portal";
6
+ import { Button } from "../Button";
7
+ import { useDeepCompareMemo } from "../../utilities";
8
+ import {
9
+ CommonPickerProps,
10
+ SinglePickerProps,
11
+ normalizeToPickerOptions,
12
+ PickerOption,
13
+ } from "./PickerCommon";
14
+ import PickerInputContainer from "./PickerInputContainer";
15
+ import { ReadTheme, withTheme } from "@draftbit/theme";
16
+ import { IconSlot } from "../../interfaces/Icon";
17
+
18
+ /**
19
+ * Duplicated version of NativePicker.tsx for maintaining state inside the Portal container to avoid this issue
20
+ * https://github.com/react-native-picker/picker/issues/615
21
+ */
22
+
23
+ interface PortalPickerContentProps extends IconSlot {
24
+ value: string | number | undefined;
25
+ options: PickerOption[];
26
+ placeholder?: string;
27
+ onValueChange?: (value: string | number) => void;
28
+ onClose: () => void;
29
+ theme: ReadTheme;
30
+ autoDismissKeyboard?: boolean;
31
+ }
32
+
33
+ const PortalPickerContent: React.FC<PortalPickerContentProps> = ({
34
+ value,
35
+ options,
36
+ placeholder,
37
+ onValueChange,
38
+ onClose,
39
+ Icon,
40
+ theme,
41
+ autoDismissKeyboard = true,
42
+ }) => {
43
+ const pickerRef = React.useRef<NativePickerComponent<string | number>>(null);
44
+
45
+ // Manage value state inside the Portal to avoid stale state issues across the Portal boundary
46
+ const [internalValue, setInternalValue] = React.useState<
47
+ string | number | undefined
48
+ >(value);
49
+
50
+ React.useEffect(() => {
51
+ setInternalValue(value);
52
+ }, [value]);
53
+
54
+ React.useEffect(() => {
55
+ if (autoDismissKeyboard) {
56
+ Keyboard.dismiss();
57
+ }
58
+ }, [autoDismissKeyboard]);
59
+
60
+ return (
61
+ <SafeAreaView
62
+ style={[
63
+ styles.iosPickerContent,
64
+ { backgroundColor: theme.colors.background.base },
65
+ ]}
66
+ >
67
+ <Button
68
+ Icon={Icon}
69
+ onPress={onClose}
70
+ style={[styles.iosButton, { color: theme.colors.branding.primary }]}
71
+ title="Close"
72
+ />
73
+ <NativePickerComponent
74
+ ref={pickerRef}
75
+ testID="native-picker-component"
76
+ selectedValue={internalValue}
77
+ onValueChange={(newValue) => {
78
+ setInternalValue(newValue);
79
+ if (newValue !== placeholder) {
80
+ onValueChange?.(newValue);
81
+ } else if (newValue === placeholder) {
82
+ onValueChange?.("");
83
+ }
84
+ }}
85
+ style={[
86
+ styles.iosNativePicker,
87
+ { backgroundColor: theme.colors.background.base },
88
+ ]}
89
+ onBlur={onClose}
90
+ >
91
+ {options.map((option) => (
92
+ <NativePickerComponent.Item
93
+ testID="native-picker-item"
94
+ label={option.label.toString()}
95
+ value={option.value}
96
+ key={option.value}
97
+ color={theme.colors.text.strong}
98
+ />
99
+ ))}
100
+ </NativePickerComponent>
101
+ </SafeAreaView>
102
+ );
103
+ };
104
+
105
+ const NativePicker: React.FC<CommonPickerProps & SinglePickerProps> = ({
106
+ options: optionsProp = [],
107
+ onValueChange,
108
+ Icon,
109
+ placeholder,
110
+ value,
111
+ autoDismissKeyboard = true,
112
+ theme,
113
+ disabled,
114
+ ...rest
115
+ }) => {
116
+ const [pickerVisible, setPickerVisible] = React.useState(false);
117
+
118
+ const options = useDeepCompareMemo(() => {
119
+ const normalizedOptions = normalizeToPickerOptions(optionsProp);
120
+
121
+ // Underlying Picker component defaults selection to first element when value is not provided (or undefined)
122
+ // Placholder must be the 1st option in order to allow selection of the 'actual' 1st option
123
+ if (placeholder) {
124
+ return [{ label: placeholder, value: placeholder }, ...normalizedOptions];
125
+ } else {
126
+ return normalizedOptions;
127
+ }
128
+ }, [placeholder, optionsProp]);
129
+
130
+ // When no placeholder is provided then first item should be marked selected to reflect underlying Picker internal state
131
+ if (!placeholder && options.length && !value && value !== options[0].value) {
132
+ onValueChange?.(options[0].value);
133
+ }
134
+
135
+ return (
136
+ <PickerInputContainer
137
+ testID="native-picker"
138
+ Icon={Icon}
139
+ placeholder={placeholder}
140
+ selectedValue={value}
141
+ options={options}
142
+ onPress={() => setPickerVisible(!pickerVisible)}
143
+ disabled={disabled}
144
+ {...rest}
145
+ >
146
+ {pickerVisible && !disabled && (
147
+ <Portal>
148
+ <PortalPickerContent
149
+ value={value}
150
+ options={options}
151
+ placeholder={placeholder}
152
+ onValueChange={onValueChange}
153
+ onClose={() => setPickerVisible(false)}
154
+ Icon={Icon}
155
+ theme={theme}
156
+ autoDismissKeyboard={autoDismissKeyboard}
157
+ />
158
+ </Portal>
159
+ )}
160
+ </PickerInputContainer>
161
+ );
162
+ };
163
+
164
+ const styles = StyleSheet.create({
165
+ iosNativePicker: {
166
+ backgroundColor: "white",
167
+ },
168
+ iosPickerContent: {
169
+ width: "100%",
170
+ position: "absolute",
171
+ bottom: 0,
172
+ backgroundColor: "white",
173
+ },
174
+ iosButton: {
175
+ backgroundColor: "transparent",
176
+ borderWidth: 0,
177
+ },
178
+ });
179
+
180
+ export default withTheme(NativePicker);
@@ -1,14 +1,10 @@
1
1
  import * as React from "react";
2
2
  import { StyleSheet, Platform, Keyboard } from "react-native";
3
- import { SafeAreaView } from "react-native-safe-area-context";
4
3
  import { Picker as NativePickerComponent } from "@react-native-picker/picker";
5
- import Portal from "../Portal/Portal";
6
- import { Button } from "../Button";
7
4
  import { useDeepCompareMemo } from "../../utilities";
8
5
  import { normalizeToPickerOptions, } from "./PickerCommon";
9
6
  import PickerInputContainer from "./PickerInputContainer";
10
7
  import { withTheme } from "@draftbit/theme";
11
- const isIos = Platform.OS === "ios";
12
8
  const isAndroid = Platform.OS === "android";
13
9
  const isWeb = Platform.OS === "web";
14
10
  const NativePicker = ({ options: optionsProp = [], onValueChange, Icon, placeholder, value, autoDismissKeyboard = true, theme, disabled, ...rest }) => {
@@ -36,21 +32,7 @@ const NativePicker = ({ options: optionsProp = [], onValueChange, Icon, placehol
36
32
  else if (newValue === placeholder) {
37
33
  onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange("");
38
34
  }
39
- }, style: isIos ? styles.iosNativePicker : styles.nativePicker, onBlur: () => setPickerVisible(false) }, options.map((option) => (React.createElement(NativePickerComponent.Item, { testID: "native-picker-item", label: option.label.toString(), value: option.value, key: option.value })))));
40
- const renderPicker = () => {
41
- if (isIos) {
42
- return (React.createElement(Portal, null,
43
- React.createElement(SafeAreaView, { style: styles.iosPickerContent },
44
- React.createElement(Button, { Icon: Icon, onPress: () => setPickerVisible(!pickerVisible), style: [
45
- styles.iosButton,
46
- { color: theme.colors.branding.primary },
47
- ], title: "Close" }),
48
- renderNativePicker())));
49
- }
50
- else {
51
- return renderNativePicker();
52
- }
53
- };
35
+ }, style: styles.nativePicker, onBlur: () => setPickerVisible(false) }, options.map((option) => (React.createElement(NativePickerComponent.Item, { testID: "native-picker-item", label: option.label.toString(), value: option.value, key: option.value })))));
54
36
  React.useEffect(() => {
55
37
  var _a;
56
38
  if (pickerVisible && pickerRef.current) {
@@ -62,7 +44,9 @@ const NativePicker = ({ options: optionsProp = [], onValueChange, Icon, placehol
62
44
  Keyboard.dismiss();
63
45
  }
64
46
  }, [pickerVisible, autoDismissKeyboard]);
65
- return (React.createElement(PickerInputContainer, { testID: "native-picker", Icon: Icon, placeholder: placeholder, selectedValue: value, options: options, onPress: () => setPickerVisible(!pickerVisible), disabled: disabled, ...rest }, (pickerVisible || isAndroid || isWeb) && !disabled && renderPicker()));
47
+ return (React.createElement(PickerInputContainer, { testID: "native-picker", Icon: Icon, placeholder: placeholder, selectedValue: value, options: options, onPress: () => setPickerVisible(!pickerVisible), disabled: disabled, ...rest }, (pickerVisible || isAndroid || isWeb) &&
48
+ !disabled &&
49
+ renderNativePicker()));
66
50
  };
67
51
  const styles = StyleSheet.create({
68
52
  nativePicker: {
@@ -77,26 +61,13 @@ const styles = StyleSheet.create({
77
61
  opacity: 0,
78
62
  ...Platform.select({
79
63
  web: {
80
- height: "100%", //To have the <select/> element fill the height
64
+ height: "100%",
81
65
  },
82
66
  android: {
83
- opacity: 0, // picker is a dialog, we don't want to show the default 'picker button' component
67
+ opacity: 0,
84
68
  },
85
69
  }),
86
70
  },
87
- iosNativePicker: {
88
- backgroundColor: "white",
89
- },
90
- iosPickerContent: {
91
- width: "100%",
92
- position: "absolute",
93
- bottom: 0,
94
- backgroundColor: "white",
95
- },
96
- iosButton: {
97
- backgroundColor: "transparent",
98
- borderWidth: 0,
99
- },
100
71
  });
101
72
  export default withTheme(NativePicker);
102
73
  //# sourceMappingURL=NativePicker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NativePicker.js","sourceRoot":"","sources":["NativePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,MAAM,IAAI,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAGL,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC;AACpC,MAAM,SAAS,GAAG,QAAQ,CAAC,EAAE,KAAK,SAAS,CAAC;AAC5C,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC;AAEpC,MAAM,YAAY,GAAoD,CAAC,EACrE,OAAO,EAAE,WAAW,GA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ACpB,cAAc,EAAE,QAAQ;QACxB,KAAK,EAAE,MAAM;QACb,eAAe,EAAE,OAAO;QACxB,OAAO,EAAE,CAAC;QACV,GAAG,QAAQ,CAAC,MAAM,CAAC;YACjB,GAAG,EAAE;gBACH,MAAM,EAAE,MAAM;aACf;YACD,OAAO,EAAE;gBACP,OAAO,EAAE,CAAC;aACX;SACF,CAAC;KACH;CACF,CAAC,CAAC;AAEH,eAAe,SAAS,CAAC,YAAY,CAAC,CAAC"}
@@ -1,9 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { StyleSheet, Platform, Keyboard } from "react-native";
3
- import { SafeAreaView } from "react-native-safe-area-context";
4
3
  import { Picker as NativePickerComponent } from "@react-native-picker/picker";
5
- import Portal from "../Portal/Portal";
6
- import { Button } from "../Button";
7
4
  import { useDeepCompareMemo } from "../../utilities";
8
5
  import {
9
6
  CommonPickerProps,
@@ -13,7 +10,6 @@ import {
13
10
  import PickerInputContainer from "./PickerInputContainer";
14
11
  import { withTheme } from "@draftbit/theme";
15
12
 
16
- const isIos = Platform.OS === "ios";
17
13
  const isAndroid = Platform.OS === "android";
18
14
  const isWeb = Platform.OS === "web";
19
15
 
@@ -61,7 +57,7 @@ const NativePicker: React.FC<CommonPickerProps & SinglePickerProps> = ({
61
57
  onValueChange?.("");
62
58
  }
63
59
  }}
64
- style={isIos ? styles.iosNativePicker : styles.nativePicker}
60
+ style={styles.nativePicker}
65
61
  onBlur={() => setPickerVisible(false)}
66
62
  >
67
63
  {options.map((option) => (
@@ -75,29 +71,6 @@ const NativePicker: React.FC<CommonPickerProps & SinglePickerProps> = ({
75
71
  </NativePickerComponent>
76
72
  );
77
73
 
78
- const renderPicker = () => {
79
- if (isIos) {
80
- return (
81
- <Portal>
82
- <SafeAreaView style={styles.iosPickerContent}>
83
- <Button
84
- Icon={Icon}
85
- onPress={() => setPickerVisible(!pickerVisible)}
86
- style={[
87
- styles.iosButton,
88
- { color: theme.colors.branding.primary },
89
- ]}
90
- title="Close"
91
- />
92
- {renderNativePicker()}
93
- </SafeAreaView>
94
- </Portal>
95
- );
96
- } else {
97
- return renderNativePicker();
98
- }
99
- };
100
-
101
74
  React.useEffect(() => {
102
75
  if (pickerVisible && pickerRef.current) {
103
76
  pickerRef?.current?.focus();
@@ -123,7 +96,9 @@ const NativePicker: React.FC<CommonPickerProps & SinglePickerProps> = ({
123
96
  >
124
97
  {/* Web version is collapsed by default, always show to allow direct expand */}
125
98
  {/* Android version needs to always be visible to allow .focus() call to launch the dialog */}
126
- {(pickerVisible || isAndroid || isWeb) && !disabled && renderPicker()}
99
+ {(pickerVisible || isAndroid || isWeb) &&
100
+ !disabled &&
101
+ renderNativePicker()}
127
102
  </PickerInputContainer>
128
103
  );
129
104
  };
@@ -141,26 +116,13 @@ const styles = StyleSheet.create({
141
116
  opacity: 0,
142
117
  ...Platform.select({
143
118
  web: {
144
- height: "100%", //To have the <select/> element fill the height
119
+ height: "100%",
145
120
  },
146
121
  android: {
147
- opacity: 0, // picker is a dialog, we don't want to show the default 'picker button' component
122
+ opacity: 0,
148
123
  },
149
124
  }),
150
125
  },
151
- iosNativePicker: {
152
- backgroundColor: "white",
153
- },
154
- iosPickerContent: {
155
- width: "100%",
156
- position: "absolute",
157
- bottom: 0,
158
- backgroundColor: "white",
159
- },
160
- iosButton: {
161
- backgroundColor: "transparent",
162
- borderWidth: 0,
163
- },
164
126
  });
165
127
 
166
128
  export default withTheme(NativePicker);