@naptics/vue-collection 0.0.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/README.md +27 -0
- package/lib/components/NAlert.d.ts +72 -0
- package/lib/components/NAlert.jsx +69 -0
- package/lib/components/NBadge.d.ts +174 -0
- package/lib/components/NBadge.jsx +58 -0
- package/lib/components/NBreadcrub.d.ts +161 -0
- package/lib/components/NBreadcrub.jsx +64 -0
- package/lib/components/NButton.d.ts +149 -0
- package/lib/components/NButton.jsx +58 -0
- package/lib/components/NCheckbox.d.ts +51 -0
- package/lib/components/NCheckbox.jsx +38 -0
- package/lib/components/NCheckboxLabel.d.ts +70 -0
- package/lib/components/NCheckboxLabel.jsx +42 -0
- package/lib/components/NCrudModal.d.ts +301 -0
- package/lib/components/NCrudModal.jsx +89 -0
- package/lib/components/NDialog.d.ts +190 -0
- package/lib/components/NDialog.jsx +144 -0
- package/lib/components/NDropdown.d.ts +116 -0
- package/lib/components/NDropdown.jsx +92 -0
- package/lib/components/NDropzone.d.ts +162 -0
- package/lib/components/NDropzone.jsx +211 -0
- package/lib/components/NForm.d.ts +43 -0
- package/lib/components/NForm.jsx +26 -0
- package/lib/components/NFormModal.d.ts +190 -0
- package/lib/components/NFormModal.jsx +48 -0
- package/lib/components/NIconButton.d.ts +202 -0
- package/lib/components/NIconButton.jsx +71 -0
- package/lib/components/NIconCircle.d.ts +135 -0
- package/lib/components/NIconCircle.jsx +67 -0
- package/lib/components/NInput.css +11 -0
- package/lib/components/NInput.d.ts +232 -0
- package/lib/components/NInput.jsx +97 -0
- package/lib/components/NInputPhone.d.ts +150 -0
- package/lib/components/NInputPhone.jsx +31 -0
- package/lib/components/NInputSelect.d.ts +271 -0
- package/lib/components/NInputSelect.jsx +89 -0
- package/lib/components/NInputSuggestion.d.ts +212 -0
- package/lib/components/NInputSuggestion.jsx +48 -0
- package/lib/components/NLink.d.ts +111 -0
- package/lib/components/NLink.jsx +58 -0
- package/lib/components/NList.d.ts +43 -0
- package/lib/components/NList.jsx +24 -0
- package/lib/components/NLoadingIndicator.css +46 -0
- package/lib/components/NLoadingIndicator.d.ts +77 -0
- package/lib/components/NLoadingIndicator.jsx +42 -0
- package/lib/components/NModal.d.ts +333 -0
- package/lib/components/NModal.jsx +170 -0
- package/lib/components/NPagination.css +15 -0
- package/lib/components/NPagination.d.ts +99 -0
- package/lib/components/NPagination.jsx +104 -0
- package/lib/components/NSearchbar.d.ts +94 -0
- package/lib/components/NSearchbar.jsx +58 -0
- package/lib/components/NSearchbarList.d.ts +90 -0
- package/lib/components/NSearchbarList.jsx +20 -0
- package/lib/components/NSelect.d.ts +159 -0
- package/lib/components/NSelect.jsx +81 -0
- package/lib/components/NSuggestionList.d.ts +275 -0
- package/lib/components/NSuggestionList.jsx +157 -0
- package/lib/components/NTable.css +3 -0
- package/lib/components/NTable.d.ts +187 -0
- package/lib/components/NTable.jsx +146 -0
- package/lib/components/NTableAction.d.ts +74 -0
- package/lib/components/NTableAction.jsx +35 -0
- package/lib/components/NTextArea.d.ts +252 -0
- package/lib/components/NTextArea.jsx +108 -0
- package/lib/components/NTooltip.css +37 -0
- package/lib/components/NTooltip.d.ts +186 -0
- package/lib/components/NTooltip.jsx +161 -0
- package/lib/components/NValInput.d.ts +297 -0
- package/lib/components/NValInput.jsx +101 -0
- package/lib/components/ValidatedForm.d.ts +34 -0
- package/lib/components/ValidatedForm.js +25 -0
- package/lib/i18n/de/template.json +10 -0
- package/lib/i18n/de/vue-collection.json +58 -0
- package/lib/i18n/de.d.ts +61 -0
- package/lib/i18n/de.js +5 -0
- package/lib/i18n/en/template.json +10 -0
- package/lib/i18n/en/vue-collection.json +58 -0
- package/lib/i18n/en.d.ts +61 -0
- package/lib/i18n/en.js +5 -0
- package/lib/i18n/index.d.ts +17 -0
- package/lib/i18n/index.js +34 -0
- package/lib/index.d.ts +64 -0
- package/lib/index.js +65 -0
- package/lib/utils/breakpoints.d.ts +15 -0
- package/lib/utils/breakpoints.js +37 -0
- package/lib/utils/component.d.ts +50 -0
- package/lib/utils/component.js +51 -0
- package/lib/utils/deferred.d.ts +13 -0
- package/lib/utils/deferred.js +17 -0
- package/lib/utils/identifiable.d.ts +57 -0
- package/lib/utils/identifiable.js +78 -0
- package/lib/utils/stringMaxLength.d.ts +14 -0
- package/lib/utils/stringMaxLength.js +28 -0
- package/lib/utils/tailwind.d.ts +2 -0
- package/lib/utils/tailwind.js +1 -0
- package/lib/utils/utils.d.ts +27 -0
- package/lib/utils/utils.js +26 -0
- package/lib/utils/vModel.d.ts +182 -0
- package/lib/utils/vModel.js +215 -0
- package/lib/utils/validation.d.ts +84 -0
- package/lib/utils/validation.js +163 -0
- package/lib/utils/vue.d.ts +13 -0
- package/lib/utils/vue.js +19 -0
- package/package.json +56 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { type Identifiable } from '../utils/identifiable';
|
|
2
|
+
import { type PropType } from 'vue';
|
|
3
|
+
export declare const nInputSelectProps: {
|
|
4
|
+
/**
|
|
5
|
+
* The id of the currently selected option of this input.
|
|
6
|
+
*/
|
|
7
|
+
value: StringConstructor;
|
|
8
|
+
/**
|
|
9
|
+
* This is called with the newly selected id when the selection has changed.
|
|
10
|
+
* This happens, when an item from the suggestion list is selected or the
|
|
11
|
+
* input matches a selection option exactly.
|
|
12
|
+
* If no id is selected, the empty string is passed, in order to
|
|
13
|
+
* match the API of all other inputs who never pass `undefined`.
|
|
14
|
+
*/
|
|
15
|
+
onUpdateValue: PropType<(newValue: string) => void>;
|
|
16
|
+
/**
|
|
17
|
+
* The options which are allowed and suggested for this input.
|
|
18
|
+
* The options are filtered based on the user input.
|
|
19
|
+
*/
|
|
20
|
+
options: {
|
|
21
|
+
type: PropType<InputSelectOption[]>;
|
|
22
|
+
default: () => never[];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* @see {@link nValInputProps.optional}
|
|
26
|
+
*/
|
|
27
|
+
optional: BooleanConstructor;
|
|
28
|
+
/**
|
|
29
|
+
* @see {@link nValInputProps.form}
|
|
30
|
+
*/
|
|
31
|
+
form: PropType<import("./ValidatedForm").ValidatedForm>;
|
|
32
|
+
/**
|
|
33
|
+
* @see {@link nValInputProps.error}
|
|
34
|
+
*/
|
|
35
|
+
error: BooleanConstructor;
|
|
36
|
+
/**
|
|
37
|
+
* @see {@link nValInputProps.errorMessage}
|
|
38
|
+
*/
|
|
39
|
+
errorMessage: StringConstructor;
|
|
40
|
+
/**
|
|
41
|
+
* If set to `true` the list is hidden even if there are still matching items in the list.
|
|
42
|
+
*/
|
|
43
|
+
hideList: BooleanConstructor;
|
|
44
|
+
/**
|
|
45
|
+
* @see {@link nSuggestionListProps.maxItems}
|
|
46
|
+
*/
|
|
47
|
+
maxItems: {
|
|
48
|
+
type: NumberConstructor;
|
|
49
|
+
default: () => 8;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* @see {@link nSuggestionListProps.listItem}
|
|
53
|
+
*/
|
|
54
|
+
listItem: PropType<(props: import("./NSuggestionList").ItemSlotProps<import("./NSuggestionList").SuggestionItem>) => JSX.Element>;
|
|
55
|
+
tooltipText: StringConstructor;
|
|
56
|
+
tooltipContent: PropType<() => void>;
|
|
57
|
+
tooltipHide: BooleanConstructor;
|
|
58
|
+
tooltipShow: BooleanConstructor;
|
|
59
|
+
tooltipPlacement: {
|
|
60
|
+
type: PropType<import("./NTooltip").TooltipPlacement>;
|
|
61
|
+
default: string;
|
|
62
|
+
};
|
|
63
|
+
tooltipMaxWidth: {
|
|
64
|
+
type: PropType<import("../utils/tailwind").TWMaxWidth>;
|
|
65
|
+
default: string;
|
|
66
|
+
};
|
|
67
|
+
name: StringConstructor;
|
|
68
|
+
placeholder: StringConstructor;
|
|
69
|
+
autocomplete: {
|
|
70
|
+
type: StringConstructor;
|
|
71
|
+
default: string;
|
|
72
|
+
};
|
|
73
|
+
type: {
|
|
74
|
+
type: StringConstructor;
|
|
75
|
+
default: string;
|
|
76
|
+
};
|
|
77
|
+
max: StringConstructor;
|
|
78
|
+
min: StringConstructor;
|
|
79
|
+
disabled: BooleanConstructor;
|
|
80
|
+
small: BooleanConstructor;
|
|
81
|
+
hideLabel: BooleanConstructor;
|
|
82
|
+
onFocus: PropType<() => void>;
|
|
83
|
+
onBlur: PropType<() => void>;
|
|
84
|
+
};
|
|
85
|
+
export type InputSelectOption = Identifiable & {
|
|
86
|
+
label: string;
|
|
87
|
+
} & Record<string, unknown>;
|
|
88
|
+
/**
|
|
89
|
+
* The `NInputSelect` is very similar to the {@link NSelect}, but instead of a select input it is a regular input.
|
|
90
|
+
* The user is forced to use a value from the specified options of the input.
|
|
91
|
+
* While they type, the list of options is shown to them and filtered based on their input.
|
|
92
|
+
*/
|
|
93
|
+
declare const _default: import("vue").DefineComponent<{
|
|
94
|
+
/**
|
|
95
|
+
* The id of the currently selected option of this input.
|
|
96
|
+
*/
|
|
97
|
+
value: StringConstructor;
|
|
98
|
+
/**
|
|
99
|
+
* This is called with the newly selected id when the selection has changed.
|
|
100
|
+
* This happens, when an item from the suggestion list is selected or the
|
|
101
|
+
* input matches a selection option exactly.
|
|
102
|
+
* If no id is selected, the empty string is passed, in order to
|
|
103
|
+
* match the API of all other inputs who never pass `undefined`.
|
|
104
|
+
*/
|
|
105
|
+
onUpdateValue: PropType<(newValue: string) => void>;
|
|
106
|
+
/**
|
|
107
|
+
* The options which are allowed and suggested for this input.
|
|
108
|
+
* The options are filtered based on the user input.
|
|
109
|
+
*/
|
|
110
|
+
options: {
|
|
111
|
+
type: PropType<InputSelectOption[]>;
|
|
112
|
+
default: () => never[];
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* @see {@link nValInputProps.optional}
|
|
116
|
+
*/
|
|
117
|
+
optional: BooleanConstructor;
|
|
118
|
+
/**
|
|
119
|
+
* @see {@link nValInputProps.form}
|
|
120
|
+
*/
|
|
121
|
+
form: PropType<import("./ValidatedForm").ValidatedForm>;
|
|
122
|
+
/**
|
|
123
|
+
* @see {@link nValInputProps.error}
|
|
124
|
+
*/
|
|
125
|
+
error: BooleanConstructor;
|
|
126
|
+
/**
|
|
127
|
+
* @see {@link nValInputProps.errorMessage}
|
|
128
|
+
*/
|
|
129
|
+
errorMessage: StringConstructor;
|
|
130
|
+
/**
|
|
131
|
+
* If set to `true` the list is hidden even if there are still matching items in the list.
|
|
132
|
+
*/
|
|
133
|
+
hideList: BooleanConstructor;
|
|
134
|
+
/**
|
|
135
|
+
* @see {@link nSuggestionListProps.maxItems}
|
|
136
|
+
*/
|
|
137
|
+
maxItems: {
|
|
138
|
+
type: NumberConstructor;
|
|
139
|
+
default: () => 8;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* @see {@link nSuggestionListProps.listItem}
|
|
143
|
+
*/
|
|
144
|
+
listItem: PropType<(props: import("./NSuggestionList").ItemSlotProps<import("./NSuggestionList").SuggestionItem>) => JSX.Element>;
|
|
145
|
+
tooltipText: StringConstructor;
|
|
146
|
+
tooltipContent: PropType<() => void>;
|
|
147
|
+
tooltipHide: BooleanConstructor;
|
|
148
|
+
tooltipShow: BooleanConstructor;
|
|
149
|
+
tooltipPlacement: {
|
|
150
|
+
type: PropType<import("./NTooltip").TooltipPlacement>;
|
|
151
|
+
default: string;
|
|
152
|
+
};
|
|
153
|
+
tooltipMaxWidth: {
|
|
154
|
+
type: PropType<import("../utils/tailwind").TWMaxWidth>;
|
|
155
|
+
default: string;
|
|
156
|
+
};
|
|
157
|
+
name: StringConstructor;
|
|
158
|
+
placeholder: StringConstructor;
|
|
159
|
+
autocomplete: {
|
|
160
|
+
type: StringConstructor;
|
|
161
|
+
default: string;
|
|
162
|
+
};
|
|
163
|
+
type: {
|
|
164
|
+
type: StringConstructor;
|
|
165
|
+
default: string;
|
|
166
|
+
};
|
|
167
|
+
max: StringConstructor;
|
|
168
|
+
min: StringConstructor;
|
|
169
|
+
disabled: BooleanConstructor;
|
|
170
|
+
small: BooleanConstructor;
|
|
171
|
+
hideLabel: BooleanConstructor;
|
|
172
|
+
onFocus: PropType<() => void>;
|
|
173
|
+
onBlur: PropType<() => void>;
|
|
174
|
+
}, 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<{
|
|
175
|
+
/**
|
|
176
|
+
* The id of the currently selected option of this input.
|
|
177
|
+
*/
|
|
178
|
+
value: StringConstructor;
|
|
179
|
+
/**
|
|
180
|
+
* This is called with the newly selected id when the selection has changed.
|
|
181
|
+
* This happens, when an item from the suggestion list is selected or the
|
|
182
|
+
* input matches a selection option exactly.
|
|
183
|
+
* If no id is selected, the empty string is passed, in order to
|
|
184
|
+
* match the API of all other inputs who never pass `undefined`.
|
|
185
|
+
*/
|
|
186
|
+
onUpdateValue: PropType<(newValue: string) => void>;
|
|
187
|
+
/**
|
|
188
|
+
* The options which are allowed and suggested for this input.
|
|
189
|
+
* The options are filtered based on the user input.
|
|
190
|
+
*/
|
|
191
|
+
options: {
|
|
192
|
+
type: PropType<InputSelectOption[]>;
|
|
193
|
+
default: () => never[];
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* @see {@link nValInputProps.optional}
|
|
197
|
+
*/
|
|
198
|
+
optional: BooleanConstructor;
|
|
199
|
+
/**
|
|
200
|
+
* @see {@link nValInputProps.form}
|
|
201
|
+
*/
|
|
202
|
+
form: PropType<import("./ValidatedForm").ValidatedForm>;
|
|
203
|
+
/**
|
|
204
|
+
* @see {@link nValInputProps.error}
|
|
205
|
+
*/
|
|
206
|
+
error: BooleanConstructor;
|
|
207
|
+
/**
|
|
208
|
+
* @see {@link nValInputProps.errorMessage}
|
|
209
|
+
*/
|
|
210
|
+
errorMessage: StringConstructor;
|
|
211
|
+
/**
|
|
212
|
+
* If set to `true` the list is hidden even if there are still matching items in the list.
|
|
213
|
+
*/
|
|
214
|
+
hideList: BooleanConstructor;
|
|
215
|
+
/**
|
|
216
|
+
* @see {@link nSuggestionListProps.maxItems}
|
|
217
|
+
*/
|
|
218
|
+
maxItems: {
|
|
219
|
+
type: NumberConstructor;
|
|
220
|
+
default: () => 8;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* @see {@link nSuggestionListProps.listItem}
|
|
224
|
+
*/
|
|
225
|
+
listItem: PropType<(props: import("./NSuggestionList").ItemSlotProps<import("./NSuggestionList").SuggestionItem>) => JSX.Element>;
|
|
226
|
+
tooltipText: StringConstructor;
|
|
227
|
+
tooltipContent: PropType<() => void>;
|
|
228
|
+
tooltipHide: BooleanConstructor;
|
|
229
|
+
tooltipShow: BooleanConstructor;
|
|
230
|
+
tooltipPlacement: {
|
|
231
|
+
type: PropType<import("./NTooltip").TooltipPlacement>;
|
|
232
|
+
default: string;
|
|
233
|
+
};
|
|
234
|
+
tooltipMaxWidth: {
|
|
235
|
+
type: PropType<import("../utils/tailwind").TWMaxWidth>;
|
|
236
|
+
default: string;
|
|
237
|
+
};
|
|
238
|
+
name: StringConstructor;
|
|
239
|
+
placeholder: StringConstructor;
|
|
240
|
+
autocomplete: {
|
|
241
|
+
type: StringConstructor;
|
|
242
|
+
default: string;
|
|
243
|
+
};
|
|
244
|
+
type: {
|
|
245
|
+
type: StringConstructor;
|
|
246
|
+
default: string;
|
|
247
|
+
};
|
|
248
|
+
max: StringConstructor;
|
|
249
|
+
min: StringConstructor;
|
|
250
|
+
disabled: BooleanConstructor;
|
|
251
|
+
small: BooleanConstructor;
|
|
252
|
+
hideLabel: BooleanConstructor;
|
|
253
|
+
onFocus: PropType<() => void>;
|
|
254
|
+
onBlur: PropType<() => void>;
|
|
255
|
+
}>> & {}, {
|
|
256
|
+
small: boolean;
|
|
257
|
+
type: string;
|
|
258
|
+
tooltipHide: boolean;
|
|
259
|
+
tooltipShow: boolean;
|
|
260
|
+
tooltipPlacement: import("./NTooltip").TooltipPlacement;
|
|
261
|
+
tooltipMaxWidth: import("../utils/tailwind").TWMaxWidth;
|
|
262
|
+
options: InputSelectOption[];
|
|
263
|
+
disabled: boolean;
|
|
264
|
+
error: boolean;
|
|
265
|
+
autocomplete: string;
|
|
266
|
+
hideLabel: boolean;
|
|
267
|
+
optional: boolean;
|
|
268
|
+
maxItems: number;
|
|
269
|
+
hideList: boolean;
|
|
270
|
+
}>;
|
|
271
|
+
export default _default;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { createComponent, createProps } from '../utils/component';
|
|
2
|
+
import { Id } from '../utils/identifiable';
|
|
3
|
+
import { option } from '../utils/validation';
|
|
4
|
+
import { vModelForRef } from '../utils/vModel';
|
|
5
|
+
import { watchRef } from '../utils/vue';
|
|
6
|
+
import { computed, ref, watch } from 'vue';
|
|
7
|
+
import { nInputProps } from './NInput';
|
|
8
|
+
import NSuggestionList, { nSuggestionListProps } from './NSuggestionList';
|
|
9
|
+
import NValInput, { nValInputProps } from './NValInput';
|
|
10
|
+
export const nInputSelectProps = createProps({
|
|
11
|
+
...nInputProps,
|
|
12
|
+
/**
|
|
13
|
+
* The id of the currently selected option of this input.
|
|
14
|
+
*/
|
|
15
|
+
value: String,
|
|
16
|
+
/**
|
|
17
|
+
* This is called with the newly selected id when the selection has changed.
|
|
18
|
+
* This happens, when an item from the suggestion list is selected or the
|
|
19
|
+
* input matches a selection option exactly.
|
|
20
|
+
* If no id is selected, the empty string is passed, in order to
|
|
21
|
+
* match the API of all other inputs who never pass `undefined`.
|
|
22
|
+
*/
|
|
23
|
+
onUpdateValue: Function,
|
|
24
|
+
/**
|
|
25
|
+
* The options which are allowed and suggested for this input.
|
|
26
|
+
* The options are filtered based on the user input.
|
|
27
|
+
*/
|
|
28
|
+
options: {
|
|
29
|
+
type: Array,
|
|
30
|
+
default: () => [],
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* @see {@link nValInputProps.optional}
|
|
34
|
+
*/
|
|
35
|
+
optional: nValInputProps.optional,
|
|
36
|
+
/**
|
|
37
|
+
* @see {@link nValInputProps.form}
|
|
38
|
+
*/
|
|
39
|
+
form: nValInputProps.form,
|
|
40
|
+
/**
|
|
41
|
+
* @see {@link nValInputProps.error}
|
|
42
|
+
*/
|
|
43
|
+
error: nValInputProps.error,
|
|
44
|
+
/**
|
|
45
|
+
* @see {@link nValInputProps.errorMessage}
|
|
46
|
+
*/
|
|
47
|
+
errorMessage: nValInputProps.errorMessage,
|
|
48
|
+
/**
|
|
49
|
+
* If set to `true` the list is hidden even if there are still matching items in the list.
|
|
50
|
+
*/
|
|
51
|
+
hideList: nSuggestionListProps.hideList,
|
|
52
|
+
/**
|
|
53
|
+
* @see {@link nSuggestionListProps.maxItems}
|
|
54
|
+
*/
|
|
55
|
+
maxItems: nSuggestionListProps.maxItems,
|
|
56
|
+
/**
|
|
57
|
+
* @see {@link nSuggestionListProps.listItem}
|
|
58
|
+
*/
|
|
59
|
+
listItem: nSuggestionListProps.listItem,
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* The `NInputSelect` is very similar to the {@link NSelect}, but instead of a select input it is a regular input.
|
|
63
|
+
* The user is forced to use a value from the specified options of the input.
|
|
64
|
+
* While they type, the list of options is shown to them and filtered based on their input.
|
|
65
|
+
*/
|
|
66
|
+
export default createComponent('NInputSelect', nInputSelectProps, props => {
|
|
67
|
+
const inputRef = ref();
|
|
68
|
+
const inputValue = ref('');
|
|
69
|
+
watch(() => props.value, newValue => {
|
|
70
|
+
if (newValue) {
|
|
71
|
+
const chosenOption = Id.find(props.options, newValue);
|
|
72
|
+
if (chosenOption)
|
|
73
|
+
inputValue.value = chosenOption.label;
|
|
74
|
+
}
|
|
75
|
+
}, { immediate: true });
|
|
76
|
+
const filteredOptions = computed(() => props.options.filter(option => option.label.includes(inputValue.value || '')));
|
|
77
|
+
const matchedOption = computed(() => {
|
|
78
|
+
const matches = props.options.filter(option => option.label === inputValue.value);
|
|
79
|
+
return matches.length > 0 ? matches[0] : null;
|
|
80
|
+
});
|
|
81
|
+
watchRef(matchedOption, newOption => props.onUpdateValue?.(newOption?.id || ''));
|
|
82
|
+
return () => (<NSuggestionList items={filteredOptions.value} onSelect={props.onUpdateValue} inputValue={inputValue.value} hideList={props.hideList || matchedOption.value != null || filteredOptions.value.length == 0} maxItems={props.maxItems} listItem={props.listItem} input={({ onFocus, onBlur }) => (<NValInput ref={inputRef} {...{ ...props, ...vModelForRef(inputValue) }} rules={option(props.options.map(opt => opt.label))} onFocus={() => {
|
|
83
|
+
onFocus();
|
|
84
|
+
props.onFocus?.();
|
|
85
|
+
}} onBlur={onBlur} disableBlurValidation/>)} onRequestInputFocus={() => inputRef.value?.focus()} onRealBlur={() => {
|
|
86
|
+
props.onBlur?.();
|
|
87
|
+
inputRef?.value?.validate();
|
|
88
|
+
}}/>);
|
|
89
|
+
});
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { type PropType } from 'vue';
|
|
2
|
+
export declare const nInputSuggestionProps: {
|
|
3
|
+
/**
|
|
4
|
+
* If set to `true` the list is hidden even if there are still matching items in the list.
|
|
5
|
+
*/
|
|
6
|
+
hideList: BooleanConstructor;
|
|
7
|
+
/**
|
|
8
|
+
* @see {@link nSuggestionListProps.maxItems}
|
|
9
|
+
*/
|
|
10
|
+
maxItems: {
|
|
11
|
+
type: NumberConstructor;
|
|
12
|
+
default: () => 8;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The suggestions which are shown to the user for this input.
|
|
16
|
+
* The suggestions are filtered based on the user input.
|
|
17
|
+
*/
|
|
18
|
+
suggestions: {
|
|
19
|
+
type: PropType<string[]>;
|
|
20
|
+
default: () => never[];
|
|
21
|
+
};
|
|
22
|
+
input: PropType<(props: import("./NValInput").InputSlotProps) => JSX.Element>;
|
|
23
|
+
optional: BooleanConstructor;
|
|
24
|
+
rules: {
|
|
25
|
+
type: PropType<import("../utils/validation").ValidationRule | import("../utils/validation").ValidationRule[]>;
|
|
26
|
+
default: () => never[];
|
|
27
|
+
};
|
|
28
|
+
form: PropType<import("./ValidatedForm").ValidatedForm>;
|
|
29
|
+
error: BooleanConstructor;
|
|
30
|
+
errorMessage: StringConstructor;
|
|
31
|
+
hideErrorMessage: BooleanConstructor;
|
|
32
|
+
disableBlurValidation: BooleanConstructor;
|
|
33
|
+
tooltipText: StringConstructor;
|
|
34
|
+
tooltipContent: PropType<() => void>;
|
|
35
|
+
tooltipHide: BooleanConstructor;
|
|
36
|
+
tooltipShow: BooleanConstructor;
|
|
37
|
+
tooltipPlacement: {
|
|
38
|
+
type: PropType<import("./NTooltip").TooltipPlacement>;
|
|
39
|
+
default: string;
|
|
40
|
+
};
|
|
41
|
+
tooltipMaxWidth: {
|
|
42
|
+
type: PropType<import("../utils/tailwind").TWMaxWidth>;
|
|
43
|
+
default: string;
|
|
44
|
+
};
|
|
45
|
+
name: StringConstructor;
|
|
46
|
+
placeholder: StringConstructor;
|
|
47
|
+
autocomplete: {
|
|
48
|
+
type: StringConstructor;
|
|
49
|
+
default: string;
|
|
50
|
+
};
|
|
51
|
+
type: {
|
|
52
|
+
type: StringConstructor;
|
|
53
|
+
default: string;
|
|
54
|
+
};
|
|
55
|
+
max: StringConstructor;
|
|
56
|
+
min: StringConstructor;
|
|
57
|
+
disabled: BooleanConstructor;
|
|
58
|
+
small: BooleanConstructor;
|
|
59
|
+
hideLabel: BooleanConstructor;
|
|
60
|
+
onFocus: PropType<() => void>;
|
|
61
|
+
onBlur: PropType<() => void>;
|
|
62
|
+
value: PropType<string>;
|
|
63
|
+
onUpdateValue: PropType<(newValue: string) => void>;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* `NInputSuggestion` is an input, which shows a list of possible suggestions to the user
|
|
67
|
+
* which is filtered while typing. Contrary to {@link NInputSelect} the user is not required to choose any of the suggestions.
|
|
68
|
+
*/
|
|
69
|
+
declare const _default: import("vue").DefineComponent<{
|
|
70
|
+
/**
|
|
71
|
+
* If set to `true` the list is hidden even if there are still matching items in the list.
|
|
72
|
+
*/
|
|
73
|
+
hideList: BooleanConstructor;
|
|
74
|
+
/**
|
|
75
|
+
* @see {@link nSuggestionListProps.maxItems}
|
|
76
|
+
*/
|
|
77
|
+
maxItems: {
|
|
78
|
+
type: NumberConstructor;
|
|
79
|
+
default: () => 8;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* The suggestions which are shown to the user for this input.
|
|
83
|
+
* The suggestions are filtered based on the user input.
|
|
84
|
+
*/
|
|
85
|
+
suggestions: {
|
|
86
|
+
type: PropType<string[]>;
|
|
87
|
+
default: () => never[];
|
|
88
|
+
};
|
|
89
|
+
input: PropType<(props: import("./NValInput").InputSlotProps) => JSX.Element>;
|
|
90
|
+
optional: BooleanConstructor;
|
|
91
|
+
rules: {
|
|
92
|
+
type: PropType<import("../utils/validation").ValidationRule | import("../utils/validation").ValidationRule[]>;
|
|
93
|
+
default: () => never[];
|
|
94
|
+
};
|
|
95
|
+
form: PropType<import("./ValidatedForm").ValidatedForm>;
|
|
96
|
+
error: BooleanConstructor;
|
|
97
|
+
errorMessage: StringConstructor;
|
|
98
|
+
hideErrorMessage: BooleanConstructor;
|
|
99
|
+
disableBlurValidation: BooleanConstructor;
|
|
100
|
+
tooltipText: StringConstructor;
|
|
101
|
+
tooltipContent: PropType<() => void>;
|
|
102
|
+
tooltipHide: BooleanConstructor;
|
|
103
|
+
tooltipShow: BooleanConstructor;
|
|
104
|
+
tooltipPlacement: {
|
|
105
|
+
type: PropType<import("./NTooltip").TooltipPlacement>;
|
|
106
|
+
default: string;
|
|
107
|
+
};
|
|
108
|
+
tooltipMaxWidth: {
|
|
109
|
+
type: PropType<import("../utils/tailwind").TWMaxWidth>;
|
|
110
|
+
default: string;
|
|
111
|
+
};
|
|
112
|
+
name: StringConstructor;
|
|
113
|
+
placeholder: StringConstructor;
|
|
114
|
+
autocomplete: {
|
|
115
|
+
type: StringConstructor;
|
|
116
|
+
default: string;
|
|
117
|
+
};
|
|
118
|
+
type: {
|
|
119
|
+
type: StringConstructor;
|
|
120
|
+
default: string;
|
|
121
|
+
};
|
|
122
|
+
max: StringConstructor;
|
|
123
|
+
min: StringConstructor;
|
|
124
|
+
disabled: BooleanConstructor;
|
|
125
|
+
small: BooleanConstructor;
|
|
126
|
+
hideLabel: BooleanConstructor;
|
|
127
|
+
onFocus: PropType<() => void>;
|
|
128
|
+
onBlur: PropType<() => void>;
|
|
129
|
+
value: PropType<string>;
|
|
130
|
+
onUpdateValue: PropType<(newValue: string) => void>;
|
|
131
|
+
}, 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<{
|
|
132
|
+
/**
|
|
133
|
+
* If set to `true` the list is hidden even if there are still matching items in the list.
|
|
134
|
+
*/
|
|
135
|
+
hideList: BooleanConstructor;
|
|
136
|
+
/**
|
|
137
|
+
* @see {@link nSuggestionListProps.maxItems}
|
|
138
|
+
*/
|
|
139
|
+
maxItems: {
|
|
140
|
+
type: NumberConstructor;
|
|
141
|
+
default: () => 8;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* The suggestions which are shown to the user for this input.
|
|
145
|
+
* The suggestions are filtered based on the user input.
|
|
146
|
+
*/
|
|
147
|
+
suggestions: {
|
|
148
|
+
type: PropType<string[]>;
|
|
149
|
+
default: () => never[];
|
|
150
|
+
};
|
|
151
|
+
input: PropType<(props: import("./NValInput").InputSlotProps) => JSX.Element>;
|
|
152
|
+
optional: BooleanConstructor;
|
|
153
|
+
rules: {
|
|
154
|
+
type: PropType<import("../utils/validation").ValidationRule | import("../utils/validation").ValidationRule[]>;
|
|
155
|
+
default: () => never[];
|
|
156
|
+
};
|
|
157
|
+
form: PropType<import("./ValidatedForm").ValidatedForm>;
|
|
158
|
+
error: BooleanConstructor;
|
|
159
|
+
errorMessage: StringConstructor;
|
|
160
|
+
hideErrorMessage: BooleanConstructor;
|
|
161
|
+
disableBlurValidation: BooleanConstructor;
|
|
162
|
+
tooltipText: StringConstructor;
|
|
163
|
+
tooltipContent: PropType<() => void>;
|
|
164
|
+
tooltipHide: BooleanConstructor;
|
|
165
|
+
tooltipShow: BooleanConstructor;
|
|
166
|
+
tooltipPlacement: {
|
|
167
|
+
type: PropType<import("./NTooltip").TooltipPlacement>;
|
|
168
|
+
default: string;
|
|
169
|
+
};
|
|
170
|
+
tooltipMaxWidth: {
|
|
171
|
+
type: PropType<import("../utils/tailwind").TWMaxWidth>;
|
|
172
|
+
default: string;
|
|
173
|
+
};
|
|
174
|
+
name: StringConstructor;
|
|
175
|
+
placeholder: StringConstructor;
|
|
176
|
+
autocomplete: {
|
|
177
|
+
type: StringConstructor;
|
|
178
|
+
default: string;
|
|
179
|
+
};
|
|
180
|
+
type: {
|
|
181
|
+
type: StringConstructor;
|
|
182
|
+
default: string;
|
|
183
|
+
};
|
|
184
|
+
max: StringConstructor;
|
|
185
|
+
min: StringConstructor;
|
|
186
|
+
disabled: BooleanConstructor;
|
|
187
|
+
small: BooleanConstructor;
|
|
188
|
+
hideLabel: BooleanConstructor;
|
|
189
|
+
onFocus: PropType<() => void>;
|
|
190
|
+
onBlur: PropType<() => void>;
|
|
191
|
+
value: PropType<string>;
|
|
192
|
+
onUpdateValue: PropType<(newValue: string) => void>;
|
|
193
|
+
}>> & {}, {
|
|
194
|
+
small: boolean;
|
|
195
|
+
type: string;
|
|
196
|
+
tooltipHide: boolean;
|
|
197
|
+
tooltipShow: boolean;
|
|
198
|
+
tooltipPlacement: import("./NTooltip").TooltipPlacement;
|
|
199
|
+
tooltipMaxWidth: import("../utils/tailwind").TWMaxWidth;
|
|
200
|
+
disabled: boolean;
|
|
201
|
+
error: boolean;
|
|
202
|
+
rules: import("../utils/validation").ValidationRule | import("../utils/validation").ValidationRule[];
|
|
203
|
+
autocomplete: string;
|
|
204
|
+
hideLabel: boolean;
|
|
205
|
+
optional: boolean;
|
|
206
|
+
hideErrorMessage: boolean;
|
|
207
|
+
disableBlurValidation: boolean;
|
|
208
|
+
maxItems: number;
|
|
209
|
+
hideList: boolean;
|
|
210
|
+
suggestions: string[];
|
|
211
|
+
}>;
|
|
212
|
+
export default _default;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createComponent, createProps } from '../utils/component';
|
|
2
|
+
import { Id } from '../utils/identifiable';
|
|
3
|
+
import { computed, ref } from 'vue';
|
|
4
|
+
import NSuggestionList, { nSuggestionListProps } from './NSuggestionList';
|
|
5
|
+
import NValInput, { nValInputProps } from './NValInput';
|
|
6
|
+
export const nInputSuggestionProps = createProps({
|
|
7
|
+
...nValInputProps,
|
|
8
|
+
/**
|
|
9
|
+
* If set to `true` the list is hidden even if there are still matching items in the list.
|
|
10
|
+
*/
|
|
11
|
+
hideList: nSuggestionListProps.hideList,
|
|
12
|
+
/**
|
|
13
|
+
* @see {@link nSuggestionListProps.maxItems}
|
|
14
|
+
*/
|
|
15
|
+
maxItems: nSuggestionListProps.maxItems,
|
|
16
|
+
/**
|
|
17
|
+
* The suggestions which are shown to the user for this input.
|
|
18
|
+
* The suggestions are filtered based on the user input.
|
|
19
|
+
*/
|
|
20
|
+
suggestions: {
|
|
21
|
+
type: Array,
|
|
22
|
+
default: () => [],
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* `NInputSuggestion` is an input, which shows a list of possible suggestions to the user
|
|
27
|
+
* which is filtered while typing. Contrary to {@link NInputSelect} the user is not required to choose any of the suggestions.
|
|
28
|
+
*/
|
|
29
|
+
export default createComponent('NInputSuggestion', nInputSuggestionProps, props => {
|
|
30
|
+
const suggestionItems = computed(() => props.suggestions
|
|
31
|
+
.filter(suggestion => suggestion.includes(props.value || ''))
|
|
32
|
+
.map((value, index) => ({
|
|
33
|
+
id: index.toString(),
|
|
34
|
+
label: value,
|
|
35
|
+
})));
|
|
36
|
+
const select = (id) => props.onUpdateValue?.(Id.find(suggestionItems.value, id)?.label || '');
|
|
37
|
+
const hideList = computed(() => props.hideList ||
|
|
38
|
+
suggestionItems.value.length == 0 ||
|
|
39
|
+
suggestionItems.value.filter(suggestion => suggestion.label !== props.value).length == 0);
|
|
40
|
+
const inputRef = ref();
|
|
41
|
+
return () => (<NSuggestionList items={suggestionItems.value} onSelect={id => select(id)} inputValue={props.value || ''} hideList={hideList.value} maxItems={props.maxItems} input={({ onFocus, onBlur }) => (<NValInput ref={inputRef} {...props} onFocus={() => {
|
|
42
|
+
onFocus();
|
|
43
|
+
props.onFocus?.();
|
|
44
|
+
}} onBlur={onBlur} disableBlurValidation/>)} onRequestInputFocus={() => inputRef.value?.focus()} onRealBlur={() => {
|
|
45
|
+
props.onBlur?.();
|
|
46
|
+
inputRef?.value?.validate();
|
|
47
|
+
}}/>);
|
|
48
|
+
});
|