@kiva/kv-components 7.2.2 → 7.2.3

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,11 +1,11 @@
1
- import { ref as E, onMounted as N, computed as y, resolveComponent as x, openBlock as r, createElementBlock as d, createElementVNode as o, Fragment as B, renderList as K, createBlock as I, withCtx as V, createCommentVNode as L, toDisplayString as S } from "vue";
2
- import W from "./KvCardFrame.js";
3
- import A from "./KvContentfulImg.js";
4
- import D from "../_virtual/_plugin-vue_export-helper.js";
5
- const F = {
1
+ import { ref as M, onMounted as V, computed as o, resolveComponent as N, openBlock as r, createElementBlock as l, createElementVNode as a, Fragment as W, renderList as z, createBlock as K, withCtx as D, normalizeClass as d, createCommentVNode as f, toDisplayString as C } from "vue";
2
+ import F from "./KvCardFrame.js";
3
+ import j from "./KvContentfulImg.js";
4
+ import q from "../_virtual/_plugin-vue_export-helper.js";
5
+ const G = {
6
6
  components: {
7
- KvCardFrame: W,
8
- KvContentfulImg: A
7
+ KvCardFrame: F,
8
+ KvContentfulImg: j
9
9
  },
10
10
  props: {
11
11
  // Expects an array of categories from our API
@@ -26,84 +26,111 @@ const F = {
26
26
  preSelectedCategory: {
27
27
  type: String,
28
28
  default: null
29
+ },
30
+ // Use compact horizontal layout on tablet and up (keeps image to the left)
31
+ useCompactCard: {
32
+ type: Boolean,
33
+ default: !1
34
+ },
35
+ // Array of category ids that the user has already selected
36
+ existingCategories: {
37
+ type: Array,
38
+ default: () => []
39
+ },
40
+ // Message to show for categories that are in the existingCategories list
41
+ existingCategoryMessage: {
42
+ type: String,
43
+ default: "Already selected"
29
44
  }
30
45
  },
31
46
  emits: ["category-selected"],
32
- setup(l, { emit: u }) {
33
- const s = E(null), n = (e) => {
34
- s.value = e, u("category-selected", e);
47
+ setup(s, { emit: g }) {
48
+ const i = M(null), n = (e) => {
49
+ i.value = e, g("category-selected", e);
35
50
  };
36
- N(() => {
37
- l.preSelectedCategory && n(l.preSelectedCategory);
51
+ V(() => {
52
+ s.preSelectedCategory && n(s.preSelectedCategory);
38
53
  });
39
- const f = (e) => {
40
- var i, t, c, _, h, g, C, p, k;
54
+ const _ = (e) => {
55
+ var k, p, b, v, y, I, S, E, L;
41
56
  if (e.contentfulEntry) {
42
- const a = (_ = (c = (t = (i = e == null ? void 0 : e.contentfulEntry) == null ? void 0 : i.entry) == null ? void 0 : t.fields) == null ? void 0 : c.content) == null ? void 0 : _.find(
43
- (m) => {
44
- var v, b;
45
- return (b = (v = m == null ? void 0 : m.fields) == null ? void 0 : v.key) == null ? void 0 : b.includes("category-icon");
57
+ const u = (v = (b = (p = (k = e == null ? void 0 : e.contentfulEntry) == null ? void 0 : k.entry) == null ? void 0 : p.fields) == null ? void 0 : b.content) == null ? void 0 : v.find(
58
+ (w) => {
59
+ var A, B;
60
+ return (B = (A = w == null ? void 0 : w.fields) == null ? void 0 : A.key) == null ? void 0 : B.includes("category-icon");
46
61
  }
47
62
  );
48
- return ((k = (p = (C = (g = (h = a == null ? void 0 : a.fields) == null ? void 0 : h.contentLight) == null ? void 0 : g[0]) == null ? void 0 : C.fields) == null ? void 0 : p.file) == null ? void 0 : k.url) ?? null;
63
+ return ((L = (E = (S = (I = (y = u == null ? void 0 : u.fields) == null ? void 0 : y.contentLight) == null ? void 0 : I[0]) == null ? void 0 : S.fields) == null ? void 0 : E.file) == null ? void 0 : L.url) ?? null;
49
64
  }
50
65
  return null;
51
- }, w = y(() => !l.categoryList || l.categoryList.length === 0 ? [] : l.categoryList.filter((e) => !l.hiddenCategories.includes(e.id)).map((e) => ({
66
+ }, h = o(() => s.useCompactCard ? "tw-p-2 md:tw-p-3 tw-flex tw-flex-row tw-items-center tw-cursor-pointer" : "tw-p-2 tw-flex tw-flex-row md:tw-flex-col tw-items-center tw-cursor-pointer"), c = o(() => s.useCompactCard ? "tw-shrink-0 tw-mr-2" : "tw-shrink-0 tw-mr-2 md:tw-mr-0 md:tw-mb-2"), m = o(() => s.useCompactCard ? "" : "md:tw-text-center"), t = (e) => s.existingCategories.includes(e), x = o(() => !s.categoryList || s.categoryList.length === 0 ? [] : s.categoryList.filter((e) => !s.hiddenCategories.includes(e.id)).map((e) => ({
52
67
  id: e.id,
53
68
  name: e.name,
54
69
  description: e.description,
55
70
  customImage: e.customImage || null,
56
- contentfulImage: f(e) || null
71
+ contentfulImage: _(e) || null
57
72
  })));
58
73
  return {
59
- selectedCategory: s,
60
- formattedCategories: w,
61
- selectCategory: n
74
+ selectedCategory: i,
75
+ formattedCategories: x,
76
+ selectCategory: n,
77
+ cardContainerClasses: h,
78
+ imageClasses: c,
79
+ textContainerClasses: m,
80
+ isCategoryExisting: t
62
81
  };
63
82
  }
64
- }, M = { class: "tw-grid tw-grid-cols-1 md:tw-grid-cols-2 tw-gap-3" }, j = { class: "tw-p-2 tw-flex tw-flex-row md:tw-flex-col tw-items-center tw-cursor-pointer" }, q = ["alt", "src", "width"], z = { class: "md:tw-text-center" }, G = { class: "tw-mb-0.5 tw-font-medium" }, H = { class: "tw-text-small" }, J = {
83
+ }, H = { class: "tw-grid tw-grid-cols-1 md:tw-grid-cols-2 tw-gap-3" }, J = ["alt", "src", "width"], O = { class: "tw-mb-0.5 tw-font-medium" }, P = { class: "tw-text-small" }, Q = {
84
+ key: 0,
85
+ class: "tw-text-small tw-py-1 tw-px-2 tw-mt-1 tw-bg-brand-200 tw-rounded tw-inline-block"
86
+ }, R = {
65
87
  key: 0,
66
88
  class: "tw-text-gray-500 tw-italic"
67
89
  };
68
- function O(l, u, s, n, f, w) {
69
- const e = x("kv-contentful-img"), i = x("kv-card-frame");
70
- return r(), d("div", null, [
71
- o("div", M, [
72
- (r(!0), d(B, null, K(n.formattedCategories, (t) => (r(), I(i, {
90
+ function T(s, g, i, n, _, h) {
91
+ const c = N("kv-contentful-img"), m = N("kv-card-frame");
92
+ return r(), l("div", null, [
93
+ a("div", H, [
94
+ (r(!0), l(W, null, z(n.formattedCategories, (t) => (r(), K(m, {
73
95
  key: t.id,
74
96
  "bg-color-class": n.selectedCategory === t.id ? "tw-bg-secondary" : "tw-bg-white",
75
97
  "border-class": n.selectedCategory === t.id ? "tw-border-2 tw-border-action" : "tw-border-2 tw-border-transparent",
76
98
  class: "tw-transition-all tw-duration-200 hover:tw-shadow-lg",
77
- onClick: (c) => n.selectCategory(t.id)
99
+ onClick: (x) => n.selectCategory(t.id)
78
100
  }, {
79
- default: V(() => [
80
- o("div", j, [
81
- t != null && t.contentfulImage ? (r(), I(e, {
101
+ default: D(() => [
102
+ a("div", {
103
+ class: d(n.cardContainerClasses)
104
+ }, [
105
+ t != null && t.contentfulImage ? (r(), K(c, {
82
106
  key: 0,
83
- class: "tw-shrink-0 tw-mr-2 md:tw-mr-0 md:tw-mb-2",
107
+ class: d(n.imageClasses),
84
108
  alt: `${t.name} image`,
85
109
  "contentful-src": t.contentfulImage,
86
- width: s.imageWidth
87
- }, null, 8, ["alt", "contentful-src", "width"])) : t != null && t.customImage ? (r(), d("img", {
110
+ width: i.imageWidth
111
+ }, null, 8, ["class", "alt", "contentful-src", "width"])) : t != null && t.customImage ? (r(), l("img", {
88
112
  key: 1,
89
- class: "tw-shrink-0 tw-mr-2 md:tw-mr-0 md:tw-mb-2",
113
+ class: d(n.imageClasses),
90
114
  alt: `${t.name} image`,
91
115
  src: t.customImage,
92
- width: s.imageWidth
93
- }, null, 8, q)) : L("", !0),
94
- o("div", z, [
95
- o("p", G, S(t.name), 1),
96
- o("p", H, S(t.description), 1)
97
- ])
98
- ])
116
+ width: i.imageWidth
117
+ }, null, 10, J)) : f("", !0),
118
+ a("div", {
119
+ class: d(n.textContainerClasses)
120
+ }, [
121
+ a("p", O, C(t.name), 1),
122
+ a("p", P, C(t.description), 1),
123
+ n.isCategoryExisting(t.id) ? (r(), l("p", Q, C(i.existingCategoryMessage), 1)) : f("", !0)
124
+ ], 2)
125
+ ], 2)
99
126
  ]),
100
127
  _: 2
101
128
  }, 1032, ["bg-color-class", "border-class", "onClick"]))), 128))
102
129
  ]),
103
- n.formattedCategories.length === 0 ? (r(), d("p", J, " No categories available ")) : L("", !0)
130
+ n.formattedCategories.length === 0 ? (r(), l("p", R, " No categories available ")) : f("", !0)
104
131
  ]);
105
132
  }
106
- const U = /* @__PURE__ */ D(F, [["render", O]]);
133
+ const $ = /* @__PURE__ */ q(G, [["render", T]]);
107
134
  export {
108
- U as default
135
+ $ as default
109
136
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiva/kv-components",
3
- "version": "7.2.2",
3
+ "version": "7.2.3",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -114,5 +114,5 @@
114
114
  "embla-carousel-fade",
115
115
  "popper.js"
116
116
  ],
117
- "gitHead": "a1f47f0b2511bbed3305b181a8e139e175657237"
117
+ "gitHead": "50e5dc38a0640b6fab10cf490c57825edac585a9"
118
118
  }