@brightspace-ui/core 1.222.0 → 1.223.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/card/card-footer-link.js +0 -15
- package/components/count-badge/count-badge-icon.js +34 -22
- package/components/list/demo/list-drag-and-drop.js +1 -1
- package/components/list/list-item-drag-drop-mixin.js +19 -7
- package/components/list/list-item-drag-image.js +123 -0
- package/components/list/list.js +1 -2
- package/components/meter/README.md +11 -12
- package/custom-elements.json +34 -0
- package/package.json +1 -1
|
@@ -76,19 +76,11 @@ class CardFooterLink extends RtlMixin(LitElement) {
|
|
|
76
76
|
return [offscreenStyles, css`
|
|
77
77
|
:host {
|
|
78
78
|
display: inline-block;
|
|
79
|
-
left: 0.15rem;
|
|
80
|
-
margin-right: 0.3rem;
|
|
81
79
|
position: relative;
|
|
82
80
|
}
|
|
83
81
|
:host[hidden] {
|
|
84
82
|
display: none;
|
|
85
83
|
}
|
|
86
|
-
:host([dir="rtl"]) {
|
|
87
|
-
left: auto;
|
|
88
|
-
margin-left: 0.3rem;
|
|
89
|
-
margin-right: 0;
|
|
90
|
-
right: 0.15rem;
|
|
91
|
-
}
|
|
92
84
|
a {
|
|
93
85
|
box-sizing: border-box;
|
|
94
86
|
display: inline-block;
|
|
@@ -99,13 +91,6 @@ class CardFooterLink extends RtlMixin(LitElement) {
|
|
|
99
91
|
d2l-count-badge-icon {
|
|
100
92
|
text-align: initial;
|
|
101
93
|
}
|
|
102
|
-
::slotted(d2l-tooltip) {
|
|
103
|
-
left: calc(-50% + 11px) !important;
|
|
104
|
-
}
|
|
105
|
-
:host([dir="rtl"]) ::slotted(d2l-tooltip) {
|
|
106
|
-
left: 0;
|
|
107
|
-
right: calc(-50% + 11px) !important;
|
|
108
|
-
}
|
|
109
94
|
`];
|
|
110
95
|
}
|
|
111
96
|
|
|
@@ -29,27 +29,24 @@ class CountBadgeIcon extends CountBadgeMixin(LitElement) {
|
|
|
29
29
|
outline: none;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
.d2l-count-badge-wrapper {
|
|
33
|
-
display: inline-block;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
32
|
:host {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
padding-left:
|
|
42
|
-
padding-right: 0;
|
|
33
|
+
/* for long numbers, center the number on the icon */
|
|
34
|
+
--d2l-count-badge-icon-padding: calc(-50% + (var(--d2l-count-badge-icon-height) / 2) + 2px);
|
|
35
|
+
display: inline-block;
|
|
36
|
+
/* symmetrical padding to prevent overflows for most numbers */
|
|
37
|
+
padding-left: 0.5rem;
|
|
38
|
+
padding-right: 0.5rem;
|
|
39
|
+
position: relative;
|
|
43
40
|
}
|
|
44
41
|
|
|
45
42
|
:host([size="large"]) {
|
|
46
|
-
--d2l-count-badge-icon-padding:
|
|
47
|
-
|
|
43
|
+
--d2l-count-badge-icon-padding-top: 0.7rem;
|
|
44
|
+
padding-top: var(--d2l-count-badge-icon-padding-top);
|
|
48
45
|
}
|
|
49
46
|
|
|
50
47
|
:host([size="small"]) {
|
|
51
|
-
--d2l-count-badge-icon-padding:
|
|
52
|
-
|
|
48
|
+
--d2l-count-badge-icon-padding-top: 0.55rem;
|
|
49
|
+
padding-top: var(--d2l-count-badge-icon-padding-top);
|
|
53
50
|
}
|
|
54
51
|
|
|
55
52
|
:host([icon*="tier1:"]) {
|
|
@@ -63,7 +60,7 @@ class CountBadgeIcon extends CountBadgeMixin(LitElement) {
|
|
|
63
60
|
}
|
|
64
61
|
|
|
65
62
|
d2l-tooltip[_open-dir="top"] {
|
|
66
|
-
margin-top: -
|
|
63
|
+
margin-top: calc(0px - var(--d2l-count-badge-icon-padding-top));
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
d2l-icon {
|
|
@@ -79,15 +76,30 @@ class CountBadgeIcon extends CountBadgeMixin(LitElement) {
|
|
|
79
76
|
}
|
|
80
77
|
|
|
81
78
|
render() {
|
|
82
|
-
|
|
83
|
-
const numberStyles = {
|
|
79
|
+
let numberStyles = {
|
|
84
80
|
border: '2px solid white',
|
|
85
|
-
position: '
|
|
86
|
-
|
|
87
|
-
right: this.dir === 'rtl' ? 'var(--d2l-count-badge-icon-padding)' : 0,
|
|
88
|
-
top: numberPadding,
|
|
89
|
-
visibility: this.skeleton ? 'hidden' : undefined
|
|
81
|
+
position: 'absolute',
|
|
82
|
+
visibility: this.skeleton ? 'hidden' : undefined,
|
|
90
83
|
};
|
|
84
|
+
|
|
85
|
+
// center long number strings to prevent overflow
|
|
86
|
+
const centerNumber = this.getNumberString().length >= 4;
|
|
87
|
+
|
|
88
|
+
if (centerNumber) {
|
|
89
|
+
const xPadding = 'var(--d2l-count-badge-icon-padding)';
|
|
90
|
+
numberStyles = {
|
|
91
|
+
... numberStyles,
|
|
92
|
+
transform: this.dir === 'rtl'
|
|
93
|
+
? `translateY(-50%) translateX(calc(0px - ${xPadding}))`
|
|
94
|
+
: `translateY(-50%) translateX(${xPadding})`
|
|
95
|
+
};
|
|
96
|
+
} else {
|
|
97
|
+
numberStyles = {
|
|
98
|
+
... numberStyles,
|
|
99
|
+
[this.dir === 'rtl' ? 'left' : 'right'] : '-0.1rem',
|
|
100
|
+
transform: 'translateY(-50%)'
|
|
101
|
+
};
|
|
102
|
+
}
|
|
91
103
|
const tabbable = (this.tabStop || this.hasTooltip) && !this.skeleton;
|
|
92
104
|
const innerHtml = html`
|
|
93
105
|
${this.renderCount(numberStyles)}
|
|
@@ -90,7 +90,7 @@ class ListDemoDragAndDrop extends LitElement {
|
|
|
90
90
|
render() {
|
|
91
91
|
const renderList = (items, nested) => {
|
|
92
92
|
return html`
|
|
93
|
-
<d2l-list grid slot="${ifDefined(nested ? 'nested' : undefined)}">
|
|
93
|
+
<d2l-list grid drag-multiple slot="${ifDefined(nested ? 'nested' : undefined)}">
|
|
94
94
|
${repeat(items, item => item.key, item => html`
|
|
95
95
|
<d2l-list-item
|
|
96
96
|
action-href="http://www.d2l.com"
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import './list-item-drag-image.js';
|
|
1
2
|
import { css, html } from 'lit-element/lit-element.js';
|
|
2
3
|
import { findComposedAncestor, isComposedAncestor } from '../../helpers/dom.js';
|
|
3
4
|
import { announce } from '../../helpers/announce.js';
|
|
@@ -332,7 +333,7 @@ export const ListItemDragDropMixin = superclass => class extends superclass {
|
|
|
332
333
|
opacity: 1;
|
|
333
334
|
}
|
|
334
335
|
}
|
|
335
|
-
`
|
|
336
|
+
`];
|
|
336
337
|
|
|
337
338
|
super.styles && styles.unshift(super.styles);
|
|
338
339
|
return styles;
|
|
@@ -550,15 +551,26 @@ export const ListItemDragDropMixin = superclass => class extends superclass {
|
|
|
550
551
|
e.dataTransfer.setData('text/plain', `${this.dropText}`);
|
|
551
552
|
}
|
|
552
553
|
|
|
553
|
-
if (this.shadowRoot) {
|
|
554
|
-
const nodeImage = this.shadowRoot.querySelector('.d2l-list-item-drag-image') || this;
|
|
555
|
-
e.dataTransfer.setDragImage(nodeImage, 50, 50);
|
|
556
|
-
}
|
|
557
|
-
|
|
558
554
|
const rootList = this._getRootList(this);
|
|
555
|
+
const selectionInfo = rootList.getSelectionInfo(rootList.dragMultiple);
|
|
556
|
+
|
|
557
|
+
if (rootList.dragMultiple && selectionInfo.keys.length > 1) {
|
|
558
|
+
let dragImage = this.shadowRoot.querySelector('d2l-list-item-drag-image');
|
|
559
|
+
if (!dragImage) {
|
|
560
|
+
dragImage = document.createElement('d2l-list-item-drag-image');
|
|
561
|
+
this.shadowRoot.appendChild(dragImage);
|
|
562
|
+
}
|
|
563
|
+
dragImage.count = selectionInfo.keys.length;
|
|
564
|
+
e.dataTransfer.setDragImage(dragImage, 24, 26);
|
|
565
|
+
} else {
|
|
566
|
+
if (this.shadowRoot) {
|
|
567
|
+
const nodeImage = this.shadowRoot.querySelector('.d2l-list-item-drag-image') || this;
|
|
568
|
+
e.dataTransfer.setDragImage(nodeImage, 50, 50);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
559
571
|
|
|
560
572
|
// getSelectionInfo(false) is fast so we can quickly check the state
|
|
561
|
-
if (!rootList.dragMultiple ||
|
|
573
|
+
if (!rootList.dragMultiple || selectionInfo.state === SelectionInfo.states.none) {
|
|
562
574
|
createDragState([this]);
|
|
563
575
|
} else {
|
|
564
576
|
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import '../colors/colors.js';
|
|
2
|
+
import '../inputs/input-checkbox.js';
|
|
3
|
+
import { css, html, LitElement } from 'lit-element/lit-element.js';
|
|
4
|
+
import { bodySmallStyles } from '../typography/styles.js';
|
|
5
|
+
import { formatNumber } from '@brightspace-ui/intl/lib/number.js';
|
|
6
|
+
import { RtlMixin } from '../../mixins/rtl-mixin.js';
|
|
7
|
+
import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
|
|
8
|
+
|
|
9
|
+
class ListItemDragImage extends SkeletonMixin(RtlMixin(LitElement)) {
|
|
10
|
+
|
|
11
|
+
static get properties() {
|
|
12
|
+
return {
|
|
13
|
+
/**
|
|
14
|
+
* @ignore
|
|
15
|
+
*/
|
|
16
|
+
count: { type: Number }
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static get styles() {
|
|
21
|
+
return [ super.styles, bodySmallStyles, css`
|
|
22
|
+
:host {
|
|
23
|
+
display: block;
|
|
24
|
+
height: 70px;
|
|
25
|
+
left: -10000px;
|
|
26
|
+
position: absolute;
|
|
27
|
+
width: 340px;
|
|
28
|
+
z-index: 0;
|
|
29
|
+
}
|
|
30
|
+
:host([hidden]) {
|
|
31
|
+
display: none;
|
|
32
|
+
}
|
|
33
|
+
:host([dir="rtl"]) {
|
|
34
|
+
left: 0;
|
|
35
|
+
right: -10000px;
|
|
36
|
+
}
|
|
37
|
+
.first, .second, .third {
|
|
38
|
+
background-color: white;
|
|
39
|
+
border: 1px solid var(--d2l-color-mica);
|
|
40
|
+
border-radius: 4px;
|
|
41
|
+
box-sizing: border-box;
|
|
42
|
+
height: 100%;
|
|
43
|
+
position: absolute;
|
|
44
|
+
width: 100%;
|
|
45
|
+
}
|
|
46
|
+
.first {
|
|
47
|
+
align-items: start;
|
|
48
|
+
display: flex;
|
|
49
|
+
padding: 16px 8px;
|
|
50
|
+
}
|
|
51
|
+
.second {
|
|
52
|
+
margin-inline-start: 6px;
|
|
53
|
+
margin-top: 6px;
|
|
54
|
+
z-index: -1;
|
|
55
|
+
}
|
|
56
|
+
.third {
|
|
57
|
+
margin-inline-start: 12px;
|
|
58
|
+
margin-top: 12px;
|
|
59
|
+
z-index: -2;
|
|
60
|
+
}
|
|
61
|
+
.text {
|
|
62
|
+
width: 100%;
|
|
63
|
+
}
|
|
64
|
+
.line-1 {
|
|
65
|
+
height: 24px;
|
|
66
|
+
margin-bottom: 4px;
|
|
67
|
+
width: 100%;
|
|
68
|
+
}
|
|
69
|
+
.line-2 {
|
|
70
|
+
height: 16px;
|
|
71
|
+
width: 25%;
|
|
72
|
+
}
|
|
73
|
+
d2l-input-checkbox {
|
|
74
|
+
line-height: 0;
|
|
75
|
+
margin: 0;
|
|
76
|
+
margin-inline-start: 16px;
|
|
77
|
+
}
|
|
78
|
+
.count {
|
|
79
|
+
background-color: var(--d2l-color-celestine);
|
|
80
|
+
border-radius: 0.7rem;
|
|
81
|
+
box-sizing: border-box;
|
|
82
|
+
color: white;
|
|
83
|
+
left: 26px;
|
|
84
|
+
min-width: 1.4rem;
|
|
85
|
+
padding: 0.2rem 0.4rem;
|
|
86
|
+
position: absolute;
|
|
87
|
+
text-align: center;
|
|
88
|
+
top: 30px;
|
|
89
|
+
z-index: 1000; /* must be higher than the skeleton z-index (999) */
|
|
90
|
+
}
|
|
91
|
+
:host([dir="rtl"]) .count {
|
|
92
|
+
left: 14px;
|
|
93
|
+
}
|
|
94
|
+
`];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
constructor() {
|
|
98
|
+
super();
|
|
99
|
+
this.count = 0;
|
|
100
|
+
this.skeleton = true;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
render() {
|
|
104
|
+
return html`
|
|
105
|
+
<div class="first">
|
|
106
|
+
<div class="count d2l-body-small">${formatNumber(this.count)}</div>
|
|
107
|
+
<svg width="18" height="18" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18">
|
|
108
|
+
<path fill="#494c4e" d="M8 16v1c0 .5-.4 1-1 1H6c-.6 0-1-.5-1-1v-1c0-.6.4-1 1-1h1c.6 0 1 .4 1 1M13 16v1c0 .5-.4 1-1 1h-1c-.6 0-1-.5-1-1v-1c0-.6.4-1 1-1h1c.6 0 1 .4 1 1M8 11v1c0 .6-.4 1-1 1H6c-.6 0-1-.4-1-1v-1c0-.6.4-1 1-1h1c.6 0 1 .4 1 1M13 11v1c0 .6-.4 1-1 1h-1c-.6 0-1-.4-1-1v-1c0-.6.4-1 1-1h1c.6 0 1 .4 1 1M8 6v1c0 .6-.4 1-1 1H6c-.6 0-1-.4-1-1V6c0-.6.4-1 1-1h1c.6 0 1 .4 1 1M13 6v1c0 .6-.4 1-1 1h-1c-.6 0-1-.4-1-1V6c0-.6.4-1 1-1h1c.6 0 1 .4 1 1M8 1v1c0 .6-.4 1-1 1H6c-.6 0-1-.4-1-1V1c0-.5.4-1 1-1h1c.6 0 1 .5 1 1M13 1v1c0 .6-.4 1-1 1h-1c-.6 0-1-.4-1-1V1c0-.5.4-1 1-1h1c.6 0 1 .5 1 1"/>
|
|
109
|
+
</svg>
|
|
110
|
+
<d2l-input-checkbox disabled skeleton></d2l-input-checkbox>
|
|
111
|
+
<div class="text">
|
|
112
|
+
<div class="line-1 d2l-skeletize"></div>
|
|
113
|
+
<div class="line-2 d2l-skeletize"></div>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
<div class="second"></div>
|
|
117
|
+
<div class="third"></div>
|
|
118
|
+
`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
customElements.define('d2l-list-item-drag-image', ListItemDragImage);
|
package/components/list/list.js
CHANGED
|
@@ -19,9 +19,8 @@ class List extends SelectionMixin(LitElement) {
|
|
|
19
19
|
static get properties() {
|
|
20
20
|
return {
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Whether the user can drag multiple items
|
|
23
23
|
* @type {boolean}
|
|
24
|
-
* @ignore
|
|
25
24
|
*/
|
|
26
25
|
dragMultiple: { type: Boolean, reflect: true, attribute: 'drag-multiple' },
|
|
27
26
|
/**
|
|
@@ -56,12 +56,11 @@ Linear meters show a horizontal progress bar.
|
|
|
56
56
|
* `value` (required, Number): Current number of completed units. A positive, non-zero number that is less than or equal to `max`.
|
|
57
57
|
* `max` (Number, default: `100`): Max number of units that are being measured by this meter. A positive, non-zero number.
|
|
58
58
|
* `percent` Boolean: Shows a percentage instead of `value/max`.
|
|
59
|
-
* `text-inline` Boolean: Keeps the meter to a single line.
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* `
|
|
63
|
-
* **DEPRECATED** `
|
|
64
|
-
* **DEPRECATED** `{y}` in the string will be replaced with `max`
|
|
59
|
+
* `text-inline` Boolean: Keeps the meter to a single line. Adding one of the following between `{}` (e.g., `{x/y}`) causes replacements:
|
|
60
|
+
* `%` in the string will be replaced with percentage value
|
|
61
|
+
* `x/y` in the string will be replaced with fraction with the proper language support
|
|
62
|
+
* **DEPRECATED** `x` in the string will be replaced with `value`
|
|
63
|
+
* **DEPRECATED** `y` in the string will be replaced with `max`
|
|
65
64
|
<!-- docs: end hidden content -->
|
|
66
65
|
|
|
67
66
|
## Radial meter [d2l-meter-radial]
|
|
@@ -89,9 +88,9 @@ Radial meters appear as a half circle. They have more visual weight than a line
|
|
|
89
88
|
* `value` (required, Number): Current number of completed units. A positive, non-zero number that is less than or equal to `max`.
|
|
90
89
|
* `max` (Number, default: `100`): Max number of units that are being measured by this meter. A positive, non-zero number.
|
|
91
90
|
* `percent` (Boolean): Shows a percentage instead of `value/max`.
|
|
92
|
-
* `text` (String): Context information about what the meter is about.
|
|
93
|
-
*
|
|
94
|
-
* `
|
|
91
|
+
* `text` (String): Context information about what the meter is about. Adding one of the following between `{}` (e.g., `{x/y}`) causes replacements:
|
|
92
|
+
* `%` in the string will be replaced with percentage value
|
|
93
|
+
* `x/y` in the string will be replaced with fraction with the proper language support
|
|
95
94
|
<!-- docs: end hidden content -->
|
|
96
95
|
|
|
97
96
|
|
|
@@ -134,7 +133,7 @@ All `meter` components have a `foreground-light` style that ensures accessibl
|
|
|
134
133
|
* `value` (required, Number): Current number of completed units. A positive, non-zero number that is less than or equal to `max`.
|
|
135
134
|
* `max` (Number, default: `100`): Max number of units that are being measured by this meter. A positive, non-zero number.
|
|
136
135
|
* `percent` (Boolean): Shows a percentage instead of `value/max`.
|
|
137
|
-
* `text` (String): Context information about what the meter is about.
|
|
138
|
-
*
|
|
139
|
-
* `
|
|
136
|
+
* `text` (String): Context information about what the meter is about. Adding one of the following between `{}` (e.g., `{x/y}`) causes replacements:
|
|
137
|
+
* `%` in the string will be replaced with percentage value
|
|
138
|
+
* `x/y` in the string will be replaced with fraction with the proper language support
|
|
140
139
|
<!-- docs: end hidden content -->
|
package/custom-elements.json
CHANGED
|
@@ -6943,6 +6943,32 @@
|
|
|
6943
6943
|
}
|
|
6944
6944
|
]
|
|
6945
6945
|
},
|
|
6946
|
+
{
|
|
6947
|
+
"name": "d2l-list-item-drag-image",
|
|
6948
|
+
"path": "./components/list/list-item-drag-image.js",
|
|
6949
|
+
"attributes": [
|
|
6950
|
+
{
|
|
6951
|
+
"name": "skeleton",
|
|
6952
|
+
"description": "Renders the input as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton)",
|
|
6953
|
+
"type": "boolean",
|
|
6954
|
+
"default": "true"
|
|
6955
|
+
}
|
|
6956
|
+
],
|
|
6957
|
+
"properties": [
|
|
6958
|
+
{
|
|
6959
|
+
"name": "count",
|
|
6960
|
+
"type": "number",
|
|
6961
|
+
"default": "0"
|
|
6962
|
+
},
|
|
6963
|
+
{
|
|
6964
|
+
"name": "skeleton",
|
|
6965
|
+
"attribute": "skeleton",
|
|
6966
|
+
"description": "Renders the input as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton)",
|
|
6967
|
+
"type": "boolean",
|
|
6968
|
+
"default": "true"
|
|
6969
|
+
}
|
|
6970
|
+
]
|
|
6971
|
+
},
|
|
6946
6972
|
{
|
|
6947
6973
|
"name": "d2l-list-item-generic-layout",
|
|
6948
6974
|
"path": "./components/list/list-item-generic-layout.js",
|
|
@@ -7242,6 +7268,12 @@
|
|
|
7242
7268
|
"type": "'all'|'between'|'none'",
|
|
7243
7269
|
"default": "\"\\\"all\\\"\""
|
|
7244
7270
|
},
|
|
7271
|
+
{
|
|
7272
|
+
"name": "drag-multiple",
|
|
7273
|
+
"description": "Whether the user can drag multiple items",
|
|
7274
|
+
"type": "boolean",
|
|
7275
|
+
"default": "false"
|
|
7276
|
+
},
|
|
7245
7277
|
{
|
|
7246
7278
|
"name": "extend-separators",
|
|
7247
7279
|
"description": "Whether to extend the separators beyond the content's edge",
|
|
@@ -7271,6 +7303,8 @@
|
|
|
7271
7303
|
},
|
|
7272
7304
|
{
|
|
7273
7305
|
"name": "dragMultiple",
|
|
7306
|
+
"attribute": "drag-multiple",
|
|
7307
|
+
"description": "Whether the user can drag multiple items",
|
|
7274
7308
|
"type": "boolean",
|
|
7275
7309
|
"default": "false"
|
|
7276
7310
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.223.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",
|