@brightspace-ui/labs 1.2.0 → 1.2.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.
package/package.json CHANGED
@@ -41,5 +41,5 @@
41
41
  "@brightspace-ui/core": "^2",
42
42
  "lit": "^2"
43
43
  },
44
- "version": "1.2.0"
44
+ "version": "1.2.2"
45
45
  }
@@ -7,11 +7,10 @@ The `<d2l-labs-opt-in-flyout>` and `<d2l-labs-opt-out-flyout>` can be used in ap
7
7
 
8
8
  | Property | Type | Description |
9
9
  |---|---|---|
10
- | `open` | Boolean, default: `false` | Indicates the opened or closed state of the flyout |
11
- | `title` | String, required | Title to display at the top of the flyout |
12
- | `short-description` | String |Descriptive text shown beneath the `title` |
10
+ | `opened` | Boolean, default: `false` | Indicates the opened or closed state of the flyout |
11
+ | `flyout-title` | String, required | Title to display at the top of the flyout |
12
+ | `short-description` | String |Descriptive text shown beneath the `flyout-title` |
13
13
  | `long-description` | String | Additional text shown beneath `short-description` |
14
- | `tab-position` | String, default: `'right'` | Position to display the expand/collapse tab. Can either be an integer percentage (including the `%` character) or the string `left`, `right`, or `center`/`centre`. |
15
14
  | `tutorial-link` | String | A URL for a tutorial of the new experience or feature |
16
15
  | `help-docs-link` | String | A URL for help documentation on the new experience or feature |
17
16
 
@@ -8,7 +8,6 @@ import { css, html, LitElement, nothing } from 'lit';
8
8
  import { classMap } from 'lit/directives/class-map.js';
9
9
  import { composeMixins } from '@brightspace-ui/core/helpers/composeMixins.js';
10
10
  import { LocalizeLabsElement } from '../localize-labs-element.js';
11
- import { RtlMixin } from '@brightspace-ui/core/mixins/rtl-mixin.js';
12
11
 
13
12
  const VISIBLE_STATES = Object.freeze({
14
13
  opened: 'OPENED',
@@ -19,19 +18,16 @@ const VISIBLE_STATES = Object.freeze({
19
18
 
20
19
  class FlyoutImplementation extends composeMixins(
21
20
  LitElement,
22
- LocalizeLabsElement,
23
- RtlMixin
21
+ LocalizeLabsElement
24
22
  ) {
25
23
 
26
24
  static get properties() {
27
25
  return {
28
26
  optOut: { type: Boolean, attribute: 'opt-out' },
29
- open: { type: Boolean, reflect: true },
30
- title: { type: String },
27
+ opened: { type: Boolean, reflect: true },
28
+ flyoutTitle: { attribute: 'flyout-title', type: String },
31
29
  shortDescription: { type: String, attribute: 'short-description' },
32
30
  longDescription: { type: String, attribute: 'long-description' },
33
- tabPosition: { type: String, attribute: 'tab-position' },
34
- noTransform: { type: Boolean, attribute: 'no-transform' },
35
31
  tutorialLink: { type: String, attribute: 'tutorial-link' },
36
32
  helpDocsLink: { type: String, attribute: 'help-docs-link' },
37
33
  hideReason: { type: Boolean, attribute: 'hide-reason' },
@@ -153,12 +149,13 @@ class FlyoutImplementation extends composeMixins(
153
149
  box-sizing: border-box;
154
150
  cursor: pointer;
155
151
  height: 1rem;
152
+ inset-block-start: 0;
153
+ inset-inline-end: 15px;
156
154
  min-height: 0;
157
155
  padding: 1px;
158
156
  pointer-events: auto;
159
157
  position: absolute;
160
158
  text-align: center;
161
- top: 0;
162
159
  width: 5rem;
163
160
  }
164
161
 
@@ -187,13 +184,12 @@ class FlyoutImplementation extends composeMixins(
187
184
 
188
185
  constructor() {
189
186
  super();
190
- this.tabPosition = 'right';
191
187
  this._visibleState = VISIBLE_STATES.closed;
192
188
  }
193
189
 
194
190
  connectedCallback() {
195
191
  super.connectedCallback();
196
- this._visibleState = this.open ? VISIBLE_STATES.opened : VISIBLE_STATES.closed;
192
+ this._visibleState = this.opened ? VISIBLE_STATES.opened : VISIBLE_STATES.closed;
197
193
  }
198
194
 
199
195
  render() {
@@ -203,7 +199,7 @@ class FlyoutImplementation extends composeMixins(
203
199
  <span tabindex="${this._getTabIndex()}" @focus="${this._shiftToLast}"></span>
204
200
  ${this._renderFlyoutContent()}
205
201
  <div class="flyout-tab-container">
206
- <button id="flyout-tab" class="flyout-tab" style="${this._getTabStyle()}" tabindex="0" aria-label="${this._getAriaLabelForTab()}" @click="${this._clickTab}">
202
+ <button id="flyout-tab" class="flyout-tab" tabindex="0" aria-label="${this._getAriaLabelForTab()}" @click="${this._clickTab}">
207
203
  <d2l-icon icon="${this._getTabIcon()}"></d2l-icon>
208
204
  </button>
209
205
  </div>
@@ -214,8 +210,8 @@ class FlyoutImplementation extends composeMixins(
214
210
 
215
211
  updated(changedProperties) {
216
212
  super.updated(changedProperties);
217
- if (changedProperties.has('open')) {
218
- this._openChanged();
213
+ if (changedProperties.has('opened')) {
214
+ this._openedChanged();
219
215
  }
220
216
  }
221
217
 
@@ -243,7 +239,7 @@ class FlyoutImplementation extends composeMixins(
243
239
 
244
240
  _clickOptIn() {
245
241
  this._fireEvent('opt-in');
246
- this.open = false;
242
+ this.opened = false;
247
243
  }
248
244
 
249
245
  _clickOptOut() {
@@ -251,20 +247,20 @@ class FlyoutImplementation extends composeMixins(
251
247
  this._optOutDialogOpen = true;
252
248
  } else {
253
249
  this._fireEvent('opt-out');
254
- this.open = false;
250
+ this.opened = false;
255
251
  }
256
252
  }
257
253
 
258
254
  _clickTab() {
259
255
  if (this._visibleState === VISIBLE_STATES.opened || this._visibleState === VISIBLE_STATES.closed) {
260
- this.open = !this.open;
256
+ this.opened = !this.opened;
261
257
  }
262
258
  }
263
259
 
264
260
  _confirmOptOut(event) {
265
261
  this._optOutDialogOpen = false;
266
262
  this._fireEvent('opt-out', event.detail);
267
- this.open = false;
263
+ this.opened = false;
268
264
  event.stopPropagation();
269
265
  }
270
266
 
@@ -281,7 +277,7 @@ class FlyoutImplementation extends composeMixins(
281
277
  }
282
278
 
283
279
  _getAriaLabelForTab() {
284
- if (this.open) {
280
+ if (this.opened) {
285
281
  return this.localize('components:optInFlyout:close');
286
282
  }
287
283
  return this.localize(this.optOut ? 'components:optInFlyout:openOptOut' : 'components:optInFlyout:openOptIn');
@@ -317,36 +313,7 @@ class FlyoutImplementation extends composeMixins(
317
313
  }
318
314
 
319
315
  _getTabIndex() {
320
- return this.open ? 0 : -1;
321
- }
322
-
323
- _getTabStyle() {
324
- let rtl = this.dir === 'rtl';
325
- let position = '';
326
- if (this.tabPosition === 'left') {
327
- position = 'calc(2.5rem + 15px)';
328
- } else if (this.tabPosition === 'right' || this.tabPosition === 'default' || !this.tabPosition) {
329
- position = 'calc(2.5rem + 15px)';
330
- rtl = !rtl;
331
- } else if (this.tabPosition === 'center' || this.tabPosition === 'centre') {
332
- position = '50%';
333
- } else if (!/^\d+(?:\.\d+)?%$/.test(this.tabPosition)) {
334
- /* eslint-disable no-console */
335
- console.warn('Invalid position supplied to opt-in flyout');
336
- position = 'calc(2.5rem + 15px)';
337
- rtl = !rtl;
338
- }
339
-
340
- const side = rtl ? 'right' : 'left';
341
- const shift = rtl ? '50%' : '-50%';
342
-
343
- const tabStyle = `${side}: ${position};`;
344
-
345
- if (this.noTransform) {
346
- return tabStyle;
347
- }
348
-
349
- return `${tabStyle} transform: translateX(${shift});`;
316
+ return this.opened ? 0 : -1;
350
317
  }
351
318
 
352
319
  _getTutorialLink(i) {
@@ -386,13 +353,13 @@ class FlyoutImplementation extends composeMixins(
386
353
  }
387
354
  }
388
355
 
389
- _openChanged() {
390
- if (this.open && this._visibleState === VISIBLE_STATES.closed || this._visibleState === VISIBLE_STATES.closing) {
356
+ _openedChanged() {
357
+ if (this.opened && this._visibleState === VISIBLE_STATES.closed || this._visibleState === VISIBLE_STATES.closing) {
391
358
  this._visibleState = VISIBLE_STATES.opening;
392
- } else if (!this.open && this._visibleState === VISIBLE_STATES.opened || this._visibleState === VISIBLE_STATES.opening) {
359
+ } else if (!this.opened && this._visibleState === VISIBLE_STATES.opened || this._visibleState === VISIBLE_STATES.opening) {
393
360
  this._visibleState = VISIBLE_STATES.closing;
394
361
  }
395
- this._fireEvent(this.open ? 'flyout-opened' : 'flyout-closed');
362
+ this._fireEvent(this.opened ? 'flyout-opened' : 'flyout-closed');
396
363
  }
397
364
 
398
365
  _renderFlyoutContent() {
@@ -402,7 +369,7 @@ class FlyoutImplementation extends composeMixins(
402
369
  return html`
403
370
  <div id="flyout-content" role="dialog" aria-labelledby="title" aria-describedby="${this._getDescription()}" class="flyout-content">
404
371
  <div class="flyout-text">
405
- <h1 class="d2l-heading-1" id="title">${this.title}</h1>
372
+ <h1 class="d2l-heading-1" id="title">${this.flyoutTitle}</h1>
406
373
  ${this._renderShortDescription()}
407
374
  ${this._renderLongDescription()}
408
375
  ${this._renderLinksText()}
@@ -491,7 +458,7 @@ class FlyoutImplementation extends composeMixins(
491
458
  }
492
459
 
493
460
  _shiftToLast() {
494
- if (this.open) {
461
+ if (this.opened) {
495
462
  this.shadowRoot.querySelector('#flyout-tab').focus();
496
463
  }
497
464
  }
@@ -6,11 +6,10 @@ class OptInFlyout extends LitElement {
6
6
 
7
7
  static get properties() {
8
8
  return {
9
- open: { type: Boolean, reflect: true },
10
- title: { type: String },
9
+ opened: { type: Boolean, reflect: true },
10
+ flyoutTitle: { attribute: 'flyout-title', type: String },
11
11
  shortDescription: { type: String, attribute: 'short-description' },
12
12
  longDescription: { type: String, attribute: 'long-description' },
13
- tabPosition: { type: String, attribute: 'tab-position' },
14
13
  tutorialLink: { type: String, attribute: 'tutorial-link' },
15
14
  helpDocsLink: { type: String, attribute: 'help-docs-link' }
16
15
  };
@@ -26,20 +25,19 @@ class OptInFlyout extends LitElement {
26
25
 
27
26
  constructor() {
28
27
  super();
29
- this.open = false;
28
+ this.opened = false;
30
29
  }
31
30
 
32
31
  render() {
33
32
  return html`
34
33
  <d2l-labs-opt-in-flyout-impl
35
34
  class="d2l-typography"
36
- title="${this.title}"
35
+ flyout-title="${this.flyoutTitle}"
37
36
  short-description="${this.shortDescription}"
38
37
  long-description="${this.longDescription}"
39
- tab-position="${this.tabPosition}"
40
38
  tutorial-link="${this.tutorialLink}"
41
39
  help-docs-link="${this.helpDocsLink}"
42
- ?open="${this.open}"
40
+ ?opened="${this.opened}"
43
41
  @flyout-opened="${this._handleOpened}"
44
42
  @flyout-closed="${this._handleClosed}">
45
43
  </d2l-labs-opt-in-flyout-impl>
@@ -47,11 +45,11 @@ class OptInFlyout extends LitElement {
47
45
  }
48
46
 
49
47
  _handleClosed() {
50
- this.open = false;
48
+ this.opened = false;
51
49
  }
52
50
 
53
51
  _handleOpened() {
54
- this.open = true;
52
+ this.opened = true;
55
53
  }
56
54
 
57
55
  }
@@ -6,12 +6,10 @@ class OptOutFlyout extends LitElement {
6
6
 
7
7
  static get properties() {
8
8
  return {
9
- open: { type: Boolean, reflect: true },
10
- title: { type: String },
9
+ opened: { type: Boolean, reflect: true },
10
+ flyoutTitle: { attribute: 'flyout-title', type: String },
11
11
  shortDescription: { type: String, attribute: 'short-description' },
12
12
  longDescription: { type: String, attribute: 'long-description' },
13
- tabPosition: { type: String, attribute: 'tab-position' },
14
- noTransform: { type: Boolean, attribute: 'no-transform' },
15
13
  tutorialLink: { type: String, attribute: 'tutorial-link' },
16
14
  helpDocsLink: { type: String, attribute: 'help-docs-link' },
17
15
  hideReason: { type: Boolean, attribute: 'hide-reason' },
@@ -29,7 +27,7 @@ class OptOutFlyout extends LitElement {
29
27
 
30
28
  constructor() {
31
29
  super();
32
- this.open = false;
30
+ this.opened = false;
33
31
  }
34
32
 
35
33
  render() {
@@ -38,16 +36,14 @@ class OptOutFlyout extends LitElement {
38
36
  id="flyout-impl"
39
37
  class="d2l-typography"
40
38
  opt-out
41
- title="${this.title}"
39
+ flyout-title="${this.flyoutTitle}"
42
40
  short-description="${this.shortDescription}"
43
41
  long-description="${this.longDescription}"
44
- tab-position="${this.tabPosition}"
45
42
  tutorial-link="${this.tutorialLink}"
46
43
  help-docs-link="${this.helpDocsLink}"
47
44
  ?hide-reason="${this.hideReason}"
48
45
  ?hide-feedback="${this.hideFeedback}"
49
- ?no-transform="${this.noTransform}"
50
- ?open="${this.open}"
46
+ ?opened="${this.opened}"
51
47
  @flyout-opened="${this._handleOpened}"
52
48
  @flyout-closed="${this._handleClosed}">
53
49
  <slot></slot>
@@ -70,11 +66,11 @@ class OptOutFlyout extends LitElement {
70
66
  }
71
67
 
72
68
  _handleClosed() {
73
- this.open = false;
69
+ this.opened = false;
74
70
  }
75
71
 
76
72
  _handleOpened() {
77
- this.open = true;
73
+ this.opened = true;
78
74
  }
79
75
 
80
76
  }