CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
DynamicIcon.mjs46 linesDownload Raw Back to esm
1"use strict";2"use client";3/**4 * @license lucide-react v1.22.0 - ISC5 *6 * This source code is licensed under the ISC license.7 * See the LICENSE file in the root directory of this source tree.8 */9 10import { forwardRef, useState, useEffect, createElement } from 'react';11import dynamicIconImports from './dynamicIconImports.mjs';12import Icon from './Icon.mjs';13 14const iconNames = Object.keys(dynamicIconImports);15async function getIconNode(name) {16  if (!(name in dynamicIconImports)) {17    throw new Error("[lucide-react]: Name in Lucide DynamicIcon not found");18  }19  const icon = await dynamicIconImports[name]();20  return icon.__iconNode;21}22const DynamicIcon = forwardRef(23  ({ name, fallback: Fallback, ...props }, ref) => {24    const [iconNode, setIconNode] = useState();25    useEffect(() => {26      getIconNode(name).then(setIconNode).catch((error) => {27        console.error(error);28      });29    }, [name]);30    if (iconNode == null) {31      if (Fallback == null) {32        return null;33      }34      return createElement(Fallback);35    }36    return createElement(Icon, {37      ref,38      ...props,39      iconNode40    });41  }42);43 44export { DynamicIcon as default, iconNames };45//# sourceMappingURL=DynamicIcon.mjs.map46