vueless 0.0.453 → 0.0.455

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.453",
3
+ "version": "0.0.455",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
@@ -2,7 +2,7 @@
2
2
  <div :data-test="dataTest" v-bind="wrapperAttrs">
3
3
  <div
4
4
  v-show="isHeaderSticky || isShownActionsHeader"
5
- ref="stickyHeaderRowRef"
5
+ ref="sticky-header-row"
6
6
  :style="tableRowWidthStyle"
7
7
  v-bind="stickyHeaderAttrs"
8
8
  >
@@ -82,7 +82,7 @@
82
82
  />
83
83
  </div>
84
84
 
85
- <div ref="tableWrapperRef" v-bind="tableWrapperAttrs">
85
+ <div ref="table-wrapper" v-bind="tableWrapperAttrs">
86
86
  <table v-bind="tableAttrs">
87
87
  <thead v-bind="headerAttrs" :style="tableRowWidthStyle">
88
88
  <tr v-if="hasSlotContent($slots['before-header'])" v-bind="headerRowAttrs">
@@ -101,7 +101,7 @@
101
101
 
102
102
  <tr v-if="hasSlotContent($slots['before-header'])" v-bind="headerRowAttrs"></tr>
103
103
 
104
- <tr ref="headerRowRef" v-bind="headerRowAttrs">
104
+ <tr ref="header-row" v-bind="headerRowAttrs">
105
105
  <th v-if="selectable" v-bind="headerCellCheckboxAttrs">
106
106
  <UCheckbox
107
107
  v-model="selectAll"
@@ -241,7 +241,7 @@
241
241
  </tbody>
242
242
 
243
243
  <tfoot v-if="hasSlotContent($slots['footer'])" v-bind="footerAttrs">
244
- <tr ref="footerRowRef" v-bind="footerRowAttrs">
244
+ <tr ref="footer-row" v-bind="footerRowAttrs">
245
245
  <td v-if="selectable" />
246
246
 
247
247
  <!--
@@ -251,7 +251,7 @@
251
251
  <slot name="footer" :cols-count="colsCount" />
252
252
  </tr>
253
253
 
254
- <tr ref="stickyFooterRowRef" :style="tableRowWidthStyle" v-bind="stickyFooterRowAttrs">
254
+ <tr ref="sticky-footer-row" :style="tableRowWidthStyle" v-bind="stickyFooterRowAttrs">
255
255
  <td v-if="selectable" />
256
256
 
257
257
  <!--
@@ -277,6 +277,7 @@ import {
277
277
  onMounted,
278
278
  onUpdated,
279
279
  onBeforeUnmount,
280
+ useTemplateRef,
280
281
  } from "vue";
281
282
  import { merge } from "lodash-es";
282
283
 
@@ -422,11 +423,11 @@ const tableWidth = ref(0);
422
423
  const tableHeight = ref(0);
423
424
  const pagePositionY = ref(0);
424
425
 
425
- const headerRowRef = ref(null);
426
- const footerRowRef = ref(null);
427
- const tableWrapperRef = ref(null);
428
- const stickyFooterRowRef = ref(null);
429
- const stickyHeaderRowRef = ref(null);
426
+ const headerRowRef = useTemplateRef("header-row");
427
+ const footerRowRef = useTemplateRef("footer-row");
428
+ const tableWrapperRef = useTemplateRef("table-wrapper");
429
+ const stickyFooterRowRef = useTemplateRef("sticky-footer-row");
430
+ const stickyHeaderRowRef = useTemplateRef("sticky-header-row");
430
431
 
431
432
  const i18nGlobal = tm(UTable);
432
433
  const currentLocale = computed(() => merge(defaultConfig.i18n, i18nGlobal, props.config.i18n));
@@ -31,21 +31,27 @@
31
31
  :style="getNestedShift()"
32
32
  v-bind="bodyCellNestedAttrs"
33
33
  >
34
- <UIcon
35
- v-if="isShownToggleIcon"
36
- size="xs"
37
- internal
38
- interactive
39
- :name="getToggleIconName(row)"
40
- color="brand"
41
- v-bind="toggleIconConfig"
42
- @click.stop="onClickToggleIcon"
43
- />
44
-
34
+ <div
35
+ ref="toggle-wrapper"
36
+ v-bind="bodyCellNestedExpandIconWrapperAttrs"
37
+ :style="{ width: getIconWidth() }"
38
+ >
39
+ <UIcon
40
+ v-if="isShownToggleIcon"
41
+ size="xs"
42
+ internal
43
+ interactive
44
+ :data-row-toggle-icon="row.id"
45
+ :name="getToggleIconName(row)"
46
+ color="brand"
47
+ v-bind="toggleIconConfig"
48
+ @click.stop="onClickToggleIcon"
49
+ />
50
+ </div>
45
51
  <slot :name="`cell-${key}`" :value="value" :row="row" :index="index">
46
52
  <div
47
53
  v-bind="bodyCellContentAttrs"
48
- ref="cellRef"
54
+ ref="cell"
49
55
  :class="cx([bodyCellContentAttrs.class, getCellContentClasses(row, key)])"
50
56
  :data-test="`${dataTest}-${key}-cell`"
51
57
  >
@@ -58,7 +64,7 @@
58
64
  <slot :name="`cell-${key}`" :value="value" :row="row" :index="index">
59
65
  <div
60
66
  v-bind="bodyCellContentAttrs"
61
- ref="cellRef"
67
+ ref="cell"
62
68
  :class="cx([bodyCellContentAttrs.class, getCellContentClasses(row, key)])"
63
69
  :data-test="`${dataTest}-${key}-cell`"
64
70
  >
@@ -147,11 +153,11 @@
147
153
  </template>
148
154
 
149
155
  <script setup>
150
- import { computed, onMounted, ref, useSlots } from "vue";
156
+ import { computed, onMounted, useSlots, useTemplateRef } from "vue";
151
157
  import { cx } from "../utils/utilUI.js";
152
158
  import useUI from "../composables/useUI.js";
153
159
 
154
- import { HYPHEN_SYMBOL } from "../constants.js";
160
+ import { HYPHEN_SYMBOL, PX_IN_REM } from "../constants.js";
155
161
  import { getFilteredRow } from "./utilTable.js";
156
162
 
157
163
  import { useMutationObserver } from "../composables/useMutationObserver.js";
@@ -207,7 +213,8 @@ const emit = defineEmits(["toggleRowVisibility", "click", "click-cell"]);
207
213
 
208
214
  const selectedRows = defineModel("selectedRows", { type: Array, default: () => [] });
209
215
 
210
- const cellRef = ref([]);
216
+ const cellRef = useTemplateRef("cell");
217
+ const toggleWrapperRef = useTemplateRef("toggle-wrapper");
211
218
  const slots = useSlots();
212
219
 
213
220
  useMutationObserver(cellRef, setCellTitle, { childList: true });
@@ -220,6 +227,7 @@ const {
220
227
  bodyCellNestedExpandIconAttrs,
221
228
  bodyCellNestedCollapseIconAttrs,
222
229
  bodyCellBaseAttrs,
230
+ bodyCellNestedExpandIconWrapperAttrs,
223
231
  } = props.attrs;
224
232
 
225
233
  const toggleIconConfig = computed(() =>
@@ -251,7 +259,13 @@ const isShownToggleIcon = computed(() => {
251
259
  );
252
260
  });
253
261
 
254
- const getToggleIconName = computed(() => (row) => {
262
+ onMounted(() => {
263
+ if (cellRef.value) {
264
+ cellRef.value.forEach(setElementTitle);
265
+ }
266
+ });
267
+
268
+ function getToggleIconName(row) {
255
269
  const isHiddenNestedRow = Array.isArray(row.row)
256
270
  ? row.row.some((nestedRow) => nestedRow.isHidden)
257
271
  : row.row?.isHidden;
@@ -259,11 +273,18 @@ const getToggleIconName = computed(() => (row) => {
259
273
  const isHidden = isHiddenNestedRow || row.nestedData?.isHidden;
260
274
 
261
275
  return isHidden ? props.config.defaults.expandIcon : props.config.defaults.collapseIcon;
262
- });
276
+ }
263
277
 
264
- onMounted(() => {
265
- cellRef.value.forEach(setElementTitle);
266
- });
278
+ function getIconWidth() {
279
+ const icon = document.querySelector(`[data-row-toggle-icon='${props.row.id}']`);
280
+ const currentWrapperWidth = toggleWrapperRef.value?.at(0)?.getBoundingClientRect()?.width;
281
+
282
+ if (icon) {
283
+ return `${icon.getBoundingClientRect().width / PX_IN_REM}rem`;
284
+ }
285
+
286
+ return `${currentWrapperWidth / PX_IN_REM || 1}rem`;
287
+ }
267
288
 
268
289
  function getCellClasses(row, key) {
269
290
  const cellClasses = row[key]?.class || "";
@@ -1,5 +1,5 @@
1
1
  export default /*tw*/ {
2
- wrapper: "relative",
2
+ wrapper: "relative w-full overflow-auto",
3
3
  headerCounterBase: "mr-1.5 pr-1.5 font-medium text-sm text-gray-900",
4
4
  stickyHeader: "fixed top-0 flex items-center z-30 overflow-hidden rounded-none border",
5
5
  stickyHeaderRow: "border-gray-200 bg-white",
@@ -18,7 +18,7 @@ export default /*tw*/ {
18
18
  stickyHeaderActionsCheckbox: "{UCheckbox}",
19
19
  stickyHeaderActionsCounter: "-ml-2",
20
20
  tableWrapper: "border border-gray-200 rounded-dynamic bg-white",
21
- table: "min-w-full border-none text-sm w-full table-fixed",
21
+ table: "min-w-full border-none text-sm w-full table-auto",
22
22
  header: "border-b border-gray-200",
23
23
  headerRow: "",
24
24
  headerCellBase: {
@@ -60,6 +60,7 @@ export default /*tw*/ {
60
60
  bodyCellCheckbox: "first:px-4", // try to remove first
61
61
  bodyCellDateDivider: "",
62
62
  bodyCellNested: "mr-2 flex gap-0.5",
63
+ bodyCellNestedExpandIconWrapper: "",
63
64
  bodyCellNestedExpandIcon: {
64
65
  component: "{UIcon}",
65
66
  wrapper: "rounded-sm",
@@ -228,7 +228,6 @@ NestedContent.args = {
228
228
  };
229
229
  }
230
230
  },
231
- selectable: true,
232
231
  slotTemplate: `
233
232
  <template #nested-content="{ row }">
234
233
  <div class="p-4 bg-gray-100">
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.453",
4
+ "version": "0.0.455",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",