@draftbit/core 42.1.4 → 42.1.6
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/components/Picker/PickerComponent.android.js +4 -1
- package/lib/commonjs/components/Picker/PickerComponent.android.js.map +1 -1
- package/lib/commonjs/components/Picker/PickerComponent.web.js +4 -1
- package/lib/commonjs/components/Picker/PickerComponent.web.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js +2 -1
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js.map +1 -1
- package/lib/module/components/Button.js +16 -14
- package/lib/module/components/Button.js.map +1 -1
- package/lib/module/components/Picker/PickerComponent.android.js +4 -1
- package/lib/module/components/Picker/PickerComponent.android.js.map +1 -1
- package/lib/module/components/Picker/PickerComponent.web.js +4 -1
- package/lib/module/components/Picker/PickerComponent.web.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButtonRow.js +7 -18
- package/lib/module/components/RadioButton/RadioButtonRow.js.map +1 -1
- package/lib/module/components/ResizeMode.js +2 -2
- package/lib/module/components/ResizeMode.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Picker/PickerComponent.android.js +4 -1
- package/src/components/Picker/PickerComponent.android.tsx +6 -1
- package/src/components/Picker/PickerComponent.web.js +4 -1
- package/src/components/Picker/PickerComponent.web.tsx +6 -1
- package/src/components/RadioButton/RadioButtonRow.js +1 -0
- package/src/components/RadioButton/RadioButtonRow.tsx +1 -0
|
@@ -38,6 +38,8 @@ const Picker = ({
|
|
|
38
38
|
onValueChange: onValueChangeOverride = () => {},
|
|
39
39
|
...props
|
|
40
40
|
}) => {
|
|
41
|
+
var _options$find$label, _options$find;
|
|
42
|
+
|
|
41
43
|
const {
|
|
42
44
|
viewStyles: {
|
|
43
45
|
borderRadius,
|
|
@@ -84,6 +86,7 @@ const Picker = ({
|
|
|
84
86
|
};
|
|
85
87
|
|
|
86
88
|
const stylesWithoutMargin = style && (0, _lodash.default)(_reactNative.StyleSheet.flatten(style), ["margin", "marginTop", "marginRight", "marginBottom", "marginLeft"]);
|
|
89
|
+
const selectedLabel = selectedValue && ((_options$find$label = (_options$find = options.find(opt => opt.value === selectedValue)) === null || _options$find === void 0 ? void 0 : _options$find.label) !== null && _options$find$label !== void 0 ? _options$find$label : selectedValue);
|
|
87
90
|
return /*#__PURE__*/React.createElement(_Touchable.default, {
|
|
88
91
|
disabled: disabled,
|
|
89
92
|
onPress: toggleFocus,
|
|
@@ -107,7 +110,7 @@ const Picker = ({
|
|
|
107
110
|
}))), /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
108
111
|
pointerEvents: "none"
|
|
109
112
|
}, /*#__PURE__*/React.createElement(_TextField.default, _extends({}, props, {
|
|
110
|
-
value:
|
|
113
|
+
value: selectedLabel,
|
|
111
114
|
placeholder: placeholder // @ts-ignore
|
|
112
115
|
,
|
|
113
116
|
ref: textField // cannot determine if ref is of correct type due to component being wrapped in a withTheme()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["PickerComponent.android.tsx"],"names":["Picker","style","options","placeholder","selectedValue","disabled","onValueChange","onValueChangeOverride","props","viewStyles","borderRadius","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderColor","backgroundColor","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","textField","React","useRef","undefined","itemValue","itemIndex","toggleFocus","current","stylesWithoutMargin","StyleSheet","flatten","
|
|
1
|
+
{"version":3,"sources":["PickerComponent.android.tsx"],"names":["Picker","style","options","placeholder","selectedValue","disabled","onValueChange","onValueChangeOverride","props","viewStyles","borderRadius","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderColor","backgroundColor","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","textField","React","useRef","undefined","itemValue","itemIndex","toggleFocus","current","stylesWithoutMargin","StyleSheet","flatten","selectedLabel","find","opt","value","label","styles","container","index","toString","opacity","position","top","left","right","bottom","map","o","create","alignSel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F;AAKE,IAAA,GAAG,EAAEoB,SALP,CAKkB;AALlB;AAME,IAAA,QAAQ,EAAElB,QANZ,CAOE;AAPF;AAQE,IAAA,KAAK,EAAE0B;AART,KADF,CApBF,CALF,CADF;AAyCD,CAlGD;;AAoGA,MAAMQ,MAAM,GAAGP,wBAAWmB,MAAX,CAAkB;AAC/BX,EAAAA,SAAS,EAAE;AACTY,IAAAA,SAAS,EAAE;AADF;AADoB,CAAlB,CAAf;;eAMe,wBAAUpD,MAAV,C","sourcesContent":["import * as React from \"react\";\nimport { View, StyleSheet } from \"react-native\";\nimport omit from \"lodash.omit\";\nimport { withTheme } from \"../../theming\";\nimport { Picker as NativePicker } from \"@react-native-picker/picker\";\nimport { extractStyles } from \"../../utilities\";\n\nimport TextField from \"../TextField\";\nimport Touchable from \"../Touchable\";\nimport { PickerComponentProps } from \"./PickerTypes\";\n\nconst Picker: React.FC<PickerComponentProps> = ({\n style,\n options,\n placeholder,\n selectedValue,\n disabled = false,\n onValueChange: onValueChangeOverride = () => {},\n ...props\n}) => {\n const {\n viewStyles: {\n borderRadius, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderTopWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderRightWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderBottomWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderLeftWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderColor, // eslint-disable-line @typescript-eslint/no-unused-vars\n backgroundColor, // eslint-disable-line @typescript-eslint/no-unused-vars\n padding, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingTop, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingRight, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingBottom, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingLeft, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...viewStyles\n },\n } = extractStyles(style);\n\n const textField = React.useRef<typeof TextField | undefined>(undefined);\n\n const onValueChange = (itemValue: string, itemIndex: number) => {\n toggleFocus();\n onValueChangeOverride(itemValue, itemIndex);\n };\n\n const toggleFocus = () => {\n if (!disabled) {\n // @ts-ignore\n textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()\n }\n };\n\n const stylesWithoutMargin =\n style &&\n omit(StyleSheet.flatten(style), [\n \"margin\",\n \"marginTop\",\n \"marginRight\",\n \"marginBottom\",\n \"marginLeft\",\n ]);\n\n const selectedLabel =\n selectedValue &&\n (options.find((opt) => opt.value === selectedValue)?.label ??\n selectedValue);\n\n return (\n <Touchable\n disabled={disabled}\n onPress={toggleFocus}\n style={[styles.container, viewStyles]}\n >\n <View>\n <NativePicker\n enabled={!disabled}\n selectedValue={selectedValue}\n onValueChange={(value, index) =>\n onValueChange(value.toString(), index)\n }\n style={{\n opacity: 0,\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n }}\n >\n {options.map((o) => (\n <NativePicker.Item label={o.label} value={o.value} key={o.value} />\n ))}\n </NativePicker>\n <View pointerEvents=\"none\">\n <TextField\n {...props}\n value={selectedLabel}\n placeholder={placeholder}\n // @ts-ignore\n ref={textField} // cannot determine if ref is of correct type due to component being wrapped in a withTheme()\n disabled={disabled}\n // @ts-expect-error\n style={stylesWithoutMargin}\n />\n </View>\n </View>\n </Touchable>\n );\n};\n\nconst styles = StyleSheet.create({\n container: {\n alignSelf: \"stretch\",\n },\n});\n\nexport default withTheme(Picker);\n"]}
|
|
@@ -36,6 +36,8 @@ const Picker = ({
|
|
|
36
36
|
onValueChange: onValueChangeOverride = () => {},
|
|
37
37
|
...props
|
|
38
38
|
}) => {
|
|
39
|
+
var _options$find$label, _options$find;
|
|
40
|
+
|
|
39
41
|
const {
|
|
40
42
|
viewStyles: {
|
|
41
43
|
borderRadius,
|
|
@@ -82,6 +84,7 @@ const Picker = ({
|
|
|
82
84
|
};
|
|
83
85
|
|
|
84
86
|
const stylesWithoutMargin = style && (0, _lodash.default)(_reactNative.StyleSheet.flatten(style), ["margin", "marginTop", "marginRight", "marginBottom", "marginLeft"]);
|
|
87
|
+
const selectedLabel = selectedValue && ((_options$find$label = (_options$find = options.find(opt => opt.value === selectedValue)) === null || _options$find === void 0 ? void 0 : _options$find.label) !== null && _options$find$label !== void 0 ? _options$find$label : selectedValue);
|
|
85
88
|
return /*#__PURE__*/React.createElement(_Touchable.default, {
|
|
86
89
|
disabled: disabled,
|
|
87
90
|
onPress: toggleFocus,
|
|
@@ -106,7 +109,7 @@ const Picker = ({
|
|
|
106
109
|
}))), /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
107
110
|
pointerEvents: "none"
|
|
108
111
|
}, /*#__PURE__*/React.createElement(_TextField.default, _extends({}, props, {
|
|
109
|
-
value:
|
|
112
|
+
value: selectedLabel,
|
|
110
113
|
placeholder: placeholder // @ts-ignore
|
|
111
114
|
,
|
|
112
115
|
ref: textField // cannot determine if ref is of correct type due to component being wrapped in a withTheme()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["PickerComponent.web.tsx"],"names":["Picker","style","options","placeholder","selectedValue","disabled","onValueChange","onValueChangeOverride","props","viewStyles","borderRadius","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderColor","backgroundColor","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","textField","React","useRef","undefined","itemValue","itemIndex","toggleFocus","current","stylesWithoutMargin","StyleSheet","flatten","
|
|
1
|
+
{"version":3,"sources":["PickerComponent.web.tsx"],"names":["Picker","style","options","placeholder","selectedValue","disabled","onValueChange","onValueChangeOverride","props","viewStyles","borderRadius","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderColor","backgroundColor","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","textField","React","useRef","undefined","itemValue","itemIndex","toggleFocus","current","stylesWithoutMargin","StyleSheet","flatten","selectedLabel","find","opt","value","label","styles","container","index","toString","flex","opacity","position","top","left","right","bottom","map","o","create","alignSelf"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;AAGA,MAAMA,MAAsC,GAAG,CAAC;AAC9CC,EAAAA,KAD8C;AAE9CC,EAAAA,OAF8C;AAG9CC,EAAAA,WAH8C;AAI9CC,EAAAA,aAJ8C;AAK9CC,EAAAA,QAAQ,GAAG,KALmC;AAM9CC,EAAAA,aAAa,EAAEC,qBAAqB,GAAG,MAAM,CAAE,CAND;AAO9C,KAAGC;AAP2C,CAAD,KAQzC;AAAA;;AACJ,QAAM;AACJC,IAAAA,UAAU,EAAE;AACVC,MAAAA,YADU;AACI;AACdC,MAAAA,WAFU;AAEG;AACbC,MAAAA,cAHU;AAGM;AAChBC,MAAAA,gBAJU;AAIQ;AAClBC,MAAAA,iBALU;AAKS;AACnBC,MAAAA,eANU;AAMO;AACjBC,MAAAA,WAPU;AAOG;AACbC,MAAAA,eARU;AAQO;AACjBC,MAAAA,OATU;AASD;AACTC,MAAAA,UAVU;AAUE;AACZC,MAAAA,YAXU;AAWI;AACdC,MAAAA,aAZU;AAYK;AACfC,MAAAA,WAbU;AAaG;AACb,SAAGb;AAdO;AADR,MAiBF,8BAAcR,KAAd,CAjBJ;AAmBA,QAAMsB,SAAS,GAAGC,KAAK,CAACC,MAAN,CAA2CC,SAA3C,CAAlB;;AAEA,QAAMpB,aAAa,GAAG,CAACqB,SAAD,EAAoBC,SAApB,KAA0C;AAC9DC,IAAAA,WAAW;AACXtB,IAAAA,qBAAqB,CAACoB,SAAD,EAAYC,SAAZ,CAArB;AACD,GAHD;;AAKA,QAAMC,WAAW,GAAG,MAAM;AACxB,QAAI,CAACxB,QAAL,EAAe;AACb;AACAkB,MAAAA,SAAS,CAACO,OAAV,CAAkBD,WAAlB,GAFa,CAEoB;AAClC;AACF,GALD;;AAOA,QAAME,mBAAmB,GACvB9B,KAAK,IACL,qBAAK+B,wBAAWC,OAAX,CAAmBhC,KAA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AAK,EAAE0B,aAFT;AAGE,IAAA,WAAW,EAAE/B,WAHf,CAIE;AAJF;AAKE,IAAA,GAAG,EAAEoB,SALP,CAKkB;AALlB;AAME,IAAA,QAAQ,EAAElB,QANZ,CAOE;AAPF;AAQE,IAAA,KAAK,EAAE0B;AART,KADF,CArBF,CALF,CADF;AA0CD,CAnGD;;AAqGA,MAAMQ,MAAM,GAAGP,wBAAWoB,MAAX,CAAkB;AAC/BZ,EAAAA,SAAS,EAAE;AACTa,IAAAA,SAAS,EAAE;AADF;AADoB,CAAlB,CAAf;;eAMe,wBAAUrD,MAAV,C","sourcesContent":["import * as React from \"react\";\nimport { View, StyleSheet, Picker as NativePicker } from \"react-native\";\nimport omit from \"lodash.omit\";\nimport { withTheme } from \"../../theming\";\nimport { extractStyles } from \"../../utilities\";\n\nimport TextField from \"../TextField\";\nimport Touchable from \"../Touchable\";\nimport { PickerComponentProps } from \"./PickerTypes\";\n\nconst Picker: React.FC<PickerComponentProps> = ({\n style,\n options,\n placeholder,\n selectedValue,\n disabled = false,\n onValueChange: onValueChangeOverride = () => {},\n ...props\n}) => {\n const {\n viewStyles: {\n borderRadius, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderTopWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderRightWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderBottomWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderLeftWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderColor, // eslint-disable-line @typescript-eslint/no-unused-vars\n backgroundColor, // eslint-disable-line @typescript-eslint/no-unused-vars\n padding, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingTop, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingRight, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingBottom, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingLeft, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...viewStyles\n },\n } = extractStyles(style);\n\n const textField = React.useRef<typeof TextField | undefined>(undefined);\n\n const onValueChange = (itemValue: string, itemIndex: number) => {\n toggleFocus();\n onValueChangeOverride(itemValue, itemIndex);\n };\n\n const toggleFocus = () => {\n if (!disabled) {\n // @ts-ignore\n textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()\n }\n };\n\n const stylesWithoutMargin =\n style &&\n omit(StyleSheet.flatten(style), [\n \"margin\",\n \"marginTop\",\n \"marginRight\",\n \"marginBottom\",\n \"marginLeft\",\n ]);\n\n const selectedLabel =\n selectedValue &&\n (options.find((opt) => opt.value === selectedValue)?.label ??\n selectedValue);\n\n return (\n <Touchable\n disabled={disabled}\n onPress={toggleFocus}\n style={[styles.container, viewStyles]}\n >\n <View>\n <NativePicker\n enabled={!disabled}\n selectedValue={selectedValue}\n onValueChange={(value, index) =>\n onValueChange(value.toString(), index)\n }\n style={{\n flex: 1,\n opacity: 0,\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n }}\n >\n {options.map((o) => (\n <NativePicker.Item label={o.label} value={o.value} key={o.value} />\n ))}\n </NativePicker>\n <View pointerEvents=\"none\">\n <TextField\n {...props}\n value={selectedLabel}\n placeholder={placeholder}\n // @ts-ignore\n ref={textField} // cannot determine if ref is of correct type due to component being wrapped in a withTheme()\n disabled={disabled}\n // @ts-expect-error\n style={stylesWithoutMargin}\n />\n </View>\n </View>\n </Touchable>\n );\n};\n\nconst styles = StyleSheet.create({\n container: {\n alignSelf: \"stretch\",\n },\n});\n\nexport default withTheme(Picker);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["RadioButtonRow.tsx"],"names":["Direction","getRadioButtonAlignment","parentDirection","direction","GroupDirection","Horizontal","Row","RowReverse","renderLabel","value","labelStyle","textStyle","RadioButtonRow","Icon","label","color","unselectedColor","onPress","labelContainerStyle","radioButtonStyle","selected","disabled","style","rest","contextValue","onValueChange","handlePress","textStyles","viewStyles","styles","mainParent","flexDirection","alignItems","flex","StyleSheet","create","justifyContent","paddingStart","minHeight","paddingEnd","Platform","select","web","cursor","userSelect","SEED_DATA","name","tag","category","COMPONENT_TYPES","input","layout","props","description","required","defaultValue","options","group","GROUPS","basic"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AASA;;AACA;;;;;;;;;;IAEYA,S;;;WAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,yBAAAA,S;;AAiBZ,MAAMC,uBAAuB,GAAG,CAC9BC,eAD8B,EAE9BC,SAF8B,KAG3B;AACH,MAAID,eAAe,KAAKE,mBAAeC,UAAvC,EAAmD;AACjD,WAAOF,SAAS,KAAKH,SAAS,CAACM,GAAxB,GAA8B,YAA9B,GAA6C,UAApD;AACD,GAFD,MAEO,IAAIH,SAAS,KAAKH,SAAS,CAACO,UAA5B,EAAwC;AAC7C,WAAO,YAAP;AACD,GAFM,MAEA;AACL,WAAO,UAAP;AACD;AACF,CAXD;;AAaA,MAAMC,WAAW,GAAG,CAClBC,KADkB,EAElBC,UAFkB,EAGlBC,SAHkB,KAIf;AACH,MAAI,OAAOF,KAAP,KAAiB,QAArB,EAA+B;AAC7B,wBAAO,oBAAC,aAAD;AAAM,MAAA,KAAK,EAAE,CAACC,UAAD,EAAaC,SAAb;AAAb,OAAuCF,KAAvC,CAAP;AACD,GAFD,MAEO;AACL,wBAAO,0CAAGA,KAAH,CAAP;AACD;AACF,CAVD;;AAYA,MAAMG,cAAwD,GAAG,CAAC;AAChEC,EAAAA,IADgE;AAEhEC,EAAAA,KAFgE;AAGhEL,EAAAA,KAHgE;AAIhEM,EAAAA,KAJgE;AAKhEC,EAAAA,eALgE;AAMhEC,EAAAA,OAAO,GAAG,MAAM,CAAE,CAN8C;AAOhEC,EAAAA,mBAPgE;AAQhER,EAAAA,UARgE;AAShES,EAAAA,gBATgE;AAUhEhB,EAAAA,SAAS,GAAGH,SAAS,CAACM,G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MAAAA,KAAK,EAAE,OADa;AAEpBuC,MAAAA,WAAW,EAAE,2BAFO;AAGpBE,MAAAA,YAAY,EAAE,IAHM;AAIpBD,MAAAA,QAAQ,EAAE;AAJU,KAAf,CAbF;AAmBLvC,IAAAA,KAAK,EAAE,4BAAgB;AACrB0C,MAAAA,KAAK,EAAEC,cAAOC,KADO;AAErBN,MAAAA,WAAW,EAAE,sBAFQ;AAGrBE,MAAAA,YAAY,EAAE;AAHO,KAAhB,CAnBF;AAwBLvC,IAAAA,eAAe,EAAE,4BAAgB;AAC/ByC,MAAAA,KAAK,EAAEC,cAAOC,KADiB;AAE/B7C,MAAAA,KAAK,EAAE,kBAFwB;AAG/BuC,MAAAA,WAAW,EAAE,iCAHkB;AAI/BE,MAAAA,YAAY,EAAE;AAJiB,KAAhB;AAxBZ;AALgB,CAAlB","sourcesContent":["import * as React from \"react\";\nimport {\n StyleProp,\n ViewStyle,\n StyleSheet,\n TextStyle,\n View,\n Platform,\n} from \"react-native\";\nimport RadioButton, { RadioButtonProps } from \"./RadioButton\";\nimport Text from \"../Text\";\nimport { useRadioButtonGroupContext } from \"./context\";\nimport {\n createTextProp,\n createTextEnumProp,\n COMPONENT_TYPES,\n createColorProp,\n GROUPS,\n} from \"@draftbit/types\";\nimport type { IconSlot } from \"../../interfaces/Icon\";\nimport { Direction as GroupDirection } from \"./context\";\nimport Touchable from \"../Touchable\";\nimport { extractStyles } from \"../../utilities\";\n\nexport enum Direction {\n Row = \"row\",\n RowReverse = \"row-reverse\",\n}\n\nexport interface RadioButtonRowProps extends Omit<RadioButtonProps, \"onPress\"> {\n label: string | React.ReactNode;\n value: string;\n color?: string;\n unselectedColor?: string;\n labelContainerStyle: StyleProp<ViewStyle>;\n radioButtonStyle?: StyleProp<ViewStyle>;\n labelStyle?: StyleProp<TextStyle>;\n onPress?: (value: string) => void;\n direction?: Direction;\n}\n\nconst getRadioButtonAlignment = (\n parentDirection: GroupDirection | undefined,\n direction: Direction\n) => {\n if (parentDirection === GroupDirection.Horizontal) {\n return direction === Direction.Row ? \"flex-start\" : \"flex-end\";\n } else if (direction === Direction.RowReverse) {\n return \"flex-start\";\n } else {\n return \"flex-end\";\n }\n};\n\nconst renderLabel = (\n value: string | React.ReactNode,\n labelStyle: StyleProp<TextStyle>,\n textStyle: StyleProp<TextStyle>\n) => {\n if (typeof value === \"string\") {\n return <Text style={[labelStyle, textStyle]}>{value}</Text>;\n } else {\n return <>{value}</>;\n }\n};\n\nconst RadioButtonRow: React.FC<RadioButtonRowProps & IconSlot> = ({\n Icon,\n label,\n value,\n color,\n unselectedColor,\n onPress = () => {},\n labelContainerStyle,\n labelStyle,\n radioButtonStyle,\n direction = Direction.Row,\n selected,\n disabled,\n style,\n ...rest\n}) => {\n const {\n value: contextValue,\n onValueChange,\n direction: parentDirection,\n } = useRadioButtonGroupContext();\n\n const handlePress = () => {\n onPress(value);\n onValueChange && onValueChange(value);\n };\n\n const { textStyles, viewStyles } = extractStyles(style);\n\n return (\n <Touchable\n onPress={handlePress}\n style={[styles.mainParent, { flexDirection: direction }, viewStyles]}\n disabled={disabled}\n {...rest}\n >\n <View\n style={[\n styles.label,\n {\n alignItems: direction === Direction.Row ? \"flex-start\" : \"flex-end\",\n },\n labelContainerStyle,\n ]}\n >\n {renderLabel(label, labelStyle, textStyles)}\n </View>\n <View\n style={{\n flex: 1,\n alignItems: getRadioButtonAlignment(parentDirection, direction),\n }}\n >\n <RadioButton\n Icon={Icon}\n selected={\n selected || (contextValue != null && contextValue === value)\n }\n color={color}\n unselectedColor={unselectedColor}\n onPress={handlePress}\n style={radioButtonStyle}\n />\n </View>\n </Touchable>\n );\n};\n\nconst styles = StyleSheet.create({\n mainParent: {\n alignItems: \"center\",\n justifyContent: \"space-around\",\n paddingStart: 20,\n minHeight: 50,\n paddingEnd: 20,\n flex: 1,\n ...Platform.select({\n web: {\n cursor: \"pointer\",\n userSelect: \"none\",\n },\n }),\n },\n label: {\n flex: 3,\n },\n});\n\nexport default RadioButtonRow;\n\nexport const SEED_DATA = {\n name: \"Radio Button Row\",\n tag: \"RadioButtonRow\",\n category: COMPONENT_TYPES.input,\n layout: {},\n props: {\n label: createTextProp({\n label: \"Label\",\n description: \"Label to show with the radio button\",\n required: true,\n defaultValue: \"First Option\",\n }),\n direction: createTextEnumProp({\n label: \"Direction\",\n description:\n \"Whether the checkbox will appear on the left or on the right\",\n options: [\"row\", \"row-reverse\"],\n }),\n value: createTextProp({\n label: \"Value\",\n description: \"Value of the radio button\",\n defaultValue: null,\n required: true,\n }),\n color: createColorProp({\n group: GROUPS.basic,\n description: \"Color for the button\",\n defaultValue: \"primary\",\n }),\n unselectedColor: createColorProp({\n group: GROUPS.basic,\n label: \"Unselected Color\",\n description: \"Unselected Color for the button\",\n defaultValue: \"primary\",\n }),\n },\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["RadioButtonRow.tsx"],"names":["Direction","getRadioButtonAlignment","parentDirection","direction","GroupDirection","Horizontal","Row","RowReverse","renderLabel","value","labelStyle","textStyle","RadioButtonRow","Icon","label","color","unselectedColor","onPress","labelContainerStyle","radioButtonStyle","selected","disabled","style","rest","contextValue","onValueChange","handlePress","textStyles","viewStyles","styles","mainParent","flexDirection","alignItems","flex","StyleSheet","create","justifyContent","paddingStart","minHeight","paddingEnd","Platform","select","web","cursor","userSelect","SEED_DATA","name","tag","category","COMPONENT_TYPES","input","layout","props","description","required","defaultValue","options","group","GROUPS","basic"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AASA;;AACA;;;;;;;;;;IAEYA,S;;;WAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,yBAAAA,S;;AAiBZ,MAAMC,uBAAuB,GAAG,CAC9BC,eAD8B,EAE9BC,SAF8B,KAG3B;AACH,MAAID,eAAe,KAAKE,mBAAeC,UAAvC,EAAmD;AACjD,WAAOF,SAAS,KAAKH,SAAS,CAACM,GAAxB,GAA8B,YAA9B,GAA6C,UAApD;AACD,GAFD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,C,CAqCP","sourcesContent":["import * as React from \"react\";\nimport {\n StyleProp,\n ViewStyle,\n StyleSheet,\n TextStyle,\n View,\n Platform,\n} from \"react-native\";\nimport RadioButton, { RadioButtonProps } from \"./RadioButton\";\nimport Text from \"../Text\";\nimport { useRadioButtonGroupContext } from \"./context\";\nimport {\n createTextProp,\n createTextEnumProp,\n COMPONENT_TYPES,\n createColorProp,\n GROUPS,\n} from \"@draftbit/types\";\nimport type { IconSlot } from \"../../interfaces/Icon\";\nimport { Direction as GroupDirection } from \"./context\";\nimport Touchable from \"../Touchable\";\nimport { extractStyles } from \"../../utilities\";\n\nexport enum Direction {\n Row = \"row\",\n RowReverse = \"row-reverse\",\n}\n\nexport interface RadioButtonRowProps extends Omit<RadioButtonProps, \"onPress\"> {\n label: string | React.ReactNode;\n value: string;\n color?: string;\n unselectedColor?: string;\n labelContainerStyle: StyleProp<ViewStyle>;\n radioButtonStyle?: StyleProp<ViewStyle>;\n labelStyle?: StyleProp<TextStyle>;\n onPress?: (value: string) => void;\n direction?: Direction;\n}\n\nconst getRadioButtonAlignment = (\n parentDirection: GroupDirection | undefined,\n direction: Direction\n) => {\n if (parentDirection === GroupDirection.Horizontal) {\n return direction === Direction.Row ? \"flex-start\" : \"flex-end\";\n } else if (direction === Direction.RowReverse) {\n return \"flex-start\";\n } else {\n return \"flex-end\";\n }\n};\n\nconst renderLabel = (\n value: string | React.ReactNode,\n labelStyle: StyleProp<TextStyle>,\n textStyle: StyleProp<TextStyle>\n) => {\n if (typeof value === \"string\") {\n return <Text style={[labelStyle, textStyle]}>{value}</Text>;\n } else {\n return <>{value}</>;\n }\n};\n\nconst RadioButtonRow: React.FC<RadioButtonRowProps & IconSlot> = ({\n Icon,\n label,\n value,\n color,\n unselectedColor,\n onPress = () => {},\n labelContainerStyle,\n labelStyle,\n radioButtonStyle,\n direction = Direction.Row,\n selected,\n disabled,\n style,\n ...rest\n}) => {\n const {\n value: contextValue,\n onValueChange,\n direction: parentDirection,\n } = useRadioButtonGroupContext();\n\n const handlePress = () => {\n onPress(value);\n onValueChange && onValueChange(value);\n };\n\n const { textStyles, viewStyles } = extractStyles(style);\n\n return (\n <Touchable\n onPress={handlePress}\n style={[styles.mainParent, { flexDirection: direction }, viewStyles]}\n disabled={disabled}\n {...rest}\n >\n <View\n style={[\n styles.label,\n {\n alignItems: direction === Direction.Row ? \"flex-start\" : \"flex-end\",\n },\n labelContainerStyle,\n ]}\n >\n {renderLabel(label, labelStyle, textStyles)}\n </View>\n <View\n style={{\n flex: 1,\n alignItems: getRadioButtonAlignment(parentDirection, direction),\n }}\n >\n <RadioButton\n Icon={Icon}\n selected={\n selected || (contextValue != null && contextValue === value)\n }\n color={color}\n unselectedColor={unselectedColor}\n onPress={handlePress}\n style={radioButtonStyle}\n />\n </View>\n </Touchable>\n );\n};\n\nconst styles = StyleSheet.create({\n mainParent: {\n alignItems: \"center\",\n justifyContent: \"space-around\",\n paddingStart: 20,\n minHeight: 50,\n paddingEnd: 20,\n flex: 1,\n ...Platform.select({\n web: {\n cursor: \"pointer\",\n userSelect: \"none\",\n },\n }),\n },\n label: {\n flex: 3,\n },\n});\n\nexport default RadioButtonRow;\n\nexport const SEED_DATA = {\n name: \"Radio Button Row\",\n tag: \"RadioButtonRow\",\n category: COMPONENT_TYPES.input,\n layout: {},\n props: {\n label: createTextProp({\n label: \"Label\",\n description: \"Label to show with the radio button\",\n required: true,\n defaultValue: \"First Option\",\n }),\n direction: createTextEnumProp({\n label: \"Direction\",\n description:\n \"Whether the checkbox will appear on the left or on the right\",\n options: [\"row\", \"row-reverse\"],\n }),\n value: createTextProp({\n label: \"Value\",\n description: \"Value of the radio button\",\n defaultValue: null,\n required: true,\n }),\n color: createColorProp({\n group: GROUPS.basic,\n description: \"Color for the button\",\n defaultValue: \"primary\",\n }),\n unselectedColor: createColorProp({\n group: GROUPS.basic,\n label: \"Unselected Color\",\n description: \"Unselected Color for the button\",\n defaultValue: \"primary\",\n }),\n },\n};\n// TODO comment testing\n"]}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
1
|
import * as React from "react";
|
|
4
2
|
import { Text, Pressable, Platform, StyleSheet, ActivityIndicator } from "react-native";
|
|
5
3
|
import { withTheme } from "../theming";
|
|
@@ -57,7 +55,7 @@ function Base({
|
|
|
57
55
|
buttonStyles.justifyContent = "flex-end";
|
|
58
56
|
}
|
|
59
57
|
|
|
60
|
-
return /*#__PURE__*/React.createElement(Pressable,
|
|
58
|
+
return /*#__PURE__*/React.createElement(Pressable, {
|
|
61
59
|
onPress: onPress,
|
|
62
60
|
disabled: disabled || loading,
|
|
63
61
|
style: ({
|
|
@@ -66,8 +64,9 @@ function Base({
|
|
|
66
64
|
return [styles.base, {
|
|
67
65
|
opacity: pressed || disabled ? 0.75 : 1
|
|
68
66
|
}, buttonStyles];
|
|
69
|
-
}
|
|
70
|
-
|
|
67
|
+
},
|
|
68
|
+
...props
|
|
69
|
+
}, loading ? /*#__PURE__*/React.createElement(ActivityIndicator, {
|
|
71
70
|
size: "small",
|
|
72
71
|
color: color,
|
|
73
72
|
style: styles.loading
|
|
@@ -86,13 +85,14 @@ const Solid = ({
|
|
|
86
85
|
theme,
|
|
87
86
|
...props
|
|
88
87
|
}) => {
|
|
89
|
-
return /*#__PURE__*/React.createElement(Base,
|
|
88
|
+
return /*#__PURE__*/React.createElement(Base, {
|
|
90
89
|
style: [{
|
|
91
90
|
color: "#FFF",
|
|
92
91
|
borderRadius: theme.roundness,
|
|
93
92
|
backgroundColor: theme.colors.primary
|
|
94
|
-
}, style]
|
|
95
|
-
|
|
93
|
+
}, style],
|
|
94
|
+
...props
|
|
95
|
+
});
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
const ButtonSolid = withTheme(Solid);
|
|
@@ -103,13 +103,14 @@ const Outline = ({
|
|
|
103
103
|
theme,
|
|
104
104
|
...props
|
|
105
105
|
}) => {
|
|
106
|
-
return /*#__PURE__*/React.createElement(Base,
|
|
106
|
+
return /*#__PURE__*/React.createElement(Base, {
|
|
107
107
|
style: [styles.outline, {
|
|
108
108
|
borderRadius: theme.roundness,
|
|
109
109
|
borderColor: theme.colors.primary,
|
|
110
110
|
color: theme.colors.primary
|
|
111
|
-
}, style]
|
|
112
|
-
|
|
111
|
+
}, style],
|
|
112
|
+
...props
|
|
113
|
+
});
|
|
113
114
|
};
|
|
114
115
|
|
|
115
116
|
const ButtonOutline = withTheme(Outline);
|
|
@@ -119,12 +120,13 @@ export const BaseLink = ({
|
|
|
119
120
|
theme,
|
|
120
121
|
...props
|
|
121
122
|
}) => {
|
|
122
|
-
return /*#__PURE__*/React.createElement(Base,
|
|
123
|
+
return /*#__PURE__*/React.createElement(Base, {
|
|
123
124
|
style: [styles.bare, {
|
|
124
125
|
color: theme.colors.primary
|
|
125
126
|
}, style],
|
|
126
|
-
hitSlop: 8
|
|
127
|
-
|
|
127
|
+
hitSlop: 8,
|
|
128
|
+
...props
|
|
129
|
+
});
|
|
128
130
|
};
|
|
129
131
|
const Link = withTheme(BaseLink);
|
|
130
132
|
export { Link };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Button.tsx"],"names":["React","Text","Pressable","Platform","StyleSheet","ActivityIndicator","withTheme","COMPONENT_TYPES","createIconProp","createBoolProp","createTextProp","GROUPS","createActionProp","Triggers","CONSTANTS","baseHeight","borderRadius","padding","icon","Base","Icon","title","onPress","loading","disabled","style","props","color","fontFamily","fontWeight","fontSize","lineHeight","letterSpacing","textTransform","textAlign","textDecorationLine","textDecorationColor","textDecorationStyle","buttonStyles","flatten","titleStyles","justifyContent","pressed","styles","base","opacity","Solid","theme","roundness","backgroundColor","colors","primary","ButtonSolid","Outline","outline","borderColor","ButtonOutline","BaseLink","bare","Link","create","position","flexDirection","alignItems","minHeight","paddingHorizontal","select","web","cursor","userSelect","borderWidth","undefined","marginRight","marginTop","alignSelf","default","marginBottom","SEED_DATA_TRIGGERS","OnPress","SEED_DATA_PROPS","defaultValue","required","label","description","group","basic","LAYOUT","SEED_DATA","name","tag","category","button","layout","triggers"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,IADF,EAEEC,SAFF,EAGEC,QAHF,EAIEC,UAJF,EAOEC,iBAPF,QAQO,cARP;AAUA,SAASC,SAAT,QAA0B,YAA1B;AAEA,SACEC,eADF,EAEEC,cAFF,EAGEC,cAHF,EAIEC,cAJF,EAKEC,MALF,EAMEC,gBANF,EAOEC,QAPF,QAQO,iBARP;AAYA,MAAMC,SAAS,GAAG;AAChBC,EAAAA,UAAU,EAAE,EADI;AAEhBC,EAAAA,YAAY,EAAE,CAFE;AAGhBC,EAAAA,OAAO,EAAE,CAHO;AAIhBC,EAAAA,IAAI,EAAE;AAJU,CAAlB;;AA4BA,SAASC,IAAT,CAAc;AACZC,EAAAA,IADY;AAEZF,EAAAA,IAFY;AAGZG,EAAAA,KAHY;AAIZC,EAAAA,OAJY;AAKZC,EAAAA,OALY;AAMZC,EAAAA,QANY;AAOZC,EAAAA,KAPY;AAQZ,KAAGC;AARS,CAAd,EAS2B;AACzB,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,MAaFlC,UAAU,CAACmC,OAAX,CAAmBd,KAAK,IAAK,EAA7B,CAbJ;AAeA,QAAMe,WAAsB,GAAG;AAC7Bb,IAAAA,KAD6B;AAE7BC,IAAAA,UAF6B;AAG7BC,IAAAA,UAH6B;AAI7BC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AVZ;AAWEnD,EAAAA,KAAK,EAAEqD;AAXT,CADuB,EAcvB;AACES,EAAAA,IAAI,EAAE,cADR;AAEEC,EAAAA,GAAG,EAAE,aAFP;AAGEC,EAAAA,QAAQ,EAAEnF,eAAe,CAACoF,MAH5B;AAIEC,EAAAA,MAAM,EAAE,EACN,GAAGN,MADG;AAENrC,IAAAA,eAAe,EAAE,SAFX;AAGNf,IAAAA,SAAS,EAAE;AAHL,GAJV;AASE2D,EAAAA,QAAQ,EAAEhB,kBATZ;AAUEnD,EAAAA,KAAK,EAAEqD;AAVT,CAduB,EA0BvB;AACES,EAAAA,IAAI,EAAE,MADR;AAEEC,EAAAA,GAAG,EAAE,MAFP;AAGEC,EAAAA,QAAQ,EAAEnF,eAAe,CAACoF,MAH5B;AAIEC,EAAAA,MAAM,EAAE,EACN,GAAGN,MADG;AAENrC,IAAAA,eAAe,EAAE,aAFX;AAGNtB,IAAAA,KAAK,EAAE,SAHD;AAINV,IAAAA,OAAO,EAAE,CAJH;AAKN+C,IAAAA,SAAS,EAAEO;AALL,GAJV;AAWEsB,EAAAA,QAAQ,EAAEhB,kBAXZ;AAYEnD,EAAAA,KAAK,EAAEqD;AAZT,CA1BuB,CAAlB","sourcesContent":["import * as React from \"react\";\nimport {\n Text,\n Pressable,\n Platform,\n StyleSheet,\n TextStyle,\n PressableProps,\n ActivityIndicator,\n} from \"react-native\";\n\nimport { withTheme } from \"../theming\";\n\nimport {\n COMPONENT_TYPES,\n createIconProp,\n createBoolProp,\n createTextProp,\n GROUPS,\n createActionProp,\n Triggers,\n} from \"@draftbit/types\";\nimport type { Theme } from \"../styles/DefaultTheme\";\nimport type { IconSlot } from \"../interfaces/Icon\";\n\nconst CONSTANTS = {\n baseHeight: 42,\n borderRadius: 4,\n padding: 8,\n icon: 24,\n};\n\ntype BaseProps = {\n title: string;\n disabled: boolean;\n loading: boolean;\n style?: TextStyle;\n onPress: () => void;\n icon?: string;\n} & PressableProps &\n IconSlot;\n\ntype Props = {\n title: string;\n disabled: boolean;\n loading: boolean;\n style?: TextStyle;\n onPress: () => void;\n icon?: string;\n theme: Theme;\n} & PressableProps &\n IconSlot;\n\nfunction Base({\n Icon,\n icon,\n title,\n onPress,\n loading,\n disabled,\n style,\n ...props\n}: BaseProps): JSX.Element {\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 ...buttonStyles\n } = StyleSheet.flatten(style || ({} as TextStyle));\n\n const titleStyles: 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 if (textAlign === \"left\") {\n buttonStyles.justifyContent = \"flex-start\";\n }\n\n if (textAlign === \"right\") {\n buttonStyles.justifyContent = \"flex-end\";\n }\n\n return (\n <Pressable\n onPress={onPress}\n disabled={disabled || loading}\n style={({ pressed }) => {\n return [\n styles.base,\n {\n opacity: pressed || disabled ? 0.75 : 1,\n },\n buttonStyles,\n ];\n }}\n {...props}\n >\n {loading ? (\n <ActivityIndicator size=\"small\" color={color} style={styles.loading} />\n ) : null}\n {icon && !loading ? (\n <Icon\n name={icon}\n color={color as string}\n style={styles.icon}\n size={CONSTANTS.icon}\n />\n ) : null}\n <Text style={titleStyles}>{title}</Text>\n </Pressable>\n );\n}\n\nconst Solid = ({ style, theme, ...props }: Props): JSX.Element => {\n return (\n <Base\n style={[\n {\n color: \"#FFF\",\n borderRadius: theme.roundness,\n backgroundColor: theme.colors.primary,\n },\n style,\n ]}\n {...props}\n />\n );\n};\n\nconst ButtonSolid: any = withTheme(Solid);\nexport { ButtonSolid };\n\nconst Outline = ({ style, theme, ...props }: Props): JSX.Element => {\n return (\n <Base\n style={[\n styles.outline,\n {\n borderRadius: theme.roundness,\n borderColor: theme.colors.primary,\n color: theme.colors.primary,\n },\n style,\n ]}\n {...props}\n />\n );\n};\n\nconst ButtonOutline: any = withTheme(Outline);\nexport { ButtonOutline };\n\nexport const BaseLink = ({ style, theme, ...props }: Props): JSX.Element => {\n return (\n <Base\n style={[styles.bare, { color: theme.colors.primary }, style]}\n hitSlop={8}\n {...props}\n />\n );\n};\n\nconst Link: any = withTheme(BaseLink);\nexport { Link };\n\nconst styles = StyleSheet.create({\n base: {\n position: \"relative\",\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"center\",\n minHeight: CONSTANTS.baseHeight,\n paddingHorizontal: 12,\n fontFamily: \"System\",\n fontWeight: \"700\",\n ...Platform.select({\n web: {\n cursor: \"pointer\",\n userSelect: \"none\",\n },\n }),\n },\n outline: {\n backgroundColor: \"transparent\",\n borderWidth: 1,\n },\n bare: {\n backgroundColor: \"transparent\",\n padding: 0,\n minHeight: undefined,\n },\n loading: {\n marginRight: 6,\n },\n icon: {\n ...Platform.select({\n web: {\n marginTop: 1,\n marginRight: 4,\n alignSelf: \"center\",\n },\n default: {\n marginBottom: 2,\n marginRight: 4,\n alignSelf: \"center\",\n },\n }),\n },\n});\n\nconst SEED_DATA_TRIGGERS = [Triggers.OnPress];\nconst SEED_DATA_PROPS = {\n onPress: createActionProp(),\n icon: createIconProp({\n defaultValue: null,\n required: false,\n }),\n title: createTextProp({\n label: \"Label\",\n description: \"Button Label\",\n defaultValue: \"Get Started\",\n }),\n disabled: createBoolProp({\n group: GROUPS.basic,\n label: \"Disabled\",\n description: \"Whether the button should be disabled\",\n }),\n loading: createBoolProp({\n group: GROUPS.basic,\n label: \"Loading\",\n description: \"Whether to show a loading indicator\",\n }),\n};\n\nconst LAYOUT = {\n backgroundColor: \"transparent\",\n borderRadius: 8,\n fontFamily: \"system-700\",\n};\n\nexport const SEED_DATA = [\n {\n name: \"Button Outline\",\n tag: \"ButtonOutline\",\n category: COMPONENT_TYPES.button,\n layout: {\n ...LAYOUT,\n backgroundColor: \"transparent\",\n borderWidth: 1,\n textAlign: \"center\",\n },\n triggers: SEED_DATA_TRIGGERS,\n props: SEED_DATA_PROPS,\n },\n {\n name: \"Button Solid\",\n tag: \"ButtonSolid\",\n category: COMPONENT_TYPES.button,\n layout: {\n ...LAYOUT,\n backgroundColor: \"primary\",\n textAlign: \"center\",\n },\n triggers: SEED_DATA_TRIGGERS,\n props: SEED_DATA_PROPS,\n },\n {\n name: \"Link\",\n tag: \"Link\",\n category: COMPONENT_TYPES.button,\n layout: {\n ...LAYOUT,\n backgroundColor: \"transparent\",\n color: \"primary\",\n padding: 0,\n minHeight: undefined,\n },\n triggers: SEED_DATA_TRIGGERS,\n props: SEED_DATA_PROPS,\n },\n];\n"]}
|
|
1
|
+
{"version":3,"sources":["Button.js"],"names":["React","Text","Pressable","Platform","StyleSheet","ActivityIndicator","withTheme","COMPONENT_TYPES","createIconProp","createBoolProp","createTextProp","GROUPS","createActionProp","Triggers","CONSTANTS","baseHeight","borderRadius","padding","icon","Base","Icon","title","onPress","loading","disabled","style","props","color","fontFamily","fontWeight","fontSize","lineHeight","letterSpacing","textTransform","textAlign","textDecorationLine","textDecorationColor","textDecorationStyle","buttonStyles","flatten","titleStyles","justifyContent","createElement","pressed","styles","base","opacity","size","name","Solid","theme","roundness","backgroundColor","colors","primary","ButtonSolid","Outline","outline","borderColor","ButtonOutline","BaseLink","bare","hitSlop","Link","create","position","flexDirection","alignItems","minHeight","paddingHorizontal","select","web","cursor","userSelect","borderWidth","undefined","marginRight","marginTop","alignSelf","default","marginBottom","SEED_DATA_TRIGGERS","OnPress","SEED_DATA_PROPS","defaultValue","required","label","description","group","basic","LAYOUT","SEED_DATA","tag","category","button","layout","triggers"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,EAAeC,SAAf,EAA0BC,QAA1B,EAAoCC,UAApC,EAAgDC,iBAAhD,QAA0E,cAA1E;AACA,SAASC,SAAT,QAA0B,YAA1B;AACA,SAASC,eAAT,EAA0BC,cAA1B,EAA0CC,cAA1C,EAA0DC,cAA1D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UI8D,EAAAA,QAAQ,EAAEf,kBAVd;AAWIvD,EAAAA,KAAK,EAAEyD;AAXX,CADqB,EAcrB;AACInC,EAAAA,IAAI,EAAE,cADV;AAEI4C,EAAAA,GAAG,EAAE,aAFT;AAGIC,EAAAA,QAAQ,EAAEtF,eAAe,CAACuF,MAH9B;AAIIC,EAAAA,MAAM,EAAE,EACJ,GAAGL,MADC;AAEJtC,IAAAA,eAAe,EAAE,SAFb;AAGJlB,IAAAA,SAAS,EAAE;AAHP,GAJZ;AASI8D,EAAAA,QAAQ,EAAEf,kBATd;AAUIvD,EAAAA,KAAK,EAAEyD;AAVX,CAdqB,EA0BrB;AACInC,EAAAA,IAAI,EAAE,MADV;AAEI4C,EAAAA,GAAG,EAAE,MAFT;AAGIC,EAAAA,QAAQ,EAAEtF,eAAe,CAACuF,MAH9B;AAIIC,EAAAA,MAAM,EAAE,EACJ,GAAGL,MADC;AAEJtC,IAAAA,eAAe,EAAE,aAFb;AAGJzB,IAAAA,KAAK,EAAE,SAHH;AAIJV,IAAAA,OAAO,EAAE,CAJL;AAKJmD,IAAAA,SAAS,EAAEO;AALP,GAJZ;AAWIqB,EAAAA,QAAQ,EAAEf,kBAXd;AAYIvD,EAAAA,KAAK,EAAEyD;AAZX,CA1BqB,CAAlB","sourcesContent":["import * as React from \"react\";\nimport { Text, Pressable, Platform, StyleSheet, ActivityIndicator, } from \"react-native\";\nimport { withTheme } from \"../theming\";\nimport { COMPONENT_TYPES, createIconProp, createBoolProp, createTextProp, GROUPS, createActionProp, Triggers, } from \"@draftbit/types\";\nconst CONSTANTS = {\n baseHeight: 42,\n borderRadius: 4,\n padding: 8,\n icon: 24,\n};\nfunction Base({ Icon, icon, title, onPress, loading, disabled, style, ...props }) {\n const { color, fontFamily, fontWeight, fontSize, lineHeight, letterSpacing, textTransform, textAlign, textDecorationLine, textDecorationColor, textDecorationStyle, ...buttonStyles } = StyleSheet.flatten(style || {});\n const titleStyles = {\n color,\n fontFamily,\n fontWeight,\n fontSize,\n lineHeight,\n letterSpacing,\n textTransform,\n textAlign,\n textDecorationLine,\n textDecorationColor,\n textDecorationStyle,\n };\n if (textAlign === \"left\") {\n buttonStyles.justifyContent = \"flex-start\";\n }\n if (textAlign === \"right\") {\n buttonStyles.justifyContent = \"flex-end\";\n }\n return (React.createElement(Pressable, { onPress: onPress, disabled: disabled || loading, style: ({ pressed }) => {\n return [\n styles.base,\n {\n opacity: pressed || disabled ? 0.75 : 1,\n },\n buttonStyles,\n ];\n }, ...props },\n loading ? (React.createElement(ActivityIndicator, { size: \"small\", color: color, style: styles.loading })) : null,\n icon && !loading ? (React.createElement(Icon, { name: icon, color: color, style: styles.icon, size: CONSTANTS.icon })) : null,\n React.createElement(Text, { style: titleStyles }, title)));\n}\nconst Solid = ({ style, theme, ...props }) => {\n return (React.createElement(Base, { style: [\n {\n color: \"#FFF\",\n borderRadius: theme.roundness,\n backgroundColor: theme.colors.primary,\n },\n style,\n ], ...props }));\n};\nconst ButtonSolid = withTheme(Solid);\nexport { ButtonSolid };\nconst Outline = ({ style, theme, ...props }) => {\n return (React.createElement(Base, { style: [\n styles.outline,\n {\n borderRadius: theme.roundness,\n borderColor: theme.colors.primary,\n color: theme.colors.primary,\n },\n style,\n ], ...props }));\n};\nconst ButtonOutline = withTheme(Outline);\nexport { ButtonOutline };\nexport const BaseLink = ({ style, theme, ...props }) => {\n return (React.createElement(Base, { style: [styles.bare, { color: theme.colors.primary }, style], hitSlop: 8, ...props }));\n};\nconst Link = withTheme(BaseLink);\nexport { Link };\nconst styles = StyleSheet.create({\n base: {\n position: \"relative\",\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"center\",\n minHeight: CONSTANTS.baseHeight,\n paddingHorizontal: 12,\n fontFamily: \"System\",\n fontWeight: \"700\",\n ...Platform.select({\n web: {\n cursor: \"pointer\",\n userSelect: \"none\",\n },\n }),\n },\n outline: {\n backgroundColor: \"transparent\",\n borderWidth: 1,\n },\n bare: {\n backgroundColor: \"transparent\",\n padding: 0,\n minHeight: undefined,\n },\n loading: {\n marginRight: 6,\n },\n icon: {\n ...Platform.select({\n web: {\n marginTop: 1,\n marginRight: 4,\n alignSelf: \"center\",\n },\n default: {\n marginBottom: 2,\n marginRight: 4,\n alignSelf: \"center\",\n },\n }),\n },\n});\nconst SEED_DATA_TRIGGERS = [Triggers.OnPress];\nconst SEED_DATA_PROPS = {\n onPress: createActionProp(),\n icon: createIconProp({\n defaultValue: null,\n required: false,\n }),\n title: createTextProp({\n label: \"Label\",\n description: \"Button Label\",\n defaultValue: \"Get Started\",\n }),\n disabled: createBoolProp({\n group: GROUPS.basic,\n label: \"Disabled\",\n description: \"Whether the button should be disabled\",\n }),\n loading: createBoolProp({\n group: GROUPS.basic,\n label: \"Loading\",\n description: \"Whether to show a loading indicator\",\n }),\n};\nconst LAYOUT = {\n backgroundColor: \"transparent\",\n borderRadius: 8,\n fontFamily: \"system-700\",\n};\nexport const SEED_DATA = [\n {\n name: \"Button Outline\",\n tag: \"ButtonOutline\",\n category: COMPONENT_TYPES.button,\n layout: {\n ...LAYOUT,\n backgroundColor: \"transparent\",\n borderWidth: 1,\n textAlign: \"center\",\n },\n triggers: SEED_DATA_TRIGGERS,\n props: SEED_DATA_PROPS,\n },\n {\n name: \"Button Solid\",\n tag: \"ButtonSolid\",\n category: COMPONENT_TYPES.button,\n layout: {\n ...LAYOUT,\n backgroundColor: \"primary\",\n textAlign: \"center\",\n },\n triggers: SEED_DATA_TRIGGERS,\n props: SEED_DATA_PROPS,\n },\n {\n name: \"Link\",\n tag: \"Link\",\n category: COMPONENT_TYPES.button,\n layout: {\n ...LAYOUT,\n backgroundColor: \"transparent\",\n color: \"primary\",\n padding: 0,\n minHeight: undefined,\n },\n triggers: SEED_DATA_TRIGGERS,\n props: SEED_DATA_PROPS,\n },\n];\n"]}
|
|
@@ -18,6 +18,8 @@ const Picker = ({
|
|
|
18
18
|
onValueChange: onValueChangeOverride = () => {},
|
|
19
19
|
...props
|
|
20
20
|
}) => {
|
|
21
|
+
var _options$find$label, _options$find;
|
|
22
|
+
|
|
21
23
|
const {
|
|
22
24
|
viewStyles: {
|
|
23
25
|
borderRadius,
|
|
@@ -64,6 +66,7 @@ const Picker = ({
|
|
|
64
66
|
};
|
|
65
67
|
|
|
66
68
|
const stylesWithoutMargin = style && omit(StyleSheet.flatten(style), ["margin", "marginTop", "marginRight", "marginBottom", "marginLeft"]);
|
|
69
|
+
const selectedLabel = selectedValue && ((_options$find$label = (_options$find = options.find(opt => opt.value === selectedValue)) === null || _options$find === void 0 ? void 0 : _options$find.label) !== null && _options$find$label !== void 0 ? _options$find$label : selectedValue);
|
|
67
70
|
return /*#__PURE__*/React.createElement(Touchable, {
|
|
68
71
|
disabled: disabled,
|
|
69
72
|
onPress: toggleFocus,
|
|
@@ -87,7 +90,7 @@ const Picker = ({
|
|
|
87
90
|
}))), /*#__PURE__*/React.createElement(View, {
|
|
88
91
|
pointerEvents: "none"
|
|
89
92
|
}, /*#__PURE__*/React.createElement(TextField, _extends({}, props, {
|
|
90
|
-
value:
|
|
93
|
+
value: selectedLabel,
|
|
91
94
|
placeholder: placeholder // @ts-ignore
|
|
92
95
|
,
|
|
93
96
|
ref: textField // cannot determine if ref is of correct type due to component being wrapped in a withTheme()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["PickerComponent.android.tsx"],"names":["React","View","StyleSheet","omit","withTheme","Picker","NativePicker","extractStyles","TextField","Touchable","style","options","placeholder","selectedValue","disabled","onValueChange","onValueChangeOverride","props","viewStyles","borderRadius","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderColor","backgroundColor","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","textField","useRef","undefined","itemValue","itemIndex","toggleFocus","current","stylesWithoutMargin","flatten","
|
|
1
|
+
{"version":3,"sources":["PickerComponent.android.tsx"],"names":["React","View","StyleSheet","omit","withTheme","Picker","NativePicker","extractStyles","TextField","Touchable","style","options","placeholder","selectedValue","disabled","onValueChange","onValueChangeOverride","props","viewStyles","borderRadius","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderColor","backgroundColor","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","textField","useRef","undefined","itemValue","itemIndex","toggleFocus","current","stylesWithoutMargin","flatten","selectedLabel","find","opt","value","label","styles","container","index","toString","opacity","position","top","left","right","bottom","map","o","create","alignSelf"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,EAAeC,UAAf,QAAiC,cAAjC;AACA,OAAOC,IAAP,MAAiB,aAAjB;AACA,SAASC,SAAT,QAA0B,eAA1B;AACA,SAASC,MAAM,IAAIC,YAAnB,QAAuC,6BAAvC;AACA,SAASC,aAAT,QAA8B,iBAA9B;AAEA,OAAOC,SAAP,MAAsB,cAAtB;AACA,OAAOC,SAAP,MAAsB,cAAtB;;AAGA,MAAMJ,MAAsC,GAAG,CAAC;AAC9CK,EAAAA,KAD8C;AAE9CC,EAAAA,OAF8C;AAG9CC,EAAAA,WAH8C;AAI9CC,EAAAA,aAJ8C;AAK9CC,EAAAA,QAAQ,GAAG,KALmC;AAM9CC,EAAAA,aAAa,EAAEC,qBAAqB,GAAG,MAAM,CAAE,CAND;AAO9C,KAAGC;AAP2C,CAAD,KAQzC;AAAA;;AACJ,QAAM;AACJC,IAAAA,UAAU,EAAE;AACVC,MAAAA,YADU;AACI;AACdC,MAAAA,WAFU;AAEG;AACbC,MAAAA,cAHU;AAGM;AAChBC,MAAAA,gBAJU;AAIQ;AAClBC,MAAAA,iBALU;AAKS;AACnBC,MAAAA,eANU;AAMO;AACjBC,MAAAA,WAPU;AAOG;AACbC,MAAAA,eARU;AAQO;AACjBC,MAAAA,OATU;AASD;AACTC,MAAAA,UAVU;AAUE;AACZC,MAAAA,YAXU;AAWI;AACdC,MAAAA,aAZU;AAYK;AACfC,MAAAA,WAbU;AAaG;AACb,SAAGb;AAdO;AADR,MAiBFX,aAAa,CAACG,K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AAE,CAHA;AAILC,MAAAA,IAAI,EAAE,CAJD;AAKLC,MAAAA,KAAK,EAAE,CALF;AAMLC,MAAAA,MAAM,EAAE;AANH;AANT,KAeG5C,OAAO,CAAC6C,GAAR,CAAaC,CAAD,iBACX,oBAAC,YAAD,CAAc,IAAd;AAAmB,IAAA,KAAK,EAAEA,CAAC,CAACZ,KAA5B;AAAmC,IAAA,KAAK,EAAEY,CAAC,CAACb,KAA5C;AAAmD,IAAA,GAAG,EAAEa,CAAC,CAACb;AAA1D,IADD,CAfH,CADF,eAoBE,oBAAC,IAAD;AAAM,IAAA,aAAa,EAAC;AAApB,kBACE,oBAAC,SAAD,eACM3B,KADN;AAEE,IAAA,KAAK,EAAEwB,aAFT;AAGE,IAAA,WAAW,EAAE7B,WAHf,CAIE;AAJF;AAKE,IAAA,GAAG,EAAEoB,SALP,CAKkB;AALlB;AAME,IAAA,QAAQ,EAAElB,QANZ,CAOE;AAPF;AAQE,IAAA,KAAK,EAAEyB;AART,KADF,CApBF,CALF,CADF;AAyCD,CAlGD;;AAoGA,MAAMO,MAAM,GAAG5C,UAAU,CAACwD,MAAX,CAAkB;AAC/BX,EAAAA,SAAS,EAAE;AACTY,IAAAA,SAAS,EAAE;AADF;AADoB,CAAlB,CAAf;AAMA,eAAevD,SAAS,CAACC,MAAD,CAAxB","sourcesContent":["import * as React from \"react\";\nimport { View, StyleSheet } from \"react-native\";\nimport omit from \"lodash.omit\";\nimport { withTheme } from \"../../theming\";\nimport { Picker as NativePicker } from \"@react-native-picker/picker\";\nimport { extractStyles } from \"../../utilities\";\n\nimport TextField from \"../TextField\";\nimport Touchable from \"../Touchable\";\nimport { PickerComponentProps } from \"./PickerTypes\";\n\nconst Picker: React.FC<PickerComponentProps> = ({\n style,\n options,\n placeholder,\n selectedValue,\n disabled = false,\n onValueChange: onValueChangeOverride = () => {},\n ...props\n}) => {\n const {\n viewStyles: {\n borderRadius, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderTopWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderRightWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderBottomWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderLeftWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderColor, // eslint-disable-line @typescript-eslint/no-unused-vars\n backgroundColor, // eslint-disable-line @typescript-eslint/no-unused-vars\n padding, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingTop, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingRight, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingBottom, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingLeft, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...viewStyles\n },\n } = extractStyles(style);\n\n const textField = React.useRef<typeof TextField | undefined>(undefined);\n\n const onValueChange = (itemValue: string, itemIndex: number) => {\n toggleFocus();\n onValueChangeOverride(itemValue, itemIndex);\n };\n\n const toggleFocus = () => {\n if (!disabled) {\n // @ts-ignore\n textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()\n }\n };\n\n const stylesWithoutMargin =\n style &&\n omit(StyleSheet.flatten(style), [\n \"margin\",\n \"marginTop\",\n \"marginRight\",\n \"marginBottom\",\n \"marginLeft\",\n ]);\n\n const selectedLabel =\n selectedValue &&\n (options.find((opt) => opt.value === selectedValue)?.label ??\n selectedValue);\n\n return (\n <Touchable\n disabled={disabled}\n onPress={toggleFocus}\n style={[styles.container, viewStyles]}\n >\n <View>\n <NativePicker\n enabled={!disabled}\n selectedValue={selectedValue}\n onValueChange={(value, index) =>\n onValueChange(value.toString(), index)\n }\n style={{\n opacity: 0,\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n }}\n >\n {options.map((o) => (\n <NativePicker.Item label={o.label} value={o.value} key={o.value} />\n ))}\n </NativePicker>\n <View pointerEvents=\"none\">\n <TextField\n {...props}\n value={selectedLabel}\n placeholder={placeholder}\n // @ts-ignore\n ref={textField} // cannot determine if ref is of correct type due to component being wrapped in a withTheme()\n disabled={disabled}\n // @ts-expect-error\n style={stylesWithoutMargin}\n />\n </View>\n </View>\n </Touchable>\n );\n};\n\nconst styles = StyleSheet.create({\n container: {\n alignSelf: \"stretch\",\n },\n});\n\nexport default withTheme(Picker);\n"]}
|
|
@@ -17,6 +17,8 @@ const Picker = ({
|
|
|
17
17
|
onValueChange: onValueChangeOverride = () => {},
|
|
18
18
|
...props
|
|
19
19
|
}) => {
|
|
20
|
+
var _options$find$label, _options$find;
|
|
21
|
+
|
|
20
22
|
const {
|
|
21
23
|
viewStyles: {
|
|
22
24
|
borderRadius,
|
|
@@ -63,6 +65,7 @@ const Picker = ({
|
|
|
63
65
|
};
|
|
64
66
|
|
|
65
67
|
const stylesWithoutMargin = style && omit(StyleSheet.flatten(style), ["margin", "marginTop", "marginRight", "marginBottom", "marginLeft"]);
|
|
68
|
+
const selectedLabel = selectedValue && ((_options$find$label = (_options$find = options.find(opt => opt.value === selectedValue)) === null || _options$find === void 0 ? void 0 : _options$find.label) !== null && _options$find$label !== void 0 ? _options$find$label : selectedValue);
|
|
66
69
|
return /*#__PURE__*/React.createElement(Touchable, {
|
|
67
70
|
disabled: disabled,
|
|
68
71
|
onPress: toggleFocus,
|
|
@@ -87,7 +90,7 @@ const Picker = ({
|
|
|
87
90
|
}))), /*#__PURE__*/React.createElement(View, {
|
|
88
91
|
pointerEvents: "none"
|
|
89
92
|
}, /*#__PURE__*/React.createElement(TextField, _extends({}, props, {
|
|
90
|
-
value:
|
|
93
|
+
value: selectedLabel,
|
|
91
94
|
placeholder: placeholder // @ts-ignore
|
|
92
95
|
,
|
|
93
96
|
ref: textField // cannot determine if ref is of correct type due to component being wrapped in a withTheme()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["PickerComponent.web.tsx"],"names":["React","View","StyleSheet","Picker","NativePicker","omit","withTheme","extractStyles","TextField","Touchable","style","options","placeholder","selectedValue","disabled","onValueChange","onValueChangeOverride","props","viewStyles","borderRadius","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderColor","backgroundColor","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","textField","useRef","undefined","itemValue","itemIndex","toggleFocus","current","stylesWithoutMargin","flatten","
|
|
1
|
+
{"version":3,"sources":["PickerComponent.web.tsx"],"names":["React","View","StyleSheet","Picker","NativePicker","omit","withTheme","extractStyles","TextField","Touchable","style","options","placeholder","selectedValue","disabled","onValueChange","onValueChangeOverride","props","viewStyles","borderRadius","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderColor","backgroundColor","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","textField","useRef","undefined","itemValue","itemIndex","toggleFocus","current","stylesWithoutMargin","flatten","selectedLabel","find","opt","value","label","styles","container","index","toString","flex","opacity","position","top","left","right","bottom","map","o","create","alignSelf"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,EAAeC,UAAf,EAA2BC,MAAM,IAAIC,YAArC,QAAyD,cAAzD;AACA,OAAOC,IAAP,MAAiB,aAAjB;AACA,SAASC,SAAT,QAA0B,eAA1B;AACA,SAASC,aAAT,QAA8B,iBAA9B;AAEA,OAAOC,SAAP,MAAsB,cAAtB;AACA,OAAOC,SAAP,MAAsB,cAAtB;;AAGA,MAAMN,MAAsC,GAAG,CAAC;AAC9CO,EAAAA,KAD8C;AAE9CC,EAAAA,OAF8C;AAG9CC,EAAAA,WAH8C;AAI9CC,EAAAA,aAJ8C;AAK9CC,EAAAA,QAAQ,GAAG,KALmC;AAM9CC,EAAAA,aAAa,EAAEC,qBAAqB,GAAG,MAAM,CAAE,CAND;AAO9C,KAAGC;AAP2C,CAAD,KAQzC;AAAA;;AACJ,QAAM;AACJC,IAAAA,UAAU,EAAE;AACVC,MAAAA,YADU;AACI;AACdC,MAAAA,WAFU;AAEG;AACbC,MAA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,qBACE,oBAAC,YAAD;AACE,IAAA,OAAO,EAAE,CAACJ,QADZ;AAEE,IAAA,aAAa,EAAED,aAFjB;AAGE,IAAA,aAAa,EAAE,CAAC+B,KAAD,EAAQI,KAAR,KACbjC,aAAa,CAAC6B,KAAK,CAACK,QAAN,EAAD,EAAmBD,KAAnB,CAJjB;AAME,IAAA,KAAK,EAAE;AACLE,MAAAA,IAAI,EAAE,CADD;AAELC,MAAAA,OAAO,EAAE,CAFJ;AAGLC,MAAAA,QAAQ,EAAE,UAHL;AAILC,MAAAA,GAAG,EAAE,CAJA;AAKLC,MAAAA,IAAI,EAAE,CALD;AAMLC,MAAAA,KAAK,EAAE,CANF;AAOLC,MAAAA,MAAM,EAAE;AAPH;AANT,KAgBG7C,OAAO,CAAC8C,GAAR,CAAaC,CAAD,iBACX,oBAAC,YAAD,CAAc,IAAd;AAAmB,IAAA,KAAK,EAAEA,CAAC,CAACb,KAA5B;AAAmC,IAAA,KAAK,EAAEa,CAAC,CAACd,KAA5C;AAAmD,IAAA,GAAG,EAAEc,CAAC,CAACd;AAA1D,IADD,CAhBH,CADF,eAqBE,oBAAC,IAAD;AAAM,IAAA,aAAa,EAAC;AAApB,kBACE,oBAAC,SAAD,eACM3B,KADN;AAEE,IAAA,KAAK,EAAEwB,aAFT;AAGE,IAAA,WAAW,EAAE7B,WAHf,CAIE;AAJF;AAKE,IAAA,GAAG,EAAEoB,SALP,CAKkB;AALlB;AAME,IAAA,QAAQ,EAAElB,QANZ,CAOE;AAPF;AAQE,IAAA,KAAK,EAAEyB;AART,KADF,CArBF,CALF,CADF;AA0CD,CAnGD;;AAqGA,MAAMO,MAAM,GAAG5C,UAAU,CAACyD,MAAX,CAAkB;AAC/BZ,EAAAA,SAAS,EAAE;AACTa,IAAAA,SAAS,EAAE;AADF;AADoB,CAAlB,CAAf;AAMA,eAAetD,SAAS,CAACH,MAAD,CAAxB","sourcesContent":["import * as React from \"react\";\nimport { View, StyleSheet, Picker as NativePicker } from \"react-native\";\nimport omit from \"lodash.omit\";\nimport { withTheme } from \"../../theming\";\nimport { extractStyles } from \"../../utilities\";\n\nimport TextField from \"../TextField\";\nimport Touchable from \"../Touchable\";\nimport { PickerComponentProps } from \"./PickerTypes\";\n\nconst Picker: React.FC<PickerComponentProps> = ({\n style,\n options,\n placeholder,\n selectedValue,\n disabled = false,\n onValueChange: onValueChangeOverride = () => {},\n ...props\n}) => {\n const {\n viewStyles: {\n borderRadius, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderTopWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderRightWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderBottomWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderLeftWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderColor, // eslint-disable-line @typescript-eslint/no-unused-vars\n backgroundColor, // eslint-disable-line @typescript-eslint/no-unused-vars\n padding, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingTop, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingRight, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingBottom, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingLeft, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...viewStyles\n },\n } = extractStyles(style);\n\n const textField = React.useRef<typeof TextField | undefined>(undefined);\n\n const onValueChange = (itemValue: string, itemIndex: number) => {\n toggleFocus();\n onValueChangeOverride(itemValue, itemIndex);\n };\n\n const toggleFocus = () => {\n if (!disabled) {\n // @ts-ignore\n textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()\n }\n };\n\n const stylesWithoutMargin =\n style &&\n omit(StyleSheet.flatten(style), [\n \"margin\",\n \"marginTop\",\n \"marginRight\",\n \"marginBottom\",\n \"marginLeft\",\n ]);\n\n const selectedLabel =\n selectedValue &&\n (options.find((opt) => opt.value === selectedValue)?.label ??\n selectedValue);\n\n return (\n <Touchable\n disabled={disabled}\n onPress={toggleFocus}\n style={[styles.container, viewStyles]}\n >\n <View>\n <NativePicker\n enabled={!disabled}\n selectedValue={selectedValue}\n onValueChange={(value, index) =>\n onValueChange(value.toString(), index)\n }\n style={{\n flex: 1,\n opacity: 0,\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n }}\n >\n {options.map((o) => (\n <NativePicker.Item label={o.label} value={o.value} key={o.value} />\n ))}\n </NativePicker>\n <View pointerEvents=\"none\">\n <TextField\n {...props}\n value={selectedLabel}\n placeholder={placeholder}\n // @ts-ignore\n ref={textField} // cannot determine if ref is of correct type due to component being wrapped in a withTheme()\n disabled={disabled}\n // @ts-expect-error\n style={stylesWithoutMargin}\n />\n </View>\n </View>\n </Touchable>\n );\n};\n\nconst styles = StyleSheet.create({\n container: {\n alignSelf: \"stretch\",\n },\n});\n\nexport default withTheme(Picker);\n"]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
1
3
|
import * as React from "react";
|
|
2
4
|
import { StyleSheet, View, Platform } from "react-native";
|
|
3
5
|
import RadioButton from "./RadioButton";
|
|
@@ -7,7 +9,7 @@ import { createTextProp, createTextEnumProp, COMPONENT_TYPES, createColorProp, G
|
|
|
7
9
|
import { Direction as GroupDirection } from "./context";
|
|
8
10
|
import Touchable from "../Touchable";
|
|
9
11
|
import { extractStyles } from "../../utilities";
|
|
10
|
-
export
|
|
12
|
+
export let Direction;
|
|
11
13
|
|
|
12
14
|
(function (Direction) {
|
|
13
15
|
Direction["Row"] = "row";
|
|
@@ -65,14 +67,13 @@ const RadioButtonRow = ({
|
|
|
65
67
|
textStyles,
|
|
66
68
|
viewStyles
|
|
67
69
|
} = extractStyles(style);
|
|
68
|
-
return /*#__PURE__*/React.createElement(Touchable, {
|
|
70
|
+
return /*#__PURE__*/React.createElement(Touchable, _extends({
|
|
69
71
|
onPress: handlePress,
|
|
70
72
|
style: [styles.mainParent, {
|
|
71
73
|
flexDirection: direction
|
|
72
74
|
}, viewStyles],
|
|
73
|
-
disabled: disabled
|
|
74
|
-
|
|
75
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
75
|
+
disabled: disabled
|
|
76
|
+
}, rest), /*#__PURE__*/React.createElement(View, {
|
|
76
77
|
style: [styles.label, {
|
|
77
78
|
alignItems: direction === Direction.Row ? "flex-start" : "flex-end"
|
|
78
79
|
}, labelContainerStyle]
|
|
@@ -146,17 +147,5 @@ export const SEED_DATA = {
|
|
|
146
147
|
defaultValue: "primary"
|
|
147
148
|
})
|
|
148
149
|
}
|
|
149
|
-
};
|
|
150
|
-
//# sourceMappingURL=RadioButtonRow.js.map,
|
|
151
|
-
description: "Color for the button",
|
|
152
|
-
defaultValue: "primary"
|
|
153
|
-
}),
|
|
154
|
-
unselectedColor: createColorProp({
|
|
155
|
-
group: GROUPS.basic,
|
|
156
|
-
label: "Unselected Color",
|
|
157
|
-
description: "Unselected Color for the button",
|
|
158
|
-
defaultValue: "primary"
|
|
159
|
-
})
|
|
160
|
-
}
|
|
161
|
-
};
|
|
150
|
+
}; // TODO comment testing
|
|
162
151
|
//# sourceMappingURL=RadioButtonRow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["RadioButtonRow.
|
|
1
|
+
{"version":3,"sources":["RadioButtonRow.tsx"],"names":["React","StyleSheet","View","Platform","RadioButton","Text","useRadioButtonGroupContext","createTextProp","createTextEnumProp","COMPONENT_TYPES","createColorProp","GROUPS","Direction","GroupDirection","Touchable","extractStyles","getRadioButtonAlignment","parentDirection","direction","Horizontal","Row","RowReverse","renderLabel","value","labelStyle","textStyle","RadioButtonRow","Icon","label","color","unselectedColor","onPress","labelContainerStyle","radioButtonStyle","selected","disabled","style","rest","contextValue","onValueChange","handlePress","textStyles","viewStyles","styles","mainParent","flexDirection","alignItems","flex","create","justifyContent","paddingStart","minHeight","paddingEnd","select","web","cursor","userSelect","SEED_DATA","name","tag","category","input","layout","props","description","required","defaultValue","options","group","basic"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAGEC,UAHF,EAKEC,IALF,EAMEC,QANF,QAOO,cAPP;AAQA,OAAOC,WAAP,MAA8C,eAA9C;AACA,OAAOC,IAAP,MAAiB,SAAjB;AACA,SAASC,0BAAT,QAA2C,WAA3C;AACA,SACEC,cADF,EAEEC,kBAFF,EAGEC,eAHF,EAIEC,eAJF,EAKEC,MALF,QAMO,iBANP;AAQA,SAASC,SAAS,IAAIC,cAAtB,QAA4C,WAA5C;AACA,OAAOC,SAAP,MAAsB,cAAtB;AACA,SAASC,aAAT,QAA8B,iBAA9B;AAEA,WAAYH,SAAZ;;WAAYA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,KAAAA,S;;AAiBZ,MAAMI,uBAAuB,GAAG,CAC9BC,eAD8B,EAE9BC,SAF8B,KAG3B;AACH,MAAID,eAAe,KAAKJ,cAAc,CAACM,UAAvC,EAAmD;AACjD,WAAOD,SAAS,KAAKN,SAAS,CAACQ,GAAxB,GAA8B,YAA9B,GAA6C,UAApD;AACD,GAFD,MAEO,IAAIF,SAAS,KAAKN,SAAS,CAACS,UAA5B,EAAwC;AAC7C,WAAO,YAAP;AACD,GAFM,MAEA;AACL,WAAO,UAAP;AACD;AACF,CAXD;;AAaA,MAAMC,WAAW,GAAG,CAClBC,KADkB,EAElBC,UAFkB,EAGlBC,SAHkB,KAIf;AACH,MAAI,OAAOF,KAAP,KAAiB,QAArB,EAA+B;AAC7B,wBAAO,oBAAC,IAAD;AAAM,MAAA,KAAK,EAAE,CAACC,UAAD,EAAaC,SAAb;AAAb,OAAuCF,KAAvC,CAAP;AACD,GAFD,MAEO;AACL,wBAAO,0CAAGA,KAAH,CAAP;AACD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pBqB,MAAAA,KAAK,EAAE,OADa;AAEpBoC,MAAAA,WAAW,EAAE,qCAFO;AAGpBC,MAAAA,QAAQ,EAAE,IAHU;AAIpBC,MAAAA,YAAY,EAAE;AAJM,KAAD,CADhB;AAOLhD,IAAAA,SAAS,EAAEV,kBAAkB,CAAC;AAC5BoB,MAAAA,KAAK,EAAE,WADqB;AAE5BoC,MAAAA,WAAW,EACT,8DAH0B;AAI5BG,MAAAA,OAAO,EAAE,CAAC,KAAD,EAAQ,aAAR;AAJmB,KAAD,CAPxB;AAaL5C,IAAAA,KAAK,EAAEhB,cAAc,CAAC;AACpBqB,MAAAA,KAAK,EAAE,OADa;AAEpBoC,MAAAA,WAAW,EAAE,2BAFO;AAGpBE,MAAAA,YAAY,EAAE,IAHM;AAIpBD,MAAAA,QAAQ,EAAE;AAJU,KAAD,CAbhB;AAmBLpC,IAAAA,KAAK,EAAEnB,eAAe,CAAC;AACrB0D,MAAAA,KAAK,EAAEzD,MAAM,CAAC0D,KADO;AAErBL,MAAAA,WAAW,EAAE,sBAFQ;AAGrBE,MAAAA,YAAY,EAAE;AAHO,KAAD,CAnBjB;AAwBLpC,IAAAA,eAAe,EAAEpB,eAAe,CAAC;AAC/B0D,MAAAA,KAAK,EAAEzD,MAAM,CAAC0D,KADiB;AAE/BzC,MAAAA,KAAK,EAAE,kBAFwB;AAG/BoC,MAAAA,WAAW,EAAE,iCAHkB;AAI/BE,MAAAA,YAAY,EAAE;AAJiB,KAAD;AAxB3B;AALgB,CAAlB,C,CAqCP","sourcesContent":["import * as React from \"react\";\nimport {\n StyleProp,\n ViewStyle,\n StyleSheet,\n TextStyle,\n View,\n Platform,\n} from \"react-native\";\nimport RadioButton, { RadioButtonProps } from \"./RadioButton\";\nimport Text from \"../Text\";\nimport { useRadioButtonGroupContext } from \"./context\";\nimport {\n createTextProp,\n createTextEnumProp,\n COMPONENT_TYPES,\n createColorProp,\n GROUPS,\n} from \"@draftbit/types\";\nimport type { IconSlot } from \"../../interfaces/Icon\";\nimport { Direction as GroupDirection } from \"./context\";\nimport Touchable from \"../Touchable\";\nimport { extractStyles } from \"../../utilities\";\n\nexport enum Direction {\n Row = \"row\",\n RowReverse = \"row-reverse\",\n}\n\nexport interface RadioButtonRowProps extends Omit<RadioButtonProps, \"onPress\"> {\n label: string | React.ReactNode;\n value: string;\n color?: string;\n unselectedColor?: string;\n labelContainerStyle: StyleProp<ViewStyle>;\n radioButtonStyle?: StyleProp<ViewStyle>;\n labelStyle?: StyleProp<TextStyle>;\n onPress?: (value: string) => void;\n direction?: Direction;\n}\n\nconst getRadioButtonAlignment = (\n parentDirection: GroupDirection | undefined,\n direction: Direction\n) => {\n if (parentDirection === GroupDirection.Horizontal) {\n return direction === Direction.Row ? \"flex-start\" : \"flex-end\";\n } else if (direction === Direction.RowReverse) {\n return \"flex-start\";\n } else {\n return \"flex-end\";\n }\n};\n\nconst renderLabel = (\n value: string | React.ReactNode,\n labelStyle: StyleProp<TextStyle>,\n textStyle: StyleProp<TextStyle>\n) => {\n if (typeof value === \"string\") {\n return <Text style={[labelStyle, textStyle]}>{value}</Text>;\n } else {\n return <>{value}</>;\n }\n};\n\nconst RadioButtonRow: React.FC<RadioButtonRowProps & IconSlot> = ({\n Icon,\n label,\n value,\n color,\n unselectedColor,\n onPress = () => {},\n labelContainerStyle,\n labelStyle,\n radioButtonStyle,\n direction = Direction.Row,\n selected,\n disabled,\n style,\n ...rest\n}) => {\n const {\n value: contextValue,\n onValueChange,\n direction: parentDirection,\n } = useRadioButtonGroupContext();\n\n const handlePress = () => {\n onPress(value);\n onValueChange && onValueChange(value);\n };\n\n const { textStyles, viewStyles } = extractStyles(style);\n\n return (\n <Touchable\n onPress={handlePress}\n style={[styles.mainParent, { flexDirection: direction }, viewStyles]}\n disabled={disabled}\n {...rest}\n >\n <View\n style={[\n styles.label,\n {\n alignItems: direction === Direction.Row ? \"flex-start\" : \"flex-end\",\n },\n labelContainerStyle,\n ]}\n >\n {renderLabel(label, labelStyle, textStyles)}\n </View>\n <View\n style={{\n flex: 1,\n alignItems: getRadioButtonAlignment(parentDirection, direction),\n }}\n >\n <RadioButton\n Icon={Icon}\n selected={\n selected || (contextValue != null && contextValue === value)\n }\n color={color}\n unselectedColor={unselectedColor}\n onPress={handlePress}\n style={radioButtonStyle}\n />\n </View>\n </Touchable>\n );\n};\n\nconst styles = StyleSheet.create({\n mainParent: {\n alignItems: \"center\",\n justifyContent: \"space-around\",\n paddingStart: 20,\n minHeight: 50,\n paddingEnd: 20,\n flex: 1,\n ...Platform.select({\n web: {\n cursor: \"pointer\",\n userSelect: \"none\",\n },\n }),\n },\n label: {\n flex: 3,\n },\n});\n\nexport default RadioButtonRow;\n\nexport const SEED_DATA = {\n name: \"Radio Button Row\",\n tag: \"RadioButtonRow\",\n category: COMPONENT_TYPES.input,\n layout: {},\n props: {\n label: createTextProp({\n label: \"Label\",\n description: \"Label to show with the radio button\",\n required: true,\n defaultValue: \"First Option\",\n }),\n direction: createTextEnumProp({\n label: \"Direction\",\n description:\n \"Whether the checkbox will appear on the left or on the right\",\n options: [\"row\", \"row-reverse\"],\n }),\n value: createTextProp({\n label: \"Value\",\n description: \"Value of the radio button\",\n defaultValue: null,\n required: true,\n }),\n color: createColorProp({\n group: GROUPS.basic,\n description: \"Color for the button\",\n defaultValue: \"primary\",\n }),\n unselectedColor: createColorProp({\n group: GROUPS.basic,\n label: \"Unselected Color\",\n description: \"Unselected Color for the button\",\n defaultValue: \"primary\",\n }),\n },\n};\n// TODO comment testing\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=ResizeMode.js.
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=ResizeMode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
1
|
+
{"version":3,"sources":["ResizeMode.js"],"names":[],"mappings":"AAAA","sourcesContent":["export {};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "42.1.
|
|
3
|
+
"version": "42.1.6",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
]
|
|
94
94
|
]
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "9611e4cf53dab158a4ca26b8a048b747e35e8657"
|
|
97
97
|
}
|
|
@@ -40,6 +40,9 @@ const Picker = ({ style, options, placeholder, selectedValue, disabled = false,
|
|
|
40
40
|
"marginBottom",
|
|
41
41
|
"marginLeft",
|
|
42
42
|
]);
|
|
43
|
+
const selectedLabel = selectedValue &&
|
|
44
|
+
(options.find((opt) => opt.value === selectedValue)?.label ??
|
|
45
|
+
selectedValue);
|
|
43
46
|
return (React.createElement(Touchable, { disabled: disabled, onPress: toggleFocus, style: [styles.container, viewStyles] },
|
|
44
47
|
React.createElement(View, null,
|
|
45
48
|
React.createElement(NativePicker, { enabled: !disabled, selectedValue: selectedValue, onValueChange: (value, index) => onValueChange(value.toString(), index), style: {
|
|
@@ -51,7 +54,7 @@ const Picker = ({ style, options, placeholder, selectedValue, disabled = false,
|
|
|
51
54
|
bottom: 0,
|
|
52
55
|
} }, options.map((o) => (React.createElement(NativePicker.Item, { label: o.label, value: o.value, key: o.value })))),
|
|
53
56
|
React.createElement(View, { pointerEvents: "none" },
|
|
54
|
-
React.createElement(TextField, { ...props, value:
|
|
57
|
+
React.createElement(TextField, { ...props, value: selectedLabel, placeholder: placeholder,
|
|
55
58
|
// @ts-ignore
|
|
56
59
|
ref: textField, disabled: disabled,
|
|
57
60
|
// @ts-expect-error
|
|
@@ -61,6 +61,11 @@ const Picker: React.FC<PickerComponentProps> = ({
|
|
|
61
61
|
"marginLeft",
|
|
62
62
|
]);
|
|
63
63
|
|
|
64
|
+
const selectedLabel =
|
|
65
|
+
selectedValue &&
|
|
66
|
+
(options.find((opt) => opt.value === selectedValue)?.label ??
|
|
67
|
+
selectedValue);
|
|
68
|
+
|
|
64
69
|
return (
|
|
65
70
|
<Touchable
|
|
66
71
|
disabled={disabled}
|
|
@@ -90,7 +95,7 @@ const Picker: React.FC<PickerComponentProps> = ({
|
|
|
90
95
|
<View pointerEvents="none">
|
|
91
96
|
<TextField
|
|
92
97
|
{...props}
|
|
93
|
-
value={
|
|
98
|
+
value={selectedLabel}
|
|
94
99
|
placeholder={placeholder}
|
|
95
100
|
// @ts-ignore
|
|
96
101
|
ref={textField} // cannot determine if ref is of correct type due to component being wrapped in a withTheme()
|
|
@@ -39,6 +39,9 @@ const Picker = ({ style, options, placeholder, selectedValue, disabled = false,
|
|
|
39
39
|
"marginBottom",
|
|
40
40
|
"marginLeft",
|
|
41
41
|
]);
|
|
42
|
+
const selectedLabel = selectedValue &&
|
|
43
|
+
(options.find((opt) => opt.value === selectedValue)?.label ??
|
|
44
|
+
selectedValue);
|
|
42
45
|
return (React.createElement(Touchable, { disabled: disabled, onPress: toggleFocus, style: [styles.container, viewStyles] },
|
|
43
46
|
React.createElement(View, null,
|
|
44
47
|
React.createElement(NativePicker, { enabled: !disabled, selectedValue: selectedValue, onValueChange: (value, index) => onValueChange(value.toString(), index), style: {
|
|
@@ -51,7 +54,7 @@ const Picker = ({ style, options, placeholder, selectedValue, disabled = false,
|
|
|
51
54
|
bottom: 0,
|
|
52
55
|
} }, options.map((o) => (React.createElement(NativePicker.Item, { label: o.label, value: o.value, key: o.value })))),
|
|
53
56
|
React.createElement(View, { pointerEvents: "none" },
|
|
54
|
-
React.createElement(TextField, { ...props, value:
|
|
57
|
+
React.createElement(TextField, { ...props, value: selectedLabel, placeholder: placeholder,
|
|
55
58
|
// @ts-ignore
|
|
56
59
|
ref: textField, disabled: disabled,
|
|
57
60
|
// @ts-expect-error
|
|
@@ -60,6 +60,11 @@ const Picker: React.FC<PickerComponentProps> = ({
|
|
|
60
60
|
"marginLeft",
|
|
61
61
|
]);
|
|
62
62
|
|
|
63
|
+
const selectedLabel =
|
|
64
|
+
selectedValue &&
|
|
65
|
+
(options.find((opt) => opt.value === selectedValue)?.label ??
|
|
66
|
+
selectedValue);
|
|
67
|
+
|
|
63
68
|
return (
|
|
64
69
|
<Touchable
|
|
65
70
|
disabled={disabled}
|
|
@@ -90,7 +95,7 @@ const Picker: React.FC<PickerComponentProps> = ({
|
|
|
90
95
|
<View pointerEvents="none">
|
|
91
96
|
<TextField
|
|
92
97
|
{...props}
|
|
93
|
-
value={
|
|
98
|
+
value={selectedLabel}
|
|
94
99
|
placeholder={placeholder}
|
|
95
100
|
// @ts-ignore
|
|
96
101
|
ref={textField} // cannot determine if ref is of correct type due to component being wrapped in a withTheme()
|