@draftbit/core 46.8.1-b0418d.2 → 46.8.1-e9e820.2

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 (45) hide show
  1. package/lib/commonjs/components/Accordion/AccordionItem.js +23 -4
  2. package/lib/commonjs/components/Picker/Picker.js +9 -8
  3. package/lib/commonjs/components/TabView/TabView.js +100 -0
  4. package/lib/commonjs/components/TabView/TabViewItem.js +25 -0
  5. package/lib/commonjs/components/TabView/index.js +20 -0
  6. package/lib/commonjs/index.js +13 -0
  7. package/lib/commonjs/mappings/TabView.js +73 -0
  8. package/lib/commonjs/mappings/TabViewItem.js +35 -0
  9. package/lib/module/components/Accordion/AccordionItem.js +25 -4
  10. package/lib/module/components/Picker/Picker.js +9 -8
  11. package/lib/module/components/TabView/TabView.js +90 -0
  12. package/lib/module/components/TabView/TabViewItem.js +20 -0
  13. package/lib/module/components/TabView/index.js +2 -0
  14. package/lib/module/constants.js +1 -0
  15. package/lib/module/index.js +1 -0
  16. package/lib/module/mappings/TabView.js +66 -0
  17. package/lib/module/mappings/TabViewItem.js +28 -0
  18. package/lib/typescript/src/components/Picker/Picker.d.ts.map +1 -1
  19. package/lib/typescript/src/components/TabView/TabView.d.ts +26 -0
  20. package/lib/typescript/src/components/TabView/TabView.d.ts.map +1 -0
  21. package/lib/typescript/src/components/TabView/TabViewItem.d.ts +11 -0
  22. package/lib/typescript/src/components/TabView/TabViewItem.d.ts.map +1 -0
  23. package/lib/typescript/src/components/TabView/index.d.ts +3 -0
  24. package/lib/typescript/src/components/TabView/index.d.ts.map +1 -0
  25. package/lib/typescript/src/index.d.ts +1 -0
  26. package/lib/typescript/src/index.d.ts.map +1 -1
  27. package/lib/typescript/src/mappings/TabView.d.ts +123 -0
  28. package/lib/typescript/src/mappings/TabView.d.ts.map +1 -0
  29. package/lib/typescript/src/mappings/TabViewItem.d.ts +25 -0
  30. package/lib/typescript/src/mappings/TabViewItem.d.ts.map +1 -0
  31. package/package.json +5 -3
  32. package/src/components/Picker/Picker.js +8 -7
  33. package/src/components/Picker/Picker.tsx +9 -7
  34. package/src/components/TabView/TabView.js +45 -0
  35. package/src/components/TabView/TabView.tsx +129 -0
  36. package/src/components/TabView/TabViewItem.js +11 -0
  37. package/src/components/TabView/TabViewItem.tsx +25 -0
  38. package/src/components/TabView/index.js +2 -0
  39. package/src/components/TabView/index.tsx +2 -0
  40. package/src/index.js +1 -0
  41. package/src/index.tsx +2 -0
  42. package/src/mappings/TabView.js +69 -0
  43. package/src/mappings/TabView.ts +79 -0
  44. package/src/mappings/TabViewItem.js +28 -0
  45. package/src/mappings/TabViewItem.ts +35 -0
@@ -12,7 +12,6 @@ var _theming = require("../../theming");
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
  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); }
14
14
  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; }
15
- function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
16
15
  const AccordionItem = _ref => {
17
16
  let {
18
17
  Icon,
@@ -27,9 +26,10 @@ const AccordionItem = _ref => {
27
26
  textStyles,
28
27
  viewStyles
29
28
  } = (0, _utilities.extractStyles)(style);
30
- return /*#__PURE__*/React.createElement(_reactNative.Pressable, _extends({
31
- style: [styles.container, viewStyles]
32
- }, rest), /*#__PURE__*/React.createElement(_reactNative.View, {
29
+ return /*#__PURE__*/React.createElement(_reactNative.Pressable, {
30
+ style: [styles.container, viewStyles],
31
+ ...rest
32
+ }, /*#__PURE__*/React.createElement(_reactNative.View, {
33
33
  style: styles.row
34
34
  }, icon ? /*#__PURE__*/React.createElement(Icon, {
35
35
  name: icon,
@@ -61,4 +61,23 @@ const styles = _reactNative.StyleSheet.create({
61
61
  }
62
62
  });
63
63
  var _default = (0, _theming.withTheme)(AccordionItem);
64
+ exports.default = _default;.StyleSheet.create({
65
+ container: {
66
+ padding: 8
67
+ },
68
+ row: {
69
+ flexDirection: "row",
70
+ alignItems: "center",
71
+ paddingLeft: 8
72
+ },
73
+ item: {
74
+ marginVertical: 6,
75
+ paddingLeft: 8
76
+ },
77
+ content: {
78
+ flex: 1,
79
+ justifyContent: "center"
80
+ }
81
+ });
82
+ var _default = (0, _theming.withTheme)(AccordionItem);
64
83
  exports.default = _default;
@@ -46,9 +46,6 @@ const isWeb = _reactNative.Platform.OS === "web";
46
46
  const unstyledColor = "rgba(165, 173, 183, 1)";
47
47
  const disabledColor = "rgb(240, 240, 240)";
48
48
  const errorColor = "rgba(255, 69, 100, 1)";
49
-
50
- //Empty string for 'value' is treated as a non-value
51
- //reason: Draftbit uses empty string as initial value for string state*/
52
49
  const Picker = _ref => {
53
50
  var _find$label, _find;
54
51
  let {
@@ -79,12 +76,12 @@ const Picker = _ref => {
79
76
  setPickerVisible(!pickerVisible);
80
77
  };
81
78
  React.useEffect(() => {
82
- if (value != null && value !== "") {
79
+ if (value != null) {
83
80
  setInternalValue(value);
84
81
  }
85
82
  }, [value]);
86
83
  React.useEffect(() => {
87
- if (defaultValue != null && defaultValue !== "") {
84
+ if (defaultValue != null) {
88
85
  setInternalValue(defaultValue);
89
86
  }
90
87
  }, [defaultValue]);
@@ -99,7 +96,11 @@ const Picker = _ref => {
99
96
  _reactNative.Keyboard.dismiss();
100
97
  }
101
98
  }, [pickerVisible, autoDismissKeyboard]);
102
- const pickerOptions = normalizeOptions(options);
99
+ const normalizedOptions = normalizeOptions(options);
100
+ const pickerOptions = placeholder ? [{
101
+ value: placeholder,
102
+ label: placeholder
103
+ }, ...normalizedOptions] : normalizedOptions;
103
104
  const {
104
105
  viewStyles,
105
106
  textStyles
@@ -199,10 +200,10 @@ const Picker = _ref => {
199
200
  } : {})
200
201
  };
201
202
  const handleValueChange = (newValue, itemIndex) => {
202
- if (newValue !== "") {
203
+ if (!placeholder || itemIndex > 0) {
203
204
  onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue, itemIndex);
204
- setInternalValue(newValue);
205
205
  }
206
+ setInternalValue(newValue);
206
207
  };
207
208
  return (
208
209
  /*#__PURE__*/
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _reactNativeTabView = require("react-native-tab-view");
9
+ var _TabViewItem = _interopRequireDefault(require("./TabViewItem"));
10
+ var _theming = require("../../theming");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ 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); }
13
+ 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; }
14
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
15
+ const TabViewComponent = _ref => {
16
+ let {
17
+ Icon,
18
+ onIndexChanged,
19
+ onEndReached,
20
+ tabBarPosition,
21
+ keyboardDismissMode,
22
+ swipeEnabled,
23
+ scrollEnabled,
24
+ activeColor,
25
+ inactiveColor,
26
+ pressColor,
27
+ indicatorColor,
28
+ tabsBackgroundColor,
29
+ style,
30
+ theme,
31
+ children
32
+ } = _ref;
33
+ const [index, setIndex] = React.useState(0);
34
+ const [routes, setRoutes] = React.useState([]);
35
+ const [tabScenes, setTabScenes] = React.useState({});
36
+
37
+ //Populate routes and scenes based on children
38
+ React.useEffect(() => {
39
+ const newRoutes = [];
40
+ const scenes = {};
41
+ React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && child.type === _TabViewItem.default).forEach((item, idx) => {
42
+ const child = item;
43
+ newRoutes.push({
44
+ key: idx.toString(),
45
+ title: child.props.title,
46
+ icon: child.props.icon,
47
+ accessibilityLabel: child.props.accessibilityLabel
48
+ });
49
+ scenes[idx] = () => child;
50
+ });
51
+ setRoutes(newRoutes);
52
+ setTabScenes(scenes);
53
+ }, [children]);
54
+ const indexChangeHandler = i => {
55
+ setIndex(i);
56
+ onIndexChanged === null || onIndexChanged === void 0 ? void 0 : onIndexChanged(i);
57
+ if (i === routes.length) {
58
+ onEndReached === null || onEndReached === void 0 ? void 0 : onEndReached();
59
+ }
60
+ };
61
+ const renderTabBar = props => {
62
+ return /*#__PURE__*/React.createElement(_reactNativeTabView.TabBar, _extends({}, props, {
63
+ activeColor: activeColor || theme.colors.primary,
64
+ inactiveColor: inactiveColor || theme.colors.divider,
65
+ pressColor: pressColor || theme.colors.primary,
66
+ scrollEnabled: scrollEnabled,
67
+ indicatorStyle: {
68
+ backgroundColor: indicatorColor || theme.colors.primary
69
+ },
70
+ renderIcon: _ref2 => {
71
+ let {
72
+ route,
73
+ color
74
+ } = _ref2;
75
+ return route !== null && route !== void 0 && route.icon ? /*#__PURE__*/React.createElement(Icon, {
76
+ name: route.icon,
77
+ color: color,
78
+ size: 36
79
+ }) : null;
80
+ },
81
+ style: [{
82
+ backgroundColor: tabsBackgroundColor || theme.colors.background
83
+ }, style]
84
+ }));
85
+ };
86
+ return /*#__PURE__*/React.createElement(_reactNativeTabView.TabView, {
87
+ navigationState: {
88
+ index,
89
+ routes
90
+ },
91
+ renderScene: (0, _reactNativeTabView.SceneMap)(tabScenes),
92
+ renderTabBar: renderTabBar,
93
+ onIndexChange: indexChangeHandler,
94
+ tabBarPosition: tabBarPosition,
95
+ keyboardDismissMode: keyboardDismissMode,
96
+ swipeEnabled: swipeEnabled
97
+ });
98
+ };
99
+ var _default = (0, _theming.withTheme)(TabViewComponent);
100
+ exports.default = _default;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _reactNative = require("react-native");
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ const TabViewItem = _ref => {
11
+ let {
12
+ style,
13
+ children
14
+ } = _ref;
15
+ return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
16
+ style: [styles.parentContainer, style]
17
+ }, children);
18
+ };
19
+ const styles = _reactNative.StyleSheet.create({
20
+ parentContainer: {
21
+ flex: 1
22
+ }
23
+ });
24
+ var _default = TabViewItem;
25
+ exports.default = _default;
@@ -0,0 +1,20 @@
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
+ var _TabView = _interopRequireDefault(require("./TabView"));
19
+ var _TabViewItem = _interopRequireDefault(require("./TabViewItem"));
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -339,6 +339,18 @@ Object.defineProperty(exports, "SwitchRow", {
339
339
  return _Switch.SwitchRow;
340
340
  }
341
341
  });
342
+ Object.defineProperty(exports, "TabView", {
343
+ enumerable: true,
344
+ get: function () {
345
+ return _TabView.TabView;
346
+ }
347
+ });
348
+ Object.defineProperty(exports, "TabViewItem", {
349
+ enumerable: true,
350
+ get: function () {
351
+ return _TabView.TabViewItem;
352
+ }
353
+ });
342
354
  Object.defineProperty(exports, "TextField", {
343
355
  enumerable: true,
344
356
  get: function () {
@@ -414,6 +426,7 @@ var _Swiper = require("./components/Swiper");
414
426
  var _Layout = require("./components/Layout");
415
427
  var _index = require("./components/RadioButton/index");
416
428
  var _DeckSwiper = require("./components/DeckSwiper");
429
+ var _TabView = require("./components/TabView");
417
430
  var _DatePicker = _interopRequireDefault(require("./components/DatePicker/DatePicker"));
418
431
  var _Picker = _interopRequireDefault(require("./components/Picker/Picker"));
419
432
  var _ProgressBar = _interopRequireDefault(require("./components/ProgressBar"));
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SEED_DATA = void 0;
7
+ var _types = require("@draftbit/types");
8
+ const SEED_DATA = {
9
+ name: "Tab View",
10
+ tag: "TabView",
11
+ description: "Tab view container",
12
+ category: _types.COMPONENT_TYPES.swiper,
13
+ stylesPanelSections: [..._types.BLOCK_STYLES_SECTIONS, _types.StylesPanelSections.Background],
14
+ triggers: [_types.Triggers.OnIndexChanged, _types.Triggers.OnEndReached],
15
+ props: {
16
+ onIndexChanged: (0, _types.createActionProp)({
17
+ label: "On index changed",
18
+ description: "Action to execute when swipe to new index"
19
+ }),
20
+ onEndReached: (0, _types.createActionProp)({
21
+ label: "On end reached",
22
+ description: "Action to execute when end of swiping reached"
23
+ }),
24
+ tabBarPosition: (0, _types.createTextEnumProp)({
25
+ label: "Tab Bar Position",
26
+ description: "Position of tab bar",
27
+ options: ["top", "bottom"],
28
+ defaultValue: "top"
29
+ }),
30
+ keyboardDismissMode: (0, _types.createTextEnumProp)({
31
+ label: "Keyboard Dismiss Mode",
32
+ description: "Keyboard Dismiss Mode",
33
+ options: ["auto", "on-drag", "none"],
34
+ defaultValue: "auto"
35
+ }),
36
+ swipeEnabled: (0, _types.createStaticBoolProp)({
37
+ label: "Swipe Enabled",
38
+ description: "Whether swiping is enabled or not",
39
+ defaultValue: true
40
+ }),
41
+ scrollEnabled: (0, _types.createStaticBoolProp)({
42
+ label: "Scroll Enabled",
43
+ description: "Whether scrolling of tabs is enabled or not",
44
+ defaultValue: true
45
+ }),
46
+ activeColor: (0, _types.createColorProp)({
47
+ label: "Active Color",
48
+ description: "Color of icon and text of active tab",
49
+ defaultValue: "primary"
50
+ }),
51
+ inactiveColor: (0, _types.createColorProp)({
52
+ label: "Inactive Color",
53
+ description: "Color of icon and text of inactive tab(s)",
54
+ defaultValue: null
55
+ }),
56
+ pressColor: (0, _types.createColorProp)({
57
+ label: "Press Color",
58
+ description: "Color of ripple when pressed (android only)",
59
+ defaultValue: "primary"
60
+ }),
61
+ indicatorColor: (0, _types.createColorProp)({
62
+ label: "Indicator Color",
63
+ description: "Color of indicator",
64
+ defaultValue: "primary"
65
+ }),
66
+ tabsBackgroundColor: (0, _types.createColorProp)({
67
+ label: "Tabs Background Color",
68
+ description: "Background color of tabs container",
69
+ defaultValue: "background"
70
+ })
71
+ }
72
+ };
73
+ exports.SEED_DATA = SEED_DATA;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SEED_DATA = void 0;
7
+ var _types = require("@draftbit/types");
8
+ const SEED_DATA = {
9
+ name: "Tab View Item",
10
+ tag: "TabViewItem",
11
+ description: "Single Tab View item to be used in TabView. Each item represents a single tab and its content",
12
+ category: _types.COMPONENT_TYPES.swiper,
13
+ stylesPanelSections: _types.CONTAINER_COMPONENT_STYLES_SECTIONS,
14
+ layout: {
15
+ flex: 1
16
+ },
17
+ props: {
18
+ title: (0, _types.createTextProp)({
19
+ label: "Title",
20
+ description: "Title of tab item",
21
+ defaultValue: null,
22
+ required: true
23
+ }),
24
+ icon: (0, _types.createIconProp)({
25
+ defaultValue: null,
26
+ required: false
27
+ }),
28
+ accessibilityLabel: (0, _types.createTextProp)({
29
+ label: "Accessibility Label",
30
+ description: "Accessibility Label",
31
+ defaultValue: null
32
+ })
33
+ }
34
+ };
35
+ exports.SEED_DATA = SEED_DATA;
@@ -1,4 +1,3 @@
1
- function _extends() { _extends = Object.assign ? Object.assign.bind() : 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
  import * as React from "react";
3
2
  import { Pressable, StyleSheet, View } from "react-native";
4
3
  import Text from "../Text";
@@ -18,9 +17,10 @@ const AccordionItem = _ref => {
18
17
  textStyles,
19
18
  viewStyles
20
19
  } = extractStyles(style);
21
- return /*#__PURE__*/React.createElement(Pressable, _extends({
22
- style: [styles.container, viewStyles]
23
- }, rest), /*#__PURE__*/React.createElement(View, {
20
+ return /*#__PURE__*/React.createElement(Pressable, {
21
+ style: [styles.container, viewStyles],
22
+ ...rest
23
+ }, /*#__PURE__*/React.createElement(View, {
24
24
  style: styles.row
25
25
  }, icon ? /*#__PURE__*/React.createElement(Icon, {
26
26
  name: icon,
@@ -51,4 +51,25 @@ const styles = StyleSheet.create({
51
51
  justifyContent: "center"
52
52
  }
53
53
  });
54
+ export default withTheme(AccordionItem);xtStyles
55
+ }, label))));
56
+ };
57
+ const styles = StyleSheet.create({
58
+ container: {
59
+ padding: 8
60
+ },
61
+ row: {
62
+ flexDirection: "row",
63
+ alignItems: "center",
64
+ paddingLeft: 8
65
+ },
66
+ item: {
67
+ marginVertical: 6,
68
+ paddingLeft: 8
69
+ },
70
+ content: {
71
+ flex: 1,
72
+ justifyContent: "center"
73
+ }
74
+ });
54
75
  export default withTheme(AccordionItem);
@@ -37,9 +37,6 @@ const isWeb = Platform.OS === "web";
37
37
  const unstyledColor = "rgba(165, 173, 183, 1)";
38
38
  const disabledColor = "rgb(240, 240, 240)";
39
39
  const errorColor = "rgba(255, 69, 100, 1)";
40
-
41
- //Empty string for 'value' is treated as a non-value
42
- //reason: Draftbit uses empty string as initial value for string state*/
43
40
  const Picker = _ref => {
44
41
  var _find$label, _find;
45
42
  let {
@@ -70,12 +67,12 @@ const Picker = _ref => {
70
67
  setPickerVisible(!pickerVisible);
71
68
  };
72
69
  React.useEffect(() => {
73
- if (value != null && value !== "") {
70
+ if (value != null) {
74
71
  setInternalValue(value);
75
72
  }
76
73
  }, [value]);
77
74
  React.useEffect(() => {
78
- if (defaultValue != null && defaultValue !== "") {
75
+ if (defaultValue != null) {
79
76
  setInternalValue(defaultValue);
80
77
  }
81
78
  }, [defaultValue]);
@@ -90,7 +87,11 @@ const Picker = _ref => {
90
87
  Keyboard.dismiss();
91
88
  }
92
89
  }, [pickerVisible, autoDismissKeyboard]);
93
- const pickerOptions = normalizeOptions(options);
90
+ const normalizedOptions = normalizeOptions(options);
91
+ const pickerOptions = placeholder ? [{
92
+ value: placeholder,
93
+ label: placeholder
94
+ }, ...normalizedOptions] : normalizedOptions;
94
95
  const {
95
96
  viewStyles,
96
97
  textStyles
@@ -190,10 +191,10 @@ const Picker = _ref => {
190
191
  } : {})
191
192
  };
192
193
  const handleValueChange = (newValue, itemIndex) => {
193
- if (newValue !== "") {
194
+ if (!placeholder || itemIndex > 0) {
194
195
  onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue, itemIndex);
195
- setInternalValue(newValue);
196
196
  }
197
+ setInternalValue(newValue);
197
198
  };
198
199
  return (
199
200
  /*#__PURE__*/
@@ -0,0 +1,90 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : 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
+ import * as React from "react";
3
+ import { TabView, TabBar, SceneMap } from "react-native-tab-view";
4
+ import TabViewItem from "./TabViewItem";
5
+ import { withTheme } from "../../theming";
6
+ const TabViewComponent = _ref => {
7
+ let {
8
+ Icon,
9
+ onIndexChanged,
10
+ onEndReached,
11
+ tabBarPosition,
12
+ keyboardDismissMode,
13
+ swipeEnabled,
14
+ scrollEnabled,
15
+ activeColor,
16
+ inactiveColor,
17
+ pressColor,
18
+ indicatorColor,
19
+ tabsBackgroundColor,
20
+ style,
21
+ theme,
22
+ children
23
+ } = _ref;
24
+ const [index, setIndex] = React.useState(0);
25
+ const [routes, setRoutes] = React.useState([]);
26
+ const [tabScenes, setTabScenes] = React.useState({});
27
+
28
+ //Populate routes and scenes based on children
29
+ React.useEffect(() => {
30
+ const newRoutes = [];
31
+ const scenes = {};
32
+ React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && child.type === TabViewItem).forEach((item, idx) => {
33
+ const child = item;
34
+ newRoutes.push({
35
+ key: idx.toString(),
36
+ title: child.props.title,
37
+ icon: child.props.icon,
38
+ accessibilityLabel: child.props.accessibilityLabel
39
+ });
40
+ scenes[idx] = () => child;
41
+ });
42
+ setRoutes(newRoutes);
43
+ setTabScenes(scenes);
44
+ }, [children]);
45
+ const indexChangeHandler = i => {
46
+ setIndex(i);
47
+ onIndexChanged === null || onIndexChanged === void 0 ? void 0 : onIndexChanged(i);
48
+ if (i === routes.length) {
49
+ onEndReached === null || onEndReached === void 0 ? void 0 : onEndReached();
50
+ }
51
+ };
52
+ const renderTabBar = props => {
53
+ return /*#__PURE__*/React.createElement(TabBar, _extends({}, props, {
54
+ activeColor: activeColor || theme.colors.primary,
55
+ inactiveColor: inactiveColor || theme.colors.divider,
56
+ pressColor: pressColor || theme.colors.primary,
57
+ scrollEnabled: scrollEnabled,
58
+ indicatorStyle: {
59
+ backgroundColor: indicatorColor || theme.colors.primary
60
+ },
61
+ renderIcon: _ref2 => {
62
+ let {
63
+ route,
64
+ color
65
+ } = _ref2;
66
+ return route !== null && route !== void 0 && route.icon ? /*#__PURE__*/React.createElement(Icon, {
67
+ name: route.icon,
68
+ color: color,
69
+ size: 36
70
+ }) : null;
71
+ },
72
+ style: [{
73
+ backgroundColor: tabsBackgroundColor || theme.colors.background
74
+ }, style]
75
+ }));
76
+ };
77
+ return /*#__PURE__*/React.createElement(TabView, {
78
+ navigationState: {
79
+ index,
80
+ routes
81
+ },
82
+ renderScene: SceneMap(tabScenes),
83
+ renderTabBar: renderTabBar,
84
+ onIndexChange: indexChangeHandler,
85
+ tabBarPosition: tabBarPosition,
86
+ keyboardDismissMode: keyboardDismissMode,
87
+ swipeEnabled: swipeEnabled
88
+ });
89
+ };
90
+ export default withTheme(TabViewComponent);
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import { StyleSheet, View } from "react-native";
3
+
4
+ //Props used by parent (TabView) to create tabs
5
+
6
+ const TabViewItem = _ref => {
7
+ let {
8
+ style,
9
+ children
10
+ } = _ref;
11
+ return /*#__PURE__*/React.createElement(View, {
12
+ style: [styles.parentContainer, style]
13
+ }, children);
14
+ };
15
+ const styles = StyleSheet.create({
16
+ parentContainer: {
17
+ flex: 1
18
+ }
19
+ });
20
+ export default TabViewItem;
@@ -0,0 +1,2 @@
1
+ export { default as TabView } from "./TabView";
2
+ export { default as TabViewItem } from "./TabViewItem";
@@ -6,4 +6,5 @@ const DEFAULT_STATUSBAR_HEIGHT_EXPO = expo !== null && expo !== void 0 && expo.C
6
6
  export const APPROX_STATUSBAR_HEIGHT = Platform.select({
7
7
  android: DEFAULT_STATUSBAR_HEIGHT_EXPO,
8
8
  ios: Platform.Version < 11 ? DEFAULT_STATUSBAR_HEIGHT_EXPO : 0
9
+ });O : 0
9
10
  });
@@ -32,6 +32,7 @@ export { Swiper, SwiperItem } from "./components/Swiper";
32
32
  export { Center, Circle, Square, Row, Stack, Spacer } from "./components/Layout";
33
33
  export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup } from "./components/RadioButton/index";
34
34
  export { DeckSwiper, DeckSwiperCard } from "./components/DeckSwiper";
35
+ export { TabView, TabViewItem } from "./components/TabView";
35
36
 
36
37
  /* Deprecated: Fix or Delete! */
37
38
  export { default as DatePicker } from "./components/DatePicker/DatePicker";
@@ -0,0 +1,66 @@
1
+ import { COMPONENT_TYPES, createTextEnumProp, createColorProp, BLOCK_STYLES_SECTIONS, StylesPanelSections, Triggers, createActionProp, createStaticBoolProp } from "@draftbit/types";
2
+ export const SEED_DATA = {
3
+ name: "Tab View",
4
+ tag: "TabView",
5
+ description: "Tab view container",
6
+ category: COMPONENT_TYPES.swiper,
7
+ stylesPanelSections: [...BLOCK_STYLES_SECTIONS, StylesPanelSections.Background],
8
+ triggers: [Triggers.OnIndexChanged, Triggers.OnEndReached],
9
+ props: {
10
+ onIndexChanged: createActionProp({
11
+ label: "On index changed",
12
+ description: "Action to execute when swipe to new index"
13
+ }),
14
+ onEndReached: createActionProp({
15
+ label: "On end reached",
16
+ description: "Action to execute when end of swiping reached"
17
+ }),
18
+ tabBarPosition: createTextEnumProp({
19
+ label: "Tab Bar Position",
20
+ description: "Position of tab bar",
21
+ options: ["top", "bottom"],
22
+ defaultValue: "top"
23
+ }),
24
+ keyboardDismissMode: createTextEnumProp({
25
+ label: "Keyboard Dismiss Mode",
26
+ description: "Keyboard Dismiss Mode",
27
+ options: ["auto", "on-drag", "none"],
28
+ defaultValue: "auto"
29
+ }),
30
+ swipeEnabled: createStaticBoolProp({
31
+ label: "Swipe Enabled",
32
+ description: "Whether swiping is enabled or not",
33
+ defaultValue: true
34
+ }),
35
+ scrollEnabled: createStaticBoolProp({
36
+ label: "Scroll Enabled",
37
+ description: "Whether scrolling of tabs is enabled or not",
38
+ defaultValue: true
39
+ }),
40
+ activeColor: createColorProp({
41
+ label: "Active Color",
42
+ description: "Color of icon and text of active tab",
43
+ defaultValue: "primary"
44
+ }),
45
+ inactiveColor: createColorProp({
46
+ label: "Inactive Color",
47
+ description: "Color of icon and text of inactive tab(s)",
48
+ defaultValue: null
49
+ }),
50
+ pressColor: createColorProp({
51
+ label: "Press Color",
52
+ description: "Color of ripple when pressed (android only)",
53
+ defaultValue: "primary"
54
+ }),
55
+ indicatorColor: createColorProp({
56
+ label: "Indicator Color",
57
+ description: "Color of indicator",
58
+ defaultValue: "primary"
59
+ }),
60
+ tabsBackgroundColor: createColorProp({
61
+ label: "Tabs Background Color",
62
+ description: "Background color of tabs container",
63
+ defaultValue: "background"
64
+ })
65
+ }
66
+ };