@draftbit/core 44.2.1-ada448.0 → 44.2.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 (41) hide show
  1. package/lib/commonjs/components/Accordion/index.js.map +1 -1
  2. package/lib/commonjs/components/ActionSheet/index.js.map +1 -1
  3. package/lib/commonjs/components/CircularProgress.js.map +1 -1
  4. package/lib/commonjs/components/Container.js +5 -16
  5. package/lib/commonjs/components/Container.js.map +1 -1
  6. package/lib/commonjs/components/Divider.js +3 -13
  7. package/lib/commonjs/components/Divider.js.map +1 -1
  8. package/lib/commonjs/components/FAB.js +5 -19
  9. package/lib/commonjs/components/FAB.js.map +1 -1
  10. package/lib/commonjs/components/FormRow.js +5 -18
  11. package/lib/commonjs/components/FormRow.js.map +1 -1
  12. package/lib/commonjs/components/Picker/Picker.js +289 -26
  13. package/lib/commonjs/components/Picker/Picker.js.map +1 -1
  14. package/lib/commonjs/index.js.map +1 -1
  15. package/lib/commonjs/mappings/Card.js.map +1 -1
  16. package/lib/commonjs/mappings/Picker.js +7 -1
  17. package/lib/commonjs/mappings/Picker.js.map +1 -1
  18. package/lib/commonjs/mappings/RowHeadlineImageIcon.js.map +1 -1
  19. package/lib/commonjs/mappings/TextArea.js.map +1 -1
  20. package/lib/commonjs/utilities.js +19 -0
  21. package/lib/commonjs/utilities.js.map +1 -1
  22. package/lib/module/components/Accordion/AccordionItem.js +22 -5
  23. package/lib/module/components/Layout.js +24 -26
  24. package/lib/module/components/Layout.js.map +1 -1
  25. package/lib/module/components/Picker/Picker.js +281 -28
  26. package/lib/module/components/Picker/Picker.js.map +1 -1
  27. package/lib/module/components/useAuthState.js.map +1 -1
  28. package/lib/module/mappings/Picker.js +8 -2
  29. package/lib/module/mappings/Picker.js.map +1 -1
  30. package/lib/module/utilities.js +12 -1
  31. package/lib/module/utilities.js.map +1 -1
  32. package/lib/typescript/src/components/Picker/Picker.d.ts +28 -4
  33. package/lib/typescript/src/mappings/Picker.d.ts +21 -0
  34. package/lib/typescript/src/utilities.d.ts +7 -0
  35. package/package.json +2 -3
  36. package/src/components/Picker/Picker.js +227 -17
  37. package/src/components/Picker/Picker.tsx +416 -34
  38. package/src/mappings/Picker.js +3 -1
  39. package/src/mappings/Picker.ts +4 -0
  40. package/src/utilities.js +49 -1
  41. package/src/utilities.ts +65 -1
@@ -4,8 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.applyStyles = applyStyles;
7
+ exports.borderStyleNames = void 0;
8
+ exports.extractBorderAndMarginStyles = extractBorderAndMarginStyles;
7
9
  exports.extractStyles = extractStyles;
8
10
  exports.getValueForRadioButton = getValueForRadioButton;
11
+ exports.marginStyleNames = void 0;
9
12
 
10
13
  var _reactNative = require("react-native");
11
14
 
@@ -45,6 +48,22 @@ function extractStyles(style) {
45
48
  textStyles
46
49
  };
47
50
  }
51
+
52
+ const borderStyleNames = ["borderRadius", "borderBottomColor", "borderBottomEndRadius", "borderBottomLeftRadius", "borderBottomRightRadius", "borderBottomStartRadius", "borderBottomWidth", "borderColor", "borderEndColor", "borderLeftColor", "borderLeftWidth", "borderRadius", "borderRightColor", "borderRightWidth", "borderStartColor", "borderStyle", "borderTopColor", "borderTopEndRadius", "borderTopLeftRadius", "borderTopRightRadius", "borderTopStartRadius", "borderTopWidth", "borderWidth"];
53
+ exports.borderStyleNames = borderStyleNames;
54
+ const marginStyleNames = ["margin", "marginBottom", "marginEnd", "marginHorizontal", "marginLeft", "marginRight", "marginStart", "marginTop", "marginVertical"];
55
+ exports.marginStyleNames = marginStyleNames;
56
+
57
+ function extractBorderAndMarginStyles(style, additionalBorderStyles, additionalMarginStyles) {
58
+ const flatStyle = _reactNative.StyleSheet.flatten(style || {});
59
+
60
+ const borderStyles = (0, _lodash.pickBy)((0, _lodash.pick)(flatStyle, [...borderStyleNames, ...(additionalBorderStyles ? additionalBorderStyles : [])]), _lodash.identity);
61
+ const marginStyles = (0, _lodash.pickBy)((0, _lodash.pick)(flatStyle, [...marginStyleNames, ...(additionalMarginStyles ? additionalMarginStyles : [])]), _lodash.identity);
62
+ return {
63
+ borderStyles,
64
+ marginStyles
65
+ };
66
+ }
48
67
  /**
49
68
  * Merges a style object on top of another style object. In React Native,
50
69
  * keys with undefined values in a style object will still override styles
@@ -1 +1 @@
1
- {"version":3,"sources":["utilities.ts"],"names":["extractStyles","style","color","fontFamily","fontWeight","fontSize","lineHeight","letterSpacing","textTransform","textAlign","textDecorationLine","textDecorationColor","textDecorationStyle","viewStyles","StyleSheet","flatten","textStyles","applyStyles","baseStyles","stylesToApply","flattenedStyles","key","value","Object","entries","getValueForRadioButton","String","Error"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEO,SAASA,aAAT,CAAuBC,KAAvB,EAA8C;AACnD,QAAM;AACJC,IAAAA,KADI;AAEJC,IAAAA,UAFI;AAGJC,IAAAA,UAHI;AAIJC,IAAAA,QAJI;AAKJC,IAAAA,UALI;AAMJC,IAAAA,aANI;AAOJC,IAAAA,aAPI;AAQJC,IAAAA,SARI;AASJC,IAAAA,kBATI;AAUJC,IAAAA,mBAVI;AAWJC,IAAAA,mBAXI;AAYJ,OAAGC;AAZC,MAaFC,wBAAWC,OAAX,CAAmBd,KAAK,IAAI,EAA5B,CAbJ;;AAeA,QAAMe,UAAqB,GAAG;AAC5Bd,IAAAA,KAD4B;AAE5BC,IAAAA,UAF4B;AAG5BC,IAAAA,UAH4B;AAI5BC,IAAAA,QAJ4B;AAK5BC,IAAAA,UAL4B;AAM5BC,IAAAA,aAN4B;AAO5BC,IAAAA,aAP4B;AAQ5BC,IAAAA,SAR4B;AAS5BC,IAAAA,kBAT4B;AAU5BC,IAAAA,mBAV4B;AAW5BC,IAAAA;AAX4B,GAA9B;AAcA,SAAO;AAAEC,IAAAA,UAAF;AAAcG,IAAAA;AAAd,GAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,WAAT,CACLC,UADK,EAELC,aAFK,EAGL;AACA,MAAI,CAACA,aAAL,EAAoB;AAClB;AACD;;AAED,QAAMC,eAAe,GAAGN,wBAAWC,OAAX,CAAmBG,UAAnB,CAAxB;;AAEA,OAAK,MAAM,CAACG,GAAD,EAAMC,KAAN,CAAX,IAA2BC,MAAM,CAACC,OAAP,CAAeL,aAAf,CAA3B,EAA0D;AACxD,QAAIG,KAAK,IAAI,IAAb,EAAmB;AACjBF,MAAAA,eAAe,CAACC,GAAD,CAAf,GAAuBC,KAAvB;AACD;AACF;;AAED,SAAOF,eAAP;AACD;;AAEM,SAASK,sBAAT,CAAgCH,KAAhC,EAAwD;AAC7D,MAAI,sBAASA,KAAT,CAAJ,EAAqB;AACnB,WAAOA,KAAP;AACD,GAFD,MAEO,IAAI,sBAASA,KAAT,CAAJ,EAAqB;AAC1B,WAAOI,MAAM,CAACJ,KAAD,CAAb;AACD,GAFM,MAEA;AACL,UAAM,IAAIK,KAAJ,CAAW,kBAAiBL,KAAM,EAAlC,CAAN;AACD;AACF","sourcesContent":["import { StyleSheet, StyleProp, TextStyle } from \"react-native\";\nimport { isString, isNumber } from \"lodash\";\n\nexport function extractStyles(style: StyleProp<any>) {\n const {\n color,\n fontFamily,\n fontWeight,\n fontSize,\n lineHeight,\n letterSpacing,\n textTransform,\n textAlign,\n textDecorationLine,\n textDecorationColor,\n textDecorationStyle,\n ...viewStyles\n } = StyleSheet.flatten(style || {});\n\n const textStyles: TextStyle = {\n color,\n fontFamily,\n fontWeight,\n fontSize,\n lineHeight,\n letterSpacing,\n textTransform,\n textAlign,\n textDecorationLine,\n textDecorationColor,\n textDecorationStyle,\n };\n\n return { viewStyles, textStyles };\n}\n\n/**\n * Merges a style object on top of another style object. In React Native,\n * keys with undefined values in a style object will still override styles\n * that appear earlier in a sequence. This avoids that problem.\n *\n * This lets us avoid the `...(something ? { something } : {})` pattern.\n * There doesn't seem to be a better way to do this. These all seem to not\n * work (i.e. they all result in `{ color: undefined }`:\n * `const mergedStyles = [{ color: \"red\" }, { color: undefined }]`\n * `const mergedStyles = StyleSheet.compose({ color: \"red\" }, { color: undefined })`\n * `const mergedStyles = StyleSheet.flatten([{ color: \"red\" }, { color: undefined }])`\n */\nexport function applyStyles(\n baseStyles: Array<StyleProp<any>>,\n stylesToApply: StyleProp<any> | undefined\n) {\n if (!stylesToApply) {\n return;\n }\n\n const flattenedStyles = StyleSheet.flatten(baseStyles);\n\n for (const [key, value] of Object.entries(stylesToApply)) {\n if (value != null) {\n flattenedStyles[key] = value;\n }\n }\n\n return flattenedStyles;\n}\n\nexport function getValueForRadioButton(value: string | number) {\n if (isString(value)) {\n return value;\n } else if (isNumber(value)) {\n return String(value);\n } else {\n throw new Error(`Invalid value: ${value}`);\n }\n}\n"]}
1
+ {"version":3,"sources":["utilities.ts"],"names":["extractStyles","style","color","fontFamily","fontWeight","fontSize","lineHeight","letterSpacing","textTransform","textAlign","textDecorationLine","textDecorationColor","textDecorationStyle","viewStyles","StyleSheet","flatten","textStyles","borderStyleNames","marginStyleNames","extractBorderAndMarginStyles","additionalBorderStyles","additionalMarginStyles","flatStyle","borderStyles","identity","marginStyles","applyStyles","baseStyles","stylesToApply","flattenedStyles","key","value","Object","entries","getValueForRadioButton","String","Error"],"mappings":";;;;;;;;;;;;AAAA;;AACA;;AAEO,SAASA,aAAT,CAAuBC,KAAvB,EAA8C;AACnD,QAAM;AACJC,IAAAA,KADI;AAEJC,IAAAA,UAFI;AAGJC,IAAAA,UAHI;AAIJC,IAAAA,QAJI;AAKJC,IAAAA,UALI;AAMJC,IAAAA,aANI;AAOJC,IAAAA,aAPI;AAQJC,IAAAA,SARI;AASJC,IAAAA,kBATI;AAUJC,IAAAA,mBAVI;AAWJC,IAAAA,mBAXI;AAYJ,OAAGC;AAZC,MAaFC,wBAAWC,OAAX,CAAmBd,KAAK,IAAI,EAA5B,CAbJ;;AAeA,QAAMe,UAAqB,GAAG;AAC5Bd,IAAAA,KAD4B;AAE5BC,IAAAA,UAF4B;A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AAGJ,gBADW,EAEd,IAAIG,sBAAsB,GAAGA,sBAAH,GAA4B,EAAtD,CAFc,CAAhB,CADmB,EAKnBG,gBALmB,CAArB;AAQA,SAAO;AAAED,IAAAA,YAAF;AAAgBE,IAAAA;AAAhB,GAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,WAAT,CACLC,UADK,EAELC,aAFK,EAGL;AACA,MAAI,CAACA,aAAL,EAAoB;AAClB;AACD;;AAED,QAAMC,eAAe,GAAGf,wBAAWC,OAAX,CAAmBY,UAAnB,CAAxB;;AAEA,OAAK,MAAM,CAACG,GAAD,EAAMC,KAAN,CAAX,IAA2BC,MAAM,CAACC,OAAP,CAAeL,aAAf,CAA3B,EAA0D;AACxD,QAAIG,KAAK,IAAI,IAAb,EAAmB;AACjBF,MAAAA,eAAe,CAACC,GAAD,CAAf,GAAuBC,KAAvB;AACD;AACF;;AAED,SAAOF,eAAP;AACD;;AAEM,SAASK,sBAAT,CAAgCH,KAAhC,EAAwD;AAC7D,MAAI,sBAASA,KAAT,CAAJ,EAAqB;AACnB,WAAOA,KAAP;AACD,GAFD,MAEO,IAAI,sBAASA,KAAT,CAAJ,EAAqB;AAC1B,WAAOI,MAAM,CAACJ,KAAD,CAAb;AACD,GAFM,MAEA;AACL,UAAM,IAAIK,KAAJ,CAAW,kBAAiBL,KAAM,EAAlC,CAAN;AACD;AACF","sourcesContent":["import { StyleSheet, StyleProp, TextStyle } from \"react-native\";\nimport { isString, isNumber, pick, pickBy, identity } from \"lodash\";\n\nexport function extractStyles(style: StyleProp<any>) {\n const {\n color,\n fontFamily,\n fontWeight,\n fontSize,\n lineHeight,\n letterSpacing,\n textTransform,\n textAlign,\n textDecorationLine,\n textDecorationColor,\n textDecorationStyle,\n ...viewStyles\n } = StyleSheet.flatten(style || {});\n\n const textStyles: TextStyle = {\n color,\n fontFamily,\n fontWeight,\n fontSize,\n lineHeight,\n letterSpacing,\n textTransform,\n textAlign,\n textDecorationLine,\n textDecorationColor,\n textDecorationStyle,\n };\n\n return { viewStyles, textStyles };\n}\n\nexport const borderStyleNames = [\n \"borderRadius\",\n \"borderBottomColor\",\n \"borderBottomEndRadius\",\n \"borderBottomLeftRadius\",\n \"borderBottomRightRadius\",\n \"borderBottomStartRadius\",\n \"borderBottomWidth\",\n \"borderColor\",\n \"borderEndColor\",\n \"borderLeftColor\",\n \"borderLeftWidth\",\n \"borderRadius\",\n \"borderRightColor\",\n \"borderRightWidth\",\n \"borderStartColor\",\n \"borderStyle\",\n \"borderTopColor\",\n \"borderTopEndRadius\",\n \"borderTopLeftRadius\",\n \"borderTopRightRadius\",\n \"borderTopStartRadius\",\n \"borderTopWidth\",\n \"borderWidth\",\n];\n\nexport const marginStyleNames = [\n \"margin\",\n \"marginBottom\",\n \"marginEnd\",\n \"marginHorizontal\",\n \"marginLeft\",\n \"marginRight\",\n \"marginStart\",\n \"marginTop\",\n \"marginVertical\",\n];\n\nexport function extractBorderAndMarginStyles(\n style: StyleProp<any>,\n additionalBorderStyles?: string[],\n additionalMarginStyles?: string[]\n) {\n const flatStyle = StyleSheet.flatten(style || {});\n\n const borderStyles = pickBy(\n pick(flatStyle, [\n ...borderStyleNames,\n ...(additionalBorderStyles ? additionalBorderStyles : []),\n ]),\n identity\n );\n\n const marginStyles = pickBy(\n pick(flatStyle, [\n ...marginStyleNames,\n ...(additionalMarginStyles ? additionalMarginStyles : []),\n ]),\n identity\n );\n\n return { borderStyles, marginStyles };\n}\n\n/**\n * Merges a style object on top of another style object. In React Native,\n * keys with undefined values in a style object will still override styles\n * that appear earlier in a sequence. This avoids that problem.\n *\n * This lets us avoid the `...(something ? { something } : {})` pattern.\n * There doesn't seem to be a better way to do this. These all seem to not\n * work (i.e. they all result in `{ color: undefined }`:\n * `const mergedStyles = [{ color: \"red\" }, { color: undefined }]`\n * `const mergedStyles = StyleSheet.compose({ color: \"red\" }, { color: undefined })`\n * `const mergedStyles = StyleSheet.flatten([{ color: \"red\" }, { color: undefined }])`\n */\nexport function applyStyles(\n baseStyles: Array<StyleProp<any>>,\n stylesToApply: StyleProp<any> | undefined\n) {\n if (!stylesToApply) {\n return;\n }\n\n const flattenedStyles = StyleSheet.flatten(baseStyles);\n\n for (const [key, value] of Object.entries(stylesToApply)) {\n if (value != null) {\n flattenedStyles[key] = value;\n }\n }\n\n return flattenedStyles;\n}\n\nexport function getValueForRadioButton(value: string | number) {\n if (isString(value)) {\n return value;\n } else if (isNumber(value)) {\n return String(value);\n } else {\n throw new Error(`Invalid value: ${value}`);\n }\n}\n"]}
@@ -1,5 +1,3 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
1
  import * as React from "react";
4
2
  import { Pressable, StyleSheet, View } from "react-native";
5
3
  import Text from "../Text";
@@ -20,9 +18,10 @@ const AccordionItem = _ref => {
20
18
  textStyles,
21
19
  viewStyles
22
20
  } = extractStyles(style);
23
- return /*#__PURE__*/React.createElement(Pressable, _extends({
24
- style: [styles.container, viewStyles]
25
- }, rest), /*#__PURE__*/React.createElement(View, {
21
+ return /*#__PURE__*/React.createElement(Pressable, {
22
+ style: [styles.container, viewStyles],
23
+ ...rest
24
+ }, /*#__PURE__*/React.createElement(View, {
26
25
  style: styles.row
27
26
  }, icon ? /*#__PURE__*/React.createElement(Icon, {
28
27
  name: icon,
@@ -55,4 +54,22 @@ const styles = StyleSheet.create({
55
54
  }
56
55
  });
57
56
  export default withTheme(AccordionItem);
57
+ //# sourceMappingURL=AccordionItem.js.map container: {
58
+ padding: 8
59
+ },
60
+ row: {
61
+ flexDirection: "row",
62
+ alignItems: "center",
63
+ paddingLeft: 8
64
+ },
65
+ item: {
66
+ marginVertical: 6,
67
+ paddingLeft: 8
68
+ },
69
+ content: {
70
+ flex: 1,
71
+ justifyContent: "center"
72
+ }
73
+ });
74
+ export default withTheme(AccordionItem);
58
75
  //# sourceMappingURL=AccordionItem.js.map
@@ -1,5 +1,8 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
1
3
  import * as React from "react";
2
- import { View } from "react-native";
4
+ import { View } from "react-native"; // @ts-ignore
5
+
3
6
  export function Center(_ref) {
4
7
  let {
5
8
  width = 240,
@@ -9,16 +12,15 @@ export function Center(_ref) {
9
12
  style,
10
13
  ...rest
11
14
  } = _ref;
12
- return /*#__PURE__*/React.createElement(View, {
15
+ return /*#__PURE__*/React.createElement(View, _extends({
13
16
  style: [{
14
17
  justifyContent: "center",
15
18
  alignItems: "center",
16
19
  width,
17
20
  height,
18
21
  backgroundColor: bgColor
19
- }, style],
20
- ...rest
21
- }, children);
22
+ }, style]
23
+ }, rest), children);
22
24
  }
23
25
  export function Circle(_ref2) {
24
26
  let {
@@ -29,7 +31,7 @@ export function Circle(_ref2) {
29
31
  ...rest
30
32
  } = _ref2;
31
33
  const borderRadius = 1000;
32
- return /*#__PURE__*/React.createElement(Center, {
34
+ return /*#__PURE__*/React.createElement(Center, _extends({
33
35
  width: size,
34
36
  height: size,
35
37
  bgColor: bgColor,
@@ -37,9 +39,8 @@ export function Circle(_ref2) {
37
39
  backgroundColor: bgColor,
38
40
  borderRadius,
39
41
  overflow: "hidden"
40
- }],
41
- ...rest
42
- }, children);
42
+ }]
43
+ }, rest), children);
43
44
  }
44
45
  export function Square(_ref3) {
45
46
  let {
@@ -49,13 +50,12 @@ export function Square(_ref3) {
49
50
  style,
50
51
  ...rest
51
52
  } = _ref3;
52
- return /*#__PURE__*/React.createElement(Center, {
53
+ return /*#__PURE__*/React.createElement(Center, _extends({
53
54
  style: style,
54
55
  width: size,
55
56
  height: size,
56
- bgColor: bgColor,
57
- ...rest
58
- }, children);
57
+ bgColor: bgColor
58
+ }, rest), children);
59
59
  }
60
60
  export function Row(_ref4) {
61
61
  let {
@@ -65,14 +65,14 @@ export function Row(_ref4) {
65
65
  style,
66
66
  ...rest
67
67
  } = _ref4;
68
- return /*#__PURE__*/React.createElement(View, {
69
- style: [style, {
68
+ return /*#__PURE__*/React.createElement(View, _extends({
69
+ style: [style, // style goes first b/c we can't override these
70
+ {
70
71
  alignItems,
71
72
  flexDirection: "row",
72
73
  justifyContent: justifyContent
73
- }],
74
- ...rest
75
- }, children);
74
+ }]
75
+ }, rest), children);
76
76
  }
77
77
  export function Spacer(_ref5) {
78
78
  let {
@@ -84,15 +84,14 @@ export function Spacer(_ref5) {
84
84
  style,
85
85
  ...rest
86
86
  } = _ref5;
87
- return /*#__PURE__*/React.createElement(View, {
87
+ return /*#__PURE__*/React.createElement(View, _extends({
88
88
  style: [style, {
89
89
  paddingRight: right,
90
90
  paddingTop: top,
91
91
  paddingLeft: left,
92
92
  paddingBottom: bottom
93
- }],
94
- ...rest
95
- }, children);
93
+ }]
94
+ }, rest), children);
96
95
  }
97
96
  export function Stack(_ref6) {
98
97
  let {
@@ -105,13 +104,12 @@ export function Stack(_ref6) {
105
104
  return (
106
105
  /*#__PURE__*/
107
106
  // style must go first since we don't want justifyContent, alignItems overridden
108
- React.createElement(View, {
107
+ React.createElement(View, _extends({
109
108
  style: [style, {
110
109
  justifyContent,
111
110
  alignItems
112
- }],
113
- ...rest
114
- }, children)
111
+ }]
112
+ }, rest), children)
115
113
  );
116
114
  }
117
115
  //# sourceMappingURL=Layout.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["Layout.js"],"names":["React","View","Center","width","height","children","bgColor","style","rest","createElement","justifyContent","alignItems","backgroundColor","Circle","size","borderRadius","overflow","Square","Row","flexDirection","Spacer","top","right","bottom","left","paddingRight","paddingTop","paddingLeft","paddingBottom","Stack"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,Q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1B,EAQUH,QARV,CAAR;AASH;AACD,OAAO,SAASwB,KAAT,QAAuG;AAAA,MAAxF;AAAExB,IAAAA,QAAF;AAAYK,IAAAA,cAAc,GAAG,YAA7B;AAA2CC,IAAAA,UAAU,GAAG,YAAxD;AAAsEJ,IAAAA,KAAtE;AAA6E,OAAGC;AAAhF,GAAwF;AAC1G;AAAA;AACA;AACAR,IAAAA,KAAK,CAACS,aAAN,CAAoBR,IAApB,EAA0B;AAAEM,MAAAA,KAAK,EAAE,CAACA,KAAD,EAAQ;AAAEG,QAAAA,cAAF;AAAkBC,QAAAA;AAAlB,OAAR,CAAT;AAAkD,SAAGH;AAArD,KAA1B,EAAuFH,QAAvF;AAFA;AAGH","sourcesContent":["import * as React from \"react\";\nimport { View } from \"react-native\";\nexport function Center({ width = 240, height = 200, children, bgColor, style, ...rest }) {\n return (React.createElement(View, { style: [\n {\n justifyContent: \"center\",\n alignItems: \"center\",\n width,\n height,\n backgroundColor: bgColor,\n },\n style,\n ], ...rest }, children));\n}\nexport function Circle({ size = 50, bgColor, children, style, ...rest }) {\n const borderRadius = 1000;\n return (React.createElement(Center, { width: size, height: size, bgColor: bgColor, style: [\n style,\n { backgroundColor: bgColor, borderRadius, overflow: \"hidden\" },\n ], ...rest }, children));\n}\nexport function Square({ size = 50, bgColor, children, style, ...rest }) {\n return (React.createElement(Center, { style: style, width: size, height: size, bgColor: bgColor, ...rest }, children));\n}\nexport function Row({ justifyContent, alignItems, children, style, ...rest }) {\n return (React.createElement(View, { style: [\n style,\n {\n alignItems,\n flexDirection: \"row\",\n justifyContent: justifyContent,\n },\n ], ...rest }, children));\n}\nexport function Spacer({ top = 8, right = 8, bottom = 8, left = 8, children, style, ...rest }) {\n return (React.createElement(View, { style: [\n style,\n {\n paddingRight: right,\n paddingTop: top,\n paddingLeft: left,\n paddingBottom: bottom,\n },\n ], ...rest }, children));\n}\nexport function Stack({ children, justifyContent = \"flex-start\", alignItems = \"flex-start\", style, ...rest }) {\n return (\n // style must go first since we don't want justifyContent, alignItems overridden\n React.createElement(View, { style: [style, { justifyContent, alignItems }], ...rest }, children));\n}\n"]}
1
+ {"version":3,"sources":["Layout.tsx"],"names":["React","View","Center","width","height","children","bgColor","style","rest","justifyContent","alignItems","backgroundColor","Circle","size","borderRadius","overflow","Square","Row","flexDirection","Spacer","top","right","bottom","left","paddingRight","paddingTop","paddingLeft","paddingBottom","Stack"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,QAA2C,cAA3C,C,CACA;;AAGA,OAAO,SAASC,MAAT,OAaJ;AAAA,MAboB;AACrBC,IAAAA,KAAK,GAAG,GADa;AAErBC,IAAAA,MAAM,GAAG,GAFY;AAGrBC,IAAAA,QAHqB;AAIrBC,IAAAA,OAJqB;AAKrBC,IAAAA,KALqB;AAMrB,OAAGC;AANkB,GAapB;AACD,sBACE,oBAAC,IAAD;AACE,IAAA,KAAK,EAAE,CACL;AACEC,MAAAA,cAAc,EAAE,QADlB;AAEEC,MAAAA,UAAU,EAAE,QAFd;AAGEP,MAAAA,KAHF;AAIEC,MAAAA,MAJF;AAKEO,MAAAA,eAAe,EAAEL;AALnB,KADK,EAQLC,KARK;AADT,KAWMC,IAXN,GAaGH,QAbH,CADF;AAiBD;AAED,OAAO,SAASO,MAAT,QAWJ;AAAA,MAXoB;AACrBC,IAAAA,IAAI,GAAG,EADc;AAErBP,IAAAA,OAFqB;AAGrBD,IAAAA,QAHqB;AAIrBE,IAAAA,KAJqB;AAKrB,OAAGC;AALkB,GAWpB;AACD,QAAMM,YAAY,GAAG,IAArB;AACA,sBACE,oBAAC,MAAD;AACE,IAAA,KAAK,EAAED,IADT;AAEE,IAAA,MAAM,EAAEA,IAFV;AAGE,IAAA,OAAO,EAAEP,OAHX;AAIE,IAAA,KAAK,EAAE,CACLC,KADK,EAEL;AAAEI,MAAAA,eAAe,EAAEL,OAAnB;AAA4BQ,MAAAA,YAA5B;AAA0CC,MAAAA,QAAQ,EAAE;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GAYGH,QAZH,CADF;AAgBD;AAED,OAAO,SAASuB,KAAT,QAWJ;AAAA,MAXmB;AACpBvB,IAAAA,QADoB;AAEpBI,IAAAA,cAAc,GAAG,YAFG;AAGpBC,IAAAA,UAAU,GAAG,YAHO;AAIpBH,IAAAA,KAJoB;AAKpB,OAAGC;AALiB,GAWnB;AACD;AAAA;AACE;AACA,wBAAC,IAAD;AAAM,MAAA,KAAK,EAAE,CAACD,KAAD,EAAQ;AAAEE,QAAAA,cAAF;AAAkBC,QAAAA;AAAlB,OAAR;AAAb,OAA0DF,IAA1D,GACGH,QADH;AAFF;AAMD","sourcesContent":["import * as React from \"react\";\nimport { View, StyleProp, ViewStyle } from \"react-native\";\n// @ts-ignore\nimport type { ViewStyleProp } from \"react-native/Libraries/StyleSheet/StyleSheet\";\n\nexport function Center({\n width = 240,\n height = 200,\n children,\n bgColor,\n style,\n ...rest\n}: {\n width: number;\n height: number;\n bgColor: string;\n children: React.ReactNode;\n style?: StyleProp<ViewStyle>;\n}) {\n return (\n <View\n style={[\n {\n justifyContent: \"center\",\n alignItems: \"center\",\n width,\n height,\n backgroundColor: bgColor,\n },\n style,\n ]}\n {...rest}\n >\n {children}\n </View>\n );\n}\n\nexport function Circle({\n size = 50,\n bgColor,\n children,\n style,\n ...rest\n}: {\n size: number;\n bgColor: string;\n children: React.ReactNode;\n style?: StyleProp<ViewStyle>;\n}) {\n const borderRadius = 1000;\n return (\n <Center\n width={size}\n height={size}\n bgColor={bgColor}\n style={[\n style,\n { backgroundColor: bgColor, borderRadius, overflow: \"hidden\" },\n ]}\n {...rest}\n >\n {children}\n </Center>\n );\n}\n\nexport function Square({\n size = 50,\n bgColor,\n children,\n style,\n ...rest\n}: {\n size: number;\n bgColor: string;\n children: React.ReactNode;\n style?: StyleProp<ViewStyle>;\n}) {\n return (\n <Center\n style={style}\n width={size}\n height={size}\n bgColor={bgColor}\n {...rest}\n >\n {children}\n </Center>\n );\n}\n\nexport function Row({\n justifyContent,\n alignItems,\n children,\n style,\n ...rest\n}: {\n alignItems: ViewStyleProp.alignItems;\n justifyContent: ViewStyleProp.justifyContent;\n children: React.ReactNode;\n style?: StyleProp<ViewStyle>;\n}) {\n return (\n <View\n style={[\n style, // style goes first b/c we can't override these\n {\n alignItems,\n flexDirection: \"row\",\n justifyContent: justifyContent,\n },\n ]}\n {...rest}\n >\n {children}\n </View>\n );\n}\n\nexport function Spacer({\n top = 8,\n right = 8,\n bottom = 8,\n left = 8,\n children,\n style,\n ...rest\n}: {\n top?: number;\n right?: number;\n left?: number;\n bottom?: number;\n children: React.ReactNode;\n style?: StyleProp<ViewStyle>;\n}) {\n return (\n <View\n style={[\n style,\n {\n paddingRight: right,\n paddingTop: top,\n paddingLeft: left,\n paddingBottom: bottom,\n },\n ]}\n {...rest}\n >\n {children}\n </View>\n );\n}\n\nexport function Stack({\n children,\n justifyContent = \"flex-start\",\n alignItems = \"flex-start\",\n style,\n ...rest\n}: {\n justifyContent: ViewStyleProp.justifyContent;\n alignItems: ViewStyleProp.alignItems;\n children: React.ReactNode;\n style?: StyleProp<ViewStyle>;\n}) {\n return (\n // style must go first since we don't want justifyContent, alignItems overridden\n <View style={[style, { justifyContent, alignItems }]} {...rest}>\n {children}\n </View>\n );\n}\n"]}
@@ -1,26 +1,30 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
1
  import * as React from "react";
4
- import { withTheme } from "../../theming"; //@ts-ignore
5
-
6
- import PickerComponent from "./PickerComponent"; //unable to find file due to using .android/.web/.ios
2
+ import { View, StyleSheet, Text, Platform, Dimensions } from "react-native";
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";
6
+ import { withTheme } from "../../theming";
7
+ import Portal from "../Portal/Portal";
8
+ import Button from "../DeprecatedButton";
9
+ import Touchable from "../Touchable";
10
+ import { extractStyles, extractBorderAndMarginStyles, borderStyleNames, marginStyleNames } from "../../utilities";
7
11
 
8
12
  function normalizeOptions(options) {
9
13
  if (options.length === 0) {
10
14
  return [];
11
15
  }
12
16
 
13
- if (typeof options[0] === "string") {
17
+ if (typeof options[0] === ("string" || "number")) {
14
18
  return options.map(option => ({
15
- label: option,
19
+ label: String(option),
16
20
  value: String(option)
17
21
  }));
18
22
  }
19
23
 
20
- if (options[0].label && options[0].value) {
24
+ if (isObject(options[0]) && options[0].value !== null && options[0].label !== null) {
21
25
  return options.map(option => {
22
26
  return {
23
- label: option.label,
27
+ label: String(option.label),
24
28
  value: String(option.value)
25
29
  };
26
30
  });
@@ -29,16 +33,47 @@ function normalizeOptions(options) {
29
33
  throw new Error('Picker options must be either an array of strings or array of { "label": string; "value": string; } objects.');
30
34
  }
31
35
 
36
+ const {
37
+ width: deviceWidth,
38
+ height: deviceHeight
39
+ } = Dimensions.get("screen");
40
+ const isIos = Platform.OS === "ios";
41
+ const unstyledColor = "rgba(165, 173, 183, 1)";
42
+ const disabledColor = "rgb(240, 240, 240)";
43
+ const errorColor = "rgba(255, 69, 100, 1)";
44
+
32
45
  const Picker = _ref => {
46
+ var _find$label, _find;
47
+
33
48
  let {
49
+ error,
34
50
  options = [],
51
+ onValueChange,
52
+ defaultValue,
53
+ Icon,
54
+ style,
35
55
  placeholder,
36
- onValueChange: onValueChangeOverride,
37
56
  value,
38
- defaultValue,
39
- ...props
57
+ disabled = false,
58
+ theme,
59
+ assistiveText,
60
+ label,
61
+ iconColor = unstyledColor,
62
+ iconSize = 24,
63
+ leftIconMode = "inset",
64
+ leftIconName,
65
+ placeholderTextColor = unstyledColor,
66
+ rightIconName,
67
+ type = "solid"
40
68
  } = _ref;
69
+ const androidPickerRef = React.useRef(undefined);
41
70
  const [internalValue, setInternalValue] = React.useState(value || defaultValue);
71
+ const [pickerVisible, setPickerVisible] = React.useState(false);
72
+
73
+ const togglePickerVisible = () => {
74
+ setPickerVisible(!pickerVisible);
75
+ };
76
+
42
77
  React.useEffect(() => {
43
78
  if (value != null) {
44
79
  setInternalValue(value);
@@ -49,34 +84,252 @@ const Picker = _ref => {
49
84
  setInternalValue(defaultValue);
50
85
  }
51
86
  }, [defaultValue]);
52
- const onValueChange = React.useCallback((itemValue, itemIndex) => {
53
- if (placeholder && itemIndex === 0) {
54
- return;
55
- }
87
+ React.useEffect(() => {
88
+ if (pickerVisible && androidPickerRef.current) {
89
+ var _androidPickerRef$cur;
56
90
 
57
- onValueChangeOverride && onValueChangeOverride(String(itemValue), itemIndex);
58
- }, [placeholder, onValueChangeOverride]);
91
+ androidPickerRef === null || androidPickerRef === void 0 ? void 0 : (_androidPickerRef$cur = androidPickerRef.current) === null || _androidPickerRef$cur === void 0 ? void 0 : _androidPickerRef$cur.focus();
92
+ }
93
+ }, [pickerVisible, androidPickerRef]);
59
94
  const normalizedOptions = normalizeOptions(options);
60
95
  const pickerOptions = placeholder ? [{
61
96
  value: placeholder,
62
97
  label: placeholder
63
98
  }, ...normalizedOptions] : normalizedOptions;
99
+ const {
100
+ colors
101
+ } = theme;
102
+ const {
103
+ viewStyles,
104
+ textStyles
105
+ } = extractStyles(style);
106
+ const additionalBorderStyles = ["backgroundColor"];
107
+ const additionalMarginStyles = ["bottom", "height", "left", "maxHeight", "maxWidth", "minHeight", "minWidth", "overflow", "position", "right", "top", "width", "zIndex"];
108
+ const {
109
+ borderStyles: extractedBorderStyles,
110
+ marginStyles: extractedMarginStyles
111
+ } = extractBorderAndMarginStyles(viewStyles, additionalBorderStyles, additionalMarginStyles);
112
+ const borderStyles = { ...{ ...(type === "solid" ? {
113
+ borderTopLeftRadius: 5,
114
+ borderTopRightRadius: 5,
115
+ borderBottomRightRadius: 5,
116
+ borderBottomLeftRadius: 5,
117
+ borderTopWidth: 1,
118
+ borderRightWidth: 1,
119
+ borderLeftWidth: 1
120
+ } : {}),
121
+ borderBottomWidth: 1,
122
+ borderColor: unstyledColor,
123
+ borderStyle: "solid"
124
+ },
125
+ ...extractedBorderStyles,
126
+ ...(error ? {
127
+ borderColor: errorColor
128
+ } : {}),
129
+ ...(disabled ? {
130
+ borderColor: "transparent",
131
+ backgroundColor: disabledColor
132
+ } : {})
133
+ };
134
+ const marginStyles = {
135
+ height: 60,
136
+ ...extractedMarginStyles
137
+ };
138
+ const stylesWithoutBordersAndMargins = omit(viewStyles, [...borderStyleNames, ...marginStyleNames, ...additionalBorderStyles, ...additionalMarginStyles]);
139
+ const selectedLabel = internalValue && ((_find$label = (_find = pickerOptions.find(option => option.value === internalValue)) === null || _find === void 0 ? void 0 : _find.label) !== null && _find$label !== void 0 ? _find$label : internalValue);
140
+ const labelText = label ? /*#__PURE__*/React.createElement(Text, {
141
+ style: {
142
+ textAlign: textStyles.textAlign,
143
+ color: unstyledColor,
144
+ fontSize: 12,
145
+ paddingBottom: 4
146
+ }
147
+ }, label) : null;
148
+ const leftIconOutset = leftIconMode === "outset";
149
+ const leftIcon = leftIconName ? /*#__PURE__*/React.createElement(Icon, {
150
+ name: leftIconName,
151
+ color: disabled ? unstyledColor : iconColor,
152
+ size: iconSize,
153
+ style: {
154
+ marginRight: 4,
155
+ marginLeft: 4
156
+ }
157
+ }) : null;
158
+ const rightIcon = rightIconName ? /*#__PURE__*/React.createElement(Icon, {
159
+ name: rightIconName,
160
+ color: disabled ? unstyledColor : iconColor,
161
+ size: iconSize,
162
+ style: {
163
+ marginRight: -10,
164
+ marginLeft: 8
165
+ }
166
+ }) : null;
167
+ const textAlign = textStyles === null || textStyles === void 0 ? void 0 : textStyles.textAlign;
64
168
 
65
- const handleValueChange = (newValue, itemIndex) => {
66
- setInternalValue(newValue);
169
+ const calculateLeftPadding = () => {
170
+ if (leftIconOutset) {
171
+ if (textAlign === "center") {
172
+ return iconSize - Math.abs(8 - iconSize);
173
+ }
174
+
175
+ return iconSize + 8;
176
+ }
177
+
178
+ return 0;
179
+ };
67
180
 
68
- if (onValueChange) {
69
- onValueChange(newValue, itemIndex);
181
+ const assistiveTextLabel = assistiveText ? /*#__PURE__*/React.createElement(Text, {
182
+ style: {
183
+ textAlign,
184
+ width: "100%",
185
+ paddingLeft: calculateLeftPadding(),
186
+ color: unstyledColor,
187
+ fontSize: 12,
188
+ paddingTop: 4
70
189
  }
190
+ }, assistiveText) : null;
191
+ const primaryTextStyle = {
192
+ color: unstyledColor,
193
+ fontSize: 14,
194
+ ...pickBy(textStyles, identity),
195
+ ...(placeholder === internalValue ? {
196
+ color: placeholderTextColor
197
+ } : {}),
198
+ ...(disabled ? {
199
+ color: unstyledColor
200
+ } : {})
71
201
  };
72
202
 
73
- return /*#__PURE__*/React.createElement(PickerComponent, _extends({}, props, {
74
- selectedValue: String(internalValue),
75
- placeholder: placeholder,
76
- options: pickerOptions,
77
- onValueChange: handleValueChange
78
- }));
203
+ const handleValueChange = (newValue, itemIndex) => {
204
+ if (!placeholder || itemIndex > 0) {
205
+ onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue, itemIndex);
206
+ }
207
+
208
+ setInternalValue(newValue);
209
+ };
210
+
211
+ return (
212
+ /*#__PURE__*/
213
+
214
+ /* marginsContainer */
215
+ React.createElement(View, {
216
+ style: [styles.marginsContainer, marginStyles]
217
+ }, /*#__PURE__*/React.createElement(Touchable, {
218
+ disabled: disabled,
219
+ onPress: togglePickerVisible,
220
+ style: styles.touchableContainer
221
+ }, /*#__PURE__*/React.createElement(View, {
222
+ pointerEvents: "none",
223
+ style: [styles.outsetContainer, stylesWithoutBordersAndMargins, !leftIconOutset ? borderStyles : {}]
224
+ }, leftIcon, /*#__PURE__*/React.createElement(View, {
225
+ style: [styles.insetContainer, leftIconOutset ? borderStyles : {}]
226
+ }, /*#__PURE__*/React.createElement(View, {
227
+ style: styles.primaryTextContainer
228
+ }, labelText, /*#__PURE__*/React.createElement(Text, {
229
+ style: primaryTextStyle
230
+ }, String(selectedLabel !== null && selectedLabel !== void 0 ? selectedLabel : placeholder))), rightIcon)), assistiveTextLabel), isIos && pickerVisible ? /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(View, {
231
+ style: [styles.iosPicker, {
232
+ backgroundColor: colors.divider
233
+ }]
234
+ }, /*#__PURE__*/React.createElement(SafeAreaView, {
235
+ style: styles.iosSafeArea
236
+ }, /*#__PURE__*/React.createElement(Button, {
237
+ Icon: Icon,
238
+ type: "text",
239
+ onPress: togglePickerVisible,
240
+ style: styles.iosButton
241
+ }, "Close"), /*#__PURE__*/React.createElement(NativePicker, {
242
+ style: styles.iosNativePicker,
243
+ selectedValue: internalValue,
244
+ onValueChange: handleValueChange
245
+ }, pickerOptions.map(option => /*#__PURE__*/React.createElement(NativePicker.Item, {
246
+ label: option.label,
247
+ value: option.value,
248
+ key: option.value
249
+ })))))) : null, !isIos && pickerVisible ? /*#__PURE__*/React.createElement(NativePicker, {
250
+ enabled: pickerVisible,
251
+ selectedValue: internalValue,
252
+ onValueChange: handleValueChange,
253
+ style: styles.nonIosPicker,
254
+ ref: androidPickerRef,
255
+ onBlur: () => setPickerVisible(false)
256
+ }, pickerOptions.map(option => /*#__PURE__*/React.createElement(NativePicker.Item, {
257
+ label: option.label,
258
+ value: option.value,
259
+ key: option.value
260
+ }))) : null)
261
+ );
79
262
  };
80
263
 
81
264
  export default withTheme(Picker);
265
+ const styles = StyleSheet.create({
266
+ marginsContainer: {
267
+ alignSelf: "stretch",
268
+ alignItems: "center",
269
+ width: "100%",
270
+ maxWidth: deviceWidth
271
+ },
272
+ touchableContainer: {
273
+ flex: 1,
274
+ height: "100%",
275
+ width: "100%",
276
+ alignSelf: "stretch",
277
+ alignItems: "center"
278
+ },
279
+ outsetContainer: {
280
+ flex: 1,
281
+ height: "100%",
282
+ width: "100%",
283
+ flexDirection: "row",
284
+ alignItems: "center",
285
+ justifyContent: "space-between"
286
+ },
287
+ insetContainer: {
288
+ flex: 1,
289
+ height: "100%",
290
+ width: "100%",
291
+ flexDirection: "row",
292
+ alignItems: "center",
293
+ justifyContent: "space-between",
294
+ paddingLeft: 12,
295
+ paddingRight: 12
296
+ },
297
+ primaryTextContainer: {
298
+ flex: 1
299
+ },
300
+ iosPicker: {
301
+ position: "absolute",
302
+ bottom: 0,
303
+ left: 0,
304
+ right: 0,
305
+ flexDirection: "row",
306
+ justifyContent: "center",
307
+ width: "100%",
308
+ maxWidth: deviceWidth,
309
+ maxHeight: deviceHeight
310
+ },
311
+ iosSafeArea: {
312
+ backgroundColor: "white",
313
+ flexDirection: "column",
314
+ width: "100%",
315
+ maxWidth: deviceWidth
316
+ },
317
+ iosButton: {
318
+ alignSelf: "flex-end"
319
+ },
320
+ iosNativePicker: {
321
+ backgroundColor: "white"
322
+ },
323
+ nonIosPicker: {
324
+ opacity: 0,
325
+ position: "absolute",
326
+ top: 0,
327
+ left: 0,
328
+ right: 0,
329
+ bottom: 0,
330
+ width: "100%",
331
+ maxWidth: deviceWidth,
332
+ maxHeight: deviceHeight
333
+ }
334
+ });
82
335
  //# sourceMappingURL=Picker.js.map