@brightspace-ui/core 3.150.6 → 3.150.7

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.
@@ -4,6 +4,11 @@
4
4
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
5
  <meta charset="UTF-8">
6
6
  <link rel="stylesheet" href="../../demo/styles.css" type="text/css">
7
+ <script type="module">
8
+ import { mockFlag } from '../../../helpers/flags.js';
9
+ const urlParams = new URLSearchParams(window.location.search);
10
+ mockFlag('GAUD-8263-scroll-wrapper-media-print', urlParams.get('media-query-print') === 'true');
11
+ </script>
7
12
  <script type="module">
8
13
  import '../../demo/demo-page.js';
9
14
  import './scroll-wrapper-test.js';
@@ -13,6 +18,8 @@
13
18
 
14
19
  <d2l-demo-page page-title="d2l-scroll-wrapper">
15
20
 
21
+ <button id="print">Print</button>
22
+
16
23
  <h2>Actions</h2>
17
24
  <d2l-demo-snippet>
18
25
  <template>
@@ -41,5 +48,10 @@
41
48
  </d2l-demo-snippet>
42
49
 
43
50
  </d2l-demo-page>
51
+ <script>
52
+ document.querySelector('#print').addEventListener('click', () => {
53
+ window.print();
54
+ });
55
+ </script>
44
56
  </body>
45
57
  </html>
@@ -1,12 +1,18 @@
1
1
  import '../colors/colors.js';
2
2
  import '../icons/icon.js';
3
3
  import { css, html, LitElement } from 'lit';
4
+ import { classMap } from 'lit/directives/class-map.js';
5
+ import { getFlag } from '../../helpers/flags.js';
4
6
  import { getFocusRingStyles } from '../../helpers/focus.js';
5
7
  import ResizeObserver from 'resize-observer-polyfill/dist/ResizeObserver.es.js';
6
8
  import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
7
9
 
10
+ export const printMediaQueryOnlyFlag = getFlag('GAUD-8263-scroll-wrapper-media-print', false);
11
+
8
12
  const RTL_MULTIPLIER = navigator.userAgent.indexOf('Edge/') > 0 ? 1 : -1; /* legacy-Edge doesn't reverse scrolling in RTL */
9
13
  const SCROLL_AMOUNT = 0.8;
14
+
15
+ // remove when cleaning up GAUD-8263-scroll-wrapper-media-print
10
16
  const PRINT_MEDIA_QUERY_LIST = matchMedia('print');
11
17
 
12
18
  let focusStyleSheet;
@@ -149,6 +155,20 @@ class ScrollWrapper extends RtlMixin(LitElement) {
149
155
  :host([scrollbar-left]) .d2l-scroll-wrapper-button-left {
150
156
  display: none;
151
157
  }
158
+
159
+ @media print {
160
+ /* remove .print-media-query-only when cleaning up GAUD-8263-scroll-wrapper-media-print */
161
+ .d2l-scroll-wrapper-actions.print-media-query-only {
162
+ display: none;
163
+ }
164
+ /* remove .print-media-query-only when cleaning up GAUD-8263-scroll-wrapper-media-print */
165
+ .d2l-scroll-wrapper-container.print-media-query-only {
166
+ border: none !important;
167
+ box-sizing: content-box !important;
168
+ overflow: visible !important;
169
+ }
170
+ }
171
+
152
172
  `;
153
173
  }
154
174
 
@@ -160,26 +180,40 @@ class ScrollWrapper extends RtlMixin(LitElement) {
160
180
  this._baseContainer = null;
161
181
  this._container = null;
162
182
  this._hScrollbar = true;
183
+
184
+ // remove when cleaning up GAUD-8263-scroll-wrapper-media-print
163
185
  this._printMode = PRINT_MEDIA_QUERY_LIST.matches;
186
+
164
187
  this._resizeObserver = new ResizeObserver(() => requestAnimationFrame(() => this.checkScrollbar()));
165
188
  this._scrollbarLeft = false;
166
189
  this._scrollbarRight = false;
167
190
  this._syncDriver = null;
168
191
  this._syncDriverTimeout = null;
169
192
  this._checkScrollThresholds = this._checkScrollThresholds.bind(this);
193
+
194
+ // remove when cleaning up GAUD-8263-scroll-wrapper-media-print
170
195
  this._handlePrintChange = this._handlePrintChange.bind(this);
196
+
171
197
  this._synchronizeScroll = this._synchronizeScroll.bind(this);
172
198
  }
173
199
 
174
200
  connectedCallback() {
175
201
  super.connectedCallback();
176
- PRINT_MEDIA_QUERY_LIST.addEventListener?.('change', this._handlePrintChange);
202
+
203
+ // remove when cleaning up GAUD-8263-scroll-wrapper-media-print
204
+ if (!printMediaQueryOnlyFlag) {
205
+ PRINT_MEDIA_QUERY_LIST.addEventListener?.('change', this._handlePrintChange);
206
+ }
177
207
  }
178
208
 
179
209
  disconnectedCallback() {
180
210
  super.disconnectedCallback();
181
211
  this._disconnectAll();
182
- PRINT_MEDIA_QUERY_LIST.removeEventListener?.('change', this._handlePrintChange);
212
+
213
+ // remove when cleaning up GAUD-8263-scroll-wrapper-media-print
214
+ if (!printMediaQueryOnlyFlag) {
215
+ PRINT_MEDIA_QUERY_LIST.removeEventListener?.('change', this._handlePrintChange);
216
+ }
183
217
  }
184
218
 
185
219
  firstUpdated(changedProperties) {
@@ -188,11 +222,21 @@ class ScrollWrapper extends RtlMixin(LitElement) {
188
222
  }
189
223
 
190
224
  render() {
191
- // when printing, just get scroll-wrapper out of the way
192
- if (this._printMode) return html`<slot></slot>`;
225
+
226
+ // when printing, just get scroll-wrapper out of the way; remove when cleaning up GAUD-8263-scroll-wrapper-media-print
227
+ if (this._printMode && !printMediaQueryOnlyFlag) return html`<slot></slot>`;
228
+
229
+ const containerClasses = {
230
+ 'd2l-scroll-wrapper-container': true,
231
+ 'print-media-query-only': printMediaQueryOnlyFlag // remove when cleaning up GAUD-8263-scroll-wrapper-media-print
232
+ };
233
+ const actionsClasses = {
234
+ 'd2l-scroll-wrapper-actions': true,
235
+ 'print-media-query-only': printMediaQueryOnlyFlag // remove when cleaning up GAUD-8263-scroll-wrapper-media-print
236
+ };
193
237
 
194
238
  const actions = !this.hideActions ? html`
195
- <div class="d2l-scroll-wrapper-actions">
239
+ <div class="${classMap(actionsClasses)}">
196
240
  <div class="d2l-scroll-wrapper-button d2l-scroll-wrapper-button-left vdiff-target" @click="${this._scrollLeft}">
197
241
  <d2l-icon icon="tier1:chevron-left"></d2l-icon>
198
242
  </div>
@@ -202,7 +246,7 @@ class ScrollWrapper extends RtlMixin(LitElement) {
202
246
  </div>` : null;
203
247
  return html`
204
248
  ${actions}
205
- <div class="d2l-scroll-wrapper-container"><slot></slot></div>
249
+ <div class="${classMap(containerClasses)}"><slot></slot></div>
206
250
  `;
207
251
  }
208
252
 
@@ -259,6 +303,7 @@ class ScrollWrapper extends RtlMixin(LitElement) {
259
303
  }
260
304
  }
261
305
 
306
+ // remove this handler when cleaning up GAUD-8263-scroll-wrapper-media-print
262
307
  async _handlePrintChange() {
263
308
  if (!this._printMode) {
264
309
  this._disconnectAll();
@@ -4,6 +4,11 @@
4
4
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
5
  <meta charset="UTF-8">
6
6
  <link rel="stylesheet" href="../../demo/styles.css" type="text/css">
7
+ <script type="module">
8
+ import { mockFlag } from '../../../helpers/flags.js';
9
+ const urlParams = new URLSearchParams(window.location.search);
10
+ mockFlag('GAUD-8263-scroll-wrapper-media-print', urlParams.get('media-query-print') === 'true');
11
+ </script>
7
12
  <script type="module">
8
13
  import '../../demo/demo-page.js';
9
14
  import './table-test.js';
@@ -13,6 +18,8 @@
13
18
 
14
19
  <d2l-demo-page page-title="d2l-table">
15
20
 
21
+ <button id="print">Print</button>
22
+
16
23
  <h2>Default</h2>
17
24
  <d2l-demo-snippet>
18
25
  <template>
@@ -89,5 +96,10 @@
89
96
 
90
97
  <div style="margin-bottom: 1000px;"></div>
91
98
  </d2l-demo-page>
99
+ <script>
100
+ document.querySelector('#print').addEventListener('click', () => {
101
+ window.print();
102
+ });
103
+ </script>
92
104
  </body>
93
105
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.150.6",
3
+ "version": "3.150.7",
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",