@brightspace-ui/core 3.198.0 → 3.199.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.
@@ -78,6 +78,9 @@ export const radioStyles = css`
78
78
  .d2l-input-radio-label-disabled:not(.d2l-input-radio-label-disabled-tooltip) > input[type="radio"] {
79
79
  opacity: 1;
80
80
  }
81
+ .d2l-input-radio.d2l-input-radio-disabled-tooltip.d2l-hovering,
82
+ .d2l-input-radio.d2l-input-radio-disabled-tooltip:hover,
83
+ .d2l-input-radio.d2l-input-radio-disabled-tooltip:focus,
81
84
  .d2l-input-radio-label-disabled-tooltip .d2l-input-radio.d2l-hovering,
82
85
  .d2l-input-radio-label-disabled-tooltip .d2l-input-radio:hover,
83
86
  .d2l-input-radio-label-disabled-tooltip .d2l-input-radio:focus,
@@ -85,7 +88,10 @@ export const radioStyles = css`
85
88
  .d2l-input-radio-label-disabled-tooltip .d2l-input-radio-label > input[type="radio"]:focus {
86
89
  background-blend-mode: lighten;
87
90
  background-color: color-mix(in srgb, var(--d2l-color-regolith) 50%, transparent); /* mock background opacity */
91
+ border-color: var(--d2l-input-radio-border-color-hover-focus, var(--d2l-color-celestine));
92
+ border-width: 2px;
88
93
  opacity: 1;
94
+ outline: none;
89
95
  }
90
96
 
91
97
  .d2l-input-radio-label:last-of-type {
@@ -157,9 +157,12 @@
157
157
  <d2l-list-item selectable key="2" selected label="Engineering Materials for Energy Systems">
158
158
  <d2l-list-item-content>Engineering Materials for Energy Systems</d2l-list-item-content>
159
159
  </d2l-list-item>
160
- <d2l-list-item selectable key="3" label="Geomorphology and GIS">
160
+ <d2l-list-item selectable selection-disabled key="3" label="Geomorphology and GIS">
161
161
  <d2l-list-item-content>Geomorphology and GIS</d2l-list-item-content>
162
162
  </d2l-list-item>
163
+ <d2l-list-item selectable selection-disabled selection-disabled-tooltip="This option is not currently available" key="5" label="Fermentation Biology">
164
+ <d2l-list-item-content>Fermentation Biology</d2l-list-item-content>
165
+ </d2l-list-item>
163
166
  </d2l-list>
164
167
  </template>
165
168
  </d2l-demo-snippet>
@@ -185,7 +188,7 @@
185
188
  <d2l-list-item selectable key="4" label="Introductory Differential Equations">
186
189
  <d2l-list-item-content>Introductory Differential Equations</d2l-list-item-content>
187
190
  </d2l-list-item>
188
- <d2l-list-item selectable key="5" label="Fermentation Biology">
191
+ <d2l-list-item selectable selection-disabled selection-disabled-tooltip="This option is not currently available" key="5" label="Fermentation Biology">
189
192
  <d2l-list-item-content>Fermentation Biology</d2l-list-item-content>
190
193
  </d2l-list-item>
191
194
  </d2l-list>
@@ -1,6 +1,7 @@
1
1
  import '../inputs/input-checkbox.js';
2
- import { css, html, LitElement } from 'lit';
2
+ import { css, html, LitElement, nothing } from 'lit';
3
3
  import { classMap } from 'lit/directives/class-map.js';
4
+ import { getUniqueId } from '../../helpers/uniqueId.js';
4
5
  import { ifDefined } from 'lit/directives/if-defined.js';
5
6
  import { LabelledMixin } from '../../mixins/labelled/labelled-mixin.js';
6
7
  import { radioStyles } from '../inputs/input-radio-styles.js';
@@ -65,6 +66,10 @@ class Input extends SkeletonMixin(LabelledMixin(LitElement)) {
65
66
  this._indeterminate = false;
66
67
  }
67
68
 
69
+ get focusDisabled() {
70
+ return this.disabled && !this._disabledTooltip;
71
+ }
72
+
68
73
  connectedCallback() {
69
74
  super.connectedCallback();
70
75
  // delay subscription otherwise import/upgrade order can cause selection mixin to miss event
@@ -99,19 +104,25 @@ class Input extends SkeletonMixin(LabelledMixin(LitElement)) {
99
104
  'd2l-selection-input-radio': true,
100
105
  'd2l-skeletize': true,
101
106
  'd2l-hovering': this.hovering,
102
- 'd2l-disabled': this.disabled
107
+ 'd2l-disabled': this.disabled,
108
+ 'd2l-input-radio-disabled-tooltip': this.disabled && this._disabledTooltip
103
109
  };
110
+ const disabledTooltip = this.disabled && this._disabledTooltip ?
111
+ html`<d2l-tooltip align="start" class="vdiff-include" for="${this.#inputId}" ?force-show="${this.hovering}" position="top">${this._disabledTooltip}</d2l-tooltip>` :
112
+ nothing;
104
113
  return html`
105
114
  <div
106
115
  aria-disabled="${ifDefined(this.disabled)}"
107
116
  aria-label="${this.label}"
108
117
  aria-checked="${this.selected ? 'true' : 'false'}"
109
118
  class="${classMap(radioClasses)}"
119
+ id="${this.#inputId}"
110
120
  @click="${this._handleRadioClick}"
111
121
  @keydown="${this._handleRadioKeyDown}"
112
122
  @keyup="${this._handleRadioKeyUp}"
113
123
  role="radio"
114
- tabindex="${ifDefined(this.disabled ? undefined : 0)}"></div>
124
+ tabindex="${ifDefined(this.focusDisabled ? undefined : 0)}"></div>
125
+ ${disabledTooltip}
115
126
  `;
116
127
  } else {
117
128
  return html`
@@ -151,6 +162,8 @@ class Input extends SkeletonMixin(LabelledMixin(LitElement)) {
151
162
  if (elem) elem.focus();
152
163
  }
153
164
 
165
+ #inputId = getUniqueId();
166
+
154
167
  _handleCheckboxChange(e) {
155
168
  e.stopPropagation();
156
169
  this.selected = e.target.checked;
@@ -167,7 +180,8 @@ class Input extends SkeletonMixin(LabelledMixin(LitElement)) {
167
180
  }
168
181
 
169
182
  _handleRadioKeyUp(e) {
170
- if (e.keyCode === keyCodes.SPACE) this.selected = !this.selected;
183
+ if (e.keyCode !== keyCodes.SPACE || this.disabled) return;
184
+ this.selected = !this.selected;
171
185
  }
172
186
 
173
187
  }
@@ -183,7 +183,7 @@ export const SelectionMixin = superclass => class extends CollectionMixin(superc
183
183
  while (focusable) {
184
184
  if (focusable.classList.contains('d2l-selection-input-radio')) {
185
185
  const selectionInput = focusable.getRootNode().host;
186
- if (!selectionInput.disabled && this._selectionSelectables.has(selectionInput)) return selectionInput;
186
+ if (!selectionInput.focusDisabled && this._selectionSelectables.has(selectionInput)) return selectionInput;
187
187
  }
188
188
 
189
189
  if (!isComposedAncestor(this, focusable)) return null;
@@ -206,7 +206,7 @@ export const SelectionMixin = superclass => class extends CollectionMixin(superc
206
206
  }
207
207
 
208
208
  if (selectionInput) {
209
- selectionInput.selected = true;
209
+ if (!selectionInput.disabled) selectionInput.selected = true;
210
210
  selectionInput.focus();
211
211
  }
212
212
 
@@ -12979,6 +12979,9 @@
12979
12979
  "description": "REQUIRED: Key for the selectable",
12980
12980
  "type": "string"
12981
12981
  },
12982
+ {
12983
+ "name": "focusDisabled"
12984
+ },
12982
12985
  {
12983
12986
  "name": "selected",
12984
12987
  "attribute": "selected",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.198.0",
3
+ "version": "3.199.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",