@kiva/kv-components 6.37.0 → 6.38.1

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.
@@ -0,0 +1 @@
1
+ [data-v-9958a4b0] .check-icon svg{transform:scale(1.2)}
@@ -1,11 +1,17 @@
1
- import { nanoid as h } from "nanoid";
2
- import { toRefs as B, ref as u, watch as L, onMounted as M, openBlock as m, createElementBlock as b, normalizeClass as f, normalizeStyle as R, createElementVNode as s, mergeProps as S, toHandlers as z, withModifiers as E, createCommentVNode as N, renderSlot as j } from "vue";
3
- import { useAttrs as H } from "../utils/attrs.js";
4
- import K from "../_virtual/_plugin-vue_export-helper.js";
5
- const k = [
1
+ import { nanoid as k } from "nanoid";
2
+ import { toRefs as L, ref as v, watch as M, onMounted as I, resolveComponent as K, openBlock as r, createElementBlock as s, normalizeClass as c, normalizeStyle as S, createElementVNode as d, mergeProps as q, toHandlers as R, withModifiers as j, createCommentVNode as b, createBlock as z, renderSlot as D } from "vue";
3
+ import { mdiCheckCircle as E } from "@mdi/js";
4
+ import N from "./KvMaterialIcon.js";
5
+ import { useAttrs as O } from "../utils/attrs.js";
6
+ import "./KvCheckbox.css";
7
+ import H from "../_virtual/_plugin-vue_export-helper.js";
8
+ const C = [
6
9
  "change",
7
10
  "update:modelValue"
8
11
  ], P = {
12
+ components: {
13
+ KvMaterialIcon: N
14
+ },
9
15
  inheritAttrs: !1,
10
16
  model: {
11
17
  prop: "modelValue",
@@ -40,62 +46,77 @@ const k = [
40
46
  valid: {
41
47
  type: Boolean,
42
48
  default: !0
49
+ },
50
+ /**
51
+ * Variant of the checkbox: 'square' (default) or 'round'
52
+ */
53
+ variant: {
54
+ type: String,
55
+ default: "square",
56
+ validator: (i) => ["square", "round"].includes(i)
57
+ },
58
+ blurOnDisabled: {
59
+ type: Boolean,
60
+ default: !0
43
61
  }
44
62
  },
45
- emits: k,
63
+ emits: C,
46
64
  setup(i, l) {
47
65
  const {
48
66
  modelValue: t,
49
67
  value: e
50
- } = B(i), { emit: n } = l, r = u(`kvc-${h(10)}`), o = u(!1), d = u(null), {
51
- classes: C,
52
- styles: g,
53
- inputAttrs: y,
54
- inputListeners: p
55
- } = H(l, k), x = (w) => {
56
- const v = w.target.checked;
57
- let a;
58
- Array.isArray(t.value) ? v ? a = [...t.value, w.target.value] : a = t.value.filter((V) => V !== e.value) : a = v, n("change", a), n("update:modelValue", a);
59
- }, c = () => {
60
- Array.isArray(t.value) ? o.value = t.value.includes(e.value) : o.value = t.value;
61
- }, _ = () => {
62
- d.focus();
68
+ } = L(i), { emit: u } = l, w = v(`kvc-${k(10)}`), a = v(!1), o = v(null), {
69
+ classes: g,
70
+ styles: y,
71
+ inputAttrs: x,
72
+ inputListeners: _
73
+ } = O(l, C), p = (h) => {
74
+ const m = h.target.checked;
75
+ let n;
76
+ Array.isArray(t.value) ? m ? n = [...t.value, h.target.value] : n = t.value.filter((V) => V !== e.value) : n = m, u("change", n), u("update:modelValue", n);
77
+ }, f = () => {
78
+ Array.isArray(t.value) ? a.value = t.value.includes(e.value) : a.value = t.value;
63
79
  }, A = () => {
64
- d.blur();
80
+ o.focus();
81
+ }, B = () => {
82
+ o.blur();
65
83
  };
66
- return c(), L(t, () => c()), M(() => {
67
- r.value = `kvc-${h(10)}`;
84
+ return f(), M(t, () => f()), I(() => {
85
+ w.value = `kvc-${k(10)}`;
68
86
  }), {
69
- uuid: r,
70
- isChecked: o,
71
- checkboxRef: d,
72
- onChange: x,
73
- setChecked: c,
74
- focus: _,
75
- blur: A,
76
- classes: C,
77
- styles: g,
78
- inputAttrs: y,
79
- inputListeners: p
87
+ uuid: w,
88
+ isChecked: a,
89
+ checkboxRef: o,
90
+ onChange: p,
91
+ setChecked: f,
92
+ focus: A,
93
+ blur: B,
94
+ classes: g,
95
+ styles: y,
96
+ inputAttrs: x,
97
+ inputListeners: _,
98
+ iconCheckCircle: E
99
+ // <-- just return the value
80
100
  };
81
101
  }
82
- }, Z = ["for"], q = ["id", "checked", "value", "disabled"], D = {
102
+ }, Z = ["for"], F = ["id", "checked", "value", "disabled"], G = {
83
103
  key: 0,
84
104
  class: "tw-w-1.5 tw-h-auto",
85
105
  viewBox: "0 0 12 9",
86
106
  fill: "none",
87
107
  xmlns: "http://www.w3.org/2000/svg"
88
- }, F = { class: "tw-flex-1 peer-focus-visible:tw-ring-2 peer-focus-visible:tw-ring-action" };
89
- function G(i, l, t, e, n, r) {
90
- return m(), b("div", {
91
- class: f(e.classes),
92
- style: R(e.styles)
108
+ }, J = { class: "tw-flex-1 peer-focus-visible:tw-ring-2 peer-focus-visible:tw-ring-action" };
109
+ function Q(i, l, t, e, u, w) {
110
+ const a = K("KvMaterialIcon");
111
+ return r(), s("div", {
112
+ class: c(e.classes),
113
+ style: S(e.styles)
93
114
  }, [
94
- s("label", {
95
- class: f(["tw-inline-flex tw-items-center", { "tw-opacity-low": t.disabled }]),
115
+ d("label", {
116
+ class: c(["tw-inline-flex tw-items-center", { "tw-opacity-low": t.disabled && t.blurOnDisabled }]),
96
117
  for: e.uuid
97
118
  }, [
98
- s("input", S(e.inputAttrs, {
119
+ d("input", q(e.inputAttrs, {
99
120
  id: e.uuid,
100
121
  ref: "checkboxRef",
101
122
  class: "tw-peer tw-appearance-none tw-w-max",
@@ -103,11 +124,12 @@ function G(i, l, t, e, n, r) {
103
124
  checked: e.isChecked,
104
125
  value: t.value,
105
126
  disabled: t.disabled
106
- }, z(e.inputListeners, !0), {
107
- onChange: l[0] || (l[0] = E((...o) => e.onChange && e.onChange(...o), ["prevent"]))
108
- }), null, 16, q),
109
- s("div", {
110
- class: f(["tw-w-3 tw-h-3 tw-mr-2 tw-flex-shrink-0 tw-rounded-sm tw-border tw-flex tw-justify-center tw-items-center tw-overflow-hidden tw-transition-all tw-duration-100 peer-focus-visible:tw-ring-2 peer-focus-visible:tw-ring-action", {
127
+ }, R(e.inputListeners, !0), {
128
+ onChange: l[0] || (l[0] = j((...o) => e.onChange && e.onChange(...o), ["prevent"]))
129
+ }), null, 16, F),
130
+ t.variant === "square" ? (r(), s("div", {
131
+ key: 0,
132
+ class: c(["tw-w-3 tw-h-3 tw-mr-2 tw-flex-shrink-0 tw-rounded-sm tw-border tw-flex tw-justify-center tw-items-center tw-overflow-hidden tw-transition-all tw-duration-100 peer-focus-visible:tw-ring-2 peer-focus-visible:tw-ring-action", {
111
133
  "tw-bg-white": !e.isChecked,
112
134
  "tw-bg-action": e.isChecked,
113
135
  "tw-border-secondary": !e.isChecked && t.valid,
@@ -115,20 +137,43 @@ function G(i, l, t, e, n, r) {
115
137
  "tw-border-danger": !t.valid
116
138
  }])
117
139
  }, [
118
- e.isChecked ? (m(), b("svg", D, l[1] || (l[1] = [
119
- s("path", {
140
+ e.isChecked ? (r(), s("svg", G, l[1] || (l[1] = [
141
+ d("path", {
120
142
  d: "M3.99975 6.79988L1.66642 4.46655C1.40642 4.20655 0.993086 4.20655 0.733086 4.46655C0.473086 4.72655 0.473086 5.13988 0.733086 5.39988L3.52642 8.19322C3.78642 8.45322 4.20642 8.45322 4.46642 8.19322L11.5331 1.13322C11.7931 0.873216 11.7931 0.459883 11.5331 0.199883C11.2731 -0.0601172 10.8598 -0.0601172 10.5998 0.199883L3.99975 6.79988Z",
121
143
  fill: "white"
122
144
  }, null, -1)
123
- ]))) : N("", !0)
124
- ], 2),
125
- s("div", F, [
126
- j(i.$slots, "default")
145
+ ]))) : b("", !0)
146
+ ], 2)) : (r(), s("div", {
147
+ key: 1,
148
+ class: c([
149
+ "tw-w-3 tw-h-3 tw-mr-2",
150
+ "tw-flex-shrink-0",
151
+ "tw-rounded-full",
152
+ "tw-flex tw-justify-center tw-items-center",
153
+ "tw-overflow-hidden",
154
+ "tw-transition-all tw-duration-100",
155
+ "peer-focus-visible:tw-ring-2",
156
+ "peer-focus-visible:tw-ring-action",
157
+ e.isChecked ? "tw-text-brand-550 tw-bg-white" : "tw-bg-gray-200",
158
+ // Only show border if checked or invalid
159
+ !e.isChecked && !t.valid ? "tw-border-danger" : "",
160
+ e.isChecked && t.valid ? "tw-border-action" : "",
161
+ (!e.isChecked && t.valid, "")
162
+ ])
163
+ }, [
164
+ e.isChecked ? (r(), z(a, {
165
+ key: 0,
166
+ icon: e.iconCheckCircle,
167
+ class: "check-icon"
168
+ }, null, 8, ["icon"])) : b("", !0)
169
+ ], 2)),
170
+ d("div", J, [
171
+ D(i.$slots, "default", {}, void 0, !0)
127
172
  ])
128
173
  ], 10, Z)
129
174
  ], 6);
130
175
  }
131
- const T = /* @__PURE__ */ K(P, [["render", G]]);
176
+ const te = /* @__PURE__ */ H(P, [["render", Q], ["__scopeId", "data-v-9958a4b0"]]);
132
177
  export {
133
- T as default
178
+ te as default
134
179
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiva/kv-components",
3
- "version": "6.37.0",
3
+ "version": "6.38.1",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -111,5 +111,5 @@
111
111
  "embla-carousel-fade",
112
112
  "popper.js"
113
113
  ],
114
- "gitHead": "8fdfc97f384073089161f4631c5ca0929ac989c4"
114
+ "gitHead": "4181d07e183bb25f8fcc95b10d594b90b3dc418c"
115
115
  }