UNPKG

payload-lucide-picker

Version:

A custom field for Payload CMS that allows you to select and configure Lucide icons in your admin panel

101 lines 3.53 kB
// src/index.tsx function _define_property(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _object_spread(target) { for(var i = 1; i < arguments.length; i++){ var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === "function") { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function(key) { _define_property(target, key, source[key]); }); } return target; } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function(sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } function _object_spread_props(target, source) { source = source != null ? source : {}; if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function(key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } import React from "react"; // src/fields/lucide-icon-picker.ts var LucideIconPicker = function() { var overrides = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; return { type: "json", name: overrides.name || "LucideIconPicker", label: overrides.label || "Lucide Icon Picker", defaultValue: overrides.defaultValue || { name: "", size: 24, color: "currentColor", strokeWidth: 2, absoluteStrokeWidth: false }, admin: { components: { Field: { path: "payload-lucide-picker/dist/fields/component/index#IconSelectField" } } }, required: overrides.required || false }; }; // src/index.tsx import dynamicIconImports from "lucide-react/dynamicIconImports"; import { HelpCircle } from "lucide-react"; import dynamic from "next/dynamic"; var iconCache = {}; var getLucideIcon = function(iconConfig) { var IconComponent = iconConfig.name && dynamicIconImports[iconConfig.name] ? function() { if (!iconCache[iconConfig.name]) { iconCache[iconConfig.name] = dynamic(dynamicIconImports[iconConfig.name]); } return iconCache[iconConfig.name]; }() : HelpCircle; return function IconWithProps(props) { return /* @__PURE__ */ React.createElement(IconComponent, _object_spread_props(_object_spread({}, props), { size: iconConfig.size, color: iconConfig.color, strokeWidth: iconConfig.strokeWidth, absoluteStrokeWidth: iconConfig.absoluteStrokeWidth })); }; }; export { LucideIconPicker, getLucideIcon }; //# sourceMappingURL=index.js.map