@draftbit/core 46.8.2-079b9d.2 → 46.8.2-0a0db3.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 (79) hide show
  1. package/lib/commonjs/components/Accordion/AccordionItem.js +23 -4
  2. package/lib/commonjs/components/AnimatedCircularProgress.js +12 -1
  3. package/lib/commonjs/components/AspectRatio.js +17 -1
  4. package/lib/commonjs/components/Banner.js +23 -4
  5. package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js +23 -5
  6. package/lib/commonjs/components/Checkbox/context.js +1 -1
  7. package/lib/commonjs/components/CircleImage.js +15 -1
  8. package/lib/commonjs/components/CircularProgress.js +26 -8
  9. package/lib/commonjs/components/Container.js +15 -4
  10. package/lib/commonjs/components/DeprecatedCardWrapper.js +15 -1
  11. package/lib/commonjs/components/DeprecatedFAB.js +21 -3
  12. package/lib/commonjs/components/Divider.js +14 -1
  13. package/lib/commonjs/components/Elevation.js +14 -2
  14. package/lib/commonjs/components/FormRow.js +16 -2
  15. package/lib/commonjs/components/IconButton.js +19 -4
  16. package/lib/commonjs/components/Image.js +17 -2
  17. package/lib/commonjs/components/Layout.js +40 -19
  18. package/lib/commonjs/components/Picker/PickerComponent.web.js +20 -3
  19. package/lib/commonjs/components/Portal/PortalConsumer.js +22 -7
  20. package/lib/commonjs/components/Portal/PortalHost.js +44 -15
  21. package/lib/commonjs/components/Portal/PortalManager.js +34 -8
  22. package/lib/commonjs/components/Pressable.js +15 -2
  23. package/lib/commonjs/components/ProgressBar.js +37 -7
  24. package/lib/commonjs/components/RadioButton/RadioButton.js +13 -2
  25. package/lib/commonjs/components/RadioButton/RadioButtonFieldGroup.js +9 -1
  26. package/lib/commonjs/components/RadioButton/RadioButtonGroup.js +15 -2
  27. package/lib/commonjs/components/RadioButton/RadioButtonRow.js +23 -5
  28. package/lib/commonjs/components/ScreenContainer.js +24 -6
  29. package/lib/commonjs/components/StarRating.js +23 -4
  30. package/lib/commonjs/components/StepIndicator.js +57 -18
  31. package/lib/commonjs/components/Surface.js +14 -2
  32. package/lib/commonjs/components/Switch.js +19 -10
  33. package/lib/commonjs/components/TabView/TabView.js +132 -0
  34. package/lib/commonjs/components/TabView/TabViewItem.js +25 -0
  35. package/lib/commonjs/components/TabView/index.js +20 -0
  36. package/lib/commonjs/components/Text.js +50 -4
  37. package/lib/commonjs/components/TextField.js +76 -28
  38. package/lib/commonjs/components/Touchable.js +15 -2
  39. package/lib/commonjs/index.js +13 -0
  40. package/lib/commonjs/mappings/FlashList.js +8 -2
  41. package/lib/commonjs/mappings/TabView.js +77 -0
  42. package/lib/commonjs/mappings/TabViewItem.js +37 -0
  43. package/lib/module/components/StepIndicator.js +18 -58
  44. package/lib/module/components/TabView/TabView.js +113 -0
  45. package/lib/module/components/TabView/TabViewItem.js +20 -0
  46. package/lib/module/components/TabView/index.js +2 -0
  47. package/lib/module/index.js +1 -0
  48. package/lib/module/mappings/FlashList.js +9 -3
  49. package/lib/module/mappings/TabView.js +70 -0
  50. package/lib/module/mappings/TabViewItem.js +30 -0
  51. package/lib/typescript/src/components/TabView/TabView.d.ts +26 -0
  52. package/lib/typescript/src/components/TabView/TabView.d.ts.map +1 -0
  53. package/lib/typescript/src/components/TabView/TabViewItem.d.ts +11 -0
  54. package/lib/typescript/src/components/TabView/TabViewItem.d.ts.map +1 -0
  55. package/lib/typescript/src/components/TabView/index.d.ts +3 -0
  56. package/lib/typescript/src/components/TabView/index.d.ts.map +1 -0
  57. package/lib/typescript/src/index.d.ts +1 -0
  58. package/lib/typescript/src/index.d.ts.map +1 -1
  59. package/lib/typescript/src/mappings/FlashList.d.ts +6 -0
  60. package/lib/typescript/src/mappings/FlashList.d.ts.map +1 -1
  61. package/lib/typescript/src/mappings/TabView.d.ts +126 -0
  62. package/lib/typescript/src/mappings/TabView.d.ts.map +1 -0
  63. package/lib/typescript/src/mappings/TabViewItem.d.ts +25 -0
  64. package/lib/typescript/src/mappings/TabViewItem.d.ts.map +1 -0
  65. package/package.json +5 -3
  66. package/src/components/TabView/TabView.js +58 -0
  67. package/src/components/TabView/TabView.tsx +151 -0
  68. package/src/components/TabView/TabViewItem.js +11 -0
  69. package/src/components/TabView/TabViewItem.tsx +25 -0
  70. package/src/components/TabView/index.js +2 -0
  71. package/src/components/TabView/index.tsx +2 -0
  72. package/src/index.js +1 -0
  73. package/src/index.tsx +2 -0
  74. package/src/mappings/FlashList.js +9 -9
  75. package/src/mappings/FlashList.ts +9 -9
  76. package/src/mappings/TabView.js +76 -0
  77. package/src/mappings/TabView.ts +86 -0
  78. package/src/mappings/TabViewItem.js +30 -0
  79. package/src/mappings/TabViewItem.ts +38 -0
@@ -10,10 +10,6 @@ var _theming = require("../theming");
10
10
  var _utilities = require("../utilities");
11
11
  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); }
12
12
  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; }
13
- 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); }
14
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
16
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
17
13
  const AnimatedText = _reactNative.Animated.createAnimatedComponent(_reactNative.Text);
18
14
  const FOCUS_ANIMATION_DURATION = 150;
19
15
  const BLUR_ANIMATION_DURATION = 180;
@@ -21,7 +17,7 @@ const ICON_SIZE = 24;
21
17
  class TextField extends React.Component {
22
18
  constructor() {
23
19
  super(...arguments);
24
- _defineProperty(this, "state", {
20
+ this.state = {
25
21
  nativeProps: {},
26
22
  labeled: new _reactNative.Animated.Value(this.props.value || this.props.error ? 0 : 1),
27
23
  focused: false,
@@ -30,47 +26,46 @@ class TextField extends React.Component {
30
26
  measured: false,
31
27
  width: 0
32
28
  }
33
- });
34
- _defineProperty(this, "_timer", setTimeout(() => {}, 0));
35
- _defineProperty(this, "_showPlaceholder", () => {
29
+ };
30
+ this._timer = setTimeout(() => {}, 0);
31
+ this._showPlaceholder = () => {
36
32
  clearTimeout(this._timer);
37
-
38
33
  // Set the placeholder in a delay to offset the label animation
39
34
  // If we show it immediately, they'll overlap and look ugly
40
35
  this._timer = setTimeout(() => this.setState({
41
36
  placeholder: this.props.placeholder
42
37
  }), 50);
43
- });
44
- _defineProperty(this, "_hidePlaceholder", () => this.setState({
38
+ };
39
+ this._hidePlaceholder = () => this.setState({
45
40
  placeholder: ""
46
- }));
47
- _defineProperty(this, "_restoreLabel", () => _reactNative.Animated.timing(this.state.labeled, {
41
+ });
42
+ this._restoreLabel = () => _reactNative.Animated.timing(this.state.labeled, {
48
43
  toValue: 1,
49
44
  duration: FOCUS_ANIMATION_DURATION,
50
45
  useNativeDriver: true
51
- }).start());
52
- _defineProperty(this, "_minmizeLabel", () => _reactNative.Animated.timing(this.state.labeled, {
46
+ }).start();
47
+ this._minmizeLabel = () => _reactNative.Animated.timing(this.state.labeled, {
53
48
  toValue: 0,
54
49
  duration: BLUR_ANIMATION_DURATION,
55
50
  useNativeDriver: true
56
- }).start());
57
- _defineProperty(this, "_handleFocus", () => {
51
+ }).start();
52
+ this._handleFocus = () => {
58
53
  if (this.props.disabled) {
59
54
  return;
60
55
  }
61
56
  this.setState({
62
57
  focused: true
63
58
  });
64
- });
65
- _defineProperty(this, "_handleBlur", () => {
59
+ };
60
+ this._handleBlur = () => {
66
61
  if (this.props.disabled) {
67
62
  return;
68
63
  }
69
64
  this.setState({
70
65
  focused: false
71
66
  });
72
- });
73
- _defineProperty(this, "_handleChangeText", value => {
67
+ };
68
+ this._handleChangeText = value => {
74
69
  if (this.props.disabled) {
75
70
  return;
76
71
  }
@@ -85,8 +80,8 @@ class TextField extends React.Component {
85
80
  });
86
81
  this.props.onChangeText && this.props.onChangeText(value.nativeEvent.text);
87
82
  }
88
- });
89
- _defineProperty(this, "_root", undefined);
83
+ };
84
+ this._root = undefined;
90
85
  }
91
86
  static getDerivedStateFromProps(nextProps, prevState) {
92
87
  return {
@@ -173,7 +168,9 @@ class TextField extends React.Component {
173
168
  roundness,
174
169
  disabledOpacity
175
170
  },
176
- render = props => /*#__PURE__*/React.createElement(_reactNative.TextInput, props),
171
+ render = props => /*#__PURE__*/React.createElement(_reactNative.TextInput, {
172
+ ...props
173
+ }),
177
174
  ...rest
178
175
  } = this.props;
179
176
  const MINIMIZED_LABEL_Y_OFFSET = -(typography.caption.lineHeight + 4);
@@ -313,9 +310,10 @@ class TextField extends React.Component {
313
310
  } = _reactNative.StyleSheet.flatten(style || {});
314
311
  return /*#__PURE__*/React.createElement(_reactNative.View, {
315
312
  style: [styles.container, styleProp]
316
- }, leftIconName && leftIconMode === "outset" ? /*#__PURE__*/React.createElement(Icon, _extends({}, leftIconProps, {
313
+ }, leftIconName && leftIconMode === "outset" ? /*#__PURE__*/React.createElement(Icon, {
314
+ ...leftIconProps,
317
315
  style: leftIconStyle
318
- })) : null, /*#__PURE__*/React.createElement(_reactNative.View, {
316
+ }) : null, /*#__PURE__*/React.createElement(_reactNative.View, {
319
317
  style: (0, _utilities.applyStyles)([containerStyle], {
320
318
  height: style === null || style === void 0 ? void 0 : style.height,
321
319
  backgroundColor: bgColor,
@@ -383,9 +381,10 @@ class TextField extends React.Component {
383
381
  style: {
384
382
  justifyContent: type === "solid" ? "center" : undefined
385
383
  }
386
- }, /*#__PURE__*/React.createElement(Icon, _extends({}, leftIconProps, {
384
+ }, /*#__PURE__*/React.createElement(Icon, {
385
+ ...leftIconProps,
387
386
  style: leftIconStyle
388
- }))) : null, render({
387
+ })) : null, render({
389
388
  ref: c => {
390
389
  this._root = c;
391
390
  },
@@ -423,6 +422,55 @@ class TextField extends React.Component {
423
422
  }
424
423
  var _default = (0, _theming.withTheme)(TextField);
425
424
  exports.default = _default;
425
+ const styles = _reactNative.StyleSheet.create({
426
+ container: {
427
+ alignSelf: "stretch"
428
+ },
429
+ placeholder: {
430
+ position: "absolute",
431
+ left: 0
432
+ },
433
+ underline: {
434
+ position: "absolute",
435
+ left: 0,
436
+ right: 0,
437
+ bottom: 0,
438
+ height: 2
439
+ },
440
+ input: {
441
+ flexGrow: 1,
442
+ justifyContent: "center",
443
+ textAlignVertical: "center",
444
+ margin: 0,
445
+ textAlign: _reactNative.I18nManager.isRTL ? "right" : "left"
446
+ }
447
+ });_handleFocus,
448
+ onBlur: this._handleBlur,
449
+ underlineColorAndroid: "transparent",
450
+ style: inputStyles,
451
+ ...rest,
452
+ ...this.state.nativeProps,
453
+ value: this.state.value
454
+ })), rightIconName ? /*#__PURE__*/React.createElement(Icon, {
455
+ name: rightIconName,
456
+ size: ICON_SIZE,
457
+ color: colors.light,
458
+ style: {
459
+ position: "absolute",
460
+ right: 16,
461
+ marginTop: type === "solid" ? MINIMIZED_LABEL_FONT_SIZE + 4 : 16
462
+ }
463
+ }) : null, assistiveText ? /*#__PURE__*/React.createElement(_reactNative.Text, {
464
+ style: [{
465
+ color: error ? colors.error : colors.light,
466
+ marginTop: 8,
467
+ marginLeft: assistiveTextLeftMargin
468
+ }]
469
+ }, assistiveText) : null);
470
+ }
471
+ }
472
+ var _default = (0, _theming.withTheme)(TextField);
473
+ exports.default = _default;
426
474
  const styles = _reactNative.StyleSheet.create({
427
475
  container: {
428
476
  alignSelf: "stretch"
@@ -7,7 +7,6 @@ exports.default = Touchable;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _reactNative = require("react-native");
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- 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); }
11
10
  function Touchable(_ref) {
12
11
  let {
13
12
  children,
@@ -20,8 +19,22 @@ function Touchable(_ref) {
20
19
  style,
21
20
  ...props
22
21
  } = _ref;
23
- return /*#__PURE__*/_react.default.createElement(_reactNative.Pressable, _extends({
22
+ return /*#__PURE__*/_react.default.createElement(_reactNative.Pressable, {
24
23
  disabled: disabled,
24
+ onPress: onPress,
25
+ delayLongPress: delayLongPress ? delayLongPress : 500,
26
+ hitSlop: hitSlop ? hitSlop : 8,
27
+ style: _ref2 => {
28
+ let {
29
+ pressed
30
+ } = _ref2;
31
+ return [{
32
+ opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1
33
+ }, style];
34
+ },
35
+ ...props
36
+ }, children);
37
+ } disabled: disabled,
25
38
  onPress: onPress,
26
39
  delayLongPress: delayLongPress ? delayLongPress : 500,
27
40
  hitSlop: hitSlop ? hitSlop : 8,
@@ -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"));
@@ -11,7 +11,10 @@ const SEED_DATA = [{
11
11
  description: "Masonry Flashlist by Shopify",
12
12
  packageName: "@shopify/flash-list",
13
13
  category: _types.COMPONENT_TYPES.data,
14
- stylesPanelSections: [_types.StylesPanelSections.Background, _types.StylesPanelSections.MarginsAndPaddings],
14
+ stylesPanelSections: _types.CONTAINER_COMPONENT_STYLES_SECTIONS,
15
+ layout: {
16
+ flex: 1
17
+ },
15
18
  triggers: [_types.Triggers.OnRefresh, _types.Triggers.OnEndReached],
16
19
  props: {
17
20
  onRefresh: (0, _types.createActionProp)(),
@@ -58,7 +61,10 @@ const SEED_DATA = [{
58
61
  description: "Flashlist by Shopify",
59
62
  packageName: "@shopify/flash-list",
60
63
  category: _types.COMPONENT_TYPES.data,
61
- stylesPanelSections: [_types.StylesPanelSections.Background, _types.StylesPanelSections.MarginsAndPaddings],
64
+ stylesPanelSections: _types.CONTAINER_COMPONENT_STYLES_SECTIONS,
65
+ layout: {
66
+ flex: 1
67
+ },
62
68
  triggers: [_types.Triggers.OnRefresh, _types.Triggers.OnEndReached],
63
69
  props: {
64
70
  onRefresh: (0, _types.createActionProp)(),
@@ -0,0 +1,77 @@
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.StylesPanelSections.Size, _types.StylesPanelSections.MarginsAndPaddings, _types.StylesPanelSections.Position, _types.StylesPanelSections.Effects, _types.StylesPanelSections.LayoutSelectedItem, _types.StylesPanelSections.Background, _types.StylesPanelSections.Typography],
14
+ layout: {
15
+ flex: 1
16
+ },
17
+ triggers: [_types.Triggers.OnIndexChanged, _types.Triggers.OnEndReached],
18
+ props: {
19
+ onIndexChanged: (0, _types.createActionProp)({
20
+ label: "On index changed",
21
+ description: "Action to execute when swipe to new index"
22
+ }),
23
+ onEndReached: (0, _types.createActionProp)({
24
+ label: "On end reached",
25
+ description: "Action to execute when end of swiping reached"
26
+ }),
27
+ tabBarPosition: (0, _types.createTextEnumProp)({
28
+ label: "Tab Bar Position",
29
+ description: "Position of tab bar",
30
+ options: ["top", "bottom"],
31
+ defaultValue: "top"
32
+ }),
33
+ keyboardDismissMode: (0, _types.createTextEnumProp)({
34
+ label: "Keyboard Dismiss Mode",
35
+ description: "Keyboard Dismiss Mode",
36
+ options: ["auto", "on-drag", "none"],
37
+ defaultValue: "auto"
38
+ }),
39
+ swipeEnabled: (0, _types.createStaticBoolProp)({
40
+ label: "Swipe Enabled",
41
+ description: "Whether swiping is enabled or not",
42
+ defaultValue: true
43
+ }),
44
+ scrollEnabled: (0, _types.createStaticBoolProp)({
45
+ label: "Tab Scroll Enabled",
46
+ description: "Whether scrolling of tabs is enabled or not",
47
+ defaultValue: false
48
+ }),
49
+ activeColor: (0, _types.createColorProp)({
50
+ label: "Active Color",
51
+ description: "Color of icon and text of active tab",
52
+ defaultValue: "primary"
53
+ }),
54
+ inactiveColor: (0, _types.createColorProp)({
55
+ label: "Inactive Color",
56
+ description: "Color of icon and text of inactive tab(s)",
57
+ defaultValue: null
58
+ }),
59
+ pressColor: (0, _types.createColorProp)({
60
+ label: "Press Color",
61
+ description: "Color of ripple when pressed",
62
+ defaultValue: "primary",
63
+ group: _types.GROUPS.android
64
+ }),
65
+ indicatorColor: (0, _types.createColorProp)({
66
+ label: "Indicator Color",
67
+ description: "Color of indicator",
68
+ defaultValue: "primary"
69
+ }),
70
+ tabsBackgroundColor: (0, _types.createColorProp)({
71
+ label: "Tabs Background Color",
72
+ description: "Background color of tabs container",
73
+ defaultValue: "background"
74
+ })
75
+ }
76
+ };
77
+ exports.SEED_DATA = SEED_DATA;
@@ -0,0 +1,37 @@
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: "Title",
22
+ required: true,
23
+ group: _types.GROUPS.basic
24
+ }),
25
+ icon: (0, _types.createIconProp)({
26
+ defaultValue: null,
27
+ required: false
28
+ }),
29
+ accessibilityLabel: (0, _types.createTextProp)({
30
+ label: "Accessibility Label",
31
+ description: "Accessibility Label",
32
+ defaultValue: null,
33
+ group: _types.GROUPS.accessibility
34
+ })
35
+ }
36
+ };
37
+ exports.SEED_DATA = SEED_DATA;
@@ -1,3 +1,6 @@
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1
4
  // @ts-nocheck
2
5
  import React, { Component } from "react";
3
6
  import { View, Text, StyleSheet, Animated, TouchableWithoutFeedback } from "react-native";
@@ -9,7 +12,7 @@ const STEP_STATUS = {
9
12
  export default class StepIndicator extends Component {
10
13
  constructor(props) {
11
14
  super(props);
12
- this.renderProgressBarBackground = () => {
15
+ _defineProperty(this, "renderProgressBarBackground", () => {
13
16
  const {
14
17
  stepCount,
15
18
  direction
@@ -52,8 +55,8 @@ export default class StepIndicator extends Component {
52
55
  },
53
56
  style: progressBarBackgroundStyle
54
57
  });
55
- };
56
- this.renderProgressBar = () => {
58
+ });
59
+ _defineProperty(this, "renderProgressBar", () => {
57
60
  const {
58
61
  stepCount,
59
62
  direction
@@ -83,8 +86,8 @@ export default class StepIndicator extends Component {
83
86
  return /*#__PURE__*/React.createElement(Animated.View, {
84
87
  style: progressBarStyle
85
88
  });
86
- };
87
- this.renderStepIndicator = () => {
89
+ });
90
+ _defineProperty(this, "renderStepIndicator", () => {
88
91
  let steps = [];
89
92
  const {
90
93
  stepCount,
@@ -115,8 +118,8 @@ export default class StepIndicator extends Component {
115
118
  height: this.state.customStyles.currentStepIndicatorSize
116
119
  }]
117
120
  }, steps);
118
- };
119
- this.renderStepLabels = () => {
121
+ });
122
+ _defineProperty(this, "renderStepLabels", () => {
120
123
  const {
121
124
  labels,
122
125
  direction,
@@ -158,8 +161,8 @@ export default class StepIndicator extends Component {
158
161
  alignItems: this.state.customStyles.labelAlign
159
162
  }]
160
163
  }, labelViews);
161
- };
162
- this.renderStep = position => {
164
+ });
165
+ _defineProperty(this, "renderStep", position => {
163
166
  const {
164
167
  renderStepIndicator
165
168
  } = this.props;
@@ -226,8 +229,8 @@ export default class StepIndicator extends Component {
226
229
  }) : /*#__PURE__*/React.createElement(Text, {
227
230
  style: indicatorLabelStyle
228
231
  }, "".concat(position + 1)));
229
- };
230
- this.getStepStatus = stepPosition => {
232
+ });
233
+ _defineProperty(this, "getStepStatus", stepPosition => {
231
234
  const {
232
235
  currentPosition
233
236
  } = this.props;
@@ -238,8 +241,8 @@ export default class StepIndicator extends Component {
238
241
  } else {
239
242
  return STEP_STATUS.UNFINISHED;
240
243
  }
241
- };
242
- this.onCurrentPositionChanged = position => {
244
+ });
245
+ _defineProperty(this, "onCurrentPositionChanged", position => {
243
246
  let {
244
247
  stepCount
245
248
  } = this.props;
@@ -259,7 +262,7 @@ export default class StepIndicator extends Component {
259
262
  toValue: this.state.customStyles.currentStepIndicatorSize / 2,
260
263
  duration: 100
261
264
  })])]).start();
262
- };
265
+ });
263
266
  const defaultStyles = {
264
267
  stepIndicatorSize: 30,
265
268
  currentStepIndicatorSize: 40,
@@ -325,6 +328,7 @@ export default class StepIndicator extends Component {
325
328
  // ),
326
329
  // }));
327
330
  // }
331
+
328
332
  if (prevProps.currentPosition !== this.props.currentPosition) {
329
333
  this.onCurrentPositionChanged(this.props.currentPosition);
330
334
  }
@@ -365,50 +369,6 @@ const styles = StyleSheet.create({
365
369
  justifyContent: "center"
366
370
  }
367
371
  });
368
- StepIndicator.defaultProps = {
369
- currentPosition: 0,
370
- stepCount: 5,
371
- customStyles: {},
372
- direction: "horizontal"
373
- };rrentPositionChanged(this.props.currentPosition);
374
- }
375
- }
376
- }
377
- const styles = StyleSheet.create({
378
- container: {
379
- backgroundColor: "transparent"
380
- },
381
- stepIndicatorContainer: {
382
- flexDirection: "row",
383
- alignItems: "center",
384
- justifyContent: "space-around",
385
- backgroundColor: "transparent"
386
- },
387
- stepLabelsContainer: {
388
- justifyContent: "space-around"
389
- },
390
- step: {
391
- alignItems: "center",
392
- justifyContent: "center",
393
- zIndex: 2
394
- },
395
- stepContainer: {
396
- flex: 1,
397
- flexDirection: "row",
398
- alignItems: "center",
399
- justifyContent: "center"
400
- },
401
- stepLabel: {
402
- fontSize: 12,
403
- textAlign: "center",
404
- fontWeight: "500"
405
- },
406
- stepLabelItem: {
407
- flex: 1,
408
- alignItems: "center",
409
- justifyContent: "center"
410
- }
411
- });
412
372
  StepIndicator.defaultProps = {
413
373
  currentPosition: 0,
414
374
  stepCount: 5,
@@ -0,0 +1,113 @@
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 { StyleSheet } from "react-native";
4
+ import { TabView, TabBar, SceneMap } from "react-native-tab-view";
5
+ import { withTheme } from "../../theming";
6
+ import { extractStyles } from "../../utilities";
7
+ const TabViewComponent = _ref => {
8
+ let {
9
+ Icon,
10
+ onIndexChanged,
11
+ onEndReached,
12
+ tabBarPosition,
13
+ keyboardDismissMode,
14
+ swipeEnabled,
15
+ scrollEnabled,
16
+ activeColor,
17
+ inactiveColor,
18
+ pressColor,
19
+ indicatorColor,
20
+ tabsBackgroundColor,
21
+ style,
22
+ theme,
23
+ children
24
+ } = _ref;
25
+ const [index, setIndex] = React.useState(0);
26
+ const [routes, setRoutes] = React.useState([]);
27
+ const [tabScenes, setTabScenes] = React.useState({});
28
+ const {
29
+ textStyles,
30
+ viewStyles
31
+ } = extractStyles(style);
32
+
33
+ //Check type of child using props
34
+ //Regular '.type' cannot work because Draftbit strips the type in Draft view
35
+ const instanceOfTabViewItemProps = object => {
36
+ return "title" in object;
37
+ };
38
+
39
+ //Populate routes and scenes based on children
40
+ React.useEffect(() => {
41
+ const newRoutes = [];
42
+ const scenes = {};
43
+ React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && instanceOfTabViewItemProps(child.props)).forEach((item, idx) => {
44
+ const child = item;
45
+ newRoutes.push({
46
+ key: idx.toString(),
47
+ title: child.props.title,
48
+ icon: child.props.icon,
49
+ accessibilityLabel: child.props.accessibilityLabel
50
+ });
51
+ scenes[idx] = () => child;
52
+ });
53
+ setRoutes(newRoutes);
54
+ setTabScenes(scenes);
55
+ }, [children]);
56
+ const indexChangeHandler = i => {
57
+ setIndex(i);
58
+ onIndexChanged === null || onIndexChanged === void 0 ? void 0 : onIndexChanged(i);
59
+ if (i === routes.length) {
60
+ onEndReached === null || onEndReached === void 0 ? void 0 : onEndReached();
61
+ }
62
+ };
63
+ const renderTabBar = props => {
64
+ return /*#__PURE__*/React.createElement(TabBar, _extends({}, props, {
65
+ activeColor: activeColor || theme.colors.primary,
66
+ inactiveColor: inactiveColor || theme.colors.divider,
67
+ pressColor: pressColor || theme.colors.primary,
68
+ scrollEnabled: scrollEnabled,
69
+ indicatorStyle: {
70
+ backgroundColor: indicatorColor || theme.colors.primary
71
+ },
72
+ labelStyle: textStyles,
73
+ renderIcon: _ref2 => {
74
+ let {
75
+ route,
76
+ color
77
+ } = _ref2;
78
+ return route !== null && route !== void 0 && route.icon ? /*#__PURE__*/React.createElement(Icon, {
79
+ name: route.icon,
80
+ color: color,
81
+ size: 16
82
+ }) : null;
83
+ },
84
+ style: {
85
+ backgroundColor: tabsBackgroundColor || theme.colors.background
86
+ }
87
+ }));
88
+ };
89
+
90
+ //Cannot render TabView without at least one tab
91
+ if (!routes.length) {
92
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
93
+ }
94
+ return /*#__PURE__*/React.createElement(TabView, {
95
+ style: [styles.tabView, viewStyles],
96
+ navigationState: {
97
+ index,
98
+ routes
99
+ },
100
+ renderScene: SceneMap(tabScenes),
101
+ renderTabBar: renderTabBar,
102
+ onIndexChange: indexChangeHandler,
103
+ tabBarPosition: tabBarPosition,
104
+ keyboardDismissMode: keyboardDismissMode,
105
+ swipeEnabled: swipeEnabled
106
+ });
107
+ };
108
+ const styles = StyleSheet.create({
109
+ tabView: {
110
+ flex: 1
111
+ }
112
+ });
113
+ 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";
@@ -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";