vanilla-vue-ui 0.0.1 → 0.0.2

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.
Files changed (29) hide show
  1. package/basic/app-bar/WAppBar.stories.ts +41 -0
  2. package/basic/app-bar/WAppBar.vue +48 -0
  3. package/basic/banner/BannerStore.ts +54 -0
  4. package/basic/banner/WBanner.stories.ts +28 -0
  5. package/basic/banner/WBanner.vue +41 -0
  6. package/basic/breadcrumb/WBreadcrumb.stories.ts +25 -0
  7. package/basic/breadcrumb/WBreadcrumb.vue +97 -0
  8. package/basic/button/WButton.stories.ts +10 -3
  9. package/basic/button/WButton.vue +3 -3
  10. package/basic/icon/WIcon.vue +5 -0
  11. package/basic/range/WRange.vue +113 -17
  12. package/basic/text-field/TextFieldSize.ts +2 -0
  13. package/basic/text-field/WTextField.stories.ts +88 -0
  14. package/basic/text-field/WTextField.vue +188 -0
  15. package/package.json +1 -1
  16. package/template/footer-simple/WFooterSimple.stories.ts +23 -0
  17. package/template/footer-simple/WFooterSimple.vue +20 -0
  18. package/template/navigation-drawer/NavigationDrawer.stories.ts +59 -0
  19. package/template/navigation-drawer/NavigationDrawer.vue +121 -0
  20. package/template/navigation-drawer/NavigationDrawerContent.ts +11 -0
  21. package/template/primary-button/WPrimaryButton.spec.ts +17 -0
  22. package/template/primary-button/WPrimaryButton.stories.ts +30 -0
  23. package/template/primary-button/WPrimaryButton.vue +9 -0
  24. package/template/secondary-button/WSecondaryButton.spec.ts +17 -0
  25. package/template/secondary-button/WSecondaryButton.stories.ts +30 -0
  26. package/template/secondary-button/WSecondaryButton.vue +9 -0
  27. package/template/tree-menu/TreeMenuContent.ts +11 -0
  28. package/template/tree-menu/WTreeMenu.stories.ts +55 -0
  29. package/template/tree-menu/WTreeMenu.vue +152 -0
@@ -0,0 +1,188 @@
1
+ <template>
2
+ <div
3
+ :class="[
4
+ mergedClasses.outline?.base,
5
+ mergedClasses.outline?.backgroundColor,
6
+ ]"
7
+ >
8
+ <label :for="name" :class="mergedClasses.label?.base">{{ label }}</label>
9
+ <div class="relative flex">
10
+ <div class="flex-1">
11
+ <input
12
+ :id="id"
13
+ :name="name"
14
+ :value="value"
15
+ :placeholder="placeholder"
16
+ :required="required"
17
+ :autocomplete="autocomplete"
18
+ :class="[
19
+ textSize,
20
+ mergedClasses.content?.input?.base,
21
+ mergedClasses.content?.input?.backgroundColor,
22
+ mergedClasses.content?.input?.color,
23
+ ]"
24
+ :type="type"
25
+ @change="changeValue($event)"
26
+ @input="inputValue($event)"
27
+ >
28
+ </div>
29
+
30
+ <div class="flex-shrink-0">
31
+ <slot name="trailing" />
32
+ </div>
33
+ </div>
34
+ </div>
35
+ <p v-if="errorMassage.length > 0" :class="mergedClasses.errorMessage?.base">{{ errorMassage }}</p>
36
+ </template>
37
+
38
+ <script setup lang="ts">
39
+ import { ref, defineProps, type PropType, defineExpose } from 'vue'
40
+ import type { ClassObject } from '../../types/ClassObject';
41
+ import { deepMergeClassObject } from '../../util';
42
+ // @ts-ignore
43
+ import type { TextFieldSize } from './TextFieldSize'
44
+
45
+ const props = defineProps({
46
+ value: {
47
+ type: String as PropType<string>
48
+ },
49
+ label: {
50
+ type: String as PropType<string>
51
+ },
52
+ placeholder: {
53
+ type: String as PropType<string>
54
+ },
55
+ type: {
56
+ type: String as PropType<string>
57
+ },
58
+ autocomplete: {
59
+ type: String as PropType<string>
60
+ },
61
+ required: {
62
+ type: Boolean as PropType<boolean>
63
+ },
64
+ rules: {
65
+ type: Array as PropType<ValidationRule[]>
66
+ },
67
+ size: {
68
+ type: String as PropType<TextFieldSize>,
69
+ default: 'base',
70
+ },
71
+ name: {
72
+ type: String as PropType<string>
73
+ },
74
+ id: {
75
+ type: String as PropType<string>
76
+ },
77
+ classes: {
78
+ type: Object as PropType<ClassObject>,
79
+ }
80
+ });
81
+
82
+
83
+ const defaultClasses: ClassObject = {
84
+ content: {
85
+ input: {
86
+ base: "block w-full border-0 p-0 placeholder:text-gray-400 sm:leading-6 focus:outline-none focus:ring-0",
87
+ backgroundColor: 'bg-surface dark:bg-surface-dark',
88
+ color: 'text-onSurface dark:text-onSurface-dark'
89
+ },
90
+ },
91
+ outline: {
92
+ base: "rounded-md px-3 pb-1.5 pt-2.5 shadow-sm ring-1 ring-inset ring-gray-300 focus-within:ring-2 focus-within:ring-primary dark:focus-within:ring-primary-dark",
93
+ backgroundColor: 'bg-surface dark:bg-surface-dark',
94
+ },
95
+ label: {
96
+ base: "block text-xs font-medium text-onSurface dark:text-onSurface-dark"
97
+ },
98
+ errorMessage: {
99
+ base: "mt-1 ml-1 text-sm text-red-600"
100
+ }
101
+ }
102
+
103
+ // props.classesが渡されていない場合、defaultClassesを使用する
104
+ const mergedClasses = props.classes ? deepMergeClassObject(defaultClasses, props.classes) : defaultClasses;
105
+
106
+
107
+ const textSize = ref('text-' + props.size)
108
+
109
+ // emit を定義
110
+ const emit = defineEmits<{
111
+ input: [value: Event],
112
+ change: [value: Event]
113
+ }>()
114
+
115
+ const errorMassage = ref("")
116
+
117
+ type ValidationRule = (value: string) => boolean | string
118
+
119
+ //
120
+ // Sample
121
+ //
122
+ // let rules: ValidationRule[] = [
123
+ // value => !!value || 'Required.', // required
124
+ // value => value.length <= 20 || 'Max 20 characters', // max
125
+ // value => {
126
+ // const pattern = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
127
+ // return pattern.test(value) || 'Invalid e-mail.'
128
+ // }, // email
129
+ // ]
130
+
131
+ // 初回バリデーション
132
+ // undefined じゃなかったら
133
+ if (typeof props.value === "string") {
134
+ const setupErrorMessage = validate(props.value)
135
+ if (setupErrorMessage) {
136
+ errorMassage.value = setupErrorMessage as string
137
+ }
138
+ }
139
+
140
+ // input の変更を受け取る
141
+ function changeValue(event: Event) {
142
+ const target = event.target as HTMLInputElement | null
143
+ if (target) {
144
+ const validationResult = validate(target.value)
145
+ if (validationResult === true) {
146
+ // バリデーションに通ったら
147
+ emit('change', event)
148
+ errorMassage.value = ""; // エラーメッセージをクリア
149
+ } else {
150
+ errorMassage.value = validationResult as string; // エラーメッセージを設定
151
+ }
152
+ }
153
+ }
154
+
155
+ function inputValue(event: Event) {
156
+ const target = event.target as HTMLInputElement | null
157
+ if (target) {
158
+ const validationResult = validate(target.value)
159
+ if (validationResult === true) {
160
+ // バリデーションに通ったら
161
+ errorMassage.value = ""; // エラーメッセージをクリア
162
+ } else {
163
+ errorMassage.value = validationResult as string; // エラーメッセージを設定
164
+ }
165
+ }
166
+
167
+ emit('input', event)
168
+ }
169
+
170
+ // バリデーション
171
+ function validate(value: string): boolean | string {
172
+ if (props.rules) {
173
+ for (const rule of props.rules) {
174
+ const result = rule(value);
175
+ if (result !== true) {
176
+ // ルールが文字列(エラーメッセージ)を返した場合、バリデーション失敗
177
+ return result;
178
+ }
179
+ }
180
+ }
181
+ return true; // ルールが設定されてない or すべてのルールが成功
182
+ }
183
+
184
+ // 外部からも呼び出せるようにする
185
+ defineExpose({
186
+ validate
187
+ });
188
+ </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vanilla-vue-ui",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "files": [
@@ -0,0 +1,23 @@
1
+ // Replace vue3 with vue if you are using Storybook for Vue 2
2
+ import type { Meta, StoryObj } from '@storybook/vue3';
3
+
4
+ import FooterSimple from './WFooterSimple.vue';
5
+
6
+ const meta: Meta<typeof FooterSimple> = {
7
+ component: FooterSimple,
8
+ };
9
+
10
+ export default meta;
11
+ type Story = StoryObj<typeof FooterSimple>;
12
+
13
+ /*
14
+ *👇 Render functions are a framework specific feature to allow you control on how the component renders.
15
+ * See https://storybook.js.org/docs/api/csf
16
+ * to learn how to use render functions.
17
+ */
18
+ export const Primary: Story = {
19
+ render: () => ({
20
+ components: { FooterSimple },
21
+ template: '<FooterSimple></FooterSimple>',
22
+ }),
23
+ };
@@ -0,0 +1,20 @@
1
+ <template>
2
+ <footer class="fixed bottom-0">
3
+ <div class="mb-4 ml-4">
4
+ <p class="text-center text-xs leading-5 text-gray-500">{{ props.text }}</p>
5
+ </div>
6
+ </footer>
7
+ </template>
8
+
9
+ <script setup lang="ts">
10
+ import { defineProps, type PropType } from 'vue'
11
+
12
+ const props = defineProps({
13
+ text: {
14
+ type: String as PropType<string>,
15
+ required: false,
16
+ default: `© 2020 Your Company, Inc. All rights reserved.`
17
+ }
18
+ })
19
+
20
+ </script>
@@ -0,0 +1,59 @@
1
+ // Replace vue3 with vue if you are using Storybook for Vue 2
2
+ import type { Meta, StoryObj } from '@storybook/vue3';
3
+ import NavigationDrawer from './NavigationDrawer.vue';
4
+ import {
5
+ HomeIcon,
6
+ BellAlertIcon,
7
+ ChatBubbleBottomCenterTextIcon,
8
+ Cog6ToothIcon,
9
+ CurrencyYenIcon,
10
+ CubeIcon,
11
+ BookOpenIcon,
12
+ MinusIcon
13
+ } from '@heroicons/vue/24/outline'
14
+
15
+ type NavigationDrawerProps = InstanceType<typeof NavigationDrawer>['$props']
16
+
17
+ const meta: Meta<typeof NavigationDrawer> = {
18
+ component: NavigationDrawer,
19
+ };
20
+
21
+ export default meta;
22
+ type Story = StoryObj<typeof NavigationDrawer>;
23
+
24
+ /*
25
+ *👇 Render functions are a framework specific feature to allow you control on how the component renders.
26
+ * See https://storybook.js.org/docs/api/csf
27
+ * to learn how to use render functions.
28
+ */
29
+ export const Primary: Story = {
30
+ render: (args: NavigationDrawerProps) => ({
31
+ setup() {
32
+ return {
33
+ ...args
34
+ }
35
+ },
36
+ components: { NavigationDrawer },
37
+ template: '<NavigationDrawer :title="title" :navigationTop="navigationTop" :navigationBottom="navigationBottom"></NavigationDrawer>',
38
+ }),
39
+ args: {
40
+ title: 'ダッシュボード',
41
+ navigationTop: [
42
+ { name: 'メニュー', href: '/menu', onClick: undefined, icon: HomeIcon, current: false },
43
+ { name: 'リクエスト', href: '/request', icon: CubeIcon, current: false },
44
+ { name: '履歴', href: '/history', icon: BookOpenIcon, current: false },
45
+ { name: '支払い', href: '/payment', icon: CurrencyYenIcon, current: false, isOpen: true,
46
+ subItems: [
47
+ { name: '現金', href: '/payment', icon: MinusIcon, current: false },
48
+ { name: 'クレジット', href: '/payment', icon: MinusIcon, current: false }
49
+ ]
50
+ },
51
+ { name: 'メッセージ', href: '/message', icon: BellAlertIcon, current: false },
52
+ { name: '問い合わせ', href: '/contact', icon: ChatBubbleBottomCenterTextIcon, current: false },
53
+ { name: '設定', href: '/setting', icon: Cog6ToothIcon, current: false },
54
+ ],
55
+ navigationBottom: [
56
+ { name: 'ログアウト', href: undefined, onClick: () => console.log('click.'), icon: undefined, current: undefined },
57
+ ]
58
+ }
59
+ };
@@ -0,0 +1,121 @@
1
+ <template>
2
+ <div>
3
+ <TransitionRoot as="template" :show="sidebarOpen">
4
+ <Dialog as="div" class="relative z-50 lg:hidden" @close="sidebarOpen = false">
5
+ <TransitionChild as="template" enter="transition-opacity ease-linear duration-300" enter-from="opacity-0" enter-to="opacity-100" leave="transition-opacity ease-linear duration-300" leave-from="opacity-100" leave-to="opacity-0">
6
+ <div class="fixed inset-0 bg-gray-900/80" />
7
+ </TransitionChild>
8
+
9
+ <div class="fixed inset-0 flex">
10
+ <TransitionChild as="template" enter="transition ease-in-out duration-300 transform" enter-from="-translate-x-full" enter-to="translate-x-0" leave="transition ease-in-out duration-300 transform" leave-from="translate-x-0" leave-to="-translate-x-full">
11
+ <DialogPanel class="relative mr-16 flex w-full max-w-xs flex-1">
12
+ <TransitionChild as="template" enter="ease-in-out duration-300" enter-from="opacity-0" enter-to="opacity-100" leave="ease-in-out duration-300" leave-from="opacity-100" leave-to="opacity-0">
13
+ <div class="absolute left-full top-0 flex w-16 justify-center pt-5">
14
+ <button type="button" class="-m-2.5 p-2.5" @click="sidebarOpen = false">
15
+ <span class="sr-only">Close sidebar</span>
16
+ <XMarkIcon class="h-6 w-6 text-white" aria-hidden="true" />
17
+ </button>
18
+ </div>
19
+ </TransitionChild>
20
+ <div class="flex grow flex-col gap-y-5 overflow-y-auto bg-surface dark:bg-surface-dark px-6 pb-2">
21
+ <div class="flex h-4 shrink-0 items-center"/>
22
+ <nav class="flex flex-1 flex-col">
23
+ <ul role="list" class="flex flex-1 flex-col gap-y-7">
24
+ <li>
25
+ <ul role="list" class="-mx-2 space-y-1">
26
+ <TreeMenu :navigation-items="navigationTop"/>
27
+ </ul>
28
+ </li>
29
+
30
+ <li class="-mx-6 mt-auto px-6 py-2">
31
+ <ul role="list" class="-mx-2 space-y-1">
32
+ <TreeMenu :navigation-items="navigationBottom"/>
33
+ </ul>
34
+ </li>
35
+
36
+ </ul>
37
+ </nav>
38
+ </div>
39
+ </DialogPanel>
40
+ </TransitionChild>
41
+ </div>
42
+ </Dialog>
43
+ </TransitionRoot>
44
+
45
+ <!-- Static sidebar for desktop -->
46
+ <div class="hidden lg:fixed lg:inset-y-0 lg:z-50 lg:flex lg:w-72 lg:flex-col">
47
+ <!-- Sidebar component, swap this element with another sidebar if you like -->
48
+ <div class="flex grow flex-col gap-y-5 overflow-y-auto border-r border-outline dark:border-outline-dark bg-surface dark:bg-surface-dark px-6">
49
+ <div class="flex h-4 shrink-0 items-center">
50
+ <!-- <img class="h-8 w-auto" src="https://tailwindui.com/img/logos/mark.svg?color=indigo&shade=600" alt="Your Company" /> -->
51
+ </div>
52
+ <nav class="flex flex-1 flex-col">
53
+ <ul role="list" class="flex flex-1 flex-col gap-y-7">
54
+ <li>
55
+ <ul role="list" class="-mx-2 space-y-1">
56
+ <TreeMenu :navigation-items="navigationTop"/>
57
+ </ul>
58
+ </li>
59
+
60
+
61
+ <li class="-mx-6 mt-auto p-6 px-2">
62
+ <ul role="list" class="mx-2 space-y-1">
63
+ <TreeMenu :navigation-items="navigationBottom"/>
64
+ </ul>
65
+ </li>
66
+ </ul>
67
+ </nav>
68
+ </div>
69
+ </div>
70
+
71
+ <AppBar class="" :title="title" @open="sidebarOpen = true"/>
72
+
73
+ <main class="lg:pl-72">
74
+ <div class="">
75
+ <!-- Your content -->
76
+ <slot />
77
+ </div>
78
+ </main>
79
+ </div>
80
+ </template>
81
+
82
+ <script setup lang="ts">
83
+ import type { NavigationDrawerContent } from './NavigationDrawerContent'
84
+ import { ref, watch, type PropType } from 'vue'
85
+ import { useRoute } from 'vue-router'
86
+ import { Dialog, DialogPanel, TransitionChild, TransitionRoot } from '@headlessui/vue'
87
+ import { XMarkIcon } from '@heroicons/vue/24/outline'
88
+ import TreeMenu from '../tree-menu/WTreeMenu.vue'
89
+ import AppBar from '../../basic/app-bar/WAppBar.vue'
90
+
91
+ const props = defineProps({
92
+ title: {
93
+ type: String as PropType<string>,
94
+ default: "Dashboard"
95
+ },
96
+ navigationTop: {
97
+ type: Array as PropType<NavigationDrawerContent[]>,
98
+ required: true
99
+ },
100
+ navigationBottom: {
101
+ type: Array as PropType<NavigationDrawerContent[]>,
102
+ required: true
103
+ }
104
+ })
105
+
106
+ const navigationTop = ref(props.navigationTop)
107
+ const navigationBottom = ref(props.navigationBottom)
108
+
109
+ const sidebarOpen = ref(false)
110
+
111
+ const route = useRoute()
112
+
113
+ watch(route, (newRoute) => {
114
+ // current、isOpen を設定
115
+ navigationTop.value.forEach(item => {
116
+ item.current = item.href === newRoute.path;
117
+ // current だったら sub を表示させる
118
+ item.isOpen = true
119
+ });
120
+ }, { immediate: true });
121
+ </script>
@@ -0,0 +1,11 @@
1
+ import type { Component } from 'vue'
2
+
3
+ export type NavigationDrawerContent = {
4
+ name: string
5
+ href?: string
6
+ onClick?: () => void
7
+ icon?: Component
8
+ current?: boolean
9
+ subItems?: NavigationDrawerContent[]
10
+ isOpen?: boolean
11
+ }
@@ -0,0 +1,17 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import PrimaryButton from './WPrimaryButton.vue'; // コンポーネントのパスを適切に設定してください
4
+
5
+ describe('PrimaryButton', () => {
6
+ it('renders correctly', () => {
7
+ const wrapper = mount(PrimaryButton, {
8
+ slots: {
9
+ default: 'Click Me'
10
+ }
11
+ });
12
+
13
+ expect(wrapper.html()).toContain('Click Me');
14
+ expect(wrapper.classes()).toContain('bg-gradient-to-r');
15
+ expect(wrapper.classes()).toContain('from-primary');
16
+ });
17
+ });
@@ -0,0 +1,30 @@
1
+ // Replace vue3 with vue if you are using Storybook for Vue 2
2
+ import type { Meta, StoryObj } from '@storybook/vue3';
3
+
4
+ import Button from './WPrimaryButton.vue';
5
+
6
+ const meta: Meta<typeof Button> = {
7
+ component: Button,
8
+ };
9
+
10
+ export default meta;
11
+ type Story = StoryObj<typeof Button>;
12
+
13
+ /*
14
+ *👇 Render functions are a framework specific feature to allow you control on how the component renders.
15
+ * See https://storybook.js.org/docs/api/csf
16
+ * to learn how to use render functions.
17
+ */
18
+ export const Primary: Story = {
19
+ render: () => ({
20
+ components: { Button },
21
+ template: '<Button>OK</Button>',
22
+ }),
23
+ };
24
+
25
+ export const Block: Story = {
26
+ render: () => ({
27
+ components: { Button },
28
+ template: '<Button block>OK</Button>',
29
+ }),
30
+ };
@@ -0,0 +1,9 @@
1
+ <template>
2
+ <Button class="bg-gradient-to-r from-primary dark:from-primary-dark via-primaryVia dark:via-primaryVia-dark to-primaryTo dark:to-primaryTo-dark text-white font-bold">
3
+ <slot></slot>
4
+ </Button>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import Button from '../../basic/button/WButton.vue'
9
+ </script>
@@ -0,0 +1,17 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import WSecondaryButton from './WSecondaryButton.vue'; // コンポーネントのパスを適切に設定してください
4
+
5
+ describe('SecondaryButton', () => {
6
+ it('renders correctly', () => {
7
+ const wrapper = mount(WSecondaryButton, {
8
+ slots: {
9
+ default: 'Click Me'
10
+ }
11
+ });
12
+
13
+ expect(wrapper.html()).toContain('Click Me');
14
+ expect(wrapper.classes()).toContain('bg-gradient-to-r');
15
+ expect(wrapper.classes()).toContain('from-primary');
16
+ });
17
+ });
@@ -0,0 +1,30 @@
1
+ // Replace vue3 with vue if you are using Storybook for Vue 2
2
+ import type { Meta, StoryObj } from '@storybook/vue3';
3
+
4
+ import Button from './WSecondaryButton.vue';
5
+
6
+ const meta: Meta<typeof Button> = {
7
+ component: Button,
8
+ };
9
+
10
+ export default meta;
11
+ type Story = StoryObj<typeof Button>;
12
+
13
+ /*
14
+ *👇 Render functions are a framework specific feature to allow you control on how the component renders.
15
+ * See https://storybook.js.org/docs/api/csf
16
+ * to learn how to use render functions.
17
+ */
18
+ export const Primary: Story = {
19
+ render: () => ({
20
+ components: { Button },
21
+ template: '<Button>OK</Button>',
22
+ }),
23
+ };
24
+
25
+ export const Block: Story = {
26
+ render: () => ({
27
+ components: { Button },
28
+ template: '<Button block>OK</Button>',
29
+ }),
30
+ };
@@ -0,0 +1,9 @@
1
+ <template>
2
+ <Button>
3
+ <slot />
4
+ </Button>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import Button from '../../basic/button/WButton.vue'
9
+ </script>
@@ -0,0 +1,11 @@
1
+ import type { Component } from 'vue'
2
+
3
+ export type TreeMenuContent = {
4
+ name: string
5
+ href?: string
6
+ onClick?: () => void
7
+ icon?: Component
8
+ current?: boolean
9
+ subItems?: TreeMenuContent[]
10
+ isOpen?: boolean
11
+ }
@@ -0,0 +1,55 @@
1
+ // Replace vue3 with vue if you are using Storybook for Vue 2
2
+ import type { Meta, StoryObj } from '@storybook/vue3';
3
+ import WTreeMenu from './WTreeMenu.vue';
4
+ import {
5
+ HomeIcon,
6
+ BellAlertIcon,
7
+ ChatBubbleBottomCenterTextIcon,
8
+ Cog6ToothIcon,
9
+ CurrencyYenIcon,
10
+ CubeIcon,
11
+ BookOpenIcon,
12
+ MinusIcon
13
+ } from '@heroicons/vue/24/outline'
14
+
15
+ type WTreeMenuProps = InstanceType<typeof WTreeMenu>['$props']
16
+
17
+ const meta: Meta<typeof WTreeMenu> = {
18
+ component: WTreeMenu,
19
+ };
20
+
21
+ export default meta;
22
+ type Story = StoryObj<typeof WTreeMenu>;
23
+
24
+ /*
25
+ *👇 Render functions are a framework specific feature to allow you control on how the component renders.
26
+ * See https://storybook.js.org/docs/api/csf
27
+ * to learn how to use render functions.
28
+ */
29
+ export const Primary: Story = {
30
+ render: (args: WTreeMenuProps) => ({
31
+ setup() {
32
+ return {
33
+ ...args
34
+ }
35
+ },
36
+ components: { WTreeMenu },
37
+ template: '<WTreeMenu :navigationItems="navigationItems"></WTreeMenu>',
38
+ }),
39
+ args: {
40
+ navigationItems: [
41
+ { name: 'メニュー', href: '/menu', onClick: undefined, icon: HomeIcon, current: false },
42
+ { name: 'リクエスト', href: '/request', icon: CubeIcon, current: false },
43
+ { name: '履歴', href: '/history', icon: BookOpenIcon, current: false },
44
+ { name: '支払い', href: '/payment', icon: CurrencyYenIcon, current: false, isOpen: true,
45
+ subItems: [
46
+ { name: '現金', href: '/payment', icon: MinusIcon, current: false },
47
+ { name: 'クレジット', href: '/payment', icon: MinusIcon, current: false }
48
+ ]
49
+ },
50
+ { name: 'メッセージ', href: '/message', icon: BellAlertIcon, current: false },
51
+ { name: '問い合わせ', href: '/contact', icon: ChatBubbleBottomCenterTextIcon, current: false },
52
+ { name: '設定', href: '/setting', icon: Cog6ToothIcon, current: false },
53
+ ]
54
+ }
55
+ };