@draftbit/core 43.4.4-03ab3e.0 → 43.4.5-ccf125.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 (47) hide show
  1. package/lib/commonjs/components/Accordion/AccordionItem.js +21 -5
  2. package/lib/commonjs/components/Accordion/AccordionItem.js.map +1 -1
  3. package/lib/commonjs/components/RadioButton/RadioButton.js +9 -6
  4. package/lib/commonjs/components/RadioButton/RadioButton.js.map +1 -1
  5. package/lib/commonjs/components/RadioButton/RadioButtonGroup.js +18 -8
  6. package/lib/commonjs/components/RadioButton/RadioButtonGroup.js.map +1 -1
  7. package/lib/commonjs/components/RadioButton/RadioButtonRow.js +14 -9
  8. package/lib/commonjs/components/RadioButton/RadioButtonRow.js.map +1 -1
  9. package/lib/commonjs/components/StarRating.js +5 -4
  10. package/lib/commonjs/components/StarRating.js.map +1 -1
  11. package/lib/commonjs/components/Touchable.js +3 -16
  12. package/lib/commonjs/components/Touchable.js.map +1 -1
  13. package/lib/commonjs/hooks.js.map +1 -1
  14. package/lib/commonjs/mappings/Accordion.js.map +1 -1
  15. package/lib/commonjs/mappings/LinearGradient.js +2 -2
  16. package/lib/commonjs/mappings/LinearGradient.js.map +1 -1
  17. package/lib/commonjs/utilities.js +16 -0
  18. package/lib/commonjs/utilities.js.map +1 -1
  19. package/lib/module/components/DatePicker/DatePickerComponentType.js.map +1 -1
  20. package/lib/module/components/RadioButton/RadioButton.js +8 -6
  21. package/lib/module/components/RadioButton/RadioButton.js.map +1 -1
  22. package/lib/module/components/RadioButton/RadioButtonGroup.js +17 -8
  23. package/lib/module/components/RadioButton/RadioButtonGroup.js.map +1 -1
  24. package/lib/module/components/RadioButton/RadioButtonRow.js +15 -10
  25. package/lib/module/components/RadioButton/RadioButtonRow.js.map +1 -1
  26. package/lib/module/components/Swiper/Swiper.js.map +1 -1
  27. package/lib/module/mappings/FAB.js.map +1 -1
  28. package/lib/module/mappings/ImageBackground.js.map +1 -1
  29. package/lib/module/mappings/KeyboardAvoidingView.js.map +1 -1
  30. package/lib/module/mappings/LinearGradient.js +2 -2
  31. package/lib/module/mappings/LinearGradient.js.map +1 -1
  32. package/lib/module/utilities.js +14 -0
  33. package/lib/module/utilities.js.map +1 -1
  34. package/lib/typescript/src/components/RadioButton/RadioButton.d.ts +1 -1
  35. package/lib/typescript/src/components/RadioButton/RadioButtonGroup.d.ts +1 -1
  36. package/lib/typescript/src/utilities.d.ts +1 -0
  37. package/package.json +2 -2
  38. package/src/components/RadioButton/RadioButton.js +9 -5
  39. package/src/components/RadioButton/RadioButton.tsx +12 -9
  40. package/src/components/RadioButton/RadioButtonGroup.js +14 -8
  41. package/src/components/RadioButton/RadioButtonGroup.tsx +21 -12
  42. package/src/components/RadioButton/RadioButtonRow.js +15 -9
  43. package/src/components/RadioButton/RadioButtonRow.tsx +19 -13
  44. package/src/mappings/LinearGradient.js +2 -2
  45. package/src/mappings/LinearGradient.ts +2 -2
  46. package/src/utilities.js +12 -0
  47. package/src/utilities.ts +13 -0
@@ -5,7 +5,7 @@ import Text from "../Text";
5
5
  import { useRadioButtonGroupContext } from "./context";
6
6
  import { Direction as GroupDirection } from "./context";
7
7
  import Touchable from "../Touchable";
8
- import { extractStyles } from "../../utilities";
8
+ import { extractStyles, getRealValue } from "../../utilities";
9
9
  export var Direction;
10
10
  (function (Direction) {
11
11
  Direction["Row"] = "row";
@@ -22,19 +22,25 @@ const getRadioButtonAlignment = (parentDirection, direction) => {
22
22
  return "flex-end";
23
23
  }
24
24
  };
25
- const renderLabel = (value, labelStyle, textStyle) => {
26
- if (typeof value === "string") {
27
- return React.createElement(Text, { style: [labelStyle, textStyle] }, value);
25
+ const renderLabel = (label, labelStyle, textStyle) => {
26
+ if (typeof label === "string") {
27
+ return React.createElement(Text, { style: [labelStyle, textStyle] }, label);
28
28
  }
29
29
  else {
30
- return React.createElement(React.Fragment, null, value);
30
+ return React.createElement(React.Fragment, null, label);
31
31
  }
32
32
  };
33
- const RadioButtonRow = ({ Icon, label, value, color, unselectedColor, onPress = () => { }, labelContainerStyle, labelStyle, radioButtonStyle, direction = Direction.Row, selected, disabled, style, ...rest }) => {
33
+ const RadioButtonRow = ({ Icon, label, value, color, unselectedColor, onPress, labelContainerStyle, labelStyle, radioButtonStyle, direction = Direction.Row, selected, disabled, style, ...rest }) => {
34
34
  const { value: contextValue, onValueChange, direction: parentDirection, } = useRadioButtonGroupContext();
35
+ const realValue = getRealValue(value);
36
+ const realContextValue = getRealValue(contextValue);
37
+ const isSelected = selected ??
38
+ (realContextValue && realValue && realContextValue === realValue);
35
39
  const handlePress = () => {
36
- onPress(value);
37
- onValueChange && onValueChange(value);
40
+ if (realValue) {
41
+ onPress?.(realValue);
42
+ onValueChange?.(realValue);
43
+ }
38
44
  };
39
45
  const { textStyles, viewStyles } = extractStyles(style);
40
46
  return (React.createElement(Touchable, { onPress: handlePress, style: [styles.mainParent, { flexDirection: direction }, viewStyles], disabled: disabled, ...rest },
@@ -49,7 +55,7 @@ const RadioButtonRow = ({ Icon, label, value, color, unselectedColor, onPress =
49
55
  flex: 1,
50
56
  alignItems: getRadioButtonAlignment(parentDirection, direction),
51
57
  } },
52
- React.createElement(RadioButton, { Icon: Icon, selected: selected || (contextValue != null && contextValue === value), color: color, unselectedColor: unselectedColor, onPress: handlePress, style: radioButtonStyle }))));
58
+ React.createElement(RadioButton, { Icon: Icon, selected: isSelected ? true : false, value: realValue, color: color, unselectedColor: unselectedColor, style: radioButtonStyle }))));
53
59
  };
54
60
  const styles = StyleSheet.create({
55
61
  mainParent: {
@@ -13,7 +13,7 @@ import { useRadioButtonGroupContext } from "./context";
13
13
  import type { IconSlot } from "../../interfaces/Icon";
14
14
  import { Direction as GroupDirection } from "./context";
15
15
  import Touchable from "../Touchable";
16
- import { extractStyles } from "../../utilities";
16
+ import { extractStyles, getRealValue } from "../../utilities";
17
17
 
18
18
  export enum Direction {
19
19
  Row = "row",
@@ -22,7 +22,7 @@ export enum Direction {
22
22
 
23
23
  export interface RadioButtonRowProps extends Omit<RadioButtonProps, "onPress"> {
24
24
  label: string | React.ReactNode;
25
- value: string; // A string that this radio button row represents when selected
25
+ value: string; // A string (or number that will be parsed String(number)) that this radio button row represents when selected
26
26
  color?: string;
27
27
  unselectedColor?: string;
28
28
  labelContainerStyle: StyleProp<ViewStyle>;
@@ -46,14 +46,14 @@ const getRadioButtonAlignment = (
46
46
  };
47
47
 
48
48
  const renderLabel = (
49
- value: string | React.ReactNode,
49
+ label: string | React.ReactNode,
50
50
  labelStyle: StyleProp<TextStyle>,
51
51
  textStyle: StyleProp<TextStyle>
52
52
  ) => {
53
- if (typeof value === "string") {
54
- return <Text style={[labelStyle, textStyle]}>{value}</Text>;
53
+ if (typeof label === "string") {
54
+ return <Text style={[labelStyle, textStyle]}>{label}</Text>;
55
55
  } else {
56
- return <>{value}</>;
56
+ return <>{label}</>;
57
57
  }
58
58
  };
59
59
 
@@ -63,7 +63,7 @@ const RadioButtonRow: React.FC<RadioButtonRowProps & IconSlot> = ({
63
63
  value,
64
64
  color,
65
65
  unselectedColor,
66
- onPress = () => {},
66
+ onPress,
67
67
  labelContainerStyle,
68
68
  labelStyle,
69
69
  radioButtonStyle,
@@ -79,9 +79,17 @@ const RadioButtonRow: React.FC<RadioButtonRowProps & IconSlot> = ({
79
79
  direction: parentDirection,
80
80
  } = useRadioButtonGroupContext();
81
81
 
82
+ const realValue = getRealValue(value);
83
+ const realContextValue = getRealValue(contextValue);
84
+ const isSelected =
85
+ selected ??
86
+ (realContextValue && realValue && realContextValue === realValue);
87
+
82
88
  const handlePress = () => {
83
- onPress(value);
84
- onValueChange && onValueChange(value);
89
+ if (realValue) {
90
+ onPress?.(realValue);
91
+ onValueChange?.(realValue);
92
+ }
85
93
  };
86
94
 
87
95
  const { textStyles, viewStyles } = extractStyles(style);
@@ -112,12 +120,10 @@ const RadioButtonRow: React.FC<RadioButtonRowProps & IconSlot> = ({
112
120
  >
113
121
  <RadioButton
114
122
  Icon={Icon}
115
- selected={
116
- selected || (contextValue != null && contextValue === value)
117
- }
123
+ selected={isSelected ? true : false}
124
+ value={realValue}
118
125
  color={color}
119
126
  unselectedColor={unselectedColor}
120
- onPress={handlePress}
121
127
  style={radioButtonStyle}
122
128
  />
123
129
  </View>
@@ -67,11 +67,11 @@ export const SEED_DATA = {
67
67
  }),
68
68
  color2: createColorProp({
69
69
  label: "Color 2",
70
- defaultValue: "rgba(251, 252, 253, 1)",
70
+ defaultValue: "secondary",
71
71
  }),
72
72
  color1: createColorProp({
73
73
  label: "Color 1",
74
- defaultValue: "rgba(90, 69, 255, 1)",
74
+ defaultValue: "primary",
75
75
  }),
76
76
  },
77
77
  };
@@ -73,11 +73,11 @@ export const SEED_DATA = {
73
73
  }),
74
74
  color2: createColorProp({
75
75
  label: "Color 2",
76
- defaultValue: "rgba(251, 252, 253, 1)",
76
+ defaultValue: "secondary",
77
77
  }),
78
78
  color1: createColorProp({
79
79
  label: "Color 1",
80
- defaultValue: "rgba(90, 69, 255, 1)",
80
+ defaultValue: "primary",
81
81
  }),
82
82
  },
83
83
  };
package/src/utilities.js CHANGED
@@ -40,3 +40,15 @@ export function applyStyles(baseStyles, stylesToApply) {
40
40
  }
41
41
  return flattenedStyles;
42
42
  }
43
+ export function getRealValue(value) {
44
+ // console.log("getRealValue typeof", typeof value);
45
+ // console.log("getRealValue value", value);
46
+ switch (typeof value) {
47
+ case "string":
48
+ return value;
49
+ case "number":
50
+ return String(value);
51
+ default:
52
+ return undefined;
53
+ }
54
+ }
package/src/utilities.ts CHANGED
@@ -63,3 +63,16 @@ export function applyStyles(
63
63
 
64
64
  return flattenedStyles;
65
65
  }
66
+
67
+ export function getRealValue(value: any) {
68
+ // console.log("getRealValue typeof", typeof value);
69
+ // console.log("getRealValue value", value);
70
+ switch (typeof value) {
71
+ case "string":
72
+ return value;
73
+ case "number":
74
+ return String(value);
75
+ default:
76
+ return undefined;
77
+ }
78
+ }