@mekari/pixel3-avatar 0.0.0 → 0.0.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.
@@ -47,8 +47,8 @@ declare const MpAvatarGroup: vue.DefineComponent<{
47
47
  onClick?: ((...args: any[]) => any) | undefined;
48
48
  }, {
49
49
  size: AvatarSize | undefined;
50
- spacing: number | undefined;
51
50
  max: number | undefined;
51
+ spacing: number | undefined;
52
52
  }, {}>;
53
53
 
54
54
  export { MpAvatarGroup };
@@ -47,8 +47,8 @@ declare const MpAvatarGroup: vue.DefineComponent<{
47
47
  onClick?: ((...args: any[]) => any) | undefined;
48
48
  }, {
49
49
  size: AvatarSize | undefined;
50
- spacing: number | undefined;
51
50
  max: number | undefined;
51
+ spacing: number | undefined;
52
52
  }, {}>;
53
53
 
54
54
  export { MpAvatarGroup };
@@ -24,8 +24,8 @@ __export(avatar_group_exports, {
24
24
  MpAvatarGroup: () => MpAvatarGroup
25
25
  });
26
26
  module.exports = __toCommonJS(avatar_group_exports);
27
+ var import_vue5 = require("vue");
27
28
  var import_vue6 = require("vue");
28
- var import_vue7 = require("vue");
29
29
  var import_pixel3_utils3 = require("@mekari/pixel3-utils");
30
30
 
31
31
  // src/modules/avatar.props.ts
@@ -55,43 +55,30 @@ var avatarGroupEmits = (0, import_pixel3_utils.declareEmit)(["click"]);
55
55
 
56
56
  // src/modules/avatar.hooks.ts
57
57
  var import_vue2 = require("vue");
58
- var import_vue3 = require("@xstate/vue");
59
- var import_pixel3_utils2 = require("@mekari/pixel3-utils");
60
58
  var import_recipes = require("@mekari/pixel3-styled-system/recipes");
61
59
 
62
- // src/modules/avatar.machines.ts
63
- var import_xstate = require("xstate");
64
- function avatarGroupMachine(context) {
65
- return (0, import_xstate.createMachine)({
66
- /** @xstate-layout N4IgpgJg5mDOIC5gF8A0IB2B7CdGgEMA3AgFwICcBaKCrAVwAd8RGtYBLUjrDFgD0QBGAEzoAnsJHIZyIA */
67
- id: "avatar-group",
68
- context,
69
- predictableActionArguments: true
70
- });
71
- }
72
- __name(avatarGroupMachine, "avatarGroupMachine");
73
-
74
60
  // src/modules/avatar.connects.ts
75
61
  var import_vue = require("vue");
62
+ var import_pixel3_utils2 = require("@mekari/pixel3-utils");
76
63
  var import_tokens = require("@mekari/pixel3-styled-system/tokens");
77
- function avatarGroupConnect(state, send, classes) {
64
+ function avatarGroupConnect(state, emit, classes) {
78
65
  const {
79
- id,
80
- onClick
81
- } = state.context;
66
+ id
67
+ } = state;
68
+ const idx = id != null ? id : `mp-avatar-group-${(0, import_pixel3_utils2.useId)()}`;
82
69
  const isClickable = (0, import_vue.computed)(() => {
83
70
  var _a, _b;
84
71
  return !!((_b = (_a = (0, import_vue.getCurrentInstance)()) == null ? void 0 : _a.vnode.props) == null ? void 0 : _b.onClick);
85
72
  }).value;
86
73
  return {
87
74
  rootProps: {
88
- id,
75
+ id: idx,
89
76
  class: classes.root,
90
77
  "data-pixel-component": "MpAvatarGroup"
91
78
  },
92
79
  excessProps: {
93
- id: `${id}-excess`,
94
- onClick,
80
+ id: `${idx}-excess`,
81
+ onClick: (evt) => emit("click", evt),
95
82
  class: classes.excess,
96
83
  style: {
97
84
  "--mp-avatar-group--cursor": isClickable ? "pointer" : void 0
@@ -104,38 +91,29 @@ __name(avatarGroupConnect, "avatarGroupConnect");
104
91
 
105
92
  // src/modules/avatar.hooks.ts
106
93
  var useAvatarGroup = /* @__PURE__ */ __name((props, emit) => {
107
- var _a;
108
94
  const context = (0, import_vue2.ref)(props);
109
- const {
110
- state,
111
- send
112
- } = (0, import_vue3.useMachine)(avatarGroupMachine({
113
- ...context.value,
114
- id: (_a = context.value.id) != null ? _a : `mp-avatar-group-${(0, import_pixel3_utils2.useId)()}`,
115
- onClick: (evt) => emit("click", evt)
116
- }));
117
- const [avatarGroupProps2] = import_recipes.avatarGroupSlotRecipe.splitVariantProps(context.value);
118
- const classes = (0, import_recipes.avatarGroupSlotRecipe)(avatarGroupProps2);
119
- return (0, import_vue2.computed)(() => avatarGroupConnect(state.value, send, classes));
95
+ const [value] = import_recipes.avatarGroupSlotRecipe.splitVariantProps(context.value);
96
+ const classes = (0, import_recipes.avatarGroupSlotRecipe)(value);
97
+ return (0, import_vue2.computed)(() => avatarGroupConnect(context.value, emit, classes));
120
98
  }, "useAvatarGroup");
121
99
 
122
100
  // src/avatar-excess.tsx
101
+ var import_vue3 = require("vue");
123
102
  var import_vue4 = require("vue");
124
- var import_vue5 = require("vue");
125
- var MpAvatarExcess = (0, import_vue5.defineComponent)({
103
+ var MpAvatarExcess = (0, import_vue4.defineComponent)({
126
104
  name: "MpAvatarExcess",
127
105
  setup(_, {
128
106
  slots
129
107
  }) {
130
108
  return () => {
131
109
  var _a;
132
- return (0, import_vue4.createVNode)("div", null, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
110
+ return (0, import_vue3.createVNode)("div", null, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
133
111
  };
134
112
  }
135
113
  });
136
114
 
137
115
  // src/avatar-group.tsx
138
- var MpAvatarGroup = (0, import_vue7.defineComponent)({
116
+ var MpAvatarGroup = (0, import_vue6.defineComponent)({
139
117
  name: "MpAvatarGroup",
140
118
  props: avatarGroupProps,
141
119
  emits: avatarGroupEmits,
@@ -144,18 +122,18 @@ var MpAvatarGroup = (0, import_vue7.defineComponent)({
144
122
  emit
145
123
  }) {
146
124
  const api = useAvatarGroup(props, emit);
147
- const children = (0, import_vue7.computed)(() => (0, import_pixel3_utils3.getChildren)(slots));
148
- const count = (0, import_vue7.computed)(() => children.value.length - (props.max || 0));
149
- const cloneChildren = (0, import_vue7.computed)(() => (0, import_vue7.computed)(() => children.value.slice(0, props.max)).value.map((vnode, index) => {
125
+ const children = (0, import_vue6.computed)(() => (0, import_pixel3_utils3.getChildren)(slots));
126
+ const count = (0, import_vue6.computed)(() => children.value.length - (props.max || 0));
127
+ const cloneChildren = (0, import_vue6.computed)(() => (0, import_vue6.computed)(() => children.value.slice(0, props.max)).value.map((vnode, index) => {
150
128
  const overrideProps = (0, import_pixel3_utils3.objectFilterUndefined)({
151
129
  size: props.size,
152
130
  spacing: index === 0 ? 0 : props.spacing,
153
131
  hasBorder: true,
154
132
  borderColor: props.borderColor
155
133
  });
156
- return (0, import_vue7.cloneVNode)(vnode, overrideProps);
134
+ return (0, import_vue6.cloneVNode)(vnode, overrideProps);
157
135
  }));
158
- return () => (0, import_vue6.createVNode)("div", api.value.rootProps, [cloneChildren.value, count.value > 0 && props.max !== 0 && (0, import_vue6.createVNode)(MpAvatarExcess, api.value.excessProps, {
136
+ return () => (0, import_vue5.createVNode)("div", api.value.rootProps, [cloneChildren.value, count.value > 0 && props.max !== 0 && (0, import_vue5.createVNode)(MpAvatarExcess, api.value.excessProps, {
159
137
  default: () => [`+${count.value}`]
160
138
  })]);
161
139
  }
@@ -1,11 +1,10 @@
1
1
  import {
2
2
  MpAvatarGroup
3
- } from "./chunk-RTYPPBOR.mjs";
3
+ } from "./chunk-EVJ6EN34.mjs";
4
4
  import "./chunk-CY2Z6I23.mjs";
5
5
  import "./chunk-ITYXDMOF.mjs";
6
- import "./chunk-JVROEGO3.mjs";
7
- import "./chunk-U4MXRXR7.mjs";
8
- import "./chunk-ZMUFXMG4.mjs";
6
+ import "./chunk-O4GQNW3M.mjs";
7
+ import "./chunk-7XAF53OT.mjs";
9
8
  import "./chunk-ZK47OSEJ.mjs";
10
9
  import "./chunk-QZ7VFGWC.mjs";
11
10
  export {
package/dist/avatar.d.mts CHANGED
@@ -92,11 +92,11 @@ declare const MpAvatar: vue.DefineComponent<{
92
92
  }>> & {
93
93
  onClick?: ((...args: any[]) => any) | undefined;
94
94
  }, {
95
- name: string | undefined;
96
95
  size: AvatarSize | undefined;
97
- variant: AvatarVariant | undefined;
98
- hasBorder: boolean | undefined;
99
96
  spacing: number | undefined;
97
+ name: string | undefined;
98
+ hasBorder: boolean | undefined;
99
+ variant: AvatarVariant | undefined;
100
100
  }, {}>;
101
101
 
102
102
  export { MpAvatar };
package/dist/avatar.d.ts CHANGED
@@ -92,11 +92,11 @@ declare const MpAvatar: vue.DefineComponent<{
92
92
  }>> & {
93
93
  onClick?: ((...args: any[]) => any) | undefined;
94
94
  }, {
95
- name: string | undefined;
96
95
  size: AvatarSize | undefined;
97
- variant: AvatarVariant | undefined;
98
- hasBorder: boolean | undefined;
99
96
  spacing: number | undefined;
97
+ name: string | undefined;
98
+ hasBorder: boolean | undefined;
99
+ variant: AvatarVariant | undefined;
100
100
  }, {}>;
101
101
 
102
102
  export { MpAvatar };
package/dist/avatar.js CHANGED
@@ -24,8 +24,8 @@ __export(avatar_exports, {
24
24
  MpAvatar: () => MpAvatar
25
25
  });
26
26
  module.exports = __toCommonJS(avatar_exports);
27
+ var import_vue7 = require("vue");
27
28
  var import_vue8 = require("vue");
28
- var import_vue9 = require("vue");
29
29
 
30
30
  // src/modules/avatar.props.ts
31
31
  var import_pixel3_utils = require("@mekari/pixel3-utils");
@@ -77,51 +77,11 @@ var avatarGroupEmits = (0, import_pixel3_utils.declareEmit)(["click"]);
77
77
 
78
78
  // src/modules/avatar.hooks.ts
79
79
  var import_vue2 = require("vue");
80
- var import_vue3 = require("@xstate/vue");
81
- var import_pixel3_utils2 = require("@mekari/pixel3-utils");
82
80
  var import_recipes = require("@mekari/pixel3-styled-system/recipes");
83
81
 
84
- // src/modules/avatar.machines.ts
85
- var import_xstate = require("xstate");
86
- function avatarMachine(context) {
87
- return (0, import_xstate.createMachine)({
88
- /** @xstate-layout N4IgpgJg5mDOIC5QEMBuyAuyBOA6ANgPbIQCWAdlAMQCSAsgOID6AMgPICCAIgKJcDaABgC6iUAAdCsUhlKFyYkAA9EARgAsATlwBWAMybBANgBMOgDQgAnojMncAdh0BfZ5bSYcBYmUq1GTDwASkFsQUKiSCCS0rLyiioIGtr6hqYW1ogAHA64gll6hUXFha7u6Fh4RCSQ-szBoeEiijEycgpRieoajnrqek6WNghZqrplIB6VuGDY2ITYdaycvALNUa1xHaBdgnq4mgMZw6p6Jq5uIOSEEHCKUzgtUm3xnYgAtEZDH0YTD1U+ChQJ6xdoJRDqEzfBCadR-Cpeaq3CAgl7bZSIHRGfajMzQ04uS7-GZzBaorbghB6QTabrqYx4zIjXI6AoldkXZxAA */
89
- id: "avatar",
90
- context,
91
- initial: "loading",
92
- states: {
93
- loading: {
94
- on: {
95
- IMG_LOADED: {
96
- target: "loaded"
97
- },
98
- IMG_ERROR: {
99
- target: "error"
100
- }
101
- }
102
- },
103
- loaded: {
104
- on: {
105
- IMG_ERROR: {
106
- target: "error"
107
- }
108
- }
109
- },
110
- error: {
111
- on: {
112
- IMG_LOADED: {
113
- target: "loaded"
114
- }
115
- }
116
- }
117
- },
118
- predictableActionArguments: true
119
- });
120
- }
121
- __name(avatarMachine, "avatarMachine");
122
-
123
82
  // src/modules/avatar.connects.ts
124
83
  var import_vue = require("vue");
84
+ var import_pixel3_utils2 = require("@mekari/pixel3-utils");
125
85
  var import_tokens = require("@mekari/pixel3-styled-system/tokens");
126
86
 
127
87
  // src/modules/avatar.utils.ts
@@ -142,7 +102,7 @@ var isColorInList = /* @__PURE__ */ __name((value) => {
142
102
  }, "isColorInList");
143
103
 
144
104
  // src/modules/avatar.connects.ts
145
- function avatarConnect(state, send, classes) {
105
+ function avatarConnect(state, emit, classes) {
146
106
  const {
147
107
  id,
148
108
  name,
@@ -153,10 +113,10 @@ function avatarConnect(state, send, classes) {
153
113
  icon,
154
114
  iconVariant,
155
115
  iconColor,
156
- spacing,
157
- onClick
158
- } = state.context;
159
- const isLoaded = state.matches("loaded");
116
+ spacing
117
+ } = state;
118
+ const idx = id != null ? id : `mp-avatar-${(0, import_pixel3_utils2.useId)()}`;
119
+ const isLoaded = (0, import_vue.ref)(false);
160
120
  const isClickable = (0, import_vue.computed)(() => {
161
121
  var _a, _b;
162
122
  return !!((_b = (_a = (0, import_vue.getCurrentInstance)()) == null ? void 0 : _a.vnode.props) == null ? void 0 : _b.onClick);
@@ -168,8 +128,8 @@ function avatarConnect(state, send, classes) {
168
128
  icon,
169
129
  isLoaded,
170
130
  rootProps: {
171
- id,
172
- onClick,
131
+ id: idx,
132
+ onClick: (evt) => emit("click", evt),
173
133
  class: classes.root,
174
134
  style: {
175
135
  "--mp-avatar--cursor": isClickable ? "pointer" : void 0,
@@ -181,33 +141,31 @@ function avatarConnect(state, send, classes) {
181
141
  "data-pixel-component": "MpAvatar"
182
142
  },
183
143
  fallbackProps: {
184
- id: `${id}-fallback`,
144
+ id: `${idx}-fallback`,
185
145
  class: classes.fallback,
186
146
  "data-pixel-component": "MpAvatarFallback"
187
147
  },
188
148
  imageProps: {
189
- id: `${id}-image`,
149
+ id: `${idx}-image`,
190
150
  alt: name,
191
151
  src,
192
- onLoad() {
193
- send({
194
- type: "IMG_LOADED"
195
- });
152
+ onLoad: (evt) => {
153
+ isLoaded.value = true;
154
+ emit("load", evt);
196
155
  },
197
- onError() {
198
- send({
199
- type: "IMG_ERROR"
200
- });
156
+ onError: (evt) => {
157
+ isLoaded.value = false;
158
+ emit("error", evt);
201
159
  },
202
160
  class: classes.image,
203
161
  style: {
204
- "--mp-avatar--visibility": !isLoaded ? "hidden" : void 0,
205
- "--mp-avatar--display": !isLoaded ? "contents" : void 0
162
+ "--mp-avatar--visibility": !isLoaded.value ? "hidden" : void 0,
163
+ "--mp-avatar--display": !isLoaded.value ? "contents" : void 0
206
164
  },
207
165
  "data-pixel-component": "MpAvatarImage"
208
166
  },
209
167
  iconProps: {
210
- id: `${id}-icon`,
168
+ id: `${idx}-icon`,
211
169
  name: icon,
212
170
  variant: iconVariant,
213
171
  variantColor: iconColor,
@@ -220,54 +178,45 @@ __name(avatarConnect, "avatarConnect");
220
178
 
221
179
  // src/modules/avatar.hooks.ts
222
180
  var useAvatar = /* @__PURE__ */ __name((props, emit) => {
223
- var _a;
224
181
  const context = (0, import_vue2.ref)(props);
225
- const {
226
- state,
227
- send
228
- } = (0, import_vue3.useMachine)(avatarMachine({
229
- ...context.value,
230
- id: (_a = context.value.id) != null ? _a : `mp-avatar-${(0, import_pixel3_utils2.useId)()}`,
231
- onClick: (evt) => emit("click", evt)
232
- }));
233
- const [avatarProps2] = import_recipes.avatarSlotRecipe.splitVariantProps(context.value);
234
- const classes = (0, import_recipes.avatarSlotRecipe)(avatarProps2);
235
- return (0, import_vue2.computed)(() => avatarConnect(state.value, send, classes));
182
+ const [value] = import_recipes.avatarSlotRecipe.splitVariantProps(context.value);
183
+ const classes = (0, import_recipes.avatarSlotRecipe)(value);
184
+ return (0, import_vue2.computed)(() => avatarConnect(context.value, emit, classes));
236
185
  }, "useAvatar");
237
186
 
238
187
  // src/avatar.tsx
239
188
  var import_pixel3_icon = require("@mekari/pixel3-icon");
240
189
 
241
190
  // src/avatar-fallback.tsx
191
+ var import_vue3 = require("vue");
242
192
  var import_vue4 = require("vue");
243
- var import_vue5 = require("vue");
244
- var MpAvatarFallback = (0, import_vue5.defineComponent)({
193
+ var MpAvatarFallback = (0, import_vue4.defineComponent)({
245
194
  name: "MpAvatarFallback",
246
195
  setup() {
247
- return () => (0, import_vue4.createVNode)("div", null, [(0, import_vue4.createVNode)("svg", {
196
+ return () => (0, import_vue3.createVNode)("div", null, [(0, import_vue3.createVNode)("svg", {
248
197
  "fill": "#ffffff",
249
198
  "viewBox": "0 0 128 128",
250
199
  "role": "img"
251
- }, [(0, import_vue4.createVNode)("path", {
200
+ }, [(0, import_vue3.createVNode)("path", {
252
201
  "d": "M103,102.1388 C93.094,111.92 79.3504,118 64.1638,118 C48.8056,118 34.9294,111.768 25,101.7892 L25,95.2 C25,86.8096 31.981,80 40.6,80 L87.4,80 C96.019,80 103,86.8096 103,95.2 L103,102.1388 Z"
253
- }, null), (0, import_vue4.createVNode)("path", {
202
+ }, null), (0, import_vue3.createVNode)("path", {
254
203
  "d": "M63.9961647,24 C51.2938136,24 41,34.2938136 41,46.9961647 C41,59.7061864 51.2938136,70 63.9961647,70 C76.6985159,70 87,59.7061864 87,46.9961647 C87,34.2938136 76.6985159,24 63.9961647,24"
255
204
  }, null)])]);
256
205
  }
257
206
  });
258
207
 
259
208
  // src/avatar-image.tsx
209
+ var import_vue5 = require("vue");
260
210
  var import_vue6 = require("vue");
261
- var import_vue7 = require("vue");
262
- var MpAvatarImage = (0, import_vue7.defineComponent)({
211
+ var MpAvatarImage = (0, import_vue6.defineComponent)({
263
212
  name: "MpAvatarImage",
264
213
  setup() {
265
- return () => (0, import_vue6.createVNode)("img", null, null);
214
+ return () => (0, import_vue5.createVNode)("img", null, null);
266
215
  }
267
216
  });
268
217
 
269
218
  // src/avatar.tsx
270
- var MpAvatar = (0, import_vue9.defineComponent)({
219
+ var MpAvatar = (0, import_vue8.defineComponent)({
271
220
  name: "MpAvatar",
272
221
  props: avatarProps,
273
222
  emits: avatarEmits,
@@ -275,7 +224,7 @@ var MpAvatar = (0, import_vue9.defineComponent)({
275
224
  emit
276
225
  }) {
277
226
  const api = useAvatar(props, emit);
278
- return () => (0, import_vue8.createVNode)("div", api.value.rootProps, [api.value.src ? (0, import_vue8.createVNode)(MpAvatarImage, api.value.imageProps, null) : void 0, !api.value.icon && !api.value.src || api.value.src && !api.value.isLoaded ? api.value.name ? getInitial(api.value.name) : (0, import_vue8.createVNode)(MpAvatarFallback, api.value.fallbackProps, null) : void 0, api.value.icon && (0, import_vue8.createVNode)(import_pixel3_icon.MpIcon, api.value.iconProps, null)]);
227
+ return () => (0, import_vue7.createVNode)("div", api.value.rootProps, [api.value.src ? (0, import_vue7.createVNode)(MpAvatarImage, api.value.imageProps, null) : void 0, !api.value.icon && !api.value.src || api.value.src && !api.value.isLoaded ? api.value.name ? getInitial(api.value.name) : (0, import_vue7.createVNode)(MpAvatarFallback, api.value.fallbackProps, null) : void 0, api.value.icon && (0, import_vue7.createVNode)(import_pixel3_icon.MpIcon, api.value.iconProps, null)]);
279
228
  }
280
229
  });
281
230
  // Annotate the CommonJS export names for ESM import in node:
package/dist/avatar.mjs CHANGED
@@ -1,12 +1,11 @@
1
1
  import {
2
2
  MpAvatar
3
- } from "./chunk-43VB6T4V.mjs";
3
+ } from "./chunk-W3IXO3TE.mjs";
4
4
  import "./chunk-NKXS73IR.mjs";
5
5
  import "./chunk-ITYXDMOF.mjs";
6
6
  import "./chunk-4VNSI4PL.mjs";
7
- import "./chunk-JVROEGO3.mjs";
8
- import "./chunk-U4MXRXR7.mjs";
9
- import "./chunk-ZMUFXMG4.mjs";
7
+ import "./chunk-O4GQNW3M.mjs";
8
+ import "./chunk-7XAF53OT.mjs";
10
9
  import "./chunk-ZK47OSEJ.mjs";
11
10
  import "./chunk-QZ7VFGWC.mjs";
12
11
  export {
@@ -7,9 +7,10 @@ import {
7
7
  } from "./chunk-QZ7VFGWC.mjs";
8
8
 
9
9
  // src/modules/avatar.connects.ts
10
- import { computed, getCurrentInstance } from "vue";
10
+ import { computed, ref, getCurrentInstance } from "vue";
11
+ import { useId } from "@mekari/pixel3-utils";
11
12
  import { token } from "@mekari/pixel3-styled-system/tokens";
12
- function avatarConnect(state, send, classes) {
13
+ function avatarConnect(state, emit, classes) {
13
14
  const {
14
15
  id,
15
16
  name,
@@ -20,10 +21,10 @@ function avatarConnect(state, send, classes) {
20
21
  icon,
21
22
  iconVariant,
22
23
  iconColor,
23
- spacing,
24
- onClick
25
- } = state.context;
26
- const isLoaded = state.matches("loaded");
24
+ spacing
25
+ } = state;
26
+ const idx = id != null ? id : `mp-avatar-${useId()}`;
27
+ const isLoaded = ref(false);
27
28
  const isClickable = computed(() => {
28
29
  var _a, _b;
29
30
  return !!((_b = (_a = getCurrentInstance()) == null ? void 0 : _a.vnode.props) == null ? void 0 : _b.onClick);
@@ -35,8 +36,8 @@ function avatarConnect(state, send, classes) {
35
36
  icon,
36
37
  isLoaded,
37
38
  rootProps: {
38
- id,
39
- onClick,
39
+ id: idx,
40
+ onClick: (evt) => emit("click", evt),
40
41
  class: classes.root,
41
42
  style: {
42
43
  "--mp-avatar--cursor": isClickable ? "pointer" : void 0,
@@ -48,33 +49,31 @@ function avatarConnect(state, send, classes) {
48
49
  "data-pixel-component": "MpAvatar"
49
50
  },
50
51
  fallbackProps: {
51
- id: `${id}-fallback`,
52
+ id: `${idx}-fallback`,
52
53
  class: classes.fallback,
53
54
  "data-pixel-component": "MpAvatarFallback"
54
55
  },
55
56
  imageProps: {
56
- id: `${id}-image`,
57
+ id: `${idx}-image`,
57
58
  alt: name,
58
59
  src,
59
- onLoad() {
60
- send({
61
- type: "IMG_LOADED"
62
- });
60
+ onLoad: (evt) => {
61
+ isLoaded.value = true;
62
+ emit("load", evt);
63
63
  },
64
- onError() {
65
- send({
66
- type: "IMG_ERROR"
67
- });
64
+ onError: (evt) => {
65
+ isLoaded.value = false;
66
+ emit("error", evt);
68
67
  },
69
68
  class: classes.image,
70
69
  style: {
71
- "--mp-avatar--visibility": !isLoaded ? "hidden" : void 0,
72
- "--mp-avatar--display": !isLoaded ? "contents" : void 0
70
+ "--mp-avatar--visibility": !isLoaded.value ? "hidden" : void 0,
71
+ "--mp-avatar--display": !isLoaded.value ? "contents" : void 0
73
72
  },
74
73
  "data-pixel-component": "MpAvatarImage"
75
74
  },
76
75
  iconProps: {
77
- id: `${id}-icon`,
76
+ id: `${idx}-icon`,
78
77
  name: icon,
79
78
  variant: iconVariant,
80
79
  variantColor: iconColor,
@@ -84,24 +83,24 @@ function avatarConnect(state, send, classes) {
84
83
  };
85
84
  }
86
85
  __name(avatarConnect, "avatarConnect");
87
- function avatarGroupConnect(state, send, classes) {
86
+ function avatarGroupConnect(state, emit, classes) {
88
87
  const {
89
- id,
90
- onClick
91
- } = state.context;
88
+ id
89
+ } = state;
90
+ const idx = id != null ? id : `mp-avatar-group-${useId()}`;
92
91
  const isClickable = computed(() => {
93
92
  var _a, _b;
94
93
  return !!((_b = (_a = getCurrentInstance()) == null ? void 0 : _a.vnode.props) == null ? void 0 : _b.onClick);
95
94
  }).value;
96
95
  return {
97
96
  rootProps: {
98
- id,
97
+ id: idx,
99
98
  class: classes.root,
100
99
  "data-pixel-component": "MpAvatarGroup"
101
100
  },
102
101
  excessProps: {
103
- id: `${id}-excess`,
104
- onClick,
102
+ id: `${idx}-excess`,
103
+ onClick: (evt) => emit("click", evt),
105
104
  class: classes.excess,
106
105
  style: {
107
106
  "--mp-avatar-group--cursor": isClickable ? "pointer" : void 0
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-ITYXDMOF.mjs";
8
8
  import {
9
9
  useAvatarGroup
10
- } from "./chunk-JVROEGO3.mjs";
10
+ } from "./chunk-O4GQNW3M.mjs";
11
11
 
12
12
  // src/avatar-group.tsx
13
13
  import { createVNode as _createVNode } from "vue";
@@ -0,0 +1,28 @@
1
+ import {
2
+ avatarConnect,
3
+ avatarGroupConnect
4
+ } from "./chunk-7XAF53OT.mjs";
5
+ import {
6
+ __name
7
+ } from "./chunk-QZ7VFGWC.mjs";
8
+
9
+ // src/modules/avatar.hooks.ts
10
+ import { computed, ref } from "vue";
11
+ import { avatarSlotRecipe, avatarGroupSlotRecipe } from "@mekari/pixel3-styled-system/recipes";
12
+ var useAvatar = /* @__PURE__ */ __name((props, emit) => {
13
+ const context = ref(props);
14
+ const [value] = avatarSlotRecipe.splitVariantProps(context.value);
15
+ const classes = avatarSlotRecipe(value);
16
+ return computed(() => avatarConnect(context.value, emit, classes));
17
+ }, "useAvatar");
18
+ var useAvatarGroup = /* @__PURE__ */ __name((props, emit) => {
19
+ const context = ref(props);
20
+ const [value] = avatarGroupSlotRecipe.splitVariantProps(context.value);
21
+ const classes = avatarGroupSlotRecipe(value);
22
+ return computed(() => avatarGroupConnect(context.value, emit, classes));
23
+ }, "useAvatarGroup");
24
+
25
+ export {
26
+ useAvatar,
27
+ useAvatarGroup
28
+ };
@@ -10,7 +10,7 @@ import {
10
10
  } from "./chunk-4VNSI4PL.mjs";
11
11
  import {
12
12
  useAvatar
13
- } from "./chunk-JVROEGO3.mjs";
13
+ } from "./chunk-O4GQNW3M.mjs";
14
14
  import {
15
15
  getInitial
16
16
  } from "./chunk-ZK47OSEJ.mjs";