@draftbit/core 43.4.5-d442fc.1 → 43.4.5-d68594.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/lib/commonjs/components/Elevation.js +3 -14
  2. package/lib/commonjs/components/Elevation.js.map +1 -1
  3. package/lib/commonjs/components/FAB.js +19 -5
  4. package/lib/commonjs/components/FAB.js.map +1 -1
  5. package/lib/commonjs/components/FieldSearchBarFull.js.map +1 -1
  6. package/lib/commonjs/components/RadioButton/RadioButton.js +9 -8
  7. package/lib/commonjs/components/RadioButton/RadioButton.js.map +1 -1
  8. package/lib/commonjs/components/RadioButton/RadioButtonGroup.js +13 -12
  9. package/lib/commonjs/components/RadioButton/RadioButtonGroup.js.map +1 -1
  10. package/lib/commonjs/components/RadioButton/RadioButtonRow.js +9 -6
  11. package/lib/commonjs/components/RadioButton/RadioButtonRow.js.map +1 -1
  12. package/lib/commonjs/components/RadioButton/index.js.map +1 -1
  13. package/lib/commonjs/index.js +0 -14
  14. package/lib/commonjs/index.js.map +1 -1
  15. package/lib/commonjs/mappings/RowHeadlineImageCaption.js.map +1 -1
  16. package/lib/commonjs/mappings/ToggleButton.js.map +1 -1
  17. package/lib/commonjs/utilities.js +13 -0
  18. package/lib/commonjs/utilities.js.map +1 -1
  19. package/lib/module/components/ProgressBar.js +4 -6
  20. package/lib/module/components/ProgressBar.js.map +1 -1
  21. package/lib/module/components/RadioButton/RadioButton.js +8 -8
  22. package/lib/module/components/RadioButton/RadioButton.js.map +1 -1
  23. package/lib/module/components/RadioButton/RadioButtonGroup.js +12 -12
  24. package/lib/module/components/RadioButton/RadioButtonGroup.js.map +1 -1
  25. package/lib/module/components/RadioButton/RadioButtonRow.js +10 -7
  26. package/lib/module/components/RadioButton/RadioButtonRow.js.map +1 -1
  27. package/lib/module/index.js +0 -1
  28. package/lib/module/index.js.map +1 -1
  29. package/lib/module/utilities.js +10 -0
  30. package/lib/module/utilities.js.map +1 -1
  31. package/lib/typescript/src/components/RadioButton/RadioButton.d.ts +2 -2
  32. package/lib/typescript/src/components/RadioButton/RadioButtonGroup.d.ts +2 -2
  33. package/lib/typescript/src/components/RadioButton/RadioButtonRow.d.ts +1 -1
  34. package/lib/typescript/src/index.d.ts +0 -1
  35. package/lib/typescript/src/utilities.d.ts +1 -0
  36. package/package.json +2 -4
  37. package/src/components/RadioButton/RadioButton.js +7 -6
  38. package/src/components/RadioButton/RadioButton.tsx +11 -12
  39. package/src/components/RadioButton/RadioButtonGroup.js +10 -10
  40. package/src/components/RadioButton/RadioButtonGroup.tsx +18 -17
  41. package/src/components/RadioButton/RadioButtonRow.js +8 -5
  42. package/src/components/RadioButton/RadioButtonRow.tsx +12 -10
  43. package/src/index.js +0 -1
  44. package/src/index.tsx +0 -1
  45. package/src/utilities.js +12 -0
  46. package/src/utilities.ts +11 -0
  47. package/lib/commonjs/components/TabView/TabView.js +0 -103
  48. package/lib/commonjs/components/TabView/TabView.js.map +0 -1
  49. package/lib/commonjs/components/TabView/TabViewItem.js +0 -27
  50. package/lib/commonjs/components/TabView/TabViewItem.js.map +0 -1
  51. package/lib/commonjs/components/TabView/index.js +0 -24
  52. package/lib/commonjs/components/TabView/index.js.map +0 -1
  53. package/lib/commonjs/mappings/TabView.js +0 -80
  54. package/lib/commonjs/mappings/TabView.js.map +0 -1
  55. package/lib/module/components/TabView/TabView.js +0 -88
  56. package/lib/module/components/TabView/TabView.js.map +0 -1
  57. package/lib/module/components/TabView/TabViewItem.js +0 -19
  58. package/lib/module/components/TabView/TabViewItem.js.map +0 -1
  59. package/lib/module/components/TabView/index.js +0 -3
  60. package/lib/module/components/TabView/index.js.map +0 -1
  61. package/lib/module/mappings/TabView.js +0 -71
  62. package/lib/module/mappings/TabView.js.map +0 -1
  63. package/lib/typescript/src/components/TabView/TabView.d.ts +0 -19
  64. package/lib/typescript/src/components/TabView/TabViewItem.d.ts +0 -10
  65. package/lib/typescript/src/components/TabView/index.d.ts +0 -2
  66. package/lib/typescript/src/mappings/TabView.d.ts +0 -111
  67. package/src/components/TabView/TabView.js +0 -33
  68. package/src/components/TabView/TabView.tsx +0 -97
  69. package/src/components/TabView/TabViewItem.js +0 -5
  70. package/src/components/TabView/TabViewItem.tsx +0 -21
  71. package/src/components/TabView/index.js +0 -2
  72. package/src/components/TabView/index.ts +0 -2
  73. package/src/mappings/TabView.js +0 -73
  74. package/src/mappings/TabView.ts +0 -80
@@ -1,5 +1,3 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
1
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
2
 
5
3
  import React, { Component } from "react";
@@ -79,7 +77,6 @@ export default class ProgressBar extends Component {
79
77
  Animated[animationType](this.state.progress, { ...animationConfig,
80
78
  toValue: progress,
81
79
  velocity: 0,
82
- //adjust this value if animation fails - velocity is required
83
80
  useNativeDriver
84
81
  }).start();
85
82
  } else {
@@ -150,10 +147,11 @@ export default class ProgressBar extends Component {
150
147
  })
151
148
  }]
152
149
  };
153
- return /*#__PURE__*/React.createElement(View, _extends({
150
+ return /*#__PURE__*/React.createElement(View, {
154
151
  style: [containerStyle, style],
155
- onLayout: this.handleLayout
156
- }, restProps), /*#__PURE__*/React.createElement(Animated.View, {
152
+ onLayout: this.handleLayout,
153
+ ...restProps
154
+ }, /*#__PURE__*/React.createElement(Animated.View, {
157
155
  style: progressStyle
158
156
  }), children);
159
157
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["ProgressBar.tsx"],"names":["React","Component","Animated","Easing","View","I18nManager","INDETERMINATE_WIDTH_FACTOR","BAR_WIDTH_ZERO_POSITION","ProgressBar","constructor","props","event","width","onLayout","setState","nativeEvent","layout","progress","progressP","indeterminate","Math","min","max","state","Value","animationValue","componentDidMount","animate","componentDidUpdate","prevProps","useNativeDriver","animationType","animationConfig","bounciness","animated","spring","toValue","start","velocity","setValue","indeterminateAnimationDuration","timing","duration","easing","linear","isInteraction","endState","finished","render","borderColor","borderRadius","borderWidth","children","color","style","unfilledColor","restProps","innerWidth","containerStyle","overflow","backgroundColor","progressStyle","height","transform","translateX","interpolate","inputRange","outputRange","isRTL","scaleX","handleLayout"],"mappings":";;;;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SACEC,QADF,EAEEC,MAFF,EAGEC,IAHF,EAIEC,WAJF,QASO,cATP;AAWA,MAAMC,0BAA0B,GAAG,GAAnC;AACA,MAAMC,uBAAuB,GAC3BD,0BAA0B,IAAI,IAAIA,0BAAR,CAD5B;AA4BA,eAAe,MAAME,WAAN,SAA0BP,SAA1B,CAAkD;AAC/DQ,EAAAA,WAAW,CAACC,KAAD,EAAe;AACxB,UAAMA,KAAN;;AADwB,0CA6DVC,KAAD,IAA8B;AAC3C,YAAM;AAAEC,QAAAA,KAAK,GAAG,GAAV;AAAeC,QAAAA;AAAf,UAA4B,KAAKH,KAAvC;;AACA,UAAI,CAACE,KAAL,EAAY;AACV,aAAKE,QAAL,CAAc;AAAEF,UAAAA,KAAK,EAAED,KAAK,CAACI,WAAN,CAAkBC,MAAlB,CAAyBJ;AAAlC,SAAd;AACD;;AACD,UAAIC,QAAJ,EAAc;AACZA,QAAAA,QAAQ,CAACF,KAAD,CAAR;AACD;AACF,KArEyB;;AAExB,UAAM;AAAEM,MAAAA,QAAQ,EAAEC,SAAS,GAAG,CAAxB;AAA2BC,MAAAA,aAAa,GAAG;AAA3C,QAAqDT,KAA3D;AACA,UAAMO,QAAQ,GAAGG,IAAI,CAACC,GAAL,CAASD,IAAI,CAACE,GAAL,CAASJ,SAAT,EAAoB,CAApB,CAAT,EAAiC,CAAjC,CAAjB;AACA,SAAKK,KAAL,GAAa;AACXX,MAAAA,KAAK,E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E,oBAAC,IAAD;AACE,MAAA,KAAK,EAAE,CAACT,cAAD,EAAiBJ,KAAjB,CADT;AAEE,MAAA,QAAQ,EAAE,KAAKgB;AAFjB,OAGMd,SAHN,gBAKE,oBAAC,QAAD,CAAU,IAAV;AAAe,MAAA,KAAK,EAAEK;AAAtB,MALF,EAMGT,QANH,CADF;AAUD;;AApJ8D","sourcesContent":["import React, { Component } from \"react\";\nimport {\n Animated,\n Easing,\n View,\n I18nManager,\n ViewProps,\n StyleProp,\n ViewStyle,\n LayoutChangeEvent,\n} from \"react-native\";\n\nconst INDETERMINATE_WIDTH_FACTOR = 0.3;\nconst BAR_WIDTH_ZERO_POSITION =\n INDETERMINATE_WIDTH_FACTOR / (1 + INDETERMINATE_WIDTH_FACTOR);\n\ntype Props = {\n borderColor?: string;\n borderRadius?: number;\n borderWidth?: number;\n children?: React.ReactNode;\n color?: string;\n height?: number;\n style?: StyleProp<ViewStyle>;\n unfilledColor?: string;\n width?: number;\n animated?: boolean;\n indeterminate?: boolean;\n indeterminateAnimationDuration?: number;\n progress?: number;\n useNativeDriver?: boolean;\n animationConfig?: Animated.AnimationConfig;\n animationType?: \"decay\" | \"timing\" | \"spring\";\n} & ViewProps;\n\ninterface State {\n width: number;\n progress: Animated.Value;\n animationValue: Animated.Value;\n}\n\nexport default class ProgressBar extends Component<Props, State> {\n constructor(props: Props) {\n super(props);\n const { progress: progressP = 0, indeterminate = false } = props;\n const progress = Math.min(Math.max(progressP, 0), 1);\n this.state = {\n width: 0,\n progress: new Animated.Value(\n indeterminate ? INDETERMINATE_WIDTH_FACTOR : progress\n ),\n animationValue: new Animated.Value(BAR_WIDTH_ZERO_POSITION),\n };\n }\n\n componentDidMount() {\n const { indeterminate = false } = this.props;\n if (indeterminate) {\n this.animate();\n }\n }\n\n componentDidUpdate(prevProps: Props) {\n const {\n indeterminate = false,\n useNativeDriver = false,\n progress: progressP = 0,\n animationType = \"spring\",\n animationConfig = { bounciness: 0 },\n animated = true,\n } = this.props;\n\n if (prevProps.indeterminate !== indeterminate) {\n if (indeterminate) {\n this.animate();\n } else {\n Animated.spring(this.state.animationValue, {\n toValue: BAR_WIDTH_ZERO_POSITION,\n useNativeDriver,\n }).start();\n }\n }\n if (\n prevProps.indeterminate !== indeterminate ||\n prevProps.progress !== progressP\n ) {\n const progress = this.props.indeterminate\n ? INDETERMINATE_WIDTH_FACTOR\n : Math.min(Math.max(progressP, 0), 1);\n\n if (animated) {\n Animated[animationType](this.state.progress, {\n ...animationConfig,\n toValue: progress,\n velocity: 0, //adjust this value if animation fails - velocity is required\n useNativeDriver,\n }).start();\n } else {\n this.state.progress.setValue(progress);\n }\n }\n }\n\n handleLayout = (event: LayoutChangeEvent) => {\n const { width = 150, onLayout } = this.props;\n if (!width) {\n this.setState({ width: event.nativeEvent.layout.width });\n }\n if (onLayout) {\n onLayout(event);\n }\n };\n\n animate() {\n const { useNativeDriver = false, indeterminateAnimationDuration = 1000 } =\n this.props;\n this.state.animationValue.setValue(0);\n Animated.timing(this.state.animationValue, {\n toValue: 1,\n duration: indeterminateAnimationDuration,\n easing: Easing.linear,\n isInteraction: false,\n useNativeDriver,\n }).start((endState) => {\n if (endState.finished) {\n this.animate();\n }\n });\n }\n\n render() {\n const {\n borderColor,\n borderRadius = 4,\n borderWidth = 1,\n children,\n color = \"rgba(0, 122, 255, 1)\",\n style,\n unfilledColor,\n width = 150,\n ...restProps\n } = this.props;\n\n const innerWidth = Math.max(0, width || this.state.width) - borderWidth * 2;\n const containerStyle: StyleProp<ViewStyle> = {\n width,\n borderWidth,\n borderColor: borderColor || color,\n borderRadius,\n overflow: \"hidden\",\n backgroundColor: unfilledColor,\n };\n const progressStyle = {\n backgroundColor: color,\n // Always take up full height of container.\n height: \"100%\",\n transform: [\n {\n translateX: this.state.animationValue.interpolate({\n inputRange: [0, 1],\n outputRange: [innerWidth * -INDETERMINATE_WIDTH_FACTOR, innerWidth],\n }),\n },\n {\n translateX: this.state.progress.interpolate({\n inputRange: [0, 1],\n outputRange: [innerWidth / (I18nManager.isRTL ? 2 : -2), 0],\n }),\n },\n {\n // Interpolation a temp workaround for https://github.com/facebook/react-native/issues/6278\n scaleX: this.state.progress.interpolate({\n inputRange: [0, 1],\n outputRange: [0.0001, 1],\n }),\n },\n ],\n };\n\n return (\n <View\n style={[containerStyle, style]}\n onLayout={this.handleLayout}\n {...restProps}\n >\n <Animated.View style={progressStyle} />\n {children}\n </View>\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["ProgressBar.js"],"names":["React","Component","Animated","Easing","View","I18nManager","INDETERMINATE_WIDTH_FACTOR","BAR_WIDTH_ZERO_POSITION","ProgressBar","constructor","props","event","width","onLayout","setState","nativeEvent","layout","progress","progressP","indeterminate","Math","min","max","state","Value","animationValue","componentDidMount","animate","componentDidUpdate","prevProps","useNativeDriver","animationType","animationConfig","bounciness","animated","spring","toValue","start","velocity","setValue","indeterminateAnimationDuration","timing","duration","easing","linear","isInteraction","endState","finished","render","borderColor","borderRadius","borderWidth","children","color","style","unfilledColor","restProps","innerWidth","containerStyle","overflow","backgroundColor","progressStyle","height","transform","translateX","interpolate","inputRange","outputRange","isRTL","scaleX","createElement","handleLayout"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SAASC,QAAT,EAAmBC,MAAnB,EAA2BC,IAA3B,EAAiCC,WAAjC,QAAqD,cAArD;AACA,MAAMC,0BAA0B,GAAG,GAAnC;AACA,MAAMC,uBAAuB,GAAGD,0BAA0B,IAAI,IAAIA,0BAAR,CAA1D;AACA,eAAe,MAAME,WAAN,SAA0BP,SAA1B,CAAoC;AAC/CQ,EAAAA,WAAW,CAACC,KAAD,EAAQ;AACf,UAAMA,KAAN;;AADe,0CA+CHC,KAAD,IAAW;AACtB,YAAM;AAAEC,QAAAA,KAAK,GAAG,GAAV;AAAeC,QAAAA;AAAf,UAA4B,KAAKH,KAAvC;;AACA,UAAI,CAACE,KAAL,EAAY;AACR,aAAKE,QAAL,CAAc;AAA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AX,CAAoBgD,WAApB,CAAgC;AACxCC,UAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ,CAD4B;AAExCC,UAAAA,WAAW,EAAE,CAACV,UAAU,IAAIpD,WAAW,CAAC+D,KAAZ,GAAoB,CAApB,GAAwB,CAAC,CAA7B,CAAX,EAA4C,CAA5C;AAF2B,SAAhC;AADhB,OAPO,EAaP;AACI;AACAC,QAAAA,MAAM,EAAE,KAAK9C,KAAL,CAAWN,QAAX,CAAoBgD,WAApB,CAAgC;AACpCC,UAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ,CADwB;AAEpCC,UAAAA,WAAW,EAAE,CAAC,MAAD,EAAS,CAAT;AAFuB,SAAhC;AAFZ,OAbO;AAJO,KAAtB;AA0BA,wBAAQnE,KAAK,CAACsE,aAAN,CAAoBlE,IAApB,EAA0B;AAAEkD,MAAAA,KAAK,EAAE,CAACI,cAAD,EAAiBJ,KAAjB,CAAT;AAAkCzC,MAAAA,QAAQ,EAAE,KAAK0D,YAAjD;AAA+D,SAAGf;AAAlE,KAA1B,eACJxD,KAAK,CAACsE,aAAN,CAAoBpE,QAAQ,CAACE,IAA7B,EAAmC;AAAEkD,MAAAA,KAAK,EAAEO;AAAT,KAAnC,CADI,EAEJT,QAFI,CAAR;AAGH;;AAhH8C","sourcesContent":["import React, { Component } from \"react\";\nimport { Animated, Easing, View, I18nManager, } from \"react-native\";\nconst INDETERMINATE_WIDTH_FACTOR = 0.3;\nconst BAR_WIDTH_ZERO_POSITION = INDETERMINATE_WIDTH_FACTOR / (1 + INDETERMINATE_WIDTH_FACTOR);\nexport default class ProgressBar extends Component {\n constructor(props) {\n super(props);\n const { progress: progressP = 0, indeterminate = false } = props;\n const progress = Math.min(Math.max(progressP, 0), 1);\n this.state = {\n width: 0,\n progress: new Animated.Value(indeterminate ? INDETERMINATE_WIDTH_FACTOR : progress),\n animationValue: new Animated.Value(BAR_WIDTH_ZERO_POSITION),\n };\n }\n componentDidMount() {\n const { indeterminate = false } = this.props;\n if (indeterminate) {\n this.animate();\n }\n }\n componentDidUpdate(prevProps) {\n const { indeterminate = false, useNativeDriver = false, progress: progressP = 0, animationType = \"spring\", animationConfig = { bounciness: 0 }, animated = true, } = this.props;\n if (prevProps.indeterminate !== indeterminate) {\n if (indeterminate) {\n this.animate();\n }\n else {\n Animated.spring(this.state.animationValue, {\n toValue: BAR_WIDTH_ZERO_POSITION,\n useNativeDriver,\n }).start();\n }\n }\n if (prevProps.indeterminate !== indeterminate ||\n prevProps.progress !== progressP) {\n const progress = this.props.indeterminate\n ? INDETERMINATE_WIDTH_FACTOR\n : Math.min(Math.max(progressP, 0), 1);\n if (animated) {\n Animated[animationType](this.state.progress, {\n ...animationConfig,\n toValue: progress,\n velocity: 0,\n useNativeDriver,\n }).start();\n }\n else {\n this.state.progress.setValue(progress);\n }\n }\n }\n handleLayout = (event) => {\n const { width = 150, onLayout } = this.props;\n if (!width) {\n this.setState({ width: event.nativeEvent.layout.width });\n }\n if (onLayout) {\n onLayout(event);\n }\n };\n animate() {\n const { useNativeDriver = false, indeterminateAnimationDuration = 1000 } = this.props;\n this.state.animationValue.setValue(0);\n Animated.timing(this.state.animationValue, {\n toValue: 1,\n duration: indeterminateAnimationDuration,\n easing: Easing.linear,\n isInteraction: false,\n useNativeDriver,\n }).start((endState) => {\n if (endState.finished) {\n this.animate();\n }\n });\n }\n render() {\n const { borderColor, borderRadius = 4, borderWidth = 1, children, color = \"rgba(0, 122, 255, 1)\", style, unfilledColor, width = 150, ...restProps } = this.props;\n const innerWidth = Math.max(0, width || this.state.width) - borderWidth * 2;\n const containerStyle = {\n width,\n borderWidth,\n borderColor: borderColor || color,\n borderRadius,\n overflow: \"hidden\",\n backgroundColor: unfilledColor,\n };\n const progressStyle = {\n backgroundColor: color,\n // Always take up full height of container.\n height: \"100%\",\n transform: [\n {\n translateX: this.state.animationValue.interpolate({\n inputRange: [0, 1],\n outputRange: [innerWidth * -INDETERMINATE_WIDTH_FACTOR, innerWidth],\n }),\n },\n {\n translateX: this.state.progress.interpolate({\n inputRange: [0, 1],\n outputRange: [innerWidth / (I18nManager.isRTL ? 2 : -2), 0],\n }),\n },\n {\n // Interpolation a temp workaround for https://github.com/facebook/react-native/issues/6278\n scaleX: this.state.progress.interpolate({\n inputRange: [0, 1],\n outputRange: [0.0001, 1],\n }),\n },\n ],\n };\n return (React.createElement(View, { style: [containerStyle, style], onLayout: this.handleLayout, ...restProps },\n React.createElement(Animated.View, { style: progressStyle }),\n children));\n }\n}\n"]}
@@ -3,6 +3,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
3
3
  import * as React from "react";
4
4
  import Config from "../Config";
5
5
  import IconButton from "../IconButton";
6
+ import { getValueForRadioButton } from "../../utilities";
6
7
  import { useRadioButtonGroupContext } from "./context";
7
8
 
8
9
  const RadioButton = _ref => {
@@ -10,10 +11,10 @@ const RadioButton = _ref => {
10
11
  Icon,
11
12
  disabled = false,
12
13
  color,
13
- value,
14
+ value = "",
14
15
  selected,
15
16
  unselectedColor,
16
- onPress = () => {},
17
+ onPress,
17
18
  size = Config.radioButtonSize,
18
19
  selectedIcon = "MaterialIcons/radio-button-checked",
19
20
  unselectedIcon = "MaterialIcons/radio-button-unchecked",
@@ -24,16 +25,15 @@ const RadioButton = _ref => {
24
25
  value: contextValue,
25
26
  onValueChange
26
27
  } = useRadioButtonGroupContext();
28
+ const realValue = getValueForRadioButton(value);
29
+ const realContextValue = getValueForRadioButton(contextValue);
30
+ const isSelected = selected !== null && selected !== void 0 ? selected : realContextValue === realValue;
27
31
 
28
32
  const handlePress = () => {
29
- onPress && onPress();
30
-
31
- if (onValueChange && value) {
32
- onValueChange(value);
33
- }
33
+ onPress === null || onPress === void 0 ? void 0 : onPress(realValue);
34
+ onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realValue);
34
35
  };
35
36
 
36
- const isSelected = selected || contextValue != null && contextValue === value;
37
37
  return /*#__PURE__*/React.createElement(IconButton, _extends({
38
38
  Icon: Icon,
39
39
  icon: isSelected ? selectedIcon : unselectedIcon,
@@ -1 +1 @@
1
- {"version":3,"sources":["RadioButton.tsx"],"names":["React","Config","IconButton","useRadioButtonGroupContext","RadioButton","Icon","disabled","color","value","selected","unselectedColor","onPress","size","radioButtonSize","selectedIcon","unselectedIcon","style","rest","contextValue","onValueChange","handlePress","isSelected"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAGA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,UAAP,MAAuB,eAAvB;AACA,SAASC,0BAAT,QAA2C,WAA3C;;AAiBA,MAAMC,WAAuC,GAAG,QAa1C;AAAA,MAb2C;AAC/CC,IAAAA,IAD+C;AAE/CC,IAAAA,QAAQ,GAAG,KAFoC;AAG/CC,IAAAA,KAH+C;AAI/CC,IAAAA,KAJ+C;AAK/CC,IAAAA,QAL+C;AAM/CC,IAAAA,eAN+C;AAO/CC,IAAAA,OAAO,GAAG,MAAM,CAAE,CAP6B;AAQ/CC,IAAAA,IAAI,GAAGX,MAAM,CAACY,eARiC;AAS/CC,IAAAA,YAAY,GAAG,oCATgC;AAU/CC,IAAAA,cAAc,GAAG,sCAV8B;AAW/CC,IAAAA,KAX+C;AAY/C,OAAGC;AAZ4C,GAa3C;AACJ,QAAM;AAAET,IAAAA,KAAK,EAAEU,YAAT;AAAuBC,IAAAA;AAAvB,MAAyChB,0BAA0B,EAAzE;;AAEA,QAAMiB,WAAW,GAAG,MAAM;AACxBT,IAAAA,OAAO,IAAIA,OAAO,EAAlB;;AAEA,QAAIQ,aAAa,IAAIX,KAArB,EAA4B;AAC1BW,MAAAA,aAAa,CAACX,KAAD,CAAb;AACD;AACF,GAND;;AAQA,QAAMa,UAAU,GACdZ,QAAQ,IAAKS,YAAY,IAAI,IAAhB,IAAwBA,YAAY,KAAKV,KADxD;AAGA,sBACE,oBAAC,UAAD;AACE,IAAA,IAAI,EAAEH,IADR;AAEE,IAAA,IAAI,EAAEgB,UAAU,GAAGP,YAAH,GAAkBC,cAFpC;AAGE,IAAA,KAAK,EAAEM,UAAU,GAAGd,KAAH,GAAWG,eAH9B;AAIE,IAAA,QAAQ,EAAEJ,QAJZ;AAKE,IAAA,OAAO,EAAEc,WALX;AAME,IAAA,IAAI,EAAER,IANR;AAOE,IAAA,KAAK,EAAEI;AAPT,KAQMC,IARN,EADF;AAYD,CAvCD;;AAyCA,eAAeb,WAAf","sourcesContent":["import * as React from \"react\";\nimport { StyleProp, ViewStyle } from \"react-native\";\n\nimport Config from \"../Config\";\nimport IconButton from \"../IconButton\";\nimport { useRadioButtonGroupContext } from \"./context\";\n\nimport type { IconSlot } from \"../../interfaces/Icon\";\n\nexport type RadioButtonProps = {\n selected?: boolean;\n disabled?: boolean;\n color?: string;\n value?: string;\n unselectedColor?: string;\n onPress?: () => void;\n style?: StyleProp<ViewStyle>;\n size?: number;\n selectedIcon?: string;\n unselectedIcon?: string;\n} & IconSlot;\n\nconst RadioButton: React.FC<RadioButtonProps> = ({\n Icon,\n disabled = false,\n color,\n value,\n selected,\n unselectedColor,\n onPress = () => {},\n size = Config.radioButtonSize,\n selectedIcon = \"MaterialIcons/radio-button-checked\",\n unselectedIcon = \"MaterialIcons/radio-button-unchecked\",\n style,\n ...rest\n}) => {\n const { value: contextValue, onValueChange } = useRadioButtonGroupContext();\n\n const handlePress = () => {\n onPress && onPress();\n\n if (onValueChange && value) {\n onValueChange(value);\n }\n };\n\n const isSelected =\n selected || (contextValue != null && contextValue === value);\n\n return (\n <IconButton\n Icon={Icon}\n icon={isSelected ? selectedIcon : unselectedIcon}\n color={isSelected ? color : unselectedColor}\n disabled={disabled}\n onPress={handlePress}\n size={size}\n style={style}\n {...rest}\n />\n );\n};\n\nexport default RadioButton;\n"]}
1
+ {"version":3,"sources":["RadioButton.tsx"],"names":["React","Config","IconButton","getValueForRadioButton","useRadioButtonGroupContext","RadioButton","Icon","disabled","color","value","selected","unselectedColor","onPress","size","radioButtonSize","selectedIcon","unselectedIcon","style","rest","contextValue","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AGE,IAAA,KAAK,EAAEO,UAAU,GAAGf,KAAH,GAAWG,eAH9B;AAIE,IAAA,QAAQ,EAAEJ,QAJZ;AAKE,IAAA,OAAO,EAAEiB,WALX;AAME,IAAA,IAAI,EAAEX,IANR;AAOE,IAAA,KAAK,EAAEI;AAPT,KAQMC,IARN,EADF;AAYD,CArCD;;AAuCA,eAAeb,WAAf","sourcesContent":["import * as React from \"react\";\nimport { StyleProp, ViewStyle } from \"react-native\";\n\nimport Config from \"../Config\";\nimport IconButton from \"../IconButton\";\nimport { getValueForRadioButton } from \"../../utilities\";\nimport { useRadioButtonGroupContext } from \"./context\";\n\nimport type { IconSlot } from \"../../interfaces/Icon\";\n\nexport type RadioButtonProps = {\n selected?: boolean;\n disabled?: boolean;\n color?: string;\n value?: string | number;\n unselectedColor?: string;\n onPress?: (value?: string) => void;\n style?: StyleProp<ViewStyle>;\n size?: number;\n selectedIcon?: string;\n unselectedIcon?: string;\n} & IconSlot;\n\nconst RadioButton: React.FC<RadioButtonProps> = ({\n Icon,\n disabled = false,\n color,\n value = \"\",\n selected,\n unselectedColor,\n onPress,\n size = Config.radioButtonSize,\n selectedIcon = \"MaterialIcons/radio-button-checked\",\n unselectedIcon = \"MaterialIcons/radio-button-unchecked\",\n style,\n ...rest\n}) => {\n const { value: contextValue, onValueChange } = useRadioButtonGroupContext();\n\n const realValue = getValueForRadioButton(value);\n const realContextValue = getValueForRadioButton(contextValue);\n const isSelected = selected ?? realContextValue === realValue;\n\n const handlePress = () => {\n onPress?.(realValue);\n onValueChange?.(realValue);\n };\n\n return (\n <IconButton\n Icon={Icon}\n icon={isSelected ? selectedIcon : unselectedIcon}\n color={isSelected ? color : unselectedColor}\n disabled={disabled}\n onPress={handlePress}\n size={size}\n style={style}\n {...rest}\n />\n );\n};\n\nexport default RadioButton;\n"]}
@@ -2,6 +2,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
2
2
 
3
3
  import * as React from "react";
4
4
  import { View } from "react-native";
5
+ import { getValueForRadioButton } from "../../utilities";
5
6
  import { radioButtonGroupContext, Direction } from "./context";
6
7
  const {
7
8
  Provider
@@ -10,28 +11,27 @@ const {
10
11
  const RadioButtonGroup = _ref => {
11
12
  let {
12
13
  direction = Direction.Vertical,
13
- value,
14
- onValueChange = () => {},
15
- defaultValue,
14
+ value = "",
15
+ onValueChange,
16
+ defaultValue = "",
16
17
  style,
17
18
  children,
18
19
  ...rest
19
20
  } = _ref;
20
- const [internalValue, setInternalValue] = React.useState(value || defaultValue);
21
+ const [internalValue, setInternalValue] = React.useState("");
21
22
  React.useEffect(() => {
22
- if (value != null) {
23
- setInternalValue(value);
24
- }
23
+ const realValue = getValueForRadioButton(value);
24
+ setInternalValue(realValue);
25
25
  }, [value]);
26
26
  React.useEffect(() => {
27
- if (defaultValue != null) {
28
- setInternalValue(defaultValue);
29
- }
27
+ const realDefaultValue = getValueForRadioButton(defaultValue);
28
+ setInternalValue(realDefaultValue);
30
29
  }, [defaultValue]);
31
30
 
32
31
  const handleValueChange = newValue => {
33
- setInternalValue(newValue);
34
- onValueChange(newValue);
32
+ const realNewValue = getValueForRadioButton(newValue);
33
+ setInternalValue(realNewValue);
34
+ onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realNewValue);
35
35
  };
36
36
 
37
37
  const _containerStyle = [{
@@ -1 +1 @@
1
- {"version":3,"sources":["RadioButtonGroup.tsx"],"names":["React","View","radioButtonGroupContext","Direction","Provider","RadioButtonGroup","direction","Vertical","value","onValueChange","defaultValue","style","children","rest","internalValue","setInternalValue","useState","useEffect","handleValueChange","newValue","_containerStyle","flexDirection","Horizontal","push","alignItems","minHeight"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,QAA2C,cAA3C;AAEA,SAASC,uBAAT,EAAkCC,SAAlC,QAAmD,WAAnD;AAWA,MAAM;AAAEC,EAAAA;AAAF,IAAeF,uBAArB;;AAEA,MAAMG,gBAAiD,GAAG,QAQpD;AAAA,MAR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EAAE;AACLL,MAAAA,KAAK,EAAEM,aAAa,IAAI,EADnB;AAELL,MAAAA,aAAa,EAAES,iBAFV;AAGLZ,MAAAA;AAHK;AADT,kBAOE,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAEc;AAAb,KAA+BR,QAA/B,CAPF,CADF,CADF;AAaD,CAvDD;;AAyDA,eAAeP,gBAAf","sourcesContent":["import * as React from \"react\";\nimport { View, StyleProp, ViewStyle } from \"react-native\";\nimport type { Theme } from \"../../styles/DefaultTheme\";\nimport { radioButtonGroupContext, Direction } from \"./context\";\nexport interface RadioButtonGroupProps {\n direction?: Direction;\n style?: StyleProp<ViewStyle>;\n value?: string;\n onValueChange?: (value: string) => void;\n defaultValue?: string;\n theme: Theme;\n children: React.ReactNode;\n}\n\nconst { Provider } = radioButtonGroupContext;\n\nconst RadioButtonGroup: React.FC<RadioButtonGroupProps> = ({\n direction = Direction.Vertical,\n value,\n onValueChange = () => {},\n defaultValue,\n style,\n children,\n ...rest\n}) => {\n const [internalValue, setInternalValue] = React.useState<string | undefined>(\n value || defaultValue\n );\n\n React.useEffect(() => {\n if (value != null) {\n setInternalValue(value);\n }\n }, [value]);\n\n React.useEffect(() => {\n if (defaultValue != null) {\n setInternalValue(defaultValue);\n }\n }, [defaultValue]);\n\n const handleValueChange = (newValue: string) => {\n setInternalValue(newValue);\n onValueChange(newValue);\n };\n\n const _containerStyle: StyleProp<ViewStyle> = [\n {\n flexDirection: direction === Direction.Horizontal ? \"row\" : \"column\",\n },\n ];\n\n if (direction !== Direction.Vertical) {\n _containerStyle.push({\n alignItems: \"center\",\n });\n }\n\n return (\n <View style={[{ minHeight: 40 }, style]} {...rest}>\n <Provider\n value={{\n value: internalValue || \"\",\n onValueChange: handleValueChange,\n direction,\n }}\n >\n <View style={_containerStyle}>{children}</View>\n </Provider>\n </View>\n );\n};\n\nexport default RadioButtonGroup;\n"]}
1
+ {"version":3,"sources":["RadioButtonGroup.tsx"],"names":["React","View","getValueForRadioButton","radioButtonGroupContext","Direction","Provider","RadioButtonGroup","direction","Vertical","value","onValueChange","defaultValue","style","children","rest","internalValue","setInternalValue","useState","useEffect","realValue","realDefaultValue","handleValueChange","newValue","realNewValue","_containerStyle","flexDirection","Horizontal","push","alignItems","minHeight"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,QAA2C,cAA3C;AAEA,SAASC,sBAAT,QAAuC,iBAAvC;AACA,SAASC,uBAAT,EAAkCC,SAAlC,QAAmD,WAAnD;AAWA,MAAM;AAAEC,EAAAA;AAAF,IAAeF,uBAArB;;AAEA,MAAMG,gBAAiD,GAAG,QAQpD;AAAA,MARqD;AACzDC,IAAAA,SAAS,GAAGH,SAAS,CAACI,QADmC;AAEzDC,IAAAA,KAAK,GAAG,EAFiD;AAGzDC,IAAAA,aAHyD;AAIzDC,IAAAA,YAAY,GAAG,EAJ0C;AAKzDC,IAAAA,KALyD;AAMzDC,IAAAA,QANyD;AAOzD,OAAGC;AAPsD,GAQrD;AACJ,QAAM,CAACC,aAAD,EAAgBC,gBAAhB,IAAoChB,KAAK,CAACiB,QAAN,CAAuB,EAAvB,CAA1C;AAEAjB,EAAAA,KAAK,CAACkB,SAAN,CAAgB,MAAM;AACpB,UAAMC,SAAS,GAAGjB,sBAAsB,CAACO,KAAD,CAAxC;AAEAO,IAAAA,gBAAgB,CAACG,SAAD,CAAhB;AACD,GAJD,EAIG,CAACV,KAAD,CAJH;AAMAT,EAAAA,KAAK,CAACkB,SAAN,CAAgB,MAAM;AACpB,UAAME,gBAAgB,GAAGlB,sBAAsB,CAACS,YAAD,CAA/C;AAEAK,IAAAA,gBAAgB,CAACI,gBAAD,CAAhB;AACD,GAJD,EAIG,CAACT,YAAD,CAJH;;AAMA,QAAMU,iBAAiB,GAAIC,QAAD,IAA+B;AACvD,UAAMC,YAAY,GAAGrB,sBAAsB,CAACoB,QAAD,CAA3C;AAEAN,IAAAA,gBAAgB,CAACO,YAAD,CAAhB;AACAb,IAAAA,aAAa,SAAb,IAAAA,aAAa,WAAb,YAAAA,aAAa,CAAGa,YAAH,CAAb;AACD,GALD;;AAOA,QAAMC,eAAqC,GAAG,CAC5C;AACEC,IAAAA,aAAa,EAAElB,SAAS,KAAKH,SAAS,CAACsB,UAAxB,GAAqC,KAArC,GAA6C;AAD9D,GAD4C,CAA9C;;AAMA,MAAInB,SAAS,KAAKH,SAAS,CAACI,QAA5B,EAAsC;AACpCgB,IAAAA,eAAe,CAACG,IAAhB,CAAqB;AACnBC,MAAAA,UAAU,EAAE;AADO,KAArB;AAGD;;AAED,sBACE,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAE,CAAC;AAAEC,MAAAA,SAAS,EAAE;AAAb,KAAD,EAAoBjB,KAApB;AAAb,KAA6CE,IAA7C,gBACE,oBAAC,QAAD;AACE,IAAA,KAAK,EAAE;AACLL,MAAAA,KAAK,EAAEM,aAAa,IAAI,EADnB;AAELL,MAAAA,aAAa,EAAEW,iBAFV;AAGLd,MAAAA;AAHK;AADT,kBAOE,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAEiB;AAAb,KAA+BX,QAA/B,CAPF,CADF,CADF;AAaD,CAvDD;;AAyDA,eAAeP,gBAAf","sourcesContent":["import * as React from \"react\";\nimport { View, StyleProp, ViewStyle } from \"react-native\";\nimport type { Theme } from \"../../styles/DefaultTheme\";\nimport { getValueForRadioButton } from \"../../utilities\";\nimport { radioButtonGroupContext, Direction } from \"./context\";\nexport interface RadioButtonGroupProps {\n direction?: Direction;\n style?: StyleProp<ViewStyle>;\n value: string;\n onValueChange?: (value: string) => void;\n defaultValue?: string | number;\n theme: Theme;\n children: React.ReactNode;\n}\n\nconst { Provider } = radioButtonGroupContext;\n\nconst RadioButtonGroup: React.FC<RadioButtonGroupProps> = ({\n direction = Direction.Vertical,\n value = \"\",\n onValueChange,\n defaultValue = \"\",\n style,\n children,\n ...rest\n}) => {\n const [internalValue, setInternalValue] = React.useState<string>(\"\");\n\n React.useEffect(() => {\n const realValue = getValueForRadioButton(value);\n\n setInternalValue(realValue);\n }, [value]);\n\n React.useEffect(() => {\n const realDefaultValue = getValueForRadioButton(defaultValue);\n\n setInternalValue(realDefaultValue);\n }, [defaultValue]);\n\n const handleValueChange = (newValue: string | number) => {\n const realNewValue = getValueForRadioButton(newValue);\n\n setInternalValue(realNewValue);\n onValueChange?.(realNewValue);\n };\n\n const _containerStyle: StyleProp<ViewStyle> = [\n {\n flexDirection: direction === Direction.Horizontal ? \"row\" : \"column\",\n },\n ];\n\n if (direction !== Direction.Vertical) {\n _containerStyle.push({\n alignItems: \"center\",\n });\n }\n\n return (\n <View style={[{ minHeight: 40 }, style]} {...rest}>\n <Provider\n value={{\n value: internalValue || \"\",\n onValueChange: handleValueChange,\n direction,\n }}\n >\n <View style={_containerStyle}>{children}</View>\n </Provider>\n </View>\n );\n};\n\nexport default RadioButtonGroup;\n"]}
@@ -7,7 +7,7 @@ import Text from "../Text";
7
7
  import { useRadioButtonGroupContext } from "./context";
8
8
  import { Direction as GroupDirection } from "./context";
9
9
  import Touchable from "../Touchable";
10
- import { extractStyles } from "../../utilities";
10
+ import { extractStyles, getValueForRadioButton } from "../../utilities";
11
11
  export let Direction;
12
12
 
13
13
  (function (Direction) {
@@ -39,10 +39,10 @@ const RadioButtonRow = _ref => {
39
39
  let {
40
40
  Icon,
41
41
  label,
42
- value,
42
+ value = "",
43
43
  color,
44
44
  unselectedColor,
45
- onPress = () => {},
45
+ onPress,
46
46
  labelContainerStyle,
47
47
  labelStyle,
48
48
  radioButtonStyle,
@@ -57,10 +57,13 @@ const RadioButtonRow = _ref => {
57
57
  onValueChange,
58
58
  direction: parentDirection
59
59
  } = useRadioButtonGroupContext();
60
+ const realValue = getValueForRadioButton(value);
61
+ const realContextValue = getValueForRadioButton(contextValue);
62
+ const isSelected = selected !== null && selected !== void 0 ? selected : realContextValue === realValue;
60
63
 
61
64
  const handlePress = () => {
62
- onPress(value);
63
- onValueChange && onValueChange(value);
65
+ onPress === null || onPress === void 0 ? void 0 : onPress(realValue);
66
+ onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realValue);
64
67
  };
65
68
 
66
69
  const {
@@ -84,10 +87,10 @@ const RadioButtonRow = _ref => {
84
87
  }
85
88
  }, /*#__PURE__*/React.createElement(RadioButton, {
86
89
  Icon: Icon,
87
- selected: selected || contextValue != null && contextValue === value,
90
+ selected: isSelected,
91
+ value: realValue,
88
92
  color: color,
89
93
  unselectedColor: unselectedColor,
90
- onPress: handlePress,
91
94
  style: radioButtonStyle
92
95
  })));
93
96
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["RadioButtonRow.tsx"],"names":["React","StyleSheet","View","Platform","RadioButton","Text","useRadioButtonGroupContext","Direction","GroupDirection","Touchable","extractStyles","getRadioButtonAlignment","parentDirection","direction","Horizontal","Row","RowReverse","renderLabel","value","labelStyle","textStyle","RadioButtonRow","Icon","label","color","unselectedColor","onPress","labelContainerStyle","radioButtonStyle","selected","disabled","style","rest","contextValue","onValueChange","handlePress","textStyles","viewStyles","styles","mainParent","flexDirection","alignItems","flex","create","justifyContent","paddingStart","minHeight","paddingEnd","select","web","cursor","userSelect"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAGEC,UAHF,EAKEC,IALF,EAMEC,QANF,QAOO,cAPP;AAQA,OAAOC,WAAP,MAA8C,eAA9C;AACA,OAAOC,IAAP,MAAiB,SAAjB;AACA,SAASC,0BAAT,QAA2C,WAA3C;AAEA,SAASC,SAAS,IAAIC,cAAtB,QAA4C,WAA5C;AACA,OAAOC,SAAP,MAAsB,cAAtB;AACA,SAASC,aAAT,QAA8B,iBAA9B;AAEA,WAAYH,SAAZ;;WAAYA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,KAAAA,S;;AAiBZ,MAAMI,uBAAuB,GAAG,CAC9BC,eAD8B,EAE9BC,SAF8B,KAG3B;AACH,MAAID,eAAe,KAAKJ,cAAc,CAACM,UAAvC,EAAmD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Q,CAAC6C,MAAT,CAAgB;AACjBC,MAAAA,GAAG,EAAE;AACHC,QAAAA,MAAM,EAAE,SADL;AAEHC,QAAAA,UAAU,EAAE;AAFT;AADY,KAAhB;AAPO,GADmB;AAe/B5B,EAAAA,KAAK,EAAE;AACLmB,IAAAA,IAAI,EAAE;AADD;AAfwB,CAAlB,CAAf;AAoBA,eAAerB,cAAf","sourcesContent":["import * as React from \"react\";\nimport {\n StyleProp,\n ViewStyle,\n StyleSheet,\n TextStyle,\n View,\n Platform,\n} from \"react-native\";\nimport RadioButton, { RadioButtonProps } from \"./RadioButton\";\nimport Text from \"../Text\";\nimport { useRadioButtonGroupContext } from \"./context\";\nimport type { IconSlot } from \"../../interfaces/Icon\";\nimport { Direction as GroupDirection } from \"./context\";\nimport Touchable from \"../Touchable\";\nimport { extractStyles } from \"../../utilities\";\n\nexport enum Direction {\n Row = \"row\",\n RowReverse = \"row-reverse\",\n}\n\nexport interface RadioButtonRowProps extends Omit<RadioButtonProps, \"onPress\"> {\n label: string | React.ReactNode;\n value: string; // A string that this radio button row represents when selected\n color?: string;\n unselectedColor?: string;\n labelContainerStyle: StyleProp<ViewStyle>;\n radioButtonStyle?: StyleProp<ViewStyle>;\n labelStyle?: StyleProp<TextStyle>;\n onPress?: (value: string) => void;\n direction?: Direction;\n}\n\nconst getRadioButtonAlignment = (\n parentDirection: GroupDirection | undefined,\n direction: Direction\n) => {\n if (parentDirection === GroupDirection.Horizontal) {\n return direction === Direction.Row ? \"flex-start\" : \"flex-end\";\n } else if (direction === Direction.RowReverse) {\n return \"flex-start\";\n } else {\n return \"flex-end\";\n }\n};\n\nconst renderLabel = (\n value: string | React.ReactNode,\n labelStyle: StyleProp<TextStyle>,\n textStyle: StyleProp<TextStyle>\n) => {\n if (typeof value === \"string\") {\n return <Text style={[labelStyle, textStyle]}>{value}</Text>;\n } else {\n return <>{value}</>;\n }\n};\n\nconst RadioButtonRow: React.FC<RadioButtonRowProps & IconSlot> = ({\n Icon,\n label,\n value,\n color,\n unselectedColor,\n onPress = () => {},\n labelContainerStyle,\n labelStyle,\n radioButtonStyle,\n direction = Direction.Row,\n selected,\n disabled,\n style,\n ...rest\n}) => {\n const {\n value: contextValue,\n onValueChange,\n direction: parentDirection,\n } = useRadioButtonGroupContext();\n\n const handlePress = () => {\n onPress(value);\n onValueChange && onValueChange(value);\n };\n\n const { textStyles, viewStyles } = extractStyles(style);\n\n return (\n <Touchable\n onPress={handlePress}\n style={[styles.mainParent, { flexDirection: direction }, viewStyles]}\n disabled={disabled}\n {...rest}\n >\n <View\n style={[\n styles.label,\n {\n alignItems: direction === Direction.Row ? \"flex-start\" : \"flex-end\",\n },\n labelContainerStyle,\n ]}\n >\n {renderLabel(label, labelStyle, textStyles)}\n </View>\n <View\n style={{\n flex: 1,\n alignItems: getRadioButtonAlignment(parentDirection, direction),\n }}\n >\n <RadioButton\n Icon={Icon}\n selected={\n selected || (contextValue != null && contextValue === value)\n }\n color={color}\n unselectedColor={unselectedColor}\n onPress={handlePress}\n style={radioButtonStyle}\n />\n </View>\n </Touchable>\n );\n};\n\nconst styles = StyleSheet.create({\n mainParent: {\n alignItems: \"center\",\n justifyContent: \"space-around\",\n paddingStart: 20,\n minHeight: 50,\n paddingEnd: 20,\n flex: 1,\n ...Platform.select({\n web: {\n cursor: \"pointer\",\n userSelect: \"none\",\n },\n }),\n },\n label: {\n flex: 3,\n },\n});\n\nexport default RadioButtonRow;\n"]}
1
+ {"version":3,"sources":["RadioButtonRow.tsx"],"names":["React","StyleSheet","View","Platform","RadioButton","Text","useRadioButtonGroupContext","Direction","GroupDirection","Touchable","extractStyles","getValueForRadioButton","getRadioButtonAlignment","parentDirection","direction","Horizontal","Row","RowReverse","renderLabel","value","labelStyle","textStyle","RadioButtonRow","Icon","label","color","unselectedColor","onPress","labelContainerStyle","radioButtonStyle","selected","disabled","style","rest","contextValue","onValueChange","realValue","realContextValue","isSelected","handlePress","textStyles","viewStyles","styles","mainParent","flexDirection","alignItems","flex","create","justifyCont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AAD3D,KAFK,EAKLY,mBALK;AADT,KASGV,WAAW,CAACM,KAAD,EAAQJ,UAAR,EAAoBoB,UAApB,CATd,CANF,eAiBE,oBAAC,IAAD;AACE,IAAA,KAAK,EAAE;AACLM,MAAAA,IAAI,EAAE,CADD;AAELD,MAAAA,UAAU,EAAEjC,uBAAuB,CAACC,eAAD,EAAkBC,SAAlB;AAF9B;AADT,kBAME,oBAAC,WAAD;AACE,IAAA,IAAI,EAAES,IADR;AAEE,IAAA,QAAQ,EAAEe,UAFZ;AAGE,IAAA,KAAK,EAAEF,SAHT;AAIE,IAAA,KAAK,EAAEX,KAJT;AAKE,IAAA,eAAe,EAAEC,eALnB;AAME,IAAA,KAAK,EAAEG;AANT,IANF,CAjBF,CADF;AAmCD,CApED;;AAsEA,MAAMa,MAAM,GAAGzC,UAAU,CAAC8C,MAAX,CAAkB;AAC/BJ,EAAAA,UAAU,EAAE;AACVE,IAAAA,UAAU,EAAE,QADF;AAEVG,IAAAA,cAAc,EAAE,cAFN;AAGVC,IAAAA,YAAY,EAAE,EAHJ;AAIVC,IAAAA,SAAS,EAAE,EAJD;AAKVC,IAAAA,UAAU,EAAE,EALF;AAMVL,IAAAA,IAAI,EAAE,CANI;AAOV,OAAG3C,QAAQ,CAACiD,MAAT,CAAgB;AACjBC,MAAAA,GAAG,EAAE;AACHC,QAAAA,MAAM,EAAE,SADL;AAEHC,QAAAA,UAAU,EAAE;AAFT;AADY,KAAhB;AAPO,GADmB;AAe/B/B,EAAAA,KAAK,EAAE;AACLsB,IAAAA,IAAI,EAAE;AADD;AAfwB,CAAlB,CAAf;AAoBA,eAAexB,cAAf","sourcesContent":["import * as React from \"react\";\nimport {\n StyleProp,\n ViewStyle,\n StyleSheet,\n TextStyle,\n View,\n Platform,\n} from \"react-native\";\nimport RadioButton, { RadioButtonProps } from \"./RadioButton\";\nimport Text from \"../Text\";\nimport { useRadioButtonGroupContext } from \"./context\";\nimport type { IconSlot } from \"../../interfaces/Icon\";\nimport { Direction as GroupDirection } from \"./context\";\nimport Touchable from \"../Touchable\";\nimport { extractStyles, getValueForRadioButton } from \"../../utilities\";\n\nexport enum Direction {\n Row = \"row\",\n RowReverse = \"row-reverse\",\n}\n\nexport interface RadioButtonRowProps extends Omit<RadioButtonProps, \"onPress\"> {\n label: string | React.ReactNode;\n value: string | number; // A string (or number that will be parsed String(number)) that this radio button row represents when selected\n color?: string;\n unselectedColor?: string;\n labelContainerStyle: StyleProp<ViewStyle>;\n radioButtonStyle?: StyleProp<ViewStyle>;\n labelStyle?: StyleProp<TextStyle>;\n onPress?: (value: string) => void;\n direction?: Direction;\n}\n\nconst getRadioButtonAlignment = (\n parentDirection: GroupDirection | undefined,\n direction: Direction\n) => {\n if (parentDirection === GroupDirection.Horizontal) {\n return direction === Direction.Row ? \"flex-start\" : \"flex-end\";\n } else if (direction === Direction.RowReverse) {\n return \"flex-start\";\n } else {\n return \"flex-end\";\n }\n};\n\nconst renderLabel = (\n value: string | React.ReactNode,\n labelStyle: StyleProp<TextStyle>,\n textStyle: StyleProp<TextStyle>\n) => {\n if (typeof value === \"string\") {\n return <Text style={[labelStyle, textStyle]}>{value}</Text>;\n } else {\n return <>{value}</>;\n }\n};\n\nconst RadioButtonRow: React.FC<RadioButtonRowProps & IconSlot> = ({\n Icon,\n label,\n value = \"\",\n color,\n unselectedColor,\n onPress,\n labelContainerStyle,\n labelStyle,\n radioButtonStyle,\n direction = Direction.Row,\n selected,\n disabled,\n style,\n ...rest\n}) => {\n const {\n value: contextValue,\n onValueChange,\n direction: parentDirection,\n } = useRadioButtonGroupContext();\n\n const realValue = getValueForRadioButton(value);\n const realContextValue = getValueForRadioButton(contextValue);\n const isSelected = selected ?? realContextValue === realValue;\n\n const handlePress = () => {\n onPress?.(realValue);\n onValueChange?.(realValue);\n };\n\n const { textStyles, viewStyles } = extractStyles(style);\n\n return (\n <Touchable\n onPress={handlePress}\n style={[styles.mainParent, { flexDirection: direction }, viewStyles]}\n disabled={disabled}\n {...rest}\n >\n <View\n style={[\n styles.label,\n {\n alignItems: direction === Direction.Row ? \"flex-start\" : \"flex-end\",\n },\n labelContainerStyle,\n ]}\n >\n {renderLabel(label, labelStyle, textStyles)}\n </View>\n <View\n style={{\n flex: 1,\n alignItems: getRadioButtonAlignment(parentDirection, direction),\n }}\n >\n <RadioButton\n Icon={Icon}\n selected={isSelected}\n value={realValue}\n color={color}\n unselectedColor={unselectedColor}\n style={radioButtonStyle}\n />\n </View>\n </Touchable>\n );\n};\n\nconst styles = StyleSheet.create({\n mainParent: {\n alignItems: \"center\",\n justifyContent: \"space-around\",\n paddingStart: 20,\n minHeight: 50,\n paddingEnd: 20,\n flex: 1,\n ...Platform.select({\n web: {\n cursor: \"pointer\",\n userSelect: \"none\",\n },\n }),\n },\n label: {\n flex: 3,\n },\n});\n\nexport default RadioButtonRow;\n"]}
@@ -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! */
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":["injectIcon","withTheme","ThemeProvider","default","Provider","DefaultTheme","Link","ButtonSolid","ButtonOutline","Avatar","AvatarEdit","Card","Carousel","Checkbox","CheckboxGroup","CheckboxRow","CircleImage","Container","Divider","FAB","FieldSearchBarFull","IconButton","Image","NumberInput","ScreenContainer","StarRating","Surface","Switch","SwitchRow","TextField","ToggleButton","Touchable","AccordionGroup","AccordionItem","ActionSheet","ActionSheetItem","ActionSheetCancel","Swiper","SwiperItem","TabView","TabViewItem","Center","Circle","Square","Row","Stack","Spacer","RadioButton","RadioButtonGroup","RadioButtonRow","RadioButtonFieldGroup","Button","CardBlock","CardContainer","CardContainerRating","CardInline","DatePicker","HeaderLarge","HeaderMedium","HeaderOverline","Picker","ProgressBar","ProgressCircle","RowBodyIcon","RowHeadlineImageCaption","RowHeadlineImageIcon","Slider","Stepper","useAuthState"],"mappings":"AAAA,SAASA,UAAT,QAA2B,mBAA3B;AACA,SAASC,SAAT,EAAoBC,aAApB,QAAyC,WAAzC;AACA,SAASC,OAAO,IAAIC,QAApB,QAAoC,YAApC;AACA,SAASD,OAAO,IAAIE,YAApB,QAAwC,uBAAxC;AAEA,SAASC,IAAT,QAAqB,mBAArB;AACA,SAASC,WAAT,EAAsBC,aAAtB,QAA2C,qBAA3C;AACA,SAASL,OAAO,IAAIM,MAApB,QAAkC,0BAAlC;AACA,SAASN,OAAO,IAAIO,UAApB,QAAsC,yBAAtC;AACA,SAASP,OAAO,IAAIQ,IAApB,QAAgC,mBAAhC;AACA,SAASR,OAAO,IAAIS,QAApB,QAAoC,uBAApC;AACA,SAASC,QAAT,EAAmBC,aAAnB,EAAkCC,WAAlC,QAAqD,uBAArD;AACA,SAASZ,OAAO,IAAIa,WAApB,QAAuC,0BAAvC;AACA,SAASb,OAAO,IAAIc,SAApB,QAAqC,wBAArC;AACA,SAASd,OAAO,IAAIe,OAApB,QAAmC,sBAAnC;AACA,SAASf,OAAO,IAAIgB,GAApB,QAA+B,kBAA/B;AACA,SAAShB,OAAO,IAAIiB,kBAApB,QAA8C,iCAA9C;AACA,SAASjB,OAAO,IAAIkB,UAApB,QAAsC,yBAAtC;AACA,SAASlB,OAAO,IAAImB,KAApB,QAAiC,oBAAjC;AACA,SAASnB,OAAO,IAAIoB,WAApB,QAAuC,0BAAvC;AACA,SAASpB,OAAO,IAAIqB,eAApB,QAA2C,8BAA3C;AACA,SAASrB,OAAO,IAAIsB,UAApB,QAAsC,yBAAtC;AACA,SAAStB,OAAO,IAAIuB,OAApB,QAAmC,sBAAnC;AACA,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BAApB,QAAmD,sCAAnD;AACA,SAAS7D,OAAO,IAAI8D,oBAApB,QAAgD,mCAAhD;AACA,SAAS9D,OAAO,IAAI+D,MAApB,QAAkC,qBAAlC;AACA,SAAS/D,OAAO,IAAIgE,OAApB,QAAmC,sBAAnC;AACA,SAASC,YAAT,QAA6B,2BAA7B","sourcesContent":["export { injectIcon } from \"./interfaces/Icon\";\nexport { withTheme, ThemeProvider } from \"./theming\";\nexport { default as Provider } from \"./Provider\";\nexport { default as DefaultTheme } from \"./styles/DefaultTheme\";\n\nexport { Link } from \"./components/Text\";\nexport { ButtonSolid, ButtonOutline } from \"./components/Button\";\nexport { default as Avatar } from \"./components/CircleImage\";\nexport { default as AvatarEdit } from \"./components/AvatarEdit\";\nexport { default as Card } from \"./components/Card\";\nexport { default as Carousel } from \"./components/Carousel\";\nexport { Checkbox, CheckboxGroup, CheckboxRow } from \"./components/Checkbox\";\nexport { default as CircleImage } from \"./components/CircleImage\";\nexport { default as Container } from \"./components/Container\";\nexport { default as Divider } from \"./components/Divider\";\nexport { default as FAB } from \"./components/FAB\";\nexport { default as FieldSearchBarFull } from \"./components/FieldSearchBarFull\";\nexport { default as IconButton } from \"./components/IconButton\";\nexport { default as Image } from \"./components/Image\";\nexport { default as NumberInput } from \"./components/NumberInput\";\nexport { default as ScreenContainer } from \"./components/ScreenContainer\";\nexport { default as StarRating } from \"./components/StarRating\";\nexport { default as Surface } from \"./components/Surface\";\nexport { default as Switch, SwitchRow } from \"./components/Switch\";\nexport { default as TextField } from \"./components/TextField\";\nexport { default as ToggleButton } from \"./components/ToggleButton\";\nexport { default as Touchable } from \"./components/Touchable\";\nexport { AccordionGroup, AccordionItem } from \"./components/Accordion\";\nexport {\n ActionSheet,\n ActionSheetItem,\n ActionSheetCancel,\n} from \"./components/ActionSheet\";\nexport { Swiper, SwiperItem } from \"./components/Swiper\";\nexport { TabView, TabViewItem } from \"./components/TabView\";\n\nexport {\n Center,\n Circle,\n Square,\n Row,\n Stack,\n Spacer,\n} from \"./components/Layout\";\n\nexport {\n RadioButton,\n RadioButtonGroup,\n RadioButtonRow,\n RadioButtonFieldGroup,\n} from \"./components/RadioButton/index\";\n\n/* Deprecated: Fix or Delete! */\nexport { default as Button } from \"./components/DeprecatedButton\";\nexport { default as CardBlock } from \"./components/CardBlock\";\nexport { default as CardContainer } from \"./components/CardContainer\";\nexport { default as CardContainerRating } from \"./components/CardContainerRating\";\nexport { default as CardInline } from \"./components/CardInline\";\nexport { default as DatePicker } from \"./components/DatePicker/DatePicker\";\nexport { default as HeaderLarge } from \"./components/HeaderLarge\";\nexport { default as HeaderMedium } from \"./components/HeaderMedium\";\nexport { default as HeaderOverline } from \"./components/HeaderOverline\";\nexport { default as Picker } from \"./components/Picker/Picker\";\nexport { default as ProgressBar } from \"./components/ProgressBar\";\nexport { default as ProgressCircle } from \"./components/ProgressCircle\";\nexport { default as RowBodyIcon } from \"./components/RowBodyIcon\";\nexport { default as RowHeadlineImageCaption } from \"./components/RowHeadlineImageCaption\";\nexport { default as RowHeadlineImageIcon } from \"./components/RowHeadlineImageIcon\";\nexport { default as Slider } from \"./components/Slider\";\nexport { default as Stepper } from \"./components/Stepper\";\nexport { useAuthState } from \"./components/useAuthState\";\n"]}
1
+ {"version":3,"sources":["index.tsx"],"names":["injectIcon","withTheme","ThemeProvider","default","Provider","DefaultTheme","Link","ButtonSolid","ButtonOutline","Avatar","AvatarEdit","Card","Carousel","Checkbox","CheckboxGroup","CheckboxRow","CircleImage","Container","Divider","FAB","FieldSearchBarFull","IconButton","Image","NumberInput","ScreenContainer","StarRating","Surface","Switch","SwitchRow","TextField","ToggleButton","Touchable","AccordionGroup","AccordionItem","ActionSheet","ActionSheetItem","ActionSheetCancel","Swiper","SwiperItem","Center","Circle","Square","Row","Stack","Spacer","RadioButton","RadioButtonGroup","RadioButtonRow","RadioButtonFieldGroup","Button","CardBlock","CardContainer","CardContainerRating","CardInline","DatePicker","HeaderLarge","HeaderMedium","HeaderOverline","Picker","ProgressBar","ProgressCircle","RowBodyIcon","RowHeadlineImageCaption","RowHeadlineImageIcon","Slider","Stepper","useAuthState"],"mappings":"AAAA,SAASA,UAAT,QAA2B,mBAA3B;AACA,SAASC,SAAT,EAAoBC,aAApB,QAAyC,WAAzC;AACA,SAASC,OAAO,IAAIC,QAApB,QAAoC,YAApC;AACA,SAASD,OAAO,IAAIE,YAApB,QAAwC,uBAAxC;AAEA,SAASC,IAAT,QAAqB,mBAArB;AACA,SAASC,WAAT,EAAsBC,aAAtB,QAA2C,qBAA3C;AACA,SAASL,OAAO,IAAIM,MAApB,QAAkC,0BAAlC;AACA,SAASN,OAAO,IAAIO,UAApB,QAAsC,yBAAtC;AACA,SAASP,OAAO,IAAIQ,IAApB,QAAgC,mBAAhC;AACA,SAASR,OAAO,IAAIS,QAApB,QAAoC,uBAApC;AACA,SAASC,QAAT,EAAmBC,aAAnB,EAAkCC,WAAlC,QAAqD,uBAArD;AACA,SAASZ,OAAO,IAAIa,WAApB,QAAuC,0BAAvC;AACA,SAASb,OAAO,IAAIc,SAApB,QAAqC,wBAArC;AACA,SAASd,OAAO,IAAIe,OAApB,QAAmC,sBAAnC;AACA,SAASf,OAAO,IAAIgB,GAApB,QAA+B,kBAA/B;AACA,SAAShB,OAAO,IAAIiB,kBAApB,QAA8C,iCAA9C;AACA,SAASjB,OAAO,IAAIkB,UAApB,QAAsC,yBAAtC;AACA,SAASlB,OAAO,IAAImB,KAApB,QAAiC,oBAAjC;AACA,SAASnB,OAAO,IAAIoB,WAApB,QAAuC,0BAAvC;AACA,SAASpB,OAAO,IAAIqB,eAApB,QAA2C,8BAA3C;AACA,SAASrB,OAAO,IAAIsB,UAApB,QAAsC,yBAAtC;AACA,SAAStB,OAAO,IAAIuB,OAApB,QAAmC,sBAAnC;AACA,SAASvB,OAAO,IAAIwB,MAApB,EAA4BC,SAA5B,QAA6C,qBAA7C;AACA,SAASzB,OAAO,IAAI0B,SAApB,QAAqC,wBAArC;AACA,SAAS1B,OAAO,IAAI2B,Y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YAAT,QAA6B,2BAA7B","sourcesContent":["export { injectIcon } from \"./interfaces/Icon\";\nexport { withTheme, ThemeProvider } from \"./theming\";\nexport { default as Provider } from \"./Provider\";\nexport { default as DefaultTheme } from \"./styles/DefaultTheme\";\n\nexport { Link } from \"./components/Text\";\nexport { ButtonSolid, ButtonOutline } from \"./components/Button\";\nexport { default as Avatar } from \"./components/CircleImage\";\nexport { default as AvatarEdit } from \"./components/AvatarEdit\";\nexport { default as Card } from \"./components/Card\";\nexport { default as Carousel } from \"./components/Carousel\";\nexport { Checkbox, CheckboxGroup, CheckboxRow } from \"./components/Checkbox\";\nexport { default as CircleImage } from \"./components/CircleImage\";\nexport { default as Container } from \"./components/Container\";\nexport { default as Divider } from \"./components/Divider\";\nexport { default as FAB } from \"./components/FAB\";\nexport { default as FieldSearchBarFull } from \"./components/FieldSearchBarFull\";\nexport { default as IconButton } from \"./components/IconButton\";\nexport { default as Image } from \"./components/Image\";\nexport { default as NumberInput } from \"./components/NumberInput\";\nexport { default as ScreenContainer } from \"./components/ScreenContainer\";\nexport { default as StarRating } from \"./components/StarRating\";\nexport { default as Surface } from \"./components/Surface\";\nexport { default as Switch, SwitchRow } from \"./components/Switch\";\nexport { default as TextField } from \"./components/TextField\";\nexport { default as ToggleButton } from \"./components/ToggleButton\";\nexport { default as Touchable } from \"./components/Touchable\";\nexport { AccordionGroup, AccordionItem } from \"./components/Accordion\";\nexport {\n ActionSheet,\n ActionSheetItem,\n ActionSheetCancel,\n} from \"./components/ActionSheet\";\nexport { Swiper, SwiperItem } from \"./components/Swiper\";\n\nexport {\n Center,\n Circle,\n Square,\n Row,\n Stack,\n Spacer,\n} from \"./components/Layout\";\n\nexport {\n RadioButton,\n RadioButtonGroup,\n RadioButtonRow,\n RadioButtonFieldGroup,\n} from \"./components/RadioButton/index\";\n\n/* Deprecated: Fix or Delete! */\nexport { default as Button } from \"./components/DeprecatedButton\";\nexport { default as CardBlock } from \"./components/CardBlock\";\nexport { default as CardContainer } from \"./components/CardContainer\";\nexport { default as CardContainerRating } from \"./components/CardContainerRating\";\nexport { default as CardInline } from \"./components/CardInline\";\nexport { default as DatePicker } from \"./components/DatePicker/DatePicker\";\nexport { default as HeaderLarge } from \"./components/HeaderLarge\";\nexport { default as HeaderMedium } from \"./components/HeaderMedium\";\nexport { default as HeaderOverline } from \"./components/HeaderOverline\";\nexport { default as Picker } from \"./components/Picker/Picker\";\nexport { default as ProgressBar } from \"./components/ProgressBar\";\nexport { default as ProgressCircle } from \"./components/ProgressCircle\";\nexport { default as RowBodyIcon } from \"./components/RowBodyIcon\";\nexport { default as RowHeadlineImageCaption } from \"./components/RowHeadlineImageCaption\";\nexport { default as RowHeadlineImageIcon } from \"./components/RowHeadlineImageIcon\";\nexport { default as Slider } from \"./components/Slider\";\nexport { default as Stepper } from \"./components/Stepper\";\nexport { useAuthState } from \"./components/useAuthState\";\n"]}
@@ -1,4 +1,5 @@
1
1
  import { StyleSheet } from "react-native";
2
+ import { isString, isNumber } from "lodash";
2
3
  export function extractStyles(style) {
3
4
  const {
4
5
  color,
@@ -60,4 +61,13 @@ export function applyStyles(baseStyles, stylesToApply) {
60
61
 
61
62
  return flattenedStyles;
62
63
  }
64
+ export function getValueForRadioButton(value) {
65
+ if (isString(value)) {
66
+ return value;
67
+ } else if (isNumber(value)) {
68
+ return String(value);
69
+ } else {
70
+ throw new Error(`Invalid value: ${value}`);
71
+ }
72
+ }
63
73
  //# sourceMappingURL=utilities.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["utilities.ts"],"names":["StyleSheet","extractStyles","style","color","fontFamily","fontWeight","fontSize","lineHeight","letterSpacing","textTransform","textAlign","textDecorationLine","textDecorationColor","textDecorationStyle","viewStyles","flatten","textStyles","applyStyles","baseStyles","stylesToApply","flattenedStyles","key","value","Object","entries"],"mappings":"AAAA,SAASA,UAAT,QAAiD,cAAjD;AAEA,OAAO,SAASC,aAAT,CAAuBC,KAAvB,EAA8C;AACnD,QAAM;AACJC,IAAAA,KADI;AAEJC,IAAAA,UAFI;AAGJC,IAAAA,UAHI;AAIJC,IAAAA,QAJI;AAKJC,IAAAA,UALI;AAMJC,IAAAA,aANI;AAOJC,IAAAA,aAPI;AAQJC,IAAAA,SARI;AASJC,IAAAA,kBATI;AAUJC,IAAAA,mBAVI;AAWJC,IAAAA,mBAXI;AAYJ,OAAGC;AAZC,MAaFd,UAAU,CAACe,OAAX,CAAmBb,KAAK,IAAI,EAA5B,CAbJ;AAeA,QAAMc,UAAqB,GAAG;AAC5Bb,IAAAA,KAD4B;AAE5BC,IAAAA,UAF4B;AAG5BC,IAAAA,UAH4B;AAI5BC,IAAAA,QAJ4B;AAK5BC,IAAAA,UAL4B;AAM5BC,IAAAA,aAN4B;AAO5BC,IAAAA,aAP4B;AAQ5BC,IAAAA,SAR4B;AAS5BC,IAAAA,kBAT4B;AAU5BC,IAAAA,mBAV4B;AAW5BC,IAAAA;AAX4B,GAA9B;AAcA,SAAO;AAAEC,IAAAA,UAAF;AAAcE,IAAAA;AAAd,GAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,WAAT,CACLC,UADK,EAELC,aAFK,EAGL;AACA,MAAI,CAACA,aAAL,EAAoB;AAClB;AACD;;AAED,QAAMC,eAAe,GAAGpB,UAAU,CAACe,OAAX,CAAmBG,UAAnB,CAAxB;;AAEA,OAAK,MAAM,CAACG,GAAD,EAAMC,KAAN,CAAX,IAA2BC,MAAM,CAACC,OAAP,CAAeL,aAAf,CAA3B,EAA0D;AACxD,QAAIG,KAAK,IAAI,IAAb,EAAmB;AACjBF,MAAAA,eAAe,CAACC,GAAD,CAAf,GAAuBC,KAAvB;AACD;AACF;;AAED,SAAOF,eAAP;AACD","sourcesContent":["import { StyleSheet, StyleProp, TextStyle } from \"react-native\";\n\nexport function extractStyles(style: StyleProp<any>) {\n const {\n color,\n fontFamily,\n fontWeight,\n fontSize,\n lineHeight,\n letterSpacing,\n textTransform,\n textAlign,\n textDecorationLine,\n textDecorationColor,\n textDecorationStyle,\n ...viewStyles\n } = StyleSheet.flatten(style || {});\n\n const textStyles: TextStyle = {\n color,\n fontFamily,\n fontWeight,\n fontSize,\n lineHeight,\n letterSpacing,\n textTransform,\n textAlign,\n textDecorationLine,\n textDecorationColor,\n textDecorationStyle,\n };\n\n return { viewStyles, textStyles };\n}\n\n/**\n * Merges a style object on top of another style object. In React Native,\n * keys with undefined values in a style object will still override styles\n * that appear earlier in a sequence. This avoids that problem.\n *\n * This lets us avoid the `...(something ? { something } : {})` pattern.\n * There doesn't seem to be a better way to do this. These all seem to not\n * work (i.e. they all result in `{ color: undefined }`:\n * `const mergedStyles = [{ color: \"red\" }, { color: undefined }]`\n * `const mergedStyles = StyleSheet.compose({ color: \"red\" }, { color: undefined })`\n * `const mergedStyles = StyleSheet.flatten([{ color: \"red\" }, { color: undefined }])`\n */\nexport function applyStyles(\n baseStyles: Array<StyleProp<any>>,\n stylesToApply: StyleProp<any> | undefined\n) {\n if (!stylesToApply) {\n return;\n }\n\n const flattenedStyles = StyleSheet.flatten(baseStyles);\n\n for (const [key, value] of Object.entries(stylesToApply)) {\n if (value != null) {\n flattenedStyles[key] = value;\n }\n }\n\n return flattenedStyles;\n}\n"]}
1
+ {"version":3,"sources":["utilities.ts"],"names":["StyleSheet","isString","isNumber","extractStyles","style","color","fontFamily","fontWeight","fontSize","lineHeight","letterSpacing","textTransform","textAlign","textDecorationLine","textDecorationColor","textDecorationStyle","viewStyles","flatten","textStyles","applyStyles","baseStyles","stylesToApply","flattenedStyles","key","value","Object","entries","getValueForRadioButton","String","Error"],"mappings":"AAAA,SAASA,UAAT,QAAiD,cAAjD;AACA,SAASC,QAAT,EAAmBC,QAAnB,QAAmC,QAAnC;AAEA,OAAO,SAASC,aAAT,CAAuBC,KAAvB,EAA8C;AACnD,QAAM;AACJC,IAAAA,KADI;AAEJC,IAAAA,UAFI;AAGJC,IAAAA,UAHI;AAIJC,IAAAA,QAJI;AAKJC,I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CAAb;AACD,GAFM,MAEA;AACL,UAAM,IAAIK,KAAJ,CAAW,kBAAiBL,KAAM,EAAlC,CAAN;AACD;AACF","sourcesContent":["import { StyleSheet, StyleProp, TextStyle } from \"react-native\";\nimport { isString, isNumber } from \"lodash\";\n\nexport function extractStyles(style: StyleProp<any>) {\n const {\n color,\n fontFamily,\n fontWeight,\n fontSize,\n lineHeight,\n letterSpacing,\n textTransform,\n textAlign,\n textDecorationLine,\n textDecorationColor,\n textDecorationStyle,\n ...viewStyles\n } = StyleSheet.flatten(style || {});\n\n const textStyles: TextStyle = {\n color,\n fontFamily,\n fontWeight,\n fontSize,\n lineHeight,\n letterSpacing,\n textTransform,\n textAlign,\n textDecorationLine,\n textDecorationColor,\n textDecorationStyle,\n };\n\n return { viewStyles, textStyles };\n}\n\n/**\n * Merges a style object on top of another style object. In React Native,\n * keys with undefined values in a style object will still override styles\n * that appear earlier in a sequence. This avoids that problem.\n *\n * This lets us avoid the `...(something ? { something } : {})` pattern.\n * There doesn't seem to be a better way to do this. These all seem to not\n * work (i.e. they all result in `{ color: undefined }`:\n * `const mergedStyles = [{ color: \"red\" }, { color: undefined }]`\n * `const mergedStyles = StyleSheet.compose({ color: \"red\" }, { color: undefined })`\n * `const mergedStyles = StyleSheet.flatten([{ color: \"red\" }, { color: undefined }])`\n */\nexport function applyStyles(\n baseStyles: Array<StyleProp<any>>,\n stylesToApply: StyleProp<any> | undefined\n) {\n if (!stylesToApply) {\n return;\n }\n\n const flattenedStyles = StyleSheet.flatten(baseStyles);\n\n for (const [key, value] of Object.entries(stylesToApply)) {\n if (value != null) {\n flattenedStyles[key] = value;\n }\n }\n\n return flattenedStyles;\n}\n\nexport function getValueForRadioButton(value: string | number) {\n if (isString(value)) {\n return value;\n } else if (isNumber(value)) {\n return String(value);\n } else {\n throw new Error(`Invalid value: ${value}`);\n }\n}\n"]}
@@ -5,9 +5,9 @@ export declare type RadioButtonProps = {
5
5
  selected?: boolean;
6
6
  disabled?: boolean;
7
7
  color?: string;
8
- value?: string;
8
+ value?: string | number;
9
9
  unselectedColor?: string;
10
- onPress?: () => void;
10
+ onPress?: (value?: string) => void;
11
11
  style?: StyleProp<ViewStyle>;
12
12
  size?: number;
13
13
  selectedIcon?: string;
@@ -5,9 +5,9 @@ import { Direction } from "./context";
5
5
  export interface RadioButtonGroupProps {
6
6
  direction?: Direction;
7
7
  style?: StyleProp<ViewStyle>;
8
- value?: string;
8
+ value: string;
9
9
  onValueChange?: (value: string) => void;
10
- defaultValue?: string;
10
+ defaultValue?: string | number;
11
11
  theme: Theme;
12
12
  children: React.ReactNode;
13
13
  }
@@ -8,7 +8,7 @@ export declare enum Direction {
8
8
  }
9
9
  export interface RadioButtonRowProps extends Omit<RadioButtonProps, "onPress"> {
10
10
  label: string | React.ReactNode;
11
- value: string;
11
+ value: string | number;
12
12
  color?: string;
13
13
  unselectedColor?: string;
14
14
  labelContainerStyle: StyleProp<ViewStyle>;
@@ -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";
@@ -16,3 +16,4 @@ export declare function extractStyles(style: StyleProp<any>): {
16
16
  * `const mergedStyles = StyleSheet.flatten([{ color: "red" }, { color: undefined }])`
17
17
  */
18
18
  export declare function applyStyles(baseStyles: Array<StyleProp<any>>, stylesToApply: StyleProp<any> | undefined): any;
19
+ export declare function getValueForRadioButton(value: string | number): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftbit/core",
3
- "version": "43.4.5-d442fc.1+d442fc18",
3
+ "version": "43.4.5-d68594.1+d685946d",
4
4
  "description": "Core (non-native) Components",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -54,8 +54,6 @@
54
54
  "lodash.omit": "^4.5.0",
55
55
  "lodash.tonumber": "^4.0.3",
56
56
  "react-native-modal-datetime-picker": "^13.0.0",
57
- "react-native-pager-view": "^5.4.9",
58
- "react-native-tab-view": "^3.1.1",
59
57
  "react-native-typography": "^1.4.1",
60
58
  "react-native-web-swiper": "^2.2.1"
61
59
  },
@@ -82,5 +80,5 @@
82
80
  ]
83
81
  ]
84
82
  },
85
- "gitHead": "d442fc18bff113f1e3f9040d6df0e2e1215c16e1"
83
+ "gitHead": "d685946d895b7949d55554658b66cdc538236805"
86
84
  }
@@ -1,16 +1,17 @@
1
1
  import * as React from "react";
2
2
  import Config from "../Config";
3
3
  import IconButton from "../IconButton";
4
+ import { getValueForRadioButton } from "../../utilities";
4
5
  import { useRadioButtonGroupContext } from "./context";
5
- const RadioButton = ({ Icon, disabled = false, color, value, selected, unselectedColor, onPress = () => { }, size = Config.radioButtonSize, selectedIcon = "MaterialIcons/radio-button-checked", unselectedIcon = "MaterialIcons/radio-button-unchecked", style, ...rest }) => {
6
+ const RadioButton = ({ Icon, disabled = false, color, value = "", selected, unselectedColor, onPress, size = Config.radioButtonSize, selectedIcon = "MaterialIcons/radio-button-checked", unselectedIcon = "MaterialIcons/radio-button-unchecked", style, ...rest }) => {
6
7
  const { value: contextValue, onValueChange } = useRadioButtonGroupContext();
8
+ const realValue = getValueForRadioButton(value);
9
+ const realContextValue = getValueForRadioButton(contextValue);
10
+ const isSelected = selected ?? realContextValue === realValue;
7
11
  const handlePress = () => {
8
- onPress && onPress();
9
- if (onValueChange && value) {
10
- onValueChange(value);
11
- }
12
+ onPress?.(realValue);
13
+ onValueChange?.(realValue);
12
14
  };
13
- const isSelected = selected || (contextValue != null && contextValue === value);
14
15
  return (React.createElement(IconButton, { Icon: Icon, icon: isSelected ? selectedIcon : unselectedIcon, color: isSelected ? color : unselectedColor, disabled: disabled, onPress: handlePress, size: size, style: style, ...rest }));
15
16
  };
16
17
  export default RadioButton;
@@ -3,6 +3,7 @@ import { StyleProp, ViewStyle } from "react-native";
3
3
 
4
4
  import Config from "../Config";
5
5
  import IconButton from "../IconButton";
6
+ import { getValueForRadioButton } from "../../utilities";
6
7
  import { useRadioButtonGroupContext } from "./context";
7
8
 
8
9
  import type { IconSlot } from "../../interfaces/Icon";
@@ -11,9 +12,9 @@ export type RadioButtonProps = {
11
12
  selected?: boolean;
12
13
  disabled?: boolean;
13
14
  color?: string;
14
- value?: string;
15
+ value?: string | number;
15
16
  unselectedColor?: string;
16
- onPress?: () => void;
17
+ onPress?: (value?: string) => void;
17
18
  style?: StyleProp<ViewStyle>;
18
19
  size?: number;
19
20
  selectedIcon?: string;
@@ -24,10 +25,10 @@ const RadioButton: React.FC<RadioButtonProps> = ({
24
25
  Icon,
25
26
  disabled = false,
26
27
  color,
27
- value,
28
+ value = "",
28
29
  selected,
29
30
  unselectedColor,
30
- onPress = () => {},
31
+ onPress,
31
32
  size = Config.radioButtonSize,
32
33
  selectedIcon = "MaterialIcons/radio-button-checked",
33
34
  unselectedIcon = "MaterialIcons/radio-button-unchecked",
@@ -36,17 +37,15 @@ const RadioButton: React.FC<RadioButtonProps> = ({
36
37
  }) => {
37
38
  const { value: contextValue, onValueChange } = useRadioButtonGroupContext();
38
39
 
39
- const handlePress = () => {
40
- onPress && onPress();
40
+ const realValue = getValueForRadioButton(value);
41
+ const realContextValue = getValueForRadioButton(contextValue);
42
+ const isSelected = selected ?? realContextValue === realValue;
41
43
 
42
- if (onValueChange && value) {
43
- onValueChange(value);
44
- }
44
+ const handlePress = () => {
45
+ onPress?.(realValue);
46
+ onValueChange?.(realValue);
45
47
  };
46
48
 
47
- const isSelected =
48
- selected || (contextValue != null && contextValue === value);
49
-
50
49
  return (
51
50
  <IconButton
52
51
  Icon={Icon}
@@ -1,22 +1,22 @@
1
1
  import * as React from "react";
2
2
  import { View } from "react-native";
3
+ import { getValueForRadioButton } from "../../utilities";
3
4
  import { radioButtonGroupContext, Direction } from "./context";
4
5
  const { Provider } = radioButtonGroupContext;
5
- const RadioButtonGroup = ({ direction = Direction.Vertical, value, onValueChange = () => { }, defaultValue, style, children, ...rest }) => {
6
- const [internalValue, setInternalValue] = React.useState(value || defaultValue);
6
+ const RadioButtonGroup = ({ direction = Direction.Vertical, value = "", onValueChange, defaultValue = "", style, children, ...rest }) => {
7
+ const [internalValue, setInternalValue] = React.useState("");
7
8
  React.useEffect(() => {
8
- if (value != null) {
9
- setInternalValue(value);
10
- }
9
+ const realValue = getValueForRadioButton(value);
10
+ setInternalValue(realValue);
11
11
  }, [value]);
12
12
  React.useEffect(() => {
13
- if (defaultValue != null) {
14
- setInternalValue(defaultValue);
15
- }
13
+ const realDefaultValue = getValueForRadioButton(defaultValue);
14
+ setInternalValue(realDefaultValue);
16
15
  }, [defaultValue]);
17
16
  const handleValueChange = (newValue) => {
18
- setInternalValue(newValue);
19
- onValueChange(newValue);
17
+ const realNewValue = getValueForRadioButton(newValue);
18
+ setInternalValue(realNewValue);
19
+ onValueChange?.(realNewValue);
20
20
  };
21
21
  const _containerStyle = [
22
22
  {