@experteam-mx/ngx-table 0.0.4 → 1.0.2

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.
@@ -0,0 +1,16 @@
1
+ # This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2
+ # For additional information regarding the format and rule options, please see:
3
+ # https://github.com/browserslist/browserslist#queries
4
+
5
+ # For the full list of supported browsers by the Angular framework, please see:
6
+ # https://angular.io/guide/browser-support
7
+
8
+ # You can see what browsers were selected by your queries by running:
9
+ # npx browserslist
10
+
11
+ last 1 Chrome version
12
+ last 1 Firefox version
13
+ last 2 Edge major versions
14
+ last 2 Safari major versions
15
+ last 2 iOS major versions
16
+ Firefox ESR
package/karma.conf.js ADDED
@@ -0,0 +1,44 @@
1
+ // Karma configuration file, see link for more information
2
+ // https://karma-runner.github.io/1.0/config/configuration-file.html
3
+
4
+ module.exports = function (config) {
5
+ config.set({
6
+ basePath: '',
7
+ frameworks: ['jasmine', '@angular-devkit/build-angular'],
8
+ plugins: [
9
+ require('karma-jasmine'),
10
+ require('karma-chrome-launcher'),
11
+ require('karma-jasmine-html-reporter'),
12
+ require('karma-coverage'),
13
+ require('@angular-devkit/build-angular/plugins/karma')
14
+ ],
15
+ client: {
16
+ jasmine: {
17
+ // you can add configuration options for Jasmine here
18
+ // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
19
+ // for example, you can disable the random execution with `random: false`
20
+ // or set a specific seed with `seed: 4321`
21
+ },
22
+ clearContext: false // leave Jasmine Spec Runner output visible in browser
23
+ },
24
+ jasmineHtmlReporter: {
25
+ suppressAll: true // removes the duplicated traces
26
+ },
27
+ coverageReporter: {
28
+ dir: require('path').join(__dirname, '../../coverage/ngx-table'),
29
+ subdir: '.',
30
+ reporters: [
31
+ { type: 'html' },
32
+ { type: 'text-summary' }
33
+ ]
34
+ },
35
+ reporters: ['progress', 'kjhtml'],
36
+ port: 9876,
37
+ colors: true,
38
+ logLevel: config.LOG_INFO,
39
+ autoWatch: true,
40
+ browsers: ['Chrome'],
41
+ singleRun: false,
42
+ restartOnFileChange: true
43
+ });
44
+ };
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/ngx-table",
4
+ "deleteDestPath": false,
5
+ "lib": {
6
+ "entryFile": "src/public-api.ts"
7
+ },
8
+ "allowedNonPeerDependencies": [
9
+ "."
10
+ ]
11
+ }
package/package.json CHANGED
@@ -1,33 +1,16 @@
1
1
  {
2
2
  "name": "@experteam-mx/ngx-table",
3
- "version": "0.0.4",
3
+ "version": "1.0.2",
4
4
  "license": "MIT",
5
- "peerDependencies": {},
6
- "dependencies": {
5
+ "peerDependencies": {
7
6
  "@angular/common": "^12.0.2",
8
- "@angular/core": "^12.0.2",
7
+ "@angular/core": "^12.0.2"
8
+ },
9
+ "dependencies": {
10
+ "@angular/localize": "^13.2.2",
11
+ "@ng-bootstrap/ng-bootstrap": "^10.0.0",
9
12
  "bootstrap": "^5.1.3",
10
- "bootstrap-icons": "^1.8.1",
13
+ "ngx-skeleton-loader": "^5.0.0",
11
14
  "tslib": "^2.1.0"
12
- },
13
- "module": "fesm2015/experteam-mx-ngx-table.mjs",
14
- "es2020": "fesm2020/experteam-mx-ngx-table.mjs",
15
- "esm2020": "esm2020/experteam-mx-ngx-table.mjs",
16
- "fesm2020": "fesm2020/experteam-mx-ngx-table.mjs",
17
- "fesm2015": "fesm2015/experteam-mx-ngx-table.mjs",
18
- "typings": "experteam-mx-ngx-table.d.ts",
19
- "exports": {
20
- "./package.json": {
21
- "default": "./package.json"
22
- },
23
- ".": {
24
- "types": "./experteam-mx-ngx-table.d.ts",
25
- "esm2020": "./esm2020/experteam-mx-ngx-table.mjs",
26
- "es2020": "./fesm2020/experteam-mx-ngx-table.mjs",
27
- "es2015": "./fesm2015/experteam-mx-ngx-table.mjs",
28
- "node": "./fesm2015/experteam-mx-ngx-table.mjs",
29
- "default": "./fesm2020/experteam-mx-ngx-table.mjs"
30
- }
31
- },
32
- "sideEffects": false
33
- }
15
+ }
16
+ }
@@ -0,0 +1,75 @@
1
+ <div class="container-fluid">
2
+ <h3 class="text-center" *ngIf="configsRender.titleTable != null">{{ configsRender.titleTable }}</h3>
3
+ <div *ngIf="!configsRender.search.active && configsRender.actions.add?.active" class="row justify-content-end mb-2">
4
+ <div class="col d-flex justify-content-end">
5
+ <button *ngIf="configsRender.actions.add?.active" class="btn btn-success" type="button" (click)="onActionClick({event: $event,type: 'add'})">
6
+ <span [innerHTML]="configsRender.actions.add?.labelHtml"></span>
7
+ </button>
8
+ </div>
9
+ </div>
10
+ <div *ngIf="configsRender.search.active" class="row justify-content-end mb-2">
11
+ <div class="col d-flex justify-content-end">
12
+ <button *ngIf="configsRender.actions.add?.active" class="btn btn-success" type="button" (click)="onActionClick({event: $event,type: 'add'})">
13
+ <span [innerHTML]="configsRender.actions.add?.labelHtml"></span>
14
+ </button>
15
+ </div>
16
+ <div class="col-lg-3">
17
+ <div class="input-group">
18
+ <input type="text" class="form-control" [(ngModel)]="configsRender.search.textSearch" [placeholder]="configsRender.search.placeholderSearch != undefined ? configsRender.search.placeholderSearch : ''" (input)="onKeySearch()">
19
+ <button class="btn btn-primary" type="button" (click)="onRestarSeach()">
20
+ <i class="bi bi-arrow-counterclockwise"></i>
21
+ </button>
22
+ </div>
23
+ </div>
24
+ </div>
25
+ <ngx-skeleton-loader *ngIf="configsRender.loading" count="5"></ngx-skeleton-loader>
26
+ <table *ngIf="!configsRender.loading" class="table table-striped table-bordered">
27
+ <thead>
28
+ <tr>
29
+ <th *ngFor="let col of headRowRender">{{ col.label }}</th>
30
+ <th class="col-compact" *ngIf="configsRender.actions.edit?.active || configsRender.actions.delete?.active">
31
+ Actions
32
+ </th>
33
+ </tr>
34
+ </thead>
35
+ <tbody>
36
+ <ng-container *ngFor="let register of registersRender; let i = index">
37
+ <tr [class.pointer]="register.configRegister?.actions?.select?.active" (click)="register.configRegister?.actions?.select?.active ? onActionClick({event: $event,type: 'select',data: register}):return">
38
+ <ng-container *ngFor="let key of objectKeys(register); let j = index">
39
+ <td [class.text-end]="headRow[j].type == 'number'">{{register[key]}}</td>
40
+ </ng-container>
41
+ <td class="text-nowrap" *ngIf="configsRender.actions.edit?.active || configsRender.actions.delete?.active">
42
+ <button *ngIf="register.configRegister?.actions?.edit?.active" type="button" class="btn btn-primary mx-1" (click)="onActionClick({event: $event,type: 'edit',data: register})">
43
+ <span [innerHTML]="register.configRegister?.actions?.edit?.labelHtml"></span>
44
+ </button>
45
+ <button *ngIf="register.configRegister?.actions?.delete?.active" type="button" class="btn btn-danger mx-1" (click)="onActionClick({event: $event,type: 'delete',data: register})">
46
+ <span [innerHTML]="register.configRegister?.actions?.delete?.labelHtml"></span>
47
+ </button>
48
+ </td>
49
+ </tr>
50
+ </ng-container>
51
+ </tbody>
52
+ </table>
53
+ <div class="position-sticky bottom-0 bg-white" *ngIf="configsRender.paginationActive && configsRender.collectionSize > 0">
54
+ <div class="row justify-content-end border-top pt-2">
55
+ <div class="col-sm-6">
56
+ <ngb-pagination
57
+ class="d-flex justify-content-center"
58
+ [pageSize]="configsRender.pageSize"
59
+ [collectionSize]="configsRender.collectionSize"
60
+ [(page)]="configsRender.page"
61
+ [maxSize]="5"
62
+ [rotate]="true"
63
+ [boundaryLinks]="true"
64
+ [ellipses]="true"
65
+ (pageChange)="onPageChange()"
66
+ size="sm"
67
+ >
68
+ <ng-template ngbPaginationNumber let-page>{{ page }}</ng-template>
69
+ </ngb-pagination>
70
+ </div>
71
+ <div class="col-sm-3">
72
+ </div>
73
+ </div>
74
+ </div>
75
+ </div>
@@ -0,0 +1,102 @@
1
+ /* You can add global styles to this file, and also import other style files */
2
+ $dhlYellow: #FFCC00;
3
+ $dhlYellowOpaque: #fff0b3;
4
+ $darkBlue: #273c5a;
5
+ $medBlue: #002147;
6
+ $lightBlue: #ddf1fa;
7
+ $inputBG: #f9f9f9;
8
+ $inputText: #2664ab;
9
+ $dhlRed: #bb133d;
10
+ $dhlGreen: #007c39;
11
+ $gray80: #333333;
12
+ $gray60: #666666;
13
+ $gray45: #8C8C8C;
14
+ $gray30: #B2B2B2;
15
+ $gray20: #CCCCCC;
16
+ $gray10: #E5E5E5;
17
+ $gray08: #EBEBEB;
18
+ $gray05: #F2F2F2;
19
+
20
+ $primary: $dhlYellow;
21
+ $success: $dhlGreen;
22
+ $danger: $dhlRed;
23
+
24
+ @import "~bootstrap/scss/functions";
25
+ @import "~bootstrap/scss/variables";
26
+ @import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css");
27
+
28
+ $pagination-color: color-contrast($primary);
29
+ $pagination-active-color: color-contrast($primary);
30
+
31
+ :host ::ng-deep{
32
+ @import "~bootstrap/scss/bootstrap";
33
+ }
34
+
35
+ .pointer{
36
+ cursor: pointer;
37
+ }
38
+
39
+ .col-compact{
40
+ width: 1px;
41
+ }
42
+
43
+ .bg-white{
44
+ background-color: #fff !important;
45
+ }
46
+
47
+ table {
48
+ margin: auto;
49
+ width: fit-content!important;
50
+ thead{
51
+ font-weight: bolder;
52
+ position: sticky;
53
+ top: -1px;
54
+ background-color: #fff;
55
+ td:first-child,
56
+ th:first-child{
57
+ &::before{
58
+ content: "";
59
+ position: absolute;
60
+ bottom: 0;
61
+ left: 0;
62
+ height: 1px;
63
+ width: 100%;
64
+ background-color: #00000017;
65
+ }
66
+ }
67
+ td,th{
68
+ background-color: $primary;
69
+ color: color-contrast($primary);
70
+ }
71
+ }
72
+ tfoot{
73
+ font-weight: bolder;
74
+ position: sticky;
75
+ bottom: 0;
76
+ background-color: #fff;
77
+ td:first-child,
78
+ th:first-child{
79
+ &::before{
80
+ content: "";
81
+ position: absolute;
82
+ left: 0;
83
+ top: 0;
84
+ height: 1px;
85
+ width: 100%;
86
+ background-color: #000000;
87
+ }
88
+ &::after{
89
+ content: "";
90
+ position: absolute;
91
+ bottom: 0;
92
+ left: 0;
93
+ height: 2px;
94
+ width: 100%;
95
+ background-color: #000000;
96
+ }
97
+ }
98
+ td,th{
99
+ background-color: $dhlYellowOpaque;
100
+ }
101
+ }
102
+ }
@@ -0,0 +1,25 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { NgxTableComponent } from './ngx-table.component';
4
+
5
+ describe('NgxTableComponent', () => {
6
+ let component: NgxTableComponent;
7
+ let fixture: ComponentFixture<NgxTableComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ NgxTableComponent ]
12
+ })
13
+ .compileComponents();
14
+ });
15
+
16
+ beforeEach(() => {
17
+ fixture = TestBed.createComponent(NgxTableComponent);
18
+ component = fixture.componentInstance;
19
+ fixture.detectChanges();
20
+ });
21
+
22
+ it('should create', () => {
23
+ expect(component).toBeTruthy();
24
+ });
25
+ });
@@ -0,0 +1,151 @@
1
+ import { Component, OnInit, OnChanges, Input, Output, EventEmitter, SimpleChanges } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'ngx-table',
5
+ templateUrl: './ngx-table.component.html',
6
+ styleUrls: ['./ngx-table.component.scss']
7
+ })
8
+ export class NgxTableComponent implements OnInit, OnChanges {
9
+
10
+ constructor() { }
11
+
12
+ @Input() headRow: any[] = new Array()
13
+ headRowRender: any[] = new Array()
14
+
15
+ @Input() registers: any[] = new Array()
16
+ @Input() registersRender: any[] = new Array()
17
+
18
+ @Input() configs: any
19
+ configsRender: any = {}
20
+
21
+ @Output() changePage = new EventEmitter<Object>();
22
+ @Output() clickEvent = new EventEmitter<Object>();
23
+
24
+ configsDefault: any = {
25
+ titleTable: null,
26
+ loading: false,
27
+ paginationActive: false,
28
+ page: 1,
29
+ pageSize: 15,
30
+ collectionSize: 0,
31
+ search:{
32
+ active: false,
33
+ textSearch: '',
34
+ placeholderSearch: 'Search'
35
+ },
36
+ order: {
37
+ active: false,
38
+ field: null,
39
+ asc: false
40
+ },
41
+ actions: {
42
+ add:{
43
+ active: false,
44
+ labelHtml: null
45
+ },
46
+ select:{
47
+ active: false,
48
+ labelHtml: null
49
+ },
50
+ edit:{
51
+ active: false,
52
+ labelHtml: null
53
+ },
54
+ delete:{
55
+ active: false,
56
+ labelHtml: null
57
+ },
58
+ },
59
+ colHead:{
60
+ label: null,
61
+ type: 'string', // string, number
62
+ field: null,
63
+ order: {
64
+ active: false
65
+ }
66
+ }
67
+ }
68
+
69
+ objectKeys( registers: any ){
70
+ let registros = new Array()
71
+ for( let key of Object.keys(registers) ){
72
+ if( key != 'configRegister' ){
73
+ registros.push( key )
74
+ }
75
+ }
76
+
77
+ return registros
78
+ }
79
+
80
+ onPageChange() {
81
+ this.configs = this.configsRender
82
+ this.changePage.emit({
83
+ ...this.configsRender
84
+ });
85
+ }
86
+
87
+ onKeySearch() {
88
+ this.configs = this.configsRender
89
+ this.changePage.emit({
90
+ ...this.configsRender
91
+ });
92
+ }
93
+
94
+ onRestarSeach() {
95
+ this.configs = this.configsRender
96
+ this.changePage.emit({
97
+ ...this.configsRender
98
+ });
99
+ }
100
+
101
+ onActionClick(object: any) {
102
+ object.event.preventDefault()
103
+ object.event.stopPropagation()
104
+
105
+ this.clickEvent.emit({
106
+ type: object.type,
107
+ data: object.data
108
+ });
109
+ }
110
+
111
+ render(){
112
+ this.headRowRender = new Array()
113
+ for( let head of this.headRow ){
114
+ this.headRowRender.push({
115
+ ...this.configsDefault.colHead,
116
+ ...head
117
+ })
118
+ }
119
+
120
+ this.configsRender = {
121
+ titleTable: this.configsDefault.titleTable,
122
+ paginationActive: this.configsDefault.paginationActive,
123
+ page: this.configsDefault.page,
124
+ pageSize: this.configsDefault.pageSize,
125
+ search: this.configsDefault.search,
126
+ order: this.configsDefault.order,
127
+ actions: this.configsDefault.actions,
128
+ ...this.configs,
129
+ collectionSize: this.registers.length,
130
+ }
131
+
132
+ this.registersRender = new Array()
133
+ for( let register of this.registers ){
134
+ this.registersRender.push({
135
+ configRegister: {
136
+ actions: this.configsRender.actions,
137
+ },
138
+ ...register
139
+ })
140
+ }
141
+ }
142
+
143
+ ngOnInit(): void {
144
+ this.render()
145
+ }
146
+
147
+ ngOnChanges(changes: SimpleChanges): void {
148
+ this.render()
149
+ }
150
+
151
+ }
@@ -0,0 +1,23 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { BrowserModule } from '@angular/platform-browser';
3
+ import { FormsModule } from '@angular/forms';
4
+
5
+ import { NgxTableComponent } from './ngx-table.component';
6
+ import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
7
+ import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
8
+
9
+ @NgModule({
10
+ declarations: [
11
+ NgxTableComponent
12
+ ],
13
+ imports: [
14
+ BrowserModule,
15
+ FormsModule,
16
+ NgbModule,
17
+ NgxSkeletonLoaderModule,
18
+ ],
19
+ exports: [
20
+ NgxTableComponent
21
+ ]
22
+ })
23
+ export class NgxTableModule { }
@@ -0,0 +1,16 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { NgxTableService } from './ngx-table.service';
4
+
5
+ describe('NgxTableService', () => {
6
+ let service: NgxTableService;
7
+
8
+ beforeEach(() => {
9
+ TestBed.configureTestingModule({});
10
+ service = TestBed.inject(NgxTableService);
11
+ });
12
+
13
+ it('should be created', () => {
14
+ expect(service).toBeTruthy();
15
+ });
16
+ });
@@ -0,0 +1,9 @@
1
+ import { Injectable } from '@angular/core';
2
+
3
+ @Injectable({
4
+ providedIn: 'root'
5
+ })
6
+ export class NgxTableService {
7
+
8
+ constructor() { }
9
+ }
@@ -1,3 +1,7 @@
1
- export * from './lib/ngx-table.service';
2
- export * from './lib/ngx-table.component';
3
- export * from './lib/ngx-table.module';
1
+ /*
2
+ * Public API Surface of ngx-table
3
+ */
4
+
5
+ export * from './lib/ngx-table.service';
6
+ export * from './lib/ngx-table.component';
7
+ export * from './lib/ngx-table.module';
package/src/test.ts ADDED
@@ -0,0 +1,27 @@
1
+ // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2
+
3
+ import 'zone.js';
4
+ import 'zone.js/testing';
5
+ import { getTestBed } from '@angular/core/testing';
6
+ import {
7
+ BrowserDynamicTestingModule,
8
+ platformBrowserDynamicTesting
9
+ } from '@angular/platform-browser-dynamic/testing';
10
+
11
+ declare const require: {
12
+ context(path: string, deep?: boolean, filter?: RegExp): {
13
+ <T>(id: string): T;
14
+ keys(): string[];
15
+ };
16
+ };
17
+
18
+ // First, initialize the Angular testing environment.
19
+ getTestBed().initTestEnvironment(
20
+ BrowserDynamicTestingModule,
21
+ platformBrowserDynamicTesting(),
22
+ );
23
+
24
+ // Then we find all the tests.
25
+ const context = require.context('./', true, /\.spec\.ts$/);
26
+ // And load the modules.
27
+ context.keys().map(context);
@@ -0,0 +1,23 @@
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "extends": "../../tsconfig.json",
4
+ "compilerOptions": {
5
+ "outDir": "../../out-tsc/lib",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "inlineSources": true,
9
+ "types": []
10
+ },
11
+ "angularCompilerOptions": {
12
+ "skipTemplateCodegen": true,
13
+ "strictMetadataEmit": true,
14
+ "enableResourceInlining": true,
15
+ "strictTemplates": false,
16
+ "fullTemplateTypeCheck": false,
17
+ "enableIvy": true
18
+ },
19
+ "exclude": [
20
+ "src/test.ts",
21
+ "**/*.spec.ts"
22
+ ]
23
+ }
@@ -0,0 +1,10 @@
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "extends": "./tsconfig.lib.json",
4
+ "compilerOptions": {
5
+ "declarationMap": false
6
+ },
7
+ "angularCompilerOptions": {
8
+ "compilationMode": "partial"
9
+ }
10
+ }
@@ -0,0 +1,17 @@
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "extends": "../../tsconfig.json",
4
+ "compilerOptions": {
5
+ "outDir": "../../out-tsc/spec",
6
+ "types": [
7
+ "jasmine"
8
+ ]
9
+ },
10
+ "files": [
11
+ "src/test.ts"
12
+ ],
13
+ "include": [
14
+ "**/*.spec.ts",
15
+ "**/*.d.ts"
16
+ ]
17
+ }
@@ -1,5 +0,0 @@
1
- /**
2
- * Generated bundle index. Do not edit.
3
- */
4
- export * from './public-api';
5
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhwZXJ0ZWFtLW14LW5neC10YWJsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3Byb2plY3RzL25neC10YWJsZS9zcmMvZXhwZXJ0ZWFtLW14LW5neC10YWJsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsY0FBYyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL3B1YmxpYy1hcGknO1xuIl19