@draftbit/core 46.9.1 → 46.9.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.
@@ -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 pickerOptions = normalizeOptions(options);
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 pickerOptions = normalizeOptions(options);
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,EAAE,MAAM,CAAC;CACf;AAED,oBAAY,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,EAA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AAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,EAAE,CAAC;IACnC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IAC7B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CACxB,CAAC;;;;AAkbF,wBAAiC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftbit/core",
3
- "version": "46.9.1",
3
+ "version": "46.9.2",
4
4
  "description": "Core (non-native) Components",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -96,5 +96,5 @@
96
96
  ]
97
97
  ]
98
98
  },
99
- "gitHead": "47a79020bf300ba2f8abf34bc4a48a5b15b190eb"
99
+ "gitHead": "0f97b1eb85353931aeb100780bf6b15032fc1025"
100
100
  }
@@ -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 pickerOptions = normalizeOptions(options);
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