@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,25 @@
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
+ }
@@ -0,0 +1,38 @@
1
+ const colors = require('tailwindcss/colors')
2
+
3
+ const unresolvedConfig = require('tailwindcss/defaultConfig')
4
+ const resolveConfig = require('tailwindcss/resolveConfig')
5
+ const config = resolveConfig(unresolvedConfig)
6
+
7
+ const allShades = '50|100|200|300|400|500|600|700|800|900'
8
+ const usedColors = 'default|primary|secondary|green|red|yellow|blue'
9
+ const smallSizes = '1|2|3|4|5|6|7|8|9|10|11|12|14|16|18|20'
10
+
11
+ /** @type {import('tailwindcss').Config} */
12
+ module.exports = {
13
+ content: ['./src/**/*.{tsx,ts}'],
14
+ safelist: [
15
+ {
16
+ pattern: new RegExp(`^(bg|text)-(${usedColors})-(${allShades})$`),
17
+ variants: ['hover'],
18
+ },
19
+ {
20
+ pattern: new RegExp(`^ring-(${usedColors})-(${allShades})$`),
21
+ variants: ['focus-visible'],
22
+ },
23
+ {
24
+ pattern: new RegExp(`^(w|h)-(${smallSizes})$`),
25
+ },
26
+ ],
27
+ theme: {
28
+ extend: {
29
+ colors: {
30
+ default: colors.slate,
31
+ primary: colors.violet,
32
+ secondary: colors.fuchsia,
33
+ },
34
+ minHeight: config.theme.spacing,
35
+ },
36
+ },
37
+ plugins: [require('@tailwindcss/forms')],
38
+ }
@@ -0,0 +1,9 @@
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
+ }
@@ -0,0 +1,19 @@
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 ADDED
@@ -0,0 +1,16 @@
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
+ }
@@ -0,0 +1,18 @@
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
+ "noEmit": false,
16
+ "declaration": true
17
+ }
18
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./tsconfig.lib.json",
3
+ "exclude": [],
4
+ "compilerOptions": {
5
+ "composite": true,
6
+ "types": ["node", "jsdom"]
7
+ }
8
+ }
@@ -1,7 +1,7 @@
1
1
  import { type ComputedRef } from 'vue';
2
2
  export type TWBreakpoint = 'sm' | 'md' | 'lg' | 'xl' | '2xl';
3
3
  export declare const breakpoints: Readonly<Record<TWBreakpoint, number>>;
4
- export declare const bodyWidth: import("vue").Ref<number>;
4
+ export declare const bodyWidth: import("vue").Ref<number, number>;
5
5
  /**
6
6
  * This function has to be called once in the app two ensure that the breakpoint utilities actually update.
7
7
  * It sets a `window.onresize` listener.
@@ -17,9 +17,7 @@ export type ExtractedProps<T extends Props> = Readonly<LooseRequired<Readonly<Ex
17
17
  * @param setup the setup function, which will be called when the component is mounted.
18
18
  * @returns the created vue-component.
19
19
  */
20
- export declare function createComponent<T extends Props>(name: string, props: T, setup: (props: ExtractedProps<T>, context: SetupContext<never[]>) => RenderFunction | Promise<RenderFunction>): import("vue").DefineComponent<T, RenderFunction, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, never[], never, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<T extends import("vue").ComponentPropsOptions<{
21
- [x: string]: unknown;
22
- }> ? ExtractPropTypes<T> : T> & {}, import("vue").ExtractDefaultPropTypes<T>>;
20
+ export declare function createComponent<T extends Props>(name: string, props: T, setup: (props: ExtractedProps<T>, context: SetupContext<never[]>) => RenderFunction | Promise<RenderFunction>): import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
23
21
  /**
24
22
  * When using this function, the created component will make available all props
25
23
  * specifiedin `slotPropKeys` as slot. In this way, they can be used by either setting
@@ -27,9 +25,7 @@ export declare function createComponent<T extends Props>(name: string, props: T,
27
25
  * components (in `.vue` files), because they are dependent on slots.
28
26
  * @see {@link createComponent}
29
27
  */
30
- export declare function createComponentWithSlots<T extends Props>(name: string, props: T, slotPropKeys: SlotPropsKeys<ExtractedProps<T>>, setup: (props: ExtractedProps<T>, context: SetupContext<never[]>) => RenderFunction | Promise<RenderFunction>): import("vue").DefineComponent<T, RenderFunction, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, never[], never, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<T extends import("vue").ComponentPropsOptions<{
31
- [x: string]: unknown;
32
- }> ? ExtractPropTypes<T> : T> & {}, import("vue").ExtractDefaultPropTypes<T>>;
28
+ export declare function createComponentWithSlots<T extends Props>(name: string, props: T, slotPropKeys: SlotPropsKeys<ExtractedProps<T>>, setup: (props: ExtractedProps<T>, context: SetupContext<never[]>) => RenderFunction | Promise<RenderFunction>): import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
33
29
  /**
34
30
  * Views should be created using this helper function. Views are special components, which don't have props.
35
31
  * They are often the parent objects in a view hierarchy and contain many components.
@@ -38,7 +34,7 @@ export declare function createComponentWithSlots<T extends Props>(name: string,
38
34
  * @param setup the setup function, which will be called when the component is mounted.
39
35
  * @returns the created vue-component.
40
36
  */
41
- export declare function createView(name: string, setup: (context: SetupContext<never[]>) => RenderFunction | Promise<RenderFunction>): import("vue").DefineComponent<{}, RenderFunction, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, never[], never, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{}>> & {}, {}>;
37
+ export declare function createView(name: string, setup: (context: SetupContext<never[]>) => RenderFunction | Promise<RenderFunction>): import("vue").DefineComponent<{}, RenderFunction, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, never[], never, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
42
38
  /**
43
39
  * Extracts props from another prop object and returns a reactive object with the specified props.
44
40
  * @param props the props to extract from
@@ -1,5 +1,4 @@
1
- import { createVNode as _createVNode, Fragment as _Fragment } from "vue";
2
- import { defineComponent, reactive, toRef, toRefs, ref } from 'vue';
1
+ import { defineComponent, reactive, toRef, toRefs, ref, Fragment as _Fragment, createVNode as _createVNode } from 'vue';
3
2
  /**
4
3
  * Components should be created using this helper function.
5
4
  * It only takes three arguments, the name and the props of the component and the setup function.
@@ -11,6 +10,10 @@ import { defineComponent, reactive, toRef, toRefs, ref } from 'vue';
11
10
  * @returns the created vue-component.
12
11
  */
13
12
  export function createComponent(name, props, setup) {
13
+ // Vue 3.5's defineComponent has strict type requirements that don't align with our simplified API.
14
+ // The type assertion is necessary because the generic setup function signature doesn't match
15
+ // Vue's complex overloaded defineComponent types, even though the runtime behavior is correct.
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
17
  return defineComponent({
15
18
  name,
16
19
  props,
@@ -21,7 +21,11 @@ function contains(array, id) {
21
21
  }
22
22
  function insertSingle(baseArray, insertItem) {
23
23
  const index = baseArray.findIndex(item => item.id === insertItem.id);
24
- index === -1 ? baseArray.push(insertItem) : baseArray.splice(index, 1, insertItem);
24
+ if (index === -1) {
25
+ baseArray.push(insertItem);
26
+ } else {
27
+ baseArray.splice(index, 1, insertItem);
28
+ }
25
29
  }
26
30
  /**
27
31
  * Inserts the items into the given array, replacing items with the same `id`.
package/vite.config.ts ADDED
@@ -0,0 +1,28 @@
1
+ import { fileURLToPath, URL } from 'url'
2
+ import { defineConfig } from 'vite'
3
+ import vue from '@vitejs/plugin-vue'
4
+ import vueJsx from '@vitejs/plugin-vue-jsx'
5
+ import vueI18n from '@intlify/unplugin-vue-i18n/vite'
6
+ import { resolve, dirname } from 'path'
7
+
8
+ const __dirname = dirname(fileURLToPath(import.meta.url))
9
+
10
+ // https://vitejs.dev/config/
11
+ export default defineConfig({
12
+ plugins: [
13
+ vue(),
14
+ vueJsx(),
15
+ vueI18n({
16
+ compositionOnly: true,
17
+ runtimeOnly: false,
18
+ fullInstall: false,
19
+ include: resolve(__dirname, 'src/i18n/*'),
20
+ }),
21
+ ],
22
+ resolve: {
23
+ alias: {
24
+ '@': fileURLToPath(new URL('./src', import.meta.url)),
25
+ },
26
+ },
27
+ base: process.env.VITE_BASE_PATH,
28
+ })