vira 25.10.0 → 25.12.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/elements/define-vira-element.d.ts +0 -6
- package/dist/elements/define-vira-element.js +1 -7
- package/dist/elements/index.d.ts +2 -0
- package/dist/elements/index.js +2 -0
- package/dist/elements/pop-up/vira-menu-item.element.js +6 -2
- package/dist/elements/table/define-table.d.ts +48 -0
- package/dist/elements/table/define-table.js +13 -0
- package/dist/elements/table/vira-table.element.d.ts +46 -0
- package/dist/elements/table/vira-table.element.js +118 -0
- package/package.json +6 -6
|
@@ -16,9 +16,3 @@ export type ViraTagName = `${typeof ViraTagNamePrefix}${string}`;
|
|
|
16
16
|
* @category Internal
|
|
17
17
|
*/
|
|
18
18
|
export declare const defineViraElement: <Inputs extends {}>(...errorParams: import("element-vir").DeclarativeElementInputErrorParams<Inputs>) => <const TagName extends `vira-${string}`, State extends {}, EventsInit extends {}, const HostClassKeys extends `${TagName}-${string}` = `${TagName}-`, const CssVarKeys extends `${TagName}-${string}` = `${TagName}-`, const SlotNames extends ReadonlyArray<string> = readonly []>(inputs: import("element-vir").DeclarativeElementInit<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>) => import("element-vir").DeclarativeElementDefinition<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>;
|
|
19
|
-
/**
|
|
20
|
-
* Define a vira element with custom requirements (like the `vira-` element tag prefix).
|
|
21
|
-
*
|
|
22
|
-
* @category Internal
|
|
23
|
-
*/
|
|
24
|
-
export declare const defineViraElementNoInputs: <const TagName extends `vira-${string}`, Inputs extends {}, State extends {}, EventsInit extends {}, const HostClassKeys extends `${TagName}-${string}` = `${TagName}-`, const CssVarKeys extends `${TagName}-${string}` = `${TagName}-`, const SlotNames extends ReadonlyArray<string> = readonly []>(inputs: import("element-vir").DeclarativeElementInit<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>) => import("element-vir").DeclarativeElementDefinition<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>;
|
|
@@ -5,7 +5,7 @@ import { wrapDefineElement } from 'element-vir';
|
|
|
5
5
|
* @category Internal
|
|
6
6
|
*/
|
|
7
7
|
export const ViraTagNamePrefix = `vira-`;
|
|
8
|
-
const { defineElement
|
|
8
|
+
const { defineElement } = wrapDefineElement({
|
|
9
9
|
assertInputs: (inputs) => {
|
|
10
10
|
if (!inputs.tagName.startsWith(ViraTagNamePrefix)) {
|
|
11
11
|
throw new Error(`Tag name should start with '${ViraTagNamePrefix}' but got '${inputs.tagName}'`);
|
|
@@ -18,9 +18,3 @@ const { defineElement, defineElementNoInputs } = wrapDefineElement({
|
|
|
18
18
|
* @category Internal
|
|
19
19
|
*/
|
|
20
20
|
export const defineViraElement = defineElement;
|
|
21
|
-
/**
|
|
22
|
-
* Define a vira element with custom requirements (like the `vira-` element tag prefix).
|
|
23
|
-
*
|
|
24
|
-
* @category Internal
|
|
25
|
-
*/
|
|
26
|
-
export const defineViraElementNoInputs = defineElementNoInputs;
|
package/dist/elements/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export * from './pop-up/vira-menu-trigger.element.js';
|
|
|
6
6
|
export * from './pop-up/vira-menu.element.js';
|
|
7
7
|
export * from './pop-up/vira-pop-up-menu.element.js';
|
|
8
8
|
export * from './pop-up/vira-pop-up-trigger.element.js';
|
|
9
|
+
export * from './table/define-table.js';
|
|
10
|
+
export * from './table/vira-table.element.js';
|
|
9
11
|
export * from './vira-bold-text.element.js';
|
|
10
12
|
export * from './vira-button.element.js';
|
|
11
13
|
export * from './vira-collapsible-wrapper.element.js';
|
package/dist/elements/index.js
CHANGED
|
@@ -6,6 +6,8 @@ export * from './pop-up/vira-menu-trigger.element.js';
|
|
|
6
6
|
export * from './pop-up/vira-menu.element.js';
|
|
7
7
|
export * from './pop-up/vira-pop-up-menu.element.js';
|
|
8
8
|
export * from './pop-up/vira-pop-up-trigger.element.js';
|
|
9
|
+
export * from './table/define-table.js';
|
|
10
|
+
export * from './table/vira-table.element.js';
|
|
9
11
|
export * from './vira-bold-text.element.js';
|
|
10
12
|
export * from './vira-button.element.js';
|
|
11
13
|
export * from './vira-collapsible-wrapper.element.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { css, html, renderIf } from 'element-vir';
|
|
1
|
+
import { classMap, css, html, renderIf } from 'element-vir';
|
|
2
2
|
import { Check24Icon } from '../../icons/icon-svgs/check-24.icon.js';
|
|
3
3
|
import { noUserSelect } from '../../styles/index.js';
|
|
4
4
|
import { defineViraElement } from '../define-vira-element.js';
|
|
@@ -44,10 +44,14 @@ export const ViraMenuItem = defineViraElement()({
|
|
|
44
44
|
margin-right: -2px;
|
|
45
45
|
margin-left: 2px;
|
|
46
46
|
}
|
|
47
|
+
|
|
48
|
+
.include-left-spacing {
|
|
49
|
+
padding-left: 12px;
|
|
50
|
+
}
|
|
47
51
|
`,
|
|
48
52
|
render({ inputs }) {
|
|
49
53
|
return html `
|
|
50
|
-
<div class="item">
|
|
54
|
+
<div class="item ${classMap({ 'include-left-spacing': !!inputs.hideCheckIcon })}">
|
|
51
55
|
${renderIf(!inputs.hideCheckIcon, html `
|
|
52
56
|
<${ViraIcon.assign({ icon: Check24Icon })}></${ViraIcon}>
|
|
53
57
|
`)}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type ArrayElement, type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
+
import { type HtmlInterpolation } from 'element-vir';
|
|
3
|
+
/**
|
|
4
|
+
* An individual cell for {@link ViraTableSetup}.
|
|
5
|
+
*
|
|
6
|
+
* @category Internal
|
|
7
|
+
*/
|
|
8
|
+
export type ViraTableCell<Columns extends ViraTableColumns | undefined = undefined> = undefined extends Columns ? Record<PropertyKey, HtmlInterpolation> : Record<ArrayElement<Exclude<Columns, undefined>>['key'], HtmlInterpolation>;
|
|
9
|
+
/**
|
|
10
|
+
* A column definition for {@link ViraTableSetup}.
|
|
11
|
+
*
|
|
12
|
+
* @category Internal
|
|
13
|
+
*/
|
|
14
|
+
export type ViraTableColumns = ReadonlyArray<Readonly<{
|
|
15
|
+
/** The key that cells must use to set a value for this column. */
|
|
16
|
+
key: PropertyKey;
|
|
17
|
+
/** This will be displayed in the header for this column. */
|
|
18
|
+
label: HtmlInterpolation;
|
|
19
|
+
} & PartialWithUndefined<{
|
|
20
|
+
/** If set to `true`, this column will not be rendered. */
|
|
21
|
+
hide: boolean;
|
|
22
|
+
}>>>;
|
|
23
|
+
/**
|
|
24
|
+
* An individual row in {@link ViraTableSetup}.
|
|
25
|
+
*
|
|
26
|
+
* @category Internal
|
|
27
|
+
*/
|
|
28
|
+
export type ViraTableRow<Columns extends ViraTableColumns | undefined = undefined> = {
|
|
29
|
+
value: ViraTableCell<Columns>;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Table information input for `ViraTable`.
|
|
33
|
+
*
|
|
34
|
+
* @category Internal
|
|
35
|
+
*/
|
|
36
|
+
export type ViraTableSetup = Readonly<{
|
|
37
|
+
/** The order of these columns determines the order that they render in. */
|
|
38
|
+
columns: ViraTableColumns;
|
|
39
|
+
rows: ReadonlyArray<Readonly<ViraTableRow>>;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Create a type-safe {@link ViraTableSetup} object to be used with the `ViraTable` element.
|
|
43
|
+
*
|
|
44
|
+
* @category Internal
|
|
45
|
+
*/
|
|
46
|
+
export declare function createTable<const Columns extends ViraTableColumns>(
|
|
47
|
+
/** The order of these columns determines the order that they render in. */
|
|
48
|
+
columns: Readonly<Columns>, rows: ReadonlyArray<Readonly<ViraTableRow<Columns>>>): ViraTableSetup;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a type-safe {@link ViraTableSetup} object to be used with the `ViraTable` element.
|
|
3
|
+
*
|
|
4
|
+
* @category Internal
|
|
5
|
+
*/
|
|
6
|
+
export function createTable(
|
|
7
|
+
/** The order of these columns determines the order that they render in. */
|
|
8
|
+
columns, rows) {
|
|
9
|
+
return {
|
|
10
|
+
columns,
|
|
11
|
+
rows,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
+
import { type AttributeValues, type CSSResult } from 'element-vir';
|
|
3
|
+
import { type ViraTableSetup } from './define-table.js';
|
|
4
|
+
/**
|
|
5
|
+
* Element tagnames that have passthroughs setup for them in {@link ViraTable}.
|
|
6
|
+
*
|
|
7
|
+
* @category Internal
|
|
8
|
+
*/
|
|
9
|
+
export type ViraTableElementsForPassthrough = 'table' | 'tr' | 'th' | 'td' | 'tbody' | 'thead';
|
|
10
|
+
/**
|
|
11
|
+
* A flexible table element with automatic header pinning. Use {@link createTable} to create a
|
|
12
|
+
* type-safe table input.
|
|
13
|
+
*
|
|
14
|
+
* @category Elements
|
|
15
|
+
*/
|
|
16
|
+
export declare const ViraTable: import("element-vir").DeclarativeElementDefinition<"vira-table", Readonly<{
|
|
17
|
+
/**
|
|
18
|
+
* The table information.
|
|
19
|
+
*
|
|
20
|
+
* Use {@link createTable} to form a type-safe value for this.
|
|
21
|
+
*/
|
|
22
|
+
table: ViraTableSetup;
|
|
23
|
+
} & PartialWithUndefined<{
|
|
24
|
+
/**
|
|
25
|
+
* Block the sticky table header.
|
|
26
|
+
*
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
preventStickyHeader: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Hide header row entirely.
|
|
32
|
+
*
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
hideHeaderRow: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Pixel value of the header row sticky offset.
|
|
38
|
+
*
|
|
39
|
+
* @default 0
|
|
40
|
+
*/
|
|
41
|
+
stickyOffset: number;
|
|
42
|
+
/** Attributes that will be applied directly to the inner elements. */
|
|
43
|
+
attributePassthrough: Readonly<PartialWithUndefined<Record<ViraTableElementsForPassthrough, AttributeValues>>>;
|
|
44
|
+
/** Styles that will be applied directly to the inner elements. */
|
|
45
|
+
stylePassthrough: Readonly<PartialWithUndefined<Record<ViraTableElementsForPassthrough, CSSResult>>>;
|
|
46
|
+
}>>, {}, {}, "vira-table-", "vira-table-", readonly []>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { attributes, css, html, ifDefined, nothing, } from 'element-vir';
|
|
2
|
+
import { defineViraElement } from '../define-vira-element.js';
|
|
3
|
+
/**
|
|
4
|
+
* A flexible table element with automatic header pinning. Use {@link createTable} to create a
|
|
5
|
+
* type-safe table input.
|
|
6
|
+
*
|
|
7
|
+
* @category Elements
|
|
8
|
+
*/
|
|
9
|
+
export const ViraTable = defineViraElement()({
|
|
10
|
+
tagName: 'vira-table',
|
|
11
|
+
styles: css `
|
|
12
|
+
:host {
|
|
13
|
+
background-color: white;
|
|
14
|
+
display: block;
|
|
15
|
+
position: relative;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
table,
|
|
19
|
+
thead {
|
|
20
|
+
background-color: inherit;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
table {
|
|
24
|
+
border-collapse: collapse;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
thead {
|
|
28
|
+
z-index: 10;
|
|
29
|
+
/* Note that important thead styles are also directly attached to the element. */
|
|
30
|
+
}
|
|
31
|
+
`,
|
|
32
|
+
render({ inputs }) {
|
|
33
|
+
const rows = inputs.table.rows.map((row) => {
|
|
34
|
+
const cells = inputs.table.columns.map((column) => {
|
|
35
|
+
return html `
|
|
36
|
+
<td
|
|
37
|
+
${inputs.attributePassthrough?.td
|
|
38
|
+
? attributes(inputs.attributePassthrough.td)
|
|
39
|
+
: nothing}
|
|
40
|
+
style=${ifDefined(inputs.stylePassthrough?.td)}
|
|
41
|
+
>
|
|
42
|
+
${row.value[column.key]}
|
|
43
|
+
</td>
|
|
44
|
+
`;
|
|
45
|
+
});
|
|
46
|
+
return html `
|
|
47
|
+
<tr
|
|
48
|
+
${inputs.attributePassthrough?.tr
|
|
49
|
+
? attributes(inputs.attributePassthrough.tr)
|
|
50
|
+
: nothing}
|
|
51
|
+
style=${ifDefined(inputs.stylePassthrough?.tr)}
|
|
52
|
+
>
|
|
53
|
+
${cells}
|
|
54
|
+
</tr>
|
|
55
|
+
`;
|
|
56
|
+
});
|
|
57
|
+
const headerCells = inputs.hideHeaderRow
|
|
58
|
+
? undefined
|
|
59
|
+
: inputs.table.columns.map((column) => {
|
|
60
|
+
return html `
|
|
61
|
+
<th
|
|
62
|
+
${inputs.attributePassthrough?.th
|
|
63
|
+
? attributes(inputs.attributePassthrough.th)
|
|
64
|
+
: nothing}
|
|
65
|
+
style=${ifDefined(inputs.stylePassthrough?.th)}
|
|
66
|
+
>
|
|
67
|
+
${column.label}
|
|
68
|
+
</th>
|
|
69
|
+
`;
|
|
70
|
+
});
|
|
71
|
+
const headerRow = headerCells
|
|
72
|
+
? html `
|
|
73
|
+
<tr
|
|
74
|
+
${inputs.attributePassthrough?.tr
|
|
75
|
+
? attributes(inputs.attributePassthrough.tr)
|
|
76
|
+
: nothing}
|
|
77
|
+
style=${ifDefined(inputs.stylePassthrough?.tr)}
|
|
78
|
+
>
|
|
79
|
+
${headerCells}
|
|
80
|
+
</tr>
|
|
81
|
+
`
|
|
82
|
+
: nothing;
|
|
83
|
+
const theadStyles = css `
|
|
84
|
+
${inputs.stylePassthrough?.thead || css ``}
|
|
85
|
+
top: ${inputs.stickyOffset || 0}px;
|
|
86
|
+
${inputs.preventStickyHeader || inputs.hideHeaderRow
|
|
87
|
+
? css ``
|
|
88
|
+
: css `
|
|
89
|
+
position: sticky;
|
|
90
|
+
`}
|
|
91
|
+
`;
|
|
92
|
+
return html `
|
|
93
|
+
<table
|
|
94
|
+
${inputs.attributePassthrough?.table
|
|
95
|
+
? attributes(inputs.attributePassthrough.table)
|
|
96
|
+
: nothing}
|
|
97
|
+
style=${ifDefined(inputs.stylePassthrough?.table)}
|
|
98
|
+
>
|
|
99
|
+
<thead
|
|
100
|
+
${inputs.attributePassthrough?.thead
|
|
101
|
+
? attributes(inputs.attributePassthrough.thead)
|
|
102
|
+
: nothing}
|
|
103
|
+
style=${theadStyles}
|
|
104
|
+
>
|
|
105
|
+
${headerRow}
|
|
106
|
+
</thead>
|
|
107
|
+
<tbody
|
|
108
|
+
${inputs.attributePassthrough?.tbody
|
|
109
|
+
? attributes(inputs.attributePassthrough.tbody)
|
|
110
|
+
: nothing}
|
|
111
|
+
style=${ifDefined(inputs.stylePassthrough?.tbody)}
|
|
112
|
+
>
|
|
113
|
+
${rows}
|
|
114
|
+
</tbody>
|
|
115
|
+
</table>
|
|
116
|
+
`;
|
|
117
|
+
},
|
|
118
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vira",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.12.0",
|
|
4
4
|
"description": "A simple and highly versatile design system using element-vir.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"design",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"test:docs": "virmator docs check"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@augment-vir/assert": "^31.21.
|
|
42
|
-
"@augment-vir/common": "^31.21.
|
|
43
|
-
"@augment-vir/web": "^31.21.
|
|
41
|
+
"@augment-vir/assert": "^31.21.1",
|
|
42
|
+
"@augment-vir/common": "^31.21.1",
|
|
43
|
+
"@augment-vir/web": "^31.21.1",
|
|
44
44
|
"colorjs.io": "^0.5.2",
|
|
45
45
|
"date-vir": "^7.3.1",
|
|
46
46
|
"device-navigation": "^4.5.5",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"typed-event-target": "^4.1.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@augment-vir/test": "^31.21.
|
|
55
|
+
"@augment-vir/test": "^31.21.1",
|
|
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",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"vite-tsconfig-paths": "^5.1.4"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"element-vir": "^25.
|
|
70
|
+
"element-vir": "^25.12.0"
|
|
71
71
|
},
|
|
72
72
|
"engines": {
|
|
73
73
|
"node": ">=22"
|