@appartmint/tsm-mint 0.0.1 → 0.0.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/dist/components/index.cjs.js +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.es.js +7 -7
- package/dist/components/title.cjs.js +1 -0
- package/dist/components/title.d.ts +3 -0
- package/dist/components/title.es.js +10 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +44 -15
- package/dist/types/index.cjs.js +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.es.js +4 -2
- package/dist/types/time.cjs.js +1 -0
- package/dist/types/time.d.ts +1 -0
- package/dist/types/time.es.js +4 -0
- package/dist/util/display.cjs.js +1 -0
- package/dist/util/display.d.ts +8 -0
- package/dist/util/display.es.js +36 -0
- package/dist/util/event.cjs.js +1 -0
- package/dist/util/event.d.ts +8 -0
- package/dist/util/event.es.js +30 -0
- package/dist/util/index.cjs.js +1 -1
- package/dist/util/index.d.ts +5 -0
- package/dist/util/index.es.js +32 -5
- package/dist/util/scroll.cjs.js +1 -0
- package/dist/util/scroll.d.ts +12 -0
- package/dist/util/scroll.es.js +31 -0
- package/dist/util/text.cjs.js +8 -0
- package/dist/util/text.d.ts +55 -0
- package/dist/util/text.es.js +81 -0
- package/dist/util/window.cjs.js +1 -0
- package/dist/util/window.d.ts +10 -0
- package/dist/util/window.es.js +12 -0
- package/package.json +1 -1
- package/dist/components/header.cjs.js +0 -1
- package/dist/components/header.d.ts +0 -3
- package/dist/components/header.es.js +0 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./grid.cjs.js"),i=require("./title.cjs.js");exports.gridNum=t.gridNum;exports.gridNumMax=t.gridNumMax;exports.gridNumMin=t.gridNumMin;exports.titleNum=i.titleNum;exports.titleNumMax=i.titleNumMax;exports.titleNumMin=i.titleNumMin;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './grid';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './title';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { gridNum as
|
|
2
|
-
import {
|
|
1
|
+
import { gridNum as t, gridNumMax as r, gridNumMin as u } from "./grid.es.js";
|
|
2
|
+
import { titleNum as e, titleNumMax as o, titleNumMin as x } from "./title.es.js";
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
t as gridNum,
|
|
5
|
+
r as gridNumMax,
|
|
6
6
|
u as gridNumMin,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
e as titleNum,
|
|
8
|
+
o as titleNumMax,
|
|
9
|
+
x as titleNumMin
|
|
10
10
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../util/math.cjs.js"),t=1,e=6;function l(i){return u.clamp(i,t,e)}exports.titleNum=l;exports.titleNumMax=e;exports.titleNumMin=t;
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./abstract/attaches-events.cjs.js"),i=require("./components/grid.cjs.js"),n=require("./components/title.cjs.js"),a=require("./types/box.cjs.js"),c=require("./types/time.cjs.js"),m=require("./util/async.cjs.js"),r=require("./util/display.cjs.js"),e=require("./util/event.cjs.js"),l=require("./util/math.cjs.js"),o=require("./util/scroll.cjs.js"),t=require("./util/text.cjs.js"),s=require("./util/window.cjs.js");exports.AttachesEvents=u.AttachesEvents;exports.gridNum=i.gridNum;exports.gridNumMax=i.gridNumMax;exports.gridNumMin=i.gridNumMin;exports.titleNum=n.titleNum;exports.titleNumMax=n.titleNumMax;exports.titleNumMin=n.titleNumMin;exports.boxPositions=a.boxPositions;exports.durationDefault=c.durationDefault;exports.wait=m.wait;exports.hideElement=r.hideElement;exports.showElement=r.showElement;exports.debounce=e.debounce;exports.debounceEvent=e.debounceEvent;exports.throttle=e.throttle;exports.throttleEvent=e.throttleEvent;exports.clamp=l.clamp;exports.randomInt=l.randomInt;exports.scrollTo=o.scrollTo;exports.showElements=o.showElements;exports.showElementsOnScroll=o.showElementsOnScroll;exports.copyText=t.copyText;exports.formatPhone=t.formatPhone;exports.generateId=t.generateId;exports.isEmail=t.isEmail;exports.isImage=t.isImage;exports.isVideo=t.isVideo;exports.plural=t.plural;exports.slug=t.slug;exports.titleCase=t.titleCase;exports.truncate=t.truncate;exports.unslug=t.unslug;exports.windowHeight=s.windowHeight;exports.windowWidth=s.windowWidth;
|
package/dist/index.es.js
CHANGED
|
@@ -1,19 +1,48 @@
|
|
|
1
|
-
import { AttachesEvents as
|
|
2
|
-
import { gridNum as
|
|
3
|
-
import {
|
|
1
|
+
import { AttachesEvents as o } from "./abstract/attaches-events.es.js";
|
|
2
|
+
import { gridNum as m, gridNumMax as i, gridNumMin as n } from "./components/grid.es.js";
|
|
3
|
+
import { titleNum as s, titleNumMax as x, titleNumMin as a } from "./components/title.es.js";
|
|
4
4
|
import { boxPositions as u } from "./types/box.es.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { durationDefault as d } from "./types/time.es.js";
|
|
6
|
+
import { wait as c } from "./util/async.es.js";
|
|
7
|
+
import { hideElement as w, showElement as E } from "./util/display.es.js";
|
|
8
|
+
import { debounce as M, debounceEvent as b, throttle as v, throttleEvent as I } from "./util/event.es.js";
|
|
9
|
+
import { clamp as T, randomInt as y } from "./util/math.es.js";
|
|
10
|
+
import { scrollTo as C, showElements as D, showElementsOnScroll as H } from "./util/scroll.es.js";
|
|
11
|
+
import { copyText as S, formatPhone as V, generateId as W, isEmail as j, isImage as k, isVideo as q, plural as z, slug as B, titleCase as F, truncate as G, unslug as J } from "./util/text.es.js";
|
|
12
|
+
import { windowHeight as L, windowWidth as Q } from "./util/window.es.js";
|
|
7
13
|
export {
|
|
8
|
-
|
|
14
|
+
o as AttachesEvents,
|
|
9
15
|
u as boxPositions,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
d as
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
T as clamp,
|
|
17
|
+
S as copyText,
|
|
18
|
+
M as debounce,
|
|
19
|
+
b as debounceEvent,
|
|
20
|
+
d as durationDefault,
|
|
21
|
+
V as formatPhone,
|
|
22
|
+
W as generateId,
|
|
23
|
+
m as gridNum,
|
|
24
|
+
i as gridNumMax,
|
|
25
|
+
n as gridNumMin,
|
|
26
|
+
w as hideElement,
|
|
27
|
+
j as isEmail,
|
|
28
|
+
k as isImage,
|
|
29
|
+
q as isVideo,
|
|
30
|
+
z as plural,
|
|
31
|
+
y as randomInt,
|
|
32
|
+
C as scrollTo,
|
|
33
|
+
E as showElement,
|
|
34
|
+
D as showElements,
|
|
35
|
+
H as showElementsOnScroll,
|
|
36
|
+
B as slug,
|
|
37
|
+
v as throttle,
|
|
38
|
+
I as throttleEvent,
|
|
39
|
+
F as titleCase,
|
|
40
|
+
s as titleNum,
|
|
41
|
+
x as titleNumMax,
|
|
42
|
+
a as titleNumMin,
|
|
43
|
+
G as truncate,
|
|
44
|
+
J as unslug,
|
|
45
|
+
c as wait,
|
|
46
|
+
L as windowHeight,
|
|
47
|
+
Q as windowWidth
|
|
19
48
|
};
|
package/dist/types/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./box.cjs.js"),e=require("./time.cjs.js");exports.boxPositions=t.boxPositions;exports.durationDefault=e.durationDefault;
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.es.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=300;exports.durationDefault=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const durationDefault: 300;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../types/box.cjs.js"),l=require("../types/time.cjs.js");function h({el:t,duration:s=l.durationDefault,from:e=r.boxPositions[0]}){if(!t)return;const i=e==="top"||e==="bottom",{scrollHeight:o,scrollWidth:n}=t;t.style.display="",requestAnimationFrame(()=>{i?t.style.height=`${o}px`:t.style.width=`${n}px`,setTimeout(()=>{i?t.style.height="auto":t.style.width="auto"},s)})}function u({el:t,duration:s=l.durationDefault,from:e=r.boxPositions[0]}){if(!t)return;const i=e==="top"||e==="bottom",{scrollHeight:o,scrollWidth:n,style:{transition:a}}=t;t.style.transition="",requestAnimationFrame(()=>{i?t.style.height=`${o}px`:t.style.width=`${n}px`,t.style.transition=a,requestAnimationFrame(()=>{i?t.style.height="0":t.style.width="0"})}),setTimeout(()=>{t.style.display="none"},s)}exports.hideElement=u;exports.showElement=h;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BoxPosition } from '../types/box';
|
|
2
|
+
export interface TransitionProps {
|
|
3
|
+
el?: HTMLElement | null;
|
|
4
|
+
duration: number;
|
|
5
|
+
from: BoxPosition;
|
|
6
|
+
}
|
|
7
|
+
export declare function showElement({ el, duration, from, }: TransitionProps): void;
|
|
8
|
+
export declare function hideElement({ el, duration, from, }: TransitionProps): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { boxPositions as r } from "../types/box.es.js";
|
|
2
|
+
import { durationDefault as h } from "../types/time.es.js";
|
|
3
|
+
function m({
|
|
4
|
+
el: t,
|
|
5
|
+
duration: s = h,
|
|
6
|
+
from: i = r[0]
|
|
7
|
+
}) {
|
|
8
|
+
if (!t)
|
|
9
|
+
return;
|
|
10
|
+
const e = i === "top" || i === "bottom", { scrollHeight: o, scrollWidth: n } = t;
|
|
11
|
+
t.style.display = "", requestAnimationFrame(() => {
|
|
12
|
+
e ? t.style.height = `${o}px` : t.style.width = `${n}px`, setTimeout(() => {
|
|
13
|
+
e ? t.style.height = "auto" : t.style.width = "auto";
|
|
14
|
+
}, s);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function u({
|
|
18
|
+
el: t,
|
|
19
|
+
duration: s = h,
|
|
20
|
+
from: i = r[0]
|
|
21
|
+
}) {
|
|
22
|
+
if (!t)
|
|
23
|
+
return;
|
|
24
|
+
const e = i === "top" || i === "bottom", { scrollHeight: o, scrollWidth: n, style: { transition: l } } = t;
|
|
25
|
+
t.style.transition = "", requestAnimationFrame(() => {
|
|
26
|
+
e ? t.style.height = `${o}px` : t.style.width = `${n}px`, t.style.transition = l, requestAnimationFrame(() => {
|
|
27
|
+
e ? t.style.height = "0" : t.style.width = "0";
|
|
28
|
+
});
|
|
29
|
+
}), setTimeout(() => {
|
|
30
|
+
t.style.display = "none";
|
|
31
|
+
}, s);
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
u as hideElement,
|
|
35
|
+
m as showElement
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../types/time.cjs.js");function m(t,u=i.durationDefault){let e;return function(...l){e&&clearTimeout(e),e=Number(setTimeout(t,u,...l))}}function h(t,u=i.durationDefault){return m(t,u)}function g(t,u=i.durationDefault,e){let l,n,f,r,a=0,b=function(){a=(e==null?void 0:e.leading)===!1?0:new Date().getTime(),r=0,f=t.apply(l,n),r||(l=n=null)};return function(){let c=new Date().getTime();!a&&(e==null?void 0:e.leading)===!1&&(a=c);let d=u-c+a;return l=this,n=arguments,d<=0||d>u?(r&&(clearTimeout(r),r=0),a=c,f=t.apply(l,n),r||(l=n=null)):!r&&(e==null?void 0:e.trailing)!==!1&&(r=window.setTimeout(b,d)),f}}function o(t,u=i.durationDefault,e){return g(t,u,e)}exports.debounce=m;exports.debounceEvent=h;exports.throttle=g;exports.throttleEvent=o;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function debounce<T extends (...args: Parameters<T>) => ReturnType<T>>(func: T, wait?: number): (...args: Parameters<T>) => void;
|
|
2
|
+
export declare function debounceEvent<T extends (e: Event) => ReturnType<T>>(func: T, wait?: number): EventListener;
|
|
3
|
+
export declare function throttle(func: Function, wait?: number, options?: {
|
|
4
|
+
[key: string]: boolean;
|
|
5
|
+
}): Function;
|
|
6
|
+
export declare function throttleEvent(func: Function, wait?: number, options?: {
|
|
7
|
+
[key: string]: boolean;
|
|
8
|
+
}): EventListener;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { durationDefault as i } from "../types/time.es.js";
|
|
2
|
+
function g(t, r = i) {
|
|
3
|
+
let e;
|
|
4
|
+
return function(...u) {
|
|
5
|
+
e && clearTimeout(e), e = Number(setTimeout(t, r, ...u));
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
function b(t, r = i) {
|
|
9
|
+
return g(t, r);
|
|
10
|
+
}
|
|
11
|
+
function T(t, r = i, e) {
|
|
12
|
+
let u, n, a, l, f = 0, d = function() {
|
|
13
|
+
f = (e == null ? void 0 : e.leading) === !1 ? 0 : (/* @__PURE__ */ new Date()).getTime(), l = 0, a = t.apply(u, n), l || (u = n = null);
|
|
14
|
+
};
|
|
15
|
+
return function() {
|
|
16
|
+
let m = (/* @__PURE__ */ new Date()).getTime();
|
|
17
|
+
!f && (e == null ? void 0 : e.leading) === !1 && (f = m);
|
|
18
|
+
let c = r - m + f;
|
|
19
|
+
return u = this, n = arguments, c <= 0 || c > r ? (l && (clearTimeout(l), l = 0), f = m, a = t.apply(u, n), l || (u = n = null)) : !l && (e == null ? void 0 : e.trailing) !== !1 && (l = window.setTimeout(d, c)), a;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function v(t, r = i, e) {
|
|
23
|
+
return T(t, r, e);
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
g as debounce,
|
|
27
|
+
b as debounceEvent,
|
|
28
|
+
T as throttle,
|
|
29
|
+
v as throttleEvent
|
|
30
|
+
};
|
package/dist/util/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./async.cjs.js"),o=require("./display.cjs.js"),t=require("./event.cjs.js"),n=require("./math.cjs.js"),l=require("./scroll.cjs.js"),e=require("./text.cjs.js"),i=require("./window.cjs.js");exports.wait=r.wait;exports.hideElement=o.hideElement;exports.showElement=o.showElement;exports.debounce=t.debounce;exports.debounceEvent=t.debounceEvent;exports.throttle=t.throttle;exports.throttleEvent=t.throttleEvent;exports.clamp=n.clamp;exports.randomInt=n.randomInt;exports.scrollTo=l.scrollTo;exports.showElements=l.showElements;exports.showElementsOnScroll=l.showElementsOnScroll;exports.copyText=e.copyText;exports.formatPhone=e.formatPhone;exports.generateId=e.generateId;exports.isEmail=e.isEmail;exports.isImage=e.isImage;exports.isVideo=e.isVideo;exports.plural=e.plural;exports.slug=e.slug;exports.titleCase=e.titleCase;exports.truncate=e.truncate;exports.unslug=e.unslug;exports.windowHeight=i.windowHeight;exports.windowWidth=i.windowWidth;
|
package/dist/util/index.d.ts
CHANGED
package/dist/util/index.es.js
CHANGED
|
@@ -1,7 +1,34 @@
|
|
|
1
|
-
import { wait as
|
|
2
|
-
import {
|
|
1
|
+
import { wait as t } from "./async.es.js";
|
|
2
|
+
import { hideElement as l, showElement as n } from "./display.es.js";
|
|
3
|
+
import { debounce as i, debounceEvent as s, throttle as a, throttleEvent as p } from "./event.es.js";
|
|
4
|
+
import { clamp as h, randomInt as f } from "./math.es.js";
|
|
5
|
+
import { scrollTo as x, showElements as c, showElementsOnScroll as u } from "./scroll.es.js";
|
|
6
|
+
import { copyText as g, formatPhone as I, generateId as b, isEmail as v, isImage as T, isVideo as y, plural as C, slug as H, titleCase as O, truncate as P, unslug as S } from "./text.es.js";
|
|
7
|
+
import { windowHeight as W, windowWidth as j } from "./window.es.js";
|
|
3
8
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
h as clamp,
|
|
10
|
+
g as copyText,
|
|
11
|
+
i as debounce,
|
|
12
|
+
s as debounceEvent,
|
|
13
|
+
I as formatPhone,
|
|
14
|
+
b as generateId,
|
|
15
|
+
l as hideElement,
|
|
16
|
+
v as isEmail,
|
|
17
|
+
T as isImage,
|
|
18
|
+
y as isVideo,
|
|
19
|
+
C as plural,
|
|
20
|
+
f as randomInt,
|
|
21
|
+
x as scrollTo,
|
|
22
|
+
n as showElement,
|
|
23
|
+
c as showElements,
|
|
24
|
+
u as showElementsOnScroll,
|
|
25
|
+
H as slug,
|
|
26
|
+
a as throttle,
|
|
27
|
+
p as throttleEvent,
|
|
28
|
+
O as titleCase,
|
|
29
|
+
P as truncate,
|
|
30
|
+
S as unslug,
|
|
31
|
+
t as wait,
|
|
32
|
+
W as windowHeight,
|
|
33
|
+
j as windowWidth
|
|
7
34
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./event.cjs.js");function s(t){switch(t){case"top":t=0;break;case"bottom":t=document.body.scrollHeight;break}window.scrollTo(0,t)}function o(){requestAnimationFrame(()=>{let t=document.querySelectorAll(".mint-fall-in:not(.mint-show)"),n=[];for(let e=0;e<t.length;e++)t[e].getBoundingClientRect().top<0?t[e].classList.add("mint-show"):t[e].getBoundingClientRect().top<window.innerHeight*3/4&&n.push(t[e]);for(let e=0;e<n.length;e++)setTimeout(()=>{n[e].classList.add("mint-show")},e*100)})}function i(){window.addEventListener("scroll",l.throttleEvent(o,200))}exports.scrollTo=s;exports.showElements=o;exports.showElementsOnScroll=i;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scroll to the top of the page
|
|
3
|
+
*/
|
|
4
|
+
export declare function scrollTo(to: number | 'top' | 'bottom'): void;
|
|
5
|
+
/**
|
|
6
|
+
* Show visible elements
|
|
7
|
+
*/
|
|
8
|
+
export declare function showElements(): void;
|
|
9
|
+
/**
|
|
10
|
+
* Show visible elements on scroll
|
|
11
|
+
*/
|
|
12
|
+
export declare function showElementsOnScroll(): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { throttleEvent as o } from "./event.es.js";
|
|
2
|
+
function s(t) {
|
|
3
|
+
switch (t) {
|
|
4
|
+
case "top":
|
|
5
|
+
t = 0;
|
|
6
|
+
break;
|
|
7
|
+
case "bottom":
|
|
8
|
+
t = document.body.scrollHeight;
|
|
9
|
+
break;
|
|
10
|
+
}
|
|
11
|
+
window.scrollTo(0, t);
|
|
12
|
+
}
|
|
13
|
+
function i() {
|
|
14
|
+
requestAnimationFrame(() => {
|
|
15
|
+
let t = document.querySelectorAll(".mint-fall-in:not(.mint-show)"), n = [];
|
|
16
|
+
for (let e = 0; e < t.length; e++)
|
|
17
|
+
t[e].getBoundingClientRect().top < 0 ? t[e].classList.add("mint-show") : t[e].getBoundingClientRect().top < window.innerHeight * 3 / 4 && n.push(t[e]);
|
|
18
|
+
for (let e = 0; e < n.length; e++)
|
|
19
|
+
setTimeout(() => {
|
|
20
|
+
n[e].classList.add("mint-show");
|
|
21
|
+
}, e * 100);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function r() {
|
|
25
|
+
window.addEventListener("scroll", o(i, 200));
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
s as scrollTo,
|
|
29
|
+
i as showElements,
|
|
30
|
+
r as showElementsOnScroll
|
|
31
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(e,t=100){return e.length>t?e.slice(0,t).trim()+"...":e}function u(e){return(e==null?void 0:e.trim().toLowerCase().replace(/'/g,"").replace(/[^\w/-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"").replace(/^\/+|\/+$/g,""))??""}function l(e){return s(e.replace(/[-/]+/g," "))}function c(e){const t=(e==null?void 0:e.toString().trim())??"";if(t==="("||t==="")return t;let n=t.replace(/\D/g,"")??"",a="";n.length>10&&(a+=`+${n.slice(0,n.length-10)} `,n=n.slice(n.length-10));for(var i=0;i<n.length;i++){switch(i){case 0:a+="(";break;case 3:a+=") ";break;case 6:a+="-";break}a+=n[i]}switch(t[t.length-1]){case")":i===3&&(a+=") ");break;case"-":i===6&&(a+="-");break}return a}function g(e){return e.endsWith("ies")||e.endsWith("es")||e.endsWith("s")&&!e.endsWith("us")&&!e.endsWith("is")&&!e.endsWith("ss")?e:e.endsWith("y")&&!["a","e","i","o","u"].includes(e.charAt(e.length-2))?e.slice(0,-1)+"ies":e.endsWith("s")||e.endsWith("sh")||e.endsWith("ch")||e.endsWith("x")||e.endsWith("z")?e+"es":e+"s"}function s(e){return e.toLowerCase().replace(/(?:^|\s)\S/g,t=>t.toUpperCase())}function f(e){let t=document.createElement("textarea");return!e||!t?!1:(t.value=e,t.style.cssText=`
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: 0;
|
|
4
|
+
left: 0;
|
|
5
|
+
transform: translate(-100%, -100%);
|
|
6
|
+
opacity: 0;
|
|
7
|
+
z-index: -1;
|
|
8
|
+
`,document.body.appendChild(t),t.select(),t.setSelectionRange(0,99999),navigator.clipboard.writeText(t.value),document.body.removeChild(t),!0)}function x(e){return e.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])+)\])/)!==null}function o(e=10){return Math.random().toString(36).substring(2,e+2)}function h(e){return!!(e!=null&&e.match(/\.(jpe?g|png|webp|gif|svg)$/i))}function m(e){return!!(e!=null&&e.match(/\.(mp4|webm|ogg)$/i))}exports.copyText=f;exports.formatPhone=c;exports.generateId=o;exports.isEmail=x;exports.isImage=h;exports.isVideo=m;exports.plural=g;exports.slug=u;exports.titleCase=s;exports.truncate=r;exports.unslug=l;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shorten a string to the given length
|
|
3
|
+
*/
|
|
4
|
+
export declare function truncate(text: string, length?: number): string;
|
|
5
|
+
/**
|
|
6
|
+
* Generate a slug from a string
|
|
7
|
+
* @param text - The string to slugify
|
|
8
|
+
* @returns The slugified string
|
|
9
|
+
*/
|
|
10
|
+
export declare function slug(text?: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Generate a title from a slug
|
|
13
|
+
* @param slug - The slug to generate a title from
|
|
14
|
+
* @returns The title
|
|
15
|
+
*/
|
|
16
|
+
export declare function unslug(slug: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Format a phone number
|
|
19
|
+
* @param phone - The phone number to format
|
|
20
|
+
* @returns The formatted phone number
|
|
21
|
+
*/
|
|
22
|
+
export declare function formatPhone(phone?: string | number): string;
|
|
23
|
+
/**
|
|
24
|
+
* Pluralize the given word
|
|
25
|
+
*/
|
|
26
|
+
export declare function plural(word: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Capitalize the first letter of the given word
|
|
29
|
+
*/
|
|
30
|
+
export declare function titleCase(text: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Copies the provided text to the clipboard
|
|
33
|
+
* @param text - the text to copy
|
|
34
|
+
* @returns - true if the text was successfully copied to the clipboard; else false
|
|
35
|
+
*/
|
|
36
|
+
export declare function copyText(text: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Tests the validity of an email address
|
|
39
|
+
* @see {@link https://stackoverflow.com/questions/201323/how-can-i-validate-an-email-address-using-a-regular-expression}
|
|
40
|
+
* @param text - the string to test
|
|
41
|
+
* @returns - true if the given string is an email address; false if not
|
|
42
|
+
*/
|
|
43
|
+
export declare function isEmail(text: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Generate a random string [a-z0-9]
|
|
46
|
+
*/
|
|
47
|
+
export declare function generateId(length?: number): string;
|
|
48
|
+
/**
|
|
49
|
+
* Check if the given string is an image url
|
|
50
|
+
*/
|
|
51
|
+
export declare function isImage(src?: string): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Check if the given string is a video url
|
|
54
|
+
*/
|
|
55
|
+
export declare function isVideo(src?: string): boolean;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
function r(e, t = 100) {
|
|
2
|
+
return e.length > t ? e.slice(0, t).trim() + "..." : e;
|
|
3
|
+
}
|
|
4
|
+
function c(e) {
|
|
5
|
+
return (e == null ? void 0 : e.trim().toLowerCase().replace(/'/g, "").replace(/[^\w/-]+/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "").replace(/^\/+|\/+$/g, "")) ?? "";
|
|
6
|
+
}
|
|
7
|
+
function u(e) {
|
|
8
|
+
return s(e.replace(/[-/]+/g, " "));
|
|
9
|
+
}
|
|
10
|
+
function l(e) {
|
|
11
|
+
const t = (e == null ? void 0 : e.toString().trim()) ?? "";
|
|
12
|
+
if (t === "(" || t === "")
|
|
13
|
+
return t;
|
|
14
|
+
let n = t.replace(/\D/g, "") ?? "", a = "";
|
|
15
|
+
n.length > 10 && (a += `+${n.slice(0, n.length - 10)} `, n = n.slice(n.length - 10));
|
|
16
|
+
for (var i = 0; i < n.length; i++) {
|
|
17
|
+
switch (i) {
|
|
18
|
+
case 0:
|
|
19
|
+
a += "(";
|
|
20
|
+
break;
|
|
21
|
+
case 3:
|
|
22
|
+
a += ") ";
|
|
23
|
+
break;
|
|
24
|
+
case 6:
|
|
25
|
+
a += "-";
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
a += n[i];
|
|
29
|
+
}
|
|
30
|
+
switch (t[t.length - 1]) {
|
|
31
|
+
case ")":
|
|
32
|
+
i === 3 && (a += ") ");
|
|
33
|
+
break;
|
|
34
|
+
case "-":
|
|
35
|
+
i === 6 && (a += "-");
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
return a;
|
|
39
|
+
}
|
|
40
|
+
function x(e) {
|
|
41
|
+
return e.endsWith("ies") || e.endsWith("es") || e.endsWith("s") && !e.endsWith("us") && !e.endsWith("is") && !e.endsWith("ss") ? e : e.endsWith("y") && !["a", "e", "i", "o", "u"].includes(e.charAt(e.length - 2)) ? e.slice(0, -1) + "ies" : e.endsWith("s") || e.endsWith("sh") || e.endsWith("ch") || e.endsWith("x") || e.endsWith("z") ? e + "es" : e + "s";
|
|
42
|
+
}
|
|
43
|
+
function s(e) {
|
|
44
|
+
return e.toLowerCase().replace(/(?:^|\s)\S/g, (t) => t.toUpperCase());
|
|
45
|
+
}
|
|
46
|
+
function f(e) {
|
|
47
|
+
let t = document.createElement("textarea");
|
|
48
|
+
return !e || !t ? !1 : (t.value = e, t.style.cssText = `
|
|
49
|
+
position: fixed;
|
|
50
|
+
top: 0;
|
|
51
|
+
left: 0;
|
|
52
|
+
transform: translate(-100%, -100%);
|
|
53
|
+
opacity: 0;
|
|
54
|
+
z-index: -1;
|
|
55
|
+
`, document.body.appendChild(t), t.select(), t.setSelectionRange(0, 99999), navigator.clipboard.writeText(t.value), document.body.removeChild(t), !0);
|
|
56
|
+
}
|
|
57
|
+
function g(e) {
|
|
58
|
+
return e.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])+)\])/) !== null;
|
|
59
|
+
}
|
|
60
|
+
function h(e = 10) {
|
|
61
|
+
return Math.random().toString(36).substring(2, e + 2);
|
|
62
|
+
}
|
|
63
|
+
function o(e) {
|
|
64
|
+
return !!(e != null && e.match(/\.(jpe?g|png|webp|gif|svg)$/i));
|
|
65
|
+
}
|
|
66
|
+
function m(e) {
|
|
67
|
+
return !!(e != null && e.match(/\.(mp4|webm|ogg)$/i));
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
f as copyText,
|
|
71
|
+
l as formatPhone,
|
|
72
|
+
h as generateId,
|
|
73
|
+
g as isEmail,
|
|
74
|
+
o as isImage,
|
|
75
|
+
m as isVideo,
|
|
76
|
+
x as plural,
|
|
77
|
+
c as slug,
|
|
78
|
+
s as titleCase,
|
|
79
|
+
r as truncate,
|
|
80
|
+
u as unslug
|
|
81
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function t(){const n=document.body.getBoundingClientRect().width%1;return window.innerWidth+n}function i(){const n=document.body.getBoundingClientRect().height%1;return window.innerHeight+n}exports.windowHeight=i;exports.windowWidth=t;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the width of the window, including fractional pixels
|
|
3
|
+
* @returns the width of the window
|
|
4
|
+
*/
|
|
5
|
+
export declare function windowWidth(): number;
|
|
6
|
+
/**
|
|
7
|
+
* Returns the height of the window, including fractional pixels
|
|
8
|
+
* @returns the height of the window
|
|
9
|
+
*/
|
|
10
|
+
export declare function windowHeight(): number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function t() {
|
|
2
|
+
const n = document.body.getBoundingClientRect().width % 1;
|
|
3
|
+
return window.innerWidth + n;
|
|
4
|
+
}
|
|
5
|
+
function i() {
|
|
6
|
+
const n = document.body.getBoundingClientRect().height % 1;
|
|
7
|
+
return window.innerHeight + n;
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
i as windowHeight,
|
|
11
|
+
t as windowWidth
|
|
12
|
+
};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../util/math.cjs.js"),e=1,r=6;function a(t){return u.clamp(t,e,r)}exports.headerNum=a;exports.headerNumMax=r;exports.headerNumMin=e;
|