@naptics/vue-collection 0.3.1 → 1.0.0-beta.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/eslint.config.cjs +0 -2
- package/package.json +32 -31
- package/postcss.config.js +1 -4
- package/src/demo/App.css +47 -3
- package/src/demo/components/ComponentSection.tsx +1 -1
- package/src/demo/views/NavigationView.tsx +1 -1
- package/src/demo/views/presentation/TooltipView.tsx +8 -2
- package/src/lib/components/NAlert.tsx +3 -3
- package/src/lib/components/NBadge.tsx +1 -1
- package/src/lib/components/NButton.tsx +6 -4
- package/src/lib/components/NCheckbox.tsx +2 -2
- package/src/lib/components/NDialog.tsx +2 -2
- package/src/lib/components/NDropdown.tsx +11 -9
- package/src/lib/components/NDropzone.tsx +4 -4
- package/src/lib/components/NIconButton.tsx +2 -2
- package/src/lib/components/NInput.tsx +1 -1
- package/src/lib/components/NLink.tsx +1 -1
- package/src/lib/components/NModal.tsx +4 -4
- package/src/lib/components/NPagination.css +4 -2
- package/src/lib/components/NPagination.tsx +1 -1
- package/src/lib/components/NSearchbar.tsx +1 -1
- package/src/lib/components/NSelect.tsx +1 -1
- package/src/lib/components/NSuggestionList.tsx +1 -1
- package/src/lib/components/NTable.css +2 -0
- package/src/lib/components/NTableAction.tsx +1 -1
- package/src/lib/components/NTextArea.tsx +1 -1
- package/src/lib/components/NTooltip.css +2 -0
- package/src/lib/components/NTooltip.tsx +42 -3
- package/src/lib/utils/component.tsx +1 -1
- package/tsconfig.lib.json +1 -0
- package/vite.config.ts +2 -0
- package/components/NAlert.d.ts +0 -29
- package/components/NAlert.js +0 -84
- package/components/NBadge.d.ts +0 -69
- package/components/NBadge.js +0 -64
- package/components/NBreadcrub.d.ts +0 -69
- package/components/NBreadcrub.js +0 -71
- package/components/NButton.d.ts +0 -60
- package/components/NButton.js +0 -72
- package/components/NCheckbox.d.ts +0 -20
- package/components/NCheckbox.js +0 -43
- package/components/NCheckboxLabel.d.ts +0 -26
- package/components/NCheckboxLabel.js +0 -42
- package/components/NCrudModal.d.ts +0 -118
- package/components/NCrudModal.js +0 -120
- package/components/NDialog.d.ts +0 -81
- package/components/NDialog.js +0 -161
- package/components/NDropdown.d.ts +0 -67
- package/components/NDropdown.js +0 -115
- package/components/NDropzone.d.ts +0 -61
- package/components/NDropzone.js +0 -218
- package/components/NForm.d.ts +0 -21
- package/components/NForm.js +0 -29
- package/components/NFormModal.d.ts +0 -75
- package/components/NFormModal.js +0 -59
- package/components/NIconButton.d.ts +0 -79
- package/components/NIconButton.js +0 -88
- package/components/NIconCircle.d.ts +0 -49
- package/components/NIconCircle.js +0 -67
- package/components/NInput.css +0 -11
- package/components/NInput.d.ts +0 -90
- package/components/NInput.js +0 -110
- package/components/NInputPhone.d.ts +0 -54
- package/components/NInputPhone.js +0 -47
- package/components/NInputSelect.d.ts +0 -99
- package/components/NInputSelect.js +0 -115
- package/components/NInputSuggestion.d.ts +0 -75
- package/components/NInputSuggestion.js +0 -64
- package/components/NLink.d.ts +0 -47
- package/components/NLink.js +0 -67
- package/components/NList.d.ts +0 -37
- package/components/NList.js +0 -40
- package/components/NLoadingIndicator.css +0 -46
- package/components/NLoadingIndicator.d.ts +0 -29
- package/components/NLoadingIndicator.js +0 -54
- package/components/NModal.d.ts +0 -133
- package/components/NModal.js +0 -232
- package/components/NPagination.css +0 -15
- package/components/NPagination.d.ts +0 -37
- package/components/NPagination.js +0 -105
- package/components/NSearchbar.d.ts +0 -39
- package/components/NSearchbar.js +0 -64
- package/components/NSearchbarList.d.ts +0 -33
- package/components/NSearchbarList.js +0 -41
- package/components/NSelect.d.ts +0 -78
- package/components/NSelect.js +0 -101
- package/components/NSuggestionList.d.ts +0 -153
- package/components/NSuggestionList.js +0 -160
- package/components/NTable.css +0 -3
- package/components/NTable.d.ts +0 -97
- package/components/NTable.js +0 -128
- package/components/NTableAction.d.ts +0 -30
- package/components/NTableAction.js +0 -50
- package/components/NTextArea.d.ts +0 -92
- package/components/NTextArea.js +0 -133
- package/components/NTooltip.css +0 -37
- package/components/NTooltip.d.ts +0 -136
- package/components/NTooltip.js +0 -207
- package/components/NValInput.d.ts +0 -155
- package/components/NValInput.js +0 -113
- package/components/ValidatedForm.d.ts +0 -39
- package/components/ValidatedForm.js +0 -35
- package/i18n/de/vue-collection.json +0 -58
- package/i18n/en/vue-collection.json +0 -58
- package/i18n/index.d.ts +0 -40
- package/i18n/index.js +0 -31
- package/index.d.ts +0 -2
- package/index.js +0 -2
- package/tailwind.config.js +0 -38
- package/utils/breakpoints.d.ts +0 -18
- package/utils/breakpoints.js +0 -40
- package/utils/component.d.ts +0 -57
- package/utils/component.js +0 -79
- package/utils/deferred.d.ts +0 -13
- package/utils/deferred.js +0 -17
- package/utils/identifiable.d.ts +0 -56
- package/utils/identifiable.js +0 -81
- package/utils/stringMaxLength.d.ts +0 -14
- package/utils/stringMaxLength.js +0 -23
- package/utils/tailwind.d.ts +0 -4
- package/utils/tailwind.js +0 -1
- package/utils/utils.d.ts +0 -47
- package/utils/utils.js +0 -56
- package/utils/vModel.d.ts +0 -182
- package/utils/vModel.js +0 -224
- package/utils/validation.d.ts +0 -90
- package/utils/validation.js +0 -147
- package/utils/vue.d.ts +0 -13
- package/utils/vue.js +0 -21
package/components/NDropdown.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { createVNode as _createVNode, isVNode as _isVNode } from "vue";
|
|
2
|
-
import { createComponentWithSlots } from '../utils/component';
|
|
3
|
-
import { computed, Transition } from 'vue';
|
|
4
|
-
import { RouterLink } from 'vue-router';
|
|
5
|
-
import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue';
|
|
6
|
-
import { ChevronDownIcon } from '@heroicons/vue/24/solid';
|
|
7
|
-
function _isSlot(s) {
|
|
8
|
-
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !_isVNode(s);
|
|
9
|
-
}
|
|
10
|
-
export const nDropdownProps = {
|
|
11
|
-
/**
|
|
12
|
-
* The title of the dropdown-button.
|
|
13
|
-
*/
|
|
14
|
-
title: String,
|
|
15
|
-
/**
|
|
16
|
-
* The items of the dropdown.
|
|
17
|
-
* The second dimension of the array is used
|
|
18
|
-
* to create groups of items, which are visually seperated.
|
|
19
|
-
*/
|
|
20
|
-
items: {
|
|
21
|
-
type: Array,
|
|
22
|
-
default: () => []
|
|
23
|
-
},
|
|
24
|
-
/**
|
|
25
|
-
* If set to `true` the panel is right-aligned to the button.
|
|
26
|
-
*/
|
|
27
|
-
right: Boolean,
|
|
28
|
-
/**
|
|
29
|
-
* If set to `true` the dropdown-button is disabled and no interaction is possible.
|
|
30
|
-
*/
|
|
31
|
-
disabled: Boolean,
|
|
32
|
-
/**
|
|
33
|
-
* Adds the classes to the Button of the dropdown.
|
|
34
|
-
*/
|
|
35
|
-
buttonClass: String,
|
|
36
|
-
/**
|
|
37
|
-
* A slot to replace the button of the dropdown.
|
|
38
|
-
* The passed parameter is the HeadlessUI `MenuButton` which should be
|
|
39
|
-
* used to create the button for the Dropdown to work properly.
|
|
40
|
-
*/
|
|
41
|
-
button: Function
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* The `NDropdown` consists of a button and a panel with multiple actions.
|
|
45
|
-
* It is useful to group multiple actions together in one place.
|
|
46
|
-
*/
|
|
47
|
-
const Component = createComponentWithSlots('NDropdown', nDropdownProps, ['button'], (props, {
|
|
48
|
-
slots
|
|
49
|
-
}) => {
|
|
50
|
-
const items = computed(() => {
|
|
51
|
-
if (props.items.length == 0) return [];
|
|
52
|
-
if (Array.isArray(props.items[0])) return props.items;else return [props.items];
|
|
53
|
-
});
|
|
54
|
-
const itemWithIcon = item => _createVNode("div", {
|
|
55
|
-
"class": "flex space-x-3 items-center"
|
|
56
|
-
}, [item.icon && _createVNode(item.icon, {
|
|
57
|
-
"class": ['h-5 w-5', item.disabled ? 'text-default-300' : 'text-default-400']
|
|
58
|
-
}, null), _createVNode("span", null, [item.label])]);
|
|
59
|
-
return () => _createVNode(Menu, {
|
|
60
|
-
"as": "div",
|
|
61
|
-
"class": `relative inline-block text-left`
|
|
62
|
-
}, {
|
|
63
|
-
default: () => [_createVNode("div", {
|
|
64
|
-
"class": "flex"
|
|
65
|
-
}, [props.button?.(MenuButton) || _createVNode(MenuButton, {
|
|
66
|
-
"disabled": props.disabled,
|
|
67
|
-
"class": ['shadow w-full flex justify-between items-center text-default-700 rounded-md border bg-white border-default-300 px-4 py-2 text-sm font-medium focus:outline-none focus:ring-offset-2 focus-visible:ring-2 focus-visible:ring-primary-500', props.disabled ? 'text-opacity-20 cursor-default' : 'hover:bg-default-100', props.buttonClass]
|
|
68
|
-
}, {
|
|
69
|
-
default: () => [_createVNode("span", null, [props.title]), _createVNode(ChevronDownIcon, {
|
|
70
|
-
"class": "-mr-1 ml-2 h-5 w-5 flex-shrink-0",
|
|
71
|
-
"aria-hidden": "true"
|
|
72
|
-
}, null)]
|
|
73
|
-
})]), _createVNode(Transition, {
|
|
74
|
-
"enterActiveClass": "transition ease-out duration-100",
|
|
75
|
-
"enterFromClass": "transform opacity-0 scale-95",
|
|
76
|
-
"enterToClass": "transform opacity-100 scale-100",
|
|
77
|
-
"leaveActiveClass": "transition ease-in duration-75",
|
|
78
|
-
"leaveFromClass": "transform opacity-100 scale-100",
|
|
79
|
-
"leaveToClass": "transform opacity-0 scale-95"
|
|
80
|
-
}, {
|
|
81
|
-
default: () => [_createVNode(MenuItems, {
|
|
82
|
-
"class": ['z-10 absolute w-56 mt-2 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none', props.right ? 'origin-top-right right-0' : 'origin-top-left left-0']
|
|
83
|
-
}, {
|
|
84
|
-
default: () => [slots.default?.() || _createVNode("div", {
|
|
85
|
-
"class": "divide-y divide-default-200"
|
|
86
|
-
}, [items.value.map((group, index) => _createVNode("div", {
|
|
87
|
-
"key": `group-${index}`,
|
|
88
|
-
"class": "py-1"
|
|
89
|
-
}, [group.map((item, index) => _createVNode(MenuItem, {
|
|
90
|
-
"key": `item-${index}`,
|
|
91
|
-
"disabled": item.disabled
|
|
92
|
-
}, {
|
|
93
|
-
default: ({
|
|
94
|
-
active
|
|
95
|
-
}) => {
|
|
96
|
-
let _slot;
|
|
97
|
-
return item.disabled ? _createVNode("div", {
|
|
98
|
-
"class": "block px-4 py-2 text-sm text-default-300"
|
|
99
|
-
}, [itemWithIcon(item)]) : item.route ? _createVNode(RouterLink, {
|
|
100
|
-
"to": item.route,
|
|
101
|
-
"class": ['block px-4 py-2 text-sm', active ? 'bg-default-100 text-default-900' : 'text-default-700']
|
|
102
|
-
}, _isSlot(_slot = itemWithIcon(item)) ? _slot : {
|
|
103
|
-
default: () => [_slot]
|
|
104
|
-
}) : _createVNode("button", {
|
|
105
|
-
"type": "button",
|
|
106
|
-
"onClick": item.onClick,
|
|
107
|
-
"class": ['w-full text-left px-4 py-2 text-sm', active ? 'bg-default-100 text-default-900' : 'text-default-700']
|
|
108
|
-
}, [itemWithIcon(item)]);
|
|
109
|
-
}
|
|
110
|
-
}))]))])]
|
|
111
|
-
})]
|
|
112
|
-
})]
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
export { Component as NDropdown, Component as default };
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
export declare const nDropzoneProps: {
|
|
2
|
-
/**
|
|
3
|
-
* A description which files are allowed for this dropzone.
|
|
4
|
-
* This should include everything the user needs to know about
|
|
5
|
-
* the file type / the extensions and the maximum size of the file.
|
|
6
|
-
* @see {@link nDropzoneProps.accept}
|
|
7
|
-
* @see {@link nDropzoneProps.maxFileSize}
|
|
8
|
-
*/
|
|
9
|
-
readonly description: StringConstructor;
|
|
10
|
-
/**
|
|
11
|
-
* The maximum amount of files which can be added to the dropzone.
|
|
12
|
-
*/
|
|
13
|
-
readonly maxFiles: {
|
|
14
|
-
readonly type: NumberConstructor;
|
|
15
|
-
readonly default: 1;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Specifies which file types are accepted. The same syntax as with inputs of type file is used.
|
|
19
|
-
* Make sure to explain the requirements to the user in the {@link nDropzoneProps.description}.
|
|
20
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#unique_file_type_specifiers
|
|
21
|
-
*/
|
|
22
|
-
readonly accept: StringConstructor;
|
|
23
|
-
/**
|
|
24
|
-
* Specifies the maximum size of an individual file in bytes.
|
|
25
|
-
* Make sure to explain the max size to the user in the {@link nDropzoneProps.description}.
|
|
26
|
-
*/
|
|
27
|
-
readonly maxFileSize: {
|
|
28
|
-
readonly type: NumberConstructor;
|
|
29
|
-
readonly default: number;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* The maximum length of the file names.
|
|
33
|
-
* Files names longer than the specified amount of characters will be shortened.
|
|
34
|
-
* @see {@link maxLengthSplitCenter}
|
|
35
|
-
*/
|
|
36
|
-
readonly maxLengthFileNames: {
|
|
37
|
-
readonly type: NumberConstructor;
|
|
38
|
-
readonly default: 35;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* A tailwind height class, which is applied to the dropzone area.
|
|
42
|
-
* It is recommended to use `min-h-*` classes,
|
|
43
|
-
* so the box is always large enough to display it's text.
|
|
44
|
-
*/
|
|
45
|
-
readonly height: {
|
|
46
|
-
readonly type: StringConstructor;
|
|
47
|
-
readonly default: "min-h-36";
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* If set to `true`, the dropzone is disabled and does not accept input anymore.
|
|
51
|
-
*/
|
|
52
|
-
readonly disabled: BooleanConstructor;
|
|
53
|
-
readonly value: import("vue").PropType<File[]>;
|
|
54
|
-
readonly onUpdateValue: import("vue").PropType<(newValue: File[]) => void>;
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* The `NDropzone` is an area where files can be added by the user by drag & drop.
|
|
58
|
-
* Files can also be selected with a file chooser by clicking on the dropzone.
|
|
59
|
-
*/
|
|
60
|
-
declare const Component: import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
|
|
61
|
-
export { Component as NDropzone, Component as default };
|
package/components/NDropzone.js
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
import { createVNode as _createVNode, Fragment as _Fragment, createTextVNode as _createTextVNode, isVNode as _isVNode } from "vue";
|
|
2
|
-
import { trslc } from '../i18n';
|
|
3
|
-
import { createComponent } from '../utils/component';
|
|
4
|
-
import { maxLengthSplitCenter } from '../utils/stringMaxLength';
|
|
5
|
-
import { notNullish } from '../utils/utils';
|
|
6
|
-
import { XMarkIcon } from '@heroicons/vue/24/solid';
|
|
7
|
-
import { computed, ref } from 'vue';
|
|
8
|
-
import NBadge from './NBadge';
|
|
9
|
-
import NIconButton from './NIconButton';
|
|
10
|
-
import NLink from './NLink';
|
|
11
|
-
import { vModelProps } from '../utils/vModel';
|
|
12
|
-
function _isSlot(s) {
|
|
13
|
-
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !_isVNode(s);
|
|
14
|
-
}
|
|
15
|
-
export const nDropzoneProps = {
|
|
16
|
-
...vModelProps(Array),
|
|
17
|
-
/**
|
|
18
|
-
* A description which files are allowed for this dropzone.
|
|
19
|
-
* This should include everything the user needs to know about
|
|
20
|
-
* the file type / the extensions and the maximum size of the file.
|
|
21
|
-
* @see {@link nDropzoneProps.accept}
|
|
22
|
-
* @see {@link nDropzoneProps.maxFileSize}
|
|
23
|
-
*/
|
|
24
|
-
description: String,
|
|
25
|
-
/**
|
|
26
|
-
* The maximum amount of files which can be added to the dropzone.
|
|
27
|
-
*/
|
|
28
|
-
maxFiles: {
|
|
29
|
-
type: Number,
|
|
30
|
-
default: 1
|
|
31
|
-
},
|
|
32
|
-
/**
|
|
33
|
-
* Specifies which file types are accepted. The same syntax as with inputs of type file is used.
|
|
34
|
-
* Make sure to explain the requirements to the user in the {@link nDropzoneProps.description}.
|
|
35
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#unique_file_type_specifiers
|
|
36
|
-
*/
|
|
37
|
-
accept: String,
|
|
38
|
-
/**
|
|
39
|
-
* Specifies the maximum size of an individual file in bytes.
|
|
40
|
-
* Make sure to explain the max size to the user in the {@link nDropzoneProps.description}.
|
|
41
|
-
*/
|
|
42
|
-
maxFileSize: {
|
|
43
|
-
type: Number,
|
|
44
|
-
default: 100 * 1024 * 1024
|
|
45
|
-
},
|
|
46
|
-
/**
|
|
47
|
-
* The maximum length of the file names.
|
|
48
|
-
* Files names longer than the specified amount of characters will be shortened.
|
|
49
|
-
* @see {@link maxLengthSplitCenter}
|
|
50
|
-
*/
|
|
51
|
-
maxLengthFileNames: {
|
|
52
|
-
type: Number,
|
|
53
|
-
default: 35
|
|
54
|
-
},
|
|
55
|
-
/**
|
|
56
|
-
* A tailwind height class, which is applied to the dropzone area.
|
|
57
|
-
* It is recommended to use `min-h-*` classes,
|
|
58
|
-
* so the box is always large enough to display it's text.
|
|
59
|
-
*/
|
|
60
|
-
height: {
|
|
61
|
-
type: String,
|
|
62
|
-
default: 'min-h-36'
|
|
63
|
-
},
|
|
64
|
-
/**
|
|
65
|
-
* If set to `true`, the dropzone is disabled and does not accept input anymore.
|
|
66
|
-
*/
|
|
67
|
-
disabled: Boolean
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* The `NDropzone` is an area where files can be added by the user by drag & drop.
|
|
71
|
-
* Files can also be selected with a file chooser by clicking on the dropzone.
|
|
72
|
-
*/
|
|
73
|
-
const Component = createComponent('NDropzone', nDropzoneProps, props => {
|
|
74
|
-
const fileError = ref();
|
|
75
|
-
const filterAndUpdateFiles = files => {
|
|
76
|
-
// filter for mime type and max size
|
|
77
|
-
const fileTypeFilteredFiles = files.filter(file => !props.accept || testFileWithAcceptString(props.accept, file));
|
|
78
|
-
const filteredFiles = fileTypeFilteredFiles.filter(file => file.size <= props.maxFileSize);
|
|
79
|
-
// filter for already existing files
|
|
80
|
-
const currentFiles = props.value || [];
|
|
81
|
-
filteredFiles.forEach(file => {
|
|
82
|
-
if (currentFiles.filter(currFile => currFile.name == file.name).length == 0) currentFiles.push(file);
|
|
83
|
-
});
|
|
84
|
-
// slice down to max amount of files
|
|
85
|
-
const newFiles = currentFiles.slice(0, props.maxFiles);
|
|
86
|
-
// error handling
|
|
87
|
-
const fileTypeFilterDiff = files.length - fileTypeFilteredFiles.length;
|
|
88
|
-
const fileSizeFilterDiff = fileTypeFilteredFiles.length - filteredFiles.length;
|
|
89
|
-
if (newFiles.length < currentFiles.length) fileError.value = trslc('vue-collection.error.too-many-files', props.maxFiles, {
|
|
90
|
-
max: props.maxFiles
|
|
91
|
-
});else if (fileSizeFilterDiff > 0) {
|
|
92
|
-
fileError.value = trslc('vue-collection.error.file-size', fileSizeFilterDiff, {
|
|
93
|
-
n: fileSizeFilterDiff
|
|
94
|
-
});
|
|
95
|
-
} else if (fileTypeFilterDiff > 0) fileError.value = trslc('vue-collection.error.file-type', fileTypeFilterDiff, {
|
|
96
|
-
n: fileTypeFilterDiff
|
|
97
|
-
});else fileError.value = undefined;
|
|
98
|
-
// update new value
|
|
99
|
-
props.onUpdateValue?.(newFiles);
|
|
100
|
-
};
|
|
101
|
-
const files = computed(() => props.value?.map((file, index) => ({
|
|
102
|
-
index,
|
|
103
|
-
name: maxLengthSplitCenter(file.name, props.maxLengthFileNames)
|
|
104
|
-
})) || []);
|
|
105
|
-
const removeFile = index => {
|
|
106
|
-
const newFiles = [...(props.value || [])];
|
|
107
|
-
newFiles.splice(index, 1);
|
|
108
|
-
fileError.value = undefined;
|
|
109
|
-
props.onUpdateValue?.(newFiles);
|
|
110
|
-
};
|
|
111
|
-
const clearFiles = () => {
|
|
112
|
-
fileError.value = undefined;
|
|
113
|
-
props.onUpdateValue?.([]);
|
|
114
|
-
};
|
|
115
|
-
const isDragOver = ref(false);
|
|
116
|
-
const onDrop = event => {
|
|
117
|
-
event.preventDefault();
|
|
118
|
-
isDragOver.value = false;
|
|
119
|
-
if (props.disabled) return;
|
|
120
|
-
const transfer = event.dataTransfer;
|
|
121
|
-
if (transfer == null) return;
|
|
122
|
-
if (transfer.items.length > 0) {
|
|
123
|
-
const items = [...transfer.items];
|
|
124
|
-
const files = items.map(item => item.kind === 'file' ? item.getAsFile() : null).filter(notNullish);
|
|
125
|
-
filterAndUpdateFiles(files);
|
|
126
|
-
} else {
|
|
127
|
-
filterAndUpdateFiles([...transfer.files]);
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
const onDragOver = event => {
|
|
131
|
-
event.preventDefault();
|
|
132
|
-
isDragOver.value = true;
|
|
133
|
-
};
|
|
134
|
-
const onDragLeave = () => {
|
|
135
|
-
isDragOver.value = false;
|
|
136
|
-
};
|
|
137
|
-
const onClick = () => {
|
|
138
|
-
fileInput.value?.click();
|
|
139
|
-
};
|
|
140
|
-
const fileInput = ref();
|
|
141
|
-
const onInputFilesChanged = () => {
|
|
142
|
-
const input = fileInput.value;
|
|
143
|
-
if (input != null) {
|
|
144
|
-
if (input.files != null) filterAndUpdateFiles([...input.files]);
|
|
145
|
-
input.value = '';
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
return () => {
|
|
149
|
-
let _slot;
|
|
150
|
-
return _createVNode("div", null, [_createVNode("button", {
|
|
151
|
-
"class": ['block w-full rounded-md border-dashed border-2 focus-visible:border-primary-500 focus:outline-none ', 'flex flex-col items-center justify-center text-center text-sm select-none p-4', !props.disabled ? 'hover:border-primary-300 hover:bg-primary-50 hover:text-primary-700' : '', props.disabled ? 'border-default-300 bg-default-50/50 text-default-500/30' : isDragOver.value ? 'border-primary-300 bg-primary-50 text-primary-700' : 'border-default-300 bg-default-50 text-default-500', props.height],
|
|
152
|
-
"onDrop": onDrop,
|
|
153
|
-
"onDragover": onDragOver,
|
|
154
|
-
"onDragleave": onDragLeave,
|
|
155
|
-
"onClick": onClick,
|
|
156
|
-
"type": "button",
|
|
157
|
-
"disabled": props.disabled
|
|
158
|
-
}, [_createVNode("input", {
|
|
159
|
-
"type": "file",
|
|
160
|
-
"class": "hidden",
|
|
161
|
-
"ref": fileInput,
|
|
162
|
-
"multiple": props.maxFiles > 1,
|
|
163
|
-
"accept": props.accept,
|
|
164
|
-
"onChange": onInputFilesChanged,
|
|
165
|
-
"onClick": event => event.stopPropagation()
|
|
166
|
-
}, null), _createVNode("div", {
|
|
167
|
-
"class": "flex-grow mb-2"
|
|
168
|
-
}, null), _createVNode("span", {
|
|
169
|
-
"class": "font-medium"
|
|
170
|
-
}, [trslc('vue-collection.text.drag-n-drop-files', props.maxFiles, {
|
|
171
|
-
n: props.maxFiles
|
|
172
|
-
})]), _createVNode("span", null, [props.description]), _createVNode("div", {
|
|
173
|
-
"class": "flex-grow mt-2 flex items-end justify-center text-red-500 font-medium"
|
|
174
|
-
}, [_createVNode("span", null, [fileError.value])])]), _createVNode("div", {
|
|
175
|
-
"class": "mt-2 space-y-1"
|
|
176
|
-
}, [_createVNode("div", {
|
|
177
|
-
"class": "flex flex-wrap gap-2 "
|
|
178
|
-
}, [files.value.map(file => _createVNode(NBadge, {
|
|
179
|
-
"key": file.index,
|
|
180
|
-
"color": "default",
|
|
181
|
-
"allCaps": false,
|
|
182
|
-
"textSize": "text-xs"
|
|
183
|
-
}, {
|
|
184
|
-
default: () => [_createVNode("div", {
|
|
185
|
-
"class": "flex items-center space-x-2"
|
|
186
|
-
}, [_createVNode("span", null, [file.name]), _createVNode(NIconButton, {
|
|
187
|
-
"icon": XMarkIcon,
|
|
188
|
-
"shade": 900,
|
|
189
|
-
"size": 3,
|
|
190
|
-
"onClick": () => removeFile(file.index)
|
|
191
|
-
}, null)])]
|
|
192
|
-
})), _createVNode("div", {
|
|
193
|
-
"class": "flex-grow text-sm text-default-500 flex items-end justify-end text-right"
|
|
194
|
-
}, [_createVNode("span", null, [_createVNode("span", null, [trslc('vue-collection.text.files-selected', files.value.length, {
|
|
195
|
-
n: files.value.length
|
|
196
|
-
})]), files.value.length > 0 && _createVNode(_Fragment, null, [_createVNode("span", null, [_createTextVNode(" ")]), _createVNode(NLink, {
|
|
197
|
-
"color": "default",
|
|
198
|
-
"onClick": clearFiles
|
|
199
|
-
}, _isSlot(_slot = trslc('vue-collection.action.clear-files', files.value.length)) ? _slot : {
|
|
200
|
-
default: () => [_slot]
|
|
201
|
-
})])])])])])]);
|
|
202
|
-
};
|
|
203
|
-
});
|
|
204
|
-
export { Component as NDropzone, Component as default };
|
|
205
|
-
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#unique_file_type_specifiers
|
|
206
|
-
const MIME_FORMAT = /^(image|audio|application|video|text)\/\*$/;
|
|
207
|
-
const EXTENSION_FORMAT = /^\.\w{2,20}$/;
|
|
208
|
-
function testFileWithAcceptString(accept, file) {
|
|
209
|
-
const splitted = accept.split(',').map(pattern => pattern.trim());
|
|
210
|
-
for (const pattern of splitted) {
|
|
211
|
-
if (MIME_FORMAT.test(pattern)) {
|
|
212
|
-
if (RegExp(`^${pattern.substring(0, pattern.length - 2)}\\/.{2,}$`).test(file.type)) return true;
|
|
213
|
-
} else if (EXTENSION_FORMAT.test(pattern)) {
|
|
214
|
-
if (RegExp(`^.*${pattern}$`).test(file.name)) return true;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return false;
|
|
218
|
-
}
|
package/components/NForm.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { PropType } from 'vue';
|
|
2
|
-
import type { ValidatedForm } from './ValidatedForm';
|
|
3
|
-
export declare const nFormProps: {
|
|
4
|
-
/**
|
|
5
|
-
* The {@link ValidatedForm} which will be used to validate the inputs.
|
|
6
|
-
* All inputs in this forms hierarchy should be added to the {@link ValidatedForm}.
|
|
7
|
-
*/
|
|
8
|
-
readonly form: PropType<ValidatedForm>;
|
|
9
|
-
/**
|
|
10
|
-
* This is called, when a button of type `submit` in the hierarchy of this view is clicked
|
|
11
|
-
* and when the validation of the `form` was successful.
|
|
12
|
-
*/
|
|
13
|
-
readonly onSubmit: PropType<() => void>;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* The `NForm` should be used to wrap multiple inputs.
|
|
17
|
-
* If it contains a button of type `submit` in it's hierarchy,
|
|
18
|
-
* it catches the submit event and passes it to the {@link ValidatedForm} in its `form` prop.
|
|
19
|
-
*/
|
|
20
|
-
declare const Component: import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
|
|
21
|
-
export { Component as NForm, Component as default };
|
package/components/NForm.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { createVNode as _createVNode } from "vue";
|
|
2
|
-
import { createComponent } from '../utils/component';
|
|
3
|
-
export const nFormProps = {
|
|
4
|
-
/**
|
|
5
|
-
* The {@link ValidatedForm} which will be used to validate the inputs.
|
|
6
|
-
* All inputs in this forms hierarchy should be added to the {@link ValidatedForm}.
|
|
7
|
-
*/
|
|
8
|
-
form: Object,
|
|
9
|
-
/**
|
|
10
|
-
* This is called, when a button of type `submit` in the hierarchy of this view is clicked
|
|
11
|
-
* and when the validation of the `form` was successful.
|
|
12
|
-
*/
|
|
13
|
-
onSubmit: Function
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* The `NForm` should be used to wrap multiple inputs.
|
|
17
|
-
* If it contains a button of type `submit` in it's hierarchy,
|
|
18
|
-
* it catches the submit event and passes it to the {@link ValidatedForm} in its `form` prop.
|
|
19
|
-
*/
|
|
20
|
-
const Component = createComponent('NForm', nFormProps, (props, context) => {
|
|
21
|
-
const onSubmit = event => {
|
|
22
|
-
event.preventDefault();
|
|
23
|
-
if (!props.form || props.form.validate().isValid) props.onSubmit?.();
|
|
24
|
-
};
|
|
25
|
-
return () => _createVNode("form", {
|
|
26
|
-
"onSubmit": onSubmit
|
|
27
|
-
}, [context.slots.default?.()]);
|
|
28
|
-
});
|
|
29
|
-
export { Component as NForm, Component as default };
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type { TWMaxWidth } from '../utils/tailwind';
|
|
2
|
-
import { type PropType } from 'vue';
|
|
3
|
-
import type { ValidatedForm } from './ValidatedForm';
|
|
4
|
-
export declare const nFormModalProps: {
|
|
5
|
-
/**
|
|
6
|
-
* The maximum width of the modal. A regular tailwind class.
|
|
7
|
-
*/
|
|
8
|
-
readonly maxWidth: {
|
|
9
|
-
readonly type: PropType<TWMaxWidth>;
|
|
10
|
-
readonly default: "max-w-lg";
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* If set to `true` the modal closes when clicking on the background.
|
|
14
|
-
* Default is `false` as the accidental reseting of the whole form is very annoying.
|
|
15
|
-
*/
|
|
16
|
-
readonly closeOnBackground: {
|
|
17
|
-
readonly type: BooleanConstructor;
|
|
18
|
-
readonly default: false;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* The {@link ValidatedForm} to validate the inputs.
|
|
22
|
-
* All inputs should be added to the form.
|
|
23
|
-
*/
|
|
24
|
-
readonly form: PropType<ValidatedForm>;
|
|
25
|
-
readonly hideHeader: BooleanConstructor;
|
|
26
|
-
readonly hideFooter: BooleanConstructor;
|
|
27
|
-
readonly hideX: BooleanConstructor;
|
|
28
|
-
readonly verticalPosition: {
|
|
29
|
-
readonly type: PropType<"start" | "center" | "end">;
|
|
30
|
-
readonly default: "center";
|
|
31
|
-
};
|
|
32
|
-
readonly horizontalPosition: {
|
|
33
|
-
readonly type: PropType<"start" | "center" | "end">;
|
|
34
|
-
readonly default: "center";
|
|
35
|
-
};
|
|
36
|
-
readonly title: StringConstructor;
|
|
37
|
-
readonly okText: {
|
|
38
|
-
readonly type: StringConstructor;
|
|
39
|
-
readonly default: string;
|
|
40
|
-
};
|
|
41
|
-
readonly okColor: {
|
|
42
|
-
readonly type: StringConstructor;
|
|
43
|
-
readonly default: "primary";
|
|
44
|
-
};
|
|
45
|
-
readonly closeOnOk: {
|
|
46
|
-
readonly type: BooleanConstructor;
|
|
47
|
-
readonly default: true;
|
|
48
|
-
};
|
|
49
|
-
readonly hideOk: BooleanConstructor;
|
|
50
|
-
readonly okDisabled: BooleanConstructor;
|
|
51
|
-
readonly cancelText: {
|
|
52
|
-
readonly type: StringConstructor;
|
|
53
|
-
readonly default: string;
|
|
54
|
-
};
|
|
55
|
-
readonly cancelColor: {
|
|
56
|
-
readonly type: StringConstructor;
|
|
57
|
-
readonly default: "default";
|
|
58
|
-
};
|
|
59
|
-
readonly hideCancel: BooleanConstructor;
|
|
60
|
-
readonly onOk: PropType<() => void>;
|
|
61
|
-
readonly onCancel: PropType<() => void>;
|
|
62
|
-
readonly modal: PropType<(props: import("./NModal").ModalSlotProps) => JSX.Element>;
|
|
63
|
-
readonly content: PropType<(props: import("./NModal").ModalSlotProps) => JSX.Element>;
|
|
64
|
-
readonly header: PropType<() => JSX.Element>;
|
|
65
|
-
readonly footer: PropType<(props: import("./NModal").ModalSlotProps) => JSX.Element>;
|
|
66
|
-
readonly value: PropType<boolean>;
|
|
67
|
-
readonly onUpdateValue: PropType<(newValue: boolean) => void>;
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* The `NFormModal` is a {@link NModal} with an integrated form.
|
|
71
|
-
* When submitting a `NFormModal` the form is first validated and
|
|
72
|
-
* only if the validation is succesful the `onOk` event is called.
|
|
73
|
-
*/
|
|
74
|
-
declare const Component: import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
|
|
75
|
-
export { Component as NFormModal, Component as default };
|
package/components/NFormModal.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { createVNode as _createVNode } from "vue";
|
|
2
|
-
import { createComponentWithSlots } from '../utils/component';
|
|
3
|
-
import { computed } from 'vue';
|
|
4
|
-
import NForm from './NForm';
|
|
5
|
-
import NModal, { nModalProps } from './NModal';
|
|
6
|
-
export const nFormModalProps = {
|
|
7
|
-
...nModalProps,
|
|
8
|
-
/**
|
|
9
|
-
* The maximum width of the modal. A regular tailwind class.
|
|
10
|
-
*/
|
|
11
|
-
maxWidth: {
|
|
12
|
-
type: String,
|
|
13
|
-
default: 'max-w-lg'
|
|
14
|
-
},
|
|
15
|
-
/**
|
|
16
|
-
* If set to `true` the modal closes when clicking on the background.
|
|
17
|
-
* Default is `false` as the accidental reseting of the whole form is very annoying.
|
|
18
|
-
*/
|
|
19
|
-
closeOnBackground: {
|
|
20
|
-
type: Boolean,
|
|
21
|
-
default: false
|
|
22
|
-
},
|
|
23
|
-
/**
|
|
24
|
-
* The {@link ValidatedForm} to validate the inputs.
|
|
25
|
-
* All inputs should be added to the form.
|
|
26
|
-
*/
|
|
27
|
-
form: Object
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* The `NFormModal` is a {@link NModal} with an integrated form.
|
|
31
|
-
* When submitting a `NFormModal` the form is first validated and
|
|
32
|
-
* only if the validation is succesful the `onOk` event is called.
|
|
33
|
-
*/
|
|
34
|
-
const Component = createComponentWithSlots('NFormModal', nFormModalProps, ['modal', 'header', 'footer'], (props, {
|
|
35
|
-
slots
|
|
36
|
-
}) => {
|
|
37
|
-
const onOk = () => {
|
|
38
|
-
if (!props.form || props.form.validate().isValid) {
|
|
39
|
-
props.onOk?.();
|
|
40
|
-
if (props.closeOnOk) props.onUpdateValue?.(false);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const childProps = computed(() => ({
|
|
44
|
-
...props,
|
|
45
|
-
onOk,
|
|
46
|
-
closeOnOk: false,
|
|
47
|
-
onKeydown: event => {
|
|
48
|
-
if (event.metaKey && event.key === 'Enter') onOk();
|
|
49
|
-
}
|
|
50
|
-
}));
|
|
51
|
-
return () => _createVNode(NModal, childProps.value, {
|
|
52
|
-
default: () => [_createVNode(NForm, {
|
|
53
|
-
"form": props.form
|
|
54
|
-
}, {
|
|
55
|
-
default: () => [slots.default?.()]
|
|
56
|
-
})]
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
export { Component as NFormModal, Component as default };
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import type { HeroIcon } from '../utils/tailwind';
|
|
2
|
-
import type { PropType } from 'vue';
|
|
3
|
-
import { type RouteLocationRaw } from 'vue-router';
|
|
4
|
-
export declare const nIconButtonProps: {
|
|
5
|
-
readonly tooltipText: StringConstructor;
|
|
6
|
-
readonly tooltipContent: PropType<() => JSX.Element>;
|
|
7
|
-
readonly tooltipHide: BooleanConstructor;
|
|
8
|
-
readonly tooltipShow: BooleanConstructor;
|
|
9
|
-
readonly tooltipPlacement: {
|
|
10
|
-
readonly type: PropType<import("./NTooltip").TooltipPlacement>;
|
|
11
|
-
readonly default: "auto";
|
|
12
|
-
};
|
|
13
|
-
readonly tooltipMaxWidth: {
|
|
14
|
-
readonly type: PropType<import("../utils/tailwind").TWMaxWidth>;
|
|
15
|
-
readonly default: "max-w-xs";
|
|
16
|
-
};
|
|
17
|
-
readonly tooltipWrapperClass: StringConstructor;
|
|
18
|
-
readonly tooltipContentClass: StringConstructor;
|
|
19
|
-
readonly tooltipArrowClass: StringConstructor;
|
|
20
|
-
/**
|
|
21
|
-
* The icon of the icon-button.
|
|
22
|
-
*/
|
|
23
|
-
readonly icon: {
|
|
24
|
-
readonly type: PropType<HeroIcon>;
|
|
25
|
-
readonly required: true;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* The route of the icon-button. If this is set, the icon-button becomes a {@link RouterLink}.
|
|
29
|
-
*/
|
|
30
|
-
readonly route: PropType<RouteLocationRaw>;
|
|
31
|
-
/**
|
|
32
|
-
* The color of the icon-button.
|
|
33
|
-
*/
|
|
34
|
-
readonly color: {
|
|
35
|
-
readonly type: StringConstructor;
|
|
36
|
-
readonly default: "default";
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* The shade of the icon-button.
|
|
40
|
-
*/
|
|
41
|
-
readonly shade: {
|
|
42
|
-
readonly type: NumberConstructor;
|
|
43
|
-
readonly default: 500;
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* The size of the icon in tailwind-units.
|
|
47
|
-
*/
|
|
48
|
-
readonly size: {
|
|
49
|
-
readonly type: NumberConstructor;
|
|
50
|
-
readonly default: 5;
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* The html attribute, which indicates the type of the button.
|
|
54
|
-
*/
|
|
55
|
-
readonly type: {
|
|
56
|
-
readonly type: PropType<"submit" | "button" | "reset">;
|
|
57
|
-
readonly default: "button";
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* If set to `true` the icon-button is disabled and no interaction is possible.
|
|
61
|
-
*/
|
|
62
|
-
readonly disabled: BooleanConstructor;
|
|
63
|
-
/**
|
|
64
|
-
* Adds the classes to the icon-button.
|
|
65
|
-
* Use this instead of `class` to style the button, because the button is wrapped inside
|
|
66
|
-
* a div for the tooltip and `class` would be applied to the wrapping div.
|
|
67
|
-
*/
|
|
68
|
-
readonly buttonClass: StringConstructor;
|
|
69
|
-
/**
|
|
70
|
-
* This is called when the icon-button is clicked.
|
|
71
|
-
* It is only called when the `route` prop is not set on the icon-button.
|
|
72
|
-
*/
|
|
73
|
-
readonly onClick: PropType<() => void>;
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* The `NIconButton` is a regular button which does not have any text but an icon instead.
|
|
77
|
-
*/
|
|
78
|
-
declare const Component: import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
|
|
79
|
-
export { Component as NIconButton, Component as default };
|