superdesk-ui-framework 4.1.4 → 4.1.5
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/.github/workflows/publish-to-npm.yml +1 -0
- package/app-typescript/components/DateTimePicker.spec.tsx +59 -0
- package/app-typescript/components/DateTimePicker.tsx +14 -6
- package/dist/components/DateTimePicker.tsx +10 -0
- package/dist/examples.bundle.js +13 -10
- package/dist/superdesk-ui.bundle.js +8 -6
- package/package.json +1 -1
- package/react/components/DateTimePicker.js +8 -6
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {describe, it} from 'mocha';
|
|
2
|
+
import * as assert from 'assert';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import {DateTimePicker} from './DateTimePicker';
|
|
5
|
+
|
|
6
|
+
function makePicker(overrides: Partial<React.ComponentProps<typeof DateTimePicker>> = {}) {
|
|
7
|
+
return new DateTimePicker({
|
|
8
|
+
valueType: 'date',
|
|
9
|
+
dateFormat: 'MM/DD/YYYY',
|
|
10
|
+
value: new Date(2024, 0, 1, 13, 30, 45),
|
|
11
|
+
onChange: () => undefined,
|
|
12
|
+
allowSeconds: true,
|
|
13
|
+
...overrides,
|
|
14
|
+
} as React.ComponentProps<typeof DateTimePicker>);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
describe('DateTimePicker', () => {
|
|
18
|
+
it('keeps seconds when formatting date values', () => {
|
|
19
|
+
const picker = makePicker();
|
|
20
|
+
|
|
21
|
+
assert.strictEqual(picker.getTimeValue(), '13:30:45');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('keeps seconds when changing time values', () => {
|
|
25
|
+
let nextValue: Date | null = null;
|
|
26
|
+
const picker = makePicker({
|
|
27
|
+
onChange: (value: Date | null) => {
|
|
28
|
+
nextValue = value;
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
picker.handleTimeChange('09:05:12');
|
|
33
|
+
|
|
34
|
+
assert.notStrictEqual(nextValue, null);
|
|
35
|
+
const timeValue = nextValue as unknown as Date;
|
|
36
|
+
|
|
37
|
+
assert.strictEqual(timeValue.getHours(), 9);
|
|
38
|
+
assert.strictEqual(timeValue.getMinutes(), 5);
|
|
39
|
+
assert.strictEqual(timeValue.getSeconds(), 12);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('keeps seconds when changing the date', () => {
|
|
43
|
+
let nextValue: Date | null = null;
|
|
44
|
+
const picker = makePicker({
|
|
45
|
+
onChange: (value: Date | null) => {
|
|
46
|
+
nextValue = value;
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
picker.handleDateChange(new Date(2024, 0, 2));
|
|
51
|
+
|
|
52
|
+
assert.notStrictEqual(nextValue, null);
|
|
53
|
+
const dateValue = nextValue as unknown as Date;
|
|
54
|
+
|
|
55
|
+
assert.strictEqual(dateValue.getHours(), 13);
|
|
56
|
+
assert.strictEqual(dateValue.getMinutes(), 30);
|
|
57
|
+
assert.strictEqual(dateValue.getSeconds(), 45);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -46,10 +46,10 @@ export class DateTimePicker extends React.PureComponent<IProps> {
|
|
|
46
46
|
|
|
47
47
|
handleTimeChange = (time: string) => {
|
|
48
48
|
if (this.props.valueType === 'date') {
|
|
49
|
-
const [hours, minutes] = time.split(':').map((x) => defaultTo(parseInt(x, 10), 0));
|
|
49
|
+
const [hours, minutes, seconds] = time.split(':').map((x) => defaultTo(parseInt(x, 10), 0));
|
|
50
50
|
const origDate = this.props.value ?? new Date();
|
|
51
51
|
|
|
52
|
-
origDate.setHours(hours, minutes);
|
|
52
|
+
origDate.setHours(hours, minutes, this.props.allowSeconds ? seconds : 0);
|
|
53
53
|
|
|
54
54
|
this.props.onChange(origDate);
|
|
55
55
|
} else if (this.props.valueType === 'object') {
|
|
@@ -72,7 +72,11 @@ export class DateTimePicker extends React.PureComponent<IProps> {
|
|
|
72
72
|
const origDate = this.props.value ?? new Date();
|
|
73
73
|
const selectedDate = new Date(date);
|
|
74
74
|
|
|
75
|
-
selectedDate.setHours(
|
|
75
|
+
selectedDate.setHours(
|
|
76
|
+
origDate.getHours(),
|
|
77
|
+
origDate.getMinutes(),
|
|
78
|
+
this.props.allowSeconds ? origDate.getSeconds() : 0,
|
|
79
|
+
);
|
|
76
80
|
|
|
77
81
|
this.props.onChange(selectedDate);
|
|
78
82
|
} else if (this.props.valueType === 'object') {
|
|
@@ -91,9 +95,13 @@ export class DateTimePicker extends React.PureComponent<IProps> {
|
|
|
91
95
|
|
|
92
96
|
getTimeValue(): string | null {
|
|
93
97
|
if (this.props.valueType === 'date') {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
if (this.props.value == null) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const seconds = this.props.allowSeconds ? `:${this.prepareFormat(this.props.value.getSeconds())}` : '';
|
|
103
|
+
|
|
104
|
+
return `${this.prepareFormat(this.props.value.getHours())}:${this.prepareFormat(this.props.value.getMinutes())}${seconds}`;
|
|
97
105
|
} else if (this.props.valueType === 'object') {
|
|
98
106
|
return this.props.value.time ?? null;
|
|
99
107
|
} else {
|
|
@@ -21,6 +21,7 @@ class DateTimePickerExample extends React.PureComponent<{}, {dateTime: Date | nu
|
|
|
21
21
|
valueType="date"
|
|
22
22
|
value={this.state.dateTime}
|
|
23
23
|
dateFormat="YYYY-MM-DD"
|
|
24
|
+
allowSeconds
|
|
24
25
|
onChange={(val) => {
|
|
25
26
|
const parsedVal = val != null ? new Date(val) : null;
|
|
26
27
|
|
|
@@ -56,6 +57,7 @@ export default class DateTimePickerDoc extends React.Component<{}, IState> {
|
|
|
56
57
|
value={this.state.dateTime}
|
|
57
58
|
dateFormat="YYYY-MM-DD"
|
|
58
59
|
fullWidth
|
|
60
|
+
allowSeconds
|
|
59
61
|
onChange={(val) => {
|
|
60
62
|
const parsedVal = val != null ? new Date(val) : null;
|
|
61
63
|
|
|
@@ -75,6 +77,7 @@ export default class DateTimePickerDoc extends React.Component<{}, IState> {
|
|
|
75
77
|
value={this.state.dateTime}
|
|
76
78
|
dateFormat="YYYY-MM-DD"
|
|
77
79
|
fullWidth
|
|
80
|
+
allowSeconds
|
|
78
81
|
onChange={(val) => {
|
|
79
82
|
const parsedVal = val != null ? new Date(val) : null;
|
|
80
83
|
|
|
@@ -100,6 +103,13 @@ export default class DateTimePickerDoc extends React.Component<{}, IState> {
|
|
|
100
103
|
default="/"
|
|
101
104
|
description='Date format to use, i.e. "MM/DD/YYYY".'
|
|
102
105
|
/>
|
|
106
|
+
<Prop
|
|
107
|
+
name="allowSeconds"
|
|
108
|
+
isRequired={false}
|
|
109
|
+
type="boolean"
|
|
110
|
+
default="false"
|
|
111
|
+
description="Allow seconds in the time picker."
|
|
112
|
+
/>
|
|
103
113
|
<Prop
|
|
104
114
|
name="onChange"
|
|
105
115
|
isRequired={true}
|
package/dist/examples.bundle.js
CHANGED
|
@@ -134047,9 +134047,9 @@ var DateTimePicker = /** @class */ (function (_super) {
|
|
|
134047
134047
|
_this.handleTimeChange = function (time) {
|
|
134048
134048
|
var _a;
|
|
134049
134049
|
if (_this.props.valueType === 'date') {
|
|
134050
|
-
var _b = time.split(':').map(function (x) { return (0, lodash_1.defaultTo)(parseInt(x, 10), 0); }), hours = _b[0], minutes = _b[1];
|
|
134050
|
+
var _b = time.split(':').map(function (x) { return (0, lodash_1.defaultTo)(parseInt(x, 10), 0); }), hours = _b[0], minutes = _b[1], seconds = _b[2];
|
|
134051
134051
|
var origDate = (_a = _this.props.value) !== null && _a !== void 0 ? _a : new Date();
|
|
134052
|
-
origDate.setHours(hours, minutes);
|
|
134052
|
+
origDate.setHours(hours, minutes, _this.props.allowSeconds ? seconds : 0);
|
|
134053
134053
|
_this.props.onChange(origDate);
|
|
134054
134054
|
}
|
|
134055
134055
|
else if (_this.props.valueType === 'object') {
|
|
@@ -134068,7 +134068,7 @@ var DateTimePicker = /** @class */ (function (_super) {
|
|
|
134068
134068
|
}
|
|
134069
134069
|
var origDate = (_a = _this.props.value) !== null && _a !== void 0 ? _a : new Date();
|
|
134070
134070
|
var selectedDate = new Date(date);
|
|
134071
|
-
selectedDate.setHours(origDate.getHours(), origDate.getMinutes());
|
|
134071
|
+
selectedDate.setHours(origDate.getHours(), origDate.getMinutes(), _this.props.allowSeconds ? origDate.getSeconds() : 0);
|
|
134072
134072
|
_this.props.onChange(selectedDate);
|
|
134073
134073
|
}
|
|
134074
134074
|
else if (_this.props.valueType === 'object') {
|
|
@@ -134097,9 +134097,11 @@ var DateTimePicker = /** @class */ (function (_super) {
|
|
|
134097
134097
|
DateTimePicker.prototype.getTimeValue = function () {
|
|
134098
134098
|
var _a;
|
|
134099
134099
|
if (this.props.valueType === 'date') {
|
|
134100
|
-
|
|
134101
|
-
|
|
134102
|
-
|
|
134100
|
+
if (this.props.value == null) {
|
|
134101
|
+
return null;
|
|
134102
|
+
}
|
|
134103
|
+
var seconds = this.props.allowSeconds ? ":".concat(this.prepareFormat(this.props.value.getSeconds())) : '';
|
|
134104
|
+
return "".concat(this.prepareFormat(this.props.value.getHours()), ":").concat(this.prepareFormat(this.props.value.getMinutes())).concat(seconds);
|
|
134103
134105
|
}
|
|
134104
134106
|
else if (this.props.valueType === 'object') {
|
|
134105
134107
|
return (_a = this.props.value.time) !== null && _a !== void 0 ? _a : null;
|
|
@@ -179796,7 +179798,7 @@ var DateTimePickerExample = /** @class */ (function (_super) {
|
|
|
179796
179798
|
return (React.createElement(app_typescript_1.DateTimePicker, { label: "Planning date",
|
|
179797
179799
|
//labelHidden
|
|
179798
179800
|
//inlineLabel
|
|
179799
|
-
fullWidth: true, valueType: "date", value: this.state.dateTime, dateFormat: "YYYY-MM-DD", onChange: function (val) {
|
|
179801
|
+
fullWidth: true, valueType: "date", value: this.state.dateTime, dateFormat: "YYYY-MM-DD", allowSeconds: true, onChange: function (val) {
|
|
179800
179802
|
var parsedVal = val != null ? new Date(val) : null;
|
|
179801
179803
|
_this.setState({ dateTime: parsedVal });
|
|
179802
179804
|
} }));
|
|
@@ -179816,16 +179818,17 @@ var DateTimePickerDoc = /** @class */ (function (_super) {
|
|
|
179816
179818
|
DateTimePickerDoc.prototype.render = function () {
|
|
179817
179819
|
return (React.createElement("section", { className: "docs-page__container" },
|
|
179818
179820
|
React.createElement("h2", { className: "docs-page__h2" }, "Date picker"),
|
|
179819
|
-
React.createElement(Markup.ReactMarkupCodePreview, null, "\n <DateTimePicker\n label=\"Planning date\"\n value={this.state.dateTime}\n dateFormat=\"YYYY-MM-DD\"\n fullWidth\n onChange={(val) => {\n const parsedVal = val != null ? new Date(val) : null;\n\n this.setState({dateTime: parsedVal});\n }}\n />\n "),
|
|
179821
|
+
React.createElement(Markup.ReactMarkupCodePreview, null, "\n <DateTimePicker\n label=\"Planning date\"\n value={this.state.dateTime}\n dateFormat=\"YYYY-MM-DD\"\n fullWidth\n allowSeconds\n onChange={(val) => {\n const parsedVal = val != null ? new Date(val) : null;\n\n this.setState({dateTime: parsedVal});\n }}\n />\n "),
|
|
179820
179822
|
React.createElement(Markup.ReactMarkup, null,
|
|
179821
179823
|
React.createElement(Markup.ReactMarkupPreview, null,
|
|
179822
179824
|
React.createElement("div", { className: "docs-page__content-row" },
|
|
179823
179825
|
React.createElement(DateTimePickerExample, null))),
|
|
179824
|
-
React.createElement(Markup.ReactMarkupCode, null, "\n <DateTimePicker\n label=\"Planning date\"\n value={this.state.dateTime}\n dateFormat=\"YYYY-MM-DD\"\n fullWidth\n onChange={(val) => {\n const parsedVal = val != null ? new Date(val) : null;\n\n this.setState({dateTime: parsedVal});\n }}\n />\n ")),
|
|
179826
|
+
React.createElement(Markup.ReactMarkupCode, null, "\n <DateTimePicker\n label=\"Planning date\"\n value={this.state.dateTime}\n dateFormat=\"YYYY-MM-DD\"\n fullWidth\n allowSeconds\n onChange={(val) => {\n const parsedVal = val != null ? new Date(val) : null;\n\n this.setState({dateTime: parsedVal});\n }}\n />\n ")),
|
|
179825
179827
|
React.createElement("h3", { className: "docs-page__h3" }, "Props"),
|
|
179826
179828
|
React.createElement(app_typescript_1.PropsList, null,
|
|
179827
179829
|
React.createElement(app_typescript_1.Prop, { name: "value", isRequired: false, type: "Date", default: "null", description: "Value of the component." }),
|
|
179828
179830
|
React.createElement(app_typescript_1.Prop, { name: "dateFormat", isRequired: true, type: "string", default: "/", description: 'Date format to use, i.e. "MM/DD/YYYY".' }),
|
|
179831
|
+
React.createElement(app_typescript_1.Prop, { name: "allowSeconds", isRequired: false, type: "boolean", default: "false", description: "Allow seconds in the time picker." }),
|
|
179829
179832
|
React.createElement(app_typescript_1.Prop, { name: "onChange", isRequired: true, type: "Function", default: "/", description: "Callback to invoke when value changes." }),
|
|
179830
179833
|
React.createElement(app_typescript_1.Prop, { name: "label", isRequired: false, type: "string", default: "/", description: "Label of component." }),
|
|
179831
179834
|
React.createElement(app_typescript_1.Prop, { name: "required", isRequired: false, type: "boolean", default: "false", description: "Mark field as required." }),
|
|
@@ -195305,7 +195308,7 @@ exports.ThreePaneLayoutPattern = ThreePaneLayoutPattern;
|
|
|
195305
195308
|
/* 1050 */
|
|
195306
195309
|
/***/ (function(module, exports) {
|
|
195307
195310
|
|
|
195308
|
-
module.exports = {"name":"superdesk-ui-framework","version":"4.1.
|
|
195311
|
+
module.exports = {"name":"superdesk-ui-framework","version":"4.1.5","license":"AGPL-3.0","repository":{"type":"git","url":"https://github.com/superdesk/superdesk-ui-framework.git"},"main":"dist/superdesk-ui.bundle.js","types":"react/index.d.ts","contributors":["Nemanja Pavlovic","Vladimir Stefanovic","Darko Tomic","Aleksandar Jelicic","Tomas Kikutis","Dragana Zivkovic"],"scripts":{"start":"webpack-dev-server --config tasks/webpack.dev.js","server":"webpack --watch --config tasks/webpack.prod.js && tsc-watch","build":"tsc -p tsconfig.json --noEmit && webpack --config tasks/webpack.prod.js && tsc","build-ui":"webpack && tsc && npm run lint","playground-lint":"tsc -p examples/pages/playgrounds/react-playgrounds --noEmit","format-code":"npx prettier . --write","lint":"tsc -p tsconfig.json --noEmit && npx prettier . --check && eslint --parser=@typescript-eslint/parser app && tslint -c tslint.json 'app-typescript/**/*.{ts,tsx}' && npm run playground-lint && npm run unit-test","lint-fix":"tsc -p tsconfig.json --noEmit && tslint --fix -c tslint.json 'app-typescript/**/*.{ts,tsx}'","prepublishOnly":"npm run build","unit-test":"mocha","debug-unit-tests":"mocha --inspect-brk"},"devDependencies":{"@types/assert":"^1.5.6","@types/chart.js":"^2.9.24","@types/classnames":"^2.2.9","@types/enzyme":"^3.10.12","@types/enzyme-adapter-react-16":"^1.0.6","@types/lodash":"^4.14.161","@types/mocha":"^9.1.1","@types/react":"16.8.23","@types/react-beautiful-dnd":"^13.1.2","@types/react-dom":"16.8.0","@types/react-router-dom":"^5.1.2","@types/react-scrollspy":"^3.3.5","@typescript-eslint/parser":"^5.58.0","angular":"^1.7.9","angular-animate":"^1.7.9","angular-route":"^1.7.9","classnames":"^2.2.5","clean-webpack-plugin":"^1.0.0","code-prettify":"^0.1.0","copy-webpack-plugin":"^4.6.0","css-loader":"^2.1.1","enzyme":"^3.11.0","enzyme-adapter-react-16":"^1.15.7","eslint":"^4.6.1","eslint-loader":"^1.9.0","eslint-plugin-angular":"^3.1.1","eslint-plugin-react":"^7.3.0","extract-text-webpack-plugin":"^3.0.2","file-loader":"^0.11.2","html-loader":"^0.5.1","html-webpack-plugin":"^2.30.1","jquery":"^3.1.1","jquery-ui":"^1.12.1","jsdom":"20.0.3","jsdom-global":"3.0.2","lodash":"4.17.21","mocha":"^8.4.0","moment":"^2.29.3","node-sass":"6.0","prettier":"3.5.3","prismjs":"^1.28.0","prop-types":"^15.6.0","react":"16.8.6","react-dom":"16.8.6","react-redux":"^5.0.6","react-router-dom":"^5.1.2","redux":"^3.7.2","redux-form":"^7.0.4","sass-loader":"^6.0.6","style-loader":"^0.18.2","superdesk-code-style":"^1.1.2","ts-loader":"^6.0.2","ts-node":"^10.9.1","tslint":"^5.18.0","typescript":"^5.8.3","url-loader":"^1.1.2","webpack":"^3.5.5","webpack-cli":"3.3.10","webpack-dev-server":"2.11.1","webpack-merge":"^4.2.1"},"dependencies":{"@popperjs/core":"^2.4.0","@sourcefabric/common":"0.0.66","@superdesk/primereact":"^5.0.2-16","@superdesk/react-resizable-panels":"0.0.39","chart.js":"^2.9.3","date-fns":"^4.1.0","popper-max-size-modifier":"^0.2.0","popper.js":"1.14.4","primeicons":"2.0.0","react-beautiful-dnd":"^13.0.0","react-id-generator":"^3.0.0","react-scrollspy":"^3.4.3","tippy.js":"^6.3.7","weekstart":"^2.0.0"},"peerDependencies":{"moment":"*"},"volta":{"node":"14.21.3"}}
|
|
195309
195312
|
|
|
195310
195313
|
/***/ }),
|
|
195311
195314
|
/* 1051 */
|
|
@@ -133394,9 +133394,9 @@ var DateTimePicker = /** @class */ (function (_super) {
|
|
|
133394
133394
|
_this.handleTimeChange = function (time) {
|
|
133395
133395
|
var _a;
|
|
133396
133396
|
if (_this.props.valueType === 'date') {
|
|
133397
|
-
var _b = time.split(':').map(function (x) { return (0, lodash_1.defaultTo)(parseInt(x, 10), 0); }), hours = _b[0], minutes = _b[1];
|
|
133397
|
+
var _b = time.split(':').map(function (x) { return (0, lodash_1.defaultTo)(parseInt(x, 10), 0); }), hours = _b[0], minutes = _b[1], seconds = _b[2];
|
|
133398
133398
|
var origDate = (_a = _this.props.value) !== null && _a !== void 0 ? _a : new Date();
|
|
133399
|
-
origDate.setHours(hours, minutes);
|
|
133399
|
+
origDate.setHours(hours, minutes, _this.props.allowSeconds ? seconds : 0);
|
|
133400
133400
|
_this.props.onChange(origDate);
|
|
133401
133401
|
}
|
|
133402
133402
|
else if (_this.props.valueType === 'object') {
|
|
@@ -133415,7 +133415,7 @@ var DateTimePicker = /** @class */ (function (_super) {
|
|
|
133415
133415
|
}
|
|
133416
133416
|
var origDate = (_a = _this.props.value) !== null && _a !== void 0 ? _a : new Date();
|
|
133417
133417
|
var selectedDate = new Date(date);
|
|
133418
|
-
selectedDate.setHours(origDate.getHours(), origDate.getMinutes());
|
|
133418
|
+
selectedDate.setHours(origDate.getHours(), origDate.getMinutes(), _this.props.allowSeconds ? origDate.getSeconds() : 0);
|
|
133419
133419
|
_this.props.onChange(selectedDate);
|
|
133420
133420
|
}
|
|
133421
133421
|
else if (_this.props.valueType === 'object') {
|
|
@@ -133444,9 +133444,11 @@ var DateTimePicker = /** @class */ (function (_super) {
|
|
|
133444
133444
|
DateTimePicker.prototype.getTimeValue = function () {
|
|
133445
133445
|
var _a;
|
|
133446
133446
|
if (this.props.valueType === 'date') {
|
|
133447
|
-
|
|
133448
|
-
|
|
133449
|
-
|
|
133447
|
+
if (this.props.value == null) {
|
|
133448
|
+
return null;
|
|
133449
|
+
}
|
|
133450
|
+
var seconds = this.props.allowSeconds ? ":".concat(this.prepareFormat(this.props.value.getSeconds())) : '';
|
|
133451
|
+
return "".concat(this.prepareFormat(this.props.value.getHours()), ":").concat(this.prepareFormat(this.props.value.getMinutes())).concat(seconds);
|
|
133450
133452
|
}
|
|
133451
133453
|
else if (this.props.valueType === 'object') {
|
|
133452
133454
|
return (_a = this.props.value.time) !== null && _a !== void 0 ? _a : null;
|
package/package.json
CHANGED
|
@@ -81,9 +81,9 @@ var DateTimePicker = /** @class */ (function (_super) {
|
|
|
81
81
|
_this.handleTimeChange = function (time) {
|
|
82
82
|
var _a;
|
|
83
83
|
if (_this.props.valueType === 'date') {
|
|
84
|
-
var _b = time.split(':').map(function (x) { return (0, lodash_1.defaultTo)(parseInt(x, 10), 0); }), hours = _b[0], minutes = _b[1];
|
|
84
|
+
var _b = time.split(':').map(function (x) { return (0, lodash_1.defaultTo)(parseInt(x, 10), 0); }), hours = _b[0], minutes = _b[1], seconds = _b[2];
|
|
85
85
|
var origDate = (_a = _this.props.value) !== null && _a !== void 0 ? _a : new Date();
|
|
86
|
-
origDate.setHours(hours, minutes);
|
|
86
|
+
origDate.setHours(hours, minutes, _this.props.allowSeconds ? seconds : 0);
|
|
87
87
|
_this.props.onChange(origDate);
|
|
88
88
|
}
|
|
89
89
|
else if (_this.props.valueType === 'object') {
|
|
@@ -102,7 +102,7 @@ var DateTimePicker = /** @class */ (function (_super) {
|
|
|
102
102
|
}
|
|
103
103
|
var origDate = (_a = _this.props.value) !== null && _a !== void 0 ? _a : new Date();
|
|
104
104
|
var selectedDate = new Date(date);
|
|
105
|
-
selectedDate.setHours(origDate.getHours(), origDate.getMinutes());
|
|
105
|
+
selectedDate.setHours(origDate.getHours(), origDate.getMinutes(), _this.props.allowSeconds ? origDate.getSeconds() : 0);
|
|
106
106
|
_this.props.onChange(selectedDate);
|
|
107
107
|
}
|
|
108
108
|
else if (_this.props.valueType === 'object') {
|
|
@@ -131,9 +131,11 @@ var DateTimePicker = /** @class */ (function (_super) {
|
|
|
131
131
|
DateTimePicker.prototype.getTimeValue = function () {
|
|
132
132
|
var _a;
|
|
133
133
|
if (this.props.valueType === 'date') {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
if (this.props.value == null) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
var seconds = this.props.allowSeconds ? ":".concat(this.prepareFormat(this.props.value.getSeconds())) : '';
|
|
138
|
+
return "".concat(this.prepareFormat(this.props.value.getHours()), ":").concat(this.prepareFormat(this.props.value.getMinutes())).concat(seconds);
|
|
137
139
|
}
|
|
138
140
|
else if (this.props.valueType === 'object') {
|
|
139
141
|
return (_a = this.props.value.time) !== null && _a !== void 0 ? _a : null;
|