vira 26.1.1 → 26.2.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.
@@ -26,13 +26,27 @@ export type ViraTableHeaders = ReadonlyArray<ViraTableKey>;
26
26
  */
27
27
  export type ViraTableEntry<Headers extends ViraTableHeaders | undefined = undefined> = Record<HeaderKey<Headers>, HtmlInterpolation>;
28
28
  /**
29
- * An individual cell in {@link ViraTable}.
29
+ * An individual cell in {@link ViraTableRow}.
30
30
  *
31
31
  * @category Internal
32
32
  */
33
- export type ViraTableCell<Headers extends ViraTableHeaders | undefined = undefined> = {
33
+ export type ViraTableCell<Headers extends ViraTableHeaders | undefined = undefined, Entry extends ViraTableEntry<Headers> | undefined = ViraTableEntry<Headers>> = {
34
34
  content: HtmlInterpolation;
35
35
  key: HeaderKey<Headers>;
36
+ /**
37
+ * The original entry that created this row (in default or vertical table orientation) or column
38
+ * (in horizontal table orientation). This is `undefined` in header cells.
39
+ */
40
+ entry: Entry;
41
+ };
42
+ /**
43
+ * An individual row in {@link ViraTable}.
44
+ *
45
+ * @category Internal
46
+ */
47
+ export type ViraTableRow<Headers extends ViraTableHeaders | undefined = undefined, CellEntry extends ViraTableEntry<Headers> | undefined = ViraTableEntry<Headers> | undefined, RowEntry extends ViraTableEntry<Headers> | undefined = CellEntry> = {
48
+ cells: ViraTableCell<Headers, CellEntry>[];
49
+ entry: RowEntry;
36
50
  };
37
51
  /**
38
52
  * All keys for the given headers.
@@ -45,14 +59,14 @@ export type HeaderKey<Headers extends ViraTableHeaders | undefined = undefined>
45
59
  *
46
60
  * @category Internal
47
61
  */
48
- export type ViraTable<Headers extends ViraTableHeaders | undefined = undefined, Orientation extends ViraTableOrientation = ViraTableOrientation.Vertical> = (Orientation extends ViraTableOrientation.Horizontal ? {
62
+ export type ViraTable<Headers extends ViraTableHeaders | undefined = undefined, Orientation extends ViraTableOrientation = ViraTableOrientation.Vertical, Entry extends ViraTableEntry<Headers> = ViraTableEntry<Headers>> = Orientation extends ViraTableOrientation.Horizontal ? {
49
63
  headerRow: undefined;
50
64
  orientation: Orientation;
65
+ rows: ViraTableRow<Headers, Entry | undefined, undefined>[];
51
66
  } : {
52
- headerRow: ViraTableCell<Headers>[];
67
+ headerRow: ViraTableCell<Headers, undefined>[];
53
68
  orientation: Orientation;
54
- }) & {
55
- rows: ViraTableCell<Headers>[][];
69
+ rows: ViraTableRow<Headers, Entry>[];
56
70
  };
57
71
  /**
58
72
  * Orientation options for {@link ViraTable}.
@@ -61,12 +75,14 @@ export type ViraTable<Headers extends ViraTableHeaders | undefined = undefined,
61
75
  */
62
76
  export declare enum ViraTableOrientation {
63
77
  /**
64
- * This is the default table layout. Each entry becomes a new row. Headers are a row at the top
65
- * of the table.
78
+ * This corresponds to a _vertical_ entry sequence (as you move from entry to entry, you move
79
+ * across the table vertically). This is the default table layout. Each entry becomes a new row.
80
+ * Headers are in a separate row.
66
81
  */
67
82
  Vertical = "vertical",
68
83
  /**
69
- * This is a pivoted table layout. Each entry becomes a column. Headers are the left most
84
+ * This corresponds to a _horizontal_ entry sequence (as you move from entry to entry, you move
85
+ * across the table horizontally). Each entry becomes a column. Headers are the left most
70
86
  * column.
71
87
  */
72
88
  Horizontal = "horizontal"
@@ -87,6 +103,6 @@ export type ViraTableOptions<Orientation extends ViraTableOrientation = ViraTabl
87
103
  *
88
104
  * @category Table
89
105
  */
90
- export declare function defineTable<const Headers extends ViraTableHeaders, const Orientation extends ViraTableOrientation = ViraTableOrientation.Vertical>(
106
+ export declare function defineTable<const Headers extends ViraTableHeaders, Entry extends ViraTableEntry<Headers>, const Orientation extends ViraTableOrientation = ViraTableOrientation.Vertical>(
91
107
  /** 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>;
108
+ headers: Readonly<Headers>, entries: Entry[], options?: ViraTableOptions<Orientation>): ViraTable<Headers, Orientation>;
@@ -6,12 +6,14 @@
6
6
  export var ViraTableOrientation;
7
7
  (function (ViraTableOrientation) {
8
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.
9
+ * This corresponds to a _vertical_ entry sequence (as you move from entry to entry, you move
10
+ * across the table vertically). This is the default table layout. Each entry becomes a new row.
11
+ * Headers are in a separate row.
11
12
  */
12
13
  ViraTableOrientation["Vertical"] = "vertical";
13
14
  /**
14
- * This is a pivoted table layout. Each entry becomes a column. Headers are the left most
15
+ * This corresponds to a _horizontal_ entry sequence (as you move from entry to entry, you move
16
+ * across the table horizontally). Each entry becomes a column. Headers are the left most
15
17
  * column.
16
18
  */
17
19
  ViraTableOrientation["Horizontal"] = "horizontal";
@@ -34,18 +36,24 @@ headers, entries, options = {}) {
34
36
  {
35
37
  content: header.content ?? header.key,
36
38
  key: header.key,
39
+ entry: undefined,
37
40
  },
38
41
  ];
39
42
  const cells = entries.map((entry) => {
40
43
  return {
41
44
  content: entry[header.key],
42
45
  key: header.key,
46
+ entry,
43
47
  };
44
48
  });
45
- return [
49
+ const allCells = [
46
50
  ...headerCellArray,
47
51
  ...cells,
48
52
  ];
53
+ return {
54
+ cells: allCells,
55
+ entry: undefined,
56
+ };
49
57
  });
50
58
  return {
51
59
  headerRow: undefined,
@@ -60,15 +68,20 @@ headers, entries, options = {}) {
60
68
  return {
61
69
  content: header.content ?? header.key,
62
70
  key: header.key,
71
+ entry: undefined,
63
72
  };
64
73
  });
65
74
  const rows = entries.map((entry) => {
66
- return headers.map((header) => {
67
- return {
68
- content: entry[header.key],
69
- key: header.key,
70
- };
71
- });
75
+ return {
76
+ cells: headers.map((header) => {
77
+ return {
78
+ content: entry[header.key],
79
+ key: header.key,
80
+ entry,
81
+ };
82
+ }),
83
+ entry,
84
+ };
72
85
  });
73
86
  return {
74
87
  headerRow,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vira",
3
- "version": "26.1.1",
3
+ "version": "26.2.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.0.0",
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.0",
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.1.1"
70
+ "element-vir": "^26.2.0"
71
71
  },
72
72
  "engines": {
73
73
  "node": ">=22"