@trackunit/ui-icons 0.0.124 → 0.0.125

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/index.cjs.js CHANGED
@@ -329,6 +329,15 @@ const validateIconName = (name) => {
329
329
  const found = Object.keys(iconNames).find(i => i === name) ? true : false;
330
330
  return found;
331
331
  };
332
+ /**
333
+ * Checks if the icon name is valid.
334
+ *
335
+ * @param name - The icon name to validate.
336
+ * @returns {boolean} - Returns true if the icon name is valid, otherwise it returns false.
337
+ */
338
+ const isIconName = (name) => {
339
+ return typeof name === "string" && Object.prototype.hasOwnProperty.call(iconNames, name);
340
+ };
332
341
  /**
333
342
  * Ensures that the icon name is valid, otherwise it returns the fallback icon name.
334
343
  *
@@ -362,3 +371,4 @@ const ensureIconWithFallback = (name, fallbackIconName = FALLBACK_ICON_NAME) =>
362
371
 
363
372
  exports.ensureIconWithFallback = ensureIconWithFallback;
364
373
  exports.iconNames = iconNames;
374
+ exports.isIconName = isIconName;
package/index.esm.js CHANGED
@@ -327,6 +327,15 @@ const validateIconName = (name) => {
327
327
  const found = Object.keys(iconNames).find(i => i === name) ? true : false;
328
328
  return found;
329
329
  };
330
+ /**
331
+ * Checks if the icon name is valid.
332
+ *
333
+ * @param name - The icon name to validate.
334
+ * @returns {boolean} - Returns true if the icon name is valid, otherwise it returns false.
335
+ */
336
+ const isIconName = (name) => {
337
+ return typeof name === "string" && Object.prototype.hasOwnProperty.call(iconNames, name);
338
+ };
330
339
  /**
331
340
  * Ensures that the icon name is valid, otherwise it returns the fallback icon name.
332
341
  *
@@ -358,4 +367,4 @@ const ensureIconWithFallback = (name, fallbackIconName = FALLBACK_ICON_NAME) =>
358
367
  }
359
368
  };
360
369
 
361
- export { ensureIconWithFallback, iconNames };
370
+ export { ensureIconWithFallback, iconNames, isIconName };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/ui-icons",
3
- "version": "0.0.124",
3
+ "version": "0.0.125",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -1,4 +1,11 @@
1
1
  import { IconName } from "./icons.generated";
2
+ /**
3
+ * Checks if the icon name is valid.
4
+ *
5
+ * @param name - The icon name to validate.
6
+ * @returns {boolean} - Returns true if the icon name is valid, otherwise it returns false.
7
+ */
8
+ export declare const isIconName: (name: unknown) => name is IconName;
2
9
  /**
3
10
  * Ensures that the icon name is valid, otherwise it returns the fallback icon name.
4
11
  *
@@ -6,4 +13,4 @@ import { IconName } from "./icons.generated";
6
13
  * @param fallbackIconName - The fallback icon name to use if the icon name is invalid.
7
14
  * @returns {IconName} - Returns the icon name if it is valid, otherwise it returns the fallback icon name.
8
15
  */
9
- export declare const ensureIconWithFallback: (name: string | undefined, fallbackIconName?: IconName) => IconName;
16
+ export declare const ensureIconWithFallback: (name: IconName | string | undefined, fallbackIconName?: IconName) => IconName;