@draftbit/core 46.8.0 → 46.8.1-b0418d.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.
@@ -46,6 +46,9 @@ const isWeb = _reactNative.Platform.OS === "web";
46
46
  const unstyledColor = "rgba(165, 173, 183, 1)";
47
47
  const disabledColor = "rgb(240, 240, 240)";
48
48
  const errorColor = "rgba(255, 69, 100, 1)";
49
+
50
+ //Empty string for 'value' is treated as a non-value
51
+ //reason: Draftbit uses empty string as initial value for string state*/
49
52
  const Picker = _ref => {
50
53
  var _find$label, _find;
51
54
  let {
@@ -76,12 +79,12 @@ const Picker = _ref => {
76
79
  setPickerVisible(!pickerVisible);
77
80
  };
78
81
  React.useEffect(() => {
79
- if (value != null) {
82
+ if (value != null && value !== "") {
80
83
  setInternalValue(value);
81
84
  }
82
85
  }, [value]);
83
86
  React.useEffect(() => {
84
- if (defaultValue != null) {
87
+ if (defaultValue != null && defaultValue !== "") {
85
88
  setInternalValue(defaultValue);
86
89
  }
87
90
  }, [defaultValue]);
@@ -96,11 +99,7 @@ const Picker = _ref => {
96
99
  _reactNative.Keyboard.dismiss();
97
100
  }
98
101
  }, [pickerVisible, autoDismissKeyboard]);
99
- const normalizedOptions = normalizeOptions(options);
100
- const pickerOptions = placeholder ? [{
101
- value: placeholder,
102
- label: placeholder
103
- }, ...normalizedOptions] : normalizedOptions;
102
+ const pickerOptions = normalizeOptions(options);
104
103
  const {
105
104
  viewStyles,
106
105
  textStyles
@@ -200,10 +199,10 @@ const Picker = _ref => {
200
199
  } : {})
201
200
  };
202
201
  const handleValueChange = (newValue, itemIndex) => {
203
- if (!placeholder || itemIndex > 0) {
202
+ if (newValue !== "") {
204
203
  onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue, itemIndex);
204
+ setInternalValue(newValue);
205
205
  }
206
- setInternalValue(newValue);
207
206
  };
208
207
  return (
209
208
  /*#__PURE__*/
@@ -37,6 +37,9 @@ const isWeb = Platform.OS === "web";
37
37
  const unstyledColor = "rgba(165, 173, 183, 1)";
38
38
  const disabledColor = "rgb(240, 240, 240)";
39
39
  const errorColor = "rgba(255, 69, 100, 1)";
40
+
41
+ //Empty string for 'value' is treated as a non-value
42
+ //reason: Draftbit uses empty string as initial value for string state*/
40
43
  const Picker = _ref => {
41
44
  var _find$label, _find;
42
45
  let {
@@ -67,12 +70,12 @@ const Picker = _ref => {
67
70
  setPickerVisible(!pickerVisible);
68
71
  };
69
72
  React.useEffect(() => {
70
- if (value != null) {
73
+ if (value != null && value !== "") {
71
74
  setInternalValue(value);
72
75
  }
73
76
  }, [value]);
74
77
  React.useEffect(() => {
75
- if (defaultValue != null) {
78
+ if (defaultValue != null && defaultValue !== "") {
76
79
  setInternalValue(defaultValue);
77
80
  }
78
81
  }, [defaultValue]);
@@ -87,11 +90,7 @@ const Picker = _ref => {
87
90
  Keyboard.dismiss();
88
91
  }
89
92
  }, [pickerVisible, autoDismissKeyboard]);
90
- const normalizedOptions = normalizeOptions(options);
91
- const pickerOptions = placeholder ? [{
92
- value: placeholder,
93
- label: placeholder
94
- }, ...normalizedOptions] : normalizedOptions;
93
+ const pickerOptions = normalizeOptions(options);
95
94
  const {
96
95
  viewStyles,
97
96
  textStyles
@@ -191,10 +190,10 @@ const Picker = _ref => {
191
190
  } : {})
192
191
  };
193
192
  const handleValueChange = (newValue, itemIndex) => {
194
- if (!placeholder || itemIndex > 0) {
193
+ if (newValue !== "") {
195
194
  onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue, itemIndex);
195
+ setInternalValue(newValue);
196
196
  }
197
- setInternalValue(newValue);
198
197
  };
199
198
  return (
200
199
  /*#__PURE__*/
@@ -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,c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AAC,CAAC;CACxB,CAAC;;;;AAyaF,wBAAiC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftbit/core",
3
- "version": "46.8.0",
3
+ "version": "46.8.1-b0418d.2+b0418d9",
4
4
  "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.8.0",
44
+ "@draftbit/types": "^46.8.1-b0418d.2+b0418d9",
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",
@@ -92,5 +92,5 @@
92
92
  ]
93
93
  ]
94
94
  },
95
- "gitHead": "c39b951332cf49ab0c1a244b1939f60f241f3ffa"
95
+ "gitHead": "b0418d9f5ae6bccecbe29639c7f468643dfcffdf"
96
96
  }
@@ -36,6 +36,8 @@ const isWeb = Platform.OS === "web";
36
36
  const unstyledColor = "rgba(165, 173, 183, 1)";
37
37
  const disabledColor = "rgb(240, 240, 240)";
38
38
  const errorColor = "rgba(255, 69, 100, 1)";
39
+ //Empty string for 'value' is treated as a non-value
40
+ //reason: Draftbit uses empty string as initial value for string state*/
39
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, }) => {
40
42
  var _a, _b;
41
43
  const androidPickerRef = React.useRef(undefined);
@@ -45,12 +47,12 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
45
47
  setPickerVisible(!pickerVisible);
46
48
  };
47
49
  React.useEffect(() => {
48
- if (value != null) {
50
+ if (value != null && value !== "") {
49
51
  setInternalValue(value);
50
52
  }
51
53
  }, [value]);
52
54
  React.useEffect(() => {
53
- if (defaultValue != null) {
55
+ if (defaultValue != null && defaultValue !== "") {
54
56
  setInternalValue(defaultValue);
55
57
  }
56
58
  }, [defaultValue]);
@@ -65,10 +67,7 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
65
67
  Keyboard.dismiss();
66
68
  }
67
69
  }, [pickerVisible, autoDismissKeyboard]);
68
- const normalizedOptions = normalizeOptions(options);
69
- const pickerOptions = placeholder
70
- ? [{ value: placeholder, label: placeholder }, ...normalizedOptions]
71
- : normalizedOptions;
70
+ const pickerOptions = normalizeOptions(options);
72
71
  const { viewStyles, textStyles } = extractStyles(style);
73
72
  const additionalBorderStyles = ["backgroundColor"];
74
73
  const additionalMarginStyles = [
@@ -163,10 +162,10 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
163
162
  ...(disabled ? { color: unstyledColor } : {}),
164
163
  };
165
164
  const handleValueChange = (newValue, itemIndex) => {
166
- if (!placeholder || itemIndex > 0) {
165
+ if (newValue !== "") {
167
166
  onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue, itemIndex);
167
+ setInternalValue(newValue);
168
168
  }
169
- setInternalValue(newValue);
170
169
  };
171
170
  return (
172
171
  /* marginsContainer */
@@ -92,6 +92,8 @@ const unstyledColor = "rgba(165, 173, 183, 1)";
92
92
  const disabledColor = "rgb(240, 240, 240)";
93
93
  const errorColor = "rgba(255, 69, 100, 1)";
94
94
 
95
+ //Empty string for 'value' is treated as a non-value
96
+ //reason: Draftbit uses empty string as initial value for string state*/
95
97
  const Picker: React.FC<PickerProps> = ({
96
98
  error,
97
99
  options = [],
@@ -126,13 +128,13 @@ const Picker: React.FC<PickerProps> = ({
126
128
  };
127
129
 
128
130
  React.useEffect(() => {
129
- if (value != null) {
131
+ if (value != null && value !== "") {
130
132
  setInternalValue(value);
131
133
  }
132
134
  }, [value]);
133
135
 
134
136
  React.useEffect(() => {
135
- if (defaultValue != null) {
137
+ if (defaultValue != null && defaultValue !== "") {
136
138
  setInternalValue(defaultValue);
137
139
  }
138
140
  }, [defaultValue]);
@@ -149,11 +151,7 @@ const Picker: React.FC<PickerProps> = ({
149
151
  }
150
152
  }, [pickerVisible, autoDismissKeyboard]);
151
153
 
152
- const normalizedOptions = normalizeOptions(options);
153
-
154
- const pickerOptions = placeholder
155
- ? [{ value: placeholder, label: placeholder }, ...normalizedOptions]
156
- : normalizedOptions;
154
+ const pickerOptions = normalizeOptions(options);
157
155
 
158
156
  const { viewStyles, textStyles } = extractStyles(style);
159
157
 
@@ -304,10 +302,10 @@ const Picker: React.FC<PickerProps> = ({
304
302
  };
305
303
 
306
304
  const handleValueChange = (newValue: string, itemIndex: number) => {
307
- if (!placeholder || itemIndex > 0) {
305
+ if (newValue !== "") {
308
306
  onValueChange?.(newValue, itemIndex);
307
+ setInternalValue(newValue);
309
308
  }
310
- setInternalValue(newValue);
311
309
  };
312
310
 
313
311
  return (