@sigx/lynx-icons-lucide 0.4.0 → 0.4.2
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/dist/components.d.ts +22 -0
- package/dist/components.js +15 -0
- package/dist/index.js +85 -53
- package/package.json +15 -7
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pinned `LucideIcon` — ergonomic shortcut around `<Icon set="lucide" name=>`.
|
|
3
|
+
* The `set` id is hard-coded to the conventional value (`'lucide'`)
|
|
4
|
+
* documented in the README; consumers using a non-default set id should
|
|
5
|
+
* fall back to the generic `<Icon>` or write their own one-line pin.
|
|
6
|
+
*
|
|
7
|
+
* Rendering still goes through `@sigx/lynx-icons`' `<Icon>`, so SVG
|
|
8
|
+
* branching, color sanitization, and theming behavior is shared with the
|
|
9
|
+
* rest of the icons pipeline. This wrapper only forwards props.
|
|
10
|
+
*/
|
|
11
|
+
import { type Define } from '@sigx/lynx';
|
|
12
|
+
import { type IconPropsExtensions } from '@sigx/lynx-icons';
|
|
13
|
+
type LucideIconProps = Define.Prop<'name', string, true> & Define.Prop<'size', number, false> & Define.Prop<'color', string, false> & Define.Prop<'class', string, false>
|
|
14
|
+
/**
|
|
15
|
+
* Inherit any theme-augmented props (e.g. daisy's `variant?: DaisyColor`).
|
|
16
|
+
* Sourced from core `IconPropsExtensions` so the pinned component's
|
|
17
|
+
* surface stays in sync without explicit forwarding.
|
|
18
|
+
*/
|
|
19
|
+
& IconPropsExtensions;
|
|
20
|
+
/** Lucide icon — pins `set="lucide"` so callers only specify the name. */
|
|
21
|
+
export declare const LucideIcon: import("@sigx/runtime-core").ComponentFactory<LucideIconProps, void, {}>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Pinned `LucideIcon` — ergonomic shortcut around `<Icon set="lucide" name=>`.
|
|
4
|
+
* The `set` id is hard-coded to the conventional value (`'lucide'`)
|
|
5
|
+
* documented in the README; consumers using a non-default set id should
|
|
6
|
+
* fall back to the generic `<Icon>` or write their own one-line pin.
|
|
7
|
+
*
|
|
8
|
+
* Rendering still goes through `@sigx/lynx-icons`' `<Icon>`, so SVG
|
|
9
|
+
* branching, color sanitization, and theming behavior is shared with the
|
|
10
|
+
* rest of the icons pipeline. This wrapper only forwards props.
|
|
11
|
+
*/
|
|
12
|
+
import { component } from '@sigx/lynx';
|
|
13
|
+
import { Icon } from '@sigx/lynx-icons';
|
|
14
|
+
/** Lucide icon — pins `set="lucide"` so callers only specify the name. */
|
|
15
|
+
export const LucideIcon = component(({ props }) => () => (_jsx(Icon, { ...props, set: "lucide" })));
|
package/dist/index.js
CHANGED
|
@@ -1,59 +1,91 @@
|
|
|
1
|
-
import { createRequire
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
3
|
+
let lucideModule;
|
|
4
|
+
function loadLucide() {
|
|
5
|
+
if (lucideModule !== undefined)
|
|
6
|
+
return lucideModule;
|
|
7
|
+
try {
|
|
8
|
+
lucideModule = require('lucide');
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
lucideModule = null;
|
|
12
|
+
}
|
|
13
|
+
return lucideModule;
|
|
12
14
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
/** Convert kebab-case → PascalCase (lucide's export naming). `a-arrow-down` → `AArrowDown`. */
|
|
16
|
+
function exportNameFor(name) {
|
|
17
|
+
return name.split('-').map((seg) => seg.charAt(0).toUpperCase() + seg.slice(1)).join('');
|
|
15
18
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Inverse of `exportNameFor`: insert `-` before every uppercase letter that
|
|
21
|
+
* isn't the first character, then lowercase. Mirrors the way `exportNameFor`
|
|
22
|
+
* builds names from kebab segments.
|
|
23
|
+
*
|
|
24
|
+
* - `User` → `user`
|
|
25
|
+
* - `ChevronRight` → `chevron-right`
|
|
26
|
+
* - `AArrowDown` → `a-arrow-down` (lucide really has names like this)
|
|
27
|
+
*/
|
|
28
|
+
function kebabFromPascal(exportName) {
|
|
29
|
+
if (exportName.length === 0)
|
|
30
|
+
return '';
|
|
31
|
+
let out = exportName.charAt(0).toLowerCase();
|
|
32
|
+
for (let i = 1; i < exportName.length; i++) {
|
|
33
|
+
const ch = exportName.charAt(i);
|
|
34
|
+
if (ch >= 'A' && ch <= 'Z') {
|
|
35
|
+
out += '-' + ch.toLowerCase();
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
out += ch;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
24
42
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
43
|
+
function escapeAttr(value) {
|
|
44
|
+
return String(value).replace(/&/g, '&').replace(/"/g, '"');
|
|
27
45
|
}
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
46
|
+
function renderElement(el) {
|
|
47
|
+
const [tag, attrs] = el;
|
|
48
|
+
const parts = [];
|
|
49
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
50
|
+
parts.push(`${k}="${escapeAttr(v)}"`);
|
|
51
|
+
}
|
|
52
|
+
return `<${tag} ${parts.join(' ')}/>`;
|
|
32
53
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
const adapter = {
|
|
55
|
+
/** Lucide is a single-style set; we still expose one entry so iteration works. */
|
|
56
|
+
styles: [''],
|
|
57
|
+
getGlyph(_style, name) {
|
|
58
|
+
const lucide = loadLucide();
|
|
59
|
+
if (!lucide)
|
|
60
|
+
return null;
|
|
61
|
+
const icon = lucide[exportNameFor(name)];
|
|
62
|
+
if (!Array.isArray(icon))
|
|
63
|
+
return null;
|
|
64
|
+
const inner = icon.map(renderElement).join('');
|
|
65
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="__COLOR__" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${inner}</svg>`;
|
|
66
|
+
return { svg };
|
|
67
|
+
},
|
|
68
|
+
/** Lucide has no font distribution. Always null → forces SVG mode. */
|
|
69
|
+
getFontPath() {
|
|
70
|
+
return null;
|
|
71
|
+
},
|
|
72
|
+
listGlyphs(_style) {
|
|
73
|
+
const lucide = loadLucide();
|
|
74
|
+
if (!lucide)
|
|
75
|
+
return [];
|
|
76
|
+
const out = [];
|
|
77
|
+
for (const [key, value] of Object.entries(lucide)) {
|
|
78
|
+
if (!Array.isArray(value))
|
|
79
|
+
continue;
|
|
80
|
+
// Lucide also exports a `createLucideIcon` helper etc. — skip
|
|
81
|
+
// anything that doesn't start with an uppercase letter (icon
|
|
82
|
+
// names are PascalCase).
|
|
83
|
+
const first = key.charAt(0);
|
|
84
|
+
if (first < 'A' || first > 'Z')
|
|
85
|
+
continue;
|
|
86
|
+
out.push(kebabFromPascal(key));
|
|
87
|
+
}
|
|
88
|
+
return out;
|
|
89
|
+
},
|
|
55
90
|
};
|
|
56
|
-
|
|
57
|
-
export { c as default };
|
|
58
|
-
|
|
59
|
-
//# sourceMappingURL=index.js.map
|
|
91
|
+
export default adapter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sigx/lynx-icons-lucide",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Lucide adapter for @sigx/lynx-icons. SVG-mode only — lucide is not distributed as a font.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
"import": "./dist/index.js",
|
|
12
12
|
"default": "./dist/index.js"
|
|
13
13
|
},
|
|
14
|
+
"./components": {
|
|
15
|
+
"types": "./dist/components.d.ts",
|
|
16
|
+
"import": "./dist/components.js",
|
|
17
|
+
"default": "./dist/components.js"
|
|
18
|
+
},
|
|
14
19
|
"./package.json": "./package.json"
|
|
15
20
|
},
|
|
16
21
|
"files": [
|
|
@@ -20,14 +25,16 @@
|
|
|
20
25
|
],
|
|
21
26
|
"peerDependencies": {
|
|
22
27
|
"lucide": "^1.0.0",
|
|
23
|
-
"@sigx/lynx
|
|
28
|
+
"@sigx/lynx": "^0.4.2",
|
|
29
|
+
"@sigx/lynx-icons": "^0.4.2"
|
|
24
30
|
},
|
|
25
31
|
"devDependencies": {
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
32
|
+
"@types/node": "^25.9.1",
|
|
33
|
+
"@typescript/native-preview": "7.0.0-dev.20260521.1",
|
|
28
34
|
"lucide": "^1.16.0",
|
|
29
35
|
"typescript": "^6.0.3",
|
|
30
|
-
"@sigx/lynx
|
|
36
|
+
"@sigx/lynx": "^0.4.2",
|
|
37
|
+
"@sigx/lynx-icons": "^0.4.2"
|
|
31
38
|
},
|
|
32
39
|
"author": "Andreas Ekdahl",
|
|
33
40
|
"license": "MIT",
|
|
@@ -51,7 +58,8 @@
|
|
|
51
58
|
"lucide"
|
|
52
59
|
],
|
|
53
60
|
"scripts": {
|
|
54
|
-
"build": "
|
|
55
|
-
"dev": "
|
|
61
|
+
"build": "node ../../scripts/clean.mjs dist && tsgo",
|
|
62
|
+
"dev": "tsgo --watch",
|
|
63
|
+
"clean": "node ../../scripts/clean.mjs dist .turbo"
|
|
56
64
|
}
|
|
57
65
|
}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport type { GlyphData, IconAdapter } from '@sigx/lynx-icons';\n\nconst require = createRequire(import.meta.url);\n\ntype LucideAttrs = Record<string, string | number>;\ntype LucideElement = [string, LucideAttrs];\ntype LucideIcon = LucideElement[];\n\nlet lucideModule: Record<string, LucideIcon> | null | undefined;\n\nfunction loadLucide(): Record<string, LucideIcon> | null {\n if (lucideModule !== undefined) return lucideModule;\n try {\n lucideModule = require('lucide') as Record<string, LucideIcon>;\n } catch {\n lucideModule = null;\n }\n return lucideModule;\n}\n\n/** Convert kebab-case → PascalCase (lucide's export naming). `a-arrow-down` → `AArrowDown`. */\nfunction exportNameFor(name: string): string {\n return name.split('-').map((seg) => seg.charAt(0).toUpperCase() + seg.slice(1)).join('');\n}\n\n/**\n * Inverse of `exportNameFor`: insert `-` before every uppercase letter that\n * isn't the first character, then lowercase. Mirrors the way `exportNameFor`\n * builds names from kebab segments.\n *\n * - `User` → `user`\n * - `ChevronRight` → `chevron-right`\n * - `AArrowDown` → `a-arrow-down` (lucide really has names like this)\n */\nfunction kebabFromPascal(exportName: string): string {\n if (exportName.length === 0) return '';\n let out = exportName.charAt(0).toLowerCase();\n for (let i = 1; i < exportName.length; i++) {\n const ch = exportName.charAt(i);\n if (ch >= 'A' && ch <= 'Z') {\n out += '-' + ch.toLowerCase();\n } else {\n out += ch;\n }\n }\n return out;\n}\n\nfunction escapeAttr(value: string | number): string {\n return String(value).replace(/&/g, '&').replace(/\"/g, '"');\n}\n\nfunction renderElement(el: LucideElement): string {\n const [tag, attrs] = el;\n const parts: string[] = [];\n for (const [k, v] of Object.entries(attrs)) {\n parts.push(`${k}=\"${escapeAttr(v)}\"`);\n }\n return `<${tag} ${parts.join(' ')}/>`;\n}\n\nconst adapter: IconAdapter = {\n /** Lucide is a single-style set; we still expose one entry so iteration works. */\n styles: [''],\n\n getGlyph(_style: string, name: string): GlyphData | null {\n const lucide = loadLucide();\n if (!lucide) return null;\n const icon = lucide[exportNameFor(name)];\n if (!Array.isArray(icon)) return null;\n const inner = icon.map(renderElement).join('');\n const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"__COLOR__\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">${inner}</svg>`;\n return { svg };\n },\n\n /** Lucide has no font distribution. Always null → forces SVG mode. */\n getFontPath(): string | null {\n return null;\n },\n\n listGlyphs(_style: string): string[] {\n const lucide = loadLucide();\n if (!lucide) return [];\n const out: string[] = [];\n for (const [key, value] of Object.entries(lucide)) {\n if (!Array.isArray(value)) continue;\n // Lucide also exports a `createLucideIcon` helper etc. — skip\n // anything that doesn't start with an uppercase letter (icon\n // names are PascalCase).\n const first = key.charAt(0);\n if (first < 'A' || first > 'Z') continue;\n out.push(kebabFromPascal(key));\n }\n return out;\n },\n};\n\nexport default adapter;\n"],"mappings":";;AAGA,IAAM,IAAU,EAAc,OAAO,KAAK,IAAI,EAM1C;AAEJ,SAAS,IAAgD;CACrD,IAAI,MAAiB,KAAA,GAAW,OAAO;CACvC,IAAI;EACA,IAAe,EAAQ,SAAS;SAC5B;EACJ,IAAe;;CAEnB,OAAO;;AAIX,SAAS,EAAc,GAAsB;CACzC,OAAO,EAAK,MAAM,IAAI,CAAC,KAAK,MAAQ,EAAI,OAAO,EAAE,CAAC,aAAa,GAAG,EAAI,MAAM,EAAE,CAAC,CAAC,KAAK,GAAG;;AAY5F,SAAS,EAAgB,GAA4B;CACjD,IAAI,EAAW,WAAW,GAAG,OAAO;CACpC,IAAI,IAAM,EAAW,OAAO,EAAE,CAAC,aAAa;CAC5C,KAAK,IAAI,IAAI,GA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