@hina-ui/vue 1.7.1 → 1.7.2
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/index.js +34 -17
- package/dist/index.js.map +1 -1
- package/dist/types/components/anchor/composables/useScrollSpy.d.ts.map +1 -1
- package/dist/types/components/data-table/DataTable.vue.d.ts.map +1 -1
- package/dist/types/components/data-table/column-sizing-styles.d.ts +4 -0
- package/dist/types/components/data-table/column-sizing-styles.d.ts.map +1 -0
- package/dist/types/components/data-table/composables/useTableColumns.d.ts +1 -0
- package/dist/types/components/data-table/composables/useTableColumns.d.ts.map +1 -1
- package/dist/types/components/table/table.variants.d.ts +1 -1
- package/dist/types/components/table/table.variants.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/anchor/composables/useScrollSpy.ts +8 -11
- package/src/components/data-table/DataTable.vue +1 -0
- package/src/components/data-table/DataTableHead.vue +1 -1
- package/src/components/data-table/column-sizing-styles.ts +40 -0
- package/src/components/data-table/composables/useTableColumns.ts +7 -9
- package/src/components/table/table.variants.ts +1 -2
- package/src/styles/data-table.css +0 -1
- package/src/styles/typography.css +1 -2
package/dist/index.js
CHANGED
|
@@ -7660,7 +7660,6 @@ var tableWrapper = tv({
|
|
|
7660
7660
|
base: [
|
|
7661
7661
|
"max-w-full rounded-lg",
|
|
7662
7662
|
"[&_th]:h-(--hn-row-h) [&_td]:h-(--hn-row-h)",
|
|
7663
|
-
"[&_th]:py-0 [&_td]:py-0",
|
|
7664
7663
|
"[&_caption>span]:sticky [&_caption>span]:start-[0.75em] [&_caption>span]:inline-block",
|
|
7665
7664
|
"[&_tbody_tr:last-child_td]:border-b-0"
|
|
7666
7665
|
],
|
|
@@ -7685,7 +7684,7 @@ var tableWrapper = tv({
|
|
|
7685
7684
|
}
|
|
7686
7685
|
});
|
|
7687
7686
|
var tableCell = tv({
|
|
7688
|
-
base: "",
|
|
7687
|
+
base: "py-0",
|
|
7689
7688
|
variants: {
|
|
7690
7689
|
align: {
|
|
7691
7690
|
start: "",
|
|
@@ -20178,7 +20177,7 @@ var Section_default = /* @__PURE__ */ defineComponent({
|
|
|
20178
20177
|
function useScrollSpy(entries) {
|
|
20179
20178
|
const visible = shallowRef(/* @__PURE__ */ new Set());
|
|
20180
20179
|
const targets = shallowRef([]);
|
|
20181
|
-
const
|
|
20180
|
+
const intersecting = /* @__PURE__ */ new Set();
|
|
20182
20181
|
const covered = computed(() => entries().filter((entry) => visible.value.has(entry.id)));
|
|
20183
20182
|
const current = computed(() => covered.value[0]?.id);
|
|
20184
20183
|
const span = computed(() => {
|
|
@@ -20186,18 +20185,18 @@ function useScrollSpy(entries) {
|
|
|
20186
20185
|
return rows.length ? `${rows[0] + 1} / ${rows.at(-1) + 2}` : void 0;
|
|
20187
20186
|
});
|
|
20188
20187
|
useIntersectionObserver(targets, (observed) => {
|
|
20189
|
-
const
|
|
20190
|
-
|
|
20191
|
-
|
|
20192
|
-
|
|
20193
|
-
|
|
20194
|
-
|
|
20195
|
-
}
|
|
20188
|
+
for (const entry of observed) if (entry.isIntersecting && entry.intersectionRatio > 0) intersecting.add(entry.target.id);
|
|
20189
|
+
else intersecting.delete(entry.target.id);
|
|
20190
|
+
visible.value = intersecting.size ? new Set(intersecting) : new Set(current.value ? [current.value] : []);
|
|
20191
|
+
}, {
|
|
20192
|
+
rootMargin: "0px 0px -15% 0px",
|
|
20193
|
+
threshold: [0, Number.EPSILON]
|
|
20194
|
+
});
|
|
20196
20195
|
function targetOf(id) {
|
|
20197
20196
|
return document.getElementById(id);
|
|
20198
20197
|
}
|
|
20199
20198
|
function locate() {
|
|
20200
|
-
|
|
20199
|
+
intersecting.clear();
|
|
20201
20200
|
targets.value = entries().map(({ id }) => targetOf(id));
|
|
20202
20201
|
}
|
|
20203
20202
|
onMounted(() => {
|
|
@@ -22236,7 +22235,7 @@ var DataTableHead_default = /* @__PURE__ */ defineComponent({
|
|
|
22236
22235
|
align: header.column.align,
|
|
22237
22236
|
"aria-sort": header.ariaSort,
|
|
22238
22237
|
style: normalizeStyle(header.style),
|
|
22239
|
-
class: normalizeClass(unref(cn)("hn-table-header relative", header.column.headerClass, __props.drag.kind.value === "column" && __props.drag.key.value === header.column.key && "opacity-40")),
|
|
22238
|
+
class: normalizeClass(unref(cn)("hn-table-header relative p-0", header.column.headerClass, __props.drag.kind.value === "column" && __props.drag.key.value === header.column.key && "opacity-40")),
|
|
22240
22239
|
"data-reorderable": header.leaf && __props.config.reorderColumns && header.column.reorderable !== false && !__props.ctl.blocked.value ? "" : void 0,
|
|
22241
22240
|
"data-align": header.column.align,
|
|
22242
22241
|
onPointerdown: ($event) => header.leaf && __props.drag.start("column", header.column.key, header.column.label, $event)
|
|
@@ -23338,6 +23337,26 @@ function resizeWidths(column, neighbor, widths, value, minimumTotalWidth = 0, ma
|
|
|
23338
23337
|
};
|
|
23339
23338
|
}
|
|
23340
23339
|
//#endregion
|
|
23340
|
+
//#region src/components/data-table/column-sizing-styles.ts
|
|
23341
|
+
function columnSizingStyles(columns, overrides, controls) {
|
|
23342
|
+
const initial = allocateWidths(columns, overrides, 0);
|
|
23343
|
+
const total = Object.values(initial).reduce((sum, width) => sum + width, controls);
|
|
23344
|
+
const flexible = columns.filter((column) => !column.pin && overrides[column.key] === void 0 && initial[column.key] < columnBounds(column).max);
|
|
23345
|
+
const capacities = flexible.map((column) => columnBounds(column).max - initial[column.key]).sort((a, b) => a - b);
|
|
23346
|
+
let consumed = 0;
|
|
23347
|
+
const shares = capacities.map((capacity, index) => {
|
|
23348
|
+
const share = `calc((100cqi - ${total + consumed}px) / ${capacities.length - index})`;
|
|
23349
|
+
consumed += capacity;
|
|
23350
|
+
return share;
|
|
23351
|
+
});
|
|
23352
|
+
const keys = new Set(flexible.map((column) => column.key));
|
|
23353
|
+
return {
|
|
23354
|
+
width: shares.length ? `clamp(${total}px, 100%, ${total + consumed}px)` : `${total}px`,
|
|
23355
|
+
"--hn-table-column-grow": shares.length ? `max(0px, ${shares.join(", ")})` : "0px",
|
|
23356
|
+
...Object.fromEntries(columns.map((column, index) => [`--hn-table-column-${index}`, keys.has(column.key) ? `min(${columnBounds(column).max}px, calc(${initial[column.key]}px + var(--hn-table-column-grow)))` : `${initial[column.key]}px`]))
|
|
23357
|
+
};
|
|
23358
|
+
}
|
|
23359
|
+
//#endregion
|
|
23341
23360
|
//#region src/components/data-table/composables/useTableResize.ts
|
|
23342
23361
|
function useTableResize(props, models, ctl, element, viewport, widths, active, available) {
|
|
23343
23362
|
const resizing = shallowRef();
|
|
@@ -23753,10 +23772,7 @@ function useTableColumns(props, models, ctl, element, viewport, leading, trailin
|
|
|
23753
23772
|
const tableStyle = computed(() => ({
|
|
23754
23773
|
"--hn-table-viewport-width": available.value ? `${available.value}px` : void 0,
|
|
23755
23774
|
tableLayout: constrained.value ? "fixed" : "auto",
|
|
23756
|
-
...constrained.value ? {
|
|
23757
|
-
...Object.fromEntries(ctl.visibleColumns.value.map((column, index) => [`--hn-table-column-${index}`, `${widths.value[column.key]}px`])),
|
|
23758
|
-
width: `${ctl.visibleColumns.value.reduce((sum, column) => sum + width(column), leading.value * 48 + trailing.value * 72)}px`
|
|
23759
|
-
} : {}
|
|
23775
|
+
...constrained.value ? columnSizingStyles(ctl.visibleColumns.value, active.value ?? models.columnWidths.value, leading.value * 48 + trailing.value * 72) : {}
|
|
23760
23776
|
}));
|
|
23761
23777
|
function moveColumn(key, target) {
|
|
23762
23778
|
if (ctl.blocked.value || key === target) return;
|
|
@@ -23779,6 +23795,7 @@ function useTableColumns(props, models, ctl, element, viewport, leading, trailin
|
|
|
23779
23795
|
observer?.disconnect();
|
|
23780
23796
|
});
|
|
23781
23797
|
return {
|
|
23798
|
+
constrained,
|
|
23782
23799
|
headerRows,
|
|
23783
23800
|
tableStyle,
|
|
23784
23801
|
cellStyle,
|
|
@@ -24509,7 +24526,7 @@ var DataTable_default = /* @__PURE__ */ defineComponent({
|
|
|
24509
24526
|
class: normalizeClass(unref(cn)(unref(tableWrapper)({
|
|
24510
24527
|
variant: props.variant,
|
|
24511
24528
|
hover: false
|
|
24512
|
-
}), (props.fill || props.height) && "h-full", props.stickyHeader && "[&_thead_th]:sticky [&_thead_th]:z-[3]", props.stickyFooter && "[&_tfoot_td]:sticky [&_tfoot_td]:bottom-0 [&_tfoot_td]:z-[2] [&_tfoot_td]:bg-(--hn-table-head-bg)", props.tableClass))
|
|
24529
|
+
}), unref(layout).constrained.value && "@container", (props.fill || props.height) && "h-full", props.stickyHeader && "[&_thead_th]:sticky [&_thead_th]:z-[3]", props.stickyFooter && "[&_tfoot_td]:sticky [&_tfoot_td]:bottom-0 [&_tfoot_td]:z-[2] [&_tfoot_td]:bg-(--hn-table-head-bg)", props.tableClass))
|
|
24513
24530
|
}, {
|
|
24514
24531
|
default: withCtx(() => [createElementVNode("table", {
|
|
24515
24532
|
ref_key: "element",
|