vueless 0.0.642 → 0.0.644

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": "0.0.642",
3
+ "version": "0.0.644",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
@@ -66,7 +66,7 @@
66
66
  "@vue/eslint-config-prettier": "^10.0.0",
67
67
  "@vue/eslint-config-typescript": "^14.1.1",
68
68
  "@vue/tsconfig": "^0.5.1",
69
- "@vueless/storybook": "^0.0.54",
69
+ "@vueless/storybook": "^0.0.57",
70
70
  "autoprefixer": "^10.4.19",
71
71
  "cssnano": "^6.1.2",
72
72
  "eslint": "^9.12.0",
@@ -10,7 +10,7 @@ interface UBoilerplateArgs extends Props {
10
10
  }
11
11
 
12
12
  export default {
13
- id: "10010",
13
+ id: "110010",
14
14
  title: "Custom / UBoilerplate",
15
15
  component: UBoilerplate,
16
16
  args: {
@@ -65,12 +65,12 @@ export interface UCalendarProps<TModelValue extends DateValue> {
65
65
  /**
66
66
  * Min date (JavaScript Date object or string formatted in given `dateFormat`).
67
67
  */
68
- minDate?: string | Date;
68
+ minDate?: Date | string;
69
69
 
70
70
  /**
71
71
  * Max date (JavaScript Date object or string formatted in given `dateFormat`).
72
72
  */
73
- maxDate?: string | Date;
73
+ maxDate?: Date | string;
74
74
 
75
75
  /**
76
76
  * Component config object.
@@ -305,10 +305,6 @@ watchEffect(() => {
305
305
  @slot Use it add something before the date.
306
306
  @binding {string} icon-name
307
307
  -->
308
- <slot name="left-icon" :icon-name="iconName" />
309
- </template>
310
-
311
- <template #right-icon="{ iconName }">
312
308
  <slot name="left" :icon-name="iconName" />
313
309
  </template>
314
310
 
@@ -81,12 +81,12 @@ export interface UDatePickerProps<TModelValue> {
81
81
  /**
82
82
  * Min date (JavaScript Date object or string formatted in given `dateFormat`).
83
83
  */
84
- minDate?: string | Date;
84
+ minDate?: Date | string;
85
85
 
86
86
  /**
87
87
  * Max date (JavaScript Date object or string formatted in given `dateFormat`).
88
88
  */
89
- maxDate?: string | Date;
89
+ maxDate?: Date | string;
90
90
 
91
91
  /**
92
92
  * Left icon name.
@@ -114,12 +114,12 @@ export interface UDatePickerRangeProps<TModelValue> {
114
114
  /**
115
115
  * Min date (JavaScript Date object or string formatted in given `dateFormat`).
116
116
  */
117
- minDate?: string | Date;
117
+ minDate?: Date | string;
118
118
 
119
119
  /**
120
120
  * Max date (JavaScript Date object or string formatted in given `dateFormat`).
121
121
  */
122
- maxDate?: string | Date;
122
+ maxDate?: Date | string;
123
123
 
124
124
  /**
125
125
  * Date string format.
@@ -1,9 +1,9 @@
1
1
  export default /*tw*/ {
2
2
  wrapper: {
3
- base: "flex gap-2 w-full",
3
+ base: "flex w-full",
4
4
  variants: {
5
5
  align: {
6
- top: "flex-col",
6
+ top: "flex-col gap-2",
7
7
  topInside: "flex-col gap-0 relative",
8
8
  topWithDesc: "flex-col-reverse w-fit",
9
9
  right: "flex-row w-fit",
@@ -14,14 +14,12 @@ export default /*tw*/ {
14
14
  },
15
15
  },
16
16
  compoundVariants: [
17
- { align: "left", size: "sm", class: "gap-2" },
18
- { align: "left", size: "md", class: "gap-3" },
19
- { align: "left", size: "lg", class: "gap-4" },
20
- { align: "right", size: "sm", class: "gap-2.5" },
21
- { align: "right", size: "md", class: "gap-3" },
22
- { align: "right", size: "lg", class: "gap-3.5" },
23
- { align: "left", centred: true, class: "items-center justify-end w-auto" },
24
- { align: "right", centred: true, class: "items-center justify-start w-auto" },
17
+ { align: ["left", "right"], size: "sm", class: "gap-2.5" },
18
+ { align: ["left", "right"], size: "md", class: "gap-3" },
19
+ { align: ["left", "right"], size: "lg", class: "gap-3.5" },
20
+ { align: ["left", "right"], centred: true, class: "items-center w-auto" },
21
+ { align: "left", centred: true, class: "justify-end" },
22
+ { align: "right", centred: true, class: "justify-start" },
25
23
  ],
26
24
  },
27
25
  content: "flex",
@@ -55,14 +53,10 @@ export default /*tw*/ {
55
53
  { align: "topWithDesc", size: "sm", class: "-mt-px" },
56
54
  { align: "topWithDesc", size: "md", class: "" },
57
55
  { align: "topWithDesc", size: "lg", class: "mt-px" },
58
- { align: "left", size: "sm", class: "-mt-px text-sm" },
59
- { align: "left", size: "md", class: "text-sm" },
60
- { align: "left", size: "lg", class: "mt-px text-base" },
61
- { align: "right", size: "sm", class: "-mt-px text-xs" },
62
- { align: "right", size: "md", class: "text-sm" },
63
- { align: "right", size: "lg", class: "mt-px text-base" },
64
- { align: "left", centred: false, class: "pt-1" },
65
- { align: "right", centred: false, class: "pt-1" },
56
+ { align: ["left", "right"], size: "sm", class: "-mt-px text-sm" },
57
+ { align: ["left", "right"], size: "md", class: "text-sm" },
58
+ { align: ["left", "right"], size: "lg", class: "mt-px text-base" },
59
+ { align: ["left", "right"], centred: false, class: "pt-1" },
66
60
  ],
67
61
  },
68
62
  description: {
@@ -63,7 +63,7 @@ const elementId = props.id || useId();
63
63
  const textareaRef = ref<HTMLTextAreaElement | null>(null);
64
64
  const labelComponentRef = ref<{ labelElement: HTMLElement | null } | null>(null);
65
65
  const leftSlotWrapperRef = ref<HTMLElement | null>(null);
66
- const textareaWrapperRef = ref<HTMLElement | null>(null);
66
+ const wrapperRef = ref<HTMLElement | null>(null);
67
67
 
68
68
  const currentRows = ref(Number(props.rows));
69
69
 
@@ -74,36 +74,43 @@ watch(
74
74
  },
75
75
  );
76
76
 
77
- function onEnter() {
78
- if (currentRows.value !== undefined) {
79
- currentRows.value++;
80
- }
81
- }
77
+ const localValue = computed({
78
+ get() {
79
+ return props.modelValue;
80
+ },
81
+ set(value) {
82
+ emit("update:modelValue", value);
83
+ },
84
+ });
82
85
 
83
- function onBackspace() {
86
+ onMounted(() => toggleReadonly(true));
87
+
88
+ function getNewRowCount() {
84
89
  const textarea = textareaRef.value;
85
90
 
86
- if (!textarea) return;
91
+ if (!textarea) return 0;
87
92
 
88
93
  const content = textarea.value;
89
94
  const newlineCount = (content.match(/\n/g) || []).length;
90
- const newRowCount = Math.max(Number(props.rows), newlineCount + 1);
91
95
 
92
- if (newRowCount < currentRows.value) {
96
+ return Math.max(Number(props.rows), newlineCount + 2);
97
+ }
98
+
99
+ function onEnter() {
100
+ const newRowCount = getNewRowCount();
101
+
102
+ if (newRowCount > currentRows.value) {
93
103
  currentRows.value = newRowCount;
94
104
  }
95
105
  }
96
106
 
97
- const localValue = computed({
98
- get() {
99
- return props.modelValue;
100
- },
101
- set(value) {
102
- emit("update:modelValue", value);
103
- },
104
- });
107
+ function onBackspace() {
108
+ const newRowCount = getNewRowCount() - 1;
105
109
 
106
- onMounted(() => toggleReadonly(true));
110
+ if (newRowCount < currentRows.value) {
111
+ currentRows.value = newRowCount;
112
+ }
113
+ }
107
114
 
108
115
  function onChange() {
109
116
  emit("change");
@@ -154,14 +161,10 @@ useMutationObserver(leftSlotWrapperRef, (mutations) => {
154
161
  function setLabelPosition() {
155
162
  if (props.labelAlign === "top" || !hasSlotContent(slots["left"])) return;
156
163
 
157
- if (
158
- leftSlotWrapperRef.value &&
159
- textareaWrapperRef.value &&
160
- labelComponentRef.value?.labelElement
161
- ) {
164
+ if (leftSlotWrapperRef.value && wrapperRef.value && labelComponentRef.value?.labelElement) {
162
165
  const leftSlotWidth = leftSlotWrapperRef.value.getBoundingClientRect().width;
163
166
 
164
- const textareaPaddingLeft = parseFloat(getComputedStyle(textareaWrapperRef.value).paddingLeft);
167
+ const textareaPaddingLeft = parseFloat(getComputedStyle(wrapperRef.value).paddingLeft);
165
168
 
166
169
  labelComponentRef.value.labelElement.style.left = `${leftSlotWidth + textareaPaddingLeft}px`;
167
170
  }
@@ -186,7 +189,7 @@ const mutatedProps = computed(() => ({
186
189
  label: Boolean(props.label),
187
190
  }));
188
191
 
189
- const { textareaAttrs, textareaLabelAttrs, textareaWrapperAttrs, leftSlotAttrs, rightSlotAttrs } =
192
+ const { textareaAttrs, textareaLabelAttrs, wrapperAttrs, leftSlotAttrs, rightSlotAttrs } =
190
193
  useUI<Config>(defaultConfig, mutatedProps);
191
194
  </script>
192
195
 
@@ -204,7 +207,7 @@ const { textareaAttrs, textareaLabelAttrs, textareaWrapperAttrs, leftSlotAttrs,
204
207
  v-bind="textareaLabelAttrs"
205
208
  :data-test="dataTest"
206
209
  >
207
- <label ref="textareaWrapperRef" :for="elementId" v-bind="textareaWrapperAttrs">
210
+ <label ref="wrapperRef" :for="elementId" v-bind="wrapperAttrs">
208
211
  <div
209
212
  v-if="hasSlotContent($slots['left'])"
210
213
  ref="leftSlotWrapperRef"
@@ -233,7 +236,7 @@ const { textareaAttrs, textareaLabelAttrs, textareaWrapperAttrs, leftSlotAttrs,
233
236
  @mousedown="onMousedown"
234
237
  @click="onClick"
235
238
  @keydown.enter="onEnter"
236
- @keydown.delete="onBackspace"
239
+ @keyup.delete="onBackspace"
237
240
  />
238
241
 
239
242
  <div v-if="hasSlotContent($slots['right'])" :for="elementId" v-bind="rightSlotAttrs">
@@ -2,9 +2,9 @@ export default /*tw*/ {
2
2
  textareaLabel: "{ULabel}",
3
3
  leftSlot: "flex items-center justify-center whitespace-nowrap pr-2.5 gap-1 rounded-dynamic rounded-r-none",
4
4
  rightSlot: "flex items-center justify-center whitespace-nowrap pl-2.5 gap-1 rounded-dynamic rounded-l-none",
5
- textareaWrapper: {
5
+ wrapper: {
6
6
  base: `
7
- flex px-3 py-2 bg-white transition w-full
7
+ flex bg-white transition w-full
8
8
  rounded-dynamic border border-gray-300 hover:border-gray-400 hover:focus-within:border-brand-500
9
9
  focus-within:border-brand-500 focus-within:ring-dynamic focus-within:ring-offset-dynamic
10
10
  focus-within:ring-brand-700/15 focus-within:outline-none
@@ -27,7 +27,7 @@ export default /*tw*/ {
27
27
  },
28
28
  textarea: {
29
29
  base: `
30
- p-0 block w-full bg-transparent border-none !leading-none font-normal text-gray-900
30
+ px-3 pt-2 pb-1.5 block w-full bg-transparent border-none font-normal text-gray-900
31
31
  placeholder:text-gray-400 placeholder:font-normal placeholder:leading-none
32
32
  focus:border-none focus:outline-none focus:ring-0 disabled:cursor-not-allowed
33
33
  `,
@@ -45,13 +45,13 @@ export default /*tw*/ {
45
45
  },
46
46
  },
47
47
  compoundVariants: [
48
- { labelAlign: "topInside", label: true, size: "sm", class: "pt-5" },
49
- { labelAlign: "topInside", label: true, size: "md", class: "pt-6" },
50
- { labelAlign: "topInside", label: true, size: "lg", class: "pt-7" },
48
+ { labelAlign: "topInside", label: true, size: "sm", class: "pt-[1.2rem]" },
49
+ { labelAlign: "topInside", label: true, size: "md", class: "pt-[1.4rem]" },
50
+ { labelAlign: "topInside", label: true, size: "lg", class: "pt-[1.6rem]" },
51
51
  ],
52
52
  },
53
53
  defaults: {
54
- rows: "3",
54
+ rows: "1",
55
55
  size: "md",
56
56
  inputmode: "text",
57
57
  labelAlign: "topInside",
@@ -55,7 +55,7 @@ function onClick(event: MouseEvent) {
55
55
  * Get element / nested component attributes for each config token ✨
56
56
  * Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
57
57
  */
58
- const { avatarAttrs, placeholderIconAttrs } = useUI<Config>(defaultConfig);
58
+ const { config, avatarAttrs, placeholderIconAttrs } = useUI<Config>(defaultConfig);
59
59
  </script>
60
60
 
61
61
  <template>
@@ -78,7 +78,7 @@ const { avatarAttrs, placeholderIconAttrs } = useUI<Config>(defaultConfig);
78
78
  internal
79
79
  :size="size"
80
80
  :color="componentColor"
81
- :name="placeholderIcon"
81
+ :name="placeholderIcon || config.defaults.placeholderIcon"
82
82
  v-bind="placeholderIconAttrs"
83
83
  />
84
84
  </slot>
@@ -24,6 +24,10 @@ export default /*tw*/ {
24
24
  { color: "grayscale", variant: "secondary", class: "text-gray-900 border-gray-900" },
25
25
  { color: "grayscale", variant: "thirdary", class: "text-gray-900 bg-gray-50" },
26
26
  { color: "grayscale", variant: "thirdary", bordered: true, class: "border-gray-200" },
27
+ { color: "gray", variant: "primary", class: "bg-gray-500" },
28
+ { color: "gray", variant: "secondary", class: "text-gray-500 border-gray-500" },
29
+ { color: "gray", variant: "thirdary", class: "text-gray-500 bg-gray-50" },
30
+ { color: "gray", variant: "thirdary", bordered: true, class: "border-gray-500" },
27
31
  ],
28
32
  },
29
33
  body: "flex items-start justify-between",
@@ -1,6 +1,7 @@
1
1
  import path from "path";
2
2
  import { statSync, existsSync } from "fs";
3
3
  import { readdir } from "node:fs/promises";
4
+ import { cwd } from "node:process";
4
5
  import esbuild from "esbuild";
5
6
 
6
7
  import { VUELESS_CONFIGS_CACHED_DIR } from "../../constants.js";
@@ -52,27 +53,27 @@ export async function getDirFiles(dirPath, ext, { recursive = true, exclude = []
52
53
 
53
54
  export function getNuxtFiles() {
54
55
  return [
55
- path.join(process.cwd(), "composables"),
56
- path.join(process.cwd(), "components"),
57
- path.join(process.cwd(), "layouts"),
58
- path.join(process.cwd(), "pages"),
59
- path.join(process.cwd(), "plugins"),
60
- path.join(process.cwd(), "utils"),
61
- path.join(process.cwd(), "Error.vue"),
62
- path.join(process.cwd(), "App.vue"),
63
- path.join(process.cwd(), "Error.vue"),
64
- path.join(process.cwd(), "app.vue"),
65
- path.join(process.cwd(), "error.vue"),
66
- path.join(process.cwd(), "playground", "app.vue"),
56
+ path.join(cwd(), "composables"),
57
+ path.join(cwd(), "components"),
58
+ path.join(cwd(), "layouts"),
59
+ path.join(cwd(), "pages"),
60
+ path.join(cwd(), "plugins"),
61
+ path.join(cwd(), "utils"),
62
+ path.join(cwd(), "Error.vue"),
63
+ path.join(cwd(), "App.vue"),
64
+ path.join(cwd(), "Error.vue"),
65
+ path.join(cwd(), "app.vue"),
66
+ path.join(cwd(), "error.vue"),
67
+ path.join(cwd(), "playground", "app.vue"),
67
68
  ];
68
69
  }
69
70
 
70
71
  export function getVueFiles() {
71
- return [path.join(process.cwd(), "src")];
72
+ return [path.join(cwd(), "src")];
72
73
  }
73
74
 
74
75
  export async function getComponentDefaultConfig(name, entryPath) {
75
- const configOutPath = path.join(process.cwd(), `${VUELESS_CONFIGS_CACHED_DIR}/${name}.mjs`);
76
+ const configOutPath = path.join(cwd(), `${VUELESS_CONFIGS_CACHED_DIR}/${name}.mjs`);
76
77
 
77
78
  await buildTSFile(entryPath, configOutPath);
78
79
 
@@ -7,8 +7,9 @@
7
7
  /* eslint-disable no-console */
8
8
  import fs from "node:fs";
9
9
  import path from "node:path";
10
- import { createRequire } from "module";
10
+ import { cwd } from "node:process";
11
11
  import { rm, cp } from "node:fs/promises";
12
+ import { createRequire } from "module";
12
13
  import { merge } from "lodash-es";
13
14
 
14
15
  import { vuelessConfig } from "./vuelessConfig.js";
@@ -25,11 +26,9 @@ import {
25
26
  ICONS_DIR,
26
27
  } from "../../constants.js";
27
28
 
28
- const cwd = process.cwd();
29
-
30
- const DEFAULT_ICONS_DIR = path.join(cwd, VUELESS_ICONS_DIR);
31
- const DEFAULT_ICONS_LOCAL_DIR = path.join(cwd, VUELESS_ICONS_LOCAL_DIR);
32
- const CACHED_ICONS_DIR = path.join(cwd, VUELESS_ICONS_CACHED_DIR);
29
+ const DEFAULT_ICONS_DIR = path.join(cwd(), VUELESS_ICONS_DIR);
30
+ const DEFAULT_ICONS_LOCAL_DIR = path.join(cwd(), VUELESS_ICONS_LOCAL_DIR);
31
+ const CACHED_ICONS_DIR = path.join(cwd(), VUELESS_ICONS_CACHED_DIR);
33
32
  const U_ICON = "UIcon";
34
33
 
35
34
  let isDebug = false;
@@ -53,8 +52,8 @@ export async function cacheIcons({ mode, env, debug, targetFiles = [] } = {}) {
53
52
 
54
53
  if (isVuelessIconsMode) {
55
54
  targetFiles = isVuelessEnv
56
- ? [path.join(cwd, VUELESS_LOCAL_DIR)]
57
- : [path.join(cwd, VUELESS_DIR)];
55
+ ? [path.join(cwd(), VUELESS_LOCAL_DIR)]
56
+ : [path.join(cwd(), VUELESS_DIR)];
58
57
  }
59
58
 
60
59
  const commonExcludes = ["/types.ts", "/constants.ts"];
@@ -93,7 +92,7 @@ export async function removeIconsCache(mirrorCacheDir, debug) {
93
92
  }
94
93
 
95
94
  if (mirrorCacheDir) {
96
- const mirrorCacheIconsPath = path.join(cwd, mirrorCacheDir, ICONS_DIR);
95
+ const mirrorCacheIconsPath = path.join(cwd(), mirrorCacheDir, ICONS_DIR);
97
96
 
98
97
  if (fs.existsSync(mirrorCacheIconsPath)) {
99
98
  await rm(mirrorCacheIconsPath, { recursive: true, force: true });
@@ -112,10 +111,10 @@ export async function removeIconsCache(mirrorCacheDir, debug) {
112
111
  * @returns {Promise<void>}
113
112
  */
114
113
  export async function copyIconsCache(mirrorCacheDir, debug) {
115
- const cachePath = path.join(cwd, VUELESS_ICONS_CACHED_DIR);
114
+ const cachePath = path.join(cwd(), VUELESS_ICONS_CACHED_DIR);
116
115
 
117
116
  if (mirrorCacheDir && fs.existsSync(cachePath)) {
118
- await cp(cachePath, path.join(cwd, mirrorCacheDir, ICONS_DIR), { recursive: true });
117
+ await cp(cachePath, path.join(cwd(), mirrorCacheDir, ICONS_DIR), { recursive: true });
119
118
  }
120
119
 
121
120
  if (debug) {
@@ -275,23 +274,23 @@ function getIconLibraryPaths(name, defaults) {
275
274
  const libraries = {
276
275
  [VUELESS_LIBRARY]: {
277
276
  // @material-symbols icons which used across the components (this works only at Vueless env).
278
- source: `${cwd}/node_modules/${library}/svg-${weight}/${style}/${name}.svg`,
277
+ source: `${cwd()}/node_modules/${library}/svg-${weight}/${style}/${name}.svg`,
279
278
  destination: `${CACHED_ICONS_DIR}/${VUELESS_LIBRARY}/${name}.svg`
280
279
  },
281
280
  "@material-symbols": {
282
- source: `${cwd}/node_modules/${library}/svg-${weight}/${style}/${name}.svg`,
281
+ source: `${cwd()}/node_modules/${library}/svg-${weight}/${style}/${name}.svg`,
283
282
  destination: `${CACHED_ICONS_DIR}/${library}/svg-${weight}/${style}/${name}.svg`
284
283
  },
285
284
  "bootstrap-icons": {
286
- source: `${cwd}/node_modules/${library}/icons/${name}.svg`,
285
+ source: `${cwd()}/node_modules/${library}/icons/${name}.svg`,
287
286
  destination: `${CACHED_ICONS_DIR}/${library}/${name}.svg`
288
287
  },
289
288
  "heroicons": {
290
- source: `${cwd}/node_modules/${library}/24/${name.endsWith("-fill") ? "solid" : "outline"}/${name}.svg`,
289
+ source: `${cwd()}/node_modules/${library}/24/${name.endsWith("-fill") ? "solid" : "outline"}/${name}.svg`,
291
290
  destination: `${CACHED_ICONS_DIR}/${library}/${name.endsWith("-fill") ? "solid" : "outline"}/${name}.svg`
292
291
  },
293
292
  "custom-icons": {
294
- source: `${cwd}/${customLibraryPath}/${name}.svg`,
293
+ source: `${cwd()}/${customLibraryPath}/${name}.svg`,
295
294
  destination: `${CACHED_ICONS_DIR}/${library}/${name}.svg`
296
295
  },
297
296
  };
@@ -308,7 +307,7 @@ function getIconLibraryPaths(name, defaults) {
308
307
  */
309
308
  async function getDefaults() {
310
309
  const defaultIconsDir = isVuelessEnv ? VUELESS_LOCAL_DIR : VUELESS_DIR;
311
- const defaultConfigPath = path.join(cwd, defaultIconsDir, COMPONENTS[U_ICON], "config.ts");
310
+ const defaultConfigPath = path.join(cwd(), defaultIconsDir, COMPONENTS[U_ICON], "config.ts");
312
311
  const uIconDefaultConfig = await getComponentDefaultConfig(U_ICON, defaultConfigPath);
313
312
 
314
313
  return merge({}, uIconDefaultConfig?.defaults, vuelessConfig?.component?.[U_ICON]?.defaults);
@@ -1,9 +1,9 @@
1
1
  import path from "node:path";
2
- import { merge, cloneDeep } from "lodash-es";
2
+ import { cwd } from "node:process";
3
3
  import { existsSync } from "node:fs";
4
4
  import { readFile } from "node:fs/promises";
5
+ import { merge, cloneDeep, isEqual } from "lodash-es";
5
6
  import { extendTailwindMerge } from "tailwind-merge";
6
- import { isEqual } from "lodash-es";
7
7
  import { defineConfig } from "cva";
8
8
 
9
9
  import { vuelessConfig } from "./vuelessConfig.js";
@@ -24,7 +24,6 @@ import {
24
24
  TAILWIND_VARIANT_DELIMITER_REG_EXP,
25
25
  } from "../../constants.js";
26
26
 
27
- const cwd = process.cwd();
28
27
  const twMerge = extendTailwindMerge(merge(TAILWIND_MERGE_EXTENSION, vuelessConfig.tailwindMerge));
29
28
 
30
29
  export const { cx } = defineConfig({
@@ -188,7 +187,7 @@ async function retrieveComponentDefaultConfig(componentName, vuelessConfigFiles)
188
187
  );
189
188
 
190
189
  return componentDefaultConfigPath
191
- ? await getComponentDefaultConfig(componentName, path.join(cwd, componentDefaultConfigPath))
190
+ ? await getComponentDefaultConfig(componentName, path.join(cwd(), componentDefaultConfigPath))
192
191
  : {};
193
192
  }
194
193
 
@@ -1,5 +1,6 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
+ import { cwd } from "node:process";
3
4
 
4
5
  import { buildTSFile } from "./helper.js";
5
6
  import { VUELESS_CACHE_DIR, VUELESS_CONFIG_FILE_NAME } from "../../constants.js";
@@ -11,12 +12,9 @@ import { VUELESS_CACHE_DIR, VUELESS_CONFIG_FILE_NAME } from "../../constants.js"
11
12
  export let vuelessConfig = {};
12
13
 
13
14
  (async () => {
14
- const configPathJs = path.join(process.cwd(), `${VUELESS_CONFIG_FILE_NAME}.js`);
15
- const configPathTs = path.join(process.cwd(), `${VUELESS_CONFIG_FILE_NAME}.ts`);
16
- const configOutPath = path.join(
17
- process.cwd(),
18
- `${VUELESS_CACHE_DIR}/${VUELESS_CONFIG_FILE_NAME}.mjs`,
19
- );
15
+ const configPathJs = path.join(cwd(), `${VUELESS_CONFIG_FILE_NAME}.js`);
16
+ const configPathTs = path.join(cwd(), `${VUELESS_CONFIG_FILE_NAME}.ts`);
17
+ const configOutPath = path.join(cwd(), `${VUELESS_CACHE_DIR}/${VUELESS_CONFIG_FILE_NAME}.mjs`);
20
18
 
21
19
  if (!fs.existsSync(configPathJs) && !fs.existsSync(configPathTs)) {
22
20
  vuelessConfig = {};
@@ -91,19 +91,20 @@ export function getArgTypes(componentName: string | undefined) {
91
91
  component.attributes?.forEach((attribute: Attribute) => {
92
92
  const type = attribute.value.type;
93
93
 
94
- if (type.includes("|")) {
94
+ if (attribute.enum) {
95
95
  types[attribute.name] = {
96
- control: type.split("|")[0].toLowerCase() as ArgType["control"],
96
+ options: attribute.enum,
97
+ control: "select",
97
98
  table: {
98
99
  defaultValue: { summary: attribute.default || "" },
100
+ type: { summary: attribute.enum.join(" | ") },
99
101
  },
100
102
  };
101
103
  }
102
104
 
103
- if (attribute.enum) {
105
+ if (attribute.enum?.length === 1) {
104
106
  types[attribute.name] = {
105
- options: attribute.enum,
106
- control: "select",
107
+ control: "object",
107
108
  table: {
108
109
  defaultValue: { summary: attribute.default || "" },
109
110
  type: { summary: attribute.enum.join(" | ") },
@@ -111,17 +112,36 @@ export function getArgTypes(componentName: string | undefined) {
111
112
  };
112
113
  }
113
114
 
114
- if (attribute.enum?.length === 1) {
115
+ const nonUnionTypes = [
116
+ "string",
117
+ "number",
118
+ "boolean",
119
+ "Date",
120
+ "UnknownObject",
121
+ "UnknownArray",
122
+ "Array",
123
+ ];
124
+
125
+ if (attribute.enum?.every((value) => nonUnionTypes.includes(value))) {
126
+ let control = attribute.enum[0];
127
+
128
+ if (control === "string") {
129
+ control = "text";
130
+ }
131
+
132
+ if (control === "Date") {
133
+ control = "date";
134
+ }
135
+
115
136
  types[attribute.name] = {
116
- control: "object",
137
+ control: control as ArgType["control"],
117
138
  table: {
118
139
  defaultValue: { summary: attribute.default || "" },
119
- type: { summary: attribute.enum.join(" | ") },
120
140
  },
121
141
  };
122
142
  }
123
143
 
124
- if (type === "string" || type.includes("string")) {
144
+ if (type === "string") {
125
145
  types[attribute.name] = {
126
146
  control: "text",
127
147
  table: {
@@ -139,14 +159,11 @@ export function getArgTypes(componentName: string | undefined) {
139
159
  };
140
160
  }
141
161
 
142
- if (type === "Date" || attribute.enum?.includes("Date")) {
162
+ if (type === "Date") {
143
163
  types[attribute.name] = {
144
164
  control: "date",
145
165
  table: {
146
166
  defaultValue: { summary: attribute.default || "" },
147
- type: {
148
- summary: ["Date", "string"].join(" | "),
149
- },
150
167
  },
151
168
  };
152
169
  }