@kiva/kv-components 6.69.3 → 7.1.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.
@@ -1,12 +1,11 @@
1
- import { toRefs as F, ref as d, computed as u, onMounted as p, resolveComponent as U, openBlock as n, createElementBlock as o, normalizeClass as r, createElementVNode as s, createBlock as H, normalizeStyle as I, createCommentVNode as y, withDirectives as b, vShow as B, toDisplayString as P } from "vue";
2
- import { isLegacyPlaceholderAvatar as j, randomizedUserAvatarClass as D } from "../utils/imageUtils.js";
3
- import M from "./KvLoadingPlaceholder.js";
4
- import "./KvUserAvatar.css";
5
- import N from "../_virtual/_plugin-vue_export-helper.js";
6
- const V = {
1
+ import { toRefs as B, ref as m, computed as a, onMounted as P, resolveComponent as V, openBlock as i, createElementBlock as c, normalizeClass as b, createElementVNode as r, createCommentVNode as f, withDirectives as N, createVNode as z, vShow as D, normalizeStyle as y, toDisplayString as F } from "vue";
2
+ import { randomizedUserAvatarClass as M, isLegacyPlaceholderAvatar as p } from "../utils/imageUtils.js";
3
+ import S from "./KvLoadingPlaceholder.js";
4
+ import E from "../_virtual/_plugin-vue_export-helper.js";
5
+ const K = {
7
6
  name: "KvUserAvatar",
8
7
  components: {
9
- KvLoadingPlaceholder: M
8
+ KvLoadingPlaceholder: S
10
9
  },
11
10
  props: {
12
11
  /**
@@ -24,115 +23,131 @@ const V = {
24
23
  default: ""
25
24
  },
26
25
  /**
27
- * The image of the lender
26
+ * Whether to render a smaller avatar
28
27
  */
29
28
  isSmall: {
30
29
  type: Boolean,
31
30
  default: !1
31
+ },
32
+ /**
33
+ * Whether to use a css variable for the avatar url before data is loaded
34
+ */
35
+ showCssPlaceholder: {
36
+ type: Boolean,
37
+ default: !1
32
38
  }
33
39
  },
34
- setup(f) {
40
+ setup(w) {
35
41
  const {
36
- lenderName: a,
37
- lenderImageUrl: e,
38
- isSmall: t
39
- } = F(f), i = d(!0), c = d(null), m = d(null), v = u(() => a.value === "" && e.value === "" || a.value === "Anonymous"), S = () => {
40
- const l = t != null && t.value ? "tw-w-3 tw-h-3 tw-text-h4" : "tw-w-6 tw-h-6 tw-text-h2";
41
- return `${D(a.value)} ${l}`;
42
- }, _ = u(() => {
43
- var l;
44
- return ((l = e == null ? void 0 : e.value) == null ? void 0 : l.split("/").pop()) ?? "";
45
- }), C = u(() => {
46
- var l;
47
- return (l = a == null ? void 0 : a.value) == null ? void 0 : l.substring(0, 1).toUpperCase();
42
+ lenderName: t,
43
+ lenderImageUrl: s,
44
+ isSmall: e,
45
+ showCssPlaceholder: d
46
+ } = B(w), u = m(!0), l = m(null), v = m(null), C = a(() => !d.value && t.value === "" && s.value === "" || t.value === "Anonymous"), _ = a(() => {
47
+ const o = e != null && e.value ? "tw-font-sans tw-font-normal" : "tw-font-serif";
48
+ return `${M(t.value)} ${o}`;
49
+ }), A = a(() => e != null && e.value ? "0 0 27 27" : "0 0 27.5 27.5"), x = a(() => {
50
+ var n;
51
+ if (d.value)
52
+ return !0;
53
+ const o = ((n = s == null ? void 0 : s.value) == null ? void 0 : n.split("/").pop()) ?? "";
54
+ return o && !p(o);
55
+ }), I = a(() => {
56
+ var o;
57
+ return (o = t == null ? void 0 : t.value) == null ? void 0 : o.substring(0, 1).toUpperCase();
48
58
  }), g = () => {
49
- i.value = !1;
50
- }, L = (l, w = 1e4) => new Promise((k, x) => {
51
- const A = Date.now() + w, h = () => {
52
- !l || l.complete ? k(l) : Date.now() > A ? x(new Error(`Timeout: ${l.src}`)) : setTimeout(h, 50);
59
+ u.value = !1;
60
+ }, U = (o, n = 1e4) => new Promise((k, H) => {
61
+ const L = Date.now() + n, h = () => {
62
+ !o || o.complete ? k(o) : Date.now() > L ? H(new Error(`Timeout: ${o.src}`)) : setTimeout(h, 50);
53
63
  };
54
64
  h();
55
65
  });
56
- return p(async () => {
57
- const l = c.value;
66
+ return P(async () => {
67
+ const o = l.value;
58
68
  try {
59
- await L(l), g();
60
- } catch (w) {
61
- console.log(w.message);
69
+ await U(o), g();
70
+ } catch (n) {
71
+ console.log(n.message);
62
72
  }
63
73
  }), {
64
- isAnonymousUser: v,
65
- avatarClass: S,
66
- imageFilename: _,
67
- lenderNameFirstLetter: C,
68
- isLegacyPlaceholderAvatar: j,
69
- isLoading: i,
74
+ isAnonymousUser: C,
75
+ avatarClass: _,
76
+ userHasImage: x,
77
+ lenderNameFirstLetter: I,
78
+ letterViewBox: A,
79
+ isLegacyPlaceholderAvatar: p,
80
+ isImageLoading: u,
70
81
  onImgLoad: g,
71
- imageRef: c,
72
- userAvatar: m
82
+ imageRef: l,
83
+ userAvatar: v
73
84
  };
74
85
  }
75
- }, z = { key: 1 }, E = ["src"];
76
- function K(f, a, e, t, i, c) {
77
- const m = U("kv-loading-placeholder");
78
- return n(), o("div", {
86
+ }, R = {
87
+ key: 0,
88
+ class: "tw-h-3/4",
89
+ viewBox: "0 0 25 37",
90
+ fill: "none",
91
+ xmlns: "http://www.w3.org/2000/svg"
92
+ }, T = ["src"], Z = ["viewBox"], j = {
93
+ x: "50%",
94
+ y: "55%",
95
+ "dominant-baseline": "middle",
96
+ "text-anchor": "middle"
97
+ };
98
+ function q(w, t, s, e, d, u) {
99
+ const l = V("kv-loading-placeholder");
100
+ return i(), c("div", {
79
101
  ref: "userAvatar",
80
- class: r(["data-hj-suppress tw-flex", { "tw-w-3": e.isSmall, "tw-w-6": !e.isSmall }])
102
+ class: b(["data-hj-suppress tw-flex tw-items-center tw-justify-center tw-rounded-full tw-overflow-hidden", {
103
+ "tw-bg-brand": e.isAnonymousUser,
104
+ [e.avatarClass]: !e.isAnonymousUser
105
+ }])
81
106
  }, [
82
- t.isAnonymousUser ? (n(), o("div", {
83
- key: 0,
84
- class: r(["tw-rounded-full tw-bg-brand tw-inline-flex tw-align-center tw-justify-center", { "tw-w-3 tw-h-3": e.isSmall, "tw-w-6 tw-h-6": !e.isSmall }])
107
+ e.isAnonymousUser ? (i(), c("svg", R, t[1] || (t[1] = [
108
+ r("path", {
109
+ d: "M8.22861 0.875H0.857178V36.3125H8.22861V0.875Z",
110
+ fill: "white"
111
+ }, null, -1),
112
+ r("path", {
113
+ d: "M10.1143 23.2751C21.9428 23.2751 24.6857 13.2126 24.6857 11.4626H23.6571C11.8286 11.4626 9.08569 21.5251 9.08569 23.2751H10.1143Z",
114
+ fill: "white"
115
+ }, null, -1),
116
+ r("path", {
117
+ d: "M9.08569 24.2376C9.08569 26.0751 11.1428 36.3126 23.8285 36.3126H24.8571C24.8571 34.4751 22.8 24.2376 10.1143 24.2376H9.08569Z",
118
+ fill: "white"
119
+ }, null, -1)
120
+ ]))) : f("", !0),
121
+ N(z(l, null, null, 512), [
122
+ [D, !e.isAnonymousUser && e.userHasImage && e.isImageLoading]
123
+ ]),
124
+ !e.isAnonymousUser && e.userHasImage ? (i(), c("div", {
125
+ key: 1,
126
+ class: "tw-w-full tw-h-full",
127
+ style: y(s.showCssPlaceholder ? { display: "var(--user-avatar-display, block)" } : {
128
+ display: e.isImageLoading ? "none" : "block"
129
+ })
85
130
  }, [
86
- (n(), o("svg", {
87
- class: r(["tw-h-full tw-text-brand", { "tw-w-3 tw-h-3": e.isSmall }]),
88
- width: "25",
89
- height: "37",
90
- viewBox: "0 0 25 37",
91
- fill: "none",
92
- xmlns: "http://www.w3.org/2000/svg"
93
- }, a[1] || (a[1] = [
94
- s("path", {
95
- d: "M8.22861 0.875H0.857178V36.3125H8.22861V0.875Z",
96
- fill: "white"
97
- }, null, -1),
98
- s("path", {
99
- d: "M10.1143 23.2751C21.9428 23.2751 24.6857 13.2126 24.6857 11.4626H23.6571C11.8286 11.4626 9.08569 21.5251 9.08569 23.2751H10.1143Z",
100
- fill: "white"
101
- }, null, -1),
102
- s("path", {
103
- d: "M9.08569 24.2376C9.08569 26.0751 11.1428 36.3126 23.8285 36.3126H24.8571C24.8571 34.4751 22.8 24.2376 10.1143 24.2376H9.08569Z",
104
- fill: "white"
105
- }, null, -1)
106
- ]), 2))
107
- ], 2)) : !t.isLegacyPlaceholderAvatar(t.imageFilename) && t.imageFilename ? (n(), o("div", z, [
108
- t.isLoading ? (n(), H(m, {
109
- key: 0,
110
- style: I({
111
- width: e.isSmall ? "1.5rem" : "3rem",
112
- height: e.isSmall ? "1.5rem" : "3rem"
113
- }),
114
- class: "!tw-rounded-full"
115
- }, null, 8, ["style"])) : y("", !0),
116
- b(s("img", {
131
+ r("img", {
117
132
  ref: "imageRef",
118
- src: e.lenderImageUrl,
133
+ src: s.lenderImageUrl,
119
134
  alt: "Image of lender",
120
- class: r(["tw-rounded-full tw-inline-block", { "tw-w-3 tw-h-3": e.isSmall, "tw-w-6 tw-h-6": !e.isSmall }]),
121
- onLoad: a[0] || (a[0] = (v) => t.onImgLoad())
122
- }, null, 42, E), [
123
- [B, !t.isLoading]
124
- ])
125
- ])) : t.isLegacyPlaceholderAvatar(t.imageFilename) || !t.imageFilename ? (n(), o("div", {
135
+ class: "tw-w-full",
136
+ style: y(s.showCssPlaceholder ? { content: "var(--user-avatar)" } : {}),
137
+ onLoad: t[0] || (t[0] = (v) => e.onImgLoad())
138
+ }, null, 44, T)
139
+ ], 4)) : f("", !0),
140
+ !e.isAnonymousUser && !e.userHasImage ? (i(), c("svg", {
126
141
  key: 2,
127
- class: r(["tw-rounded-full tw-inline-flex tw-align-center tw-justify-center", t.avatarClass()])
142
+ class: "tw-w-full tw-h-full",
143
+ fill: "currentColor",
144
+ viewBox: e.letterViewBox
128
145
  }, [
129
- s("span", {
130
- class: r(["tw-self-center", { "adjust-vertical-spacing": !e.isSmall }])
131
- }, P(t.lenderNameFirstLetter), 3)
132
- ], 2)) : y("", !0)
146
+ r("text", j, F(e.lenderNameFirstLetter), 1)
147
+ ], 8, Z)) : f("", !0)
133
148
  ], 2);
134
149
  }
135
- const J = /* @__PURE__ */ N(V, [["render", K], ["__scopeId", "data-v-c9339e78"]]);
150
+ const W = /* @__PURE__ */ E(K, [["render", q]]);
136
151
  export {
137
- J as default
152
+ W as default
138
153
  };
@@ -1 +1 @@
1
- .header-link[data-v-d30fd983]{cursor:pointer;padding-top:1rem;padding-bottom:1rem;--tw-text-opacity: 1;color:rgba(var(--text-primary),var(--tw-text-opacity, 1));text-decoration-line:none}.header-link[data-v-d30fd983]:hover{--tw-text-opacity: 1;color:rgba(var(--text-action),var(--tw-text-opacity, 1));text-decoration-line:none}[data-v-d30fd983] .avatar div:first-child{display:flex}
1
+ .header-link[data-v-c31f1fca]{cursor:pointer;padding-top:1rem;padding-bottom:1rem;--tw-text-opacity: 1;color:rgba(var(--text-primary),var(--tw-text-opacity, 1));text-decoration-line:none}.header-link[data-v-c31f1fca]:hover{--tw-text-opacity: 1;color:rgba(var(--text-action),var(--tw-text-opacity, 1));text-decoration-line:none}