@appartmint/mint 0.15.9 → 1.0.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.
Files changed (75) hide show
  1. package/dist/css/mint.css +18 -9
  2. package/dist/css/mint.css.map +1 -1
  3. package/dist/css/mint.min.css +1 -1
  4. package/dist/css/mint.min.css.map +1 -1
  5. package/dist/js/imports/components/header.d.ts +2 -2
  6. package/dist/js/imports/components/header.d.ts.map +1 -1
  7. package/dist/js/imports/components/index.d.ts +5 -0
  8. package/dist/js/imports/components/index.d.ts.map +1 -0
  9. package/dist/js/imports/enums/index.d.ts +5 -0
  10. package/dist/js/imports/enums/index.d.ts.map +1 -0
  11. package/dist/js/imports/{enum.d.ts → enums/side.d.ts} +2 -2
  12. package/dist/js/imports/enums/side.d.ts.map +1 -0
  13. package/dist/js/imports/index.d.ts +8 -0
  14. package/dist/js/imports/index.d.ts.map +1 -0
  15. package/dist/js/imports/models/index.d.ts +6 -0
  16. package/dist/js/imports/models/index.d.ts.map +1 -0
  17. package/dist/js/imports/models/item.d.ts +6 -6
  18. package/dist/js/imports/util/display.d.ts +20 -2
  19. package/dist/js/imports/util/display.d.ts.map +1 -1
  20. package/dist/js/imports/util/event.d.ts +36 -2
  21. package/dist/js/imports/util/event.d.ts.map +1 -1
  22. package/dist/js/imports/util/icon.d.ts +2 -2
  23. package/dist/js/imports/util/index.d.ts +15 -0
  24. package/dist/js/imports/util/index.d.ts.map +1 -0
  25. package/dist/js/imports/util/list.d.ts +2 -2
  26. package/dist/js/imports/util/math.d.ts +2 -2
  27. package/dist/js/imports/util/object.d.ts +2 -2
  28. package/dist/js/imports/util/scroll.d.ts +2 -2
  29. package/dist/js/imports/util/selectors.d.ts +2 -2
  30. package/dist/js/imports/util/settings.d.ts +2 -2
  31. package/dist/js/imports/util/settings.d.ts.map +1 -1
  32. package/dist/js/imports/util/text.d.ts +15 -2
  33. package/dist/js/imports/util/text.d.ts.map +1 -1
  34. package/dist/js/imports/util/window.d.ts +7 -2
  35. package/dist/js/imports/util/window.d.ts.map +1 -1
  36. package/dist/js/index.d.ts +1 -16
  37. package/dist/js/index.d.ts.map +1 -1
  38. package/dist/js/index.js +541 -475
  39. package/dist/js/index.js.map +1 -1
  40. package/dist/js/index.min.js +1 -1
  41. package/dist/js/index.min.js.map +1 -1
  42. package/package.json +1 -1
  43. package/src/scss/imports/components/_footer.scss +1 -0
  44. package/src/scss/imports/components/_header.scss +10 -12
  45. package/src/scss/imports/global/_global.scss +10 -2
  46. package/src/scss/imports/global/_texture.scss +3 -0
  47. package/src/scss/imports/util/_vars.scss +2 -1
  48. package/src/ts/imports/components/header.ts +34 -29
  49. package/src/ts/imports/components/index.ts +4 -0
  50. package/src/ts/imports/enums/index.ts +4 -0
  51. package/src/ts/imports/{enum.ts → enums/side.ts} +1 -1
  52. package/src/ts/imports/index.ts +7 -0
  53. package/src/ts/imports/models/index.ts +5 -0
  54. package/src/ts/imports/models/item.ts +6 -6
  55. package/src/ts/imports/util/display.ts +67 -2
  56. package/src/ts/imports/util/event.ts +88 -2
  57. package/src/ts/imports/util/icon.ts +2 -2
  58. package/src/ts/imports/util/index.ts +14 -0
  59. package/src/ts/imports/util/list.ts +2 -2
  60. package/src/ts/imports/util/math.ts +2 -2
  61. package/src/ts/imports/util/object.ts +3 -3
  62. package/src/ts/imports/util/scroll.ts +2 -2
  63. package/src/ts/imports/util/selectors.ts +3 -3
  64. package/src/ts/imports/util/settings.ts +2 -3
  65. package/src/ts/imports/util/text.ts +43 -2
  66. package/src/ts/imports/util/window.ts +10 -3
  67. package/src/ts/index.ts +1 -25
  68. package/dist/js/imports/enum.d.ts.map +0 -1
  69. package/dist/js/util.d.ts +0 -78
  70. package/dist/js/util.d.ts.map +0 -1
  71. package/dist/js/util.js +0 -399
  72. package/dist/js/util.js.map +0 -1
  73. package/dist/js/util.min.js +0 -2
  74. package/dist/js/util.min.js.map +0 -1
  75. package/src/ts/util.ts +0 -209
@@ -1 +0,0 @@
1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C5C,SAASC,KAAKmD,YAAYV,GAEnB,GACX,CAQA7E,eAAgB4E,GACZ,OAAO,OAASA,EAAKY,MAAM,icAC/B,EApMJ/F,EAAAA,SAAAwC,EAsMAxC,EAAAA,QAAewC,C,GC/MXwD,EAA2B,CAAC,ECE5BC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqB/C,IAAjBgD,EACH,OAAOA,EAAapG,QAGrB,IAAIC,EAAS+F,EAAyBG,GAAY,CAGjDnG,QAAS,CAAC,GAOX,OAHAqG,EAAoBF,GAAUG,KAAKrG,EAAOD,QAASC,EAAQA,EAAOD,QAASkG,GAGpEjG,EAAOD,OACf,CCnB0BkG,CAAoB,K","sources":["webpack://mint/webpack/universalModuleDefinition","webpack://mint/./src/ts/imports/enum.ts","webpack://mint/./src/ts/imports/util/settings.ts","webpack://mint/./src/ts/util.ts","webpack://mint/webpack/bootstrap","webpack://mint/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"mintUtil\"] = factory();\n\telse\n\t\troot[\"mintUtil\"] = factory();\n})(this, () => {\nreturn ","/**\r\n * Side Enum\r\n */\r\n export enum mintSide {\r\n Top,\r\n Right,\r\n Bottom,\r\n Left\r\n};\r\n","/**\n * Settings management\n * @public\n */\nexport abstract class mintSettings {\n /**\n * Value added to all delay variables\n */\n static delayBase: number = 0;\n\n /**\n * Value multiplied by delay variable index\n */\n static delayStep: number = 100;\n\n /**\n * Delay variables\n */\n static delay: {[key: string]: number} = {\n instant: this.delayBase + this.delayStep * 0,\n fast: this.delayBase + this.delayStep * 1,\n medFast: this.delayBase + this.delayStep * 2,\n default: this.delayBase + this.delayStep * 3,\n medSlow: this.delayBase + this.delayStep * 4,\n slow: this.delayBase + this.delayStep * 5\n };\n\n /**\n * Breakpoint variables\n */\n static break: {[key: string]: number} = {\n z: 0,\n xs: 480,\n sm: 768,\n md: 1024,\n lg: 1200,\n xl: 1440\n };\n\n /**\n * Update the provided settings variables\n * @param settings - Object of settings variables to update\n */\n static set (settings: {[key: string]: any}) : void {\n let newDelay: boolean = false;\n if (typeof settings.delayBase === 'number') {\n this.delayBase = settings.delayBase;\n newDelay = true;\n }\n if (typeof settings.delayStep === 'number') {\n this.delayStep = settings.delayStep;\n newDelay = true;\n }\n if (newDelay) {\n this.setDelay();\n }\n\n if (settings.delay && Object.keys(settings.delay).length) {\n if (Object.values(settings.delay).reduce((prev: any, next: any) => prev && typeof next === 'number', true)) {\n this.delay = {...this.delay, ...settings.delay};\n }\n }\n\n if (settings.break && Object.keys(settings.break).length) {\n if (Object.values(settings.break).reduce((prev: any, next: any) => prev && typeof next === 'number', true)) {\n this.break = {...this.break, ...settings.break};\n }\n }\n }\n\n /**\n * Updates the delay variables based on `this.delayBase` and `this.delayStep`\n */\n protected static setDelay () : void {\n this.delay = {\n instant: this.delayBase + this.delayStep * 0,\n fast: this.delayBase + this.delayStep * 1,\n medFast: this.delayBase + this.delayStep * 2,\n default: this.delayBase + this.delayStep * 3,\n medSlow: this.delayBase + this.delayStep * 4,\n slow: this.delayBase + this.delayStep * 5\n };\n }\n};\n\nexport default mintSettings;\n","/**\n * Imports\n */\nimport { mintSide } from './imports/enum';\nimport mintSettings from './imports/util/settings';\n\n/**\n * Utility functions\n * @public\n */\nexport abstract class mintUtil {\n /**\n * Returns the width of the window, including fractional pixels\n * @returns the width of the window\n */\n static windowWidth () : number {\n const decimal: number = document.body.getBoundingClientRect().width % 1;\n return window.innerWidth + decimal;\n }\n\n /**\n * Ensures that a function `func` is run only after not being called for `wait` milliseconds\n * @param func - the function to debounce\n * @param wait - the amount of time to wait before running the function\n * @returns - the debounced function\n */\n static debounce (func: Function, wait: number = mintSettings.delay.default) : Function {\n let timer: number;\n return function (e: any) {\n if (timer) {\n clearTimeout(timer);\n }\n timer = setTimeout(func, wait, e);\n }\n }\n\n /**\n * Ensures that a function `func` is run only after not being called for `wait` milliseconds\n * @param func - the function to debounce\n * @param wait - the amount of time to wait before running the function\n * @returns - the debounced function as an EventListener\n */\n static debounceEvent (func: Function, wait: number = mintSettings.delay.default) : EventListener {\n return mintUtil.debounce(func, wait) as EventListener;\n }\n\n /**\n * Ensures that a function `func` is called at most every `wait` milliseconds with optional leading and trailing calls\n * @param func - the function to throttle\n * @param wait - the amount of time between function calls\n * @param options - leading and trailing options: default = \\{ leading: true, trailing, true \\}\n * @returns - the throttled function\n */\n static throttle (func: Function,\n wait: number = mintSettings.delay.default,\n options?: {[key: string]: boolean}) : Function {\n let context: any, args: any, result: any,\n timeout: number, previous: number = 0,\n later: Function = function () {\n previous = options?.leading === false ? 0 : new Date().getTime();\n timeout = 0;\n result = func.apply(context, args);\n if (!timeout) {\n context = args = null;\n }\n },\n throttled: Function = function (this: any): any {\n let now: number = new Date().getTime();\n if (!previous && options?.leading === false) {\n previous = now;\n }\n let remaining: number = wait - now + previous;\n context = this;\n args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = 0;\n }\n previous = now;\n result = func.apply(context, args);\n if (!timeout) {\n context = args = null;\n }\n } else if (!timeout && options?.trailing !== false) {\n timeout = window.setTimeout(later, remaining);\n }\n return result;\n };\n\n return throttled;\n }\n\n /**\n * Ensures that a function `func` is called at most every `wait` milliseconds with optional leading and trailing calls\n * @param func - the function to throttle\n * @param wait - the amount of time between function calls\n * @param options - leading and trailing options: default = \\{ leading: true, trailing, true \\}\n * @returns - the throttled function as an EventListener\n */\n static throttleEvent (func: Function,\n wait: number = mintSettings.delay.default,\n options?: {[key: string]: boolean}) : EventListener {\n return mintUtil.throttle(func, wait, options) as EventListener;\n }\n\n /**\n * Sets the element's height to its `innerHeight`, then to `auto` after a delay\n * @param el - the element whose height will be set\n * @param delay - the amount of time in milliseconds that the show animation will be active\n * @param from - the side that the element is animating from\n */\n static show (el?: HTMLElement | null, delay: number = mintSettings.delay.default, from: mintSide = mintSide.Top) : void {\n if (el) {\n el.style.display = '';\n requestAnimationFrame(() => {\n if (from === mintSide.Top || from === mintSide.Bottom) {\n el.style.height = `${el.scrollHeight}px`;\n } else {\n el.style.width = `${el.scrollWidth}px`;\n }\n \n setTimeout(() => {\n if (from === mintSide.Top || from === mintSide.Bottom) {\n el.style.height = 'auto';\n } else {\n el.style.width = 'auto';\n }\n }, delay);\n });\n }\n }\n\n /**\n * Sets the element's height to 0\n * @param el - the element whose height will be set\n * @param delay - the amount of time in milliseconds that the show animation will be active\n * @param from - the side that the element is animating from\n */\n static hide (el?: HTMLElement | null, delay: number = mintSettings.delay.default, from: mintSide = mintSide.Top) : void {\n if (el) {\n let height = el.scrollHeight,\n width = el.scrollWidth,\n transition = el.style.transition;\n el.style.transition = '';\n requestAnimationFrame(() => {\n if (from === mintSide.Top || from === mintSide.Bottom) {\n el.style.height = `${height}px`;\n } else {\n el.style.width = `${width}px`;\n }\n \n el.style.transition = transition;\n requestAnimationFrame(() => {\n if (from === mintSide.Top || from === mintSide.Bottom) {\n el.style.height = '0';\n } else {\n el.style.width = '0';\n }\n });\n });\n setTimeout(() => {\n el.style.display = 'none';\n }, delay);\n }\n }\n\n /**\n * Copies the provided text to the clipboard\n * @param text - the text to copy\n * @returns - true if the text was successfully copied to the clipboard; else false\n */\n static copyText (text: string) : boolean {\n let textArea: HTMLTextAreaElement = document.createElement('textarea');\n\n if (!text || !textArea) {\n return false;\n }\n\n textArea.value = text;\n textArea.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n transform: translate(-100%, -100%);\n opacity: 0;\n z-index: -1;\n `;\n\n document.body.appendChild(textArea);\n textArea.select();\n textArea.setSelectionRange(0, 99999);\n navigator.clipboard.writeText(textArea.value);\n document.body.removeChild(textArea);\n\n return true;\n }\n\n /**\n * Tests the validity of an email address\n * @see {@link https://stackoverflow.com/questions/201323/how-can-i-validate-an-email-address-using-a-regular-expression}\n * @param text - the string to test\n * @returns - true if the given string is an email address; false if not\n */\n static isEmail (text: string) : boolean {\n 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])+)\\])/);\n }\n}\nexport default mintUtil;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(427);\n"],"names":["root","factory","exports","module","define","amd","this","mintSide","mintSettings","static","settings","newDelay","delayBase","delayStep","setDelay","delay","Object","keys","length","values","reduce","prev","next","assign","break","instant","fast","medFast","default","medSlow","slow","_a","z","xs","sm","md","lg","xl","enum_1","require","settings_1","__importDefault","mintUtil","decimal","document","body","getBoundingClientRect","width","window","innerWidth","func","timer","wait","arguments","undefined","e","clearTimeout","setTimeout","debounce","context","args","result","timeout","options","previous","later","leading","Date","getTime","apply","now","remaining","trailing","throttle","el","from","Top","style","display","requestAnimationFrame","Bottom","height","scrollHeight","scrollWidth","transition","text","textArea","createElement","value","cssText","appendChild","select","setSelectionRange","navigator","clipboard","writeText","removeChild","match","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","call"],"sourceRoot":""}
package/src/ts/util.ts DELETED
@@ -1,209 +0,0 @@
1
- /**
2
- * Imports
3
- */
4
- import { mintSide } from './imports/enum';
5
- import mintSettings from './imports/util/settings';
6
-
7
- /**
8
- * Utility functions
9
- * @public
10
- */
11
- export abstract class mintUtil {
12
- /**
13
- * Returns the width of the window, including fractional pixels
14
- * @returns the width of the window
15
- */
16
- static windowWidth () : number {
17
- const decimal: number = document.body.getBoundingClientRect().width % 1;
18
- return window.innerWidth + decimal;
19
- }
20
-
21
- /**
22
- * Ensures that a function `func` is run only after not being called for `wait` milliseconds
23
- * @param func - the function to debounce
24
- * @param wait - the amount of time to wait before running the function
25
- * @returns - the debounced function
26
- */
27
- static debounce (func: Function, wait: number = mintSettings.delay.default) : Function {
28
- let timer: number;
29
- return function (e: any) {
30
- if (timer) {
31
- clearTimeout(timer);
32
- }
33
- timer = setTimeout(func, wait, e);
34
- }
35
- }
36
-
37
- /**
38
- * Ensures that a function `func` is run only after not being called for `wait` milliseconds
39
- * @param func - the function to debounce
40
- * @param wait - the amount of time to wait before running the function
41
- * @returns - the debounced function as an EventListener
42
- */
43
- static debounceEvent (func: Function, wait: number = mintSettings.delay.default) : EventListener {
44
- return mintUtil.debounce(func, wait) as EventListener;
45
- }
46
-
47
- /**
48
- * Ensures that a function `func` is called at most every `wait` milliseconds with optional leading and trailing calls
49
- * @param func - the function to throttle
50
- * @param wait - the amount of time between function calls
51
- * @param options - leading and trailing options: default = \{ leading: true, trailing, true \}
52
- * @returns - the throttled function
53
- */
54
- static throttle (func: Function,
55
- wait: number = mintSettings.delay.default,
56
- options?: {[key: string]: boolean}) : Function {
57
- let context: any, args: any, result: any,
58
- timeout: number, previous: number = 0,
59
- later: Function = function () {
60
- previous = options?.leading === false ? 0 : new Date().getTime();
61
- timeout = 0;
62
- result = func.apply(context, args);
63
- if (!timeout) {
64
- context = args = null;
65
- }
66
- },
67
- throttled: Function = function (this: any): any {
68
- let now: number = new Date().getTime();
69
- if (!previous && options?.leading === false) {
70
- previous = now;
71
- }
72
- let remaining: number = wait - now + previous;
73
- context = this;
74
- args = arguments;
75
- if (remaining <= 0 || remaining > wait) {
76
- if (timeout) {
77
- clearTimeout(timeout);
78
- timeout = 0;
79
- }
80
- previous = now;
81
- result = func.apply(context, args);
82
- if (!timeout) {
83
- context = args = null;
84
- }
85
- } else if (!timeout && options?.trailing !== false) {
86
- timeout = window.setTimeout(later, remaining);
87
- }
88
- return result;
89
- };
90
-
91
- return throttled;
92
- }
93
-
94
- /**
95
- * Ensures that a function `func` is called at most every `wait` milliseconds with optional leading and trailing calls
96
- * @param func - the function to throttle
97
- * @param wait - the amount of time between function calls
98
- * @param options - leading and trailing options: default = \{ leading: true, trailing, true \}
99
- * @returns - the throttled function as an EventListener
100
- */
101
- static throttleEvent (func: Function,
102
- wait: number = mintSettings.delay.default,
103
- options?: {[key: string]: boolean}) : EventListener {
104
- return mintUtil.throttle(func, wait, options) as EventListener;
105
- }
106
-
107
- /**
108
- * Sets the element's height to its `innerHeight`, then to `auto` after a delay
109
- * @param el - the element whose height will be set
110
- * @param delay - the amount of time in milliseconds that the show animation will be active
111
- * @param from - the side that the element is animating from
112
- */
113
- static show (el?: HTMLElement | null, delay: number = mintSettings.delay.default, from: mintSide = mintSide.Top) : void {
114
- if (el) {
115
- el.style.display = '';
116
- requestAnimationFrame(() => {
117
- if (from === mintSide.Top || from === mintSide.Bottom) {
118
- el.style.height = `${el.scrollHeight}px`;
119
- } else {
120
- el.style.width = `${el.scrollWidth}px`;
121
- }
122
-
123
- setTimeout(() => {
124
- if (from === mintSide.Top || from === mintSide.Bottom) {
125
- el.style.height = 'auto';
126
- } else {
127
- el.style.width = 'auto';
128
- }
129
- }, delay);
130
- });
131
- }
132
- }
133
-
134
- /**
135
- * Sets the element's height to 0
136
- * @param el - the element whose height will be set
137
- * @param delay - the amount of time in milliseconds that the show animation will be active
138
- * @param from - the side that the element is animating from
139
- */
140
- static hide (el?: HTMLElement | null, delay: number = mintSettings.delay.default, from: mintSide = mintSide.Top) : void {
141
- if (el) {
142
- let height = el.scrollHeight,
143
- width = el.scrollWidth,
144
- transition = el.style.transition;
145
- el.style.transition = '';
146
- requestAnimationFrame(() => {
147
- if (from === mintSide.Top || from === mintSide.Bottom) {
148
- el.style.height = `${height}px`;
149
- } else {
150
- el.style.width = `${width}px`;
151
- }
152
-
153
- el.style.transition = transition;
154
- requestAnimationFrame(() => {
155
- if (from === mintSide.Top || from === mintSide.Bottom) {
156
- el.style.height = '0';
157
- } else {
158
- el.style.width = '0';
159
- }
160
- });
161
- });
162
- setTimeout(() => {
163
- el.style.display = 'none';
164
- }, delay);
165
- }
166
- }
167
-
168
- /**
169
- * Copies the provided text to the clipboard
170
- * @param text - the text to copy
171
- * @returns - true if the text was successfully copied to the clipboard; else false
172
- */
173
- static copyText (text: string) : boolean {
174
- let textArea: HTMLTextAreaElement = document.createElement('textarea');
175
-
176
- if (!text || !textArea) {
177
- return false;
178
- }
179
-
180
- textArea.value = text;
181
- textArea.style.cssText = `
182
- position: fixed;
183
- top: 0;
184
- left: 0;
185
- transform: translate(-100%, -100%);
186
- opacity: 0;
187
- z-index: -1;
188
- `;
189
-
190
- document.body.appendChild(textArea);
191
- textArea.select();
192
- textArea.setSelectionRange(0, 99999);
193
- navigator.clipboard.writeText(textArea.value);
194
- document.body.removeChild(textArea);
195
-
196
- return true;
197
- }
198
-
199
- /**
200
- * Tests the validity of an email address
201
- * @see {@link https://stackoverflow.com/questions/201323/how-can-i-validate-an-email-address-using-a-regular-expression}
202
- * @param text - the string to test
203
- * @returns - true if the given string is an email address; false if not
204
- */
205
- static isEmail (text: string) : boolean {
206
- 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])+)\])/);
207
- }
208
- }
209
- export default mintUtil;