@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,232 @@
|
|
|
1
|
+
import { type PropType } from 'vue';
|
|
2
|
+
import './NInput.css';
|
|
3
|
+
export declare const nInputProps: {
|
|
4
|
+
tooltipText: StringConstructor;
|
|
5
|
+
tooltipContent: PropType<() => void>;
|
|
6
|
+
tooltipHide: BooleanConstructor;
|
|
7
|
+
tooltipShow: BooleanConstructor;
|
|
8
|
+
tooltipPlacement: {
|
|
9
|
+
type: PropType<import("./NTooltip").TooltipPlacement>;
|
|
10
|
+
default: string;
|
|
11
|
+
};
|
|
12
|
+
tooltipMaxWidth: {
|
|
13
|
+
type: PropType<import("../utils/tailwind").TWMaxWidth>;
|
|
14
|
+
default: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The name of the input. Is displayed as a label above the input.
|
|
18
|
+
*/
|
|
19
|
+
name: StringConstructor;
|
|
20
|
+
/**
|
|
21
|
+
* The placeholder of the input.
|
|
22
|
+
*/
|
|
23
|
+
placeholder: StringConstructor;
|
|
24
|
+
/**
|
|
25
|
+
* The html autocomplete attribute of the input.
|
|
26
|
+
*/
|
|
27
|
+
autocomplete: {
|
|
28
|
+
type: StringConstructor;
|
|
29
|
+
default: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The html type attribute of the input.
|
|
33
|
+
*/
|
|
34
|
+
type: {
|
|
35
|
+
type: StringConstructor;
|
|
36
|
+
default: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The maximum value of the input.
|
|
40
|
+
*/
|
|
41
|
+
max: StringConstructor;
|
|
42
|
+
/**
|
|
43
|
+
* The minimum value of the input.
|
|
44
|
+
*/
|
|
45
|
+
min: StringConstructor;
|
|
46
|
+
/**
|
|
47
|
+
* If set to `true` the input is displayed with a red border.
|
|
48
|
+
*/
|
|
49
|
+
error: BooleanConstructor;
|
|
50
|
+
/**
|
|
51
|
+
* If set to `true` the input is disabled and no interaction is possible.
|
|
52
|
+
*/
|
|
53
|
+
disabled: BooleanConstructor;
|
|
54
|
+
/**
|
|
55
|
+
* If set to `true` the input is displayed smaller.
|
|
56
|
+
*/
|
|
57
|
+
small: BooleanConstructor;
|
|
58
|
+
/**
|
|
59
|
+
* If set to `true` the input's label is hidden.
|
|
60
|
+
*/
|
|
61
|
+
hideLabel: BooleanConstructor;
|
|
62
|
+
/**
|
|
63
|
+
* This is called when the input reveices focus.
|
|
64
|
+
*/
|
|
65
|
+
onFocus: PropType<() => void>;
|
|
66
|
+
/**
|
|
67
|
+
* This is called when the input looses focus.
|
|
68
|
+
*/
|
|
69
|
+
onBlur: PropType<() => void>;
|
|
70
|
+
value: PropType<string>;
|
|
71
|
+
onUpdateValue: PropType<(newValue: string) => void>;
|
|
72
|
+
};
|
|
73
|
+
export type NInputExposed = {
|
|
74
|
+
/**
|
|
75
|
+
* Request focus on the input.
|
|
76
|
+
*/
|
|
77
|
+
focus(): void;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* The base class of inputs. A styled input with a lot of configuration possibilities but no validation.
|
|
81
|
+
*/
|
|
82
|
+
declare const _default: import("vue").DefineComponent<{
|
|
83
|
+
tooltipText: StringConstructor;
|
|
84
|
+
tooltipContent: PropType<() => void>;
|
|
85
|
+
tooltipHide: BooleanConstructor;
|
|
86
|
+
tooltipShow: BooleanConstructor;
|
|
87
|
+
tooltipPlacement: {
|
|
88
|
+
type: PropType<import("./NTooltip").TooltipPlacement>;
|
|
89
|
+
default: string;
|
|
90
|
+
};
|
|
91
|
+
tooltipMaxWidth: {
|
|
92
|
+
type: PropType<import("../utils/tailwind").TWMaxWidth>;
|
|
93
|
+
default: string;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* The name of the input. Is displayed as a label above the input.
|
|
97
|
+
*/
|
|
98
|
+
name: StringConstructor;
|
|
99
|
+
/**
|
|
100
|
+
* The placeholder of the input.
|
|
101
|
+
*/
|
|
102
|
+
placeholder: StringConstructor;
|
|
103
|
+
/**
|
|
104
|
+
* The html autocomplete attribute of the input.
|
|
105
|
+
*/
|
|
106
|
+
autocomplete: {
|
|
107
|
+
type: StringConstructor;
|
|
108
|
+
default: string;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* The html type attribute of the input.
|
|
112
|
+
*/
|
|
113
|
+
type: {
|
|
114
|
+
type: StringConstructor;
|
|
115
|
+
default: string;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* The maximum value of the input.
|
|
119
|
+
*/
|
|
120
|
+
max: StringConstructor;
|
|
121
|
+
/**
|
|
122
|
+
* The minimum value of the input.
|
|
123
|
+
*/
|
|
124
|
+
min: StringConstructor;
|
|
125
|
+
/**
|
|
126
|
+
* If set to `true` the input is displayed with a red border.
|
|
127
|
+
*/
|
|
128
|
+
error: BooleanConstructor;
|
|
129
|
+
/**
|
|
130
|
+
* If set to `true` the input is disabled and no interaction is possible.
|
|
131
|
+
*/
|
|
132
|
+
disabled: BooleanConstructor;
|
|
133
|
+
/**
|
|
134
|
+
* If set to `true` the input is displayed smaller.
|
|
135
|
+
*/
|
|
136
|
+
small: BooleanConstructor;
|
|
137
|
+
/**
|
|
138
|
+
* If set to `true` the input's label is hidden.
|
|
139
|
+
*/
|
|
140
|
+
hideLabel: BooleanConstructor;
|
|
141
|
+
/**
|
|
142
|
+
* This is called when the input reveices focus.
|
|
143
|
+
*/
|
|
144
|
+
onFocus: PropType<() => void>;
|
|
145
|
+
/**
|
|
146
|
+
* This is called when the input looses focus.
|
|
147
|
+
*/
|
|
148
|
+
onBlur: PropType<() => void>;
|
|
149
|
+
value: PropType<string>;
|
|
150
|
+
onUpdateValue: PropType<(newValue: string) => void>;
|
|
151
|
+
}, 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<{
|
|
152
|
+
tooltipText: StringConstructor;
|
|
153
|
+
tooltipContent: PropType<() => void>;
|
|
154
|
+
tooltipHide: BooleanConstructor;
|
|
155
|
+
tooltipShow: BooleanConstructor;
|
|
156
|
+
tooltipPlacement: {
|
|
157
|
+
type: PropType<import("./NTooltip").TooltipPlacement>;
|
|
158
|
+
default: string;
|
|
159
|
+
};
|
|
160
|
+
tooltipMaxWidth: {
|
|
161
|
+
type: PropType<import("../utils/tailwind").TWMaxWidth>;
|
|
162
|
+
default: string;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* The name of the input. Is displayed as a label above the input.
|
|
166
|
+
*/
|
|
167
|
+
name: StringConstructor;
|
|
168
|
+
/**
|
|
169
|
+
* The placeholder of the input.
|
|
170
|
+
*/
|
|
171
|
+
placeholder: StringConstructor;
|
|
172
|
+
/**
|
|
173
|
+
* The html autocomplete attribute of the input.
|
|
174
|
+
*/
|
|
175
|
+
autocomplete: {
|
|
176
|
+
type: StringConstructor;
|
|
177
|
+
default: string;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* The html type attribute of the input.
|
|
181
|
+
*/
|
|
182
|
+
type: {
|
|
183
|
+
type: StringConstructor;
|
|
184
|
+
default: string;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* The maximum value of the input.
|
|
188
|
+
*/
|
|
189
|
+
max: StringConstructor;
|
|
190
|
+
/**
|
|
191
|
+
* The minimum value of the input.
|
|
192
|
+
*/
|
|
193
|
+
min: StringConstructor;
|
|
194
|
+
/**
|
|
195
|
+
* If set to `true` the input is displayed with a red border.
|
|
196
|
+
*/
|
|
197
|
+
error: BooleanConstructor;
|
|
198
|
+
/**
|
|
199
|
+
* If set to `true` the input is disabled and no interaction is possible.
|
|
200
|
+
*/
|
|
201
|
+
disabled: BooleanConstructor;
|
|
202
|
+
/**
|
|
203
|
+
* If set to `true` the input is displayed smaller.
|
|
204
|
+
*/
|
|
205
|
+
small: BooleanConstructor;
|
|
206
|
+
/**
|
|
207
|
+
* If set to `true` the input's label is hidden.
|
|
208
|
+
*/
|
|
209
|
+
hideLabel: BooleanConstructor;
|
|
210
|
+
/**
|
|
211
|
+
* This is called when the input reveices focus.
|
|
212
|
+
*/
|
|
213
|
+
onFocus: PropType<() => void>;
|
|
214
|
+
/**
|
|
215
|
+
* This is called when the input looses focus.
|
|
216
|
+
*/
|
|
217
|
+
onBlur: PropType<() => void>;
|
|
218
|
+
value: PropType<string>;
|
|
219
|
+
onUpdateValue: PropType<(newValue: string) => void>;
|
|
220
|
+
}>> & {}, {
|
|
221
|
+
small: boolean;
|
|
222
|
+
type: string;
|
|
223
|
+
tooltipHide: boolean;
|
|
224
|
+
tooltipShow: boolean;
|
|
225
|
+
tooltipPlacement: import("./NTooltip").TooltipPlacement;
|
|
226
|
+
tooltipMaxWidth: import("../utils/tailwind").TWMaxWidth;
|
|
227
|
+
disabled: boolean;
|
|
228
|
+
error: boolean;
|
|
229
|
+
autocomplete: string;
|
|
230
|
+
hideLabel: boolean;
|
|
231
|
+
}>;
|
|
232
|
+
export default _default;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createComponent, createProps } from '../utils/component';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import { ExclamationCircleIcon } from '@heroicons/vue/24/solid';
|
|
4
|
+
import NTooltip, { mapTooltipProps, nToolTipPropsForImplementor } from './NTooltip';
|
|
5
|
+
import './NInput.css';
|
|
6
|
+
import { vModelProps } from '../utils/vModel';
|
|
7
|
+
export const nInputProps = createProps({
|
|
8
|
+
...vModelProps(String),
|
|
9
|
+
/**
|
|
10
|
+
* The name of the input. Is displayed as a label above the input.
|
|
11
|
+
*/
|
|
12
|
+
name: String,
|
|
13
|
+
/**
|
|
14
|
+
* The placeholder of the input.
|
|
15
|
+
*/
|
|
16
|
+
placeholder: String,
|
|
17
|
+
/**
|
|
18
|
+
* The html autocomplete attribute of the input.
|
|
19
|
+
*/
|
|
20
|
+
autocomplete: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: 'off',
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* The html type attribute of the input.
|
|
26
|
+
*/
|
|
27
|
+
type: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: 'text',
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* The maximum value of the input.
|
|
33
|
+
*/
|
|
34
|
+
max: String,
|
|
35
|
+
/**
|
|
36
|
+
* The minimum value of the input.
|
|
37
|
+
*/
|
|
38
|
+
min: String,
|
|
39
|
+
/**
|
|
40
|
+
* If set to `true` the input is displayed with a red border.
|
|
41
|
+
*/
|
|
42
|
+
error: Boolean,
|
|
43
|
+
/**
|
|
44
|
+
* If set to `true` the input is disabled and no interaction is possible.
|
|
45
|
+
*/
|
|
46
|
+
disabled: Boolean,
|
|
47
|
+
/**
|
|
48
|
+
* If set to `true` the input is displayed smaller.
|
|
49
|
+
*/
|
|
50
|
+
small: Boolean,
|
|
51
|
+
/**
|
|
52
|
+
* If set to `true` the input's label is hidden.
|
|
53
|
+
*/
|
|
54
|
+
hideLabel: Boolean,
|
|
55
|
+
/**
|
|
56
|
+
* This is called when the input reveices focus.
|
|
57
|
+
*/
|
|
58
|
+
onFocus: Function,
|
|
59
|
+
/**
|
|
60
|
+
* This is called when the input looses focus.
|
|
61
|
+
*/
|
|
62
|
+
onBlur: Function,
|
|
63
|
+
...nToolTipPropsForImplementor,
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* The base class of inputs. A styled input with a lot of configuration possibilities but no validation.
|
|
67
|
+
*/
|
|
68
|
+
export default createComponent('NInput', nInputProps, (props, context) => {
|
|
69
|
+
const inputRef = ref();
|
|
70
|
+
const exposed = {
|
|
71
|
+
focus: () => inputRef.value?.focus(),
|
|
72
|
+
};
|
|
73
|
+
context.expose(exposed);
|
|
74
|
+
return () => (<div>
|
|
75
|
+
{props.name && !props.hideLabel && (<label for={props.name} class={['block text-sm font-medium mb-1', props.disabled ? 'text-default-300' : 'text-default-700']}>
|
|
76
|
+
{props.name}
|
|
77
|
+
</label>)}
|
|
78
|
+
<NTooltip block {...mapTooltipProps(props)}>
|
|
79
|
+
<div class="relative">
|
|
80
|
+
<input ref={inputRef} name={props.name} value={props.value} onInput={event => props.onUpdateValue?.(event.target.value)} placeholder={props.placeholder} autocomplete={props.autocomplete} type={props.type} min={props.min} max={props.max} disabled={props.disabled} onFocus={() => props.onFocus?.()} onBlur={() => props.onBlur?.()} onInvalid={event => event.preventDefault()} class={[
|
|
81
|
+
'block w-full rounded-md border focus:outline-none focus:ring-1 ',
|
|
82
|
+
props.small ? 'text-xs py-0.5 px-2' : 'py-2 px-4',
|
|
83
|
+
props.disabled
|
|
84
|
+
? 'text-default-500 placeholder-default-300 bg-default-50'
|
|
85
|
+
: 'text-default-900 placeholder-default-400 ',
|
|
86
|
+
props.error
|
|
87
|
+
? 'border-red-500 focus:border-red-500 focus:ring-red-500 pr-10'
|
|
88
|
+
: 'border-default-300 focus:border-primary-500 focus:ring-primary-500',
|
|
89
|
+
]}/>
|
|
90
|
+
|
|
91
|
+
<div class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none" v-show={props.error && !props.small}>
|
|
92
|
+
<ExclamationCircleIcon class="h-5 w-5 text-red-700" aria-hidden="true"/>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
</NTooltip>
|
|
96
|
+
</div>);
|
|
97
|
+
});
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
export declare const nInputPhoneProps: {
|
|
2
|
+
input: import("vue").PropType<(props: import("./NValInput").InputSlotProps) => JSX.Element>;
|
|
3
|
+
optional: BooleanConstructor;
|
|
4
|
+
rules: {
|
|
5
|
+
type: import("vue").PropType<import("../utils/validation").ValidationRule | import("../utils/validation").ValidationRule[]>;
|
|
6
|
+
default: () => never[];
|
|
7
|
+
};
|
|
8
|
+
form: import("vue").PropType<import("./ValidatedForm").ValidatedForm>;
|
|
9
|
+
error: BooleanConstructor;
|
|
10
|
+
errorMessage: StringConstructor;
|
|
11
|
+
hideErrorMessage: BooleanConstructor;
|
|
12
|
+
disableBlurValidation: BooleanConstructor;
|
|
13
|
+
tooltipText: StringConstructor;
|
|
14
|
+
tooltipContent: import("vue").PropType<() => void>;
|
|
15
|
+
tooltipHide: BooleanConstructor;
|
|
16
|
+
tooltipShow: BooleanConstructor;
|
|
17
|
+
tooltipPlacement: {
|
|
18
|
+
type: import("vue").PropType<import("./NTooltip").TooltipPlacement>;
|
|
19
|
+
default: string;
|
|
20
|
+
};
|
|
21
|
+
tooltipMaxWidth: {
|
|
22
|
+
type: import("vue").PropType<import("../utils/tailwind").TWMaxWidth>;
|
|
23
|
+
default: string;
|
|
24
|
+
};
|
|
25
|
+
name: StringConstructor;
|
|
26
|
+
placeholder: StringConstructor;
|
|
27
|
+
autocomplete: {
|
|
28
|
+
type: StringConstructor;
|
|
29
|
+
default: string;
|
|
30
|
+
};
|
|
31
|
+
type: {
|
|
32
|
+
type: StringConstructor;
|
|
33
|
+
default: string;
|
|
34
|
+
};
|
|
35
|
+
max: StringConstructor;
|
|
36
|
+
min: StringConstructor;
|
|
37
|
+
disabled: BooleanConstructor;
|
|
38
|
+
small: BooleanConstructor;
|
|
39
|
+
hideLabel: BooleanConstructor;
|
|
40
|
+
onFocus: import("vue").PropType<() => void>;
|
|
41
|
+
onBlur: import("vue").PropType<() => void>;
|
|
42
|
+
value: import("vue").PropType<string>;
|
|
43
|
+
onUpdateValue: import("vue").PropType<(newValue: string) => void>;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* The `NInputPhone` autoformats phone numbers and checks if they are valid.
|
|
47
|
+
*/
|
|
48
|
+
declare const _default: import("vue").DefineComponent<{
|
|
49
|
+
input: import("vue").PropType<(props: import("./NValInput").InputSlotProps) => JSX.Element>;
|
|
50
|
+
optional: BooleanConstructor;
|
|
51
|
+
rules: {
|
|
52
|
+
type: import("vue").PropType<import("../utils/validation").ValidationRule | import("../utils/validation").ValidationRule[]>;
|
|
53
|
+
default: () => never[];
|
|
54
|
+
};
|
|
55
|
+
form: import("vue").PropType<import("./ValidatedForm").ValidatedForm>;
|
|
56
|
+
error: BooleanConstructor;
|
|
57
|
+
errorMessage: StringConstructor;
|
|
58
|
+
hideErrorMessage: BooleanConstructor;
|
|
59
|
+
disableBlurValidation: BooleanConstructor;
|
|
60
|
+
tooltipText: StringConstructor;
|
|
61
|
+
tooltipContent: import("vue").PropType<() => void>;
|
|
62
|
+
tooltipHide: BooleanConstructor;
|
|
63
|
+
tooltipShow: BooleanConstructor;
|
|
64
|
+
tooltipPlacement: {
|
|
65
|
+
type: import("vue").PropType<import("./NTooltip").TooltipPlacement>;
|
|
66
|
+
default: string;
|
|
67
|
+
};
|
|
68
|
+
tooltipMaxWidth: {
|
|
69
|
+
type: import("vue").PropType<import("../utils/tailwind").TWMaxWidth>;
|
|
70
|
+
default: string;
|
|
71
|
+
};
|
|
72
|
+
name: StringConstructor;
|
|
73
|
+
placeholder: StringConstructor;
|
|
74
|
+
autocomplete: {
|
|
75
|
+
type: StringConstructor;
|
|
76
|
+
default: string;
|
|
77
|
+
};
|
|
78
|
+
type: {
|
|
79
|
+
type: StringConstructor;
|
|
80
|
+
default: string;
|
|
81
|
+
};
|
|
82
|
+
max: StringConstructor;
|
|
83
|
+
min: StringConstructor;
|
|
84
|
+
disabled: BooleanConstructor;
|
|
85
|
+
small: BooleanConstructor;
|
|
86
|
+
hideLabel: BooleanConstructor;
|
|
87
|
+
onFocus: import("vue").PropType<() => void>;
|
|
88
|
+
onBlur: import("vue").PropType<() => void>;
|
|
89
|
+
value: import("vue").PropType<string>;
|
|
90
|
+
onUpdateValue: import("vue").PropType<(newValue: string) => void>;
|
|
91
|
+
}, 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<{
|
|
92
|
+
input: import("vue").PropType<(props: import("./NValInput").InputSlotProps) => JSX.Element>;
|
|
93
|
+
optional: BooleanConstructor;
|
|
94
|
+
rules: {
|
|
95
|
+
type: import("vue").PropType<import("../utils/validation").ValidationRule | import("../utils/validation").ValidationRule[]>;
|
|
96
|
+
default: () => never[];
|
|
97
|
+
};
|
|
98
|
+
form: import("vue").PropType<import("./ValidatedForm").ValidatedForm>;
|
|
99
|
+
error: BooleanConstructor;
|
|
100
|
+
errorMessage: StringConstructor;
|
|
101
|
+
hideErrorMessage: BooleanConstructor;
|
|
102
|
+
disableBlurValidation: BooleanConstructor;
|
|
103
|
+
tooltipText: StringConstructor;
|
|
104
|
+
tooltipContent: import("vue").PropType<() => void>;
|
|
105
|
+
tooltipHide: BooleanConstructor;
|
|
106
|
+
tooltipShow: BooleanConstructor;
|
|
107
|
+
tooltipPlacement: {
|
|
108
|
+
type: import("vue").PropType<import("./NTooltip").TooltipPlacement>;
|
|
109
|
+
default: string;
|
|
110
|
+
};
|
|
111
|
+
tooltipMaxWidth: {
|
|
112
|
+
type: import("vue").PropType<import("../utils/tailwind").TWMaxWidth>;
|
|
113
|
+
default: string;
|
|
114
|
+
};
|
|
115
|
+
name: StringConstructor;
|
|
116
|
+
placeholder: StringConstructor;
|
|
117
|
+
autocomplete: {
|
|
118
|
+
type: StringConstructor;
|
|
119
|
+
default: string;
|
|
120
|
+
};
|
|
121
|
+
type: {
|
|
122
|
+
type: StringConstructor;
|
|
123
|
+
default: string;
|
|
124
|
+
};
|
|
125
|
+
max: StringConstructor;
|
|
126
|
+
min: StringConstructor;
|
|
127
|
+
disabled: BooleanConstructor;
|
|
128
|
+
small: BooleanConstructor;
|
|
129
|
+
hideLabel: BooleanConstructor;
|
|
130
|
+
onFocus: import("vue").PropType<() => void>;
|
|
131
|
+
onBlur: import("vue").PropType<() => void>;
|
|
132
|
+
value: import("vue").PropType<string>;
|
|
133
|
+
onUpdateValue: import("vue").PropType<(newValue: string) => void>;
|
|
134
|
+
}>> & {}, {
|
|
135
|
+
small: boolean;
|
|
136
|
+
type: string;
|
|
137
|
+
tooltipHide: boolean;
|
|
138
|
+
tooltipShow: boolean;
|
|
139
|
+
tooltipPlacement: import("./NTooltip").TooltipPlacement;
|
|
140
|
+
tooltipMaxWidth: import("../utils/tailwind").TWMaxWidth;
|
|
141
|
+
disabled: boolean;
|
|
142
|
+
error: boolean;
|
|
143
|
+
rules: import("../utils/validation").ValidationRule | import("../utils/validation").ValidationRule[];
|
|
144
|
+
autocomplete: string;
|
|
145
|
+
hideLabel: boolean;
|
|
146
|
+
optional: boolean;
|
|
147
|
+
hideErrorMessage: boolean;
|
|
148
|
+
disableBlurValidation: boolean;
|
|
149
|
+
}>;
|
|
150
|
+
export default _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createComponent, createProps } from '../utils/component';
|
|
2
|
+
import { external } from '../utils/validation';
|
|
3
|
+
import { computed, Suspense } from 'vue';
|
|
4
|
+
import NValInput, { nValInputProps } from './NValInput';
|
|
5
|
+
export const nInputPhoneProps = createProps(nValInputProps);
|
|
6
|
+
/**
|
|
7
|
+
* The `NInputPhone` autoformats phone numbers and checks if they are valid.
|
|
8
|
+
*/
|
|
9
|
+
export default createComponent('NInputPhoneSuspended', nInputPhoneProps, props => {
|
|
10
|
+
// Async components have to be wrapped in a suspense component.
|
|
11
|
+
return () => (<Suspense>
|
|
12
|
+
<NPhoneInput {...props}/>
|
|
13
|
+
</Suspense>);
|
|
14
|
+
});
|
|
15
|
+
const NPhoneInput = createComponent('NInputPhone', nInputPhoneProps, async (props) => {
|
|
16
|
+
// import dynamically for better codesplitting as the library is pretty large
|
|
17
|
+
const { parsePhoneNumber } = await import('awesome-phonenumber');
|
|
18
|
+
const DEFAULT_COUNTRY_CODE = 'CH';
|
|
19
|
+
const formattedToPlain = (number) => parsePhoneNumber(number, { regionCode: DEFAULT_COUNTRY_CODE }).number?.e164;
|
|
20
|
+
const plainToFormatted = (number) => parsePhoneNumber(number, { regionCode: DEFAULT_COUNTRY_CODE }).number?.international;
|
|
21
|
+
const onUpdateValue = (newValue) => {
|
|
22
|
+
const plain = formattedToPlain(newValue);
|
|
23
|
+
props.onUpdateValue?.(plain || newValue);
|
|
24
|
+
};
|
|
25
|
+
const value = computed(() => {
|
|
26
|
+
const formatted = plainToFormatted(props.value || '');
|
|
27
|
+
return formatted || props.value;
|
|
28
|
+
});
|
|
29
|
+
const isValid = computed(() => parsePhoneNumber(props.value || '').valid);
|
|
30
|
+
return () => (<NValInput {...{ ...props, onUpdateValue }} value={value.value} rules={external(isValid.value, 'phone')} type="tel"/>);
|
|
31
|
+
});
|