@rainersoft/utils 1.1.0 → 1.3.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/date/index.d.mts +2 -9
- package/dist/date/index.d.ts +2 -9
- package/dist/index-BA11MtKk.d.ts +18 -0
- package/dist/index-BPYjFrM1.d.mts +18 -0
- package/dist/index-BfZE8XjJ.d.ts +18 -0
- package/dist/index-BuqX8-qm.d.mts +18 -0
- package/dist/index.d.mts +66 -3
- package/dist/index.d.ts +66 -3
- package/dist/index.js +222 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +207 -1
- package/dist/index.mjs.map +1 -1
- package/dist/status/index.d.mts +2 -9
- package/dist/status/index.d.ts +2 -9
- package/package.json +1 -1
package/dist/date/index.d.mts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
declare function formatDate(date: string | Date, format?: 'short' | 'long' | 'full', locale?: Locale): string;
|
|
4
|
-
declare function formatDateTime(date: string | Date, locale?: Locale): string;
|
|
5
|
-
declare function formatRelativeDate(date: string | Date, locale?: Locale): string;
|
|
6
|
-
declare function toISOString(date: Date): string;
|
|
7
|
-
declare function isValidDate(date: unknown): date is Date;
|
|
8
|
-
|
|
9
|
-
export { formatDate, formatDateTime, formatRelativeDate, isValidDate, toISOString };
|
|
1
|
+
import '../types-tUMATEGI.mjs';
|
|
2
|
+
export { f as formatDate, a as formatDateTime, b as formatRelativeDate, i as isValidDate, t as toISOString } from '../index-BPYjFrM1.mjs';
|
package/dist/date/index.d.ts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
declare function formatDate(date: string | Date, format?: 'short' | 'long' | 'full', locale?: Locale): string;
|
|
4
|
-
declare function formatDateTime(date: string | Date, locale?: Locale): string;
|
|
5
|
-
declare function formatRelativeDate(date: string | Date, locale?: Locale): string;
|
|
6
|
-
declare function toISOString(date: Date): string;
|
|
7
|
-
declare function isValidDate(date: unknown): date is Date;
|
|
8
|
-
|
|
9
|
-
export { formatDate, formatDateTime, formatRelativeDate, isValidDate, toISOString };
|
|
1
|
+
import '../types-tUMATEGI.js';
|
|
2
|
+
export { f as formatDate, a as formatDateTime, b as formatRelativeDate, i as isValidDate, t as toISOString } from '../index-BA11MtKk.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { L as Locale } from './types-tUMATEGI.js';
|
|
2
|
+
|
|
3
|
+
declare function formatDate(date: string | Date, format?: 'short' | 'long' | 'full', locale?: Locale): string;
|
|
4
|
+
declare function formatDateTime(date: string | Date, locale?: Locale): string;
|
|
5
|
+
declare function formatRelativeDate(date: string | Date, locale?: Locale): string;
|
|
6
|
+
declare function toISOString(date: Date): string;
|
|
7
|
+
declare function isValidDate(date: unknown): date is Date;
|
|
8
|
+
|
|
9
|
+
declare const dateModule_formatDate: typeof formatDate;
|
|
10
|
+
declare const dateModule_formatDateTime: typeof formatDateTime;
|
|
11
|
+
declare const dateModule_formatRelativeDate: typeof formatRelativeDate;
|
|
12
|
+
declare const dateModule_isValidDate: typeof isValidDate;
|
|
13
|
+
declare const dateModule_toISOString: typeof toISOString;
|
|
14
|
+
declare namespace dateModule {
|
|
15
|
+
export { dateModule_formatDate as formatDate, dateModule_formatDateTime as formatDateTime, dateModule_formatRelativeDate as formatRelativeDate, dateModule_isValidDate as isValidDate, dateModule_toISOString as toISOString };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { formatDateTime as a, formatRelativeDate as b, dateModule as d, formatDate as f, isValidDate as i, toISOString as t };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { L as Locale } from './types-tUMATEGI.mjs';
|
|
2
|
+
|
|
3
|
+
declare function formatDate(date: string | Date, format?: 'short' | 'long' | 'full', locale?: Locale): string;
|
|
4
|
+
declare function formatDateTime(date: string | Date, locale?: Locale): string;
|
|
5
|
+
declare function formatRelativeDate(date: string | Date, locale?: Locale): string;
|
|
6
|
+
declare function toISOString(date: Date): string;
|
|
7
|
+
declare function isValidDate(date: unknown): date is Date;
|
|
8
|
+
|
|
9
|
+
declare const dateModule_formatDate: typeof formatDate;
|
|
10
|
+
declare const dateModule_formatDateTime: typeof formatDateTime;
|
|
11
|
+
declare const dateModule_formatRelativeDate: typeof formatRelativeDate;
|
|
12
|
+
declare const dateModule_isValidDate: typeof isValidDate;
|
|
13
|
+
declare const dateModule_toISOString: typeof toISOString;
|
|
14
|
+
declare namespace dateModule {
|
|
15
|
+
export { dateModule_formatDate as formatDate, dateModule_formatDateTime as formatDateTime, dateModule_formatRelativeDate as formatRelativeDate, dateModule_isValidDate as isValidDate, dateModule_toISOString as toISOString };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { formatDateTime as a, formatRelativeDate as b, dateModule as d, formatDate as f, isValidDate as i, toISOString as t };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { L as Locale } from './types-tUMATEGI.js';
|
|
2
|
+
|
|
3
|
+
type GenericStatus = 'DRAFT' | 'PENDING' | 'PUBLISHED' | 'ACTIVE' | 'INACTIVE' | 'ARCHIVED' | 'DELETED' | 'SCHEDULED' | 'COMPLETED' | 'CANCELLED' | 'APPROVED' | 'REJECTED';
|
|
4
|
+
declare function translateStatus(status: string, locale?: Locale): string;
|
|
5
|
+
declare function getStatusColor(status: string): string;
|
|
6
|
+
declare function getStatusVariant(status: string): 'default' | 'secondary' | 'destructive' | 'outline';
|
|
7
|
+
declare function translatePostStatus(status: string, locale?: Locale): string;
|
|
8
|
+
|
|
9
|
+
type statusModule_GenericStatus = GenericStatus;
|
|
10
|
+
declare const statusModule_getStatusColor: typeof getStatusColor;
|
|
11
|
+
declare const statusModule_getStatusVariant: typeof getStatusVariant;
|
|
12
|
+
declare const statusModule_translatePostStatus: typeof translatePostStatus;
|
|
13
|
+
declare const statusModule_translateStatus: typeof translateStatus;
|
|
14
|
+
declare namespace statusModule {
|
|
15
|
+
export { type statusModule_GenericStatus as GenericStatus, statusModule_getStatusColor as getStatusColor, statusModule_getStatusVariant as getStatusVariant, statusModule_translatePostStatus as translatePostStatus, statusModule_translateStatus as translateStatus };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { type GenericStatus as G, getStatusVariant as a, translatePostStatus as b, getStatusColor as g, statusModule as s, translateStatus as t };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { L as Locale } from './types-tUMATEGI.mjs';
|
|
2
|
+
|
|
3
|
+
type GenericStatus = 'DRAFT' | 'PENDING' | 'PUBLISHED' | 'ACTIVE' | 'INACTIVE' | 'ARCHIVED' | 'DELETED' | 'SCHEDULED' | 'COMPLETED' | 'CANCELLED' | 'APPROVED' | 'REJECTED';
|
|
4
|
+
declare function translateStatus(status: string, locale?: Locale): string;
|
|
5
|
+
declare function getStatusColor(status: string): string;
|
|
6
|
+
declare function getStatusVariant(status: string): 'default' | 'secondary' | 'destructive' | 'outline';
|
|
7
|
+
declare function translatePostStatus(status: string, locale?: Locale): string;
|
|
8
|
+
|
|
9
|
+
type statusModule_GenericStatus = GenericStatus;
|
|
10
|
+
declare const statusModule_getStatusColor: typeof getStatusColor;
|
|
11
|
+
declare const statusModule_getStatusVariant: typeof getStatusVariant;
|
|
12
|
+
declare const statusModule_translatePostStatus: typeof translatePostStatus;
|
|
13
|
+
declare const statusModule_translateStatus: typeof translateStatus;
|
|
14
|
+
declare namespace statusModule {
|
|
15
|
+
export { type statusModule_GenericStatus as GenericStatus, statusModule_getStatusColor as getStatusColor, statusModule_getStatusVariant as getStatusVariant, statusModule_translatePostStatus as translatePostStatus, statusModule_translateStatus as translateStatus };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { type GenericStatus as G, getStatusVariant as a, translatePostStatus as b, getStatusColor as g, statusModule as s, translateStatus as t };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { L as Locale } from './types-tUMATEGI.mjs';
|
|
2
2
|
export { C as CURRENCY_MAP, D as DEFAULT_LOCALE, a as LocaleConfig } from './types-tUMATEGI.mjs';
|
|
3
3
|
export { textToSlug } from './string/index.mjs';
|
|
4
|
-
|
|
4
|
+
import { d as dateModule } from './index-BPYjFrM1.mjs';
|
|
5
|
+
export { f as formatDate, a as formatDateTime, b as formatRelativeDate, i as isValidDate, t as toISOString } from './index-BPYjFrM1.mjs';
|
|
5
6
|
export { formatCurrency } from './number/index.mjs';
|
|
6
|
-
|
|
7
|
+
import { s as statusModule } from './index-BuqX8-qm.mjs';
|
|
8
|
+
export { G as GenericStatus, g as getStatusColor, a as getStatusVariant, b as translatePostStatus, t as translateStatus } from './index-BuqX8-qm.mjs';
|
|
7
9
|
|
|
8
10
|
declare function extractInitials(name: string | null | undefined, maxChars?: number): string;
|
|
9
11
|
declare function generateAvatarUrl(name: string, size?: number, backgroundColor?: string, textColor?: string): string;
|
|
@@ -22,6 +24,24 @@ declare function isEmpty(text: string | null | undefined): boolean;
|
|
|
22
24
|
declare function normalizeSpaces(text: string, options?: {
|
|
23
25
|
newlines?: boolean;
|
|
24
26
|
}): string;
|
|
27
|
+
declare function calculateReadingTime(content: string | Record<string, any>, wordsPerMinute?: number): number;
|
|
28
|
+
|
|
29
|
+
declare const textModule_calculateReadingTime: typeof calculateReadingTime;
|
|
30
|
+
declare const textModule_capitalize: typeof capitalize;
|
|
31
|
+
declare const textModule_cleanText: typeof cleanText;
|
|
32
|
+
declare const textModule_countWords: typeof countWords;
|
|
33
|
+
declare const textModule_extractInitials: typeof extractInitials;
|
|
34
|
+
declare const textModule_generateAvatarUrl: typeof generateAvatarUrl;
|
|
35
|
+
declare const textModule_generateDynamicAvatarUrl: typeof generateDynamicAvatarUrl;
|
|
36
|
+
declare const textModule_generateUniqueId: typeof generateUniqueId;
|
|
37
|
+
declare const textModule_getAvatarColorFromName: typeof getAvatarColorFromName;
|
|
38
|
+
declare const textModule_isEmpty: typeof isEmpty;
|
|
39
|
+
declare const textModule_isValidAvatarUrl: typeof isValidAvatarUrl;
|
|
40
|
+
declare const textModule_normalizeSpaces: typeof normalizeSpaces;
|
|
41
|
+
declare const textModule_truncateText: typeof truncateText;
|
|
42
|
+
declare namespace textModule {
|
|
43
|
+
export { textModule_calculateReadingTime as calculateReadingTime, textModule_capitalize as capitalize, textModule_cleanText as cleanText, textModule_countWords as countWords, textModule_extractInitials as extractInitials, textModule_generateAvatarUrl as generateAvatarUrl, textModule_generateDynamicAvatarUrl as generateDynamicAvatarUrl, textModule_generateUniqueId as generateUniqueId, textModule_getAvatarColorFromName as getAvatarColorFromName, textModule_isEmpty as isEmpty, textModule_isValidAvatarUrl as isValidAvatarUrl, textModule_normalizeSpaces as normalizeSpaces, textModule_truncateText as truncateText };
|
|
44
|
+
}
|
|
25
45
|
|
|
26
46
|
interface ValidationResult {
|
|
27
47
|
isValid: boolean;
|
|
@@ -94,6 +114,44 @@ declare function findMinMax<T extends Record<string, any>>(data: T[], field: key
|
|
|
94
114
|
max: number;
|
|
95
115
|
};
|
|
96
116
|
|
|
117
|
+
declare const getToken: () => string | null;
|
|
118
|
+
declare const setToken: (token: string) => void;
|
|
119
|
+
declare const getRefreshToken: () => string | null;
|
|
120
|
+
declare const setRefreshToken: (refreshToken: string) => void;
|
|
121
|
+
declare const removeToken: () => void;
|
|
122
|
+
declare const hasToken: () => boolean;
|
|
123
|
+
declare const getTokens: () => {
|
|
124
|
+
accessToken: string | null;
|
|
125
|
+
refreshToken: string | null;
|
|
126
|
+
};
|
|
127
|
+
declare const setTokens: ({ accessToken, refreshToken, }: {
|
|
128
|
+
accessToken: string;
|
|
129
|
+
refreshToken: string;
|
|
130
|
+
}) => void;
|
|
131
|
+
|
|
132
|
+
declare const authModule_getRefreshToken: typeof getRefreshToken;
|
|
133
|
+
declare const authModule_getToken: typeof getToken;
|
|
134
|
+
declare const authModule_getTokens: typeof getTokens;
|
|
135
|
+
declare const authModule_hasToken: typeof hasToken;
|
|
136
|
+
declare const authModule_removeToken: typeof removeToken;
|
|
137
|
+
declare const authModule_setRefreshToken: typeof setRefreshToken;
|
|
138
|
+
declare const authModule_setToken: typeof setToken;
|
|
139
|
+
declare const authModule_setTokens: typeof setTokens;
|
|
140
|
+
declare namespace authModule {
|
|
141
|
+
export { authModule_getRefreshToken as getRefreshToken, authModule_getToken as getToken, authModule_getTokens as getTokens, authModule_hasToken as hasToken, authModule_removeToken as removeToken, authModule_setRefreshToken as setRefreshToken, authModule_setToken as setToken, authModule_setTokens as setTokens };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
interface SearchOptions {
|
|
145
|
+
fields?: string[];
|
|
146
|
+
caseSensitive?: boolean;
|
|
147
|
+
exactMatch?: boolean;
|
|
148
|
+
}
|
|
149
|
+
declare function searchContent<T extends Record<string, any>>(query: string, content: T[], options?: SearchOptions): T[];
|
|
150
|
+
declare function searchWithScore<T extends Record<string, any>>(query: string, content: T[], options?: SearchOptions): T[];
|
|
151
|
+
declare function fuzzySearch<T extends Record<string, any>>(query: string, content: T[], options?: SearchOptions & {
|
|
152
|
+
threshold?: number;
|
|
153
|
+
}): T[];
|
|
154
|
+
|
|
97
155
|
declare function usePasswordStrength(password: string, options?: {
|
|
98
156
|
minLength?: number;
|
|
99
157
|
requireUppercase?: boolean;
|
|
@@ -159,4 +217,9 @@ declare namespace ptBr {
|
|
|
159
217
|
export { ptBr_formatCompact as formatCompact, ptBr_formatCurrency as formatCurrency, ptBr_formatDate as formatDate, ptBr_formatDateTime as formatDateTime, ptBr_formatNumber as formatNumber, ptBr_formatRelativeDate as formatRelativeDate, ptBr_translateStatus as translateStatus };
|
|
160
218
|
}
|
|
161
219
|
|
|
162
|
-
|
|
220
|
+
declare const textProcessing: typeof textModule;
|
|
221
|
+
declare const datetime: typeof dateModule;
|
|
222
|
+
declare const authentication: typeof authModule;
|
|
223
|
+
declare const stateManagement: typeof statusModule;
|
|
224
|
+
|
|
225
|
+
export { Locale, type SearchOptions, type ValidationResult, authentication, calculateChange, calculateMovingAverage, calculateReadingTime, capitalize, cleanText, copyToClipboard, countWords, datetime, downloadFile, extractInitials, findMinMax, formatNumber$1 as formatNumber, formatPercentage, fuzzySearch, generateAvatarUrl, generateDynamicAvatarUrl, generateMockChartData, generateUniqueId, getAvatarColorFromName, getElementPosition, getRefreshToken, getToken, getTokens, groupDataByPeriod, hasToken, isDarkMode, isElementVisible, isEmpty, isMobile, isValidAvatarUrl, normalizeSpaces, onDarkModeChange, onReducedMotionChange, prefersReducedMotion, ptBr as ptBR, removeToken, scrollToElement, scrollToPosition, scrollToTop, searchContent, searchWithScore, setRefreshToken, setToken, setTokens, smoothScrollTo, stateManagement, textProcessing, truncateText, usePasswordStrength, validateEmail, validateMessage, validatePassword, validatePhone, validateSlug, validateText, validateUrl, validateUsername };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { L as Locale } from './types-tUMATEGI.js';
|
|
2
2
|
export { C as CURRENCY_MAP, D as DEFAULT_LOCALE, a as LocaleConfig } from './types-tUMATEGI.js';
|
|
3
3
|
export { textToSlug } from './string/index.js';
|
|
4
|
-
|
|
4
|
+
import { d as dateModule } from './index-BA11MtKk.js';
|
|
5
|
+
export { f as formatDate, a as formatDateTime, b as formatRelativeDate, i as isValidDate, t as toISOString } from './index-BA11MtKk.js';
|
|
5
6
|
export { formatCurrency } from './number/index.js';
|
|
6
|
-
|
|
7
|
+
import { s as statusModule } from './index-BfZE8XjJ.js';
|
|
8
|
+
export { G as GenericStatus, g as getStatusColor, a as getStatusVariant, b as translatePostStatus, t as translateStatus } from './index-BfZE8XjJ.js';
|
|
7
9
|
|
|
8
10
|
declare function extractInitials(name: string | null | undefined, maxChars?: number): string;
|
|
9
11
|
declare function generateAvatarUrl(name: string, size?: number, backgroundColor?: string, textColor?: string): string;
|
|
@@ -22,6 +24,24 @@ declare function isEmpty(text: string | null | undefined): boolean;
|
|
|
22
24
|
declare function normalizeSpaces(text: string, options?: {
|
|
23
25
|
newlines?: boolean;
|
|
24
26
|
}): string;
|
|
27
|
+
declare function calculateReadingTime(content: string | Record<string, any>, wordsPerMinute?: number): number;
|
|
28
|
+
|
|
29
|
+
declare const textModule_calculateReadingTime: typeof calculateReadingTime;
|
|
30
|
+
declare const textModule_capitalize: typeof capitalize;
|
|
31
|
+
declare const textModule_cleanText: typeof cleanText;
|
|
32
|
+
declare const textModule_countWords: typeof countWords;
|
|
33
|
+
declare const textModule_extractInitials: typeof extractInitials;
|
|
34
|
+
declare const textModule_generateAvatarUrl: typeof generateAvatarUrl;
|
|
35
|
+
declare const textModule_generateDynamicAvatarUrl: typeof generateDynamicAvatarUrl;
|
|
36
|
+
declare const textModule_generateUniqueId: typeof generateUniqueId;
|
|
37
|
+
declare const textModule_getAvatarColorFromName: typeof getAvatarColorFromName;
|
|
38
|
+
declare const textModule_isEmpty: typeof isEmpty;
|
|
39
|
+
declare const textModule_isValidAvatarUrl: typeof isValidAvatarUrl;
|
|
40
|
+
declare const textModule_normalizeSpaces: typeof normalizeSpaces;
|
|
41
|
+
declare const textModule_truncateText: typeof truncateText;
|
|
42
|
+
declare namespace textModule {
|
|
43
|
+
export { textModule_calculateReadingTime as calculateReadingTime, textModule_capitalize as capitalize, textModule_cleanText as cleanText, textModule_countWords as countWords, textModule_extractInitials as extractInitials, textModule_generateAvatarUrl as generateAvatarUrl, textModule_generateDynamicAvatarUrl as generateDynamicAvatarUrl, textModule_generateUniqueId as generateUniqueId, textModule_getAvatarColorFromName as getAvatarColorFromName, textModule_isEmpty as isEmpty, textModule_isValidAvatarUrl as isValidAvatarUrl, textModule_normalizeSpaces as normalizeSpaces, textModule_truncateText as truncateText };
|
|
44
|
+
}
|
|
25
45
|
|
|
26
46
|
interface ValidationResult {
|
|
27
47
|
isValid: boolean;
|
|
@@ -94,6 +114,44 @@ declare function findMinMax<T extends Record<string, any>>(data: T[], field: key
|
|
|
94
114
|
max: number;
|
|
95
115
|
};
|
|
96
116
|
|
|
117
|
+
declare const getToken: () => string | null;
|
|
118
|
+
declare const setToken: (token: string) => void;
|
|
119
|
+
declare const getRefreshToken: () => string | null;
|
|
120
|
+
declare const setRefreshToken: (refreshToken: string) => void;
|
|
121
|
+
declare const removeToken: () => void;
|
|
122
|
+
declare const hasToken: () => boolean;
|
|
123
|
+
declare const getTokens: () => {
|
|
124
|
+
accessToken: string | null;
|
|
125
|
+
refreshToken: string | null;
|
|
126
|
+
};
|
|
127
|
+
declare const setTokens: ({ accessToken, refreshToken, }: {
|
|
128
|
+
accessToken: string;
|
|
129
|
+
refreshToken: string;
|
|
130
|
+
}) => void;
|
|
131
|
+
|
|
132
|
+
declare const authModule_getRefreshToken: typeof getRefreshToken;
|
|
133
|
+
declare const authModule_getToken: typeof getToken;
|
|
134
|
+
declare const authModule_getTokens: typeof getTokens;
|
|
135
|
+
declare const authModule_hasToken: typeof hasToken;
|
|
136
|
+
declare const authModule_removeToken: typeof removeToken;
|
|
137
|
+
declare const authModule_setRefreshToken: typeof setRefreshToken;
|
|
138
|
+
declare const authModule_setToken: typeof setToken;
|
|
139
|
+
declare const authModule_setTokens: typeof setTokens;
|
|
140
|
+
declare namespace authModule {
|
|
141
|
+
export { authModule_getRefreshToken as getRefreshToken, authModule_getToken as getToken, authModule_getTokens as getTokens, authModule_hasToken as hasToken, authModule_removeToken as removeToken, authModule_setRefreshToken as setRefreshToken, authModule_setToken as setToken, authModule_setTokens as setTokens };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
interface SearchOptions {
|
|
145
|
+
fields?: string[];
|
|
146
|
+
caseSensitive?: boolean;
|
|
147
|
+
exactMatch?: boolean;
|
|
148
|
+
}
|
|
149
|
+
declare function searchContent<T extends Record<string, any>>(query: string, content: T[], options?: SearchOptions): T[];
|
|
150
|
+
declare function searchWithScore<T extends Record<string, any>>(query: string, content: T[], options?: SearchOptions): T[];
|
|
151
|
+
declare function fuzzySearch<T extends Record<string, any>>(query: string, content: T[], options?: SearchOptions & {
|
|
152
|
+
threshold?: number;
|
|
153
|
+
}): T[];
|
|
154
|
+
|
|
97
155
|
declare function usePasswordStrength(password: string, options?: {
|
|
98
156
|
minLength?: number;
|
|
99
157
|
requireUppercase?: boolean;
|
|
@@ -159,4 +217,9 @@ declare namespace ptBr {
|
|
|
159
217
|
export { ptBr_formatCompact as formatCompact, ptBr_formatCurrency as formatCurrency, ptBr_formatDate as formatDate, ptBr_formatDateTime as formatDateTime, ptBr_formatNumber as formatNumber, ptBr_formatRelativeDate as formatRelativeDate, ptBr_translateStatus as translateStatus };
|
|
160
218
|
}
|
|
161
219
|
|
|
162
|
-
|
|
220
|
+
declare const textProcessing: typeof textModule;
|
|
221
|
+
declare const datetime: typeof dateModule;
|
|
222
|
+
declare const authentication: typeof authModule;
|
|
223
|
+
declare const stateManagement: typeof statusModule;
|
|
224
|
+
|
|
225
|
+
export { Locale, type SearchOptions, type ValidationResult, authentication, calculateChange, calculateMovingAverage, calculateReadingTime, capitalize, cleanText, copyToClipboard, countWords, datetime, downloadFile, extractInitials, findMinMax, formatNumber$1 as formatNumber, formatPercentage, fuzzySearch, generateAvatarUrl, generateDynamicAvatarUrl, generateMockChartData, generateUniqueId, getAvatarColorFromName, getElementPosition, getRefreshToken, getToken, getTokens, groupDataByPeriod, hasToken, isDarkMode, isElementVisible, isEmpty, isMobile, isValidAvatarUrl, normalizeSpaces, onDarkModeChange, onReducedMotionChange, prefersReducedMotion, ptBr as ptBR, removeToken, scrollToElement, scrollToPosition, scrollToTop, searchContent, searchWithScore, setRefreshToken, setToken, setTokens, smoothScrollTo, stateManagement, textProcessing, truncateText, usePasswordStrength, validateEmail, validateMessage, validatePassword, validatePhone, validateSlug, validateText, validateUrl, validateUsername };
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,22 @@ var CURRENCY_MAP = {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
// src/text/index.ts
|
|
24
|
+
var text_exports = {};
|
|
25
|
+
__export(text_exports, {
|
|
26
|
+
calculateReadingTime: () => calculateReadingTime,
|
|
27
|
+
capitalize: () => capitalize,
|
|
28
|
+
cleanText: () => cleanText,
|
|
29
|
+
countWords: () => countWords,
|
|
30
|
+
extractInitials: () => extractInitials,
|
|
31
|
+
generateAvatarUrl: () => generateAvatarUrl,
|
|
32
|
+
generateDynamicAvatarUrl: () => generateDynamicAvatarUrl,
|
|
33
|
+
generateUniqueId: () => generateUniqueId,
|
|
34
|
+
getAvatarColorFromName: () => getAvatarColorFromName,
|
|
35
|
+
isEmpty: () => isEmpty,
|
|
36
|
+
isValidAvatarUrl: () => isValidAvatarUrl,
|
|
37
|
+
normalizeSpaces: () => normalizeSpaces,
|
|
38
|
+
truncateText: () => truncateText
|
|
39
|
+
});
|
|
24
40
|
function extractInitials(name, maxChars = 2) {
|
|
25
41
|
if (!name || !name.trim()) {
|
|
26
42
|
return "";
|
|
@@ -125,6 +141,28 @@ function normalizeSpaces(text, options = {}) {
|
|
|
125
141
|
}
|
|
126
142
|
return cleaned.trim();
|
|
127
143
|
}
|
|
144
|
+
function calculateReadingTime(content, wordsPerMinute = 200) {
|
|
145
|
+
let text = "";
|
|
146
|
+
if (typeof content === "object" && content !== null) {
|
|
147
|
+
const extractText = (node) => {
|
|
148
|
+
if (!node) return "";
|
|
149
|
+
let result = "";
|
|
150
|
+
if (node.text) {
|
|
151
|
+
result += node.text + " ";
|
|
152
|
+
}
|
|
153
|
+
if (Array.isArray(node.content)) {
|
|
154
|
+
result += node.content.map(extractText).join(" ");
|
|
155
|
+
}
|
|
156
|
+
return result;
|
|
157
|
+
};
|
|
158
|
+
text = extractText(content);
|
|
159
|
+
} else if (typeof content === "string") {
|
|
160
|
+
text = content.replace(/<[^>]*>/g, "");
|
|
161
|
+
}
|
|
162
|
+
const words = text.trim().split(/\s+/).filter((word) => word.length > 0).length;
|
|
163
|
+
const time = Math.ceil(words / wordsPerMinute);
|
|
164
|
+
return time > 0 ? time : 1;
|
|
165
|
+
}
|
|
128
166
|
|
|
129
167
|
// src/string/index.ts
|
|
130
168
|
function textToSlug(text) {
|
|
@@ -132,6 +170,14 @@ function textToSlug(text) {
|
|
|
132
170
|
}
|
|
133
171
|
|
|
134
172
|
// src/date/index.ts
|
|
173
|
+
var date_exports = {};
|
|
174
|
+
__export(date_exports, {
|
|
175
|
+
formatDate: () => formatDate,
|
|
176
|
+
formatDateTime: () => formatDateTime,
|
|
177
|
+
formatRelativeDate: () => formatRelativeDate,
|
|
178
|
+
isValidDate: () => isValidDate,
|
|
179
|
+
toISOString: () => toISOString
|
|
180
|
+
});
|
|
135
181
|
var RELATIVE_TEXTS = {
|
|
136
182
|
"pt-BR": {
|
|
137
183
|
now: "agora",
|
|
@@ -249,6 +295,13 @@ function formatCompact(value, decimals = 1, locale = DEFAULT_LOCALE) {
|
|
|
249
295
|
}
|
|
250
296
|
|
|
251
297
|
// src/status/index.ts
|
|
298
|
+
var status_exports = {};
|
|
299
|
+
__export(status_exports, {
|
|
300
|
+
getStatusColor: () => getStatusColor,
|
|
301
|
+
getStatusVariant: () => getStatusVariant,
|
|
302
|
+
translatePostStatus: () => translatePostStatus,
|
|
303
|
+
translateStatus: () => translateStatus
|
|
304
|
+
});
|
|
252
305
|
var STATUS_TRANSLATIONS = {
|
|
253
306
|
"pt-BR": {
|
|
254
307
|
// Estados de conteúdo
|
|
@@ -845,6 +898,153 @@ function findMinMax(data, field) {
|
|
|
845
898
|
max: Math.max(...values)
|
|
846
899
|
};
|
|
847
900
|
}
|
|
901
|
+
|
|
902
|
+
// src/auth/index.ts
|
|
903
|
+
var auth_exports = {};
|
|
904
|
+
__export(auth_exports, {
|
|
905
|
+
getRefreshToken: () => getRefreshToken,
|
|
906
|
+
getToken: () => getToken,
|
|
907
|
+
getTokens: () => getTokens,
|
|
908
|
+
hasToken: () => hasToken,
|
|
909
|
+
removeToken: () => removeToken,
|
|
910
|
+
setRefreshToken: () => setRefreshToken,
|
|
911
|
+
setToken: () => setToken,
|
|
912
|
+
setTokens: () => setTokens
|
|
913
|
+
});
|
|
914
|
+
var TOKEN_KEY = "auth_token";
|
|
915
|
+
var REFRESH_TOKEN_KEY = "refresh_token";
|
|
916
|
+
var getToken = () => {
|
|
917
|
+
if (typeof window === "undefined") {
|
|
918
|
+
return null;
|
|
919
|
+
}
|
|
920
|
+
return localStorage.getItem(TOKEN_KEY);
|
|
921
|
+
};
|
|
922
|
+
var setToken = (token) => {
|
|
923
|
+
if (typeof window === "undefined") {
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
localStorage.setItem(TOKEN_KEY, token);
|
|
927
|
+
};
|
|
928
|
+
var getRefreshToken = () => {
|
|
929
|
+
if (typeof window === "undefined") {
|
|
930
|
+
return null;
|
|
931
|
+
}
|
|
932
|
+
return localStorage.getItem(REFRESH_TOKEN_KEY);
|
|
933
|
+
};
|
|
934
|
+
var setRefreshToken = (refreshToken) => {
|
|
935
|
+
if (typeof window === "undefined") {
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
localStorage.setItem(REFRESH_TOKEN_KEY, refreshToken);
|
|
939
|
+
};
|
|
940
|
+
var removeToken = () => {
|
|
941
|
+
if (typeof window === "undefined") {
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
localStorage.removeItem(TOKEN_KEY);
|
|
945
|
+
localStorage.removeItem(REFRESH_TOKEN_KEY);
|
|
946
|
+
};
|
|
947
|
+
var hasToken = () => {
|
|
948
|
+
return !!getToken();
|
|
949
|
+
};
|
|
950
|
+
var getTokens = () => {
|
|
951
|
+
return {
|
|
952
|
+
accessToken: getToken(),
|
|
953
|
+
refreshToken: getRefreshToken()
|
|
954
|
+
};
|
|
955
|
+
};
|
|
956
|
+
var setTokens = ({
|
|
957
|
+
accessToken,
|
|
958
|
+
refreshToken
|
|
959
|
+
}) => {
|
|
960
|
+
setToken(accessToken);
|
|
961
|
+
setRefreshToken(refreshToken);
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
// src/search/index.ts
|
|
965
|
+
function searchContent(query, content, options = {}) {
|
|
966
|
+
if (!query.trim()) return content;
|
|
967
|
+
const {
|
|
968
|
+
fields = ["title", "description", "content", "tags"],
|
|
969
|
+
caseSensitive = false,
|
|
970
|
+
exactMatch = false
|
|
971
|
+
} = options;
|
|
972
|
+
const searchQuery = caseSensitive ? query : query.toLowerCase();
|
|
973
|
+
return content.filter((item) => {
|
|
974
|
+
return fields.some((field) => {
|
|
975
|
+
const value = item[field];
|
|
976
|
+
if (!value) return false;
|
|
977
|
+
if (Array.isArray(value)) {
|
|
978
|
+
return value.some((v) => {
|
|
979
|
+
const strValue2 = caseSensitive ? String(v) : String(v).toLowerCase();
|
|
980
|
+
return exactMatch ? strValue2 === searchQuery : strValue2.includes(searchQuery);
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
const strValue = caseSensitive ? String(value) : String(value).toLowerCase();
|
|
984
|
+
return exactMatch ? strValue === searchQuery : strValue.includes(searchQuery);
|
|
985
|
+
});
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
function searchWithScore(query, content, options = {}) {
|
|
989
|
+
if (!query.trim()) return content;
|
|
990
|
+
const {
|
|
991
|
+
fields = ["title", "description", "content", "tags"],
|
|
992
|
+
caseSensitive = false
|
|
993
|
+
} = options;
|
|
994
|
+
const searchQuery = caseSensitive ? query : query.toLowerCase();
|
|
995
|
+
const scored = content.map((item) => {
|
|
996
|
+
let score = 0;
|
|
997
|
+
fields.forEach((field, index) => {
|
|
998
|
+
const value = item[field];
|
|
999
|
+
if (!value) return;
|
|
1000
|
+
const weight = fields.length - index;
|
|
1001
|
+
if (Array.isArray(value)) {
|
|
1002
|
+
const matches = value.filter((v) => {
|
|
1003
|
+
const strValue = caseSensitive ? String(v) : String(v).toLowerCase();
|
|
1004
|
+
return strValue.includes(searchQuery);
|
|
1005
|
+
}).length;
|
|
1006
|
+
score += matches * weight;
|
|
1007
|
+
} else {
|
|
1008
|
+
const strValue = caseSensitive ? String(value) : String(value).toLowerCase();
|
|
1009
|
+
if (strValue.includes(searchQuery)) {
|
|
1010
|
+
score += weight;
|
|
1011
|
+
if (strValue === searchQuery) {
|
|
1012
|
+
score += weight * 2;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
1017
|
+
return { item, score };
|
|
1018
|
+
});
|
|
1019
|
+
return scored.filter(({ score }) => score > 0).sort((a, b) => b.score - a.score).map(({ item }) => item);
|
|
1020
|
+
}
|
|
1021
|
+
function fuzzySearch(query, content, options = {}) {
|
|
1022
|
+
if (!query.trim()) return content;
|
|
1023
|
+
const {
|
|
1024
|
+
fields = ["title", "description"],
|
|
1025
|
+
caseSensitive = false,
|
|
1026
|
+
threshold = 0.6
|
|
1027
|
+
// Similaridade mínima (0-1)
|
|
1028
|
+
} = options;
|
|
1029
|
+
const searchQuery = caseSensitive ? query : query.toLowerCase();
|
|
1030
|
+
return content.filter((item) => {
|
|
1031
|
+
return fields.some((field) => {
|
|
1032
|
+
const value = item[field];
|
|
1033
|
+
if (!value) return false;
|
|
1034
|
+
const strValue = caseSensitive ? String(value) : String(value).toLowerCase();
|
|
1035
|
+
const similarity = calculateSimilarity(searchQuery, strValue);
|
|
1036
|
+
return similarity >= threshold;
|
|
1037
|
+
});
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
function calculateSimilarity(str1, str2) {
|
|
1041
|
+
if (str1 === str2) return 1;
|
|
1042
|
+
if (str1.length === 0 || str2.length === 0) return 0;
|
|
1043
|
+
if (str2.includes(str1)) return 0.8;
|
|
1044
|
+
const common = str1.split("").filter((char) => str2.includes(char)).length;
|
|
1045
|
+
const similarity = common / Math.max(str1.length, str2.length);
|
|
1046
|
+
return similarity;
|
|
1047
|
+
}
|
|
848
1048
|
function usePasswordStrength(password, options = {}) {
|
|
849
1049
|
const {
|
|
850
1050
|
minLength = 8,
|
|
@@ -1065,14 +1265,23 @@ function translateStatus2(status) {
|
|
|
1065
1265
|
return translateStatus(status, "pt-BR");
|
|
1066
1266
|
}
|
|
1067
1267
|
|
|
1268
|
+
// src/index.ts
|
|
1269
|
+
var textProcessing = text_exports;
|
|
1270
|
+
var datetime = date_exports;
|
|
1271
|
+
var authentication = auth_exports;
|
|
1272
|
+
var stateManagement = status_exports;
|
|
1273
|
+
|
|
1068
1274
|
exports.CURRENCY_MAP = CURRENCY_MAP;
|
|
1069
1275
|
exports.DEFAULT_LOCALE = DEFAULT_LOCALE;
|
|
1276
|
+
exports.authentication = authentication;
|
|
1070
1277
|
exports.calculateChange = calculateChange;
|
|
1071
1278
|
exports.calculateMovingAverage = calculateMovingAverage;
|
|
1279
|
+
exports.calculateReadingTime = calculateReadingTime;
|
|
1072
1280
|
exports.capitalize = capitalize;
|
|
1073
1281
|
exports.cleanText = cleanText;
|
|
1074
1282
|
exports.copyToClipboard = copyToClipboard;
|
|
1075
1283
|
exports.countWords = countWords;
|
|
1284
|
+
exports.datetime = datetime;
|
|
1076
1285
|
exports.downloadFile = downloadFile;
|
|
1077
1286
|
exports.extractInitials = extractInitials;
|
|
1078
1287
|
exports.findMinMax = findMinMax;
|
|
@@ -1082,15 +1291,20 @@ exports.formatDateTime = formatDateTime;
|
|
|
1082
1291
|
exports.formatNumber = formatNumber2;
|
|
1083
1292
|
exports.formatPercentage = formatPercentage;
|
|
1084
1293
|
exports.formatRelativeDate = formatRelativeDate;
|
|
1294
|
+
exports.fuzzySearch = fuzzySearch;
|
|
1085
1295
|
exports.generateAvatarUrl = generateAvatarUrl;
|
|
1086
1296
|
exports.generateDynamicAvatarUrl = generateDynamicAvatarUrl;
|
|
1087
1297
|
exports.generateMockChartData = generateMockChartData;
|
|
1088
1298
|
exports.generateUniqueId = generateUniqueId;
|
|
1089
1299
|
exports.getAvatarColorFromName = getAvatarColorFromName;
|
|
1090
1300
|
exports.getElementPosition = getElementPosition;
|
|
1301
|
+
exports.getRefreshToken = getRefreshToken;
|
|
1091
1302
|
exports.getStatusColor = getStatusColor;
|
|
1092
1303
|
exports.getStatusVariant = getStatusVariant;
|
|
1304
|
+
exports.getToken = getToken;
|
|
1305
|
+
exports.getTokens = getTokens;
|
|
1093
1306
|
exports.groupDataByPeriod = groupDataByPeriod;
|
|
1307
|
+
exports.hasToken = hasToken;
|
|
1094
1308
|
exports.isDarkMode = isDarkMode;
|
|
1095
1309
|
exports.isElementVisible = isElementVisible;
|
|
1096
1310
|
exports.isEmpty = isEmpty;
|
|
@@ -1102,10 +1316,18 @@ exports.onDarkModeChange = onDarkModeChange;
|
|
|
1102
1316
|
exports.onReducedMotionChange = onReducedMotionChange;
|
|
1103
1317
|
exports.prefersReducedMotion = prefersReducedMotion;
|
|
1104
1318
|
exports.ptBR = pt_br_exports;
|
|
1319
|
+
exports.removeToken = removeToken;
|
|
1105
1320
|
exports.scrollToElement = scrollToElement;
|
|
1106
1321
|
exports.scrollToPosition = scrollToPosition;
|
|
1107
1322
|
exports.scrollToTop = scrollToTop;
|
|
1323
|
+
exports.searchContent = searchContent;
|
|
1324
|
+
exports.searchWithScore = searchWithScore;
|
|
1325
|
+
exports.setRefreshToken = setRefreshToken;
|
|
1326
|
+
exports.setToken = setToken;
|
|
1327
|
+
exports.setTokens = setTokens;
|
|
1108
1328
|
exports.smoothScrollTo = smoothScrollTo;
|
|
1329
|
+
exports.stateManagement = stateManagement;
|
|
1330
|
+
exports.textProcessing = textProcessing;
|
|
1109
1331
|
exports.textToSlug = textToSlug;
|
|
1110
1332
|
exports.toISOString = toISOString;
|
|
1111
1333
|
exports.translatePostStatus = translatePostStatus;
|