@brightspace-ui/core 1.222.3 → 1.224.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.
@@ -605,12 +605,14 @@ class InputText extends LabelledMixin(FormElementMixin(SkeletonMixin(RtlMixin(Li
605
605
  || (this.unit && this.dir !== 'rtl');
606
606
 
607
607
  if (firstSlotHasNodes) {
608
- requestAnimationFrame(() => this._firstSlotWidth = firstContainer.getBoundingClientRect().width);
608
+ // Firefox can have trouble rendering the cursor if the padding is a decimal
609
+ requestAnimationFrame(() => this._firstSlotWidth = Math.ceil(firstContainer.getBoundingClientRect().width));
609
610
  } else {
610
611
  this._firstSlotWidth = 0;
611
612
  }
612
613
  if (lastSlotHasNodes) {
613
- requestAnimationFrame(() => this._lastSlotWidth = lastContainer.getBoundingClientRect().width);
614
+ // Firefox can have trouble rendering the cursor if the padding is a decimal
615
+ requestAnimationFrame(() => this._lastSlotWidth = Math.ceil(lastContainer.getBoundingClientRect().width));
614
616
  } else {
615
617
  this._lastSlotWidth = 0;
616
618
  }
@@ -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 || rootList.getSelectionInfo(false).state === SelectionInfo.states.none) {
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);
@@ -19,9 +19,8 @@ class List extends SelectionMixin(LitElement) {
19
19
  static get properties() {
20
20
  return {
21
21
  /**
22
- * Not publicly available yet. Whether the user can drag multiple items
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
  /**
@@ -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._dir === 'rtl') distance = distance * RTL_MULTIPLIER;
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._dir !== 'rtl' && e.keyCode === keyCodes.RIGHT)
142
- || (this._dir === 'rtl' && e.keyCode === keyCodes.LEFT)
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._dir !== 'rtl' && e.keyCode === keyCodes.LEFT)
147
- || (this._dir === 'rtl' && e.keyCode === keyCodes.RIGHT)
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;
@@ -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
  },
@@ -4,7 +4,10 @@ export const RtlMixin = dedupeMixin(superclass => class extends superclass {
4
4
 
5
5
  static get properties() {
6
6
  return {
7
- _dir: { type: String, reflect: true, attribute: 'dir' }
7
+ /**
8
+ * @ignore
9
+ */
10
+ dir: { type: String, reflect: true }
8
11
  };
9
12
  }
10
13
 
@@ -13,7 +16,7 @@ export const RtlMixin = dedupeMixin(superclass => class extends superclass {
13
16
  const dir = document.documentElement.getAttribute('dir');
14
17
  // avoid reflecting "ltr" for better performance
15
18
  if (dir && dir !== 'ltr') {
16
- this._dir = dir;
19
+ this.dir = dir;
17
20
  }
18
21
  }
19
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "1.222.3",
3
+ "version": "1.224.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",