@naptics/vue-collection 0.2.15 → 0.3.1

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 (171) 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 +59 -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 +6 -70
  41. package/components/NLink.js +8 -1
  42. package/components/NList.d.ts +1 -43
  43. package/components/NList.js +1 -1
  44. package/components/NLoadingIndicator.d.ts +1 -49
  45. package/components/NModal.d.ts +12 -250
  46. package/components/NModal.js +15 -9
  47. package/components/NPagination.d.ts +1 -63
  48. package/components/NSearchbar.d.ts +1 -56
  49. package/components/NSearchbarList.d.ts +3 -63
  50. package/components/NSearchbarList.js +1 -1
  51. package/components/NSelect.d.ts +2 -148
  52. package/components/NSelect.js +1 -1
  53. package/components/NSuggestionList.d.ts +3 -126
  54. package/components/NSuggestionList.js +5 -2
  55. package/components/NTable.d.ts +1 -85
  56. package/components/NTable.js +12 -6
  57. package/components/NTableAction.d.ts +2 -46
  58. package/components/NTableAction.js +1 -1
  59. package/components/NTextArea.d.ts +2 -181
  60. package/components/NTextArea.js +1 -1
  61. package/components/NTooltip.d.ts +1 -105
  62. package/components/NTooltip.js +1 -1
  63. package/components/NValInput.d.ts +7 -182
  64. package/components/NValInput.js +1 -1
  65. package/env.d.ts +15 -0
  66. package/eslint.config.cjs +29 -0
  67. package/index.html +13 -0
  68. package/package.json +21 -19
  69. package/postcss.config.js +6 -0
  70. package/public/favicon.ico +0 -0
  71. package/scripts/build-lib.sh +52 -0
  72. package/scripts/sync-node-types.js +70 -0
  73. package/src/demo/App.css +9 -0
  74. package/src/demo/App.tsx +5 -0
  75. package/src/demo/components/ColorGrid.tsx +26 -0
  76. package/src/demo/components/ComponentGrid.tsx +26 -0
  77. package/src/demo/components/ComponentSection.tsx +30 -0
  78. package/src/demo/components/VariantSection.tsx +18 -0
  79. package/src/demo/i18n/de.ts +7 -0
  80. package/src/demo/i18n/en.ts +7 -0
  81. package/src/demo/i18n/index.ts +24 -0
  82. package/src/demo/main.ts +13 -0
  83. package/src/demo/router/index.ts +21 -0
  84. package/src/demo/views/HomeView.tsx +94 -0
  85. package/src/demo/views/NavigationView.tsx +43 -0
  86. package/src/demo/views/presentation/AlertView.tsx +40 -0
  87. package/src/demo/views/presentation/BadgeView.tsx +61 -0
  88. package/src/demo/views/presentation/BreadcrumbView.tsx +52 -0
  89. package/src/demo/views/presentation/ButtonView.tsx +49 -0
  90. package/src/demo/views/presentation/CheckboxView.tsx +59 -0
  91. package/src/demo/views/presentation/DropdownView.tsx +59 -0
  92. package/src/demo/views/presentation/DropzoneView.tsx +39 -0
  93. package/src/demo/views/presentation/IconButtonView.tsx +47 -0
  94. package/src/demo/views/presentation/IconCircleView.tsx +38 -0
  95. package/src/demo/views/presentation/InputView.tsx +179 -0
  96. package/src/demo/views/presentation/LinkView.tsx +60 -0
  97. package/src/demo/views/presentation/ListView.tsx +29 -0
  98. package/src/demo/views/presentation/LoadingIndicatorView.tsx +38 -0
  99. package/src/demo/views/presentation/ModalView.tsx +210 -0
  100. package/src/demo/views/presentation/PaginationView.tsx +25 -0
  101. package/src/demo/views/presentation/SearchbarView.tsx +80 -0
  102. package/src/demo/views/presentation/TableView.tsx +146 -0
  103. package/src/demo/views/presentation/TooltipView.tsx +86 -0
  104. package/src/lib/components/NAlert.tsx +85 -0
  105. package/src/lib/components/NBadge.tsx +75 -0
  106. package/src/lib/components/NBreadcrub.tsx +97 -0
  107. package/src/lib/components/NButton.tsx +80 -0
  108. package/src/lib/components/NCheckbox.tsx +55 -0
  109. package/src/lib/components/NCheckboxLabel.tsx +51 -0
  110. package/src/lib/components/NCrudModal.tsx +133 -0
  111. package/src/lib/components/NDialog.tsx +182 -0
  112. package/src/lib/components/NDropdown.tsx +167 -0
  113. package/src/lib/components/NDropzone.tsx +265 -0
  114. package/src/lib/components/NForm.tsx +32 -0
  115. package/src/lib/components/NFormModal.tsx +66 -0
  116. package/src/lib/components/NIconButton.tsx +92 -0
  117. package/src/lib/components/NIconCircle.tsx +78 -0
  118. package/src/lib/components/NInput.css +11 -0
  119. package/src/lib/components/NInput.tsx +139 -0
  120. package/src/lib/components/NInputPhone.tsx +53 -0
  121. package/src/lib/components/NInputSelect.tsx +126 -0
  122. package/src/lib/components/NInputSuggestion.tsx +80 -0
  123. package/src/lib/components/NLink.tsx +82 -0
  124. package/src/lib/components/NList.tsx +67 -0
  125. package/src/lib/components/NLoadingIndicator.css +46 -0
  126. package/src/lib/components/NLoadingIndicator.tsx +63 -0
  127. package/src/lib/components/NModal.tsx +243 -0
  128. package/src/lib/components/NPagination.css +15 -0
  129. package/src/lib/components/NPagination.tsx +131 -0
  130. package/src/lib/components/NSearchbar.tsx +78 -0
  131. package/src/lib/components/NSearchbarList.tsx +47 -0
  132. package/src/lib/components/NSelect.tsx +128 -0
  133. package/src/lib/components/NSuggestionList.tsx +216 -0
  134. package/src/lib/components/NTable.css +3 -0
  135. package/src/lib/components/NTable.tsx +247 -0
  136. package/src/lib/components/NTableAction.tsx +49 -0
  137. package/src/lib/components/NTextArea.tsx +159 -0
  138. package/src/lib/components/NTooltip.css +37 -0
  139. package/src/lib/components/NTooltip.tsx +250 -0
  140. package/src/lib/components/NValInput.tsx +163 -0
  141. package/src/lib/components/ValidatedForm.ts +71 -0
  142. package/src/lib/components/__tests__/NButton.spec.tsx +26 -0
  143. package/src/lib/components/__tests__/NCheckbox.spec.tsx +39 -0
  144. package/src/lib/i18n/de/vue-collection.json +58 -0
  145. package/src/lib/i18n/en/vue-collection.json +58 -0
  146. package/src/lib/i18n/index.ts +54 -0
  147. package/src/lib/index.ts +2 -0
  148. package/src/lib/jsx.d.ts +13 -0
  149. package/src/lib/utils/__tests__/identifiable.spec.ts +72 -0
  150. package/src/lib/utils/__tests__/validation.spec.ts +92 -0
  151. package/src/lib/utils/breakpoints.ts +47 -0
  152. package/src/lib/utils/component.tsx +131 -0
  153. package/src/lib/utils/deferred.ts +28 -0
  154. package/src/lib/utils/identifiable.ts +87 -0
  155. package/src/lib/utils/stringMaxLength.ts +25 -0
  156. package/src/lib/utils/tailwind.ts +41 -0
  157. package/src/lib/utils/utils.ts +90 -0
  158. package/src/lib/utils/vModel.ts +260 -0
  159. package/src/lib/utils/validation.ts +189 -0
  160. package/src/lib/utils/vue.ts +25 -0
  161. package/tailwind.config.js +38 -0
  162. package/tsconfig.config.json +9 -0
  163. package/tsconfig.demo.json +19 -0
  164. package/tsconfig.json +16 -0
  165. package/tsconfig.lib.json +18 -0
  166. package/tsconfig.vitest.json +8 -0
  167. package/utils/breakpoints.d.ts +1 -1
  168. package/utils/component.d.ts +3 -7
  169. package/utils/component.js +5 -2
  170. package/utils/identifiable.js +5 -1
  171. package/vite.config.ts +28 -0
@@ -0,0 +1,52 @@
1
+ import NBreadcrub, { type BreadcrumbItem } from '@/lib/components/NBreadcrub'
2
+ import ComponentSection from '@/demo/components/ComponentSection'
3
+ import VariantSection from '@/demo/components/VariantSection'
4
+ import { createView } from '@/lib/utils/component'
5
+ import { ChevronDoubleRightIcon } from '@heroicons/vue/24/solid'
6
+
7
+ export default createView('BreadcrumbView', () => {
8
+ const breadcrumbItems: BreadcrumbItem[] = [
9
+ { label: 'Overview', route: '/' },
10
+ { label: 'Customers', route: '/' },
11
+ { label: 'Customer Details', route: '/' },
12
+ { label: 'Edit Customer', route: '/' },
13
+ ]
14
+
15
+ return () => (
16
+ <ComponentSection
17
+ id="breadcrumbs"
18
+ title="Breadcrumbs"
19
+ subtitle="Breadcrumbs can be used as a navigation in hierarchical views."
20
+ >
21
+ <VariantSection
22
+ title="Default Breadcrumb"
23
+ subtitle="Without any customization the default breadcrumb looks like this."
24
+ >
25
+ <NBreadcrub items={breadcrumbItems} />
26
+ </VariantSection>
27
+
28
+ <VariantSection title="Different Icon" subtitle="Any icon can be chosen as the sepeartor.">
29
+ <NBreadcrub items={breadcrumbItems} iconSize={4} icon={ChevronDoubleRightIcon} />
30
+ </VariantSection>
31
+
32
+ <VariantSection
33
+ title="Customize everthing"
34
+ subtitle="The color and size of the text and icons can be customized. Additionally the items and the sepeators have custom slots."
35
+ >
36
+ <NBreadcrub
37
+ items={breadcrumbItems}
38
+ color="secondary"
39
+ textSize="text-lg"
40
+ seperator={() => (
41
+ <button
42
+ class="text-secondary-500 text-sm font-semibold mx-3"
43
+ onClick={() => window.alert('You found the custom button seperator 🕵🏽‍♂️')}
44
+ >
45
+ /
46
+ </button>
47
+ )}
48
+ />
49
+ </VariantSection>
50
+ </ComponentSection>
51
+ )
52
+ })
@@ -0,0 +1,49 @@
1
+ import { createView } from '@/lib/utils/component'
2
+ import NButton from '@/lib/components/NButton'
3
+ import ComponentSection from '@/demo/components/ComponentSection'
4
+ import VariantSection from '@/demo/components/VariantSection'
5
+ import ColorGrid from '@/demo/components/ColorGrid'
6
+
7
+ export default createView('ButtonView', () => {
8
+ return () => (
9
+ <ComponentSection
10
+ title="Buttons"
11
+ subtitle="The basic building block of all our apps. They can have two sizes and different colors."
12
+ id="buttons"
13
+ >
14
+ <VariantSection title="Normal">
15
+ <ColorGrid item={color => <NButton color={color}>Click me</NButton>} />
16
+ </VariantSection>
17
+
18
+ <VariantSection title="Small">
19
+ <ColorGrid
20
+ item={color => (
21
+ <NButton color={color} small>
22
+ Click me
23
+ </NButton>
24
+ )}
25
+ />
26
+ </VariantSection>
27
+
28
+ <VariantSection title="Disabled">
29
+ <ColorGrid
30
+ item={color => (
31
+ <NButton color={color} disabled>
32
+ Click me
33
+ </NButton>
34
+ )}
35
+ />
36
+ </VariantSection>
37
+
38
+ <VariantSection title="Loading">
39
+ <ColorGrid
40
+ item={color => (
41
+ <NButton color={color} loading>
42
+ Click me
43
+ </NButton>
44
+ )}
45
+ />
46
+ </VariantSection>
47
+ </ComponentSection>
48
+ )
49
+ })
@@ -0,0 +1,59 @@
1
+ import NCheckbox from '@/lib/components/NCheckbox'
2
+ import NCheckboxLabel from '@/lib/components/NCheckboxLabel'
3
+ import ColorGrid from '@/demo/components/ColorGrid'
4
+ import ComponentSection from '@/demo/components/ComponentSection'
5
+ import VariantSection from '@/demo/components/VariantSection'
6
+ import { createView } from '@/lib/utils/component'
7
+ import { ref } from 'vue'
8
+ import { vModelForRef } from '@/lib/utils/vModel'
9
+
10
+ export default createView('CheckboxView', () => {
11
+ const refs = Array.from({ length: 6 }, () => ref(true))
12
+
13
+ return () => (
14
+ <ComponentSection
15
+ title="Checkboxes"
16
+ subtitle="Checkboxes come in different colors and can be used on their own or together with labels."
17
+ id="checkboxes"
18
+ >
19
+ <VariantSection title="On their own">
20
+ <ColorGrid item={(color, idx) => <NCheckbox color={color} {...vModelForRef(refs[idx])} />} />
21
+ </VariantSection>
22
+
23
+ <VariantSection title="Disabled">
24
+ <ColorGrid item={(color, idx) => <NCheckbox color={color} {...vModelForRef(refs[idx])} disabled />} />
25
+ </VariantSection>
26
+
27
+ <VariantSection title="With labels" subtitle="Checkboxes can also be toggled by clicking on the texts.">
28
+ <ColorGrid
29
+ colors={2}
30
+ cols={2}
31
+ item={(color, idx) => (
32
+ <NCheckboxLabel
33
+ color={color}
34
+ {...vModelForRef(refs[idx])}
35
+ title="Choose Option"
36
+ description="This option will provide many advantages. For example the checkbox will be very beautifully enlightened."
37
+ />
38
+ )}
39
+ />
40
+ </VariantSection>
41
+
42
+ <VariantSection title="Disabled with labels">
43
+ <ColorGrid
44
+ colors={2}
45
+ cols={2}
46
+ item={(color, idx) => (
47
+ <NCheckboxLabel
48
+ color={color}
49
+ {...vModelForRef(refs[idx])}
50
+ title="Choose Option"
51
+ description="This option will provide many advantages."
52
+ disabled
53
+ />
54
+ )}
55
+ />
56
+ </VariantSection>
57
+ </ComponentSection>
58
+ )
59
+ })
@@ -0,0 +1,59 @@
1
+ import NDropdown, { type DropdownItem } from '@/lib/components/NDropdown'
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
+ import { ArrowDownOnSquareIcon, ShareIcon } from '@heroicons/vue/24/solid'
7
+
8
+ export default createView('DropdownView', () => {
9
+ const base: DropdownItem[] = [{ label: 'Save File' }, { label: 'Share File' }]
10
+ const multiple: DropdownItem[][] = [base, [{ label: 'Logout', route: '/logout' }, { label: 'Profile' }]]
11
+ const icons: DropdownItem[] = [
12
+ { label: 'Save File', icon: ArrowDownOnSquareIcon },
13
+ { label: 'Share File', icon: ShareIcon, route: '/share' },
14
+ ]
15
+
16
+ const links: DropdownItem[][] = [
17
+ [{ label: 'Normal Action' }],
18
+ [
19
+ { label: 'Route', route: '/link' },
20
+ { label: 'Other Route', route: '/link2' },
21
+ ],
22
+ ]
23
+
24
+ return () => (
25
+ <ComponentSection
26
+ title="Dropdowns"
27
+ subtitle="Dropdowns can be used to group multiple actions together."
28
+ id="dropdowns"
29
+ >
30
+ <VariantSection
31
+ title="Different Contents"
32
+ subtitle="The content can be selected using the mouse or the arrow keys. The items can either trigger an action or be a router link."
33
+ >
34
+ <ComponentGrid cols={4}>
35
+ <NDropdown title="Basic Dropdown" items={base} />
36
+ <NDropdown title="Multiple Sections" items={multiple} />
37
+ <NDropdown title="Action Icons" items={icons} />
38
+ <NDropdown title="Router Links" items={links} />
39
+ </ComponentGrid>
40
+ </VariantSection>
41
+
42
+ <VariantSection
43
+ title="Customization"
44
+ subtitle="Dropdowns can be disabled and configured to be right aligned. For further customized there is a slot for a custom button."
45
+ >
46
+ <ComponentGrid cols={4}>
47
+ <NDropdown title="Disabled" disabled />
48
+ <NDropdown title="Right Aligned" right items={base} />
49
+ <div class="flex items-center justify-center">
50
+ <NDropdown
51
+ items={base}
52
+ button={HeadlessButton => <HeadlessButton> Custom Button</HeadlessButton>}
53
+ />
54
+ </div>
55
+ </ComponentGrid>
56
+ </VariantSection>
57
+ </ComponentSection>
58
+ )
59
+ })
@@ -0,0 +1,39 @@
1
+ import NDropzone from '@/lib/components/NDropzone'
2
+ import ComponentSection from '@/demo/components/ComponentSection'
3
+ import VariantSection from '@/demo/components/VariantSection'
4
+ import { createView } from '@/lib/utils/component'
5
+ import { ref } from 'vue'
6
+ import { vModelForRef } from '@/lib/utils/vModel'
7
+
8
+ export default createView('DropzoneView', () => {
9
+ const fileRefs = Array.from({ length: 5 }).map(() => ref<File[]>([]))
10
+
11
+ return () => (
12
+ <ComponentSection
13
+ title="Dropzones"
14
+ subtitle="Dropzones are a simple way for the user to provide files to the application."
15
+ id="dropzones"
16
+ >
17
+ <VariantSection title="Basic" subtitle="Files can be added by clicking on the area or by dropping them.">
18
+ <NDropzone {...vModelForRef(fileRefs[0])} maxLengthFileNames={50} />
19
+ </VariantSection>
20
+
21
+ <VariantSection title="Multiple files">
22
+ <NDropzone {...vModelForRef(fileRefs[1])} maxFiles={10} />
23
+ </VariantSection>
24
+
25
+ <VariantSection
26
+ title="File Type and Size"
27
+ subtitle="The allowed file types and their maximum size can be specified."
28
+ >
29
+ <NDropzone
30
+ {...vModelForRef(fileRefs[2])}
31
+ maxFiles={5}
32
+ accept="image/*, .pdf, .zip"
33
+ maxFileSize={5 * 1024 * 1024}
34
+ description="Files of type .pdf or .zip and all image files with a max size of 5 MB are allowed."
35
+ />
36
+ </VariantSection>
37
+ </ComponentSection>
38
+ )
39
+ })
@@ -0,0 +1,47 @@
1
+ import NIconButton from '@/lib/components/NIconButton'
2
+ import ColorGrid from '@/demo/components/ColorGrid'
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 {
8
+ CogIcon,
9
+ CreditCardIcon,
10
+ EyeIcon,
11
+ KeyIcon,
12
+ PencilIcon,
13
+ RssIcon,
14
+ ArrowTopRightOnSquareIcon,
15
+ ChevronDoubleRightIcon,
16
+ } from '@heroicons/vue/24/solid'
17
+
18
+ export default createView('IconButtonView', () => {
19
+ const icons = [CogIcon, RssIcon, KeyIcon, CreditCardIcon, PencilIcon, EyeIcon]
20
+ const sizes = [4, 5, 6, 7, 8, 10]
21
+
22
+ return () => (
23
+ <ComponentSection
24
+ title="Icon Buttons"
25
+ subtitle="Icon Buttons are regular buttons which just have an icon and no text."
26
+ id="icon-buttons"
27
+ >
28
+ <VariantSection title="Different Colors">
29
+ <ColorGrid item={(color, index) => <NIconButton icon={icons[index]} color={color} />} />
30
+ </VariantSection>
31
+
32
+ <VariantSection title="Different Sizes">
33
+ <ComponentGrid>
34
+ {sizes.map(size => (
35
+ <div class="flex items-center justify-start">
36
+ <NIconButton icon={ChevronDoubleRightIcon} size={size} />
37
+ </div>
38
+ ))}
39
+ </ComponentGrid>
40
+ </VariantSection>
41
+
42
+ <VariantSection title="Router Links" subtitle="The Icon Button can also be used as a regular router link.">
43
+ <ColorGrid item={color => <NIconButton icon={ArrowTopRightOnSquareIcon} route="/" color={color} />} />
44
+ </VariantSection>
45
+ </ComponentSection>
46
+ )
47
+ })
@@ -0,0 +1,38 @@
1
+ import NIconCircle from '@/lib/components/NIconCircle'
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
+ import { FireIcon } from '@heroicons/vue/24/solid'
7
+
8
+ export default createView('IconCircleView', () => {
9
+ return () => (
10
+ <ComponentSection title="Icon Circles" subtitle="Just a regular icon in a circle." id="icon-circles">
11
+ <VariantSection
12
+ title="Unlimited possibilities"
13
+ subtitle="The color, circle size, icon size and the shades of icon and background can be customized."
14
+ >
15
+ <ComponentGrid>
16
+ <div class="flex items-center">
17
+ <NIconCircle icon={FireIcon} />
18
+ </div>
19
+ <div class="flex items-center">
20
+ <NIconCircle icon={FireIcon} color="red" />
21
+ </div>
22
+ <div class="flex items-center">
23
+ <NIconCircle icon={FireIcon} color="red" bgShade={700} iconShade={50} />
24
+ </div>
25
+ <div class="flex items-center">
26
+ <NIconCircle icon={FireIcon} color="red" circleSize={16} iconSize={4} />
27
+ </div>
28
+ <div class="flex items-center">
29
+ <NIconCircle icon={FireIcon} color="red" circleSize={16} iconSize={14} />
30
+ </div>
31
+ <div class="flex items-center">
32
+ <NIconCircle icon={FireIcon} color="red" iconSize={6} />
33
+ </div>
34
+ </ComponentGrid>
35
+ </VariantSection>
36
+ </ComponentSection>
37
+ )
38
+ })
@@ -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,60 @@
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
+ <VariantSection title="Disabled Links">
49
+ <ComponentGrid cols={4}>
50
+ <div>
51
+ <NLink text="Disabled Link" disabled />
52
+ </div>
53
+ <div>
54
+ <NLink text="Disabled Link" onClick={hi} color="secondary" disabled />
55
+ </div>
56
+ </ComponentGrid>
57
+ </VariantSection>
58
+ </ComponentSection>
59
+ )
60
+ })
@@ -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
+ })