@brightspace-ui/core 2.98.0 → 2.98.1
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.
|
@@ -14,7 +14,6 @@ import { getUniqueId } from '../../helpers/uniqueId.js';
|
|
|
14
14
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
15
15
|
import { LabelledMixin } from '../../mixins/labelled-mixin.js';
|
|
16
16
|
import { LocalizeCoreElement } from '../../helpers/localize-core-element.js';
|
|
17
|
-
import ResizeObserver from 'resize-observer-polyfill/dist/ResizeObserver.es.js';
|
|
18
17
|
import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
|
|
19
18
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
20
19
|
|
|
@@ -195,26 +194,36 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
|
|
|
195
194
|
|
|
196
195
|
this._textInput = this.shadowRoot.querySelector('d2l-input-text');
|
|
197
196
|
|
|
197
|
+
const hiddenContent = this.shadowRoot.querySelector('.d2l-input-date-hidden-text');
|
|
198
|
+
const tryUpdateHiddenContentWidth = () => {
|
|
199
|
+
const width = Math.ceil(parseFloat(getComputedStyle(hiddenContent).getPropertyValue('width')));
|
|
200
|
+
if (isNaN(width)) return false; // hidden elements will have "auto" width
|
|
201
|
+
this._hiddenContentWidth = `${width}px`;
|
|
202
|
+
return true;
|
|
203
|
+
};
|
|
204
|
+
|
|
198
205
|
this.addEventListener('blur', this._handleBlur);
|
|
199
206
|
this.addEventListener('d2l-localize-resources-change', () => {
|
|
200
207
|
this._dateTimeDescriptor = getDateTimeDescriptorShared(true);
|
|
201
208
|
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
|
-
});
|
|
209
|
+
this.updateComplete.then(() => tryUpdateHiddenContentWidth());
|
|
206
210
|
});
|
|
207
211
|
|
|
208
212
|
this._formattedValue = this.emptyText ? this.emptyText : '';
|
|
209
213
|
|
|
210
214
|
await (document.fonts ? document.fonts.ready : Promise.resolve());
|
|
211
215
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
216
|
+
// resize observer needed to handle case where it's initially hidden
|
|
217
|
+
if (!tryUpdateHiddenContentWidth()) {
|
|
218
|
+
this._hiddenContentResizeObserver = new ResizeObserver(() => {
|
|
219
|
+
if (tryUpdateHiddenContentWidth()) {
|
|
220
|
+
this._hiddenContentResizeObserver.disconnect();
|
|
221
|
+
this._hiddenContentResizeObserver = null;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
this._hiddenContentResizeObserver.observe(hiddenContent);
|
|
225
|
+
}
|
|
226
|
+
|
|
218
227
|
}
|
|
219
228
|
|
|
220
229
|
render() {
|
|
@@ -15,7 +15,6 @@ import { inputLabelStyles } from './input-label-styles.js';
|
|
|
15
15
|
import { inputStyles } from './input-styles.js';
|
|
16
16
|
import { LabelledMixin } from '../../mixins/labelled-mixin.js';
|
|
17
17
|
import { offscreenStyles } from '../offscreen/offscreen.js';
|
|
18
|
-
import ResizeObserver from 'resize-observer-polyfill/dist/ResizeObserver.es.js';
|
|
19
18
|
import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
|
|
20
19
|
|
|
21
20
|
const MIDNIGHT = new Date(2020, 0, 1, 0, 0, 0);
|
|
@@ -271,18 +270,38 @@ class InputTime extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
|
|
|
271
270
|
}
|
|
272
271
|
|
|
273
272
|
const hiddenContent = this.shadowRoot.querySelector('.d2l-input-time-hidden-content');
|
|
273
|
+
const tryUpdateHiddenContentWidth = () => {
|
|
274
|
+
const width = Math.ceil(parseFloat(getComputedStyle(hiddenContent).getPropertyValue('width')));
|
|
275
|
+
if (isNaN(width)) return false; // hidden elements will have "auto" width
|
|
276
|
+
this._hiddenContentWidth = `${width}px`;
|
|
277
|
+
/** @ignore */
|
|
278
|
+
this.dispatchEvent(new CustomEvent(
|
|
279
|
+
'd2l-input-time-hidden-content-width-change',
|
|
280
|
+
{ bubbles: true, composed: false }
|
|
281
|
+
));
|
|
282
|
+
return true;
|
|
283
|
+
};
|
|
284
|
+
|
|
274
285
|
this.addEventListener('d2l-localize-resources-change', async() => {
|
|
275
286
|
await this.updateComplete;
|
|
276
287
|
this._formattedValue = formatTime(getDateFromISOTime(this.value));
|
|
277
288
|
INTERVALS.clear();
|
|
278
289
|
this.requestUpdate();
|
|
279
|
-
this.updateComplete.then(() =>
|
|
290
|
+
this.updateComplete.then(() => tryUpdateHiddenContentWidth());
|
|
280
291
|
});
|
|
281
292
|
|
|
282
293
|
await (document.fonts ? document.fonts.ready : Promise.resolve());
|
|
283
294
|
|
|
284
|
-
|
|
285
|
-
|
|
295
|
+
// resize observer needed to handle case where it's initially hidden
|
|
296
|
+
if (!tryUpdateHiddenContentWidth()) {
|
|
297
|
+
this._hiddenContentResizeObserver = new ResizeObserver(() => {
|
|
298
|
+
if (tryUpdateHiddenContentWidth()) {
|
|
299
|
+
this._hiddenContentResizeObserver.disconnect();
|
|
300
|
+
this._hiddenContentResizeObserver = null;
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
this._hiddenContentResizeObserver.observe(hiddenContent);
|
|
304
|
+
}
|
|
286
305
|
|
|
287
306
|
}
|
|
288
307
|
|
|
@@ -428,15 +447,5 @@ class InputTime extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
|
|
|
428
447
|
}
|
|
429
448
|
}
|
|
430
449
|
|
|
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
450
|
}
|
|
442
451
|
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.1",
|
|
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",
|