@skyux/core 12.1.0 → 12.3.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.
@@ -1248,10 +1248,9 @@ class SkyDynamicComponentService {
1248
1248
  * Creates an instance of the specified component and adds it to the specified location
1249
1249
  * on the page.
1250
1250
  */
1251
- createComponent(componentType, options) {
1252
- options ||= {
1253
- location: SkyDynamicComponentLocation.BodyBottom,
1254
- };
1251
+ createComponent(componentType, options = {
1252
+ location: SkyDynamicComponentLocation.BodyBottom,
1253
+ }) {
1255
1254
  const environmentInjector = createEnvironmentInjector(options.providers ?? [], options.environmentInjector ?? this.#environmentInjector);
1256
1255
  let componentRef;
1257
1256
  if (options.viewContainerRef) {
@@ -1264,34 +1263,41 @@ class SkyDynamicComponentService {
1264
1263
  environmentInjector,
1265
1264
  });
1266
1265
  this.#applicationRef.attachView(componentRef.hostView);
1266
+ this.#insertComponentAtLocation(componentRef, options);
1267
+ }
1268
+ if (options.className) {
1267
1269
  const el = this.#getRootNode(componentRef);
1268
- const bodyEl = this.#windowRef.nativeWindow.document.body;
1269
- switch (options.location) {
1270
- case SkyDynamicComponentLocation.BeforeElement:
1271
- if (!options.referenceEl) {
1272
- throw new Error('[SkyDynamicComponentService] Could not create a component at location `SkyDynamicComponentLocation.BeforeElement` because a reference element was not provided.');
1273
- }
1274
- this.#renderer.insertBefore(options.referenceEl.parentElement, el, options.referenceEl);
1275
- break;
1276
- case SkyDynamicComponentLocation.ElementTop:
1277
- if (!options.referenceEl) {
1278
- throw new Error('[SkyDynamicComponentService] Could not create a component at location `SkyDynamicComponentLocation.ElementTop` because a reference element was not provided.');
1279
- }
1280
- this.#renderer.insertBefore(options.referenceEl, el, options.referenceEl.firstChild);
1281
- break;
1282
- case SkyDynamicComponentLocation.ElementBottom:
1283
- this.#renderer.appendChild(options.referenceEl, el);
1284
- break;
1285
- case SkyDynamicComponentLocation.BodyTop:
1286
- this.#renderer.insertBefore(bodyEl, el, bodyEl.firstChild);
1287
- break;
1288
- default:
1289
- this.#renderer.appendChild(bodyEl, el);
1290
- break;
1291
- }
1270
+ this.#renderer.addClass(el, options.className);
1292
1271
  }
1293
1272
  return componentRef;
1294
1273
  }
1274
+ #insertComponentAtLocation(componentRef, options) {
1275
+ const el = this.#getRootNode(componentRef);
1276
+ const bodyEl = this.#windowRef.nativeWindow.document.body;
1277
+ switch (options.location) {
1278
+ case SkyDynamicComponentLocation.BeforeElement:
1279
+ if (!options.referenceEl) {
1280
+ throw new Error('[SkyDynamicComponentService] Could not create a component at location `SkyDynamicComponentLocation.BeforeElement` because a reference element was not provided.');
1281
+ }
1282
+ this.#renderer.insertBefore(options.referenceEl.parentElement, el, options.referenceEl);
1283
+ break;
1284
+ case SkyDynamicComponentLocation.ElementTop:
1285
+ if (!options.referenceEl) {
1286
+ throw new Error('[SkyDynamicComponentService] Could not create a component at location `SkyDynamicComponentLocation.ElementTop` because a reference element was not provided.');
1287
+ }
1288
+ this.#renderer.insertBefore(options.referenceEl, el, options.referenceEl.firstChild);
1289
+ break;
1290
+ case SkyDynamicComponentLocation.ElementBottom:
1291
+ this.#renderer.appendChild(options.referenceEl, el);
1292
+ break;
1293
+ case SkyDynamicComponentLocation.BodyTop:
1294
+ this.#renderer.insertBefore(bodyEl, el, bodyEl.firstChild);
1295
+ break;
1296
+ default:
1297
+ this.#renderer.appendChild(bodyEl, el);
1298
+ break;
1299
+ }
1300
+ }
1295
1301
  /**
1296
1302
  * Removes a component ref from the page
1297
1303
  * @param componentRef Component ref for the component being removed
@@ -4110,29 +4116,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImpor
4110
4116
  }] });
4111
4117
 
4112
4118
  const CLS_VIEWKEEPER_FIXED = 'sky-viewkeeper-fixed';
4119
+ const CLS_VIEWKEEPER_FIXED_NOT_LAST = 'sky-viewkeeper-fixed-not-last';
4120
+ const CLS_VIEWKEEPER_BOUNDARY = 'sky-viewkeeper-boundary';
4113
4121
  const EVT_AFTER_VIEWKEEPER_SYNC = 'afterViewkeeperSync';
4114
- let styleEl;
4115
4122
  let nextIdIndex;
4116
- function ensureStyleEl() {
4117
- if (!styleEl) {
4118
- styleEl = document.createElement('style');
4119
- const css = document.createTextNode(`
4120
- .${CLS_VIEWKEEPER_FIXED} {
4121
- position: fixed !important;
4122
- z-index: 999;
4123
- opacity: 0.95;
4124
- overflow: hidden;
4125
- }
4126
-
4127
- .sky-theme-modern .${CLS_VIEWKEEPER_FIXED} {
4128
- box-shadow: 0px 1px 8px -1px rgba(0, 0, 0, 0.3);
4129
- opacity: initial;
4130
- }
4131
- `);
4132
- styleEl.appendChild(css);
4133
- document.head.appendChild(styleEl);
4134
- }
4135
- }
4136
4123
  function nextId() {
4137
4124
  nextIdIndex = (nextIdIndex || 0) + 1;
4138
4125
  return 'viewkeeper-' + nextIdIndex;
@@ -4225,7 +4212,7 @@ class SkyViewkeeper {
4225
4212
  window.addEventListener('scroll', this.#syncElPositionHandler, true);
4226
4213
  window.addEventListener('resize', this.#syncElPositionHandler);
4227
4214
  window.addEventListener('orientationchange', this.#syncElPositionHandler);
4228
- ensureStyleEl();
4215
+ this.#boundaryEl.classList.add(CLS_VIEWKEEPER_BOUNDARY);
4229
4216
  this.syncElPosition(el, boundaryEl);
4230
4217
  }
4231
4218
  syncElPosition(el, boundaryEl) {
@@ -4240,9 +4227,11 @@ class SkyViewkeeper {
4240
4227
  if (this.#needsUpdating(doFixEl, fixedStyles)) {
4241
4228
  if (doFixEl) {
4242
4229
  this.#fixEl(el, boundaryInfo, fixedStyles);
4230
+ this.#verticalOffsetEl?.classList.add(CLS_VIEWKEEPER_FIXED_NOT_LAST);
4243
4231
  }
4244
4232
  else {
4245
4233
  this.#unfixEl(el);
4234
+ this.#verticalOffsetEl?.classList.remove(CLS_VIEWKEEPER_FIXED_NOT_LAST);
4246
4235
  }
4247
4236
  }
4248
4237
  const evt = createCustomEvent(EVT_AFTER_VIEWKEEPER_SYNC);
@@ -4259,8 +4248,10 @@ class SkyViewkeeper {
4259
4248
  }
4260
4249
  if (this.#verticalOffsetEl) {
4261
4250
  this.#verticalOffsetEl.removeEventListener(EVT_AFTER_VIEWKEEPER_SYNC, this.#syncElPositionHandler);
4251
+ this.#verticalOffsetEl.classList.remove(CLS_VIEWKEEPER_FIXED_NOT_LAST);
4262
4252
  }
4263
4253
  this.#spacerResizeObserver?.disconnect();
4254
+ this.#boundaryEl?.classList.remove(CLS_VIEWKEEPER_BOUNDARY);
4264
4255
  this.#el =
4265
4256
  this.#boundaryEl =
4266
4257
  this.#verticalOffsetEl =
@@ -4612,7 +4603,7 @@ class Version {
4612
4603
  /**
4613
4604
  * Represents the version of @skyux/core.
4614
4605
  */
4615
- const VERSION = new Version('12.1.0');
4606
+ const VERSION = new Version('12.3.0');
4616
4607
 
4617
4608
  /**
4618
4609
  * Generated bundle index. Do not edit.