mirror of
https://github.com/FJurmanovic/wallet-web.git
synced 2026-02-06 06:08:10 +00:00
custom app form
This commit is contained in:
@@ -4,3 +4,5 @@ export { default as index } from "./index-deco";
|
||||
export { default as closest } from "./closest-deco";
|
||||
export { default as isTrue } from "./isTrue";
|
||||
export { default as firstUpper } from "./first-upper";
|
||||
export { default as query } from "./query-deco";
|
||||
export { default as querys } from "./querys-deco";
|
||||
|
||||
15
src/core/utils/query-deco.ts
Normal file
15
src/core/utils/query-deco.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { toKebabCase } from "core/utils";
|
||||
|
||||
export default function query(proto: Object, key: string): any {
|
||||
const kebab: string = toKebabCase(key);
|
||||
return Object.defineProperty(proto, key, {
|
||||
configurable: true,
|
||||
get() {
|
||||
return findQuery(this, kebab);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function findQuery(element: HTMLElement, key: string): HTMLElement {
|
||||
return element.querySelector(key);
|
||||
}
|
||||
18
src/core/utils/querys-deco.ts
Normal file
18
src/core/utils/querys-deco.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { toKebabCase } from "core/utils";
|
||||
|
||||
export default function querys(proto: Object, key: string): any {
|
||||
const kebab: string = toKebabCase(key);
|
||||
return Object.defineProperty(proto, key, {
|
||||
configurable: true,
|
||||
get() {
|
||||
return findQuerys(this, kebab);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function findQuerys(
|
||||
element: HTMLElement,
|
||||
key: string
|
||||
): NodeListOf<HTMLElement> {
|
||||
return element.querySelectorAll(key);
|
||||
}
|
||||
Reference in New Issue
Block a user