@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,104 @@
|
|
|
1
|
+
import { createComponent, createProps } from '../utils/component';
|
|
2
|
+
import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/vue/24/solid';
|
|
3
|
+
import { computed, watch } from 'vue';
|
|
4
|
+
import './NPagination.css';
|
|
5
|
+
export const nPaginationProps = createProps({
|
|
6
|
+
/**
|
|
7
|
+
* The page number which is currently selected.
|
|
8
|
+
*/
|
|
9
|
+
value: {
|
|
10
|
+
type: Number,
|
|
11
|
+
default: () => 1,
|
|
12
|
+
},
|
|
13
|
+
/**
|
|
14
|
+
* This is called, when a new page number has been selected.
|
|
15
|
+
*/
|
|
16
|
+
onUpdateValue: Function,
|
|
17
|
+
/**
|
|
18
|
+
* The total pages which exists. This is needed to correctly display the selectable pages.
|
|
19
|
+
*/
|
|
20
|
+
total: {
|
|
21
|
+
type: Number,
|
|
22
|
+
default: () => 1,
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* If set to `true`, the pagination is displayed smaller.
|
|
26
|
+
*/
|
|
27
|
+
small: Boolean,
|
|
28
|
+
/**
|
|
29
|
+
* This is called, when the visible pages, which are selectable in the pagination, have changed.
|
|
30
|
+
* This is useful as only these pages can be navigated to on the next click.
|
|
31
|
+
* This information can be useful for prefetching.
|
|
32
|
+
*/
|
|
33
|
+
onVisiblePagesChanged: Function,
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* The `NPagination` is a styled pagination component.
|
|
37
|
+
*/
|
|
38
|
+
export default createComponent('NPagination', nPaginationProps, props => {
|
|
39
|
+
const numbers = computed(() => {
|
|
40
|
+
if (props.total <= 7) {
|
|
41
|
+
return range(1, props.total);
|
|
42
|
+
}
|
|
43
|
+
else if (props.value <= 4) {
|
|
44
|
+
return [...range(1, 5), -1, props.total];
|
|
45
|
+
}
|
|
46
|
+
else if (props.value >= props.total - 3) {
|
|
47
|
+
return [1, -1, ...range(props.total - 4, props.total)];
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return [1, -1, ...range(props.value - 1, props.value + 1), -1, props.total];
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
watch(() => numbers.value, () => {
|
|
54
|
+
const visiblePages = numbers.value.filter(value => value != -1);
|
|
55
|
+
props.onVisiblePagesChanged?.(visiblePages);
|
|
56
|
+
}, { immediate: true });
|
|
57
|
+
const clickedNumber = (value) => {
|
|
58
|
+
if (value <= props.total && value >= 1)
|
|
59
|
+
props.onUpdateValue?.(value);
|
|
60
|
+
};
|
|
61
|
+
const next = () => clickedNumber(props.value + 1);
|
|
62
|
+
const previous = () => clickedNumber(props.value - 1);
|
|
63
|
+
const items = computed(() => numbers.value.map(number => {
|
|
64
|
+
if (number == -1)
|
|
65
|
+
return { label: '...', selectable: false, selected: false };
|
|
66
|
+
else
|
|
67
|
+
return {
|
|
68
|
+
label: `${number}`,
|
|
69
|
+
selectable: true,
|
|
70
|
+
selected: number == props.value,
|
|
71
|
+
click: () => clickedNumber(number),
|
|
72
|
+
};
|
|
73
|
+
}));
|
|
74
|
+
const classesForItem = (item) => [
|
|
75
|
+
'pagination-item',
|
|
76
|
+
item.selectable ? 'selectable ' : '',
|
|
77
|
+
item.selected ? 'selected' : '',
|
|
78
|
+
props.small ? '' : 'not-small',
|
|
79
|
+
];
|
|
80
|
+
return () => (<nav class="inline-flex rounded-md shadow -space-x-px">
|
|
81
|
+
<button class={['pagination-item selectable rounded-l-md', props.small ? '' : 'not-small']} onClick={previous}>
|
|
82
|
+
<span class="sr-only">Previous</span>
|
|
83
|
+
<ChevronLeftIcon class="h-5 w-5" aria-hidden="true"/>
|
|
84
|
+
</button>
|
|
85
|
+
|
|
86
|
+
{items.value.map((item, index) => item.selectable ? (<button key={index} class={classesForItem(item)} onClick={item.click}>
|
|
87
|
+
{item.label}
|
|
88
|
+
</button>) : (<div key={index} class={classesForItem(item)}>
|
|
89
|
+
{item.label}
|
|
90
|
+
</div>))}
|
|
91
|
+
|
|
92
|
+
<button class={['pagination-item selectable rounded-r-md', props.small ? '' : 'not-small']} onClick={next}>
|
|
93
|
+
<span class="sr-only">Next</span>
|
|
94
|
+
<ChevronRightIcon class="h-5 w-5" aria-hidden="true"/>
|
|
95
|
+
</button>
|
|
96
|
+
</nav>);
|
|
97
|
+
});
|
|
98
|
+
function range(from, to) {
|
|
99
|
+
const array = [];
|
|
100
|
+
for (let i = from; i <= to; i++) {
|
|
101
|
+
array.push(i);
|
|
102
|
+
}
|
|
103
|
+
return array;
|
|
104
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { type PropType } from 'vue';
|
|
2
|
+
export declare const nSearchbarProps: {
|
|
3
|
+
/**
|
|
4
|
+
* The placeholder of the search-bar.
|
|
5
|
+
*/
|
|
6
|
+
placeholder: {
|
|
7
|
+
type: StringConstructor;
|
|
8
|
+
default: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* If set to `true` the search-bar is displayed smaller.
|
|
12
|
+
*/
|
|
13
|
+
small: BooleanConstructor;
|
|
14
|
+
/**
|
|
15
|
+
* The classes are directly added to the input (e.g. for shadow).
|
|
16
|
+
*/
|
|
17
|
+
inputClass: StringConstructor;
|
|
18
|
+
/**
|
|
19
|
+
* This is called when the search-bar receives focus.
|
|
20
|
+
*/
|
|
21
|
+
onFocus: PropType<() => void>;
|
|
22
|
+
/**
|
|
23
|
+
* This is called when the search-bar looses focus.
|
|
24
|
+
*/
|
|
25
|
+
onBlur: PropType<() => void>;
|
|
26
|
+
value: PropType<string>;
|
|
27
|
+
onUpdateValue: PropType<(newValue: string) => void>;
|
|
28
|
+
};
|
|
29
|
+
export type NSearchbarExposed = {
|
|
30
|
+
/**
|
|
31
|
+
* Request focus on the search-bar.
|
|
32
|
+
*/
|
|
33
|
+
focus(): void;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The `NSearchbar` is a styled input with a search icon.
|
|
37
|
+
*/
|
|
38
|
+
declare const _default: import("vue").DefineComponent<{
|
|
39
|
+
/**
|
|
40
|
+
* The placeholder of the search-bar.
|
|
41
|
+
*/
|
|
42
|
+
placeholder: {
|
|
43
|
+
type: StringConstructor;
|
|
44
|
+
default: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* If set to `true` the search-bar is displayed smaller.
|
|
48
|
+
*/
|
|
49
|
+
small: BooleanConstructor;
|
|
50
|
+
/**
|
|
51
|
+
* The classes are directly added to the input (e.g. for shadow).
|
|
52
|
+
*/
|
|
53
|
+
inputClass: StringConstructor;
|
|
54
|
+
/**
|
|
55
|
+
* This is called when the search-bar receives focus.
|
|
56
|
+
*/
|
|
57
|
+
onFocus: PropType<() => void>;
|
|
58
|
+
/**
|
|
59
|
+
* This is called when the search-bar looses focus.
|
|
60
|
+
*/
|
|
61
|
+
onBlur: PropType<() => void>;
|
|
62
|
+
value: PropType<string>;
|
|
63
|
+
onUpdateValue: PropType<(newValue: string) => void>;
|
|
64
|
+
}, 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<{
|
|
65
|
+
/**
|
|
66
|
+
* The placeholder of the search-bar.
|
|
67
|
+
*/
|
|
68
|
+
placeholder: {
|
|
69
|
+
type: StringConstructor;
|
|
70
|
+
default: string;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* If set to `true` the search-bar is displayed smaller.
|
|
74
|
+
*/
|
|
75
|
+
small: BooleanConstructor;
|
|
76
|
+
/**
|
|
77
|
+
* The classes are directly added to the input (e.g. for shadow).
|
|
78
|
+
*/
|
|
79
|
+
inputClass: StringConstructor;
|
|
80
|
+
/**
|
|
81
|
+
* This is called when the search-bar receives focus.
|
|
82
|
+
*/
|
|
83
|
+
onFocus: PropType<() => void>;
|
|
84
|
+
/**
|
|
85
|
+
* This is called when the search-bar looses focus.
|
|
86
|
+
*/
|
|
87
|
+
onBlur: PropType<() => void>;
|
|
88
|
+
value: PropType<string>;
|
|
89
|
+
onUpdateValue: PropType<(newValue: string) => void>;
|
|
90
|
+
}>> & {}, {
|
|
91
|
+
small: boolean;
|
|
92
|
+
placeholder: string;
|
|
93
|
+
}>;
|
|
94
|
+
export default _default;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { trsl } from '../i18n';
|
|
2
|
+
import { createComponent, createProps } from '../utils/component';
|
|
3
|
+
import { MagnifyingGlassIcon } from '@heroicons/vue/24/solid';
|
|
4
|
+
import { ref } from 'vue';
|
|
5
|
+
import { vModelProps } from '../utils/vModel';
|
|
6
|
+
export const nSearchbarProps = createProps({
|
|
7
|
+
...vModelProps(String),
|
|
8
|
+
/**
|
|
9
|
+
* The placeholder of the search-bar.
|
|
10
|
+
*/
|
|
11
|
+
placeholder: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: trsl('vue-collection.action.search'),
|
|
14
|
+
},
|
|
15
|
+
/**
|
|
16
|
+
* If set to `true` the search-bar is displayed smaller.
|
|
17
|
+
*/
|
|
18
|
+
small: Boolean,
|
|
19
|
+
/**
|
|
20
|
+
* The classes are directly added to the input (e.g. for shadow).
|
|
21
|
+
*/
|
|
22
|
+
inputClass: String,
|
|
23
|
+
/**
|
|
24
|
+
* This is called when the search-bar receives focus.
|
|
25
|
+
*/
|
|
26
|
+
onFocus: Function,
|
|
27
|
+
/**
|
|
28
|
+
* This is called when the search-bar looses focus.
|
|
29
|
+
*/
|
|
30
|
+
onBlur: Function,
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* The `NSearchbar` is a styled input with a search icon.
|
|
34
|
+
*/
|
|
35
|
+
export default createComponent('NSearchbar', nSearchbarProps, (props, context) => {
|
|
36
|
+
const inputRef = ref();
|
|
37
|
+
const exposed = {
|
|
38
|
+
focus: () => {
|
|
39
|
+
inputRef.value?.focus();
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
context.expose(exposed);
|
|
43
|
+
return () => (<div>
|
|
44
|
+
<label for="search" class="sr-only">
|
|
45
|
+
{props.placeholder}
|
|
46
|
+
</label>
|
|
47
|
+
<div class="relative">
|
|
48
|
+
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
|
49
|
+
<MagnifyingGlassIcon class="h-5 w-5 text-default-400" aria-hidden="true"/>
|
|
50
|
+
</div>
|
|
51
|
+
<input ref={inputRef} value={props.value} onInput={event => props.onUpdateValue?.(event.target.value)} type="text" name="search" placeholder={props.placeholder} autocomplete="off" class={[
|
|
52
|
+
'block w-full pl-10 pr-4 rounded-md border focus:outline-none focus:ring-1 transition placeholder-default-400 border-default-300 focus:border-primary-500 focus:ring-primary-500',
|
|
53
|
+
props.small ? 'py-1' : 'py-2',
|
|
54
|
+
props.inputClass,
|
|
55
|
+
]} onFocus={props.onFocus} onBlur={props.onBlur}/>
|
|
56
|
+
</div>
|
|
57
|
+
</div>);
|
|
58
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export declare const nSearchbarListProps: {
|
|
2
|
+
/**
|
|
3
|
+
* @see {@link nSearchbarProps.placeholder}
|
|
4
|
+
*/
|
|
5
|
+
placeholder: {
|
|
6
|
+
type: StringConstructor;
|
|
7
|
+
default: string;
|
|
8
|
+
};
|
|
9
|
+
value: import("vue").PropType<string>;
|
|
10
|
+
onUpdateValue: import("vue").PropType<(newValue: string) => void>;
|
|
11
|
+
items: {
|
|
12
|
+
type: import("vue").PropType<import("./NSuggestionList").SuggestionItem[]>;
|
|
13
|
+
default: () => never[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The `NSearchbarList` is a {@link NSearchbar} with a {@link NSuggestionList}.
|
|
17
|
+
*/
|
|
18
|
+
maxItems: {
|
|
19
|
+
type: NumberConstructor;
|
|
20
|
+
default: () => 8;
|
|
21
|
+
};
|
|
22
|
+
hideList: BooleanConstructor;
|
|
23
|
+
loading: BooleanConstructor;
|
|
24
|
+
onSelect: import("vue").PropType<(id: string) => void>;
|
|
25
|
+
listItem: import("vue").PropType<(props: import("./NSuggestionList").ItemSlotProps<import("./NSuggestionList").SuggestionItem>) => JSX.Element>;
|
|
26
|
+
onRealBlur: import("vue").PropType<() => void>;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The `NSearchbarList` is a {@link NSearchbar} with a {@link NSuggestionList}.
|
|
30
|
+
*/
|
|
31
|
+
declare const _default: import("vue").DefineComponent<{
|
|
32
|
+
/**
|
|
33
|
+
* @see {@link nSearchbarProps.placeholder}
|
|
34
|
+
*/
|
|
35
|
+
placeholder: {
|
|
36
|
+
type: StringConstructor;
|
|
37
|
+
default: string;
|
|
38
|
+
};
|
|
39
|
+
value: import("vue").PropType<string>;
|
|
40
|
+
onUpdateValue: import("vue").PropType<(newValue: string) => void>;
|
|
41
|
+
items: {
|
|
42
|
+
type: import("vue").PropType<import("./NSuggestionList").SuggestionItem[]>;
|
|
43
|
+
default: () => never[];
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* The `NSearchbarList` is a {@link NSearchbar} with a {@link NSuggestionList}.
|
|
47
|
+
*/
|
|
48
|
+
maxItems: {
|
|
49
|
+
type: NumberConstructor;
|
|
50
|
+
default: () => 8;
|
|
51
|
+
};
|
|
52
|
+
hideList: BooleanConstructor;
|
|
53
|
+
loading: BooleanConstructor;
|
|
54
|
+
onSelect: import("vue").PropType<(id: string) => void>;
|
|
55
|
+
listItem: import("vue").PropType<(props: import("./NSuggestionList").ItemSlotProps<import("./NSuggestionList").SuggestionItem>) => JSX.Element>;
|
|
56
|
+
onRealBlur: import("vue").PropType<() => void>;
|
|
57
|
+
}, 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<{
|
|
58
|
+
/**
|
|
59
|
+
* @see {@link nSearchbarProps.placeholder}
|
|
60
|
+
*/
|
|
61
|
+
placeholder: {
|
|
62
|
+
type: StringConstructor;
|
|
63
|
+
default: string;
|
|
64
|
+
};
|
|
65
|
+
value: import("vue").PropType<string>;
|
|
66
|
+
onUpdateValue: import("vue").PropType<(newValue: string) => void>;
|
|
67
|
+
items: {
|
|
68
|
+
type: import("vue").PropType<import("./NSuggestionList").SuggestionItem[]>;
|
|
69
|
+
default: () => never[];
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* The `NSearchbarList` is a {@link NSearchbar} with a {@link NSuggestionList}.
|
|
73
|
+
*/
|
|
74
|
+
maxItems: {
|
|
75
|
+
type: NumberConstructor;
|
|
76
|
+
default: () => 8;
|
|
77
|
+
};
|
|
78
|
+
hideList: BooleanConstructor;
|
|
79
|
+
loading: BooleanConstructor;
|
|
80
|
+
onSelect: import("vue").PropType<(id: string) => void>;
|
|
81
|
+
listItem: import("vue").PropType<(props: import("./NSuggestionList").ItemSlotProps<import("./NSuggestionList").SuggestionItem>) => JSX.Element>;
|
|
82
|
+
onRealBlur: import("vue").PropType<() => void>;
|
|
83
|
+
}>> & {}, {
|
|
84
|
+
loading: boolean;
|
|
85
|
+
items: import("./NSuggestionList").SuggestionItem[];
|
|
86
|
+
placeholder: string;
|
|
87
|
+
maxItems: number;
|
|
88
|
+
hideList: boolean;
|
|
89
|
+
}>;
|
|
90
|
+
export default _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createComponent, createProps } from '../utils/component';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import { vModelProps } from '../utils/vModel';
|
|
4
|
+
import NSearchbar, { nSearchbarProps } from './NSearchbar';
|
|
5
|
+
import NSuggestionList, { nSuggestionListPropsForConfig } from './NSuggestionList';
|
|
6
|
+
export const nSearchbarListProps = createProps({
|
|
7
|
+
...nSuggestionListPropsForConfig,
|
|
8
|
+
...vModelProps(String),
|
|
9
|
+
/**
|
|
10
|
+
* @see {@link nSearchbarProps.placeholder}
|
|
11
|
+
*/
|
|
12
|
+
placeholder: nSearchbarProps.placeholder,
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* The `NSearchbarList` is a {@link NSearchbar} with a {@link NSuggestionList}.
|
|
16
|
+
*/
|
|
17
|
+
export default createComponent('NSearchbarList', nSearchbarListProps, props => {
|
|
18
|
+
const searchbarRef = ref();
|
|
19
|
+
return () => (<NSuggestionList {...props} inputValue={props.value || ''} input={({ onFocus, onBlur }) => (<NSearchbar ref={searchbarRef} value={props.value} onUpdateValue={props.onUpdateValue} placeholder={props.placeholder} inputClass="shadow-lg" onFocus={onFocus} onBlur={onBlur}/>)} onRequestInputFocus={() => searchbarRef.value?.focus()}/>);
|
|
20
|
+
});
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { Identifiable } from '../utils/identifiable';
|
|
2
|
+
import { type PropType } from 'vue';
|
|
3
|
+
import { type NValInputExposed } from './NValInput';
|
|
4
|
+
export declare const nSelectProps: {
|
|
5
|
+
tooltipText: StringConstructor;
|
|
6
|
+
tooltipContent: PropType<() => void>;
|
|
7
|
+
tooltipHide: BooleanConstructor;
|
|
8
|
+
tooltipShow: BooleanConstructor;
|
|
9
|
+
tooltipPlacement: {
|
|
10
|
+
type: PropType<import("./NTooltip").TooltipPlacement>;
|
|
11
|
+
default: string;
|
|
12
|
+
};
|
|
13
|
+
tooltipMaxWidth: {
|
|
14
|
+
type: PropType<import("../utils/tailwind").TWMaxWidth>;
|
|
15
|
+
default: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The id of the currently selected option of this input.
|
|
19
|
+
*/
|
|
20
|
+
value: StringConstructor;
|
|
21
|
+
/**
|
|
22
|
+
* This is called with the newly selected id when the selection has changed.
|
|
23
|
+
* If no id is selected, the empty string is passed, in order to
|
|
24
|
+
* match the API of all other inputs who never pass `undefined`.
|
|
25
|
+
*/
|
|
26
|
+
onUpdateValue: PropType<(newValue: string) => void>;
|
|
27
|
+
/**
|
|
28
|
+
* The different options which can be selected.
|
|
29
|
+
*/
|
|
30
|
+
options: {
|
|
31
|
+
type: PropType<SelectionOption[]>;
|
|
32
|
+
default: () => never[];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* @see {@link nValInputProps.name}
|
|
36
|
+
*/
|
|
37
|
+
name: StringConstructor;
|
|
38
|
+
/**
|
|
39
|
+
* @see {@link nValInputProps.optional}
|
|
40
|
+
*/
|
|
41
|
+
optional: BooleanConstructor;
|
|
42
|
+
/**
|
|
43
|
+
* @see {@link nValInputProps.disabled}
|
|
44
|
+
*/
|
|
45
|
+
disabled: BooleanConstructor;
|
|
46
|
+
/**
|
|
47
|
+
* @see {@link nValInputProps.form}
|
|
48
|
+
*/
|
|
49
|
+
form: PropType<import("./ValidatedForm").ValidatedForm>;
|
|
50
|
+
};
|
|
51
|
+
export type SelectionOption = Identifiable & {
|
|
52
|
+
label: string;
|
|
53
|
+
};
|
|
54
|
+
export type NSelectExposed = NValInputExposed;
|
|
55
|
+
/**
|
|
56
|
+
* The `NSelect` is a styled html select-input.
|
|
57
|
+
*/
|
|
58
|
+
declare const _default: import("vue").DefineComponent<{
|
|
59
|
+
tooltipText: StringConstructor;
|
|
60
|
+
tooltipContent: PropType<() => void>;
|
|
61
|
+
tooltipHide: BooleanConstructor;
|
|
62
|
+
tooltipShow: BooleanConstructor;
|
|
63
|
+
tooltipPlacement: {
|
|
64
|
+
type: PropType<import("./NTooltip").TooltipPlacement>;
|
|
65
|
+
default: string;
|
|
66
|
+
};
|
|
67
|
+
tooltipMaxWidth: {
|
|
68
|
+
type: PropType<import("../utils/tailwind").TWMaxWidth>;
|
|
69
|
+
default: string;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* The id of the currently selected option of this input.
|
|
73
|
+
*/
|
|
74
|
+
value: StringConstructor;
|
|
75
|
+
/**
|
|
76
|
+
* This is called with the newly selected id when the selection has changed.
|
|
77
|
+
* If no id is selected, the empty string is passed, in order to
|
|
78
|
+
* match the API of all other inputs who never pass `undefined`.
|
|
79
|
+
*/
|
|
80
|
+
onUpdateValue: PropType<(newValue: string) => void>;
|
|
81
|
+
/**
|
|
82
|
+
* The different options which can be selected.
|
|
83
|
+
*/
|
|
84
|
+
options: {
|
|
85
|
+
type: PropType<SelectionOption[]>;
|
|
86
|
+
default: () => never[];
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* @see {@link nValInputProps.name}
|
|
90
|
+
*/
|
|
91
|
+
name: StringConstructor;
|
|
92
|
+
/**
|
|
93
|
+
* @see {@link nValInputProps.optional}
|
|
94
|
+
*/
|
|
95
|
+
optional: BooleanConstructor;
|
|
96
|
+
/**
|
|
97
|
+
* @see {@link nValInputProps.disabled}
|
|
98
|
+
*/
|
|
99
|
+
disabled: BooleanConstructor;
|
|
100
|
+
/**
|
|
101
|
+
* @see {@link nValInputProps.form}
|
|
102
|
+
*/
|
|
103
|
+
form: PropType<import("./ValidatedForm").ValidatedForm>;
|
|
104
|
+
}, 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<{
|
|
105
|
+
tooltipText: StringConstructor;
|
|
106
|
+
tooltipContent: PropType<() => void>;
|
|
107
|
+
tooltipHide: BooleanConstructor;
|
|
108
|
+
tooltipShow: BooleanConstructor;
|
|
109
|
+
tooltipPlacement: {
|
|
110
|
+
type: PropType<import("./NTooltip").TooltipPlacement>;
|
|
111
|
+
default: string;
|
|
112
|
+
};
|
|
113
|
+
tooltipMaxWidth: {
|
|
114
|
+
type: PropType<import("../utils/tailwind").TWMaxWidth>;
|
|
115
|
+
default: string;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* The id of the currently selected option of this input.
|
|
119
|
+
*/
|
|
120
|
+
value: StringConstructor;
|
|
121
|
+
/**
|
|
122
|
+
* This is called with the newly selected id when the selection has changed.
|
|
123
|
+
* If no id is selected, the empty string is passed, in order to
|
|
124
|
+
* match the API of all other inputs who never pass `undefined`.
|
|
125
|
+
*/
|
|
126
|
+
onUpdateValue: PropType<(newValue: string) => void>;
|
|
127
|
+
/**
|
|
128
|
+
* The different options which can be selected.
|
|
129
|
+
*/
|
|
130
|
+
options: {
|
|
131
|
+
type: PropType<SelectionOption[]>;
|
|
132
|
+
default: () => never[];
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* @see {@link nValInputProps.name}
|
|
136
|
+
*/
|
|
137
|
+
name: StringConstructor;
|
|
138
|
+
/**
|
|
139
|
+
* @see {@link nValInputProps.optional}
|
|
140
|
+
*/
|
|
141
|
+
optional: BooleanConstructor;
|
|
142
|
+
/**
|
|
143
|
+
* @see {@link nValInputProps.disabled}
|
|
144
|
+
*/
|
|
145
|
+
disabled: BooleanConstructor;
|
|
146
|
+
/**
|
|
147
|
+
* @see {@link nValInputProps.form}
|
|
148
|
+
*/
|
|
149
|
+
form: PropType<import("./ValidatedForm").ValidatedForm>;
|
|
150
|
+
}>> & {}, {
|
|
151
|
+
tooltipHide: boolean;
|
|
152
|
+
tooltipShow: boolean;
|
|
153
|
+
tooltipPlacement: import("./NTooltip").TooltipPlacement;
|
|
154
|
+
tooltipMaxWidth: import("../utils/tailwind").TWMaxWidth;
|
|
155
|
+
options: SelectionOption[];
|
|
156
|
+
disabled: boolean;
|
|
157
|
+
optional: boolean;
|
|
158
|
+
}>;
|
|
159
|
+
export default _default;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { trsl } from '../i18n';
|
|
2
|
+
import { createComponent, createProps } from '../utils/component';
|
|
3
|
+
import { ref } from 'vue';
|
|
4
|
+
import NTooltip, { mapTooltipProps, nToolTipPropsForImplementor } from './NTooltip';
|
|
5
|
+
import NValInput, { nValInputProps } from './NValInput';
|
|
6
|
+
export const nSelectProps = createProps({
|
|
7
|
+
/**
|
|
8
|
+
* The id of the currently selected option of this input.
|
|
9
|
+
*/
|
|
10
|
+
value: String,
|
|
11
|
+
/**
|
|
12
|
+
* This is called with the newly selected id when the selection has changed.
|
|
13
|
+
* If no id is selected, the empty string is passed, in order to
|
|
14
|
+
* match the API of all other inputs who never pass `undefined`.
|
|
15
|
+
*/
|
|
16
|
+
onUpdateValue: Function,
|
|
17
|
+
/**
|
|
18
|
+
* The different options which can be selected.
|
|
19
|
+
*/
|
|
20
|
+
options: {
|
|
21
|
+
type: Array,
|
|
22
|
+
default: () => [],
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* @see {@link nValInputProps.name}
|
|
26
|
+
*/
|
|
27
|
+
name: nValInputProps.name,
|
|
28
|
+
/**
|
|
29
|
+
* @see {@link nValInputProps.optional}
|
|
30
|
+
*/
|
|
31
|
+
optional: nValInputProps.optional,
|
|
32
|
+
/**
|
|
33
|
+
* @see {@link nValInputProps.disabled}
|
|
34
|
+
*/
|
|
35
|
+
disabled: nValInputProps.disabled,
|
|
36
|
+
/**
|
|
37
|
+
* @see {@link nValInputProps.form}
|
|
38
|
+
*/
|
|
39
|
+
form: nValInputProps.form,
|
|
40
|
+
...nToolTipPropsForImplementor,
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* The `NSelect` is a styled html select-input.
|
|
44
|
+
*/
|
|
45
|
+
export default createComponent('NSelect', nSelectProps, (props, context) => {
|
|
46
|
+
const inputRef = ref();
|
|
47
|
+
const exposed = {
|
|
48
|
+
focus: () => inputRef.value?.focus(),
|
|
49
|
+
validate: () => {
|
|
50
|
+
if (inputRef.value == null)
|
|
51
|
+
throw new Error('Can not validate NSelect as its input was undefined');
|
|
52
|
+
return inputRef.value.validate();
|
|
53
|
+
},
|
|
54
|
+
reset: () => inputRef.value?.reset(),
|
|
55
|
+
};
|
|
56
|
+
context.expose(exposed);
|
|
57
|
+
return () => (<NValInput ref={inputRef} {...props} input={slotProps => (<>
|
|
58
|
+
<label for={props.name} class={[
|
|
59
|
+
'block text-sm font-medium mb-1',
|
|
60
|
+
props.disabled ? 'text-default-300' : 'text-default-700',
|
|
61
|
+
]}>
|
|
62
|
+
{props.name}
|
|
63
|
+
</label>
|
|
64
|
+
<NTooltip block {...mapTooltipProps(props)}>
|
|
65
|
+
<select name={props.name} disabled={props.disabled} value={props.value} onChange={event => slotProps.onUpdateValue(event.target.value)} onBlur={slotProps.onBlur} class={[
|
|
66
|
+
'block w-full py-2 pl-4 pr-10 rounded-md border focus:outline-none focus:ring-1',
|
|
67
|
+
props.disabled ? 'text-default-300 ' : 'text-default-900 ',
|
|
68
|
+
slotProps.error
|
|
69
|
+
? 'border-red-500 focus:border-red-500 focus:ring-red-500'
|
|
70
|
+
: 'border-default-300 focus:border-primary-500 focus:ring-primary-500',
|
|
71
|
+
]}>
|
|
72
|
+
<option disabled={!props.optional} selected={!props.value} value="">
|
|
73
|
+
{trsl('vue-collection.action.select')}
|
|
74
|
+
</option>
|
|
75
|
+
{props.options.map(option => (<option key={option.id} value={option.id} selected={props.value == option.id}>
|
|
76
|
+
{option.label}
|
|
77
|
+
</option>))}
|
|
78
|
+
</select>
|
|
79
|
+
</NTooltip>
|
|
80
|
+
</>)}/>);
|
|
81
|
+
});
|