0.0.8 • Published 10 months ago

ngx-ui-builder v0.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

ngx-ui-builder

This library provide components that can generate by configs.

Installation

Using npm:

npm i ngx-ui-builder

Components

  1. Table
  2. Pagination

Example

Add ussage package to NgModule imports. The exmaple below describe how to use Table module.

// example.module.ts
import { NubTableModule } from 'ngx-ui-builder/table';

@NgModule({
  ...
  imports: [NubTableModule,...]
  ...
})
// example.compnent.ts
import { NubTableComponent, NubTableConfig } from 'ngx-ui-builder/table';

@Component({
  selector: 'app-example',
  template: '<nub-table [configs]="tableConfigs"></nub-table>',
})
export class TableComponent {
  @ViewChild(NubTableComponent) nubTable!: NubTableComponent;

  tableConfigs: NubTableConfig = {
    columnOptions: [
      {
        title: 'Name',
        property: 'name',
        sort: {},
        filter: {
          component: FilterCellNameComponent,
        },
      },
      {
        title: 'Link',
        property: 'url',
        component: LinkCellComponent,
        filter: {},
      },
    ],
    mapQueryParams: (queryParams) => {
      queryParams = Object.assign(
        {},
        queryParams,
      );
      return {
        limit: queryParams.pageSize,
        offset: queryParams.pageSize * (queryParams.page - 1),
      };
    },
    dataSource: (params: any) => {
      return this.httpClient.get(`yoururl?${params}`).pipe(
        map(res => {
          return {
            data: res['results'],
            totalItems: res['count'],
          };
        })
      );
    }
  };

  constructor(
    private httpClient: HttpClient
  ) { }

}

Compatibility

ngx-ui-builderAngular
0.x.x16.2.x

Further information

The project is in the planning stage and will add more modules in the future. All questions or contributions are welcome.

0.0.8

10 months ago

0.0.7

1 year ago

0.0.1

2 years ago

0.0.6

2 years ago