@weconstudio/nuxt 0.0.0-stage → 1.72.0
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/LICENSE +1 -0
- package/README.md +115 -2
- package/dist/module.d.mts +7 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +250 -0
- package/dist/runtime/components/We/Autocomplete.d.vue.ts +13 -0
- package/dist/runtime/components/We/Autocomplete.vue +91 -0
- package/dist/runtime/components/We/Autocomplete.vue.d.ts +13 -0
- package/dist/runtime/components/We/BoldText.d.vue.ts +17 -0
- package/dist/runtime/components/We/BoldText.vue +29 -0
- package/dist/runtime/components/We/BoldText.vue.d.ts +17 -0
- package/dist/runtime/components/We/ColorPicker.d.vue.ts +11 -0
- package/dist/runtime/components/We/ColorPicker.vue +199 -0
- package/dist/runtime/components/We/ColorPicker.vue.d.ts +11 -0
- package/dist/runtime/components/We/ConfirmDialog.d.vue.ts +104 -0
- package/dist/runtime/components/We/ConfirmDialog.vue +143 -0
- package/dist/runtime/components/We/ConfirmDialog.vue.d.ts +104 -0
- package/dist/runtime/components/We/Datatable.d.vue.ts +40 -0
- package/dist/runtime/components/We/Datatable.vue +87 -0
- package/dist/runtime/components/We/Datatable.vue.d.ts +40 -0
- package/dist/runtime/components/We/DatatableInternal.d.vue.ts +194 -0
- package/dist/runtime/components/We/DatatableInternal.vue +638 -0
- package/dist/runtime/components/We/DatatableInternal.vue.d.ts +194 -0
- package/dist/runtime/components/We/DatePicker.d.vue.ts +51 -0
- package/dist/runtime/components/We/DatePicker.vue +901 -0
- package/dist/runtime/components/We/DatePicker.vue.d.ts +51 -0
- package/dist/runtime/components/We/Dt/Actions.d.vue.ts +51 -0
- package/dist/runtime/components/We/Dt/Actions.vue +106 -0
- package/dist/runtime/components/We/Dt/Actions.vue.d.ts +51 -0
- package/dist/runtime/components/We/Dt/BooleanFormatter.d.vue.ts +8 -0
- package/dist/runtime/components/We/Dt/BooleanFormatter.vue +26 -0
- package/dist/runtime/components/We/Dt/BooleanFormatter.vue.d.ts +8 -0
- package/dist/runtime/components/We/Dt/CardFilterContainer.d.vue.ts +17 -0
- package/dist/runtime/components/We/Dt/CardFilterContainer.vue +60 -0
- package/dist/runtime/components/We/Dt/CardFilterContainer.vue.d.ts +17 -0
- package/dist/runtime/components/We/Dt/CheckboxFilter.d.vue.ts +16 -0
- package/dist/runtime/components/We/Dt/CheckboxFilter.vue +47 -0
- package/dist/runtime/components/We/Dt/CheckboxFilter.vue.d.ts +16 -0
- package/dist/runtime/components/We/Dt/ChipGroupSelect.d.vue.ts +7 -0
- package/dist/runtime/components/We/Dt/ChipGroupSelect.vue +35 -0
- package/dist/runtime/components/We/Dt/ChipGroupSelect.vue.d.ts +7 -0
- package/dist/runtime/components/We/Dt/ClusterFilter.d.vue.ts +18 -0
- package/dist/runtime/components/We/Dt/ClusterFilter.vue +68 -0
- package/dist/runtime/components/We/Dt/ClusterFilter.vue.d.ts +18 -0
- package/dist/runtime/components/We/Dt/DatasetFormatter.d.vue.ts +19 -0
- package/dist/runtime/components/We/Dt/DatasetFormatter.vue +65 -0
- package/dist/runtime/components/We/Dt/DatasetFormatter.vue.d.ts +19 -0
- package/dist/runtime/components/We/Dt/DaterangeFilter.d.vue.ts +28 -0
- package/dist/runtime/components/We/Dt/DaterangeFilter.vue +140 -0
- package/dist/runtime/components/We/Dt/DaterangeFilter.vue.d.ts +28 -0
- package/dist/runtime/components/We/Dt/Filter.d.vue.ts +7 -0
- package/dist/runtime/components/We/Dt/Filter.vue +234 -0
- package/dist/runtime/components/We/Dt/Filter.vue.d.ts +7 -0
- package/dist/runtime/components/We/Dt/Filters.d.vue.ts +6 -0
- package/dist/runtime/components/We/Dt/Filters.vue +24 -0
- package/dist/runtime/components/We/Dt/Filters.vue.d.ts +6 -0
- package/dist/runtime/components/We/Dt/LuxonFormatter.d.vue.ts +12 -0
- package/dist/runtime/components/We/Dt/LuxonFormatter.vue +23 -0
- package/dist/runtime/components/We/Dt/LuxonFormatter.vue.d.ts +12 -0
- package/dist/runtime/components/We/Dt/SelectFilter.d.vue.ts +60 -0
- package/dist/runtime/components/We/Dt/SelectFilter.vue +333 -0
- package/dist/runtime/components/We/Dt/SelectFilter.vue.d.ts +60 -0
- package/dist/runtime/components/We/Dt/SelectResourceFilter.d.vue.ts +43 -0
- package/dist/runtime/components/We/Dt/SelectResourceFilter.vue +127 -0
- package/dist/runtime/components/We/Dt/SelectResourceFilter.vue.d.ts +43 -0
- package/dist/runtime/components/We/Dt/dt.types.d.ts +8 -0
- package/dist/runtime/components/We/EndpointSwitcher.d.vue.ts +12 -0
- package/dist/runtime/components/We/EndpointSwitcher.vue +256 -0
- package/dist/runtime/components/We/EndpointSwitcher.vue.d.ts +12 -0
- package/dist/runtime/components/We/Import.d.vue.ts +118 -0
- package/dist/runtime/components/We/Import.vue +730 -0
- package/dist/runtime/components/We/Import.vue.d.ts +118 -0
- package/dist/runtime/components/We/ImportDefaultValues.d.vue.ts +3666 -0
- package/dist/runtime/components/We/ImportDefaultValues.vue +115 -0
- package/dist/runtime/components/We/ImportDefaultValues.vue.d.ts +3666 -0
- package/dist/runtime/components/We/ImportMatchColumns.d.vue.ts +66 -0
- package/dist/runtime/components/We/ImportMatchColumns.vue +172 -0
- package/dist/runtime/components/We/ImportMatchColumns.vue.d.ts +66 -0
- package/dist/runtime/components/We/ImportPreviewResults.d.vue.ts +38 -0
- package/dist/runtime/components/We/ImportPreviewResults.vue +165 -0
- package/dist/runtime/components/We/ImportPreviewResults.vue.d.ts +38 -0
- package/dist/runtime/components/We/ImportSelectStart.d.vue.ts +47 -0
- package/dist/runtime/components/We/ImportSelectStart.vue +106 -0
- package/dist/runtime/components/We/ImportSelectStart.vue.d.ts +47 -0
- package/dist/runtime/components/We/Notification.d.vue.ts +7 -0
- package/dist/runtime/components/We/Notification.vue +49 -0
- package/dist/runtime/components/We/Notification.vue.d.ts +7 -0
- package/dist/runtime/components/We/S3Dropzone.d.vue.ts +17 -0
- package/dist/runtime/components/We/S3Dropzone.vue +527 -0
- package/dist/runtime/components/We/S3Dropzone.vue.d.ts +17 -0
- package/dist/runtime/components/We/Select.d.vue.ts +39 -0
- package/dist/runtime/components/We/Select.vue +354 -0
- package/dist/runtime/components/We/Select.vue.d.ts +39 -0
- package/dist/runtime/components/We/TipTap.d.vue.ts +26 -0
- package/dist/runtime/components/We/TipTap.vue +362 -0
- package/dist/runtime/components/We/TipTap.vue.d.ts +26 -0
- package/dist/runtime/components/We/datatable.props.d.ts +57 -0
- package/dist/runtime/components/We/datatable.props.js +60 -0
- package/dist/runtime/composables/datatable/useAutoFillHeight.d.ts +31 -0
- package/dist/runtime/composables/datatable/useAutoFillHeight.js +57 -0
- package/dist/runtime/composables/datatable/useDataTable.d.ts +33 -0
- package/dist/runtime/composables/datatable/useDataTable.js +161 -0
- package/dist/runtime/composables/datatable/useDatatableColumns.d.ts +12 -0
- package/dist/runtime/composables/datatable/useDatatableColumns.js +96 -0
- package/dist/runtime/composables/useApi.d.ts +56 -0
- package/dist/runtime/composables/useApi.js +230 -0
- package/dist/runtime/composables/useApiFetch.d.ts +2 -0
- package/dist/runtime/composables/useApiFetch.js +9 -0
- package/dist/runtime/composables/useApiUrl.d.ts +10 -0
- package/dist/runtime/composables/useApiUrl.js +37 -0
- package/dist/runtime/composables/useAuth.d.ts +9 -0
- package/dist/runtime/composables/useAuth.js +22 -0
- package/dist/runtime/composables/useBus.d.ts +8 -0
- package/dist/runtime/composables/useBus.js +18 -0
- package/dist/runtime/composables/useDateRangePresets.d.ts +21 -0
- package/dist/runtime/composables/useDateRangePresets.js +90 -0
- package/dist/runtime/composables/useForm.d.ts +29 -0
- package/dist/runtime/composables/useForm.js +74 -0
- package/dist/runtime/composables/useFormLock.d.ts +11 -0
- package/dist/runtime/composables/useFormLock.js +8 -0
- package/dist/runtime/composables/useFormWrapper.d.ts +16 -0
- package/dist/runtime/composables/useFormWrapper.js +36 -0
- package/dist/runtime/composables/useImportJob.d.ts +55 -0
- package/dist/runtime/composables/useImportJob.js +94 -0
- package/dist/runtime/composables/useLux.d.ts +1 -0
- package/dist/runtime/composables/useLux.js +8 -0
- package/dist/runtime/composables/useNotify.d.ts +12 -0
- package/dist/runtime/composables/useNotify.js +24 -0
- package/dist/runtime/composables/usePaginatedFetch.d.ts +24 -0
- package/dist/runtime/composables/usePaginatedFetch.js +154 -0
- package/dist/runtime/composables/useServerErrors.d.ts +16 -0
- package/dist/runtime/composables/useServerErrors.js +60 -0
- package/dist/runtime/composables/useValidators.d.ts +18 -0
- package/dist/runtime/composables/useValidators.js +56 -0
- package/dist/runtime/generator/code/dt.d.ts +8 -0
- package/dist/runtime/generator/code/dt.js +97 -0
- package/dist/runtime/generator/code/edit.d.ts +4 -0
- package/dist/runtime/generator/code/edit.js +41 -0
- package/dist/runtime/generator/code/form.d.ts +6 -0
- package/dist/runtime/generator/code/form.js +229 -0
- package/dist/runtime/generator/code/i18n.d.ts +5 -0
- package/dist/runtime/generator/code/i18n.js +43 -0
- package/dist/runtime/generator/code/index.d.ts +11 -0
- package/dist/runtime/generator/code/index.js +90 -0
- package/dist/runtime/generator/components/CodeSnippet.d.vue.ts +14 -0
- package/dist/runtime/generator/components/CodeSnippet.vue +49 -0
- package/dist/runtime/generator/components/CodeSnippet.vue.d.ts +14 -0
- package/dist/runtime/generator/components/Configuration.d.vue.ts +16 -0
- package/dist/runtime/generator/components/Configuration.vue +154 -0
- package/dist/runtime/generator/components/Configuration.vue.d.ts +16 -0
- package/dist/runtime/generator/components/GeneratorPage.d.vue.ts +50 -0
- package/dist/runtime/generator/components/GeneratorPage.vue +226 -0
- package/dist/runtime/generator/components/GeneratorPage.vue.d.ts +50 -0
- package/dist/runtime/generator/fs.d.ts +16 -0
- package/dist/runtime/generator/fs.js +79 -0
- package/dist/runtime/generator/index.d.vue.ts +52 -0
- package/dist/runtime/generator/index.vue +17 -0
- package/dist/runtime/generator/index.vue.d.ts +52 -0
- package/dist/runtime/internals/api.d.ts +3 -0
- package/dist/runtime/internals/api.js +16 -0
- package/dist/runtime/internals/bus.d.ts +1 -0
- package/dist/runtime/internals/bus.js +2 -0
- package/dist/runtime/internals/dt.d.ts +24 -0
- package/dist/runtime/internals/dt.js +57 -0
- package/dist/runtime/lang/en.json +211 -0
- package/dist/runtime/lang/it.json +211 -0
- package/dist/runtime/mixins/formValidator.d.ts +38 -0
- package/dist/runtime/mixins/formValidator.js +118 -0
- package/dist/runtime/plugins/api-legacy.d.ts +76 -0
- package/dist/runtime/plugins/api-legacy.js +11 -0
- package/dist/runtime/plugins/auth-legacy.d.ts +22 -0
- package/dist/runtime/plugins/auth-legacy.js +14 -0
- package/dist/runtime/plugins/bus-legacy.d.ts +6 -0
- package/dist/runtime/plugins/bus-legacy.js +9 -0
- package/dist/runtime/plugins/notify-legacy.d.ts +25 -0
- package/dist/runtime/plugins/notify-legacy.js +35 -0
- package/dist/runtime/plugins/portal.d.ts +2 -0
- package/dist/runtime/plugins/portal.js +5 -0
- package/dist/runtime/plugins/update-sanctum-app-config.d.ts +2 -0
- package/dist/runtime/plugins/update-sanctum-app-config.js +44 -0
- package/dist/runtime/plugins/vuetify-nuxt-icon.d.ts +4 -0
- package/dist/runtime/plugins/vuetify-nuxt-icon.js +30 -0
- package/dist/runtime/types/app-config.d.ts +24 -0
- package/dist/runtime/types/app-config.js +1 -0
- package/dist/runtime/types/icons.d.ts +82 -0
- package/dist/runtime/types/icons.js +84 -0
- package/dist/runtime/types/index.d.ts +2 -0
- package/dist/runtime/types/index.js +2 -0
- package/dist/runtime/types/module-options.d.ts +29 -0
- package/dist/runtime/types/module-options.js +0 -0
- package/dist/runtime/types/runtime-hooks.d.ts +17 -0
- package/dist/runtime/types/runtime-hooks.js +1 -0
- package/dist/runtime/utils/color.d.ts +10 -0
- package/dist/runtime/utils/color.js +38 -0
- package/dist/runtime/utils/file.d.ts +17 -0
- package/dist/runtime/utils/file.js +108 -0
- package/dist/runtime/utils/format.d.ts +1 -0
- package/dist/runtime/utils/format.js +14 -0
- package/dist/runtime/utils/make-enum.d.ts +15 -0
- package/dist/runtime/utils/make-enum.js +27 -0
- package/dist/runtime/utils/mergeDefaults.d.ts +1 -0
- package/dist/runtime/utils/mergeDefaults.js +18 -0
- package/dist/runtime/utils/object-to-formdata.d.ts +10 -0
- package/dist/runtime/utils/object-to-formdata.js +82 -0
- package/dist/runtime/utils/uuid.d.ts +1 -0
- package/dist/runtime/utils/uuid.js +9 -0
- package/dist/types.d.mts +9 -0
- package/package.json +92 -4
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
2
|
+
export default _default;
|
|
3
|
+
type __VLS_WithSlots<T, S> = T & (new () => {
|
|
4
|
+
$slots: S;
|
|
5
|
+
});
|
|
6
|
+
declare const __VLS_component: import("vue").DefineComponent<{}, {
|
|
7
|
+
$emit: (event: "error" | "update:modelValue" | "update:object-value", ...args: any[]) => void;
|
|
8
|
+
lazy: boolean;
|
|
9
|
+
extraParams: Record<string, any>;
|
|
10
|
+
paginate: boolean | Record<string, any>;
|
|
11
|
+
multiple: boolean;
|
|
12
|
+
clearable: boolean;
|
|
13
|
+
readonly: boolean;
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
itemValue: string;
|
|
16
|
+
objectValue: string | number | boolean | Record<string, any> | unknown[] | null;
|
|
17
|
+
returnObject: boolean;
|
|
18
|
+
itemText: string | Function;
|
|
19
|
+
itemTitle: string | Function;
|
|
20
|
+
searchAsItem: boolean;
|
|
21
|
+
waitForInteraction: boolean;
|
|
22
|
+
keepSearchOnSelect: boolean;
|
|
23
|
+
resource?: string | undefined;
|
|
24
|
+
modelValue?: string | number | boolean | Record<string, any> | unknown[] | null | undefined;
|
|
25
|
+
autoSelect?: string | Function | undefined;
|
|
26
|
+
onRedirect?: Function | undefined;
|
|
27
|
+
$props: any;
|
|
28
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
29
|
+
type __VLS_Slots = {
|
|
30
|
+
[x: string]: ((props: any) => any) | undefined;
|
|
31
|
+
} & {
|
|
32
|
+
item?: ((props: any) => any) | undefined;
|
|
33
|
+
} & {
|
|
34
|
+
'search-item'?: ((props: {
|
|
35
|
+
value: any;
|
|
36
|
+
}) => any) | undefined;
|
|
37
|
+
} & {
|
|
38
|
+
'no-data'?: ((props: {}) => any) | undefined;
|
|
39
|
+
};
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, ref, toRaw, toRef, useSlots, watch } from "vue";
|
|
3
|
+
import { useFormLock } from "../../composables/useFormLock";
|
|
4
|
+
import { usePaginatedFetch } from "../../composables/usePaginatedFetch";
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
resource: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: false,
|
|
9
|
+
default: void 0
|
|
10
|
+
},
|
|
11
|
+
extraParams: {
|
|
12
|
+
type: Object,
|
|
13
|
+
default: () => ({})
|
|
14
|
+
},
|
|
15
|
+
modelValue: {
|
|
16
|
+
type: [String, Object, Array, Boolean, Number, null],
|
|
17
|
+
required: false,
|
|
18
|
+
default: void 0
|
|
19
|
+
},
|
|
20
|
+
objectValue: {
|
|
21
|
+
type: [String, Object, Array, Boolean, Number, null],
|
|
22
|
+
default: null
|
|
23
|
+
},
|
|
24
|
+
returnObject: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: false
|
|
27
|
+
},
|
|
28
|
+
itemValue: {
|
|
29
|
+
type: String,
|
|
30
|
+
default: "id"
|
|
31
|
+
},
|
|
32
|
+
itemText: {
|
|
33
|
+
type: [String, Function],
|
|
34
|
+
default: "name"
|
|
35
|
+
},
|
|
36
|
+
itemTitle: {
|
|
37
|
+
type: [String, Function],
|
|
38
|
+
default: null
|
|
39
|
+
},
|
|
40
|
+
clearable: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: true
|
|
43
|
+
},
|
|
44
|
+
paginate: {
|
|
45
|
+
type: [Boolean, Object],
|
|
46
|
+
default: false
|
|
47
|
+
},
|
|
48
|
+
multiple: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: false
|
|
51
|
+
},
|
|
52
|
+
searchAsItem: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: false
|
|
55
|
+
},
|
|
56
|
+
lazy: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
default: false
|
|
59
|
+
},
|
|
60
|
+
autoSelect: {
|
|
61
|
+
type: [String, Function],
|
|
62
|
+
default: void 0
|
|
63
|
+
},
|
|
64
|
+
onRedirect: {
|
|
65
|
+
type: Function,
|
|
66
|
+
default: void 0
|
|
67
|
+
},
|
|
68
|
+
waitForInteraction: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
default: false
|
|
71
|
+
},
|
|
72
|
+
keepSearchOnSelect: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
default: false
|
|
75
|
+
},
|
|
76
|
+
readonly: {
|
|
77
|
+
type: Boolean,
|
|
78
|
+
default: null
|
|
79
|
+
},
|
|
80
|
+
disabled: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: null
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
const emit = defineEmits(["error", "update:object-value", "update:modelValue"]);
|
|
86
|
+
const search = ref(null);
|
|
87
|
+
const { isReadonly, isDisabled } = useFormLock(props);
|
|
88
|
+
const usePagination = computed(() => props.paginate !== false);
|
|
89
|
+
const useReturnObject = computed(() => props.returnObject || props.paginate);
|
|
90
|
+
const multiple = toRef(props, "multiple");
|
|
91
|
+
const safeItemTitle = computed(() => props.itemTitle || props.itemText);
|
|
92
|
+
const paginateSearch = computed(() => {
|
|
93
|
+
if (!props.paginate) {
|
|
94
|
+
return void 0;
|
|
95
|
+
}
|
|
96
|
+
if (!props.modelValue) {
|
|
97
|
+
return search.value;
|
|
98
|
+
}
|
|
99
|
+
if (multiple.value) {
|
|
100
|
+
return search.value;
|
|
101
|
+
}
|
|
102
|
+
const v = getValueAsObject();
|
|
103
|
+
return getItemTitle(v) !== search.value ? search.value : void 0;
|
|
104
|
+
});
|
|
105
|
+
const userHasInteracted = ref(false);
|
|
106
|
+
function handleMenuUpdate(value) {
|
|
107
|
+
if (value) {
|
|
108
|
+
userHasInteracted.value = true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const frozen = computed(() => {
|
|
112
|
+
return props.waitForInteraction && !userHasInteracted.value;
|
|
113
|
+
});
|
|
114
|
+
const { items, hasMore, loadMore, loading } = usePaginatedFetch(
|
|
115
|
+
() => props.resource,
|
|
116
|
+
{
|
|
117
|
+
extraParams: () => props.extraParams,
|
|
118
|
+
paginate: () => props.paginate,
|
|
119
|
+
search: paginateSearch,
|
|
120
|
+
frozen,
|
|
121
|
+
lazy: () => props.lazy,
|
|
122
|
+
onError: (e) => {
|
|
123
|
+
emit("error", e);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
const hasItemSlot = computed(() => !!useSlots().item);
|
|
128
|
+
const missingValues = computed(() => {
|
|
129
|
+
if (!props.modelValue || !props.returnObject) {
|
|
130
|
+
return [];
|
|
131
|
+
}
|
|
132
|
+
const existingIds = new Set(items.value.map((item) => item[props.itemValue]));
|
|
133
|
+
const modelValues = multiple.value ? props.modelValue : [props.modelValue];
|
|
134
|
+
return modelValues.filter((val) => !existingIds.has(val[props.itemValue]));
|
|
135
|
+
});
|
|
136
|
+
const allItems = computed(() => {
|
|
137
|
+
const allItems2 = [...items.value, ...missingValues.value];
|
|
138
|
+
if (!loading.value && props.searchAsItem && search.value) {
|
|
139
|
+
const searchItem = {
|
|
140
|
+
[props.itemValue]: search.value,
|
|
141
|
+
__SEARCH__: true
|
|
142
|
+
};
|
|
143
|
+
if (typeof props.itemText === "string") {
|
|
144
|
+
searchItem[props.itemText] = search.value;
|
|
145
|
+
}
|
|
146
|
+
allItems2.push(searchItem);
|
|
147
|
+
}
|
|
148
|
+
return allItems2;
|
|
149
|
+
});
|
|
150
|
+
watch(() => props.modelValue, (val) => {
|
|
151
|
+
const rawVal = toRaw(val);
|
|
152
|
+
if (multiple.value && !Array.isArray(rawVal)) {
|
|
153
|
+
emit("update:modelValue", []);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const singleItem = multiple.value ? rawVal?.length ? toRaw(rawVal[0]) : null : rawVal;
|
|
157
|
+
if (!singleItem) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (useReturnObject.value && typeof singleItem !== "object") {
|
|
161
|
+
throw new TypeError("we-select: modelValue must be an object when return-object or paginate is true");
|
|
162
|
+
}
|
|
163
|
+
if (!useReturnObject.value && typeof singleItem === "object") {
|
|
164
|
+
throw new TypeError("we-select: modelValue must not be an object when return-object is false");
|
|
165
|
+
}
|
|
166
|
+
if (useReturnObject.value) {
|
|
167
|
+
emitValue(rawVal, true);
|
|
168
|
+
}
|
|
169
|
+
if (multiple.value && !props.keepSearchOnSelect) {
|
|
170
|
+
search.value = null;
|
|
171
|
+
}
|
|
172
|
+
}, { immediate: true });
|
|
173
|
+
function getItemTitle(value) {
|
|
174
|
+
const itemTitle = safeItemTitle.value;
|
|
175
|
+
if (typeof itemTitle === "function") {
|
|
176
|
+
return itemTitle(value);
|
|
177
|
+
}
|
|
178
|
+
if (value) {
|
|
179
|
+
return value[itemTitle];
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function getValueAsObject() {
|
|
183
|
+
if (useReturnObject.value) {
|
|
184
|
+
return props.modelValue;
|
|
185
|
+
}
|
|
186
|
+
return items.value.find((item) => item[props.itemValue] === props.modelValue);
|
|
187
|
+
}
|
|
188
|
+
function emitValue(val, emitOnlyObjectValue = false) {
|
|
189
|
+
if (useReturnObject.value) {
|
|
190
|
+
if (multiple.value) {
|
|
191
|
+
emit("update:object-value", (val || []).map((v) => v[props.itemValue]));
|
|
192
|
+
} else {
|
|
193
|
+
emit("update:object-value", val ? val[props.itemValue] : null);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (!emitOnlyObjectValue) {
|
|
197
|
+
emit("update:modelValue", val);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function infiniteScrolling(isIntersecting) {
|
|
201
|
+
if (!isIntersecting || !hasMore.value || loading.value) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
loadMore();
|
|
205
|
+
}
|
|
206
|
+
watch(items, (value) => {
|
|
207
|
+
if (!props.autoSelect) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (props.modelValue) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const rawItems = toRaw(value);
|
|
214
|
+
function select(v) {
|
|
215
|
+
const map = (i) => {
|
|
216
|
+
if (!useReturnObject.value) {
|
|
217
|
+
return i?.[props.itemValue];
|
|
218
|
+
}
|
|
219
|
+
return i;
|
|
220
|
+
};
|
|
221
|
+
if (!multiple.value) {
|
|
222
|
+
emitValue(map(v));
|
|
223
|
+
} else {
|
|
224
|
+
if (!Array.isArray(v)) {
|
|
225
|
+
v = [v];
|
|
226
|
+
}
|
|
227
|
+
emitValue(v.map(map));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
let fn;
|
|
231
|
+
if (props.autoSelect === "first") {
|
|
232
|
+
fn = (item, index) => index === 0;
|
|
233
|
+
}
|
|
234
|
+
if (props.autoSelect === "only-option") {
|
|
235
|
+
fn = (item, index, arr) => index === 0 && arr.length === 1;
|
|
236
|
+
}
|
|
237
|
+
if (typeof props.autoSelect === "function") {
|
|
238
|
+
fn = props.autoSelect;
|
|
239
|
+
}
|
|
240
|
+
if (fn) {
|
|
241
|
+
const selected = multiple.value ? rawItems.filter(fn) : rawItems.find(fn);
|
|
242
|
+
select(selected);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
const otherSlots = computed(() => {
|
|
246
|
+
const overrideSlots = ["item", "search-item", "no-data"];
|
|
247
|
+
return Object.keys(useSlots()).filter((key) => !overrideSlots.includes(key));
|
|
248
|
+
});
|
|
249
|
+
function redirectTo() {
|
|
250
|
+
props.onRedirect?.call();
|
|
251
|
+
}
|
|
252
|
+
</script>
|
|
253
|
+
|
|
254
|
+
<template>
|
|
255
|
+
<v-autocomplete
|
|
256
|
+
v-model:search="search"
|
|
257
|
+
:multiple="multiple"
|
|
258
|
+
:no-filter="usePagination"
|
|
259
|
+
:model-value="modelValue"
|
|
260
|
+
:loading="loading"
|
|
261
|
+
:items="allItems"
|
|
262
|
+
:item-title="safeItemTitle"
|
|
263
|
+
:item-value="itemValue"
|
|
264
|
+
:clearable="clearable && !isReadonly"
|
|
265
|
+
:readonly="isReadonly"
|
|
266
|
+
:disabled="isDisabled"
|
|
267
|
+
:return-object="useReturnObject"
|
|
268
|
+
:no-auto-scroll="!!missingValues.length"
|
|
269
|
+
autocomplete="suppress"
|
|
270
|
+
v-bind="$attrs"
|
|
271
|
+
@update:model-value="emitValue"
|
|
272
|
+
@update:menu="handleMenuUpdate"
|
|
273
|
+
>
|
|
274
|
+
<template
|
|
275
|
+
v-if="hasItemSlot"
|
|
276
|
+
#item="attrs"
|
|
277
|
+
>
|
|
278
|
+
<slot
|
|
279
|
+
v-if="!attrs.item.__SEARCH__"
|
|
280
|
+
name="item"
|
|
281
|
+
v-bind="attrs"
|
|
282
|
+
/>
|
|
283
|
+
<slot
|
|
284
|
+
v-else
|
|
285
|
+
name="search-item"
|
|
286
|
+
v-bind="{ value: attrs.item[itemValue] }"
|
|
287
|
+
/>
|
|
288
|
+
</template>
|
|
289
|
+
|
|
290
|
+
<template
|
|
291
|
+
v-if="props.onRedirect"
|
|
292
|
+
#prepend-inner
|
|
293
|
+
>
|
|
294
|
+
<v-hover v-slot="{ isHovering, props: hoverProps }">
|
|
295
|
+
<v-btn
|
|
296
|
+
variant="text"
|
|
297
|
+
v-bind="hoverProps"
|
|
298
|
+
:disabled="!props.modelValue"
|
|
299
|
+
icon
|
|
300
|
+
size="small"
|
|
301
|
+
:color="isHovering ? 'primary' : 'undefined'"
|
|
302
|
+
@click.stop.prevent="redirectTo"
|
|
303
|
+
>
|
|
304
|
+
<v-icon size="large">
|
|
305
|
+
mdi-open-in-new
|
|
306
|
+
</v-icon>
|
|
307
|
+
</v-btn>
|
|
308
|
+
</v-hover>
|
|
309
|
+
</template>
|
|
310
|
+
|
|
311
|
+
<template #append-item>
|
|
312
|
+
<v-card
|
|
313
|
+
v-if="hasMore"
|
|
314
|
+
v-intersect="infiniteScrolling"
|
|
315
|
+
elevation="0"
|
|
316
|
+
rounded="0"
|
|
317
|
+
>
|
|
318
|
+
<v-card-text class="pa-0">
|
|
319
|
+
<v-list class="pa-0">
|
|
320
|
+
<v-list-item v-for="i in 3" :key="`we-select-loader-${i}`">
|
|
321
|
+
<v-skeleton-loader height="16" />
|
|
322
|
+
</v-list-item>
|
|
323
|
+
</v-list>
|
|
324
|
+
</v-card-text>
|
|
325
|
+
</v-card>
|
|
326
|
+
</template>
|
|
327
|
+
|
|
328
|
+
<template #no-data>
|
|
329
|
+
<slot name="no-data" />
|
|
330
|
+
<template v-if="!$slots['no-data']">
|
|
331
|
+
<div v-if="loading" class="text-center">
|
|
332
|
+
<v-progress-circular color="primary" indeterminate size="small" :width="3" />
|
|
333
|
+
</div>
|
|
334
|
+
<v-list-item v-else>
|
|
335
|
+
{{ $t('$vuetify.noDataText') }}
|
|
336
|
+
</v-list-item>
|
|
337
|
+
</template>
|
|
338
|
+
</template>
|
|
339
|
+
|
|
340
|
+
<template
|
|
341
|
+
v-for="slot in otherSlots"
|
|
342
|
+
#[slot]="slotAttrs"
|
|
343
|
+
>
|
|
344
|
+
<slot
|
|
345
|
+
:name="slot"
|
|
346
|
+
v-bind="slotAttrs"
|
|
347
|
+
/>
|
|
348
|
+
</template>
|
|
349
|
+
</v-autocomplete>
|
|
350
|
+
</template>
|
|
351
|
+
|
|
352
|
+
<style scoped>
|
|
353
|
+
.v-text-field--rounded.v-text-field--filled{border-radius:8px!important}
|
|
354
|
+
</style>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
2
|
+
export default _default;
|
|
3
|
+
type __VLS_WithSlots<T, S> = T & (new () => {
|
|
4
|
+
$slots: S;
|
|
5
|
+
});
|
|
6
|
+
declare const __VLS_component: import("vue").DefineComponent<{}, {
|
|
7
|
+
$emit: (event: "error" | "update:modelValue" | "update:object-value", ...args: any[]) => void;
|
|
8
|
+
lazy: boolean;
|
|
9
|
+
extraParams: Record<string, any>;
|
|
10
|
+
paginate: boolean | Record<string, any>;
|
|
11
|
+
multiple: boolean;
|
|
12
|
+
clearable: boolean;
|
|
13
|
+
readonly: boolean;
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
itemValue: string;
|
|
16
|
+
objectValue: string | number | boolean | Record<string, any> | unknown[] | null;
|
|
17
|
+
returnObject: boolean;
|
|
18
|
+
itemText: string | Function;
|
|
19
|
+
itemTitle: string | Function;
|
|
20
|
+
searchAsItem: boolean;
|
|
21
|
+
waitForInteraction: boolean;
|
|
22
|
+
keepSearchOnSelect: boolean;
|
|
23
|
+
resource?: string | undefined;
|
|
24
|
+
modelValue?: string | number | boolean | Record<string, any> | unknown[] | null | undefined;
|
|
25
|
+
autoSelect?: string | Function | undefined;
|
|
26
|
+
onRedirect?: Function | undefined;
|
|
27
|
+
$props: any;
|
|
28
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
29
|
+
type __VLS_Slots = {
|
|
30
|
+
[x: string]: ((props: any) => any) | undefined;
|
|
31
|
+
} & {
|
|
32
|
+
item?: ((props: any) => any) | undefined;
|
|
33
|
+
} & {
|
|
34
|
+
'search-item'?: ((props: {
|
|
35
|
+
value: any;
|
|
36
|
+
}) => any) | undefined;
|
|
37
|
+
} & {
|
|
38
|
+
'no-data'?: ((props: {}) => any) | undefined;
|
|
39
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {
|
|
2
|
+
$emit: (event: "update:modelValue", ...args: any[]) => void;
|
|
3
|
+
flat: boolean;
|
|
4
|
+
messages: string | unknown[];
|
|
5
|
+
label: string;
|
|
6
|
+
rules: unknown[];
|
|
7
|
+
readonly: boolean;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
color: string;
|
|
10
|
+
density: string;
|
|
11
|
+
tile: boolean;
|
|
12
|
+
variant: string;
|
|
13
|
+
placeholder: string;
|
|
14
|
+
errorMessages: string | unknown[];
|
|
15
|
+
persistentHint: boolean;
|
|
16
|
+
hideDetails: string | boolean;
|
|
17
|
+
persistentCounter: boolean;
|
|
18
|
+
limit?: number | undefined;
|
|
19
|
+
modelValue?: string | undefined;
|
|
20
|
+
bgColor?: string | undefined;
|
|
21
|
+
rounded?: string | number | boolean | undefined;
|
|
22
|
+
baseColor?: string | undefined;
|
|
23
|
+
hint?: string | undefined;
|
|
24
|
+
$props: any;
|
|
25
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
26
|
+
export default _default;
|