vira 26.1.0 → 26.1.1
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/util/define-table.d.ts +20 -5
- package/dist/util/define-table.js +20 -4
- package/package.json +2 -2
|
@@ -24,20 +24,35 @@ export type ViraTableHeaders = ReadonlyArray<ViraTableKey>;
|
|
|
24
24
|
*
|
|
25
25
|
* @category Internal
|
|
26
26
|
*/
|
|
27
|
-
export type ViraTableEntry<
|
|
27
|
+
export type ViraTableEntry<Headers extends ViraTableHeaders | undefined = undefined> = Record<HeaderKey<Headers>, HtmlInterpolation>;
|
|
28
|
+
/**
|
|
29
|
+
* An individual cell in {@link ViraTable}.
|
|
30
|
+
*
|
|
31
|
+
* @category Internal
|
|
32
|
+
*/
|
|
33
|
+
export type ViraTableCell<Headers extends ViraTableHeaders | undefined = undefined> = {
|
|
34
|
+
content: HtmlInterpolation;
|
|
35
|
+
key: HeaderKey<Headers>;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* All keys for the given headers.
|
|
39
|
+
*
|
|
40
|
+
* @category Internal
|
|
41
|
+
*/
|
|
42
|
+
export type HeaderKey<Headers extends ViraTableHeaders | undefined = undefined> = undefined extends Headers ? string | number : ArrayElement<Exclude<Headers, undefined>>['key'];
|
|
28
43
|
/**
|
|
29
44
|
* Table information that can easily be mapped into a `<table>` element.
|
|
30
45
|
*
|
|
31
46
|
* @category Internal
|
|
32
47
|
*/
|
|
33
|
-
export type ViraTable<Orientation extends ViraTableOrientation = ViraTableOrientation.Vertical> = (Orientation extends ViraTableOrientation.Horizontal ? {
|
|
48
|
+
export type ViraTable<Headers extends ViraTableHeaders | undefined = undefined, Orientation extends ViraTableOrientation = ViraTableOrientation.Vertical> = (Orientation extends ViraTableOrientation.Horizontal ? {
|
|
34
49
|
headerRow: undefined;
|
|
35
50
|
orientation: Orientation;
|
|
36
51
|
} : {
|
|
37
|
-
headerRow:
|
|
52
|
+
headerRow: ViraTableCell<Headers>[];
|
|
38
53
|
orientation: Orientation;
|
|
39
54
|
}) & {
|
|
40
|
-
rows:
|
|
55
|
+
rows: ViraTableCell<Headers>[][];
|
|
41
56
|
};
|
|
42
57
|
/**
|
|
43
58
|
* Orientation options for {@link ViraTable}.
|
|
@@ -74,4 +89,4 @@ export type ViraTableOptions<Orientation extends ViraTableOrientation = ViraTabl
|
|
|
74
89
|
*/
|
|
75
90
|
export declare function defineTable<const Headers extends ViraTableHeaders, const Orientation extends ViraTableOrientation = ViraTableOrientation.Vertical>(
|
|
76
91
|
/** The order of these keys determines the order that they render in. */
|
|
77
|
-
headers: Readonly<Headers>, entries: ReadonlyArray<Readonly<ViraTableEntry<Headers>>>, options?: ViraTableOptions<Orientation>): ViraTable<Orientation>;
|
|
92
|
+
headers: Readonly<Headers>, entries: ReadonlyArray<Readonly<ViraTableEntry<Headers>>>, options?: ViraTableOptions<Orientation>): ViraTable<Headers, Orientation>;
|
|
@@ -30,9 +30,17 @@ headers, entries, options = {}) {
|
|
|
30
30
|
const rows = headers.map((header) => {
|
|
31
31
|
const headerCellArray = options.hideHeaders
|
|
32
32
|
? []
|
|
33
|
-
: [
|
|
33
|
+
: [
|
|
34
|
+
{
|
|
35
|
+
content: header.content ?? header.key,
|
|
36
|
+
key: header.key,
|
|
37
|
+
},
|
|
38
|
+
];
|
|
34
39
|
const cells = entries.map((entry) => {
|
|
35
|
-
return
|
|
40
|
+
return {
|
|
41
|
+
content: entry[header.key],
|
|
42
|
+
key: header.key,
|
|
43
|
+
};
|
|
36
44
|
});
|
|
37
45
|
return [
|
|
38
46
|
...headerCellArray,
|
|
@@ -48,10 +56,18 @@ headers, entries, options = {}) {
|
|
|
48
56
|
else {
|
|
49
57
|
const headerRow = options.hideHeaders
|
|
50
58
|
? []
|
|
51
|
-
: headers.map((header) =>
|
|
59
|
+
: headers.map((header) => {
|
|
60
|
+
return {
|
|
61
|
+
content: header.content ?? header.key,
|
|
62
|
+
key: header.key,
|
|
63
|
+
};
|
|
64
|
+
});
|
|
52
65
|
const rows = entries.map((entry) => {
|
|
53
66
|
return headers.map((header) => {
|
|
54
|
-
return
|
|
67
|
+
return {
|
|
68
|
+
content: entry[header.key],
|
|
69
|
+
key: header.key,
|
|
70
|
+
};
|
|
55
71
|
});
|
|
56
72
|
});
|
|
57
73
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vira",
|
|
3
|
-
"version": "26.1.
|
|
3
|
+
"version": "26.1.1",
|
|
4
4
|
"description": "A simple and highly versatile design system using element-vir.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"design",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"vite-tsconfig-paths": "^5.1.4"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"element-vir": "^26.1.
|
|
70
|
+
"element-vir": "^26.1.1"
|
|
71
71
|
},
|
|
72
72
|
"engines": {
|
|
73
73
|
"node": ">=22"
|