@verisoft/ui-core 20.1.0 → 20.1.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.
Files changed (137) hide show
  1. package/fesm2022/verisoft-ui-core.mjs +2026 -0
  2. package/fesm2022/verisoft-ui-core.mjs.map +1 -0
  3. package/index.d.ts +1126 -0
  4. package/package.json +18 -6
  5. package/.eslintrc.json +0 -48
  6. package/jest.config.ts +0 -21
  7. package/ng-package.json +0 -11
  8. package/project.json +0 -36
  9. package/src/index.ts +0 -6
  10. package/src/lib/common/angular-helper.ts +0 -44
  11. package/src/lib/common/constants.ts +0 -5
  12. package/src/lib/common/control.models.ts +0 -80
  13. package/src/lib/common/datasource-component.model.spec.ts +0 -42
  14. package/src/lib/common/datasource-component.model.ts +0 -43
  15. package/src/lib/common/deactivate-guard.model.ts +0 -5
  16. package/src/lib/common/download-file.ts +0 -20
  17. package/src/lib/common/filter.ts +0 -7
  18. package/src/lib/common/icons.ts +0 -34
  19. package/src/lib/common/index.ts +0 -10
  20. package/src/lib/common/notificable-property.model.ts +0 -5
  21. package/src/lib/common/rxjs.spec.ts +0 -58
  22. package/src/lib/common/rxjs.ts +0 -21
  23. package/src/lib/components/action-button-group/action-button-group.model.ts +0 -15
  24. package/src/lib/components/action-button-group/action-button.model.ts +0 -15
  25. package/src/lib/components/action-button-group/index.ts +0 -2
  26. package/src/lib/components/base-form/base-form-input.component.ts +0 -120
  27. package/src/lib/components/base-form/base-form.component.ts +0 -236
  28. package/src/lib/components/base-form/directives/detail-store.directive.ts +0 -219
  29. package/src/lib/components/base-form/index.ts +0 -4
  30. package/src/lib/components/base-form/models/base-form-input.models.ts +0 -11
  31. package/src/lib/components/base-form/models/base-form.models.ts +0 -31
  32. package/src/lib/components/base-form/models/index.ts +0 -2
  33. package/src/lib/components/breadcrumb/breadcrumb.model.ts +0 -21
  34. package/src/lib/components/breadcrumb/breadcrumb.service.ts +0 -9
  35. package/src/lib/components/breadcrumb/breadcrumbcore.component.ts +0 -117
  36. package/src/lib/components/breadcrumb/index.ts +0 -3
  37. package/src/lib/components/button/button.model.ts +0 -21
  38. package/src/lib/components/button/index.ts +0 -1
  39. package/src/lib/components/calendar/calendar.model.ts +0 -16
  40. package/src/lib/components/calendar/index.ts +0 -1
  41. package/src/lib/components/checkbox/checkbox.model.ts +0 -10
  42. package/src/lib/components/checkbox/index.ts +0 -1
  43. package/src/lib/components/confirm-dialog/confirm-dialog.model.ts +0 -31
  44. package/src/lib/components/confirm-dialog/index.ts +0 -1
  45. package/src/lib/components/dropdown/dropdown.model.ts +0 -16
  46. package/src/lib/components/dropdown/index.ts +0 -1
  47. package/src/lib/components/dropdown-button/dropdown-button.model.ts +0 -18
  48. package/src/lib/components/dropdown-button/index.ts +0 -1
  49. package/src/lib/components/dynamic-component/dynamic-component.model.ts +0 -2
  50. package/src/lib/components/dynamic-component/index.ts +0 -1
  51. package/src/lib/components/filter/filter.model.ts +0 -17
  52. package/src/lib/components/filter/index.ts +0 -1
  53. package/src/lib/components/form-field/form-field.model.ts +0 -15
  54. package/src/lib/components/form-field/index.ts +0 -1
  55. package/src/lib/components/generic-field/generic-field.model.ts +0 -10
  56. package/src/lib/components/generic-field/index.ts +0 -1
  57. package/src/lib/components/generic-form/generic-form.component.ts +0 -33
  58. package/src/lib/components/generic-form/index.ts +0 -1
  59. package/src/lib/components/header/header.model.ts +0 -18
  60. package/src/lib/components/header/index.ts +0 -1
  61. package/src/lib/components/icons/icons.component.ts +0 -22
  62. package/src/lib/components/icons/icons.model.ts +0 -16
  63. package/src/lib/components/icons/index.ts +0 -2
  64. package/src/lib/components/index.ts +0 -37
  65. package/src/lib/components/input-group/index.ts +0 -1
  66. package/src/lib/components/input-group/input-group.model.ts +0 -17
  67. package/src/lib/components/loader/index.ts +0 -1
  68. package/src/lib/components/loader/loader.model.ts +0 -7
  69. package/src/lib/components/multiselect/index.ts +0 -1
  70. package/src/lib/components/multiselect/mutiselect.model.ts +0 -13
  71. package/src/lib/components/number-input/index.ts +0 -1
  72. package/src/lib/components/number-input/number-input.model.ts +0 -14
  73. package/src/lib/components/page-header/index.ts +0 -3
  74. package/src/lib/components/page-header/page-header.model.ts +0 -11
  75. package/src/lib/components/page-header/page-header.service.ts +0 -9
  76. package/src/lib/components/page-header/page-headercore.component.ts +0 -42
  77. package/src/lib/components/password/index.ts +0 -1
  78. package/src/lib/components/password/password.model.ts +0 -25
  79. package/src/lib/components/radiobutton/index.ts +0 -1
  80. package/src/lib/components/radiobutton/radiobutton.model.ts +0 -16
  81. package/src/lib/components/section/index.ts +0 -1
  82. package/src/lib/components/section/section.model.ts +0 -11
  83. package/src/lib/components/side-menu/directives/side-menu-service.directive.ts +0 -31
  84. package/src/lib/components/side-menu/index.ts +0 -4
  85. package/src/lib/components/side-menu/services/side-menu-provider.service.ts +0 -13
  86. package/src/lib/components/side-menu/services/side-menu.service.ts +0 -62
  87. package/src/lib/components/side-menu/side-menu.model.ts +0 -67
  88. package/src/lib/components/slider/index.ts +0 -1
  89. package/src/lib/components/slider/slider.model.ts +0 -13
  90. package/src/lib/components/snackbar/index.ts +0 -1
  91. package/src/lib/components/snackbar/snackbar.model.ts +0 -7
  92. package/src/lib/components/stepper/index.ts +0 -1
  93. package/src/lib/components/stepper/stepper.model.ts +0 -24
  94. package/src/lib/components/switch/index.ts +0 -1
  95. package/src/lib/components/switch/switch.model.ts +0 -8
  96. package/src/lib/components/tab-view/index.ts +0 -1
  97. package/src/lib/components/tab-view/tab-view.model.ts +0 -22
  98. package/src/lib/components/table/column-configuration.ts +0 -38
  99. package/src/lib/components/table/index.ts +0 -4
  100. package/src/lib/components/table/table-builder.ts +0 -93
  101. package/src/lib/components/table/table-column.directive.ts +0 -62
  102. package/src/lib/components/table/table.models.ts +0 -261
  103. package/src/lib/components/table-filter/index.ts +0 -1
  104. package/src/lib/components/table-filter/table-filter.model.ts +0 -22
  105. package/src/lib/components/tag/index.ts +0 -1
  106. package/src/lib/components/tag/tag.model.ts +0 -13
  107. package/src/lib/components/textarea/index.ts +0 -1
  108. package/src/lib/components/textarea/textarea.model.ts +0 -13
  109. package/src/lib/components/textfield/index.ts +0 -1
  110. package/src/lib/components/textfield/textfield.model.ts +0 -13
  111. package/src/lib/components/tooltip/index.ts +0 -1
  112. package/src/lib/components/tooltip/tooltip.model.ts +0 -13
  113. package/src/lib/components/unsubscribe.component.ts +0 -12
  114. package/src/lib/directives/datasource.directive.ts +0 -275
  115. package/src/lib/directives/index.ts +0 -4
  116. package/src/lib/directives/shortcut.directive.ts +0 -37
  117. package/src/lib/directives/table-datasource.directive.ts +0 -184
  118. package/src/lib/directives/table-filter.directive.ts +0 -69
  119. package/src/lib/format/format.ts +0 -74
  120. package/src/lib/pipes/error/error.codes.ts +0 -11
  121. package/src/lib/pipes/error/error.models.ts +0 -27
  122. package/src/lib/pipes/error/error.pipe.ts +0 -27
  123. package/src/lib/pipes/error/warning.codes.ts +0 -5
  124. package/src/lib/pipes/error/warning.pipe.ts +0 -27
  125. package/src/lib/pipes/helper/enumToList.pipe.ts +0 -16
  126. package/src/lib/pipes/index.ts +0 -7
  127. package/src/lib/pipes/keyOrFn/keyOrFn.pipe.ts +0 -23
  128. package/src/lib/services/confirm-dialog.service.ts +0 -44
  129. package/src/lib/services/index.ts +0 -4
  130. package/src/lib/services/leave-form.service.ts +0 -53
  131. package/src/lib/services/screen-size.service.ts +0 -25
  132. package/src/lib/services/table.service.ts +0 -22
  133. package/src/test-setup.ts +0 -8
  134. package/tsconfig.json +0 -28
  135. package/tsconfig.lib.json +0 -17
  136. package/tsconfig.lib.prod.json +0 -9
  137. package/tsconfig.spec.json +0 -16
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@verisoft/ui-core",
3
- "version": "20.1.0",
3
+ "version": "20.1.2",
4
4
  "peerDependencies": {
5
- "@verisoft/core": "~20.1.0",
6
- "@verisoft/store": "~20.1.0",
5
+ "@verisoft/core": "~20.1.2",
6
+ "@verisoft/store": "~20.1.2",
7
7
  "@angular/core": "~20.2.0",
8
8
  "@angular/common": "~20.2.0",
9
9
  "@angular/forms": "~20.2.0",
@@ -15,7 +15,19 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "lodash-es": "^4.17.21",
18
- "uuid": "^11.0.0"
18
+ "uuid": "^11.0.0",
19
+ "tslib": "^2.3.0"
19
20
  },
20
- "sideEffects": false
21
- }
21
+ "sideEffects": false,
22
+ "module": "fesm2022/verisoft-ui-core.mjs",
23
+ "typings": "index.d.ts",
24
+ "exports": {
25
+ "./package.json": {
26
+ "default": "./package.json"
27
+ },
28
+ ".": {
29
+ "types": "./index.d.ts",
30
+ "default": "./fesm2022/verisoft-ui-core.mjs"
31
+ }
32
+ }
33
+ }
package/.eslintrc.json DELETED
@@ -1,48 +0,0 @@
1
- {
2
- "extends": ["../../../.eslintrc.base.json"],
3
- "ignorePatterns": ["!**/*"],
4
- "overrides": [
5
- {
6
- "files": ["*.ts"],
7
- "extends": [
8
- "plugin:@nx/angular",
9
- "plugin:@angular-eslint/template/process-inline-templates"
10
- ],
11
- "rules": {
12
- "@angular-eslint/directive-selector": [
13
- "error",
14
- {
15
- "type": "attribute",
16
- "prefix": "v",
17
- "style": "camelCase"
18
- }
19
- ],
20
- "@angular-eslint/component-selector": [
21
- "error",
22
- {
23
- "type": "element",
24
- "prefix": "v",
25
- "style": "kebab-case"
26
- }
27
- ]
28
- }
29
- },
30
- {
31
- "files": ["*.html"],
32
- "extends": ["plugin:@nx/angular-template"],
33
- "rules": {}
34
- },
35
- {
36
- "files": ["*.json"],
37
- "parser": "jsonc-eslint-parser",
38
- "rules": {
39
- "@nx/dependency-checks": [
40
- "error",
41
- {
42
- "ignoredFiles": ["{projectRoot}/eslint.config.{js,cjs,mjs}"]
43
- }
44
- ]
45
- }
46
- }
47
- ]
48
- }
package/jest.config.ts DELETED
@@ -1,21 +0,0 @@
1
- export default {
2
- displayName: 'ui-core',
3
- preset: '../../../jest.preset.js',
4
- setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
5
- coverageDirectory: '../../../coverage/src/libs/ui-core',
6
- transform: {
7
- '^.+\\.(ts|mjs|js|html)$': [
8
- 'jest-preset-angular',
9
- {
10
- tsconfig: '<rootDir>/tsconfig.spec.json',
11
- stringifyContentPathRegex: '\\.(html|svg)$',
12
- },
13
- ],
14
- },
15
- transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
16
- snapshotSerializers: [
17
- 'jest-preset-angular/build/serializers/no-ng-attributes',
18
- 'jest-preset-angular/build/serializers/ng-snapshot',
19
- 'jest-preset-angular/build/serializers/html-comment',
20
- ],
21
- };
package/ng-package.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
3
- "dest": "../../../dist/src/libs/ui-core",
4
- "lib": {
5
- "entryFile": "src/index.ts"
6
- },
7
- "allowedNonPeerDependencies": [
8
- "lodash-es",
9
- "uuid"
10
- ]
11
- }
package/project.json DELETED
@@ -1,36 +0,0 @@
1
- {
2
- "name": "ui-core",
3
- "$schema": "../../../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "src/libs/ui-core/src",
5
- "prefix": "lib",
6
- "projectType": "library",
7
- "tags": [],
8
- "targets": {
9
- "build": {
10
- "executor": "@nx/angular:package",
11
- "outputs": ["{workspaceRoot}/dist/{projectRoot}"],
12
- "options": {
13
- "project": "src/libs/ui-core/ng-package.json"
14
- },
15
- "configurations": {
16
- "production": {
17
- "tsConfig": "src/libs/ui-core/tsconfig.lib.prod.json"
18
- },
19
- "development": {
20
- "tsConfig": "src/libs/ui-core/tsconfig.lib.json"
21
- }
22
- },
23
- "defaultConfiguration": "production"
24
- },
25
- "test": {
26
- "executor": "@nx/jest:jest",
27
- "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
28
- "options": {
29
- "jestConfig": "src/libs/ui-core/jest.config.ts"
30
- }
31
- },
32
- "lint": {
33
- "executor": "@nx/eslint:lint"
34
- }
35
- }
36
- }
package/src/index.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from './lib/common';
2
- export * from './lib/components';
3
- export * from './lib/directives';
4
- export * from './lib/pipes';
5
- export * from './lib/services';
6
- export * from './lib/format/format';
@@ -1,44 +0,0 @@
1
- import { OnChanges, SimpleChange, SimpleChanges } from '@angular/core';
2
-
3
- export function setComponentProperties<TComponent>(
4
- component: TComponent,
5
- value: Partial<TComponent>,
6
- firstChange = false
7
- ) {
8
- if (!value || !component) {
9
- return;
10
- }
11
-
12
- const simpleChanges = Object.keys(value).reduce(
13
- (changes: SimpleChanges, property: string) => {
14
- const indexedComponent = component as unknown as {
15
- [key: string]: TComponent[keyof TComponent];
16
- };
17
- const indexedValue = value as unknown as {
18
- [key: string]: TComponent[keyof TComponent];
19
- };
20
- const previousValue = indexedComponent[property];
21
- const currentValue = indexedValue[
22
- property
23
- ] as TComponent[keyof TComponent];
24
- if (currentValue !== previousValue) {
25
- indexedComponent[property] = currentValue;
26
- const change = new SimpleChange(
27
- previousValue,
28
- currentValue,
29
- firstChange
30
- );
31
-
32
- return { ...changes, [property]: change };
33
- }
34
-
35
- return changes;
36
- },
37
- {}
38
- );
39
-
40
- const changeableComponent = component as unknown as OnChanges;
41
- if (changeableComponent['ngOnChanges']) {
42
- changeableComponent.ngOnChanges(simpleChanges);
43
- }
44
- }
@@ -1,5 +0,0 @@
1
- export const DEFAULT_DEBOUNCE_TIME = 300;
2
-
3
- export const DEFAULT_PAGINATION = [10, 25, 50, 100];
4
-
5
- export const MAX_COLUMN_CHAR_COUNT = 30;
@@ -1,80 +0,0 @@
1
- export enum ControlSeverity {
2
- success = 'success',
3
- info = 'info',
4
- warning = 'warning',
5
- danger = 'danger',
6
- help = 'help',
7
- primary = 'primary',
8
- secondary = 'secondary',
9
- contrast = 'contrast',
10
- }
11
-
12
- export enum GovControlSeverity {
13
- primary = 'primary',
14
- secondary = 'secondary',
15
- neutral = 'neutral',
16
- error = 'error',
17
- success = 'success',
18
- warning = 'warning',
19
- }
20
-
21
- export enum GovButtonType {
22
- solid = 'solid',
23
- outlined = "outlined",
24
- base = "base",
25
- link = "link"
26
- }
27
-
28
- export enum IconPosition {
29
- left = 'left',
30
- right = 'right',
31
- }
32
-
33
- export enum SlotPosition {
34
- top = 'top',
35
- bottom = 'bottom',
36
- }
37
-
38
- export enum Position{
39
- top = 'top',
40
- bottom = 'bottom',
41
- left = 'left',
42
- right = 'right',
43
- }
44
-
45
- export enum FieldSize {
46
- small = 'small',
47
- medium = 'medium',
48
- large = 'large',
49
- xl = 'xl',
50
- }
51
-
52
- export enum FieldAlign {
53
- left = 'left',
54
- center = 'center',
55
- right = 'right',
56
- }
57
-
58
- export enum FieldType {
59
- text = 'text',
60
- number = 'number',
61
- password = 'password',
62
- search = 'search',
63
- date = 'date',
64
- }
65
-
66
- export enum LayoutType {
67
- horizontal = 'horizontal',
68
- vertical = 'vertical',
69
- }
70
-
71
- export type ControlSeverityType = keyof typeof ControlSeverity;
72
- export type GovControlSeverityType = keyof typeof GovControlSeverity;
73
- export type GovButtonTypeType = keyof typeof GovButtonType;
74
- export type IconPositionType = keyof typeof IconPosition;
75
- export type SlotPositionType = keyof typeof SlotPosition;
76
- export type PositionType = keyof typeof Position;
77
- export type FieldSizeType = keyof typeof FieldSize;
78
- export type FieldAlignType = keyof typeof FieldAlign;
79
- export type FieldTypeType = keyof typeof FieldType;
80
- export type LayoutTypeType = keyof typeof LayoutType;
@@ -1,42 +0,0 @@
1
- import { setDataToArray } from './datasource-component.model';
2
-
3
- describe('setDataToArray', () => {
4
- test('Should return data when target array is null and data is passed.', () => {
5
- const data = ['item 1', 'item 2'];
6
- const targetData = undefined;
7
-
8
- const actual = setDataToArray(targetData, data);
9
-
10
- expect(actual).toEqual(data);
11
- });
12
-
13
- test('Should return data when target array is null and data is passed.', () => {
14
- const data = ['item 1', 'item 2'];
15
- const targetData: string[] = [];
16
-
17
- const actual = setDataToArray(targetData, data);
18
-
19
- expect(actual).toEqual(data);
20
- });
21
-
22
- test('Should return extended target array when target array is empty and data is passed and offset is specified.', () => {
23
- const data = ['item 1', 'item 2'];
24
- const targetData: string[] = [];
25
- const offset = 1;
26
-
27
- const actual = setDataToArray(targetData, data, offset);
28
-
29
- expect(actual).toEqual([undefined, ...data]);
30
- });
31
-
32
- test('Should return target array extended to total items when data is passed and total is specified.', () => {
33
- const data = ['item 1', 'item 2'];
34
- const targetData: string[] = [];
35
- const total = 5;
36
- const offset = 0;
37
-
38
- const actual = setDataToArray(targetData, data, offset, total);
39
-
40
- expect(actual.length).toEqual(total);
41
- });
42
- });
@@ -1,43 +0,0 @@
1
- import { EventEmitter, SimpleChanges } from '@angular/core';
2
- import { FilterEvent, LazyLoadEvent, RequestParams } from '@verisoft/core';
3
-
4
- export interface DataSourceComponentModel<TEntity> {
5
- ngOnChanges?: (changes: SimpleChanges) => void;
6
- lazy: boolean;
7
- loading: boolean;
8
- filter: boolean;
9
- options: TEntity[] | undefined;
10
- optionValue: string | undefined;
11
- optionLabel: string | undefined;
12
- showed: EventEmitter<any>;
13
- cleared: EventEmitter<any>;
14
- filtered: EventEmitter<FilterEvent>;
15
- lazyLoad: EventEmitter<LazyLoadEvent>;
16
- }
17
-
18
- export function setDataToArray<T>(
19
- targetArray: (T | undefined)[] | undefined,
20
- data: T[],
21
- offset = 0,
22
- total: number | undefined = undefined,
23
- defaultItem: T | undefined = undefined
24
- ): (T | undefined)[] {
25
- const totalItems = total ?? data.length + offset;
26
- if (!targetArray) {
27
- targetArray = Array(totalItems).fill(defaultItem);
28
- }
29
-
30
- if (targetArray.length < totalItems) {
31
- targetArray = targetArray.concat(
32
- new Array(totalItems - targetArray.length).fill(defaultItem)
33
- );
34
- }
35
-
36
- for (let i = 0; i < data.length; i++) {
37
- targetArray[i + offset] = data[i] ?? defaultItem;
38
- }
39
-
40
- return targetArray;
41
- }
42
-
43
- export type ExtendedRequestType<T> = RequestParams<T> & { useNewData: boolean}
@@ -1,5 +0,0 @@
1
- import { Observable } from "rxjs";
2
-
3
- export interface PreventUnsavedChangesCore {
4
- canDeactivate: () => Observable<boolean> | Promise<boolean> | boolean;
5
- }
@@ -1,20 +0,0 @@
1
- export function downloadText(
2
- filename: string,
3
- text: string,
4
- mimeType: string | undefined = 'text/plain'
5
- ): void {
6
- const blob = new Blob([text], { type: mimeType });
7
- downloadFile(filename, blob);
8
- }
9
-
10
- export function downloadFile(
11
- filename: string,
12
- blob: Blob
13
- ): void {
14
- const url = window.URL.createObjectURL(blob);
15
- const a = document.createElement('a');
16
- a.href = url;
17
- a.download = filename;
18
- a.click();
19
- window.URL.revokeObjectURL(url);
20
- }
@@ -1,7 +0,0 @@
1
- export function isFilterEmpty<T>(filter: Partial<T> | undefined) {
2
- if (filter == undefined) {
3
- return true;
4
- }
5
-
6
- return !Object.entries(filter).some((x) => x[1] != undefined);
7
- }
@@ -1,34 +0,0 @@
1
- export interface CommonIcons {
2
- add: string;
3
- minus: string;
4
- delete: string;
5
- filter: string;
6
- download: string;
7
- save: string;
8
- print: string;
9
- edit: string;
10
- settings: string;
11
- house: string;
12
- calendar: string;
13
- chevronRight: string;
14
- chevronLeft: string;
15
- chevronDown: string;
16
- chevronUp: string;
17
- checkbox: string;
18
- warning: string;
19
- search: string;
20
- action: string;
21
- user: string;
22
- logout: string;
23
- crossCircle: string;
24
- infoCircle: string;
25
- cross: string;
26
- arrowLeft: string;
27
- arrowRight: string;
28
- questionCircle: string;
29
- checkCircle: string;
30
- sitemap: string;
31
- check: string;
32
- envelope: string;
33
- loader: string;
34
- }
@@ -1,10 +0,0 @@
1
- export * from './angular-helper';
2
- export * from './control.models';
3
- export * from './constants';
4
- export * from './datasource-component.model';
5
- export * from './filter';
6
- export * from './notificable-property.model';
7
- export * from './rxjs';
8
- export * from './icons';
9
- export * from './download-file';
10
- export * from './deactivate-guard.model'
@@ -1,5 +0,0 @@
1
- import { Observable } from "rxjs";
2
-
3
- export interface NotificableProperty {
4
- propertyChanged: Observable<unknown>;
5
- }
@@ -1,58 +0,0 @@
1
- import { QueryList } from '@angular/core';
2
- import { skip, Subject } from 'rxjs';
3
- import { NotificableProperty } from './notificable-property.model';
4
- import { queryListChanged } from './rxjs';
5
-
6
- describe('queryListChanged', () => {
7
- let queryList: QueryList<NotificableProperty>;
8
-
9
- beforeEach(() => {
10
- queryList = new QueryList<NotificableProperty>();
11
- });
12
-
13
- it('should emit initial value', (done) => {
14
- queryListChanged(queryList).subscribe((result) => {
15
- expect(result).toEqual([]);
16
- done();
17
- });
18
- });
19
-
20
- it('should emit when propertyChanged emits', (done) => {
21
- const propertyChanged = new Subject<void>();
22
- const item = { propertyChanged } as NotificableProperty;
23
- queryList.reset([item]);
24
- queryList.notifyOnChanges();
25
-
26
- queryListChanged(queryList)
27
- .pipe(skip(1))
28
- .subscribe((result) => {
29
- expect(result).toEqual([item]);
30
- done();
31
- });
32
-
33
- setTimeout(() => {
34
- propertyChanged.next();
35
- }, 60);
36
- });
37
-
38
- it('should debounce emissions', (done) => {
39
- const propertyChanged = new Subject<void>();
40
- const item = { propertyChanged } as NotificableProperty;
41
- queryList.reset([item]);
42
- queryList.notifyOnChanges();
43
-
44
- const emittedValues: NotificableProperty[][] = [];
45
- queryListChanged(queryList).subscribe((result) => {
46
- emittedValues.push(result);
47
- });
48
-
49
- propertyChanged.next();
50
- propertyChanged.next();
51
-
52
- setTimeout(() => {
53
- expect(emittedValues.length).toBe(1);
54
- expect(emittedValues[0]).toEqual([item]);
55
- done();
56
- }, 100);
57
- });
58
- });
@@ -1,21 +0,0 @@
1
- import { QueryList } from '@angular/core';
2
- import { debounceTime, map, merge, startWith, switchMap } from 'rxjs';
3
- import { NotificableProperty } from './notificable-property.model';
4
-
5
- export function queryListChanged<TEntity>(list: QueryList<TEntity>) {
6
- return list.changes.pipe(
7
- startWith({}),
8
- switchMap(() => {
9
- const actionPropertyChanges$ = list
10
- .toArray()
11
- .filter((action) => (<NotificableProperty>action).propertyChanged)
12
- .map((action) => (<NotificableProperty>action).propertyChanged);
13
-
14
- return merge(...actionPropertyChanges$).pipe(
15
- startWith({}),
16
- map(() => list.toArray())
17
- );
18
- }),
19
- debounceTime(50)
20
- );
21
- }
@@ -1,15 +0,0 @@
1
- import { InjectionToken } from '@angular/core';
2
- import { IconPositionType } from '../../common';
3
- import { ActionButton } from './action-button.model';
4
-
5
- export const ACTION_BUTTON_GROUP_COMPONENT_TOKEN =
6
- new InjectionToken<ActionButtonGroupCore>('ActionButtonGroupComponentToken');
7
-
8
- export interface ActionButtonGroupCore {
9
- maxItems: number;
10
- maxItemsMobile: number;
11
- items: ActionButton[];
12
- menuIconPos: IconPositionType;
13
- menuIcon: string;
14
- label?: string;
15
- }
@@ -1,15 +0,0 @@
1
- import { EventEmitter } from '@angular/core';
2
- import { ControlSeverityType, FieldSizeType, NotificableProperty } from '../../common';
3
-
4
- export interface ActionButton extends NotificableProperty {
5
- disabled: boolean;
6
- toolTip?: string;
7
- id?: string;
8
- icon?: string;
9
- outlined: boolean;
10
- raised: boolean;
11
- severity?: ControlSeverityType;
12
- label?: string;
13
- size?: FieldSizeType;
14
- click: EventEmitter<MouseEvent>;
15
- }
@@ -1,2 +0,0 @@
1
- export * from './action-button-group.model';
2
- export * from './action-button.model';