@aslam-dev/my-lib 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.
- package/dist/components/BigNote.d.ts +6 -0
- package/dist/components/BigNote.d.ts.map +1 -0
- package/dist/components/BigNote.js +55 -0
- package/dist/components/BigNote.js.map +1 -0
- package/dist/components/Note.d.ts +8 -0
- package/dist/components/Note.d.ts.map +1 -0
- package/dist/components/Note.js +10 -0
- package/dist/components/Note.js.map +1 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +3 -0
- package/dist/components/index.js.map +1 -0
- package/dist/datetime.d.ts +9 -0
- package/dist/datetime.d.ts.map +1 -0
- package/dist/datetime.js +10 -0
- package/dist/datetime.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/phone.d.ts +19 -0
- package/dist/phone.d.ts.map +1 -0
- package/dist/phone.js +46 -0
- package/dist/phone.js.map +1 -0
- package/dist/transformers.d.ts +14 -0
- package/dist/transformers.d.ts.map +1 -0
- package/dist/transformers.js +74 -0
- package/dist/transformers.js.map +1 -0
- package/package.json +27 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BigNote.d.ts","sourceRoot":"","sources":["../../src/components/BigNote.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf;AAcD,QAAA,MAAM,OAAO,GAAI,WAAW,YAAY,4CAuEvC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
+
/* ---------------------------------------------------------- */
|
|
4
|
+
/* NOTE: Content remains EXACTLY same as provided */
|
|
5
|
+
/* ---------------------------------------------------------- */
|
|
6
|
+
const content = `
|
|
7
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis purus turpis, pharetra eu placerat non, maximus ut mi. Vivamus lacus elit, finibus at tempor a, gravida vitae massa. Cras consequat eu urna et dapibus. Etiam auctor facilisis nunc, ac egestas orci euismod vitae. Donec in vehicula leo. Cras iaculis, sem eget rutrum maximus, eros quam lacinia leo, vitae convallis ipsum ipsum et arcu. Duis risus augue, ornare at ligula eget, mollis vehicula tellus. Sed vitae nibh metus. Morbi augue nisl, vulputate id tincidunt eu, pretium ac ipsum. Vivamus est lorem, ultrices non efficitur in, malesuada et ligula. In hac habitasse platea dictumst.
|
|
8
|
+
`.repeat(5000);
|
|
9
|
+
/* ---------------------------------------------------------- */
|
|
10
|
+
const CHUNK_SIZE = 1000;
|
|
11
|
+
const BigNote = ({ title }) => {
|
|
12
|
+
const [visibleContent, setVisibleContent] = useState("");
|
|
13
|
+
const [loading, setLoading] = useState(false);
|
|
14
|
+
const [contentIndex, setContentIndex] = useState(0);
|
|
15
|
+
const contentRef = useRef(null);
|
|
16
|
+
const observerRef = useRef(null);
|
|
17
|
+
/* ---------------- Load More Content ---------------- */
|
|
18
|
+
const loadMoreContent = useCallback(() => {
|
|
19
|
+
if (loading)
|
|
20
|
+
return;
|
|
21
|
+
setContentIndex((prevIndex) => {
|
|
22
|
+
if (prevIndex >= content.length)
|
|
23
|
+
return prevIndex;
|
|
24
|
+
setLoading(true);
|
|
25
|
+
setTimeout(() => {
|
|
26
|
+
const nextContent = content.slice(prevIndex, prevIndex + CHUNK_SIZE);
|
|
27
|
+
setVisibleContent((prev) => prev + nextContent);
|
|
28
|
+
setLoading(false);
|
|
29
|
+
}, 500);
|
|
30
|
+
return prevIndex + CHUNK_SIZE;
|
|
31
|
+
});
|
|
32
|
+
}, [loading]);
|
|
33
|
+
/* ---------------- Intersection Observer ---------------- */
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (!contentRef.current)
|
|
36
|
+
return;
|
|
37
|
+
observerRef.current = new IntersectionObserver(([entry]) => {
|
|
38
|
+
if (entry.isIntersecting) {
|
|
39
|
+
loadMoreContent();
|
|
40
|
+
}
|
|
41
|
+
}, { threshold: 1 });
|
|
42
|
+
observerRef.current.observe(contentRef.current);
|
|
43
|
+
return () => {
|
|
44
|
+
observerRef.current?.disconnect();
|
|
45
|
+
};
|
|
46
|
+
}, [loadMoreContent]);
|
|
47
|
+
/* ---------------- Initial Load ---------------- */
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
loadMoreContent();
|
|
50
|
+
}, [loadMoreContent]);
|
|
51
|
+
/* ---------------- Render ---------------- */
|
|
52
|
+
return (_jsxs("div", { className: "max-w-sm mx-auto bg-yellow-100 border-l-4 border-yellow-500 p-4 rounded shadow-md mt-4", children: [_jsx("h2", { className: "text-lg font-bold text-yellow-800", children: title }), _jsx("p", { className: "text-yellow-900 mt-2 whitespace-pre-wrap", children: visibleContent }), loading && _jsx("p", { className: "text-gray-500 mt-2", children: "Loading..." }), _jsx("div", { ref: contentRef, style: { height: 20 } })] }));
|
|
53
|
+
};
|
|
54
|
+
export default BigNote;
|
|
55
|
+
//# sourceMappingURL=BigNote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BigNote.js","sourceRoot":"","sources":["../../src/components/BigNote.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAMxE,gEAAgE;AAChE,gEAAgE;AAChE,gEAAgE;AAEhE,MAAM,OAAO,GAAG;;CAEf,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAEf,gEAAgE;AAEhE,MAAM,UAAU,GAAG,IAAI,CAAC;AAExB,MAAM,OAAO,GAAG,CAAC,EAAE,KAAK,EAAgB,EAAE,EAAE;IAC1C,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAS,E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AEF,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAEhD,OAAO,GAAG,EAAE;YACV,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC;QACpC,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;IAEtB,oDAAoD;IAEpD,SAAS,CAAC,GAAG,EAAE;QACb,eAAe,EAAE,CAAC;IACpB,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;IAEtB,8CAA8C;IAE9C,OAAO,CACL,eAAK,SAAS,EAAC,wFAAwF,aACrG,aAAI,SAAS,EAAC,mCAAmC,YAAE,KAAK,GAAM,EAE9D,YAAG,SAAS,EAAC,0CAA0C,YACpD,cAAc,GACb,EAEH,OAAO,IAAI,YAAG,SAAS,EAAC,oBAAoB,2BAAe,EAE5D,cAAK,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,GAAI,IAC3C,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Note.d.ts","sourceRoot":"","sources":["../../src/components/Note.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD,QAAA,MAAM,IAAI,GAAI,oBAAoB,QAAQ,CAAC,SAAS,CAAC,4CAOpD,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/* -------------------------------------------------------------------------- */
|
|
3
|
+
/* Note Component */
|
|
4
|
+
/* -------------------------------------------------------------------------- */
|
|
5
|
+
const Note = ({ title, content }) => {
|
|
6
|
+
return (_jsxs("div", { className: "max-w-sm mx-auto bg-yellow-100 border-l-4 border-yellow-500 p-4 rounded shadow-md mt-4", children: [_jsx("h2", { className: "text-lg font-bold text-yellow-800", children: title }), _jsx("p", { className: "text-yellow-900 mt-2", children: content })] }));
|
|
7
|
+
};
|
|
8
|
+
export default Note;
|
|
9
|
+
export { Note };
|
|
10
|
+
//# sourceMappingURL=Note.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Note.js","sourceRoot":"","sources":["../../src/components/Note.tsx"],"names":[],"mappings":";AAWA,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,MAAM,IAAI,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,EAAuB,EAAE,EAAE;IACvD,OAAO,CACL,eAAK,SAAS,EAAC,wFAAwF,aACrG,aAAI,SAAS,EAAC,mCAAmC,YAAE,KAAK,GAAM,EAC9D,YAAG,SAAS,EAAC,sBAAsB,YAAE,OAAO,GAAK,IAC7C,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AACzC,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AAGzC,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MomentInput } from "moment";
|
|
2
|
+
export declare const getCurrentDate: () => string;
|
|
3
|
+
export declare const getTomorrowDate: () => string;
|
|
4
|
+
export declare const getFutureDate: (days?: number) => string;
|
|
5
|
+
export declare const isLeapYear: () => boolean;
|
|
6
|
+
export declare const getCurrentYear: () => number;
|
|
7
|
+
export declare const formatDate: (date: MomentInput) => string;
|
|
8
|
+
export declare const getRelativeTime: (date: MomentInput) => string;
|
|
9
|
+
//# sourceMappingURL=datetime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datetime.d.ts","sourceRoot":"","sources":["../src/datetime.ts"],"names":[],"mappings":"AAAA,OAAe,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAI7C,eAAO,MAAM,cAAc,QAAO,MAAyC,CAAC;AAE5E,eAAO,MAAM,eAAe,QAAO,MACa,CAAC;AAEjD,eAAO,MAAM,aAAa,GAAI,OAAM,MAAW,KAAG,MACC,CAAC;AAEpD,eAAO,MAAM,UAAU,QAAO,OAAgC,CAAC;AAE/D,eAAO,MAAM,cAAc,QAAO,MAAyB,CAAC;AAE5D,eAAO,MAAM,UAAU,GAAI,MAAM,WAAW,KAAG,MACV,CAAC;AAEtC,eAAO,MAAM,eAAe,GAAI,MAAM,WAAW,KAAG,MAC5B,CAAC"}
|
package/dist/datetime.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import moment from "moment";
|
|
2
|
+
const DEFAULT_FORMAT = "MMMM DD, YYYY";
|
|
3
|
+
export const getCurrentDate = () => moment().format(DEFAULT_FORMAT);
|
|
4
|
+
export const getTomorrowDate = () => moment().add(1, "days").format(DEFAULT_FORMAT);
|
|
5
|
+
export const getFutureDate = (days = 30) => moment().add(days, "days").format(DEFAULT_FORMAT);
|
|
6
|
+
export const isLeapYear = () => moment().isLeapYear();
|
|
7
|
+
export const getCurrentYear = () => moment().year();
|
|
8
|
+
export const formatDate = (date) => moment(date).format(DEFAULT_FORMAT);
|
|
9
|
+
export const getRelativeTime = (date) => moment(date).fromNow();
|
|
10
|
+
//# sourceMappingURL=datetime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datetime.js","sourceRoot":"","sources":["../src/datetime.ts"],"names":[],"mappings":"AAAA,OAAO,MAAuB,MAAM,QAAQ,CAAC;AAE7C,MAAM,cAAc,GAAG,eAAe,CAAC;AAEvC,MAAM,CAAC,MAAM,cAAc,GAAG,GAAW,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AAE5E,MAAM,CAAC,MAAM,eAAe,GAAG,GAAW,EAAE,CAC1C,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AAEjD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAe,EAAE,EAAU,EAAE,CACzD,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AAEpD,MAAM,CAAC,MAAM,UAAU,GAAG,GAAY,EAAE,CAAC,MAAM,EAAE,CAAC,UAAU,EAAE,CAAC;AAE/D,MAAM,CAAC,MAAM,cAAc,GAAG,GAAW,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;AAE5D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAiB,EAAU,EAAE,CACtD,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AAEtC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAiB,EAAU,EAAE,CAC3D,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAI/B,cAAc,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* -------------------------------------------------------------------------- */
|
|
2
|
+
/* @aslam-dev/my-lib */
|
|
3
|
+
/* -------------------------------------------------------------------------- */
|
|
4
|
+
/*
|
|
5
|
+
Public Export Surface
|
|
6
|
+
|
|
7
|
+
Consumers should import ONLY from this root file.
|
|
8
|
+
|
|
9
|
+
Example:
|
|
10
|
+
import { getCurrentDate, Note } from "@aslam-dev/my-lib";
|
|
11
|
+
*/
|
|
12
|
+
/* ---------- Utilities ---------- */
|
|
13
|
+
export * from "./datetime";
|
|
14
|
+
export * from "./phone";
|
|
15
|
+
export * from "./transformers";
|
|
16
|
+
/* ---------- Components ---------- */
|
|
17
|
+
export * from "./components";
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAChF;;;;;;;EAOE;AAEF,qCAAqC;AAErC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAE/B,sCAAsC;AAEtC,cAAc,cAAc,CAAC"}
|
package/dist/phone.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type CountryCode, type NumberType } from "libphonenumber-js";
|
|
2
|
+
export declare function validatePhoneNumber(phoneNumber: string, country?: CountryCode): boolean;
|
|
3
|
+
export declare function formatPhoneNumber(phoneNumber: string, country?: CountryCode): string;
|
|
4
|
+
export declare function getPhoneNumberType(phoneNumber: string, country?: CountryCode): NumberType | undefined;
|
|
5
|
+
export declare function getCountryCode(phoneNumber: string, country?: CountryCode): CountryCode | undefined;
|
|
6
|
+
export interface ParsedPhoneSuccess {
|
|
7
|
+
isValid: true;
|
|
8
|
+
international: string;
|
|
9
|
+
national: string;
|
|
10
|
+
country?: CountryCode;
|
|
11
|
+
type?: NumberType;
|
|
12
|
+
}
|
|
13
|
+
export interface ParsedPhoneFailure {
|
|
14
|
+
isValid: false;
|
|
15
|
+
error: string;
|
|
16
|
+
}
|
|
17
|
+
export type ParsedPhoneResult = ParsedPhoneSuccess | ParsedPhoneFailure;
|
|
18
|
+
export declare function parsePhone(phoneNumber: string, country?: CountryCode): ParsedPhoneResult;
|
|
19
|
+
//# sourceMappingURL=phone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone.d.ts","sourceRoot":"","sources":["../src/phone.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,mBAAmB,CAAC;AAM3B,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,WAAkB,GAC1B,OAAO,CAGT;AAMD,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,WAAkB,GAC1B,MAAM,CAGR;AAMD,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,WAAkB,GAC1B,UAAU,GAAG,SAAS,CAGxB;AAMD,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,WAAkB,GAC1B,WAAW,GAAG,SAAS,CAGzB;AAMD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,IAAI,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;AAExE,wBAAgB,UAAU,CACxB,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,WAAkB,GAC1B,iBAAiB,CAiBnB"}
|
package/dist/phone.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { parsePhoneNumberFromString, } from "libphonenumber-js";
|
|
2
|
+
/* -------------------------------------------------------------------------- */
|
|
3
|
+
/* Validate Phone Number */
|
|
4
|
+
/* -------------------------------------------------------------------------- */
|
|
5
|
+
export function validatePhoneNumber(phoneNumber, country = "US") {
|
|
6
|
+
const phone = parsePhoneNumberFromString(phoneNumber, country);
|
|
7
|
+
return phone?.isValid() ?? false;
|
|
8
|
+
}
|
|
9
|
+
/* -------------------------------------------------------------------------- */
|
|
10
|
+
/* Format Phone Number */
|
|
11
|
+
/* -------------------------------------------------------------------------- */
|
|
12
|
+
export function formatPhoneNumber(phoneNumber, country = "US") {
|
|
13
|
+
const phone = parsePhoneNumberFromString(phoneNumber, country);
|
|
14
|
+
return phone?.formatInternational() ?? phoneNumber;
|
|
15
|
+
}
|
|
16
|
+
/* -------------------------------------------------------------------------- */
|
|
17
|
+
/* Get Phone Number Type */
|
|
18
|
+
/* -------------------------------------------------------------------------- */
|
|
19
|
+
export function getPhoneNumberType(phoneNumber, country = "US") {
|
|
20
|
+
const phone = parsePhoneNumberFromString(phoneNumber, country);
|
|
21
|
+
return phone?.getType();
|
|
22
|
+
}
|
|
23
|
+
/* -------------------------------------------------------------------------- */
|
|
24
|
+
/* Get Country Code */
|
|
25
|
+
/* -------------------------------------------------------------------------- */
|
|
26
|
+
export function getCountryCode(phoneNumber, country = "US") {
|
|
27
|
+
const phone = parsePhoneNumberFromString(phoneNumber, country);
|
|
28
|
+
return phone?.country;
|
|
29
|
+
}
|
|
30
|
+
export function parsePhone(phoneNumber, country = "US") {
|
|
31
|
+
const phone = parsePhoneNumberFromString(phoneNumber, country);
|
|
32
|
+
if (!phone || !phone.isValid()) {
|
|
33
|
+
return {
|
|
34
|
+
isValid: false,
|
|
35
|
+
error: "Invalid phone number",
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
isValid: true,
|
|
40
|
+
international: phone.formatInternational(),
|
|
41
|
+
national: phone.formatNational(),
|
|
42
|
+
country: phone.country,
|
|
43
|
+
type: phone.getType(),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=phone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone.js","sourceRoot":"","sources":["../src/phone.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,GAG3B,MAAM,mBAAmB,CAAC;AAE3B,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,MAAM,UAAU,mBAAmB,CACjC,WAAmB,EACnB,UAAuB,IAAI;IAE3B,MAAM,KAAK,GAAG,0BAA0B,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,KAAK,CAAC;AACnC,CAAC;AAED,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,MAAM,UAAU,iBAAiB,CAC/B,WAAmB,EACnB,UAAuB,IAAI;IAE3B,MAAM,KAAK,GAAG,0BAA0B,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,IAAI,WAAW,CAAC;AACrD,CAAC;AAED,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,MAAM,UAAU,kBAAkB,CAChC,WAAmB,EACnB,UAAuB,IAAI;IAE3B,MAAM,KAAK,GAAG,0BAA0B,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,CAAC;AAC1B,CAAC;AAED,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,MAAM,UAAU,cAAc,CAC5B,WAAmB,EACnB,UAAuB,IAAI;IAE3B,MAAM,KAAK,GAAG,0BAA0B,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC/D,OAAO,KAAK,EAAE,OAAO,CAAC;AACxB,CAAC;AAqBD,MAAM,UAAU,UAAU,CACxB,WAAmB,EACnB,UAAuB,IAAI;IAE3B,MAAM,KAAK,GAAG,0BAA0B,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAE/D,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;QAC/B,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,sBAAsB;SAC9B,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,aAAa,EAAE,KAAK,CAAC,mBAAmB,EAAE;QAC1C,QAAQ,EAAE,KAAK,CAAC,cAAc,EAAE;QAChC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE;KACtB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
export declare function transformArray<T, R>(array: readonly T[], iteratee: (value: T, index: number, array: readonly T[]) => R): R[];
|
|
3
|
+
export declare function groupByProperty<T>(array: readonly T[], property: keyof T): Record<string, T[]>;
|
|
4
|
+
export declare function chunkArray<T>(array: readonly T[], size?: number): T[][];
|
|
5
|
+
export declare function getUnique<T>(array: readonly T[]): T[];
|
|
6
|
+
export declare function sortByProperty<T>(array: readonly T[], property: keyof T, order?: "asc" | "desc"): T[];
|
|
7
|
+
export declare function deepClone<T>(obj: T): T;
|
|
8
|
+
export declare function flattenArray<T>(array: readonly T[][]): T[];
|
|
9
|
+
export declare function arrayDifference<T>(array1: readonly T[], array2: readonly T[]): T[];
|
|
10
|
+
export declare function debounceFunction<F extends (...args: any[]) => any>(func: F, wait?: number): _.DebouncedFunc<F>;
|
|
11
|
+
export declare function throttleFunction<F extends (...args: any[]) => any>(func: F, wait?: number): _.DebouncedFunc<F>;
|
|
12
|
+
export declare function pickProperties<T extends object, K extends keyof T>(obj: T, properties: readonly K[]): Pick<T, K>;
|
|
13
|
+
export declare function omitProperties<T extends object, K extends keyof T>(obj: T, properties: readonly K[]): Omit<T, K>;
|
|
14
|
+
//# sourceMappingURL=transformers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../src/transformers.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,QAAQ,CAAC;AAMvB,wBAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,EACjC,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,KAAK,CAAC,GAC5D,CAAC,EAAE,CAEL;AAMD,wBAAgB,eAAe,CAAC,CAAC,EAC/B,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,QAAQ,EAAE,MAAM,CAAC,GAChB,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAErB;AAMD,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,SAAI,GAAG,CAAC,EAAE,EAAE,CAElE;AAMD,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,EAAE,CAErD;AAMD,wBAAgB,cAAc,CAAC,CAAC,EAC9B,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,QAAQ,EAAE,MAAM,CAAC,EACjB,KAAK,GAAE,KAAK,GAAG,MAAc,GAC5B,CAAC,EAAE,CAEL;AAMD,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAEtC;AAMD,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAE1D;AAMD,wBAAgB,eAAe,CAAC,CAAC,EAC/B,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,MAAM,EAAE,SAAS,CAAC,EAAE,GACnB,CAAC,EAAE,CAEL;AAMD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAChE,IAAI,EAAE,CAAC,EACP,IAAI,SAAM,GACT,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAEpB;AAMD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAChE,IAAI,EAAE,CAAC,EACP,IAAI,SAAM,GACT,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAEpB;AAMD,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAChE,GAAG,EAAE,CAAC,EACN,UAAU,EAAE,SAAS,CAAC,EAAE,GACvB,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAEZ;AAMD,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAChE,GAAG,EAAE,CAAC,EACN,UAAU,EAAE,SAAS,CAAC,EAAE,GACvB,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAEZ"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
/* -------------------------------------------------------------------------- */
|
|
3
|
+
/* Array Mapping */
|
|
4
|
+
/* -------------------------------------------------------------------------- */
|
|
5
|
+
export function transformArray(array, iteratee) {
|
|
6
|
+
return _.map(array, iteratee);
|
|
7
|
+
}
|
|
8
|
+
/* -------------------------------------------------------------------------- */
|
|
9
|
+
/* Group By Property */
|
|
10
|
+
/* -------------------------------------------------------------------------- */
|
|
11
|
+
export function groupByProperty(array, property) {
|
|
12
|
+
return _.groupBy(array, property);
|
|
13
|
+
}
|
|
14
|
+
/* -------------------------------------------------------------------------- */
|
|
15
|
+
/* Chunk Array */
|
|
16
|
+
/* -------------------------------------------------------------------------- */
|
|
17
|
+
export function chunkArray(array, size = 2) {
|
|
18
|
+
return _.chunk([...array], size);
|
|
19
|
+
}
|
|
20
|
+
/* -------------------------------------------------------------------------- */
|
|
21
|
+
/* Unique Values */
|
|
22
|
+
/* -------------------------------------------------------------------------- */
|
|
23
|
+
export function getUnique(array) {
|
|
24
|
+
return _.uniq([...array]);
|
|
25
|
+
}
|
|
26
|
+
/* -------------------------------------------------------------------------- */
|
|
27
|
+
/* Sort By Property */
|
|
28
|
+
/* -------------------------------------------------------------------------- */
|
|
29
|
+
export function sortByProperty(array, property, order = "asc") {
|
|
30
|
+
return _.orderBy([...array], [property], [order]);
|
|
31
|
+
}
|
|
32
|
+
/* -------------------------------------------------------------------------- */
|
|
33
|
+
/* Deep Clone */
|
|
34
|
+
/* -------------------------------------------------------------------------- */
|
|
35
|
+
export function deepClone(obj) {
|
|
36
|
+
return _.cloneDeep(obj);
|
|
37
|
+
}
|
|
38
|
+
/* -------------------------------------------------------------------------- */
|
|
39
|
+
/* Flatten Array */
|
|
40
|
+
/* -------------------------------------------------------------------------- */
|
|
41
|
+
export function flattenArray(array) {
|
|
42
|
+
return _.flatten([...array]);
|
|
43
|
+
}
|
|
44
|
+
/* -------------------------------------------------------------------------- */
|
|
45
|
+
/* Array Difference */
|
|
46
|
+
/* -------------------------------------------------------------------------- */
|
|
47
|
+
export function arrayDifference(array1, array2) {
|
|
48
|
+
return _.difference([...array1], [...array2]);
|
|
49
|
+
}
|
|
50
|
+
/* -------------------------------------------------------------------------- */
|
|
51
|
+
/* Debounce Function */
|
|
52
|
+
/* -------------------------------------------------------------------------- */
|
|
53
|
+
export function debounceFunction(func, wait = 300) {
|
|
54
|
+
return _.debounce(func, wait);
|
|
55
|
+
}
|
|
56
|
+
/* -------------------------------------------------------------------------- */
|
|
57
|
+
/* Throttle Function */
|
|
58
|
+
/* -------------------------------------------------------------------------- */
|
|
59
|
+
export function throttleFunction(func, wait = 300) {
|
|
60
|
+
return _.throttle(func, wait);
|
|
61
|
+
}
|
|
62
|
+
/* -------------------------------------------------------------------------- */
|
|
63
|
+
/* Pick Object Properties */
|
|
64
|
+
/* -------------------------------------------------------------------------- */
|
|
65
|
+
export function pickProperties(obj, properties) {
|
|
66
|
+
return _.pick(obj, properties);
|
|
67
|
+
}
|
|
68
|
+
/* -------------------------------------------------------------------------- */
|
|
69
|
+
/* Omit Object Properties */
|
|
70
|
+
/* -------------------------------------------------------------------------- */
|
|
71
|
+
export function omitProperties(obj, properties) {
|
|
72
|
+
return _.omit(obj, properties);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=transformers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformers.js","sourceRoot":"","sources":["../src/transformers.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,QAAQ,CAAC;AAEvB,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,MAAM,UAAU,cAAc,CAC5B,KAAmB,EACnB,QAA6D;IAE7D,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAQ,CAAC;AACvC,CAAC;AAED,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,MAAM,UAAU,eAAe,CAC7B,KAAmB,EACnB,QAAiB;IAEjB,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,QAAkB,CAAC,CAAC;AAC9C,CAAC;AAED,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,MAAM,UAAU,UAAU,CAAI,KAAmB,EAAE,IAAI,GAAG,CAAC;IACzD,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,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CAC9B,IAAO,EACP,IAAI,GAAG,GAAG;IAEV,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAChC,CAAC;AAED,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,MAAM,UAAU,cAAc,CAC5B,GAAM,EACN,UAAwB;IAExB,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAe,CAAC;AAC/C,CAAC;AAED,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,MAAM,UAAU,cAAc,CAC5B,GAAM,EACN,UAAwB;IAExB,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAe,CAAC;AAC/C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aslam-dev/my-lib",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Reusable utility + UI helper library",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"prepare": "npm run build"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"libphonenumber-js": "^1.12.36",
|
|
16
|
+
"lodash": "^4.17.23",
|
|
17
|
+
"moment": "^2.30.1"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"react": "^18 || ^19"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/lodash": "^4.17.23",
|
|
24
|
+
"@types/react": "^19.2.13",
|
|
25
|
+
"typescript": "^5.0.0"
|
|
26
|
+
}
|
|
27
|
+
}
|