npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@senior-erp-service-tower/hst-lookup

v2.0.6

Published

> **Fork:** Código fonte extraído de `@senior-hcm-service-tower/hst-lookup` e mantido independentemente para o contexto ERP.

Readme

Fork: Código fonte extraído de @senior-hcm-service-tower/hst-lookup e mantido independentemente para o contexto ERP.

ERP Service Tower Senior - Lookup

Componente desenvolvido para uso em telas customizadas e BPMs pelo time de serviços customizados ERP da Senior Sistemas.

Requisitos

  • Angular: 18.0.1
  • primeflex: 3.3.1
  • primeicons: 7.0.0
  • primeng: 17.18.9

Instalação

npm install @senior-erp-service-tower/hst-lookup

Visão Geral

O componente hst-lookup é um campo de busca com dialog modal contendo uma tabela paginada com lazy loading. Implementa ControlValueAccessor, permitindo uso com formControlName e ngModel. Ao clicar no campo, um modal é aberto com uma tabela para busca e seleção de registros.


Parâmetros de Entrada (@Input)

| Input | Tipo | Valor Padrão | Descrição | | --- | --- | --- | --- | | config | SearchConfigModel | undefined | Configuração obrigatória do lookup (serviço, colunas, pattern) | | label | string | '' | Label exibida acima do campo | | title | string | 'Selecionar valor para o campo' | Título do modal de busca | | placeHolder | string | 'Clique para buscar' | Placeholder do campo | | errorsMessage | object | undefined | Dicionário customizado de mensagens de erro | | disabled | boolean | false | Desabilita o campo (exibe apenas o valor selecionado) | | showIcon | boolean | true | Exibe ícone de busca (lupa) no campo | | args | object | {} | Parâmetros adicionais enviados ao serviço de busca |


Modelos Exportados

SearchConfigModel

Interface principal de configuração do lookup.

export interface SearchConfigModel {
  filterType: FilterType[];     // Colunas exibidas na tabela de busca
  patternField: string;         // Pattern para exibir o valor selecionado no campo
  service: ServiceSearch<any>;  // Serviço que implementa a busca
  initialValue?: any;           // Valor inicial (objeto completo)
}

| Campo | Tipo | Obrigatório | Descrição | | --- | --- | --- | --- | | filterType | FilterType[] | Sim | Define as colunas da tabela no modal | | patternField | string | Sim | Template para exibição do valor selecionado. Use ${campo} para referenciar propriedades do objeto | | service | ServiceSearch | Sim | Serviço que implementa a interface ServiceSearch | | initialValue | any | Não | Objeto inicial para pré-seleção |


FilterType

Interface que define cada coluna da tabela de busca.

export interface FilterType {
  label: string;  // Título da coluna (header)
  field: string;  // Nome do campo no objeto de dados
}

ServiceSearch

Interface que o serviço de busca deve implementar.

export interface ServiceSearch<T> {
  find(
    top: number,
    skip: number,
    filter: string,
    args?: Record<string, string>
  ): Observable<ResultListInterface<T>>;
}

| Parâmetro | Tipo | Descrição | | --- | --- | --- | | top | number | Quantidade de registros por página | | skip | number | Offset para paginação | | filter | string | Texto digitado pelo usuário para filtro | | args | Record<string, string> | Parâmetros adicionais opcionais (recebidos do Input args) |


ResultListInterface

Interface do retorno esperado pelo serviço de busca.

export interface ResultListInterface<T> {
  size?: number;  // Total de registros
  result: T[];    // Lista de resultados da página atual
}

Sistema de Dicionário de Erros

O lookup possui o mesmo sistema de dicionário de erros do hst-input:

const errors = {
  default: 'Valor inválido!',
  required: 'Campo obrigatório!',
  minlength: 'Tamanho inválido!',
  cpf: 'CPF inválido!',
  cnpj: 'CNPJ inválido!',
  email: 'E-mail inválido!'
};

Personalize com o input errorsMessage:

<hst-lookup
  formControlName="colaborador"
  [config]="config"
  [errorsMessage]="{ required: 'Selecione um colaborador' }">
</hst-lookup>

Exemplo Completo

1. Criar o modelo de dados

export interface ColaboradorModel {
  matricula: number;
  nome: string;
  cargo: string;
}

2. Implementar o serviço de busca

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { ServiceSearch, ResultListInterface } from '@senior-erp-service-tower/hst-lookup';
import { ColaboradorModel } from './colaborador.model';

@Injectable({ providedIn: 'root' })
export class ColaboradorService implements ServiceSearch<ColaboradorModel> {

  private readonly url = 'https://api.exemplo.com/colaboradores';

  constructor(private http: HttpClient) {}

  find(
    top: number,
    skip: number,
    filter: string,
    args?: Record<string, string>
  ): Observable<ResultListInterface<ColaboradorModel>> {
    const params: any = { top, skip };
    if (filter) params.filter = filter;
    if (args?.filial) params.filial = args.filial;

    return this.http.get<ResultListInterface<ColaboradorModel>>(this.url, { params });
  }
}

3. Configurar e utilizar o componente

import { Component } from '@angular/core';
import { FormBuilder, FormGroup, Validators, ReactiveFormsModule } from '@angular/forms';
import { LookupComponent, SearchConfigModel, FilterType } from '@senior-erp-service-tower/hst-lookup';
import { ColaboradorService } from './colaborador.service';

@Component({
  selector: 'app-formulario',
  standalone: true,
  imports: [LookupComponent, ReactiveFormsModule],
  template: `
    <form [formGroup]="form">
      <hst-lookup
        formControlName="colaborador"
        label="Colaborador"
        title="Buscar Colaborador"
        placeHolder="Clique para buscar o colaborador"
        [config]="buscaColabConfig"
        [args]="{ filial: '01' }">
      </hst-lookup>
    </form>
  `
})
export class FormularioComponent {
  form: FormGroup;
  buscaColabConfig: SearchConfigModel;

  constructor(
    private fb: FormBuilder,
    private colaboradorService: ColaboradorService
  ) {
    this.form = this.fb.group({
      colaborador: [null, Validators.required]
    });

    this.buscaColabConfig = {
      filterType: [
        { label: 'Matrícula', field: 'matricula' } as FilterType,
        { label: 'Nome', field: 'nome' } as FilterType,
        { label: 'Cargo', field: 'cargo' } as FilterType
      ],
      patternField: '${matricula} - ${nome}',
      service: this.colaboradorService
    };
  }
}

Exemplo com Valor Inicial

Para pré-selecionar um valor ao carregar o componente:

this.buscaColabConfig = {
  filterType: [
    { label: 'Matrícula', field: 'matricula' },
    { label: 'Nome', field: 'nome' }
  ],
  patternField: '${matricula} - ${nome}',
  service: this.colaboradorService,
  initialValue: { matricula: 12345, nome: 'João da Silva' }
};

Ou via FormControl:

this.form.get('colaborador')?.setValue({ matricula: 12345, nome: 'João da Silva' });

Comportamento do Modal

  1. Ao clicar no campo, o modal é aberto com uma tabela paginada
  2. O usuário pode digitar um filtro e pressionar Enter ou clicar no botão de busca
  3. A tabela exibe os resultados com paginação (10 registros por página)
  4. Ao clicar em uma linha, o objeto é selecionado e o modal fecha
  5. O valor exibido no campo segue o patternField configurado

Indicador de Campo Obrigatório

Se o FormControl possuir o validador Validators.required, um asterisco vermelho (*) será exibido automaticamente antes da label.