@draftbit/core 42.4.6-1ce8ff.0 → 42.4.6-7e6a42.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/Checkbox/Checkbox.js +6 -27
- package/lib/commonjs/components/Checkbox/Checkbox.js.map +1 -1
- package/lib/commonjs/components/Checkbox/CheckboxRow.js +7 -13
- package/lib/commonjs/components/Checkbox/CheckboxRow.js.map +1 -1
- package/lib/commonjs/components/Switch.js +2 -1
- package/lib/commonjs/components/Switch.js.map +1 -1
- package/lib/commonjs/index.js +0 -20
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mappings/Checkbox.js +0 -11
- package/lib/commonjs/mappings/Checkbox.js.map +1 -1
- package/lib/module/components/Checkbox/Checkbox.js +5 -24
- package/lib/module/components/Checkbox/Checkbox.js.map +1 -1
- package/lib/module/components/Checkbox/CheckboxRow.js +7 -13
- package/lib/module/components/Checkbox/CheckboxRow.js.map +1 -1
- package/lib/module/components/Switch.js +2 -1
- package/lib/module/components/Switch.js.map +1 -1
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/mappings/Checkbox.js +0 -11
- package/lib/module/mappings/Checkbox.js.map +1 -1
- package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +2 -9
- package/lib/typescript/src/components/Checkbox/CheckboxRow.d.ts +1 -12
- package/lib/typescript/src/components/Switch.d.ts +1 -1
- package/lib/typescript/src/index.d.ts +0 -1
- package/package.json +2 -4
- package/src/components/Checkbox/Checkbox.js +8 -24
- package/src/components/Checkbox/Checkbox.tsx +10 -34
- package/src/components/Checkbox/CheckboxRow.js +7 -13
- package/src/components/Checkbox/CheckboxRow.tsx +8 -19
- package/src/components/Switch.js +2 -2
- package/src/components/Switch.tsx +2 -1
- package/src/index.js +0 -1
- package/src/index.tsx +0 -1
- package/src/mappings/Checkbox.js +0 -11
- package/lib/commonjs/components/MapView/MapCallout.native.js +0 -47
- package/lib/commonjs/components/MapView/MapCallout.native.js.map +0 -1
- package/lib/commonjs/components/MapView/MapCallout.web.js +0 -47
- package/lib/commonjs/components/MapView/MapCallout.web.js.map +0 -1
- package/lib/commonjs/components/MapView/MapMarker.native.js +0 -86
- package/lib/commonjs/components/MapView/MapMarker.native.js.map +0 -1
- package/lib/commonjs/components/MapView/MapMarker.web.js +0 -116
- package/lib/commonjs/components/MapView/MapMarker.web.js.map +0 -1
- package/lib/commonjs/components/MapView/MapView.native.js +0 -162
- package/lib/commonjs/components/MapView/MapView.native.js.map +0 -1
- package/lib/commonjs/components/MapView/MapView.web.js +0 -55
- package/lib/commonjs/components/MapView/MapView.web.js.map +0 -1
- package/lib/commonjs/components/MapView/NoApiKey.js +0 -20
- package/lib/commonjs/components/MapView/NoApiKey.js.map +0 -1
- package/lib/commonjs/components/MapView/index.js +0 -32
- package/lib/commonjs/components/MapView/index.js.map +0 -1
- package/lib/commonjs/components/MapView/types.js +0 -5
- package/lib/commonjs/components/MapView/types.js.map +0 -1
- package/lib/module/components/MapView/MapCallout.native.js +0 -32
- package/lib/module/components/MapView/MapCallout.native.js.map +0 -1
- package/lib/module/components/MapView/MapCallout.web.js +0 -32
- package/lib/module/components/MapView/MapCallout.web.js.map +0 -1
- package/lib/module/components/MapView/MapMarker.native.js +0 -71
- package/lib/module/components/MapView/MapMarker.native.js.map +0 -1
- package/lib/module/components/MapView/MapMarker.web.js +0 -96
- package/lib/module/components/MapView/MapMarker.web.js.map +0 -1
- package/lib/module/components/MapView/MapView.native.js +0 -144
- package/lib/module/components/MapView/MapView.native.js.map +0 -1
- package/lib/module/components/MapView/MapView.web.js +0 -38
- package/lib/module/components/MapView/MapView.web.js.map +0 -1
- package/lib/module/components/MapView/NoApiKey.js +0 -7
- package/lib/module/components/MapView/NoApiKey.js.map +0 -1
- package/lib/module/components/MapView/index.js +0 -7
- package/lib/module/components/MapView/index.js.map +0 -1
- package/lib/module/components/MapView/types.js +0 -2
- package/lib/module/components/MapView/types.js.map +0 -1
- package/lib/typescript/src/components/MapView/MapCallout.native.d.ts +0 -33
- package/lib/typescript/src/components/MapView/MapCallout.web.d.ts +0 -4
- package/lib/typescript/src/components/MapView/MapMarker.native.d.ts +0 -57
- package/lib/typescript/src/components/MapView/MapMarker.web.d.ts +0 -12
- package/lib/typescript/src/components/MapView/MapView.native.d.ts +0 -130
- package/lib/typescript/src/components/MapView/MapView.web.d.ts +0 -4
- package/lib/typescript/src/components/MapView/NoApiKey.d.ts +0 -2
- package/lib/typescript/src/components/MapView/index.d.ts +0 -3
- package/lib/typescript/src/components/MapView/types.d.ts +0 -35
- package/src/components/MapView/MapCallout.native.js +0 -22
- package/src/components/MapView/MapCallout.native.tsx +0 -40
- package/src/components/MapView/MapCallout.web.js +0 -14
- package/src/components/MapView/MapCallout.web.tsx +0 -31
- package/src/components/MapView/MapMarker.native.js +0 -52
- package/src/components/MapView/MapMarker.native.tsx +0 -83
- package/src/components/MapView/MapMarker.web.js +0 -68
- package/src/components/MapView/MapMarker.web.tsx +0 -105
- package/src/components/MapView/MapView.native.js +0 -118
- package/src/components/MapView/MapView.native.tsx +0 -163
- package/src/components/MapView/MapView.web.js +0 -18
- package/src/components/MapView/MapView.web.tsx +0 -42
- package/src/components/MapView/NoApiKey.js +0 -5
- package/src/components/MapView/NoApiKey.tsx +0 -10
- package/src/components/MapView/index.js +0 -6
- package/src/components/MapView/index.tsx +0 -6
- package/src/components/MapView/types.js +0 -1
- package/src/components/MapView/types.tsx +0 -38
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CheckboxRow.tsx"],"names":["React","StyleSheet","View","Platform","Checkbox","CheckboxStatus","Text","useCheckboxGroupContext","createTextProp","createTextStyle","createRowDirectionProp","createFieldNameProp","COMPONENT_TYPES","Triggers","createColorProp","Direction","GroupDirection","Touchable","extractStyles","getCheckboxAlignment","parentDirection","direction","Horizontal","Row","RowReverse","renderLabel","value","labelStyle","textStyle","CheckboxRow","Icon","label","onPress","labelContainerStyle","checkboxStyle","status","disabled","style","color","uncheckedColor","indeterminateColor","rest","values","selectedValues","onValueChange","Array","isArray","isChecked","Checked","includes","handlePress","textStyles","viewStyles","styles","mainParent","flexDirection","alignItems","flex","Unchecked","create","justifyContent","paddingStart","minHeight","paddingEnd","select","web","cursor","userSelect","SEED_DATA","name","tag","category","input","layout","triggers","OnPress","props","description","required","defaultValue","editable","fieldName","valuePropName","handlerPropName"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAGEC,UAHF,EAKEC,IALF,EAMEC,QANF,QAOO,cAPP;AAQA,OAAOC,QAAP,IAAkCC,cAAlC,QAAwD,YAAxD;AACA,OAAOC,IAAP,MAAiB,SAAjB;AACA,SAASC,uBAAT,QAAwC,WAAxC;AACA,SACEC,cADF,EAEEC,eAFF,EAGEC,sBAHF,EAIEC,mBAJF,EAKEC,eALF,EAMEC,QANF,EAOEC,eAPF,QAQO,iBARP;AAUA,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;;AAkBZ,MAAMI,oBAAoB,GAAG,CAC3BC,eAD2B,EAE3BC,SAF2B,KAGxB;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;AA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IAAAA,KAAK,EAAExB,eAAe,CAAC;AACrB+D,MAAAA,WAAW,EAAE;AADQ,KAAD,CAnBjB;AAsBLtC,IAAAA,cAAc,EAAEzB,eAAe,CAAC;AAC9BiB,MAAAA,KAAK,EAAE,kBADuB;AAE9B8C,MAAAA,WAAW,EAAE;AAFiB,KAAD,CAtB1B;AA0BLrC,IAAAA,kBAAkB,EAAE1B,eAAe,CAAC;AAClCiB,MAAAA,KAAK,EAAE,qBAD2B;AAElC8C,MAAAA,WAAW,EAAE;AAFqB,KAAD;AA1B9B;AARgB,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 Checkbox, { CheckboxProps, CheckboxStatus } from \"./Checkbox\";\nimport Text from \"../Text\";\nimport { useCheckboxGroupContext } from \"./context\";\nimport {\n createTextProp,\n createTextStyle,\n createRowDirectionProp,\n createFieldNameProp,\n COMPONENT_TYPES,\n Triggers,\n createColorProp,\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 CheckboxRowProps extends Omit<CheckboxProps, \"onPress\"> {\n label: string | React.ReactNode;\n value: string;\n labelContainerStyle: StyleProp<ViewStyle>;\n checkboxStyle?: StyleProp<ViewStyle>;\n labelStyle?: StyleProp<TextStyle>;\n onPress?: (value: string) => void;\n direction?: Direction;\n color: string;\n unselectedColor: string;\n indeterminateColor: string;\n}\n\nconst getCheckboxAlignment = (\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 CheckboxRow: React.FC<CheckboxRowProps & IconSlot> = ({\n Icon,\n label = \"Label\",\n value,\n onPress = () => {},\n labelContainerStyle,\n labelStyle,\n checkboxStyle,\n direction = Direction.Row,\n status,\n disabled,\n style,\n color,\n uncheckedColor,\n indeterminateColor,\n ...rest\n}) => {\n const {\n values: selectedValues,\n onValueChange,\n direction: parentDirection,\n } = useCheckboxGroupContext();\n\n const values = Array.isArray(selectedValues) ? selectedValues : [];\n const isChecked = status === CheckboxStatus.Checked || values.includes(value);\n\n const handlePress = () => {\n if (!disabled) {\n onPress(value);\n onValueChange && onValueChange(value, !isChecked);\n }\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: getCheckboxAlignment(parentDirection, direction),\n }}\n >\n <Checkbox\n Icon={Icon}\n status={\n status || values.includes(value)\n ? CheckboxStatus.Checked\n : CheckboxStatus.Unchecked\n }\n onPress={handlePress}\n style={checkboxStyle}\n disabled={disabled}\n color={color}\n uncheckedColor={uncheckedColor}\n indeterminateColor={indeterminateColor}\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 CheckboxRow;\n\nexport const SEED_DATA = {\n name: \"Checkbox Row\",\n tag: \"CheckboxRow\",\n category: COMPONENT_TYPES.input,\n layout: {\n minHeight: 50,\n },\n triggers: [Triggers.OnPress],\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 labelStyle: createTextStyle({\n label: \"Label Style\",\n description: \"Change the styles of the label\",\n required: false,\n editable: false,\n }),\n direction: createRowDirectionProp(),\n fieldName: createFieldNameProp({\n defaultValue: \"unchecked\",\n valuePropName: \"status\",\n handlerPropName: \"onPress\",\n }),\n color: createColorProp({\n description: \"Color for the button (used when the checkbox is checked)\",\n }),\n uncheckedColor: createColorProp({\n label: \"Unselected Color\",\n description: \"Color for the button when the checkbox is unchecked\",\n }),\n indeterminateColor: createColorProp({\n label: \"Indeterminate Color\",\n description: \"Color for the button when the checkbox is indeterminate\",\n }),\n },\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["CheckboxRow.tsx"],"names":["React","StyleSheet","View","Platform","Checkbox","Text","useCheckboxGroupContext","createTextProp","createTextStyle","createRowDirectionProp","createFieldNameProp","COMPONENT_TYPES","Triggers","createColorProp","Direction","GroupDirection","Touchable","extractStyles","getCheckboxAlignment","parentDirection","direction","Horizontal","Row","RowReverse","renderLabel","value","labelStyle","textStyle","CheckboxRow","Icon","label","onPress","labelContainerStyle","checkboxStyle","status","disabled","style","color","uncheckedColor","rest","values","selectedValues","onValueChange","Array","isArray","isChecked","includes","handlePress","textStyles","viewStyles","styles","mainParent","flexDirection","alignItems","flex","create","justifyContent","paddingStart","minHeight","paddingEnd","select","web","cursor","userSelect","SEED_DATA","name","tag","category","input","layout","triggers","OnPress","props","description","required","defaultValue","editable","fieldName","valuePropName","handlerPropName"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAGEC,UAHF,EAKEC,IALF,EAMEC,QANF,QAO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A,SAAS,EAAE;AADL,GAJe;AAOvBY,EAAAA,QAAQ,EAAE,CAAC1D,QAAQ,CAAC2D,OAAV,CAPa;AAQvBC,EAAAA,KAAK,EAAE;AACL1C,IAAAA,KAAK,EAAEvB,cAAc,CAAC;AACpBuB,MAAAA,KAAK,EAAE,OADa;AAEpB2C,MAAAA,WAAW,EAAE,iCAFO;AAGpBC,MAAAA,QAAQ,EAAE,IAHU;AAIpBC,MAAAA,YAAY,EAAE;AAJM,KAAD,CADhB;AAOLjD,IAAAA,UAAU,EAAElB,eAAe,CAAC;AAC1BsB,MAAAA,KAAK,EAAE,aADmB;AAE1B2C,MAAAA,WAAW,EAAE,gCAFa;AAG1BC,MAAAA,QAAQ,EAAE,KAHgB;AAI1BE,MAAAA,QAAQ,EAAE;AAJgB,KAAD,CAPtB;AAaLxD,IAAAA,SAAS,EAAEX,sBAAsB,EAb5B;AAcLoE,IAAAA,SAAS,EAAEnE,mBAAmB,CAAC;AAC7BiE,MAAAA,YAAY,EAAE,eADe;AAE7BG,MAAAA,aAAa,EAAE,OAFc;AAG7BC,MAAAA,eAAe,EAAE;AAHY,KAAD,CAdzB;AAmBL1C,IAAAA,KAAK,EAAExB,eAAe,CAAC;AACrB4D,MAAAA,WAAW,EAAE;AADQ,KAAD,CAnBjB;AAsBLnC,IAAAA,cAAc,EAAEzB,eAAe,CAAC;AAC9BiB,MAAAA,KAAK,EAAE,kBADuB;AAE9B2C,MAAAA,WAAW,EAAE;AAFiB,KAAD;AAtB1B;AARgB,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 Checkbox, { CheckboxProps } from \"./Checkbox\";\nimport Text from \"../Text\";\nimport { useCheckboxGroupContext } from \"./context\";\nimport {\n createTextProp,\n createTextStyle,\n createRowDirectionProp,\n createFieldNameProp,\n COMPONENT_TYPES,\n Triggers,\n createColorProp,\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 CheckboxRowProps extends Omit<CheckboxProps, \"onPress\"> {\n label: string | React.ReactNode;\n value: string; // A string that this checkbox represents\n labelContainerStyle: StyleProp<ViewStyle>;\n checkboxStyle?: StyleProp<ViewStyle>;\n labelStyle?: StyleProp<TextStyle>;\n onPress?: (status: boolean) => void;\n direction?: Direction;\n color: string;\n unselectedColor: string;\n}\n\nconst getCheckboxAlignment = (\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 CheckboxRow: React.FC<CheckboxRowProps & IconSlot> = ({\n Icon,\n label = \"Label\",\n value,\n onPress = () => {},\n labelContainerStyle,\n labelStyle,\n checkboxStyle,\n direction = Direction.Row,\n status,\n disabled,\n style,\n color,\n uncheckedColor,\n ...rest\n}) => {\n const {\n values: selectedValues,\n onValueChange,\n direction: parentDirection,\n } = useCheckboxGroupContext();\n\n const values = Array.isArray(selectedValues) ? selectedValues : [];\n const isChecked = status || values.includes(value);\n\n const handlePress = () => {\n if (!disabled) {\n onPress(!isChecked);\n onValueChange && onValueChange(value, !isChecked);\n }\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: getCheckboxAlignment(parentDirection, direction),\n }}\n >\n <Checkbox\n Icon={Icon}\n status={status || values.includes(value)}\n onPress={handlePress}\n style={checkboxStyle}\n disabled={disabled}\n color={color}\n uncheckedColor={uncheckedColor}\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 CheckboxRow;\n\nexport const SEED_DATA = {\n name: \"Checkbox Row\",\n tag: \"CheckboxRow\",\n category: COMPONENT_TYPES.input,\n layout: {\n minHeight: 50,\n },\n triggers: [Triggers.OnPress],\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 labelStyle: createTextStyle({\n label: \"Label Style\",\n description: \"Change the styles of the label\",\n required: false,\n editable: false,\n }),\n direction: createRowDirectionProp(),\n fieldName: createFieldNameProp({\n defaultValue: \"checkboxValue\",\n valuePropName: \"value\",\n handlerPropName: \"onPress\",\n }),\n color: createColorProp({\n description: \"Color for the button (used when the checkbox is checked)\",\n }),\n uncheckedColor: createColorProp({\n label: \"Unselected Color\",\n description: \"Color for the button when the checkbox is unchecked\",\n }),\n },\n};\n"]}
|
|
@@ -68,6 +68,7 @@ function Row({
|
|
|
68
68
|
direction = RowDirection.Row,
|
|
69
69
|
style,
|
|
70
70
|
value,
|
|
71
|
+
defaultValue,
|
|
71
72
|
disabled,
|
|
72
73
|
onValueChange,
|
|
73
74
|
activeTrackColor,
|
|
@@ -77,7 +78,7 @@ function Row({
|
|
|
77
78
|
theme,
|
|
78
79
|
...rest
|
|
79
80
|
}) {
|
|
80
|
-
const [checked, setChecked] = React.useState(value);
|
|
81
|
+
const [checked, setChecked] = React.useState(value || defaultValue);
|
|
81
82
|
React.useEffect(() => {
|
|
82
83
|
if (value !== checked) {
|
|
83
84
|
setChecked(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Switch.tsx"],"names":["React","Switch","NativeSwitch","withTheme","FormRow","RowDirection","usePrevious","value","initialValue","defaultValue","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;;AAeA,SAASL,MAAT,CAAgB;AACdM,EAAAA,KADc;AAEdC,EAAAA,YAFc;AAGdC,EAAAA,YAHc;AAIdC,EAAAA,QAJc;AAKdC,EAAAA,aALc;AAMdC,EAAAA,gBANc;AAOdC,EAAAA,kBAPc;AAQdC,EAAAA,gBARc;AASdC,EAAAA,kBATc;AAUdC,EAAAA,KAVc;AAWdC,EAAAA,KAXc;AAYd,KAAGC;AAZW,CAAhB,EAaU;AACR,QAAMC,qBAAqB,GAAGP,gBAAgB,IAAII,KAAK,CAACI,MAAN,CAAaC,OAA/D;AACA,QAAMC,uBAAuB,GAAGT,kBAAkB,IAAI,MAAtD;AAEA,QAAMU,qBAAqB,GAAGT,gBAAgB,IAAI,MAAlD;AACA,QAAMU,uBAAuB,GAA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IAAA,mBAAmB,EAAED,uBAVvB;AAWE,IAAA,KAAK,EAAEL,KAXT;AAYE,IAAA,aAAa,EAAGiB,IAAD,IAAU;AACvBR,MAAAA,UAAU,CAACQ,IAAD,CAAV;AACAvB,MAAAA,aAAa,IAAIA,aAAa,CAACuB,IAAD,CAA9B;AACD;AAfH,KAgBMhB,IAhBN,EADF;AAoBD;;AAQD,SAASiB,GAAT,CAAa;AACXC,EAAAA,KAAK,GAAG,OADG;AAEXC,EAAAA,SAAS,GAAGhC,YAAY,CAAC8B,GAFd;AAGXlB,EAAAA,KAHW;AAIXV,EAAAA,KAJW;
|
|
1
|
+
{"version":3,"sources":["Switch.tsx"],"names":["React","Switch","NativeSwitch","withTheme","FormRow","RowDirection","usePrevious","value","initialValue","defaultValue","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;;AAeA,SAASL,MAAT,CAAgB;AACdM,EAAAA,KADc;AAEdC,EAAAA,YAFc;AAGdC,EAAAA,YAHc;AAIdC,EAAAA,QAJc;AAKdC,EAAAA,aALc;AAMdC,EAAAA,gBANc;AAOdC,EAAAA,kBAPc;AAQdC,EAAAA,gBARc;AASdC,EAAAA,kBATc;AAUdC,EAAAA,KAVc;AAWdC,EAAAA,KAXc;AAYd,KAAGC;AAZW,CAAhB,EAaU;AACR,QAAMC,qBAAqB,GAAGP,gBAAgB,IAAII,KAAK,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EW,KANT;AAOE,IAAA,SAAS,EAAEC,SAPb;AAQE,IAAA,KAAK,EAAEpB;AART,KASMC,IATN,gBAWE,oBAAC,MAAD;AACE,IAAA,KAAK,EAAEF,KADT;AAEE,IAAA,KAAK,EAAES,OAFT;AAGE,IAAA,QAAQ,EAAEf,QAHZ;AAIE,IAAA,aAAa,EAAEC,aAJjB;AAKE,IAAA,gBAAgB,EAAEC,gBALpB;AAME,IAAA,kBAAkB,EAAEC,kBANtB;AAOE,IAAA,gBAAgB,EAAEC,gBAPpB;AAQE,IAAA,kBAAkB,EAAEC;AARtB,IAXF,CADF;AAwBD;;AAED,MAAMuB,SAAS,GAAGnC,SAAS,CAACgC,GAAD,CAA3B;AACA,SAASG,SAAT;AACA,eAAenC,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; // deprecated\n defaultValue?: boolean;\n theme: Theme;\n activeTrackColor: string;\n inactiveTrackColor: string;\n activeThumbColor: string;\n inactiveThumbColor: string;\n} & SwitchProps;\n\nfunction Switch({\n value,\n initialValue,\n defaultValue,\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 || defaultValue);\n\n React.useEffect(() => {\n if (value != null && value !== checked) {\n setChecked(value);\n }\n }, [value, checked]);\n\n React.useEffect(() => {\n if (defaultValue != null) {\n setChecked(defaultValue);\n }\n }, [defaultValue]);\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,\n defaultValue,\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 || defaultValue);\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"]}
|
package/lib/module/index.js
CHANGED
|
@@ -28,7 +28,6 @@ export { default as Touchable } from "./components/Touchable";
|
|
|
28
28
|
export { AccordionGroup, AccordionItem } from "./components/Accordion";
|
|
29
29
|
export { ActionSheet, ActionSheetItem, ActionSheetCancel } from "./components/ActionSheet";
|
|
30
30
|
export { Swiper, SwiperItem } from "./components/Swiper";
|
|
31
|
-
export { MapView, MapMarker, MapCallout } from "./components/MapView";
|
|
32
31
|
export { Center, Circle, Square, Row, Stack, Spacer } from "./components/Layout";
|
|
33
32
|
export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup } from "./components/RadioButton/index";
|
|
34
33
|
/* Deprecated: Fix or Delete! */
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["injectIcon","withTheme","ThemeProvider","default","Provider","DefaultTheme","Link","ButtonSolid","ButtonOutline","Avatar","AvatarEdit","Card","Carousel","Checkbox","CheckboxGroup","CheckboxRow","CircleImage","Container","Divider","FAB","FieldSearchBarFull","IconButton","Image","NumberInput","ScreenContainer","StarRating","Surface","Switch","SwitchRow","TextField","TextInput","ToggleButton","Touchable","AccordionGroup","AccordionItem","ActionSheet","ActionSheetItem","ActionSheetCancel","Swiper","SwiperItem","
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["injectIcon","withTheme","ThemeProvider","default","Provider","DefaultTheme","Link","ButtonSolid","ButtonOutline","Avatar","AvatarEdit","Card","Carousel","Checkbox","CheckboxGroup","CheckboxRow","CircleImage","Container","Divider","FAB","FieldSearchBarFull","IconButton","Image","NumberInput","ScreenContainer","StarRating","Surface","Switch","SwitchRow","TextField","TextInput","ToggleButton","Touchable","AccordionGroup","AccordionItem","ActionSheet","ActionSheetItem","ActionSheetCancel","Swiper","SwiperItem","Center","Circle","Square","Row","Stack","Spacer","RadioButton","RadioButtonGroup","RadioButtonRow","RadioButtonFieldGroup","Button","CardBlock","CardContainer","CardContainerRating","CardInline","DatePicker","HeaderLarge","HeaderMedium","HeaderOverline","Picker","ProgressBar","ProgressCircle","RowBodyIcon","RowHeadlineImageCaption","RowHeadlineImageIcon","Slider","Stepper","useAuthState"],"mappings":"AAAA,SAASA,UAAT,QAA2B,mBAA3B;AACA,SAASC,SAAT,EAAoBC,aAApB,QAAyC,WAAzC;AACA,SAASC,OAAO,IAAIC,QAApB,QAAoC,YAApC;AACA,SAASD,OAAO,IAAIE,YAApB,QAAwC,uBAAxC;AAEA,SAASC,IAAT,QAAqB,mBAArB;AACA,SAASC,WAAT,EAAsBC,aAAtB,QAA2C,qBAA3C;AACA,SAASL,OAAO,IAAIM,MAApB,QAAkC,0BAAlC;AACA,SAASN,OAAO,IAAIO,UAApB,QAAsC,yBAAtC;AACA,SAASP,OAAO,IAAIQ,IAApB,QAAgC,mBAAhC;AACA,SAASR,OAAO,IAAIS,QAApB,QAAoC,uBAApC;AACA,SAASC,QAAT,EAAmBC,aAAnB,EAAkCC,WAAlC,QAAqD,uBAArD;AACA,SAASZ,OAAO,IAAIa,WAApB,QAAuC,0BAAvC;AACA,SAASb,OAAO,IAAIc,SAApB,QAAqC,wBAArC;AACA,SAASd,OAAO,IAAIe,OAApB,QAAmC,sBAAnC;AACA,SAASf,OAAO,IAAIgB,GAApB,QAA+B,kBAA/B;AACA,SAAShB,OAAO,IAAIiB,kBAApB,QAA8C,iCAA9C;AACA,SAASjB,OAAO,IAAIkB,UAApB,QAAsC,yBAAtC;AACA,SAASlB,OAAO,IAAImB,KAApB,QAAiC,oBAAjC;AACA,SAASnB,OAAO,IAAIoB,WAApB,QAAuC,0BAAvC;AACA,SAASpB,OAAO,IAAIqB,eAApB,QAA2C,8BAA3C;AACA,SAASrB,OAAO,IAAIsB,UAApB,QAAsC,yBAAtC;AACA,S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ApB,QAAuC,0BAAvC;AACA,SAAS3D,OAAO,IAAI4D,uBAApB,QAAmD,sCAAnD;AACA,SAAS5D,OAAO,IAAI6D,oBAApB,QAAgD,mCAAhD;AACA,SAAS7D,OAAO,IAAI8D,MAApB,QAAkC,qBAAlC;AACA,SAAS9D,OAAO,IAAI+D,OAApB,QAAmC,sBAAnC;AACA,SAASC,YAAT,QAA6B,2BAA7B","sourcesContent":["export { injectIcon } from \"./interfaces/Icon\";\nexport { withTheme, ThemeProvider } from \"./theming\";\nexport { default as Provider } from \"./Provider\";\nexport { default as DefaultTheme } from \"./styles/DefaultTheme\";\n\nexport { Link } from \"./components/Text\";\nexport { ButtonSolid, ButtonOutline } from \"./components/Button\";\nexport { default as Avatar } from \"./components/CircleImage\";\nexport { default as AvatarEdit } from \"./components/AvatarEdit\";\nexport { default as Card } from \"./components/Card\";\nexport { default as Carousel } from \"./components/Carousel\";\nexport { Checkbox, CheckboxGroup, CheckboxRow } from \"./components/Checkbox\";\nexport { default as CircleImage } from \"./components/CircleImage\";\nexport { default as Container } from \"./components/Container\";\nexport { default as Divider } from \"./components/Divider\";\nexport { default as FAB } from \"./components/FAB\";\nexport { default as FieldSearchBarFull } from \"./components/FieldSearchBarFull\";\nexport { default as IconButton } from \"./components/IconButton\";\nexport { default as Image } from \"./components/Image\";\nexport { default as NumberInput } from \"./components/NumberInput\";\nexport { default as ScreenContainer } from \"./components/ScreenContainer\";\nexport { default as StarRating } from \"./components/StarRating\";\nexport { default as Surface } from \"./components/Surface\";\nexport { default as Switch, SwitchRow } from \"./components/Switch\";\nexport { default as TextField } from \"./components/TextField\";\nexport { default as TextInput } from \"./components/TextInput\";\nexport { default as ToggleButton } from \"./components/ToggleButton\";\nexport { default as Touchable } from \"./components/Touchable\";\nexport { AccordionGroup, AccordionItem } from \"./components/Accordion\";\nexport {\n ActionSheet,\n ActionSheetItem,\n ActionSheetCancel,\n} from \"./components/ActionSheet\";\nexport { Swiper, SwiperItem } from \"./components/Swiper\";\n\nexport {\n Center,\n Circle,\n Square,\n Row,\n Stack,\n Spacer,\n} from \"./components/Layout\";\n\nexport {\n RadioButton,\n RadioButtonGroup,\n RadioButtonRow,\n RadioButtonFieldGroup,\n} from \"./components/RadioButton/index\";\n\n/* Deprecated: Fix or Delete! */\nexport { default as Button } from \"./components/DeprecatedButton\";\nexport { default as CardBlock } from \"./components/CardBlock\";\nexport { default as CardContainer } from \"./components/CardContainer\";\nexport { default as CardContainerRating } from \"./components/CardContainerRating\";\nexport { default as CardInline } from \"./components/CardInline\";\nexport { default as DatePicker } from \"./components/DatePicker/DatePicker\";\nexport { default as HeaderLarge } from \"./components/HeaderLarge\";\nexport { default as HeaderMedium } from \"./components/HeaderMedium\";\nexport { default as HeaderOverline } from \"./components/HeaderOverline\";\nexport { default as Picker } from \"./components/Picker/Picker\";\nexport { default as ProgressBar } from \"./components/ProgressBar\";\nexport { default as ProgressCircle } from \"./components/ProgressCircle\";\nexport { default as RowBodyIcon } from \"./components/RowBodyIcon\";\nexport { default as RowHeadlineImageCaption } from \"./components/RowHeadlineImageCaption\";\nexport { default as RowHeadlineImageIcon } from \"./components/RowHeadlineImageIcon\";\nexport { default as Slider } from \"./components/Slider\";\nexport { default as Stepper } from \"./components/Stepper\";\nexport { useAuthState } from \"./components/useAuthState\";\n"]}
|
|
@@ -22,12 +22,6 @@ export const SEED_DATA = {
|
|
|
22
22
|
description: "Color for the button when the checkbox is unchecked",
|
|
23
23
|
defaultValue: null
|
|
24
24
|
}),
|
|
25
|
-
indeterminateColor: createColorProp({
|
|
26
|
-
group: GROUPS.basic,
|
|
27
|
-
label: "Indeterminate Color",
|
|
28
|
-
description: "Color for the button when the checkbox is indeterminate",
|
|
29
|
-
defaultValue: null
|
|
30
|
-
}),
|
|
31
25
|
disabled: createBoolProp({
|
|
32
26
|
label: "Disabled",
|
|
33
27
|
description: "Whether the checkbox is disabled"
|
|
@@ -46,11 +40,6 @@ export const SEED_DATA = {
|
|
|
46
40
|
label: "Unchecked Icon",
|
|
47
41
|
description: 'Icon to show when the checkbox status is "unchecked"',
|
|
48
42
|
defaultValue: null
|
|
49
|
-
}),
|
|
50
|
-
indeterminateIcon: createIconProp({
|
|
51
|
-
label: "Indeterminate Icon",
|
|
52
|
-
description: 'Icon to show when the checkbox status is "indeterminate"',
|
|
53
|
-
defaultValue: null
|
|
54
43
|
})
|
|
55
44
|
}
|
|
56
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Checkbox.js"],"names":["COMPONENT_TYPES","createBoolProp","createIconProp","createStaticNumberProp","createColorProp","createFieldNameProp","GROUPS","Triggers","SEED_DATA","name","tag","category","input","triggers","OnPress","props","fieldName","defaultValue","valuePropName","handlerPropName","color","group","basic","label","description","uncheckedColor","
|
|
1
|
+
{"version":3,"sources":["Checkbox.js"],"names":["COMPONENT_TYPES","createBoolProp","createIconProp","createStaticNumberProp","createColorProp","createFieldNameProp","GROUPS","Triggers","SEED_DATA","name","tag","category","input","triggers","OnPress","props","fieldName","defaultValue","valuePropName","handlerPropName","color","group","basic","label","description","uncheckedColor","disabled","size","checkedIcon","uncheckedIcon"],"mappings":"AAAA,SACEA,eADF,EAEEC,cAFF,EAGEC,cAHF,EAIEC,sBAJF,EAKEC,eALF,EAMEC,mBANF,EAOEC,MAPF,EAQEC,QARF,QASO,iBATP;AAWA,OAAO,MAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,UADiB;AAEvBC,EAAAA,GAAG,EAAE,UAFkB;AAGvBC,EAAAA,QAAQ,EAAEX,eAAe,CAACY,KAHH;AAIvBC,EAAAA,QAAQ,EAAE,CAACN,QAAQ,CAACO,OAAV,CAJa;AAKvBC,EAAAA,KAAK,EAAE;AACLC,IAAAA,SAAS,EAAEX,mBAAmB,CAAC;AAC7BY,MAAAA,YAAY,EAAE,eADe;AAE7BC,MAAAA,aAAa,EAAE,QAFc;AAG7BC,MAAAA,eAAe,EAAE;AAHY,KAAD,CADzB;AAMLC,IAAAA,KAAK,EAAEhB,eAAe,CAAC;AACrBiB,MAAAA,KAAK,EAAEf,MAAM,CAACgB,KADO;AAErBC,MAAAA,KAAK,EAAE,OAFc;AAGrBC,MAAAA,WAAW,EAAE,0DAHQ;AAIrBP,MAAAA,YAAY,EAAE;AAJO,KAAD,CANjB;AAYLQ,IAAAA,cAAc,EAAErB,eAAe,CAAC;AAC9BiB,MAAAA,KAAK,EAAEf,MAAM,CAACgB,KADgB;AAE9BC,MAAAA,KAAK,EAAE,kBAFuB;AAG9BC,MAAAA,WAAW,EAAE,qDAHiB;AAI9BP,MAAAA,YAAY,EAAE;AAJgB,KAAD,CAZ1B;AAkBLS,IAAAA,QAAQ,EAAEzB,cAAc,CAAC;AACvBsB,MAAAA,KAAK,EAAE,UADgB;AAEvBC,MAAAA,WAAW,EAAE;AAFU,KAAD,CAlBnB;AAsBLG,IAAAA,IAAI,EAAExB,sBAAsB,CAAC;AAC3BoB,MAAAA,KAAK,EAAE,MADoB;AAE3BC,MAAAA,WAAW,EAAE,gCAFc;AAG3BP,MAAAA,YAAY,EAAE;AAHa,KAAD,CAtBvB;AA2BLW,IAAAA,WAAW,EAAE1B,cAAc,CAAC;AAC1BqB,MAAAA,KAAK,EAAE,cADmB;AAE1BC,MAAAA,WAAW,EAAE,oDAFa;AAG1BP,MAAAA,YAAY,EAAE;AAHY,KAAD,CA3BtB;AAgCLY,IAAAA,aAAa,EAAE3B,cAAc,CAAC;AAC5BqB,MAAAA,KAAK,EAAE,gBADqB;AAE5BC,MAAAA,WAAW,EAAE,sDAFe;AAG5BP,MAAAA,YAAY,EAAE;AAHc,KAAD;AAhCxB;AALgB,CAAlB","sourcesContent":["import {\n COMPONENT_TYPES,\n createBoolProp,\n createIconProp,\n createStaticNumberProp,\n createColorProp,\n createFieldNameProp,\n GROUPS,\n Triggers,\n} from \"@draftbit/types\";\n\nexport const SEED_DATA = {\n name: \"Checkbox\",\n tag: \"Checkbox\",\n category: COMPONENT_TYPES.input,\n triggers: [Triggers.OnPress],\n props: {\n fieldName: createFieldNameProp({\n defaultValue: \"checkboxValue\",\n valuePropName: \"status\",\n handlerPropName: \"onPress\",\n }),\n color: createColorProp({\n group: GROUPS.basic,\n label: \"Color\",\n description: \"Color for the button (used when the checkbox is checked)\",\n defaultValue: null,\n }),\n uncheckedColor: createColorProp({\n group: GROUPS.basic,\n label: \"Unselected Color\",\n description: \"Color for the button when the checkbox is unchecked\",\n defaultValue: null,\n }),\n disabled: createBoolProp({\n label: \"Disabled\",\n description: \"Whether the checkbox is disabled\",\n }),\n size: createStaticNumberProp({\n label: \"Size\",\n description: \"Specifies the size of the icon\",\n defaultValue: null,\n }),\n checkedIcon: createIconProp({\n label: \"Checked Icon\",\n description: 'Icon to show when the checkbox status is \"checked\"',\n defaultValue: null,\n }),\n uncheckedIcon: createIconProp({\n label: \"Unchecked Icon\",\n description: 'Icon to show when the checkbox status is \"unchecked\"',\n defaultValue: null,\n }),\n },\n};\n"]}
|
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { TouchableHighlightProps, StyleProp, ViewStyle } from "react-native";
|
|
3
3
|
import type { IconSlot } from "../../interfaces/Icon";
|
|
4
|
-
export declare enum CheckboxStatus {
|
|
5
|
-
Checked = "checked",
|
|
6
|
-
Unchecked = "unchecked",
|
|
7
|
-
Indeterminate = "indeterminate"
|
|
8
|
-
}
|
|
9
4
|
export interface CheckboxProps {
|
|
10
|
-
status?:
|
|
5
|
+
status?: boolean;
|
|
11
6
|
disabled?: boolean;
|
|
12
7
|
onPress?: (checked: boolean) => void;
|
|
13
8
|
color?: string;
|
|
14
9
|
uncheckedColor?: string;
|
|
15
|
-
indeterminateColor?: string;
|
|
16
10
|
checkedIcon?: string;
|
|
17
11
|
uncheckedIcon?: string;
|
|
18
|
-
indeterminateIcon?: string;
|
|
19
12
|
initialValue?: boolean;
|
|
20
|
-
defaultValue?:
|
|
13
|
+
defaultValue?: boolean;
|
|
21
14
|
size?: number;
|
|
22
15
|
style?: StyleProp<ViewStyle>;
|
|
23
16
|
}
|
|
@@ -12,11 +12,10 @@ export interface CheckboxRowProps extends Omit<CheckboxProps, "onPress"> {
|
|
|
12
12
|
labelContainerStyle: StyleProp<ViewStyle>;
|
|
13
13
|
checkboxStyle?: StyleProp<ViewStyle>;
|
|
14
14
|
labelStyle?: StyleProp<TextStyle>;
|
|
15
|
-
onPress?: (
|
|
15
|
+
onPress?: (status: boolean) => void;
|
|
16
16
|
direction?: Direction;
|
|
17
17
|
color: string;
|
|
18
18
|
unselectedColor: string;
|
|
19
|
-
indeterminateColor: string;
|
|
20
19
|
}
|
|
21
20
|
declare const CheckboxRow: React.FC<CheckboxRowProps & IconSlot>;
|
|
22
21
|
export default CheckboxRow;
|
|
@@ -83,15 +82,5 @@ export declare const SEED_DATA: {
|
|
|
83
82
|
formType: string;
|
|
84
83
|
propType: string;
|
|
85
84
|
};
|
|
86
|
-
indeterminateColor: {
|
|
87
|
-
group: string;
|
|
88
|
-
label: string;
|
|
89
|
-
description: string;
|
|
90
|
-
editable: boolean;
|
|
91
|
-
required: boolean;
|
|
92
|
-
defaultValue: null;
|
|
93
|
-
formType: string;
|
|
94
|
-
propType: string;
|
|
95
|
-
};
|
|
96
85
|
};
|
|
97
86
|
};
|
|
@@ -20,7 +20,7 @@ declare type RowProps = {
|
|
|
20
20
|
direction: RowDirection;
|
|
21
21
|
style?: StyleProp<ViewStyle>;
|
|
22
22
|
};
|
|
23
|
-
declare function Row({ label, direction, style, value, disabled, onValueChange, activeTrackColor, inactiveTrackColor, activeThumbColor, inactiveThumbColor, theme, ...rest }: Props & RowProps): JSX.Element;
|
|
23
|
+
declare function Row({ label, direction, style, value, defaultValue, disabled, onValueChange, activeTrackColor, inactiveTrackColor, activeThumbColor, inactiveThumbColor, theme, ...rest }: Props & RowProps): JSX.Element;
|
|
24
24
|
declare const SwitchRow: React.ComponentType<import("@draftbit/react-theme-provider").$Without<{
|
|
25
25
|
value?: boolean | undefined;
|
|
26
26
|
disabled?: boolean | undefined;
|
|
@@ -28,7 +28,6 @@ export { default as Touchable } from "./components/Touchable";
|
|
|
28
28
|
export { AccordionGroup, AccordionItem } from "./components/Accordion";
|
|
29
29
|
export { ActionSheet, ActionSheetItem, ActionSheetCancel, } from "./components/ActionSheet";
|
|
30
30
|
export { Swiper, SwiperItem } from "./components/Swiper";
|
|
31
|
-
export { MapView, MapMarker, MapCallout } from "./components/MapView";
|
|
32
31
|
export { Center, Circle, Square, Row, Stack, Spacer, } from "./components/Layout";
|
|
33
32
|
export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup, } from "./components/RadioButton/index";
|
|
34
33
|
export { default as Button } from "./components/DeprecatedButton";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "42.4.6-
|
|
3
|
+
"version": "42.4.6-7e6a42.0+7e6a42fd",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -44,7 +44,6 @@
|
|
|
44
44
|
"@draftbit/types": "^42.2.1",
|
|
45
45
|
"@material-ui/core": "^4.11.0",
|
|
46
46
|
"@material-ui/pickers": "^3.2.10",
|
|
47
|
-
"@react-google-maps/api": "^2.5.0",
|
|
48
47
|
"@react-native-community/slider": "4.0.0-rc.3",
|
|
49
48
|
"@react-native-picker/picker": "^2.1.0",
|
|
50
49
|
"color": "^3.1.2",
|
|
@@ -53,7 +52,6 @@
|
|
|
53
52
|
"lodash.isnumber": "^3.0.3",
|
|
54
53
|
"lodash.omit": "^4.5.0",
|
|
55
54
|
"lodash.tonumber": "^4.0.3",
|
|
56
|
-
"react-native-maps": "^0.29.3",
|
|
57
55
|
"react-native-modal-datetime-picker": "^10.0.0",
|
|
58
56
|
"react-native-typography": "^1.4.1",
|
|
59
57
|
"react-native-web-swiper": "^2.2.1"
|
|
@@ -97,5 +95,5 @@
|
|
|
97
95
|
]
|
|
98
96
|
]
|
|
99
97
|
},
|
|
100
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "7e6a42fdb0152df913abdf0fd3963116ded6f2f9"
|
|
101
99
|
}
|
|
@@ -3,14 +3,8 @@ import { View, StyleSheet, } from "react-native";
|
|
|
3
3
|
import { useTheme } from "../../theming";
|
|
4
4
|
import Touchable from "../Touchable";
|
|
5
5
|
import { usePrevious } from "../../hooks";
|
|
6
|
-
|
|
7
|
-
(
|
|
8
|
-
CheckboxStatus["Checked"] = "checked";
|
|
9
|
-
CheckboxStatus["Unchecked"] = "unchecked";
|
|
10
|
-
CheckboxStatus["Indeterminate"] = "indeterminate";
|
|
11
|
-
})(CheckboxStatus || (CheckboxStatus = {}));
|
|
12
|
-
const Checkbox = ({ Icon, status, disabled = false, onPress = () => { }, color, uncheckedColor, indeterminateColor, initialValue, defaultValue, checkedIcon = "MaterialCommunityIcons/checkbox-marked", uncheckedIcon = "MaterialCommunityIcons/checkbox-blank-outline", indeterminateIcon = "AntDesign/minussquareo", size = 24, style, ...rest }) => {
|
|
13
|
-
const [internalValue, setInternalValue] = React.useState(status || defaultValue || CheckboxStatus.Unchecked);
|
|
6
|
+
const Checkbox = ({ Icon, status, disabled = false, onPress = () => { }, color, uncheckedColor, initialValue, defaultValue, checkedIcon = "MaterialCommunityIcons/checkbox-marked", uncheckedIcon = "MaterialCommunityIcons/checkbox-blank-outline", size = 24, style, ...rest }) => {
|
|
7
|
+
const [internalValue, setInternalValue] = React.useState(status || defaultValue || false);
|
|
14
8
|
React.useEffect(() => {
|
|
15
9
|
if (status != null) {
|
|
16
10
|
setInternalValue(status);
|
|
@@ -28,25 +22,15 @@ const Checkbox = ({ Icon, status, disabled = false, onPress = () => { }, color,
|
|
|
28
22
|
}
|
|
29
23
|
}, [initialValue, previousInitialValue, onPress]);
|
|
30
24
|
const { colors } = useTheme();
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
[CheckboxStatus.Indeterminate]: indeterminateColor || colors.light,
|
|
35
|
-
};
|
|
36
|
-
const iconsMap = {
|
|
37
|
-
[CheckboxStatus.Checked]: checkedIcon,
|
|
38
|
-
[CheckboxStatus.Unchecked]: uncheckedIcon,
|
|
39
|
-
[CheckboxStatus.Indeterminate]: indeterminateIcon,
|
|
40
|
-
};
|
|
41
|
-
const checkboxColor = colorsMap[internalValue];
|
|
25
|
+
const checkboxColor = internalValue
|
|
26
|
+
? color || colors.primary
|
|
27
|
+
: uncheckedColor || colors.primary;
|
|
42
28
|
const handlePress = () => {
|
|
43
|
-
setInternalValue(internalValue
|
|
44
|
-
|
|
45
|
-
: CheckboxStatus.Unchecked);
|
|
46
|
-
onPress(internalValue === CheckboxStatus.Unchecked);
|
|
29
|
+
setInternalValue(!internalValue);
|
|
30
|
+
onPress(!internalValue);
|
|
47
31
|
};
|
|
48
32
|
return (React.createElement(Touchable, { ...rest, onPress: handlePress, disabled: disabled, accessibilityState: { disabled }, accessibilityRole: "button", accessibilityLiveRegion: "polite", style: [styles.container, style, { width: size, height: size }] },
|
|
49
|
-
React.createElement(Icon, { style: styles.icon, name:
|
|
33
|
+
React.createElement(Icon, { style: styles.icon, name: internalValue ? checkedIcon : uncheckedIcon, size: size, color: checkboxColor }),
|
|
50
34
|
React.createElement(View, { style: [StyleSheet.absoluteFill, styles.fillContainer] },
|
|
51
35
|
React.createElement(View, { style: [
|
|
52
36
|
styles.fill,
|
|
@@ -12,24 +12,16 @@ import type { IconSlot } from "../../interfaces/Icon";
|
|
|
12
12
|
import Touchable from "../Touchable";
|
|
13
13
|
import { usePrevious } from "../../hooks";
|
|
14
14
|
|
|
15
|
-
export enum CheckboxStatus {
|
|
16
|
-
Checked = "checked",
|
|
17
|
-
Unchecked = "unchecked",
|
|
18
|
-
Indeterminate = "indeterminate",
|
|
19
|
-
}
|
|
20
|
-
|
|
21
15
|
export interface CheckboxProps {
|
|
22
|
-
status?:
|
|
16
|
+
status?: boolean;
|
|
23
17
|
disabled?: boolean;
|
|
24
18
|
onPress?: (checked: boolean) => void;
|
|
25
19
|
color?: string;
|
|
26
20
|
uncheckedColor?: string;
|
|
27
|
-
indeterminateColor?: string;
|
|
28
21
|
checkedIcon?: string;
|
|
29
22
|
uncheckedIcon?: string;
|
|
30
|
-
indeterminateIcon?: string;
|
|
31
23
|
initialValue?: boolean; // deprecated
|
|
32
|
-
defaultValue?:
|
|
24
|
+
defaultValue?: boolean;
|
|
33
25
|
size?: number;
|
|
34
26
|
style?: StyleProp<ViewStyle>;
|
|
35
27
|
}
|
|
@@ -42,18 +34,16 @@ const Checkbox: React.FC<CheckboxProps & TouchableHighlightProps & IconSlot> =
|
|
|
42
34
|
onPress = () => {},
|
|
43
35
|
color,
|
|
44
36
|
uncheckedColor,
|
|
45
|
-
indeterminateColor,
|
|
46
37
|
initialValue,
|
|
47
38
|
defaultValue,
|
|
48
39
|
checkedIcon = "MaterialCommunityIcons/checkbox-marked",
|
|
49
40
|
uncheckedIcon = "MaterialCommunityIcons/checkbox-blank-outline",
|
|
50
|
-
indeterminateIcon = "AntDesign/minussquareo",
|
|
51
41
|
size = 24,
|
|
52
42
|
style,
|
|
53
43
|
...rest
|
|
54
44
|
}) => {
|
|
55
|
-
const [internalValue, setInternalValue] = React.useState<
|
|
56
|
-
status || defaultValue ||
|
|
45
|
+
const [internalValue, setInternalValue] = React.useState<boolean>(
|
|
46
|
+
status || defaultValue || false
|
|
57
47
|
);
|
|
58
48
|
|
|
59
49
|
React.useEffect(() => {
|
|
@@ -76,27 +66,13 @@ const Checkbox: React.FC<CheckboxProps & TouchableHighlightProps & IconSlot> =
|
|
|
76
66
|
}, [initialValue, previousInitialValue, onPress]);
|
|
77
67
|
const { colors } = useTheme();
|
|
78
68
|
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
[CheckboxStatus.Indeterminate]: indeterminateColor || colors.light,
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const iconsMap = {
|
|
86
|
-
[CheckboxStatus.Checked]: checkedIcon,
|
|
87
|
-
[CheckboxStatus.Unchecked]: uncheckedIcon,
|
|
88
|
-
[CheckboxStatus.Indeterminate]: indeterminateIcon,
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const checkboxColor = colorsMap[internalValue];
|
|
69
|
+
const checkboxColor = internalValue
|
|
70
|
+
? color || colors.primary
|
|
71
|
+
: uncheckedColor || colors.primary;
|
|
92
72
|
|
|
93
73
|
const handlePress = () => {
|
|
94
|
-
setInternalValue(
|
|
95
|
-
|
|
96
|
-
? CheckboxStatus.Checked
|
|
97
|
-
: CheckboxStatus.Unchecked
|
|
98
|
-
);
|
|
99
|
-
onPress(internalValue === CheckboxStatus.Unchecked);
|
|
74
|
+
setInternalValue(!internalValue);
|
|
75
|
+
onPress(!internalValue);
|
|
100
76
|
};
|
|
101
77
|
|
|
102
78
|
return (
|
|
@@ -111,7 +87,7 @@ const Checkbox: React.FC<CheckboxProps & TouchableHighlightProps & IconSlot> =
|
|
|
111
87
|
>
|
|
112
88
|
<Icon
|
|
113
89
|
style={styles.icon}
|
|
114
|
-
name={
|
|
90
|
+
name={internalValue ? checkedIcon : uncheckedIcon}
|
|
115
91
|
size={size}
|
|
116
92
|
color={checkboxColor}
|
|
117
93
|
/>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { StyleSheet, View, Platform, } from "react-native";
|
|
3
|
-
import Checkbox
|
|
3
|
+
import Checkbox from "./Checkbox";
|
|
4
4
|
import Text from "../Text";
|
|
5
5
|
import { useCheckboxGroupContext } from "./context";
|
|
6
6
|
import { createTextProp, createTextStyle, createRowDirectionProp, createFieldNameProp, COMPONENT_TYPES, Triggers, createColorProp, } from "@draftbit/types";
|
|
@@ -31,13 +31,13 @@ const renderLabel = (value, labelStyle, textStyle) => {
|
|
|
31
31
|
return React.createElement(React.Fragment, null, value);
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
-
const CheckboxRow = ({ Icon, label = "Label", value, onPress = () => { }, labelContainerStyle, labelStyle, checkboxStyle, direction = Direction.Row, status, disabled, style, color, uncheckedColor,
|
|
34
|
+
const CheckboxRow = ({ Icon, label = "Label", value, onPress = () => { }, labelContainerStyle, labelStyle, checkboxStyle, direction = Direction.Row, status, disabled, style, color, uncheckedColor, ...rest }) => {
|
|
35
35
|
const { values: selectedValues, onValueChange, direction: parentDirection, } = useCheckboxGroupContext();
|
|
36
36
|
const values = Array.isArray(selectedValues) ? selectedValues : [];
|
|
37
|
-
const isChecked = status
|
|
37
|
+
const isChecked = status || values.includes(value);
|
|
38
38
|
const handlePress = () => {
|
|
39
39
|
if (!disabled) {
|
|
40
|
-
onPress(
|
|
40
|
+
onPress(!isChecked);
|
|
41
41
|
onValueChange && onValueChange(value, !isChecked);
|
|
42
42
|
}
|
|
43
43
|
};
|
|
@@ -54,9 +54,7 @@ const CheckboxRow = ({ Icon, label = "Label", value, onPress = () => { }, labelC
|
|
|
54
54
|
flex: 1,
|
|
55
55
|
alignItems: getCheckboxAlignment(parentDirection, direction),
|
|
56
56
|
} },
|
|
57
|
-
React.createElement(Checkbox, { Icon: Icon, status: status || values.includes(value)
|
|
58
|
-
? CheckboxStatus.Checked
|
|
59
|
-
: CheckboxStatus.Unchecked, onPress: handlePress, style: checkboxStyle, disabled: disabled, color: color, uncheckedColor: uncheckedColor, indeterminateColor: indeterminateColor }))));
|
|
57
|
+
React.createElement(Checkbox, { Icon: Icon, status: status || values.includes(value), onPress: handlePress, style: checkboxStyle, disabled: disabled, color: color, uncheckedColor: uncheckedColor }))));
|
|
60
58
|
};
|
|
61
59
|
const styles = StyleSheet.create({
|
|
62
60
|
mainParent: {
|
|
@@ -101,8 +99,8 @@ export const SEED_DATA = {
|
|
|
101
99
|
}),
|
|
102
100
|
direction: createRowDirectionProp(),
|
|
103
101
|
fieldName: createFieldNameProp({
|
|
104
|
-
defaultValue: "
|
|
105
|
-
valuePropName: "
|
|
102
|
+
defaultValue: "checkboxValue",
|
|
103
|
+
valuePropName: "value",
|
|
106
104
|
handlerPropName: "onPress",
|
|
107
105
|
}),
|
|
108
106
|
color: createColorProp({
|
|
@@ -112,9 +110,5 @@ export const SEED_DATA = {
|
|
|
112
110
|
label: "Unselected Color",
|
|
113
111
|
description: "Color for the button when the checkbox is unchecked",
|
|
114
112
|
}),
|
|
115
|
-
indeterminateColor: createColorProp({
|
|
116
|
-
label: "Indeterminate Color",
|
|
117
|
-
description: "Color for the button when the checkbox is indeterminate",
|
|
118
|
-
}),
|
|
119
113
|
},
|
|
120
114
|
};
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
View,
|
|
8
8
|
Platform,
|
|
9
9
|
} from "react-native";
|
|
10
|
-
import Checkbox, { CheckboxProps
|
|
10
|
+
import Checkbox, { CheckboxProps } from "./Checkbox";
|
|
11
11
|
import Text from "../Text";
|
|
12
12
|
import { useCheckboxGroupContext } from "./context";
|
|
13
13
|
import {
|
|
@@ -31,15 +31,14 @@ export enum Direction {
|
|
|
31
31
|
|
|
32
32
|
export interface CheckboxRowProps extends Omit<CheckboxProps, "onPress"> {
|
|
33
33
|
label: string | React.ReactNode;
|
|
34
|
-
value: string;
|
|
34
|
+
value: string; // A string that this checkbox represents
|
|
35
35
|
labelContainerStyle: StyleProp<ViewStyle>;
|
|
36
36
|
checkboxStyle?: StyleProp<ViewStyle>;
|
|
37
37
|
labelStyle?: StyleProp<TextStyle>;
|
|
38
|
-
onPress?: (
|
|
38
|
+
onPress?: (status: boolean) => void;
|
|
39
39
|
direction?: Direction;
|
|
40
40
|
color: string;
|
|
41
41
|
unselectedColor: string;
|
|
42
|
-
indeterminateColor: string;
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
const getCheckboxAlignment = (
|
|
@@ -81,7 +80,6 @@ const CheckboxRow: React.FC<CheckboxRowProps & IconSlot> = ({
|
|
|
81
80
|
style,
|
|
82
81
|
color,
|
|
83
82
|
uncheckedColor,
|
|
84
|
-
indeterminateColor,
|
|
85
83
|
...rest
|
|
86
84
|
}) => {
|
|
87
85
|
const {
|
|
@@ -91,11 +89,11 @@ const CheckboxRow: React.FC<CheckboxRowProps & IconSlot> = ({
|
|
|
91
89
|
} = useCheckboxGroupContext();
|
|
92
90
|
|
|
93
91
|
const values = Array.isArray(selectedValues) ? selectedValues : [];
|
|
94
|
-
const isChecked = status
|
|
92
|
+
const isChecked = status || values.includes(value);
|
|
95
93
|
|
|
96
94
|
const handlePress = () => {
|
|
97
95
|
if (!disabled) {
|
|
98
|
-
onPress(
|
|
96
|
+
onPress(!isChecked);
|
|
99
97
|
onValueChange && onValueChange(value, !isChecked);
|
|
100
98
|
}
|
|
101
99
|
};
|
|
@@ -128,17 +126,12 @@ const CheckboxRow: React.FC<CheckboxRowProps & IconSlot> = ({
|
|
|
128
126
|
>
|
|
129
127
|
<Checkbox
|
|
130
128
|
Icon={Icon}
|
|
131
|
-
status={
|
|
132
|
-
status || values.includes(value)
|
|
133
|
-
? CheckboxStatus.Checked
|
|
134
|
-
: CheckboxStatus.Unchecked
|
|
135
|
-
}
|
|
129
|
+
status={status || values.includes(value)}
|
|
136
130
|
onPress={handlePress}
|
|
137
131
|
style={checkboxStyle}
|
|
138
132
|
disabled={disabled}
|
|
139
133
|
color={color}
|
|
140
134
|
uncheckedColor={uncheckedColor}
|
|
141
|
-
indeterminateColor={indeterminateColor}
|
|
142
135
|
/>
|
|
143
136
|
</View>
|
|
144
137
|
</Touchable>
|
|
@@ -190,8 +183,8 @@ export const SEED_DATA = {
|
|
|
190
183
|
}),
|
|
191
184
|
direction: createRowDirectionProp(),
|
|
192
185
|
fieldName: createFieldNameProp({
|
|
193
|
-
defaultValue: "
|
|
194
|
-
valuePropName: "
|
|
186
|
+
defaultValue: "checkboxValue",
|
|
187
|
+
valuePropName: "value",
|
|
195
188
|
handlerPropName: "onPress",
|
|
196
189
|
}),
|
|
197
190
|
color: createColorProp({
|
|
@@ -201,9 +194,5 @@ export const SEED_DATA = {
|
|
|
201
194
|
label: "Unselected Color",
|
|
202
195
|
description: "Color for the button when the checkbox is unchecked",
|
|
203
196
|
}),
|
|
204
|
-
indeterminateColor: createColorProp({
|
|
205
|
-
label: "Indeterminate Color",
|
|
206
|
-
description: "Color for the button when the checkbox is indeterminate",
|
|
207
|
-
}),
|
|
208
197
|
},
|
|
209
198
|
};
|
package/src/components/Switch.js
CHANGED
|
@@ -44,8 +44,8 @@ function Switch({ value, initialValue, defaultValue, disabled, onValueChange, ac
|
|
|
44
44
|
onValueChange && onValueChange(bool);
|
|
45
45
|
}, ...rest }));
|
|
46
46
|
}
|
|
47
|
-
function Row({ label = "Label", direction = RowDirection.Row, style, value, disabled, onValueChange, activeTrackColor, inactiveTrackColor, activeThumbColor, inactiveThumbColor, theme, ...rest }) {
|
|
48
|
-
const [checked, setChecked] = React.useState(value);
|
|
47
|
+
function Row({ label = "Label", direction = RowDirection.Row, style, value, defaultValue, disabled, onValueChange, activeTrackColor, inactiveTrackColor, activeThumbColor, inactiveThumbColor, theme, ...rest }) {
|
|
48
|
+
const [checked, setChecked] = React.useState(value || defaultValue);
|
|
49
49
|
React.useEffect(() => {
|
|
50
50
|
if (value !== checked) {
|
|
51
51
|
setChecked(value);
|
|
@@ -107,6 +107,7 @@ function Row({
|
|
|
107
107
|
direction = RowDirection.Row,
|
|
108
108
|
style,
|
|
109
109
|
value,
|
|
110
|
+
defaultValue,
|
|
110
111
|
disabled,
|
|
111
112
|
onValueChange,
|
|
112
113
|
activeTrackColor,
|
|
@@ -116,7 +117,7 @@ function Row({
|
|
|
116
117
|
theme,
|
|
117
118
|
...rest
|
|
118
119
|
}: Props & RowProps) {
|
|
119
|
-
const [checked, setChecked] = React.useState(value);
|
|
120
|
+
const [checked, setChecked] = React.useState(value || defaultValue);
|
|
120
121
|
|
|
121
122
|
React.useEffect(() => {
|
|
122
123
|
if (value !== checked) {
|