@jack-henry/jh-elements 2.0.0-beta.10
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/LICENSE +201 -0
- package/NOTICE +26 -0
- package/README.md +13 -0
- package/components/badge/badge.js +73 -0
- package/components/button/button.js +953 -0
- package/components/card/card.js +343 -0
- package/components/checkbox/checkbox.js +601 -0
- package/components/checkbox-group/checkbox-group.js +241 -0
- package/components/divider/divider.js +91 -0
- package/components/icon/icon.js +96 -0
- package/components/input/input.js +1247 -0
- package/components/input-email/input-email.js +18 -0
- package/components/input-password/input-password.js +153 -0
- package/components/input-search/input-search.js +41 -0
- package/components/input-telephone/input-telephone.js +18 -0
- package/components/input-textarea/input-textarea.js +379 -0
- package/components/input-url/input-url.js +31 -0
- package/components/list-group/list-group.js +103 -0
- package/components/list-item/list-item.js +350 -0
- package/components/menu/menu.js +60 -0
- package/components/notification/notification.js +327 -0
- package/components/progress/progress.js +417 -0
- package/components/radio/radio.js +422 -0
- package/components/radio-group/radio-group.js +400 -0
- package/components/switch/switch.js +315 -0
- package/components/table/table.js +367 -0
- package/components/table-data-cell/table-data-cell.js +107 -0
- package/components/table-header-cell/table-header-cell.js +321 -0
- package/components/table-row/table-row.js +52 -0
- package/components/tag/tag.js +422 -0
- package/components/tag-group/tag-group.js +57 -0
- package/components/toast/toast.js +172 -0
- package/components/toast-controller/toast-controller.js +122 -0
- package/components/tooltip/tooltip.js +498 -0
- package/custom-elements.json +6892 -0
- package/index.d.ts +69 -0
- package/jsconfig.json +9 -0
- package/package.json +52 -0
- package/utils/themeProvider.js +32 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2025 Jack Henry
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
import { LitElement, css, html } from 'lit';
|
|
6
|
+
import '@jack-henry/jh-icons/icons-wc/icon-arrow-up-arrow-down.js';
|
|
7
|
+
import '@jack-henry/jh-icons/icons-wc/icon-arrow-up-small.js';
|
|
8
|
+
import '@jack-henry/jh-icons/icons-wc/icon-arrow-down-small.js';
|
|
9
|
+
|
|
10
|
+
let id = 0;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Table Header Cell
|
|
14
|
+
*
|
|
15
|
+
* @cssprop --jh-table-header-cell-color-text-enabled - The header cell text color when enabled. Defaults to `--jh-color-content-primary-enabled`.
|
|
16
|
+
* @cssprop --jh-table-header-cell-color-text-hover - The sortable header cell text color when hovered. Defaults to `--jh-color-content-primary-hover`.
|
|
17
|
+
* @cssprop --jh-table-header-cell-color-text-focus - The sortable header cell text color when focused. Defaults to `--jh-color-content-primary-hover`.
|
|
18
|
+
* @cssprop --jh-table-header-cell-color-text-active - The sortable header cell text color when active. Defaults to `--jh-color-content-primary-active`.
|
|
19
|
+
* @cssprop --jh-table-header-cell-color-text-selected - The sortable header cell text color when selected. Defaults to `--jh-color-content-primary-enabled`.
|
|
20
|
+
* @cssprop --jh-table-header-cell-color-background-enabled - The header cell background color when enabled. Defaults to `--jh-color-container-primary-enabled`.
|
|
21
|
+
* @cssprop --jh-table-header-cell-color-background-hover - The sortable header cell background color when hovered. Defaults to `--jh-color-container-primary-hover`.
|
|
22
|
+
* @cssprop --jh-table-header-cell-color-background-focus - The sortable header cell background color when focused. Defaults to `--jh-color-container-primary-hover`.
|
|
23
|
+
* @cssprop --jh-table-header-cell-color-background-active - The sortable header cell background color when active. Defaults to `--jh-color-container-primary-active`.
|
|
24
|
+
* @cssprop --jh-table-header-cell-color-background-selected - The sortable header cell background color when selected. Defaults to `--jh-color-container-primary-selected`.
|
|
25
|
+
* @cssprop --jh-table-header-cell-color-border-bottom-enabled - The header cell border bottom color when enabled. Defaults to `--jh-border-decorative-color`.
|
|
26
|
+
* @cssprop --jh-table-header-cell-border-bottom-width - The header cell border bottom width. Defaults to `--jh-border-decorative-width`.
|
|
27
|
+
* @cssprop --jh-table-header-cell-border-bottom-style - The header cell border bottom style. Defaults to `--jh-border-decorative-style`.
|
|
28
|
+
* @cssprop --jh-table-header-cell-color-border-top-enabled - The header cell border top color when enabled. Defaults to `--jh-border-decorative-color`.
|
|
29
|
+
* @cssprop --jh-table-header-cell-border-top-width - The header cell border top width. Defaults to `--jh-border-decorative-width`.
|
|
30
|
+
* @cssprop --jh-table-header-cell-border-top-style - The header cell border top style. Defaults to `--jh-border-decorative-style`.
|
|
31
|
+
* @cssprop --jh-table-header-cell-color-border-left-enabled - The header cell border left color when enabled. Defaults to `transparent`.
|
|
32
|
+
* @cssprop --jh-table-header-cell-border-left-width - The header cell border left width. Defaults to `--jh-border-decorative-width`.
|
|
33
|
+
* @cssprop --jh-table-header-cell-border-left-style - The header cell border left style. Defaults to `--jh-border-decorative-style`.
|
|
34
|
+
* @cssprop --jh-table-header-cell-color-border-right-enabled - The header cell border right color when enabled. Defaults to `transparent`.
|
|
35
|
+
* @cssprop --jh-table-header-cell-border-right-width - The header cell border right width. Defaults to `--jh-border-decorative-width`.
|
|
36
|
+
* @cssprop --jh-table-header-cell-border-right-style - The header cell border right style. Defaults to `--jh-border-decorative-style`.
|
|
37
|
+
* @cssprop --jh-table-header-cell-icon-color-fill-enabled - The sortable header cell icon color when enabled. Defaults to `--jh-color-content-brand-enabled`.
|
|
38
|
+
* @cssprop --jh-table-header-cell-icon-color-fill-hover - The sortable header cell icon color when hovered. Defaults to `--jh-color-content-brand-hover`.
|
|
39
|
+
* @cssprop --jh-table-header-cell-icon-color-fill-focus - The sortable header cell icon color when focused. Defaults to `--jh-color-content-brand-hover`.
|
|
40
|
+
* @cssprop --jh-table-header-cell-icon-color-fill-active - The sortable header cell icon color when active. Defaults to `--jh-color-content-brand-active`.
|
|
41
|
+
* @cssprop --jh-table-header-cell-icon-color-fill-selected - The sortable header cell icon color when selected. Defaults to `--jh-color-content-brand-enabled`.
|
|
42
|
+
* @cssprop --jh-table-header-cell-color-border-bottom-hover - The sortable header cell border bottom color when hovered. Defaults to `--jh-border-decorative-color`.
|
|
43
|
+
* @cssprop --jh-table-header-cell-color-border-bottom-focus - The sortable header cell border bottom color when focused. Defaults to `--jh-border-decorative-color`.
|
|
44
|
+
* @cssprop --jh-table-header-cell-color-border-bottom-active - The sortable header cell border bottom color when active. Defaults to `--jh-border-decorative-color`.
|
|
45
|
+
* @cssprop --jh-table-header-cell-color-border-bottom-selected - The sortable header cell border bottom color when selected. Defaults to `--jh-border-decorative-color`.
|
|
46
|
+
* @cssprop --jh-table-header-cell-color-border-top-hover - The sortable header cell border top color when hovered. Defaults to `--jh-border-decorative-color`.
|
|
47
|
+
* @cssprop --jh-table-header-cell-color-border-top-focus - The sortable header cell border top color when focused. Defaults to `--jh-border-decorative-color`.
|
|
48
|
+
* @cssprop --jh-table-header-cell-color-border-top-active - The sortable header cell border top color when active. Defaults to `--jh-border-decorative-color`.
|
|
49
|
+
* @cssprop --jh-table-header-cell-color-border-top-selected - The sortable header cell border top color when selected. Defaults to `--jh-border-decorative-color`.
|
|
50
|
+
* @cssprop --jh-table-header-cell-color-border-right-hover - The sortable header cell border right color when hovered. Defaults to `transparent`.
|
|
51
|
+
* @cssprop --jh-table-header-cell-color-border-right-focus - The sortable header cell border right color when focused. Defaults to `transparent`.
|
|
52
|
+
* @cssprop --jh-table-header-cell-color-border-right-active - The sortable header cell border right color when active. Defaults to `transparent`.
|
|
53
|
+
* @cssprop --jh-table-header-cell-color-border-right-selected - The sortable header cell border right color when selected. Defaults to `transparent`.
|
|
54
|
+
* @cssprop --jh-table-header-cell-color-border-left-hover - The sortable header cell border left color when hovered. Defaults to `transparent`.
|
|
55
|
+
* @cssprop --jh-table-header-cell-color-border-left-focus - The sortable header cell border left color when focused. Defaults to `transparent`.
|
|
56
|
+
* @cssprop --jh-table-header-cell-color-border-left-active - The sortable header cell border left color when active. Defaults to `transparent`.
|
|
57
|
+
* @cssprop --jh-table-header-cell-color-border-left-selected - The sortable header cell border left color when selected. Defaults to `transparent`.
|
|
58
|
+
* @cssprop --jh-table-header-cell-space-padding-top - The header cell padding top. Defaults to `--jh-dimension-400`.
|
|
59
|
+
* @cssprop --jh-table-header-cell-space-padding-right - The header cell padding right. Defaults to `--jh-dimension-400`.
|
|
60
|
+
* @cssprop --jh-table-header-cell-space-padding-bottom - The header cell padding bottom. Defaults to `--jh-dimension-400`.
|
|
61
|
+
* @cssprop --jh-table-header-cell-space-padding-left - The header cell padding left. Defaults to `--jh-dimension-400`.
|
|
62
|
+
* @cssprop --jh-table-header-cell-color-focus - The header cell outline color when it receives keyboard focus. Defaults to `--jh-border-color-focus`.
|
|
63
|
+
*
|
|
64
|
+
* @slot jh-table-sorted-ascending - Use to insert a custom icon for ascending sort.
|
|
65
|
+
* @slot jh-table-sorted-descending - Use to insert a custom icon for descending sort.
|
|
66
|
+
* @slot jh-table-sorted-none - Use to insert a custom icon for no sort.
|
|
67
|
+
* @slot default - Use to insert table header text.
|
|
68
|
+
*
|
|
69
|
+
* @event jh-sort - Dispatched when a sortable header cell is activated. Event payload includes the column, sorted state, and id of the header cell and can be accessed via `e.detail.column`, `e.detail.sorted`, and ` e.detail.id`.
|
|
70
|
+
* @customElement jh-table-header-cell
|
|
71
|
+
*/
|
|
72
|
+
export class JhTableHeaderCell extends LitElement {
|
|
73
|
+
|
|
74
|
+
/** @type {ElementInternals} */
|
|
75
|
+
#internals;
|
|
76
|
+
|
|
77
|
+
static get styles() {
|
|
78
|
+
return css`
|
|
79
|
+
:host {
|
|
80
|
+
border-top-color: var(--jh-table-header-cell-color-border-top-enabled, var(--jh-border-decorative-color));
|
|
81
|
+
border-top-width: var(--jh-table-header-cell-border-top-width, var(--jh-border-decorative-width));
|
|
82
|
+
border-top-style: var(--jh-table-header-cell-border-top-style, var(--jh-border-decorative-style));
|
|
83
|
+
border-right-color: var(--jh-table-header-cell-color-border-right-enabled, transparent);
|
|
84
|
+
border-right-width: var(--jh-table-header-cell-border-right-width, var(--jh-border-decorative-width));
|
|
85
|
+
border-right-style: var(--jh-table-header-cell-border-right-style, var(--jh-border-decorative-style));
|
|
86
|
+
border-left-color: var(--jh-table-header-cell-color-border-left-enabled, transparent);
|
|
87
|
+
border-left-width: var(--jh-table-header-cell-border-left-width, var(--jh-border-decorative-width));
|
|
88
|
+
border-left-style: var(--jh-table-header-cell-border-left-style, var(--jh-border-decorative-style));
|
|
89
|
+
border-bottom-color: var(--jh-table-header-cell-color-border-bottom-enabled, var(--jh-border-decorative-color));
|
|
90
|
+
border-bottom-width: var(--jh-table-header-cell-border-bottom-width, var(--jh-border-decorative-width));
|
|
91
|
+
border-bottom-style: var(--jh-table-header-cell-border-bottom-style, var(--jh-border-decorative-style));
|
|
92
|
+
color: var(--jh-table-header-cell-color-text-enabled, var(--jh-color-content-primary-enabled));
|
|
93
|
+
background-color: var(--jh-table-header-cell-color-background-enabled, var(--jh-color-container-primary-enabled));
|
|
94
|
+
line-height: var(--jh-font-body-bold-1-line-height);
|
|
95
|
+
font-weight: var(--jh-font-body-bold-1-font-weight);
|
|
96
|
+
font-size: var(--jh-font-body-bold-1-font-size);
|
|
97
|
+
font-family: var(--jh-font-body-bold-1-font-family);
|
|
98
|
+
--jh-icon-color-fill: var(--jh-table-header-cell-icon-color-fill-enabled, var(--jh-color-content-brand-enabled));
|
|
99
|
+
vertical-align: var(--vertical-align, top);
|
|
100
|
+
display: table-cell;
|
|
101
|
+
box-sizing: border-box;
|
|
102
|
+
width: 100%;
|
|
103
|
+
}
|
|
104
|
+
:host([sortable]:hover) {
|
|
105
|
+
border-bottom-color: var(--jh-table-header-cell-color-border-bottom-hover, var(--jh-border-decorative-color));
|
|
106
|
+
border-top-color: var(--jh-table-header-cell-color-border-top-hover, var(--jh-border-decorative-color));
|
|
107
|
+
border-right-color: var(--jh-table-header-cell-color-border-right-hover, transparent);
|
|
108
|
+
border-left-color: var(--jh-table-header-cell-color-border-left-hover, transparent);
|
|
109
|
+
color: var(--jh-table-header-cell-color-text-hover, var(--jh-color-content-primary-hover));
|
|
110
|
+
background-color: var(--jh-table-header-cell-color-background-hover, var(--jh-color-container-primary-hover));
|
|
111
|
+
--jh-icon-color-fill: var(--jh-table-header-cell-icon-color-fill-hover, var(--jh-color-content-brand-hover));
|
|
112
|
+
}
|
|
113
|
+
:host([sortable]:focus-visible) {
|
|
114
|
+
border-bottom-color: var(--jh-table-header-cell-color-border-bottom-focus, var(--jh-border-decorative-color));
|
|
115
|
+
border-top-color: var(--jh-table-header-cell-color-border-top-focus, var(--jh-border-decorative-color));
|
|
116
|
+
border-right-color: var(--jh-table-header-cell-color-border-right-focus, transparent);
|
|
117
|
+
border-left-color: var(--jh-table-header-cell-color-border-left-focus, transparent);
|
|
118
|
+
color: var(--jh-table-header-cell-color-text-focus, var(--jh-color-content-primary-hover));
|
|
119
|
+
background-color: var(--jh-table-header-cell-color-background-focus, var(--jh-color-container-primary-hover));
|
|
120
|
+
--jh-icon-color-fill: var(--jh-table-header-cell-icon-color-fill-focus, var(--jh-color-content-brand-hover));
|
|
121
|
+
outline-color: var(--jh-table-header-cell-color-focus, var(--jh-border-focus-color));
|
|
122
|
+
outline-width: var(--jh-border-focus-width);
|
|
123
|
+
outline-style: var(--jh-border-focus-style);
|
|
124
|
+
outline-offset: -2px;
|
|
125
|
+
}
|
|
126
|
+
:host([sortable]:active) {
|
|
127
|
+
border-bottom-color: var(--jh-table-header-cell-color-border-bottom-active, var(--jh-border-decorative-color));
|
|
128
|
+
border-top-color: var(--jh-table-header-cell-color-border-top-active, var(--jh-border-decorative-color));
|
|
129
|
+
border-right-color: var(--jh-table-header-cell-color-border-right-active, transparent);
|
|
130
|
+
border-left-color: var(--jh-table-header-cell-color-border-left-active, transparent);
|
|
131
|
+
color: var(--jh-table-header-cell-color-text-active, var(--jh-color-content-primary-active));
|
|
132
|
+
background-color: var(--jh-table-header-cell-color-background-active, var(--jh-color-container-primary-active));
|
|
133
|
+
--jh-icon-color-fill: var(--jh-table-header-cell-icon-color-fill-active, var(--jh-color-content-brand-active));
|
|
134
|
+
}
|
|
135
|
+
:host([sortable][sorted="ascending"]),
|
|
136
|
+
:host([sortable][sorted="descending"]) {
|
|
137
|
+
border-bottom-color: var(--jh-table-header-cell-color-border-bottom-selected, var(--jh-border-decorative-color));
|
|
138
|
+
border-top-color: var(--jh-table-header-cell-color-border-top-selected, var(--jh-border-decorative-color));
|
|
139
|
+
border-right-color: var(--jh-table-header-cell-color-border-right-selected, transparent);
|
|
140
|
+
border-left-color: var(--jh-table-header-cell-color-border-left-selected, transparent);
|
|
141
|
+
color: var(--jh-table-header-cell-color-text-selected, var(--jh-color-content-primary-enabled));
|
|
142
|
+
background-color: var(--jh-table-header-cell-color-background-selected, var(--jh-color-container-primary-selected));
|
|
143
|
+
--jh-icon-color-fill: var(--jh-table-header-cell-icon-color-fill-selected, var(--jh-color-content-brand-enabled));
|
|
144
|
+
}
|
|
145
|
+
button {
|
|
146
|
+
all: unset;
|
|
147
|
+
cursor: pointer;
|
|
148
|
+
}
|
|
149
|
+
.sortable-header {
|
|
150
|
+
gap: var(--jh-dimension-200);
|
|
151
|
+
display: flex;
|
|
152
|
+
flex-direction: row;
|
|
153
|
+
box-sizing: border-box;
|
|
154
|
+
width: 100%;
|
|
155
|
+
height: 100%;
|
|
156
|
+
justify-content: space-between;
|
|
157
|
+
}
|
|
158
|
+
.fixed-header,
|
|
159
|
+
.sortable-header {
|
|
160
|
+
padding-top: var(--jh-table-header-cell-space-padding-top, var(--jh-dimension-400));
|
|
161
|
+
padding-right: var(--jh-table-header-cell-space-padding-right, var(--jh-dimension-400));
|
|
162
|
+
padding-bottom: var(--jh-table-header-cell-space-padding-bottom, var(--jh-dimension-400));
|
|
163
|
+
padding-left: var(--jh-table-header-cell-space-padding-left, var(--jh-dimension-400));
|
|
164
|
+
}
|
|
165
|
+
.header-text {
|
|
166
|
+
align-self: var(--flex-vertical-align, flex-start);
|
|
167
|
+
display: block;
|
|
168
|
+
width: 100%;
|
|
169
|
+
}
|
|
170
|
+
button:focus-visible {
|
|
171
|
+
outline: none;
|
|
172
|
+
}
|
|
173
|
+
:host([horizontal-align="left"]) .header-text,
|
|
174
|
+
:host([horizontal-align="left"]) .fixed-header {
|
|
175
|
+
text-align: left;
|
|
176
|
+
}
|
|
177
|
+
:host([horizontal-align="center"]) .header-text,
|
|
178
|
+
:host([horizontal-align="center"]) .fixed-header {
|
|
179
|
+
text-align: center;
|
|
180
|
+
}
|
|
181
|
+
:host([horizontal-align="right"]) .header-text,
|
|
182
|
+
:host([horizontal-align="right"]) .fixed-header {
|
|
183
|
+
text-align: right;
|
|
184
|
+
}
|
|
185
|
+
slot[name^='jh-table-sorted-'] *, slot[name^='jh-table-sorted-']::slotted(*) {
|
|
186
|
+
flex: 0 0 auto;
|
|
187
|
+
}
|
|
188
|
+
`;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
static get properties() {
|
|
192
|
+
return {
|
|
193
|
+
horizontalAlign: {
|
|
194
|
+
type: String,
|
|
195
|
+
reflect: true,
|
|
196
|
+
attribute: 'horizontal-align'
|
|
197
|
+
},
|
|
198
|
+
sortable: {
|
|
199
|
+
type: Boolean,
|
|
200
|
+
reflect: true
|
|
201
|
+
},
|
|
202
|
+
sorted: {
|
|
203
|
+
type: String,
|
|
204
|
+
reflect: true
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
constructor() {
|
|
210
|
+
super();
|
|
211
|
+
this.#internals = this.attachInternals();
|
|
212
|
+
this.#internals.role = 'columnheader';
|
|
213
|
+
/**
|
|
214
|
+
* Sets the horizontal alignment of the content.
|
|
215
|
+
* @attr horizontal-align
|
|
216
|
+
* @type {'left' | 'center' | 'right'}
|
|
217
|
+
*/
|
|
218
|
+
this.horizontalAlign = 'left';
|
|
219
|
+
/**
|
|
220
|
+
* Makes a column sortable.
|
|
221
|
+
* @attr sortable
|
|
222
|
+
* @type {boolean}
|
|
223
|
+
*/
|
|
224
|
+
this.sortable = false;
|
|
225
|
+
/**
|
|
226
|
+
* Sets the order in which the items in the column are sorted.
|
|
227
|
+
* @attr sorted
|
|
228
|
+
* @type {'none' | 'ascending' | 'descending'}
|
|
229
|
+
*/
|
|
230
|
+
this.sorted = 'none';
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
connectedCallback() {
|
|
234
|
+
super.connectedCallback();
|
|
235
|
+
/** @ignore */
|
|
236
|
+
this.id = `table-header-${id++}`;
|
|
237
|
+
if (this.sortable) {
|
|
238
|
+
this.setAttribute('tabindex', '0');
|
|
239
|
+
this.setAttribute('aria-sort', this.sorted);
|
|
240
|
+
this.addEventListener('click', this.#handleSort);
|
|
241
|
+
this.addEventListener('keydown', this.#handleKeydown);
|
|
242
|
+
} else {
|
|
243
|
+
this.sorted = null;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
#handleKeydown(e) {
|
|
247
|
+
if (e.code === 'Space'|| e.code === 'Enter') {
|
|
248
|
+
e.preventDefault();
|
|
249
|
+
this.#handleSort();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
#handleSort() {
|
|
254
|
+
if (this.sorted==='none') {
|
|
255
|
+
this.sorted = 'ascending';
|
|
256
|
+
} else if (this.sorted==='ascending') {
|
|
257
|
+
this.sorted = 'descending';
|
|
258
|
+
} else {
|
|
259
|
+
this.sorted = 'none';
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
this.setAttribute('aria-sort', this.sorted);
|
|
263
|
+
|
|
264
|
+
this.dispatchEvent(
|
|
265
|
+
new CustomEvent('jh-sort', {
|
|
266
|
+
bubbles: true,
|
|
267
|
+
cancelable: true,
|
|
268
|
+
composed: true,
|
|
269
|
+
detail: {
|
|
270
|
+
column: this,
|
|
271
|
+
sorted: this.sorted,
|
|
272
|
+
id: this.id,
|
|
273
|
+
},
|
|
274
|
+
})
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
#getSortingIcon() {
|
|
279
|
+
if (!this.sortable) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
switch (this.sorted) {
|
|
283
|
+
case 'ascending':
|
|
284
|
+
return html`
|
|
285
|
+
<slot name="jh-table-sorted-ascending" class="icon-slot">
|
|
286
|
+
<jh-icon-arrow-up-small>
|
|
287
|
+
</jh-icon-arrow-up-small>
|
|
288
|
+
</slot>
|
|
289
|
+
`;
|
|
290
|
+
case 'descending':
|
|
291
|
+
return html`
|
|
292
|
+
<slot name="jh-table-sorted-descending" class="icon-slot">
|
|
293
|
+
<jh-icon-arrow-down-small>
|
|
294
|
+
</jh-icon-arrow-down-small>
|
|
295
|
+
</slot>
|
|
296
|
+
`;
|
|
297
|
+
case 'none':
|
|
298
|
+
return html`
|
|
299
|
+
<slot name="jh-table-sorted-none" class="icon-slot">
|
|
300
|
+
<jh-icon-arrow-up-arrow-down>
|
|
301
|
+
</jh-icon-arrow-up-arrow-down>
|
|
302
|
+
</slot>
|
|
303
|
+
`;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
render() {
|
|
308
|
+
return this.sortable ?
|
|
309
|
+
html`
|
|
310
|
+
<button class="sortable-header" tabindex="-1">
|
|
311
|
+
<div class="header-text"><slot></slot></div>
|
|
312
|
+
${this.#getSortingIcon()}
|
|
313
|
+
</button>` :
|
|
314
|
+
html`
|
|
315
|
+
<div class="fixed-header">
|
|
316
|
+
<slot></slot>
|
|
317
|
+
</div>`;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
customElements.define('jh-table-header-cell', JhTableHeaderCell);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2025 Jack Henry
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
import { LitElement, css, html } from 'lit';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Table Row
|
|
9
|
+
*
|
|
10
|
+
* @cssprop --jh-table-row-color-text-enabled - The row text color when enabled. Defaults to `--jh-color-content-primary-enabled`.
|
|
11
|
+
* @cssprop --jh-table-row-color-background-enabled - The row background color when enabled. Defaults to `--jh-color-container-primary-enabled`.
|
|
12
|
+
* @cssprop --jh-table-row-color-border-bottom-enabled - The row border bottom color when enabled. Defaults to `--jh-border-decorative-color`.
|
|
13
|
+
* @cssprop --jh-table-row-color-text-hover - The row text color when hovered. Defaults to `--jh-color-content-primary-hover`.
|
|
14
|
+
* @cssprop --jh-table-row-color-background-hover - The row background color when hovered. Defaults to `--jh-color-container-primary-hover`.
|
|
15
|
+
* @cssprop --jh-table-row-color-border-bottom-hover - The row border bottom color when hovered. Defaults to `--jh-border-decorative-color`.
|
|
16
|
+
*
|
|
17
|
+
* @slot default - Use to insert `<jh-table-data-cell>`s or `<jh-table-header-cell>`s.
|
|
18
|
+
* @customElement jh-table-row
|
|
19
|
+
*/
|
|
20
|
+
export class JhTableRow extends LitElement {
|
|
21
|
+
|
|
22
|
+
/** @type {ElementInternals} */
|
|
23
|
+
#internals;
|
|
24
|
+
|
|
25
|
+
static get styles() {
|
|
26
|
+
return css`
|
|
27
|
+
:host {
|
|
28
|
+
display: table-row;
|
|
29
|
+
--jh-table-data-cell-color-text: var(--jh-table-row-color-text-enabled);
|
|
30
|
+
--jh-table-data-cell-color-border-bottom: var(--jh-table-row-color-border-bottom-enabled);
|
|
31
|
+
--jh-table-data-cell-color-background: var(--jh-table-row-color-background-enabled);
|
|
32
|
+
}
|
|
33
|
+
:host(:hover) {
|
|
34
|
+
--jh-table-data-cell-color-text: var(--jh-table-row-color-text-hover, var(--jh-color-content-primary-hover));
|
|
35
|
+
--jh-table-data-cell-color-border-bottom: var(--jh-table-row-color-border-bottom-hover);
|
|
36
|
+
--jh-table-data-cell-color-background: var(--jh-table-row-color-background-hover, var(--jh-color-container-primary-hover));
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
constructor() {
|
|
42
|
+
super();
|
|
43
|
+
this.#internals = this.attachInternals();
|
|
44
|
+
this.#internals.role = 'row';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
render() {
|
|
48
|
+
return html`<slot></slot>`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
customElements.define('jh-table-row', JhTableRow);
|