@steroidsjs/core 2.2.47 → 2.2.50

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steroidsjs/core",
3
- "version": "2.2.47",
3
+ "version": "2.2.50",
4
4
  "description": "",
5
5
  "author": "Vladimir Kozhin <hello@kozhindev.com>",
6
6
  "repository": {
@@ -23,7 +23,7 @@ function useDateInputState(props) {
23
23
  var propsDisplayValue = react_1.useMemo(function () { return calendar_1.convertDate(props.input.value, [
24
24
  props.valueFormat,
25
25
  props.displayFormat,
26
- ], props.displayFormat, false, true) || ''; }, [props.displayFormat, props.input.value, props.valueFormat]);
26
+ ], props.displayFormat, false, props.useUTC) || ''; }, [props.displayFormat, props.input.value, props.valueFormat]);
27
27
  // Display value state
28
28
  var _a = react_1.useState(propsDisplayValue), displayValue = _a[0], setDisplayValue = _a[1];
29
29
  // Update display value on update props input value
@@ -41,7 +41,7 @@ function useDateInputState(props) {
41
41
  var onDisplayValueChange = react_1.useCallback(function (value) {
42
42
  value = value.replace(/[^0-9:. ]/g, '');
43
43
  setDisplayValue(value);
44
- var parsedValue = calendar_1.convertDate(value, props.displayFormat, props.valueFormat, true);
44
+ var parsedValue = calendar_1.convertDate(value, props.displayFormat, props.valueFormat, props.useUTC);
45
45
  var newValue = parsedValue || !value ? parsedValue || null : false;
46
46
  if (newValue && newValue !== props.input.value) {
47
47
  props.input.onChange.call(null, newValue);
@@ -49,7 +49,7 @@ function useDateInputState(props) {
49
49
  props.onChange.call(null, value);
50
50
  }
51
51
  }
52
- }, [props.displayFormat, props.input.onChange, props.input.value, props.onChange, props.valueFormat]);
52
+ }, [props.displayFormat, props.input.onChange, props.input.value, props.onChange, props.valueFormat, props.useUTC]);
53
53
  // Dropdown opened state
54
54
  var _b = react_1.useState(false), isOpened = _b[0], setIsOpened = _b[1];
55
55
  // Focus/blur handlers
@@ -160,9 +160,9 @@ function Form(props) {
160
160
  // OnChange handler
161
161
  react_use_1.useUpdateEffect(function () {
162
162
  if (props.onChange) {
163
- props.onChange(values);
163
+ props.onChange.call(null, values);
164
164
  }
165
- }, [props, values]);
165
+ }, [props.onChange, values]);
166
166
  // OnSubmit handler
167
167
  var onSubmit = react_1.useCallback(function (e) {
168
168
  if (e === void 0) { e = null; }
@@ -178,16 +178,33 @@ function Form(props) {
178
178
  if (e) {
179
179
  e.preventDefault();
180
180
  }
181
+ cleanedValues = cloneDeep_1["default"](values);
181
182
  // Append non touched fields to values object
182
183
  if (props.formId) {
183
184
  Object.keys(components.ui.getRegisteredFields(props.formId) || {})
184
185
  .forEach(function (key) {
185
- if (isUndefined_1["default"](get_1["default"](values, key))) {
186
- set_1["default"](values, key, null);
186
+ // Don't set null values for keys in empty array items
187
+ var keyParts = [];
188
+ var arrayKey;
189
+ key.split('.').find(function (keyPart) {
190
+ if (keyParts.length > 0 && Array.isArray(get_1["default"](cleanedValues, keyParts))) {
191
+ keyParts.push(keyPart);
192
+ arrayKey = keyParts.join('.');
193
+ return true;
194
+ }
195
+ keyParts.push(keyPart);
196
+ return false;
197
+ });
198
+ if (arrayKey && !get_1["default"](cleanedValues, arrayKey)) {
199
+ return;
200
+ }
201
+ if (isUndefined_1["default"](get_1["default"](cleanedValues, key))) {
202
+ set_1["default"](cleanedValues, key, null);
187
203
  }
188
204
  });
189
205
  }
190
- cleanedValues = cloneDeep_1["default"](form_1.cleanEmptyObject(values));
206
+ // Clean
207
+ cleanedValues = form_1.cleanEmptyObject(cleanedValues);
191
208
  // Event onBeforeSubmit
192
209
  if (props.onBeforeSubmit && props.onBeforeSubmit.call(null, cleanedValues) === false) {
193
210
  dispatch(form_2.formSetSubmitting(props.formId, false));
@@ -28,7 +28,8 @@ function TimeField(props) {
28
28
  inputProps: props.inputProps,
29
29
  placeholder: props.placeholder,
30
30
  valueFormat: props.valueFormat,
31
- displayFormat: props.displayFormat
31
+ displayFormat: props.displayFormat,
32
+ useUTC: props.useUTC
32
33
  }), onNow = _a.onNow, onClear = _a.onClear, onClose = _a.onClose, isOpened = _a.isOpened, inputProps = _a.inputProps;
33
34
  var timePanelViewProps = react_1.useMemo(function () { return (__assign({ onNow: onNow,
34
35
  onClose: onClose, value: inputProps.value, onSelect: inputProps.onChange }, props.timePanelViewProps)); }, [inputProps.onChange, inputProps.value, onClose, onNow, props.timePanelViewProps]);