UNPKG

@lobehub/ui

Version:

Lobe UI is an open-source UI component library for building AIGC web apps

1 lines 1.79 kB
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/Tag/utils.ts"],"sourcesContent":["import { cssVar } from 'antd-style';\nimport { camelCase } from 'es-toolkit/compat';\n\nexport const presetColors = [\n 'red',\n 'volcano',\n 'orange',\n 'gold',\n 'yellow',\n 'lime',\n 'green',\n 'cyan',\n 'blue',\n 'geekblue',\n 'purple',\n 'magenta',\n 'gray',\n];\n\nexport const presetSystemColors = new Set(['error', 'warning', 'success', 'info', 'processing']);\n\nconst toKebabCase = (value: string) =>\n value\n .replaceAll(/([a-z])([A-Z])/g, '$1-$2')\n .replaceAll(/([a-z])(\\d)/g, '$1-$2')\n .replaceAll(/(\\d)([A-Z])/g, '$1-$2')\n .replaceAll(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')\n .toLowerCase();\n\nconst getCssVar = (tokenKey: string) => {\n const mapped = (cssVar as Record<string, string>)[tokenKey];\n return mapped || `var(--ant-${toKebabCase(tokenKey)})`;\n};\n\nexport const colorsPreset = (type: string, ...keys: string[]) =>\n getCssVar(camelCase([type, ...keys].join('-')));\n\nexport const colorsPresetSystem = (type: string, ...keys: string[]) => {\n const t = type === 'processing' ? 'info' : type;\n return getCssVar(camelCase(['color', t, ...keys].join('-')));\n};\n"],"mappings":";;;;AAGA,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,qBAAqB,IAAI,IAAI;CAAC;CAAS;CAAW;CAAW;CAAQ;CAAa,CAAC;AAEhG,MAAM,eAAe,UACnB,MACG,WAAW,mBAAmB,QAAQ,CACtC,WAAW,gBAAgB,QAAQ,CACnC,WAAW,gBAAgB,QAAQ,CACnC,WAAW,yBAAyB,QAAQ,CAC5C,aAAa;AAElB,MAAM,aAAa,aAAqB;AAEtC,QADgB,OAAkC,aACjC,aAAa,YAAY,SAAS,CAAC;;AAGtD,MAAa,gBAAgB,MAAc,GAAG,SAC5C,UAAU,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;AAEjD,MAAa,sBAAsB,MAAc,GAAG,SAAmB;AAErE,QAAO,UAAU,UAAU;EAAC;EADlB,SAAS,eAAe,SAAS;EACH,GAAG;EAAK,CAAC,KAAK,IAAI,CAAC,CAAC"}