@zohodesk/components 1.0.0-alpha-274 → 1.0.0-alpha-276
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/README.md +9 -0
- package/es/DateTime/DateTime.js +37 -3
- package/lib/DateTime/DateTime.js +40 -3
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -32,6 +32,15 @@ In this Package, we Provide Some Basic Components to Build Web App
|
|
|
32
32
|
- TextBoxIcon
|
|
33
33
|
- Tooltip
|
|
34
34
|
|
|
35
|
+
# 1.0.0-alpha-276
|
|
36
|
+
|
|
37
|
+
- **DateTime** - TimeZone null Case Handled
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# 1.0.0-alpha-275
|
|
41
|
+
|
|
42
|
+
- **DateTime** - millisecond and second should work only when customDateFormat is given issue fixed. this fix related to *1.0.0-alpha-272*
|
|
43
|
+
|
|
35
44
|
# 1.0.0-alpha-274
|
|
36
45
|
|
|
37
46
|
- **AppContainer** - needTooltip prop added
|
package/es/DateTime/DateTime.js
CHANGED
|
@@ -46,6 +46,7 @@ export default class DateTime extends React.PureComponent {
|
|
|
46
46
|
this.handleSelectMonthViaYearView = this.handleSelectMonthViaYearView.bind(this);
|
|
47
47
|
this.handleGetStateValues = this.handleGetStateValues.bind(this);
|
|
48
48
|
this.handleYearViewToggle = this.handleYearViewToggle.bind(this);
|
|
49
|
+
this.getInitialDate = this.getInitialDate.bind(this);
|
|
49
50
|
const {
|
|
50
51
|
ampmText = ampmTextDefault
|
|
51
52
|
} = props.i18nKeys;
|
|
@@ -102,6 +103,33 @@ export default class DateTime extends React.PureComponent {
|
|
|
102
103
|
this.handleExposeMethods(false);
|
|
103
104
|
}
|
|
104
105
|
|
|
106
|
+
getInitialDate(value) {
|
|
107
|
+
let timeZone = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
108
|
+
let isDateTime = arguments.length > 2 ? arguments[2] : undefined;
|
|
109
|
+
let result = null;
|
|
110
|
+
|
|
111
|
+
if (isDateTime) {
|
|
112
|
+
if (timeZone && value) {
|
|
113
|
+
result = datetime.toDate(datetime.tz.utcToTz(value, timeZone));
|
|
114
|
+
} else {
|
|
115
|
+
value = value.replace('Z', '');
|
|
116
|
+
result = new Date(value);
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
if (value) {
|
|
120
|
+
if (timeZone) {
|
|
121
|
+
result = datetime.toDate(value);
|
|
122
|
+
} else {
|
|
123
|
+
result = new Date(value);
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
result = new Date();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
|
|
105
133
|
getStateFromProps(props) {
|
|
106
134
|
let date, month, year, hours, mins, amPm;
|
|
107
135
|
let {
|
|
@@ -126,7 +154,7 @@ export default class DateTime extends React.PureComponent {
|
|
|
126
154
|
defaultMin = parseInt(defaultMin);
|
|
127
155
|
}
|
|
128
156
|
|
|
129
|
-
const dateObj =
|
|
157
|
+
const dateObj = this.getInitialDate(value, timeZone, isDateTimeField);
|
|
130
158
|
date = dateObj.getDate();
|
|
131
159
|
month = dateObj.getMonth();
|
|
132
160
|
year = dateObj.getFullYear();
|
|
@@ -205,9 +233,15 @@ export default class DateTime extends React.PureComponent {
|
|
|
205
233
|
let milliSec = currentDate.getMilliseconds();
|
|
206
234
|
|
|
207
235
|
if (isDateTimeField || customDateFormat) {
|
|
208
|
-
|
|
236
|
+
const dateArgs = [year, month, date, hours, mins];
|
|
237
|
+
|
|
238
|
+
if (customDateFormat) {
|
|
239
|
+
dateArgs.push(sec, milliSec);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
selectedInMillis = timeZone ? datetime.tz.tzToUtc(Date.UTC(...dateArgs), timeZone) : Date.UTC(...dateArgs);
|
|
209
243
|
selectedValue = datetime.ISO(selectedInMillis);
|
|
210
|
-
formattedValue = formatDate(new Date(
|
|
244
|
+
formattedValue = formatDate(new Date(...dateArgs), customDateFormat == null ? is24Hour ? `${dateFormat} HH:mm:ss` : `${dateFormat} hh:mm:ss A` : `${customDateFormat}`);
|
|
211
245
|
} else {
|
|
212
246
|
selectedInMillis = Date.UTC(year, month, date);
|
|
213
247
|
selectedValue = formatDate(new Date(year, month, date), 'YYYY-MM-DD');
|
package/lib/DateTime/DateTime.js
CHANGED
|
@@ -41,6 +41,8 @@ var _dateFormatUtils = require("./dateFormatUtils");
|
|
|
41
41
|
|
|
42
42
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
43
43
|
|
|
44
|
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
45
|
+
|
|
44
46
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
45
47
|
|
|
46
48
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -109,6 +111,7 @@ var DateTime = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
109
111
|
_this.handleSelectMonthViaYearView = _this.handleSelectMonthViaYearView.bind(_assertThisInitialized(_this));
|
|
110
112
|
_this.handleGetStateValues = _this.handleGetStateValues.bind(_assertThisInitialized(_this));
|
|
111
113
|
_this.handleYearViewToggle = _this.handleYearViewToggle.bind(_assertThisInitialized(_this));
|
|
114
|
+
_this.getInitialDate = _this.getInitialDate.bind(_assertThisInitialized(_this));
|
|
112
115
|
var _props$i18nKeys$ampmT = props.i18nKeys.ampmText,
|
|
113
116
|
ampmText = _props$i18nKeys$ampmT === void 0 ? _constants.ampmTextDefault : _props$i18nKeys$ampmT;
|
|
114
117
|
|
|
@@ -168,6 +171,34 @@ var DateTime = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
168
171
|
value: function componentWillUnmount() {
|
|
169
172
|
this.handleExposeMethods(false);
|
|
170
173
|
}
|
|
174
|
+
}, {
|
|
175
|
+
key: "getInitialDate",
|
|
176
|
+
value: function getInitialDate(value) {
|
|
177
|
+
var timeZone = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
178
|
+
var isDateTime = arguments.length > 2 ? arguments[2] : undefined;
|
|
179
|
+
var result = null;
|
|
180
|
+
|
|
181
|
+
if (isDateTime) {
|
|
182
|
+
if (timeZone && value) {
|
|
183
|
+
result = _datetimejs["default"].toDate(_datetimejs["default"].tz.utcToTz(value, timeZone));
|
|
184
|
+
} else {
|
|
185
|
+
value = value.replace('Z', '');
|
|
186
|
+
result = new Date(value);
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
if (value) {
|
|
190
|
+
if (timeZone) {
|
|
191
|
+
result = _datetimejs["default"].toDate(value);
|
|
192
|
+
} else {
|
|
193
|
+
result = new Date(value);
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
result = new Date();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return result;
|
|
201
|
+
}
|
|
171
202
|
}, {
|
|
172
203
|
key: "getStateFromProps",
|
|
173
204
|
value: function getStateFromProps(props) {
|
|
@@ -198,7 +229,7 @@ var DateTime = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
198
229
|
defaultMin = parseInt(defaultMin);
|
|
199
230
|
}
|
|
200
231
|
|
|
201
|
-
var dateObj =
|
|
232
|
+
var dateObj = this.getInitialDate(value, timeZone, isDateTimeField);
|
|
202
233
|
date = dateObj.getDate();
|
|
203
234
|
month = dateObj.getMonth();
|
|
204
235
|
year = dateObj.getFullYear();
|
|
@@ -276,9 +307,15 @@ var DateTime = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
276
307
|
var milliSec = currentDate.getMilliseconds();
|
|
277
308
|
|
|
278
309
|
if (isDateTimeField || customDateFormat) {
|
|
279
|
-
|
|
310
|
+
var dateArgs = [year, month, date, hours, mins];
|
|
311
|
+
|
|
312
|
+
if (customDateFormat) {
|
|
313
|
+
dateArgs.push(sec, milliSec);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
selectedInMillis = timeZone ? _datetimejs["default"].tz.tzToUtc(Date.UTC.apply(Date, dateArgs), timeZone) : Date.UTC.apply(Date, dateArgs);
|
|
280
317
|
selectedValue = _datetimejs["default"].ISO(selectedInMillis);
|
|
281
|
-
formattedValue = (0, _common.formatDate)(
|
|
318
|
+
formattedValue = (0, _common.formatDate)(_construct(Date, dateArgs), customDateFormat == null ? is24Hour ? "".concat(dateFormat, " HH:mm:ss") : "".concat(dateFormat, " hh:mm:ss A") : "".concat(customDateFormat));
|
|
282
319
|
} else {
|
|
283
320
|
selectedInMillis = Date.UTC(year, month, date);
|
|
284
321
|
selectedValue = (0, _common.formatDate)(new Date(year, month, date), 'YYYY-MM-DD');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/components",
|
|
3
|
-
"version": "1.0.0-alpha-
|
|
3
|
+
"version": "1.0.0-alpha-276",
|
|
4
4
|
"main": "es/index.js",
|
|
5
5
|
"module": "es/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -51,12 +51,12 @@
|
|
|
51
51
|
"variable:check": "node ./node_modules/@zohodesk-private/css-variable-migrator/es/variableErrorCheck.js ./src ./node_modules/@zohodesk-private/css-variable-migrator/es/config/cssVariableReplacementOptions.json"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@zohodesk-private/css-variable-migrator": "^1.0.
|
|
54
|
+
"@zohodesk-private/css-variable-migrator": "^1.0.5",
|
|
55
55
|
"@zohodesk/a11y": "1.3.7",
|
|
56
56
|
"@zohodesk-private/node-plugins": "^1.0.0",
|
|
57
57
|
"@zohodesk/docstool": "1.0.0-alpha-2",
|
|
58
|
-
"@zohodesk/icons": "1.0.0-beta.
|
|
59
|
-
"@zohodesk/svg": "1.0.0-beta.
|
|
58
|
+
"@zohodesk/icons": "1.0.0-beta.132",
|
|
59
|
+
"@zohodesk/svg": "1.0.0-beta.59",
|
|
60
60
|
"@zohodesk/variables": "1.0.0-beta.31",
|
|
61
61
|
"@zohodesk/virtualizer": "1.0.3",
|
|
62
62
|
"react-sortable-hoc": "^0.8.3",
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
"selectn": "1.1.2"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@zohodesk/icons": "1.0.0-beta.
|
|
72
|
+
"@zohodesk/icons": "1.0.0-beta.132",
|
|
73
73
|
"@zohodesk/variables": "1.0.0-beta.31",
|
|
74
|
-
"@zohodesk/svg": "1.0.0-beta.
|
|
74
|
+
"@zohodesk/svg": "1.0.0-beta.59",
|
|
75
75
|
"@zohodesk/virtualizer": "1.0.3",
|
|
76
76
|
"velocity-react": "1.4.3",
|
|
77
77
|
"react-sortable-hoc": "^0.8.3",
|