vueless 0.0.643 → 0.0.645
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 +2 -2
- package/ui.boilerplate/storybook/{stories_.ts → stories.ts} +1 -1
- package/ui.container-page/UPage.vue +1 -1
- package/ui.container-page/config.ts +18 -16
- package/ui.container-page/types.ts +4 -4
- package/ui.form-calendar/types.ts +2 -2
- package/ui.form-date-picker/UDatePicker.vue +0 -4
- package/ui.form-date-picker/types.ts +2 -2
- package/ui.form-date-picker-range/types.ts +2 -2
- package/ui.form-textarea/config.ts +1 -1
- package/ui.image-avatar/UAvatar.vue +2 -2
- package/utils/node/helper.js +15 -14
- package/utils/node/loaderIcon.js +16 -17
- package/utils/node/tailwindSafelist.js +3 -4
- package/utils/node/vuelessConfig.js +4 -6
- package/utils/storybook.ts +30 -13
- /package/ui.boilerplate/storybook/{docs_.mdx → docs.mdx} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vueless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.645",
|
|
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.
|
|
69
|
+
"@vueless/storybook": "^0.0.57",
|
|
70
70
|
"autoprefixer": "^10.4.19",
|
|
71
71
|
"cssnano": "^6.1.2",
|
|
72
72
|
"eslint": "^9.12.0",
|
|
@@ -157,7 +157,7 @@ const {
|
|
|
157
157
|
<slot name="footer-after" />
|
|
158
158
|
</div>
|
|
159
159
|
|
|
160
|
-
<div v-if="
|
|
160
|
+
<div v-if="!isMobileBreakpoint" v-bind="rightRoundingWrapperAttrs">
|
|
161
161
|
<div v-bind="rightRoundingAttrs" />
|
|
162
162
|
</div>
|
|
163
163
|
</div>
|
|
@@ -15,25 +15,20 @@ export default /*tw*/ {
|
|
|
15
15
|
"5xl": "md:w-[75rem] md:max-[1300px]:!w-full",
|
|
16
16
|
wide: "md:w-full",
|
|
17
17
|
},
|
|
18
|
-
fixedRounding: {
|
|
19
|
-
true: "relative pr-0 md:pr-4 md:rounded-none",
|
|
20
|
-
false: "md:rounded-r-2xl",
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
page: {
|
|
25
|
-
base: "p-4 md:py-6 md:pl-8 mx-auto min-h-screen w-full",
|
|
26
|
-
variants: {
|
|
27
18
|
gray: {
|
|
28
19
|
false: "bg-white",
|
|
29
20
|
true: "bg-gray-50",
|
|
30
21
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
rounding: {
|
|
23
|
+
relative: "md:relative md:pr-4 md:rounded-r-dynamic-lg",
|
|
24
|
+
fixed: "md:bg-transparent md:relative md:pr-4 md:rounded-r-dynamic-lg",
|
|
34
25
|
},
|
|
35
26
|
},
|
|
36
27
|
},
|
|
28
|
+
page: {
|
|
29
|
+
base: "p-4 md:py-6 md:pl-8 md:pr-8 mx-auto min-h-screen w-full",
|
|
30
|
+
compoundVariants: [{ rounding: ["fixed", "relative"], class: "md:pr-4" }],
|
|
31
|
+
},
|
|
37
32
|
header: "flex items-start justify-between mb-4 md:mb-6",
|
|
38
33
|
headerLeft: "flex items-center gap-4",
|
|
39
34
|
headerLeftFallback: "flex flex-col gap-0.5",
|
|
@@ -43,12 +38,19 @@ export default /*tw*/ {
|
|
|
43
38
|
description: "mt-1.5 text-base font-normal text-gray-500",
|
|
44
39
|
headerRight: "",
|
|
45
40
|
body: "",
|
|
46
|
-
footer:
|
|
41
|
+
footer: "mb-0 mt-14 justify-between pt-8 md:flex md:items-baseline space-y-4 md:space-y-0 border-t border-gray-200",
|
|
47
42
|
footerLeft: "md:flex space-y-4 md:space-x-4 md:space-y-0",
|
|
48
43
|
footerRight: "md:flex space-y-4 md:space-x-4 md:space-y-0",
|
|
49
|
-
rightRoundingWrapper:
|
|
44
|
+
rightRoundingWrapper: {
|
|
45
|
+
base: "absolute right-4",
|
|
46
|
+
variants: {
|
|
47
|
+
rounding: {
|
|
48
|
+
none: "hidden",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
50
52
|
rightRounding: {
|
|
51
|
-
base: "fixed top-0 w-4 rounded-r-
|
|
53
|
+
base: "fixed top-0 w-4 rounded-r-dynamic-lg h-screen",
|
|
52
54
|
variants: {
|
|
53
55
|
gray: {
|
|
54
56
|
false: "bg-white",
|
|
@@ -57,10 +59,10 @@ export default /*tw*/ {
|
|
|
57
59
|
},
|
|
58
60
|
},
|
|
59
61
|
defaults: {
|
|
62
|
+
rounding: "none",
|
|
60
63
|
titleSize: "md",
|
|
61
64
|
size: "wide",
|
|
62
65
|
gray: false,
|
|
63
|
-
fixedRounding: false,
|
|
64
66
|
/* icons */
|
|
65
67
|
backIcon: "arrow_back",
|
|
66
68
|
},
|
|
@@ -37,14 +37,14 @@ export interface Props {
|
|
|
37
37
|
backLabel?: string;
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Show rounding block on the right side of the component.
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
rounding?: "none" | "fixed" | "relative";
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* Sets background light gray (useful if the page contains nested cards).
|
|
46
46
|
*/
|
|
47
|
-
|
|
47
|
+
gray?: boolean;
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Component config object.
|
|
@@ -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?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
122
|
+
maxDate?: Date | string;
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* Date string format.
|
|
@@ -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>
|
package/utils/node/helper.js
CHANGED
|
@@ -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(
|
|
56
|
-
path.join(
|
|
57
|
-
path.join(
|
|
58
|
-
path.join(
|
|
59
|
-
path.join(
|
|
60
|
-
path.join(
|
|
61
|
-
path.join(
|
|
62
|
-
path.join(
|
|
63
|
-
path.join(
|
|
64
|
-
path.join(
|
|
65
|
-
path.join(
|
|
66
|
-
path.join(
|
|
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(
|
|
72
|
+
return [path.join(cwd(), "src")];
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
export async function getComponentDefaultConfig(name, entryPath) {
|
|
75
|
-
const configOutPath = path.join(
|
|
76
|
+
const configOutPath = path.join(cwd(), `${VUELESS_CONFIGS_CACHED_DIR}/${name}.mjs`);
|
|
76
77
|
|
|
77
78
|
await buildTSFile(entryPath, configOutPath);
|
|
78
79
|
|
package/utils/node/loaderIcon.js
CHANGED
|
@@ -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 {
|
|
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
|
|
29
|
-
|
|
30
|
-
const
|
|
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 {
|
|
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(
|
|
15
|
-
const configPathTs = path.join(
|
|
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 = {};
|
package/utils/storybook.ts
CHANGED
|
@@ -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 (
|
|
94
|
+
if (attribute.enum) {
|
|
95
95
|
types[attribute.name] = {
|
|
96
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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: "
|
|
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"
|
|
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"
|
|
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
|
}
|
|
File without changes
|