@naptics/vue-collection 0.2.15 → 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 +7 -251
  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 +7 -151
  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 +12 -250
  45. package/components/NModal.js +15 -9
  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,179 @@
1
+ import NButton from '@/lib/components/NButton'
2
+ import NForm from '@/lib/components/NForm'
3
+ import NInput from '@/lib/components/NInput'
4
+ import NSelect from '@/lib/components/NSelect'
5
+ import NValInput from '@/lib/components/NValInput'
6
+ import { createValidatedForm } from '@/lib/components/ValidatedForm'
7
+ import ComponentGrid from '@/demo/components/ComponentGrid'
8
+ import ComponentSection from '@/demo/components/ComponentSection'
9
+ import VariantSection from '@/demo/components/VariantSection'
10
+ import { email, matches, password, regex, integer, numberRange, length } from '@/lib/utils/validation'
11
+ import { createView } from '@/lib/utils/component'
12
+ import { ref } from 'vue'
13
+ import NInputSelect from '@/lib/components/NInputSelect'
14
+ import NInputSuggestion from '@/lib/components/NInputSuggestion'
15
+ import NInputPhone from '@/lib/components/NInputPhone'
16
+ import { vModelForRef } from '@/lib/utils/vModel'
17
+ import NTextArea from '@/lib/components/NTextArea'
18
+
19
+ export default createView('InputView', () => {
20
+ const suggestions = [
21
+ { id: '1', label: 'Heidi Klum' },
22
+ { id: '2', label: 'Frida Kahlo' },
23
+ { id: '3', label: 'Berta Meier' },
24
+ { id: '4', label: 'Mike Müller' },
25
+ { id: '5', label: 'Hans Peter' },
26
+ { id: '6', label: 'Franz Weber' },
27
+ { id: '7', label: 'Franziska Weberin' },
28
+ { id: '8', label: 'Angela Merkel' },
29
+ ]
30
+
31
+ const refs = Array.from({ length: 21 }, () => ref(''))
32
+
33
+ function vModel(n: number) {
34
+ return vModelForRef(refs[n])
35
+ }
36
+
37
+ const form = createValidatedForm()
38
+ const onSubmit = () => alert('Form was submitted!')
39
+
40
+ const showDynamicInput = ref(true)
41
+
42
+ return () => (
43
+ <ComponentSection
44
+ title="Inputs and Forms"
45
+ subtitle="Handle user input well with these inputs and forms."
46
+ id="inputs"
47
+ >
48
+ <VariantSection
49
+ title="Plain HTML"
50
+ subtitle="Wherever it is possible, the html features are used. The inputs can be selected by specifying the type attribute."
51
+ >
52
+ <NForm>
53
+ <ComponentGrid cols={2}>
54
+ <NInput {...vModel(0)} name="Name" />
55
+ <NInput {...vModel(1)} name="Age" type="number" />
56
+ <NInput {...vModel(2)} name="Password" type="password" />
57
+ <div class="space-y-2">
58
+ <NSelect
59
+ {...vModel(3)}
60
+ name="Country"
61
+ optional
62
+ options={[
63
+ { id: 'ch', label: 'Switzerland' },
64
+ { id: 'de', label: 'Germany' },
65
+ { id: 'au', label: 'Austria' },
66
+ ]}
67
+ />
68
+ <p class="text-xs text-default-500">{`Value of the field: ${vModel(3).value}`}</p>
69
+ </div>
70
+ <div class="space-y-2">
71
+ <NInput {...vModel(4)} name="Date" type="date" />
72
+ <p class="text-xs text-default-500">{`Value of the field: ${vModel(4).value}`}</p>
73
+ </div>
74
+ <div class="space-y-2">
75
+ <NInput {...vModel(5)} name="Time" type="time" />
76
+ <p class="text-xs text-default-500">{`Value of the field: ${vModel(5).value}`}</p>
77
+ </div>
78
+ </ComponentGrid>
79
+ </NForm>
80
+ </VariantSection>
81
+
82
+ <VariantSection
83
+ title="Input Validation"
84
+ subtitle="Inputs can be validated using different rules. Some inputs also implement a custom formatter, like the input for phone numbers."
85
+ >
86
+ <NForm>
87
+ <ComponentGrid cols={2}>
88
+ <NValInput {...vModel(15)} name="First Name" />
89
+ <NValInput {...vModel(16)} name="Last Name" rules={length(2, undefined)} />
90
+ <NValInput {...vModel(6)} name="Age" type="number" rules={[integer, numberRange(0, 120)]} />
91
+ <NValInput {...vModel(7)} name="Email" type="email" rules={email} />
92
+ <NValInput {...vModel(8)} name="Password" type="password" rules={password} />
93
+ <NValInput
94
+ {...vModel(9)}
95
+ name="Repeat Password"
96
+ type="password"
97
+ rules={[matches(refs[8].value)]}
98
+ />
99
+ <NValInput
100
+ {...vModel(10)}
101
+ name="Regex"
102
+ rules={regex(/^foo.*bar$/)}
103
+ placeholder="Try foo...bar"
104
+ />
105
+ <div class="space-y-2">
106
+ <NInputPhone {...vModel(11)} name="Mobile" />
107
+ <p class="text-xs text-default-500">{`Value of the field: ${vModel(11).value}`}</p>
108
+ </div>
109
+ </ComponentGrid>
110
+ </NForm>
111
+ </VariantSection>
112
+
113
+ <VariantSection
114
+ title="Text Areas"
115
+ subtitle="If longer text is needed, the text area can be used. It provides most of the feature of a validated input."
116
+ >
117
+ <div class="space-y-4">
118
+ <NTextArea
119
+ {...vModel(17)}
120
+ name="Resizable Text Area"
121
+ placeholder="This text area can be resized with the handle with max 100 characters, which is required to fill out."
122
+ maxLength={100}
123
+ />
124
+ <NTextArea
125
+ {...vModel(18)}
126
+ name="Larger Text Area"
127
+ placeholder="This is a larger non-resizable optional text area."
128
+ rows={5}
129
+ resizable={false}
130
+ optional
131
+ />
132
+ </div>
133
+ </VariantSection>
134
+
135
+ <VariantSection
136
+ title="Suggestion Lists"
137
+ subtitle="The left input just shows filtered suggestions and allows any input. The right input expects the user to pick an item from the list."
138
+ >
139
+ <ComponentGrid cols={2}>
140
+ <div class="space-y-2">
141
+ <NInputSuggestion
142
+ {...vModel(12)}
143
+ suggestions={suggestions.map(sugg => sugg.label)}
144
+ name="Any Person"
145
+ />
146
+ <p class="text-xs text-default-500">{`Value of the field: ${vModel(12).value}`}</p>
147
+ </div>
148
+ <div class="space-y-2">
149
+ <NInputSelect {...vModel(19)} options={suggestions} name="Choose Person" />
150
+ <p class="text-xs text-default-500">{`Value of the field: ${vModel(19).value}`}</p>
151
+ </div>
152
+ </ComponentGrid>
153
+ </VariantSection>
154
+
155
+ <VariantSection
156
+ title="Forms"
157
+ subtitle="Validated Inputs can be added to forms. When trying to submit the form, all inputs are validated first and only if the validation succeeds, the form is submitted."
158
+ >
159
+ <NForm form={form} onSubmit={onSubmit}>
160
+ <ComponentGrid cols={2}>
161
+ <NValInput name="First Name" form={form} {...vModel(13)} />
162
+ <NValInput name="Last name" form={form} {...vModel(14)} />
163
+ {showDynamicInput.value && <NValInput name="Hello World" form={form} {...vModel(20)} />}
164
+
165
+ <div class="flex space-x-2 items-end">
166
+ <NButton
167
+ color="secondary"
168
+ onClick={() => (showDynamicInput.value = !showDynamicInput.value)}
169
+ >
170
+ Toggle Input
171
+ </NButton>
172
+ <NButton type="submit">Submit Form</NButton>
173
+ </div>
174
+ </ComponentGrid>
175
+ </NForm>
176
+ </VariantSection>
177
+ </ComponentSection>
178
+ )
179
+ })
@@ -0,0 +1,50 @@
1
+ import NLink from '@/lib/components/NLink'
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('LinkView', () => {
8
+ const hi = () => window.alert('hello')
9
+
10
+ return () => (
11
+ <ComponentSection
12
+ id="links"
13
+ title="Links"
14
+ subtitle="Links are styled texts which can be used as links or regular buttons."
15
+ >
16
+ <VariantSection title="Normal Links">
17
+ <ComponentGrid cols={4}>
18
+ <div>
19
+ <NLink text="Privacy Policy" route="/" />
20
+ </div>
21
+ <div>
22
+ <NLink text="Privacy Policy" route="/" shade={200} />
23
+ </div>
24
+ <div>
25
+ <NLink text="Privacy Policy" route="/" color="secondary" shade={200} />
26
+ </div>
27
+ <div>
28
+ <NLink text="Privacy Policy" route="/" color="secondary" />
29
+ </div>
30
+ </ComponentGrid>
31
+ </VariantSection>
32
+ <VariantSection title="Button Links" subtitle="Sometimes it can be useful to style a button as a link.">
33
+ <ComponentGrid cols={4}>
34
+ <div>
35
+ <NLink text="Fake Link" onClick={hi} />
36
+ </div>
37
+ <div>
38
+ <NLink text="Fake Link" onClick={hi} shade={200} />
39
+ </div>
40
+ <div>
41
+ <NLink text="Fake Link" onClick={hi} color="secondary" shade={200} />
42
+ </div>
43
+ <div>
44
+ <NLink text="Fake Link" onClick={hi} color="secondary" />
45
+ </div>
46
+ </ComponentGrid>
47
+ </VariantSection>
48
+ </ComponentSection>
49
+ )
50
+ })
@@ -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
+ })