@hostlink/nuxt-light 1.74.1 → 1.75.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/dist/module.json
CHANGED
|
@@ -195,6 +195,17 @@ const resolveColumnOptions = async (col) => {
|
|
|
195
195
|
} catch {
|
|
196
196
|
}
|
|
197
197
|
};
|
|
198
|
+
const autoWidthSelectStyle = (col) => {
|
|
199
|
+
if (!col.autoWidth) return {};
|
|
200
|
+
const options = localSearchOptions.value[col.name] ?? [];
|
|
201
|
+
const labelWidth = (option) => {
|
|
202
|
+
const label = String(option.label ?? option.value ?? "");
|
|
203
|
+
return Array.from(label).reduce((width2, character) => width2 + (character.charCodeAt(0) > 255 ? 2 : 1), 0);
|
|
204
|
+
};
|
|
205
|
+
const longestLabel = Math.max(0, ...options.map(labelWidth));
|
|
206
|
+
const width = Math.min(36, Math.max(12, longestLabel + 4));
|
|
207
|
+
return { width: `${width}ch`, minWidth: `${width}ch` };
|
|
208
|
+
};
|
|
198
209
|
onMounted(async () => {
|
|
199
210
|
await Promise.all(
|
|
200
211
|
(props.columns ?? []).map((col) => resolveColumnOptions(col))
|
|
@@ -700,7 +711,7 @@ const hasFilters = computed(() => {
|
|
|
700
711
|
<q-td v-if="selection != 'none'" auto-width />
|
|
701
712
|
<q-td v-if="hasRowExpand" auto-width />
|
|
702
713
|
<q-td v-if="hasActions" auto-width />
|
|
703
|
-
<q-td v-for="col in props.cols" :key="col.name" :style="col.style">
|
|
714
|
+
<q-td v-for="col in props.cols" :key="col.name" :auto-width="col.autoWidth ?? false" :style="col.style">
|
|
704
715
|
|
|
705
716
|
<template v-if="col.searchable">
|
|
706
717
|
|
|
@@ -724,7 +735,7 @@ const hasFilters = computed(() => {
|
|
|
724
735
|
:options="localSearchOptions[col.name]" emit-value map-options
|
|
725
736
|
:multiple="col.searchMultiple" use-input input-debounce="0" @filter="(val, update) => {
|
|
726
737
|
searchSelectFilter(val, update, col.name);
|
|
727
|
-
}" :style="col.searchStyle" :placeholder="col.searchPlaceholder" />
|
|
738
|
+
}" :style="[autoWidthSelectStyle(col), col.searchStyle]" :placeholder="col.searchPlaceholder" />
|
|
728
739
|
</template>
|
|
729
740
|
|
|
730
741
|
<template v-if="col.searchType == 'date'">
|