New:Socket for Asana Is Now Available.Learn more
Get Started

@aurorajs.dev/core-front

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aurorajs.dev/core-front - npm Package Compare versions

Comparing version
1.0.7
to
1.0.8
+18
dist/domain/decorators/blur-active-element.decorator.d.ts
/**
* Method decorator that blurs the currently focused DOM element
* before executing the decorated method.
*
* Prevents UI side effects (visible tooltips, pending validations,
* virtual keyboard on mobile) when the user triggers an action
* while an input still holds focus.
*
* @example
* ```typescript
* @BlurActiveElement()
* onSave(): void {
* // The active input has already lost focus at this point
* this.doSomething();
* }
* ```
*/
export declare function BlurActiveElement(): MethodDecorator;
export * from './blur-active-element.decorator';
export * from './decorators';
export * from './pipes';
export * from './types';
import { KeyValue } from '@angular/common';
import { PipeTransform } from '@angular/core';
import * as i0 from "@angular/core";
/**
* Converts a TypeScript string enum into a sorted `KeyValue<string, string>[]`
* array, using a custom priority order.
*
* Enum keys present in the `order` array are sorted by their position;
* keys **not** included are appended at the end in their original declaration order.
*
* This pipe is **pure** — Angular only re-evaluates it when the input
* reference changes.
*
* @example
* ```html
* <!-- basic usage with custom order -->
* <mat-select formControlName="type">
* @for (type of MyEnum | enumOrder: myOrder; track type.key) {
* <mat-option [value]="type.key">{{ type.value }}</mat-option>
* }
* </mat-select>
* ```
*
* ```typescript
* // in the component
* myOrder: string[] = [
* MyEnum.FIRST,
* MyEnum.SECOND,
* MyEnum.THIRD,
* ];
* ```
*
* @example
* ```html
* <!-- without order array — keeps original enum declaration order -->
* @for (type of MyEnum | enumOrder; track type.key) { ... }
* ```
*/
export declare class EnumOrderPipe implements PipeTransform {
transform(enumObj: Record<string, string>, order?: string[]): KeyValue<string, string>[];
static ɵfac: i0.ɵɵFactoryDeclaration<EnumOrderPipe, never>;
static ɵpipe: i0.ɵɵPipeDeclaration<EnumOrderPipe, "enumOrder", true>;
}
export * from './enum-order.pipe';
import { Operator } from '@aurorajs.dev/core-common';
export type ContactOperator = Operator.and | Operator.or;
export * from './aurora.types';
import * as i0 from '@angular/core';
import { Pipe } from '@angular/core';
/**
* Method decorator that blurs the currently focused DOM element
* before executing the decorated method.
*
* Prevents UI side effects (visible tooltips, pending validations,
* virtual keyboard on mobile) when the user triggers an action
* while an input still holds focus.
*
* @example
* ```typescript
* @BlurActiveElement()
* onSave(): void {
* // The active input has already lost focus at this point
* this.doSomething();
* }
* ```
*/
function BlurActiveElement() {
return (target, propertyKey, descriptor) => {
const originalMethod = descriptor.value;
descriptor.value = function (...args) {
const active = document.activeElement;
if (active && typeof active.blur === 'function') {
active.blur();
}
return originalMethod.apply(this, args);
};
return descriptor;
};
}
/**
* Converts a TypeScript string enum into a sorted `KeyValue<string, string>[]`
* array, using a custom priority order.
*
* Enum keys present in the `order` array are sorted by their position;
* keys **not** included are appended at the end in their original declaration order.
*
* This pipe is **pure** — Angular only re-evaluates it when the input
* reference changes.
*
* @example
* ```html
* <!-- basic usage with custom order -->
* <mat-select formControlName="type">
* @for (type of MyEnum | enumOrder: myOrder; track type.key) {
* <mat-option [value]="type.key">{{ type.value }}</mat-option>
* }
* </mat-select>
* ```
*
* ```typescript
* // in the component
* myOrder: string[] = [
* MyEnum.FIRST,
* MyEnum.SECOND,
* MyEnum.THIRD,
* ];
* ```
*
* @example
* ```html
* <!-- without order array — keeps original enum declaration order -->
* @for (type of MyEnum | enumOrder; track type.key) { ... }
* ```
*/
class EnumOrderPipe {
transform(enumObj, order = []) {
const entries = Object.keys(enumObj).map((key) => ({
key,
value: enumObj[key],
}));
return entries.sort((a, b) => {
const indexA = order.indexOf(a.key);
const indexB = order.indexOf(b.key);
return ((indexA === -1 ? order.length : indexA) -
(indexB === -1 ? order.length : indexB));
});
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: EnumOrderPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.18", ngImport: i0, type: EnumOrderPipe, isStandalone: true, name: "enumOrder" });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: EnumOrderPipe, decorators: [{
type: Pipe,
args: [{
name: 'enumOrder',
pure: true,
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { BlurActiveElement, EnumOrderPipe };
//# sourceMappingURL=aurorajs.dev-core-front.mjs.map
{"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;;;;"}
export * from './domain';
# @aurorajs.dev/core-front
Shared TypeScript library for Aurora frontend projects. Provides domain-level
utilities and decorators for managing common UI interactions.
## Installation
```bash
npm install @aurorajs.dev/core-front
```
### Peer dependencies
| Package | Version |
| --------------------------- | ------- |
| `@aurorajs.dev/core-common` | ^1.0.3 |
## Usage
```typescript
import { BlurActiveElement } from '@aurorajs.dev/core-front';
```
### Decorators
#### `@BlurActiveElement()`
Method decorator that blurs the currently focused DOM element before executing
the decorated method. Prevents UI side effects (visible tooltips, pending
validations, virtual keyboard) when users trigger actions while an input still
has focus.
```typescript
class MyComponent {
@BlurActiveElement()
onSubmit(): void {
// the active element is blurred before this runs
}
}
```
## Development
```bash
# Install dependencies
npm install
# Dev mode with watch
npm run start:dev
# Build
npm run build
# Tests
npm test
npm run test:watch
npm run test:cov
# Formatting & linting
npm run format
npm run lint
```
## Build
Built with **tsup** producing dual CJS/ESM output targeting ES2021:
| Output | Path |
| ----------------- | ----------------- |
| ESM | `dist/index.js` |
| CJS | `dist/index.cjs` |
| Type declarations | `dist/index.d.ts` |
## Publishing
```bash
make publish
```
## License
MIT
+50
-16
{
"name": "@aurorajs.dev/core-front",
"version": "1.0.7",
"version": "1.0.8",
"description": "Aurora npm core front package",

@@ -11,2 +11,12 @@ "author": "José Carlos Rodríguez Palacín <carlos.rodriguez.palacin@gmail.com>",

],
"scripts": {
"build": "ng-packagr -p ng-package.json",
"prepare": "husky && npm run build",
"format": "prettier --write \"src/**/*.ts\"",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"peerDependencies": {

@@ -17,20 +27,44 @@ "@angular/common": ">=19.0.0",

},
"publishConfig": {
"access": "public"
"devDependencies": {
"@angular/compiler-cli": "^19.2.18",
"@aurorajs.dev/core-common": "^1.0.3",
"@commitlint/cli": "^20.4.1",
"@commitlint/config-conventional": "^20.4.1",
"@types/jest": "^30.0.0",
"@types/node": "^25.2.3",
"eslint": "^9.0.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-prettier": "^5.5.5",
"husky": "^9.1.7",
"jest": "^30.0.0",
"ng-packagr": "^19.2.2",
"prettier": "^3.8.1",
"prettier-plugin-organize-attributes": "^1.0.0",
"prettier-plugin-organize-imports": "^4.3.0",
"prettier-plugin-tailwindcss": "^0.7.2",
"rimraf": "^6.1.2",
"ts-jest": "^29.4.6",
"typescript": "~5.8.0",
"typescript-eslint": "^8.55.0"
},
"module": "fesm2022/aurorajs.dev-core-front.mjs",
"typings": "index.d.ts",
"exports": {
"./package.json": {
"default": "./package.json"
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
".": {
"types": "./index.d.ts",
"default": "./fesm2022/aurorajs.dev-core-front.mjs"
}
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
},
"sideEffects": false,
"dependencies": {
"tslib": "^2.3.0"
"publishConfig": {
"access": "public"
}
}
}