@brightspace-ui/core 2.98.0 → 2.98.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.
|
@@ -195,26 +195,36 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
|
|
|
195
195
|
|
|
196
196
|
this._textInput = this.shadowRoot.querySelector('d2l-input-text');
|
|
197
197
|
|
|
198
|
+
const hiddenContent = this.shadowRoot.querySelector('.d2l-input-date-hidden-text');
|
|
199
|
+
const tryUpdateHiddenContentWidth = () => {
|
|
200
|
+
const width = Math.ceil(parseFloat(getComputedStyle(hiddenContent).getPropertyValue('width')));
|
|
201
|
+
if (isNaN(width)) return false; // hidden elements will have "auto" width
|
|
202
|
+
this._hiddenContentWidth = `${width}px`;
|
|
203
|
+
return true;
|
|
204
|
+
};
|
|
205
|
+
|
|
198
206
|
this.addEventListener('blur', this._handleBlur);
|
|
199
207
|
this.addEventListener('d2l-localize-resources-change', () => {
|
|
200
208
|
this._dateTimeDescriptor = getDateTimeDescriptorShared(true);
|
|
201
209
|
this.requestUpdate();
|
|
202
|
-
this.updateComplete.then(() =>
|
|
203
|
-
const width = Math.ceil(parseFloat(getComputedStyle(this.shadowRoot.querySelector('.d2l-input-date-hidden-text')).getPropertyValue('width')));
|
|
204
|
-
this._hiddenContentWidth = `${width}px`;
|
|
205
|
-
});
|
|
210
|
+
this.updateComplete.then(() => tryUpdateHiddenContentWidth());
|
|
206
211
|
});
|
|
207
212
|
|
|
208
213
|
this._formattedValue = this.emptyText ? this.emptyText : '';
|
|
209
214
|
|
|
210
215
|
await (document.fonts ? document.fonts.ready : Promise.resolve());
|
|
211
216
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
217
|
+
// resize observer needed to handle case where it's initially hidden
|
|
218
|
+
if (!tryUpdateHiddenContentWidth()) {
|
|
219
|
+
this._hiddenContentResizeObserver = new ResizeObserver(() => {
|
|
220
|
+
if (tryUpdateHiddenContentWidth()) {
|
|
221
|
+
this._hiddenContentResizeObserver.disconnect();
|
|
222
|
+
this._hiddenContentResizeObserver = null;
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
this._hiddenContentResizeObserver.observe(hiddenContent);
|
|
226
|
+
}
|
|
227
|
+
|
|
218
228
|
}
|
|
219
229
|
|
|
220
230
|
render() {
|
|
@@ -271,18 +271,38 @@ class InputTime extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
|
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
const hiddenContent = this.shadowRoot.querySelector('.d2l-input-time-hidden-content');
|
|
274
|
+
const tryUpdateHiddenContentWidth = () => {
|
|
275
|
+
const width = Math.ceil(parseFloat(getComputedStyle(hiddenContent).getPropertyValue('width')));
|
|
276
|
+
if (isNaN(width)) return false; // hidden elements will have "auto" width
|
|
277
|
+
this._hiddenContentWidth = `${width}px`;
|
|
278
|
+
/** @ignore */
|
|
279
|
+
this.dispatchEvent(new CustomEvent(
|
|
280
|
+
'd2l-input-time-hidden-content-width-change',
|
|
281
|
+
{ bubbles: true, composed: false }
|
|
282
|
+
));
|
|
283
|
+
return true;
|
|
284
|
+
};
|
|
285
|
+
|
|
274
286
|
this.addEventListener('d2l-localize-resources-change', async() => {
|
|
275
287
|
await this.updateComplete;
|
|
276
288
|
this._formattedValue = formatTime(getDateFromISOTime(this.value));
|
|
277
289
|
INTERVALS.clear();
|
|
278
290
|
this.requestUpdate();
|
|
279
|
-
this.updateComplete.then(() =>
|
|
291
|
+
this.updateComplete.then(() => tryUpdateHiddenContentWidth());
|
|
280
292
|
});
|
|
281
293
|
|
|
282
294
|
await (document.fonts ? document.fonts.ready : Promise.resolve());
|
|
283
295
|
|
|
284
|
-
|
|
285
|
-
|
|
296
|
+
// resize observer needed to handle case where it's initially hidden
|
|
297
|
+
if (!tryUpdateHiddenContentWidth()) {
|
|
298
|
+
this._hiddenContentResizeObserver = new ResizeObserver(() => {
|
|
299
|
+
if (tryUpdateHiddenContentWidth()) {
|
|
300
|
+
this._hiddenContentResizeObserver.disconnect();
|
|
301
|
+
this._hiddenContentResizeObserver = null;
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
this._hiddenContentResizeObserver.observe(hiddenContent);
|
|
305
|
+
}
|
|
286
306
|
|
|
287
307
|
}
|
|
288
308
|
|
|
@@ -428,15 +448,5 @@ class InputTime extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
|
|
|
428
448
|
}
|
|
429
449
|
}
|
|
430
450
|
|
|
431
|
-
_onResize(hiddenContent) {
|
|
432
|
-
const width = Math.ceil(parseFloat(getComputedStyle(hiddenContent).getPropertyValue('width')));
|
|
433
|
-
this._hiddenContentWidth = `${width}px`;
|
|
434
|
-
|
|
435
|
-
/** @ignore */
|
|
436
|
-
this.dispatchEvent(new CustomEvent(
|
|
437
|
-
'd2l-input-time-hidden-content-width-change',
|
|
438
|
-
{ bubbles: true, composed: false }
|
|
439
|
-
));
|
|
440
|
-
}
|
|
441
451
|
}
|
|
442
452
|
customElements.define('d2l-input-time', InputTime);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "2.98.
|
|
3
|
+
"version": "2.98.2",
|
|
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",
|