@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/iconParts.js
CHANGED
|
@@ -1,102 +1,132 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The colour of a detail drawn in secondary on a filled shape (a floppy's label, a ribbon): the
|
|
8
|
-
* secondary colour, but the accent colour in the cutout's mask — there secondary is cut out with
|
|
9
|
-
* the shape and the detail would vanish, while the accent draws in the cut.
|
|
10
|
-
*/
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const createIcon = require("./createIcon.js");
|
|
11
5
|
function detailColor({ variant, secondaryColor, accentColor }) {
|
|
12
|
-
|
|
6
|
+
return variant === "cutout" ? accentColor : secondaryColor;
|
|
13
7
|
}
|
|
14
|
-
/**
|
|
15
|
-
* A duotone renderer with its two colours swapped, at full strength (1.3.8) — for a duotone that
|
|
16
|
-
* drew its larger area in secondary (a pale body under a primary outline): the body turns
|
|
17
|
-
* primary, the outline and the details secondary.
|
|
18
|
-
*/
|
|
19
8
|
function swapDuotone(render) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
return (props) => render({
|
|
10
|
+
...props,
|
|
11
|
+
primaryColor: props.secondaryColor,
|
|
12
|
+
secondaryColor: props.primaryColor,
|
|
13
|
+
secondaryOpacity: 1
|
|
14
|
+
});
|
|
26
15
|
}
|
|
27
|
-
/**
|
|
28
|
-
* `content` drawn only inside `shape` — for accent lines that read as a cut through a shape (a
|
|
29
|
-
* pencil's band, a calendar's header line, an envelope's flap): clipped, they meet the shape's
|
|
30
|
-
* edges flush in every variant, where their round caps used to stick out of it (and `sharp` /
|
|
31
|
-
* `rounded` re-cap every stroke, so caps alone cannot do it).
|
|
32
|
-
*
|
|
33
|
-
* `uid` is the icon's `IconRenderProps.uid`; `name` tells the clips of one icon apart. Without a
|
|
34
|
-
* `uid` — a renderer called outside createIcon — the content is drawn as it is.
|
|
35
|
-
*/
|
|
36
16
|
function within(uid, name, shape, content) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
17
|
+
if (!uid) {
|
|
18
|
+
return content;
|
|
19
|
+
}
|
|
20
|
+
const id = `${uid}${name}`;
|
|
21
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
22
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id, children: shape }),
|
|
23
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: `url(#${id})`, children: content })
|
|
24
|
+
] });
|
|
42
25
|
}
|
|
43
|
-
const BELL =
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
/** NtdBellRing's ring marks, either side of the crown. */
|
|
48
|
-
const BELL_RINGS = 'M2 4l1.5 1.5M22 4l-1.5 1.5';
|
|
49
|
-
/**
|
|
50
|
-
* NtdBell and NtdBellRing, so the two share one bell; `ringing` adds the ring marks. Duotone and
|
|
51
|
-
* vivid are fills only: the bell primary, the clapper secondary. The marks are primary on the solid
|
|
52
|
-
* bell, secondary in duotone and in the accent colour in vivid.
|
|
53
|
-
*/
|
|
26
|
+
const BELL = "M18 8A6 6 0 006 8c0 7-3 9-3 9h18s-3-2-3-9z";
|
|
27
|
+
const BELL_CLAPPER = "M9 18.5h6a3 3 0 01-6 0z";
|
|
28
|
+
const BELL_CLAPPER_LINE = "M9 19a3 3 0 006 0";
|
|
29
|
+
const BELL_RINGS = "M2 4l1.5 1.5M22 4l-1.5 1.5";
|
|
54
30
|
function bellIcon(displayName, ringing) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
31
|
+
const parts = ({ primaryColor, strokeWidth }, detail, rings, ringsOpacity = 1) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
32
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: BELL, fill: primaryColor }),
|
|
33
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: BELL_CLAPPER, fill: detail }),
|
|
34
|
+
ringing && /* @__PURE__ */ jsxRuntime.jsx("path", { d: BELL_RINGS, stroke: rings, strokeWidth, opacity: ringsOpacity })
|
|
35
|
+
] });
|
|
36
|
+
return createIcon.createIcon({
|
|
37
|
+
displayName,
|
|
38
|
+
// stacked icons and text go into the bell's body, above the clapper (1.3.8)
|
|
39
|
+
perfectStackX: 12,
|
|
40
|
+
perfectStackY: 10.5,
|
|
41
|
+
perfectStackSize: 0.4,
|
|
42
|
+
paths: {
|
|
43
|
+
solid: (props) => parts(props, props.primaryColor, props.primaryColor),
|
|
44
|
+
outline: ({ primaryColor, strokeWidth }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
45
|
+
"path",
|
|
46
|
+
{
|
|
47
|
+
d: `${BELL}${BELL_CLAPPER_LINE}${ringing ? BELL_RINGS : ""}`,
|
|
48
|
+
stroke: primaryColor,
|
|
49
|
+
strokeWidth,
|
|
50
|
+
fill: "none"
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
duotone: (props) => parts(props, props.secondaryColor, props.secondaryColor),
|
|
54
|
+
vivid: (props) => parts(props, props.secondaryColor, props.accentColor, props.accentOpacity)
|
|
55
|
+
}
|
|
56
|
+
});
|
|
69
57
|
}
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
58
|
+
const PAPER = "M12 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V10z";
|
|
59
|
+
const PAPER_FOLD = "M12 2v6a2 2 0 002 2h6z";
|
|
60
|
+
const PAPER_FOLD_LINE = "M12 2v8h8";
|
|
61
|
+
const PAPER_SHARP = "M12 2H4v20h16V10z";
|
|
62
|
+
const PAPER_FOLD_SHARP = "M12 2v8h8z";
|
|
63
|
+
function paperIcon(displayName, text = "") {
|
|
64
|
+
return createIcon.createIcon({
|
|
65
|
+
displayName,
|
|
66
|
+
// stacked icons and text go onto the page below the fold (1.3.8), the same on every paper
|
|
67
|
+
perfectStackX: 12,
|
|
68
|
+
perfectStackY: 14,
|
|
69
|
+
perfectStackSize: 0.5,
|
|
70
|
+
paths: {
|
|
71
|
+
solid: ({ primaryColor, secondaryColor, accentColor, accentOpacity }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
72
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: PAPER, fill: primaryColor }),
|
|
73
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: PAPER_FOLD, fill: secondaryColor }),
|
|
74
|
+
text && /* @__PURE__ */ jsxRuntime.jsx(
|
|
75
|
+
"path",
|
|
76
|
+
{
|
|
77
|
+
d: text,
|
|
78
|
+
stroke: accentColor,
|
|
79
|
+
strokeOpacity: accentOpacity,
|
|
80
|
+
strokeWidth: "1.5",
|
|
81
|
+
strokeLinecap: "round",
|
|
82
|
+
fill: "none"
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
] }),
|
|
86
|
+
// square at every corner, the fold included — the derived `sharp` keeps a path's arcs round
|
|
87
|
+
sharp: ({ primaryColor, secondaryColor, accentColor, accentOpacity }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
88
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: PAPER_SHARP, fill: primaryColor }),
|
|
89
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: PAPER_FOLD_SHARP, fill: secondaryColor }),
|
|
90
|
+
text && /* @__PURE__ */ jsxRuntime.jsx(
|
|
91
|
+
"path",
|
|
92
|
+
{
|
|
93
|
+
d: text,
|
|
94
|
+
stroke: accentColor,
|
|
95
|
+
strokeOpacity: accentOpacity,
|
|
96
|
+
strokeWidth: "1.5",
|
|
97
|
+
fill: "none"
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
] }),
|
|
101
|
+
outline: ({ primaryColor, strokeWidth }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
102
|
+
"path",
|
|
103
|
+
{
|
|
104
|
+
d: `${PAPER}${PAPER_FOLD_LINE}${text}`,
|
|
105
|
+
stroke: primaryColor,
|
|
106
|
+
strokeWidth,
|
|
107
|
+
fill: "none"
|
|
108
|
+
}
|
|
109
|
+
),
|
|
110
|
+
// duotone (1.3.8): createIcon's default — the solid page, its writing in secondary like the fold
|
|
111
|
+
vivid: ({ primaryColor, secondaryColor }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
112
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: PAPER, fill: primaryColor }),
|
|
113
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: PAPER, fill: "white", opacity: "0.1" }),
|
|
114
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: PAPER_FOLD, fill: secondaryColor }),
|
|
115
|
+
text && /* @__PURE__ */ jsxRuntime.jsx(
|
|
116
|
+
"path",
|
|
117
|
+
{
|
|
118
|
+
d: text,
|
|
119
|
+
stroke: "white",
|
|
120
|
+
strokeOpacity: "0.9",
|
|
121
|
+
strokeWidth: "1.5",
|
|
122
|
+
strokeLinecap: "round",
|
|
123
|
+
fill: "none"
|
|
124
|
+
}
|
|
125
|
+
)
|
|
126
|
+
] })
|
|
127
|
+
}
|
|
128
|
+
});
|
|
98
129
|
}
|
|
99
|
-
|
|
100
130
|
exports.bellIcon = bellIcon;
|
|
101
131
|
exports.detailColor = detailColor;
|
|
102
132
|
exports.paperIcon = paperIcon;
|
package/dist/cjs/iconStack.js
CHANGED
|
@@ -1,180 +1,161 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/** A name `textBinding` can take: a JavaScript identifier. */
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const React = require("react");
|
|
7
5
|
function isValidTextBinding(name) {
|
|
8
|
-
|
|
6
|
+
return !!name && /^[A-Za-z_$][\w$]*$/.test(name);
|
|
9
7
|
}
|
|
10
|
-
/** The id of the layer `layer` sits in, `undefined` for the base. */
|
|
11
8
|
function stackParentId(layers, layer) {
|
|
12
|
-
|
|
13
|
-
return layer === layers[0] ? undefined : ((_a = layer.parent) !== null && _a !== void 0 ? _a : (_b = layers[0]) === null || _b === void 0 ? void 0 : _b.id);
|
|
9
|
+
return layer === layers[0] ? void 0 : layer.parent ?? layers[0]?.id;
|
|
14
10
|
}
|
|
15
|
-
/** The layers that sit directly in layer `id`, in order. */
|
|
16
11
|
function stackChildrenOf(layers, id) {
|
|
17
|
-
|
|
12
|
+
return layers.filter((l) => l !== layers[0] && stackParentId(layers, l) === id);
|
|
18
13
|
}
|
|
19
|
-
/** An icon's name as people read it: the export name without `Ntd` — `NtdAlertBell` → `AlertBell`. */
|
|
20
14
|
function iconDisplayName(name) {
|
|
21
|
-
|
|
15
|
+
return name.replace(/^Ntd(?=[A-Z0-9])/, "");
|
|
22
16
|
}
|
|
23
|
-
/** A short id no layer of the stack has yet: `'1'`, `'2'`… (1.3.9 — it was the icon name and a timestamp). */
|
|
24
17
|
function nextStackLayerId(layers) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
const taken = new Set(layers.map((l) => l.id));
|
|
19
|
+
let n = layers.length + 1;
|
|
20
|
+
while (taken.has(String(n))) {
|
|
21
|
+
n += 1;
|
|
22
|
+
}
|
|
23
|
+
return String(n);
|
|
31
24
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Puts an icon on the stack (1.3.9): into layer `into` (the base when absent or unknown), or as the
|
|
34
|
-
* base of an empty stack. Returns the new layers and the new layer's id.
|
|
35
|
-
*/
|
|
36
25
|
function addStackLayer(layers, icon, into) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
26
|
+
const id = nextStackLayerId(layers);
|
|
27
|
+
const parent = layers.find((l) => l.id === into);
|
|
28
|
+
const layer = {
|
|
29
|
+
id,
|
|
30
|
+
icon: icon.icon,
|
|
31
|
+
...icon.variant ? { variant: icon.variant } : {},
|
|
32
|
+
...parent && parent !== layers[0] ? { parent: parent.id } : {}
|
|
33
|
+
};
|
|
34
|
+
return { layers: [...layers, layer], id };
|
|
46
35
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Takes a layer off the stack (1.3.9; NiceIconStacker's own until then): what sat in it moves up
|
|
49
|
-
* into its parent, and a removed base hands over to its first child.
|
|
50
|
-
*/
|
|
51
36
|
function removeStackLayer(layers, id) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
.map((l) => siblings.includes(l)
|
|
81
|
-
? { ...l, parent: heir.id }
|
|
82
|
-
: l.parent === heir.id
|
|
83
|
-
? { ...l, parent: undefined }
|
|
84
|
-
: l),
|
|
85
|
-
];
|
|
37
|
+
const base = layers[0];
|
|
38
|
+
if (!base) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
if (id !== base.id) {
|
|
42
|
+
const gone = layers.find((l) => l.id === id);
|
|
43
|
+
const up = gone ? stackParentId(layers, gone) : void 0;
|
|
44
|
+
return layers.filter((l) => l.id !== id).map((l) => l.parent === id ? { ...l, parent: up === base.id ? void 0 : up } : l);
|
|
45
|
+
}
|
|
46
|
+
const [heir, ...siblings] = stackChildrenOf(layers, base.id);
|
|
47
|
+
if (!heir) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
const newBase = {
|
|
51
|
+
...heir,
|
|
52
|
+
parent: void 0,
|
|
53
|
+
align: void 0,
|
|
54
|
+
size: void 0,
|
|
55
|
+
rotation: void 0,
|
|
56
|
+
offsetX: void 0,
|
|
57
|
+
offsetY: void 0
|
|
58
|
+
};
|
|
59
|
+
return [
|
|
60
|
+
newBase,
|
|
61
|
+
...layers.filter((l) => l.id !== base.id && l.id !== heir.id).map(
|
|
62
|
+
(l) => siblings.includes(l) ? { ...l, parent: heir.id } : l.parent === heir.id ? { ...l, parent: void 0 } : l
|
|
63
|
+
)
|
|
64
|
+
];
|
|
86
65
|
}
|
|
87
|
-
const COLOR_PROPS = [
|
|
88
|
-
/** The stack as JSX: every layer wrapping the layers that sit in it, text innermost. */
|
|
66
|
+
const COLOR_PROPS = ["primaryColor", "secondaryColor", "accentColor", "textColor"];
|
|
89
67
|
function niceIconStackCode(layers) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
68
|
+
const base = layers[0];
|
|
69
|
+
if (!base) {
|
|
70
|
+
return "";
|
|
71
|
+
}
|
|
72
|
+
const bound = layers.filter((l) => isValidTextBinding(l.textBinding));
|
|
73
|
+
const write = (layer, parent, indent) => {
|
|
74
|
+
const attrs = [
|
|
75
|
+
// the parent's own spot is the default (1.3.8), so only another position is written
|
|
76
|
+
parent && layer.align && layer.align !== "perfect" ? `stackAlign="${layer.align}"` : "",
|
|
77
|
+
parent && layer.size !== void 0 ? `stackSize={${layer.size}}` : "",
|
|
78
|
+
parent && layer.rotation !== void 0 ? `stackRotation={${layer.rotation}}` : "",
|
|
79
|
+
parent && layer.offsetX ? `stackOffsetX={${layer.offsetX}}` : "",
|
|
80
|
+
parent && layer.offsetY ? `stackOffsetY={${layer.offsetY}}` : "",
|
|
81
|
+
layer.variant && layer.variant !== parent?.variant ? `variant="${layer.variant}"` : "",
|
|
82
|
+
...COLOR_PROPS.map((p) => layer[p] ? `${p}="${layer[p]}"` : ""),
|
|
83
|
+
layer.textSize !== void 0 ? `textSize={${layer.textSize}}` : ""
|
|
84
|
+
].filter(Boolean).join(" ");
|
|
85
|
+
const open = `${layer.icon}${attrs ? ` ${attrs}` : ""}`;
|
|
86
|
+
const text = isValidTextBinding(layer.textBinding) ? `{${layer.textBinding}}` : layer.text;
|
|
87
|
+
const inner = stackChildrenOf(layers, layer.id);
|
|
88
|
+
if (inner.length === 0) {
|
|
89
|
+
return text ? `${indent}<${open}>${text}</${layer.icon}>` : `${indent}<${open} />`;
|
|
93
90
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
layer.textSize !== undefined ? `textSize={${layer.textSize}}` : '',
|
|
106
|
-
]
|
|
107
|
-
.filter(Boolean)
|
|
108
|
-
.join(' ');
|
|
109
|
-
const open = `${layer.icon}${attrs ? ` ${attrs}` : ''}`;
|
|
110
|
-
const text = isValidTextBinding(layer.textBinding) ? `{${layer.textBinding}}` : layer.text;
|
|
111
|
-
const inner = stackChildrenOf(layers, layer.id);
|
|
112
|
-
if (inner.length === 0) {
|
|
113
|
-
return text ? `${indent}<${open}>${text}</${layer.icon}>` : `${indent}<${open} />`;
|
|
114
|
-
}
|
|
115
|
-
return [
|
|
116
|
-
`${indent}<${open}>`,
|
|
117
|
-
...(text ? [`${indent} ${text}`] : []),
|
|
118
|
-
...inner.map((child) => write(child, layer, `${indent} `)),
|
|
119
|
-
`${indent}</${layer.icon}>`,
|
|
120
|
-
].join('\n');
|
|
121
|
-
};
|
|
122
|
-
const notes = bound.map((l) => `// {${l.textBinding}}: bound text${l.text ? `, e.g. "${l.text}"` : ''}`);
|
|
123
|
-
return [...notes, write(base, undefined, '')].join('\n');
|
|
91
|
+
return [
|
|
92
|
+
`${indent}<${open}>`,
|
|
93
|
+
...text ? [`${indent} ${text}`] : [],
|
|
94
|
+
...inner.map((child) => write(child, layer, `${indent} `)),
|
|
95
|
+
`${indent}</${layer.icon}>`
|
|
96
|
+
].join("\n");
|
|
97
|
+
};
|
|
98
|
+
const notes = bound.map(
|
|
99
|
+
(l) => `// {${l.textBinding}}: bound text${l.text ? `, e.g. "${l.text}"` : ""}`
|
|
100
|
+
);
|
|
101
|
+
return [...notes, write(base, void 0, "")].join("\n");
|
|
124
102
|
}
|
|
125
|
-
/**
|
|
126
|
-
* The stack drawn as icons — the base wrapping the layers that sit in it, text innermost (1.3.6).
|
|
127
|
-
* One SVG, as nesting the icons by hand would give.
|
|
128
|
-
*/
|
|
129
103
|
function renderIconStack(layers, icons, { baseProps, values } = {}) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
textColor: layer.textColor,
|
|
146
|
-
textSize: layer.textSize,
|
|
147
|
-
};
|
|
148
|
-
const inner = stackChildrenOf(layers, layer.id).map((child) => draw(child, layer));
|
|
149
|
-
if (!parent) {
|
|
150
|
-
const props = { ...baseProps };
|
|
151
|
-
for (const [k, v] of Object.entries(own)) {
|
|
152
|
-
if (v !== undefined) {
|
|
153
|
-
props[k] = v;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return (React.createElement(Icon, { ...props, key: layer.id, variant: (_a = layer.variant) !== null && _a !== void 0 ? _a : baseProps === null || baseProps === void 0 ? void 0 : baseProps.variant },
|
|
157
|
-
inner,
|
|
158
|
-
text));
|
|
159
|
-
}
|
|
160
|
-
return (React.createElement(Icon, { ...own, key: layer.id, stackAlign: layer.align, stackSize: layer.size, stackRotation: layer.rotation, stackOffsetX: layer.offsetX, stackOffsetY: layer.offsetY, variant: layer.variant !== parent.variant ? layer.variant : undefined },
|
|
161
|
-
inner,
|
|
162
|
-
text));
|
|
104
|
+
const lookup = (name) => typeof icons === "function" ? icons(name) : icons[name];
|
|
105
|
+
const resolve = (name) => lookup(name) ?? lookup(`Ntd${name}`);
|
|
106
|
+
const draw = (layer, parent) => {
|
|
107
|
+
const Icon = resolve(layer.icon);
|
|
108
|
+
if (!Icon) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
const bound = isValidTextBinding(layer.textBinding) ? values?.[layer.textBinding] : void 0;
|
|
112
|
+
const text = bound ?? layer.text;
|
|
113
|
+
const own = {
|
|
114
|
+
primaryColor: layer.primaryColor,
|
|
115
|
+
secondaryColor: layer.secondaryColor,
|
|
116
|
+
accentColor: layer.accentColor,
|
|
117
|
+
textColor: layer.textColor,
|
|
118
|
+
textSize: layer.textSize
|
|
163
119
|
};
|
|
164
|
-
|
|
120
|
+
const inner = stackChildrenOf(layers, layer.id).map((child) => draw(child, layer));
|
|
121
|
+
if (!parent) {
|
|
122
|
+
const props = { ...baseProps };
|
|
123
|
+
for (const [k, v] of Object.entries(own)) {
|
|
124
|
+
if (v !== void 0) {
|
|
125
|
+
props[k] = v;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return /* @__PURE__ */ React.createElement(Icon, { ...props, key: layer.id, variant: layer.variant ?? baseProps?.variant }, inner, text);
|
|
129
|
+
}
|
|
130
|
+
return /* @__PURE__ */ React.createElement(
|
|
131
|
+
Icon,
|
|
132
|
+
{
|
|
133
|
+
...own,
|
|
134
|
+
key: layer.id,
|
|
135
|
+
stackAlign: layer.align,
|
|
136
|
+
stackSize: layer.size,
|
|
137
|
+
stackRotation: layer.rotation,
|
|
138
|
+
stackOffsetX: layer.offsetX,
|
|
139
|
+
stackOffsetY: layer.offsetY,
|
|
140
|
+
variant: layer.variant !== parent.variant ? layer.variant : void 0
|
|
141
|
+
},
|
|
142
|
+
inner,
|
|
143
|
+
text
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
return layers[0] ? draw(layers[0], void 0) : null;
|
|
165
147
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
148
|
+
function NiceIconStack({
|
|
149
|
+
layers,
|
|
150
|
+
icons,
|
|
151
|
+
values,
|
|
152
|
+
...baseProps
|
|
153
|
+
}) {
|
|
154
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderIconStack(layers, icons, { baseProps, values }) });
|
|
173
155
|
}
|
|
174
|
-
if (process.env.NODE_ENV !==
|
|
175
|
-
|
|
156
|
+
if (process.env.NODE_ENV !== "production") {
|
|
157
|
+
NiceIconStack.displayName = "NiceIconStack";
|
|
176
158
|
}
|
|
177
|
-
|
|
178
159
|
exports.NiceIconStack = NiceIconStack;
|
|
179
160
|
exports.addStackLayer = addStackLayer;
|
|
180
161
|
exports.iconDisplayName = iconDisplayName;
|