@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollSpy.d.ts","sourceRoot":"","sources":["../../../../../src/components/anchor/composables/useScrollSpy.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,QAAQ,EAAE;;;;;
|
|
1
|
+
{"version":3,"file":"useScrollSpy.d.ts","sourceRoot":"","sources":["../../../../../src/components/anchor/composables/useScrollSpy.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,QAAQ,EAAE;;;;;kBAkD/B,UAAU,MAAM,MAAM;EAU5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTable.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/data-table/DataTable.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DataTable.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/data-table/DataTable.vue"],"names":[],"mappings":"AA6WE,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACZ,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,aAAa,EACd,MAAM,SAAS,CAAA;AAEhB,QAAA,MAAM,YAAY,GAAK,CAAC,SAAS,MAAM,EACxC,aAAa,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,EAC9D,YAAY,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,EAC3G,gBAAgB,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,EAClE;WAkuBO,OAAO,KAAK,EAAE,WAAW,GAAG,mBAAmB,CAAC;eAjmB/C,MAAM;mBACF,MAAM;kBACP,aAAa,EAAE;iBAChB,MAAM;wBACC,eAAe,EAAE;mBACtB,MAAM,EAAE;mBACR,YAAY,EAAE;mBACd,YAAY,EAAE;yBACR,MAAM,EAAE;wBACT,MAAM,EAAE;sBACV,MAAM,EAAE;uBACP,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;KAslBoD,CAAC,GAAG,CAAC,OAAO,UAAU,SAAS;QAAE,oBAAoB,EAAE,MAAM,CAAC,CAAA;KAAE,GAAG,CAAC,GAAG,EAAE,CAAC;YAC5J,CAAC,OAAO,EAAE,OAAO,KAAK,EAAE,gBAAgB;;;;;MAAsB,KAAK,IAAI;WACxE,GAAG;;UAEJ,knCAAoC;EAEvC,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAA;CAAI,CAAC;wBACpE,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,CAAC,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CSSProperties } from 'vue';
|
|
2
|
+
import type { DataTableColumn } from './types';
|
|
3
|
+
export declare function columnSizingStyles<T extends object>(columns: DataTableColumn<T>[], overrides: Record<string, number>, controls: number): CSSProperties;
|
|
4
|
+
//# sourceMappingURL=column-sizing-styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-sizing-styles.d.ts","sourceRoot":"","sources":["../../../../src/components/data-table/column-sizing-styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EACjD,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,EAC7B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,QAAQ,EAAE,MAAM,GACf,aAAa,CA+Bf"}
|
|
@@ -42,6 +42,7 @@ export declare function useTableColumns<T extends object>(props: DataTableProps<
|
|
|
42
42
|
resize: (column: DataTableColumn<T>, event: PointerEvent) => void;
|
|
43
43
|
resizeKey: (column: DataTableColumn<T>, event: KeyboardEvent) => void;
|
|
44
44
|
setWidth: (key: string, value: number) => void;
|
|
45
|
+
constrained: import("vue").ComputedRef<boolean>;
|
|
45
46
|
headerRows: import("vue").ComputedRef<DataTableHeader<T>[][]>;
|
|
46
47
|
tableStyle: import("vue").ComputedRef<CSSProperties>;
|
|
47
48
|
cellStyle: (column: DataTableColumn<T>, head?: boolean) => CSSProperties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTableColumns.d.ts","sourceRoot":"","sources":["../../../../../src/components/data-table/composables/useTableColumns.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,GAAG,EACR,KAAK,aAAa,EACnB,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"useTableColumns.d.ts","sourceRoot":"","sources":["../../../../../src/components/data-table/composables/useTableColumns.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,GAAG,EACR,KAAK,aAAa,EACnB,MAAM,KAAK,CAAA;AAMZ,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAChF,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAE1E,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,EAC9C,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EACxB,MAAM,EAAE,eAAe,EACvB,GAAG,EAAE,mBAAmB,CAAC,CAAC,CAAC,EAC3B,OAAO,EAAE,GAAG,CAAC,gBAAgB,GAAG,SAAS,CAAC,EAC1C,QAAQ,EAAE,GAAG,CAAC,WAAW,GAAG,SAAS,CAAC,EACtC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EACpB,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC;oBAwEE,eAAe,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAyBd,eAAe,CAAC,CAAC,CAAC,qBAAiB,aAAa;yBAQ/C,OAAO,GAAG,KAAK,SAAS,MAAM,qBAAiB,aAAa;EAuHzF;AAED,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,MAAM,IAAI,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.variants.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table.variants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AAEpD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"table.variants.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table.variants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AAEpD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAwBvB,CAAA;AAEF,MAAM,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,YAAY,CAAC,CAAA;AAE7D,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsBpB,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,YAAY,CAAC,OAAO,SAAS,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@ export interface SpyEntry {
|
|
|
11
11
|
export function useScrollSpy(entries: () => SpyEntry[]) {
|
|
12
12
|
const visible = shallowRef<ReadonlySet<string>>(new Set())
|
|
13
13
|
const targets = shallowRef<Array<HTMLElement | null>>([])
|
|
14
|
-
const
|
|
14
|
+
const intersecting = new Set<string>()
|
|
15
15
|
|
|
16
16
|
const covered = computed(() => entries().filter(entry => visible.value.has(entry.id)))
|
|
17
17
|
const current = computed(() => covered.value[0]?.id)
|
|
@@ -23,18 +23,15 @@ export function useScrollSpy(entries: () => SpyEntry[]) {
|
|
|
23
23
|
useIntersectionObserver(
|
|
24
24
|
targets,
|
|
25
25
|
observed => {
|
|
26
|
-
const next = new Set(visible.value)
|
|
27
26
|
for (const entry of observed) {
|
|
28
|
-
if (entry.isIntersecting)
|
|
29
|
-
|
|
30
|
-
next.add(entry.target.id)
|
|
31
|
-
} else if (seen.has(entry.target.id)) {
|
|
32
|
-
next.delete(entry.target.id)
|
|
33
|
-
}
|
|
27
|
+
if (entry.isIntersecting && entry.intersectionRatio > 0) intersecting.add(entry.target.id)
|
|
28
|
+
else intersecting.delete(entry.target.id)
|
|
34
29
|
}
|
|
35
|
-
|
|
30
|
+
visible.value = intersecting.size
|
|
31
|
+
? new Set(intersecting)
|
|
32
|
+
: new Set(current.value ? [current.value] : [])
|
|
36
33
|
},
|
|
37
|
-
{ rootMargin: '0px 0px -15% 0px' },
|
|
34
|
+
{ rootMargin: '0px 0px -15% 0px', threshold: [0, Number.EPSILON] },
|
|
38
35
|
)
|
|
39
36
|
|
|
40
37
|
function targetOf(id: string) {
|
|
@@ -42,7 +39,7 @@ export function useScrollSpy(entries: () => SpyEntry[]) {
|
|
|
42
39
|
}
|
|
43
40
|
|
|
44
41
|
function locate() {
|
|
45
|
-
|
|
42
|
+
intersecting.clear()
|
|
46
43
|
targets.value = entries().map(({ id }) => targetOf(id))
|
|
47
44
|
}
|
|
48
45
|
|
|
@@ -168,6 +168,7 @@
|
|
|
168
168
|
:class="
|
|
169
169
|
cn(
|
|
170
170
|
tableWrapper({ variant: props.variant, hover: false }),
|
|
171
|
+
layout.constrained.value && '@container',
|
|
171
172
|
(props.fill || props.height) && 'h-full',
|
|
172
173
|
props.stickyHeader && '[&_thead_th]:sticky [&_thead_th]:z-[3]',
|
|
173
174
|
props.stickyFooter &&
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { CSSProperties } from 'vue'
|
|
2
|
+
import { allocateWidths, columnBounds } from './column-sizing'
|
|
3
|
+
import type { DataTableColumn } from './types'
|
|
4
|
+
|
|
5
|
+
export function columnSizingStyles<T extends object>(
|
|
6
|
+
columns: DataTableColumn<T>[],
|
|
7
|
+
overrides: Record<string, number>,
|
|
8
|
+
controls: number,
|
|
9
|
+
): CSSProperties {
|
|
10
|
+
const initial = allocateWidths(columns, overrides, 0)
|
|
11
|
+
const total = Object.values(initial).reduce((sum, width) => sum + width, controls)
|
|
12
|
+
const flexible = columns.filter(
|
|
13
|
+
column =>
|
|
14
|
+
!column.pin &&
|
|
15
|
+
overrides[column.key] === undefined &&
|
|
16
|
+
initial[column.key]! < columnBounds(column).max,
|
|
17
|
+
)
|
|
18
|
+
const capacities = flexible
|
|
19
|
+
.map(column => columnBounds(column).max - initial[column.key]!)
|
|
20
|
+
.sort((a, b) => a - b)
|
|
21
|
+
let consumed = 0
|
|
22
|
+
const shares = capacities.map((capacity, index) => {
|
|
23
|
+
const share = `calc((100cqi - ${total + consumed}px) / ${capacities.length - index})`
|
|
24
|
+
consumed += capacity
|
|
25
|
+
return share
|
|
26
|
+
})
|
|
27
|
+
const keys = new Set(flexible.map(column => column.key))
|
|
28
|
+
return {
|
|
29
|
+
width: shares.length ? `clamp(${total}px, 100%, ${total + consumed}px)` : `${total}px`,
|
|
30
|
+
'--hn-table-column-grow': shares.length ? `max(0px, ${shares.join(', ')})` : '0px',
|
|
31
|
+
...Object.fromEntries(
|
|
32
|
+
columns.map((column, index) => [
|
|
33
|
+
`--hn-table-column-${index}`,
|
|
34
|
+
keys.has(column.key)
|
|
35
|
+
? `min(${columnBounds(column).max}px, calc(${initial[column.key]}px + var(--hn-table-column-grow)))`
|
|
36
|
+
: `${initial[column.key]}px`,
|
|
37
|
+
]),
|
|
38
|
+
),
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from 'vue'
|
|
10
10
|
import { cssSize } from '../utils'
|
|
11
11
|
import { allocateWidths, pixelWidth } from '../column-sizing'
|
|
12
|
+
import { columnSizingStyles } from '../column-sizing-styles'
|
|
12
13
|
import { useTableResize } from './useTableResize'
|
|
13
14
|
import { useTableResizeHandles } from './useTableResizeHandles'
|
|
14
15
|
import type { DataTableColumn, DataTableHeader, DataTableProps } from '../types'
|
|
@@ -200,15 +201,11 @@ export function useTableColumns<T extends object>(
|
|
|
200
201
|
'--hn-table-viewport-width': available.value ? `${available.value}px` : undefined,
|
|
201
202
|
tableLayout: constrained.value ? 'fixed' : 'auto',
|
|
202
203
|
...(constrained.value
|
|
203
|
-
?
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
]),
|
|
209
|
-
),
|
|
210
|
-
width: `${ctl.visibleColumns.value.reduce((sum, column) => sum + width(column), leading.value * 48 + trailing.value * 72)}px`,
|
|
211
|
-
}
|
|
204
|
+
? columnSizingStyles(
|
|
205
|
+
ctl.visibleColumns.value,
|
|
206
|
+
active.value ?? models.columnWidths.value,
|
|
207
|
+
leading.value * 48 + trailing.value * 72,
|
|
208
|
+
)
|
|
212
209
|
: {}),
|
|
213
210
|
}))
|
|
214
211
|
function moveColumn(key: string, target: string) {
|
|
@@ -240,6 +237,7 @@ export function useTableColumns<T extends object>(
|
|
|
240
237
|
observer?.disconnect()
|
|
241
238
|
})
|
|
242
239
|
return {
|
|
240
|
+
constrained,
|
|
243
241
|
headerRows,
|
|
244
242
|
tableStyle,
|
|
245
243
|
cellStyle,
|
|
@@ -4,7 +4,6 @@ export const tableWrapper = tv({
|
|
|
4
4
|
base: [
|
|
5
5
|
'max-w-full rounded-lg',
|
|
6
6
|
'[&_th]:h-(--hn-row-h) [&_td]:h-(--hn-row-h)',
|
|
7
|
-
'[&_th]:py-0 [&_td]:py-0',
|
|
8
7
|
'[&_caption>span]:sticky [&_caption>span]:start-[0.75em] [&_caption>span]:inline-block',
|
|
9
8
|
'[&_tbody_tr:last-child_td]:border-b-0',
|
|
10
9
|
],
|
|
@@ -30,7 +29,7 @@ export const tableWrapper = tv({
|
|
|
30
29
|
export type TableVariants = VariantProps<typeof tableWrapper>
|
|
31
30
|
|
|
32
31
|
export const tableCell = tv({
|
|
33
|
-
base: '',
|
|
32
|
+
base: 'py-0',
|
|
34
33
|
variants: {
|
|
35
34
|
align: {
|
|
36
35
|
start: '',
|