@brightspace-ui/core 3.312.0 → 3.314.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.
@@ -1,6 +1,6 @@
1
1
  import '../colors/colors.js';
2
2
  import { css, html, LitElement } from 'lit';
3
- import { cssEscape, getComposedChildren, getComposedParent, isComposedAncestor, isVisible } from '../../helpers/dom.js';
3
+ import { getComposedChildren, getComposedParent, isComposedAncestor, isVisible } from '../../helpers/dom.js';
4
4
  import { getComposedActiveElement } from '../../helpers/focus.js';
5
5
 
6
6
  const BACKDROP_HIDDEN = 'data-d2l-backdrop-hidden';
@@ -103,7 +103,7 @@ class Backdrop extends LitElement {
103
103
 
104
104
  if (this._state === null) {
105
105
  preventBodyScroll(this);
106
- const target = this.parentNode.querySelector(`#${cssEscape(this.forTarget)}`);
106
+ const target = this.parentNode.querySelector(`#${CSS.escape(this.forTarget)}`);
107
107
  // aria-hidden elements cannot have focus, so wait for focus to be within target
108
108
  waitForFocusWithinTarget(target, Date.now() + 200).then(() => {
109
109
  if (!this.shown || this._state !== 'showing') return;
@@ -6,6 +6,7 @@ import { css, html, LitElement, nothing } from 'lit';
6
6
  import { classMap } from 'lit/directives/class-map.js';
7
7
  import { DialogMixin } from './dialog-mixin.js';
8
8
  import { dialogStyles } from './dialog-styles.js';
9
+ import { getFlag } from '../../helpers/flags.js';
9
10
  import { getUniqueId } from '../../helpers/uniqueId.js';
10
11
  import { ifDefined } from 'lit/directives/if-defined.js';
11
12
  import { LocalizeCoreElement } from '../../helpers/localize-core-element.js';
@@ -62,6 +63,11 @@ class Dialog extends PropertyRequiredMixin(LocalizeCoreElement(AsyncContainerMix
62
63
  padding-bottom: 15px;
63
64
  }
64
65
 
66
+ .d2l-dialog-header > div {
67
+ display: flex;
68
+ flex-direction: row-reverse;
69
+ }
70
+
65
71
  .d2l-dialog-header > div > d2l-button-icon {
66
72
  flex: none;
67
73
  margin-block: -4px 0;
@@ -99,7 +105,7 @@ class Dialog extends PropertyRequiredMixin(LocalizeCoreElement(AsyncContainerMix
99
105
  this.critical = false;
100
106
  this.describeContent = false;
101
107
  this.fullHeight = false;
102
- this.preferNative = false;
108
+ this.preferNative = getFlag('GAUD-10409-prefer-native-general-dialogs', true);
103
109
  this.width = 600;
104
110
  this._criticalLabelId = getUniqueId();
105
111
  this._titleId = getUniqueId();
@@ -162,18 +168,17 @@ class Dialog extends PropertyRequiredMixin(LocalizeCoreElement(AsyncContainerMix
162
168
  <div id="${ifDefined(this._textId)}" style=${styleMap(slotStyles)}><slot @slotchange="${this._handleSlotChange}"></slot></div>
163
169
  `;
164
170
 
165
- const contentTabIndex = !this.focusableContentElemPresent ? '0' : undefined;
166
171
  const labelId = this.critical ? `${this._criticalLabelId} ${this._titleId}` : this._titleId;
167
172
  const inner = html`
168
173
  ${this.critical ? html`<div id="${this._criticalLabelId}" hidden>${this.localize('components.dialog.critical')}</div>` : nothing}
169
174
  <div class="d2l-dialog-inner" style=${styleMap(heightOverride)}>
170
175
  <div class="d2l-dialog-header">
171
176
  <div>
172
- <h2 id="${this._titleId}" class="d2l-heading-3">${this.titleText}</h2>
173
177
  <d2l-button-icon icon="tier1:close-small" text="${this.localize('components.dialog.close')}" @click="${this._abort}"></d2l-button-icon>
178
+ ${this._renderHeading(this.titleText, { id: this._titleId, class: 'd2l-heading-3' })}
174
179
  </div>
175
180
  </div>
176
- <div class="d2l-dialog-content" @pending-state="${this._handleAsyncItemState}" tabindex="${ifDefined(contentTabIndex)}">${content}</div>
181
+ ${this._renderContent(content, { handleAsyncItemState: this._handleAsyncItemState, hasTitleText: !!this.titleText })}
177
182
  <div class="${classMap(footerClasses)}">
178
183
  <slot name="footer" @slotchange="${this._handleFooterSlotChange}"></slot>
179
184
  </div>
@@ -210,6 +215,11 @@ class Dialog extends PropertyRequiredMixin(LocalizeCoreElement(AsyncContainerMix
210
215
  this._close('abort');
211
216
  }
212
217
 
218
+ _focusInitial() {
219
+ if (!this.shadowRoot || this._useNative) return;
220
+ else super._focusInitial();
221
+ }
222
+
213
223
  _handleFooterSlotChange(e) {
214
224
  const footerContent = e.target.assignedNodes({ flatten: true });
215
225
  this._hasFooterContent = (footerContent && footerContent.length > 0);
@@ -1,6 +1,4 @@
1
1
 
2
- import { cssEscape } from '../../helpers/dom.js';
3
-
4
2
  const formElements = {
5
3
  button: true,
6
4
  fieldset: true,
@@ -67,7 +65,7 @@ const _tryGetLabelElement = ele => {
67
65
  }
68
66
  if (ele.id) {
69
67
  const rootNode = ele.getRootNode();
70
- return rootNode.querySelector(`label[for="${cssEscape(ele.id)}"]`);
68
+ return rootNode.querySelector(`label[for="${CSS.escape(ele.id)}"]`);
71
69
  }
72
70
  return null;
73
71
  };
@@ -1,4 +1,3 @@
1
- import { cssEscape } from '../../helpers/dom.js';
2
1
  import { SelectionInfo } from './selection-mixin.js';
3
2
 
4
3
  export const SelectionObserverMixin = superclass => class extends superclass {
@@ -103,7 +102,7 @@ export const SelectionObserverMixin = superclass => class extends superclass {
103
102
  }
104
103
 
105
104
  _updateProvider() {
106
- const selectionComponent = this.selectionFor ? this.getRootNode().querySelector(`#${cssEscape(this.selectionFor)}`) : undefined;
105
+ const selectionComponent = this.selectionFor ? this.getRootNode().querySelector(`#${CSS.escape(this.selectionFor)}`) : undefined;
107
106
  if (this._provider === selectionComponent) return;
108
107
 
109
108
  this._disconnectProvider();
@@ -2,7 +2,7 @@ import '../colors/colors.js';
2
2
  import '../icons/icon.js';
3
3
  import './tab-internal.js';
4
4
  import { css, html, LitElement, nothing, unsafeCSS } from 'lit';
5
- import { cssEscape, findComposedAncestor, getOffsetParent, isVisible } from '../../helpers/dom.js';
5
+ import { findComposedAncestor, getOffsetParent, isVisible } from '../../helpers/dom.js';
6
6
  import { getFocusPseudoClass, getFocusRingStyles } from '../../helpers/focus.js';
7
7
  import { ArrowKeysMixin } from '../../mixins/arrow-keys/arrow-keys-mixin.js';
8
8
  import { bodyCompactStyles } from '../typography/styles.js';
@@ -455,7 +455,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(LitElement))
455
455
  // remove with GAUD-8299-core-tabs-use-new-structure flag clean up
456
456
  _animateTabAdditionDefaultSlotBehavior(tabInfo) {
457
457
  const tab = this.shadowRoot
458
- && this.shadowRoot.querySelector(`d2l-tab-internal[controls-panel="${cssEscape(tabInfo.id)}"]`);
458
+ && this.shadowRoot.querySelector(`d2l-tab-internal[controls-panel="${CSS.escape(tabInfo.id)}"]`);
459
459
  if (!tab) Promise.resolve();
460
460
 
461
461
  return new Promise((resolve) => {
@@ -487,7 +487,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(LitElement))
487
487
  // remove with GAUD-8299-core-tabs-use-new-structure flag clean up
488
488
  _animateTabRemovalDefaultSlotBehavior(tabInfo) {
489
489
  const tab = this.shadowRoot &&
490
- this.shadowRoot.querySelector(`d2l-tab-internal[controls-panel="${cssEscape(tabInfo.id)}"]`);
490
+ this.shadowRoot.querySelector(`d2l-tab-internal[controls-panel="${CSS.escape(tabInfo.id)}"]`);
491
491
  if (!tab) Promise.resolve();
492
492
 
493
493
  return new Promise((resolve) => {
@@ -1,5 +1,5 @@
1
1
  import { css, html, LitElement } from 'lit';
2
- import { cssEscape, elemIdListAdd, elemIdListRemove, isComposedAncestor } from '../../helpers/dom.js';
2
+ import { elemIdListAdd, elemIdListRemove, isComposedAncestor } from '../../helpers/dom.js';
3
3
  import { getComposedActiveElement, isFocusable } from '../../helpers/focus.js';
4
4
  import { interactiveElements, interactiveRoles, isInteractive } from '../../helpers/interactive.js';
5
5
  import { announce } from '../../helpers/announce.js';
@@ -398,7 +398,7 @@ class Tooltip extends PopoverMixin(LitElement) {
398
398
 
399
399
  let target;
400
400
  if (this.for) {
401
- const targetSelector = `#${cssEscape(this.for)}`;
401
+ const targetSelector = `#${CSS.escape(this.for)}`;
402
402
  target = ownerRoot.querySelector(targetSelector);
403
403
  target = (target || ownerRoot?.host?.querySelector(targetSelector)) ?? null;
404
404
  } else {
@@ -1,5 +1,3 @@
1
- import { cssEscape } from '../../helpers/dom.js';
2
-
3
1
  class BaseController {
4
2
  constructor(host, name, options = {}) {
5
3
  if (!host || !name) throw new TypeError('SubscriberController: missing host or subscription name');
@@ -211,7 +209,7 @@ export class IdSubscriberController extends BaseSubscriber {
211
209
  }
212
210
 
213
211
  _updateRegistry(registryId) {
214
- const registryComponent = this._host.getRootNode().querySelector(`#${cssEscape(registryId)}`) || undefined;
212
+ const registryComponent = this._host.getRootNode().querySelector(`#${CSS.escape(registryId)}`) || undefined;
215
213
 
216
214
  if (this._registries.get(registryId) === registryComponent) return registryComponent;
217
215
 
@@ -3134,7 +3134,6 @@
3134
3134
  },
3135
3135
  {
3136
3136
  "name": "preferNative",
3137
- "type": "boolean",
3138
3137
  "default": "false"
3139
3138
  }
3140
3139
  ],
package/helpers/dom.js CHANGED
@@ -1,14 +1,5 @@
1
1
  import { getFlag } from './flags.js';
2
2
 
3
- // needed for legacy-Edge, after it's removed use CSS.escape directly
4
- export function cssEscape(val) {
5
- if (window.CSS && window.CSS.escape) {
6
- return window.CSS.escape(val);
7
- }
8
- val = val.replace(/\$/g, '\\$');
9
- return val;
10
- }
11
-
12
3
  export function elemIdListAdd(elem, attrName, value) {
13
4
 
14
5
  if (elem === undefined || elem === null || !elem.getAttribute || !elem.setAttribute) {
@@ -1,5 +1,4 @@
1
1
 
2
- import { cssEscape } from '../../helpers/dom.js';
3
2
  import { PropertyRequiredMixin } from '../property-required/property-required-mixin.js';
4
3
 
5
4
  const getCommonAncestor = (elem1, elem2) => {
@@ -117,7 +116,7 @@ export const LabelledMixin = superclass => class extends PropertyRequiredMixin(s
117
116
  if (!this.labelledBy) {
118
117
  this._updateLabelElem(null);
119
118
  } else {
120
- const labelElem = await waitForElement(this.getRootNode(), `#${cssEscape(this.labelledBy)}`, 3000);
119
+ const labelElem = await waitForElement(this.getRootNode(), `#${CSS.escape(this.labelledBy)}`, 3000);
121
120
  if (!labelElem) {
122
121
  this._throwError(
123
122
  new Error(`LabelledMixin: "${this.tagName.toLowerCase()}" is labelled-by="${this.labelledBy}", but no such element exists`)
@@ -166,7 +165,7 @@ export const LabelledMixin = superclass => class extends PropertyRequiredMixin(s
166
165
  }
167
166
 
168
167
  this._labelObserver = new MutationObserver(() => {
169
- const newElem = this.getRootNode().querySelector(`#${cssEscape(this.labelledBy)}`);
168
+ const newElem = this.getRootNode().querySelector(`#${CSS.escape(this.labelledBy)}`);
170
169
  if (isCustomElement(newElem)) {
171
170
  requestAnimationFrame(() => {
172
171
  // element often sets its label in its own updated(), so we need to wait
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.312.0",
3
+ "version": "3.314.0",
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",