UNPKG

payload-lucide-picker

Version:

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

1 lines 9.75 kB
{"version":3,"sources":["/home/runner/work/payload-lucide-picker/payload-lucide-picker/dist/index.cjs","../src/index.tsx","../src/fields/lucide-icon-picker.ts"],"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","src_exports","LucideIconPicker","getLucideIcon","module","exports","import_react","require","overrides","type","label","defaultValue","size","color","strokeWidth","absoluteStrokeWidth","admin","components","Field","path","required","import_dynamicIconImports","import_lucide_react","import_dynamic","iconCache","iconConfig","IconComponent","dynamicIconImports","dynamic","HelpCircle","IconWithProps","props","React","createElement"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAIA,WAAWC,OAAOC,MAAM;AAC5B,IAAIC,YAAYF,OAAOG,cAAc;AACrC,IAAIC,mBAAmBJ,OAAOK,wBAAwB;AACtD,IAAIC,oBAAoBN,OAAOO,mBAAmB;AAClD,IAAIC,eAAeR,OAAOS,cAAc;AACxC,IAAIC,eAAeV,OAAOW,SAAS,CAACC,cAAc;AAClD,IAAIC,WAAW,SAACC,QAAQC;IACtB,IAAK,IAAIC,QAAQD,IACfb,UAAUY,QAAQE,MAAM;QAAEC,KAAKF,GAAG,CAACC,KAAK;QAAEE,YAAY;IAAK;AAC/D;AACA,IAAIC,cAAc,SAACC,IAAIC,MAAMC,QAAQC;IACnC,IAAIF,QAAQ,CAAA,OAAOA,qCAAP,SAAOA,KAAG,MAAM,YAAY,OAAOA,SAAS,YAAY;YAC7D,kCAAA,2BAAA;;;gBAAA,IAAIG,MAAJ;gBACH,IAAI,CAACd,aAAae,IAAI,C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,UAAUZ,UAAUY,QAAA,IAAY;IAClC;AACF;AFWA,gBAAgB;AC1DhB,IAAAC,4BAA+B1B,QAAAY,QAAA,oCAAA;AAC/B,IAAAe,sBAA2Bf,QAAA;AAE3B,IAAAgB,iBAAoB5B,QAAAY,QAAA,iBAAA;AAMpB,IAAMiB,YAA8D,CAAC;AAG9D,IAAMrB,gBAAgB,SAACsB;IAC1B,IAAMC,gBAAgBD,WAAWxC,IAAA,IAAQoC,0BAAAM,OAAAA,CAAmBF,WAAWxC,IAAuC,CAAA,GAAA,AACzG;QACC,IAAI,CAACuC,SAAA,CAAUC,WAAWxC,IAAI,CAAA,EAAG;YAC/BuC,SAAA,CAAUC,WAAWxC,IAAI,CAAA,GAAA,CAAA,GAAIsC,eAAAK,OAAAA,EAAQP,0BAAAM,OAAAA,CAAmBF,WAAWxC,IAAuC,CAAC;QAC7G;QACA,OAAOuC,SAAA,CAAUC,WAAWxC,IAAI,CAAA;IAClC,MACAqC,oBAAAO,UAAA;IAEJ,OAAO,SAASC,cAAcC,KAAA;QAC5B,OACE,aAAA,GAAAzB,aAAA0B,OAAAA,CAAAC,aAAA,CAACP,eAAA,wCACKK;YACJnB,MAAMa,WAAWb,IAAA;YACjBC,OAAOY,WAAWZ,KAAA;YAClBC,aAAaW,WAAWX,WAAA;YACxBC,qBAAqBU,WAAWV,mBAAA;;IAGtC;AACF;ADkDF,6DAA6D;AAC7D,KAAMX,CAAAA,OAAOC,OAAO,GAAG;IACrBH,kBAAAA;IACAC,eAAAA;AACF,CAAA","sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/index.tsx\nvar src_exports = {};\n__export(src_exports, {\n LucideIconPicker: () => LucideIconPicker,\n getLucideIcon: () => getLucideIcon\n});\nmodule.exports = __toCommonJS(src_exports);\nvar import_react = __toESM(require(\"react\"), 1);\n\n// src/fields/lucide-icon-picker.ts\nvar LucideIconPicker = (overrides = {}) => {\n return {\n type: \"json\",\n name: overrides.name || \"LucideIconPicker\",\n label: overrides.label || \"Lucide Icon Picker\",\n defaultValue: overrides.defaultValue || {\n name: \"\",\n size: 24,\n color: \"currentColor\",\n strokeWidth: 2,\n absoluteStrokeWidth: false\n },\n admin: {\n components: {\n Field: {\n path: \"payload-lucide-picker/dist/fields/component/index#IconSelectField\"\n }\n }\n },\n required: overrides.required || false\n };\n};\n\n// src/index.tsx\nvar import_dynamicIconImports = __toESM(require(\"lucide-react/dynamicIconImports\"), 1);\nvar import_lucide_react = require(\"lucide-react\");\nvar import_dynamic = __toESM(require(\"next/dynamic\"), 1);\nvar iconCache = {};\nvar getLucideIcon = (iconConfig) => {\n const IconComponent = iconConfig.name && import_dynamicIconImports.default[iconConfig.name] ? (() => {\n if (!iconCache[iconConfig.name]) {\n iconCache[iconConfig.name] = (0, import_dynamic.default)(import_dynamicIconImports.default[iconConfig.name]);\n }\n return iconCache[iconConfig.name];\n })() : import_lucide_react.HelpCircle;\n return function IconWithProps(props) {\n return /* @__PURE__ */ import_react.default.createElement(\n IconComponent,\n {\n ...props,\n size: iconConfig.size,\n color: iconConfig.color,\n strokeWidth: iconConfig.strokeWidth,\n absoluteStrokeWidth: iconConfig.absoluteStrokeWidth\n }\n );\n };\n};\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n LucideIconPicker,\n getLucideIcon\n});\n","import React from \"react\";\n// import * as LucideIcons from \"lucide-react\";\nimport { LucideIconPicker } from \"./fields/lucide-icon-picker\";\nimport type { LucideIconPickerType } from \"./fields/lucide-icon-picker\";\nimport dynamicIconImports from \"lucide-react/dynamicIconImports\";\nimport { HelpCircle } from \"lucide-react\";\nimport type { LucideProps } from \"lucide-react\";\nimport dynamic from 'next/dynamic';\n\nexport { LucideIconPicker }\nexport type { LucideIconPickerType }\n\n// Preload and cache icons to improve performance\nconst iconCache: Record<string, React.ComponentType<LucideProps>> = {};\n\n// Updated to accept LucideIconPickerType\nexport const getLucideIcon = (iconConfig: LucideIconPickerType) => {\n const IconComponent = iconConfig.name && dynamicIconImports[iconConfig.name as keyof typeof dynamicIconImports] \n ? (() => {\n if (!iconCache[iconConfig.name]) {\n iconCache[iconConfig.name] = dynamic(dynamicIconImports[iconConfig.name as keyof typeof dynamicIconImports]);\n }\n return iconCache[iconConfig.name];\n })()\n : HelpCircle;\n \n return function IconWithProps(props: LucideProps) {\n return (\n <IconComponent \n {...props}\n size={iconConfig.size}\n color={iconConfig.color}\n strokeWidth={iconConfig.strokeWidth}\n absoluteStrokeWidth={iconConfig.absoluteStrokeWidth}\n />\n );\n };\n };\n\n\n\n\n\n","import { Field } from 'payload';\nimport dynamicIconImports from \"lucide-react/dynamicIconImports\";\n\n// Define the icon configuration type\nexport interface LucideIconPickerType {\n name: string;\n size?: number;\n color?: string;\n strokeWidth?: number;\n absoluteStrokeWidth?: boolean;\n}\n\n// Define the icon data type\nexport type LucideIconData = {\n name: string;\n size: number;\n color: string;\n strokeWidth: number;\n absoluteStrokeWidth: boolean;\n}\n\n// Define the overrides type\nexport type LucideIconPickerOverrides = Partial<{\n name: string;\n label: string;\n required: boolean;\n defaultValue: Partial<LucideIconData>;\n interfaceName: string;\n}>\n\nexport const LucideIconPicker = (overrides: LucideIconPickerOverrides = {}): Field => {\n return {\n type: 'json' as const,\n name: overrides.name || 'LucideIconPicker',\n label: overrides.label || 'Lucide Icon Picker',\n defaultValue: overrides.defaultValue || {\n name: '',\n size: 24,\n color: 'currentColor',\n strokeWidth: 2,\n absoluteStrokeWidth: false,\n },\n admin: {\n components: {\n Field: {\n path: 'payload-lucide-picker/dist/fields/component/index#IconSelectField',\n },\n },\n },\n required: overrides.required || false,\n };\n};\n\nexport default LucideIconPicker;\n"]}