@draftbit/core 46.10.2-b59d51.2 → 46.10.2-f194c1.2
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/FAB.js +4 -18
- package/lib/commonjs/components/Picker/Picker.js +13 -3
- package/lib/module/components/Picker/Picker.js +13 -3
- package/lib/typescript/src/components/Picker/Picker.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/Picker/Picker.js +12 -3
- package/src/components/Picker/Picker.tsx +12 -3
|
@@ -9,6 +9,7 @@ var _reactNative = require("react-native");
|
|
|
9
9
|
var _theming = require("../theming");
|
|
10
10
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
11
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
12
13
|
const FAB = _ref => {
|
|
13
14
|
let {
|
|
14
15
|
onPress,
|
|
@@ -32,7 +33,7 @@ const FAB = _ref => {
|
|
|
32
33
|
borderRadius: size / 2,
|
|
33
34
|
overflow: "hidden"
|
|
34
35
|
}, style]
|
|
35
|
-
}, /*#__PURE__*/React.createElement(_reactNative.Pressable, {
|
|
36
|
+
}, /*#__PURE__*/React.createElement(_reactNative.Pressable, _extends({
|
|
36
37
|
onPress: onPress,
|
|
37
38
|
disabled: loading || disabled,
|
|
38
39
|
android_ripple: {
|
|
@@ -50,9 +51,8 @@ const FAB = _ref => {
|
|
|
50
51
|
borderRadius: size / 2,
|
|
51
52
|
backgroundColor
|
|
52
53
|
}];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
}, /*#__PURE__*/React.createElement(_reactNative.View, null, loading ? /*#__PURE__*/React.createElement(_reactNative.ActivityIndicator, {
|
|
54
|
+
}
|
|
55
|
+
}, props), /*#__PURE__*/React.createElement(_reactNative.View, null, loading ? /*#__PURE__*/React.createElement(_reactNative.ActivityIndicator, {
|
|
56
56
|
style: size > 50 ? {
|
|
57
57
|
marginTop: 2,
|
|
58
58
|
marginLeft: 2
|
|
@@ -79,18 +79,4 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
81
|
var _default = (0, _theming.withTheme)(FAB);
|
|
82
|
-
exports.default = _default; styles = _reactNative.StyleSheet.create({
|
|
83
|
-
button: {
|
|
84
|
-
backgroundColor: "#5a45ff",
|
|
85
|
-
justifyContent: "center",
|
|
86
|
-
alignItems: "center",
|
|
87
|
-
..._reactNative.Platform.select({
|
|
88
|
-
web: {
|
|
89
|
-
cursor: "pointer",
|
|
90
|
-
userSelect: "none"
|
|
91
|
-
}
|
|
92
|
-
})
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
var _default = (0, _theming.withTheme)(FAB);
|
|
96
82
|
exports.default = _default;
|
|
@@ -58,7 +58,7 @@ const Picker = _ref => {
|
|
|
58
58
|
defaultValue,
|
|
59
59
|
Icon,
|
|
60
60
|
style,
|
|
61
|
-
placeholder,
|
|
61
|
+
placeholder = "Select an option",
|
|
62
62
|
value,
|
|
63
63
|
disabled = false,
|
|
64
64
|
assistiveText,
|
|
@@ -99,7 +99,14 @@ const Picker = _ref => {
|
|
|
99
99
|
_reactNative.Keyboard.dismiss();
|
|
100
100
|
}
|
|
101
101
|
}, [pickerVisible, autoDismissKeyboard]);
|
|
102
|
-
const
|
|
102
|
+
const normalizedOptions = normalizeOptions(options);
|
|
103
|
+
|
|
104
|
+
//Underlying Picker component defaults selection to first element when value is not provided (or undefined)
|
|
105
|
+
//Placholder must be the 1st option in order to allow selection of the 'actual' 1st option
|
|
106
|
+
const pickerOptions = placeholder ? [{
|
|
107
|
+
label: placeholder,
|
|
108
|
+
value: placeholder
|
|
109
|
+
}, ...normalizedOptions] : normalizedOptions;
|
|
103
110
|
const {
|
|
104
111
|
viewStyles,
|
|
105
112
|
textStyles
|
|
@@ -199,9 +206,12 @@ const Picker = _ref => {
|
|
|
199
206
|
} : {})
|
|
200
207
|
};
|
|
201
208
|
const handleValueChange = (newValue, itemIndex) => {
|
|
202
|
-
if (newValue !== "") {
|
|
209
|
+
if (newValue !== "" && newValue !== placeholder) {
|
|
203
210
|
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue, itemIndex);
|
|
204
211
|
setInternalValue(newValue);
|
|
212
|
+
} else if (newValue === placeholder) {
|
|
213
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange("", 0);
|
|
214
|
+
setInternalValue(undefined);
|
|
205
215
|
}
|
|
206
216
|
};
|
|
207
217
|
return (
|
|
@@ -49,7 +49,7 @@ const Picker = _ref => {
|
|
|
49
49
|
defaultValue,
|
|
50
50
|
Icon,
|
|
51
51
|
style,
|
|
52
|
-
placeholder,
|
|
52
|
+
placeholder = "Select an option",
|
|
53
53
|
value,
|
|
54
54
|
disabled = false,
|
|
55
55
|
assistiveText,
|
|
@@ -90,7 +90,14 @@ const Picker = _ref => {
|
|
|
90
90
|
Keyboard.dismiss();
|
|
91
91
|
}
|
|
92
92
|
}, [pickerVisible, autoDismissKeyboard]);
|
|
93
|
-
const
|
|
93
|
+
const normalizedOptions = normalizeOptions(options);
|
|
94
|
+
|
|
95
|
+
//Underlying Picker component defaults selection to first element when value is not provided (or undefined)
|
|
96
|
+
//Placholder must be the 1st option in order to allow selection of the 'actual' 1st option
|
|
97
|
+
const pickerOptions = placeholder ? [{
|
|
98
|
+
label: placeholder,
|
|
99
|
+
value: placeholder
|
|
100
|
+
}, ...normalizedOptions] : normalizedOptions;
|
|
94
101
|
const {
|
|
95
102
|
viewStyles,
|
|
96
103
|
textStyles
|
|
@@ -190,9 +197,12 @@ const Picker = _ref => {
|
|
|
190
197
|
} : {})
|
|
191
198
|
};
|
|
192
199
|
const handleValueChange = (newValue, itemIndex) => {
|
|
193
|
-
if (newValue !== "") {
|
|
200
|
+
if (newValue !== "" && newValue !== placeholder) {
|
|
194
201
|
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue, itemIndex);
|
|
195
202
|
setInternalValue(newValue);
|
|
203
|
+
} else if (newValue === placeholder) {
|
|
204
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange("", 0);
|
|
205
|
+
setInternalValue(undefined);
|
|
196
206
|
}
|
|
197
207
|
};
|
|
198
208
|
return (
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../../../src/components/Picker/Picker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAKL,SAAS,EACT,SAAS,EAGV,MAAM,cAAc,CAAC;AAStB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAQtD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,E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
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@date-io/date-fns": "^1.3.13",
|
|
43
43
|
"@draftbit/react-theme-provider": "^2.1.1",
|
|
44
|
-
"@draftbit/types": "^46.10.2-
|
|
44
|
+
"@draftbit/types": "^46.10.2-f194c1.2+f194c16",
|
|
45
45
|
"@material-ui/core": "^4.11.0",
|
|
46
46
|
"@material-ui/pickers": "^3.2.10",
|
|
47
47
|
"@react-native-community/slider": "4.2.3",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
]
|
|
101
101
|
]
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "f194c16dea96d8bb44c344af38b9bf75f1da664f"
|
|
104
104
|
}
|
|
@@ -38,7 +38,7 @@ const disabledColor = "rgb(240, 240, 240)";
|
|
|
38
38
|
const errorColor = "rgba(255, 69, 100, 1)";
|
|
39
39
|
//Empty string for 'value' is treated as a non-value
|
|
40
40
|
//reason: Draftbit uses empty string as initial value for string state*/
|
|
41
|
-
const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style, placeholder, value, disabled = false, assistiveText, label, iconColor = unstyledColor, iconSize = 24, leftIconMode = "inset", leftIconName, placeholderTextColor = unstyledColor, rightIconName, type = "solid", autoDismissKeyboard = true, }) => {
|
|
41
|
+
const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style, placeholder = "Select an option", value, disabled = false, assistiveText, label, iconColor = unstyledColor, iconSize = 24, leftIconMode = "inset", leftIconName, placeholderTextColor = unstyledColor, rightIconName, type = "solid", autoDismissKeyboard = true, }) => {
|
|
42
42
|
var _a, _b;
|
|
43
43
|
const androidPickerRef = React.useRef(undefined);
|
|
44
44
|
const [internalValue, setInternalValue] = React.useState(value || defaultValue);
|
|
@@ -67,7 +67,12 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
|
|
|
67
67
|
Keyboard.dismiss();
|
|
68
68
|
}
|
|
69
69
|
}, [pickerVisible, autoDismissKeyboard]);
|
|
70
|
-
const
|
|
70
|
+
const normalizedOptions = normalizeOptions(options);
|
|
71
|
+
//Underlying Picker component defaults selection to first element when value is not provided (or undefined)
|
|
72
|
+
//Placholder must be the 1st option in order to allow selection of the 'actual' 1st option
|
|
73
|
+
const pickerOptions = placeholder
|
|
74
|
+
? [{ label: placeholder, value: placeholder }, ...normalizedOptions]
|
|
75
|
+
: normalizedOptions;
|
|
71
76
|
const { viewStyles, textStyles } = extractStyles(style);
|
|
72
77
|
const additionalBorderStyles = ["backgroundColor"];
|
|
73
78
|
const additionalMarginStyles = [
|
|
@@ -162,10 +167,14 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
|
|
|
162
167
|
...(disabled ? { color: unstyledColor } : {}),
|
|
163
168
|
};
|
|
164
169
|
const handleValueChange = (newValue, itemIndex) => {
|
|
165
|
-
if (newValue !== "") {
|
|
170
|
+
if (newValue !== "" && newValue !== placeholder) {
|
|
166
171
|
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue, itemIndex);
|
|
167
172
|
setInternalValue(newValue);
|
|
168
173
|
}
|
|
174
|
+
else if (newValue === placeholder) {
|
|
175
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange("", 0);
|
|
176
|
+
setInternalValue(undefined);
|
|
177
|
+
}
|
|
169
178
|
};
|
|
170
179
|
return (
|
|
171
180
|
/* marginsContainer */
|
|
@@ -101,7 +101,7 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
101
101
|
defaultValue,
|
|
102
102
|
Icon,
|
|
103
103
|
style,
|
|
104
|
-
placeholder,
|
|
104
|
+
placeholder = "Select an option",
|
|
105
105
|
value,
|
|
106
106
|
disabled = false,
|
|
107
107
|
assistiveText,
|
|
@@ -151,7 +151,13 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
151
151
|
}
|
|
152
152
|
}, [pickerVisible, autoDismissKeyboard]);
|
|
153
153
|
|
|
154
|
-
const
|
|
154
|
+
const normalizedOptions = normalizeOptions(options);
|
|
155
|
+
|
|
156
|
+
//Underlying Picker component defaults selection to first element when value is not provided (or undefined)
|
|
157
|
+
//Placholder must be the 1st option in order to allow selection of the 'actual' 1st option
|
|
158
|
+
const pickerOptions = placeholder
|
|
159
|
+
? [{ label: placeholder, value: placeholder }, ...normalizedOptions]
|
|
160
|
+
: normalizedOptions;
|
|
155
161
|
|
|
156
162
|
const { viewStyles, textStyles } = extractStyles(style);
|
|
157
163
|
|
|
@@ -302,9 +308,12 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
302
308
|
};
|
|
303
309
|
|
|
304
310
|
const handleValueChange = (newValue: string, itemIndex: number) => {
|
|
305
|
-
if (newValue !== "") {
|
|
311
|
+
if (newValue !== "" && newValue !== placeholder) {
|
|
306
312
|
onValueChange?.(newValue, itemIndex);
|
|
307
313
|
setInternalValue(newValue);
|
|
314
|
+
} else if (newValue === placeholder) {
|
|
315
|
+
onValueChange?.("", 0);
|
|
316
|
+
setInternalValue(undefined);
|
|
308
317
|
}
|
|
309
318
|
};
|
|
310
319
|
|