@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,61 @@
1
+ import * as React from "react";
2
+ import { withTheme } from "../theming";
3
+ import { GROUPS, COMPONENT_TYPES, FORM_TYPES, PROP_TYPES, } from "@draftbit/types";
4
+ import Header from "./Header";
5
+ const HeaderOverline = ({ Icon, title, buttonText, icon, onPress = () => { }, style, theme: { colors, typography }, }) => {
6
+ return (React.createElement(Header, { Icon: Icon, titleTypeStyle: typography.overline, titleColor: colors.light, title: title && title.toUpperCase(), buttonText: buttonText, icon: icon, dividerTopMargin: 12, onPress: onPress, style: style }));
7
+ };
8
+ export default withTheme(HeaderOverline);
9
+ export const SEED_DATA = [
10
+ {
11
+ name: "Header Overline",
12
+ tag: "HeaderOverline",
13
+ description: "A small header with an optional touchable right aligned text and icon.",
14
+ category: COMPONENT_TYPES.header,
15
+ preview_image_url: "{CLOUDINARY_URL}/Header_OverlineIconText.png",
16
+ supports_list_render: false,
17
+ props: {
18
+ title: {
19
+ group: GROUPS.data,
20
+ label: "Title",
21
+ description: "Text to display",
22
+ formType: FORM_TYPES.string,
23
+ propType: PROP_TYPES.STRING,
24
+ defaultValue: "Title",
25
+ editable: true,
26
+ required: false,
27
+ },
28
+ buttonText: {
29
+ group: GROUPS.data,
30
+ label: "Button text",
31
+ description: "Right aligned button text to display",
32
+ formType: FORM_TYPES.string,
33
+ propType: PROP_TYPES.STRING,
34
+ defaultValue: "See All",
35
+ editable: true,
36
+ required: false,
37
+ },
38
+ icon: {
39
+ group: GROUPS.basic,
40
+ label: "Icon",
41
+ description: "Name of icon to display",
42
+ formType: FORM_TYPES.icon,
43
+ propType: PROP_TYPES.ASSET,
44
+ defaultValue: null,
45
+ editable: true,
46
+ required: false,
47
+ },
48
+ onPress: {
49
+ group: GROUPS.basic,
50
+ label: "Action",
51
+ description: "Action to execute when button pressed",
52
+ editable: true,
53
+ required: false,
54
+ formType: FORM_TYPES.action,
55
+ propType: PROP_TYPES.STRING,
56
+ defaultValue: null,
57
+ },
58
+ },
59
+ layout: {},
60
+ },
61
+ ];
@@ -0,0 +1,65 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet, ActivityIndicator, Pressable, Platform, } from "react-native";
3
+ import { withTheme } from "../theming";
4
+ import { COMPONENT_TYPES, GROUPS, createIconProp, createColorProp, createNumberProp, createBoolProp, createActionProp, Triggers, } from "@draftbit/types";
5
+ const IconButton = ({ Icon, icon, color: customColor, size = 32, disabled = false, loading = false, onPress, theme, style, ...props }) => {
6
+ const iconColor = customColor || theme.colors.primary;
7
+ return (React.createElement(Pressable, { onPress: onPress, disabled: disabled || loading, style: ({ pressed }) => {
8
+ return [
9
+ styles.container,
10
+ {
11
+ opacity: pressed || disabled ? 0.75 : 1,
12
+ width: size,
13
+ height: size,
14
+ alignItems: "center",
15
+ justifyContent: "center",
16
+ },
17
+ style,
18
+ ];
19
+ }, ...props },
20
+ React.createElement(View, null,
21
+ icon && !loading ? (React.createElement(Icon, { name: icon, size: size - 2, color: iconColor })) : null,
22
+ loading ? React.createElement(ActivityIndicator, { size: "small", color: iconColor }) : null)));
23
+ };
24
+ const styles = StyleSheet.create({
25
+ container: {
26
+ alignItems: "center",
27
+ justifyContent: "center",
28
+ ...Platform.select({
29
+ web: {
30
+ cursor: "pointer",
31
+ userSelect: "none",
32
+ },
33
+ }),
34
+ },
35
+ });
36
+ export default withTheme(IconButton);
37
+ export const SEED_DATA = {
38
+ name: "Icon Button",
39
+ tag: "IconButton",
40
+ category: COMPONENT_TYPES.button,
41
+ layout: {},
42
+ triggers: [Triggers.OnPress],
43
+ props: {
44
+ onPress: createActionProp(),
45
+ icon: createIconProp(),
46
+ color: createColorProp({
47
+ label: "Color",
48
+ group: GROUPS.basic,
49
+ }),
50
+ disabled: createBoolProp({
51
+ label: "Disabled",
52
+ group: GROUPS.basic,
53
+ }),
54
+ size: createNumberProp({
55
+ group: GROUPS.basic,
56
+ label: "Size",
57
+ description: "Width and height of your icon",
58
+ defaultValue: 32,
59
+ min: 16,
60
+ max: 128,
61
+ step: 1,
62
+ precision: 0,
63
+ }),
64
+ },
65
+ };
@@ -0,0 +1,62 @@
1
+ /* README: Internal Image component used for stuff like Card. DO NOT EXPORT! */
2
+ import React from "react";
3
+ import { Image as NativeImage, StyleSheet, } from "react-native";
4
+ import Config from "./Config";
5
+ import { COMPONENT_TYPES, createImageProp, createResizeModeProp, } from "@draftbit/types";
6
+ import AspectRatio from "./AspectRatio";
7
+ const generateDimensions = ({ aspectRatio, width, height }) => {
8
+ if (aspectRatio && !width && !height) {
9
+ return {
10
+ aspectRatio,
11
+ width: "100%",
12
+ };
13
+ }
14
+ if (aspectRatio && height) {
15
+ return {
16
+ aspectRatio,
17
+ height,
18
+ width: aspectRatio * height,
19
+ };
20
+ }
21
+ if (aspectRatio && width) {
22
+ return {
23
+ aspectRatio,
24
+ width,
25
+ height: width / aspectRatio,
26
+ };
27
+ }
28
+ return { width, height };
29
+ };
30
+ const Image = ({ source, resizeMode = "cover", style, ...props }) => {
31
+ let imageSource = source === null || source === undefined
32
+ ? Config.placeholderImageURL
33
+ : source;
34
+ const styles = StyleSheet.flatten(style || {});
35
+ const { aspectRatio, width, height } = generateDimensions(styles);
36
+ if (aspectRatio) {
37
+ return (React.createElement(AspectRatio, { style: [style, { width, height, aspectRatio }] },
38
+ React.createElement(NativeImage, { ...props, source: imageSource, resizeMode: resizeMode, style: [
39
+ style,
40
+ {
41
+ height: "100%",
42
+ width: "100%",
43
+ },
44
+ ] })));
45
+ }
46
+ return (React.createElement(NativeImage, { ...props, source: source, resizeMode: resizeMode, style: style }));
47
+ };
48
+ export default Image;
49
+ export const SEED_DATA = {
50
+ name: "Image",
51
+ tag: "Image",
52
+ description: "A basic Image Component",
53
+ category: COMPONENT_TYPES.media,
54
+ layout: {
55
+ width: 250,
56
+ height: 250,
57
+ },
58
+ props: {
59
+ source: createImageProp(),
60
+ resizeMode: createResizeModeProp(),
61
+ },
62
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,245 @@
1
+ import * as React from "react";
2
+ import { View } from "react-native";
3
+ import { GROUPS, FORM_TYPES, PROP_TYPES, COMPONENT_TYPES, } from "@draftbit/types";
4
+ export function Center({ width = 240, height = 200, children, bgColor, style, ...rest }) {
5
+ return (React.createElement(View, { style: [
6
+ {
7
+ justifyContent: "center",
8
+ alignItems: "center",
9
+ width,
10
+ height,
11
+ backgroundColor: bgColor,
12
+ },
13
+ style,
14
+ ], ...rest }, children));
15
+ }
16
+ export function Circle({ size = 50, bgColor, children, style, ...rest }) {
17
+ const borderRadius = 1000;
18
+ return (React.createElement(Center, { width: size, height: size, bgColor: bgColor, style: [
19
+ style,
20
+ { backgroundColor: bgColor, borderRadius, overflow: "hidden" },
21
+ ], ...rest }, children));
22
+ }
23
+ export function Square({ size = 50, bgColor, children, style, ...rest }) {
24
+ return (React.createElement(Center, { style: style, width: size, height: size, bgColor: bgColor, ...rest }, children));
25
+ }
26
+ export function Row({ justifyContent, alignItems, children, style, ...rest }) {
27
+ return (React.createElement(View, { style: [
28
+ style,
29
+ {
30
+ alignItems,
31
+ flexDirection: "row",
32
+ justifyContent: justifyContent,
33
+ },
34
+ ], ...rest }, children));
35
+ }
36
+ export function Spacer({ top = 8, right = 8, bottom = 8, left = 8, children, style, ...rest }) {
37
+ return (React.createElement(View, { style: [
38
+ style,
39
+ {
40
+ paddingRight: right,
41
+ paddingTop: top,
42
+ paddingLeft: left,
43
+ paddingBottom: bottom,
44
+ },
45
+ ], ...rest }, children));
46
+ }
47
+ export function Stack({ children, justifyContent = "flex-start", alignItems = "flex-start", style, ...rest }) {
48
+ return (
49
+ // style must go first since we don't want justifyContent, alignItems overridden
50
+ React.createElement(View, { style: [style, { justifyContent, alignItems }], ...rest }, children));
51
+ }
52
+ export const SEED_DATA = [
53
+ {
54
+ name: "Row",
55
+ tag: "Row",
56
+ category: COMPONENT_TYPES.layout,
57
+ props: {
58
+ justifyContent: {
59
+ label: "Align Horizontally",
60
+ group: GROUPS.style,
61
+ description: "Align Items Horizontally (on the X Axis)",
62
+ formType: FORM_TYPES.string,
63
+ propType: PROP_TYPES.STRING,
64
+ defaultValue: "flex-start",
65
+ editable: true,
66
+ required: false,
67
+ },
68
+ alignItems: {
69
+ label: "Align Vertically",
70
+ group: GROUPS.style,
71
+ description: "Align Items Vertically (on the Y Axis)",
72
+ formType: FORM_TYPES.string,
73
+ propType: PROP_TYPES.STRING,
74
+ defaultValue: "flex-start",
75
+ editable: true,
76
+ required: false,
77
+ },
78
+ },
79
+ },
80
+ {
81
+ name: "Spacer",
82
+ tag: "Spacer",
83
+ category: COMPONENT_TYPES.layout,
84
+ props: {
85
+ top: {
86
+ label: "Top",
87
+ description: "Top",
88
+ formType: FORM_TYPES.number,
89
+ propType: PROP_TYPES.NUMBER,
90
+ group: GROUPS.style,
91
+ defaultValue: 8,
92
+ editable: true,
93
+ required: false,
94
+ },
95
+ right: {
96
+ label: "Right",
97
+ description: "Right",
98
+ formType: FORM_TYPES.number,
99
+ propType: PROP_TYPES.NUMBER,
100
+ group: GROUPS.style,
101
+ defaultValue: 8,
102
+ editable: true,
103
+ required: false,
104
+ },
105
+ bottom: {
106
+ label: "Bottom",
107
+ description: "Bottom",
108
+ formType: FORM_TYPES.number,
109
+ propType: PROP_TYPES.NUMBER,
110
+ group: GROUPS.style,
111
+ defaultValue: 8,
112
+ editable: true,
113
+ required: false,
114
+ },
115
+ left: {
116
+ label: "Left",
117
+ description: "Left",
118
+ formType: FORM_TYPES.number,
119
+ propType: PROP_TYPES.NUMBER,
120
+ group: GROUPS.style,
121
+ defaultValue: 8,
122
+ editable: true,
123
+ required: false,
124
+ },
125
+ },
126
+ },
127
+ {
128
+ name: "Stack",
129
+ tag: "Stack",
130
+ category: COMPONENT_TYPES.layout,
131
+ props: {
132
+ justifyContent: {
133
+ group: GROUPS.style,
134
+ label: "Justify",
135
+ description: "Justify horizontally",
136
+ formType: FORM_TYPES.string,
137
+ propType: PROP_TYPES.STRING,
138
+ defaultValue: "flex-start",
139
+ editable: true,
140
+ required: false,
141
+ },
142
+ alignItems: {
143
+ group: GROUPS.style,
144
+ label: "Align",
145
+ description: "Vertical align",
146
+ formType: FORM_TYPES.string,
147
+ propType: PROP_TYPES.STRING,
148
+ defaultValue: "flex-start",
149
+ editable: true,
150
+ required: false,
151
+ },
152
+ },
153
+ },
154
+ {
155
+ name: "Center",
156
+ tag: "Center",
157
+ category: COMPONENT_TYPES.layout,
158
+ props: {
159
+ width: {
160
+ label: "Width",
161
+ description: "Width",
162
+ formType: FORM_TYPES.number,
163
+ propType: PROP_TYPES.NUMBER,
164
+ group: GROUPS.style,
165
+ defaultValue: 240,
166
+ editable: true,
167
+ required: false,
168
+ },
169
+ height: {
170
+ label: "Height",
171
+ description: "Height",
172
+ formType: FORM_TYPES.number,
173
+ propType: PROP_TYPES.NUMBER,
174
+ group: GROUPS.style,
175
+ defaultValue: 200,
176
+ editable: true,
177
+ required: false,
178
+ },
179
+ bgColor: {
180
+ label: "Background Color",
181
+ description: "Background color",
182
+ formType: FORM_TYPES.color,
183
+ propType: PROP_TYPES.THEME,
184
+ editable: true,
185
+ required: false,
186
+ defaultValue: "light",
187
+ group: GROUPS.style,
188
+ },
189
+ },
190
+ },
191
+ {
192
+ name: "Circle",
193
+ tag: "Circle",
194
+ category: COMPONENT_TYPES.layout,
195
+ props: {
196
+ size: {
197
+ label: "Size",
198
+ description: "Size",
199
+ formType: FORM_TYPES.number,
200
+ propType: PROP_TYPES.NUMBER,
201
+ group: GROUPS.style,
202
+ defaultValue: 50,
203
+ editable: true,
204
+ required: false,
205
+ },
206
+ bgColor: {
207
+ label: "Background Color",
208
+ description: "Background color",
209
+ formType: FORM_TYPES.color,
210
+ propType: PROP_TYPES.THEME,
211
+ editable: true,
212
+ required: false,
213
+ defaultValue: "light",
214
+ group: GROUPS.style,
215
+ },
216
+ },
217
+ },
218
+ {
219
+ name: "Square",
220
+ tag: "Square",
221
+ category: COMPONENT_TYPES.layout,
222
+ props: {
223
+ size: {
224
+ label: "Size",
225
+ description: "Size",
226
+ formType: FORM_TYPES.number,
227
+ propType: PROP_TYPES.NUMBER,
228
+ group: GROUPS.style,
229
+ defaultValue: 50,
230
+ editable: true,
231
+ required: false,
232
+ },
233
+ bgColor: {
234
+ label: "Background Color",
235
+ description: "Background color",
236
+ formType: FORM_TYPES.color,
237
+ propType: PROP_TYPES.THEME,
238
+ editable: true,
239
+ required: false,
240
+ defaultValue: "light",
241
+ group: GROUPS.style,
242
+ },
243
+ },
244
+ },
245
+ ];
@@ -0,0 +1,204 @@
1
+ import * as React from "react";
2
+ import { withTheme } from "../../theming";
3
+ //@ts-ignore
4
+ import PickerComponent from "./PickerComponent"; //unable to find file due to using .android/.web/.ios
5
+ import { GROUPS, COMPONENT_TYPES, FORM_TYPES, PROP_TYPES, FIELD_NAME, Triggers, } from "@draftbit/types";
6
+ import { usePrevious } from "../../hooks";
7
+ function normalizeOptions(options) {
8
+ if (options.length === 0) {
9
+ return [];
10
+ }
11
+ if (typeof options[0] === "string") {
12
+ return options.map((option) => ({
13
+ label: option,
14
+ value: option,
15
+ }));
16
+ }
17
+ if (options[0].label && options[0].value) {
18
+ return options;
19
+ }
20
+ throw new Error('Picker options must be either an array of strings or array of { "label": string; "value": string; } objects.');
21
+ }
22
+ const Picker = ({ options = [], placeholder, onValueChange: onValueChangeOverride, value, initialValue, ...props }) => {
23
+ const onValueChange = React.useCallback((itemValue, itemIndex) => {
24
+ if (placeholder && itemIndex === 0) {
25
+ return;
26
+ }
27
+ onValueChangeOverride && onValueChangeOverride(itemValue, itemIndex);
28
+ }, [placeholder, onValueChangeOverride]);
29
+ const normalizedOptions = normalizeOptions(options);
30
+ const previousInitialValue = usePrevious(initialValue);
31
+ React.useEffect(() => {
32
+ if (initialValue !== previousInitialValue) {
33
+ const index = normalizedOptions.findIndex((opt) => opt.value === initialValue);
34
+ if (index == null) {
35
+ return;
36
+ }
37
+ onValueChange(initialValue, index);
38
+ }
39
+ }, [initialValue, previousInitialValue, normalizedOptions, onValueChange]);
40
+ const pickerOptions = placeholder
41
+ ? [{ value: placeholder, label: placeholder }, ...normalizedOptions]
42
+ : normalizedOptions;
43
+ return (React.createElement(PickerComponent, { ...props, selectedValue: value, placeholder: placeholder, options: pickerOptions, onValueChange: onValueChange }));
44
+ };
45
+ export default withTheme(Picker);
46
+ const SEED_DATA_PROPS = {
47
+ label: {
48
+ group: GROUPS.data,
49
+ label: "Label",
50
+ description: "The label to be displayed on the picker",
51
+ formType: FORM_TYPES.string,
52
+ propType: PROP_TYPES.STRING,
53
+ defaultValue: null,
54
+ editable: true,
55
+ required: true,
56
+ },
57
+ placeholder: {
58
+ group: GROUPS.basic,
59
+ label: "Placeholder",
60
+ description: "The placeholder text of the picker",
61
+ formType: FORM_TYPES.string,
62
+ propType: PROP_TYPES.STRING,
63
+ defaultValue: "Select an option",
64
+ editable: true,
65
+ required: false,
66
+ },
67
+ placeholderTextColor: {
68
+ group: GROUPS.basic,
69
+ label: "Placeholder Text Color",
70
+ description: "The color of the placeholder text.",
71
+ editable: true,
72
+ required: false,
73
+ defaultValue: null,
74
+ formType: FORM_TYPES.color,
75
+ propType: PROP_TYPES.STRING,
76
+ },
77
+ assistiveText: {
78
+ group: GROUPS.basic,
79
+ label: "Assistive text",
80
+ description: "Helper text to display below the picker",
81
+ formType: FORM_TYPES.string,
82
+ propType: PROP_TYPES.STRING,
83
+ defaultValue: null,
84
+ editable: true,
85
+ required: false,
86
+ },
87
+ options: {
88
+ group: GROUPS.data,
89
+ label: "Options",
90
+ description: "Array of picker options. An array of objects containing a label and value.",
91
+ editable: true,
92
+ required: false,
93
+ formType: FORM_TYPES.array,
94
+ propType: PROP_TYPES.OBJECT,
95
+ options: [],
96
+ defaultValue: null,
97
+ },
98
+ disabled: {
99
+ group: GROUPS.basic,
100
+ label: "Disabled",
101
+ description: "Whether the picker should be disabled. Will prevent selection and show a greyed out state.",
102
+ formType: FORM_TYPES.boolean,
103
+ propType: PROP_TYPES.BOOLEAN,
104
+ defaultValue: false,
105
+ editable: true,
106
+ required: false,
107
+ },
108
+ error: {
109
+ group: GROUPS.data,
110
+ label: "Error",
111
+ description: "Whether the picker should display the error state",
112
+ formType: FORM_TYPES.boolean,
113
+ propType: PROP_TYPES.BOOLEAN,
114
+ defaultValue: false,
115
+ editable: true,
116
+ required: false,
117
+ },
118
+ leftIconName: {
119
+ group: GROUPS.basic,
120
+ label: "Left icon name",
121
+ description: "The icon to display on the left",
122
+ formType: FORM_TYPES.icon,
123
+ propType: PROP_TYPES.ASSET,
124
+ defaultValue: null,
125
+ editable: true,
126
+ required: false,
127
+ },
128
+ leftIconMode: {
129
+ group: GROUPS.basic,
130
+ label: "Left icon mode",
131
+ description: "The mode of the icon to display on the left. 'inset' or 'outset'.",
132
+ formType: FORM_TYPES.flatArray,
133
+ propType: PROP_TYPES.STRING,
134
+ defaultValue: "inset",
135
+ options: ["inset", "outset"],
136
+ editable: true,
137
+ required: true,
138
+ },
139
+ rightIconName: {
140
+ group: GROUPS.basic,
141
+ label: "Right icon name",
142
+ description: "The icon to display on the right",
143
+ formType: FORM_TYPES.icon,
144
+ propType: PROP_TYPES.ASSET,
145
+ defaultValue: null,
146
+ editable: true,
147
+ required: false,
148
+ },
149
+ fieldName: {
150
+ ...FIELD_NAME,
151
+ defaultValue: "pickerValue",
152
+ handlerPropName: "onValueChange",
153
+ },
154
+ };
155
+ const SEED_DATA_TRIGGERS = [Triggers.OnValueChange];
156
+ export const SEED_DATA = [
157
+ {
158
+ name: "Picker",
159
+ tag: "Picker",
160
+ description: "A component used to pick a value from a set of options",
161
+ category: COMPONENT_TYPES.input,
162
+ preview_image_url: "{CLOUDINARY_URL}/Picker.png",
163
+ supports_list_render: false,
164
+ triggers: SEED_DATA_TRIGGERS,
165
+ props: {
166
+ ...SEED_DATA_PROPS,
167
+ type: {
168
+ label: "Appearance",
169
+ description: "Type of Picker",
170
+ formType: FORM_TYPES.flatArray,
171
+ propType: PROP_TYPES.STRING,
172
+ defaultValue: "solid",
173
+ options: ["solid", "underline"],
174
+ editable: true,
175
+ required: true,
176
+ group: GROUPS.basic,
177
+ },
178
+ },
179
+ layout: {},
180
+ },
181
+ {
182
+ name: "Picker - Underline",
183
+ tag: "Picker",
184
+ description: "A picker with an underline",
185
+ category: COMPONENT_TYPES.input,
186
+ preview_image_url: "{CLOUDINARY_URL}/Picker.png",
187
+ supports_list_render: false,
188
+ triggers: SEED_DATA_TRIGGERS,
189
+ props: {
190
+ ...SEED_DATA_PROPS,
191
+ type: {
192
+ label: "Type",
193
+ description: "Type",
194
+ group: GROUPS.uncategorized,
195
+ formType: FORM_TYPES.string,
196
+ propType: PROP_TYPES.STRING,
197
+ defaultValue: "underline",
198
+ editable: false,
199
+ required: false,
200
+ },
201
+ },
202
+ layout: {},
203
+ },
204
+ ];