@draftbit/core 43.4.5-e035fd.1 → 43.4.5

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 (56) 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/FieldSearchBarFull.js.map +1 -1
  4. package/lib/commonjs/components/RadioButton/RadioButton.js +9 -8
  5. package/lib/commonjs/components/RadioButton/RadioButton.js.map +1 -1
  6. package/lib/commonjs/components/RadioButton/RadioButtonGroup.js +13 -12
  7. package/lib/commonjs/components/RadioButton/RadioButtonGroup.js.map +1 -1
  8. package/lib/commonjs/components/RadioButton/RadioButtonRow.js +9 -6
  9. package/lib/commonjs/components/RadioButton/RadioButtonRow.js.map +1 -1
  10. package/lib/commonjs/index.js +0 -8
  11. package/lib/commonjs/index.js.map +1 -1
  12. package/lib/commonjs/mappings/RowBodyIcon.js.map +1 -1
  13. package/lib/commonjs/mappings/RowHeadlineImageIcon.js.map +1 -1
  14. package/lib/commonjs/utilities.js +13 -0
  15. package/lib/commonjs/utilities.js.map +1 -1
  16. package/lib/module/components/RadioButton/RadioButton.js +8 -8
  17. package/lib/module/components/RadioButton/RadioButton.js.map +1 -1
  18. package/lib/module/components/RadioButton/RadioButtonGroup.js +12 -12
  19. package/lib/module/components/RadioButton/RadioButtonGroup.js.map +1 -1
  20. package/lib/module/components/RadioButton/RadioButtonRow.js +10 -7
  21. package/lib/module/components/RadioButton/RadioButtonRow.js.map +1 -1
  22. package/lib/module/index.js +0 -1
  23. package/lib/module/index.js.map +1 -1
  24. package/lib/module/mappings/LinearGradient.js.map +1 -1
  25. package/lib/module/utilities.js +10 -0
  26. package/lib/module/utilities.js.map +1 -1
  27. package/lib/typescript/src/components/RadioButton/RadioButton.d.ts +2 -2
  28. package/lib/typescript/src/components/RadioButton/RadioButtonGroup.d.ts +2 -2
  29. package/lib/typescript/src/components/RadioButton/RadioButtonRow.d.ts +1 -1
  30. package/lib/typescript/src/index.d.ts +0 -1
  31. package/lib/typescript/src/utilities.d.ts +1 -0
  32. package/package.json +2 -3
  33. package/src/components/RadioButton/RadioButton.js +7 -6
  34. package/src/components/RadioButton/RadioButton.tsx +11 -12
  35. package/src/components/RadioButton/RadioButtonGroup.js +10 -10
  36. package/src/components/RadioButton/RadioButtonGroup.tsx +18 -17
  37. package/src/components/RadioButton/RadioButtonRow.js +8 -5
  38. package/src/components/RadioButton/RadioButtonRow.tsx +12 -10
  39. package/src/index.js +0 -1
  40. package/src/index.tsx +0 -1
  41. package/src/utilities.js +12 -0
  42. package/src/utilities.ts +11 -0
  43. package/lib/commonjs/components/Markdown.js +0 -30
  44. package/lib/commonjs/components/Markdown.js.map +0 -1
  45. package/lib/commonjs/mappings/Markdown.js +0 -24
  46. package/lib/commonjs/mappings/Markdown.js.map +0 -1
  47. package/lib/module/components/Markdown.js +0 -13
  48. package/lib/module/components/Markdown.js.map +0 -1
  49. package/lib/module/mappings/Markdown.js +0 -15
  50. package/lib/module/mappings/Markdown.js.map +0 -1
  51. package/lib/typescript/src/components/Markdown.d.ts +0 -12
  52. package/lib/typescript/src/mappings/Markdown.d.ts +0 -9
  53. package/src/components/Markdown.js +0 -7
  54. package/src/components/Markdown.tsx +0 -14
  55. package/src/mappings/Markdown.js +0 -14
  56. package/src/mappings/Markdown.ts +0 -15
@@ -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, getValueForRadioButton } 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 | number; // 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>;
@@ -60,10 +60,10 @@ const renderLabel = (
60
60
  const RadioButtonRow: React.FC<RadioButtonRowProps & IconSlot> = ({
61
61
  Icon,
62
62
  label,
63
- value,
63
+ value = "",
64
64
  color,
65
65
  unselectedColor,
66
- onPress = () => {},
66
+ onPress,
67
67
  labelContainerStyle,
68
68
  labelStyle,
69
69
  radioButtonStyle,
@@ -79,9 +79,13 @@ const RadioButtonRow: React.FC<RadioButtonRowProps & IconSlot> = ({
79
79
  direction: parentDirection,
80
80
  } = useRadioButtonGroupContext();
81
81
 
82
+ const realValue = getValueForRadioButton(value);
83
+ const realContextValue = getValueForRadioButton(contextValue);
84
+ const isSelected = selected ?? realContextValue === realValue;
85
+
82
86
  const handlePress = () => {
83
- onPress(value);
84
- onValueChange && onValueChange(value);
87
+ onPress?.(realValue);
88
+ onValueChange?.(realValue);
85
89
  };
86
90
 
87
91
  const { textStyles, viewStyles } = extractStyles(style);
@@ -112,12 +116,10 @@ const RadioButtonRow: React.FC<RadioButtonRowProps & IconSlot> = ({
112
116
  >
113
117
  <RadioButton
114
118
  Icon={Icon}
115
- selected={
116
- selected || (contextValue != null && contextValue === value)
117
- }
119
+ selected={isSelected}
120
+ value={realValue}
118
121
  color={color}
119
122
  unselectedColor={unselectedColor}
120
- onPress={handlePress}
121
123
  style={radioButtonStyle}
122
124
  />
123
125
  </View>
package/src/index.js CHANGED
@@ -48,4 +48,3 @@ export { default as RowHeadlineImageIcon } from "./components/RowHeadlineImageIc
48
48
  export { default as Slider } from "./components/Slider";
49
49
  export { default as Stepper } from "./components/Stepper";
50
50
  export { useAuthState } from "./components/useAuthState";
51
- export { default as Markdown } from "./components/Markdown";
package/src/index.tsx CHANGED
@@ -68,4 +68,3 @@ export { default as RowHeadlineImageIcon } from "./components/RowHeadlineImageIc
68
68
  export { default as Slider } from "./components/Slider";
69
69
  export { default as Stepper } from "./components/Stepper";
70
70
  export { useAuthState } from "./components/useAuthState";
71
- export { default as Markdown } from "./components/Markdown";
package/src/utilities.js CHANGED
@@ -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 { color, fontFamily, fontWeight, fontSize, lineHeight, letterSpacing, textTransform, textAlign, textDecorationLine, textDecorationColor, textDecorationStyle, ...viewStyles } = StyleSheet.flatten(style || {});
4
5
  const textStyles = {
@@ -40,3 +41,14 @@ export function applyStyles(baseStyles, stylesToApply) {
40
41
  }
41
42
  return flattenedStyles;
42
43
  }
44
+ export function getValueForRadioButton(value) {
45
+ if (isString(value)) {
46
+ return value;
47
+ }
48
+ else if (isNumber(value)) {
49
+ return String(value);
50
+ }
51
+ else {
52
+ throw new Error(`Invalid value: ${value}`);
53
+ }
54
+ }
package/src/utilities.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { StyleSheet, StyleProp, TextStyle } from "react-native";
2
+ import { isString, isNumber } from "lodash";
2
3
 
3
4
  export function extractStyles(style: StyleProp<any>) {
4
5
  const {
@@ -63,3 +64,13 @@ export function applyStyles(
63
64
 
64
65
  return flattenedStyles;
65
66
  }
67
+
68
+ export function getValueForRadioButton(value: string | number) {
69
+ if (isString(value)) {
70
+ return value;
71
+ } else if (isNumber(value)) {
72
+ return String(value);
73
+ } else {
74
+ throw new Error(`Invalid value: ${value}`);
75
+ }
76
+ }
@@ -1,30 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var React = _interopRequireWildcard(require("react"));
9
-
10
- var _reactNativeMarkdownDisplay = _interopRequireDefault(require("react-native-markdown-display"));
11
-
12
- var _theming = require("../theming");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
-
20
- const MarkdownComponent = _ref => {
21
- let {
22
- content
23
- } = _ref;
24
- return /*#__PURE__*/React.createElement(_reactNativeMarkdownDisplay.default, null, content);
25
- };
26
-
27
- var _default = (0, _theming.withTheme)(MarkdownComponent);
28
-
29
- exports.default = _default;
30
- //# sourceMappingURL=Markdown.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["Markdown.tsx"],"names":["MarkdownComponent","content"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;;;;;AAMA,MAAMA,iBAAkC,GAAG,QAAiB;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AAC1D,sBAAO,oBAAC,mCAAD,QAAWA,OAAX,CAAP;AACD,CAFD;;eAIe,wBAAUD,iBAAV,C","sourcesContent":["import * as React from \"react\";\nimport Markdown from \"react-native-markdown-display\";\n\nimport { withTheme } from \"../theming\";\n\ntype Props = {\n content?: string;\n};\n\nconst MarkdownComponent: React.FC<Props> = ({ content }) => {\n return <Markdown>{content}</Markdown>;\n};\n\nexport default withTheme(MarkdownComponent);\n"]}
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SEED_DATA = void 0;
7
-
8
- var _types = require("@draftbit/types");
9
-
10
- const SEED_DATA = {
11
- name: "Markdown",
12
- tag: "MarkdownComponent",
13
- description: "A markdown component",
14
- category: _types.COMPONENT_TYPES.basic,
15
- props: {
16
- content: (0, _types.createTextProp)({
17
- label: "Markdown Text",
18
- description: "Markdown Text",
19
- defaultValue: null
20
- })
21
- }
22
- };
23
- exports.SEED_DATA = SEED_DATA;
24
- //# sourceMappingURL=Markdown.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["Markdown.ts"],"names":["SEED_DATA","name","tag","description","category","COMPONENT_TYPES","basic","props","content","label","defaultValue"],"mappings":";;;;;;;AAAA;;AAEO,MAAMA,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,UADiB;AAEvBC,EAAAA,GAAG,EAAE,mBAFkB;AAGvBC,EAAAA,WAAW,EAAE,sBAHU;AAIvBC,EAAAA,QAAQ,EAAEC,uBAAgBC,KAJH;AAKvBC,EAAAA,KAAK,EAAE;AACLC,IAAAA,OAAO,EAAE,2BAAe;AACtBC,MAAAA,KAAK,EAAE,eADe;AAEtBN,MAAAA,WAAW,EAAE,eAFS;AAGtBO,MAAAA,YAAY,EAAE;AAHQ,KAAf;AADJ;AALgB,CAAlB","sourcesContent":["import { COMPONENT_TYPES, createTextProp } from \"@draftbit/types\";\n\nexport const SEED_DATA = {\n name: \"Markdown\",\n tag: \"MarkdownComponent\",\n description: \"A markdown component\",\n category: COMPONENT_TYPES.basic,\n props: {\n content: createTextProp({\n label: \"Markdown Text\",\n description: \"Markdown Text\",\n defaultValue: null,\n }),\n },\n};\n"]}
@@ -1,13 +0,0 @@
1
- import * as React from "react";
2
- import Markdown from "react-native-markdown-display";
3
- import { withTheme } from "../theming";
4
-
5
- const MarkdownComponent = _ref => {
6
- let {
7
- content
8
- } = _ref;
9
- return /*#__PURE__*/React.createElement(Markdown, null, content);
10
- };
11
-
12
- export default withTheme(MarkdownComponent);
13
- //# sourceMappingURL=Markdown.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["Markdown.tsx"],"names":["React","Markdown","withTheme","MarkdownComponent","content"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,OAAOC,QAAP,MAAqB,+BAArB;AAEA,SAASC,SAAT,QAA0B,YAA1B;;AAMA,MAAMC,iBAAkC,GAAG,QAAiB;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AAC1D,sBAAO,oBAAC,QAAD,QAAWA,OAAX,CAAP;AACD,CAFD;;AAIA,eAAeF,SAAS,CAACC,iBAAD,CAAxB","sourcesContent":["import * as React from \"react\";\nimport Markdown from \"react-native-markdown-display\";\n\nimport { withTheme } from \"../theming\";\n\ntype Props = {\n content?: string;\n};\n\nconst MarkdownComponent: React.FC<Props> = ({ content }) => {\n return <Markdown>{content}</Markdown>;\n};\n\nexport default withTheme(MarkdownComponent);\n"]}
@@ -1,15 +0,0 @@
1
- import { COMPONENT_TYPES, createTextProp } from "@draftbit/types";
2
- export const SEED_DATA = {
3
- name: "Markdown",
4
- tag: "MarkdownComponent",
5
- description: "A markdown component",
6
- category: COMPONENT_TYPES.basic,
7
- props: {
8
- content: createTextProp({
9
- label: "Markdown Text",
10
- description: "Markdown Text",
11
- defaultValue: null
12
- })
13
- }
14
- };
15
- //# sourceMappingURL=Markdown.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["Markdown.ts"],"names":["COMPONENT_TYPES","createTextProp","SEED_DATA","name","tag","description","category","basic","props","content","label","defaultValue"],"mappings":"AAAA,SAASA,eAAT,EAA0BC,cAA1B,QAAgD,iBAAhD;AAEA,OAAO,MAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,UADiB;AAEvBC,EAAAA,GAAG,EAAE,mBAFkB;AAGvBC,EAAAA,WAAW,EAAE,sBAHU;AAIvBC,EAAAA,QAAQ,EAAEN,eAAe,CAACO,KAJH;AAKvBC,EAAAA,KAAK,EAAE;AACLC,IAAAA,OAAO,EAAER,cAAc,CAAC;AACtBS,MAAAA,KAAK,EAAE,eADe;AAEtBL,MAAAA,WAAW,EAAE,eAFS;AAGtBM,MAAAA,YAAY,EAAE;AAHQ,KAAD;AADlB;AALgB,CAAlB","sourcesContent":["import { COMPONENT_TYPES, createTextProp } from \"@draftbit/types\";\n\nexport const SEED_DATA = {\n name: \"Markdown\",\n tag: \"MarkdownComponent\",\n description: \"A markdown component\",\n category: COMPONENT_TYPES.basic,\n props: {\n content: createTextProp({\n label: \"Markdown Text\",\n description: \"Markdown Text\",\n defaultValue: null,\n }),\n },\n};\n"]}
@@ -1,12 +0,0 @@
1
- import * as React from "react";
2
- declare type Props = {
3
- content?: string;
4
- };
5
- declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<{
6
- theme: any;
7
- }, "theme"> & {
8
- theme?: import("@draftbit/react-theme-provider").$DeepPartial<any> | undefined;
9
- }> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<{
10
- theme: any;
11
- }> & React.FC<Props>, {}>;
12
- export default _default;
@@ -1,9 +0,0 @@
1
- export declare const SEED_DATA: {
2
- name: string;
3
- tag: string;
4
- description: string;
5
- category: string;
6
- props: {
7
- content: any;
8
- };
9
- };
@@ -1,7 +0,0 @@
1
- import * as React from "react";
2
- import Markdown from "react-native-markdown-display";
3
- import { withTheme } from "../theming";
4
- const MarkdownComponent = ({ content }) => {
5
- return React.createElement(Markdown, null, content);
6
- };
7
- export default withTheme(MarkdownComponent);
@@ -1,14 +0,0 @@
1
- import * as React from "react";
2
- import Markdown from "react-native-markdown-display";
3
-
4
- import { withTheme } from "../theming";
5
-
6
- type Props = {
7
- content?: string;
8
- };
9
-
10
- const MarkdownComponent: React.FC<Props> = ({ content }) => {
11
- return <Markdown>{content}</Markdown>;
12
- };
13
-
14
- export default withTheme(MarkdownComponent);
@@ -1,14 +0,0 @@
1
- import { COMPONENT_TYPES, createTextProp } from "@draftbit/types";
2
- export const SEED_DATA = {
3
- name: "Markdown",
4
- tag: "MarkdownComponent",
5
- description: "A markdown component",
6
- category: COMPONENT_TYPES.basic,
7
- props: {
8
- content: createTextProp({
9
- label: "Markdown Text",
10
- description: "Markdown Text",
11
- defaultValue: null,
12
- }),
13
- },
14
- };
@@ -1,15 +0,0 @@
1
- import { COMPONENT_TYPES, createTextProp } from "@draftbit/types";
2
-
3
- export const SEED_DATA = {
4
- name: "Markdown",
5
- tag: "MarkdownComponent",
6
- description: "A markdown component",
7
- category: COMPONENT_TYPES.basic,
8
- props: {
9
- content: createTextProp({
10
- label: "Markdown Text",
11
- description: "Markdown Text",
12
- defaultValue: null,
13
- }),
14
- },
15
- };