@brightspace-ui/core 3.254.1 → 3.255.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.
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# FormElementContainerMixin
|
|
2
|
+
|
|
3
|
+
Extending `FormElementContainerMixin` will allow a custom element's children (native or [custom](./form-element-mixin.md)) to participate in the parent `<d2l-form>`.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Simply extend the `FormElementContainerMixin`:
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
import { FormElementContainerMixin } from '@brightspace-ui/core/form/form-element-container-mixin.js';
|
|
11
|
+
|
|
12
|
+
class MyCustomFormElementContainer extends FormElementContainerMixin(LitElement) {
|
|
13
|
+
render() {
|
|
14
|
+
html`
|
|
15
|
+
<d2l-input-text
|
|
16
|
+
label="First Name"
|
|
17
|
+
name="first-name"
|
|
18
|
+
required></d2l-input-text>
|
|
19
|
+
<d2l-input-text
|
|
20
|
+
label="Last Name"
|
|
21
|
+
name="last-name"
|
|
22
|
+
required></d2l-input-text>
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
customElements.define('my-custom-form-element-container', MyCustomFormElementContainer);
|
|
28
|
+
```
|
|
@@ -15,24 +15,34 @@ export const isElement = (node) => node && node.nodeType === Node.ELEMENT_NODE;
|
|
|
15
15
|
|
|
16
16
|
export const isCustomElement = (node) => isElement(node) && node.nodeName.indexOf('-') !== -1;
|
|
17
17
|
|
|
18
|
-
export const isCustomFormElement = (node) => isCustomElement(node) &&
|
|
18
|
+
export const isCustomFormElement = (node) => isCustomElement(node) && Boolean(node.formAssociated);
|
|
19
|
+
|
|
20
|
+
export const isCustomFormElementContainer = (node) => isCustomElement(node) && Boolean(node.isCustomFormElementContainer);
|
|
19
21
|
|
|
20
22
|
export const isNativeFormElement = (node) => {
|
|
21
23
|
if (!isElement(node)) {
|
|
22
24
|
return false;
|
|
23
25
|
}
|
|
24
26
|
const nodeName = node.nodeName.toLowerCase();
|
|
25
|
-
return
|
|
27
|
+
return Boolean(formElements[nodeName]);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const getElementChildren = (elem) => {
|
|
31
|
+
if (isCustomFormElementContainer(elem)) {
|
|
32
|
+
return elem.shadowRoot.children;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return elem.tagName === 'SLOT' && ['primary', 'secondary'].includes(elem.name) ? elem.assignedNodes() : elem.children;
|
|
26
36
|
};
|
|
27
37
|
|
|
28
|
-
const _findFormElementsHelper = (
|
|
29
|
-
if (isNativeFormElement(
|
|
30
|
-
|
|
38
|
+
const _findFormElementsHelper = (elem, elems, isFormElementPredicate, visitChildrenPredicate) => {
|
|
39
|
+
if (isNativeFormElement(elem) || isCustomFormElement(elem) || isFormElementPredicate(elem)) {
|
|
40
|
+
elems.push(elem);
|
|
31
41
|
}
|
|
32
|
-
if (visitChildrenPredicate(
|
|
33
|
-
const children =
|
|
42
|
+
if (visitChildrenPredicate(elem)) {
|
|
43
|
+
const children = getElementChildren(elem);
|
|
34
44
|
for (const child of children) {
|
|
35
|
-
_findFormElementsHelper(child,
|
|
45
|
+
_findFormElementsHelper(child, elems, isFormElementPredicate, visitChildrenPredicate);
|
|
36
46
|
}
|
|
37
47
|
}
|
|
38
48
|
};
|
|
@@ -5,7 +5,6 @@ import { css, html, LitElement, nothing } from 'lit';
|
|
|
5
5
|
import { cssSizes } from '../inputs/input-checkbox-styles.js';
|
|
6
6
|
import { getComposedParent } from '../../helpers/dom.js';
|
|
7
7
|
import { getFlag } from '../../helpers/flags.js';
|
|
8
|
-
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
9
8
|
import { isPopoverSupported } from '../popover/popover-mixin.js';
|
|
10
9
|
import { PageableMixin } from '../paging/pageable-mixin.js';
|
|
11
10
|
import { PropertyRequiredMixin } from '../../mixins/property-required/property-required-mixin.js';
|
|
@@ -421,8 +420,6 @@ export class TableWrapper extends PropertyRequiredMixin(PageableMixin(SelectionM
|
|
|
421
420
|
|
|
422
421
|
this.dirtyText = null;
|
|
423
422
|
this.dirtyButtonText = null;
|
|
424
|
-
|
|
425
|
-
this._excludeStickyColumnsFromScrollCalculations = getFlag('GAUD-9530-exclude-sticky-columns-from-scroll-calculations', false);
|
|
426
423
|
}
|
|
427
424
|
|
|
428
425
|
connectedCallback() {
|
|
@@ -461,7 +458,7 @@ export class TableWrapper extends PropertyRequiredMixin(PageableMixin(SelectionM
|
|
|
461
458
|
return html`
|
|
462
459
|
<slot name="controls" @slotchange="${this._handleControlsSlotChange}"></slot>
|
|
463
460
|
${this.stickyHeaders && this._controlsScrolled ? html`<div class="d2l-sticky-headers-backdrop"></div>` : nothing}
|
|
464
|
-
${useScrollWrapper ? html`<d2l-scroll-wrapper scroll-area-offset=${
|
|
461
|
+
${useScrollWrapper ? html`<d2l-scroll-wrapper scroll-area-offset=${this._stickyWidth} .customScrollers="${this._tableScrollers}">${slot}</d2l-scroll-wrapper>` : slot}
|
|
465
462
|
${this._renderPagerContainer()}
|
|
466
463
|
`;
|
|
467
464
|
}
|
|
@@ -796,7 +793,7 @@ export class TableWrapper extends PropertyRequiredMixin(PageableMixin(SelectionM
|
|
|
796
793
|
}
|
|
797
794
|
if (headCell.hasAttribute('sticky')) stickyWidth += cellWidth;
|
|
798
795
|
}
|
|
799
|
-
|
|
796
|
+
this._stickyWidth = stickyWidth;
|
|
800
797
|
}
|
|
801
798
|
|
|
802
799
|
_updateStickyAncestor(node, popoverOpened) {
|
package/custom-elements.json
CHANGED
|
@@ -4967,6 +4967,21 @@
|
|
|
4967
4967
|
}
|
|
4968
4968
|
]
|
|
4969
4969
|
},
|
|
4970
|
+
{
|
|
4971
|
+
"name": "d2l-custom-form-element-container",
|
|
4972
|
+
"path": "./components/form/demo/custom-form-element-container.js",
|
|
4973
|
+
"properties": [
|
|
4974
|
+
{
|
|
4975
|
+
"name": "styles",
|
|
4976
|
+
"type": "CSSResult[]",
|
|
4977
|
+
"default": "[\"inputStyles\",\"inputLabelStyles\"]"
|
|
4978
|
+
},
|
|
4979
|
+
{
|
|
4980
|
+
"name": "isCustomFormElementContainer",
|
|
4981
|
+
"type": "boolean"
|
|
4982
|
+
}
|
|
4983
|
+
]
|
|
4984
|
+
},
|
|
4970
4985
|
{
|
|
4971
4986
|
"name": "d2l-form-demo",
|
|
4972
4987
|
"path": "./components/form/demo/form-demo.js"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.255.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",
|