super-utilix 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/README.md +148 -0
- package/dist/index.d.mts +139 -0
- package/dist/index.d.ts +139 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# super-utilix
|
|
2
|
+
|
|
3
|
+
A powerful and comprehensive utility library for TypeScript/JavaScript applications. This package provides a wide range of helper functions for handling dates, objects, arrays, string manipulation, validation, and more.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install super-utilix
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- 📅 **Date Utilities**: Format dates, calculate age, validate future dates, and more.
|
|
14
|
+
- 🛠 **Object Utilities**: deep object manipulation, filtering, sorting, and form data conversion.
|
|
15
|
+
- 🔍 **Search & Filter**: Recursive search in objects, array filtering, and query string generation.
|
|
16
|
+
- 🔢 **Arabic Utilities**: Convert numbers to Arabic ordinal words.
|
|
17
|
+
- 📝 **DOM & Events**: HTML text extraction and keyboard event handlers (Arabic, English, Numbers).
|
|
18
|
+
- 🔄 **CRUD Helpers**: Frontend-side state management for Create, Read, Update, Delete operations.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## API Reference
|
|
23
|
+
|
|
24
|
+
### 1. Arabic Utilities (`literalOrdinals`)
|
|
25
|
+
Convert numbers into their Arabic ordinal representation (e.g., 1 -> الأول).
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { literalOrdinals } from 'super-utilix';
|
|
29
|
+
|
|
30
|
+
console.log(literalOrdinals(1, 'ar')); // "الأول"
|
|
31
|
+
console.log(literalOrdinals(25, 'ar')); // "الخامس والعشرون"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 2. Date Utilities
|
|
35
|
+
|
|
36
|
+
#### `formatDateTime(date)`
|
|
37
|
+
Formats a date string or object into `DD/MM/YYYY, h:mmA`.
|
|
38
|
+
```typescript
|
|
39
|
+
formatDateTime('2023-12-25T14:30:00'); // "25/12/2023, 2:30PM"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
#### `formatDate(date)`
|
|
43
|
+
Formats a date string or object into `DD/MM/YYYY`.
|
|
44
|
+
```typescript
|
|
45
|
+
formatDate('2023-12-25'); // "25/12/2023"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
#### `calculateDetailedAge(birthDate, t, currentDate, gender)`
|
|
49
|
+
Calculates detailed age (years, months, days) with localization support.
|
|
50
|
+
```typescript
|
|
51
|
+
const age = calculateDetailedAge('1990-01-01');
|
|
52
|
+
console.log(age.message); // "33 years - 11 months - 24 days..."
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### `calculateAge(birthDate)`
|
|
56
|
+
Returns the age in years from a given birth date.
|
|
57
|
+
```typescript
|
|
58
|
+
calculateAge('1990-01-01'); // 33
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 3. Object Utilities
|
|
62
|
+
|
|
63
|
+
#### `removeEmptyFields(obj)`
|
|
64
|
+
Removes fields with `null`, `undefined`, or empty string values from an object.
|
|
65
|
+
```typescript
|
|
66
|
+
const clean = removeEmptyFields({ name: 'Ali', age: null, city: '' });
|
|
67
|
+
// { name: 'Ali' }
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
#### `objectToFormData(obj)`
|
|
71
|
+
Converts a potentially nested object into a `FormData` object (useful for API requests).
|
|
72
|
+
```typescript
|
|
73
|
+
const formData = objectToFormData({ name: 'Ali', file: fileObj });
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
#### `compareObjects(original, updated, keysToIgnore)`
|
|
77
|
+
Deeply compares two objects to check if they are equivalent, optionally ignoring specific keys.
|
|
78
|
+
```typescript
|
|
79
|
+
const isEqual = compareObjects({ a: 1 }, { a: 1, b: 2 }, ['b']); // true
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### `getChangedFields(original, updated)`
|
|
83
|
+
Returns an object containing only the fields that have changed between two objects.
|
|
84
|
+
```typescript
|
|
85
|
+
const changes = getChangedFields({ a: 1 }, { a: 2 }); // { a: 2 }
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 4. Search & Filter Utilities
|
|
89
|
+
|
|
90
|
+
#### `searchInObjects(data, query, childrenField, fieldsToSearch)`
|
|
91
|
+
Recursively searches through an array of objects (and their children) for a query string.
|
|
92
|
+
```typescript
|
|
93
|
+
const result = searchInObjects(treeData, 'node', 'children', ['name']);
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### `filterInArray(field, values, data)`
|
|
97
|
+
Filters an array of objects based on whether a field's value exists in a provided array.
|
|
98
|
+
```typescript
|
|
99
|
+
filterInArray('id', [1, 2], [{ id: 1 }, { id: 3 }]); // [{ id: 1 }]
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### `toQueryString(params)`
|
|
103
|
+
Converts an object into a URL query string, automatically removing empty fields.
|
|
104
|
+
```typescript
|
|
105
|
+
toQueryString({ page: 1, search: 'test' }); // "page=1&search=test"
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 5. Event Handlers (Input Validation)
|
|
109
|
+
|
|
110
|
+
#### `handleKeyDownNumber(event)`
|
|
111
|
+
Prevents non-numeric input in text fields.
|
|
112
|
+
```typescript
|
|
113
|
+
<input onKeyDown={handleKeyDownNumber} />
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### `handleKeyDownArabic(event)`
|
|
117
|
+
Restricts input to Arabic characters and common symbols.
|
|
118
|
+
|
|
119
|
+
#### `handleKeyDownEnglish(event)`
|
|
120
|
+
Restricts input to English characters and common symbols.
|
|
121
|
+
|
|
122
|
+
### 6. DOM Utilities
|
|
123
|
+
|
|
124
|
+
#### `getTextOnlyFromHtml(html)`
|
|
125
|
+
Extracts plain text from an HTML string using `DOMParser`.
|
|
126
|
+
```typescript
|
|
127
|
+
getTextOnlyFromHtml('<p>Hello <b>World</b></p>'); // "Hello World"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### 7. CRUD Operations (Frontend)
|
|
131
|
+
Helper functions to manage state arrays for CRUD operations.
|
|
132
|
+
|
|
133
|
+
- `handleCreateFront`: Adds a new item to the list.
|
|
134
|
+
- `handleUpdateFront`: Updates an existing item in the list.
|
|
135
|
+
- `handleDeleteFront`: Removes an item from the list.
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
handleCreateFront({ items, setItems, itemData: { name: 'New Item' } });
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 8. Validation
|
|
142
|
+
|
|
143
|
+
#### `validateDay(value)`, `validateMonth(value)`, `validateYear(value)`
|
|
144
|
+
Validates and sanitizes date inputs (e.g., ensures day is between 1-31).
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
ISC
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
declare const literalOrdinals: (num: number, lang: "ar" | "en") => string;
|
|
2
|
+
|
|
3
|
+
declare const handleCreateFront: ({ items, setItems, itemData }: {
|
|
4
|
+
items?: any[];
|
|
5
|
+
setItems?: any;
|
|
6
|
+
itemData?: any;
|
|
7
|
+
}) => void;
|
|
8
|
+
declare const handleCreateFrontUnique: ({ items, setItems, itemData, uniqueField }: {
|
|
9
|
+
items?: any[];
|
|
10
|
+
setItems?: any;
|
|
11
|
+
itemData?: any;
|
|
12
|
+
uniqueField?: string;
|
|
13
|
+
}) => void;
|
|
14
|
+
declare const handleUpdateFront: ({ id, items, setItems, itemData }: {
|
|
15
|
+
id?: number | string;
|
|
16
|
+
items?: any[];
|
|
17
|
+
setItems?: any;
|
|
18
|
+
itemData?: any;
|
|
19
|
+
}) => void;
|
|
20
|
+
declare const handleDeleteFront: ({ id, items, setItems }: {
|
|
21
|
+
id?: number | string | null | (number | string | null)[];
|
|
22
|
+
items?: any[];
|
|
23
|
+
setItems?: any;
|
|
24
|
+
}) => void;
|
|
25
|
+
|
|
26
|
+
declare const formatDateTime: (date: string | Date | null | undefined) => string;
|
|
27
|
+
declare const formatDate: (date: string | Date | null | undefined) => string;
|
|
28
|
+
declare const isNotFutureDate: (date: string) => boolean;
|
|
29
|
+
declare function getTime(inputDate: string | Date | null | undefined): string;
|
|
30
|
+
interface Age {
|
|
31
|
+
years: number;
|
|
32
|
+
months: number;
|
|
33
|
+
days: number;
|
|
34
|
+
}
|
|
35
|
+
declare const calculateDetailedAge: (birthDate?: Date | string | null, t?: (key: string) => string, currentDate?: Date | string, gender?: string) => {
|
|
36
|
+
age: Age;
|
|
37
|
+
message: string;
|
|
38
|
+
};
|
|
39
|
+
declare const birthDateToAge: (birthDate?: Date | string | null) => {
|
|
40
|
+
years: number;
|
|
41
|
+
months: number;
|
|
42
|
+
days: number;
|
|
43
|
+
} | null;
|
|
44
|
+
declare const ageToBirthDate: (age: {
|
|
45
|
+
years: number;
|
|
46
|
+
months: number;
|
|
47
|
+
days: number;
|
|
48
|
+
}) => Date;
|
|
49
|
+
declare const ageToBirthDateChangeSegment: (oldAge: {
|
|
50
|
+
years: number;
|
|
51
|
+
months: number;
|
|
52
|
+
days: number;
|
|
53
|
+
} | null, age: {
|
|
54
|
+
years: number;
|
|
55
|
+
months: number;
|
|
56
|
+
days: number;
|
|
57
|
+
}) => Date;
|
|
58
|
+
declare function convertTimeToTimestamp(timeString: string): number;
|
|
59
|
+
declare const calculateAge: (birthDate: string) => number;
|
|
60
|
+
|
|
61
|
+
declare const getTextOnlyFromHtml: (html?: string) => string;
|
|
62
|
+
|
|
63
|
+
declare const handleKeyDownArabic: (event: any) => void;
|
|
64
|
+
declare const handleKeyDownEnglish: (event: any) => void;
|
|
65
|
+
declare const handleKeyDownNumber: (event: any) => void;
|
|
66
|
+
declare const handleKeyDownNumberNoCopy: (event: any) => void;
|
|
67
|
+
declare const handleKeyDownFloatNumber: (event: any) => void;
|
|
68
|
+
|
|
69
|
+
declare function filterInArray<T>(field: keyof T, values: T[keyof T][], data: T[]): T[];
|
|
70
|
+
declare function filterInObjects(data: any[] | undefined, query: string[], childrenField?: string, fieldsToFilter?: string[]): any[];
|
|
71
|
+
|
|
72
|
+
declare const capitalizeString: (str: string) => string;
|
|
73
|
+
declare function removeEmptyFields<T extends Record<string, any>>(obj: T): Partial<T>;
|
|
74
|
+
type WithId = {
|
|
75
|
+
_id?: string;
|
|
76
|
+
[key: string]: any;
|
|
77
|
+
};
|
|
78
|
+
declare function removeIdFromObjects<T extends WithId>(objects: T[]): Omit<T, "_id">[];
|
|
79
|
+
declare function removeItemsWithIds(array: any[], idsToRemove: string[]): any[];
|
|
80
|
+
declare function createOptionsArray<T>(data: T[], valueField: keyof T, ...labelFields: (keyof T)[]): {
|
|
81
|
+
value: string | number;
|
|
82
|
+
label: string;
|
|
83
|
+
}[];
|
|
84
|
+
declare function filterUsersOption(option: any, inputValue: string): any;
|
|
85
|
+
declare function removeKeys(obj: any, keys: string[]): any;
|
|
86
|
+
declare function getArrayKeys(obj: any): {
|
|
87
|
+
[x: string]: any[];
|
|
88
|
+
}[];
|
|
89
|
+
declare function convertObjectToArray(obj: any): any[];
|
|
90
|
+
type Permission = {
|
|
91
|
+
[key: string]: string[];
|
|
92
|
+
};
|
|
93
|
+
declare function comparePermissionLists(list1: Permission[], list2: Permission[]): boolean;
|
|
94
|
+
declare function objectToFormData(obj: Record<string, any>, formData?: FormData, namespace?: string): FormData;
|
|
95
|
+
/**
|
|
96
|
+
* Compares two objects and returns true if they are equivalent.
|
|
97
|
+
* Ignores specified keys if provided.
|
|
98
|
+
*
|
|
99
|
+
* @param {any} original - The original object.
|
|
100
|
+
* @param {any} updated - The updated object to compare with.
|
|
101
|
+
* @param {string[]} [keysToIgnore=[]] - Optional keys to ignore during comparison.
|
|
102
|
+
* @returns {boolean} - True if objects are equivalent, otherwise false.
|
|
103
|
+
*/
|
|
104
|
+
declare function compareObjects(original: any, updated: any, keysToIgnore?: string[]): boolean;
|
|
105
|
+
declare function getChangedFields(original: any, updated: any): any;
|
|
106
|
+
declare function sortObjectByKeys<T extends Record<string, any>>(obj: T): T;
|
|
107
|
+
declare function sortObjectByValues<T extends Record<string, any>>(obj: T): T;
|
|
108
|
+
type AnyObject = {
|
|
109
|
+
[key: string]: any;
|
|
110
|
+
};
|
|
111
|
+
declare function removeFields(obj: AnyObject, fieldsToRemove: string[]): AnyObject;
|
|
112
|
+
declare function removeFieldsTopLevel(obj: AnyObject | AnyObject[] | null | undefined, fieldsToRemove?: string[]): any;
|
|
113
|
+
declare function removeFieldsFromObject(obj: AnyObject, fieldsToRemove?: string[]): AnyObject;
|
|
114
|
+
declare const getLabelByItemsAndId: (id?: string | number, items?: any[], fields?: string[] | string) => any;
|
|
115
|
+
declare const getLabelByItemsAndOptions: (id?: string | number | null, items?: any[]) => any;
|
|
116
|
+
|
|
117
|
+
declare function toQueryString(params?: any): string;
|
|
118
|
+
declare function pureURLS3(url: string | undefined): string | undefined;
|
|
119
|
+
declare const createSearchQuery: (params: Record<string, string | number | boolean | undefined | string[] | number[]>) => string;
|
|
120
|
+
declare const serializeFormQuery: (params: Record<string, string | number | boolean | undefined | string[] | number[]>) => string;
|
|
121
|
+
declare const arrFromQuery: (query: string | null) => number[];
|
|
122
|
+
declare const uniqueId: () => number;
|
|
123
|
+
declare const prePareFilters: (searchParams: URLSearchParams) => any;
|
|
124
|
+
|
|
125
|
+
declare const addSearchParam: (searchParams: URLSearchParams, setSearchParams: any, key: string, value: string) => void;
|
|
126
|
+
/**
|
|
127
|
+
* Recursively searches across all fields of objects and their [`${childrenField}`].
|
|
128
|
+
* @param data - The array of objects to search.
|
|
129
|
+
* @param query - The search query string.
|
|
130
|
+
* @returns An array of objects that match the search query.
|
|
131
|
+
*/
|
|
132
|
+
declare function searchInObjectsWithParents(data?: any[], query?: string, childrenField?: string, fieldsToSearch?: string[]): any[];
|
|
133
|
+
declare function searchInObjects(data?: any[], query?: string, childrenField?: string, fieldsToSearch?: string[]): any[];
|
|
134
|
+
|
|
135
|
+
declare const validateDay: (value: string) => string;
|
|
136
|
+
declare const validateMonth: (value: string) => string;
|
|
137
|
+
declare const validateYear: (value: string) => string;
|
|
138
|
+
|
|
139
|
+
export { addSearchParam, ageToBirthDate, ageToBirthDateChangeSegment, arrFromQuery, birthDateToAge, calculateAge, calculateDetailedAge, capitalizeString, compareObjects, comparePermissionLists, convertObjectToArray, convertTimeToTimestamp, createOptionsArray, createSearchQuery, filterInArray, filterInObjects, filterUsersOption, formatDate, formatDateTime, getArrayKeys, getChangedFields, getLabelByItemsAndId, getLabelByItemsAndOptions, getTextOnlyFromHtml, getTime, handleCreateFront, handleCreateFrontUnique, handleDeleteFront, handleKeyDownArabic, handleKeyDownEnglish, handleKeyDownFloatNumber, handleKeyDownNumber, handleKeyDownNumberNoCopy, handleUpdateFront, isNotFutureDate, literalOrdinals, objectToFormData, prePareFilters, pureURLS3, removeEmptyFields, removeFields, removeFieldsFromObject, removeFieldsTopLevel, removeIdFromObjects, removeItemsWithIds, removeKeys, searchInObjects, searchInObjectsWithParents, serializeFormQuery, sortObjectByKeys, sortObjectByValues, toQueryString, uniqueId, validateDay, validateMonth, validateYear };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
declare const literalOrdinals: (num: number, lang: "ar" | "en") => string;
|
|
2
|
+
|
|
3
|
+
declare const handleCreateFront: ({ items, setItems, itemData }: {
|
|
4
|
+
items?: any[];
|
|
5
|
+
setItems?: any;
|
|
6
|
+
itemData?: any;
|
|
7
|
+
}) => void;
|
|
8
|
+
declare const handleCreateFrontUnique: ({ items, setItems, itemData, uniqueField }: {
|
|
9
|
+
items?: any[];
|
|
10
|
+
setItems?: any;
|
|
11
|
+
itemData?: any;
|
|
12
|
+
uniqueField?: string;
|
|
13
|
+
}) => void;
|
|
14
|
+
declare const handleUpdateFront: ({ id, items, setItems, itemData }: {
|
|
15
|
+
id?: number | string;
|
|
16
|
+
items?: any[];
|
|
17
|
+
setItems?: any;
|
|
18
|
+
itemData?: any;
|
|
19
|
+
}) => void;
|
|
20
|
+
declare const handleDeleteFront: ({ id, items, setItems }: {
|
|
21
|
+
id?: number | string | null | (number | string | null)[];
|
|
22
|
+
items?: any[];
|
|
23
|
+
setItems?: any;
|
|
24
|
+
}) => void;
|
|
25
|
+
|
|
26
|
+
declare const formatDateTime: (date: string | Date | null | undefined) => string;
|
|
27
|
+
declare const formatDate: (date: string | Date | null | undefined) => string;
|
|
28
|
+
declare const isNotFutureDate: (date: string) => boolean;
|
|
29
|
+
declare function getTime(inputDate: string | Date | null | undefined): string;
|
|
30
|
+
interface Age {
|
|
31
|
+
years: number;
|
|
32
|
+
months: number;
|
|
33
|
+
days: number;
|
|
34
|
+
}
|
|
35
|
+
declare const calculateDetailedAge: (birthDate?: Date | string | null, t?: (key: string) => string, currentDate?: Date | string, gender?: string) => {
|
|
36
|
+
age: Age;
|
|
37
|
+
message: string;
|
|
38
|
+
};
|
|
39
|
+
declare const birthDateToAge: (birthDate?: Date | string | null) => {
|
|
40
|
+
years: number;
|
|
41
|
+
months: number;
|
|
42
|
+
days: number;
|
|
43
|
+
} | null;
|
|
44
|
+
declare const ageToBirthDate: (age: {
|
|
45
|
+
years: number;
|
|
46
|
+
months: number;
|
|
47
|
+
days: number;
|
|
48
|
+
}) => Date;
|
|
49
|
+
declare const ageToBirthDateChangeSegment: (oldAge: {
|
|
50
|
+
years: number;
|
|
51
|
+
months: number;
|
|
52
|
+
days: number;
|
|
53
|
+
} | null, age: {
|
|
54
|
+
years: number;
|
|
55
|
+
months: number;
|
|
56
|
+
days: number;
|
|
57
|
+
}) => Date;
|
|
58
|
+
declare function convertTimeToTimestamp(timeString: string): number;
|
|
59
|
+
declare const calculateAge: (birthDate: string) => number;
|
|
60
|
+
|
|
61
|
+
declare const getTextOnlyFromHtml: (html?: string) => string;
|
|
62
|
+
|
|
63
|
+
declare const handleKeyDownArabic: (event: any) => void;
|
|
64
|
+
declare const handleKeyDownEnglish: (event: any) => void;
|
|
65
|
+
declare const handleKeyDownNumber: (event: any) => void;
|
|
66
|
+
declare const handleKeyDownNumberNoCopy: (event: any) => void;
|
|
67
|
+
declare const handleKeyDownFloatNumber: (event: any) => void;
|
|
68
|
+
|
|
69
|
+
declare function filterInArray<T>(field: keyof T, values: T[keyof T][], data: T[]): T[];
|
|
70
|
+
declare function filterInObjects(data: any[] | undefined, query: string[], childrenField?: string, fieldsToFilter?: string[]): any[];
|
|
71
|
+
|
|
72
|
+
declare const capitalizeString: (str: string) => string;
|
|
73
|
+
declare function removeEmptyFields<T extends Record<string, any>>(obj: T): Partial<T>;
|
|
74
|
+
type WithId = {
|
|
75
|
+
_id?: string;
|
|
76
|
+
[key: string]: any;
|
|
77
|
+
};
|
|
78
|
+
declare function removeIdFromObjects<T extends WithId>(objects: T[]): Omit<T, "_id">[];
|
|
79
|
+
declare function removeItemsWithIds(array: any[], idsToRemove: string[]): any[];
|
|
80
|
+
declare function createOptionsArray<T>(data: T[], valueField: keyof T, ...labelFields: (keyof T)[]): {
|
|
81
|
+
value: string | number;
|
|
82
|
+
label: string;
|
|
83
|
+
}[];
|
|
84
|
+
declare function filterUsersOption(option: any, inputValue: string): any;
|
|
85
|
+
declare function removeKeys(obj: any, keys: string[]): any;
|
|
86
|
+
declare function getArrayKeys(obj: any): {
|
|
87
|
+
[x: string]: any[];
|
|
88
|
+
}[];
|
|
89
|
+
declare function convertObjectToArray(obj: any): any[];
|
|
90
|
+
type Permission = {
|
|
91
|
+
[key: string]: string[];
|
|
92
|
+
};
|
|
93
|
+
declare function comparePermissionLists(list1: Permission[], list2: Permission[]): boolean;
|
|
94
|
+
declare function objectToFormData(obj: Record<string, any>, formData?: FormData, namespace?: string): FormData;
|
|
95
|
+
/**
|
|
96
|
+
* Compares two objects and returns true if they are equivalent.
|
|
97
|
+
* Ignores specified keys if provided.
|
|
98
|
+
*
|
|
99
|
+
* @param {any} original - The original object.
|
|
100
|
+
* @param {any} updated - The updated object to compare with.
|
|
101
|
+
* @param {string[]} [keysToIgnore=[]] - Optional keys to ignore during comparison.
|
|
102
|
+
* @returns {boolean} - True if objects are equivalent, otherwise false.
|
|
103
|
+
*/
|
|
104
|
+
declare function compareObjects(original: any, updated: any, keysToIgnore?: string[]): boolean;
|
|
105
|
+
declare function getChangedFields(original: any, updated: any): any;
|
|
106
|
+
declare function sortObjectByKeys<T extends Record<string, any>>(obj: T): T;
|
|
107
|
+
declare function sortObjectByValues<T extends Record<string, any>>(obj: T): T;
|
|
108
|
+
type AnyObject = {
|
|
109
|
+
[key: string]: any;
|
|
110
|
+
};
|
|
111
|
+
declare function removeFields(obj: AnyObject, fieldsToRemove: string[]): AnyObject;
|
|
112
|
+
declare function removeFieldsTopLevel(obj: AnyObject | AnyObject[] | null | undefined, fieldsToRemove?: string[]): any;
|
|
113
|
+
declare function removeFieldsFromObject(obj: AnyObject, fieldsToRemove?: string[]): AnyObject;
|
|
114
|
+
declare const getLabelByItemsAndId: (id?: string | number, items?: any[], fields?: string[] | string) => any;
|
|
115
|
+
declare const getLabelByItemsAndOptions: (id?: string | number | null, items?: any[]) => any;
|
|
116
|
+
|
|
117
|
+
declare function toQueryString(params?: any): string;
|
|
118
|
+
declare function pureURLS3(url: string | undefined): string | undefined;
|
|
119
|
+
declare const createSearchQuery: (params: Record<string, string | number | boolean | undefined | string[] | number[]>) => string;
|
|
120
|
+
declare const serializeFormQuery: (params: Record<string, string | number | boolean | undefined | string[] | number[]>) => string;
|
|
121
|
+
declare const arrFromQuery: (query: string | null) => number[];
|
|
122
|
+
declare const uniqueId: () => number;
|
|
123
|
+
declare const prePareFilters: (searchParams: URLSearchParams) => any;
|
|
124
|
+
|
|
125
|
+
declare const addSearchParam: (searchParams: URLSearchParams, setSearchParams: any, key: string, value: string) => void;
|
|
126
|
+
/**
|
|
127
|
+
* Recursively searches across all fields of objects and their [`${childrenField}`].
|
|
128
|
+
* @param data - The array of objects to search.
|
|
129
|
+
* @param query - The search query string.
|
|
130
|
+
* @returns An array of objects that match the search query.
|
|
131
|
+
*/
|
|
132
|
+
declare function searchInObjectsWithParents(data?: any[], query?: string, childrenField?: string, fieldsToSearch?: string[]): any[];
|
|
133
|
+
declare function searchInObjects(data?: any[], query?: string, childrenField?: string, fieldsToSearch?: string[]): any[];
|
|
134
|
+
|
|
135
|
+
declare const validateDay: (value: string) => string;
|
|
136
|
+
declare const validateMonth: (value: string) => string;
|
|
137
|
+
declare const validateYear: (value: string) => string;
|
|
138
|
+
|
|
139
|
+
export { addSearchParam, ageToBirthDate, ageToBirthDateChangeSegment, arrFromQuery, birthDateToAge, calculateAge, calculateDetailedAge, capitalizeString, compareObjects, comparePermissionLists, convertObjectToArray, convertTimeToTimestamp, createOptionsArray, createSearchQuery, filterInArray, filterInObjects, filterUsersOption, formatDate, formatDateTime, getArrayKeys, getChangedFields, getLabelByItemsAndId, getLabelByItemsAndOptions, getTextOnlyFromHtml, getTime, handleCreateFront, handleCreateFrontUnique, handleDeleteFront, handleKeyDownArabic, handleKeyDownEnglish, handleKeyDownFloatNumber, handleKeyDownNumber, handleKeyDownNumberNoCopy, handleUpdateFront, isNotFutureDate, literalOrdinals, objectToFormData, prePareFilters, pureURLS3, removeEmptyFields, removeFields, removeFieldsFromObject, removeFieldsTopLevel, removeIdFromObjects, removeItemsWithIds, removeKeys, searchInObjects, searchInObjectsWithParents, serializeFormQuery, sortObjectByKeys, sortObjectByValues, toQueryString, uniqueId, validateDay, validateMonth, validateYear };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var E=Object.create;var g=Object.defineProperty,L=Object.defineProperties,C=Object.getOwnPropertyDescriptor,U=Object.getOwnPropertyDescriptors,P=Object.getOwnPropertyNames,p=Object.getOwnPropertySymbols,R=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable;var F=(t,e,r)=>e in t?g(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,y=(t,e)=>{for(var r in e||(e={}))d.call(e,r)&&F(t,r,e[r]);if(p)for(var r of p(e))M.call(e,r)&&F(t,r,e[r]);return t},j=(t,e)=>L(t,U(e));var $=(t,e)=>{var r={};for(var n in t)d.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&p)for(var n of p(t))e.indexOf(n)<0&&M.call(t,n)&&(r[n]=t[n]);return r};var K=(t,e)=>{for(var r in e)g(t,r,{get:e[r],enumerable:!0})},S=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of P(e))!d.call(t,o)&&o!==r&&g(t,o,{get:()=>e[o],enumerable:!(n=C(e,o))||n.enumerable});return t};var N=(t,e,r)=>(r=t!=null?E(R(t)):{},S(e||!t||!t.__esModule?g(r,"default",{value:t,enumerable:!0}):r,t)),B=t=>S(g({},"__esModule",{value:!0}),t);var Ke={};K(Ke,{addSearchParam:()=>Ee,ageToBirthDate:()=>V,ageToBirthDateChangeSegment:()=>q,arrFromQuery:()=>Ye,birthDateToAge:()=>X,calculateAge:()=>te,calculateDetailedAge:()=>G,capitalizeString:()=>le,compareObjects:()=>be,comparePermissionLists:()=>De,convertObjectToArray:()=>xe,convertTimeToTimestamp:()=>ee,createOptionsArray:()=>pe,createSearchQuery:()=>$e,filterInArray:()=>ue,filterInObjects:()=>fe,filterUsersOption:()=>de,formatDate:()=>H,formatDateTime:()=>W,getArrayKeys:()=>me,getChangedFields:()=>k,getLabelByItemsAndId:()=>Te,getLabelByItemsAndOptions:()=>Fe,getTextOnlyFromHtml:()=>ne,getTime:()=>Z,handleCreateFront:()=>v,handleCreateFrontUnique:()=>z,handleDeleteFront:()=>_,handleKeyDownArabic:()=>oe,handleKeyDownEnglish:()=>se,handleKeyDownFloatNumber:()=>ce,handleKeyDownNumber:()=>ae,handleKeyDownNumberNoCopy:()=>ie,handleUpdateFront:()=>Q,isNotFutureDate:()=>J,literalOrdinals:()=>Y,objectToFormData:()=>I,prePareFilters:()=>ke,pureURLS3:()=>je,removeEmptyFields:()=>D,removeFields:()=>m,removeFieldsFromObject:()=>x,removeFieldsTopLevel:()=>Oe,removeIdFromObjects:()=>ye,removeItemsWithIds:()=>ge,removeKeys:()=>he,searchInObjects:()=>Ce,searchInObjectsWithParents:()=>Le,serializeFormQuery:()=>Se,sortObjectByKeys:()=>we,sortObjectByValues:()=>Ae,toQueryString:()=>Me,uniqueId:()=>Ie,validateDay:()=>Ue,validateMonth:()=>Pe,validateYear:()=>Re});module.exports=B(Ke);var Y=(t,e)=>{if(e==="ar"){let r=["","\u0627\u0644\u0623\u0648\u0644","\u0627\u0644\u062B\u0627\u0646\u064A","\u0627\u0644\u062B\u0627\u0644\u062B","\u0627\u0644\u0631\u0627\u0628\u0639","\u0627\u0644\u062E\u0627\u0645\u0633","\u0627\u0644\u0633\u0627\u062F\u0633","\u0627\u0644\u0633\u0627\u0628\u0639","\u0627\u0644\u062B\u0627\u0645\u0646","\u0627\u0644\u062A\u0627\u0633\u0639"],n=["\u0627\u0644\u062D\u0627\u062F\u064A \u0639\u0634\u0631","\u0627\u0644\u062B\u0627\u0646\u064A \u0639\u0634\u0631","\u0627\u0644\u062B\u0627\u0644\u062B \u0639\u0634\u0631","\u0627\u0644\u0631\u0627\u0628\u0639 \u0639\u0634\u0631","\u0627\u0644\u062E\u0627\u0645\u0633 \u0639\u0634\u0631","\u0627\u0644\u0633\u0627\u062F\u0633 \u0639\u0634\u0631","\u0627\u0644\u0633\u0627\u0628\u0639 \u0639\u0634\u0631","\u0627\u0644\u062B\u0627\u0645\u0646 \u0639\u0634\u0631","\u0627\u0644\u062A\u0627\u0633\u0639 \u0639\u0634\u0631"],o=["","\u0627\u0644\u0639\u0627\u0634\u0631","\u0627\u0644\u0639\u0634\u0631\u0648\u0646","\u0627\u0644\u062B\u0644\u0627\u062B\u0648\u0646","\u0627\u0644\u0623\u0631\u0628\u0639\u0648\u0646","\u0627\u0644\u062E\u0645\u0633\u0648\u0646","\u0627\u0644\u0633\u062A\u0648\u0646","\u0627\u0644\u0633\u0628\u0639\u0648\u0646","\u0627\u0644\u062B\u0645\u0627\u0646\u0648\u0646","\u0627\u0644\u062A\u0633\u0639\u0648\u0646"],s=["","\u0627\u0644\u0645\u0627\u0626\u0629","\u0627\u0644\u0645\u0626\u062A\u0627\u0646","\u0627\u0644\u062B\u0644\u0627\u062B\u0645\u0627\u0626\u0629","\u0627\u0644\u0623\u0631\u0628\u0639\u0645\u0627\u0626\u0629","\u0627\u0644\u062E\u0645\u0633\u0645\u0627\u0626\u0629","\u0627\u0644\u0633\u062A\u0645\u0627\u0626\u0629","\u0627\u0644\u0633\u0628\u0639\u0645\u0627\u0626\u0629","\u0627\u0644\u062B\u0645\u0627\u0646\u0645\u0627\u0626\u0629","\u0627\u0644\u062A\u0633\u0639\u0645\u0627\u0626\u0629"];if(t===1)return"\u0627\u0644\u0623\u0648\u0644";if(t>=2&&t<=9)return r[t];if(t>=11&&t<=19)return n[t-11];if(t%10===0&&t<100)return o[t/10];let a=t%10,u=Math.floor(t/10)*10;if(u===10)return`\u0627\u0644${r[a]} \u0639\u0634\u0631`;if(a===1)return`\u0627\u0644\u062D\u0627\u062F\u064A ${o[u/10]}`;if(a===2)return`\u0627\u0644\u062B\u0627\u0646\u064A ${o[u/10]}`;let i=`${r[a]} \u0648${o[u/10]}`,f=Math.floor(t/100),c=t%100;return f>0?c===0?s[f]:`${s[f]} \u0648${Y(c,e)}`:i}else{let r=["th","st","nd","rd"],n=t%100;return t+(r[(n-20)%10]||r[n]||r[0])}};var v=({items:t,setItems:e,itemData:r})=>{if(!t||!e||!r)return;let n=y({id:Number(new Date().getTime())},r);n&&e([...t,n])},z=({items:t,setItems:e,itemData:r,uniqueField:n})=>{if(!t||!e||!r)return;t.some(s=>n&&typeof r=="object"&&r!==null?s[n]===r[n]:s===r)||e([...t,r])},Q=({id:t,items:e,setItems:r,itemData:n})=>{!t||!e||!r||!n||r(e==null?void 0:e.map(o=>o.id===t?y(y({},o),n):o))},_=({id:t,items:e,setItems:r})=>{!t||!e||!r||r(e==null?void 0:e.filter(n=>{var o;return typeof n=="object"&&n!==null&&!Array.isArray(t)?n.id!==t:Array.isArray(t)?!t.includes((o=n.id)!=null?o:n):n!==t}))};var h=N(require("dayjs")),W=t=>{if(!t)return"";let e=new Date(t);return(0,h.default)(e).format("DD/MM/YYYY, h:mmA")},H=t=>{if(!t)return"";let e=new Date(t);return(0,h.default)(e).format("DD/MM/YYYY")},J=t=>{let e=new Date(t),r=new Date;return r.setDate(r.getDate()+1),r.setHours(0,0,0,0),e<r};function Z(t){if(!t)return"";let e=new Date(t),r=s=>s.toString().padStart(2,"0"),n=r(e.getHours()),o=r(e.getMinutes());return`${n}:${o}`}var G=(t,e=o=>o,r=new Date,n)=>{let o={age:{years:0,months:0,days:0},message:e("no_age")};if(t==null)return o;let s=t instanceof Date?t:re(t)?new Date(t):new Date(Number(t)),a=r instanceof Date?r:new Date(Number(r));if(isNaN(s.getTime())||isNaN(a.getTime())||a<s)return o;let u=a.getFullYear()-s.getFullYear(),i=a.getMonth()-s.getMonth(),f=a.getDate()-s.getDate();if(f<0){let c=new Date(a.getFullYear(),a.getMonth(),0);f+=c.getDate(),i--}return i<0&&(u--,i+=12),{age:{years:u,months:i,days:f},message:`${u} ${e("years")} - ${i} ${e("months")} - ${f} ${e("days")} / ${e(n!=null?n:"")}`}},X=t=>{if(!t)return null;let e=new Date(t),r=new Date,n=r.getFullYear()-e.getFullYear(),o=r.getMonth()-e.getMonth(),s=r.getDate()-e.getDate();return s<0&&(o--,s+=new Date(r.getFullYear(),r.getMonth(),0).getDate()),o<0&&(n--,o+=12),{years:n,months:o,days:s}},V=t=>{let e=new Date,r=e.getFullYear()-t.years,n=e.getMonth()-t.months,o=e.getDate()-t.days,s=new Date(e.getFullYear(),e.getMonth(),e.getDate());return s.setFullYear(r),s.setMonth(n),s.setDate(o),s},q=(t,e)=>{let r=new Date,n=t&&t.years?t.years-e.years:r.getFullYear()-e.years,o=t&&t.months?t.months-e.months:r.getMonth()-e.months,s=t&&t.days?t.days-e.days:r.getDate()-e.days,a=new Date(r.getFullYear(),r.getMonth(),r.getDate());return a.setFullYear(n),a.setMonth(o),a.setDate(s),a};function ee(t){let[e,r]=t.split(" "),n=parseInt(e.replace(/^0+/,""),10),[o,s,a]=r==null?void 0:r.split(":").map(i=>parseInt(i,10));return n*24*60*60*1e3+o*60*60*1e3+s*60*1e3+a*1e3}var te=t=>{let e=new Date,r;if(t.includes("/")){let[s,a,u]=t.split("/").map(Number);r=new Date(u,a-1,s)}else if(!isNaN(Date.parse(t)))r=new Date(t);else throw new Error("Unsupported date format");let n=e.getFullYear()-r.getFullYear(),o=e.getMonth()-r.getMonth();return(o<0||o===0&&e.getDate()<r.getDate())&&n--,n};function re(t){let e=new Date(t);return!isNaN(e.getTime())&&e.toISOString()===t}var ne=t=>{var n;let e=new DOMParser,r=t&&e.parseFromString(t,"text/html");return(n=r&&r.body.textContent)!=null?n:""};var oe=t=>{let{key:e,ctrlKey:r,metaKey:n}=t;e==="Backspace"||e==="Delete"||e==="ArrowLeft"||e==="ArrowRight"||e==="ArrowUp"||e==="ArrowDown"||e==="Tab"||e==="Enter"||(r||n)&&(e==="c"||e==="v"||e==="x"||e==="a")||/[\u0600-\u06FF0-9\s!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]/.test(e)||t.preventDefault()},se=t=>{let{key:e,ctrlKey:r,metaKey:n}=t;e==="Backspace"||e==="Delete"||e==="ArrowLeft"||e==="ArrowRight"||e==="ArrowUp"||e==="ArrowDown"||e==="Tab"||e==="Enter"||(r||n)&&(e==="c"||e==="v"||e==="x"||e==="a")||/[A-Za-z0-9\s!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]/.test(e)||t.preventDefault()},ae=t=>{let{key:e,ctrlKey:r,metaKey:n}=t;e==="Backspace"||e==="Delete"||e==="ArrowLeft"||e==="ArrowRight"||e==="ArrowUp"||e==="ArrowDown"||e==="Tab"||e==="Enter"||(r||n)&&(e==="c"||e==="v"||e==="x"||e==="a")||/[0-9]/.test(e)||t.preventDefault()},ie=t=>{let{key:e}=t;e==="Backspace"||e==="Delete"||e==="ArrowLeft"||e==="ArrowRight"||e==="ArrowUp"||e==="ArrowDown"||e==="Tab"||e==="Enter"||/[0-9]/.test(e)||t.preventDefault()},ce=t=>{let{key:e,ctrlKey:r,metaKey:n}=t,o=t.currentTarget;e==="Backspace"||e==="Delete"||e==="ArrowLeft"||e==="ArrowRight"||e==="ArrowUp"||e==="ArrowDown"||e==="Tab"||e==="Enter"||(r||n)&&(e==="c"||e==="v"||e==="x"||e==="a")||e==="."&&!o.value.includes(".")||!/[0-9]/.test(e)&&e!=="."&&t.preventDefault()};function ue(t,e,r){return e.length===0?r:r.filter(n=>e.includes(n[t]))}function fe(t=[],e,r="children",n){if(!t)return[];if(!e||(e==null?void 0:e.length)===0)return t;let o=a=>(n?n.map(i=>a[i]).filter(Boolean):Object.values(a)).some(i=>typeof i=="string"&&e.some(f=>i.includes(f))),s=a=>{let u=[];return a.forEach(i=>{o(i)&&u.push(i),i[r]&&(u=u.concat(s(i[r])))}),u};return s(t)}var l=require("lodash");var le=t=>t.charAt(0).toUpperCase()+t.slice(1);function D(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>(e==null?void 0:e.length)!==0&&e!==null&&e!==void 0))}function ye(t){return t.map(n=>{var o=n,{_id:e}=o,r=$(o,["_id"]);return r})}function ge(t,e){return t.filter(r=>!(r!=null&&r._id)||!e.includes(r==null?void 0:r._id))}function pe(t,e,...r){return t.map(n=>({value:n[e],label:r.map(o=>n[o]).join(" ")}))}function de(t,e){var o,s,a,u,i,f,c,b,w,A,O,T;let r=`${(i=(u=(a=(s=(o=t==null?void 0:t.label)==null?void 0:o.props)==null?void 0:s.children)==null?void 0:a[0])==null?void 0:u.props)==null?void 0:i.children}`,n=(A=(w=(b=(c=(f=t==null?void 0:t.label)==null?void 0:f.props)==null?void 0:c.children)==null?void 0:b[1])==null?void 0:w.props)==null?void 0:A.children;return((O=r==null?void 0:r.toLowerCase())==null?void 0:O.includes(e==null?void 0:e.toLowerCase()))||((T=n==null?void 0:n.toLowerCase())==null?void 0:T.includes(e==null?void 0:e.toLowerCase()))}function he(t,e){let r=y({},t);for(let n of e)delete r[n];return r}function me(t){let e=[];for(let r in t)Array.isArray(t[r])&&e.push({[r]:t[r]});return e}function xe(t){return t?Object.entries(t).map(([e,r])=>({[e]:r})):[]}function De(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++){let n=Object.keys(t[r]),o=Object.keys(e[r]);if(n.length!==o.length)return!1;for(let s of n){if(!o.includes(s))return!1;let a=t[r][s],u=e[r][s];if(a.length!==u.length)return!1;for(let i of a)if(!u.includes(i))return!1}}return!0}function I(t,e=new FormData,r=""){for(let n in t){if(!t.hasOwnProperty(n))continue;let o=r?`${r}[${n}]`:n;typeof t[n]=="object"&&!(t[n]instanceof File)?I(t[n],e,o):e.append(o,t[n])}return e}function be(t,e,r=[]){let n=(0,l.omit)(t,r),o=(0,l.omit)(e,r);return(0,l.isEqual)(n,o)}function k(t,e){let r={};return Object.keys(e!=null?e:{}).forEach(n=>{let o=t[n],s=e[n];if((0,l.isDate)(s)&&(0,l.isDate)(o))(o==null?void 0:o.getTime())!==(s==null?void 0:s.getTime())&&(r[n]=s);else if((0,l.isObject)(s)&&!(0,l.isArray)(s)&&(0,l.isObject)(o)&&!(0,l.isArray)(o)){let a=k(o,s);Object.keys(a).length>0&&(r[n]=a)}else(0,l.isArray)(s)&&(0,l.isArray)(o)?(0,l.isEqual)(o,s)||(r[n]=s):(0,l.isEqual)(o,s)||(r[n]=s)}),r}function we(t){let e=Object.entries(t).sort((r,n)=>r[0].localeCompare(n[0]));return Object.fromEntries(e)}function Ae(t){let e=Object.entries(t).sort((r,n)=>typeof r[1]=="number"&&typeof n[1]=="number"?r[1]-n[1]:0);return Object.fromEntries(e)}function m(t,e){if(Array.isArray(t))return t.map(r=>m(r,e));if(typeof t=="object"&&t!==null){let r={};for(let n in t)e.includes(n)||(r[n]=m(t[n],e));return r}return t}function Oe(t,e){return t==null?t:Array.isArray(t)?t.map(r=>typeof r=="object"&&r!==null?x(r,e):r):typeof t=="object"&&t!==null?x(t,e):t}function x(t,e){let r=y({},t);for(let n of e||[])delete r[n];return r}var Te=(t,e,r="name")=>{if(!e||!t)return;let n=e==null?void 0:e.find(o=>o.id===t);return n?Array.isArray(r)?r.map(o=>n[o]).join(" "):n[r]:""},Fe=(t,e)=>{if(!e||!t)return;let r=e==null?void 0:e.find(n=>n.value===t||(n==null?void 0:n.id)===t||(n==null?void 0:n._id)===t);return r?r.label:""};function Me(t){return t?Object.entries(D(t)).filter(([,e])=>e!==void 0).map(([e,r])=>`${encodeURIComponent(e)}=${encodeURIComponent(String(r))}`).join("&"):""}function je(t){return t!=null&&t.startsWith("http")?t.split(".com/")[1].split("?")[0]:t}var $e=t=>{let e=new URLSearchParams;for(let[r,n]of Object.entries(t))if(Array.isArray(n))for(let o of n)e.append(r,o.toString());else n!==void 0&&e.append(r,n.toString());return e.toString()},Se=t=>Object.entries(t).map(([e,r])=>Array.isArray(r)?r.length===0?"":`${e}=${r.join(",")}`:r===void 0||r===""?"":`${e}=${r}`).filter(e=>e!=="").join("&"),Ye=t=>!t||t===null||t===""?[]:t.split(",").map(e=>parseInt(e)),Ie=()=>Date.now()+Math.floor(Math.random()*1e4),ke=t=>{let e=t.get("filters");if(!e)return null;try{let r=decodeURIComponent(e);return JSON.parse(r)}catch(r){return console.error("Error parsing filters from URL:",r),null}};var Ee=(t,e,r,n)=>{let o=new URLSearchParams(t);o.set(r,n),e(o)};function Le(t=[],e="",r="children",n){var u;if(!t)return[];if(!e)return t;let o=(u=e.trim())==null?void 0:u.toLowerCase(),s=i=>(n?n.map(c=>i[c]).filter(Boolean):Object.values(i)).some(c=>typeof c=="string"&&(c==null?void 0:c.toLowerCase().includes(o))),a=i=>i.map(f=>{let c=f[r]?a(f[r]):[];return s(f)||c.length>0?j(y({},f),{[r]:c.length>0?c:void 0}):null}).filter(f=>f!==null);return a(t)}function Ce(t=[],e="",r="children",n){var u;if(!t)return[];if(!e)return t;let o=(u=e==null?void 0:e.trim())==null?void 0:u.toLowerCase(),s=i=>(n?n.map(c=>i[c]).filter(Boolean):Object.values(i)).some(c=>typeof c=="string"&&(c==null?void 0:c.toLowerCase().includes(o))),a=i=>{let f=[];return i.forEach(c=>{s(c)&&f.push(c),c[r]&&(f=f.concat(a(c[r])))}),f};return a(t)}var Ue=t=>{let e=t.replace(/\D/g,"");return e?Math.min(Math.max(parseInt(e,10),1),31).toString():""},Pe=t=>{let e=t.replace(/\D/g,"");return e?Math.min(Math.max(parseInt(e,10),1),12).toString():""},Re=t=>{let e=t.replace(/\D/g,"");return e?e.length<4?e:parseInt(e,10)<1900?"1900":e:""};0&&(module.exports={addSearchParam,ageToBirthDate,ageToBirthDateChangeSegment,arrFromQuery,birthDateToAge,calculateAge,calculateDetailedAge,capitalizeString,compareObjects,comparePermissionLists,convertObjectToArray,convertTimeToTimestamp,createOptionsArray,createSearchQuery,filterInArray,filterInObjects,filterUsersOption,formatDate,formatDateTime,getArrayKeys,getChangedFields,getLabelByItemsAndId,getLabelByItemsAndOptions,getTextOnlyFromHtml,getTime,handleCreateFront,handleCreateFrontUnique,handleDeleteFront,handleKeyDownArabic,handleKeyDownEnglish,handleKeyDownFloatNumber,handleKeyDownNumber,handleKeyDownNumberNoCopy,handleUpdateFront,isNotFutureDate,literalOrdinals,objectToFormData,prePareFilters,pureURLS3,removeEmptyFields,removeFields,removeFieldsFromObject,removeFieldsTopLevel,removeIdFromObjects,removeItemsWithIds,removeKeys,searchInObjects,searchInObjectsWithParents,serializeFormQuery,sortObjectByKeys,sortObjectByValues,toQueryString,uniqueId,validateDay,validateMonth,validateYear});
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../index.ts","../src/arabic.ts","../src/curdOperation.ts","../src/dateUtils.ts","../src/domUtils.ts","../src/eventHandlers.ts","../src/filter.ts","../src/objectUtils.tsx","../src/queryUtils.ts","../src/search.ts","../src/validationDate.ts"],"sourcesContent":["export * from './src/arabic';\r\nexport * from './src/curdOperation';\r\nexport * from './src/dateUtils';\r\nexport * from './src/domUtils';\r\nexport * from './src/eventHandlers';\r\nexport * from './src/filter';\r\nexport * from './src/objectUtils';\r\nexport * from './src/queryUtils';\r\nexport * from './src/search';\r\nexport * from './src/validationDate';","export const literalOrdinals = (num: number, lang: \"ar\" | \"en\"): string => {\n if (lang === \"ar\") {\n const ones = [\"\", \"الأول\", \"الثاني\", \"الثالث\", \"الرابع\", \"الخامس\", \"السادس\", \"السابع\", \"الثامن\", \"التاسع\"];\n const teens = [\"الحادي عشر\", \"الثاني عشر\", \"الثالث عشر\", \"الرابع عشر\", \"الخامس عشر\", \"السادس عشر\", \"السابع عشر\", \"الثامن عشر\", \"التاسع عشر\"];\n const tens = [\"\", \"العاشر\", \"العشرون\", \"الثلاثون\", \"الأربعون\", \"الخمسون\", \"الستون\", \"السبعون\", \"الثمانون\", \"التسعون\"];\n const hundreds = [\"\", \"المائة\", \"المئتان\", \"الثلاثمائة\", \"الأربعمائة\", \"الخمسمائة\", \"الستمائة\", \"السبعمائة\", \"الثمانمائة\", \"التسعمائة\"];\n\n if (num === 1) return \"الأول\";\n if (num >= 2 && num <= 9) return ones[num];\n if (num >= 11 && num <= 19) return teens[num - 11];\n if (num % 10 === 0 && num < 100) return tens[num / 10];\n\n const remainder = num % 10;\n const base = Math.floor(num / 10) * 10;\n\n if (base === 10) return `ال${ones[remainder]} عشر`;\n if (remainder === 1) return `الحادي ${tens[base / 10]}`;\n if (remainder === 2) return `الثاني ${tens[base / 10]}`;\n const result = `${ones[remainder]} و${tens[base / 10]}`;\n\n const hundredPart = Math.floor(num / 100);\n const remainderPart = num % 100;\n if (hundredPart > 0) {\n if (remainderPart === 0) return hundreds[hundredPart];\n return `${hundreds[hundredPart]} و${literalOrdinals(remainderPart, lang)}`;\n }\n\n return result;\n } else {\n const suffixes = [\"th\", \"st\", \"nd\", \"rd\"];\n const v = num % 100;\n return num + (suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0]);\n }\n};\n","// Create\nexport const handleCreateFront = ({ items, setItems, itemData }: { items?: any[]; setItems?: any; itemData?: any }) => {\n if (!items || !setItems || !itemData) return;\n const newItem: any = {\n // id: items.length > 0 ? Math.max(...items.map((item) => item.id)) + 1 : 1,\n id: Number(new Date().getTime()),\n ...itemData,\n };\n newItem && setItems([...items, newItem]);\n};\n// CreateUnique\nexport const handleCreateFrontUnique = ({ items, setItems, itemData, uniqueField }: { items?: any[]; setItems?: any; itemData?: any; uniqueField?: string }) => {\n if (!items || !setItems || !itemData) return;\n\n // Check if the item already exists in the array\n const itemExists = items.some((item) => {\n // If uniqueField is provided and itemData is an object\n if (uniqueField && typeof itemData === \"object\" && itemData !== null) {\n return item[uniqueField] === itemData[uniqueField];\n }\n // For primitive types (string, number, boolean, etc.)\n return item === itemData;\n });\n\n // Only add the item if it doesn't already exist\n if (!itemExists) {\n // const newItem = {\n // id: Number(new Date().getTime()),\n // ...(typeof itemData === \"object\" && itemData !== null ? itemData : { value: itemData }),\n // };\n setItems([...items, itemData]);\n }\n};\n\n// Update\nexport const handleUpdateFront = ({ id, items, setItems, itemData }: { id?: number | string; items?: any[]; setItems?: any; itemData?: any }) => {\n if (!id || !items || !setItems || !itemData) return;\n setItems(items?.map((item) => (item.id === id ? { ...item, ...itemData } : item)));\n};\n\n// Delete\nexport const handleDeleteFront = ({ id, items, setItems }: { id?: number | string | null | (number | string | null)[]; items?: any[]; setItems?: any }) => {\n if (!id || !items || !setItems) return;\n setItems(\n items?.filter((item: any) => {\n if (typeof item === \"object\" && item !== null && !Array.isArray(id)) {\n return item.id !== id;\n } else if (Array.isArray(id)) {\n return !id.includes(item.id ?? item);\n } else {\n return item !== id;\n }\n }),\n );\n};\n","import dayjs from \"dayjs\";\n\nexport const formatDateTime = (date: string | Date | null | undefined) => {\n if (!date) return \"\";\n const newDate = new Date(date);\n //old: \"YYYY-MM-DD\"\n\n return dayjs(newDate).format(\"DD/MM/YYYY, h:mmA\");\n};\n\nexport const formatDate = (date: string | Date | null | undefined) => {\n if (!date) return \"\";\n // return date only\n const newDate = new Date(date);\n //old: \"YYYY-MM-DD\"\n return dayjs(newDate).format(\"DD/MM/YYYY\");\n};\n\nexport const isNotFutureDate = (date: string) => {\n const val = new Date(date);\n // Check if the date is not in the future based on day\n\n const now = new Date();\n now.setDate(now.getDate() + 1);\n now.setHours(0, 0, 0, 0);\n return val < now;\n};\n\nexport function getTime(inputDate: string | Date | null | undefined): string {\n if (!inputDate) return \"\";\n const date = new Date(inputDate);\n const pad = (num: number) => num.toString().padStart(2, \"0\");\n const formattedHours = pad(date.getHours());\n const formattedMinutes = pad(date.getMinutes());\n return `${formattedHours}:${formattedMinutes}`;\n}\n\ninterface Age {\n years: number;\n months: number;\n days: number;\n}\n\nexport const calculateDetailedAge = (birthDate?: Date | string | null, t = (key: string) => key, currentDate: Date | string = new Date(), gender?: string): { age: Age; message: string } => {\n const zeroAge = {\n age: {\n years: 0,\n months: 0,\n days: 0,\n },\n message: t(\"no_age\"),\n };\n if (birthDate === null || birthDate === undefined) {\n return zeroAge;\n }\n // Convert to Date objects if strings are passed\n const birth: Date = birthDate instanceof Date ? birthDate : isValidISODate(birthDate) ? new Date(birthDate) : new Date(Number(birthDate));\n\n const current: Date = currentDate instanceof Date ? currentDate : new Date(Number(currentDate));\n // Validate input dates\n if (isNaN(birth.getTime()) || isNaN(current.getTime())) {\n // throw new Error(\"Invalid date input\");\n return zeroAge;\n }\n\n // Ensure current date is not before birth date\n if (current < birth) {\n // throw new Error(\"Current date cannot be before birth date\");\n return zeroAge;\n }\n\n // Calculate years, months, and days\n let years = current.getFullYear() - birth.getFullYear();\n let months = current.getMonth() - birth.getMonth();\n let days = current.getDate() - birth.getDate();\n\n // Adjust calculations if needed\n if (days < 0) {\n // Borrow days from previous month\n const lastMonth = new Date(current.getFullYear(), current.getMonth(), 0);\n days += lastMonth.getDate();\n months--;\n }\n\n if (months < 0) {\n years--;\n months += 12;\n }\n\n return {\n age: {\n years,\n months,\n days,\n },\n message: `${years} ${t(\"years\")} - ${months} ${t(\"months\")} - ${days} ${t(\"days\")} / ${t(gender ?? \"\")}`,\n };\n};\n\nexport const birthDateToAge = (birthDate?: Date | string | null) => {\n if (!birthDate) return null;\n const birth = new Date(birthDate);\n const today = new Date();\n\n let years = today.getFullYear() - birth.getFullYear();\n let months = today.getMonth() - birth.getMonth();\n let days = today.getDate() - birth.getDate();\n\n if (days < 0) {\n months--;\n days += new Date(today.getFullYear(), today.getMonth(), 0).getDate();\n }\n if (months < 0) {\n years--;\n months += 12;\n }\n\n return { years, months, days };\n};\n\nexport const ageToBirthDate = (age: { years: number; months: number; days: number }) => {\n const today = new Date();\n const birthYear = today.getFullYear() - age.years;\n const birthMonth = today.getMonth() - age.months;\n const birthDay = today.getDate() - age.days;\n\n let birthDate = new Date(today.getFullYear(), today.getMonth(), today.getDate());\n birthDate.setFullYear(birthYear);\n birthDate.setMonth(birthMonth);\n birthDate.setDate(birthDay);\n\n return birthDate;\n};\n\nexport const ageToBirthDateChangeSegment = (oldAge: { years: number; months: number; days: number } | null, age: { years: number; months: number; days: number }) => {\n const today = new Date();\n const birthYear = oldAge && oldAge.years ? oldAge.years - age.years : today.getFullYear() - age.years;\n const birthMonth = oldAge && oldAge.months ? oldAge.months - age.months : today.getMonth() - age.months;\n const birthDay = oldAge && oldAge.days ? oldAge.days - age.days : today.getDate() - age.days;\n\n let birthDate = new Date(today.getFullYear(), today.getMonth(), today.getDate());\n birthDate.setFullYear(birthYear);\n birthDate.setMonth(birthMonth);\n birthDate.setDate(birthDay);\n\n return birthDate;\n};\n\nexport function convertTimeToTimestamp(timeString: string): number {\n // Split the input string into days and time components\n const [daysPart, timePart] = timeString.split(\" \");\n\n // Extract days (remove leading zeros)\n const days = parseInt(daysPart.replace(/^0+/, \"\"), 10);\n\n // Split time into hours, minutes, seconds\n const [hours, minutes, seconds] = timePart?.split(\":\").map((part) => parseInt(part, 10));\n\n // Calculate total milliseconds\n // 1 day = 24 * 60 * 60 * 1000 milliseconds\n const totalMilliseconds =\n days * 24 * 60 * 60 * 1000 + // days to milliseconds\n hours * 60 * 60 * 1000 + // hours to milliseconds\n minutes * 60 * 1000 + // minutes to milliseconds\n seconds * 1000; // seconds to milliseconds\n\n return totalMilliseconds;\n}\n\n// Calculate age function (accept iso format)\nexport const calculateAge = (birthDate: string): number => {\n const today = new Date();\n let birth: Date;\n\n if (birthDate.includes(\"/\")) {\n // DD/MM/YYYY\n const [day, month, year] = birthDate.split(\"/\").map(Number);\n birth = new Date(year, month - 1, day);\n } else if (!isNaN(Date.parse(birthDate))) {\n // ISO or any valid date string\n birth = new Date(birthDate);\n } else {\n throw new Error(\"Unsupported date format\");\n }\n\n let age = today.getFullYear() - birth.getFullYear();\n const m = today.getMonth() - birth.getMonth();\n\n if (m < 0 || (m === 0 && today.getDate() < birth.getDate())) {\n age--;\n }\n\n return age;\n};\n\nfunction isValidISODate(dateString: string): boolean {\n const date = new Date(dateString);\n // Check if the date is valid (not \"Invalid Date\") and if its ISO string representation matches the original.\n // The second check helps to ensure the string was correctly parsed as an ISO date and not some other format.\n return !isNaN(date.getTime()) && date.toISOString() === dateString;\n}\n","export const getTextOnlyFromHtml = (html?: string): string => {\n const parser = new DOMParser();\n const doc = html && parser.parseFromString(html, \"text/html\");\n return (doc && doc.body.textContent) ?? \"\";\n};\n","export const handleKeyDownArabic = (event: any) => {\n const { key, ctrlKey, metaKey } = event;\n // Allow control keys like backspace, delete, arrow keys, etc.\n if (\n key === \"Backspace\" ||\n key === \"Delete\" ||\n key === \"ArrowLeft\" ||\n key === \"ArrowRight\" ||\n key === \"ArrowUp\" ||\n key === \"ArrowDown\" ||\n key === \"Tab\" ||\n key === \"Enter\"\n ) {\n return; // Allow these keys without further checking\n }\n // Allow copy, paste, cut, select all (Ctrl/Command + C, V, X, A)\n if (\n (ctrlKey || metaKey) &&\n (key === \"c\" || key === \"v\" || key === \"x\" || key === \"a\")\n ) {\n return;\n }\n // Check if the key matches Arabic characters, numbers, symbols, or whitespace\n if (!/[\\u0600-\\u06FF0-9\\s!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~]/.test(key)) {\n event.preventDefault();\n }\n};\n\nexport const handleKeyDownEnglish = (event: any) => {\n const { key, ctrlKey, metaKey } = event;\n // Allow control keys like backspace, delete, arrow keys, etc.\n if (\n key === \"Backspace\" ||\n key === \"Delete\" ||\n key === \"ArrowLeft\" ||\n key === \"ArrowRight\" ||\n key === \"ArrowUp\" ||\n key === \"ArrowDown\" ||\n key === \"Tab\" ||\n key === \"Enter\"\n ) {\n return; // Allow these keys without further checking\n }\n // Allow copy, paste, cut, select all (Ctrl/Command + C, V, X, A)\n if (\n (ctrlKey || metaKey) &&\n (key === \"c\" || key === \"v\" || key === \"x\" || key === \"a\")\n ) {\n return;\n }\n\n // Check if the key matches English letters, numbers, or symbols\n if (!/[A-Za-z0-9\\s!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~]/.test(key)) {\n event.preventDefault();\n }\n};\n\nexport const handleKeyDownNumber = (event: any) => {\n const { key, ctrlKey, metaKey } = event;\n\n // Allow keys for navigation, deletion, tab, and enter\n if (\n key === \"Backspace\" ||\n key === \"Delete\" ||\n key === \"ArrowLeft\" ||\n key === \"ArrowRight\" ||\n key === \"ArrowUp\" ||\n key === \"ArrowDown\" ||\n key === \"Tab\" ||\n key === \"Enter\"\n ) {\n return;\n }\n\n // Allow copy, paste, cut, select all (Ctrl/Command + C, V, X, A)\n if (\n (ctrlKey || metaKey) &&\n (key === \"c\" || key === \"v\" || key === \"x\" || key === \"a\")\n ) {\n return;\n }\n\n // Prevent non-numeric input\n if (!/[0-9]/.test(key)) {\n event.preventDefault();\n }\n};\n\nexport const handleKeyDownNumberNoCopy = (event: any) => {\n const { key } = event;\n\n // Allow keys for navigation, deletion, tab, and enter\n if (\n key === \"Backspace\" ||\n key === \"Delete\" ||\n key === \"ArrowLeft\" ||\n key === \"ArrowRight\" ||\n key === \"ArrowUp\" ||\n key === \"ArrowDown\" ||\n key === \"Tab\" ||\n key === \"Enter\"\n ) {\n return;\n }\n // Prevent non-numeric input\n if (!/[0-9]/.test(key)) {\n event.preventDefault();\n }\n};\n\nexport const handleKeyDownFloatNumber = (event: any) => {\n const { key, ctrlKey, metaKey } = event;\n const input = event.currentTarget;\n\n // Allow keys for navigation, deletion, tab, and enter\n if (\n key === \"Backspace\" ||\n key === \"Delete\" ||\n key === \"ArrowLeft\" ||\n key === \"ArrowRight\" ||\n key === \"ArrowUp\" ||\n key === \"ArrowDown\" ||\n key === \"Tab\" ||\n key === \"Enter\"\n ) {\n return;\n }\n\n // Allow copy, paste, cut, select all (Ctrl/Command + C, V, X, A)\n if (\n (ctrlKey || metaKey) &&\n (key === \"c\" || key === \"v\" || key === \"x\" || key === \"a\")\n ) {\n return;\n }\n\n // Allow one decimal point if it doesn't already exist\n if (key === \".\" && !input.value.includes(\".\")) {\n return;\n }\n\n // Prevent non-numeric input (allow numbers and one decimal point)\n if (!/[0-9]/.test(key) && key !== \".\") {\n event.preventDefault();\n }\n};\n","export function filterInArray<T>(field: keyof T, values: T[keyof T][], data: T[]): T[] {\n if (values.length === 0) return data;\n return data.filter((item) => values.includes(item[field]));\n}\n\nexport function filterInObjects(\n data: any[] = [],\n query: string[],\n childrenField: string = \"children\",\n fieldsToFilter?: string[], // Optional array of fields to filter on\n): any[] {\n if (!data) return [];\n if (!query || query?.length === 0) return data;\n\n // Helper function to check if the specified field or all fields match the query.\n const matchesQuery = (obj: any): boolean => {\n const valuesToFilter = fieldsToFilter\n ? fieldsToFilter.map((field) => obj[field]).filter(Boolean) // Only valid fields\n : Object.values(obj); // Default to all fields\n\n return valuesToFilter.some((value) => typeof value === \"string\" && query.some((q) => value.includes(q)));\n };\n\n // Recursive function to filter objects and extract matching ones.\n const filter = (data: any[]): any[] => {\n let results: any[] = [];\n\n data.forEach((item) => {\n // If the current item matches, add it to the results.\n if (matchesQuery(item)) {\n results.push(item);\n }\n\n // Recursively filter the children and add their matches.\n if (item[childrenField]) {\n results = results.concat(filter(item[childrenField]));\n }\n });\n\n return results;\n };\n\n return filter(data);\n}\n","import { isArray, isDate, isEqual, isObject, omit } from \"lodash\";\n\nexport const capitalizeString = (str: string) => {\n return str.charAt(0).toUpperCase() + str.slice(1);\n};\n\nexport function removeEmptyFields<T extends Record<string, any>>(obj: T): Partial<T> {\n return Object.fromEntries(Object.entries(obj).filter(([, value]) => value?.length !== 0 && value !== null && value !== undefined)) as Partial<T>;\n}\n\ntype WithId = {\n _id?: string;\n\n [key: string]: any;\n};\n\nexport function removeIdFromObjects<T extends WithId>(objects: T[]): Omit<T, \"_id\">[] {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n return objects.map(({ _id, ...rest }) => rest);\n}\n\nexport function removeItemsWithIds(array: any[], idsToRemove: string[]): any[] {\n return array.filter((item) => !item?._id || !idsToRemove.includes(item?._id));\n}\n\nexport function createOptionsArray<T>(data: T[], valueField: keyof T, ...labelFields: (keyof T)[]) {\n return data.map((item) => ({\n value: item[valueField] as string | number,\n label: labelFields.map((field) => item[field]).join(\" \"),\n }));\n}\n\nexport function filterUsersOption(option: any, inputValue: string) {\n const fullNameLabel = `${option?.label?.props?.children?.[0]?.props?.children}`;\n const emailLabel = option?.label?.props?.children?.[1]?.props?.children;\n\n return fullNameLabel?.toLowerCase()?.includes(inputValue?.toLowerCase()) || emailLabel?.toLowerCase()?.includes(inputValue?.toLowerCase());\n}\n\nexport function removeKeys(obj: any, keys: string[]): any {\n const clonedObj = { ...obj };\n\n for (const key of keys) {\n delete clonedObj[key];\n }\n\n return clonedObj;\n}\n\nexport function getArrayKeys(obj: any) {\n const result = [];\n for (const key in obj) {\n if (Array.isArray(obj[key])) {\n result.push({ [key]: obj[key] });\n }\n }\n return result;\n}\n\nexport function convertObjectToArray(obj: any): any[] {\n if (!obj) return [];\n return Object.entries(obj).map(([key, value]) => ({\n [key]: value,\n }));\n}\n\ntype Permission = {\n [key: string]: string[];\n};\n\nexport function comparePermissionLists(list1: Permission[], list2: Permission[]): boolean {\n if (list1.length !== list2.length) {\n return false;\n }\n\n for (let i = 0; i < list1.length; i++) {\n const keys1 = Object.keys(list1[i]);\n const keys2 = Object.keys(list2[i]);\n\n if (keys1.length !== keys2.length) {\n return false;\n }\n\n for (const key of keys1) {\n if (!keys2.includes(key)) {\n return false;\n }\n\n const values1 = list1[i][key];\n const values2 = list2[i][key];\n\n if (values1.length !== values2.length) {\n return false;\n }\n\n for (const value of values1) {\n if (!values2.includes(value)) {\n return false;\n }\n }\n }\n }\n\n return true;\n}\n\nexport function objectToFormData(obj: Record<string, any>, formData: FormData = new FormData(), namespace: string = \"\"): FormData {\n for (let key in obj) {\n if (!obj.hasOwnProperty(key)) continue;\n\n const formKey = namespace ? `${namespace}[${key}]` : key;\n\n if (typeof obj[key] === \"object\" && !(obj[key] instanceof File)) {\n // If it's an array or object, call the function recursively\n objectToFormData(obj[key], formData, formKey);\n } else {\n // Otherwise append the value\n formData.append(formKey, obj[key]);\n }\n }\n\n return formData;\n}\n\n/**\n * Compares two objects and returns true if they are equivalent.\n * Ignores specified keys if provided.\n *\n * @param {any} original - The original object.\n * @param {any} updated - The updated object to compare with.\n * @param {string[]} [keysToIgnore=[]] - Optional keys to ignore during comparison.\n * @returns {boolean} - True if objects are equivalent, otherwise false.\n */\nexport function compareObjects(original: any, updated: any, keysToIgnore: string[] = []): boolean {\n const normalizedOriginal = omit(original, keysToIgnore);\n const normalizedUpdated = omit(updated, keysToIgnore);\n\n return isEqual(normalizedOriginal, normalizedUpdated);\n}\n\nexport function getChangedFields(original: any, updated: any): any {\n const changedFields: any = {};\n\n Object.keys(updated ?? {}).forEach((key) => {\n const originalValue = original[key];\n const updatedValue = updated[key];\n\n if (isDate(updatedValue) && isDate(originalValue)) {\n // Handle Date objects\n if (originalValue?.getTime() !== updatedValue?.getTime()) {\n changedFields[key] = updatedValue;\n }\n } else if (isObject(updatedValue) && !isArray(updatedValue) && isObject(originalValue) && !isArray(originalValue)) {\n // Handle nested objects\n const nestedChanges = getChangedFields(originalValue, updatedValue);\n if (Object.keys(nestedChanges).length > 0) {\n changedFields[key] = nestedChanges;\n }\n } else if (isArray(updatedValue) && isArray(originalValue)) {\n // Handle arrays\n if (!isEqual(originalValue, updatedValue)) {\n changedFields[key] = updatedValue;\n }\n } else if (!isEqual(originalValue, updatedValue)) {\n // Handle primitive types (string, number, boolean, etc.)\n changedFields[key] = updatedValue;\n }\n });\n\n return changedFields;\n}\n\nexport function sortObjectByKeys<T extends Record<string, any>>(obj: T): T {\n const sortedEntries = Object.entries(obj).sort((a, b) => {\n return a[0].localeCompare(b[0]);\n });\n\n return Object.fromEntries(sortedEntries) as T;\n}\n\nexport function sortObjectByValues<T extends Record<string, any>>(obj: T): T {\n const sortedEntries = Object.entries(obj).sort((a, b) => {\n if (typeof a[1] === \"number\" && typeof b[1] === \"number\") {\n return a[1] - b[1];\n }\n return 0;\n });\n\n return Object.fromEntries(sortedEntries) as T;\n}\n\n// Example usage\n// const data = {\n// name: { ar: \"اختبار333333333\", \"en-US\": \"test333333333\" },\n// description: { ar: \"اختبار33333\", \"en-US\": \"test33333\" },\n// location: { lat: 12345, lng: 12345 },\n// status: { ar: \"test\", \"en-US\": \"test\" },\n// features: [\"66a92a500075488d302b2184\", \"66a92aab0075488d302b2190\"],\n// price: 5000,\n// // attachments: [ videoFile, pictureFile]\n// };\n\n// const formData = objectToFormData(data);\n\n// // Log the FormData keys and values for verification\n// for (let pair of formData.entries()) {\n//\n// }\n\n// const methodsOrder = [\"POST\", \"GET\", \"PATCH\", \"DELETE\", \"DATA\"];\n\n// export const toggleAndSortMethod = (method: string, methodArray: string[]) => {\n// const index = methodArray.indexOf(method);\n// if (index === -1) {\n// // Method not found, add it\n// methodArray.push(method);\n// } else {\n// // Method found, remove it\n// methodArray.splice(index, 1);\n// }\n// // Sort the array based on the defined order\n// methodArray.sort((a, b) => methodsOrder.indexOf(a) - methodsOrder.indexOf(b));\n// return methodArray;\n// };\n\ntype AnyObject = { [key: string]: any };\n\nexport function removeFields(obj: AnyObject, fieldsToRemove: string[]): AnyObject {\n if (Array.isArray(obj)) {\n // Recursively process each item in the array\n return obj.map((item) => removeFields(item, fieldsToRemove));\n } else if (typeof obj === \"object\" && obj !== null) {\n const newObj: AnyObject = {};\n\n // Iterate over each key-value pair in the object\n for (const key in obj) {\n if (!fieldsToRemove.includes(key)) {\n // Only add the key if it's not in fieldsToRemove, and process its value recursively\n newObj[key] = removeFields(obj[key], fieldsToRemove);\n }\n }\n\n return newObj;\n }\n\n // Return primitive types (strings, numbers, etc.) as is\n return obj;\n}\n\nexport function removeFieldsTopLevel(obj: AnyObject | AnyObject[] | null | undefined, fieldsToRemove?: string[]): any {\n if (obj === null || obj === undefined) {\n return obj;\n }\n if (Array.isArray(obj)) {\n // If it's an array, process each item in the array\n return obj.map((item) => {\n if (typeof item === \"object\" && item !== null) {\n return removeFieldsFromObject(item, fieldsToRemove);\n }\n return item; // Return non-object items as is\n });\n } else if (typeof obj === \"object\" && obj !== null) {\n // If it's a single object, remove fields at the top level\n return removeFieldsFromObject(obj, fieldsToRemove);\n }\n\n // If it's neither an object nor an array, return it as is\n return obj;\n}\n\n// Helper function to remove fields from a single object at the top level\nexport function removeFieldsFromObject(obj: AnyObject, fieldsToRemove?: string[]): AnyObject {\n const newObj: AnyObject = { ...obj };\n\n // Remove specified fields from the object\n for (const field of fieldsToRemove || []) {\n delete newObj[field];\n }\n\n return newObj;\n}\n\nexport const getLabelByItemsAndId = (id?: string | number, items?: any[], fields: string[] | string = \"name\") => {\n if (!items || !id) return undefined;\n const item = items?.find((item) => item.id === id);\n if (item) {\n if (Array.isArray(fields)) {\n return fields.map((field) => item[field]).join(\" \");\n }\n return item[fields];\n }\n return \"\";\n};\n// ex\n// {getLabelByItemsAndId(row.getValue(\"name\"), items, [\n// \"firstName\",\n// \"lastName\",\n// ])}\n\nexport const getLabelByItemsAndOptions = (id?: string | number | null, items?: any[]) => {\n if (!items || !id) return undefined;\n const item = items?.find((item) => item.value === id || item?.id === id || item?._id === id);\n if (item) {\n return item.label;\n }\n return \"\";\n};\n// ex {getLabelByItemsAndOptions(row.getValue(\"name\"), usersOptions)}\n","import { removeEmptyFields } from \"./objectUtils\";\n\nexport function toQueryString(params?: any): string {\n if (params)\n return Object.entries(removeEmptyFields(params))\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`)\n .join(\"&\");\n return \"\";\n}\n\nexport function pureURLS3(url: string | undefined): string | undefined {\n if (url?.startsWith(\"http\")) {\n return url.split(\".com/\")[1].split(\"?\")[0];\n }\n return url;\n}\n\nexport const createSearchQuery = (params: Record<string, string | number | boolean | undefined | string[] | number[]>) => {\n const query = new URLSearchParams();\n for (const [key, value] of Object.entries(params)) {\n if (Array.isArray(value)) {\n for (const v of value) {\n query.append(key, v.toString());\n }\n } else if (value !== undefined) {\n query.append(key, value.toString());\n }\n }\n\n return query.toString();\n};\n\nexport const serializeFormQuery = (params: Record<string, string | number | boolean | undefined | string[] | number[]>) => {\n return Object.entries(params)\n .map(([key, value]) => {\n if (Array.isArray(value)) {\n if (value.length === 0) return \"\";\n return `${key}=${value.join(\",\")}`;\n }\n if (value === undefined || value === \"\") return \"\";\n return `${key}=${value}`;\n })\n .filter((val) => val !== \"\")\n .join(\"&\");\n};\n\nexport const arrFromQuery = (query: string | null) => (!query || query === null || query === \"\" ? [] : query.split(\",\").map((val) => parseInt(val)));\n\nexport const uniqueId = (): number => {\n return Date.now() + Math.floor(Math.random() * 10000);\n};\n\nexport const prePareFilters = (searchParams: URLSearchParams) => {\n const filtersParam = searchParams.get(\"filters\");\n if (!filtersParam) return null;\n\n try {\n const decoded = decodeURIComponent(filtersParam);\n const filtersArray = JSON.parse(decoded);\n\n // Convert filter format to backend format if needed\n // The filters come in format: { column, logic, value, fields, operatorGroup }\n // We need to send them as-is to trigger refetch\n return filtersArray;\n } catch (error) {\n console.error(\"Error parsing filters from URL:\", error);\n return null;\n }\n};\n","\nexport const addSearchParam = (searchParams: URLSearchParams, setSearchParams: any, key: string, value: string) => {\n const newSearchParams = new URLSearchParams(searchParams);\n newSearchParams.set(key, value);\n setSearchParams(newSearchParams);\n};\n\n/**\n * Recursively searches across all fields of objects and their [`${childrenField}`].\n * @param data - The array of objects to search.\n * @param query - The search query string.\n * @returns An array of objects that match the search query.\n */\nexport function searchInObjectsWithParents(\n data: any[] = [],\n query: string = \"\",\n childrenField: string = \"children\",\n fieldsToSearch?: string[], // Optional: Array of specific fields to search\n): any[] {\n if (!data) return [];\n if (!query) return data;\n\n const lowerQuery = query.trim()?.toLowerCase();\n\n // Helper function to check if the object matches the query within the specified fields.\n const matchesQuery = (obj: any): boolean => {\n const valuesToSearch = fieldsToSearch\n ? fieldsToSearch.map((field) => obj[field]).filter(Boolean) // Filter out invalid fields\n : Object.values(obj); // Default to all values\n\n return valuesToSearch.some((value) => typeof value === \"string\" && value?.toLowerCase().includes(lowerQuery));\n };\n\n // Recursive function to search objects and retain matching parents and children.\n const search = (data: any[]): any[] => {\n return data\n .map((item) => {\n const childResults = item[childrenField] ? search(item[childrenField]) : [];\n\n // If the item matches the query or any child matches, include it in the results.\n if (matchesQuery(item) || childResults.length > 0) {\n return {\n ...item,\n [childrenField]: childResults.length > 0 ? childResults : undefined, // Keep only matching children.\n };\n }\n return null; // Exclude non-matching items.\n })\n .filter((item) => item !== null); // Remove null values from the result.\n };\n\n return search(data);\n}\n\nexport function searchInObjects(\n data: any[] = [],\n query: string = \"\",\n childrenField: string = \"children\",\n fieldsToSearch?: string[], // Optional array of fields to search on\n): any[] {\n if (!data) return [];\n if (!query) return data;\n const lowerQuery = query?.trim()?.toLowerCase();\n\n // Helper function to check if the specified field or all fields match the query.\n const matchesQuery = (obj: any): boolean => {\n const valuesToSearch = fieldsToSearch\n ? fieldsToSearch.map((field) => obj[field]).filter(Boolean) // Only valid fields\n : Object.values(obj); // Default to all fields\n\n return valuesToSearch.some((value) => typeof value === \"string\" && value?.toLowerCase().includes(lowerQuery));\n };\n\n // Recursive function to search objects and extract matching ones.\n const search = (data: any[]): any[] => {\n let results: any[] = [];\n\n data.forEach((item) => {\n // If the current item matches, add it to the results.\n if (matchesQuery(item)) {\n results.push(item);\n }\n\n // Recursively search the children and add their matches.\n if (item[childrenField]) {\n results = results.concat(search(item[childrenField]));\n }\n });\n\n return results;\n };\n\n return search(data);\n}\n","export const validateDay = (value: string): string => {\n let sanitizedValue = value.replace(/\\D/g, \"\"); // Remove non-numeric characters\n if (!sanitizedValue) return \"\"; // Allow empty input\n return Math.min(Math.max(parseInt(sanitizedValue, 10), 1), 31).toString(); // Ensure between 1-31\n};\n\nexport const validateMonth = (value: string): string => {\n let sanitizedValue = value.replace(/\\D/g, \"\");\n if (!sanitizedValue) return \"\";\n return Math.min(Math.max(parseInt(sanitizedValue, 10), 1), 12).toString(); // Ensure between 1-12\n};\n\nexport const validateYear = (value: string): string => {\n let sanitizedValue = value.replace(/\\D/g, \"\"); // Remove non-numeric characters\n if (!sanitizedValue) return \"\";\n\n // Allow typing until 4 digits are reached\n if (sanitizedValue.length < 4) return sanitizedValue;\n\n // Ensure the year is at least 1900 when it reaches 4 digits\n const year = parseInt(sanitizedValue, 10);\n return year < 1900 ? \"1900\" : sanitizedValue;\n};\n"],"mappings":"mjCAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,oBAAAE,GAAA,mBAAAC,EAAA,gCAAAC,EAAA,iBAAAC,GAAA,mBAAAC,EAAA,iBAAAC,GAAA,yBAAAC,EAAA,qBAAAC,GAAA,mBAAAC,GAAA,2BAAAC,GAAA,yBAAAC,GAAA,2BAAAC,GAAA,uBAAAC,GAAA,sBAAAC,GAAA,kBAAAC,GAAA,oBAAA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GAAU,OAAOA,GAAU,WAAYA,GAAA,YAAAA,EAAO,cAAc,SAASQ,GAAW,EAIxGI,EAAUT,GAAuB,CACrC,IAAIe,EAAiB,CAAC,EAEtB,OAAAf,EAAK,QAASU,GAAS,CAEjBJ,EAAaI,CAAI,GACnBK,EAAQ,KAAKL,CAAI,EAIfA,EAAKR,CAAa,IACpBa,EAAUA,EAAQ,OAAON,EAAOC,EAAKR,CAAa,CAAC,CAAC,EAExD,CAAC,EAEMa,CACT,EAEA,OAAON,EAAOT,CAAI,CACpB,CC7FO,IAAMgB,GAAeC,GAA0B,CACpD,IAAIC,EAAiBD,EAAM,QAAQ,MAAO,EAAE,EAC5C,OAAKC,EACE,KAAK,IAAI,KAAK,IAAI,SAASA,EAAgB,EAAE,EAAG,CAAC,EAAG,EAAE,EAAE,SAAS,EAD5C,EAE9B,EAEaC,GAAiBF,GAA0B,CACtD,IAAIC,EAAiBD,EAAM,QAAQ,MAAO,EAAE,EAC5C,OAAKC,EACE,KAAK,IAAI,KAAK,IAAI,SAASA,EAAgB,EAAE,EAAG,CAAC,EAAG,EAAE,EAAE,SAAS,EAD5C,EAE9B,EAEaE,GAAgBH,GAA0B,CACrD,IAAIC,EAAiBD,EAAM,QAAQ,MAAO,EAAE,EAC5C,OAAKC,EAGDA,EAAe,OAAS,EAAUA,EAGzB,SAASA,EAAgB,EAAE,EAC1B,KAAO,OAASA,EAPF,EAQ9B","names":["index_exports","__export","addSearchParam","ageToBirthDate","ageToBirthDateChangeSegment","arrFromQuery","birthDateToAge","calculateAge","calculateDetailedAge","capitalizeString","compareObjects","comparePermissionLists","convertObjectToArray","convertTimeToTimestamp","createOptionsArray","createSearchQuery","filterInArray","filterInObjects","filterUsersOption","formatDate","formatDateTime","getArrayKeys","getChangedFields","getLabelByItemsAndId","getLabelByItemsAndOptions","getTextOnlyFromHtml","getTime","handleCreateFront","handleCreateFrontUnique","handleDeleteFront","handleKeyDownArabic","handleKeyDownEnglish","handleKeyDownFloatNumber","handleKeyDownNumber","handleKeyDownNumberNoCopy","handleUpdateFront","isNotFutureDate","literalOrdinals","objectToFormData","prePareFilters","pureURLS3","removeEmptyFields","removeFields","removeFieldsFromObject","removeFieldsTopLevel","removeIdFromObjects","removeItemsWithIds","removeKeys","searchInObjects","searchInObjectsWithParents","serializeFormQuery","sortObjectByKeys","sortObjectByValues","toQueryString","uniqueId","validateDay","validateMonth","validateYear","__toCommonJS","literalOrdinals","num","lang","ones","teens","tens","hundreds","remainder","base","result","hundredPart","remainderPart","suffixes","v","handleCreateFront","items","setItems","itemData","newItem","__spreadValues","handleCreateFrontUnique","uniqueField","item","handleUpdateFront","id","handleDeleteFront","_a","import_dayjs","formatDateTime","date","newDate","dayjs","formatDate","isNotFutureDate","val","now","getTime","inputDate","pad","num","formattedHours","formattedMinutes","calculateDetailedAge","birthDate","t","key","currentDate","gender","zeroAge","birth","isValidISODate","current","years","months","days","lastMonth","birthDateToAge","today","ageToBirthDate","age","birthYear","birthMonth","birthDay","ageToBirthDateChangeSegment","oldAge","convertTimeToTimestamp","timeString","daysPart","timePart","hours","minutes","seconds","part","calculateAge","day","month","year","m","dateString","getTextOnlyFromHtml","html","_a","parser","doc","handleKeyDownArabic","event","key","ctrlKey","metaKey","handleKeyDownEnglish","handleKeyDownNumber","handleKeyDownNumberNoCopy","handleKeyDownFloatNumber","input","filterInArray","field","values","data","item","filterInObjects","query","childrenField","fieldsToFilter","matchesQuery","obj","value","q","filter","results","import_lodash","capitalizeString","str","removeEmptyFields","obj","value","removeIdFromObjects","objects","_a","_b","_id","rest","__objRest","removeItemsWithIds","array","idsToRemove","item","createOptionsArray","data","valueField","labelFields","field","filterUsersOption","option","inputValue","_c","_d","_e","_f","_g","_h","_i","_j","_k","_l","fullNameLabel","emailLabel","removeKeys","keys","clonedObj","__spreadValues","key","getArrayKeys","result","convertObjectToArray","comparePermissionLists","list1","list2","i","keys1","keys2","values1","values2","objectToFormData","formData","namespace","formKey","compareObjects","original","updated","keysToIgnore","normalizedOriginal","normalizedUpdated","getChangedFields","changedFields","originalValue","updatedValue","nestedChanges","sortObjectByKeys","sortedEntries","a","b","sortObjectByValues","removeFields","fieldsToRemove","newObj","removeFieldsTopLevel","removeFieldsFromObject","getLabelByItemsAndId","id","items","fields","getLabelByItemsAndOptions","toQueryString","params","removeEmptyFields","value","key","pureURLS3","url","createSearchQuery","query","v","serializeFormQuery","val","arrFromQuery","uniqueId","prePareFilters","searchParams","filtersParam","decoded","error","addSearchParam","searchParams","setSearchParams","key","value","newSearchParams","searchInObjectsWithParents","data","query","childrenField","fieldsToSearch","_a","lowerQuery","matchesQuery","obj","field","search","item","childResults","__spreadProps","__spreadValues","searchInObjects","results","validateDay","value","sanitizedValue","validateMonth","validateYear"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var k=Object.defineProperty,E=Object.defineProperties;var L=Object.getOwnPropertyDescriptors;var y=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var b=(t,e,r)=>e in t?k(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,l=(t,e)=>{for(var r in e||(e={}))w.call(e,r)&&b(t,r,e[r]);if(y)for(var r of y(e))A.call(e,r)&&b(t,r,e[r]);return t},O=(t,e)=>E(t,L(e));var T=(t,e)=>{var r={};for(var n in t)w.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&y)for(var n of y(t))e.indexOf(n)<0&&A.call(t,n)&&(r[n]=t[n]);return r};var C=(t,e)=>{if(e==="ar"){let r=["","\u0627\u0644\u0623\u0648\u0644","\u0627\u0644\u062B\u0627\u0646\u064A","\u0627\u0644\u062B\u0627\u0644\u062B","\u0627\u0644\u0631\u0627\u0628\u0639","\u0627\u0644\u062E\u0627\u0645\u0633","\u0627\u0644\u0633\u0627\u062F\u0633","\u0627\u0644\u0633\u0627\u0628\u0639","\u0627\u0644\u062B\u0627\u0645\u0646","\u0627\u0644\u062A\u0627\u0633\u0639"],n=["\u0627\u0644\u062D\u0627\u062F\u064A \u0639\u0634\u0631","\u0627\u0644\u062B\u0627\u0646\u064A \u0639\u0634\u0631","\u0627\u0644\u062B\u0627\u0644\u062B \u0639\u0634\u0631","\u0627\u0644\u0631\u0627\u0628\u0639 \u0639\u0634\u0631","\u0627\u0644\u062E\u0627\u0645\u0633 \u0639\u0634\u0631","\u0627\u0644\u0633\u0627\u062F\u0633 \u0639\u0634\u0631","\u0627\u0644\u0633\u0627\u0628\u0639 \u0639\u0634\u0631","\u0627\u0644\u062B\u0627\u0645\u0646 \u0639\u0634\u0631","\u0627\u0644\u062A\u0627\u0633\u0639 \u0639\u0634\u0631"],o=["","\u0627\u0644\u0639\u0627\u0634\u0631","\u0627\u0644\u0639\u0634\u0631\u0648\u0646","\u0627\u0644\u062B\u0644\u0627\u062B\u0648\u0646","\u0627\u0644\u0623\u0631\u0628\u0639\u0648\u0646","\u0627\u0644\u062E\u0645\u0633\u0648\u0646","\u0627\u0644\u0633\u062A\u0648\u0646","\u0627\u0644\u0633\u0628\u0639\u0648\u0646","\u0627\u0644\u062B\u0645\u0627\u0646\u0648\u0646","\u0627\u0644\u062A\u0633\u0639\u0648\u0646"],s=["","\u0627\u0644\u0645\u0627\u0626\u0629","\u0627\u0644\u0645\u0626\u062A\u0627\u0646","\u0627\u0644\u062B\u0644\u0627\u062B\u0645\u0627\u0626\u0629","\u0627\u0644\u0623\u0631\u0628\u0639\u0645\u0627\u0626\u0629","\u0627\u0644\u062E\u0645\u0633\u0645\u0627\u0626\u0629","\u0627\u0644\u0633\u062A\u0645\u0627\u0626\u0629","\u0627\u0644\u0633\u0628\u0639\u0645\u0627\u0626\u0629","\u0627\u0644\u062B\u0645\u0627\u0646\u0645\u0627\u0626\u0629","\u0627\u0644\u062A\u0633\u0639\u0645\u0627\u0626\u0629"];if(t===1)return"\u0627\u0644\u0623\u0648\u0644";if(t>=2&&t<=9)return r[t];if(t>=11&&t<=19)return n[t-11];if(t%10===0&&t<100)return o[t/10];let a=t%10,u=Math.floor(t/10)*10;if(u===10)return`\u0627\u0644${r[a]} \u0639\u0634\u0631`;if(a===1)return`\u0627\u0644\u062D\u0627\u062F\u064A ${o[u/10]}`;if(a===2)return`\u0627\u0644\u062B\u0627\u0646\u064A ${o[u/10]}`;let i=`${r[a]} \u0648${o[u/10]}`,f=Math.floor(t/100),c=t%100;return f>0?c===0?s[f]:`${s[f]} \u0648${C(c,e)}`:i}else{let r=["th","st","nd","rd"],n=t%100;return t+(r[(n-20)%10]||r[n]||r[0])}};var B=({items:t,setItems:e,itemData:r})=>{if(!t||!e||!r)return;let n=l({id:Number(new Date().getTime())},r);n&&e([...t,n])},v=({items:t,setItems:e,itemData:r,uniqueField:n})=>{if(!t||!e||!r)return;t.some(s=>n&&typeof r=="object"&&r!==null?s[n]===r[n]:s===r)||e([...t,r])},z=({id:t,items:e,setItems:r,itemData:n})=>{!t||!e||!r||!n||r(e==null?void 0:e.map(o=>o.id===t?l(l({},o),n):o))},Q=({id:t,items:e,setItems:r})=>{!t||!e||!r||r(e==null?void 0:e.filter(n=>{var o;return typeof n=="object"&&n!==null&&!Array.isArray(t)?n.id!==t:Array.isArray(t)?!t.includes((o=n.id)!=null?o:n):n!==t}))};import F from"dayjs";var J=t=>{if(!t)return"";let e=new Date(t);return F(e).format("DD/MM/YYYY, h:mmA")},Z=t=>{if(!t)return"";let e=new Date(t);return F(e).format("DD/MM/YYYY")},G=t=>{let e=new Date(t),r=new Date;return r.setDate(r.getDate()+1),r.setHours(0,0,0,0),e<r};function X(t){if(!t)return"";let e=new Date(t),r=s=>s.toString().padStart(2,"0"),n=r(e.getHours()),o=r(e.getMinutes());return`${n}:${o}`}var V=(t,e=o=>o,r=new Date,n)=>{let o={age:{years:0,months:0,days:0},message:e("no_age")};if(t==null)return o;let s=t instanceof Date?t:U(t)?new Date(t):new Date(Number(t)),a=r instanceof Date?r:new Date(Number(r));if(isNaN(s.getTime())||isNaN(a.getTime())||a<s)return o;let u=a.getFullYear()-s.getFullYear(),i=a.getMonth()-s.getMonth(),f=a.getDate()-s.getDate();if(f<0){let c=new Date(a.getFullYear(),a.getMonth(),0);f+=c.getDate(),i--}return i<0&&(u--,i+=12),{age:{years:u,months:i,days:f},message:`${u} ${e("years")} - ${i} ${e("months")} - ${f} ${e("days")} / ${e(n!=null?n:"")}`}},q=t=>{if(!t)return null;let e=new Date(t),r=new Date,n=r.getFullYear()-e.getFullYear(),o=r.getMonth()-e.getMonth(),s=r.getDate()-e.getDate();return s<0&&(o--,s+=new Date(r.getFullYear(),r.getMonth(),0).getDate()),o<0&&(n--,o+=12),{years:n,months:o,days:s}},ee=t=>{let e=new Date,r=e.getFullYear()-t.years,n=e.getMonth()-t.months,o=e.getDate()-t.days,s=new Date(e.getFullYear(),e.getMonth(),e.getDate());return s.setFullYear(r),s.setMonth(n),s.setDate(o),s},te=(t,e)=>{let r=new Date,n=t&&t.years?t.years-e.years:r.getFullYear()-e.years,o=t&&t.months?t.months-e.months:r.getMonth()-e.months,s=t&&t.days?t.days-e.days:r.getDate()-e.days,a=new Date(r.getFullYear(),r.getMonth(),r.getDate());return a.setFullYear(n),a.setMonth(o),a.setDate(s),a};function re(t){let[e,r]=t.split(" "),n=parseInt(e.replace(/^0+/,""),10),[o,s,a]=r==null?void 0:r.split(":").map(i=>parseInt(i,10));return n*24*60*60*1e3+o*60*60*1e3+s*60*1e3+a*1e3}var ne=t=>{let e=new Date,r;if(t.includes("/")){let[s,a,u]=t.split("/").map(Number);r=new Date(u,a-1,s)}else if(!isNaN(Date.parse(t)))r=new Date(t);else throw new Error("Unsupported date format");let n=e.getFullYear()-r.getFullYear(),o=e.getMonth()-r.getMonth();return(o<0||o===0&&e.getDate()<r.getDate())&&n--,n};function U(t){let e=new Date(t);return!isNaN(e.getTime())&&e.toISOString()===t}var se=t=>{var n;let e=new DOMParser,r=t&&e.parseFromString(t,"text/html");return(n=r&&r.body.textContent)!=null?n:""};var ie=t=>{let{key:e,ctrlKey:r,metaKey:n}=t;e==="Backspace"||e==="Delete"||e==="ArrowLeft"||e==="ArrowRight"||e==="ArrowUp"||e==="ArrowDown"||e==="Tab"||e==="Enter"||(r||n)&&(e==="c"||e==="v"||e==="x"||e==="a")||/[\u0600-\u06FF0-9\s!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]/.test(e)||t.preventDefault()},ce=t=>{let{key:e,ctrlKey:r,metaKey:n}=t;e==="Backspace"||e==="Delete"||e==="ArrowLeft"||e==="ArrowRight"||e==="ArrowUp"||e==="ArrowDown"||e==="Tab"||e==="Enter"||(r||n)&&(e==="c"||e==="v"||e==="x"||e==="a")||/[A-Za-z0-9\s!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]/.test(e)||t.preventDefault()},ue=t=>{let{key:e,ctrlKey:r,metaKey:n}=t;e==="Backspace"||e==="Delete"||e==="ArrowLeft"||e==="ArrowRight"||e==="ArrowUp"||e==="ArrowDown"||e==="Tab"||e==="Enter"||(r||n)&&(e==="c"||e==="v"||e==="x"||e==="a")||/[0-9]/.test(e)||t.preventDefault()},fe=t=>{let{key:e}=t;e==="Backspace"||e==="Delete"||e==="ArrowLeft"||e==="ArrowRight"||e==="ArrowUp"||e==="ArrowDown"||e==="Tab"||e==="Enter"||/[0-9]/.test(e)||t.preventDefault()},le=t=>{let{key:e,ctrlKey:r,metaKey:n}=t,o=t.currentTarget;e==="Backspace"||e==="Delete"||e==="ArrowLeft"||e==="ArrowRight"||e==="ArrowUp"||e==="ArrowDown"||e==="Tab"||e==="Enter"||(r||n)&&(e==="c"||e==="v"||e==="x"||e==="a")||e==="."&&!o.value.includes(".")||!/[0-9]/.test(e)&&e!=="."&&t.preventDefault()};function ge(t,e,r){return e.length===0?r:r.filter(n=>e.includes(n[t]))}function pe(t=[],e,r="children",n){if(!t)return[];if(!e||(e==null?void 0:e.length)===0)return t;let o=a=>(n?n.map(i=>a[i]).filter(Boolean):Object.values(a)).some(i=>typeof i=="string"&&e.some(f=>i.includes(f))),s=a=>{let u=[];return a.forEach(i=>{o(i)&&u.push(i),i[r]&&(u=u.concat(s(i[r])))}),u};return s(t)}import{isArray as g,isDate as M,isEqual as p,isObject as j,omit as $}from"lodash";var me=t=>t.charAt(0).toUpperCase()+t.slice(1);function I(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>(e==null?void 0:e.length)!==0&&e!==null&&e!==void 0))}function xe(t){return t.map(n=>{var o=n,{_id:e}=o,r=T(o,["_id"]);return r})}function De(t,e){return t.filter(r=>!(r!=null&&r._id)||!e.includes(r==null?void 0:r._id))}function be(t,e,...r){return t.map(n=>({value:n[e],label:r.map(o=>n[o]).join(" ")}))}function we(t,e){var o,s,a,u,i,f,c,d,h,m,x,D;let r=`${(i=(u=(a=(s=(o=t==null?void 0:t.label)==null?void 0:o.props)==null?void 0:s.children)==null?void 0:a[0])==null?void 0:u.props)==null?void 0:i.children}`,n=(m=(h=(d=(c=(f=t==null?void 0:t.label)==null?void 0:f.props)==null?void 0:c.children)==null?void 0:d[1])==null?void 0:h.props)==null?void 0:m.children;return((x=r==null?void 0:r.toLowerCase())==null?void 0:x.includes(e==null?void 0:e.toLowerCase()))||((D=n==null?void 0:n.toLowerCase())==null?void 0:D.includes(e==null?void 0:e.toLowerCase()))}function Ae(t,e){let r=l({},t);for(let n of e)delete r[n];return r}function Oe(t){let e=[];for(let r in t)Array.isArray(t[r])&&e.push({[r]:t[r]});return e}function Te(t){return t?Object.entries(t).map(([e,r])=>({[e]:r})):[]}function Fe(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++){let n=Object.keys(t[r]),o=Object.keys(e[r]);if(n.length!==o.length)return!1;for(let s of n){if(!o.includes(s))return!1;let a=t[r][s],u=e[r][s];if(a.length!==u.length)return!1;for(let i of a)if(!u.includes(i))return!1}}return!0}function P(t,e=new FormData,r=""){for(let n in t){if(!t.hasOwnProperty(n))continue;let o=r?`${r}[${n}]`:n;typeof t[n]=="object"&&!(t[n]instanceof File)?P(t[n],e,o):e.append(o,t[n])}return e}function Me(t,e,r=[]){let n=$(t,r),o=$(e,r);return p(n,o)}function R(t,e){let r={};return Object.keys(e!=null?e:{}).forEach(n=>{let o=t[n],s=e[n];if(M(s)&&M(o))(o==null?void 0:o.getTime())!==(s==null?void 0:s.getTime())&&(r[n]=s);else if(j(s)&&!g(s)&&j(o)&&!g(o)){let a=R(o,s);Object.keys(a).length>0&&(r[n]=a)}else g(s)&&g(o)?p(o,s)||(r[n]=s):p(o,s)||(r[n]=s)}),r}function je(t){let e=Object.entries(t).sort((r,n)=>r[0].localeCompare(n[0]));return Object.fromEntries(e)}function $e(t){let e=Object.entries(t).sort((r,n)=>typeof r[1]=="number"&&typeof n[1]=="number"?r[1]-n[1]:0);return Object.fromEntries(e)}function S(t,e){if(Array.isArray(t))return t.map(r=>S(r,e));if(typeof t=="object"&&t!==null){let r={};for(let n in t)e.includes(n)||(r[n]=S(t[n],e));return r}return t}function Se(t,e){return t==null?t:Array.isArray(t)?t.map(r=>typeof r=="object"&&r!==null?Y(r,e):r):typeof t=="object"&&t!==null?Y(t,e):t}function Y(t,e){let r=l({},t);for(let n of e||[])delete r[n];return r}var Ye=(t,e,r="name")=>{if(!e||!t)return;let n=e==null?void 0:e.find(o=>o.id===t);return n?Array.isArray(r)?r.map(o=>n[o]).join(" "):n[r]:""},Ie=(t,e)=>{if(!e||!t)return;let r=e==null?void 0:e.find(n=>n.value===t||(n==null?void 0:n.id)===t||(n==null?void 0:n._id)===t);return r?r.label:""};function Ce(t){return t?Object.entries(I(t)).filter(([,e])=>e!==void 0).map(([e,r])=>`${encodeURIComponent(e)}=${encodeURIComponent(String(r))}`).join("&"):""}function Ue(t){return t!=null&&t.startsWith("http")?t.split(".com/")[1].split("?")[0]:t}var Pe=t=>{let e=new URLSearchParams;for(let[r,n]of Object.entries(t))if(Array.isArray(n))for(let o of n)e.append(r,o.toString());else n!==void 0&&e.append(r,n.toString());return e.toString()},Re=t=>Object.entries(t).map(([e,r])=>Array.isArray(r)?r.length===0?"":`${e}=${r.join(",")}`:r===void 0||r===""?"":`${e}=${r}`).filter(e=>e!=="").join("&"),Ke=t=>!t||t===null||t===""?[]:t.split(",").map(e=>parseInt(e)),Ne=()=>Date.now()+Math.floor(Math.random()*1e4),Be=t=>{let e=t.get("filters");if(!e)return null;try{let r=decodeURIComponent(e);return JSON.parse(r)}catch(r){return console.error("Error parsing filters from URL:",r),null}};var ze=(t,e,r,n)=>{let o=new URLSearchParams(t);o.set(r,n),e(o)};function Qe(t=[],e="",r="children",n){var u;if(!t)return[];if(!e)return t;let o=(u=e.trim())==null?void 0:u.toLowerCase(),s=i=>(n?n.map(c=>i[c]).filter(Boolean):Object.values(i)).some(c=>typeof c=="string"&&(c==null?void 0:c.toLowerCase().includes(o))),a=i=>i.map(f=>{let c=f[r]?a(f[r]):[];return s(f)||c.length>0?O(l({},f),{[r]:c.length>0?c:void 0}):null}).filter(f=>f!==null);return a(t)}function _e(t=[],e="",r="children",n){var u;if(!t)return[];if(!e)return t;let o=(u=e==null?void 0:e.trim())==null?void 0:u.toLowerCase(),s=i=>(n?n.map(c=>i[c]).filter(Boolean):Object.values(i)).some(c=>typeof c=="string"&&(c==null?void 0:c.toLowerCase().includes(o))),a=i=>{let f=[];return i.forEach(c=>{s(c)&&f.push(c),c[r]&&(f=f.concat(a(c[r])))}),f};return a(t)}var Je=t=>{let e=t.replace(/\D/g,"");return e?Math.min(Math.max(parseInt(e,10),1),31).toString():""},Ze=t=>{let e=t.replace(/\D/g,"");return e?Math.min(Math.max(parseInt(e,10),1),12).toString():""},Ge=t=>{let e=t.replace(/\D/g,"");return e?e.length<4?e:parseInt(e,10)<1900?"1900":e:""};export{ze as addSearchParam,ee as ageToBirthDate,te as ageToBirthDateChangeSegment,Ke as arrFromQuery,q as birthDateToAge,ne as calculateAge,V as calculateDetailedAge,me as capitalizeString,Me as compareObjects,Fe as comparePermissionLists,Te as convertObjectToArray,re as convertTimeToTimestamp,be as createOptionsArray,Pe as createSearchQuery,ge as filterInArray,pe as filterInObjects,we as filterUsersOption,Z as formatDate,J as formatDateTime,Oe as getArrayKeys,R as getChangedFields,Ye as getLabelByItemsAndId,Ie as getLabelByItemsAndOptions,se as getTextOnlyFromHtml,X as getTime,B as handleCreateFront,v as handleCreateFrontUnique,Q as handleDeleteFront,ie as handleKeyDownArabic,ce as handleKeyDownEnglish,le as handleKeyDownFloatNumber,ue as handleKeyDownNumber,fe as handleKeyDownNumberNoCopy,z as handleUpdateFront,G as isNotFutureDate,C as literalOrdinals,P as objectToFormData,Be as prePareFilters,Ue as pureURLS3,I as removeEmptyFields,S as removeFields,Y as removeFieldsFromObject,Se as removeFieldsTopLevel,xe as removeIdFromObjects,De as removeItemsWithIds,Ae as removeKeys,_e as searchInObjects,Qe as searchInObjectsWithParents,Re as serializeFormQuery,je as sortObjectByKeys,$e as sortObjectByValues,Ce as toQueryString,Ne as uniqueId,Je as validateDay,Ze as validateMonth,Ge as validateYear};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/arabic.ts","../src/curdOperation.ts","../src/dateUtils.ts","../src/domUtils.ts","../src/eventHandlers.ts","../src/filter.ts","../src/objectUtils.tsx","../src/queryUtils.ts","../src/search.ts","../src/validationDate.ts"],"sourcesContent":["export const literalOrdinals = (num: number, lang: \"ar\" | \"en\"): string => {\n if (lang === \"ar\") {\n const ones = [\"\", \"الأول\", \"الثاني\", \"الثالث\", \"الرابع\", \"الخامس\", \"السادس\", \"السابع\", \"الثامن\", \"التاسع\"];\n const teens = [\"الحادي عشر\", \"الثاني عشر\", \"الثالث عشر\", \"الرابع عشر\", \"الخامس عشر\", \"السادس عشر\", \"السابع عشر\", \"الثامن عشر\", \"التاسع عشر\"];\n const tens = [\"\", \"العاشر\", \"العشرون\", \"الثلاثون\", \"الأربعون\", \"الخمسون\", \"الستون\", \"السبعون\", \"الثمانون\", \"التسعون\"];\n const hundreds = [\"\", \"المائة\", \"المئتان\", \"الثلاثمائة\", \"الأربعمائة\", \"الخمسمائة\", \"الستمائة\", \"السبعمائة\", \"الثمانمائة\", \"التسعمائة\"];\n\n if (num === 1) return \"الأول\";\n if (num >= 2 && num <= 9) return ones[num];\n if (num >= 11 && num <= 19) return teens[num - 11];\n if (num % 10 === 0 && num < 100) return tens[num / 10];\n\n const remainder = num % 10;\n const base = Math.floor(num / 10) * 10;\n\n if (base === 10) return `ال${ones[remainder]} عشر`;\n if (remainder === 1) return `الحادي ${tens[base / 10]}`;\n if (remainder === 2) return `الثاني ${tens[base / 10]}`;\n const result = `${ones[remainder]} و${tens[base / 10]}`;\n\n const hundredPart = Math.floor(num / 100);\n const remainderPart = num % 100;\n if (hundredPart > 0) {\n if (remainderPart === 0) return hundreds[hundredPart];\n return `${hundreds[hundredPart]} و${literalOrdinals(remainderPart, lang)}`;\n }\n\n return result;\n } else {\n const suffixes = [\"th\", \"st\", \"nd\", \"rd\"];\n const v = num % 100;\n return num + (suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0]);\n }\n};\n","// Create\nexport const handleCreateFront = ({ items, setItems, itemData }: { items?: any[]; setItems?: any; itemData?: any }) => {\n if (!items || !setItems || !itemData) return;\n const newItem: any = {\n // id: items.length > 0 ? Math.max(...items.map((item) => item.id)) + 1 : 1,\n id: Number(new Date().getTime()),\n ...itemData,\n };\n newItem && setItems([...items, newItem]);\n};\n// CreateUnique\nexport const handleCreateFrontUnique = ({ items, setItems, itemData, uniqueField }: { items?: any[]; setItems?: any; itemData?: any; uniqueField?: string }) => {\n if (!items || !setItems || !itemData) return;\n\n // Check if the item already exists in the array\n const itemExists = items.some((item) => {\n // If uniqueField is provided and itemData is an object\n if (uniqueField && typeof itemData === \"object\" && itemData !== null) {\n return item[uniqueField] === itemData[uniqueField];\n }\n // For primitive types (string, number, boolean, etc.)\n return item === itemData;\n });\n\n // Only add the item if it doesn't already exist\n if (!itemExists) {\n // const newItem = {\n // id: Number(new Date().getTime()),\n // ...(typeof itemData === \"object\" && itemData !== null ? itemData : { value: itemData }),\n // };\n setItems([...items, itemData]);\n }\n};\n\n// Update\nexport const handleUpdateFront = ({ id, items, setItems, itemData }: { id?: number | string; items?: any[]; setItems?: any; itemData?: any }) => {\n if (!id || !items || !setItems || !itemData) return;\n setItems(items?.map((item) => (item.id === id ? { ...item, ...itemData } : item)));\n};\n\n// Delete\nexport const handleDeleteFront = ({ id, items, setItems }: { id?: number | string | null | (number | string | null)[]; items?: any[]; setItems?: any }) => {\n if (!id || !items || !setItems) return;\n setItems(\n items?.filter((item: any) => {\n if (typeof item === \"object\" && item !== null && !Array.isArray(id)) {\n return item.id !== id;\n } else if (Array.isArray(id)) {\n return !id.includes(item.id ?? item);\n } else {\n return item !== id;\n }\n }),\n );\n};\n","import dayjs from \"dayjs\";\n\nexport const formatDateTime = (date: string | Date | null | undefined) => {\n if (!date) return \"\";\n const newDate = new Date(date);\n //old: \"YYYY-MM-DD\"\n\n return dayjs(newDate).format(\"DD/MM/YYYY, h:mmA\");\n};\n\nexport const formatDate = (date: string | Date | null | undefined) => {\n if (!date) return \"\";\n // return date only\n const newDate = new Date(date);\n //old: \"YYYY-MM-DD\"\n return dayjs(newDate).format(\"DD/MM/YYYY\");\n};\n\nexport const isNotFutureDate = (date: string) => {\n const val = new Date(date);\n // Check if the date is not in the future based on day\n\n const now = new Date();\n now.setDate(now.getDate() + 1);\n now.setHours(0, 0, 0, 0);\n return val < now;\n};\n\nexport function getTime(inputDate: string | Date | null | undefined): string {\n if (!inputDate) return \"\";\n const date = new Date(inputDate);\n const pad = (num: number) => num.toString().padStart(2, \"0\");\n const formattedHours = pad(date.getHours());\n const formattedMinutes = pad(date.getMinutes());\n return `${formattedHours}:${formattedMinutes}`;\n}\n\ninterface Age {\n years: number;\n months: number;\n days: number;\n}\n\nexport const calculateDetailedAge = (birthDate?: Date | string | null, t = (key: string) => key, currentDate: Date | string = new Date(), gender?: string): { age: Age; message: string } => {\n const zeroAge = {\n age: {\n years: 0,\n months: 0,\n days: 0,\n },\n message: t(\"no_age\"),\n };\n if (birthDate === null || birthDate === undefined) {\n return zeroAge;\n }\n // Convert to Date objects if strings are passed\n const birth: Date = birthDate instanceof Date ? birthDate : isValidISODate(birthDate) ? new Date(birthDate) : new Date(Number(birthDate));\n\n const current: Date = currentDate instanceof Date ? currentDate : new Date(Number(currentDate));\n // Validate input dates\n if (isNaN(birth.getTime()) || isNaN(current.getTime())) {\n // throw new Error(\"Invalid date input\");\n return zeroAge;\n }\n\n // Ensure current date is not before birth date\n if (current < birth) {\n // throw new Error(\"Current date cannot be before birth date\");\n return zeroAge;\n }\n\n // Calculate years, months, and days\n let years = current.getFullYear() - birth.getFullYear();\n let months = current.getMonth() - birth.getMonth();\n let days = current.getDate() - birth.getDate();\n\n // Adjust calculations if needed\n if (days < 0) {\n // Borrow days from previous month\n const lastMonth = new Date(current.getFullYear(), current.getMonth(), 0);\n days += lastMonth.getDate();\n months--;\n }\n\n if (months < 0) {\n years--;\n months += 12;\n }\n\n return {\n age: {\n years,\n months,\n days,\n },\n message: `${years} ${t(\"years\")} - ${months} ${t(\"months\")} - ${days} ${t(\"days\")} / ${t(gender ?? \"\")}`,\n };\n};\n\nexport const birthDateToAge = (birthDate?: Date | string | null) => {\n if (!birthDate) return null;\n const birth = new Date(birthDate);\n const today = new Date();\n\n let years = today.getFullYear() - birth.getFullYear();\n let months = today.getMonth() - birth.getMonth();\n let days = today.getDate() - birth.getDate();\n\n if (days < 0) {\n months--;\n days += new Date(today.getFullYear(), today.getMonth(), 0).getDate();\n }\n if (months < 0) {\n years--;\n months += 12;\n }\n\n return { years, months, days };\n};\n\nexport const ageToBirthDate = (age: { years: number; months: number; days: number }) => {\n const today = new Date();\n const birthYear = today.getFullYear() - age.years;\n const birthMonth = today.getMonth() - age.months;\n const birthDay = today.getDate() - age.days;\n\n let birthDate = new Date(today.getFullYear(), today.getMonth(), today.getDate());\n birthDate.setFullYear(birthYear);\n birthDate.setMonth(birthMonth);\n birthDate.setDate(birthDay);\n\n return birthDate;\n};\n\nexport const ageToBirthDateChangeSegment = (oldAge: { years: number; months: number; days: number } | null, age: { years: number; months: number; days: number }) => {\n const today = new Date();\n const birthYear = oldAge && oldAge.years ? oldAge.years - age.years : today.getFullYear() - age.years;\n const birthMonth = oldAge && oldAge.months ? oldAge.months - age.months : today.getMonth() - age.months;\n const birthDay = oldAge && oldAge.days ? oldAge.days - age.days : today.getDate() - age.days;\n\n let birthDate = new Date(today.getFullYear(), today.getMonth(), today.getDate());\n birthDate.setFullYear(birthYear);\n birthDate.setMonth(birthMonth);\n birthDate.setDate(birthDay);\n\n return birthDate;\n};\n\nexport function convertTimeToTimestamp(timeString: string): number {\n // Split the input string into days and time components\n const [daysPart, timePart] = timeString.split(\" \");\n\n // Extract days (remove leading zeros)\n const days = parseInt(daysPart.replace(/^0+/, \"\"), 10);\n\n // Split time into hours, minutes, seconds\n const [hours, minutes, seconds] = timePart?.split(\":\").map((part) => parseInt(part, 10));\n\n // Calculate total milliseconds\n // 1 day = 24 * 60 * 60 * 1000 milliseconds\n const totalMilliseconds =\n days * 24 * 60 * 60 * 1000 + // days to milliseconds\n hours * 60 * 60 * 1000 + // hours to milliseconds\n minutes * 60 * 1000 + // minutes to milliseconds\n seconds * 1000; // seconds to milliseconds\n\n return totalMilliseconds;\n}\n\n// Calculate age function (accept iso format)\nexport const calculateAge = (birthDate: string): number => {\n const today = new Date();\n let birth: Date;\n\n if (birthDate.includes(\"/\")) {\n // DD/MM/YYYY\n const [day, month, year] = birthDate.split(\"/\").map(Number);\n birth = new Date(year, month - 1, day);\n } else if (!isNaN(Date.parse(birthDate))) {\n // ISO or any valid date string\n birth = new Date(birthDate);\n } else {\n throw new Error(\"Unsupported date format\");\n }\n\n let age = today.getFullYear() - birth.getFullYear();\n const m = today.getMonth() - birth.getMonth();\n\n if (m < 0 || (m === 0 && today.getDate() < birth.getDate())) {\n age--;\n }\n\n return age;\n};\n\nfunction isValidISODate(dateString: string): boolean {\n const date = new Date(dateString);\n // Check if the date is valid (not \"Invalid Date\") and if its ISO string representation matches the original.\n // The second check helps to ensure the string was correctly parsed as an ISO date and not some other format.\n return !isNaN(date.getTime()) && date.toISOString() === dateString;\n}\n","export const getTextOnlyFromHtml = (html?: string): string => {\n const parser = new DOMParser();\n const doc = html && parser.parseFromString(html, \"text/html\");\n return (doc && doc.body.textContent) ?? \"\";\n};\n","export const handleKeyDownArabic = (event: any) => {\n const { key, ctrlKey, metaKey } = event;\n // Allow control keys like backspace, delete, arrow keys, etc.\n if (\n key === \"Backspace\" ||\n key === \"Delete\" ||\n key === \"ArrowLeft\" ||\n key === \"ArrowRight\" ||\n key === \"ArrowUp\" ||\n key === \"ArrowDown\" ||\n key === \"Tab\" ||\n key === \"Enter\"\n ) {\n return; // Allow these keys without further checking\n }\n // Allow copy, paste, cut, select all (Ctrl/Command + C, V, X, A)\n if (\n (ctrlKey || metaKey) &&\n (key === \"c\" || key === \"v\" || key === \"x\" || key === \"a\")\n ) {\n return;\n }\n // Check if the key matches Arabic characters, numbers, symbols, or whitespace\n if (!/[\\u0600-\\u06FF0-9\\s!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~]/.test(key)) {\n event.preventDefault();\n }\n};\n\nexport const handleKeyDownEnglish = (event: any) => {\n const { key, ctrlKey, metaKey } = event;\n // Allow control keys like backspace, delete, arrow keys, etc.\n if (\n key === \"Backspace\" ||\n key === \"Delete\" ||\n key === \"ArrowLeft\" ||\n key === \"ArrowRight\" ||\n key === \"ArrowUp\" ||\n key === \"ArrowDown\" ||\n key === \"Tab\" ||\n key === \"Enter\"\n ) {\n return; // Allow these keys without further checking\n }\n // Allow copy, paste, cut, select all (Ctrl/Command + C, V, X, A)\n if (\n (ctrlKey || metaKey) &&\n (key === \"c\" || key === \"v\" || key === \"x\" || key === \"a\")\n ) {\n return;\n }\n\n // Check if the key matches English letters, numbers, or symbols\n if (!/[A-Za-z0-9\\s!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~]/.test(key)) {\n event.preventDefault();\n }\n};\n\nexport const handleKeyDownNumber = (event: any) => {\n const { key, ctrlKey, metaKey } = event;\n\n // Allow keys for navigation, deletion, tab, and enter\n if (\n key === \"Backspace\" ||\n key === \"Delete\" ||\n key === \"ArrowLeft\" ||\n key === \"ArrowRight\" ||\n key === \"ArrowUp\" ||\n key === \"ArrowDown\" ||\n key === \"Tab\" ||\n key === \"Enter\"\n ) {\n return;\n }\n\n // Allow copy, paste, cut, select all (Ctrl/Command + C, V, X, A)\n if (\n (ctrlKey || metaKey) &&\n (key === \"c\" || key === \"v\" || key === \"x\" || key === \"a\")\n ) {\n return;\n }\n\n // Prevent non-numeric input\n if (!/[0-9]/.test(key)) {\n event.preventDefault();\n }\n};\n\nexport const handleKeyDownNumberNoCopy = (event: any) => {\n const { key } = event;\n\n // Allow keys for navigation, deletion, tab, and enter\n if (\n key === \"Backspace\" ||\n key === \"Delete\" ||\n key === \"ArrowLeft\" ||\n key === \"ArrowRight\" ||\n key === \"ArrowUp\" ||\n key === \"ArrowDown\" ||\n key === \"Tab\" ||\n key === \"Enter\"\n ) {\n return;\n }\n // Prevent non-numeric input\n if (!/[0-9]/.test(key)) {\n event.preventDefault();\n }\n};\n\nexport const handleKeyDownFloatNumber = (event: any) => {\n const { key, ctrlKey, metaKey } = event;\n const input = event.currentTarget;\n\n // Allow keys for navigation, deletion, tab, and enter\n if (\n key === \"Backspace\" ||\n key === \"Delete\" ||\n key === \"ArrowLeft\" ||\n key === \"ArrowRight\" ||\n key === \"ArrowUp\" ||\n key === \"ArrowDown\" ||\n key === \"Tab\" ||\n key === \"Enter\"\n ) {\n return;\n }\n\n // Allow copy, paste, cut, select all (Ctrl/Command + C, V, X, A)\n if (\n (ctrlKey || metaKey) &&\n (key === \"c\" || key === \"v\" || key === \"x\" || key === \"a\")\n ) {\n return;\n }\n\n // Allow one decimal point if it doesn't already exist\n if (key === \".\" && !input.value.includes(\".\")) {\n return;\n }\n\n // Prevent non-numeric input (allow numbers and one decimal point)\n if (!/[0-9]/.test(key) && key !== \".\") {\n event.preventDefault();\n }\n};\n","export function filterInArray<T>(field: keyof T, values: T[keyof T][], data: T[]): T[] {\n if (values.length === 0) return data;\n return data.filter((item) => values.includes(item[field]));\n}\n\nexport function filterInObjects(\n data: any[] = [],\n query: string[],\n childrenField: string = \"children\",\n fieldsToFilter?: string[], // Optional array of fields to filter on\n): any[] {\n if (!data) return [];\n if (!query || query?.length === 0) return data;\n\n // Helper function to check if the specified field or all fields match the query.\n const matchesQuery = (obj: any): boolean => {\n const valuesToFilter = fieldsToFilter\n ? fieldsToFilter.map((field) => obj[field]).filter(Boolean) // Only valid fields\n : Object.values(obj); // Default to all fields\n\n return valuesToFilter.some((value) => typeof value === \"string\" && query.some((q) => value.includes(q)));\n };\n\n // Recursive function to filter objects and extract matching ones.\n const filter = (data: any[]): any[] => {\n let results: any[] = [];\n\n data.forEach((item) => {\n // If the current item matches, add it to the results.\n if (matchesQuery(item)) {\n results.push(item);\n }\n\n // Recursively filter the children and add their matches.\n if (item[childrenField]) {\n results = results.concat(filter(item[childrenField]));\n }\n });\n\n return results;\n };\n\n return filter(data);\n}\n","import { isArray, isDate, isEqual, isObject, omit } from \"lodash\";\n\nexport const capitalizeString = (str: string) => {\n return str.charAt(0).toUpperCase() + str.slice(1);\n};\n\nexport function removeEmptyFields<T extends Record<string, any>>(obj: T): Partial<T> {\n return Object.fromEntries(Object.entries(obj).filter(([, value]) => value?.length !== 0 && value !== null && value !== undefined)) as Partial<T>;\n}\n\ntype WithId = {\n _id?: string;\n\n [key: string]: any;\n};\n\nexport function removeIdFromObjects<T extends WithId>(objects: T[]): Omit<T, \"_id\">[] {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n return objects.map(({ _id, ...rest }) => rest);\n}\n\nexport function removeItemsWithIds(array: any[], idsToRemove: string[]): any[] {\n return array.filter((item) => !item?._id || !idsToRemove.includes(item?._id));\n}\n\nexport function createOptionsArray<T>(data: T[], valueField: keyof T, ...labelFields: (keyof T)[]) {\n return data.map((item) => ({\n value: item[valueField] as string | number,\n label: labelFields.map((field) => item[field]).join(\" \"),\n }));\n}\n\nexport function filterUsersOption(option: any, inputValue: string) {\n const fullNameLabel = `${option?.label?.props?.children?.[0]?.props?.children}`;\n const emailLabel = option?.label?.props?.children?.[1]?.props?.children;\n\n return fullNameLabel?.toLowerCase()?.includes(inputValue?.toLowerCase()) || emailLabel?.toLowerCase()?.includes(inputValue?.toLowerCase());\n}\n\nexport function removeKeys(obj: any, keys: string[]): any {\n const clonedObj = { ...obj };\n\n for (const key of keys) {\n delete clonedObj[key];\n }\n\n return clonedObj;\n}\n\nexport function getArrayKeys(obj: any) {\n const result = [];\n for (const key in obj) {\n if (Array.isArray(obj[key])) {\n result.push({ [key]: obj[key] });\n }\n }\n return result;\n}\n\nexport function convertObjectToArray(obj: any): any[] {\n if (!obj) return [];\n return Object.entries(obj).map(([key, value]) => ({\n [key]: value,\n }));\n}\n\ntype Permission = {\n [key: string]: string[];\n};\n\nexport function comparePermissionLists(list1: Permission[], list2: Permission[]): boolean {\n if (list1.length !== list2.length) {\n return false;\n }\n\n for (let i = 0; i < list1.length; i++) {\n const keys1 = Object.keys(list1[i]);\n const keys2 = Object.keys(list2[i]);\n\n if (keys1.length !== keys2.length) {\n return false;\n }\n\n for (const key of keys1) {\n if (!keys2.includes(key)) {\n return false;\n }\n\n const values1 = list1[i][key];\n const values2 = list2[i][key];\n\n if (values1.length !== values2.length) {\n return false;\n }\n\n for (const value of values1) {\n if (!values2.includes(value)) {\n return false;\n }\n }\n }\n }\n\n return true;\n}\n\nexport function objectToFormData(obj: Record<string, any>, formData: FormData = new FormData(), namespace: string = \"\"): FormData {\n for (let key in obj) {\n if (!obj.hasOwnProperty(key)) continue;\n\n const formKey = namespace ? `${namespace}[${key}]` : key;\n\n if (typeof obj[key] === \"object\" && !(obj[key] instanceof File)) {\n // If it's an array or object, call the function recursively\n objectToFormData(obj[key], formData, formKey);\n } else {\n // Otherwise append the value\n formData.append(formKey, obj[key]);\n }\n }\n\n return formData;\n}\n\n/**\n * Compares two objects and returns true if they are equivalent.\n * Ignores specified keys if provided.\n *\n * @param {any} original - The original object.\n * @param {any} updated - The updated object to compare with.\n * @param {string[]} [keysToIgnore=[]] - Optional keys to ignore during comparison.\n * @returns {boolean} - True if objects are equivalent, otherwise false.\n */\nexport function compareObjects(original: any, updated: any, keysToIgnore: string[] = []): boolean {\n const normalizedOriginal = omit(original, keysToIgnore);\n const normalizedUpdated = omit(updated, keysToIgnore);\n\n return isEqual(normalizedOriginal, normalizedUpdated);\n}\n\nexport function getChangedFields(original: any, updated: any): any {\n const changedFields: any = {};\n\n Object.keys(updated ?? {}).forEach((key) => {\n const originalValue = original[key];\n const updatedValue = updated[key];\n\n if (isDate(updatedValue) && isDate(originalValue)) {\n // Handle Date objects\n if (originalValue?.getTime() !== updatedValue?.getTime()) {\n changedFields[key] = updatedValue;\n }\n } else if (isObject(updatedValue) && !isArray(updatedValue) && isObject(originalValue) && !isArray(originalValue)) {\n // Handle nested objects\n const nestedChanges = getChangedFields(originalValue, updatedValue);\n if (Object.keys(nestedChanges).length > 0) {\n changedFields[key] = nestedChanges;\n }\n } else if (isArray(updatedValue) && isArray(originalValue)) {\n // Handle arrays\n if (!isEqual(originalValue, updatedValue)) {\n changedFields[key] = updatedValue;\n }\n } else if (!isEqual(originalValue, updatedValue)) {\n // Handle primitive types (string, number, boolean, etc.)\n changedFields[key] = updatedValue;\n }\n });\n\n return changedFields;\n}\n\nexport function sortObjectByKeys<T extends Record<string, any>>(obj: T): T {\n const sortedEntries = Object.entries(obj).sort((a, b) => {\n return a[0].localeCompare(b[0]);\n });\n\n return Object.fromEntries(sortedEntries) as T;\n}\n\nexport function sortObjectByValues<T extends Record<string, any>>(obj: T): T {\n const sortedEntries = Object.entries(obj).sort((a, b) => {\n if (typeof a[1] === \"number\" && typeof b[1] === \"number\") {\n return a[1] - b[1];\n }\n return 0;\n });\n\n return Object.fromEntries(sortedEntries) as T;\n}\n\n// Example usage\n// const data = {\n// name: { ar: \"اختبار333333333\", \"en-US\": \"test333333333\" },\n// description: { ar: \"اختبار33333\", \"en-US\": \"test33333\" },\n// location: { lat: 12345, lng: 12345 },\n// status: { ar: \"test\", \"en-US\": \"test\" },\n// features: [\"66a92a500075488d302b2184\", \"66a92aab0075488d302b2190\"],\n// price: 5000,\n// // attachments: [ videoFile, pictureFile]\n// };\n\n// const formData = objectToFormData(data);\n\n// // Log the FormData keys and values for verification\n// for (let pair of formData.entries()) {\n//\n// }\n\n// const methodsOrder = [\"POST\", \"GET\", \"PATCH\", \"DELETE\", \"DATA\"];\n\n// export const toggleAndSortMethod = (method: string, methodArray: string[]) => {\n// const index = methodArray.indexOf(method);\n// if (index === -1) {\n// // Method not found, add it\n// methodArray.push(method);\n// } else {\n// // Method found, remove it\n// methodArray.splice(index, 1);\n// }\n// // Sort the array based on the defined order\n// methodArray.sort((a, b) => methodsOrder.indexOf(a) - methodsOrder.indexOf(b));\n// return methodArray;\n// };\n\ntype AnyObject = { [key: string]: any };\n\nexport function removeFields(obj: AnyObject, fieldsToRemove: string[]): AnyObject {\n if (Array.isArray(obj)) {\n // Recursively process each item in the array\n return obj.map((item) => removeFields(item, fieldsToRemove));\n } else if (typeof obj === \"object\" && obj !== null) {\n const newObj: AnyObject = {};\n\n // Iterate over each key-value pair in the object\n for (const key in obj) {\n if (!fieldsToRemove.includes(key)) {\n // Only add the key if it's not in fieldsToRemove, and process its value recursively\n newObj[key] = removeFields(obj[key], fieldsToRemove);\n }\n }\n\n return newObj;\n }\n\n // Return primitive types (strings, numbers, etc.) as is\n return obj;\n}\n\nexport function removeFieldsTopLevel(obj: AnyObject | AnyObject[] | null | undefined, fieldsToRemove?: string[]): any {\n if (obj === null || obj === undefined) {\n return obj;\n }\n if (Array.isArray(obj)) {\n // If it's an array, process each item in the array\n return obj.map((item) => {\n if (typeof item === \"object\" && item !== null) {\n return removeFieldsFromObject(item, fieldsToRemove);\n }\n return item; // Return non-object items as is\n });\n } else if (typeof obj === \"object\" && obj !== null) {\n // If it's a single object, remove fields at the top level\n return removeFieldsFromObject(obj, fieldsToRemove);\n }\n\n // If it's neither an object nor an array, return it as is\n return obj;\n}\n\n// Helper function to remove fields from a single object at the top level\nexport function removeFieldsFromObject(obj: AnyObject, fieldsToRemove?: string[]): AnyObject {\n const newObj: AnyObject = { ...obj };\n\n // Remove specified fields from the object\n for (const field of fieldsToRemove || []) {\n delete newObj[field];\n }\n\n return newObj;\n}\n\nexport const getLabelByItemsAndId = (id?: string | number, items?: any[], fields: string[] | string = \"name\") => {\n if (!items || !id) return undefined;\n const item = items?.find((item) => item.id === id);\n if (item) {\n if (Array.isArray(fields)) {\n return fields.map((field) => item[field]).join(\" \");\n }\n return item[fields];\n }\n return \"\";\n};\n// ex\n// {getLabelByItemsAndId(row.getValue(\"name\"), items, [\n// \"firstName\",\n// \"lastName\",\n// ])}\n\nexport const getLabelByItemsAndOptions = (id?: string | number | null, items?: any[]) => {\n if (!items || !id) return undefined;\n const item = items?.find((item) => item.value === id || item?.id === id || item?._id === id);\n if (item) {\n return item.label;\n }\n return \"\";\n};\n// ex {getLabelByItemsAndOptions(row.getValue(\"name\"), usersOptions)}\n","import { removeEmptyFields } from \"./objectUtils\";\n\nexport function toQueryString(params?: any): string {\n if (params)\n return Object.entries(removeEmptyFields(params))\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`)\n .join(\"&\");\n return \"\";\n}\n\nexport function pureURLS3(url: string | undefined): string | undefined {\n if (url?.startsWith(\"http\")) {\n return url.split(\".com/\")[1].split(\"?\")[0];\n }\n return url;\n}\n\nexport const createSearchQuery = (params: Record<string, string | number | boolean | undefined | string[] | number[]>) => {\n const query = new URLSearchParams();\n for (const [key, value] of Object.entries(params)) {\n if (Array.isArray(value)) {\n for (const v of value) {\n query.append(key, v.toString());\n }\n } else if (value !== undefined) {\n query.append(key, value.toString());\n }\n }\n\n return query.toString();\n};\n\nexport const serializeFormQuery = (params: Record<string, string | number | boolean | undefined | string[] | number[]>) => {\n return Object.entries(params)\n .map(([key, value]) => {\n if (Array.isArray(value)) {\n if (value.length === 0) return \"\";\n return `${key}=${value.join(\",\")}`;\n }\n if (value === undefined || value === \"\") return \"\";\n return `${key}=${value}`;\n })\n .filter((val) => val !== \"\")\n .join(\"&\");\n};\n\nexport const arrFromQuery = (query: string | null) => (!query || query === null || query === \"\" ? [] : query.split(\",\").map((val) => parseInt(val)));\n\nexport const uniqueId = (): number => {\n return Date.now() + Math.floor(Math.random() * 10000);\n};\n\nexport const prePareFilters = (searchParams: URLSearchParams) => {\n const filtersParam = searchParams.get(\"filters\");\n if (!filtersParam) return null;\n\n try {\n const decoded = decodeURIComponent(filtersParam);\n const filtersArray = JSON.parse(decoded);\n\n // Convert filter format to backend format if needed\n // The filters come in format: { column, logic, value, fields, operatorGroup }\n // We need to send them as-is to trigger refetch\n return filtersArray;\n } catch (error) {\n console.error(\"Error parsing filters from URL:\", error);\n return null;\n }\n};\n","\nexport const addSearchParam = (searchParams: URLSearchParams, setSearchParams: any, key: string, value: string) => {\n const newSearchParams = new URLSearchParams(searchParams);\n newSearchParams.set(key, value);\n setSearchParams(newSearchParams);\n};\n\n/**\n * Recursively searches across all fields of objects and their [`${childrenField}`].\n * @param data - The array of objects to search.\n * @param query - The search query string.\n * @returns An array of objects that match the search query.\n */\nexport function searchInObjectsWithParents(\n data: any[] = [],\n query: string = \"\",\n childrenField: string = \"children\",\n fieldsToSearch?: string[], // Optional: Array of specific fields to search\n): any[] {\n if (!data) return [];\n if (!query) return data;\n\n const lowerQuery = query.trim()?.toLowerCase();\n\n // Helper function to check if the object matches the query within the specified fields.\n const matchesQuery = (obj: any): boolean => {\n const valuesToSearch = fieldsToSearch\n ? fieldsToSearch.map((field) => obj[field]).filter(Boolean) // Filter out invalid fields\n : Object.values(obj); // Default to all values\n\n return valuesToSearch.some((value) => typeof value === \"string\" && value?.toLowerCase().includes(lowerQuery));\n };\n\n // Recursive function to search objects and retain matching parents and children.\n const search = (data: any[]): any[] => {\n return data\n .map((item) => {\n const childResults = item[childrenField] ? search(item[childrenField]) : [];\n\n // If the item matches the query or any child matches, include it in the results.\n if (matchesQuery(item) || childResults.length > 0) {\n return {\n ...item,\n [childrenField]: childResults.length > 0 ? childResults : undefined, // Keep only matching children.\n };\n }\n return null; // Exclude non-matching items.\n })\n .filter((item) => item !== null); // Remove null values from the result.\n };\n\n return search(data);\n}\n\nexport function searchInObjects(\n data: any[] = [],\n query: string = \"\",\n childrenField: string = \"children\",\n fieldsToSearch?: string[], // Optional array of fields to search on\n): any[] {\n if (!data) return [];\n if (!query) return data;\n const lowerQuery = query?.trim()?.toLowerCase();\n\n // Helper function to check if the specified field or all fields match the query.\n const matchesQuery = (obj: any): boolean => {\n const valuesToSearch = fieldsToSearch\n ? fieldsToSearch.map((field) => obj[field]).filter(Boolean) // Only valid fields\n : Object.values(obj); // Default to all fields\n\n return valuesToSearch.some((value) => typeof value === \"string\" && value?.toLowerCase().includes(lowerQuery));\n };\n\n // Recursive function to search objects and extract matching ones.\n const search = (data: any[]): any[] => {\n let results: any[] = [];\n\n data.forEach((item) => {\n // If the current item matches, add it to the results.\n if (matchesQuery(item)) {\n results.push(item);\n }\n\n // Recursively search the children and add their matches.\n if (item[childrenField]) {\n results = results.concat(search(item[childrenField]));\n }\n });\n\n return results;\n };\n\n return search(data);\n}\n","export const validateDay = (value: string): string => {\n let sanitizedValue = value.replace(/\\D/g, \"\"); // Remove non-numeric characters\n if (!sanitizedValue) return \"\"; // Allow empty input\n return Math.min(Math.max(parseInt(sanitizedValue, 10), 1), 31).toString(); // Ensure between 1-31\n};\n\nexport const validateMonth = (value: string): string => {\n let sanitizedValue = value.replace(/\\D/g, \"\");\n if (!sanitizedValue) return \"\";\n return Math.min(Math.max(parseInt(sanitizedValue, 10), 1), 12).toString(); // Ensure between 1-12\n};\n\nexport const validateYear = (value: string): string => {\n let sanitizedValue = value.replace(/\\D/g, \"\"); // Remove non-numeric characters\n if (!sanitizedValue) return \"\";\n\n // Allow typing until 4 digits are reached\n if (sanitizedValue.length < 4) return sanitizedValue;\n\n // Ensure the year is at least 1900 when it reaches 4 digits\n const year = parseInt(sanitizedValue, 10);\n return year < 1900 ? \"1900\" : sanitizedValue;\n};\n"],"mappings":"+kBAAO,IAAMA,EAAkB,CAACC,EAAaC,IAA8B,CACzE,GAAIA,IAAS,KAAM,CACjB,IAAMC,EAAO,CAAC,GAAI,iCAAS,uCAAU,uCAAU,uCAAU,uCAAU,uCAAU,uCAAU,uCAAU,sCAAQ,EACnGC,EAAQ,CAAC,0DAAc,0DAAc,0DAAc,0DAAc,0DAAc,0DAAc,0DAAc,0DAAc,yDAAY,EACrIC,EAAO,CAAC,GAAI,uCAAU,6CAAW,mDAAY,mDAAY,6CAAW,uCAAU,6CAAW,mDAAY,4CAAS,EAC9GC,EAAW,CAAC,GAAI,uCAAU,6CAAW,+DAAc,+DAAc,yDAAa,mDAAY,yDAAa,+DAAc,wDAAW,EAEtI,GAAIL,IAAQ,EAAG,MAAO,iCACtB,GAAIA,GAAO,GAAKA,GAAO,EAAG,OAAOE,EAAKF,CAAG,EACzC,GAAIA,GAAO,IAAMA,GAAO,GAAI,OAAOG,EAAMH,EAAM,EAAE,EACjD,GAAIA,EAAM,KAAO,GAAKA,EAAM,IAAK,OAAOI,EAAKJ,EAAM,EAAE,EAErD,IAAMM,EAAYN,EAAM,GAClBO,EAAO,KAAK,MAAMP,EAAM,EAAE,EAAI,GAEpC,GAAIO,IAAS,GAAI,MAAO,eAAKL,EAAKI,CAAS,CAAC,sBAC5C,GAAIA,IAAc,EAAG,MAAO,wCAAUF,EAAKG,EAAO,EAAE,CAAC,GACrD,GAAID,IAAc,EAAG,MAAO,wCAAUF,EAAKG,EAAO,EAAE,CAAC,GACrD,IAAMC,EAAS,GAAGN,EAAKI,CAAS,CAAC,UAAKF,EAAKG,EAAO,EAAE,CAAC,GAE/CE,EAAc,KAAK,MAAMT,EAAM,GAAG,EAClCU,EAAgBV,EAAM,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,GAA0B,CACpD,IAAIC,EAAiBD,EAAM,QAAQ,MAAO,EAAE,EAC5C,OAAKC,EACE,KAAK,IAAI,KAAK,IAAI,SAASA,EAAgB,EAAE,EAAG,CAAC,EAAG,EAAE,EAAE,SAAS,EAD5C,EAE9B,EAEaC,GAAiBF,GAA0B,CACtD,IAAIC,EAAiBD,EAAM,QAAQ,MAAO,EAAE,EAC5C,OAAKC,EACE,KAAK,IAAI,KAAK,IAAI,SAASA,EAAgB,EAAE,EAAG,CAAC,EAAG,EAAE,EAAE,SAAS,EAD5C,EAE9B,EAEaE,GAAgBH,GAA0B,CACrD,IAAIC,EAAiBD,EAAM,QAAQ,MAAO,EAAE,EAC5C,OAAKC,EAGDA,EAAe,OAAS,EAAUA,EAGzB,SAASA,EAAgB,EAAE,EAC1B,KAAO,OAASA,EAPF,EAQ9B","names":["literalOrdinals","num","lang","ones","teens","tens","hundreds","remainder","base","result","hundredPart","remainderPart","suffixes","v","handleCreateFront","items","setItems","itemData","newItem","__spreadValues","handleCreateFrontUnique","uniqueField","item","handleUpdateFront","id","handleDeleteFront","_a","dayjs","formatDateTime","date","newDate","formatDate","isNotFutureDate","val","now","getTime","inputDate","pad","num","formattedHours","formattedMinutes","calculateDetailedAge","birthDate","t","key","currentDate","gender","zeroAge","birth","isValidISODate","current","years","months","days","lastMonth","birthDateToAge","today","ageToBirthDate","age","birthYear","birthMonth","birthDay","ageToBirthDateChangeSegment","oldAge","convertTimeToTimestamp","timeString","daysPart","timePart","hours","minutes","seconds","part","calculateAge","day","month","year","m","dateString","getTextOnlyFromHtml","html","_a","parser","doc","handleKeyDownArabic","event","key","ctrlKey","metaKey","handleKeyDownEnglish","handleKeyDownNumber","handleKeyDownNumberNoCopy","handleKeyDownFloatNumber","input","filterInArray","field","values","data","item","filterInObjects","query","childrenField","fieldsToFilter","matchesQuery","obj","value","q","filter","results","isArray","isDate","isEqual","isObject","omit","capitalizeString","str","removeEmptyFields","obj","value","removeIdFromObjects","objects","_a","_b","_id","rest","__objRest","removeItemsWithIds","array","idsToRemove","item","createOptionsArray","data","valueField","labelFields","field","filterUsersOption","option","inputValue","_c","_d","_e","_f","_g","_h","_i","_j","_k","_l","fullNameLabel","emailLabel","removeKeys","keys","clonedObj","__spreadValues","key","getArrayKeys","result","convertObjectToArray","comparePermissionLists","list1","list2","i","keys1","keys2","values1","values2","objectToFormData","formData","namespace","formKey","compareObjects","original","updated","keysToIgnore","normalizedOriginal","omit","normalizedUpdated","isEqual","getChangedFields","changedFields","originalValue","updatedValue","isDate","isObject","isArray","nestedChanges","sortObjectByKeys","sortedEntries","a","b","sortObjectByValues","removeFields","fieldsToRemove","newObj","removeFieldsTopLevel","removeFieldsFromObject","getLabelByItemsAndId","id","items","fields","getLabelByItemsAndOptions","toQueryString","params","removeEmptyFields","value","key","pureURLS3","url","createSearchQuery","query","v","serializeFormQuery","val","arrFromQuery","uniqueId","prePareFilters","searchParams","filtersParam","decoded","error","addSearchParam","searchParams","setSearchParams","key","value","newSearchParams","searchInObjectsWithParents","data","query","childrenField","fieldsToSearch","_a","lowerQuery","matchesQuery","obj","field","search","item","childResults","__spreadProps","__spreadValues","searchInObjects","results","validateDay","value","sanitizedValue","validateMonth","validateYear"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "super-utilix",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A collection of utility functions",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"import": "./dist/index.mjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsup",
|
|
20
|
+
"prepublishOnly": "npm run build"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"utils",
|
|
24
|
+
"typescript",
|
|
25
|
+
"power-utils"
|
|
26
|
+
],
|
|
27
|
+
"author": "",
|
|
28
|
+
"license": "ISC",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"dayjs": "^1.11.10",
|
|
31
|
+
"lodash": "^4.17.21"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/lodash": "^4.14.202",
|
|
35
|
+
"@types/node": "^20.10.0",
|
|
36
|
+
"rimraf": "^5.0.5",
|
|
37
|
+
"tsup": "^8.5.1",
|
|
38
|
+
"typescript": "^5.3.3"
|
|
39
|
+
}
|
|
40
|
+
}
|