@brightspace-ui/core 2.80.1 → 2.80.3

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.
@@ -52,7 +52,7 @@ class CollapsiblePanel extends RtlMixin(LitElement) {
52
52
  */
53
53
  expanded: { type: Boolean, reflect: true },
54
54
  /**
55
- * REQUIRED: Label describing the contents of the header.
55
+ * Optional label describing the contents of the header.
56
56
  * Used for screen readers.
57
57
  * @type {string}
58
58
  */
@@ -59,6 +59,19 @@
59
59
  </template>
60
60
  </d2l-demo-snippet>
61
61
 
62
+ <h2>Object Property List: Hidden items</h2>
63
+
64
+ <d2l-demo-snippet overflow-hidden>
65
+ <template>
66
+ <d2l-object-property-list>
67
+ <d2l-object-property-list-item text="Item 1"></d2l-object-property-list-item>
68
+ <d2l-object-property-list-item text="Item 2 (Hidden)" hidden></d2l-object-property-list-item>
69
+ <d2l-object-property-list-item text="Item 3"></d2l-object-property-list-item>
70
+ <d2l-object-property-list-item text="Item 4 (Hidden)" hidden></d2l-object-property-list-item>
71
+ </d2l-object-property-list>
72
+ </template>
73
+ </d2l-demo-snippet>
74
+
62
75
  <h2>Object Property List: No external whitespace (still contains internal whitespace in the component renderers)</h2>
63
76
 
64
77
  <d2l-demo-snippet overflow-hidden>
@@ -11,6 +11,10 @@ import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
11
11
  export class ObjectPropertyListItem extends SkeletonMixin(LitElement) {
12
12
  static get properties() {
13
13
  return {
14
+ /**
15
+ * @ignore
16
+ */
17
+ hidden: { type: Boolean },
14
18
  /**
15
19
  * Name of an optional icon to display
16
20
  * @type {string}
@@ -21,6 +25,7 @@ export class ObjectPropertyListItem extends SkeletonMixin(LitElement) {
21
25
  * @type {string}
22
26
  */
23
27
  text: { type: String },
28
+ _showSeparator: { state: true },
24
29
  };
25
30
  }
26
31
 
@@ -29,12 +34,14 @@ export class ObjectPropertyListItem extends SkeletonMixin(LitElement) {
29
34
  :host {
30
35
  vertical-align: middle;
31
36
  }
37
+ :host([hidden]) {
38
+ display: none;
39
+ }
32
40
  d2l-icon {
33
41
  height: 1.2857em; /* 18px desired height at main font size (14px), but using em to scale properly at smaller breakpoint. */
34
42
  width: 1.2857em;
35
43
  }
36
44
  .separator {
37
- display: var(--d2l-object-property-list-item-separator-display, inline);
38
45
  margin: 0 -0.05rem; /* 10px desired margin, subtract 5px arbitrary whitespace and 6px whitespace inside bullet icon. */
39
46
  }
40
47
  .separator d2l-icon {
@@ -57,6 +64,11 @@ export class ObjectPropertyListItem extends SkeletonMixin(LitElement) {
57
64
  `];
58
65
  }
59
66
 
67
+ constructor() {
68
+ super();
69
+ this._showSeparator = true;
70
+ }
71
+
60
72
  render() {
61
73
  return html`
62
74
  ${this._renderIcon()}
@@ -65,17 +77,27 @@ export class ObjectPropertyListItem extends SkeletonMixin(LitElement) {
65
77
  `;
66
78
  }
67
79
 
80
+ updated(changedProperties) {
81
+ super.updated(changedProperties);
82
+ if (changedProperties.has('hidden')) this._onHidden();
83
+ }
84
+
85
+ _onHidden() {
86
+ /** Dispatched when the visibility of the item changes */
87
+ this.dispatchEvent(new CustomEvent('d2l-object-property-list-item-visibility-change', { bubbles: true, composed: true }));
88
+ }
89
+
68
90
  _renderIcon() {
69
91
  return this.icon && !this.skeleton ? html`<d2l-icon icon="${this.icon}" class="item-icon"></d2l-icon>` : nothing;
70
92
  }
71
93
 
72
94
  _renderSeparator() {
73
- return html`
95
+ return this._showSeparator ? html`
74
96
  <span class="separator">
75
97
  <d2l-screen-reader-pause></d2l-screen-reader-pause>
76
98
  <d2l-icon icon="tier1:bullet"></d2l-icon>
77
99
  </span>
78
- `;
100
+ ` : nothing;
79
101
  }
80
102
 
81
103
  _renderText() {
@@ -28,9 +28,6 @@ class ObjectPropertyList extends LocalizeCoreElement(SkeletonMixin(LitElement))
28
28
  :host([hidden]) {
29
29
  display: none;
30
30
  }
31
- ::slotted(:last-child), slot :last-child {
32
- --d2l-object-property-list-item-separator-display: none;
33
- }
34
31
  ::slotted([slot="status"]) {
35
32
  display: none;
36
33
  }
@@ -41,6 +38,13 @@ class ObjectPropertyList extends LocalizeCoreElement(SkeletonMixin(LitElement))
41
38
  `];
42
39
  }
43
40
 
41
+ firstUpdated() {
42
+ this.addEventListener('d2l-object-property-list-item-visibility-change', () => this._onItemsChanged());
43
+
44
+ const slot = this.shadowRoot.querySelector('slot:not([name])');
45
+ if (slot.childElementCount) this._setItemSeparatorVisibility(slot);
46
+ }
47
+
44
48
  render() {
45
49
  const slotContents = this.skeleton && this.skeletonCount > 0 ? [...Array(this.skeletonCount)].map(() => html`
46
50
  <d2l-object-property-list-item text="${this.localize('components.object-property-list.item-placeholder-text')}" skeleton></d2l-object-property-list-item>
@@ -50,10 +54,24 @@ class ObjectPropertyList extends LocalizeCoreElement(SkeletonMixin(LitElement))
50
54
  <div class="d2l-body-small">
51
55
  <slot name="status"></slot>
52
56
  <d2l-screen-reader-pause></d2l-screen-reader-pause>
53
- <slot>${slotContents}</slot>
57
+ <slot @slotchange="${this._onItemsChanged}">${slotContents}</slot>
54
58
  </div>
55
59
  `;
56
60
  }
61
+
62
+ _onItemsChanged(e) {
63
+ const slot = e?.target || this.shadowRoot.querySelector('slot:not([name])');
64
+ this._setItemSeparatorVisibility(slot);
65
+ }
66
+
67
+ _setItemSeparatorVisibility(slot) {
68
+ const slottedElements = slot.assignedElements();
69
+ const elements = slottedElements.length ? slottedElements : [ ...slot.children ];
70
+ const filtered = elements.filter(item => item.tagName?.toLowerCase().includes('d2l-object-property-list-') && !item.hidden);
71
+
72
+ const lastIndex = filtered.length - 1;
73
+ filtered.forEach((item, i) => item._showSeparator = (i !== lastIndex));
74
+ }
57
75
  }
58
76
 
59
77
  customElements.define('d2l-object-property-list', ObjectPropertyList);
@@ -1078,7 +1078,7 @@
1078
1078
  },
1079
1079
  {
1080
1080
  "name": "expand-collapse-label",
1081
- "description": "REQUIRED: Label describing the contents of the header.\nUsed for screen readers.",
1081
+ "description": "Optional label describing the contents of the header.\nUsed for screen readers.",
1082
1082
  "type": "string"
1083
1083
  },
1084
1084
  {
@@ -1128,7 +1128,7 @@
1128
1128
  {
1129
1129
  "name": "expandCollapseLabel",
1130
1130
  "attribute": "expand-collapse-label",
1131
- "description": "REQUIRED: Label describing the contents of the header.\nUsed for screen readers.",
1131
+ "description": "Optional label describing the contents of the header.\nUsed for screen readers.",
1132
1132
  "type": "string"
1133
1133
  },
1134
1134
  {
@@ -9498,6 +9498,12 @@
9498
9498
  "type": "boolean",
9499
9499
  "default": "false"
9500
9500
  }
9501
+ ],
9502
+ "events": [
9503
+ {
9504
+ "name": "d2l-object-property-list-item-visibility-change",
9505
+ "description": "Dispatched when the visibility of the item changes"
9506
+ }
9501
9507
  ]
9502
9508
  },
9503
9509
  {
@@ -9542,6 +9548,12 @@
9542
9548
  "type": "boolean",
9543
9549
  "default": "false"
9544
9550
  }
9551
+ ],
9552
+ "events": [
9553
+ {
9554
+ "name": "d2l-object-property-list-item-visibility-change",
9555
+ "description": "Dispatched when the visibility of the item changes"
9556
+ }
9545
9557
  ]
9546
9558
  },
9547
9559
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.80.1",
3
+ "version": "2.80.3",
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",