vira 26.1.1 → 26.3.0
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/index.d.ts +0 -1
- package/dist/util/index.js +0 -1
- package/package.json +4 -4
- package/dist/util/define-table.d.ts +0 -92
- package/dist/util/define-table.js +0 -79
package/dist/util/index.d.ts
CHANGED
package/dist/util/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vira",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.3.0",
|
|
4
4
|
"description": "A simple and highly versatile design system using element-vir.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"design",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"lit-css-vars": "^3.0.11",
|
|
48
48
|
"observavir": "^2.0.5",
|
|
49
49
|
"page-active": "^1.0.1",
|
|
50
|
-
"spa-router-vir": "^6.
|
|
50
|
+
"spa-router-vir": "^6.1.1",
|
|
51
51
|
"type-fest": "^4.41.0",
|
|
52
52
|
"typed-event-target": "^4.1.0"
|
|
53
53
|
},
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@web/dev-server-esbuild": "^1.0.4",
|
|
57
57
|
"@web/test-runner": "^0.20.2",
|
|
58
58
|
"@web/test-runner-commands": "^0.9.0",
|
|
59
|
-
"@web/test-runner-playwright": "^0.11.
|
|
59
|
+
"@web/test-runner-playwright": "^0.11.1",
|
|
60
60
|
"@web/test-runner-visual-regression": "^0.10.0",
|
|
61
61
|
"esbuild": "^0.25.5",
|
|
62
62
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"vite-tsconfig-paths": "^5.1.4"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"element-vir": "^26.
|
|
70
|
+
"element-vir": "^26.3.0"
|
|
71
71
|
},
|
|
72
72
|
"engines": {
|
|
73
73
|
"node": ">=22"
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { type ArrayElement, type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
-
import { type HtmlInterpolation } from 'element-vir';
|
|
3
|
-
/**
|
|
4
|
-
* An individual key definition in {@link ViraTableHeaders}.
|
|
5
|
-
*
|
|
6
|
-
* @category Internal
|
|
7
|
-
*/
|
|
8
|
-
export type ViraTableKey = Readonly<{
|
|
9
|
-
/** The key that cells must set a value to. */
|
|
10
|
-
key: string | number;
|
|
11
|
-
} & PartialWithUndefined<{
|
|
12
|
-
/** If this is not provided, `key` will be used directly. */
|
|
13
|
-
content: HtmlInterpolation;
|
|
14
|
-
}>>;
|
|
15
|
-
/**
|
|
16
|
-
* All header definitions for a {@link ViraTable} instance.
|
|
17
|
-
*
|
|
18
|
-
* @category Internal
|
|
19
|
-
*/
|
|
20
|
-
export type ViraTableHeaders = ReadonlyArray<ViraTableKey>;
|
|
21
|
-
/**
|
|
22
|
-
* An individual entry in {@link ViraTable}. In default table orientation, this will be a row. In
|
|
23
|
-
* horizontal orientation, this will be a column.
|
|
24
|
-
*
|
|
25
|
-
* @category Internal
|
|
26
|
-
*/
|
|
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'];
|
|
43
|
-
/**
|
|
44
|
-
* Table information that can easily be mapped into a `<table>` element.
|
|
45
|
-
*
|
|
46
|
-
* @category Internal
|
|
47
|
-
*/
|
|
48
|
-
export type ViraTable<Headers extends ViraTableHeaders | undefined = undefined, Orientation extends ViraTableOrientation = ViraTableOrientation.Vertical> = (Orientation extends ViraTableOrientation.Horizontal ? {
|
|
49
|
-
headerRow: undefined;
|
|
50
|
-
orientation: Orientation;
|
|
51
|
-
} : {
|
|
52
|
-
headerRow: ViraTableCell<Headers>[];
|
|
53
|
-
orientation: Orientation;
|
|
54
|
-
}) & {
|
|
55
|
-
rows: ViraTableCell<Headers>[][];
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Orientation options for {@link ViraTable}.
|
|
59
|
-
*
|
|
60
|
-
* @category Internal
|
|
61
|
-
*/
|
|
62
|
-
export declare enum ViraTableOrientation {
|
|
63
|
-
/**
|
|
64
|
-
* This is the default table layout. Each entry becomes a new row. Headers are a row at the top
|
|
65
|
-
* of the table.
|
|
66
|
-
*/
|
|
67
|
-
Vertical = "vertical",
|
|
68
|
-
/**
|
|
69
|
-
* This is a pivoted table layout. Each entry becomes a column. Headers are the left most
|
|
70
|
-
* column.
|
|
71
|
-
*/
|
|
72
|
-
Horizontal = "horizontal"
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Options for {@link defineTable}.
|
|
76
|
-
*
|
|
77
|
-
* @category Internal
|
|
78
|
-
*/
|
|
79
|
-
export type ViraTableOptions<Orientation extends ViraTableOrientation = ViraTableOrientation> = PartialWithUndefined<{
|
|
80
|
-
orientation: Orientation;
|
|
81
|
-
hideHeaders: boolean;
|
|
82
|
-
}>;
|
|
83
|
-
/**
|
|
84
|
-
* Accepts headers and entries and lays them out into rows according to the given
|
|
85
|
-
* `options.orientation` (defaulting to vertical). This does not itself create a `<table>` element,
|
|
86
|
-
* but makes it easy to loop over rows to (with `.map()`) to generate rows in a table.
|
|
87
|
-
*
|
|
88
|
-
* @category Table
|
|
89
|
-
*/
|
|
90
|
-
export declare function defineTable<const Headers extends ViraTableHeaders, const Orientation extends ViraTableOrientation = ViraTableOrientation.Vertical>(
|
|
91
|
-
/** The order of these keys determines the order that they render in. */
|
|
92
|
-
headers: Readonly<Headers>, entries: ReadonlyArray<Readonly<ViraTableEntry<Headers>>>, options?: ViraTableOptions<Orientation>): ViraTable<Headers, Orientation>;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Orientation options for {@link ViraTable}.
|
|
3
|
-
*
|
|
4
|
-
* @category Internal
|
|
5
|
-
*/
|
|
6
|
-
export var ViraTableOrientation;
|
|
7
|
-
(function (ViraTableOrientation) {
|
|
8
|
-
/**
|
|
9
|
-
* This is the default table layout. Each entry becomes a new row. Headers are a row at the top
|
|
10
|
-
* of the table.
|
|
11
|
-
*/
|
|
12
|
-
ViraTableOrientation["Vertical"] = "vertical";
|
|
13
|
-
/**
|
|
14
|
-
* This is a pivoted table layout. Each entry becomes a column. Headers are the left most
|
|
15
|
-
* column.
|
|
16
|
-
*/
|
|
17
|
-
ViraTableOrientation["Horizontal"] = "horizontal";
|
|
18
|
-
})(ViraTableOrientation || (ViraTableOrientation = {}));
|
|
19
|
-
/**
|
|
20
|
-
* Accepts headers and entries and lays them out into rows according to the given
|
|
21
|
-
* `options.orientation` (defaulting to vertical). This does not itself create a `<table>` element,
|
|
22
|
-
* but makes it easy to loop over rows to (with `.map()`) to generate rows in a table.
|
|
23
|
-
*
|
|
24
|
-
* @category Table
|
|
25
|
-
*/
|
|
26
|
-
export function defineTable(
|
|
27
|
-
/** The order of these keys determines the order that they render in. */
|
|
28
|
-
headers, entries, options = {}) {
|
|
29
|
-
if (options.orientation === ViraTableOrientation.Horizontal) {
|
|
30
|
-
const rows = headers.map((header) => {
|
|
31
|
-
const headerCellArray = options.hideHeaders
|
|
32
|
-
? []
|
|
33
|
-
: [
|
|
34
|
-
{
|
|
35
|
-
content: header.content ?? header.key,
|
|
36
|
-
key: header.key,
|
|
37
|
-
},
|
|
38
|
-
];
|
|
39
|
-
const cells = entries.map((entry) => {
|
|
40
|
-
return {
|
|
41
|
-
content: entry[header.key],
|
|
42
|
-
key: header.key,
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
return [
|
|
46
|
-
...headerCellArray,
|
|
47
|
-
...cells,
|
|
48
|
-
];
|
|
49
|
-
});
|
|
50
|
-
return {
|
|
51
|
-
headerRow: undefined,
|
|
52
|
-
rows,
|
|
53
|
-
orientation: ViraTableOrientation.Horizontal,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
const headerRow = options.hideHeaders
|
|
58
|
-
? []
|
|
59
|
-
: headers.map((header) => {
|
|
60
|
-
return {
|
|
61
|
-
content: header.content ?? header.key,
|
|
62
|
-
key: header.key,
|
|
63
|
-
};
|
|
64
|
-
});
|
|
65
|
-
const rows = entries.map((entry) => {
|
|
66
|
-
return headers.map((header) => {
|
|
67
|
-
return {
|
|
68
|
-
content: entry[header.key],
|
|
69
|
-
key: header.key,
|
|
70
|
-
};
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
return {
|
|
74
|
-
headerRow,
|
|
75
|
-
rows,
|
|
76
|
-
orientation: ViraTableOrientation.Vertical,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
}
|