@appartmint/mint 1.2.11 → 1.3.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/dist/css/mint.css +4 -0
- package/dist/css/mint.css.map +1 -1
- package/dist/css/mint.min.css +1 -1
- package/dist/css/mint.min.css.map +1 -1
- package/dist/js/index.js +2 -2
- package/dist/js/index.js.map +1 -1
- package/dist/js/index.min.js +1 -1
- package/dist/js/index.min.js.map +1 -1
- package/package.json +4 -3
- package/src/scss/imports/_index.scss +0 -10
- package/src/scss/imports/components/_backgrounds.scss +0 -38
- package/src/scss/imports/components/_buttons.scss +0 -243
- package/src/scss/imports/components/_cards.scss +0 -259
- package/src/scss/imports/components/_embed.scss +0 -75
- package/src/scss/imports/components/_footer.scss +0 -134
- package/src/scss/imports/components/_header.scss +0 -512
- package/src/scss/imports/components/_image.scss +0 -37
- package/src/scss/imports/components/_index.scss +0 -16
- package/src/scss/imports/components/_recaptcha.scss +0 -17
- package/src/scss/imports/components/_tables.scss +0 -29
- package/src/scss/imports/global/_animations.scss +0 -79
- package/src/scss/imports/global/_aspect.scss +0 -54
- package/src/scss/imports/global/_flex.scss +0 -7
- package/src/scss/imports/global/_global.scss +0 -208
- package/src/scss/imports/global/_grid.scss +0 -153
- package/src/scss/imports/global/_icons.scss +0 -6
- package/src/scss/imports/global/_index.scss +0 -12
- package/src/scss/imports/global/_inputs.scss +0 -135
- package/src/scss/imports/global/_structure.scss +0 -83
- package/src/scss/imports/global/_text.scss +0 -62
- package/src/scss/imports/global/_texture.scss +0 -124
- package/src/scss/imports/global/_themes.scss +0 -174
- package/src/scss/imports/overrides/_amplify.scss +0 -48
- package/src/scss/imports/overrides/_full-calendar.scss +0 -46
- package/src/scss/imports/overrides/_index.scss +0 -11
- package/src/scss/imports/overrides/_material.scss +0 -24
- package/src/scss/imports/overrides/_swiper.scss +0 -55
- package/src/scss/imports/util/_index.scss +0 -9
- package/src/scss/imports/util/_util.scss +0 -1034
- package/src/scss/imports/util/_vars.scss +0 -262
- package/src/scss/mint.scss +0 -7
- package/src/scss/noscript.scss +0 -14
- package/src/ts/imports/components/header.ts +0 -408
- package/src/ts/imports/components/index.ts +0 -4
- package/src/ts/imports/enums/index.ts +0 -4
- package/src/ts/imports/enums/side.ts +0 -9
- package/src/ts/imports/index.ts +0 -7
- package/src/ts/imports/models/color.ts +0 -96
- package/src/ts/imports/models/file.ts +0 -16
- package/src/ts/imports/models/index.ts +0 -9
- package/src/ts/imports/models/item.ts +0 -72
- package/src/ts/imports/models/minify.ts +0 -11
- package/src/ts/imports/models/page.ts +0 -19
- package/src/ts/imports/models/recaptcha.ts +0 -8
- package/src/ts/imports/util/async.ts +0 -12
- package/src/ts/imports/util/display.ts +0 -72
- package/src/ts/imports/util/event.ts +0 -93
- package/src/ts/imports/util/icon.ts +0 -67
- package/src/ts/imports/util/index.ts +0 -15
- package/src/ts/imports/util/list.ts +0 -39
- package/src/ts/imports/util/math.ts +0 -17
- package/src/ts/imports/util/object.ts +0 -234
- package/src/ts/imports/util/scroll.ts +0 -53
- package/src/ts/imports/util/selectors.ts +0 -185
- package/src/ts/imports/util/settings.ts +0 -85
- package/src/ts/imports/util/text.ts +0 -151
- package/src/ts/imports/util/window.ts +0 -14
- package/src/ts/index.ts +0 -10
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Object functions for the util library
|
|
3
|
-
*/
|
|
4
|
-
export abstract class MintObject {
|
|
5
|
-
/**
|
|
6
|
-
* Returns true if the provided objects have the same entries
|
|
7
|
-
*/
|
|
8
|
-
static isSimilar (obj1: any, obj2: any) : boolean {
|
|
9
|
-
let keys: string[] = Object.keys(obj1);
|
|
10
|
-
if (keys.length !== Object.keys(obj2).length) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
let isSimilar: boolean = true;
|
|
14
|
-
keys.forEach((key: string) => {
|
|
15
|
-
if (obj1[key] !== obj2[key]) {
|
|
16
|
-
isSimilar = false;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
return isSimilar;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Returns true if the first object has at least the same
|
|
24
|
-
* entries as the second object
|
|
25
|
-
* @param superset - the object to check
|
|
26
|
-
* @param subset - the object whose entries are required
|
|
27
|
-
* @returns - true if the first object is a superset of the second
|
|
28
|
-
* @recursive
|
|
29
|
-
*/
|
|
30
|
-
static isSuperset (superset: any, subset: any) : boolean {
|
|
31
|
-
let isSuperset: boolean = true;
|
|
32
|
-
|
|
33
|
-
// Base case - if the objects are equal, it is a superset
|
|
34
|
-
if (superset === subset) {
|
|
35
|
-
return isSuperset;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// If the subset isn't an object or array, and doesn't
|
|
39
|
-
// satisfy the base case, it isn't a superset
|
|
40
|
-
try {
|
|
41
|
-
if (Object.keys(subset).length === 0) {
|
|
42
|
-
return !isSuperset;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
// If the subset is null or undefined, and doesn't satisfy
|
|
46
|
-
// the base case, it isn't a superset
|
|
47
|
-
// TODO: Check if other exceptions could occur
|
|
48
|
-
catch (e) {
|
|
49
|
-
return !isSuperset;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// If the children of the subset are subsets of the
|
|
53
|
-
// respective children of the superset, it is a superset
|
|
54
|
-
Object.keys(subset).forEach((key: string) => {
|
|
55
|
-
isSuperset = isSuperset && MintObject.isSuperset(superset[key], subset[key]);
|
|
56
|
-
});
|
|
57
|
-
return isSuperset;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Removes object entries by key
|
|
62
|
-
* @alias mintObject.removeKeys
|
|
63
|
-
* @param object - the object to remove entries from
|
|
64
|
-
* @param keys - the keys to remove
|
|
65
|
-
*/
|
|
66
|
-
static remove (object: any, keys: string[]) : Object {
|
|
67
|
-
return this.removeKeys(object, keys);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Removes object entries by key
|
|
72
|
-
* @param object - the object to remove entries from
|
|
73
|
-
* @param keys - the keys to remove
|
|
74
|
-
*/
|
|
75
|
-
static removeKeys (object: any, keys: string[]) : any {
|
|
76
|
-
return Object.keys(object).reduce((obj: any, key: string) => {
|
|
77
|
-
if (!keys.includes(key)) {
|
|
78
|
-
obj[key] = object[key];
|
|
79
|
-
}
|
|
80
|
-
return obj;
|
|
81
|
-
}, {});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Removes object entries by value
|
|
86
|
-
*/
|
|
87
|
-
static removeValues (object: any, values: any[]) : any {
|
|
88
|
-
return Object.keys(object).reduce((obj: any, key: string) => {
|
|
89
|
-
if (!values.includes(object[key])) {
|
|
90
|
-
obj[key] = object[key];
|
|
91
|
-
}
|
|
92
|
-
return obj;
|
|
93
|
-
}, {});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Sorts an object's entries alphabetically by key
|
|
98
|
-
*/
|
|
99
|
-
static sort (object: any, compareFn?: (a: string, b: string) => number) : any {
|
|
100
|
-
return this.sortKeys(object, compareFn);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Sorts an object's entries alphabetically by key
|
|
105
|
-
*/
|
|
106
|
-
static sortKeys (object: any, compareFn?: (a: string, b: string) => number) : any {
|
|
107
|
-
return Object.keys(object).sort(compareFn).reduce((obj: any, key: string) => {
|
|
108
|
-
obj[key] = object[key];
|
|
109
|
-
return obj;
|
|
110
|
-
}, {});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Sorts an object's entries alphabetically by value
|
|
115
|
-
*/
|
|
116
|
-
static sortValues (object: any, compareFn: (a: any, b: any) => number) : any {
|
|
117
|
-
return Object.keys(object).sort((a: string, b: string) => compareFn(object[a], object[b])).reduce((obj: any, key: string) => {
|
|
118
|
-
obj[key] = object[key];
|
|
119
|
-
return obj;
|
|
120
|
-
}, {});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* @alias mintObject.filterKeys
|
|
125
|
-
*/
|
|
126
|
-
static filter (object: any, keys: string[]) : Object {
|
|
127
|
-
return this.filterKeys(object, keys);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Filters an object by its keys
|
|
132
|
-
* @param object - the object to filter
|
|
133
|
-
* @param keys - the keys to keep
|
|
134
|
-
* @returns - the filtered object
|
|
135
|
-
*/
|
|
136
|
-
static filterKeys (object: any, keys: string[]) : Object {
|
|
137
|
-
return keys.reduce((obj: any, key: string) => {
|
|
138
|
-
obj[key] = object[key];
|
|
139
|
-
return obj;
|
|
140
|
-
}, {});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Filters an object by its values
|
|
145
|
-
* @param object - the object to filter
|
|
146
|
-
* @param values - the values to keep
|
|
147
|
-
* @returns - the filtered object
|
|
148
|
-
*/
|
|
149
|
-
static filterValues (object: any, values: any[]) : Object {
|
|
150
|
-
return Object.keys(object).reduce((obj: any, key: string) => {
|
|
151
|
-
if (values.includes(object[key])) {
|
|
152
|
-
obj[key] = object[key];
|
|
153
|
-
}
|
|
154
|
-
return obj;
|
|
155
|
-
}, {});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Update two sets of objects
|
|
160
|
-
* @param original - the original object
|
|
161
|
-
* @param update - the object to update the original with
|
|
162
|
-
* @returns - the original objects with updated data from the update
|
|
163
|
-
*/
|
|
164
|
-
static updateArray (original: any[], update?: any[], key = 'id') : any {
|
|
165
|
-
|
|
166
|
-
// If there are no originals, push the updates
|
|
167
|
-
if (!update?.length) {
|
|
168
|
-
update?.forEach((object) => original.push(object));
|
|
169
|
-
|
|
170
|
-
// If there are existing objects
|
|
171
|
-
} else {
|
|
172
|
-
|
|
173
|
-
// Create a dictionary of the updated objects
|
|
174
|
-
const updateObjects = update.reduce<{ [key: string]: Object }>((objects, object) => ({
|
|
175
|
-
...objects,
|
|
176
|
-
[object?.[key] ?? '']: object
|
|
177
|
-
}), {});
|
|
178
|
-
|
|
179
|
-
// Remove any objects that aren't in the updated objects
|
|
180
|
-
const missingObjects = original.filter((object) => !updateObjects[object?.[key] ?? '']);
|
|
181
|
-
missingObjects?.forEach((object) => {
|
|
182
|
-
const index = original.indexOf(object);
|
|
183
|
-
if (typeof index == 'number' && index !== -1) {
|
|
184
|
-
original.splice(index, 1);
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
// Update the existing objects with updates
|
|
189
|
-
original.forEach((object) => {
|
|
190
|
-
if (updateObjects[object?.[key] ?? '']) {
|
|
191
|
-
Object.assign(object, updateObjects[object?.[key] ?? '']);
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Push any new objects
|
|
197
|
-
const newObjects = update?.filter((object) => !original.some((existingObject) => existingObject?.[key] === object?.[key]));
|
|
198
|
-
newObjects?.forEach(newObject => original.push(newObject));
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Get an object's key by value
|
|
203
|
-
*/
|
|
204
|
-
static getKeyByValue(object: any, value: any): string | undefined {
|
|
205
|
-
return Object.keys(object).find((key) => object[key] === value);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Create a deep copy of an object
|
|
210
|
-
* @recursive
|
|
211
|
-
*/
|
|
212
|
-
static deepClone(object: any): any {
|
|
213
|
-
|
|
214
|
-
// Clone every property
|
|
215
|
-
const clone: any = {};
|
|
216
|
-
for (const key in object) {
|
|
217
|
-
|
|
218
|
-
// Functions
|
|
219
|
-
if (typeof object[key] === 'function') {
|
|
220
|
-
clone[key] = object[key].bind(clone);
|
|
221
|
-
|
|
222
|
-
// Objects
|
|
223
|
-
} else if (object[key] && typeof object[key] === 'object') {
|
|
224
|
-
clone[key] = this.deepClone(object[key]);
|
|
225
|
-
|
|
226
|
-
// Primitives
|
|
227
|
-
} else {
|
|
228
|
-
clone[key] = object[key];
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return clone;
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
export default MintObject;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Imports
|
|
3
|
-
*/
|
|
4
|
-
import MintEvent from './event';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Scroll functions
|
|
8
|
-
*/
|
|
9
|
-
export abstract class MintScroll {
|
|
10
|
-
/**
|
|
11
|
-
* Scroll to the top of the page
|
|
12
|
-
*/
|
|
13
|
-
static toTop(): void {
|
|
14
|
-
window.scrollTo(0, 0);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Scroll to the bottom of the page
|
|
19
|
-
*/
|
|
20
|
-
static toBottom(): void {
|
|
21
|
-
window.scrollTo(0, document.body.scrollHeight);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Show visible elements
|
|
26
|
-
*/
|
|
27
|
-
static showElements(): void {
|
|
28
|
-
requestAnimationFrame(() => {
|
|
29
|
-
let elements = document.querySelectorAll('.mint-fall-in:not(.mint-show)'),
|
|
30
|
-
elementsToShow: Element[] = [];
|
|
31
|
-
for (let i = 0; i < elements.length; i++) {
|
|
32
|
-
if (elements[i].getBoundingClientRect().top < 0) {
|
|
33
|
-
elements[i].classList.add('mint-show');
|
|
34
|
-
} else if (elements[i].getBoundingClientRect().top < window.innerHeight * 3 / 4) {
|
|
35
|
-
elementsToShow.push(elements[i]);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
for (let i = 0; i < elementsToShow.length; i++) {
|
|
39
|
-
setTimeout(() => {
|
|
40
|
-
elementsToShow[i].classList.add('mint-show');
|
|
41
|
-
}, i * 200 + i * i * 20);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Show visible elements on scroll
|
|
48
|
-
*/
|
|
49
|
-
static showElementsOnScroll(): void {
|
|
50
|
-
window.addEventListener('scroll', MintEvent.throttleEvent(this.showElements, 200));
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
export default MintScroll;
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CSS-selector helpers
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
|
-
export abstract class MintSelectors {
|
|
6
|
-
/**
|
|
7
|
-
* The library name that will be added as a prefix
|
|
8
|
-
*/
|
|
9
|
-
static lib: string = 'mint';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The prefix built from the library name
|
|
13
|
-
*/
|
|
14
|
-
static pre: string = `${this.lib}-`;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* CSS-selector for disabled elements
|
|
18
|
-
*/
|
|
19
|
-
static disabled: string = '[disabled]';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* CSS-selector for elements with an aria-controls attribute
|
|
23
|
-
*/
|
|
24
|
-
static hasControls: string = '[aria-controls]';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* CSS-selector for elements with an aria-expanded attribute
|
|
28
|
-
*/
|
|
29
|
-
static hasExpanded: string = '[aria-expanded]';
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* CSS-selector for elements with an href attribute
|
|
33
|
-
*/
|
|
34
|
-
static hasLink: string = '[href]';
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* CSS-selector for elements with a routerLink attribute
|
|
38
|
-
*/
|
|
39
|
-
static hasRouterLink: string = '[routerLink]';
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* CSS-selector for elements with an id attribute
|
|
43
|
-
*/
|
|
44
|
-
static hasId: string = '[id]';
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* CSS-selector for elements that aren't tabbable (i.e. tabindex is negative)
|
|
48
|
-
*/
|
|
49
|
-
static notTabbable: string = '[tabindex^="-"]';
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* CSS-selector for elements that are tabbable (i.e. tabindex isn't negative)
|
|
53
|
-
*/
|
|
54
|
-
static tabbable: string = `[tabindex]${this.neg(this.notTabbable)}`;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* CSS-selector for elements that can receive focus
|
|
58
|
-
*/
|
|
59
|
-
static focusable: string = `input${this.neg(this.disabled)}${this.neg(this.notTabbable)},
|
|
60
|
-
select${this.neg(this.disabled)}${this.neg(this.notTabbable)},
|
|
61
|
-
textarea${this.neg(this.disabled)}${this.neg(this.notTabbable)},
|
|
62
|
-
button${this.neg(this.disabled)}${this.neg(this.notTabbable)},
|
|
63
|
-
object${this.neg(this.disabled)}${this.neg(this.notTabbable)},
|
|
64
|
-
a${this.hasLink}, a${this.hasRouterLink},
|
|
65
|
-
area${this.hasLink},
|
|
66
|
-
${this.tabbable}`.replace(/\s/g, '');
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* CSS-selector for submenu buttons
|
|
70
|
-
*/
|
|
71
|
-
static subMenuButtons: string = `button${this.hasControls}`;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* CSS-selector for submenus
|
|
75
|
-
*/
|
|
76
|
-
static subMenu: string = `${this.subMenuButtons} + ul${this.hasId}`;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Adds the library prefix to the beginning of the provided string
|
|
80
|
-
* @param base - the string to be prefixed
|
|
81
|
-
* @returns - the provided string prefixed with the library name
|
|
82
|
-
*/
|
|
83
|
-
static prefix (base: string) : string {
|
|
84
|
-
base = base.toLowerCase();
|
|
85
|
-
return base.startsWith(this.pre) ? base : `${this.pre}${base}`;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Adds two dashes to the beginning of the provided string
|
|
90
|
-
* @param base - the string to be prefixed
|
|
91
|
-
* @returns - the provided string prefixed with two dashes
|
|
92
|
-
*/
|
|
93
|
-
static cssPrefix (base: string) : string {
|
|
94
|
-
return `--${this.prefix(base.replace(/^-+/, ''))}`;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Turns the provided string into a CSS variable call
|
|
99
|
-
* @param base - the name of the CSS variable to call
|
|
100
|
-
* @returns - the CSS variable call for the provided string
|
|
101
|
-
*/
|
|
102
|
-
static cssVar (base: string) : string {
|
|
103
|
-
return `var(${this.cssPrefix(base)})`;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Negates the provided CSS selector
|
|
108
|
-
* @param base - the CSS selector to negate
|
|
109
|
-
* @returns - the negated CSS selector
|
|
110
|
-
*/
|
|
111
|
-
static neg (base: string) : string {
|
|
112
|
-
return `:not(${base})`;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Generates a class CSS selector
|
|
117
|
-
* @param base - the name of the class to generate
|
|
118
|
-
* @returns - the generated CSS selector
|
|
119
|
-
*/
|
|
120
|
-
static class (base: string) : string {
|
|
121
|
-
return `.${this.prefix(base)}`;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Generates an id CSS selector
|
|
126
|
-
* @param base - the name of the id to generate
|
|
127
|
-
* @returns - the generated CSS selector
|
|
128
|
-
*/
|
|
129
|
-
static id (base: string) : string {
|
|
130
|
-
return `#${this.prefix(base)}`;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Generates an aria-controls CSS selector
|
|
135
|
-
* @param id - the id of the controlled element
|
|
136
|
-
* @returns - the generated CSS selector
|
|
137
|
-
*/
|
|
138
|
-
static controls (id?: string | null) : string {
|
|
139
|
-
return id ? `[aria-controls="${this.prefix(id)}"]` : this.hasControls;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Generates an aria-expanded CSS selector
|
|
144
|
-
* @param bool - whether the element is expanded or not
|
|
145
|
-
* @returns - the generated CSS selector
|
|
146
|
-
*/
|
|
147
|
-
static expanded (bool?: boolean | null) : string {
|
|
148
|
-
return typeof bool === 'boolean' ? `[aria-expanded="${bool}"]` : this.hasExpanded;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Returns a NodeList of HTMLElements within the given element that are focusable
|
|
153
|
-
* @param el - the element whose focusable children will be returned
|
|
154
|
-
* @returns - the elements within the given element that are focusable
|
|
155
|
-
*/
|
|
156
|
-
static getFocusables (el?: HTMLElement) : HTMLElement[] {
|
|
157
|
-
let focusables: HTMLElement[];
|
|
158
|
-
if (el) {
|
|
159
|
-
focusables = Array.from(el.querySelectorAll<HTMLElement>(this.focusable));
|
|
160
|
-
} else {
|
|
161
|
-
focusables = Array.from(document.querySelectorAll<HTMLElement>(this.focusable));
|
|
162
|
-
}
|
|
163
|
-
return focusables.filter((el: HTMLElement) => this.isFocusable(el));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Returns true if an element is focusable and false if not,
|
|
168
|
-
* based on styles (i.e. a parent has display: none;)
|
|
169
|
-
* NOTE: Still need to determine what other styles may make an element un-focusable
|
|
170
|
-
* @param el - the element
|
|
171
|
-
* @returns - true if the element is focusable; false if not
|
|
172
|
-
*/
|
|
173
|
-
static isFocusable (el: HTMLElement) : boolean {
|
|
174
|
-
let current: HTMLElement | null = el;
|
|
175
|
-
|
|
176
|
-
do {
|
|
177
|
-
if (window.getComputedStyle(current).getPropertyValue('display').toLowerCase() === 'none') {
|
|
178
|
-
return false;
|
|
179
|
-
}
|
|
180
|
-
current = current.parentElement;
|
|
181
|
-
} while (current);
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
export default MintSelectors;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Settings management
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
|
-
export abstract class MintSettings {
|
|
6
|
-
/**
|
|
7
|
-
* Value added to all delay variables
|
|
8
|
-
*/
|
|
9
|
-
static delayBase: number = 0;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Value multiplied by delay variable index
|
|
13
|
-
*/
|
|
14
|
-
static delayStep: number = 100;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Delay variables
|
|
18
|
-
*/
|
|
19
|
-
static delay: {[key: string]: number} = {
|
|
20
|
-
instant: this.delayBase + this.delayStep * 0,
|
|
21
|
-
fast: this.delayBase + this.delayStep * 1,
|
|
22
|
-
medFast: this.delayBase + this.delayStep * 2,
|
|
23
|
-
default: this.delayBase + this.delayStep * 3,
|
|
24
|
-
medSlow: this.delayBase + this.delayStep * 4,
|
|
25
|
-
slow: this.delayBase + this.delayStep * 5
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Breakpoint variables
|
|
30
|
-
*/
|
|
31
|
-
static break: {[key: string]: number} = {
|
|
32
|
-
z: 0,
|
|
33
|
-
xs: 480,
|
|
34
|
-
sm: 768,
|
|
35
|
-
md: 1024,
|
|
36
|
-
lg: 1200,
|
|
37
|
-
xl: 1440
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Update the provided settings variables
|
|
42
|
-
* @param settings - Object of settings variables to update
|
|
43
|
-
*/
|
|
44
|
-
static set (settings: {[key: string]: any}) : void {
|
|
45
|
-
let newDelay: boolean = false;
|
|
46
|
-
if (typeof settings.delayBase === 'number') {
|
|
47
|
-
this.delayBase = settings.delayBase;
|
|
48
|
-
newDelay = true;
|
|
49
|
-
}
|
|
50
|
-
if (typeof settings.delayStep === 'number') {
|
|
51
|
-
this.delayStep = settings.delayStep;
|
|
52
|
-
newDelay = true;
|
|
53
|
-
}
|
|
54
|
-
if (newDelay) {
|
|
55
|
-
this.setDelay();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (settings.delay && Object.keys(settings.delay).length) {
|
|
59
|
-
if (Object.values(settings.delay).reduce((prev: any, next: any) => prev && typeof next === 'number', true)) {
|
|
60
|
-
this.delay = {...this.delay, ...settings.delay};
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (settings.break && Object.keys(settings.break).length) {
|
|
65
|
-
if (Object.values(settings.break).reduce((prev: any, next: any) => prev && typeof next === 'number', true)) {
|
|
66
|
-
this.break = {...this.break, ...settings.break};
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Updates the delay variables based on `this.delayBase` and `this.delayStep`
|
|
73
|
-
*/
|
|
74
|
-
protected static setDelay () : void {
|
|
75
|
-
this.delay = {
|
|
76
|
-
instant: this.delayBase + this.delayStep * 0,
|
|
77
|
-
fast: this.delayBase + this.delayStep * 1,
|
|
78
|
-
medFast: this.delayBase + this.delayStep * 2,
|
|
79
|
-
default: this.delayBase + this.delayStep * 3,
|
|
80
|
-
medSlow: this.delayBase + this.delayStep * 4,
|
|
81
|
-
slow: this.delayBase + this.delayStep * 5
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
export default MintSettings;
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Functions for analyzing and manipulating text.
|
|
3
|
-
*/
|
|
4
|
-
export abstract class MintText {
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Generate a slug from a string
|
|
8
|
-
* @param text - The string to slugify
|
|
9
|
-
* @returns The slugified string
|
|
10
|
-
*/
|
|
11
|
-
static slug (text?: string): string {
|
|
12
|
-
return text?.trim()
|
|
13
|
-
.toLowerCase()
|
|
14
|
-
.replace(/'/g, '')
|
|
15
|
-
.replace(/\W+/g, '-')
|
|
16
|
-
.replace(/-+/g, '-')
|
|
17
|
-
.replace(/^-+|-+$/g, '')
|
|
18
|
-
.replace(/^\/+|\/+$/g, '') ?? '';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Generate a title from a slug
|
|
23
|
-
* @param slug - The slug to generate a title from
|
|
24
|
-
* @returns The title
|
|
25
|
-
*/
|
|
26
|
-
static unslug (slug: string): string {
|
|
27
|
-
return this.titleCase(slug.replace(/[-/]+/g, ' '));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Format a phone number
|
|
32
|
-
* @param phone - The phone number to format
|
|
33
|
-
* @returns The formatted phone number
|
|
34
|
-
*/
|
|
35
|
-
static phone (phone?: string | number): string {
|
|
36
|
-
const given = phone?.toString().trim() ?? '';
|
|
37
|
-
if (given === '(' || given === '') {
|
|
38
|
-
return given;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
let numbers = given.replace(/\D/g, '') ?? '',
|
|
42
|
-
formatted = '';
|
|
43
|
-
|
|
44
|
-
if (numbers.length > 10) {
|
|
45
|
-
formatted += `+${numbers.slice(0, numbers.length - 10)} `;
|
|
46
|
-
numbers = numbers.slice(numbers.length - 10);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
for (var i = 0; i < numbers.length; i++) {
|
|
50
|
-
switch (i) {
|
|
51
|
-
case 0:
|
|
52
|
-
formatted += '(';
|
|
53
|
-
break;
|
|
54
|
-
case 3:
|
|
55
|
-
formatted += ') ';
|
|
56
|
-
break;
|
|
57
|
-
case 6:
|
|
58
|
-
formatted += '-';
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
formatted += numbers[i];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
switch (given[given.length - 1]) {
|
|
65
|
-
case ')':
|
|
66
|
-
if (i === 3) {
|
|
67
|
-
formatted += ') ';
|
|
68
|
-
}
|
|
69
|
-
break;
|
|
70
|
-
case '-':
|
|
71
|
-
if (i === 6) {
|
|
72
|
-
formatted += '-';
|
|
73
|
-
}
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return formatted;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Pluralize the given word
|
|
82
|
-
*/
|
|
83
|
-
static plural (word: string): string {
|
|
84
|
-
if (word.endsWith('ies') ||
|
|
85
|
-
word.endsWith('es') ||
|
|
86
|
-
(word.endsWith('s') && !word.endsWith('us') && !word.endsWith('is') && !word.endsWith('ss'))) {
|
|
87
|
-
return word;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (word.endsWith('y') && !['a', 'e', 'i', 'o', 'u'].includes(word.charAt(word.length - 2))) {
|
|
91
|
-
return word.slice(0, -1) + 'ies';
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (word.endsWith('s') || word.endsWith('sh') || word.endsWith('ch') || word.endsWith('x') || word.endsWith('z')) {
|
|
95
|
-
return word + 'es';
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return word + 's';
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Capitalize the first letter of the given word
|
|
103
|
-
*/
|
|
104
|
-
static titleCase (text: string): string {
|
|
105
|
-
return text
|
|
106
|
-
.toLowerCase()
|
|
107
|
-
.replace(/(?:^|\s)\S/g, a => a.toUpperCase());
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Copies the provided text to the clipboard
|
|
112
|
-
* @param text - the text to copy
|
|
113
|
-
* @returns - true if the text was successfully copied to the clipboard; else false
|
|
114
|
-
*/
|
|
115
|
-
static copyText (text: string) : boolean {
|
|
116
|
-
let textArea: HTMLTextAreaElement = document.createElement('textarea');
|
|
117
|
-
|
|
118
|
-
if (!text || !textArea) {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
textArea.value = text;
|
|
123
|
-
textArea.style.cssText = `
|
|
124
|
-
position: fixed;
|
|
125
|
-
top: 0;
|
|
126
|
-
left: 0;
|
|
127
|
-
transform: translate(-100%, -100%);
|
|
128
|
-
opacity: 0;
|
|
129
|
-
z-index: -1;
|
|
130
|
-
`;
|
|
131
|
-
|
|
132
|
-
document.body.appendChild(textArea);
|
|
133
|
-
textArea.select();
|
|
134
|
-
textArea.setSelectionRange(0, 99999);
|
|
135
|
-
navigator.clipboard.writeText(textArea.value);
|
|
136
|
-
document.body.removeChild(textArea);
|
|
137
|
-
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Tests the validity of an email address
|
|
143
|
-
* @see {@link https://stackoverflow.com/questions/201323/how-can-i-validate-an-email-address-using-a-regular-expression}
|
|
144
|
-
* @param text - the string to test
|
|
145
|
-
* @returns - true if the given string is an email address; false if not
|
|
146
|
-
*/
|
|
147
|
-
static isEmail (text: string) : boolean {
|
|
148
|
-
return null !== text.match(/(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/);
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
export default MintText;
|