@aurorajs.dev/core-front 1.0.1
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/README.md +82 -0
- package/dist/index.cjs +45 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/package.json +81 -0
package/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
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
BlurActiveElement: () => BlurActiveElement
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/domain/decorators/blur-active-element.decorator.ts
|
|
28
|
+
function BlurActiveElement() {
|
|
29
|
+
return (target, propertyKey, descriptor) => {
|
|
30
|
+
const originalMethod = descriptor.value;
|
|
31
|
+
descriptor.value = function(...args) {
|
|
32
|
+
const active = document.activeElement;
|
|
33
|
+
if (active && typeof active.blur === "function") {
|
|
34
|
+
active.blur();
|
|
35
|
+
}
|
|
36
|
+
return originalMethod.apply(this, args);
|
|
37
|
+
};
|
|
38
|
+
return descriptor;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
BlurActiveElement
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/domain/decorators/blur-active-element.decorator.ts"],"sourcesContent":["export * from './domain';\n","/**\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiBO,SAAS,oBAAqC;AACnD,SAAO,CACL,QACA,aACA,eACG;AACH,UAAM,iBAAiB,WAAW;AAElC,eAAW,QAAQ,YAAa,MAAa;AAC3C,YAAM,SAAS,SAAS;AAExB,UAAI,UAAU,OAAO,OAAO,SAAS,YAAY;AAC/C,eAAO,KAAK;AAAA,MACd;AAEA,aAAO,eAAe,MAAM,MAAM,IAAI;AAAA,IACxC;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
declare function BlurActiveElement(): MethodDecorator;
|
|
19
|
+
|
|
20
|
+
export { BlurActiveElement };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
declare function BlurActiveElement(): MethodDecorator;
|
|
19
|
+
|
|
20
|
+
export { BlurActiveElement };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/domain/decorators/blur-active-element.decorator.ts
|
|
2
|
+
function BlurActiveElement() {
|
|
3
|
+
return (target, propertyKey, descriptor) => {
|
|
4
|
+
const originalMethod = descriptor.value;
|
|
5
|
+
descriptor.value = function(...args) {
|
|
6
|
+
const active = document.activeElement;
|
|
7
|
+
if (active && typeof active.blur === "function") {
|
|
8
|
+
active.blur();
|
|
9
|
+
}
|
|
10
|
+
return originalMethod.apply(this, args);
|
|
11
|
+
};
|
|
12
|
+
return descriptor;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
BlurActiveElement
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/domain/decorators/blur-active-element.decorator.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"],"mappings":";AAiBO,SAAS,oBAAqC;AACnD,SAAO,CACL,QACA,aACA,eACG;AACH,UAAM,iBAAiB,WAAW;AAElC,eAAW,QAAQ,YAAa,MAAa;AAC3C,YAAM,SAAS,SAAS;AAExB,UAAI,UAAU,OAAO,OAAO,SAAS,YAAY;AAC/C,eAAO,KAAK;AAAA,MACd;AAEA,aAAO,eAAe,MAAM,MAAM,IAAI;AAAA,IACxC;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aurorajs.dev/core-front",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Aurora npm core front package",
|
|
5
|
+
"author": "José Carlos Rodríguez Palacín <carlos.rodriguez.palacin@gmail.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"readmeFilename": "README.md",
|
|
8
|
+
"main": "./dist/index.cjs",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"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
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"start:dev": "tsup --watch",
|
|
28
|
+
"build": "rimraf dist && tsup",
|
|
29
|
+
"prepare": "husky && npm run build",
|
|
30
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
31
|
+
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
|
32
|
+
"test": "jest",
|
|
33
|
+
"test:watch": "jest --watch",
|
|
34
|
+
"test:cov": "jest --coverage",
|
|
35
|
+
"test:e2e": "jest --config ./test/jest-e2e.json"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@aurorajs.dev/core-common": "^1.0.3"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@aurorajs.dev/core-common": "^1.0.3",
|
|
42
|
+
"@commitlint/cli": "^20.4.1",
|
|
43
|
+
"@commitlint/config-conventional": "^20.4.1",
|
|
44
|
+
"@types/jest": "^30.0.0",
|
|
45
|
+
"@types/node": "^25.2.3",
|
|
46
|
+
"eslint": "^9.0.0",
|
|
47
|
+
"eslint-config-prettier": "^10.1.8",
|
|
48
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
49
|
+
"husky": "^9.1.7",
|
|
50
|
+
"jest": "^30.0.0",
|
|
51
|
+
"prettier": "^3.8.1",
|
|
52
|
+
"prettier-plugin-organize-attributes": "^1.0.0",
|
|
53
|
+
"prettier-plugin-organize-imports": "^4.3.0",
|
|
54
|
+
"prettier-plugin-tailwindcss": "^0.7.2",
|
|
55
|
+
"rimraf": "^6.1.2",
|
|
56
|
+
"ts-jest": "^29.4.6",
|
|
57
|
+
"tsup": "^8.5.0",
|
|
58
|
+
"typescript": "^5.9.3",
|
|
59
|
+
"typescript-eslint": "^8.55.0"
|
|
60
|
+
},
|
|
61
|
+
"jest": {
|
|
62
|
+
"moduleFileExtensions": [
|
|
63
|
+
"js",
|
|
64
|
+
"json",
|
|
65
|
+
"ts"
|
|
66
|
+
],
|
|
67
|
+
"rootDir": "src",
|
|
68
|
+
"testRegex": ".*\\.spec\\.ts$",
|
|
69
|
+
"transform": {
|
|
70
|
+
"^.+\\.(t|j)s$": "ts-jest"
|
|
71
|
+
},
|
|
72
|
+
"collectCoverageFrom": [
|
|
73
|
+
"**/*.(t|j)s"
|
|
74
|
+
],
|
|
75
|
+
"coverageDirectory": "../coverage",
|
|
76
|
+
"testEnvironment": "node"
|
|
77
|
+
},
|
|
78
|
+
"publishConfig": {
|
|
79
|
+
"access": "public"
|
|
80
|
+
}
|
|
81
|
+
}
|