@naptics/vue-collection 0.2.6 → 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.
@@ -8,7 +8,9 @@ export declare const nSelectProps: {
8
8
  readonly tooltipShow: BooleanConstructor;
9
9
  readonly tooltipPlacement: {
10
10
  readonly type: PropType<import("./NTooltip").TooltipPlacement>;
11
- readonly default: "auto";
11
+ readonly default: "auto"; /**
12
+ * @see {@link nValInputProps.name}
13
+ */
12
14
  };
13
15
  readonly tooltipMaxWidth: {
14
16
  readonly type: PropType<import("../utils/tailwind").TWMaxWidth>;
@@ -34,6 +36,14 @@ export declare const nSelectProps: {
34
36
  readonly type: PropType<SelectionOption[]>;
35
37
  readonly default: () => never[];
36
38
  };
39
+ /**
40
+ * The value which is shown in the empty state.
41
+ * The "nothing-option" will be called like this.
42
+ */
43
+ readonly placeholder: {
44
+ readonly type: StringConstructor;
45
+ readonly default: () => string;
46
+ };
37
47
  /**
38
48
  * @see {@link nValInputProps.name}
39
49
  */
@@ -73,7 +83,9 @@ declare const Component: import("vue").DefineComponent<{
73
83
  readonly tooltipShow: BooleanConstructor;
74
84
  readonly tooltipPlacement: {
75
85
  readonly type: PropType<import("./NTooltip").TooltipPlacement>;
76
- readonly default: "auto";
86
+ readonly default: "auto"; /**
87
+ * @see {@link nValInputProps.name}
88
+ */
77
89
  };
78
90
  readonly tooltipMaxWidth: {
79
91
  readonly type: PropType<import("../utils/tailwind").TWMaxWidth>;
@@ -99,6 +111,14 @@ declare const Component: import("vue").DefineComponent<{
99
111
  readonly type: PropType<SelectionOption[]>;
100
112
  readonly default: () => never[];
101
113
  };
114
+ /**
115
+ * The value which is shown in the empty state.
116
+ * The "nothing-option" will be called like this.
117
+ */
118
+ readonly placeholder: {
119
+ readonly type: StringConstructor;
120
+ readonly default: () => string;
121
+ };
102
122
  /**
103
123
  * @see {@link nValInputProps.name}
104
124
  */
@@ -130,7 +150,9 @@ declare const Component: import("vue").DefineComponent<{
130
150
  readonly tooltipShow: BooleanConstructor;
131
151
  readonly tooltipPlacement: {
132
152
  readonly type: PropType<import("./NTooltip").TooltipPlacement>;
133
- readonly default: "auto";
153
+ readonly default: "auto"; /**
154
+ * @see {@link nValInputProps.name}
155
+ */
134
156
  };
135
157
  readonly tooltipMaxWidth: {
136
158
  readonly type: PropType<import("../utils/tailwind").TWMaxWidth>;
@@ -156,6 +178,14 @@ declare const Component: import("vue").DefineComponent<{
156
178
  readonly type: PropType<SelectionOption[]>;
157
179
  readonly default: () => never[];
158
180
  };
181
+ /**
182
+ * The value which is shown in the empty state.
183
+ * The "nothing-option" will be called like this.
184
+ */
185
+ readonly placeholder: {
186
+ readonly type: StringConstructor;
187
+ readonly default: () => string;
188
+ };
159
189
  /**
160
190
  * @see {@link nValInputProps.name}
161
191
  */
@@ -187,6 +217,7 @@ declare const Component: import("vue").DefineComponent<{
187
217
  readonly tooltipMaxWidth: import("../utils/tailwind").TWMaxWidth;
188
218
  readonly options: SelectionOption[];
189
219
  readonly disabled: boolean;
220
+ readonly placeholder: string;
190
221
  readonly hideLabel: boolean;
191
222
  readonly optional: boolean;
192
223
  }>;
@@ -22,6 +22,14 @@ export const nSelectProps = {
22
22
  type: Array,
23
23
  default: () => []
24
24
  },
25
+ /**
26
+ * The value which is shown in the empty state.
27
+ * The "nothing-option" will be called like this.
28
+ */
29
+ placeholder: {
30
+ type: String,
31
+ default: () => trsl('vue-collection.action.select')
32
+ },
25
33
  /**
26
34
  * @see {@link nValInputProps.name}
27
35
  */
@@ -82,7 +90,7 @@ const Component = createComponent('NSelect', nSelectProps, (props, context) => {
82
90
  "disabled": !props.optional,
83
91
  "selected": !props.value,
84
92
  "value": ""
85
- }, [trsl('vue-collection.action.select')]), props.options.map(option => _createVNode("option", {
93
+ }, [props.placeholder]), props.options.map(option => _createVNode("option", {
86
94
  "key": option.id,
87
95
  "value": option.id,
88
96
  "selected": props.value == option.id
@@ -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
  }>> & {}, {
@@ -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
- props.form?.addInput(expose);
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): void;
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
- this.inputs.push(input);
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.6",
5
+ "version": "0.2.8",
6
6
  "main": "./index.js",
7
7
  "repository": {
8
8
  "type": "git",