@code-coaching/vuetiful 0.13.2 → 0.14.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.
Files changed (31) hide show
  1. package/README.md +55 -2
  2. package/dist/style.css +1 -1
  3. package/dist/styles/all.css +118 -1
  4. package/dist/types/components/atoms/VBadge.test.d.ts +1 -0
  5. package/dist/types/components/atoms/VChip.test.d.ts +1 -0
  6. package/dist/types/components/atoms/VSwitch/VSwitch.test.d.ts +1 -0
  7. package/dist/types/components/atoms/VSwitch/VSwitch.vue.d.ts +70 -0
  8. package/dist/types/components/atoms/VSwitch/VSwitchDescription.test.d.ts +1 -0
  9. package/dist/types/components/atoms/VSwitch/VSwitchDescription.vue.d.ts +14 -0
  10. package/dist/types/components/atoms/VSwitch/VSwitchGroup.test.d.ts +1 -0
  11. package/dist/types/components/atoms/VSwitch/VSwitchGroup.vue.d.ts +14 -0
  12. package/dist/types/components/atoms/VSwitch/VSwitchLabel.test.d.ts +1 -0
  13. package/dist/types/components/atoms/VSwitch/VSwitchLabel.vue.d.ts +23 -0
  14. package/dist/types/components/atoms/index.d.ts +5 -1
  15. package/dist/vuetiful.es.mjs +243 -25
  16. package/dist/vuetiful.umd.js +10 -10
  17. package/package.json +1 -1
  18. package/src/components/atoms/VBadge.test.ts +18 -0
  19. package/src/components/atoms/VButton.test.ts +32 -32
  20. package/src/components/atoms/VChip.test.ts +18 -0
  21. package/src/components/atoms/VSwitch/VSwitch.test.ts +121 -0
  22. package/src/components/atoms/VSwitch/VSwitch.vue +91 -0
  23. package/src/components/atoms/VSwitch/VSwitchDescription.test.ts +56 -0
  24. package/src/components/atoms/VSwitch/VSwitchDescription.vue +16 -0
  25. package/src/components/atoms/VSwitch/VSwitchGroup.test.ts +26 -0
  26. package/src/components/atoms/VSwitch/VSwitchGroup.vue +16 -0
  27. package/src/components/atoms/VSwitch/VSwitchLabel.test.ts +89 -0
  28. package/src/components/atoms/VSwitch/VSwitchLabel.vue +20 -0
  29. package/src/components/atoms/index.ts +18 -1
  30. package/src/components/molecules/VRail.vue +1 -1
  31. package/src/utils/theme/remove.test.ts +1 -1
@@ -1,4 +1,4 @@
1
- import { openBlock, createElementBlock, renderSlot, normalizeClass, defineComponent, createBlock, resolveDynamicComponent, withCtx, Fragment, cloneVNode, h as h$1, watchEffect, computed, ref, provide, onMounted, onUnmounted, unref, inject, toRaw, watch, createElementVNode, reactive, readonly, toRefs, createVNode, Transition, createCommentVNode, useAttrs, mergeProps, toDisplayString, withDirectives, createTextVNode, resolveComponent, renderList, pushScopeId, popScopeId } from "vue";
1
+ import { openBlock, createElementBlock, renderSlot, normalizeClass, defineComponent, createBlock, resolveDynamicComponent, withCtx, Fragment, cloneVNode, h as h$1, onMounted, watchEffect, ref, computed, provide, onUnmounted, unref, inject, toRaw, watch, createElementVNode, createCommentVNode, reactive, readonly, toRefs, createVNode, Transition, useAttrs, mergeProps, toDisplayString, withDirectives, createTextVNode, resolveComponent, renderList, pushScopeId, popScopeId } from "vue";
2
2
  var _export_sfc = (sfc, props) => {
3
3
  const target = sfc.__vccOpts || sfc;
4
4
  for (const [key, val] of props) {
@@ -6,17 +6,17 @@ var _export_sfc = (sfc, props) => {
6
6
  }
7
7
  return target;
8
8
  };
9
- const _sfc_main$d = {};
10
- const _hoisted_1$7 = {
9
+ const _sfc_main$h = {};
10
+ const _hoisted_1$8 = {
11
11
  class: /* @__PURE__ */ normalizeClass(`vuetiful-badge badge`)
12
12
  };
13
13
  function _sfc_render$3(_ctx, _cache) {
14
- return openBlock(), createElementBlock("div", _hoisted_1$7, [
14
+ return openBlock(), createElementBlock("div", _hoisted_1$8, [
15
15
  renderSlot(_ctx.$slots, "default")
16
16
  ]);
17
17
  }
18
- var VBadge = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$3]]);
19
- const _sfc_main$c = /* @__PURE__ */ defineComponent({
18
+ var VBadge = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$3]]);
19
+ const _sfc_main$g = /* @__PURE__ */ defineComponent({
20
20
  __name: "VButton",
21
21
  props: {
22
22
  icon: {
@@ -66,16 +66,16 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
66
66
  };
67
67
  }
68
68
  });
69
- const _sfc_main$b = {};
70
- const _hoisted_1$6 = {
69
+ const _sfc_main$f = {};
70
+ const _hoisted_1$7 = {
71
71
  class: /* @__PURE__ */ normalizeClass(`vuetiful-chip chip`)
72
72
  };
73
73
  function _sfc_render$2(_ctx, _cache) {
74
- return openBlock(), createElementBlock("div", _hoisted_1$6, [
74
+ return openBlock(), createElementBlock("div", _hoisted_1$7, [
75
75
  renderSlot(_ctx.$slots, "default")
76
76
  ]);
77
77
  }
78
- var VChip = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$2]]);
78
+ var VChip = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$2]]);
79
79
  function u(r2, n2, ...a2) {
80
80
  if (r2 in n2) {
81
81
  let e2 = n2[r2];
@@ -84,7 +84,7 @@ function u(r2, n2, ...a2) {
84
84
  let t2 = new Error(`Tried to handle "${r2}" but there is no handler defined. Only defined handlers are: ${Object.keys(n2).map((e2) => `"${e2}"`).join(", ")}.`);
85
85
  throw Error.captureStackTrace && Error.captureStackTrace(t2, u), t2;
86
86
  }
87
- var N$1 = ((o2) => (o2[o2.None = 0] = "None", o2[o2.RenderStrategy = 1] = "RenderStrategy", o2[o2.Static = 2] = "Static", o2))(N$1 || {}), S = ((e2) => (e2[e2.Unmount = 0] = "Unmount", e2[e2.Hidden = 1] = "Hidden", e2))(S || {});
87
+ var N$1 = ((o2) => (o2[o2.None = 0] = "None", o2[o2.RenderStrategy = 1] = "RenderStrategy", o2[o2.Static = 2] = "Static", o2))(N$1 || {}), S$1 = ((e2) => (e2[e2.Unmount = 0] = "Unmount", e2[e2.Hidden = 1] = "Hidden", e2))(S$1 || {});
88
88
  function H$2({ visible: r2 = true, features: t2 = 0, ourProps: e2, theirProps: o2, ...i2 }) {
89
89
  var a2;
90
90
  let n2 = j$1(o2, e2), l = Object.assign(i2, { props: n2 });
@@ -110,7 +110,7 @@ function y$1({ props: r2, attrs: t2, slots: e2, slot: o2, name: i2 }) {
110
110
  u2 && (d2["data-headlessui-state"] = c2.join(" "));
111
111
  }
112
112
  if (n2 === "template") {
113
- if (a2 = b$1(a2 != null ? a2 : []), Object.keys(l).length > 0 || Object.keys(t2).length > 0) {
113
+ if (a2 = b$2(a2 != null ? a2 : []), Object.keys(l).length > 0 || Object.keys(t2).length > 0) {
114
114
  let [u2, ...c2] = a2 != null ? a2 : [];
115
115
  if (!v(u2) || c2.length > 0)
116
116
  throw new Error(['Passing props on "template"!', "", `The current component <${i2} /> is rendering a "template".`, "However we need to passthrough the following props:", Object.keys(l).concat(Object.keys(t2)).map((s2) => s2.trim()).filter((s2, g, R) => R.indexOf(s2) === g).sort((s2, g) => s2.localeCompare(g)).map((s2) => ` - ${s2}`).join(`
@@ -126,8 +126,8 @@ function y$1({ props: r2, attrs: t2, slots: e2, slot: o2, name: i2 }) {
126
126
  }
127
127
  return h$1(n2, Object.assign({}, l, d2), { default: () => a2 });
128
128
  }
129
- function b$1(r2) {
130
- return r2.flatMap((t2) => t2.type === Fragment ? b$1(t2.children) : [t2]);
129
+ function b$2(r2) {
130
+ return r2.flatMap((t2) => t2.type === Fragment ? b$2(t2.children) : [t2]);
131
131
  }
132
132
  function j$1(...r2) {
133
133
  if (r2.length === 0)
@@ -178,6 +178,22 @@ function o(n2) {
178
178
  var l;
179
179
  return n2 == null || n2.value == null ? null : (l = n2.value.$el) != null ? l : n2.value;
180
180
  }
181
+ function r$1(t2, e2) {
182
+ if (t2)
183
+ return t2;
184
+ let n2 = e2 != null ? e2 : "button";
185
+ if (typeof n2 == "string" && n2.toLowerCase() === "button")
186
+ return "button";
187
+ }
188
+ function b$1(t2, e2) {
189
+ let n2 = ref(r$1(t2.value.type, t2.value.as));
190
+ return onMounted(() => {
191
+ n2.value = r$1(t2.value.type, t2.value.as);
192
+ }), watchEffect(() => {
193
+ var o$12;
194
+ n2.value || o(e2) && o(e2) instanceof HTMLButtonElement && !((o$12 = o(e2)) != null && o$12.hasAttribute("type")) && (n2.value = "button");
195
+ }), n2;
196
+ }
181
197
  var i = Object.defineProperty;
182
198
  var d$3 = (t2, e2, r2) => e2 in t2 ? i(t2, e2, { enumerable: true, configurable: true, writable: true, value: r2 }) : t2[e2] = r2;
183
199
  var n = (t2, e2, r2) => (d$3(t2, typeof e2 != "symbol" ? e2 + "" : e2, r2), r2);
@@ -507,7 +523,52 @@ let Ee = defineComponent({ name: "RadioGroupOption", props: { as: { type: [Objec
507
523
  return H$2({ ourProps: K2, theirProps: G, slot: N2, attrs: c2, slots: u2, name: "RadioGroupOption" });
508
524
  };
509
525
  } }), we = T, Se = E;
510
- const _sfc_main$a = /* @__PURE__ */ defineComponent({
526
+ let S = Symbol("GroupContext"), ae = defineComponent({ name: "SwitchGroup", props: { as: { type: [Object, String], default: "template" } }, setup(l, { slots: p2, attrs: a2 }) {
527
+ let o2 = ref(null), f2 = K({ name: "SwitchLabel", props: { htmlFor: computed(() => {
528
+ var r2;
529
+ return (r2 = o2.value) == null ? void 0 : r2.id;
530
+ }), onClick(r2) {
531
+ o2.value && (r2.currentTarget.tagName === "LABEL" && r2.preventDefault(), o2.value.click(), o2.value.focus({ preventScroll: true }));
532
+ } } }), t2 = M({ name: "SwitchDescription" });
533
+ return provide(S, { switchRef: o2, labelledby: f2, describedby: t2 }), () => H$2({ theirProps: l, ourProps: {}, slot: {}, slots: p2, attrs: a2, name: "SwitchGroup" });
534
+ } }), ue = defineComponent({ name: "Switch", emits: { "update:modelValue": (l) => true }, props: { as: { type: [Object, String], default: "button" }, modelValue: { type: Boolean, default: void 0 }, defaultChecked: { type: Boolean, optional: true }, form: { type: String, optional: true }, name: { type: String, optional: true }, value: { type: String, optional: true }, id: { type: String, default: () => `headlessui-switch-${t()}` } }, inheritAttrs: false, setup(l, { emit: p2, attrs: a2, slots: o$2, expose: f2 }) {
535
+ let t2 = inject(S, null), [i2, r2] = d$2(computed(() => l.modelValue), (e2) => p2("update:modelValue", e2), computed(() => l.defaultChecked));
536
+ function s2() {
537
+ r2(!i2.value);
538
+ }
539
+ let w = ref(null), u2 = t2 === null ? w : t2.switchRef, g = b$1(computed(() => ({ as: l.as, type: a2.type })), u2);
540
+ f2({ el: u2, $el: u2 });
541
+ function k(e2) {
542
+ e2.preventDefault(), s2();
543
+ }
544
+ function C(e2) {
545
+ e2.key === o$1.Space ? (e2.preventDefault(), s2()) : e2.key === o$1.Enter && p$1(e2.currentTarget);
546
+ }
547
+ function E2(e2) {
548
+ e2.preventDefault();
549
+ }
550
+ let c2 = computed(() => {
551
+ var e2, n2;
552
+ return (n2 = (e2 = o(u2)) == null ? void 0 : e2.closest) == null ? void 0 : n2.call(e2, "form");
553
+ });
554
+ return onMounted(() => {
555
+ watch([c2], () => {
556
+ if (!c2.value || l.defaultChecked === void 0)
557
+ return;
558
+ function e2() {
559
+ r2(l.defaultChecked);
560
+ }
561
+ return c2.value.addEventListener("reset", e2), () => {
562
+ var n2;
563
+ (n2 = c2.value) == null || n2.removeEventListener("reset", e2);
564
+ };
565
+ }, { immediate: true });
566
+ }), () => {
567
+ let { id: e2, name: n2, value: L, form: D, ...R } = l, K2 = { checked: i2.value }, x = { id: e2, ref: u2, role: "switch", type: g.value, tabIndex: 0, "aria-checked": i2.value, "aria-labelledby": t2 == null ? void 0 : t2.labelledby.value, "aria-describedby": t2 == null ? void 0 : t2.describedby.value, onClick: k, onKeyup: C, onKeypress: E2 };
568
+ return h$1(Fragment, [n2 != null && i2.value != null ? h$1(f$1, K$1({ features: a$1.Hidden, as: "input", type: "checkbox", hidden: true, readOnly: true, checked: i2.value, form: D, name: n2, value: L })) : null, H$2({ ourProps: x, theirProps: { ...a2, ...T$2(R, ["modelValue", "defaultChecked"]) }, slot: K2, attrs: a2, slots: o$2, name: "Switch" })]);
569
+ };
570
+ } }), de = T, ce = E;
571
+ const _sfc_main$e = /* @__PURE__ */ defineComponent({
511
572
  __name: "VRadioDescription",
512
573
  props: {
513
574
  as: {
@@ -526,7 +587,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
526
587
  };
527
588
  }
528
589
  });
529
- const _sfc_main$9 = /* @__PURE__ */ defineComponent({
590
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
530
591
  __name: "VRadioGroup",
531
592
  props: {
532
593
  as: {
@@ -594,7 +655,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
594
655
  };
595
656
  }
596
657
  });
597
- const _sfc_main$8 = /* @__PURE__ */ defineComponent({
658
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
598
659
  __name: "VRadioItem",
599
660
  props: {
600
661
  value: {
@@ -619,7 +680,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
619
680
  };
620
681
  }
621
682
  });
622
- const _sfc_main$7 = /* @__PURE__ */ defineComponent({
683
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
623
684
  __name: "VRadioLabel",
624
685
  props: {
625
686
  as: {
@@ -638,6 +699,159 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
638
699
  };
639
700
  }
640
701
  });
702
+ const _hoisted_1$6 = {
703
+ key: 0,
704
+ class: "sr-only"
705
+ };
706
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
707
+ __name: "VSwitch",
708
+ props: {
709
+ modelValue: {
710
+ type: Boolean,
711
+ default: false
712
+ },
713
+ disabled: {
714
+ type: Boolean,
715
+ default: false
716
+ },
717
+ size: {
718
+ type: String,
719
+ default: "md"
720
+ },
721
+ switchClass: {
722
+ type: String,
723
+ default: "variant-filled"
724
+ },
725
+ thumbClass: {
726
+ type: String,
727
+ default: "bg-surface-100-800-token"
728
+ },
729
+ as: {
730
+ type: String,
731
+ default: "button"
732
+ },
733
+ name: {
734
+ type: String,
735
+ default: ""
736
+ }
737
+ },
738
+ emits: ["update:modelValue"],
739
+ setup(__props, { emit }) {
740
+ const props = __props;
741
+ const parentModelValue = ref(props.modelValue);
742
+ watch(
743
+ () => props.modelValue,
744
+ (newValue) => {
745
+ parentModelValue.value = newValue;
746
+ }
747
+ );
748
+ watch(
749
+ () => parentModelValue.value,
750
+ (newValue) => {
751
+ emit("update:modelValue", newValue);
752
+ }
753
+ );
754
+ const trackSize = computed(() => {
755
+ switch (props.size) {
756
+ case "xs":
757
+ return "w-8 h-4";
758
+ case "sm":
759
+ return "w-12 h-6";
760
+ case "md":
761
+ return "w-16 h-8";
762
+ case "lg":
763
+ return "w-20 h-10";
764
+ case "xl":
765
+ return "w-24 h-12";
766
+ default:
767
+ return props.size;
768
+ }
769
+ });
770
+ return (_ctx, _cache) => {
771
+ return openBlock(), createBlock(unref(ue), {
772
+ class: normalizeClass(`slide-toggle-track flex transition-all duration-[150ms] border-token rounded-container-token ${unref(trackSize)} ${__props.disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"} ${__props.switchClass}`),
773
+ name: __props.name,
774
+ as: __props.as,
775
+ modelValue: parentModelValue.value,
776
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => parentModelValue.value = $event)
777
+ }, {
778
+ default: withCtx(({ checked }) => [
779
+ _ctx.$slots.default ? (openBlock(), createElementBlock("span", _hoisted_1$6, [
780
+ renderSlot(_ctx.$slots, "default")
781
+ ])) : createCommentVNode("", true),
782
+ createElementVNode("div", {
783
+ class: normalizeClass(`slide-toggle-thumb h-full w-[50%] scale-[0.8] shadow transition-all duration-[150ms] rounded-token ${checked ? "translate-x-full" : "opacity-90"} ${__props.disabled ? "cursor-not-allowed" : "cursor-pointer"} ${__props.thumbClass} bg-opacity-90`)
784
+ }, null, 2)
785
+ ]),
786
+ _: 3
787
+ }, 8, ["class", "name", "as", "modelValue"]);
788
+ };
789
+ }
790
+ });
791
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
792
+ __name: "VSwitchDescription",
793
+ props: {
794
+ as: {
795
+ type: String,
796
+ default: "p"
797
+ }
798
+ },
799
+ setup(__props) {
800
+ return (_ctx, _cache) => {
801
+ return openBlock(), createBlock(unref(ce), { as: __props.as }, {
802
+ default: withCtx(() => [
803
+ renderSlot(_ctx.$slots, "default")
804
+ ]),
805
+ _: 3
806
+ }, 8, ["as"]);
807
+ };
808
+ }
809
+ });
810
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
811
+ __name: "VSwitchGroup",
812
+ props: {
813
+ as: {
814
+ type: String,
815
+ default: "template"
816
+ }
817
+ },
818
+ setup(__props) {
819
+ return (_ctx, _cache) => {
820
+ return openBlock(), createBlock(unref(ae), { as: __props.as }, {
821
+ default: withCtx(() => [
822
+ renderSlot(_ctx.$slots, "default")
823
+ ]),
824
+ _: 3
825
+ }, 8, ["as"]);
826
+ };
827
+ }
828
+ });
829
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
830
+ __name: "VSwitchLabel",
831
+ props: {
832
+ as: {
833
+ type: String,
834
+ default: "p"
835
+ },
836
+ passive: {
837
+ type: Boolean,
838
+ default: false
839
+ }
840
+ },
841
+ setup(__props) {
842
+ return (_ctx, _cache) => {
843
+ return openBlock(), createBlock(unref(de), {
844
+ as: __props.as,
845
+ passive: __props.passive
846
+ }, {
847
+ default: withCtx(() => [
848
+ renderSlot(_ctx.$slots, "default")
849
+ ]),
850
+ _: 3
851
+ }, 8, ["as", "passive"]);
852
+ };
853
+ }
854
+ });
641
855
  const selectedRailTile = ref("");
642
856
  const useRail = () => {
643
857
  return {
@@ -958,13 +1172,17 @@ const _sfc_main$3 = defineComponent({
958
1172
  var components = /* @__PURE__ */ Object.freeze({
959
1173
  __proto__: null,
960
1174
  [Symbol.toStringTag]: "Module",
961
- VButton: _sfc_main$c,
1175
+ VButton: _sfc_main$g,
962
1176
  VBadge,
963
1177
  VChip,
964
- VRadioGroup: _sfc_main$9,
965
- VRadioItem: _sfc_main$8,
966
- VRadioLabel: _sfc_main$7,
967
- VRadioDescription: _sfc_main$a,
1178
+ VRadioGroup: _sfc_main$d,
1179
+ VRadioItem: _sfc_main$c,
1180
+ VRadioLabel: _sfc_main$b,
1181
+ VRadioDescription: _sfc_main$e,
1182
+ VSwitchGroup: _sfc_main$8,
1183
+ VSwitchLabel: _sfc_main$7,
1184
+ VSwitchDescription: _sfc_main$9,
1185
+ VSwitch: _sfc_main$a,
968
1186
  VRail: _sfc_main$5,
969
1187
  VRailTile: _sfc_main$4,
970
1188
  VShell: _sfc_main$3,
@@ -47614,7 +47832,7 @@ var themeSwitcher_vue_vue_type_style_index_0_scoped_true_lang = "";
47614
47832
  const _sfc_main = defineComponent({
47615
47833
  components: {
47616
47834
  DarkModeSwitch,
47617
- VButton: _sfc_main$c
47835
+ VButton: _sfc_main$g
47618
47836
  },
47619
47837
  props: {
47620
47838
  bgLight: {
@@ -47857,4 +48075,4 @@ function install(app) {
47857
48075
  }
47858
48076
  }
47859
48077
  var index = { install };
47860
- export { DarkModeSwitch, themeSwitcher as ThemeSwitcher, VBadge, _sfc_main$c as VButton, VChip, _sfc_main$2 as VCodeBlock, _sfc_main$6 as VDrawer, _sfc_main$a as VRadioDescription, _sfc_main$9 as VRadioGroup, _sfc_main$8 as VRadioItem, _sfc_main$7 as VRadioLabel, _sfc_main$5 as VRail, _sfc_main$4 as VRailTile, _sfc_main$3 as VShell, index as default, useDarkMode, useDrawer, useRail, useTheme, clipboard as vClipboard };
48078
+ export { DarkModeSwitch, themeSwitcher as ThemeSwitcher, VBadge, _sfc_main$g as VButton, VChip, _sfc_main$2 as VCodeBlock, _sfc_main$6 as VDrawer, _sfc_main$e as VRadioDescription, _sfc_main$d as VRadioGroup, _sfc_main$c as VRadioItem, _sfc_main$b as VRadioLabel, _sfc_main$5 as VRail, _sfc_main$4 as VRailTile, _sfc_main$3 as VShell, _sfc_main$a as VSwitch, _sfc_main$9 as VSwitchDescription, _sfc_main$8 as VSwitchGroup, _sfc_main$7 as VSwitchLabel, index as default, useDarkMode, useDrawer, useRail, useTheme, clipboard as vClipboard };