@draftbit/core 44.1.12 → 44.1.13-2d7ff5.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.
Files changed (38) hide show
  1. package/lib/commonjs/Provider.js.map +1 -1
  2. package/lib/commonjs/components/Accordion/AccordionItem.js +21 -5
  3. package/lib/commonjs/components/Accordion/AccordionItem.js.map +1 -1
  4. package/lib/commonjs/components/Accordion/index.js.map +1 -1
  5. package/lib/commonjs/components/Picker/Picker.js +23 -47
  6. package/lib/commonjs/components/Picker/Picker.js.map +1 -1
  7. package/lib/commonjs/components/Picker/PickerComponent.android.js +59 -0
  8. package/lib/commonjs/components/Picker/PickerComponent.android.js.map +1 -0
  9. package/lib/commonjs/components/Picker/PickerComponent.ios.js +92 -0
  10. package/lib/commonjs/components/Picker/PickerComponent.ios.js.map +1 -0
  11. package/lib/commonjs/components/Picker/PickerComponent.web.js +59 -0
  12. package/lib/commonjs/components/Picker/PickerComponent.web.js.map +1 -0
  13. package/lib/commonjs/components/RowHeadlineImageIcon.js.map +1 -1
  14. package/lib/commonjs/components/Typography.js.map +1 -1
  15. package/lib/commonjs/mappings/CircleImage.js.map +1 -1
  16. package/lib/commonjs/mappings/RowHeadlineImageCaption.js.map +1 -1
  17. package/lib/commonjs/mappings/SafeAreaView.js.map +1 -1
  18. package/lib/commonjs/mappings/TextArea.js.map +1 -1
  19. package/lib/module/components/Picker/Picker.js +26 -47
  20. package/lib/module/components/Picker/Picker.js.map +1 -1
  21. package/lib/module/components/Picker/PickerComponent.android.js +41 -0
  22. package/lib/module/components/Picker/PickerComponent.android.js.map +1 -0
  23. package/lib/module/components/Picker/PickerComponent.ios.js +69 -0
  24. package/lib/module/components/Picker/PickerComponent.ios.js.map +1 -0
  25. package/lib/module/components/Picker/PickerComponent.web.js +41 -0
  26. package/lib/module/components/Picker/PickerComponent.web.js.map +1 -0
  27. package/lib/typescript/src/components/Picker/PickerComponent.android.d.ts +13 -0
  28. package/lib/typescript/src/components/Picker/PickerComponent.ios.d.ts +13 -0
  29. package/lib/typescript/src/components/Picker/PickerComponent.web.d.ts +13 -0
  30. package/package.json +2 -2
  31. package/src/components/Picker/Picker.js +21 -19
  32. package/src/components/Picker/Picker.tsx +30 -12
  33. package/src/components/Picker/PickerComponent.android.js +20 -0
  34. package/src/components/Picker/PickerComponent.android.tsx +59 -0
  35. package/src/components/Picker/PickerComponent.ios.js +43 -0
  36. package/src/components/Picker/PickerComponent.ios.tsx +89 -0
  37. package/src/components/Picker/PickerComponent.web.js +20 -0
  38. package/src/components/Picker/PickerComponent.web.tsx +59 -0
@@ -1,13 +1,15 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Text, Platform, Dimensions, } from "react-native";
2
+ import { View, StyleSheet, Text, Dimensions, } from "react-native";
3
3
  import { omit, pickBy, identity, isObject } from "lodash";
4
- import { SafeAreaView } from "react-native-safe-area-context";
5
- import { Picker as NativePicker } from "@react-native-picker/picker";
4
+ // import { SafeAreaView } from "react-native-safe-area-context";
5
+ // import { Picker as NativePicker } from "@react-native-picker/picker";
6
6
  import { withTheme } from "../../theming";
7
- import Portal from "../Portal/Portal";
8
- import Button from "../DeprecatedButton";
7
+ // import Portal from "../Portal/Portal";
8
+ // import Button from "../DeprecatedButton";
9
9
  import Touchable from "../Touchable";
10
10
  import { extractStyles, extractBorderAndMarginStyles, borderStyleNames, marginStyleNames, } from "../../utilities";
11
+ // @ts-expect-error
12
+ import { PickerComponent } from "./PickerComponent";
11
13
  function normalizeOptions(options) {
12
14
  if (options.length === 0) {
13
15
  return [];
@@ -31,11 +33,13 @@ function normalizeOptions(options) {
31
33
  throw new Error('Picker options must be either an array of strings or array of { "label": string; "value": string; } objects.');
32
34
  }
33
35
  const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
34
- const isIos = Platform.OS === "ios";
36
+ // const isIos = Platform.OS === "ios";
35
37
  const unstyledColor = "rgba(165, 173, 183, 1)";
36
38
  const disabledColor = "rgb(240, 240, 240)";
37
39
  const errorColor = "rgba(255, 69, 100, 1)";
38
- const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style, placeholder, value, disabled = false, theme, assistiveText, label, iconColor = unstyledColor, iconSize = 24, leftIconMode = "inset", leftIconName, placeholderTextColor = unstyledColor, rightIconName, type = "solid", }) => {
40
+ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style, placeholder, value, disabled = false,
41
+ // theme,
42
+ assistiveText, label, iconColor = unstyledColor, iconSize = 24, leftIconMode = "inset", leftIconName, placeholderTextColor = unstyledColor, rightIconName, type = "solid", }) => {
39
43
  const androidPickerRef = React.useRef(undefined);
40
44
  const [internalValue, setInternalValue] = React.useState(value || defaultValue);
41
45
  const [pickerVisible, setPickerVisible] = React.useState(false);
@@ -61,7 +65,7 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
61
65
  const pickerOptions = placeholder
62
66
  ? [{ value: placeholder, label: placeholder }, ...normalizedOptions]
63
67
  : normalizedOptions;
64
- const { colors } = theme;
68
+ // const { colors } = theme;
65
69
  const { viewStyles, textStyles } = extractStyles(style);
66
70
  const additionalBorderStyles = ["backgroundColor"];
67
71
  const additionalMarginStyles = [
@@ -181,17 +185,14 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
181
185
  React.createElement(Text, { style: primaryTextStyle }, String(selectedLabel ?? placeholder))),
182
186
  rightIcon)),
183
187
  assistiveTextLabel),
184
- isIos && pickerVisible ? (React.createElement(Portal, null,
185
- React.createElement(View, { style: [
186
- styles.iosPicker,
187
- {
188
- backgroundColor: colors.divider,
189
- },
190
- ] },
191
- React.createElement(SafeAreaView, { style: styles.iosSafeArea },
192
- React.createElement(Button, { Icon: Icon, type: "text", onPress: togglePickerVisible, style: styles.iosButton }, "Close"),
193
- React.createElement(NativePicker, { style: styles.iosNativePicker, selectedValue: internalValue, onValueChange: handleValueChange }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value })))))))) : null,
194
- !isIos && pickerVisible ? (React.createElement(NativePicker, { enabled: pickerVisible, selectedValue: internalValue, onValueChange: handleValueChange, style: styles.nonIosPicker, ref: androidPickerRef, onBlur: () => setPickerVisible(false) }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value }))))) : null));
188
+ React.createElement(View, null, pickerVisible ? (React.createElement(PickerComponent, { ...{
189
+ Icon,
190
+ androidPickerRef,
191
+ togglePickerVisible,
192
+ pickerOptions,
193
+ internalValue,
194
+ handleValueChange,
195
+ } })) : null)));
195
196
  };
196
197
  export default withTheme(Picker);
197
198
  const styles = StyleSheet.create({
@@ -207,6 +208,7 @@ const styles = StyleSheet.create({
207
208
  width: "100%",
208
209
  alignSelf: "stretch",
209
210
  alignItems: "center",
211
+ backgroundColor: "pink", // TODO
210
212
  },
211
213
  outsetContainer: {
212
214
  flex: 1,
@@ -3,18 +3,18 @@ import {
3
3
  View,
4
4
  StyleSheet,
5
5
  Text,
6
- Platform,
6
+ // Platform,
7
7
  ViewStyle,
8
8
  StyleProp,
9
9
  Dimensions,
10
10
  } from "react-native";
11
11
  import { omit, pickBy, identity, isObject } from "lodash";
12
- import { SafeAreaView } from "react-native-safe-area-context";
13
- import { Picker as NativePicker } from "@react-native-picker/picker";
12
+ // import { SafeAreaView } from "react-native-safe-area-context";
13
+ // import { Picker as NativePicker } from "@react-native-picker/picker";
14
14
 
15
15
  import { withTheme } from "../../theming";
16
- import Portal from "../Portal/Portal";
17
- import Button from "../DeprecatedButton";
16
+ // import Portal from "../Portal/Portal";
17
+ // import Button from "../DeprecatedButton";
18
18
  import Touchable from "../Touchable";
19
19
  import type { Theme } from "../../styles/DefaultTheme";
20
20
  import type { IconSlot } from "../../interfaces/Icon";
@@ -24,6 +24,8 @@ import {
24
24
  borderStyleNames,
25
25
  marginStyleNames,
26
26
  } from "../../utilities";
27
+ // @ts-expect-error
28
+ import { PickerComponent } from "./PickerComponent";
27
29
 
28
30
  export interface PickerOption {
29
31
  value: string;
@@ -83,7 +85,7 @@ function normalizeOptions(options: PickerProps["options"]): PickerOption[] {
83
85
  }
84
86
 
85
87
  const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
86
- const isIos = Platform.OS === "ios";
88
+ // const isIos = Platform.OS === "ios";
87
89
  const unstyledColor = "rgba(165, 173, 183, 1)";
88
90
  const disabledColor = "rgb(240, 240, 240)";
89
91
  const errorColor = "rgba(255, 69, 100, 1)";
@@ -98,7 +100,7 @@ const Picker: React.FC<PickerProps> = ({
98
100
  placeholder,
99
101
  value,
100
102
  disabled = false,
101
- theme,
103
+ // theme,
102
104
  assistiveText,
103
105
  label,
104
106
  iconColor = unstyledColor,
@@ -145,7 +147,7 @@ const Picker: React.FC<PickerProps> = ({
145
147
  ? [{ value: placeholder, label: placeholder }, ...normalizedOptions]
146
148
  : normalizedOptions;
147
149
 
148
- const { colors } = theme;
150
+ // const { colors } = theme;
149
151
 
150
152
  const { viewStyles, textStyles } = extractStyles(style);
151
153
 
@@ -344,8 +346,23 @@ const Picker: React.FC<PickerProps> = ({
344
346
  {assistiveTextLabel}
345
347
  </Touchable>
346
348
 
349
+ <View>
350
+ {pickerVisible ? (
351
+ <PickerComponent
352
+ {...{
353
+ Icon,
354
+ androidPickerRef,
355
+ togglePickerVisible,
356
+ pickerOptions,
357
+ internalValue,
358
+ handleValueChange,
359
+ }}
360
+ />
361
+ ) : null}
362
+ </View>
363
+
347
364
  {/* iosPicker */}
348
- {isIos && pickerVisible ? (
365
+ {/* isIos && pickerVisible ? (
349
366
  <Portal>
350
367
  <View
351
368
  style={[
@@ -381,10 +398,10 @@ const Picker: React.FC<PickerProps> = ({
381
398
  </SafeAreaView>
382
399
  </View>
383
400
  </Portal>
384
- ) : null}
401
+ ) : null */}
385
402
 
386
403
  {/* nonIosPicker */}
387
- {!isIos && pickerVisible ? (
404
+ {/* !isIos && pickerVisible ? (
388
405
  <NativePicker
389
406
  enabled={pickerVisible}
390
407
  selectedValue={internalValue}
@@ -401,7 +418,7 @@ const Picker: React.FC<PickerProps> = ({
401
418
  />
402
419
  ))}
403
420
  </NativePicker>
404
- ) : null}
421
+ ) : null */}
405
422
  </View>
406
423
  );
407
424
  };
@@ -421,6 +438,7 @@ const styles = StyleSheet.create({
421
438
  width: "100%",
422
439
  alignSelf: "stretch",
423
440
  alignItems: "center",
441
+ backgroundColor: "pink", // TODO
424
442
  },
425
443
  outsetContainer: {
426
444
  flex: 1,
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+ import { StyleSheet, Dimensions } from "react-native";
3
+ import { Picker as NativePicker } from "@react-native-picker/picker";
4
+ const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
5
+ export const PickerComponent = ({ androidPickerRef, togglePickerVisible, pickerOptions, internalValue, handleValueChange, }) => {
6
+ return (React.createElement(NativePicker, { selectedValue: internalValue, onValueChange: handleValueChange, style: styles.nonIosPicker, ref: androidPickerRef, onBlur: togglePickerVisible }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value })))));
7
+ };
8
+ const styles = StyleSheet.create({
9
+ nonIosPicker: {
10
+ opacity: 0,
11
+ position: "absolute",
12
+ top: 0,
13
+ left: 0,
14
+ right: 0,
15
+ bottom: 0,
16
+ width: "100%",
17
+ maxWidth: deviceWidth,
18
+ maxHeight: deviceHeight,
19
+ },
20
+ });
@@ -0,0 +1,59 @@
1
+ import * as React from "react";
2
+ import { StyleSheet, Dimensions } from "react-native";
3
+
4
+ import { Picker as NativePicker } from "@react-native-picker/picker";
5
+
6
+ import type { IconSlot } from "../../interfaces/Icon";
7
+
8
+ import { PickerOption } from "./Picker";
9
+
10
+ const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
11
+
12
+ interface PickerComponentProps {
13
+ Icon: IconSlot["Icon"];
14
+ androidPickerRef: React.RefObject<any>;
15
+ togglePickerVisible: () => void;
16
+ pickerOptions: PickerOption[];
17
+ internalValue: string | undefined;
18
+ handleValueChange: (newValue: string, itemIndex: number) => void;
19
+ }
20
+
21
+ export const PickerComponent: React.FC<PickerComponentProps> = ({
22
+ androidPickerRef,
23
+ togglePickerVisible,
24
+ pickerOptions,
25
+ internalValue,
26
+ handleValueChange,
27
+ }) => {
28
+ return (
29
+ <NativePicker
30
+ selectedValue={internalValue}
31
+ onValueChange={handleValueChange}
32
+ style={styles.nonIosPicker}
33
+ ref={androidPickerRef}
34
+ onBlur={togglePickerVisible}
35
+ >
36
+ {(pickerOptions as unknown as PickerOption[]).map((option) => (
37
+ <NativePicker.Item
38
+ label={option.label}
39
+ value={option.value}
40
+ key={option.value}
41
+ />
42
+ ))}
43
+ </NativePicker>
44
+ );
45
+ };
46
+
47
+ const styles = StyleSheet.create({
48
+ nonIosPicker: {
49
+ opacity: 0,
50
+ position: "absolute",
51
+ top: 0,
52
+ left: 0,
53
+ right: 0,
54
+ bottom: 0,
55
+ width: "100%",
56
+ maxWidth: deviceWidth,
57
+ maxHeight: deviceHeight,
58
+ },
59
+ });
@@ -0,0 +1,43 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet, Dimensions } from "react-native";
3
+ import { SafeAreaView } from "react-native-safe-area-context";
4
+ import { Picker as NativePicker } from "@react-native-picker/picker";
5
+ import Portal from "../Portal/Portal";
6
+ import Button from "../DeprecatedButton";
7
+ const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
8
+ export const PickerComponent = ({ Icon, togglePickerVisible, pickerOptions, internalValue, handleValueChange, }) => {
9
+ return (React.createElement(Portal, null,
10
+ React.createElement(View, { style: styles.iosPicker },
11
+ React.createElement(SafeAreaView, { style: styles.iosSafeArea },
12
+ React.createElement(Button, { Icon: Icon, type: "text", onPress: togglePickerVisible, style: styles.iosButton }, "Close"),
13
+ React.createElement(NativePicker, { style: styles.iosNativePicker, selectedValue: internalValue, onValueChange: handleValueChange }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value }))))))));
14
+ };
15
+ const styles = StyleSheet.create({
16
+ iosPicker: {
17
+ position: "absolute",
18
+ bottom: 0,
19
+ left: 0,
20
+ right: 0,
21
+ flexDirection: "row",
22
+ justifyContent: "center",
23
+ width: deviceWidth,
24
+ maxWidth: deviceWidth,
25
+ maxHeight: deviceHeight,
26
+ backgroundColor: "green", // TODO
27
+ // backgroundColor: "rgba(255, 255, 255, 1)",
28
+ },
29
+ iosSafeArea: {
30
+ backgroundColor: "yellow",
31
+ // backgroundColor: "white",// TODO
32
+ flexDirection: "column",
33
+ width: deviceWidth,
34
+ maxWidth: deviceWidth,
35
+ },
36
+ iosButton: {
37
+ alignSelf: "flex-end",
38
+ },
39
+ iosNativePicker: {
40
+ //backgroundColor: "white",// TODO
41
+ backgroundColor: "red",
42
+ },
43
+ });
@@ -0,0 +1,89 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet, Dimensions } from "react-native";
3
+ import { SafeAreaView } from "react-native-safe-area-context";
4
+ import { Picker as NativePicker } from "@react-native-picker/picker";
5
+
6
+ import type { IconSlot } from "../../interfaces/Icon";
7
+ import Portal from "../Portal/Portal";
8
+ import Button from "../DeprecatedButton";
9
+ import { PickerOption } from "./Picker";
10
+
11
+ const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
12
+
13
+ interface PickerComponentProps {
14
+ Icon: IconSlot["Icon"];
15
+ androidPickerRef: React.RefObject<any>;
16
+ togglePickerVisible: () => void;
17
+ pickerOptions: PickerOption[];
18
+ internalValue: string | undefined;
19
+ handleValueChange: (newValue: string, itemIndex: number) => void;
20
+ }
21
+
22
+ export const PickerComponent: React.FC<PickerComponentProps> = ({
23
+ Icon,
24
+ togglePickerVisible,
25
+ pickerOptions,
26
+ internalValue,
27
+ handleValueChange,
28
+ }) => {
29
+ return (
30
+ <Portal>
31
+ <View style={styles.iosPicker}>
32
+ <SafeAreaView style={styles.iosSafeArea}>
33
+ <Button
34
+ Icon={Icon}
35
+ type="text"
36
+ onPress={togglePickerVisible}
37
+ style={styles.iosButton}
38
+ >
39
+ {"Close"}
40
+ </Button>
41
+
42
+ <NativePicker
43
+ style={styles.iosNativePicker}
44
+ selectedValue={internalValue}
45
+ onValueChange={handleValueChange}
46
+ >
47
+ {(pickerOptions as unknown as PickerOption[]).map((option) => (
48
+ <NativePicker.Item
49
+ label={option.label}
50
+ value={option.value}
51
+ key={option.value}
52
+ />
53
+ ))}
54
+ </NativePicker>
55
+ </SafeAreaView>
56
+ </View>
57
+ </Portal>
58
+ );
59
+ };
60
+
61
+ const styles = StyleSheet.create({
62
+ iosPicker: {
63
+ position: "absolute",
64
+ bottom: 0,
65
+ left: 0,
66
+ right: 0,
67
+ flexDirection: "row",
68
+ justifyContent: "center",
69
+ width: deviceWidth, // TODO
70
+ maxWidth: deviceWidth,
71
+ maxHeight: deviceHeight,
72
+ backgroundColor: "green", // TODO
73
+ // backgroundColor: "rgba(255, 255, 255, 1)",
74
+ },
75
+ iosSafeArea: {
76
+ backgroundColor: "yellow",
77
+ // backgroundColor: "white",// TODO
78
+ flexDirection: "column",
79
+ width: deviceWidth,
80
+ maxWidth: deviceWidth,
81
+ },
82
+ iosButton: {
83
+ alignSelf: "flex-end",
84
+ },
85
+ iosNativePicker: {
86
+ //backgroundColor: "white",// TODO
87
+ backgroundColor: "red",
88
+ },
89
+ });
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+ import { StyleSheet, Dimensions } from "react-native";
3
+ import { Picker as NativePicker } from "@react-native-picker/picker";
4
+ const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
5
+ export const PickerComponent = ({ androidPickerRef, togglePickerVisible, pickerOptions, internalValue, handleValueChange, }) => {
6
+ return (React.createElement(NativePicker, { selectedValue: internalValue, onValueChange: handleValueChange, style: styles.nonIosPicker, ref: androidPickerRef, onBlur: togglePickerVisible }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value })))));
7
+ };
8
+ const styles = StyleSheet.create({
9
+ nonIosPicker: {
10
+ opacity: 0,
11
+ position: "absolute",
12
+ top: 0,
13
+ left: 0,
14
+ right: 0,
15
+ bottom: 0,
16
+ width: "100%",
17
+ maxWidth: deviceWidth,
18
+ maxHeight: deviceHeight,
19
+ },
20
+ });
@@ -0,0 +1,59 @@
1
+ import * as React from "react";
2
+ import { StyleSheet, Dimensions } from "react-native";
3
+
4
+ import { Picker as NativePicker } from "@react-native-picker/picker";
5
+
6
+ import type { IconSlot } from "../../interfaces/Icon";
7
+
8
+ import { PickerOption } from "./Picker";
9
+
10
+ const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
11
+
12
+ interface PickerComponentProps {
13
+ Icon: IconSlot["Icon"];
14
+ androidPickerRef: React.RefObject<any>;
15
+ togglePickerVisible: () => void;
16
+ pickerOptions: PickerOption[];
17
+ internalValue: string | undefined;
18
+ handleValueChange: (newValue: string, itemIndex: number) => void;
19
+ }
20
+
21
+ export const PickerComponent: React.FC<PickerComponentProps> = ({
22
+ androidPickerRef,
23
+ togglePickerVisible,
24
+ pickerOptions,
25
+ internalValue,
26
+ handleValueChange,
27
+ }) => {
28
+ return (
29
+ <NativePicker
30
+ selectedValue={internalValue}
31
+ onValueChange={handleValueChange}
32
+ style={styles.nonIosPicker}
33
+ ref={androidPickerRef}
34
+ onBlur={togglePickerVisible}
35
+ >
36
+ {(pickerOptions as unknown as PickerOption[]).map((option) => (
37
+ <NativePicker.Item
38
+ label={option.label}
39
+ value={option.value}
40
+ key={option.value}
41
+ />
42
+ ))}
43
+ </NativePicker>
44
+ );
45
+ };
46
+
47
+ const styles = StyleSheet.create({
48
+ nonIosPicker: {
49
+ opacity: 0,
50
+ position: "absolute",
51
+ top: 0,
52
+ left: 0,
53
+ right: 0,
54
+ bottom: 0,
55
+ width: "100%",
56
+ maxWidth: deviceWidth,
57
+ maxHeight: deviceHeight,
58
+ },
59
+ });