@brightspace-ui/core 3.335.0 → 3.336.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.
@@ -60,6 +60,7 @@ export const PopoverMixin = superclass => class extends superclass {
60
60
  static properties = {
61
61
  _async: { type: Boolean },
62
62
  _asyncState: { state: true },
63
+ _autoWidth: { state: true },
63
64
  _contentHeight: { state: true },
64
65
  _location: { type: String, reflect: true, attribute: '_location' },
65
66
  _margin: { state: true },
@@ -325,6 +326,7 @@ export const PopoverMixin = superclass => class extends superclass {
325
326
  || properties?.position?.location === positionLocations.inlineEnd) this._margin = 0;
326
327
  else this._margin = 18;
327
328
  this._async = properties?.async ?? false;
329
+ this._autoWidth = properties?.autoWidth ?? false;
328
330
  this._maxHeight = properties?.maxHeight;
329
331
  this._maxWidth = properties?.maxWidth;
330
332
  this._minHeight = properties?.minHeight;
@@ -819,7 +821,6 @@ export const PopoverMixin = superclass => class extends superclass {
819
821
  }
820
822
 
821
823
  #getLocation(spaceAround, spaceAroundScroll, spaceRequired) {
822
-
823
824
  const preferred = this._preferredPosition;
824
825
  if (!preferred.allowFlip) {
825
826
  return preferred.location;
@@ -1024,13 +1025,13 @@ export const PopoverMixin = superclass => class extends superclass {
1024
1025
  if (this._preferredPosition.span === positionSpans.end) {
1025
1026
  position.left = openerRect.left + xAdjustment;
1026
1027
  } else {
1027
- position.right = (openerRect.right * -1) + xAdjustment;
1028
+ position.right = this.clientWidth - openerRect.right + xAdjustment;
1028
1029
  }
1029
1030
  } else {
1030
1031
  if (this._preferredPosition.span === positionSpans.end) {
1031
1032
  position.right = window.innerWidth - openerRect.right + xAdjustment - SCROLLBAR_WIDTH;
1032
1033
  } else {
1033
- position.left = (window.innerWidth - openerRect.left - xAdjustment - SCROLLBAR_WIDTH) * -1;
1034
+ position.left = this.clientWidth - (window.innerWidth - openerRect.left - xAdjustment - SCROLLBAR_WIDTH);
1034
1035
  }
1035
1036
  }
1036
1037
  } else {
@@ -1053,9 +1054,9 @@ export const PopoverMixin = superclass => class extends superclass {
1053
1054
 
1054
1055
  if (this._location === positionLocations.inlineStart) {
1055
1056
  if (!this._rtl) {
1056
- position.right = (openerRect.left - this._offset + 7) * -1; // 7 minor adjustment to position pointer at edge of content
1057
+ position.right = this.clientWidth - (openerRect.left - this._offset + 7); // 7 minor adjustment to position pointer at edge of content
1057
1058
  } else {
1058
- position.left = (window.innerWidth - openerRect.right + 7 - this._offset - SCROLLBAR_WIDTH) * -1; // 7 minor adjustment to position pointer at edge of content
1059
+ position.left = this.clientWidth - (window.innerWidth - openerRect.right + 7 - this._offset - SCROLLBAR_WIDTH); // 7 minor adjustment to position pointer at edge of content
1059
1060
  }
1060
1061
  } else {
1061
1062
  if (!this._rtl) {
@@ -1099,9 +1100,9 @@ export const PopoverMixin = superclass => class extends superclass {
1099
1100
 
1100
1101
  if (this._location === positionLocations.inlineStart) {
1101
1102
  if (!this._rtl) {
1102
- position.right = (openerRect.left - this._offset) * -1;
1103
+ position.right = this.clientWidth - (openerRect.left - this._offset);
1103
1104
  } else {
1104
- position.left = (window.innerWidth - openerRect.right - this._offset - SCROLLBAR_WIDTH) * -1;
1105
+ position.left = this.clientWidth - (window.innerWidth - openerRect.right - this._offset - SCROLLBAR_WIDTH);
1105
1106
  }
1106
1107
  } else {
1107
1108
  if (!this._rtl) {
@@ -1202,6 +1203,12 @@ export const PopoverMixin = superclass => class extends superclass {
1202
1203
  minWidth: this._minWidth ? `${this._minWidth}px` : undefined,
1203
1204
  width: this._width ? `${this._width + 2}px` : undefined
1204
1205
  };
1206
+ if (this._autoWidth) {
1207
+ // if auto-width is set, max-width is set to the available space (i.e. this._width or window width)
1208
+ const isInline = this._location === positionLocations.inlineStart || this._location === positionLocations.inlineEnd;
1209
+ widthStyle.maxWidth = isInline ? widthStyle.width : `${window.innerWidth - 2 * inlineMargin}px`;
1210
+ widthStyle.width = 'auto';
1211
+ }
1205
1212
 
1206
1213
  const contentStyle = {
1207
1214
  maxHeight: this._contentHeight ? `${this._contentHeight}px` : undefined,
@@ -64,6 +64,11 @@ class Tooltip extends PopoverMixin(LitElement) {
64
64
  * @type {'start'|'end'}
65
65
  */
66
66
  align: { type: String, reflect: true },
67
+ /**
68
+ * Let the tooltip adjust to the content width
69
+ * @type {boolean}
70
+ */
71
+ autoWidth: { type: Boolean, attribute: 'auto-width', reflect: true },
67
72
  /**
68
73
  * ADVANCED: Announce the tooltip innerText when applicable (for use with custom elements)
69
74
  * @type {boolean}
@@ -152,6 +157,13 @@ class Tooltip extends PopoverMixin(LitElement) {
152
157
  padding-inline: ${contentHorizontalPadding - contentBorderSize}px;
153
158
  white-space: normal;
154
159
  }
160
+ :host([auto-width]) {
161
+ width: auto;
162
+ }
163
+ :host([auto-width]) .d2l-tooltip-content {
164
+ max-width: none;
165
+ overflow: visible;
166
+ }
155
167
  ::slotted(ul),
156
168
  ::slotted(ol) {
157
169
  padding-inline-start: 1rem;
@@ -167,6 +179,7 @@ class Tooltip extends PopoverMixin(LitElement) {
167
179
  constructor() {
168
180
  super();
169
181
  this.announced = false;
182
+ this.autoWidth = false;
170
183
  this.closeOnClick = false;
171
184
  this.delay = 300;
172
185
  this.disableFocusLock = false;
@@ -232,9 +245,9 @@ class Tooltip extends PopoverMixin(LitElement) {
232
245
 
233
246
  willUpdate(changedProperties) {
234
247
  super.willUpdate(changedProperties);
235
-
236
- if (changedProperties.has('align') || changedProperties.has('forceShow') || changedProperties.has('offset') || changedProperties.has('positionLocation')) {
248
+ if (['align', 'forceShow', 'offset', 'positionLocation', 'autoWidth'].some(prop => changedProperties.has(prop))) {
237
249
  super.configure({
250
+ autoWidth: this.autoWidth,
238
251
  maxWidth: '350',
239
252
  minWidth: '48',
240
253
  noAutoClose: this.forceShow,
@@ -17927,6 +17927,12 @@
17927
17927
  "type": "boolean",
17928
17928
  "default": "false"
17929
17929
  },
17930
+ {
17931
+ "name": "auto-width",
17932
+ "description": "Let the tooltip adjust to the content width",
17933
+ "type": "boolean",
17934
+ "default": "false"
17935
+ },
17930
17936
  {
17931
17937
  "name": "close-on-click",
17932
17938
  "description": "ADVANCED: Causes the tooltip to close when its target is clicked",
@@ -18005,6 +18011,13 @@
18005
18011
  "type": "boolean",
18006
18012
  "default": "false"
18007
18013
  },
18014
+ {
18015
+ "name": "autoWidth",
18016
+ "attribute": "auto-width",
18017
+ "description": "Let the tooltip adjust to the content width",
18018
+ "type": "boolean",
18019
+ "default": "false"
18020
+ },
18008
18021
  {
18009
18022
  "name": "closeOnClick",
18010
18023
  "attribute": "close-on-click",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.335.0",
3
+ "version": "3.336.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",