wini-web-components 2.4.3 → 2.4.4
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/dist/component/button/button.d.ts +4 -0
- package/dist/component/calendar/calendar.d.ts +10 -4
- package/dist/component/calendar/calendar.js +181 -222
- package/dist/component/date-picker/date-picker.js +2 -2
- package/dist/component/dialog/dialog.d.ts +1 -0
- package/dist/component/dialog/dialog.js +6 -1
- package/dist/component/import-file/import-file.d.ts +1 -0
- package/dist/component/import-file/import-file.js +3 -3
- package/dist/component/input-otp/input-otp.d.ts +21 -0
- package/dist/component/input-otp/input-otp.js +157 -0
- package/dist/component/tag/tag.d.ts +4 -0
- package/dist/component/tag/tag.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -7,6 +7,10 @@ interface ButtonProps {
|
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
style?: CSSProperties;
|
|
9
9
|
type?: "button" | "reset" | "submit";
|
|
10
|
+
/**
|
|
11
|
+
* default: size32: button-text-3 \
|
|
12
|
+
* recommend: size64: button-text-1 | size56: button-text-1 | size48: button-text-1 | size40: button-text-3 | size32: button-text-3 | size24: button-text-5
|
|
13
|
+
* */
|
|
10
14
|
className?: string;
|
|
11
15
|
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
12
16
|
}
|
|
@@ -12,18 +12,24 @@ export declare enum CalendarType {
|
|
|
12
12
|
}
|
|
13
13
|
interface CalendarProps extends WithTranslation {
|
|
14
14
|
id?: string;
|
|
15
|
-
value?: Date
|
|
15
|
+
value?: Date | {
|
|
16
|
+
sTime: Date;
|
|
17
|
+
eTime: Date;
|
|
18
|
+
};
|
|
19
|
+
range?: boolean;
|
|
16
20
|
min?: Date;
|
|
17
21
|
max?: Date;
|
|
18
|
-
onSelect?: (props: Date
|
|
22
|
+
onSelect?: (props: Date | {
|
|
23
|
+
sTime: Date;
|
|
24
|
+
eTime: Date;
|
|
25
|
+
}) => void;
|
|
19
26
|
disabled?: boolean;
|
|
20
27
|
helperText?: string;
|
|
21
28
|
helperTextColor?: string;
|
|
22
29
|
placeholder?: string;
|
|
23
30
|
className?: string;
|
|
24
31
|
style?: CSSProperties;
|
|
25
|
-
|
|
26
|
-
showSidebar?: boolean;
|
|
32
|
+
header?: ReactNode;
|
|
27
33
|
footer?: ReactNode;
|
|
28
34
|
}
|
|
29
35
|
export declare const Calendar: React.ComponentType<Omit<import("react-i18next/helpers").$Subtract<CalendarProps, import("react-i18next").WithTranslationProps>, keyof WithTranslation<Ns, undefined>> & import("react-i18next").WithTranslationProps>;
|
|
@@ -33,8 +33,8 @@ exports.Calendar = exports.CalendarType = exports.inRangeTime = exports.endDate
|
|
|
33
33
|
var react_1 = __importDefault(require("react"));
|
|
34
34
|
var calendar_module_css_1 = __importDefault(require("./calendar.module.css"));
|
|
35
35
|
var date_fns_1 = require("date-fns");
|
|
36
|
-
var winicon_1 = require("../wini-icon/winicon");
|
|
37
36
|
var react_i18next_1 = require("react-i18next");
|
|
37
|
+
var winicon_1 = require("../wini-icon/winicon");
|
|
38
38
|
exports.today = new Date();
|
|
39
39
|
exports.startDate = new Date(exports.today.getFullYear() - 100, exports.today.getMonth(), exports.today.getDate());
|
|
40
40
|
exports.endDate = new Date(exports.today.getFullYear() + 100, exports.today.getMonth(), exports.today.getDate());
|
|
@@ -47,27 +47,66 @@ var CalendarType;
|
|
|
47
47
|
CalendarType[CalendarType["YEAR"] = 2] = "YEAR";
|
|
48
48
|
CalendarType[CalendarType["DATETIME"] = 3] = "DATETIME";
|
|
49
49
|
})(CalendarType || (exports.CalendarType = CalendarType = {}));
|
|
50
|
+
var CalendarTab;
|
|
51
|
+
(function (CalendarTab) {
|
|
52
|
+
CalendarTab[CalendarTab["DATE"] = 0] = "DATE";
|
|
53
|
+
CalendarTab[CalendarTab["MONTH"] = 1] = "MONTH";
|
|
54
|
+
CalendarTab[CalendarTab["YEAR"] = 2] = "YEAR";
|
|
55
|
+
})(CalendarTab || (CalendarTab = {}));
|
|
56
|
+
var stateValue = function (minDate, maxDate, value, range) {
|
|
57
|
+
var defaultValue;
|
|
58
|
+
if (value) {
|
|
59
|
+
if (range) {
|
|
60
|
+
if (value instanceof Date)
|
|
61
|
+
defaultValue = { sTime: value, eTime: value };
|
|
62
|
+
else
|
|
63
|
+
defaultValue = value;
|
|
64
|
+
if (defaultValue.sTime.getTime() < minDate.getTime())
|
|
65
|
+
defaultValue.sTime = minDate;
|
|
66
|
+
if (defaultValue.eTime.getTime() > maxDate.getTime())
|
|
67
|
+
defaultValue.eTime = maxDate;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
if (value instanceof Date)
|
|
71
|
+
defaultValue = value;
|
|
72
|
+
else
|
|
73
|
+
defaultValue = value.sTime;
|
|
74
|
+
if (defaultValue.getTime() < minDate.getTime())
|
|
75
|
+
defaultValue = minDate;
|
|
76
|
+
if (defaultValue.getTime() > maxDate.getTime())
|
|
77
|
+
defaultValue = maxDate;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
defaultValue = range ? { sTime: exports.today, eTime: exports.today } : exports.today;
|
|
82
|
+
}
|
|
83
|
+
var defaultMonth = defaultValue instanceof Date ? defaultValue.getMonth() : defaultValue.sTime.getMonth();
|
|
84
|
+
var defaultYear = defaultValue instanceof Date ? defaultValue.getFullYear() : defaultValue.sTime.getFullYear();
|
|
85
|
+
return {
|
|
86
|
+
value: value ? defaultValue : undefined,
|
|
87
|
+
selectMonth: defaultMonth,
|
|
88
|
+
selectYear: defaultYear,
|
|
89
|
+
tab: CalendarTab.DATE,
|
|
90
|
+
};
|
|
91
|
+
};
|
|
50
92
|
var TCalendar = /** @class */ (function (_super) {
|
|
51
93
|
__extends(TCalendar, _super);
|
|
52
94
|
function TCalendar(props) {
|
|
53
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
54
95
|
var _this = _super.call(this, props) || this;
|
|
55
|
-
_this.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
selectMonth: ((_c = _this.props.value) !== null && _c !== void 0 ? _c : exports.today).getMonth(),
|
|
59
|
-
selectYear: ((_d = _this.props.value) !== null && _d !== void 0 ? _d : exports.today).getFullYear(),
|
|
60
|
-
type: CalendarType.DATE,
|
|
61
|
-
selectHours: (_f = (_e = _this.props.value) === null || _e === void 0 ? void 0 : _e.getHours()) !== null && _f !== void 0 ? _f : 0,
|
|
62
|
-
selectMinutes: (_h = (_g = _this.props.value) === null || _g === void 0 ? void 0 : _g.getMinutes()) !== null && _h !== void 0 ? _h : 0,
|
|
63
|
-
selectSeconds: (_k = (_j = _this.props.value) === null || _j === void 0 ? void 0 : _j.getSeconds()) !== null && _k !== void 0 ? _k : 0,
|
|
64
|
-
};
|
|
96
|
+
_this.minDate = !_this.props.min || _this.props.min.getTime() < exports.startDate.getTime() ? exports.startDate : _this.props.min;
|
|
97
|
+
_this.maxDate = !_this.props.max || _this.props.max.getTime() > exports.endDate.getTime() ? exports.endDate : _this.props.max;
|
|
98
|
+
_this.state = stateValue(_this.minDate, _this.maxDate, _this.props.value, _this.props.range);
|
|
65
99
|
_this.showDateInMonth = _this.showDateInMonth.bind(_this);
|
|
66
100
|
_this.showMonthInYear = _this.showMonthInYear.bind(_this);
|
|
67
101
|
_this.showYearInRange = _this.showYearInRange.bind(_this);
|
|
68
102
|
_this.getTitle = _this.getTitle.bind(_this);
|
|
69
103
|
return _this;
|
|
70
104
|
}
|
|
105
|
+
TCalendar.prototype.componentDidUpdate = function (prevProps, prevState, snapshot) {
|
|
106
|
+
if (prevProps.value !== this.props.value) {
|
|
107
|
+
this.setState(stateValue(this.minDate, this.maxDate, this.props.value, this.props.range));
|
|
108
|
+
}
|
|
109
|
+
};
|
|
71
110
|
TCalendar.prototype.showDateInMonth = function () {
|
|
72
111
|
var _this = this;
|
|
73
112
|
var firstDayOfMonth = new Date(this.state.selectYear, this.state.selectMonth, 1);
|
|
@@ -99,42 +138,55 @@ var TCalendar = /** @class */ (function (_super) {
|
|
|
99
138
|
weekdayTitle = '';
|
|
100
139
|
break;
|
|
101
140
|
}
|
|
102
|
-
return react_1.default.createElement("div", { key: 'dtwk-' + i, className: "".concat(calendar_module_css_1.default['date-picker-circle'], "
|
|
141
|
+
return react_1.default.createElement("div", { key: 'dtwk-' + i, className: "".concat(calendar_module_css_1.default['date-picker-circle'], " date-picker-circle") },
|
|
142
|
+
react_1.default.createElement("span", { className: "label-4 row" }, weekdayTitle));
|
|
103
143
|
}),
|
|
104
144
|
Array.from({ length: 42 }).map(function (_, i) {
|
|
105
|
-
var _a, _b;
|
|
145
|
+
var _a, _b, _c;
|
|
106
146
|
var dateNumber = (i % 7) + (Math.floor(i / 7) * 7) - firstDayOfMonth.getDay();
|
|
107
|
-
var timeValue = new Date(_this.state.selectYear, _this.state.selectMonth, dateNumber + 1
|
|
108
|
-
var
|
|
109
|
-
var
|
|
110
|
-
var selected = false;
|
|
147
|
+
var timeValue = new Date(_this.state.selectYear, _this.state.selectMonth, dateNumber + 1);
|
|
148
|
+
var className = "".concat(calendar_module_css_1.default['date-picker-circle'], " date-picker-circle");
|
|
149
|
+
var typoClassName = "body-3";
|
|
111
150
|
if (dateNumber + 1 === exports.today.getDate() && _this.state.selectMonth === exports.today.getMonth() && _this.state.selectYear === exports.today.getFullYear()) {
|
|
112
|
-
|
|
151
|
+
className += " ".concat(calendar_module_css_1.default['today']);
|
|
113
152
|
}
|
|
114
|
-
|
|
115
|
-
|
|
153
|
+
var style;
|
|
154
|
+
if (!(0, exports.inRangeTime)(timeValue, _this.minDate, _this.maxDate)) {
|
|
155
|
+
className += " ".concat(calendar_module_css_1.default['invalid']);
|
|
116
156
|
}
|
|
117
|
-
else if (
|
|
118
|
-
|
|
157
|
+
else if (_this.state.value instanceof Date) {
|
|
158
|
+
if (_this.state.value.getTime() === timeValue.getTime())
|
|
159
|
+
className += " ".concat(calendar_module_css_1.default['selected']);
|
|
119
160
|
}
|
|
120
|
-
else if (_this.state.value.
|
|
121
|
-
|
|
122
|
-
selected = true;
|
|
161
|
+
else if (((_a = _this.state.value) === null || _a === void 0 ? void 0 : _a.sTime.getTime()) === timeValue.getTime() || ((_b = _this.state.value) === null || _b === void 0 ? void 0 : _b.eTime.getTime()) === timeValue.getTime()) {
|
|
162
|
+
className += " ".concat(calendar_module_css_1.default['selected'], " ").concat(calendar_module_css_1.default["".concat(((_c = _this.state.value) === null || _c === void 0 ? void 0 : _c.sTime.getTime()) === timeValue.getTime() ? "start" : "end", "-range")]);
|
|
123
163
|
}
|
|
124
|
-
else if (
|
|
125
|
-
|
|
164
|
+
else if (_this.state.value && (0, exports.inRangeTime)(timeValue, _this.state.value.sTime, _this.state.value.eTime)) {
|
|
165
|
+
className += " ".concat(calendar_module_css_1.default['in-range']);
|
|
126
166
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
167
|
+
if (timeValue.getMonth() !== _this.state.selectMonth) {
|
|
168
|
+
typoClassName = "placeholder-2";
|
|
169
|
+
}
|
|
170
|
+
return react_1.default.createElement("div", { key: timeValue.toString(), className: className, style: style },
|
|
171
|
+
react_1.default.createElement("button", { type: "button", className: "".concat(typoClassName, " row"), onClick: function () {
|
|
172
|
+
var currentValue = _this.state.value;
|
|
173
|
+
if (_this.props.range) {
|
|
174
|
+
var newValue = (!currentValue || timeValue.getTime() < currentValue.sTime.getTime()) ? { sTime: timeValue, eTime: timeValue } : { sTime: currentValue.sTime, eTime: timeValue };
|
|
175
|
+
_this.setState(__assign(__assign({}, _this.state), { value: newValue }));
|
|
176
|
+
if (_this.props.onSelect)
|
|
177
|
+
_this.props.onSelect(newValue);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
_this.setState(__assign(__assign({}, _this.state), { value: timeValue }));
|
|
181
|
+
if (_this.props.onSelect)
|
|
182
|
+
_this.props.onSelect(timeValue);
|
|
183
|
+
}
|
|
184
|
+
} }, timeValue.getDate()));
|
|
132
185
|
}));
|
|
133
186
|
};
|
|
134
187
|
TCalendar.prototype.showMonthInYear = function () {
|
|
135
188
|
var _this = this;
|
|
136
189
|
return react_1.default.createElement(react_1.default.Fragment, null, Array.from({ length: 12 }).map(function (_, i) {
|
|
137
|
-
var _a, _b, _c;
|
|
138
190
|
switch (i) {
|
|
139
191
|
case 0:
|
|
140
192
|
var monthTitle = _this.props.i18n.language === "en" ? "Jan" : _this.props.t('january');
|
|
@@ -176,75 +228,61 @@ var TCalendar = /** @class */ (function (_super) {
|
|
|
176
228
|
monthTitle = '';
|
|
177
229
|
break;
|
|
178
230
|
}
|
|
179
|
-
var timeValue = new Date(_this.state.selectYear, i
|
|
180
|
-
var
|
|
181
|
-
var style = {};
|
|
182
|
-
var selected = false;
|
|
231
|
+
var timeValue = new Date(_this.state.selectYear, i);
|
|
232
|
+
var className = "".concat(calendar_module_css_1.default['month-picker-circle'], " month-picker-circle");
|
|
183
233
|
if (_this.state.selectYear === exports.today.getFullYear() && exports.today.getMonth() === i) {
|
|
184
|
-
|
|
234
|
+
className += " ".concat(calendar_module_css_1.default['today']);
|
|
185
235
|
}
|
|
186
|
-
if (!(0, exports.inRangeTime)(timeValue,
|
|
187
|
-
|
|
236
|
+
if (!(0, exports.inRangeTime)(timeValue, _this.minDate, _this.maxDate)) {
|
|
237
|
+
className += " ".concat(calendar_module_css_1.default['invalid']);
|
|
188
238
|
}
|
|
189
|
-
else if (
|
|
190
|
-
if (_this.state.selectYear ===
|
|
191
|
-
|
|
192
|
-
color: 'var(--neutral-text-disabled-color)',
|
|
193
|
-
pointerEvents: 'none'
|
|
194
|
-
};
|
|
195
|
-
}
|
|
239
|
+
else if (_this.state.value instanceof Date) {
|
|
240
|
+
if (_this.state.selectYear === _this.state.value.getFullYear() && i === _this.state.value.getMonth())
|
|
241
|
+
className += " ".concat(calendar_module_css_1.default['selected']);
|
|
196
242
|
}
|
|
197
|
-
if (_this.state.
|
|
198
|
-
selected
|
|
243
|
+
else if (_this.state.value && ((i === _this.state.value.sTime.getMonth() && _this.state.value.sTime.getFullYear() === _this.state.selectYear) || (i === _this.state.value.eTime.getMonth() && _this.state.value.eTime.getFullYear() === _this.state.selectYear))) {
|
|
244
|
+
className += " ".concat(calendar_module_css_1.default['selected'], " ").concat(calendar_module_css_1.default["".concat(i === _this.state.value.sTime.getMonth() && _this.state.value.sTime.getFullYear() === _this.state.selectYear ? "start" : "end", "-range")]);
|
|
199
245
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
_this.setState(__assign(__assign({}, _this.state), { selectMonth: i, type: CalendarType.DATE }));
|
|
208
|
-
}
|
|
209
|
-
} }), monthTitle);
|
|
246
|
+
else if (_this.state.value && (0, exports.inRangeTime)(timeValue, _this.state.value.sTime, _this.state.value.eTime)) {
|
|
247
|
+
className += " ".concat(calendar_module_css_1.default['in-range']);
|
|
248
|
+
}
|
|
249
|
+
return react_1.default.createElement("div", { key: timeValue.toString(), className: className },
|
|
250
|
+
react_1.default.createElement("button", { type: "button", className: "body-3 row", onClick: function () { _this.setState(__assign(__assign({}, _this.state), { selectMonth: i, tab: CalendarTab.DATE })); } }, monthTitle));
|
|
210
251
|
}));
|
|
211
252
|
};
|
|
212
253
|
TCalendar.prototype.showYearInRange = function () {
|
|
213
254
|
var _this = this;
|
|
214
|
-
return
|
|
215
|
-
var _a, _b;
|
|
255
|
+
return Array.from({ length: 12 }).map(function (_, i) {
|
|
256
|
+
var _a, _b, _c;
|
|
216
257
|
var firstYearInTable = _this.state.selectYear - ((_this.state.selectYear - exports.startDate.getFullYear()) % 12);
|
|
217
258
|
var yearNumber = i + firstYearInTable;
|
|
218
|
-
var
|
|
219
|
-
var style = {};
|
|
220
|
-
var selected = false;
|
|
259
|
+
var className = "".concat(calendar_module_css_1.default['year-picker-circle'], " year-picker-circle");
|
|
221
260
|
if (yearNumber === exports.today.getFullYear()) {
|
|
222
|
-
|
|
261
|
+
className += " ".concat(calendar_module_css_1.default['today']);
|
|
223
262
|
}
|
|
224
|
-
|
|
225
|
-
|
|
263
|
+
if (yearNumber < _this.minDate.getFullYear() || yearNumber > _this.maxDate.getFullYear()) {
|
|
264
|
+
className += " ".concat(calendar_module_css_1.default['invalid']);
|
|
226
265
|
}
|
|
227
|
-
if (
|
|
228
|
-
|
|
266
|
+
else if (_this.state.value instanceof Date) {
|
|
267
|
+
if (yearNumber === _this.state.value.getFullYear())
|
|
268
|
+
className += " ".concat(calendar_module_css_1.default['selected']);
|
|
229
269
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
} }), yearNumber);
|
|
240
|
-
}));
|
|
270
|
+
else if (yearNumber === ((_a = _this.state.value) === null || _a === void 0 ? void 0 : _a.sTime.getFullYear()) || yearNumber === ((_b = _this.state.value) === null || _b === void 0 ? void 0 : _b.eTime.getFullYear())) {
|
|
271
|
+
className += " ".concat(calendar_module_css_1.default['selected'], " ").concat(calendar_module_css_1.default["".concat(yearNumber === ((_c = _this.state.value) === null || _c === void 0 ? void 0 : _c.sTime.getFullYear()) ? "start" : "end", "-range")]);
|
|
272
|
+
}
|
|
273
|
+
else if (_this.state.value && yearNumber > _this.state.value.sTime.getFullYear() && yearNumber < _this.state.value.eTime.getFullYear()) {
|
|
274
|
+
className += " ".concat(calendar_module_css_1.default['in-range']);
|
|
275
|
+
}
|
|
276
|
+
return react_1.default.createElement("div", { key: yearNumber.toString(), className: className },
|
|
277
|
+
react_1.default.createElement("button", { type: "button", className: "body-3 row", onClick: function () { _this.setState(__assign(__assign({}, _this.state), { tab: CalendarTab.MONTH, selectYear: yearNumber })); } }, yearNumber));
|
|
278
|
+
});
|
|
241
279
|
};
|
|
242
280
|
TCalendar.prototype.getTitle = function () {
|
|
243
|
-
switch (this.state.
|
|
244
|
-
case
|
|
281
|
+
switch (this.state.tab) {
|
|
282
|
+
case CalendarTab.YEAR:
|
|
245
283
|
var firstYearInTable = this.state.selectYear - ((this.state.selectYear - exports.startDate.getFullYear()) % 12);
|
|
246
284
|
return "".concat(firstYearInTable, "-").concat(firstYearInTable + 11);
|
|
247
|
-
case
|
|
285
|
+
case CalendarTab.MONTH:
|
|
248
286
|
return this.state.selectYear;
|
|
249
287
|
default:
|
|
250
288
|
switch (this.state.selectMonth) {
|
|
@@ -293,144 +331,65 @@ var TCalendar = /** @class */ (function (_super) {
|
|
|
293
331
|
};
|
|
294
332
|
TCalendar.prototype.render = function () {
|
|
295
333
|
var _this = this;
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
react_1.default.createElement("button", { type:
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
_this.setState(__assign(__assign({}, _this.state), { type: _this.state.type === CalendarType.DATE ? CalendarType.MONTH : CalendarType.YEAR }));
|
|
356
|
-
} }, this.getTitle()),
|
|
357
|
-
react_1.default.createElement("button", { type: 'button', onClick: function () {
|
|
358
|
-
switch (_this.state.type) {
|
|
359
|
-
case CalendarType.YEAR:
|
|
360
|
-
if (_this.state.selectYear + 10 > exports.endDate.getFullYear()) {
|
|
361
|
-
_this.setState(__assign(__assign({}, _this.state), { selectYear: exports.endDate.getFullYear() }));
|
|
362
|
-
}
|
|
363
|
-
else {
|
|
364
|
-
_this.setState(__assign(__assign({}, _this.state), { selectYear: _this.state.selectYear + 10 }));
|
|
365
|
-
}
|
|
366
|
-
break;
|
|
367
|
-
case CalendarType.MONTH:
|
|
368
|
-
if (_this.state.selectYear + 1 <= exports.endDate.getFullYear()) {
|
|
369
|
-
_this.setState(__assign(__assign({}, _this.state), { selectYear: _this.state.selectYear + 1 }));
|
|
370
|
-
}
|
|
371
|
-
break;
|
|
372
|
-
default:
|
|
373
|
-
var newDataVl = new Date(_this.state.selectYear, _this.state.selectMonth + 1, 1);
|
|
374
|
-
_this.setState(__assign(__assign({}, _this.state), { selectMonth: newDataVl.getMonth(), selectYear: newDataVl.getFullYear() }));
|
|
375
|
-
break;
|
|
376
|
-
}
|
|
377
|
-
} },
|
|
378
|
-
react_1.default.createElement(winicon_1.Winicon, { src: "fill/arrows/right-arrow", size: '1.4rem' })),
|
|
379
|
-
react_1.default.createElement("button", { type: 'button', onClick: function () {
|
|
380
|
-
switch (_this.state.type) {
|
|
381
|
-
case CalendarType.YEAR:
|
|
382
|
-
if (_this.state.selectYear + 20 > exports.endDate.getFullYear()) {
|
|
383
|
-
_this.setState(__assign(__assign({}, _this.state), { selectYear: exports.endDate.getFullYear() }));
|
|
384
|
-
}
|
|
385
|
-
else {
|
|
386
|
-
_this.setState(__assign(__assign({}, _this.state), { selectYear: _this.state.selectYear + 20 }));
|
|
387
|
-
}
|
|
388
|
-
break;
|
|
389
|
-
case CalendarType.MONTH:
|
|
390
|
-
if (_this.state.selectYear + 10 < exports.endDate.getFullYear()) {
|
|
391
|
-
_this.setState(__assign(__assign({}, _this.state), { selectYear: exports.endDate.getFullYear() }));
|
|
392
|
-
}
|
|
393
|
-
else {
|
|
394
|
-
_this.setState(__assign(__assign({}, _this.state), { selectYear: _this.state.selectYear + 10 }));
|
|
395
|
-
}
|
|
396
|
-
break;
|
|
397
|
-
default:
|
|
398
|
-
_this.setState(__assign(__assign({}, _this.state), { selectYear: _this.state.selectYear + 1 }));
|
|
399
|
-
break;
|
|
400
|
-
}
|
|
401
|
-
} },
|
|
402
|
-
react_1.default.createElement(winicon_1.Winicon, { src: "fill/arrows/double-arrow-right", size: '1.4rem' }))),
|
|
403
|
-
react_1.default.createElement("div", { className: "".concat(calendar_module_css_1.default['picker-date-body'], " row") }, this.state.type === CalendarType.YEAR ? this.showYearInRange() : this.state.type === CalendarType.MONTH ? this.showMonthInYear() : this.showDateInMonth())),
|
|
404
|
-
this.props.type === CalendarType.DATETIME ? react_1.default.createElement("div", { className: "".concat(calendar_module_css_1.default['picker-time-container'], " col") },
|
|
405
|
-
react_1.default.createElement("div", { className: "heading-7" },
|
|
406
|
-
this.state.selectHours < 10 ? "0".concat(this.state.selectHours) : this.state.selectHours,
|
|
407
|
-
":",
|
|
408
|
-
this.state.selectMinutes < 10 ? "0".concat(this.state.selectMinutes) : this.state.selectMinutes,
|
|
409
|
-
":",
|
|
410
|
-
this.state.selectSeconds < 10 ? "0".concat(this.state.selectSeconds) : this.state.selectSeconds),
|
|
411
|
-
react_1.default.createElement("div", { className: "row", style: { alignItems: 'start', flex: 1, height: '100%' } },
|
|
412
|
-
react_1.default.createElement("div", { className: "".concat(calendar_module_css_1.default['scroll-picker-hours'], " scroll-picker-hours col") }, Array.from({ length: 24 }).map(function (_, i) { return react_1.default.createElement("button", { type: "button", onClick: function () {
|
|
413
|
-
var newValue = _this.state.value;
|
|
414
|
-
newValue.setHours(i);
|
|
415
|
-
_this.setState(__assign(__assign({}, _this.state), { selectHours: i, value: newValue }));
|
|
416
|
-
if (_this.props.onSelect)
|
|
417
|
-
_this.props.onSelect(newValue);
|
|
418
|
-
}, key: "hours-".concat(i), className: "label-4 ".concat(_this.state.selectHours === (i) ? calendar_module_css_1.default['selected'] : '') }, i < 10 ? "0".concat(i) : i); })),
|
|
419
|
-
react_1.default.createElement("div", { className: "".concat(calendar_module_css_1.default['scroll-picker-minutes'], " scroll-picker-minutes col") }, Array.from({ length: 60 }).map(function (_, i) { return react_1.default.createElement("button", { type: "button", onClick: function () {
|
|
420
|
-
var newValue = _this.state.value;
|
|
421
|
-
newValue.setMinutes(i);
|
|
422
|
-
_this.setState(__assign(__assign({}, _this.state), { selectMinutes: i, value: newValue }));
|
|
423
|
-
if (_this.props.onSelect)
|
|
424
|
-
_this.props.onSelect(newValue);
|
|
425
|
-
}, key: "hours-".concat(i), className: "label-4 ".concat(_this.state.selectMinutes === (i) ? calendar_module_css_1.default['selected'] : '') }, i < 10 ? "0".concat(i) : i); })),
|
|
426
|
-
react_1.default.createElement("div", { className: "".concat(calendar_module_css_1.default['scroll-picker-seconds'], " scroll-picker-seconds col") }, Array.from({ length: 60 }).map(function (_, i) { return react_1.default.createElement("button", { type: "button", onClick: function () {
|
|
427
|
-
var newValue = _this.state.value;
|
|
428
|
-
newValue.setSeconds(i);
|
|
429
|
-
_this.setState(__assign(__assign({}, _this.state), { selectSeconds: i, value: newValue }));
|
|
430
|
-
if (_this.props.onSelect)
|
|
431
|
-
_this.props.onSelect(newValue);
|
|
432
|
-
}, key: "hours-".concat(i), className: "label-4 ".concat(_this.state.selectSeconds === (i) ? calendar_module_css_1.default['selected'] : '') }, i < 10 ? "0".concat(i) : i); })))) : null),
|
|
433
|
-
this.props.footer));
|
|
334
|
+
return react_1.default.createElement("div", { className: "".concat(calendar_module_css_1.default['calendar-container'], " col") },
|
|
335
|
+
this.props.header,
|
|
336
|
+
react_1.default.createElement("div", { className: "".concat(calendar_module_css_1.default['picker-date-header'], " row") },
|
|
337
|
+
react_1.default.createElement("button", { type: 'button', onClick: function () {
|
|
338
|
+
switch (_this.state.tab) {
|
|
339
|
+
case CalendarTab.YEAR:
|
|
340
|
+
if (_this.state.selectYear - 10 < exports.startDate.getFullYear()) {
|
|
341
|
+
_this.setState(__assign(__assign({}, _this.state), { selectYear: exports.startDate.getFullYear() }));
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
_this.setState(__assign(__assign({}, _this.state), { selectYear: _this.state.selectYear - 10 }));
|
|
345
|
+
}
|
|
346
|
+
break;
|
|
347
|
+
case CalendarTab.MONTH:
|
|
348
|
+
var newTime = new Date(_this.state.selectYear, _this.state.selectMonth - 1);
|
|
349
|
+
if (newTime.getTime() >= exports.startDate.getTime()) {
|
|
350
|
+
_this.setState(__assign(__assign({}, _this.state), { selectYear: _this.state.selectYear - 1 }));
|
|
351
|
+
}
|
|
352
|
+
break;
|
|
353
|
+
default:
|
|
354
|
+
var newDataVl = new Date(_this.state.selectYear, _this.state.selectMonth - 1);
|
|
355
|
+
if (newDataVl.getTime() >= exports.startDate.getTime()) {
|
|
356
|
+
_this.setState(__assign(__assign({}, _this.state), { selectMonth: newDataVl.getMonth(), selectYear: newDataVl.getFullYear() }));
|
|
357
|
+
}
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
} },
|
|
361
|
+
react_1.default.createElement(winicon_1.Winicon, { src: "fill/arrows/left-arrow", size: '1.4rem' })),
|
|
362
|
+
react_1.default.createElement("span", { className: "heading-7", onClick: function () {
|
|
363
|
+
if (_this.state.tab !== CalendarTab.YEAR)
|
|
364
|
+
_this.setState(__assign(__assign({}, _this.state), { tab: _this.state.tab === CalendarTab.DATE ? CalendarTab.MONTH : CalendarTab.YEAR }));
|
|
365
|
+
} }, this.getTitle()),
|
|
366
|
+
react_1.default.createElement("button", { type: 'button', onClick: function () {
|
|
367
|
+
switch (_this.state.tab) {
|
|
368
|
+
case CalendarTab.YEAR:
|
|
369
|
+
if (_this.state.selectYear + 10 > exports.endDate.getFullYear()) {
|
|
370
|
+
_this.setState(__assign(__assign({}, _this.state), { selectYear: exports.endDate.getFullYear() }));
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
_this.setState(__assign(__assign({}, _this.state), { selectYear: _this.state.selectYear + 10 }));
|
|
374
|
+
}
|
|
375
|
+
break;
|
|
376
|
+
case CalendarTab.MONTH:
|
|
377
|
+
var newTime = new Date(_this.state.selectYear, _this.state.selectMonth + 1);
|
|
378
|
+
if (newTime.getTime() <= exports.endDate.getTime()) {
|
|
379
|
+
_this.setState(__assign(__assign({}, _this.state), { selectYear: _this.state.selectYear + 1 }));
|
|
380
|
+
}
|
|
381
|
+
break;
|
|
382
|
+
default:
|
|
383
|
+
var newDataVl = new Date(_this.state.selectYear, _this.state.selectMonth + 1);
|
|
384
|
+
if (newDataVl.getTime() <= exports.endDate.getTime()) {
|
|
385
|
+
_this.setState(__assign(__assign({}, _this.state), { selectMonth: newDataVl.getMonth(), selectYear: newDataVl.getFullYear() }));
|
|
386
|
+
}
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
} },
|
|
390
|
+
react_1.default.createElement(winicon_1.Winicon, { src: "fill/arrows/right-arrow", size: '1.4rem' }))),
|
|
391
|
+
react_1.default.createElement("div", { className: "".concat(calendar_module_css_1.default['picker-date-body'], " row") }, this.state.tab === CalendarTab.YEAR ? this.showYearInRange() : this.state.tab === CalendarTab.MONTH ? this.showMonthInYear() : this.showDateInMonth()),
|
|
392
|
+
this.props.footer);
|
|
434
393
|
};
|
|
435
394
|
return TCalendar;
|
|
436
395
|
}(react_1.default.Component));
|
|
@@ -194,7 +194,7 @@ var TDatePicker = /** @class */ (function (_super) {
|
|
|
194
194
|
};
|
|
195
195
|
TDatePicker.prototype.render = function () {
|
|
196
196
|
var _this = this;
|
|
197
|
-
var _a, _b, _c, _d, _e, _f
|
|
197
|
+
var _a, _b, _c, _d, _e, _f;
|
|
198
198
|
var t = this.props.t;
|
|
199
199
|
var maxLength = 10;
|
|
200
200
|
switch (this.props.pickerType) {
|
|
@@ -314,7 +314,7 @@ var TDatePicker = /** @class */ (function (_super) {
|
|
|
314
314
|
if (ev.target.classList.contains('popup-overlay'))
|
|
315
315
|
_this.setState(__assign(__assign({}, _this.state), { isOpen: false }));
|
|
316
316
|
} },
|
|
317
|
-
react_1.default.createElement(index_1.Calendar, { min: this.props.min, max: this.props.max, value: this.getNewValue(),
|
|
317
|
+
react_1.default.createElement(index_1.Calendar, { min: this.props.min, max: this.props.max, value: this.getNewValue(), className: 'date-picker-popup-container', style: (_f = this.state.style) !== null && _f !== void 0 ? _f : { top: this.state.offset.y + this.state.offset.height + 2 + 'px', left: this.state.offset.x + 'px', border: 'none', boxShadow: '-20px 20px 40px -4px rgba(145, 158, 171, 0.24), 0px 0px 2px 0px rgba(145, 158, 171, 0.24)' }, onSelect: function (dateValue) {
|
|
318
318
|
var _a;
|
|
319
319
|
switch (_this.props.pickerType) {
|
|
320
320
|
case index_1.CalendarType.YEAR:
|
|
@@ -106,7 +106,11 @@ var TDialog = /** @class */ (function (_super) {
|
|
|
106
106
|
react_1.default.createElement(index_1.Text, { className: 'heading-6', style: { textAlign: this.state.alignment === DialogAlignment.center ? 'center' : 'start' } }, this.state.title),
|
|
107
107
|
react_1.default.createElement(index_1.Text, { className: 'body-3', style: { textAlign: this.state.alignment === DialogAlignment.center ? 'center' : 'start' } }, this.state.content))),
|
|
108
108
|
react_1.default.createElement("div", { className: "".concat(dialog_module_css_1.default['dialog-footer'], " row") },
|
|
109
|
-
react_1.default.createElement("button", { type: 'button', style: this.state.alignment === DialogAlignment.center ? { flex: 1, width: '100%' } : undefined, onClick: function () {
|
|
109
|
+
react_1.default.createElement("button", { type: 'button', style: this.state.alignment === DialogAlignment.center ? { flex: 1, width: '100%' } : undefined, onClick: function () {
|
|
110
|
+
if (_this.state.onCancel)
|
|
111
|
+
_this.state.onCancel();
|
|
112
|
+
_this.setState({ open: false });
|
|
113
|
+
}, className: "".concat(dialog_module_css_1.default['dialog-action'], " row") },
|
|
110
114
|
react_1.default.createElement(index_1.Text, { className: 'button-text-3' }, (_a = this.state.cancelTitle) !== null && _a !== void 0 ? _a : t("cancel"))),
|
|
111
115
|
react_1.default.createElement("button", { type: 'button', style: this.state.alignment === DialogAlignment.center ? { flex: 1, width: '100%' } : undefined, onClick: function () {
|
|
112
116
|
_this.state.onSubmit();
|
|
@@ -130,6 +134,7 @@ var showDialog = function (props) {
|
|
|
130
134
|
status: (_b = props.status) !== null && _b !== void 0 ? _b : index_1.ComponentStatus.INFOR,
|
|
131
135
|
content: (_c = props.content) !== null && _c !== void 0 ? _c : '',
|
|
132
136
|
onSubmit: (_d = props.onSubmit) !== null && _d !== void 0 ? _d : (function () { }),
|
|
137
|
+
onCancel: props.onCancel,
|
|
133
138
|
submitTitle: props.submitTitle,
|
|
134
139
|
cancelTitle: props.cancelTitle,
|
|
135
140
|
alignment: props.alignment
|