@nice2dev/icons 1.3.15 → 1.3.16
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/CHANGELOG.md +9 -0
- package/dist/cjs/NiceDesktopIconExporter.js +688 -599
- package/dist/cjs/NiceFaviconGenerator.js +603 -417
- package/dist/cjs/NiceIconPicker.js +788 -508
- package/dist/cjs/NiceIconPreview.js +246 -188
- package/dist/cjs/NiceIconSetCreator.js +683 -552
- package/dist/cjs/NiceIconStacker.js +547 -171
- package/dist/cjs/NiceIconValue.js +27 -35
- package/dist/cjs/NtdIconBadge.js +384 -360
- package/dist/cjs/NtdIconMorph.js +419 -354
- package/dist/cjs/NtdStateMorph.js +150 -147
- package/dist/cjs/advancedIconSearch.js +373 -510
- package/dist/cjs/animationControls.js +518 -642
- package/dist/cjs/client.js +12 -15
- package/dist/cjs/createIcon.js +349 -251
- package/dist/cjs/design-tokens.js +324 -390
- package/dist/cjs/figmaExport.js +162 -257
- package/dist/cjs/figmaSync.js +234 -316
- package/dist/cjs/headless-ui.js +240 -368
- package/dist/cjs/iconAnalytics.js +337 -393
- package/dist/cjs/iconHtml.js +64 -86
- package/dist/cjs/iconMetadata.js +392 -472
- package/dist/cjs/iconParts.js +120 -90
- package/dist/cjs/iconStack.js +136 -155
- package/dist/cjs/iconStyles.js +1609 -504
- package/dist/cjs/iconValue.js +359 -430
- package/dist/cjs/icons/accessibility.js +1119 -134
- package/dist/cjs/icons/actions.js +1290 -330
- package/dist/cjs/icons/ai.js +1424 -144
- package/dist/cjs/icons/brand.js +1344 -172
- package/dist/cjs/icons/business.js +903 -193
- package/dist/cjs/icons/devtech.js +1656 -227
- package/dist/cjs/icons/ecommerce.js +802 -111
- package/dist/cjs/icons/education.js +1345 -199
- package/dist/cjs/icons/files.js +1597 -328
- package/dist/cjs/icons/fintech.js +793 -104
- package/dist/cjs/icons/food.js +1507 -153
- package/dist/cjs/icons/fun.js +786 -109
- package/dist/cjs/icons/gaming.js +916 -170
- package/dist/cjs/icons/health.js +623 -112
- package/dist/cjs/icons/index.js +32 -35
- package/dist/cjs/icons/input.js +282 -83
- package/dist/cjs/icons/legal.js +1065 -122
- package/dist/cjs/icons/media.js +1061 -267
- package/dist/cjs/icons/navigation.js +387 -122
- package/dist/cjs/icons/omniverk.js +747 -90
- package/dist/cjs/icons/realestate.js +1520 -193
- package/dist/cjs/icons/saas.js +867 -98
- package/dist/cjs/icons/science.js +1451 -202
- package/dist/cjs/icons/shapes.js +1316 -308
- package/dist/cjs/icons/smarthome.js +786 -90
- package/dist/cjs/icons/social.js +591 -59
- package/dist/cjs/icons/sports.js +1225 -133
- package/dist/cjs/icons/sustainability.js +1211 -139
- package/dist/cjs/icons/travel.js +1470 -148
- package/dist/cjs/icons/ui.js +1508 -315
- package/dist/cjs/icons/weather.js +1160 -173
- package/dist/cjs/index.js +566 -568
- package/dist/cjs/lottieIntegration.js +261 -266
- package/dist/cjs/nicetodev-icons.css +1 -1
- package/dist/cjs/particleEffects.js +270 -251
- package/dist/cjs/resolver.js +229 -284
- package/dist/cjs/rsc.js +175 -193
- package/dist/cjs/sharpen.js +73 -130
- package/dist/cjs/smilAnimations.js +371 -165
- package/dist/cjs/stacking.js +87 -122
- package/dist/cjs/tailwind-plugin.js +280 -320
- package/dist/cjs/types.js +46 -72
- package/dist/cjs/utilities.js +163 -324
- package/dist/cjs/variantProps.js +12 -52
- package/dist/esm/NiceDesktopIconExporter.js +671 -598
- package/dist/esm/NiceFaviconGenerator.js +583 -416
- package/dist/esm/NiceIconPicker.js +789 -507
- package/dist/esm/NiceIconPreview.js +247 -187
- package/dist/esm/NiceIconSetCreator.js +685 -551
- package/dist/esm/NiceIconStacker.js +549 -170
- package/dist/esm/NiceIconValue.js +29 -34
- package/dist/esm/NtdIconBadge.js +388 -359
- package/dist/esm/NtdIconMorph.js +423 -353
- package/dist/esm/NtdStateMorph.js +152 -146
- package/dist/esm/advancedIconSearch.js +391 -509
- package/dist/esm/animationControls.js +527 -641
- package/dist/esm/client.js +48 -10
- package/dist/esm/createIcon.js +350 -250
- package/dist/esm/design-tokens.js +334 -387
- package/dist/esm/figmaExport.js +170 -256
- package/dist/esm/figmaSync.js +237 -315
- package/dist/esm/headless-ui.js +254 -365
- package/dist/esm/iconAnalytics.js +342 -392
- package/dist/esm/iconHtml.js +67 -85
- package/dist/esm/iconMetadata.js +404 -471
- package/dist/esm/iconParts.js +125 -89
- package/dist/esm/iconStack.js +145 -154
- package/dist/esm/iconStyles.js +1620 -503
- package/dist/esm/iconValue.js +361 -429
- package/dist/esm/icons/accessibility.js +1133 -133
- package/dist/esm/icons/actions.js +1320 -329
- package/dist/esm/icons/ai.js +1441 -143
- package/dist/esm/icons/brand.js +1351 -171
- package/dist/esm/icons/business.js +931 -201
- package/dist/esm/icons/devtech.js +1687 -226
- package/dist/esm/icons/ecommerce.js +816 -110
- package/dist/esm/icons/education.js +1364 -198
- package/dist/esm/icons/files.js +1628 -327
- package/dist/esm/icons/fintech.js +807 -103
- package/dist/esm/icons/food.js +1524 -152
- package/dist/esm/icons/fun.js +801 -108
- package/dist/esm/icons/gaming.js +933 -169
- package/dist/esm/icons/health.js +636 -111
- package/dist/esm/icons/index.js +596 -32
- package/dist/esm/icons/input.js +326 -82
- package/dist/esm/icons/legal.js +1079 -121
- package/dist/esm/icons/media.js +1086 -266
- package/dist/esm/icons/navigation.js +401 -121
- package/dist/esm/icons/omniverk.js +759 -89
- package/dist/esm/icons/realestate.js +1544 -198
- package/dist/esm/icons/saas.js +880 -97
- package/dist/esm/icons/science.js +1477 -208
- package/dist/esm/icons/shapes.js +1343 -307
- package/dist/esm/icons/smarthome.js +799 -89
- package/dist/esm/icons/social.js +599 -58
- package/dist/esm/icons/sports.js +1240 -132
- package/dist/esm/icons/sustainability.js +1226 -138
- package/dist/esm/icons/travel.js +1486 -147
- package/dist/esm/icons/ui.js +1540 -314
- package/dist/esm/icons/weather.js +1181 -172
- package/dist/esm/index.js +756 -58
- package/dist/esm/lottieIntegration.js +264 -265
- package/dist/esm/nicetodev-icons.css +1 -1
- package/dist/esm/particleEffects.js +271 -250
- package/dist/esm/resolver.js +231 -283
- package/dist/esm/rsc.js +182 -192
- package/dist/esm/sharpen.js +78 -129
- package/dist/esm/smilAnimations.js +376 -164
- package/dist/esm/stacking.js +99 -121
- package/dist/esm/tailwind-plugin.js +282 -319
- package/dist/esm/types.js +50 -71
- package/dist/esm/utilities.js +177 -321
- package/dist/esm/variantProps.js +23 -52
- package/package.json +15 -22
package/dist/cjs/rsc.js
CHANGED
|
@@ -1,205 +1,187 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/* ────────────────────────────────────────────────────────────────────────────
|
|
8
|
-
RSC-COMPATIBLE ICON FACTORY
|
|
9
|
-
───────────────────────────────────────────────────────────────────────────── */
|
|
10
|
-
/**
|
|
11
|
-
* Creates a React Server Component compatible icon.
|
|
12
|
-
*
|
|
13
|
-
* Unlike the standard `createIcon`, this version:
|
|
14
|
-
* - Does NOT use React hooks (useId, useSyncExternalStore, etc.)
|
|
15
|
-
* - Does NOT support animations
|
|
16
|
-
* - Does NOT support automatic dark/light mode detection
|
|
17
|
-
* - IS fully streamable and SSR-safe
|
|
18
|
-
*
|
|
19
|
-
* @param options - Icon configuration
|
|
20
|
-
* @returns A React function component (not using forwardRef)
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```tsx
|
|
24
|
-
* export const NtdHomeRSC = createIconRSC({
|
|
25
|
-
* displayName: 'NtdHomeRSC',
|
|
26
|
-
* paths: {
|
|
27
|
-
* solid: ({ primaryColor }) => <path d="..." fill={primaryColor} />,
|
|
28
|
-
* outline: ({ primaryColor, strokeWidth }) => <path d="..." stroke={primaryColor} />,
|
|
29
|
-
* duotone: ({ primaryColor, secondaryColor }) => <path d="..." />,
|
|
30
|
-
* },
|
|
31
|
-
* });
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const sharpen = require("./sharpen.js");
|
|
5
|
+
const types = require("./types.js");
|
|
34
6
|
function createIconRSC(options) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
if (flipY) {
|
|
71
|
-
transforms.push('scaleY(-1)');
|
|
72
|
-
}
|
|
73
|
-
if (scale && scale !== 1) {
|
|
74
|
-
transforms.push(`scale(${scale})`);
|
|
75
|
-
}
|
|
76
|
-
// Build gradient defs if needed
|
|
77
|
-
let gradientDefs = null;
|
|
78
|
-
let gradientId = null;
|
|
79
|
-
if (gradient && types.GRADIENT_PRESETS[gradient]) {
|
|
80
|
-
const colors = types.GRADIENT_PRESETS[gradient];
|
|
81
|
-
// Generate a deterministic ID based on displayName and gradient
|
|
82
|
-
gradientId = `${displayName}-${gradient}-grad`;
|
|
83
|
-
const x1 = Math.round(50 - 50 * Math.cos((gradientDirection * Math.PI) / 180));
|
|
84
|
-
const y1 = Math.round(50 - 50 * Math.sin((gradientDirection * Math.PI) / 180));
|
|
85
|
-
const x2 = Math.round(50 + 50 * Math.cos((gradientDirection * Math.PI) / 180));
|
|
86
|
-
const y2 = Math.round(50 + 50 * Math.sin((gradientDirection * Math.PI) / 180));
|
|
87
|
-
gradientDefs = (jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("linearGradient", { id: gradientId, x1: `${x1}%`, y1: `${y1}%`, x2: `${x2}%`, y2: `${y2}%`, children: colors.map((color, i) => (jsxRuntime.jsx("stop", { offset: `${(i / (colors.length - 1)) * 100}%`, stopColor: color }, i))) }) }));
|
|
88
|
-
// Override primary color with gradient reference
|
|
89
|
-
renderProps.primaryColor = `url(#${gradientId})`;
|
|
90
|
-
}
|
|
91
|
-
// Final styles
|
|
92
|
-
const finalStyle = {
|
|
93
|
-
width: resolvedSize,
|
|
94
|
-
height: resolvedSize,
|
|
95
|
-
...style,
|
|
96
|
-
...(transforms.length > 0 && { transform: transforms.join(' ') }),
|
|
97
|
-
};
|
|
98
|
-
// Cutout mask ID (deterministic for SSR)
|
|
99
|
-
const cutoutMaskId = isCutout ? `${displayName}-cutout-mask` : null;
|
|
100
|
-
// Cutout shape renderer
|
|
101
|
-
const cutoutBg = isCutout
|
|
102
|
-
? (() => {
|
|
103
|
-
const fill = renderProps.primaryColor !== 'currentColor'
|
|
104
|
-
? renderProps.secondaryColor
|
|
105
|
-
: renderProps.primaryColor;
|
|
106
|
-
const mask = `url(#${cutoutMaskId})`;
|
|
107
|
-
switch (cutoutShape) {
|
|
108
|
-
case 'circle':
|
|
109
|
-
return jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "11", fill: fill, mask: mask });
|
|
110
|
-
case 'square':
|
|
111
|
-
return jsxRuntime.jsx("rect", { x: "1", y: "1", width: "22", height: "22", fill: fill, mask: mask });
|
|
112
|
-
case 'hexagon':
|
|
113
|
-
return (jsxRuntime.jsx("polygon", { points: "12,1 22.39,6.5 22.39,17.5 12,23 1.61,17.5 1.61,6.5", fill: fill, mask: mask }));
|
|
114
|
-
case 'diamond':
|
|
115
|
-
return jsxRuntime.jsx("polygon", { points: "12,1 23,12 12,23 1,12", fill: fill, mask: mask });
|
|
116
|
-
case 'shield':
|
|
117
|
-
return (jsxRuntime.jsx("path", { d: "M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5L12 1z", fill: fill, mask: mask }));
|
|
118
|
-
case 'squircle':
|
|
119
|
-
return (jsxRuntime.jsx("path", { d: "M12 1C5.5 1 1 5.5 1 8.5v7C1 18.5 5.5 23 12 23s11-4.5 11-7.5v-7C23 5.5 18.5 1 12 1z", fill: fill, mask: mask }));
|
|
120
|
-
default:
|
|
121
|
-
return jsxRuntime.jsx("rect", { x: "1", y: "1", width: "22", height: "22", rx: "4", fill: fill, mask: mask });
|
|
122
|
-
}
|
|
123
|
-
})()
|
|
124
|
-
: null;
|
|
125
|
-
// Mirrors the client renderer in createIcon.tsx: `sharp` / `rounded` /
|
|
126
|
-
// `wireframe` / `mini` all reuse `paths.solid`, so each needs its own pass
|
|
127
|
-
// to be distinguishable.
|
|
128
|
-
const rendered = isCutout
|
|
129
|
-
? cutoutBg
|
|
130
|
-
: variant === 'sharp'
|
|
131
|
-
? sharpen.sharpenTree(pathRenderer(renderProps))
|
|
132
|
-
: variant === 'rounded'
|
|
133
|
-
? sharpen.roundTree(pathRenderer(renderProps))
|
|
134
|
-
: variant === 'wireframe'
|
|
135
|
-
? sharpen.wireTree(pathRenderer(renderProps), renderProps.primaryColor)
|
|
136
|
-
: pathRenderer(renderProps);
|
|
137
|
-
const iconContent = variant === 'mini' ? (jsxRuntime.jsx("g", { transform: `translate(12 12) scale(${sharpen.MINI_SCALE}) translate(-12 -12)`, children: rendered })) : (rendered);
|
|
138
|
-
return (jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: viewBox, width: resolvedSize, height: resolvedSize, fill: "none", className: className, style: finalStyle, role: role, "aria-label": ariaLabel, "aria-hidden": ariaHidden !== null && ariaHidden !== void 0 ? ariaHidden : !ariaLabel, "data-testid": testId, children: [title && jsxRuntime.jsx("title", { children: title }), gradientDefs, isCutout && (jsxRuntime.jsx("defs", { children: jsxRuntime.jsxs("mask", { id: cutoutMaskId, children: [jsxRuntime.jsx("rect", { x: "0", y: "0", width: "24", height: "24", fill: "white" }), jsxRuntime.jsx("g", { transform: "translate(12,12) scale(0.8) translate(-12,-12)", children: paths.solid({
|
|
139
|
-
...renderProps,
|
|
140
|
-
primaryColor: 'black',
|
|
141
|
-
secondaryColor: 'black',
|
|
142
|
-
accentColor: 'white',
|
|
143
|
-
}) })] }) })), iconContent] }));
|
|
7
|
+
const { displayName, viewBox = "0 0 24 24", paths } = options;
|
|
8
|
+
function IconRSC(props) {
|
|
9
|
+
const {
|
|
10
|
+
size = "md",
|
|
11
|
+
variant = "solid",
|
|
12
|
+
cutoutShape = "rounded-square",
|
|
13
|
+
primaryColor: primaryColorProp,
|
|
14
|
+
secondaryColor: secondaryColorProp,
|
|
15
|
+
accentColor: accentColorProp,
|
|
16
|
+
secondaryOpacity = 0.35,
|
|
17
|
+
strokeWidth = 1,
|
|
18
|
+
gradient,
|
|
19
|
+
gradientDirection = 135,
|
|
20
|
+
color,
|
|
21
|
+
rotate,
|
|
22
|
+
flipX,
|
|
23
|
+
flipY,
|
|
24
|
+
scale,
|
|
25
|
+
className,
|
|
26
|
+
style,
|
|
27
|
+
"aria-label": ariaLabel,
|
|
28
|
+
"aria-hidden": ariaHidden,
|
|
29
|
+
title,
|
|
30
|
+
role = ariaLabel ? "img" : "presentation",
|
|
31
|
+
"data-testid": testId
|
|
32
|
+
} = props;
|
|
33
|
+
const resolvedSize = typeof size === "number" ? size : types.SIZE_MAP[size] || types.SIZE_MAP.md;
|
|
34
|
+
let primaryColor = primaryColorProp ?? "currentColor";
|
|
35
|
+
const secondaryColor = secondaryColorProp ?? "currentColor";
|
|
36
|
+
const accentColor = accentColorProp ?? primaryColor;
|
|
37
|
+
if (color && types.SEMANTIC_COLOR_DEFAULTS[color]) {
|
|
38
|
+
if (!primaryColorProp) {
|
|
39
|
+
primaryColor = types.SEMANTIC_COLOR_DEFAULTS[color];
|
|
40
|
+
}
|
|
144
41
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
42
|
+
const isCutout = variant === "cutout";
|
|
43
|
+
const pathRenderer = isCutout || variant === "wireframe" ? paths.solid : paths[variant] ?? paths.solid;
|
|
44
|
+
const renderProps = {
|
|
45
|
+
primaryColor,
|
|
46
|
+
secondaryColor,
|
|
47
|
+
accentColor,
|
|
48
|
+
secondaryOpacity,
|
|
49
|
+
strokeWidth
|
|
50
|
+
};
|
|
51
|
+
const transforms = [];
|
|
52
|
+
if (rotate) {
|
|
53
|
+
transforms.push(`rotate(${rotate}deg)`);
|
|
54
|
+
}
|
|
55
|
+
if (flipX) {
|
|
56
|
+
transforms.push("scaleX(-1)");
|
|
57
|
+
}
|
|
58
|
+
if (flipY) {
|
|
59
|
+
transforms.push("scaleY(-1)");
|
|
60
|
+
}
|
|
61
|
+
if (scale && scale !== 1) {
|
|
62
|
+
transforms.push(`scale(${scale})`);
|
|
163
63
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
64
|
+
let gradientDefs = null;
|
|
65
|
+
let gradientId = null;
|
|
66
|
+
if (gradient && types.GRADIENT_PRESETS[gradient]) {
|
|
67
|
+
const colors = types.GRADIENT_PRESETS[gradient];
|
|
68
|
+
gradientId = `${displayName}-${gradient}-grad`;
|
|
69
|
+
const x1 = Math.round(50 - 50 * Math.cos(gradientDirection * Math.PI / 180));
|
|
70
|
+
const y1 = Math.round(50 - 50 * Math.sin(gradientDirection * Math.PI / 180));
|
|
71
|
+
const x2 = Math.round(50 + 50 * Math.cos(gradientDirection * Math.PI / 180));
|
|
72
|
+
const y2 = Math.round(50 + 50 * Math.sin(gradientDirection * Math.PI / 180));
|
|
73
|
+
gradientDefs = /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsx("linearGradient", { id: gradientId, x1: `${x1}%`, y1: `${y1}%`, x2: `${x2}%`, y2: `${y2}%`, children: colors.map((color2, i) => /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: `${i / (colors.length - 1) * 100}%`, stopColor: color2 }, i)) }) });
|
|
74
|
+
renderProps.primaryColor = `url(#${gradientId})`;
|
|
169
75
|
}
|
|
76
|
+
const finalStyle = {
|
|
77
|
+
width: resolvedSize,
|
|
78
|
+
height: resolvedSize,
|
|
79
|
+
...style,
|
|
80
|
+
...transforms.length > 0 && { transform: transforms.join(" ") }
|
|
81
|
+
};
|
|
82
|
+
const cutoutMaskId = isCutout ? `${displayName}-cutout-mask` : null;
|
|
83
|
+
const cutoutBg = isCutout ? (() => {
|
|
84
|
+
const fill = renderProps.primaryColor !== "currentColor" ? renderProps.secondaryColor : renderProps.primaryColor;
|
|
85
|
+
const mask = `url(#${cutoutMaskId})`;
|
|
86
|
+
switch (cutoutShape) {
|
|
87
|
+
case "circle":
|
|
88
|
+
return /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "11", fill, mask });
|
|
89
|
+
case "square":
|
|
90
|
+
return /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "1", y: "1", width: "22", height: "22", fill, mask });
|
|
91
|
+
case "hexagon":
|
|
92
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
93
|
+
"polygon",
|
|
94
|
+
{
|
|
95
|
+
points: "12,1 22.39,6.5 22.39,17.5 12,23 1.61,17.5 1.61,6.5",
|
|
96
|
+
fill,
|
|
97
|
+
mask
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
case "diamond":
|
|
101
|
+
return /* @__PURE__ */ jsxRuntime.jsx("polygon", { points: "12,1 23,12 12,23 1,12", fill, mask });
|
|
102
|
+
case "shield":
|
|
103
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
104
|
+
"path",
|
|
105
|
+
{
|
|
106
|
+
d: "M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5L12 1z",
|
|
107
|
+
fill,
|
|
108
|
+
mask
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
case "squircle":
|
|
112
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
113
|
+
"path",
|
|
114
|
+
{
|
|
115
|
+
d: "M12 1C5.5 1 1 5.5 1 8.5v7C1 18.5 5.5 23 12 23s11-4.5 11-7.5v-7C23 5.5 18.5 1 12 1z",
|
|
116
|
+
fill,
|
|
117
|
+
mask
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
default:
|
|
121
|
+
return /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "1", y: "1", width: "22", height: "22", rx: "4", fill, mask });
|
|
122
|
+
}
|
|
123
|
+
})() : null;
|
|
124
|
+
const rendered = isCutout ? cutoutBg : variant === "sharp" ? sharpen.sharpenTree(pathRenderer(renderProps)) : variant === "rounded" ? sharpen.roundTree(pathRenderer(renderProps)) : variant === "wireframe" ? sharpen.wireTree(pathRenderer(renderProps), renderProps.primaryColor) : pathRenderer(renderProps);
|
|
125
|
+
const iconContent = variant === "mini" ? /* @__PURE__ */ jsxRuntime.jsx("g", { transform: `translate(12 12) scale(${sharpen.MINI_SCALE}) translate(-12 -12)`, children: rendered }) : rendered;
|
|
126
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
127
|
+
"svg",
|
|
128
|
+
{
|
|
129
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
130
|
+
viewBox,
|
|
131
|
+
width: resolvedSize,
|
|
132
|
+
height: resolvedSize,
|
|
133
|
+
fill: "none",
|
|
134
|
+
className,
|
|
135
|
+
style: finalStyle,
|
|
136
|
+
role,
|
|
137
|
+
"aria-label": ariaLabel,
|
|
138
|
+
"aria-hidden": ariaHidden ?? !ariaLabel,
|
|
139
|
+
"data-testid": testId,
|
|
140
|
+
children: [
|
|
141
|
+
title && /* @__PURE__ */ jsxRuntime.jsx("title", { children: title }),
|
|
142
|
+
gradientDefs,
|
|
143
|
+
isCutout && /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs("mask", { id: cutoutMaskId, children: [
|
|
144
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "0", y: "0", width: "24", height: "24", fill: "white" }),
|
|
145
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { transform: "translate(12,12) scale(0.8) translate(-12,-12)", children: paths.solid({
|
|
146
|
+
...renderProps,
|
|
147
|
+
primaryColor: "black",
|
|
148
|
+
secondaryColor: "black",
|
|
149
|
+
accentColor: "white"
|
|
150
|
+
}) })
|
|
151
|
+
] }) }),
|
|
152
|
+
iconContent
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
IconRSC.displayName = displayName;
|
|
158
|
+
return IconRSC;
|
|
159
|
+
}
|
|
160
|
+
function renderIconToString(Icon, props = {}) {
|
|
161
|
+
try {
|
|
162
|
+
const { renderToStaticMarkup } = require("react-dom/server");
|
|
163
|
+
const element = Icon(props);
|
|
164
|
+
return renderToStaticMarkup(element);
|
|
165
|
+
} catch {
|
|
166
|
+
const {
|
|
167
|
+
size = "md",
|
|
168
|
+
primaryColor = "currentColor",
|
|
169
|
+
variant: _variant = "solid",
|
|
170
|
+
className = ""
|
|
171
|
+
} = props;
|
|
172
|
+
const sizeValue = types.SIZE_MAP[size] ?? (typeof size === "number" ? size : 24);
|
|
173
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="${sizeValue}" height="${sizeValue}" class="${className}" fill="${primaryColor}"><path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5" fill="${primaryColor}"></path></svg>`;
|
|
174
|
+
}
|
|
170
175
|
}
|
|
171
|
-
/**
|
|
172
|
-
* Type guard to check if a component is an RSC-compatible icon
|
|
173
|
-
*/
|
|
174
176
|
function isRSCIcon(component) {
|
|
175
|
-
|
|
176
|
-
'displayName' in component &&
|
|
177
|
-
typeof component.displayName === 'string' &&
|
|
178
|
-
component.displayName.endsWith('RSC'));
|
|
177
|
+
return typeof component === "function" && "displayName" in component && typeof component.displayName === "string" && component.displayName.endsWith("RSC");
|
|
179
178
|
}
|
|
180
|
-
/* ────────────────────────────────────────────────────────────────────────────
|
|
181
|
-
RSC ICON WRAPPER
|
|
182
|
-
───────────────────────────────────────────────────────────────────────────── */
|
|
183
|
-
/**
|
|
184
|
-
* Creates an RSC version from an existing icon's path config.
|
|
185
|
-
* This allows creating RSC-compatible versions from standard icons.
|
|
186
|
-
*
|
|
187
|
-
* @example
|
|
188
|
-
* ```tsx
|
|
189
|
-
* import { NtdHome } from '@nice2dev/icons';
|
|
190
|
-
* import { wrapAsRSC } from '@nice2dev/icons/rsc';
|
|
191
|
-
*
|
|
192
|
-
* // Note: This requires access to the original path config
|
|
193
|
-
* const NtdHomeRSC = wrapAsRSC(NtdHome);
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
196
179
|
function wrapAsRSC(originalPaths, displayName) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
180
|
+
return createIconRSC({
|
|
181
|
+
displayName: `${displayName}RSC`,
|
|
182
|
+
paths: originalPaths
|
|
183
|
+
});
|
|
201
184
|
}
|
|
202
|
-
|
|
203
185
|
exports.GRADIENT_PRESETS = types.GRADIENT_PRESETS;
|
|
204
186
|
exports.SEMANTIC_COLOR_DEFAULTS = types.SEMANTIC_COLOR_DEFAULTS;
|
|
205
187
|
exports.SIZE_MAP = types.SIZE_MAP;
|
package/dist/cjs/sharpen.js
CHANGED
|
@@ -1,145 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Tags whose `rx`/`ry` express a *corner rounding* rather than the shape
|
|
7
|
-
* itself. `circle` / `ellipse` are deliberately absent — a circle has to stay
|
|
8
|
-
* a circle in every variant.
|
|
9
|
-
*/
|
|
10
|
-
const ROUNDED_CORNER_TAGS = new Set(['rect']);
|
|
11
|
-
/**
|
|
12
|
-
* Scale factor of the `mini` variant, about the icon centre. Shared by the
|
|
13
|
-
* client (`createIcon`) and RSC (`rsc`) renderers so the two stay identical.
|
|
14
|
-
*
|
|
15
|
-
* Thinning the stroke — what `mini` did on its own — is invisible on a filled
|
|
16
|
-
* shape, which left `mini` indistinguishable from `solid` for most of the set.
|
|
17
|
-
*/
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const ROUNDED_CORNER_TAGS = /* @__PURE__ */ new Set(["rect"]);
|
|
18
5
|
const MINI_SCALE = 0.875;
|
|
19
|
-
/**
|
|
20
|
-
* Corner radius `rounded` gives a `<rect>`, as a fraction of its shorter side.
|
|
21
|
-
* Relative rather than absolute so it reads the same on a 16-unit detail rect
|
|
22
|
-
* and on a full-bleed 22-unit background.
|
|
23
|
-
*/
|
|
24
6
|
const ROUND_RADIUS_RATIO = 0.25;
|
|
25
|
-
/** SVG lengths arrive as numbers or numeric strings; anything else is unusable. */
|
|
26
7
|
function toNumber(value) {
|
|
27
|
-
|
|
28
|
-
|
|
8
|
+
const n = typeof value === "number" ? value : typeof value === "string" ? Number(value) : NaN;
|
|
9
|
+
return Number.isFinite(n) ? n : void 0;
|
|
29
10
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Turns a rendered `solid` tree into its `sharp` equivalent: square line caps,
|
|
32
|
-
* mitered joins and zeroed corner radii, applied recursively.
|
|
33
|
-
*
|
|
34
|
-
* The `sharp` variant has no per-icon path data — it reuses `paths.solid` — so
|
|
35
|
-
* without this pass it would be pixel-identical to `solid` for every fill-based
|
|
36
|
-
* icon. Overriding rather than defaulting matters: some icons hardcode their
|
|
37
|
-
* own `strokeLinecap` / `strokeLinejoin`, and those must not survive here.
|
|
38
|
-
*
|
|
39
|
-
* Intrinsic (string-typed) elements only — fragments are traversed but never
|
|
40
|
-
* receive SVG attributes.
|
|
41
|
-
*/
|
|
42
11
|
function sharpenTree(node) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
12
|
+
return React.Children.map(node, (child) => {
|
|
13
|
+
if (!React.isValidElement(child)) {
|
|
14
|
+
return child;
|
|
15
|
+
}
|
|
16
|
+
const el = child;
|
|
17
|
+
const next = {};
|
|
18
|
+
if (typeof el.type === "string") {
|
|
19
|
+
next.strokeLinecap = "square";
|
|
20
|
+
next.strokeLinejoin = "miter";
|
|
21
|
+
if (ROUNDED_CORNER_TAGS.has(el.type)) {
|
|
22
|
+
next.rx = 0;
|
|
23
|
+
next.ry = 0;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const { children } = el.props;
|
|
27
|
+
if (children != null) {
|
|
28
|
+
next.children = sharpenTree(children);
|
|
29
|
+
}
|
|
30
|
+
return React.cloneElement(el, next);
|
|
31
|
+
});
|
|
63
32
|
}
|
|
64
|
-
/**
|
|
65
|
-
* The mirror of {@link sharpenTree}: round line caps and joins, and `<rect>`
|
|
66
|
-
* corners rounded to {@link ROUND_RADIUS_RATIO} of the shorter side.
|
|
67
|
-
*
|
|
68
|
-
* `rounded` reuses `paths.solid` exactly like `sharp` does, so without this pass
|
|
69
|
-
* it is indistinguishable from `solid`. Same override-don't-default rule — icons
|
|
70
|
-
* that hardcode square caps have to lose them here.
|
|
71
|
-
*
|
|
72
|
-
* A rect whose `width`/`height` cannot be read keeps whatever radius it had:
|
|
73
|
-
* guessing a radius without knowing the box would deform the shape. Rectangles
|
|
74
|
-
* drawn as `<path>` are out of reach either way — the same limitation
|
|
75
|
-
* `sharpenTree` documents above.
|
|
76
|
-
*/
|
|
77
33
|
function roundTree(node) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
34
|
+
return React.Children.map(node, (child) => {
|
|
35
|
+
if (!React.isValidElement(child)) {
|
|
36
|
+
return child;
|
|
37
|
+
}
|
|
38
|
+
const el = child;
|
|
39
|
+
const next = {};
|
|
40
|
+
if (typeof el.type === "string") {
|
|
41
|
+
next.strokeLinecap = "round";
|
|
42
|
+
next.strokeLinejoin = "round";
|
|
43
|
+
if (ROUNDED_CORNER_TAGS.has(el.type)) {
|
|
44
|
+
const width = toNumber(el.props.width);
|
|
45
|
+
const height = toNumber(el.props.height);
|
|
46
|
+
if (width !== void 0 && height !== void 0) {
|
|
47
|
+
const radius = Math.max(
|
|
48
|
+
toNumber(el.props.rx) ?? 0,
|
|
49
|
+
Math.min(width, height) * ROUND_RADIUS_RATIO
|
|
50
|
+
);
|
|
51
|
+
next.rx = radius;
|
|
52
|
+
next.ry = radius;
|
|
97
53
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const { children } = el.props;
|
|
57
|
+
if (children != null) {
|
|
58
|
+
next.children = roundTree(children);
|
|
59
|
+
}
|
|
60
|
+
return React.cloneElement(el, next);
|
|
61
|
+
});
|
|
104
62
|
}
|
|
105
|
-
/**
|
|
106
|
-
* Stroke width of the `wireframe` variant — a thin, uniform construction line,
|
|
107
|
-
* deliberately independent of the caller's `strokeWidth` so a wireframe grid
|
|
108
|
-
* draws at one consistent weight.
|
|
109
|
-
*/
|
|
110
63
|
const WIREFRAME_STROKE = 1;
|
|
111
|
-
/**
|
|
112
|
-
* Turns a rendered tree into its `wireframe` equivalent: every shape becomes an
|
|
113
|
-
* unfilled thin outline in the primary colour, keeping the interior construction
|
|
114
|
-
* that `outline` drops (creases, inner discs, duotone underlays).
|
|
115
|
-
*
|
|
116
|
-
* Fed from `paths.solid`, because that layer carries the whole construction —
|
|
117
|
-
* `outline` is the silhouette only. Per-shape `opacity` is cleared as well, so a
|
|
118
|
-
* faint duotone wash does not survive as a ghost line.
|
|
119
|
-
*/
|
|
120
64
|
function wireTree(node, color) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
65
|
+
return React.Children.map(node, (child) => {
|
|
66
|
+
if (!React.isValidElement(child)) {
|
|
67
|
+
return child;
|
|
68
|
+
}
|
|
69
|
+
const el = child;
|
|
70
|
+
const next = {};
|
|
71
|
+
if (typeof el.type === "string") {
|
|
72
|
+
next.fill = "none";
|
|
73
|
+
next.stroke = color;
|
|
74
|
+
next.strokeWidth = WIREFRAME_STROKE;
|
|
75
|
+
next.strokeLinecap = "round";
|
|
76
|
+
next.strokeLinejoin = "round";
|
|
77
|
+
next.opacity = void 0;
|
|
78
|
+
}
|
|
79
|
+
const { children } = el.props;
|
|
80
|
+
if (children != null) {
|
|
81
|
+
next.children = wireTree(children, color);
|
|
82
|
+
}
|
|
83
|
+
return React.cloneElement(el, next);
|
|
84
|
+
});
|
|
141
85
|
}
|
|
142
|
-
|
|
143
86
|
exports.MINI_SCALE = MINI_SCALE;
|
|
144
87
|
exports.WIREFRAME_STROKE = WIREFRAME_STROKE;
|
|
145
88
|
exports.roundTree = roundTree;
|