nuxt-ui-tools 1.16.1 → 1.16.3

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
@@ -5,7 +5,7 @@
5
5
  "configKey": "nuxtUiTools",
6
6
  "docs": "https://ui.nuxt.com/docs/getting-started/installation/nuxt",
7
7
  "name": "nuxt-ui-tools",
8
- "version": "1.16.1",
8
+ "version": "1.16.3",
9
9
  "builder": {
10
10
  "@nuxt/module-builder": "1.0.3",
11
11
  "unbuild": "unknown"
@@ -11,11 +11,12 @@ const { params } = useFieldControl(
11
11
  () => props.path
12
12
  );
13
13
  const rendered = computed(() => props.field.render?.(params.value));
14
+ const Rendered = () => rendered.value;
14
15
  </script>
15
16
 
16
17
  <template>
17
18
  <FormFieldShell :field="field" :path="path">
18
19
  <component :is="field.component" v-if="field.component" />
19
- <component :is="() => rendered" v-else-if="rendered" />
20
+ <Rendered v-else-if="rendered" />
20
21
  </FormFieldShell>
21
22
  </template>
@@ -1,7 +1,8 @@
1
1
  <script setup>
2
2
  import UButton from "@nuxt/ui/components/Button.vue";
3
3
  import UDropdownMenu from "@nuxt/ui/components/DropdownMenu.vue";
4
- import { computed } from "vue";
4
+ import { useResizeObserver } from "@vueuse/core";
5
+ import { computed, nextTick, ref, useTemplateRef, watch } from "vue";
5
6
  import { useUiToolsLocale } from "#ui-tools/i18n";
6
7
  import { isString, isNullish } from "../../../shared/utils/predicate";
7
8
  import { useDataListBreakpoint } from "../../composables/use-data-list-breakpoint";
@@ -59,8 +60,13 @@ const scopeEnabled = computed(
59
60
  );
60
61
  const bulkScope = computed(() => internals.selection.bulkScope.value);
61
62
  const maxVisible = computed(() => props.maxVisible ?? (isMobile.value ? 1 : 3));
62
- const visibleActions = computed(() => actions.value.slice(0, maxVisible.value));
63
- const overflowActions = computed(() => actions.value.slice(maxVisible.value));
63
+ const fitted = ref(Number.POSITIVE_INFINITY);
64
+ const visibleCount = computed(() => Math.min(maxVisible.value, fitted.value));
65
+ const visibleActions = computed(() => actions.value.slice(0, visibleCount.value));
66
+ const overflowActions = computed(() => actions.value.slice(visibleCount.value));
67
+ const rootElement = useTemplateRef("rootElement");
68
+ const actionsElement = useTemplateRef("actionsElement");
69
+ let fitting = 0;
64
70
  const overflowItems = computed(
65
71
  () => overflowActions.value.map((action) => ({
66
72
  disabled: action.state.disabled,
@@ -77,12 +83,36 @@ function formatCount(value) {
77
83
  function clearSelection() {
78
84
  internals.selection.clearSelection();
79
85
  }
86
+ function overflowing() {
87
+ const strip = actionsElement.value;
88
+ return Boolean(strip && strip.scrollWidth > strip.clientWidth + 1);
89
+ }
90
+ async function fit() {
91
+ const run = ++fitting;
92
+ fitted.value = Number.POSITIVE_INFINITY;
93
+ await nextTick();
94
+ while (run === fitting && visibleCount.value > 0 && overflowing()) {
95
+ fitted.value = visibleCount.value - 1;
96
+ await nextTick();
97
+ }
98
+ }
99
+ watch(
100
+ () => [
101
+ selectedCount.value > 0,
102
+ maxVisible.value,
103
+ actions.value.map((action) => resolveTableActionLabel(action.definition.label)).join("\n")
104
+ ],
105
+ () => void fit(),
106
+ { flush: "post" }
107
+ );
108
+ useResizeObserver(rootElement, () => void fit());
80
109
  </script>
81
110
 
82
111
  <template>
83
112
  <Transition name="nut-dl-selbar">
84
113
  <div
85
114
  v-if="selectedCount > 0 && actions.length"
115
+ ref="rootElement"
86
116
  :class="
87
117
  mergeDataListUiClass(
88
118
  `nut-dl-selbar pointer-events-none z-40 flex justify-center px-4 ${position === 'fixed' ? 'fixed inset-x-0 bottom-4' : 'absolute inset-x-0 bottom-[22px]'}`,
@@ -163,6 +193,7 @@ function clearSelection() {
163
193
  </span>
164
194
 
165
195
  <div
196
+ ref="actionsElement"
166
197
  :class="
167
198
  mergeDataListUiClass(
168
199
  `nut-dl-selbar__actions flex min-w-0 items-center gap-0.5 ${scopeEnabled ? 'ml-1 pl-2' : ''}`,
@@ -76,5 +76,5 @@ function startResize(event) {
76
76
  </template>
77
77
 
78
78
  <style>
79
- .nut-dl-colmenu{min-width:13.5rem}.nut-dl-colmenu .nut-dl-colmenu__title{color:var(--ui-text-dimmed);font-size:11px;font-weight:600;letter-spacing:.06em;padding:.35rem .5rem .25rem;text-transform:uppercase}.nut-dl-colmenu .nut-dl-colmenu__item--active{color:var(--ui-text-highlighted);font-weight:600}.nut-dl-colmenu .nut-dl-colmenu__item--active:after{background:var(--ui-primary);border-radius:999px;content:"";flex:none;height:7px;margin-left:auto;width:7px}
79
+ .nut-dl-colmenu{min-width:13.5rem}.nut-dl-colmenu .nut-dl-colmenu__title{font-size:11px;font-weight:600;letter-spacing:.06em;padding:.35rem .5rem .25rem;text-transform:uppercase}.nut-dl-colmenu .nut-dl-colmenu__item--active{font-weight:600}.nut-dl-colmenu .nut-dl-colmenu__item--active:after{background:var(--ui-primary);border-radius:999px;content:"";flex:none;height:7px;margin-left:auto;width:7px}
80
80
  </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-ui-tools",
3
- "version": "1.16.1",
3
+ "version": "1.16.3",
4
4
  "description": "Nuxt module and runtime toolkit for UI-heavy Nuxt applications",
5
5
  "homepage": "https://github.com/ChronicStone/nuxt-ui-tools#readme",
6
6
  "bugs": "https://github.com/ChronicStone/nuxt-ui-tools/issues",