@zag-js/avatar 2.0.0-next.2 → 2.0.0-next.4

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.
@@ -1,6 +1,2 @@
1
- import * as _zag_js_anatomy from '@zag-js/anatomy';
2
-
3
- declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "image" | "fallback">;
4
- declare const parts: Record<"root" | "image" | "fallback", _zag_js_anatomy.AnatomyPart>;
5
-
6
- export { anatomy, parts };
1
+ export declare const anatomy: import("@zag-js/anatomy").AnatomyInstance<"fallback" | "image" | "root">;
2
+ export declare const parts: Record<"fallback" | "image" | "root", import("@zag-js/anatomy").AnatomyPart>;
@@ -1,6 +1,2 @@
1
- import * as _zag_js_anatomy from '@zag-js/anatomy';
2
-
3
- declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "image" | "fallback">;
4
- declare const parts: Record<"root" | "image" | "fallback", _zag_js_anatomy.AnatomyPart>;
5
-
6
- export { anatomy, parts };
1
+ export declare const anatomy: import("@zag-js/anatomy").AnatomyInstance<"fallback" | "image" | "root">;
2
+ export declare const parts: Record<"fallback" | "image" | "root", import("@zag-js/anatomy").AnatomyPart>;
@@ -1,34 +1,9 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
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.anatomy.ts
21
- var avatar_anatomy_exports = {};
22
- __export(avatar_anatomy_exports, {
23
- anatomy: () => anatomy,
24
- parts: () => parts
25
- });
26
- module.exports = __toCommonJS(avatar_anatomy_exports);
27
- var import_anatomy = require("@zag-js/anatomy");
28
- var anatomy = (0, import_anatomy.createAnatomy)("avatar").parts("root", "image", "fallback");
29
- var parts = anatomy.build();
30
- // Annotate the CommonJS export names for ESM import in node:
31
- 0 && (module.exports = {
32
- anatomy,
33
- parts
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
34
4
  });
5
+ // src/avatar.anatomy.ts
6
+ const anatomy = (0, require("@zag-js/anatomy").createAnatomy)("avatar").parts("root", "image", "fallback");
7
+ const parts = anatomy.build();
8
+ exports.anatomy = anatomy;
9
+ exports.parts = parts;
@@ -1,8 +1,5 @@
1
- // src/avatar.anatomy.ts
2
1
  import { createAnatomy } from "@zag-js/anatomy";
3
- var anatomy = createAnatomy("avatar").parts("root", "image", "fallback");
4
- var parts = anatomy.build();
5
- export {
6
- anatomy,
7
- parts
8
- };
2
+ // src/avatar.anatomy.ts
3
+ const anatomy = createAnatomy("avatar").parts("root", "image", "fallback");
4
+ const parts = anatomy.build();
5
+ export { anatomy, parts };
@@ -1,7 +1,4 @@
1
- import { PropTypes, NormalizeProps } from '@zag-js/types';
2
- import { Service } from '@zag-js/core';
3
- import { AvatarSchema, AvatarApi } from './avatar.types.mjs';
4
-
5
- declare function connect<T extends PropTypes>(service: Service<AvatarSchema>, normalize: NormalizeProps<T>): AvatarApi<T>;
6
-
7
- export { connect };
1
+ import { AvatarApi, AvatarSchema } from "./avatar.types.mjs";
2
+ import { Service } from "@zag-js/core";
3
+ import { NormalizeProps, PropTypes } from "@zag-js/types";
4
+ export declare function connect<T extends PropTypes>(service: Service<AvatarSchema>, normalize: NormalizeProps<T>): AvatarApi<T>;
@@ -1,7 +1,4 @@
1
- import { PropTypes, NormalizeProps } from '@zag-js/types';
2
- import { Service } from '@zag-js/core';
3
- import { AvatarSchema, AvatarApi } from './avatar.types.js';
4
-
5
- declare function connect<T extends PropTypes>(service: Service<AvatarSchema>, normalize: NormalizeProps<T>): AvatarApi<T>;
6
-
7
- export { connect };
1
+ import { AvatarApi, AvatarSchema } from "./avatar.types.js";
2
+ import { NormalizeProps, PropTypes } from "@zag-js/types";
3
+ import { Service } from "@zag-js/core";
4
+ export declare function connect<T extends PropTypes>(service: Service<AvatarSchema>, normalize: NormalizeProps<T>): AvatarApi<T>;
@@ -1,79 +1,74 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
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.connect.ts
21
- var avatar_connect_exports = {};
22
- __export(avatar_connect_exports, {
23
- connect: () => connect
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
24
4
  });
25
- module.exports = __toCommonJS(avatar_connect_exports);
26
- var import_avatar = require("./avatar.anatomy.js");
5
+ const require_avatar_anatomy = require("./avatar.anatomy.js");
6
+ // src/avatar.connect.ts
27
7
  function connect(service, normalize) {
28
- const { send, prop, scope } = service;
29
- const status = getStatus(service);
30
- const loaded = status === "loaded";
31
- return {
32
- status,
33
- loaded,
34
- setLoaded() {
35
- send({ type: "img.loaded", src: "api" });
36
- },
37
- setError() {
38
- send({ type: "img.error", src: "api" });
39
- },
40
- getRootProps() {
41
- return normalize.element({
42
- ...import_avatar.parts.root.attrs(scope.id),
43
- dir: prop("dir")
44
- });
45
- },
46
- getImageProps() {
47
- return normalize.img({
48
- ...import_avatar.parts.image.attrs(scope.id),
49
- hidden: !loaded,
50
- dir: prop("dir"),
51
- "data-state": loaded ? "visible" : "hidden",
52
- onLoad() {
53
- send({ type: "img.loaded", src: "element" });
54
- },
55
- onError() {
56
- send({ type: "img.error", src: "element" });
57
- }
58
- });
59
- },
60
- getFallbackProps() {
61
- return normalize.element({
62
- ...import_avatar.parts.fallback.attrs(scope.id),
63
- dir: prop("dir"),
64
- hidden: loaded,
65
- "data-state": loaded ? "hidden" : "visible"
66
- });
67
- }
68
- };
8
+ const { send, prop, scope } = service;
9
+ const status = getStatus(service);
10
+ const loaded = status === "loaded";
11
+ function getRootState() {
12
+ return { status };
13
+ }
14
+ return {
15
+ status,
16
+ loaded,
17
+ setLoaded() {
18
+ send({
19
+ type: "img.loaded",
20
+ src: "api"
21
+ });
22
+ },
23
+ setError() {
24
+ send({
25
+ type: "img.error",
26
+ src: "api"
27
+ });
28
+ },
29
+ getRootState,
30
+ getRootProps() {
31
+ const rootState = getRootState();
32
+ return normalize.element({
33
+ ...require_avatar_anatomy.parts.root.attrs(scope.id),
34
+ dir: prop("dir"),
35
+ "data-status": rootState.status
36
+ });
37
+ },
38
+ getImageProps() {
39
+ return normalize.img({
40
+ ...require_avatar_anatomy.parts.image.attrs(scope.id),
41
+ hidden: !loaded,
42
+ dir: prop("dir"),
43
+ "data-state": loaded ? "visible" : "hidden",
44
+ onLoad() {
45
+ send({
46
+ type: "img.loaded",
47
+ src: "element"
48
+ });
49
+ },
50
+ onError() {
51
+ send({
52
+ type: "img.error",
53
+ src: "element"
54
+ });
55
+ }
56
+ });
57
+ },
58
+ getFallbackProps() {
59
+ return normalize.element({
60
+ ...require_avatar_anatomy.parts.fallback.attrs(scope.id),
61
+ dir: prop("dir"),
62
+ hidden: loaded,
63
+ "data-state": loaded ? "hidden" : "visible"
64
+ });
65
+ }
66
+ };
69
67
  }
70
68
  function getStatus(service) {
71
- const { state } = service;
72
- if (state.matches("error")) return "error";
73
- if (state.matches("loaded")) return "loaded";
74
- return "loading";
69
+ const { state } = service;
70
+ if (state.matches("error")) return "error";
71
+ if (state.matches("loaded")) return "loaded";
72
+ return "loading";
75
73
  }
76
- // Annotate the CommonJS export names for ESM import in node:
77
- 0 && (module.exports = {
78
- connect
79
- });
74
+ exports.connect = connect;
@@ -1,54 +1,70 @@
1
- // src/avatar.connect.ts
2
1
  import { parts } from "./avatar.anatomy.mjs";
2
+ // src/avatar.connect.ts
3
3
  function connect(service, normalize) {
4
- const { send, prop, scope } = service;
5
- const status = getStatus(service);
6
- const loaded = status === "loaded";
7
- return {
8
- status,
9
- loaded,
10
- setLoaded() {
11
- send({ type: "img.loaded", src: "api" });
12
- },
13
- setError() {
14
- send({ type: "img.error", src: "api" });
15
- },
16
- getRootProps() {
17
- return normalize.element({
18
- ...parts.root.attrs(scope.id),
19
- dir: prop("dir")
20
- });
21
- },
22
- getImageProps() {
23
- return normalize.img({
24
- ...parts.image.attrs(scope.id),
25
- hidden: !loaded,
26
- dir: prop("dir"),
27
- "data-state": loaded ? "visible" : "hidden",
28
- onLoad() {
29
- send({ type: "img.loaded", src: "element" });
30
- },
31
- onError() {
32
- send({ type: "img.error", src: "element" });
33
- }
34
- });
35
- },
36
- getFallbackProps() {
37
- return normalize.element({
38
- ...parts.fallback.attrs(scope.id),
39
- dir: prop("dir"),
40
- hidden: loaded,
41
- "data-state": loaded ? "hidden" : "visible"
42
- });
43
- }
44
- };
4
+ const { send, prop, scope } = service;
5
+ const status = getStatus(service);
6
+ const loaded = status === "loaded";
7
+ function getRootState() {
8
+ return { status };
9
+ }
10
+ return {
11
+ status,
12
+ loaded,
13
+ setLoaded() {
14
+ send({
15
+ type: "img.loaded",
16
+ src: "api"
17
+ });
18
+ },
19
+ setError() {
20
+ send({
21
+ type: "img.error",
22
+ src: "api"
23
+ });
24
+ },
25
+ getRootState,
26
+ getRootProps() {
27
+ const rootState = getRootState();
28
+ return normalize.element({
29
+ ...parts.root.attrs(scope.id),
30
+ dir: prop("dir"),
31
+ "data-status": rootState.status
32
+ });
33
+ },
34
+ getImageProps() {
35
+ return normalize.img({
36
+ ...parts.image.attrs(scope.id),
37
+ hidden: !loaded,
38
+ dir: prop("dir"),
39
+ "data-state": loaded ? "visible" : "hidden",
40
+ onLoad() {
41
+ send({
42
+ type: "img.loaded",
43
+ src: "element"
44
+ });
45
+ },
46
+ onError() {
47
+ send({
48
+ type: "img.error",
49
+ src: "element"
50
+ });
51
+ }
52
+ });
53
+ },
54
+ getFallbackProps() {
55
+ return normalize.element({
56
+ ...parts.fallback.attrs(scope.id),
57
+ dir: prop("dir"),
58
+ hidden: loaded,
59
+ "data-state": loaded ? "hidden" : "visible"
60
+ });
61
+ }
62
+ };
45
63
  }
46
64
  function getStatus(service) {
47
- const { state } = service;
48
- if (state.matches("error")) return "error";
49
- if (state.matches("loaded")) return "loaded";
50
- return "loading";
65
+ const { state } = service;
66
+ if (state.matches("error")) return "error";
67
+ if (state.matches("loaded")) return "loaded";
68
+ return "loading";
51
69
  }
52
- export {
53
- connect
54
- };
70
+ export { connect };
@@ -1,9 +1,6 @@
1
- import { Scope } from '@zag-js/core';
2
-
3
- declare const getRootId: (ctx: Scope) => any;
4
- declare const getImageId: (ctx: Scope) => any;
5
- declare const getFallbackId: (ctx: Scope) => any;
6
- declare const getRootEl: (ctx: Scope) => HTMLElement | null;
7
- declare const getImageEl: (ctx: Scope) => HTMLImageElement | null;
8
-
9
- export { getFallbackId, getImageEl, getImageId, getRootEl, getRootId };
1
+ import { Scope } from "@zag-js/core";
2
+ export declare const getRootId: (ctx: Scope) => any;
3
+ export declare const getImageId: (ctx: Scope) => any;
4
+ export declare const getFallbackId: (ctx: Scope) => any;
5
+ export declare const getRootEl: (ctx: Scope) => HTMLElement | null;
6
+ export declare const getImageEl: (ctx: Scope) => HTMLImageElement | null;
@@ -1,9 +1,6 @@
1
- import { Scope } from '@zag-js/core';
2
-
3
- declare const getRootId: (ctx: Scope) => any;
4
- declare const getImageId: (ctx: Scope) => any;
5
- declare const getFallbackId: (ctx: Scope) => any;
6
- declare const getRootEl: (ctx: Scope) => HTMLElement | null;
7
- declare const getImageEl: (ctx: Scope) => HTMLImageElement | null;
8
-
9
- export { getFallbackId, getImageEl, getImageId, getRootEl, getRootId };
1
+ import { Scope } from "@zag-js/core";
2
+ export declare const getRootId: (ctx: Scope) => any;
3
+ export declare const getImageId: (ctx: Scope) => any;
4
+ export declare const getFallbackId: (ctx: Scope) => any;
5
+ export declare const getRootEl: (ctx: Scope) => HTMLElement | null;
6
+ export declare const getImageEl: (ctx: Scope) => HTMLImageElement | null;
@@ -1,43 +1,16 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
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.dom.ts
21
- var avatar_dom_exports = {};
22
- __export(avatar_dom_exports, {
23
- getFallbackId: () => getFallbackId,
24
- getImageEl: () => getImageEl,
25
- getImageId: () => getImageId,
26
- getRootEl: () => getRootEl,
27
- getRootId: () => getRootId
28
- });
29
- module.exports = __toCommonJS(avatar_dom_exports);
30
- var import_avatar = require("./avatar.anatomy.js");
31
- var getRootId = (ctx) => ctx.ids?.root ?? `${ctx.id}`;
32
- var getImageId = (ctx) => ctx.ids?.image ?? `${ctx.id}:image`;
33
- var getFallbackId = (ctx) => ctx.ids?.fallback ?? `${ctx.id}:fallback`;
34
- var getRootEl = (ctx) => ctx.query(ctx.selector(import_avatar.parts.root));
35
- var getImageEl = (ctx) => ctx.query(ctx.selector(import_avatar.parts.image));
36
- // Annotate the CommonJS export names for ESM import in node:
37
- 0 && (module.exports = {
38
- getFallbackId,
39
- getImageEl,
40
- getImageId,
41
- getRootEl,
42
- getRootId
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
43
4
  });
5
+ const require_avatar_anatomy = require("./avatar.anatomy.js");
6
+ // src/avatar.dom.ts
7
+ const getRootId = (ctx) => ctx.ids?.root ?? `${ctx.id}`;
8
+ const getImageId = (ctx) => ctx.ids?.image ?? `${ctx.id}:image`;
9
+ const getFallbackId = (ctx) => ctx.ids?.fallback ?? `${ctx.id}:fallback`;
10
+ const getRootEl = (ctx) => ctx.query(ctx.selector(require_avatar_anatomy.parts.root));
11
+ const getImageEl = (ctx) => ctx.query(ctx.selector(require_avatar_anatomy.parts.image));
12
+ exports.getFallbackId = getFallbackId;
13
+ exports.getImageEl = getImageEl;
14
+ exports.getImageId = getImageId;
15
+ exports.getRootEl = getRootEl;
16
+ exports.getRootId = getRootId;
@@ -1,14 +1,8 @@
1
- // src/avatar.dom.ts
2
1
  import { parts } from "./avatar.anatomy.mjs";
3
- var getRootId = (ctx) => ctx.ids?.root ?? `${ctx.id}`;
4
- var getImageId = (ctx) => ctx.ids?.image ?? `${ctx.id}:image`;
5
- var getFallbackId = (ctx) => ctx.ids?.fallback ?? `${ctx.id}:fallback`;
6
- var getRootEl = (ctx) => ctx.query(ctx.selector(parts.root));
7
- var getImageEl = (ctx) => ctx.query(ctx.selector(parts.image));
8
- export {
9
- getFallbackId,
10
- getImageEl,
11
- getImageId,
12
- getRootEl,
13
- getRootId
14
- };
2
+ // src/avatar.dom.ts
3
+ const getRootId = (ctx) => ctx.ids?.root ?? `${ctx.id}`;
4
+ const getImageId = (ctx) => ctx.ids?.image ?? `${ctx.id}:image`;
5
+ const getFallbackId = (ctx) => ctx.ids?.fallback ?? `${ctx.id}:fallback`;
6
+ const getRootEl = (ctx) => ctx.query(ctx.selector(parts.root));
7
+ const getImageEl = (ctx) => ctx.query(ctx.selector(parts.image));
8
+ export { getFallbackId, getImageEl, getImageId, getRootEl, getRootId };
@@ -1,7 +1,2 @@
1
- import * as _zag_js_core from '@zag-js/core';
2
- import { AvatarSchema } from './avatar.types.mjs';
3
- import '@zag-js/types';
4
-
5
- declare const machine: _zag_js_core.Machine<AvatarSchema>;
6
-
7
- export { machine };
1
+ import { AvatarSchema } from "./avatar.types.mjs";
2
+ export declare const machine: import("@zag-js/core").Machine<AvatarSchema>;
@@ -1,7 +1,2 @@
1
- import * as _zag_js_core from '@zag-js/core';
2
- import { AvatarSchema } from './avatar.types.js';
3
- import '@zag-js/types';
4
-
5
- declare const machine: _zag_js_core.Machine<AvatarSchema>;
6
-
7
- export { machine };
1
+ import { AvatarSchema } from "./avatar.types.js";
2
+ export declare const machine: import("@zag-js/core").Machine<AvatarSchema>;