@naptics/vue-collection 0.0.4 → 0.0.5
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/i18n/index.js +4 -4
- package/index.js +1 -1
- package/package.json +1 -1
- package/utils/breakpoints.js +21 -21
- package/utils/component.js +9 -17
- package/utils/deferred.js +12 -12
- package/utils/identifiable.js +29 -27
- package/utils/stringMaxLength.js +13 -8
- package/utils/tailwind.js +1 -1
- package/utils/utils.js +5 -5
- package/utils/vModel.js +73 -82
- package/utils/validation.js +81 -55
- package/utils/vue.js +5 -7
- package/components/NAlert.jsx +0 -69
- package/components/NBadge.jsx +0 -58
- package/components/NBreadcrub.jsx +0 -64
- package/components/NButton.jsx +0 -58
- package/components/NCheckbox.jsx +0 -38
- package/components/NCheckboxLabel.jsx +0 -42
- package/components/NCrudModal.jsx +0 -89
- package/components/NDialog.jsx +0 -144
- package/components/NDropdown.jsx +0 -92
- package/components/NDropzone.jsx +0 -211
- package/components/NForm.jsx +0 -26
- package/components/NFormModal.jsx +0 -48
- package/components/NIconButton.jsx +0 -71
- package/components/NIconCircle.jsx +0 -67
- package/components/NInput.jsx +0 -97
- package/components/NInputPhone.jsx +0 -32
- package/components/NInputSelect.jsx +0 -89
- package/components/NInputSuggestion.jsx +0 -48
- package/components/NLink.jsx +0 -58
- package/components/NList.jsx +0 -24
- package/components/NLoadingIndicator.jsx +0 -42
- package/components/NModal.jsx +0 -170
- package/components/NPagination.jsx +0 -104
- package/components/NSearchbar.jsx +0 -58
- package/components/NSearchbarList.jsx +0 -20
- package/components/NSelect.jsx +0 -81
- package/components/NSuggestionList.jsx +0 -157
- package/components/NTable.jsx +0 -146
- package/components/NTableAction.jsx +0 -35
- package/components/NTextArea.jsx +0 -108
- package/components/NTooltip.jsx +0 -161
- package/components/NValInput.jsx +0 -101
package/i18n/index.js
CHANGED
|
@@ -6,7 +6,7 @@ let provider = undefined;
|
|
|
6
6
|
* @param newProvider
|
|
7
7
|
*/
|
|
8
8
|
export function registerTranslationProvider(newProvider) {
|
|
9
|
-
|
|
9
|
+
provider = newProvider;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Translates the specified key with the according message.
|
|
@@ -15,7 +15,7 @@ export function registerTranslationProvider(newProvider) {
|
|
|
15
15
|
* @returns the translated message.
|
|
16
16
|
*/
|
|
17
17
|
export function trsl(key, params) {
|
|
18
|
-
|
|
18
|
+
return provider?.trsl(key, params) ?? key;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Translates the specified key using pluralization.
|
|
@@ -27,5 +27,5 @@ export function trsl(key, params) {
|
|
|
27
27
|
* @see trsl
|
|
28
28
|
*/
|
|
29
29
|
export function trslc(key, count, params) {
|
|
30
|
-
|
|
31
|
-
}
|
|
30
|
+
return provider?.trslc(key, count, params) ?? key;
|
|
31
|
+
}
|
package/index.js
CHANGED
|
@@ -64,4 +64,4 @@ export { NValInput };
|
|
|
64
64
|
import { createValidatedForm } from './components/ValidatedForm';
|
|
65
65
|
export { createValidatedForm };
|
|
66
66
|
import { createComponent, createView, createProps } from './utils/component';
|
|
67
|
-
export { createComponent, createView, createProps };
|
|
67
|
+
export { createComponent, createView, createProps };
|
package/package.json
CHANGED
package/utils/breakpoints.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { computed, ref } from 'vue';
|
|
2
2
|
export const breakpoints = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
sm: 640,
|
|
4
|
+
md: 768,
|
|
5
|
+
lg: 1024,
|
|
6
|
+
xl: 1280,
|
|
7
|
+
'2xl': 1536,
|
|
8
8
|
};
|
|
9
9
|
export const bodyWidth = ref(document.body.clientWidth);
|
|
10
10
|
/**
|
|
@@ -12,26 +12,26 @@ export const bodyWidth = ref(document.body.clientWidth);
|
|
|
12
12
|
* It sets a `window.onresize` listener.
|
|
13
13
|
*/
|
|
14
14
|
export function addDocumentResizeEventListener() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
window.onresize = () => {
|
|
16
|
+
bodyWidth.value = document.body.clientWidth;
|
|
17
|
+
};
|
|
18
18
|
}
|
|
19
19
|
export function isWidthBreakpoint(breakpoint) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
switch (breakpoint) {
|
|
21
|
+
case 'sm':
|
|
22
|
+
return isWidthSm;
|
|
23
|
+
case 'md':
|
|
24
|
+
return isWidthMd;
|
|
25
|
+
case 'lg':
|
|
26
|
+
return isWidthLg;
|
|
27
|
+
case 'xl':
|
|
28
|
+
return isWidthXl;
|
|
29
|
+
case '2xl':
|
|
30
|
+
return isWidth2xl;
|
|
31
|
+
}
|
|
32
32
|
}
|
|
33
33
|
export const isWidth2xl = computed(() => bodyWidth.value > breakpoints['2xl']);
|
|
34
34
|
export const isWidthXl = computed(() => bodyWidth.value > breakpoints.xl);
|
|
35
35
|
export const isWidthLg = computed(() => bodyWidth.value > breakpoints.lg);
|
|
36
36
|
export const isWidthMd = computed(() => bodyWidth.value > breakpoints.md);
|
|
37
|
-
export const isWidthSm = computed(() => bodyWidth.value > breakpoints.sm);
|
|
37
|
+
export const isWidthSm = computed(() => bodyWidth.value > breakpoints.sm);
|
package/utils/component.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, reactive, toRef } from 'vue';
|
|
1
|
+
import { defineComponent, reactive, toRef, } from 'vue';
|
|
2
2
|
/**
|
|
3
3
|
* Components should be created using this helper function.
|
|
4
4
|
* It only takes three arguments, the name and the props of the component and the setup function.
|
|
@@ -10,12 +10,7 @@ import { defineComponent, reactive, toRef } from 'vue';
|
|
|
10
10
|
* @returns the created vue-component.
|
|
11
11
|
*/
|
|
12
12
|
export function createComponent(name, props, setup) {
|
|
13
|
-
|
|
14
|
-
name,
|
|
15
|
-
props,
|
|
16
|
-
emits: [],
|
|
17
|
-
setup
|
|
18
|
-
});
|
|
13
|
+
return defineComponent({ name, props, emits: [], setup });
|
|
19
14
|
}
|
|
20
15
|
/**
|
|
21
16
|
* Views should be created using this helper function. Views are special components, which don't have props.
|
|
@@ -26,11 +21,7 @@ export function createComponent(name, props, setup) {
|
|
|
26
21
|
* @returns the created vue-component.
|
|
27
22
|
*/
|
|
28
23
|
export function createView(name, setup) {
|
|
29
|
-
|
|
30
|
-
name,
|
|
31
|
-
emits: [],
|
|
32
|
-
setup: (props, context) => setup(context)
|
|
33
|
-
});
|
|
24
|
+
return defineComponent({ name, emits: [], setup: (props, context) => setup(context) });
|
|
34
25
|
}
|
|
35
26
|
/**
|
|
36
27
|
* If props are specified outside of the {@link createComponent}
|
|
@@ -40,7 +31,7 @@ export function createView(name, setup) {
|
|
|
40
31
|
* @returns the created props, with correct typing.
|
|
41
32
|
*/
|
|
42
33
|
export function createProps(props) {
|
|
43
|
-
|
|
34
|
+
return props;
|
|
44
35
|
}
|
|
45
36
|
/**
|
|
46
37
|
* Extracts props from another prop object and returns a reactive object with the specified props.
|
|
@@ -53,7 +44,8 @@ export function createProps(props) {
|
|
|
53
44
|
* console.log(childProps) // { title: 'hi' }
|
|
54
45
|
*/
|
|
55
46
|
export function extractProps(props, ...keys) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
const partial = {};
|
|
48
|
+
for (const key of keys)
|
|
49
|
+
partial[key] = toRef(props, key);
|
|
50
|
+
return reactive(partial);
|
|
51
|
+
}
|
package/utils/deferred.js
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
* @returns promise, resolve and reject
|
|
4
4
|
*/
|
|
5
5
|
export function deferred() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
6
|
+
let resolve;
|
|
7
|
+
let reject;
|
|
8
|
+
const promise = new Promise((_resolve, _reject) => {
|
|
9
|
+
resolve = _resolve;
|
|
10
|
+
reject = _reject;
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
promise,
|
|
14
|
+
resolve,
|
|
15
|
+
reject,
|
|
16
|
+
};
|
|
17
|
+
}
|
package/utils/identifiable.js
CHANGED
|
@@ -6,8 +6,11 @@ import { markReadonly } from './utils';
|
|
|
6
6
|
* @returns The first item with the specified `id` or `undefined` if none exists.
|
|
7
7
|
*/
|
|
8
8
|
function find(array, id) {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const filtered = array.filter(item => item.id === id);
|
|
10
|
+
if (filtered.length > 0)
|
|
11
|
+
return filtered[0];
|
|
12
|
+
else
|
|
13
|
+
return undefined;
|
|
11
14
|
}
|
|
12
15
|
/**
|
|
13
16
|
* Checks if the given array contains an item with the `id`.
|
|
@@ -16,11 +19,11 @@ function find(array, id) {
|
|
|
16
19
|
* @returns `true` if there is at least one item in the array with the given `id`.
|
|
17
20
|
*/
|
|
18
21
|
function contains(array, id) {
|
|
19
|
-
|
|
22
|
+
return find(array, id) !== undefined;
|
|
20
23
|
}
|
|
21
24
|
function insertSingle(baseArray, insertItem) {
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
const index = baseArray.findIndex(item => item.id === insertItem.id);
|
|
26
|
+
index === -1 ? baseArray.push(insertItem) : baseArray.splice(index, 1, insertItem);
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
26
29
|
* Inserts the items into the given array, replacing items with the same `id`.
|
|
@@ -31,8 +34,8 @@ function insertSingle(baseArray, insertItem) {
|
|
|
31
34
|
* @returns The reference to the same array, which was passed.
|
|
32
35
|
*/
|
|
33
36
|
function insert(array, ...insertItems) {
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
insertItems.forEach(item => insertSingle(array, item));
|
|
38
|
+
return array;
|
|
36
39
|
}
|
|
37
40
|
/**
|
|
38
41
|
* Removes all items with the specified `ids` from the given array.
|
|
@@ -41,14 +44,17 @@ function insert(array, ...insertItems) {
|
|
|
41
44
|
* @returns The reference to the same array, which was passed.
|
|
42
45
|
*/
|
|
43
46
|
function remove(array, ...ids) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
ids.forEach(id => {
|
|
48
|
+
let noMatches = false;
|
|
49
|
+
while (!noMatches) {
|
|
50
|
+
const index = array.findIndex(item => item.id === id);
|
|
51
|
+
if (index != -1)
|
|
52
|
+
array.splice(index, 1);
|
|
53
|
+
else
|
|
54
|
+
noMatches = true;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return array;
|
|
52
58
|
}
|
|
53
59
|
/**
|
|
54
60
|
* Compares the two arrays and checks if they both have
|
|
@@ -58,19 +64,15 @@ function remove(array, ...ids) {
|
|
|
58
64
|
* @returns `true` if the arrays contain item with the same `ids` in the same order.
|
|
59
65
|
*/
|
|
60
66
|
function areSameArrays(first, second) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
if (first.length != second.length)
|
|
68
|
+
return false;
|
|
69
|
+
for (let i = 0; i < first.length; i++) {
|
|
70
|
+
if (first[i]?.id !== second[i]?.id)
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
66
74
|
}
|
|
67
75
|
/**
|
|
68
76
|
* This object contains utility functions to deal with {@link Identifiable} objects.
|
|
69
77
|
*/
|
|
70
|
-
export const Id = markReadonly({
|
|
71
|
-
find,
|
|
72
|
-
contains,
|
|
73
|
-
insert,
|
|
74
|
-
remove,
|
|
75
|
-
areSameArrays
|
|
76
|
-
});
|
|
78
|
+
export const Id = markReadonly({ find, contains, insert, remove, areSameArrays });
|
package/utils/stringMaxLength.js
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
* @see maxLengthSplitCenter
|
|
6
6
|
*/
|
|
7
7
|
export function maxLength(input, maxLength) {
|
|
8
|
-
|
|
8
|
+
if (input && input.length > maxLength)
|
|
9
|
+
return `${input.substring(0, maxLength - 3).trim()}...`;
|
|
10
|
+
else
|
|
11
|
+
return input || '';
|
|
9
12
|
}
|
|
10
13
|
/**
|
|
11
14
|
* Returns a shortened string with '...' in the center of the string if it is longer than the given `maxLength`.
|
|
@@ -14,10 +17,12 @@ export function maxLength(input, maxLength) {
|
|
|
14
17
|
* @see maxLength
|
|
15
18
|
*/
|
|
16
19
|
export function maxLengthSplitCenter(input, maxLength) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
if (input && input.length > maxLength) {
|
|
21
|
+
const chars = maxLength - 3;
|
|
22
|
+
const charsAtStart = Math.ceil(chars / 2);
|
|
23
|
+
const charsAtEnd = Math.floor(chars / 2);
|
|
24
|
+
return `${input.substring(0, charsAtStart).trim()}...${input.substring(input.length - charsAtEnd).trim()}`;
|
|
25
|
+
}
|
|
26
|
+
else
|
|
27
|
+
return input || '';
|
|
28
|
+
}
|
package/utils/tailwind.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/utils/utils.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export function markReadonly(object) {
|
|
2
|
-
|
|
2
|
+
return object;
|
|
3
3
|
}
|
|
4
4
|
let currentId = 1;
|
|
5
5
|
/**
|
|
6
6
|
* Generates and returns a non random but unique id.
|
|
7
7
|
*/
|
|
8
8
|
export function uniqueId() {
|
|
9
|
-
|
|
9
|
+
return currentId++;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Determines if a value is not null or undefined.
|
|
@@ -14,7 +14,7 @@ export function uniqueId() {
|
|
|
14
14
|
* @returns `true` if the value is anything but `null` or `undefined`.
|
|
15
15
|
*/
|
|
16
16
|
export function notNullish(value) {
|
|
17
|
-
|
|
17
|
+
return value !== null && value !== undefined;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Determines if a value is null or undefined.
|
|
@@ -22,5 +22,5 @@ export function notNullish(value) {
|
|
|
22
22
|
* @returns `true` if the value is `null` or `undefined`.
|
|
23
23
|
*/
|
|
24
24
|
export function isNullish(value) {
|
|
25
|
-
|
|
26
|
-
}
|
|
25
|
+
return value === null || value === undefined;
|
|
26
|
+
}
|
package/utils/vModel.js
CHANGED
|
@@ -8,54 +8,54 @@
|
|
|
8
8
|
* @returns An object containing the value-property and the update-function.
|
|
9
9
|
*/
|
|
10
10
|
export function vModelProps(propType) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
return {
|
|
12
|
+
/**
|
|
13
|
+
* The value of the component.
|
|
14
|
+
*/
|
|
15
|
+
value: propType,
|
|
16
|
+
/**
|
|
17
|
+
* This will be called, when the value of the component has changed.
|
|
18
|
+
*/
|
|
19
|
+
onUpdateValue: Function,
|
|
20
|
+
};
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* Creates props for a required `v-model` of the given type.
|
|
24
24
|
* @see {@link vModelProps}
|
|
25
25
|
*/
|
|
26
26
|
export function vModelRequiredProps(propType) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
return {
|
|
28
|
+
/**
|
|
29
|
+
* The value of the component.
|
|
30
|
+
*/
|
|
31
|
+
value: {
|
|
32
|
+
type: propType,
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* This will be called, when the value of the component has changed.
|
|
37
|
+
*/
|
|
38
|
+
onUpdateValue: Function,
|
|
39
|
+
};
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Creates props for a `v-model` of the given type with a default value.
|
|
43
43
|
* @see {@link vModelProps}
|
|
44
44
|
*/
|
|
45
45
|
export function vModelDefaultProps(propType, defaultValue) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
46
|
+
return {
|
|
47
|
+
/**
|
|
48
|
+
* The value of the component.
|
|
49
|
+
*/
|
|
50
|
+
value: {
|
|
51
|
+
type: propType,
|
|
52
|
+
default: defaultValue,
|
|
53
|
+
},
|
|
54
|
+
/**
|
|
55
|
+
* This will be called, when the value of the component has changed.
|
|
56
|
+
*/
|
|
57
|
+
onUpdateValue: Function,
|
|
58
|
+
};
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
61
|
* Uses the given `ref` as a `v-model`, to create a two-way binding with the `ref`.
|
|
@@ -63,12 +63,12 @@ export function vModelDefaultProps(propType, defaultValue) {
|
|
|
63
63
|
* @returns An object of type {@link VModel}, which connects the `ref` to the `v-model`.
|
|
64
64
|
*/
|
|
65
65
|
export function vModelForRef(ref) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
return {
|
|
67
|
+
value: ref.value,
|
|
68
|
+
onUpdateValue: (newValue) => {
|
|
69
|
+
ref.value = newValue;
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
74
|
* This creates a `v-model` for a property of an object. The property of the object is taken as the
|
|
@@ -93,15 +93,12 @@ export function vModelForRef(ref) {
|
|
|
93
93
|
* ```
|
|
94
94
|
*/
|
|
95
95
|
export function vModelForObjectProperty(object, key, onUpdate) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
};
|
|
96
|
+
return {
|
|
97
|
+
value: object[key],
|
|
98
|
+
onUpdateValue: (newValue) => {
|
|
99
|
+
onUpdate?.({ ...object, [key]: newValue });
|
|
100
|
+
},
|
|
101
|
+
};
|
|
105
102
|
}
|
|
106
103
|
/**
|
|
107
104
|
* This creates a `v-model` which operates on one property of a parent `v-model`. It takes the value of
|
|
@@ -133,15 +130,12 @@ export function vModelForObjectProperty(object, key, onUpdate) {
|
|
|
133
130
|
* ```
|
|
134
131
|
*/
|
|
135
132
|
export function vModelForVModelProperty(vModel, key) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
};
|
|
133
|
+
return {
|
|
134
|
+
value: vModel.value[key],
|
|
135
|
+
onUpdateValue: (newValue) => {
|
|
136
|
+
vModel.onUpdateValue?.({ ...vModel.value, [key]: newValue });
|
|
137
|
+
},
|
|
138
|
+
};
|
|
145
139
|
}
|
|
146
140
|
/**
|
|
147
141
|
* This function does the same thing as {@link vModelForVModelProperty},
|
|
@@ -174,15 +168,12 @@ export function vModelForVModelProperty(vModel, key) {
|
|
|
174
168
|
* ```
|
|
175
169
|
*/
|
|
176
170
|
export function vModelForVModelPropertyMapType(vModel, key, mapType) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
};
|
|
171
|
+
return {
|
|
172
|
+
value: vModel.value[key],
|
|
173
|
+
onUpdateValue: (newValue) => {
|
|
174
|
+
vModel.onUpdateValue?.({ ...vModel.value, [key]: mapType(newValue) });
|
|
175
|
+
},
|
|
176
|
+
};
|
|
186
177
|
}
|
|
187
178
|
/**
|
|
188
179
|
* Creates an array of `v-models`, one for every element of an array. All changes in
|
|
@@ -209,16 +200,16 @@ export function vModelForVModelPropertyMapType(vModel, key, mapType) {
|
|
|
209
200
|
* ```
|
|
210
201
|
*/
|
|
211
202
|
export function vModelsForArray(array, onUpdate) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
203
|
+
return array.map((entry, index) => ({
|
|
204
|
+
value: entry,
|
|
205
|
+
onUpdateValue: (entry) => {
|
|
206
|
+
const newArray = [...array];
|
|
207
|
+
newArray[index] = entry;
|
|
208
|
+
onUpdate?.(newArray);
|
|
209
|
+
},
|
|
210
|
+
remove: () => {
|
|
211
|
+
const newArray = [...array.slice(0, index), ...array.slice(index + 1)];
|
|
212
|
+
onUpdate?.(newArray);
|
|
213
|
+
},
|
|
214
|
+
}));
|
|
215
|
+
}
|