@brightspace-ui/core 3.198.0 → 3.200.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.
- package/components/inputs/input-radio-styles.js +6 -0
- package/components/list/demo/list-item-actions.html +5 -2
- package/components/list/list-item-checkbox-mixin.js +1 -1
- package/components/selection/README.md +1 -0
- package/components/selection/selection-input.js +24 -7
- package/components/selection/selection-mixin.js +2 -2
- package/custom-elements.json +14 -0
- package/package.json +1 -1
|
@@ -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>
|
|
@@ -169,7 +169,7 @@ export const ListItemCheckboxMixin = superclass => class extends SkeletonMixin(s
|
|
|
169
169
|
<d2l-selection-input
|
|
170
170
|
@d2l-selection-change="${this._onCheckboxChange}"
|
|
171
171
|
?disabled="${this.selectionDisabled}"
|
|
172
|
-
|
|
172
|
+
disabled-tooltip=${this.selectionDisabledTooltip}
|
|
173
173
|
.hovering="${this._hoveringSelection}"
|
|
174
174
|
id="${this._checkboxId}"
|
|
175
175
|
?_indeterminate="${this.selectionInfo.state === SelectionInfo.states.some}"
|
|
@@ -247,6 +247,7 @@ Note: `d2l-list-item` already provides a selection input for selectable list ite
|
|
|
247
247
|
| `label` | String | Accessible hidden label for the input. |
|
|
248
248
|
| `labelled-by` | String | Id reference to the accessible label for the input. **Note:** if specified, it must reference an element in the same DOM context. |
|
|
249
249
|
| `disabled` | Boolean | Disables the input element(checkbox/radio btn). |
|
|
250
|
+
| `disabled-tooltip` | String | Tooltip text when disabled. |
|
|
250
251
|
| `selected` | Boolean | State of the input. |
|
|
251
252
|
|
|
252
253
|
### Events
|
|
@@ -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';
|
|
@@ -29,6 +30,11 @@ class Input extends SkeletonMixin(LabelledMixin(LitElement)) {
|
|
|
29
30
|
* @type {boolean}
|
|
30
31
|
*/
|
|
31
32
|
disabled: { type: Boolean, reflect: true },
|
|
33
|
+
/**
|
|
34
|
+
* Tooltip text when disabled
|
|
35
|
+
* @type {string}
|
|
36
|
+
*/
|
|
37
|
+
disabledTooltip: { type: String, attribute: 'disabled-tooltip' },
|
|
32
38
|
/**
|
|
33
39
|
* Private. Force hovering state of input
|
|
34
40
|
* @ignore
|
|
@@ -40,8 +46,6 @@ class Input extends SkeletonMixin(LabelledMixin(LitElement)) {
|
|
|
40
46
|
* @type {string}
|
|
41
47
|
*/
|
|
42
48
|
key: { type: String },
|
|
43
|
-
/* passthrough for list-item */
|
|
44
|
-
_disabledTooltip: { state: true },
|
|
45
49
|
_indeterminate: { type: Boolean },
|
|
46
50
|
_provider: { type: Object }
|
|
47
51
|
};
|
|
@@ -65,6 +69,10 @@ class Input extends SkeletonMixin(LabelledMixin(LitElement)) {
|
|
|
65
69
|
this._indeterminate = false;
|
|
66
70
|
}
|
|
67
71
|
|
|
72
|
+
get focusDisabled() {
|
|
73
|
+
return this.disabled && !this.disabledTooltip;
|
|
74
|
+
}
|
|
75
|
+
|
|
68
76
|
connectedCallback() {
|
|
69
77
|
super.connectedCallback();
|
|
70
78
|
// delay subscription otherwise import/upgrade order can cause selection mixin to miss event
|
|
@@ -99,19 +107,25 @@ class Input extends SkeletonMixin(LabelledMixin(LitElement)) {
|
|
|
99
107
|
'd2l-selection-input-radio': true,
|
|
100
108
|
'd2l-skeletize': true,
|
|
101
109
|
'd2l-hovering': this.hovering,
|
|
102
|
-
'd2l-disabled': this.disabled
|
|
110
|
+
'd2l-disabled': this.disabled,
|
|
111
|
+
'd2l-input-radio-disabled-tooltip': this.disabled && this.disabledTooltip
|
|
103
112
|
};
|
|
113
|
+
const disabledTooltip = this.disabled && this.disabledTooltip ?
|
|
114
|
+
html`<d2l-tooltip align="start" class="vdiff-include" for="${this.#inputId}" ?force-show="${this.hovering}" position="top">${this.disabledTooltip}</d2l-tooltip>` :
|
|
115
|
+
nothing;
|
|
104
116
|
return html`
|
|
105
117
|
<div
|
|
106
118
|
aria-disabled="${ifDefined(this.disabled)}"
|
|
107
119
|
aria-label="${this.label}"
|
|
108
120
|
aria-checked="${this.selected ? 'true' : 'false'}"
|
|
109
121
|
class="${classMap(radioClasses)}"
|
|
122
|
+
id="${this.#inputId}"
|
|
110
123
|
@click="${this._handleRadioClick}"
|
|
111
124
|
@keydown="${this._handleRadioKeyDown}"
|
|
112
125
|
@keyup="${this._handleRadioKeyUp}"
|
|
113
126
|
role="radio"
|
|
114
|
-
tabindex="${ifDefined(this.
|
|
127
|
+
tabindex="${ifDefined(this.focusDisabled ? undefined : 0)}"></div>
|
|
128
|
+
${disabledTooltip}
|
|
115
129
|
`;
|
|
116
130
|
} else {
|
|
117
131
|
return html`
|
|
@@ -122,7 +136,7 @@ class Input extends SkeletonMixin(LabelledMixin(LitElement)) {
|
|
|
122
136
|
?checked="${this.selected}"
|
|
123
137
|
class="${ifDefined(this.hovering ? 'd2l-hovering' : undefined)}"
|
|
124
138
|
?disabled="${this.disabled}"
|
|
125
|
-
disabled-tooltip="${ifDefined(this.
|
|
139
|
+
disabled-tooltip="${ifDefined(this.disabledTooltip)}"
|
|
126
140
|
?indeterminate="${this._indeterminate}"
|
|
127
141
|
?skeleton="${this.skeleton}">
|
|
128
142
|
</d2l-input-checkbox>
|
|
@@ -151,6 +165,8 @@ class Input extends SkeletonMixin(LabelledMixin(LitElement)) {
|
|
|
151
165
|
if (elem) elem.focus();
|
|
152
166
|
}
|
|
153
167
|
|
|
168
|
+
#inputId = getUniqueId();
|
|
169
|
+
|
|
154
170
|
_handleCheckboxChange(e) {
|
|
155
171
|
e.stopPropagation();
|
|
156
172
|
this.selected = e.target.checked;
|
|
@@ -167,7 +183,8 @@ class Input extends SkeletonMixin(LabelledMixin(LitElement)) {
|
|
|
167
183
|
}
|
|
168
184
|
|
|
169
185
|
_handleRadioKeyUp(e) {
|
|
170
|
-
if (e.keyCode
|
|
186
|
+
if (e.keyCode !== keyCodes.SPACE || this.disabled) return;
|
|
187
|
+
this.selected = !this.selected;
|
|
171
188
|
}
|
|
172
189
|
|
|
173
190
|
}
|
|
@@ -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.
|
|
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
|
|
package/custom-elements.json
CHANGED
|
@@ -12939,6 +12939,11 @@
|
|
|
12939
12939
|
"description": "Disables the input",
|
|
12940
12940
|
"type": "boolean"
|
|
12941
12941
|
},
|
|
12942
|
+
{
|
|
12943
|
+
"name": "disabled-tooltip",
|
|
12944
|
+
"description": "Tooltip text when disabled",
|
|
12945
|
+
"type": "string"
|
|
12946
|
+
},
|
|
12942
12947
|
{
|
|
12943
12948
|
"name": "key",
|
|
12944
12949
|
"description": "REQUIRED: Key for the selectable",
|
|
@@ -12973,12 +12978,21 @@
|
|
|
12973
12978
|
"description": "Disables the input",
|
|
12974
12979
|
"type": "boolean"
|
|
12975
12980
|
},
|
|
12981
|
+
{
|
|
12982
|
+
"name": "disabledTooltip",
|
|
12983
|
+
"attribute": "disabled-tooltip",
|
|
12984
|
+
"description": "Tooltip text when disabled",
|
|
12985
|
+
"type": "string"
|
|
12986
|
+
},
|
|
12976
12987
|
{
|
|
12977
12988
|
"name": "key",
|
|
12978
12989
|
"attribute": "key",
|
|
12979
12990
|
"description": "REQUIRED: Key for the selectable",
|
|
12980
12991
|
"type": "string"
|
|
12981
12992
|
},
|
|
12993
|
+
{
|
|
12994
|
+
"name": "focusDisabled"
|
|
12995
|
+
},
|
|
12982
12996
|
{
|
|
12983
12997
|
"name": "selected",
|
|
12984
12998
|
"attribute": "selected",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.200.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",
|