@radiantabyss/vue 3.1.6 → 3.2.0
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/package.json +1 -1
- package/src/Bootstrap.js +3 -0
- package/src/Modal.js +16 -0
- package/src/Support/Str.js +131 -0
package/package.json
CHANGED
package/src/Bootstrap.js
CHANGED
|
@@ -11,6 +11,7 @@ import Helpers from './Support/Helpers';
|
|
|
11
11
|
import Invoke from './Invoke';
|
|
12
12
|
import Item from './Support/Item';
|
|
13
13
|
import Items from './Support/Items';
|
|
14
|
+
import Modal from './Modal';
|
|
14
15
|
import Request from './Request';
|
|
15
16
|
import ReactiveStorage from './Support/ReactiveStorage';
|
|
16
17
|
import Str from './Support/Str';
|
|
@@ -36,6 +37,7 @@ export default async (app) => {
|
|
|
36
37
|
window.Invoke = Invoke;
|
|
37
38
|
window.Item = Item;
|
|
38
39
|
window.Items = Items;
|
|
40
|
+
window.Modal = Modal;
|
|
39
41
|
window.Request = Request;
|
|
40
42
|
window.ReactiveStorage = ReactiveStorage;
|
|
41
43
|
window.Str = Str;
|
|
@@ -44,6 +46,7 @@ export default async (app) => {
|
|
|
44
46
|
app.config.globalProperties.Item = Item;
|
|
45
47
|
app.config.globalProperties.Items = Items;
|
|
46
48
|
app.config.globalProperties.Gate = Gate;
|
|
49
|
+
app.config.globalProperties.Modal = Modal;
|
|
47
50
|
app.config.globalProperties.Str = Str;
|
|
48
51
|
|
|
49
52
|
await Store(app);
|
package/src/Modal.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
let self = {
|
|
2
|
+
show(name, params) {
|
|
3
|
+
window.dispatchEvent(new CustomEvent('modal-show', { detail: {
|
|
4
|
+
name,
|
|
5
|
+
params,
|
|
6
|
+
}}));
|
|
7
|
+
},
|
|
8
|
+
|
|
9
|
+
hide(name) {
|
|
10
|
+
window.dispatchEvent(new CustomEvent('modal-hide', { detail: {
|
|
11
|
+
name,
|
|
12
|
+
}}));
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default self;
|
package/src/Support/Str.js
CHANGED
|
@@ -204,6 +204,137 @@ let self = {
|
|
|
204
204
|
|
|
205
205
|
return str;
|
|
206
206
|
},
|
|
207
|
+
|
|
208
|
+
string_to_date(str) {
|
|
209
|
+
let match;
|
|
210
|
+
let months_short = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
|
|
211
|
+
|
|
212
|
+
//trim spaces
|
|
213
|
+
str = str.trim();
|
|
214
|
+
|
|
215
|
+
//dash format: 23-10-2024
|
|
216
|
+
match = str.match(/(\d{2})-(\d{2})-(\d{4})/);
|
|
217
|
+
if ( match && match.length == 4 ) {
|
|
218
|
+
return new Date(`${match[3]}-${match[2]}-${match[1]}`);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
//dot format: 23.10.2024
|
|
222
|
+
match = str.match(/(\d{2})\.(\d{2})\.(\d{4})/);
|
|
223
|
+
if ( match && match.length == 4 ) {
|
|
224
|
+
return new Date(`${match[3]}-${match[2]}-${match[1]}`);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
//pretty format: 23 Oct
|
|
228
|
+
match = str.match(/(\d{2}) (\w{3})/i);
|
|
229
|
+
if ( match && match.length == 3 ) {
|
|
230
|
+
let date = new Date();
|
|
231
|
+
let month = months_short.indexOf(match[2].toLowerCase()) + 1;
|
|
232
|
+
return new Date(`${date.getFullYear()}-${self.leading_zero(month)}-${match[1]}`);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
//pretty format with year: 23 Oct 2024
|
|
236
|
+
match = str.match(/(\d{2}) (\w{3}) (\d{4})/i);
|
|
237
|
+
if ( match && match.length == 4 ) {
|
|
238
|
+
let month = months_short.indexOf(months_short[match[2].toLowerCase()]) + 1;
|
|
239
|
+
return new Date(`${match[3]}-${self.leading_zero(month)}-${match[1]}`);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
//today
|
|
243
|
+
if ( str.match(/^today$/i) ) {
|
|
244
|
+
return new Date();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
//yesterday
|
|
248
|
+
if ( str.match(/^yesterday$/i) ) {
|
|
249
|
+
let date = new Date();
|
|
250
|
+
return date.setDate(date.getDate() - 1);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return new Date(str);
|
|
254
|
+
},
|
|
255
|
+
|
|
256
|
+
prettify_date(date) {
|
|
257
|
+
if ( !date ) {
|
|
258
|
+
return 'Never';
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
let mysql_date = date;
|
|
262
|
+
if ( typeof date == 'string' ) {
|
|
263
|
+
date = new Date(date);
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
mysql_date = self.mysql_date(date);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if ( isNaN(date) ) {
|
|
270
|
+
return 'Invalid Date';
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
//check if is today
|
|
274
|
+
let today = new Date();
|
|
275
|
+
if ( self.mysql_date(today) == mysql_date ) {
|
|
276
|
+
return 'Today';
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
//check if is yesterday
|
|
280
|
+
today.setDate(-1);
|
|
281
|
+
if ( self.mysql_date(today) == mysql_date ) {
|
|
282
|
+
return 'Yesterday';
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
//check if is current year then don't display it
|
|
286
|
+
if ( new Date(date).getFullYear() == today.getFullYear() ) {
|
|
287
|
+
return `${self.leading_zero(date.getDate())} ${date.toLocaleString('default', { month: 'short' })}`;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
return `${self.leading_zero(date.getDate())} ${date.toLocaleString('default', { month: 'short' })} ${date.getFullYear()}`;
|
|
291
|
+
},
|
|
292
|
+
|
|
293
|
+
prettify_datetime(date) {
|
|
294
|
+
const options = {};
|
|
295
|
+
const parsed_date = new Date(new Date(date + 'Z').toLocaleString('en-US', options)); // Add 'Z' for UTC handling
|
|
296
|
+
const now = new Date();
|
|
297
|
+
|
|
298
|
+
if (parsed_date.getFullYear() === now.getFullYear()) {
|
|
299
|
+
return parsed_date.toLocaleDateString('en-US', {
|
|
300
|
+
day: '2-digit',
|
|
301
|
+
month: 'short',
|
|
302
|
+
hour: '2-digit',
|
|
303
|
+
minute: '2-digit',
|
|
304
|
+
hour12: false,
|
|
305
|
+
}).replace(',', ' @');
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return parsed_date.toLocaleDateString('en-US', {
|
|
309
|
+
day: '2-digit',
|
|
310
|
+
month: 'short',
|
|
311
|
+
year: 'numeric',
|
|
312
|
+
hour: '2-digit',
|
|
313
|
+
minute: '2-digit',
|
|
314
|
+
hour12: false,
|
|
315
|
+
}).replace(',', ' @');
|
|
316
|
+
},
|
|
317
|
+
|
|
318
|
+
prettify_time(date) {
|
|
319
|
+
const options = {};
|
|
320
|
+
const parsed_date = new Date(new Date(date + 'Z').toLocaleString('en-US', options)); // Add 'Z' for UTC handling
|
|
321
|
+
|
|
322
|
+
return parsed_date.toLocaleTimeString('en-US', {
|
|
323
|
+
hour: '2-digit',
|
|
324
|
+
minute: '2-digit',
|
|
325
|
+
hour12: false,
|
|
326
|
+
});
|
|
327
|
+
},
|
|
328
|
+
|
|
329
|
+
mysql_date(date = null) {
|
|
330
|
+
if ( !date ) {
|
|
331
|
+
date = new Date();
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
let month = date.getMonth() + 1;
|
|
335
|
+
let day = date.getDate();
|
|
336
|
+
return `${date.getFullYear()}-${self.leading_zero(month)}-${self.leading_zero(day)}`;
|
|
337
|
+
},
|
|
207
338
|
}
|
|
208
339
|
|
|
209
340
|
export default self;
|