@draftbit/core 43.2.4-aa029f.0 → 43.2.5-da45ce.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 (59) hide show
  1. package/lib/commonjs/components/DeprecatedCardWrapper.js +2 -14
  2. package/lib/commonjs/components/DeprecatedCardWrapper.js.map +1 -1
  3. package/lib/commonjs/components/DeprecatedFAB.js +20 -4
  4. package/lib/commonjs/components/DeprecatedFAB.js.map +1 -1
  5. package/lib/commonjs/components/Divider.js +13 -3
  6. package/lib/commonjs/components/Divider.js.map +1 -1
  7. package/lib/commonjs/components/NumberInput.js +25 -17
  8. package/lib/commonjs/components/NumberInput.js.map +1 -1
  9. package/lib/commonjs/index.js +0 -14
  10. package/lib/commonjs/index.js.map +1 -1
  11. package/lib/commonjs/mappings/FAB.js +1 -1
  12. package/lib/commonjs/mappings/FAB.js.map +1 -1
  13. package/lib/module/components/Accordion/AccordionItem.js +5 -22
  14. package/lib/module/components/Header.js.map +1 -1
  15. package/lib/module/components/NumberInput.js +27 -19
  16. package/lib/module/components/NumberInput.js.map +1 -1
  17. package/lib/module/index.js +0 -1
  18. package/lib/module/index.js.map +1 -1
  19. package/lib/module/mappings/FAB.js +1 -1
  20. package/lib/module/mappings/FAB.js.map +1 -1
  21. package/lib/module/mappings/MapMarker.js.map +1 -1
  22. package/lib/typescript/src/components/NumberInput.d.ts +2 -1
  23. package/lib/typescript/src/index.d.ts +0 -1
  24. package/lib/typescript/src/mappings/FAB.d.ts +1 -1
  25. package/package.json +3 -5
  26. package/src/components/NumberInput.js +19 -14
  27. package/src/components/NumberInput.tsx +28 -19
  28. package/src/index.js +0 -1
  29. package/src/index.tsx +0 -1
  30. package/src/mappings/FAB.js +1 -1
  31. package/src/mappings/FAB.ts +1 -1
  32. package/lib/commonjs/components/TabView/TabView.js +0 -103
  33. package/lib/commonjs/components/TabView/TabView.js.map +0 -1
  34. package/lib/commonjs/components/TabView/TabViewItem.js +0 -27
  35. package/lib/commonjs/components/TabView/TabViewItem.js.map +0 -1
  36. package/lib/commonjs/components/TabView/index.js +0 -24
  37. package/lib/commonjs/components/TabView/index.js.map +0 -1
  38. package/lib/commonjs/mappings/TabView.js +0 -80
  39. package/lib/commonjs/mappings/TabView.js.map +0 -1
  40. package/lib/module/components/TabView/TabView.js +0 -88
  41. package/lib/module/components/TabView/TabView.js.map +0 -1
  42. package/lib/module/components/TabView/TabViewItem.js +0 -19
  43. package/lib/module/components/TabView/TabViewItem.js.map +0 -1
  44. package/lib/module/components/TabView/index.js +0 -3
  45. package/lib/module/components/TabView/index.js.map +0 -1
  46. package/lib/module/mappings/TabView.js +0 -71
  47. package/lib/module/mappings/TabView.js.map +0 -1
  48. package/lib/typescript/src/components/TabView/TabView.d.ts +0 -19
  49. package/lib/typescript/src/components/TabView/TabViewItem.d.ts +0 -10
  50. package/lib/typescript/src/components/TabView/index.d.ts +0 -2
  51. package/lib/typescript/src/mappings/TabView.d.ts +0 -111
  52. package/src/components/TabView/TabView.js +0 -33
  53. package/src/components/TabView/TabView.tsx +0 -97
  54. package/src/components/TabView/TabViewItem.js +0 -5
  55. package/src/components/TabView/TabViewItem.tsx +0 -21
  56. package/src/components/TabView/index.js +0 -2
  57. package/src/components/TabView/index.ts +0 -2
  58. package/src/mappings/TabView.js +0 -73
  59. package/src/mappings/TabView.ts +0 -80
@@ -1 +1 @@
1
- {"version":3,"sources":["MapMarker.js"],"names":["COMPONENT_TYPES","createBoolProp","createColorProp","createNumberProp","createTextProp","GROUPS","SEED_DATA","name","tag","description","category","deprecated","layout","props","latitude","label","required","precision","min","max","longitude","title","defaultValue","flat","group","basic","pinColor"],"mappings":"AAAA,SAASA,eAAT,EAA0BC,cAA1B,EAA0CC,eAA1C,EAA2DC,gBAA3D,EAA6EC,cAA7E,EAA6FC,MAA7F,QAA4G,iBAA5G;AACA,OAAO,MAAMC,SAAS,GAAG;AACrBC,EAAAA,IAAI,EAAE,YADe;AAErBC,EAAAA,GAAG,EAA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CAAC;AACtBa,MAAAA,KAAK,EAAE,WADe;AAEtBN,MAAAA,WAAW,EAAE;AAFS,KAAD;AAjCtB;AANc,CAAlB","sourcesContent":["import { COMPONENT_TYPES, createBoolProp, createColorProp, createNumberProp, createTextProp, GROUPS, } from \"@draftbit/types\";\nexport const SEED_DATA = {\n name: \"Map Marker\",\n tag: \"MapMarker\",\n description: \"A marker to show inside map view\",\n category: COMPONENT_TYPES.deprecated,\n layout: {},\n props: {\n latitude: createNumberProp({\n label: \"Latitude\",\n description: \"The latitude in which the marker is located\",\n required: true,\n precision: 6,\n min: -90,\n max: 90,\n }),\n longitude: createNumberProp({\n label: \"Longitude\",\n description: \"The longitude in which the marker is located\",\n required: true,\n precision: 6,\n min: -180,\n max: 180,\n }),\n title: createTextProp({\n label: \"Title\",\n description: \"Title to show along with the marker\",\n defaultValue: null,\n }),\n description: createTextProp({\n label: \"Description\",\n description: \"Optional description for the marker\",\n defaultValue: null,\n }),\n flat: createBoolProp({\n label: \"Flat\",\n description: \"Sets whether this marker should be flat against the map (if true) or a billboard facing the camera (if false)\",\n group: GROUPS.basic,\n defaultValue: false,\n }),\n pinColor: createColorProp({\n label: \"Pin Color\",\n description: \"Sets the color of the marker\",\n }),\n },\n};\n"]}
1
+ {"version":3,"sources":["MapMarker.ts"],"names":["COMPONENT_TYPES","createBoolProp","createColorProp","createNumberProp","createTextProp","GROUPS","SEED_DATA","name","tag","description","category","deprecated","layout","props","latitude","label","required","precision","min","max","longitude","title","defaultValue","flat","group","basic","pinColor"],"mappings":"AAAA,SACEA,eADF,EAEEC,cAFF,EAGEC,eAHF,EAIEC,gBAJF,EAKEC,cALF,EAMEC,MANF,QAOO,iBAPP;AASA,OAAO,MAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,YADiB;AAEvBC,EAAAA,GAAG,EAAE,WAFkB;AAGvBC,EAAAA,WAAW,EAAE,kCAHU;AAIvBC,EAAAA,QAAQ,EAAEV,eAAe,CAACW,UAJH;AAKvBC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lB","sourcesContent":["import {\n COMPONENT_TYPES,\n createBoolProp,\n createColorProp,\n createNumberProp,\n createTextProp,\n GROUPS,\n} from \"@draftbit/types\";\n\nexport const SEED_DATA = {\n name: \"Map Marker\",\n tag: \"MapMarker\",\n description: \"A marker to show inside map view\",\n category: COMPONENT_TYPES.deprecated,\n layout: {},\n props: {\n latitude: createNumberProp({\n label: \"Latitude\",\n description: \"The latitude in which the marker is located\",\n required: true,\n precision: 6,\n min: -90,\n max: 90,\n }),\n longitude: createNumberProp({\n label: \"Longitude\",\n description: \"The longitude in which the marker is located\",\n required: true,\n precision: 6,\n min: -180,\n max: 180,\n }),\n title: createTextProp({\n label: \"Title\",\n description: \"Title to show along with the marker\",\n defaultValue: null,\n }),\n description: createTextProp({\n label: \"Description\",\n description: \"Optional description for the marker\",\n defaultValue: null,\n }),\n flat: createBoolProp({\n label: \"Flat\",\n description:\n \"Sets whether this marker should be flat against the map (if true) or a billboard facing the camera (if false)\",\n group: GROUPS.basic,\n defaultValue: false,\n }),\n pinColor: createColorProp({\n label: \"Pin Color\",\n description: \"Sets the color of the marker\",\n }),\n },\n};\n"]}
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  interface Props {
3
- defaultValue?: string;
3
+ value?: number;
4
+ defaultValue?: number;
4
5
  onChangeText: (value?: number) => void;
5
6
  }
6
7
  declare const NumberInput: React.FC<Props>;
@@ -27,7 +27,6 @@ export { default as Touchable } from "./components/Touchable";
27
27
  export { AccordionGroup, AccordionItem } from "./components/Accordion";
28
28
  export { ActionSheet, ActionSheetItem, ActionSheetCancel, } from "./components/ActionSheet";
29
29
  export { Swiper, SwiperItem } from "./components/Swiper";
30
- export { TabView, TabViewItem } from "./components/TabView";
31
30
  export { Center, Circle, Square, Row, Stack, Spacer, } from "./components/Layout";
32
31
  export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup, } from "./components/RadioButton/index";
33
32
  export { default as Button } from "./components/DeprecatedButton";
@@ -66,7 +66,7 @@ export declare const SEED_DATA: {
66
66
  formType: string;
67
67
  propType: string;
68
68
  };
69
- iconSize: {
69
+ size: {
70
70
  group: string;
71
71
  label: string;
72
72
  description: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftbit/core",
3
- "version": "43.2.4-aa029f.0+aa029f8e",
3
+ "version": "43.2.5-da45ce.0+da45ce1d",
4
4
  "description": "Core (non-native) Components",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -41,7 +41,7 @@
41
41
  "dependencies": {
42
42
  "@date-io/date-fns": "^1.3.13",
43
43
  "@draftbit/react-theme-provider": "^2.1.1",
44
- "@draftbit/types": "^43.2.0",
44
+ "@draftbit/types": "^43.2.4",
45
45
  "@material-ui/core": "^4.11.0",
46
46
  "@material-ui/pickers": "^3.2.10",
47
47
  "@react-native-community/slider": "4.1.7",
@@ -53,8 +53,6 @@
53
53
  "lodash.omit": "^4.5.0",
54
54
  "lodash.tonumber": "^4.0.3",
55
55
  "react-native-modal-datetime-picker": "^13.0.0",
56
- "react-native-pager-view": "^5.4.9",
57
- "react-native-tab-view": "^3.1.1",
58
56
  "react-native-typography": "^1.4.1",
59
57
  "react-native-web-swiper": "^2.2.1"
60
58
  },
@@ -81,5 +79,5 @@
81
79
  ]
82
80
  ]
83
81
  },
84
- "gitHead": "aa029f8e3934e3717bc10f06e86131e0d9ef175d"
82
+ "gitHead": "da45ce1da13dea1a28b56ca96251dad30c9eaa5a"
85
83
  }
@@ -1,23 +1,28 @@
1
1
  import React from "react";
2
- import { TextInput as NativeNumberInput } from "react-native";
3
- const NumberInput = ({ defaultValue, onChangeText, ...props }) => {
4
- const [internalValue, setInternalValue] = React.useState(defaultValue);
2
+ import { TextInput } from "react-native";
3
+ const NumberInput = ({ onChangeText, value, defaultValue, ...props }) => {
4
+ const [isDecimal, setIsDecimal] = React.useState(value && !Number.isInteger(value));
5
5
  React.useEffect(() => {
6
- if (defaultValue != null) {
7
- setInternalValue(defaultValue);
6
+ if (value) {
7
+ setIsDecimal(value.toString().includes("."));
8
8
  }
9
- }, [defaultValue]);
10
- const handleChangeText = (value) => {
11
- setInternalValue(value);
9
+ }, [value]);
10
+ const handleChangeText = (newValue) => {
12
11
  if (onChangeText) {
13
- onChangeText(stringToInteger(value));
12
+ const parsedNumber = parseFloat(newValue);
13
+ const number = isNaN(parsedNumber) ? 0 : parsedNumber;
14
+ setIsDecimal(newValue.includes("."));
15
+ onChangeText(number);
14
16
  }
15
17
  };
16
- return (React.createElement(NativeNumberInput, { keyboardType: "numeric", onChangeText: handleChangeText, ...props, value: internalValue }));
17
- };
18
- const stringToInteger = (str) => {
19
- const number = parseFloat(str);
20
- return isNaN(number) ? 0 : number;
18
+ let strValue;
19
+ if (value != undefined) {
20
+ strValue = value.toString();
21
+ if (isDecimal && !strValue.includes(".")) {
22
+ strValue = `${strValue}.`;
23
+ }
24
+ }
25
+ return (React.createElement(TextInput, { keyboardType: "numeric", ...props, value: strValue, defaultValue: defaultValue?.toString(), onChangeText: handleChangeText }));
21
26
  };
22
27
  export default NumberInput;
23
28
  // comment to try to fix sourcemap issue
@@ -1,46 +1,55 @@
1
1
  import React from "react";
2
- import { TextInput as NativeNumberInput } from "react-native";
2
+ import { TextInput } from "react-native";
3
3
 
4
4
  interface Props {
5
- defaultValue?: string;
5
+ value?: number;
6
+ defaultValue?: number;
6
7
  onChangeText: (value?: number) => void;
7
8
  }
8
9
 
9
10
  const NumberInput: React.FC<Props> = ({
10
- defaultValue,
11
11
  onChangeText,
12
+ value,
13
+ defaultValue,
12
14
  ...props
13
15
  }) => {
14
- const [internalValue, setInternalValue] = React.useState(defaultValue);
15
-
16
+ const [isDecimal, setIsDecimal] = React.useState(
17
+ value && !Number.isInteger(value)
18
+ );
16
19
  React.useEffect(() => {
17
- if (defaultValue != null) {
18
- setInternalValue(defaultValue);
20
+ if (value) {
21
+ setIsDecimal(value.toString().includes("."));
19
22
  }
20
- }, [defaultValue]);
23
+ }, [value]);
21
24
 
22
- const handleChangeText = (value: string) => {
23
- setInternalValue(value);
25
+ const handleChangeText = (newValue: string) => {
24
26
  if (onChangeText) {
25
- onChangeText(stringToInteger(value));
27
+ const parsedNumber = parseFloat(newValue);
28
+ const number = isNaN(parsedNumber) ? 0 : parsedNumber;
29
+ setIsDecimal(newValue.includes("."));
30
+ onChangeText(number);
26
31
  }
27
32
  };
28
33
 
34
+ let strValue;
35
+ if (value != undefined) {
36
+ strValue = value.toString();
37
+ if (isDecimal && !strValue.includes(".")) {
38
+ strValue = `${strValue}.`;
39
+ }
40
+ }
41
+
29
42
  return (
30
- <NativeNumberInput
43
+ <TextInput
31
44
  keyboardType="numeric"
32
- onChangeText={handleChangeText}
33
45
  {...props}
34
- value={internalValue}
46
+ value={strValue}
47
+ defaultValue={defaultValue?.toString()}
48
+ onChangeText={handleChangeText}
35
49
  />
36
50
  );
37
51
  };
38
52
 
39
- const stringToInteger = (str: string | undefined): number => {
40
- const number = parseFloat(str as string);
41
- return isNaN(number) ? 0 : number;
42
- };
43
-
44
53
  export default NumberInput;
45
54
 
46
55
  // comment to try to fix sourcemap issue
package/src/index.js CHANGED
@@ -27,7 +27,6 @@ export { default as Touchable } from "./components/Touchable";
27
27
  export { AccordionGroup, AccordionItem } from "./components/Accordion";
28
28
  export { ActionSheet, ActionSheetItem, ActionSheetCancel, } from "./components/ActionSheet";
29
29
  export { Swiper, SwiperItem } from "./components/Swiper";
30
- export { TabView, TabViewItem } from "./components/TabView";
31
30
  export { Center, Circle, Square, Row, Stack, Spacer, } from "./components/Layout";
32
31
  export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup, } from "./components/RadioButton/index";
33
32
  /* Deprecated: Fix or Delete! */
package/src/index.tsx CHANGED
@@ -32,7 +32,6 @@ export {
32
32
  ActionSheetCancel,
33
33
  } from "./components/ActionSheet";
34
34
  export { Swiper, SwiperItem } from "./components/Swiper";
35
- export { TabView, TabViewItem } from "./components/TabView";
36
35
 
37
36
  export {
38
37
  Center,
@@ -31,6 +31,6 @@ export const SEED_DATA = {
31
31
  defaultValue: null,
32
32
  group: GROUPS.basic,
33
33
  }),
34
- iconSize: createIconSizeProp(),
34
+ size: createIconSizeProp(),
35
35
  },
36
36
  };
@@ -41,6 +41,6 @@ export const SEED_DATA = {
41
41
  defaultValue: null,
42
42
  group: GROUPS.basic,
43
43
  }),
44
- iconSize: createIconSizeProp(),
44
+ size: createIconSizeProp(),
45
45
  },
46
46
  };
@@ -1,103 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var React = _interopRequireWildcard(require("react"));
9
-
10
- var _reactNativeTabView = require("react-native-tab-view");
11
-
12
- var _TabViewItem = _interopRequireDefault(require("./TabViewItem"));
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
-
20
- 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); }
21
-
22
- const TabViewComponent = _ref => {
23
- let {
24
- Icon,
25
- tabBarPosition,
26
- keyboardDismissMode,
27
- swipeEnabled,
28
- scrollEnabled,
29
- activeColor,
30
- inactiveColor,
31
- pressColor,
32
- indicatorColor,
33
- style,
34
- children
35
- } = _ref;
36
- const [index, setIndex] = React.useState(0);
37
- const [routes, setRoutes] = React.useState([]);
38
- const [tabScenes, setTabScenes] = React.useState({});
39
- React.useEffect(() => {
40
- const newRoutes = [];
41
- const scenes = {};
42
- React.Children.toArray(children).filter(child => child.type === _TabViewItem.default).forEach(child => {
43
- var _child$props;
44
-
45
- if (child !== null && child !== void 0 && (_child$props = child.props) !== null && _child$props !== void 0 && _child$props.id) {
46
- var _child$props2, _child$props3;
47
-
48
- newRoutes.push({
49
- key: child === null || child === void 0 ? void 0 : (_child$props2 = child.props) === null || _child$props2 === void 0 ? void 0 : _child$props2.id,
50
- ...(child === null || child === void 0 ? void 0 : child.props)
51
- });
52
-
53
- scenes[child === null || child === void 0 ? void 0 : (_child$props3 = child.props) === null || _child$props3 === void 0 ? void 0 : _child$props3.id] = () => child;
54
- }
55
- });
56
- setRoutes(newRoutes);
57
- setTabScenes(scenes);
58
- }, [children]);
59
-
60
- const indexChangeHandler = i => setIndex(i);
61
-
62
- const renderTabBar = props => {
63
- console.log(props);
64
- return /*#__PURE__*/React.createElement(_reactNativeTabView.TabBar, _extends({}, props, {
65
- activeColor: activeColor,
66
- inactiveColor: inactiveColor,
67
- pressColor: pressColor,
68
- scrollEnabled: scrollEnabled,
69
- indicatorStyle: {
70
- backgroundColor: indicatorColor
71
- },
72
- renderIcon: _ref2 => {
73
- let {
74
- route,
75
- color
76
- } = _ref2;
77
- return route !== null && route !== void 0 && route.icon ? /*#__PURE__*/React.createElement(Icon, {
78
- name: route.icon,
79
- color: color,
80
- size: 36
81
- }) : null;
82
- },
83
- style: style
84
- }));
85
- };
86
-
87
- return /*#__PURE__*/React.createElement(_reactNativeTabView.TabView, {
88
- navigationState: {
89
- index,
90
- routes
91
- },
92
- renderScene: (0, _reactNativeTabView.SceneMap)(tabScenes),
93
- renderTabBar: renderTabBar,
94
- onIndexChange: indexChangeHandler,
95
- tabBarPosition: tabBarPosition,
96
- keyboardDismissMode: keyboardDismissMode,
97
- swipeEnabled: swipeEnabled
98
- });
99
- };
100
-
101
- var _default = TabViewComponent;
102
- exports.default = _default;
103
- //# sourceMappingURL=TabView.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["TabView.tsx"],"names":["TabViewComponent","Icon","tabBarPosition","keyboardDismissMode","swipeEnabled","scrollEnabled","activeColor","inactiveColor","pressColor","indicatorColor","style","children","index","setIndex","React","useState","routes","setRoutes","tabScenes","setTabScenes","useEffect","newRoutes","scenes","Children","toArray","filter","child","type","TabViewItem","forEach","props","id","push","key","indexChangeHandler","i","renderTabBar","console","log","backgroundColor","route","color","icon"],"mappings":";;;;;;;AAAA;;AAEA;;AAGA;;;;;;;;;;AAmBA,MAAMA,gBAAgB,GAAG,QAYL;AAAA,MAZM;AACxBC,IAAAA,IADwB;AAExBC,IAAAA,cAFwB;AAGxBC,IAAAA,mBAHwB;AAIxBC,IAAAA,YAJwB;AAKxBC,IAAAA,aALwB;AAMxBC,IAAAA,WANwB;AAOxBC,IAAAA,aAPwB;AAQxBC,IAAAA,UARwB;AASxBC,IAAAA,cATwB;AAUxBC,IAAAA,KAVwB;AAWxBC,IAAAA;AAXwB,GAYN;AAClB,QAAM,CAACC,KAAD,EAAQC,QAAR,IAAoBC,KAAK,CAACC,QAAN,CAAe,CAAf,CAA1B;AACA,QAAM,CAACC,MAAD,EAASC,SAAT,IAAsBH,KAAK,CAACC,QAAN,CAAe,EAAf,CAA5B;AACA,QAAM,CAACG,SAAD,EAAYC,YAAZ,IAA4BL,KAAK,CAACC,QAAN,CAAe,EAAf,CAAlC;AAEAD,EAAAA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A,YAAC;AAAE+B,UAAAA,KAAF;AAASC,UAAAA;AAAT,SAAD;AAAA,eACVD,KAAK,SAAL,IAAAA,KAAK,WAAL,IAAAA,KAAK,CAAEE,IAAP,gBACE,oBAAC,IAAD;AAAM,UAAA,IAAI,EAAEF,KAAK,CAACE,IAAlB;AAAwB,UAAA,KAAK,EAAED,KAA/B;AAAsC,UAAA,IAAI,EAAE;AAA5C,UADF,GAEI,IAHM;AAAA,OAPd;AAYE,MAAA,KAAK,EAAE/B;AAZT,OADF;AAgBD,GAlBD;;AAoBA,sBACE,oBAAC,2BAAD;AACE,IAAA,eAAe,EAAE;AAAEE,MAAAA,KAAF;AAASI,MAAAA;AAAT,KADnB;AAEE,IAAA,WAAW,EAAE,kCAASE,SAAT,CAFf;AAGE,IAAA,YAAY,EAAEkB,YAHhB;AAIE,IAAA,aAAa,EAAEF,kBAJjB;AAKE,IAAA,cAAc,EAAEhC,cALlB;AAME,IAAA,mBAAmB,EAAEC,mBANvB;AAOE,IAAA,YAAY,EAAEC;AAPhB,IADF;AAWD,CAtED;;eAwEeJ,gB","sourcesContent":["import * as React from \"react\";\nimport { StyleProp, TextStyle, ViewStyle } from \"react-native\";\nimport { TabView, TabBar, SceneMap } from \"react-native-tab-view\";\n\n// import { withTheme } from \"../../theming\";\nimport TabViewItem from \"./TabViewItem\";\nimport type { IconSlot } from \"../../interfaces/Icon\";\n\ntype TabBarPosition = \"top\" | \"bottom\";\ntype KeyboardDismissMode = \"none\" | \"auto\" | \"on-drag\";\n\ntype TabViewProps = {\n tabBarPosition?: TabBarPosition;\n keyboardDismissMode?: KeyboardDismissMode;\n swipeEnabled?: boolean;\n scrollEnabled?: boolean;\n activeColor?: string;\n inactiveColor?: string;\n pressColor?: string;\n indicatorColor?: string;\n style?: StyleProp<TextStyle | ViewStyle>;\n children: React.ReactNode;\n} & IconSlot;\n\nconst TabViewComponent = ({\n Icon,\n tabBarPosition,\n keyboardDismissMode,\n swipeEnabled,\n scrollEnabled,\n activeColor,\n inactiveColor,\n pressColor,\n indicatorColor,\n style,\n children,\n}: TabViewProps) => {\n const [index, setIndex] = React.useState(0);\n const [routes, setRoutes] = React.useState([]);\n const [tabScenes, setTabScenes] = React.useState({});\n\n React.useEffect(() => {\n const newRoutes: any = [];\n const scenes: any = {};\n\n React.Children.toArray(children)\n .filter((child: any) => child.type === TabViewItem)\n .forEach((child: any) => {\n if (child?.props?.id) {\n newRoutes.push({\n key: child?.props?.id,\n ...child?.props,\n });\n scenes[child?.props?.id] = () => child;\n }\n });\n\n setRoutes(newRoutes);\n setTabScenes(scenes);\n }, [children]);\n\n const indexChangeHandler = (i: any) => setIndex(i);\n\n const renderTabBar = (props: any) => {\n console.log(props);\n return (\n <TabBar\n {...props}\n activeColor={activeColor}\n inactiveColor={inactiveColor}\n pressColor={pressColor}\n scrollEnabled={scrollEnabled}\n indicatorStyle={{ backgroundColor: indicatorColor }}\n renderIcon={({ route, color }) =>\n route?.icon ? (\n <Icon name={route.icon} color={color} size={36} />\n ) : null\n }\n style={style}\n />\n );\n };\n\n return (\n <TabView\n navigationState={{ index, routes }}\n renderScene={SceneMap(tabScenes)}\n renderTabBar={renderTabBar}\n onIndexChange={indexChangeHandler}\n tabBarPosition={tabBarPosition}\n keyboardDismissMode={keyboardDismissMode}\n swipeEnabled={swipeEnabled}\n />\n );\n};\n\nexport default TabViewComponent;\n"]}
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- const TabViewItem = _ref => {
9
- let {
10
- title,
11
- id,
12
- icon,
13
- children,
14
- accessibilityLabel
15
- } = _ref;
16
- console.log({
17
- title,
18
- id,
19
- icon,
20
- accessibilityLabel
21
- });
22
- return children;
23
- };
24
-
25
- var _default = TabViewItem;
26
- exports.default = _default;
27
- //# sourceMappingURL=TabViewItem.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["TabViewItem.tsx"],"names":["TabViewItem","title","id","icon","children","accessibilityLabel","console","log"],"mappings":";;;;;;;AASA,MAAMA,WAAW,GAAG,QAMI;AAAA,MANH;AACnBC,IAAAA,KADmB;AAEnBC,IAAAA,EAFmB;AAGnBC,IAAAA,IAHmB;AAInBC,IAAAA,QAJmB;AAKnBC,IAAAA;AALmB,GAMG;AACtBC,EAAAA,OAAO,CAACC,GAAR,CAAY;AAAEN,IAAAA,KAAF;AAASC,IAAAA,EAAT;AAAaC,IAAAA,IAAb;AAAmBE,IAAAA;AAAnB,GAAZ;AACA,SAAOD,QAAP;AACD,CATD;;eAWeJ,W","sourcesContent":["import React from \"react\";\ninterface TabViewItemProps {\n title: string;\n id: string;\n icon: string;\n accessibilityLabel: string;\n children: React.ReactNode;\n}\n\nconst TabViewItem = ({\n title,\n id,\n icon,\n children,\n accessibilityLabel,\n}: TabViewItemProps) => {\n console.log({ title, id, icon, accessibilityLabel });\n return children;\n};\n\nexport default TabViewItem;\n"]}
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "TabView", {
7
- enumerable: true,
8
- get: function () {
9
- return _TabView.default;
10
- }
11
- });
12
- Object.defineProperty(exports, "TabViewItem", {
13
- enumerable: true,
14
- get: function () {
15
- return _TabViewItem.default;
16
- }
17
- });
18
-
19
- var _TabView = _interopRequireDefault(require("./TabView"));
20
-
21
- var _TabViewItem = _interopRequireDefault(require("./TabViewItem"));
22
-
23
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AACA","sourcesContent":["export { default as TabView } from \"./TabView\";\nexport { default as TabViewItem } from \"./TabViewItem\";\n"]}
@@ -1,80 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SEED_DATA = void 0;
7
-
8
- var _types = require("@draftbit/types");
9
-
10
- const SEED_DATA = [{
11
- name: "TabView",
12
- tag: "TabView",
13
- category: _types.COMPONENT_TYPES.container,
14
- layout: {},
15
- props: {
16
- tabBarPosition: (0, _types.createTextEnumProp)({
17
- label: "Tab Bar Position",
18
- description: "Tab Bar Position",
19
- options: ["top", "bottom"],
20
- defaultValue: "top"
21
- }),
22
- keyboardDismissMode: (0, _types.createTextEnumProp)({
23
- label: "Keyboard Dismiss Mode",
24
- description: "Keyboard Dismiss Mode",
25
- options: ["auto", "on-drag", "none"],
26
- defaultValue: "auto"
27
- }),
28
- swipeEnabled: (0, _types.createBoolProp)({
29
- label: "Swipe Enabled",
30
- description: "Swipe Enabled",
31
- defaultValue: true
32
- }),
33
- scrollEnabled: (0, _types.createBoolProp)({
34
- label: "Scroll Enabled",
35
- description: "Scroll Enabled",
36
- defaultValue: true
37
- }),
38
- activeColor: (0, _types.createColorProp)({
39
- label: "Active Color",
40
- description: "Active Color",
41
- defaultValue: "primary"
42
- }),
43
- inactiveColor: (0, _types.createColorProp)({
44
- label: "Inactive Color",
45
- description: "Inactive Color",
46
- defaultValue: null
47
- }),
48
- pressColor: (0, _types.createColorProp)({
49
- label: "Press Color",
50
- description: "Press Color",
51
- defaultValue: null
52
- }),
53
- indicatorColor: (0, _types.createColorProp)({
54
- label: "Indicator Color",
55
- description: "Indicator Color",
56
- defaultValue: null
57
- })
58
- }
59
- }, {
60
- name: "TabViewItem",
61
- tag: "TabViewItem",
62
- category: _types.COMPONENT_TYPES.container,
63
- layout: {},
64
- props: {
65
- title: (0, _types.createTextProp)({
66
- label: "Title",
67
- description: "Tab Title"
68
- }),
69
- id: (0, _types.createTextProp)({
70
- label: "Id",
71
- description: "Tab Id"
72
- }),
73
- accessibilityLabel: (0, _types.createTextProp)({
74
- label: "Accessibility Label",
75
- description: "Accessibility Label"
76
- })
77
- }
78
- }];
79
- exports.SEED_DATA = SEED_DATA;
80
- //# sourceMappingURL=TabView.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["TabView.ts"],"names":["SEED_DATA","name","tag","category","COMPONENT_TYPES","container","layout","props","tabBarPosition","label","description","options","defaultValue","keyboardDismissMode","swipeEnabled","scrollEnabled","activeColor","inactiveColor","pressColor","indicatorColor","title","id","accessibilityLabel"],"mappings":";;;;;;;AAAA;;AAQO,MAAMA,SAAS,GAAG,CACvB;AACEC,EAAAA,IAAI,EAAE,SADR;AAEEC,EAAAA,GAAG,EAAE,SAFP;AAGEC,EAAAA,QAAQ,EAAEC,uBAAgBC,SAH5B;AAIEC,EAAAA,MAAM,EAAE,EAJV;AAKEC,EAAAA,KAAK,EAAE;AACLC,IAAAA,cAAc,EAAE,+BAAmB;AACjCC,MAAAA,KAAK,EAAE,kBAD0B;AAEjCC,MAAAA,WAAW,EAAE,kBAFoB;AAGjCC,MAAAA,OAAO,EAAE,CAAC,KAAD,EAAQ,QAAR,CAHwB;AAIjCC,MAAAA,YAAY,EAAE;AAJmB,KAAnB,CADX;AAOLC,IAAAA,mBAAmB,EAAE,+BAAmB;AACtCJ,MAAAA,KAAK,EAAE,uBAD+B;AAEtCC,MAAAA,WAAW,EAAE,uBAFyB;AAGtCC,MAAAA,OAAO,EAAE,CAAC,MAAD,EAAS,SAAT,EAAoB,MAApB,CAH6B;AAItCC,MAAAA,YAAY,EAAE;AAJwB,KAAnB,CAPhB;AAaLE,IAAAA,YAAY,EAAE,2BAAe;AAC3BL,MAAAA,KAAK,EAAE,eADoB;AAE3BC,MAAAA,WAAW,EAAE,eAFc;AAG3BE,MAAAA,YAAY,EAAE;AAHa,KAAf,CAbT;AAkBLG,IAAAA,aAAa,EAAE,2BAAe;AAC5BN,MAAAA,KAAK,EAAE,gBADqB;AAE5BC,MAAAA,WAAW,EAAE,gBAFe;AAG5BE,MAAAA,YAAY,EAAE;AAHc,KAAf,CAlBV;AAuBLI,IAAAA,WAAW,EAAE,4BAAgB;AAC3BP,MAAAA,KAAK,EAAE,cADoB;AAE3BC,MAAAA,WAAW,EAAE,cAFc;AAG3BE,MAAAA,YAAY,EAAE;AAHa,KAAhB,CAvBR;AA4BLK,IAAAA,aAAa,EAAE,4BAAgB;AAC7BR,MAAAA,KAAK,EAAE,gBADsB;AAE7BC,MAAAA,WAAW,EAAE,gBAFgB;AAG7BE,MAAAA,YAAY,EAAE;AAHe,KAAhB,CA5BV;AAiCLM,IAAAA,UAAU,EAAE,4BAAgB;AAC1BT,MAAAA,KAAK,EAAE,aADmB;AAE1BC,MAAAA,WAAW,EAAE,aAFa;AAG1BE,MAAAA,YAAY,EAAE;AAHY,KAAhB,CAjCP;AAsCLO,IAAAA,cAAc,EAAE,4BAAgB;AAC9BV,MAAAA,KAAK,EAAE,iBADuB;AAE9BC,MAAAA,WAAW,EAAE,iBAFiB;AAG9BE,MAAAA,YAAY,EAAE;AAHgB,KAAhB;AAtCX;AALT,CADuB,EAmDvB;AACEX,EAAAA,IAAI,EAAE,aADR;AAEEC,EAAAA,GAAG,EAAE,aAFP;AAGEC,EAAAA,QAAQ,EAAEC,uBAAgBC,SAH5B;AAIEC,EAAAA,MAAM,EAAE,EAJV;AAKEC,EAAAA,KAAK,EAAE;AACLa,IAAAA,KAAK,EAAE,2BAAe;AACpBX,MAAAA,KAAK,EAAE,OADa;AAEpBC,MAAAA,WAAW,EAAE;AAFO,KAAf,CADF;AAKLW,IAAAA,EAAE,EAAE,2BAAe;AACjBZ,MAAAA,KAAK,EAAE,IADU;AAEjBC,MAAAA,WAAW,EAAE;AAFI,KAAf,CALC;AASLY,IAAAA,kBAAkB,EAAE,2BAAe;AACjCb,MAAAA,KAAK,EAAE,qBAD0B;AAEjCC,MAAAA,WAAW,EAAE;AAFoB,KAAf;AATf;AALT,CAnDuB,CAAlB","sourcesContent":["import {\n COMPONENT_TYPES,\n createTextProp,\n createTextEnumProp,\n createBoolProp,\n createColorProp,\n} from \"@draftbit/types\";\n\nexport const SEED_DATA = [\n {\n name: \"TabView\",\n tag: \"TabView\",\n category: COMPONENT_TYPES.container,\n layout: {},\n props: {\n tabBarPosition: createTextEnumProp({\n label: \"Tab Bar Position\",\n description: \"Tab Bar Position\",\n options: [\"top\", \"bottom\"],\n defaultValue: \"top\",\n }),\n keyboardDismissMode: createTextEnumProp({\n label: \"Keyboard Dismiss Mode\",\n description: \"Keyboard Dismiss Mode\",\n options: [\"auto\", \"on-drag\", \"none\"],\n defaultValue: \"auto\",\n }),\n swipeEnabled: createBoolProp({\n label: \"Swipe Enabled\",\n description: \"Swipe Enabled\",\n defaultValue: true,\n }),\n scrollEnabled: createBoolProp({\n label: \"Scroll Enabled\",\n description: \"Scroll Enabled\",\n defaultValue: true,\n }),\n activeColor: createColorProp({\n label: \"Active Color\",\n description: \"Active Color\",\n defaultValue: \"primary\",\n }),\n inactiveColor: createColorProp({\n label: \"Inactive Color\",\n description: \"Inactive Color\",\n defaultValue: null,\n }),\n pressColor: createColorProp({\n label: \"Press Color\",\n description: \"Press Color\",\n defaultValue: null,\n }),\n indicatorColor: createColorProp({\n label: \"Indicator Color\",\n description: \"Indicator Color\",\n defaultValue: null,\n }),\n },\n },\n {\n name: \"TabViewItem\",\n tag: \"TabViewItem\",\n category: COMPONENT_TYPES.container,\n layout: {},\n props: {\n title: createTextProp({\n label: \"Title\",\n description: \"Tab Title\",\n }),\n id: createTextProp({\n label: \"Id\",\n description: \"Tab Id\",\n }),\n accessibilityLabel: createTextProp({\n label: \"Accessibility Label\",\n description: \"Accessibility Label\",\n }),\n },\n },\n];\n"]}
@@ -1,88 +0,0 @@
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
- import * as React from "react";
4
- import { TabView, TabBar, SceneMap } from "react-native-tab-view"; // import { withTheme } from "../../theming";
5
-
6
- import TabViewItem from "./TabViewItem";
7
-
8
- const TabViewComponent = _ref => {
9
- let {
10
- Icon,
11
- tabBarPosition,
12
- keyboardDismissMode,
13
- swipeEnabled,
14
- scrollEnabled,
15
- activeColor,
16
- inactiveColor,
17
- pressColor,
18
- indicatorColor,
19
- style,
20
- children
21
- } = _ref;
22
- const [index, setIndex] = React.useState(0);
23
- const [routes, setRoutes] = React.useState([]);
24
- const [tabScenes, setTabScenes] = React.useState({});
25
- React.useEffect(() => {
26
- const newRoutes = [];
27
- const scenes = {};
28
- React.Children.toArray(children).filter(child => child.type === TabViewItem).forEach(child => {
29
- var _child$props;
30
-
31
- if (child !== null && child !== void 0 && (_child$props = child.props) !== null && _child$props !== void 0 && _child$props.id) {
32
- var _child$props2, _child$props3;
33
-
34
- newRoutes.push({
35
- key: child === null || child === void 0 ? void 0 : (_child$props2 = child.props) === null || _child$props2 === void 0 ? void 0 : _child$props2.id,
36
- ...(child === null || child === void 0 ? void 0 : child.props)
37
- });
38
-
39
- scenes[child === null || child === void 0 ? void 0 : (_child$props3 = child.props) === null || _child$props3 === void 0 ? void 0 : _child$props3.id] = () => child;
40
- }
41
- });
42
- setRoutes(newRoutes);
43
- setTabScenes(scenes);
44
- }, [children]);
45
-
46
- const indexChangeHandler = i => setIndex(i);
47
-
48
- const renderTabBar = props => {
49
- console.log(props);
50
- return /*#__PURE__*/React.createElement(TabBar, _extends({}, props, {
51
- activeColor: activeColor,
52
- inactiveColor: inactiveColor,
53
- pressColor: pressColor,
54
- scrollEnabled: scrollEnabled,
55
- indicatorStyle: {
56
- backgroundColor: indicatorColor
57
- },
58
- renderIcon: _ref2 => {
59
- let {
60
- route,
61
- color
62
- } = _ref2;
63
- return route !== null && route !== void 0 && route.icon ? /*#__PURE__*/React.createElement(Icon, {
64
- name: route.icon,
65
- color: color,
66
- size: 36
67
- }) : null;
68
- },
69
- style: style
70
- }));
71
- };
72
-
73
- return /*#__PURE__*/React.createElement(TabView, {
74
- navigationState: {
75
- index,
76
- routes
77
- },
78
- renderScene: SceneMap(tabScenes),
79
- renderTabBar: renderTabBar,
80
- onIndexChange: indexChangeHandler,
81
- tabBarPosition: tabBarPosition,
82
- keyboardDismissMode: keyboardDismissMode,
83
- swipeEnabled: swipeEnabled
84
- });
85
- };
86
-
87
- export default TabViewComponent;
88
- //# sourceMappingURL=TabView.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["TabView.tsx"],"names":["React","TabView","TabBar","SceneMap","TabViewItem","TabViewComponent","Icon","tabBarPosition","keyboardDismissMode","swipeEnabled","scrollEnabled","activeColor","inactiveColor","pressColor","indicatorColor","style","children","index","setIndex","useState","routes","setRoutes","tabScenes","setTabScenes","useEffect","newRoutes","scenes","Children","toArray","filter","child","type","forEach","props","id","push","key","indexChangeHandler","i","renderTabBar","console","log","backgroundColor","route","color","icon"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,SAASC,OAAT,EAAkBC,MAAlB,EAA0BC,QAA1B,QAA0C,uBAA1C,C,CAEA;;AACA,OAAOC,WAAP,MAAwB,eAAxB;;AAmBA,MAAMC,gBAAgB,GAAG,QAYL;AAAA,MAZM;AACxBC,IAAAA,IADwB;AAExBC,IAAAA,cAFwB;AAGxBC,IAAAA,mBAHwB;AAIxBC,IAAAA,YAJwB;AAKxBC,IAAAA,aALwB;AAMxBC,IAAAA,WANwB;AAOxBC,IAAAA,aAPwB;AAQxBC,IAAAA,UARwB;AASxBC,IAAAA,cATwB;AAUxBC,IAAAA,KAVwB;AAWxBC,IAAAA;AAXwB,GAYN;AAClB,QAAM,CAACC,KAAD,EAAQC,QAAR,IAAoBlB,KAAK,CAACmB,QAAN,CAAe,CAAf,CAA1B;AACA,QAAM,CAACC,MAAD,EAASC,SAAT,IAAsBrB,KAAK,CAACmB,QAAN,CAAe,EAAf,CAA5B;AACA,QAAM,CAACG,SAAD,EAAYC,YAAZ,IAA4BvB,KAAK,CAACmB,QAAN,CAAe,EAAf,CAAlC;AAEAnB,EAAAA,KAAK,CAACwB,SAAN,CAAgB,MAAM;AACpB,UAAMC,SAAc,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;AAAT,SAAD;AAAA,eACVD,KAAK,SAAL,IAAAA,KAAK,WAAL,IAAAA,KAAK,CAAEE,IAAP,gBACE,oBAAC,IAAD;AAAM,UAAA,IAAI,EAAEF,KAAK,CAACE,IAAlB;AAAwB,UAAA,KAAK,EAAED,KAA/B;AAAsC,UAAA,IAAI,EAAE;AAA5C,UADF,GAEI,IAHM;AAAA,OAPd;AAYE,MAAA,KAAK,EAAE7B;AAZT,OADF;AAgBD,GAlBD;;AAoBA,sBACE,oBAAC,OAAD;AACE,IAAA,eAAe,EAAE;AAAEE,MAAAA,KAAF;AAASG,MAAAA;AAAT,KADnB;AAEE,IAAA,WAAW,EAAEjB,QAAQ,CAACmB,SAAD,CAFvB;AAGE,IAAA,YAAY,EAAEiB,YAHhB;AAIE,IAAA,aAAa,EAAEF,kBAJjB;AAKE,IAAA,cAAc,EAAE9B,cALlB;AAME,IAAA,mBAAmB,EAAEC,mBANvB;AAOE,IAAA,YAAY,EAAEC;AAPhB,IADF;AAWD,CAtED;;AAwEA,eAAeJ,gBAAf","sourcesContent":["import * as React from \"react\";\nimport { StyleProp, TextStyle, ViewStyle } from \"react-native\";\nimport { TabView, TabBar, SceneMap } from \"react-native-tab-view\";\n\n// import { withTheme } from \"../../theming\";\nimport TabViewItem from \"./TabViewItem\";\nimport type { IconSlot } from \"../../interfaces/Icon\";\n\ntype TabBarPosition = \"top\" | \"bottom\";\ntype KeyboardDismissMode = \"none\" | \"auto\" | \"on-drag\";\n\ntype TabViewProps = {\n tabBarPosition?: TabBarPosition;\n keyboardDismissMode?: KeyboardDismissMode;\n swipeEnabled?: boolean;\n scrollEnabled?: boolean;\n activeColor?: string;\n inactiveColor?: string;\n pressColor?: string;\n indicatorColor?: string;\n style?: StyleProp<TextStyle | ViewStyle>;\n children: React.ReactNode;\n} & IconSlot;\n\nconst TabViewComponent = ({\n Icon,\n tabBarPosition,\n keyboardDismissMode,\n swipeEnabled,\n scrollEnabled,\n activeColor,\n inactiveColor,\n pressColor,\n indicatorColor,\n style,\n children,\n}: TabViewProps) => {\n const [index, setIndex] = React.useState(0);\n const [routes, setRoutes] = React.useState([]);\n const [tabScenes, setTabScenes] = React.useState({});\n\n React.useEffect(() => {\n const newRoutes: any = [];\n const scenes: any = {};\n\n React.Children.toArray(children)\n .filter((child: any) => child.type === TabViewItem)\n .forEach((child: any) => {\n if (child?.props?.id) {\n newRoutes.push({\n key: child?.props?.id,\n ...child?.props,\n });\n scenes[child?.props?.id] = () => child;\n }\n });\n\n setRoutes(newRoutes);\n setTabScenes(scenes);\n }, [children]);\n\n const indexChangeHandler = (i: any) => setIndex(i);\n\n const renderTabBar = (props: any) => {\n console.log(props);\n return (\n <TabBar\n {...props}\n activeColor={activeColor}\n inactiveColor={inactiveColor}\n pressColor={pressColor}\n scrollEnabled={scrollEnabled}\n indicatorStyle={{ backgroundColor: indicatorColor }}\n renderIcon={({ route, color }) =>\n route?.icon ? (\n <Icon name={route.icon} color={color} size={36} />\n ) : null\n }\n style={style}\n />\n );\n };\n\n return (\n <TabView\n navigationState={{ index, routes }}\n renderScene={SceneMap(tabScenes)}\n renderTabBar={renderTabBar}\n onIndexChange={indexChangeHandler}\n tabBarPosition={tabBarPosition}\n keyboardDismissMode={keyboardDismissMode}\n swipeEnabled={swipeEnabled}\n />\n );\n};\n\nexport default TabViewComponent;\n"]}
@@ -1,19 +0,0 @@
1
- const TabViewItem = _ref => {
2
- let {
3
- title,
4
- id,
5
- icon,
6
- children,
7
- accessibilityLabel
8
- } = _ref;
9
- console.log({
10
- title,
11
- id,
12
- icon,
13
- accessibilityLabel
14
- });
15
- return children;
16
- };
17
-
18
- export default TabViewItem;
19
- //# sourceMappingURL=TabViewItem.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["TabViewItem.tsx"],"names":["TabViewItem","title","id","icon","children","accessibilityLabel","console","log"],"mappings":"AASA,MAAMA,WAAW,GAAG,QAMI;AAAA,MANH;AACnBC,IAAAA,KADmB;AAEnBC,IAAAA,EAFmB;AAGnBC,IAAAA,IAHmB;AAInBC,IAAAA,QAJmB;AAKnBC,IAAAA;AALmB,GAMG;AACtBC,EAAAA,OAAO,CAACC,GAAR,CAAY;AAAEN,IAAAA,KAAF;AAASC,IAAAA,EAAT;AAAaC,IAAAA,IAAb;AAAmBE,IAAAA;AAAnB,GAAZ;AACA,SAAOD,QAAP;AACD,CATD;;AAWA,eAAeJ,WAAf","sourcesContent":["import React from \"react\";\ninterface TabViewItemProps {\n title: string;\n id: string;\n icon: string;\n accessibilityLabel: string;\n children: React.ReactNode;\n}\n\nconst TabViewItem = ({\n title,\n id,\n icon,\n children,\n accessibilityLabel,\n}: TabViewItemProps) => {\n console.log({ title, id, icon, accessibilityLabel });\n return children;\n};\n\nexport default TabViewItem;\n"]}
@@ -1,3 +0,0 @@
1
- export { default as TabView } from "./TabView";
2
- export { default as TabViewItem } from "./TabViewItem";
3
- //# sourceMappingURL=index.js.map