@lovince/icons 1.1.2 → 1.3.0
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/README.md +38 -0
- package/dist/LvMorphIcon.vue.d.ts +28 -0
- package/dist/animated/LvMenuToClose.vue.d.ts +1 -1
- package/dist/animated/LvPlusToClose.vue.d.ts +1 -1
- package/dist/core/morph.d.ts +50 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +40 -40
- package/dist/motion-CBQXeIyE.js +166 -0
- package/dist/paths.d.ts +47 -47
- package/dist/paths.js +111 -111
- package/dist/vue.d.ts +1 -0
- package/dist/vue.js +197 -125
- package/package.json +1 -1
- package/dist/motion-72rOKpWt.js +0 -85
package/README.md
CHANGED
|
@@ -19,6 +19,7 @@ do the things a general-purpose set is not trying to do:
|
|
|
19
19
|
| | |
|
|
20
20
|
|---|---|
|
|
21
21
|
| **One geometry, three variants** | Outline, duotone and filled are the same paths at different fill strengths — so a variant change is an animatable value, not a swap |
|
|
22
|
+
| **Any icon morphs into any other** | Not curated pairs — `home` into `settings`, `search` into `spark`. Arbitrary geometry, no hand-alignment |
|
|
22
23
|
| **Transitions, not swaps** | Menu ⇄ Close, Plus ⇄ Close, and a tick that draws on. Continuity is the point |
|
|
23
24
|
| **Hit area separated from icon size** | An 18px icon still gets a 44px target. The most common icon-button mistake, invisible until someone taps it |
|
|
24
25
|
| **Journey step states** | `○ → ◉ → ✓` as one shape, for onboarding progress |
|
|
@@ -112,6 +113,43 @@ control moves as one object:
|
|
|
112
113
|
</button>
|
|
113
114
|
```
|
|
114
115
|
|
|
116
|
+
## Morphing
|
|
117
|
+
|
|
118
|
+
Libraries that morph icons do it by hand: a menu and a close are *drawn* as the
|
|
119
|
+
same three lines so CSS can rotate one into the other. That works for a handful
|
|
120
|
+
of curated pairs and not at all for the rest.
|
|
121
|
+
|
|
122
|
+
This morphs arbitrary geometry.
|
|
123
|
+
|
|
124
|
+
```vue
|
|
125
|
+
<LvMorphIcon :name="current" :size="28" />
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Change `name` and the icon transforms into the new one — any icon, any other
|
|
129
|
+
icon, with no pre-alignment.
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
import { planMorph, canMorph } from '@lovince/icons'
|
|
133
|
+
|
|
134
|
+
const plan = planMorph(paths.home, paths.settings)
|
|
135
|
+
plan?.at(0.5) // the geometry halfway between them
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**How it works.** Both icons are sampled into equal point counts using the
|
|
139
|
+
browser's own geometry engine (`getPointAtLength`), then interpolated. Using
|
|
140
|
+
the browser rather than a hand-written path parser means arcs, cubics,
|
|
141
|
+
quadratics and every shorthand come for free, and the sampling cannot drift
|
|
142
|
+
from how the path actually renders.
|
|
143
|
+
|
|
144
|
+
Sub-paths are padded on both sides, so a five-path icon can morph into a
|
|
145
|
+
two-path icon: the surplus collapses to a point instead of vanishing. Point
|
|
146
|
+
rings are rotated to their nearest alignment first, which is what stops the
|
|
147
|
+
shape visibly unwinding mid-morph.
|
|
148
|
+
|
|
149
|
+
Where no geometry engine exists — a server, an old browser, reduced motion —
|
|
150
|
+
`canMorph()` reports `false` and the component swaps instantly. The end state
|
|
151
|
+
is identical either way.
|
|
152
|
+
|
|
115
153
|
## Icon set
|
|
116
154
|
|
|
117
155
|
47 icons across five groups — `navigation`, `journey`, `status`, `onboarding`,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { IconName } from './paths';
|
|
2
|
+
import { IconFlip } from './core/props';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
/** Change this and the icon morphs into the new one. Any icon, any other icon. */
|
|
5
|
+
name: IconName;
|
|
6
|
+
size?: number | string;
|
|
7
|
+
strokeWidth?: number | string;
|
|
8
|
+
absoluteStrokeWidth?: boolean;
|
|
9
|
+
flip?: IconFlip;
|
|
10
|
+
rotate?: number | string;
|
|
11
|
+
label?: string;
|
|
12
|
+
duration?: number;
|
|
13
|
+
/** Points sampled per sub-path. Higher is smoother and slower to prepare. */
|
|
14
|
+
resolution?: number;
|
|
15
|
+
};
|
|
16
|
+
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
17
|
+
morphed: (args_0: "arrowRight" | "arrowLeft" | "arrowUp" | "arrowDown" | "chevronRight" | "chevronLeft" | "chevronUp" | "chevronDown" | "close" | "menu" | "external" | "start" | "skip" | "complete" | "target" | "spark" | "pause" | "restart" | "success" | "warning" | "info" | "error" | "welcome" | "discover" | "click" | "swipe" | "drag" | "scroll" | "tip" | "help" | "shortcut" | "newFeature" | "home" | "search" | "install" | "book" | "code" | "palette" | "shield" | "accessibility" | "sun" | "moon" | "monitor" | "plus" | "minus" | "copy" | "settings") => any;
|
|
18
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
19
|
+
onMorphed?: ((args_0: "arrowRight" | "arrowLeft" | "arrowUp" | "arrowDown" | "chevronRight" | "chevronLeft" | "chevronUp" | "chevronDown" | "close" | "menu" | "external" | "start" | "skip" | "complete" | "target" | "spark" | "pause" | "restart" | "success" | "warning" | "info" | "error" | "welcome" | "discover" | "click" | "swipe" | "drag" | "scroll" | "tip" | "help" | "shortcut" | "newFeature" | "home" | "search" | "install" | "book" | "code" | "palette" | "shield" | "accessibility" | "sun" | "moon" | "monitor" | "plus" | "minus" | "copy" | "settings") => any) | undefined;
|
|
20
|
+
}>, {
|
|
21
|
+
size: number | string;
|
|
22
|
+
strokeWidth: number | string;
|
|
23
|
+
absoluteStrokeWidth: boolean;
|
|
24
|
+
duration: number;
|
|
25
|
+
resolution: number;
|
|
26
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
27
|
+
declare const _default: typeof __VLS_export;
|
|
28
|
+
export default _default;
|
|
@@ -10,8 +10,8 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {
|
|
|
10
10
|
size: number | string;
|
|
11
11
|
strokeWidth: number | string;
|
|
12
12
|
absoluteStrokeWidth: boolean;
|
|
13
|
-
open: boolean;
|
|
14
13
|
duration: number;
|
|
14
|
+
open: boolean;
|
|
15
15
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
16
16
|
declare const _default: typeof __VLS_export;
|
|
17
17
|
export default _default;
|
|
@@ -10,8 +10,8 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {
|
|
|
10
10
|
size: number | string;
|
|
11
11
|
strokeWidth: number | string;
|
|
12
12
|
absoluteStrokeWidth: boolean;
|
|
13
|
-
open: boolean;
|
|
14
13
|
duration: number;
|
|
14
|
+
open: boolean;
|
|
15
15
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
16
16
|
declare const _default: typeof __VLS_export;
|
|
17
17
|
export default _default;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface Point {
|
|
2
|
+
readonly x: number;
|
|
3
|
+
readonly y: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Morphing between *arbitrary* icons.
|
|
7
|
+
*
|
|
8
|
+
* Icon libraries that morph do it by hand: a menu and a close are drawn as the
|
|
9
|
+
* same three lines so CSS can rotate them. That works for a handful of curated
|
|
10
|
+
* pairs and not at all for the other 2,000 combinations.
|
|
11
|
+
*
|
|
12
|
+
* This samples any two paths into equal point counts and interpolates between
|
|
13
|
+
* them, so *any* icon can become *any* other — `home` into `settings`, `search`
|
|
14
|
+
* into `spark` — with no hand-alignment.
|
|
15
|
+
*
|
|
16
|
+
* The sampling uses the browser's own geometry engine (`getPointAtLength`)
|
|
17
|
+
* rather than a hand-written path parser. That is the whole trick: arcs,
|
|
18
|
+
* cubics, quadratics and every shorthand come for free and cannot drift from
|
|
19
|
+
* how the browser actually renders them.
|
|
20
|
+
*
|
|
21
|
+
* Where that engine is unavailable — a server, an older environment — every
|
|
22
|
+
* function returns `null` and callers swap instantly instead.
|
|
23
|
+
*/
|
|
24
|
+
export declare const canMorph: () => boolean;
|
|
25
|
+
/** Samples one path into `count` points spaced evenly along its length. */
|
|
26
|
+
export declare const samplePath: (d: string, count: number) => Point[] | null;
|
|
27
|
+
/**
|
|
28
|
+
* Samples a whole icon. Sub-paths are padded to the same count on both sides so
|
|
29
|
+
* a three-path icon can morph into a one-path icon: the surplus collapses to a
|
|
30
|
+
* point rather than being dropped, which keeps the motion continuous.
|
|
31
|
+
*/
|
|
32
|
+
export declare const sampleIcon: (shapes: readonly string[], perPath: number) => Point[][] | null;
|
|
33
|
+
/**
|
|
34
|
+
* Rotates the target ring so its start point is nearest the source's. Without
|
|
35
|
+
* this the shape visibly unwinds during the morph, which reads as a glitch
|
|
36
|
+
* rather than a transformation.
|
|
37
|
+
*/
|
|
38
|
+
export declare const align: (from: readonly Point[], to: readonly Point[]) => Point[];
|
|
39
|
+
export declare const lerp: (a: number, b: number, t: number) => number;
|
|
40
|
+
export interface MorphPlan {
|
|
41
|
+
readonly from: Point[][];
|
|
42
|
+
readonly to: Point[][];
|
|
43
|
+
/** `at(0)` is the source icon, `at(1)` the target. */
|
|
44
|
+
readonly at: (progress: number) => string[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Prepares a reusable interpolation between two icons. Sampling is the
|
|
48
|
+
* expensive part, so it happens once here rather than on every frame.
|
|
49
|
+
*/
|
|
50
|
+
export declare const planMorph: (from: readonly string[], to: readonly string[], perPath?: number) => MorphPlan | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,5 +8,6 @@ export { renderIcon, createIcon, iconDataUri, type RenderOptions } from './rende
|
|
|
8
8
|
export { defineIconElement, optionsFromAttributes, resolveElementName, type LvIconElement, } from './element';
|
|
9
9
|
export { CANVAS, DEFAULT_SIZE, DEFAULT_STROKE, resolveGeometry, resolveStroke, resolveTransform, resolveFill, type IconFlip, type IconGeometry, } from './core/props';
|
|
10
10
|
export { CONTEXT, VARIANT_FILL, STATE_FILL, STATE_OPACITY, opticalStroke, resolveContext, resolveVariantFill, type ContextPreset, type IconContext, type IconState, type IconVariant, } from './core/variants';
|
|
11
|
+
export { align, canMorph, lerp, planMorph, sampleIcon, samplePath, type MorphPlan, type Point, } from './core/morph';
|
|
11
12
|
export { createTimeline, journeyChoreography, type Cue, type CueInput, type Timeline, } from './core/choreography';
|
|
12
13
|
export { DURATION, EASE, cssDuration, prefersReducedMotion, resolveDuration, } from './core/motion';
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { iconGroups as e, iconNames as t, isIconName as n, paths as r } from "./paths.js";
|
|
2
|
-
import {
|
|
2
|
+
import { C as i, S as a, T as o, _ as s, a as c, b as l, c as u, d, f, g as p, h as m, i as h, l as g, m as _, n as v, o as y, p as b, r as x, s as S, t as C, u as w, v as T, w as E, x as D, y as O } from "./motion-CBQXeIyE.js";
|
|
3
3
|
//#region src/render.ts
|
|
4
|
-
var
|
|
5
|
-
let n = i(t),
|
|
6
|
-
xmlns:
|
|
4
|
+
var k = "http://www.w3.org/2000/svg", A = (e) => e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">"), j = (e, t) => {
|
|
5
|
+
let n = i(t), o = a(t.fill), s = t.label == null || t.label.length === 0, c = {
|
|
6
|
+
xmlns: k,
|
|
7
7
|
class: t.class ?? "lv-icon",
|
|
8
8
|
width: String(n.size),
|
|
9
9
|
height: String(n.size),
|
|
@@ -14,29 +14,29 @@ var C = "http://www.w3.org/2000/svg", w = (e) => e.replace(/&/g, "&").replac
|
|
|
14
14
|
"stroke-linecap": "round",
|
|
15
15
|
"stroke-linejoin": "round"
|
|
16
16
|
};
|
|
17
|
-
return
|
|
18
|
-
attrs:
|
|
17
|
+
return s ? c["aria-hidden"] = "true" : (c.role = "img", c["aria-label"] = t.label), {
|
|
18
|
+
attrs: c,
|
|
19
19
|
shapes: r[e] ?? [],
|
|
20
20
|
transform: n.transform,
|
|
21
|
-
fill:
|
|
21
|
+
fill: o
|
|
22
22
|
};
|
|
23
|
-
},
|
|
24
|
-
let { attrs: n, shapes: r, transform: i, fill: a } =
|
|
25
|
-
return `<svg ${o}>${i === void 0 ? c : `<g transform="${
|
|
26
|
-
},
|
|
23
|
+
}, M = (e, t = {}) => {
|
|
24
|
+
let { attrs: n, shapes: r, transform: i, fill: a } = j(e, t), o = Object.entries(n).map(([e, t]) => `${e}="${A(t)}"`).join(" "), s = a > 0 ? ` fill="currentColor" fill-opacity="${a}"` : "", c = r.map((e) => `<path d="${A(e)}"${s}/>`).join("");
|
|
25
|
+
return `<svg ${o}>${i === void 0 ? c : `<g transform="${A(i)}">${c}</g>`}</svg>`;
|
|
26
|
+
}, N = (e, t = {}) => {
|
|
27
27
|
if (typeof document > "u") return null;
|
|
28
|
-
let { attrs: n, shapes: r, transform: i, fill: a } =
|
|
28
|
+
let { attrs: n, shapes: r, transform: i, fill: a } = j(e, t), o = document.createElementNS(k, "svg");
|
|
29
29
|
for (let [e, t] of Object.entries(n)) o.setAttribute(e, t);
|
|
30
30
|
let s = i === void 0 ? o : (() => {
|
|
31
|
-
let e = document.createElementNS(
|
|
31
|
+
let e = document.createElementNS(k, "g");
|
|
32
32
|
return e.setAttribute("transform", i), o.appendChild(e), e;
|
|
33
33
|
})();
|
|
34
34
|
for (let e of r) {
|
|
35
|
-
let t = document.createElementNS(
|
|
35
|
+
let t = document.createElementNS(k, "path");
|
|
36
36
|
t.setAttribute("d", e), a > 0 && (t.setAttribute("fill", "currentColor"), t.setAttribute("fill-opacity", String(a))), s.appendChild(t);
|
|
37
37
|
}
|
|
38
38
|
return o;
|
|
39
|
-
},
|
|
39
|
+
}, P = (e, t = {}) => `data:image/svg+xml,${encodeURIComponent(M(e, t))}`, F = [
|
|
40
40
|
"name",
|
|
41
41
|
"size",
|
|
42
42
|
"stroke-width",
|
|
@@ -45,30 +45,30 @@ var C = "http://www.w3.org/2000/svg", w = (e) => e.replace(/&/g, "&").replac
|
|
|
45
45
|
"rotate",
|
|
46
46
|
"flip",
|
|
47
47
|
"label"
|
|
48
|
-
],
|
|
48
|
+
], I = (e) => e.replace(/-([a-z])/g, (e, t) => t.toUpperCase()), L = (e) => {
|
|
49
49
|
if (e == null) return null;
|
|
50
|
-
let t =
|
|
50
|
+
let t = I(e.trim());
|
|
51
51
|
return n(t) ? t : null;
|
|
52
|
-
},
|
|
52
|
+
}, R = (e, t) => {
|
|
53
53
|
if (e == null) return t;
|
|
54
54
|
let n = Number.parseFloat(e);
|
|
55
55
|
return Number.isFinite(n) ? n : t;
|
|
56
|
-
},
|
|
56
|
+
}, z = (e, t) => {
|
|
57
57
|
let n = e("flip"), r = e("label");
|
|
58
58
|
return {
|
|
59
|
-
size:
|
|
60
|
-
strokeWidth:
|
|
59
|
+
size: R(e("size"), 24),
|
|
60
|
+
strokeWidth: R(e("stroke-width"), 2),
|
|
61
61
|
absoluteStrokeWidth: t("absolute-stroke-width"),
|
|
62
|
-
fill:
|
|
63
|
-
rotate:
|
|
62
|
+
fill: R(e("fill"), 0),
|
|
63
|
+
rotate: R(e("rotate"), 0),
|
|
64
64
|
...n === "horizontal" || n === "vertical" || n === "both" ? { flip: n } : {},
|
|
65
65
|
...r == null ? {} : { label: r }
|
|
66
66
|
};
|
|
67
|
-
},
|
|
67
|
+
}, B = (e = "lv-icon") => {
|
|
68
68
|
if (typeof window > "u" || typeof customElements > "u" || typeof HTMLElement > "u" || customElements.get(e) !== void 0) return;
|
|
69
69
|
class t extends HTMLElement {
|
|
70
70
|
static get observedAttributes() {
|
|
71
|
-
return
|
|
71
|
+
return F;
|
|
72
72
|
}
|
|
73
73
|
connectedCallback() {
|
|
74
74
|
this.render();
|
|
@@ -77,16 +77,16 @@ var C = "http://www.w3.org/2000/svg", w = (e) => e.replace(/&/g, "&").replac
|
|
|
77
77
|
this.isConnected && this.render();
|
|
78
78
|
}
|
|
79
79
|
render() {
|
|
80
|
-
let e =
|
|
80
|
+
let e = L(this.getAttribute("name"));
|
|
81
81
|
if (this.replaceChildren(), e === null) return;
|
|
82
|
-
let t =
|
|
82
|
+
let t = N(e, z((e) => this.getAttribute(e), (e) => this.hasAttribute(e)));
|
|
83
83
|
t !== null && this.appendChild(t);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
customElements.define(e, t);
|
|
87
|
-
},
|
|
87
|
+
}, V = (e) => e < .5 ? 4 * e * e * e : 1 - (-2 * e + 2) ** 3 / 2, H = () => {
|
|
88
88
|
let e = [], t = 0, n = 0, r = !1, i = (n) => {
|
|
89
|
-
let r = n.duration ??
|
|
89
|
+
let r = n.duration ?? C.state, i = Math.max(0, t + (n.offset ?? 0));
|
|
90
90
|
e.push({
|
|
91
91
|
name: n.name,
|
|
92
92
|
at: i,
|
|
@@ -94,23 +94,23 @@ var C = "http://www.w3.org/2000/svg", w = (e) => e.replace(/&/g, "&").replac
|
|
|
94
94
|
run: n.run,
|
|
95
95
|
...n.onComplete === void 0 ? {} : { onComplete: n.onComplete }
|
|
96
96
|
}), t = i + r;
|
|
97
|
-
},
|
|
98
|
-
add: (e) => (i(e),
|
|
99
|
-
stagger: (e, n =
|
|
97
|
+
}, a = {
|
|
98
|
+
add: (e) => (i(e), a),
|
|
99
|
+
stagger: (e, n = C.micro / 2) => {
|
|
100
100
|
let r = t;
|
|
101
101
|
return e.forEach((e, a) => {
|
|
102
102
|
t = r + a * n, i({
|
|
103
103
|
...e,
|
|
104
104
|
offset: 0
|
|
105
105
|
});
|
|
106
|
-
}), t = Math.max(t, r + (e.length - 1) * n + (e[0]?.duration ??
|
|
106
|
+
}), t = Math.max(t, r + (e.length - 1) * n + (e[0]?.duration ?? C.state)), a;
|
|
107
107
|
},
|
|
108
108
|
cues: () => [...e],
|
|
109
109
|
duration: () => e.reduce((e, t) => Math.max(e, t.at + t.duration), 0),
|
|
110
110
|
play: () => {
|
|
111
111
|
r = !1;
|
|
112
|
-
let t =
|
|
113
|
-
if (
|
|
112
|
+
let t = a.duration();
|
|
113
|
+
if (c(t) === 0 || typeof requestAnimationFrame != "function") {
|
|
114
114
|
for (let t of e) t.run(1), t.onComplete?.();
|
|
115
115
|
return Promise.resolve();
|
|
116
116
|
}
|
|
@@ -121,7 +121,7 @@ var C = "http://www.w3.org/2000/svg", w = (e) => e.replace(/&/g, "&").replac
|
|
|
121
121
|
for (let t of e) {
|
|
122
122
|
if (l < t.at) continue;
|
|
123
123
|
let e = t.duration <= 0 ? 1 : (l - t.at) / t.duration, n = e >= 1 ? 1 : e;
|
|
124
|
-
t.run(
|
|
124
|
+
t.run(V(n)), n === 1 && !o.has(t.name) && (o.add(t.name), t.onComplete?.());
|
|
125
125
|
}
|
|
126
126
|
if (l >= t) return i();
|
|
127
127
|
n = requestAnimationFrame(s);
|
|
@@ -133,9 +133,9 @@ var C = "http://www.w3.org/2000/svg", w = (e) => e.replace(/&/g, "&").replac
|
|
|
133
133
|
r = !0, n !== 0 && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(n), n = 0;
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
|
-
return
|
|
137
|
-
},
|
|
138
|
-
let t =
|
|
136
|
+
return a;
|
|
137
|
+
}, U = (e) => {
|
|
138
|
+
let t = H().add({
|
|
139
139
|
name: "spotlight",
|
|
140
140
|
duration: .72,
|
|
141
141
|
run: e.spotlight
|
|
@@ -156,4 +156,4 @@ var C = "http://www.w3.org/2000/svg", w = (e) => e.replace(/&/g, "&").replac
|
|
|
156
156
|
}), n.length > 0 && t.stagger(n, .06), t;
|
|
157
157
|
};
|
|
158
158
|
//#endregion
|
|
159
|
-
export {
|
|
159
|
+
export { O as CANVAS, f as CONTEXT, l as DEFAULT_SIZE, D as DEFAULT_STROKE, C as DURATION, v as EASE, b as STATE_FILL, _ as STATE_OPACITY, m as VARIANT_FILL, y as align, S as canMorph, N as createIcon, H as createTimeline, x as cssDuration, B as defineIconElement, P as iconDataUri, e as iconGroups, t as iconNames, n as isIconName, U as journeyChoreography, u as lerp, p as opticalStroke, z as optionsFromAttributes, r as paths, g as planMorph, h as prefersReducedMotion, M as renderIcon, s as resolveContext, c as resolveDuration, L as resolveElementName, a as resolveFill, i as resolveGeometry, E as resolveStroke, o as resolveTransform, T as resolveVariantFill, w as sampleIcon, d as samplePath };
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
//#region src/core/props.ts
|
|
2
|
+
var e = 24, t = 24, n = 2, r = (e, t) => {
|
|
3
|
+
if (typeof e == "number") return Number.isFinite(e) ? e : t;
|
|
4
|
+
if (typeof e == "string") {
|
|
5
|
+
let n = Number.parseFloat(e);
|
|
6
|
+
return Number.isFinite(n) ? n : t;
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
}, i = (e, t, n) => {
|
|
10
|
+
let i = r(e, 2);
|
|
11
|
+
return !n || t <= 0 ? i : i * 24 / t;
|
|
12
|
+
}, a = (e) => (r(e, 0) % 360 + 360) % 360, o = (e) => e === "horizontal" ? [-1, 1] : e === "vertical" ? [1, -1] : e === "both" ? [-1, -1] : [1, 1], s = (e, t) => {
|
|
13
|
+
let n = a(e), [r, i] = o(t);
|
|
14
|
+
if (n === 0 && r === 1 && i === 1) return;
|
|
15
|
+
let s = ["translate(12 12)"];
|
|
16
|
+
return n !== 0 && s.push(`rotate(${n})`), (r !== 1 || i !== 1) && s.push(`scale(${r} ${i})`), s.push("translate(-12 -12)"), s.join(" ");
|
|
17
|
+
}, c = (e) => {
|
|
18
|
+
let t = r(e.size, 24);
|
|
19
|
+
return {
|
|
20
|
+
size: t,
|
|
21
|
+
strokeWidth: i(e.strokeWidth, t, e.absoluteStrokeWidth === !0),
|
|
22
|
+
transform: s(e.rotate, e.flip)
|
|
23
|
+
};
|
|
24
|
+
}, l = (e) => {
|
|
25
|
+
if (e === !0) return 1;
|
|
26
|
+
if (e === void 0 || e === !1) return 0;
|
|
27
|
+
let t = r(e, 0);
|
|
28
|
+
return t < 0 ? 0 : t > 1 ? 1 : t;
|
|
29
|
+
}, u = {
|
|
30
|
+
outline: 0,
|
|
31
|
+
duotone: .18,
|
|
32
|
+
filled: 1
|
|
33
|
+
}, d = (e) => u[e ?? "outline"] ?? 0, f = {
|
|
34
|
+
inline: {
|
|
35
|
+
size: 16,
|
|
36
|
+
strokeWidth: 2,
|
|
37
|
+
hitArea: 0
|
|
38
|
+
},
|
|
39
|
+
toolbar: {
|
|
40
|
+
size: 20,
|
|
41
|
+
strokeWidth: 2,
|
|
42
|
+
hitArea: 44
|
|
43
|
+
},
|
|
44
|
+
button: {
|
|
45
|
+
size: 18,
|
|
46
|
+
strokeWidth: 2,
|
|
47
|
+
hitArea: 44
|
|
48
|
+
},
|
|
49
|
+
navigation: {
|
|
50
|
+
size: 22,
|
|
51
|
+
strokeWidth: 1.9,
|
|
52
|
+
hitArea: 48
|
|
53
|
+
},
|
|
54
|
+
status: {
|
|
55
|
+
size: 20,
|
|
56
|
+
strokeWidth: 2,
|
|
57
|
+
hitArea: 0
|
|
58
|
+
},
|
|
59
|
+
hero: {
|
|
60
|
+
size: 40,
|
|
61
|
+
strokeWidth: 1.6,
|
|
62
|
+
hitArea: 0
|
|
63
|
+
}
|
|
64
|
+
}, p = (e) => e === void 0 ? null : f[e] ?? null, m = (e, t = 2) => e <= 16 ? t * .9 : e <= 20 ? t * .95 : e <= 28 ? t : e <= 40 ? t * .85 : t * .75, h = {
|
|
65
|
+
default: 0,
|
|
66
|
+
hover: .12,
|
|
67
|
+
active: 1,
|
|
68
|
+
selected: 1,
|
|
69
|
+
disabled: 0
|
|
70
|
+
}, g = {
|
|
71
|
+
default: 1,
|
|
72
|
+
hover: 1,
|
|
73
|
+
active: 1,
|
|
74
|
+
selected: 1,
|
|
75
|
+
disabled: .38
|
|
76
|
+
}, _ = "http://www.w3.org/2000/svg", v = () => {
|
|
77
|
+
if (typeof document > "u") return !1;
|
|
78
|
+
try {
|
|
79
|
+
let e = document.createElementNS(_, "path");
|
|
80
|
+
return typeof e.getTotalLength == "function" && typeof e.getPointAtLength == "function";
|
|
81
|
+
} catch {
|
|
82
|
+
return !1;
|
|
83
|
+
}
|
|
84
|
+
}, y = (e, t) => {
|
|
85
|
+
if (!v() || t < 2) return null;
|
|
86
|
+
try {
|
|
87
|
+
let n = document.createElementNS(_, "svg"), r = document.createElementNS(_, "path");
|
|
88
|
+
r.setAttribute("d", e), n.appendChild(r);
|
|
89
|
+
let i = r.getTotalLength();
|
|
90
|
+
if (!Number.isFinite(i) || i <= 0) return null;
|
|
91
|
+
let a = [];
|
|
92
|
+
for (let e = 0; e < t; e += 1) {
|
|
93
|
+
let n = r.getPointAtLength(i * e / (t - 1));
|
|
94
|
+
a.push({
|
|
95
|
+
x: n.x,
|
|
96
|
+
y: n.y
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return a;
|
|
100
|
+
} catch {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
}, b = (e, t) => {
|
|
104
|
+
if (e.length === 0) return null;
|
|
105
|
+
let n = [];
|
|
106
|
+
for (let r of e) {
|
|
107
|
+
let e = y(r, t);
|
|
108
|
+
if (e === null) return null;
|
|
109
|
+
n.push(e);
|
|
110
|
+
}
|
|
111
|
+
return n;
|
|
112
|
+
}, x = (e) => {
|
|
113
|
+
let t = 0, n = 0;
|
|
114
|
+
for (let r of e) t += r.x, n += r.y;
|
|
115
|
+
return {
|
|
116
|
+
x: t / e.length,
|
|
117
|
+
y: n / e.length
|
|
118
|
+
};
|
|
119
|
+
}, S = (e) => {
|
|
120
|
+
let t = x(e);
|
|
121
|
+
return e.map(() => t);
|
|
122
|
+
}, C = (e, t) => Math.hypot(e.x - t.x, e.y - t.y), w = (e, t) => {
|
|
123
|
+
if (e.length !== t.length || e.length === 0) return [...t];
|
|
124
|
+
let n = 0, r = Infinity, i = Math.max(1, Math.floor(t.length / 24));
|
|
125
|
+
for (let a = 0; a < t.length; a += i) {
|
|
126
|
+
let o = 0;
|
|
127
|
+
for (let n = 0; n < e.length; n += i) o += C(e[n], t[(n + a) % t.length]);
|
|
128
|
+
o < r && (r = o, n = a);
|
|
129
|
+
}
|
|
130
|
+
return t.map((e, r) => t[(r + n) % t.length]);
|
|
131
|
+
}, T = (e, t, n) => e + (t - e) * n, E = (e) => {
|
|
132
|
+
if (e.length === 0) return "";
|
|
133
|
+
let t = e[0], n = e.slice(1).map((e) => `L${e.x.toFixed(2)} ${e.y.toFixed(2)}`).join("");
|
|
134
|
+
return `M${t.x.toFixed(2)} ${t.y.toFixed(2)}${n}`;
|
|
135
|
+
}, D = (e, t, n = 64) => {
|
|
136
|
+
let r = b(e, n), i = b(t, n);
|
|
137
|
+
if (r === null || i === null) return null;
|
|
138
|
+
let a = Math.max(r.length, i.length), o = [], s = [];
|
|
139
|
+
for (let e = 0; e < a; e += 1) {
|
|
140
|
+
let t = r[e], n = i[e];
|
|
141
|
+
t !== void 0 && n !== void 0 ? (o.push([...t]), s.push(w(t, n))) : t === void 0 ? n !== void 0 && (o.push(S(n)), s.push([...n])) : (o.push([...t]), s.push(S(t)));
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
from: o,
|
|
145
|
+
to: s,
|
|
146
|
+
at: (e) => {
|
|
147
|
+
let t = e <= 0 ? 0 : e >= 1 ? 1 : e;
|
|
148
|
+
return o.map((e, n) => {
|
|
149
|
+
let r = s[n];
|
|
150
|
+
return E(e.map((e, n) => ({
|
|
151
|
+
x: T(e.x, r[n].x, t),
|
|
152
|
+
y: T(e.y, r[n].y, t)
|
|
153
|
+
})));
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}, O = {
|
|
158
|
+
micro: .18,
|
|
159
|
+
state: .28,
|
|
160
|
+
morph: .36
|
|
161
|
+
}, k = {
|
|
162
|
+
enter: "cubic-bezier(0.33, 1, 0.68, 1)",
|
|
163
|
+
morph: "cubic-bezier(0.65, 0, 0.35, 1)"
|
|
164
|
+
}, A = () => typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia("(prefers-reduced-motion: reduce)").matches === !0, j = (e, t = A()) => t ? 0 : e, M = (e, t) => `${j(e, t)}s`;
|
|
165
|
+
//#endregion
|
|
166
|
+
export { c as C, l as S, s as T, p as _, j as a, t as b, T as c, y as d, f, m as g, u as h, A as i, D as l, g as m, k as n, w as o, h as p, M as r, v as s, O as t, b as u, d as v, i as w, n as x, e as y };
|
package/dist/paths.d.ts
CHANGED
|
@@ -9,53 +9,53 @@
|
|
|
9
9
|
* those, which is what lets one definition serve every size and weight.
|
|
10
10
|
*/
|
|
11
11
|
export declare const paths: {
|
|
12
|
-
readonly arrowRight: readonly ["M4
|
|
13
|
-
readonly arrowLeft: readonly ["M20
|
|
14
|
-
readonly arrowUp: readonly ["M12
|
|
15
|
-
readonly arrowDown: readonly ["M12
|
|
16
|
-
readonly chevronRight: readonly ["
|
|
17
|
-
readonly chevronLeft: readonly ["
|
|
18
|
-
readonly chevronUp: readonly ["
|
|
19
|
-
readonly chevronDown: readonly ["
|
|
20
|
-
readonly close: readonly ["
|
|
21
|
-
readonly menu: readonly ["M4
|
|
22
|
-
readonly external: readonly ["M14
|
|
23
|
-
readonly start: readonly ["M9.5 7.
|
|
24
|
-
readonly skip: readonly ["
|
|
25
|
-
readonly complete: readonly ["
|
|
26
|
-
readonly target: readonly ["M12
|
|
27
|
-
readonly spark: readonly ["M12 3.
|
|
28
|
-
readonly pause: readonly ["M9.5
|
|
29
|
-
readonly restart: readonly ["M20
|
|
30
|
-
readonly success: readonly ["M12
|
|
31
|
-
readonly warning: readonly ["M10.
|
|
32
|
-
readonly info: readonly ["M12
|
|
33
|
-
readonly error: readonly ["M12
|
|
34
|
-
readonly welcome: readonly ["M4 11.
|
|
35
|
-
readonly discover: readonly ["M11 4.
|
|
36
|
-
readonly click: readonly ["M9 4.
|
|
37
|
-
readonly swipe: readonly ["M7
|
|
38
|
-
readonly drag: readonly ["M9 6.
|
|
39
|
-
readonly scroll: readonly ["M12 5.
|
|
40
|
-
readonly tip: readonly ["M9
|
|
41
|
-
readonly help: readonly ["M12
|
|
42
|
-
readonly shortcut: readonly ["M6 8.
|
|
43
|
-
readonly newFeature: readonly ["M12 3.5
|
|
44
|
-
readonly home: readonly ["M3 10.
|
|
45
|
-
readonly search: readonly ["M11 4.
|
|
46
|
-
readonly install: readonly ["M12
|
|
47
|
-
readonly book: readonly ["M4 4.
|
|
48
|
-
readonly code: readonly ["
|
|
49
|
-
readonly palette: readonly ["M12
|
|
50
|
-
readonly shield: readonly ["M12
|
|
51
|
-
readonly accessibility: readonly ["M12
|
|
52
|
-
readonly sun: readonly ["M12
|
|
53
|
-
readonly moon: readonly ["M20
|
|
54
|
-
readonly monitor: readonly ["M4
|
|
55
|
-
readonly plus: readonly ["M12
|
|
56
|
-
readonly minus: readonly ["M5
|
|
57
|
-
readonly copy: readonly ["M9
|
|
58
|
-
readonly settings: readonly ["M12 8.
|
|
12
|
+
readonly arrowRight: readonly ["M4 12L19 12", "M13 6L19 12L13 18"];
|
|
13
|
+
readonly arrowLeft: readonly ["M20 12L5 12", "M11 6L5 12L11 18"];
|
|
14
|
+
readonly arrowUp: readonly ["M12 20L12 5", "M6 11L12 5L18 11"];
|
|
15
|
+
readonly arrowDown: readonly ["M12 4L12 19", "M6 13L12 19L18 13"];
|
|
16
|
+
readonly chevronRight: readonly ["M9 6L15 12L9 18"];
|
|
17
|
+
readonly chevronLeft: readonly ["M15 6L9 12L15 18"];
|
|
18
|
+
readonly chevronUp: readonly ["M6 15L12 9L18 15"];
|
|
19
|
+
readonly chevronDown: readonly ["M6 9L12 15L18 9"];
|
|
20
|
+
readonly close: readonly ["M6 6L18 18", "M18 6L6 18"];
|
|
21
|
+
readonly menu: readonly ["M4 7L20 7", "M4 12L20 12", "M4 17L20 17"];
|
|
22
|
+
readonly external: readonly ["M14 4L20 4L20 10", "M20 4L11 13", "M18 14L18 19A1 1 0 0 1 17 20L5 20A1 1 0 0 1 4 19L4 7A1 1 0 0 1 5 6L10 6"];
|
|
23
|
+
readonly start: readonly ["M9.5 7.5L9.5 16.5L16.5 12Z", "M12 3A9 9 0 1 0 12 21A9 9 0 0 0 12 3Z"];
|
|
24
|
+
readonly skip: readonly ["M6 6L13 12L6 18", "M18 5L18 19"];
|
|
25
|
+
readonly complete: readonly ["M5 12.5L9.5 17L19 7.5"];
|
|
26
|
+
readonly target: readonly ["M12 3A9 9 0 1 0 12 21A9 9 0 0 0 12 3Z", "M12 8A4 4 0 1 0 12 16A4 4 0 0 0 12 8Z", "M12 11.5A1 1 0 1 0 12 13A1 1 0 0 0 12 11.5Z"];
|
|
27
|
+
readonly spark: readonly ["M12 3.5L14 9L19.5 11L14 13L12 18.5L10 13L4.5 11L10 9Z", "M18.5 4L18.5 7", "M20 5.5L17 5.5"];
|
|
28
|
+
readonly pause: readonly ["M9.5 5L9.5 19", "M14.5 5L14.5 19"];
|
|
29
|
+
readonly restart: readonly ["M20 12A8 8 0 1 1 17.5 6", "M20 4L20 9L15 9"];
|
|
30
|
+
readonly success: readonly ["M12 3A9 9 0 1 0 12 21A9 9 0 0 0 12 3Z", "M8.5 12.5L11 15L16 9.5"];
|
|
31
|
+
readonly warning: readonly ["M10.5 4.5L3 17.5A1.5 1.5 0 0 0 4.5 20L20 20A1.5 1.5 0 0 0 21.5 17.5L13.5 4.5A1.5 1.5 0 0 0 10.5 4.5Z", "M12 9.5L12 13.5", "M12 17L12 17"];
|
|
32
|
+
readonly info: readonly ["M12 3A9 9 0 1 0 12 21A9 9 0 0 0 12 3Z", "M12 11L12 16", "M12 8L12 8"];
|
|
33
|
+
readonly error: readonly ["M12 3A9 9 0 1 0 12 21A9 9 0 0 0 12 3Z", "M9 9L15 15", "M15 9L9 15"];
|
|
34
|
+
readonly welcome: readonly ["M4 11.5L12 4L20 11.5", "M6.5 10L6.5 19A1 1 0 0 0 7.5 20L16.5 20A1 1 0 0 0 17.5 19L17.5 10", "M9.5 20L9.5 15.5A2.5 2.5 0 0 1 14.5 15.5L14.5 20"];
|
|
35
|
+
readonly discover: readonly ["M11 4.5A6.5 6.5 0 1 0 11 17.5A6.5 6.5 0 0 0 11 4.5Z", "M20 20L15.5 15.5", "M11 8.5L11 13.5", "M8.5 11L13.5 11"];
|
|
36
|
+
readonly click: readonly ["M9 4.5L9 7.5", "M4.5 9L7.5 9", "M6 6L8 8", "M11 11L19.5 14L16 15.5L14.5 19Z"];
|
|
37
|
+
readonly swipe: readonly ["M7 12L17 12", "M10 9L7 12L10 15", "M14 9L17 12L14 15", "M12 4L12 6", "M12 18L12 20"];
|
|
38
|
+
readonly drag: readonly ["M9 6.5L9 6.5", "M15 6.5L15 6.5", "M9 12L9 12", "M15 12L15 12", "M9 17.5L9 17.5", "M15 17.5L15 17.5"];
|
|
39
|
+
readonly scroll: readonly ["M12 5.5A3.5 3.5 0 0 0 8.5 9L8.5 15A3.5 3.5 0 0 0 15.5 15L15.5 9A3.5 3.5 0 0 0 12 5.5Z", "M12 9L12 11.5"];
|
|
40
|
+
readonly tip: readonly ["M9 18L15 18", "M10 21L14 21", "M12 3A6 6 0 0 0 8.5 14C9 14.5 9.5 15 9.5 15.5L9.5 16L14.5 16L14.5 15.5C14.5 15 15 14.5 15.5 14A6 6 0 0 0 12 3Z"];
|
|
41
|
+
readonly help: readonly ["M12 3A9 9 0 1 0 12 21A9 9 0 0 0 12 3Z", "M9.5 9.5A2.5 2.5 0 1 1 13 12C12.5 12 12 13 12 13.5L12 14", "M12 16.5L12 16.5"];
|
|
42
|
+
readonly shortcut: readonly ["M6 8.5A2.5 2.5 0 1 1 8.5 11L6 11Z", "M8.5 13L6 13L6 15.5A2.5 2.5 0 1 0 8.5 13Z", "M15.5 11L18 11L18 8.5A2.5 2.5 0 1 0 15.5 11Z", "M15.5 13A2.5 2.5 0 1 0 18 15.5L18 13Z"];
|
|
43
|
+
readonly newFeature: readonly ["M12 3.5L13.5 9L19 11L13.5 13L12 18L10.5 12.5L5 11L10.5 9Z", "M18.5 15L18.5 18.5", "M20.5 17L17 17"];
|
|
44
|
+
readonly home: readonly ["M3 10.5L12 3L21 10.5", "M5.5 9L5.5 20A1 1 0 0 0 6.5 21L10 21L10 15L14 15L14 21L17.5 21A1 1 0 0 0 18.5 20L18.5 9"];
|
|
45
|
+
readonly search: readonly ["M11 4.5A6.5 6.5 0 1 0 11 17.5A6.5 6.5 0 0 0 11 4.5Z", "M20 20L15.5 15.5"];
|
|
46
|
+
readonly install: readonly ["M12 3L12 14", "M7.5 10L12 14L16.5 10", "M4 17L4 19A2 2 0 0 0 6 21L18 21A2 2 0 0 0 20 19L20 17"];
|
|
47
|
+
readonly book: readonly ["M4 4.5L9 4.5A3 3 0 0 1 12 7.5L12 20A2.5 2.5 0 0 0 9.5 17.5L4 17.5Z", "M20 4.5L15 4.5A3 3 0 0 0 12 7.5L12 20A2.5 2.5 0 0 1 14.5 17.5L20 17.5Z"];
|
|
48
|
+
readonly code: readonly ["M8.5 7L3.5 12L8.5 17", "M15.5 7L20.5 12L15.5 17", "M13.5 4L10.5 20"];
|
|
49
|
+
readonly palette: readonly ["M12 3A9 9 0 0 0 12 21A2 2 0 0 0 13.5 18A2 2 0 0 1 15 15L18 15A3 3 0 0 0 21 12A9 9 0 0 0 12 3.5Z", "M7.5 12.5L7.5 12.5", "M9.5 8L9.5 8", "M14 7L14 7", "M17 10L17 10"];
|
|
50
|
+
readonly shield: readonly ["M12 3L19.5 6L19.5 12C19.5 16.5 16.5 20 12 21.5C7.5 20 4.5 16.5 4.5 12L4.5 6Z", "M9 12L11 14L15.5 10"];
|
|
51
|
+
readonly accessibility: readonly ["M12 3A1.5 1.5 0 1 0 12 6A1.5 1.5 0 0 0 12 3Z", "M4.5 8.5L12 10L19.5 8.5", "M12 10L12 14.5", "M9 20.5L12 14.5L15 20.5"];
|
|
52
|
+
readonly sun: readonly ["M12 8A4 4 0 1 0 12 16A4 4 0 0 0 12 8Z", "M12 2.5L12 4.5", "M12 19.5L12 21.5", "M4.5 4.5L6 6", "M18 18L19.5 19.5", "M2.5 12L4.5 12", "M19.5 12L21.5 12", "M4.5 19.5L6 18", "M18 6L19.5 4.5"];
|
|
53
|
+
readonly moon: readonly ["M20 14A8 8 0 0 1 10 4A8.5 8.5 0 1 0 20 14Z"];
|
|
54
|
+
readonly monitor: readonly ["M4 5L20 5A1 1 0 0 1 21 6L21 15A1 1 0 0 1 20 16L4 16A1 1 0 0 1 3 15L3 6A1 1 0 0 1 4 5Z", "M9 20L15 20", "M12 16L12 20"];
|
|
55
|
+
readonly plus: readonly ["M12 5L12 19", "M5 12L19 12"];
|
|
56
|
+
readonly minus: readonly ["M5 12L19 12"];
|
|
57
|
+
readonly copy: readonly ["M9 9L18 9A1 1 0 0 1 19 10L19 19A1 1 0 0 1 18 20L9 20A1 1 0 0 1 8 19L8 10A1 1 0 0 1 9 9Z", "M5 15L4 15A1 1 0 0 1 3 14L3 5A1 1 0 0 1 4 4L13 4A1 1 0 0 1 14 5L14 6"];
|
|
58
|
+
readonly settings: readonly ["M12 8.5A3.5 3.5 0 1 0 12 15.5A3.5 3.5 0 0 0 12 8.5Z", "M19.5 15A1.5 1.5 0 0 0 20 17L20 17A2 2 0 1 1 17 20L17 20A1.5 1.5 0 0 0 14.5 21L14.5 21.5A2 2 0 1 1 10.5 21.5L10.5 21.5A1.5 1.5 0 0 0 7.5 20.5L7.5 20.5A2 2 0 1 1 4.5 17.5L4.5 17.5A1.5 1.5 0 0 0 3.5 15L3 15A2 2 0 1 1 3 11L3 11A1.5 1.5 0 0 0 4 8L4 8A2 2 0 1 1 7 5L7 5A1.5 1.5 0 0 0 10 4.5L10 4A2 2 0 1 1 14 4L14 4A1.5 1.5 0 0 0 17 5L17 5A2 2 0 1 1 20 8L20 8A1.5 1.5 0 0 0 21 11L21.5 11A2 2 0 1 1 21.5 15L21.5 15A1.5 1.5 0 0 0 20 16Z"];
|
|
59
59
|
};
|
|
60
60
|
export type IconName = keyof typeof paths;
|
|
61
61
|
export declare const iconNames: IconName[];
|