@naptics/vue-collection 0.2.7 → 0.2.8
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.
|
@@ -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.8",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|