mado-ui 0.2.0 → 0.2.1
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.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 +33 -1
package/dist/index.esm.js
CHANGED
|
@@ -4,186 +4,6 @@ import { Children, isValidElement, Fragment, createContext, useContext, useSyncE
|
|
|
4
4
|
import { Button as Button$1, Field, Label, Input as Input$1, Description, Textarea as Textarea$1, Dialog, DialogBackdrop, DialogPanel } from '@headlessui/react';
|
|
5
5
|
import { createPortal } from 'react-dom';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* ### Has Class
|
|
9
|
-
* - Returns a boolean based on whether the specified element has the specified class
|
|
10
|
-
* @param {HTMLElement} element Any HTML Element
|
|
11
|
-
* @param {string} className A string of any class to check for
|
|
12
|
-
* @returns {boolean} true if the specified element has the specified class, else false
|
|
13
|
-
*/
|
|
14
|
-
function hasClass(element, className) {
|
|
15
|
-
return element.classList.contains(className);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* ### Add Class
|
|
19
|
-
* - Adds the specified classes to the specified elements
|
|
20
|
-
* @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)
|
|
21
|
-
* @param {string|string[]} classList A string or an array of classes to add to each element
|
|
22
|
-
*/
|
|
23
|
-
function addClass(elements, classList) {
|
|
24
|
-
const elementsType = elements.constructor.name, elementsIsString = typeof elements === 'string', classListType = classList.constructor.name, classListIsString = typeof classList === 'string';
|
|
25
|
-
let elementList, classListGroup;
|
|
26
|
-
// & Convert elements to array
|
|
27
|
-
switch (elementsType) {
|
|
28
|
-
// Selector
|
|
29
|
-
case 'String':
|
|
30
|
-
if (elementsIsString)
|
|
31
|
-
elementList = Array.from(document.querySelectorAll(elements));
|
|
32
|
-
break;
|
|
33
|
-
// Multiple HTML Elements
|
|
34
|
-
case 'NodeList':
|
|
35
|
-
if (!elementsIsString)
|
|
36
|
-
elementList = Array.from(elements);
|
|
37
|
-
break;
|
|
38
|
-
// Array of Elements
|
|
39
|
-
case 'Array':
|
|
40
|
-
if (!elementsIsString)
|
|
41
|
-
elementList = elements;
|
|
42
|
-
break;
|
|
43
|
-
// Single HTML Element
|
|
44
|
-
default:
|
|
45
|
-
if (elementsType.startsWith('HTML') && !elementsIsString)
|
|
46
|
-
elementList = [elements];
|
|
47
|
-
}
|
|
48
|
-
// & Convert classList to array
|
|
49
|
-
switch (classListType) {
|
|
50
|
-
case 'String':
|
|
51
|
-
if (classListIsString)
|
|
52
|
-
if (classList.split(' ').length >= 2) {
|
|
53
|
-
classListGroup = classList.split(' ');
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
classListGroup = [classList];
|
|
57
|
-
}
|
|
58
|
-
break;
|
|
59
|
-
case 'Array':
|
|
60
|
-
if (!classListIsString)
|
|
61
|
-
classListGroup = classList;
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
if (!elementList || elementList.length < 1)
|
|
65
|
-
throw new Error(`Elements are invalid or undefined. elements: ${elements} → elementList: ${elementList}`);
|
|
66
|
-
if (!classListGroup || classListGroup.length < 1)
|
|
67
|
-
throw new Error(`Class List is invalid or undefined. classList: ${classList} → classListGroup: ${classListGroup}`);
|
|
68
|
-
elementList.forEach((element) => classListGroup.forEach((classItem) => {
|
|
69
|
-
if (hasClass(element, classItem))
|
|
70
|
-
return;
|
|
71
|
-
element.classList.add(classItem);
|
|
72
|
-
}));
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* ### Remove Class
|
|
76
|
-
* - Removes the specified classes from the specified elements
|
|
77
|
-
* @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)
|
|
78
|
-
* @param {string|string[]} classList A string or an array of classes to remove from each element
|
|
79
|
-
*/
|
|
80
|
-
function removeClass(elements, classList) {
|
|
81
|
-
const elementsType = elements.constructor.name, elementsIsString = typeof elements === 'string', classListType = classList.constructor.name, classListIsString = typeof classList === 'string';
|
|
82
|
-
let elementList, classListGroup;
|
|
83
|
-
// & Convert elements to array
|
|
84
|
-
switch (elementsType) {
|
|
85
|
-
// Selector
|
|
86
|
-
case 'String':
|
|
87
|
-
if (elementsIsString)
|
|
88
|
-
elementList = Array.from(document.querySelectorAll(elements));
|
|
89
|
-
break;
|
|
90
|
-
// Multiple HTML Elements
|
|
91
|
-
case 'NodeList':
|
|
92
|
-
if (!elementsIsString)
|
|
93
|
-
elementList = Array.from(elements);
|
|
94
|
-
break;
|
|
95
|
-
// Array of Elements
|
|
96
|
-
case 'Array':
|
|
97
|
-
if (!elementsIsString)
|
|
98
|
-
elementList = elements;
|
|
99
|
-
break;
|
|
100
|
-
// Single HTML Element
|
|
101
|
-
default:
|
|
102
|
-
if (elementsType.startsWith('HTML') && !elementsIsString)
|
|
103
|
-
elementList = [elements];
|
|
104
|
-
}
|
|
105
|
-
// & Convert classList to array
|
|
106
|
-
switch (classListType) {
|
|
107
|
-
case 'String':
|
|
108
|
-
if (classListIsString)
|
|
109
|
-
if (classList.split(' ').length >= 2) {
|
|
110
|
-
classListGroup = classList.split(' ');
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
classListGroup = [classList];
|
|
114
|
-
}
|
|
115
|
-
break;
|
|
116
|
-
case 'Array':
|
|
117
|
-
if (!classListIsString)
|
|
118
|
-
classListGroup = classList;
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
if (!elementList || elementList.length < 1)
|
|
122
|
-
throw new Error(`Elements are invalid or undefined. elements: ${elements} → elementList: ${elementList}`);
|
|
123
|
-
if (!classListGroup || classListGroup.length < 1)
|
|
124
|
-
throw new Error(`Class List is invalid or undefined. classList: ${classList} → classListGroup: ${classListGroup}`);
|
|
125
|
-
elementList.forEach((element) => classListGroup.forEach((classItem) => {
|
|
126
|
-
if (!hasClass(element, classItem))
|
|
127
|
-
return;
|
|
128
|
-
element.classList.remove(classItem);
|
|
129
|
-
}));
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* ### Toggle Class
|
|
133
|
-
* - Toggles the specified classes on the specified elements
|
|
134
|
-
* @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)
|
|
135
|
-
* @param {string|string[]} classList A string or an array of classes to toggle on each element
|
|
136
|
-
*/
|
|
137
|
-
function toggleClass(elements, classList) {
|
|
138
|
-
const elementsType = elements.constructor.name, elementsIsString = typeof elements === 'string', classListType = classList.constructor.name, classListIsString = typeof classList === 'string';
|
|
139
|
-
let elementList, classListGroup;
|
|
140
|
-
// & Convert elements to array
|
|
141
|
-
switch (elementsType) {
|
|
142
|
-
// Selector
|
|
143
|
-
case 'String':
|
|
144
|
-
if (elementsIsString)
|
|
145
|
-
elementList = Array.from(document.querySelectorAll(elements));
|
|
146
|
-
break;
|
|
147
|
-
// Multiple HTML Elements
|
|
148
|
-
case 'NodeList':
|
|
149
|
-
if (!elementsIsString)
|
|
150
|
-
elementList = Array.from(elements);
|
|
151
|
-
break;
|
|
152
|
-
// Array of Elements
|
|
153
|
-
case 'Array':
|
|
154
|
-
if (!elementsIsString)
|
|
155
|
-
elementList = elements;
|
|
156
|
-
break;
|
|
157
|
-
// Single HTML Element
|
|
158
|
-
default:
|
|
159
|
-
if (elementsType.startsWith('HTML') && !elementsIsString)
|
|
160
|
-
elementList = [elements];
|
|
161
|
-
}
|
|
162
|
-
// & Convert classList to array
|
|
163
|
-
switch (classListType) {
|
|
164
|
-
case 'String':
|
|
165
|
-
if (classListIsString)
|
|
166
|
-
if (classList.split(' ').length >= 2) {
|
|
167
|
-
classListGroup = classList.split(' ');
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
classListGroup = [classList];
|
|
171
|
-
}
|
|
172
|
-
break;
|
|
173
|
-
case 'Array':
|
|
174
|
-
if (!classListIsString)
|
|
175
|
-
classListGroup = classList;
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
if (!elementList || elementList.length < 1)
|
|
179
|
-
throw new Error(`Elements are invalid or undefined. elements: ${elements} → elementList: ${elementList}`);
|
|
180
|
-
if (!classListGroup || classListGroup.length < 1)
|
|
181
|
-
throw new Error(`Class List is invalid or undefined. classList: ${classList} → classListGroup: ${classListGroup}`);
|
|
182
|
-
elementList.forEach((element) => classListGroup.forEach((classItem) => {
|
|
183
|
-
element.classList.toggle(classItem);
|
|
184
|
-
}));
|
|
185
|
-
}
|
|
186
|
-
|
|
187
7
|
const integerList = Array.from({ length: 100 }, (_, i) => `${i + 1}`);
|
|
188
8
|
const twMerge = extendTailwindMerge({
|
|
189
9
|
extend: {
|
|
@@ -260,105 +80,13 @@ const twMerge = extendTailwindMerge({
|
|
|
260
80
|
},
|
|
261
81
|
},
|
|
262
82
|
});
|
|
263
|
-
function extendMadoTailwindMerge(configExtension) {
|
|
264
|
-
const extend = configExtension.extend || {};
|
|
265
|
-
const theme = extend.theme || {};
|
|
266
|
-
const color = 'color' in theme ? theme.color : [];
|
|
267
|
-
const classGroups = extend.classGroups || {};
|
|
268
|
-
const themeRest = { ...theme };
|
|
269
|
-
if ('color' in themeRest)
|
|
270
|
-
delete themeRest.color;
|
|
271
|
-
const extendRest = { ...extend };
|
|
272
|
-
delete extendRest.theme;
|
|
273
|
-
delete extendRest.classGroups;
|
|
274
|
-
return extendTailwindMerge({
|
|
275
|
-
extend: {
|
|
276
|
-
theme: {
|
|
277
|
-
color: [
|
|
278
|
-
{
|
|
279
|
-
ui: [
|
|
280
|
-
'red',
|
|
281
|
-
'orange',
|
|
282
|
-
'yellow',
|
|
283
|
-
'green',
|
|
284
|
-
'sky-blue',
|
|
285
|
-
'blue',
|
|
286
|
-
'violet',
|
|
287
|
-
'magenta',
|
|
288
|
-
'purple',
|
|
289
|
-
'brown',
|
|
290
|
-
'grey',
|
|
291
|
-
'pink',
|
|
292
|
-
],
|
|
293
|
-
},
|
|
294
|
-
...color,
|
|
295
|
-
],
|
|
296
|
-
...themeRest,
|
|
297
|
-
},
|
|
298
|
-
classGroups: {
|
|
299
|
-
animate: [
|
|
300
|
-
{
|
|
301
|
-
animate: [
|
|
302
|
-
'bounce',
|
|
303
|
-
'double-spin',
|
|
304
|
-
'drop-in',
|
|
305
|
-
'flip',
|
|
306
|
-
'flip-again',
|
|
307
|
-
'grid-rows',
|
|
308
|
-
'heartbeat',
|
|
309
|
-
'ping',
|
|
310
|
-
'pulse',
|
|
311
|
-
'slide-up',
|
|
312
|
-
'spin',
|
|
313
|
-
'wave',
|
|
314
|
-
],
|
|
315
|
-
},
|
|
316
|
-
],
|
|
317
|
-
'animation-direction': [
|
|
318
|
-
{
|
|
319
|
-
'animation-direction': ['normal', 'reverse', 'alternate', 'alternate-reverse'],
|
|
320
|
-
},
|
|
321
|
-
],
|
|
322
|
-
'animation-fill': [
|
|
323
|
-
{
|
|
324
|
-
'animation-fill': ['none', 'forwards', 'backwards', 'both'],
|
|
325
|
-
},
|
|
326
|
-
],
|
|
327
|
-
'animation-iteration': [
|
|
328
|
-
{
|
|
329
|
-
'animation-iteration': [...integerList, 'infinite'],
|
|
330
|
-
},
|
|
331
|
-
],
|
|
332
|
-
'animation-state': [
|
|
333
|
-
{
|
|
334
|
-
'animation-state': ['running', 'paused'],
|
|
335
|
-
},
|
|
336
|
-
],
|
|
337
|
-
'grid-cols': [
|
|
338
|
-
{
|
|
339
|
-
'grid-cols': ['0fr', '1fr'],
|
|
340
|
-
},
|
|
341
|
-
],
|
|
342
|
-
'grid-rows': [
|
|
343
|
-
{
|
|
344
|
-
'grid-rows': ['0fr', '1fr'],
|
|
345
|
-
},
|
|
346
|
-
],
|
|
347
|
-
transition: ['transition-rows'],
|
|
348
|
-
...classGroups,
|
|
349
|
-
},
|
|
350
|
-
...extendRest,
|
|
351
|
-
},
|
|
352
|
-
...configExtension,
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
83
|
|
|
356
84
|
/** The current date as a Date object */
|
|
357
85
|
const d = new Date();
|
|
358
86
|
/** The current minute of the current hour */
|
|
359
87
|
const minutes = d.getMinutes();
|
|
360
88
|
/** The current year */
|
|
361
|
-
|
|
89
|
+
d.getFullYear();
|
|
362
90
|
/** An array of the names of month in order */
|
|
363
91
|
const monthNamesList = [
|
|
364
92
|
'January',
|
|
@@ -385,29 +113,9 @@ const weekdayNamesList = [
|
|
|
385
113
|
'Saturday',
|
|
386
114
|
];
|
|
387
115
|
/** The name of the current month */
|
|
388
|
-
|
|
116
|
+
getMonthName();
|
|
389
117
|
/** The name of the current day of the week */
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* ### Days In Month
|
|
393
|
-
* - Returns the number of days in the specified month.
|
|
394
|
-
* @param {Date} date A Date object representing the month to get the number of days for. (Preset to the current date)
|
|
395
|
-
* @returns {number} The number of days in the specified month.
|
|
396
|
-
*/
|
|
397
|
-
function daysInMonth(date = d) {
|
|
398
|
-
const selectedYear = date.getFullYear(), selectedMonth = date.getMonth() + 1;
|
|
399
|
-
return new Date(selectedYear, selectedMonth, 0).getDate();
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* ### First of Month
|
|
403
|
-
* - Returns the first day of the specified month.
|
|
404
|
-
* @param {Date} date A Date object representing the month to get the first day for. (Preset to current date)
|
|
405
|
-
* @returns {Date} A Date object of the given month, with the first day.
|
|
406
|
-
*/
|
|
407
|
-
function firstOfMonth(date = d) {
|
|
408
|
-
// Return a new Date object with the first of the month selected
|
|
409
|
-
return new Date(date.getFullYear(), date.getMonth(), 1);
|
|
410
|
-
}
|
|
118
|
+
getWeekdayName();
|
|
411
119
|
/**
|
|
412
120
|
* ### Get Date
|
|
413
121
|
* - Returns the date with two digits
|
|
@@ -436,32 +144,6 @@ function getHours(hours = d) {
|
|
|
436
144
|
formattedHours = `0${formattedHours}`;
|
|
437
145
|
return formattedHours;
|
|
438
146
|
}
|
|
439
|
-
/**
|
|
440
|
-
* ### Get Hours in 12
|
|
441
|
-
* - Returns the hour based on the specified 24 hour value in a 12 hour format
|
|
442
|
-
* @param {number|Date} hour The hour to be converted to 12 hour format
|
|
443
|
-
* @returns {number} The hour in a 12 hour format
|
|
444
|
-
*/
|
|
445
|
-
function getHoursIn12(hour = d) {
|
|
446
|
-
if (typeof hour !== 'number')
|
|
447
|
-
hour = hour.getHours();
|
|
448
|
-
if (hour > 12)
|
|
449
|
-
return hour - 12;
|
|
450
|
-
return hour;
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* ### Get Meridian from Hour
|
|
454
|
-
* - Returns either 'pm' or 'am' based on the specified 24 hour value
|
|
455
|
-
* @param {number|Date} hour The hour to get the meridian from
|
|
456
|
-
* @returns {'am'|'pm'} The meridian for the given hour
|
|
457
|
-
*/
|
|
458
|
-
function getMeridianFromHour(hour = d) {
|
|
459
|
-
if (typeof hour !== 'number')
|
|
460
|
-
hour = hour.getHours();
|
|
461
|
-
if (hour >= 12)
|
|
462
|
-
return 'pm';
|
|
463
|
-
return 'am';
|
|
464
|
-
}
|
|
465
147
|
/**
|
|
466
148
|
* ### Get Milliseconds
|
|
467
149
|
* - Returns the milliseconds with two digits
|
|
@@ -504,9 +186,6 @@ function getMonth(month = d) {
|
|
|
504
186
|
formattedMonth = `0${formattedMonth}`;
|
|
505
187
|
return formattedMonth;
|
|
506
188
|
}
|
|
507
|
-
function getMonthIndexFromName(name) {
|
|
508
|
-
return monthNamesList.findIndex(monthName => monthName === name);
|
|
509
|
-
}
|
|
510
189
|
/**
|
|
511
190
|
* ### Get Month Name
|
|
512
191
|
* - Returns the name of the specified month
|
|
@@ -518,28 +197,6 @@ function getMonthName(date = d) {
|
|
|
518
197
|
return monthNamesList[date];
|
|
519
198
|
return monthNamesList[date.getMonth()];
|
|
520
199
|
}
|
|
521
|
-
/**
|
|
522
|
-
* ### Get Next Month
|
|
523
|
-
* - Returns the number of the following month from the specified month
|
|
524
|
-
* @param {Date} date The Date object representing the month to get the following month from (Preset to current date)
|
|
525
|
-
* @returns {number} The indexed month of the following month
|
|
526
|
-
*/
|
|
527
|
-
function getNextMonth(date = d) {
|
|
528
|
-
const givenMonth = date.getMonth(); // Get the month from date
|
|
529
|
-
// Return the indexed month. min 0, max 11
|
|
530
|
-
return givenMonth === 11 ? 0 : givenMonth + 1;
|
|
531
|
-
}
|
|
532
|
-
/**
|
|
533
|
-
* ### Get Previous Month
|
|
534
|
-
* - Returns the number of the previous month from the specified month
|
|
535
|
-
* @param {Date} date The Date object representing the month to get the previous month from (Preset to current date)
|
|
536
|
-
* @returns {number} The indexed month of the previous month
|
|
537
|
-
*/
|
|
538
|
-
function getPreviousMonth(date = d) {
|
|
539
|
-
const givenMonth = date.getMonth(); // Get the month from date
|
|
540
|
-
// Return the indexed month. min 0, max 11
|
|
541
|
-
return givenMonth === 0 ? 11 : givenMonth - 1;
|
|
542
|
-
}
|
|
543
200
|
/**
|
|
544
201
|
* ### Get Seconds
|
|
545
202
|
* - Returns the seconds with two digits
|
|
@@ -554,31 +211,6 @@ function getSeconds(seconds = d) {
|
|
|
554
211
|
formattedSeconds = `0${formattedSeconds}`;
|
|
555
212
|
return formattedSeconds;
|
|
556
213
|
}
|
|
557
|
-
/**
|
|
558
|
-
* ### Get User Readable Date
|
|
559
|
-
* - Returns a string of the current date in a user-friendly way
|
|
560
|
-
* - Includes `'Yesterday'`, '`Today'`, and `'Tomorrow'`
|
|
561
|
-
* @param date (default: `new Date()`)
|
|
562
|
-
* @returns {'Today'|'Tomorrow'|'Yesterday'|string} `'weekday, month day, year'` | `'Yesterday'` | `'Today'` | `'Tomorrow'`
|
|
563
|
-
*/
|
|
564
|
-
function getUserReadableDate(date = d) {
|
|
565
|
-
const dateTime = date.getTime();
|
|
566
|
-
const today = new Date(), isToday = dateTime === today.getTime();
|
|
567
|
-
if (isToday)
|
|
568
|
-
return 'Today';
|
|
569
|
-
const yesterday = new Date(today.getDate() - 1), isYesterday = dateTime === yesterday.getTime();
|
|
570
|
-
if (isYesterday)
|
|
571
|
-
return 'Yesterday';
|
|
572
|
-
const tomorrow = new Date(today.getDate() + 1), isTomorrow = dateTime === tomorrow.getTime();
|
|
573
|
-
if (isTomorrow)
|
|
574
|
-
return 'Tomorrow';
|
|
575
|
-
const thisYear = today.getFullYear(), isSameYear = date.getFullYear() === thisYear;
|
|
576
|
-
const fullDateString = toFullDateString(date, {
|
|
577
|
-
weekday: 'code',
|
|
578
|
-
year: !isSameYear,
|
|
579
|
-
});
|
|
580
|
-
return fullDateString;
|
|
581
|
-
}
|
|
582
214
|
/**
|
|
583
215
|
* ### Get Weekday Name
|
|
584
216
|
* - Returns the weekday name of the specified day
|
|
@@ -591,80 +223,6 @@ function getWeekdayName(weekday = d) {
|
|
|
591
223
|
// Return the name of the day of the week
|
|
592
224
|
return weekdayNamesList[weekday.getDay()];
|
|
593
225
|
}
|
|
594
|
-
/**
|
|
595
|
-
* ### Get Years in Range
|
|
596
|
-
* - Returns an array of years in between the specified minimum and maximum years
|
|
597
|
-
* @param {number} minYear The minimum year
|
|
598
|
-
* @param {number} maxYear The maximum year
|
|
599
|
-
* @returns {number[]} Array of years
|
|
600
|
-
*/
|
|
601
|
-
function getYearsInRange(minYear = 0, maxYear = year) {
|
|
602
|
-
const yearList = [];
|
|
603
|
-
for (let selectedYear = minYear; selectedYear <= maxYear; selectedYear++) {
|
|
604
|
-
yearList.push(selectedYear);
|
|
605
|
-
}
|
|
606
|
-
return yearList;
|
|
607
|
-
}
|
|
608
|
-
/**
|
|
609
|
-
* ### To Full Date String
|
|
610
|
-
* - Returns a formatted string to display the date
|
|
611
|
-
* @param {Date} date (default: `new Date()`)
|
|
612
|
-
* @param {ToFullDateStringOptionsProps} options Change how to display the weekday, month name, day of the month, and year.
|
|
613
|
-
* @returns {string} '`weekday`, `month` `day`, `year`'
|
|
614
|
-
*/
|
|
615
|
-
function toFullDateString(date = d, options) {
|
|
616
|
-
let weekdayName = getWeekdayName(date), monthName = getMonthName(date), dayOfMonth = date.getDate(), year = date.getFullYear().toString();
|
|
617
|
-
if (options) {
|
|
618
|
-
const includesWeekday = options.weekday !== false, includesDay = options.day !== false, includesMonth = options.month !== false, includesYear = options.year !== false;
|
|
619
|
-
if (includesWeekday) {
|
|
620
|
-
if (options.weekday === 'code')
|
|
621
|
-
weekdayName = weekdayName.slice(0, 3);
|
|
622
|
-
if (includesMonth || includesDay || includesYear)
|
|
623
|
-
weekdayName += ', ';
|
|
624
|
-
}
|
|
625
|
-
else {
|
|
626
|
-
weekdayName = '';
|
|
627
|
-
}
|
|
628
|
-
if (includesMonth) {
|
|
629
|
-
if (options.month === 'code')
|
|
630
|
-
monthName = monthName.slice(0, 3);
|
|
631
|
-
if (includesDay)
|
|
632
|
-
monthName += ' ';
|
|
633
|
-
}
|
|
634
|
-
else {
|
|
635
|
-
monthName = '';
|
|
636
|
-
}
|
|
637
|
-
if (!includesDay)
|
|
638
|
-
dayOfMonth = '';
|
|
639
|
-
if (includesYear) {
|
|
640
|
-
if (options.year === 'code')
|
|
641
|
-
year = year.slice(-2);
|
|
642
|
-
if (includesMonth || includesDay)
|
|
643
|
-
year = ', ' + year;
|
|
644
|
-
}
|
|
645
|
-
else {
|
|
646
|
-
year = '';
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
return weekdayName + monthName + dayOfMonth + year;
|
|
650
|
-
}
|
|
651
|
-
/**
|
|
652
|
-
* ### Get User Readable Date From Timestampz
|
|
653
|
-
* - Returns a string of the current date in a user-friendly way
|
|
654
|
-
* - Includes `'Yesterday'`, '`Today'`, and `'Tomorrow'`
|
|
655
|
-
* @param string
|
|
656
|
-
* @returns {'Today'|'Tomorrow'|'Yesterday'|string} `'weekday, month day, year'` | `'Yesterday'` | `'Today'` | `'Tomorrow'`
|
|
657
|
-
*/
|
|
658
|
-
function getUserReadableDateFromTimestampz(timestampz) {
|
|
659
|
-
const [date, time] = timestampz.split('T') || [];
|
|
660
|
-
const [year, month, day] = date?.split('-').map(string => Number(string)) || [];
|
|
661
|
-
const timezoneIsAheadOfUTC = time?.includes('+');
|
|
662
|
-
const [hms, _timezone] = timezoneIsAheadOfUTC ? time?.split('+') : time?.split('-') || [];
|
|
663
|
-
const [hours, minutes, seconds] = hms?.split(':').map(string => Number(string)) || [];
|
|
664
|
-
// const [timezoneHours, timezoneMinutes] = timezone?.split(':').map(string => Number(string)) || []
|
|
665
|
-
const dateAndTime = new Date(year, month - 1, day, hours, minutes, seconds), userReadableDateAndTime = getUserReadableDate(dateAndTime);
|
|
666
|
-
return userReadableDateAndTime;
|
|
667
|
-
}
|
|
668
226
|
|
|
669
227
|
function findComponentByType(children, componentType) {
|
|
670
228
|
const childrenArray = Children.toArray(children);
|
|
@@ -717,7 +275,7 @@ function isPhoneNumber(tel) {
|
|
|
717
275
|
* @returns {string} string formatted (000) 000-0000
|
|
718
276
|
*/
|
|
719
277
|
function formatPhoneNumber(string, countryCode) {
|
|
720
|
-
return (`${
|
|
278
|
+
return (`${`+${countryCode} ` }` +
|
|
721
279
|
string
|
|
722
280
|
.replace(/\D/g, '')
|
|
723
281
|
.slice(-10)
|
|
@@ -2175,5 +1733,5 @@ function Time({ children, dateObject, dateTime, day, hours, milliseconds, minute
|
|
|
2175
1733
|
return (jsx("time", { dateTime: dateAndTime, ref: ref, ...props, children: dateDisplay }));
|
|
2176
1734
|
}
|
|
2177
1735
|
|
|
2178
|
-
export { Airplane, Anchor, ArrowTriangle2CirclepathCircle, ArrowTriangle2CirclepathCircleFill, BagFill, Banknote, BellFill, BoltCar, BoltFill, BoltRingClosed, BoltTrianglebadgeExclamationmark, BookFill, BookmarkFill, BriefcaseFill, BubbleLeftFill, Building2Fill, Button, Calendar, CameraFill, CarFill, CartFill, ChartBarDocHorizontal, Checkmark, CheckmarkSeal, ChevronCompactDown, ChevronDown, ChevronLeft, ChevronLeftForwardslashChevronRight, ChevronRight, ChevronUpChevronDown, CircleFill, ClockBadgeCheckmark, ClockFill, CloudFill, CubeFill, CurvePointLeft, DialHigh, DocFill, DocOnClipboard, DocOnDoc, DocOnDocFill, DocOnMagnifyingglass as DocTextMagnifyingglass, DollarSign, EllipsisCircle, EllipsisCircleFill, Envelope, EnvelopeFill, ExclamationmarkOctagon, Eye, FigureWaterFitness, FlagFill, FlameFill, Folder, FolderFill, Form, FormContextProvider, FormStatusProvider, Gearshape, GearshapeFill, Ghost, GiftFill, GlobeAmericasFill, HareFill, Heading, House, HouseDeskclock, HouseFill, IPhoneHouse, Input, LightRibbon, LightbulbFill, LightbulbLed, Link, ListBulletClipboardFill, Magnifyingglass, MapPinEllipse, MinusPlusBatteryblock, Modal, ModalDialog, ModalTrigger, Network, NetworkShield, NewspaperFill, Number$1 as Number, PaperplaneFill, Person, PersonCropSquare, PersonFill, PersonFillQuestionmark, Phone, PhoneArrowUpRight, PhoneFill, PlayRectangleFill, Plus, Qrcode, RectanglePortraitAndArrowLeft, RectanglePortraitAndArrowLeftFill, Sensor, Signature, SolarPanel, SquareAndArrowDown, SquareAndArrowDownFill, SquareAndArrowUp, SquareAndArrowUpFill, SquareAndPencil, SquareAndPencilFill, SubmitButton, TextBubble, Textarea, ThreePeople, ThreeRectanglesDesktop, ThreeRectanglesDesktopFill, Time, Trash, TrashFill, Tree, UmbrellaFill, xmark as Xmark,
|
|
1736
|
+
export { Airplane, Anchor, ArrowTriangle2CirclepathCircle, ArrowTriangle2CirclepathCircleFill, BagFill, Banknote, BellFill, BoltCar, BoltFill, BoltRingClosed, BoltTrianglebadgeExclamationmark, BookFill, BookmarkFill, BriefcaseFill, BubbleLeftFill, Building2Fill, Button, Calendar, CameraFill, CarFill, CartFill, ChartBarDocHorizontal, Checkmark, CheckmarkSeal, ChevronCompactDown, ChevronDown, ChevronLeft, ChevronLeftForwardslashChevronRight, ChevronRight, ChevronUpChevronDown, CircleFill, ClockBadgeCheckmark, ClockFill, CloudFill, CubeFill, CurvePointLeft, DialHigh, DocFill, DocOnClipboard, DocOnDoc, DocOnDocFill, DocOnMagnifyingglass as DocTextMagnifyingglass, DollarSign, EllipsisCircle, EllipsisCircleFill, Envelope, EnvelopeFill, ExclamationmarkOctagon, Eye, FigureWaterFitness, FlagFill, FlameFill, Folder, FolderFill, Form, FormContextProvider, FormStatusProvider, Gearshape, GearshapeFill, Ghost, GiftFill, GlobeAmericasFill, HareFill, Heading, House, HouseDeskclock, HouseFill, IPhoneHouse, Input, LightRibbon, LightbulbFill, LightbulbLed, Link, ListBulletClipboardFill, Magnifyingglass, MapPinEllipse, MinusPlusBatteryblock, Modal, ModalDialog, ModalTrigger, Network, NetworkShield, NewspaperFill, Number$1 as Number, PaperplaneFill, Person, PersonCropSquare, PersonFill, PersonFillQuestionmark, Phone, PhoneArrowUpRight, PhoneFill, PlayRectangleFill, Plus, Qrcode, RectanglePortraitAndArrowLeft, RectanglePortraitAndArrowLeftFill, Sensor, Signature, SolarPanel, SquareAndArrowDown, SquareAndArrowDownFill, SquareAndArrowUp, SquareAndArrowUpFill, SquareAndPencil, SquareAndPencilFill, SubmitButton, TextBubble, Textarea, ThreePeople, ThreeRectanglesDesktop, ThreeRectanglesDesktopFill, Time, Trash, TrashFill, Tree, UmbrellaFill, xmark as Xmark, defineField, useFormContext, useFormStatus };
|
|
2179
1737
|
//# sourceMappingURL=index.esm.js.map
|