@elmethis/core 1.0.0-alpha.181 → 1.0.0-alpha.183

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,10 +1,12 @@
1
- import { ElmImageProps } from './ElmImage.vue';
2
- export type ElmBlockImageProps = {
3
- rounded?: boolean;
4
- shadow?: boolean;
5
- } & ElmImageProps;
6
- declare const _default: import('vue').DefineComponent<ElmBlockImageProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ElmBlockImageProps> & Readonly<{}>, {
7
- rounded: boolean;
8
- shadow: boolean;
9
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
1
+ export interface ElmBlockImageProps {
2
+ /**
3
+ * Image source URL
4
+ */
5
+ src: string;
6
+ /**
7
+ * Image alt text
8
+ */
9
+ alt?: string;
10
+ }
11
+ declare const _default: import('vue').DefineComponent<ElmBlockImageProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ElmBlockImageProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
10
12
  export default _default;
@@ -1,10 +1,22 @@
1
+ (function() {
2
+ "use strict";
3
+ try {
4
+ if (typeof document != "undefined") {
5
+ var elementStyle = document.createElement("style");
6
+ elementStyle.appendChild(document.createTextNode(".v-enter-to[data-v-090cf1b2],.v-leave-from[data-v-090cf1b2]{opacity:1}.v-enter-active[data-v-090cf1b2],.v-leave-active[data-v-090cf1b2]{transition:opacity .3s}.v-enter-from[data-v-090cf1b2],.v-leave-to[data-v-090cf1b2]{opacity:0}"));
7
+ document.head.appendChild(elementStyle);
8
+ }
9
+ } catch (e) {
10
+ console.error("vite-plugin-css-injected-by-js", e);
11
+ }
12
+ })();
1
13
  import _sfc_main from "./ElmBlockImage.vue2.mjs";
2
14
  import style0 from "./ElmBlockImage.vue3.mjs";
3
15
  import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
4
16
  const cssModules = {
5
17
  "$style": style0
6
18
  };
7
- const ElmBlockImage = /* @__PURE__ */ _export_sfc(_sfc_main, [["__cssModules", cssModules]]);
19
+ const ElmBlockImage = /* @__PURE__ */ _export_sfc(_sfc_main, [["__cssModules", cssModules], ["__scopeId", "data-v-090cf1b2"]]);
8
20
  export {
9
21
  ElmBlockImage as default
10
22
  };
@@ -1,30 +1,85 @@
1
- import { defineComponent, createElementBlock, openBlock, normalizeClass, createElementVNode, normalizeStyle, createVNode, normalizeProps, guardReactiveProps } from "vue";
2
- import ElmImage from "./ElmImage.vue.mjs";
1
+ import { defineComponent, ref, createElementBlock, openBlock, Fragment, createElementVNode, createVNode, normalizeClass, Transition, withCtx, unref, normalizeStyle, createCommentVNode } from "vue";
2
+ import ElmRectangleWave from "../fallback/ElmRectangleWave.vue.mjs";
3
+ import ElmDotLoadingIcon from "../icon/ElmDotLoadingIcon.vue.mjs";
4
+ import { useImage, onKeyStroke } from "@vueuse/core";
5
+ import ElmInlineText from "../inline/ElmInlineText.vue.mjs";
6
+ const _hoisted_1 = ["src", "alt"];
7
+ const _hoisted_2 = ["src", "alt"];
3
8
  const _sfc_main = /* @__PURE__ */ defineComponent({
4
9
  __name: "ElmBlockImage",
5
10
  props: {
6
- rounded: { type: Boolean, default: true },
7
- shadow: { type: Boolean, default: true },
8
11
  src: {},
9
- alt: {},
10
- enableModal: { type: Boolean },
11
- margin: {}
12
+ alt: {}
12
13
  },
13
14
  setup(__props) {
14
15
  const props = __props;
16
+ const { isLoading, error } = useImage({ src: props.src });
17
+ const isModalOpen = ref(false);
18
+ onKeyStroke("Escape", (e) => {
19
+ e.preventDefault();
20
+ isModalOpen.value = false;
21
+ });
15
22
  return (_ctx, _cache) => {
16
- return openBlock(), createElementBlock("div", {
17
- class: normalizeClass(_ctx.$style.container)
18
- }, [
23
+ return openBlock(), createElementBlock(Fragment, null, [
19
24
  createElementVNode("div", {
20
- style: normalizeStyle({
21
- boxShadow: _ctx.shadow ? "0 0 0.125rem #b3b3b3" : void 0,
22
- ..._ctx.rounded ? { borderRadius: "0.25rem", overflow: "hidden" } : {}
23
- })
25
+ class: normalizeClass(_ctx.$style.container)
24
26
  }, [
25
- createVNode(ElmImage, normalizeProps(guardReactiveProps(props)), null, 16)
26
- ], 4)
27
- ], 2);
27
+ createVNode(Transition, { mode: "out-in" }, {
28
+ default: withCtx(() => [
29
+ unref(error) ? (openBlock(), createElementBlock("div", {
30
+ key: 0,
31
+ class: normalizeClass(_ctx.$style.error)
32
+ }, [
33
+ createVNode(ElmInlineText, {
34
+ text: "Error loading image",
35
+ color: "#c56565",
36
+ size: "1.5rem"
37
+ })
38
+ ], 2)) : unref(isLoading) ? (openBlock(), createElementBlock("div", {
39
+ key: 1,
40
+ class: normalizeClass(_ctx.$style.fallback)
41
+ }, [
42
+ createVNode(ElmRectangleWave),
43
+ createElementVNode("div", null, [
44
+ createVNode(ElmDotLoadingIcon)
45
+ ])
46
+ ], 2)) : (openBlock(), createElementBlock("img", {
47
+ key: 2,
48
+ class: normalizeClass(_ctx.$style.image),
49
+ src: _ctx.src,
50
+ alt: _ctx.alt,
51
+ onClick: _cache[0] || (_cache[0] = () => {
52
+ isModalOpen.value = true;
53
+ }),
54
+ style: normalizeStyle({
55
+ "--height": unref(isLoading) ? "0" : "auto",
56
+ "--opacity": unref(isLoading) ? 0 : 1,
57
+ display: unref(isLoading) ? "none" : "block"
58
+ })
59
+ }, null, 14, _hoisted_1))
60
+ ]),
61
+ _: 1
62
+ })
63
+ ], 2),
64
+ createVNode(Transition, null, {
65
+ default: withCtx(() => [
66
+ isModalOpen.value ? (openBlock(), createElementBlock("div", {
67
+ key: 0,
68
+ class: normalizeClass(_ctx.$style.modal)
69
+ }, [
70
+ createElementVNode("img", {
71
+ class: normalizeClass(_ctx.$style["modal-image"]),
72
+ src: _ctx.src,
73
+ alt: _ctx.alt,
74
+ onClick: _cache[1] || (_cache[1] = () => {
75
+ isModalOpen.value = false;
76
+ })
77
+ }, null, 10, _hoisted_2)
78
+ ], 2)) : createCommentVNode("", true)
79
+ ]),
80
+ _: 1
81
+ })
82
+ ], 64);
28
83
  };
29
84
  }
30
85
  });
@@ -3,18 +3,31 @@
3
3
  try {
4
4
  if (typeof document != "undefined") {
5
5
  var elementStyle = document.createElement("style");
6
- elementStyle.appendChild(document.createTextNode("._container_ppumw_1{width:100%;display:flex;justify-content:center}"));
6
+ elementStyle.appendChild(document.createTextNode("._container_1y2x6_1{width:100%;display:flex;justify-content:center;align-items:center}._image_1y2x6_8{overflow:hidden;border-radius:.25rem;box-shadow:0 0 .25rem #0000004d;display:block;max-width:100%;height:var(--height);opacity:var(--opacity);transition:opacity .4s;cursor:zoom-in}._error_1y2x6_20{display:flex;justify-content:center;align-items:center;gap:1rem;width:100%;height:100%;min-height:10rem;line-height:1.5rem;color:#c56565}._fallback_1y2x6_32{margin-block:1rem;margin:0;padding:0;position:relative;width:100%;z-index:1;display:flex;justify-content:center;align-items:center;aspect-ratio:1200/630}._modal_1y2x6_45{z-index:1000;position:fixed;width:100%;height:100vh;top:0;left:0;background-color:#000000b3;display:flex;justify-content:center;align-items:center;cursor:zoom-out}._modal_1y2x6_45 ._modal-image_1y2x6_58{width:100vw;height:100vh;-o-object-fit:contain;object-fit:contain}"));
7
7
  document.head.appendChild(elementStyle);
8
8
  }
9
9
  } catch (e) {
10
10
  console.error("vite-plugin-css-injected-by-js", e);
11
11
  }
12
12
  })();
13
- const container = "_container_ppumw_1";
13
+ const container = "_container_1y2x6_1";
14
+ const image = "_image_1y2x6_8";
15
+ const error = "_error_1y2x6_20";
16
+ const fallback = "_fallback_1y2x6_32";
17
+ const modal = "_modal_1y2x6_45";
14
18
  const style0 = {
15
- container
19
+ container,
20
+ image,
21
+ error,
22
+ fallback,
23
+ modal,
24
+ "modal-image": "_modal-image_1y2x6_58"
16
25
  };
17
26
  export {
18
27
  container,
19
- style0 as default
28
+ style0 as default,
29
+ error,
30
+ fallback,
31
+ image,
32
+ modal
20
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elmethis/core",
3
- "version": "1.0.0-alpha.181",
3
+ "version": "1.0.0-alpha.183",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },