@etsoo/react 1.7.13 → 1.7.15
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/app/ReactUtils.js +10 -2
- package/package.json +1 -1
- package/src/app/ReactUtils.ts +13 -4
package/lib/app/ReactUtils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DomUtils, Utils } from '@etsoo/shared';
|
|
1
|
+
import { DateUtils, DomUtils, Utils } from '@etsoo/shared';
|
|
2
2
|
/**
|
|
3
3
|
* React utils
|
|
4
4
|
*/
|
|
@@ -112,7 +112,15 @@ export var ReactUtils;
|
|
|
112
112
|
else if (item instanceof HTMLInputElement ||
|
|
113
113
|
item instanceof HTMLTextAreaElement ||
|
|
114
114
|
item instanceof HTMLSelectElement) {
|
|
115
|
-
|
|
115
|
+
const value = Utils.getNestedValue(data, item.name || k);
|
|
116
|
+
const isDateTime = item.type === 'datetime-local';
|
|
117
|
+
if (isDateTime || item.type === 'date') {
|
|
118
|
+
item.value =
|
|
119
|
+
(_a = DateUtils.formatForInput(value, isDateTime ? false : undefined)) !== null && _a !== void 0 ? _a : '';
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
item.value = `${value !== null && value !== void 0 ? value : ''}`;
|
|
123
|
+
}
|
|
116
124
|
}
|
|
117
125
|
else {
|
|
118
126
|
item.value = data[k];
|
package/package.json
CHANGED
package/src/app/ReactUtils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes, DomUtils, Utils } from '@etsoo/shared';
|
|
1
|
+
import { DataTypes, DateUtils, DomUtils, Utils } from '@etsoo/shared';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -140,9 +140,18 @@ export namespace ReactUtils {
|
|
|
140
140
|
item instanceof HTMLTextAreaElement ||
|
|
141
141
|
item instanceof HTMLSelectElement
|
|
142
142
|
) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
const value = Utils.getNestedValue(data, item.name || k);
|
|
144
|
+
|
|
145
|
+
const isDateTime = item.type === 'datetime-local';
|
|
146
|
+
if (isDateTime || item.type === 'date') {
|
|
147
|
+
item.value =
|
|
148
|
+
DateUtils.formatForInput(
|
|
149
|
+
value,
|
|
150
|
+
isDateTime ? false : undefined
|
|
151
|
+
) ?? '';
|
|
152
|
+
} else {
|
|
153
|
+
item.value = `${value ?? ''}`;
|
|
154
|
+
}
|
|
146
155
|
} else {
|
|
147
156
|
(item as any).value = data[k];
|
|
148
157
|
}
|