@brightspace-ui/core 3.338.0 → 3.338.2
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.
|
@@ -3,7 +3,6 @@ import '../icons/icon.js';
|
|
|
3
3
|
import '../tooltip/tooltip.js';
|
|
4
4
|
import { css, html, LitElement, nothing } from 'lit';
|
|
5
5
|
import { buttonStyles } from './button-styles.js';
|
|
6
|
-
import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
|
|
7
6
|
import { getUniqueId } from '../../helpers/uniqueId.js';
|
|
8
7
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
9
8
|
import { labelStyles } from '../typography/styles.js';
|
|
@@ -13,7 +12,7 @@ import { PropertyRequiredMixin } from '../../mixins/property-required/property-r
|
|
|
13
12
|
/**
|
|
14
13
|
* A navigation control for moving sequentially through a set of items.
|
|
15
14
|
*/
|
|
16
|
-
class ButtonIterator extends
|
|
15
|
+
class ButtonIterator extends PropertyRequiredMixin(LocalizeCoreElement(LitElement)) {
|
|
17
16
|
|
|
18
17
|
static properties = {
|
|
19
18
|
/**
|
|
@@ -84,11 +83,11 @@ class ButtonIterator extends FocusMixin(PropertyRequiredMixin(LocalizeCoreElemen
|
|
|
84
83
|
min-width: calc(2rem + 2px);
|
|
85
84
|
padding: 0;
|
|
86
85
|
}
|
|
87
|
-
button:not([disabled]):hover,
|
|
88
|
-
button:not([disabled]):focus {
|
|
86
|
+
button:not([aria-disabled]):hover,
|
|
87
|
+
button:not([aria-disabled]):focus {
|
|
89
88
|
background-color: var(--d2l-theme-background-color-interactive-secondary-hover);
|
|
90
89
|
}
|
|
91
|
-
button[disabled] {
|
|
90
|
+
button[aria-disabled] {
|
|
92
91
|
cursor: default;
|
|
93
92
|
opacity: var(--d2l-theme-opacity-disabled-control);
|
|
94
93
|
}
|
|
@@ -104,10 +103,6 @@ class ButtonIterator extends FocusMixin(PropertyRequiredMixin(LocalizeCoreElemen
|
|
|
104
103
|
this.previousText = '';
|
|
105
104
|
}
|
|
106
105
|
|
|
107
|
-
static get focusElementSelector() {
|
|
108
|
-
return 'button:not([disabled])';
|
|
109
|
-
}
|
|
110
|
-
|
|
111
106
|
render() {
|
|
112
107
|
const nextText = this.nextText ? this.nextText : this.localizeCommon('navigation:next:title');
|
|
113
108
|
if (this.nextOnly) {
|
|
@@ -129,13 +124,21 @@ class ButtonIterator extends FocusMixin(PropertyRequiredMixin(LocalizeCoreElemen
|
|
|
129
124
|
`;
|
|
130
125
|
}
|
|
131
126
|
|
|
127
|
+
focus() {
|
|
128
|
+
if (!this.previousDisabled || this.nextDisabled) {
|
|
129
|
+
this.shadowRoot.querySelector('button.previous').focus();
|
|
130
|
+
} else {
|
|
131
|
+
this.shadowRoot.querySelector('button.next').focus();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
132
135
|
#descriptionId = getUniqueId();
|
|
133
136
|
#previousId = getUniqueId();
|
|
134
137
|
#nextId = getUniqueId();
|
|
135
138
|
|
|
136
139
|
#handleButtonClick(e) {
|
|
137
140
|
const button = e.currentTarget;
|
|
138
|
-
if (button.disabled) {
|
|
141
|
+
if (button.hasAttribute('aria-disabled')) {
|
|
139
142
|
return;
|
|
140
143
|
}
|
|
141
144
|
e.stopPropagation();
|
|
@@ -149,25 +152,21 @@ class ButtonIterator extends FocusMixin(PropertyRequiredMixin(LocalizeCoreElemen
|
|
|
149
152
|
}
|
|
150
153
|
|
|
151
154
|
#renderButton(id, className, icon, text, descriptionId, disabled) {
|
|
152
|
-
const ariaLabel = disabled ? text : undefined;
|
|
153
|
-
const tooltip = !disabled ? html`
|
|
154
|
-
<d2l-tooltip
|
|
155
|
-
class="vdiff-target"
|
|
156
|
-
for="${id}"
|
|
157
|
-
for-type="label"
|
|
158
|
-
position="bottom">${text}</d2l-tooltip>` : nothing;
|
|
159
155
|
return html`
|
|
160
156
|
<button
|
|
161
157
|
aria-describedby="${ifDefined(descriptionId)}"
|
|
162
|
-
aria-
|
|
158
|
+
aria-disabled="${ifDefined(disabled ? 'true' : undefined)}"
|
|
163
159
|
class="${className}"
|
|
164
160
|
@click="${this.#handleButtonClick}"
|
|
165
|
-
?disabled="${disabled}"
|
|
166
161
|
id="${id}"
|
|
167
162
|
type="button">
|
|
168
163
|
<d2l-icon icon="${icon}"></d2l-icon>
|
|
169
164
|
</button>
|
|
170
|
-
|
|
165
|
+
<d2l-tooltip
|
|
166
|
+
class="vdiff-target"
|
|
167
|
+
for="${id}"
|
|
168
|
+
for-type="label"
|
|
169
|
+
position="bottom">${text}</d2l-tooltip>
|
|
171
170
|
`;
|
|
172
171
|
}
|
|
173
172
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import '../colors/colors.js';
|
|
2
|
-
import { css, html, LitElement } from 'lit';
|
|
2
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
3
3
|
import { bodySmallStyles } from '../typography/styles.js';
|
|
4
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
5
4
|
import { getOverflowDeclarations } from '../../helpers/overflow.js';
|
|
6
5
|
import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
|
|
7
|
-
import { styleMap } from 'lit/directives/style-map.js';
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* A component for a "summary item" child component that describes the content in a collapsible panel.
|
|
@@ -35,9 +33,6 @@ class CollapsiblePanelSummaryItem extends SkeletonMixin(LitElement) {
|
|
|
35
33
|
.d2l-body-small {
|
|
36
34
|
line-height: 1.2rem;
|
|
37
35
|
}
|
|
38
|
-
p.truncate {
|
|
39
|
-
${getOverflowDeclarations({ lines: 1 })}
|
|
40
|
-
}
|
|
41
36
|
`];
|
|
42
37
|
|
|
43
38
|
constructor() {
|
|
@@ -47,13 +42,8 @@ class CollapsiblePanelSummaryItem extends SkeletonMixin(LitElement) {
|
|
|
47
42
|
}
|
|
48
43
|
|
|
49
44
|
render() {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
'd2l-skeletize': true,
|
|
53
|
-
'truncate': this.lines > 0
|
|
54
|
-
};
|
|
55
|
-
const styles = (this.lines > 0) ? { '-webkit-line-clamp': this.lines } : {};
|
|
56
|
-
return html`<p class="${classMap(classes)}" style="${styleMap(styles)}">${this.text}</p>`;
|
|
45
|
+
const styles = this.lines ? getOverflowDeclarations({ lines: this.lines }) : null;
|
|
46
|
+
return html`<p class="d2l-body-small d2l-skeletize" style="${styles ?? nothing}">${this.text}</p>`;
|
|
57
47
|
}
|
|
58
48
|
}
|
|
59
49
|
|
package/components/link/link.js
CHANGED
|
@@ -2,15 +2,14 @@ import '../colors/colors.js';
|
|
|
2
2
|
import '../icons/icon.js';
|
|
3
3
|
import '../tooltip/tooltip.js';
|
|
4
4
|
import { css, html, LitElement, nothing } from 'lit';
|
|
5
|
-
import { getOverflowDeclarations, overflowEllipsisDeclarations } from '../../helpers/overflow.js';
|
|
6
5
|
import { _generateLinkStyles } from './link-styles.js';
|
|
7
6
|
import { classMap } from 'lit/directives/class-map.js';
|
|
8
7
|
import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
|
|
8
|
+
import { getOverflowDeclarations } from '../../helpers/overflow.js';
|
|
9
9
|
import { getUniqueId } from '../../helpers/uniqueId.js';
|
|
10
10
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
11
11
|
import { LocalizeCoreElement } from '../../helpers/localize-core-element.js';
|
|
12
12
|
import { offscreenStyles } from '../offscreen/offscreen.js';
|
|
13
|
-
import { styleMap } from 'lit/directives/style-map.js';
|
|
14
13
|
|
|
15
14
|
export const linkStyles = _generateLinkStyles('.d2l-link', true);
|
|
16
15
|
|
|
@@ -90,12 +89,6 @@ class Link extends LocalizeCoreElement(FocusMixin(LitElement)) {
|
|
|
90
89
|
align-items: baseline;
|
|
91
90
|
display: flex;
|
|
92
91
|
}
|
|
93
|
-
a span.truncate {
|
|
94
|
-
${getOverflowDeclarations({ lines: 1 })}
|
|
95
|
-
}
|
|
96
|
-
a span.truncate-one {
|
|
97
|
-
${overflowEllipsisDeclarations}
|
|
98
|
-
}
|
|
99
92
|
#new-window {
|
|
100
93
|
line-height: 0;
|
|
101
94
|
white-space: nowrap;
|
|
@@ -157,12 +150,7 @@ class Link extends LocalizeCoreElement(FocusMixin(LitElement)) {
|
|
|
157
150
|
'd2l-link-main': this.main,
|
|
158
151
|
'd2l-link-small': this.small
|
|
159
152
|
};
|
|
160
|
-
const
|
|
161
|
-
'd2l-link-content': true,
|
|
162
|
-
'truncate': this.lines > 1,
|
|
163
|
-
'truncate-one': this.lines === 1
|
|
164
|
-
};
|
|
165
|
-
const styles = { webkitLineClamp: this.lines || null };
|
|
153
|
+
const styles = this.lines ? getOverflowDeclarations({ lines: this.lines }) : null;
|
|
166
154
|
const newWindowElements = (this.target === '_blank')
|
|
167
155
|
? html`<span id="new-window"><span style="font-size: 0;"> </span><d2l-icon icon="tier1:new-window"></d2l-icon></span><span class="d2l-offscreen">${this.localize('components.link.open-in-new-window')}</span>`
|
|
168
156
|
: nothing;
|
|
@@ -186,8 +174,8 @@ class Link extends LocalizeCoreElement(FocusMixin(LitElement)) {
|
|
|
186
174
|
tabindex="${ifDefined(this.disabled && this.disabledTooltip ? 0 : undefined)}"
|
|
187
175
|
target="${ifDefined(this.target)}"
|
|
188
176
|
><span
|
|
189
|
-
class="
|
|
190
|
-
style="${
|
|
177
|
+
class="d2l-link-content"
|
|
178
|
+
style="${styles ?? nothing}"><slot></slot></span>${newWindowElements}</a>${disabledTooltip}`;
|
|
191
179
|
}
|
|
192
180
|
|
|
193
181
|
#linkId = getUniqueId();
|
package/helpers/overflow.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { set } from './template-tags.js';
|
|
2
2
|
import { unsafeCSS } from 'lit';
|
|
3
3
|
|
|
4
|
-
export const overflowHiddenDeclarations = getOverflowDeclarations({});
|
|
5
|
-
export const overflowEllipsisDeclarations = getOverflowDeclarations({ textOverflow: 'ellipsis' });
|
|
4
|
+
export const overflowHiddenDeclarations = getOverflowDeclarations({ lines: 0 });
|
|
5
|
+
export const overflowEllipsisDeclarations = getOverflowDeclarations({ textOverflow: 'ellipsis', lines: 0 });
|
|
6
6
|
|
|
7
|
-
export function getOverflowDeclarations({ textOverflow = '', lines =
|
|
7
|
+
export function getOverflowDeclarations({ textOverflow = '', lines = 1, lit = true } = {}) {
|
|
8
8
|
if (!arguments.length) return overflowHiddenDeclarations;
|
|
9
|
+
if (arguments[0].lines === 1) return overflowEllipsisDeclarations;
|
|
9
10
|
|
|
10
11
|
const declarations = set`
|
|
11
12
|
min-width: 0; /* clamps width of flex items */
|
|
12
13
|
overflow-x: clip;
|
|
13
|
-
${lines
|
|
14
|
+
${lines > 1 || lines.constructor === String
|
|
14
15
|
? set`
|
|
15
16
|
display: -webkit-box;
|
|
16
17
|
overflow-clip-margin: 0.2em;
|
|
17
18
|
overflow-wrap: anywhere;
|
|
18
19
|
overflow-y: clip;
|
|
19
|
-
text-overflow: ${textOverflow || 'ellipsis'};
|
|
20
20
|
-webkit-box-orient: vertical;
|
|
21
21
|
-webkit-line-clamp: ${lines};`
|
|
22
22
|
: set`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "3.338.
|
|
3
|
+
"version": "3.338.2",
|
|
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",
|