@appartmint/mint 0.14.0 → 0.14.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/README.md +3 -3
- package/dist/css/mint.css +97 -4
- 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/imports/components/header.d.ts +124 -124
- package/dist/js/imports/enum.d.ts +9 -9
- package/dist/js/imports/models/color.d.ts +31 -31
- package/dist/js/imports/models/item.d.ts +69 -69
- package/dist/js/imports/util/display.d.ts +6 -6
- package/dist/js/imports/util/event.d.ts +6 -6
- package/dist/js/imports/util/icon.d.ts +28 -28
- package/dist/js/imports/util/list.d.ts +12 -12
- package/dist/js/imports/util/math.d.ts +13 -13
- package/dist/js/imports/util/object.d.ts +65 -58
- package/dist/js/imports/util/object.d.ts.map +1 -1
- package/dist/js/imports/util/selectors.d.ts +121 -121
- package/dist/js/imports/util/settings.d.ts +38 -38
- package/dist/js/imports/util/text.d.ts +16 -16
- package/dist/js/imports/util/window.d.ts +6 -6
- package/dist/js/index.d.ts +23 -23
- package/dist/js/index.js +360 -317
- 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/dist/js/util.d.ts +77 -77
- package/dist/js/util.js +67 -67
- package/dist/js/util.js.map +1 -1
- package/dist/js/util.min.js.map +1 -1
- package/package.json +1 -1
- package/src/scss/imports/_index.scss +8 -8
- package/src/scss/imports/components/_buttons.scss +2 -0
- package/src/scss/imports/components/_cards.scss +23 -1
- package/src/scss/imports/components/_index.scss +7 -7
- package/src/scss/imports/global/_icons.scss +6 -6
- package/src/scss/imports/global/_structure.scss +117 -25
- package/src/scss/imports/util/_index.scss +8 -8
- package/src/ts/imports/enum.ts +9 -9
- package/src/ts/imports/models/color.ts +96 -96
- package/src/ts/imports/util/display.ts +6 -6
- package/src/ts/imports/util/event.ts +7 -7
- package/src/ts/imports/util/list.ts +19 -19
- package/src/ts/imports/util/math.ts +17 -17
- package/src/ts/imports/util/object.ts +43 -0
- package/src/ts/imports/util/window.ts +6 -6
- package/src/ts/index.ts +33 -33
|
@@ -82,45 +82,137 @@ section {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
85
|
+
@mixin grid-2 {
|
|
86
|
+
@include break(sm) {
|
|
87
|
+
grid-template-columns: repeat(2, 1fr);
|
|
88
|
+
|
|
89
|
+
& > :last-child:nth-child(odd) {
|
|
90
|
+
#{class(card)} {
|
|
91
|
+
grid-column: span 2;
|
|
92
|
+
width: 50%;
|
|
93
|
+
margin-left: auto;
|
|
94
|
+
margin-right: auto;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
94
97
|
}
|
|
98
|
+
}
|
|
95
99
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
@mixin grid-3 {
|
|
101
|
+
@include break(lg) {
|
|
102
|
+
grid-template-columns: repeat(3, 1fr);
|
|
103
|
+
|
|
104
|
+
& > :last-child:nth-child(odd) {
|
|
105
|
+
#{class(card)} {
|
|
106
|
+
grid-column: span 1;
|
|
107
|
+
width: 100%;
|
|
108
|
+
}
|
|
99
109
|
}
|
|
100
|
-
}
|
|
101
110
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
111
|
+
& > :last-child:nth-child(#{'3n+1'}) {
|
|
112
|
+
#{class(card)} {
|
|
113
|
+
grid-column: 2;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
& > :last-child:nth-child(#{'3n+2'}) {
|
|
118
|
+
#{class(card)} {
|
|
119
|
+
grid-column: 3;
|
|
120
|
+
}
|
|
105
121
|
}
|
|
106
122
|
|
|
107
|
-
|
|
108
|
-
|
|
123
|
+
& > :nth-last-child(2):nth-child(#{'3n+1'}) {
|
|
124
|
+
#{class(card)} {
|
|
125
|
+
grid-column: 1;
|
|
126
|
+
}
|
|
109
127
|
}
|
|
110
128
|
}
|
|
129
|
+
}
|
|
111
130
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
131
|
+
@mixin grid-4 {
|
|
132
|
+
@include break(xl) {
|
|
133
|
+
grid-template-columns: repeat(4, 1fr);
|
|
134
|
+
|
|
135
|
+
& > :last-child:nth-child(odd),
|
|
136
|
+
& > :last-child:nth-child(#{'3n+1'}),
|
|
137
|
+
& > :last-child:nth-child(#{'3n+2'}),
|
|
138
|
+
& > :nth-last-child(2):nth-child(#{'3n+1'}) {
|
|
139
|
+
#{class(card)} {
|
|
140
|
+
grid-column: span 1;
|
|
141
|
+
width: 100%;
|
|
142
|
+
}
|
|
115
143
|
}
|
|
116
144
|
|
|
117
|
-
|
|
118
|
-
|
|
145
|
+
& > :last-child:nth-child(#{'4n+1'}) {
|
|
146
|
+
#{class(card)} {
|
|
147
|
+
grid-column: 2 / span 2;
|
|
148
|
+
width: 50%;
|
|
149
|
+
margin-left: auto;
|
|
150
|
+
margin-right: auto;
|
|
151
|
+
}
|
|
119
152
|
}
|
|
120
153
|
|
|
121
|
-
|
|
122
|
-
|
|
154
|
+
& > :last-child:nth-child(#{'4n+2'}) {
|
|
155
|
+
#{class(card)} {
|
|
156
|
+
grid-column: 3 / span 2;
|
|
157
|
+
width: 50%;
|
|
158
|
+
margin-left: auto;
|
|
159
|
+
margin-right: auto;
|
|
160
|
+
}
|
|
123
161
|
}
|
|
162
|
+
|
|
163
|
+
& > :nth-last-child(2):nth-child(#{'4n+1'}) {
|
|
164
|
+
#{class(card)} {
|
|
165
|
+
grid-column: 1 / span 2;
|
|
166
|
+
width: 50%;
|
|
167
|
+
margin-left: auto;
|
|
168
|
+
margin-right: auto;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
& > :last-child:nth-child(#{'4n+3'}) {
|
|
173
|
+
#{class(card)} {
|
|
174
|
+
grid-column: 4;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
& > :nth-last-child(2):nth-child(#{'4n+2'}) {
|
|
179
|
+
#{class(card)} {
|
|
180
|
+
grid-column: 2 / span 2;
|
|
181
|
+
width: 50%;
|
|
182
|
+
margin-left: auto;
|
|
183
|
+
margin-right: auto;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
& > :nth-last-child(3):nth-child(#{'4n+1'}) {
|
|
188
|
+
#{class(card)} {
|
|
189
|
+
grid-column: 1;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
#{class(grid)} {
|
|
197
|
+
display: grid;
|
|
198
|
+
grid-template-columns: 1fr;
|
|
199
|
+
gap: $grid-gap;
|
|
200
|
+
margin-top: $grid-gap;
|
|
201
|
+
margin-bottom: $grid-gap;
|
|
202
|
+
|
|
203
|
+
&#{class('2')} {
|
|
204
|
+
@include grid-2;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
&#{class('3')} {
|
|
208
|
+
@include grid-2;
|
|
209
|
+
@include grid-3;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
&#{class('4')} {
|
|
213
|
+
@include grid-2;
|
|
214
|
+
@include grid-3;
|
|
215
|
+
@include grid-4;
|
|
124
216
|
}
|
|
125
217
|
|
|
126
218
|
#{class(portrait)} {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/// _index.scss - SCSS Utilities
|
|
2
|
-
/// @author App Art Mint LLC
|
|
3
|
-
///
|
|
4
|
-
/// @group Mint
|
|
5
|
-
|
|
6
|
-
/// Forwards
|
|
7
|
-
@forward './util';
|
|
8
|
-
@forward './vars';
|
|
1
|
+
/// _index.scss - SCSS Utilities
|
|
2
|
+
/// @author App Art Mint LLC
|
|
3
|
+
///
|
|
4
|
+
/// @group Mint
|
|
5
|
+
|
|
6
|
+
/// Forwards
|
|
7
|
+
@forward './util';
|
|
8
|
+
@forward './vars';
|
package/src/ts/imports/enum.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Side Enum
|
|
3
|
-
*/
|
|
4
|
-
export enum mintSide {
|
|
5
|
-
Top,
|
|
6
|
-
Right,
|
|
7
|
-
Bottom,
|
|
8
|
-
Left
|
|
9
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Side Enum
|
|
3
|
+
*/
|
|
4
|
+
export enum mintSide {
|
|
5
|
+
Top,
|
|
6
|
+
Right,
|
|
7
|
+
Bottom,
|
|
8
|
+
Left
|
|
9
|
+
};
|
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Color
|
|
3
|
-
*/
|
|
4
|
-
export class mintColor {
|
|
5
|
-
protected static hexBase: number = 16;
|
|
6
|
-
protected static hexMax: string = 'FF';
|
|
7
|
-
public r: number;
|
|
8
|
-
public g: number;
|
|
9
|
-
public b: number;
|
|
10
|
-
public a: number;
|
|
11
|
-
|
|
12
|
-
constructor (args: {[key: string]: number | string}) {
|
|
13
|
-
this.r = typeof args.r === 'number' ? Math.max(Math.min(args.r, mintColor.hexBase ** 2 - 1), 0) : 0;
|
|
14
|
-
this.g = typeof args.g === 'number' ? Math.max(Math.min(args.g, mintColor.hexBase ** 2 - 1), 0) : 0;
|
|
15
|
-
this.b = typeof args.b === 'number' ? Math.max(Math.min(args.b, mintColor.hexBase ** 2 - 1), 0) : 0;
|
|
16
|
-
this.a = typeof args.a === 'number' ? Math.max(Math.min(args.a, 1), 0) : 1;
|
|
17
|
-
if (typeof args.color === 'string') {
|
|
18
|
-
this.stringConstructor(args.color);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Constructor from a string argument
|
|
24
|
-
*/
|
|
25
|
-
protected stringConstructor (str: string) : void {
|
|
26
|
-
if (str.startsWith('#')) {
|
|
27
|
-
this.hexConstructor(str);
|
|
28
|
-
} else {
|
|
29
|
-
if (~str.indexOf('linear-gradient')) {
|
|
30
|
-
str = str.substring(str.indexOf('linear-gradient'), str.length);
|
|
31
|
-
}
|
|
32
|
-
this.rgbConstructor(str);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Constructor from a hex argument
|
|
38
|
-
*/
|
|
39
|
-
protected hexConstructor (hex: string) : void {
|
|
40
|
-
switch (hex.length) {
|
|
41
|
-
case 1:
|
|
42
|
-
case 5:
|
|
43
|
-
case 6:
|
|
44
|
-
return;
|
|
45
|
-
case 2:
|
|
46
|
-
hex = '#' + hex[1] + hex[1] + hex[1] + hex[1] + hex[1] + hex[1] + mintColor.hexMax;
|
|
47
|
-
break;
|
|
48
|
-
case 3:
|
|
49
|
-
hex = '#' + hex[1] + hex[1] + hex[1] + hex[2] + hex[2] + hex[2] + mintColor.hexMax;
|
|
50
|
-
break;
|
|
51
|
-
case 4:
|
|
52
|
-
hex = '#' + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3] + mintColor.hexMax;
|
|
53
|
-
break;
|
|
54
|
-
case 7:
|
|
55
|
-
hex += mintColor.hexMax;
|
|
56
|
-
break;
|
|
57
|
-
case 8:
|
|
58
|
-
hex += hex[hex.length - 1];
|
|
59
|
-
break;
|
|
60
|
-
default:
|
|
61
|
-
hex = hex.substring(0, 9);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
this.r = parseInt(hex.substring(1, 3), mintColor.hexBase);
|
|
65
|
-
this.g = parseInt(hex.substring(3, 5), mintColor.hexBase);
|
|
66
|
-
this.b = parseInt(hex.substring(5, 7), mintColor.hexBase);
|
|
67
|
-
this.a = parseInt(hex.substring(7, 9), mintColor.hexBase) / mintColor.hexBase ** 2;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Constructor from an rgba argument
|
|
72
|
-
*/
|
|
73
|
-
protected rgbConstructor (rgb: string) : void {
|
|
74
|
-
let match: RegExpMatchArray | null = rgb.match(/rgba?\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\)?(?:, ?(\d(?:\.\d*)?)\))?/);
|
|
75
|
-
if (match) {
|
|
76
|
-
this.r = parseInt(match[1]);
|
|
77
|
-
this.g = parseInt(match[2]);
|
|
78
|
-
this.b = parseInt(match[3]);
|
|
79
|
-
this.a = parseFloat(match[4]);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Returns the perceived brightness of the color
|
|
85
|
-
*/
|
|
86
|
-
getBrightness () : number {
|
|
87
|
-
if (this.a === 0) {
|
|
88
|
-
return 262;
|
|
89
|
-
}
|
|
90
|
-
if (!isNaN(this.r) && !isNaN(this.g) && !isNaN(this.b)) {
|
|
91
|
-
return Math.round((this.r * 299 + this.g * 587 + this.b * 144) / 1000);
|
|
92
|
-
}
|
|
93
|
-
return -1;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
export default mintColor;
|
|
1
|
+
/**
|
|
2
|
+
* Color
|
|
3
|
+
*/
|
|
4
|
+
export class mintColor {
|
|
5
|
+
protected static hexBase: number = 16;
|
|
6
|
+
protected static hexMax: string = 'FF';
|
|
7
|
+
public r: number;
|
|
8
|
+
public g: number;
|
|
9
|
+
public b: number;
|
|
10
|
+
public a: number;
|
|
11
|
+
|
|
12
|
+
constructor (args: {[key: string]: number | string}) {
|
|
13
|
+
this.r = typeof args.r === 'number' ? Math.max(Math.min(args.r, mintColor.hexBase ** 2 - 1), 0) : 0;
|
|
14
|
+
this.g = typeof args.g === 'number' ? Math.max(Math.min(args.g, mintColor.hexBase ** 2 - 1), 0) : 0;
|
|
15
|
+
this.b = typeof args.b === 'number' ? Math.max(Math.min(args.b, mintColor.hexBase ** 2 - 1), 0) : 0;
|
|
16
|
+
this.a = typeof args.a === 'number' ? Math.max(Math.min(args.a, 1), 0) : 1;
|
|
17
|
+
if (typeof args.color === 'string') {
|
|
18
|
+
this.stringConstructor(args.color);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Constructor from a string argument
|
|
24
|
+
*/
|
|
25
|
+
protected stringConstructor (str: string) : void {
|
|
26
|
+
if (str.startsWith('#')) {
|
|
27
|
+
this.hexConstructor(str);
|
|
28
|
+
} else {
|
|
29
|
+
if (~str.indexOf('linear-gradient')) {
|
|
30
|
+
str = str.substring(str.indexOf('linear-gradient'), str.length);
|
|
31
|
+
}
|
|
32
|
+
this.rgbConstructor(str);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Constructor from a hex argument
|
|
38
|
+
*/
|
|
39
|
+
protected hexConstructor (hex: string) : void {
|
|
40
|
+
switch (hex.length) {
|
|
41
|
+
case 1:
|
|
42
|
+
case 5:
|
|
43
|
+
case 6:
|
|
44
|
+
return;
|
|
45
|
+
case 2:
|
|
46
|
+
hex = '#' + hex[1] + hex[1] + hex[1] + hex[1] + hex[1] + hex[1] + mintColor.hexMax;
|
|
47
|
+
break;
|
|
48
|
+
case 3:
|
|
49
|
+
hex = '#' + hex[1] + hex[1] + hex[1] + hex[2] + hex[2] + hex[2] + mintColor.hexMax;
|
|
50
|
+
break;
|
|
51
|
+
case 4:
|
|
52
|
+
hex = '#' + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3] + mintColor.hexMax;
|
|
53
|
+
break;
|
|
54
|
+
case 7:
|
|
55
|
+
hex += mintColor.hexMax;
|
|
56
|
+
break;
|
|
57
|
+
case 8:
|
|
58
|
+
hex += hex[hex.length - 1];
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
hex = hex.substring(0, 9);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
this.r = parseInt(hex.substring(1, 3), mintColor.hexBase);
|
|
65
|
+
this.g = parseInt(hex.substring(3, 5), mintColor.hexBase);
|
|
66
|
+
this.b = parseInt(hex.substring(5, 7), mintColor.hexBase);
|
|
67
|
+
this.a = parseInt(hex.substring(7, 9), mintColor.hexBase) / mintColor.hexBase ** 2;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Constructor from an rgba argument
|
|
72
|
+
*/
|
|
73
|
+
protected rgbConstructor (rgb: string) : void {
|
|
74
|
+
let match: RegExpMatchArray | null = rgb.match(/rgba?\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\)?(?:, ?(\d(?:\.\d*)?)\))?/);
|
|
75
|
+
if (match) {
|
|
76
|
+
this.r = parseInt(match[1]);
|
|
77
|
+
this.g = parseInt(match[2]);
|
|
78
|
+
this.b = parseInt(match[3]);
|
|
79
|
+
this.a = parseFloat(match[4]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Returns the perceived brightness of the color
|
|
85
|
+
*/
|
|
86
|
+
getBrightness () : number {
|
|
87
|
+
if (this.a === 0) {
|
|
88
|
+
return 262;
|
|
89
|
+
}
|
|
90
|
+
if (!isNaN(this.r) && !isNaN(this.g) && !isNaN(this.b)) {
|
|
91
|
+
return Math.round((this.r * 299 + this.g * 587 + this.b * 144) / 1000);
|
|
92
|
+
}
|
|
93
|
+
return -1;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export default mintColor;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Handles the display of elements
|
|
3
|
-
*/
|
|
4
|
-
export abstract class mintDisplay {
|
|
5
|
-
|
|
6
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Handles the display of elements
|
|
3
|
+
*/
|
|
4
|
+
export abstract class mintDisplay {
|
|
5
|
+
|
|
6
|
+
};
|
|
7
7
|
export default mintDisplay;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Event helper functions
|
|
3
|
-
*/
|
|
4
|
-
export abstract class mintEvent {
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
export default mintEvent;
|
|
1
|
+
/**
|
|
2
|
+
* Event helper functions
|
|
3
|
+
*/
|
|
4
|
+
export abstract class mintEvent {
|
|
5
|
+
|
|
6
|
+
};
|
|
7
|
+
export default mintEvent;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* List functions for the util library
|
|
3
|
-
*/
|
|
4
|
-
export abstract class mintList {
|
|
5
|
-
/**
|
|
6
|
-
* Returns a copy of the provided list with the items in random order
|
|
7
|
-
* @param list - the list to shuffle
|
|
8
|
-
* @returns - the shuffled list
|
|
9
|
-
*/
|
|
10
|
-
static shuffle (list: any[]): any[] {
|
|
11
|
-
let copy = [...list];
|
|
12
|
-
for (let i = copy.length - 1; i > 0; i--) {
|
|
13
|
-
const j = Math.floor(Math.random() * (i + 1));
|
|
14
|
-
[copy[i], copy[j]] = [copy[j], copy[i]];
|
|
15
|
-
}
|
|
16
|
-
return copy;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
export default mintList;
|
|
1
|
+
/**
|
|
2
|
+
* List functions for the util library
|
|
3
|
+
*/
|
|
4
|
+
export abstract class mintList {
|
|
5
|
+
/**
|
|
6
|
+
* Returns a copy of the provided list with the items in random order
|
|
7
|
+
* @param list - the list to shuffle
|
|
8
|
+
* @returns - the shuffled list
|
|
9
|
+
*/
|
|
10
|
+
static shuffle (list: any[]): any[] {
|
|
11
|
+
let copy = [...list];
|
|
12
|
+
for (let i = copy.length - 1; i > 0; i--) {
|
|
13
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
14
|
+
[copy[i], copy[j]] = [copy[j], copy[i]];
|
|
15
|
+
}
|
|
16
|
+
return copy;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export default mintList;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Math functions for the util library
|
|
3
|
-
*/
|
|
4
|
-
export abstract class mintMath {
|
|
5
|
-
/**
|
|
6
|
-
* Get a random integer between min and max
|
|
7
|
-
* @param max Maximum value to return
|
|
8
|
-
* @param min Minimum value to return (default is 0)
|
|
9
|
-
* @returns a random integer between min and max
|
|
10
|
-
*/
|
|
11
|
-
static randomInt (max: number, min: number = 0): number {
|
|
12
|
-
min = Math.ceil(min);
|
|
13
|
-
max = Math.floor(max);
|
|
14
|
-
return Math.floor(Math.random() * (max - min) + min);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
export default mintMath;
|
|
1
|
+
/**
|
|
2
|
+
* Math functions for the util library
|
|
3
|
+
*/
|
|
4
|
+
export abstract class mintMath {
|
|
5
|
+
/**
|
|
6
|
+
* Get a random integer between min and max
|
|
7
|
+
* @param max Maximum value to return
|
|
8
|
+
* @param min Minimum value to return (default is 0)
|
|
9
|
+
* @returns a random integer between min and max
|
|
10
|
+
*/
|
|
11
|
+
static randomInt (max: number, min: number = 0): number {
|
|
12
|
+
min = Math.ceil(min);
|
|
13
|
+
max = Math.floor(max);
|
|
14
|
+
return Math.floor(Math.random() * (max - min) + min);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export default mintMath;
|
|
@@ -137,5 +137,48 @@ export abstract class mintObject {
|
|
|
137
137
|
return obj;
|
|
138
138
|
}, {});
|
|
139
139
|
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Update two sets of objects
|
|
143
|
+
* @param original - the original object
|
|
144
|
+
* @param update - the object to update the original with
|
|
145
|
+
* @returns - the original objects with updated data from the update
|
|
146
|
+
*/
|
|
147
|
+
static updateArray (original: any[], update?: any[], key = 'id') : any {
|
|
148
|
+
|
|
149
|
+
// If there are no originals, push the updates
|
|
150
|
+
if (!update?.length) {
|
|
151
|
+
update?.forEach((object) => original.push(object));
|
|
152
|
+
|
|
153
|
+
// If there are existing objects
|
|
154
|
+
} else {
|
|
155
|
+
|
|
156
|
+
// Create a dictionary of the updated objects
|
|
157
|
+
const updateObjects = update.reduce<{ [key: string]: Object }>((objects, object) => ({
|
|
158
|
+
...objects,
|
|
159
|
+
[object?.[key] ?? '']: object
|
|
160
|
+
}), {});
|
|
161
|
+
|
|
162
|
+
// Remove any objects that aren't in the updated objects
|
|
163
|
+
const missingObjects = original.filter((object) => !updateObjects[object?.[key] ?? '']);
|
|
164
|
+
missingObjects?.forEach((object) => {
|
|
165
|
+
const index = original.indexOf(object);
|
|
166
|
+
if (typeof index == 'number' && index !== -1) {
|
|
167
|
+
original.splice(index, 1);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// Update the existing objects with updates
|
|
172
|
+
original.forEach((object) => {
|
|
173
|
+
if (updateObjects[object?.[key] ?? '']) {
|
|
174
|
+
Object.assign(object, updateObjects[object?.[key] ?? '']);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Push any new objects
|
|
180
|
+
const newObjects = update?.filter((object) => !original.some((existingObject) => existingObject?.[key] === object?.[key]));
|
|
181
|
+
newObjects?.forEach(newObject => original.push(newObject));
|
|
182
|
+
}
|
|
140
183
|
};
|
|
141
184
|
export default mintObject;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Functions related to the browser window.
|
|
3
|
-
*/
|
|
4
|
-
export abstract class mintWindow {
|
|
5
|
-
|
|
6
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Functions related to the browser window.
|
|
3
|
+
*/
|
|
4
|
+
export abstract class mintWindow {
|
|
5
|
+
|
|
6
|
+
};
|
|
7
7
|
export default mintWindow;
|
package/src/ts/index.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A library for building responsive web applications.
|
|
3
|
-
*
|
|
4
|
-
* @packageDocumentation
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Exports
|
|
9
|
-
*/
|
|
10
|
-
// Enums
|
|
11
|
-
export { mintSide } from './imports/enum';
|
|
12
|
-
|
|
13
|
-
// Components
|
|
14
|
-
export { mintHeader } from './imports/components/header';
|
|
15
|
-
|
|
16
|
-
// Models
|
|
17
|
-
export { mintColor } from './imports/models/color';
|
|
18
|
-
export { mintItem } from './imports/models/item';
|
|
19
|
-
|
|
20
|
-
// Utilities
|
|
21
|
-
export { mintDisplay } from './imports/util/display';
|
|
22
|
-
export { mintEvent } from './imports/util/event';
|
|
23
|
-
export { mintIcon } from './imports/util/icon';
|
|
24
|
-
export { mintList } from './imports/util/list';
|
|
25
|
-
export { mintMath } from './imports/util/math';
|
|
26
|
-
export { mintObject } from './imports/util/object';
|
|
27
|
-
export { mintText } from './imports/util/text';
|
|
28
|
-
export { mintWindow } from './imports/util/window';
|
|
29
|
-
|
|
30
|
-
// Objects
|
|
31
|
-
export { mintSelectors } from './imports/util/selectors';
|
|
32
|
-
export { mintSettings } from './imports/util/settings';
|
|
33
|
-
export { mintUtil, default } from './util';
|
|
1
|
+
/**
|
|
2
|
+
* A library for building responsive web applications.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Exports
|
|
9
|
+
*/
|
|
10
|
+
// Enums
|
|
11
|
+
export { mintSide } from './imports/enum';
|
|
12
|
+
|
|
13
|
+
// Components
|
|
14
|
+
export { mintHeader } from './imports/components/header';
|
|
15
|
+
|
|
16
|
+
// Models
|
|
17
|
+
export { mintColor } from './imports/models/color';
|
|
18
|
+
export { mintItem } from './imports/models/item';
|
|
19
|
+
|
|
20
|
+
// Utilities
|
|
21
|
+
export { mintDisplay } from './imports/util/display';
|
|
22
|
+
export { mintEvent } from './imports/util/event';
|
|
23
|
+
export { mintIcon } from './imports/util/icon';
|
|
24
|
+
export { mintList } from './imports/util/list';
|
|
25
|
+
export { mintMath } from './imports/util/math';
|
|
26
|
+
export { mintObject } from './imports/util/object';
|
|
27
|
+
export { mintText } from './imports/util/text';
|
|
28
|
+
export { mintWindow } from './imports/util/window';
|
|
29
|
+
|
|
30
|
+
// Objects
|
|
31
|
+
export { mintSelectors } from './imports/util/selectors';
|
|
32
|
+
export { mintSettings } from './imports/util/settings';
|
|
33
|
+
export { mintUtil, default } from './util';
|