@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.
- package/.github/workflows/build.yml +26 -0
- package/.github/workflows/deploy-demo.yml +46 -0
- package/.github/workflows/deploy-lib.yml +59 -0
- package/.gitlab-ci.yml +57 -0
- package/.nvmrc +1 -0
- package/.prettierrc +8 -0
- package/.vscode/extensions.json +10 -0
- package/.vscode/launch.json +23 -0
- package/.vscode/settings.json +13 -0
- package/babel.config.json +3 -0
- package/components/NAlert.d.ts +1 -44
- package/components/NBadge.d.ts +1 -133
- package/components/NBreadcrub.d.ts +2 -106
- package/components/NBreadcrub.js +1 -1
- package/components/NButton.d.ts +2 -118
- package/components/NCheckbox.d.ts +1 -32
- package/components/NCheckboxLabel.d.ts +1 -45
- package/components/NCheckboxLabel.js +1 -1
- package/components/NCrudModal.d.ts +7 -251
- package/components/NCrudModal.js +1 -1
- package/components/NDialog.d.ts +1 -110
- package/components/NDialog.js +1 -1
- package/components/NDropdown.d.ts +1 -69
- package/components/NDropdown.js +1 -1
- package/components/NDropzone.d.ts +1 -115
- package/components/NDropzone.js +1 -1
- package/components/NForm.d.ts +1 -23
- package/components/NFormModal.d.ts +7 -151
- package/components/NIconButton.d.ts +3 -159
- package/components/NIconButton.js +1 -1
- package/components/NIconCircle.d.ts +1 -87
- package/components/NInput.d.ts +1 -164
- package/components/NInput.js +1 -1
- package/components/NInputPhone.d.ts +2 -114
- package/components/NInputPhone.js +1 -1
- package/components/NInputSelect.d.ts +2 -187
- package/components/NInputSelect.js +1 -1
- package/components/NInputSuggestion.d.ts +2 -155
- package/components/NInputSuggestion.js +1 -1
- package/components/NLink.d.ts +6 -70
- package/components/NLink.js +8 -1
- package/components/NList.d.ts +1 -43
- package/components/NList.js +1 -1
- package/components/NLoadingIndicator.d.ts +1 -49
- package/components/NModal.d.ts +12 -250
- package/components/NModal.js +15 -9
- package/components/NPagination.d.ts +1 -63
- package/components/NSearchbar.d.ts +1 -56
- package/components/NSearchbarList.d.ts +3 -63
- package/components/NSearchbarList.js +1 -1
- package/components/NSelect.d.ts +2 -148
- package/components/NSelect.js +1 -1
- package/components/NSuggestionList.d.ts +3 -126
- package/components/NSuggestionList.js +5 -2
- package/components/NTable.d.ts +1 -85
- package/components/NTable.js +12 -6
- package/components/NTableAction.d.ts +2 -46
- package/components/NTableAction.js +1 -1
- package/components/NTextArea.d.ts +2 -181
- package/components/NTextArea.js +1 -1
- package/components/NTooltip.d.ts +1 -105
- package/components/NTooltip.js +1 -1
- package/components/NValInput.d.ts +7 -182
- package/components/NValInput.js +1 -1
- package/env.d.ts +15 -0
- package/eslint.config.cjs +29 -0
- package/index.html +13 -0
- package/package.json +21 -19
- package/postcss.config.js +6 -0
- package/public/favicon.ico +0 -0
- package/scripts/build-lib.sh +52 -0
- package/scripts/sync-node-types.js +70 -0
- package/src/demo/App.css +9 -0
- package/src/demo/App.tsx +5 -0
- package/src/demo/components/ColorGrid.tsx +26 -0
- package/src/demo/components/ComponentGrid.tsx +26 -0
- package/src/demo/components/ComponentSection.tsx +30 -0
- package/src/demo/components/VariantSection.tsx +18 -0
- package/src/demo/i18n/de.ts +7 -0
- package/src/demo/i18n/en.ts +7 -0
- package/src/demo/i18n/index.ts +24 -0
- package/src/demo/main.ts +13 -0
- package/src/demo/router/index.ts +21 -0
- package/src/demo/views/HomeView.tsx +94 -0
- package/src/demo/views/NavigationView.tsx +43 -0
- package/src/demo/views/presentation/AlertView.tsx +40 -0
- package/src/demo/views/presentation/BadgeView.tsx +61 -0
- package/src/demo/views/presentation/BreadcrumbView.tsx +52 -0
- package/src/demo/views/presentation/ButtonView.tsx +49 -0
- package/src/demo/views/presentation/CheckboxView.tsx +59 -0
- package/src/demo/views/presentation/DropdownView.tsx +59 -0
- package/src/demo/views/presentation/DropzoneView.tsx +39 -0
- package/src/demo/views/presentation/IconButtonView.tsx +47 -0
- package/src/demo/views/presentation/IconCircleView.tsx +38 -0
- package/src/demo/views/presentation/InputView.tsx +179 -0
- package/src/demo/views/presentation/LinkView.tsx +60 -0
- package/src/demo/views/presentation/ListView.tsx +29 -0
- package/src/demo/views/presentation/LoadingIndicatorView.tsx +38 -0
- package/src/demo/views/presentation/ModalView.tsx +210 -0
- package/src/demo/views/presentation/PaginationView.tsx +25 -0
- package/src/demo/views/presentation/SearchbarView.tsx +80 -0
- package/src/demo/views/presentation/TableView.tsx +146 -0
- package/src/demo/views/presentation/TooltipView.tsx +86 -0
- package/src/lib/components/NAlert.tsx +85 -0
- package/src/lib/components/NBadge.tsx +75 -0
- package/src/lib/components/NBreadcrub.tsx +97 -0
- package/src/lib/components/NButton.tsx +80 -0
- package/src/lib/components/NCheckbox.tsx +55 -0
- package/src/lib/components/NCheckboxLabel.tsx +51 -0
- package/src/lib/components/NCrudModal.tsx +133 -0
- package/src/lib/components/NDialog.tsx +182 -0
- package/src/lib/components/NDropdown.tsx +167 -0
- package/src/lib/components/NDropzone.tsx +265 -0
- package/src/lib/components/NForm.tsx +32 -0
- package/src/lib/components/NFormModal.tsx +66 -0
- package/src/lib/components/NIconButton.tsx +92 -0
- package/src/lib/components/NIconCircle.tsx +78 -0
- package/src/lib/components/NInput.css +11 -0
- package/src/lib/components/NInput.tsx +139 -0
- package/src/lib/components/NInputPhone.tsx +53 -0
- package/src/lib/components/NInputSelect.tsx +126 -0
- package/src/lib/components/NInputSuggestion.tsx +80 -0
- package/src/lib/components/NLink.tsx +82 -0
- package/src/lib/components/NList.tsx +67 -0
- package/src/lib/components/NLoadingIndicator.css +46 -0
- package/src/lib/components/NLoadingIndicator.tsx +63 -0
- package/src/lib/components/NModal.tsx +243 -0
- package/src/lib/components/NPagination.css +15 -0
- package/src/lib/components/NPagination.tsx +131 -0
- package/src/lib/components/NSearchbar.tsx +78 -0
- package/src/lib/components/NSearchbarList.tsx +47 -0
- package/src/lib/components/NSelect.tsx +128 -0
- package/src/lib/components/NSuggestionList.tsx +216 -0
- package/src/lib/components/NTable.css +3 -0
- package/src/lib/components/NTable.tsx +247 -0
- package/src/lib/components/NTableAction.tsx +49 -0
- package/src/lib/components/NTextArea.tsx +159 -0
- package/src/lib/components/NTooltip.css +37 -0
- package/src/lib/components/NTooltip.tsx +250 -0
- package/src/lib/components/NValInput.tsx +163 -0
- package/src/lib/components/ValidatedForm.ts +71 -0
- package/src/lib/components/__tests__/NButton.spec.tsx +26 -0
- package/src/lib/components/__tests__/NCheckbox.spec.tsx +39 -0
- package/src/lib/i18n/de/vue-collection.json +58 -0
- package/src/lib/i18n/en/vue-collection.json +58 -0
- package/src/lib/i18n/index.ts +54 -0
- package/src/lib/index.ts +2 -0
- package/src/lib/jsx.d.ts +13 -0
- package/src/lib/utils/__tests__/identifiable.spec.ts +72 -0
- package/src/lib/utils/__tests__/validation.spec.ts +92 -0
- package/src/lib/utils/breakpoints.ts +47 -0
- package/src/lib/utils/component.tsx +131 -0
- package/src/lib/utils/deferred.ts +28 -0
- package/src/lib/utils/identifiable.ts +87 -0
- package/src/lib/utils/stringMaxLength.ts +25 -0
- package/src/lib/utils/tailwind.ts +41 -0
- package/src/lib/utils/utils.ts +90 -0
- package/src/lib/utils/vModel.ts +260 -0
- package/src/lib/utils/validation.ts +189 -0
- package/src/lib/utils/vue.ts +25 -0
- package/tailwind.config.js +38 -0
- package/tsconfig.config.json +9 -0
- package/tsconfig.demo.json +19 -0
- package/tsconfig.json +16 -0
- package/tsconfig.lib.json +18 -0
- package/tsconfig.vitest.json +8 -0
- package/utils/breakpoints.d.ts +1 -1
- package/utils/component.d.ts +3 -7
- package/utils/component.js +5 -2
- package/utils/identifiable.js +5 -1
- 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,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,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
|
+
}
|
package/utils/breakpoints.d.ts
CHANGED
|
@@ -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.
|
package/utils/component.d.ts
CHANGED
|
@@ -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").
|
|
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").
|
|
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").
|
|
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
|
package/utils/component.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
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,
|
package/utils/identifiable.js
CHANGED
|
@@ -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
|
|
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
|
+
})
|