@aerogel/core 0.1.1-next.99766defd90af84297715d34b226d66e90304026 → 0.1.1-next.99b3fb08de2a9c2e13062ba0459f432627992d23

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": "@aerogel/core",
3
- "version": "0.1.1-next.99766defd90af84297715d34b226d66e90304026",
3
+ "version": "0.1.1-next.99b3fb08de2a9c2e13062ba0459f432627992d23",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {
@@ -65,11 +65,19 @@ function getValue(): FormFieldValue | null {
65
65
  return $input.value.checked;
66
66
  case 'date':
67
67
  case 'time':
68
- case 'datetime-local':
69
- return new Date(
68
+ case 'datetime-local': {
69
+ const date = new Date(
70
70
  Math.round($input.value.valueAsNumber / 60000) * 60000 +
71
- getLocalTimezoneOffset($input.value.valueAsDate),
71
+ getLocalTimezoneOffset($input.value.valueAsDate ?? new Date($input.value.valueAsNumber)),
72
72
  );
73
+
74
+ if (isNaN(date.getTime())) {
75
+ return null;
76
+ }
77
+
78
+ return date;
79
+ }
80
+
73
81
  case 'number':
74
82
  return $input.value.valueAsNumber;
75
83
  default:
@@ -87,7 +95,10 @@ watchEffect(() => {
87
95
  const roundedValue = Math.round(value.value.getTime() / 60000) * 60000;
88
96
 
89
97
  $input.value.valueAsNumber = roundedValue - getLocalTimezoneOffset(value.value);
90
- input.update(new Date(roundedValue));
98
+
99
+ if (value.value.getTime() !== roundedValue) {
100
+ input.update(new Date(roundedValue));
101
+ }
91
102
 
92
103
  return;
93
104
  }
@@ -1,4 +1,3 @@
1
- import { isTesting } from '@noeldemartin/utils';
2
1
  import type { App as AppInstance } from 'vue';
3
2
 
4
3
  import App from '@aerogel/core/services/App';
@@ -18,10 +17,7 @@ export type { ErrorSource, ErrorReport, ErrorReportLog };
18
17
 
19
18
  const services = { $errors: Errors };
20
19
  const frameworkHandler: ErrorHandler = (error) => {
21
- if (
22
- isTesting('e2e') &&
23
- getErrorMessage(error).includes('ResizeObserver loop completed with undelivered notifications.')
24
- ) {
20
+ if (getErrorMessage(error).includes('ResizeObserver loop completed with undelivered notifications.')) {
25
21
  return true;
26
22
  }
27
23
 
@@ -1,5 +1,5 @@
1
1
  import { computed, nextTick, reactive, readonly, ref } from 'vue';
2
- import { MagicObject, arrayRemove, fail, toString } from '@noeldemartin/utils';
2
+ import { MagicObject, arrayRemove, fail } from '@noeldemartin/utils';
3
3
  import type { ComputedRef, DeepReadonly, Ref, UnwrapNestedRefs } from 'vue';
4
4
 
5
5
  import { validate, validateType } from './validation';
@@ -91,17 +91,13 @@ export default class FormController<Fields extends FormFieldDefinitions = FormFi
91
91
  }
92
92
 
93
93
  public setFieldValue<T extends keyof Fields>(field: T, value: FormData<Fields>[T]): void {
94
- const definition =
95
- this._fields[field] ?? fail<FormFieldDefinition>(`Trying to set undefined '${toString(field)}' field`);
94
+ this._data[field] = value;
96
95
 
97
- this._data[field] =
98
- definition.type === 'string' && (definition.trim ?? true)
99
- ? (toString(value).trim() as FormData<Fields>[T])
100
- : value;
101
-
102
- if (this._submitted.value) {
103
- this.validate();
96
+ if (!this._submitted.value) {
97
+ return;
104
98
  }
99
+
100
+ this.validate();
105
101
  }
106
102
 
107
103
  public getFieldValue<T extends keyof Fields>(field: T): GetFormFieldValue<Fields[T]['type']> {
@@ -149,6 +145,16 @@ export default class FormController<Fields extends FormFieldDefinitions = FormFi
149
145
  public submit(): boolean {
150
146
  this._submitted.value = true;
151
147
 
148
+ for (const [field, value] of Object.entries(this._data)) {
149
+ const definition = this._fields[field] ?? fail<FormFieldDefinition>();
150
+
151
+ if (typeof value !== 'string' || !(definition.trim ?? true)) {
152
+ continue;
153
+ }
154
+
155
+ this._data[field as keyof Fields] = value.trim() as FormData<Fields>[string];
156
+ }
157
+
152
158
  const valid = this.validate();
153
159
 
154
160
  valid && this._listeners['submit']?.forEach((listener) => listener());