@brightspace-ui/core 3.127.1 → 3.127.3

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.
@@ -6,6 +6,7 @@ import { heading1Styles, heading2Styles, heading3Styles, heading4Styles } from '
6
6
  import { classMap } from 'lit/directives/class-map.js';
7
7
  import { EventSubscriberController } from '../../controllers/subscriber/subscriberControllers.js';
8
8
  import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
9
+ import { getComposedActiveElement } from '../../helpers/focus.js';
9
10
  import { ifDefined } from 'lit/directives/if-defined.js';
10
11
  import { isComposedAncestor } from '../../helpers/dom.js';
11
12
  import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
@@ -27,6 +28,21 @@ const normalizeHeadingLevel = (number) => {
27
28
 
28
29
  const defaultHeading = 3;
29
30
 
31
+ let tabPressed = false;
32
+ let tabListenerAdded = false;
33
+ function addTabListener() {
34
+ if (tabListenerAdded) return;
35
+ tabListenerAdded = true;
36
+ document.addEventListener('keydown', e => {
37
+ if (e.keyCode !== 9) return;
38
+ tabPressed = true;
39
+ });
40
+ document.addEventListener('keyup', e => {
41
+ if (e.keyCode !== 9) return;
42
+ tabPressed = false;
43
+ });
44
+ }
45
+
30
46
  /**
31
47
  * A container with a title that can be expanded/collapsed to show/hide content.
32
48
  * @slot before - Slot for content to be placed at the left side of the header, aligned with the title and header slot
@@ -85,7 +101,6 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
85
101
  * @type {boolean}
86
102
  */
87
103
  noSticky: { attribute: 'no-sticky', type: Boolean },
88
- _clicked: { state: true },
89
104
  _focused: { state: true },
90
105
  _hasBefore: { state: true },
91
106
  _hasSummary: { state: true },
@@ -323,7 +338,6 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
323
338
  this.paddingType = 'default';
324
339
  this.type = 'default';
325
340
  this.noSticky = false;
326
- this._clicked = false;
327
341
  this._focused = false;
328
342
  this._group = undefined;
329
343
  this._groupSubscription = new EventSubscriberController(this, 'collapsible-panel-group', {
@@ -341,6 +355,11 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
341
355
  return '.d2l-collapsible-panel-opener';
342
356
  }
343
357
 
358
+ connectedCallback() {
359
+ super.connectedCallback();
360
+ addTabListener();
361
+ }
362
+
344
363
  disconnectedCallback() {
345
364
  super.disconnectedCallback();
346
365
  if (this._intersectionObserver) this._intersectionObserver.disconnect();
@@ -349,7 +368,7 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
349
368
  render() {
350
369
  const classes = {
351
370
  'd2l-collapsible-panel': true,
352
- 'focused': this._focused && !this._clicked,
371
+ 'focused': this._focused,
353
372
  'has-summary': this._hasSummary,
354
373
  'has-before': this._hasBefore,
355
374
  'scrolled': this._scrolled,
@@ -425,7 +444,6 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
425
444
  }
426
445
 
427
446
  _handlePanelClick(e) {
428
- this._clicked = e.detail && e.detail > 0; // detect if click event is from a mouse
429
447
  const content = this.shadowRoot.querySelector('.d2l-collapsible-panel-content');
430
448
  if (e.target !== content && !isComposedAncestor(content, e.target)) this._toggleExpand();
431
449
  }
@@ -436,11 +454,15 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
436
454
  }
437
455
 
438
456
  _onBlur() {
439
- this._focused = false;
440
- this._clicked = false;
457
+ setTimeout(() => {
458
+ // don't remove focus if the button still ends up in focus
459
+ if (getComposedActiveElement() === this.shadowRoot.querySelector('button')) return;
460
+ this._focused = false;
461
+ }, 10);
441
462
  }
442
463
 
443
464
  _onFocus() {
465
+ if (!tabPressed) return;
444
466
  this._focused = true;
445
467
  }
446
468
 
@@ -1,18 +1,15 @@
1
1
  import '../colors/colors.js';
2
2
  import '../tooltip/tooltip.js';
3
- import { css, html, LitElement, nothing, unsafeCSS } from 'lit';
3
+ import { css, html, LitElement, nothing } from 'lit';
4
4
  import { classMap } from 'lit/directives/class-map.js';
5
5
  import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
6
6
  import { FormElementMixin } from '../form/form-element-mixin.js';
7
- import { getFlag } from '../../helpers/flags.js';
8
7
  import { getUniqueId } from '../../helpers/uniqueId.js';
9
8
  import { ifDefined } from 'lit/directives/if-defined.js';
10
9
  import { InputInlineHelpMixin } from './input-inline-help.js';
11
10
  import { offscreenStyles } from '../offscreen/offscreen.js';
12
11
  import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
13
12
 
14
- const inputStyleTweaksEnabled = getFlag('input-style-tweaks', true);
15
-
16
13
  export const cssSizes = {
17
14
  inputBoxSize: 1.2,
18
15
  checkboxMargin: 0.5,
@@ -132,7 +129,7 @@ class InputCheckbox extends FormElementMixin(InputInlineHelpMixin(FocusMixin(Ske
132
129
  css`
133
130
  :host {
134
131
  display: block;
135
- margin-block-end: ${unsafeCSS(inputStyleTweaksEnabled ? '0.6rem' : '0.9rem')}; /* stylelint-disable-line */
132
+ margin-block-end: 0.6rem;
136
133
  }
137
134
  :host([hidden]) {
138
135
  display: none;
@@ -180,7 +177,7 @@ class InputCheckbox extends FormElementMixin(InputInlineHelpMixin(FocusMixin(Ske
180
177
  }
181
178
  .d2l-input-checkbox-supporting {
182
179
  display: none;
183
- margin-block-start: ${unsafeCSS(inputStyleTweaksEnabled ? '0.6rem' : '0.9rem')}; /* stylelint-disable-line */
180
+ margin-block-start: 0.6rem;
184
181
  }
185
182
  .d2l-input-checkbox-supporting-visible {
186
183
  display: block;
@@ -1,7 +1,4 @@
1
- import { css, unsafeCSS } from 'lit';
2
- import { getFlag } from '../../helpers/flags.js';
3
-
4
- const inputStyleTweaksEnabled = getFlag('input-style-tweaks', true);
1
+ import { css } from 'lit';
5
2
 
6
3
  export const inputLabelStyles = css`
7
4
  .d2l-input-label {
@@ -10,8 +7,8 @@ export const inputLabelStyles = css`
10
7
  font-size: 0.7rem;
11
8
  font-weight: 700;
12
9
  letter-spacing: 0.2px;
13
- line-height: ${unsafeCSS(inputStyleTweaksEnabled ? '0.9rem' : '1rem')}; /* stylelint-disable-line */
14
- margin-block: 0 ${unsafeCSS(inputStyleTweaksEnabled ? '0.4rem' : '7px')}; /* stylelint-disable-line */
10
+ line-height: 0.9rem;
11
+ margin-block: 0 0.4rem;
15
12
  margin-inline: 0;
16
13
  padding: 0;
17
14
  }
@@ -9,10 +9,6 @@
9
9
  padding-block: 0 0.4rem;
10
10
  padding-inline: 0;
11
11
  width: 100%;
12
- .d2l-typography.d2l-no-input-style-tweaks & {
13
- line-height: 1rem;
14
- padding-block-end: 7px;
15
- }
16
12
  }
17
13
 
18
14
  @mixin d2l-input-label-required() {
@@ -1,19 +1,16 @@
1
1
  import { clearDismissible, setDismissible } from '../../helpers/dismissible.js';
2
- import { css, html, LitElement, unsafeCSS } from 'lit';
2
+ import { css, html, LitElement } from 'lit';
3
3
  import { cssEscape, elemIdListAdd, elemIdListRemove, getBoundingAncestor, getOffsetParent, isComposedAncestor } from '../../helpers/dom.js';
4
4
  import { getComposedActiveElement, isFocusable } from '../../helpers/focus.js';
5
5
  import { interactiveElements, interactiveRoles, isInteractive } from '../../helpers/interactive.js';
6
6
  import { announce } from '../../helpers/announce.js';
7
7
  import { bodySmallStyles } from '../typography/styles.js';
8
8
  import { classMap } from 'lit/directives/class-map.js';
9
- import { getFlag } from '../../helpers/flags.js';
10
9
  import { getUniqueId } from '../../helpers/uniqueId.js';
11
10
  import ResizeObserver from 'resize-observer-polyfill/dist/ResizeObserver.es.js';
12
11
  import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
13
12
  import { styleMap } from 'lit/directives/style-map.js';
14
13
 
15
- const inputStyleTweaksEnabled = getFlag('input-style-tweaks', true);
16
-
17
14
  let logAccessibilityWarning = true;
18
15
 
19
16
  /* only one tooltip is to be shown at once - track the active tooltip so it can be hidden if necessary */
@@ -313,12 +310,12 @@ class Tooltip extends RtlMixin(LitElement) {
313
310
  border-radius: ${contentBorderRadius}px;
314
311
  box-sizing: border-box;
315
312
  max-width: 17.5rem;
316
- min-height: ${unsafeCSS(inputStyleTweaksEnabled ? '1.95rem' : '2.1rem')}; /* stylelint-disable-line */
313
+ min-height: 1.95rem;
317
314
  min-width: 2.1rem;
318
315
  outline: ${outlineSize}px solid var(--d2l-tooltip-outline-color);
319
316
  overflow: hidden;
320
317
  overflow-wrap: anywhere;
321
- padding-block: ${(inputStyleTweaksEnabled ? 10 : 11) - contentBorderSize}px ${11 - contentBorderSize}px;
318
+ padding-block: ${10 - contentBorderSize}px ${11 - contentBorderSize}px;
322
319
  padding-inline: ${contentHorizontalPadding - contentBorderSize}px;
323
320
  position: absolute;
324
321
  }
@@ -1,8 +1,5 @@
1
1
  import '../colors/colors.js';
2
2
  import { css, unsafeCSS } from 'lit';
3
- import { getFlag } from '../../helpers/flags.js';
4
-
5
- const inputStyleTweaksEnabled = getFlag('input-style-tweaks', true);
6
3
 
7
4
  export const _isValidCssSelector = (selector) => {
8
5
  if (selector === ':host') return true;
@@ -115,7 +112,7 @@ export const _generateBodySmallStyles = (selector) => {
115
112
  color: var(--d2l-color-tungsten);
116
113
  font-size: 0.7rem;
117
114
  font-weight: 400;
118
- line-height: ${unsafeCSS(inputStyleTweaksEnabled ? '0.9rem' : '1rem')}; /* stylelint-disable-line */
115
+ line-height: 0.9rem;
119
116
  margin: auto;
120
117
  }
121
118
  :host([skeleton]) ${selector}.d2l-skeletize::before {
@@ -132,7 +129,6 @@ export const _generateBodySmallStyles = (selector) => {
132
129
  max-height: 5rem;
133
130
  }
134
131
  @media (max-width: 615px) {
135
- ${unsafeCSS(!inputStyleTweaksEnabled ? `${selector} { font-size: 0.6rem; line-height: 0.9rem; }` : '')}
136
132
  :host([skeleton]) ${selector}.d2l-skeletize::before {
137
133
  bottom: 0.25rem;
138
134
  top: 0.2rem;
@@ -272,7 +268,7 @@ export const _generateLabelStyles = (selector) => {
272
268
  font-size: 0.7rem;
273
269
  font-weight: 700;
274
270
  letter-spacing: 0.2px;
275
- line-height: ${unsafeCSS(inputStyleTweaksEnabled ? '0.9rem' : '1rem')}; /* stylelint-disable-line */
271
+ line-height: 0.9rem;
276
272
  }
277
273
  :host([skeleton]) ${selector}.d2l-skeletize::before {
278
274
  bottom: 0.25rem;
@@ -1,9 +1,7 @@
1
1
  import '../colors/colors.js';
2
2
  import { _generateBlockquoteStyles, fontFacesCss } from './styles.js';
3
- import { getFlag } from '../../helpers/flags.js';
4
3
 
5
4
  if (!document.head.querySelector('#d2l-typography-font-face')) {
6
- const inputStyleTweaksEnabled = getFlag('input-style-tweaks', true);
7
5
  const style = document.createElement('style');
8
6
  style.id = 'd2l-typography-font-face';
9
7
  style.textContent = `
@@ -45,13 +43,13 @@ if (!document.head.querySelector('#d2l-typography-font-face')) {
45
43
  color: var(--d2l-color-tungsten);
46
44
  font-size: 0.7rem;
47
45
  font-weight: 400;
48
- line-height: ${(inputStyleTweaksEnabled ? '0.9rem' : '1rem')};
46
+ line-height: 0.9rem;
49
47
  margin: auto;
50
48
  }
51
49
 
52
50
  .d2l-typography .d2l-label-text {
53
51
  font-size: 0.7rem;
54
- line-height: ${(inputStyleTweaksEnabled ? '0.9rem' : '1rem')};
52
+ line-height: 0.9rem;
55
53
  font-weight: 700;
56
54
  letter-spacing: 0.2px;
57
55
  }
@@ -117,11 +115,6 @@ if (!document.head.querySelector('#d2l-typography-font-face')) {
117
115
  line-height: 1.2rem;
118
116
  }
119
117
 
120
- ${!inputStyleTweaksEnabled ? `.d2l-typography .d2l-body-small {
121
- font-size: 0.6rem;
122
- line-height: 0.9rem;
123
- }` : ''}
124
-
125
118
  .d2l-typography .d2l-heading-1 {
126
119
  font-size: 1.5rem;
127
120
  line-height: 1.8rem;
@@ -113,13 +113,6 @@
113
113
  font-weight: 400;
114
114
  line-height: 0.9rem;
115
115
  margin: auto;
116
- .d2l-typography.d2l-no-input-style-tweaks & {
117
- line-height: 1rem;
118
- @media (max-width: 615px) {
119
- font-size: 0.6rem;
120
- line-height: 0.9rem;
121
- }
122
- }
123
116
  }
124
117
 
125
118
  @mixin d2l-heading-1 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.127.1",
3
+ "version": "3.127.3",
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",