@brightspace-ui/core 1.222.1 → 1.224.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/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/components/scroll-wrapper/scroll-wrapper.js +1 -1
- package/components/selection/selection-mixin.js +4 -4
- package/custom-elements.json +775 -4
- package/mixins/rtl-mixin.js +2 -2
- package/package.json +1 -1
|
@@ -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 -->
|
|
@@ -184,7 +184,7 @@ class ScrollWrapper extends FocusVisiblePolyfillMixin(RtlMixin(LitElement)) {
|
|
|
184
184
|
|
|
185
185
|
scrollDistance(distance, smooth) {
|
|
186
186
|
if (!this._container) return;
|
|
187
|
-
if (this.
|
|
187
|
+
if (this.dir === 'rtl') distance = distance * RTL_MULTIPLIER;
|
|
188
188
|
if (this._container.scrollBy) {
|
|
189
189
|
this._container.scrollBy({ left: distance, behavior: smooth ? 'smooth' : 'auto' });
|
|
190
190
|
} else {
|
|
@@ -138,13 +138,13 @@ export const SelectionMixin = superclass => class extends RtlMixin(superclass) {
|
|
|
138
138
|
if (currentIndex === -1) currentIndex = 0;
|
|
139
139
|
let newIndex;
|
|
140
140
|
|
|
141
|
-
if ((this.
|
|
142
|
-
|| (this.
|
|
141
|
+
if ((this.dir !== 'rtl' && e.keyCode === keyCodes.RIGHT)
|
|
142
|
+
|| (this.dir === 'rtl' && e.keyCode === keyCodes.LEFT)
|
|
143
143
|
|| e.keyCode === keyCodes.DOWN) {
|
|
144
144
|
if (currentIndex === selectables.length - 1) newIndex = 0;
|
|
145
145
|
else newIndex = currentIndex + 1;
|
|
146
|
-
} else if ((this.
|
|
147
|
-
|| (this.
|
|
146
|
+
} else if ((this.dir !== 'rtl' && e.keyCode === keyCodes.LEFT)
|
|
147
|
+
|| (this.dir === 'rtl' && e.keyCode === keyCodes.RIGHT)
|
|
148
148
|
|| e.keyCode === keyCodes.UP) {
|
|
149
149
|
if (currentIndex === 0) newIndex = selectables.length - 1;
|
|
150
150
|
else newIndex = currentIndex - 1;
|