@react-fabric/utilities 1.0.0-beta.8 → 1.0.1

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.
Files changed (168) hide show
  1. package/dist/cjs/css/boundingBox.js +72 -0
  2. package/dist/cjs/css/cn.js +39 -0
  3. package/dist/cjs/css/imageColorset.js +96 -0
  4. package/dist/cjs/data/countries.js +98 -0
  5. package/dist/cjs/{_fileType.js → data/fileType.js} +37 -19
  6. package/dist/cjs/data/format.js +136 -0
  7. package/dist/cjs/helpers/debounce.js +63 -0
  8. package/dist/cjs/{useLogger.js → helpers/getLogger.js} +96 -96
  9. package/dist/cjs/helpers/lonlat.js +99 -0
  10. package/dist/cjs/index.js +99 -76
  11. package/dist/cjs/lists/dedupe.js +54 -0
  12. package/dist/cjs/lists/flatten.js +66 -0
  13. package/dist/cjs/{_getByPath.js → lists/getByPath.js} +58 -37
  14. package/dist/cjs/lists/groupBy.js +49 -0
  15. package/dist/cjs/matchers/compare.js +70 -0
  16. package/dist/cjs/matchers/isEmpty.js +34 -0
  17. package/dist/cjs/matchers/isEqual.js +82 -0
  18. package/dist/cjs/matchers/nullChecks.js +61 -0
  19. package/dist/cjs/matchers/typeChecks.js +127 -0
  20. package/dist/cjs/strings/ascii.js +105 -0
  21. package/dist/cjs/strings/hash.js +75 -0
  22. package/dist/cjs/strings/interpolate.js +47 -0
  23. package/dist/cjs/strings/matchString.js +54 -0
  24. package/dist/cjs/strings/template.js +48 -0
  25. package/dist/cjs/strings/tokenize.js +83 -0
  26. package/dist/cjs/utils/mergeRefs.js +56 -0
  27. package/dist/esm/css/boundingBox.js +71 -0
  28. package/dist/esm/css/cn.js +39 -0
  29. package/dist/esm/css/imageColorset.js +96 -0
  30. package/dist/esm/data/countries.js +98 -0
  31. package/dist/esm/{_fileType.js → data/fileType.js} +37 -19
  32. package/dist/esm/data/format.js +138 -0
  33. package/dist/esm/helpers/debounce.js +63 -0
  34. package/dist/esm/{useLogger.js → helpers/getLogger.js} +96 -96
  35. package/dist/esm/helpers/lonlat.js +97 -0
  36. package/dist/esm/index.js +54 -36
  37. package/dist/esm/lists/dedupe.js +54 -0
  38. package/dist/esm/lists/flatten.js +65 -0
  39. package/dist/esm/{_getByPath.js → lists/getByPath.js} +50 -29
  40. package/dist/esm/lists/groupBy.js +49 -0
  41. package/dist/esm/matchers/compare.js +70 -0
  42. package/dist/esm/matchers/isEmpty.js +34 -0
  43. package/dist/esm/matchers/isEqual.js +82 -0
  44. package/dist/esm/matchers/nullChecks.js +58 -0
  45. package/dist/esm/matchers/typeChecks.js +119 -0
  46. package/dist/esm/strings/ascii.js +105 -0
  47. package/dist/esm/strings/hash.js +73 -0
  48. package/dist/esm/strings/interpolate.js +47 -0
  49. package/dist/esm/strings/matchString.js +54 -0
  50. package/dist/esm/strings/template.js +48 -0
  51. package/dist/esm/strings/tokenize.js +82 -0
  52. package/dist/esm/utils/mergeRefs.js +56 -0
  53. package/dist/types/css/boundingBox.d.ts +46 -0
  54. package/dist/types/css/cn.d.ts +26 -0
  55. package/dist/types/css/imageColorset.d.ts +37 -0
  56. package/dist/types/data/countries.d.ts +136 -0
  57. package/dist/types/{_fileType.d.ts → data/fileType.d.ts} +41 -1
  58. package/dist/types/data/format.d.ts +122 -0
  59. package/dist/types/helpers/debounce.d.ts +38 -0
  60. package/dist/types/helpers/getLogger.d.ts +49 -0
  61. package/dist/types/helpers/lonlat.d.ts +48 -0
  62. package/dist/types/index.d.ts +54 -20
  63. package/dist/types/lists/dedupe.d.ts +36 -0
  64. package/dist/types/lists/flatten.d.ts +47 -0
  65. package/dist/types/lists/getByPath.d.ts +45 -0
  66. package/dist/types/lists/groupBy.d.ts +36 -0
  67. package/dist/types/matchers/compare.d.ts +38 -0
  68. package/dist/types/matchers/isEmpty.d.ts +38 -0
  69. package/dist/types/matchers/isEqual.d.ts +39 -0
  70. package/dist/types/matchers/nullChecks.d.ts +43 -0
  71. package/dist/types/matchers/typeChecks.d.ts +107 -0
  72. package/dist/types/strings/ascii.d.ts +34 -0
  73. package/dist/types/strings/hash.d.ts +46 -0
  74. package/dist/types/strings/interpolate.d.ts +34 -0
  75. package/dist/types/strings/matchString.d.ts +41 -0
  76. package/dist/types/strings/template.d.ts +35 -0
  77. package/dist/types/strings/tokenize.d.ts +44 -0
  78. package/dist/types/utils/mergeRefs.d.ts +36 -0
  79. package/package.json +13 -11
  80. package/src/css/boundingBox.ts +80 -0
  81. package/src/css/cn.ts +32 -0
  82. package/src/css/imageColorset.ts +97 -0
  83. package/src/data/countries.ts +126 -0
  84. package/src/{_fileType.ts → data/fileType.ts} +72 -89
  85. package/src/data/format.ts +192 -0
  86. package/src/helpers/debounce.ts +49 -0
  87. package/src/{useLogger.ts → helpers/getLogger.ts} +52 -101
  88. package/src/helpers/lonlat.ts +124 -0
  89. package/src/index.ts +57 -37
  90. package/src/lists/dedupe.ts +46 -0
  91. package/src/lists/flatten.ts +56 -0
  92. package/src/lists/getByPath.ts +122 -0
  93. package/src/lists/groupBy.ts +47 -0
  94. package/src/matchers/compare.ts +64 -0
  95. package/src/matchers/isEmpty.ts +54 -0
  96. package/src/matchers/isEqual.ts +71 -0
  97. package/src/matchers/nullChecks.ts +55 -0
  98. package/src/matchers/typeChecks.ts +146 -0
  99. package/src/strings/ascii.ts +100 -0
  100. package/src/strings/hash.ts +68 -0
  101. package/src/strings/interpolate.ts +42 -0
  102. package/src/strings/matchString.ts +49 -0
  103. package/src/strings/template.ts +43 -0
  104. package/src/strings/tokenize.ts +77 -0
  105. package/src/utils/mergeRefs.ts +47 -0
  106. package/src/{yup.ts → utils/yup.ts} +3 -3
  107. package/dist/cjs/_ascii.js +0 -76
  108. package/dist/cjs/_boundingBox.js +0 -59
  109. package/dist/cjs/_countries.js +0 -2805
  110. package/dist/cjs/_debounce.js +0 -53
  111. package/dist/cjs/_dedupe.js +0 -63
  112. package/dist/cjs/_fetch.js +0 -128
  113. package/dist/cjs/_format.js +0 -118
  114. package/dist/cjs/_hash.js +0 -67
  115. package/dist/cjs/_interpolate.js +0 -47
  116. package/dist/cjs/_isEqual.js +0 -108
  117. package/dist/cjs/_isType.js +0 -98
  118. package/dist/cjs/_mergeRefs.js +0 -40
  119. package/dist/cjs/_tokenize.js +0 -67
  120. package/dist/cjs/getImageColorset.js +0 -70
  121. package/dist/esm/_ascii.js +0 -76
  122. package/dist/esm/_boundingBox.js +0 -58
  123. package/dist/esm/_countries.js +0 -2805
  124. package/dist/esm/_debounce.js +0 -53
  125. package/dist/esm/_dedupe.js +0 -60
  126. package/dist/esm/_fetch.js +0 -128
  127. package/dist/esm/_format.js +0 -120
  128. package/dist/esm/_hash.js +0 -65
  129. package/dist/esm/_interpolate.js +0 -46
  130. package/dist/esm/_isEqual.js +0 -106
  131. package/dist/esm/_isType.js +0 -85
  132. package/dist/esm/_mergeRefs.js +0 -40
  133. package/dist/esm/_tokenize.js +0 -66
  134. package/dist/esm/getImageColorset.js +0 -70
  135. package/dist/types/_ascii.d.ts +0 -5
  136. package/dist/types/_boundingBox.d.ts +0 -10
  137. package/dist/types/_countries.d.ts +0 -85
  138. package/dist/types/_debounce.d.ts +0 -8
  139. package/dist/types/_dedupe.d.ts +0 -4
  140. package/dist/types/_fetch.d.ts +0 -23
  141. package/dist/types/_format.d.ts +0 -27
  142. package/dist/types/_getByPath.d.ts +0 -10
  143. package/dist/types/_hash.d.ts +0 -16
  144. package/dist/types/_interpolate.d.ts +0 -6
  145. package/dist/types/_isEqual.d.ts +0 -15
  146. package/dist/types/_isType.d.ts +0 -14
  147. package/dist/types/_mergeRefs.d.ts +0 -1
  148. package/dist/types/_tokenize.d.ts +0 -8
  149. package/dist/types/getImageColorset.d.ts +0 -1
  150. package/dist/types/useLogger.d.ts +0 -25
  151. package/src/_ascii.ts +0 -93
  152. package/src/_boundingBox.ts +0 -72
  153. package/src/_countries.ts +0 -3046
  154. package/src/_debounce.ts +0 -42
  155. package/src/_dedupe.ts +0 -56
  156. package/src/_fetch.ts +0 -109
  157. package/src/_format.ts +0 -141
  158. package/src/_getByPath.ts +0 -108
  159. package/src/_hash.ts +0 -62
  160. package/src/_interpolate.ts +0 -42
  161. package/src/_isEqual.ts +0 -102
  162. package/src/_isType.ts +0 -105
  163. package/src/_mergeRefs.ts +0 -33
  164. package/src/_tokenize.ts +0 -69
  165. package/src/getImageColorset.ts +0 -81
  166. /package/dist/cjs/{yup.js → utils/yup.js} +0 -0
  167. /package/dist/esm/{yup.js → utils/yup.js} +0 -0
  168. /package/dist/types/{yup.d.ts → utils/yup.d.ts} +0 -0
@@ -0,0 +1,122 @@
1
+ /**
2
+ * React Fabric
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2024 Adarsh Pastakia
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ /**
26
+ * Format utility functions for various data types.
27
+ * This namespace provides methods to format phone numbers, numbers, bytes, percentages, dates, and durations.
28
+ */
29
+ export declare namespace Format {
30
+ /**
31
+ * Format phone number with country flag or emoji.
32
+ * It takes a phone number string, a country code, and a boolean to indicate whether to use CSS classes for flags.
33
+ * If the phone number is empty, less than 6 characters, or does not match the regex for valid phone numbers,
34
+ * it returns the original value.
35
+ * If the phone number is valid, it formats the phone number using `libphonenumber-js` and returns it with the country flag or emoji.
36
+ * The country flag is represented as a CSS class, and the emoji is obtained from the `Countries` module.
37
+ *
38
+ * @param {string} value - The phone number to format.
39
+ * @param {string} country - The country code to use for formatting.
40
+ * @param {boolean} useCss - Whether to use CSS classes for flags.
41
+ * @returns {string} The formatted phone number with country flag or emoji.
42
+ */
43
+ function phone(value?: string, country?: string, useCss?: boolean): string | undefined;
44
+ /**
45
+ * Format number using `numeral`.
46
+ * It takes a number or string and a format string, and returns the formatted number.
47
+ * If the number is undefined or null, it returns an empty string.
48
+ * If the number starts with a '+', it retains the '+' sign in the formatted output.
49
+ * This function is useful for displaying numbers in a human-readable format,
50
+ * such as for financial data, statistics, or any numerical representation.
51
+ *
52
+ * @param {string | number} number - number or string to format
53
+ * @param {string} [format] - optional format string, defaults to "0,0[.]00a"
54
+ * @returns {string} formatted number
55
+ */
56
+ function number(number?: string | number, format?: string): string;
57
+ /**
58
+ * Format bytes using `numeral`.
59
+ * It takes a number or string and returns the formatted bytes.
60
+ * If the number is undefined or null, it returns an empty string.
61
+ * If the number starts with a '+', it retains the '+' sign in the formatted output.
62
+ * This function is useful for displaying file sizes or data transfer amounts in a human-readable format.
63
+ *
64
+ * @param {string | number} number - number or string to format
65
+ * @returns {string} formatted bytes
66
+ */
67
+ function bytes(number?: string | number): string;
68
+ /**
69
+ * Format percentage using `numeral`.
70
+ * It takes a number or string and returns the formatted percentage.
71
+ * If the number is undefined or null, it returns an empty string.
72
+ * If the number starts with a '+', it retains the '+' sign in the formatted output.
73
+ *
74
+ * @param {string | number} number - number or string to format
75
+ * @returns {string} formatted percentage
76
+ */
77
+ function percent(number?: string | number): string;
78
+ /**
79
+ * Format date using `date-fns`.
80
+ * It takes a date (as a Date object, string, or number) and a format string.
81
+ * If the date is undefined or null, it returns an empty string.
82
+ * If the date is a valid date, it formats it using the provided format string.
83
+ * Format defaults to "d-M-y" if not provided.
84
+ *
85
+ * @param {date | string | number} date - Date object, string, or number to format
86
+ * @typedef {string} format - Optional format string, defaults to "d-M-y"
87
+ * @returns {string} - Formatted date string
88
+ */
89
+ function date(date?: Date | string | number, format?: string): string;
90
+ /** ***************** format time duration from total seconds/milliseconds *******************/
91
+ /**
92
+ * Format time duration with milliseconds
93
+ * This function takes a number or string representing a duration in seconds or milliseconds,
94
+ * and returns a formatted string in the format "HH:mm:ss.SSS".
95
+ * If the input is undefined or null, it returns "00:00.000".
96
+ * If the input is Infinity, it returns "∞".
97
+ * The function also accepts an optional boolean parameter `isFraction` to indicate whether the input is in seconds (true) or milliseconds (false).
98
+ * If `isFraction` is true, the input is multiplied by 1000 to convert seconds to milliseconds.
99
+ * The function uses the `makeDuration` helper function to format the duration.
100
+ *
101
+ * @param {string | number} number - The duration to format, can be a string or number.
102
+ * @param {boolean} isFraction - Optional parameter to indicate if the input is in seconds (true) or milliseconds (false).
103
+ * @returns {string} - The formatted duration string.
104
+ */
105
+ function duration(number?: string | number, isFraction?: boolean): string;
106
+ /**
107
+ * Format time duration in seconds
108
+ * This function takes a number or string representing a duration in seconds,
109
+ * and returns a formatted string in the format "HH:mm:ss".
110
+ * If the input is undefined or null, it returns "00:00".
111
+ * If the input is Infinity, it returns "∞".
112
+ * The function also accepts an optional boolean parameter `isFraction` to indicate whether the input is in seconds (true) or milliseconds (false).
113
+ * If `isFraction` is true, the input is multiplied by 1000 to convert seconds to milliseconds.
114
+ * The function uses the `makeDuration` helper function to format the duration.
115
+ * This function is useful for displaying durations in a human-readable format, such as for timers or elapsed time.
116
+ *
117
+ * @param {string | number} number - The duration to format, can be a string or number.
118
+ * @param {boolean} isFraction - Optional parameter to indicate if the input is in seconds (true) or milliseconds (false).
119
+ * @returns {string} - The formatted duration string.
120
+ */
121
+ function durationSeconds(number?: string | number, isFraction?: boolean): string;
122
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * React Fabric
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2024 Adarsh Pastakia
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ /**
26
+ * Debounce function to limit the rate at which a function can fire.
27
+ * It will delay the execution of the function until after a specified timeout
28
+ * has elapsed since the last time the function was invoked.
29
+ *
30
+ * @param fn - The function to debounce.
31
+ * @param timeout - The number of milliseconds to wait before invoking the function.
32
+ * @returns A debounced version of the function that can be called with any arguments.
33
+ * The debounced function also has a `cancel` method to clear the timeout.
34
+ */
35
+ export declare function debounce(fn: (...rest: AnyObject[]) => unknown, timeout?: number): {
36
+ (...args: AnyObject[]): void;
37
+ cancel(): void;
38
+ };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * React Fabric
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2024 Adarsh Pastakia
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ interface LogDetail {
26
+ module?: string;
27
+ process?: string;
28
+ duration?: number;
29
+ totalTime?: number;
30
+ }
31
+ /**
32
+ * Returns a logger object with log/debug/info/error/warning methods, adapted for Node or browser. Optionally takes a module name.
33
+ */
34
+ export declare const getLogger: (mod?: string) => {
35
+ timer(process: string): {
36
+ log: (msg: string, ...rest: unknown[]) => void;
37
+ debug: (msg: string, ...rest: unknown[]) => void;
38
+ info: (msg: string, ...rest: unknown[]) => void;
39
+ error: (msg: string, ...rest: unknown[]) => void;
40
+ warning: (msg: string, ...rest: unknown[]) => void;
41
+ end: (msg?: string, ...rest: unknown[]) => void;
42
+ };
43
+ log(msg: string, opts: LogDetail, ...rest: unknown[]): void;
44
+ debug(msg: string, opts: LogDetail, ...rest: unknown[]): void;
45
+ info(msg: string, opts: LogDetail, ...rest: unknown[]): void;
46
+ error(msg: string, opts: LogDetail, ...rest: unknown[]): void;
47
+ warning(msg: string, opts: LogDetail, ...rest: unknown[]): void;
48
+ };
49
+ export {};
@@ -0,0 +1,48 @@
1
+ export type LngLatLike = {
2
+ lng: number;
3
+ lat: number;
4
+ } | {
5
+ lon: number;
6
+ lat: number;
7
+ } | {
8
+ longitude: number;
9
+ latitude: number;
10
+ } | [lon: number | string, lat: number | string] | [lon: number | string, lat: number | string, z: number | string] | string;
11
+ /**
12
+ * Convert various formats of longitude and latitude to a tuple of [lon, lat].
13
+ * This function supports:
14
+ * - Arrays with two or three elements (e.g., [lon, lat] or [lon, lat, alt])
15
+ * - Objects with properties `lng`, `lat`, `lon`, or `longitude` and `latitude`
16
+ * - Strings in the format "lat,lon"
17
+ * The function will return a tuple of numbers [lon, lat].
18
+ *
19
+ * @param {LngLatLike} lonLat - The input longitude and latitude in various formats.
20
+ * @returns { [lon: number, lat: number] } A tuple of [lon, lat] where lon and lat are numbers.
21
+ * @throws Error if the input is not a valid format.
22
+ */
23
+ export declare function convertToLonLat(lonLat: LngLatLike): [lon: number, lat: number];
24
+ export declare function getLatitudeLongitude(lonLat: LngLatLike): {
25
+ latitude: number;
26
+ longitude: number;
27
+ };
28
+ /**
29
+ * Convert a latitude and longitude to a human-readable text format.
30
+ * This function takes a latitude and longitude in various formats and
31
+ * returns a string in the format "degrees˚minutes'seconds" with direction (N/S, E/W).
32
+ *
33
+ * This function supports:
34
+ *
35
+ * - Objects with properties `lng`, `lat`, `lon`, or `longitude` and `latitude`
36
+ * - Arrays with two or three elements (e.g., [lon, lat] or [lon, lat, alt])
37
+ * - Strings in the format "lat,lon"
38
+ *
39
+ * @param {LngLatLike} latlon - The latitude and longitude in various formats.
40
+ * @returns {string} A string representation of the location in DMS format.
41
+ *
42
+ * @example
43
+ * ```jsx
44
+ * const location = getLocationAsText({ lat: 40.7128, lng: -74.0060 });
45
+ * console.log(location); // "40˚42'51.36"N, 74˚0'21.60"W"
46
+ * ```
47
+ */
48
+ export declare function getLocationAsText(latlon: LngLatLike): string;
@@ -1,22 +1,56 @@
1
- export * from "./_ascii";
2
- export * from "./_boundingBox";
3
- export { getBoundingBox, getBox } from "./_boundingBox";
4
- export { default as Countries } from "./_countries";
5
- export type { Country } from "./_countries";
6
- export * from "./_debounce";
7
- export * from "./_dedupe";
8
- export { _fetch as fetch } from "./_fetch";
9
- export { default as FileUtil } from "./_fileType";
10
- export * from "./_format";
11
- export * from "./_getByPath";
12
- export * from "./_hash";
13
- export * from "./_interpolate";
14
- export * from "./_isEqual";
15
- export * from "./_isType";
16
- export * from "./_mergeRefs";
17
- export * from "./_tokenize";
18
- export { getImageColorset } from "./getImageColorset";
19
- export { useLogger } from "./useLogger";
20
- export * from "./yup";
1
+ /**
2
+ * React Fabric
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2024 Adarsh Pastakia
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ export declare const UTILITIES_PACKAGE = "@react-fabric/utilities";
26
+ export declare const UTILITIES_VERSION = "1.0.0";
27
+ export { getBoundingBox, getBox } from "./css/boundingBox";
28
+ export { cn } from "./css/cn";
29
+ export { getImageColorset } from "./css/imageColorset";
30
+ export { dedupe } from "./lists/dedupe";
31
+ export { flatten, flattenAndDedupe } from "./lists/flatten";
32
+ export { getByPath, getValue } from "./lists/getByPath";
33
+ export { groupBy } from "./lists/groupBy";
34
+ export { default as Countries } from "./data/countries";
35
+ export type { Country } from "./data/countries";
36
+ export { default as FileUtil } from "./data/fileType";
37
+ export { Format } from "./data/format";
38
+ export { debounce } from "./helpers/debounce";
39
+ export { getLogger } from "./helpers/getLogger";
40
+ export { convertToLonLat, getLatitudeLongitude, getLocationAsText } from "./helpers/lonlat";
41
+ export type { LngLatLike } from "./helpers/lonlat";
42
+ export { compareValues } from "./matchers/compare";
43
+ export { isEmpty } from "./matchers/isEmpty";
44
+ export { isEqual } from "./matchers/isEqual";
45
+ export { isDefined, isNil, isNull, isUndefined } from "./matchers/nullChecks";
46
+ export { isArray, isBoolean, isColor, isFalse, isNumber, isObject, isString, isSvgPath, isTrue } from "./matchers/typeChecks";
47
+ export { hash, shortHash, uuid } from "./strings/hash";
48
+ export { interpolate } from "./strings/interpolate";
49
+ export { matchString } from "./strings/matchString";
50
+ export { renderTemplate } from "./strings/template";
51
+ export { iconToken, tokenize } from "./strings/tokenize";
52
+ export { mergeRefs } from "./utils/mergeRefs";
53
+ export { yup } from "./utils/yup";
21
54
  export declare const EMPTY_ARRAY: never[];
22
55
  export declare const EMPTY_OBJECT: {};
56
+ export declare const EMPTY_FC: () => () => null;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * React Fabric
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2024 Adarsh Pastakia
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ /**
26
+ * Remove duplicates from a list of objects based on a key or the entire object.
27
+ * If a key is provided, it will deduplicate based on the value of that key.
28
+ * If no key is provided, it will deduplicate based on the entire object.
29
+ * This is useful for normalizing data structures that may have nested arrays or objects.
30
+ *
31
+ * @param list
32
+ * @param key
33
+ * @typedef {T} AnyObject - A generic type representing list items.
34
+ * @returns {T[]} - A new array with duplicates removed.
35
+ */
36
+ export declare function dedupe<T extends AnyObject>(list: T[], key?: keyof T): T[];
@@ -0,0 +1,47 @@
1
+ /**
2
+ * React Fabric
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2024 Adarsh Pastakia
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ /**
26
+ * Flatten a list of objects, removing any empty objects.
27
+ * It will flatten up to 5 levels deep and filter out any empty objects.
28
+ * This is useful for normalizing data structures that may have nested arrays or objects.
29
+ *
30
+ * @param list
31
+ * @typedef {T} AnyObject - A generic type representing list items.
32
+ * @returns {T[]} - A flattened array of objects.
33
+ */
34
+ export declare function flatten<T extends AnyObject>(list: T[]): (T extends readonly (infer InnerArr)[] ? InnerArr extends readonly (infer InnerArr)[] ? InnerArr extends readonly (infer InnerArr)[] ? InnerArr extends readonly (infer InnerArr)[] ? InnerArr extends readonly (infer InnerArr)[] ? InnerArr : InnerArr : InnerArr : InnerArr : InnerArr : T)[];
35
+ /**
36
+ * Flatten a list of objects and remove duplicates based on a key or the entire object.
37
+ * If a key is provided, it will deduplicate based on the value of that key.
38
+ * If no key is provided, it will deduplicate based on the entire object.
39
+ * This is useful for normalizing data structures that may have nested arrays or objects.
40
+ * Flattening is done first, followed by deduplication.
41
+ *
42
+ * @param list
43
+ * @param key
44
+ * @typedef {T} AnyObject - A generic type representing list items.
45
+ * @returns {T[]} - A new array with duplicates removed.
46
+ */
47
+ export declare function flattenAndDedupe<T extends AnyObject>(list?: T[][], key?: keyof T): T[];
@@ -0,0 +1,45 @@
1
+ /**
2
+ * React Fabric
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2024 Adarsh Pastakia
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ /**
26
+ * Get a value from an object by a given path.
27
+ * This function allows you to retrieve a value from a nested object structure using a dot-separated path.
28
+ * If the path does not exist or the object is empty, it returns a default value.
29
+ * @param {KeyValue} obj - The object from which to retrieve the value.
30
+ * @param {string} path - The dot-separated path to the value within the object.
31
+ * @param {any} defaultValue - The value to return if the path does not exist or the object is empty.
32
+ * @typedef {T} AnyObject - The type of the value to be returned.
33
+ * @returns {T} The value at the specified path, or the default value if the path does not exist.
34
+ */
35
+ export declare function getByPath<T = unknown>(obj: KeyValue, path: string, defaultValue?: any): T;
36
+ /**
37
+ * Get the first non-empty value from the provided arguments.
38
+ * This function is useful for finding a default value or fallback when multiple values are provided.
39
+ * It checks each argument in order and returns the first one that is not empty.
40
+ * If all arguments are empty, it returns `undefined`.
41
+ *
42
+ * @param {...any} args - The values to check for non-emptiness.
43
+ * @returns {any} The first non-empty value, or `undefined` if all are empty.
44
+ */
45
+ export declare function getValue<T = string>(...args: T[]): T | undefined;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * React Fabric
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2024 Adarsh Pastakia
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ /**
26
+ * Group a list of objects by a specific property.
27
+ * If the property is not present in an object, it will use the `missingKey` value as the key.
28
+ * This is useful for organizing data into categories based on a specific property.
29
+ *
30
+ * @param list
31
+ * @param prop
32
+ * @param missingKey
33
+ * @typedef {T} KeyValue - A generic type representing list items with key-value pairs.
34
+ * @returns {KeyValue<T[]>} - An object mapping keys to arrays of items.
35
+ */
36
+ export declare function groupBy<T extends KeyValue>(list: T[], prop: keyof T, missingKey?: string): KeyValue<T[]>;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * React Fabric
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2024 Adarsh Pastakia
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ /**
26
+ * Compare two values for sorting.
27
+ * This function compares two values based on the specified order (ascending or descending).
28
+ * If a key is provided, it compares the values of that key in the objects.
29
+ * It handles various data types such as strings, numbers, booleans, and objects.
30
+ * It returns a comparison function that can be used with array sorting methods.
31
+ * * The comparison is done in a case-insensitive manner for strings,
32
+ * treating special characters as their ASCII equivalents.
33
+ *
34
+ * @param {("asc" | "desc")} order - The order of comparison, either "asc" for ascending or "desc" for descending.
35
+ * @param {string} key - An optional key to compare values within objects.
36
+ * @returns {Function} A comparison function that can be used with array sorting methods.
37
+ */
38
+ export declare function compareValues(order?: "asc" | "desc", key?: string): (a: unknown, b: unknown) => 0 | 1 | -1;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * React Fabric
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2024 Adarsh Pastakia
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ /**
26
+ * Check if a value is empty.
27
+ * A value is considered empty if it is:
28
+ * - undefined
29
+ * - null
30
+ * - an empty string
31
+ * - an empty array
32
+ * - an empty object
33
+ * - an empty Map or Set
34
+ * - a boolean, number, or bigint (not empty)
35
+ * @param val - The value to check.
36
+ * @returns true if the value is empty, false otherwise.
37
+ */
38
+ export declare function isEmpty(val: AnyObject): val is undefined;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * React Fabric
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2024 Adarsh Pastakia
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ /**
26
+ * Compare two objects or values for equality.
27
+ * This function checks if two values are equal, including nested objects and arrays.
28
+ * It handles various data types such as strings, numbers, booleans, arrays, and objects.
29
+ * If both values are `null` or `undefined`, they are considered equal.
30
+ * If both values are primitive types (string, number, boolean), they are compared directly.
31
+ * If both values are arrays, they are compared element by element.
32
+ * If both values are objects, they are compared by their keys and values.
33
+ * If the values are of different types or structures, they are considered not equal.
34
+ *
35
+ * @param {unknown} obj - The first value to compare.
36
+ * @param {unknown} test - The second value to compare against the first.
37
+ * @returns {boolean} - Returns true if the values are equal, false otherwise.
38
+ */
39
+ export declare function isEqual(obj: unknown, test: unknown): boolean;