vueless 1.2.5-beta.0 → 1.2.5-beta.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "1.2.5-beta.0",
3
+ "version": "1.2.5-beta.2",
4
4
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
5
5
  "author": "Johnny Grid <hello@vueless.com> (https://vueless.com)",
6
6
  "homepage": "https://vueless.com",
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { computed, provide, useTemplateRef, ref, watch } from "vue";
2
+ import { computed, provide, useTemplateRef, ref, watch, onMounted } from "vue";
3
3
 
4
4
  import useUI from "../composables/useUI";
5
5
  import { getDefaults } from "../utils/ui";
@@ -15,7 +15,7 @@ defineOptions({ inheritAttrs: false });
15
15
 
16
16
  const props = withDefaults(defineProps<Props>(), {
17
17
  ...getDefaults<Props, Config>(defaultConfig, COMPONENT_NAME),
18
- modelValue: undefined,
18
+ modelValue: () => [],
19
19
  options: () => [],
20
20
  });
21
21
 
@@ -42,6 +42,16 @@ const selectedItem = computed({
42
42
  },
43
43
  });
44
44
 
45
+ onMounted(() => {
46
+ const initiallyOpened = props.options
47
+ .filter((option) => option.opened)
48
+ .map((option) => option.value);
49
+
50
+ if (initiallyOpened.length > 0) {
51
+ selectedItem.value = props.multiple ? initiallyOpened : initiallyOpened[0];
52
+ }
53
+ });
54
+
45
55
  provide<SetAccordionSelectedItem>("setAccordionSelectedItem", (value, opened) => {
46
56
  if (props.multiple) {
47
57
  let current: string[] = [];
@@ -101,7 +111,6 @@ const { getDataTest, accordionItemAttrs, accordionAttrs } = useUI<Config>(defaul
101
111
  :key="index"
102
112
  :model-value="selectedItem"
103
113
  :value="option.value"
104
- :opened="option.opened"
105
114
  :title="option.title"
106
115
  :description="option.description"
107
116
  :size="size"
@@ -28,7 +28,7 @@ export default {
28
28
  title: "Containers / Accordion",
29
29
  component: UAccordion,
30
30
  args: {
31
- modelValue: "2",
31
+ modelValue: null,
32
32
  options: [
33
33
  {
34
34
  value: "1",
@@ -40,6 +40,7 @@ export default {
40
40
  },
41
41
  {
42
42
  value: "2",
43
+ opened: true,
43
44
  title: "Pioneering Cutting-Edge Solutions",
44
45
  description:
45
46
  trimText(`Our team stays ahead of the curve, integrating the latest technologies
@@ -1,3 +1,4 @@
1
+ import { ref } from "vue";
1
2
  import { mount } from "@vue/test-utils";
2
3
  import { describe, it, expect } from "vitest";
3
4
 
@@ -57,8 +58,17 @@ describe("UAccordion", () => {
57
58
  // Events
58
59
  describe("Events", () => {
59
60
  it("emits update:modelValue when an item is toggled (single)", async () => {
61
+ const modelValue = ref<string | null>(null);
62
+
60
63
  const component = mount(UAccordion, {
61
- props: { options },
64
+ props: {
65
+ options,
66
+ modelValue: modelValue.value,
67
+ "onUpdate:modelValue": (value: string | null) => {
68
+ modelValue.value = value;
69
+ component.setProps({ modelValue: value });
70
+ },
71
+ },
62
72
  });
63
73
 
64
74
  const firstItem = component.findAllComponents(UAccordionItem)[0];
@@ -77,8 +87,18 @@ describe("UAccordion", () => {
77
87
  });
78
88
 
79
89
  it("emits update:modelValue with arrays when multiple=true", async () => {
90
+ const modelValue = ref<string[]>([]);
91
+
80
92
  const component = mount(UAccordion, {
81
- props: { options, multiple: true },
93
+ props: {
94
+ options,
95
+ multiple: true,
96
+ modelValue: modelValue.value,
97
+ "onUpdate:modelValue": (value: string[]) => {
98
+ modelValue.value = value;
99
+ component.setProps({ modelValue: value });
100
+ },
101
+ },
82
102
  });
83
103
 
84
104
  const [firstItem, secondItem] = component.findAllComponents(UAccordionItem);
@@ -54,7 +54,7 @@ watchEffect(() => (accordionDisabled.value = toValue(getAccordionDisabled) || pr
54
54
  const slots = useSlots();
55
55
  const elementId = props.id || useId();
56
56
 
57
- const internalOpened = ref(false);
57
+ const internalOpened = ref(props.opened || false);
58
58
 
59
59
  const isOpened = computed(() => {
60
60
  const selectedItem = toValue(getAccordionSelectedItem);
@@ -67,7 +67,7 @@ const isOpened = computed(() => {
67
67
  return isEqual(selectedItem, props.value);
68
68
  }
69
69
 
70
- return props.opened || internalOpened.value;
70
+ return internalOpened.value;
71
71
  });
72
72
 
73
73
  const toggleIconName = computed(() => {
@@ -27,6 +27,7 @@ export default {
27
27
  title: "Containers / Accordion Item",
28
28
  component: UAccordionItem,
29
29
  args: {
30
+ opened: true,
30
31
  title: "Committed to Quality and Performance",
31
32
  description: trimText(
32
33
  `We take pride in delivering high-quality solutions tailored to your needs.
@@ -40,7 +40,7 @@ export default /*tw*/ {
40
40
  interactive: false,
41
41
  /* icon library */
42
42
  library: "@material-symbols",
43
- path: "", // set for `custom-icons` library only.
43
+ path: "", // set for `custom` library only.
44
44
  style: "outlined",
45
45
  weight: 500,
46
46
  },
@@ -6,7 +6,7 @@ import type { ComponentConfig } from "../types";
6
6
 
7
7
  export type Config = typeof defaultConfig;
8
8
 
9
- export type IconLibraries = "@material-symbols" | "bootstrap-icons" | "heroicons" | "custom-icons";
9
+ export type IconLibraries = "@material-symbols" | "bootstrap-icons" | "heroicons" | "custom";
10
10
 
11
11
  export interface Props {
12
12
  /**