@fctc/widget-logic 5.3.7-beta.9 → 5.3.8
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/config.d.mts +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/hooks.d.mts +16 -9
- package/dist/hooks.d.ts +16 -9
- package/dist/hooks.js +166 -355
- package/dist/hooks.mjs +156 -335
- package/dist/icons.d.mts +27 -0
- package/dist/icons.d.ts +27 -0
- package/dist/icons.js +273 -0
- package/dist/icons.mjs +239 -0
- package/dist/index.d.mts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +4786 -592
- package/dist/index.mjs +4673 -460
- package/dist/store.d.mts +1 -0
- package/dist/store.d.ts +1 -0
- package/dist/store.js +24 -0
- package/dist/store.mjs +2 -0
- package/dist/utils.d.mts +8 -5
- package/dist/utils.d.ts +8 -5
- package/dist/utils.js +104 -326
- package/dist/utils.mjs +101 -313
- package/dist/widget.d.mts +25 -10
- package/dist/widget.d.ts +25 -10
- package/dist/widget.js +4436 -524
- package/dist/widget.mjs +4362 -432
- package/package.json +92 -67
package/dist/utils.mjs
CHANGED
|
@@ -13,9 +13,6 @@ var countSum = (data, field) => {
|
|
|
13
13
|
0
|
|
14
14
|
);
|
|
15
15
|
};
|
|
16
|
-
var isObjectEmpty = (obj) => {
|
|
17
|
-
return Object.keys(obj).length === 0;
|
|
18
|
-
};
|
|
19
16
|
function mergeButtons(fields) {
|
|
20
17
|
const buttons = fields?.filter((f) => f.type_co === "button");
|
|
21
18
|
const others = fields?.filter((f) => f.type_co !== "button");
|
|
@@ -27,6 +24,103 @@ function mergeButtons(fields) {
|
|
|
27
24
|
}
|
|
28
25
|
return others;
|
|
29
26
|
}
|
|
27
|
+
var getDateRange = (currentDate, unit) => {
|
|
28
|
+
const date = new Date(currentDate);
|
|
29
|
+
let dateStart, dateEnd;
|
|
30
|
+
function formatDate(d) {
|
|
31
|
+
return d.getFullYear() + "-" + String(d.getMonth() + 1).padStart(2, "0") + "-" + String(d.getDate()).padStart(2, "0") + " " + String(d.getHours()).padStart(2, "0") + ":" + String(d.getMinutes()).padStart(2, "0") + ":" + String(d.getSeconds()).padStart(2, "0");
|
|
32
|
+
}
|
|
33
|
+
switch (unit) {
|
|
34
|
+
case "month":
|
|
35
|
+
dateStart = new Date(
|
|
36
|
+
date.getFullYear(),
|
|
37
|
+
date.getMonth() + 1,
|
|
38
|
+
date.getDate(),
|
|
39
|
+
23,
|
|
40
|
+
59,
|
|
41
|
+
59
|
|
42
|
+
);
|
|
43
|
+
dateStart.setHours(dateStart.getHours() - 7);
|
|
44
|
+
dateEnd = new Date(date.getFullYear(), date.getMonth(), 0, 0, 0, 0);
|
|
45
|
+
dateEnd.setHours(dateEnd.getHours() - 7);
|
|
46
|
+
break;
|
|
47
|
+
case "day":
|
|
48
|
+
dateStart = new Date(
|
|
49
|
+
date.getFullYear(),
|
|
50
|
+
date.getMonth(),
|
|
51
|
+
date.getDate(),
|
|
52
|
+
23,
|
|
53
|
+
59,
|
|
54
|
+
59
|
|
55
|
+
);
|
|
56
|
+
dateStart.setHours(dateStart.getHours() - 7);
|
|
57
|
+
dateEnd = new Date(
|
|
58
|
+
date.getFullYear(),
|
|
59
|
+
date.getMonth(),
|
|
60
|
+
date.getDate(),
|
|
61
|
+
0,
|
|
62
|
+
0,
|
|
63
|
+
0
|
|
64
|
+
);
|
|
65
|
+
dateEnd.setHours(dateEnd.getHours() - 7);
|
|
66
|
+
break;
|
|
67
|
+
case "week":
|
|
68
|
+
const dayOfWeek = date.getDay();
|
|
69
|
+
const daysToMonday = dayOfWeek === 0 ? -6 : 1 - dayOfWeek;
|
|
70
|
+
const daysToSunday = dayOfWeek === 0 ? 0 : 7 - dayOfWeek;
|
|
71
|
+
dateStart = new Date(
|
|
72
|
+
date.getFullYear(),
|
|
73
|
+
date.getMonth(),
|
|
74
|
+
date.getDate() + daysToSunday,
|
|
75
|
+
23,
|
|
76
|
+
59,
|
|
77
|
+
59
|
|
78
|
+
);
|
|
79
|
+
dateStart.setHours(dateStart.getHours() - 7);
|
|
80
|
+
dateEnd = new Date(
|
|
81
|
+
date.getFullYear(),
|
|
82
|
+
date.getMonth(),
|
|
83
|
+
date.getDate() + daysToMonday,
|
|
84
|
+
0,
|
|
85
|
+
0,
|
|
86
|
+
0
|
|
87
|
+
);
|
|
88
|
+
dateEnd.setHours(dateEnd.getHours() - 7);
|
|
89
|
+
break;
|
|
90
|
+
case "year":
|
|
91
|
+
dateStart = new Date(date.getFullYear(), 11, 31, 23, 59, 59);
|
|
92
|
+
dateStart.setHours(dateStart.getHours() - 7);
|
|
93
|
+
dateEnd = new Date(date.getFullYear() - 1, 11, 31, 0, 0, 0);
|
|
94
|
+
dateEnd.setHours(dateEnd.getHours() - 7);
|
|
95
|
+
break;
|
|
96
|
+
default:
|
|
97
|
+
throw new Error(
|
|
98
|
+
"\u0110\u01A1n v\u1ECB kh\xF4ng h\u1EE3p l\u1EC7. Ch\u1EC9 ch\u1EA5p nh\u1EADn: week, day, month, year"
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
return [
|
|
102
|
+
["date_start", "<=", formatDate(dateStart)],
|
|
103
|
+
["date_end", ">=", formatDate(dateEnd)]
|
|
104
|
+
];
|
|
105
|
+
};
|
|
106
|
+
var convertFieldsToArray = (fields) => {
|
|
107
|
+
const defaultFields = ["display_name", "date_start", "date_end"];
|
|
108
|
+
if (!fields || !Array.isArray(fields)) {
|
|
109
|
+
return defaultFields;
|
|
110
|
+
}
|
|
111
|
+
const inputFields = fields.filter((field) => field && field.type_co === "field").map((field) => field.name);
|
|
112
|
+
return [...defaultFields, ...inputFields];
|
|
113
|
+
};
|
|
114
|
+
function combineContexts(contexts) {
|
|
115
|
+
if (contexts.some((context) => !context)) {
|
|
116
|
+
return void 0;
|
|
117
|
+
} else {
|
|
118
|
+
const res = contexts.reduce((acc, context) => {
|
|
119
|
+
return { ...acc, ...context };
|
|
120
|
+
}, {});
|
|
121
|
+
return res;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
30
124
|
var STORAGES = {
|
|
31
125
|
TOKEN: "accessToken",
|
|
32
126
|
USER_INFO: "USER_INFO"
|
|
@@ -67,323 +161,17 @@ function useStorageState(key) {
|
|
|
67
161
|
);
|
|
68
162
|
return [state, setValue];
|
|
69
163
|
}
|
|
70
|
-
var guessTypeFromUrl = (url) => {
|
|
71
|
-
const ext = url.split(".").pop()?.toLowerCase();
|
|
72
|
-
if (!ext) return null;
|
|
73
|
-
const map = {
|
|
74
|
-
jpg: "image/jpeg",
|
|
75
|
-
jpeg: "image/jpeg",
|
|
76
|
-
png: "image/png",
|
|
77
|
-
webp: "image/webp",
|
|
78
|
-
gif: "image/gif",
|
|
79
|
-
svg: "image/svg+xml",
|
|
80
|
-
bmp: "image/bmp",
|
|
81
|
-
tiff: "image/tiff",
|
|
82
|
-
pdf: "application/pdf",
|
|
83
|
-
zip: "application/zip",
|
|
84
|
-
rar: "application/x-rar-compressed",
|
|
85
|
-
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
86
|
-
xls: "application/vnd.ms-excel",
|
|
87
|
-
mp4: "video/mp4",
|
|
88
|
-
mov: "video/quicktime"
|
|
89
|
-
};
|
|
90
|
-
return map[ext] || null;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// src/utils/format-date.ts
|
|
94
|
-
import moment from "moment";
|
|
95
|
-
var validateAndParseDate = (input, isDateTime = false) => {
|
|
96
|
-
if (!input || typeof input !== "string") return null;
|
|
97
|
-
const cleanInput = input.replace(/[^0-9-\/:\s]/g, "");
|
|
98
|
-
const dateFormat = "YYYY-MM-DD";
|
|
99
|
-
const dateTimeFormat = "YYYY-MM-DD HH:mm:ss";
|
|
100
|
-
const currentDay = moment().format("DD");
|
|
101
|
-
const currentMonth = moment().format("MM");
|
|
102
|
-
const currentYear = moment().format("YYYY");
|
|
103
|
-
const defaultTime = "00:00:00";
|
|
104
|
-
const maxYear = parseInt(currentYear) + 10;
|
|
105
|
-
const isValidDate = (day, month, year) => {
|
|
106
|
-
const date = moment(`${day}-${month}-${year}`, "DD-MM-YYYY", true);
|
|
107
|
-
return date.isValid();
|
|
108
|
-
};
|
|
109
|
-
const isValidTime = (hour, minute = "00", second = "00") => {
|
|
110
|
-
const h = parseInt(hour, 10);
|
|
111
|
-
const m = parseInt(minute, 10);
|
|
112
|
-
const s = parseInt(second, 10);
|
|
113
|
-
return h >= 0 && h <= 23 && m >= 0 && m <= 59 && s >= 0 && s <= 59;
|
|
114
|
-
};
|
|
115
|
-
const formatOutput = (day, month, year, time = defaultTime) => {
|
|
116
|
-
let result = moment(
|
|
117
|
-
`${day}-${month}-${year} ${time}`,
|
|
118
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
119
|
-
);
|
|
120
|
-
if (!result.isValid()) return null;
|
|
121
|
-
if (isDateTime) {
|
|
122
|
-
result = result.subtract(7, "hours");
|
|
123
|
-
return result.format(dateTimeFormat);
|
|
124
|
-
}
|
|
125
|
-
return result.format(dateFormat);
|
|
126
|
-
};
|
|
127
|
-
if (isDateTime && input.match(
|
|
128
|
-
/^\d{1,2}[\/-]\d{1,2}[\/-]\d{2,4}\s+\d{1,2}(:\d{1,2}(:\d{1,2})?)?$/
|
|
129
|
-
)) {
|
|
130
|
-
const [datePart, timePart] = input.split(/\s+/);
|
|
131
|
-
const dateParts = datePart.split(/[\/-]/);
|
|
132
|
-
const timeParts = timePart.split(":");
|
|
133
|
-
const day = dateParts[0].padStart(2, "0");
|
|
134
|
-
const month = dateParts[1].padStart(2, "0");
|
|
135
|
-
const year = dateParts[2].length <= 2 ? `20${dateParts[2].padStart(2, "0")}` : dateParts[2].padStart(4, "0");
|
|
136
|
-
const hour = timeParts[0].padStart(2, "0");
|
|
137
|
-
const minute = timeParts[1] ? timeParts[1].padStart(2, "0") : "00";
|
|
138
|
-
const second = timeParts[2] ? timeParts[2].padStart(2, "0") : "00";
|
|
139
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
140
|
-
let result = moment(
|
|
141
|
-
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
142
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
143
|
-
);
|
|
144
|
-
if (!result.isValid()) return null;
|
|
145
|
-
result = result.subtract(7, "hours");
|
|
146
|
-
return result.format(dateTimeFormat);
|
|
147
|
-
}
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
if (cleanInput.match(/^\d{4}-\d{2}-\d{2}$/)) {
|
|
151
|
-
const [year, month, day] = cleanInput.split("-");
|
|
152
|
-
if (isValidDate(day, month, year)) {
|
|
153
|
-
return formatOutput(day, month, year);
|
|
154
|
-
}
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
if (cleanInput.match(/^\d{1,2}\/\d{1,2}\/\d{2,4}$/)) {
|
|
158
|
-
const [day, month, year] = cleanInput.split("/");
|
|
159
|
-
const paddedDay = day.padStart(2, "0");
|
|
160
|
-
const paddedMonth = month.padStart(2, "0");
|
|
161
|
-
const fullYear = year.length <= 2 ? `20${year.padStart(2, "0")}` : year.padStart(4, "0");
|
|
162
|
-
if (isValidDate(paddedDay, paddedMonth, fullYear)) {
|
|
163
|
-
return formatOutput(paddedDay, paddedMonth, fullYear);
|
|
164
|
-
}
|
|
165
|
-
return null;
|
|
166
|
-
}
|
|
167
|
-
if (cleanInput.match(/^\d{1,2}-\d{1,2}-\d{2,4}$/)) {
|
|
168
|
-
const [day, month, year] = cleanInput.split("-");
|
|
169
|
-
const paddedDay = day.padStart(2, "0");
|
|
170
|
-
const paddedMonth = month.padStart(2, "0");
|
|
171
|
-
const fullYear = year.length <= 2 ? `20${year.padStart(2, "0")}` : year.padStart(4, "0");
|
|
172
|
-
if (isValidDate(paddedDay, paddedMonth, fullYear)) {
|
|
173
|
-
return formatOutput(paddedDay, paddedMonth, fullYear);
|
|
174
|
-
}
|
|
175
|
-
return null;
|
|
176
|
-
}
|
|
177
|
-
if (cleanInput.match(/^\d{1,2}[\/-]\d{1,2}$/)) {
|
|
178
|
-
const [day, month] = cleanInput.split(/[\/-]/);
|
|
179
|
-
const paddedDay = day.padStart(2, "0");
|
|
180
|
-
const paddedMonth = month.padStart(2, "0");
|
|
181
|
-
if (isValidDate(paddedDay, paddedMonth, currentYear)) {
|
|
182
|
-
return formatOutput(paddedDay, paddedMonth, currentYear);
|
|
183
|
-
}
|
|
184
|
-
return null;
|
|
185
|
-
}
|
|
186
|
-
if (cleanInput.match(/^\d{4}$/)) {
|
|
187
|
-
const num = parseInt(cleanInput, 10);
|
|
188
|
-
if (num >= 2e3 && num <= maxYear) {
|
|
189
|
-
if (isValidDate(currentDay, currentMonth, num.toString())) {
|
|
190
|
-
return formatOutput(currentDay, currentMonth, num.toString());
|
|
191
|
-
}
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
const day = cleanInput.slice(0, 2);
|
|
195
|
-
const month = cleanInput.slice(2, 4);
|
|
196
|
-
if (isValidDate(day, month, currentYear)) {
|
|
197
|
-
return formatOutput(day, month, currentYear);
|
|
198
|
-
}
|
|
199
|
-
return null;
|
|
200
|
-
}
|
|
201
|
-
if (cleanInput.startsWith("-") && /^\-\d+$/.test(cleanInput)) {
|
|
202
|
-
const daysToSubtract = Math.abs(parseInt(cleanInput, 10));
|
|
203
|
-
let result = moment().subtract(daysToSubtract, "days");
|
|
204
|
-
if (isDateTime) {
|
|
205
|
-
result = result.subtract(7, "hours");
|
|
206
|
-
}
|
|
207
|
-
if (result.isValid()) {
|
|
208
|
-
return isDateTime ? result.format(dateTimeFormat) : result.format(dateFormat);
|
|
209
|
-
}
|
|
210
|
-
return null;
|
|
211
|
-
}
|
|
212
|
-
if (input.match(/^\d{1,2}[^0-9-\/]+\d{1,2}[^0-9-\/]+\d{2,4}.*$/)) {
|
|
213
|
-
const parts = input.split(/[^0-9-\/]+/).filter(Boolean);
|
|
214
|
-
const day = parts[0].padStart(2, "0");
|
|
215
|
-
const month = parts[1].padStart(2, "0");
|
|
216
|
-
let year = parts[2];
|
|
217
|
-
year = year.length === 2 ? `20${year}` : year.padStart(4, "0");
|
|
218
|
-
if (isValidDate(day, month, year)) {
|
|
219
|
-
return formatOutput(day, month, year);
|
|
220
|
-
}
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
if (isDateTime) {
|
|
224
|
-
if (cleanInput.length === 9) {
|
|
225
|
-
const day = cleanInput.slice(0, 2);
|
|
226
|
-
const month = cleanInput.slice(2, 4);
|
|
227
|
-
const year = cleanInput.slice(4, 8);
|
|
228
|
-
const hour = cleanInput.slice(8, 9).padStart(2, "0");
|
|
229
|
-
if (isValidDate(day, month, year) && isValidTime(hour)) {
|
|
230
|
-
let result = moment(
|
|
231
|
-
`${day}-${month}-${year} ${hour}:00:00`,
|
|
232
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
233
|
-
);
|
|
234
|
-
if (!result.isValid()) return null;
|
|
235
|
-
result = result.subtract(7, "hours");
|
|
236
|
-
return result.format(dateTimeFormat);
|
|
237
|
-
}
|
|
238
|
-
return null;
|
|
239
|
-
}
|
|
240
|
-
if (cleanInput.length === 10) {
|
|
241
|
-
const day = cleanInput.slice(0, 2);
|
|
242
|
-
const month = cleanInput.slice(2, 4);
|
|
243
|
-
const year = cleanInput.slice(4, 8);
|
|
244
|
-
const hour = cleanInput.slice(8, 10);
|
|
245
|
-
if (isValidDate(day, month, year) && isValidTime(hour)) {
|
|
246
|
-
let result = moment(
|
|
247
|
-
`${day}-${month}-${year} ${hour}:00:00`,
|
|
248
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
249
|
-
);
|
|
250
|
-
if (!result.isValid()) return null;
|
|
251
|
-
result = result.subtract(7, "hours");
|
|
252
|
-
return result.format(dateTimeFormat);
|
|
253
|
-
}
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
|
-
if (cleanInput.length === 11) {
|
|
257
|
-
const day = cleanInput.slice(0, 2);
|
|
258
|
-
const month = cleanInput.slice(2, 4);
|
|
259
|
-
const year = cleanInput.slice(4, 8);
|
|
260
|
-
const hour = cleanInput.slice(8, 10);
|
|
261
|
-
const minute = cleanInput.slice(10, 11).padStart(2, "0");
|
|
262
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
|
|
263
|
-
let result = moment(
|
|
264
|
-
`${day}-${month}-${year} ${hour}:${minute}:00`,
|
|
265
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
266
|
-
);
|
|
267
|
-
if (!result.isValid()) return null;
|
|
268
|
-
result = result.subtract(7, "hours");
|
|
269
|
-
return result.format(dateTimeFormat);
|
|
270
|
-
}
|
|
271
|
-
return null;
|
|
272
|
-
}
|
|
273
|
-
if (cleanInput.length === 12) {
|
|
274
|
-
const day = cleanInput.slice(0, 2);
|
|
275
|
-
const month = cleanInput.slice(2, 4);
|
|
276
|
-
const year = cleanInput.slice(4, 8);
|
|
277
|
-
const hour = cleanInput.slice(8, 10);
|
|
278
|
-
const minute = cleanInput.slice(10, 12);
|
|
279
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
|
|
280
|
-
let result = moment(
|
|
281
|
-
`${day}-${month}-${year} ${hour}:${minute}:00`,
|
|
282
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
283
|
-
);
|
|
284
|
-
if (!result.isValid()) return null;
|
|
285
|
-
result = result.subtract(7, "hours");
|
|
286
|
-
return result.format(dateTimeFormat);
|
|
287
|
-
}
|
|
288
|
-
return null;
|
|
289
|
-
}
|
|
290
|
-
if (cleanInput.length === 13) {
|
|
291
|
-
const day = cleanInput.slice(0, 2);
|
|
292
|
-
const month = cleanInput.slice(2, 4);
|
|
293
|
-
const year = cleanInput.slice(4, 8);
|
|
294
|
-
const hour = cleanInput.slice(8, 10);
|
|
295
|
-
const minute = cleanInput.slice(10, 12);
|
|
296
|
-
const second = cleanInput.slice(12, 13).padStart(2, "0");
|
|
297
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
298
|
-
let result = moment(
|
|
299
|
-
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
300
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
301
|
-
);
|
|
302
|
-
if (!result.isValid()) return null;
|
|
303
|
-
result = result.subtract(7, "hours");
|
|
304
|
-
return result.format(dateTimeFormat);
|
|
305
|
-
}
|
|
306
|
-
return null;
|
|
307
|
-
}
|
|
308
|
-
if (cleanInput.length === 14) {
|
|
309
|
-
const day = cleanInput.slice(0, 2);
|
|
310
|
-
const month = cleanInput.slice(2, 4);
|
|
311
|
-
const year = cleanInput.slice(4, 8);
|
|
312
|
-
const hour = cleanInput.slice(8, 10);
|
|
313
|
-
const minute = cleanInput.slice(10, 12);
|
|
314
|
-
const second = cleanInput.slice(12, 14);
|
|
315
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
316
|
-
let result = moment(
|
|
317
|
-
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
318
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
319
|
-
);
|
|
320
|
-
if (!result.isValid()) return null;
|
|
321
|
-
result = result.subtract(7, "hours");
|
|
322
|
-
return result.format(dateTimeFormat);
|
|
323
|
-
}
|
|
324
|
-
return null;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
const len = cleanInput.length;
|
|
328
|
-
if (len === 1 || len === 2) {
|
|
329
|
-
const paddedDay = cleanInput.padStart(2, "0");
|
|
330
|
-
if (isValidDate(paddedDay, currentMonth, currentYear)) {
|
|
331
|
-
return formatOutput(paddedDay, currentMonth, currentYear);
|
|
332
|
-
}
|
|
333
|
-
return null;
|
|
334
|
-
}
|
|
335
|
-
if (len === 3) {
|
|
336
|
-
const day = cleanInput.slice(0, 2);
|
|
337
|
-
const month = cleanInput.slice(2, 3).padStart(2, "0");
|
|
338
|
-
if (isValidDate(day, month, currentYear)) {
|
|
339
|
-
return formatOutput(day, month, currentYear);
|
|
340
|
-
}
|
|
341
|
-
return null;
|
|
342
|
-
}
|
|
343
|
-
if (len === 6) {
|
|
344
|
-
const day = cleanInput.slice(0, 2);
|
|
345
|
-
const month = cleanInput.slice(2, 4);
|
|
346
|
-
let year = cleanInput.slice(4, 6);
|
|
347
|
-
year = `20${year}`;
|
|
348
|
-
if (parseInt(month) > 12) {
|
|
349
|
-
if (isValidDate(day, currentMonth, currentYear)) {
|
|
350
|
-
return formatOutput(day, currentMonth, currentYear);
|
|
351
|
-
}
|
|
352
|
-
return null;
|
|
353
|
-
}
|
|
354
|
-
if (isValidDate(day, month, year)) {
|
|
355
|
-
return formatOutput(day, month, year);
|
|
356
|
-
}
|
|
357
|
-
return null;
|
|
358
|
-
}
|
|
359
|
-
if (len === 7) {
|
|
360
|
-
return null;
|
|
361
|
-
}
|
|
362
|
-
if (len === 8) {
|
|
363
|
-
const day = cleanInput.slice(0, 2);
|
|
364
|
-
const month = cleanInput.slice(2, 4);
|
|
365
|
-
const year = cleanInput.slice(4, 8);
|
|
366
|
-
if (isValidDate(day, month, year)) {
|
|
367
|
-
return formatOutput(day, month, year);
|
|
368
|
-
}
|
|
369
|
-
return null;
|
|
370
|
-
}
|
|
371
|
-
if (len > 8 && !isDateTime) {
|
|
372
|
-
return null;
|
|
373
|
-
}
|
|
374
|
-
return null;
|
|
375
|
-
};
|
|
376
164
|
|
|
377
165
|
// src/utils.ts
|
|
378
166
|
export * from "@fctc/interface-logic/utils";
|
|
379
167
|
export {
|
|
380
168
|
STORAGES,
|
|
169
|
+
combineContexts,
|
|
170
|
+
convertFieldsToArray,
|
|
381
171
|
countSum,
|
|
382
|
-
|
|
383
|
-
isObjectEmpty,
|
|
172
|
+
getDateRange,
|
|
384
173
|
languages,
|
|
385
174
|
mergeButtons,
|
|
386
175
|
setStorageItemAsync,
|
|
387
|
-
useStorageState
|
|
388
|
-
validateAndParseDate
|
|
176
|
+
useStorageState
|
|
389
177
|
};
|
package/dist/widget.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ChangeEvent } from 'react';
|
|
3
3
|
import { IInputFieldProps } from './types.mjs';
|
|
4
|
+
import moment from 'moment';
|
|
4
5
|
import '@fctc/interface-logic/types';
|
|
5
6
|
|
|
6
7
|
type TStatus = 'normal' | 'done' | 'blocked';
|
|
@@ -130,6 +131,7 @@ declare const many2manyTagsController: (props: IMany2ManyTagFieldProps) => {
|
|
|
130
131
|
isUser: boolean;
|
|
131
132
|
isFetching: boolean;
|
|
132
133
|
fetchMoreOptions: () => void;
|
|
134
|
+
setInputValue: react.Dispatch<react.SetStateAction<string>>;
|
|
133
135
|
domainObject: any;
|
|
134
136
|
setDomainObject: react.Dispatch<any>;
|
|
135
137
|
handleChooseRecord: (idRecord: number) => void;
|
|
@@ -177,6 +179,26 @@ declare const downLoadBinaryController: (props: IInputFieldProps) => {
|
|
|
177
179
|
handleFileDownload: (e: any) => Promise<void>;
|
|
178
180
|
};
|
|
179
181
|
|
|
182
|
+
interface IDateFieldProps extends IInputFieldProps {
|
|
183
|
+
showTime: boolean;
|
|
184
|
+
widget: string;
|
|
185
|
+
min: number | string;
|
|
186
|
+
max: number | string;
|
|
187
|
+
viewData: any;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
declare const dateFieldController: (props: IDateFieldProps) => {
|
|
191
|
+
formatDate: string;
|
|
192
|
+
formatDateParse: string;
|
|
193
|
+
range: (start: number, end: number, step?: number) => number[];
|
|
194
|
+
years: number[];
|
|
195
|
+
months_vi: string[];
|
|
196
|
+
months_en: string[];
|
|
197
|
+
customValidateMinMax: (date: any) => string | false;
|
|
198
|
+
minNowValue: boolean | moment.Moment | null;
|
|
199
|
+
maxNowValue: boolean | moment.Moment | null;
|
|
200
|
+
};
|
|
201
|
+
|
|
180
202
|
declare const copyLinkButtonController: (props: IInputFieldProps) => {
|
|
181
203
|
isCopied: boolean;
|
|
182
204
|
handleCopyToClipboard: (value: string) => Promise<void>;
|
|
@@ -231,15 +253,6 @@ declare const many2manyBinaryController: (props: IInputFieldProps & UploadDeps &
|
|
|
231
253
|
setInitialFiles: react.Dispatch<react.SetStateAction<any[]>>;
|
|
232
254
|
};
|
|
233
255
|
|
|
234
|
-
interface IProviderEinvoiceFieldProps extends IInputFieldProps {
|
|
235
|
-
options?: any;
|
|
236
|
-
xNode?: any;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
declare const providerEinvoiceFieldController: (props: IProviderEinvoiceFieldProps) => {
|
|
240
|
-
listDataCard: any;
|
|
241
|
-
};
|
|
242
|
-
|
|
243
256
|
declare const tableHeadController: (props: any) => {
|
|
244
257
|
handleCheckBoxAll: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
245
258
|
checkedAll: any;
|
|
@@ -282,6 +295,7 @@ declare const tableController: ({ data }: ITableProps) => {
|
|
|
282
295
|
};
|
|
283
296
|
|
|
284
297
|
declare const tableGroupController: (props: any) => {
|
|
298
|
+
onExpandChildGroup: () => void;
|
|
285
299
|
colEmptyGroup: {
|
|
286
300
|
fromStart: number;
|
|
287
301
|
fromEnd: number;
|
|
@@ -289,6 +303,7 @@ declare const tableGroupController: (props: any) => {
|
|
|
289
303
|
isShowGroup: boolean;
|
|
290
304
|
isDataGroupFetched: boolean;
|
|
291
305
|
isDataPlaceHolder: boolean;
|
|
306
|
+
nameGroupWithCount: string;
|
|
292
307
|
columnsGroup: any;
|
|
293
308
|
rowsGroup: any[];
|
|
294
309
|
dataGroup: any;
|
|
@@ -325,4 +340,4 @@ declare const searchController: ({ viewData, model, domain, context, fieldsList,
|
|
|
325
340
|
hoveredIndexSearchList: number | null;
|
|
326
341
|
};
|
|
327
342
|
|
|
328
|
-
export { type ISelctionStateProps, type ITableHeadProps, type ITableProps, binaryFieldController, colorFieldController, copyLinkButtonController, downLoadBinaryController, downloadFileController, durationController, many2manyBinaryController, many2manyFieldController, many2manyTagsController, many2oneButtonController, many2oneFieldController, priorityFieldController,
|
|
343
|
+
export { type ISelctionStateProps, type ITableHeadProps, type ITableProps, binaryFieldController, colorFieldController, copyLinkButtonController, dateFieldController, downLoadBinaryController, downloadFileController, durationController, many2manyBinaryController, many2manyFieldController, many2manyTagsController, many2oneButtonController, many2oneFieldController, priorityFieldController, searchController, statusDropdownController, tableController, tableGroupController, tableHeadController };
|
package/dist/widget.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ChangeEvent } from 'react';
|
|
3
3
|
import { IInputFieldProps } from './types.js';
|
|
4
|
+
import moment from 'moment';
|
|
4
5
|
import '@fctc/interface-logic/types';
|
|
5
6
|
|
|
6
7
|
type TStatus = 'normal' | 'done' | 'blocked';
|
|
@@ -130,6 +131,7 @@ declare const many2manyTagsController: (props: IMany2ManyTagFieldProps) => {
|
|
|
130
131
|
isUser: boolean;
|
|
131
132
|
isFetching: boolean;
|
|
132
133
|
fetchMoreOptions: () => void;
|
|
134
|
+
setInputValue: react.Dispatch<react.SetStateAction<string>>;
|
|
133
135
|
domainObject: any;
|
|
134
136
|
setDomainObject: react.Dispatch<any>;
|
|
135
137
|
handleChooseRecord: (idRecord: number) => void;
|
|
@@ -177,6 +179,26 @@ declare const downLoadBinaryController: (props: IInputFieldProps) => {
|
|
|
177
179
|
handleFileDownload: (e: any) => Promise<void>;
|
|
178
180
|
};
|
|
179
181
|
|
|
182
|
+
interface IDateFieldProps extends IInputFieldProps {
|
|
183
|
+
showTime: boolean;
|
|
184
|
+
widget: string;
|
|
185
|
+
min: number | string;
|
|
186
|
+
max: number | string;
|
|
187
|
+
viewData: any;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
declare const dateFieldController: (props: IDateFieldProps) => {
|
|
191
|
+
formatDate: string;
|
|
192
|
+
formatDateParse: string;
|
|
193
|
+
range: (start: number, end: number, step?: number) => number[];
|
|
194
|
+
years: number[];
|
|
195
|
+
months_vi: string[];
|
|
196
|
+
months_en: string[];
|
|
197
|
+
customValidateMinMax: (date: any) => string | false;
|
|
198
|
+
minNowValue: boolean | moment.Moment | null;
|
|
199
|
+
maxNowValue: boolean | moment.Moment | null;
|
|
200
|
+
};
|
|
201
|
+
|
|
180
202
|
declare const copyLinkButtonController: (props: IInputFieldProps) => {
|
|
181
203
|
isCopied: boolean;
|
|
182
204
|
handleCopyToClipboard: (value: string) => Promise<void>;
|
|
@@ -231,15 +253,6 @@ declare const many2manyBinaryController: (props: IInputFieldProps & UploadDeps &
|
|
|
231
253
|
setInitialFiles: react.Dispatch<react.SetStateAction<any[]>>;
|
|
232
254
|
};
|
|
233
255
|
|
|
234
|
-
interface IProviderEinvoiceFieldProps extends IInputFieldProps {
|
|
235
|
-
options?: any;
|
|
236
|
-
xNode?: any;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
declare const providerEinvoiceFieldController: (props: IProviderEinvoiceFieldProps) => {
|
|
240
|
-
listDataCard: any;
|
|
241
|
-
};
|
|
242
|
-
|
|
243
256
|
declare const tableHeadController: (props: any) => {
|
|
244
257
|
handleCheckBoxAll: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
245
258
|
checkedAll: any;
|
|
@@ -282,6 +295,7 @@ declare const tableController: ({ data }: ITableProps) => {
|
|
|
282
295
|
};
|
|
283
296
|
|
|
284
297
|
declare const tableGroupController: (props: any) => {
|
|
298
|
+
onExpandChildGroup: () => void;
|
|
285
299
|
colEmptyGroup: {
|
|
286
300
|
fromStart: number;
|
|
287
301
|
fromEnd: number;
|
|
@@ -289,6 +303,7 @@ declare const tableGroupController: (props: any) => {
|
|
|
289
303
|
isShowGroup: boolean;
|
|
290
304
|
isDataGroupFetched: boolean;
|
|
291
305
|
isDataPlaceHolder: boolean;
|
|
306
|
+
nameGroupWithCount: string;
|
|
292
307
|
columnsGroup: any;
|
|
293
308
|
rowsGroup: any[];
|
|
294
309
|
dataGroup: any;
|
|
@@ -325,4 +340,4 @@ declare const searchController: ({ viewData, model, domain, context, fieldsList,
|
|
|
325
340
|
hoveredIndexSearchList: number | null;
|
|
326
341
|
};
|
|
327
342
|
|
|
328
|
-
export { type ISelctionStateProps, type ITableHeadProps, type ITableProps, binaryFieldController, colorFieldController, copyLinkButtonController, downLoadBinaryController, downloadFileController, durationController, many2manyBinaryController, many2manyFieldController, many2manyTagsController, many2oneButtonController, many2oneFieldController, priorityFieldController,
|
|
343
|
+
export { type ISelctionStateProps, type ITableHeadProps, type ITableProps, binaryFieldController, colorFieldController, copyLinkButtonController, dateFieldController, downLoadBinaryController, downloadFileController, durationController, many2manyBinaryController, many2manyFieldController, many2manyTagsController, many2oneButtonController, many2oneFieldController, priorityFieldController, searchController, statusDropdownController, tableController, tableGroupController, tableHeadController };
|