@solcre-org/core-ui 2.11.12 → 2.11.14

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.
@@ -8949,6 +8949,105 @@ class SidebarCustomModalService {
8949
8949
  currentConfig = signal(null);
8950
8950
  componentRef = null;
8951
8951
  viewContainerRef = null;
8952
+ componentRegistry = new Map();
8953
+ async openComponent(componentPath, data, customClass, onClose) {
8954
+ try {
8955
+ if (componentPath.startsWith('./') || componentPath.startsWith('../')) {
8956
+ const module = await this.loadComponentByPath(componentPath);
8957
+ return this.createModalFromModule(module, data, customClass, onClose);
8958
+ }
8959
+ if (this.componentRegistry.has(componentPath)) {
8960
+ return this.openRegisteredComponent(componentPath, data, customClass, onClose);
8961
+ }
8962
+ return this.loadComponentByConvention(componentPath, data, customClass, onClose);
8963
+ }
8964
+ catch (error) {
8965
+ console.error('Error opening component:', componentPath, error);
8966
+ throw new Error(`Failed to load component: ${componentPath}`);
8967
+ }
8968
+ }
8969
+ async loadComponentByConvention(componentName, data, customClass, onClose) {
8970
+ const conventions = [
8971
+ `./components/${componentName}/${componentName}.component`,
8972
+ `./components/${componentName}-modal/${componentName}-modal.component`,
8973
+ `./modals/${componentName}/${componentName}.component`,
8974
+ `./components/${componentName}.component`,
8975
+ ];
8976
+ for (const convention of conventions) {
8977
+ try {
8978
+ const module = await this.loadComponentByPath(convention);
8979
+ return this.createModalFromModule(module, data, customClass, onClose);
8980
+ }
8981
+ catch (error) {
8982
+ continue;
8983
+ }
8984
+ }
8985
+ throw new Error(`Component '${componentName}' not found using any convention. Tried: ${conventions.join(', ')}`);
8986
+ }
8987
+ async loadComponentByPath(path) {
8988
+ return import(/* @vite-ignore */ path);
8989
+ }
8990
+ createModalFromModule(module, data, customClass, onClose) {
8991
+ const componentKey = Object.keys(module).find(key => key.endsWith('Component') &&
8992
+ (key.includes('Modal') || key.includes('Dialog') || Object.keys(module).length === 1)) || Object.keys(module)[0];
8993
+ if (!componentKey) {
8994
+ throw new Error('No component found in module');
8995
+ }
8996
+ const Component = module[componentKey];
8997
+ this.openComponentModal(Component, data, {
8998
+ customClass,
8999
+ onClose
9000
+ });
9001
+ }
9002
+ openModal(componentPath, data, options) {
9003
+ return this.openComponent(componentPath, data, options?.customClass, options?.onClose);
9004
+ }
9005
+ openLazyModal(lazyImport, data, options) {
9006
+ return lazyImport()
9007
+ .then(module => this.createModalFromModule(module, data, options?.customClass, options?.onClose))
9008
+ .catch(error => {
9009
+ console.error('Error loading lazy modal:', error);
9010
+ throw new Error(`Failed to load lazy modal: ${error.message}`);
9011
+ });
9012
+ }
9013
+ openDirectModal(component, data, options) {
9014
+ this.openComponentModal(component, data, {
9015
+ customClass: options?.customClass,
9016
+ onClose: options?.onClose
9017
+ });
9018
+ }
9019
+ registerComponent(name, loader) {
9020
+ this.componentRegistry.set(name, loader);
9021
+ }
9022
+ openRegisteredComponent(componentName, data, customClass, onClose) {
9023
+ const loader = this.componentRegistry.get(componentName);
9024
+ if (!loader) {
9025
+ throw new Error(`Component '${componentName}' not registered. Use registerComponent() first.`);
9026
+ }
9027
+ return loader()
9028
+ .then((module) => {
9029
+ const componentKey = Object.keys(module).find(key => key.endsWith('Component') || key === componentName);
9030
+ if (!componentKey) {
9031
+ throw new Error(`No component found in module for '${componentName}'`);
9032
+ }
9033
+ const Component = module[componentKey];
9034
+ this.openComponentModal(Component, data, {
9035
+ customClass,
9036
+ onClose
9037
+ });
9038
+ })
9039
+ .catch(error => {
9040
+ console.error('Error loading registered component:', componentName, error);
9041
+ throw new Error(`Failed to load component '${componentName}': ${error.message}`);
9042
+ });
9043
+ }
9044
+ getRegisteredComponents() {
9045
+ return Array.from(this.componentRegistry.keys());
9046
+ }
9047
+ registerAndOpenComponent(name, importPath, data, customClass, onClose) {
9048
+ this.registerComponent(name, () => import(/* @vite-ignore */ importPath));
9049
+ return this.openRegisteredComponent(name, data, customClass, onClose);
9050
+ }
8952
9051
  getIsOpen() {
8953
9052
  return this.isOpen;
8954
9053
  }
@@ -8958,6 +9057,9 @@ class SidebarCustomModalService {
8958
9057
  setViewContainerRef(vcr) {
8959
9058
  this.viewContainerRef = vcr;
8960
9059
  }
9060
+ resetViewContainerRef() {
9061
+ this.viewContainerRef = null;
9062
+ }
8961
9063
  openComponentModal(component, data, config) {
8962
9064
  this.closeModal();
8963
9065
  const modalConfig = {
@@ -8969,14 +9071,29 @@ class SidebarCustomModalService {
8969
9071
  };
8970
9072
  this.currentConfig.set(modalConfig);
8971
9073
  this.isOpen.set(true);
9074
+ this.createComponentWhenReady(component, data);
9075
+ }
9076
+ createComponentWhenReady(component, data) {
9077
+ if (this.viewContainerRef) {
9078
+ this.createComponentInstance(component, data);
9079
+ }
9080
+ else {
9081
+ setTimeout(() => this.createComponentWhenReady(component, data), 10);
9082
+ }
9083
+ }
9084
+ createComponentInstance(component, data) {
9085
+ if (this.componentRef) {
9086
+ return;
9087
+ }
8972
9088
  if (this.viewContainerRef && component) {
8973
9089
  this.componentRef = this.viewContainerRef.createComponent(component);
8974
9090
  if (data) {
8975
9091
  Object.keys(data).forEach(key => {
8976
- if (this.componentRef?.instance.hasOwnProperty(key)) {
9092
+ if (key in this.componentRef.instance) {
8977
9093
  this.componentRef.instance[key] = data[key];
8978
9094
  }
8979
9095
  });
9096
+ this.componentRef.changeDetectorRef.detectChanges();
8980
9097
  }
8981
9098
  if (this.componentRef.instance.modalClosed) {
8982
9099
  this.componentRef.instance.modalClosed.subscribe(() => {
@@ -9002,6 +9119,7 @@ class SidebarCustomModalService {
9002
9119
  this.componentRef.destroy();
9003
9120
  this.componentRef = null;
9004
9121
  }
9122
+ this.resetViewContainerRef();
9005
9123
  const config = this.currentConfig();
9006
9124
  if (config?.onClose) {
9007
9125
  config.onClose();
@@ -9009,6 +9127,20 @@ class SidebarCustomModalService {
9009
9127
  this.isOpen.set(false);
9010
9128
  this.currentConfig.set(null);
9011
9129
  }
9130
+ openDynamicComponentModal(importPath, componentName, data, config) {
9131
+ return import(/* @vite-ignore */ importPath)
9132
+ .then((module) => {
9133
+ const Component = module[componentName];
9134
+ if (!Component) {
9135
+ throw new Error(`Component ${componentName} not found in module ${importPath}`);
9136
+ }
9137
+ this.openComponentModal(Component, data, config);
9138
+ })
9139
+ .catch(error => {
9140
+ console.error('Error loading dynamic component:', componentName, 'from:', importPath, error);
9141
+ throw new Error(`Failed to load component ${componentName} from ${importPath}`);
9142
+ });
9143
+ }
9012
9144
  onBackdropClick() {
9013
9145
  const config = this.currentConfig();
9014
9146
  if (config?.closeOnBackdrop !== false) {
@@ -9271,12 +9403,45 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImpor
9271
9403
 
9272
9404
  class SidebarCustomModalComponent {
9273
9405
  modalService = inject(SidebarCustomModalService);
9406
+ cdr = inject(ChangeDetectorRef);
9274
9407
  dynamicComponent;
9275
- ngOnInit() {
9276
- setTimeout(() => {
9277
- this.modalService.setViewContainerRef(this.dynamicComponent);
9408
+ hasInitializedViewContainerRef = false;
9409
+ currentModalState = false;
9410
+ constructor() {
9411
+ effect(() => {
9412
+ const isOpen = this.modalService.getIsOpen()();
9413
+ if (this.currentModalState && !isOpen) {
9414
+ this.hasInitializedViewContainerRef = false;
9415
+ this.modalService['viewContainerRef'] = null;
9416
+ }
9417
+ this.currentModalState = isOpen;
9278
9418
  });
9279
9419
  }
9420
+ ngAfterViewInit() {
9421
+ this.setupViewContainerRefIfAvailable();
9422
+ }
9423
+ ngAfterViewChecked() {
9424
+ this.setupViewContainerRefIfAvailable();
9425
+ }
9426
+ setupViewContainerRefIfAvailable() {
9427
+ if (!this.modalService.getIsOpen()() || !this.dynamicComponent) {
9428
+ return;
9429
+ }
9430
+ const hasViewContainerRef = !!this.modalService['viewContainerRef'];
9431
+ const hasComponentRef = !!this.modalService['componentRef'];
9432
+ if (!hasViewContainerRef || !this.hasInitializedViewContainerRef) {
9433
+ this.modalService.setViewContainerRef(this.dynamicComponent);
9434
+ this.hasInitializedViewContainerRef = true;
9435
+ setTimeout(() => this.cdr.detectChanges(), 0);
9436
+ const config = this.modalService.getCurrentConfig()();
9437
+ if (config?.component && !hasComponentRef) {
9438
+ setTimeout(() => {
9439
+ this.modalService.createComponentInstance(config.component, config.data);
9440
+ this.cdr.detectChanges();
9441
+ }, 0);
9442
+ }
9443
+ }
9444
+ }
9280
9445
  ngOnDestroy() {
9281
9446
  this.modalService.closeModal();
9282
9447
  }
@@ -9298,12 +9463,12 @@ class SidebarCustomModalComponent {
9298
9463
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.6", type: SidebarCustomModalComponent, isStandalone: true, selector: "core-sidebar-custom-modal", viewQueries: [{ propertyName: "dynamicComponent", first: true, predicate: ["dynamicComponent"], descendants: true, read: ViewContainerRef }], ngImport: i0, template: `
9299
9464
  @if(modalService.getIsOpen()()) {
9300
9465
  <ng-container #dynamicComponent></ng-container>
9301
-
9302
- @if(getCurrentConfig()?.template) {
9466
+
9467
+ @if(getCurrentConfig()?.template) {
9303
9468
  <ng-container
9304
9469
  *ngTemplateOutlet="getCurrentConfig()!.template!; context: { $implicit: getCurrentConfig()?.data }">
9305
9470
  </ng-container>
9306
- }
9471
+ }
9307
9472
  }
9308
9473
  `, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
9309
9474
  }
@@ -9316,18 +9481,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImpor
9316
9481
  template: `
9317
9482
  @if(modalService.getIsOpen()()) {
9318
9483
  <ng-container #dynamicComponent></ng-container>
9319
-
9320
- @if(getCurrentConfig()?.template) {
9484
+
9485
+ @if(getCurrentConfig()?.template) {
9321
9486
  <ng-container
9322
9487
  *ngTemplateOutlet="getCurrentConfig()!.template!; context: { $implicit: getCurrentConfig()?.data }">
9323
9488
  </ng-container>
9324
- }
9489
+ }
9325
9490
  }
9326
9491
  `,
9327
9492
  }]
9328
- }], propDecorators: { dynamicComponent: [{
9493
+ }], ctorParameters: () => [], propDecorators: { dynamicComponent: [{
9329
9494
  type: ViewChild,
9330
- args: ['dynamicComponent', { read: ViewContainerRef }]
9495
+ args: ['dynamicComponent', { read: ViewContainerRef, static: false }]
9331
9496
  }] } });
9332
9497
 
9333
9498
  var TimelineStatus;
@@ -9787,11 +9952,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImpor
9787
9952
  // Este archivo es generado automáticamente por scripts/update-version.js
9788
9953
  // No edites manualmente este archivo
9789
9954
  const VERSION = {
9790
- full: '2.11.12',
9955
+ full: '2.11.14',
9791
9956
  major: 2,
9792
9957
  minor: 11,
9793
- patch: 12,
9794
- timestamp: '2025-08-22T09:26:03.222Z',
9958
+ patch: 14,
9959
+ timestamp: '2025-08-22T11:07:18.089Z',
9795
9960
  buildDate: '22/8/2025'
9796
9961
  };
9797
9962
 
@@ -11316,5 +11481,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImpor
11316
11481
  * Generated bundle index. Do not edit.
11317
11482
  */
11318
11483
 
11319
- export { ActiveFiltersComponent, AlertComponent, AlertContainerComponent, AlertService, AlertType, ApiConfigurationProvider, BaseFieldComponent, ButtonContext, ButtonSize, ButtonType, CacheBustingInterceptor, CardComponent, CheckboxFieldComponent, ConfigurationModel, ConfirmationDialogComponent, ConfirmationDialogService, CoreHostDirective, CoreUiHttpLoaderFactory, CoreUiTranslateLoader, CoreUiTranslateService, DataListComponent, DataListItemComponent, DateFieldComponent, DateUtility, DatetimeFieldComponent, DialogActions, DocumentAction, DocumentDisplayMode, DropdownComponent, DropdownDirection, DropdownService, DynamicFieldDirective, FieldErrorsComponent, FieldType, FileFieldComponent, FileModel, FileTemplateModel, FileTemplateType, FileType, FileTypeModel, FileUploadService, FilterModalComponent, FilterService, FilterType, GenericButtonComponent, GenericDocumentationComponent, GenericModalComponent, GenericPaginationComponent, GenericRatingComponent, GenericSidebarComponent, GenericStepsComponent, GenericTableComponent, GenericTabsComponent, GenericTimelineComponent, GlobalApiConfigService, HeaderComponent, HeaderConfigurationService, HeaderElementType, HeaderService, HttpLoaderFactory, ImageModalComponent, LayoutAuth, LayoutBreakpoint, LayoutComponent, LayoutService, LayoutStateService, LayoutType, LoaderComponent, LoaderService, MainNavComponent, MainNavService, ModalMode, ModelApiService, MultiEntryFieldComponent, MultiEntryOutputFormat, NumberFieldComponent, NumberFieldConfigType, NumberFieldType, NumberRange, PERMISSION_ACTIONS_PROVIDER, PERMISSION_PROVIDER, PERMISSION_RESOURCES_PROVIDER, PaginationService, PasswordFieldComponent, PermissionEnumsService, PermissionModel, PermissionService, PermissionWrapperService, PermissionsActions, PermissionsInterceptor, PermissionsResources, ProgressBarComponent, ProgressBarSize, RatingService, RatingSize, RatingType, ResetPasswordModel, RoleModel, SelectFieldComponent, ServerSelectFieldComponent, ServerSelectService, SidebarCustomModalComponent, SidebarHeight, SidebarMobileModalService, SidebarMobileType, SidebarPosition, SidebarService, SidebarState, SidebarTemplateRegistryService, SidebarVisibility, SidebarWidth, SmartFieldComponent, StepSize, StepStatus, StepType, SwitchFieldComponent, TableAction, TableActionService, TableDataService, TextAreaFieldComponent, TextFieldComponent, TimeFieldComponent, TimeInterval, TimelineService, TimelineStatus, TimelineType, TranslationMergeService, UsersModel, VERSION, equalToValidator, isSameDate, provideCoreUiTranslateLoader, providePermissionActions, providePermissionEnums, providePermissionResources, providePermissionService, providePermissionServiceFactory, provideTranslateLoader };
11484
+ export { ActiveFiltersComponent, AlertComponent, AlertContainerComponent, AlertService, AlertType, ApiConfigurationProvider, BaseFieldComponent, ButtonContext, ButtonSize, ButtonType, CacheBustingInterceptor, CardComponent, CheckboxFieldComponent, ConfigurationModel, ConfirmationDialogComponent, ConfirmationDialogService, CoreHostDirective, CoreUiHttpLoaderFactory, CoreUiTranslateLoader, CoreUiTranslateService, DataListComponent, DataListItemComponent, DateFieldComponent, DateUtility, DatetimeFieldComponent, DialogActions, DocumentAction, DocumentDisplayMode, DropdownComponent, DropdownDirection, DropdownService, DynamicFieldDirective, FieldErrorsComponent, FieldType, FileFieldComponent, FileModel, FileTemplateModel, FileTemplateType, FileType, FileTypeModel, FileUploadService, FilterModalComponent, FilterService, FilterType, GenericButtonComponent, GenericDocumentationComponent, GenericModalComponent, GenericPaginationComponent, GenericRatingComponent, GenericSidebarComponent, GenericStepsComponent, GenericTableComponent, GenericTabsComponent, GenericTimelineComponent, GlobalApiConfigService, HeaderComponent, HeaderConfigurationService, HeaderElementType, HeaderService, HttpLoaderFactory, ImageModalComponent, LayoutAuth, LayoutBreakpoint, LayoutComponent, LayoutService, LayoutStateService, LayoutType, LoaderComponent, LoaderService, MainNavComponent, MainNavService, ModalMode, ModelApiService, MultiEntryFieldComponent, MultiEntryOutputFormat, NumberFieldComponent, NumberFieldConfigType, NumberFieldType, NumberRange, PERMISSION_ACTIONS_PROVIDER, PERMISSION_PROVIDER, PERMISSION_RESOURCES_PROVIDER, PaginationService, PasswordFieldComponent, PermissionEnumsService, PermissionModel, PermissionService, PermissionWrapperService, PermissionsActions, PermissionsInterceptor, PermissionsResources, ProgressBarComponent, ProgressBarSize, RatingService, RatingSize, RatingType, ResetPasswordModel, RoleModel, SelectFieldComponent, ServerSelectFieldComponent, ServerSelectService, SidebarCustomModalComponent, SidebarCustomModalService, SidebarHeight, SidebarMobileModalService, SidebarMobileType, SidebarPosition, SidebarService, SidebarState, SidebarTemplateRegistryService, SidebarVisibility, SidebarWidth, SmartFieldComponent, StepSize, StepStatus, StepType, SwitchFieldComponent, TableAction, TableActionService, TableDataService, TextAreaFieldComponent, TextFieldComponent, TimeFieldComponent, TimeInterval, TimelineService, TimelineStatus, TimelineType, TranslationMergeService, UsersModel, VERSION, equalToValidator, isSameDate, provideCoreUiTranslateLoader, providePermissionActions, providePermissionEnums, providePermissionResources, providePermissionService, providePermissionServiceFactory, provideTranslateLoader };
11320
11485
  //# sourceMappingURL=solcre-org-core-ui.mjs.map