vueless 1.2.5-beta.4 → 1.2.5-beta.5

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.4",
3
+ "version": "1.2.5-beta.5",
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",
@@ -73,14 +73,14 @@ describe("UAccordion", () => {
73
73
 
74
74
  const firstItem = component.findAllComponents(UAccordionItem)[0];
75
75
 
76
- await firstItem.trigger("click");
76
+ await firstItem.find("[vl-child-key='title']").trigger("click");
77
77
 
78
78
  const updates = component.emitted("update:modelValue");
79
79
 
80
80
  expect(updates).toBeTruthy();
81
81
  expect(updates?.[0]).toEqual(["a"]);
82
82
 
83
- await firstItem.trigger("click");
83
+ await firstItem.find("[vl-child-key='title']").trigger("click");
84
84
  const updates2 = component.emitted("update:modelValue");
85
85
 
86
86
  expect(updates2?.[1]).toEqual([null]);
@@ -103,14 +103,14 @@ describe("UAccordion", () => {
103
103
 
104
104
  const [firstItem, secondItem] = component.findAllComponents(UAccordionItem);
105
105
 
106
- await firstItem.trigger("click");
107
- await secondItem.trigger("click");
106
+ await firstItem.find("[vl-child-key='title']").trigger("click");
107
+ await secondItem.find("[vl-child-key='title']").trigger("click");
108
108
  const updates = component.emitted("update:modelValue");
109
109
 
110
110
  expect(updates?.[0]).toEqual([["a"]]);
111
111
  expect(updates?.[1]).toEqual([["a", "b"]]);
112
112
 
113
- await firstItem.trigger("click");
113
+ await firstItem.find("[vl-child-key='title']").trigger("click");
114
114
  const updates2 = component.emitted("update:modelValue");
115
115
 
116
116
  expect(updates2?.[2]).toEqual([["b"]]);
@@ -42,8 +42,7 @@ const emit = defineEmits([
42
42
  ]);
43
43
 
44
44
  const wrapperRef = useTemplateRef<HTMLDivElement>("wrapper");
45
- const descriptionRef = useTemplateRef<HTMLDivElement>("description");
46
- const contentRef = useTemplateRef<HTMLDivElement>("content");
45
+ const titleRef = useTemplateRef<HTMLDivElement>("title");
47
46
 
48
47
  const accordionSize = ref(toValue(getAccordionSize) || props.size);
49
48
  const accordionDisabled = ref(toValue(getAccordionDisabled) || props.disabled);
@@ -79,10 +78,9 @@ const toggleIconName = computed(() => {
79
78
  });
80
79
 
81
80
  function onClickItem(event: MouseEvent) {
82
- const clickedInsideContent = contentRef.value?.contains(event.target as Node);
83
- const clickedDescription = descriptionRef.value?.contains(event.target as Node);
81
+ const clickedOnTitle = titleRef.value?.contains(event.target as Node);
84
82
 
85
- if (props.disabled || clickedDescription || clickedInsideContent) return;
83
+ if (!clickedOnTitle || props.disabled) return;
86
84
 
87
85
  emit("click", elementId, !isOpened.value);
88
86
 
@@ -123,7 +121,7 @@ const {
123
121
  <template>
124
122
  <div ref="wrapper" v-bind="wrapperAttrs" :data-test="getDataTest()" @click="onClickItem">
125
123
  <div v-bind="bodyAttrs">
126
- <div v-bind="titleAttrs">
124
+ <div v-bind="titleAttrs" ref="title">
127
125
  {{ title }}
128
126
  <!--
129
127
  @slot Use it to add something instead of the toggle icon.
@@ -144,12 +142,11 @@ const {
144
142
  <div
145
143
  v-if="description"
146
144
  :id="`description-${elementId}`"
147
- ref="description"
148
145
  v-bind="descriptionAttrs"
149
146
  v-text="description"
150
147
  />
151
148
 
152
- <div v-if="isOpened && hasSlotContent(slots['default'])" ref="content" v-bind="contentAttrs">
149
+ <div v-if="isOpened && hasSlotContent(slots['default'])" v-bind="contentAttrs">
153
150
  <!-- @slot Use it to add accordion content. -->
154
151
  <slot />
155
152
  </div>
@@ -171,7 +171,7 @@ describe("UAccordionItem", () => {
171
171
  expect(toggleElement.attributes("data-opened")).toBe("false");
172
172
 
173
173
  // Click to toggle
174
- await component.trigger("click");
174
+ await component.find("[vl-key='title']").trigger("click");
175
175
 
176
176
  expect(toggleElement.attributes("data-opened")).toBe("true");
177
177
  });
@@ -190,12 +190,12 @@ describe("UAccordionItem", () => {
190
190
 
191
191
  expect(component.find(`.${slotClass}`).exists()).toBe(false);
192
192
 
193
- await component.trigger("click");
193
+ await component.find("[vl-key='title']").trigger("click");
194
194
 
195
195
  expect(component.find(`.${slotClass}`).exists()).toBe(true);
196
196
  expect(component.find(`.${slotClass}`).text()).toBe(slotContent);
197
197
 
198
- await component.trigger("click");
198
+ await component.find("[vl-key='title']").trigger("click");
199
199
 
200
200
  expect(component.find(`.${slotClass}`).exists()).toBe(false);
201
201
  });
@@ -217,7 +217,7 @@ describe("UAccordionItem", () => {
217
217
  it("does not render content wrapper when default slot is empty", async () => {
218
218
  const component = mount(UAccordionItem, { props: { name: "test" } });
219
219
 
220
- await component.trigger("click");
220
+ await component.find("[vl-key='title']").trigger("click");
221
221
 
222
222
  expect(component.find("[vl-key='content']").exists()).toBe(false);
223
223
  });
@@ -235,7 +235,7 @@ describe("UAccordionItem", () => {
235
235
  },
236
236
  });
237
237
 
238
- await component.trigger("click");
238
+ await component.find("[vl-key='title']").trigger("click");
239
239
 
240
240
  const emitted = component.emitted("click");
241
241
 
@@ -243,7 +243,7 @@ describe("UAccordionItem", () => {
243
243
  expect(emitted?.[0]).toEqual([id, true]);
244
244
 
245
245
  // Click again to toggle back
246
- await component.trigger("click");
246
+ await component.find("[vl-key='title']").trigger("click");
247
247
 
248
248
  const emittedAgain = component.emitted("click");
249
249
 
@@ -281,13 +281,13 @@ describe("UAccordionItem", () => {
281
281
  expect(descriptionElement.classes()).not.toContain(openedClass);
282
282
 
283
283
  // Click to open
284
- await component.trigger("click");
284
+ await component.find("[vl-key='title']").trigger("click");
285
285
 
286
286
  // Should be opened
287
287
  expect(descriptionElement.classes()).toContain(openedClass);
288
288
 
289
289
  // Click to close
290
- await component.trigger("click");
290
+ await component.find("[vl-key='title']").trigger("click");
291
291
 
292
292
  // Should be closed again
293
293
  expect(descriptionElement.classes()).not.toContain(openedClass);