ferns-ui 0.25.3 → 0.26.1

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 (90) hide show
  1. package/dist/ActionSheet.d.ts +1 -1
  2. package/dist/ActionSheet.js +1 -2
  3. package/dist/ActionSheet.js.map +1 -1
  4. package/dist/Box.js +1 -1
  5. package/dist/Box.js.map +1 -1
  6. package/dist/CheckBox.d.ts +1 -4
  7. package/dist/CheckBox.js +33 -20
  8. package/dist/CheckBox.js.map +1 -1
  9. package/dist/Common.d.ts +44 -10
  10. package/dist/Common.js.map +1 -1
  11. package/dist/DateTimeField.android.d.ts +1 -1
  12. package/dist/DateTimeField.android.js +58 -16
  13. package/dist/DateTimeField.android.js.map +1 -1
  14. package/dist/DateTimeField.d.ts +2 -2
  15. package/dist/DateTimeField.ios.d.ts +1 -1
  16. package/dist/DateTimeField.ios.js +43 -12
  17. package/dist/DateTimeField.ios.js.map +1 -1
  18. package/dist/DateTimeField.js.map +1 -1
  19. package/dist/Field.js +2 -2
  20. package/dist/Field.js.map +1 -1
  21. package/dist/Mask.d.ts +2 -3
  22. package/dist/MediaQuery.d.ts +1 -0
  23. package/dist/MediaQuery.js +16 -0
  24. package/dist/MediaQuery.js.map +1 -1
  25. package/dist/Page.js.map +1 -1
  26. package/dist/SegmentedControl.js +6 -2
  27. package/dist/SegmentedControl.js.map +1 -1
  28. package/dist/SelectList.d.ts +1 -1
  29. package/dist/SelectList.js +9 -8
  30. package/dist/SelectList.js.map +1 -1
  31. package/dist/SplitPage.d.ts +3 -21
  32. package/dist/SplitPage.js +78 -23
  33. package/dist/SplitPage.js.map +1 -1
  34. package/dist/SplitPage.native.d.ts +3 -0
  35. package/dist/SplitPage.native.js +75 -0
  36. package/dist/SplitPage.native.js.map +1 -0
  37. package/dist/Table.d.ts +21 -0
  38. package/dist/Table.js +31 -0
  39. package/dist/Table.js.map +1 -0
  40. package/dist/TableHeader.d.ts +20 -0
  41. package/dist/TableHeader.js +11 -0
  42. package/dist/TableHeader.js.map +1 -0
  43. package/dist/TableHeaderCell.d.ts +15 -0
  44. package/dist/TableHeaderCell.js +36 -0
  45. package/dist/TableHeaderCell.js.map +1 -0
  46. package/dist/TableRow.d.ts +24 -0
  47. package/dist/TableRow.js +30 -0
  48. package/dist/TableRow.js.map +1 -0
  49. package/dist/TapToEdit.js +21 -16
  50. package/dist/TapToEdit.js.map +1 -1
  51. package/dist/TextField.js +11 -6
  52. package/dist/TextField.js.map +1 -1
  53. package/dist/Utilities.d.ts +1 -0
  54. package/dist/Utilities.js +18 -2
  55. package/dist/Utilities.js.map +1 -1
  56. package/dist/WithLabel.d.ts +3 -3
  57. package/dist/WithLabel.js +3 -0
  58. package/dist/WithLabel.js.map +1 -1
  59. package/dist/index.d.ts +9 -4
  60. package/dist/index.js +5 -0
  61. package/dist/index.js.map +1 -1
  62. package/dist/tableContext.d.ts +18 -0
  63. package/dist/tableContext.js +16 -0
  64. package/dist/tableContext.js.map +1 -0
  65. package/package.json +2 -1
  66. package/src/ActionSheet.tsx +2 -3
  67. package/src/Box.tsx +1 -0
  68. package/src/CheckBox.tsx +85 -60
  69. package/src/Common.ts +49 -10
  70. package/src/DateTimeField.android.tsx +71 -26
  71. package/src/DateTimeField.ios.tsx +55 -13
  72. package/src/DateTimeField.tsx +2 -2
  73. package/src/Field.tsx +4 -4
  74. package/src/Mask.tsx +2 -2
  75. package/src/MediaQuery.ts +14 -0
  76. package/src/Page.tsx +0 -1
  77. package/src/SegmentedControl.tsx +3 -3
  78. package/src/SelectList.tsx +9 -2
  79. package/src/SplitPage.native.tsx +156 -0
  80. package/src/SplitPage.tsx +136 -47
  81. package/src/Table.tsx +69 -0
  82. package/src/TableHeader.tsx +33 -0
  83. package/src/TableHeaderCell.tsx +76 -0
  84. package/src/TableRow.tsx +87 -0
  85. package/src/TapToEdit.tsx +21 -22
  86. package/src/TextField.tsx +26 -17
  87. package/src/Utilities.tsx +24 -3
  88. package/src/WithLabel.tsx +6 -3
  89. package/src/index.tsx +10 -5
  90. package/src/tableContext.tsx +43 -0
package/src/CheckBox.tsx CHANGED
@@ -1,27 +1,54 @@
1
- // import {library} from "@fortawesome/fontawesome-svg-core";
2
- // import {faCheck} from "@fortawesome/free-solid-svg-icons";
3
1
  import React from "react";
4
2
 
5
3
  import {Box} from "./Box";
6
- import {CheckBoxProps} from "./Common";
4
+ import {BoxColor, CheckBoxProps} from "./Common";
7
5
  import {Icon} from "./Icon";
8
6
  import {Text} from "./Text";
9
7
 
10
- // library.add(faCheck);
8
+ export function CheckBox({
9
+ color,
10
+ checked,
11
+ size,
12
+ radio,
13
+ label,
14
+ labelColor,
15
+ subLabel,
16
+ disabled,
17
+ onChange,
18
+ onClick,
19
+ indeterminate,
20
+ }: CheckBoxProps): React.ReactElement {
21
+ if (checked && indeterminate) {
22
+ console.error("CheckBox cannot be checked and indeterminate at the same time");
23
+ }
24
+
25
+ const doOnClick = () => {
26
+ if (disabled) {
27
+ return;
28
+ }
29
+ if (!indeterminate) {
30
+ onChange({value: !checked});
31
+ }
32
+ onClick && onClick();
33
+ };
11
34
 
12
- export class CheckBox extends React.Component<CheckBoxProps, {}> {
13
- renderCheckBox() {
35
+ const renderCheckBox = () => {
36
+ let bgColor: BoxColor;
37
+ if (disabled) {
38
+ bgColor = "gray";
39
+ } else if (checked) {
40
+ bgColor = color || "darkGray";
41
+ } else {
42
+ bgColor = "white";
43
+ }
14
44
  return (
15
45
  <Box
16
- border={this.props.color || "darkGray"}
17
- color={this.props.checked ? this.props.color || "darkGray" : "white"}
18
- height={this.props.size === "sm" ? 16 : 24}
19
- rounding={this.props.radio ? "circle" : 3}
20
- width={this.props.size === "sm" ? 16 : 24}
21
- onClick={() => {
22
- this.props.onChange({value: !this.props.checked});
23
- this.props.onClick && this.props.onClick();
24
- }}
46
+ border={color || "darkGray"}
47
+ color={bgColor}
48
+ height={size === "sm" ? 16 : 24}
49
+ rounding={radio ? "circle" : size === "sm" ? 2 : 3}
50
+ width={size === "sm" ? 16 : 24}
51
+ onClick={doOnClick}
25
52
  >
26
53
  <Box
27
54
  alignItems="center"
@@ -31,63 +58,61 @@ export class CheckBox extends React.Component<CheckBoxProps, {}> {
31
58
  justifyContent="center"
32
59
  width="100%"
33
60
  >
34
- {this.props.checked && (
61
+ {checked && (
62
+ <Icon color="white" name="check" prefix="fas" size={size === "sm" ? "sm" : "md"} />
63
+ )}
64
+ {indeterminate && (
35
65
  <Icon
36
- color="white"
37
- name="check"
66
+ color={color || "darkGray"}
67
+ name="circle"
38
68
  prefix="fas"
39
- size={this.props.size === "sm" ? "sm" : "md"}
69
+ size={size === "sm" ? "sm" : "md"}
40
70
  />
41
71
  )}
42
72
  </Box>
43
73
  </Box>
44
74
  );
45
- }
75
+ };
46
76
 
47
- render() {
48
- return (
77
+ return (
78
+ <Box
79
+ alignItems="center"
80
+ direction="row"
81
+ display="flex"
82
+ maxHeight={60}
83
+ paddingY={1}
84
+ width="100%"
85
+ >
49
86
  <Box
50
- alignItems="center"
51
- direction="row"
52
87
  display="flex"
53
- maxHeight={60}
54
- paddingY={1}
55
- width="100%"
88
+ justifyContent="center"
89
+ maxWidth={size === "sm" ? 14 : 20}
90
+ width={size === "sm" ? 14 : 20}
56
91
  >
57
- <Box
58
- display="flex"
59
- justifyContent="center"
60
- maxWidth={this.props.size === "sm" ? 14 : 20}
61
- width={this.props.size === "sm" ? 14 : 20}
62
- >
63
- {this.renderCheckBox()}
64
- </Box>
65
- <Box
66
- direction="column"
67
- display="flex"
68
- height="100%"
69
- justifyContent="center"
70
- marginLeft={4}
71
- onClick={() => {
72
- this.props.onChange({value: !this.props.checked});
73
- this.props.onClick && this.props.onClick();
74
- }}
92
+ {renderCheckBox()}
93
+ </Box>
94
+ <Box
95
+ direction="column"
96
+ display="flex"
97
+ height="100%"
98
+ justifyContent="center"
99
+ marginLeft={4}
100
+ onClick={doOnClick}
101
+ >
102
+ <Text
103
+ color={labelColor || "darkGray"}
104
+ numberOfLines={subLabel ? 1 : 2}
105
+ size={size}
106
+ weight="bold"
75
107
  >
76
- <Text
77
- color={this.props.labelColor || "darkGray"}
78
- numberOfLines={this.props.subLabel ? 1 : 2}
79
- size={this.props.size}
80
- weight="bold"
81
- >
82
- {this.props.label}
108
+ {label}
109
+ </Text>
110
+ {Boolean(subLabel) && (
111
+ <Text color={labelColor || "darkGray"} size="sm" weight="bold">
112
+ {subLabel!}
83
113
  </Text>
84
- {Boolean(this.props.subLabel) && (
85
- <Text color={this.props.labelColor || "darkGray"} size="sm" weight="bold">
86
- {this.props.subLabel}
87
- </Text>
88
- )}
89
- </Box>
114
+ )}
90
115
  </Box>
91
- );
92
- }
116
+ </Box>
117
+ );
93
118
  }
package/src/Common.ts CHANGED
@@ -1,4 +1,5 @@
1
- import {SyntheticEvent} from "react";
1
+ import {ReactElement, ReactNode, SyntheticEvent} from "react";
2
+ import {ListRenderItemInfo} from "react-native";
2
3
 
3
4
  export interface BaseProfile {
4
5
  email: string;
@@ -1832,16 +1833,16 @@ export interface BlurBoxProps extends BoxProps {
1832
1833
  }
1833
1834
 
1834
1835
  export interface LayerProps {
1835
- children: React.ReactNode;
1836
+ children: ReactChildren;
1836
1837
  }
1837
1838
 
1838
1839
  export interface ModalProps {
1839
1840
  header?: React.ReactNode;
1840
1841
  accessibilityModalLabel: string;
1841
- children?: React.ReactNode;
1842
+ children?: ReactChildren;
1842
1843
  closeOnOutsideClick?: boolean;
1843
- footer?: React.ReactNode;
1844
- heading?: string | React.ReactNode;
1844
+ footer?: ReactChild;
1845
+ heading?: string | ReactChild;
1845
1846
  onDismiss: () => void;
1846
1847
  role?: "alertdialog" | "dialog";
1847
1848
  size?: "sm" | "md" | "lg" | number;
@@ -1852,7 +1853,7 @@ export interface BoxProps {
1852
1853
  alignItems?: AlignItems;
1853
1854
  alignSelf?: AlignSelf;
1854
1855
  bottom?: boolean;
1855
- children?: React.ReactNode;
1856
+ children?: ReactChildren;
1856
1857
  color?: BoxColor;
1857
1858
  column?: UnsignedUpTo12;
1858
1859
  smColumn?: UnsignedUpTo12;
@@ -2019,13 +2020,16 @@ export interface FieldWithLabelsProps {
2019
2020
  labelColor?: AllColors;
2020
2021
  helperText?: string;
2021
2022
  helperTextColor?: AllColors;
2022
- children?: React.ReactNode;
2023
+ children?: ReactChildren;
2023
2024
  }
2024
2025
 
2025
2026
  export interface DateTimeFieldProps extends FieldWithLabelsProps {
2027
+ label?: string;
2026
2028
  mode: "date" | "time" | "datetime";
2027
2029
  value: Date;
2028
2030
  onChange: (date: Date) => void;
2031
+ dateFormat?: string;
2032
+ pickerType?: "default" | "compact" | "inline" | "spinner";
2029
2033
  }
2030
2034
 
2031
2035
  export interface TextFieldProps extends FieldWithLabelsProps {
@@ -2091,7 +2095,7 @@ export interface SpinnerProps {
2091
2095
  }
2092
2096
 
2093
2097
  export interface MaskProps {
2094
- children?: React.ReactElement;
2098
+ children?: ReactChildren;
2095
2099
  shape?: "circle" | "rounded" | "square";
2096
2100
  height?: number | string;
2097
2101
  width?: number | string;
@@ -2111,7 +2115,7 @@ export interface IconRowProps {
2111
2115
  export interface LinkProps {
2112
2116
  href: string;
2113
2117
  inline?: boolean;
2114
- children?: React.ReactNode;
2118
+ children?: ReactChild;
2115
2119
  onClick?: () => void;
2116
2120
  target?: null | "blank";
2117
2121
  }
@@ -2144,7 +2148,7 @@ export interface ImageProps {
2144
2148
  maxWidth?: number;
2145
2149
  maxHeight?: number;
2146
2150
  src: string;
2147
- children?: React.ReactNode;
2151
+ children?: ReactChildren;
2148
2152
  fit?: "cover" | "contain" | "none";
2149
2153
  onError?: () => void;
2150
2154
  onLoad?: () => void;
@@ -2624,6 +2628,35 @@ export interface PickerProps {
2624
2628
  prompt?: string;
2625
2629
  }
2626
2630
 
2631
+ export interface SplitPageProps {
2632
+ /**
2633
+ * can accept either one React Child or any array of ReactChild. If this is not provided,
2634
+ * renderContent must return one or many ReactChild.
2635
+ */
2636
+ children?: ReactChild | ReactChild[] | null;
2637
+ /**
2638
+ * The names of the tabs that will be generated per ReactChild provided. Tabs will not be generated if renderContent is provided in place of children
2639
+ */
2640
+ tabs?: string[];
2641
+ // The select limit for the number of tabs that can be selected
2642
+ selectLimit?: number;
2643
+ // Provide in mobile if you have a bottomTabBar so that split page can adjust accordingly
2644
+ bottomNavBarHeight?: number;
2645
+ // boolean to initiate and handle state from the app that has imported ferns-ui
2646
+ showItemList?: boolean;
2647
+ loading?: boolean;
2648
+ color?: Color;
2649
+ keyboardOffset?: number;
2650
+ renderListViewItem: (itemInfo: ListRenderItemInfo<any>) => ReactElement | null;
2651
+ renderListViewHeader?: () => ReactElement | null;
2652
+ renderContent?: (index?: number) => ReactElement | ReactElement[] | null;
2653
+ listViewData: any[];
2654
+ listViewExtraData?: any;
2655
+ listViewWidth?: number;
2656
+ renderChild?: () => ReactChild;
2657
+ onSelectionChange?: (value?: any) => void | Promise<void>;
2658
+ }
2659
+
2627
2660
  export type LogLevel = "fatal" | "error" | "warning" | "info" | "debug" | "critical";
2628
2661
  export type PermissionKind =
2629
2662
  | "location"
@@ -2698,3 +2731,9 @@ export interface AddressInterface {
2698
2731
  state: string;
2699
2732
  zipcode: string;
2700
2733
  }
2734
+
2735
+ // TODO: Tighten up type to exclude string, which is almost never an acceptable type for React Native children
2736
+ // (except Heading or Text for example.).
2737
+ export type ReactChild = ReactNode;
2738
+ export type ReactChildren = ReactNode;
2739
+ export type WithChildren<P> = P & {children?: ReactNode};
@@ -1,9 +1,10 @@
1
1
  import DateTimePicker from "@react-native-community/datetimepicker";
2
2
  import moment from "moment-timezone";
3
- import React, {ReactElement} from "react";
3
+ import React, {ReactElement, useMemo, useState} from "react";
4
+ import {TextInput} from "react-native";
4
5
 
5
- import {Box} from "./Box";
6
6
  import {DateTimeFieldProps} from "./Common";
7
+ import {Unifier} from "./Unifier";
7
8
  import {WithLabel} from "./WithLabel";
8
9
 
9
10
  export const DateTimeField = ({
@@ -11,8 +12,45 @@ export const DateTimeField = ({
11
12
  value,
12
13
  onChange,
13
14
  errorMessage,
15
+ pickerType = "default",
16
+ dateFormat,
14
17
  errorMessageColor,
15
18
  }: DateTimeFieldProps): ReactElement => {
19
+ // const [showCalendar, setShowCalendar] = useState(false);
20
+ // const [showClock, setShowClock] = useState(false);
21
+ // const [tempDate, setTempDate] = useState<Date>();
22
+ const [pickerMode, setPickerMode] = useState(mode);
23
+ const [showPicker, setShowPicker] = useState(false);
24
+
25
+ const showCalendarFirst = mode === "datetime" || mode === "date";
26
+
27
+ const defaultFormat = useMemo(() => {
28
+ if (dateFormat) {
29
+ return dateFormat;
30
+ } else {
31
+ if (mode === "date") {
32
+ return "MMMM Do YYYY";
33
+ } else if (mode === "time") {
34
+ return "h:mm a";
35
+ } else {
36
+ return "MMMM Do YYYY, h:mm a";
37
+ }
38
+ }
39
+ }, [mode, dateFormat]);
40
+
41
+ const showMode = (currentMode: "date" | "time") => {
42
+ setShowPicker(true);
43
+ setPickerMode(currentMode);
44
+ };
45
+
46
+ const showDatePicker = () => {
47
+ showMode("date");
48
+ };
49
+
50
+ const showTimePicker = () => {
51
+ showMode("time");
52
+ };
53
+
16
54
  return (
17
55
  <WithLabel
18
56
  label={errorMessage}
@@ -21,35 +59,42 @@ export const DateTimeField = ({
21
59
  labelSize="sm"
22
60
  >
23
61
  <WithLabel>
24
- <Box maxWidth={300}>
62
+ <TextInput
63
+ inputMode="none"
64
+ style={{
65
+ flex: 1,
66
+ paddingTop: 10,
67
+ paddingRight: 10,
68
+ paddingBottom: 10,
69
+ paddingLeft: 10,
70
+ height: 40,
71
+ width: "100%",
72
+ color: Unifier.theme.darkGray,
73
+ fontFamily: Unifier.theme.primaryFont,
74
+ borderWidth: 1,
75
+ }}
76
+ value={moment(value).format(defaultFormat)}
77
+ onPressIn={() => {
78
+ showCalendarFirst ? showDatePicker() : showTimePicker();
79
+ }}
80
+ />
81
+ {showPicker && (
25
82
  <DateTimePicker
26
- display="spinner"
27
- mode={mode === "datetime" ? "date" : mode}
83
+ display={pickerType}
84
+ mode={pickerMode}
28
85
  testID="dateTimePicker"
29
- value={moment(value).toDate()}
30
- onChange={(event: any, date: any) => {
31
- if (!date) {
32
- return;
86
+ value={value}
87
+ onChange={(event, date) => {
88
+ if (date) {
89
+ onChange(date);
90
+ if (pickerMode === "date" && mode === "datetime") {
91
+ showTimePicker();
92
+ }
33
93
  }
34
- onChange(value);
94
+ setShowPicker(false);
35
95
  }}
36
96
  />
37
- {mode === "datetime" && (
38
- <DateTimePicker
39
- display="spinner"
40
- mode="time"
41
- testID="dateTimePicker"
42
- value={moment(value).toDate()}
43
- onChange={(event: any, date: any) => {
44
- // fix to append to date object
45
- if (!date) {
46
- return;
47
- }
48
- onChange(value);
49
- }}
50
- />
51
- )}
52
- </Box>
97
+ )}
53
98
  </WithLabel>
54
99
  </WithLabel>
55
100
  );
@@ -1,9 +1,10 @@
1
1
  import DateTimePicker from "@react-native-community/datetimepicker";
2
2
  import moment from "moment-timezone";
3
- import React, {ReactElement} from "react";
3
+ import React, {ReactElement, useMemo, useState} from "react";
4
+ import {TextInput} from "react-native";
4
5
 
5
- import {Box} from "./Box";
6
6
  import {DateTimeFieldProps} from "./Common";
7
+ import {Unifier} from "./Unifier";
7
8
  import {WithLabel} from "./WithLabel";
8
9
 
9
10
  export const DateTimeField = ({
@@ -12,29 +13,70 @@ export const DateTimeField = ({
12
13
  onChange,
13
14
  errorMessage,
14
15
  errorMessageColor,
16
+ dateFormat,
17
+ pickerType = "inline",
18
+ label,
15
19
  }: DateTimeFieldProps): ReactElement => {
20
+ const [showPicker, setShowPicker] = useState(false);
21
+
22
+ const defaultFormat = useMemo(() => {
23
+ if (dateFormat) {
24
+ return dateFormat;
25
+ } else {
26
+ if (mode === "date") {
27
+ return "MMMM Do YYYY";
28
+ } else if (mode === "time") {
29
+ return "h:mm a";
30
+ } else {
31
+ return "MMMM Do YYYY, h:mm a";
32
+ }
33
+ }
34
+ }, [mode, dateFormat]);
35
+
16
36
  return (
17
- <WithLabel
18
- label={errorMessage}
19
- labelColor={errorMessageColor || "red"}
20
- labelPlacement="after"
21
- labelSize="sm"
22
- >
23
- <WithLabel>
24
- <Box maxWidth={300}>
37
+ <WithLabel label={label} labelSize="lg">
38
+ <WithLabel
39
+ label={errorMessage}
40
+ labelColor={errorMessageColor || "red"}
41
+ labelPlacement="after"
42
+ labelSize="sm"
43
+ >
44
+ <TextInput
45
+ inputMode="none"
46
+ style={{
47
+ flex: 1,
48
+ paddingTop: 10,
49
+ paddingRight: 10,
50
+ paddingBottom: 10,
51
+ paddingLeft: 10,
52
+ height: 40,
53
+ width: "100%",
54
+ color: Unifier.theme.darkGray,
55
+ fontFamily: Unifier.theme.primaryFont,
56
+ borderWidth: 1,
57
+ }}
58
+ value={moment(value).format(defaultFormat)}
59
+ onPressIn={() => {
60
+ setShowPicker(!showPicker);
61
+ }}
62
+ />
63
+
64
+ {showPicker && (
25
65
  <DateTimePicker
26
- display="spinner"
66
+ accentColor={Unifier.theme.primary}
67
+ display={pickerType}
27
68
  mode={mode}
69
+ style={{alignSelf: "flex-start"}}
28
70
  testID="dateTimePicker"
29
71
  value={moment(value).toDate()}
30
72
  onChange={(event: any, date: any) => {
31
73
  if (!date) {
32
74
  return;
33
75
  }
34
- onChange(value);
76
+ onChange(date);
35
77
  }}
36
78
  />
37
- </Box>
79
+ )}
38
80
  </WithLabel>
39
81
  </WithLabel>
40
82
  );
@@ -4,7 +4,7 @@ import DateTimePickerWeb from "react-datetime-picker";
4
4
  import TimePicker from "react-time-picker";
5
5
 
6
6
  import {Box} from "./Box";
7
- import {DateTimeFieldProps} from "./Common";
7
+ import {DateTimeFieldProps, WithChildren} from "./Common";
8
8
  import {WithLabel} from "./WithLabel";
9
9
 
10
10
  export const DateTimeField = ({
@@ -13,7 +13,7 @@ export const DateTimeField = ({
13
13
  onChange,
14
14
  errorMessage,
15
15
  errorMessageColor,
16
- }: DateTimeFieldProps): ReactElement => {
16
+ }: WithChildren<DateTimeFieldProps>): ReactElement => {
17
17
  return (
18
18
  <WithLabel
19
19
  label={errorMessage}
package/src/Field.tsx CHANGED
@@ -2,7 +2,7 @@ import React from "react";
2
2
 
3
3
  import {Box} from "./Box";
4
4
  import {CheckBox} from "./CheckBox";
5
- import {AddressInterface, FieldWithLabelsProps, TextFieldType} from "./Common";
5
+ import {AddressInterface, FieldWithLabelsProps, ReactChildren, TextFieldType} from "./Common";
6
6
  import {USSTATESLIST} from "./Constants";
7
7
  import {CustomSelect} from "./CustomSelect";
8
8
  import {FieldWithLabels} from "./FieldWithLabels";
@@ -66,11 +66,11 @@ export const Field = ({
66
66
  onChange(switchValue);
67
67
  };
68
68
 
69
- const renderField = () => {
69
+ const renderField = (): ReactChildren => {
70
70
  if (type === "select") {
71
71
  if (!options) {
72
72
  console.error("Field with type=select require options");
73
- return null;
73
+ return undefined;
74
74
  }
75
75
  return (
76
76
  <SelectList
@@ -85,7 +85,7 @@ export const Field = ({
85
85
  } else if (type === "multiselect") {
86
86
  if (!options) {
87
87
  console.error("Field with type=multiselect require options");
88
- return null;
88
+ return undefined;
89
89
  }
90
90
  return (
91
91
  <Box width="100%">
package/src/Mask.tsx CHANGED
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
2
  import {View} from "react-native";
3
3
 
4
- import {MaskProps} from "./Common";
4
+ import {MaskProps, ReactChildren} from "./Common";
5
5
 
6
- export function Mask(props: MaskProps): React.ReactElement | null {
6
+ export function Mask(props: MaskProps): ReactChildren {
7
7
  if (props.shape === "rounded") {
8
8
  return <View style={{overflow: "hidden", borderRadius: 12}}>{props.children}</View>;
9
9
  } else if (props.shape === "circle") {
package/src/MediaQuery.ts CHANGED
@@ -26,3 +26,17 @@ export function mediaQueryLargerThan(size: "xs" | "sm" | "md" | "lg"): boolean {
26
26
  }
27
27
  return false;
28
28
  }
29
+
30
+ export function mediaQuerySmallerThan(size: "xs" | "sm" | "md" | "lg"): boolean {
31
+ const media = mediaQuery();
32
+ if (size === "lg") {
33
+ return true;
34
+ } else if (size === "md") {
35
+ return ["xs", "sm", "md"].includes(media);
36
+ } else if (size === "sm") {
37
+ return ["xs", "sm"].includes(media);
38
+ } else if (size === "xs") {
39
+ return ["xs"].includes(media);
40
+ }
41
+ return false;
42
+ }
package/src/Page.tsx CHANGED
@@ -97,7 +97,6 @@ export class Page extends React.Component<PageProps, {}> {
97
97
  padding={this.props.padding !== undefined ? this.props.padding : 2}
98
98
  scroll={this.props.scroll === undefined ? true : this.props.scroll}
99
99
  width="100%"
100
- // color="ligh"
101
100
  >
102
101
  {this.renderHeader()}
103
102
  {this.props.loading === true && (
@@ -27,7 +27,7 @@ export const SegmentedControl = ({
27
27
  }
28
28
 
29
29
  if (!multiselect && selectedItemIndexes?.length && selectedItemIndexes?.length > 1) {
30
- console.warn("Muliple selections not allowed without multiselect flag");
30
+ console.warn("Multiple selections not allowed without multiselect flag");
31
31
  return null;
32
32
  }
33
33
 
@@ -49,7 +49,7 @@ export const SegmentedControl = ({
49
49
  display="flex"
50
50
  height={40}
51
51
  justifyContent="between"
52
- padding={1}
52
+ // padding={1}
53
53
  rounding={3}
54
54
  width="100%"
55
55
  >
@@ -58,7 +58,7 @@ export const SegmentedControl = ({
58
58
  key={index}
59
59
  color={isTabActive(index)}
60
60
  height="100%"
61
- paddingX={2}
61
+ // paddingX={2}
62
62
  rounding={3}
63
63
  width={`${100 / items.length}%`}
64
64
  >
@@ -30,18 +30,25 @@ export function SelectList({
30
30
  labelColor,
31
31
  style,
32
32
  placeholder,
33
+ disabled,
33
34
  }: SelectListProps) {
34
35
  const withLabelProps = {label, labelColor};
35
36
 
37
+ let backgroundColor = style?.backgroundColor || Unifier.theme.white;
38
+ if (disabled) {
39
+ backgroundColor = Unifier.theme.lightGray;
40
+ }
41
+
36
42
  return (
37
43
  <WithLabel {...withLabelProps}>
38
44
  <RNPickerSelect
39
- // Icon only needed for iOs, web and android use default icons
40
45
  Icon={() => {
46
+ // Icon only needed for iOS, web and android use default icons
41
47
  return Platform.OS === "ios" ? (
42
48
  <Icon color="darkGray" name="angle-down" size="md" />
43
49
  ) : null;
44
50
  }}
51
+ disabled={disabled}
45
52
  items={options}
46
53
  placeholder={placeholder ? {label: placeholder, value: ""} : {}}
47
54
  style={{
@@ -54,7 +61,7 @@ export function SelectList({
54
61
  borderColor: style?.borderColor || Unifier.theme.gray,
55
62
  borderWidth: style?.borderWidth || 1,
56
63
  borderRadius: style?.borderRadius || 5,
57
- backgroundColor: style?.backgroundColor || Unifier.theme.white,
64
+ backgroundColor,
58
65
  },
59
66
  inputIOS: {
60
67
  paddingVertical: 12,