@naptics/vue-collection 0.2.14 → 0.3.0

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 (170) hide show
  1. package/.github/workflows/build.yml +26 -0
  2. package/.github/workflows/deploy-demo.yml +46 -0
  3. package/.github/workflows/deploy-lib.yml +65 -0
  4. package/.gitlab-ci.yml +57 -0
  5. package/.nvmrc +1 -0
  6. package/.prettierrc +8 -0
  7. package/.vscode/extensions.json +10 -0
  8. package/.vscode/launch.json +23 -0
  9. package/.vscode/settings.json +13 -0
  10. package/babel.config.json +3 -0
  11. package/components/NAlert.d.ts +1 -44
  12. package/components/NBadge.d.ts +1 -133
  13. package/components/NBreadcrub.d.ts +2 -106
  14. package/components/NBreadcrub.js +1 -1
  15. package/components/NButton.d.ts +2 -118
  16. package/components/NCheckbox.d.ts +1 -32
  17. package/components/NCheckboxLabel.d.ts +1 -45
  18. package/components/NCheckboxLabel.js +1 -1
  19. package/components/NCrudModal.d.ts +9 -221
  20. package/components/NCrudModal.js +1 -1
  21. package/components/NDialog.d.ts +1 -110
  22. package/components/NDialog.js +1 -1
  23. package/components/NDropdown.d.ts +1 -69
  24. package/components/NDropdown.js +1 -1
  25. package/components/NDropzone.d.ts +1 -115
  26. package/components/NDropzone.js +1 -1
  27. package/components/NForm.d.ts +1 -23
  28. package/components/NFormModal.d.ts +9 -127
  29. package/components/NIconButton.d.ts +3 -159
  30. package/components/NIconButton.js +1 -1
  31. package/components/NIconCircle.d.ts +1 -87
  32. package/components/NInput.d.ts +1 -164
  33. package/components/NInput.js +1 -1
  34. package/components/NInputPhone.d.ts +2 -114
  35. package/components/NInputPhone.js +1 -1
  36. package/components/NInputSelect.d.ts +2 -187
  37. package/components/NInputSelect.js +1 -1
  38. package/components/NInputSuggestion.d.ts +2 -155
  39. package/components/NInputSuggestion.js +1 -1
  40. package/components/NLink.d.ts +1 -70
  41. package/components/NList.d.ts +1 -43
  42. package/components/NList.js +1 -1
  43. package/components/NLoadingIndicator.d.ts +1 -49
  44. package/components/NModal.d.ts +15 -227
  45. package/components/NModal.js +16 -2
  46. package/components/NPagination.d.ts +1 -63
  47. package/components/NSearchbar.d.ts +1 -56
  48. package/components/NSearchbarList.d.ts +3 -63
  49. package/components/NSearchbarList.js +1 -1
  50. package/components/NSelect.d.ts +2 -148
  51. package/components/NSelect.js +1 -1
  52. package/components/NSuggestionList.d.ts +3 -126
  53. package/components/NSuggestionList.js +5 -2
  54. package/components/NTable.d.ts +1 -85
  55. package/components/NTable.js +12 -6
  56. package/components/NTableAction.d.ts +2 -46
  57. package/components/NTableAction.js +1 -1
  58. package/components/NTextArea.d.ts +2 -181
  59. package/components/NTextArea.js +1 -1
  60. package/components/NTooltip.d.ts +1 -105
  61. package/components/NTooltip.js +1 -1
  62. package/components/NValInput.d.ts +7 -182
  63. package/components/NValInput.js +1 -1
  64. package/env.d.ts +15 -0
  65. package/eslint.config.cjs +29 -0
  66. package/index.html +13 -0
  67. package/package.json +21 -19
  68. package/postcss.config.js +6 -0
  69. package/public/favicon.ico +0 -0
  70. package/scripts/build-lib.sh +52 -0
  71. package/scripts/sync-node-types.js +70 -0
  72. package/src/demo/App.css +9 -0
  73. package/src/demo/App.tsx +5 -0
  74. package/src/demo/components/ColorGrid.tsx +26 -0
  75. package/src/demo/components/ComponentGrid.tsx +26 -0
  76. package/src/demo/components/ComponentSection.tsx +30 -0
  77. package/src/demo/components/VariantSection.tsx +18 -0
  78. package/src/demo/i18n/de.ts +7 -0
  79. package/src/demo/i18n/en.ts +7 -0
  80. package/src/demo/i18n/index.ts +24 -0
  81. package/src/demo/main.ts +13 -0
  82. package/src/demo/router/index.ts +21 -0
  83. package/src/demo/views/HomeView.tsx +94 -0
  84. package/src/demo/views/NavigationView.tsx +43 -0
  85. package/src/demo/views/presentation/AlertView.tsx +40 -0
  86. package/src/demo/views/presentation/BadgeView.tsx +61 -0
  87. package/src/demo/views/presentation/BreadcrumbView.tsx +52 -0
  88. package/src/demo/views/presentation/ButtonView.tsx +49 -0
  89. package/src/demo/views/presentation/CheckboxView.tsx +59 -0
  90. package/src/demo/views/presentation/DropdownView.tsx +59 -0
  91. package/src/demo/views/presentation/DropzoneView.tsx +39 -0
  92. package/src/demo/views/presentation/IconButtonView.tsx +47 -0
  93. package/src/demo/views/presentation/IconCircleView.tsx +38 -0
  94. package/src/demo/views/presentation/InputView.tsx +179 -0
  95. package/src/demo/views/presentation/LinkView.tsx +50 -0
  96. package/src/demo/views/presentation/ListView.tsx +29 -0
  97. package/src/demo/views/presentation/LoadingIndicatorView.tsx +38 -0
  98. package/src/demo/views/presentation/ModalView.tsx +210 -0
  99. package/src/demo/views/presentation/PaginationView.tsx +25 -0
  100. package/src/demo/views/presentation/SearchbarView.tsx +80 -0
  101. package/src/demo/views/presentation/TableView.tsx +146 -0
  102. package/src/demo/views/presentation/TooltipView.tsx +86 -0
  103. package/src/lib/components/NAlert.tsx +85 -0
  104. package/src/lib/components/NBadge.tsx +75 -0
  105. package/src/lib/components/NBreadcrub.tsx +97 -0
  106. package/src/lib/components/NButton.tsx +80 -0
  107. package/src/lib/components/NCheckbox.tsx +55 -0
  108. package/src/lib/components/NCheckboxLabel.tsx +51 -0
  109. package/src/lib/components/NCrudModal.tsx +133 -0
  110. package/src/lib/components/NDialog.tsx +182 -0
  111. package/src/lib/components/NDropdown.tsx +167 -0
  112. package/src/lib/components/NDropzone.tsx +265 -0
  113. package/src/lib/components/NForm.tsx +32 -0
  114. package/src/lib/components/NFormModal.tsx +66 -0
  115. package/src/lib/components/NIconButton.tsx +92 -0
  116. package/src/lib/components/NIconCircle.tsx +78 -0
  117. package/src/lib/components/NInput.css +11 -0
  118. package/src/lib/components/NInput.tsx +139 -0
  119. package/src/lib/components/NInputPhone.tsx +53 -0
  120. package/src/lib/components/NInputSelect.tsx +126 -0
  121. package/src/lib/components/NInputSuggestion.tsx +80 -0
  122. package/src/lib/components/NLink.tsx +68 -0
  123. package/src/lib/components/NList.tsx +67 -0
  124. package/src/lib/components/NLoadingIndicator.css +46 -0
  125. package/src/lib/components/NLoadingIndicator.tsx +63 -0
  126. package/src/lib/components/NModal.tsx +243 -0
  127. package/src/lib/components/NPagination.css +15 -0
  128. package/src/lib/components/NPagination.tsx +131 -0
  129. package/src/lib/components/NSearchbar.tsx +78 -0
  130. package/src/lib/components/NSearchbarList.tsx +47 -0
  131. package/src/lib/components/NSelect.tsx +128 -0
  132. package/src/lib/components/NSuggestionList.tsx +216 -0
  133. package/src/lib/components/NTable.css +3 -0
  134. package/src/lib/components/NTable.tsx +247 -0
  135. package/src/lib/components/NTableAction.tsx +49 -0
  136. package/src/lib/components/NTextArea.tsx +159 -0
  137. package/src/lib/components/NTooltip.css +37 -0
  138. package/src/lib/components/NTooltip.tsx +250 -0
  139. package/src/lib/components/NValInput.tsx +163 -0
  140. package/src/lib/components/ValidatedForm.ts +71 -0
  141. package/src/lib/components/__tests__/NButton.spec.tsx +26 -0
  142. package/src/lib/components/__tests__/NCheckbox.spec.tsx +39 -0
  143. package/src/lib/i18n/de/vue-collection.json +58 -0
  144. package/src/lib/i18n/en/vue-collection.json +58 -0
  145. package/src/lib/i18n/index.ts +54 -0
  146. package/src/lib/index.ts +2 -0
  147. package/src/lib/jsx.d.ts +13 -0
  148. package/src/lib/utils/__tests__/identifiable.spec.ts +72 -0
  149. package/src/lib/utils/__tests__/validation.spec.ts +92 -0
  150. package/src/lib/utils/breakpoints.ts +47 -0
  151. package/src/lib/utils/component.tsx +131 -0
  152. package/src/lib/utils/deferred.ts +28 -0
  153. package/src/lib/utils/identifiable.ts +87 -0
  154. package/src/lib/utils/stringMaxLength.ts +25 -0
  155. package/src/lib/utils/tailwind.ts +41 -0
  156. package/src/lib/utils/utils.ts +90 -0
  157. package/src/lib/utils/vModel.ts +260 -0
  158. package/src/lib/utils/validation.ts +189 -0
  159. package/src/lib/utils/vue.ts +25 -0
  160. package/tailwind.config.js +38 -0
  161. package/tsconfig.config.json +9 -0
  162. package/tsconfig.demo.json +19 -0
  163. package/tsconfig.json +16 -0
  164. package/tsconfig.lib.json +18 -0
  165. package/tsconfig.vitest.json +8 -0
  166. package/utils/breakpoints.d.ts +1 -1
  167. package/utils/component.d.ts +3 -7
  168. package/utils/component.js +5 -2
  169. package/utils/identifiable.js +5 -1
  170. package/vite.config.ts +28 -0
@@ -0,0 +1,29 @@
1
+ import type { ListItem } from '@/lib/components/NList'
2
+ import NList from '@/lib/components/NList'
3
+ import ComponentSection from '@/demo/components/ComponentSection'
4
+ import VariantSection from '@/demo/components/VariantSection'
5
+ import { createView } from '@/lib/utils/component'
6
+
7
+ export default createView('ListView', () => {
8
+ const items: ListItem[] = [
9
+ { title: 'Name', text: 'Michael Scott' },
10
+ { title: 'Profession', text: 'Nerd' },
11
+ { title: 'Title', text: 'Dr. phil.' },
12
+ {
13
+ title: () => <span class="font-extrabold">Date Of Birth</span>,
14
+ text: () => <span class="text-primary-500">14.10.1982</span>,
15
+ },
16
+ ]
17
+
18
+ return () => (
19
+ <ComponentSection
20
+ title="List"
21
+ subtitle="A component to display key-value information in a simple and neat way."
22
+ id="lists"
23
+ >
24
+ <VariantSection title="Display Information">
25
+ <NList items={items} />
26
+ </VariantSection>
27
+ </ComponentSection>
28
+ )
29
+ })
@@ -0,0 +1,38 @@
1
+ import NLoadingIndicator from '@/lib/components/NLoadingIndicator'
2
+ import ComponentGrid from '@/demo/components/ComponentGrid'
3
+ import ComponentSection from '@/demo/components/ComponentSection'
4
+ import VariantSection from '@/demo/components/VariantSection'
5
+ import { createView } from '@/lib/utils/component'
6
+
7
+ export default createView('NLoadingIndicator', () => {
8
+ const sizes = [4, 6, 8, 10, 12, 14]
9
+
10
+ return () => (
11
+ <ComponentSection
12
+ title="Loading Indicator"
13
+ subtitle="A loading indicator which helps to keep the user patient."
14
+ id="loading-indicators"
15
+ >
16
+ <VariantSection title="Different colors and shades">
17
+ <ComponentGrid>
18
+ <NLoadingIndicator shade={700} />
19
+ <NLoadingIndicator shade={400} />
20
+ <NLoadingIndicator shade={100} />
21
+ <NLoadingIndicator color="secondary" shade={100} />
22
+ <NLoadingIndicator color="secondary" shade={400} />
23
+ <NLoadingIndicator color="secondary" shade={700} />
24
+ </ComponentGrid>
25
+ </VariantSection>
26
+
27
+ <VariantSection title="Different sizes">
28
+ <ComponentGrid>
29
+ {sizes.map(size => (
30
+ <div class="flex items-center">
31
+ <NLoadingIndicator size={size} />
32
+ </div>
33
+ ))}
34
+ </ComponentGrid>
35
+ </VariantSection>
36
+ </ComponentSection>
37
+ )
38
+ })
@@ -0,0 +1,210 @@
1
+ import { createView } from '@/lib/utils/component'
2
+ import { vModelForRef } from '@/lib/utils/vModel'
3
+ import {
4
+ ArrowDownIcon,
5
+ ArrowDownRightIcon,
6
+ ArrowDownLeftIcon,
7
+ ArrowLeftIcon,
8
+ ArrowRightIcon,
9
+ ArrowUpIcon,
10
+ ArrowUpLeftIcon,
11
+ ArrowUpRightIcon,
12
+ NoSymbolIcon,
13
+ SunIcon,
14
+ } from '@heroicons/vue/24/solid'
15
+ import { ref } from 'vue'
16
+ import NButton from '@/lib/components/NButton'
17
+ import NModal from '@/lib/components/NModal'
18
+ import ComponentGrid from '@/demo/components/ComponentGrid'
19
+ import ComponentSection from '@/demo/components/ComponentSection'
20
+ import VariantSection from '@/demo/components/VariantSection'
21
+ import NIconButton from '@/lib/components/NIconButton'
22
+ import NFormModal from '@/lib/components/NFormModal'
23
+ import { createValidatedForm } from '@/lib/components/ValidatedForm'
24
+ import NValInput from '@/lib/components/NValInput'
25
+ import { email } from '@/lib/utils/validation'
26
+ import NCrudModal from '@/lib/components/NCrudModal'
27
+ import NDialog, { type NDialogExposed } from '@/lib/components/NDialog'
28
+
29
+ export default createView('ModalView', () => {
30
+ const refs = Array.from({ length: 14 }, () => ref(false))
31
+ const dialogRefs = Array.from({ length: 5 }, () => ref<NDialogExposed>())
32
+ const inputRefs = Array.from({ length: 4 }, () => ref(''))
33
+
34
+ function openModal(n: number) {
35
+ return () => (refs[n].value = true)
36
+ }
37
+
38
+ function openDialog(n: number) {
39
+ return () => dialogRefs[n].value?.show().then(result => console.log(`Dialog result: ${result}`))
40
+ }
41
+
42
+ function vModel(n: number) {
43
+ return vModelForRef(refs[n])
44
+ }
45
+
46
+ const form1 = createValidatedForm()
47
+ const form2 = createValidatedForm()
48
+
49
+ return () => (
50
+ <>
51
+ <ComponentSection
52
+ title="Modals and Dialogs"
53
+ subtitle="Useful components which come to the foreground to interact with the user."
54
+ id="modals"
55
+ >
56
+ <VariantSection
57
+ title="Basic Modals"
58
+ subtitle="Basic Modals offer a lot of configuration possibilities. The title, texts and colors of buttons as well as all actions can be configured. If this is not enough, the header, footer or the whole modal can be replaced with a custom slot."
59
+ >
60
+ <ComponentGrid cols={4}>
61
+ <NButton onClick={openModal(0)}> Basic Modal </NButton>
62
+ <NButton color="secondary" onClick={openModal(1)}>
63
+ Custom Header
64
+ </NButton>
65
+ <NButton color="blue" onClick={openModal(2)}>
66
+ Custom Footer
67
+ </NButton>
68
+ <NButton color="red" onClick={openModal(3)}>
69
+ Custom Modal
70
+ </NButton>
71
+ </ComponentGrid>
72
+ </VariantSection>
73
+
74
+ <VariantSection
75
+ title="Advanced Modals"
76
+ subtitle="The Advanced Modals provide utility to deal with forms. The Form Modal automatically checks the integrated form before closing. The Crud Modal adds an intergrated delete button with a dialog."
77
+ >
78
+ <ComponentGrid cols={4}>
79
+ <NButton onClick={openModal(4)}> Form Modal </NButton>
80
+ <NButton color="secondary" onClick={openModal(5)}>
81
+ Crud Modal
82
+ </NButton>
83
+ </ComponentGrid>
84
+ </VariantSection>
85
+
86
+ <VariantSection
87
+ title="Dialogs"
88
+ subtitle="Dialogs can be used to prompt the user with a yes/no - decision or to interrupt them with important information."
89
+ >
90
+ <ComponentGrid cols={4}>
91
+ <NButton color="red" onClick={openDialog(3)}>
92
+ Danger Dialog
93
+ </NButton>
94
+ <NButton color="red" onClick={openDialog(4)}>
95
+ Remove Dialog
96
+ </NButton>
97
+ <NButton color="yellow" onClick={openDialog(2)}>
98
+ Warning Dialog
99
+ </NButton>
100
+ <NButton color="blue" onClick={openDialog(1)}>
101
+ Info Dialog
102
+ </NButton>
103
+ <NButton color="green" onClick={openDialog(0)}>
104
+ Success Dialog
105
+ </NButton>
106
+ </ComponentGrid>
107
+ </VariantSection>
108
+
109
+ <VariantSection title="Positioning" subtitle="Modals can be positioned vertically and horizontally.">
110
+ <ComponentGrid cols={8}>
111
+ <NIconButton icon={ArrowUpLeftIcon} onClick={openModal(6)} />
112
+ <NIconButton icon={ArrowUpIcon} onClick={openModal(7)} />
113
+ <NIconButton icon={ArrowUpRightIcon} onClick={openModal(8)} />
114
+ <NIconButton icon={ArrowRightIcon} onClick={openModal(9)} />
115
+ <NIconButton icon={ArrowDownRightIcon} onClick={openModal(10)} />
116
+ <NIconButton icon={ArrowDownIcon} onClick={openModal(11)} />
117
+ <NIconButton icon={ArrowDownLeftIcon} onClick={openModal(12)} />
118
+ <NIconButton icon={ArrowLeftIcon} onClick={openModal(13)} />
119
+ </ComponentGrid>
120
+ </VariantSection>
121
+ </ComponentSection>
122
+
123
+ {/* Basic Modal */}
124
+ <NModal {...vModel(0)} title="Basic Modal" cancelText="Bye Modal" okText="Ok Modal">
125
+ This is a pretty basic modal. Nothing fancy.
126
+ </NModal>
127
+
128
+ {/* Custom Header */}
129
+ <NModal {...vModel(1)} okColor="yellow" header={() => <SunIcon class="text-yellow-400 h-10 w-10" />}>
130
+ This modal has a custom styled header.
131
+ </NModal>
132
+
133
+ {/* Custom Footer */}
134
+ <NModal
135
+ {...vModel(2)}
136
+ title="Custom Footer"
137
+ footer={({ cancel }) => (
138
+ <div class="flex justify-center">
139
+ <NIconButton icon={NoSymbolIcon} color="red" size={7} onClick={cancel} />
140
+ </div>
141
+ )}
142
+ >
143
+ This modal has a custom footer
144
+ </NModal>
145
+
146
+ {/* Custom Modal */}
147
+ <NModal
148
+ {...vModel(3)}
149
+ modal={({ cancel }) => (
150
+ <div class="bg-red-500 p-4 shadow-red-500 text-lg text-white shadow-2xl rounded-full flex justify-between items-center">
151
+ <span>Very ugly custom modal</span>
152
+ <NButton color="default" onClick={cancel}>
153
+ Close
154
+ </NButton>
155
+ </div>
156
+ )}
157
+ />
158
+
159
+ {/* Form Modal */}
160
+ <NFormModal {...vModel(4)} title="Form Modal" form={form1}>
161
+ <NValInput {...vModelForRef(inputRefs[0])} form={form1} name="Name" />
162
+ <NValInput {...vModelForRef(inputRefs[1])} form={form1} rules={email} name="Email" />
163
+ </NFormModal>
164
+
165
+ {/** Crud Modal */}
166
+ <NCrudModal
167
+ {...vModel(5)}
168
+ title="Crud Modal"
169
+ form={form2}
170
+ removeDialogTitle="Remove this item"
171
+ removeDialogText="Are you really really really sure?"
172
+ >
173
+ <NValInput {...vModelForRef(inputRefs[2])} form={form2} name="Name" />
174
+ <NValInput {...vModelForRef(inputRefs[3])} form={form2} rules={email} name="Email" />
175
+ </NCrudModal>
176
+
177
+ {/* Dialogs */}
178
+ <NDialog ref={dialogRefs[0]} variant="success" title="Success" text="This was a success." />
179
+ <NDialog ref={dialogRefs[1]} variant="info" title="Info" text="This is an info." />
180
+ <NDialog
181
+ ref={dialogRefs[2]}
182
+ variant="warning"
183
+ title="Warning"
184
+ text="Be careful, this is a warning with a pretty long text."
185
+ />
186
+ <NDialog
187
+ ref={dialogRefs[3]}
188
+ variant="danger"
189
+ title="Dangerous Action"
190
+ text="Would you really like to proceed."
191
+ />
192
+ <NDialog
193
+ ref={dialogRefs[4]}
194
+ variant="remove"
195
+ title="Delete user"
196
+ text="Are you sure you want to delete the user?"
197
+ />
198
+
199
+ {/* Positioned Modals */}
200
+ <NModal {...vModel(6)} title="Top Left" verticalPosition="start" horizontalPosition="start" />
201
+ <NModal {...vModel(7)} title="Top Center" verticalPosition="start" horizontalPosition="center" />
202
+ <NModal {...vModel(8)} title="Top Right" verticalPosition="start" horizontalPosition="end" />
203
+ <NModal {...vModel(9)} title="Center Right" verticalPosition="center" horizontalPosition="end" />
204
+ <NModal {...vModel(10)} title="Bottom Right" verticalPosition="end" horizontalPosition="end" />
205
+ <NModal {...vModel(11)} title="Bottom Center" verticalPosition="end" horizontalPosition="center" />
206
+ <NModal {...vModel(12)} title="Bottom Left" verticalPosition="end" horizontalPosition="start" />
207
+ <NModal {...vModel(13)} title="Center Left" verticalPosition="center" horizontalPosition="start" />
208
+ </>
209
+ )
210
+ })
@@ -0,0 +1,25 @@
1
+ import NPagination from '@/lib/components/NPagination'
2
+ import ComponentSection from '@/demo/components/ComponentSection'
3
+ import VariantSection from '@/demo/components/VariantSection'
4
+ import { createView } from '@/lib/utils/component'
5
+ import { vModelForRef } from '@/lib/utils/vModel'
6
+ import { ref } from 'vue'
7
+
8
+ export default createView('PaginationView', () => {
9
+ const pageRef = ref(1)
10
+
11
+ return () => (
12
+ <ComponentSection
13
+ title="Pagination"
14
+ subtitle="A pagination element to use for all paged contents."
15
+ id="pagination"
16
+ >
17
+ <VariantSection title="Two sizes">
18
+ <div class="flex flex-col justify-start items-start space-y-8">
19
+ <NPagination {...vModelForRef(pageRef)} total={25} />
20
+ <NPagination small {...vModelForRef(pageRef)} total={25} />
21
+ </div>
22
+ </VariantSection>
23
+ </ComponentSection>
24
+ )
25
+ })
@@ -0,0 +1,80 @@
1
+ import NSearchbar from '@/lib/components/NSearchbar'
2
+ import NSearchbarList from '@/lib/components/NSearchbarList'
3
+ import ComponentGrid from '@/demo/components/ComponentGrid'
4
+ import ComponentSection from '@/demo/components/ComponentSection'
5
+ import VariantSection from '@/demo/components/VariantSection'
6
+ import { createView } from '@/lib/utils/component'
7
+ import { vModelForRef } from '@/lib/utils/vModel'
8
+ import { UserIcon } from '@heroicons/vue/24/solid'
9
+ import { computed, ref } from 'vue'
10
+
11
+ export default createView('SearchbarView', () => {
12
+ const refs = Array.from({ length: 10 }, () => ref(''))
13
+
14
+ const suggestions = [
15
+ { id: '1', name: 'Heidi Klum' },
16
+ { id: '2', name: 'Frida Kahlo' },
17
+ { id: '3', name: 'Berta Meier' },
18
+ { id: '4', name: 'Mike Müller' },
19
+ { id: '5', name: 'Hans Peter' },
20
+ { id: '6', name: 'Franz Weber' },
21
+ { id: '7', name: 'Franziska Weberin' },
22
+ { id: '8', name: 'Angela Merkel' },
23
+ ]
24
+
25
+ const filteredSuggestions = (n: number) => {
26
+ return computed(() =>
27
+ suggestions
28
+ .filter(sugg => sugg.name.toLowerCase().includes(refs[n].value.toLowerCase()))
29
+ .map(sugg => ({ id: sugg.id, label: sugg.name }))
30
+ )
31
+ }
32
+
33
+ function vModel(n: number) {
34
+ return vModelForRef(refs[n])
35
+ }
36
+
37
+ return () => (
38
+ <ComponentSection
39
+ title="Searchbars"
40
+ subtitle="Searchbars are styled inputs which can optionally provide a list of suggestions."
41
+ id="searchbars"
42
+ >
43
+ <VariantSection title="Simple Searchbars">
44
+ <ComponentGrid cols={2}>
45
+ <NSearchbar placeholder="Big Searchbar" {...vModel(0)} />
46
+ <NSearchbar small placeholder="Small Searchbar" {...vModel(1)} />
47
+ </ComponentGrid>
48
+ </VariantSection>
49
+
50
+ <VariantSection title="With Suggestion List" subtitle="">
51
+ <ComponentGrid cols={2}>
52
+ <NSearchbarList {...vModel(2)} items={filteredSuggestions(2).value} placeholder="Basic List" />
53
+ <NSearchbarList
54
+ {...vModel(3)}
55
+ items={filteredSuggestions(3).value}
56
+ placeholder="Loading Indicator"
57
+ loading
58
+ />
59
+ <NSearchbarList
60
+ {...vModel(4)}
61
+ items={filteredSuggestions(4).value}
62
+ hideList={refs[4].value.length < 3}
63
+ placeholder="Min. 3 Characters"
64
+ />
65
+ <NSearchbarList
66
+ {...vModel(5)}
67
+ items={filteredSuggestions(5).value}
68
+ placeholder="Customized Items"
69
+ listItem={item => (
70
+ <div class="flex space-x-2 items-center justify-start">
71
+ <UserIcon class="h-5 w-5 text-default-600" />
72
+ <span class="text-lg text-default-700 font-medium">{item.item.label}</span>
73
+ </div>
74
+ )}
75
+ />
76
+ </ComponentGrid>
77
+ </VariantSection>
78
+ </ComponentSection>
79
+ )
80
+ })
@@ -0,0 +1,146 @@
1
+ import NBadge from '@/lib/components/NBadge'
2
+ import NIconButton from '@/lib/components/NIconButton'
3
+ import NTable, { type TableHeading } from '@/lib/components/NTable'
4
+ import NTableAction from '@/lib/components/NTableAction'
5
+ import ComponentSection from '@/demo/components/ComponentSection'
6
+ import VariantSection from '@/demo/components/VariantSection'
7
+ import { createView } from '@/lib/utils/component'
8
+ import { PencilIcon, MagnifyingGlassIcon } from '@heroicons/vue/24/solid'
9
+
10
+ export default createView('TableView', () => {
11
+ const headings: TableHeading[] = [
12
+ { key: 'id', label: 'ID' },
13
+ { key: 'username', label: 'Username', emph: true },
14
+ { key: 'email', label: 'Email', breakpoint: 'md' },
15
+ { key: 'phone', label: 'Phone', breakpoint: 'lg' },
16
+ { key: 'state', label: 'State', breakpoint: 'sm' },
17
+ ]
18
+
19
+ const details: TableHeading[] = [
20
+ { key: 'address', label: 'Addresse', isDetail: true },
21
+ { key: 'zip', label: 'PLZ', isDetail: true },
22
+ { key: 'place', label: 'Ort', isDetail: true },
23
+ ]
24
+
25
+ const data = [
26
+ {
27
+ id: 1,
28
+ username: 'herbert',
29
+ email: 'herbert@naptics.ch',
30
+ phone: '+41 76 810 29 21',
31
+ state: 'unknown',
32
+ address: 'Hugentoblergasse 132',
33
+ zip: '8400',
34
+ place: 'Winterthur',
35
+ },
36
+ {
37
+ id: 2,
38
+ username: 'franziska',
39
+ email: 'franzsika@naptics.ch',
40
+ phone: '+41 76 810 28 22',
41
+ state: 'registered',
42
+ address: 'Hugentoblergasse 132',
43
+ zip: '8400',
44
+ place: 'Winterthur',
45
+ },
46
+ {
47
+ id: 3,
48
+ username: 'frank',
49
+ email: 'frank@naptics.ch',
50
+ phone: '+41 76 810 27 23',
51
+ state: 'registered',
52
+ address: 'Hugentoblergasse 132',
53
+ zip: '8400',
54
+ place: 'Winterthur',
55
+ },
56
+ {
57
+ id: 4,
58
+ username: 'prünhilde',
59
+ email: 'pruenhilde@naptics.ch',
60
+ phone: '+41 76 810 26 24',
61
+ state: 'banned',
62
+ address: 'Hugentoblergasse 132',
63
+ zip: '8400',
64
+ place: 'Winterthur',
65
+ },
66
+ {
67
+ id: 5,
68
+ username: 'gertrud',
69
+ email: 'gertrud@naptics.ch',
70
+ phone: '+41 76 810 25 25',
71
+ state: 'registered',
72
+ address: 'Hugentoblergasse 132',
73
+ zip: '8400',
74
+ place: 'Winterthur',
75
+ },
76
+ ]
77
+
78
+ return () => (
79
+ <ComponentSection
80
+ title="Tables"
81
+ subtitle="Tables are perfect to display a lot of data in an orderly way."
82
+ id="tables"
83
+ >
84
+ <VariantSection
85
+ title="Basic Table"
86
+ subtitle="If nothing needs to be customized, the data can be displayed directly as text."
87
+ >
88
+ <NTable headings={headings} items={data} />
89
+ </VariantSection>
90
+
91
+ <VariantSection
92
+ title="Customization"
93
+ subtitle="Individual columns can be customized to use other elements."
94
+ >
95
+ <NTable
96
+ headings={headings}
97
+ items={data.map(item => ({
98
+ ...item,
99
+ state: () => (
100
+ <NBadge
101
+ textSize="text-xs"
102
+ color={
103
+ item.state == 'registered' ? 'green' : item.state == 'banned' ? 'red' : 'default'
104
+ }
105
+ >
106
+ {item.state}
107
+ </NBadge>
108
+ ),
109
+ }))}
110
+ />
111
+ </VariantSection>
112
+
113
+ <VariantSection
114
+ title="With Details"
115
+ subtitle="If there is a lot of information to display, a details section can be added."
116
+ >
117
+ <NTable headings={[...headings, ...details]} items={data} />
118
+ </VariantSection>
119
+
120
+ <VariantSection
121
+ title="Actions"
122
+ subtitle="Table Actions can be added to either trigger an action or navigate to a route."
123
+ >
124
+ <NTable
125
+ headings={headings}
126
+ items={data.map(item => ({
127
+ ...item,
128
+ username: () => <NTableAction route={`/`} text={item.username} />,
129
+ action: () => (
130
+ <>
131
+ <NIconButton
132
+ icon={PencilIcon}
133
+ onClick={() => alert(`You will edit ${item.username}.`)}
134
+ />
135
+ <NIconButton
136
+ icon={MagnifyingGlassIcon}
137
+ onClick={() => alert(`You will lookup ${item.username}.`)}
138
+ />
139
+ </>
140
+ ),
141
+ }))}
142
+ />
143
+ </VariantSection>
144
+ </ComponentSection>
145
+ )
146
+ })
@@ -0,0 +1,86 @@
1
+ import NBadge from '@/lib/components/NBadge'
2
+ import NButton from '@/lib/components/NButton'
3
+ import NIconButton from '@/lib/components/NIconButton'
4
+ import NInput from '@/lib/components/NInput'
5
+ import NTooltip from '@/lib/components/NTooltip'
6
+ import ComponentGrid from '@/demo/components/ComponentGrid'
7
+ import ComponentSection from '@/demo/components/ComponentSection'
8
+ import VariantSection from '@/demo/components/VariantSection'
9
+ import { createView } from '@/lib/utils/component'
10
+ import { ArrowTopRightOnSquareIcon } from '@heroicons/vue/24/solid'
11
+
12
+ export default createView('TooltipView', () => {
13
+ return () => (
14
+ <ComponentSection
15
+ id="tooltips"
16
+ title="Tooltips"
17
+ subtitle="Tooltips can be added to all components to display small explanations or tips to the user."
18
+ >
19
+ <VariantSection
20
+ title="Customization"
21
+ subtitle="The content of a tooltip can be a simple text or there is a slot available for customization. More properties like placement, maximum width and more can be configured."
22
+ >
23
+ <ComponentGrid cols={4}>
24
+ <div class="flex">
25
+ <NTooltip text="Hello tooltip!">
26
+ <NBadge text="Hover me" />
27
+ </NTooltip>
28
+ </div>
29
+
30
+ <div class="flex">
31
+ <NTooltip
32
+ content={() => (
33
+ <div>
34
+ <h2 class="font-medium text-base"> The importance of tooltips</h2>
35
+ <p>
36
+ Tooltips are very important as they allow the display information conditionally
37
+ on the screen.
38
+ </p>
39
+ </div>
40
+ )}
41
+ >
42
+ <NBadge text="Hover me" />
43
+ </NTooltip>
44
+ </div>
45
+
46
+ <div class="flex">
47
+ <NTooltip text="Tooltip placed at «top-start»." placement="top-start">
48
+ <NBadge text="Hover me" />
49
+ </NTooltip>
50
+ </div>
51
+
52
+ <div class="flex">
53
+ <NTooltip
54
+ text="I don't go away, but I am a multiline text in a tooltip. I wrap around multiple lines."
55
+ placement="bottom-start"
56
+ >
57
+ <NBadge text="Hover me" />
58
+ </NTooltip>
59
+ </div>
60
+ </ComponentGrid>
61
+ </VariantSection>
62
+
63
+ <VariantSection
64
+ title="Out of the box"
65
+ subtitle="The following components contain integrated tooltips out of the box."
66
+ >
67
+ <ComponentGrid cols={4}>
68
+ <div class="flex items-center">
69
+ <NIconButton
70
+ icon={ArrowTopRightOnSquareIcon}
71
+ tooltipText="Icon Buttons have integrated tooltips."
72
+ />
73
+ </div>
74
+ <div class="flex items-center">
75
+ <NButton tooltipText="Buttons have integrated tooltips."> Button </NButton>
76
+ </div>
77
+ <div class="flex items-center">
78
+ <NBadge text="Badge" tooltipText="Badges have integrated tooltips." />
79
+ </div>
80
+
81
+ <NInput name="Disabled" disabled tooltipText="Inputs have integrated tooltips." />
82
+ </ComponentGrid>
83
+ </VariantSection>
84
+ </ComponentSection>
85
+ )
86
+ })