@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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
|
|
8
8
|
var React = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
@@ -23,15 +23,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
23
23
|
|
|
24
24
|
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); }
|
|
25
25
|
|
|
26
|
-
let CheckboxStatus;
|
|
27
|
-
exports.CheckboxStatus = CheckboxStatus;
|
|
28
|
-
|
|
29
|
-
(function (CheckboxStatus) {
|
|
30
|
-
CheckboxStatus["Checked"] = "checked";
|
|
31
|
-
CheckboxStatus["Unchecked"] = "unchecked";
|
|
32
|
-
CheckboxStatus["Indeterminate"] = "indeterminate";
|
|
33
|
-
})(CheckboxStatus || (exports.CheckboxStatus = CheckboxStatus = {}));
|
|
34
|
-
|
|
35
26
|
const Checkbox = ({
|
|
36
27
|
Icon,
|
|
37
28
|
status,
|
|
@@ -39,17 +30,15 @@ const Checkbox = ({
|
|
|
39
30
|
onPress = () => {},
|
|
40
31
|
color,
|
|
41
32
|
uncheckedColor,
|
|
42
|
-
indeterminateColor,
|
|
43
33
|
initialValue,
|
|
44
34
|
defaultValue,
|
|
45
35
|
checkedIcon = "MaterialCommunityIcons/checkbox-marked",
|
|
46
36
|
uncheckedIcon = "MaterialCommunityIcons/checkbox-blank-outline",
|
|
47
|
-
indeterminateIcon = "AntDesign/minussquareo",
|
|
48
37
|
size = 24,
|
|
49
38
|
style,
|
|
50
39
|
...rest
|
|
51
40
|
}) => {
|
|
52
|
-
const [internalValue, setInternalValue] = React.useState(status || defaultValue ||
|
|
41
|
+
const [internalValue, setInternalValue] = React.useState(status || defaultValue || false);
|
|
53
42
|
React.useEffect(() => {
|
|
54
43
|
if (status != null) {
|
|
55
44
|
setInternalValue(status);
|
|
@@ -69,21 +58,11 @@ const Checkbox = ({
|
|
|
69
58
|
const {
|
|
70
59
|
colors
|
|
71
60
|
} = (0, _theming.useTheme)();
|
|
72
|
-
const
|
|
73
|
-
[CheckboxStatus.Checked]: color || colors.primary,
|
|
74
|
-
[CheckboxStatus.Unchecked]: uncheckedColor || colors.primary,
|
|
75
|
-
[CheckboxStatus.Indeterminate]: indeterminateColor || colors.light
|
|
76
|
-
};
|
|
77
|
-
const iconsMap = {
|
|
78
|
-
[CheckboxStatus.Checked]: checkedIcon,
|
|
79
|
-
[CheckboxStatus.Unchecked]: uncheckedIcon,
|
|
80
|
-
[CheckboxStatus.Indeterminate]: indeterminateIcon
|
|
81
|
-
};
|
|
82
|
-
const checkboxColor = colorsMap[internalValue];
|
|
61
|
+
const checkboxColor = internalValue ? color || colors.primary : uncheckedColor || colors.primary;
|
|
83
62
|
|
|
84
63
|
const handlePress = () => {
|
|
85
|
-
setInternalValue(internalValue
|
|
86
|
-
onPress(internalValue
|
|
64
|
+
setInternalValue(!internalValue);
|
|
65
|
+
onPress(!internalValue);
|
|
87
66
|
};
|
|
88
67
|
|
|
89
68
|
return /*#__PURE__*/React.createElement(_Touchable.default, _extends({}, rest, {
|
|
@@ -100,7 +79,7 @@ const Checkbox = ({
|
|
|
100
79
|
}]
|
|
101
80
|
}), /*#__PURE__*/React.createElement(Icon, {
|
|
102
81
|
style: styles.icon,
|
|
103
|
-
name:
|
|
82
|
+
name: internalValue ? checkedIcon : uncheckedIcon,
|
|
104
83
|
size: size,
|
|
105
84
|
color: checkboxColor
|
|
106
85
|
}), /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Checkbox.tsx"],"names":["
|
|
1
|
+
{"version":3,"sources":["Checkbox.tsx"],"names":["Checkbox","Icon","status","disabled","onPress","color","uncheckedColor","initialValue","defaultValue","checkedIcon","uncheckedIcon","size","style","rest","internalValue","setInternalValue","React","useState","useEffect","previousInitialValue","colors","checkboxColor","primary","handlePress","styles","container","width","height","icon","StyleSheet","absoluteFill","fillContainer","fill","opacity","borderColor","create","borderRadius","alignItems","justifyContent","alignSelf"],"mappings":";;;;;;;AAAA;;AACA;;AAOA;;AAGA;;AACA;;;;;;;;;;AAgBA,MAAMA,QAAsE,GAC1E,CAAC;A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;AACJW,IAAAA,SAAS,EAAE;AADP,GARyB;AAW/BP,EAAAA,IAAI,EAAE;AACJI,IAAAA,YAAY,EAAE,CADV;AAEJV,IAAAA,KAAK,EAAE,EAFH;AAGJC,IAAAA,MAAM,EAAE,EAHJ;AAIJY,IAAAA,SAAS,EAAE;AAJP;AAXyB,CAAlB,CAAf;;eAmBevC,Q","sourcesContent":["import * as React from \"react\";\nimport {\n View,\n StyleSheet,\n TouchableHighlightProps,\n StyleProp,\n ViewStyle,\n} from \"react-native\";\nimport { useTheme } from \"../../theming\";\nimport type { IconSlot } from \"../../interfaces/Icon\";\n\nimport Touchable from \"../Touchable\";\nimport { usePrevious } from \"../../hooks\";\n\nexport interface CheckboxProps {\n status?: boolean;\n disabled?: boolean;\n onPress?: (checked: boolean) => void;\n color?: string;\n uncheckedColor?: string;\n checkedIcon?: string;\n uncheckedIcon?: string;\n initialValue?: boolean; // deprecated\n defaultValue?: boolean;\n size?: number;\n style?: StyleProp<ViewStyle>;\n}\n\nconst Checkbox: React.FC<CheckboxProps & TouchableHighlightProps & IconSlot> =\n ({\n Icon,\n status,\n disabled = false,\n onPress = () => {},\n color,\n uncheckedColor,\n initialValue,\n defaultValue,\n checkedIcon = \"MaterialCommunityIcons/checkbox-marked\",\n uncheckedIcon = \"MaterialCommunityIcons/checkbox-blank-outline\",\n size = 24,\n style,\n ...rest\n }) => {\n const [internalValue, setInternalValue] = React.useState<boolean>(\n status || defaultValue || false\n );\n\n React.useEffect(() => {\n if (status != null) {\n setInternalValue(status);\n }\n }, [status]);\n\n React.useEffect(() => {\n if (defaultValue != null) {\n setInternalValue(defaultValue);\n }\n }, [defaultValue]);\n\n const previousInitialValue = usePrevious(initialValue);\n React.useEffect(() => {\n if (initialValue !== previousInitialValue) {\n onPress(initialValue);\n }\n }, [initialValue, previousInitialValue, onPress]);\n const { colors } = useTheme();\n\n const checkboxColor = internalValue\n ? color || colors.primary\n : uncheckedColor || colors.primary;\n\n const handlePress = () => {\n setInternalValue(!internalValue);\n onPress(!internalValue);\n };\n\n return (\n <Touchable\n {...rest}\n onPress={handlePress}\n disabled={disabled}\n accessibilityState={{ disabled }}\n accessibilityRole=\"button\"\n accessibilityLiveRegion=\"polite\"\n style={[styles.container, style, { width: size, height: size }]}\n >\n <Icon\n style={styles.icon}\n name={internalValue ? checkedIcon : uncheckedIcon}\n size={size}\n color={checkboxColor}\n />\n <View style={[StyleSheet.absoluteFill, styles.fillContainer]}>\n <View\n style={[\n styles.fill,\n { opacity: disabled ? 0.5 : 1 },\n { borderColor: checkboxColor },\n ]}\n />\n </View>\n </Touchable>\n );\n };\n\nconst styles = StyleSheet.create({\n container: {\n borderRadius: 18,\n },\n fillContainer: {\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n icon: {\n alignSelf: \"center\",\n },\n fill: {\n borderRadius: 5,\n width: 30,\n height: 30,\n alignSelf: \"center\",\n },\n});\n\nexport default Checkbox;\n"]}
|
|
@@ -9,7 +9,7 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _reactNative = require("react-native");
|
|
11
11
|
|
|
12
|
-
var _Checkbox =
|
|
12
|
+
var _Checkbox = _interopRequireDefault(require("./Checkbox"));
|
|
13
13
|
|
|
14
14
|
var _Text = _interopRequireDefault(require("../Text"));
|
|
15
15
|
|
|
@@ -71,7 +71,6 @@ const CheckboxRow = ({
|
|
|
71
71
|
style,
|
|
72
72
|
color,
|
|
73
73
|
uncheckedColor,
|
|
74
|
-
indeterminateColor,
|
|
75
74
|
...rest
|
|
76
75
|
}) => {
|
|
77
76
|
const {
|
|
@@ -80,11 +79,11 @@ const CheckboxRow = ({
|
|
|
80
79
|
direction: parentDirection
|
|
81
80
|
} = (0, _context.useCheckboxGroupContext)();
|
|
82
81
|
const values = Array.isArray(selectedValues) ? selectedValues : [];
|
|
83
|
-
const isChecked = status
|
|
82
|
+
const isChecked = status || values.includes(value);
|
|
84
83
|
|
|
85
84
|
const handlePress = () => {
|
|
86
85
|
if (!disabled) {
|
|
87
|
-
onPress(
|
|
86
|
+
onPress(!isChecked);
|
|
88
87
|
onValueChange && onValueChange(value, !isChecked);
|
|
89
88
|
}
|
|
90
89
|
};
|
|
@@ -110,13 +109,12 @@ const CheckboxRow = ({
|
|
|
110
109
|
}
|
|
111
110
|
}, /*#__PURE__*/React.createElement(_Checkbox.default, {
|
|
112
111
|
Icon: Icon,
|
|
113
|
-
status: status || values.includes(value)
|
|
112
|
+
status: status || values.includes(value),
|
|
114
113
|
onPress: handlePress,
|
|
115
114
|
style: checkboxStyle,
|
|
116
115
|
disabled: disabled,
|
|
117
116
|
color: color,
|
|
118
|
-
uncheckedColor: uncheckedColor
|
|
119
|
-
indeterminateColor: indeterminateColor
|
|
117
|
+
uncheckedColor: uncheckedColor
|
|
120
118
|
})));
|
|
121
119
|
};
|
|
122
120
|
|
|
@@ -165,8 +163,8 @@ const SEED_DATA = {
|
|
|
165
163
|
}),
|
|
166
164
|
direction: (0, _types.createRowDirectionProp)(),
|
|
167
165
|
fieldName: (0, _types.createFieldNameProp)({
|
|
168
|
-
defaultValue: "
|
|
169
|
-
valuePropName: "
|
|
166
|
+
defaultValue: "checkboxValue",
|
|
167
|
+
valuePropName: "value",
|
|
170
168
|
handlerPropName: "onPress"
|
|
171
169
|
}),
|
|
172
170
|
color: (0, _types.createColorProp)({
|
|
@@ -175,10 +173,6 @@ const SEED_DATA = {
|
|
|
175
173
|
uncheckedColor: (0, _types.createColorProp)({
|
|
176
174
|
label: "Unselected Color",
|
|
177
175
|
description: "Color for the button when the checkbox is unchecked"
|
|
178
|
-
}),
|
|
179
|
-
indeterminateColor: (0, _types.createColorProp)({
|
|
180
|
-
label: "Indeterminate Color",
|
|
181
|
-
description: "Color for the button when the checkbox is indeterminate"
|
|
182
176
|
})
|
|
183
177
|
}
|
|
184
178
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CheckboxRow.tsx"],"names":["Direction","getCheckboxAlignment","parentDirection","direction","GroupDirection","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","CheckboxStatus","Checked","includes","handlePress","textStyles","viewStyles","styles","mainParent","flexDirection","alignItems","flex","Unchecked","StyleSheet","create","justifyContent","paddingStart","minHeight","paddingEnd","Platform","select","web","cursor","userSelect","SEED_DATA","name","tag","category","COMPONENT_TYPES","input","layout","triggers","Triggers","OnPress","props","description","required","defaultValue","editable","fieldName","valuePropName","handlerPropName"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AAWA;;AACA;;;;;;;;;;IAEYA,S;;;WAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,yBAAAA,S;;AAkBZ,MAAMC,oBAAoB,GAAG,CAC3BC,eAD2B,EAE3BC,SAF2B,KAGxB;AACH,MAAID,eAAe,KAAKE,mBAAeC,UAAvC,EAAmD;AACjD,WAAOF,SAAS,KAAKH,SAAS,CAACM,GAAxB,GAA8B,YAA9B,GAA6C,UAApD;AACD,GAFD,MAEO,IAAIH,SAAS,KAAKH,SAAS,CAACO,UAA5B,EAAwC;AAC7C,WAAO,YAAP;AACD,GAFM,MAEA;AACL,WAAO,UAAP;AACD;AACF,CAXD;;AAaA,MAAMC,WAAW,GAAG,CAClBC,KADkB,EAElBC,UAFkB,EAGlBC,SAHkB,KAIf;AACH,MAAI,OAAOF,KAAP,KAAiB,QAArB,EAA+B;AAC7B,wBAAO,oBAAC,aAAD;AAAM,MAAA,KAAK,EAAE,CAACC,UAAD,EAAaC,SAAb;AAAb,OAAuCF,KAAvC,CAAP;AACD,GAFD,MAEO;AACL,wBAAO,0CAAGA,KAAH,CAAP;AACD;AACF,CAVD;;AAYA,MAAMG,WAAkD,GAAG,CAAC;AAC1DC,EAAAA,IAD0D;AAE1DC,EAAAA,KAAK,GAAG,OAFk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leProp,\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":["Direction","getCheckboxAlignment","parentDirection","direction","GroupDirection","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","StyleSheet","create","justifyContent","paddingStart","minHeight","paddingEnd","Platform","select","web","cursor","userSelect","SEED_DATA","name","tag","category","COMPONENT_TYPES","input","layout","triggers","Triggers","OnPress","props","description","required","defaultValue","editable","fieldName","valuePropName","handlerPropName"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AAWA;;AACA;;;;;;;;;;IAEYA,S;;;WAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,yBAAAA,S;;AAiBZ,MAAMC,oBAAoB,GAAG,CAC3BC,eAD2B,EAE3BC,SAF2B,KAGxB;AACH,MAAID,eAAe,KAAKE,mBAAeC,UAAvC,EAAmD;AACjD,WAAOF,SAAS,KAAKH,SAAS,CAACM,GAAxB,GAA8B,YAA9B,GAA6C,UAApD;AACD,GAFD,MAEO,IAAIH,SAAS,KAAKH,SAAS,CAACO,UAA5B,EAAwC;AAC7C,WAAO,YAAP;AACD,GAFM,MAEA;AACL,WAAO,UAAP;AACD;AACF,CAXD;;AAaA,MAAMC,WAAW,GAAG,CAClBC,KADkB,EAElBC,UAFkB,EAGlBC,SAHkB,KAIf;AACH,MAAI,OAAOF,KAA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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"]}
|
|
@@ -86,6 +86,7 @@ function Row({
|
|
|
86
86
|
direction = _types.RowDirection.Row,
|
|
87
87
|
style,
|
|
88
88
|
value,
|
|
89
|
+
defaultValue,
|
|
89
90
|
disabled,
|
|
90
91
|
onValueChange,
|
|
91
92
|
activeTrackColor,
|
|
@@ -95,7 +96,7 @@ function Row({
|
|
|
95
96
|
theme,
|
|
96
97
|
...rest
|
|
97
98
|
}) {
|
|
98
|
-
const [checked, setChecked] = React.useState(value);
|
|
99
|
+
const [checked, setChecked] = React.useState(value || defaultValue);
|
|
99
100
|
React.useEffect(() => {
|
|
100
101
|
if (value !== checked) {
|
|
101
102
|
setChecked(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Switch.tsx"],"names":["Switch","value","initialValue","defaultValue","disabled","onValueChange","activeTrackColor","inactiveTrackColor","activeThumbColor","inactiveThumbColor","theme","style","rest","activeTrackThemeColor","colors","primary","inactiveTrackThemeColor","activeThumbThemeColor","inactiveThumbThemeColor","checked","setChecked","React","useState","useEffect","booleanInitialValue","Boolean","previousInitialValue","false","true","bool","Row","label","direction","RowDirection","SwitchRow"],"mappings":";;;;;;;AAAA;;AACA;;AAMA;;AACA;;AACA;;AAEA;;;;;;;;;;AAeA,SAASA,MAAT,CAAgB;AACdC,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,uBA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Z,KAAK,GAAGgB,qBAAH,GAA2BC,uBAP9C,CAQE;AARF;AASE,IAAA,gBAAgB,EAAED,qBATpB;AAUE,IAAA,mBAAmB,EAAED,uBAVvB;AAWE,IAAA,KAAK,EAAEL,KAXT;AAYE,IAAA,aAAa,EAAGkB,IAAD,IAAU;AACvBT,MAAAA,UAAU,CAACS,IAAD,CAAV;AACAxB,MAAAA,aAAa,IAAIA,aAAa,CAACwB,IAAD,CAA9B;AACD;AAfH,KAgBMjB,IAhBN,EADF;AAoBD;;AAQD,SAASkB,GAAT,CAAa;AACXC,EAAAA,KAAK,GAAG,OADG;AAEXC,EAAAA,SAAS,GAAGC,oBAAaH,GAFd;AAGXnB,EAAAA,KAHW;AAIXV,EAAAA,KAJW;
|
|
1
|
+
{"version":3,"sources":["Switch.tsx"],"names":["Switch","value","initialValue","defaultValue","disabled","onValueChange","activeTrackColor","inactiveTrackColor","activeThumbColor","inactiveThumbColor","theme","style","rest","activeTrackThemeColor","colors","primary","inactiveTrackThemeColor","activeThumbThemeColor","inactiveThumbThemeColor","checked","setChecked","React","useState","useEffect","booleanInitialValue","Boolean","previousInitialValue","false","true","bool","Row","label","direction","RowDirection","SwitchRow"],"mappings":";;;;;;;AAAA;;AACA;;AAMA;;AACA;;AACA;;AAEA;;;;;;;;;;AAeA,SAASA,MAAT,CAAgB;AACdC,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,GAAG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E,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,MAAMyB,SAAS,GAAG,wBAAUJ,GAAV,CAAlB;;;eAEe,wBAAU9B,MAAV,C;AAEf;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/commonjs/index.js
CHANGED
|
@@ -237,24 +237,6 @@ Object.defineProperty(exports, "SwiperItem", {
|
|
|
237
237
|
return _Swiper.SwiperItem;
|
|
238
238
|
}
|
|
239
239
|
});
|
|
240
|
-
Object.defineProperty(exports, "MapView", {
|
|
241
|
-
enumerable: true,
|
|
242
|
-
get: function () {
|
|
243
|
-
return _MapView.MapView;
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
Object.defineProperty(exports, "MapMarker", {
|
|
247
|
-
enumerable: true,
|
|
248
|
-
get: function () {
|
|
249
|
-
return _MapView.MapMarker;
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
Object.defineProperty(exports, "MapCallout", {
|
|
253
|
-
enumerable: true,
|
|
254
|
-
get: function () {
|
|
255
|
-
return _MapView.MapCallout;
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
240
|
Object.defineProperty(exports, "Center", {
|
|
259
241
|
enumerable: true,
|
|
260
242
|
get: function () {
|
|
@@ -482,8 +464,6 @@ var _ActionSheet = require("./components/ActionSheet");
|
|
|
482
464
|
|
|
483
465
|
var _Swiper = require("./components/Swiper");
|
|
484
466
|
|
|
485
|
-
var _MapView = require("./components/MapView");
|
|
486
|
-
|
|
487
467
|
var _Layout = require("./components/Layout");
|
|
488
468
|
|
|
489
469
|
var _index = require("./components/RadioButton/index");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAEA;;AASA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","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"]}
|
|
@@ -30,12 +30,6 @@ const SEED_DATA = {
|
|
|
30
30
|
description: "Color for the button when the checkbox is unchecked",
|
|
31
31
|
defaultValue: null
|
|
32
32
|
}),
|
|
33
|
-
indeterminateColor: (0, _types.createColorProp)({
|
|
34
|
-
group: _types.GROUPS.basic,
|
|
35
|
-
label: "Indeterminate Color",
|
|
36
|
-
description: "Color for the button when the checkbox is indeterminate",
|
|
37
|
-
defaultValue: null
|
|
38
|
-
}),
|
|
39
33
|
disabled: (0, _types.createBoolProp)({
|
|
40
34
|
label: "Disabled",
|
|
41
35
|
description: "Whether the checkbox is disabled"
|
|
@@ -54,11 +48,6 @@ const SEED_DATA = {
|
|
|
54
48
|
label: "Unchecked Icon",
|
|
55
49
|
description: 'Icon to show when the checkbox status is "unchecked"',
|
|
56
50
|
defaultValue: null
|
|
57
|
-
}),
|
|
58
|
-
indeterminateIcon: (0, _types.createIconProp)({
|
|
59
|
-
label: "Indeterminate Icon",
|
|
60
|
-
description: 'Icon to show when the checkbox status is "indeterminate"',
|
|
61
|
-
defaultValue: null
|
|
62
51
|
})
|
|
63
52
|
}
|
|
64
53
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Checkbox.js"],"names":["SEED_DATA","name","tag","category","COMPONENT_TYPES","input","triggers","Triggers","OnPress","props","fieldName","defaultValue","valuePropName","handlerPropName","color","group","GROUPS","basic","label","description","uncheckedColor","
|
|
1
|
+
{"version":3,"sources":["Checkbox.js"],"names":["SEED_DATA","name","tag","category","COMPONENT_TYPES","input","triggers","Triggers","OnPress","props","fieldName","defaultValue","valuePropName","handlerPropName","color","group","GROUPS","basic","label","description","uncheckedColor","disabled","size","checkedIcon","uncheckedIcon"],"mappings":";;;;;;;AAAA;;AAWO,MAAMA,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,UADiB;AAEvBC,EAAAA,GAAG,EAAE,UAFkB;AAGvBC,EAAAA,QAAQ,EAAEC,uBAAgBC,KAHH;AAIvBC,EAAAA,QAAQ,EAAE,CAACC,gBAASC,OAAV,CAJa;AAKvBC,EAAAA,KAAK,EAAE;AACLC,IAAAA,SAAS,EAAE,gCAAoB;AAC7BC,MAAAA,YAAY,EAAE,eADe;AAE7BC,MAAAA,aAAa,EAAE,QAFc;AAG7BC,MAAAA,eAAe,EAAE;AAHY,KAApB,CADN;AAMLC,IAAAA,KAAK,EAAE,4BAAgB;AACrBC,MAAAA,KAAK,EAAEC,cAAOC,KADO;AAErBC,MAAAA,KAAK,EAAE,OAFc;AAGrBC,MAAAA,WAAW,EAAE,0DAHQ;AAIrBR,MAAAA,YAAY,EAAE;AAJO,KAAhB,CANF;AAYLS,IAAAA,cAAc,EAAE,4BAAgB;AAC9BL,MAAAA,KAAK,EAAEC,cAAOC,KADgB;AAE9BC,MAAAA,KAAK,EAAE,kBAFuB;AAG9BC,MAAAA,WAAW,EAAE,qDAHiB;AAI9BR,MAAAA,YAAY,EAAE;AAJgB,KAAhB,CAZX;AAkBLU,IAAAA,QAAQ,EAAE,2BAAe;AACvBH,MAAAA,KAAK,EAAE,UADgB;AAEvBC,MAAAA,WAAW,EAAE;AAFU,KAAf,CAlBL;AAsBLG,IAAAA,IAAI,EAAE,mCAAuB;AAC3BJ,MAAAA,KAAK,EAAE,MADoB;AAE3BC,MAAAA,WAAW,EAAE,gCAFc;AAG3BR,MAAAA,YAAY,EAAE;AAHa,KAAvB,CAtBD;AA2BLY,IAAAA,WAAW,EAAE,2BAAe;AAC1BL,MAAAA,KAAK,EAAE,cADmB;AAE1BC,MAAAA,WAAW,EAAE,oDAFa;AAG1BR,MAAAA,YAAY,EAAE;AAHY,KAAf,CA3BR;AAgCLa,IAAAA,aAAa,EAAE,2BAAe;AAC5BN,MAAAA,KAAK,EAAE,gBADqB;AAE5BC,MAAAA,WAAW,EAAE,sDAFe;AAG5BR,MAAAA,YAAY,EAAE;AAHc,KAAf;AAhCV;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"]}
|
|
@@ -5,13 +5,6 @@ import { View, StyleSheet } from "react-native";
|
|
|
5
5
|
import { useTheme } from "../../theming";
|
|
6
6
|
import Touchable from "../Touchable";
|
|
7
7
|
import { usePrevious } from "../../hooks";
|
|
8
|
-
export let CheckboxStatus;
|
|
9
|
-
|
|
10
|
-
(function (CheckboxStatus) {
|
|
11
|
-
CheckboxStatus["Checked"] = "checked";
|
|
12
|
-
CheckboxStatus["Unchecked"] = "unchecked";
|
|
13
|
-
CheckboxStatus["Indeterminate"] = "indeterminate";
|
|
14
|
-
})(CheckboxStatus || (CheckboxStatus = {}));
|
|
15
8
|
|
|
16
9
|
const Checkbox = ({
|
|
17
10
|
Icon,
|
|
@@ -20,17 +13,15 @@ const Checkbox = ({
|
|
|
20
13
|
onPress = () => {},
|
|
21
14
|
color,
|
|
22
15
|
uncheckedColor,
|
|
23
|
-
indeterminateColor,
|
|
24
16
|
initialValue,
|
|
25
17
|
defaultValue,
|
|
26
18
|
checkedIcon = "MaterialCommunityIcons/checkbox-marked",
|
|
27
19
|
uncheckedIcon = "MaterialCommunityIcons/checkbox-blank-outline",
|
|
28
|
-
indeterminateIcon = "AntDesign/minussquareo",
|
|
29
20
|
size = 24,
|
|
30
21
|
style,
|
|
31
22
|
...rest
|
|
32
23
|
}) => {
|
|
33
|
-
const [internalValue, setInternalValue] = React.useState(status || defaultValue ||
|
|
24
|
+
const [internalValue, setInternalValue] = React.useState(status || defaultValue || false);
|
|
34
25
|
React.useEffect(() => {
|
|
35
26
|
if (status != null) {
|
|
36
27
|
setInternalValue(status);
|
|
@@ -50,21 +41,11 @@ const Checkbox = ({
|
|
|
50
41
|
const {
|
|
51
42
|
colors
|
|
52
43
|
} = useTheme();
|
|
53
|
-
const
|
|
54
|
-
[CheckboxStatus.Checked]: color || colors.primary,
|
|
55
|
-
[CheckboxStatus.Unchecked]: uncheckedColor || colors.primary,
|
|
56
|
-
[CheckboxStatus.Indeterminate]: indeterminateColor || colors.light
|
|
57
|
-
};
|
|
58
|
-
const iconsMap = {
|
|
59
|
-
[CheckboxStatus.Checked]: checkedIcon,
|
|
60
|
-
[CheckboxStatus.Unchecked]: uncheckedIcon,
|
|
61
|
-
[CheckboxStatus.Indeterminate]: indeterminateIcon
|
|
62
|
-
};
|
|
63
|
-
const checkboxColor = colorsMap[internalValue];
|
|
44
|
+
const checkboxColor = internalValue ? color || colors.primary : uncheckedColor || colors.primary;
|
|
64
45
|
|
|
65
46
|
const handlePress = () => {
|
|
66
|
-
setInternalValue(internalValue
|
|
67
|
-
onPress(internalValue
|
|
47
|
+
setInternalValue(!internalValue);
|
|
48
|
+
onPress(!internalValue);
|
|
68
49
|
};
|
|
69
50
|
|
|
70
51
|
return /*#__PURE__*/React.createElement(Touchable, _extends({}, rest, {
|
|
@@ -81,7 +62,7 @@ const Checkbox = ({
|
|
|
81
62
|
}]
|
|
82
63
|
}), /*#__PURE__*/React.createElement(Icon, {
|
|
83
64
|
style: styles.icon,
|
|
84
|
-
name:
|
|
65
|
+
name: internalValue ? checkedIcon : uncheckedIcon,
|
|
85
66
|
size: size,
|
|
86
67
|
color: checkboxColor
|
|
87
68
|
}), /*#__PURE__*/React.createElement(View, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Checkbox.tsx"],"names":["React","View","StyleSheet","useTheme","Touchable","usePrevious","
|
|
1
|
+
{"version":3,"sources":["Checkbox.tsx"],"names":["React","View","StyleSheet","useTheme","Touchable","usePrevious","Checkbox","Icon","status","disabled","onPress","color","uncheckedColor","initialValue","defaultValue","checkedIcon","uncheckedIcon","size","style","rest","internalValue","setInternalValue","useState","useEffect","previousInitialValue","colors","checkboxColor","primary","handlePress","styles","container","width","height","icon","absoluteFill","fillContainer","fill","opacity","borderColor","create","borderRadius","alignItems","justifyContent","alignSelf"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,IADF,EAEEC,UAFF,QAMO,cANP;AAOA,SAASC,QAAT,QAAyB,eAAzB;AAGA,OAAOC,SAAP,MAAsB,cAAtB;AACA,SAASC,WAAT,QAA4B,aAA5B;;AAgBA,MAAMC,QAAsE,GAC1E,CAAC;AACCC,EAAAA,IADD;AAECC,EAAAA,MAFD;AAGCC,EAAAA,QAAQ,GAAG,KAHZ;AAICC,EAAAA,OAAO,GAAG,MAAM,CAAE,CAJnB;AAKCC,EAAAA,KALD;AAMCC,EAAAA,cAND;AAOCC,EAAAA,YAPD;AAQCC,EAAAA,YARD;AASCC,EAAAA,WAAW,GAAG,wCATf;AAUCC,EAAAA,aAAa,GAAG,+CAVjB;AAWCC,EAAAA,IAAI,GAAG,EAXR;AAYCC,EAAAA,KAZD;AAaC,KAAGC;AAbJ,CAAD,KAcM;AACJ,QAAM,CAACC,aAAD,EAAgBC,gBAAhB,IAAoCrB,KAAK,CAACsB,QAAN,CACxCd,MAAM,IAAIM,YAAV,IAA0B,KADc,CAA1C;AAIAd,EAAAA,KAAK,CAACuB,SAAN,CAAgB,MAAM;AACpB,QAAIf,MAAM,IAAI,IAAd,EAAoB;AAClBa,MAAAA,gBAAgB,CAACb,MAAD,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Aa,GAAGL,WAAH,GAAiBC,aAFtC;AAGE,IAAA,IAAI,EAAEC,IAHR;AAIE,IAAA,KAAK,EAAES;AAJT,IATF,eAeE,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAE,CAACxB,UAAU,CAACgC,YAAZ,EAA0BL,MAAM,CAACM,aAAjC;AAAb,kBACE,oBAAC,IAAD;AACE,IAAA,KAAK,EAAE,CACLN,MAAM,CAACO,IADF,EAEL;AAAEC,MAAAA,OAAO,EAAE5B,QAAQ,GAAG,GAAH,GAAS;AAA5B,KAFK,EAGL;AAAE6B,MAAAA,WAAW,EAAEZ;AAAf,KAHK;AADT,IADF,CAfF,CADF;AA2BD,CA5EH;;AA8EA,MAAMG,MAAM,GAAG3B,UAAU,CAACqC,MAAX,CAAkB;AAC/BT,EAAAA,SAAS,EAAE;AACTU,IAAAA,YAAY,EAAE;AADL,GADoB;AAI/BL,EAAAA,aAAa,EAAE;AACbM,IAAAA,UAAU,EAAE,QADC;AAEbC,IAAAA,cAAc,EAAE;AAFH,GAJgB;AAQ/BT,EAAAA,IAAI,EAAE;AACJU,IAAAA,SAAS,EAAE;AADP,GARyB;AAW/BP,EAAAA,IAAI,EAAE;AACJI,IAAAA,YAAY,EAAE,CADV;AAEJT,IAAAA,KAAK,EAAE,EAFH;AAGJC,IAAAA,MAAM,EAAE,EAHJ;AAIJW,IAAAA,SAAS,EAAE;AAJP;AAXyB,CAAlB,CAAf;AAmBA,eAAerC,QAAf","sourcesContent":["import * as React from \"react\";\nimport {\n View,\n StyleSheet,\n TouchableHighlightProps,\n StyleProp,\n ViewStyle,\n} from \"react-native\";\nimport { useTheme } from \"../../theming\";\nimport type { IconSlot } from \"../../interfaces/Icon\";\n\nimport Touchable from \"../Touchable\";\nimport { usePrevious } from \"../../hooks\";\n\nexport interface CheckboxProps {\n status?: boolean;\n disabled?: boolean;\n onPress?: (checked: boolean) => void;\n color?: string;\n uncheckedColor?: string;\n checkedIcon?: string;\n uncheckedIcon?: string;\n initialValue?: boolean; // deprecated\n defaultValue?: boolean;\n size?: number;\n style?: StyleProp<ViewStyle>;\n}\n\nconst Checkbox: React.FC<CheckboxProps & TouchableHighlightProps & IconSlot> =\n ({\n Icon,\n status,\n disabled = false,\n onPress = () => {},\n color,\n uncheckedColor,\n initialValue,\n defaultValue,\n checkedIcon = \"MaterialCommunityIcons/checkbox-marked\",\n uncheckedIcon = \"MaterialCommunityIcons/checkbox-blank-outline\",\n size = 24,\n style,\n ...rest\n }) => {\n const [internalValue, setInternalValue] = React.useState<boolean>(\n status || defaultValue || false\n );\n\n React.useEffect(() => {\n if (status != null) {\n setInternalValue(status);\n }\n }, [status]);\n\n React.useEffect(() => {\n if (defaultValue != null) {\n setInternalValue(defaultValue);\n }\n }, [defaultValue]);\n\n const previousInitialValue = usePrevious(initialValue);\n React.useEffect(() => {\n if (initialValue !== previousInitialValue) {\n onPress(initialValue);\n }\n }, [initialValue, previousInitialValue, onPress]);\n const { colors } = useTheme();\n\n const checkboxColor = internalValue\n ? color || colors.primary\n : uncheckedColor || colors.primary;\n\n const handlePress = () => {\n setInternalValue(!internalValue);\n onPress(!internalValue);\n };\n\n return (\n <Touchable\n {...rest}\n onPress={handlePress}\n disabled={disabled}\n accessibilityState={{ disabled }}\n accessibilityRole=\"button\"\n accessibilityLiveRegion=\"polite\"\n style={[styles.container, style, { width: size, height: size }]}\n >\n <Icon\n style={styles.icon}\n name={internalValue ? checkedIcon : uncheckedIcon}\n size={size}\n color={checkboxColor}\n />\n <View style={[StyleSheet.absoluteFill, styles.fillContainer]}>\n <View\n style={[\n styles.fill,\n { opacity: disabled ? 0.5 : 1 },\n { borderColor: checkboxColor },\n ]}\n />\n </View>\n </Touchable>\n );\n };\n\nconst styles = StyleSheet.create({\n container: {\n borderRadius: 18,\n },\n fillContainer: {\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n icon: {\n alignSelf: \"center\",\n },\n fill: {\n borderRadius: 5,\n width: 30,\n height: 30,\n alignSelf: \"center\",\n },\n});\n\nexport default Checkbox;\n"]}
|
|
@@ -2,7 +2,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { StyleSheet, View, Platform } from "react-native";
|
|
5
|
-
import Checkbox
|
|
5
|
+
import Checkbox from "./Checkbox";
|
|
6
6
|
import Text from "../Text";
|
|
7
7
|
import { useCheckboxGroupContext } from "./context";
|
|
8
8
|
import { createTextProp, createTextStyle, createRowDirectionProp, createFieldNameProp, COMPONENT_TYPES, Triggers, createColorProp } from "@draftbit/types";
|
|
@@ -50,7 +50,6 @@ const CheckboxRow = ({
|
|
|
50
50
|
style,
|
|
51
51
|
color,
|
|
52
52
|
uncheckedColor,
|
|
53
|
-
indeterminateColor,
|
|
54
53
|
...rest
|
|
55
54
|
}) => {
|
|
56
55
|
const {
|
|
@@ -59,11 +58,11 @@ const CheckboxRow = ({
|
|
|
59
58
|
direction: parentDirection
|
|
60
59
|
} = useCheckboxGroupContext();
|
|
61
60
|
const values = Array.isArray(selectedValues) ? selectedValues : [];
|
|
62
|
-
const isChecked = status
|
|
61
|
+
const isChecked = status || values.includes(value);
|
|
63
62
|
|
|
64
63
|
const handlePress = () => {
|
|
65
64
|
if (!disabled) {
|
|
66
|
-
onPress(
|
|
65
|
+
onPress(!isChecked);
|
|
67
66
|
onValueChange && onValueChange(value, !isChecked);
|
|
68
67
|
}
|
|
69
68
|
};
|
|
@@ -89,13 +88,12 @@ const CheckboxRow = ({
|
|
|
89
88
|
}
|
|
90
89
|
}, /*#__PURE__*/React.createElement(Checkbox, {
|
|
91
90
|
Icon: Icon,
|
|
92
|
-
status: status || values.includes(value)
|
|
91
|
+
status: status || values.includes(value),
|
|
93
92
|
onPress: handlePress,
|
|
94
93
|
style: checkboxStyle,
|
|
95
94
|
disabled: disabled,
|
|
96
95
|
color: color,
|
|
97
|
-
uncheckedColor: uncheckedColor
|
|
98
|
-
indeterminateColor: indeterminateColor
|
|
96
|
+
uncheckedColor: uncheckedColor
|
|
99
97
|
})));
|
|
100
98
|
};
|
|
101
99
|
|
|
@@ -142,8 +140,8 @@ export const SEED_DATA = {
|
|
|
142
140
|
}),
|
|
143
141
|
direction: createRowDirectionProp(),
|
|
144
142
|
fieldName: createFieldNameProp({
|
|
145
|
-
defaultValue: "
|
|
146
|
-
valuePropName: "
|
|
143
|
+
defaultValue: "checkboxValue",
|
|
144
|
+
valuePropName: "value",
|
|
147
145
|
handlerPropName: "onPress"
|
|
148
146
|
}),
|
|
149
147
|
color: createColorProp({
|
|
@@ -152,10 +150,6 @@ export const SEED_DATA = {
|
|
|
152
150
|
uncheckedColor: createColorProp({
|
|
153
151
|
label: "Unselected Color",
|
|
154
152
|
description: "Color for the button when the checkbox is unchecked"
|
|
155
|
-
}),
|
|
156
|
-
indeterminateColor: createColorProp({
|
|
157
|
-
label: "Indeterminate Color",
|
|
158
|
-
description: "Color for the button when the checkbox is indeterminate"
|
|
159
153
|
})
|
|
160
154
|
}
|
|
161
155
|
};
|