@sepale/components 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +65 -3
- package/dist/components/Accordion.svelte +48 -0
- package/dist/components/Accordion.svelte.d.ts +24 -0
- package/dist/components/Alert.svelte +107 -0
- package/dist/components/Alert.svelte.d.ts +40 -0
- package/dist/components/Avatar.svelte +75 -0
- package/dist/components/Avatar.svelte.d.ts +37 -0
- package/dist/components/Badge.svelte +46 -0
- package/dist/components/Badge.svelte.d.ts +22 -0
- package/dist/components/Breadcrumbs.svelte +36 -0
- package/dist/components/Breadcrumbs.svelte.d.ts +18 -0
- package/dist/components/Bubble.svelte +43 -0
- package/dist/components/Bubble.svelte.d.ts +23 -0
- package/dist/components/Button.svelte +132 -0
- package/dist/components/Button.svelte.d.ts +40 -0
- package/dist/components/Calendar.svelte +193 -0
- package/dist/components/Calendar.svelte.d.ts +60 -0
- package/dist/components/Card.svelte +69 -0
- package/dist/components/Card.svelte.d.ts +37 -0
- package/dist/components/Carousel.svelte +550 -0
- package/dist/components/Carousel.svelte.d.ts +124 -0
- package/dist/components/Checkbox.svelte +48 -0
- package/dist/components/Checkbox.svelte.d.ts +26 -0
- package/dist/components/Chip.svelte +60 -0
- package/dist/components/Chip.svelte.d.ts +26 -0
- package/dist/components/ChipsInput.svelte +158 -0
- package/dist/components/ChipsInput.svelte.d.ts +64 -0
- package/dist/components/Collapse.svelte +101 -0
- package/dist/components/Collapse.svelte.d.ts +46 -0
- package/dist/components/ColorPicker.svelte +135 -0
- package/dist/components/ColorPicker.svelte.d.ts +44 -0
- package/dist/components/Combobox.svelte +496 -0
- package/dist/components/Combobox.svelte.d.ts +96 -0
- package/dist/components/DataControl.svelte +754 -0
- package/dist/components/DataControl.svelte.d.ts +143 -0
- package/dist/components/DataHandler.svelte +67 -0
- package/dist/components/DataHandler.svelte.d.ts +44 -0
- package/dist/components/DatePicker.svelte +185 -0
- package/dist/components/DatePicker.svelte.d.ts +56 -0
- package/dist/components/Dialog.svelte +194 -0
- package/dist/components/Dialog.svelte.d.ts +51 -0
- package/dist/components/Divider.svelte +54 -0
- package/dist/components/Divider.svelte.d.ts +27 -0
- package/dist/components/Dock.svelte +34 -0
- package/dist/components/Dock.svelte.d.ts +18 -0
- package/dist/components/Drawer.svelte +174 -0
- package/dist/components/Drawer.svelte.d.ts +51 -0
- package/dist/components/Dropdown.svelte +183 -0
- package/dist/components/Dropdown.svelte.d.ts +52 -0
- package/dist/components/Editable.svelte +292 -0
- package/dist/components/Editable.svelte.d.ts +113 -0
- package/dist/components/EmptyState.svelte +64 -0
- package/dist/components/EmptyState.svelte.d.ts +29 -0
- package/dist/components/Fieldset.svelte +42 -0
- package/dist/components/Fieldset.svelte.d.ts +20 -0
- package/dist/components/FileDropzone.svelte +154 -0
- package/dist/components/FileDropzone.svelte.d.ts +45 -0
- package/dist/components/FileExplorer.svelte +643 -0
- package/dist/components/FileExplorer.svelte.d.ts +114 -0
- package/dist/components/FileInput.svelte +125 -0
- package/dist/components/FileInput.svelte.d.ts +51 -0
- package/dist/components/FloatingLabel.svelte +38 -0
- package/dist/components/FloatingLabel.svelte.d.ts +24 -0
- package/dist/components/Footer.svelte +68 -0
- package/dist/components/Footer.svelte.d.ts +37 -0
- package/dist/components/Grid.svelte +122 -0
- package/dist/components/Grid.svelte.d.ts +72 -0
- package/dist/components/Hero.svelte +62 -0
- package/dist/components/Hero.svelte.d.ts +33 -0
- package/dist/components/Input.svelte +184 -0
- package/dist/components/Input.svelte.d.ts +65 -0
- package/dist/components/Join.svelte +38 -0
- package/dist/components/Join.svelte.d.ts +21 -0
- package/dist/components/Kanban.svelte +284 -0
- package/dist/components/Kanban.svelte.d.ts +93 -0
- package/dist/components/Label.svelte +32 -0
- package/dist/components/Label.svelte.d.ts +21 -0
- package/dist/components/LaptopFrame.svelte +44 -0
- package/dist/components/LaptopFrame.svelte.d.ts +21 -0
- package/dist/components/List.svelte +95 -0
- package/dist/components/List.svelte.d.ts +69 -0
- package/dist/components/Loading.svelte +37 -0
- package/dist/components/Loading.svelte.d.ts +17 -0
- package/dist/components/Menu.svelte +144 -0
- package/dist/components/Menu.svelte.d.ts +53 -0
- package/dist/components/MobileFrame.svelte +41 -0
- package/dist/components/MobileFrame.svelte.d.ts +21 -0
- package/dist/components/Navbar.svelte +49 -0
- package/dist/components/Navbar.svelte.d.ts +25 -0
- package/dist/components/NumberInput.svelte +255 -0
- package/dist/components/NumberInput.svelte.d.ts +68 -0
- package/dist/components/Pagination.svelte +169 -0
- package/dist/components/Pagination.svelte.d.ts +50 -0
- package/dist/components/Progress.svelte +65 -0
- package/dist/components/Progress.svelte.d.ts +28 -0
- package/dist/components/RadialProgress.svelte +48 -0
- package/dist/components/RadialProgress.svelte.d.ts +20 -0
- package/dist/components/Radio.svelte +50 -0
- package/dist/components/Radio.svelte.d.ts +28 -0
- package/dist/components/Range.svelte +53 -0
- package/dist/components/Range.svelte.d.ts +26 -0
- package/dist/components/Rating.svelte +90 -0
- package/dist/components/Rating.svelte.d.ts +41 -0
- package/dist/components/Select.svelte +338 -0
- package/dist/components/Select.svelte.d.ts +74 -0
- package/dist/components/Sidebar.svelte +100 -0
- package/dist/components/Sidebar.svelte.d.ts +54 -0
- package/dist/components/Skeleton.svelte +40 -0
- package/dist/components/Skeleton.svelte.d.ts +18 -0
- package/dist/components/Stat.svelte +71 -0
- package/dist/components/Stat.svelte.d.ts +35 -0
- package/dist/components/Stats.svelte +38 -0
- package/dist/components/Stats.svelte.d.ts +22 -0
- package/dist/components/Steps.svelte +204 -0
- package/dist/components/Steps.svelte.d.ts +66 -0
- package/dist/components/Subtitle.svelte +44 -0
- package/dist/components/Subtitle.svelte.d.ts +26 -0
- package/dist/components/Swatch.svelte +61 -0
- package/dist/components/Swatch.svelte.d.ts +27 -0
- package/dist/components/Switch.svelte +105 -0
- package/dist/components/Switch.svelte.d.ts +44 -0
- package/dist/components/Table.svelte +243 -0
- package/dist/components/Table.svelte.d.ts +121 -0
- package/dist/components/Tabs.svelte +142 -0
- package/dist/components/Tabs.svelte.d.ts +80 -0
- package/dist/components/Text.svelte +43 -0
- package/dist/components/Text.svelte.d.ts +25 -0
- package/dist/components/Textarea.svelte +76 -0
- package/dist/components/Textarea.svelte.d.ts +39 -0
- package/dist/components/Title.svelte +46 -0
- package/dist/components/Title.svelte.d.ts +29 -0
- package/dist/components/Toast.svelte +154 -0
- package/dist/components/Toast.svelte.d.ts +49 -0
- package/dist/components/Toggle.svelte +48 -0
- package/dist/components/Toggle.svelte.d.ts +25 -0
- package/dist/components/Tooltip.svelte +70 -0
- package/dist/components/Tooltip.svelte.d.ts +34 -0
- package/dist/components/WindowFrame.svelte +53 -0
- package/dist/components/WindowFrame.svelte.d.ts +24 -0
- package/dist/components/accordion-context.d.ts +8 -0
- package/dist/components/accordion-context.js +25 -0
- package/dist/components/color.d.ts +39 -0
- package/dist/components/color.js +92 -0
- package/dist/components/data-handler.svelte.d.ts +362 -0
- package/dist/components/data-handler.svelte.js +690 -0
- package/dist/components/file-icons.d.ts +25 -0
- package/dist/components/file-icons.js +46 -0
- package/dist/family-types.d.ts +45 -0
- package/dist/family-types.js +73 -0
- package/dist/generated/classes.d.ts +17 -0
- package/dist/generated/classes.js +2511 -0
- package/dist/generated/components.d.ts +39 -0
- package/dist/generated/components.js +28666 -0
- package/dist/generated/registry.d.ts +35 -0
- package/dist/generated/registry.js +2658 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.js +99 -0
- package/dist/sepale-types.d.ts +8 -0
- package/dist/sepale-types.js +200 -0
- package/dist/theme.d.ts +123 -0
- package/dist/theme.js +226 -0
- package/dist/variants.d.ts +124 -0
- package/dist/variants.js +70 -0
- package/dist/vendor/air-datepicker/LICENSE.md +21 -0
- package/dist/vendor/air-datepicker/README.md +19 -0
- package/dist/vendor/air-datepicker/buttonPresets.d.ts +13 -0
- package/dist/vendor/air-datepicker/buttonPresets.js +12 -0
- package/dist/vendor/air-datepicker/consts.d.ts +18 -0
- package/dist/vendor/air-datepicker/consts.js +35 -0
- package/dist/vendor/air-datepicker/datepicker.d.ts +289 -0
- package/dist/vendor/air-datepicker/datepicker.js +1435 -0
- package/dist/vendor/air-datepicker/datepickerBody.d.ts +46 -0
- package/dist/vendor/air-datepicker/datepickerBody.js +386 -0
- package/dist/vendor/air-datepicker/datepickerButtons.d.ts +25 -0
- package/dist/vendor/air-datepicker/datepickerButtons.js +85 -0
- package/dist/vendor/air-datepicker/datepickerCell.d.ts +35 -0
- package/dist/vendor/air-datepicker/datepickerCell.js +297 -0
- package/dist/vendor/air-datepicker/datepickerKeyboard.d.ts +26 -0
- package/dist/vendor/air-datepicker/datepickerKeyboard.js +207 -0
- package/dist/vendor/air-datepicker/datepickerNav.d.ts +31 -0
- package/dist/vendor/air-datepicker/datepickerNav.js +200 -0
- package/dist/vendor/air-datepicker/datepickerTime.d.ts +60 -0
- package/dist/vendor/air-datepicker/datepickerTime.js +276 -0
- package/dist/vendor/air-datepicker/defaults.d.ts +65 -0
- package/dist/vendor/air-datepicker/defaults.js +79 -0
- package/dist/vendor/air-datepicker/index.d.ts +168 -0
- package/dist/vendor/air-datepicker/index.js +3 -0
- package/dist/vendor/air-datepicker/locale/ar.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/ar.js +14 -0
- package/dist/vendor/air-datepicker/locale/bg.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/bg.js +14 -0
- package/dist/vendor/air-datepicker/locale/ca.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/ca.js +14 -0
- package/dist/vendor/air-datepicker/locale/cs.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/cs.js +14 -0
- package/dist/vendor/air-datepicker/locale/da.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/da.js +14 -0
- package/dist/vendor/air-datepicker/locale/de.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/de.js +14 -0
- package/dist/vendor/air-datepicker/locale/el.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/el.js +14 -0
- package/dist/vendor/air-datepicker/locale/en.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/en.js +14 -0
- package/dist/vendor/air-datepicker/locale/es.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/es.js +14 -0
- package/dist/vendor/air-datepicker/locale/eu.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/eu.js +14 -0
- package/dist/vendor/air-datepicker/locale/fi.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/fi.js +14 -0
- package/dist/vendor/air-datepicker/locale/fr.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/fr.js +14 -0
- package/dist/vendor/air-datepicker/locale/hr.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/hr.js +14 -0
- package/dist/vendor/air-datepicker/locale/hu.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/hu.js +14 -0
- package/dist/vendor/air-datepicker/locale/id.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/id.js +14 -0
- package/dist/vendor/air-datepicker/locale/it.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/it.js +14 -0
- package/dist/vendor/air-datepicker/locale/ja.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/ja.js +14 -0
- package/dist/vendor/air-datepicker/locale/ko.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/ko.js +14 -0
- package/dist/vendor/air-datepicker/locale/nb.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/nb.js +14 -0
- package/dist/vendor/air-datepicker/locale/nl.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/nl.js +14 -0
- package/dist/vendor/air-datepicker/locale/pl.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/pl.js +14 -0
- package/dist/vendor/air-datepicker/locale/pt-BR.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/pt-BR.js +14 -0
- package/dist/vendor/air-datepicker/locale/pt.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/pt.js +14 -0
- package/dist/vendor/air-datepicker/locale/ro.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/ro.js +14 -0
- package/dist/vendor/air-datepicker/locale/ru.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/ru.js +14 -0
- package/dist/vendor/air-datepicker/locale/si.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/si.js +14 -0
- package/dist/vendor/air-datepicker/locale/sk.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/sk.js +14 -0
- package/dist/vendor/air-datepicker/locale/sl.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/sl.js +14 -0
- package/dist/vendor/air-datepicker/locale/sv.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/sv.js +14 -0
- package/dist/vendor/air-datepicker/locale/th.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/th.js +14 -0
- package/dist/vendor/air-datepicker/locale/tr.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/tr.js +16 -0
- package/dist/vendor/air-datepicker/locale/uk.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/uk.js +14 -0
- package/dist/vendor/air-datepicker/locale/zh.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/zh.js +14 -0
- package/dist/vendor/air-datepicker/typedefs.d.ts +3 -0
- package/dist/vendor/air-datepicker/typedefs.js +15 -0
- package/dist/vendor/air-datepicker/utils.d.ts +155 -0
- package/dist/vendor/air-datepicker/utils.js +395 -0
- package/dist/vendor/air-datepicker/withEvents.d.ts +1 -0
- package/dist/vendor/air-datepicker/withEvents.js +39 -0
- package/package.json +44 -3
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
// @ts-nocheck — vendored code, typed by index.d.ts; not ours to check.
|
|
2
|
+
// air-datepicker 3.6.0 (MIT, Timofey Marochkin) — see LICENSE.md and README.md.
|
|
3
|
+
/**
|
|
4
|
+
* Finds DOM element
|
|
5
|
+
* @param {HTMLElement, String} el
|
|
6
|
+
* @param {Document|HTMLElement} [context=document]
|
|
7
|
+
*/
|
|
8
|
+
import consts from './consts.js';
|
|
9
|
+
|
|
10
|
+
export function getEl(el, context = document) {
|
|
11
|
+
return typeof el === 'string'
|
|
12
|
+
? context['querySelector'](el)
|
|
13
|
+
: el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Creates HTML DOM element
|
|
18
|
+
* @param {String} [tagName] - element's tag name
|
|
19
|
+
* @param {String} [className]
|
|
20
|
+
* @param {String} [innerHtml]
|
|
21
|
+
* @param {String} [id]
|
|
22
|
+
* @param {Object} [attrs]
|
|
23
|
+
* @returns {HTMLElement}
|
|
24
|
+
*/
|
|
25
|
+
export function createElement({tagName = 'div', className = '', innerHtml = '', id = '', attrs = {}} = {}) {
|
|
26
|
+
let $element = document.createElement(tagName);
|
|
27
|
+
if (className) $element.classList.add(...className.split(' '));
|
|
28
|
+
if (id) $element.id = id;
|
|
29
|
+
|
|
30
|
+
if (innerHtml) {
|
|
31
|
+
$element.innerHTML = innerHtml;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (attrs) {
|
|
35
|
+
setAttribute($element, attrs);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return $element;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Sets multiple attributes of element
|
|
43
|
+
* @param {HTMLElement} el
|
|
44
|
+
* @param {Object} attrs - attributes object
|
|
45
|
+
* @returns {HTMLElement}
|
|
46
|
+
*/
|
|
47
|
+
export function setAttribute(el, attrs) {
|
|
48
|
+
for (let [name, value] of Object.entries(attrs)) {
|
|
49
|
+
if (value === undefined) continue;
|
|
50
|
+
|
|
51
|
+
el.setAttribute(name, value);
|
|
52
|
+
}
|
|
53
|
+
return el;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Inserts newElement after targetElement
|
|
58
|
+
* @param {HTMLElement} newElement - element to be inserted
|
|
59
|
+
* @param {HTMLElement} targetElement - after which must be inserted
|
|
60
|
+
* @return {HTMLElement} newElement
|
|
61
|
+
*/
|
|
62
|
+
export function insertAfter(newElement, targetElement) {
|
|
63
|
+
targetElement.parentNode
|
|
64
|
+
.insertBefore(newElement, targetElement.nextSibling);
|
|
65
|
+
return newElement;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Makes object deep copy
|
|
70
|
+
* @param {Object} obj
|
|
71
|
+
* @return {Object}
|
|
72
|
+
*/
|
|
73
|
+
export function deepCopy(obj) {
|
|
74
|
+
return JSON.parse(JSON.stringify(obj));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Calculates amount of days in passed date
|
|
79
|
+
* @param {Date} date
|
|
80
|
+
* @return {number}
|
|
81
|
+
*/
|
|
82
|
+
export function getDaysCount(date) {
|
|
83
|
+
return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get detailed date object
|
|
88
|
+
* @param {Date} date
|
|
89
|
+
* @return {{
|
|
90
|
+
* date: number,
|
|
91
|
+
* hours: number,
|
|
92
|
+
* fullDate: (string|*),
|
|
93
|
+
* month: number,
|
|
94
|
+
* fullHours: (string|*),
|
|
95
|
+
* year: number,
|
|
96
|
+
* minutes: number,
|
|
97
|
+
* fullMonth: string,
|
|
98
|
+
* day: number,
|
|
99
|
+
* fullMinutes: (string|*),
|
|
100
|
+
* hours12: number,
|
|
101
|
+
* dayPeriod: 'am' | 'pm'
|
|
102
|
+
* }}
|
|
103
|
+
*/
|
|
104
|
+
export function getParsedDate(date) {
|
|
105
|
+
let hours = date.getHours(),
|
|
106
|
+
{hours: hours12, dayPeriod} = getDayPeriodFromHours24(hours);
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
year: date.getFullYear(),
|
|
110
|
+
month: date.getMonth(),
|
|
111
|
+
fullMonth: (date.getMonth() + 1) < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1, // One based
|
|
112
|
+
date: date.getDate(),
|
|
113
|
+
fullDate: date.getDate() < 10 ? '0' + date.getDate() : date.getDate(),
|
|
114
|
+
day: date.getDay(),
|
|
115
|
+
hours,
|
|
116
|
+
fullHours: getLeadingZeroNum(hours),
|
|
117
|
+
hours12,
|
|
118
|
+
dayPeriod,
|
|
119
|
+
fullHours12: getLeadingZeroNum(hours12),
|
|
120
|
+
minutes: date.getMinutes(),
|
|
121
|
+
fullMinutes: date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function getDayPeriodFromHours24(hours) {
|
|
126
|
+
let hours12 = hours % 12 === 0 ? 12 : hours % 12;
|
|
127
|
+
let dayPeriod = hours > 11 ? 'pm' : 'am';
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
dayPeriod,
|
|
131
|
+
hours: hours12
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Converts 1 -> 01
|
|
137
|
+
* @param {Number} num
|
|
138
|
+
* @return {String|Number}
|
|
139
|
+
*/
|
|
140
|
+
export function getLeadingZeroNum(num) {
|
|
141
|
+
return num < 10 ? '0' + num : num;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Calculates current decade
|
|
146
|
+
* @param {Date} date
|
|
147
|
+
* @return {number[]} - array of two years, decade start - decade end
|
|
148
|
+
*/
|
|
149
|
+
export function getDecade(date) {
|
|
150
|
+
let firstYear = Math.floor(date.getFullYear() / 10) * 10;
|
|
151
|
+
return [firstYear, firstYear + 9];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Subtract days from date
|
|
156
|
+
* @param {Date} date
|
|
157
|
+
* @param {Number} days
|
|
158
|
+
* @return {Date}
|
|
159
|
+
*/
|
|
160
|
+
export function subDays(date, days) {
|
|
161
|
+
let {year, month, date: _date} = getParsedDate(date);
|
|
162
|
+
return new Date(year, month, _date - days);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Class names' handler, inspired by https://github.com/JedWatson/classnames but very simplified
|
|
167
|
+
* @param {String|Object} classes - class names, could contain strings or object
|
|
168
|
+
*/
|
|
169
|
+
export function classNames(...classes) {
|
|
170
|
+
let classNames = [];
|
|
171
|
+
|
|
172
|
+
classes.forEach((c) => {
|
|
173
|
+
if (typeof c === 'object') {
|
|
174
|
+
for (let cName in c) {
|
|
175
|
+
if (c[cName]) {
|
|
176
|
+
classNames.push(cName);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
} else if (c) {
|
|
180
|
+
classNames.push(c);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
return classNames.join(' ');
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function toggleClass(el, classes) {
|
|
187
|
+
for (let className in classes) {
|
|
188
|
+
if (classes[className]) {
|
|
189
|
+
el.classList.add(className);
|
|
190
|
+
} else {
|
|
191
|
+
el.classList.remove(className);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export function addClass(el, ...classes) {
|
|
197
|
+
if (el.length) {
|
|
198
|
+
el.forEach((node) => {
|
|
199
|
+
node.classList.add(...classes);
|
|
200
|
+
});
|
|
201
|
+
} else {
|
|
202
|
+
el.classList.add(...classes);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function removeClass(el, ...classes) {
|
|
207
|
+
if (el.length) {
|
|
208
|
+
el.forEach((node) => {
|
|
209
|
+
node.classList.remove(...classes);
|
|
210
|
+
});
|
|
211
|
+
} else {
|
|
212
|
+
el.classList.remove(...classes);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Checks if passed dates are the same
|
|
218
|
+
* @param {Date} date1
|
|
219
|
+
* @param {Date} date2
|
|
220
|
+
* @param {String} cellType - one of days|months|years
|
|
221
|
+
* @return {boolean}
|
|
222
|
+
*/
|
|
223
|
+
export function isSameDate(date1, date2, cellType = consts.days) {
|
|
224
|
+
if (!date1 || !date2) return false;
|
|
225
|
+
let d1 = getParsedDate(date1),
|
|
226
|
+
d2 = getParsedDate(date2),
|
|
227
|
+
|
|
228
|
+
conditions = {
|
|
229
|
+
[consts.days]: d1.date === d2.date && d1.month === d2.month && d1.year === d2.year,
|
|
230
|
+
[consts.months]: d1.month === d2.month && d1.year === d2.year,
|
|
231
|
+
[consts.years]: d1.year === d2.year
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
return conditions[cellType];
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export function isDateBigger(date, comparedDate, loose) {
|
|
238
|
+
let d1 = copyDate(date, false).getTime(),
|
|
239
|
+
d2 = copyDate(comparedDate, false).getTime();
|
|
240
|
+
|
|
241
|
+
return loose
|
|
242
|
+
? d1 >= d2
|
|
243
|
+
: d1 > d2;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function isDateSmaller(date, comparedDate) {
|
|
247
|
+
return !isDateBigger(date, comparedDate, true);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Copies date
|
|
252
|
+
* @param {Date} date
|
|
253
|
+
* @param {Boolean} [keepTime] - should keep the time in a new date or not
|
|
254
|
+
* @return {Date}
|
|
255
|
+
*/
|
|
256
|
+
export function copyDate(date, keepTime = true) {
|
|
257
|
+
let newDate = new Date(date.getTime());
|
|
258
|
+
|
|
259
|
+
if (typeof keepTime === 'boolean' && !keepTime) {
|
|
260
|
+
resetTime(newDate);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return newDate;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export function resetTime(date) {
|
|
267
|
+
date.setHours(0, 0, 0, 0);
|
|
268
|
+
return date;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export function isDateBetween(date, dateFrom, dateTo) {
|
|
272
|
+
return isDateBigger(date, dateFrom) && isDateSmaller(date, dateTo);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Adds event listener to DOM element
|
|
277
|
+
* @param {HTMLElement|HTMLCollection} el
|
|
278
|
+
* @param {String} type
|
|
279
|
+
* @param {Function} listener
|
|
280
|
+
*/
|
|
281
|
+
export function addEventListener(el, type, listener) {
|
|
282
|
+
if (el.length) {
|
|
283
|
+
el.forEach((e) => {
|
|
284
|
+
e.addEventListener(type, listener);
|
|
285
|
+
});
|
|
286
|
+
} else {
|
|
287
|
+
el.addEventListener(type, listener);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Finds closest DOM element to passed target. Similar to jQuery.closest()
|
|
293
|
+
* @param {HTMLElement} target
|
|
294
|
+
* @param {String} selector
|
|
295
|
+
* @return {HTMLElement|Boolean}
|
|
296
|
+
*/
|
|
297
|
+
export function closest(target, selector) {
|
|
298
|
+
if (!target || target === document || target instanceof DocumentFragment) return false;
|
|
299
|
+
|
|
300
|
+
if (target.matches(selector)) {
|
|
301
|
+
return target;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return closest(target.parentNode, selector);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Clamps number between min and max
|
|
309
|
+
* @param {Number} val
|
|
310
|
+
* @param {Number} min
|
|
311
|
+
* @param {Number} max
|
|
312
|
+
* @return {Number}
|
|
313
|
+
*/
|
|
314
|
+
export function clamp(val, min, max,) {
|
|
315
|
+
return val > max
|
|
316
|
+
? max
|
|
317
|
+
: val < min
|
|
318
|
+
? min
|
|
319
|
+
: val;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Deep merge of objects or arrays, used to merge options
|
|
324
|
+
* @param {object|array} target - target object or array
|
|
325
|
+
* @param {object|array} objects - source objects
|
|
326
|
+
* @return {object|array}
|
|
327
|
+
*/
|
|
328
|
+
export function deepMerge(target, ...objects) {
|
|
329
|
+
objects.filter(o => o).forEach((obj) => {
|
|
330
|
+
for (let [key, value] of Object.entries(obj)) {
|
|
331
|
+
let arrayOrObject = value !== undefined ? value.toString() === ('[object Object]' || '[object Array]') : false;
|
|
332
|
+
|
|
333
|
+
if (arrayOrObject) {
|
|
334
|
+
let targetType = target[key] !== undefined ? target[key].toString() : undefined,
|
|
335
|
+
sourceType = value.toString(),
|
|
336
|
+
initialValue = Array.isArray(value) ? [] : {};
|
|
337
|
+
|
|
338
|
+
// If target and source types are different, e.g. we try to merge number with object,
|
|
339
|
+
// then take source type
|
|
340
|
+
target[key] = target[key]
|
|
341
|
+
? targetType !== sourceType
|
|
342
|
+
? initialValue
|
|
343
|
+
: target[key]
|
|
344
|
+
: initialValue;
|
|
345
|
+
|
|
346
|
+
deepMerge(target[key], value);
|
|
347
|
+
} else {
|
|
348
|
+
target[key] = value;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
return target;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Checks if ISO date string consists only of numbers
|
|
358
|
+
* @param {string} dateString
|
|
359
|
+
* @returns {boolean}
|
|
360
|
+
*/
|
|
361
|
+
function dateStringIsDateOnly(dateString) {
|
|
362
|
+
return /^\d{4}-\d{2}-\d{2}$/.test(dateString);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Creates Date object from string or number. If passed param is instance of Date, then just returns it.
|
|
367
|
+
* @param {number|string|Date} date
|
|
368
|
+
* @return {Date | boolean}
|
|
369
|
+
*/
|
|
370
|
+
export function createDate(date) {
|
|
371
|
+
let resultDate = date;
|
|
372
|
+
|
|
373
|
+
if (!(date instanceof Date)) {
|
|
374
|
+
// If string is date-only string, we should add time to it
|
|
375
|
+
// so created date will be in a local time
|
|
376
|
+
// https://github.com/t1m0n/air-datepicker/issues/589
|
|
377
|
+
if (typeof date === 'string' && dateStringIsDateOnly(date)) {
|
|
378
|
+
date += 'T00:00:00';
|
|
379
|
+
}
|
|
380
|
+
resultDate = new Date(date);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (isNaN(resultDate.getTime())) {
|
|
384
|
+
console.log(`Unable to convert value "${date}" to Date object`);
|
|
385
|
+
resultDate = false;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
return resultDate;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
export function getWordBoundaryRegExp(sign) {
|
|
392
|
+
let symbols = '\\s|\\.|-|/|\\\\|,|\\$|\\!|\\?|:|;';
|
|
393
|
+
|
|
394
|
+
return new RegExp('(^|>|' + symbols + ')(' + sign + ')($|<|' + symbols + ')', 'g');
|
|
395
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function _default(target: any): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// @ts-nocheck — vendored code, typed by index.d.ts; not ours to check.
|
|
2
|
+
// air-datepicker 3.6.0 (MIT, Timofey Marochkin) — see LICENSE.md and README.md.
|
|
3
|
+
let events = {
|
|
4
|
+
on(eventName, handler) {
|
|
5
|
+
if (!this.__events) {
|
|
6
|
+
this.__events = {};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (!this.__events[eventName]) {
|
|
10
|
+
this.__events[eventName] = [handler];
|
|
11
|
+
} else {
|
|
12
|
+
this.__events[eventName].push(handler);
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
off(eventName, handler) {
|
|
17
|
+
if (!this.__events) return;
|
|
18
|
+
if (!this.__events[eventName]) return;
|
|
19
|
+
|
|
20
|
+
this.__events[eventName] = this.__events[eventName].filter(h => h !== handler);
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
removeAllEvents() {
|
|
24
|
+
this.__events = {};
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
trigger(eventName, ...args) {
|
|
28
|
+
if (!this.__events) return;
|
|
29
|
+
if (!this.__events[eventName]) return;
|
|
30
|
+
|
|
31
|
+
this.__events[eventName].forEach((handler) => {
|
|
32
|
+
handler(...args);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default function (target) {
|
|
38
|
+
Object.assign(target, events);
|
|
39
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sepale/components",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Sepale's Svelte components, typed by the family stylesheet you import.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"svelte": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"sepale-types": "./dist/sepale-types.js"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"svelte": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"!dist/**/*.test.*"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@sepale/style": "^0.1.0",
|
|
24
|
+
"svelte": "^5.0.0"
|
|
25
|
+
},
|
|
26
|
+
"peerDependenciesMeta": {
|
|
27
|
+
"@sepale/style": {
|
|
28
|
+
"optional": true
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@sepale/style": "^0.1.0"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/Tyrenn/sepale.git",
|
|
40
|
+
"directory": "packages/components"
|
|
41
|
+
},
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/Tyrenn/sepale/issues"
|
|
44
|
+
},
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"scripts": {}
|
|
6
47
|
}
|