vueless 1.1.1-beta.6 → 1.1.1-beta.8

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.
@@ -2,14 +2,15 @@ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
2
2
  import { computed, nextTick } from "vue";
3
3
  import { mount } from "@vue/test-utils";
4
4
 
5
+ import type { ComponentInternalInstance } from "vue";
6
+
5
7
  // TODO: Autogenerated, need to be reviewed
6
8
 
7
9
  // Mock the ui utils
8
10
  vi.mock("../../utils/ui.ts", () => ({
9
11
  cx: vi.fn((classes) => (Array.isArray(classes) ? classes.filter(Boolean).join(" ") : classes)),
10
12
  cva: vi.fn((config) => {
11
- // Return a spy function that can be called and tracked
12
- const cvaSpy = vi.fn((props) => {
13
+ return vi.fn((props) => {
13
14
  if (!config.variants) return config.base || "";
14
15
 
15
16
  let classes = config.base || "";
@@ -17,16 +18,15 @@ vi.mock("../../utils/ui.ts", () => ({
17
18
  // Apply variants
18
19
  Object.entries(config.variants).forEach(([key, variants]) => {
19
20
  const value = props[key];
21
+ const variantsRecord = variants as UnknownObject;
20
22
 
21
- if (value && variants[value]) {
22
- classes += ` ${variants[value]}`;
23
+ if (variantsRecord?.[value]) {
24
+ classes += ` ${variantsRecord[value]}`;
23
25
  }
24
26
  });
25
27
 
26
28
  return classes.trim();
27
29
  });
28
-
29
- return cvaSpy;
30
30
  }),
31
31
  setColor: vi.fn((classes, color) => classes?.replace(/{color}/g, color)),
32
32
  vuelessConfig: { components: {}, unstyled: false },
@@ -56,10 +56,25 @@ vi.mock("vue", async () => {
56
56
  import useUI from "../useUI.ts";
57
57
  import * as uiUtils from "../../utils/ui.ts";
58
58
  import { getCurrentInstance, useAttrs } from "vue";
59
+ import type { UnknownObject } from "../../types.ts";
59
60
 
60
61
  // Test component for integration testing
61
62
  const TestComponent = {
62
63
  template: '<div :data-test="getDataTest()" v-bind="bodyAttrs">Test</div>',
64
+ props: {
65
+ config: {
66
+ type: Object,
67
+ default: () => ({}),
68
+ },
69
+ dataTest: {
70
+ type: String,
71
+ default: null,
72
+ },
73
+ color: {
74
+ type: String,
75
+ default: "primary",
76
+ },
77
+ },
63
78
  setup() {
64
79
  const defaultConfig = {
65
80
  body: {
@@ -97,7 +112,7 @@ describe("useUI", () => {
97
112
  type: { __name: "TestComponent" },
98
113
  props: { dataTest: "test", color: "primary", config: {} },
99
114
  parent: null,
100
- });
115
+ } as unknown as ComponentInternalInstance);
101
116
 
102
117
  vi.mocked(useAttrs).mockReturnValue({
103
118
  class: "",
@@ -148,7 +163,7 @@ describe("useUI", () => {
148
163
  type: { __name: "TestComponent" },
149
164
  props: { config: propsConfig, dataTest: "test" },
150
165
  parent: null,
151
- });
166
+ } as unknown as ComponentInternalInstance);
152
167
 
153
168
  // Call useUI to trigger the config merging
154
169
  useUI(defaultConfig);
@@ -201,7 +216,7 @@ describe("useUI", () => {
201
216
  type: { __name: "TestComponent" },
202
217
  props: { color: "blue", dataTest: "test" },
203
218
  parent: null,
204
- });
219
+ } as unknown as ComponentInternalInstance);
205
220
 
206
221
  // Test the setColor function directly
207
222
  expect(uiUtils.setColor).toBeDefined();
@@ -247,7 +262,7 @@ describe("useUI", () => {
247
262
  type: { __name: "TestComponent" },
248
263
  props: {},
249
264
  parent: null,
250
- });
265
+ } as unknown as ComponentInternalInstance);
251
266
 
252
267
  const result = useUI({});
253
268
  const dataTest = result.getDataTest();
@@ -336,7 +351,7 @@ describe("useUI", () => {
336
351
  type: { __name: "UButton" },
337
352
  props: { dataTest: "test" },
338
353
  parent: null,
339
- });
354
+ } as unknown as ComponentInternalInstance);
340
355
 
341
356
  const result = useUI({});
342
357
 
@@ -349,8 +364,8 @@ describe("useUI", () => {
349
364
  props: { dataTest: "test" },
350
365
  parent: {
351
366
  type: { __name: "UButton" },
352
- },
353
- });
367
+ } as UnknownObject,
368
+ } as unknown as ComponentInternalInstance);
354
369
 
355
370
  const result = useUI({});
356
371
 
@@ -17,9 +17,12 @@ export function useComponentLocaleMessages<TLocale>(
17
17
 
18
18
  const globalComponentMassages = ref(recursiveRt(tm(componentName) as VueMessageType));
19
19
 
20
- watch(locale, () => {
21
- globalComponentMassages.value = recursiveRt(tm(componentName) as VueMessageType);
22
- });
20
+ watch(
21
+ () => locale,
22
+ () => {
23
+ globalComponentMassages.value = recursiveRt(tm(componentName) as VueMessageType);
24
+ },
25
+ );
23
26
 
24
27
  const localeMessages = computed(
25
28
  () => merge({}, defaultLocale, globalComponentMassages.value, propsLocale) as TLocale,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "1.1.1-beta.6",
3
+ "version": "1.1.1-beta.8",
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",
@@ -186,6 +186,7 @@ const {
186
186
  :data-test="getDataTest('table')"
187
187
  @drag-sort="onDragEnd"
188
188
  >
189
+ <!-- @vue-ignore -->
189
190
  <template #label="slotProps: { item: DataListItem; crossed: boolean }">
190
191
  <!--
191
192
  @slot Use it to modify label.
@@ -200,6 +201,7 @@ const {
200
201
  </slot>
201
202
  </template>
202
203
 
204
+ <!-- @vue-ignore -->
203
205
  <template #actions="slotProps: { item: DataListItem }">
204
206
  <!--
205
207
  @slot Use it to add custom actions.