@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,343 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2025 Jack Henry
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
import { LitElement, css, html } from 'lit';
|
|
6
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
7
|
+
import '../divider/divider.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @cssprop --jh-card-color-background - The card background-color. Defaults to `--jh-color-container-primary-enabled`.
|
|
11
|
+
* @cssprop --jh-card-border-radius - The card border-radius. Defaults to `--jh-border-radius-400`.
|
|
12
|
+
* @cssprop --jh-card-shadow - The card box-shadow. Defaults to `--jh-shadow-low`.
|
|
13
|
+
* @cssprop --jh-card-media-aspect-ratio - The media slot aspect-ratio. Defaults to `auto`.
|
|
14
|
+
* @cssprop --jh-card-media-space-padding - The media slot padding. Defaults to `0`.
|
|
15
|
+
* @cssprop --jh-card-header-color-text - The header text color. Defaults to `--jh-color-content-primary-enabled`.
|
|
16
|
+
* @cssprop --jh-card-header-space-padding - The header slot padding. Defaults to `--jh-dimension-400 --jh-dimension-600 0`. When `padding="small"`, defaults to
|
|
17
|
+
* `--jh-dimension-400 --jh-dimension-400 0`. When `padding="small"` and `show-header-divider`, defaults to `--jh-dimension-400`. When `padding="medium"` or
|
|
18
|
+
* `padding="none'` and `show-header-divider`, defaults to `--jh-dimension-400 --jh-dimension-600`.
|
|
19
|
+
* @cssprop --jh-card-default-color-text - The default slot text color. Defaults to `--jh-color-content-primary-enabled`.
|
|
20
|
+
* @cssprop --jh-card-default-space-padding - The default slot padding. Defaults to `--jh-dimension-400 --jh-dimension-600`. When `padding="small"`, defaults
|
|
21
|
+
* to `--jh-dimension-400`. When `padding="none"`, defaults to `--jh-dimension-400 0`.
|
|
22
|
+
* @cssprop --jh-card-footer-color-text - The footer slot text color. Defaults to `--jh-color-content-secondary-enabled`.
|
|
23
|
+
* @cssprop --jh-card-footer-space-padding - The footer slot padding. Defaults to `0 --jh-dimension-600 --jh-dimension-400`. When `padding="small"`, defaults to
|
|
24
|
+
* `0 --jh-dimension-400 --jh-dimension-400`. When `padding="small"` and `show-footer-divider`, defaults to `--jh-dimension-400`. When `padding="medium"` or
|
|
25
|
+
* `padding="none"` and `show-footer-divider`, defaults to `--jh-dimension-400 --jh-dimension-600`.
|
|
26
|
+
* @cssprop --jh-card-header-title-color-text - The header title text color. Defaults to `--jh-color-content-primary-enabled`.
|
|
27
|
+
* @cssprop --jh-card-header-subtitle-color-text - The header subtitle text color. Defaults to `--jh-color-content-secondary-enabled`.
|
|
28
|
+
* @slot default - Use to insert card body content.
|
|
29
|
+
* @slot jh-card-media - Use to insert media content in the top section of the card. User may need to add addtional styling to elements such as border, object-fit, etc.
|
|
30
|
+
* @slot jh-card-header - Use to insert custom card header layout. Default layout includes `headerTitle` and `headerSubtitle` properties.
|
|
31
|
+
* @slot jh-card-footer - Use to insert card footer content.
|
|
32
|
+
* @customElement jh-card
|
|
33
|
+
*/
|
|
34
|
+
export class JhCard extends LitElement {
|
|
35
|
+
static get styles() {
|
|
36
|
+
return css`
|
|
37
|
+
:host {
|
|
38
|
+
--border-radius: var(--jh-border-radius-400);
|
|
39
|
+
background-color: var(
|
|
40
|
+
--jh-card-color-background,
|
|
41
|
+
var(--jh-color-container-primary-enabled)
|
|
42
|
+
);
|
|
43
|
+
border-radius: var(
|
|
44
|
+
--jh-card-border-radius,
|
|
45
|
+
var(--border-radius)
|
|
46
|
+
);
|
|
47
|
+
box-shadow: var(--jh-card-shadow, var(--jh-shadow-low));
|
|
48
|
+
word-break: break-word;
|
|
49
|
+
display: block;
|
|
50
|
+
}
|
|
51
|
+
.display-slot {
|
|
52
|
+
display: block;
|
|
53
|
+
}
|
|
54
|
+
slot[name='jh-card-media'] {
|
|
55
|
+
padding: var(--jh-card-media-space-padding, 0);
|
|
56
|
+
border-radius: var(--border-radius) var(--border-radius) 0 0;
|
|
57
|
+
overflow: hidden;
|
|
58
|
+
}
|
|
59
|
+
::slotted([slot='jh-card-media']) {
|
|
60
|
+
aspect-ratio: var(--jh-card-media-aspect-ratio, auto);
|
|
61
|
+
width: 100%;
|
|
62
|
+
}
|
|
63
|
+
::slotted([slot='jh-card-header']) {
|
|
64
|
+
color: var(
|
|
65
|
+
--jh-card-header-color-text,
|
|
66
|
+
var(--jh-color-content-primary-enabled)
|
|
67
|
+
);
|
|
68
|
+
font-family: var(--jh-font-heading-medium-3-font-family);
|
|
69
|
+
font-weight: var(--jh-font-heading-medium-3-font-weight);
|
|
70
|
+
font-size: var(--jh-font-heading-medium-3-font-size);
|
|
71
|
+
line-height: var(--jh-font-heading-medium-3-line-height);
|
|
72
|
+
}
|
|
73
|
+
h1,
|
|
74
|
+
h2,
|
|
75
|
+
h3,
|
|
76
|
+
h4,
|
|
77
|
+
h5,
|
|
78
|
+
h6 {
|
|
79
|
+
color: var(
|
|
80
|
+
--jh-card-header-title-color-text,
|
|
81
|
+
var(--jh-color-content-primary-enabled)
|
|
82
|
+
);
|
|
83
|
+
font-family: var(--jh-font-heading-medium-3-font-family);
|
|
84
|
+
font-weight: var(--jh-font-heading-medium-3-font-weight);
|
|
85
|
+
font-size: var(--jh-font-heading-medium-3-font-size);
|
|
86
|
+
line-height: var(--jh-font-heading-medium-3-line-height);
|
|
87
|
+
margin: 0;
|
|
88
|
+
}
|
|
89
|
+
p {
|
|
90
|
+
color: var(
|
|
91
|
+
--jh-card-header-subtitle-color-text,
|
|
92
|
+
var(--jh-color-content-secondary-enabled)
|
|
93
|
+
);
|
|
94
|
+
font-family: var(--jh-font-body-regular-1-font-family);
|
|
95
|
+
font-weight: var(--jh-font-body-regular-1-font-weight);
|
|
96
|
+
font-size: var(--jh-font-body-regular-1-font-size);
|
|
97
|
+
line-height: var(--jh-font-body-regular-1-line-height);
|
|
98
|
+
margin: 0;
|
|
99
|
+
}
|
|
100
|
+
slot:not([name]) {
|
|
101
|
+
color: var(
|
|
102
|
+
--jh-card-default-color-text,
|
|
103
|
+
var(--jh-color-content-primary-enabled)
|
|
104
|
+
);
|
|
105
|
+
font-family: var(--jh-font-body-regular-1-font-family);
|
|
106
|
+
font-weight: var(--jh-font-body-regular-1-font-weight);
|
|
107
|
+
font-size: var(--jh-font-body-regular-1-font-size);
|
|
108
|
+
line-height: var(--jh-font-body-regular-1-line-height);
|
|
109
|
+
}
|
|
110
|
+
::slotted([slot='jh-card-footer']) {
|
|
111
|
+
color: var(
|
|
112
|
+
--jh-card-footer-color-text,
|
|
113
|
+
var(--jh-color-content-secondary-enabled)
|
|
114
|
+
);
|
|
115
|
+
font-family: var(--jh-font-helper-regular-font-family);
|
|
116
|
+
font-weight: var(--jh-font-helper-regular-font-weight);
|
|
117
|
+
font-size: var(--jh-font-helper-regular-font-size);
|
|
118
|
+
line-height: var(--jh-font-helper-regular-line-height);
|
|
119
|
+
}
|
|
120
|
+
.card-header-divider,
|
|
121
|
+
.card-footer-divider {
|
|
122
|
+
margin-top: 0px;
|
|
123
|
+
margin-bottom: 0px;
|
|
124
|
+
}
|
|
125
|
+
/* padding */
|
|
126
|
+
:host([padding='small']) .display-header,
|
|
127
|
+
:host([padding='small']) slot[name='jh-card-header'] {
|
|
128
|
+
padding: var(
|
|
129
|
+
--jh-card-header-space-padding,
|
|
130
|
+
var(--jh-dimension-400) var(--jh-dimension-400) 0
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
:host([padding='none']) .display-header,
|
|
134
|
+
:host([padding='medium']) .display-header,
|
|
135
|
+
:host([padding='none']) slot[name='jh-card-header'],
|
|
136
|
+
:host([padding='medium']) slot[name='jh-card-header'] {
|
|
137
|
+
padding: var(
|
|
138
|
+
--jh-card-header-space-padding,
|
|
139
|
+
var(--jh-dimension-400) var(--jh-dimension-600) 0
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
:host([padding='none']) slot:not([name]) {
|
|
143
|
+
padding: var(--jh-card-default-space-padding, var(--jh-dimension-400) 0);
|
|
144
|
+
}
|
|
145
|
+
:host([padding='small']) slot:not([name]) {
|
|
146
|
+
padding: var(--jh-card-default-space-padding, var(--jh-dimension-400));
|
|
147
|
+
}
|
|
148
|
+
:host([padding='medium']) slot:not([name]) {
|
|
149
|
+
padding: var(
|
|
150
|
+
--jh-card-default-space-padding,
|
|
151
|
+
var(--jh-dimension-400) var(--jh-dimension-600)
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
:host([padding='small']) slot[name='jh-card-footer'] {
|
|
155
|
+
padding: var(
|
|
156
|
+
--jh-card-footer-space-padding,
|
|
157
|
+
0 var(--jh-dimension-400) var(--jh-dimension-400)
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
:host([padding='none']) slot[name='jh-card-footer'],
|
|
161
|
+
:host([padding='medium']) slot[name='jh-card-footer'] {
|
|
162
|
+
padding: var(
|
|
163
|
+
--jh-card-footer-space-padding,
|
|
164
|
+
0 var(--jh-dimension-600) var(--jh-dimension-400)
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
/* dividers and padding */
|
|
168
|
+
:host([show-header-divider][padding='small']) .display-header,
|
|
169
|
+
:host([show-header-divider][padding='small']) slot[name='jh-card-header'] {
|
|
170
|
+
padding: var(--jh-card-header-space-padding, var(--jh-dimension-400));
|
|
171
|
+
}
|
|
172
|
+
:host([show-header-divider][padding='none']) .display-header,
|
|
173
|
+
:host([show-header-divider][padding='medium']) .display-header,
|
|
174
|
+
:host([show-header-divider][padding='none']) slot[name='jh-card-header'],
|
|
175
|
+
:host([show-header-divider][padding='medium']) slot[name='jh-card-header'] {
|
|
176
|
+
padding: var(
|
|
177
|
+
--jh-card-header-space-padding,
|
|
178
|
+
var(--jh-dimension-400) var(--jh-dimension-600)
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
:host([show-footer-divider][padding='small']) slot[name='jh-card-footer'] {
|
|
182
|
+
padding: var(--jh-card-footer-space-padding, var(--jh-dimension-400));
|
|
183
|
+
}
|
|
184
|
+
:host([show-footer-divider][padding='none']) slot[name='jh-card-footer'],
|
|
185
|
+
:host([show-footer-divider][padding='medium']) slot[name='jh-card-footer'] {
|
|
186
|
+
padding: var(
|
|
187
|
+
--jh-card-footer-space-padding,
|
|
188
|
+
var(--jh-dimension-400) var(--jh-dimension-600)
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
`;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
static get properties() {
|
|
195
|
+
return {
|
|
196
|
+
/** Sets the alignment of the left edge of the divider above the footer. */
|
|
197
|
+
footerDividerInset: {
|
|
198
|
+
type: Number,
|
|
199
|
+
attribute: 'footer-divider-inset',
|
|
200
|
+
},
|
|
201
|
+
/** Sets the alignment of the left edge of the divider below the header. */
|
|
202
|
+
headerDividerInset: {
|
|
203
|
+
type: Number,
|
|
204
|
+
attribute: 'header-divider-inset',
|
|
205
|
+
},
|
|
206
|
+
/** Adds a divider above the footer to create a clearer definition between the body and footer. */
|
|
207
|
+
showFooterDivider: {
|
|
208
|
+
type: Boolean,
|
|
209
|
+
attribute: 'show-footer-divider',
|
|
210
|
+
reflect: true,
|
|
211
|
+
},
|
|
212
|
+
/** Adds a divider below the header to create a clearer definition between the header and body. */
|
|
213
|
+
showHeaderDivider: {
|
|
214
|
+
type: Boolean,
|
|
215
|
+
attribute: 'show-header-divider',
|
|
216
|
+
reflect: true,
|
|
217
|
+
},
|
|
218
|
+
/** Sets padding on all slots. Set `padding='none'` to remove padding solely from default slot. To override padding property, set component level token for desired slot.*/
|
|
219
|
+
padding: {
|
|
220
|
+
type: String,
|
|
221
|
+
reflect: true,
|
|
222
|
+
},
|
|
223
|
+
/** Adds additional information about the card below the title. */
|
|
224
|
+
headerSubtitle: {
|
|
225
|
+
type: String,
|
|
226
|
+
attribute: 'header-subtitle',
|
|
227
|
+
},
|
|
228
|
+
/** Provides context for the content of the card. */
|
|
229
|
+
headerTitle: {
|
|
230
|
+
type: String,
|
|
231
|
+
attribute: 'header-title',
|
|
232
|
+
},
|
|
233
|
+
/** Informs assistive technologies what heading level the card title represents. Defaults to h2. */
|
|
234
|
+
titleHeadingLevel: {
|
|
235
|
+
type: Number,
|
|
236
|
+
attribute: 'title-heading-level',
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
constructor() {
|
|
242
|
+
super();
|
|
243
|
+
/** @type {0|8|16|24|32|40|48|56|64|72|80|88|96} */
|
|
244
|
+
this.footerDividerInset = null;
|
|
245
|
+
/** @type {0|8|16|24|32|40|48|56|64|72|80|88|96} */
|
|
246
|
+
this.headerDividerInset = null;
|
|
247
|
+
/** @type {1|2|3|4|5|6} */
|
|
248
|
+
this.titleHeadingLevel = 2;
|
|
249
|
+
/** @type {'small'|'medium'|'none'} */
|
|
250
|
+
this.padding = 'medium';
|
|
251
|
+
/** @type {boolean} */
|
|
252
|
+
this.showFooterDivider = false;
|
|
253
|
+
/** @type {boolean} */
|
|
254
|
+
this.showHeaderDivider = false;
|
|
255
|
+
/** @type {?string} */
|
|
256
|
+
this.headerSubtitle = null;
|
|
257
|
+
/** @type {?string} */
|
|
258
|
+
this.headerTitle = null;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
#checkSlotContent(slot) {
|
|
262
|
+
if (slot.assignedElements().length > 0) {
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return slot.assignedNodes().some((node) => node.nodeType === Node.TEXT_NODE && node.textContent.trim() !== '');
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
#handleSlotChange(e) {
|
|
270
|
+
let slot = e.target;
|
|
271
|
+
let hasContent = this.#checkSlotContent(slot);
|
|
272
|
+
slot.classList.toggle('display-slot', hasContent);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
#getTitle() {
|
|
276
|
+
switch (this.titleHeadingLevel) {
|
|
277
|
+
case 1:
|
|
278
|
+
return html`<h1>${this.headerTitle}</h1>`;
|
|
279
|
+
case 2:
|
|
280
|
+
return html`<h2>${this.headerTitle}</h2>`;
|
|
281
|
+
case 3:
|
|
282
|
+
return html`<h3>${this.headerTitle}</h3>`;
|
|
283
|
+
case 4:
|
|
284
|
+
return html`<h4>${this.headerTitle}</h4>`;
|
|
285
|
+
case 5:
|
|
286
|
+
return html`<h5>${this.headerTitle}</h5>`;
|
|
287
|
+
case 6:
|
|
288
|
+
return html`<h6>${this.headerTitle}</h6>`;
|
|
289
|
+
default:
|
|
290
|
+
return html`<h2>${this.headerTitle}</h2>`;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
render() {
|
|
295
|
+
let cardHeader;
|
|
296
|
+
let headerDivider;
|
|
297
|
+
let footerDivider;
|
|
298
|
+
|
|
299
|
+
if (this.headerTitle || this.headerSubtitle) {
|
|
300
|
+
cardHeader = html`
|
|
301
|
+
<div class="display-header">
|
|
302
|
+
${this.headerTitle ? this.#getTitle() : null}
|
|
303
|
+
${this.headerSubtitle ? html`<p>${this.headerSubtitle}</p>` : null}
|
|
304
|
+
</div>
|
|
305
|
+
`;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (this.showHeaderDivider) {
|
|
309
|
+
headerDivider = html`
|
|
310
|
+
<jh-divider
|
|
311
|
+
class="card-header-divider"
|
|
312
|
+
inset=${ifDefined(
|
|
313
|
+
this.headerDividerInset ? this.headerDividerInset : null
|
|
314
|
+
)}
|
|
315
|
+
>
|
|
316
|
+
</jh-divider>
|
|
317
|
+
`;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (this.showFooterDivider) {
|
|
321
|
+
footerDivider = html`
|
|
322
|
+
<jh-divider
|
|
323
|
+
class="card-footer-divider"
|
|
324
|
+
inset=${ifDefined(
|
|
325
|
+
this.footerDividerInset ? this.footerDividerInset : null
|
|
326
|
+
)}
|
|
327
|
+
>
|
|
328
|
+
</jh-divider>
|
|
329
|
+
`;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
return html`
|
|
333
|
+
<slot name="jh-card-media" @slotchange=${this.#handleSlotChange}></slot>
|
|
334
|
+
<slot name="jh-card-header" @slotchange=${this.#handleSlotChange}>${cardHeader}</slot>
|
|
335
|
+
${headerDivider}
|
|
336
|
+
<slot @slotchange=${this.#handleSlotChange}></slot>
|
|
337
|
+
${footerDivider}
|
|
338
|
+
<slot name="jh-card-footer" @slotchange=${this.#handleSlotChange}></slot>
|
|
339
|
+
`;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
customElements.define('jh-card', JhCard);
|