@draftbit/core 42.1.3 → 42.1.6-f67332.0
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/Divider.js +18 -5
- package/lib/commonjs/components/Divider.js.map +1 -1
- 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/commonjs/components/Switch.js +4 -70
- package/lib/commonjs/components/Switch.js.map +1 -1
- package/lib/commonjs/mappings/Switch.js +79 -0
- package/lib/commonjs/mappings/Switch.js.map +1 -0
- package/lib/module/components/Accordion/AccordionItem.js +5 -18
- package/lib/module/components/Accordion/AccordionItem.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 +1 -1
- package/lib/module/components/RadioButton/RadioButtonRow.js.map +1 -1
- package/lib/module/components/Switch.js +13 -92
- package/lib/module/components/Switch.js.map +1 -1
- package/lib/module/components/Touchable.web.js.map +1 -1
- package/lib/module/mappings/Switch.js +70 -0
- package/lib/module/mappings/Switch.js.map +1 -0
- package/lib/typescript/src/components/Switch.d.ts +0 -155
- 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
- package/src/components/Switch.js +3 -72
- package/src/components/Switch.tsx +3 -83
- package/src/mappings/Switch.js +81 -0
|
@@ -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;AAK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ACwD,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,IAA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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 +1 @@
|
|
|
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,KAI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";\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":["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,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import 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,8 +1,10 @@
|
|
|
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 { Switch as NativeSwitch } from "react-native";
|
|
3
5
|
import { withTheme } from "../theming";
|
|
4
6
|
import FormRow from "./FormRow";
|
|
5
|
-
import {
|
|
7
|
+
import { RowDirection } from "@draftbit/types";
|
|
6
8
|
import { usePrevious } from "../hooks";
|
|
7
9
|
|
|
8
10
|
function Switch({
|
|
@@ -36,24 +38,23 @@ function Switch({
|
|
|
36
38
|
onValueChange && onValueChange(booleanInitialValue);
|
|
37
39
|
}
|
|
38
40
|
}, [initialValue, booleanInitialValue, previousInitialValue, setChecked, onValueChange]);
|
|
39
|
-
return /*#__PURE__*/React.createElement(NativeSwitch, {
|
|
41
|
+
return /*#__PURE__*/React.createElement(NativeSwitch, _extends({
|
|
40
42
|
value: checked,
|
|
41
43
|
disabled: disabled,
|
|
42
44
|
trackColor: {
|
|
43
45
|
false: inactiveTrackThemeColor,
|
|
44
46
|
true: activeTrackThemeColor
|
|
45
47
|
},
|
|
46
|
-
thumbColor: value ? activeThumbThemeColor : inactiveThumbThemeColor
|
|
47
|
-
|
|
48
|
+
thumbColor: value ? activeThumbThemeColor : inactiveThumbThemeColor // @ts-ignore react-native-web only
|
|
49
|
+
,
|
|
48
50
|
activeThumbColor: activeThumbThemeColor,
|
|
49
51
|
ios_backgroundColor: inactiveTrackThemeColor,
|
|
50
52
|
style: style,
|
|
51
53
|
onValueChange: bool => {
|
|
52
54
|
setChecked(bool);
|
|
53
55
|
onValueChange && onValueChange(bool);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
});
|
|
56
|
+
}
|
|
57
|
+
}, rest));
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
function Row({
|
|
@@ -76,7 +77,7 @@ function Row({
|
|
|
76
77
|
setChecked(value);
|
|
77
78
|
}
|
|
78
79
|
}, [value, checked]);
|
|
79
|
-
return /*#__PURE__*/React.createElement(FormRow, {
|
|
80
|
+
return /*#__PURE__*/React.createElement(FormRow, _extends({
|
|
80
81
|
disabled: disabled,
|
|
81
82
|
onPress: () => {
|
|
82
83
|
setChecked(!checked);
|
|
@@ -84,9 +85,8 @@ function Row({
|
|
|
84
85
|
},
|
|
85
86
|
label: label,
|
|
86
87
|
direction: direction,
|
|
87
|
-
style: style
|
|
88
|
-
|
|
89
|
-
}, /*#__PURE__*/React.createElement(Switch, {
|
|
88
|
+
style: style
|
|
89
|
+
}, rest), /*#__PURE__*/React.createElement(Switch, {
|
|
90
90
|
theme: theme,
|
|
91
91
|
value: checked,
|
|
92
92
|
disabled: disabled,
|
|
@@ -101,85 +101,6 @@ function Row({
|
|
|
101
101
|
const SwitchRow = withTheme(Row);
|
|
102
102
|
export { SwitchRow };
|
|
103
103
|
export default withTheme(Switch);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
name: "Switch",
|
|
107
|
-
tag: "Switch",
|
|
108
|
-
category: COMPONENT_TYPES.input,
|
|
109
|
-
layout: {},
|
|
110
|
-
triggers: SEED_DATA_TRIGGERS,
|
|
111
|
-
props: {
|
|
112
|
-
disabled: createBoolProp({
|
|
113
|
-
label: "Disabled",
|
|
114
|
-
description: "Boolean to handle disabling the switch"
|
|
115
|
-
}),
|
|
116
|
-
fieldName: createFieldNameProp({
|
|
117
|
-
handlerPropName: "onValueChange",
|
|
118
|
-
valuePropName: "value",
|
|
119
|
-
defaultValue: "switchValue"
|
|
120
|
-
}),
|
|
121
|
-
activeTrackColor: createColorProp({
|
|
122
|
-
label: "Active Track Color"
|
|
123
|
-
}),
|
|
124
|
-
inactiveTrackColor: createColorProp({
|
|
125
|
-
label: "Inactive Track Color"
|
|
126
|
-
}),
|
|
127
|
-
activeThumbColor: createColorProp({
|
|
128
|
-
label: "Active Thumb Color"
|
|
129
|
-
}),
|
|
130
|
-
inactiveThumbColor: createColorProp({
|
|
131
|
-
label: "Inactive Thumb Color"
|
|
132
|
-
})
|
|
133
|
-
}
|
|
134
|
-
}, {
|
|
135
|
-
name: "Switch Row",
|
|
136
|
-
tag: "SwitchRow",
|
|
137
|
-
category: COMPONENT_TYPES.input,
|
|
138
|
-
layout: {},
|
|
139
|
-
triggers: SEED_DATA_TRIGGERS,
|
|
140
|
-
props: {
|
|
141
|
-
label: createTextProp({
|
|
142
|
-
label: "Label",
|
|
143
|
-
description: "Label to show with the checkbox",
|
|
144
|
-
required: true,
|
|
145
|
-
defaultValue: "First Option"
|
|
146
|
-
}),
|
|
147
|
-
direction: createRowDirectionProp(),
|
|
148
|
-
disabled: createBoolProp({
|
|
149
|
-
label: "Disabled",
|
|
150
|
-
description: "Boolean to handle disabling the switch",
|
|
151
|
-
group: GROUPS.data
|
|
152
|
-
}),
|
|
153
|
-
fieldName: createFieldNameProp({
|
|
154
|
-
handlerPropName: "onValueChange",
|
|
155
|
-
valuePropName: "value",
|
|
156
|
-
defaultValue: "switchValue"
|
|
157
|
-
}),
|
|
158
|
-
activeTrackColor: createColorProp({
|
|
159
|
-
label: "Active Track Color"
|
|
160
|
-
}),
|
|
161
|
-
inactiveTrackColor: createColorProp({
|
|
162
|
-
label: "Inactive Track Color"
|
|
163
|
-
}),
|
|
164
|
-
activeThumbColor: createColorProp({
|
|
165
|
-
label: "Active Thumb Color"
|
|
166
|
-
}),
|
|
167
|
-
inactiveThumbColor: createColorProp({
|
|
168
|
-
label: "Inactive Thumb Color"
|
|
169
|
-
})
|
|
170
|
-
}
|
|
171
|
-
}];
|
|
172
|
-
//# sourceMappingURL=Switch.js.map: "Active Track Color"
|
|
173
|
-
}),
|
|
174
|
-
inactiveTrackColor: createColorProp({
|
|
175
|
-
label: "Inactive Track Color"
|
|
176
|
-
}),
|
|
177
|
-
activeThumbColor: createColorProp({
|
|
178
|
-
label: "Active Thumb Color"
|
|
179
|
-
}),
|
|
180
|
-
inactiveThumbColor: createColorProp({
|
|
181
|
-
label: "Inactive Thumb Color"
|
|
182
|
-
})
|
|
183
|
-
}
|
|
184
|
-
}];
|
|
104
|
+
/* README: SEED_DATA lives inside mappings/Switch.js since there were weird issues taking place with sourceMaps being
|
|
105
|
+
* generated */
|
|
185
106
|
//# sourceMappingURL=Switch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Switch.js"],"names":["React","Switch","NativeSwitch","withTheme","FormRow","COMPONENT_TYPES","GROUPS","createBoolProp","createColorProp","createFieldNameProp","createTextProp","createRowDirectionProp","RowDirection","Triggers","usePrevious","value","initialValue","disabled","onValueChange","activeTrackColor","inactiveTrackColor","activeThumbColor","inactiveThumbColor","theme","style","rest","activeTrackThemeColor","colors","primary","inactiveTrackThemeColor","activeThumbThemeColor","inactiveThumbThemeColor","checked","setChecked","useState","useEffect","booleanInitialValue","Boolean","previousInitialValue","createElement","trackColor","false","true","thumbColor","ios_backgroundColor","bool","Row","label","direction","onPress","SwitchRow","SEED_DATA_TRIGGERS","OnValueChange","SEED_DATA","name","tag","category","input","layout","triggers","props","description","fieldName","handlerPropName","valuePropName","defaultValue","required","group","data"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,MAAM,IAAIC,YAAnB,QAAwC,cAAxC;AACA,SAASC,SAAT,QAA0B,YAA1B;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,SAASC,eAAT,EAA0BC,MAA1B,EAAkCC,cAAlC,EAAkDC,eAAlD,EAAmEC,mBAAnE,EAAwFC,cAAxF,EAAwGC,sBAAxG,EAAgIC,YAAhI,EAA8IC,QAA9I,QAA+J,iBAA/J;AACA,SAASC,WAAT,QAA4B,UAA5B;;AACA,SAASb,MAAT,CAAgB;AAAEc,EAAAA,KAAK,GAAG,KAAV;AAAiBC,EAAAA,YAAjB;AAA+BC,EAAAA,QAA/B;AAAyCC,EAAAA,aAAzC;AAAwDC,EAAAA,gBAAxD;AAA0EC,EAAAA,kBAA1E;AAA8FC,EAAAA,gBAA9F;AAAgHC,EAAAA,kBAAhH;AAAo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9B;AAqBH3B,IAAAA,kBAAkB,EAAEZ,eAAe,CAAC;AAChCuC,MAAAA,KAAK,EAAE;AADyB,KAAD,CArBhC;AAwBH1B,IAAAA,gBAAgB,EAAEb,eAAe,CAAC;AAC9BuC,MAAAA,KAAK,EAAE;AADuB,KAAD,CAxB9B;AA2BHzB,IAAAA,kBAAkB,EAAEd,eAAe,CAAC;AAChCuC,MAAAA,KAAK,EAAE;AADyB,KAAD;AA3BhC;AANX,CA/BqB,CAAlB","sourcesContent":["import * as React from \"react\";\nimport { Switch as NativeSwitch, } from \"react-native\";\nimport { withTheme } from \"../theming\";\nimport FormRow from \"./FormRow\";\nimport { COMPONENT_TYPES, GROUPS, createBoolProp, createColorProp, createFieldNameProp, createTextProp, createRowDirectionProp, RowDirection, Triggers, } from \"@draftbit/types\";\nimport { usePrevious } from \"../hooks\";\nfunction Switch({ value = false, initialValue, disabled, onValueChange, activeTrackColor, inactiveTrackColor, activeThumbColor, inactiveThumbColor, theme, style, ...rest }) {\n const activeTrackThemeColor = activeTrackColor || theme.colors.primary;\n const inactiveTrackThemeColor = inactiveTrackColor || \"#EEE\";\n const activeThumbThemeColor = activeThumbColor || \"#FFF\";\n const inactiveThumbThemeColor = inactiveThumbColor || \"#FFF\";\n const [checked, setChecked] = React.useState(value);\n React.useEffect(() => {\n if (value !== checked) {\n setChecked(value);\n }\n }, [value, checked]);\n const booleanInitialValue = Boolean(initialValue);\n const previousInitialValue = usePrevious(booleanInitialValue);\n React.useEffect(() => {\n if (initialValue != null && booleanInitialValue !== previousInitialValue) {\n setChecked(booleanInitialValue);\n onValueChange && onValueChange(booleanInitialValue);\n }\n }, [\n initialValue,\n booleanInitialValue,\n previousInitialValue,\n setChecked,\n onValueChange,\n ]);\n return (React.createElement(NativeSwitch, { value: checked, disabled: disabled, trackColor: {\n false: inactiveTrackThemeColor,\n true: activeTrackThemeColor,\n }, thumbColor: value ? activeThumbThemeColor : inactiveThumbThemeColor, \n // @ts-ignore react-native-web only\n activeThumbColor: activeThumbThemeColor, ios_backgroundColor: inactiveTrackThemeColor, style: style, onValueChange: (bool) => {\n setChecked(bool);\n onValueChange && onValueChange(bool);\n }, ...rest }));\n}\nfunction Row({ label = \"Label\", direction = RowDirection.Row, style, value = false, disabled, onValueChange, activeTrackColor, inactiveTrackColor, activeThumbColor, inactiveThumbColor, theme, ...rest }) {\n const [checked, setChecked] = React.useState(value);\n React.useEffect(() => {\n if (value !== checked) {\n setChecked(value);\n }\n }, [value, checked]);\n return (React.createElement(FormRow, { disabled: disabled, onPress: () => {\n setChecked(!checked);\n onValueChange && onValueChange(!checked);\n }, label: label, direction: direction, style: style, ...rest },\n React.createElement(Switch, { theme: theme, value: checked, disabled: disabled, onValueChange: onValueChange, activeTrackColor: activeTrackColor, inactiveTrackColor: inactiveTrackColor, activeThumbColor: activeThumbColor, inactiveThumbColor: inactiveThumbColor })));\n}\nconst SwitchRow = withTheme(Row);\nexport { SwitchRow };\nexport default withTheme(Switch);\nconst SEED_DATA_TRIGGERS = [Triggers.OnValueChange];\nexport const SEED_DATA = [\n {\n name: \"Switch\",\n tag: \"Switch\",\n category: COMPONENT_TYPES.input,\n layout: {},\n triggers: SEED_DATA_TRIGGERS,\n props: {\n disabled: createBoolProp({\n label: \"Disabled\",\n description: \"Boolean to handle disabling the switch\",\n }),\n fieldName: createFieldNameProp({\n handlerPropName: \"onValueChange\",\n valuePropName: \"value\",\n defaultValue: \"switchValue\",\n }),\n activeTrackColor: createColorProp({\n label: \"Active Track Color\",\n }),\n inactiveTrackColor: createColorProp({\n label: \"Inactive Track Color\",\n }),\n activeThumbColor: createColorProp({\n label: \"Active Thumb Color\",\n }),\n inactiveThumbColor: createColorProp({\n label: \"Inactive Thumb Color\",\n }),\n },\n },\n {\n name: \"Switch Row\",\n tag: \"SwitchRow\",\n category: COMPONENT_TYPES.input,\n layout: {},\n triggers: SEED_DATA_TRIGGERS,\n props: {\n label: createTextProp({\n label: \"Label\",\n description: \"Label to show with the checkbox\",\n required: true,\n defaultValue: \"First Option\",\n }),\n direction: createRowDirectionProp(),\n disabled: createBoolProp({\n label: \"Disabled\",\n description: \"Boolean to handle disabling the switch\",\n group: GROUPS.data,\n }),\n fieldName: createFieldNameProp({\n handlerPropName: \"onValueChange\",\n valuePropName: \"value\",\n defaultValue: \"switchValue\",\n }),\n activeTrackColor: createColorProp({\n label: \"Active Track Color\",\n }),\n inactiveTrackColor: createColorProp({\n label: \"Inactive Track Color\",\n }),\n activeThumbColor: createColorProp({\n label: \"Active Thumb Color\",\n }),\n inactiveThumbColor: createColorProp({\n label: \"Inactive Thumb Color\",\n }),\n },\n },\n];\n"]}
|
|
1
|
+
{"version":3,"sources":["Switch.tsx"],"names":["React","Switch","NativeSwitch","withTheme","FormRow","RowDirection","usePrevious","value","initialValue","disabled","onValueChange","activeTrackColor","inactiveTrackColor","activeThumbColor","inactiveThumbColor","theme","style","rest","activeTrackThemeColor","colors","primary","inactiveTrackThemeColor","activeThumbThemeColor","inactiveThumbThemeColor","checked","setChecked","useState","useEffect","booleanInitialValue","Boolean","previousInitialValue","false","true","bool","Row","label","direction","SwitchRow"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,MAAM,IAAIC,YADZ,QAKO,cALP;AAMA,SAASC,SAAT,QAA0B,YAA1B;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,SAASC,YAAT,QAA6B,iBAA7B;AAEA,SAASC,WAAT,QAA4B,UAA5B;;AAcA,SAASL,MAAT,CAAgB;AACdM,EAAAA,KAAK,GAAG,KADM;AAEdC,EAAAA,YAFc;AAGdC,EAAAA,QAHc;AAIdC,EAAAA,aAJc;AAKdC,EAAAA,gBALc;AAMdC,EAAAA,kBANc;AAOdC,EAAAA,gBAPc;AAQdC,EAAAA,kBARc;AASdC,EAAAA,KATc;AAUdC,EAAAA,KAVc;AAWd,KAAGC;AAXW,CAAhB,EAYU;AACR,QAAMC,qBAAqB,GAAGP,gBAAgB,IAAII,KAAK,CAACI,M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EAAEC,gBALpB;AAME,IAAA,kBAAkB,EAAEC,kBANtB;AAOE,IAAA,gBAAgB,EAAEC,gBAPpB;AAQE,IAAA,kBAAkB,EAAEC;AARtB,IAXF,CADF;AAwBD;;AAED,MAAMuB,SAAS,GAAGlC,SAAS,CAAC+B,GAAD,CAA3B;AACA,SAASG,SAAT;AACA,eAAelC,SAAS,CAACF,MAAD,CAAxB;AAEA;AACA","sourcesContent":["import * as React from \"react\";\nimport {\n Switch as NativeSwitch,\n SwitchProps,\n StyleProp,\n ViewStyle,\n} from \"react-native\";\nimport { withTheme } from \"../theming\";\nimport FormRow from \"./FormRow\";\nimport { RowDirection } from \"@draftbit/types\";\nimport type { Theme } from \"../styles/DefaultTheme\";\nimport { usePrevious } from \"../hooks\";\n\ntype Props = {\n value: boolean;\n disabled?: boolean;\n onValueChange?: (value: boolean) => void;\n initialValue?: boolean;\n theme: Theme;\n activeTrackColor: string;\n inactiveTrackColor: string;\n activeThumbColor: string;\n inactiveThumbColor: string;\n} & SwitchProps;\n\nfunction Switch({\n value = false,\n initialValue,\n disabled,\n onValueChange,\n activeTrackColor,\n inactiveTrackColor,\n activeThumbColor,\n inactiveThumbColor,\n theme,\n style,\n ...rest\n}: Props) {\n const activeTrackThemeColor = activeTrackColor || theme.colors.primary;\n const inactiveTrackThemeColor = inactiveTrackColor || \"#EEE\";\n\n const activeThumbThemeColor = activeThumbColor || \"#FFF\";\n const inactiveThumbThemeColor = inactiveThumbColor || \"#FFF\";\n\n const [checked, setChecked] = React.useState(value);\n React.useEffect(() => {\n if (value !== checked) {\n setChecked(value);\n }\n }, [value, checked]);\n\n const booleanInitialValue = Boolean(initialValue);\n const previousInitialValue = usePrevious(booleanInitialValue);\n\n React.useEffect(() => {\n if (initialValue != null && booleanInitialValue !== previousInitialValue) {\n setChecked(booleanInitialValue);\n onValueChange && onValueChange(booleanInitialValue);\n }\n }, [\n initialValue,\n booleanInitialValue,\n previousInitialValue,\n setChecked,\n onValueChange,\n ]);\n\n return (\n <NativeSwitch\n value={checked}\n disabled={disabled}\n trackColor={{\n false: inactiveTrackThemeColor,\n true: activeTrackThemeColor,\n }}\n thumbColor={value ? activeThumbThemeColor : inactiveThumbThemeColor}\n // @ts-ignore react-native-web only\n activeThumbColor={activeThumbThemeColor}\n ios_backgroundColor={inactiveTrackThemeColor}\n style={style}\n onValueChange={(bool) => {\n setChecked(bool);\n onValueChange && onValueChange(bool);\n }}\n {...rest}\n />\n );\n}\n\ntype RowProps = {\n label: string;\n direction: RowDirection;\n style?: StyleProp<ViewStyle>;\n};\n\nfunction Row({\n label = \"Label\",\n direction = RowDirection.Row,\n style,\n value = false,\n disabled,\n onValueChange,\n activeTrackColor,\n inactiveTrackColor,\n activeThumbColor,\n inactiveThumbColor,\n theme,\n ...rest\n}: Props & RowProps) {\n const [checked, setChecked] = React.useState(value);\n\n React.useEffect(() => {\n if (value !== checked) {\n setChecked(value);\n }\n }, [value, checked]);\n\n return (\n <FormRow\n disabled={disabled}\n onPress={() => {\n setChecked(!checked);\n onValueChange && onValueChange(!checked);\n }}\n label={label}\n direction={direction}\n style={style}\n {...rest}\n >\n <Switch\n theme={theme}\n value={checked}\n disabled={disabled}\n onValueChange={onValueChange}\n activeTrackColor={activeTrackColor}\n inactiveTrackColor={inactiveTrackColor}\n activeThumbColor={activeThumbColor}\n inactiveThumbColor={inactiveThumbColor}\n />\n </FormRow>\n );\n}\n\nconst SwitchRow = withTheme(Row);\nexport { SwitchRow };\nexport default withTheme(Switch);\n\n/* README: SEED_DATA lives inside mappings/Switch.js since there were weird issues taking place with sourceMaps being\n * generated */\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Touchable.web.
|
|
1
|
+
{"version":3,"sources":["Touchable.web.tsx"],"names":["TouchableOpacity"],"mappings":"AAAA,SAASA,gBAAT,QAAiC,cAAjC;AAEA,eAAeA,gBAAf","sourcesContent":["import { TouchableOpacity } from \"react-native\";\n\nexport default TouchableOpacity;\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { COMPONENT_TYPES, GROUPS, createBoolProp, createColorProp, createFieldNameProp, createTextProp, createRowDirectionProp, Triggers } from "@draftbit/types";
|
|
2
|
+
const SEED_DATA_TRIGGERS = [Triggers.OnValueChange];
|
|
3
|
+
export const SEED_DATA = [{
|
|
4
|
+
name: "Switch",
|
|
5
|
+
tag: "Switch",
|
|
6
|
+
category: COMPONENT_TYPES.input,
|
|
7
|
+
layout: {},
|
|
8
|
+
triggers: SEED_DATA_TRIGGERS,
|
|
9
|
+
props: {
|
|
10
|
+
disabled: createBoolProp({
|
|
11
|
+
label: "Disabled",
|
|
12
|
+
description: "Boolean to handle disabling the switch"
|
|
13
|
+
}),
|
|
14
|
+
fieldName: createFieldNameProp({
|
|
15
|
+
handlerPropName: "onValueChange",
|
|
16
|
+
valuePropName: "value",
|
|
17
|
+
defaultValue: "switchValue"
|
|
18
|
+
}),
|
|
19
|
+
activeTrackColor: createColorProp({
|
|
20
|
+
label: "Active Track Color"
|
|
21
|
+
}),
|
|
22
|
+
inactiveTrackColor: createColorProp({
|
|
23
|
+
label: "Inactive Track Color"
|
|
24
|
+
}),
|
|
25
|
+
activeThumbColor: createColorProp({
|
|
26
|
+
label: "Active Thumb Color"
|
|
27
|
+
}),
|
|
28
|
+
inactiveThumbColor: createColorProp({
|
|
29
|
+
label: "Inactive Thumb Color"
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
name: "Switch Row",
|
|
34
|
+
tag: "SwitchRow",
|
|
35
|
+
category: COMPONENT_TYPES.input,
|
|
36
|
+
layout: {},
|
|
37
|
+
triggers: SEED_DATA_TRIGGERS,
|
|
38
|
+
props: {
|
|
39
|
+
label: createTextProp({
|
|
40
|
+
label: "Label",
|
|
41
|
+
description: "Label to show with the checkbox",
|
|
42
|
+
required: true,
|
|
43
|
+
defaultValue: "First Option"
|
|
44
|
+
}),
|
|
45
|
+
direction: createRowDirectionProp(),
|
|
46
|
+
disabled: createBoolProp({
|
|
47
|
+
label: "Disabled",
|
|
48
|
+
description: "Boolean to handle disabling the switch",
|
|
49
|
+
group: GROUPS.data
|
|
50
|
+
}),
|
|
51
|
+
fieldName: createFieldNameProp({
|
|
52
|
+
handlerPropName: "onValueChange",
|
|
53
|
+
valuePropName: "value",
|
|
54
|
+
defaultValue: "switchValue"
|
|
55
|
+
}),
|
|
56
|
+
activeTrackColor: createColorProp({
|
|
57
|
+
label: "Active Track Color"
|
|
58
|
+
}),
|
|
59
|
+
inactiveTrackColor: createColorProp({
|
|
60
|
+
label: "Inactive Track Color"
|
|
61
|
+
}),
|
|
62
|
+
activeThumbColor: createColorProp({
|
|
63
|
+
label: "Active Thumb Color"
|
|
64
|
+
}),
|
|
65
|
+
inactiveThumbColor: createColorProp({
|
|
66
|
+
label: "Inactive Thumb Color"
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
}];
|
|
70
|
+
//# sourceMappingURL=Switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["Switch.js"],"names":["COMPONENT_TYPES","GROUPS","createBoolProp","createColorProp","createFieldNameProp","createTextProp","createRowDirectionProp","Triggers","SEED_DATA_TRIGGERS","OnValueChange","SEED_DATA","name","tag","category","input","layout","triggers","props","disabled","label","description","fieldName","handlerPropName","valuePropName","defaultValue","activeTrackColor","inactiveTrackColor","activeThumbColor","inactiveThumbColor","required","direction","group","data"],"mappings":"AAAA,SACEA,eADF,EAEEC,MAFF,EAGEC,cAHF,EAIEC,eAJF,EAKEC,mBALF,EAMEC,cANF,EAOEC,sBAPF,EAQEC,QARF,QASO,iBATP;AAUA,MAAMC,kBAAkB,GAAG,CAACD,QAAQ,CAACE,aAAV,CAA3B;AACA,OAAO,MAAMC,SAAS,GAAG,CACvB;AACEC,EAAAA,IAAI,EAAE,QADR;AAEEC,EAAAA,GAAG,EAAE,QAFP;AAGEC,EAAAA,QAAQ,EAAEb,eAAe,CAACc,KAH5B;AAIEC,EA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A,KAAK,EAAE,UADgB;AAEvBC,MAAAA,WAAW,EAAE,wCAFU;AAGvBW,MAAAA,KAAK,EAAE9B,MAAM,CAAC+B;AAHS,KAAD,CARnB;AAaLX,IAAAA,SAAS,EAAEjB,mBAAmB,CAAC;AAC7BkB,MAAAA,eAAe,EAAE,eADY;AAE7BC,MAAAA,aAAa,EAAE,OAFc;AAG7BC,MAAAA,YAAY,EAAE;AAHe,KAAD,CAbzB;AAkBLC,IAAAA,gBAAgB,EAAEtB,eAAe,CAAC;AAChCgB,MAAAA,KAAK,EAAE;AADyB,KAAD,CAlB5B;AAqBLO,IAAAA,kBAAkB,EAAEvB,eAAe,CAAC;AAClCgB,MAAAA,KAAK,EAAE;AAD2B,KAAD,CArB9B;AAwBLQ,IAAAA,gBAAgB,EAAExB,eAAe,CAAC;AAChCgB,MAAAA,KAAK,EAAE;AADyB,KAAD,CAxB5B;AA2BLS,IAAAA,kBAAkB,EAAEzB,eAAe,CAAC;AAClCgB,MAAAA,KAAK,EAAE;AAD2B,KAAD;AA3B9B;AANT,CA/BuB,CAAlB","sourcesContent":["import {\n COMPONENT_TYPES,\n GROUPS,\n createBoolProp,\n createColorProp,\n createFieldNameProp,\n createTextProp,\n createRowDirectionProp,\n Triggers,\n} from \"@draftbit/types\";\nconst SEED_DATA_TRIGGERS = [Triggers.OnValueChange];\nexport const SEED_DATA = [\n {\n name: \"Switch\",\n tag: \"Switch\",\n category: COMPONENT_TYPES.input,\n layout: {},\n triggers: SEED_DATA_TRIGGERS,\n props: {\n disabled: createBoolProp({\n label: \"Disabled\",\n description: \"Boolean to handle disabling the switch\",\n }),\n fieldName: createFieldNameProp({\n handlerPropName: \"onValueChange\",\n valuePropName: \"value\",\n defaultValue: \"switchValue\",\n }),\n activeTrackColor: createColorProp({\n label: \"Active Track Color\",\n }),\n inactiveTrackColor: createColorProp({\n label: \"Inactive Track Color\",\n }),\n activeThumbColor: createColorProp({\n label: \"Active Thumb Color\",\n }),\n inactiveThumbColor: createColorProp({\n label: \"Inactive Thumb Color\",\n }),\n },\n },\n {\n name: \"Switch Row\",\n tag: \"SwitchRow\",\n category: COMPONENT_TYPES.input,\n layout: {},\n triggers: SEED_DATA_TRIGGERS,\n props: {\n label: createTextProp({\n label: \"Label\",\n description: \"Label to show with the checkbox\",\n required: true,\n defaultValue: \"First Option\",\n }),\n direction: createRowDirectionProp(),\n disabled: createBoolProp({\n label: \"Disabled\",\n description: \"Boolean to handle disabling the switch\",\n group: GROUPS.data,\n }),\n fieldName: createFieldNameProp({\n handlerPropName: \"onValueChange\",\n valuePropName: \"value\",\n defaultValue: \"switchValue\",\n }),\n activeTrackColor: createColorProp({\n label: \"Active Track Color\",\n }),\n inactiveTrackColor: createColorProp({\n label: \"Inactive Track Color\",\n }),\n activeThumbColor: createColorProp({\n label: \"Active Thumb Color\",\n }),\n inactiveThumbColor: createColorProp({\n label: \"Inactive Thumb Color\",\n }),\n },\n },\n];\n"]}
|
|
@@ -3064,158 +3064,3 @@ declare const _default: React.ComponentType<import("@draftbit/react-theme-provid
|
|
|
3064
3064
|
inactiveThumbColor: string;
|
|
3065
3065
|
} & SwitchProps> & typeof Switch, {}>;
|
|
3066
3066
|
export default _default;
|
|
3067
|
-
export declare const SEED_DATA: ({
|
|
3068
|
-
name: string;
|
|
3069
|
-
tag: string;
|
|
3070
|
-
category: string;
|
|
3071
|
-
layout: {};
|
|
3072
|
-
triggers: string[];
|
|
3073
|
-
props: {
|
|
3074
|
-
disabled: {
|
|
3075
|
-
label: string;
|
|
3076
|
-
description: string;
|
|
3077
|
-
formType: string;
|
|
3078
|
-
propType: string;
|
|
3079
|
-
defaultValue: boolean;
|
|
3080
|
-
editable: boolean;
|
|
3081
|
-
required: boolean;
|
|
3082
|
-
group: string;
|
|
3083
|
-
};
|
|
3084
|
-
fieldName: {
|
|
3085
|
-
handlerPropName: string;
|
|
3086
|
-
group: string;
|
|
3087
|
-
label: string;
|
|
3088
|
-
description: string;
|
|
3089
|
-
formType: string;
|
|
3090
|
-
propType: string;
|
|
3091
|
-
defaultValue: string;
|
|
3092
|
-
valuePropName: string;
|
|
3093
|
-
editable: boolean;
|
|
3094
|
-
required: boolean;
|
|
3095
|
-
};
|
|
3096
|
-
activeTrackColor: {
|
|
3097
|
-
group: string;
|
|
3098
|
-
label: string;
|
|
3099
|
-
description: string;
|
|
3100
|
-
editable: boolean;
|
|
3101
|
-
required: boolean;
|
|
3102
|
-
defaultValue: null;
|
|
3103
|
-
formType: string;
|
|
3104
|
-
propType: string;
|
|
3105
|
-
};
|
|
3106
|
-
inactiveTrackColor: {
|
|
3107
|
-
group: string;
|
|
3108
|
-
label: string;
|
|
3109
|
-
description: string;
|
|
3110
|
-
editable: boolean;
|
|
3111
|
-
required: boolean;
|
|
3112
|
-
defaultValue: null;
|
|
3113
|
-
formType: string;
|
|
3114
|
-
propType: string;
|
|
3115
|
-
};
|
|
3116
|
-
activeThumbColor: {
|
|
3117
|
-
group: string;
|
|
3118
|
-
label: string;
|
|
3119
|
-
description: string;
|
|
3120
|
-
editable: boolean;
|
|
3121
|
-
required: boolean;
|
|
3122
|
-
defaultValue: null;
|
|
3123
|
-
formType: string;
|
|
3124
|
-
propType: string;
|
|
3125
|
-
};
|
|
3126
|
-
inactiveThumbColor: {
|
|
3127
|
-
group: string;
|
|
3128
|
-
label: string;
|
|
3129
|
-
description: string;
|
|
3130
|
-
editable: boolean;
|
|
3131
|
-
required: boolean;
|
|
3132
|
-
defaultValue: null;
|
|
3133
|
-
formType: string;
|
|
3134
|
-
propType: string;
|
|
3135
|
-
};
|
|
3136
|
-
label?: undefined;
|
|
3137
|
-
direction?: undefined;
|
|
3138
|
-
};
|
|
3139
|
-
} | {
|
|
3140
|
-
name: string;
|
|
3141
|
-
tag: string;
|
|
3142
|
-
category: string;
|
|
3143
|
-
layout: {};
|
|
3144
|
-
triggers: string[];
|
|
3145
|
-
props: {
|
|
3146
|
-
label: any;
|
|
3147
|
-
direction: {
|
|
3148
|
-
group: string;
|
|
3149
|
-
label: string;
|
|
3150
|
-
description: string;
|
|
3151
|
-
editable: boolean;
|
|
3152
|
-
required: boolean;
|
|
3153
|
-
formType: string;
|
|
3154
|
-
propType: string;
|
|
3155
|
-
defaultValue: null;
|
|
3156
|
-
options: never[];
|
|
3157
|
-
};
|
|
3158
|
-
disabled: {
|
|
3159
|
-
label: string;
|
|
3160
|
-
description: string;
|
|
3161
|
-
formType: string;
|
|
3162
|
-
propType: string;
|
|
3163
|
-
defaultValue: boolean;
|
|
3164
|
-
editable: boolean;
|
|
3165
|
-
required: boolean;
|
|
3166
|
-
group: string;
|
|
3167
|
-
};
|
|
3168
|
-
fieldName: {
|
|
3169
|
-
handlerPropName: string;
|
|
3170
|
-
group: string;
|
|
3171
|
-
label: string;
|
|
3172
|
-
description: string;
|
|
3173
|
-
formType: string;
|
|
3174
|
-
propType: string;
|
|
3175
|
-
defaultValue: string;
|
|
3176
|
-
valuePropName: string;
|
|
3177
|
-
editable: boolean;
|
|
3178
|
-
required: boolean;
|
|
3179
|
-
};
|
|
3180
|
-
activeTrackColor: {
|
|
3181
|
-
group: string;
|
|
3182
|
-
label: string;
|
|
3183
|
-
description: string;
|
|
3184
|
-
editable: boolean;
|
|
3185
|
-
required: boolean;
|
|
3186
|
-
defaultValue: null;
|
|
3187
|
-
formType: string;
|
|
3188
|
-
propType: string;
|
|
3189
|
-
};
|
|
3190
|
-
inactiveTrackColor: {
|
|
3191
|
-
group: string;
|
|
3192
|
-
label: string;
|
|
3193
|
-
description: string;
|
|
3194
|
-
editable: boolean;
|
|
3195
|
-
required: boolean;
|
|
3196
|
-
defaultValue: null;
|
|
3197
|
-
formType: string;
|
|
3198
|
-
propType: string;
|
|
3199
|
-
};
|
|
3200
|
-
activeThumbColor: {
|
|
3201
|
-
group: string;
|
|
3202
|
-
label: string;
|
|
3203
|
-
description: string;
|
|
3204
|
-
editable: boolean;
|
|
3205
|
-
required: boolean;
|
|
3206
|
-
defaultValue: null;
|
|
3207
|
-
formType: string;
|
|
3208
|
-
propType: string;
|
|
3209
|
-
};
|
|
3210
|
-
inactiveThumbColor: {
|
|
3211
|
-
group: string;
|
|
3212
|
-
label: string;
|
|
3213
|
-
description: string;
|
|
3214
|
-
editable: boolean;
|
|
3215
|
-
required: boolean;
|
|
3216
|
-
defaultValue: null;
|
|
3217
|
-
formType: string;
|
|
3218
|
-
propType: string;
|
|
3219
|
-
};
|
|
3220
|
-
};
|
|
3221
|
-
})[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "42.1.
|
|
3
|
+
"version": "42.1.6-f67332.0+f6733247",
|
|
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": "f6733247325d3a764e1ac1dad243af39c3757a51"
|
|
97
97
|
}
|