wini-web-components 0.5.0 → 0.5.2
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/calendar/calendar.d.ts +46 -0
- package/dist/component/calendar/calendar.js +426 -0
- package/dist/component/checkbox/checkbox.d.ts +20 -0
- package/dist/component/checkbox/checkbox.js +79 -0
- package/dist/component/component-status.d.ts +8 -0
- package/dist/component/component-status.js +32 -0
- package/dist/component/date-picker/date-picker.d.ts +31 -0
- package/dist/component/date-picker/date-picker.js +358 -0
- package/dist/component/dialog/dialog.d.ts +33 -0
- package/dist/component/dialog/dialog.js +96 -0
- package/dist/component/import-file/import-file.d.ts +35 -0
- package/dist/component/import-file/import-file.js +117 -0
- package/dist/component/infinite-scroll/infinite-scroll.d.ts +16 -0
- package/dist/component/infinite-scroll/infinite-scroll.js +102 -0
- package/dist/component/input-multi-select/input-multi-select.d.ts +39 -0
- package/dist/component/input-multi-select/input-multi-select.js +249 -0
- package/dist/component/pagination/pagination.d.ts +11 -0
- package/dist/component/pagination/pagination.js +46 -0
- package/dist/component/popup/popup.d.ts +31 -0
- package/dist/component/popup/popup.js +105 -0
- package/dist/component/progress-bar/progress-bar.d.ts +16 -0
- package/dist/component/progress-bar/progress-bar.js +39 -0
- package/dist/component/progress-circle/progress-circle.d.ts +13 -0
- package/dist/component/progress-circle/progress-circle.js +31 -0
- package/dist/component/radio-button/radio-button.d.ts +20 -0
- package/dist/component/radio-button/radio-button.js +64 -0
- package/dist/component/rating/rating.d.ts +23 -0
- package/dist/component/rating/rating.js +76 -0
- package/dist/component/select1/select1.d.ts +38 -0
- package/dist/component/select1/select1.js +185 -0
- package/dist/component/slider/slider.d.ts +31 -0
- package/dist/component/slider/slider.js +83 -0
- package/dist/component/switch/switch.d.ts +23 -0
- package/dist/component/switch/switch.js +81 -0
- package/dist/component/table/table.d.ts +46 -0
- package/dist/component/table/table.js +119 -0
- package/dist/component/text/text.d.ts +14 -0
- package/dist/component/text/text.js +50 -0
- package/dist/component/text-area/text-area.d.ts +25 -0
- package/dist/component/text-area/text-area.js +47 -0
- package/dist/component/text-field/text-field.d.ts +28 -0
- package/dist/component/text-field/text-field.js +50 -0
- package/dist/component/toast-noti/toast-noti.d.ts +4 -0
- package/dist/component/toast-noti/toast-noti.js +27 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +59 -1
- package/dist/skin/color.css +17 -0
- package/dist/skin/layout.css +601 -0
- package/dist/skin/typography.css +378 -0
- package/package.json +4 -2
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.DatePicker = void 0;
|
|
33
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
34
|
+
var react_1 = __importDefault(require("react"));
|
|
35
|
+
var react_dom_1 = __importDefault(require("react-dom"));
|
|
36
|
+
require("./date-picker.css");
|
|
37
|
+
var index_1 = require("../../index");
|
|
38
|
+
var calendar_1 = require("../calendar/calendar");
|
|
39
|
+
var date_fns_1 = require("date-fns");
|
|
40
|
+
var CalendarIcon = function (_a) {
|
|
41
|
+
var _b = _a.color, color = _b === void 0 ? '#00204D99' : _b, _c = _a.width, width = _c === void 0 ? '1.6rem' : _c, _d = _a.height, height = _d === void 0 ? '1.6rem' : _d;
|
|
42
|
+
return (react_1.default.createElement("svg", { xmlns: 'http://www.w3.org/2000/svg', width: '100%', height: '100%', viewBox: '0 0 17 16', fill: 'none', style: { width: width, height: height } },
|
|
43
|
+
react_1.default.createElement("path", { d: 'M12.3876 2.99967V1.88856C12.3876 1.74122 12.3291 1.59991 12.2249 1.49573C12.1207 1.39154 11.9794 1.33301 11.832 1.33301C11.6847 1.33301 11.5434 1.39154 11.4392 1.49573C11.335 1.59991 11.2765 1.74122 11.2765 1.88856V2.99967H12.3876Z', fill: color }),
|
|
44
|
+
react_1.default.createElement("path", { d: 'M5.72092 2.99967V1.88856C5.72092 1.74122 5.66239 1.59991 5.5582 1.49573C5.45401 1.39154 5.31271 1.33301 5.16536 1.33301C5.01802 1.33301 4.87671 1.39154 4.77253 1.49573C4.66834 1.59991 4.60981 1.74122 4.60981 1.88856V2.99967H5.72092Z', fill: color }),
|
|
45
|
+
react_1.default.createElement("path", { d: 'M13.4987 14.1108H3.4987C3.05667 14.1108 2.63275 13.9352 2.32019 13.6226C2.00763 13.3101 1.83203 12.8861 1.83203 12.4441V5.2219C1.83203 4.77987 2.00763 4.35595 2.32019 4.04339C2.63275 3.73082 3.05667 3.55523 3.4987 3.55523H13.4987C13.9407 3.55523 14.3646 3.73082 14.6772 4.04339C14.9898 4.35595 15.1654 4.77987 15.1654 5.2219V12.4441C15.1654 12.8861 14.9898 13.3101 14.6772 13.6226C14.3646 13.9352 13.9407 14.1108 13.4987 14.1108ZM14.0543 6.33301H2.94314V12.4441C2.94314 12.5915 3.00167 12.7328 3.10586 12.837C3.21005 12.9411 3.35136 12.9997 3.4987 12.9997H13.4987C13.646 12.9997 13.7873 12.9411 13.8915 12.837C13.9957 12.7328 14.0543 12.5915 14.0543 12.4441V6.33301Z', fill: color }),
|
|
46
|
+
react_1.default.createElement("path", { d: 'M6.27648 7.44412H4.05425V9.11079H6.27648V7.44412Z', fill: color }),
|
|
47
|
+
react_1.default.createElement("path", { d: 'M9.60981 7.44412H7.38759V9.11079H9.60981V7.44412Z', fill: color }),
|
|
48
|
+
react_1.default.createElement("path", { d: 'M6.27648 10.2219H4.05425V11.8886H6.27648V10.2219Z', fill: color }),
|
|
49
|
+
react_1.default.createElement("path", { d: 'M9.60981 10.2219H7.38759V11.8886H9.60981V10.2219Z', fill: color }),
|
|
50
|
+
react_1.default.createElement("path", { d: 'M12.9431 7.44412H10.7209V9.11079H12.9431V7.44412Z', fill: color })));
|
|
51
|
+
};
|
|
52
|
+
var dateToString = function (x, y) {
|
|
53
|
+
if (y === void 0) { y = "dd/mm/yyyy"; }
|
|
54
|
+
var splitDateTime = y.split(" ");
|
|
55
|
+
var dateFormat = splitDateTime[0];
|
|
56
|
+
var timeFormat = splitDateTime[1];
|
|
57
|
+
if (dateFormat.includes('hh')) {
|
|
58
|
+
dateFormat = splitDateTime[1];
|
|
59
|
+
timeFormat = splitDateTime[0];
|
|
60
|
+
}
|
|
61
|
+
var dateConvert = dateFormat.split(y.includes("/") ? "/" : "-").map(function (type) {
|
|
62
|
+
switch (type.toLowerCase()) {
|
|
63
|
+
case "dd":
|
|
64
|
+
return x.getDate() < 10 ? "0".concat(x.getDate()) : "".concat(x.getDate());
|
|
65
|
+
case "mm":
|
|
66
|
+
return (x.getMonth() + 1) < 10 ? "0".concat((x.getMonth() + 1)) : "".concat((x.getMonth() + 1));
|
|
67
|
+
case "yyyy":
|
|
68
|
+
return "".concat(x.getFullYear());
|
|
69
|
+
default:
|
|
70
|
+
return '';
|
|
71
|
+
}
|
|
72
|
+
}).join(y.includes("/") ? "/" : "-");
|
|
73
|
+
if (timeFormat) {
|
|
74
|
+
var timeConvert = timeFormat.split(":").map(function (type) {
|
|
75
|
+
switch (type) {
|
|
76
|
+
case "hh":
|
|
77
|
+
return x.getHours() < 10 ? "0".concat(x.getHours()) : "".concat(x.getHours());
|
|
78
|
+
case "mm":
|
|
79
|
+
return x.getMinutes() < 10 ? "0".concat(x.getMinutes()) : "".concat(x.getMinutes());
|
|
80
|
+
case "ss":
|
|
81
|
+
return x.getSeconds() < 10 ? "0".concat(x.getSeconds()) : "".concat(x.getSeconds());
|
|
82
|
+
default:
|
|
83
|
+
return 'D';
|
|
84
|
+
}
|
|
85
|
+
}).join(":");
|
|
86
|
+
return dateConvert + " " + timeConvert;
|
|
87
|
+
}
|
|
88
|
+
return dateConvert;
|
|
89
|
+
};
|
|
90
|
+
var stringToDate = function (_date, _format, _delimiter) {
|
|
91
|
+
var _a, _b, _c, _d, _e;
|
|
92
|
+
if (_format === void 0) { _format = "dd/MM/yyyy"; }
|
|
93
|
+
if (_delimiter === void 0) { _delimiter = "/"; }
|
|
94
|
+
var dayformat = _format;
|
|
95
|
+
var hourformat = '';
|
|
96
|
+
var day = _date;
|
|
97
|
+
var hours = '';
|
|
98
|
+
var isHour = false;
|
|
99
|
+
if (_format.trim().indexOf(" ") > -1) {
|
|
100
|
+
dayformat = _format.trim().split(" ")[0];
|
|
101
|
+
hourformat = _format.trim().split(" ")[1];
|
|
102
|
+
day = _date.trim().split(" ")[0];
|
|
103
|
+
hours = (_a = _date.trim().split(" ")[1]) !== null && _a !== void 0 ? _a : '00:00:00';
|
|
104
|
+
isHour = true;
|
|
105
|
+
}
|
|
106
|
+
var formatLowerCase = dayformat.toLowerCase();
|
|
107
|
+
var formatItems = formatLowerCase.split(_delimiter);
|
|
108
|
+
var dateItems = day.split(_delimiter);
|
|
109
|
+
var monthIndex = formatItems.indexOf("mm");
|
|
110
|
+
var dayIndex = formatItems.indexOf("dd");
|
|
111
|
+
var yearIndex = formatItems.indexOf("yyyy");
|
|
112
|
+
var hour = 0;
|
|
113
|
+
var min = 0;
|
|
114
|
+
var sec = 0;
|
|
115
|
+
if (isHour) {
|
|
116
|
+
var tmpHour = hourformat.split(":");
|
|
117
|
+
var hourindex = tmpHour.indexOf("HH");
|
|
118
|
+
if (hourindex < 0) {
|
|
119
|
+
hourindex = tmpHour.indexOf("hh");
|
|
120
|
+
}
|
|
121
|
+
var mmindex = tmpHour.indexOf("mm");
|
|
122
|
+
var ssindex = tmpHour.indexOf("ss");
|
|
123
|
+
var time = hours.split(":");
|
|
124
|
+
hour = parseInt((_b = time[hourindex]) !== null && _b !== void 0 ? _b : '0');
|
|
125
|
+
min = parseInt((_c = time[mmindex]) !== null && _c !== void 0 ? _c : '0');
|
|
126
|
+
sec = parseInt((_d = time[ssindex]) !== null && _d !== void 0 ? _d : '0');
|
|
127
|
+
}
|
|
128
|
+
var month = parseInt(dateItems[monthIndex]);
|
|
129
|
+
month -= 1;
|
|
130
|
+
var formatedDate = new Date(parseInt(dateItems[yearIndex]), month, parseInt((_e = dateItems[dayIndex]) !== null && _e !== void 0 ? _e : '0'), hour, min, sec);
|
|
131
|
+
return formatedDate;
|
|
132
|
+
};
|
|
133
|
+
var DatePicker = /** @class */ (function (_super) {
|
|
134
|
+
__extends(DatePicker, _super);
|
|
135
|
+
function DatePicker(props) {
|
|
136
|
+
var _this = _super.call(this, props) || this;
|
|
137
|
+
_this.getNewValue = function (value) {
|
|
138
|
+
var _a, _b, _c, _d, _e, _f;
|
|
139
|
+
var params = (_b = value !== null && value !== void 0 ? value : (_a = _this.state) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : '';
|
|
140
|
+
if ((_c = params.trim()) === null || _c === void 0 ? void 0 : _c.length) {
|
|
141
|
+
switch (_this.props.pickerType) {
|
|
142
|
+
case 2 /* CalendarType.YEAR */:
|
|
143
|
+
return new Date(parseInt(params), 1, 1);
|
|
144
|
+
case 1 /* CalendarType.MONTH */:
|
|
145
|
+
var splitParams = params.includes('/') ? params.split('/') : params.split('-');
|
|
146
|
+
return new Date(parseInt((_d = splitParams[1]) !== null && _d !== void 0 ? _d : "".concat(calendar_1.today.getFullYear())), parseInt((_e = splitParams[0]) !== null && _e !== void 0 ? _e : "".concat(calendar_1.today.getMonth())), 1);
|
|
147
|
+
case 3 /* CalendarType.DATETIME */:
|
|
148
|
+
return stringToDate(params, (_f = _this.props.formatDate) !== null && _f !== void 0 ? _f : 'dd/mm/yyyy hh:mm');
|
|
149
|
+
default:
|
|
150
|
+
return stringToDate(params);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return undefined;
|
|
154
|
+
};
|
|
155
|
+
_this.state = {
|
|
156
|
+
value: props.value,
|
|
157
|
+
offset: {
|
|
158
|
+
x: 0,
|
|
159
|
+
y: 0,
|
|
160
|
+
height: 0,
|
|
161
|
+
width: 0,
|
|
162
|
+
bottom: 0,
|
|
163
|
+
left: 0,
|
|
164
|
+
right: 0,
|
|
165
|
+
top: 0,
|
|
166
|
+
toJSON: function () {
|
|
167
|
+
throw new Error('Function not implemented.');
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
isOpen: false,
|
|
171
|
+
};
|
|
172
|
+
return _this;
|
|
173
|
+
}
|
|
174
|
+
DatePicker.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|
175
|
+
var _a;
|
|
176
|
+
if (prevProps.value !== this.props.value) {
|
|
177
|
+
this.setState(__assign(__assign({}, this.state), { value: this.props.value }));
|
|
178
|
+
}
|
|
179
|
+
if (prevState.isOpen !== this.state.isOpen && this.state.isOpen) {
|
|
180
|
+
var thisPopupRect = (_a = document.body.querySelector('.date-picker-popup-container')) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
181
|
+
if (thisPopupRect) {
|
|
182
|
+
var style = void 0;
|
|
183
|
+
if (thisPopupRect.right > document.body.offsetWidth) {
|
|
184
|
+
style = {
|
|
185
|
+
top: this.state.offset.y + this.state.offset.height + 2 + 'px',
|
|
186
|
+
right: document.body.offsetWidth - this.state.offset.left + 'px'
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
if ((thisPopupRect.bottom - 20) > document.body.offsetHeight) {
|
|
190
|
+
style = style ? __assign(__assign({}, style), { top: undefined, bottom: document.body.offsetHeight - this.state.offset.top + 'px' }) : {
|
|
191
|
+
left: this.state.offset.x + 'px',
|
|
192
|
+
bottom: document.body.offsetHeight - this.state.offset.top + 'px'
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
if (style)
|
|
196
|
+
this.setState(__assign(__assign({}, this.state), { style: style }));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
DatePicker.prototype.render = function () {
|
|
201
|
+
var _this = this;
|
|
202
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
203
|
+
var maxLength = 10;
|
|
204
|
+
switch (this.props.pickerType) {
|
|
205
|
+
case 2 /* CalendarType.YEAR */:
|
|
206
|
+
maxLength = 4;
|
|
207
|
+
break;
|
|
208
|
+
case 1 /* CalendarType.MONTH */:
|
|
209
|
+
maxLength = 7;
|
|
210
|
+
break;
|
|
211
|
+
case 3 /* CalendarType.DATETIME */:
|
|
212
|
+
maxLength = 19;
|
|
213
|
+
break;
|
|
214
|
+
default:
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
return react_1.default.createElement("label", { className: "date-picker-container row ".concat((_a = this.props.className) !== null && _a !== void 0 ? _a : 'placeholder-2', " ").concat(this.props.disabled ? 'disabled' : '', " ").concat(((_b = this.props.helperText) === null || _b === void 0 ? void 0 : _b.length) && 'helper-text'), "helper-text": this.props.helperText, style: this.props.style ? __assign(__assign({}, { '--helper-text-color': (_c = this.props.helperTextColor) !== null && _c !== void 0 ? _c : '#e14337' }), this.props.style) : { '--helper-text-color': (_d = this.props.helperTextColor) !== null && _d !== void 0 ? _d : '#e14337' } },
|
|
218
|
+
react_1.default.createElement("div", { className: 'input-field-value row', style: { height: '4rem' } },
|
|
219
|
+
react_1.default.createElement("input", { autoComplete: 'off', value: (_e = this.state.value) !== null && _e !== void 0 ? _e : '', onChange: function (ev) { return _this.setState(__assign(__assign({}, _this.state), { value: ev.target.value })); }, placeholder: this.props.placeholder, maxLength: maxLength, onBlur: function (ev) {
|
|
220
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
221
|
+
var inputValue = ev.target.value.trim();
|
|
222
|
+
switch (_this.props.pickerType) {
|
|
223
|
+
case 2 /* CalendarType.YEAR */:
|
|
224
|
+
var minYear = ((_a = _this.props.min) !== null && _a !== void 0 ? _a : calendar_1.startDate).getFullYear();
|
|
225
|
+
var maxYear = ((_b = _this.props.min) !== null && _b !== void 0 ? _b : calendar_1.endDate).getFullYear();
|
|
226
|
+
if (!isNaN(parseInt(inputValue)) && parseInt(inputValue) <= maxYear && parseInt(inputValue) >= minYear) {
|
|
227
|
+
_this.setState(__assign(__assign({}, _this.state), { isOpen: false, value: inputValue }));
|
|
228
|
+
if (_this.props.onChange)
|
|
229
|
+
_this.props.onChange(inputValue);
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
_this.setState(__assign(__assign({}, _this.state), { isOpen: false, value: undefined }));
|
|
233
|
+
if (_this.props.onChange)
|
|
234
|
+
_this.props.onChange(undefined);
|
|
235
|
+
}
|
|
236
|
+
break;
|
|
237
|
+
case 1 /* CalendarType.MONTH */:
|
|
238
|
+
if (inputValue.match(/[0-9]{1,2}(\/|-)[0-9]{4}/g)) {
|
|
239
|
+
var dateValue_1 = stringToDate("1/".concat(inputValue), 'dd/MM/yyyy', '/');
|
|
240
|
+
if ((0, calendar_1.inRangeTime)(dateValue_1, (_d = (_c = _this.props.min) !== null && _c !== void 0 ? _c : calendar_1.startDate) !== null && _d !== void 0 ? _d : calendar_1.startDate, (_f = (_e = _this.props.min) !== null && _e !== void 0 ? _e : calendar_1.endDate) !== null && _f !== void 0 ? _f : calendar_1.endDate)) {
|
|
241
|
+
_this.setState(__assign(__assign({}, _this.state), { isOpen: false, value: dateToString(dateValue_1) }));
|
|
242
|
+
if (_this.props.onChange)
|
|
243
|
+
_this.props.onChange(dateToString(dateValue_1));
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
_this.setState(__assign(__assign({}, _this.state), { isOpen: false, value: undefined }));
|
|
247
|
+
if (_this.props.onChange)
|
|
248
|
+
_this.props.onChange(undefined);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
_this.setState(__assign(__assign({}, _this.state), { isOpen: false, value: undefined }));
|
|
253
|
+
if (_this.props.onChange)
|
|
254
|
+
_this.props.onChange(undefined);
|
|
255
|
+
}
|
|
256
|
+
break;
|
|
257
|
+
case 3 /* CalendarType.DATETIME */:
|
|
258
|
+
var dateTimeValue = undefined;
|
|
259
|
+
if (inputValue.match(/[0-9]{1,2}(\/|-)[0-9]{1,2}(\/|-)[0-9]{4}/g)) {
|
|
260
|
+
dateTimeValue = stringToDate(inputValue, (_g = _this.props.formatDate) !== null && _g !== void 0 ? _g : 'dd/mm/yyyy hh:mm', '/');
|
|
261
|
+
if ((0, calendar_1.inRangeTime)(dateTimeValue, (_h = _this.props.min) !== null && _h !== void 0 ? _h : calendar_1.startDate, (_j = _this.props.min) !== null && _j !== void 0 ? _j : calendar_1.endDate)) {
|
|
262
|
+
}
|
|
263
|
+
else if ((0, date_fns_1.differenceInCalendarDays)((_k = _this.props.min) !== null && _k !== void 0 ? _k : calendar_1.startDate, dateTimeValue) > -1) {
|
|
264
|
+
dateTimeValue = (_l = _this.props.min) !== null && _l !== void 0 ? _l : calendar_1.startDate;
|
|
265
|
+
}
|
|
266
|
+
else if ((0, date_fns_1.differenceInCalendarDays)(dateTimeValue, (_m = _this.props.min) !== null && _m !== void 0 ? _m : calendar_1.endDate) > -1) {
|
|
267
|
+
dateTimeValue = (_o = _this.props.min) !== null && _o !== void 0 ? _o : calendar_1.startDate;
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
dateTimeValue = undefined;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
var stateDateTimeValue = dateTimeValue ? dateToString(dateTimeValue, (_p = _this.props.formatDate) !== null && _p !== void 0 ? _p : 'dd/mm/yyyy hh:mm') : dateTimeValue;
|
|
274
|
+
_this.setState(__assign(__assign({}, _this.state), { isOpen: false, value: stateDateTimeValue }));
|
|
275
|
+
if (_this.props.onChange)
|
|
276
|
+
_this.props.onChange(stateDateTimeValue);
|
|
277
|
+
break;
|
|
278
|
+
default:
|
|
279
|
+
var dateValue = undefined;
|
|
280
|
+
if (inputValue.match(/[0-9]{1,2}(\/|-)[0-9]{1,2}(\/|-)[0-9]{4}/g)) {
|
|
281
|
+
dateValue = stringToDate(inputValue, 'dd/MM/yyyy', '/');
|
|
282
|
+
if ((0, calendar_1.inRangeTime)(dateValue, (_q = _this.props.min) !== null && _q !== void 0 ? _q : calendar_1.startDate, (_r = _this.props.min) !== null && _r !== void 0 ? _r : calendar_1.endDate)) {
|
|
283
|
+
}
|
|
284
|
+
else if ((0, date_fns_1.differenceInCalendarDays)((_s = _this.props.min) !== null && _s !== void 0 ? _s : calendar_1.startDate, dateValue) > -1) {
|
|
285
|
+
dateValue = (_t = _this.props.min) !== null && _t !== void 0 ? _t : calendar_1.startDate;
|
|
286
|
+
}
|
|
287
|
+
else if ((0, date_fns_1.differenceInCalendarDays)(dateValue, (_u = _this.props.min) !== null && _u !== void 0 ? _u : calendar_1.endDate) > -1) {
|
|
288
|
+
dateValue = (_v = _this.props.max) !== null && _v !== void 0 ? _v : calendar_1.endDate;
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
dateValue = undefined;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
var stateDateValue = dateValue ? dateToString(dateValue) : dateValue;
|
|
295
|
+
_this.setState(__assign(__assign({}, _this.state), { isOpen: false, value: stateDateValue }));
|
|
296
|
+
if (_this.props.onChange)
|
|
297
|
+
_this.props.onChange(stateDateValue);
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
} })),
|
|
301
|
+
react_1.default.createElement("button", { type: 'button', onClick: function (ev) {
|
|
302
|
+
var _a;
|
|
303
|
+
if (!_this.state.isOpen) {
|
|
304
|
+
_this.setState(__assign(__assign({}, _this.state), { isOpen: true, style: undefined, offset: ((_a = ev.target.closest('.date-picker-container')) !== null && _a !== void 0 ? _a : ev.target).getBoundingClientRect() }));
|
|
305
|
+
}
|
|
306
|
+
}, className: 'row', style: { padding: '0.4rem' } },
|
|
307
|
+
react_1.default.createElement(CalendarIcon, null)),
|
|
308
|
+
this.state.isOpen &&
|
|
309
|
+
react_dom_1.default.createPortal(react_1.default.createElement("div", { className: "popup-overlay hidden-overlay", onClick: function (ev) {
|
|
310
|
+
if (ev.target.classList.contains('popup-overlay'))
|
|
311
|
+
_this.setState(__assign(__assign({}, _this.state), { isOpen: false }));
|
|
312
|
+
} },
|
|
313
|
+
react_1.default.createElement(index_1.Calendar, { value: this.getNewValue(), type: (_f = this.props.pickerType) !== null && _f !== void 0 ? _f : 0 /* CalendarType.DATE */, className: 'date-picker-popup-container', style: (_g = this.state.style) !== null && _g !== void 0 ? _g : { 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) {
|
|
314
|
+
var _a;
|
|
315
|
+
switch (_this.props.pickerType) {
|
|
316
|
+
case 2 /* CalendarType.YEAR */:
|
|
317
|
+
_this.setState(__assign(__assign({}, _this.state), { value: dateValue.getFullYear().toString(), isOpen: false }));
|
|
318
|
+
if (_this.props.onChange)
|
|
319
|
+
_this.props.onChange(dateValue.getFullYear().toString());
|
|
320
|
+
break;
|
|
321
|
+
case 1 /* CalendarType.MONTH */:
|
|
322
|
+
var newValue = dateToString(dateValue);
|
|
323
|
+
_this.setState(__assign(__assign({}, _this.state), { value: newValue.split('/').slice(1).join('/'), isOpen: false }));
|
|
324
|
+
if (_this.props.onChange)
|
|
325
|
+
_this.props.onChange(newValue.split('/').slice(1).join('/'));
|
|
326
|
+
break;
|
|
327
|
+
case 3 /* CalendarType.DATETIME */:
|
|
328
|
+
var newValue = dateToString(dateValue, (_a = _this.props.formatDate) !== null && _a !== void 0 ? _a : 'dd/mm/yyyy hh:mm');
|
|
329
|
+
_this.setState(__assign(__assign({}, _this.state), { value: newValue }));
|
|
330
|
+
break;
|
|
331
|
+
default:
|
|
332
|
+
var newValue = dateToString(dateValue);
|
|
333
|
+
_this.setState(__assign(__assign({}, _this.state), { value: newValue, isOpen: false }));
|
|
334
|
+
if (_this.props.onChange)
|
|
335
|
+
_this.props.onChange(newValue);
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
}, footer: (this.props.pickerType === 3 /* CalendarType.DATETIME */ || !this.props.hideButtonToday) && react_1.default.createElement("div", { className: 'row picker-popup-footer' },
|
|
339
|
+
this.props.pickerType === undefined || this.props.pickerType === 0 /* CalendarType.DATE */ || this.props.pickerType === 3 /* CalendarType.DATETIME */ ?
|
|
340
|
+
react_1.default.createElement("button", { type: 'button', className: 'row button-text-3', style: { color: 'var(--infor-color)', width: 'fit-content' }, onClick: function () {
|
|
341
|
+
var _a;
|
|
342
|
+
var format = (_a = _this.props.formatDate) !== null && _a !== void 0 ? _a : (_this.props.pickerType === 3 /* CalendarType.DATETIME */ ? 'dd/mm/yyyy hh:mm' : 'dd/mm/yyyy');
|
|
343
|
+
_this.setState(__assign(__assign({}, _this.state), { isOpen: false, value: dateToString(calendar_1.today, format) }));
|
|
344
|
+
if (_this.props.onChange)
|
|
345
|
+
_this.props.onChange(dateToString(calendar_1.today, format));
|
|
346
|
+
} }, "Today") : null,
|
|
347
|
+
this.props.pickerType === 3 /* CalendarType.DATETIME */ ? react_1.default.createElement(react_1.default.Fragment, null,
|
|
348
|
+
react_1.default.createElement("div", { style: { flex: 1 } }),
|
|
349
|
+
react_1.default.createElement("button", { type: 'button', className: 'row button-primary', style: { padding: '0.6rem 0.8rem' }, onClick: function () {
|
|
350
|
+
_this.setState(__assign(__assign({}, _this.state), { isOpen: false }));
|
|
351
|
+
if (_this.props.onChange)
|
|
352
|
+
_this.props.onChange(_this.state.value);
|
|
353
|
+
} },
|
|
354
|
+
react_1.default.createElement("div", { className: 'button-text-3' }, "Submit"))) : null) })), document.body));
|
|
355
|
+
};
|
|
356
|
+
return DatePicker;
|
|
357
|
+
}(react_1.default.Component));
|
|
358
|
+
exports.DatePicker = DatePicker;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './dialog.css';
|
|
3
|
+
import { ComponentStatus } from '../../index';
|
|
4
|
+
export declare enum DialogAlignment {
|
|
5
|
+
start = "start",
|
|
6
|
+
center = "center",
|
|
7
|
+
end = "end"
|
|
8
|
+
}
|
|
9
|
+
interface DialogState {
|
|
10
|
+
readonly open?: boolean;
|
|
11
|
+
title: string;
|
|
12
|
+
status: ComponentStatus;
|
|
13
|
+
content: string;
|
|
14
|
+
onSubmit: Function;
|
|
15
|
+
submitTitle?: string;
|
|
16
|
+
alignment?: DialogAlignment;
|
|
17
|
+
}
|
|
18
|
+
export declare const showDialog: ({ ref, title, status, content, onSubmit, submitTitle, alignment }: {
|
|
19
|
+
ref: React.MutableRefObject<Dialog>;
|
|
20
|
+
title?: string | undefined;
|
|
21
|
+
status?: ComponentStatus | undefined;
|
|
22
|
+
content?: string | undefined;
|
|
23
|
+
onSubmit?: Function | undefined;
|
|
24
|
+
submitTitle?: string | undefined;
|
|
25
|
+
alignment?: DialogAlignment | undefined;
|
|
26
|
+
}) => void;
|
|
27
|
+
export declare class Dialog extends React.Component<Object, DialogState> {
|
|
28
|
+
state: Readonly<DialogState>;
|
|
29
|
+
showDialogNoti(data: DialogState): void;
|
|
30
|
+
closeDialog(): void;
|
|
31
|
+
render(): React.JSX.Element;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.Dialog = exports.showDialog = exports.DialogAlignment = void 0;
|
|
33
|
+
var react_1 = __importDefault(require("react"));
|
|
34
|
+
var react_dom_1 = __importDefault(require("react-dom"));
|
|
35
|
+
require("./dialog.css");
|
|
36
|
+
var index_1 = require("../../index");
|
|
37
|
+
var DialogAlignment;
|
|
38
|
+
(function (DialogAlignment) {
|
|
39
|
+
DialogAlignment["start"] = "start";
|
|
40
|
+
DialogAlignment["center"] = "center";
|
|
41
|
+
DialogAlignment["end"] = "end";
|
|
42
|
+
})(DialogAlignment = exports.DialogAlignment || (exports.DialogAlignment = {}));
|
|
43
|
+
var showDialog = function (_a) {
|
|
44
|
+
var ref = _a.ref, title = _a.title, status = _a.status, content = _a.content, onSubmit = _a.onSubmit, submitTitle = _a.submitTitle, alignment = _a.alignment;
|
|
45
|
+
ref.current.showDialogNoti({
|
|
46
|
+
title: title !== null && title !== void 0 ? title : '',
|
|
47
|
+
status: status !== null && status !== void 0 ? status : 1 /* ComponentStatus.INFOR */,
|
|
48
|
+
content: content !== null && content !== void 0 ? content : '',
|
|
49
|
+
onSubmit: onSubmit !== null && onSubmit !== void 0 ? onSubmit : (function () { }),
|
|
50
|
+
submitTitle: submitTitle,
|
|
51
|
+
alignment: alignment
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
exports.showDialog = showDialog;
|
|
55
|
+
var Dialog = /** @class */ (function (_super) {
|
|
56
|
+
__extends(Dialog, _super);
|
|
57
|
+
function Dialog() {
|
|
58
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
59
|
+
_this.state = {
|
|
60
|
+
open: false,
|
|
61
|
+
title: '',
|
|
62
|
+
status: 1 /* ComponentStatus.INFOR */,
|
|
63
|
+
content: '',
|
|
64
|
+
onSubmit: function () { }
|
|
65
|
+
};
|
|
66
|
+
return _this;
|
|
67
|
+
}
|
|
68
|
+
Dialog.prototype.showDialogNoti = function (data) {
|
|
69
|
+
this.setState(__assign({ open: true }, data));
|
|
70
|
+
};
|
|
71
|
+
Dialog.prototype.closeDialog = function () {
|
|
72
|
+
this.setState({ open: false });
|
|
73
|
+
};
|
|
74
|
+
Dialog.prototype.render = function () {
|
|
75
|
+
var _this = this;
|
|
76
|
+
var _a;
|
|
77
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, this.state.open &&
|
|
78
|
+
react_dom_1.default.createPortal(react_1.default.createElement("div", { className: 'dialog-overlay' },
|
|
79
|
+
react_1.default.createElement("div", { className: 'dialog-container col', style: { width: '41.4rem', alignItems: this.state.alignment }, "dialog-type": this.state.status, onClick: function (e) { return e.stopPropagation(); } },
|
|
80
|
+
react_1.default.createElement("div", { key: 'dialog-body', className: 'dialog-body col', style: { alignItems: 'inherit' } },
|
|
81
|
+
react_1.default.createElement("div", { className: 'dialog-status row' }, (0, index_1.getStatusIcon)(this.state.status)),
|
|
82
|
+
react_1.default.createElement("div", { className: 'dialog-title', style: { textAlign: this.state.alignment === DialogAlignment.center ? 'center' : 'start' } }, this.state.title),
|
|
83
|
+
react_1.default.createElement("div", { className: 'dialog-content', style: { textAlign: this.state.alignment === DialogAlignment.center ? 'center' : 'start' } }, this.state.content)),
|
|
84
|
+
react_1.default.createElement("div", { key: 'dialog-footer', className: 'dialog-footer row' },
|
|
85
|
+
react_1.default.createElement("button", { type: 'button', style: this.state.alignment === DialogAlignment.center ? { flex: 1, width: '100%' } : undefined, onClick: function () { return _this.setState({ open: false }); }, className: 'dialog-action' }, "Quay l\u1EA1i"),
|
|
86
|
+
react_1.default.createElement("button", { type: 'button', style: this.state.alignment === DialogAlignment.center ? { flex: 1, width: '100%' } : undefined, onClick: function () {
|
|
87
|
+
_this.state.onSubmit();
|
|
88
|
+
_this.setState({ open: false });
|
|
89
|
+
}, className: 'dialog-action dialog-submit' }, (_a = this.state.submitTitle) !== null && _a !== void 0 ? _a : 'Xác nhận')),
|
|
90
|
+
react_1.default.createElement("button", { type: 'button', onClick: function () { return _this.setState({ open: false }); }, className: 'dialog-close-btn row' },
|
|
91
|
+
react_1.default.createElement("svg", { width: '100%', height: '100%', viewBox: '0 0 20 20', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', style: { width: '2rem', height: '2rem' } },
|
|
92
|
+
react_1.default.createElement("path", { fillRule: 'evenodd', clipRule: 'evenodd', d: 'M16.4223 4.7559C16.7477 4.43047 16.7477 3.90283 16.4223 3.57739C16.0968 3.25195 15.5692 3.25195 15.2438 3.57739L9.99967 8.82147L4.7556 3.57739C4.43016 3.25195 3.90252 3.25195 3.57709 3.57739C3.25165 3.90283 3.25165 4.43047 3.57709 4.7559L8.82116 9.99998L3.57709 15.2441C3.25165 15.5695 3.25165 16.0971 3.57709 16.4226C3.90252 16.748 4.43016 16.748 4.7556 16.4226L9.99967 11.1785L15.2438 16.4226C15.5692 16.748 16.0968 16.748 16.4223 16.4226C16.7477 16.0971 16.7477 15.5695 16.4223 15.2441L11.1782 9.99998L16.4223 4.7559Z', fill: '#00204D', fillOpacity: 0.6 }))))), document.body)));
|
|
93
|
+
};
|
|
94
|
+
return Dialog;
|
|
95
|
+
}(react_1.default.Component));
|
|
96
|
+
exports.Dialog = Dialog;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { CSSProperties } from 'react';
|
|
2
|
+
import './import-file.css';
|
|
3
|
+
import { ComponentStatus } from '../component-status';
|
|
4
|
+
interface ObjWithKnownKeys {
|
|
5
|
+
[k: string]: any;
|
|
6
|
+
}
|
|
7
|
+
interface ImportFileState {
|
|
8
|
+
status?: ComponentStatus;
|
|
9
|
+
preview: File | ObjWithKnownKeys | undefined | null;
|
|
10
|
+
}
|
|
11
|
+
type ChangeFileFunction = (a?: File) => void;
|
|
12
|
+
interface ImportFileProps {
|
|
13
|
+
status?: ComponentStatus;
|
|
14
|
+
value?: File | ObjWithKnownKeys;
|
|
15
|
+
buttonOnly: boolean;
|
|
16
|
+
onChange?: ChangeFileFunction;
|
|
17
|
+
label?: string;
|
|
18
|
+
className?: string;
|
|
19
|
+
style?: CSSProperties;
|
|
20
|
+
allowType?: Array<string>;
|
|
21
|
+
subTitle?: string;
|
|
22
|
+
/**
|
|
23
|
+
* maxSize unit: kb (kilobytes)
|
|
24
|
+
*/
|
|
25
|
+
maxSize?: number;
|
|
26
|
+
}
|
|
27
|
+
export declare class ImportFile extends React.Component<ImportFileProps, ImportFileState> {
|
|
28
|
+
private fileRef;
|
|
29
|
+
constructor(props: ImportFileProps | Readonly<ImportFileProps>);
|
|
30
|
+
state: Readonly<ImportFileState>;
|
|
31
|
+
showFilePicker(): void;
|
|
32
|
+
componentDidUpdate(prevProps: Readonly<ImportFileProps>, prevState: Readonly<ImportFileState>): void;
|
|
33
|
+
render(): React.JSX.Element;
|
|
34
|
+
}
|
|
35
|
+
export {};
|