@domql/qsql 0.1.0 → 3.2.7

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/apply.js ADDED
@@ -0,0 +1,21 @@
1
+ import { params } from './params.js'
2
+ import { applyEvents } from './on.js'
3
+
4
+ const isObject = (v) => v !== null && typeof v === 'object' && v.constructor === Object
5
+ const isFunction = (v) => typeof v === 'function'
6
+
7
+ export const apply = (element) => {
8
+ element.nodes.forEach(node => {
9
+ if (isObject(element.on)) applyEvents(element, node)
10
+
11
+ for (const key in element) {
12
+ const elemParam = element[key]
13
+ const param = params[key]
14
+ if (param) param(elemParam, element, node)
15
+ }
16
+
17
+ if (element.on && isFunction(element.on.init)) {
18
+ element.on.init.call(element, element, node)
19
+ }
20
+ })
21
+ }
package/define.js ADDED
@@ -0,0 +1,12 @@
1
+ import { params } from './params.js'
2
+
3
+ export const define = (newParams, options = {}) => {
4
+ const { overwrite } = options
5
+ for (const param in newParams) {
6
+ if (params[param] && !overwrite) {
7
+ console.warn('Can\'t overwrite default params. Use { overwrite: true } to force update')
8
+ } else {
9
+ params[param] = newParams[param]
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,39 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var apply_exports = {};
19
+ __export(apply_exports, {
20
+ apply: () => apply
21
+ });
22
+ module.exports = __toCommonJS(apply_exports);
23
+ var import_params = require("./params.js");
24
+ var import_on = require("./on.js");
25
+ const isObject = (v) => v !== null && typeof v === "object" && v.constructor === Object;
26
+ const isFunction = (v) => typeof v === "function";
27
+ const apply = (element) => {
28
+ element.nodes.forEach((node) => {
29
+ if (isObject(element.on)) (0, import_on.applyEvents)(element, node);
30
+ for (const key in element) {
31
+ const elemParam = element[key];
32
+ const param = import_params.params[key];
33
+ if (param) param(elemParam, element, node);
34
+ }
35
+ if (element.on && isFunction(element.on.init)) {
36
+ element.on.init.call(element, element, node);
37
+ }
38
+ });
39
+ };
@@ -0,0 +1,33 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var define_exports = {};
19
+ __export(define_exports, {
20
+ define: () => define
21
+ });
22
+ module.exports = __toCommonJS(define_exports);
23
+ var import_params = require("./params.js");
24
+ const define = (newParams, options = {}) => {
25
+ const { overwrite } = options;
26
+ for (const param in newParams) {
27
+ if (import_params.params[param] && !overwrite) {
28
+ console.warn("Can't overwrite default params. Use { overwrite: true } to force update");
29
+ } else {
30
+ import_params.params[param] = newParams[param];
31
+ }
32
+ }
33
+ };
@@ -0,0 +1,28 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var find_exports = {};
19
+ __export(find_exports, {
20
+ find: () => find
21
+ });
22
+ module.exports = __toCommonJS(find_exports);
23
+ var import_registry = require("./registry.js");
24
+ const find = (key) => {
25
+ const element = import_registry.REGISTRY[key];
26
+ if (!element) console.warn(`Can't find element "${key}"`);
27
+ return element;
28
+ };
@@ -0,0 +1,41 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var index_exports = {};
19
+ __export(index_exports, {
20
+ REGISTRY: () => import_registry.REGISTRY,
21
+ default: () => index_default,
22
+ define: () => import_define.define,
23
+ find: () => import_find.find,
24
+ methods: () => import_methods.methods,
25
+ query: () => import_query.query,
26
+ setMethod: () => import_methods.setMethod
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+ var import_registry = require("./registry.js");
30
+ var import_query = require("./query.js");
31
+ var import_define = require("./define.js");
32
+ var import_find = require("./find.js");
33
+ var import_methods = require("./methods.js");
34
+ var index_default = {
35
+ REGISTRY: import_registry.REGISTRY,
36
+ query: import_query.query,
37
+ define: import_define.define,
38
+ find: import_find.find,
39
+ methods: import_methods.methods,
40
+ setMethod: import_methods.setMethod
41
+ };
@@ -0,0 +1,30 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var methods_exports = {};
19
+ __export(methods_exports, {
20
+ methods: () => methods,
21
+ setMethod: () => setMethod
22
+ });
23
+ module.exports = __toCommonJS(methods_exports);
24
+ const methods = {};
25
+ const setMethod = (newMethods) => {
26
+ for (const param in newMethods) {
27
+ methods[param] = newMethods[param];
28
+ }
29
+ return methods;
30
+ };
package/dist/cjs/on.js ADDED
@@ -0,0 +1,34 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var on_exports = {};
19
+ __export(on_exports, {
20
+ applyEvents: () => applyEvents
21
+ });
22
+ module.exports = __toCommonJS(on_exports);
23
+ const isFunction = (v) => typeof v === "function";
24
+ const applyEvents = (element, node) => {
25
+ for (const param in element.on) {
26
+ if (param === "init" || param === "render") continue;
27
+ const appliedFunction = element.on[param];
28
+ if (isFunction(appliedFunction)) {
29
+ node.addEventListener(param, (event) => {
30
+ appliedFunction.call(element, event, element, node);
31
+ }, true);
32
+ }
33
+ }
34
+ };
@@ -0,0 +1,77 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var params_exports = {};
19
+ __export(params_exports, {
20
+ params: () => params
21
+ });
22
+ module.exports = __toCommonJS(params_exports);
23
+ const isObject = (v) => v !== null && typeof v === "object" && v.constructor === Object;
24
+ const applyStyle = (params2, element, node) => {
25
+ if (params2 && isObject(params2)) {
26
+ for (const prop in params2) {
27
+ node.style[prop] = params2[prop];
28
+ }
29
+ }
30
+ };
31
+ const applyAttr = (params2, element, node) => {
32
+ if (params2 && isObject(params2)) {
33
+ for (const attr in params2) {
34
+ const val = params2[attr];
35
+ if (val !== false && val !== void 0 && val !== null) {
36
+ node.setAttribute(attr, val);
37
+ } else {
38
+ node.removeAttribute(attr);
39
+ }
40
+ }
41
+ }
42
+ };
43
+ const applyClassList = (params2, element, node) => {
44
+ if (!params2) return;
45
+ if (typeof params2 === "string") {
46
+ node.className = params2;
47
+ } else if (isObject(params2)) {
48
+ let className = "";
49
+ for (const item in params2) {
50
+ const val = params2[item];
51
+ if (val === true) className += ` ${item}`;
52
+ else if (typeof val === "string") className += ` ${val}`;
53
+ }
54
+ node.className = className.trim();
55
+ }
56
+ };
57
+ const applyData = (params2, element, node) => {
58
+ if (params2 && isObject(params2)) {
59
+ for (const key in params2) {
60
+ node.dataset[key] = params2[key];
61
+ }
62
+ }
63
+ };
64
+ const applyText = (param, element, node) => {
65
+ node.textContent = param;
66
+ };
67
+ const applyHtml = (param, element, node) => {
68
+ node.innerHTML = param;
69
+ };
70
+ const params = {
71
+ attr: applyAttr,
72
+ class: applyClassList,
73
+ data: applyData,
74
+ style: applyStyle,
75
+ text: applyText,
76
+ html: applyHtml
77
+ };
@@ -0,0 +1,50 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var query_exports = {};
19
+ __export(query_exports, {
20
+ query: () => query
21
+ });
22
+ module.exports = __toCommonJS(query_exports);
23
+ var import_registry = require("./registry.js");
24
+ var import_apply = require("./apply.js");
25
+ var import_update = require("./update.js");
26
+ var import_methods = require("./methods.js");
27
+ const isNode = (obj) => obj instanceof Node;
28
+ const query = (config) => {
29
+ for (const key in config) {
30
+ const element = config[key];
31
+ const { query: selector, node } = element;
32
+ const nodesArr = [];
33
+ if (node && isNode(node)) {
34
+ nodesArr.push(node);
35
+ } else if (selector) {
36
+ const nodes = document.querySelectorAll(selector);
37
+ if (nodes.length === 0) console.warn(`Could not find element "${key}"`);
38
+ nodes.forEach((n) => nodesArr.push(n));
39
+ }
40
+ element.nodes = nodesArr;
41
+ element.key = key;
42
+ element.update = import_update.update;
43
+ for (const name in import_methods.methods) {
44
+ if (key !== name) element[name] = import_methods.methods[name];
45
+ }
46
+ import_registry.REGISTRY[key] = element;
47
+ (0, import_apply.apply)(element);
48
+ }
49
+ return import_registry.REGISTRY;
50
+ };
@@ -0,0 +1,23 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var registry_exports = {};
19
+ __export(registry_exports, {
20
+ REGISTRY: () => REGISTRY
21
+ });
22
+ module.exports = __toCommonJS(registry_exports);
23
+ const REGISTRY = {};
@@ -0,0 +1,40 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var update_exports = {};
19
+ __export(update_exports, {
20
+ update: () => update
21
+ });
22
+ module.exports = __toCommonJS(update_exports);
23
+ var import_params = require("./params.js");
24
+ var import_on = require("./on.js");
25
+ const isObject = (v) => v !== null && typeof v === "object" && v.constructor === Object;
26
+ const isFunction = (v) => typeof v === "function";
27
+ const update = function(newParams) {
28
+ const element = this;
29
+ element.nodes.forEach((node) => {
30
+ if (isObject(newParams.on)) (0, import_on.applyEvents)(element, node);
31
+ for (const param in newParams) {
32
+ const newParam = newParams[param];
33
+ const hasParam = import_params.params[param];
34
+ if (hasParam) hasParam(newParam, element, node);
35
+ }
36
+ });
37
+ if (element.on && isFunction(element.on.update)) {
38
+ element.on.update.call(element, element);
39
+ }
40
+ };
@@ -0,0 +1,20 @@
1
+ import { params } from "./params.js";
2
+ import { applyEvents } from "./on.js";
3
+ const isObject = (v) => v !== null && typeof v === "object" && v.constructor === Object;
4
+ const isFunction = (v) => typeof v === "function";
5
+ const apply = (element) => {
6
+ element.nodes.forEach((node) => {
7
+ if (isObject(element.on)) applyEvents(element, node);
8
+ for (const key in element) {
9
+ const elemParam = element[key];
10
+ const param = params[key];
11
+ if (param) param(elemParam, element, node);
12
+ }
13
+ if (element.on && isFunction(element.on.init)) {
14
+ element.on.init.call(element, element, node);
15
+ }
16
+ });
17
+ };
18
+ export {
19
+ apply
20
+ };
@@ -0,0 +1,14 @@
1
+ import { params } from "./params.js";
2
+ const define = (newParams, options = {}) => {
3
+ const { overwrite } = options;
4
+ for (const param in newParams) {
5
+ if (params[param] && !overwrite) {
6
+ console.warn("Can't overwrite default params. Use { overwrite: true } to force update");
7
+ } else {
8
+ params[param] = newParams[param];
9
+ }
10
+ }
11
+ };
12
+ export {
13
+ define
14
+ };
@@ -0,0 +1,9 @@
1
+ import { REGISTRY } from "./registry.js";
2
+ const find = (key) => {
3
+ const element = REGISTRY[key];
4
+ if (!element) console.warn(`Can't find element "${key}"`);
5
+ return element;
6
+ };
7
+ export {
8
+ find
9
+ };
@@ -0,0 +1,22 @@
1
+ import { REGISTRY } from "./registry.js";
2
+ import { query } from "./query.js";
3
+ import { define } from "./define.js";
4
+ import { find } from "./find.js";
5
+ import { methods, setMethod } from "./methods.js";
6
+ var index_default = {
7
+ REGISTRY,
8
+ query,
9
+ define,
10
+ find,
11
+ methods,
12
+ setMethod
13
+ };
14
+ export {
15
+ REGISTRY,
16
+ index_default as default,
17
+ define,
18
+ find,
19
+ methods,
20
+ query,
21
+ setMethod
22
+ };
@@ -0,0 +1,11 @@
1
+ const methods = {};
2
+ const setMethod = (newMethods) => {
3
+ for (const param in newMethods) {
4
+ methods[param] = newMethods[param];
5
+ }
6
+ return methods;
7
+ };
8
+ export {
9
+ methods,
10
+ setMethod
11
+ };
package/dist/esm/on.js ADDED
@@ -0,0 +1,15 @@
1
+ const isFunction = (v) => typeof v === "function";
2
+ const applyEvents = (element, node) => {
3
+ for (const param in element.on) {
4
+ if (param === "init" || param === "render") continue;
5
+ const appliedFunction = element.on[param];
6
+ if (isFunction(appliedFunction)) {
7
+ node.addEventListener(param, (event) => {
8
+ appliedFunction.call(element, event, element, node);
9
+ }, true);
10
+ }
11
+ }
12
+ };
13
+ export {
14
+ applyEvents
15
+ };
@@ -0,0 +1,58 @@
1
+ const isObject = (v) => v !== null && typeof v === "object" && v.constructor === Object;
2
+ const applyStyle = (params2, element, node) => {
3
+ if (params2 && isObject(params2)) {
4
+ for (const prop in params2) {
5
+ node.style[prop] = params2[prop];
6
+ }
7
+ }
8
+ };
9
+ const applyAttr = (params2, element, node) => {
10
+ if (params2 && isObject(params2)) {
11
+ for (const attr in params2) {
12
+ const val = params2[attr];
13
+ if (val !== false && val !== void 0 && val !== null) {
14
+ node.setAttribute(attr, val);
15
+ } else {
16
+ node.removeAttribute(attr);
17
+ }
18
+ }
19
+ }
20
+ };
21
+ const applyClassList = (params2, element, node) => {
22
+ if (!params2) return;
23
+ if (typeof params2 === "string") {
24
+ node.className = params2;
25
+ } else if (isObject(params2)) {
26
+ let className = "";
27
+ for (const item in params2) {
28
+ const val = params2[item];
29
+ if (val === true) className += ` ${item}`;
30
+ else if (typeof val === "string") className += ` ${val}`;
31
+ }
32
+ node.className = className.trim();
33
+ }
34
+ };
35
+ const applyData = (params2, element, node) => {
36
+ if (params2 && isObject(params2)) {
37
+ for (const key in params2) {
38
+ node.dataset[key] = params2[key];
39
+ }
40
+ }
41
+ };
42
+ const applyText = (param, element, node) => {
43
+ node.textContent = param;
44
+ };
45
+ const applyHtml = (param, element, node) => {
46
+ node.innerHTML = param;
47
+ };
48
+ const params = {
49
+ attr: applyAttr,
50
+ class: applyClassList,
51
+ data: applyData,
52
+ style: applyStyle,
53
+ text: applyText,
54
+ html: applyHtml
55
+ };
56
+ export {
57
+ params
58
+ };
@@ -0,0 +1,31 @@
1
+ import { REGISTRY } from "./registry.js";
2
+ import { apply } from "./apply.js";
3
+ import { update } from "./update.js";
4
+ import { methods } from "./methods.js";
5
+ const isNode = (obj) => obj instanceof Node;
6
+ const query = (config) => {
7
+ for (const key in config) {
8
+ const element = config[key];
9
+ const { query: selector, node } = element;
10
+ const nodesArr = [];
11
+ if (node && isNode(node)) {
12
+ nodesArr.push(node);
13
+ } else if (selector) {
14
+ const nodes = document.querySelectorAll(selector);
15
+ if (nodes.length === 0) console.warn(`Could not find element "${key}"`);
16
+ nodes.forEach((n) => nodesArr.push(n));
17
+ }
18
+ element.nodes = nodesArr;
19
+ element.key = key;
20
+ element.update = update;
21
+ for (const name in methods) {
22
+ if (key !== name) element[name] = methods[name];
23
+ }
24
+ REGISTRY[key] = element;
25
+ apply(element);
26
+ }
27
+ return REGISTRY;
28
+ };
29
+ export {
30
+ query
31
+ };
@@ -0,0 +1,4 @@
1
+ const REGISTRY = {};
2
+ export {
3
+ REGISTRY
4
+ };
@@ -0,0 +1,21 @@
1
+ import { params } from "./params.js";
2
+ import { applyEvents } from "./on.js";
3
+ const isObject = (v) => v !== null && typeof v === "object" && v.constructor === Object;
4
+ const isFunction = (v) => typeof v === "function";
5
+ const update = function(newParams) {
6
+ const element = this;
7
+ element.nodes.forEach((node) => {
8
+ if (isObject(newParams.on)) applyEvents(element, node);
9
+ for (const param in newParams) {
10
+ const newParam = newParams[param];
11
+ const hasParam = params[param];
12
+ if (hasParam) hasParam(newParam, element, node);
13
+ }
14
+ });
15
+ if (element.on && isFunction(element.on.update)) {
16
+ element.on.update.call(element, element);
17
+ }
18
+ };
19
+ export {
20
+ update
21
+ };