@aurorajs.dev/core-front 1.0.2 → 1.0.4

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/dist/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # @aurorajs.dev/core-front
2
+
3
+ Shared TypeScript library for Aurora frontend projects. Provides domain-level
4
+ utilities and decorators for managing common UI interactions.
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ npm install @aurorajs.dev/core-front
10
+ ```
11
+
12
+ ### Peer dependencies
13
+
14
+ | Package | Version |
15
+ | --------------------------- | ------- |
16
+ | `@aurorajs.dev/core-common` | ^1.0.3 |
17
+
18
+ ## Usage
19
+
20
+ ```typescript
21
+ import { BlurActiveElement } from '@aurorajs.dev/core-front';
22
+ ```
23
+
24
+ ### Decorators
25
+
26
+ #### `@BlurActiveElement()`
27
+
28
+ Method decorator that blurs the currently focused DOM element before executing
29
+ the decorated method. Prevents UI side effects (visible tooltips, pending
30
+ validations, virtual keyboard) when users trigger actions while an input still
31
+ has focus.
32
+
33
+ ```typescript
34
+ class MyComponent {
35
+ @BlurActiveElement()
36
+ onSubmit(): void {
37
+ // the active element is blurred before this runs
38
+ }
39
+ }
40
+ ```
41
+
42
+ ## Development
43
+
44
+ ```bash
45
+ # Install dependencies
46
+ npm install
47
+
48
+ # Dev mode with watch
49
+ npm run start:dev
50
+
51
+ # Build
52
+ npm run build
53
+
54
+ # Tests
55
+ npm test
56
+ npm run test:watch
57
+ npm run test:cov
58
+
59
+ # Formatting & linting
60
+ npm run format
61
+ npm run lint
62
+ ```
63
+
64
+ ## Build
65
+
66
+ Built with **tsup** producing dual CJS/ESM output targeting ES2021:
67
+
68
+ | Output | Path |
69
+ | ----------------- | ----------------- |
70
+ | ESM | `dist/index.js` |
71
+ | CJS | `dist/index.cjs` |
72
+ | Type declarations | `dist/index.d.ts` |
73
+
74
+ ## Publishing
75
+
76
+ ```bash
77
+ make publish
78
+ ```
79
+
80
+ ## License
81
+
82
+ MIT
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Method decorator that blurs the currently focused DOM element
3
+ * before executing the decorated method.
4
+ *
5
+ * Prevents UI side effects (visible tooltips, pending validations,
6
+ * virtual keyboard on mobile) when the user triggers an action
7
+ * while an input still holds focus.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * @BlurActiveElement()
12
+ * onSave(): void {
13
+ * // The active input has already lost focus at this point
14
+ * this.doSomething();
15
+ * }
16
+ * ```
17
+ */
18
+ export declare function BlurActiveElement(): MethodDecorator;
@@ -0,0 +1 @@
1
+ export * from './blur-active-element.decorator';
@@ -0,0 +1,3 @@
1
+ export * from './decorators';
2
+ export * from './pipes';
3
+ export * from './types';
@@ -1,26 +1,6 @@
1
1
  import { KeyValue } from '@angular/common';
2
2
  import { PipeTransform } from '@angular/core';
3
- import { Operator } from '@aurorajs.dev/core-common';
4
-
5
- /**
6
- * Method decorator that blurs the currently focused DOM element
7
- * before executing the decorated method.
8
- *
9
- * Prevents UI side effects (visible tooltips, pending validations,
10
- * virtual keyboard on mobile) when the user triggers an action
11
- * while an input still holds focus.
12
- *
13
- * @example
14
- * ```typescript
15
- * @BlurActiveElement()
16
- * onSave(): void {
17
- * // The active input has already lost focus at this point
18
- * this.doSomething();
19
- * }
20
- * ```
21
- */
22
- declare function BlurActiveElement(): MethodDecorator;
23
-
3
+ import * as i0 from "@angular/core";
24
4
  /**
25
5
  * Converts a TypeScript string enum into a sorted `KeyValue<string, string>[]`
26
6
  * array, using a custom priority order.
@@ -56,10 +36,8 @@ declare function BlurActiveElement(): MethodDecorator;
56
36
  * @for (type of MyEnum | enumOrder; track type.key) { ... }
57
37
  * ```
58
38
  */
59
- declare class EnumOrderPipe implements PipeTransform {
39
+ export declare class EnumOrderPipe implements PipeTransform {
60
40
  transform(enumObj: Record<string, string>, order?: string[]): KeyValue<string, string>[];
41
+ static ɵfac: i0.ɵɵFactoryDeclaration<EnumOrderPipe, never>;
42
+ static ɵpipe: i0.ɵɵPipeDeclaration<EnumOrderPipe, "enumOrder", true>;
61
43
  }
62
-
63
- type ContactOperator = Operator.and | Operator.or;
64
-
65
- export { BlurActiveElement, type ContactOperator, EnumOrderPipe };
@@ -0,0 +1 @@
1
+ export * from './enum-order.pipe';
@@ -0,0 +1,2 @@
1
+ import { Operator } from '@aurorajs.dev/core-common';
2
+ export type ContactOperator = Operator.and | Operator.or;
@@ -0,0 +1 @@
1
+ export * from './aurora.types';
@@ -0,0 +1,99 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Pipe } from '@angular/core';
3
+
4
+ /**
5
+ * Method decorator that blurs the currently focused DOM element
6
+ * before executing the decorated method.
7
+ *
8
+ * Prevents UI side effects (visible tooltips, pending validations,
9
+ * virtual keyboard on mobile) when the user triggers an action
10
+ * while an input still holds focus.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * @BlurActiveElement()
15
+ * onSave(): void {
16
+ * // The active input has already lost focus at this point
17
+ * this.doSomething();
18
+ * }
19
+ * ```
20
+ */
21
+ function BlurActiveElement() {
22
+ return (target, propertyKey, descriptor) => {
23
+ const originalMethod = descriptor.value;
24
+ descriptor.value = function (...args) {
25
+ const active = document.activeElement;
26
+ if (active && typeof active.blur === 'function') {
27
+ active.blur();
28
+ }
29
+ return originalMethod.apply(this, args);
30
+ };
31
+ return descriptor;
32
+ };
33
+ }
34
+
35
+ /**
36
+ * Converts a TypeScript string enum into a sorted `KeyValue<string, string>[]`
37
+ * array, using a custom priority order.
38
+ *
39
+ * Enum keys present in the `order` array are sorted by their position;
40
+ * keys **not** included are appended at the end in their original declaration order.
41
+ *
42
+ * This pipe is **pure** — Angular only re-evaluates it when the input
43
+ * reference changes.
44
+ *
45
+ * @example
46
+ * ```html
47
+ * <!-- basic usage with custom order -->
48
+ * <mat-select formControlName="type">
49
+ * @for (type of MyEnum | enumOrder: myOrder; track type.key) {
50
+ * <mat-option [value]="type.key">{{ type.value }}</mat-option>
51
+ * }
52
+ * </mat-select>
53
+ * ```
54
+ *
55
+ * ```typescript
56
+ * // in the component
57
+ * myOrder: string[] = [
58
+ * MyEnum.FIRST,
59
+ * MyEnum.SECOND,
60
+ * MyEnum.THIRD,
61
+ * ];
62
+ * ```
63
+ *
64
+ * @example
65
+ * ```html
66
+ * <!-- without order array — keeps original enum declaration order -->
67
+ * @for (type of MyEnum | enumOrder; track type.key) { ... }
68
+ * ```
69
+ */
70
+ class EnumOrderPipe {
71
+ transform(enumObj, order = []) {
72
+ const entries = Object.keys(enumObj).map((key) => ({
73
+ key,
74
+ value: enumObj[key],
75
+ }));
76
+ return entries.sort((a, b) => {
77
+ const indexA = order.indexOf(a.key);
78
+ const indexB = order.indexOf(b.key);
79
+ return ((indexA === -1 ? order.length : indexA) -
80
+ (indexB === -1 ? order.length : indexB));
81
+ });
82
+ }
83
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: EnumOrderPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
84
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.18", ngImport: i0, type: EnumOrderPipe, isStandalone: true, name: "enumOrder" });
85
+ }
86
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: EnumOrderPipe, decorators: [{
87
+ type: Pipe,
88
+ args: [{
89
+ name: 'enumOrder',
90
+ pure: true,
91
+ }]
92
+ }] });
93
+
94
+ /**
95
+ * Generated bundle index. Do not edit.
96
+ */
97
+
98
+ export { BlurActiveElement, EnumOrderPipe };
99
+ //# sourceMappingURL=aurorajs.dev-core-front.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aurorajs.dev-core-front.mjs","sources":["../../src/domain/decorators/blur-active-element.decorator.ts","../../src/domain/pipes/enum-order.pipe.ts","../../src/aurorajs.dev-core-front.ts"],"sourcesContent":["/**\n * Method decorator that blurs the currently focused DOM element\n * before executing the decorated method.\n *\n * Prevents UI side effects (visible tooltips, pending validations,\n * virtual keyboard on mobile) when the user triggers an action\n * while an input still holds focus.\n *\n * @example\n * ```typescript\n * @BlurActiveElement()\n * onSave(): void {\n * // The active input has already lost focus at this point\n * this.doSomething();\n * }\n * ```\n */\nexport function BlurActiveElement(): MethodDecorator {\n return (\n target: any,\n propertyKey: string | symbol,\n descriptor: PropertyDescriptor,\n ) => {\n const originalMethod = descriptor.value;\n\n descriptor.value = function (...args: any[]) {\n const active = document.activeElement as HTMLElement | null;\n\n if (active && typeof active.blur === 'function') {\n active.blur();\n }\n\n return originalMethod.apply(this, args);\n };\n\n return descriptor;\n };\n}\n","import { KeyValue } from '@angular/common';\nimport { Pipe, PipeTransform } from '@angular/core';\n\n/**\n * Converts a TypeScript string enum into a sorted `KeyValue<string, string>[]`\n * array, using a custom priority order.\n *\n * Enum keys present in the `order` array are sorted by their position;\n * keys **not** included are appended at the end in their original declaration order.\n *\n * This pipe is **pure** — Angular only re-evaluates it when the input\n * reference changes.\n *\n * @example\n * ```html\n * <!-- basic usage with custom order -->\n * <mat-select formControlName=\"type\">\n * @for (type of MyEnum | enumOrder: myOrder; track type.key) {\n * <mat-option [value]=\"type.key\">{{ type.value }}</mat-option>\n * }\n * </mat-select>\n * ```\n *\n * ```typescript\n * // in the component\n * myOrder: string[] = [\n * MyEnum.FIRST,\n * MyEnum.SECOND,\n * MyEnum.THIRD,\n * ];\n * ```\n *\n * @example\n * ```html\n * <!-- without order array — keeps original enum declaration order -->\n * @for (type of MyEnum | enumOrder; track type.key) { ... }\n * ```\n */\n@Pipe({\n name: 'enumOrder',\n pure: true,\n})\nexport class EnumOrderPipe implements PipeTransform {\n transform(\n enumObj: Record<string, string>,\n order: string[] = [],\n ): KeyValue<string, string>[] {\n const entries: KeyValue<string, string>[] = Object.keys(enumObj).map(\n (key) => ({\n key,\n value: enumObj[key],\n }),\n );\n\n return entries.sort((a, b) => {\n const indexA = order.indexOf(a.key);\n const indexB = order.indexOf(b.key);\n\n return (\n (indexA === -1 ? order.length : indexA) -\n (indexB === -1 ? order.length : indexB)\n );\n });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;AAgBG;SACa,iBAAiB,GAAA;AAC/B,IAAA,OAAO,CACL,MAAW,EACX,WAA4B,EAC5B,UAA8B,KAC5B;AACF,QAAA,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK;AAEvC,QAAA,UAAU,CAAC,KAAK,GAAG,UAAU,GAAG,IAAW,EAAA;AACzC,YAAA,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAmC;YAE3D,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE;gBAC/C,MAAM,CAAC,IAAI,EAAE;YACf;YAEA,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;AACzC,QAAA,CAAC;AAED,QAAA,OAAO,UAAU;AACnB,IAAA,CAAC;AACH;;AClCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCG;MAKU,aAAa,CAAA;AACxB,IAAA,SAAS,CACP,OAA+B,EAC/B,KAAA,GAAkB,EAAE,EAAA;AAEpB,QAAA,MAAM,OAAO,GAA+B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAClE,CAAC,GAAG,MAAM;YACR,GAAG;AACH,YAAA,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC;AACpB,SAAA,CAAC,CACH;QAED,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAI;YAC3B,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;YACnC,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;AAEnC,YAAA,QACE,CAAC,MAAM,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM;AACtC,iBAAC,MAAM,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;AAE3C,QAAA,CAAC,CAAC;IACJ;wGArBW,aAAa,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,IAAA,EAAA,CAAA;sGAAb,aAAa,EAAA,YAAA,EAAA,IAAA,EAAA,IAAA,EAAA,WAAA,EAAA,CAAA;;4FAAb,aAAa,EAAA,UAAA,EAAA,CAAA;kBAJzB,IAAI;AAAC,YAAA,IAAA,EAAA,CAAA;AACJ,oBAAA,IAAI,EAAE,WAAW;AACjB,oBAAA,IAAI,EAAE,IAAI;AACX,iBAAA;;;ACzCD;;AAEG;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,65 +1 @@
1
- import { KeyValue } from '@angular/common';
2
- import { PipeTransform } from '@angular/core';
3
- import { Operator } from '@aurorajs.dev/core-common';
4
-
5
- /**
6
- * Method decorator that blurs the currently focused DOM element
7
- * before executing the decorated method.
8
- *
9
- * Prevents UI side effects (visible tooltips, pending validations,
10
- * virtual keyboard on mobile) when the user triggers an action
11
- * while an input still holds focus.
12
- *
13
- * @example
14
- * ```typescript
15
- * @BlurActiveElement()
16
- * onSave(): void {
17
- * // The active input has already lost focus at this point
18
- * this.doSomething();
19
- * }
20
- * ```
21
- */
22
- declare function BlurActiveElement(): MethodDecorator;
23
-
24
- /**
25
- * Converts a TypeScript string enum into a sorted `KeyValue<string, string>[]`
26
- * array, using a custom priority order.
27
- *
28
- * Enum keys present in the `order` array are sorted by their position;
29
- * keys **not** included are appended at the end in their original declaration order.
30
- *
31
- * This pipe is **pure** — Angular only re-evaluates it when the input
32
- * reference changes.
33
- *
34
- * @example
35
- * ```html
36
- * <!-- basic usage with custom order -->
37
- * <mat-select formControlName="type">
38
- * @for (type of MyEnum | enumOrder: myOrder; track type.key) {
39
- * <mat-option [value]="type.key">{{ type.value }}</mat-option>
40
- * }
41
- * </mat-select>
42
- * ```
43
- *
44
- * ```typescript
45
- * // in the component
46
- * myOrder: string[] = [
47
- * MyEnum.FIRST,
48
- * MyEnum.SECOND,
49
- * MyEnum.THIRD,
50
- * ];
51
- * ```
52
- *
53
- * @example
54
- * ```html
55
- * <!-- without order array — keeps original enum declaration order -->
56
- * @for (type of MyEnum | enumOrder; track type.key) { ... }
57
- * ```
58
- */
59
- declare class EnumOrderPipe implements PipeTransform {
60
- transform(enumObj: Record<string, string>, order?: string[]): KeyValue<string, string>[];
61
- }
62
-
63
- type ContactOperator = Operator.and | Operator.or;
64
-
65
- export { BlurActiveElement, type ContactOperator, EnumOrderPipe };
1
+ export * from './domain';
package/package.json CHANGED
@@ -1,31 +1,17 @@
1
1
  {
2
2
  "name": "@aurorajs.dev/core-front",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Aurora npm core front package",
5
5
  "author": "José Carlos Rodríguez Palacín <carlos.rodriguez.palacin@gmail.com>",
6
6
  "license": "MIT",
7
7
  "readmeFilename": "README.md",
8
- "main": "./dist/index.cjs",
9
- "module": "./dist/index.js",
8
+ "main": "./dist/esm2022/index.mjs",
10
9
  "types": "./dist/index.d.ts",
11
- "exports": {
12
- ".": {
13
- "import": {
14
- "types": "./dist/index.d.mts",
15
- "default": "./dist/index.js"
16
- },
17
- "require": {
18
- "types": "./dist/index.d.ts",
19
- "default": "./dist/index.cjs"
20
- }
21
- }
22
- },
23
10
  "files": [
24
11
  "dist"
25
12
  ],
26
13
  "scripts": {
27
- "start:dev": "tsup --watch",
28
- "build": "rimraf dist && tsup",
14
+ "build": "ng-packagr -p ng-package.json",
29
15
  "prepare": "husky && npm run build",
30
16
  "format": "prettier --write \"src/**/*.ts\"",
31
17
  "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
@@ -35,11 +21,12 @@
35
21
  "test:e2e": "jest --config ./test/jest-e2e.json"
36
22
  },
37
23
  "peerDependencies": {
38
- "@angular/common": "^19.0.5",
39
- "@angular/compiler": "^19.0.5",
24
+ "@angular/common": ">=19.0.0",
25
+ "@angular/compiler": ">=19.0.0",
40
26
  "@aurorajs.dev/core-common": "^1.0.3"
41
27
  },
42
28
  "devDependencies": {
29
+ "@angular/compiler-cli": "^19.2.18",
43
30
  "@aurorajs.dev/core-common": "^1.0.3",
44
31
  "@commitlint/cli": "^20.4.1",
45
32
  "@commitlint/config-conventional": "^20.4.1",
@@ -50,6 +37,7 @@
50
37
  "eslint-plugin-prettier": "^5.5.5",
51
38
  "husky": "^9.1.7",
52
39
  "jest": "^30.0.0",
40
+ "ng-packagr": "^19.2.2",
53
41
  "prettier": "^3.8.1",
54
42
  "prettier-plugin-organize-attributes": "^1.0.0",
55
43
  "prettier-plugin-organize-imports": "^4.3.0",
@@ -57,7 +45,7 @@
57
45
  "rimraf": "^6.1.2",
58
46
  "ts-jest": "^29.4.6",
59
47
  "tsup": "^8.5.0",
60
- "typescript": "^5.9.3",
48
+ "typescript": "~5.8.0",
61
49
  "typescript-eslint": "^8.55.0"
62
50
  },
63
51
  "jest": {