nx-lecom-helper 1.0.0

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.
@@ -0,0 +1,42 @@
1
+ (function (global) {
2
+ "use strict";
3
+
4
+ if (global.LecomHelper) return;
5
+
6
+ const _state = { debug: false, version: "1.0.0" };
7
+
8
+ function init(options) {
9
+ options = options || {};
10
+ if (typeof options.debug === "boolean") _state.debug = options.debug;
11
+ log("init ok", { version: _state.version });
12
+ }
13
+
14
+ function log(...args) {
15
+ if (_state.debug && global.console) console.log("[LecomHelper]", ...args);
16
+ }
17
+
18
+ function get(obj, path, defaultValue) {
19
+ if (!obj || !path) return defaultValue;
20
+ const parts = String(path).split(".");
21
+ let cur = obj;
22
+ for (const p of parts) {
23
+ if (cur && Object.prototype.hasOwnProperty.call(cur, p)) cur = cur[p];
24
+ else return defaultValue;
25
+ }
26
+ return cur ?? defaultValue;
27
+ }
28
+
29
+ function gridContains(gridRow, fieldName, needle) {
30
+ const val = String(get(gridRow, fieldName, "") || "");
31
+ return val.includes(needle);
32
+ }
33
+
34
+ const api = Object.freeze({ init, get, gridContains, version: _state.version });
35
+
36
+ Object.defineProperty(global, "LecomHelper", {
37
+ value: api,
38
+ writable: false,
39
+ configurable: false
40
+ });
41
+ })(typeof window !== "undefined" ? window : this);
42
+
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "nx-lecom-helper",
3
+ "version": "1.0.0",
4
+ "description": "Utilitários JS para BPM Lecom (API global)",
5
+ "main": "dist/nxLecom-helper.umd.js",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "license": "MIT",
10
+ "private": false,
11
+ "author": {
12
+ "name": "Thiago Costa",
13
+ "email": "thiago.costa@nexum.com.br"
14
+ }
15
+ }