@draftbit/core 42.1.5 → 42.1.7-71d4c6.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 (127) hide show
  1. package/LICENSE +21 -0
  2. package/lib/commonjs/components/DatePicker/DatePicker.js +6 -1
  3. package/lib/commonjs/components/DatePicker/DatePicker.js.map +1 -1
  4. package/lib/commonjs/components/DatePicker/DatePickerComponentType.js +2 -0
  5. package/lib/commonjs/components/Divider.js +18 -5
  6. package/lib/commonjs/components/Divider.js.map +1 -1
  7. package/lib/commonjs/components/Elevation.js +14 -3
  8. package/lib/commonjs/components/Elevation.js.map +1 -1
  9. package/lib/commonjs/components/Justification.js +3 -0
  10. package/lib/commonjs/components/Picker/PickerComponent.android.js +4 -1
  11. package/lib/commonjs/components/Picker/PickerComponent.android.js.map +1 -1
  12. package/lib/commonjs/components/Picker/PickerComponent.web.js +4 -1
  13. package/lib/commonjs/components/Picker/PickerComponent.web.js.map +1 -1
  14. package/lib/commonjs/components/Picker/PickerTypes.js +3 -0
  15. package/lib/commonjs/components/Portal/PortalHost.js.map +1 -1
  16. package/lib/commonjs/components/ResizeMode.js +3 -0
  17. package/lib/module/components/DatePicker/DatePicker.js +6 -1
  18. package/lib/module/components/DatePicker/DatePicker.js.map +1 -1
  19. package/lib/module/components/DatePicker/DatePickerComponentType.js +1 -1
  20. package/lib/module/components/Justification.js +1 -1
  21. package/lib/module/components/Picker/PickerComponent.android.js +4 -1
  22. package/lib/module/components/Picker/PickerComponent.android.js.map +1 -1
  23. package/lib/module/components/Picker/PickerComponent.web.js +4 -1
  24. package/lib/module/components/Picker/PickerComponent.web.js.map +1 -1
  25. package/lib/module/components/Picker/PickerTypes.js +1 -1
  26. package/lib/module/components/ResizeMode.js +1 -1
  27. package/package.json +3 -2
  28. package/src/Provider.js +9 -0
  29. package/src/components/Accordion/AccordionGroup.js +94 -0
  30. package/src/components/Accordion/AccordionItem.js +48 -0
  31. package/src/components/Accordion/index.js +2 -0
  32. package/src/components/ActionSheet/ActionSheet.js +57 -0
  33. package/src/components/ActionSheet/ActionSheetCancel.js +28 -0
  34. package/src/components/ActionSheet/ActionSheetItem.js +49 -0
  35. package/src/components/ActionSheet/index.js +3 -0
  36. package/src/components/AnimatedCircularProgress.js +43 -0
  37. package/src/components/AspectRatio.js +18 -0
  38. package/src/components/AvatarEdit.js +67 -0
  39. package/src/components/Button.js +187 -0
  40. package/src/components/Card.js +109 -0
  41. package/src/components/CardBlock.js +176 -0
  42. package/src/components/CardContainer.js +171 -0
  43. package/src/components/CardContainerRating.js +203 -0
  44. package/src/components/CardContainerShortImage.js +151 -0
  45. package/src/components/CardInline.js +87 -0
  46. package/src/components/Carousel.js +85 -0
  47. package/src/components/Checkbox/Checkbox.js +114 -0
  48. package/src/components/Checkbox/CheckboxGroup.js +46 -0
  49. package/src/components/Checkbox/CheckboxRow.js +109 -0
  50. package/src/components/Checkbox/context.js +14 -0
  51. package/src/components/Checkbox/index.js +3 -0
  52. package/src/components/CircleImage.js +32 -0
  53. package/src/components/CircularProgress.js +78 -0
  54. package/src/components/Config.js +63 -0
  55. package/src/components/Container.js +73 -0
  56. package/src/components/DatePicker/DatePicker.js +379 -0
  57. package/src/components/DatePicker/DatePicker.tsx +7 -1
  58. package/src/components/DatePicker/DatePickerComponent.js +13 -0
  59. package/src/components/DatePicker/DatePickerComponent.web.js +30 -0
  60. package/src/components/DatePicker/DatePickerComponentType.js +1 -0
  61. package/src/components/DeprecatedButton.js +201 -0
  62. package/src/components/DeprecatedCardWrapper.js +18 -0
  63. package/src/components/DeprecatedFAB.js +261 -0
  64. package/src/components/Divider.js +39 -0
  65. package/src/components/Elevation.js +20 -0
  66. package/src/components/FAB.js +82 -0
  67. package/src/components/FieldSearchBarFull.js +92 -0
  68. package/src/components/FormRow.js +19 -0
  69. package/src/components/Header.js +44 -0
  70. package/src/components/HeaderLarge.js +35 -0
  71. package/src/components/HeaderMedium.js +61 -0
  72. package/src/components/HeaderOverline.js +61 -0
  73. package/src/components/IconButton.js +65 -0
  74. package/src/components/Image.js +62 -0
  75. package/src/components/Justification.js +1 -0
  76. package/src/components/Layout.js +245 -0
  77. package/src/components/Picker/Picker.js +204 -0
  78. package/src/components/Picker/PickerComponent.android.js +68 -0
  79. package/src/components/Picker/PickerComponent.android.tsx +6 -1
  80. package/src/components/Picker/PickerComponent.ios.js +72 -0
  81. package/src/components/Picker/PickerComponent.web.js +68 -0
  82. package/src/components/Picker/PickerComponent.web.tsx +6 -1
  83. package/src/components/Picker/PickerTypes.js +1 -0
  84. package/src/components/Portal/Portal.js +35 -0
  85. package/src/components/Portal/PortalConsumer.js +28 -0
  86. package/src/components/Portal/PortalHost.js +105 -0
  87. package/src/components/Portal/PortalManager.js +29 -0
  88. package/src/components/ProgressBar.js +218 -0
  89. package/src/components/ProgressCircle.js +121 -0
  90. package/src/components/ProgressIndicator.js +207 -0
  91. package/src/components/RadioButton/RadioButton.js +66 -0
  92. package/src/components/RadioButton/RadioButtonFieldGroup.js +17 -0
  93. package/src/components/RadioButton/RadioButtonGroup.js +43 -0
  94. package/src/components/RadioButton/RadioButtonRow.js +111 -0
  95. package/src/components/RadioButton/context.js +14 -0
  96. package/src/components/RadioButton/index.js +4 -0
  97. package/src/components/ResizeMode.js +1 -0
  98. package/src/components/Row.js +48 -0
  99. package/src/components/RowBodyIcon.js +83 -0
  100. package/src/components/RowHeadlineImageCaption.js +179 -0
  101. package/src/components/RowHeadlineImageIcon.js +113 -0
  102. package/src/components/ScreenContainer.js +35 -0
  103. package/src/components/Slider.js +114 -0
  104. package/src/components/StarRating.js +80 -0
  105. package/src/components/StepIndicator.js +346 -0
  106. package/src/components/Stepper.js +69 -0
  107. package/src/components/Surface.js +36 -0
  108. package/src/components/Switch.js +59 -0
  109. package/src/components/Text.js +232 -0
  110. package/src/components/TextField.js +552 -0
  111. package/src/components/TextInput.js +13 -0
  112. package/src/components/ToggleButton.js +75 -0
  113. package/src/components/Touchable.js +24 -0
  114. package/src/components/Touchable.web.js +2 -0
  115. package/src/components/Typography.js +36 -0
  116. package/src/components/useAuthState.js +31 -0
  117. package/src/constants.js +10 -0
  118. package/src/hooks.js +12 -0
  119. package/src/index.js +48 -0
  120. package/src/interfaces/Icon.js +8 -0
  121. package/src/styles/DarkTheme.js +26 -0
  122. package/src/styles/DefaultTheme.js +111 -0
  123. package/src/styles/fonts.js +62 -0
  124. package/src/styles/overlay.js +60 -0
  125. package/src/styles/shadow.js +51 -0
  126. package/src/theming.js +3 -0
  127. package/src/utilities.js +42 -0
@@ -0,0 +1,171 @@
1
+ import React from "react";
2
+ import { View, Text, } from "react-native";
3
+ import color from "color";
4
+ import Image from "./Image";
5
+ import Card from "./DeprecatedCardWrapper";
6
+ import Elevation from "./Elevation";
7
+ import { withTheme } from "../theming";
8
+ import { GROUPS, FORM_TYPES, PROP_TYPES, COMPONENT_TYPES, createElevationType, createNumColumnsType, } from "@draftbit/types";
9
+ import Config from "./Config";
10
+ const ICON_CONTAINER_SIZE = Config.cardIconSize * 2;
11
+ const ICON_CONTAINER_PADDING = Config.cardIconSize / 2 - 1;
12
+ const CardContainer = ({ Icon, icon, image = Config.cardImageUrl, title, leftDescription, rightDescription, textCentered, aspectRatio = 1.5, elevation = 2, numColumns = 3, theme: { colors, roundness, typography }, style, onPress, ...rest }) => {
13
+ let textJustification;
14
+ let titleStyle;
15
+ if (textCentered && !rightDescription) {
16
+ textJustification = "center";
17
+ }
18
+ else {
19
+ textJustification = "space-between";
20
+ }
21
+ switch (numColumns) {
22
+ case 2:
23
+ titleStyle = typography.headline6;
24
+ break;
25
+ case 3:
26
+ titleStyle = typography.headline5;
27
+ break;
28
+ }
29
+ return (React.createElement(Card, { style: style, onPress: onPress, numColumns: numColumns, ...rest },
30
+ React.createElement(Elevation, { style: { elevation, borderRadius: roundness } },
31
+ React.createElement(View, { style: {
32
+ borderRadius: roundness,
33
+ overflow: "hidden",
34
+ backgroundColor: colors.surface,
35
+ } },
36
+ React.createElement(Image, { style: { aspectRatio }, source: typeof image === "string" ? { uri: image } : image, resizeMode: "cover" }),
37
+ React.createElement(View, { style: {
38
+ padding: numColumns === 1 ? 8 : 16,
39
+ } },
40
+ title ? (React.createElement(View, { style: {
41
+ flexDirection: "row",
42
+ alignItems: "center",
43
+ justifyContent: textJustification,
44
+ } },
45
+ React.createElement(Text, { numberOfLines: 1, style: [titleStyle, { color: colors.strong }] }, title))) : null,
46
+ leftDescription ? (React.createElement(View, { style: {
47
+ flexDirection: "row",
48
+ justifyContent: textJustification,
49
+ alignItems: "center",
50
+ marginTop: numColumns === 3 ? 4 : 4 / 2,
51
+ } },
52
+ React.createElement(Text, { numberOfLines: 1, style: [typography.body2, { color: colors.medium }] }, leftDescription),
53
+ rightDescription ? (React.createElement(Text, { numberOfLines: 1, style: [typography.subtitle2, { color: colors.light }] }, rightDescription)) : null)) : null),
54
+ icon ? (React.createElement(Elevation, { style: {
55
+ elevation: Config.cardIconElevation,
56
+ position: "absolute",
57
+ top: 12,
58
+ right: 12,
59
+ width: ICON_CONTAINER_SIZE,
60
+ height: ICON_CONTAINER_SIZE,
61
+ padding: ICON_CONTAINER_PADDING,
62
+ borderRadius: ICON_CONTAINER_SIZE,
63
+ backgroundColor: color(colors.strong)
64
+ .alpha(Config.cardIconBackgroundOpacity)
65
+ .rgb()
66
+ .string(),
67
+ } },
68
+ React.createElement(Icon, { name: icon, size: Config.cardIconSize, color: colors.surface }))) : null))));
69
+ };
70
+ export default withTheme(CardContainer);
71
+ const SEED_DATA_PROPS = {
72
+ image: {
73
+ label: "Image",
74
+ description: "Image",
75
+ formType: FORM_TYPES.image,
76
+ propType: PROP_TYPES.ASSET,
77
+ defaultValue: null,
78
+ editable: true,
79
+ required: true,
80
+ group: GROUPS.data,
81
+ },
82
+ title: {
83
+ label: "Title",
84
+ description: "Text to display",
85
+ formType: FORM_TYPES.string,
86
+ propType: PROP_TYPES.STRING,
87
+ defaultValue: "Beautiful West Coast Villa",
88
+ editable: true,
89
+ required: false,
90
+ group: GROUPS.data,
91
+ },
92
+ leftDescription: {
93
+ label: "Left description",
94
+ description: "Text to display on the left",
95
+ formType: FORM_TYPES.string,
96
+ propType: PROP_TYPES.STRING,
97
+ defaultValue: "San Diego",
98
+ editable: true,
99
+ required: false,
100
+ group: GROUPS.data,
101
+ },
102
+ rightDescription: {
103
+ label: "Right description",
104
+ description: "Text to display on the right",
105
+ formType: FORM_TYPES.string,
106
+ propType: PROP_TYPES.STRING,
107
+ defaultValue: "$100",
108
+ editable: true,
109
+ required: false,
110
+ group: GROUPS.data,
111
+ },
112
+ icon: {
113
+ label: "Icon",
114
+ description: "Icon to display on the top right",
115
+ formType: FORM_TYPES.icon,
116
+ propType: PROP_TYPES.STRING /* OR ASSET TODO TEST ME */,
117
+ defaultValue: null,
118
+ editable: true,
119
+ required: false,
120
+ group: GROUPS.basic,
121
+ },
122
+ aspectRatio: {
123
+ label: "Aspect ratio",
124
+ description: "Aspect ratio of the image",
125
+ formType: FORM_TYPES.aspectRatio,
126
+ propType: PROP_TYPES.NUMBER,
127
+ defaultValue: 1.5,
128
+ editable: true,
129
+ required: false,
130
+ group: GROUPS.basic,
131
+ },
132
+ textCentered: {
133
+ label: "Centered Text",
134
+ description: "Whether to center the text",
135
+ formType: FORM_TYPES.boolean,
136
+ propType: PROP_TYPES.BOOLEAN,
137
+ defaultValue: false,
138
+ editable: true,
139
+ required: false,
140
+ group: GROUPS.basic,
141
+ },
142
+ elevation: createElevationType(2),
143
+ };
144
+ export const SEED_DATA = [
145
+ {
146
+ name: "Medium Card",
147
+ tag: "CardContainer",
148
+ description: "An elevated card with a title and description, that takes up half of its container.",
149
+ category: COMPONENT_TYPES.card,
150
+ layout: null,
151
+ props: {
152
+ ...SEED_DATA_PROPS,
153
+ numColumns: createNumColumnsType({
154
+ defaultValue: 2,
155
+ }),
156
+ },
157
+ },
158
+ {
159
+ name: "Large Card",
160
+ tag: "CardContainer",
161
+ description: "An elevated card with a title and description, that takes up its full container.",
162
+ category: COMPONENT_TYPES.card,
163
+ layout: null,
164
+ props: {
165
+ ...SEED_DATA_PROPS,
166
+ numColumns: createNumColumnsType({
167
+ defaultValue: 3,
168
+ }),
169
+ },
170
+ },
171
+ ];
@@ -0,0 +1,203 @@
1
+ import React from "react";
2
+ import { View, Text, } from "react-native";
3
+ import color from "color";
4
+ import Image from "./Image";
5
+ import Card from "./DeprecatedCardWrapper";
6
+ import Elevation from "./Elevation";
7
+ import StarRating from "./StarRating";
8
+ import { withTheme } from "../theming";
9
+ import { GROUPS, FORM_TYPES, PROP_TYPES, COMPONENT_TYPES, createElevationType, } from "@draftbit/types";
10
+ import Config from "./Config";
11
+ const ICON_CONTAINER_SIZE = Config.cardIconSize * 2;
12
+ const ICON_CONTAINER_PADDING = Config.cardIconSize / 2 - 1;
13
+ const CardContainerRating = ({ Icon, icon, image = Config.cardImageUrl, title, leftDescription, rightDescription, rating, aspectRatio = 1.5, elevation = 2, numColumns = 3, theme: { colors, roundness, typography }, style, onPress, ...rest }) => {
14
+ let titleStyle, rightDescriptionStyle;
15
+ switch (numColumns) {
16
+ case 2:
17
+ titleStyle = typography.headline6;
18
+ rightDescriptionStyle = typography.body2;
19
+ break;
20
+ case 3:
21
+ titleStyle = typography.headline5;
22
+ rightDescriptionStyle = typography.caption;
23
+ break;
24
+ }
25
+ return (React.createElement(Card, { style: style, onPress: onPress, numColumns: numColumns, ...rest },
26
+ React.createElement(Elevation, { style: { elevation, borderRadius: roundness } },
27
+ React.createElement(View, { style: {
28
+ borderRadius: roundness,
29
+ overflow: "hidden",
30
+ backgroundColor: colors.background,
31
+ //background color is needed for bug on android 9 - https://github.com/facebook/react-native/issues/25093
32
+ } },
33
+ React.createElement(Image, { style: { aspectRatio }, source: typeof image === "string" ? { uri: image } : image, resizeMode: "cover" }),
34
+ React.createElement(View, { style: {
35
+ padding: numColumns === 1 ? 8 : 16,
36
+ } },
37
+ title ? (React.createElement(View, { style: {
38
+ flexDirection: "row",
39
+ alignItems: "center",
40
+ justifyContent: "space-between",
41
+ } },
42
+ React.createElement(Text, { numberOfLines: 1, style: [titleStyle, { color: colors.strong }] }, title))) : null,
43
+ leftDescription ? (React.createElement(Text, { numberOfLines: 1, style: [
44
+ typography.body2,
45
+ {
46
+ color: colors.medium,
47
+ marginTop: numColumns === 3 ? 4 : 4 / 2,
48
+ },
49
+ ] }, leftDescription)) : null,
50
+ React.createElement(View, { style: {
51
+ flexDirection: "row",
52
+ justifyContent: "space-between",
53
+ alignItems: "center",
54
+ marginTop: numColumns === 3 ? 16 : 12,
55
+ } },
56
+ React.createElement(StarRating, { Icon: Icon, starSize: numColumns === 1 ? 10 : 16, rating: rating }),
57
+ React.createElement(Text, { style: [
58
+ rightDescriptionStyle,
59
+ {
60
+ color: colors.medium,
61
+ marginLeft: 8,
62
+ },
63
+ ], numberOfLines: 1 }, rightDescription))),
64
+ icon ? (React.createElement(Elevation, { style: {
65
+ elevation: Config.cardIconElevation,
66
+ position: "absolute",
67
+ top: 12,
68
+ right: 12,
69
+ width: ICON_CONTAINER_SIZE,
70
+ height: ICON_CONTAINER_SIZE,
71
+ padding: ICON_CONTAINER_PADDING,
72
+ borderRadius: ICON_CONTAINER_SIZE,
73
+ backgroundColor: color(colors.strong)
74
+ .alpha(Config.cardIconBackgroundOpacity)
75
+ .rgb()
76
+ .string(),
77
+ } },
78
+ React.createElement(Icon, { name: icon, size: Config.cardIconSize, color: colors.surface }))) : null))));
79
+ };
80
+ export default withTheme(CardContainerRating);
81
+ const SEED_DATA_PROPS = {
82
+ image: {
83
+ group: GROUPS.data,
84
+ label: "Image",
85
+ description: "Image",
86
+ formType: FORM_TYPES.image,
87
+ propType: PROP_TYPES.ASSET,
88
+ defaultValue: null,
89
+ editable: true,
90
+ required: false,
91
+ },
92
+ title: {
93
+ group: GROUPS.data,
94
+ label: "Title",
95
+ description: "Text to display",
96
+ formType: FORM_TYPES.string,
97
+ propType: PROP_TYPES.STRING,
98
+ defaultValue: "Beautiful West Coast Villa",
99
+ editable: true,
100
+ required: false,
101
+ },
102
+ leftDescription: {
103
+ group: GROUPS.data,
104
+ label: "Left description",
105
+ description: "Text to display on the left",
106
+ formType: FORM_TYPES.string,
107
+ propType: PROP_TYPES.STRING,
108
+ defaultValue: "San Diego",
109
+ editable: true,
110
+ required: false,
111
+ },
112
+ rightDescription: {
113
+ group: GROUPS.data,
114
+ label: "Right description",
115
+ description: "Text to display on the right",
116
+ formType: FORM_TYPES.string,
117
+ propType: PROP_TYPES.STRING,
118
+ defaultValue: "$100",
119
+ editable: true,
120
+ required: false,
121
+ },
122
+ icon: {
123
+ group: GROUPS.basic,
124
+ label: "Icon",
125
+ description: "Icon to display on the top right",
126
+ formType: FORM_TYPES.icon,
127
+ propType: PROP_TYPES.ASSET,
128
+ defaultValue: null,
129
+ editable: true,
130
+ required: false,
131
+ },
132
+ aspectRatio: {
133
+ group: GROUPS.basic,
134
+ label: "Aspect ratio",
135
+ description: "Aspect ratio of the image",
136
+ formType: FORM_TYPES.aspectRatio,
137
+ propType: PROP_TYPES.NUMBER,
138
+ defaultValue: 1.5,
139
+ editable: true,
140
+ required: false,
141
+ },
142
+ rating: {
143
+ group: GROUPS.data,
144
+ label: "Rating",
145
+ description: "Number of stars to show. A number 0-5.",
146
+ formType: FORM_TYPES.number,
147
+ propType: PROP_TYPES.NUMBER,
148
+ defaultValue: 5,
149
+ min: 0,
150
+ max: 5,
151
+ step: 1,
152
+ precision: 0,
153
+ editable: true,
154
+ required: false,
155
+ },
156
+ elevation: createElevationType(2),
157
+ };
158
+ export const SEED_DATA = [
159
+ {
160
+ name: "Medium Card (Rating)",
161
+ tag: "CardContainerRating",
162
+ description: "An elevated card with a title and description, that takes up half of its container.",
163
+ category: COMPONENT_TYPES.card,
164
+ preview_image_url: "{CLOUDINARY_URL}/Card_ContainerRating_2col.png",
165
+ supports_list_render: true,
166
+ props: {
167
+ ...SEED_DATA_PROPS,
168
+ numColumns: {
169
+ label: "Number of Columns",
170
+ description: "Numbre of columns",
171
+ group: GROUPS.uncategorized,
172
+ formType: FORM_TYPES.number,
173
+ propType: PROP_TYPES.NUMBER,
174
+ defaultValue: 2,
175
+ editable: false,
176
+ required: false,
177
+ },
178
+ },
179
+ layout: {},
180
+ },
181
+ {
182
+ name: "Large Card (Rating)",
183
+ tag: "CardContainerRating",
184
+ description: "An elevated card with a title and description, that takes up its full container.",
185
+ category: COMPONENT_TYPES.card,
186
+ preview_image_url: "{CLOUDINARY_URL}/Card_ContainerRating_3col.png",
187
+ supports_list_render: true,
188
+ props: {
189
+ ...SEED_DATA_PROPS,
190
+ numColumns: {
191
+ label: "Number of Columns",
192
+ description: "Numbre of columns",
193
+ group: GROUPS.uncategorized,
194
+ formType: FORM_TYPES.number,
195
+ propType: PROP_TYPES.NUMBER,
196
+ defaultValue: 3,
197
+ editable: false,
198
+ required: false,
199
+ },
200
+ },
201
+ layout: {},
202
+ },
203
+ ];
@@ -0,0 +1,151 @@
1
+ import React from "react";
2
+ import { View, Text, } from "react-native";
3
+ import Image from "./Image";
4
+ import Card from "./DeprecatedCardWrapper";
5
+ import Elevation from "./Elevation";
6
+ import { withTheme } from "../theming";
7
+ import { GROUPS, COMPONENT_TYPES, FORM_TYPES, PROP_TYPES, createElevationType, } from "@draftbit/types";
8
+ import Config from "./Config";
9
+ const CardContainerShortImage = ({ image = Config.squareImageUrl, title, subtitle, mode = "left", aspectRatio = 1, elevation = 2, theme: { colors, roundness, typography }, style, onPress, ...rest }) => {
10
+ return (React.createElement(Card, { style: style, onPress: onPress, ...rest },
11
+ React.createElement(Elevation, { style: {
12
+ elevation,
13
+ borderRadius: roundness,
14
+ } },
15
+ React.createElement(View, { style: {
16
+ overflow: "hidden",
17
+ flexDirection: "row",
18
+ justifyContent: mode === "right" ? "space-between" : "flex-start",
19
+ borderRadius: roundness,
20
+ } },
21
+ mode === "left" && (React.createElement(Image, { style: { aspectRatio }, source: typeof image === "string" ? { uri: image } : image, resizeMode: "cover" })),
22
+ React.createElement(View, { style: {
23
+ padding: 16,
24
+ backgroundColor: colors.surface,
25
+ flex: 1,
26
+ } },
27
+ React.createElement(Text, { numberOfLines: 1, style: [typography.headline5, { color: colors.strong }] }, title),
28
+ subtitle ? (React.createElement(Text, { numberOfLines: 1, style: [
29
+ typography.body2,
30
+ { color: colors.medium, marginTop: 4 },
31
+ ] }, subtitle)) : null),
32
+ mode === "right" && (React.createElement(Image, { style: { aspectRatio }, source: typeof image === "string" ? { uri: image } : image, resizeMode: "cover" }))))));
33
+ };
34
+ export default withTheme(CardContainerShortImage);
35
+ export const SEED_DATA = [
36
+ {
37
+ name: "Short Card (Left)",
38
+ tag: "CardContainerShortImage",
39
+ description: "An elevated card with a left aligned image and a title and subtitle",
40
+ category: COMPONENT_TYPES.card,
41
+ preview_image_url: "{CLOUDINARY_URL}/Card_ContainerShortLeftImage.png",
42
+ supports_list_render: true,
43
+ props: {
44
+ image: {
45
+ group: GROUPS.data,
46
+ label: "Image",
47
+ description: "Image",
48
+ formType: FORM_TYPES.image,
49
+ propType: PROP_TYPES.ASSET,
50
+ defaultValue: null,
51
+ editable: true,
52
+ required: false,
53
+ },
54
+ title: {
55
+ group: GROUPS.data,
56
+ label: "Title",
57
+ description: "Title to display",
58
+ formType: FORM_TYPES.string,
59
+ propType: PROP_TYPES.STRING,
60
+ defaultValue: "Beautiful West Coast Villa",
61
+ editable: true,
62
+ required: false,
63
+ },
64
+ subtitle: {
65
+ group: GROUPS.data,
66
+ label: "Subtitle",
67
+ description: "Subtitle to display",
68
+ formType: FORM_TYPES.string,
69
+ propType: PROP_TYPES.STRING,
70
+ defaultValue: "San Diego",
71
+ editable: true,
72
+ required: false,
73
+ },
74
+ aspectRatio: {
75
+ group: GROUPS.basic,
76
+ label: "Aspect ratio",
77
+ description: "Aspect ratio of the image",
78
+ formType: FORM_TYPES.aspectRatio,
79
+ propType: PROP_TYPES.STRING,
80
+ defaultValue: null,
81
+ editable: true,
82
+ required: false,
83
+ },
84
+ elevation: createElevationType(2),
85
+ mode: {
86
+ group: GROUPS.uncategorized,
87
+ label: "Image Side",
88
+ description: "The side on which the image is on (left or right)",
89
+ formType: FORM_TYPES.flatArray,
90
+ propType: PROP_TYPES.STRING,
91
+ defaultValue: "left",
92
+ options: ["left", "right"],
93
+ editable: false,
94
+ required: false,
95
+ },
96
+ },
97
+ layout: {},
98
+ },
99
+ {
100
+ name: "Short Card (Right)",
101
+ tag: "CardContainerShortImage",
102
+ description: "An elevated card with a right aligned image and a title and subtitle",
103
+ category: COMPONENT_TYPES.card,
104
+ preview_image_url: "{CLOUDINARY_URL}/Card_ContainerShortRightImage.png",
105
+ supports_list_render: true,
106
+ props: {
107
+ image: {
108
+ group: GROUPS.data,
109
+ label: "Image",
110
+ description: "Image",
111
+ formType: FORM_TYPES.image,
112
+ propType: PROP_TYPES.ASSET,
113
+ defaultValue: null,
114
+ editable: true,
115
+ required: false,
116
+ },
117
+ title: {
118
+ group: GROUPS.data,
119
+ label: "Title",
120
+ description: "Title to display",
121
+ formType: FORM_TYPES.string,
122
+ propType: PROP_TYPES.STRING,
123
+ defaultValue: "Beautiful West Coast Villa",
124
+ editable: true,
125
+ required: false,
126
+ },
127
+ subtitle: {
128
+ group: GROUPS.data,
129
+ label: "Subtitle",
130
+ description: "Subtitle to display",
131
+ formType: FORM_TYPES.string,
132
+ propType: PROP_TYPES.STRING,
133
+ defaultValue: "San Diego",
134
+ editable: true,
135
+ required: false,
136
+ },
137
+ elevation: createElevationType(2),
138
+ mode: {
139
+ label: "Mode",
140
+ description: "Mode",
141
+ group: GROUPS.uncategorized,
142
+ formType: FORM_TYPES.string,
143
+ propType: PROP_TYPES.STRING,
144
+ defaultValue: "right",
145
+ editable: false,
146
+ required: false,
147
+ },
148
+ },
149
+ layout: {},
150
+ },
151
+ ];
@@ -0,0 +1,87 @@
1
+ // @ts-nocheck
2
+ import React from "react";
3
+ import { Pressable, View, StyleSheet, } from "react-native";
4
+ import { Title, Subtitle } from "./Typography";
5
+ import Image from "./Image";
6
+ import Surface from "./Surface";
7
+ import Config from "./Config";
8
+ import { withTheme } from "../theming";
9
+ import { GROUPS, COMPONENT_TYPES, FORM_TYPES, PROP_TYPES, createElevationType, } from "@draftbit/types";
10
+ const CardInline = ({ image = Config.cardImageUrl, title, subtitle, aspectRatio = 1.5, elevation = 2, style, titleStyle, subtitleStyle, onPress, }) => {
11
+ const { alignItems, justifyContent, width, height } = StyleSheet.flatten(style || {});
12
+ const imageStyles = width && height ? { width, height } : { aspectRatio };
13
+ return (React.createElement(Surface, { style: [{ elevation }, style] },
14
+ React.createElement(Pressable, { disabled: !onPress, onPress: onPress, style: ({ pressed }) => {
15
+ return [
16
+ {
17
+ opacity: pressed ? 0.8 : 1,
18
+ },
19
+ ];
20
+ } },
21
+ React.createElement(Image, { style: imageStyles, source: typeof image === "string" ? { uri: image } : image, resizeMode: "cover" }),
22
+ React.createElement(View, { style: [styles.overlay, { justifyContent, alignItems }] },
23
+ title ? (React.createElement(Title, { style: [{ color: "white" }, titleStyle], text: title })) : null,
24
+ subtitle ? (React.createElement(Subtitle, { style: [{ color: "rgba(255, 255, 255, 0.7)" }, subtitleStyle], text: subtitle })) : null))));
25
+ };
26
+ const styles = StyleSheet.create({
27
+ overlay: {
28
+ position: "absolute",
29
+ top: 0,
30
+ bottom: 0,
31
+ left: 0,
32
+ right: 0,
33
+ padding: 16,
34
+ backgroundColor: "rgba(0, 0, 0, 0.2)",
35
+ },
36
+ });
37
+ export default withTheme(CardInline);
38
+ export const SEED_DATA = {
39
+ name: "Inline Card",
40
+ tag: "CardInline",
41
+ description: "An elevated card with image and a title and description overlayed, that takes up the full width of its container.",
42
+ category: COMPONENT_TYPES.card,
43
+ layout: {},
44
+ props: {
45
+ image: {
46
+ group: GROUPS.data,
47
+ label: "Image",
48
+ description: "Image",
49
+ formType: FORM_TYPES.image,
50
+ propType: PROP_TYPES.ASSET,
51
+ defaultValue: null,
52
+ editable: true,
53
+ required: false,
54
+ },
55
+ title: {
56
+ group: GROUPS.data,
57
+ label: "Title",
58
+ description: "Text to display",
59
+ formType: FORM_TYPES.string,
60
+ propType: PROP_TYPES.STRING,
61
+ defaultValue: "Beautiful West Coast Villa",
62
+ editable: true,
63
+ required: false,
64
+ },
65
+ subtitle: {
66
+ group: GROUPS.data,
67
+ label: "Subtitle",
68
+ description: "Subtitle text",
69
+ formType: FORM_TYPES.string,
70
+ propType: PROP_TYPES.STRING,
71
+ defaultValue: "San Diego",
72
+ editable: true,
73
+ required: false,
74
+ },
75
+ aspectRatio: {
76
+ group: GROUPS.basic,
77
+ label: "Aspect ratio",
78
+ description: "Aspect ratio of the image",
79
+ formType: FORM_TYPES.aspectRatio,
80
+ propType: PROP_TYPES.NUMBER,
81
+ defaultValue: 1.5,
82
+ editable: true,
83
+ required: false,
84
+ },
85
+ elevation: createElevationType(2),
86
+ },
87
+ };