vira 26.2.0 → 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.
@@ -1,2 +1 @@
1
- export * from './define-table.js';
2
1
  export * from './pop-up-manager.js';
@@ -1,2 +1 @@
1
- export * from './define-table.js';
2
1
  export * from './pop-up-manager.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vira",
3
- "version": "26.2.0",
3
+ "version": "26.3.0",
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.2.0"
70
+ "element-vir": "^26.3.0"
71
71
  },
72
72
  "engines": {
73
73
  "node": ">=22"
@@ -1,108 +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 ViraTableRow}.
30
- *
31
- * @category Internal
32
- */
33
- export type ViraTableCell<Headers extends ViraTableHeaders | undefined = undefined, Entry extends ViraTableEntry<Headers> | undefined = ViraTableEntry<Headers>> = {
34
- content: HtmlInterpolation;
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;
50
- };
51
- /**
52
- * All keys for the given headers.
53
- *
54
- * @category Internal
55
- */
56
- export type HeaderKey<Headers extends ViraTableHeaders | undefined = undefined> = undefined extends Headers ? string | number : ArrayElement<Exclude<Headers, undefined>>['key'];
57
- /**
58
- * Table information that can easily be mapped into a `<table>` element.
59
- *
60
- * @category Internal
61
- */
62
- export type ViraTable<Headers extends ViraTableHeaders | undefined = undefined, Orientation extends ViraTableOrientation = ViraTableOrientation.Vertical, Entry extends ViraTableEntry<Headers> = ViraTableEntry<Headers>> = Orientation extends ViraTableOrientation.Horizontal ? {
63
- headerRow: undefined;
64
- orientation: Orientation;
65
- rows: ViraTableRow<Headers, Entry | undefined, undefined>[];
66
- } : {
67
- headerRow: ViraTableCell<Headers, undefined>[];
68
- orientation: Orientation;
69
- rows: ViraTableRow<Headers, Entry>[];
70
- };
71
- /**
72
- * Orientation options for {@link ViraTable}.
73
- *
74
- * @category Internal
75
- */
76
- export declare enum ViraTableOrientation {
77
- /**
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.
81
- */
82
- Vertical = "vertical",
83
- /**
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
86
- * column.
87
- */
88
- Horizontal = "horizontal"
89
- }
90
- /**
91
- * Options for {@link defineTable}.
92
- *
93
- * @category Internal
94
- */
95
- export type ViraTableOptions<Orientation extends ViraTableOrientation = ViraTableOrientation> = PartialWithUndefined<{
96
- orientation: Orientation;
97
- hideHeaders: boolean;
98
- }>;
99
- /**
100
- * Accepts headers and entries and lays them out into rows according to the given
101
- * `options.orientation` (defaulting to vertical). This does not itself create a `<table>` element,
102
- * but makes it easy to loop over rows to (with `.map()`) to generate rows in a table.
103
- *
104
- * @category Table
105
- */
106
- export declare function defineTable<const Headers extends ViraTableHeaders, Entry extends ViraTableEntry<Headers>, const Orientation extends ViraTableOrientation = ViraTableOrientation.Vertical>(
107
- /** The order of these keys determines the order that they render in. */
108
- headers: Readonly<Headers>, entries: Entry[], options?: ViraTableOptions<Orientation>): ViraTable<Headers, Orientation>;
@@ -1,92 +0,0 @@
1
- /**
2
- * Orientation options for {@link ViraTable}.
3
- *
4
- * @category Internal
5
- */
6
- export var ViraTableOrientation;
7
- (function (ViraTableOrientation) {
8
- /**
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.
12
- */
13
- ViraTableOrientation["Vertical"] = "vertical";
14
- /**
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
17
- * column.
18
- */
19
- ViraTableOrientation["Horizontal"] = "horizontal";
20
- })(ViraTableOrientation || (ViraTableOrientation = {}));
21
- /**
22
- * Accepts headers and entries and lays them out into rows according to the given
23
- * `options.orientation` (defaulting to vertical). This does not itself create a `<table>` element,
24
- * but makes it easy to loop over rows to (with `.map()`) to generate rows in a table.
25
- *
26
- * @category Table
27
- */
28
- export function defineTable(
29
- /** The order of these keys determines the order that they render in. */
30
- headers, entries, options = {}) {
31
- if (options.orientation === ViraTableOrientation.Horizontal) {
32
- const rows = headers.map((header) => {
33
- const headerCellArray = options.hideHeaders
34
- ? []
35
- : [
36
- {
37
- content: header.content ?? header.key,
38
- key: header.key,
39
- entry: undefined,
40
- },
41
- ];
42
- const cells = entries.map((entry) => {
43
- return {
44
- content: entry[header.key],
45
- key: header.key,
46
- entry,
47
- };
48
- });
49
- const allCells = [
50
- ...headerCellArray,
51
- ...cells,
52
- ];
53
- return {
54
- cells: allCells,
55
- entry: undefined,
56
- };
57
- });
58
- return {
59
- headerRow: undefined,
60
- rows,
61
- orientation: ViraTableOrientation.Horizontal,
62
- };
63
- }
64
- else {
65
- const headerRow = options.hideHeaders
66
- ? []
67
- : headers.map((header) => {
68
- return {
69
- content: header.content ?? header.key,
70
- key: header.key,
71
- entry: undefined,
72
- };
73
- });
74
- const rows = entries.map((entry) => {
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
- };
85
- });
86
- return {
87
- headerRow,
88
- rows,
89
- orientation: ViraTableOrientation.Vertical,
90
- };
91
- }
92
- }