@skyux/core 12.2.0 → 12.4.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
@@ -4597,7 +4603,7 @@ class Version {
4597
4603
  /**
4598
4604
  * Represents the version of @skyux/core.
4599
4605
  */
4600
- const VERSION = new Version('12.2.0');
4606
+ const VERSION = new Version('12.4.0');
4601
4607
 
4602
4608
  /**
4603
4609
  * Generated bundle index. Do not edit.