vira 2.4.0 → 2.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.
@@ -39,4 +39,7 @@ export declare const ViraImage: import("element-vir").DeclarativeElementDefiniti
39
39
  erroredUrls: Readonly<{
40
40
  [url: string]: true;
41
41
  }>;
42
- }, {}, "vira-image-height-constrained", `vira-image-${string}`, import("lit-html").HTMLTemplateResult>;
42
+ }, {
43
+ imageLoad: import("element-vir").DefinedTypedEventNameDefinition<void>;
44
+ imageError: import("element-vir").DefinedTypedEventNameDefinition<unknown>;
45
+ }, "vira-image-height-constrained", `vira-image-${string}`, import("lit-html").HTMLTemplateResult>;
@@ -1,5 +1,5 @@
1
1
  import { wait } from '@augment-vir/common';
2
- import { classMap, css, html, listen, renderIf } from 'element-vir';
2
+ import { classMap, css, defineElementEvent, html, listen, renderIf } from 'element-vir';
3
3
  import { LoaderAnimated24Icon, StatusFailure24Icon } from '../../icons';
4
4
  import { defineViraElement } from '../define-vira-element';
5
5
  import { ViraIcon } from '../vira-icon/vira-icon.element';
@@ -20,6 +20,10 @@ export const ViraImage = defineViraElement()({
20
20
  hostClasses: {
21
21
  'vira-image-height-constrained': ({ inputs }) => inputs.dominantDimension === 'height',
22
22
  },
23
+ events: {
24
+ imageLoad: defineElementEvent(),
25
+ imageError: defineElementEvent(),
26
+ },
23
27
  styles: ({ hostClasses }) => css `
24
28
  :host {
25
29
  display: inline-flex;
@@ -79,7 +83,7 @@ export const ViraImage = defineViraElement()({
79
83
  */
80
84
  erroredUrls: {},
81
85
  },
82
- renderCallback({ inputs, state, updateState }) {
86
+ renderCallback({ inputs, state, updateState, dispatch, events }) {
83
87
  /**
84
88
  * Saved off for use in the image listeners. This is used to eliminate race conditions
85
89
  * between image events and the input URL changing.
@@ -114,8 +118,9 @@ export const ViraImage = defineViraElement()({
114
118
  [imageUrl]: true,
115
119
  },
116
120
  });
121
+ dispatch(new events.imageLoad());
117
122
  })}
118
- ${listen('error', async () => {
123
+ ${listen('error', async (event) => {
119
124
  if (inputs._debugLoadDelay) {
120
125
  await wait(inputs._debugLoadDelay.milliseconds);
121
126
  }
@@ -125,6 +130,7 @@ export const ViraImage = defineViraElement()({
125
130
  [imageUrl]: true,
126
131
  },
127
132
  });
133
+ dispatch(new events.imageError(event.error));
128
134
  })}
129
135
  src=${imageUrl}
130
136
  />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vira",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "A simple and highly versatile design system using element-vir.",
5
5
  "keywords": [
6
6
  "design",