@zag-js/avatar 1.47.0 → 1.48.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/dist/avatar.anatomy.d.mts +2 -6
- package/dist/avatar.anatomy.d.ts +2 -6
- package/dist/avatar.anatomy.js +8 -33
- package/dist/avatar.anatomy.mjs +4 -7
- package/dist/avatar.connect.d.mts +4 -7
- package/dist/avatar.connect.d.ts +4 -7
- package/dist/avatar.connect.js +64 -86
- package/dist/avatar.connect.mjs +60 -51
- package/dist/avatar.dom.d.mts +6 -9
- package/dist/avatar.dom.d.ts +6 -9
- package/dist/avatar.dom.js +14 -41
- package/dist/avatar.dom.mjs +6 -12
- package/dist/avatar.machine.d.mts +2 -7
- package/dist/avatar.machine.d.ts +2 -7
- package/dist/avatar.machine.js +75 -127
- package/dist/avatar.machine.mjs +71 -91
- package/dist/avatar.props.d.mts +3 -8
- package/dist/avatar.props.d.ts +3 -8
- package/dist/avatar.props.js +16 -34
- package/dist/avatar.props.mjs +10 -7
- package/dist/avatar.types.d.mts +59 -62
- package/dist/avatar.types.d.ts +59 -62
- package/dist/avatar.types.js +4 -18
- package/dist/avatar.types.mjs +1 -0
- package/dist/index.d.mts +6 -8
- package/dist/index.d.ts +6 -8
- package/dist/index.js +12 -38
- package/dist/index.mjs +2 -7
- package/package.json +8 -8
package/dist/avatar.machine.js
CHANGED
|
@@ -1,131 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/avatar.machine.ts
|
|
31
|
-
var avatar_machine_exports = {};
|
|
32
|
-
__export(avatar_machine_exports, {
|
|
33
|
-
machine: () => machine
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
34
4
|
});
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
(node) => node.nodeType === Node.ELEMENT_NODE && node.matches("[data-scope=avatar][data-part=image]")
|
|
106
|
-
);
|
|
107
|
-
if (removed) {
|
|
108
|
-
send({ type: "img.unmount" });
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
},
|
|
113
|
-
trackSrcChange({ send, scope }) {
|
|
114
|
-
const imageEl = dom.getImageEl(scope);
|
|
115
|
-
return (0, import_dom_query.observeAttributes)(imageEl, {
|
|
116
|
-
attributes: ["src", "srcset"],
|
|
117
|
-
callback() {
|
|
118
|
-
send({ type: "src.change" });
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
5
|
+
const require_avatar_dom = require("./avatar.dom.js");
|
|
6
|
+
let _zag_js_dom_query = require("@zag-js/dom-query");
|
|
7
|
+
// src/avatar.machine.ts
|
|
8
|
+
const machine = (0, require("@zag-js/core").createMachine)({
|
|
9
|
+
initialState() {
|
|
10
|
+
return "loading";
|
|
11
|
+
},
|
|
12
|
+
effects: ["trackImageRemoval", "trackSrcChange"],
|
|
13
|
+
on: {
|
|
14
|
+
"src.change": { target: "loading" },
|
|
15
|
+
"img.unmount": { target: "error" }
|
|
16
|
+
},
|
|
17
|
+
states: {
|
|
18
|
+
loading: {
|
|
19
|
+
entry: ["checkImageStatus"],
|
|
20
|
+
on: {
|
|
21
|
+
"img.loaded": {
|
|
22
|
+
target: "loaded",
|
|
23
|
+
actions: ["invokeOnLoad"]
|
|
24
|
+
},
|
|
25
|
+
"img.error": {
|
|
26
|
+
target: "error",
|
|
27
|
+
actions: ["invokeOnError"]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
error: { on: { "img.loaded": {
|
|
32
|
+
target: "loaded",
|
|
33
|
+
actions: ["invokeOnLoad"]
|
|
34
|
+
} } },
|
|
35
|
+
loaded: { on: { "img.error": {
|
|
36
|
+
target: "error",
|
|
37
|
+
actions: ["invokeOnError"]
|
|
38
|
+
} } }
|
|
39
|
+
},
|
|
40
|
+
implementations: {
|
|
41
|
+
actions: {
|
|
42
|
+
invokeOnLoad({ prop }) {
|
|
43
|
+
prop("onStatusChange")?.({ status: "loaded" });
|
|
44
|
+
},
|
|
45
|
+
invokeOnError({ prop }) {
|
|
46
|
+
prop("onStatusChange")?.({ status: "error" });
|
|
47
|
+
},
|
|
48
|
+
checkImageStatus({ send, scope }) {
|
|
49
|
+
const imageEl = require_avatar_dom.getImageEl(scope);
|
|
50
|
+
if (!imageEl?.complete) return;
|
|
51
|
+
send({
|
|
52
|
+
type: hasLoaded(imageEl) ? "img.loaded" : "img.error",
|
|
53
|
+
src: "ssr"
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
effects: {
|
|
58
|
+
trackImageRemoval({ send, scope }) {
|
|
59
|
+
const rootEl = require_avatar_dom.getRootEl(scope);
|
|
60
|
+
return (0, _zag_js_dom_query.observeChildren)(rootEl, { callback(records) {
|
|
61
|
+
if (Array.from(records[0].removedNodes).find((node) => node.nodeType === Node.ELEMENT_NODE && node.matches("[data-scope=avatar][data-part=image]"))) send({ type: "img.unmount" });
|
|
62
|
+
} });
|
|
63
|
+
},
|
|
64
|
+
trackSrcChange({ send, scope }) {
|
|
65
|
+
const imageEl = require_avatar_dom.getImageEl(scope);
|
|
66
|
+
return (0, _zag_js_dom_query.observeAttributes)(imageEl, {
|
|
67
|
+
attributes: ["src", "srcset"],
|
|
68
|
+
callback() {
|
|
69
|
+
send({ type: "src.change" });
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
124
75
|
});
|
|
125
76
|
function hasLoaded(image) {
|
|
126
|
-
|
|
77
|
+
return image.complete && image.naturalWidth !== 0 && image.naturalHeight !== 0;
|
|
127
78
|
}
|
|
128
|
-
|
|
129
|
-
0 && (module.exports = {
|
|
130
|
-
machine
|
|
131
|
-
});
|
|
79
|
+
exports.machine = machine;
|
package/dist/avatar.machine.mjs
CHANGED
|
@@ -1,96 +1,76 @@
|
|
|
1
|
-
|
|
1
|
+
import { getImageEl, getRootEl } from "./avatar.dom.mjs";
|
|
2
2
|
import { observeAttributes, observeChildren } from "@zag-js/dom-query";
|
|
3
3
|
import { createMachine } from "@zag-js/core";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
if (removed) {
|
|
74
|
-
send({ type: "img.unmount" });
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
},
|
|
79
|
-
trackSrcChange({ send, scope }) {
|
|
80
|
-
const imageEl = dom.getImageEl(scope);
|
|
81
|
-
return observeAttributes(imageEl, {
|
|
82
|
-
attributes: ["src", "srcset"],
|
|
83
|
-
callback() {
|
|
84
|
-
send({ type: "src.change" });
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
4
|
+
// src/avatar.machine.ts
|
|
5
|
+
const machine = createMachine({
|
|
6
|
+
initialState() {
|
|
7
|
+
return "loading";
|
|
8
|
+
},
|
|
9
|
+
effects: ["trackImageRemoval", "trackSrcChange"],
|
|
10
|
+
on: {
|
|
11
|
+
"src.change": { target: "loading" },
|
|
12
|
+
"img.unmount": { target: "error" }
|
|
13
|
+
},
|
|
14
|
+
states: {
|
|
15
|
+
loading: {
|
|
16
|
+
entry: ["checkImageStatus"],
|
|
17
|
+
on: {
|
|
18
|
+
"img.loaded": {
|
|
19
|
+
target: "loaded",
|
|
20
|
+
actions: ["invokeOnLoad"]
|
|
21
|
+
},
|
|
22
|
+
"img.error": {
|
|
23
|
+
target: "error",
|
|
24
|
+
actions: ["invokeOnError"]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
error: { on: { "img.loaded": {
|
|
29
|
+
target: "loaded",
|
|
30
|
+
actions: ["invokeOnLoad"]
|
|
31
|
+
} } },
|
|
32
|
+
loaded: { on: { "img.error": {
|
|
33
|
+
target: "error",
|
|
34
|
+
actions: ["invokeOnError"]
|
|
35
|
+
} } }
|
|
36
|
+
},
|
|
37
|
+
implementations: {
|
|
38
|
+
actions: {
|
|
39
|
+
invokeOnLoad({ prop }) {
|
|
40
|
+
prop("onStatusChange")?.({ status: "loaded" });
|
|
41
|
+
},
|
|
42
|
+
invokeOnError({ prop }) {
|
|
43
|
+
prop("onStatusChange")?.({ status: "error" });
|
|
44
|
+
},
|
|
45
|
+
checkImageStatus({ send, scope }) {
|
|
46
|
+
const imageEl = getImageEl(scope);
|
|
47
|
+
if (!imageEl?.complete) return;
|
|
48
|
+
send({
|
|
49
|
+
type: hasLoaded(imageEl) ? "img.loaded" : "img.error",
|
|
50
|
+
src: "ssr"
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
effects: {
|
|
55
|
+
trackImageRemoval({ send, scope }) {
|
|
56
|
+
const rootEl = getRootEl(scope);
|
|
57
|
+
return observeChildren(rootEl, { callback(records) {
|
|
58
|
+
if (Array.from(records[0].removedNodes).find((node) => node.nodeType === Node.ELEMENT_NODE && node.matches("[data-scope=avatar][data-part=image]"))) send({ type: "img.unmount" });
|
|
59
|
+
} });
|
|
60
|
+
},
|
|
61
|
+
trackSrcChange({ send, scope }) {
|
|
62
|
+
const imageEl = getImageEl(scope);
|
|
63
|
+
return observeAttributes(imageEl, {
|
|
64
|
+
attributes: ["src", "srcset"],
|
|
65
|
+
callback() {
|
|
66
|
+
send({ type: "src.change" });
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
90
72
|
});
|
|
91
73
|
function hasLoaded(image) {
|
|
92
|
-
|
|
74
|
+
return image.complete && image.naturalWidth !== 0 && image.naturalHeight !== 0;
|
|
93
75
|
}
|
|
94
|
-
export {
|
|
95
|
-
machine
|
|
96
|
-
};
|
|
76
|
+
export { machine };
|
package/dist/avatar.props.d.mts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import { AvatarProps } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare const props: (keyof AvatarProps)[];
|
|
6
|
-
declare const splitProps: <Props extends Partial<AvatarProps>>(props: Props) => [Partial<AvatarProps>, Omit<Props, keyof AvatarProps>];
|
|
7
|
-
|
|
8
|
-
export { props, splitProps };
|
|
1
|
+
import { AvatarProps } from "./avatar.types.mjs";
|
|
2
|
+
export declare const props: (keyof AvatarProps)[];
|
|
3
|
+
export declare const splitProps: <Props extends Partial<AvatarProps>>(props: Props) => [Partial<AvatarProps>, Omit<Props, keyof AvatarProps>];
|
package/dist/avatar.props.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import { AvatarProps } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare const props: (keyof AvatarProps)[];
|
|
6
|
-
declare const splitProps: <Props extends Partial<AvatarProps>>(props: Props) => [Partial<AvatarProps>, Omit<Props, keyof AvatarProps>];
|
|
7
|
-
|
|
8
|
-
export { props, splitProps };
|
|
1
|
+
import { AvatarProps } from "./avatar.types.js";
|
|
2
|
+
export declare const props: (keyof AvatarProps)[];
|
|
3
|
+
export declare const splitProps: <Props extends Partial<AvatarProps>>(props: Props) => [Partial<AvatarProps>, Omit<Props, keyof AvatarProps>];
|
package/dist/avatar.props.js
CHANGED
|
@@ -1,35 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/avatar.props.ts
|
|
21
|
-
var avatar_props_exports = {};
|
|
22
|
-
__export(avatar_props_exports, {
|
|
23
|
-
props: () => props,
|
|
24
|
-
splitProps: () => splitProps
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(avatar_props_exports);
|
|
27
|
-
var import_types = require("@zag-js/types");
|
|
28
|
-
var import_utils = require("@zag-js/utils");
|
|
29
|
-
var props = (0, import_types.createProps)()(["dir", "id", "ids", "onStatusChange", "getRootNode"]);
|
|
30
|
-
var splitProps = (0, import_utils.createSplitProps)(props);
|
|
31
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
-
0 && (module.exports = {
|
|
33
|
-
props,
|
|
34
|
-
splitProps
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
35
4
|
});
|
|
5
|
+
let _zag_js_types = require("@zag-js/types");
|
|
6
|
+
let _zag_js_utils = require("@zag-js/utils");
|
|
7
|
+
// src/avatar.props.ts
|
|
8
|
+
const props = (0, _zag_js_types.createProps)()([
|
|
9
|
+
"dir",
|
|
10
|
+
"id",
|
|
11
|
+
"ids",
|
|
12
|
+
"onStatusChange",
|
|
13
|
+
"getRootNode"
|
|
14
|
+
]);
|
|
15
|
+
const splitProps = (0, _zag_js_utils.createSplitProps)(props);
|
|
16
|
+
exports.props = props;
|
|
17
|
+
exports.splitProps = splitProps;
|
package/dist/avatar.props.mjs
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
// src/avatar.props.ts
|
|
2
1
|
import { createProps } from "@zag-js/types";
|
|
3
2
|
import { createSplitProps } from "@zag-js/utils";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
// src/avatar.props.ts
|
|
4
|
+
const props = createProps()([
|
|
5
|
+
"dir",
|
|
6
|
+
"id",
|
|
7
|
+
"ids",
|
|
8
|
+
"onStatusChange",
|
|
9
|
+
"getRootNode"
|
|
10
|
+
]);
|
|
11
|
+
const splitProps = createSplitProps(props);
|
|
12
|
+
export { props, splitProps };
|
package/dist/avatar.types.d.mts
CHANGED
|
@@ -1,66 +1,63 @@
|
|
|
1
|
-
import { Machine, Service } from
|
|
2
|
-
import { CommonProperties, DirectionProperty, PropTypes } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
status: LoadStatus;
|
|
1
|
+
import { Machine, Service } from "@zag-js/core";
|
|
2
|
+
import { CommonProperties, DirectionProperty, PropTypes } from "@zag-js/types";
|
|
3
|
+
export type LoadStatus = "error" | "loaded";
|
|
4
|
+
export interface StatusChangeDetails {
|
|
5
|
+
status: LoadStatus;
|
|
7
6
|
}
|
|
8
|
-
interface ElementIds {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
export interface ElementIds {
|
|
8
|
+
root?: string | undefined;
|
|
9
|
+
image?: string | undefined;
|
|
10
|
+
fallback?: string | undefined;
|
|
12
11
|
}
|
|
13
|
-
interface AvatarProps extends CommonProperties, DirectionProperty {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
export interface AvatarProps extends CommonProperties, DirectionProperty {
|
|
13
|
+
/**
|
|
14
|
+
* Functional called when the image loading status changes.
|
|
15
|
+
*/
|
|
16
|
+
onStatusChange?: ((details: StatusChangeDetails) => void) | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* The ids of the elements in the avatar. Useful for composition.
|
|
19
|
+
*/
|
|
20
|
+
ids?: ElementIds | undefined;
|
|
22
21
|
}
|
|
23
|
-
interface AvatarSchema {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
22
|
+
export interface AvatarSchema {
|
|
23
|
+
props: AvatarProps;
|
|
24
|
+
context: any;
|
|
25
|
+
initial: "loading";
|
|
26
|
+
effect: "trackImageRemoval" | "trackSrcChange";
|
|
27
|
+
action: "invokeOnLoad" | "invokeOnError" | "checkImageStatus";
|
|
28
|
+
event: {
|
|
29
|
+
type: "img.loaded";
|
|
30
|
+
src?: string | undefined;
|
|
31
|
+
} | {
|
|
32
|
+
type: "img.error";
|
|
33
|
+
src?: string | undefined;
|
|
34
|
+
} | {
|
|
35
|
+
type: "img.unmount";
|
|
36
|
+
} | {
|
|
37
|
+
type: "src.change";
|
|
38
|
+
};
|
|
39
|
+
state: "loading" | "error" | "loaded";
|
|
41
40
|
}
|
|
42
|
-
type AvatarService = Service<AvatarSchema>;
|
|
43
|
-
type AvatarMachine = Machine<AvatarSchema>;
|
|
44
|
-
interface AvatarApi<T extends PropTypes = PropTypes> {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export type { AvatarApi, AvatarMachine, AvatarProps, AvatarSchema, AvatarService, ElementIds, LoadStatus, StatusChangeDetails };
|
|
41
|
+
export type AvatarService = Service<AvatarSchema>;
|
|
42
|
+
export type AvatarMachine = Machine<AvatarSchema>;
|
|
43
|
+
export interface AvatarApi<T extends PropTypes = PropTypes> {
|
|
44
|
+
/**
|
|
45
|
+
* Whether the image is loaded.
|
|
46
|
+
*/
|
|
47
|
+
loaded: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Function to set new src.
|
|
50
|
+
*/
|
|
51
|
+
setSrc: (src: string) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Function to set loaded state.
|
|
54
|
+
*/
|
|
55
|
+
setLoaded: VoidFunction;
|
|
56
|
+
/**
|
|
57
|
+
* Function to set error state.
|
|
58
|
+
*/
|
|
59
|
+
setError: VoidFunction;
|
|
60
|
+
getRootProps: () => T["element"];
|
|
61
|
+
getImageProps: () => T["img"];
|
|
62
|
+
getFallbackProps: () => T["element"];
|
|
63
|
+
}
|