@lfsoftwares/native-util 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/README.md +61 -0
- package/index.ts +1 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -0
- package/lib/src/DateUtils/index.js +2 -0
- package/lib/src/DateUtils/index.js.map +1 -0
- package/lib/src/DateUtils/util.dates.js +293 -0
- package/lib/src/DateUtils/util.dates.js.map +1 -0
- package/lib/src/FormatUtils/index.js +2 -0
- package/lib/src/FormatUtils/index.js.map +1 -0
- package/lib/src/FormatUtils/util.format.js +118 -0
- package/lib/src/FormatUtils/util.format.js.map +1 -0
- package/lib/src/GeneralConsts/consts.general.js +135 -0
- package/lib/src/GeneralConsts/consts.general.js.map +1 -0
- package/lib/src/GeneralConsts/index.js +2 -0
- package/lib/src/GeneralConsts/index.js.map +1 -0
- package/lib/src/GeneralUtils/index.js +2 -0
- package/lib/src/GeneralUtils/index.js.map +1 -0
- package/lib/src/GeneralUtils/util.general.js +71 -0
- package/lib/src/GeneralUtils/util.general.js.map +1 -0
- package/lib/src/MaskUtils/index.js +2 -0
- package/lib/src/MaskUtils/index.js.map +1 -0
- package/lib/src/MaskUtils/util.masks.js +58 -0
- package/lib/src/MaskUtils/util.masks.js.map +1 -0
- package/lib/src/NetworkUtils/index.js +2 -0
- package/lib/src/NetworkUtils/index.js.map +1 -0
- package/lib/src/NetworkUtils/util.network.js +11 -0
- package/lib/src/NetworkUtils/util.network.js.map +1 -0
- package/lib/src/NumberUtils/index.js +2 -0
- package/lib/src/NumberUtils/index.js.map +1 -0
- package/lib/src/NumberUtils/util.numbers.js +212 -0
- package/lib/src/NumberUtils/util.numbers.js.map +1 -0
- package/lib/src/RegexConsts/consts.regex.js +8 -0
- package/lib/src/RegexConsts/consts.regex.js.map +1 -0
- package/lib/src/RegexConsts/index.js +2 -0
- package/lib/src/RegexConsts/index.js.map +1 -0
- package/lib/src/ValidationUtils/index.js +2 -0
- package/lib/src/ValidationUtils/index.js.map +1 -0
- package/lib/src/ValidationUtils/util.validation.js +175 -0
- package/lib/src/ValidationUtils/util.validation.js.map +1 -0
- package/lib/src/index.js +10 -0
- package/lib/src/index.js.map +1 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/src/DateUtils/index.d.ts +2 -0
- package/lib/types/src/DateUtils/index.d.ts.map +1 -0
- package/lib/types/src/DateUtils/util.dates.d.ts +19 -0
- package/lib/types/src/DateUtils/util.dates.d.ts.map +1 -0
- package/lib/types/src/FormatUtils/index.d.ts +2 -0
- package/lib/types/src/FormatUtils/index.d.ts.map +1 -0
- package/lib/types/src/FormatUtils/util.format.d.ts +10 -0
- package/lib/types/src/FormatUtils/util.format.d.ts.map +1 -0
- package/lib/types/src/GeneralConsts/consts.general.d.ts +11 -0
- package/lib/types/src/GeneralConsts/consts.general.d.ts.map +1 -0
- package/lib/types/src/GeneralConsts/index.d.ts +2 -0
- package/lib/types/src/GeneralConsts/index.d.ts.map +1 -0
- package/lib/types/src/GeneralUtils/index.d.ts +2 -0
- package/lib/types/src/GeneralUtils/index.d.ts.map +1 -0
- package/lib/types/src/GeneralUtils/util.general.d.ts +9 -0
- package/lib/types/src/GeneralUtils/util.general.d.ts.map +1 -0
- package/lib/types/src/MaskUtils/index.d.ts +2 -0
- package/lib/types/src/MaskUtils/index.d.ts.map +1 -0
- package/lib/types/src/MaskUtils/util.masks.d.ts +11 -0
- package/lib/types/src/MaskUtils/util.masks.d.ts.map +1 -0
- package/lib/types/src/NetworkUtils/index.d.ts +2 -0
- package/lib/types/src/NetworkUtils/index.d.ts.map +1 -0
- package/lib/types/src/NetworkUtils/util.network.d.ts +5 -0
- package/lib/types/src/NetworkUtils/util.network.d.ts.map +1 -0
- package/lib/types/src/NumberUtils/index.d.ts +2 -0
- package/lib/types/src/NumberUtils/index.d.ts.map +1 -0
- package/lib/types/src/NumberUtils/util.numbers.d.ts +15 -0
- package/lib/types/src/NumberUtils/util.numbers.d.ts.map +1 -0
- package/lib/types/src/RegexConsts/consts.regex.d.ts +8 -0
- package/lib/types/src/RegexConsts/consts.regex.d.ts.map +1 -0
- package/lib/types/src/RegexConsts/index.d.ts +2 -0
- package/lib/types/src/RegexConsts/index.d.ts.map +1 -0
- package/lib/types/src/ValidationUtils/index.d.ts +2 -0
- package/lib/types/src/ValidationUtils/index.d.ts.map +1 -0
- package/lib/types/src/ValidationUtils/util.validation.d.ts +8 -0
- package/lib/types/src/ValidationUtils/util.validation.d.ts.map +1 -0
- package/lib/types/src/index.d.ts +10 -0
- package/lib/types/src/index.d.ts.map +1 -0
- package/package.json +56 -0
- package/src/DateUtils/index.ts +1 -0
- package/src/DateUtils/util.dates.ts +337 -0
- package/src/FormatUtils/index.ts +1 -0
- package/src/FormatUtils/util.format.ts +151 -0
- package/src/GeneralConsts/consts.general.ts +138 -0
- package/src/GeneralConsts/index.ts +1 -0
- package/src/GeneralUtils/index.ts +1 -0
- package/src/GeneralUtils/util.general.ts +76 -0
- package/src/MaskUtils/index.ts +1 -0
- package/src/MaskUtils/util.masks.ts +78 -0
- package/src/NetworkUtils/index.ts +1 -0
- package/src/NetworkUtils/util.network.ts +15 -0
- package/src/NumberUtils/index.ts +1 -0
- package/src/NumberUtils/util.numbers.ts +250 -0
- package/src/RegexConsts/consts.regex.ts +10 -0
- package/src/RegexConsts/index.ts +1 -0
- package/src/ValidationUtils/index.ts +1 -0
- package/src/ValidationUtils/util.validation.ts +215 -0
- package/src/index.ts +9 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/DateUtils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare class RNDateUtils {
|
|
2
|
+
static formatUSDate(date?: Date, shortYear?: boolean): string;
|
|
3
|
+
static formatDateTimeZone(date?: string, shortYear?: boolean): string | undefined;
|
|
4
|
+
static validateDateString(date?: string): string | undefined;
|
|
5
|
+
static dateTimeStringBRToDateTimeStringUS(dateTime?: string): string;
|
|
6
|
+
static dateStringBRToDateStringUS(date?: string): string;
|
|
7
|
+
static dateStringUSToDateStringBR(date?: string, shortYear?: boolean): string | undefined;
|
|
8
|
+
static compareDates(initialDate: string, endDate: string): number;
|
|
9
|
+
static expiredDate(date?: Date): boolean;
|
|
10
|
+
static minutesBetween(majorDate: string, minorDate: string): number;
|
|
11
|
+
static getCurrentDateText(): string;
|
|
12
|
+
static getCurrentDateTimeText(): string;
|
|
13
|
+
static getCurrentDateTimeZoneText(): string;
|
|
14
|
+
static formatDate(date: Date): string;
|
|
15
|
+
static getDateFromToday(addMonths?: number): string;
|
|
16
|
+
static formatJsDateTime(date?: Date, putHours?: boolean, shortYear?: boolean): string;
|
|
17
|
+
}
|
|
18
|
+
export default RNDateUtils;
|
|
19
|
+
//# sourceMappingURL=util.dates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.dates.d.ts","sourceRoot":"","sources":["../../../../src/DateUtils/util.dates.ts"],"names":[],"mappings":"AAIA,cAAM,WAAW;IACf,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,OAAO;IA6CpD,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO;IAuC5D,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,MAAM;IAiDvC,MAAM,CAAC,kCAAkC,CAAC,QAAQ,CAAC,EAAE,MAAM;IAkB3D,MAAM,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,MAAM;IAU/C,MAAM,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO;IAoBpE,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAMxD,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI;IAY9B,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAM1D,MAAM,CAAC,kBAAkB;IAKzB,MAAM,CAAC,sBAAsB;IAK7B,MAAM,CAAC,0BAA0B;IAajC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI;IAK5B,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM;IAW1C,MAAM,CAAC,gBAAgB,CACrB,IAAI,CAAC,EAAE,IAAI,EACX,QAAQ,CAAC,EAAE,OAAO,EAClB,SAAS,CAAC,EAAE,OAAO;CAkFtB;AAED,eAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/FormatUtils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare class RNFormatUtils {
|
|
2
|
+
static formatCelPhoneToWhatsApp(cellPhone?: string, uf?: string, presentationFormat?: boolean, invalidText?: string): string | undefined;
|
|
3
|
+
static formatPhoneNumber(phone?: string, uf?: string): string | undefined;
|
|
4
|
+
static formatIpAdress(ip: string): string;
|
|
5
|
+
static formatUrlAdress(url: string): string;
|
|
6
|
+
static formatUserName(fullName: string): string | undefined;
|
|
7
|
+
static firstLetterUpper(text: string): string;
|
|
8
|
+
}
|
|
9
|
+
export default RNFormatUtils;
|
|
10
|
+
//# sourceMappingURL=util.format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.format.d.ts","sourceRoot":"","sources":["../../../../src/FormatUtils/util.format.ts"],"names":[],"mappings":"AAIA,cAAM,aAAa;IACjB,MAAM,CAAC,wBAAwB,CAC7B,SAAS,CAAC,EAAE,MAAM,EAClB,EAAE,CAAC,EAAE,MAAM,EACX,kBAAkB,CAAC,EAAE,OAAO,EAC5B,WAAW,CAAC,EAAE,MAAM;IA4CtB,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM;IA4CpD,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,MAAM;IAgBhC,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,MAAM;IAclC,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM;IAkBtC,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM;CAGrC;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const GeneralConsts: {
|
|
2
|
+
DEFAULT_OPACITY_CLICK: number;
|
|
3
|
+
MAX_ACCESSIBILITY_MULTIPLIER: number;
|
|
4
|
+
BASE64_PREFIX: string;
|
|
5
|
+
EMPTY_DATE_TEXT: string;
|
|
6
|
+
DDD_BRASIL_UF: string[];
|
|
7
|
+
DDD_PRINCIPAL_UF: string[];
|
|
8
|
+
DDD_BRASIL: string[];
|
|
9
|
+
};
|
|
10
|
+
export default GeneralConsts;
|
|
11
|
+
//# sourceMappingURL=consts.general.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.general.d.ts","sourceRoot":"","sources":["../../../../src/GeneralConsts/consts.general.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,aAAa;;;;;;;;CAuIlB,CAAA;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/GeneralConsts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/GeneralUtils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare class GeneralUtils {
|
|
2
|
+
static hideSplash(): Promise<void>;
|
|
3
|
+
static getUUID(): string;
|
|
4
|
+
static getDeviceDetails(): string;
|
|
5
|
+
static getAppVersion(fullVersion?: boolean): string;
|
|
6
|
+
static copyToClipboard(value: string): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export default GeneralUtils;
|
|
9
|
+
//# sourceMappingURL=util.general.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.general.d.ts","sourceRoot":"","sources":["../../../../src/GeneralUtils/util.general.ts"],"names":[],"mappings":"AAOA,cAAM,YAAY;WACH,UAAU;IAQvB,MAAM,CAAC,OAAO;IAId,MAAM,CAAC,gBAAgB;IAsBvB,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,OAAO;WA4B7B,eAAe,CAAC,KAAK,EAAE,MAAM;CAG3C;AAED,eAAe,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/MaskUtils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare class MaskUtils {
|
|
2
|
+
static maskCEP(value: string): string;
|
|
3
|
+
static maskPhone(value: string): string;
|
|
4
|
+
static maskCurrency(value: string, putSymbol: boolean): string;
|
|
5
|
+
static maskCPF(value: string): string;
|
|
6
|
+
static maskCNPJ(value: string): string;
|
|
7
|
+
static maskCPFCNPJ(value: string): string;
|
|
8
|
+
static maskNumbers(value: string): string;
|
|
9
|
+
}
|
|
10
|
+
export default MaskUtils;
|
|
11
|
+
//# sourceMappingURL=util.masks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.masks.d.ts","sourceRoot":"","sources":["../../../../src/MaskUtils/util.masks.ts"],"names":[],"mappings":"AASA,cAAM,SAAS;IACb,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM;IAM5B,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM;IAO9B,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO;IAOrD,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM;IAa5B,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM;IAc7B,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM;IAchC,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM;CAIjC;AAED,eAAe,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/NetworkUtils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.network.d.ts","sourceRoot":"","sources":["../../../../src/NetworkUtils/util.network.ts"],"names":[],"mappings":"AAEA,cAAM,YAAY;IAChB,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM;CASzC;AAED,eAAe,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/NumberUtils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare class NumberUtils {
|
|
2
|
+
static stringToFloat(textValue?: string): number;
|
|
3
|
+
static editFloatString(textValue?: string): string;
|
|
4
|
+
static currencyFormat(currencyValue: number | string | undefined, putSymbol?: boolean, putPercent?: boolean, outMultiple?: number, decimals?: number): string;
|
|
5
|
+
static extractCurrencyValue(currencyText: string): number;
|
|
6
|
+
static extractNumbers(text: string, includeComma?: boolean): string;
|
|
7
|
+
static numbersAndDots(text: string): string;
|
|
8
|
+
static stringToInteger(text?: string): number;
|
|
9
|
+
static formatDecimalValue(decimalText: string, putSymbol: boolean): string;
|
|
10
|
+
static truncValue(value: number): number;
|
|
11
|
+
static roundValue(value: number, decimalPlaces: number): number;
|
|
12
|
+
static roundValueStr(value: number, decimalPlaces: number): string;
|
|
13
|
+
}
|
|
14
|
+
export default NumberUtils;
|
|
15
|
+
//# sourceMappingURL=util.numbers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.numbers.d.ts","sourceRoot":"","sources":["../../../../src/NumberUtils/util.numbers.ts"],"names":[],"mappings":"AAGA,cAAM,WAAW;IACf,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,MAAM;IAmBvC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE,MAAM;IAkBzC,MAAM,CAAC,cAAc,CACnB,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EAC1C,SAAS,UAAQ,EACjB,UAAU,UAAQ,EAClB,WAAW,SAAI,EACf,QAAQ,SAAI;IAoFd,MAAM,CAAC,oBAAoB,CAAC,YAAY,EAAE,MAAM;IAgBhD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,OAAO;IAS1D,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM;IASlC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM;IAkBpC,MAAM,CAAC,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO;IAiCjE,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM;IAuB/B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;IAItD,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;CAK1D;AAED,eAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.regex.d.ts","sourceRoot":"","sources":["../../../../src/RegexConsts/consts.regex.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,OAAO;;;;;CAOZ,CAAA;AAED,eAAe,OAAO,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/RegexConsts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ValidationUtils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare class ValidationUtils {
|
|
2
|
+
static validateCNPJ(cnpj?: string): string;
|
|
3
|
+
static validateCPF(cpf?: string): string;
|
|
4
|
+
static validateEmail(email?: string): boolean | "";
|
|
5
|
+
static validatePhoneNumber(phoneNumber?: string, forceNineDigits?: boolean): string;
|
|
6
|
+
}
|
|
7
|
+
export default ValidationUtils;
|
|
8
|
+
//# sourceMappingURL=util.validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.validation.d.ts","sourceRoot":"","sources":["../../../../src/ValidationUtils/util.validation.ts"],"names":[],"mappings":"AAIA,cAAM,eAAe;IACnB,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM;IAmEjC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,MAAM;IAoD/B,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM;IAQnC,MAAM,CAAC,mBAAmB,CACxB,WAAW,CAAC,EAAE,MAAM,EACpB,eAAe,CAAC,EAAE,OAAO;CA8E5B;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default as RNGeneralConsts } from './GeneralConsts';
|
|
2
|
+
export { default as RNRegexConsts } from './RegexConsts';
|
|
3
|
+
export { default as RNDateUtils } from './DateUtils';
|
|
4
|
+
export { default as RNFormatUtils } from './FormatUtils';
|
|
5
|
+
export { default as RNGeneralUtils } from './GeneralUtils';
|
|
6
|
+
export { default as RNMaskUtils } from './MaskUtils';
|
|
7
|
+
export { default as RNNetworkUtils } from './NetworkUtils';
|
|
8
|
+
export { default as RNNumberUtils } from './NumberUtils';
|
|
9
|
+
export { default as RNValidationUtils } from './ValidationUtils';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,mBAAmB,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lfsoftwares/native-util",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Utility library for react native",
|
|
5
|
+
"author": "Leandro Fernandes <lfsoftwares.solucoes@gmail.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/leofernandesbh/npm-libs/tree/main/native-util"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"lfsoftwares",
|
|
15
|
+
"lf-softwares",
|
|
16
|
+
"util",
|
|
17
|
+
"react",
|
|
18
|
+
"native",
|
|
19
|
+
"react-native",
|
|
20
|
+
"react-component"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"commit:main": "cd .. && git add . && git commit -m 'libraries updated' && git push origin main",
|
|
24
|
+
"pub:view": "npm run build && npm publish --dry-run",
|
|
25
|
+
"postpub:view": "echo 'package simulation finalized'",
|
|
26
|
+
"prebuild": "sudo rm -rf lib",
|
|
27
|
+
"build": "tsc -p .",
|
|
28
|
+
"pub:main": "npm run build && npm version patch --force && npm publish --access public",
|
|
29
|
+
"postpub:main": "echo 'package has been published'"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/react": "^18.2.22",
|
|
33
|
+
"react": "^18.2.0",
|
|
34
|
+
"react-native": "^0.72.4",
|
|
35
|
+
"typescript": "^5.2.2",
|
|
36
|
+
"date-fns": "^2.30.0",
|
|
37
|
+
"expo-clipboard": "~4.3.1",
|
|
38
|
+
"expo-constants": "~14.4.2",
|
|
39
|
+
"expo-crypto": "~12.4.1",
|
|
40
|
+
"expo-device": "~5.4.0",
|
|
41
|
+
"expo-splash-screen": "~0.20.5",
|
|
42
|
+
"react-native-format-currency": "^0.0.3"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@types/react": "*",
|
|
46
|
+
"react": "*",
|
|
47
|
+
"react-native": "*",
|
|
48
|
+
"date-fns": "*",
|
|
49
|
+
"expo-clipboard": "*",
|
|
50
|
+
"expo-constants": "*",
|
|
51
|
+
"expo-crypto": "*",
|
|
52
|
+
"expo-device": "*",
|
|
53
|
+
"expo-splash-screen": "*",
|
|
54
|
+
"react-native-format-currency": "*"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './util.dates'
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { Platform } from 'react-native'
|
|
2
|
+
import { compareAsc, add, format, differenceInMinutes } from 'date-fns'
|
|
3
|
+
import { pt } from 'date-fns/locale'
|
|
4
|
+
|
|
5
|
+
class RNDateUtils {
|
|
6
|
+
static formatUSDate(date?: Date, shortYear?: boolean) {
|
|
7
|
+
try {
|
|
8
|
+
if (date) {
|
|
9
|
+
const dateString = date.toString()
|
|
10
|
+
|
|
11
|
+
if (dateString.length === 10) {
|
|
12
|
+
const dateParts = dateString.split('-')
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
dateParts[2] +
|
|
16
|
+
'/' +
|
|
17
|
+
dateParts[1] +
|
|
18
|
+
'/' +
|
|
19
|
+
(shortYear ? dateParts[0].substring(2) : dateParts[0])
|
|
20
|
+
)
|
|
21
|
+
} else if (Platform.OS === 'ios') {
|
|
22
|
+
const newDate = new Date(date.toString())
|
|
23
|
+
|
|
24
|
+
const dateFormated = Intl.DateTimeFormat('pt-BR', {
|
|
25
|
+
dateStyle: 'short',
|
|
26
|
+
timeStyle: 'short',
|
|
27
|
+
}).format(newDate)
|
|
28
|
+
|
|
29
|
+
if (shortYear) {
|
|
30
|
+
const onlyDate = dateFormated.split(' ')[0]
|
|
31
|
+
const dateParts = onlyDate.split('/')
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
dateParts[0] + '/' + dateParts[1] + '/' + dateParts[2].substring(2)
|
|
35
|
+
)
|
|
36
|
+
} else {
|
|
37
|
+
return dateFormated.split(' ')[0]
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
return shortYear
|
|
41
|
+
? format(date, 'dd/MM/yy', { locale: pt })
|
|
42
|
+
: format(date, 'dd/MM/yyy', { locale: pt })
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
return ''
|
|
46
|
+
}
|
|
47
|
+
} catch (e) {
|
|
48
|
+
return ''
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
static formatDateTimeZone(date?: string, shortYear?: boolean) {
|
|
52
|
+
// 2023-02-16T00:00:00.000Z ou 2023-02-16
|
|
53
|
+
if (date && date.includes('-')) {
|
|
54
|
+
if (date.includes('T')) {
|
|
55
|
+
const onlyDate = date.split('T')[0]
|
|
56
|
+
const dateParts = onlyDate.split('-')
|
|
57
|
+
|
|
58
|
+
let formatedDate
|
|
59
|
+
|
|
60
|
+
if (dateParts[0].length === 4) {
|
|
61
|
+
formatedDate =
|
|
62
|
+
dateParts[2] +
|
|
63
|
+
'/' +
|
|
64
|
+
dateParts[1] +
|
|
65
|
+
'/' +
|
|
66
|
+
(shortYear ? dateParts[0].substring(2) : dateParts[0])
|
|
67
|
+
} else {
|
|
68
|
+
formatedDate =
|
|
69
|
+
dateParts[0] +
|
|
70
|
+
'/' +
|
|
71
|
+
dateParts[1] +
|
|
72
|
+
'/' +
|
|
73
|
+
(shortYear ? dateParts[2].substring(2) : dateParts[2])
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return formatedDate
|
|
77
|
+
} else if (date && date.length === 10) {
|
|
78
|
+
const dateParts = date.split('-')
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
dateParts[2] +
|
|
82
|
+
'/' +
|
|
83
|
+
dateParts[1] +
|
|
84
|
+
'/' +
|
|
85
|
+
(shortYear ? dateParts[0].substring(2) : dateParts[0])
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
static validateDateString(date?: string) {
|
|
91
|
+
try {
|
|
92
|
+
if (
|
|
93
|
+
date &&
|
|
94
|
+
date.includes('/') &&
|
|
95
|
+
(date.length === 6 ||
|
|
96
|
+
date.length === 7 ||
|
|
97
|
+
date.length === 8 ||
|
|
98
|
+
date.length === 10)
|
|
99
|
+
) {
|
|
100
|
+
const dateParts = date.split('/')
|
|
101
|
+
|
|
102
|
+
if (dateParts.length === 3) {
|
|
103
|
+
dateParts[0] = dateParts[0].padStart(2, '0')
|
|
104
|
+
dateParts[1] = dateParts[1].padStart(2, '0')
|
|
105
|
+
|
|
106
|
+
if (dateParts[2].length === 2) {
|
|
107
|
+
dateParts[2] = '20' + dateParts[2]
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (
|
|
111
|
+
dateParts[0].length !== 2 ||
|
|
112
|
+
dateParts[1].length !== 2 ||
|
|
113
|
+
dateParts[2].length !== 4
|
|
114
|
+
) {
|
|
115
|
+
return undefined
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const dateValidate = new Date(
|
|
119
|
+
dateParts[2] + '-' + dateParts[1] + '-' + dateParts[0],
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
const validDate = dateValidate.getTime()
|
|
123
|
+
|
|
124
|
+
if (!isNaN(validDate)) {
|
|
125
|
+
return dateParts[0] + '/' + dateParts[1] + '/' + dateParts[2]
|
|
126
|
+
} else {
|
|
127
|
+
return undefined
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
return undefined
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
return undefined
|
|
134
|
+
}
|
|
135
|
+
} catch (e) {
|
|
136
|
+
return undefined
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
static dateTimeStringBRToDateTimeStringUS(dateTime?: string) {
|
|
140
|
+
if (!dateTime || dateTime.length !== 19) {
|
|
141
|
+
return ''
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const dateBR = this.validateDateString(dateTime.split(' ')[0])
|
|
145
|
+
|
|
146
|
+
if (dateBR) {
|
|
147
|
+
const dateParts = dateBR.split('/')
|
|
148
|
+
const onlyTime = dateTime.split(' ')[1]
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
dateParts[2] + '-' + dateParts[1] + '-' + dateParts[0] + ' ' + onlyTime
|
|
152
|
+
)
|
|
153
|
+
} else {
|
|
154
|
+
return ''
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
static dateStringBRToDateStringUS(date?: string) {
|
|
158
|
+
const dateBR = this.validateDateString(date)
|
|
159
|
+
|
|
160
|
+
if (dateBR) {
|
|
161
|
+
const dateParts = dateBR.split('/')
|
|
162
|
+
return dateParts[2] + '-' + dateParts[1] + '-' + dateParts[0]
|
|
163
|
+
} else {
|
|
164
|
+
return ''
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
static dateStringUSToDateStringBR(date?: string, shortYear?: boolean) {
|
|
168
|
+
if (date && date.includes('-') && date.length === 10) {
|
|
169
|
+
const dateParts = date.split('-')
|
|
170
|
+
|
|
171
|
+
dateParts[2] = dateParts[2].padStart(2, '0')
|
|
172
|
+
dateParts[1] = dateParts[1].padStart(2, '0')
|
|
173
|
+
|
|
174
|
+
if (dateParts[0].length === 2) {
|
|
175
|
+
dateParts[0] = '20' + dateParts[0]
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (shortYear) {
|
|
179
|
+
dateParts[0] = dateParts[0].substring(2)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return dateParts[2] + '/' + dateParts[1] + '/' + dateParts[0]
|
|
183
|
+
} else {
|
|
184
|
+
return undefined
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
static compareDates(initialDate: string, endDate: string) {
|
|
188
|
+
initialDate = this.dateStringBRToDateStringUS(initialDate)
|
|
189
|
+
endDate = this.dateStringBRToDateStringUS(endDate)
|
|
190
|
+
|
|
191
|
+
return compareAsc(new Date(initialDate), new Date(endDate))
|
|
192
|
+
}
|
|
193
|
+
static expiredDate(date?: Date) {
|
|
194
|
+
if (!date) return false
|
|
195
|
+
|
|
196
|
+
if (date.toString().includes('1899')) return false
|
|
197
|
+
|
|
198
|
+
const today = this.getCurrentDateText()
|
|
199
|
+
const formatedDate = this.formatJsDateTime(date)
|
|
200
|
+
|
|
201
|
+
const compareResult = this.compareDates(formatedDate, today)
|
|
202
|
+
|
|
203
|
+
return compareResult < 0
|
|
204
|
+
}
|
|
205
|
+
static minutesBetween(majorDate: string, minorDate: string) {
|
|
206
|
+
majorDate = this.dateTimeStringBRToDateTimeStringUS(majorDate)
|
|
207
|
+
minorDate = this.dateTimeStringBRToDateTimeStringUS(minorDate)
|
|
208
|
+
|
|
209
|
+
return differenceInMinutes(new Date(majorDate), new Date(minorDate))
|
|
210
|
+
}
|
|
211
|
+
static getCurrentDateText() {
|
|
212
|
+
return format(new Date(), 'dd/MM/yyyy', {
|
|
213
|
+
locale: pt,
|
|
214
|
+
})
|
|
215
|
+
}
|
|
216
|
+
static getCurrentDateTimeText() {
|
|
217
|
+
return format(new Date(), 'dd/MM/yyyy HH:mm:ss', {
|
|
218
|
+
locale: pt,
|
|
219
|
+
})
|
|
220
|
+
}
|
|
221
|
+
static getCurrentDateTimeZoneText() {
|
|
222
|
+
const formatedDate = format(new Date(), 'yyyy-MM-dd', {
|
|
223
|
+
locale: pt,
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
const formatedTime = format(new Date(), 'HH:mm:ss', {
|
|
227
|
+
locale: pt,
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
const formatedDateTime = formatedDate.concat('T', formatedTime, '.000Z')
|
|
231
|
+
|
|
232
|
+
return formatedDateTime
|
|
233
|
+
}
|
|
234
|
+
static formatDate(date: Date) {
|
|
235
|
+
return format(date, 'dd/MM/yyyy', {
|
|
236
|
+
locale: pt,
|
|
237
|
+
})
|
|
238
|
+
}
|
|
239
|
+
static getDateFromToday(addMonths?: number) {
|
|
240
|
+
let newDate = new Date()
|
|
241
|
+
|
|
242
|
+
if (addMonths) {
|
|
243
|
+
newDate = add(newDate, { months: addMonths })
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return format(newDate, 'dd/MM/yyyy', {
|
|
247
|
+
locale: pt,
|
|
248
|
+
})
|
|
249
|
+
}
|
|
250
|
+
static formatJsDateTime(
|
|
251
|
+
date?: Date,
|
|
252
|
+
putHours?: boolean,
|
|
253
|
+
shortYear?: boolean,
|
|
254
|
+
) {
|
|
255
|
+
try {
|
|
256
|
+
if (date) {
|
|
257
|
+
const dateString = date.toString()
|
|
258
|
+
|
|
259
|
+
if (dateString.length === 10) {
|
|
260
|
+
const dateParts = dateString.split('-')
|
|
261
|
+
|
|
262
|
+
return (
|
|
263
|
+
dateParts[2] +
|
|
264
|
+
'/' +
|
|
265
|
+
dateParts[1] +
|
|
266
|
+
'/' +
|
|
267
|
+
(shortYear ? dateParts[0].substring(2) : dateParts[0])
|
|
268
|
+
)
|
|
269
|
+
} else if (Platform.OS === 'ios') {
|
|
270
|
+
const newDate = new Date(
|
|
271
|
+
date.toString().replace('00:00:00.000', '12:00:00.000'),
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
let dateFormated = Intl.DateTimeFormat('pt-BR', {
|
|
275
|
+
dateStyle: 'short',
|
|
276
|
+
timeStyle: 'short',
|
|
277
|
+
}).format(newDate)
|
|
278
|
+
|
|
279
|
+
if (shortYear) {
|
|
280
|
+
const dateTimeParts = dateFormated.split(' ')
|
|
281
|
+
const onlyDate = dateTimeParts[0]
|
|
282
|
+
const onlyTime = dateTimeParts[1]
|
|
283
|
+
const dateParts = onlyDate.split('/')
|
|
284
|
+
|
|
285
|
+
dateFormated =
|
|
286
|
+
dateParts[0] +
|
|
287
|
+
'/' +
|
|
288
|
+
dateParts[1] +
|
|
289
|
+
'/' +
|
|
290
|
+
dateParts[2].substring(2) +
|
|
291
|
+
' ' +
|
|
292
|
+
onlyTime
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (putHours) {
|
|
296
|
+
return dateFormated.replace(' ', ' - ')
|
|
297
|
+
} else {
|
|
298
|
+
return dateFormated.split(' ')[0]
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
const newDate = date.toString().replace('00:00:00.000', '12:00:00.000')
|
|
302
|
+
const onlyDate = newDate.includes('T')
|
|
303
|
+
? newDate.split('T')[0]
|
|
304
|
+
: newDate.split(' ')[0]
|
|
305
|
+
const onlyTime = newDate.includes('T')
|
|
306
|
+
? newDate.split('T')[1]
|
|
307
|
+
: newDate.split(' ')[1]
|
|
308
|
+
const fieldsDate = onlyDate.split('-')
|
|
309
|
+
const fieldsTime = onlyTime.split(':')
|
|
310
|
+
|
|
311
|
+
const dateFormated =
|
|
312
|
+
fieldsDate[2] +
|
|
313
|
+
'/' +
|
|
314
|
+
fieldsDate[1] +
|
|
315
|
+
'/' +
|
|
316
|
+
(shortYear ? fieldsDate[0].substring(2) : fieldsDate[0]) +
|
|
317
|
+
' - ' +
|
|
318
|
+
fieldsTime[0] +
|
|
319
|
+
':' +
|
|
320
|
+
fieldsTime[1]
|
|
321
|
+
|
|
322
|
+
if (putHours) {
|
|
323
|
+
return dateFormated
|
|
324
|
+
} else {
|
|
325
|
+
return dateFormated.split('-')[0].trim()
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
} else {
|
|
329
|
+
return ''
|
|
330
|
+
}
|
|
331
|
+
} catch (e) {
|
|
332
|
+
return ''
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export default RNDateUtils
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './util.format'
|