@brightspace-ui/core 3.37.0 → 3.39.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -5,6 +5,7 @@ import '../../expand-collapse/expand-collapse-content.js';
|
|
5
5
|
import '../../inputs/input-number.js';
|
6
6
|
import '../../inputs/input-text.js';
|
7
7
|
import '../form.js';
|
8
|
+
import '../../collapsible-panel/collapsible-panel.js';
|
8
9
|
import { css, html, LitElement } from 'lit';
|
9
10
|
import { heading3Styles } from '../../typography/styles.js';
|
10
11
|
import { inputStyles } from '../../inputs/input-styles.js';
|
@@ -63,36 +64,38 @@ class FormPanelDemo extends LitElement {
|
|
63
64
|
|
64
65
|
render() {
|
65
66
|
return html`
|
66
|
-
<
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
<div class="d2l-form-panel-demo-container">
|
88
|
-
<d2l-input-number label="Age" name="age" required min="18" max="23"></d2l-input-number>
|
89
|
-
</div>
|
90
|
-
</d2l-form>
|
91
|
-
</d2l-expand-collapse-content>
|
92
|
-
</div>
|
67
|
+
<d2l-collapsible-panel
|
68
|
+
panel-title="Personal Information"
|
69
|
+
type="subtle"
|
70
|
+
?expanded=${this._expanded}
|
71
|
+
@d2l-collapsible-panel-expand=${this._onExpand}
|
72
|
+
@d2l-collapsible-panel-collapse=${this._onCollapse}>
|
73
|
+
<d2l-form @d2l-form-invalid=${this._onInvalid} @d2l-form-submit=${this._onSubmit}>
|
74
|
+
<div class="d2l-form-panel-demo-container">
|
75
|
+
<d2l-input-text label="First Name" name="first-name" required minlength="4" maxlength="15"></d2l-input-text>
|
76
|
+
</div>
|
77
|
+
<div class="d2l-form-panel-demo-container">
|
78
|
+
<d2l-input-text label="Middle Name" name="middle-name" minlength="4" maxlength="8"></d2l-input-text>
|
79
|
+
</div>
|
80
|
+
<div class="d2l-form-panel-demo-container">
|
81
|
+
<d2l-input-text label="Last Name" name="last-name" required minlength="4" maxlength="15"></d2l-input-text>
|
82
|
+
</div>
|
83
|
+
<div class="d2l-form-panel-demo-container">
|
84
|
+
<d2l-input-number label="Age" name="age" required min="18" max="23"></d2l-input-number>
|
85
|
+
</div>
|
86
|
+
</d2l-form>
|
87
|
+
</d2l-collapsible-panel>
|
93
88
|
`;
|
94
89
|
}
|
95
90
|
|
91
|
+
_onCollapse() {
|
92
|
+
this._expanded = false;
|
93
|
+
}
|
94
|
+
|
95
|
+
_onExpand() {
|
96
|
+
this._expanded = true;
|
97
|
+
}
|
98
|
+
|
96
99
|
_onInvalid() {
|
97
100
|
this._expanded = true;
|
98
101
|
}
|
@@ -101,11 +104,5 @@ class FormPanelDemo extends LitElement {
|
|
101
104
|
// eslint-disable-next-line no-console
|
102
105
|
console.log(e.detail.formData);
|
103
106
|
}
|
104
|
-
|
105
|
-
_toggleExpandCollapse(e) {
|
106
|
-
e.stopPropagation();
|
107
|
-
this._expanded = !this._expanded;
|
108
|
-
}
|
109
|
-
|
110
107
|
}
|
111
108
|
customElements.define('d2l-form-panel-demo', FormPanelDemo);
|
@@ -259,6 +259,11 @@ export const tableStyles = css`
|
|
259
259
|
}
|
260
260
|
`;
|
261
261
|
|
262
|
+
const SELECTORS = {
|
263
|
+
headers: 'tr.d2l-table-header, tr[header], thead tr',
|
264
|
+
items: ':not(thead) > tr:not(.d2l-table-header):not([header])',
|
265
|
+
};
|
266
|
+
|
262
267
|
/**
|
263
268
|
* Wraps a native <table> element, providing styling and scroll buttons for overflow.
|
264
269
|
* @slot - Content to wrap
|
@@ -486,7 +491,7 @@ export class TableWrapper extends RtlMixin(PageableMixin(SelectionMixin(LitEleme
|
|
486
491
|
}
|
487
492
|
|
488
493
|
_getItems() {
|
489
|
-
return this._table?.querySelectorAll(
|
494
|
+
return this._table?.querySelectorAll(SELECTORS.items) || [];
|
490
495
|
}
|
491
496
|
|
492
497
|
_getItemShowingCount() {
|
@@ -574,13 +579,37 @@ export class TableWrapper extends RtlMixin(PageableMixin(SelectionMixin(LitEleme
|
|
574
579
|
this._handleTableChange();
|
575
580
|
}
|
576
581
|
|
577
|
-
async _handleTableChange() {
|
582
|
+
async _handleTableChange(mutationRecords) {
|
583
|
+
const flag = window.D2L?.LP?.Web?.UI?.Flags.Flag('table-update-filter-GAUD-6955', true) ?? true;
|
584
|
+
const updates = { count: true, classNames: true, sticky: true, syncWidths: true };
|
585
|
+
if (flag) {
|
586
|
+
if (mutationRecords) {
|
587
|
+
for (const key in updates) updates[key] = false;
|
588
|
+
for (const { type, removedNodes, addedNodes, target, attributeName } of mutationRecords) {
|
589
|
+
if (type === 'attributes') {
|
590
|
+
updates.classNames = attributeName === 'selected';
|
591
|
+
continue;
|
592
|
+
}
|
593
|
+
|
594
|
+
updates.sticky ||= target.matches(SELECTORS.headers);
|
595
|
+
const affectedNodes = [...removedNodes, ...addedNodes];
|
596
|
+
for (const node of affectedNodes) {
|
597
|
+
if (!(node instanceof Element)) continue;
|
598
|
+
updates.classNames ||= node.matches('tr');
|
599
|
+
updates.syncWidths ||= node.matches('tr');
|
600
|
+
updates.sticky ||= node.matches(SELECTORS.headers);
|
601
|
+
updates.count ||= node.matches(SELECTORS.items);
|
602
|
+
}
|
603
|
+
}
|
604
|
+
}
|
605
|
+
}
|
606
|
+
|
578
607
|
await new Promise(resolve => requestAnimationFrame(resolve));
|
579
608
|
|
580
|
-
this._updateItemShowingCount();
|
581
|
-
this._applyClassNames();
|
582
|
-
this._syncColumnWidths();
|
583
|
-
this._updateStickyTops();
|
609
|
+
if (updates.count) this._updateItemShowingCount();
|
610
|
+
if (updates.classNames) this._applyClassNames();
|
611
|
+
if (updates.syncWidths) this._syncColumnWidths();
|
612
|
+
if (updates.sticky) this._updateStickyTops();
|
584
613
|
}
|
585
614
|
|
586
615
|
_registerMutationObserver(observerName, callback, target, options) {
|
@@ -721,7 +750,7 @@ export class TableWrapper extends RtlMixin(PageableMixin(SelectionMixin(LitEleme
|
|
721
750
|
|
722
751
|
if (!this._table || !this.stickyHeaders || this.stickyHeadersScrollWrapper) return;
|
723
752
|
|
724
|
-
const stickyRows = Array.from(this._table.querySelectorAll(
|
753
|
+
const stickyRows = Array.from(this._table.querySelectorAll(SELECTORS.headers));
|
725
754
|
stickyRows.forEach(r => {
|
726
755
|
const thTop = hasStickyControls ? `${rowTop}px` : `calc(${rowTop}px + var(--d2l-table-border-radius-sticky-offset, 0px))`;
|
727
756
|
const ths = Array.from(r.querySelectorAll('th'));
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.39.0",
|
4
4
|
"description": "A collection of accessible, free, open-source web components for building Brightspace applications",
|
5
5
|
"type": "module",
|
6
6
|
"repository": "https://github.com/BrightspaceUI/core.git",
|