@naptics/vue-collection 0.1.4 → 0.1.6
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/components/NCrudModal.d.ts +0 -9
- package/components/NCrudModal.js +2 -2
- package/components/NDropdown.js +2 -2
- package/components/NFormModal.js +7 -7
- package/components/NInputSuggestion.d.ts +0 -12
- package/components/NModal.js +2 -2
- package/components/NSearchbarList.d.ts +12 -12
- package/components/NSuggestionList.js +2 -2
- package/components/NValInput.js +2 -2
- package/package.json +1 -1
- package/utils/component.js +6 -5
|
@@ -97,9 +97,6 @@ export declare const nCrudModalProps: {
|
|
|
97
97
|
readonly modal: PropType<(props: import("./NModal").ModalSlotProps) => JSX.Element>;
|
|
98
98
|
readonly header: PropType<() => JSX.Element>;
|
|
99
99
|
readonly footer: PropType<(props: import("./NModal").ModalSlotProps) => JSX.Element>;
|
|
100
|
-
/**
|
|
101
|
-
* The color of the remove-button.
|
|
102
|
-
*/
|
|
103
100
|
readonly value: PropType<boolean>;
|
|
104
101
|
readonly onUpdateValue: PropType<(newValue: boolean) => void>;
|
|
105
102
|
};
|
|
@@ -205,9 +202,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
205
202
|
readonly modal: PropType<(props: import("./NModal").ModalSlotProps) => JSX.Element>;
|
|
206
203
|
readonly header: PropType<() => JSX.Element>;
|
|
207
204
|
readonly footer: PropType<(props: import("./NModal").ModalSlotProps) => JSX.Element>;
|
|
208
|
-
/**
|
|
209
|
-
* The color of the remove-button.
|
|
210
|
-
*/
|
|
211
205
|
readonly value: PropType<boolean>;
|
|
212
206
|
readonly onUpdateValue: PropType<(newValue: boolean) => void>;
|
|
213
207
|
}, import("vue").RenderFunction, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, never[], never, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -307,9 +301,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
307
301
|
readonly modal: PropType<(props: import("./NModal").ModalSlotProps) => JSX.Element>;
|
|
308
302
|
readonly header: PropType<() => JSX.Element>;
|
|
309
303
|
readonly footer: PropType<(props: import("./NModal").ModalSlotProps) => JSX.Element>;
|
|
310
|
-
/**
|
|
311
|
-
* The color of the remove-button.
|
|
312
|
-
*/
|
|
313
304
|
readonly value: PropType<boolean>;
|
|
314
305
|
readonly onUpdateValue: PropType<(newValue: boolean) => void>;
|
|
315
306
|
}>> & {}, {
|
package/components/NCrudModal.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mergeProps as _mergeProps, createVNode as _createVNode } from "vue";
|
|
2
2
|
import { trsl } from '../i18n';
|
|
3
|
-
import {
|
|
3
|
+
import { createComponentWithSlots } from '../utils/component';
|
|
4
4
|
import { ref } from 'vue';
|
|
5
5
|
import NButton from './NButton';
|
|
6
6
|
import NDialog from './NDialog';
|
|
@@ -69,7 +69,7 @@ export const nCrudModalProps = {
|
|
|
69
69
|
* It has an integrated remove-button with a user-dialog to remove the editing element.
|
|
70
70
|
* When the dialog is accepted `onRemove` is called.
|
|
71
71
|
*/
|
|
72
|
-
export default
|
|
72
|
+
export default createComponentWithSlots('NCrudModal', nCrudModalProps, ['modal', 'footer', 'header'], (props, {
|
|
73
73
|
slots
|
|
74
74
|
}) => {
|
|
75
75
|
const removeDialog = ref();
|
package/components/NDropdown.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isVNode as _isVNode, createVNode as _createVNode } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { createComponentWithSlots } from '../utils/component';
|
|
3
3
|
import { computed, Transition } from 'vue';
|
|
4
4
|
import { RouterLink } from 'vue-router';
|
|
5
5
|
import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue';
|
|
@@ -42,7 +42,7 @@ export const nDropdownProps = {
|
|
|
42
42
|
* The `NDropdown` consists of a button and a panel with multiple actions.
|
|
43
43
|
* It is useful to group multiple actions together in one place.
|
|
44
44
|
*/
|
|
45
|
-
export default
|
|
45
|
+
export default createComponentWithSlots('NDropdown', nDropdownProps, ['button'], (props, {
|
|
46
46
|
slots
|
|
47
47
|
}) => {
|
|
48
48
|
const items = computed(() => {
|
package/components/NFormModal.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createVNode as _createVNode } from "vue";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { createComponentWithSlots } from '../utils/component';
|
|
3
|
+
import { computed } from 'vue';
|
|
4
4
|
import NForm from './NForm';
|
|
5
5
|
import NModal, { nModalProps } from './NModal';
|
|
6
6
|
export const nFormModalProps = {
|
|
@@ -31,11 +31,11 @@ export const nFormModalProps = {
|
|
|
31
31
|
* When submitting a `NFormModal` the form is first validated and
|
|
32
32
|
* only if the validation is succesful the `onOk` event is called.
|
|
33
33
|
*/
|
|
34
|
-
export default
|
|
34
|
+
export default createComponentWithSlots('NFormModal', nFormModalProps, ['modal', 'header', 'footer'], (props, {
|
|
35
35
|
slots
|
|
36
36
|
}) => {
|
|
37
|
-
const childProps =
|
|
38
|
-
...
|
|
37
|
+
const childProps = computed(() => ({
|
|
38
|
+
...props,
|
|
39
39
|
onOk: () => {
|
|
40
40
|
if (!props.form || props.form.validate().isValid) {
|
|
41
41
|
props.onOk?.();
|
|
@@ -43,8 +43,8 @@ export default createComponent('NFormModal', nFormModalProps, (props, {
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
closeOnOk: false
|
|
46
|
-
});
|
|
47
|
-
return () => _createVNode(NModal, childProps, {
|
|
46
|
+
}));
|
|
47
|
+
return () => _createVNode(NModal, childProps.value, {
|
|
48
48
|
default: () => [_createVNode(NForm, {
|
|
49
49
|
"form": props.form
|
|
50
50
|
}, {
|
|
@@ -22,10 +22,6 @@ export declare const nInputSuggestionProps: {
|
|
|
22
22
|
readonly input: PropType<(props: import("./NValInput").InputSlotProps) => JSX.Element>;
|
|
23
23
|
readonly optional: BooleanConstructor;
|
|
24
24
|
readonly rules: {
|
|
25
|
-
/**
|
|
26
|
-
* `NInputSuggestion` is an input, which shows a list of possible suggestions to the user
|
|
27
|
-
* which is filtered while typing. Contrary to {@link NInputSelect} the user is not required to choose any of the suggestions.
|
|
28
|
-
*/
|
|
29
25
|
readonly type: PropType<import("../utils/validation").ValidationRule | import("../utils/validation").ValidationRule[]>;
|
|
30
26
|
readonly default: () => never[];
|
|
31
27
|
};
|
|
@@ -97,10 +93,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
97
93
|
readonly input: PropType<(props: import("./NValInput").InputSlotProps) => JSX.Element>;
|
|
98
94
|
readonly optional: BooleanConstructor;
|
|
99
95
|
readonly rules: {
|
|
100
|
-
/**
|
|
101
|
-
* `NInputSuggestion` is an input, which shows a list of possible suggestions to the user
|
|
102
|
-
* which is filtered while typing. Contrary to {@link NInputSelect} the user is not required to choose any of the suggestions.
|
|
103
|
-
*/
|
|
104
96
|
readonly type: PropType<import("../utils/validation").ValidationRule | import("../utils/validation").ValidationRule[]>;
|
|
105
97
|
readonly default: () => never[];
|
|
106
98
|
};
|
|
@@ -167,10 +159,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
167
159
|
readonly input: PropType<(props: import("./NValInput").InputSlotProps) => JSX.Element>;
|
|
168
160
|
readonly optional: BooleanConstructor;
|
|
169
161
|
readonly rules: {
|
|
170
|
-
/**
|
|
171
|
-
* `NInputSuggestion` is an input, which shows a list of possible suggestions to the user
|
|
172
|
-
* which is filtered while typing. Contrary to {@link NInputSelect} the user is not required to choose any of the suggestions.
|
|
173
|
-
*/
|
|
174
162
|
readonly type: PropType<import("../utils/validation").ValidationRule | import("../utils/validation").ValidationRule[]>;
|
|
175
163
|
readonly default: () => never[];
|
|
176
164
|
};
|
package/components/NModal.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createTextVNode as _createTextVNode, createVNode as _createVNode } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { createComponentWithSlots } from '../utils/component';
|
|
3
3
|
import { Dialog, DialogOverlay, DialogTitle, TransitionRoot, TransitionChild } from '@headlessui/vue';
|
|
4
4
|
import NButton from './NButton';
|
|
5
5
|
import NIconButton from './NIconButton';
|
|
@@ -112,7 +112,7 @@ export const nModalProps = {
|
|
|
112
112
|
* The `NModal` is the base component for all modals and dialogs.
|
|
113
113
|
* It provides the core mechanics to display a window in front of everything else.
|
|
114
114
|
*/
|
|
115
|
-
export default
|
|
115
|
+
export default createComponentWithSlots('NModal', nModalProps, ['modal', 'header', 'footer'], (props, {
|
|
116
116
|
slots
|
|
117
117
|
}) => {
|
|
118
118
|
const ok = () => {
|
|
@@ -18,10 +18,10 @@ export declare const nSearchbarListProps: {
|
|
|
18
18
|
readonly onUpdateValue: import("vue").PropType<(newValue: string) => void>;
|
|
19
19
|
readonly items: {
|
|
20
20
|
readonly type: import("vue").PropType<import("./NSuggestionList").SuggestionItem[]>;
|
|
21
|
-
readonly default: () => never[];
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
readonly default: () => never[]; /**
|
|
22
|
+
* Adds the classes directly to the input (e.g. for shadow).
|
|
23
|
+
*/
|
|
24
|
+
};
|
|
25
25
|
readonly maxItems: {
|
|
26
26
|
readonly type: NumberConstructor;
|
|
27
27
|
readonly default: () => number;
|
|
@@ -55,10 +55,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
55
55
|
readonly onUpdateValue: import("vue").PropType<(newValue: string) => void>;
|
|
56
56
|
readonly items: {
|
|
57
57
|
readonly type: import("vue").PropType<import("./NSuggestionList").SuggestionItem[]>;
|
|
58
|
-
readonly default: () => never[];
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
readonly default: () => never[]; /**
|
|
59
|
+
* Adds the classes directly to the input (e.g. for shadow).
|
|
60
|
+
*/
|
|
61
|
+
};
|
|
62
62
|
readonly maxItems: {
|
|
63
63
|
readonly type: NumberConstructor;
|
|
64
64
|
readonly default: () => number;
|
|
@@ -88,10 +88,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
88
88
|
readonly onUpdateValue: import("vue").PropType<(newValue: string) => void>;
|
|
89
89
|
readonly items: {
|
|
90
90
|
readonly type: import("vue").PropType<import("./NSuggestionList").SuggestionItem[]>;
|
|
91
|
-
readonly default: () => never[];
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
readonly default: () => never[]; /**
|
|
92
|
+
* Adds the classes directly to the input (e.g. for shadow).
|
|
93
|
+
*/
|
|
94
|
+
};
|
|
95
95
|
readonly maxItems: {
|
|
96
96
|
readonly type: NumberConstructor;
|
|
97
97
|
readonly default: () => number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createTextVNode as _createTextVNode, createVNode as _createVNode } from "vue";
|
|
2
2
|
import { trsl } from '../i18n';
|
|
3
|
-
import {
|
|
3
|
+
import { createComponentWithSlots } from '../utils/component';
|
|
4
4
|
import { computed, ref } from 'vue';
|
|
5
5
|
import NLoadingIndicator from './NLoadingIndicator';
|
|
6
6
|
export const nSuggestionListPropsForConfig = {
|
|
@@ -72,7 +72,7 @@ export const nSuggestionListProps = {
|
|
|
72
72
|
/**
|
|
73
73
|
* The `NSuggestionList` can be added to an input and adds a list below it which is shown when the input is focused.
|
|
74
74
|
*/
|
|
75
|
-
export default
|
|
75
|
+
export default createComponentWithSlots('NSuggestionList', nSuggestionListProps, ['input', 'listItem'], props => {
|
|
76
76
|
const selectedIndex = ref(null);
|
|
77
77
|
const displayItems = computed(() => props.items.slice(0, props.maxItems));
|
|
78
78
|
const isInFocus = ref(false);
|
package/components/NValInput.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createVNode as _createVNode, mergeProps as _mergeProps } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { createComponentWithSlots } from '../utils/component';
|
|
3
3
|
import { computed } from 'vue';
|
|
4
4
|
import { ref, reactive, watch } from 'vue';
|
|
5
5
|
import NInput, { nInputProps } from './NInput';
|
|
@@ -53,7 +53,7 @@ export const nValInputProps = {
|
|
|
53
53
|
/**
|
|
54
54
|
* The `NValInput` is a `NInput` with custom validation.
|
|
55
55
|
*/
|
|
56
|
-
export default
|
|
56
|
+
export default createComponentWithSlots('NValInput', nValInputProps, ['input'], (props, context) => {
|
|
57
57
|
const rules = computed(() => {
|
|
58
58
|
const otherRules = Array.isArray(props.rules) ? props.rules : [props.rules];
|
|
59
59
|
return props.optional ? otherRules : [required, ...otherRules];
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@naptics/vue-collection",
|
|
3
3
|
"author": "Timo Siegenthaler",
|
|
4
4
|
"description": "Vue Collection is a collection of styled and fully functional Vue components which can easily be integrated into our projects.",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.6",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
package/utils/component.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createVNode as _createVNode, Fragment as _Fragment } from "vue";
|
|
2
|
-
import { defineComponent, reactive, toRef } from 'vue';
|
|
2
|
+
import { defineComponent, reactive, toRef, toRefs, ref } from 'vue';
|
|
3
3
|
/**
|
|
4
4
|
* Components should be created using this helper function.
|
|
5
5
|
* It only takes three arguments, the name and the props of the component and the setup function.
|
|
@@ -63,13 +63,14 @@ export function extractProps(props, ...keys) {
|
|
|
63
63
|
return reactive(partial);
|
|
64
64
|
}
|
|
65
65
|
function createSlotProps(props, slots, ...keys) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
};
|
|
66
|
+
// create refs, don't touch all props which are not slots
|
|
67
|
+
const newProps = toRefs(props);
|
|
69
68
|
keys.forEach(key => {
|
|
69
|
+
// if a slot is set once, it is basically always set. The changing content is not a problem as it is inside the function.
|
|
70
70
|
const slot = slots[key];
|
|
71
|
+
// if the slot is set, overwrite the props
|
|
71
72
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
73
|
if (slot) newProps[key] = (...args) => _createVNode(_Fragment, null, [slot?.(...args)]);
|
|
73
74
|
});
|
|
74
|
-
return newProps;
|
|
75
|
+
return ref(newProps).value;
|
|
75
76
|
}
|