pjc-fields 0.0.52 → 0.0.54

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.
@@ -1555,11 +1555,9 @@ class PjcEnumService {
1555
1555
  getItems(url) {
1556
1556
  return this.http
1557
1557
  .get(url)
1558
- .pipe(map((data) => data
1559
- .map((item) => ({ nome: item.nome, descricao: item.descricao }))
1560
- .sort((a, b) => {
1561
- const aDisplay = a.descricao || a.nome || '';
1562
- const bDisplay = b.descricao || b.nome || '';
1558
+ .pipe(map((data) => [...data].sort((a, b) => {
1559
+ const aDisplay = String(a['descricao'] || a['nome'] || '');
1560
+ const bDisplay = String(b['descricao'] || b['nome'] || '');
1563
1561
  return aDisplay.localeCompare(bDisplay);
1564
1562
  })));
1565
1563
  }
@@ -1584,7 +1582,9 @@ class PjcEnumFieldComponent {
1584
1582
  readonly = input(false, ...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
1585
1583
  erros = input({}, ...(ngDevMode ? [{ debugName: "erros" }] : /* istanbul ignore next */ []));
1586
1584
  /** URL of the endpoint that returns the list of items. */
1587
- url = input.required(...(ngDevMode ? [{ debugName: "url" }] : /* istanbul ignore next */ []));
1585
+ url = input('', ...(ngDevMode ? [{ debugName: "url" }] : /* istanbul ignore next */ []));
1586
+ /** Static list of items to display. When provided, takes precedence over `url`. */
1587
+ options = input([], ...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
1588
1588
  /**
1589
1589
  * Key of the object property displayed as the option label in the select.
1590
1590
  * Defaults to 'descricao'.
@@ -1630,8 +1630,12 @@ class PjcEnumFieldComponent {
1630
1630
  }
1631
1631
  constructor() {
1632
1632
  effect(() => {
1633
+ const staticOptions = this.options();
1633
1634
  const url = this.url();
1634
- if (url) {
1635
+ if (staticOptions.length > 0) {
1636
+ this.items.set(staticOptions);
1637
+ }
1638
+ else if (url) {
1635
1639
  this.fetchItems(url);
1636
1640
  }
1637
1641
  else {
@@ -1677,7 +1681,7 @@ class PjcEnumFieldComponent {
1677
1681
  });
1678
1682
  }
1679
1683
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: PjcEnumFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1680
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: PjcEnumFieldComponent, isStandalone: true, selector: "pjc-enum-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, labelVariant: { classPropertyName: "labelVariant", publicName: "labelVariant", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, erros: { classPropertyName: "erros", publicName: "erros", isSignal: true, isRequired: false, transformFunction: null }, url: { classPropertyName: "url", publicName: "url", isSignal: true, isRequired: true, transformFunction: null }, optionLabel: { classPropertyName: "optionLabel", publicName: "optionLabel", isSignal: true, isRequired: false, transformFunction: null }, optionValue: { classPropertyName: "optionValue", publicName: "optionValue", isSignal: true, isRequired: false, transformFunction: null }, filter: { classPropertyName: "filter", publicName: "filter", isSignal: true, isRequired: false, transformFunction: null }, showClear: { classPropertyName: "showClear", publicName: "showClear", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
1684
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: PjcEnumFieldComponent, isStandalone: true, selector: "pjc-enum-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, labelVariant: { classPropertyName: "labelVariant", publicName: "labelVariant", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, erros: { classPropertyName: "erros", publicName: "erros", isSignal: true, isRequired: false, transformFunction: null }, url: { classPropertyName: "url", publicName: "url", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, optionLabel: { classPropertyName: "optionLabel", publicName: "optionLabel", isSignal: true, isRequired: false, transformFunction: null }, optionValue: { classPropertyName: "optionValue", publicName: "optionValue", isSignal: true, isRequired: false, transformFunction: null }, filter: { classPropertyName: "filter", publicName: "filter", isSignal: true, isRequired: false, transformFunction: null }, showClear: { classPropertyName: "showClear", publicName: "showClear", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
1681
1685
  {
1682
1686
  provide: NG_VALUE_ACCESSOR,
1683
1687
  useExisting: forwardRef(() => PjcEnumFieldComponent),
@@ -1694,7 +1698,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1694
1698
  multi: true,
1695
1699
  },
1696
1700
  ], template: "<div class=\"flex flex-col gap-1 w-full\">\n @if (label()) {\n <p-floatlabel [variant]=\"labelVariant()\" class=\"w-full\">\n <p-select\n [inputId]=\"id()\"\n [options]=\"items()\"\n [ngModel]=\"value\"\n (ngModelChange)=\"onModelChange($event)\"\n (onBlur)=\"onModelTouched()\"\n [optionLabel]=\"optionLabel()\"\n [optionValue]=\"optionValue()\"\n appendTo=\"body\"\n [filter]=\"filter()\"\n [filterMatchMode]=\"$any(accentContainsFilter)\"\n [showClear]=\"showClear()\"\n [disabled]=\"disabled || readonly() || loading()\"\n [loading]=\"loading()\"\n styleClass=\"w-full\"\n class=\"w-full\"\n [class.ng-invalid]=\"invalid\"\n [class.ng-dirty]=\"invalid\"\n />\n <label [for]=\"id()\">{{ label() }}</label>\n </p-floatlabel>\n } @else {\n <p-select\n [inputId]=\"id()\"\n [options]=\"items()\"\n [ngModel]=\"value\"\n (ngModelChange)=\"onModelChange($event)\"\n (onBlur)=\"onModelTouched()\"\n [optionLabel]=\"optionLabel()\"\n [optionValue]=\"optionValue()\"\n appendTo=\"body\"\n [filter]=\"filter()\"\n [showClear]=\"showClear()\"\n [placeholder]=\"placeholder()\"\n [disabled]=\"disabled || readonly() || loading()\"\n [loading]=\"loading()\"\n styleClass=\"w-full\"\n class=\"w-full\"\n [class.ng-invalid]=\"invalid\"\n [class.ng-dirty]=\"invalid\"\n />\n }\n\n @if (hint()) {\n <small class=\"text-xs text-surface-500\">{{ hint() }}</small>\n }\n\n @if (errorMessage) {\n <p-message severity=\"error\" variant=\"simple\" size=\"small\">{{ errorMessage }}</p-message>\n }\n\n <ng-content></ng-content>\n</div>\n" }]
1697
- }], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], labelVariant: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelVariant", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], erros: [{ type: i0.Input, args: [{ isSignal: true, alias: "erros", required: false }] }], url: [{ type: i0.Input, args: [{ isSignal: true, alias: "url", required: true }] }], optionLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionLabel", required: false }] }], optionValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionValue", required: false }] }], filter: [{ type: i0.Input, args: [{ isSignal: true, alias: "filter", required: false }] }], showClear: [{ type: i0.Input, args: [{ isSignal: true, alias: "showClear", required: false }] }] } });
1701
+ }], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], labelVariant: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelVariant", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], erros: [{ type: i0.Input, args: [{ isSignal: true, alias: "erros", required: false }] }], url: [{ type: i0.Input, args: [{ isSignal: true, alias: "url", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], optionLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionLabel", required: false }] }], optionValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionValue", required: false }] }], filter: [{ type: i0.Input, args: [{ isSignal: true, alias: "filter", required: false }] }], showClear: [{ type: i0.Input, args: [{ isSignal: true, alias: "showClear", required: false }] }] } });
1698
1702
 
1699
1703
  class PjcErroValidacaoComponent {
1700
1704
  container = inject(ControlContainer);