@kiva/kv-components 10.2.1 → 10.3.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,17 +1,17 @@
1
- import s from "./KvSwitch2.js";
2
- import { openBlock as w, createElementBlock as a, normalizeStyle as d, normalizeClass as r, createElementVNode as i, mergeProps as c, toHandlers as f, withModifiers as u, renderSlot as h } from "vue";
1
+ import n from "./KvSwitch2.js";
2
+ import { openBlock as a, createElementBlock as c, normalizeStyle as d, normalizeClass as i, createElementVNode as t, mergeProps as w, toHandlers as f, withModifiers as u, renderSlot as h } from "vue";
3
3
  import m from "../_virtual/_plugin-vue_export-helper.js";
4
- const b = ["for"], v = ["id", "checked", "disabled"], p = { class: "tw-flex-1 peer-focus-visible:tw-ring-2 peer-focus-visible:tw-ring-action" };
5
- function g(o, t, l, e, k, x) {
6
- return w(), a("div", {
7
- class: r(e.classes),
4
+ const b = ["for"], v = ["id", "checked", "disabled"], g = { class: "tw-flex-1 peer-focus-visible:tw-ring-2 peer-focus-visible:tw-ring-action" };
5
+ function _(r, o, l, e, p, k) {
6
+ return a(), c("div", {
7
+ class: i(e.classes),
8
8
  style: d(e.styles)
9
9
  }, [
10
- i("label", {
11
- class: r(["tw-inline-flex tw-gap-2 tw-items-center tw-relative hover:tw-cursor-pointer", { "tw-opacity-low": l.disabled }]),
10
+ t("label", {
11
+ class: i(["tw-inline-flex tw-gap-2 tw-items-center tw-relative hover:tw-cursor-pointer", { "tw-opacity-low": l.disabled }]),
12
12
  for: e.uuid
13
13
  }, [
14
- i("input", c({ id: e.uuid }, e.inputAttrs, {
14
+ t("input", w({ id: e.uuid }, e.inputAttrs, {
15
15
  ref: "switchRef",
16
16
  class: "tw-sr-only tw-peer",
17
17
  type: "checkbox",
@@ -19,17 +19,21 @@ function g(o, t, l, e, k, x) {
19
19
  checked: l.modelValue,
20
20
  disabled: l.disabled
21
21
  }, f(e.inputListeners, !0), {
22
- onChange: t[0] || (t[0] = u((...n) => e.onChange && e.onChange(...n), ["prevent"]))
22
+ onChange: o[0] || (o[0] = u((...s) => e.onChange && e.onChange(...s), ["prevent"]))
23
23
  }), null, 16, v),
24
- t[1] || (t[1] = i("div", { class: "tw-w-7 tw-h-4 tw-rounded-full tw-relative tw-overflow-hidden peer-focus-visible:tw-ring-2 peer-focus-visible:tw-ring-action tw-bg-tertiary peer-checked:tw-bg-action tw-transition-all tw-ease-in-out" }, null, -1)),
25
- t[2] || (t[2] = i("div", { class: "tw-flex-shrink-0 tw-w-3 tw-h-3 tw-absolute tw-m-0.5 tw-top-0 tw-rounded-full tw-bg-white tw-transform tw-transition-all tw-ease-in-out peer-checked:tw-translate-x-3" }, null, -1)),
26
- i("div", p, [
27
- h(o.$slots, "default")
24
+ t("div", {
25
+ class: i(["tw-rounded-full tw-relative tw-overflow-hidden peer-focus-visible:tw-ring-2 peer-focus-visible:tw-ring-action tw-bg-tertiary peer-checked:tw-bg-action tw-transition-all tw-ease-in-out", e.trackSizeClasses])
26
+ }, null, 2),
27
+ t("div", {
28
+ class: i(["tw-flex-shrink-0 tw-absolute tw-m-0.5 tw-top-0 tw-rounded-full tw-bg-white tw-transform tw-transition-all tw-ease-in-out", e.knobSizeClasses])
29
+ }, null, 2),
30
+ t("div", g, [
31
+ h(r.$slots, "default")
28
32
  ])
29
33
  ], 10, b)
30
34
  ], 6);
31
35
  }
32
- const S = /* @__PURE__ */ m(s, [["render", g]]);
36
+ const S = /* @__PURE__ */ m(n, [["render", _]]);
33
37
  export {
34
38
  S as default
35
39
  };
@@ -7,6 +7,11 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
7
7
  type: BooleanConstructor;
8
8
  default: boolean;
9
9
  };
10
+ size: {
11
+ type: StringConstructor;
12
+ default: string;
13
+ validator(value: string): boolean;
14
+ };
10
15
  }>, {
11
16
  uuid: import('vue').Ref<string, string>;
12
17
  onChange: (event: any) => void;
@@ -16,6 +21,8 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
16
21
  styles: any[];
17
22
  inputAttrs: any;
18
23
  inputListeners: any;
24
+ trackSizeClasses: import('vue').ComputedRef<"tw-w-6 tw-h-3.5" | "tw-w-7 tw-h-4">;
25
+ knobSizeClasses: import('vue').ComputedRef<"tw-w-2.5 tw-h-2.5 peer-checked:tw-translate-x-2.5" | "tw-w-3 tw-h-3 peer-checked:tw-translate-x-3">;
19
26
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, string[], string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
20
27
  modelValue: {
21
28
  type: BooleanConstructor;
@@ -25,10 +32,16 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
25
32
  type: BooleanConstructor;
26
33
  default: boolean;
27
34
  };
35
+ size: {
36
+ type: StringConstructor;
37
+ default: string;
38
+ validator(value: string): boolean;
39
+ };
28
40
  }>> & Readonly<{
29
41
  [x: `on${Capitalize<string>}`]: (...args: any[]) => any;
30
42
  }>, {
31
43
  disabled: boolean;
44
+ size: string;
32
45
  modelValue: boolean;
33
46
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
34
47
  export default _default;
@@ -1,7 +1,7 @@
1
- import { ref as o, onMounted as v } from "vue";
2
- import { nanoid as l } from "nanoid";
1
+ import { ref as a, computed as o, onMounted as z } from "vue";
2
+ import { nanoid as u } from "nanoid";
3
3
  import { useAttrs as V } from "../utils/attrs.js";
4
- const u = [
4
+ const n = [
5
5
  "update:modelValue"
6
6
  ], A = {
7
7
  inheritAttrs: !1,
@@ -24,33 +24,49 @@ const u = [
24
24
  disabled: {
25
25
  type: Boolean,
26
26
  default: !1
27
+ },
28
+ /**
29
+ * Size of the switch.
30
+ * `default` renders a 56x32px track (`tw-w-7 tw-h-4`) with a 24px
31
+ * knob (`tw-w-3 tw-h-3`) travelling 24px when checked.
32
+ * `small` renders a 48x28px track (`tw-w-6 tw-h-3.5`) with a 20px
33
+ * knob (`tw-w-2.5 tw-h-2.5`) travelling 20px when checked.
34
+ */
35
+ size: {
36
+ type: String,
37
+ default: "default",
38
+ validator(e) {
39
+ return ["default", "small"].includes(e);
40
+ }
27
41
  }
28
42
  },
29
- emits: u,
30
- setup(h, e) {
31
- const { emit: a } = e, t = o(`kvs-${l(10)}`), s = o(null), {
32
- classes: n,
33
- styles: r,
34
- inputAttrs: d,
35
- inputListeners: p
36
- } = V(e, u), c = (f) => {
37
- a("update:modelValue", f.target.checked);
38
- }, i = () => {
39
- s.value.focus();
40
- }, m = () => {
41
- s.value.blur();
43
+ emits: n,
44
+ setup(e, t) {
45
+ const { emit: r } = t, s = a(`kvs-${u(10)}`), l = a(null), {
46
+ classes: d,
47
+ styles: c,
48
+ inputAttrs: i,
49
+ inputListeners: m
50
+ } = V(t, n), p = o(() => e.size === "small" ? "tw-w-6 tw-h-3.5" : "tw-w-7 tw-h-4"), f = o(() => e.size === "small" ? "tw-w-2.5 tw-h-2.5 peer-checked:tw-translate-x-2.5" : "tw-w-3 tw-h-3 peer-checked:tw-translate-x-3"), w = (v) => {
51
+ r("update:modelValue", v.target.checked);
52
+ }, h = () => {
53
+ l.value.focus();
54
+ }, k = () => {
55
+ l.value.blur();
42
56
  };
43
- return v(() => {
44
- t.value = `kvs-${l(10)}`;
57
+ return z(() => {
58
+ s.value = `kvs-${u(10)}`;
45
59
  }), {
46
- uuid: t,
47
- onChange: c,
48
- focus: i,
49
- blur: m,
50
- classes: n,
51
- styles: r,
52
- inputAttrs: d,
53
- inputListeners: p
60
+ uuid: s,
61
+ onChange: w,
62
+ focus: h,
63
+ blur: k,
64
+ classes: d,
65
+ styles: c,
66
+ inputAttrs: i,
67
+ inputListeners: m,
68
+ trackSizeClasses: p,
69
+ knobSizeClasses: f
54
70
  };
55
71
  }
56
72
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiva/kv-components",
3
- "version": "10.2.1",
3
+ "version": "10.3.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -112,5 +112,5 @@
112
112
  "dependencies": {
113
113
  "fuse.js": "^7.1.0"
114
114
  },
115
- "gitHead": "81ac7dc6b38cd9d9b53334c5ce40b49094524218"
115
+ "gitHead": "85947c6f6991c7ef893d142a4aac78afe3017d06"
116
116
  }