style: update code formatting

This commit is contained in:
Lars Rickert 2024-02-19 17:22:47 +01:00
parent 79c8078643
commit d5e7fdba05
17 changed files with 190 additions and 187 deletions

View File

@ -12,13 +12,10 @@ export const core: PresetProperty<'core'> = {
renderer: getAbsolutePath('@storybook/vue3'),
};
export const viteFinal: StorybookConfig['viteFinal'] = async (
config: Record<string, any>,
{ _ }: any
) => {
export const viteFinal: StorybookConfig['viteFinal'] = async (config) => {
const plugins: PluginOption[] = [];
// Add docgen plugin
// Add vue-component-meta plugin
plugins.push(await vueComponentMeta());
const { mergeConfig } = await import('vite');

View File

@ -1,11 +1,11 @@
import type { StoryObj, Meta } from '@storybook/vue3';
import type { Meta, StoryObj } from '@storybook/vue3';
import Component from './options-api/component';
const meta = {
component: Component,
tags: ['autodocs'],
} satisfies Meta<typeof Component>;
type Story = StoryObj<typeof meta>;
export default meta;

View File

@ -1,10 +1,11 @@
import type { StoryObj, Meta } from '@storybook/vue3';
import type { Meta, StoryObj } from '@storybook/vue3';
import Component from './reference-type-events/component.vue';
const meta = {
component: Component,
tags: ['autodocs'],
} satisfies Meta<typeof Component>;
type Story = StoryObj<typeof meta>;
export default meta;

View File

@ -1,10 +1,11 @@
import type { StoryObj, Meta } from '@storybook/vue3';
import type { Meta, StoryObj } from '@storybook/vue3';
import Component from './reference-type-exposed/component.vue';
const meta = {
component: Component,
tags: ['autodocs'],
} satisfies Meta<typeof Component>;
type Story = StoryObj<typeof meta>;
export default meta;

View File

@ -1,12 +1,14 @@
import type { StoryObj, Meta } from '@storybook/vue3';
import type { Meta, StoryObj } from '@storybook/vue3';
import Component from './reference-type-props/component.vue';
const meta = {
component: Component,
tags: ['autodocs'],
} satisfies Meta<typeof Component>;
type Story = StoryObj<typeof meta>;
export default meta;
enum MyEnum {
Small,
Medium,

View File

@ -1,11 +1,11 @@
import type { StoryObj, Meta } from '@storybook/vue3';
import type { Meta, StoryObj } from '@storybook/vue3';
import Component from './template-slots/component.vue';
const meta = {
component: Component,
tags: ['autodocs'],
} satisfies Meta<typeof Component>;
type Story = StoryObj<typeof meta>;
export default meta;

View File

@ -1,5 +1,4 @@
import type { Meta, StoryObj } from '@storybook/vue3';
import Component from './ts-component/component';
const meta = {
@ -10,4 +9,9 @@ const meta = {
type Story = StoryObj<typeof meta>;
export default meta;
export const Default: Story = { args: { foo: 'bar', bar: 20 } };
export const Default: Story = {
args: {
foo: 'bar',
bar: 20,
},
};

View File

@ -1,12 +1,17 @@
import type { StoryObj, Meta } from '@storybook/vue3';
import type { Meta, StoryObj } from '@storybook/vue3';
import { ComponentA } from './ts-named-export/component';
const meta = {
component: ComponentA,
tags: ['autodocs'],
} satisfies Meta<typeof ComponentA>;
type Story = StoryObj<typeof meta>;
export default meta;
export const Default: Story = { args: { size: 'large', backgroundColor: 'blue' } };
export const Default: Story = {
args: {
size: 'large',
backgroundColor: 'blue',
},
};

View File

@ -2,9 +2,9 @@
import { VNode } from 'vue';
export default {} as new () => {
$slots: {
default(_: { num: number; }): VNode[];
foo(_: { str: string; }): VNode[];
};
$slots: {
default(_: { num: number }): VNode[];
foo(_: { str: string }): VNode[];
};
};
</script>

View File

@ -1,7 +0,0 @@
<script setup lang="ts">
const internalProp = 42;
</script>
<template>
{{ internalProp }}
</template>

View File

@ -12,6 +12,7 @@ interface MyEvents {
const emit = defineEmits<MyEvents>();
</script>
<template>
<div>
foo:

View File

@ -1,22 +1,21 @@
<template>
<Pre>{{ JSON.stringify({ label, count }, null, 2) }} </Pre>
</template>
<script setup lang="ts">
import { ref } from 'vue';
const label = ref('Button')
const count = ref(100)
const label = ref('Button');
const count = ref(100);
defineExpose({
/**
* a label string
*/
label,
/**
* a count number
*/
count
/**
* a label string
*/
label,
/**
* a count number
*/
count,
});
</script>
</script>
<template>
<Pre>{{ JSON.stringify({ label, count }, null, 2) }} </Pre>
</template>

View File

@ -10,22 +10,22 @@ defineProps({
*/
foo: {
type: String,
required: true
required: true,
},
/**
* The bar property has default value
*/
bar: {
type: String,
default: 'BAR'
default: 'BAR',
},
/**
* The baz property is optional.
*/
baz: {
type: String
type: String,
},
/**
/**
* The xfoo property is required.
*/
xfoo: StringRequired,
@ -44,15 +44,15 @@ defineProps({
*/
hello: {
type: String,
default: 'Hello'
default: 'Hello',
},
numberOrStringProp: {
type: [Number, String],
default: 42
default: 42,
},
arrayProps: {
type: Array,
default: () => [42, 43, 44]
}
})
</script>
default: () => [42, 43, 44],
},
});
</script>

View File

@ -1,42 +1,43 @@
<script lang="ts">
import { defineComponent } from 'vue'
import { defineComponent } from 'vue';
import { StringEmpty, StringRequired, StringUndefined } from './my-props';
export default defineComponent({
props: {
/**
* foo description, required prop
* @required
*/
foo: {
type: String,
required: true
},
/**
* bar description, default value BAR
*/
bar: {
type: String,
default: 'BAR',
},
/**
* baz description, optional prop
*/
baz: {
type: String
},
/**
* xfoo description, required string prop
*/
xfoo: StringRequired,
/**
* xbar description, empty string prop
*/
xbar: StringEmpty,
xbaz: StringUndefined,
}
})
props: {
/**
* foo description, required prop
* @required
*/
foo: {
type: String,
required: true,
},
/**
* bar description, default value BAR
*/
bar: {
type: String,
default: 'BAR',
},
/**
* baz description, optional prop
*/
baz: {
type: String,
},
/**
* xfoo description, required string prop
*/
xfoo: StringRequired,
/**
* xbar description, empty string prop
*/
xbar: StringEmpty,
xbaz: StringUndefined,
},
});
</script>
<template>
<pre> {{ $props }}</pre>
<pre> {{ $props }}</pre>
</template>

View File

@ -1,109 +1,109 @@
<script setup lang="ts">
export interface MyNestedProps {
/**
* nested prop documentation
*/
nestedProp: string;
/**
* nested prop documentation
*/
nestedProp: string;
}
interface MyIgnoredNestedProps {
nestedProp: string;
nestedProp: string;
}
interface MyNestedRecursiveProps {
recursive: MyNestedRecursiveProps
recursive: MyNestedRecursiveProps;
}
enum MyEnum {
Small,
Medium,
Large,
Small,
Medium,
Large,
}
const categories = [
'Uncategorized',
'Content',
'Interaction',
'Display',
'Forms',
'Addons',
'Uncategorized',
'Content',
'Interaction',
'Display',
'Forms',
'Addons',
] as const;
type MyCategories = typeof categories[number];
type MyCategories = (typeof categories)[number];
interface MyProps {
/**
* string foo
*
* @default "rounded"
* @since v1.0.0
* @see https://vuejs.org/
* @deprecated v1.1.0
*/
foo: string,
/**
* description bar is optional number
*/
bar?: number,
/**
* description baz is required boolean
*/
baz: boolean,
/**
* description stringArray is string array
*/
stringArray?: string[],
/**
* description union is required union type
*/
union: string | number,
/**
* description unionOptional is optional union type
*/
unionOptional?: string | number | boolean,
/**
* description nested is required nested object
*/
nested: MyNestedProps,
/**
* description required nested object with intersection
*/
nestedIntersection: MyNestedProps & {
/**
* description required additional property
*/
additionalProp: string;
},
/**
* description optional nested object
*/
nestedOptional?: MyNestedProps | MyIgnoredNestedProps,
/**
* description required array object
*/
array: MyNestedProps[],
/**
* description optional array object
*/
arrayOptional?: MyNestedProps[],
/**
* description enum value
*/
enumValue: MyEnum,
/**
* description literal type alias that require context
*/
literalFromContext: MyCategories,
inlined: { foo: string; },
recursive?: MyNestedRecursiveProps
/**
* string foo
*
* @default "rounded"
* @since v1.0.0
* @see https://vuejs.org/
* @deprecated v1.1.0
*/
foo: string;
/**
* description bar is optional number
*/
bar?: number;
/**
* description baz is required boolean
*/
baz: boolean;
/**
* description stringArray is string array
*/
stringArray?: string[];
/**
* description union is required union type
*/
union: string | number;
/**
* description unionOptional is optional union type
*/
unionOptional?: string | number | boolean;
/**
* description nested is required nested object
*/
nested: MyNestedProps;
/**
* description required nested object with intersection
*/
nestedIntersection: MyNestedProps & {
/**
* description required additional property
*/
additionalProp: string;
};
/**
* description optional nested object
*/
nestedOptional?: MyNestedProps | MyIgnoredNestedProps;
/**
* description required array object
*/
array: MyNestedProps[];
/**
* description optional array object
*/
arrayOptional?: MyNestedProps[];
/**
* description enum value
*/
enumValue: MyEnum;
/**
* description literal type alias that require context
*/
literalFromContext: MyCategories;
inlined: { foo: string };
recursive?: MyNestedRecursiveProps;
}
withDefaults(defineProps<MyProps>(), {
bar: 1,
stringArray: () => ['foo', 'bar'],
bar: 1,
stringArray: () => ['foo', 'bar'],
});
</script>
<template>
<pre>{{ JSON.stringify($props, null, 2) }}</pre>
<pre>{{ JSON.stringify($props, null, 2) }}</pre>
</template>

View File

@ -1,6 +1,6 @@
<template>
<slot name="no-bind"></slot>
<slot :num="123"></slot>
<slot name="named-slot" str="str"></slot>
<slot name="vbind" v-bind="{ num: 123, str: 'str' }"></slot>
<slot name="no-bind"></slot>
<slot :num="123"></slot>
<slot name="named-slot" str="str"></slot>
<slot name="vbind" v-bind="{ num: 123, str: 'str' }"></slot>
</template>

View File

@ -1,12 +1,11 @@
<template>
<slot name="no-bind"></slot>
<br>
<slot :num="123"></slot>
<br>
<slot name="named" str="str"></slot>
<br>
<slot name="vbind" v-bind="{ num: 123, str: 'str' }"></slot>
</template>
<script setup lang="ts"></script>
<script setup lang="ts">
</script>
<template>
<slot name="no-bind"></slot>
<br />
<slot :num="123"></slot>
<br />
<slot name="named" str="str"></slot>
<br />
<slot name="vbind" v-bind="{ num: 123, str: 'str' }"></slot>
</template>