mado-ui 0.2.0 → 0.2.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/components.esm.js +1329 -0
- package/dist/components.esm.js.map +1 -0
- package/dist/components.js +1343 -0
- package/dist/components.js.map +1 -0
- package/dist/hooks.esm.js +73 -0
- package/dist/hooks.esm.js.map +1 -0
- package/dist/hooks.js +80 -0
- package/dist/hooks.js.map +1 -0
- package/dist/icons.esm.js +416 -0
- package/dist/icons.esm.js.map +1 -0
- package/dist/icons.js +520 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +1 -3
- package/dist/index.esm.js +5 -447
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +4 -484
- package/dist/index.js.map +1 -1
- package/dist/types.esm.js +2 -0
- package/dist/types.esm.js.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.esm.js +751 -0
- package/dist/utils.esm.js.map +1 -0
- package/dist/utils.js +790 -0
- package/dist/utils.js.map +1 -0
- package/package.json +35 -4
package/dist/index.js
CHANGED
|
@@ -6,186 +6,6 @@ var react = require('react');
|
|
|
6
6
|
var react$1 = require('@headlessui/react');
|
|
7
7
|
var reactDom = require('react-dom');
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* ### Has Class
|
|
11
|
-
* - Returns a boolean based on whether the specified element has the specified class
|
|
12
|
-
* @param {HTMLElement} element Any HTML Element
|
|
13
|
-
* @param {string} className A string of any class to check for
|
|
14
|
-
* @returns {boolean} true if the specified element has the specified class, else false
|
|
15
|
-
*/
|
|
16
|
-
function hasClass(element, className) {
|
|
17
|
-
return element.classList.contains(className);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* ### Add Class
|
|
21
|
-
* - Adds the specified classes to the specified elements
|
|
22
|
-
* @param {Element|HTMLElement|HTMLElement[]|NodeList|string|undefined} elements An HTML Element, an array of HTML Elements, a Node List, a string (as a selector for a querySelector)
|
|
23
|
-
* @param {string|string[]} classList A string or an array of classes to add to each element
|
|
24
|
-
*/
|
|
25
|
-
function addClass(elements, classList) {
|
|
26
|
-
const elementsType = elements.constructor.name, elementsIsString = typeof elements === 'string', classListType = classList.constructor.name, classListIsString = typeof classList === 'string';
|
|
27
|
-
let elementList, classListGroup;
|
|
28
|
-
// & Convert elements to array
|
|
29
|
-
switch (elementsType) {
|
|
30
|
-
// Selector
|
|
31
|
-
case 'String':
|
|
32
|
-
if (elementsIsString)
|
|
33
|
-
elementList = Array.from(document.querySelectorAll(elements));
|
|
34
|
-
break;
|
|
35
|
-
// Multiple HTML Elements
|
|
36
|
-
case 'NodeList':
|
|
37
|
-
if (!elementsIsString)
|
|
38
|
-
elementList = Array.from(elements);
|
|
39
|
-
break;
|
|
40
|
-
// Array of Elements
|
|
41
|
-
case 'Array':
|
|
42
|
-
if (!elementsIsString)
|
|
43
|
-
elementList = elements;
|
|
44
|
-
break;
|
|
45
|
-
// Single HTML Element
|
|
46
|
-
default:
|
|
47
|
-
if (elementsType.startsWith('HTML') && !elementsIsString)
|
|
48
|
-
elementList = [elements];
|
|
49
|
-
}
|
|
50
|
-
// & Convert classList to array
|
|
51
|
-
switch (classListType) {
|
|
52
|
-
case 'String':
|
|
53
|
-
if (classListIsString)
|
|
54
|
-
if (classList.split(' ').length >= 2) {
|
|
55
|
-
classListGroup = classList.split(' ');
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
classListGroup = [classList];
|
|
59
|
-
}
|
|
60
|
-
break;
|
|
61
|
-
case 'Array':
|
|
62
|
-
if (!classListIsString)
|
|
63
|
-
classListGroup = classList;
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
if (!elementList || elementList.length < 1)
|
|
67
|
-
throw new Error(`Elements are invalid or undefined. elements: ${elements} → elementList: ${elementList}`);
|
|
68
|
-
if (!classListGroup || classListGroup.length < 1)
|
|
69
|
-
throw new Error(`Class List is invalid or undefined. classList: ${classList} → classListGroup: ${classListGroup}`);
|
|
70
|
-
elementList.forEach((element) => classListGroup.forEach((classItem) => {
|
|
71
|
-
if (hasClass(element, classItem))
|
|
72
|
-
return;
|
|
73
|
-
element.classList.add(classItem);
|
|
74
|
-
}));
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* ### Remove Class
|
|
78
|
-
* - Removes the specified classes from the specified elements
|
|
79
|
-
* @param {HTMLElement|HTMLElement[]|NodeList|string|undefined} elements An HTML Element, an array of HTML Elements, a Node List, a string (as a selector for a querySelector)
|
|
80
|
-
* @param {string|string[]} classList A string or an array of classes to remove from each element
|
|
81
|
-
*/
|
|
82
|
-
function removeClass(elements, classList) {
|
|
83
|
-
const elementsType = elements.constructor.name, elementsIsString = typeof elements === 'string', classListType = classList.constructor.name, classListIsString = typeof classList === 'string';
|
|
84
|
-
let elementList, classListGroup;
|
|
85
|
-
// & Convert elements to array
|
|
86
|
-
switch (elementsType) {
|
|
87
|
-
// Selector
|
|
88
|
-
case 'String':
|
|
89
|
-
if (elementsIsString)
|
|
90
|
-
elementList = Array.from(document.querySelectorAll(elements));
|
|
91
|
-
break;
|
|
92
|
-
// Multiple HTML Elements
|
|
93
|
-
case 'NodeList':
|
|
94
|
-
if (!elementsIsString)
|
|
95
|
-
elementList = Array.from(elements);
|
|
96
|
-
break;
|
|
97
|
-
// Array of Elements
|
|
98
|
-
case 'Array':
|
|
99
|
-
if (!elementsIsString)
|
|
100
|
-
elementList = elements;
|
|
101
|
-
break;
|
|
102
|
-
// Single HTML Element
|
|
103
|
-
default:
|
|
104
|
-
if (elementsType.startsWith('HTML') && !elementsIsString)
|
|
105
|
-
elementList = [elements];
|
|
106
|
-
}
|
|
107
|
-
// & Convert classList to array
|
|
108
|
-
switch (classListType) {
|
|
109
|
-
case 'String':
|
|
110
|
-
if (classListIsString)
|
|
111
|
-
if (classList.split(' ').length >= 2) {
|
|
112
|
-
classListGroup = classList.split(' ');
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
classListGroup = [classList];
|
|
116
|
-
}
|
|
117
|
-
break;
|
|
118
|
-
case 'Array':
|
|
119
|
-
if (!classListIsString)
|
|
120
|
-
classListGroup = classList;
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
if (!elementList || elementList.length < 1)
|
|
124
|
-
throw new Error(`Elements are invalid or undefined. elements: ${elements} → elementList: ${elementList}`);
|
|
125
|
-
if (!classListGroup || classListGroup.length < 1)
|
|
126
|
-
throw new Error(`Class List is invalid or undefined. classList: ${classList} → classListGroup: ${classListGroup}`);
|
|
127
|
-
elementList.forEach((element) => classListGroup.forEach((classItem) => {
|
|
128
|
-
if (!hasClass(element, classItem))
|
|
129
|
-
return;
|
|
130
|
-
element.classList.remove(classItem);
|
|
131
|
-
}));
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* ### Toggle Class
|
|
135
|
-
* - Toggles the specified classes on the specified elements
|
|
136
|
-
* @param {HTMLElement|HTMLElement[]|NodeList|string|undefined} elements An HTML Element, an array of HTML Elements, a Node List, a string (as a selector for a querySelector)
|
|
137
|
-
* @param {string|string[]} classList A string or an array of classes to toggle on each element
|
|
138
|
-
*/
|
|
139
|
-
function toggleClass(elements, classList) {
|
|
140
|
-
const elementsType = elements.constructor.name, elementsIsString = typeof elements === 'string', classListType = classList.constructor.name, classListIsString = typeof classList === 'string';
|
|
141
|
-
let elementList, classListGroup;
|
|
142
|
-
// & Convert elements to array
|
|
143
|
-
switch (elementsType) {
|
|
144
|
-
// Selector
|
|
145
|
-
case 'String':
|
|
146
|
-
if (elementsIsString)
|
|
147
|
-
elementList = Array.from(document.querySelectorAll(elements));
|
|
148
|
-
break;
|
|
149
|
-
// Multiple HTML Elements
|
|
150
|
-
case 'NodeList':
|
|
151
|
-
if (!elementsIsString)
|
|
152
|
-
elementList = Array.from(elements);
|
|
153
|
-
break;
|
|
154
|
-
// Array of Elements
|
|
155
|
-
case 'Array':
|
|
156
|
-
if (!elementsIsString)
|
|
157
|
-
elementList = elements;
|
|
158
|
-
break;
|
|
159
|
-
// Single HTML Element
|
|
160
|
-
default:
|
|
161
|
-
if (elementsType.startsWith('HTML') && !elementsIsString)
|
|
162
|
-
elementList = [elements];
|
|
163
|
-
}
|
|
164
|
-
// & Convert classList to array
|
|
165
|
-
switch (classListType) {
|
|
166
|
-
case 'String':
|
|
167
|
-
if (classListIsString)
|
|
168
|
-
if (classList.split(' ').length >= 2) {
|
|
169
|
-
classListGroup = classList.split(' ');
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
classListGroup = [classList];
|
|
173
|
-
}
|
|
174
|
-
break;
|
|
175
|
-
case 'Array':
|
|
176
|
-
if (!classListIsString)
|
|
177
|
-
classListGroup = classList;
|
|
178
|
-
break;
|
|
179
|
-
}
|
|
180
|
-
if (!elementList || elementList.length < 1)
|
|
181
|
-
throw new Error(`Elements are invalid or undefined. elements: ${elements} → elementList: ${elementList}`);
|
|
182
|
-
if (!classListGroup || classListGroup.length < 1)
|
|
183
|
-
throw new Error(`Class List is invalid or undefined. classList: ${classList} → classListGroup: ${classListGroup}`);
|
|
184
|
-
elementList.forEach((element) => classListGroup.forEach((classItem) => {
|
|
185
|
-
element.classList.toggle(classItem);
|
|
186
|
-
}));
|
|
187
|
-
}
|
|
188
|
-
|
|
189
9
|
const integerList = Array.from({ length: 100 }, (_, i) => `${i + 1}`);
|
|
190
10
|
const twMerge = tailwindMerge.extendTailwindMerge({
|
|
191
11
|
extend: {
|
|
@@ -262,105 +82,13 @@ const twMerge = tailwindMerge.extendTailwindMerge({
|
|
|
262
82
|
},
|
|
263
83
|
},
|
|
264
84
|
});
|
|
265
|
-
function extendMadoTailwindMerge(configExtension) {
|
|
266
|
-
const extend = configExtension.extend || {};
|
|
267
|
-
const theme = extend.theme || {};
|
|
268
|
-
const color = 'color' in theme ? theme.color : [];
|
|
269
|
-
const classGroups = extend.classGroups || {};
|
|
270
|
-
const themeRest = { ...theme };
|
|
271
|
-
if ('color' in themeRest)
|
|
272
|
-
delete themeRest.color;
|
|
273
|
-
const extendRest = { ...extend };
|
|
274
|
-
delete extendRest.theme;
|
|
275
|
-
delete extendRest.classGroups;
|
|
276
|
-
return tailwindMerge.extendTailwindMerge({
|
|
277
|
-
extend: {
|
|
278
|
-
theme: {
|
|
279
|
-
color: [
|
|
280
|
-
{
|
|
281
|
-
ui: [
|
|
282
|
-
'red',
|
|
283
|
-
'orange',
|
|
284
|
-
'yellow',
|
|
285
|
-
'green',
|
|
286
|
-
'sky-blue',
|
|
287
|
-
'blue',
|
|
288
|
-
'violet',
|
|
289
|
-
'magenta',
|
|
290
|
-
'purple',
|
|
291
|
-
'brown',
|
|
292
|
-
'grey',
|
|
293
|
-
'pink',
|
|
294
|
-
],
|
|
295
|
-
},
|
|
296
|
-
...color,
|
|
297
|
-
],
|
|
298
|
-
...themeRest,
|
|
299
|
-
},
|
|
300
|
-
classGroups: {
|
|
301
|
-
animate: [
|
|
302
|
-
{
|
|
303
|
-
animate: [
|
|
304
|
-
'bounce',
|
|
305
|
-
'double-spin',
|
|
306
|
-
'drop-in',
|
|
307
|
-
'flip',
|
|
308
|
-
'flip-again',
|
|
309
|
-
'grid-rows',
|
|
310
|
-
'heartbeat',
|
|
311
|
-
'ping',
|
|
312
|
-
'pulse',
|
|
313
|
-
'slide-up',
|
|
314
|
-
'spin',
|
|
315
|
-
'wave',
|
|
316
|
-
],
|
|
317
|
-
},
|
|
318
|
-
],
|
|
319
|
-
'animation-direction': [
|
|
320
|
-
{
|
|
321
|
-
'animation-direction': ['normal', 'reverse', 'alternate', 'alternate-reverse'],
|
|
322
|
-
},
|
|
323
|
-
],
|
|
324
|
-
'animation-fill': [
|
|
325
|
-
{
|
|
326
|
-
'animation-fill': ['none', 'forwards', 'backwards', 'both'],
|
|
327
|
-
},
|
|
328
|
-
],
|
|
329
|
-
'animation-iteration': [
|
|
330
|
-
{
|
|
331
|
-
'animation-iteration': [...integerList, 'infinite'],
|
|
332
|
-
},
|
|
333
|
-
],
|
|
334
|
-
'animation-state': [
|
|
335
|
-
{
|
|
336
|
-
'animation-state': ['running', 'paused'],
|
|
337
|
-
},
|
|
338
|
-
],
|
|
339
|
-
'grid-cols': [
|
|
340
|
-
{
|
|
341
|
-
'grid-cols': ['0fr', '1fr'],
|
|
342
|
-
},
|
|
343
|
-
],
|
|
344
|
-
'grid-rows': [
|
|
345
|
-
{
|
|
346
|
-
'grid-rows': ['0fr', '1fr'],
|
|
347
|
-
},
|
|
348
|
-
],
|
|
349
|
-
transition: ['transition-rows'],
|
|
350
|
-
...classGroups,
|
|
351
|
-
},
|
|
352
|
-
...extendRest,
|
|
353
|
-
},
|
|
354
|
-
...configExtension,
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
85
|
|
|
358
86
|
/** The current date as a Date object */
|
|
359
87
|
const d = new Date();
|
|
360
88
|
/** The current minute of the current hour */
|
|
361
89
|
const minutes = d.getMinutes();
|
|
362
90
|
/** The current year */
|
|
363
|
-
|
|
91
|
+
d.getFullYear();
|
|
364
92
|
/** An array of the names of month in order */
|
|
365
93
|
const monthNamesList = [
|
|
366
94
|
'January',
|
|
@@ -387,29 +115,9 @@ const weekdayNamesList = [
|
|
|
387
115
|
'Saturday',
|
|
388
116
|
];
|
|
389
117
|
/** The name of the current month */
|
|
390
|
-
|
|
118
|
+
getMonthName();
|
|
391
119
|
/** The name of the current day of the week */
|
|
392
|
-
|
|
393
|
-
/**
|
|
394
|
-
* ### Days In Month
|
|
395
|
-
* - Returns the number of days in the specified month.
|
|
396
|
-
* @param {Date} date A Date object representing the month to get the number of days for. (Preset to the current date)
|
|
397
|
-
* @returns {number} The number of days in the specified month.
|
|
398
|
-
*/
|
|
399
|
-
function daysInMonth(date = d) {
|
|
400
|
-
const selectedYear = date.getFullYear(), selectedMonth = date.getMonth() + 1;
|
|
401
|
-
return new Date(selectedYear, selectedMonth, 0).getDate();
|
|
402
|
-
}
|
|
403
|
-
/**
|
|
404
|
-
* ### First of Month
|
|
405
|
-
* - Returns the first day of the specified month.
|
|
406
|
-
* @param {Date} date A Date object representing the month to get the first day for. (Preset to current date)
|
|
407
|
-
* @returns {Date} A Date object of the given month, with the first day.
|
|
408
|
-
*/
|
|
409
|
-
function firstOfMonth(date = d) {
|
|
410
|
-
// Return a new Date object with the first of the month selected
|
|
411
|
-
return new Date(date.getFullYear(), date.getMonth(), 1);
|
|
412
|
-
}
|
|
120
|
+
getWeekdayName();
|
|
413
121
|
/**
|
|
414
122
|
* ### Get Date
|
|
415
123
|
* - Returns the date with two digits
|
|
@@ -438,32 +146,6 @@ function getHours(hours = d) {
|
|
|
438
146
|
formattedHours = `0${formattedHours}`;
|
|
439
147
|
return formattedHours;
|
|
440
148
|
}
|
|
441
|
-
/**
|
|
442
|
-
* ### Get Hours in 12
|
|
443
|
-
* - Returns the hour based on the specified 24 hour value in a 12 hour format
|
|
444
|
-
* @param {number|Date} hour The hour to be converted to 12 hour format
|
|
445
|
-
* @returns {number} The hour in a 12 hour format
|
|
446
|
-
*/
|
|
447
|
-
function getHoursIn12(hour = d) {
|
|
448
|
-
if (typeof hour !== 'number')
|
|
449
|
-
hour = hour.getHours();
|
|
450
|
-
if (hour > 12)
|
|
451
|
-
return hour - 12;
|
|
452
|
-
return hour;
|
|
453
|
-
}
|
|
454
|
-
/**
|
|
455
|
-
* ### Get Meridian from Hour
|
|
456
|
-
* - Returns either 'pm' or 'am' based on the specified 24 hour value
|
|
457
|
-
* @param {number|Date} hour The hour to get the meridian from
|
|
458
|
-
* @returns {'am'|'pm'} The meridian for the given hour
|
|
459
|
-
*/
|
|
460
|
-
function getMeridianFromHour(hour = d) {
|
|
461
|
-
if (typeof hour !== 'number')
|
|
462
|
-
hour = hour.getHours();
|
|
463
|
-
if (hour >= 12)
|
|
464
|
-
return 'pm';
|
|
465
|
-
return 'am';
|
|
466
|
-
}
|
|
467
149
|
/**
|
|
468
150
|
* ### Get Milliseconds
|
|
469
151
|
* - Returns the milliseconds with two digits
|
|
@@ -506,9 +188,6 @@ function getMonth(month = d) {
|
|
|
506
188
|
formattedMonth = `0${formattedMonth}`;
|
|
507
189
|
return formattedMonth;
|
|
508
190
|
}
|
|
509
|
-
function getMonthIndexFromName(name) {
|
|
510
|
-
return monthNamesList.findIndex(monthName => monthName === name);
|
|
511
|
-
}
|
|
512
191
|
/**
|
|
513
192
|
* ### Get Month Name
|
|
514
193
|
* - Returns the name of the specified month
|
|
@@ -520,28 +199,6 @@ function getMonthName(date = d) {
|
|
|
520
199
|
return monthNamesList[date];
|
|
521
200
|
return monthNamesList[date.getMonth()];
|
|
522
201
|
}
|
|
523
|
-
/**
|
|
524
|
-
* ### Get Next Month
|
|
525
|
-
* - Returns the number of the following month from the specified month
|
|
526
|
-
* @param {Date} date The Date object representing the month to get the following month from (Preset to current date)
|
|
527
|
-
* @returns {number} The indexed month of the following month
|
|
528
|
-
*/
|
|
529
|
-
function getNextMonth(date = d) {
|
|
530
|
-
const givenMonth = date.getMonth(); // Get the month from date
|
|
531
|
-
// Return the indexed month. min 0, max 11
|
|
532
|
-
return givenMonth === 11 ? 0 : givenMonth + 1;
|
|
533
|
-
}
|
|
534
|
-
/**
|
|
535
|
-
* ### Get Previous Month
|
|
536
|
-
* - Returns the number of the previous month from the specified month
|
|
537
|
-
* @param {Date} date The Date object representing the month to get the previous month from (Preset to current date)
|
|
538
|
-
* @returns {number} The indexed month of the previous month
|
|
539
|
-
*/
|
|
540
|
-
function getPreviousMonth(date = d) {
|
|
541
|
-
const givenMonth = date.getMonth(); // Get the month from date
|
|
542
|
-
// Return the indexed month. min 0, max 11
|
|
543
|
-
return givenMonth === 0 ? 11 : givenMonth - 1;
|
|
544
|
-
}
|
|
545
202
|
/**
|
|
546
203
|
* ### Get Seconds
|
|
547
204
|
* - Returns the seconds with two digits
|
|
@@ -556,31 +213,6 @@ function getSeconds(seconds = d) {
|
|
|
556
213
|
formattedSeconds = `0${formattedSeconds}`;
|
|
557
214
|
return formattedSeconds;
|
|
558
215
|
}
|
|
559
|
-
/**
|
|
560
|
-
* ### Get User Readable Date
|
|
561
|
-
* - Returns a string of the current date in a user-friendly way
|
|
562
|
-
* - Includes `'Yesterday'`, '`Today'`, and `'Tomorrow'`
|
|
563
|
-
* @param date (default: `new Date()`)
|
|
564
|
-
* @returns {'Today'|'Tomorrow'|'Yesterday'|string} `'weekday, month day, year'` | `'Yesterday'` | `'Today'` | `'Tomorrow'`
|
|
565
|
-
*/
|
|
566
|
-
function getUserReadableDate(date = d) {
|
|
567
|
-
const dateTime = date.getTime();
|
|
568
|
-
const today = new Date(), isToday = dateTime === today.getTime();
|
|
569
|
-
if (isToday)
|
|
570
|
-
return 'Today';
|
|
571
|
-
const yesterday = new Date(today.getDate() - 1), isYesterday = dateTime === yesterday.getTime();
|
|
572
|
-
if (isYesterday)
|
|
573
|
-
return 'Yesterday';
|
|
574
|
-
const tomorrow = new Date(today.getDate() + 1), isTomorrow = dateTime === tomorrow.getTime();
|
|
575
|
-
if (isTomorrow)
|
|
576
|
-
return 'Tomorrow';
|
|
577
|
-
const thisYear = today.getFullYear(), isSameYear = date.getFullYear() === thisYear;
|
|
578
|
-
const fullDateString = toFullDateString(date, {
|
|
579
|
-
weekday: 'code',
|
|
580
|
-
year: !isSameYear,
|
|
581
|
-
});
|
|
582
|
-
return fullDateString;
|
|
583
|
-
}
|
|
584
216
|
/**
|
|
585
217
|
* ### Get Weekday Name
|
|
586
218
|
* - Returns the weekday name of the specified day
|
|
@@ -593,80 +225,6 @@ function getWeekdayName(weekday = d) {
|
|
|
593
225
|
// Return the name of the day of the week
|
|
594
226
|
return weekdayNamesList[weekday.getDay()];
|
|
595
227
|
}
|
|
596
|
-
/**
|
|
597
|
-
* ### Get Years in Range
|
|
598
|
-
* - Returns an array of years in between the specified minimum and maximum years
|
|
599
|
-
* @param {number} minYear The minimum year
|
|
600
|
-
* @param {number} maxYear The maximum year
|
|
601
|
-
* @returns {number[]} Array of years
|
|
602
|
-
*/
|
|
603
|
-
function getYearsInRange(minYear = 0, maxYear = year) {
|
|
604
|
-
const yearList = [];
|
|
605
|
-
for (let selectedYear = minYear; selectedYear <= maxYear; selectedYear++) {
|
|
606
|
-
yearList.push(selectedYear);
|
|
607
|
-
}
|
|
608
|
-
return yearList;
|
|
609
|
-
}
|
|
610
|
-
/**
|
|
611
|
-
* ### To Full Date String
|
|
612
|
-
* - Returns a formatted string to display the date
|
|
613
|
-
* @param {Date} date (default: `new Date()`)
|
|
614
|
-
* @param {ToFullDateStringOptionsProps} options Change how to display the weekday, month name, day of the month, and year.
|
|
615
|
-
* @returns {string} '`weekday`, `month` `day`, `year`'
|
|
616
|
-
*/
|
|
617
|
-
function toFullDateString(date = d, options) {
|
|
618
|
-
let weekdayName = getWeekdayName(date), monthName = getMonthName(date), dayOfMonth = date.getDate(), year = date.getFullYear().toString();
|
|
619
|
-
if (options) {
|
|
620
|
-
const includesWeekday = options.weekday !== false, includesDay = options.day !== false, includesMonth = options.month !== false, includesYear = options.year !== false;
|
|
621
|
-
if (includesWeekday) {
|
|
622
|
-
if (options.weekday === 'code')
|
|
623
|
-
weekdayName = weekdayName.slice(0, 3);
|
|
624
|
-
if (includesMonth || includesDay || includesYear)
|
|
625
|
-
weekdayName += ', ';
|
|
626
|
-
}
|
|
627
|
-
else {
|
|
628
|
-
weekdayName = '';
|
|
629
|
-
}
|
|
630
|
-
if (includesMonth) {
|
|
631
|
-
if (options.month === 'code')
|
|
632
|
-
monthName = monthName.slice(0, 3);
|
|
633
|
-
if (includesDay)
|
|
634
|
-
monthName += ' ';
|
|
635
|
-
}
|
|
636
|
-
else {
|
|
637
|
-
monthName = '';
|
|
638
|
-
}
|
|
639
|
-
if (!includesDay)
|
|
640
|
-
dayOfMonth = '';
|
|
641
|
-
if (includesYear) {
|
|
642
|
-
if (options.year === 'code')
|
|
643
|
-
year = year.slice(-2);
|
|
644
|
-
if (includesMonth || includesDay)
|
|
645
|
-
year = ', ' + year;
|
|
646
|
-
}
|
|
647
|
-
else {
|
|
648
|
-
year = '';
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
return weekdayName + monthName + dayOfMonth + year;
|
|
652
|
-
}
|
|
653
|
-
/**
|
|
654
|
-
* ### Get User Readable Date From Timestampz
|
|
655
|
-
* - Returns a string of the current date in a user-friendly way
|
|
656
|
-
* - Includes `'Yesterday'`, '`Today'`, and `'Tomorrow'`
|
|
657
|
-
* @param string
|
|
658
|
-
* @returns {'Today'|'Tomorrow'|'Yesterday'|string} `'weekday, month day, year'` | `'Yesterday'` | `'Today'` | `'Tomorrow'`
|
|
659
|
-
*/
|
|
660
|
-
function getUserReadableDateFromTimestampz(timestampz) {
|
|
661
|
-
const [date, time] = timestampz.split('T') || [];
|
|
662
|
-
const [year, month, day] = date?.split('-').map(string => Number(string)) || [];
|
|
663
|
-
const timezoneIsAheadOfUTC = time?.includes('+');
|
|
664
|
-
const [hms, _timezone] = timezoneIsAheadOfUTC ? time?.split('+') : time?.split('-') || [];
|
|
665
|
-
const [hours, minutes, seconds] = hms?.split(':').map(string => Number(string)) || [];
|
|
666
|
-
// const [timezoneHours, timezoneMinutes] = timezone?.split(':').map(string => Number(string)) || []
|
|
667
|
-
const dateAndTime = new Date(year, month - 1, day, hours, minutes, seconds), userReadableDateAndTime = getUserReadableDate(dateAndTime);
|
|
668
|
-
return userReadableDateAndTime;
|
|
669
|
-
}
|
|
670
228
|
|
|
671
229
|
function findComponentByType(children, componentType) {
|
|
672
230
|
const childrenArray = react.Children.toArray(children);
|
|
@@ -719,7 +277,7 @@ function isPhoneNumber(tel) {
|
|
|
719
277
|
* @returns {string} string formatted (000) 000-0000
|
|
720
278
|
*/
|
|
721
279
|
function formatPhoneNumber(string, countryCode) {
|
|
722
|
-
return (`${
|
|
280
|
+
return (`${`+${countryCode} ` }` +
|
|
723
281
|
string
|
|
724
282
|
.replace(/\D/g, '')
|
|
725
283
|
.slice(-10)
|
|
@@ -2295,45 +1853,7 @@ exports.TrashFill = TrashFill;
|
|
|
2295
1853
|
exports.Tree = Tree;
|
|
2296
1854
|
exports.UmbrellaFill = UmbrellaFill;
|
|
2297
1855
|
exports.Xmark = xmark;
|
|
2298
|
-
exports.addClass = addClass;
|
|
2299
|
-
exports.currentMonthName = currentMonthName;
|
|
2300
|
-
exports.currentWeekdayName = currentWeekdayName;
|
|
2301
|
-
exports.daysInMonth = daysInMonth;
|
|
2302
1856
|
exports.defineField = defineField;
|
|
2303
|
-
exports.easeOutExpo = easeOutExpo;
|
|
2304
|
-
exports.emailRegex = emailRegex;
|
|
2305
|
-
exports.extendMadoTailwindMerge = extendMadoTailwindMerge;
|
|
2306
|
-
exports.findComponentByType = findComponentByType;
|
|
2307
|
-
exports.firstOfMonth = firstOfMonth;
|
|
2308
|
-
exports.formatPhoneNumber = formatPhoneNumber;
|
|
2309
|
-
exports.getDate = getDate;
|
|
2310
|
-
exports.getHours = getHours;
|
|
2311
|
-
exports.getHoursIn12 = getHoursIn12;
|
|
2312
|
-
exports.getMeridianFromHour = getMeridianFromHour;
|
|
2313
|
-
exports.getMilliseconds = getMilliseconds;
|
|
2314
|
-
exports.getMinutes = getMinutes;
|
|
2315
|
-
exports.getMonth = getMonth;
|
|
2316
|
-
exports.getMonthIndexFromName = getMonthIndexFromName;
|
|
2317
|
-
exports.getMonthName = getMonthName;
|
|
2318
|
-
exports.getNextMonth = getNextMonth;
|
|
2319
|
-
exports.getPreviousMonth = getPreviousMonth;
|
|
2320
|
-
exports.getSeconds = getSeconds;
|
|
2321
|
-
exports.getUserReadableDate = getUserReadableDate;
|
|
2322
|
-
exports.getUserReadableDateFromTimestampz = getUserReadableDateFromTimestampz;
|
|
2323
|
-
exports.getWeekdayName = getWeekdayName;
|
|
2324
|
-
exports.getYearsInRange = getYearsInRange;
|
|
2325
|
-
exports.hasClass = hasClass;
|
|
2326
|
-
exports.isEmail = isEmail;
|
|
2327
|
-
exports.isPhoneNumber = isPhoneNumber;
|
|
2328
|
-
exports.monthNamesList = monthNamesList;
|
|
2329
|
-
exports.removeClass = removeClass;
|
|
2330
|
-
exports.telRegex = telRegex;
|
|
2331
|
-
exports.toFullDateString = toFullDateString;
|
|
2332
|
-
exports.toLowerCase = toLowerCase;
|
|
2333
|
-
exports.toggleClass = toggleClass;
|
|
2334
|
-
exports.twMerge = twMerge;
|
|
2335
|
-
exports.twSort = twSort;
|
|
2336
1857
|
exports.useFormContext = useFormContext;
|
|
2337
1858
|
exports.useFormStatus = useFormStatus;
|
|
2338
|
-
exports.weekdayNamesList = weekdayNamesList;
|
|
2339
1859
|
//# sourceMappingURL=index.js.map
|