@praxisui/settings-panel 3.0.0-beta.2 → 3.0.0-beta.4

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.
@@ -7,7 +7,7 @@ import * as i3$1 from '@angular/material/button';
7
7
  import { MatButtonModule } from '@angular/material/button';
8
8
  import * as i4 from '@angular/material/icon';
9
9
  import { MatIconModule } from '@angular/material/icon';
10
- import { PraxisIconDirective, GlobalConfigService, FieldControlType, IconPickerService, LoggerService } from '@praxisui/core';
10
+ import { PraxisIconDirective, SETTINGS_PANEL_DATA as SETTINGS_PANEL_DATA$1, GlobalConfigService, FieldControlType, IconPickerService, LoggerService } from '@praxisui/core';
11
11
  import * as i5 from '@angular/material/tooltip';
12
12
  import { MatTooltipModule } from '@angular/material/tooltip';
13
13
  import { CdkTrapFocus } from '@angular/cdk/a11y';
@@ -87,11 +87,12 @@ class SettingsPanelComponent {
87
87
  this.cdr = cdr;
88
88
  this.dialog = dialog;
89
89
  }
90
- attachContent(component, injector, ref) {
90
+ attachContent(component, injector, ref, inputs) {
91
91
  this.ref = ref;
92
92
  this.contentRef = this.contentHost.createComponent(component, {
93
93
  injector,
94
94
  });
95
+ this.applyInputs(this.contentRef, inputs);
95
96
  const instance = this.contentRef.instance;
96
97
  if (instance.isDirty$) {
97
98
  instance.isDirty$
@@ -132,6 +133,35 @@ class SettingsPanelComponent {
132
133
  }
133
134
  catch { }
134
135
  }
136
+ applyInputs(contentRef, inputs) {
137
+ if (!inputs) {
138
+ return;
139
+ }
140
+ const supportedInputs = this.resolveSupportedInputs(contentRef);
141
+ for (const [key, value] of Object.entries(inputs)) {
142
+ if (supportedInputs && !supportedInputs.has(key)) {
143
+ continue;
144
+ }
145
+ try {
146
+ if (typeof contentRef.setInput === 'function') {
147
+ contentRef.setInput(key, value);
148
+ }
149
+ else {
150
+ contentRef.instance[key] = value;
151
+ }
152
+ }
153
+ catch { }
154
+ }
155
+ contentRef.changeDetectorRef.detectChanges();
156
+ }
157
+ resolveSupportedInputs(contentRef) {
158
+ const componentDef = contentRef.componentType?.ɵcmp;
159
+ const declaredInputs = componentDef?.inputs;
160
+ if (!declaredInputs || typeof declaredInputs !== 'object') {
161
+ return null;
162
+ }
163
+ return new Set(Object.keys(declaredInputs));
164
+ }
135
165
  onReset() {
136
166
  const dialogData = {
137
167
  title: 'Redefinir Alterações',
@@ -311,7 +341,7 @@ class SettingsPanelRef {
311
341
  }
312
342
  }
313
343
 
314
- const SETTINGS_PANEL_DATA = new InjectionToken('SETTINGS_PANEL_DATA');
344
+ const SETTINGS_PANEL_DATA = SETTINGS_PANEL_DATA$1;
315
345
  const SETTINGS_PANEL_REF = new InjectionToken('SETTINGS_PANEL_REF');
316
346
 
317
347
  class SettingsPanelService {
@@ -359,7 +389,7 @@ class SettingsPanelService {
359
389
  ],
360
390
  parent: this.injector,
361
391
  });
362
- panelRef.instance.attachContent(config.content.component, injector, ref);
392
+ panelRef.instance.attachContent(config.content.component, injector, ref, inputs);
363
393
  overlayRef.backdropClick().subscribe(() => ref.close('backdrop'));
364
394
  overlayRef.keydownEvents().subscribe((event) => {
365
395
  if (event.key === 'Escape') {