@react-fabric/utilities 1.0.0-beta.50 → 1.0.0-beta.52

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 (73) hide show
  1. package/dist/cjs/_ascii.js +7 -2
  2. package/dist/cjs/_boundingBox.js +16 -4
  3. package/dist/cjs/_countries.js +39 -21
  4. package/dist/cjs/_debounce.js +8 -2
  5. package/dist/cjs/_dedupe.js +47 -0
  6. package/dist/cjs/_fetch.js +12 -7
  7. package/dist/cjs/_fileType.js +16 -0
  8. package/dist/cjs/_format.js +19 -6
  9. package/dist/cjs/_getByPath.js +15 -4
  10. package/dist/cjs/_hash.js +12 -6
  11. package/dist/cjs/_interpolate.js +18 -2
  12. package/dist/cjs/_isEqual.js +37 -6
  13. package/dist/cjs/_isType.js +121 -0
  14. package/dist/cjs/_lonlat.js +46 -0
  15. package/dist/cjs/_mergeRefs.js +11 -0
  16. package/dist/cjs/_tokenize.js +17 -4
  17. package/dist/cjs/getImageColorset.js +15 -0
  18. package/dist/cjs/useLogger.js +9 -1
  19. package/dist/esm/_ascii.js +7 -2
  20. package/dist/esm/_boundingBox.js +16 -4
  21. package/dist/esm/_countries.js +39 -21
  22. package/dist/esm/_debounce.js +8 -2
  23. package/dist/esm/_dedupe.js +47 -0
  24. package/dist/esm/_fetch.js +12 -7
  25. package/dist/esm/_fileType.js +16 -0
  26. package/dist/esm/_format.js +19 -6
  27. package/dist/esm/_getByPath.js +15 -4
  28. package/dist/esm/_hash.js +12 -6
  29. package/dist/esm/_interpolate.js +18 -2
  30. package/dist/esm/_isEqual.js +37 -6
  31. package/dist/esm/_isType.js +121 -0
  32. package/dist/esm/_lonlat.js +46 -0
  33. package/dist/esm/_mergeRefs.js +11 -0
  34. package/dist/esm/_tokenize.js +17 -4
  35. package/dist/esm/getImageColorset.js +15 -0
  36. package/dist/esm/useLogger.js +9 -1
  37. package/dist/types/_ascii.d.ts +7 -2
  38. package/dist/types/_boundingBox.d.ts +16 -4
  39. package/dist/types/_countries.d.ts +39 -21
  40. package/dist/types/_debounce.d.ts +8 -2
  41. package/dist/types/_dedupe.d.ts +47 -4
  42. package/dist/types/_fetch.d.ts +12 -9
  43. package/dist/types/_fileType.d.ts +16 -0
  44. package/dist/types/_format.d.ts +84 -13
  45. package/dist/types/_getByPath.d.ts +15 -4
  46. package/dist/types/_hash.d.ts +12 -6
  47. package/dist/types/_interpolate.d.ts +17 -2
  48. package/dist/types/_isEqual.d.ts +37 -6
  49. package/dist/types/_isType.d.ts +110 -2
  50. package/dist/types/_lonlat.d.ts +32 -0
  51. package/dist/types/_mergeRefs.d.ts +11 -0
  52. package/dist/types/_tokenize.d.ts +16 -4
  53. package/dist/types/getImageColorset.d.ts +15 -0
  54. package/dist/types/useLogger.d.ts +9 -1
  55. package/package.json +2 -2
  56. package/src/_ascii.ts +7 -2
  57. package/src/_boundingBox.ts +16 -4
  58. package/src/_countries.ts +39 -21
  59. package/src/_debounce.ts +8 -2
  60. package/src/_dedupe.ts +43 -0
  61. package/src/_fetch.ts +12 -7
  62. package/src/_fileType.ts +16 -0
  63. package/src/_format.ts +87 -18
  64. package/src/_getByPath.ts +15 -4
  65. package/src/_hash.ts +12 -6
  66. package/src/_interpolate.ts +17 -2
  67. package/src/_isEqual.ts +37 -6
  68. package/src/_isType.ts +112 -0
  69. package/src/_lonlat.ts +44 -0
  70. package/src/_mergeRefs.ts +11 -0
  71. package/src/_tokenize.ts +16 -4
  72. package/src/getImageColorset.ts +15 -0
  73. package/src/useLogger.ts +9 -1
@@ -30,10 +30,13 @@ import { isEmpty, isNil } from './_isType.js';
30
30
  */
31
31
 
32
32
 
33
+ /**
34
+ * Format utility functions for various data types.
35
+ * This namespace provides methods to format phone numbers, numbers, bytes, percentages, dates, and durations.
36
+ */
33
37
  // eslint-disable-next-line @typescript-eslint/no-namespace
34
38
  var Format;
35
39
  (function (_Format) {
36
- /** ***************** get phone number object using `libphonenumber-js` *******************/
37
40
  var getPhone = function getPhone(value, country) {
38
41
  var phone = value.match(/^[0+]/) != null ? value.replace(/^00/, "+") : "+".concat(value);
39
42
  var number = parsePhoneNumberFromString(phone, country);
@@ -45,8 +48,6 @@ var Format;
45
48
  }
46
49
  };
47
50
  };
48
-
49
- /** ***************** common number format method using `numeral` *******************/
50
51
  var numberFormat = function numberFormat(number) {
51
52
  var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "0,0[.]00a";
52
53
  if (isNil(number)) {
@@ -66,7 +67,19 @@ var Format;
66
67
  }
67
68
  };
68
69
 
69
- /** ***************** format phone number using `libphonenumber-js` *******************/
70
+ /**
71
+ * Format phone number with country flag or emoji.
72
+ * It takes a phone number string, a country code, and a boolean to indicate whether to use CSS classes for flags.
73
+ * If the phone number is empty, less than 6 characters, or does not match the regex for valid phone numbers,
74
+ * it returns the original value.
75
+ * If the phone number is valid, it formats the phone number using `libphonenumber-js` and returns it with the country flag or emoji.
76
+ * The country flag is represented as a CSS class, and the emoji is obtained from the `Countries` module.
77
+ *
78
+ * @param {string} value - The phone number to format.
79
+ * @param {string} country - The country code to use for formatting.
80
+ * @param {boolean} useCss - Whether to use CSS classes for flags.
81
+ * @returns {string} The formatted phone number with country flag or emoji.
82
+ */
70
83
  _Format.phone = function (value) {
71
84
  var _phone$country;
72
85
  var country = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "AE";
@@ -86,8 +99,8 @@ var Format;
86
99
  return numberFormat(number, "0,0[.]00%");
87
100
  };
88
101
  _Format.date = function (date) {
89
- var fmt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "d-M-y";
90
- return date ? format(new Date(date), fmt) : "";
102
+ var format$1 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "d-M-y";
103
+ return date ? format(new Date(date), format$1) : "";
91
104
  };
92
105
  _Format.duration = function (number, isFraction) {
93
106
  if (isNil(number)) {
@@ -92,8 +92,14 @@ var _get = function _get(hit, field) {
92
92
  };
93
93
 
94
94
  /**
95
- * get property value by path
96
- * @internal
95
+ * Get a value from an object by a given path.
96
+ * This function allows you to retrieve a value from a nested object structure using a dot-separated path.
97
+ * If the path does not exist or the object is empty, it returns a default value.
98
+ * @param {KeyValue} obj - The object from which to retrieve the value.
99
+ * @param {string} path - The dot-separated path to the value within the object.
100
+ * @param {any} defaultValue - The value to return if the path does not exist or the object is empty.
101
+ * @typedef {T} AnyObject - The type of the value to be returned.
102
+ * @returns {T} The value at the specified path, or the default value if the path does not exist.
97
103
  */
98
104
  var getByPath = function getByPath(obj, path) {
99
105
  var defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
@@ -109,8 +115,13 @@ var getByPath = function getByPath(obj, path) {
109
115
  };
110
116
 
111
117
  /**
112
- * get first available value in list
113
- * @internal
118
+ * Get the first non-empty value from the provided arguments.
119
+ * This function is useful for finding a default value or fallback when multiple values are provided.
120
+ * It checks each argument in order and returns the first one that is not empty.
121
+ * If all arguments are empty, it returns `undefined`.
122
+ *
123
+ * @param {...any} args - The values to check for non-emptiness.
124
+ * @returns {any} The first non-empty value, or `undefined` if all are empty.
114
125
  */
115
126
  var getValue = function getValue() {
116
127
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
package/dist/esm/_hash.js CHANGED
@@ -27,9 +27,11 @@ import { isEmpty } from './_isType.js';
27
27
 
28
28
 
29
29
  /**
30
- * calculate hash from string
30
+ * Generate a hash from a string.
31
+ * This function computes a simple hash by iterating over each character in the string,
32
+ * performing bitwise operations to produce a 32-bit integer hash.
31
33
  * @param str
32
- * @internal
34
+ * @returns {number} A 32-bit integer hash of the input string.
33
35
  */
34
36
  var hash = function hash(str) {
35
37
  var hash = 0;
@@ -45,16 +47,20 @@ var hash = function hash(str) {
45
47
  };
46
48
 
47
49
  /**
48
- * generate short hash from current time
49
- * @internal
50
+ * Generate a short hash using the current timestamp and a random number.
51
+ * This function creates a unique identifier by combining the current time in milliseconds
52
+ * with a random number, and then converting it to a base-36 string.
53
+ * @returns {string} A short hash string.
50
54
  */
51
55
  var shortHash = function shortHash() {
52
56
  return (new Date().getTime() * Math.random()).toString(36);
53
57
  };
54
58
 
55
59
  /**
56
- * generate uuid using `crypto.getRandomValues`
57
- * @internal
60
+ * Generate a UUID (Universally Unique Identifier).
61
+ * This function creates a version 4 UUID by generating random numbers
62
+ * and formatting them according to the UUID standard.
63
+ * @returns {string} A UUID string in the format xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx.
58
64
  */
59
65
  var uuid = function uuid() {
60
66
  return [1e7, 1e3, 4e3, 8e3, 1e11].join("-").replace(/[018]/g, function (c) {
@@ -27,8 +27,13 @@ import { getByPath } from './_getByPath.js';
27
27
 
28
28
 
29
29
  /**
30
- * interpolate string template using model
31
- * @internal
30
+ * Interpolate a string with values from a model.
31
+ * This function replaces placeholders in the format ${key} with corresponding values from the model object.
32
+ * If the value is not a string or number, it returns an empty string.
33
+ *
34
+ * @param {string} str - The string to interpolate.
35
+ * @param {KeyValue} model - The model object containing key-value pairs for interpolation.
36
+ * @returns {string} The interpolated string with placeholders replaced by values from the model.
32
37
  */
33
38
  var interpolate = function interpolate(str, model) {
34
39
  return str.replace(/\${([^{}]*)}/g, function (a, b) {
@@ -36,6 +41,17 @@ var interpolate = function interpolate(str, model) {
36
41
  return typeof r === "string" || typeof r === "number" ? "".concat(r) : "";
37
42
  });
38
43
  };
44
+
45
+ /**
46
+ * Render a template string with values from a model.
47
+ * This function replaces placeholders in the format {{key}} with corresponding values from the model object.
48
+ * If the value is not a string or number, it returns an empty string.
49
+ * This is similar to the interpolate function but for handlebar templates.
50
+ *
51
+ * @param {string} str - The template string to render.
52
+ * @param {KeyValue} model - The model object containing key-value pairs for rendering the template.
53
+ * @returns {string} The rendered template string with placeholders replaced by values from the model.
54
+ */
39
55
  var renderTemplate = function renderTemplate(str, model) {
40
56
  return str.replace(/{{([^{}]*)}}/g, function (a, b) {
41
57
  var r = getByPath(model, b);
@@ -28,8 +28,18 @@ import { isNil, isString, isNumber, isBoolean, isObject } from './_isType.js';
28
28
 
29
29
 
30
30
  /**
31
- * check equality of objects
32
- * @internal
31
+ * Compare two objects or values for equality.
32
+ * This function checks if two values are equal, including nested objects and arrays.
33
+ * It handles various data types such as strings, numbers, booleans, arrays, and objects.
34
+ * If both values are `null` or `undefined`, they are considered equal.
35
+ * If both values are primitive types (string, number, boolean), they are compared directly.
36
+ * If both values are arrays, they are compared element by element.
37
+ * If both values are objects, they are compared by their keys and values.
38
+ * If the values are of different types or structures, they are considered not equal.
39
+ *
40
+ * @param {unknown} obj - The first value to compare.
41
+ * @param {unknown} test - The second value to compare against the first.
42
+ * @returns {boolean} - Returns true if the values are equal, false otherwise.
33
43
  */
34
44
  var isEqual = function isEqual(obj, test) {
35
45
  if (isNil(obj) && isNil(test)) {
@@ -68,8 +78,20 @@ var isEqual = function isEqual(obj, test) {
68
78
  };
69
79
 
70
80
  /**
71
- * match strings
72
- * @internal
81
+ * Match a string against another string with options for equality.
82
+ * This function checks if the base string starts with, includes, or is equal to the match string,
83
+ * based on the specified equality condition.
84
+ * It normalizes both strings to lowercase and ASCII format before comparison.
85
+ * This is useful for case-insensitive and ASCII-only comparisons,
86
+ * such as when filtering or searching through text data.
87
+ *
88
+ * @param {string} base - The base string to match against.
89
+ * @param {string} match - The string to match with the base string.
90
+ * @param {("start" | boolean)} equality - The type of match to perform:
91
+ * - "start": checks if the base string starts with the match string.
92
+ * - true: checks for exact equality.
93
+ * - false (default): checks if the base string includes the match string.
94
+ * @returns {boolean} - Returns true if the base string matches the conditions specified by the match string and equality.
73
95
  */
74
96
  var matchString = function matchString(base, match) {
75
97
  var equality = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
@@ -79,8 +101,17 @@ var matchString = function matchString(base, match) {
79
101
  };
80
102
 
81
103
  /**
82
- * compare values
83
- * @internal
104
+ * Compare two values for sorting.
105
+ * This function compares two values based on the specified order (ascending or descending).
106
+ * If a key is provided, it compares the values of that key in the objects.
107
+ * It handles various data types such as strings, numbers, booleans, and objects.
108
+ * It returns a comparison function that can be used with array sorting methods.
109
+ * * The comparison is done in a case-insensitive manner for strings,
110
+ * treating special characters as their ASCII equivalents.
111
+ *
112
+ * @param {("asc" | "desc")} order - The order of comparison, either "asc" for ascending or "desc" for descending.
113
+ * @param {string} key - An optional key to compare values within objects.
114
+ * @returns {Function} A comparison function that can be used with array sorting methods.
84
115
  */
85
116
  var compareValues = function compareValues() {
86
117
  var order = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "asc";
@@ -25,15 +25,46 @@ import _typeof from '@babel/runtime/helpers/typeof';
25
25
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
26
  */
27
27
 
28
+ /**
29
+ * Check if a value is undefined.
30
+ * @param value - The value to check.
31
+ * @returns true if the value is undefined, false otherwise.
32
+ */
28
33
  var isUndefined = function isUndefined(value) {
29
34
  return value === undefined;
30
35
  };
36
+
37
+ /**
38
+ * Check if a value is null.
39
+ * @param value - The value to check.
40
+ * @returns true if the value is null, false otherwise.
41
+ */
31
42
  var isNull = function isNull(value) {
32
43
  return value === null;
33
44
  };
45
+
46
+ /**
47
+ * Check if a value is either null or undefined.
48
+ * @param val - The value to check.
49
+ * @returns true if the value is null or undefined, false otherwise.
50
+ */
34
51
  var isNil = function isNil(val) {
35
52
  return val === undefined || val === null;
36
53
  };
54
+
55
+ /**
56
+ * Check if a value is empty.
57
+ * A value is considered empty if it is:
58
+ * - undefined
59
+ * - null
60
+ * - an empty string
61
+ * - an empty array
62
+ * - an empty object
63
+ * - an empty Map or Set
64
+ * - a boolean, number, or bigint (not empty)
65
+ * @param val - The value to check.
66
+ * @returns true if the value is empty, false otherwise.
67
+ */
37
68
  var isEmpty = function isEmpty(val) {
38
69
  if (val instanceof Date) return false;
39
70
  if (isNil(val) || val === "") {
@@ -48,36 +79,126 @@ var isEmpty = function isEmpty(val) {
48
79
  }
49
80
  return !!val && _typeof(val) === "object" && Object.entries(val).length === 0;
50
81
  };
82
+
83
+ /**
84
+ * Check if a value is an object.
85
+ * An object is considered valid if it is:
86
+ * - not null or undefined
87
+ * - not a Date instance
88
+ * - of type 'object'
89
+ * - not an array
90
+ * @param val - The value to check.
91
+ * @returns true if the value is an object, false otherwise.
92
+ */
51
93
  var isObject = function isObject(val) {
52
94
  return !isNil(val) && !(val instanceof Date) && _typeof(val) === "object" && !Array.isArray(val);
53
95
  };
96
+
97
+ /**
98
+ * Check if a value is an array.
99
+ * An array is considered valid if it is:
100
+ * - not null or undefined
101
+ * - an instance of Array
102
+ * @param val - The value to check.
103
+ * @returns true if the value is an array, false otherwise.
104
+ */
54
105
  var isArray = function isArray(val) {
55
106
  return Array.isArray(val);
56
107
  };
108
+
109
+ /**
110
+ * Check if a value is a string.
111
+ * A string is considered valid if it is:
112
+ * - not null or undefined
113
+ * - of type 'string'
114
+ * @param value - The value to check.
115
+ * @returns true if the value is a string, false otherwise.
116
+ */
57
117
  var isString = function isString(value) {
58
118
  return typeof value === "string";
59
119
  };
120
+
121
+ /**
122
+ * Check if a value is a number.
123
+ * A number is considered valid if it is:
124
+ * - not null or undefined
125
+ * - of type 'number'
126
+ * @param value - The value to check.
127
+ * @returns true if the value is a number, false otherwise.
128
+ */
60
129
  var isNumber = function isNumber(value) {
61
130
  return typeof value === "number";
62
131
  };
132
+
133
+ /**
134
+ * Check if a value is a boolean.
135
+ * A boolean is considered valid if it is:
136
+ * - not null or undefined
137
+ * - of type 'boolean'
138
+ */
63
139
  var isBoolean = function isBoolean(value) {
64
140
  return typeof value === "boolean";
65
141
  };
142
+
143
+ /**
144
+ * Check if a value is a true.
145
+ * A value is considered true if it is:
146
+ * - strictly equal to true
147
+ * - equal to 1
148
+ * - a string that is "yes" or "true" (case insensitive)
149
+ */
66
150
  var isTrue = function isTrue() {
67
151
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
68
152
  return value === true || value === 1 || (value === null || value === void 0 ? void 0 : value.toString().toLowerCase()) === "yes" || (value === null || value === void 0 ? void 0 : value.toString().toLowerCase()) === "true";
69
153
  };
154
+
155
+ /**
156
+ * Check if a value is false.
157
+ * A value is considered false if it is:
158
+ * - strictly equal to false
159
+ * - equal to 0
160
+ * - a string that is "no" or "false" (case insensitive)
161
+ */
70
162
  var isFalse = function isFalse() {
71
163
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
72
164
  return value === false || value === 0 || (value === null || value === void 0 ? void 0 : value.toString().toLowerCase()) === "no" || (value === null || value === void 0 ? void 0 : value.toString().toLowerCase()) === "false";
73
165
  };
166
+
167
+ /**
168
+ * Check if a value is a valid color.
169
+ * A color is considered valid if it:
170
+ * - starts with a '#' (hex color)
171
+ * - starts with 'rgb' (RGB color)
172
+ * - starts with 'hsl' (HSL color)
173
+ * - starts with 'lab' (Lab color)
174
+ * - is equal to 'transparent'
175
+ * @param color - The value to check.
176
+ * @returns true if the value is a valid color, false otherwise.
177
+ */
74
178
  var isColor = function isColor(color) {
75
179
  var _color$startsWith, _color$startsWith2, _color$startsWith3, _color$startsWith4;
76
180
  return ((_color$startsWith = color.startsWith) === null || _color$startsWith === void 0 ? void 0 : _color$startsWith.call(color, "#")) || ((_color$startsWith2 = color.startsWith) === null || _color$startsWith2 === void 0 ? void 0 : _color$startsWith2.call(color, "rgb")) || ((_color$startsWith3 = color.startsWith) === null || _color$startsWith3 === void 0 ? void 0 : _color$startsWith3.call(color, "hsl")) || ((_color$startsWith4 = color.startsWith) === null || _color$startsWith4 === void 0 ? void 0 : _color$startsWith4.call(color, "lab")) || color === "transparent";
77
181
  };
182
+
183
+ /**
184
+ * Check if a value is a valid SVG path.
185
+ * A valid SVG path is a string that:
186
+ * - starts with 'M' or 'm' (move to command)
187
+ * - contains at least one digit or decimal point
188
+ * - ends with 'Z' or 'z' (close path command)
189
+ * @param value - The value to check.
190
+ * @returns true if the value is a valid SVG path, false otherwise.
191
+ */
78
192
  var isSvgPath = function isSvgPath(value) {
79
193
  return typeof value === "string" && value.match(/^[Mm][\d.].*[\dzZ]$/) !== null;
80
194
  };
195
+
196
+ /**
197
+ * Check if the document is in RTL (Right-to-Left) mode.
198
+ * This function checks the computed style of the document's root element
199
+ * to determine if the direction is set to 'rtl'.
200
+ * @returns true if the document is in RTL mode, false otherwise.
201
+ */
81
202
  var isRtl = function isRtl() {
82
203
  return getComputedStyle(document.documentElement).direction === "rtl";
83
204
  };
@@ -3,6 +3,18 @@
3
3
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
4
  import { isArray, isObject, isString } from './_isType.js';
5
5
 
6
+ /**
7
+ * Convert various formats of longitude and latitude to a tuple of [lon, lat].
8
+ * This function supports:
9
+ * - Arrays with two or three elements (e.g., [lon, lat] or [lon, lat, alt])
10
+ * - Objects with properties `lng`, `lat`, `lon`, or `longitude` and `latitude`
11
+ * - Strings in the format "lat,lon"
12
+ * The function will return a tuple of numbers [lon, lat].
13
+ *
14
+ * @param {LngLatLike} lonLat - The input longitude and latitude in various formats.
15
+ * @returns { [lon: number, lat: number] } A tuple of [lon, lat] where lon and lat are numbers.
16
+ * @throws Error if the input is not a valid format.
17
+ */
6
18
  var convertLatLng = function convertLatLng(lonLat) {
7
19
  if (isArray(lonLat) && lonLat.length === 2 || isArray(lonLat) && lonLat.length === 3) {
8
20
  return [Number(lonLat[0]), Number(lonLat[1])];
@@ -22,6 +34,19 @@ var convertLatLng = function convertLatLng(lonLat) {
22
34
  }
23
35
  throw Error("Invalid geo coordinates");
24
36
  };
37
+
38
+ /**
39
+ * Convert a coordinate to Degrees, Minutes, Seconds (DMS) format.
40
+ * This function takes a coordinate and returns a string in the format "degrees˚minutes'seconds" with direction (N/S or E/W).
41
+ * It handles both latitude and longitude coordinates.
42
+ * This function assumes that the input coordinate is in decimal degrees format.
43
+ * It converts the coordinate to DMS format by calculating the degrees, minutes, and seconds,
44
+ * and then formatting the result as a string.
45
+ *
46
+ * @param {number} coord - The coordinate to convert.
47
+ * @param {boolean} isLat - Whether the coordinate is latitude (default is false for longitude).
48
+ * @returns {string} A string representation of the coordinate in DMS format.
49
+ */
25
50
  var convertToDMS = function convertToDMS(coord) {
26
51
  var isLat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
27
52
  var degree = Math.floor(coord);
@@ -29,6 +54,27 @@ var convertToDMS = function convertToDMS(coord) {
29
54
  var minute = (hour - Math.floor(hour)) * 60;
30
55
  return "".concat(degree, "\u02DA").concat(Math.floor(hour), "'").concat(minute.toFixed(2), "\"").concat(coord < 0 ? isLat ? "S" : "W" : isLat ? "N" : "E");
31
56
  };
57
+
58
+ /**
59
+ * Convert a latitude and longitude to a human-readable text format.
60
+ * This function takes a latitude and longitude in various formats and
61
+ * returns a string in the format "degrees˚minutes'seconds" with direction (N/S, E/W).
62
+ *
63
+ * This function supports:
64
+ *
65
+ * - Objects with properties `lng`, `lat`, `lon`, or `longitude` and `latitude`
66
+ * - Arrays with two or three elements (e.g., [lon, lat] or [lon, lat, alt])
67
+ * - Strings in the format "lat,lon"
68
+ *
69
+ * @param {LngLatLike} latlon - The latitude and longitude in various formats.
70
+ * @returns {string} A string representation of the location in DMS format.
71
+ *
72
+ * @example
73
+ * ```jsx
74
+ * const location = getLocationAsText({ lat: 40.7128, lng: -74.0060 });
75
+ * console.log(location); // "40˚42'51.36"N, 74˚0'21.60"W"
76
+ * ```
77
+ */
32
78
  var getLocationAsText = function getLocationAsText(latlon) {
33
79
  var _convertLatLng = convertLatLng(latlon),
34
80
  _convertLatLng2 = _slicedToArray(_convertLatLng, 2),
@@ -25,6 +25,17 @@
25
25
 
26
26
  /* istanbul ignore file */
27
27
 
28
+ /**
29
+ * Merge multiple refs into a single ref callback.
30
+ * This function allows you to combine multiple refs (either callback refs or React refs)
31
+ * into a single ref callback that can be used in React components.
32
+ * This is particularly useful when you want to assign a single element to multiple refs,
33
+ * such as when using third-party libraries that require refs or when you want to share refs between components.
34
+ * The function iterates over the provided refs and assigns the element to each ref.
35
+ *
36
+ * @param {AnyObject[]} refs - An array of refs to merge.
37
+ * @returns {function} A function that takes an element and assigns it to all provided refs.
38
+ */
28
39
  var mergeRefs = function mergeRefs() {
29
40
  for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
30
41
  refs[_key] = arguments[_key];
@@ -27,10 +27,14 @@ import { isEmpty, isArray } from './_isType.js';
27
27
 
28
28
 
29
29
  /**
30
- * split text into array of tokens by word boundaries
31
- * @param str
32
- * @param keywords
33
- * @internal
30
+ * Tokenize a string based on provided keywords.
31
+ * This function splits the input string into tokens, where each token is an array containing
32
+ * the substring before the keyword and the keyword itself.
33
+ * If no keywords are provided, it returns the entire string as a single token.
34
+ *
35
+ * @param {string} str - The string to tokenize.
36
+ * @param {string | string[]} keywords - A string or an array of strings to use as keywords for tokenization.
37
+ * @returns {Array<[string, string]>} An array of tokens, where each token is an array of [substring, keyword].
34
38
  */
35
39
  var tokenize = function tokenize(str, keywords) {
36
40
  if (isEmpty(keywords)) {
@@ -56,6 +60,15 @@ var tokenize = function tokenize(str, keywords) {
56
60
  tokens.push([str.substring(lastIndex), ""]);
57
61
  return tokens;
58
62
  };
63
+
64
+ /**
65
+ * Generate a token from a string.
66
+ * This function creates a token by taking the first letter of the first word and the first letter of the last word,
67
+ * or the first two letters of the first word if there is no last word.
68
+ *
69
+ * @param {string} str - The string to tokenize.
70
+ * @returns {string} A string token consisting of the first letters of the first and last words, or the first two letters of the first word.
71
+ */
59
72
  var iconToken = function iconToken(str) {
60
73
  var split = str.trim().split(" ");
61
74
  var first = split[0];
@@ -25,6 +25,21 @@
25
25
 
26
26
  /* istanbul ignore file */
27
27
 
28
+ /**
29
+ * Get the color set of an image element.
30
+ * This function analyzes the pixel data of an image to determine if it is predominantly light or dark.
31
+ * It returns "light", "dark", or "light_transparent"/"dark_transparent" based on the pixel analysis.
32
+ * It uses a canvas to draw the image and extract pixel data for analysis.
33
+ * * The function calculates the brightness of each pixel using the formula:
34
+ * brightness = 0.2126 * R + 0.7152 * G + 0.0722 * B
35
+ * * It counts the number of light and dark pixels, and determines the overall color set based on the ratio of light to dark pixels.
36
+ * * If the image has transparent pixels, it appends "_transparent" to the result.
37
+ * * This function is useful for determining the color scheme of an image, which can be helpful for UI design,
38
+ * theming, and accessibility considerations.
39
+ *
40
+ * @param {HTMLImageElement} el - The HTMLImageElement to analyze.
41
+ * @returns {string} A string indicating the color set of the image.
42
+ */
28
43
  var getImageColorset = function getImageColorset(el) {
29
44
  // create canvas
30
45
  var canvas = document.createElement("canvas");
@@ -207,7 +207,15 @@ var logger = function logger() {
207
207
  };
208
208
 
209
209
  /**
210
- * @internal
210
+ * useLogger is a custom hook that provides logging functionality.
211
+ * It allows you to log messages with different levels (log, debug, info, error, warning)
212
+ * and also provides a timer function to measure the duration of processes.
213
+ * The logs can include additional details such as the module name, process name, duration, and total time.
214
+ * It is designed to work in both Node.js and browser environments, adapting the log format accordingly.
215
+ * It uses ANSI escape codes for terminal colors in Node.js and CSS styles for console logs in the browser.
216
+ *
217
+ * @param mod - Optional module name to include in the log details.
218
+ * @returns An object with methods for logging messages and a timer function.
211
219
  */
212
220
  var useLogger = function useLogger(mod) {
213
221
  return {
@@ -1,5 +1,10 @@
1
1
  /**
2
- * latin to ascii converter for convenient searching
3
- * @internal
2
+ * Converts a string to its ASCII representation by replacing
3
+ * special characters with their ASCII equivalents.
4
+ * This function is useful for normalizing strings for search or display purposes.
5
+ * It replaces characters like "Ä" with "Ae", "ß" with "ss", etc.
6
+ *
7
+ * @param {string} str - The input string to be converted.
8
+ * @returns {string} - The ASCII representation of the input string.
4
9
  */
5
10
  export declare const ascii: (str: string) => string;
@@ -1,10 +1,22 @@
1
1
  /**
2
- * box "x,y,w,h" | [x,y,w,h]
3
- * returns canvas box [x,y,w,h]
2
+ * Get bounding box from a string or array.
3
+ * The box can be in the format "x,y,w,h" or [x,y,w,h].
4
+ * The box is adjusted to ensure that x and y are non-negative.
5
+ * The width and height are adjusted accordingly.
6
+ *
7
+ * @param box "x,y,w,h" | [x,y,w,h]
8
+ * @returns canvas box [x,y,w,h]
4
9
  */
5
10
  export declare const getBox: (box?: string | [number, number, number, number]) => [number, number, number, number];
6
11
  /**
7
- * box "x1,y1,x2,y2" | [x1,y1,x2,y2]
8
- * returns canvas box [x,y,w,h]
12
+ * Get bounding box from a string or array.
13
+ * The box can be in the format "x1,y1,x2,y2" or [x1,y1,x2,y2].
14
+ * The box is adjusted to ensure that x1 and y1 are non-negative.
15
+ * The width and height are calculated as x2 - x1 and y2 - y1 respectively.
16
+ * If x1 or y1 are negative, they are set to 0 and the width and height are adjusted accordingly.
17
+ * This is useful for ensuring that the bounding box is always within the canvas area.
18
+ *
19
+ * @param box "x1,y1,x2,y2" | [x1,y1,x2,y2]
20
+ * @returns canvas box [x,y,w,h]
9
21
  */
10
22
  export declare const getBoundingBox: (box?: string | [number, number, number, number]) => [number, number, number, number];