@draftbit/core 44.2.1-e53c90.0 → 44.2.1-fb9884.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.
- package/lib/commonjs/Provider.js.map +1 -1
- package/lib/commonjs/components/Picker/Picker.js +293 -26
- package/lib/commonjs/components/Picker/Picker.js.map +1 -1
- package/lib/commonjs/components/Surface.js +3 -13
- package/lib/commonjs/components/Surface.js.map +1 -1
- package/lib/commonjs/mappings/Picker.js +7 -1
- package/lib/commonjs/mappings/Picker.js.map +1 -1
- package/lib/commonjs/mappings/RadioButtonGroup.js.map +1 -1
- package/lib/commonjs/utilities.js +19 -0
- package/lib/commonjs/utilities.js.map +1 -1
- package/lib/module/components/Checkbox/context.js +1 -1
- package/lib/module/components/Checkbox/context.js.map +1 -1
- package/lib/module/components/CircleImage.js +3 -16
- package/lib/module/components/CircleImage.js.map +1 -1
- package/lib/module/components/Picker/Picker.js +281 -28
- package/lib/module/components/Picker/Picker.js.map +1 -1
- package/lib/module/mappings/AccordionItem.js.map +1 -1
- package/lib/module/mappings/ActionSheetCancel.js.map +1 -1
- package/lib/module/mappings/DatePicker.js.map +1 -1
- package/lib/module/mappings/Picker.js +8 -2
- package/lib/module/mappings/Picker.js.map +1 -1
- package/lib/module/utilities.js +12 -1
- package/lib/module/utilities.js.map +1 -1
- package/lib/typescript/src/components/Picker/Picker.d.ts +28 -4
- package/lib/typescript/src/mappings/Picker.d.ts +21 -0
- package/lib/typescript/src/utilities.d.ts +7 -0
- package/package.json +2 -2
- package/src/components/Picker/Picker.js +227 -17
- package/src/components/Picker/Picker.tsx +416 -34
- package/src/mappings/Picker.js +3 -1
- package/src/mappings/Picker.ts +4 -0
- package/src/utilities.js +49 -1
- package/src/utilities.ts +65 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { COMPONENT_TYPES, Triggers, GROUPS, FORM_TYPES, PROP_TYPES, FIELD_NAME } from "@draftbit/types";
|
|
1
|
+
import { COMPONENT_TYPES, Triggers, GROUPS, FORM_TYPES, PROP_TYPES, FIELD_NAME, createIconSizeProp, createColorProp } from "@draftbit/types";
|
|
2
2
|
const SEED_DATA_PROPS = {
|
|
3
3
|
label: {
|
|
4
4
|
group: GROUPS.data,
|
|
@@ -127,7 +127,13 @@ export const SEED_DATA = [{
|
|
|
127
127
|
editable: true,
|
|
128
128
|
required: true,
|
|
129
129
|
group: GROUPS.basic
|
|
130
|
-
}
|
|
130
|
+
},
|
|
131
|
+
iconSize: createIconSizeProp({
|
|
132
|
+
defaultValue: 24
|
|
133
|
+
}),
|
|
134
|
+
iconColor: createColorProp({
|
|
135
|
+
label: "Icon Color"
|
|
136
|
+
})
|
|
131
137
|
},
|
|
132
138
|
layout: {}
|
|
133
139
|
}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Picker.ts"],"names":["COMPONENT_TYPES","Triggers","GROUPS","FORM_TYPES","PROP_TYPES","FIELD_NAME","SEED_DATA_PROPS","label","group","data","description","formType","string","propType","STRING","defaultValue","editable","required","placeholder","basic","placeholderTextColor","color","assistiveText","options","array","OBJECT","disabled","boolean","BOOLEAN","error","leftIconName","icon","ASSET","leftIconMode","flatArray","rightIconName","fieldName","handlerPropName","SEED_DATA_TRIGGERS","OnValueChange","SEED_DATA","name","tag","category","input","preview_image_url","supports_list_render","triggers","props","type","layout"],"mappings":"AAAA,SACEA,eADF,EAEEC,QAFF,EAGEC,MAHF,EAIEC,UAJF,EAKEC,UALF,EAMEC,UANF,
|
|
1
|
+
{"version":3,"sources":["Picker.ts"],"names":["COMPONENT_TYPES","Triggers","GROUPS","FORM_TYPES","PROP_TYPES","FIELD_NAME","createIconSizeProp","createColorProp","SEED_DATA_PROPS","label","group","data","description","formType","string","propType","STRING","defaultValue","editable","required","placeholder","basic","placeholderTextColor","color","assistiveText","options","array","OBJECT","disabled","boolean","BOOLEAN","error","leftIconName","icon","ASSET","leftIconMode","flatArray","rightIconName","fieldName","handlerPropName","SEED_DATA_TRIGGERS","OnValueChange","SEED_DATA","name","tag","category","input","preview_image_url","supports_list_render","triggers","props","type","iconSize","iconColor","layout"],"mappings":"AAAA,SACEA,eADF,EAEEC,QAFF,EAGEC,MAHF,EAIEC,UAJF,EAKEC,UALF,EAMEC,UANF,EAOEC,kBAPF,EAQEC,eARF,QASO,iBATP;AAWA,MAAMC,eAAe,GAAG;AACtBC,EAAAA,KAAK,EAAE;AACLC,IAAAA,KAAK,EAAER,MAAM,CAACS,IADT;AAELF,IAAAA,KAAK,EAAE,OAFF;AAGLG,IAAAA,WAAW,EAAE,yCAHR;AAILC,IAAAA,QAAQ,EAAEV,UAAU,CAACW,MAJhB;AAKLC,IAAAA,QAAQ,EAAEX,UAAU,CAACY,MALhB;AAMLC,IAAAA,YAAY,EAAE,IANT;AAOLC,IAAAA,QAAQ,EAAE,IAPL;AAQLC,IAAAA,QAAQ,EAAE;AARL,GADe;AAWtBC,EAAAA,WAAW,EAAE;AACXV,IAAAA,KAAK,EAAER,MAAM,CAACmB,KADH;AAEXZ,IAAAA,KAAK,EAAE,aAFI;AAGXG,IAAAA,WAAW,EAAE,oCAHF;AAIXC,IAAAA,QAAQ,EAAEV,UAAU,CAACW,MAJV;AAKXC,IAAAA,QAAQ,EAAEX,UAAU,CAACY,MALV;AAMXC,IAAAA,YAAY,EAAE,kBANH;AAOXC,IAAAA,QAAQ,EAAE,IAPC;AAQXC,IAAAA,QAAQ,EAAE;AARC,GAXS;AAqBtBG,EAAAA,oBAAoB,EAAE;AACpBZ,IAAAA,KAAK,EAAER,MAAM,CAACmB,KADM;AAEpBZ,IAAAA,KAAK,EAAE,wBAFa;AAGpBG,IAAAA,WAAW,EAAE,oCAHO;AAIpBM,IAAAA,QAAQ,EAAE,IAJU;AAKpBC,IAAAA,QAAQ,EAAE,KALU;AAMpBF,IAAAA,YAAY,EAAE,IANM;AAOpBJ,IAAAA,QAAQ,EAAEV,UAAU,CAACoB,KAPD;AAQpBR,IAAAA,QAAQ,EAAEX,U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PS,\n FORM_TYPES,\n PROP_TYPES,\n FIELD_NAME,\n createIconSizeProp,\n createColorProp,\n} from \"@draftbit/types\";\n\nconst SEED_DATA_PROPS = {\n label: {\n group: GROUPS.data,\n label: \"Label\",\n description: \"The label to be displayed on the picker\",\n formType: FORM_TYPES.string,\n propType: PROP_TYPES.STRING,\n defaultValue: null,\n editable: true,\n required: true,\n },\n placeholder: {\n group: GROUPS.basic,\n label: \"Placeholder\",\n description: \"The placeholder text of the picker\",\n formType: FORM_TYPES.string,\n propType: PROP_TYPES.STRING,\n defaultValue: \"Select an option\",\n editable: true,\n required: false,\n },\n placeholderTextColor: {\n group: GROUPS.basic,\n label: \"Placeholder Text Color\",\n description: \"The color of the placeholder text.\",\n editable: true,\n required: false,\n defaultValue: null,\n formType: FORM_TYPES.color,\n propType: PROP_TYPES.STRING,\n },\n assistiveText: {\n group: GROUPS.basic,\n label: \"Assistive text\",\n description: \"Helper text to display below the picker\",\n formType: FORM_TYPES.string,\n propType: PROP_TYPES.STRING,\n defaultValue: null,\n editable: true,\n required: false,\n },\n options: {\n group: GROUPS.data,\n label: \"Options\",\n description:\n \"Array of picker options. An array of objects containing a label and value.\",\n editable: true,\n required: false,\n formType: FORM_TYPES.array,\n propType: PROP_TYPES.OBJECT,\n options: [],\n defaultValue: null,\n },\n disabled: {\n group: GROUPS.basic,\n label: \"Disabled\",\n description:\n \"Whether the picker should be disabled. Will prevent selection and show a greyed out state.\",\n formType: FORM_TYPES.boolean,\n propType: PROP_TYPES.BOOLEAN,\n defaultValue: false,\n editable: true,\n required: false,\n },\n error: {\n group: GROUPS.data,\n label: \"Error\",\n description: \"Whether the picker should display the error state\",\n formType: FORM_TYPES.boolean,\n propType: PROP_TYPES.BOOLEAN,\n defaultValue: false,\n editable: true,\n required: false,\n },\n leftIconName: {\n group: GROUPS.basic,\n label: \"Left icon name\",\n description: \"The icon to display on the left\",\n formType: FORM_TYPES.icon,\n propType: PROP_TYPES.ASSET,\n defaultValue: null,\n editable: true,\n required: false,\n },\n leftIconMode: {\n group: GROUPS.basic,\n label: \"Left icon mode\",\n description:\n \"The mode of the icon to display on the left. 'inset' or 'outset'.\",\n formType: FORM_TYPES.flatArray,\n propType: PROP_TYPES.STRING,\n defaultValue: \"inset\",\n options: [\"inset\", \"outset\"],\n editable: true,\n required: true,\n },\n rightIconName: {\n group: GROUPS.basic,\n label: \"Right icon name\",\n description: \"The icon to display on the right\",\n formType: FORM_TYPES.icon,\n propType: PROP_TYPES.ASSET,\n defaultValue: null,\n editable: true,\n required: false,\n },\n fieldName: {\n ...FIELD_NAME,\n defaultValue: \"pickerValue\",\n handlerPropName: \"onValueChange\",\n },\n};\n\nconst SEED_DATA_TRIGGERS = [Triggers.OnValueChange];\nexport const SEED_DATA = [\n {\n name: \"Picker\",\n tag: \"Picker\",\n description: \"A component used to pick a value from a set of options\",\n category: COMPONENT_TYPES.input,\n preview_image_url: \"{CLOUDINARY_URL}/Picker.png\",\n supports_list_render: false,\n triggers: SEED_DATA_TRIGGERS,\n props: {\n ...SEED_DATA_PROPS,\n type: {\n label: \"Appearance\",\n description: \"Type of Picker\",\n formType: FORM_TYPES.flatArray,\n propType: PROP_TYPES.STRING,\n defaultValue: \"solid\",\n options: [\"solid\", \"underline\"],\n editable: true,\n required: true,\n group: GROUPS.basic,\n },\n iconSize: createIconSizeProp({ defaultValue: 24 }),\n iconColor: createColorProp({ label: \"Icon Color\" }),\n },\n layout: {},\n },\n];\n"]}
|
package/lib/module/utilities.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StyleSheet } from "react-native";
|
|
2
|
-
import { isString, isNumber } from "lodash";
|
|
2
|
+
import { isString, isNumber, pick, pickBy, identity } from "lodash";
|
|
3
3
|
export function extractStyles(style) {
|
|
4
4
|
const {
|
|
5
5
|
color,
|
|
@@ -33,6 +33,17 @@ export function extractStyles(style) {
|
|
|
33
33
|
textStyles
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
+
export const borderStyleNames = ["borderRadius", "borderBottomColor", "borderBottomEndRadius", "borderBottomLeftRadius", "borderBottomRightRadius", "borderBottomStartRadius", "borderBottomWidth", "borderColor", "borderEndColor", "borderLeftColor", "borderLeftWidth", "borderRadius", "borderRightColor", "borderRightWidth", "borderStartColor", "borderStyle", "borderTopColor", "borderTopEndRadius", "borderTopLeftRadius", "borderTopRightRadius", "borderTopStartRadius", "borderTopWidth", "borderWidth"];
|
|
37
|
+
export const marginStyleNames = ["margin", "marginBottom", "marginEnd", "marginHorizontal", "marginLeft", "marginRight", "marginStart", "marginTop", "marginVertical"];
|
|
38
|
+
export function extractBorderAndMarginStyles(style, additionalBorderStyles, additionalMarginStyles) {
|
|
39
|
+
const flatStyle = StyleSheet.flatten(style || {});
|
|
40
|
+
const borderStyles = pickBy(pick(flatStyle, [...borderStyleNames, ...(additionalBorderStyles ? additionalBorderStyles : [])]), identity);
|
|
41
|
+
const marginStyles = pickBy(pick(flatStyle, [...marginStyleNames, ...(additionalMarginStyles ? additionalMarginStyles : [])]), identity);
|
|
42
|
+
return {
|
|
43
|
+
borderStyles,
|
|
44
|
+
marginStyles
|
|
45
|
+
};
|
|
46
|
+
}
|
|
36
47
|
/**
|
|
37
48
|
* Merges a style object on top of another style object. In React Native,
|
|
38
49
|
* keys with undefined values in a style object will still override styles
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
1
|
+
{"version":3,"sources":["utilities.ts"],"names":["StyleSheet","isString","isNumber","pick","pickBy","identity","extractStyles","style","color","fontFamily","fontWeight","fontSize","lineHeight","letterSpacing","textTransform","textAlign","textDecorationLine","textDecorationColor","textDecorationStyle","viewStyles","flatten","textStyles","borderStyleNames","marginStyleNames","extractBorderAndMarginStyles","additionalBorderStyles","additionalMarginStyles","flatStyle","borderStyles","marginStyles","applyStyles","baseStyles","stylesToApply","flattenedStyles","key","value","Object","entries","getValueForRadioButton","String","Error"],"mappings":"AAAA,SAASA,UAAT,QAAiD,cAAjD;AACA,SAASC,QAAT,EAAmBC,QAAnB,EAA6BC,IAA7B,EAAmCC,MAAnC,EAA2CC,QAA3C,QAA2D,QAA3D;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,MAaFnB,UAAU,CAACoB,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,OAAO,MAAMC,gBAAgB,GAAG,CAC9B,cAD8B,EAE9B,mBAF8B,EAG9B,uBAH8B,EAI9B,wBAJ8B,EAK9B,yBAL8B,EAM9B,yBAN8B,EAO9B,mBAP8B,EAQ9B,aAR8B,EAS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EA,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;AAED,OAAO,SAASK,sBAAT,CAAgCH,KAAhC,EAAwD;AAC7D,MAAIlC,QAAQ,CAACkC,KAAD,CAAZ,EAAqB;AACnB,WAAOA,KAAP;AACD,GAFD,MAEO,IAAIjC,QAAQ,CAACiC,KAAD,CAAZ,EAAqB;AAC1B,WAAOI,MAAM,CAACJ,KAAD,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, pick, pickBy, identity } 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\nexport const borderStyleNames = [\n \"borderRadius\",\n \"borderBottomColor\",\n \"borderBottomEndRadius\",\n \"borderBottomLeftRadius\",\n \"borderBottomRightRadius\",\n \"borderBottomStartRadius\",\n \"borderBottomWidth\",\n \"borderColor\",\n \"borderEndColor\",\n \"borderLeftColor\",\n \"borderLeftWidth\",\n \"borderRadius\",\n \"borderRightColor\",\n \"borderRightWidth\",\n \"borderStartColor\",\n \"borderStyle\",\n \"borderTopColor\",\n \"borderTopEndRadius\",\n \"borderTopLeftRadius\",\n \"borderTopRightRadius\",\n \"borderTopStartRadius\",\n \"borderTopWidth\",\n \"borderWidth\",\n];\n\nexport const marginStyleNames = [\n \"margin\",\n \"marginBottom\",\n \"marginEnd\",\n \"marginHorizontal\",\n \"marginLeft\",\n \"marginRight\",\n \"marginStart\",\n \"marginTop\",\n \"marginVertical\",\n];\n\nexport function extractBorderAndMarginStyles(\n style: StyleProp<any>,\n additionalBorderStyles?: string[],\n additionalMarginStyles?: string[]\n) {\n const flatStyle = StyleSheet.flatten(style || {});\n\n const borderStyles = pickBy(\n pick(flatStyle, [\n ...borderStyleNames,\n ...(additionalBorderStyles ? additionalBorderStyles : []),\n ]),\n identity\n );\n\n const marginStyles = pickBy(\n pick(flatStyle, [\n ...marginStyleNames,\n ...(additionalMarginStyles ? additionalMarginStyles : []),\n ]),\n identity\n );\n\n return { borderStyles, marginStyles };\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"]}
|
|
@@ -1,11 +1,35 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { ViewStyle, StyleProp } from "react-native";
|
|
3
|
+
import type { Theme } from "../../styles/DefaultTheme";
|
|
4
|
+
import type { IconSlot } from "../../interfaces/Icon";
|
|
5
|
+
export interface PickerOption {
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
}
|
|
9
|
+
export declare type PickerProps = {
|
|
10
|
+
error?: any;
|
|
4
11
|
placeholder?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
style?: StyleProp<ViewStyle> & {
|
|
14
|
+
height?: number;
|
|
15
|
+
};
|
|
5
16
|
value?: string;
|
|
6
17
|
options: PickerOption[] | string[];
|
|
18
|
+
onValueChange: (value: string, index: number) => void;
|
|
19
|
+
defaultValue?: string;
|
|
20
|
+
assistiveText?: string;
|
|
21
|
+
label?: string;
|
|
22
|
+
iconColor?: string;
|
|
23
|
+
iconSize?: number;
|
|
24
|
+
leftIconMode?: "inset" | "outset";
|
|
25
|
+
leftIconName?: string;
|
|
26
|
+
placeholderTextColor?: string;
|
|
27
|
+
rightIconName?: string;
|
|
28
|
+
type?: "solid" | "underline";
|
|
29
|
+
theme: Theme;
|
|
30
|
+
Icon: IconSlot["Icon"];
|
|
7
31
|
};
|
|
8
|
-
declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<
|
|
32
|
+
declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<PickerProps, "theme"> & {
|
|
9
33
|
theme?: import("@draftbit/react-theme-provider").$DeepPartial<any> | undefined;
|
|
10
|
-
}> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<
|
|
34
|
+
}> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<PickerProps> & React.FC<PickerProps>, {}>;
|
|
11
35
|
export default _default;
|
|
@@ -18,6 +18,27 @@ export declare const SEED_DATA: {
|
|
|
18
18
|
required: boolean;
|
|
19
19
|
group: string;
|
|
20
20
|
};
|
|
21
|
+
iconSize: {
|
|
22
|
+
group: string;
|
|
23
|
+
label: string;
|
|
24
|
+
description: string;
|
|
25
|
+
editable: boolean;
|
|
26
|
+
required: boolean;
|
|
27
|
+
formType: string;
|
|
28
|
+
propType: string;
|
|
29
|
+
defaultValue: number;
|
|
30
|
+
options: number[];
|
|
31
|
+
};
|
|
32
|
+
iconColor: {
|
|
33
|
+
group: string;
|
|
34
|
+
label: string;
|
|
35
|
+
description: string;
|
|
36
|
+
editable: boolean;
|
|
37
|
+
required: boolean;
|
|
38
|
+
defaultValue: null;
|
|
39
|
+
formType: string;
|
|
40
|
+
propType: string;
|
|
41
|
+
};
|
|
21
42
|
label: {
|
|
22
43
|
group: string;
|
|
23
44
|
label: string;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
1
2
|
import { StyleProp, TextStyle } from "react-native";
|
|
2
3
|
export declare function extractStyles(style: StyleProp<any>): {
|
|
3
4
|
viewStyles: any;
|
|
4
5
|
textStyles: TextStyle;
|
|
5
6
|
};
|
|
7
|
+
export declare const borderStyleNames: string[];
|
|
8
|
+
export declare const marginStyleNames: string[];
|
|
9
|
+
export declare function extractBorderAndMarginStyles(style: StyleProp<any>, additionalBorderStyles?: string[], additionalMarginStyles?: string[]): {
|
|
10
|
+
borderStyles: import("lodash").Dictionary<any>;
|
|
11
|
+
marginStyles: import("lodash").Dictionary<any>;
|
|
12
|
+
};
|
|
6
13
|
/**
|
|
7
14
|
* Merges a style object on top of another style object. In React Native,
|
|
8
15
|
* keys with undefined values in a style object will still override styles
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "44.2.1-
|
|
3
|
+
"version": "44.2.1-fb9884.1+fb9884b5",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
]
|
|
79
79
|
]
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "fb9884b5b85705433b90996212756f37c2d70f19"
|
|
82
82
|
}
|
|
@@ -1,29 +1,47 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet, Text, Platform, Dimensions, } from "react-native";
|
|
3
|
+
import { omit, pickBy, identity, isObject } from "lodash";
|
|
4
|
+
import { SafeAreaView } from "react-native-safe-area-context";
|
|
5
|
+
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
2
6
|
import { withTheme } from "../../theming";
|
|
3
|
-
|
|
4
|
-
import
|
|
7
|
+
import Portal from "../Portal/Portal";
|
|
8
|
+
import Button from "../DeprecatedButton";
|
|
9
|
+
import Touchable from "../Touchable";
|
|
10
|
+
import { extractStyles, extractBorderAndMarginStyles, borderStyleNames, marginStyleNames, } from "../../utilities";
|
|
5
11
|
function normalizeOptions(options) {
|
|
6
12
|
if (options.length === 0) {
|
|
7
13
|
return [];
|
|
8
14
|
}
|
|
9
|
-
if (typeof options[0] === "string") {
|
|
15
|
+
if (typeof options[0] === ("string" || "number")) {
|
|
10
16
|
return options.map((option) => ({
|
|
11
|
-
label: option,
|
|
17
|
+
label: String(option),
|
|
12
18
|
value: String(option),
|
|
13
19
|
}));
|
|
14
20
|
}
|
|
15
|
-
if (options[0]
|
|
21
|
+
if (isObject(options[0]) &&
|
|
22
|
+
options[0].value !== null &&
|
|
23
|
+
options[0].label !== null) {
|
|
16
24
|
return options.map((option) => {
|
|
17
25
|
return {
|
|
18
|
-
label: option.label,
|
|
26
|
+
label: String(option.label),
|
|
19
27
|
value: String(option.value),
|
|
20
28
|
};
|
|
21
29
|
});
|
|
22
30
|
}
|
|
23
31
|
throw new Error('Picker options must be either an array of strings or array of { "label": string; "value": string; } objects.');
|
|
24
32
|
}
|
|
25
|
-
const
|
|
33
|
+
const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
|
|
34
|
+
const isIos = Platform.OS === "ios";
|
|
35
|
+
const unstyledColor = "rgba(165, 173, 183, 1)";
|
|
36
|
+
const disabledColor = "rgb(240, 240, 240)";
|
|
37
|
+
const errorColor = "rgba(255, 69, 100, 1)";
|
|
38
|
+
const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style, placeholder, value, disabled = false, theme, assistiveText, label, iconColor = unstyledColor, iconSize = 24, leftIconMode = "inset", leftIconName, placeholderTextColor = unstyledColor, rightIconName, type = "solid", }) => {
|
|
39
|
+
const androidPickerRef = React.useRef(undefined);
|
|
26
40
|
const [internalValue, setInternalValue] = React.useState(value || defaultValue);
|
|
41
|
+
const [pickerVisible, setPickerVisible] = React.useState(false);
|
|
42
|
+
const togglePickerVisible = () => {
|
|
43
|
+
setPickerVisible(!pickerVisible);
|
|
44
|
+
};
|
|
27
45
|
React.useEffect(() => {
|
|
28
46
|
if (value != null) {
|
|
29
47
|
setInternalValue(value);
|
|
@@ -34,23 +52,215 @@ const Picker = ({ options = [], placeholder, onValueChange: onValueChangeOverrid
|
|
|
34
52
|
setInternalValue(defaultValue);
|
|
35
53
|
}
|
|
36
54
|
}, [defaultValue]);
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
-
|
|
55
|
+
React.useEffect(() => {
|
|
56
|
+
if (pickerVisible && androidPickerRef.current) {
|
|
57
|
+
androidPickerRef?.current?.focus();
|
|
40
58
|
}
|
|
41
|
-
|
|
42
|
-
onValueChangeOverride(String(itemValue), itemIndex);
|
|
43
|
-
}, [placeholder, onValueChangeOverride]);
|
|
59
|
+
}, [pickerVisible, androidPickerRef]);
|
|
44
60
|
const normalizedOptions = normalizeOptions(options);
|
|
45
61
|
const pickerOptions = placeholder
|
|
46
62
|
? [{ value: placeholder, label: placeholder }, ...normalizedOptions]
|
|
47
63
|
: normalizedOptions;
|
|
64
|
+
const { colors } = theme;
|
|
65
|
+
const { viewStyles, textStyles } = extractStyles(style);
|
|
66
|
+
const additionalBorderStyles = ["backgroundColor"];
|
|
67
|
+
const additionalMarginStyles = [
|
|
68
|
+
"bottom",
|
|
69
|
+
"height",
|
|
70
|
+
"left",
|
|
71
|
+
"maxHeight",
|
|
72
|
+
"maxWidth",
|
|
73
|
+
"minHeight",
|
|
74
|
+
"minWidth",
|
|
75
|
+
"overflow",
|
|
76
|
+
"position",
|
|
77
|
+
"right",
|
|
78
|
+
"top",
|
|
79
|
+
"width",
|
|
80
|
+
"zIndex",
|
|
81
|
+
];
|
|
82
|
+
const { borderStyles: extractedBorderStyles, marginStyles: extractedMarginStyles, } = extractBorderAndMarginStyles(viewStyles, additionalBorderStyles, additionalMarginStyles);
|
|
83
|
+
const borderStyles = {
|
|
84
|
+
...{
|
|
85
|
+
...(type === "solid"
|
|
86
|
+
? {
|
|
87
|
+
borderTopLeftRadius: 5,
|
|
88
|
+
borderTopRightRadius: 5,
|
|
89
|
+
borderBottomRightRadius: 5,
|
|
90
|
+
borderBottomLeftRadius: 5,
|
|
91
|
+
borderTopWidth: 1,
|
|
92
|
+
borderRightWidth: 1,
|
|
93
|
+
borderLeftWidth: 1,
|
|
94
|
+
}
|
|
95
|
+
: {}),
|
|
96
|
+
borderBottomWidth: 1,
|
|
97
|
+
borderColor: unstyledColor,
|
|
98
|
+
borderStyle: "solid",
|
|
99
|
+
},
|
|
100
|
+
...extractedBorderStyles,
|
|
101
|
+
...(error ? { borderColor: errorColor } : {}),
|
|
102
|
+
...(disabled
|
|
103
|
+
? { borderColor: "transparent", backgroundColor: disabledColor }
|
|
104
|
+
: {}),
|
|
105
|
+
};
|
|
106
|
+
const marginStyles = {
|
|
107
|
+
height: 60,
|
|
108
|
+
...extractedMarginStyles,
|
|
109
|
+
};
|
|
110
|
+
const stylesWithoutBordersAndMargins = omit(viewStyles, [
|
|
111
|
+
...borderStyleNames,
|
|
112
|
+
...marginStyleNames,
|
|
113
|
+
...additionalBorderStyles,
|
|
114
|
+
...additionalMarginStyles,
|
|
115
|
+
]);
|
|
116
|
+
const selectedLabel = internalValue &&
|
|
117
|
+
(pickerOptions.find((option) => option.value === internalValue)?.label ??
|
|
118
|
+
internalValue);
|
|
119
|
+
const labelText = label ? (React.createElement(Text, { style: {
|
|
120
|
+
textAlign: textStyles.textAlign,
|
|
121
|
+
color: unstyledColor,
|
|
122
|
+
fontSize: 12,
|
|
123
|
+
paddingBottom: 4,
|
|
124
|
+
} }, label)) : null;
|
|
125
|
+
const leftIconOutset = leftIconMode === "outset";
|
|
126
|
+
const leftIcon = leftIconName ? (React.createElement(Icon, { name: leftIconName, color: disabled ? unstyledColor : iconColor, size: iconSize, style: {
|
|
127
|
+
marginRight: 4,
|
|
128
|
+
marginLeft: 4,
|
|
129
|
+
} })) : null;
|
|
130
|
+
const rightIcon = rightIconName ? (React.createElement(Icon, { name: rightIconName, color: disabled ? unstyledColor : iconColor, size: iconSize, style: {
|
|
131
|
+
marginRight: -10,
|
|
132
|
+
marginLeft: 8,
|
|
133
|
+
} })) : null;
|
|
134
|
+
const textAlign = textStyles?.textAlign;
|
|
135
|
+
const calculateLeftPadding = () => {
|
|
136
|
+
if (leftIconOutset) {
|
|
137
|
+
if (textAlign === "center") {
|
|
138
|
+
return iconSize - Math.abs(8 - iconSize);
|
|
139
|
+
}
|
|
140
|
+
return iconSize + 8;
|
|
141
|
+
}
|
|
142
|
+
return 0;
|
|
143
|
+
};
|
|
144
|
+
const assistiveTextLabel = assistiveText ? (React.createElement(Text, { style: {
|
|
145
|
+
textAlign,
|
|
146
|
+
width: "100%",
|
|
147
|
+
paddingLeft: calculateLeftPadding(),
|
|
148
|
+
color: unstyledColor,
|
|
149
|
+
fontSize: 12,
|
|
150
|
+
paddingTop: 4,
|
|
151
|
+
} }, assistiveText)) : null;
|
|
152
|
+
const primaryTextStyle = {
|
|
153
|
+
color: unstyledColor,
|
|
154
|
+
fontSize: 14,
|
|
155
|
+
...pickBy(textStyles, identity),
|
|
156
|
+
...(placeholder === internalValue ? { color: placeholderTextColor } : {}),
|
|
157
|
+
...(disabled ? { color: unstyledColor } : {}),
|
|
158
|
+
};
|
|
48
159
|
const handleValueChange = (newValue, itemIndex) => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
onValueChange(newValue, itemIndex);
|
|
160
|
+
if (!placeholder || itemIndex > 0) {
|
|
161
|
+
onValueChange?.(newValue, itemIndex);
|
|
52
162
|
}
|
|
163
|
+
setInternalValue(newValue);
|
|
53
164
|
};
|
|
54
|
-
return (
|
|
165
|
+
return (
|
|
166
|
+
/* marginsContainer */
|
|
167
|
+
React.createElement(View, { style: [styles.marginsContainer, marginStyles] },
|
|
168
|
+
React.createElement(Touchable, { disabled: disabled, onPress: togglePickerVisible, style: styles.touchableContainer },
|
|
169
|
+
React.createElement(View, { pointerEvents: "none", style: [
|
|
170
|
+
styles.outsetContainer,
|
|
171
|
+
stylesWithoutBordersAndMargins,
|
|
172
|
+
!leftIconOutset ? borderStyles : {},
|
|
173
|
+
] },
|
|
174
|
+
leftIcon,
|
|
175
|
+
React.createElement(View, { style: [
|
|
176
|
+
styles.insetContainer,
|
|
177
|
+
leftIconOutset ? borderStyles : {},
|
|
178
|
+
] },
|
|
179
|
+
React.createElement(View, { style: styles.primaryTextContainer },
|
|
180
|
+
labelText,
|
|
181
|
+
React.createElement(Text, { style: primaryTextStyle }, String(selectedLabel ?? placeholder))),
|
|
182
|
+
rightIcon)),
|
|
183
|
+
assistiveTextLabel),
|
|
184
|
+
isIos && pickerVisible ? (React.createElement(Portal, null,
|
|
185
|
+
React.createElement(View, { style: [
|
|
186
|
+
styles.iosPicker,
|
|
187
|
+
{
|
|
188
|
+
backgroundColor: colors.divider,
|
|
189
|
+
},
|
|
190
|
+
] },
|
|
191
|
+
React.createElement(SafeAreaView, { style: styles.iosSafeArea },
|
|
192
|
+
React.createElement(Button, { Icon: Icon, type: "text", onPress: togglePickerVisible, style: styles.iosButton }, "Close"),
|
|
193
|
+
React.createElement(NativePicker, { style: styles.iosNativePicker, selectedValue: internalValue, onValueChange: handleValueChange }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value })))))))) : null,
|
|
194
|
+
!isIos && pickerVisible ? (React.createElement(NativePicker, { enabled: pickerVisible, selectedValue: internalValue, onValueChange: handleValueChange, style: styles.nonIosPicker, ref: androidPickerRef, onBlur: () => setPickerVisible(false) }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value }))))) : null));
|
|
55
195
|
};
|
|
56
196
|
export default withTheme(Picker);
|
|
197
|
+
const styles = StyleSheet.create({
|
|
198
|
+
marginsContainer: {
|
|
199
|
+
alignSelf: "stretch",
|
|
200
|
+
alignItems: "center",
|
|
201
|
+
width: "100%",
|
|
202
|
+
maxWidth: deviceWidth,
|
|
203
|
+
},
|
|
204
|
+
touchableContainer: {
|
|
205
|
+
flex: 1,
|
|
206
|
+
height: "100%",
|
|
207
|
+
width: "100%",
|
|
208
|
+
alignSelf: "stretch",
|
|
209
|
+
alignItems: "center",
|
|
210
|
+
},
|
|
211
|
+
outsetContainer: {
|
|
212
|
+
flex: 1,
|
|
213
|
+
height: "100%",
|
|
214
|
+
width: "100%",
|
|
215
|
+
flexDirection: "row",
|
|
216
|
+
alignItems: "center",
|
|
217
|
+
justifyContent: "space-between",
|
|
218
|
+
},
|
|
219
|
+
insetContainer: {
|
|
220
|
+
flex: 1,
|
|
221
|
+
height: "100%",
|
|
222
|
+
width: "100%",
|
|
223
|
+
flexDirection: "row",
|
|
224
|
+
alignItems: "center",
|
|
225
|
+
justifyContent: "space-between",
|
|
226
|
+
paddingLeft: 12,
|
|
227
|
+
paddingRight: 12,
|
|
228
|
+
},
|
|
229
|
+
primaryTextContainer: {
|
|
230
|
+
flex: 1,
|
|
231
|
+
},
|
|
232
|
+
iosPicker: {
|
|
233
|
+
position: "absolute",
|
|
234
|
+
bottom: 0,
|
|
235
|
+
left: 0,
|
|
236
|
+
right: 0,
|
|
237
|
+
flexDirection: "row",
|
|
238
|
+
justifyContent: "center",
|
|
239
|
+
width: "100%",
|
|
240
|
+
maxWidth: deviceWidth,
|
|
241
|
+
maxHeight: deviceHeight,
|
|
242
|
+
},
|
|
243
|
+
iosSafeArea: {
|
|
244
|
+
backgroundColor: "white",
|
|
245
|
+
flexDirection: "column",
|
|
246
|
+
width: "100%",
|
|
247
|
+
maxWidth: deviceWidth,
|
|
248
|
+
},
|
|
249
|
+
iosButton: {
|
|
250
|
+
alignSelf: "flex-end",
|
|
251
|
+
},
|
|
252
|
+
iosNativePicker: {
|
|
253
|
+
backgroundColor: "white",
|
|
254
|
+
},
|
|
255
|
+
nonIosPicker: {
|
|
256
|
+
opacity: 0,
|
|
257
|
+
position: "absolute",
|
|
258
|
+
top: 0,
|
|
259
|
+
left: 0,
|
|
260
|
+
right: 0,
|
|
261
|
+
bottom: 0,
|
|
262
|
+
width: "100%",
|
|
263
|
+
maxWidth: deviceWidth,
|
|
264
|
+
maxHeight: deviceHeight,
|
|
265
|
+
},
|
|
266
|
+
});
|