@js-smart/ng-kit 20.6.2-beta.1 → 20.6.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.
- package/fesm2022/js-smart-ng-kit.mjs +2443 -0
- package/fesm2022/js-smart-ng-kit.mjs.map +1 -0
- package/index.d.ts +1100 -0
- package/package.json +13 -2
- package/eslint.config.js +0 -18
- package/karma.conf.js +0 -35
- package/ng-package.json +0 -11
- package/src/assets/app-buttons.css +0 -33
- package/src/assets/app-mat-snack-bar.css +0 -89
- package/src/assets/app-variables.css +0 -10
- package/src/assets/general.scss +0 -77
- package/src/assets/styles.scss +0 -5
- package/src/lib/components/alert/alert.component.html +0 -12
- package/src/lib/components/alert/alert.component.scss +0 -5
- package/src/lib/components/alert/alert.component.ts +0 -105
- package/src/lib/components/autocomplete/autocomplete.component.html +0 -42
- package/src/lib/components/autocomplete/autocomplete.component.ts +0 -207
- package/src/lib/components/buttons/base-button/base-button.component.html +0 -0
- package/src/lib/components/buttons/base-button/base-button.component.ts +0 -86
- package/src/lib/components/buttons/base-button/base-button.directive.ts +0 -87
- package/src/lib/components/buttons/bs-link-button/bs-link-button.component.ts +0 -37
- package/src/lib/components/buttons/bs-link-button/bs-link-button.directive.ts +0 -28
- package/src/lib/components/buttons/close-button/close-button.directive.ts +0 -12
- package/src/lib/components/buttons/delete-button/delete-button.component.ts +0 -42
- package/src/lib/components/buttons/delete-button/delete-button.directive.ts +0 -15
- package/src/lib/components/buttons/edit-bs-button/edit-bs-button.component.ts +0 -39
- package/src/lib/components/buttons/edit-bs-button/edit-bs-button.directive.ts +0 -37
- package/src/lib/components/buttons/edit-button/edit-button.component.ts +0 -37
- package/src/lib/components/buttons/edit-button/edit-button.directive.ts +0 -15
- package/src/lib/components/buttons/edit-svg-icon-button/edit-svg-icon-button.component.ts +0 -37
- package/src/lib/components/buttons/edit-svg-icon-button/edit-svg-icon-button.directive.ts +0 -39
- package/src/lib/components/buttons/excel-export-button/excel-export-button.component.ts +0 -23
- package/src/lib/components/buttons/excel-export-button/excel-export-button.directive.ts +0 -23
- package/src/lib/components/buttons/manage-button/manage-button.component.ts +0 -35
- package/src/lib/components/buttons/manage-button/manage-button.directive.ts +0 -15
- package/src/lib/components/buttons/pdf-export-button/pdf-export-button.component.ts +0 -20
- package/src/lib/components/buttons/pdf-export-button/pdf-export-button.directive.ts +0 -22
- package/src/lib/components/buttons/primary-button/primary-button.component.ts +0 -43
- package/src/lib/components/buttons/primary-button/primary-button.directive.ts +0 -16
- package/src/lib/components/buttons/save-primary-button/save-primary-button.component.ts +0 -43
- package/src/lib/components/buttons/save-primary-button/save-primary-button.directive.ts +0 -16
- package/src/lib/components/buttons/search-button/search-button.component.ts +0 -41
- package/src/lib/components/buttons/success-button/success-button.component.ts +0 -41
- package/src/lib/components/buttons/success-button/success-button.directive.ts +0 -15
- package/src/lib/components/buttons/view-button/view-button.component.ts +0 -32
- package/src/lib/components/buttons/view-button/view-button.directive.ts +0 -14
- package/src/lib/components/buttons/view-primary-button/view-primary-button.component.ts +0 -37
- package/src/lib/components/buttons/view-primary-button/view-primary-button.directive.ts +0 -15
- package/src/lib/components/confirm-dialog/confirm-dialog.component.ts +0 -56
- package/src/lib/components/ngx-spinner/ngx-spinner.component.css +0 -169
- package/src/lib/components/ngx-spinner/ngx-spinner.component.html +0 -24
- package/src/lib/components/ngx-spinner/ngx-spinner.component.spec.ts +0 -186
- package/src/lib/components/ngx-spinner/ngx-spinner.component.ts +0 -199
- package/src/lib/components/ngx-spinner/ngx-spinner.enum.ts +0 -45
- package/src/lib/components/ngx-spinner/ngx-spinner.service.ts +0 -66
- package/src/lib/components/ngx-spinner/safe-html.pipe.ts +0 -17
- package/src/lib/components/snack-bar/error-snack-bar/error-snack-bar.component.ts +0 -36
- package/src/lib/components/snack-bar/success-snack-bar/success-snack-bar.component.ts +0 -35
- package/src/lib/components/spinner/spinner.component.html +0 -11
- package/src/lib/components/spinner/spinner.component.scss +0 -18
- package/src/lib/components/spinner/spinner.component.ts +0 -31
- package/src/lib/directives/ngx-print/ngx-print.directive.ts +0 -281
- package/src/lib/directives/ngx-print/print-options.ts +0 -16
- package/src/lib/directives/prevent-multiple-clicks/prevent-multiple-clicks.directive.spec.ts +0 -99
- package/src/lib/directives/prevent-multiple-clicks/prevent-multiple-clicks.directive.ts +0 -36
- package/src/lib/services/mat-snack-bar.service.ts +0 -102
- package/src/lib/store/entity-store.spec.ts +0 -128
- package/src/lib/store/entity-store.ts +0 -88
- package/src/lib/store/store.spec.ts +0 -47
- package/src/lib/store/store.ts +0 -44
- package/src/lib/svg-icons/edit-solid-svg/edit-solid-svg.component.ts +0 -20
- package/src/lib/types/id-type.ts +0 -3
- package/src/lib/types/progress-state.ts +0 -7
- package/src/lib/util/progress-util.ts +0 -84
- package/src/public-api.ts +0 -64
- package/test.ts +0 -11
- package/tsconfig.lib.json +0 -12
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@js-smart/ng-kit",
|
|
3
|
-
"version": "20.6.2
|
|
3
|
+
"version": "20.6.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Pavan Kumar Jadda",
|
|
6
6
|
"private": false,
|
|
@@ -32,5 +32,16 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"tslib": "^2.8.1"
|
|
34
34
|
},
|
|
35
|
-
"sideEffects": false
|
|
35
|
+
"sideEffects": false,
|
|
36
|
+
"module": "fesm2022/js-smart-ng-kit.mjs",
|
|
37
|
+
"typings": "index.d.ts",
|
|
38
|
+
"exports": {
|
|
39
|
+
"./package.json": {
|
|
40
|
+
"default": "./package.json"
|
|
41
|
+
},
|
|
42
|
+
".": {
|
|
43
|
+
"types": "./index.d.ts",
|
|
44
|
+
"default": "./fesm2022/js-smart-ng-kit.mjs"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
36
47
|
}
|
package/eslint.config.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
const tseslint = require('typescript-eslint');
|
|
3
|
-
const rootConfig = require('../../eslint.config.js');
|
|
4
|
-
|
|
5
|
-
module.exports = tseslint.config(
|
|
6
|
-
...rootConfig,
|
|
7
|
-
{
|
|
8
|
-
files: ['**/*.ts'],
|
|
9
|
-
rules: {
|
|
10
|
-
'@typescript-eslint/no-explicit-any': 'error',
|
|
11
|
-
'@typescript-eslint/explicit-function-return-type': 'warn',
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
files: ['**/*.html'],
|
|
16
|
-
rules: { '@angular-eslint/template/no-negated-async': 'error' },
|
|
17
|
-
},
|
|
18
|
-
);
|
package/karma.conf.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
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
|
-
},
|
|
23
|
-
jasmineHtmlReporter: {
|
|
24
|
-
suppressAll: true, // removes the duplicated traces
|
|
25
|
-
},
|
|
26
|
-
coverageReporter: {
|
|
27
|
-
dir: require('path').join(__dirname, '../../coverage/ng-kit'),
|
|
28
|
-
subdir: '.',
|
|
29
|
-
reporters: [{ type: 'html' }, { type: 'text-summary' }],
|
|
30
|
-
},
|
|
31
|
-
reporters: ['progress', 'kjhtml'],
|
|
32
|
-
browsers: ['Chrome'],
|
|
33
|
-
restartOnFileChange: true,
|
|
34
|
-
});
|
|
35
|
-
};
|
package/ng-package.json
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
.primary-button,
|
|
2
|
-
.primary-button:hover,
|
|
3
|
-
.primary-button:active,
|
|
4
|
-
.primary-button:visited {
|
|
5
|
-
color: white !important;
|
|
6
|
-
background-color: var(--primary-color) !important;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.secondary-button,
|
|
10
|
-
.secondary-button:hover,
|
|
11
|
-
.secondary-button:active,
|
|
12
|
-
.secondary-button:visited {
|
|
13
|
-
color: white !important;
|
|
14
|
-
background-color: var(--secondary-color) !important;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/* Adds CSS for Success Button class */
|
|
18
|
-
.success-button,
|
|
19
|
-
.success-button:hover,
|
|
20
|
-
.success-button:active,
|
|
21
|
-
.success-button:visited {
|
|
22
|
-
color: white !important;
|
|
23
|
-
background-color: var(--success-color) !important;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/* Adds CSS for Delete Button class */
|
|
27
|
-
.delete-button,
|
|
28
|
-
.delete-button:hover,
|
|
29
|
-
.delete-button:active,
|
|
30
|
-
.success-button:visited {
|
|
31
|
-
color: white !important;
|
|
32
|
-
background-color: var(--delete-color) !important;
|
|
33
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
@import 'app-variables.css';
|
|
2
|
-
|
|
3
|
-
/* Success Snack Bar Styles */
|
|
4
|
-
.success-snackbar {
|
|
5
|
-
--mdc-snackbar-container-color: var(--success-color) !important;
|
|
6
|
-
--mat-mdc-snack-bar-button-color: var(--white-color) !important;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.success-snackbar .mdc-snackbar__surface {
|
|
10
|
-
background-color: var(--success-color) !important;
|
|
11
|
-
color: white !important;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.success-snackbar .mat-mdc-snack-bar-action {
|
|
15
|
-
color: var(--white-color) !important;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/* Error Snack Bar Styles */
|
|
19
|
-
.error-snackbar {
|
|
20
|
-
--mdc-snackbar-container-color: var(--delete-color) !important;
|
|
21
|
-
--mat-mdc-snack-bar-button-color: var(--white-color) !important;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.error-snackbar .mdc-snackbar__surface {
|
|
25
|
-
background-color: var(--delete-color) !important;
|
|
26
|
-
color: white !important;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.error-snackbar .mat-mdc-snack-bar-action {
|
|
30
|
-
color: var(--white-color) !important;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/* Light Success Snack Bar Styles */
|
|
34
|
-
.light-success-snackbar {
|
|
35
|
-
--mdc-snackbar-container-color: #d4edda !important;
|
|
36
|
-
--mat-mdc-snack-bar-button-color: darkgreen !important;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.light-success-snackbar .mdc-snackbar__surface {
|
|
40
|
-
background-color: #d4edda !important;
|
|
41
|
-
color: #155724 !important;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.light-success-snackbar .mat-mdc-snack-bar-action {
|
|
45
|
-
color: darkgreen !important;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/* Light Error Snack Bar Styles */
|
|
49
|
-
.light-error-snackbar {
|
|
50
|
-
--mdc-snackbar-container-color: #f8d7da !important;
|
|
51
|
-
--mat-mdc-snack-bar-button-color: darkred !important;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.light-error-snackbar .mdc-snackbar__surface {
|
|
55
|
-
background-color: #f8d7da !important;
|
|
56
|
-
color: #721c24 !important;
|
|
57
|
-
border: 1px solid #f5c6cb;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/* Additional Color Options */
|
|
61
|
-
.info-snackbar {
|
|
62
|
-
--mdc-snackbar-container-color: #0dcaf0 !important;
|
|
63
|
-
--mat-mdc-snack-bar-button-color: white !important;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.info-snackbar .mdc-snackbar__surface {
|
|
67
|
-
background-color: #0dcaf0 !important;
|
|
68
|
-
color: white !important;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.warning-snackbar {
|
|
72
|
-
--mdc-snackbar-container-color: #ffc107 !important;
|
|
73
|
-
--mat-mdc-snack-bar-button-color: #000 !important;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.warning-snackbar .mdc-snackbar__surface {
|
|
77
|
-
background-color: #ffc107 !important;
|
|
78
|
-
color: #000 !important;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.primary-snackbar {
|
|
82
|
-
--mdc-snackbar-container-color: var(--primary-color) !important;
|
|
83
|
-
--mat-mdc-snack-bar-button-color: white !important;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.primary-snackbar .mdc-snackbar__surface {
|
|
87
|
-
background-color: var(--primary-color) !important;
|
|
88
|
-
color: white !important;
|
|
89
|
-
}
|
package/src/assets/general.scss
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
@import 'app-variables.css';
|
|
2
|
-
|
|
3
|
-
/* Remove underline from hyperlink */
|
|
4
|
-
a {
|
|
5
|
-
text-decoration: none;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/* Show underline in hyperlink only when mouse is hovered */
|
|
9
|
-
a:hover {
|
|
10
|
-
text-decoration: underline;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/* By default make aligns items center for bootstrap row class */
|
|
14
|
-
.row {
|
|
15
|
-
align-items: center;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/* Extends bootstrap row class and aligns items start */
|
|
19
|
-
.row-align-items-start {
|
|
20
|
-
@extend .row;
|
|
21
|
-
align-items: start;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/* End of Bootstrap 5 adjustments */
|
|
25
|
-
|
|
26
|
-
// Sets Mat-Dialog Overflow to auto by default
|
|
27
|
-
.mat-dialog-content,
|
|
28
|
-
.mat-dialog-container {
|
|
29
|
-
overflow: auto;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Places item in the middle of the box
|
|
33
|
-
.app-flex-center {
|
|
34
|
-
display: flex;
|
|
35
|
-
align-items: center;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Places item in the center of the box
|
|
39
|
-
.app-flex-justify-center {
|
|
40
|
-
display: flex;
|
|
41
|
-
justify-content: center;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Places item in the left of the box
|
|
45
|
-
.app-flex-justify-left {
|
|
46
|
-
display: flex;
|
|
47
|
-
justify-content: flex-start;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Places item in the right of the box
|
|
51
|
-
.app-flex-justify-right {
|
|
52
|
-
display: flex;
|
|
53
|
-
justify-content: flex-end;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Places items at the start of the item
|
|
57
|
-
.app-flex-align-items-start {
|
|
58
|
-
display: flex;
|
|
59
|
-
align-items: flex-start;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Places items at the start of the item
|
|
63
|
-
.app-flex-align-items-center {
|
|
64
|
-
display: flex;
|
|
65
|
-
align-items: center;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Add padding to strong HTML tag
|
|
69
|
-
strong {
|
|
70
|
-
padding-left: 5px;
|
|
71
|
-
padding-right: 5px;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
//Primary color text
|
|
75
|
-
.primary-color-text {
|
|
76
|
-
color: var(--primary-color);
|
|
77
|
-
}
|
package/src/assets/styles.scss
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
@if (open()) {
|
|
2
|
-
<div class="row {{ class() }}">
|
|
3
|
-
<div class="col-xs-12 col-sm-12 col-md-auto mx-auto">
|
|
4
|
-
<div class="alert alert-{{ type() }} alert-dismissible alert_div" role="alert">
|
|
5
|
-
<ng-content></ng-content>
|
|
6
|
-
@if (dismissible()) {
|
|
7
|
-
<button (click)="closeAlert()" aria-label="Close" class="btn-close" data-bs-dismiss="alert" type="button"></button>
|
|
8
|
-
}
|
|
9
|
-
</div>
|
|
10
|
-
</div>
|
|
11
|
-
</div>
|
|
12
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectorRef, Component, effect, inject, input, type OnInit, output, signal } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
export type AlertType = 'info' | 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'dark' | 'light';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Boostrap Alert component that can be used to alert messages to the user
|
|
7
|
-
*
|
|
8
|
-
* @author Pavan Kumar Jadda
|
|
9
|
-
* @since 12.0.0
|
|
10
|
-
*/
|
|
11
|
-
@Component({
|
|
12
|
-
selector: 'lib-alert, alert',
|
|
13
|
-
templateUrl: './alert.component.html',
|
|
14
|
-
styleUrls: ['./alert.component.scss'],
|
|
15
|
-
})
|
|
16
|
-
export class AlertComponent implements OnInit {
|
|
17
|
-
cdr = inject(ChangeDetectorRef);
|
|
18
|
-
/**
|
|
19
|
-
* Type of the BootStrap Alert. Following values are supported. See BootStrap docs for more information
|
|
20
|
-
*/
|
|
21
|
-
type = input<AlertType>('info');
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Is alert visible or open
|
|
25
|
-
*/
|
|
26
|
-
isOpen = input(true);
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Writable signal for isOpen
|
|
30
|
-
*/
|
|
31
|
-
open = signal(this.isOpen());
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* If set, displays an inline “Close” button
|
|
35
|
-
*/
|
|
36
|
-
dismissible = input(true);
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* If set, dismisses the alert after Dismiss Timeout
|
|
40
|
-
*/
|
|
41
|
-
dismissOnTimeout = input(true);
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Number in milliseconds, after which alert will be closed. Default value is 5000 ms
|
|
45
|
-
*/
|
|
46
|
-
dismissTimeout = input(5000);
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Additional classes to be added to the alert. This can be used to add custom styles to the alert
|
|
50
|
-
*/
|
|
51
|
-
class = input('');
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Emits when the alert is closed.
|
|
55
|
-
*/
|
|
56
|
-
closed = output<void>();
|
|
57
|
-
|
|
58
|
-
constructor() {
|
|
59
|
-
// React to isOpen input changes
|
|
60
|
-
effect(() => {
|
|
61
|
-
this.open.set(this.isOpen());
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Initialize the component and settings
|
|
67
|
-
*
|
|
68
|
-
* @author Pavan Kumar Jadda
|
|
69
|
-
* @since 12.0.0
|
|
70
|
-
*/
|
|
71
|
-
ngOnInit(): void {
|
|
72
|
-
this.openAlert();
|
|
73
|
-
|
|
74
|
-
if (this.dismissOnTimeout()) {
|
|
75
|
-
setTimeout(() => {
|
|
76
|
-
this.closeAlert();
|
|
77
|
-
this.cdr.markForCheck();
|
|
78
|
-
}, this.dismissTimeout());
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Closes BootStrap Alert if not open
|
|
84
|
-
*
|
|
85
|
-
* @author Pavan Kumar Jadda
|
|
86
|
-
* @since 12.0.0
|
|
87
|
-
*/
|
|
88
|
-
closeAlert(): void {
|
|
89
|
-
if (!this.isOpen()) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
this.open.set(false);
|
|
93
|
-
this.closed.emit();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Opens Bootstrap Alert
|
|
98
|
-
*
|
|
99
|
-
* @author Pavan Kumar Jadda
|
|
100
|
-
* @since 12.0.0
|
|
101
|
-
*/
|
|
102
|
-
private openAlert(): void {
|
|
103
|
-
this.open.set(true);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
<div>
|
|
2
|
-
<mat-form-field appearance="fill" class="{{ classes() }}">
|
|
3
|
-
<mat-label>{{ label() }}</mat-label>
|
|
4
|
-
<input
|
|
5
|
-
#inputAutoComplete
|
|
6
|
-
#trigger="matAutocompleteTrigger"
|
|
7
|
-
[formControl]="control"
|
|
8
|
-
[matAutocomplete]="auto"
|
|
9
|
-
[placeholder]="placeHolder()"
|
|
10
|
-
[required]="required()"
|
|
11
|
-
matInput
|
|
12
|
-
type="text" />
|
|
13
|
-
|
|
14
|
-
<div matSuffix style="display: flex">
|
|
15
|
-
@if (control.value) {
|
|
16
|
-
<button (click)="clearInput($event)" aria-label="Clear" mat-icon-button type="button">
|
|
17
|
-
<mat-icon>clear</mat-icon>
|
|
18
|
-
</button>
|
|
19
|
-
}
|
|
20
|
-
<button (click)="openOrClosePanel($event, trigger)" aria-label="Clear" mat-icon-button type="button">
|
|
21
|
-
<mat-icon>{{ arrowIconSubject.getValue() }}</mat-icon>
|
|
22
|
-
</button>
|
|
23
|
-
</div>
|
|
24
|
-
|
|
25
|
-
<mat-autocomplete
|
|
26
|
-
#auto="matAutocomplete"
|
|
27
|
-
(closed)="arrowIconSubject.next('arrow_drop_down')"
|
|
28
|
-
(opened)="arrowIconSubject.next('arrow_drop_up')"
|
|
29
|
-
(optionSelected)="arrowIconSubject.next('arrow_drop_down')"
|
|
30
|
-
[displayWith]="displayFn">
|
|
31
|
-
@for (option of filteredOptions | async; track option[bindValue()]) {
|
|
32
|
-
<mat-option (onSelectionChange)="emitSelectedValue($event)" [value]="option">
|
|
33
|
-
@if (typeof option === 'string') {
|
|
34
|
-
<ng-container>{{ option }}</ng-container>
|
|
35
|
-
} @else if (typeof option === 'object') {
|
|
36
|
-
<ng-container>{{ option[bindLabel()] }}</ng-container>
|
|
37
|
-
}
|
|
38
|
-
</mat-option>
|
|
39
|
-
}
|
|
40
|
-
</mat-autocomplete>
|
|
41
|
-
</mat-form-field>
|
|
42
|
-
</div>
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import { AsyncPipe } from '@angular/common';
|
|
2
|
-
import {
|
|
3
|
-
AfterContentChecked,
|
|
4
|
-
ChangeDetectorRef,
|
|
5
|
-
Component,
|
|
6
|
-
ElementRef,
|
|
7
|
-
forwardRef,
|
|
8
|
-
inject,
|
|
9
|
-
Input,
|
|
10
|
-
input,
|
|
11
|
-
OnChanges,
|
|
12
|
-
OnInit,
|
|
13
|
-
Optional,
|
|
14
|
-
output,
|
|
15
|
-
SimpleChanges,
|
|
16
|
-
ViewChild,
|
|
17
|
-
} from '@angular/core';
|
|
18
|
-
import { ControlValueAccessor, FormControl, NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';
|
|
19
|
-
import { MatAutocompleteModule, MatAutocompleteTrigger } from '@angular/material/autocomplete';
|
|
20
|
-
import { MatButtonModule } from '@angular/material/button';
|
|
21
|
-
import { MatOptionSelectionChange } from '@angular/material/core';
|
|
22
|
-
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
23
|
-
import { MatIconModule } from '@angular/material/icon';
|
|
24
|
-
import { MatInputModule } from '@angular/material/input';
|
|
25
|
-
import { BehaviorSubject, Observable } from 'rxjs';
|
|
26
|
-
import { map, startWith } from 'rxjs/operators';
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Reusable Auto Complete component that extends MatAutoComplete to show Clear icon and Arrow buttons
|
|
30
|
-
*
|
|
31
|
-
* @author Pavan Kumar Jadda
|
|
32
|
-
* @since 12.0.0
|
|
33
|
-
*/
|
|
34
|
-
@Component({
|
|
35
|
-
selector: 'autocomplete, lib-autocomplete',
|
|
36
|
-
imports: [ReactiveFormsModule, MatFormFieldModule, MatAutocompleteModule, MatInputModule, MatButtonModule, MatIconModule, AsyncPipe],
|
|
37
|
-
templateUrl: './autocomplete.component.html',
|
|
38
|
-
providers: [
|
|
39
|
-
{
|
|
40
|
-
provide: NG_VALUE_ACCESSOR,
|
|
41
|
-
useExisting: forwardRef(() => AutocompleteComponent),
|
|
42
|
-
multi: true,
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
})
|
|
46
|
-
export class AutocompleteComponent implements OnInit, OnChanges, AfterContentChecked, ControlValueAccessor {
|
|
47
|
-
/**
|
|
48
|
-
* Gets reference inputAutoComplete HTML attribute
|
|
49
|
-
*/
|
|
50
|
-
@ViewChild('inputAutoComplete') inputAutoComplete!: ElementRef;
|
|
51
|
-
|
|
52
|
-
cdRef = inject(ChangeDetectorRef);
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Internal form control for the autocomplete
|
|
56
|
-
*/
|
|
57
|
-
control = new FormControl('');
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Label of the AutoComplete
|
|
61
|
-
*/
|
|
62
|
-
label = input('');
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Placeholder of the AutoComplete
|
|
66
|
-
*/
|
|
67
|
-
placeHolder = input('');
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Appearance of the AutoComplete, defaults to `fill`
|
|
71
|
-
*/
|
|
72
|
-
appearance = input('fill');
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* List of CSS classes that need to applied to autocomplete
|
|
76
|
-
*/
|
|
77
|
-
classes = input('');
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Attribute of the Object whose value would be shown when searching for data. Defaults to `ID`
|
|
81
|
-
*/
|
|
82
|
-
bindLabel = input('');
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Attribute of the Object whose value would be used for search
|
|
86
|
-
*/
|
|
87
|
-
bindValue = input('id');
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Function that maps an option's control value to its display value in the trigger.
|
|
91
|
-
*/
|
|
92
|
-
@Input() @Optional() displayWith: ((value: any) => string) | null = null;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Specifies if the autocomplete is required. Default is not required.
|
|
96
|
-
*/
|
|
97
|
-
required = input(false);
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Specifies if the autocomplete is disabled. Default is not required.
|
|
101
|
-
*/
|
|
102
|
-
disabled = input(false);
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* List of Objects that need to be bind and searched for
|
|
106
|
-
*/
|
|
107
|
-
data = input<string[] | any[]>();
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Emit selected value on selection changes
|
|
111
|
-
*/
|
|
112
|
-
onSelectionChange = output<any>();
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* BehaviorSubject that shows the current active arrow icon
|
|
116
|
-
*/
|
|
117
|
-
arrowIconSubject = new BehaviorSubject('arrow_drop_down');
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Filtered options when user types
|
|
121
|
-
*/
|
|
122
|
-
filteredOptions: Observable<any[] | undefined> | undefined;
|
|
123
|
-
|
|
124
|
-
writeValue(value: any): void {
|
|
125
|
-
this.control.setValue(value, { emitEvent: false });
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
registerOnChange(fn: any): void {
|
|
129
|
-
this.onChange = fn;
|
|
130
|
-
// Forward value changes from internal control to parent form
|
|
131
|
-
this.control.valueChanges.subscribe((value) => fn(value));
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
registerOnTouched(fn: any): void {
|
|
135
|
-
this.onTouched = fn;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
setDisabledState(isDisabled: boolean): void {
|
|
139
|
-
if (isDisabled) {
|
|
140
|
-
this.control.disable();
|
|
141
|
-
} else {
|
|
142
|
-
this.control.enable();
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
ngAfterContentChecked(): void {
|
|
147
|
-
this.cdRef.detectChanges();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
ngOnInit() {
|
|
151
|
-
this.filteredOptions = this.control.valueChanges.pipe(
|
|
152
|
-
startWith(''),
|
|
153
|
-
map((value) => (typeof value === 'string' ? value : value !== null ? value[this.bindLabel()] : '')),
|
|
154
|
-
map(
|
|
155
|
-
(propertyName) =>
|
|
156
|
-
this.data()?.filter((option) => {
|
|
157
|
-
return typeof option === 'string'
|
|
158
|
-
? option?.toLowerCase().startsWith(propertyName.toLowerCase())
|
|
159
|
-
: option[this.bindLabel()]?.toLowerCase().indexOf(propertyName.toLowerCase()) === 0;
|
|
160
|
-
}) ?? this.data()?.slice(),
|
|
161
|
-
),
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
ngOnChanges(_changes: SimpleChanges): void {
|
|
166
|
-
this.displayFn = this.displayFn.bind(this);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
clearInput(evt: any): void {
|
|
170
|
-
evt.stopPropagation();
|
|
171
|
-
this.control.reset();
|
|
172
|
-
this.onChange(null);
|
|
173
|
-
this.inputAutoComplete?.nativeElement.focus();
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
openOrClosePanel(evt: any, trigger: MatAutocompleteTrigger): void {
|
|
177
|
-
evt.stopPropagation();
|
|
178
|
-
if (trigger.panelOpen) {
|
|
179
|
-
trigger.closePanel();
|
|
180
|
-
} else {
|
|
181
|
-
trigger.openPanel();
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
displayFn(object: any): string {
|
|
186
|
-
if (this.displayWith !== undefined && this.displayWith !== null && typeof this.displayWith === 'function') {
|
|
187
|
-
this.displayFn = this.displayWith.bind(this);
|
|
188
|
-
return this.displayWith(object);
|
|
189
|
-
} else {
|
|
190
|
-
if (typeof object === 'string') {
|
|
191
|
-
return object;
|
|
192
|
-
}
|
|
193
|
-
return object?.[this.bindLabel()] ? object[this.bindLabel()] : '';
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
emitSelectedValue($event: MatOptionSelectionChange) {
|
|
198
|
-
this.onSelectionChange.emit($event.source.value);
|
|
199
|
-
this.onChange($event.source.value);
|
|
200
|
-
this.onTouched();
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// ControlValueAccessor implementation
|
|
204
|
-
private onChange: (value: any) => void = () => {};
|
|
205
|
-
|
|
206
|
-
private onTouched: () => void = () => {};
|
|
207
|
-
}
|
|
File without changes
|