iconplease 0.4.0 → 0.5.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/ICONS-LICENSE.md +53 -0
- package/LICENSE +30 -0
- package/README.md +8 -0
- package/dist/animation.d.ts +22 -5
- package/dist/animation.js +110 -11
- package/dist/iconplease.min.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/player.js +87 -37
- package/package.json +7 -4
package/ICONS-LICENSE.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# iconplease Icon License
|
|
2
|
+
|
|
3
|
+
Version 1.0 — 2026
|
|
4
|
+
|
|
5
|
+
This licence covers the icons in the public iconplease catalogue (served from
|
|
6
|
+
`cdn.iconplease.com` and shown on iconplease.com/icons). It does not cover
|
|
7
|
+
private icons; see "Private icons" below.
|
|
8
|
+
|
|
9
|
+
## You may
|
|
10
|
+
|
|
11
|
+
- Use the icons for free in personal and commercial work: websites, apps,
|
|
12
|
+
software, products you sell, marketing, print, video, slides and documents.
|
|
13
|
+
- Change them: recolour, resize, re-stroke, edit and combine them.
|
|
14
|
+
- Ship them inside your own product, website or app, including in source code
|
|
15
|
+
and builds that other people can download.
|
|
16
|
+
|
|
17
|
+
No attribution is required. A link back to iconplease.com is appreciated.
|
|
18
|
+
|
|
19
|
+
## You may not
|
|
20
|
+
|
|
21
|
+
- Redistribute the icons as an icon set, icon font, icon pack or library — on
|
|
22
|
+
their own or as the main part of another product — whether free or paid.
|
|
23
|
+
- Use them to build a product that competes with iconplease (an icon library,
|
|
24
|
+
icon marketplace or icon design service).
|
|
25
|
+
- Sell or license the icons themselves, as they are or modified, for example as
|
|
26
|
+
stock assets, templates or NFTs.
|
|
27
|
+
- Use them in a logo or trademark, or in a way that suggests iconplease
|
|
28
|
+
endorses you.
|
|
29
|
+
|
|
30
|
+
## Private icons
|
|
31
|
+
|
|
32
|
+
Private icons are not covered by this licence, by the MIT licence of the
|
|
33
|
+
iconplease code, or by any other open licence. Private icons are:
|
|
34
|
+
|
|
35
|
+
- icons drawn in the iconplease designer and saved to an account ("My icons");
|
|
36
|
+
- icons in a private set, including catalogue icons that a set owner changed;
|
|
37
|
+
- icons in a file written by `npx iconplease pull` from a private set.
|
|
38
|
+
|
|
39
|
+
A private icon belongs to the person who made it (or their employer or client,
|
|
40
|
+
as they agree between themselves). iconplease does not own it and only stores
|
|
41
|
+
and serves it to do the job the owner asked for. Seeing, downloading or
|
|
42
|
+
receiving a private icon, through a website, an API key, a token, a build file
|
|
43
|
+
or a Figma file, gives you no right to use it. Only its owner can grant one.
|
|
44
|
+
|
|
45
|
+
A catalogue icon that someone has only recoloured or resized stays a catalogue
|
|
46
|
+
icon, and this licence still applies to it.
|
|
47
|
+
|
|
48
|
+
## No warranty
|
|
49
|
+
|
|
50
|
+
The icons are provided "as is", without warranty of any kind. iconplease is
|
|
51
|
+
not liable for any claim or damage arising from their use.
|
|
52
|
+
|
|
53
|
+
Questions: hello@iconplease.com
|
package/LICENSE
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TECHNOLOGYPLEASE Co., Ltd.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
This licence covers the code in this package only. It does not cover any icon
|
|
24
|
+
the code loads, renders or writes, including:
|
|
25
|
+
|
|
26
|
+
- the public catalogue icons from cdn.iconplease.com, which are covered by the
|
|
27
|
+
iconplease Icon License (ICONS-LICENSE.md);
|
|
28
|
+
- private icons: icons in a private set, icons people draw in the iconplease
|
|
29
|
+
designer, and icons in a file written by `npx iconplease pull`. These belong
|
|
30
|
+
to their owners. Nothing in this licence grants anyone any right to them.
|
package/README.md
CHANGED
|
@@ -144,3 +144,11 @@ await load(["heart", "star"]);
|
|
|
144
144
|
import { init } from "iconplease";
|
|
145
145
|
init({ revalidate: 600 });
|
|
146
146
|
```
|
|
147
|
+
|
|
148
|
+
## Licence
|
|
149
|
+
|
|
150
|
+
The code is MIT (see `LICENSE`). The catalogue icons are free for personal and
|
|
151
|
+
commercial use, with no attribution, under the iconplease Icon License (see
|
|
152
|
+
`ICONS-LICENSE.md`). Just don't redistribute them as an icon set of your own.
|
|
153
|
+
Private icons (your own drawings, private sets, files from `npx iconplease pull`)
|
|
154
|
+
are not covered by either licence. They belong to their owners.
|
package/dist/animation.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type AnimationPreset = "draw" | "fade" | "pop" | "spin" | "slide-up" | "slide-down" | "slide-left" | "slide-right" | "bounce" | "pulse" | "shake" | "follow";
|
|
1
|
+
export type AnimationPreset = "draw" | "fade" | "pop" | "spin" | "slide-up" | "slide-down" | "slide-left" | "slide-right" | "bounce" | "pulse" | "shake" | "spin-back" | "fade-out" | "pop-out" | "slide-out-up" | "slide-out-down" | "follow";
|
|
2
2
|
export type AnimationEasing = "linear" | "ease-in" | "ease-out" | "ease-in-out" | "spring";
|
|
3
|
-
export type AnimationTrigger = "load" | "hover" | "click" | "visible";
|
|
3
|
+
export type AnimationTrigger = "load" | "hover" | "click" | "toggle" | "visible";
|
|
4
4
|
export type AnimationClip = {
|
|
5
5
|
id: string;
|
|
6
6
|
target: string;
|
|
@@ -11,13 +11,22 @@ export type AnimationClip = {
|
|
|
11
11
|
path?: string;
|
|
12
12
|
orient?: boolean;
|
|
13
13
|
};
|
|
14
|
-
export type
|
|
15
|
-
version: 1;
|
|
14
|
+
export type AnimationStage = {
|
|
16
15
|
trigger: AnimationTrigger;
|
|
17
16
|
loop: boolean;
|
|
18
17
|
loopGap: number;
|
|
18
|
+
reverse?: boolean;
|
|
19
19
|
clips: AnimationClip[];
|
|
20
20
|
};
|
|
21
|
+
export type IconAnimation = AnimationStage & {
|
|
22
|
+
version: 1;
|
|
23
|
+
stages?: AnimationStage[];
|
|
24
|
+
};
|
|
25
|
+
export type StageKind = "appear" | "hover" | "click";
|
|
26
|
+
export declare const STAGE_KINDS: StageKind[];
|
|
27
|
+
export declare const STAGE_TRIGGERS: Record<StageKind, AnimationTrigger[]>;
|
|
28
|
+
export declare const STAGE_LABELS: Record<StageKind, string>;
|
|
29
|
+
export declare const stageKindOf: (trigger: AnimationTrigger) => StageKind;
|
|
21
30
|
type Frame = {
|
|
22
31
|
offset: number;
|
|
23
32
|
transform?: string;
|
|
@@ -43,6 +52,8 @@ export declare const TRIGGERS: Record<AnimationTrigger, string>;
|
|
|
43
52
|
export declare const MAX_CLIPS = 64;
|
|
44
53
|
export declare const MAX_TIME = 10000;
|
|
45
54
|
export declare const MIN_DURATION = 50;
|
|
55
|
+
export declare const stagesOf: (animation: IconAnimation | undefined) => AnimationStage[];
|
|
56
|
+
export declare const fromStages: (list: AnimationStage[]) => IconAnimation | undefined;
|
|
46
57
|
export declare const cleanAnimation: (value: unknown) => IconAnimation | undefined;
|
|
47
58
|
export declare const ANIMATION_ATTRIBUTE = "data-ip-animation";
|
|
48
59
|
export declare const MARKER_ATTRIBUTE = "data-ip";
|
|
@@ -56,8 +67,14 @@ export type Playback = {
|
|
|
56
67
|
cancel: () => void;
|
|
57
68
|
readonly period: number;
|
|
58
69
|
readonly animations: Animation[];
|
|
70
|
+
/** Plays backwards from wherever it is, then calls done once it is back at the start. */
|
|
71
|
+
reverse: (done?: () => void) => void;
|
|
72
|
+
/** Plays forwards again after a reverse, from wherever it is. */
|
|
73
|
+
forward: () => void;
|
|
74
|
+
/** Maps an animation's raw currentTime to a moment on the designer's ruler (0..total). */
|
|
75
|
+
readonly clock: (raw: number) => number;
|
|
59
76
|
};
|
|
60
|
-
export declare const animate: (animation:
|
|
77
|
+
export declare const animate: (animation: AnimationStage, targetsOf: (target: string) => Element[], options?: {
|
|
61
78
|
paused?: boolean;
|
|
62
79
|
loop?: boolean;
|
|
63
80
|
}) => Playback;
|
package/dist/animation.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
export const STAGE_KINDS = ["appear", "hover", "click"];
|
|
2
|
+
export const STAGE_TRIGGERS = {
|
|
3
|
+
appear: ["load", "visible"],
|
|
4
|
+
hover: ["hover"],
|
|
5
|
+
click: ["click", "toggle"],
|
|
6
|
+
};
|
|
7
|
+
export const STAGE_LABELS = {
|
|
8
|
+
appear: "Appear",
|
|
9
|
+
hover: "Hover",
|
|
10
|
+
click: "Click",
|
|
11
|
+
};
|
|
12
|
+
export const stageKindOf = (trigger) => trigger === "hover" ? "hover" : trigger === "click" || trigger === "toggle" ? "click" : "appear";
|
|
1
13
|
export const PRESETS = {
|
|
2
14
|
draw: { label: "Draw on", hint: "Strokes draw themselves", duration: 700, easing: "ease-in-out", draw: true },
|
|
3
15
|
fade: { label: "Fade in", hint: "From invisible to visible", duration: 400, easing: "ease-out", frames: [{ offset: 0, opacity: 0 }, { offset: 1, opacity: 1 }] },
|
|
@@ -31,6 +43,11 @@ export const PRESETS = {
|
|
|
31
43
|
{ offset: 1, transform: "scale(1)" },
|
|
32
44
|
],
|
|
33
45
|
},
|
|
46
|
+
"spin-back": { label: "Spin back", hint: "One full turn, anticlockwise", duration: 800, easing: "ease-in-out", frames: [{ offset: 0, transform: "rotate(0deg)" }, { offset: 1, transform: "rotate(-360deg)" }] },
|
|
47
|
+
"fade-out": { label: "Fade out", hint: "From visible to invisible", duration: 400, easing: "ease-in", frames: [{ offset: 0, opacity: 1 }, { offset: 1, opacity: 0 }] },
|
|
48
|
+
"pop-out": { label: "Pop out", hint: "Shrinks away to nothing", duration: 350, easing: "ease-in", frames: [{ offset: 0, transform: "scale(1)" }, { offset: 1, transform: "scale(0)" }] },
|
|
49
|
+
"slide-out-up": { label: "Slide out up", hint: "Rises and fades away", duration: 400, easing: "ease-in", frames: [{ offset: 0, transform: "translateY(0px)", opacity: 1 }, { offset: 1, transform: "translateY(-4px)", opacity: 0 }] },
|
|
50
|
+
"slide-out-down": { label: "Slide out down", hint: "Drops and fades away", duration: 400, easing: "ease-in", frames: [{ offset: 0, transform: "translateY(0px)", opacity: 1 }, { offset: 1, transform: "translateY(4px)", opacity: 0 }] },
|
|
34
51
|
follow: { label: "Move along path", hint: "The shape's centre travels along a route you drew", duration: 1200, easing: "ease-in-out", route: true },
|
|
35
52
|
shake: {
|
|
36
53
|
label: "Shake",
|
|
@@ -60,20 +77,41 @@ export const TRIGGERS = {
|
|
|
60
77
|
load: "When it appears",
|
|
61
78
|
hover: "On hover",
|
|
62
79
|
click: "On click",
|
|
80
|
+
toggle: "Click to toggle",
|
|
63
81
|
visible: "When scrolled into view",
|
|
64
82
|
};
|
|
65
83
|
export const MAX_CLIPS = 64;
|
|
66
84
|
export const MAX_TIME = 10000;
|
|
67
85
|
export const MIN_DURATION = 50;
|
|
68
|
-
const PRESET_SET = new Set(
|
|
86
|
+
const PRESET_SET = new Set(Object.keys(PRESETS));
|
|
69
87
|
const ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
70
88
|
const ms = (value, low, high) => typeof value === "number" && Number.isFinite(value) ? Math.round(Math.min(Math.max(value, low), high)) : undefined;
|
|
71
|
-
|
|
89
|
+
const stageOnly = (stage) => ({
|
|
90
|
+
trigger: stage.trigger,
|
|
91
|
+
loop: stage.loop,
|
|
92
|
+
loopGap: stage.loopGap,
|
|
93
|
+
...(stage.reverse === true ? { reverse: true } : {}),
|
|
94
|
+
clips: stage.clips,
|
|
95
|
+
});
|
|
96
|
+
export const stagesOf = (animation) => animation ? [stageOnly(animation), ...(animation.stages ?? []).map(stageOnly)] : [];
|
|
97
|
+
export const fromStages = (list) => {
|
|
98
|
+
const kept = [];
|
|
99
|
+
for (const kind of STAGE_KINDS) {
|
|
100
|
+
const stage = list.find((candidate) => stageKindOf(candidate.trigger) === kind && candidate.clips.length > 0);
|
|
101
|
+
if (stage)
|
|
102
|
+
kept.push(stageOnly(stage));
|
|
103
|
+
}
|
|
104
|
+
const [first, ...rest] = kept;
|
|
105
|
+
if (!first)
|
|
106
|
+
return undefined;
|
|
107
|
+
return { version: 1, ...first, ...(rest.length ? { stages: rest } : {}) };
|
|
108
|
+
};
|
|
109
|
+
const cleanStage = (value, budget) => {
|
|
72
110
|
if (!value || typeof value !== "object")
|
|
73
111
|
return undefined;
|
|
74
112
|
const raw = value;
|
|
75
113
|
const clips = [];
|
|
76
|
-
for (const clip of Array.isArray(raw.clips) ? raw.clips.slice(0,
|
|
114
|
+
for (const clip of Array.isArray(raw.clips) ? raw.clips.slice(0, budget) : []) {
|
|
77
115
|
if (!clip || typeof clip !== "object")
|
|
78
116
|
continue;
|
|
79
117
|
const start = ms(clip.start, 0, MAX_TIME);
|
|
@@ -100,13 +138,30 @@ export const cleanAnimation = (value) => {
|
|
|
100
138
|
if (!clips.length)
|
|
101
139
|
return undefined;
|
|
102
140
|
return {
|
|
103
|
-
version: 1,
|
|
104
141
|
trigger: raw.trigger && raw.trigger in TRIGGERS ? raw.trigger : "load",
|
|
105
142
|
loop: raw.loop === true,
|
|
106
143
|
loopGap: ms(raw.loopGap, 0, MAX_TIME) ?? 0,
|
|
144
|
+
...(raw.reverse === true ? { reverse: true } : {}),
|
|
107
145
|
clips,
|
|
108
146
|
};
|
|
109
147
|
};
|
|
148
|
+
export const cleanAnimation = (value) => {
|
|
149
|
+
if (!value || typeof value !== "object")
|
|
150
|
+
return undefined;
|
|
151
|
+
const raw = value;
|
|
152
|
+
const list = [];
|
|
153
|
+
let budget = MAX_CLIPS;
|
|
154
|
+
for (const candidate of [raw, ...(Array.isArray(raw.stages) ? raw.stages.slice(0, STAGE_KINDS.length) : [])]) {
|
|
155
|
+
if (budget <= 0)
|
|
156
|
+
break;
|
|
157
|
+
const stage = cleanStage(candidate, budget);
|
|
158
|
+
if (!stage)
|
|
159
|
+
continue;
|
|
160
|
+
budget -= stage.clips.length;
|
|
161
|
+
list.push(stage);
|
|
162
|
+
}
|
|
163
|
+
return fromStages(list);
|
|
164
|
+
};
|
|
110
165
|
export const ANIMATION_ATTRIBUTE = "data-ip-animation";
|
|
111
166
|
export const MARKER_ATTRIBUTE = "data-ip";
|
|
112
167
|
const toBase64Url = (text) => btoa(text).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
@@ -171,9 +226,9 @@ const routeFrames = (root, d, orient) => {
|
|
|
171
226
|
guide.remove();
|
|
172
227
|
}
|
|
173
228
|
};
|
|
174
|
-
const onTimeline = (frames, clip, period, neutral) => {
|
|
175
|
-
const begin = clip.start / period;
|
|
176
|
-
const end = (clip.start + clip.duration) / period;
|
|
229
|
+
const onTimeline = (frames, clip, period, neutral, lead = 0) => {
|
|
230
|
+
const begin = (clip.start + lead) / period;
|
|
231
|
+
const end = (clip.start + lead + clip.duration) / period;
|
|
177
232
|
const easing = EASINGS[clip.easing].css;
|
|
178
233
|
const placed = frames.map((frame, index) => ({
|
|
179
234
|
...frame,
|
|
@@ -197,8 +252,15 @@ export const animate = (animation, targetsOf, options = {}) => {
|
|
|
197
252
|
const total = Math.max(totalDuration(animation), MIN_DURATION);
|
|
198
253
|
const loop = options.loop ?? animation.loop;
|
|
199
254
|
const period = loop ? total + animation.loopGap : total;
|
|
255
|
+
const backAndForth = loop && animation.reverse === true;
|
|
256
|
+
const lead = backAndForth ? animation.loopGap / 2 : 0;
|
|
200
257
|
const animations = [];
|
|
201
|
-
const timing = {
|
|
258
|
+
const timing = {
|
|
259
|
+
duration: period,
|
|
260
|
+
iterations: loop ? Infinity : 1,
|
|
261
|
+
fill: "both",
|
|
262
|
+
direction: backAndForth ? "alternate" : "normal",
|
|
263
|
+
};
|
|
202
264
|
for (const clip of animation.clips) {
|
|
203
265
|
const spec = PRESETS[clip.preset];
|
|
204
266
|
const follows = animation.clips.some((other) => other.target === clip.target && other.start < clip.start);
|
|
@@ -211,7 +273,7 @@ export const animate = (animation, targetsOf, options = {}) => {
|
|
|
211
273
|
{ offset: 1, strokeDasharray: `${length} ${length}`, strokeDashoffset: 0 },
|
|
212
274
|
];
|
|
213
275
|
const shown = follows ? { offset: 0, strokeDasharray: `${length} ${length}`, strokeDashoffset: 0 } : undefined;
|
|
214
|
-
animations.push(stroke.animate(onTimeline(frames, clip, period, shown), timing));
|
|
276
|
+
animations.push(stroke.animate(onTimeline(frames, clip, period, shown, lead), timing));
|
|
215
277
|
}
|
|
216
278
|
continue;
|
|
217
279
|
}
|
|
@@ -226,18 +288,55 @@ export const animate = (animation, targetsOf, options = {}) => {
|
|
|
226
288
|
const shown = follows
|
|
227
289
|
? { offset: 0, ...(moves ? { transform: "translate(0px, 0px)" } : {}), ...(fades ? { opacity: 1 } : {}) }
|
|
228
290
|
: undefined;
|
|
229
|
-
animations.push(element.animate(onTimeline(frames, clip, period, shown), { ...timing, composite: moves ? "add" : "replace" }));
|
|
291
|
+
animations.push(element.animate(onTimeline(frames, clip, period, shown, lead), { ...timing, composite: moves ? "add" : "replace" }));
|
|
230
292
|
}
|
|
231
293
|
}
|
|
232
294
|
const each = (fn) => animations.forEach(fn);
|
|
295
|
+
const clock = (raw) => {
|
|
296
|
+
if (!loop)
|
|
297
|
+
return Math.min(raw, total);
|
|
298
|
+
const cycle = Math.floor(raw / period);
|
|
299
|
+
const within = raw - cycle * period;
|
|
300
|
+
const forward = backAndForth && cycle % 2 === 1 ? period - within : within;
|
|
301
|
+
return Math.min(total, Math.max(0, forward - lead));
|
|
302
|
+
};
|
|
233
303
|
if (options.paused)
|
|
234
304
|
each((item) => item.pause());
|
|
235
305
|
return {
|
|
236
306
|
play: () => each((item) => item.play()),
|
|
237
307
|
pause: () => each((item) => item.pause()),
|
|
238
|
-
|
|
308
|
+
reverse: (done) => {
|
|
309
|
+
const first = animations[0];
|
|
310
|
+
if (!first)
|
|
311
|
+
return done?.();
|
|
312
|
+
const at = clock(Number(first.currentTime ?? 0)) + lead;
|
|
313
|
+
if (at <= 1)
|
|
314
|
+
return done?.();
|
|
315
|
+
try {
|
|
316
|
+
each((item) => {
|
|
317
|
+
item.currentTime = at;
|
|
318
|
+
item.playbackRate = -1;
|
|
319
|
+
item.play();
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
catch {
|
|
323
|
+
return done?.();
|
|
324
|
+
}
|
|
325
|
+
first.onfinish = () => {
|
|
326
|
+
first.onfinish = null;
|
|
327
|
+
done?.();
|
|
328
|
+
};
|
|
329
|
+
},
|
|
330
|
+
forward: () => {
|
|
331
|
+
if (animations[0])
|
|
332
|
+
animations[0].onfinish = null;
|
|
333
|
+
each((item) => (item.playbackRate = 1));
|
|
334
|
+
each((item) => item.play());
|
|
335
|
+
},
|
|
336
|
+
seek: (time) => each((item) => (item.currentTime = Math.max(0, time + lead))),
|
|
239
337
|
cancel: () => each((item) => item.cancel()),
|
|
240
338
|
period,
|
|
241
339
|
animations,
|
|
340
|
+
clock,
|
|
242
341
|
};
|
|
243
342
|
};
|
package/dist/iconplease.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var M={cdnUrl:"https://cdn.iconplease.com",apiUrl:"https://api.iconplease.com",revalidate:3600},k={...M},Z=(e={})=>{if(e.apiKey&&e.apiKey.startsWith("ip_sk_"))throw new Error("iconplease: that is a secret key. init() runs in the browser, where the key is readable by anyone \u2014 use the publishable key (ip_pk_\u2026).");if(e.apiKey&&!/^ip_pk_[A-Za-z0-9]{32}$/.test(e.apiKey)&&console.warn("iconplease: that does not look like a publishable key (ip_pk_ followed by 32 characters). Set icons will not load."),e.token!==void 0&&typeof e.token!="function")throw new Error('iconplease: token must be a function that asks your server for a fresh token, e.g. () => fetch("/api/iconplease-token").then((r) => r.json()).');return k={...M,...e},k};var Q=()=>{var e;return((e=k.cdnUrl)!=null?e:M.cdnUrl).replace(/\/+$/,"")},ee=()=>{var e;return Math.max(0,(e=k.revalidate)!=null?e:M.revalidate)*1e3},te=()=>{var e;return((e=k.apiUrl)!=null?e:M.apiUrl).replace(/\/+$/,"")},ne=()=>k.apiKey||void 0,$=()=>k.token,ve=()=>k.set;var et=/<\s*(script|foreignObject|iframe|object|embed|style)\b[\s\S]*?(<\s*\/\s*\1\s*>|\/>)/gi,tt=/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,nt=/\s+(?:xlink:)?href\s*=\s*("\s*javascript:[^"]*"|'\s*javascript:[^']*')/gi,ot=/^[a-z][a-z0-9-]*$/,rt=/^[^"<>]*$/,st=e=>e.replace(et,"").replace(tt,"").replace(nt,""),oe=e=>{var r;if(!e||typeof e!="object")return;let t=e;if(typeof t.body!="string"||typeof t.viewBox!="string"||!/^[0-9.\s-]+$/.test(t.viewBox))return;let n={};for(let[o,s]of Object.entries((r=t.attrs)!=null?r:{}))ot.test(o)&&!o.startsWith("on")&&typeof s=="string"&&rt.test(s)&&(n[o]=s);return{viewBox:t.viewBox,attrs:n,body:st(t.body)}};var Oe="iconplease:index:v2",Pe="iconplease:icons:v2",Me="iconplease:set:v1",it=1e3,C=/^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/,g={status:"idle",revision:0},Y=0,z,Ae=!1,Se=!1,re,I=new Map,T=new Map,ie,_=0,O=!1,R,ae=!1,se=new Map,P=null,ce=0,at=6e4,D,U=null,le=new Map,F=new Map,ct=()=>{let e=ve();if(e!==D&&(D=e,le.clear(),F.clear(),U=null,!(!e||e.format!==1||typeof e.icons!="object"))){U=typeof e.version=="number"?e.version:null;for(let[t,n]of Object.entries(e.icons)){if(!C.test(t)||typeof(n==null?void 0:n.svg)!="string")continue;let r=q(n.svg);r&&(n.source==="public"?F:le).set(t,r)}}},lt=()=>P!==null&&(U===null||P>U),E=e=>{var t,n;return D?lt()?(t=T.get(e))!=null?t:F.get(e):(n=le.get(e))!=null?n:F.get(e):T.get(e)};var fe=new Set,L=()=>{try{return typeof localStorage=="undefined"?void 0:localStorage}catch{return}},A=(e={})=>{g={...g,...e,revision:g.revision+1};for(let t of fe)t()},V=(e,t)=>`${e}@${t}`,$e=e=>{if(!e||typeof e!="object")return;let t=e;if(t.format!==2||typeof t.hash!="string"||!t.icons||typeof t.icons!="object")return;let n=Object.entries(t.icons).filter(([r,o])=>C.test(r)&&Number.isInteger(o)&&o>0);return{format:2,hash:t.hash,icons:Object.fromEntries(n)}},ft=e=>e.slice(0,14),j=()=>{if($())return"token";let e=ne();return e?ft(e):void 0},dt=6e4,ut=9*6e4,K,N,pt=(e=!1)=>{let t=$();return t?!e&&K&&K.expiresAt-dt>Date.now()?Promise.resolve(K.token):N||(N=t().then(n=>{let r=typeof n=="string"?n:n==null?void 0:n.token;if(typeof r!="string"||!r.startsWith("ipt_"))throw new Error("your token function did not return an iconplease token (ipt_\u2026).");let o=typeof n=="string"?void 0:n.expiresAt,s=typeof o=="number"?o:o?Date.parse(o):NaN;return K={token:r,expiresAt:Number.isFinite(s)?s:Date.now()+ut},r}).finally(()=>{N=void 0}),N):Promise.reject(new Error("no token source"))},gt=()=>{var t,n,r;let e=j();if(e!==ie&&(ie=e,T.clear(),_=0,O=!1,R=void 0,ae=!1,P=null,ce=0,!!e))try{if(e==="token")return;let o=JSON.parse((n=(t=L())==null?void 0:t.getItem(Me))!=null?n:"null");if(!o||o.tag!==e)return;for(let[s,i]of Object.entries((r=o.icons)!=null?r:{})){let a=C.test(s)&&typeof(i==null?void 0:i.svg)=="string"?q(i.svg):void 0;a&&T.set(s,a)}_=typeof o.checkedAt=="number"?o.checkedAt:0,P=typeof o.version=="number"?o.version:null,O=!0}catch{return}},S=()=>{var t,n;if(ct(),gt(),Ae)return;Ae=!0;let e=L();if(e){try{let r=JSON.parse((t=e.getItem(Oe))!=null?t:"null"),o=$e(r==null?void 0:r.index);o&&(g={status:"ready",index:o,revision:g.revision},Y=typeof(r==null?void 0:r.checkedAt)=="number"?r.checkedAt:0)}catch{return}try{let r=JSON.parse((n=e.getItem(Pe))!=null?n:"{}");for(let[o,s]of Object.entries(r)){let i=oe(s);i&&I.set(o,i)}}catch{return}}},Ee=()=>{var e;try{(e=L())==null||e.setItem(Oe,JSON.stringify({index:g.index,checkedAt:Y}))}catch{return}},Ne=()=>{re||(re=setTimeout(()=>{var n,r,o;re=void 0;let e=(r=(n=g.index)==null?void 0:n.icons)!=null?r:{},t=[...I.entries()].filter(([s])=>{let i=s.lastIndexOf("@");return e[s.slice(0,i)]===Number(s.slice(i+1))});try{(o=L())==null||o.setItem(Pe,JSON.stringify(Object.fromEntries(t.slice(-it))))}catch{return}},0))},Ie=async e=>{let t=await fetch(e);if(!t.ok)throw new Error(`${t.status} for ${e}`);return t.json()},Re=e=>{Se||(Se=!0,console.warn("iconplease: could not reach the icon CDN.",e))},mt=async()=>{var o;let e=Q(),t=await Ie(`${e}/catalogue/latest.json`);if((t==null?void 0:t.format)!==2||typeof t.hash!="string"||typeof t.index!="string")throw new Error("iconplease: the catalogue pointer is malformed");if(Y=Date.now(),((o=g.index)==null?void 0:o.hash)===t.hash){Ee();return}let n=t.index.replace(/^\/+/,"");if(!/^catalogue\/index-[a-z0-9]+\.json$/.test(n))throw new Error("iconplease: unexpected index location");let r=$e(await Ie(`${e}/${n}`));if(!r)throw new Error("iconplease: the icon index is malformed");A({status:"ready",index:r}),Ee(),Ne()},de=(e={})=>{if(S(),g.index&&Date.now()-Y<ee()&&!e.force)return Promise.resolve();if(z)return z;let n=mt().catch(r=>{g.index||A({status:"error"}),Re(r)}).finally(()=>{z=void 0});return z=n,!g.index&&g.status!=="loading"&&A({status:"loading"}),n},q=e=>{let t=/<svg\b([^>]*)>([\s\S]*)<\/svg>\s*$/.exec(e.trim());if(!t)return;let n={},r="0 0 24 24";for(let[,o,s]of t[1].matchAll(/([a-zA-Z:-]+)="([^"]*)"/g))o==="viewBox"?r=s:["xmlns","width","height","aria-hidden","role","class","style"].includes(o)||(n[o]=s);return oe({viewBox:r,attrs:n,body:t[2]})},ht=(e,t)=>{let n=V(e,t),r=se.get(n);if(r)return r;let o=fetch(`${Q()}/v${t}/${e}.svg`).then(async s=>{if(!s.ok)throw new Error(`${s.status} for ${e}`);let i=q(await s.text());if(!i)throw new Error(`iconplease: "${e}" is not a valid SVG`);I.set(n,i),Ne(),A()}).catch(Re).finally(()=>{se.delete(n)});return se.set(n,o),o},Te=async(e=!1)=>{var n;if(!$()){let r=(n=ne())!=null?n:"";return fetch(`${te()}/sdk/set?key=${encodeURIComponent(r)}`)}let t=await pt(e);return fetch(`${te()}/sdk/set`,{headers:{Authorization:`Bearer ${t}`}})},yt=async e=>{var s,i;let t=await Te();t.status===401&&$()&&(t=await Te(!0));let n=await t.json().catch(()=>({}));if(!t.ok)throw new Error(n.error||`HTTP ${t.status}`);let r=new Map,o={};for(let[a,c]of Object.entries((s=n.icons)!=null?s:{})){if(!C.test(a)||typeof(c==null?void 0:c.svg)!="string")continue;let u=q(c.svg);u&&(r.set(a,u),o[a]={version:Number(c.version)||1,svg:c.svg})}if(e===ie){T.clear();for(let[a,c]of r)T.set(a,c);_=Date.now(),O=!0,P=typeof n.version=="number"?n.version:null;try{e!=="token"&&((i=L())==null||i.setItem(Me,JSON.stringify({tag:e,checkedAt:_,version:P,icons:o})))}catch{A();return}A()}},ue=(e={})=>{S();let t=j();if(!t||O&&Date.now()-_<ee()&&!e.force||!e.force&&Date.now()<ce)return Promise.resolve();if(R)return R;let r=yt(t).catch(o=>{O=!0,ce=Date.now()+at,ae||(ae=!0,console.warn(`iconplease: could not load your icon set \u2014 ${o instanceof Error?o.message:String(o)} Falling back to public icons.`)),A()}).finally(()=>{R=void 0});return R=r,r},pe=async e=>{var r,o;if(!C.test(e))return;if(S(),j()){if(E(e)){ue();return}if(await ue(),E(e))return}else if(E(e))return;let t=(r=g.index)==null?void 0:r.icons[e];if(t&&I.has(V(e,t))){de();return}await de();let n=(o=g.index)==null?void 0:o.icons[e];n&&!I.has(V(e,n))&&await ht(e,n)},ge=async(e={})=>{let{icons:t=[],force:n=!1}=Array.isArray(e)?{icons:e}:e;S(),!(D&&!j()&&t.every(o=>E(o)))&&(await Promise.all([D?Promise.resolve():de({force:n}),ue({force:n})]),await Promise.all(t.map(pe)))},_e=e=>(S(),fe.add(e),()=>fe.delete(e));var J=e=>{var r;S();let t=E(e);if(t)return t;let n=(r=g.index)==null?void 0:r.icons[e];return n?I.get(V(e,n)):void 0},De=e=>(S(),E(e)||j()&&!O?!1:g.status==="ready"&&!!g.index&&!(e in g.index.icons));var bt=/^[#a-zA-Z0-9(),.%\s-]{1,64}$/,xt=/[<>"&]/g,wt={"<":"<",">":">",'"':""","&":"&"},kt=e=>e.replace(xt,t=>wt[t]),Ce=e=>String(Number(e.toFixed(3))),vt=(e,t)=>e.replace(/\b(fill|stroke)="currentColor"/g,`$1="${t}"`),At=(e,t)=>e.replace(/\bstroke-width="([0-9]*\.?[0-9]+)"/g,(n,r)=>`stroke-width="${Ce(Number(r)*t)}"`),me=(e,t={})=>{var d;let{size:n=24,color:r,strokeScale:o,motion:s,label:i,className:a}=t,c=r&&bt.test(r)?r:void 0,u=typeof o=="number"&&Number.isFinite(o)&&o>0&&o!==1?o:void 0,l={...(d=e.attrs)!=null?d:{}};if(c)for(let f of["fill","stroke"])l[f]==="currentColor"&&(l[f]=c);u&&l["stroke-width"]&&(l["stroke-width"]=Ce(Number(l["stroke-width"])*u));let p=e.body;return c&&(p=vt(p,c)),u&&(p=At(p,u)),l.width=String(n),l.height=String(n),l.viewBox=e.viewBox,s&&s!=="none"&&(l["data-motion"]=s),i?(l.role="img",l["aria-label"]=i):l["aria-hidden"]="true",a&&(l.class=a),{attrs:l,body:p}},he=({attrs:e,body:t})=>`<svg xmlns="http://www.w3.org/2000/svg" ${Object.entries(e).map(([r,o])=>`${r}="${kt(o)}"`).join(" ")}>${t}</svg>`,Le=(e,t={})=>{let n=typeof e=="string"?J(e):e;return n?he(me(n,t)):void 0};var B={draw:{label:"Draw on",hint:"Strokes draw themselves",duration:700,easing:"ease-in-out",draw:!0},fade:{label:"Fade in",hint:"From invisible to visible",duration:400,easing:"ease-out",frames:[{offset:0,opacity:0},{offset:1,opacity:1}]},pop:{label:"Pop in",hint:"Grows from nothing with a little overshoot",duration:450,easing:"spring",frames:[{offset:0,transform:"scale(0)"},{offset:1,transform:"scale(1)"}]},spin:{label:"Spin",hint:"One full turn",duration:800,easing:"ease-in-out",frames:[{offset:0,transform:"rotate(0deg)"},{offset:1,transform:"rotate(360deg)"}]},"slide-up":{label:"Slide up",hint:"Rises into place",duration:450,easing:"ease-out",frames:[{offset:0,transform:"translateY(4px)",opacity:0},{offset:1,transform:"translateY(0px)",opacity:1}]},"slide-down":{label:"Slide down",hint:"Drops into place",duration:450,easing:"ease-out",frames:[{offset:0,transform:"translateY(-4px)",opacity:0},{offset:1,transform:"translateY(0px)",opacity:1}]},"slide-left":{label:"Slide left",hint:"Comes in from the right",duration:450,easing:"ease-out",frames:[{offset:0,transform:"translateX(4px)",opacity:0},{offset:1,transform:"translateX(0px)",opacity:1}]},"slide-right":{label:"Slide right",hint:"Comes in from the left",duration:450,easing:"ease-out",frames:[{offset:0,transform:"translateX(-4px)",opacity:0},{offset:1,transform:"translateX(0px)",opacity:1}]},bounce:{label:"Bounce",hint:"Hops up and lands",duration:700,easing:"ease-out",frames:[{offset:0,transform:"translateY(0px)"},{offset:.35,transform:"translateY(-4px)"},{offset:.65,transform:"translateY(0px)"},{offset:.82,transform:"translateY(-1.5px)"},{offset:1,transform:"translateY(0px)"}]},pulse:{label:"Pulse",hint:"Swells and settles",duration:600,easing:"ease-in-out",frames:[{offset:0,transform:"scale(1)"},{offset:.5,transform:"scale(1.18)"},{offset:1,transform:"scale(1)"}]},follow:{label:"Move along path",hint:"The shape's centre travels along a route you drew",duration:1200,easing:"ease-in-out",route:!0},shake:{label:"Shake",hint:"A quick wobble",duration:600,easing:"ease-in-out",frames:[{offset:0,transform:"rotate(0deg)"},{offset:.2,transform:"rotate(-14deg)"},{offset:.4,transform:"rotate(12deg)"},{offset:.6,transform:"rotate(-8deg)"},{offset:.8,transform:"rotate(4deg)"},{offset:1,transform:"rotate(0deg)"}]}},St=Object.keys(B).filter(e=>!B[e].route),Et=/^[MmLlHhVvCcSsQqTtAaZz0-9eE.,\s+-]{1,8000}$/,Ge={linear:{label:"Linear",css:"linear"},"ease-in":{label:"Ease in",css:"cubic-bezier(0.4, 0, 1, 1)"},"ease-out":{label:"Ease out",css:"cubic-bezier(0, 0, 0.2, 1)"},"ease-in-out":{label:"Ease in-out",css:"cubic-bezier(0.4, 0, 0.2, 1)"},spring:{label:"Spring",css:"cubic-bezier(0.34, 1.56, 0.64, 1)"}},It={load:"When it appears",hover:"On hover",click:"On click",visible:"When scrolled into view"},Tt=64,ye=1e4,ze=50,Ot=new Set(St),je=/^[A-Za-z0-9_-]{1,64}$/,be=(e,t,n)=>typeof e=="number"&&Number.isFinite(e)?Math.round(Math.min(Math.max(e,t),n)):void 0,Pt=e=>{var r;if(!e||typeof e!="object")return;let t=e,n=[];for(let o of Array.isArray(t.clips)?t.clips.slice(0,Tt):[]){if(!o||typeof o!="object")continue;let s=be(o.start,0,ye),i=be(o.duration,ze,ye);if(typeof o.id!="string"||!je.test(o.id)||typeof o.target!="string"||!je.test(o.target)||!Ot.has(o.preset)||s===void 0||i===void 0)continue;let a=B[o.preset].route;a&&(typeof o.path!="string"||!Et.test(o.path)||!/^\s*[Mm]/.test(o.path))||n.push({id:o.id,target:o.target,preset:o.preset,start:s,duration:i,easing:o.easing&&o.easing in Ge?o.easing:B[o.preset].easing,...a?{path:o.path,orient:o.orient===!0}:{}})}if(n.length)return{version:1,trigger:t.trigger&&t.trigger in It?t.trigger:"load",loop:t.loop===!0,loopGap:(r=be(t.loopGap,0,ye))!=null?r:0,clips:n}},we="data-ip-animation",Ke="data-ip";var Mt=e=>atob(e.replace(/-/g,"+").replace(/_/g,"/"));var Ue=e=>{if(!(!e||e.length>6e4||!/^[A-Za-z0-9_-]+$/.test(e)))try{return Pt(JSON.parse(Mt(e)))}catch{return}},$t=e=>e.clips.reduce((t,n)=>Math.max(t,n.start+n.duration),0),Nt="path, line, rect, ellipse, circle, polyline, polygon",Rt=e=>[...e.querySelectorAll(Nt)].filter(t=>{var r;if(t.closest("defs, clipPath, mask"))return!1;let n=(r=t.getAttribute("stroke"))!=null?r:getComputedStyle(t).stroke;return!!n&&n!=="none"&&n!=="transparent"&&typeof t.getTotalLength=="function"}),_t="http://www.w3.org/2000/svg",xe=48,Dt=(e,t,n)=>{var s;let r=(s=e.ownerSVGElement)!=null?s:e.closest("svg");if(!r||typeof e.getBBox!="function")return[];let o=document.createElementNS(_t,"path");o.setAttribute("d",t),o.setAttribute("visibility","hidden"),r.appendChild(o);try{let i=o.getTotalLength(),a=e.getBBox(),c=a.x+a.width/2,u=a.y+a.height/2,l=h=>o.getPointAtLength(Math.min(Math.max(h,0),i)),p=h=>{let m=Math.max(i/400,.01),b=l(h-m),y=l(h+m);return Math.atan2(y.y-b.y,y.x-b.x)*180/Math.PI},d=p(0),f=0;return Array.from({length:xe+1},(h,m)=>{let b=m/xe*i,y=l(b),x=p(b)-d;for(;x-f>180;)x-=360;for(;x-f<-180;)x+=360;f=x;let G=`translate(${(y.x-c).toFixed(3)}px, ${(y.y-u).toFixed(3)}px)`;return{offset:m/xe,transform:n?`${G} rotate(${x.toFixed(2)}deg)`:G}})}finally{o.remove()}},Be=(e,t,n,r)=>{let o=t.start/n,s=(t.start+t.duration)/n,i=Ge[t.easing].css,a=e.map((p,d)=>({...p,offset:o+p.offset*(s-o),easing:d<e.length-1?i:"linear"})),c={...r!=null?r:e[0],offset:0,easing:"linear"},u={...e[e.length-1],offset:1,easing:"linear"},l=[];return a[0].offset>0&&(l.push(c),r&&l.push({...r,offset:a[0].offset,easing:"linear"})),l.push(...a),a[a.length-1].offset<1&&l.push(u),l},Fe=(e,t,n={})=>{var u,l,p;let r=Math.max($t(e),ze),o=(u=n.loop)!=null?u:e.loop,s=o?r+e.loopGap:r,i=[],a={duration:s,iterations:o?1/0:1,fill:"both"};for(let d of e.clips){let f=B[d.preset],h=e.clips.some(m=>m.target===d.target&&m.start<d.start);for(let m of t(d.target)){if(f.draw){for(let w of Rt(m)){let v=Math.max(w.getTotalLength(),.01),Ze=[{offset:0,strokeDasharray:`${v} ${v}`,strokeDashoffset:v},{offset:1,strokeDasharray:`${v} ${v}`,strokeDashoffset:0}],Qe=h?{offset:0,strokeDasharray:`${v} ${v}`,strokeDashoffset:0}:void 0;i.push(w.animate(Be(Ze,d,s,Qe),a))}continue}let b=m;b.style.transformBox="fill-box",b.style.transformOrigin="center";let y=f.route?Dt(m,(l=d.path)!=null?l:"",d.orient===!0):((p=f.frames)!=null?p:[]).map(w=>({...w}));if(!y.length)continue;let x=y.some(w=>w.transform!==void 0),G=y.some(w=>w.opacity!==void 0),We=h?{offset:0,...x?{transform:"translate(0px, 0px)"}:{},...G?{opacity:1}:{}}:void 0;i.push(b.animate(Be(y,d,s,We),{...a,composite:x?"add":"replace"}))}}let c=d=>i.forEach(d);return n.paused&&c(d=>d.pause()),{play:()=>c(d=>d.play()),pause:()=>c(d=>d.pause()),seek:d=>c(f=>f.currentTime=Math.max(0,d)),cancel:()=>c(d=>d.cancel()),period:s,animations:i}};var H=new WeakMap,Ct=()=>typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,Ve=e=>{var t,n;return(n=(t=e.closest("a, button, [role=button], label, summary"))!=null?t:e.parentElement)!=null?n:e},X=(e,t={})=>{var l,p,d;(l=H.get(e))==null||l();let n=Ue(e.getAttribute(we));if(!n||typeof e.animate!="function")return()=>{};if((p=t.reducedMotion)!=null?p:Ct())return()=>{};let r=(d=t.trigger)!=null?d:n.trigger,o=f=>[...e.querySelectorAll(`[${Ke}="${f}"]`)],s,i=[],a=()=>{s==null||s.cancel(),s=void 0},c=()=>{a(),s=Fe(n,o)};if(r==="load"&&c(),r==="hover"){let f=Ve(e);f.addEventListener("pointerenter",c),f.addEventListener("pointerleave",a),f.addEventListener("focusin",c),f.addEventListener("focusout",a),i.push(()=>{f.removeEventListener("pointerenter",c),f.removeEventListener("pointerleave",a),f.removeEventListener("focusin",c),f.removeEventListener("focusout",a)})}if(r==="click"){let f=Ve(e);f.addEventListener("click",c),i.push(()=>f.removeEventListener("click",c))}if(r==="visible")if(typeof IntersectionObserver=="function"){let f=new IntersectionObserver(h=>{h.some(m=>m.isIntersecting)&&(f.disconnect(),c())},{threshold:.5});f.observe(e),i.push(()=>f.disconnect())}else c();let u=()=>{a(),i.forEach(f=>f()),H.delete(e)};return H.set(e,u),u},Ye=(e=document)=>{e.querySelectorAll(`svg[${we}]`).forEach(t=>{H.has(t)||X(t)})};var qe="[data-icon], i.ip[class*='ip-']",Lt=new Set(["none","wiggle","pop","bounce","draw"]),Je=new Set,jt=e=>{let t=e.getAttribute("data-icon");if(t)return t;for(let n of Array.from(e.classList))if(n.startsWith("ip-")&&n.length>3)return n.slice(3)},He=e=>{if(e===null)return;let t=Number(e);return Number.isFinite(t)&&t>0?t:void 0},ke=e=>{var c,u,l,p;let t=jt(e);if(!t)return;let n=J(t),r=e.getAttribute("data-motion"),o=r&&Lt.has(r)?r:void 0,s={size:(c=He(e.getAttribute("data-size")))!=null?c:24,color:(u=e.getAttribute("data-color"))!=null?u:void 0,strokeScale:He(e.getAttribute("data-stroke")),motion:o,label:(l=e.getAttribute("data-label"))!=null?l:void 0},i=JSON.stringify([t,s,n?"1":"0"]);if(e.getAttribute("data-ip-rendered")===i)return;if(!n){De(t)?Je.has(t)||(Je.add(t),console.warn(`iconplease: no icon named "${t}".`)):pe(t);return}e.innerHTML=he(me(n,s)),e.setAttribute("data-ip-rendered",i);let a=e.querySelector("svg");a&&X(a),e.tagName==="I"&&((p=e.style).display||(p.display="inline-flex"))},W=(e=document)=>{e instanceof Element&&e.matches(qe)&&ke(e),e.querySelectorAll(qe).forEach(ke)},Xe=()=>{let e=window.iconpleaseConfig;e&&Z(e),_e(()=>W()),W(),ge(),new MutationObserver(t=>{for(let n of t)n.type==="attributes"&&n.target instanceof Element&&ke(n.target),n.addedNodes.forEach(r=>{r instanceof Element&&W(r)})}).observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-icon","data-size","data-color","data-stroke","data-motion","data-label","class"]})};window.iconplease={init:Z,load:ge,renderSVG:Le,attachAnimation:X,attachAll:Ye,refresh:()=>W()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Xe,{once:!0}):Xe();})();
|
|
1
|
+
"use strict";(()=>{var D={cdnUrl:"https://cdn.iconplease.com",apiUrl:"https://api.iconplease.com",revalidate:3600},E={...D},oe=(e={})=>{if(e.apiKey&&e.apiKey.startsWith("ip_sk_"))throw new Error("iconplease: that is a secret key. init() runs in the browser, where the key is readable by anyone \u2014 use the publishable key (ip_pk_\u2026).");if(e.apiKey&&!/^ip_pk_[A-Za-z0-9]{32}$/.test(e.apiKey)&&console.warn("iconplease: that does not look like a publishable key (ip_pk_ followed by 32 characters). Set icons will not load."),e.token!==void 0&&typeof e.token!="function")throw new Error('iconplease: token must be a function that asks your server for a fresh token, e.g. () => fetch("/api/iconplease-token").then((r) => r.json()).');return E={...D,...e},E};var re=()=>{var e;return((e=E.cdnUrl)!=null?e:D.cdnUrl).replace(/\/+$/,"")},se=()=>{var e;return Math.max(0,(e=E.revalidate)!=null?e:D.revalidate)*1e3},ie=()=>{var e;return((e=E.apiUrl)!=null?e:D.apiUrl).replace(/\/+$/,"")},ae=()=>E.apiKey||void 0,C=()=>E.token,Oe=()=>E.set;var it=/<\s*(script|foreignObject|iframe|object|embed|style)\b[\s\S]*?(<\s*\/\s*\1\s*>|\/>)/gi,at=/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,ct=/\s+(?:xlink:)?href\s*=\s*("\s*javascript:[^"]*"|'\s*javascript:[^']*')/gi,lt=/^[a-z][a-z0-9-]*$/,ft=/^[^"<>]*$/,dt=e=>e.replace(it,"").replace(at,"").replace(ct,""),ce=e=>{var o;if(!e||typeof e!="object")return;let t=e;if(typeof t.body!="string"||typeof t.viewBox!="string"||!/^[0-9.\s-]+$/.test(t.viewBox))return;let n={};for(let[r,s]of Object.entries((o=t.attrs)!=null?o:{}))lt.test(r)&&!r.startsWith("on")&&typeof s=="string"&&ft.test(s)&&(n[r]=s);return{viewBox:t.viewBox,attrs:n,body:dt(t.body)}};var _e="iconplease:index:v2",De="iconplease:icons:v2",Ce="iconplease:set:v1",ut=1e3,L=/^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/,b={status:"idle",revision:0},J=0,U,Pe=!1,Me=!1,le,M=new Map,R=new Map,de,B=0,$=!1,G,ue=!1,fe=new Map,N=null,pe=0,pt=6e4,K,V=null,ge=new Map,q=new Map,gt=()=>{let e=Oe();if(e!==K&&(K=e,ge.clear(),q.clear(),V=null,!(!e||e.format!==1||typeof e.icons!="object"))){V=typeof e.version=="number"?e.version:null;for(let[t,n]of Object.entries(e.icons)){if(!L.test(t)||typeof(n==null?void 0:n.svg)!="string")continue;let o=X(n.svg);o&&(n.source==="public"?q:ge).set(t,o)}}},mt=()=>N!==null&&(V===null||N>V),P=e=>{var t,n;return K?mt()?(t=R.get(e))!=null?t:q.get(e):(n=ge.get(e))!=null?n:q.get(e):R.get(e)};var me=new Set,F=()=>{try{return typeof localStorage=="undefined"?void 0:localStorage}catch{return}},T=(e={})=>{b={...b,...e,revision:b.revision+1};for(let t of me)t()},H=(e,t)=>`${e}@${t}`,je=e=>{if(!e||typeof e!="object")return;let t=e;if(t.format!==2||typeof t.hash!="string"||!t.icons||typeof t.icons!="object")return;let n=Object.entries(t.icons).filter(([o,r])=>L.test(o)&&Number.isInteger(r)&&r>0);return{format:2,hash:t.hash,icons:Object.fromEntries(n)}},ht=e=>e.slice(0,14),z=()=>{if(C())return"token";let e=ae();return e?ht(e):void 0},yt=6e4,bt=9*6e4,Y,j,kt=(e=!1)=>{let t=C();return t?!e&&Y&&Y.expiresAt-yt>Date.now()?Promise.resolve(Y.token):j||(j=t().then(n=>{let o=typeof n=="string"?n:n==null?void 0:n.token;if(typeof o!="string"||!o.startsWith("ipt_"))throw new Error("your token function did not return an iconplease token (ipt_\u2026).");let r=typeof n=="string"?void 0:n.expiresAt,s=typeof r=="number"?r:r?Date.parse(r):NaN;return Y={token:o,expiresAt:Number.isFinite(s)?s:Date.now()+bt},o}).finally(()=>{j=void 0}),j):Promise.reject(new Error("no token source"))},xt=()=>{var t,n,o;let e=z();if(e!==de&&(de=e,R.clear(),B=0,$=!1,G=void 0,ue=!1,N=null,pe=0,!!e))try{if(e==="token")return;let r=JSON.parse((n=(t=F())==null?void 0:t.getItem(Ce))!=null?n:"null");if(!r||r.tag!==e)return;for(let[s,l]of Object.entries((o=r.icons)!=null?o:{})){let d=L.test(s)&&typeof(l==null?void 0:l.svg)=="string"?X(l.svg):void 0;d&&R.set(s,d)}B=typeof r.checkedAt=="number"?r.checkedAt:0,N=typeof r.version=="number"?r.version:null,$=!0}catch{return}},O=()=>{var t,n;if(gt(),xt(),Pe)return;Pe=!0;let e=F();if(e){try{let o=JSON.parse((t=e.getItem(_e))!=null?t:"null"),r=je(o==null?void 0:o.index);r&&(b={status:"ready",index:r,revision:b.revision},J=typeof(o==null?void 0:o.checkedAt)=="number"?o.checkedAt:0)}catch{return}try{let o=JSON.parse((n=e.getItem(De))!=null?n:"{}");for(let[r,s]of Object.entries(o)){let l=ce(s);l&&M.set(r,l)}}catch{return}}},Re=()=>{var e;try{(e=F())==null||e.setItem(_e,JSON.stringify({index:b.index,checkedAt:J}))}catch{return}},Ge=()=>{le||(le=setTimeout(()=>{var n,o,r;le=void 0;let e=(o=(n=b.index)==null?void 0:n.icons)!=null?o:{},t=[...M.entries()].filter(([s])=>{let l=s.lastIndexOf("@");return e[s.slice(0,l)]===Number(s.slice(l+1))});try{(r=F())==null||r.setItem(De,JSON.stringify(Object.fromEntries(t.slice(-ut))))}catch{return}},0))},$e=async e=>{let t=await fetch(e);if(!t.ok)throw new Error(`${t.status} for ${e}`);return t.json()},Be=e=>{Me||(Me=!0,console.warn("iconplease: could not reach the icon CDN.",e))},wt=async()=>{var r;let e=re(),t=await $e(`${e}/catalogue/latest.json`);if((t==null?void 0:t.format)!==2||typeof t.hash!="string"||typeof t.index!="string")throw new Error("iconplease: the catalogue pointer is malformed");if(J=Date.now(),((r=b.index)==null?void 0:r.hash)===t.hash){Re();return}let n=t.index.replace(/^\/+/,"");if(!/^catalogue\/index-[a-z0-9]+\.json$/.test(n))throw new Error("iconplease: unexpected index location");let o=je(await $e(`${e}/${n}`));if(!o)throw new Error("iconplease: the icon index is malformed");T({status:"ready",index:o}),Re(),Ge()},he=(e={})=>{if(O(),b.index&&Date.now()-J<se()&&!e.force)return Promise.resolve();if(U)return U;let n=wt().catch(o=>{b.index||T({status:"error"}),Be(o)}).finally(()=>{U=void 0});return U=n,!b.index&&b.status!=="loading"&&T({status:"loading"}),n},X=e=>{let t=/<svg\b([^>]*)>([\s\S]*)<\/svg>\s*$/.exec(e.trim());if(!t)return;let n={},o="0 0 24 24";for(let[,r,s]of t[1].matchAll(/([a-zA-Z:-]+)="([^"]*)"/g))r==="viewBox"?o=s:["xmlns","width","height","aria-hidden","role","class","style"].includes(r)||(n[r]=s);return ce({viewBox:o,attrs:n,body:t[2]})},At=(e,t)=>{let n=H(e,t),o=fe.get(n);if(o)return o;let r=fetch(`${re()}/v${t}/${e}.svg`).then(async s=>{if(!s.ok)throw new Error(`${s.status} for ${e}`);let l=X(await s.text());if(!l)throw new Error(`iconplease: "${e}" is not a valid SVG`);M.set(n,l),Ge(),T()}).catch(Be).finally(()=>{fe.delete(n)});return fe.set(n,r),r},Ne=async(e=!1)=>{var n;if(!C()){let o=(n=ae())!=null?n:"";return fetch(`${ie()}/sdk/set?key=${encodeURIComponent(o)}`)}let t=await kt(e);return fetch(`${ie()}/sdk/set`,{headers:{Authorization:`Bearer ${t}`}})},St=async e=>{var s,l;let t=await Ne();t.status===401&&C()&&(t=await Ne(!0));let n=await t.json().catch(()=>({}));if(!t.ok)throw new Error(n.error||`HTTP ${t.status}`);let o=new Map,r={};for(let[d,i]of Object.entries((s=n.icons)!=null?s:{})){if(!L.test(d)||typeof(i==null?void 0:i.svg)!="string")continue;let g=X(i.svg);g&&(o.set(d,g),r[d]={version:Number(i.version)||1,svg:i.svg})}if(e===de){R.clear();for(let[d,i]of o)R.set(d,i);B=Date.now(),$=!0,N=typeof n.version=="number"?n.version:null;try{e!=="token"&&((l=F())==null||l.setItem(Ce,JSON.stringify({tag:e,checkedAt:B,version:N,icons:r})))}catch{T();return}T()}},ye=(e={})=>{O();let t=z();if(!t||$&&Date.now()-B<se()&&!e.force||!e.force&&Date.now()<pe)return Promise.resolve();if(G)return G;let o=St(t).catch(r=>{$=!0,pe=Date.now()+pt,ue||(ue=!0,console.warn(`iconplease: could not load your icon set \u2014 ${r instanceof Error?r.message:String(r)} Falling back to public icons.`)),T()}).finally(()=>{G=void 0});return G=o,o},be=async e=>{var o,r;if(!L.test(e))return;if(O(),z()){if(P(e)){ye();return}if(await ye(),P(e))return}else if(P(e))return;let t=(o=b.index)==null?void 0:o.icons[e];if(t&&M.has(H(e,t))){he();return}await he();let n=(r=b.index)==null?void 0:r.icons[e];n&&!M.has(H(e,n))&&await At(e,n)},ke=async(e={})=>{let{icons:t=[],force:n=!1}=Array.isArray(e)?{icons:e}:e;O(),!(K&&!z()&&t.every(r=>P(r)))&&(await Promise.all([K?Promise.resolve():he({force:n}),ye({force:n})]),await Promise.all(t.map(be)))},Ke=e=>(O(),me.add(e),()=>me.delete(e));var W=e=>{var o;O();let t=P(e);if(t)return t;let n=(o=b.index)==null?void 0:o.icons[e];return n?M.get(H(e,n)):void 0},Le=e=>(O(),P(e)||z()&&!$?!1:b.status==="ready"&&!!b.index&&!(e in b.index.icons));var vt=/^[#a-zA-Z0-9(),.%\s-]{1,64}$/,Et=/[<>"&]/g,It={"<":"<",">":">",'"':""","&":"&"},Tt=e=>e.replace(Et,t=>It[t]),Fe=e=>String(Number(e.toFixed(3))),Ot=(e,t)=>e.replace(/\b(fill|stroke)="currentColor"/g,`$1="${t}"`),Pt=(e,t)=>e.replace(/\bstroke-width="([0-9]*\.?[0-9]+)"/g,(n,o)=>`stroke-width="${Fe(Number(o)*t)}"`),xe=(e,t={})=>{var w;let{size:n=24,color:o,strokeScale:r,motion:s,label:l,className:d}=t,i=o&&vt.test(o)?o:void 0,g=typeof r=="number"&&Number.isFinite(r)&&r>0&&r!==1?r:void 0,f={...(w=e.attrs)!=null?w:{}};if(i)for(let y of["fill","stroke"])f[y]==="currentColor"&&(f[y]=i);g&&f["stroke-width"]&&(f["stroke-width"]=Fe(Number(f["stroke-width"])*g));let p=e.body;return i&&(p=Ot(p,i)),g&&(p=Pt(p,g)),f.width=String(n),f.height=String(n),f.viewBox=e.viewBox,s&&s!=="none"&&(f["data-motion"]=s),l?(f.role="img",f["aria-label"]=l):f["aria-hidden"]="true",d&&(f.class=d),{attrs:f,body:p}},we=({attrs:e,body:t})=>`<svg xmlns="http://www.w3.org/2000/svg" ${Object.entries(e).map(([o,r])=>`${o}="${Tt(r)}"`).join(" ")}>${t}</svg>`,ze=(e,t={})=>{let n=typeof e=="string"?W(e):e;return n?we(xe(n,t)):void 0};var Ve=["appear","hover","click"];var Z=e=>e==="hover"?"hover":e==="click"||e==="toggle"?"click":"appear",_={draw:{label:"Draw on",hint:"Strokes draw themselves",duration:700,easing:"ease-in-out",draw:!0},fade:{label:"Fade in",hint:"From invisible to visible",duration:400,easing:"ease-out",frames:[{offset:0,opacity:0},{offset:1,opacity:1}]},pop:{label:"Pop in",hint:"Grows from nothing with a little overshoot",duration:450,easing:"spring",frames:[{offset:0,transform:"scale(0)"},{offset:1,transform:"scale(1)"}]},spin:{label:"Spin",hint:"One full turn",duration:800,easing:"ease-in-out",frames:[{offset:0,transform:"rotate(0deg)"},{offset:1,transform:"rotate(360deg)"}]},"slide-up":{label:"Slide up",hint:"Rises into place",duration:450,easing:"ease-out",frames:[{offset:0,transform:"translateY(4px)",opacity:0},{offset:1,transform:"translateY(0px)",opacity:1}]},"slide-down":{label:"Slide down",hint:"Drops into place",duration:450,easing:"ease-out",frames:[{offset:0,transform:"translateY(-4px)",opacity:0},{offset:1,transform:"translateY(0px)",opacity:1}]},"slide-left":{label:"Slide left",hint:"Comes in from the right",duration:450,easing:"ease-out",frames:[{offset:0,transform:"translateX(4px)",opacity:0},{offset:1,transform:"translateX(0px)",opacity:1}]},"slide-right":{label:"Slide right",hint:"Comes in from the left",duration:450,easing:"ease-out",frames:[{offset:0,transform:"translateX(-4px)",opacity:0},{offset:1,transform:"translateX(0px)",opacity:1}]},bounce:{label:"Bounce",hint:"Hops up and lands",duration:700,easing:"ease-out",frames:[{offset:0,transform:"translateY(0px)"},{offset:.35,transform:"translateY(-4px)"},{offset:.65,transform:"translateY(0px)"},{offset:.82,transform:"translateY(-1.5px)"},{offset:1,transform:"translateY(0px)"}]},pulse:{label:"Pulse",hint:"Swells and settles",duration:600,easing:"ease-in-out",frames:[{offset:0,transform:"scale(1)"},{offset:.5,transform:"scale(1.18)"},{offset:1,transform:"scale(1)"}]},"spin-back":{label:"Spin back",hint:"One full turn, anticlockwise",duration:800,easing:"ease-in-out",frames:[{offset:0,transform:"rotate(0deg)"},{offset:1,transform:"rotate(-360deg)"}]},"fade-out":{label:"Fade out",hint:"From visible to invisible",duration:400,easing:"ease-in",frames:[{offset:0,opacity:1},{offset:1,opacity:0}]},"pop-out":{label:"Pop out",hint:"Shrinks away to nothing",duration:350,easing:"ease-in",frames:[{offset:0,transform:"scale(1)"},{offset:1,transform:"scale(0)"}]},"slide-out-up":{label:"Slide out up",hint:"Rises and fades away",duration:400,easing:"ease-in",frames:[{offset:0,transform:"translateY(0px)",opacity:1},{offset:1,transform:"translateY(-4px)",opacity:0}]},"slide-out-down":{label:"Slide out down",hint:"Drops and fades away",duration:400,easing:"ease-in",frames:[{offset:0,transform:"translateY(0px)",opacity:1},{offset:1,transform:"translateY(4px)",opacity:0}]},follow:{label:"Move along path",hint:"The shape's centre travels along a route you drew",duration:1200,easing:"ease-in-out",route:!0},shake:{label:"Shake",hint:"A quick wobble",duration:600,easing:"ease-in-out",frames:[{offset:0,transform:"rotate(0deg)"},{offset:.2,transform:"rotate(-14deg)"},{offset:.4,transform:"rotate(12deg)"},{offset:.6,transform:"rotate(-8deg)"},{offset:.8,transform:"rotate(4deg)"},{offset:1,transform:"rotate(0deg)"}]}},en=Object.keys(_).filter(e=>!_[e].route),Mt=/^[MmLlHhVvCcSsQqTtAaZz0-9eE.,\s+-]{1,8000}$/,qe={linear:{label:"Linear",css:"linear"},"ease-in":{label:"Ease in",css:"cubic-bezier(0.4, 0, 1, 1)"},"ease-out":{label:"Ease out",css:"cubic-bezier(0, 0, 0.2, 1)"},"ease-in-out":{label:"Ease in-out",css:"cubic-bezier(0.4, 0, 0.2, 1)"},spring:{label:"Spring",css:"cubic-bezier(0.34, 1.56, 0.64, 1)"}},Rt={load:"When it appears",hover:"On hover",click:"On click",toggle:"Click to toggle",visible:"When scrolled into view"},$t=64,Ae=1e4,He=50,Nt=new Set(Object.keys(_)),Ue=/^[A-Za-z0-9_-]{1,64}$/,Se=(e,t,n)=>typeof e=="number"&&Number.isFinite(e)?Math.round(Math.min(Math.max(e,t),n)):void 0,Ee=e=>({trigger:e.trigger,loop:e.loop,loopGap:e.loopGap,...e.reverse===!0?{reverse:!0}:{},clips:e.clips}),Je=e=>{var t;return e?[Ee(e),...((t=e.stages)!=null?t:[]).map(Ee)]:[]},_t=e=>{let t=[];for(let r of Ve){let s=e.find(l=>Z(l.trigger)===r&&l.clips.length>0);s&&t.push(Ee(s))}let[n,...o]=t;if(n)return{version:1,...n,...o.length?{stages:o}:{}}},Dt=(e,t)=>{var r;if(!e||typeof e!="object")return;let n=e,o=[];for(let s of Array.isArray(n.clips)?n.clips.slice(0,t):[]){if(!s||typeof s!="object")continue;let l=Se(s.start,0,Ae),d=Se(s.duration,He,Ae);if(typeof s.id!="string"||!Ue.test(s.id)||typeof s.target!="string"||!Ue.test(s.target)||!Nt.has(s.preset)||l===void 0||d===void 0)continue;let i=_[s.preset].route;i&&(typeof s.path!="string"||!Mt.test(s.path)||!/^\s*[Mm]/.test(s.path))||o.push({id:s.id,target:s.target,preset:s.preset,start:l,duration:d,easing:s.easing&&s.easing in qe?s.easing:_[s.preset].easing,...i?{path:s.path,orient:s.orient===!0}:{}})}if(o.length)return{trigger:n.trigger&&n.trigger in Rt?n.trigger:"load",loop:n.loop===!0,loopGap:(r=Se(n.loopGap,0,Ae))!=null?r:0,...n.reverse===!0?{reverse:!0}:{},clips:o}},Ct=e=>{if(!e||typeof e!="object")return;let t=e,n=[],o=$t;for(let r of[t,...Array.isArray(t.stages)?t.stages.slice(0,Ve.length):[]]){if(o<=0)break;let s=Dt(r,o);s&&(o-=s.clips.length,n.push(s))}return _t(n)},Ie="data-ip-animation",Xe="data-ip";var jt=e=>atob(e.replace(/-/g,"+").replace(/_/g,"/"));var We=e=>{if(!(!e||e.length>6e4||!/^[A-Za-z0-9_-]+$/.test(e)))try{return Ct(JSON.parse(jt(e)))}catch{return}},Gt=e=>e.clips.reduce((t,n)=>Math.max(t,n.start+n.duration),0),Bt="path, line, rect, ellipse, circle, polyline, polygon",Kt=e=>[...e.querySelectorAll(Bt)].filter(t=>{var o;if(t.closest("defs, clipPath, mask"))return!1;let n=(o=t.getAttribute("stroke"))!=null?o:getComputedStyle(t).stroke;return!!n&&n!=="none"&&n!=="transparent"&&typeof t.getTotalLength=="function"}),Lt="http://www.w3.org/2000/svg",ve=48,Ft=(e,t,n)=>{var s;let o=(s=e.ownerSVGElement)!=null?s:e.closest("svg");if(!o||typeof e.getBBox!="function")return[];let r=document.createElementNS(Lt,"path");r.setAttribute("d",t),r.setAttribute("visibility","hidden"),o.appendChild(r);try{let l=r.getTotalLength(),d=e.getBBox(),i=d.x+d.width/2,g=d.y+d.height/2,f=S=>r.getPointAtLength(Math.min(Math.max(S,0),l)),p=S=>{let a=Math.max(l/400,.01),u=f(S-a),k=f(S+a);return Math.atan2(k.y-u.y,k.x-u.x)*180/Math.PI},w=p(0),y=0;return Array.from({length:ve+1},(S,a)=>{let u=a/ve*l,k=f(u),m=p(u)-w;for(;m-y>180;)m-=360;for(;m-y<-180;)m+=360;y=m;let A=`translate(${(k.x-i).toFixed(3)}px, ${(k.y-g).toFixed(3)}px)`;return{offset:a/ve,transform:n?`${A} rotate(${m.toFixed(2)}deg)`:A}})}finally{r.remove()}},Ye=(e,t,n,o,r=0)=>{let s=(t.start+r)/n,l=(t.start+r+t.duration)/n,d=qe[t.easing].css,i=e.map((w,y)=>({...w,offset:s+w.offset*(l-s),easing:y<e.length-1?d:"linear"})),g={...o!=null?o:e[0],offset:0,easing:"linear"},f={...e[e.length-1],offset:1,easing:"linear"},p=[];return i[0].offset>0&&(p.push(g),o&&p.push({...o,offset:i[0].offset,easing:"linear"})),p.push(...i),i[i.length-1].offset<1&&p.push(f),p},Ze=(e,t,n={})=>{var w,y,S;let o=Math.max(Gt(e),He),r=(w=n.loop)!=null?w:e.loop,s=r?o+e.loopGap:o,l=r&&e.reverse===!0,d=l?e.loopGap/2:0,i=[],g={duration:s,iterations:r?1/0:1,fill:"both",direction:l?"alternate":"normal"};for(let a of e.clips){let u=_[a.preset],k=e.clips.some(m=>m.target===a.target&&m.start<a.start);for(let m of t(a.target)){if(u.draw){for(let v of Kt(m)){let I=Math.max(v.getTotalLength(),.01),rt=[{offset:0,strokeDasharray:`${I} ${I}`,strokeDashoffset:I},{offset:1,strokeDasharray:`${I} ${I}`,strokeDashoffset:0}],st=k?{offset:0,strokeDasharray:`${I} ${I}`,strokeDashoffset:0}:void 0;i.push(v.animate(Ye(rt,a,s,st,d),g))}continue}let A=m;A.style.transformBox="fill-box",A.style.transformOrigin="center";let c=u.route?Ft(m,(y=a.path)!=null?y:"",a.orient===!0):((S=u.frames)!=null?S:[]).map(v=>({...v}));if(!c.length)continue;let h=c.some(v=>v.transform!==void 0),x=c.some(v=>v.opacity!==void 0),ne=k?{offset:0,...h?{transform:"translate(0px, 0px)"}:{},...x?{opacity:1}:{}}:void 0;i.push(A.animate(Ye(c,a,s,ne,d),{...g,composite:h?"add":"replace"}))}}let f=a=>i.forEach(a),p=a=>{if(!r)return Math.min(a,o);let u=Math.floor(a/s),k=a-u*s,m=l&&u%2===1?s-k:k;return Math.min(o,Math.max(0,m-d))};return n.paused&&f(a=>a.pause()),{play:()=>f(a=>a.play()),pause:()=>f(a=>a.pause()),reverse:a=>{var m;let u=i[0];if(!u)return a==null?void 0:a();let k=p(Number((m=u.currentTime)!=null?m:0))+d;if(k<=1)return a==null?void 0:a();try{f(A=>{A.currentTime=k,A.playbackRate=-1,A.play()})}catch{return a==null?void 0:a()}u.onfinish=()=>{u.onfinish=null,a==null||a()}},forward:()=>{i[0]&&(i[0].onfinish=null),f(a=>a.playbackRate=1),f(a=>a.play())},seek:a=>f(u=>u.currentTime=Math.max(0,a+d)),cancel:()=>f(a=>a.cancel()),period:s,animations:i,clock:p}};var Q=new WeakMap,zt=()=>typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,Ut=e=>{var t,n;return(n=(t=e.closest("a, button, [role=button], label, summary"))!=null?t:e.parentElement)!=null?n:e},ee=(e,t={})=>{var m,A;(m=Q.get(e))==null||m();let n=We(e.getAttribute(Ie));if(!n||typeof e.animate!="function")return()=>{};if((A=t.reducedMotion)!=null?A:zt())return()=>{};let o=Je(n),r=t.trigger?[{...o[0],trigger:t.trigger}]:o,s=c=>[...e.querySelectorAll(`[${Xe}="${c}"]`)],l=r.find(c=>Z(c.trigger)==="appear"&&c.loop),d=[],i,g=!1,f=!1,p=()=>{i==null||i.playback.cancel(),i=void 0,g=!1},w=()=>{l&&f&&y(l)},y=c=>{var x;p();let h={stage:c,playback:Ze(c,s)};i=h,Z(c.trigger)==="appear"&&(f=!0),c.trigger==="click"&&!c.loop&&((x=h.playback.animations[0])==null||x.finished.then(()=>{i===h&&w()},()=>{}))},S=c=>{if((i==null?void 0:i.stage)===c){g&&(g=!1,i.playback.forward());return}y(c)},a=c=>{let h=i;!h||h.stage!==c||(g=!0,h.playback.reverse(()=>{!g||i!==h||(p(),w())}))},u=(c,h,x)=>{c.addEventListener(h,x),d.push(()=>c.removeEventListener(h,x))};for(let c of r){let h=Ut(e);if(c.trigger==="load"&&y(c),c.trigger==="hover"&&(u(h,"pointerenter",()=>S(c)),u(h,"pointerleave",()=>a(c)),u(h,"focusin",()=>S(c)),u(h,"focusout",()=>a(c))),c.trigger==="toggle"){let x=!1;u(h,"click",()=>{x=!(x&&(i==null?void 0:i.stage)===c),x?S(c):a(c)})}if(c.trigger==="click"&&u(h,"click",()=>y(c)),c.trigger==="visible")if(typeof IntersectionObserver=="function"){let x=new IntersectionObserver(ne=>{ne.some(v=>v.isIntersecting)&&(x.disconnect(),i?f=!0:y(c))},{threshold:.5});x.observe(e),d.push(()=>x.disconnect())}else y(c)}let k=()=>{p(),d.forEach(c=>c()),Q.delete(e)};return Q.set(e,k),k},Qe=(e=document)=>{e.querySelectorAll(`svg[${Ie}]`).forEach(t=>{Q.has(t)||ee(t)})};var et="[data-icon], i.ip[class*='ip-']",Yt=new Set(["none","wiggle","pop","bounce","draw"]),tt=new Set,Vt=e=>{let t=e.getAttribute("data-icon");if(t)return t;for(let n of Array.from(e.classList))if(n.startsWith("ip-")&&n.length>3)return n.slice(3)},nt=e=>{if(e===null)return;let t=Number(e);return Number.isFinite(t)&&t>0?t:void 0},Te=e=>{var i,g,f,p;let t=Vt(e);if(!t)return;let n=W(t),o=e.getAttribute("data-motion"),r=o&&Yt.has(o)?o:void 0,s={size:(i=nt(e.getAttribute("data-size")))!=null?i:24,color:(g=e.getAttribute("data-color"))!=null?g:void 0,strokeScale:nt(e.getAttribute("data-stroke")),motion:r,label:(f=e.getAttribute("data-label"))!=null?f:void 0},l=JSON.stringify([t,s,n?"1":"0"]);if(e.getAttribute("data-ip-rendered")===l)return;if(!n){Le(t)?tt.has(t)||(tt.add(t),console.warn(`iconplease: no icon named "${t}".`)):be(t);return}e.innerHTML=we(xe(n,s)),e.setAttribute("data-ip-rendered",l);let d=e.querySelector("svg");d&&ee(d),e.tagName==="I"&&((p=e.style).display||(p.display="inline-flex"))},te=(e=document)=>{e instanceof Element&&e.matches(et)&&Te(e),e.querySelectorAll(et).forEach(Te)},ot=()=>{let e=window.iconpleaseConfig;e&&oe(e),Ke(()=>te()),te(),ke(),new MutationObserver(t=>{for(let n of t)n.type==="attributes"&&n.target instanceof Element&&Te(n.target),n.addedNodes.forEach(o=>{o instanceof Element&&te(o)})}).observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-icon","data-size","data-color","data-stroke","data-motion","data-label","class"]})};window.iconplease={init:oe,load:ke,renderSVG:ze,attachAnimation:ee,attachAll:Qe,refresh:()=>te()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",ot,{once:!0}):ot();})();
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ export { init, getConfig } from "./config.js";
|
|
|
2
2
|
export { load, loadSet, requestIcon, subscribe, getIcon, getStatus, iconNames, setIconNames, isUnknown, bundledIcon } from "./store.js";
|
|
3
3
|
export { renderSVG, prepare } from "./render.js";
|
|
4
4
|
export { attachAnimation, attachAll } from "./player.js";
|
|
5
|
-
export { decodeAnimation, encodeAnimation, cleanAnimation, PRESETS } from "./animation.js";
|
|
6
|
-
export type { IconAnimation, AnimationClip, AnimationPreset, AnimationTrigger } from "./animation.js";
|
|
5
|
+
export { decodeAnimation, encodeAnimation, cleanAnimation, stagesOf, fromStages, stageKindOf, PRESETS } from "./animation.js";
|
|
6
|
+
export type { IconAnimation, AnimationStage, AnimationClip, AnimationPreset, AnimationTrigger, StageKind } from "./animation.js";
|
|
7
7
|
export type { RenderOptions, Prepared } from "./render.js";
|
|
8
8
|
export type { LoadOptions } from "./store.js";
|
|
9
9
|
export type { Config, IconData, IconIndex, IconMotion, Status, BundledSet, BundledIcon, TokenSource } from "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -2,4 +2,4 @@ export { init, getConfig } from "./config.js";
|
|
|
2
2
|
export { load, loadSet, requestIcon, subscribe, getIcon, getStatus, iconNames, setIconNames, isUnknown, bundledIcon } from "./store.js";
|
|
3
3
|
export { renderSVG, prepare } from "./render.js";
|
|
4
4
|
export { attachAnimation, attachAll } from "./player.js";
|
|
5
|
-
export { decodeAnimation, encodeAnimation, cleanAnimation, PRESETS } from "./animation.js";
|
|
5
|
+
export { decodeAnimation, encodeAnimation, cleanAnimation, stagesOf, fromStages, stageKindOf, PRESETS } from "./animation.js";
|
package/dist/player.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ANIMATION_ATTRIBUTE, MARKER_ATTRIBUTE, animate, decodeAnimation } from "./animation.js";
|
|
1
|
+
import { ANIMATION_ATTRIBUTE, MARKER_ATTRIBUTE, animate, decodeAnimation, stageKindOf, stagesOf } from "./animation.js";
|
|
2
2
|
const attached = new WeakMap();
|
|
3
3
|
const prefersReduced = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
4
4
|
const hoverHost = (svg) => svg.closest("a, button, [role=button], label, summary") ?? svg.parentElement ?? svg;
|
|
@@ -9,51 +9,101 @@ export const attachAnimation = (svg, options = {}) => {
|
|
|
9
9
|
return () => { };
|
|
10
10
|
if (options.reducedMotion ?? prefersReduced())
|
|
11
11
|
return () => { };
|
|
12
|
-
const
|
|
12
|
+
const all = stagesOf(animation);
|
|
13
|
+
const stages = options.trigger ? [{ ...all[0], trigger: options.trigger }] : all;
|
|
13
14
|
const targets = (marker) => [...svg.querySelectorAll(`[${MARKER_ATTRIBUTE}="${marker}"]`)];
|
|
14
|
-
|
|
15
|
+
const idle = stages.find((stage) => stageKindOf(stage.trigger) === "appear" && stage.loop);
|
|
15
16
|
const cleanups = [];
|
|
17
|
+
let current;
|
|
18
|
+
let backwards = false;
|
|
19
|
+
let appeared = false;
|
|
16
20
|
const stop = () => {
|
|
17
|
-
playback
|
|
18
|
-
|
|
21
|
+
current?.playback.cancel();
|
|
22
|
+
current = undefined;
|
|
23
|
+
backwards = false;
|
|
19
24
|
};
|
|
20
|
-
const
|
|
25
|
+
const resume = () => {
|
|
26
|
+
if (idle && appeared)
|
|
27
|
+
start(idle);
|
|
28
|
+
};
|
|
29
|
+
const start = (stage) => {
|
|
21
30
|
stop();
|
|
22
|
-
|
|
31
|
+
const playing = { stage, playback: animate(stage, targets) };
|
|
32
|
+
current = playing;
|
|
33
|
+
if (stageKindOf(stage.trigger) === "appear")
|
|
34
|
+
appeared = true;
|
|
35
|
+
if (stage.trigger === "click" && !stage.loop) {
|
|
36
|
+
playing.playback.animations[0]?.finished.then(() => {
|
|
37
|
+
if (current === playing)
|
|
38
|
+
resume();
|
|
39
|
+
}, () => undefined);
|
|
40
|
+
}
|
|
23
41
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
const enter = (stage) => {
|
|
43
|
+
if (current?.stage === stage) {
|
|
44
|
+
if (backwards) {
|
|
45
|
+
backwards = false;
|
|
46
|
+
current.playback.forward();
|
|
47
|
+
}
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
start(stage);
|
|
51
|
+
};
|
|
52
|
+
const leave = (stage) => {
|
|
53
|
+
const playing = current;
|
|
54
|
+
if (!playing || playing.stage !== stage)
|
|
55
|
+
return;
|
|
56
|
+
backwards = true;
|
|
57
|
+
playing.playback.reverse(() => {
|
|
58
|
+
if (!backwards || current !== playing)
|
|
59
|
+
return;
|
|
60
|
+
stop();
|
|
61
|
+
resume();
|
|
37
62
|
});
|
|
38
|
-
}
|
|
39
|
-
|
|
63
|
+
};
|
|
64
|
+
const on = (host, type, listener) => {
|
|
65
|
+
host.addEventListener(type, listener);
|
|
66
|
+
cleanups.push(() => host.removeEventListener(type, listener));
|
|
67
|
+
};
|
|
68
|
+
for (const stage of stages) {
|
|
40
69
|
const host = hoverHost(svg);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
70
|
+
if (stage.trigger === "load")
|
|
71
|
+
start(stage);
|
|
72
|
+
if (stage.trigger === "hover") {
|
|
73
|
+
on(host, "pointerenter", () => enter(stage));
|
|
74
|
+
on(host, "pointerleave", () => leave(stage));
|
|
75
|
+
on(host, "focusin", () => enter(stage));
|
|
76
|
+
on(host, "focusout", () => leave(stage));
|
|
77
|
+
}
|
|
78
|
+
if (stage.trigger === "toggle") {
|
|
79
|
+
let held = false;
|
|
80
|
+
on(host, "click", () => {
|
|
81
|
+
held = !(held && current?.stage === stage);
|
|
82
|
+
if (held)
|
|
83
|
+
enter(stage);
|
|
84
|
+
else
|
|
85
|
+
leave(stage);
|
|
86
|
+
});
|
|
54
87
|
}
|
|
55
|
-
|
|
56
|
-
start();
|
|
88
|
+
if (stage.trigger === "click")
|
|
89
|
+
on(host, "click", () => start(stage));
|
|
90
|
+
if (stage.trigger === "visible") {
|
|
91
|
+
if (typeof IntersectionObserver === "function") {
|
|
92
|
+
const observer = new IntersectionObserver((entries) => {
|
|
93
|
+
if (!entries.some((entry) => entry.isIntersecting))
|
|
94
|
+
return;
|
|
95
|
+
observer.disconnect();
|
|
96
|
+
if (!current)
|
|
97
|
+
start(stage);
|
|
98
|
+
else
|
|
99
|
+
appeared = true;
|
|
100
|
+
}, { threshold: 0.5 });
|
|
101
|
+
observer.observe(svg);
|
|
102
|
+
cleanups.push(() => observer.disconnect());
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
start(stage);
|
|
106
|
+
}
|
|
57
107
|
}
|
|
58
108
|
}
|
|
59
109
|
const detach = () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iconplease",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Icons you can draw yourself. Pages load only the icons they show from the iconplease CDN; private sets via a key, a token or a build-time file.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"icons",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"icon-library"
|
|
11
11
|
],
|
|
12
12
|
"homepage": "https://iconplease.com",
|
|
13
|
-
"
|
|
13
|
+
"author": "TECHNOLOGYPLEASE Co., Ltd.",
|
|
14
|
+
"license": "MIT",
|
|
14
15
|
"type": "module",
|
|
15
16
|
"sideEffects": [
|
|
16
17
|
"*.css"
|
|
@@ -35,7 +36,9 @@
|
|
|
35
36
|
"files": [
|
|
36
37
|
"dist",
|
|
37
38
|
"bin",
|
|
38
|
-
"README.md"
|
|
39
|
+
"README.md",
|
|
40
|
+
"LICENSE",
|
|
41
|
+
"ICONS-LICENSE.md"
|
|
39
42
|
],
|
|
40
43
|
"engines": {
|
|
41
44
|
"node": ">=18"
|
|
@@ -64,6 +67,6 @@
|
|
|
64
67
|
"typescript": "^5.8.3"
|
|
65
68
|
},
|
|
66
69
|
"bin": {
|
|
67
|
-
"iconplease": "
|
|
70
|
+
"iconplease": "bin/iconplease.mjs"
|
|
68
71
|
}
|
|
69
72
|
}
|