@naptics/vue-collection 0.2.7 → 0.2.9
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.
|
@@ -46,6 +46,10 @@ export declare const nDropzoneProps: {
|
|
|
46
46
|
readonly type: StringConstructor;
|
|
47
47
|
readonly default: "min-h-36";
|
|
48
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* If set to `true`, the dropzone is disabled and does not accept input anymore.
|
|
51
|
+
*/
|
|
52
|
+
readonly disabled: BooleanConstructor;
|
|
49
53
|
readonly value: import("vue").PropType<File[]>;
|
|
50
54
|
readonly onUpdateValue: import("vue").PropType<(newValue: File[]) => void>;
|
|
51
55
|
};
|
|
@@ -101,6 +105,10 @@ declare const Component: import("vue").DefineComponent<{
|
|
|
101
105
|
readonly type: StringConstructor;
|
|
102
106
|
readonly default: "min-h-36";
|
|
103
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* If set to `true`, the dropzone is disabled and does not accept input anymore.
|
|
110
|
+
*/
|
|
111
|
+
readonly disabled: BooleanConstructor;
|
|
104
112
|
readonly value: import("vue").PropType<File[]>;
|
|
105
113
|
readonly onUpdateValue: import("vue").PropType<(newValue: File[]) => void>;
|
|
106
114
|
}, 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<{
|
|
@@ -151,9 +159,14 @@ declare const Component: import("vue").DefineComponent<{
|
|
|
151
159
|
readonly type: StringConstructor;
|
|
152
160
|
readonly default: "min-h-36";
|
|
153
161
|
};
|
|
162
|
+
/**
|
|
163
|
+
* If set to `true`, the dropzone is disabled and does not accept input anymore.
|
|
164
|
+
*/
|
|
165
|
+
readonly disabled: BooleanConstructor;
|
|
154
166
|
readonly value: import("vue").PropType<File[]>;
|
|
155
167
|
readonly onUpdateValue: import("vue").PropType<(newValue: File[]) => void>;
|
|
156
168
|
}>> & {}, {
|
|
169
|
+
readonly disabled: boolean;
|
|
157
170
|
readonly maxFiles: number;
|
|
158
171
|
readonly maxFileSize: number;
|
|
159
172
|
readonly maxLengthFileNames: number;
|
package/components/NDropzone.js
CHANGED
|
@@ -60,7 +60,11 @@ export const nDropzoneProps = {
|
|
|
60
60
|
height: {
|
|
61
61
|
type: String,
|
|
62
62
|
default: 'min-h-36'
|
|
63
|
-
}
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* If set to `true`, the dropzone is disabled and does not accept input anymore.
|
|
66
|
+
*/
|
|
67
|
+
disabled: Boolean
|
|
64
68
|
};
|
|
65
69
|
/**
|
|
66
70
|
* The `NDropzone` is an area where files can be added by the user by drag & drop.
|
|
@@ -112,6 +116,7 @@ const Component = createComponent('NDropzone', nDropzoneProps, props => {
|
|
|
112
116
|
const onDrop = event => {
|
|
113
117
|
event.preventDefault();
|
|
114
118
|
isDragOver.value = false;
|
|
119
|
+
if (props.disabled) return;
|
|
115
120
|
const transfer = event.dataTransfer;
|
|
116
121
|
if (transfer == null) return;
|
|
117
122
|
if (transfer.items.length > 0) {
|
|
@@ -143,11 +148,13 @@ const Component = createComponent('NDropzone', nDropzoneProps, props => {
|
|
|
143
148
|
return () => {
|
|
144
149
|
let _slot;
|
|
145
150
|
return _createVNode("div", null, [_createVNode("button", {
|
|
146
|
-
"class": ['block w-full rounded-md border-dashed border-2
|
|
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],
|
|
147
152
|
"onDrop": onDrop,
|
|
148
153
|
"onDragover": onDragOver,
|
|
149
154
|
"onDragleave": onDragLeave,
|
|
150
|
-
"onClick": onClick
|
|
155
|
+
"onClick": onClick,
|
|
156
|
+
"type": "button",
|
|
157
|
+
"disabled": props.disabled
|
|
151
158
|
}, [_createVNode("input", {
|
|
152
159
|
"type": "file",
|
|
153
160
|
"class": "hidden",
|
|
@@ -123,10 +123,7 @@ export declare const nValInputProps: {
|
|
|
123
123
|
readonly hideLabel: BooleanConstructor;
|
|
124
124
|
readonly inputClass: StringConstructor;
|
|
125
125
|
readonly onFocus: PropType<() => void>;
|
|
126
|
-
readonly onBlur: PropType<() => void>;
|
|
127
|
-
* If set to `true` the error message is not shown.
|
|
128
|
-
* However, the input is still marked red if it is in an error state.
|
|
129
|
-
*/
|
|
126
|
+
readonly onBlur: PropType<() => void>;
|
|
130
127
|
readonly value: PropType<string>;
|
|
131
128
|
readonly onUpdateValue: PropType<(newValue: string) => void>;
|
|
132
129
|
};
|
|
@@ -229,10 +226,7 @@ declare const Component: import("vue").DefineComponent<{
|
|
|
229
226
|
readonly hideLabel: BooleanConstructor;
|
|
230
227
|
readonly inputClass: StringConstructor;
|
|
231
228
|
readonly onFocus: PropType<() => void>;
|
|
232
|
-
readonly onBlur: PropType<() => void>;
|
|
233
|
-
* If set to `true` the error message is not shown.
|
|
234
|
-
* However, the input is still marked red if it is in an error state.
|
|
235
|
-
*/
|
|
229
|
+
readonly onBlur: PropType<() => void>;
|
|
236
230
|
readonly value: PropType<string>;
|
|
237
231
|
readonly onUpdateValue: PropType<(newValue: string) => void>;
|
|
238
232
|
}, 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<{
|
|
@@ -313,10 +307,7 @@ declare const Component: import("vue").DefineComponent<{
|
|
|
313
307
|
readonly hideLabel: BooleanConstructor;
|
|
314
308
|
readonly inputClass: StringConstructor;
|
|
315
309
|
readonly onFocus: PropType<() => void>;
|
|
316
|
-
readonly onBlur: PropType<() => void>;
|
|
317
|
-
* If set to `true` the error message is not shown.
|
|
318
|
-
* However, the input is still marked red if it is in an error state.
|
|
319
|
-
*/
|
|
310
|
+
readonly onBlur: PropType<() => void>;
|
|
320
311
|
readonly value: PropType<string>;
|
|
321
312
|
readonly onUpdateValue: PropType<(newValue: string) => void>;
|
|
322
313
|
}>> & {}, {
|
package/components/NValInput.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createVNode as _createVNode, mergeProps as _mergeProps } from "vue";
|
|
2
2
|
import { createComponentWithSlots } from '../utils/component';
|
|
3
|
-
import { computed } from 'vue';
|
|
3
|
+
import { computed, onMounted, onUnmounted } from 'vue';
|
|
4
4
|
import { ref, reactive, watch } from 'vue';
|
|
5
5
|
import NInput, { nInputProps } from './NInput';
|
|
6
6
|
import { validate, required, validResult } from '../utils/validation';
|
|
@@ -98,7 +98,9 @@ const Component = createComponentWithSlots('NValInput', nValInputProps, ['input'
|
|
|
98
98
|
focus: () => inputRef.value?.focus()
|
|
99
99
|
};
|
|
100
100
|
context.expose(expose);
|
|
101
|
-
|
|
101
|
+
let assignedId = undefined;
|
|
102
|
+
onMounted(() => assignedId = props.form?.addInput(expose));
|
|
103
|
+
onUnmounted(() => assignedId && props.form?.removeInput(assignedId));
|
|
102
104
|
return () => _createVNode("div", null, [props.input?.(inputSlotProps) || _createVNode(NInput, _mergeProps({
|
|
103
105
|
"ref": inputRef
|
|
104
106
|
}, {
|
|
@@ -11,12 +11,17 @@ import type { NValInputExposed } from './NValInput';
|
|
|
11
11
|
*/
|
|
12
12
|
export type ValidatedForm = {
|
|
13
13
|
/**
|
|
14
|
-
* Adds the input to the list of this form
|
|
14
|
+
* Adds the input to the list of this form and returns the assigned `id`.
|
|
15
15
|
* If this form is passed to a `<NValInput />` via the props, will add itself to this form.
|
|
16
|
+
* @returns the newly assigned `id` of the added input.
|
|
16
17
|
* @example
|
|
17
18
|
* <NValInput ... form={form} />
|
|
18
19
|
*/
|
|
19
|
-
addInput(input: NValInputExposed):
|
|
20
|
+
addInput(input: NValInputExposed): string;
|
|
21
|
+
/**
|
|
22
|
+
* Removes the input with the given `id` from this form.
|
|
23
|
+
*/
|
|
24
|
+
removeInput(id: string): void;
|
|
20
25
|
/**
|
|
21
26
|
* Validates all inputs of the form. If inputs are invalid they will show it visually.
|
|
22
27
|
* The first invalid validation result is returned.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Id } from '../utils/identifiable';
|
|
2
|
+
import { uniqueId } from '../utils/utils';
|
|
1
3
|
/**
|
|
2
4
|
* Creates a new ValidatedForm.
|
|
3
5
|
* @returns the instance of the new form.
|
|
@@ -8,7 +10,15 @@ export function createValidatedForm() {
|
|
|
8
10
|
class ValidatedFormImpl {
|
|
9
11
|
inputs = [];
|
|
10
12
|
addInput(input) {
|
|
11
|
-
|
|
13
|
+
const id = `input-${uniqueId()}`;
|
|
14
|
+
this.inputs.push({
|
|
15
|
+
id,
|
|
16
|
+
...input
|
|
17
|
+
});
|
|
18
|
+
return id;
|
|
19
|
+
}
|
|
20
|
+
removeInput(id) {
|
|
21
|
+
Id.remove(this.inputs, id);
|
|
12
22
|
}
|
|
13
23
|
validate() {
|
|
14
24
|
const results = this.inputs.map(input => input.validate());
|
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.2.
|
|
5
|
+
"version": "0.2.9",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|