@brightspace-ui/core 1.220.3 → 1.222.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/count-badge/README.md +2 -2
- package/components/count-badge/count-badge-mixin.js +31 -13
- package/components/dropdown/README.md +1 -0
- package/components/dropdown/dropdown-button-subtle.js +8 -1
- package/components/dropdown/dropdown-content-mixin.js +9 -5
- package/components/dropdown/dropdown-content-styles.js +3 -3
- package/custom-elements.json +15 -4
- package/package.json +1 -1
|
@@ -46,7 +46,7 @@ The `d2l-count-badge` element is a web component to display a number count, depe
|
|
|
46
46
|
| `number` | Number, required | The number to display on the badge. Must be a positive integer. |
|
|
47
47
|
| `size`, default: `small` | String | The size of the badge. Valid options are `"small"` and `"large"`. |
|
|
48
48
|
| `type`, default: `count` | String | The type of the badge. Valid options are `"notification"` and `"count"`. Notification badges are orange and count badges are grey. |
|
|
49
|
-
| `max-digits`, default: `2` when `type="notification"` | Number | Optionally specify a digit limit, after which numbers are truncated. Defaults to two for `"notification"` type and
|
|
49
|
+
| `max-digits`, default: `2` when `type="notification"`, `5` when `type="count"` | Number | Optionally specify a digit limit, after which numbers are truncated. Defaults to two for `"notification"` type and five for `"count"` type. Must be between 1-5.
|
|
50
50
|
| `hide-zero`, default: `false` | Boolean | Optionally choose not to show the count badge when the number is zero. |
|
|
51
51
|
| `text`, required | String | Descriptive text for the badge which will act as an accessible label and tooltip text when tooltips are enabled. |
|
|
52
52
|
| `tab-stop`, default: `false` | Boolean | Optionally choose to make the badge a tab stop. |
|
|
@@ -88,7 +88,7 @@ The `d2l-count-badge-icon` element is a web component to display a number count,
|
|
|
88
88
|
| `icon` | String | Required: [Preset icon key](../icons#preset-icons) (e.g. `tier1:gear`) |
|
|
89
89
|
| `size`, default: `small` | String | The size of the badge. Valid options are `"small"` and `"large"`. |
|
|
90
90
|
| `type`, default: `count` | String | The type of the badge. Valid options are `"notification"` and `"count"`. Notification badges are orange and count badges are grey. |
|
|
91
|
-
| `max-digits`, default: `2` when `type="notification"` | Number | Optionally specify a digit limit, after which numbers are truncated. Defaults to two for `"notification"` type and
|
|
91
|
+
| `max-digits`, default: `2` when `type="notification"`, `5` when `type="count"` | Number | Optionally specify a digit limit, after which numbers are truncated. Defaults to two for `"notification"` type and five for `"count"` type. Must be between 1-5.
|
|
92
92
|
| `hide-zero`, default: `false` | Boolean | Optionally choose not to show the count badge when the number is zero. |
|
|
93
93
|
| `text` | String | REQUIRED: Descriptive text for the badge which will act as an accessible label and tooltip text when tooltips are enabled. |
|
|
94
94
|
| `tab-stop`, default: `false` | Boolean | Optionally choose to make the badge a tab stop. |
|
|
@@ -9,6 +9,8 @@ import { RtlMixin } from '../../mixins/rtl-mixin.js';
|
|
|
9
9
|
import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
|
|
10
10
|
import { styleMap } from 'lit-html/directives/style-map.js';
|
|
11
11
|
|
|
12
|
+
const maxBadgeDigits = 5;
|
|
13
|
+
|
|
12
14
|
export const CountBadgeMixin = superclass => class extends LocalizeCoreElement(SkeletonMixin(RtlMixin(superclass))) {
|
|
13
15
|
|
|
14
16
|
static get properties() {
|
|
@@ -47,7 +49,8 @@ export const CountBadgeMixin = superclass => class extends LocalizeCoreElement(S
|
|
|
47
49
|
attribute: 'hide-zero'
|
|
48
50
|
},
|
|
49
51
|
/**
|
|
50
|
-
* Optionally specify a digit limit, after which numbers are truncated.
|
|
52
|
+
* Optionally specify a digit limit, after which numbers are truncated.
|
|
53
|
+
* Defaults to two for "notification" type and five for "count" type.
|
|
51
54
|
* @type {number}
|
|
52
55
|
*/
|
|
53
56
|
maxDigits: {
|
|
@@ -156,9 +159,20 @@ export const CountBadgeMixin = superclass => class extends LocalizeCoreElement(S
|
|
|
156
159
|
|
|
157
160
|
connectedCallback() {
|
|
158
161
|
super.connectedCallback();
|
|
159
|
-
if (!this.maxDigits
|
|
160
|
-
// default to two digits for notification type
|
|
161
|
-
this.maxDigits = 2;
|
|
162
|
+
if (!this.maxDigits) {
|
|
163
|
+
// default to two digits for notification type, 5 for count
|
|
164
|
+
this.maxDigits = this.type === 'notification' ? 2 : maxBadgeDigits;
|
|
165
|
+
} else if (this.maxDigits > maxBadgeDigits) {
|
|
166
|
+
// limit all badges to 5 digits
|
|
167
|
+
this.maxDigits = maxBadgeDigits;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
updated(changedProperties) {
|
|
172
|
+
super.updated(changedProperties);
|
|
173
|
+
if (changedProperties.get('maxDigits') && this.maxDigits > maxBadgeDigits) {
|
|
174
|
+
// impose a 5 digit maximum to prevent overflows
|
|
175
|
+
this.maxDigits = maxBadgeDigits;
|
|
162
176
|
}
|
|
163
177
|
}
|
|
164
178
|
|
|
@@ -166,15 +180,8 @@ export const CountBadgeMixin = superclass => class extends LocalizeCoreElement(S
|
|
|
166
180
|
return this.hasTooltip ? undefined : this._labelId;
|
|
167
181
|
}
|
|
168
182
|
|
|
169
|
-
|
|
183
|
+
getNumberString() {
|
|
170
184
|
let numberString = `${this.number}`;
|
|
171
|
-
const hideNumber = this.hideZero && this.number === 0;
|
|
172
|
-
if (!numberStyles || numberStyles.visibility !== 'hidden') {
|
|
173
|
-
numberStyles = {
|
|
174
|
-
...numberStyles,
|
|
175
|
-
visibility: hideNumber ? 'hidden' : 'visible'
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
185
|
if (this.maxDigits && this.number.toString().length > this.maxDigits) {
|
|
179
186
|
numberString = `${'9'.repeat(this.maxDigits)}`;
|
|
180
187
|
numberString = formatNumber(parseInt(numberString));
|
|
@@ -183,9 +190,20 @@ export const CountBadgeMixin = superclass => class extends LocalizeCoreElement(S
|
|
|
183
190
|
numberString = formatNumber(numberString);
|
|
184
191
|
}
|
|
185
192
|
|
|
193
|
+
return numberString;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
renderCount(numberStyles) {
|
|
197
|
+
const hideNumber = this.hideZero && this.number === 0;
|
|
198
|
+
if (!numberStyles || numberStyles.visibility !== 'hidden') {
|
|
199
|
+
numberStyles = {
|
|
200
|
+
...numberStyles,
|
|
201
|
+
visibility: hideNumber ? 'hidden' : 'visible'
|
|
202
|
+
};
|
|
203
|
+
}
|
|
186
204
|
return html`
|
|
187
205
|
<div class="d2l-count-badge-number" style=${styleMap(numberStyles)}>
|
|
188
|
-
<div aria-hidden="true">${
|
|
206
|
+
<div aria-hidden="true">${this.getNumberString()}</div>
|
|
189
207
|
</div>
|
|
190
208
|
`;
|
|
191
209
|
}
|
|
@@ -126,6 +126,7 @@ If the dropdown is initially empty when it's opened, the dropdown pointer will n
|
|
|
126
126
|
| `disabled` | Boolean, default: `false` | Disables the dropdown opener |
|
|
127
127
|
| `no-auto-open` | Boolean, default: `false` | Prevents the dropdown from automatically on click or on key press |
|
|
128
128
|
| `open-on-hover` | Boolean, default: `false` | Optionally open dropdown on click or hover action |
|
|
129
|
+
| `h-align` | String | Possible values are undefined (default) or text. If text, aligns the button content to the leading edge of text |
|
|
129
130
|
<!-- docs: end hidden content -->
|
|
130
131
|
|
|
131
132
|
### Accessibility Properties
|
|
@@ -17,6 +17,13 @@ class DropdownButtonSubtle extends DropdownOpenerMixin(LitElement) {
|
|
|
17
17
|
* @type {string}
|
|
18
18
|
*/
|
|
19
19
|
description: { type: String },
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Aligns the leading edge of text if value is set to "text"
|
|
23
|
+
* @type {'text'|''}
|
|
24
|
+
*/
|
|
25
|
+
hAlign: { type: String, reflect: true, attribute: 'h-align' },
|
|
26
|
+
|
|
20
27
|
/**
|
|
21
28
|
* REQUIRED: Text for the button
|
|
22
29
|
* @type {string}
|
|
@@ -31,7 +38,7 @@ class DropdownButtonSubtle extends DropdownOpenerMixin(LitElement) {
|
|
|
31
38
|
|
|
32
39
|
render() {
|
|
33
40
|
return html`
|
|
34
|
-
<d2l-button-subtle description="${ifDefined(this.description)}" text=${this.text} icon="tier1:chevron-down" icon-right ?disabled=${this.disabled}></d2l-button-subtle>
|
|
41
|
+
<d2l-button-subtle description="${ifDefined(this.description)}" h-align="${ifDefined(this.hAlign)}" text=${this.text} icon="tier1:chevron-down" icon-right ?disabled=${this.disabled}></d2l-button-subtle>
|
|
35
42
|
<slot></slot>
|
|
36
43
|
`;
|
|
37
44
|
}
|
|
@@ -14,6 +14,8 @@ import { tryGetIfrauBackdropService } from '../../helpers/ifrauBackdropService.j
|
|
|
14
14
|
const reduceMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
15
15
|
const minBackdropHeightMobile = 42;
|
|
16
16
|
const minBackdropWidthMobile = 30;
|
|
17
|
+
const outerMarginTopBottom = 18;
|
|
18
|
+
const defaultVerticalOffset = 16;
|
|
17
19
|
|
|
18
20
|
export const DropdownContentMixin = superclass => class extends LocalizeCoreElement(RtlMixin(superclass)) {
|
|
19
21
|
|
|
@@ -264,6 +266,7 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
|
|
|
264
266
|
this._hasHeader = false;
|
|
265
267
|
this._hasFooter = false;
|
|
266
268
|
this._showBackdrop = false;
|
|
269
|
+
this._verticalOffset = defaultVerticalOffset;
|
|
267
270
|
|
|
268
271
|
this.__onResize = this.__onResize.bind(this);
|
|
269
272
|
this.__onAutoCloseFocus = this.__onAutoCloseFocus.bind(this);
|
|
@@ -324,9 +327,10 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
|
|
|
324
327
|
if (propName === 'verticalOffset') {
|
|
325
328
|
let newVerticalOffset = parseInt(this.verticalOffset);
|
|
326
329
|
if (isNaN(newVerticalOffset)) {
|
|
327
|
-
newVerticalOffset =
|
|
330
|
+
newVerticalOffset = defaultVerticalOffset;
|
|
328
331
|
}
|
|
329
332
|
this.style.setProperty('--d2l-dropdown-verticaloffset', `${newVerticalOffset}px`);
|
|
333
|
+
this._verticalOffset = newVerticalOffset;
|
|
330
334
|
}
|
|
331
335
|
});
|
|
332
336
|
}
|
|
@@ -616,9 +620,9 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
|
|
|
616
620
|
if (bounded) {
|
|
617
621
|
spaceAround = this._constrainSpaceAround({
|
|
618
622
|
// allow for target offset + outer margin
|
|
619
|
-
above: targetRect.top - boundingContainerRect.top -
|
|
623
|
+
above: targetRect.top - boundingContainerRect.top - this._verticalOffset - outerMarginTopBottom,
|
|
620
624
|
// allow for target offset + outer margin
|
|
621
|
-
below: boundingContainerRect.bottom - targetRect.bottom -
|
|
625
|
+
below: boundingContainerRect.bottom - targetRect.bottom - this._verticalOffset - outerMarginTopBottom,
|
|
622
626
|
// allow for outer margin
|
|
623
627
|
left: targetRect.left - boundingContainerRect.left - 20,
|
|
624
628
|
// allow for outer margin
|
|
@@ -631,9 +635,9 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
|
|
|
631
635
|
} else {
|
|
632
636
|
spaceAround = this._constrainSpaceAround({
|
|
633
637
|
// allow for target offset + outer margin
|
|
634
|
-
above: targetRect.top -
|
|
638
|
+
above: targetRect.top - this._verticalOffset - outerMarginTopBottom,
|
|
635
639
|
// allow for target offset + outer margin
|
|
636
|
-
below: window.innerHeight - targetRect.bottom -
|
|
640
|
+
below: window.innerHeight - targetRect.bottom - this._verticalOffset - outerMarginTopBottom,
|
|
637
641
|
// allow for outer margin
|
|
638
642
|
left: targetRect.left - 20,
|
|
639
643
|
// allow for outer margin
|
|
@@ -16,7 +16,7 @@ export const dropdownContentStyles = css`
|
|
|
16
16
|
left: 0;
|
|
17
17
|
position: absolute;
|
|
18
18
|
text-align: left;
|
|
19
|
-
top: calc(100% + var(--d2l-dropdown-verticaloffset,
|
|
19
|
+
top: calc(100% + var(--d2l-dropdown-verticaloffset, 16px));
|
|
20
20
|
width: 100%;
|
|
21
21
|
z-index: 1000; /* position on top of floating buttons */
|
|
22
22
|
}
|
|
@@ -38,7 +38,7 @@ export const dropdownContentStyles = css`
|
|
|
38
38
|
|
|
39
39
|
:host([opened-above]) {
|
|
40
40
|
animation: var(--d2l-dropdown-above-animation-name) 300ms ease;
|
|
41
|
-
bottom: calc(100% + var(--d2l-dropdown-verticaloffset,
|
|
41
|
+
bottom: calc(100% + var(--d2l-dropdown-verticaloffset, 16px));
|
|
42
42
|
top: auto;
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -49,7 +49,7 @@ export const dropdownContentStyles = css`
|
|
|
49
49
|
|
|
50
50
|
:host([data-mobile][opened-above]:not([mobile-tray])) {
|
|
51
51
|
animation: var(--d2l-dropdown-above-animation-name) 300ms ease;
|
|
52
|
-
bottom: calc(100% + var(--d2l-dropdown-verticaloffset,
|
|
52
|
+
bottom: calc(100% + var(--d2l-dropdown-verticaloffset, 16px));
|
|
53
53
|
top: auto;
|
|
54
54
|
}
|
|
55
55
|
|
package/custom-elements.json
CHANGED
|
@@ -1032,7 +1032,7 @@
|
|
|
1032
1032
|
},
|
|
1033
1033
|
{
|
|
1034
1034
|
"name": "max-digits",
|
|
1035
|
-
"description": "Optionally specify a digit limit, after which numbers are truncated
|
|
1035
|
+
"description": "Optionally specify a digit limit, after which numbers are truncated.\nDefaults to two for \"notification\" type and five for \"count\" type.",
|
|
1036
1036
|
"type": "number"
|
|
1037
1037
|
},
|
|
1038
1038
|
{
|
|
@@ -1105,7 +1105,7 @@
|
|
|
1105
1105
|
{
|
|
1106
1106
|
"name": "maxDigits",
|
|
1107
1107
|
"attribute": "max-digits",
|
|
1108
|
-
"description": "Optionally specify a digit limit, after which numbers are truncated
|
|
1108
|
+
"description": "Optionally specify a digit limit, after which numbers are truncated.\nDefaults to two for \"notification\" type and five for \"count\" type.",
|
|
1109
1109
|
"type": "number"
|
|
1110
1110
|
},
|
|
1111
1111
|
{
|
|
@@ -1185,7 +1185,7 @@
|
|
|
1185
1185
|
"attributes": [
|
|
1186
1186
|
{
|
|
1187
1187
|
"name": "max-digits",
|
|
1188
|
-
"description": "Optionally specify a digit limit, after which numbers are truncated
|
|
1188
|
+
"description": "Optionally specify a digit limit, after which numbers are truncated.\nDefaults to two for \"notification\" type and five for \"count\" type.",
|
|
1189
1189
|
"type": "number"
|
|
1190
1190
|
},
|
|
1191
1191
|
{
|
|
@@ -1252,7 +1252,7 @@
|
|
|
1252
1252
|
{
|
|
1253
1253
|
"name": "maxDigits",
|
|
1254
1254
|
"attribute": "max-digits",
|
|
1255
|
-
"description": "Optionally specify a digit limit, after which numbers are truncated
|
|
1255
|
+
"description": "Optionally specify a digit limit, after which numbers are truncated.\nDefaults to two for \"notification\" type and five for \"count\" type.",
|
|
1256
1256
|
"type": "number"
|
|
1257
1257
|
},
|
|
1258
1258
|
{
|
|
@@ -1686,6 +1686,11 @@
|
|
|
1686
1686
|
"description": "A description to be added to the opener button for accessibility when text on button does not provide enough context",
|
|
1687
1687
|
"type": "string"
|
|
1688
1688
|
},
|
|
1689
|
+
{
|
|
1690
|
+
"name": "h-align",
|
|
1691
|
+
"description": "Aligns the leading edge of text if value is set to \"text\"",
|
|
1692
|
+
"type": "'text'|''"
|
|
1693
|
+
},
|
|
1689
1694
|
{
|
|
1690
1695
|
"name": "text",
|
|
1691
1696
|
"description": "REQUIRED: Text for the button",
|
|
@@ -1717,6 +1722,12 @@
|
|
|
1717
1722
|
"description": "A description to be added to the opener button for accessibility when text on button does not provide enough context",
|
|
1718
1723
|
"type": "string"
|
|
1719
1724
|
},
|
|
1725
|
+
{
|
|
1726
|
+
"name": "hAlign",
|
|
1727
|
+
"attribute": "h-align",
|
|
1728
|
+
"description": "Aligns the leading edge of text if value is set to \"text\"",
|
|
1729
|
+
"type": "'text'|''"
|
|
1730
|
+
},
|
|
1720
1731
|
{
|
|
1721
1732
|
"name": "text",
|
|
1722
1733
|
"attribute": "text",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.222.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",
|