@ulu/frontend-vue 0.5.6 → 0.5.8

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.
@@ -22,6 +22,7 @@ declare const __VLS_component: import('vue').DefineComponent<{}, {
22
22
  titleTo?: string | Record<string, any> | undefined;
23
23
  titleHref?: string | undefined;
24
24
  titleTarget?: string | undefined;
25
+ image?: Record<string, any> | undefined;
25
26
  imageSrc?: string | undefined;
26
27
  imageAlt?: string | undefined;
27
28
  $props: {
@@ -42,6 +43,7 @@ declare const __VLS_component: import('vue').DefineComponent<{}, {
42
43
  readonly titleTo?: string | Record<string, any> | undefined;
43
44
  readonly titleHref?: string | undefined;
44
45
  readonly titleTarget?: string | undefined;
46
+ readonly image?: Record<string, any> | undefined;
45
47
  readonly imageSrc?: string | undefined;
46
48
  readonly imageAlt?: string | undefined;
47
49
  };
@@ -1 +1 @@
1
- {"version":3,"file":"UluCard.vue.d.ts","sourceRoot":"","sources":["../../../lib/components/elements/UluCard.vue"],"names":[],"mappings":"AA+EA;wBAkpBqB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;;6BAEtE,CAAC,EAAE,CAAC;;;AAbjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAUG"}
1
+ {"version":3,"file":"UluCard.vue.d.ts","sourceRoot":"","sources":["../../../lib/components/elements/UluCard.vue"],"names":[],"mappings":"AA+EA;wBA+rBqB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;;6BAEtE,CAAC,EAAE,CAAC;;;AAbjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAUG"}
@@ -1,14 +1,15 @@
1
- import { useSlots as N, ref as f, computed as r, createBlock as k, openBlock as a, resolveDynamicComponent as B, normalizeStyle as R, normalizeClass as h, unref as n, withCtx as S, createElementVNode as C, createElementBlock as m, createCommentVNode as y, renderSlot as i, createTextVNode as x, toDisplayString as b } from "vue";
2
- import { RouterLink as P } from "vue-router";
3
- import { useModifiers as V } from "../../composables/useModifiers.js";
4
- import { refToElement as I } from "../../utils/dom.js";
5
- const q = { class: "card__body" }, L = { class: "card__main" }, F = ["href", "target"], G = {
1
+ import { useSlots as V, computed as o, ref as f, createBlock as k, openBlock as a, resolveDynamicComponent as P, normalizeStyle as p, normalizeClass as h, unref as n, withCtx as S, createElementVNode as $, createElementBlock as m, createCommentVNode as y, renderSlot as i, createTextVNode as C, toDisplayString as x, createVNode as A, normalizeProps as I, guardReactiveProps as q } from "vue";
2
+ import { RouterLink as B } from "vue-router";
3
+ import { useModifiers as L } from "../../composables/useModifiers.js";
4
+ import { refToElement as F } from "../../utils/dom.js";
5
+ import G from "./UluImage.vue.js";
6
+ const J = { class: "card__body" }, K = { class: "card__main" }, Q = ["href", "target"], W = {
6
7
  key: 0,
7
8
  class: "card__aside"
8
- }, J = ["src", "alt"], K = {
9
+ }, X = {
9
10
  key: 1,
10
11
  class: "card__footer"
11
- }, Z = {
12
+ }, le = {
12
13
  __name: "UluCard",
13
14
  props: {
14
15
  /**
@@ -82,11 +83,17 @@ const q = { class: "card__body" }, L = { class: "card__main" }, F = ["href", "ta
82
83
  default: () => ({})
83
84
  },
84
85
  /**
85
- * Source of image
86
+ * Advanced configuration for the underlying `<UluImage>` component.
87
+ * Accepts a full configuration object (e.g., for lazy loading, srcset, etc.).
88
+ */
89
+ image: Object,
90
+ /**
91
+ * Convenience prop for quickly setting the image source.
92
+ * For advanced image configurations, use the `image` prop or `#image` slot instead.
86
93
  */
87
94
  imageSrc: String,
88
95
  /**
89
- * Alt text for image
96
+ * The alt text for the image when using the `imageSrc` convenience prop.
90
97
  */
91
98
  imageAlt: String,
92
99
  /**
@@ -112,111 +119,111 @@ const q = { class: "card__body" }, L = { class: "card__main" }, F = ["href", "ta
112
119
  modifiers: [Array, String]
113
120
  },
114
121
  emits: ["proxy-click"],
115
- setup(e, { emit: $ }) {
116
- const t = e, O = $, s = N();
117
- t.proxyClick && (t.to || t.href) && console.warn("UluCard: 'proxyClick' is ignored when 'to' or 'href' are present."), (t.titleTo || t.titleHref) && (t.to || t.href) && console.warn("UluCard: 'titleTo'/'titleHref' should not be used with 'to'/'href'.");
118
- const T = f(null), v = f(null), { resolvedModifiers: H } = V({ props: t, baseClass: "card" }), E = f(null), c = f(!1), u = r(() => t.proxyClick && !t.to && !t.href), w = r(() => u.value && (t.titleTo || t.titleHref)), M = r(() => u.value && !w.value), g = r(() => u.value || null), z = r(() => ({
122
+ setup(t, { emit: O }) {
123
+ const e = t, H = O, s = V();
124
+ e.proxyClick && (e.to || e.href) && console.warn("UluCard: 'proxyClick' is ignored when 'to' or 'href' are present."), (e.titleTo || e.titleHref) && (e.to || e.href) && console.warn("UluCard: 'titleTo'/'titleHref' should not be used with 'to'/'href'.");
125
+ const b = o(() => e.image ? e.image : e.imageSrc ? {
126
+ src: e.imageSrc,
127
+ alt: e.imageAlt || ""
128
+ } : null), T = f(null), v = f(null), { resolvedModifiers: M } = L({ props: e, baseClass: "card" }), E = f(null), c = f(!1), u = o(() => e.proxyClick && !e.to && !e.href), w = o(() => u.value && (e.titleTo || e.titleHref)), j = o(() => u.value && !w.value), g = o(() => u.value || null), z = o(() => ({
119
129
  selectorPrevent: "input, select, textarea, button, a, [tabindex='-1']",
120
130
  mousedownDurationPrevent: 250,
121
- ...t.proxyClickOptions
122
- })), j = r(() => u.value ? "pointer" : null), D = r(() => t.to ? P : t.href ? "a" : t.cardElement);
123
- function U({ target: l, timeStamp: d }) {
131
+ ...e.proxyClickOptions
132
+ })), D = o(() => u.value ? "pointer" : null), N = o(() => e.to ? B : e.href ? "a" : e.cardElement);
133
+ function R({ target: l, timeStamp: d }) {
124
134
  if (!g.value) return;
125
- const { selectorPrevent: o } = z.value;
126
- c.value = !1, l.closest(o) || (c.value = !0, E.value = d);
135
+ const { selectorPrevent: r } = z.value;
136
+ c.value = !1, l.closest(r) || (c.value = !0, E.value = d);
127
137
  }
128
- function A({ timeStamp: l }) {
138
+ function U({ timeStamp: l }) {
129
139
  if (!g.value || !c.value) return;
130
140
  const { mousedownDurationPrevent: d } = z.value;
131
141
  if (l - E.value < d) {
132
142
  if (w.value) {
133
- const o = I(v.value);
134
- o ? o.click() : console.warn("Unable to resolve title link ref");
135
- } else if (M.value) {
136
- const o = T.value?.querySelector("[data-ulu-card-proxy-target]");
137
- o ? o.click() : O("proxy-click");
143
+ const r = F(v.value);
144
+ r ? r.click() : console.warn("Unable to resolve title link ref");
145
+ } else if (j.value) {
146
+ const r = T.value?.querySelector("[data-ulu-card-proxy-target]");
147
+ r ? r.click() : H("proxy-click");
138
148
  }
139
149
  }
140
150
  c.value = !1;
141
151
  }
142
- return (l, d) => (a(), k(B(D.value), {
152
+ return (l, d) => (a(), k(P(N.value), {
143
153
  ref_key: "cardRoot",
144
154
  ref: T,
145
155
  class: h(["card", [
146
156
  {
147
- "card--horizontal": e.horizontal || e.horizontalCenter,
148
- "card--horizontal-center": e.horizontalCenter,
149
- "card--overlay": e.overlay
157
+ "card--horizontal": t.horizontal || t.horizontalCenter,
158
+ "card--horizontal-center": t.horizontalCenter,
159
+ "card--overlay": t.overlay
150
160
  },
151
- n(H)
161
+ n(M)
152
162
  ]]),
153
- onMousedown: U,
154
- onMouseup: A,
155
- style: R({ cursor: j.value }),
156
- target: e.target,
157
- to: e.to,
158
- href: e.href,
163
+ onMousedown: R,
164
+ onMouseup: U,
165
+ style: p({ cursor: D.value }),
166
+ target: t.target,
167
+ to: t.to,
168
+ href: t.href,
159
169
  "data-ulu-proxy-click-init": g.value
160
170
  }, {
161
171
  default: S(() => [
162
- C("div", q, [
163
- C("div", L, [
164
- e.title || n(s).title ? (a(), k(B(e.titleElement), {
172
+ $("div", J, [
173
+ $("div", K, [
174
+ t.title || n(s).title ? (a(), k(P(t.titleElement), {
165
175
  key: 0,
166
- class: h(["card__title", e.classes.title])
176
+ class: h(["card__title", t.classes.title])
167
177
  }, {
168
178
  default: S(() => [
169
- e.titleTo ? (a(), k(n(P), {
179
+ t.titleTo ? (a(), k(n(B), {
170
180
  key: 0,
171
181
  class: "card__title-link",
172
- to: e.titleTo,
182
+ to: t.titleTo,
173
183
  ref_key: "link",
174
184
  ref: v
175
185
  }, {
176
186
  default: S(() => [
177
187
  i(l.$slots, "title", {}, () => [
178
- x(b(e.title), 1)
188
+ C(x(t.title), 1)
179
189
  ])
180
190
  ]),
181
191
  _: 3
182
- }, 8, ["to"])) : e.titleHref ? (a(), m("a", {
192
+ }, 8, ["to"])) : t.titleHref ? (a(), m("a", {
183
193
  key: 1,
184
194
  class: "card__title-link",
185
- href: e.titleHref,
186
- target: e.titleTarget,
195
+ href: t.titleHref,
196
+ target: t.titleTarget,
187
197
  ref_key: "link",
188
198
  ref: v
189
199
  }, [
190
200
  i(l.$slots, "title", {}, () => [
191
- x(b(e.title), 1)
201
+ C(x(t.title), 1)
192
202
  ])
193
- ], 8, F)) : i(l.$slots, "title", { key: 2 }, () => [
194
- x(b(e.title), 1)
203
+ ], 8, Q)) : i(l.$slots, "title", { key: 2 }, () => [
204
+ C(x(t.title), 1)
195
205
  ])
196
206
  ]),
197
207
  _: 3
198
208
  }, 8, ["class"])) : y("", !0),
199
209
  i(l.$slots, "body")
200
210
  ]),
201
- n(s).aside ? (a(), m("div", G, [
211
+ n(s).aside ? (a(), m("div", W, [
202
212
  i(l.$slots, "aside")
203
213
  ])) : y("", !0)
204
214
  ]),
205
- n(s).image || e.imageSrc ? (a(), m("div", {
215
+ n(s).image || b.value ? (a(), m("div", {
206
216
  key: 0,
207
217
  class: h(["card__image", [
208
- { "card__image--icon": e.imageIcon },
209
- e.classes.image
218
+ { "card__image--icon": t.imageIcon },
219
+ t.classes.image
210
220
  ]])
211
221
  }, [
212
222
  i(l.$slots, "image", {}, () => [
213
- C("img", {
214
- src: e.imageSrc,
215
- alt: e.imageAlt
216
- }, null, 8, J)
223
+ A(G, I(q(b.value)), null, 16)
217
224
  ])
218
225
  ], 2)) : y("", !0),
219
- n(s).footer ? (a(), m("div", K, [
226
+ n(s).footer ? (a(), m("div", X, [
220
227
  i(l.$slots, "footer")
221
228
  ])) : y("", !0)
222
229
  ]),
@@ -225,5 +232,5 @@ const q = { class: "card__body" }, L = { class: "card__main" }, F = ["href", "ta
225
232
  }
226
233
  };
227
234
  export {
228
- Z as default
235
+ le as default
229
236
  };
@@ -11,6 +11,6 @@ declare const _default: import('vue').DefineComponent<{}, {
11
11
  readonly alt?: string | undefined;
12
12
  readonly imageId?: string | undefined;
13
13
  };
14
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLImageElement>;
14
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
15
15
  export default _default;
16
16
  //# sourceMappingURL=UluPlaceholderImage.vue.d.ts.map
@@ -1,6 +1,7 @@
1
- import { computed as n, createElementBlock as d, openBlock as h } from "vue";
2
- import { randomInt as o } from "@ulu/utils/random.js";
3
- const s = ["src", "alt"], g = {
1
+ import { computed as o, createBlock as m, openBlock as d } from "vue";
2
+ import { randomInt as n } from "@ulu/utils/random.js";
3
+ import h from "../elements/UluImage.vue.js";
4
+ const g = {
4
5
  __name: "UluPlaceholderImage",
5
6
  props: {
6
7
  imageId: String,
@@ -28,17 +29,17 @@ const s = ["src", "alt"], g = {
28
29
  random: Boolean
29
30
  },
30
31
  setup(e) {
31
- const t = e, a = n(() => t.random ? {
32
- width: o(500, 1e3),
33
- height: o(500, 1e3)
34
- } : { width: t.width, height: t.height }), c = n(() => {
32
+ const t = e, a = o(() => t.random ? {
33
+ width: n(500, 1e3),
34
+ height: n(500, 1e3)
35
+ } : { width: t.width, height: t.height }), c = o(() => {
35
36
  const { width: r, height: i } = a.value;
36
37
  return `https://picsum.photos/${t.imageId ? `id/${t.imageId}/` : ""}${r}/${i}`;
37
38
  });
38
- return (r, i) => (h(), d("img", {
39
+ return (r, i) => (d(), m(h, {
39
40
  src: c.value,
40
41
  alt: e.alt
41
- }, null, 8, s));
42
+ }, null, 8, ["src", "alt"]));
42
43
  }
43
44
  };
44
45
  export {
@@ -61,7 +61,7 @@
61
61
  </div>
62
62
  </div>
63
63
  <div
64
- v-if="$slots.image || imageSrc"
64
+ v-if="$slots.image || resolvedImage"
65
65
  class="card__image"
66
66
  :class="[
67
67
  { 'card__image--icon' : imageIcon },
@@ -69,7 +69,7 @@
69
69
  ]"
70
70
  >
71
71
  <slot name="image">
72
- <img :src="imageSrc" :alt="imageAlt">
72
+ <UluImage v-bind="resolvedImage" />
73
73
  </slot>
74
74
  </div>
75
75
  <div class="card__footer" v-if="$slots.footer">
@@ -83,6 +83,7 @@
83
83
  import { RouterLink } from "vue-router";
84
84
  import { useModifiers } from "../../composables/useModifiers.js";
85
85
  import { refToElement } from '../../utils/dom.js';
86
+ import UluImage from './UluImage.vue';
86
87
 
87
88
  const props = defineProps({
88
89
  /**
@@ -156,11 +157,17 @@
156
157
  default: () => ({})
157
158
  },
158
159
  /**
159
- * Source of image
160
+ * Advanced configuration for the underlying `<UluImage>` component.
161
+ * Accepts a full configuration object (e.g., for lazy loading, srcset, etc.).
162
+ */
163
+ image: Object,
164
+ /**
165
+ * Convenience prop for quickly setting the image source.
166
+ * For advanced image configurations, use the `image` prop or `#image` slot instead.
160
167
  */
161
168
  imageSrc: String,
162
169
  /**
163
- * Alt text for image
170
+ * The alt text for the image when using the `imageSrc` convenience prop.
164
171
  */
165
172
  imageAlt: String,
166
173
  /**
@@ -197,6 +204,18 @@
197
204
  console.warn("UluCard: 'titleTo'/'titleHref' should not be used with 'to'/'href'.");
198
205
  }
199
206
 
207
+ const resolvedImage = computed(() => {
208
+ if (props.image) {
209
+ return props.image;
210
+ } else if (props.imageSrc) {
211
+ return {
212
+ src: props.imageSrc,
213
+ alt: props.imageAlt || ''
214
+ };
215
+ }
216
+ return null;
217
+ });
218
+
200
219
  // --- Template refs
201
220
  const cardRoot = ref(null);
202
221
  const link = ref(null);
@@ -1,10 +1,11 @@
1
1
  <template>
2
- <img :src="src" :alt="alt">
2
+ <UluImage :src="src" :alt="alt" />
3
3
  </template>
4
4
 
5
5
  <script setup>
6
6
  import { computed } from 'vue';
7
7
  import { randomInt } from "@ulu/utils/random.js";
8
+ import UluImage from "../elements/UluImage.vue";
8
9
 
9
10
  const props = defineProps({
10
11
  imageId: String,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulu/frontend-vue",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "description": "A modular, tree-shakeable Vue 3 component library for the Ulu Frontend theming system, plus general utilities for Vue development",
5
5
  "type": "module",
6
6
  "files": [