iconflow 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +72 -70
- package/dist/index.mjs +74 -117
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __esm = (fn, res) => function __init() {
|
|
6
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
7
|
-
};
|
|
8
7
|
var __export = (target, all) => {
|
|
9
8
|
for (var name in all)
|
|
10
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -17,77 +16,77 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
16
|
}
|
|
18
17
|
return to;
|
|
19
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
20
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
28
|
|
|
22
|
-
// src/
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
// src/index.js
|
|
30
|
+
var index_exports = {};
|
|
31
|
+
__export(index_exports, {
|
|
32
|
+
AnimatedIcon: () => AnimatedIcon_default,
|
|
33
|
+
IconFlow: () => IconFlow,
|
|
34
|
+
default: () => index_default
|
|
26
35
|
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
37
|
|
|
28
38
|
// src/AnimatedIcon.jsx
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
className: `iconflow-${animationType} ${isTriggered ? "iconflow-active" : ""} ${className}`.trim(),
|
|
79
|
-
style: { "--iconflow-speed": `${speed}s` },
|
|
80
|
-
...handlers[triggerType]
|
|
81
|
-
},
|
|
82
|
-
/* @__PURE__ */ React.createElement(Icon, { size, color, strokeWidth })
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
AnimatedIcon_default = AnimatedIcon;
|
|
86
|
-
}
|
|
87
|
-
});
|
|
39
|
+
var import_react = __toESM(require("react"));
|
|
40
|
+
var ANIMATION_TYPES = [
|
|
41
|
+
"shake",
|
|
42
|
+
"spin",
|
|
43
|
+
"bounce",
|
|
44
|
+
"swing",
|
|
45
|
+
"pulse",
|
|
46
|
+
"heartbeat"
|
|
47
|
+
];
|
|
48
|
+
var TRIGGERS = ["hover", "click", "mount", "loop"];
|
|
49
|
+
var AnimatedIcon = ({
|
|
50
|
+
icon: Icon,
|
|
51
|
+
animation,
|
|
52
|
+
trigger,
|
|
53
|
+
size = 24,
|
|
54
|
+
color = "currentColor",
|
|
55
|
+
speed = 1,
|
|
56
|
+
strokeWidth = 2,
|
|
57
|
+
className = ""
|
|
58
|
+
}) => {
|
|
59
|
+
const animationType = ANIMATION_TYPES.includes(animation) ? animation : "shake";
|
|
60
|
+
const triggerType = TRIGGERS.includes(trigger) ? trigger : "hover";
|
|
61
|
+
const [isTriggered, setIsTriggered] = (0, import_react.useState)(
|
|
62
|
+
triggerType === "mount" || triggerType === "loop"
|
|
63
|
+
);
|
|
64
|
+
(0, import_react.useEffect)(() => {
|
|
65
|
+
if (triggerType === "mount") {
|
|
66
|
+
setIsTriggered(true);
|
|
67
|
+
}
|
|
68
|
+
}, [triggerType]);
|
|
69
|
+
const handlers = {
|
|
70
|
+
hover: {
|
|
71
|
+
onMouseEnter: () => setIsTriggered(true),
|
|
72
|
+
onMouseLeave: () => setIsTriggered(false)
|
|
73
|
+
},
|
|
74
|
+
click: { onClick: () => setIsTriggered((prev) => !prev) },
|
|
75
|
+
mount: {}
|
|
76
|
+
};
|
|
77
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
78
|
+
"span",
|
|
79
|
+
{
|
|
80
|
+
className: `iconflow-${animationType} ${isTriggered ? "iconflow-active" : ""} ${className}`.trim(),
|
|
81
|
+
style: { "--iconflow-speed": `${speed}s` },
|
|
82
|
+
...handlers[triggerType]
|
|
83
|
+
},
|
|
84
|
+
/* @__PURE__ */ import_react.default.createElement(Icon, { size, color, strokeWidth })
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
var AnimatedIcon_default = AnimatedIcon;
|
|
88
88
|
|
|
89
89
|
// src/index.js
|
|
90
|
-
var AnimatedIcon2 = (init_AnimatedIcon(), __toCommonJS(AnimatedIcon_exports));
|
|
91
90
|
var IconFlow = class {
|
|
92
91
|
constructor(options = {}) {
|
|
93
92
|
this.defaultSize = options.size ?? 24;
|
|
@@ -109,6 +108,9 @@ var IconFlow = class {
|
|
|
109
108
|
};
|
|
110
109
|
}
|
|
111
110
|
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
module.exports
|
|
111
|
+
var index_default = AnimatedIcon_default;
|
|
112
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
113
|
+
0 && (module.exports = {
|
|
114
|
+
AnimatedIcon,
|
|
115
|
+
IconFlow
|
|
116
|
+
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,122 +1,79 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __esm = (fn, res) => function __init() {
|
|
6
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
7
|
-
};
|
|
8
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
11
|
-
var __export = (target, all) => {
|
|
12
|
-
for (var name in all)
|
|
13
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
-
};
|
|
15
|
-
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
-
for (let key of __getOwnPropNames(from))
|
|
18
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
-
}
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
-
|
|
25
|
-
// src/styles.css
|
|
26
|
-
var init_styles = __esm({
|
|
27
|
-
"src/styles.css"() {
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
1
|
// src/AnimatedIcon.jsx
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
className: `iconflow-${animationType} ${isTriggered ? "iconflow-active" : ""} ${className}`.trim(),
|
|
82
|
-
style: { "--iconflow-speed": `${speed}s` },
|
|
83
|
-
...handlers[triggerType]
|
|
84
|
-
},
|
|
85
|
-
/* @__PURE__ */ React.createElement(Icon, { size, color, strokeWidth })
|
|
86
|
-
);
|
|
87
|
-
};
|
|
88
|
-
AnimatedIcon_default = AnimatedIcon;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
|
+
var ANIMATION_TYPES = [
|
|
4
|
+
"shake",
|
|
5
|
+
"spin",
|
|
6
|
+
"bounce",
|
|
7
|
+
"swing",
|
|
8
|
+
"pulse",
|
|
9
|
+
"heartbeat"
|
|
10
|
+
];
|
|
11
|
+
var TRIGGERS = ["hover", "click", "mount", "loop"];
|
|
12
|
+
var AnimatedIcon = ({
|
|
13
|
+
icon: Icon,
|
|
14
|
+
animation,
|
|
15
|
+
trigger,
|
|
16
|
+
size = 24,
|
|
17
|
+
color = "currentColor",
|
|
18
|
+
speed = 1,
|
|
19
|
+
strokeWidth = 2,
|
|
20
|
+
className = ""
|
|
21
|
+
}) => {
|
|
22
|
+
const animationType = ANIMATION_TYPES.includes(animation) ? animation : "shake";
|
|
23
|
+
const triggerType = TRIGGERS.includes(trigger) ? trigger : "hover";
|
|
24
|
+
const [isTriggered, setIsTriggered] = useState(
|
|
25
|
+
triggerType === "mount" || triggerType === "loop"
|
|
26
|
+
);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (triggerType === "mount") {
|
|
29
|
+
setIsTriggered(true);
|
|
30
|
+
}
|
|
31
|
+
}, [triggerType]);
|
|
32
|
+
const handlers = {
|
|
33
|
+
hover: {
|
|
34
|
+
onMouseEnter: () => setIsTriggered(true),
|
|
35
|
+
onMouseLeave: () => setIsTriggered(false)
|
|
36
|
+
},
|
|
37
|
+
click: { onClick: () => setIsTriggered((prev) => !prev) },
|
|
38
|
+
mount: {}
|
|
39
|
+
};
|
|
40
|
+
return /* @__PURE__ */ React.createElement(
|
|
41
|
+
"span",
|
|
42
|
+
{
|
|
43
|
+
className: `iconflow-${animationType} ${isTriggered ? "iconflow-active" : ""} ${className}`.trim(),
|
|
44
|
+
style: { "--iconflow-speed": `${speed}s` },
|
|
45
|
+
...handlers[triggerType]
|
|
46
|
+
},
|
|
47
|
+
/* @__PURE__ */ React.createElement(Icon, { size, color, strokeWidth })
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
var AnimatedIcon_default = AnimatedIcon;
|
|
91
51
|
|
|
92
52
|
// src/index.js
|
|
93
|
-
var
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
animation: this.defaultAnimation,
|
|
112
|
-
trigger: this.defaultTrigger,
|
|
113
|
-
...overrides
|
|
114
|
-
};
|
|
115
|
-
}
|
|
53
|
+
var IconFlow = class {
|
|
54
|
+
constructor(options = {}) {
|
|
55
|
+
this.defaultSize = options.size ?? 24;
|
|
56
|
+
this.defaultColor = options.color ?? "currentColor";
|
|
57
|
+
this.defaultSpeed = options.speed ?? 1;
|
|
58
|
+
this.defaultStrokeWidth = options.strokeWidth ?? 2;
|
|
59
|
+
this.defaultAnimation = options.animation ?? "shake";
|
|
60
|
+
this.defaultTrigger = options.trigger ?? "hover";
|
|
61
|
+
}
|
|
62
|
+
getDefaults(overrides = {}) {
|
|
63
|
+
return {
|
|
64
|
+
size: this.defaultSize,
|
|
65
|
+
color: this.defaultColor,
|
|
66
|
+
speed: this.defaultSpeed,
|
|
67
|
+
strokeWidth: this.defaultStrokeWidth,
|
|
68
|
+
animation: this.defaultAnimation,
|
|
69
|
+
trigger: this.defaultTrigger,
|
|
70
|
+
...overrides
|
|
116
71
|
};
|
|
117
|
-
module.exports = IconFlow;
|
|
118
|
-
module.exports.AnimatedIcon = AnimatedIcon2;
|
|
119
|
-
module.exports.default = IconFlow;
|
|
120
72
|
}
|
|
121
|
-
}
|
|
122
|
-
|
|
73
|
+
};
|
|
74
|
+
var index_default = AnimatedIcon_default;
|
|
75
|
+
export {
|
|
76
|
+
AnimatedIcon_default as AnimatedIcon,
|
|
77
|
+
IconFlow,
|
|
78
|
+
index_default as default
|
|
79
|
+
};
|