@naptics/vue-collection 1.0.0-beta.1 → 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/lib/components/NAlert.d.ts +29 -0
  2. package/lib/components/NAlert.js +84 -0
  3. package/lib/components/NBadge.d.ts +73 -0
  4. package/lib/components/NBadge.js +64 -0
  5. package/lib/components/NBreadcrub.d.ts +69 -0
  6. package/lib/components/NBreadcrub.js +71 -0
  7. package/lib/components/NButton.d.ts +64 -0
  8. package/lib/components/NButton.js +70 -0
  9. package/lib/components/NCheckbox.d.ts +20 -0
  10. package/lib/components/NCheckbox.js +43 -0
  11. package/lib/components/NCheckboxLabel.d.ts +26 -0
  12. package/lib/components/NCheckboxLabel.js +42 -0
  13. package/lib/components/NCrudModal.d.ts +118 -0
  14. package/lib/components/NCrudModal.js +120 -0
  15. package/lib/components/NDialog.d.ts +81 -0
  16. package/lib/components/NDialog.js +161 -0
  17. package/lib/components/NDropdown.d.ts +67 -0
  18. package/lib/components/NDropdown.js +115 -0
  19. package/lib/components/NDropzone.d.ts +61 -0
  20. package/lib/components/NDropzone.js +218 -0
  21. package/lib/components/NForm.d.ts +21 -0
  22. package/lib/components/NForm.js +29 -0
  23. package/lib/components/NFormModal.d.ts +75 -0
  24. package/lib/components/NFormModal.js +59 -0
  25. package/lib/components/NIconButton.d.ts +83 -0
  26. package/lib/components/NIconButton.js +88 -0
  27. package/lib/components/NIconCircle.d.ts +49 -0
  28. package/lib/components/NIconCircle.js +67 -0
  29. package/lib/components/NInput.d.ts +94 -0
  30. package/lib/components/NInput.js +110 -0
  31. package/lib/components/NInputPhone.d.ts +58 -0
  32. package/lib/components/NInputPhone.js +47 -0
  33. package/lib/components/NInputSelect.d.ts +103 -0
  34. package/lib/components/NInputSelect.js +115 -0
  35. package/lib/components/NInputSuggestion.d.ts +79 -0
  36. package/lib/components/NInputSuggestion.js +64 -0
  37. package/lib/components/NLink.d.ts +47 -0
  38. package/lib/components/NLink.js +67 -0
  39. package/lib/components/NList.d.ts +37 -0
  40. package/lib/components/NList.js +40 -0
  41. package/lib/components/NLoadingIndicator.d.ts +29 -0
  42. package/lib/components/NLoadingIndicator.js +54 -0
  43. package/lib/components/NModal.d.ts +133 -0
  44. package/lib/components/NModal.js +235 -0
  45. package/{src/lib → lib}/components/NPagination.css +1 -1
  46. package/lib/components/NPagination.d.ts +37 -0
  47. package/lib/components/NPagination.js +105 -0
  48. package/lib/components/NSearchbar.d.ts +39 -0
  49. package/lib/components/NSearchbar.js +64 -0
  50. package/lib/components/NSearchbarList.d.ts +33 -0
  51. package/lib/components/NSearchbarList.js +41 -0
  52. package/lib/components/NSelect.d.ts +82 -0
  53. package/lib/components/NSelect.js +101 -0
  54. package/lib/components/NSuggestionList.d.ts +153 -0
  55. package/lib/components/NSuggestionList.js +160 -0
  56. package/{src/lib → lib}/components/NTable.css +1 -1
  57. package/lib/components/NTable.d.ts +97 -0
  58. package/lib/components/NTable.js +128 -0
  59. package/lib/components/NTableAction.d.ts +30 -0
  60. package/lib/components/NTableAction.js +50 -0
  61. package/lib/components/NTextArea.d.ts +96 -0
  62. package/lib/components/NTextArea.js +133 -0
  63. package/{src/lib → lib}/components/NTooltip.css +1 -1
  64. package/lib/components/NTooltip.d.ts +152 -0
  65. package/lib/components/NTooltip.js +241 -0
  66. package/lib/components/NValInput.d.ts +156 -0
  67. package/lib/components/NValInput.js +113 -0
  68. package/lib/components/ValidatedForm.d.ts +39 -0
  69. package/lib/components/ValidatedForm.js +35 -0
  70. package/{src/lib/i18n/index.ts → lib/i18n/index.d.ts} +9 -23
  71. package/lib/i18n/index.js +31 -0
  72. package/lib/index.d.ts +2 -0
  73. package/lib/index.js +2 -0
  74. package/lib/utils/breakpoints.d.ts +18 -0
  75. package/lib/utils/breakpoints.js +40 -0
  76. package/lib/utils/component.d.ts +57 -0
  77. package/lib/utils/component.js +79 -0
  78. package/lib/utils/deferred.d.ts +13 -0
  79. package/lib/utils/deferred.js +17 -0
  80. package/lib/utils/identifiable.d.ts +56 -0
  81. package/lib/utils/identifiable.js +81 -0
  82. package/lib/utils/stringMaxLength.d.ts +14 -0
  83. package/lib/utils/stringMaxLength.js +23 -0
  84. package/lib/utils/tailwind.d.ts +4 -0
  85. package/lib/utils/tailwind.js +1 -0
  86. package/lib/utils/utils.d.ts +47 -0
  87. package/lib/utils/utils.js +56 -0
  88. package/{src/lib/utils/vModel.ts → lib/utils/vModel.d.ts} +48 -126
  89. package/lib/utils/vModel.js +224 -0
  90. package/lib/utils/validation.d.ts +90 -0
  91. package/lib/utils/validation.js +147 -0
  92. package/lib/utils/vue.d.ts +13 -0
  93. package/lib/utils/vue.js +21 -0
  94. package/package.json +6 -2
  95. package/.github/workflows/build.yml +0 -26
  96. package/.github/workflows/deploy-demo.yml +0 -46
  97. package/.github/workflows/deploy-lib.yml +0 -59
  98. package/.gitlab-ci.yml +0 -57
  99. package/.nvmrc +0 -1
  100. package/.prettierrc +0 -8
  101. package/.vscode/extensions.json +0 -10
  102. package/.vscode/launch.json +0 -23
  103. package/.vscode/settings.json +0 -13
  104. package/babel.config.json +0 -3
  105. package/env.d.ts +0 -15
  106. package/eslint.config.cjs +0 -27
  107. package/index.html +0 -13
  108. package/postcss.config.js +0 -3
  109. package/public/favicon.ico +0 -0
  110. package/scripts/build-lib.sh +0 -52
  111. package/scripts/sync-node-types.js +0 -70
  112. package/src/demo/App.css +0 -53
  113. package/src/demo/App.tsx +0 -5
  114. package/src/demo/components/ColorGrid.tsx +0 -26
  115. package/src/demo/components/ComponentGrid.tsx +0 -26
  116. package/src/demo/components/ComponentSection.tsx +0 -30
  117. package/src/demo/components/VariantSection.tsx +0 -18
  118. package/src/demo/i18n/de.ts +0 -7
  119. package/src/demo/i18n/en.ts +0 -7
  120. package/src/demo/i18n/index.ts +0 -24
  121. package/src/demo/main.ts +0 -13
  122. package/src/demo/router/index.ts +0 -21
  123. package/src/demo/views/HomeView.tsx +0 -94
  124. package/src/demo/views/NavigationView.tsx +0 -43
  125. package/src/demo/views/presentation/AlertView.tsx +0 -40
  126. package/src/demo/views/presentation/BadgeView.tsx +0 -61
  127. package/src/demo/views/presentation/BreadcrumbView.tsx +0 -52
  128. package/src/demo/views/presentation/ButtonView.tsx +0 -49
  129. package/src/demo/views/presentation/CheckboxView.tsx +0 -59
  130. package/src/demo/views/presentation/DropdownView.tsx +0 -59
  131. package/src/demo/views/presentation/DropzoneView.tsx +0 -39
  132. package/src/demo/views/presentation/IconButtonView.tsx +0 -47
  133. package/src/demo/views/presentation/IconCircleView.tsx +0 -38
  134. package/src/demo/views/presentation/InputView.tsx +0 -179
  135. package/src/demo/views/presentation/LinkView.tsx +0 -60
  136. package/src/demo/views/presentation/ListView.tsx +0 -29
  137. package/src/demo/views/presentation/LoadingIndicatorView.tsx +0 -38
  138. package/src/demo/views/presentation/ModalView.tsx +0 -210
  139. package/src/demo/views/presentation/PaginationView.tsx +0 -25
  140. package/src/demo/views/presentation/SearchbarView.tsx +0 -80
  141. package/src/demo/views/presentation/TableView.tsx +0 -146
  142. package/src/demo/views/presentation/TooltipView.tsx +0 -92
  143. package/src/lib/components/NAlert.tsx +0 -85
  144. package/src/lib/components/NBadge.tsx +0 -75
  145. package/src/lib/components/NBreadcrub.tsx +0 -97
  146. package/src/lib/components/NButton.tsx +0 -82
  147. package/src/lib/components/NCheckbox.tsx +0 -55
  148. package/src/lib/components/NCheckboxLabel.tsx +0 -51
  149. package/src/lib/components/NCrudModal.tsx +0 -133
  150. package/src/lib/components/NDialog.tsx +0 -182
  151. package/src/lib/components/NDropdown.tsx +0 -169
  152. package/src/lib/components/NDropzone.tsx +0 -265
  153. package/src/lib/components/NForm.tsx +0 -32
  154. package/src/lib/components/NFormModal.tsx +0 -66
  155. package/src/lib/components/NIconButton.tsx +0 -92
  156. package/src/lib/components/NIconCircle.tsx +0 -78
  157. package/src/lib/components/NInput.tsx +0 -139
  158. package/src/lib/components/NInputPhone.tsx +0 -53
  159. package/src/lib/components/NInputSelect.tsx +0 -126
  160. package/src/lib/components/NInputSuggestion.tsx +0 -80
  161. package/src/lib/components/NLink.tsx +0 -82
  162. package/src/lib/components/NList.tsx +0 -67
  163. package/src/lib/components/NLoadingIndicator.tsx +0 -63
  164. package/src/lib/components/NModal.tsx +0 -243
  165. package/src/lib/components/NPagination.tsx +0 -131
  166. package/src/lib/components/NSearchbar.tsx +0 -78
  167. package/src/lib/components/NSearchbarList.tsx +0 -47
  168. package/src/lib/components/NSelect.tsx +0 -128
  169. package/src/lib/components/NSuggestionList.tsx +0 -216
  170. package/src/lib/components/NTable.tsx +0 -247
  171. package/src/lib/components/NTableAction.tsx +0 -49
  172. package/src/lib/components/NTextArea.tsx +0 -159
  173. package/src/lib/components/NTooltip.tsx +0 -289
  174. package/src/lib/components/NValInput.tsx +0 -163
  175. package/src/lib/components/ValidatedForm.ts +0 -71
  176. package/src/lib/components/__tests__/NButton.spec.tsx +0 -26
  177. package/src/lib/components/__tests__/NCheckbox.spec.tsx +0 -39
  178. package/src/lib/index.ts +0 -2
  179. package/src/lib/jsx.d.ts +0 -13
  180. package/src/lib/utils/__tests__/identifiable.spec.ts +0 -72
  181. package/src/lib/utils/__tests__/validation.spec.ts +0 -92
  182. package/src/lib/utils/breakpoints.ts +0 -47
  183. package/src/lib/utils/component.tsx +0 -131
  184. package/src/lib/utils/deferred.ts +0 -28
  185. package/src/lib/utils/identifiable.ts +0 -87
  186. package/src/lib/utils/stringMaxLength.ts +0 -25
  187. package/src/lib/utils/tailwind.ts +0 -41
  188. package/src/lib/utils/utils.ts +0 -90
  189. package/src/lib/utils/validation.ts +0 -189
  190. package/src/lib/utils/vue.ts +0 -25
  191. package/tsconfig.config.json +0 -9
  192. package/tsconfig.demo.json +0 -19
  193. package/tsconfig.json +0 -16
  194. package/tsconfig.lib.json +0 -19
  195. package/tsconfig.vitest.json +0 -8
  196. package/vite.config.ts +0 -30
  197. /package/{src/lib → lib}/components/NInput.css +0 -0
  198. /package/{src/lib → lib}/components/NLoadingIndicator.css +0 -0
  199. /package/{src/lib → lib}/i18n/de/vue-collection.json +0 -0
  200. /package/{src/lib → lib}/i18n/en/vue-collection.json +0 -0
@@ -1,189 +0,0 @@
1
- import { trsl } from '../i18n'
2
-
3
- export type ValidationResultValid = {
4
- isValid: true
5
- errorMessage?: undefined
6
- }
7
-
8
- export type ValidationResultInvalid = {
9
- isValid: false
10
- errorMessage: string
11
- }
12
-
13
- export type InputValue = string | null | undefined
14
- export type ValidationResult = ValidationResultValid | ValidationResultInvalid
15
-
16
- /**
17
- * A `ValidationRule` checks an input for a criteria and returns either
18
- * a {@link ValidationResultValid} or a {@link ValidationResultInvalid}.
19
- * A falsy input-value should always return a valid result to not interfere
20
- * with the {@link required} rule.
21
- */
22
- export type ValidationRule = (input: InputValue) => ValidationResult
23
-
24
- /**
25
- * Creates a valid result.
26
- */
27
- export function validResult(): ValidationResultValid {
28
- return { isValid: true }
29
- }
30
-
31
- /**
32
- * Creates an invalid result with the provided error message.
33
- */
34
- export function invalidResult(errorMessage: string): ValidationResultInvalid {
35
- return { isValid: false, errorMessage }
36
- }
37
-
38
- const TRANSLATION_KEY_BASE = 'vue-collection.validation.rules'
39
- function invalidResultInternal(key: string, params?: Record<string, unknown>): ValidationResultInvalid {
40
- return invalidResult(trsl(`${TRANSLATION_KEY_BASE}.${key}`, params))
41
- }
42
-
43
- /**
44
- * Validates a given input with the specified rules.
45
- * The rules are evaluated in the order they're in the array.
46
- * The {@link ValidationResult} will either contain the errorMessage of the failed rule
47
- * or a valid result if all rules passed.
48
- * @param input the input to validate.
49
- * @param rules the rules which should be vaildated, in the order of priority.
50
- * @returns an object containing the result of the validation.
51
- */
52
- export function validate(input: InputValue, rules: ValidationRule[]): ValidationResult {
53
- for (const rule of rules) {
54
- const validationResult = rule(input)
55
- if (!validationResult.isValid) return validationResult
56
- }
57
- return validResult()
58
- }
59
-
60
- /*
61
- * ---------- Validation Rules ----------
62
- */
63
-
64
- /**
65
- * This rule expects the trimmed input-value to be truthy.
66
- */
67
- export const required: ValidationRule = input => {
68
- const trimmed = input?.trim()
69
- if (trimmed) return validResult()
70
- else return invalidResultInternal('required')
71
- }
72
-
73
- /**
74
- * This rule expects the input to be an integer.
75
- */
76
- export const integer: ValidationRule = input => {
77
- if (!input || Number.isInteger(+input)) return validResult()
78
- else return invalidResultInternal('integer')
79
- }
80
-
81
- /**
82
- * This rule expects the input to be in the specified length range. An empty input
83
- * will always be allowed by this rule to not interefere with the {@link required} rule.
84
- * @param min The minimum length of the string.
85
- * @param max The maximum length of the string.
86
- */
87
- export function length(min: number | undefined, max: number | undefined): ValidationRule {
88
- return input => {
89
- if (!input) return validResult()
90
-
91
- if (min !== undefined && max !== undefined && !(min <= input.length && input.length <= max))
92
- return invalidResultInternal('length.min-max', { min, max })
93
- else if (min !== undefined && !(min <= input.length)) return invalidResultInternal('length.min', { min })
94
- else if (max !== undefined && !(input.length <= max)) return invalidResultInternal('length.max', { max })
95
-
96
- return validResult()
97
- }
98
- }
99
-
100
- /**
101
- * This rule expects the input to be a number in the specified range.
102
- * @param min the lower bound, if `undefined` there is no lower bound.
103
- * @param max the upper bound, if `undefined` there is no upper bound.
104
- */
105
- export function numberRange(min: number | undefined, max: number | undefined): ValidationRule {
106
- return input => {
107
- if (!input) return validResult()
108
-
109
- const parsed = Number.parseFloat(input)
110
- if (Number.isNaN(parsed)) return invalidResultInternal('number-range.nan')
111
-
112
- if (min !== undefined && max !== undefined && !(min <= parsed && parsed <= max))
113
- return invalidResultInternal('number-range.min-max', { min, max })
114
- else if (min !== undefined && !(min <= parsed)) return invalidResultInternal('number-range.min', { min })
115
- else if (max !== undefined && !(parsed <= max)) return invalidResultInternal('number-range.max', { max })
116
-
117
- return validResult()
118
- }
119
- }
120
-
121
- export const VALIDATION_FORMAT_EMAIL = /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/
122
-
123
- /**
124
- * This rule expects the input-value to be a valid email adress matching {@link VALIDATION_FORMAT_EMAIL}.
125
- */
126
- export const email: ValidationRule = input => {
127
- if (!input || VALIDATION_FORMAT_EMAIL.test(input)) return validResult()
128
- else return invalidResultInternal('email')
129
- }
130
-
131
- export const VALIDATION_FORMAT_PASSWORD = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$^+\-=!*()@%&?]).{8,}$/
132
-
133
- /**
134
- * This rule expects the input-value to be a password matching {@link VALIDATION_FORMAT_PASSWORD}.
135
- */
136
- export const password: ValidationRule = input => {
137
- if (!input || VALIDATION_FORMAT_PASSWORD.test(input)) return validResult()
138
- else if (input.length < 8) return invalidResultInternal('password.to-short')
139
- else if (!/[a-z]+/.test(input)) return invalidResultInternal('password.no-lowercase')
140
- else if (!/[A-Z]+/.test(input)) return invalidResultInternal('password.no-uppercase')
141
- else if (!/\d+/.test(input)) return invalidResultInternal('password.no-digits')
142
- else if (!/[#$^+\-=!*()@%&?]+/.test(input)) return invalidResultInternal('password.no-special-chars')
143
- else return invalidResultInternal('password.unknown')
144
- }
145
-
146
- /**
147
- * This rule expects the input-value to match another (input-) value.
148
- * In difference to most other rules, this rule does not always return a valid result,
149
- * when the input is falsy. The input is always required to match the other value.
150
- * @param other the other value to match
151
- */
152
- export function matches(other: string | null | undefined): ValidationRule {
153
- return input => {
154
- if (input === other) return validResult()
155
- else return invalidResultInternal('matches')
156
- }
157
- }
158
-
159
- /**
160
- * This rule expects the input-value to match one option in an array.
161
- * @param options the options which the input can match
162
- */
163
- export function option(options: string[]): ValidationRule {
164
- return input => {
165
- if (!input || options.includes(input || '')) return validResult()
166
- else return invalidResultInternal('option')
167
- }
168
- }
169
-
170
- /**
171
- * This rule expects the input-value to match the regex pattern
172
- * @param pattern the pattern the input should match.
173
- */
174
- export function regex(pattern: RegExp): ValidationRule {
175
- return input => {
176
- if (!input || pattern.test(input || '')) return validResult()
177
- else return invalidResultInternal('regex')
178
- }
179
- }
180
-
181
- /**
182
- * This rule can be used if the validation logic happens somewhere else.
183
- * When `isValid = true` is passed, the function will return a valid result,
184
- * otherwise it will return the invalid result with the passed `errorKey`.
185
- * Like always, a falsy input is always valid to not interefere with the {@link required} rule.
186
- */
187
- export function external(isValid: boolean, errorMessage: string): ValidationRule {
188
- return input => (!input || isValid ? validResult() : invalidResult(errorMessage))
189
- }
@@ -1,25 +0,0 @@
1
- import { type Ref, watch, type ComputedRef } from 'vue'
2
-
3
- /**
4
- * Creates a watcher on the updater function, which sets the value of the ref on every change.
5
- * @param ref the ref to update
6
- * @param updater the updater funtion which provides the updates
7
- */
8
- export function updateWith<T>(ref: Ref<T>, updater: () => T): void {
9
- watch(
10
- updater,
11
- newValue => {
12
- ref.value = newValue
13
- },
14
- { immediate: true }
15
- )
16
- }
17
-
18
- /**
19
- * Conveience function to create a watcher for a ref
20
- * @param ref the ref to watch
21
- * @param onChange the function, which is executed on change of a value
22
- */
23
- export function watchRef<T>(ref: Ref<T> | ComputedRef<T>, onChange: (newValue: T) => void): void {
24
- watch(() => ref.value, onChange)
25
- }
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "@vue/tsconfig/tsconfig.json",
3
- "include": ["vite.config.*", "vitest.config.*", "cypress.config.*"],
4
- "compilerOptions": {
5
- "composite": true,
6
- "types": ["node"],
7
- "noEmit": false
8
- }
9
- }
@@ -1,19 +0,0 @@
1
- {
2
- "extends": "@vue/tsconfig/tsconfig.dom.json",
3
- // all files must be included, because demo uses lib.
4
- "include": ["env.d.ts", "src/**/*", "src/**/*.json"],
5
- "exclude": ["src/**/__tests__/*"],
6
- "compilerOptions": {
7
- "composite": true,
8
- "baseUrl": ".",
9
- "paths": {
10
- "@/*": ["./src/*"]
11
- },
12
- "jsx": "preserve",
13
- "jsxImportSource": "vue",
14
- "noImplicitAny": false,
15
- "noUncheckedIndexedAccess": false,
16
- "skipLibCheck": true,
17
- "noEmit": false
18
- }
19
- }
package/tsconfig.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- "references": [
3
- {
4
- "path": "./tsconfig.config.json"
5
- },
6
- {
7
- "path": "./tsconfig.demo.json"
8
- },
9
- {
10
- "path": "./tsconfig.lib.json"
11
- },
12
- {
13
- "path": "./tsconfig.vitest.json"
14
- }
15
- ]
16
- }
package/tsconfig.lib.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "extends": "@vue/tsconfig/tsconfig.dom.json",
3
- "include": ["src/lib/**/*", "src/lib/**/*.json"],
4
- "exclude": ["src/**/__tests__/*"],
5
- "compilerOptions": {
6
- "composite": true,
7
- // don't allow @ alias inside library
8
- "paths": {},
9
- "outDir": "lib",
10
- "jsx": "preserve",
11
- "jsxImportSource": "vue",
12
- "noImplicitAny": false,
13
- "downlevelIteration": true,
14
- "skipLibCheck": true,
15
- "allowImportingTsExtensions": false,
16
- "noEmit": false,
17
- "declaration": true
18
- }
19
- }
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "./tsconfig.lib.json",
3
- "exclude": [],
4
- "compilerOptions": {
5
- "composite": true,
6
- "types": ["node", "jsdom"]
7
- }
8
- }
package/vite.config.ts DELETED
@@ -1,30 +0,0 @@
1
- import { fileURLToPath, URL } from 'url'
2
- import { defineConfig } from 'vite'
3
- import tailwindcss from '@tailwindcss/vite'
4
- import vue from '@vitejs/plugin-vue'
5
- import vueJsx from '@vitejs/plugin-vue-jsx'
6
- import vueI18n from '@intlify/unplugin-vue-i18n/vite'
7
- import { resolve, dirname } from 'path'
8
-
9
- const __dirname = dirname(fileURLToPath(import.meta.url))
10
-
11
- // https://vitejs.dev/config/
12
- export default defineConfig({
13
- plugins: [
14
- tailwindcss(),
15
- vue(),
16
- vueJsx(),
17
- vueI18n({
18
- compositionOnly: true,
19
- runtimeOnly: false,
20
- fullInstall: false,
21
- include: resolve(__dirname, 'src/i18n/*'),
22
- }),
23
- ],
24
- resolve: {
25
- alias: {
26
- '@': fileURLToPath(new URL('./src', import.meta.url)),
27
- },
28
- },
29
- base: process.env.VITE_BASE_PATH,
30
- })
File without changes
File without changes
File without changes